showtableheader('styles_import'); showimportdata(); showtablerow('', '', '<input class="checkbox" type="checkbox" name="ignoreversion" id="ignoreversion" value="1" /><label for="ignoreversion"> ' . cplang('styles_import_ignore_version') . '</label>'); showsubmit('importsubmit'); showtablefooter(); showformfooter(); } else { require_once libfile('function/importdata'); $restore = !empty($_G['gp_restore']) ? $_G['gp_restore'] : 0; if ($restore) { $_G['gp_dir'] = DB::result_first("SELECT t.directory FROM " . DB::table('common_style') . " s LEFT JOIN " . DB::table('common_template') . " t ON t.templateid=s.templateid WHERE s.styleid='{$restore}'"); } if (!empty($_G['gp_dir'])) { $renamed = import_styles(1, $_G['gp_dir'], $restore); } else { $renamed = import_styles($_G['gp_ignoreversion'], $_G['gp_dir']); } cpmsg(!empty($_G['gp_dir']) ? !$restore ? 'styles_install_succeed' : 'styles_restore_succeed' : ($renamed ? 'styles_import_succeed_renamed' : 'styles_import_succeed'), 'action=styles', 'succeed'); } } elseif ($operation == 'copy') { $style = DB::fetch_first("SELECT * FROM " . DB::table('common_style') . " WHERE styleid='{$id}'"); $style['name'] .= '_' . random(4); $styleidnew = DB::insert('common_style', array('name' => $style['name'], 'available' => $style['available'], 'templateid' => $style['templateid']), 1); $query = DB::query("SELECT * FROM " . DB::table('common_stylevar') . " WHERE styleid='{$id}'"); while ($stylevar = DB::fetch($query)) { $stylevar['substitute'] = addslashes($stylevar['substitute']); DB::insert('common_stylevar', array('styleid' => $styleidnew, 'variable' => $stylevar['variable'], 'substitute' => $stylevar['substitute'])); } updatecache(array('setting', 'styles')); cpmsg('styles_copy_succeed', 'action=styles', 'succeed'); } elseif ($operation == 'edit') {
echo "<p>" . lang('update', 'tables_fields_no_unused') . "</p><a href=\"{$theurl}?step=style\">" . lang('update', 'click_next_step') . "</a></p>"; } else { echo "<p><input type=\"submit\" name=\"delsubmit\" value=\"" . lang('update', 'submit_delete') . "\"></p><p>" . lang('update', 'ignore_unused') . "<br><a href=\"{$theurl}?step=style\">" . lang('update', 'next_step_directly') . "</a></p>"; } echo '</form>'; show_footer(); exit; } elseif ($_GET['step'] == 'style') { if (empty($_GET['confirm'])) { show_msg(lang('update', 'default_style_restore_sure') . "<br /><br /><a href=\"{$theurl}?step=style&confirm=yes\">[ " . lang('update', 'yes') . " ]</a> <a href=\"{$theurl}?step=cache\">[ " . lang('update', 'no') . " ]</a>", ''); } define('IN_ADMINCP', true); require_once libfile('function/admincp'); require_once libfile('function/importdata'); $dir = DB::result_first("SELECT t.directory FROM " . DB::table('common_style') . " s LEFT JOIN " . DB::table('common_template') . " t ON t.templateid=s.templateid WHERE s.styleid='1'"); import_styles(1, $dir, 1, 0); DB::update('common_setting', array('svalue' => 1), "skey='styleid'"); show_msg(lang('update', 'default_style_restored'), "{$theurl}?step=cache"); } elseif ($_GET['step'] == 'cache') { if (!$devmode && @($fp = fopen($lockfile, 'w'))) { fwrite($fp, ' '); fclose($fp); } dir_clear(ROOT_PATH . './data/template'); dir_clear(ROOT_PATH . './data/cache'); dir_clear(ROOT_PATH . './data/threadcache'); dir_clear(ROOT_PATH . './uc_client/data'); dir_clear(ROOT_PATH . './uc_client/data/cache'); show_msg(lang('update', 'database_updated') . '<iframe src="../misc.php?mod=initsys" style="display:none;"></iframe>'); } function has_another_special_table($tablename, $key)
} } } elseif ($operation == 'import') { if (!submitcheck('importsubmit') && !isset($dir)) { shownav('style', 'styles_admin'); showsubmenu('styles_admin', array(array('admin', 'styles', '0'), array('import', 'styles&operation=import', '1'))); showformheader('styles&operation=import', 'enctype'); showtableheader('styles_import'); showimportdata(); showtablerow('', '', '<input class="checkbox" type="checkbox" name="ignoreversion" id="ignoreversion" value="1" /><label for="ignoreversion"> ' . lang('styles_import_ignore_version') . '</label>'); showsubmit('importsubmit'); showtablefooter(); showformfooter(); } else { require_once DISCUZ_ROOT . './admin/importdata.func.php'; $renamed = import_styles($ignoreversion, $dir); cpmsg(!empty($dir) ? 'styles_install_succeed' : ($renamed ? 'styles_import_succeed_renamed' : 'styles_import_succeed'), $BASESCRIPT . '?action=styles', 'succeed'); } } elseif ($operation == 'copy') { $style = $db->fetch_first("SELECT * FROM {$tablepre}styles WHERE styleid='{$id}'"); $style['name'] .= '_' . random(4); $db->query("INSERT INTO {$tablepre}styles (name, available, templateid)\r\n\t\t\tVALUES ('{$style['name']}', '{$style['available']}', '{$style['templateid']}')"); $styleidnew = $db->insert_id(); $query = $db->query("SELECT * FROM {$tablepre}stylevars WHERE styleid='{$id}'"); while ($stylevar = $db->fetch_array($query)) { $stylevar['substitute'] = addslashes($stylevar['substitute']); $db->query("INSERT INTO {$tablepre}stylevars (styleid, variable, substitute)\r\n\t\t\t\tVALUES ('{$styleidnew}', '{$stylevar['variable']}', '{$stylevar['substitute']}')"); } updatecache('styles'); updatecache('settings'); cpmsg('styles_copy_succeed', $BASESCRIPT . '?action=styles', 'succeed');