Exemplo n.º 1
0
 function assignVariables()
 {
     $umask = isset($_POST['umask']) ? $_POST['umask'] : '022';
     if (isset($_POST['umask']) && !empty($_POST['umask'])) {
         $test = testUmask(1, ilang('test_check_umask'), $umask, ilang('test_check_umask_failed'));
         $this->smarty->assign('test', $test);
     }
     $this->smarty->assign('umask', $umask);
     $this->smarty->assign('errors', $this->errors);
 }
Exemplo n.º 2
0
 function preContent(&$db)
 {
     $test = new StdClass();
     $test->error = false;
     $test->messages = array();
     $db->SetFetchMode(ADODB_FETCH_ASSOC);
     $current_version = 1;
     $query = "SELECT version from " . cms_db_prefix() . "version";
     $dbresult = $db->Execute($query);
     if (!$dbresult) {
         $test->messages[] = ilang('invalid_query', $query);
         $test->error = true;
     } else {
         while ($row = $dbresult->FetchRow()) {
             $current_version = $row["version"];
         }
         if ($current_version == 1) {
             $test->messages[] = ilang('empty_query', $query);
             $test->error = true;
         }
     }
     if (!$test->error && $current_version < CMS_SCHEMA_VERSION) {
         $test->messages[] = ilang('need_upgrade_schema', $current_version, CMS_SCHEMA_VERSION);
         while ($current_version < CMS_SCHEMA_VERSION) {
             $filename = cms_join_path(CMS_INSTALL_BASE, 'upgrades', "upgrade.{$current_version}.to." . ($current_version + 1) . '.php');
             if (file_exists($filename)) {
                 if ($this->debug) {
                     include $filename;
                 } else {
                     @(include $filename);
                 }
             } else {
                 $test->messages[] = ilang('nofiles') . ": {$filename}";
             }
             $current_version++;
         }
         $test->messages[] = ilang('schema_ok', $current_version);
     } elseif (!$test->error) {
         $test->messages[] = ilang('noneed_upgrade_schema', CMS_SCHEMA_VERSION);
     }
     if (isset($_SESSION['disable_hierarchy'])) {
         // gotta move the hierarchy stuff
         $query = 'UPDATE ' . cms_db_prefix() . 'content SET page_url = content_alias';
         $db->Execute($query);
         set_site_preference('content_autocreate_urls', 1);
         set_site_preference('content_autocreate_flaturls', 1);
         $test->messages[] = ilang('setup_flat_urls');
         unset($_SESSION['disable_hierarchy']);
     }
     $this->smarty->assign('test', $test);
 }
Exemplo n.º 3
0
 function assignVariables()
 {
     $values = array();
     $values['sitename'] = isset($_POST['sitename']) ? htmlentities($_POST['sitename'], ENT_QUOTES, 'UTF-8') : 'CMS Made Simple Site';
     $values['db']['dbms'] = isset($_POST['dbms']) ? $_POST['dbms'] : 'mysqli';
     $values['db']['host'] = isset($_POST['host']) ? $_POST['host'] : 'localhost';
     $values['db']['database'] = isset($_POST['database']) ? $_POST['database'] : 'cms';
     $values['db']['username'] = isset($_POST['username']) ? $_POST['username'] : '';
     $values['db']['password'] = isset($_POST['password']) ? $_POST['password'] : '';
     $values['db']['prefix'] = isset($_POST['prefix']) ? $_POST['prefix'] : 'cms_';
     $values['db']['db_port'] = isset($_POST['db_port']) ? $_POST['db_port'] : '';
     // $values['db']['db_socket'] = isset($_POST['db_socket']) ? $_POST['db_socket'] : '';
     if (isset($_SESSION['cms_orig_tz']) && $_SESSION['cms_orig_tz'] != '') {
         $values['timezone'] = $_SESSION['cms_orig_tz'];
         $this->smarty->assign('current_timezone', $_SESSION['cms_orig_tz']);
     }
     if (isset($_POST['timezone'])) {
         $values['timezone'] = $_POST['timezone'];
     }
     $values['umask'] = isset($_POST['umask']) ? $_POST['umask'] : '';
     $values['admininfo']['username'] = $_POST['adminusername'];
     $values['admininfo']['email'] = $_POST['adminemail'];
     if (isset($_POST['adminsalt'])) {
         $values['admininfo']['salt'] = $_POST['adminsalt'];
     }
     $values['admininfo']['password'] = $_POST['adminpassword'];
     $values['email_accountinfo'] = empty($_POST['email_accountinfo']) ? 0 : 1;
     $values['createtables'] = isset($_POST['createtables']) ? 1 : (isset($_POST['sitename']) ? 0 : 1);
     $values['createextra'] = isset($_POST['createextra']) ? 1 : (isset($_POST['sitename']) ? 0 : 1);
     $databases = array(array('name' => 'mysqli', 'title' => 'MySQLi (4.1+)'), array('name' => 'mysql', 'title' => 'MySQL (compatibility)'));
     $dbms_options = array();
     foreach ($databases as $db) {
         $extension = isset($db['extension']) ? $db['extension'] : $db['name'];
         if (extension_loaded($extension)) {
             $dbms_options[] = $db;
         }
     }
     $tmp = timezone_identifiers_list();
     if (is_array($tmp)) {
         $timezones = array();
         $timezones[''] = ilang('none');
         foreach ($tmp as $zone) {
             $timezones[$zone] = $zone;
         }
         $this->smarty->assign('timezones', $timezones);
     }
     $this->smarty->assign('extra_sql', is_file(cms_join_path(CMS_INSTALL_BASE, 'schemas', 'extra.sql')));
     $this->smarty->assign('dbms_options', $dbms_options);
     $this->smarty->assign('values', $values);
     $this->smarty->assign('errors', $this->errors);
 }
Exemplo n.º 4
0
function smarty_lang($params, &$smarty)
{
    if (count($params)) {
        $tmp = array();
        foreach ($params as $k => $v) {
            $tmp[] = $v;
        }
        $str = $tmp[0];
        $tmp2 = array();
        for ($i = 1; $i < count($tmp); $i++) {
            $tmp2[] = $params[$i];
        }
        return ilang($str, $tmp2);
    }
}
Exemplo n.º 5
0
 function assignVariables()
 {
     // do module upgrades and installs.
     ModuleOperations::get_instance()->LoadModules(TRUE);
     $allmodules = ModuleOperations::get_instance()->GetAllModuleNames();
     foreach ($allmodules as $name) {
         // we force all system modules to be loaded...
         if (ModuleOperations::get_instance()->IsSystemModule($name)) {
             $module = ModuleOperations::get_instance()->get_module_instance($name, '', TRUE);
         }
     }
     // display a message.
     $test = new StdClass();
     $test->error = false;
     $test->messages = array();
     $test->messages[] = ilang('noneed_upgrade_modules');
     $this->smarty->assign('test', $test);
     $this->smarty->assign('errors', $this->errors);
 }
Exemplo n.º 6
0
 function assignVariables()
 {
     $gCms = cmsms();
     $config =& $gCms->GetConfig();
     $test = new StdClass();
     $test->error = false;
     $test->messages = array();
     if (file_exists(TMP_CACHE_LOCATION . DIRECTORY_SEPARATOR . 'SITEDOWN')) {
         if ($this->debug) {
             $_test = unlink(TMP_CACHE_LOCATION . DIRECTORY_SEPARATOR . 'SITEDOWN');
         } else {
             $_test = @unlink(TMP_CACHE_LOCATION . DIRECTORY_SEPARATOR . 'SITEDOWN');
         }
         if (!$_test) {
             $test->messages[] = ilang('sitedown_not_removed');
             $test->error = true;
         }
     }
     $test->messages[] = ilang('upgrade_ok');
     $test->messages[] = ilang('upgrade_end', '<a href="../index.php">' . ilang('here') . '</a>', '<a href="../' . $config['admin_dir'] . '">' . ilang('go_to_admin') . '</a>');
     $this->smarty->assign('test', $test);
     $this->smarty->assign('errors', $this->errors);
 }
Exemplo n.º 7
0
 function assignVariables()
 {
     if (isset($_POST['recheck'])) {
         $error = '';
         $test = testFileUploads('cksumdat');
         if (isset($test->error)) {
             $error = $test->error;
         } elseif (count($test->files) > 1) {
             $error = ilang('upload_file_multiple');
         } else {
             if (isset($test->files[0]['error_string'])) {
                 $error = $test->files[0]['error_string'];
             } else {
                 $checksum_file = $test->files[0]['tmp_name'];
                 if ($this->debug) {
                     $handle = fopen($checksum_file, 'rb');
                 } else {
                     $handle = @fopen($checksum_file, 'rb');
                 }
                 if (!$handle) {
                     $error = ilang('upload_file_no_readable');
                 }
             }
         }
         if (empty($error)) {
             $results = array();
             while (!feof($handle)) {
                 $line = @fgets($handle, 4096);
                 $line = trim($line);
                 // clean
                 if (empty($line)) {
                     continue;
                 }
                 // skip empty line
                 $pos = strpos($line, '#');
                 if ($pos) {
                     $line = substr($line, 0, $pos);
                 }
                 // strip out comments
                 list($md5sum, $file) = explode(' *./', $line, 2);
                 // split it into fields
                 $md5sum = trim($md5sum);
                 $file = trim($file);
                 $file = str_replace('/', DIRECTORY_SEPARATOR, $file);
                 // avoid windows suck
                 $test_file = CMS_BASE . DIRECTORY_SEPARATOR . $file;
                 $test = testFileChecksum(0, '', $test_file, $md5sum, '', ilang('format_datetime'), $this->debug);
                 if ($test->res == 'green') {
                     continue;
                 }
                 // ok, skip
                 $results[] = $test;
             }
             @fclose($handle);
             if (count($results) > 0) {
                 $this->smarty->assign('results', $results);
                 $this->smarty->assign('error_fragment', 'Checksum_report_errors');
             }
             $this->smarty->assign('try_test', true);
         } else {
             $this->errors[] = $error;
         }
     }
     $this->smarty->assign('errors', $this->errors);
 }
 function preContent(&$db)
 {
     // check if db info is correct as it should at this point to prevent an undeleted installation dir
     // to be used for sending spam by messing up $_POST variables
     $db = ADONewConnection($_POST['dbms'], 'pear:date:extend:transaction');
     if (!empty($_POST['db_port'])) {
         $db->port = $_POST['db_port'];
     }
     if (!$db->Connect($_POST['host'], $_POST['username'], $_POST['password'], $_POST['database'])) {
         $this->errors[] = ilang('could_not_connect_db');
         return;
     }
     $newconfig = cmsms()->GetConfig();
     $newconfig['dbms'] = trim($_POST['dbms']);
     $newconfig['db_hostname'] = trim($_POST['host']);
     $newconfig['db_username'] = trim($_POST['username']);
     $newconfig['db_password'] = trim($_POST['password']);
     $newconfig['db_name'] = trim($_POST['database']);
     $newconfig['db_prefix'] = trim($_POST['prefix']);
     $newconfig['db_port'] = (int) $_POST['db_port'];
     $newconfig['root_url'] = rtrim(trim($_POST['docroot']), '/');
     $tmp = trim($_POST['querystr']);
     if ($tmp != 'page') {
         $newconfig['query_var'] = $_POST['querystr'];
     }
     $newconfig['timezone'] = $_POST['timezone'];
     $newconfig['default_encoding'] = $_POST['default_encoding'];
     $newconfig->save();
     if (file_exists(cms_join_path(TMP_CACHE_LOCATION, 'SITEDOWN'))) {
         if (!unlink(cms_join_path(TMP_CACHE_LOCATION, 'SITEDOWN'))) {
             echo ilang('install_admin_sitedown');
         }
     }
     #Make sure $gCms->db is set
     #Do module installation
     if (isset($_POST["createtables"]) && $_POST['createtables'] != 0) {
         $gCms = cmsms();
         global $DONT_LOAD_DB;
         $DONT_LOAD_DB = 'force';
         $db = $gCms->GetDb();
         $db->SetFetchMode(ADODB_FETCH_ASSOC);
         echo '<p>' . ilang('install_admin_update_hierarchy');
         $contentops = cmsms()->GetContentOperations();
         $contentops->SetAllHierarchyPositions();
         echo " [" . ilang('done') . "]</p>";
         echo '<p>' . ilang('install_admin_set_core_event');
         Events::SetupCoreEvents();
         echo " [" . ilang('done') . "]</p>";
         echo '<p>' . ilang('install_admin_install_modules');
         $modops = $gCms->GetModuleOperations();
         $modops->LoadModules(TRUE);
         $allmodules = $modops->GetAllModuleNames();
         if (is_array($allmodules) && count($allmodules)) {
             foreach ($allmodules as $module_name) {
                 $obj = $modops->get_module_instance($module_name, '', TRUE);
             }
         }
         echo " [" . ilang('done') . "]</p>";
         echo '<p>' . ilang('install_admin_clear_cache');
         $contentops->ClearCache();
         echo " [" . ilang('done') . "]</p>";
         // Insert new site preferences
         set_site_preference('global_umask', $_POST['umask']);
         set_site_preference('frontendlang', $_POST['frontendlang']);
         set_preference(1, 'default_cms_language', $_POST['default_cms_lang']);
     } else {
         $this->smarty->assign('tables_notinstalled', 1);
     }
     $link = str_replace(" ", "%20", $_POST['docroot']);
     if ($_POST['email_accountinfo'] == 1 && !empty($_POST['adminemail'])) {
         echo '<p>' . ilang('install_admin_emailing');
         $to = $_POST['adminemail'];
         $subject = ilang('email_accountinfo_subject');
         $message = ilang('email_accountinfo_message', $_POST['adminusername'], $_POST['adminpassword'], "{$link}/admin/");
         $message = html_entity_decode($message, ENT_QUOTES);
         // Encoded from TC
         echo @mail($to, $subject, $message) ? " [" . ilang('done') . "]" : "<strong>[" . ilang('failed') . "]</strong>";
         echo "</p>";
     }
 }
Exemplo n.º 9
0
    $sqlarray = $dbdict->CreateIndexSQL($db_prefix . 'index_userprefs_by_user_id', $db_prefix . "userprefs", 'user_id');
    $return = $dbdict->ExecuteSQLArray($sqlarray);
    $ado_ret = $return == 2 ? ilang('done') : ilang('failed');
    echo ilang('install_creating_index', 'content', $ado_ret);
    $flds = "\n\t\tuser_id I KEY,\n\t\tusername C(25),\n\t\tpassword C(40),\n\t\tadmin_access I1,\n\t\tfirst_name C(50),\n\t\tlast_name C(50),\n\t\temail C(255),\n\t\tactive I1,\n\t\tcreate_date DT,\n\t\tmodified_date DT\n\t";
    $sqlarray = $dbdict->CreateTableSQL($db_prefix . "users", $flds, $taboptarray);
    $return = $dbdict->ExecuteSQLArray($sqlarray);
    $ado_ret = $return == 2 ? ilang('done') : ilang('failed');
    echo ilang('install_creating_table', 'users', $ado_ret);
    $flds = "\n\t\tuserplugin_id I KEY,\n\t\tuserplugin_name C(255),\n\t\tcode X,\n\t\tdescription X,\n\t\tcreate_date DT,\n\t\tmodified_date DT\n\t";
    $sqlarray = $dbdict->CreateTableSQL($db_prefix . "userplugins", $flds, $taboptarray);
    $return = $dbdict->ExecuteSQLArray($sqlarray);
    $ado_ret = $return == 2 ? ilang('done') : ilang('failed');
    echo ilang('install_creating_table', 'userplugins', $ado_ret);
    $flds = "\n\t\tversion I\n\t";
    $sqlarray = $dbdict->CreateTableSQL($db_prefix . "version", $flds, $taboptarray);
    $return = $dbdict->ExecuteSQLArray($sqlarray);
    $ado_ret = $return == 2 ? ilang('done') : ilang('failed');
    echo ilang('install_creating_table', 'version', $ado_ret);
    $flds = "\n                sig  C(80) KEY NOT NULL,\n                name C(80) NOT NULL,\n                module C(160) NOT NULL,\n                type C(40) NOT NULL,\n                callback C(255) NOT NULL,\n                available I,\n                cachable I1\n        ";
    $sqlarray = $dbdict->CreateTableSQL($db_prefix . "module_smarty_plugins", $flds, $taboptarray);
    $return = $dbdict->ExecuteSQLArray($sqlarray);
    $ado_ret = $return == 2 ? ilang('done') : ilang('failed');
    echo ilang('install_creating_table', 'module_smarty_plugins', $ado_ret);
    $flds = "\n                term C(255) KEY NOT NULL,\n                key1 C(50) KEY NOT NULL,\n                key2 C(50),\n                key3 C(50),\n                data X, \n                created " . CMS_ADODB_DT;
    $sqlarray = $dbdict->CreateTableSQL($db_prefix . "routes", $flds, $taboptarray);
    $return = $dbdict->ExecuteSQLArray($sqlarray);
    $ado_ret = $return == 2 ? ilang('done') : ilang('failed');
    echo ilang('install_creating_table', 'routes', $ado_ret);
}
# vim:ts=4 sw=4 noet
Exemplo n.º 10
0
    fclose($fp);
    ins_header();
    ?>
<script type="text/javascript">
	function showmessage(message) {
		document.getElementById('notice').value += message + "\r\n";
	}
</script>
<table width="100%" cellspacing="0" border="0" align="center">
<tr><td align="center"><br />
<textarea name="notice" style="width: 80%; height: 400px" readonly id="notice"></textarea>
</td></tr>
</table>
<?php 
    ins_mider();
    echo "<input type=\"button\" name=\"submit\" value=\"" . ilang('installing') . "\" disabled onclick=\"window.location='index.php'\" id=\"laststep\">\n";
    ins_footer();
    runquery($sql);
    $backupdir = substr(md5($_SERVER['SERVER_ADDR'] . $_SERVER['HTTP_USER_AGENT'] . substr($timestamp, 0, 4)), 8, 6);
    @mkdir('dynamic/backup_' . $backupdir, 0777);
    $hosturl = 'http://' . $_SERVER['HTTP_HOST'];
    $php_self = $_SERVER['PHP_SELF'] ? $_SERVER['PHP_SELF'] : $_SERVER['SCRIPT_NAME'];
    $cmsurl = substr($php_self, 0, strrpos($php_self, '/')) . '/';
    $authkey = substr(md5($_SERVER['SERVER_ADDR'] . $_SERVER['HTTP_USER_AGENT'] . $dbhost . $dbuser . $dbpw . $dbname . $username . $password . $pconnect . substr($timestamp, 0, 6)), 8, 6) . random(10);
    $db->query("REPLACE INTO {$tblprefix}mconfigs (varname, value, cftype) VALUES ('authkey','{$authkey}','visit')");
    $db->query("REPLACE INTO {$tblprefix}mconfigs (varname, value, cftype) VALUES ('hosturl','{$hosturl}','site')");
    $db->query("REPLACE INTO {$tblprefix}mconfigs (varname, value, cftype) VALUES ('cmsurl','{$cmsurl}','site')");
    $db->query("REPLACE INTO {$tblprefix}mconfigs (varname, value, cftype) VALUES ('backupdir','{$backupdir}','')");
    $db->query("REPLACE INTO {$tblprefix}mconfigs (varname, value, cftype) VALUES ('dir_userfile','userfiles','upload')");
    $db->query("REPLACE INTO {$tblprefix}members (mid,mname,isfounder,password,email,checked,regdate) VALUES ('1','{$username}','1','{$password}','{$email}','1','{$timestamp}');", 'SILENT');
    $db->query("REPLACE INTO {$tblprefix}members_1 (mid) VALUES ('1')", 'SILENT');
Exemplo n.º 11
0
<?php

if (isset($CMS_INSTALL_CREATE_TABLES)) {
    $table_ids = array('additional_users' => array('id' => 'additional_users_id'), 'admin_bookmarks' => array('id' => 'bookmark_id'), 'admin_recent_pages' => array('id' => 'id'), 'content' => array('id' => 'content_id'), 'content_props' => array('id' => 'content_id'), 'css' => array('id' => 'css_id'), 'events' => array('id' => 'event_id'), 'event_handlers' => array('id' => 'handler_id', 'seq' => 'event_handler_seq'), 'group_perms' => array('id' => 'group_perm_id'), 'groups' => array('id' => 'group_id'), 'htmlblobs' => array('id' => 'htmlblob_id'), 'additional_htmlblob_users' => array('id' => 'additional_htmlblob_users_id'), 'permissions' => array('id' => 'permission_id'), 'templates' => array('id' => 'template_id'), 'users' => array('id' => 'user_id'), 'userplugins' => array('id' => 'userplugin_id'));
    foreach ($table_ids as $tablename => $tableinfo) {
        echo '<p>' . ilang('install_admin_db_create_seq', $tablename);
        $max = $db->Execute('SELECT max(' . $tableinfo['id'] . ') AS maxid FROM ' . $db_prefix . $tablename);
        $max = $max && ($row = $max->FetchRow()) ? $row['maxid'] + 1 : 1;
        $tableinfo['seq'] = isset($tableinfo['seq']) ? $tableinfo['seq'] : $tablename . '_seq';
        $db->CreateSequence($db_prefix . $tableinfo['seq'], $max);
        echo " [" . ilang('done') . "]</p>";
    }
}
# vim:ts=4 sw=4 noet
Exemplo n.º 12
0
 function preContent(&$db)
 {
     $db_prefix = $_POST['prefix'];
     if (isset($_POST['createtables'])) {
         $db->SetFetchMode(ADODB_FETCH_ASSOC);
         $CMS_INSTALL_DROP_TABLES = 1;
         $CMS_INSTALL_CREATE_TABLES = 1;
         include_once cms_join_path(CMS_INSTALL_BASE, 'schemas', 'schema.php');
         echo "<p>" . ilang('install_admin_importing');
         $handle = '';
         if (isset($_POST["createextra"])) {
             $_file = cms_join_path(CMS_INSTALL_BASE, 'schemas', 'extra.sql');
             if ($this->debug) {
                 $handle = fopen($_file, 'r');
             } else {
                 $handle = @fopen($_file, 'r');
             }
         } else {
             $_file = cms_join_path(CMS_INSTALL_BASE, 'schemas', 'initial.sql');
             if ($this->debug) {
                 $handle = fopen($_file, 'r');
             } else {
                 $handle = @fopen($_file, 'r');
             }
         }
         if ($handle) {
             while (!feof($handle)) {
                 @set_magic_quotes_runtime(false);
                 $s = fgets($handle, 32768);
                 if ($s != "") {
                     $s = trim(str_replace("{DB_PREFIX}", $db_prefix, $s));
                     $s = str_replace("\\r\\n", "\r\n", $s);
                     $s = str_replace("\\'", "''", $s);
                     $s = str_replace('\\"', '"', $s);
                     $result = $db->Execute($s);
                     if (!$result) {
                         die(ilang('invalid_query', $s) . ' -- ' . $db->ErrorMsg());
                     }
                 }
             }
             fclose($handle);
             echo " [" . ilang('done') . "]</p>";
         } else {
             echo ilang('install_admin_error_schema') . "</p>";
         }
         echo "<p>" . ilang('install_admin_set_account');
         $sql_error = false;
         if ($_POST['adminsalt'] == '1') {
             $salt = substr(str_shuffle("23456789ABCDEFGHJKMNPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz@#\$%^&*"), 0, 16);
         } else {
             $salt = '';
         }
         $sql = 'UPDATE ' . $db_prefix . 'users SET username = ?, password = ?, email = ? WHERE user_id = 1';
         $dbresult = $db->Execute($sql, array($_POST['adminusername'], md5($salt . $_POST['adminpassword']), $_POST['adminemail']));
         if (!$dbresult) {
             echo ilang('invalid_query', $db->{$sql}) . "</p>";
             $sql_error = true;
         } else {
             echo " [" . ilang('done') . "]</p>";
         }
         echo "<p>" . ilang('install_admin_set_sitename');
         $query = "INSERT INTO " . $db_prefix . "siteprefs (sitepref_name, sitepref_value) VALUES (?,?)";
         $dbresult = $db->Execute($query, array('sitename', htmlentities($_POST['sitename'], ENT_QUOTES, 'UTF-8')));
         if (!$dbresult) {
             echo ilang('invalid_query', $db->sql) . "</p>";
             $sql_error = true;
         } else {
             echo " [" . ilang('done') . "]</p>";
         }
         $dbresult = $db->Execute($query, array('sitemask', $salt));
         if (!$dbresult) {
             echo ilang('invalid_query', $db->sql) . "</p>";
             $sql_error = true;
         }
         include_once cms_join_path(CMS_INSTALL_BASE, 'schemas', 'createseq.php');
         $db->Close();
         if (!$sql_error) {
             echo '<p class="success">' . ilang('success') . '!</p>';
         } else {
             echo '<p class="error">' . ilang('invalid_querys') . '!</p>';
         }
     }
 }
Exemplo n.º 13
0
$sqlarray = $dbdict->AddColumnSQL(cms_db_prefix() . 'adminlog', 'ip_addr C(20)');
$return = $dbdict->ExecuteSQLArray($sqlarray);
echo "[done]</p>";
echo '<p>Adding columns to modules table...';
$sqlarray = $dbdict->AddColumnSQL(cms_db_prefix() . 'modules', 'allow_fe_lazyload I1,allow_admin_lazyload I1');
$return = $dbdict->ExecuteSQLArray($sqlarray);
echo "[done]</p>";
echo '<p>Making sure all modules (except nuSOAP) are enabled...';
$query = 'UPDATE ' . cms_db_prefix() . 'modules SET active = 1 WHERE module_name != ?';
$return = $db->Execute($query, array('nuSOAP'));
echo "[done]</p>";
echo '<p>Disabling the nusoap module...';
$query = 'UPDATE ' . cms_db_prefix() . 'modules SET active = 0 WHERE module_name = ?';
$return = $db->Execute($query, array('nuSOAP'));
echo "[done]</p>";
echo '<p>Adding columns to userplugins table...';
$sqlarray = $dbdict->AddColumnSQL(cms_db_prefix() . 'userplugins', 'description X');
$return = $dbdict->ExecuteSQLArray($sqlarray);
echo "[done]</p>";
$sqlarray = $dbdict->CreateIndexSQL(cms_db_prefix() . 'index_content_by_hierarchy', cms_db_prefix() . "content", 'hierarchy');
$return = $dbdict->ExecuteSQLArray($sqlarray);
$ado_ret = $return == 2 ? ilang('done') : ilang('failed');
echo ilang('install_creating_index', 'content', $ado_ret);
$sqlarray = $dbdict->CreateIndexSQL(cms_db_prefix() . 'event_id', cms_db_prefix() . "events", 'event_id');
$return = $dbdict->ExecuteSQLArray($sqlarray);
$ado_ret = $return == 2 ? ilang('done') : ilang('failed');
echo ilang('install_creating_index', 'content', $ado_ret);
echo '<p>Updating schema version... ';
$query = "UPDATE " . cms_db_prefix() . "version SET version = 35";
$db->Execute($query);
echo '[done]</p>';
Exemplo n.º 14
0
$return = $dbdict->ExecuteSQLArray($sqlarray);
echo "[done]</p>";
echo '<p>Adding columns to modules table...';
$sqlarray = $dbdict->AddColumnSQL(cms_db_prefix() . 'modules', 'allow_fe_lazyload I1,allow_admin_lazyload I1');
$return = $dbdict->ExecuteSQLArray($sqlarray);
echo "[done]</p>";
echo '<p>Making sure all modules (except nuSOAP) are enabled...';
$query = 'UPDATE ' . cms_db_prefix() . 'modules SET active = 1 WHERE module_name != ?';
$return = $db->Execute($query, array('nuSOAP'));
echo "[done]</p>";
echo '<p>Disabling the nusoap module...';
$query = 'UPDATE ' . cms_db_prefix() . 'modules SET active = 0 WHERE module_name = ?';
$return = $db->Execute($query, array('nuSOAP'));
echo "[done]</p>";
echo '<p>Adding columns to userplugins table...';
$sqlarray = $dbdict->AddColumnSQL(cms_db_prefix() . 'userplugins', 'description X');
$return = $dbdict->ExecuteSQLArray($sqlarray);
echo "[done]</p>";
echo '<p>Adding an index to the content table...';
$sqlarray = $dbdict->CreateIndexSQL(cms_db_prefix() . 'index_content_by_hierarchy', cms_db_prefix() . "content", 'hierarchy');
$return = $dbdict->ExecuteSQLArray($sqlarray);
echo "[done]</p>";
$sqlarray = $dbdict->CreateIndexSQL(cms_db_prefix() . 'event_id', cms_db_prefix() . "events", 'event_id');
$return = $dbdict->ExecuteSQLArray($sqlarray);
$ado_ret = $return == 2 ? ilang('done') : ilang('failed');
echo ilang('install_creating_index', 'events', $ado_ret);
echo "[done]</p>";
echo '<p>Updating schema version... ';
$query = "UPDATE " . cms_db_prefix() . "version SET version = 35";
$db->Execute($query);
echo '[done]</p>';
Exemplo n.º 15
0
function result($result = 1, $output = 1, $html = 1)
{
    if ($result) {
        $text = $html ? '<font color="#131395">' . ilang('writeable') . '</font><br />' : ilang('writeable') . "\n";
        if (!$output) {
            return $text;
        }
        echo $text;
    } else {
        $text = $html ? '<font color="#FF0000">' . ilang('unwriteable') . '</font><br />' : ilang('writeable') . "\n";
        if (!$output) {
            return $text;
        }
        echo $text;
    }
}
Exemplo n.º 16
0
echo '<p>Enhancing the adminlog table...';
$sqlarray = $dbdict->AlterColumnSQL(cms_db_prefix() . 'adminlog', 'ip_addr C(40)');
$return = $dbdict->ExecuteSQLArray($sqlarray);
$ado_ret = $return == 2 ? ilang('done') : ilang('failed');
if ($return == 2) {
    $sqlarray = $dbdict->CreateIndexSQL(cms_db_prefix() . 'index_adminlog1', cms_db_prefix() . "adminlog", 'timestamp');
    $return = $dbdict->ExecuteSQLArray($sqlarray);
}
echo "[done]</p>";
echo '<p>Enhancing the css table table... ';
$sqlarray = $dbdict->AddColumnSQL(cms_db_prefix() . 'css', 'media_query X');
$return = $dbdict->ExecuteSQLArray($sqlarray);
echo "[done]</p>";
echo '<p>Creating routes table... ';
$flds = "\n          term C(255) KEY NOT NULL,\n          key1 C(50) KEY NOT NULL,\n          key2 C(50),\n          key3 C(50),\n          data X, \n          created " . CMS_ADODB_DT;
$sqlarray = $dbdict->CreateTableSQL(cms_db_prefix() . "routes", $flds, $taboptarray);
$return = $dbdict->ExecuteSQLArray($sqlarray);
$ado_ret = $return == 2 ? ilang('done') : ilang('failed');
echo '[done]</p>';
echo '<p>Adding an index to the content table.... ';
$sqlarray = $dbdict->CreateIndexSQL(cms_db_prefix() . 'index_content_by_idhier', cms_db_prefix() . "content", 'content_id, hierarchy');
$return = $dbdict->ExecuteSQLArray($sqlarray);
$ado_ret = $return == 2 ? ilang('done') : ilang('failed');
echo '[done]</p>';
echo '<p>Building static route database... ';
cms_route_manager::rebuild_static_routes();
echo '[done]</p>';
echo '<p>Updating schema version... ';
$query = "UPDATE " . cms_db_prefix() . "version SET version = 36";
$db->Execute($query);
echo '[done]</p>';
Exemplo n.º 17
0
 function assignVariables()
 {
     $settings = array('info' => array(), 'required' => array(), 'recommended' => array());
     $safe_mode = ini_get('safe_mode');
     $open_basedir = ini_get('open_basedir');
     /*
      * Info Settings
      */
     $settings['info']['server_software'] = $_SERVER['SERVER_SOFTWARE'];
     $settings['info']['server_api'] = PHP_SAPI;
     $settings['info']['server_os'] = PHP_OS . ' ' . php_uname('r') . ' ' . ilang('on') . ' ' . php_uname('m');
     if (extension_loaded_or('apache2handler')) {
         $settings['info']['mod_security'] = getApacheModules('mod_security') ? ilang('on') : ilang('off');
     }
     /*
      * Required Settings
      */
     list($minimum, $recommended) = getTestValues('php_version');
     $settings['recommended'][] = testIntegerMask(0, ilang('test_error_estrict'), 'error_reporting', E_STRICT, ilang('test_estrict_failed'), true, true, false);
     if (defined('E_DEPRECATED')) {
         $settings['recommended'][] = testIntegerMask(0, ilang('test_error_edeprecated'), 'error_reporting', E_DEPRECATED, ilang('test_edeprecated_failed'), true, true, false);
     }
     $settings['required'][] = testVersionRange(1, ilang('test_check_php', $minimum) . '<br />' . ilang('test_min_recommend', $minimum, $recommended), phpversion(), ilang('test_requires_php_version', phpversion(), $recommended), $minimum, $recommended, false);
     $settings['required'][] = testBoolean(1, ilang('test_check_md5_func'), function_exists('md5'), '', false, false, 'Function_md5_disabled');
     list($minimum, $recommended) = getTestValues('gd_version');
     $settings['required'][] = testGDVersion(1, ilang('test_check_gd'), $minimum, ilang('test_check_gd_failed'), 'min_GD_version');
     $settings['required'][] = testFileWritable(1, ilang('test_check_write') . ' config.php', CONFIG_FILE_LOCATION, ilang('test_may_not_exist'), $this->debug);
     $settings['required'][] = testBoolean(1, ilang('test_check_tempnam'), function_exists('tempnam'), '', false, false, 'Function_tempnam_disabled');
     $settings['required'][] = testBoolean(1, ilang('test_check_magic_quotes_runtime'), 'magic_quotes_runtime', ilang('test_check_magic_quotes_runtime_failed'), true, true, 'magic_quotes_runtime_On');
     $settings['required'][] = testSupportedDatabase(1, ilang('test_check_db_drivers'), false, ilang('test_check_db_drivers_failed'));
     if ('1' != $safe_mode && !isset($_SESSION['allowsafemode'])) {
         $settings['required'][] = testCreateDirAndFile(1, ilang('test_create_dir_and_file'), ilang('info_create_dir_and_file'), $this->debug);
     }
     /*
      * Recommended Settings
      */
     list($minimum, $recommended) = getTestValues('memory_limit');
     $settings['recommended'][] = testRange(0, ilang('test_check_memory') . '<br />' . ilang('test_min_recommend', $minimum, $recommended), 'memory_limit', ilang('test_check_memory_failed'), $minimum, $recommended, true, true, null, 'memory_limit_range');
     list($minimum, $recommended) = getTestValues('max_execution_time');
     $settings['recommended'][] = testRange(0, ilang('test_check_time_limit') . '<br />' . ilang('test_min_recommend', $minimum, $recommended), 'max_execution_time', ilang('test_check_time_limit_failed'), $minimum, $recommended, true, false, 0, 'max_execution_time_range');
     $settings['recommended'][] = testBoolean(0, ilang('test_check_register_globals'), 'register_globals', ilang('test_check_register_globals_failed'), true, true, 'register_globals_enabled');
     $settings['recommended'][] = testInteger(0, ilang('test_check_output_buffering'), 'output_buffering', ilang('test_check_output_buffering_failed'), true, true, 'output_buffering_disabled');
     $settings['recommended'][] = testString(0, ilang('test_check_disable_functions'), 'disable_functions', ilang('test_check_disable_functions_failed'), true, 'green', 'yellow', 'disable_functions_not_empty');
     if (!isset($_SESSION['allowsafemode'])) {
         $settings['recommended'][] = testBoolean(0, ilang('test_check_safe_mode'), 'safe_mode', ilang('test_check_safe_mode_failed'), true, true, 'safe_mode_enabled');
     }
     $settings['recommended'][] = testString(0, ilang('test_check_open_basedir'), $open_basedir, ilang('test_check_open_basedir_failed'), false, 'green', 'yellow', 'open_basedir_enabled');
     if (!isset($_SESSION['skipremote'])) {
         $settings['recommended'][] = testRemoteFile(0, ilang('test_remote_url'), '', ilang('test_remote_url_failed'), $this->debug);
     }
     $settings['recommended'][] = testBoolean(0, ilang('test_check_file_upload'), 'file_uploads', ilang('test_check_file_failed'), true, false, 'Function_file_uploads_disabled');
     list($minimum, $recommended) = getTestValues('post_max_size');
     $settings['recommended'][] = testRange(0, ilang('test_check_post_max') . '<br />' . ilang('test_min_recommend', $minimum, $recommended), 'post_max_size', ilang('test_check_post_max_failed'), $minimum, $recommended, true, true, null, 'min_post_max_size');
     list($minimum, $recommended) = getTestValues('upload_max_filesize');
     $settings['recommended'][] = testRange(0, ilang('test_check_upload_max') . '<br />' . ilang('test_min_recommend', $minimum, $recommended), 'upload_max_filesize', ilang('test_check_upload_max_failed'), $minimum, $recommended, true, true, null, 'min_upload_max_filesize');
     $f = cms_join_path(CMS_BASE, 'uploads');
     $settings['recommended'][] = testDirWrite(0, ilang('test_check_writable', $f), $f, ilang('test_check_upload_failed'), 0, $this->debug);
     $f = cms_join_path(CMS_BASE, 'uploads' . DIRECTORY_SEPARATOR . 'images');
     $settings['recommended'][] = testDirWrite(0, ilang('test_check_writable', $f), $f, ilang('test_check_images_failed'), 0, $this->debug);
     $f = cms_join_path(CMS_BASE, 'modules');
     $settings['recommended'][] = testDirWrite(0, ilang('test_check_writable', $f), $f, ilang('test_check_modules_failed'), 0, $this->debug);
     $session_save_path = testSessionSavePath('');
     if (empty($session_save_path)) {
         $settings['recommended'][] = testDummy(ilang('test_check_session_save_path'), '', 'yellow', ilang('test_empty_session_save_path'), 'session_save_path_empty', '');
     } elseif (!empty($open_basedir)) {
         $settings['recommended'][] = testDummy(ilang('test_check_session_save_path'), '', 'yellow', ilang('test_open_basedir_session_save_path'), 'No_check_session_save_path_with_open_basedir', '');
     } else {
         $settings['recommended'][] = testDirWrite(0, ilang('test_check_session_save_path'), $session_save_path, ilang('test_check_session_save_path_failed', $session_save_path), 1, $this->debug);
     }
     $settings['recommended'][] = testBoolean(0, 'session.use_cookies', 'session.use_cookies', ilang('session_use_cookies'));
     $settings['recommended'][] = testBoolean(0, ilang('test_check_xml_func'), extension_loaded_or('xml'), ilang('test_check_xml_failed'), false, false, 'Function_xml_disabled');
     $settings['recommended'][] = testBoolean(0, ilang('test_xmlreader_class'), class_exists('XMLReader', false), ilang('test_xmlreader_failed'), false, false, 'class_xmlreader_unavailable');
     $settings['recommended'][] = testBoolean(0, ilang('test_check_file_get_contents'), function_exists('file_get_contents'), ilang('test_check_file_get_contents_failed'), false, false, 'Function_file_get_content_disabled');
     #		$settings['recommended'][] =
     #			testBoolean(0, ilang('test_check_magic_quotes_gpc'),
     #				'magic_quotes_gpc', ilang('test_check_magic_quotes_gpc_failed'), true, true, 'magic_quotes_gpc_On');
     $_log_errors_max_len = ini_get('log_errors_max_len') ? ini_get('log_errors_max_len') . '0' : '99';
     ini_set('log_errors_max_len', $_log_errors_max_len);
     $result = ini_get('log_errors_max_len') == $_log_errors_max_len;
     $settings['recommended'][] = testBoolean(0, ilang('test_check_ini_set'), $result, ilang('test_check_ini_set_failed'), false, false, 'ini_set_disabled');
     // assign settings
     list($this->continueon, $this->special_failed) = testGlobal(array(true, false), true);
     $this->smarty->assign('settings', $settings);
     $this->smarty->assign('special_failed', $this->special_failed);
     if (isset($_SESSION['advanceduser'])) {
         $this->smarty->assign('continueon', true);
     } else {
         $this->smarty->assign('continueon', $this->continueon);
     }
     $this->smarty->assign('phpinfo', getEmbedPhpInfo(INFO_CONFIGURATION | INFO_MODULES));
     $this->smarty->assign('errors', $this->errors);
 }
Exemplo n.º 18
0
 echo ilang('install_creating_index', 'content', $ado_ret);
 $flds = "\n\t\tuser_id I KEY,\n\t\tusername C(25),\n\t\tpassword C(40),\n\t\tadmin_access I1,\n\t\tfirst_name C(50),\n\t\tlast_name C(50),\n\t\temail C(255),\n\t\tactive I1,\n\t\tcreate_date DT,\n\t\tmodified_date DT\n\t";
 $sqlarray = $dbdict->CreateTableSQL($db_prefix . "users", $flds, $taboptarray);
 $return = $dbdict->ExecuteSQLArray($sqlarray);
 $ado_ret = $return == 2 ? ilang('done') : ilang('failed');
 echo ilang('install_creating_table', 'users', $ado_ret);
 $flds = "\n\t\tuserplugin_id I KEY,\n\t\tuserplugin_name C(255),\n\t\tcode X,\n\t\tdescription X,\n\t\tcreate_date DT,\n\t\tmodified_date DT\n\t";
 $sqlarray = $dbdict->CreateTableSQL($db_prefix . "userplugins", $flds, $taboptarray);
 $return = $dbdict->ExecuteSQLArray($sqlarray);
 $ado_ret = $return == 2 ? ilang('done') : ilang('failed');
 echo ilang('install_creating_table', 'userplugins', $ado_ret);
 $flds = "\n\t\tversion I\n\t";
 $sqlarray = $dbdict->CreateTableSQL($db_prefix . "version", $flds, $taboptarray);
 $return = $dbdict->ExecuteSQLArray($sqlarray);
 $ado_ret = $return == 2 ? ilang('done') : ilang('failed');
 echo ilang('install_creating_table', 'version', $ado_ret);
 /*
 $flds = "
 	sequence_id I KEY,
 	sequence_name C(25),
 	sequence_actions X,
 	sequence_panic X,
 	active I1,
 	create_date DT,
 	modified_date DT
 ";
 $sqlarray = $dbdict->CreateTableSQL($db_prefix."sequence", $flds, $taboptarray);
 $return = $dbdict->ExecuteSQLArray($sqlarray);
 $ado_ret = ($return == 2) ? ilang('done') : ilang('failed');
 echo ilang('install_creating_table', 'sequence', $ado_ret);
 */
Exemplo n.º 19
0
 /**
  * Processes submitted forms, redirects to previous page if needed
  * @return mixed Returns a ADOdb Connection object (for re-use) if created
  */
 function processSubmit($process = 'install')
 {
     if ($process == 'install') {
         switch ($this->currentPage) {
             case 2:
                 if (isset($_POST['recheck'])) {
                     $this->currentPage = 1;
                 }
                 break;
             case 3:
                 if (isset($_POST['recheck'])) {
                     $this->currentPage = 2;
                 }
                 break;
             case 4:
                 if (isset($_POST['umask']) && trim($_POST['umask']) == '') {
                     $this->errors[] = ilang('test_umask_not_given');
                     $this->currentPage = 3;
                 }
                 if (isset($_POST['recheck'])) {
                     $this->currentPage = 3;
                 }
                 break;
             case 5:
                 $_POST['adminusername'] = cleanValue(trim($_POST['adminusername']));
                 if ($_POST['adminusername'] == '') {
                     $this->errors[] = ilang('test_username_not_given');
                 } elseif (!preg_match("/^[a-zA-Z0-9\\._ ]+\$/", $_POST['adminusername'])) {
                     $this->errors[] = ilang('test_username_illegal');
                 }
                 if (trim($_POST['adminpassword']) == '' || trim($_POST['adminpasswordagain']) == '') {
                     $this->errors[] = ilang('test_not_both_passwd');
                 } elseif ($_POST['adminpassword'] != $_POST['adminpasswordagain']) {
                     $this->errors[] = ilang('test_passwd_not_match');
                 }
                 $_POST['adminemail'] = trim($_POST['adminemail']);
                 if (!empty($_POST['adminemail']) && !is_email($_POST['adminemail'])) {
                     $this->errors[] = ilang('invalidemail');
                 }
                 if (isset($_POST['email_accountinfo']) && empty($_POST['adminemail'])) {
                     $this->errors[] = ilang('test_email_accountinfo');
                 }
                 if (count($this->errors) > 0) {
                     $this->currentPage = 4;
                 }
                 break;
             case 6:
                 if (isset($_POST['prefix']) && $_POST['prefix'] != '' && !preg_match('/^[a-zA-Z0-9_]+$/', trim($_POST['prefix']))) {
                     $this->errors[] = ilang('test_database_prefix');
                     $this->currentPage = 5;
                     return;
                 }
                 if (trim($_POST['dbms']) == '') {
                     $this->errors[] = ilang('test_no_dbms');
                     $this->currentPage = 5;
                     return;
                 }
                 $db =& ADONewConnection($_POST['dbms'], 'pear:date:extend:transaction');
                 if (!empty($_POST['db_port'])) {
                     $db->port = $_POST['db_port'];
                 }
                 if (!empty($_POST['db_socket']) && $_POST['dbms'] == 'mysqli') {
                     $db->socket = $_POST['db_socket'];
                 }
                 $result = $db->Connect($_POST['host'], $_POST['username'], $_POST['password'], $_POST['database']);
                 if (!$result) {
                     $this->errors[] = ilang('test_could_not_connect_db');
                     $this->currentPage = 5;
                     return;
                 }
                 //Try to create and drop a dummy table (with appropriate prefix)
                 $db_prefix = $_POST['prefix'];
                 @$db->Execute('DROP TABLE ' . $db_prefix . 'dummyinstall');
                 $result = $db->Execute('CREATE TABLE ' . $db_prefix . 'dummyinstall (i int)');
                 if ($result) {
                     $result = $db->Execute('DROP TABLE ' . $db_prefix . 'dummyinstall');
                     if (!$result) {
                         //could not drop table
                         $this->errors[] = ilang('test_could_not_drop_table');
                         $this->currentPage = 5;
                         return;
                     }
                 } else {
                     //could not create table
                     $this->errors[] = ilang('test_could_not_create_table');
                     $this->currentPage = 5;
                     return;
                 }
                 return $db;
                 break;
         }
     } elseif ($process == 'upgrade') {
         switch ($this->currentPage) {
             case 2:
                 if (isset($_POST['recheck'])) {
                     $this->currentPage = 1;
                 }
                 break;
             case 3:
                 if (isset($_POST['recheck'])) {
                     $this->currentPage = 2;
                 }
                 break;
             case 4:
                 if (isset($_POST['recheck'])) {
                     $this->currentPage = 3;
                 }
                 break;
             case 5:
                 if (isset($_POST['recheck'])) {
                     $this->currentPage = 4;
                     return;
                 }
                 $gCms = cmsms();
                 $db =& $gCms->GetDB();
                 return $db;
                 break;
             case 6:
                 if (isset($_POST['recheck'])) {
                     $this->currentPage = 5;
                     return;
                 }
                 $gCms = cmsms();
                 $db =& $gCms->GetDB();
                 return $db;
                 break;
             case 7:
                 if (isset($_POST['recheck'])) {
                     $this->currentPage = 6;
                 }
                 break;
         }
     }
     return NULL;
 }