jswizard.inc.php

来自「Discuz_7.0.0 是一款社区程序源码!! 国内80 的站长使用此程序」· PHP 代码 · 共 968 行 · 第 1/5 页

PHP
968
字号
		if($type == 'side') {
			$jskey = substr($jskey, 0, strlen($lang['jswizard_infoside_pre'])) == $lang['jswizard_infoside_pre'] ? $jskey : $lang['jswizard_infoside_pre'].$jskey;
		}
		if($jssubmit && $function == $type) {
			if($function == 'side' && !empty($parameter['selectmodule'])) {
				$parameter['jstemplate'] = '';
				$splitbar = '';
				foreach($parameter['selectmodule'] as $value) {
					$parameter['jstemplate'] .= $splitbar.'[module]'.$value.'[/module]';
					$splitbar = '<hr class="shadowline"/>';
				}
			}
			$jsurl = $jssetting ? $jssetting : "function=$function".
				($parameter['boardurl'] ? "&boardurl=".rawurlencode($parameter['boardurl']) : '').
				"&jscharset=$parameter[jscharset]".
				($parameter['cachelife'] != '' ? "&cachelife=$parameter[cachelife]" : '').
				(!empty($parameter['jstemplate']) ? '&jstemplate='.rawurlencode($parameter['jstemplate']) : '');

			if(!$preview) {
				jssavesetting($type == 'custom' ? -1 : -2);
			}
			$jspreview = ($type == 'custom' ? $lang['jswizard_innerrequest'].'<textarea rows="2" style="width: 95%; word-break: break-all" onFocus="this.select()">{eval request(\''.str_replace("'", "\'", $jskey).'\');}</textarea><br />'.
				$lang['jswizard_outerrequest'].'<textarea rows="2" style="width: 95%; word-break: break-all" onFocus="this.select()">'.
				dhtmlspecialchars("<script type=\"text/javascript\" src=\"{$boardurl}api/javascript.php?key=".rawurlencode($jskey)."\"></script>").
				'</textarea><br />' : '').jspreviewcode($jsurl).'<br />';
		}

		echo '<div class="colorbox">';
		if($jspreview && in_array($type, array('custom', 'side'))) {
			echo '<h4 style="margin-bottom:15px;">'.lang('preview').'</h4>'.$jspreview;
		}

		$jsmodule = '';$selectarray = $requests = array();
		$requests = array();
		$query = $db->query("SELECT * FROM {$tablepre}request WHERE type>=0");
		while($settings = $db->fetch_array($query)) {
			$value = unserialize($settings['value']);
			$optionitem = '<option value="'.$settings['variable'].'">'.($value['parameter']['sidestatus'] ? '* ' : '').($value['comment'] != '' ? $value['comment'] : '').'['.$settings['variable'].']'.'</option>';
			if($type == 'side' && !empty($parameter['selectmodule'])) {
				$key = array_search($settings['variable'], $parameter['selectmodule']);
				if($key !== FALSE && $key !== NULL) {
					$selectarray[$key] = $optionitem;
				} else {
					$jsmodule .= $optionitem;
				}
			} else {
				$jsmodule .= $optionitem;
			}
		}
		if($type == 'side' && !empty($selectarray)) {
			ksort($selectarray);
			$selectmodule = implode($selectarray);
		}

		showformheader('jswizard&function='.$type.'#'.$lang['jswizard_'.$type]);

		if($type == 'custom') {
			echo '<h4 style="margin-bottom:15px;">'.lang('jswizard_custom').' - '.lang('jswizard_jstemplate').'</h4><div class="extcredits">';
			echo $lang['jswizard_custom_jstemplate_comment'].'</div><select onchange="insertunit(\'[module]\'+this.value+\'[/module]\')"><option>'.$lang['jswizard_custom_jstemplate_current_module'].'</option>'.$jsmodule.'</select><br /><br />';
			jsinsertunit();
			echo '<textarea cols="100" rows="5" id="jstemplate" name="parameter[jstemplate]" style="width: 95%;" onkeyup="textareasize(this)">'.($parameter['jstemplate'] != '' ? stripslashes($parameter['jstemplate']) : '').'</textarea>';
		} else {
			echo '<h4 style="margin-bottom:15px;">'.lang('jswizard_side').'</h4><div class="extcredits">';
			echo '<tr><td colspan="2">'.$lang['jswizard_sidemodule_comment'].'</div>';
			echo '<script type="text/JavaScript">
			function moveselect(fromitem, toitem) {
				var selectindex = $(fromitem).selectedIndex;
				if(selectindex == -1) return;
				var itemtext = $(fromitem).options[selectindex].text;
				var itemvalue = $(fromitem).value;
				$(fromitem).removeChild($(fromitem).options[selectindex]);
				var newoption = new Option(itemtext, itemvalue);
				$(toitem).options.add(newoption);
			}
			function orderselect(option) {
				var selectindex = $(\'selectmodule\').selectedIndex;
				if(selectindex == -1) return;
				var itemtext = $(\'selectmodule\').options[selectindex].text;
				var itemvalue = $(\'selectmodule\').value;
				var itemcount = $(\'selectmodule\').options.length;
				if(option == 1 && selectindex == 0 || option == 0 && selectindex == itemcount - 1) return;
				if(option == 1) {
					if(selectindex == 0) return;var swapindex = selectindex - 1;
				} else {
					if(selectindex == itemcount - 1) return;var swapindex = selectindex + 1;
				}
				var tmptext = $(\'selectmodule\').options[swapindex].text;
				var tmpvalue = $(\'selectmodule\').options[swapindex].value;
				$(\'selectmodule\').options[swapindex].text = $(\'selectmodule\').options[selectindex].text;
				$(\'selectmodule\').options[swapindex].value = $(\'selectmodule\').options[selectindex].value;
				$(\'selectmodule\').options[selectindex].text = tmptext;
				$(\'selectmodule\').options[selectindex].value = tmpvalue;
				$(\'selectmodule\').selectedIndex = swapindex;
			}
			function selectall() {
				var itemcount = $(\'selectmodule\').options.length;
				for(i = 0;i < itemcount;i++) {
					$(\'selectmodule\').options[i].selected = true;
				}
			}
			</script>
			<table width="95%" border="0" cellpadding="0" cellspacing="0"><tr><td style="text-align:center;border: 0">
			<button class=button onclick="orderselect(1);return false">'.$lang['jswizard_custom_jstemplate_up'].'</button>
			<br /><br /><button class=button onclick="orderselect(0);return false">'.$lang['jswizard_custom_jstemplate_down'].'</button>
			</td><td width="40%" style="border: 0">
			'.$lang['jswizard_custom_jstemplate_selected_module'].'<select ondblclick="moveselect(\'selectmodule\', \'currentmodule\')" id="selectmodule" name="parameter[selectmodule][]" multiple="multiple" size="10" style="width: 100%">'.$selectmodule.'</select>
			</td><td style="text-align:center;border: 0">
			<button class=button onclick="moveselect(\'currentmodule\', \'selectmodule\');return false">'.$lang['jswizard_custom_jstemplate_select'].'</button>
			<br /><br /><button class=button onclick="moveselect(\'selectmodule\', \'currentmodule\');return false">'.$lang['jswizard_custom_jstemplate_remove'].'</button>
			</td><td width="40%" style="border: 0">
			'.$lang['jswizard_custom_jstemplate_current_module'].'<select ondblclick="moveselect(\'currentmodule\', \'selectmodule\')" id="currentmodule" multiple="multiple" size="10" style="width:100%">'.$jsmodule.'</select>
			</td></tr></table>
			';
		}

		echo '<br /><input type="button" class="btn" onclick="this.form.jssubmit.click()" value="'.$lang['preview'].'">&nbsp; &nbsp;<input type="button" class="btn" onclick="this.form.preview.value=0;this.form.jssubmit.click()" value="'.$lang['submit'].'"></div><br /><br />';

		showtableheader();
		showtitle('jswizard_'.$type);
		showsetting('jswizard_jskey', 'jskey', $jskey, 'text');
		showsetting('jswizard_comment', 'comment', $comment, 'text');
		showsetting('jswizard_cachelife_custom', 'parameter[cachelife]', $parameter['cachelife'] != '' ? intval($parameter['cachelife']) : '', 'text');
		if($type == 'custom') {
			if(strtoupper($charset) != 'UTF-8') {
				showsetting('jswizard_charset', 'parameter[jscharset]', $parameter['jscharset'], 'radio');
			} else {
				showsetting('jswizard_charsetr', array('parameter[jscharset]', array(array(0, $lang['none']), array(1, 'GBK'), array(2, 'BIG5'))), intval($parameter['jscharset']), 'mradio');
			}
		}
		showsetting('jswizard_boardurl', 'parameter[boardurl]', $parameter['boardurl'], 'text');
		echo '<tr><td colspan="2">'.$editext.'<br /><input type="submit" class="btn" name="jssubmit"'.($type == 'side' ? ' onclick="selectall()"' : '').' value="'.$lang['preview'].'">&nbsp; &nbsp;<input type="button" class="btn" onclick="this.form.preview.value=0;this.form.jssubmit.click()" value="'.$lang['submit'].'"><input name="preview" type="hidden" value="1"></td></tr>';
		showtablefooter();
		showformfooter();

	}

} elseif($operation == 'import') {

	if(!submitcheck('importsubmit')) {
		shownav('tools', 'nav_javascript');
		showsubmenu('nav_javascript', array(
			array('config', 'jswizard&operation=config', 0),
			$infosidemenu,
			array('admin', 'jswizard', 0),
			array(array('menu' => 'jswizard_addmodule', 'submenu' => $addmenu), '', 0),
			array('jswizard_module', 'jswizard&type=module', 0),
			array('import', 'jswizard&operation=import', 1)
		));

		showformheader('jswizard&operation=import', 'enctype');

		showtableheader('jswizard_import');
		showimportdata();
		showtablerow('', 'class="rowform"', mradio('importrewrite', array(
			0 => lang('jswizard_import_default'),
			1 => lang('jswizard_import_norewrite'),
			2 => lang('jswizard_import_rewrite'),
		), 0, FALSE));
		showsubmit('importsubmit');
		showtablefooter();
		showformfooter();
	} else {
		$importarray = getimportdata(0);
		$keys = implode("','", array_keys($importarray));

		if($importrewrite != 2) {
			$query = $db->query("SELECT variable FROM {$tablepre}request WHERE variable IN ('$keys')");
			$existkeyarray = array();
			while($existkey = $db->fetch_array($query)) {
				if($importrewrite == 1) {
					unset($importarray[$existkey['variable']]);
				} else {
					$existkeyarray[] = $existkey['variable'];
				}
			}

			if($importrewrite == 0 && $existkeyarray) {
				$existkeys = implode(", ", $existkeyarray);
				cpmsg('jswizard_import_exist', '', 'error');
			}
		}

		foreach($importarray as $key => $value) {
			$value = unserialize($value);
			$type = $value['type'];
			unset($value['type']);
			$value = addslashes(serialize($value));
			$db->query("REPLACE INTO {$tablepre}request (variable, value, `type`) VALUES ('$key', '$value', '$type')");
		}

		updatecache('request');
		cpmsg('jswizard_succeed', $BASESCRIPT.'?action=jswizar

⌨️ 快捷键说明

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