示例#1
0
 function getReplacedConnectionFileForSimpleApp($arguments = "")
 {
     $rootFolder = FILES_TO_COPY_PHP_TEMPLATE_SIMPLE;
     $rootCommon = $rootFolder . FILE_SEPARATOR . "common";
     if ($arguments != "") {
         $thisDb = $arguments['db'];
     }
     if (HAVE_AUTHENTICATION) {
         $dbUserName = $_SESSION['dbUserName'];
         $dbHostName = $_SESSION['dbHostName'];
         $encDbPassword = $_SESSION['dbPassword'];
         $thisEncrypter = new textEncrypter();
         $unEncodedDbPassword = $thisEncrypter->decode($encDbPassword);
     } else {
         $dbUserName = DATABASE_USER_NAME;
         $dbHostName = DATABASE_HOST;
         $unEncodedDbPassword = DATABASE_PASSWORD;
     }
     // DB CONNECTION FILE TO REPLACE
     $replacePair = array();
     $replacePair[] = new pair("{DB_HOST}", $dbHostName);
     $replacePair[] = new pair("{DB_USER}", $dbUserName);
     $replacePair[] = new pair("{DB_PASSWORD}", $unEncodedDbPassword);
     $replacePair[] = new pair("{DB_NAME}", $thisDb);
     $dbConnectionFileName = $rootCommon . FILE_SEPARATOR . "dbConnection.php";
     $newDbConnectionText = stringUtils::replaceStringInFileAndReturnString($dbConnectionFileName, $replacePair);
     return $newDbConnectionText;
 }
示例#2
0
 function setConnectionParameters()
 {
     if (HAVE_AUTHENTICATION) {
         $dbUserName = $_SESSION['dbUserName'];
         $dbType = $_SESSION['dbType'];
         $dbHostName = $_SESSION['dbHostName'];
         $encDbPassword = $_SESSION['dbPassword'];
         $thisEncrypter = new textEncrypter();
         $unEncodedDbPassword = $thisEncrypter->decode($encDbPassword);
         $this->setDatabaseType($dbType);
         $this->setDatabaseHost($dbHostName);
         $this->setDbPassword($unEncodedDbPassword);
         $this->setDbUserName($dbUserName);
     } else {
         $this->setDatabaseType(DATABASE_SERVER_TO_USE);
         $this->setDatabaseHost(DATABASE_HOST);
         $this->setDbPassword(DATABASE_PASSWORD);
         $this->setDbUserName(DATABASE_USER_NAME);
     }
 }
 function setDatabaseConnectionVariablesFromSession()
 {
     $dbUserName = $_SESSION['dbUserName'];
     $dbType = $_SESSION['dbType'];
     $dbHostName = $_SESSION['dbHostName'];
     $encDbPassword = $_SESSION['dbPassword'];
     $thisEncrypter = new textEncrypter();
     $unEncodedDbPassword = $thisEncrypter->decode($encDbPassword);
     $this->setDatabaseType($dbType);
     $this->setDatabaseHost($dbHostName);
     $this->setDatabasePassword($unEncodedDbPassword);
     $this->setDatabaseUserName($dbUserName);
     //$this->setDatabaseToUse(DATABASE_NAME);
 }
 function generate()
 {
     $code = "";
     if ($_SESSION['dbSession']) {
         $dbUserName = $_SESSION['dbUserName'];
         $dbType = $_SESSION['dbType'];
         $dbHostName = $_SESSION['dbHostName'];
         $encDbPassword = $_SESSION['dbPassword'];
         $thisEncrypter = new textEncrypter();
         $dbPassword = $thisEncrypter->decode($encDbPassword);
     } else {
         $dbUserName = DATABASE_USER_NAME;
         $dbType = DATABASE_SERVER_TO_USE;
         $dbHostName = DATABASE_HOST;
         $dbPassword = DATABASE_PASSWORD;
     }
     if (FILE_SEPARATOR == "\\") {
         $fileSeparator = "\\\\";
     } else {
         $fileSeparator = FILE_SEPARATOR;
     }
     $code .= "<?\n";
     $code .= "/*\n";
     $code .= "This is the main Configuration file for your gip generated application.\n\n";
     $code .= "This file need to put in the include directory of php or you need to add the directory where this file is located to the php include path list\n\n";
     $code .= "Please change the configuration below when moving to a new server.\n\n";
     $code .= "*/\n\n";
     $code .= "// Web Address (URL) of your Website\n";
     $code .= "define(\"URL_ROOT_ADDRESS\",\"" . $this->getUrlAddress() . "\");\n";
     $code .= "define(\"URL_ADDRESS\",URL_ROOT_ADDRESS.\"/web\");\n\n";
     $code .= "// Location of your Source code (absolute Paths)\n";
     $code .= "define(\"SITE_PATH\",\"" . $this->getSiteRoot() . "\");             // no trailing slashes (e.g windows : c:\\server\\myWebsite, *nix : /usr/local/apache/myWebsite)\n";
     $code .= "define(\"FILE_SEPARATOR\", \"" . $fileSeparator . "\");       // Different OS use different File Separators (e.g windows : \\, *nix : / )\n";
     $code .= "define(\"WEB_SEPARATOR\",\"/\");                        // Just in case url token separator change at some point in time :)\n\n";
     $code .= "// Database Configuration\n";
     $code .= "define(\"DATABASE_SERVER_TO_USE\",\"" . $dbType . "\");            // Adodb Database Type to use (e.g mysql, oracle, postgres..)\n";
     $code .= "define(\"DATABASE_HOST\", \"" . $dbHostName . "\");                    // Address of your database server (could be hostname or ipaddress)\n";
     $code .= "define(\"DATABASE_USER_NAME\",\"" . $dbUserName . "\");           // User to connect to database as\n";
     $code .= "define(\"DATABASE_PASSWORD\",\"" . $dbPassword . "\");             // Password to connect to database\n";
     $code .= "define(\"DATABASE_NAME\",\"" . $this->getDb() . "\");                     // Database Name (for oraclle, that'll be empty)\n\n";
     $code .= "// Application Basic Paths - DO NOT CHANGE THESE\n";
     $code .= "define(\"APP_PATH\",SITE_PATH.FILE_SEPARATOR.\"app\");\n";
     $code .= "define(\"WEB_PATH\",SITE_PATH.FILE_SEPARATOR.\"web\");\n";
     $code .= "define(\"CONFIG_COMPONENT\",SITE_PATH.FILE_SEPARATOR.\"config\");\n";
     $code .= "define(\"CONFIG_FILE\",CONFIG_COMPONENT.FILE_SEPARATOR.\"configuration.inc.php\");\n\n";
     $code .= "?>";
     $this->appendToCode($code);
     return $this->getSourceCode();
 }