styles.php

来自「全新且完善的强大网上商店系统」· PHP 代码 · 共 361 行 · 第 1/2 页

PHP
361
字号
<?php
/*
  [SOOBIC!] admin/styles.php 

	Version: 1.5
	Author: soolan (soolan@qq.com)
	Copyright: soolan (www.soobic.com)
	Last Modified: 2005/4/12 10:00

*/


if(!defined("IN_SOOBIC")) {
        exit("Access Denied");
}

if(!$allowsetstyle){
    cpheader();
		cpmsg("对不起,您的管理权限受限,不能进行此操作。");
}


if($act == 'styles' && $export) {
	$query = $db->query("SELECT s.name, s.templateid, t.name AS tplname, t.charset, t.directory, t.copyright FROM $table_styles s LEFT JOIN $table_templates t ON t.templateid=s.templateid WHERE styleid='$export'");
	if(!$stylearray = $db->fetch_array($query)) {
		cpheader();
		cpmsg('指定的风格不存在,无法导出。');
	}

	$stylearray['version'] = strip_tags($version);
	$time = gmdate("$dateformat $timeformat", $timestamp + $timeoffset * 3600);

	$query = $db->query("SELECT * FROM $table_stylevars WHERE styleid='$export'");
	while($style = $db->fetch_array($query)) {
		$stylearray['style'][$style['variable']] = $style['substitute'];
	}

	if($stylearray['templateid'] != 1) {
		$dir = dir($soobic.'./'.$stylearray['directory']);
		while($entry = $dir->read()) {
			$filename = $soobic.'./'.$stylearray['directory'].'/'.$entry;
			if(is_file($filename)) {
				$stylearray['template'][str_replace('.', '_DOT_', $entry)] = join('', file($filename));
			}
		}
		$dir->close();
	}

	$style_export = "# Soobic! Style Dump\n".
			"# Version: Soobic! 1.0.0\n".
			"# Time: $time\n".
			"# From: ".TITLE."\n".
			"#\n".
			"# This file was BASE64 encoded\n".
			"#\n".
			"# Soobic! Community: http://www.soobic.com\n".
			"# Please visit our website for newest infomation about Soobic!\n".
			"# --------------------------------------------------------\n\n\n".
			wordwrap(base64_encode(serialize($stylearray)), 50, "\n", 1);

	ob_end_clean();
	header('Content-Encoding: none');
	header('Content-Type: '.(strpos($HTTP_SERVER_VARS['HTTP_USER_AGENT'], 'MSIE') ? 'application/octetstream' : 'application/octet-stream'));
	header('Content-Disposition: '.(strpos($HTTP_SERVER_VARS['HTTP_USER_AGENT'], 'MSIE') ? 'inline; ' : 'attachment; ').'filename="Soobic_style_'.$stylearray['name'].'.txt"');
	header('Content-Length: '.strlen($style_export));
	header('Pragma: no-cache');
	header('Expires: 0');

	echo $style_export;
	soobic_exit();
}

cpheader();

if($act == 'styles' && !$export) {

	$predefinedvars = array('bgcolor', 'altbg1', 'altbg2', 'link', 'bordercolor', 'headercolor', 'headertext', 'catcolor',
				'tabletext', 'text', 'borderwidth', 'tablewidth', 'tablespace', 'fontsize', 'font',
				'smfontsize', 'smfont', 'nobold', 'boardimg', 'imgdir', 'smdir', 'cattext','borderoutcolor','maxtablewidth','maxborderwidth','maxtablespace','maxtablecolor');

	if(!$stylesubmit && !$importsubmit && !$edit && !$export) {

		$styleselect = '';
		$query = $db->query("SELECT s.styleid, s.available, s.name, t.name AS tplname, t.charset, t.copyright FROM $table_styles s LEFT JOIN $table_templates t ON t.templateid=s.templateid");
		while($styleinfo = $db->fetch_array($query)) {
			$styleselect .= "<tr align=\"center\"><td bgcolor=\"".ALTBG1."\"><input type=\"checkbox\" name=\"delete[]\" value=\"$styleinfo[styleid]\"></td>\n".
				"<td bgcolor=\"".ALTBG2."\"><input type=\"text\" name=\"namenew[$styleinfo[styleid]]\" value=\"$styleinfo[name]\" size=\"18\"></td>\n".
				"<td bgcolor=\"".ALTBG1."\"><input type=\"checkbox\" name=\"availablenew[$styleinfo[styleid]]\" value=\"1\" ".($styleinfo['available'] ? 'checked' : NULL)."></td>\n".
				"<td bgcolor=\"".ALTBG2."\">$styleinfo[styleid]</td>\n".
				"<td bgcolor=\"".ALTBG1."\">$styleinfo[tplname]</td>\n".
				"<td bgcolor=\"".ALTBG2."\">$styleinfo[charset]</td>\n".
				"<td bgcolor=\"".ALTBG1."\"><a href=\"".tep_href_link('admincp.php','act=styles&export='.$styleinfo[styleid])."\">[下载]</a></td>\n".
				"<td bgcolor=\"".ALTBG2."\"><a href=\"".tep_href_link('admincp.php','act=styles&edit='.$styleinfo[styleid])."\">[详情]</a></td></tr>\n";
		}

?>
<table cellspacing="0" cellpadding="0" border="0" width="90%" align="center">
<tr><td bgcolor="<?=BORDERCOLOR?>">
<table border="0" cellspacing="<?=BORDERWIDTH?>" cellpadding="<?=TABLESPACE?>" width="100%">
<tr class="header"><td>特别提示</td></tr>
<tr bgcolor="<?=ALTBG1?>"><td>
<br>
<ul><li>您可以指导用户通过在 URL 加入 styleid 变量来轻松切换当前界面风格,如 http://your.com/soobic/index.php?styleid=2 </ul>
<ul><li>界面方案的“可用”是指用户是否选择使用此风格,但无论设置可用与否,都可以将此界面设置为默认界面或。</ul>
</td></tr></table></td></tr></table><br><br>

<form method="post" action="<?=tep_href_link('admincp.php','act=styles')?>">
<table cellspacing="0" cellpadding="0" border="0" width="90%" align="center">
<tr><td bgcolor="<?=BORDERCOLOR?>">
<table border="0" cellspacing="<?=BORDERWIDTH?>" cellpadding="<?=TABLESPACE?>" width="100%">
<tr class="header" align="center">
<td width="45"><input type="checkbox" name="chkall" class="header" onclick="checkall(this.form)">删?</td>
<td>方案名称</td><td>可用</td><td>styleID</td><td>所用模板</td><td>字符集</td><td>导出</td><td>编辑</td></tr>
<?=$styleselect?>
<tr bgcolor="<?=ALTBG2?>"><td height="1" colspan="8"></td></tr>
<tr align="center"><td bgcolor="<?=ALTBG1?>">新增:</td>
<td bgcolor="<?=ALTBG2?>"><input type='text' name="newname" size="18"></td>
<td colspan="6" bgcolor="<?=ALTBG2?>">&nbsp;</td>
</tr></table></td></tr></table><br>
<center><input type="submit" name="stylesubmit" value="更新界面设置"></center></form>

<br><form method="post" action="admincp.php?act=styles">
<table cellspacing="<?=BORDERWIDTH?>" cellpadding="<?=TABLESPACE?>" width="90%" bgcolor="<?=BORDERCOLOR?>" align="center">
<tr class="header"><td>导入界面方案 - 请将导出的文件内容粘贴如下</td></tr>
<tr><td bgcolor="<?=ALTBG1?>" align="center"><textarea  name="styledata" cols="80" rows="8"></textarea><br>
<input type="checkbox" name="ignoreversion" value="1"> 允许导入不同版本 Soobic!的界面(易产生错误!!)</td></tr>
</table><br><center><input type="submit" name="importsubmit" value="将风格文件导入 Soobic!"></center></form>
<?

	} elseif($stylesubmit) {

		if(is_array($namenew)) {
			foreach($namenew as $id => $val) {
				$db->query("UPDATE $table_styles SET name='$namenew[$id]', available='$availablenew[$id]' WHERE styleid='$id'");
			}
		}

		if(is_array($delete)) {
			$ids = $comma = '';
			foreach($delete as $id) {
				$ids .= "$comma'$id'";
				$comma  = ', ';
			}
			$query = $db->query("SELECT COUNT(*) FROM $table_settings WHERE styleid IN ($ids)");
			if($db->result($query, 0)) {
				cpmsg("您不能直接删除系统默认的风格,请返回选择其他风格为默认后再进行删除。");
			}

			$db->query("DELETE FROM $table_styles WHERE styleid IN ($ids)");
			$db->query("DELETE FROM $table_stylevars WHERE styleid IN ($ids)");
			$db->query("UPDATE $table_members SET styleid='0' WHERE styleid IN ($ids)");
			$db->query("UPDATE $table_forums SET styleid='0' WHERE styleid IN ($ids)");
			$db->query("UPDATE $table_sessions SET styleid='$_DCACHE[settings][styleid]' WHERE styleid IN ($ids)");
		}

		if($newname) {
			$db->query("INSERT INTO $table_styles (name, templateid) VALUES ('$newname', '1')");
			$styleid = $db->insert_id();
			foreach($predefinedvars as $variable) {
				$db->query("INSERT INTO $table_stylevars (styleid, variable)
					VALUES ('$styleid', '$variable')");
			}
		}

		cpmsg("界面方案成功更新。");

	} elseif($importsubmit) {

		$styledata = preg_replace("/(#.*\s+)*/", '', $styledata);
		$stylearray = daddslashes(unserialize(base64_decode($styledata)), 1);

		if(!is_array($stylearray)) {
			cpmsg("界面文件已损坏,无法导入,请返回。");
		}

		if(empty($ignoreversion) && strip_tags($stylearray['version']) != strip_tags($version)) {
			cpmsg("导出界面所用 Soobic! ($stylearray[version])与当前版本($version)不一致,请返回。");
		}

		if($stylearray['templateid'] != 1) {
			$templatedir = $soobic.'./'.$stylearray['directory'];

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?