static function run_backup() { global $_lang; set_time_limit(0); ini_set('memory_limit', '1024M'); $output = array(); $db_factory = new db_factory(); $tables = $db_factory->query(" show table status from `" . DBNAME . "`"); $temp_arr = array(); foreach ($tables as $v) { if (substr($v[Name], 0, strlen(TABLEPRE)) == TABLEPRE) { $temp_arr[] = $v; } } $tables = $temp_arr; $sqlmsg = ''; foreach ($tables as $tablesarr) { $table_name = $tablesarr['Name']; $table_type = $tablesarr['Type']; $result = $db_factory->query("show fields from " . $table_name); $sqlmsg .= "#" . $_lang['table_name'] . ":<" . $table_name . ">\n"; $sqlmsg .= "DROP TABLE IF EXISTS `" . $table_name . "`;\n"; $createtable = $db_factory->query("SHOW CREATE TABLE " . $table_name); $sqlmsg .= $createtable[0]['Create Table'] . " ;\n"; $result = $db_factory->query("show fields from " . $table_name); foreach ($result as $fileds) { $fields[] = "`" . $fileds['Field'] . "`"; } $field = join(",", $fields); $sql_insert = self::querySelect($table_name, $field, $result); if ($sql_insert !== false) { $sqlmsg .= $sql_insert; } unset($fields); $output[] = str_replace(TABLEPRE . 'witkey_', '**********************', $table_name); } $sqlmsg .= "\n"; $path = S_ROOT . './data/backup/backup_' . time() . '_' . DBNAME . ".sql"; keke_tpl_class::swritefile($path, $sqlmsg); kekezu::admin_system_log($_lang['backup_database'] . '' . "backup_" . time() . '_' . DBNAME . ".sql"); file_exists($path) and kekezu::echojson('', 1, $output) or kekezu::echojson('', 0, $output); die; }
} if (mysql_errno()) { $error_arr['dbname'] = 'database_errno_1044' . mysql_error(); include INSTALL_ROOT . 'tpl' . DIRECTORY_SEPARATOR . 'sql.tpl.php'; break; } mysql_close($link); $db = new db_tool(); $db->connect($dbhost, $dbuser, $dbpw, $dbname, DBCHARSET); $temp_arr = array("dbhost" => $dbhost, "dbname" => $dbname, "dbuser" => $dbuser, "dbpass" => $dbpw, "tablepre" => $tablepre, 'cookie_path' => $c_path); $config_content = keke_tpl_class::sreadfile($config_path); foreach ($temp_arr as $key => $value) { $key = strtoupper($key); $config_content = preg_replace("/define\\s?+\\(\\s?+'({$key})'\\s?+,\\s?+.*'\\s?+\\);/i", "define ( '{$key}', '{$value}');", $config_content); } keke_tpl_class::swritefile($config_path, $config_content); // 写配置文件 if ($data_type == 'b') { // 带演示版本 $sqlfile = $sqldemofile; } $sql = file_get_contents($sqlfile); $sql = str_replace("\r\n", "\n", $sql); include INSTALL_ROOT . 'tpl' . DIRECTORY_SEPARATOR . $step . '.tpl.php'; runquery($sql, $tablepre, $db); // ob for ($i = 1; $i <= 3; $i++) { $sql_district = file_get_contents(INSTALL_ROOT . 'data/keke_witkey_district_' . $i . '.sql'); $sql_district = str_replace("\r\n", "\n", $sql_district); runquery($sql_district, $tablepre, $db); // ob
<?php defined('ADMIN_KEKE') or exit('Access Denied'); kekezu::admin_check_role(51); $filename = S_ROOT . './tpl/' . $tplname . '/' . $tname; $code_content = htmlspecialchars(keke_tpl_class::sreadfile($filename)); if ($sbt_edit) { $filename = S_ROOT . $tname; if (!is_writable($filename)) { kekezu::admin_show_msg($_lang['file'] . $filename . $_lang['can_not_write_please_check'], "index.php?do=tpl&view=tpllist&tplname={$tplname}", 3, '', 'warning'); } keke_tpl_class::swritefile($filename, htmlspecialchars_decode(kekezu::k_stripslashes($txt_code_content))); kekezu::admin_system_log($_lang['edit_template'] . $tplname . '/' . $tname); kekezu::admin_show_msg($_lang['tpl_edit_success'], "index.php?do=tpl&view=tpllist&tplname={$tplname}", 3, '', 'success'); } require $template_obj->template(ADMIN_DIRECTORY . '/tpl/admin_tpl_' . $view);
} $postdata = "m=app&a=add&ucfounder=&ucfounderpw=" . urlencode($ucfounderpw) . "&apptype=" . urlencode($app_type) . "&appname=" . urlencode($app_name) . "&appurl=" . urlencode($app_url) . "&appip=&appcharset=" . CHARSET . '&appdbcharset=' . DBCHARSET . '&' . $app_tagtemplates . '&release=' . UC_CLIENT_RELEASE; $ucconfig = uc_fopen($ucapi . '/index.php', 500, $postdata, '', 1, $ucip); if (empty($ucconfig)) { kekezu::admin_show_msg($_lang['uc_app_fail_to_add'], 'index.php?do=config&view=integration&type=uc', '', 3, 'warning'); } elseif ($ucconfig == '-1') { kekezu::admin_show_msg($_lang['uc_error_author_password'], 'index.php?do=config&view=integration&type=uc', 3, '', 'warning'); } else { list($appauthkey, $appid) = explode('|', $ucconfig); if (empty($appauthkey) || empty($appid)) { kekezu::admin_system_log($_lang['add_log_msg']); kekezu::admin_show_msg(keke::lang('uc_app_invalid_to_add'), 'index.php?do=config&view=integration&type=uc', 3, '', 'success'); } } } $ucconfig_info = explode('|', $ucconfig); $config_ucenter = keke_tpl_class::sreadfile(S_ROOT . "/config/config_ucenter.php"); $config_ucenter = preg_replace("/define\\('UC_KEY',\\s*'.*?'\\);/s", "define('UC_KEY', '" . $ucconfig_info['0'] . "');", $config_ucenter); $config_ucenter = preg_replace("/define\\('UC_APPID',\\s*'*.*?'*\\);/s", "define('UC_APPID', " . $ucconfig_info[1] . ");", $config_ucenter); keke_tpl_class::swritefile(S_ROOT . "/config/config_ucenter.php", $config_ucenter); $config_obj->setWhere(" k = 'user_intergration'"); $config_obj->setV(2); $config_obj->edit_keke_witkey_basic_config(); $kekezu->_cache_obj->gc(); kekezu::admin_system_log($_lang['uc_integrate_log']); kekezu::admin_show_msg($_lang['uc_integrate_success'], "index.php?do=config&view=integration", 2, '', 'success'); } require $template_obj->template(ADMIN_DIRECTORY . '/tpl/admin_config_' . $view . '_uc'); die; } require $template_obj->template(ADMIN_DIRECTORY . '/tpl/admin_config_' . $view);