本文整理汇总了PHP中writeConfig函数的典型用法代码示例。如果您正苦于以下问题:PHP writeConfig函数的具体用法?PHP writeConfig怎么用?PHP writeConfig使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了writeConfig函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: initialize
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: ";
$line['password'] = trim(fgets(STDIN));
print "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;
}
示例2: mergeDeprecatedConfig
/**
* 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');
}
}
示例3: initialize
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: ";
$line['password'] = trim(fgets(STDIN));
print "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;
}
示例4: install
//.........这里部分代码省略.........
$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]
示例5: html_header
}
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;
示例6: validateInput
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();
}
示例7: testMergeDeprecatedConfigNoFile
/**
* 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']);
}
示例8: install
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;
}
示例9: performProcess
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();
}
示例10: install
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;
}
示例11: updateMethodMergeDeprecatedConfigFile
/**
* 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;
}
示例12: install
//.........这里部分代码省略.........
$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]
示例13: sprintf
$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');
示例14: install
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;
}
示例15:
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.";
}