📄 styles.inc.php
字号:
showtablefooter();
showformfooter();
} else {
if($updatecsscache) {
updatecache('styles');
cpmsg('csscache_update', $BASESCRIPT.'?action=styles', 'succeed');
} else {
if(is_numeric($defaultnew) && $defaultid != $defaultnew && isset($sarray[$defaultnew])) {
$defaultid = $defaultnew;
$db->query("UPDATE {$tablepre}settings SET value='$defaultid' WHERE variable='styleid'");
}
$availablenew[$defaultid] = 1;
foreach($sarray as $id => $old) {
$namenew[$id] = trim($namenew[$id]);
$availablenew[$id] = $availablenew[$id] ? 1 : 0;
if($namenew[$id] != $old['name'] || $availablenew[$id] != $old['available']) {
$db->query("UPDATE {$tablepre}styles SET name='$namenew[$id]', available='$availablenew[$id]' WHERE styleid='$id'");
}
}
if(!empty($delete) && is_array($delete)) {
$did = array();
foreach($delete as $id) {
$id = intval($id);
if($id == $defaultid) {
cpmsg('styles_delete_invalid', '', 'error');
} elseif($id != 1){
$did[] = intval($id);
}
}
if($did && ($ids = implodeids($did))) {
$query = $db->query("SELECT templateid FROM {$tablepre}styles");
$tplids = array();
while($style = $db->fetch_array($query)) {
$tplids[$style['templateid']] = $style['templateid'];
}
$db->query("DELETE FROM {$tablepre}styles WHERE styleid IN ($ids)");
$db->query("DELETE FROM {$tablepre}stylevars WHERE styleid IN ($ids)");
$db->query("UPDATE {$tablepre}members SET styleid='0' WHERE styleid IN ($ids)");
$db->query("UPDATE {$tablepre}forums SET styleid='0' WHERE styleid IN ($ids)");
$db->query("UPDATE {$tablepre}sessions SET styleid='$defaultid' WHERE styleid IN ($ids)");
$query = $db->query("SELECT templateid FROM {$tablepre}styles");
while($style = $db->fetch_array($query)) {
unset($tplids[$style['templateid']]);
}
if($tplids) {
$db->query("DELETE FROM {$tablepre}templates WHERE templateid IN (".implodeids($tplids).")");
}
}
}
if($newname) {
$db->query("INSERT INTO {$tablepre}styles (name, templateid) VALUES ('$newname', '1')");
$styleidnew = $db->insert_id();
foreach(array_keys($predefinedvars) as $variable) {
$substitute = isset($predefinedvars[$variable][2]) ? $predefinedvars[$variable][2] : '';;
$db->query("INSERT INTO {$tablepre}stylevars (styleid, variable, substitute)
VALUES ('$styleidnew', '$variable', '$substitute')");
}
}
updatecache('settings');
updatecache('styles');
cpmsg('styles_edit_succeed', $BASESCRIPT.'?action=styles', 'succeed');
}
}
} 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 {
if(!isset($dir)) {
$stylearrays = array(getimportdata());
} else {
$dir = str_replace(array('/', '\\'), '', $dir);
$templatedir = DISCUZ_ROOT.'./templates/'.$dir;
$searchdir = dir($templatedir);
$stylearrays = array();
while($searchentry = $searchdir->read()) {
if(substr($searchentry, 0, 13) == 'discuz_style_' && fileext($searchentry) == 'txt') {
$importfile = $templatedir.'/'.$searchentry;
$styledata = preg_replace("/(#.*\s+)*/", '', @implode('', file($importfile)));
$style = daddslashes(unserialize(base64_decode($styledata)), 1);
if(!is_array($style)) {
cpmsg('import_data_invalid', '', 'error');
}
$stylearrays[] = $style;
}
}
}
foreach($stylearrays as $stylearray) {
if(empty($ignoreversion) && strip_tags($stylearray['version']) != strip_tags($version)) {
cpmsg('styles_import_version_invalid', '', 'error');
}
$renamed = 0;
if($stylearray['templateid'] != 1) {
$templatedir = DISCUZ_ROOT.'./'.$stylearray['directory'];
if(!is_dir($templatedir)) {
if(!@mkdir($templatedir, 0777)) {
$basedir = dirname($stylearray['directory']);
cpmsg('styles_import_directory_invalid', '', 'error');
}
}
if(!($templateid = $db->result_first("SELECT templateid FROM {$tablepre}templates WHERE name='$stylearray[tplname]'"))) {
$db->query("INSERT INTO {$tablepre}templates (name, directory, copyright)
VALUES ('$stylearray[tplname]', '$stylearray[directory]', '$stylearray[copyright]')");
$templateid = $db->insert_id();
}
} else {
$templateid = 1;
}
if($db->result_first("SELECT COUNT(*) FROM {$tablepre}styles WHERE name='$stylearray[name]'")) {
$stylearray['name'] .= '_'.random(4);
$renamed = 1;
}
$db->query("INSERT INTO {$tablepre}styles (name, templateid)
VALUES ('$stylearray[name]', '$templateid')");
$styleidnew = $db->insert_id();
foreach($stylearray['style'] as $variable => $substitute) {
$substitute = @htmlspecialchars($substitute);
$db->query("INSERT INTO {$tablepre}stylevars (styleid, variable, substitute)
VALUES ('$styleidnew', '$variable', '$substitute')");
}
}
updatecache('styles');
updatecache('settings');
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)
VALUES ('$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)
VALUES ('$styleidnew', '$stylevar[variable]', '$stylevar[substitute]')");
}
updatecache('styles');
updatecache('settings');
cpmsg('styles_copy_succeed', $BASESCRIPT.'?action=styles', 'succeed');
} elseif($operation == 'edit') {
if(!submitcheck('editsubmit')) {
if(empty($id)) {
$stylelist = "<select name=\"id\" style=\"width: 150px\">\n";
$query = $db->query("SELECT styleid, name FROM {$tablepre}styles");
while($style = $db->fetch_array($query)) {
$stylelist .= "<option value=\"$style[styleid]\">$style[name]</option>\n";
}
$stylelist .= '</select>';
cpmsg('styles_nonexistence', $BASESCRIPT.'?action=styles&operation=edit'.(!empty($highlight) ? "&highlight=$highlight" : ''), 'form', $stylelist);
}
$style = $db->fetch_first("SELECT name, templateid FROM {$tablepre}styles WHERE styleid='$id'");
if(!$style) {
cpmsg('undefined_action', '', 'error');
}
$stylecustom = '';
$stylestuff = $existvars = array();
$query = $db->query("SELECT * FROM {$tablepre}stylevars WHERE styleid='$id'");
while($stylevar = $db->fetch_array($query)) {
if(array_key_exists($stylevar['variable'], $predefinedvars)) {
$stylestuff[$stylevar['variable']] = array('id' => $stylevar['stylevarid'], 'subst' => $stylevar['substitute']);
$existvars[] = $stylevar['variable'];
} else {
$stylecustom .= showtablerow('', array('class="td25"', 'class="td24 bold"', 'class="td26"'), array(
"<input class=\"checkbox\" type=\"checkbox\" name=\"delete[]\" value=\"$stylevar[stylevarid]\">",
'{'.strtoupper($stylevar['variable']).'}',
"<textarea name=\"stylevar[$stylevar[stylevarid]]\" style=\"height: 45px\" cols=\"50\" rows=\"2\">$stylevar[substitute]</textarea>",
), TRUE);
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -