/** 解析表单项目 @param array $rs 数据构成 @param array $data 表单值 @return string $rs['ntype']值 1 单行文本 2 多行文本(不支持编辑器) 3 多行文本 (支持编辑器) 4 单选 (下拉列表) 5 单选 (radio) 6 多选 (多选列表) 7 复选框 8 文件上传(图片类型) 9 图片列表 10 文件上传(文件类型) 11 文件列表 12 颜色框 13 选择模板 */ public function formdecode($rs, $data) { $c = array(); $s = ''; $h = kc_help($rs['khelp'] ? $rs['kmodule'] . '/' . $rs['khelp'] : ''); switch ($rs['ntype']) { case 1: $c[] = array($rs['kname'], 0, $rs['nsizemin'], $rs['nsizemax']); if ($rs['nvalidate'] != 0) { $c[] = array($rs['kname'], $rs['nvalidate']); } $s = '<input type="text" name="' . $rs['kname'] . '" id="' . $rs['kname'] . '" value="' . htmlspecialchars($data[$rs['kname']]) . '" class="k_in" style="width:' . $rs['nstylewidth'] . 'px;" maxlength="' . $rs['nsizemax'] . '" />'; $h .= kc_htm_setvalue_nl($rs['kname'], $rs['koption']); break; case 2: $c[] = array($rs['kname'], 0, $rs['nsizemin'], $rs['nsizemax']); $s = '<textarea name="' . $rs['kname'] . '" class="k_in" style="width:' . $rs['nstylewidth'] . 'px;height:' . $rs['nstyleheight'] . 'px;" >' . htmlspecialchars($data[$rs['kname']]) . '</textarea>'; break; case 3: $c[] = array($rs['kname'], 0, $rs['nsizemin'], $rs['nsizemax']); $s = kc_htm_editor($rs['kname'], $data[$rs['kname']], $rs['nstylewidth'], $rs['nstyleheight']); break; case 4: $c[] = array($rs['kname'], 0, $rs['nsizemin'], $rs['nsizemax']); $array_def = explode(NL, $rs['koption']); $array_select = array(); foreach ($array_def as $val) { if (isset($val[0])) { //不能为空值 $array_val = explode('|', $val, 2); if (count($array_val) > 1) { //有分割符号 $array_select += array($array_val[0] => $array_val[1]); } else { $array_select += array($val => $val); } } } $s = kc_htm_select($rs['kname'], $array_select, $data[$rs['kname']]); break; case 5: $c[] = array($rs['kname'], 0, $rs['nsizemin'], $rs['nsizemax']); $array_def = explode(NL, $rs['koption']); $array_radio = array(); foreach ($array_def as $val) { if (isset($val[0])) { //不能为空值 $array_val = explode('|', $val, 2); if (count($array_val) > 1) { //有分割符号 $array_radio += array($array_val[0] => $array_val[1]); } else { $array_radio += array($val => $val); } } } $s = kc_htm_radio($rs['kname'], $array_radio, $data[$rs['kname']]); break; case 6: $c[] = array($rs['kname'], 0, $rs['nsizemin'], $rs['nsizemax']); $array_def = explode(NL, $rs['koption']); $array_select = array(); foreach ($array_def as $val) { if (isset($val[0])) { //不能为空值 $array_val = explode('|', $val, 2); if (count($array_val) > 1) { //有分割符号 $array_select += array($array_val[0] => $array_val[1]); } else { $array_select += array($val => $val); } } } $s = kc_htm_select($rs['kname'], $array_select, $data[$rs['kname']], ' multiple="multiple" style="width:' . $rs['nstylewidth'] . 'px;height:' . $rs['nstyleheight'] . 'px;"'); break; case 7: $c[] = array($rs['kname'], 0, $rs['nsizemin'], $rs['nsizemax']); $array_def = explode(NL, $rs['koption']); $array_radio = array(); foreach ($array_def as $val) { if (isset($val[0])) { //不能为空值 $array_val = explode('|', $val, 2); if (count($array_val) > 1) { //有分割符号 $array_radio += array($array_val[0] => $array_val[1]); } else { $array_radio += array($val => $val); } } } $s = kc_htm_checkbox($rs['kname'], $array_radio, $data[$rs['kname']]); break; case 8: $c[] = array($rs['kname'], 0, $rs['nsizemin'], $rs['nsizemax']); $s = '<input type="text" name="' . $rs['kname'] . '" id="' . $rs['kname'] . '" value="' . htmlspecialchars($data[$rs['kname']]) . '" class="k_in" style="width:' . $rs['nstylewidth'] . 'px;" maxlength="' . $rs['nsizemax'] . '" />'; $h .= kc_f_brow($rs['kname'], $this->config('uppath') . '/image', 0); break; case 9: $c[] = array($rs['kname'], 0, $rs['nsizemin'], $rs['nsizemax']); $s = '<input type="hidden" id="' . $rs['kname'] . '" name="' . $rs['kname'] . '" value="' . htmlspecialchars($data[$rs['kname']]) . '"/>'; $s .= '<table class="k_side" cellspacing="0"><tr><td id="k' . $rs['kname'] . 'show" class="k_in imglist" style="width:' . $rs['nstylewidth'] . 'px;height:' . $rs['nstyleheight'] . 'px;">'; $s .= 'Loading...'; $s .= '</td><td>'; $s .= kc_f_brow($rs['kname'], $this->config('uppath') . '/image', 0, 1, $jsfun = 'k' . $rs['kname'] . 'show();'); $s .= '</td></tr></table>'; $s .= kc_help($rs['khelp'] ? $rs['kmodule'] . '/' . $rs['khelp'] : ''); $s .= "<script>function k{$rs['kname']}show(){\$.kc_ajax('{CMD:\\'imageload\\',label:\\'{$rs['kname']}\\',VAL:\\'{$rs['kname']}\\',listid}\\'}');k{$rs['kname']}show();</script>"; break; case 10: $c[] = array($rs['kname'], 0, $rs['nsizemin'], $rs['nsizemax']); $s = '<input type="text" name="' . $rs['kname'] . '" id="' . $rs['kname'] . '" value="' . htmlspecialchars($data[$rs['kname']]) . '" class="k_in" style="width:' . $rs['nstylewidth'] . 'px;" maxlength="' . $rs['nsizemax'] . '" />'; $h .= kc_f_brow($rs['kname'], $this->config('uppath') . '/file', 1); break; case 11: $c[] = array($rs['kname'], 0, $rs['nsizemin'], $rs['nsizemax']); $s = '<input type="hidden" id="' . $rs['kname'] . '" name="' . $rs['kname'] . '" value="' . htmlspecialchars($data[$rs['kname']]) . '"/>'; $s .= '<table class="k_side" cellspacing="0"><tr><td id="k' . $rs['kname'] . 'show" class="k_in filelist" style="width:' . $rs['nstylewidth'] . 'px;height:' . $rs['nstyleheight'] . 'px;">'; $s .= 'Loading...'; $s .= '</td><td>'; $s .= kc_f_brow($rs['kname'], $this->config('uppath') . '/file', 1, 1, $jsfun = 'k' . $rs['kname'] . 'show();'); $s .= '</td></tr></table>'; $s .= kc_help($rs['khelp'] ? $rs['kmodule'] . '/' . $rs['khelp'] : ''); $s .= "<script>function k{$rs['kname']}show(){\$.kc_ajax('{CMD:\\'filesload\\',label:\\'{$rs['kname']}\\',VAL:\\'{$rs['kname']},listid\\',ID:\\'k{$rs['kname']}show\\'}')};k{$rs['kname']}show();</script>"; break; case 12: $c[] = array('kcolor', 0, 6, 6); $s = '<input class="k_in w50" type="text" id="' . $rs['kname'] . '" name="' . $rs['kname'] . '" value="' . htmlspecialchars($data[$rs['kname']]) . '" maxlength="6" />'; $h .= kc_f_color($rs['kname']); break; case 13: $c[] = array($rs['kname'], 0, $rs['nsizemin'], $rs['nsizemax']); $s = '<input type="text" name="' . $rs['kname'] . '" id="' . $rs['kname'] . '" value="' . htmlspecialchars($data[$rs['kname']]) . '" class="k_in" style="width:' . $rs['nstylewidth'] . 'px;" maxlength="' . $rs['nsizemax'] . '" />'; $h .= kc_f_brow($rs['kname'], $this->config('templatepath'), 2); break; } $htm = $this->htmForm($this->lang->get($rs['kmodule'] . '/const/' . $rs['kname']), $s, $c, 'config.' . $rs['kmodule'] . '.' . $rs['kname'], $h); return $htm; }
function king_edt() { global $king; $king->access('portal_model_edt'); $_htmlcode = ''; $_arraycheck = array(); /** $_isattrib='isshow,ishead,iscommend,isup,isfocus,ishot'; $_sql=$_isattrib.',issearch,modelname,modeltable,klanguage,isid,klistorder,kpageorder,nlocktime,nshowtime,ktemplatesearch,ktemplatepublish'; */ $_sql = 'issearch,modelname,modeltable,klanguage,isid,klistorder,kpageorder,nlocktime,nshowtime,ktemplatesearch,ktemplatepublish,npagenumber,nlistnumber,ispublish1,ispublish2,ktemplatecomment,ncommentnumber'; $modelid = kc_get('modelid'); $fields = explode(',', $_sql); if ($GLOBALS['ismethod'] || $modelid == '') { //POST过程或新添加的过程 $data = $_POST; if (!$GLOBALS['ismethod']) { //初始化新添加的数据 $_array = array('istag', 'iscontent', 'isshow', 'ispath', 'iscommend', 'iskeyword', 'isdescription', 'isimage', 'isrelate'); foreach ($_array as $_value) { $data[$_value] = 1; } $data['kretitle'] = $king->lang->get('system/common/title'); $data['klanguage'] = $_COOKIE['language']; $data['nlocktime'] = 24; $data['nshowtime'] = 0; $data['isid'] = 1; //默认排序 $data['klistorder'] = 'nup desc,norder desc'; $data['kpageorder'] = 'norder,kid'; //默认显示数 $data['nlistnumber'] = 20; $data['npagenumber'] = 1; $data['ncommentnumber'] = 20; //默认模板 $tpath = $king->config('templatepath'); $tdefa = $king->config('templatedefault'); $ktemplate = $tpath . '/' . $tdefa; $data['ktemplatesearch'] = is_file(ROOT . $ktemplate) ? $ktemplate : ''; $data['ktemplatepublish'] = is_file(ROOT . $ktemplate) ? $ktemplate : ''; $data['ktemplatecomment'] = is_file(ROOT . $ktemplate) ? $ktemplate : ''; } } else { //编辑数据,从数据库读出 $data = $king->db->getRows_one('select ' . $_sql . ' from %s_model where modelid=' . $modelid . ' limit 1;'); $data['modeltable'] = DB_PREFIX . '__' . $data['modeltable']; } $data = kc_data($fields, $data); $s = $king->openForm('manage.model.php?action=edt', $king->lang->get('portal/caption/basic')); //模型名称 $_array = array(array('modelname', 0, 2, 50)); $s .= $king->htmForm($king->lang->get('portal/list/modelname') . ' (2-50)', '<input class="k_in w200" type="text" name="modelname" value="' . htmlspecialchars($data['modelname']) . '" maxlength="50" />', $_array); //数据表名 if (empty($modelid)) { //update $_array = array(array('modeltable', 0, 1, 50), array('modeltable', 1), array('modeltable', 12, $king->lang->get('system/check/none'), $king->db->getRows_one("select modelid from %s_model where modeltable='" . $king->db->escape(kc_post('modeltable')) . "';")), array('modeltable', 18, null, $king->portal->holdmodel)); $s .= $king->htmForm($king->lang->get('portal/list/table') . ' (1-50)', '<input class="k_in w200" type="text" name="modeltable" value="' . htmlspecialchars($data['modeltable']) . '" maxlength="50" />', $_array); } else { $s .= $king->htmForm($king->lang->get('portal/list/table') . ' (1-50)', '<input class="k_in w200" type="text" disabled="true" value="' . htmlspecialchars($data['modeltable']) . '" />'); $s .= kc_htm_hidden(array('modeltable' => $data['modeltable'])); } //klanguage $s .= $king->htmForm($king->lang->get('system/common/language'), kc_htm_select('klanguage', kc_htm_selectlang(), $data['klanguage'])); /** //[ATTRIB] $_array_attrib=explode(',',$_isattrib); foreach($_array_attrib as $_value){ $data[$_value]==1 ? $_checked=' checked="checked"' : $_checked=''; $_htmlcode.='<input type="checkbox" value="1" id="'.$_value.'" name="'.$_value.'"'.$_checked.'/>'; $_htmlcode.='<label for="'.$_value.'">'.$king->lang->get('portal/label/attrib/'.$_value).'</label> '; } $s.=$king->htmForm($king->lang->get('portal/label/attrib1'),"<span>$_htmlcode</span>"); */ //加入搜索 $data['issearch'] == 1 ? $_checked = ' checked="checked"' : ($_checked = ''); $_htmlcode = '<span><input type="checkbox" value="1" id="issearch" name="issearch"' . $_checked . '/>'; $_htmlcode .= '<label for="issearch">' . $king->lang->get('portal/label/attrib/issearch') . '</label></span>'; //是否在列表中显示id $data['isid'] == 1 ? $_checked = ' checked="checked"' : ($_checked = ''); $_htmlcode .= ' <span><input type="checkbox" value="1" id="isid" name="isid"' . $_checked . '/>'; $_htmlcode .= '<label for="isid">' . $king->lang->get('portal/label/attrib/isid') . '</label></span>'; $s .= $king->htmForm($king->lang->get('system/common/option'), $_htmlcode); $s .= $king->splitForm($king->lang->get('portal/caption/all')); //klistorder $array_select = array('nup desc,norder desc' => $king->lang->get('portal/order/list1'), 'nup desc,norder' => $king->lang->get('portal/order/list2'), 'nup desc,nlastdate desc' => $king->lang->get('portal/order/list3'), 'nup desc,nhit desc' => $king->lang->get('portal/order/list4'), 'nup desc,nhitlate desc' => $king->lang->get('portal/order/list5'), 'nup desc,ndigg1 desc' => $king->lang->get('portal/order/list6'), 'nup desc,ndigg0 desc' => $king->lang->get('portal/order/list7'), 'nup desc,ndigg desc' => $king->lang->get('portal/order/list8'), 'nup desc,nprice asc' => $king->lang->get('portal/order/list9'), 'nup desc,nprice desc' => $king->lang->get('portal/order/list10')); $array = array(array('klistorder', 0, 0, 255)); $s .= $king->htmForm($king->lang->get('portal/label/listorder'), kc_htm_input('klistorder', $data['klistorder'], 255, 200), $array, '', kc_htm_setvalue('klistorder', $array_select, 300, 1) . kc_help('portal/help/listorder', 500, 400)); //nlistnumber $array = array(array('nlistnumber', 0, 1, 3), array('nlistnumber', 2), array('nlistnumber', 16, $king->lang->get('portal/check/listnumber'), 1, 100)); $array_select = array(10 => 10, 20 => 20, 25 => 25, 30 => 30); $s .= $king->htmForm($king->lang->get('portal/label/mlistnumber'), kc_htm_input('nlistnumber', $data['nlistnumber'], 3, 50), $array, '', kc_htm_setvalue('nlistnumber', $array_select, 200)); //kpageorder $array_select = array('norder,kid' => $king->lang->get('portal/order/page1'), 'norder desc,kid desc' => $king->lang->get('portal/order/page2'), 'kid' => $king->lang->get('portal/order/page3'), 'kid desc' => $king->lang->get('portal/order/page4'), 'kid1,kid' => $king->lang->get('portal/order/page5'), 'kid1,kid desc' => $king->lang->get('portal/order/page6'), 'kid1,isok desc,kid desc' => $king->lang->get('portal/order/page7')); $array = array(array('kpageorder', 0, 0, 255)); $s .= $king->htmForm($king->lang->get('portal/label/pageorder'), kc_htm_input('kpageorder', $data['kpageorder'], 255, 200), $array, '', kc_htm_setvalue('kpageorder', $array_select, 300, 1) . kc_help('portal/help/pageorder', 500, 400)); //npagenumber $array = array(array('npagenumber', 0, 1, 3), array('npagenumber', 2), array('npagenumber', 16, $king->lang->get('portal/check/pagenumber'), 1, 100)); $array_select = array(1 => 1, 10 => 10, 20 => 20, 30 => 30); $s .= $king->htmForm($king->lang->get('portal/label/mpagenumber'), kc_htm_input('npagenumber', $data['npagenumber'], 3, 50), $array, '', kc_htm_setvalue('npagenumber', $array_select, 200)); //ispublish1 $_array_radio = array(0 => $king->lang->get('portal/label/pub0'), 1 => $king->lang->get('portal/label/pub1'), 2 => $king->lang->get('portal/label/pub2')); $s .= $king->htmForm($king->lang->get('portal/label/mpublish1'), kc_htm_radio('ispublish1', $_array_radio, $data['ispublish1'])); //ispublish2 $_array_radio = array(0 => $king->lang->get('portal/label/pub0'), 1 => $king->lang->get('portal/label/pub1'), 2 => $king->lang->get('portal/label/pub2')); $s .= $king->htmForm($king->lang->get('portal/label/mpublish2'), kc_htm_radio('ispublish2', $_array_radio, $data['ispublish2'])); //nlocktime $array_value = array(24 => $king->lang->get('system/time/oneday'), 168 => $king->lang->get('system/time/hebdomad'), 360 => $king->lang->get('system/time/halfmoon'), 0 => $king->lang->get('system/time/always')); $_array = array(array('nlocktime', 0, 1, 10)); $s .= $king->htmForm($king->lang->get('portal/label/locktime') . ' (' . $king->lang->get('portal/label/unit') . ')', '<input class="k_in w100" type="text" name="nlocktime" id="nlocktime" value="' . htmlspecialchars($data['nlocktime']) . '" maxlength="10" />', $_array, null, kc_htm_setvalue('nlocktime', $array_value) . kc_help('portal/help/locktime')); //nshowtime $array_value = array(168 => $king->lang->get('system/time/hebdomad'), 360 => $king->lang->get('system/time/halfmoon'), 720 => $king->lang->get('system/time/jan'), 4368 => $king->lang->get('system/time/halfyear'), 0 => $king->lang->get('system/time/always')); $_array = array(array('nshowtime', 0, 1, 10)); $s .= $king->htmForm($king->lang->get('portal/label/showtime') . ' (' . $king->lang->get('portal/label/unit') . ')', '<input class="k_in w100" type="text" name="nshowtime" id="nshowtime" value="' . htmlspecialchars($data['nshowtime']) . '" maxlength="10" />', $_array, null, kc_htm_setvalue('nshowtime', $array_value, 200) . kc_help('portal/help/showtime')); //ktemplatepublish $_array = array(array('ktemplatepublish', 0, 5, 255), array('ktemplatepublish', 15)); $s .= $king->htmForm($king->lang->get('portal/label/templatepublish') . ' (5-255)', '<input class="k_in w400" type="text" id="ktemplatepublish" name="ktemplatepublish" value="' . htmlspecialchars($data['ktemplatepublish']) . '" maxlength="255" />', $_array, null, kc_f_brow('ktemplatepublish', $king->config('templatepath'), 2) . kc_help('portal/help/template', 455, 455)); //ktemplatesearch $_array = array(array('ktemplatesearch', 0, 5, 255), array('ktemplatesearch', 15)); $s .= $king->htmForm($king->lang->get('portal/label/templatesearch') . ' (5-255)', '<input class="k_in w400" type="text" id="ktemplatesearch" name="ktemplatesearch" value="' . htmlspecialchars($data['ktemplatesearch']) . '" maxlength="255" />', $_array, null, kc_f_brow('ktemplatesearch', $king->config('templatepath'), 2) . kc_help('portal/help/template', 455, 455)); //ktemplatecomment $_array = array(array('ktemplatecomment', 0, 5, 255), array('ktemplatecomment', 15)); $s .= $king->htmForm($king->lang->get('portal/label/templatecomment') . ' (5-255)', '<input class="k_in w400" type="text" id="ktemplatecomment" name="ktemplatecomment" value="' . htmlspecialchars($data['ktemplatecomment']) . '" maxlength="255" />', $_array, null, kc_f_brow('ktemplatecomment', $king->config('templatepath'), 2) . kc_help('portal/help/template', 455, 455)); //ncommentnumber $array = array(array('ncommentnumber', 0, 1, 3), array('ncommentnumber', 2), array('ncommentnumber', 16, $king->lang->get('portal/check/commentnumber'), 1, 100)); $array_select = array(10 => 10, 20 => 20, 25 => 25, 30 => 30); $s .= $king->htmForm($king->lang->get('portal/label/mcommentnumber'), kc_htm_input('ncommentnumber', $data['ncommentnumber'], 3, 50), $array, '', kc_htm_setvalue('ncommentnumber', $array_select, 200)); $s .= kc_htm_hidden(array('modelid' => $modelid)); $s .= $king->closeForm('save'); if ($GLOBALS['ischeck']) { /** $_array=array(); $_array_sql=explode(',',$_isattrib.',issearch,isid'); foreach($_array_sql as $_value){ $data[$_value]==1 ? $_val=1 : $_val=0; $_array+=array($_value=>$_val); } */ $_array = array('issearch' => $data['issearch'] ? 1 : 0, 'isid' => $data['isid'] ? 1 : 0, 'ispublish1' => $data['ispublish1'], 'ispublish2' => $data['ispublish2'], 'modelname' => $data['modelname'], 'klanguage' => $data['klanguage'], 'klistorder' => $data['klistorder'], 'kpageorder' => $data['kpageorder'], 'npagenumber' => $data['npagenumber'], 'nlistnumber' => $data['nlistnumber'], 'nshowtime' => $data['nshowtime'], 'nlocktime' => $data['nlocktime'], 'ktemplatesearch' => $data['ktemplatesearch'], 'ktemplatepublish' => $data['ktemplatepublish'], 'ktemplatecomment' => $data['ktemplatecomment'], 'ncommentnumber' => $data['ncommentnumber']); //添加&更新数据 if (!empty($modelid)) { $king->db->update('%s_model', $_array, 'modelid=' . $modelid); $_nlog = 7; } else { $_array += array('modeltable' => strtolower($data['modeltable']), 'norder' => $king->db->neworder('%s_model')); $_nlog = 5; $_newid = $king->db->insert('%s_model', $_array); //__[modeltable] $king->portal->installmodeltable($data['modeltable']); $_array_sql = array('ktitle', 'ksubtitle', 'kimage', 'kcontent', 'kkeywords', 'ktag', 'kdescription', 'kpath', 'krelate', 'nprice', 'nnumber', 'nweight', 'nattrib'); //补充循环添加的内容。 $i = 0; foreach ($_array_sql as $val) { $_array = array('modelid' => $_newid, 'ktitle' => $king->lang->get('system/common/' . substr($val, 1)), 'kfield' => $val, 'norder' => $i + 1); if ($val == 'kcontent') { //内容设置长度 $_array['nsizemin'] = 10; $_array['nsizemax'] = 999999; $_array['nstylewidth'] = 780; $_array['nstyleheight'] = 360; } $i++; $new_kid = $king->db->insert('%s_field', $_array); //循环最后一个获得的值为nattrib的newid } // $_array_sql = array('show', 'head', 'commend', 'up', 'focus', 'hot'); foreach ($_array_sql as $val) { $_array = array('modelid' => $_newid, 'ktitle' => $king->lang->get('portal/label/attrib/is' . $val), 'kfield' => 'n' . $val, 'kid1' => $new_kid, 'norder' => $i + 1, 'isuser1' => 0, 'isuser2' => 0, 'islist' => 1); $i++; $king->db->insert('%s_field', $_array); } } $king->cache->del('portal/model/model' . $modelid); $king->cache->del('portal/model/name'); $king->cache->del('portal/model/table'); /**/ if (!($res = $king->db->getRows("select listid from %s_list where modelid={$modelid};"))) { $res = array(); } foreach ($res as $rs) { //更新列表信息 $king->portal->lastUpdated($rs['listid'], 'list'); $king->cache->del('portal/list/' . $rs['listid']); } $king->cache->del('portal/model'); $king->cache->del('portal/model/table'); $king->cache->del('portal/model/name'); /**/ //写log $king->log($_nlog, 'Model:' . $data['modelname']); kc_goto($king->lang->get('system/goto/is'), 'manage.model.php?action=edt', 'manage.model.php'); } list($left, $right) = king_inc_list(); $king->skin->output($king->lang->get('portal/title/model' . ($modelid ? 'edt' : 'add')), $left, $right, $s); }
function king_admin_edt() { global $king; $data = array(); $s = $king->access('admin'); $_sql = "adminname,adminpass,adminlevel,adminlanguage,admineditor,adminmode,adminlogin,siteurl"; //,admindiymenu $_adminid = kc_get('adminid'); if ($GLOBALS['ismethod'] || $_adminid == '') { //POST过程或新添加的过程 $data = $_POST; if (!$GLOBALS['ismethod']) { //初始化新添加的数据 $data['adminlanguage'] = LANGUAGE; $data['adminlogin'] = '******'; } } else { //编辑数据,从数据库读出 $data = $king->db->getRows_one('select ' . $_sql . ' from %a_admin where adminid=' . $_adminid . ' limit 1;'); } $fields = explode(',', $_sql); $data = kc_data($fields, $data); $s = $king->openForm('manage.php?action=admin_edt'); //帐号 if ($_adminid) { //update $s .= $king->htmForm($king->lang->get('system/admin/name'), '<input class="k_in w100" type="text" disabled="true" value="' . htmlspecialchars($data['adminname']) . '" />'); $s .= kc_htm_hidden(array('adminname' => $data['adminname'])); } else { $_array = array(array('adminname', 0, 2, 12), array('adminname', 1), array('adminname', 12, $king->lang->get('system/check/none'), $king->db->getRows_one("select adminid from %a_admin where adminname='" . $king->db->escape(kc_post('adminname')) . "';"))); $s .= $king->htmForm($king->lang->get("system/admin/name") . ' (2-12)', '<input class="k_in w150" type="text" name="adminname" value="' . htmlspecialchars($data['adminname']) . '" maxlength="12" />', $_array); } //密码 if ($_adminid) { $_array = array(array('pass1', 17, null, 'pass2')); } else { $_array = array(array('pass1', 0, 6, 30), array('pass1', 17, null, 'pass2')); } $s .= $king->htmForm($king->lang->get('system/admin/pass1') . ' (6-30)', '<input class="k_in w150" type="password" name="pass1" maxlength="30" />', $_array); $s .= $king->htmForm($king->lang->get('system/admin/pass2'), '<input class="k_in w150" type="password" name="pass2" maxlength="30" />'); //adminlanguage $s .= $king->htmForm($king->lang->get('system/common/language'), kc_htm_select('adminlanguage', kc_htm_selectlang(), $data['adminlanguage'])); //admineditor $array_dir = kc_f_getdir('system/editor/', 'dir'); $_array = array(); foreach ($array_dir as $val) { $_array[$val] = $val; } $s .= $king->htmForm($king->lang->get('system/common/editor'), kc_htm_select('admineditor', $_array, $data['admineditor'])); //adminmode $_array = array(2 => $king->lang->get('system/admin/mode2'), 1 => $king->lang->get('system/admin/mode1'), 0 => $king->lang->get('system/admin/mode0')); $s .= $king->htmForm($king->lang->get('system/admin/mode'), kc_htm_radio('adminmode', $_array, $data['adminmode'])); //adminlevel if ($king->admin['adminid'] != $_adminid) { $data['adminlevel'] == 'admin' ? $_checkbox = '<input type="checkbox" id="adminlevel" name="adminlevel" value="admin" onclick="javascript:selevel()" checked="checked" />' : ($_checkbox = '<input type="checkbox" id="adminlevel" name="adminlevel" value="admin" onclick="javascript:selevel()" />'); $_array = array('-' . $king->lang->get('system/name') . '-', $king->lang->get('system/level/channel') . '[', '#open_settring' => $king->lang->get('system/common/setting'), '#open_help' => $king->lang->get('system/common/help'), ']', '[', '#resetpass' => $king->lang->get('system/level/resetpass'), ']', '[', '#novice' => $king->lang->get('system/level/novice'), ']', '|', $king->lang->get('system/common/system') . '[', '#systeminfo' => $king->lang->get('system/level/config'), '#systemcache' => $king->lang->get('system/level/clearcache'), '#module' => $king->lang->get('system/level/module'), '#plugin' => $king->lang->get('system/level/plugin'), '#lnk' => $king->lang->get('system/level/lnk'), '#phpinfo' => $king->lang->get('system/level/phpinfo'), '#timingtask' => $king->lang->get('system/level/timingtask'), ']', '|', $king->lang->get('system/level/log') . '[', '#log' => $king->lang->get('system/common/access'), '#log_delete' => $king->lang->get('system/common/del'), ']', '-', $king->lang->get('system/common/filemanage') . '[', '#brow' => $king->lang->get('system/common/access'), '#brow_md' => $king->lang->get('system/common/md'), '#brow_upfile' => $king->lang->get('system/common/upfile'), '#brow_delfile' => $king->lang->get('system/common/delfile'), ']', '|', $king->lang->get('system/level/event') . '[', '#event' => $king->lang->get('system/common/access'), '#event_delete' => $king->lang->get('system/common/del'), ']', '-', $king->lang->get('system/upfile/manage') . '[', '#upfile' => $king->lang->get('system/upfile/access'), '#upfile_edt' => $king->lang->get('system/common/edit'), '#upfile_delete' => $king->lang->get('system/upfile/del'), ']', '-', $king->lang->get('system/bot/title') . '[', '#bot' => $king->lang->get('system/common/access'), '#botedt' => $king->lang->get('system/common/edit'), '#botdel' => $king->lang->get('system/common/del'), ']', '|', $king->lang->get('system/title/conn') . '[', '#conn' => $king->lang->get('system/common/access'), '#conn_edt' => $king->lang->get('system/common/edit'), '#conn_del' => $king->lang->get('system/common/del'), ']'); $module = $king->getModule(); foreach ($module as $val) { $language = is_file(ROOT . $val . '/language/' . $king->admin['adminlanguage'] . '.xml') ? $king->admin['adminlanguage'] : LANGUAGE; $xml = new KC_XML_class(); $xml->load_file($val . '/language/' . $language . '.xml'); $array_kingcms = $xml->xml2array(); $array_access = $array_kingcms['ACCESS']; if ($array_access) { $_array[] = '|'; $_array[] = '|'; $_array[] = '-' . $king->lang->get($val . '/name') . '-'; // kc_error('<pre>'.print_r($array_access,1)); foreach ($array_access as $k => $v) { $v == '|' ? $_array[] = '|' : ($_array[$k] = $v); } } } $_s = '<div id="levels">'; $_s .= kc_htm_checkbox('level', $_array, $data['adminlevel']); $_s .= '</div>'; $s .= $king->htmForm($king->lang->get('system/admin/setlevel'), '<span>' . $_checkbox . '<label for="adminlevel">' . $king->lang->get('system/level/admin') . '</label></span>' . $_s); $s .= "<script>function selevel(){if (\$('#adminlevel').attr('checked')==true){\$('#levels').hide()}"; $s .= "else{\$('#levels').show();}};selevel();</script>"; } //adminlogin $_array = array(array('adminlogin', 0, 5, 100)); $array_value = array('../system/manage.php' => $king->lang->get('system/common/home'), '../portal/manage.php' => $king->lang->get('system/title/list')); $s .= $king->htmForm($king->lang->get('system/admin/login') . ' (5-100)', '<input type="text" name="adminlogin" id="adminlogin" class="k_in w300" value="' . htmlspecialchars($data['adminlogin']) . '" maxlength="100" />' . kc_htm_setvalue('adminlogin', $array_value), $_array); //siteurl $_array = array(array('siteurl', 0, 0, 100)); $s .= $king->htmForm($king->lang->get('system/admin/url') . ' (0-100)', '<input type="text" name="siteurl" id="siteurl" class="k_in w300" value="' . htmlspecialchars($data['siteurl']) . '" maxlength="100" />', $_array, null, kc_help('system/help/lockurl', 350, 150)); $s .= kc_htm_hidden(array('adminid' => $_adminid)); $s .= $king->closeForm('save'); if ($GLOBALS['ischeck']) { $_sql = 'adminlanguage,admineditor,adminmode,adminlogin,siteurl'; //,admindiymenu if (!$_adminid) { $_sql .= ',adminname'; } $_array_sql = explode(',', $_sql); $_array = array(); foreach ($_array_sql as $val) { $_array[$val] = $data[$val]; } // $_array=array_combine($_array_sql,array_map('post',$_array_sql)); if (kc_post('pass1')) { $_array['adminpass'] = md5(kc_post('pass1')); } if ($king->admin['adminid'] != $_adminid) { if (kc_post('adminlevel') == 'admin') { $_adminlevel = 'admin'; } else { $data['level'][] = 0; /** is_array($data['level']) ? array_push($data['level'],0) : $data['level']=array(0); */ $_adminlevel = implode(',', $data['level']); } $_array['adminlevel'] = $_adminlevel; } if ($_adminid) { $king->db->update('%a_admin', $_array, 'adminid=' . $_adminid); $_nlog = 7; $king->cache->del('system/admin/' . $data['adminname']); } else { // kc_error('<pre>'.print_r($_array,1)); $king->db->insert('%a_admin', $_array); $_nlog = 5; } //写log $king->log($_nlog, 'AdminName:' . $data['adminname']); //更新缓存 $king->cache->rd('system/mainmenu/' . $king->admin['adminid']); $king->cache->del('system/admin/' . $king->admin['adminname']); kc_goto($king->lang->get('system/goto/is'), 'manage.php?action=admin_edt', 'manage.php?action=admin'); } $king->skin->output($king->lang->get('system/title/admin'), king_inc_admin_left(), '', $s); }
function king_def() { global $king; $sel_array = array('mysql' => 'MySQL', 'sqlite' => 'SQLite'); $phpself = $_SERVER['PHP_SELF']; $inst = substr($phpself, 0, strlen($phpself) - 11); //安装目录 $select_type = kc_htm_radio('dbtype', $sel_array, 'sqlite'); //数据库类型 $array_dirs = array('config.php', 'system/js'); $array_func = array('mysql_connect', 'file_get_contents', 'file_put_contents', 'simplexml_load_file'); //,'fsockopen' $s = "<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.0 Transitional//EN\" \"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd\">\r\n<html xmlns=\"http://www.w3.org/1999/xhtml\">\r\n<head>\r\n<meta http-equiv=\"Content-Type\" content=\"text/html; charset=utf-8\" />\r\n<title>" . $king->lang->get('system/install/title') . "</title>\r\n<link href=\"system/skins/default/style.css\" rel=\"stylesheet\" type=\"text/css\" />\r\n<style type=\"text/css\">\r\n.k_table_form{font-size:12px;}\r\n.k_table_form th{width:200px;color:#000;font-weight:normal;text-indent:5px;padding:5px;}\r\n.k_table_form td{text-indent:5px;}\r\n</style>\r\n<meta name=\"generator\" content=\"KingCMS\"/>\r\n<script type=\"text/javascript\" src=\"system/js/jquery.js\"></script>\r\n<script type=\"text/javascript\" src=\"system/js/jquery.kc.js\"></script>\r\n<script type=\"text/javascript\" src=\"system/skins/default/fun.js\"></script>\r\n<script type=\"text/javascript\">\r\njQuery(function(\$){\r\n\r\n\t\$(\"#k_dbtype_mysql , #k_dbtype_sqlite\").click(function(){\$.ck_radio(this)});\r\n\r\n\t\$.ck_radio=function(obj){\r\n\t\tif(\$(obj).attr('id')=='k_dbtype_mysql'){\r\n\t\t\t\$('.mysql').show();\r\n\t\t\t\$('.sqlite').hide();\r\n\r\n\t\t}else{\r\n\t\t\t\$('.sqlite').show();\r\n\t\t\t\$('.mysql').hide();\r\n\t\t\r\n\t\t}\r\n\t}\r\n\r\n});\r\n\r\n</script>\r\n</head>\r\n<body>\r\n<div id=\"k_ajax\"></div>\r\n<div id=\"top\">\r\n\t<a id=\"logo\" href=\"http://www.kingcms.com\" target=\"_blank\"><img alt=\"KingCMS\" src=\"system/skins/default/logo.gif\"/></a>\r\n\t<ul class=\"k_menu\">\r\n\t\t<li><a href=\"INSTALL.php\">" . $king->lang->get('system/common/install') . "</a></li>\r\n\t\t<li><a href=\"javascript:;\">" . $king->lang->get('system/common/language') . "</a>\r\n\r\n\t\t\t\t<ul>"; //language $array = kc_f_getdir('system/language', 'xml'); $array = array_map('kc_f_name', $array); $_language = kc_cookie('language'); foreach ($array as $val) { $s .= '<li><a href="javascript:;" class="k_ajax" rel="{CMD:\'language\',lang:\'' . $val . '\'}">'; if ($_language == $val) { $s .= '• '; } $s .= kc_getlang($val) . '</a></li>'; } $s .= "</ul>\r\n\t\t</li>\r\n\t</ul>\r\n</div>\r\n<div id=\"main\">\r\n\r\n\r\n<table class=\"w0\"><tr><td style=\"vertical-align:top;\" class=\"w10\">\r\n\t<form name=\"form_install\" id=\"form_install\">\r\n\t<h3 class=\"caption\">" . $king->lang->get('system/install/db') . "</h3>\r\n\t<table class=\"k_table_form\" cellspacing=\"0\">\r\n\t\t<tbody><tr><th>" . $king->lang->get('system/install/dbtype') . "</th><td>{$select_type}</td></tr></tbody>\r\n\t\t<tr><th>" . $king->lang->get('system/install/pre') . "</th><td><input id=\"pre\" name=\"pre\" class=\"k_in w200\" value=\"king\"/></td></tr>\r\n\t\t<tr><th>" . $king->lang->get('system/install/preadmin') . "</th><td><input id=\"preadmin\" name=\"preadmin\" class=\"k_in w200\" value=\"kc\"/></td></tr>\r\n\r\n\t\t<tr class=\"mysql none\"><th>" . $king->lang->get('system/install/dbhost') . "</th><td><input id=\"host\" name=\"host\" class=\"k_in w200\" value=\"localhost\"/></td></tr>\r\n\t\t<tr class=\"mysql none\"><th>" . $king->lang->get('system/install/dbdata') . "</th><td><input id=\"data\" name=\"data\" class=\"k_in w200\" value=\"test\"/></td></tr>\r\n\t\t<tr class=\"mysql none\"><th>" . $king->lang->get('system/install/dbuser') . "</th><td><input id=\"user\" name=\"user\" class=\"k_in w200\" value=\"root\"/></td></tr>\r\n\t\t<tr class=\"mysql none\"><th>" . $king->lang->get('system/install/dbpass') . "</th><td><input id=\"pass\" name=\"pass\" class=\"k_in w200\" value=\"\"/></td></tr>\r\n\r\n\t\t<tr class=\"sqlite\"><th>" . $king->lang->get('system/install/dbfile') . "</th><td><input id=\"sqlitedata\" name=\"sqlitedata\" class=\"k_in w200\" value=\"" . kc_random(12) . ".db3\"/></td></tr>\r\n\t</table>\r\n\r\n\t<h3 class=\"caption\">" . $king->lang->get('system/install/admin') . "</h3>\r\n\t<table class=\"k_table_form\" cellspacing=\"0\">\r\n\t\t<tbody><tr><th>" . $king->lang->get('system/install/adminname') . "</th><td><input id=\"adminname\" name=\"adminname\" class=\"k_in w200\" value=\"admin\"/></td></tr></tbody>\r\n\t\t<tr><th>" . $king->lang->get('system/install/adminpass') . "</th><td><input id=\"adminpass\" name=\"adminpass\" class=\"k_in w200\" value=\"admin888\"/></td></tr>\r\n\t</table>\r\n\r\n\t<h3 class=\"caption\">" . $king->lang->get('system/level/config') . "</h3>\r\n\t<table class=\"k_table_form\" cellspacing=\"0\">\r\n\t\t<tbody><tr><th>" . $king->lang->get('system/install/cache') . "</th><td><input id=\"cache\" name=\"cache\" class=\"k_in w200\" value=\"_cache\"/></td></tr></tbody>\r\n\r\n\t\t<tr><th>" . $king->lang->get('system/const/inst') . "</th><td><input id=\"inst\" name=\"inst\" class=\"k_in w100\" value=\"{$inst}\"/></td></tr>\r\n\t\t<tr><th>" . $king->lang->get('system/install/timediff') . "</th><td><input id=\"timediff\" name=\"timediff\" class=\"k_in w100\"/></td></tr>\r\n\t\t<tr><th>" . $king->lang->get('system/install/debug') . "</th><td><input id=\"debug\" value=\"1\" name=\"debug\" type=\"checkbox\" checked=\"checked\"/><label for=\"debug\">" . $king->lang->get('system/install/opendebug') . "</label></td></tr>\r\n\t</table>\r\n\r\n\t<script type=\"text/javascript\">\r\n\tvar dateObj = new Date();\r\n\tvar timediff=" . date('G', 0) . ";\r\n\t\$('#timediff').val(timediff);\r\n\t</script>\r\n\r\n\t<p>\r\n\t\t<input value=\"1\" id=\"license\" name=\"license\" type=\"checkbox\"/><label for=\"license\">" . $king->lang->get('system/install/readlicense') . "</label>\r\n\t\t[<a href=\"http://www.kingcms.com/license/\" target=\"_blank\">" . $king->lang->get('system/install/license') . "</a>]\r\n\t</p>\r\n\t\t<input value=\"1\" id=\"isdelete\" name=\"isdelete\" type=\"checkbox\" checked=\"checked\"/><label for=\"isdelete\">" . $king->lang->get('system/install/isdelete') . "</label>\r\n\t<p>\r\n\r\n\t</p>\r\n\r\n\t<p class=\"k_submit\">\r\n\r\n\t\t<input value=\"" . $king->lang->get('system/common/install') . "[S]\" class=\"k_ajax big\" rel=\"{CMD:'config',FORM:'form_install'}\" type=\"button\" accesskey=\"s\"/>\r\n\r\n\t</p>\r\n\t</form>\r\n</td><td class=\"w1\" style=\"vertical-align:top;\"></td><td>\r\n\r\n\t<h3 class=\"caption\">" . $king->lang->get('system/skin/sys') . "</h3>\r\n\t<table class=\"k_table_list\" cellspacing=\"0\">\r\n\t<tr><th class=\"w10\">" . $king->lang->get('system/skin/obj') . "</th><th class=\"w5\">" . $king->lang->get('system/skin/required') . "</th><th class=\"w5\">" . $king->lang->get('system/skin/this') . "</th></tr>"; $s .= '<tr><td>' . $king->lang->get('system/skin/os') . '</td><td>ALL</td><td>' . PHP_OS . '</td></tr>'; $s .= '<tr><td>' . $king->lang->get('system/skin/phpver') . '</td><td>5.1.0+</td><td>' . PHP_VERSION . '</td></tr>'; if (function_exists('disk_free_space')) { $s .= '<tr><td>' . $king->lang->get('system/skin/diskspace') . '</td><td>>2 Mb</td><td>' . kc_f_size(disk_free_space('./')) . '</td></tr>'; } $s .= "</table>\r\n\t<h3 class=\"caption\">" . $king->lang->get('system/skin/writeinfo') . "</h3>\r\n\t<table class=\"k_table_list\" cellspacing=\"0\">\r\n\t<tr><th class=\"w10\">" . $king->lang->get('system/skin/filedir') . "</th><th class=\"w5\">" . $king->lang->get('system/skin/required') . "</th><th class=\"w5wgfv -k07-87;[yu'pbv9io/h9;'99999\">" . $king->lang->get('system/skin/this') . "</td></tr>"; foreach ($array_dirs as $val) { $s .= '<tr><td>' . $val . '</td><td>' . $king->lang->get('system/skin/write/w1') . '</td><td>' . $king->lang->get('system/skin/write/w' . (is_writable(ROOT . $val) ? 1 : 0)) . '</td></tr>'; } $s .= "</table>\r\n\t<h3 class=\"caption\">" . $king->lang->get('system/skin/func') . "</h3>\r\n\t<table class=\"k_table_list\" cellspacing=\"0\">\r\n\t<tr><th class=\"w10\">" . $king->lang->get('system/skin/funs') . "</th><th class=\"w5\">" . $king->lang->get('system/skin/required') . "</th><th class=\"w5\">" . $king->lang->get('system/skin/this') . "</th></tr>"; foreach ($array_func as $val) { $s .= '<tr><td>' . $val . '()</td><td>' . $king->lang->get('system/skin/fun/f1') . '</td><td>' . $king->lang->get('system/skin/fun/f' . (function_exists($val) ? 1 : 0)) . '</td></tr>'; } $s .= "</table>\r\n\t<h3 class=\"caption\">" . $king->lang->get('system/skin/other') . "</h3>\r\n\t<table class=\"k_table_list\" cellspacing=\"0\">\r\n\t"; $s .= "<tr><th class=\"w10 red\">" . $king->lang->get('system/skin/obj') . "</th><th class=\"w5 red\">" . $king->lang->get('system/skin/advice') . "</th><th class=\"w5 red\">" . $king->lang->get('system/skin/this') . "</th></tr>\r\n\t<tr><td>" . $king->lang->get('system/skin/browser') . "</td><td>IE 7.0</td><td>" . kc_browser() . "</td></tr>\r\n\t<tr><td>" . $king->lang->get('system/skin/safemode') . "</td><td>--</td><td>" . $king->lang->get('system/skin/open/o' . (ini_get('safe_mode') ? 1 : 0)) . "</td></tr>\r\n\t<tr><td>" . $king->lang->get('system/skin/maxetime') . "</td><td>--</td><td>" . ini_get('max_execution_time') . "s</td></tr>\r\n\t</table>\r\n\r\n\t<p><img class=\"f6 os\" src=\"system/images/white.gif\"/><a href=\"http://www.kingcms.com/\" class=\"k_ajax\" rel=\"{CMD:'repass',METHOD:'GET'}\">" . $king->lang->get('system/install/resetpass') . "</a></p>\r\n\t<p><img class=\"j2 os\" src=\"system/images/white.gif\"/><a href=\"http://www.kingcms.com/\" class=\"k_ajax\" rel=\"{CMD:'delete'}\">" . $king->lang->get('system/install/delfile') . "</a></p>\r\n\t<p><img class=\"n1 os\" src=\"system/images/white.gif\"/><a href=\"system/login.php\">" . $king->lang->get('system/install/login') . "</a></p>\r\n\r\n</td></tr></table>\r\n\r\n</div>\r\n</body>\r\n</html>"; exit($s); }
/** 添加/编辑碎片 */ function king_ajax_edt() { global $king; $king->access('dbquery_edt'); $kid = kc_get('kid', 2); $sql = "kid,kname,ntype,dbhost,dbname,dbfile,dbuser,dbpass,dbcharset"; $array_sql = explode(',', $sql); if ($GLOBALS['ismethod'] || empty($kid) || kc_post('reset') == 1) { //若kid为空,则添加 $data = $_POST; if (!$GLOBALS['ismethod']) { //预置项 $data['ntype'] = isset($_POST['ntype']) ? $_POST['ntype'] : 1; } } else { //编辑数据,从数据库读出 if (!($data = $king->db->getRows_one("select {$sql} from %s_dbquery where kid={$kid} limit 1"))) { kc_error($king->lang->get('system/error/notrecord')); } } $data = kc_data($array_sql, $data); //ntype $array_type = array(1 => 'MySQL', 2 => 'SQLite'); $exp = " onClick=\"\$('#ntype').val(\$(this).val());setTimeout('\$.kc_ajax({URL:\\'../dbquery/manage.php\\',CMD:\\'edt\\',IS:1,METHOD:\\'GET\\',kid:\\'{$kid}\\',reset:1})',50)\" "; $s = $king->htmForm($king->lang->get('dbquery/label/type'), kc_htm_radio('ntype_show', $array_type, $data['ntype'], $exp)); $s .= kc_htm_hidden(array('ntype' => $data['ntype'])); //kname $array = array(array('kname', 0, 1, 50)); //验证重复值 if (empty($kid)) { $array[] = array('kname', 12, $king->lang->get('dbquery/error/name'), $king->db->getRows_one("select kid from %s_dbquery where kname='" . $king->db->escape($data['kname']) . "'")); } else { $array[] = array('kname', 12, $king->lang->get('dbquery/error/name'), $king->db->getRows_one("select kid from %s_dbquery where kname='" . $king->db->escape($data['kname']) . "' and kid<>{$kid}")); } $s .= $king->htmForm($king->lang->get('dbquery/label/name'), kc_htm_input('kname', $data['kname'], 50, 200), $array); if ($data['ntype'] == 1) { //mysql //dbhost $array = array(array('dbhost', 0, 1, 50)); $s .= $king->htmForm($king->lang->get('dbquery/label/dbhost'), kc_htm_input('dbhost', $data['dbhost'], 50, 400), $array); //dbname $array = array(array('dbname', 0, 1, 50)); $s .= $king->htmForm($king->lang->get('dbquery/label/dbname'), kc_htm_input('dbname', $data['dbname'], 50, 400), $array); //dbuser $array = array(array('dbuser', 0, 1, 50)); $s .= $king->htmForm($king->lang->get('dbquery/label/dbuser'), kc_htm_input('dbuser', $data['dbuser'], 50, 200), $array); //dbpass $array = array(array('dbpass', 0, 0, 50)); $s .= $king->htmForm($king->lang->get('dbquery/label/dbpass'), kc_htm_input('dbpass', $data['dbpass'], 50, 200), $array); //dbcharset $array = array(array('dbcharset', 0, 0, 50)); $array_charset = array('UTF-8' => 'UTF-8', 'GBK' => 'GBK'); $s .= $king->htmForm($king->lang->get('dbquery/label/dbcharset'), kc_htm_select('dbcharset', $array_charset, $data['dbcharset']), $array); $height = 340; } else { //dbfile $array = array(array('dbfile', 0, 4, 50), array('dbfile', 12, $king->lang->get('dbquery/error/dbfile'), !is_file(ROOT . $data['dbfile']))); $s .= $king->htmForm($king->lang->get('dbquery/label/dbfile'), kc_htm_input('dbfile', $data['dbfile'], 50, 400), $array); $height = 160; } if ($GLOBALS['ischeck']) { if ($data['ntype'] == 1) { $array = array('ntype' => 1, 'kname' => $data['kname'], 'dbhost' => $data['dbhost'], 'dbname' => $data['dbname'], 'dbuser' => $data['dbuser'], 'dbpass' => $data['dbpass'], 'dbcharset' => $data['dbcharset']); } else { $array = array('ntype' => 2, 'kname' => $data['kname'], 'dbfile' => $data['dbfile']); } if (empty($kid)) { //insert $array['norder'] = $king->db->neworder('%s_dbquery'); $king->db->insert('%s_dbquery', $array); } else { $king->db->update('%s_dbquery', $array, "kid={$kid}"); } $king->cache->del("dbquery/info/{$data['kname']}"); kc_ajax('OK', "<p class=\"k_ok\">" . $king->lang->get('system/ok/' . (empty($kid) ? 'add' : 'edt')) . "</p>", 1); } $tit = $king->lang->get('dbquery/title/' . (empty($kid) ? 'add' : 'edt')); $but = kc_htm_a($king->lang->get("system/common/" . (empty($kid) ? 'add' : 'edit')), "{URL:'../dbquery/manage.php',CMD:'edt',kid:'{$kid}',IS:1}"); kc_ajax($tit, $s, $but, '', 440, $height + $GLOBALS['check_num'] * 15); }
function king_def() { global $king; //die(uc_user_synlogin(2)); if ($GLOBALS['ismethod']) { //POST过程 $data = $_POST; } else { $data = array('re' => kc_val($_SERVER, 'HTTP_REFERER')); } $data = kc_data(array('re', 'username', 'userpass', 'expire')); if ($king->config('blackuser', 'user')) { $array_black = explode('|', $king->config('blackuser', 'user')); $array_black = array_diff($array_black, array(null)); } else { $array_black = array(); } $s = $king->openForm('login.php'); //username $_array = array(array('username', 0, 3, 15), array('username', 14, $king->lang->get('portal/check/reg/u-1'), array('*', '\\', ':', '?', '<', '>', '|', ';', ',', '\'', '!', '~', '$', '#', '@', '^', '(', ')', '{', '}', '=', '+', '%', '/')), array('username', 14, $king->lang->get('portal/check/reg/u-2'), $array_black)); $s .= $king->htmForm($king->lang->get('portal/user/name'), '<input class="k_in w150" type="text" name="username" value="' . htmlspecialchars($data['username']) . '" maxlength="15" />', $_array, null, "<tt><a href=\"javascript:; \" class=\"k_user_register\">" . $king->lang->get('portal/user/reg') . "</a></tt>"); //pass $_array = array(array('userpass', 0, 6, 30)); if ($data['userpass'] && $GLOBALS['ischeck']) { //有密码 并 账号验证成功的时候进行验证 $username = $data['username']; $is = False; if ($king->user->isuc) { //如果有UC if ($array_uc = uc_user_login($data['username'], $data['userpass'])) { //链接成功 if ((int) $array_uc[0] < 0) { //用户名不存在或密码错误 if ($res = $king->db->getRows_one("select usermail,userpass,ksalt,userid from %s_user where username='******' and uid=0")) { //判断本地是否存在这个用户并且未同步到uc $userid = $res['userid']; if (md5($res['ksalt'] . $data['userpass']) == $res['userpass']) { //检测密码 $uid = uc_user_register($username, $data['userpass'], $res['usermail']); //注册用户到uc $king->db->update('%s_user', array('lastlogindate' => time(), 'uid' => $uid > 0 ? $uid : 0), 'username=\'' . $king->db->escape($username . '\'')); uc_user_login($data['username'], $data['userpass']); } else { $is = True; $errId = -2; } } else { $is = True; $errId = $array_uc[0]; } } else { //登录成功的时候,检查一下本地是否有这个账号 $uid = $array_uc[0]; //UC中的UID if ($res = $king->db->getRows_one("select userpass,ksalt,userid from %s_user where username='******'")) { //如果有这么个账号 $userid = $res['userid']; if (md5($res['ksalt'] . $data['userpass']) != $res['userpass']) { //若不一致,则进行更新 $userpass = md5($res['ksalt'] . $data['userpass']); $king->db->update('%s_user', array('userpass' => $userpass, 'lastlogindate' => time()), 'username=\'' . $king->db->escape($username . '\'')); } else { $king->db->update('%s_user', array('lastlogindate' => time()), 'username=\'' . $king->db->escape($username . '\'')); } } else { //如果本地没有这个账号,则添加 $usermail = $array_uc[3]; $ksalt = kc_random(6); $array = array('username' => $username, 'userpass' => md5($ksalt . $data['userpass']), 'usermail' => $usermail, 'ksalt' => $ksalt, 'uid' => $uid, 'regdate' => time(), 'lastlogindate' => time()); $king->db->insert('%s_user', $array); $res = $king->db->getRows_one("select userid from %s_user where uid='" . $uid . "' and isdelete=0"); $userid = $res['userid']; } } } else { kc_error($king->lang->get('portal/error/connect')); //连接错误 } } else { //如果没有UC if ($res = $king->db->getRows_one("select userpass,ksalt,userid from %s_user where username='******' and isdelete=0")) { //如果有这么个账号 $md5pass = md5($res['ksalt'] . $data['userpass']); // kc_error($md5pass."\t".$res['userpass']); if ($md5pass != $res['userpass']) { //若不一致,提示错误 $is = True; $errId = -2; } else { //验证通过 $userid = $res['userid']; $king->db->update('%s_user', array('lastlogindate' => time()), 'userid=' . $userid); // $userpass=md5($res['ksalt'].$data['userpass']); } } else { $is = True; $errId = -1; } } if (!empty($errId)) { $_array[] = array('userpass', 12, $king->lang->get('portal/check/pwd/p' . $errId), $is); } } $s .= $king->htmForm($king->lang->get('portal/user/pass') . '', '<input class="k_in w150" type="password" name="userpass" maxlength="30" />', $_array, null, "<tt><a href=\"javascript:;\" class=\"k_user_lostpwd\">" . $king->lang->get('portal/user/lostpwd') . "</a></tt>"); //expire $array_select = array(0 => $king->lang->get('system/time/cookie'), 86400 => $king->lang->get('system/time/oneday'), 2592000 => $king->lang->get('system/time/jan'), 15768000 => $king->lang->get('system/time/halfyear'), 31536000 => $king->lang->get('system/time/ayear'), 315360000 => $king->lang->get('system/time/forever')); $s .= $king->htmForm($king->lang->get('portal/user/expire'), kc_htm_radio('expire', $array_select, 2592000)); //verify $verify = new KC_Verify_class(); $s .= $verify->Show(); $s .= kc_htm_hidden(array('re' => $data['re'])); $s .= $king->closeForm($king->lang->get('system/common/login')); if ($GLOBALS['ischeck']) { //写Cookie $s = $king->user->userLogin($userid, $data['expire']); $array = array('<a href="/">' . $king->lang->get('portal/user/return/home') . '</a>', '<a href="index.php">' . $king->lang->get('portal/user/return/uc') . '</a>'); if ($data['re']) { $array[] = '<a href="' . $data['re'] . '">' . $king->lang->get('portal/user/return/re') . ' : ' . $data['re'] . '</a>'; $goto = $data['re']; } else { $goto = $king->config('inst') . 'user/index.php'; } $s .= kc_htm_ol($king->lang->get('portal/user/loginok'), $array, $goto); } $tmp = new KC_Template_class($king->config('templateuser', 'user'), $king->config('templatepath') . '/inside/user/login.htm'); $tmp->assign('main', $s); $tmp->assign('title', $king->lang->get('portal/title/login')); echo $tmp->output(); }
/** 解析表单项目 @param array $rs 当前对象的数组 @param array $data 表单值 @param array $info 模型及字段相关信息,由listid值获取 @param int $is 默认为1后台,0的时候是前台调用 @param int $at 默认为1首页,2的时候是次页调用 @param int $group 默认为1非组,0的时候是[组]调用 */ public function formDeCode($rs, $data, $info, $is = 1, $at = 1, $group = 1) { /* $sql='ktitle,kfield,ntype,nvalidate,nsizemin,nsizemax,kdefault,koption,nstylewidth,nstyleheight,nupfile,issearch,isshow'; */ global $king; $model = $this->infoModel($info['modelid']); $s = ''; $h = ''; $c = array(); $f = $rs['kfield']; switch ($rs['ntype']) { case 0: //系统字段 switch ($f) { case 'ktitle': if ($at == 1) { //首页必填 $c[] = array($f, 0, 1, 100); } else { //次页可选择不填 $c[] = array($f, 0, 0, 100); } $s = '<input type="text" id="' . $f . '" name="' . $f . '" value="' . htmlspecialchars($data[$f]) . '" class="k_in w400" maxlength="100" />'; $h = '<a id="cktitle" class="k_ajax" rel="{URL:\'manage.content.php\',CMD:\'ckre\',obj:\'ktitle\',listid:' . $info['listid'] . ',kid:\'' . $data['kid'] . '\',ID:\'cktitle\',IS:2,ktitle:$(\'#ktitle\').val()}" >'; $h .= kc_icon('a7', $king->lang->get('system/common/ckre')) . '</a>'; break; case 'ksubtitle': $c = $data[$f] != '' ? array(array($f, 0, 4, 20)) : array(); $s = '<input type="text" id="' . $f . '" name="' . $f . '" value="' . htmlspecialchars($data[$f]) . '" class="k_in w300" maxlength="20" />'; break; case 'kkeywords': $c[] = array($f, 0, 0, 100); $s = '<input type="text" id="' . $f . '" name="' . $f . '" value="' . htmlspecialchars($data[$f]) . '" class="k_in w400" maxlength="100" />'; $h = '<a class="k_ajax" rel="{URL:\'manage.content.php\',CMD:\'keywords\',VAL:\'' . $f . ',ktitle,listid\'}" >'; $h .= kc_icon('d7', $king->lang->get('portal/label/insert')) . '</a>' . kc_help('portal/help/comma', 350, 100); break; case 'ktag': $c[] = array($f, 0, 0, 100); $s = '<input type="text" id="' . $f . '" name="' . $f . '" value="' . htmlspecialchars($data[$f]) . '" class="k_in w400" maxlength="100" />'; $h = '<a class="k_ajax" rel="{URL:\'manage.content.php\',CMD:\'tag\',VAL:\'' . $f . ',ktitle,listid\'}" >'; $h .= kc_icon('d7', $king->lang->get('portal/label/insert')) . '</a>'; $h .= '<a href="manage.tag.php" target="_blank">' . kc_icon('e7', $king->lang->get('system/common/manage')) . '</a>' . kc_help('portal/help/comma', 350, 100); break; case 'kimage': $c[] = array($f, 0, 0, 255); $c[] = array($f, 15, null, $king->config('upimg')); $s = '<input type="text" id="' . $f . '" name="' . $f . '" value="' . htmlspecialchars($data[$f]) . '" class="k_in w400" maxlength="100" />'; $h = kc_f_brow('kimage', $king->config('uppath') . '/image/', 0); break; case 'kpath': if ($info['npage'] == 0 && $king->admin['adminmode'] != 0) { //如果生成静态,则 $c[] = array($f, 0, 1, 255); $c[] = array($f, 15); if ($data['kid']) { $c[] = array($f, 12, $king->lang->get('portal/tip/isexist1'), $king->db->getRows_one("select kpath from %s__{$model['modeltable']} where kpath='" . $king->db->escape($data['kpath']) . "' and kid<>{$data['kid']};")); } else { $c[] = array($f, 12, $king->lang->get('portal/tip/isexist1'), $king->db->getRows_one("select kpath from %s__{$model['modeltable']} where kpath='" . $king->db->escape($data['kpath']) . "';")); } $s = '<input type="text" id="' . $f . '" name="' . $f . '" value="' . htmlspecialchars($data[$f]) . '" class="k_in w400" maxlength="100" />'; $h = '<a id="ckpath" class="k_ajax" rel="{URL:\'manage.content.php\',ID:\'ckpath\',CMD:\'ckre\',obj:\'kpath\',listid:' . $info['listid'] . ',kid:\'' . $data['kid'] . '\',' . $f . ':$(\'#' . $f . '\').val()}" >'; $h .= kc_icon('a7', $king->lang->get('system/common/ckre')) . '</a>'; } else { return; // $s=kc_htm_hidden(array($f=>htmlspecialchars($data[$f]))); } break; case 'nattrib': $kid = $rs['kid']; $isshow = $is == 1 ? "isadmin{$at}" : "isuser{$at}"; if (!($res2 = $king->db->getRows("select * from %s_field where modelid={$info['modelid']} and {$isshow}=1 and kid1={$kid} order by norder,kid;"))) { //全部调用 return; } //如果没有可见项,则返回空值 $s = ''; $c2 = array(); $h2 = ''; //($s,$c,$h) foreach ($res2 as $rs2) { list($s2, $c2, $h2) = $this->formdecode($rs2, $data, $info, $is, $at, 0); $s .= '<span class="k_field">'; if ($rs2['istitle']) { $s .= '<label>' . addslashes($rs2['ktitle']) . '</label>'; } $s .= $s2 . '</span>'; $c = array_merge($c, $c2); $h .= $h2; } break; case 'kcontent': $c[] = array($f, 0, $rs['nsizemin'], $rs['nsizemax']); $c[] = array($f, 21); if ($is) { $s .= '<span><input type="checkbox" id="isgrab" name="isgrab" ' . (kc_post('isgrab') ? 'checked="true"' : '') . '/><label for="isgrab">' . $king->lang->get('system/common/grab') . '</label>'; $s .= '<input type="checkbox" id="isoneimage" name="isoneimage" ' . (kc_post('isoneimage') ? 'checked="true"' : '') . '/><label for="isoneimage">' . $king->lang->get('portal/remove/oneimage') . '</label></span>'; //$s.='<input type="checkbox" id="isreplacetag" name="isreplacetag" '.(kc_post('isreplacetag')?'checked="true"':'').'/><label for="isreplacetag">'.$king->lang->get('portal/remove/replacetag').'</label></span>'; $s .= '<span><img src="../system/images/white.gif" class="os n4"/>' . $king->lang->get('system/common/filtercode') . '[<input type="checkbox" id="isremovea" name="isremovea" ' . (kc_post('isremovea') ? 'checked="true"' : '') . '/><label for="isremovea">' . $king->lang->get('portal/remove/a') . '</label>'; $s .= '<input type="checkbox" id="isremovetable" name="isremovetable" ' . (kc_post('isremovetable') ? 'checked="true"' : '') . '/><label for="isremovetable">' . $king->lang->get('portal/remove/table') . '</label>'; $s .= '<input type="checkbox" id="isremovestyle" name="isremovestyle" ' . (kc_post('isremovestyle') ? 'checked="true"' : '') . '/><label for="isremovestyle">' . $king->lang->get('portal/remove/style') . '</label>'; $s .= '<input type="checkbox" id="isremoveid" name="isremoveid" ' . (kc_post('isremoveid') ? 'checked="true"' : '') . '/><label for="isremoveid">' . $king->lang->get('portal/remove/id') . '</label>'; $s .= '<input type="checkbox" id="isremoveclass" name="isremoveclass" ' . (kc_post('isremoveclass') ? 'checked="true"' : '') . '/><label for="isremoveclass">' . $king->lang->get('portal/remove/class') . '</label>]</span><br/>'; } $s .= kc_htm_editor($f, $data[$f], $rs['nstylewidth'], $rs['nstyleheight']); break; case 'krelate': $c = $data[$f] ? array(array($f, 3)) : array(); $s = '<input type="hidden" id="' . $f . '" name="' . $f . '" value="' . htmlspecialchars($data[$f]) . '"/>'; $s .= '<table class="k_side" cellspacing="0"><tr><td id="krelateshow" class="k_in">'; $s .= 'Loading...'; $s .= '</td><td>'; $s .= '<a class="k_ajax" rel="{URL:\'manage.content.php\',CMD:\'hrelate\',VAL:\'krelate,listid,kid\'}" >' . kc_icon('b7', $king->lang->get('portal/label/relate1')) . '</a>'; //手动匹配 $s .= '<a class="k_ajax" rel="{URL:\'manage.content.php\',ID:\'krelateshow\',CMD:\'relate\',VAL:\'ktitle,listid,kid\'}">' . kc_icon('c7', $king->lang->get('portal/label/relate0')) . '</a>'; //自动匹配 $s .= kc_help('portal/help/relate'); $s .= '</td></tr></table>'; $s .= "<script>function krelateshow(){\$.kc_ajax('{URL:\\'manage.content.php\\',CMD:\\'relateload\\',ID:\\'krelateshow\\',VAL:\\'krelate,listid\\'}')};krelateshow();</script>"; break; case 'kdescription': $c[] = array($f, 0, 0, 255); $s = '<textarea rows="4" cols="100" class="k_in w400" name="' . $f . '" maxlength="255" >' . htmlspecialchars($data[$f]) . '</textarea>'; break; case 'nprice': $c[] = array($f, 0, 1, 11); $c[] = array($f, 3); $s = '<input type="text" id="' . $f . '" name="' . $f . '" value="' . htmlspecialchars($data[$f]) . '" class="k_in w100" maxlength="11" />'; $h = kc_htm_setvalue_nl($f, $rs['koption']); break; case 'nweight': $c[] = array($f, 0, 1, 11); $c[] = array($f, 2); $s = '<input type="text" id="' . $f . '" name="' . $f . '" value="' . htmlspecialchars($data[$f]) . '" class="k_in w100" maxlength="11" />'; $h = kc_htm_setvalue_nl($f, $rs['koption']) . kc_help('portal/help/weight'); break; case 'nnumber': $c[] = array($f, 0, 1, 11); $c[] = array($f, 2); $s = '<input type="text" id="' . $f . '" name="' . $f . '" value="' . htmlspecialchars($data[$f]) . '" class="k_in w100" maxlength="11" />'; $h = kc_htm_setvalue_nl($f, $rs['koption']); break; default: if (in_array($f, array('nshow', 'nhead', 'ncommend', 'nup', 'nfocus', 'nhot'))) { $c[] = array($f, 20, null, array(0, 1)); // kc_error(print_r($data,1)); $checked = empty($data[$f]) ? '' : ' checked="checked"'; $s = '<input' . $checked . ' type="checkbox" id="' . $f . '" name="' . $f . '" value="1" />'; $s .= '<label for="' . $f . '">' . htmlspecialchars($rs['ktitle']) . '</label>'; } } break; //value="'.htmlspecialchars($data[$f]).'" //$rs='ktitle,kfield,ntype,nvalidate,nsizemin,nsizemax,kdefault,koption,nstylewidth,nstyleheight,nupfile,issearch,isshow'; //value="'.htmlspecialchars($data[$f]).'" //$rs='ktitle,kfield,ntype,nvalidate,nsizemin,nsizemax,kdefault,koption,nstylewidth,nstyleheight,nupfile,issearch,isshow'; case 1: //单行文本 $c[] = array($f, 0, $rs['nsizemin'], $rs['nsizemax']); if ($rs['nvalidate'] != 0) { $c[] = array($f, $rs['nvalidate']); } $s = '<input type="text" name="' . $f . '" id="' . $f . '" value="' . htmlspecialchars($data[$f]) . '" class="k_in" style="width:' . $rs['nstylewidth'] . 'px;" maxlength="' . $rs['nsizemax'] . '" />'; $h = $this->help($rs['kid'], $rs['khelp']) . kc_htm_setvalue_nl($f, $rs['koption']); break; case 2: //多行文本 (不支持编辑器) $c[] = array($f, 0, $rs['nsizemin'], $rs['nsizemax']); $s = '<table class="k_side" cellspacing="0"><tr><td><textarea name="' . $f . '" class="k_in" style="width:' . $rs['nstylewidth'] . 'px;height:' . $rs['nstyleheight'] . 'px;" >' . htmlspecialchars($data[$f]) . '</textarea></td><td>' . $this->help($rs['kid'], $rs['khelp']) . '</td></tr></table>'; break; case 3: //多行文本 (支持编辑器) $c[] = array($f, 0); $c[] = array($f, 21); $s = '<table class="k_side" cellspacing="0"><tr><td>' . kc_htm_editor($f, $data[$f]) . '</td><td>' . $this->help($rs['kid'], $rs['khelp']) . '</td></tr></table>'; break; case 4: //单选 (下拉列表) $c[] = array($f, 0, 0, 255); $array_def = explode(NL, $rs['koption']); $array_select = array(); foreach ($array_def as $val) { if (isset($val[0])) { //不能为空值 $array_val = explode('|', $val, 2); if (count($array_val) > 1) { //有分割符号 $array_select[$array_val[0]] = $array_val[1]; } else { $array_select[$val] = $val; } } } $c[] = array($f, 20, null, array_keys($array_select)); $s = kc_htm_select($f, $array_select, $data[$f]); $h = $this->help($rs['kid'], $rs['khelp']); break; case 5: //单选 (radio) $c[] = array($f, 0, 0, 255); $array_def = explode(NL, $rs['koption']); $array_radio = array(); foreach ($array_def as $val) { if (isset($val[0])) { //不能为空值 $array_val = explode('|', $val, 2); if (count($array_val) > 1) { //有分割符号 $array_radio[$array_val[0]] = $array_val[1]; } else { $array_radio[$val] = $val; } } } $c[] = array($f, 20, null, array_keys($array_radio)); $s = kc_htm_radio($f, $array_radio, $data[$f]); $h = $this->help($rs['kid'], $rs['khelp']); break; case 6: //多选 (多选列表) $c[] = array($f, 0, 0, 255); $array_def = explode(NL, $rs['koption']); $array_select = array(); foreach ($array_def as $val) { if (isset($val[0])) { //不能为空值 $array_val = explode('|', $val, 2); if (count($array_val) > 1) { //有分割符号 $array_select[$array_val[0]] = $array_val[1]; } else { $array_select[$val] = $val; } } } $array_keys = array_keys($array_select); //可选值,但需要再加一个空值进去 $array_keys[''] = ''; $c[] = array($f, 23, null, $array_keys); $s = kc_htm_select($f, $array_select, $data[$f], ' multiple="multiple" style="width:' . $rs['nstylewidth'] . 'px;height:' . $rs['nstyleheight'] . 'px;"'); $h = $this->help($rs['kid'], $rs['khelp']); break; case 7: //复选框 $c[] = array($f, 0, 0, 255); $array_def = explode(NL, $rs['koption']); $array_radio = array(); foreach ($array_def as $val) { if (isset($val[0])) { //不能为空值 $array_val = explode('|', $val, 2); if (count($array_val) > 1) { //有分割符号 $array_radio[$array_val[0]] = $array_val[1]; } else { $array_radio[$val] = $val; } } } $array_keys = array_keys($array_radio); //可选值,但需要再加一个空值进去 $array_keys[''] = ''; $c[] = array($f, 23, null, $array_keys); $s = kc_htm_checkbox($f, $array_radio, $data[$f]); $h = $this->help($rs['kid'], $rs['khelp']); break; case 8: //文件上传(图片类型) $c[] = array($f, 0, $rs['nsizemin'], $rs['nsizemax']); $s = '<input type="text" name="' . $f . '" id="' . $f . '" value="' . htmlspecialchars($data[$f]) . '" class="k_in" style="width:' . $rs['nstylewidth'] . 'px;" maxlength="' . $rs['nsizemax'] . '" />'; $h = kc_f_brow($f, $king->config('uppath') . '/image', 0) . $this->help($rs['kid'], $rs['khelp']) . kc_htm_setvalue_nl($f, $rs['koption']); break; case 9: //图片列表 $c[] = array($f, 0, $rs['nsizemin'], $rs['nsizemax']); // class="w800" $s = kc_htm_hidden(array($f => $data[$f])); $src = $king->lang->get('portal/label/imgsrc'); $alt = $king->lang->get('portal/label/imgalt'); $s .= kc_htm_input("S{$f}", $src, 400, 400, " onClick=\"\$(this).val(this.value=='{$src}'?'':this.value)\"") . "<br/>"; $s .= kc_htm_input("A{$f}", $alt, 400, 300, " onClick=\"\$(this).val(this.value=='{$alt}'?'':this.value)\""); $s .= " <input type=\"button\" value=\"" . $king->lang->get('system/common/add') . "\" id=\"B{$f}\" />"; // onClick=\"F$f()\" $s .= "<div id=\"W{$f}\" class=\"imglist\" style=\"width:{$rs['nstylewidth']}px\"></div>"; //JavaScript中判断Src值是否为远程图像,如果是的话,则直接抓取图片到本地 $s .= "<script>\r\n\t\t\t\t//点击“添加”按钮的时候的效果\r\n\t\t\t\tfunction F{$f}(){\r\n\t\t\t\t\tvar t=String.fromCharCode(9);\r\n\t\t\t\t\tvar S=\$('#S{$f}').val().replace(t,'');\r\n\t\t\t\t\tvar A=\$('#A{$f}').val().replace(t,'');\r\n\t\t\t\t\t//判断是否填写图片地址\r\n\t\t\t\t\tif(S=='' || S=='{$src}'){\r\n\t\t\t\t\t\talert('" . $king->lang->get('portal/error/notimgsrc') . "');\r\n\t\t\t\t\t\treturn;\r\n\t\t\t\t\t}\r\n\r\n\t\t\t\t\tif(A=='' || A=='{$alt}') A=S;\r\n\t\t\t\t\tvar s=S+t+A;\r\n\t\t\t\t\tvar ss=\$('#{$f}').val();\r\n\t\t\t\t\t//如果S为空,则提示错误\r\n\t\t\t\t\tif(ss==''){\r\n\t\t\t\t\t\t\$('#{$f}').val(s);\r\n\t\t\t\t\t}else{\r\n\t\t\t\t\t\t//判断图片是否已经存在\r\n\t\t\t\t\t\tvar ss_1=ss.split(t+t);\r\n\t\t\t\t\t\tvar ss_2,src;\r\n\t\t\t\t\t\tfor(i=0;i<ss_1.length;i++){\r\n\t\t\t\t\t\t\tss_2=ss_1[i].split(t);\r\n\t\t\t\t\t\t\tsrc=ss_2[0];\r\n\t\t\t\t\t\t\tif(src==S){\r\n\t\t\t\t\t\t\t\talert('" . $king->lang->get('portal/error/retimgsrc') . "');\r\n\t\t\t\t\t\t\t\t\$('#S{$f}').val('');\r\n\t\t\t\t\t\t\t\treturn;\r\n\t\t\t\t\t\t\t}\r\n\t\t\t\t\t\t}\r\n\t\t\t\t\t\t\$('#{$f}').val(ss+t+t+s);\r\n\t\t\t\t\t}\r\n\t\t\t\t\t\$('#S{$f}').val('');\r\n\t\t\t\t\t\$('#A{$f}').val('');\r\n\t\t\t\t\tS{$f}();\r\n\t\t\t\t}\r\n\t\t\t\t//显示数据\r\n\t\t\t\tfunction S{$f}(){\r\n\t\t\t\t\tvar t=String.fromCharCode(9);\r\n\t\t\t\t\tvar ss=\$('#{$f}').val();\r\n\t\t\t\t\tif(ss==''){\r\n\t\t\t\t\t\t\$('#W{$f}').html('');\r\n\t\t\t\t\t\treturn;\r\n\t\t\t\t\t}\r\n\t\t\t\t\tvar s='';\r\n\t\t\t\t\tvar ss_1=ss.split(t+t);\r\n\t\t\t\t\tvar ss_2,alt,src;\r\n\t\t\t\t\tfor(i=0;i<ss_1.length;i++){\r\n\t\t\t\t\t\tss_2=ss_1[i].split(t);\r\n\t\t\t\t\t\tsrc=ss_2[0];\r\n\t\t\t\t\t\talt=ss_2[1];\r\n\r\n\t\t\t\t\t\ts+='<span class=\"img\" title=\"'+alt+'\">';\r\n\t\t\t\t\t\ts+='<a href=\"javascript:;\" onClick=\"E{$f}('+i+')\" class=\"img\" title=\"" . $king->lang->get('system/common/edit') . "\">';\r\n\t\t\t\t\t\ts+='<img class=\"img\" src=\"'+(ss_2[0].match(/^[a-zA-Z]{3,10}:\\/\\/[^\\s]+\$/) ? ss_2[0] : '../'+ss_2[0])+'\"/>';\r\n\t\t\t\t\t\ts+='</a>';\r\n\r\n\t\t\t\t\t\ts+='<a class=\"title\" href=\"javascript:;\" onClick=\"D{$f}('+i+')\" title=\"" . $king->lang->get('system/common/del') . "\">';\r\n\t\t\t\t\t\ts+=\$.kc_icon('j2')+alt;\r\n\t\t\t\t\t\ts+='</a>';\r\n\t\t\t\t\t\ts+='</span>';\r\n\t\t\t\t\t}\r\n\t\t\t\t\t\$('#W{$f}').html(s);\r\n\t\t\t\t}\r\n\t\t\t\t//删除图片\r\n\t\t\t\tfunction D{$f}(num){\r\n\t\t\t\t\tvar t=String.fromCharCode(9);\r\n\t\t\t\t\tvar ss=\$('#{$f}').val();\r\n\t\t\t\t\tif(ss==''){\r\n\t\t\t\t\t\t\$('#W{$f}').html('');\r\n\t\t\t\t\t\treturn;\r\n\t\t\t\t\t}\r\n\t\t\t\t\tvar ss_1=ss.split(t+t);\r\n\t\t\t\t\t\r\n\t\t\t\t\tss_1.splice(num,1);\r\n\r\n\t\t\t\t\t\$('#{$f}').val(ss_1.join(t+t));\r\n\r\n\t\t\t\t\tS{$f}();\r\n\t\t\t\t\t\r\n\t\t\t\t}\r\n\t\t\t\t//编辑图片\r\n\t\t\t\tfunction E{$f}(num){\r\n\t\t\t\t\tvar t=String.fromCharCode(9);\r\n\t\t\t\t\tvar ss=\$('#{$f}').val();\r\n\t\t\t\t\tif(ss=='') return;\r\n\t\t\t\t\tvar ss_1=ss.split(t+t);\r\n\r\n\t\t\t\t\tvar ss_num=ss_1.slice(num,num+1);\r\n\t\t\t\t\tvar ss_2=ss_num[0].split(t);\r\n\r\n\t\t\t\t\t\$('#S{$f}').val(ss_2[0]);\r\n\t\t\t\t\t\$('#A{$f}')\r\n\t\t\t\t\t\t.val(ss_2[1])\r\n\t\t\t\t\t\t.width(250);\r\n\r\n\t\t\t\t\t\$('#B{$f}')\r\n\t\t\t\t\t\t.val('" . $king->lang->get('system/common/up') . "')\r\n\t\t\t\t\t\t.unbind('click')\r\n\t\t\t\t\t\t.click(function(){U{$f}(num)});\r\n\t\t\t\t\tif(!\$('#B{$f}').next('input').length){\r\n\t\t\t\t\t\t\$('#B{$f}').after('<input type=\"button\" value=\"" . $king->lang->get('system/common/cancel') . "\" onClick=\"C{$f}()\"/>');\r\n\t\t\t\t\t}\r\n\t\t\t\t}\r\n\t\t\t\t//提交编辑结果\r\n\t\t\t\tfunction U{$f}(num){\r\n\t\t\t\t\tvar t=String.fromCharCode(9);\r\n\t\t\t\t\tvar ss=\$('#{$f}').val();\r\n\r\n\t\t\t\t\tvar S=\$('#S{$f}').val().replace(t,'');\r\n\t\t\t\t\tvar A=\$('#A{$f}').val().replace(t,'');\r\n\r\n\t\t\t\t\t//判断是否填写图片地址\r\n\t\t\t\t\tif(S=='' || S=='{$src}'){\r\n\t\t\t\t\t\talert('" . $king->lang->get('portal/error/notimgsrc') . "');\r\n\t\t\t\t\t\treturn;\r\n\t\t\t\t\t}\r\n\r\n\t\t\t\t\tvar ss_1=ss.split(t+t);\r\n\t\t\t\t\tss_1.splice(num,1,S+t+A);\r\n\r\n\t\t\t\t\t\$('#{$f}').val(ss_1.join(t+t));\r\n\r\n\t\t\t\t\t\$('#S{$f}').val('');\r\n\t\t\t\t\t\$('#A{$f}').val('')\r\n\t\t\t\t\t\t.width(300);\r\n\r\n\t\t\t\t\t\$('#B{$f}').val('" . $king->lang->get('system/common/add') . "')\r\n\t\t\t\t\t\t.unbind('click')\r\n\t\t\t\t\t\t.click(function(){F{$f}()})\r\n\t\t\t\t\t\t.next('input').remove();\r\n\r\n\t\t\t\t\tS{$f}();\r\n\r\n\t\t\t\t}\r\n\t\t\t\t//取消按钮\r\n\t\t\t\tfunction C{$f}(){\r\n\r\n\t\t\t\t\t\$('#S{$f}').val('');\r\n\t\t\t\t\t\$('#A{$f}').val('')\r\n\t\t\t\t\t\t.width(300);\r\n\r\n\t\t\t\t\t\$('#B{$f}').val('" . $king->lang->get('system/common/add') . "')\r\n\t\t\t\t\t\t.unbind('click')\r\n\t\t\t\t\t\t.click(function(){F{$f}()})\r\n\t\t\t\t\t\t.next('input').remove();\r\n\r\n\t\t\t\t}\r\n\t\t\t\tS{$f}();\r\n\t\t\t\t\$('#B{$f}').click(function(){F{$f}()});\r\n\t\t\t\t</script>"; $h = kc_f_brow("S{$f}", $king->config('uppath') . '/image/', 0, 1, "F{$f}()"); $h .= $this->help($rs['kid'], $rs['khelp']); break; case 10: //文件上传(文件类型) $c[] = array($f, 0, $rs['nsizemin'], $rs['nsizemax']); $s = '<input type="text" name="' . $f . '" id="' . $f . '" value="' . htmlspecialchars($data[$f]) . '" class="k_in" style="width:' . $rs['nstylewidth'] . 'px;" maxlength="' . $rs['nsizemax'] . '" />'; $h = kc_f_brow($f, $king->config('uppath') . '/file/', 1) . $this->help($rs['kid'], $rs['khelp']) . kc_htm_setvalue_nl($f, $rs['koption']); break; case 11: //文件列表 $c[] = array($f, 0, $rs['nsizemin'], $rs['nsizemax']); $s = kc_htm_hidden(array($f => $data[$f])); $src = $king->lang->get('portal/label/filesrc'); $alt = $king->lang->get('portal/label/filealt'); $s .= kc_htm_input("S{$f}", $src, 400, 400, " onClick=\"\$(this).val(this.value=='{$src}'?'':this.value)\"") . "<br/>"; $s .= kc_htm_input("A{$f}", $alt, 400, 300, " onClick=\"\$(this).val(this.value=='{$alt}'?'':this.value)\""); $s .= " <input type=\"button\" value=\"" . $king->lang->get('system/common/add') . "\" id=\"B{$f}\" />"; $s .= "<div id=\"W{$f}\" class=\"filelist\" style=\"width:{$rs['nstylewidth']}px\"></div>"; $s .= "<script>\r\n\t\t\t\t//点击“添加”按钮的时候的效果\r\n\t\t\t\tfunction F{$f}(){\r\n\t\t\t\t\tvar t=String.fromCharCode(9);\r\n\t\t\t\t\tvar S=\$('#S{$f}').val().replace(t,'');\r\n\t\t\t\t\tvar A=\$('#A{$f}').val().replace(t,'');\r\n\t\t\t\t\t//判断是否填写文件地址\r\n\t\t\t\t\tif(S=='' || S=='{$src}'){\r\n\t\t\t\t\t\talert('" . $king->lang->get('portal/error/notimgsrc') . "');\r\n\t\t\t\t\t\treturn;\r\n\t\t\t\t\t}\r\n\r\n\t\t\t\t\tif(A=='' || A=='{$alt}') A=S;\r\n\t\t\t\t\tvar s=S+t+A;\r\n\t\t\t\t\tvar ss=\$('#{$f}').val();\r\n\t\t\t\t\t//如果S为空,则提示错误\r\n\t\t\t\t\tif(ss==''){\r\n\t\t\t\t\t\t\$('#{$f}').val(s);\r\n\t\t\t\t\t}else{\r\n\t\t\t\t\t\t//判断文件是否已经存在\r\n\t\t\t\t\t\tvar ss_1=ss.split(t+t);\r\n\t\t\t\t\t\tvar ss_2,src;\r\n\t\t\t\t\t\tfor(i=0;i<ss_1.length;i++){\r\n\t\t\t\t\t\t\tss_2=ss_1[i].split(t);\r\n\t\t\t\t\t\t\tsrc=ss_2[0];\r\n\t\t\t\t\t\t\tif(src==S){\r\n\t\t\t\t\t\t\t\talert('" . $king->lang->get('portal/error/retfilesrc') . "');\r\n\t\t\t\t\t\t\t\t\$('#S{$f}').val('');\r\n\t\t\t\t\t\t\t\treturn;\r\n\t\t\t\t\t\t\t}\r\n\t\t\t\t\t\t}\r\n\t\t\t\t\t\t\$('#{$f}').val(ss+t+t+s);\r\n\t\t\t\t\t}\r\n\t\t\t\t\t\$('#S{$f}').val('');\r\n\t\t\t\t\t\$('#A{$f}').val('');\r\n\t\t\t\t\tS{$f}();\r\n\t\t\t\t}\r\n\t\t\t\t//显示数据\r\n\t\t\t\tfunction S{$f}(){\r\n\t\t\t\t\tvar t=String.fromCharCode(9);\r\n\t\t\t\t\tvar ss=\$('#{$f}').val();\r\n\t\t\t\t\tif(ss==''){\r\n\t\t\t\t\t\t\$('#W{$f}').html('');\r\n\t\t\t\t\t\treturn;\r\n\t\t\t\t\t}\r\n\t\t\t\t\tvar s='';\r\n\t\t\t\t\tvar ss_1=ss.split(t+t);\r\n\t\t\t\t\tvar ss_2,alt,src;\r\n\t\t\t\t\tfor(i=0;i<ss_1.length;i++){\r\n\t\t\t\t\t\tss_2=ss_1[i].split(t);\r\n\t\t\t\t\t\tsrc=ss_2[0];\r\n\t\t\t\t\t\talt=ss_2[1];\r\n\r\n\t\t\t\t\t\ts+='<span class=\"file\" title=\"'+alt+'\">';\r\n\r\n\t\t\t\t\t\ts+='<a href=\"javascript:;\" class=\"icon\" onClick=\"D{$f}('+i+')\" title=\"" . $king->lang->get('system/common/del') . "\">';\r\n\t\t\t\t\t\ts+=\$.kc_icon('j2','" . $king->lang->get('system/common/del') . "')+'</a>';\r\n\r\n\t\t\t\t\t\ts+='<a href=\"javascript:;\" onClick=\"E{$f}('+i+')\" class=\"title\" title=\"" . $king->lang->get('system/common/edit') . "\">';\r\n\t\t\t\t\t\ts+=alt;\r\n\t\t\t\t\t\t//s+='<img class=\"file\" src=\"'+(ss_2[0].match(/^[a-zA-Z]{3,10}:\\/\\/[^\\s]+\$/) ? ss_2[0] : '../'+ss_2[0])+'\"/>';\r\n\t\t\t\t\t\ts+='</a>';\r\n\r\n\t\t\t\t\t\ts+='<a title=\"" . $king->lang->get('system/common/down') . "\" class=\"src\" href=\"'+(ss_2[0].match(/^[a-zA-Z]{3,10}:\\/\\/[^\\s]+\$/) ? ss_2[0] : '../'+ss_2[0])+'\">';\r\n\t\t\t\t\t\ts+=\$.kc_icon('e3','" . $king->lang->get('system/common/down') . "');\r\n\t\t\t\t\t\ts+=src+'</a>';\r\n\t\t\t\t\t\ts+='</span>';\r\n\t\t\t\t\t}\r\n\r\n\t\t\t\t\t\$('#W{$f}').html(s);\r\n\t\t\t\t}\r\n\t\t\t\t//删除文件\r\n\t\t\t\tfunction D{$f}(num){\r\n\t\t\t\t\tvar t=String.fromCharCode(9);\r\n\t\t\t\t\tvar ss=\$('#{$f}').val();\r\n\t\t\t\t\tif(ss==''){\r\n\t\t\t\t\t\t\$('#W{$f}').html('');\r\n\t\t\t\t\t\treturn;\r\n\t\t\t\t\t}\r\n\t\t\t\t\tvar ss_1=ss.split(t+t);\r\n\t\t\t\t\t\r\n\t\t\t\t\tss_1.splice(num,1);\r\n\r\n\t\t\t\t\t\$('#{$f}').val(ss_1.join(t+t));\r\n\r\n\t\t\t\t\tS{$f}();\r\n\t\t\t\t\t\r\n\t\t\t\t}\r\n\t\t\t\t//编辑图片\r\n\t\t\t\tfunction E{$f}(num){\r\n\t\t\t\t\tvar t=String.fromCharCode(9);\r\n\t\t\t\t\tvar ss=\$('#{$f}').val();\r\n\t\t\t\t\tif(ss=='') return;\r\n\t\t\t\t\tvar ss_1=ss.split(t+t);\r\n\r\n\t\t\t\t\tvar ss_num=ss_1.slice(num,num+1);\r\n\t\t\t\t\tvar ss_2=ss_num[0].split(t);\r\n\r\n\t\t\t\t\t\$('#S{$f}').val(ss_2[0]);\r\n\t\t\t\t\t\$('#A{$f}')\r\n\t\t\t\t\t\t.val(ss_2[1])\r\n\t\t\t\t\t\t.width(250);\r\n\r\n\t\t\t\t\t\$('#B{$f}')\r\n\t\t\t\t\t\t.val('" . $king->lang->get('system/common/up') . "')\r\n\t\t\t\t\t\t.unbind('click')\r\n\t\t\t\t\t\t.click(function(){U{$f}(num)});\r\n\t\t\t\t\tif(!\$('#B{$f}').next('input').length){\r\n\t\t\t\t\t\t\$('#B{$f}').after('<input type=\"button\" value=\"" . $king->lang->get('system/common/cancel') . "\" onClick=\"C{$f}()\"/>');\r\n\t\t\t\t\t}\r\n\t\t\t\t}\r\n\t\t\t\t//提交编辑结果\r\n\t\t\t\tfunction U{$f}(num){\r\n\t\t\t\t\tvar t=String.fromCharCode(9);\r\n\t\t\t\t\tvar ss=\$('#{$f}').val();\r\n\r\n\t\t\t\t\tvar S=\$('#S{$f}').val().replace(t,'');\r\n\t\t\t\t\tvar A=\$('#A{$f}').val().replace(t,'');\r\n\r\n\t\t\t\t\t//判断是否填写图片地址\r\n\t\t\t\t\tif(S=='' || S=='{$src}'){\r\n\t\t\t\t\t\talert('" . $king->lang->get('portal/error/notfilesrc') . "');\r\n\t\t\t\t\t\treturn;\r\n\t\t\t\t\t}\r\n\r\n\t\t\t\t\tvar ss_1=ss.split(t+t);\r\n\t\t\t\t\tss_1.splice(num,1,S+t+A);\r\n\r\n\t\t\t\t\t\$('#{$f}').val(ss_1.join(t+t));\r\n\r\n\t\t\t\t\t\$('#S{$f}').val('');\r\n\t\t\t\t\t\$('#A{$f}').val('')\r\n\t\t\t\t\t\t.width(300);\r\n\r\n\t\t\t\t\t\$('#B{$f}').val('" . $king->lang->get('system/common/add') . "')\r\n\t\t\t\t\t\t.unbind('click')\r\n\t\t\t\t\t\t.click(function(){F{$f}()})\r\n\t\t\t\t\t\t.next('input').remove();\r\n\r\n\t\t\t\t\tS{$f}();\r\n\r\n\t\t\t\t}\r\n\t\t\t\t//取消按钮\r\n\t\t\t\tfunction C{$f}(){\r\n\r\n\t\t\t\t\t\$('#S{$f}').val('');\r\n\t\t\t\t\t\$('#A{$f}').val('')\r\n\t\t\t\t\t\t.width(300);\r\n\r\n\t\t\t\t\t\$('#B{$f}').val('" . $king->lang->get('system/common/add') . "')\r\n\t\t\t\t\t\t.unbind('click')\r\n\t\t\t\t\t\t.click(function(){F{$f}()})\r\n\t\t\t\t\t\t.next('input').remove();\r\n\r\n\t\t\t\t}\r\n\t\t\t\tS{$f}();\r\n\t\t\t\t\$('#B{$f}').click(function(){F{$f}()});\r\n\t\t\t\t</script>"; /* $s='<input type="hidden" id="'.$f.'" name="'.$f.'" value="'.htmlspecialchars($data[$f]).'"/><br/>'; $s.='<input type="hidden" id="'.$f.'_temp" name="'.$f.'_temp"/>'; $s.='<table class="k_side" cellspacing="0"><tr><td id="k'.$f.'show" class="k_in filelist" style="width:'.$rs['nstylewidth'].'px;height:'.$rs['nstyleheight'].'px;">'; $s.='Loading...'; $s.='</td></tr></table>'; $h=kc_f_brow($f.'_temp',$king->config('uppath').'/file/',1,1,$jsfun='k'.$f.'show();'); $s.="<script>function k{$f}js(title,file,label){var s='<span class=\"file\" title=\"'+title+'\">"; $s.="<a class=\"img k_ajax\" href=\"javascript:;\" rel=\"{CMD:\'filetitle\',file:\''+file+'\',label:\''+label+'\',VAL:\''+label+','+label+'_temp,listid\',METHOD:\'GET\'}\">"; $s.="<img class=\"file\" src=\"../'+file+'\"/></a>"; $s.="<em class=\"title\">"; $s.="<a class=\"k_ajax\" href=\"javascript:;\" rel=\"{CMD:\'filesdel\',delfile:\''+file+'\',label:\''+label+'\',VAL:\''+label+','+label+'_temp,listid\',IS:1}\">"; $s.="'+\$.kc_icon('j2')+'</a>'+title+'</em></span>';return s;};"; $s.="function k{$f}show(){\$.kc_ajax('{URL:\'manage.content.php\',ID:\'k{$f}show\',CMD:\'filesload\',label:\'{$f}\',VAL:\'{$f}_temp,{$f},listid\'}')};k{$f}show();</script>"; */ $h = kc_f_brow("S{$f}", $king->config('uppath') . '/file/', 1, 1, "F{$f}()"); $h .= $this->help($rs['kid'], $rs['khelp']); break; case 12: //颜色框 $c[] = array($f, 0, 7, 7); $c[] = array($f, 13); // $s='<table class="k_side" cellspacing="0"><tr><td><input class="k_in k_color" type="text" id="'.$f.'" name="'.$f.'" value="'.htmlspecialchars($data[$f]).'" '.(kc_validate($data[$f],13)?' style="background:'.$data[$f].'"':'').' maxlength="7" /></td>'; // $s.='<td>'.kc_f_color($f).'</td></tr></table>'; $s = '<input class="k_in w50" type="text" id="' . $f . '" name="' . $f . '" value="' . htmlspecialchars($data[$f]) . '" ' . (kc_validate($data[$f], 13) ? ' style="background:' . $data[$f] . '"' : '') . ' maxlength="7" />'; $s .= kc_f_color($f); //"<a href=\"javascript:;\" class=\"k_color\" rel=\"{id:'{$f}'}\"><img src=\"../system/images/white.gif\" class=\"os a8\"/></a>"; break; case 13: //是/否 $c[] = array($f, 20, null, array('', 1)); $checked = $data[$f] ? ' checked="checked"' : ''; $s = '<input' . $checked . ' type="checkbox" id="' . $f . '" name="' . $f . '" value="1" />'; $s .= '<label for="' . $f . '">' . ($group ? $king->lang->get('system/common/selectyes') : htmlspecialchars($rs['ktitle'])) . '</label>'; break; case 14: //日期 // $c[]=array($f,9); $c[] = array($f, 0, $rs['nsizemin'], $rs['nsizemax']); if ($rs['nvalidate'] != 0) { $c[] = array($f, $rs['nvalidate']); } $date = $data[$f] == 'TODAY' ? kc_formatdate(time(), "Y-m-d") : $data[$f]; $s = kc_htm_input($f, $date, 30, 100); $s .= "<a href=\"javascript:;\" class=\"k_calendar\" rel=\"{id:'{$f}'}\"><img src=\"../system/images/white.gif\" class=\"os k9\"/></a>"; /* $h="<script>";//<script type=\"text/javascript\" src=\"../system/js/calendar.js\"></script> for($i=0;$i<7;$i++){ $h.="k_lang['week{$i}']='".$king->lang->get('system/time/week'.$i)."';"; } $h.="$.kc_calendar('{$f}')</script>"; */ break; case 99: $kid = $rs['kid']; $isshow = $is == 1 ? "isadmin{$at}" : "isuser{$at}"; if (!($res2 = $king->db->getRows("select * from %s_field where modelid={$info['modelid']} and {$isshow}=1 and kid1={$kid} order by norder,kid;"))) { //全部调用 return; } //若没有可见项,返回空值 $s = ''; $c2 = array(); $h2 = ''; //($s,$c,$h) foreach ($res2 as $rs2) { list($s2, $c2, $h2) = $this->formdecode($rs2, $data, $info, $is, $at, 2); $s .= '<span class="k_field">'; if ($rs2['istitle']) { $s .= '<label>' . addslashes($rs2['ktitle']) . '</label>'; } $s .= $s2 . '</span>'; $c = array_merge($c, $c2); $h .= $h2; } break; default: $s = $rs['ktitle'] . '=' . $rs['ntype']; } if ($group == 1) { if ($is == 1) { //后台调用 if ($rs['ntype'] == 0 && $f == 'nattrib' || $rs['ntype'] == 99) { //组输出,不需要标签 return $king->htmForm($rs['ktitle'], $s, $c, '', $h); } else { return $king->htmForm($rs['ktitle'], $s, $c, substr($f, 1), $h); } } else { return $king->htmForm($rs['ktitle'], $s, $c); } } else { //组调用 if ($is == 1) { return array($s, $c, $h); } else { return array($s, $c, ''); } } // return $htmlForm; }
function king_edt() { global $king; $_htmlcode = ''; $_arraycheck = array(); $_array_varchar = $king->portal->array_varchar; //varchar类型的字段 $king->access('portal_field_edt'); $_sql = 'ktitle,kfield,modelid,ntype,nvalidate,nsizemin,nsizemax,kdefault,koption,nstylewidth,nstyleheight,issearch,isadmin1,isadmin2,isuser1,isuser2,islist,khelp,isrelate,istitle'; $modelid = kc_get('modelid'); $kid = kc_get('kid', 2); $type = kc_get('type', 2); $kid1 = kc_get('kid1', 2); if ($type == '') { $type = 1; } $at_array = array(1, 4, 5, 7, 12, 13, 14); //允许添加的子字段 //ntype参数验证 if ($kid1 && !in_array($type, $at_array) || !in_array($type, $king->portal->ntype)) { kc_error($king->lang->get('system/error/param') . kc_clew(__FILE__, __LINE__)); } $fields = explode(',', $_sql); if ($GLOBALS['ismethod'] || $kid == '') { //POST过程或新添加的过程 $data = $_POST; if (!$GLOBALS['ismethod']) { //初始化新添加的数据 if (in_array($type, $_array_varchar)) { $data['nsizemin'] = 1; $data['nsizemax'] = 255; } else { $data['nsizemin'] = 1; $data['nsizemax'] = 999999; } $data['nstylewidth'] = 400; $data['nstyleheight'] = 70; $data['isadmin1'] = 1; $data['isadmin2'] = 1; $data['isuser1'] = 1; $data['isuser2'] = 1; $data['istitle'] = 1; if ($type == 12) { $data['nvalidate'] = 13; $data['kdefault'] = '#000000'; $data['nsizemax'] = 7; } if ($type == 14) { $data['nstylewidth'] = 100; $data['nsizemax'] = 10; $data['kdefault'] = 'TODAY'; $data['nvalidate'] = 9; //数据类型设置为日期类型 $data['nsizemin'] = 10; $data['nsizemax'] = 10; } } else { if ($kid != '') { $_res = $king->db->getRows_one('select ntype from %s_field where kid=' . $kid); //上面kc_get('kid')中有数据类型验证,无安全隐患 $_res ? $type = $_res['ntype'] : kc_error($king->lang->get('system/error/not')); } } } else { //编辑数据,从数据库读出 if ($data = $king->db->getRows_one('select ' . $_sql . ' from %s_field where kid=' . $kid . ' limit 1;')) { $type = $data['ntype']; $modelid = $data['modelid']; } else { kc_error($king->lang->get('system/error/param') . '<br/>select ' . $_sql . ' from %s_field where kid=' . $kid . ' limit 1;<br/>File:' . basename(__FILE__) . ';Line:' . __LINE__); } } $data = kc_data($fields, $data); $model = $king->portal->infoModel($modelid); $s = '<script type="text/javascript">'; $s .= 'function jumpmenu(obj){eval("parent.location=\'manage.field.php?action=edt&modelid=' . $modelid . '&kid1=' . $kid1 . '&type="+obj.options[obj.selectedIndex].value+"\'");}'; $s .= '</script>'; $s .= $king->openForm('manage.field.php?action=edt'); //字段类型 $_array = array(array('ntype', 2)); if ($kid) { $s .= $king->htmForm($king->lang->get('portal/list/ntype'), kc_htm_select('type', array($type => $king->lang->get('portal/type/n' . $type)), '', ' disabled="true"'), $_array); } else { $_array_select = array(); $array_type = $kid1 ? $at_array : $king->portal->ntype; foreach ($array_type as $val) { $_array_select[$val] = $king->lang->get('portal/type/n' . $val); } $s .= $king->htmForm($king->lang->get('portal/list/ntype'), kc_htm_select('type', $_array_select, $type, ' onChange="jumpmenu(this);"'), $_array); } //子项目中是否显示标题 if ($kid1 && $type != 13) { $checked = $data['istitle'] == 1 ? ' checked="checked"' : ''; $s_istitle = $kid1 ? '<input' . $checked . ' type="checkbox" id="istitle" name="istitle" value="1"/><label for="istitle">' . $king->lang->get('portal/label/showtitle') . '</label>' : ''; } else { $s_istitle = ''; } //字段标题 $_array = array(array('ktitle', 0, 2, 50)); $s .= $king->htmForm($king->lang->get('portal/list/ktitle') . ' (2-50)', '<input class="k_in w200" type="text" name="ktitle" value="' . htmlspecialchars($data['ktitle']) . '" maxlength="50" />' . $s_istitle, $_array); if ($type != 99) { //字段名 if ($kid) { //update $s .= $king->htmForm($king->lang->get('portal/list/kfield'), '<input class="k_in w200" type="text" disabled="true" value="' . htmlspecialchars($data['kfield']) . '" />'); $s .= kc_htm_hidden(array('kfield' => $data['kfield'])); } else { $_array = array(array('kfield', 0, 1, 50), array('kfield', 4), array('kfield', 12, $king->lang->get('system/check/none'), $king->db->getRows_one("select kid from %s_field where kfield='k_" . $king->db->escape(kc_post('kfield')) . "' and modelid={$modelid};"))); $s .= $king->htmForm($king->lang->get('portal/list/kfield') . ' (1-50)', '<input class="k_in w200" type="text" name="kfield" value="' . htmlspecialchars($data['kfield']) . '" maxlength="50" />', $_array); } //数据类型 if (in_array($type, array(1, 14))) { $array = array(0, 1, 2, 22, 3, 4, 5, 6, 7, 8, 9, 13); $_array_select = array(); foreach ($array as $val) { $_array_select += array($val => $king->lang->get('portal/validate/n' . $val)); } $s .= $king->htmForm($king->lang->get('portal/list/nvalidate'), kc_htm_select('nvalidate', $_array_select, $data['nvalidate']), array(array('nvalidate', 2))); } //长度 if (!in_array($type, array(0, 4, 5, 6, 7, 12, 13)) || $data['kfield'] == 'kcontent') { //系统标签和颜色值无需设置长度 $_size = '<input class="k_in w50" type="text" name="nsizemin" id="nsizemin" value="' . htmlspecialchars($data['nsizemin']) . '" maxlength="6" />'; $_size .= ' - <input class="k_in w100" type="text" name="nsizemax" id="nsizemax" value="' . htmlspecialchars($data['nsizemax']) . '" maxlength="11" />'; $_array = array(array('nsizemin', 2), array('nsizemax', 2), array('nsizemin', 0, 1, 6), array('nsizemax', 0, 1, 11)); if (in_array($type, $_array_varchar)) { $_lang = 'nsize'; $_array[] = array('nsizemin', 16, $king->lang->get('portal/check/nsize1'), 0, 255); $_array[] = array('nsizemax', 16, $king->lang->get('portal/check/nsize2'), 1, 255); } else { $_lang = 'nsizetext'; } $s .= $king->htmForm($king->lang->get('portal/label/' . $_lang), $_size, $_array); } else { $s .= kc_htm_hidden(array('nsizemin' => $data['nsizemin'], 'nsizemax' => $data['nsizemax'])); } //默认值 if (in_array($type, array(1, 4, 5, 6, 7, 8, 10))) { $_array = array(array('kdefault', 0, 0, 255)); $str = '<input class="k_in w400" type="text" id="kdefault" name="kdefault" value="' . htmlspecialchars($data['kdefault']) . '" maxlength="255" />'; /**/ if (in_array($type, array(8))) { $str .= kc_f_brow('kdefault', $king->config('uppath') . '/image', 0); } if (in_array($type, array(10))) { $str .= kc_f_brow('kdefault', $king->config('uppath') . '/file', 1); } /**/ $s .= $king->htmForm($king->lang->get('portal/label/kdefault') . ' (0-255)', $str, $_array); } elseif (in_array($type, array(12))) { //颜色 $_array = array(array('kdefault', 0, 7, 7), array('kdefault', 13)); $str = '<input class="k_in k_color" type="text" id="kdefault" name="kdefault" value="' . htmlspecialchars($data['kdefault']) . '" maxlength="7" ' . (kc_validate($data['kdefault'], 13) ? ' style="background:' . $data['kdefault'] . '"' : '') . '/>'; $s .= $king->htmForm($king->lang->get('portal/label/kdefault'), $str, $_array, null, kc_f_color('kdefault')); } elseif (in_array($type, array(14))) { $array = array('TODAY' => $king->lang->get('system/time/today')); $_array = array(array('kdefault', 0, 0, 20)); $s .= $king->htmForm($king->lang->get('portal/label/kdefault'), kc_htm_input('kdefault', $data['kdefault']), $_array, 0, kc_htm_setvalue('kdefault', $array)); } elseif (in_array($type, array(13))) { $array = array(1 => $king->lang->get('system/common/yes'), 0 => $king->lang->get('system/common/no')); $s .= $king->htmForm($king->lang->get('portal/label/kdefault'), kc_htm_radio('kdefault', $array, $data['kdefault'])); } else { $s .= kc_htm_hidden(array('kdefault' => '')); } } //end if($type==99) //选项 if (in_array($type, array(4, 5, 6, 7))) { $array = array(array('koption', 0, 1, 999999)); $_default = '<table class="k_side" cellspacing="0"><tr><td><textarea name="koption" class="k_in w400" cols="130" rows="7">' . htmlspecialchars($data['koption']) . '</textarea></td>'; $_default .= '<td>' . kc_help('portal/help/koption', 360, 310); $_default .= '</td></tr></table>'; $s .= $king->htmForm($king->lang->get('portal/label/koption'), $_default, $array); } elseif (in_array($type, array(1, 8, 10)) || in_array($data['kfield'], array('nprice', 'nnumber', 'nweight'))) { $array = array(array('koption', 0, 0, 999999)); $_default = '<table class="k_side" cellspacing="0"><tr><td><textarea name="koption" class="k_in w400" cols="130" rows="7">' . htmlspecialchars($data['koption']) . '</textarea></td>'; $_default .= '<td>' . kc_help('portal/help/kdefault', 360, 260); $_default .= '</td></tr></table>'; $s .= $king->htmForm($king->lang->get('portal/label/kdefault1'), $_default, $array); } else { $s .= kc_htm_hidden(array('koption' => '')); } //尺寸 if (in_array($type, array(2, 3, 6, 9, 11)) || $data['kfield'] == 'kcontent') { //长X宽 $_size = '<input class="k_in w50" type="text" name="nstylewidth" id="nstylewidth" value="' . htmlspecialchars($data['nstylewidth']) . '" maxlength="4" />'; $_size .= ' X <input class="k_in w50" type="text" name="nstyleheight" id="nstyleheight" value="' . htmlspecialchars($data['nstyleheight']) . '" maxlength="4" />(px)'; $_array = array(array('nstylewidth', 2), array('nstyleheight', 2), array('nstylewidth', 0, 1, 4), array('nstyleheight', 0, 1, 4)); $s .= $king->htmForm($king->lang->get('portal/label/nstyle'), $_size, $_array); } elseif (in_array($type, array(1, 8, 10))) { //长 $_size = '<input class="k_in w50" type="text" name="nstylewidth" id="nstylewidth" value="' . htmlspecialchars($data['nstylewidth']) . '" maxlength="4" />'; $_array = array(array('nstylewidth', 2), array('nstyleheight', 2), array('nstylewidth', 0, 1, 4), array('nstyleheight', 0, 1, 4)); $s .= kc_htm_hidden(array('nstyleheight' => 0)); $s .= $king->htmForm($king->lang->get('portal/label/nstylewidth'), $_size, $_array, '', kc_htm_setvalue('nstylewidth', array(50 => '50 px', 100 => '100 px', 200 => '200 px', 400 => '400 px'))); } else { $s .= kc_htm_hidden(array('nstylewidth' => 0, 'nstyleheight' => 0)); } /** //上传文件类型 if(in_array($type,array(8))){ $_array=array( array('nupfile',0,0,255), array('nupfile',2), ); $s.=$king->htmForm($king->lang->get('portal/label/nupfile'),'<input class="k_in w300" type="text" name="nupfile" value="'.htmlspecialchars($data['nupfile']).'" maxlength="255" />',$_array); }else{ $s.=kc_htm_hidden(array('nupfile'=>'')); } /**/ $_htmlcode = ''; //加入搜索和关联选项 if (in_array($type, array(1, 2))) { $data['issearch'] == 1 ? $_checked = ' checked="checked"' : ($_checked = ''); $_htmlcode = '<span><input type="checkbox" value="1" id="issearch" name="issearch"' . $_checked . '/>'; $_htmlcode .= '<label for="issearch">' . $king->lang->get('portal/label/attrib/issearch') . '</label></span>'; // $s.=$king->htmForm($king->lang->get('system/common/option'),$_htmlcode); } else { $s .= kc_htm_hidden(array('issearch' => 0)); } if (in_array($type, array(1, 4, 5))) { $data['isrelate'] == 1 ? $_checked = ' checked="checked"' : ($_checked = ''); $_htmlcode .= ' <span><input type="checkbox" value="1" id="isrelate" name="isrelate"' . $_checked . '/>'; $_htmlcode .= '<label for="isrelate">' . $king->lang->get('portal/label/attrib/isrelate1') . '</label></span>'; // $s.=$king->htmForm($king->lang->get('system/common/option'),$_htmlcode); } else { $s .= kc_htm_hidden(array('issearch' => 0)); } if ($_htmlcode) { $s .= $king->htmForm($king->lang->get('system/common/option'), $_htmlcode); } //是否显示 if ($type == 0 && $data['kfield'] == 'ktitle' || $type == 99) { $s .= kc_htm_hidden(array('isadmin1' => 1, 'isadmin2' => 1, 'isuser1' => 1, 'isuser2' => 1)); } else { $_htmlcode = '<span>'; $data['isadmin1'] == 1 ? $_checked = ' checked="checked"' : ($_checked = ''); $_htmlcode .= '<input type="checkbox" value="1" id="isadmin1" name="isadmin1"' . $_checked . '/>'; $_htmlcode .= '<label for="isadmin1">' . $king->lang->get('portal/label/attrib/isadmin1') . '</label>'; $data['isadmin2'] == 1 ? $_checked = ' checked="checked"' : ($_checked = ''); $_htmlcode .= '<input type="checkbox" value="1" id="isadmin2" name="isadmin2"' . $_checked . '/>'; $_htmlcode .= '<label for="isadmin2">' . $king->lang->get('portal/label/attrib/isadmin2') . '</label>'; $data['isuser1'] == 1 ? $_checked = ' checked="checked"' : ($_checked = ''); $_htmlcode .= '<input type="checkbox" value="1" id="isuser1" name="isuser1"' . $_checked . '/>'; $_htmlcode .= '<label for="isuser1">' . $king->lang->get('portal/label/attrib/isuser1') . '</label>'; $data['isuser2'] == 1 ? $_checked = ' checked="checked"' : ($_checked = ''); $_htmlcode .= '<input type="checkbox" value="1" id="isuser2" name="isuser2"' . $_checked . '/>'; $_htmlcode .= '<label for="isuser2">' . $king->lang->get('portal/label/attrib/isuser2') . '</label>'; if (!in_array($type, array(0, 2, 3, 9, 11))) { $data['islist'] == 1 ? $_checked = ' checked="checked"' : ($_checked = ''); $_htmlcode .= '<input type="checkbox" value="1" id="islist" name="islist"' . $_checked . '/>'; $_htmlcode .= '<label for="islist">' . $king->lang->get('portal/label/attrib/islist') . '</label>'; } $_htmlcode .= '</span>'; $s .= $king->htmForm($king->lang->get('portal/label/attrib/isshow'), $_htmlcode); } //khelp if ($type != 0 && !$kid1) { $s .= $king->htmForm($king->lang->get('portal/list/khelp'), '<table class="k_side" cellspacing="0"><tr><td><textarea class="k_in w400" rows="5" name="khelp" >' . htmlspecialchars($data['khelp']) . '</textarea></td><td>' . kc_help('portal/help/khelp', 300, 160) . '</td></tr></table>'); } $s .= kc_htm_hidden(array('modelid' => $modelid, 'kid' => $kid, 'ntype' => $type, 'kid1' => $kid1)); $s .= $king->closeForm('save'); //数据处理 if ($GLOBALS['ischeck']) { $_sql = 'ktitle,nsizemin,nsizemax,kdefault,koption,nstylewidth,nstyleheight,khelp'; $_array = array(); $_array_sql = explode(',', $_sql); foreach ($_array_sql as $val) { if (isset($_POST[$val])) { $_array[$val] = $data[$val]; } } $array_is = array('issearch', 'isadmin1', 'isadmin2', 'isuser1', 'isuser2', 'islist', 'isrelate', 'istitle'); foreach ($array_is as $val) { $_array[$val] = $data[$val] == 1 ? 1 : 0; } $_array['nvalidate'] = $data['nvalidate'] ? $data['nvalidate'] : 0; //添加&更新数据 if ($kid) { //update if (!($resmt = $king->db->getRows_one("select modeltable from %s_model where modelid={$modelid};"))) { kc_error($king->lang->get('system/error/param') . '<br/>File:' . basename(__FILE__) . ';Line:' . __LINE__); } $_modeltable = $resmt['modeltable']; if (in_array($type, $_array_varchar)) { //varchar类型 $king->db->query('alter table %s__' . $king->db->escape($_modeltable) . ' modify ' . $king->db->escape(kc_post('kfield')) . ' varchar(' . $_array['nsizemax'] . ') null;'); } $king->db->update('%s_field', $_array, 'kid=' . $kid); $_nlog = 7; } else { $_array += array('ktitle' => $data['ktitle'], 'kfield' => $data['kfield'] ? 'k_' . $data['kfield'] : '', 'modelid' => $data['modelid'], 'ntype' => $data['ntype'], 'norder' => $king->db->neworder('%s_field', 'modelid=' . $modelid), 'khelp' => $data['khelp'], 'kid1' => $kid1 ? $kid1 : 0); if (in_array($data['ntype'], array('10,11'))) { //当文件上传字段的时候,才可以上传文件 $_array += array('ntype' => 1); } $king->db->insert('%s_field', $_array); $_nlog = 5; $res = $king->db->getRows_one("select modeltable from %s_model where modelid={$modelid};"); $_modeltable = $res['modeltable']; if (in_array($type, $_array_varchar)) { //varchar类型 $king->db->query('alter table %s__' . $king->db->escape($_modeltable) . ' add k_' . $king->db->escape($data['kfield']) . ' varchar(' . $_array['nsizemax'] . ') null;'); } elseif (in_array($type, array(13))) { //tinyint $king->db->query('alter table %s__' . $king->db->escape($_modeltable) . ' add k_' . $king->db->escape($data['kfield']) . ' tinyint(1) not null default 0;'); } elseif ($type == 99) { //组选项不需要字段 } else { $king->db->query('alter table %s__' . $king->db->escape($_modeltable) . ' add k_' . $king->db->escape($data['kfield']) . ' text null;'); } } $king->cache->del('portal/model/model' . $modelid); $king->cache->rd('data/_' . $_modeltable); //写log $king->log($_nlog, 'Field:' . $data['ktitle']); kc_goto($king->lang->get('system/goto/is'), 'manage.field.php?action=edt&modelid=' . $modelid . '&kid1=' . $kid1, 'manage.field.php?modelid=' . $modelid . '&kid1=' . $kid1); } list($left, $right) = king_inc_list(); $king->skin->output($king->lang->get('portal/title/field' . ($kid ? 'edt' : 'add')) . "({$model['modelname']})", $left, $right, $s); }
function king_edt() { global $king; $king->access("portal_list_edt"); $array_static = array(3 => $king->lang->get('portal/static/t3'), 0 => $king->lang->get('portal/static/t0'), 1 => $king->lang->get('portal/static/t1'), 2 => $king->lang->get('portal/static/t2')); $listid = kc_get('listid', 2); $modelid = kc_get('modelid', 22); $modeltables = $king->portal->getModelTables(); $line = $king->config('pidline'); $_sql = 'modelid,listid1,siteid,klistname,ktitle,kkeywords,kdescription,kimage,isblank,iscontent,kcontent,klistpath,ktemplatelist1,ktemplatelist2,kpathmode,ktemplatepage1,ktemplatepage2,ispublish1,ispublish2,klanguage,ismenu1,ismenu2,ismenu3,ismenu4,ismenu5,ismap,nlistnumber,npagenumber,nlist,npage,gid,gidpublish'; if ($GLOBALS['ismethod'] || $listid == '') { //POST过程或新添加的过程 $data = $_POST; if (!$GLOBALS['ismethod']) { //初始化新添加的数据 $data['klanguage'] = $_COOKIE['language']; $data['siteid'] = 0; $data['ismap'] = 1; $data['ismenu1'] = 1; $data['ismenu2'] = 1; $data['listid1'] = 0; $newlistid = $king->db->neworder('%s_list', null, 'listid'); $data['gid'] = -1; $data['nlist'] = 1; $data['npage'] = 0; $tpath = $king->config('templatepath'); $tdefa = $king->config('templatedefault'); switch ($modelid) { case 0: $data['klistpath'] = "list{$line}{$newlistid}" . $king->config('rewriteend'); $data['iscontent'] = 1; $data['ismenu3'] = 1; //默认模板 $ktemplatelist1 = $tpath . '/' . $tdefa; $data['ktemplatelist1'] = is_file(ROOT . $ktemplatelist1) ? $ktemplatelist1 : ''; $ktemplatelist2 = $tpath . '/inside/onepage/' . $tdefa; $data['ktemplatelist2'] = is_file(ROOT . $ktemplatelist2) ? $ktemplatelist2 : ''; break; case -1: $data['klistpath'] = 'http://'; break; default: $data['kpathmode'] = "page{$line}{$newlistid}{$line}ID" . $king->config('rewriteend'); $data['klistpath'] = "list{$line}{$newlistid}{$line}PID" . $king->config('rewriteend'); $model = $king->portal->infoModel($modelid); $data['ispublish1'] = $model['ispublish1']; $data['ispublish2'] = $model['ispublish2']; $data['npagenumber'] = $model['npagenumber']; $data['nlistnumber'] = $model['nlistnumber']; //默认模板 $ktemplatelist1 = $tpath . '/' . $tdefa; $data['ktemplatelist1'] = is_file(ROOT . $ktemplatelist1) ? $ktemplatelist1 : ''; $data['ktemplatepage1'] = is_file(ROOT . $ktemplatelist1) ? $ktemplatelist1 : ''; $ktemplatelist2 = $tpath . '/inside/' . $model['modeltable'] . '[list]/' . $tdefa; $data['ktemplatelist2'] = is_file(ROOT . $ktemplatelist2) ? $ktemplatelist2 : ''; $ktemplatepage2 = $tpath . '/inside/' . $model['modeltable'] . '[page]/' . $tdefa; $data['ktemplatepage2'] = is_file(ROOT . $ktemplatepage2) ? $ktemplatepage2 : ''; } } } else { //编辑数据,从数据库读出 if (!($data = $king->db->getRows_one('select ' . $_sql . ' from %s_list where listid=' . $listid . ' limit 1;'))) { kc_error($king->lang->get('system/error/param') . '<br/>File:' . basename(__FILE__) . ';Line:' . __LINE__ . '<br/>' . $_sql); } if (isset($modelid[0])) { //当有URL形式指定的modelid的时候,比较一下,如果modelid值不同,则重新设置默认值 if ($modelid != $data['modelid']) { if (!isset($data['klanguage'][0])) { $data['klanguage'] = $_COOKIE['language']; } switch ($modelid) { case 0: //单页 $data['klistpath'] = "onepage/list{$line}{$listid}" . $king->config('rewriteend'); break; case -1: //超链 $data['klistpath'] = 'http://'; break; default: $data['klistpath'] = "list{$line}{$listid}{$line}PID" . $king->config('rewriteend'); if (!isset($data['kpathmode'][0])) { $data['kpathmode'] = "page{$line}{$listid}{$line}ID" . $king->config('rewriteend'); } } } } else { $modelid = $data['modelid']; } } $fields = explode(',', $_sql); $data = kc_data($fields, $data); //这个必须要放在下面,不然无法正常获取modelid值 $modeltable = isset($modeltables[$modelid]) ? $modeltables[$modelid] : ''; $s = $king->openForm('manage.php?action=edt', $king->lang->get('portal/caption/basic')); ////modelid 选择模型 if (!($res = $king->db->getRows("select modelid,modelname from %s_model"))) { $res = array(); } $_array_select = array(0 => $king->lang->get('portal/label/onepage'), -1 => $king->lang->get('portal/label/hyperlink')); foreach ($res as $rs) { $_array_select += array($rs['modelid'] => $rs['modelname']); } if ($listid) { //如果是编辑列表,则不让修改栏目类型 if (in_array($modelid, array(0, -1))) { //超链和单页允许修改类型 $s .= $king->htmForm($king->lang->get('portal/label/model'), kc_htm_select('modelid', $_array_select, $modelid, ' onChange="jumpmenu(this);"'), null, 'modelid'); } else { $s .= kc_htm_hidden(array('listid' => $listid)); $s .= $king->htmForm($king->lang->get('portal/label/model'), '<select><option>' . $_array_select[$modelid] . '</option></select>', null, 'modelid'); } } else { $s .= $king->htmForm($king->lang->get('portal/label/model'), kc_htm_select('modelid', $_array_select, $modelid, ' onChange="jumpmenu(this);"'), null, 'modelid', kc_help('portal/help/model', 320, 120)); } $s .= '<script type="text/javascript">'; $s .= 'function jumpmenu(obj){eval("parent.location=\'manage.php?action=edt&listid=' . $listid . '&modelid="+obj.options[obj.selectedIndex].value+"\'");}'; $s .= '</script>'; //listid1 $s .= $king->htmForm($king->lang->get('portal/label/listid1'), $king->portal->LinkAge('listid1', $data['listid1'], 0, $listid), null, 'Listid1'); //siteid if (!($res = $king->db->getRows("select siteid,sitename from %s_site;"))) { kc_error($king->lang->get('system/error/notre')); } $_array_select = array(); foreach ($res as $rs) { $_array_select += array($rs['siteid'] => htmlspecialchars($rs['sitename'])); } if ($modelid != -1) { if ($king->acc('portal_site_edt')) { $manage = '<a class="k_ajax" rel="{CMD:\'site\',is:1,METHOD:\'GET\'}">' . kc_icon('f7', $king->lang->get('portal/common/addsite')) . '</a>'; } $s .= $king->htmForm($king->lang->get('portal/label/siteid'), kc_htm_select('siteid', $_array_select, $data['siteid']) . $manage, null, 'Siteid', kc_help('portal/help/site', 320, 150)); } else { $s .= kc_htm_hidden(array('siteid' => $res[0]['siteid'])); } $s .= "<script>function addsite(siteid,sitename){var site=document.getElementsByName('siteid');var opt=document.createElement('option');opt.innerHTML=sitename;opt.value=siteid;opt.selected='selected';site[0].appendChild(opt);};</script>"; //klistname $_array = array(array('klistname', 0, 1, 100)); $s .= $king->htmForm($king->lang->get('portal/label/listname') . ' (1-100)', '<input class="k_in w300" type="text" name="klistname" value="' . htmlspecialchars($data['klistname']) . '" maxlength="100" />', $_array, 'ListName'); //ktitle $_array = array(array('ktitle', 0, 1, 100)); $s .= $king->htmForm($king->lang->get('portal/label/listtitle') . ' (1-100, ' . $king->lang->get('portal/label/listtitle1') . ')', '<input class="k_in w300" type="text" name="ktitle" value="' . htmlspecialchars($data['ktitle']) . '" maxlength="100" />', $_array, 'ListTitle'); //kkeywords $_array = array(array('kkeywords', 0, 0, 100)); $s .= $king->htmForm($king->lang->get('system/common/keywords') . ' (0-100)', '<input class="k_in w400" type="text" name="kkeywords" value="' . htmlspecialchars($data['kkeywords']) . '" maxlength="100" />', $_array, 'Keywords'); //kdescription $_array = array(array('kdescription', 0, 0, 255)); $s .= $king->htmForm($king->lang->get('system/common/description') . ' (0-255)', '<textarea rows="4" cols="100" class="k_in w400" name="kdescription" maxlength="255" >' . htmlspecialchars($data['kdescription']) . '</textarea>', $_array, 'Description'); //kimage if ($data['kimage']) { $_array = array(array('kimage', 0, 0, 255), array('kimage', 7)); } $s .= $king->htmForm($king->lang->get('system/common/image') . ' (0-255)', '<input class="k_in w400" type="text" id="kimage" name="kimage" value="' . htmlspecialchars($data['kimage']) . '" maxlength="255" />' . kc_f_brow('kimage', $king->config('uppath') . '/image', 0), $_array, 'Image'); //klanguage $s .= $king->htmForm($king->lang->get('system/common/language'), kc_htm_select('klanguage', kc_htm_selectlang(), $data['klanguage']), null, 'Language'); //gid if ($modelid > 0) { $king->Load('user'); $array_group = $king->user->getGroup(); $array_group[-1] = $king->lang->get('user/group/open'); $s .= $king->htmForm($king->lang->get('user/label/access'), kc_htm_select('gid', $array_group, $data['gid']), null, 'gid', kc_help('user/help/access')); } $s .= $king->splitForm($king->lang->get('portal/caption/list')); switch ($modelid) { case 0: //单页 //nlist $s .= $king->htmForm($king->lang->get('portal/label/onetype'), kc_htm_select('nlist', $array_static, $data['nlist'])); //klistpath $_array = array(array('klistpath', 0, 0, 255), array('klistpath', 15)); //判断(编辑/添加)状态 if ($listid) { //edt if (isset($data['klistpath'][0])) { array_push($_array, array('klistpath', 12, $king->lang->get('system/check/none'), $king->db->getRows_one("select listid from %s_list where klistpath='" . $king->db->escape($data['klistpath']) . "' and listid<>{$listid} and modelid<>1;"))); } else { //如果是空值,则比较同一siteid下面是否有两个 array_push($_array, array('klistpath', 12, $king->lang->get('system/check/none'), $king->db->getRows_one("select listid from %s_list where klistpath='' and siteid=" . $king->db->escape($data['siteid']) . " and modelid=0 and listid<>{$listid};"))); } } else { //add if (isset($data['klistpath'][0])) { array_push($_array, array('klistpath', 12, $king->lang->get('system/check/none'), $king->db->getRows_one("select listid from %s_list where klistpath='" . $king->db->escape($data['klistpath']) . "' and modelid<>1;"))); } else { array_push($_array, array('klistpath', 12, $king->lang->get('system/check/none'), $king->db->getRows_one("select listid from %s_list where klistpath='' and siteid=" . $king->db->escape($data['siteid']) . " and modelid=0;"))); } } if (in_array($modelid, array(0))) { //单页 $s .= $king->htmForm($king->lang->get('portal/label/path') . ' (0-255)', '<input class="k_in w400" type="text" name="klistpath" value="' . htmlspecialchars($data['klistpath']) . '" maxlength="255" />', $_array, 'Path', kc_help('portal/help/path', 320, 120)); //ktemplatelist1 if ($modelid == 0) { $_array = array(array('ktemplatelist1', 0, 5, 255), array('ktemplatelist1', 15)); } else { $_array = array(); } $s .= $king->htmForm($king->lang->get('portal/label/template1') . ' (5-255)', '<input class="k_in w400" type="text" id="ktemplatelist1" name="ktemplatelist1" value="' . htmlspecialchars($data['ktemplatelist1']) . '" maxlength="255" />' . kc_f_brow('ktemplatelist1', $king->config('templatepath'), 2), $_array, null, kc_help('portal/help/template', 455, 455)); //ktemplatelist2 $_array = array(array('ktemplatelist2', 0, 0, 255), array('ktemplatelist2', 15)); $s .= $king->htmForm($king->lang->get('portal/label/template2') . ' (0-255)', '<input class="k_in w400" type="text" id="ktemplatelist2" name="ktemplatelist2" value="' . htmlspecialchars($data['ktemplatelist2']) . '" maxlength="255" />' . kc_f_brow('ktemplatelist2', $king->config('templatepath') . '/inside/onepage', 2), $_array); } break; case -1: //超链 //klistpath + islink $_array = array(array('klistpath', 0, 1, 255)); $data['isblank'] == 1 ? $checked = ' checked="checked"' : ($checked = ''); $s .= $king->htmForm($king->lang->get('portal/label/linkpath') . ' (1-255)', '<input class="k_in w500" type="text" name="klistpath" value="' . htmlspecialchars($data['klistpath']) . '" maxlength="255" /><br/><span><input type="checkbox" name="isblank" id="isblank" value="1" ' . $checked . '/><label for="isblank">' . $king->lang->get('portal/label/isblank') . '</label></span>', $_array, 'ListPath'); break; default: //nlist if ($data['gid'] == -1) { $_array = array(); } else { $_array = array(array('nlist', 12, $king->lang->get('user/check/access'), $data['nlist'] == 0)); } $array_static_list = $array_static; $array_static_list[4] = $king->lang->get('portal/static/t4'); $s .= $king->htmForm($king->lang->get('portal/label/nlist'), kc_htm_select('nlist', $array_static_list, $data['nlist']), $_array); //klistpath $_array = array(array('klistpath', 0, 1, 255), array('klistpath', 15)); $s .= $king->htmForm($king->lang->get('portal/label/listpath') . ' (1-255)', '<input class="k_in w400" type="text" name="klistpath" value="' . htmlspecialchars($data['klistpath']) . '" maxlength="255" />', $_array, 'ListPath', kc_help('portal/help/listpath')); //ktemplatelist1 $_array = array(array('ktemplatelist1', 0, 5, 255), array('ktemplatelist1', 15)); $s .= $king->htmForm($king->lang->get('portal/label/templatelist1') . ' (5-255)', '<input class="k_in w400" type="text" name="ktemplatelist1" id="ktemplatelist1" value="' . htmlspecialchars($data['ktemplatelist1']) . '" maxlength="255" />', $_array, null, kc_f_brow('ktemplatelist1', $king->config('templatepath'), 2) . kc_help('portal/help/template', 455, 455)); //ktemplatelist2 $_array = array(array('ktemplatelist2', 0, 0, 255), array('ktemplatelist2', 15)); $s .= $king->htmForm($king->lang->get('portal/label/templatelist2') . ' (0-255)', '<input class="k_in w400" type="text" name="ktemplatelist2" id="ktemplatelist2" value="' . htmlspecialchars($data['ktemplatelist2']) . '" maxlength="255" />', $_array, null, kc_f_brow('ktemplatelist2', $king->config('templatepath') . '/inside/' . $modeltable . '[list]', 2)); //nlistnumber $_array = array(array('nlistnumber', 2), array('nlistnumber', 16, $king->lang->get('portal/error/listnumber'), 1, 100)); $s .= $king->htmForm($king->lang->get('portal/label/listnumber') . ' (≤100)', '<input class="k_in w50" type="text" name="nlistnumber" id="nlistnumber" value="' . htmlspecialchars($data['nlistnumber']) . '" maxlength="3" />', $_array); $s .= $king->splitForm($king->lang->get('portal/caption/page')); //npage if ($data['gid'] == -1) { $_array = array(); } else { $_array = array(array('npage', 12, $king->lang->get('user/check/access'), $data['npage'] == 0)); } $s .= $king->htmForm($king->lang->get('portal/label/npage'), kc_htm_select('npage', $array_static, $data['npage']), $_array); //kpathmode $_array = array(array('kpathmode', 0, 1, 100), array('kpathmode', 15)); $s .= $king->htmForm($king->lang->get('portal/label/pathmode') . ' (1-100)', '<input class="k_in w400" type="text" name="kpathmode" value="' . htmlspecialchars($data['kpathmode']) . '" maxlength="100" />', $_array, null, kc_help('portal/help/kpathmode', 300, 350)); //ktemplatepage1 $_array = array(array('ktemplatepage1', 0, 5, 255), array('ktemplatepage1', 15)); $s .= $king->htmForm($king->lang->get('portal/label/templatepage1') . ' (5-255)', '<input class="k_in w400" type="text" name="ktemplatepage1" id="ktemplatepage1" value="' . htmlspecialchars($data['ktemplatepage1']) . '" maxlength="255" />', $_array, null, kc_f_brow('ktemplatepage1', $king->config('templatepath'), 2) . kc_help('portal/help/template', 455, 455)); //ktemplatepage2 $_array = array(array('ktemplatepage2', 0, 0, 255), array('ktemplatepage2', 15)); $s .= $king->htmForm($king->lang->get('portal/label/templatepage2') . ' (0-255)', '<input class="k_in w400" type="text" name="ktemplatepage2" id="ktemplatepage2" value="' . htmlspecialchars($data['ktemplatepage2']) . '" maxlength="255" />', $_array, null, kc_f_brow('ktemplatepage2', $king->config('templatepath') . '/inside/' . $modeltable . '[page]', 2)); //npagenumber $_array = array(array('npagenumber', 2), array('npagenumber', 16, $king->lang->get('portal/error/listnumber'), 1, 100)); $s .= $king->htmForm($king->lang->get('portal/label/pagenumber') . ' (≤100)', '<input class="k_in w50" type="text" name="npagenumber" id="npagenumber" value="' . htmlspecialchars($data['npagenumber']) . '" maxlength="3" />', $_array, null, kc_help('portal/help/pagenumber', 300, 160)); } if ($modelid > 0) { $s .= $king->splitForm($king->lang->get('portal/caption/access')); //gidpublish $_array = array(array('gidpublish', 0, 1, 6), array('gidpublish', 22)); $s .= $king->htmForm($king->lang->get('user/label/publish'), kc_htm_select('gidpublish', $array_group, $data['gidpublish']), $_array, 'gidpublish'); //ispublish1 $_array_radio = array(0 => $king->lang->get('portal/label/pub0'), 1 => $king->lang->get('portal/label/pub1'), 2 => $king->lang->get('portal/label/pub2')); $s .= $king->htmForm($king->lang->get('portal/label/publish1'), kc_htm_radio('ispublish1', $_array_radio, $data['ispublish1'])); //ispublish2 $_array_radio = array(0 => $king->lang->get('portal/label/pub0'), 1 => $king->lang->get('portal/label/pub1'), 2 => $king->lang->get('portal/label/pub2')); $s .= $king->htmForm($king->lang->get('portal/label/publish2'), kc_htm_radio('ispublish2', $_array_radio, $data['ispublish2'])); } $s .= $king->splitForm($king->lang->get('portal/caption/other')); if ($modelid != -1) { //iscontent $data['iscontent'] == 1 ? $checked = ' checked="checked"' : ($checked = ''); $_checkbox = '<span><input type="checkbox" id="iscontent" name="iscontent" value="1" onclick="javascript:seiscontent()" ' . $checked . '/><label for="iscontent">' . $king->lang->get('portal/label/havecontent') . '</label><var><i onClick="window.clipboardData.setData(\'Text\',\'{king:content/}\');">{king:content/}</i></var></span>'; // $s.=$king->htmForm($_checkbox.$king->lang->get('system/common/content'),null,array(),'Content'); //kcontent if ($data['iscontent'] == 1) { $_array = array(array('kcontent', 0), array('kcontent', 21)); } else { $_array = array(); } $s .= $king->htmForm($king->lang->get('system/common/content'), $_checkbox . '<div id="iscontent1">' . kc_htm_editor('kcontent', $data['kcontent']) . '</div>', $_array); $s .= "<script>"; $s .= "function seiscontent(){var obj=\$('#iscontent');if(obj.attr('checked')==true){\$('#iscontent1').show();}else{\$('#iscontent1').hide()}};seiscontent();"; $s .= "</script>"; } //菜单设置 $_menu = '<span>'; for ($i = 1; $i <= 5; ++$i) { $data['ismenu' . $i] == 1 ? $checked = ' checked="checked"' : ($checked = ''); if ($i >= 3) { $_menu .= '<br/><a href="manage.php?action=menu' . $i . '" target="_blank">' . kc_icon('e7', $king->lang->get('portal/common/edtmenu')) . '</a>'; } $_menu .= '<input type="checkbox" name="ismenu' . $i . '" id="ismenu' . $i . '" value="1"' . $checked . '/><label for="ismenu' . $i . '">' . $king->lang->get('portal/label/menu' . $i) . '</label> '; } $_menu .= '</span>'; $_menu .= ''; $s .= $king->htmForm($king->lang->get('portal/label/setmenu'), $_menu); //地图显示设置 $data['ismap'] == 1 ? $checked = ' checked="checked"' : ($checked = ''); $s .= $king->htmForm($king->lang->get('portal/label/map'), '<span><input type="checkbox" name="ismap" id="ismap" value="1"' . $checked . '/><label for="ismap">' . $king->lang->get('portal/label/maps') . '</label></span>'); $s .= kc_htm_hidden(array('modelid' => $modelid, 'listid' => $listid)); $s .= $king->closeForm('save'); if ($GLOBALS['ischeck']) { $_array_sql = array('isblank', 'iscontent', 'ismap'); foreach ($_array_sql as $_value) { $data[$_value] = $data[$_value] ? 1 : 0; } for ($i = 1; $i <= 5; $i++) { $data['ismenu' . $i] = $data['ismenu' . $i] ? 1 : 0; } $_array = array('modelid' => $modelid ? $modelid : 0, 'listid1' => $data['listid1'], 'klistname' => $data['klistname'], 'ktitle' => $data['ktitle'], 'kkeywords' => $data['kkeywords'], 'kdescription' => $data['kdescription'], 'kimage' => $data['kimage'], 'ismenu1' => $data['ismenu1'], 'ismenu2' => $data['ismenu2'], 'ismenu3' => $data['ismenu3'], 'ismenu4' => $data['ismenu4'], 'ismenu5' => $data['ismenu5'], 'ismap' => $data['ismap'], 'siteid' => $data['siteid'], 'klanguage' => $data['klanguage'], 'klistpath' => $data['klistpath'], 'gid' => !empty($data['gid']) ? $data['gid'] : -1, 'gidpublish' => isset($data['gidpublish']) ? intval($data['gidpublish']) : -1); switch ($modelid) { case 0: //单页 $_array += array('ktemplatelist1' => $data['ktemplatelist1'], 'ktemplatelist2' => $data['ktemplatelist2'], 'iscontent' => $data['iscontent'], 'kcontent' => $data['kcontent'], 'nlist' => $data['nlist']); break; case -1: //超链 $_array['isblank'] = $data['isblank']; break; default: //自定义模型 $_array += array('iscontent' => $data['iscontent'], 'kcontent' => $data['kcontent'], 'nlistnumber' => $data['nlistnumber'], 'npagenumber' => $data['npagenumber'], 'klistpath' => $data['klistpath'], 'ktemplatelist1' => $data['ktemplatelist1'], 'ktemplatelist2' => $data['ktemplatelist2'], 'kpathmode' => $data['kpathmode'], 'ktemplatepage1' => $data['ktemplatepage1'], 'ktemplatepage2' => $data['ktemplatepage2'], 'ispublish1' => $data['ispublish1'], 'ispublish2' => $data['ispublish2'], 'nlist' => $data['nlist'], 'npage' => $data['npage']); } if ($listid) { //update // kc_error('<pre>'.print_r($_array,1)); $king->db->update('%s_list', $_array, 'listid=' . $listid); $nlog = 7; //更新列表信息 $king->portal->lastUpdated($listid); } else { $neworder = $king->db->neworder('%s_list'); $_array += array('norder' => $neworder, 'norder3' => $neworder, 'norder4' => $neworder, 'norder5' => $neworder); $listid = $king->db->insert('%s_list', $_array); // kc_error('<pre>'.print_r($_array,1)); $nlog = 5; } //删除缓存 $king->cache->del('portal/list/' . $listid); $king->cache->rd('portal/site'); if ($data['listid1']) { $king->cache->del('portal/list/' . $data['listid1']); } //单页的时候调用生成列表,列表的时候,加入到增量更新里 /**/ if ($modelid == 0) { $king->portal->createList($listid); } /**/ //写log $king->log($nlog, 'ListName:' . $data['klistname']); kc_goto($king->lang->get('system/goto/is'), 'manage.php?action=edt', 'manage.php'); } list($left, $right) = king_inc_list(); $king->skin->output($king->lang->get('portal/title/list' . ($listid ? 'edt' : 'add')), $left, $right, $s); }