function initialize() { $line = array(); $merchantArray = array(); $handle = @fopen('./litle_SDK_config.ini', "w"); if ($handle) { print "Welcome to Litle PHP_SDK" . PHP_EOL; print "Please input your user name: "; $line['user'] = trim(fgets(STDIN)); print "Please input your password: "******"Please input your merchantId: "; $line['currency_merchant_map ']['DEFAULT'] = trim(fgets(STDIN)); print "Please choose Litle url from the following list (example: 'cert') or directly input another URL: \nsandbox => https://www.testlitle.com/sandbox/communicator/online \ncert => https://cert.litle.com/vap/communicator/online \nprecert => https://precert.litle.com/vap/communicator/online \nproduction1 => https://payments.litle.com/vap/communicator/online \nproduction2 => https://payments2.litle.com/vap/communicator/online" . PHP_EOL; $url = urlMapper(trim(fgets(STDIN))); $line['url'] = $url; print "Please input the proxy, if no proxy hit enter key: "; $line['proxy'] = trim(fgets(STDIN)); writeConfig($line, $handle); fwrite($handle, "version = 8.10" . PHP_EOL); fwrite($handle, "timeout = 65" . PHP_EOL); fwrite($handle, "reportGroup = planets" . PHP_EOL); } fclose($handle); print "The Litle configuration file has been generated, the file is located in the lib directory" . PHP_EOL; }
/** * Milestone 0.9 - shaarli/Shaarli#41: options.php is not supported anymore. * ==> if user is loggedIn, merge its content with config.php, then delete options.php. * * @param array $config contains all configuration fields. * @param bool $isLoggedIn true if user is logged in. * * @return void */ function mergeDeprecatedConfig($config, $isLoggedIn) { $config_file = $config['config']['CONFIG_FILE']; if (is_file($config['config']['DATADIR'] . '/options.php') && $isLoggedIn) { include $config['config']['DATADIR'] . '/options.php'; // Load GLOBALS into config foreach ($GLOBALS as $key => $value) { $config[$key] = $value; } $config['config']['CONFIG_FILE'] = $config_file; writeConfig($config, $isLoggedIn); unlink($config['config']['DATADIR'] . '/options.php'); } }
function initialize() { $line = array(); $merchantArray = array(); $handle = @fopen('./litle_SDK_config.ini', "w"); if ($handle) { print "Welcome to Litle PHP_SDK" . PHP_EOL; print "Please input your user name: "; $line['user'] = trim(fgets(STDIN)); print "Please input your password: "******"Please input your merchantId: "; $line['currency_merchant_map ']['DEFAULT'] = trim(fgets(STDIN)); print "Please choose Litle url from the following list (example: 'sandbox') or directly input another URL: \nsandbox => https://www.testlitle.com/sandbox/communicator/online \npostlive => https://postlive.litle.com/vap/communicator/online \ntransact-postlive => https://transact-postlive.litle.com/vap/communicator/online \nproduction => https://payments.litle.com/vap/communicator/online \nproduction-transact => https://transact.litle.com/vap/communicator/online \nprelive => https://prelive.litle.com/vap/communicator/online \ntransact-prelive => https://transact-prelive.litle.com/vap/communicator/online" . PHP_EOL; $url = UrlMapper::getUrl(trim(fgets(STDIN))); $line['url'] = $url; print "Please input the proxy, if no proxy hit enter key: "; $line['proxy'] = trim(fgets(STDIN)); print "Batch processing saves files to disk. \n"; print "Please input a directory to save these files. If you are not using batch processing, you may hit enter. "; $dir = trim(fgets(STDIN)); $line['batch_requests_path'] = $dir; $line['litle_requests_path'] = $dir; print "Please input your SFTP username. If you are not using SFTP, you may hit enter. "; $line['sftp_username'] = trim(fgets(STDIN)); print "Please input your SFTP password. If you are not using SFTP, you may hit enter. "; $line['sftp_password'] = trim(fgets(STDIN)); print "Please input the URL for batch processing. If you are not using batch processing, you may hit enter. "; $line['batch_url'] = trim(fgets(STDIN)); print "Please input the port for stream batch delivery. If you are not using stream batch delivery, you may hit enter. "; $line['tcp_port'] = trim(fgets(STDIN)); print "Please input the timeout (in seconds) for stream batch delivery. If you are not using stream batch delivery, you may hit enter. "; $line['tcp_timeout'] = trim(fgets(STDIN)); # ssl should be usd by default $line['tcp_ssl'] = '1'; $line['print_xml'] = '0'; writeConfig($line, $handle); fwrite($handle, "timeout = 65" . PHP_EOL); fwrite($handle, "reportGroup = Default Report Group" . PHP_EOL); } fclose($handle); print "The Litle configuration file has been generated, the file is located in the lib directory" . PHP_EOL; }
function install(&$Page, $fields) { global $warnings; $database_connection_error = false; try { $db = new MySQL(); $db->connect($fields['database']['host'], $fields['database']['username'], $fields['database']['password'], $fields['database']['port']); $tables = $db->fetch(sprintf("SHOW TABLES FROM `%s` LIKE '%s'", mysql_escape_string($fields['database']['name']), mysql_escape_string($fields['database']['prefix']) . '%')); } catch (DatabaseException $e) { $database_connection_error = true; } ## Invalid path if (!@is_dir(rtrim($fields['docroot'], '/') . '/symphony')) { $Page->log->pushToLog("Configuration - Bad Document Root Specified: " . $fields['docroot'], E_NOTICE, true); define("kENVIRONMENT_WARNING", true); if (!defined("ERROR")) { define("ERROR", 'no-symphony-dir'); } } elseif (is_file(rtrim($fields['docroot'], '/') . '/.htaccess')) { $Page->log->pushToLog("Configuration - Existing '.htaccess' file found: " . $fields['docroot'] . '/.htaccess', E_NOTICE, true); define("kENVIRONMENT_WARNING", true); if (!defined("ERROR")) { define("ERROR", 'existing-htaccess'); } } elseif (is_dir(rtrim($fields['docroot'], '/') . '/workspace') && !is_writable(rtrim($fields['docroot'], '/') . '/workspace')) { $Page->log->pushToLog("Configuration - Workspace folder not writable: " . $fields['docroot'] . '/workspace', E_NOTICE, true); define("kENVIRONMENT_WARNING", true); if (!defined("ERROR")) { define("ERROR", 'no-write-permission-workspace'); } } elseif (!is_writable(rtrim($fields['docroot'], '/'))) { $Page->log->pushToLog("Configuration - Root folder not writable: " . $fields['docroot'], E_NOTICE, true); define("kENVIRONMENT_WARNING", true); if (!defined("ERROR")) { define("ERROR", 'no-write-permission-root'); } } elseif ($database_connection_error) { $Page->log->pushToLog("Configuration - Could not establish database connection", E_NOTICE, true); define("kDATABASE_CONNECTION_WARNING", true); if (!defined("ERROR")) { define("ERROR", 'no-database-connection'); } } elseif (version_compare($db->fetchVar('version', 0, "SELECT VERSION() AS `version`;"), '4.1', '<')) { $version = $db->fetchVar('version', 0, "SELECT VERSION() AS `version`;"); $Page->log->pushToLog('Configuration - MySQL Version is not correct. ' . $version . ' detected.', E_NOTICE, true); define("kDATABASE_VERSION_WARNING", true); $warnings['database-incorrect-version'] = __('Symphony requires <code>MySQL 4.1</code> or greater to work, however version <code>%s</code> was detected. This requirement must be met before installation can proceed.', array($version)); if (!defined("ERROR")) { define("ERROR", 'database-incorrect-version'); } } elseif (!$db->select($fields['database']['name'])) { $Page->log->pushToLog("Configuration - Database '" . $fields['database']['name'] . "' Not Found", E_NOTICE, true); define("kDATABASE_CONNECTION_WARNING", true); if (!defined("ERROR")) { define("ERROR", 'no-database-connection'); } } elseif (is_array($tables) && !empty($tables)) { $Page->log->pushToLog("Configuration - Database table prefix clash with '" . $fields['database']['name'] . "'", E_NOTICE, true); define("kDATABASE_PREFIX_WARNING", true); if (!defined("ERROR")) { define("ERROR", 'database-table-clash'); } } elseif (trim($fields['user']['username']) == '') { $Page->log->pushToLog("Configuration - No username entered.", E_NOTICE, true); define("kUSER_USERNAME_WARNING", true); if (!defined("ERROR")) { define("ERROR", 'user-no-username'); } } elseif (trim($fields['user']['password']) == '') { $Page->log->pushToLog("Configuration - No password entered.", E_NOTICE, true); define("kUSER_PASSWORD_WARNING", true); if (!defined("ERROR")) { define("ERROR", 'user-no-password'); } } elseif ($fields['user']['password'] != $fields['user']['confirm-password']) { $Page->log->pushToLog("Configuration - Passwords did not match.", E_NOTICE, true); define("kUSER_PASSWORD_WARNING", true); if (!defined("ERROR")) { define("ERROR", 'user-password-mismatch'); } } elseif (trim($fields['user']['firstname']) == '' || trim($fields['user']['lastname']) == '') { $Page->log->pushToLog("Configuration - Did not enter First and Last names.", E_NOTICE, true); define("kUSER_NAME_WARNING", true); if (!defined("ERROR")) { define("ERROR", 'user-no-name'); } } elseif (!preg_match('/^\\w(?:\\.?[\\w%+-]+)*@\\w(?:[\\w-]*\\.)+?[a-z]{2,}$/i', $fields['user']['email'])) { $Page->log->pushToLog("Configuration - Invalid email address supplied.", E_NOTICE, true); define("kUSER_EMAIL_WARNING", true); if (!defined("ERROR")) { define("ERROR", 'user-invalid-email'); } } else { $config = $fields; $kDOCROOT = rtrim($config['docroot'], '/'); $database = array_map("trim", $fields['database']); if (!isset($database['host']) || $database['host'] == "") { $database['host'] = "localhost"; } if (!isset($database['port']) || $database['port'] == "") { $database['port'] = "3306"; } if (!isset($database['prefix']) || $database['prefix'] == "") { $database['prefix'] = "sym_"; } $install_log = $Page->log; $start = time(); $install_log->writeToLog(CRLF . '============================================', true); $install_log->writeToLog('INSTALLATION PROCESS STARTED (' . DateTimeObj::get('c') . ')', true); $install_log->writeToLog('============================================', true); $install_log->pushToLog("MYSQL: Establishing Connection...", E_NOTICE, true, false); $db = new MySQL(); if (!$db->connect($database['host'], $database['username'], $database['password'], $database['port'])) { define('_INSTALL_ERRORS_', "There was a problem while trying to establish a connection to the MySQL server. Please check your settings."); $install_log->pushToLog("Failed", E_NOTICE, true, true, true); installResult($Page, $install_log, $start); } else { $install_log->pushToLog("Done", E_NOTICE, true, true, true); } $install_log->pushToLog("MYSQL: Selecting Database '" . $database['name'] . "'...", E_NOTICE, true, false); if (!$db->select($database['name'])) { define('_INSTALL_ERRORS_', "Could not connect to specified database. Please check your settings."); $install_log->pushToLog("Failed", E_NOTICE, true, true, true); installResult($Page, $install_log, $start); } else { $install_log->pushToLog("Done", E_NOTICE, true, true, true); } $db->setPrefix($database['prefix']); $conf = getDynamicConfiguration(); if ($conf['database']['runtime_character_set_alter'] == '1') { $db->setCharacterEncoding($conf['database']['character_encoding']); $db->setCharacterSet($conf['database']['character_set']); } $install_log->pushToLog("MYSQL: Importing Table Schema...", E_NOTICE, true, false); $error = NULL; if (!fireSql($db, getTableSchema(), $error, $config['database']['high-compatibility'] == 'yes' ? 'high' : 'normal')) { define('_INSTALL_ERRORS_', "There was an error while trying to import data to the database. MySQL returned: {$error}"); $install_log->pushToLog("Failed", E_ERROR, true, true, true); installResult($Page, $install_log, $start); } else { $install_log->pushToLog("Done", E_NOTICE, true, true, true); } $author_sql = sprintf("INSERT INTO `tbl_authors` (\n\t\t\t\t\t\t`id` , \n\t\t\t\t\t\t`username` , \n\t\t\t\t\t\t`password` , \n\t\t\t\t\t\t`first_name` , \n\t\t\t\t\t\t`last_name` , \n\t\t\t\t\t\t`email` , \n\t\t\t\t\t\t`last_seen` , \n\t\t\t\t\t\t`user_type` , \n\t\t\t\t\t\t`primary` , \n\t\t\t\t\t\t`default_section` , \n\t\t\t\t\t\t`auth_token_active`\n\t\t\t\t\t)\n\t\t\t\t\tVALUES (\n\t\t\t\t\t\t1,\n\t\t\t\t\t\t'%s',\n\t\t\t\t\t\tMD5('%s'),\n\t\t\t\t\t\t'%s', \n\t\t\t\t\t\t'%s', \n\t\t\t\t\t\t'%s', \n\t\t\t\t\t\tNULL , \n\t\t\t\t\t\t'developer', \n\t\t\t\t\t\t'yes', \n\t\t\t\t\t\t'6', \n\t\t\t\t\t\t'no'\n\t\t\t\t\t);", $db->cleanValue($config['user']['username']), $db->cleanValue($config['user']['password']), $db->cleanValue($config['user']['firstname']), $db->cleanValue($config['user']['lastname']), $db->cleanValue($config['user']['email'])); $install_log->pushToLog("MYSQL: Creating Default Author...", E_NOTICE, true, false); if (!$db->query($author_sql)) { $error = $db->getLastError(); define('_INSTALL_ERRORS_', "There was an error while trying create the default author. MySQL returned: " . $error['num'] . ': ' . $error['msg']); $install_log->pushToLog("Failed", E_ERROR, true, true, true); installResult($Page, $install_log, $start); } else { $install_log->pushToLog("Done", E_NOTICE, true, true, true); } $conf = array(); if (@is_dir($fields['docroot'] . '/workspace')) { foreach (getDynamicConfiguration() as $group => $settings) { if (!is_array($conf['settings'][$group])) { $conf['settings'][$group] = array(); } $conf['settings'][$group] = array_merge($conf['settings'][$group], $settings); } } else { $conf['settings']['admin']['max_upload_size'] = '5242880'; $conf['settings']['symphony']['pagination_maximum_rows'] = '17'; $conf['settings']['symphony']['allow_page_subscription'] = '1'; $conf['settings']['symphony']['lang'] = defined('__LANG__') ? __LANG__ : 'en'; $conf['settings']['symphony']['pages_table_nest_children'] = 'no'; $conf['settings']['log']['archive'] = '1'; $conf['settings']['log']['maxsize'] = '102400'; $conf['settings']['image']['cache'] = '1'; $conf['settings']['image']['quality'] = '90'; $conf['settings']['database']['driver'] = 'mysql'; $conf['settings']['database']['character_set'] = 'utf8'; $conf['settings']['database']['character_encoding'] = 'utf8'; $conf['settings']['database']['runtime_character_set_alter'] = '1'; $conf['settings']['public']['display_event_xml_in_source'] = 'no'; } $conf['settings']['symphony']['version'] = kVERSION; $conf['settings']['symphony']['cookie_prefix'] = 'sym-'; $conf['settings']['general']['useragent'] = 'Symphony/' . kVERSION; $conf['settings']['general']['sitename'] = strlen(trim($config['general']['sitename'])) > 0 ? $config['general']['sitename'] : __('Website Name'); $conf['settings']['file']['write_mode'] = $config['permission']['file']; $conf['settings']['directory']['write_mode'] = $config['permission']['directory']; $conf['settings']['database']['host'] = $database['host']; $conf['settings']['database']['port'] = $database['port']; $conf['settings']['database']['user'] = $database['username']; $conf['settings']['database']['password'] = $database['password']; $conf['settings']['database']['db'] = $database['name']; $conf['settings']['database']['tbl_prefix'] = $database['prefix']; $conf['settings']['region']['time_format'] = $config['region']['time_format']; $conf['settings']['region']['date_format'] = $config['region']['date_format']; $conf['settings']['region']['timezone'] = $config['region']['timezone']; ## Create Manifest directory structure # $install_log->pushToLog("WRITING: Creating 'manifest' folder (/manifest)", E_NOTICE, true, true); if (!GeneralExtended::realiseDirectory($kDOCROOT . '/manifest', $conf['settings']['directory']['write_mode'])) { define('_INSTALL_ERRORS_', "Could not create 'manifest' directory. Check permission on the root folder."); $install_log->pushToLog("ERROR: Creation of 'manifest' folder failed.", E_ERROR, true, true); installResult($Page, $install_log, $start); return; } $install_log->pushToLog("WRITING: Creating 'logs' folder (/manifest/logs)", E_NOTICE, true, true); if (!GeneralExtended::realiseDirectory($kDOCROOT . '/manifest/logs', $conf['settings']['directory']['write_mode'])) { define('_INSTALL_ERRORS_', "Could not create 'logs' directory. Check permission on /manifest."); $install_log->pushToLog("ERROR: Creation of 'logs' folder failed.", E_ERROR, true, true); installResult($Page, $install_log, $start); return; } $install_log->pushToLog("WRITING: Creating 'cache' folder (/manifest/cache)", E_NOTICE, true, true); if (!GeneralExtended::realiseDirectory($kDOCROOT . '/manifest/cache', $conf['settings']['directory']['write_mode'])) { define('_INSTALL_ERRORS_', "Could not create 'cache' directory. Check permission on /manifest."); $install_log->pushToLog("ERROR: Creation of 'cache' folder failed.", E_ERROR, true, true); installResult($Page, $install_log, $start); return; } $install_log->pushToLog("WRITING: Creating 'tmp' folder (/manifest/tmp)", E_NOTICE, true, true); if (!GeneralExtended::realiseDirectory($kDOCROOT . '/manifest/tmp', $conf['settings']['directory']['write_mode'])) { define('_INSTALL_ERRORS_', "Could not create 'tmp' directory. Check permission on /manifest."); $install_log->pushToLog("ERROR: Creation of 'tmp' folder failed.", E_ERROR, true, true); installResult($Page, $install_log, $start); return; } $install_log->pushToLog("WRITING: Configuration File", E_NOTICE, true, true); if (!writeConfig($kDOCROOT . '/manifest/', $conf, $conf['settings']['file']['write_mode'])) { define('_INSTALL_ERRORS_', "Could not write config file. Check permission on /manifest."); $install_log->pushToLog("ERROR: Writing Configuration File Failed", E_ERROR, true, true); installResult($Page, $install_log, $start); } $rewrite_base = trim(dirname($_SERVER['PHP_SELF']), '/'); if (strlen($rewrite_base) > 0) { $rewrite_base .= '/'; } $htaccess = ' ### Symphony 2.0.x ### Options +FollowSymlinks <IfModule mod_rewrite.c> RewriteEngine on RewriteBase /' . $rewrite_base . ' ### DO NOT APPLY RULES WHEN REQUESTING "favicon.ico" RewriteCond %{REQUEST_FILENAME} favicon.ico [NC] RewriteRule .* - [S=14] ### IMAGE RULES RewriteRule ^image\\/(.+\\.(jpg|gif|jpeg|png|bmp))$ extensions/jit_image_manipulation/lib/image.php?param=$1 [L,NC] ### CHECK FOR TRAILING SLASH - Will ignore files RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_URI} !/$ RewriteCond %{REQUEST_URI} !(.*)/$ RewriteRule ^(.*)$ $1/ [L,R=301] ### ADMIN REWRITE RewriteRule ^symphony\\/?$ index.php?mode=administration&%{QUERY_STRING} [NC,L] RewriteCond %{REQUEST_FILENAME} !-d RewriteCond %{REQUEST_FILENAME} !-f RewriteRule ^symphony(\\/(.*\\/?))?$ index.php?symphony-page=$1&mode=administration&%{QUERY_STRING} [NC,L] ### FRONTEND REWRITE - Will ignore files and folders RewriteCond %{REQUEST_FILENAME} !-d RewriteCond %{REQUEST_FILENAME} !-f RewriteRule ^(.*\\/?)$ index.php?symphony-page=$1&%{QUERY_STRING} [L] </IfModule> ###### '; $install_log->pushToLog("CONFIGURING: Frontend", E_NOTICE, true, true); if (!GeneralExtended::writeFile($kDOCROOT . "/.htaccess", $htaccess, $conf['settings']['file']['write_mode'])) { define('_INSTALL_ERRORS_', "Could not write .htaccess file. Check permission on " . $kDOCROOT); $install_log->pushToLog("ERROR: Writing .htaccess File Failed", E_ERROR, true, true); installResult($Page, $install_log, $start); } if (@(!is_dir($fields['docroot'] . '/workspace'))) { ### Create the workspace folder structure # $install_log->pushToLog("WRITING: Creating 'workspace' folder (/workspace)", E_NOTICE, true, true); if (!GeneralExtended::realiseDirectory($kDOCROOT . '/workspace', $conf['settings']['directory']['write_mode'])) { define('_INSTALL_ERRORS_', "Could not create 'workspace' directory. Check permission on the root folder."); $install_log->pushToLog("ERROR: Creation of 'workspace' folder failed.", E_ERROR, true, true); installResult($Page, $install_log, $start); return; } $install_log->pushToLog("WRITING: Creating 'data-sources' folder (/workspace/data-sources)", E_NOTICE, true, true); if (!GeneralExtended::realiseDirectory($kDOCROOT . '/workspace/data-sources', $conf['settings']['directory']['write_mode'])) { define('_INSTALL_ERRORS_', "Could not create 'workspace/data-sources' directory. Check permission on the root folder."); $install_log->pushToLog("ERROR: Creation of 'workspace/data-sources' folder failed.", E_ERROR, true, true); installResult($Page, $install_log, $start); return; } $install_log->pushToLog("WRITING: Creating 'events' folder (/workspace/events)", E_NOTICE, true, true); if (!GeneralExtended::realiseDirectory($kDOCROOT . '/workspace/events', $conf['settings']['directory']['write_mode'])) { define('_INSTALL_ERRORS_', "Could not create 'workspace/events' directory. Check permission on the root folder."); $install_log->pushToLog("ERROR: Creation of 'workspace/events' folder failed.", E_ERROR, true, true); installResult($Page, $install_log, $start); return; } $install_log->pushToLog("WRITING: Creating 'pages' folder (/workspace/pages)", E_NOTICE, true, true); if (!GeneralExtended::realiseDirectory($kDOCROOT . '/workspace/pages', $conf['settings']['directory']['write_mode'])) { define('_INSTALL_ERRORS_', "Could not create 'workspace/pages' directory. Check permission on the root folder."); $install_log->pushToLog("ERROR: Creation of 'workspace/pages' folder failed.", E_ERROR, true, true); installResult($Page, $install_log, $start); return; } $install_log->pushToLog("WRITING: Creating 'utilities' folder (/workspace/utilities)", E_NOTICE, true, true); if (!GeneralExtended::realiseDirectory($kDOCROOT . '/workspace/utilities', $conf['settings']['directory']['write_mode'])) { define('_INSTALL_ERRORS_', "Could not create 'workspace/utilities' directory. Check permission on the root folder."); $install_log->pushToLog("ERROR: Creation of 'workspace/utilities' folder failed.", E_ERROR, true, true); installResult($Page, $install_log, $start); return; } } else { $install_log->pushToLog("MYSQL: Importing Workspace Data...", E_NOTICE, true, false); $error = NULL; if (!fireSql($db, getWorkspaceData(), $error, $config['database']['high-compatibility'] == 'yes' ? 'high' : 'normal')) { define('_INSTALL_ERRORS_', "There was an error while trying to import data to the database. MySQL returned: {$error}"); $install_log->pushToLog("Failed", E_ERROR, true, true, true); installResult($Page, $install_log, $start); } else { $install_log->pushToLog("Done", E_NOTICE, true, true, true); } } if (@(!is_dir($fields['docroot'] . '/extensions'))) { $install_log->pushToLog("WRITING: Creating 'campfire' folder (/extensions)", E_NOTICE, true, true); if (!GeneralExtended::realiseDirectory($kDOCROOT . '/extensions', $conf['settings']['directory']['write_mode'])) { define('_INSTALL_ERRORS_', "Could not create 'extensions' directory. Check permission on the root folder."); $install_log->pushToLog("ERROR: Creation of 'extensions' folder failed.", E_ERROR, true, true); installResult($Page, $install_log, $start); return; } } $install_log->pushToLog("Installation Process Completed In " . max(1, time() - $start) . " sec", E_NOTICE, true); installResult($Page, $install_log, $start); redirect('http://' . rtrim(str_replace('http://', '', _INSTALL_DOMAIN_), '/') . '/symphony/'); } }
} html_header(); if ($error != '') { html_error(); } else { if (isset($config['admin_username'])) { setTmpConfig('step', STEP_FINALISE); } } html_admin(); html_footer(); break; case STEP_FINALISE: // Finally check if everything is set up properly and tell the user so // write real config file writeConfig(); $page_title = $language['title_finished']; html_header(); if ($error != '') { html_error(); } html_finish(); html_footer(); // delete temp config + created test images!! $files_to_remove = array('albums/combined_generated.jpg', 'albums/giftest_generated.gif', 'albums/giftest_generated.jpg', 'albums/jpgtest_generated.jpg', 'albums/pngtest_generated.jpg', 'albums/pngtest_generated.png', 'albums/scaled_generated.jpg', 'albums/texttest_generated.jpg', 'include/config.tmp.php'); foreach ($files_to_remove as $file) { if (is_file($file)) { unlink($file); } } break;
function validateInput() { global $db, $html; // do a check by step if ($_REQUEST['step'] == '2') { $db_details = $db->testConnection($_REQUEST['database_server'], $_REQUEST['database_name'], $_REQUEST['database_user'], $_REQUEST['database_password']); if (!$db_details) { echo $html['Error']['Database_Details']; exit; } } // update the config file if all is well writeConfig(); }
/** * Test mergeDeprecatedConfig while being logged in without options file. */ public function testMergeDeprecatedConfigNoFile() { writeConfig(self::$_configFields, true); mergeDeprecatedConfig(self::$_configFields, true); include self::$_configFields['config']['CONFIG_FILE']; $this->assertEquals(self::$_configFields['login'], $GLOBALS['login']); }
function install() { global $core; // On free.fr host, make sure the /sessions directory exists, otherwise login will not work. if (endsWith($_SERVER['SERVER_NAME'], '.free.fr') && !is_dir($_SERVER['DOCUMENT_ROOT'] . '/sessions')) { mkdir($_SERVER['DOCUMENT_ROOT'] . '/sessions', 0705); } if ($core->auth->sessionExists() && !empty($_POST['setlogin'])) { $tz = 'UTC'; if (!empty($_POST['continent']) && !empty($_POST['city'])) { if (isTZvalid($_POST['continent'], $_POST['city'])) { $tz = $_POST['continent'] . '/' . $_POST['city']; } } $GLOBALS['timezone'] = $tz; // Everything is ok, let's create config file. $GLOBALS['login'] = $core->auth->userID(); $GLOBALS['salt'] = sha1(uniqid('', true) . '_' . mt_rand()); // Salt renders rainbow-tables attacks useless. $GLOBALS['hash'] = sha1($core->auth->userToken() . $GLOBALS['login'] . $GLOBALS['salt']); $GLOBALS['title'] = empty($_POST['title']) ? 'Shared links on ' . htmlspecialchars(indexUrl()) : $_POST['title']; writeConfig(); echo '<script language="JavaScript">alert("Shaarli is now configured !");document.location=\'\';</script>'; exit; } // Display config form: list($timezone_form, $timezone_js) = templateTZform(); $timezone_html = ''; if ($timezone_form != '') { $timezone_html = '<tr><td valign="top"><b>Timezone:</b></td><td>' . $timezone_form . '</td></tr>'; } $PAGE = new pageBuilder(); $PAGE->assign('login_html', $core->auth->userID()); $PAGE->assign('timezone_html', $timezone_html); $PAGE->assign('timezone_js', $timezone_js); $PAGE->renderPage('install'); exit; }
function performProcess() { global $blogPath; echo '<p>Starting the process ... </p>'; readConfig(); writeConfig(); loadPosts(); echo '<p><strong>CONGRATULATIONS !! Your Pritlog installation has been updated to the 0.811</strong></p>'; echo '<p><a href="' . $blogPath . '">Home page</a></p>'; translationInfo(); }
function install() { // On free.fr host, make sure the /sessions directory exists, otherwise login will not work. if (endsWith($_SERVER['HTTP_HOST'], '.free.fr') && !is_dir($_SERVER['DOCUMENT_ROOT'] . '/sessions')) { mkdir($_SERVER['DOCUMENT_ROOT'] . '/sessions', 0705); } // This part makes sure sessions works correctly. // (Because on some hosts, session.save_path may not be set correctly, // or we may not have write access to it.) if (isset($_GET['test_session']) && (!isset($_SESSION) || !isset($_SESSION['session_tested']) || $_SESSION['session_tested'] != 'Working')) { // Step 2: Check if data in session is correct. echo '<pre>Sessions do not seem to work correctly on your server.<br>'; echo 'Make sure the variable session.save_path is set correctly in your php config, and that you have write access to it.<br>'; echo 'It currently points to ' . session_save_path() . '<br>'; echo 'Check that the hostname used to access Shaarli contains a dot. On some browsers, accessing your server via a hostname like \'localhost\' or any custom hostname without a dot causes cookie storage to fail. We recommend accessing your server via it\'s IP address or Fully Qualified Domain Name.<br>'; echo '<br><a href="?">Click to try again.</a></pre>'; die; } if (!isset($_SESSION['session_tested'])) { // Step 1 : Try to store data in session and reload page. $_SESSION['session_tested'] = 'Working'; // Try to set a variable in session. header('Location: ' . index_url($_SERVER) . '?test_session'); // Redirect to check stored data. } if (isset($_GET['test_session'])) { // Step 3: Sessions are OK. Remove test parameter from URL. header('Location: ' . index_url($_SERVER)); } if (!empty($_POST['setlogin']) && !empty($_POST['setpassword'])) { $tz = 'UTC'; if (!empty($_POST['continent']) && !empty($_POST['city'])) { if (isTimeZoneValid($_POST['continent'], $_POST['city'])) { $tz = $_POST['continent'] . '/' . $_POST['city']; } } $GLOBALS['timezone'] = $tz; // Everything is ok, let's create config file. $GLOBALS['login'] = $_POST['setlogin']; $GLOBALS['salt'] = sha1(uniqid('', true) . '_' . mt_rand()); // Salt renders rainbow-tables attacks useless. $GLOBALS['hash'] = sha1($_POST['setpassword'] . $GLOBALS['login'] . $GLOBALS['salt']); $GLOBALS['title'] = empty($_POST['title']) ? 'Shared links on ' . escape(index_url($_SERVER)) : $_POST['title']; $GLOBALS['config']['ENABLE_UPDATECHECK'] = !empty($_POST['updateCheck']); try { writeConfig($GLOBALS, isLoggedIn()); } catch (Exception $e) { error_log('ERROR while writing config file after installation.' . PHP_EOL . $e->getMessage()); // TODO: do not handle exceptions/errors in JS. echo '<script>alert("' . $e->getMessage() . '");document.location=\'?\';</script>'; exit; } echo '<script>alert("Shaarli is now configured. Please enter your login/password and start shaaring your links!");document.location=\'?do=login\';</script>'; exit; } // Display config form: list($timezone_form, $timezone_js) = generateTimeZoneForm(); $timezone_html = ''; if ($timezone_form != '') { $timezone_html = '<tr><td><b>Timezone:</b></td><td>' . $timezone_form . '</td></tr>'; } $PAGE = new pageBuilder(); $PAGE->assign('timezone_html', $timezone_html); $PAGE->assign('timezone_js', $timezone_js); $PAGE->renderPage('install'); exit; }
/** * Move deprecated options.php to config.php. * * Milestone 0.9 (old versioning) - shaarli/Shaarli#41: * options.php is not supported anymore. */ public function updateMethodMergeDeprecatedConfigFile() { $config_file = $this->config['config']['CONFIG_FILE']; if (is_file($this->config['config']['DATADIR'] . '/options.php')) { include $this->config['config']['DATADIR'] . '/options.php'; // Load GLOBALS into config foreach ($GLOBALS as $key => $value) { $this->config[$key] = $value; } $this->config['config']['CONFIG_FILE'] = $config_file; writeConfig($this->config, $this->isLoggedIn); unlink($this->config['config']['DATADIR'] . '/options.php'); } return true; }
function install(&$Page, $fields) { $db = new MySQL(); $db->connect($fields['database']['host'], $fields['database']['username'], $fields['database']['password'], $fields['database']['port']); if ($db->isConnected()) { $tables = $db->fetch("SHOW TABLES FROM `" . $fields['database']['name'] . "` LIKE '" . mysql_escape_string($fields['database']['prefix']) . "%'"); } ## Invalid path if (!@is_dir(rtrim($fields['docroot'], '/') . '/symphony')) { $Page->log->pushToLog("Configuration - Bad Document Root Specified: " . $fields['docroot'], SYM_LOG_NOTICE, true); define("kENVIRONMENT_WARNING", true); if (!defined("ERROR")) { define("ERROR", 'no-symphony-dir'); } } elseif (is_file(rtrim($fields['docroot'], '/') . '/.htaccess')) { $Page->log->pushToLog("Configuration - Existing '.htaccess' file found: " . $fields['docroot'] . '/.htaccess', SYM_LOG_NOTICE, true); define("kENVIRONMENT_WARNING", true); if (!defined("ERROR")) { define("ERROR", 'existing-htaccess'); } } elseif (is_dir(rtrim($fields['docroot'], '/') . '/workspace') && !is_writable(rtrim($fields['docroot'], '/') . '/workspace')) { $Page->log->pushToLog("Configuration - Workspace folder not writable: " . $fields['docroot'] . '/workspace', SYM_LOG_NOTICE, true); define("kENVIRONMENT_WARNING", true); if (!defined("ERROR")) { define("ERROR", 'no-write-permission-workspace'); } } elseif (!is_writable(rtrim($fields['docroot'], '/'))) { $Page->log->pushToLog("Configuration - Root folder not writable: " . $fields['docroot'], SYM_LOG_NOTICE, true); define("kENVIRONMENT_WARNING", true); if (!defined("ERROR")) { define("ERROR", 'no-write-permission-root'); } } elseif (!$db->isConnected()) { $Page->log->pushToLog("Configuration - Could not establish database connection", SYM_LOG_NOTICE, true); define("kDATABASE_CONNECTION_WARNING", true); if (!defined("ERROR")) { define("ERROR", 'no-database-connection'); } } elseif (!$db->select($fields['database']['name'])) { $Page->log->pushToLog("Configuration - Database '" . $fields['database']['name'] . "' Not Found", SYM_LOG_NOTICE, true); define("kDATABASE_CONNECTION_WARNING", true); if (!defined("ERROR")) { define("ERROR", 'no-database-connection'); } } elseif (is_array($tables) && !empty($tables)) { $Page->log->pushToLog("Configuration - Database table prefix clash with '" . $fields['database']['name'] . "'", SYM_LOG_NOTICE, true); define("kDATABASE_PREFIX_WARNING", true); if (!defined("ERROR")) { define("ERROR", 'database-table-clash'); } } elseif (trim($fields['user']['username']) == '') { $Page->log->pushToLog("Configuration - No username entered.", SYM_LOG_NOTICE, true); define("kUSER_USERNAME_WARNING", true); if (!defined("ERROR")) { define("ERROR", 'user-no-username'); } } elseif (trim($fields['user']['password']) == '') { $Page->log->pushToLog("Configuration - No password entered.", SYM_LOG_NOTICE, true); define("kUSER_PASSWORD_WARNING", true); if (!defined("ERROR")) { define("ERROR", 'user-no-password'); } } elseif ($fields['user']['password'] != $fields['user']['confirm-password']) { $Page->log->pushToLog("Configuration - Passwords did not match.", SYM_LOG_NOTICE, true); define("kUSER_PASSWORD_WARNING", true); if (!defined("ERROR")) { define("ERROR", 'user-password-mismatch'); } } elseif (trim($fields['user']['firstname']) == '' || trim($fields['user']['lastname']) == '') { $Page->log->pushToLog("Configuration - Did not enter First and Last names.", SYM_LOG_NOTICE, true); define("kUSER_NAME_WARNING", true); if (!defined("ERROR")) { define("ERROR", 'user-no-name'); } } elseif (!ereg('^[a-zA-Z0-9_\\.\\-]+@[a-zA-Z0-9\\-]+\\.[a-zA-Z0-9\\-\\.]+$', $fields['user']['email'])) { $Page->log->pushToLog("Configuration - Invalid email address supplied.", SYM_LOG_NOTICE, true); define("kUSER_EMAIL_WARNING", true); if (!defined("ERROR")) { define("ERROR", 'user-invalid-email'); } } else { $config = $fields; $kDOCROOT = rtrim($config['docroot'], '/'); $database = array_map("trim", $fields['database']); if (!isset($database['host']) || $database['host'] == "") { $database['host'] = "localhost"; } if (!isset($database['port']) || $database['port'] == "") { $database['port'] = "3306"; } if (!isset($database['prefix']) || $database['prefix'] == "") { $database['prefix'] = "sym_"; } $install_log = $Page->log; $start = time(); $install_log->writeToLog(CRLF . '============================================', true); $install_log->writeToLog('INSTALLATION PROCESS STARTED (' . date("d.m.y H:i:s") . ')', true); $install_log->writeToLog('============================================', true); $db = new MySQL(); $install_log->pushToLog("MYSQL: Establishing Connection...", SYM_LOG_NOTICE, true, false); $db = new MySQL(); if (!$db->connect($database['host'], $database['username'], $database['password'], $database['port'])) { define("_INSTALL_ERRORS_", "There was a problem while trying to establish a connection to the MySQL server. Please check your settings."); $install_log->pushToLog("Failed", SYM_LOG_NOTICE, true, true, true); installResult($Page, $install_log, $start); } else { $install_log->pushToLog("Done", SYM_LOG_NOTICE, true, true, true); } $install_log->pushToLog("MYSQL: Selecting Database '" . $database['name'] . "'...", SYM_LOG_NOTICE, true, false); if (!$db->select($database['name'])) { define("_INSTALL_ERRORS_", "Could not connect to specified database. Please check your settings."); $install_log->pushToLog("Failed", SYM_LOG_NOTICE, true, true, true); installResult($Page, $install_log, $start); } else { $install_log->pushToLog("Done", SYM_LOG_NOTICE, true, true, true); } $db->setPrefix($database['prefix']); $install_log->pushToLog("MYSQL: Creating Tables...", SYM_LOG_NOTICE, true, false); $error = NULL; if (!fireSql($db, getTableSchema(), $error, $config['database']['high-compatibility'] == 'yes' ? 'high' : 'normal')) { define("_INSTALL_ERRORS_", "There was an error while trying to create tables in the database. MySQL returned: {$error}"); $install_log->pushToLog("Failed", SYM_LOG_ERROR, true, true, true); installResult($Page, $install_log, $start); } else { $install_log->pushToLog("Done", SYM_LOG_NOTICE, true, true, true); } $author_sql = "INSERT INTO `tbl_authors` " . "(username, password, firstname, lastname, email, superuser, owner, textformat) " . "VALUES (" . "'" . $config['user']['username'] . "', " . "'" . md5($config['user']['password']) . "', " . "'" . $config['user']['firstname'] . "', " . "'" . $config['user']['lastname'] . "', " . "'" . $config['user']['email'] . "', " . "'1', '1', 'simplehtml' )"; $error = NULL; $db->query($author_sql, $error); if (!empty($error)) { define("_INSTALL_ERRORS_", "There was an error while trying create the default author. MySQL returned: {$error}"); $install_log->pushToLog("Failed", SYM_LOG_ERROR, true, true, true); installResult($Page, $install_log, $start); } else { $install_log->pushToLog("Done", SYM_LOG_NOTICE, true, true, true); } $conf = array(); $conf['define'] = array('DOCROOT' => $kDOCROOT, 'DOMAIN' => str_replace("http://", "", _INSTALL_DOMAIN_)); $conf['require'] = array($kDOCROOT . '/symphony/lib/boot/bundle.php'); $conf['settings']['admin']['max_upload_size'] = '5242880'; $conf['settings']['admin']['handle_length'] = '50'; $conf['settings']['filemanager']['filetype_restriction'] = 'bmp, jpg, gif, png, doc, rtf, pdf, zip'; $conf['settings']['filemanager']['enabled'] = 'yes'; $conf['settings']['filemanager']['log_all_upload_attempts'] = 'yes'; $conf['settings']['symphony']['build'] = kBUILD; $conf['settings']['symphony']['acct_server'] = kSUPPORT_SERVER; $conf['settings']['symphony']['update'] = '5'; $conf['settings']['symphony']['lastupdatecheck'] = time(); $conf['settings']['symphony']['prune_logs'] = '1'; $conf['settings']['symphony']['allow_page_subscription'] = '1'; $conf['settings']['symphony']['strict_section_field_validation'] = '1'; $conf['settings']['symphony']['allow_primary_field_handles_to_change'] = '1'; $conf['settings']['symphony']['pagination_maximum_rows'] = '17'; $conf['settings']['symphony']['cookie_prefix'] = 'sym_'; $conf['settings']['xsl']['exclude-parameter-declarations'] = 'off'; if ($config['theme'] == 'yes') { $conf['settings']['general']['sitename'] = 'Symphony Web Publishing System'; } else { $conf['settings']['general']['sitename'] = 'Website Name'; } $conf['settings']['general']['useragent'] = 'Symphony/' . kBUILD; $conf['settings']['image']['cache'] = '1'; $conf['settings']['image']['quality'] = '70'; $conf['settings']['file']['extend_timeout'] = 'off'; $conf['settings']['file']['write_mode'] = $config['permission']['file']; $conf['settings']['directory']['write_mode'] = $config['permission']['directory']; $conf['settings']['database']['driver'] = 'MySQL'; $conf['settings']['database']['host'] = $database['host']; $conf['settings']['database']['port'] = $database['port']; $conf['settings']['database']['user'] = $database['username']; $conf['settings']['database']['password'] = $database['password']; $conf['settings']['database']['db'] = $database['name']; $conf['settings']['database']['tbl_prefix'] = $database['prefix']; $conf['settings']['database']['character_set'] = 'utf8'; $conf['settings']['database']['character_encoding'] = 'utf8'; $conf['settings']['database']['runtime_character_set_alter'] = '0'; $conf['settings']['public']['status'] = 'online'; $conf['settings']['public']['caching'] = 'on'; $conf['settings']['public']['excerpt-length'] = '100'; $conf['settings']['region']['time_zone'] = '10'; $conf['settings']['region']['time_format'] = 'g:i a'; $conf['settings']['region']['date_format'] = 'j F Y'; $conf['settings']['region']['dst'] = 'no'; $conf['settings']['workspace']['config_checksum'] = ''; $conf['settings']['commenting']['allow-by-default'] = 'on'; $conf['settings']['commenting']['email-notify'] = 'off'; $conf['settings']['commenting']['allow-duplicates'] = 'off'; $conf['settings']['commenting']['maximum-allowed-links'] = '3'; $conf['settings']['commenting']['banned-words'] = ''; $conf['settings']['commenting']['banned-words-replacement'] = '*****'; $conf['settings']['commenting']['hide-spam-flagged'] = 'on'; $conf['settings']['commenting']['formatting-type'] = 'simplehtml'; $conf['settings']['commenting']['add-nofollow'] = 'off'; $conf['settings']['commenting']['convert-urls'] = 'off'; $conf['settings']['commenting']['check-referer'] = 'on'; $conf['settings']['commenting']['nuke-spam'] = 'on'; $conf['settings']['commenting']['ip-blacklist'] = ''; ## Create Manifest directory structure # $install_log->pushToLog("WRITING: Creating 'manifest' folder (/manifest)", SYM_LOG_NOTICE, true, true); if (!GeneralExtended::realiseDirectory($kDOCROOT . '/manifest', $conf['settings']['directory']['write_mode'])) { define("_INSTALL_ERRORS_", "Could not create 'manifest' directory. Check permission on the root folder."); $install_log->pushToLog("ERROR: Creation of 'manifest' folder failed.", SYM_LOG_ERROR, true, true); installResult($Page, $install_log, $start); return; } $install_log->pushToLog("WRITING: Creating 'logs' folder (/manifest/logs)", SYM_LOG_NOTICE, true, true); if (!GeneralExtended::realiseDirectory($kDOCROOT . '/manifest/logs', $conf['settings']['directory']['write_mode'])) { define("_INSTALL_ERRORS_", "Could not create 'logs' directory. Check permission on /manifest."); $install_log->pushToLog("ERROR: Creation of 'logs' folder failed.", SYM_LOG_ERROR, true, true); installResult($Page, $install_log, $start); return; } $install_log->pushToLog("WRITING: Creating 'cache' folder (/manifest/cache)", SYM_LOG_NOTICE, true, true); if (!GeneralExtended::realiseDirectory($kDOCROOT . '/manifest/cache', $conf['settings']['directory']['write_mode'])) { define("_INSTALL_ERRORS_", "Could not create 'cache' directory. Check permission on /manifest."); $install_log->pushToLog("ERROR: Creation of 'cache' folder failed.", SYM_LOG_ERROR, true, true); installResult($Page, $install_log, $start); return; } $install_log->pushToLog("WRITING: Creating 'tmp' folder (/manifest/tmp)", SYM_LOG_NOTICE, true, true); if (!GeneralExtended::realiseDirectory($kDOCROOT . '/manifest/tmp', $conf['settings']['directory']['write_mode'])) { define("_INSTALL_ERRORS_", "Could not create 'tmp' directory. Check permission on /manifest."); $install_log->pushToLog("ERROR: Creation of 'tmp' folder failed.", SYM_LOG_ERROR, true, true); installResult($Page, $install_log, $start); return; } $install_log->pushToLog("WRITING: Configuration File", SYM_LOG_NOTICE, true, true); if (!writeConfig($kDOCROOT . "/manifest/", $conf, $conf['settings']['file']['write_mode'])) { define("_INSTALL_ERRORS_", "Could not write config file. Check permission on /manifest."); $install_log->pushToLog("ERROR: Writing Configuration File Failed", SYM_LOG_ERROR, true, true); installResult($Page, $install_log, $start); } $rewrite_base = dirname($_SERVER['PHP_SELF']); $rewrite_base = trim($rewrite_base, '/'); if ($rewrite_base != "") { $rewrite_base .= '/'; } $htaccess = ' ### Symphony 1.7 - Do not edit ### <IfModule mod_rewrite.c> RewriteEngine on RewriteBase /' . $rewrite_base . ' ### DO NOT APPLY RULES WHEN REQUESTING "favicon.ico" RewriteCond %{REQUEST_FILENAME} favicon.ico [NC] RewriteRule .* - [S=14] ### IMAGE RULES RewriteRule ^image/([0-9]+)\\/([0-9]+)\\/(0|1)\\/([a-fA-f0-9]{1,6})\\/external/([\\W\\w]+)\\.(jpg|gif|jpeg|png|bmp)$ /' . $rewrite_base . 'symphony/image.php?width=$1&height=$2&crop=$3&bg=$4&_f=$5.$6&external=true [L] RewriteRule ^image/external/([\\W\\w]+)\\.(jpg|gif|jpeg|png|bmp)$ /' . $rewrite_base . 'symphony/image.php?width=0&height=0&crop=0&bg=0&_f=$1.$2&external=true [L] RewriteRule ^image/([0-9]+)\\/([0-9]+)\\/(0|1)\\/([a-fA-f0-9]{1,6})\\/external/(.*)\\.(jpg|gif|jpeg|png|bmp)$ /' . $rewrite_base . 'symphony/image.php?width=$1&height=$2&crop=$3&bg=$4&_f=$5.$6&external=true [L] RewriteRule ^image/external/(.*)\\.(jpg|gif|jpeg|png|bmp)$ /' . $rewrite_base . 'symphony/image.php?width=0&height=0&crop=0&bg=0&_f=$1.$2&external=true [L] RewriteRule ^image/([0-9]+)\\/([0-9]+)\\/(0|1)\\/([a-fA-f0-9]{1,6})\\/([\\W\\w]+)\\.(jpg|gif|jpeg|png|bmp)$ /' . $rewrite_base . 'symphony/image.php?width=$1&height=$2&crop=$3&bg=$4&_f=$5.$6 [L] RewriteRule ^image/([\\W\\w]+)\\.(jpg|gif|jpeg|png|bmp)$ /' . $rewrite_base . 'symphony/image.php?width=0&height=0&crop=0&bg=0&_f=$1.$2 [L] RewriteRule ^image/([0-9]+)\\/([0-9]+)\\/(0|1)\\/([a-fA-f0-9]{1,6})\\/(.*)\\.(jpg|gif|jpeg|png|bmp)$ /' . $rewrite_base . 'symphony/image.php?width=$1&height=$2&crop=$3&bg=$4&_f=$5.$6 [L] RewriteRule ^image/(.*)\\.(jpg|gif|jpeg|png|bmp)$ /' . $rewrite_base . 'symphony/image.php?width=0&height=0&crop=0&bg=0&_f=$1.$2 [L] ### CHECK FOR TRAILING SLASH - Will ignore files RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_URI} !/' . trim($rewrite_base, '/') . '$ RewriteCond %{REQUEST_URI} !(.*)/$ RewriteRule ^(.*)$ /' . $rewrite_base . '$1/ [L,R=301] ### MAIN REWRITE - This will ignore directories RewriteCond %{REQUEST_FILENAME} !-d RewriteRule ^(.*)\\/$ /' . $rewrite_base . 'index.php?page=$1&%{QUERY_STRING} [L] </IfModule> DirectoryIndex index.php IndexIgnore * ###### '; $install_log->pushToLog("CONFIGURING: Frontend", SYM_LOG_NOTICE, true, true); if (!GeneralExtended::writeFile($kDOCROOT . "/.htaccess", $htaccess, $conf['settings']['file']['write_mode'])) { define("_INSTALL_ERRORS_", "Could not write .htaccess file. Check permission on " . $kDOCROOT); $install_log->pushToLog("ERROR: Writing .htaccess File Failed", SYM_LOG_ERROR, true, true); installResult($Page, $install_log, $start); } if (@is_file($fields['docroot'] . '/workspace/workspace.conf')) { $install_log->pushToLog("CONFIGURING: Importing Workspace", SYM_LOG_NOTICE, true, false); if (!fireSql($db, file_get_contents($fields['docroot'] . '/workspace/workspace.conf') . getDefaultTableData(), $error, $config['database']['high-compatibility'] == 'yes' ? 'high' : 'normal')) { define("_INSTALL_ERRORS_", "There was an error while trying to import the workspace data. MySQL returned: {$error}"); $install_log->pushToLog("Failed", SYM_LOG_ERROR, true, true, true); installResult($Page, $install_log, $start); } else { $install_log->pushToLog("Done", SYM_LOG_NOTICE, true, true, true); } } elseif (@(!is_dir($fields['docroot'] . '/workspace'))) { ### Create the workspace folder structure # $install_log->pushToLog("WRITING: Creating 'workspace' folder (/workspace)", SYM_LOG_NOTICE, true, true); if (!GeneralExtended::realiseDirectory($kDOCROOT . '/workspace', $conf['settings']['directory']['write_mode'])) { define("_INSTALL_ERRORS_", "Could not create 'workspace' directory. Check permission on the root folder."); $install_log->pushToLog("ERROR: Creation of 'workspace' folder failed.", SYM_LOG_ERROR, true, true); installResult($Page, $install_log, $start); return; } $install_log->pushToLog("WRITING: Creating 'data-sources' folder (/workspace/data-sources)", SYM_LOG_NOTICE, true, true); if (!GeneralExtended::realiseDirectory($kDOCROOT . '/workspace/data-sources', $conf['settings']['directory']['write_mode'])) { define("_INSTALL_ERRORS_", "Could not create 'workspace/data-sources' directory. Check permission on the root folder."); $install_log->pushToLog("ERROR: Creation of 'workspace/data-sources' folder failed.", SYM_LOG_ERROR, true, true); installResult($Page, $install_log, $start); return; } $install_log->pushToLog("WRITING: Creating 'events' folder (/workspace/events)", SYM_LOG_NOTICE, true, true); if (!GeneralExtended::realiseDirectory($kDOCROOT . '/workspace/events', $conf['settings']['directory']['write_mode'])) { define("_INSTALL_ERRORS_", "Could not create 'workspace/events' directory. Check permission on the root folder."); $install_log->pushToLog("ERROR: Creation of 'workspace/events' folder failed.", SYM_LOG_ERROR, true, true); installResult($Page, $install_log, $start); return; } $install_log->pushToLog("WRITING: Creating 'masters' folder (/workspace/masters)", SYM_LOG_NOTICE, true, true); if (!GeneralExtended::realiseDirectory($kDOCROOT . '/workspace/masters', $conf['settings']['directory']['write_mode'])) { define("_INSTALL_ERRORS_", "Could not create 'workspace/masters' directory. Check permission on the root folder."); $install_log->pushToLog("ERROR: Creation of 'workspace/masters' folder failed.", SYM_LOG_ERROR, true, true); installResult($Page, $install_log, $start); return; } $install_log->pushToLog("WRITING: Creating 'pages' folder (/workspace/pages)", SYM_LOG_NOTICE, true, true); if (!GeneralExtended::realiseDirectory($kDOCROOT . '/workspace/pages', $conf['settings']['directory']['write_mode'])) { define("_INSTALL_ERRORS_", "Could not create 'workspace/pages' directory. Check permission on the root folder."); $install_log->pushToLog("ERROR: Creation of 'workspace/pages' folder failed.", SYM_LOG_ERROR, true, true); installResult($Page, $install_log, $start); return; } $install_log->pushToLog("WRITING: Creating 'text-formatters' folder (/workspace/text-formatters)", SYM_LOG_NOTICE, true, true); if (!GeneralExtended::realiseDirectory($kDOCROOT . '/workspace/text-formatters', $conf['settings']['directory']['write_mode'])) { define("_INSTALL_ERRORS_", "Could not create 'workspace/text-formatters' directory. Check permission on the root folder."); $install_log->pushToLog("ERROR: Creation of 'workspace/text-formatters' folder failed.", SYM_LOG_ERROR, true, true); installResult($Page, $install_log, $start); return; } $install_log->pushToLog("WRITING: Creating 'upload' folder (/workspace/upload)", SYM_LOG_NOTICE, true, true); if (!GeneralExtended::realiseDirectory($kDOCROOT . '/workspace/upload', $conf['settings']['directory']['write_mode'])) { define("_INSTALL_ERRORS_", "Could not create 'workspace/upload' directory. Check permission on the root folder."); $install_log->pushToLog("ERROR: Creation of 'workspace/upload' folder failed.", SYM_LOG_ERROR, true, true); installResult($Page, $install_log, $start); return; } $install_log->pushToLog("WRITING: Creating 'utilities' folder (/workspace/utilities)", SYM_LOG_NOTICE, true, true); if (!GeneralExtended::realiseDirectory($kDOCROOT . '/workspace/utilities', $conf['settings']['directory']['write_mode'])) { define("_INSTALL_ERRORS_", "Could not create 'workspace/utilities' directory. Check permission on the root folder."); $install_log->pushToLog("ERROR: Creation of 'workspace/utilities' folder failed.", SYM_LOG_ERROR, true, true); installResult($Page, $install_log, $start); return; } } if (@(!is_dir($fields['docroot'] . '/campfire'))) { $install_log->pushToLog("WRITING: Creating 'campfire' folder (/campfire)", SYM_LOG_NOTICE, true, true); if (!GeneralExtended::realiseDirectory($kDOCROOT . '/campfire', $conf['settings']['directory']['write_mode'])) { define("_INSTALL_ERRORS_", "Could not create 'campfire' directory. Check permission on the root folder."); $install_log->pushToLog("ERROR: Creation of 'campfire' folder failed.", SYM_LOG_ERROR, true, true); installResult($Page, $install_log, $start); return; } } $install_log->pushToLog("Installation Process Completed In " . max(1, time() - $start) . " sec", SYM_LOG_NOTICE, true); installResult($Page, $install_log, $start); GeneralExtended::redirect('http://' . rtrim(str_replace('http://', '', _INSTALL_DOMAIN_), '/') . '/symphony/'); } }
$trigger = sprintf("%s\t%s", $fnName, implode(' ', $fnPieces)); if (!empty($fnPieces)) { $contents = $fnName; foreach ($fnPieces as $n => $p) { $contents .= sprintf(' ${%d:%s}', $n + 1, $p); } $config['completions'][] = array('trigger' => $trigger, 'contents' => $contents); } else { $config['completions'][] = $fnName; } } } function addApi(&$config) { $root = getNamespaces(); foreach ($root as $ns => $href) { $fns = getNamespaceFunctions($ns, $href); addNamespaceFunctionsToConfig($config, $ns, $fns); } } function writeConfig($config, $filename) { $file = fopen($filename, 'w'); fwrite($file, json_encode($config)); fclose($file); } $config = array('scope' => 'source.clojure source.symbol.clojure', 'completions' => array()); addUseful($config); addApi($config); writeConfig($config, 'riemann.sublime-completions');
function install() { // On free.fr host, make sure the /sessions directory exists, otherwise login will not work. if (endsWith($_SERVER['HTTP_HOST'], '.free.fr') && !is_dir($_SERVER['DOCUMENT_ROOT'] . '/sessions')) { mkdir($_SERVER['DOCUMENT_ROOT'] . '/sessions', 0705); } // This part makes sure sessions works correctly. // (Because on some hosts, session.save_path may not be set correctly, // or we may not have write access to it.) if (isset($_GET['test_session']) && (!isset($_SESSION) || !isset($_SESSION['session_tested']) || $_SESSION['session_tested'] != 'Working')) { // Step 2: Check if data in session is correct. echo '<pre>Sessions do not seem to work correctly on your server.<br>'; echo 'Make sure the variable session.save_path is set correctly in your php config, and that you have write access to it.<br>'; echo 'It currently points to ' . session_save_path() . '<br><br><a href="?">Click to try again.</a></pre>'; die; } if (!isset($_SESSION['session_tested'])) { // Step 1 : Try to store data in session and reload page. $_SESSION['session_tested'] = 'Working'; // Try to set a variable in session. header('Location: ' . indexUrl() . '?test_session'); // Redirect to check stored data. } if (isset($_GET['test_session'])) { // Step 3: Sessions are ok. Remove test parameter from URL. header('Location: ' . indexUrl()); } if (!empty($_POST['setlogin']) && !empty($_POST['setpassword'])) { $tz = 'UTC'; if (!empty($_POST['continent']) && !empty($_POST['city'])) { if (isTZvalid($_POST['continent'], $_POST['city'])) { $tz = $_POST['continent'] . '/' . $_POST['city']; } } $GLOBALS['timezone'] = $tz; // Everything is ok, let's create config file. $GLOBALS['login'] = $_POST['setlogin']; $GLOBALS['salt'] = sha1(uniqid('', true) . '_' . mt_rand()); // Salt renders rainbow-tables attacks useless. $GLOBALS['hash'] = sha1($_POST['setpassword'] . $GLOBALS['login'] . $GLOBALS['salt']); $GLOBALS['title'] = empty($_POST['title']) ? 'Shared links on ' . htmlspecialchars(indexUrl()) : $_POST['title']; writeConfig(); echo '<script language="JavaScript">alert("Shaarli is now configured. Please enter your login/password and start shaaring your links !");document.location=\'?do=login\';</script>'; exit; } // Display config form: list($timezone_form, $timezone_js) = templateTZform(); $timezone_html = ''; if ($timezone_form != '') { $timezone_html = '<tr><td valign="top"><b>Timezone:</b></td><td>' . $timezone_form . '</td></tr>'; } $PAGE = new pageBuilder(); $PAGE->assign('timezone_html', $timezone_html); $PAGE->assign('timezone_js', $timezone_js); $PAGE->renderPage('install'); exit; }
echo "<FONT COLOR=RED><B>Problems creating required tables were detected.</B> Please use the following error output to report a bug to http://sourceforge.net/tracker/?group_id=120663&atid=687790.<BR><BR>"; for ($i = 0, $totalerr = count($sqlerror); $i < $totalerr; $i++) { echo "<B>Error " . $sqlerror[$i]["name"] . "</B>: " . $sqlerror[$i]["error"] . "<BR>"; } echo "<BR> Please copy the above information into a new bugreport.<BR><BR></FONT>"; } /* * If requested, attempt to write a configuration file. */ if (isset($_POST["write_conf"]) ? strcmp($_POST["write_conf"], "checked") == 0 ? true : false : false) { /* * Hm, decide which username and password to put in the config file */ $cfgusername = $_POST["install_type"] == DB_USER_TABLES ? $_POST["newusername"] : $_POST["username"]; $cfgpassword = $_POST["install_type"] == DB_USER_TABLES ? $_POST["newpassword"] : $_POST["password"]; if (writeConfig($_POST["db_loc"], $cfgusername, $cfgpassword, $_POST["db_name"])) { echo "<B><FONT COLOR=BLUE>config.php written.</FONT></B><BR><BR>"; } else { echo "<B><FONT COLOR=RED>Can't create config.php, more than likely write permission denied.</FONT></B><BR><BR>"; } } else { echo "This script did NOT attempt to write a configuration file to the server. You will need to rename config_sample.php to config.php manually.<BR><BR>"; } if ($tablescreated == count($query_list)) { echo "<B><FONT COLOR=BLUE>Installation appears to have completed. Delete install.php and/or upgrade.php from your web server. Refer to the INSTALL for the rest of the installation procedure.</FONT></B>"; } else { echo "<B><FONT COLOR=RED>Installation appears to have had errors. Please check and try again, if needed.</FONT></B>"; } } else { echo "<BR><FONT COLOR=RED><B>Some fields were not filled out.</B></FONT> Correct the errors and try again."; }
$dblink_temp->loadModule('Manager'); $dblink_temp->createDatabase($dbname); if (MDB2::isError($dblink_temp)) { echo "<p class=\"error\">Error when creating the database. Make sure you have the privileges to create a database and that a database with the same name doesn't exist.</p>"; $errorCreatingDB = true; } } } if (!$errorCreatingDB) { // test database connection information $conn_dsn = "{$dbtype}://{$dbuname}:{$dbpass}@{$dbhost}{$dbportStr}/{$dbname}"; $dblink = MDB2::connect($conn_dsn); if (MDB2::isError($dblink)) { echo "<p class=\"error\">A connection cannot be established with the database.</p>"; } else { writeConfig($table_prefix, $dbhost, $dbport, $dbuname, $dbpass, $dbname, $dbtype); $from_install = true; include '../conn.php'; include '../includes/user.php'; $user = new User(); // Load the right shema structure switch ($dbtype) { case "mysqli": case "mysql": $structure = "mysql"; break; case "pgsql": $structure = "pgsql"; break; } // Create the tables from the sql file (with the script from phpBB)
$table = '`tbl_entries_data_' . $id . '`'; $frontend->Database->query('ALTER TABLE ' . $table . ' CHANGE `author_id` `author_id` int(11) unsigned NULL'); } } catch (Exception $ex) { } } if (version_compare($existing_version, '2.2.2 Beta 1', '<')) { // Rename old variations of the query_caching configuration setting if (isset($settings['database']['disable_query_caching'])) { $settings['database']['query_caching'] = $settings['database']['disable_query_caching'] == "no" ? "on" : "off"; unset($settings['database']['disable_query_caching']); } // Add Session GC collection as a configuration parameter $settings['symphony']['session_gc_divisor'] = '10'; // Save the manifest changes writeConfig(DOCROOT . '/manifest', $settings, $settings['file']['write_mode']); } if (version_compare($existing_version, '2.2.2 Beta 2', '<')) { try { // Change Textareas to be MEDIUMTEXT columns $textarea_tables = $frontend->Database->fetchCol("field_id", "SELECT `field_id` FROM `tbl_fields_textarea`"); foreach ($textarea_tables as $field) { $frontend->Database->query(sprintf("ALTER TABLE `tbl_entries_data_%d` CHANGE `value` `value` MEDIUMTEXT, CHANGE `value_formatted` `value_formatted` MEDIUMTEXT", $field)); $frontend->Database->query(sprintf('OPTIMIZE TABLE `tbl_entries_data_%d`', $field)); } } catch (Exception $ex) { } } $sbl_version = $frontend->Database->fetchVar('version', 0, "SELECT `version` FROM `tbl_extensions` WHERE `name` = 'selectbox_link_field' LIMIT 1"); $code = sprintf($shell, ' <h1>Update Symphony <em>Version ' . kVERSION . '</em><em><a href="' . kCHANGELOG . '">change log</a></em></h1> <h2>Update Complete</h2>
function adminPageAdvancedSubmit() { global $config, $lang, $theme_main; $do = 1; if (isset($_SESSION['logged_in']) && $_SESSION['logged_in'] && isset($_SESSION['isAdmin']) && $_SESSION['isAdmin']) { if (isset($_POST['metaDesc']) && trim($_POST['metaDesc']) != "") { $config['metaDescription'] = $_POST['metaDesc']; } if (isset($_POST['metaKeywords']) && trim($_POST['metaKeywords']) != "") { $config['metaKeywords'] = $_POST['metaKeywords']; } if (isset($_POST['commentsMaxLength']) && trim($_POST['commentsMaxLength']) != "") { $config['commentsMaxLength'] = $_POST['commentsMaxLength']; } if (isset($_POST['commentsForbiddenAuthors']) && trim($_POST['commentsForbiddenAuthors']) != "") { $config['commentsForbiddenAuthors'] = $_POST['commentsForbiddenAuthors']; } if (isset($_POST['statsDontLog']) && trim($_POST['statsDontLog']) != "") { $config['statsDontLog'] = $_POST['statsDontLog']; } if (isset($_POST['entriesOnRSS']) && trim($_POST['entriesOnRSS']) != "") { $config['entriesOnRSS'] = $_POST['entriesOnRSS']; } if (isset($_POST['entriesPerPage']) && trim($_POST['entriesPerPage']) != "") { $config['entriesPerPage'] = $_POST['entriesPerPage']; } if (isset($_POST['menuEntriesLimit']) && trim($_POST['menuEntriesLimit']) != "") { $config['menuEntriesLimit'] = $_POST['menuEntriesLimit']; } if (isset($_POST['timeoutDuration']) && trim($_POST['timeoutDuration']) != "") { $config['timeoutDuration'] = $_POST['timeoutDuration']; } if (isset($_POST['limitLogins']) && trim($_POST['limitLogins']) != "") { $config['limitLogins'] = $_POST['limitLogins']; } if ($_POST['sendMailComments'] == 1) { $config['sendMailWithNewComment'] = 1; } else { $config['sendMailWithNewComment'] = 0; } if ($_POST['commentsSecurityCode'] == 1) { $config['commentsSecurityCode'] = 1; } else { $config['commentsSecurityCode'] = 0; } if ($_POST['authorEditPost'] == 1) { $config['authorEditPost'] = 1; } else { $config['authorEditPost'] = 0; } if ($_POST['authorDeleteComment'] == 1) { $config['authorDeleteComment'] = 1; } else { $config['authorDeleteComment'] = 0; } if ($_POST['showCategoryCloud'] == 1) { $config['showCategoryCloud'] = 1; } else { $config['showCategoryCloud'] = 0; } if ($_POST['allowRegistration'] == 1) { $config['allowRegistration'] = 1; } else { $config['allowRegistration'] = 0; } if ($_POST['sendRegistMail'] == 1) { $config['sendRegistMail'] = 1; } else { $config['sendRegistMail'] = 0; } if ($_POST['commentModerate'] == 1) { $config['commentModerate'] = 1; } else { $config['commentModerate'] = 0; } if ($_POST['cleanUrl'] == 1) { $config['cleanUrl'] = 1; } else { $config['cleanUrl'] = 0; } if (isset($_POST['menuLinks'])) { $config['menuLinks'] = $config['menuLinksOrig'] = str_replace("\r\n", ";", $_POST['menuLinks']); } if (isset($_POST['ipBan'])) { $ipBanArray = explode("\r\n", $_POST['ipBan']); @sqlite_query($config['db'], "DELETE FROM ipban"); foreach ($ipBanArray as $ipBan) { $ipBan = trim($ipBan); sqlite_query($config['db'], "INSERT INTO ipban (ip) VALUES ('{$ipBan}')"); } } if (isset($_POST['blogLanguage'])) { $config['blogLanguage'] = $_POST['blogLanguage']; } if (isset($_POST['theme'])) { $config['theme'] = $_POST['theme']; } if (isset($_POST['privacy'])) { $config['privacy'] = $_POST['privacy']; } setConfigDefaults(); writeConfig(false); return true; } else { return $lang['errorPasswordIncorrect']; } }
/** * 将数据库配置写入到文件 * * @param string $dbhost 数据库主机 * @param string $dbname 数据库名 * @param string $port 端口 * @param string $dbuser 数据库用户名 * @param string $dbpwd 数据库密码 * @param string $dbprefix 数据库表前缀 * @param string $configSampleFile 配置样本文件路经 * @param string $configFile 配置文件路径 * @return boolean $result 写入结果 */ function setDBConfig($dbhost, $dbname, $port, $dbuser, $dbpwd, $dbprefix, $language, $configSampleFile, $configFile) { $config = (require $configSampleFile); $config['components']['db']['connectionString'] = 'mysql:host=' . $dbhost . ';dbname=' . $dbname . ';port=' . $port; $config['components']['db']['username'] = $dbuser; $config['components']['db']['password'] = $dbpwd; $config['components']['db']['tablePrefix'] = $dbprefix; $config['language'] = $language; return writeConfig($config, $configFile); }
if (is_numeric($_POST['rulesacceptgroup'])) { $rulesacceptgroup = $_POST['rulesacceptgroup']; } else { $rulesacceptgroup = 0; } if (empty($_POST['groupsdisallow'])) { $groupsdisallow = '[]'; } else { $groupsdisallow = json_encode($_POST['groupsdisallow'], 1); } if (empty($_POST['enablerules']) and !$_POST['enablerules']) { $enablerules = false; } else { $enablerules = true; } if (!writeConfig(IP, QUERYPORT, SERVERPORT, QUERYUSER, QUERYPASS, QUERYDISPLAYNAME, ADMINPANEL_PASS, $maxgroups, $rulesacceptgroup, $groupsdisallow, RULES, $enablerules, GROUPS)) { $error[] = array('danger', 'Error while writing Config File! Check Write Permissions!'); } else { header("Refresh:0"); die; } break; } } if (!empty($_GET['page'])) { switch ($_GET['page']) { case 'rules': $do = 'rules'; $rules = json_decode(RULES); break; case 'ts3connection':