Location: PHPKode > projects > PhpScribe Documentation Generator > config/scribe.inc
<?php
//-------------------------------------------------------------------------------------------------
// Verifica a versão do PHP
if (!version_compare(PHP_VERSION, '4.1.0', '>=') == -1) {
     echo "<FONT COLOR='#FF0000'>phpScribe requires PHP 4.1.0 at least. You're running PHP ".PHP_VERSION.". Update PHP in order to use phpScribe normally.</FONT>";
     exit;
}

//-------------------------------------------------------------------------------------------------
// Carrega as configurações setadas pelo usuário
if (!file_exists(dirname(__FILE__) . "/user.cfg")) {
     echo "<FONT COLOR='#FF0000' STYLE='font-size:16px'><B>WARNING!</B></FONT><BR>If this is your first time using phpScribe, read the lines below carefully.<BR><BR>";
     echo "<FONT COLOR='#FF0000'>It wasn't possible to find the file <B>user.cfg</B> in phpScribe's folder or it may contain errors.<BR>You must configure the installation settings correctly to start using the system.<BR>Therefore, you'll be redirected to the phpScribe installer in a while...<BR><BR>If your browser doesn't support META refresh, <A HREF='install.php' STYLE='color:#ff0000;text-decoration:underline;font-weight:bold'>click here</A> to go directly to the installer.</FONT>";
     echo "<META HTTP-EQUIV=\"refresh\" content=\"8; URL=install.php\">";
     exit;
} else include_once("user.cfg");

//-------------------------------------------------------------------------------------------------
// Verifica se o caminho global foi configurado corretamente
if (!isset($PS_USER_CFG['GLOBAL_PATH'])) {
     echo "<FONT COLOR='#FF0000'>You didn't set the 'GLOBAL_PATH' in your user configuration file!<BR><BR>You'll be redirected to the phpScribe installer in a while...<BR><BR>If your browser doesn't support META refresh, <A HREF='install.php' STYLE='color:#ff0000;text-decoration:underline;font-weight:bold'>click here</A> to go directly to the installer.</FONT>";
     echo "<META HTTP-EQUIV=\"refresh\" content=\"8; URL=install.php\">";
     exit;
}
else {
     // retira '/' do final
     if ($PS_USER_CFG['GLOBAL_PATH'][strlen($PS_USER_CFG['GLOBAL_PATH'])-1] == "/") {
          $PS_USER_CFG['GLOBAL_PATH'] = substr($PS_USER_CFG['GLOBAL_PATH'],0,strlen($PS_USER_CFG['GLOBAL_PATH'])-1);
     }
     if (!file_exists($PS_USER_CFG['GLOBAL_PATH']."/install.php")) {
     echo "<FONT COLOR='#FF0000'>The system couldn't find the phpScribe's main file index.php.<BR>Is the server path value right?<BR><BR>You'll be redirected to the phpScribe installer in a while...<BR><BR>If your browser doesn't support META refresh, <A HREF='install.php' STYLE='color:#ff0000;text-decoration:underline;font-weight:bold'>click here</A> to go directly to the installer.</FONT>";
     echo "<META HTTP-EQUIV=\"refresh\" content=\"8; URL=install.php\">";
     exit;
     }
}

//-------------------------------------------------------------------------------------------------
// Verifica se o caminho absoluto (url) foi configurado corretamente
if (!isset($PS_USER_CFG['ABSOLUTE_PATH'])) {
     echo "<FONT COLOR='#FF0000'>You didn't set the 'ABSOLUTE_PATH' in your user configuration file!<BR><BR>You'll be redirected to the phpScribe installer in a while...<BR><BR>If your browser doesn't support META refresh, <A HREF='install.php' STYLE='color:#ff0000;text-decoration:underline;font-weight:bold'>click here</A> to go directly to the installer.</FONT>";
     echo "<META HTTP-EQUIV=\"refresh\" content=\"8; URL=install.php\">";
     exit;
}
else if (!ereg("WIN",strtoupper(PHP_OS))) {
     // retira 'http://' do início
     if (substr($PS_USER_CFG['ABSOLUTE_PATH'],0,7) == "http://") {
          $hostname = substr($PS_USER_CFG['ABSOLUTE_PATH'],7,strlen($PS_USER_CFG['ABSOLUTE_PATH'])-7);
     } else {
          $hostname = $PS_USER_CFG['ABSOLUTE_PATH'];
     }
     // retira '/' do final
     if ($hostname[strlen($hostname)-1] == "/") {
          $hostname = substr($hostname,0,strlen($hostname)-1);
     }
     //if (!checkdnsrr($hostname,"ANY")) {
     //     echo "<FONT COLOR='#FF0000'>The system couldn't reach the provided absolute path (phpScribe's URL location)<BR>Is the path value right? Check the DNS settings in the server.<BR><BR>You'll be redirected to the phpScribe installer in a while...<BR><BR>If your browser doesn't support META refresh, <A HREF='install.php' STYLE='color:#ff0000;text-decoration:underline;font-weight:bold'>click here</A> to go directly to the installer.</FONT>";
     //     echo "<META HTTP-EQUIV=\"refresh\" content=\"8; URL=install.php\">";
     //     exit;
     //}
}

//-------------------------------------------------------------------------------------------------
// Cria as constantes para os caminhos básicos do sistema
//-------------------------------------------------------------------------------------------------
// Inserção da barra final no caminho absoluto
if ($PS_USER_CFG['ABSOLUTE_PATH'][strlen($PS_USER_CFG['ABSOLUTE_PATH'])-1] != '/') {
     $absPath = $PS_USER_CFG['ABSOLUTE_PATH']."/";
} else {
     $absPath = $PS_USER_CFG['ABSOLUTE_PATH'];
}
define("PHPSCRIBE_ABSOLUTE_PATH",          $absPath);
//-------------------------------------------------------------------------------------------------
// Inserção da barra final no caminho do servidor
if ($PS_USER_CFG['GLOBAL_PATH'][strlen($PS_USER_CFG['GLOBAL_PATH'])-1] != '/') {
     $glbPath = $PS_USER_CFG['GLOBAL_PATH']."/";
} else {
     $glbPath = $PS_USER_CFG['GLOBAL_PATH'];
}
define("PHPSCRIBE_GLOBAL_PATH",            $glbPath);
define("PHPSCRIBE_ADODB_PATH",             PHPSCRIBE_GLOBAL_PATH."adodb/");
define("PHPSCRIBE_CLASS_PATH",             PHPSCRIBE_GLOBAL_PATH."classes/");
define("PHPSCRIBE_IMAGE_PATH",             PHPSCRIBE_ABSOLUTE_PATH."resources/image/");
define("PHPSCRIBE_JAVASCRIPT_PATH",        PHPSCRIBE_ABSOLUTE_PATH."resources/javascript/");
define("PHPSCRIBE_LIBRARY_PATH",           PHPSCRIBE_GLOBAL_PATH."libraries/");
define("PHPSCRIBE_LANGUAGE_PATH",          PHPSCRIBE_GLOBAL_PATH."languages/");
define("PHPSCRIBE_SKINS_PATH",             PHPSCRIBE_ABSOLUTE_PATH."resources/docskins/");
define("PHPSCRIBE_STYLE_PATH",             PHPSCRIBE_ABSOLUTE_PATH."resources/stylesheet/");
define("PHPSCRIBE_TEMPLATE_PATH",          PHPSCRIBE_GLOBAL_PATH."templates/");
define("PHPSCRIBE_XML_PATH",               PHPSCRIBE_GLOBAL_PATH."xml/");

//-------------------------------------------------------------------------------------------------
// Cria as constantes para os caminhos das bibliotecas e classes do phpScribe
define("PHPSCRIBE_CLASS_DATABASE",         PHPSCRIBE_CLASS_PATH."Db.class");
define("PHPSCRIBE_CLASS_DOCGENERATOR",     PHPSCRIBE_CLASS_PATH."DocGenerator.class");
define("PHPSCRIBE_CLASS_FILEDOCPARSER",    PHPSCRIBE_CLASS_PATH."FileDocParser.class");
define("PHPSCRIBE_CLASS_FOOTER",           PHPSCRIBE_CLASS_PATH."Footer.class");
define("PHPSCRIBE_CLASS_FORM",             PHPSCRIBE_CLASS_PATH."Form.class");
define("PHPSCRIBE_CLASS_FORMTEMPLATE",     PHPSCRIBE_CLASS_PATH."FormTemplate.class");
define("PHPSCRIBE_CLASS_HEADER",           PHPSCRIBE_CLASS_PATH."Header.class");
define("PHPSCRIBE_CLASS_HTML",             PHPSCRIBE_CLASS_PATH."Html.class");
define("PHPSCRIBE_CLASS_MENU",             PHPSCRIBE_CLASS_PATH."Menu.class");
define("PHPSCRIBE_CLASS_REPORT",           PHPSCRIBE_CLASS_PATH."Report.class");
define("PHPSCRIBE_CLASS_TEMPLATE",         PHPSCRIBE_CLASS_PATH."Template.class");
define("PHPSCRIBE_CLASS_XML",              PHPSCRIBE_CLASS_PATH."Xml.class");
define("PHPSCRIBE_CLASS_ZIP",              PHPSCRIBE_CLASS_PATH."Zip.class");
define("PHPSCRIBE_LIB_FUNCTIONS",          PHPSCRIBE_LIBRARY_PATH."Main.lib");
define("PHPSCRIBE_LIB_GZDOC",              PHPSCRIBE_LIBRARY_PATH."Gzdoc.lib");
define("PHPSCRIBE_PAGESIZE",               760);
define("PHPSCRIBE_TITLE",                  ":::: p h p S c r i b e ::::");
define("PHPSCRIBE_VERSION",                "0.9");
define("PHPSCRIBE_RELEASE_DATE",           "11/12/2003");

//-------------------------------------------------------------------------------------------------
// Configurações de linguagem do phpScribe
// Requisita o arquivo de linguagem configurado pelo usuário
// Se o arquivo não existir, exibe erro
// Para valor em branco, requisita a biblioteca pt-br (Português Brasileiro)
if (isset($PS_USER_CFG['LANGUAGE'])) {
     switch($PS_USER_CFG['LANGUAGE']) {
          case "en-us" : require_once(PHPSCRIBE_LANGUAGE_PATH."en-us.inc");
                         break;
          default      : trigger_error("The <B>".$PS_USER_CFG['LANGUAGE']."</B> language is not supported");
     }
} else {
     include(dirname(__FILE__) . "/../languages/en-us.inc");
     //require_once(PHPSCRIBE_LANGUAGE_PATH."en-us.inc");
}

//-------------------------------------------------------------------------------------------------
// Carrega o arquivo de tratamento de erros do phpScribe
require_once(PHPSCRIBE_GLOBAL_PATH . "errorHandler.inc");

//-------------------------------------------------------------------------------------------------
// Configuração do tratador de erros
// Modifica as configurações do PHP para tratar somente os erros fatais
// Direciona os demais erros para um tratador específico do phpScribe
error_reporting(E_ERROR | E_PARSE | E_COMPILE_ERROR);
$handler = set_error_handler("phpScribeErrorHandler");

//-------------------------------------------------------------------------------------------------
// Carrega a biblioteca principal de funções
require_once(PHPSCRIBE_LIB_FUNCTIONS);

//-------------------------------------------------------------------------------------------------
// Carrega a classe de acesso a banco de dados
require_once(PHPSCRIBE_CLASS_DATABASE);

//-------------------------------------------------------------------------------------------------
// Retira os magic_quotes dos super globals, se estiverem habilitados
if (get_magic_quotes_gpc()) {
	foreach($_GET as $k=>$v) $_GET["$k"]=stripslashes($v);
	foreach($_POST as $k=>$v) $_POST["$k"]=stripslashes($v);
	foreach($_COOKIE as $k=>$v) $_COOKIE["$k"]=stripslashes($v);
}

//-------------------------------------------------------------------------------------------------
// Testa a conexão com o banco de dados e as tabelas
require_once('dbinstall.php');
if ( (isset($PS_USER_CFG['DATABASE_HOST'])) && (isset($PS_USER_CFG['DATABASE_USER'])) && (isset($PS_USER_CFG['DATABASE_PASS'])) ) {
     $PS_USER_CFG['SHOW_ERRORS'] = FALSE;
     if (!function_exists("mysql_connect")) {
          echo "<FONT COLOR='#FF0000'><B>FATAL ERROR!</B><BR><BR>Your server doesn't have mySQL support. phpScribe's not able to run without a functional mySQL database.</FONT><BR><BR><A HREF='http://www.mysql.com' STYLE='color:#ff0000;text-decoration:underline;font-weight:bold' TARGET='_blank'>Wanna download mySQL?</A>";
          exit;
     } else if (!$link = @mysql_connect($PS_USER_CFG['DATABASE_HOST'],$PS_USER_CFG['DATABASE_USER'],$PS_USER_CFG['DATABASE_PASS'])) {
          $PS_USER_CFG['SHOW_ERRORS'] = TRUE;
          echo "<FONT COLOR='#FF0000'>It wasn't possible to connect to yout mySQL database using the current settings!<BR><BR>You'll be redirected to the phpScribe installer in a while...<BR><BR>If your browser doesn't support META refresh, <A HREF='install.php' STYLE='color:#ff0000;text-decoration:underline;font-weight:bold'>click here</A> to go directly to the installer.</FONT>";
          echo "<META HTTP-EQUIV=\"refresh\" content=\"8; URL=install.php\">";
          exit;
     } else if (!@mysql_select_db($PS_USER_CFG['DATABASE_BASE'],$link)) {
          echo "<BR><FONT COLOR='#FF0000'>It wasn't possible to select the provided database <B>".$PS_USER_CFG['DATABASE_BASE']."</B>!<BR><BR>You'll be redirected to the phpScribe installer in a while...<BR><BR>If your browser doesn't support META refresh, <A HREF='install.php' STYLE='color:#ff0000;text-decoration:underline;font-weight:bold'>click here</A> to go directly to the installer.</FONT><BR><BR>";
          echo "<META HTTP-EQUIV=\"refresh\" content=\"8; URL=install.php\">";
          exit;
     } else {
          $DB = new Db();
          $tables = $DB->conn->MetaTables();
          $missingTables = array();
          if (!in_array("class", $tables)) {
               $missingTables[] = "class";
          }
          if (!in_array("constant", $tables)) {
               $missingTables[] = "constant";
          }
          if (!in_array("example", $tables)) {
               $missingTables[] = "example";
          }
          if (!in_array("file", $tables)) {
               $missingTables[] = "file";
          }
          if (!in_array("file_type", $tables)) {
               $missingTables[] = "file_type";
          }
          if (!in_array("function", $tables)) {
               $missingTables[] = "function";
          }
          if (!in_array("note", $tables)) {
               $missingTables[] = "note";
          }
          if (!in_array("package", $tables)) {
               $missingTables[] = "package";
          }          
          if (!in_array("param", $tables)) {
               $missingTables[] = "param";
          }
          if (!in_array("project", $tables)) {
               $missingTables[] = "project";
          }
          if (!in_array("property", $tables)) {
               $missingTables[] = "property";
          }
          if (!in_array("revision", $tables)) {
               $missingTables[] = "revision";
          }
          if (!in_array("see", $tables)) {
               $missingTables[] = "see";
          }
          if (!in_array("uses", $tables)) {
               $missingTables[] = "uses";
          }
          if (!empty($missingTables)) {
               echo "<FONT COLOR='#FF0000'>The following phpScribe's system tables weren't found in your database:<BR><B>".implode(",",$missingTables)."</B><BR><BR>You'll be redirected to the phpScribe installer in a while...<BR><BR>If your browser doesn't support META refresh, <A HREF='install.php#step2' STYLE='color:#ff0000;text-decoration:underline;font-weight:bold'>click here</A> to go directly to the installer.</FONT>";
               echo "<META HTTP-EQUIV=\"refresh\" content=\"8; URL=install.php#step2\">";
               exit;
          }
     }
}
?>
Return current item: PhpScribe Documentation Generator