add(DBLAN_53, E_MESSAGE_WARNING); } else { $_POST[$type] = true; } } if(isset($_POST['exportXmlFile'])) { if(exportXmlFile($_POST['xml_prefs'],$_POST['xml_tables'],$_POST['xml_plugprefs'],$_POST['xml_themeprefs'], $_POST['package_images'], false)) { $mes = e107::getMessage(); $mes->add(LAN_CREATED, E_MESSAGE_SUCCESS); } } if(e_AJAX_REQUEST ) { session_write_close(); while (ob_get_length() !== false) // destroy all ouput buffering { ob_end_clean(); } if(varset($_GET['mode']) == 'backup') //FIXME - not displaying progress until complete. Use e-progress? { echo "".DBLAN_120."
"; $data = array(); $data[] = e_MEDIA; $data[] = e_LOG; $data[] = e_IMPORT; $data[] = e_TEMP; $data[] = e_SYSTEM."filetypes.xml"; $data[] = e_THEME.e107::getPref('sitetheme'); $plugins = e107::getPlugin()->getOtherPlugins(); foreach($plugins as $dir) { $data[] = e_PLUGIN.$dir; } $newFile = eHelper::title2sef(SITENAME)."_".date("Y-m-d-H-i-s"); $zip = e107::getFile()->zip($data, e_BACKUP.$newFile.".zip"); echo DBLAN_60." (".$zip.")
"; echo DBLAN_61."
"; $dbfile = e107::getDb()->backup('*', $newFile.".sql", array('nologs'=>1, 'droptable'=>1)); echo DBLAN_62." (".$dbfile.")"; e107::getLog()->addSuccess($zip." ".$dbfile, false)->save(DBLAN_63); } exit; } require_once ("auth.php"); $st = new system_tools; /* No longer needed after XML feature added. if(isset($_POST['backup_core']) || $_GET['mode']=='backup_core') { backup_core(); //message_handler("MESSAGE", DBLAN_1); $mes->add(DBLAN_1, E_MESSAGE_SUCCESS); } */ require_once ("footer.php"); class system_tools { public $_options = array(); private $_utf8_exclude = array(); function __construct() { global $mySQLdefaultdb; $this->_utf8_exclude = array(MPREFIX."core"); $this->_options = array( "db_update" => array('diz'=>DBLAN_15, 'label'=>DBLAN_16, 'icon'=>'fas-angle-double-up.glyph'), "verify_sql" => array('diz'=>DBLAN_4, 'label'=>DBLAN_5, 'icon'=>'fas-database.glyph'), 'optimize_sql' => array('diz'=>DBLAN_6, 'label'=> DBLAN_7, 'icon'=>'fas-wrench.glyph'), 'plugin_scan' => array('diz'=>DBLAN_28, 'label'=> DBLAN_29, 'icon'=>'fas-plug.glyph'), 'pref_editor' => array('diz'=>DBLAN_19, 'label'=> DBLAN_20, 'icon'=>'fas-edit.glyph'), // 'backup_core' => array('diz'=>DBLAN_8, 'label'=> DBLAN_9), // 'verify_sql_record' => array('diz'=>DBLAN_35, 'label'=> DBLAN_36), 'importForm' => array('diz'=>DBLAN_59, 'label'=> DBLAN_59, 'icon'=>'fas-file-import.glyph'), 'exportForm' => array('diz'=>DBLAN_58, 'label'=> DBLAN_58, 'icon'=>'fas-file-export.glyph'), 'sc_override_scan' => array('diz'=>DBLAN_55, 'label'=> DBLAN_56, 'icon'=>'fas-search.glyph'), 'convert_to_utf8' => array('diz'=>DBLAN_64,'label'=>DBLAN_65, 'icon'=>'fas-language.glyph'), 'correct_perms' => array('diz'=>DBLAN_66,'label'=>DBLAN_67, 'icon'=>'fas-folder.glyph'), 'backup' => array('diz'=>DBLAN_68,'label'=>DBLAN_69, 'icon'=>'fas-archive.glyph') ); if(deftrue('e_DEVELOPER')) { $this->_options['multisite'] = array('diz'=>"".DBLAN_114."", 'label'=> 'Multi-Site' , 'icon'=>'fas-clone.glyph'); $this->_options['github'] = array('diz'=>"".DBLAN_114." ".DBLAN_115."", 'label'=> DBLAN_112, 'icon'=>'fab-github.glyph' ); } $this->_options = multiarray_sort($this->_options, 'label'); if(isset($_POST['delplug'])) { $this->delete_plugin_entry(); // $_POST['pref_type'] } if(isset($_POST['upload'])) { $this->importXmlFile(); } if(isset($_POST['delpref']) || (isset($_POST['delpref_checked']) && isset($_POST['delpref2']))) { $this->del_pref_val($_POST['pref_type']); } if(isset($_POST['verify_sql']) || !empty($_POST['verify_table']) || varset($_GET['mode']) =='verify_sql') { e107::css('inline', " td.darker { background-color: rgba(0,0,0,0.5) } label.form-check { cursor: pointer } "); e107::js('footer-inline', " $('#core-db-verify-sql-tables input[type=\"checkbox\"]').click(function(evt){ if(this.checked) { $(this).closest('td').addClass('darker', 50 ); } else { $(this).closest('td').removeClass('darker', 300 ); } }); "); e107::getCache()->clear('Dbverify',true); require_once(e_HANDLER."db_verify_class.php"); $dbv = new db_verify; $dbv->backUrl = e_SELF."?mode=verify_sql"; $dbv->verify(); //echo e107::getMessage()->render(); return; } // ----------------- Processes ------------------ // if(isset($_POST['verify_sql_record']) || varset($_GET['mode'])=='verify_sql_record' || isset($_POST['check_verify_sql_record']) || isset($_POST['delete_verify_sql_record'])) // { //$this->verify_sql_record(); // - currently performed in db_verify_class.php // } if(isset($_POST['importForm']) || $_GET['mode']=='importForm') { $this->importForm(); } if(isset($_POST['db_update']) || varset($_GET['mode'])=='db_update') // Requires further testing. { // header("location: ".e_ADMIN."e107_update.php"); $dbupdate = null; require_once(e_ADMIN."update_routines.php"); new e107Update($dbupdate); return; } if(isset($_POST['convert_to_utf8']) || $_GET['mode'] =='convert_to_utf8') { $this->convertUTF8Form(); } if(isset($_POST['exportForm']) || $_GET['mode']=='exportForm') { $this->exportXmlForm(); } if(isset($_POST['optimize_sql']) || $_GET['mode']=='optimize_sql') { $this->optimizesql($mySQLdefaultdb); } if(isset($_POST['pref_editor']) || $_GET['mode']=='pref_editor' || isset($_POST['delpref']) || isset($_POST['delpref_checked'])) { $type = isset($_GET['type']) ? $_GET['type'] : "core"; $this->pref_editor($type); } if(isset($_POST['sc_override_scan']) || $_GET['mode']=='sc_override_scan') { $this->scan_override(); } if(isset($_POST['plugin_scan']) || e_QUERY == "plugin" || isset($_POST['delplug']) || $_GET['mode']=='plugin_scan') { $this->plugin_viewscan('refresh'); } if(!empty($_POST['create_multisite'])) { $this->multiSiteProcess(); } if(!empty($_POST['perform_utf8_convert'])) { $this->perform_utf8_convert(); return; } if(!empty($_POST['githubSyncProcess'])) { $this->githubSyncProcess(); return; } // --------------------- Modes --------------------------------. if(varset($_GET['mode'])=='correct_perms') { $this->correct_perms(); return; } if(varset($_GET['mode'])=='multisite') { $this->multiSite(); return; } if(varset($_GET['mode']) == 'github') { $this->githubSync(); } if(varset($_GET['mode']) == 'backup') { $this->backup(); return; } if(!vartrue($_GET['mode']) && !isset($_POST['db_execute'])) { $this->render_options(); } } // Developer Mode ONly.. No LANS required. private function githubSync() { $frm = e107::getForm(); $mes = e107::getMessage(); $pref = e107::pref(); if(empty($pref['developer'])) { e107::getMessage()->addError("Developer mode has to be enabled in order to use this functionality!"); e107::getRender()->tablerender(DBLAN_10.SEP.DBLAN_112, $mes->render()); return; } // Check for minimum required PHP version, and display warning instead of sync button to avoid broken functionality after syncing // MIN_PHP_VERSION constant only defined in install.php, thus hardcoded here $min_php_version = '5.6'; if(version_compare(PHP_VERSION, $min_php_version, "<")) { $mes->addWarning("The minimum required PHP version is ".$min_php_version.". You are using PHP version ".PHP_VERSION.".
Syncing with Github has been disabled to avoid broken fuctionality."); // No need to translate, developer mode only } else { $message = $frm->open('githubSync'); $message .= "

".DBLAN_116." ".e_SYSTEM."temp ".DBLAN_117."

"; $message .= $frm->button('githubSyncProcess',1,'delete', DBLAN_113); $message .= $frm->close(); $mes->addInfo($message); } e107::getRender()->tablerender(DBLAN_10.SEP.DBLAN_112, $mes->render()); } // Developer Mode ONly.. No LANS. private function githubSyncProcess() { $result = e107::getFile()->unzipGithubArchive('core'); if($result === false) { e107::getMessage()->addError( DBLAN_118 ); return null; } $success = $result['success']; $error = $result['error']; // $message = e107::getParser()->lanVars(DBLAN_121, array('x'=>$oldPath, 'y'=>$newPath)); if(!empty($success)) { e107::getMessage()->addSuccess(print_a($success,true)); } if(!empty($skipped)) { e107::getMessage()->setTitle("Skipped",E_MESSAGE_INFO)->addInfo(print_a($skipped,true)); } if(!empty($error)) { //e107::getMessage()->addError(print_a($error,true)); e107::getMessage()->setTitle("Ignored",E_MESSAGE_WARNING)->addWarning(print_a($error,true)); } e107::getRender()->tablerender(DBLAN_10.SEP.DBLAN_112, e107::getMessage()->render()); e107::getCache()->clearAll('system'); } private function backup() { $mes = e107::getMessage(); $message = DBLAN_70; $message .= "
".LAN_CREATE.""; $mes->addInfo($message); $text = "
"; e107::getRender()->tablerender(DBLAN_10.SEP.DBLAN_119, $mes->render().$text); } /** * Correct Folder and File permissions. */ function correct_perms() { $mes = e107::getMessage(); $fl = e107::getFile(); ob_start(); $fl->chmod(e_BASE); $fl->chmod(e_BASE."cron.php",0755); $errors = ob_get_clean(); if($errors !='') { $mes->addError($errors); } else { $mes->addSuccess(DBLAN_72); } e107::getRender()->tablerender(DBLAN_10.SEP.DBLAN_73, $mes->render()); } private function multiSiteProcess() { $sql = e107::getDb('new'); $mes = e107::getMessage(); $user = $_POST['name']; $pass = $_POST['password']; $server = e107::getMySQLConfig('server'); // $_POST['server']; $database = $_POST['db']; $prefix = $_POST['prefix']; if($connect = $sql->connect($server,$user, $pass, true)) { $mes->addSuccess(DBLAN_74); if(vartrue($_POST['createdb'])) { if($sql->gen("CREATE DATABASE ".$database." CHARACTER SET `utf8`")) { $mes->addSuccess(DBLAN_75); // $sql->gen("CREATE USER ".$user."@'".$server."' IDENTIFIED BY '".$pass."';"); $sql->gen("GRANT ALL ON `".$database."`.* TO ".$user."@'".$server."';"); $sql->gen("FLUSH PRIVILEGES;"); } else { $mes->addError(DBLAN_75); return; } } if(!$sql->database($database)) { $mes->addError(DBLAN_76); } $mes->addSuccess(DBLAN_76); if($this->multiSiteCreateTables($sql, $prefix)) { $coreConfig = e_CORE. "xml/default_install.xml"; $ret = e107::getXml()->e107Import($coreConfig, 'add', true, false, $sql); // Add core pref values $mes->addInfo(print_a($ret,true)); } } else { $mes->addSuccess(DBLAN_74); } if($error = $sql->getLastErrorText()) { $mes->addError($error); } // print_a($_POST); } /** * @param object $sql * @param $prefix * @return bool */ private function multiSiteCreateTables($sql, $prefix) { $mes = e107::getMessage(); $sql_data = file_get_contents(e_CORE."sql/core_sql.php"); $sql_data = preg_replace("#\/\*.*?\*\/#mis", '', $sql_data); // Strip comments if (!$sql_data) { $mes->addError(DBLAN_77); } preg_match_all("/create(.*?)(?:myisam|innodb);/si", $sql_data, $result ); $sql->gen('SET NAMES `utf8`'); foreach ($result[0] as $sql_table) { $sql_table = preg_replace("/create table\s/si", "CREATE TABLE ".$prefix, $sql_table); if (!$sql->gen($sql_table)) { $mes->addError($sql->getLastErrorText()); return false; } /* else { // $mes->addDebug($sql_table); } */ } return true; } private function multiSite() { if(!deftrue('e_DEVELOPER')) { return false; } $mes = e107::getMessage(); $frm = e107::getForm(); e107::lan('core','installer'); // Leave here until no longer experimental. - Should be placed inside lan_db.php and LANS renamed. define('LANINS_130', "Parked Domain"); define('LANINS_131', "The parked domain which will become a new e107 website."); define('LANINS_132', "mydomain.com"); define('LANINS_133', "This will create a fresh installation of e107 at the domain you specify. Using your server administration software (e.g. cPanel) - park your other domain on top of [x]"); $config = e107::getMySQLConfig(); // prefix|server|user|password|defaultdb if(!isset($POST['create_multisite'])) { $info = str_replace('[x]', e_DOMAIN, LANINS_133); $mes->addInfo($info); } $text = $frm->open('multisite')." "; /* $text .= " "; */ $text .= " "; $text .= " "; $text .= " \n"; $text .= "
".LANINS_131."
".LANINS_030."
".LANINS_031."
".LANINS_032."
".LANINS_033."
".LANINS_034."
".LANINS_073."
".LANINS_123."
".LANINS_124."
".LANINS_079."
".LANINS_081."
".$frm->admin_button('create_multisite',1,'submit','Create New Site')."
\n"; $text .= $frm->close(); e107::getRender()->tablerender(DBLAN_10.SEP."Multi-Site".SEP.$config['mySQLdefaultdb'], $mes->render().$text); } private function convertUTF8Form() { $mes = e107::getMessage(); $frm = e107::getForm(); $config = e107::getMySQLConfig(); $sql = e107::getDb(); $tp = e107::getParser(); $sql->gen('SHOW TABLE STATUS WHERE Name LIKE "'.$config['mySQLprefix'].'%" '); $text = ""; $invalidCollations = false; while($row = $sql->fetch()) { if(in_array($row['Name'],$this->_utf8_exclude)) { continue; } $text .= ""; // print_a($row); if($row['Collation'] != 'utf8_general_ci') { $invalidCollations = true; } } $text .= "
".DBLAN_78." ".DBLAN_79." ".DBLAN_80." ".DBLAN_81."
".$row['Name']." ".$row['Engine']." ".$row['Collation']." ".(($row['Collation'] == 'utf8_general_ci') ? defset('ADMIN_TRUE_ICON') : defset('ADMIN_FALSE_ICON'))."
"; if($invalidCollations == true) { $message = str_replace('[database]', $config['mySQLdefaultdb'], DBLAN_82); $message .= '
'; $message .= DBLAN_83; $message .= '
'; $message .= '
'; $message .= DBLAN_84; $message .= ''; $mes->add($tp->toHTML($message,true), E_MESSAGE_WARNING); $text .= "
".DBLAN_89."
".$frm->admin_button('perform_utf8_convert', DBLAN_90,false,DBLAN_90,'class=btn-success&data-loading-text='.DBLAN_91)."
"; } else { $mes->addSuccess(DBLAN_92); } e107::getRender()->tablerender(DBLAN_10.SEP.DBLAN_65.SEP.$config['mySQLdefaultdb'], $mes->render().$text); } private function perform_utf8_convert() { $config = e107::getMySQLConfig(); $dbtable = $config['mySQLdefaultdb']; //TODO Add a check to be sure the database is not already utf-8. // yep, needs more methods - possibly a class in e107_handler $sql = e107::getDb('utf8-convert'); $mes = e107::getMessage(); $ERROR = FALSE; // if(!$sql->gen("USE information_schema;")) // { // $mes->add("Couldn't read information_schema", E_MESSAGE_ERROR); // return; // } $queries = array(); $queries[] = $this->getQueries("SELECT CONCAT('ALTER TABLE `', table_name, '` MODIFY ', column_name, ' ', REPLACE(column_type, 'char', 'binary'), ';') FROM information_schema.columns WHERE TABLE_SCHEMA = '".$dbtable."' AND TABLE_NAME LIKE '".$config['mySQLprefix']."%' AND COLLATION_NAME != 'utf8_general_ci' and data_type LIKE '%char%';"); $queries[] = $this->getQueries("SELECT CONCAT('ALTER TABLE `', table_name, '` MODIFY ', column_name, ' ', REPLACE(column_type, 'text', 'blob'), ';') FROM information_schema.columns WHERE TABLE_SCHEMA = '".$dbtable."' AND TABLE_NAME LIKE '".$config['mySQLprefix']."%' AND COLLATION_NAME != 'utf8_general_ci' and data_type LIKE '%text%';"); $queries2 = array(); $queries2[] = $this->getQueries("SELECT CONCAT('ALTER TABLE `', table_name, '` MODIFY ', column_name, ' ', column_type, ' CHARACTER SET utf8;') FROM information_schema.columns WHERE TABLE_SCHEMA ='".$dbtable."' AND TABLE_NAME LIKE '".$config['mySQLprefix']."%' AND COLLATION_NAME != 'utf8_general_ci' and data_type LIKE '%char%';"); $queries2[] = $this->getQueries("SELECT CONCAT('ALTER TABLE `', table_name, '` MODIFY ', column_name, ' ', column_type, ' CHARACTER SET utf8;') FROM information_schema.columns WHERE TABLE_SCHEMA = '".$dbtable."' AND TABLE_NAME LIKE '".$config['mySQLprefix']."%' AND COLLATION_NAME != 'utf8_general_ci' and data_type LIKE '%text%';"); // $sql->gen("USE ".$dbtable); // print_a($queries2); // echo $mes->render(); // return; // Convert Text tables to Binary. foreach($queries as $qry) { foreach($qry as $q) { if(!$sql->db_Query($q)) { $mes->addError($q); $ERROR = TRUE; } else { $mes->addDebug($q); } } } //------------ // Convert Table Fields to utf8 $sql2 = e107::getDb('sql2'); $sql->gen('SHOW TABLE STATUS WHERE Collation != "utf8_general_ci" '); while ($row = $sql->fetch()) { $table = $row['Name']; if(in_array($row['Name'], $this->_utf8_exclude)) { continue; } $tab_query = "ALTER TABLE ".$table." DEFAULT CHARACTER SET utf8 COLLATE utf8_general_ci; "; //echo "TABQRT= ".$tab_query; if(!$sql2->db_Query($tab_query)) { $mes->addError($tab_query); $ERROR = TRUE; } else { $mes->addDebug($tab_query); } } // --------------- // Convert Table Fields back to Text/varchar etc. foreach($queries2 as $qry) { foreach($qry as $q) { if(!$sql->db_Query($q)) { $mes->addError($q); $ERROR = TRUE; } else { $mes->addDebug($q); } } } //------------ $lastQry = "ALTER DATABASE `".$dbtable."` DEFAULT CHARACTER SET utf8 COLLATE utf8_general_ci;"; if(!$sql->db_Query($lastQry)) { $mes->add($lastQry, E_MESSAGE_ERROR); } elseif($ERROR != TRUE) { $message = DBLAN_93; //$message .= "
Please now add the following line to your e107_config.php file:
\$mySQLcharset = 'utf8';"; $mes->add($message, E_MESSAGE_SUCCESS); $mes->addSuccess(DBLAN_94); $mes->addSuccess('$mySQLcharset = "utf8";'); } echo $mes->render(); } function getQueries($query) { $mes = e107::getMessage(); $sql = e107::getDb('utf8-convert'); $qry = []; if($sql->gen($query)) { while ($row = $sql->fetch('num')) { $qry[] = $row[0]; } } else { $mes->addError($query); } return $qry; /* if(!$result = mysql_query($query)) { $mes->addError("Query Failed: ".$query); return; } while ($row = mysql_fetch_array($result, 'num')) { $qry[] = $row[0]; } return $qry; * */ } /** * Delete selected preferences. * @return null */ private function del_pref_val($mode='core') { $mes = e107::getMessage(); $deleted_list = ""; $config = $this->getPrefConfig($mode); // Single Pref Deletion using button if(varset($_POST['delpref'])) { $delpref = key($_POST['delpref']); if($config->remove($delpref)) { $deleted_list .= "
  • ".$delpref."
  • "; } } // Multiple Pref deletion using checkboxes if(varset($_POST['delpref2'])) { foreach($_POST['delpref2'] as $k => $v) { if($config->remove($k)) { $deleted_list .= "
  • ".$k."
  • "; } } } if($deleted_list && $config->save()) { $mes->add(LAN_DELETED.""); e107::getCache()->clear(); } return null; } private function delete_plugin_entry() { $mes = e107::getMessage(); $sql = e107::getDb(); $del = array_keys($_POST['delplug']); if($sql->delete("plugin", "plugin_id='".intval($del[0])."'")) { $mes->add(LAN_DELETED, E_MESSAGE_SUCCESS); } else { $mes->add(LAN_DELETED_FAILED, E_MESSAGE_WARNING); } } /** * Render Options * @return null */ private function render_options() { $mes = e107::getMessage(); $tp = e107::getParser(); $text = "
    ".DBLAN_10." "; $text = "
    "; foreach($this->_options as $key=>$val) { $text .= ""; } /* $text .= "
    "; // $text .= "
    // ".$frm->admin_button('trigger_db_execute', DBLAN_51, 'execute')." //
    "; $text .= "
    "; */ e107::getRender()->tablerender(DBLAN_10, $mes->render().$text); return null; } /** * Import XML Form * @return null */ private function importForm() { // Get largest allowable file upload $frm = e107::getSingleton('e_form'); $mes = e107::getMessage(); require_once(e_HANDLER.'upload_handler.php'); $max_file_size = get_user_max_upload(); $text = "
    ".LAN_UPLOAD."
    "; $text .= $frm->admin_button('upload', LAN_UPLOAD, 'submit', LAN_UPLOAD); $text .= "
    \n"; e107::getRender()->tablerender(DBLAN_10.SEP.DBLAN_59, $mes->render().$text); return null; } /** * Export XML Dump * @return null */ private function exportXmlForm() { $mes = e107::getMessage(); $frm = e107::getSingleton('e_form'); $text = "
    ".DBLAN_95." "; $pref_types = e107::getConfig()->aliases; unset($pref_types['core_old'], $pref_types['core_backup']); // $exclusions = array('core_old'=>1,'core_backup'=>1); // $filteredprefs = array_diff($pref_types,$exclusions); foreach($pref_types as $key=>$description) { $data = e107::getConfig($key)->getPref(); $rows = count($data); $checked = (vartrue($_POST['xml_prefs'][$key]) == $key) ? 1: 0; $text .= ""; } // Plugin Preferences ---------------------------- $pluglist = e107::pref('core','plug_installed'); $text .= ""; ksort($pluglist); foreach($pluglist as $plug=>$ver) { $data = e107::getPlugConfig($plug)->getPref(); $key = $plug; $checked = false; if(!empty($data)) { $rows = count($data); $text .= ""; } } // theme preferences $sitetheme = e107::pref('core','sitetheme'); // currently just sitetheme, but could easily be expanded. $themelist = array($sitetheme); $text .= ""; // ksort($themelist); foreach($themelist as $plug) { $data = e107::getThemeConfig($plug)->getPref(); $key = $plug; $checked = false; if(!empty($data)) { $rows = count($data); $text .= ""; } } $text .= "
    ".$frm->checkbox_toggle('check-all-verify', 'xml_prefs')."  ".LAN_PREFS." ".DBLAN_98."
    ".$frm->checkbox("xml_prefs[".$key."]", $key, $checked, array('label'=>LAN_PREFS.": ".$key))." ".intval($rows)."
    ".$frm->checkbox_toggle('check-all-verify', 'xml_plugprefs')."  Plugin ".LAN_PREFS." ".DBLAN_98."
    ".$frm->checkbox("xml_plugprefs[".$key."]",$key, $checked, array('label'=>LAN_PREFS.": ".$key))." ".$rows."
    ".$frm->checkbox_toggle('check-all-verify', 'xml_plugprefs')."  Theme ".LAN_PREFS." ".DBLAN_98."
    ".$frm->checkbox("xml_themeprefs[".$key."]",$key, $checked, array('label'=>LAN_PREFS.": ".$key))." ".$rows."
    \n"; $tables = table_list(); foreach($tables as $name=>$count) { $checked = (vartrue($_POST['xml_tables'][$name]) == $name) ? 1: 0; $text .= ""; } $text .="
    ".$frm->checkbox_toggle('check-all-verify', 'xml_tables')."  ".DBLAN_97." ".DBLAN_98."
    ".$frm->checkbox("xml_tables[".$name."]", $name, $checked, array('label'=>DBLAN_99." ".$name)). " ".$count."
    ".LAN_OPTIONS."
    "; $checked = (vartrue($_POST['package_images'])) ? 1: 0; $text .= $frm->checkbox("package_images",'package_images', $checked)." ".DBLAN_100." ".e107::getParser()->replaceConstants(EXPORT_PATH)."
    ".$frm->admin_button('exportXmlFile', DBLAN_101, 'other')."
    "; // display differences between default and core prefs. /* $corePrefs = e107::pref('core'); $defaultArray = e107::getXml()->loadXMLfile(e_CORE."xml/default_install.xml", 'advanced'); $defaultPrefs = e107::getXml()->e107ImportPrefs($defaultArray); $text .= ""; foreach($defaultPrefs as $k=> $val) { if($val == $corePrefs[$k] || substr($k,-5) === '_list' || substr($k,0,9) == 'sitetheme') { continue; } $text .= ""; } $text .= "
    ".$k." ".print_a($val,true)."".print_a($corePrefs[$k],true)."
    "; */ e107::getRender()->tablerender(DBLAN_10.SEP.DBLAN_102,$mes->render(). $text); return null; } /** * Import XML Dump * @return null */ private function importXmlFile() { $ret = e107::getSingleton('xmlClass')->e107Import($_FILES['file_userfile']['tmp_name'][0]); foreach($ret['success'] as $table) { e107::getMessage()->addSuccess(DBLAN_103." $table"); } foreach($ret['failed'] as $table) { e107::getMessage()->addError(DBLAN_104." $table"); } return null; } /** * Optimize SQL * @param $mySQLdefaultdb * @return null */ private function optimizesql($mySQLdefaultdb) { $mes = e107::getMessage(); $tables = e107::getDb()->tables(); foreach($tables as $table) { e107::getDb()->gen("OPTIMIZE TABLE ".$table); } $mes->addSuccess(e107::getParser()->lanVars(DBLAN_11, $mySQLdefaultdb)); e107::getRender()->tablerender(DBLAN_10.SEP.DBLAN_7, $mes->render()); return null; } private function getPrefConfig($type) { if(strpos($type,'plugin_') === 0) { $config = e107::getPlugConfig(substr($type,7)); } elseif(strpos($type,'theme_') === 0) { $config = e107::getThemeConfig(substr($type,6)); } else { $config = e107::getConfig($type); } return $config; } /** * Preferences Editor * @param string $type * @return string text for display */ private function pref_editor($type='core') { global $e107; $frm = e107::getForm(); $mes = e107::getMessage(); $tp = e107::getParser(); $pref = e107::getPref(); $config = $this->getPrefConfig($type); $spref = $config->getPref(); ksort($spref); $text = "
    ".DBLAN_20.""; $text .= " "; foreach($spref as $key => $val) { if(is_array($val)) { $varView = deftrue('e_DEBUG') ? var_export($val, true): print_r($val, true); $ptext = "
    ".htmlentities($varView)."
    " ; } else { $ptext = htmlspecialchars($val, ENT_QUOTES, 'utf-8'); } $ptext = $tp->textclean($ptext, 80); $text .= " "; } $text .= "
    ".LAN_DELETE." ".DBLAN_17." ".DBLAN_18." ".LAN_OPTIONS."
    ".$frm->checkbox("delpref2[$key]", 1)." {$key} {$ptext} ".$frm->submit_image("delpref[$key]", LAN_DELETE, 'delete', LAN_CONFIRMDEL." [$key]")."
    ".$frm->admin_button('delpref_checked', LAN_DELCHECKED, 'delete')." ".$frm->admin_button('back', LAN_BACK, 'back')."
    \n\n"; if(strpos($type,'plugin_') === 0) { $caption = LAN_PLUGIN . SEP . ucfirst(substr($type,7)); } elseif(strpos($type,'theme_') === 0) { $caption = LAN_THEME . SEP . ucfirst(substr($type,6)); } else { $caption = ucwords($type); } e107::getRender()->tablerender(DBLAN_10.SEP.DBLAN_20.SEP.$caption, $mes->render().$text); return $text; } /** * Preferences Editor * @return null */ private function scan_override() { $pref = e107::getPref(); $mes = e107::getMessage(); $f = e107::getFile(); $config = e107::getConfig(); $fList = $f->get_files(e_CORE.'override/shortcodes/single', '\.php$'); $scList = array(); if(count($fList)) { foreach($fList as $file) { $scList[] = strtoupper(substr($file['fname'], 0, -4)); } $scList = implode(',', $scList); } $config->set('sc_override', $scList)->save(false); // core batch overrides $fList = $f->get_files(e_CORE.'override/shortcodes/batch', '\.php$'); $scList = array(); if(count($fList)) { foreach($fList as $file) { $scList[] = substr($file['fname'], 0, -4); } $scList = implode(',', $scList); } $config->set('sc_batch_override', $scList)->save(false); //$pref['sc_override'] = $scList; //save_prefs(); // $mes->add(DBLAN_57.':
    '.$pref['sc_override'], E_MESSAGE_SUCCESS); e107::getRender()->tablerender( ''.DBLAN_56, DBLAN_57.': ' .($config->get('sc_override') ? '
    '.$config->get('sc_override') : DBLAN_106) .'

    '.DBLAN_105.'' .($config->get('sc_batch_override') ? '
    '.$config->get('sc_batch_override') : DBLAN_106) ); } /** * Plugin Folder Scanner * @return null */ private function plugin_viewscan($mode = 'update') { $error_messages = array(0 => DBLAN_31, 1 => LAN_ERROR, 2 => DBLAN_33, 3 => DBLAN_34); // $error_image = array("integrity_pass.png", "integrity_fail.png", "warning.png", "blank.png"); $error_glyph = array(ADMIN_TRUE_ICON, ADMIN_FALSE_ICON, ADMIN_WARNING_ICON," "); $error_type = array('warning'=>2, 'error'=>1); global $e107; $sql = e107::getDb(); $tp = e107::getParser(); $frm = e107::getForm(); $mes = e107::getMessage(); // require_once (e_HANDLER."plugin_class.php"); // $ep = new e107plugin(); // $ep->update_plugins_table($mode); // scan for e_xxx changes and save to plugin table. // $ep->save_addon_prefs($mode); // generate global e_xxx_list prefs from plugin table. $mes->add(DBLAN_23, E_MESSAGE_SUCCESS); $mes->add("".LAN_BACK."", E_MESSAGE_SUCCESS); $mes->add(DBLAN_30); $text = "
    ".ADLAN_CL_7." "; $plg = e107::getPlug()->clearCache(); $plg->buildAddonPrefLists(); $plgClass = e107::getPlugin(); foreach($plg->getDetected() as $folder) { $plg->load($folder); $plgClass->plugFolder = $folder; $plgClass->XmlLanguageFiles('refresh'); $name = $plg->getName(); $addons = $plg->getAddons(); $text .= " "; } $text .= "
    ".LAN_NAME." ".DBLAN_25." ".DBLAN_26." ".DBLAN_27."
    ".$name." ".$folder." "; if(!empty($addons)) { foreach(explode(',', $addons) as $this_addon) { $ret_code = 3; // Default to 'not checked if((strpos($this_addon, 'e_') === 0) || (substr($this_addon, - 4, 4) == '_sql')) { $ret_code = $plg->getAddonErrors($this_addon); // See whether spaces before opening tag or after closing tag } elseif(strpos($this_addon, 'sc_') === 0) { $this_addon = substr($this_addon, 3). ' (sc)'; } if(!is_numeric($ret_code)) { $errorMessage = $ret_code['msg']; $ret_code = $error_type[$ret_code['type']]; } else { $errorMessage = $error_messages[$ret_code]; } $text .= ""; $text .= $error_glyph[$ret_code]." "; $text .= trim($this_addon); // $ret_code - 0=OK, 1=content error, 2=access error $text .= "
    "; } } $text .= "
    "; $text .= ($plg->isInstalled() === true) ? "".DBLAN_27."" : " "; $text .= "
    "; e107::getRender()->tablerender(DBLAN_10.SEP.DBLAN_22, $mes->render().$text); return null; } } //XXX - what is this for (backup core)? function db_adminmenu() //FIXME - has problems when navigation is on the LEFT instead of the right. { global $st; $var = array(); foreach($st->_options as $key=>$val) { $var[$key]['text'] = $val['label']; $var[$key]['link'] = e_SELF."?mode=".$key; $var[$key]['image_src'] = $val['icon']; } $caption = "".DBLAN_10.""; $var['_extras_']['icon'] = e107::getParser()->toIcon('e-database-24'); e107::getNav()->admin($caption, $_GET['mode'], $var); } /** * Export XML File and Copy Images. * @param object $prefs * @param object $tables * @param object $debug [optional] * @return bool|null */ function exportXmlFile($prefs,$tables=array(),$plugPrefs=array(), $themePrefs=array(), $package=FALSE,$debug=FALSE) { $xml = e107::getXml(); $tp = e107::getParser(); $mes = e107::getMessage(); $desinationFolder = null; if(vartrue($package)) { $xml->convertFilePaths = TRUE; $xml->modifiedPrefsOnly = true; $xml->filePathDestination = EXPORT_PATH; $xml->filePathPrepend = array( 'news_thumbnail' => "{e_IMAGE}newspost_images/" ); $desinationFolder = $tp->replaceConstants($xml->filePathDestination); if(!is_writable($desinationFolder)) { $message = str_replace('[folder]', $desinationFolder, DBLAN_107); $mes->add($message, E_MESSAGE_ERROR); return false ; } } $mode = ($debug === true) ? array( "debug" =>1) : null; if($xml->e107Export($prefs,$tables,$plugPrefs, $themePrefs, $mode)) { $mes->add(DBLAN_108." ".$desinationFolder."install.xml", E_MESSAGE_SUCCESS); if(varset($xml->fileConvertLog)) { foreach($xml->fileConvertLog as $oldfile) { $file = basename($oldfile); $newfile = $desinationFolder.$file; if($oldfile == $newfile || (copy($oldfile,$newfile))) { $mes->add(DBLAN_109." ".$newfile, E_MESSAGE_SUCCESS); } elseif(!file_exists($newfile)) { $mes->add(DBLAN_110." ".$newfile, E_MESSAGE_ERROR); } } } } return null; } function table_list() { // grab default language lists. //TODO - a similar function is in db_verify.php. Should probably all be moved to mysql_class.php. $exclude = array(); $exclude[] = "core"; $exclude[] = "rbinary"; $exclude[] = "parser"; $exclude[] = "tmp"; $exclude[] = "online"; $exclude[] = "upload"; $exclude[] = "user_extended_country"; // $exclude[] = "plugin"; $coreTables = e107::getDb()->tables('nolan'); $tables = array_diff($coreTables,$exclude); $tabs = array(); foreach($tables as $e107tab) { $count = (int) e107::getDb()->count($e107tab); if(!empty($count)) { $tabs[$e107tab] = $count; } } return $tabs; } ?>