<?php
/**
* This is NOT a freeware, use is subject to license terms
* From www.caogen8.co ver 1.0.1
*/
if (!defined('IN_DISCUZ')) {
exit('http://127.0.0.1/');
}
function s_showsettings($pluginvars, $pluginvars_array) {
global $_G, $lang, $plugin;
$extra = array();
$s_e = 'ex';
foreach ($pluginvars_array as $k => $variable) {
if (!isset($pluginvars[$variable])) {
continue;
}
$var = $pluginvars[$variable];
if (strexists($var['type'], '_')) {
continue;
}
$var['variable'] = 'varsnew[' . $var['variable'] . ']';
if ($var['type'] == 'number') {
$var['type'] = 'text';
} elseif ($var['type'] == 'select') {
$var['type'] = "<select name=\"$var[variable]\">\n";
foreach (explode("\n", $var['extra']) as $key => $option) {
$option = trim($option);
if (strpos($option, '=') === FALSE) {
$key = $option;
} else {
$item = explode('=', $option);
$key = trim($item[0]);
$option = trim($item[1]);
}
$var['type'] .= "<option value=\"" . dhtmlspecialchars($key) . "\" " . ($var['value'] == $key ? 'selected' : '') . ">$option</option>\n";
}
$var['type'] .= "</select>\n";
$var['variable'] = $var['value'] = '';
} elseif ($var['type'] == 'selects') {
$var['value'] = unserialize($var['value']);
$var['value'] = is_array($var['value']) ? $var['value'] : array($var['value']);
$var['type'] = "<select name=\"$var[variable][]\" multiple=\"multiple\" size=\"10\">\n";
foreach (explode("\n", $var['extra']) as $key => $option) {
$option = trim($option);
if (strpos($option, '=') === FALSE) {
$key = $option;
} else {
$item = explode('=', $option);
$key = trim($item[0]);
$option = trim($item[1]);
}
$var['type'] .= "<option value=\"" . dhtmlspecialchars($key) . "\" " . (in_array($key, $var['value']) ? 'selected' : '') . ">$option</option>\n";
}
$var['type'] .= "</select>\n";
$var['variable'] = $var['value'] = '';
} elseif ($var['type'] == 'date') {
$var['type'] = 'calendar';
$extra['date'] = '<script type="text/javascript" src="static/js/calendar.js"></script>';
} elseif ($var['type'] == 'datetime') {
$var['type'] = 'calendar';
$var['extra'] = 1;
$extra['date'] = '<script type="text/javascript" src="static/js/calendar.js"></script>';
} elseif ($var['type'] == 'forum') {
require_once libfile('function/forumlist');
$var['type'] = '<select name="' . $var['variable'] . '"><option value="">' . cplang('plugins_empty') . '</option>' . forumselect(FALSE, 0, $var['value'], TRUE) . '</select>';
$var['variable'] = $var['value'] = '';
} elseif ($var['type'] == 'forums') {
$var['description'] = ($var['description'] ? (isset($lang[$var['description']]) ? $lang[$var['description']] : $var['description']) . "\n" : '') . $lang['plugins_edit_vars_multiselect_comment'] . "\n" . $var['comment'];
$var['value'] = unserialize($var['value']);
$var['value'] = is_array($var['value']) ? $var['value'] : array();
require_once libfile('function/forumlist');
$var['type'] = '<select name="' . $var['variable'] . '[]" size="10" multiple="multiple"><option value="">' . cplang('plugins_empty') . '</option>' . forumselect(FALSE, 0, 0, TRUE) . '</select>';
foreach ($var['value'] as $v) {
$var['type'] = str_replace('<option value="' . $v . '">', '<option value="' . $v . '" selected>', $var['type']);
}
$var['variable'] = $var['value'] = '';
} elseif (substr($var['type'], 0, 5) == 'group') {
if ($var['type'] == 'groups') {
$var['description'] = ($var['description'] ? (isset($lang[$var['description']]) ? $lang[$var['description']] : $var['description']) . "\n" : '') . $lang['plugins_edit_vars_multiselect_comment'] . "\n" . $var['comment'];
$var['value'] = unserialize($var['value']);
$var['type'] = '<select name="' . $var['variable'] . '[]" size="10" multiple="multiple"><option value=""' . (@in_array('', $var['value']) ? ' selected' : '') . '>' . cplang('plugins_empty') . '</option>';
} else {
$var['type'] = '<select name="' . $var['variable'] . '"><option value="">' . cplang('plugins_empty') . '</option>';
}
$var['value'] = is_array($var['value']) ? $var['value'] : array($var['value']);
$query = DB::query("SELECT type, groupid, grouptitle, radminid FROM " . DB::table('common_usergroup') . " ORDER BY (creditshigher<>'0' || creditslower<>'0'), creditslower, groupid");
$groupselect = array();
while ($group = DB::fetch($query)) {
$group['type'] = $group['type'] == 'special' && $group['radminid'] ? 'specialadmin' : $group['type'];
$groupselect[$group['type']] .= '<option value="' . $group['groupid'] . '"' . (@in_array($group['groupid'], $var['value']) ? ' selected' : '') . '>' . $group['grouptitle'] . '</option>';
}
$var['type'] .= '<optgroup label="' . $lang['usergroups_member'] . '">' . $groupselect['member'] . '</optgroup>' .
($groupselect['special'] ? '<optgroup label="' . $lang['usergroups_special'] . '">' . $groupselect['special'] . '</optgroup>' : '') .
($groupselect['specialadmin'] ? '<optgroup label="' . $lang['usergroups_specialadmin'] . '">' . $groupselect['specialadmin'] . '</optgroup>' : '') .
'<optgroup label="' . $lang['usergroups_system'] . '">' . $groupselect['system'] . '</optgroup></select>';
$var['variable'] = $var['value'] = '';
} elseif ($var['type'] == 'extcredit') {
$var['type'] = '<select name="' . $var['variable'] . '"><option value="">' . cplang('plugins_empty') . '</option>';
foreach ($_G['setting']['extcredits'] as $id => $credit) {
$var['type'] .= '<option value="' . $id . '"' . ($var['value'] == $id ? ' selected' : '') . '>' . $credit['title'] . '</option>';
}
$var['type'] .= '</select>';
$var['variable'] = $var['value'] = '';
} elseif ($var['type'] == 'mcheckbox' || $var['type'] == 'mcheckbox2') {
$drkextra = explode(chr(10), $var['extra']);
foreach ($drkextra as $val) {
$extr = explode('=', $val);
$arr[] = array($extr[0], trim($extr[1]));
}
$var['variable'] = array($var['variable'], $arr);
unset($arr);
$var['value'] = unserialize($var['value']);
} elseif ($var['type'] == 'portal') {
include_once libfile('function/portalcp');
$var['type'] = category_showselect('portal', $var['variable'], false, $var['value']);
} elseif ($var['type'] == 'portals') {
$var['description'] = ($var['description'] ? (isset($lang[$var['description']]) ? $lang[$var['description']] : $var['description']) . "\n" : '') . $lang['plugins_edit_vars_multiselect_comment'] . "\n" . $var['comment'];
$var['value'] = unserialize($var['value']);
$var['value'] = is_array($var['value']) ? $var['value'] : array();
require_once libfile('function/forumlist');
$var['type'] = '<select name="' . $var['variable'] . '[]" size="10" multiple="mult