exit; } icms_core_Filesystem::chmod("../mainfile.php", 0444); if (defined('XOOPS_TRUST_PATH') && XOOPS_TRUST_PATH != '') { icms_core_Filesystem::chmod(XOOPS_TRUST_PATH, 0777); icms_core_Filesystem::chmod(XOOPS_ROOT_PATH . '/modules', 0777); icms_core_Filesystem::chmod("/modules/protector/root/modules/protector", 0777); icms_core_Filesystem::chmod("/modules/protector/trust_path/modules", 0777); if (!is_dir(XOOPS_ROOT_PATH . '/modules/protector')) { icms_core_Filesystem::copyRecursive(XOOPS_ROOT_PATH . '/install/modules/protector/root/modules/protector', XOOPS_ROOT_PATH . '/modules/protector'); } if (!is_dir(XOOPS_TRUST_PATH . '/modules')) { icms_core_Filesystem::copyRecursive(XOOPS_ROOT_PATH . '/install/modules/protector/trust_path/modules', XOOPS_TRUST_PATH . '/modules'); } if (!is_dir(XOOPS_TRUST_PATH . '/modules/protector')) { icms_core_Filesystem::copyRecursive(XOOPS_ROOT_PATH . '/install/modules/protector/trust_path/modules/protector', XOOPS_TRUST_PATH . '/modules/protector'); } icms_core_Filesystem::chmod(XOOPS_ROOT_PATH . '/modules', 0755); } $wizard->setPage('tablescreate'); $pageHasForm = true; $pageHasHelp = false; $vars =& $_SESSION['settings']; include_once "../mainfile.php"; include_once './class/dbmanager.php'; $dbm = new db_manager(); if (!$dbm->isConnectable()) { $wizard->redirectToPage('-3'); exit; } $process = '';
/** * Copy a file, or a folder and its contents * * @author Aidan Lister <*****@*****.**> * @param string $source The source * @param string $dest The destination * @return bool Returns true on success, false on failure * @deprecated Use icms_core_Filesystem::copyRecursive, instead * @todo Remove in version 1.4 - all occurrences have been removed from the core */ function icms_copyr($source, $dest) { icms_core_Debug::setDeprecated('icms_core_Filesystem::copyRecursive', sprintf(_CORE_REMOVE_IN_VERSION, '1.4')); return icms_core_Filesystem::copyRecursive($source, $dest); }
function profile_db_upgrade_2() { // Initialization $profile_field_handler = icms_getModuleHandler('field', basename(dirname(dirname(__FILE__))), 'profile'); // add new fields $fieldid = addField('email', _US_EMAIL, '', 2, 'email', 1, 5, 0, array(), 1, 255, 1); addVisibility($fieldid, array(ICMS_GROUP_ADMIN, ICMS_GROUP_USERS), 0); // Copy images icms_core_Filesystem::copyRecursive(ICMS_ROOT_PATH . '/modules/' . basename(dirname(dirname(__FILE__))) . '/images/field', ICMS_UPLOAD_PATH . '/' . basename(dirname(dirname(__FILE__))) . '/field'); // Assign Images to fields $profile_field_handler->updateAll('url', 'aim.gif', new icms_db_criteria_Compo(new icms_db_criteria_Item('field_name', 'user_aim'))); $profile_field_handler->updateAll('url', 'bio.gif', new icms_db_criteria_Compo(new icms_db_criteria_Item('field_name', 'bio'))); $profile_field_handler->updateAll('url', 'birthday.gif', new icms_db_criteria_Compo(new icms_db_criteria_Item('field_name', 'user_regdate'))); $profile_field_handler->updateAll('url', 'clock.gif', new icms_db_criteria_Compo(new icms_db_criteria_Item('field_name', 'last_login'))); $profile_field_handler->updateAll('url', 'comments.gif', new icms_db_criteria_Compo(new icms_db_criteria_Item('field_name', 'posts'))); $profile_field_handler->updateAll('url', 'email.gif', new icms_db_criteria_Compo(new icms_db_criteria_Item('field_name', 'email'))); $profile_field_handler->updateAll('url', 'house.gif', new icms_db_criteria_Compo(new icms_db_criteria_Item('field_name', 'user_from'))); $profile_field_handler->updateAll('url', 'icq.gif', new icms_db_criteria_Compo(new icms_db_criteria_Item('field_name', 'user_icq'))); $profile_field_handler->updateAll('url', 'interests.gif', new icms_db_criteria_Compo(new icms_db_criteria_Item('field_name', 'user_intrest'))); $profile_field_handler->updateAll('url', 'msnm.gif', new icms_db_criteria_Compo(new icms_db_criteria_Item('field_name', 'user_msnm'))); $profile_field_handler->updateAll('url', 'occ.gif', new icms_db_criteria_Compo(new icms_db_criteria_Item('field_name', 'user_occ'))); $profile_field_handler->updateAll('url', 'openid.gif', new icms_db_criteria_Compo(new icms_db_criteria_Item('field_name', 'openid'))); $profile_field_handler->updateAll('url', 'rank.gif', new icms_db_criteria_Compo(new icms_db_criteria_Item('field_name', 'rank'))); $profile_field_handler->updateAll('url', 'signature.gif', new icms_db_criteria_Compo(new icms_db_criteria_Item('field_name', 'user_sig'))); $profile_field_handler->updateAll('url', 'url.gif', new icms_db_criteria_Compo(new icms_db_criteria_Item('field_name', 'url'))); $profile_field_handler->updateAll('url', 'username.gif', new icms_db_criteria_Compo(new icms_db_criteria_Item('field_name', 'name'))); $profile_field_handler->updateAll('url', 'ym.gif', new icms_db_criteria_Compo(new icms_db_criteria_Item('field_name', 'user_yim'))); // update existing fields $profile_field_handler->updateAll('field_type', 'url', new icms_db_criteria_Compo(new icms_db_criteria_Item('field_name', 'url'))); $profile_field_handler->updateAll('field_type', 'location', new icms_db_criteria_Compo(new icms_db_criteria_Item('field_name', 'user_from'))); $profile_field_handler->updateAll('field_type', 'openid', new icms_db_criteria_Compo(new icms_db_criteria_Item('field_name', 'openid'))); $profile_field_handler->updateAll('field_edit', '0', new icms_db_criteria_Compo(new icms_db_criteria_Item('field_name', '("posts", "openid", "user_viewoid")', 'IN'))); $profile_field_handler->updateAll('system', '1', new icms_db_criteria_Compo(new icms_db_criteria_Item('field_name', '("' . implode('", "', $profile_field_handler->getUserVars()) . '")', 'IN'))); }
function protector_oninstall_base($module, $mydirname) { // transations on module install global $ret; // TODO :-D // for Cube 2.1 if (defined('XOOPS_CUBE_LEGACY')) { $root =& XCube_Root::getSingleton(); $root->mDelegateManager->add('Legacy.Admin.Event.ModuleInstall.' . ucfirst($mydirname) . '.Success', 'protector_message_append_oninstall'); $ret = array(); } else { if (!is_array($ret)) { $ret = array(); } } $db =& icms_db_Factory::instance(); $mid = $module->getVar('mid'); // TABLES (loading mysql.sql) $sql_file_path = dirname(__FILE__) . '/sql/mysql.sql'; $prefix_mod = $db->prefix() . '_' . $mydirname; if (file_exists($sql_file_path)) { $ret[] = "SQL file found at <b>" . htmlspecialchars($sql_file_path) . "</b>.<br /> Creating tables..."; $sqlutil = new icms_db_legacy_mysql_Utility(); $sql_query = trim(file_get_contents($sql_file_path)); $sqlutil->splitMySqlFile($pieces, $sql_query); $created_tables = array(); foreach ($pieces as $piece) { $prefixed_query = $sqlutil->prefixQuery($piece, $prefix_mod); if (!$prefixed_query) { $ret[] = "Invalid SQL <b>" . htmlspecialchars($piece) . "</b><br />"; return false; } if (!$db->query($prefixed_query[0])) { $ret[] = '<b>' . htmlspecialchars($db->error()) . '</b><br />'; //var_dump( $db->error() ) ; return false; } else { if (!in_array($prefixed_query[4], $created_tables)) { $ret[] = 'Table <b>' . htmlspecialchars($prefix_mod . '_' . $prefixed_query[4]) . '</b> created.<br />'; $created_tables[] = $prefixed_query[4]; } else { $ret[] = 'Data inserted to table <b>' . htmlspecialchars($prefix_mod . '_' . $prefixed_query[4]) . '</b>.</br />'; } } } } // TEMPLATES $tplfile_handler =& new icms_view_template_file_Handler(icms::$xoopsDB); $tpl_path = dirname(__FILE__) . '/templates'; if ($handler = @opendir($tpl_path . '/')) { while (($file = readdir($handler)) !== false) { if (substr($file, 0, 1) == '.') { continue; } $file_path = $tpl_path . '/' . $file; if (is_file($file_path) && in_array(strrchr($file, '.'), array('.html', '.css', '.js'))) { $mtime = intval(@filemtime($file_path)); $tplfile =& $tplfile_handler->create(); $tplfile->setVar('tpl_source', file_get_contents($file_path), true); $tplfile->setVar('tpl_refid', $mid); $tplfile->setVar('tpl_tplset', 'default'); $tplfile->setVar('tpl_file', $mydirname . '_' . $file); $tplfile->setVar('tpl_desc', '', true); $tplfile->setVar('tpl_module', $mydirname); $tplfile->setVar('tpl_lastmodified', $mtime); $tplfile->setVar('tpl_lastimported', 0); $tplfile->setVar('tpl_type', 'module'); if (!$tplfile_handler->insert($tplfile)) { $ret[] = '<span style="color:#ff0000;">ERROR: Could not insert template <b>' . htmlspecialchars($mydirname . '_' . $file) . '</b> to the database.</span><br />'; } else { $tplid = $tplfile->getVar('tpl_id'); $ret[] = 'Template <b>' . htmlspecialchars($mydirname . '_' . $file) . '</b> added to the database. (ID: <b>' . $tplid . '</b>)<br />'; // generate compiled file if (!icms_view_Tpl::template_touch($tplid)) { $ret[] = '<span style="color:#ff0000;">ERROR: Failed compiling template <b>' . htmlspecialchars($mydirname . '_' . $file) . '</b>.</span><br />'; } else { $ret[] = 'Template <b>' . htmlspecialchars($mydirname . '_' . $file) . '</b> compiled.</span><br />'; } } } } closedir($handler); } /* Fixes Bug #619 : parse Error */ if (defined('ICMS_PRELOAD_PATH') && !file_exists(ICMS_PRELOAD_PATH . '/protector.php') && (!defined('PROTECTOR_POSTCHECK_INCLUDED') || !defined('PROTECTOR_PRECHECK_INCLUDED'))) { if (icms_core_Filesystem::copyRecursive(ICMS_TRUST_PATH . '/modules/protector/patches/ImpressCMS1.1/preload_protector.php', ICMS_PRELOAD_PATH . '/protector.php')) { $ret[] = 'Successfully moved protector preload<br />'; } else { $ret[] = icms_core_Message::error("Failed to move protector preload - your site is not protected.", "", FALSE); } } icms_view_Tpl::template_clear_module_cache($mid); return true; }
function protector_onupdate_base($module, $mydirname) { // transations on module update global $msgs; // TODO :-D // for Cube 2.1 if (defined('XOOPS_CUBE_LEGACY')) { $root =& XCube_Root::getSingleton(); $root->mDelegateManager->add('Legacy.Admin.Event.ModuleUpdate.' . ucfirst($mydirname) . '.Success', 'protector_message_append_onupdate'); $msgs = array(); } else { if (!is_array($msgs)) { $msgs = array(); } } $db =& icms_db_Factory::instance(); $mid = $module->getVar('mid'); // TABLES (write here ALTER TABLE etc. if necessary) // configs (Though I know it is not a recommended way...) $check_sql = "SHOW COLUMNS FROM " . $db->prefix("config") . " LIKE 'conf_title'"; if (($result = $db->query($check_sql)) && ($myrow = $db->fetchArray($result)) && @$myrow['Type'] == 'varchar(30)') { $db->queryF("ALTER TABLE " . $db->prefix("config") . " MODIFY `conf_title` varchar(255) NOT NULL default '', MODIFY `conf_desc` varchar(255) NOT NULL default ''"); } list(, $create_string) = $db->fetchRow($db->query("SHOW CREATE TABLE " . $db->prefix("config"))); foreach (explode('KEY', $create_string) as $line) { if (preg_match('/(\\`conf\\_title_\\d+\\`) \\(\\`conf\\_title\\`\\)/', $line, $regs)) { $db->query("ALTER TABLE " . $db->prefix("config") . " DROP KEY " . $regs[1]); } } $db->query("ALTER TABLE " . $db->prefix("config") . " ADD KEY `conf_title` (`conf_title`)"); // 2.x -> 3.0 list(, $create_string) = $db->fetchRow($db->query("SHOW CREATE TABLE " . $db->prefix($mydirname . "_log"))); if (preg_match('/timestamp\\(/i', $create_string)) { $db->query("ALTER TABLE " . $db->prefix($mydirname . "_log") . " MODIFY `timestamp` DATETIME"); } // TEMPLATES (all templates have been already removed by modulesadmin) $tplfile_handler =& icms::handler('icms_view_template_file'); $tpl_path = dirname(__FILE__) . '/templates'; if ($handler = @opendir($tpl_path . '/')) { while (($file = readdir($handler)) !== false) { if (substr($file, 0, 1) == '.') { continue; } $file_path = $tpl_path . '/' . $file; if (is_file($file_path) && in_array(strrchr($file, '.'), array('.html', '.css', '.js'))) { $mtime = intval(@filemtime($file_path)); $tplfile =& $tplfile_handler->create(); $tplfile->setVar('tpl_source', file_get_contents($file_path), true); $tplfile->setVar('tpl_refid', $mid); $tplfile->setVar('tpl_tplset', 'default'); $tplfile->setVar('tpl_file', $mydirname . '_' . $file); $tplfile->setVar('tpl_desc', '', true); $tplfile->setVar('tpl_module', $mydirname); $tplfile->setVar('tpl_lastmodified', $mtime); $tplfile->setVar('tpl_lastimported', 0); $tplfile->setVar('tpl_type', 'module'); if (!$tplfile_handler->insert($tplfile)) { $msgs[] = '<span style="color:#ff0000;">ERROR: Could not insert template <b>' . htmlspecialchars($mydirname . '_' . $file) . '</b> to the database.</span>'; } else { $tplid = $tplfile->getVar('tpl_id'); $msgs[] = 'Template <b>' . htmlspecialchars($mydirname . '_' . $file) . '</b> added to the database. (ID: <b>' . $tplid . '</b>)'; // generate compiled file if (!icms_view_Tpl::template_touch($tplid)) { $msgs[] = '<span style="color:#ff0000;">ERROR: Failed compiling template <b>' . htmlspecialchars($mydirname . '_' . $file) . '</b>.</span>'; } else { $msgs[] = 'Template <b>' . htmlspecialchars($mydirname . '_' . $file) . '</b> compiled.</span>'; } } } } closedir($handler); } if (defined(ICMS_PRELOAD_PATH) && !file_exists(ICMS_PRELOAD_PATH . '/protector.php') && (!defined('PROTECTOR_POSTCHECK_INCLUDED') || !defined('PROTECTOR_PRECHECK_INCLUDED')) && function_exists('icms_copyr')) { icms_core_Filesystem::copyRecursive(ICMS_TRUST_PATH . '/modules/protector/patches/ImpressCMS1.1/preload_protector.php', ICMS_PRELOAD_PATH . '/protector.php'); } icms_view_Tpl::template_clear_module_cache($mid); return true; }
} else { $new_folder = $row['imgcat_foldername ']; } /* attempt to create the new folder for the image category */ if (FALSE === icms_core_Filesystem::mkdir(ICMS_IMANAGER_FOLDER_PATH . '/' . $new_folder)) { $newDbVersion = 36; echo '<br />' . sprintf('Unable to create category folder - %s', $new_folder); $abortUpdate = true; } else { $moved = array(); /* Get all the images in the category */ $result1 = icms::$xoopsDB->query('SELECT * FROM `' . icms::$xoopsDB->prefix('image') . '` WHERE imgcat_id=' . $row['imgcat_id']); /* copy all the images in the category to the new folder */ while (($row1 = icms::$xoopsDB->fetchArray($result1)) && !$abortUpdate) { if (!file_exists(ICMS_IMANAGER_FOLDER_PATH . '/' . $new_folder . '/' . $row1['image_name']) && file_exists(ICMS_UPLOAD_PATH . '/' . $row1['image_name'])) { if (icms_core_Filesystem::copyRecursive(ICMS_UPLOAD_PATH . '/' . $row1['image_name'], ICMS_IMANAGER_FOLDER_PATH . '/' . $new_folder . '/' . $row1['image_name'])) { $moved[] = $row1['image_name']; } else { $newDbVersion = 36; echo '<br />' . sprintf('Unable to copy image - %s', $row1['image_name']); $abortUpdate = true; } } } /* if all the images were successfully copied for this category - update the category folder and * Do NOT delete the old images - it affects existing content */ if (FALSE === $abortUpdate) { icms::$xoopsDB->queryF('UPDATE `' . icms::$xoopsDB->prefix('imagecategory') . '` SET imgcat_foldername="' . $new_folder . '" WHERE imgcat_id=' . $row['imgcat_id']); /* This would delete the images from the uploads folder after they are moved * do not do this - it will affect any existing content
/** * Relocate images for ranks from previous location * @return bool */ public function MoveAllRanksImagesToProperPath() { $sql = "SELECT rank_image FROM " . $this->table; $Query = $this->query($sql, FALSE); for ($i = 0; $i < count($Query); $i++) { $values[] = $Query[$i]["rank_image"]; } foreach ($values as $value) { if (file_exists(ICMS_UPLOAD_PATH . "/" . $value)) { icms_core_Filesystem::copyRecursive(ICMS_UPLOAD_PATH . "/" . $value, $this->getImagePath() . $value); } } return TRUE; }