/* reporting all errors for support */\r
error_reporting(E_ALL);\r
\r
-$minimum_php_version = '5.0.6';\r
-$minimum_mysql_version = '3.23';\r
+$minimum_php_version = '5.0.6';\r
+$minimum_mysql_version = '3.23';\r
\r
-$page_footer_copyright = '© 2001-2012 The Nucleus Groupe . Running Nucleus CMS v4.00';\r
+$page_footer_copyright = '© 2001-2012 The Nucleus Groupe . Running Nucleus CMS v4.00';\r
\r
// begin if: server's PHP version is below the minimum; halt installation\r
if ( version_compare(PHP_VERSION, $minimum_php_version, '<') )\r
{\r
- exit('<div style="font-size: xx-large;"> Nucleus requires at least PHP version '. $minimum_php_version .'</div>');\r
+ exit('<div style="font-size: xx-large;"> Nucleus requires at least PHP version ' . $minimum_php_version . '</div>');\r
}\r
\r
// make sure there's no unnecessary escaping: # set_magic_quotes_runtime(0);\r
}\r
\r
/* default installed plugins and skins */\r
-$aConfPlugsToInstall = array('NP_SecurityEnforcer', 'NP_SkinFiles', 'NP_Text');\r
-$aConfSkinsToImport = array('atom', 'rss2.0', 'rsd', 'default');\r
+$aConfPlugsToInstall = array('NP_SecurityEnforcer', 'NP_SkinFiles', 'NP_Text');\r
+$aConfSkinsToImport = array('atom', 'rss2.0', 'rsd', 'default');\r
\r
// Check if some important files\r
do_check_files();\r
}\r
exit;\r
\r
-\r
/**\r
* installer action\r
*/\r
}\r
break;\r
case 'weblog':\r
- if ( count($param->check_user_parameters()) == 0\r
- && count($param->check_weblog_parameters()) == 0 )\r
+ if ( count($param->check_user_parameters()) == 0 && count($param->check_weblog_parameters()) == 0 )\r
{\r
$param->set_state('install');\r
$isPostback = false;\r
header("Cache-Control: no-cache, must-revalidate");\r
header("Expires: Sat, 26 Jul 1997 05:00:00 GMT");\r
header('Content-Type: text/html; charset=' . i18n::get_current_charset());\r
-\r
?>\r
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">\r
<html xmlns="http://www.w3.org/1999/xhtml">\r
<div id="navigation">\r
<h1><img src="./styles/nucleus_rogo.png" alt="NucleusCMS" /></h1>\r
<ul>\r
- <?php\r
- if ( in_array($param->state, array('mysql', 'weblog', 'install')) )\r
- {\r
- echo '<li>', _STEP1, '</li><li';\r
- if ( $param->state == 'mysql' )\r
- {\r
- echo ' class="gry"';\r
- }\r
- echo '> > ', _STEP2, '</li><li';\r
- if ( in_array($param->state, array('mysql', 'weblog')) )\r
- {\r
- echo ' class="gry"';\r
- }\r
- echo '> > ', _STEP3, "</li>\n";\r
- }\r
- if ( in_array($param->state, array('mysql', 'weblog', 'detail')) )\r
- {\r
- echo '<li class="rightbox">';\r
- if ( in_array($param->state, array('mysql', 'weblog')) )\r
- {\r
- echo '<a href="./?mode=detail">', _MODE2, '</a>';\r
- }\r
- else\r
- {\r
- echo '<a href="./?mode=simple">', _MODE1, '</a>';\r
- }\r
- echo '</li>';\r
- }\r
- ?>\r
+<?php\r
+ if ( in_array($param->state, array('mysql', 'weblog', 'install')) )\r
+ {\r
+ echo '<li>', _STEP1, '</li><li';\r
+ if ( $param->state == 'mysql' )\r
+ {\r
+ echo ' class="gry"';\r
+ }\r
+ echo '> > ', _STEP2, '</li><li';\r
+ if ( in_array($param->state, array('mysql', 'weblog')) )\r
+ {\r
+ echo ' class="gry"';\r
+ }\r
+ echo '> > ', _STEP3, "</li>\n";\r
+ }\r
+ if ( in_array($param->state, array('mysql', 'weblog', 'detail')) )\r
+ {\r
+ echo '<li class="rightbox">';\r
+ if ( in_array($param->state, array('mysql', 'weblog')) )\r
+ {\r
+ echo '<a href="./?mode=detail">', _MODE2, '</a>';\r
+ }\r
+ else\r
+ {\r
+ echo '<a href="./?mode=simple">', _MODE1, '</a>';\r
+ }\r
+ echo '</li>';\r
+ }\r
+?>\r
</ul>\r
</div>\r
</div>\r
// Get the browser language that can be displayed\r
// TODO: default locale select simple implementation\r
$languages = explode(',', $_SERVER['HTTP_ACCEPT_LANGUAGE']);\r
- foreach ($languages as $language)\r
+ foreach ( $languages as $language )\r
{\r
$language = preg_replace('#([\w]+).*#', '$1', $language);\r
break;\r
\r
$config_writable = canConfigFileWritable();\r
$mysql_version = getMySqlVersion();\r
- ?>\r
+?>\r
<div id="container">\r
<p class="msg">\r
<?php\r
}\r
elseif ( version_compare($mysql_version, $minimum_mysql_version, '<') )\r
{\r
- echo '<span class="err">', sprintf(_DBVERSION_TOOLOW , $minimum_mysql_version), '</span>';\r
+ echo '<span class="err">', sprintf(_DBVERSION_TOOLOW, $minimum_mysql_version), '</span>';\r
}\r
?>\r
</p>\r
function show_blog_setting_form($isPostback)\r
{\r
global $param;\r
-\r
?>\r
<div id="container">\r
<p class="msg">\r
echo ($mysql_version == '0.0.0') ? _DBVERSION_UNKOWN : $mysql_version;\r
if ( version_compare($mysql_version, $minimum_mysql_version, '<') )\r
{\r
- echo '<span class="err">', sprintf(_DBVERSION_TOOLOW , $minimum_mysql_version), '</span>';\r
+ echo '<span class="err">', sprintf(_DBVERSION_TOOLOW, $minimum_mysql_version), '</span>';\r
}\r
?></li>\r
</ul>\r
{\r
echo '<span class="err">', _INST_TEXT4, '</span>';\r
?>\r
-<textarea id="config_text" readonly="readonly" onfocus="SelectText(this);"><?php echo htmlentities($_SESSION['config_data'], null, i18n::get_current_charset() ) ?></textarea>\r
+<textarea id="config_text" readonly="readonly" onfocus="SelectText(this);"><?php echo htmlentities($_SESSION['config_data'], null, i18n::get_current_charset()) ?></textarea>\r
<?php\r
}\r
else\r
/*\r
* 1. put all param-vars into vars\r
*/\r
- $MYSQL_HOST = $param->mysql_host;\r
- $MYSQL_USER = $param->mysql_user;\r
+ $MYSQL_HOST = $param->mysql_host;\r
+ $MYSQL_USER = $param->mysql_user;\r
$MYSQL_PASSWORD = $param->mysql_password;\r
$MYSQL_DATABASE = $param->mysql_database;\r
- $MYSQL_PREFIX = $param->mysql_tablePrefix;\r
+ $MYSQL_PREFIX = $param->mysql_tablePrefix;\r
\r
$DIR_NUCLEUS = $param->AdminPath;\r
- $DIR_MEDIA = $param->MediaPath;\r
- $DIR_SKINS = $param->SkinsPath;\r
+ $DIR_MEDIA = $param->MediaPath;\r
+ $DIR_SKINS = $param->SkinsPath;\r
$DIR_PLUGINS = $DIR_NUCLEUS . 'plugins/';\r
$DIR_LOCALES = $DIR_NUCLEUS . 'locales/';\r
- $DIR_LIBS = $DIR_NUCLEUS . 'libs/';\r
+ $DIR_LIBS = $DIR_NUCLEUS . 'libs/';\r
\r
/*\r
* 2.open mySQL connection\r
\r
// table exists check\r
$result = sql_query('SHOW TABLES');\r
- while ($row = mysql_fetch_array($result, MYSQL_NUM))\r
+ while ( $row = mysql_fetch_array($result, MYSQL_NUM) )\r
{\r
if ( in_array($row[0], $prefixed_table_names) )\r
{\r
\r
$filename = 'install.sql';\r
$fd = fopen($filename, 'r');\r
- $queries = fread($fd, filesize($filename) );\r
+ $queries = fread($fd, filesize($filename));\r
fclose($fd);\r
\r
$queries = preg_split('#(;\n|;\r)#', $queries);\r
array_merge($errors, updateConfig('Locale', i18n::get_current_locale()));\r
\r
/* escape strings for SQL */\r
- $user_name = sql_real_escape_string($param->user_name);\r
- $user_realname = sql_real_escape_string($param->user_realname);\r
- $user_password = sql_real_escape_string(md5($param->user_password));\r
- $user_email = sql_real_escape_string($param->user_email);\r
- $blog_name = sql_real_escape_string($param->blog_name);\r
- $blog_shortname = sql_real_escape_string($param->blog_shortname);\r
- $config_indexurl = sql_real_escape_string($param->IndexURL);\r
+ $user_name = sql_real_escape_string($param->user_name);\r
+ $user_realname = sql_real_escape_string($param->user_realname);\r
+ $user_password = sql_real_escape_string(md5($param->user_password));\r
+ $user_email = sql_real_escape_string($param->user_email);\r
+ $blog_name = sql_real_escape_string($param->blog_name);\r
+ $blog_shortname = sql_real_escape_string($param->blog_shortname);\r
+ $config_indexurl = sql_real_escape_string($param->IndexURL);\r
\r
/* push super admin */\r
$query = "UPDATE %s SET mname = '%s', mrealname = '%s', mpassword = '%s', memail = '%s', murl = '%s', madmin = 1, mcanlogin = 1 WHERE mnumber = 1";\r
}\r
\r
include_once($DIR_LIBS . 'skinie.php');\r
- \r
+\r
$aSkinErrors = installCustomSkins();\r
if ( count($aSkinErrors) > 0 )\r
{\r
array_merge($errors, $aSkinErrors);\r
}\r
\r
- $query = "SELECT sdnumber FROM %s WHERE sdname='default'";\r
+ $query = "SELECT sdnumber FROM %s WHERE sdname='default'";\r
$query = sprintf($query, tableName('nucleus_skin_desc'));\r
$res = sql_query($query);\r
$obj = sql_fetch_assoc($res);\r
$config_data .= "// default is \$MYSQL_HANDLER = array('mysql','mysql');\n";\r
$config_data .= "//\$MYSQL_HANDLER = array('mysql','mysql');\n";\r
$config_data .= "//\$MYSQL_HANDLER = array('pdo','mysql');\n";\r
- $config_data .= "\$MYSQL_HANDLER = array('".$MYSQL_HANDLER[0]."','".$MYSQL_HANDLER[1]."');\n";\r
+ $config_data .= "\$MYSQL_HANDLER = array('" . $MYSQL_HANDLER[0] . "','" . $MYSQL_HANDLER[1] . "');\n";\r
$config_data .= "\n";\r
$config_data .= "// main nucleus directory\n";\r
$config_data .= "\$DIR_NUCLEUS = '" . $DIR_NUCLEUS . "';\n";\r
{\r
if ( $fp = @fopen('../config.php', 'w') )\r
{\r
- $result = @fwrite($fp, $config_data, i18n::strlen($config_data) );\r
+ $result = @fwrite($fp, $config_data, i18n::strlen($config_data));\r
fclose($fp);\r
}\r
}\r
if ( $result )\r
{\r
// try to change the read-only permission.\r
- if (strtoupper(substr(PHP_OS, 0, 3)) !== 'WIN' )\r
+ if ( strtoupper(substr(PHP_OS, 0, 3)) !== 'WIN' )\r
{\r
@chmod('../config.php', 0444);\r
}\r
if ( @file_exists('../config.php') && @!is_writable('../config.php') )\r
{\r
// try to change the read-write permission.\r
- if (strtoupper(substr(PHP_OS, 0, 3)) !== 'WIN' )\r
+ if ( strtoupper(substr(PHP_OS, 0, 3)) !== 'WIN' )\r
{\r
@chmod('../config.php', 0666);\r
}\r
if ( $result != FALSE && sql_num_rows($result) > 0 )\r
{\r
$row = sql_fetch_array($result);\r
- $match = i18n::explode('.', $row['version']);\r
+ $match = preg_split('#\.#', $row['version']);\r
}\r
else\r
{\r
if ( $result != FALSE && @sql_num_rows($result) > 0 )\r
{\r
$row = sql_fetch_row($result);\r
- $match = i18n::explode('.', $row[1]);\r
+ $match = preg_split('#\.#', $row[1]);\r
}\r
else\r
{\r
//$output = shell_exec('mysql -V');\r
- $output = ( function_exists('shell_exec') ) ? @shell_exec('mysql -V') : '0.0.0';\r
+ $output = (function_exists('shell_exec')) ? @shell_exec('mysql -V') : '0.0.0';\r
preg_match('@[0-9]+\.[0-9]+\.[0-9]+@', $output, $version);\r
- $match = i18n::explode('.', $version[0]);\r
+ $match = preg_split('#\.#', $version[0]);\r
\r
if ( $match[0] == '' )\r
{\r
return $aErrors;\r
}\r
\r
- $res = sql_query('SELECT * FROM ' . tableName('nucleus_plugin') );\r
+ $res = sql_query('SELECT * FROM ' . tableName('nucleus_plugin'));\r
$numCurrent = sql_num_rows($res);\r
\r
foreach ( $aConfPlugsToInstall as $plugName )\r
{\r
sql_query('DELETE FROM ' . tableName('nucleus_plugin') . " WHERE pfile = '" . sql_real_escape_string($plugName) . "'");\r
$numCurrent--;\r
- array_push($aErrors, sprintf(_INST_ERROR9 ,$plugName));\r
+ array_push($aErrors, sprintf(_INST_ERROR9, $plugName));\r
continue;\r
}\r
$plugin->install();\r
}\r
\r
- sql_query('DELETE FROM ' . tableName('nucleus_plugin_event') );\r
- $res = sql_query('SELECT pid, pfile FROM ' . tableName('nucleus_plugin') );\r
+ sql_query('DELETE FROM ' . tableName('nucleus_plugin_event'));\r
+ $res = sql_query('SELECT pid, pfile FROM ' . tableName('nucleus_plugin'));\r
\r
while ( $o = sql_fetch_object($res) )\r
{\r
return $aErrors;\r
}\r
\r
-\r
/**\r
* Check if some important files of the Nucleus CMS installation are available\r
* Give an error if one or more files are not accessible\r
{\r
if ( !is_readable($files[$i]) )\r
{\r
- array_push( $missingfiles, 'File <b>' . $files[$i] . '</b> is missing or not readable.<br />');\r
+ array_push($missingfiles, 'File <b>' . $files[$i] . '</b> is missing or not readable.<br />');\r
}\r
}\r
\r
if ( count($missingfiles) > 0 )\r
{\r
- exit(implode( "\n", $missingfiles));\r
+ exit(implode("\n", $missingfiles));\r
}\r
}\r
\r
-\r
/**\r
* Updates the configuration in the database\r
*\r
{\r
$errors = array();\r
$name = sql_real_escape_string($name);\r
- $value = trim(sql_real_escape_string($value) );\r
+ $value = trim(sql_real_escape_string($value));\r
\r
$query = "UPDATE %s SET value = '%s' WHERE name = '%s'";\r
$query = sprintf($query, tableName('nucleus_config'), $value, $name);\r
return $errors;\r
}\r
\r
-\r
class ParamManager\r
{\r
/* process parameter */\r
$this->blog_shortname = 'mynucleuscms';\r
\r
/* root path */\r
-// $this->root_path = realpath(dirname(__FILE__) . '/..');\r
- $this->root_path = implode('/', i18n::explode(DIRECTORY_SEPARATOR, realpath(dirname(__FILE__) . '/..')));\r
+ // $this->root_path = realpath(dirname(__FILE__) . '/..');\r
+ $directory_separator = preg_quote(DIRECTORY_SEPARATOR, '|');\r
+ $this->root_path = implode('/', preg_split("|$directory_separator|", realpath(dirname(__FILE__) . '/..')));\r
if ( substr($this->root_path, -1, 1) !== '/' )\r
{\r
$this->root_path .= '/';\r
$base_path_pcre = preg_quote($this->root_path, '|');\r
\r
/* current directry name */\r
- $directory_name = preg_replace("|$base_path_pcre|", '', implode('/', i18n::explode(DIRECTORY_SEPARATOR, realpath(dirname(__FILE__)))));\r
+ $directory_name = preg_replace("|$base_path_pcre|", '', implode('/', preg_split("|$directory_separator|", realpath(dirname(__FILE__)))));\r
$directory_name_pcre = preg_quote($directory_name, '|');\r
\r
/* root uri */\r
$this->MediaPath = $this->root_path . 'media/';\r
$this->SkinsPath = $this->root_path . 'skins/';\r
\r
- $this->IndexURL = $this->root_url;\r
- $this->AdminURL = $this->root_url . 'nucleus/';\r
- $this->MediaURL = $this->root_url . 'media/';\r
- $this->SkinsURL = $this->root_url . 'skins/';\r
+ $this->IndexURL = $this->root_url;\r
+ $this->AdminURL = $this->root_url . 'nucleus/';\r
+ $this->MediaURL = $this->root_url . 'media/';\r
+ $this->SkinsURL = $this->root_url . 'skins/';\r
$this->PluginURL = $this->root_url . 'nucleus/plugins/';\r
$this->ActionURL = $this->root_url . 'action.php';\r
}\r
{\r
$errors[] = sprintf(_VALID_ERROR1, _DB_FIELD2);\r
}\r
- \r
+\r
if ( $this->mysql_user != ''\r
&& !preg_match('/^[a-z0-9_\-]+$/i', $this->mysql_user) )\r
{\r
$errors[] = sprintf(_VALID_ERROR2, _DB_FIELD2);\r
}\r
- \r
-// if ( $this->mysql_password == '' )\r
-// {\r
-// $errors[] = sprintf(_VALID_ERROR1, _DB_FIELD3);\r
-// }\r
+\r
+ // if ( $this->mysql_password == '' )\r
+ // {\r
+ // $errors[] = sprintf(_VALID_ERROR1, _DB_FIELD3);\r
+ // }\r
\r
if ( $this->mysql_database == '' )\r
{\r
{\r
$errors[] = sprintf(_VALID_ERROR3, _DB_FIELD5);\r
}\r
- \r
+\r
if ( count($errors) == 0 )\r
{\r
$mysql_conn = @sql_connect_args($this->mysql_host, $this->mysql_user, $this->mysql_password);\r