/**
	编辑
*/
function king_ajax_edt()
{
    global $king;
    $king->access('portal_express_edt');
    $eid = kc_get('eid', 2);
    $sql = "kname,nsprice,niprice,kremark,kaddress";
    $array_sql = explode(',', $sql);
    if ($GLOBALS['ismethod'] || empty($eid)) {
        $data = $_POST;
        if (!$GLOBALS['ismethod']) {
            $data['kaddress'] = 'http://';
        }
    } else {
        if (!($data = $king->db->getRows_one("select {$sql} from %s_express where eid={$eid}"))) {
            kc_error($king->lang->get('system/error/notre'));
        }
    }
    $data = kc_data($array_sql, $data);
    //kname
    $array = array(array('kname', 0, 1, 50));
    $s = $king->htmForm($king->lang->get('portal/express/name'), kc_htm_input('kname', $data['kname'], 50, 200), $array);
    //nsprice
    $array = array(array('nsprice', 0, 1, 5), array('nsprice', 2));
    $s .= $king->htmForm($king->lang->get('portal/express/sprice'), kc_htm_input('nsprice', $data['nsprice'], 5, 50), $array);
    //nsprice
    $array = array(array('niprice', 0, 1, 5), array('niprice', 2));
    $s .= $king->htmForm($king->lang->get('portal/express/iprice'), kc_htm_input('niprice', $data['niprice'], 5, 50), $array);
    //kaddress
    $array = array(array('kaddress', 0, 1, 255), array('kaddress', 6));
    $s .= $king->htmForm($king->lang->get('portal/express/address'), kc_htm_input('kaddress', $data['kaddress'], 255, 400), $array);
    //kremark
    $array = array(array('kremark', 0, 0, 3000));
    $s .= $king->htmForm($king->lang->get('portal/common/remark'), '<textarea name="kremark" id="kremark" rows="6" cols="100" class="k_in w400">' . htmlspecialchars($data['kremark']) . '</textarea>', $array);
    if ($GLOBALS['ischeck']) {
        $array = array();
        foreach ($array_sql as $val) {
            $array[$val] = $data[$val];
        }
        if (empty($eid)) {
            //insert
            $king->db->insert('%s_express', $array);
        } else {
            $king->db->update('%s_express', $array, "eid={$eid}");
        }
        $js = 'setTimeout("parent.location=\'manage.express.php\'",1000)';
        kc_ajax('', '', '', $js);
    }
    $but = kc_htm_a($king->lang->get('system/common/save'), "{CMD:'edt',eid:'{$eid}',IS:1}");
    kc_ajax($king->lang->get('portal/title/expressedt'), $s, $but, '', 440, 350 + $GLOBALS['check_num'] * 15);
}
Beispiel #2
0
/**
	发货
*/
function king_ajax_express()
{
    global $king;
    $king->access('portal_orders_delivery');
    $oid = kc_get('oid', 2, 1);
    $sql = "eid,expressnumber,kremark,nsenddate";
    $array_sql = explode(',', $sql);
    if ($GLOBALS['ismethod']) {
        $data = $_POST;
    } else {
        if (!($data = $king->db->getRows_one("select {$sql} from %s_orders where oid={$oid}"))) {
            kc_error($king->lang->get('system/error/notre'));
        }
    }
    $data = kc_data($array_sql, $data);
    $s = '';
    //eid
    $express = $king->portal->getExpress();
    $array_express = array();
    foreach ($express as $eid => $rs) {
        $array_express[$eid] = htmlspecialchars($rs['kname']);
    }
    $array = array(array('eid', 0, 1, 11), array('eid', 2));
    $s .= $king->htmForm($king->lang->get('portal/orders/express'), kc_htm_select('eid', $array_express, $data['eid']), $array);
    //expressnumber
    $array = array(array('expressnumber', 0, 1, 30));
    $s .= $king->htmForm($king->lang->get('portal/express/expressnumber'), kc_htm_input('expressnumber', $data['expressnumber'], 30, 200), $array);
    //kremark
    $array = array(array('kremark', 0, 0, 3000));
    $s .= $king->htmForm($king->lang->get('portal/common/remark'), '<textarea name="kremark" id="kremark" rows="8" cols="100" class="k_in w400">' . htmlspecialchars($data['kremark']) . '</textarea>', $array);
    if ($GLOBALS['ischeck']) {
        $array = array();
        foreach ($array_sql as $val) {
            $array[$val] = $data[$val];
        }
        if (empty($data['nsenddate'])) {
            $array['nsenddate'] = time();
        }
        //如果nsenddate为空,则填写当前时间戳
        $array['nstatus'] = 4;
        //交易状态设置为发货
        $king->db->update('%s_orders', $array, "oid={$oid}");
        $js = 'setTimeout("parent.location=\'manage.orders.php\'",1000)';
        kc_ajax('', '', '', $js);
    }
    $but = kc_htm_a($king->lang->get('portal/common/delivery'), "{CMD:'express',oid:'{$oid}',IS:1,nsenddate:'{$data['nsenddate']}'}");
    kc_ajax($king->lang->get('portal/title/delivery'), $s, $but, '', 440, 290 + $GLOBALS['check_num'] * 15);
}
function king_edt()
{
    global $king;
    $king->access('portal_content_edt');
    //初始化
    $listid = kc_get('listid', 2, 1);
    //$info['listid'];
    $info = $king->portal->infoList($listid);
    $model = $king->portal->infoModel($info['modelid']);
    //	kc_error('<pre>'.print_r($array_field,1));
    $kid = kc_get('kid', 2);
    $kid1 = kc_get('kid1', 2);
    $isadmin = $kid1 ? 'isadmin2' : 'isadmin1';
    //次页:首页
    $array_field = array_keys($model['field'][$isadmin]);
    $sql_field = implode(',', $array_field);
    //[tablemodel]字段调用
    //	$listid=kc_get('listid',2);
    if ($GLOBALS['ismethod'] || $kid == '') {
        //POST过程或新添加的过程
        $data = $_POST;
        if (!$GLOBALS['ismethod']) {
            //初始化新添加的数据
            $data['kpath'] = $king->portal->depathMode($info);
            $data['nshow'] = 1;
            $array_field_default = $model['field']['default'];
            foreach ($array_field_default as $key => $val) {
                $data[$key] = $val;
            }
        }
    } else {
        //编辑数据,从数据库读出
        if (!($data = $king->db->getRows_one('select ' . $sql_field . ' from %s__' . $model['modeltable'] . ' where kid=' . $kid . ' limit 1;'))) {
            kc_error($king->lang->get('system/error/param') . '<br/>select ' . $sql_field . ' from %s__' . $model['modeltable'] . ' where kid=' . $kid . ' limit 1;' . '<br/>File:' . basename(__FILE__) . ';Line:' . __LINE__);
        }
    }
    $data = kc_data($array_field, $data);
    $data['kid'] = $kid;
    if (!($res = $king->db->getRows("select * from %s_field where modelid={$info['modelid']} and {$isadmin}=1 and kid1=0 order by norder,kid;"))) {
        //全部调用
        $res = array();
    }
    $s = $king->openForm('manage.content.php?action=edt');
    $s .= kc_htm_hidden(array('listid' => $listid, 'kid' => $kid, 'kid1' => $kid1));
    //这个隐藏域不要放在下面
    //kc_error("select * from %s_field where modelid={$info['modelid']} and {$isshow}=1 and kid1=0 order by norder,kid;");
    //kc_error('<pre>'.print_r($res,1));
    foreach ($res as $rs) {
        $s .= $king->portal->formdecode($rs, $data, $info, 1, $kid1 ? 2 : 1);
    }
    $s .= $king->htmForm($king->lang->get('portal/common/exp'), kc_htm_checkbox('pag', array(1 => $king->lang->get('portal/goto/addpag')), kc_post('pag')));
    $s .= $king->closeForm('save');
    //数据处理
    if ($GLOBALS['ischeck']) {
        $_array = array();
        //设置为空数组
        //收集字段的值
        foreach ($array_field as $val) {
            if (in_array($val, array('nshow', 'nhead', 'ncommend', 'nup', 'nfocus', 'nhot')) || array_key_exists($val, $model['field']['offon'])) {
                //增加判断offon
                $_array[$val] = $data[$val] ? 1 : 0;
            } else {
                if (is_array($data[$val])) {
                    $_array[$val] = implode(',', $data[$val]);
                } else {
                    $_array[$val] = $data[$val];
                }
                //抓图和过滤链接
                if ($val == 'kcontent') {
                    if (kc_post('isgrab')) {
                        //抓图
                        $_array[$val] = kc_grab($_array[$val]);
                    }
                    if (kc_post('isremovea')) {
                        //过滤链接
                        $_array[$val] = preg_replace('/<a ([^>]*)>|<\\/a>/is', '', $_array[$val]);
                    }
                    if (kc_post('isremovetable')) {
                        //过滤表格
                        $_array[$val] = preg_replace('/<(table|tbody|thead|tr|td|th|caption) ?([^>]*)>|<\\/(table|tbody|thead|tr|td|th|caption)>/is', '', $_array[$val]);
                    }
                    if (kc_post('isremovestyle')) {
                        //过滤样式
                        $_array[$val] = preg_replace('/(<([^>]*))( style=)(["\'])(.*?)\\4(([^>]*)\\/?>)/is', '$1 $6', $_array[$val]);
                    }
                    if (kc_post('isremoveid')) {
                        //过滤样式
                        $_array[$val] = preg_replace('/(<([^>]*))( id=)(["\'])(.*?)\\4(([^>]*)\\/?>)/is', '$1 $6', $_array[$val]);
                    }
                    if (kc_post('isremoveclass')) {
                        //过滤样式
                        $_array[$val] = preg_replace('/(<([^>]*))( class=)(["\'])(.*?)\\4(([^>]*)\\/?>)/is', '$1 $6', $_array[$val]);
                    }
                }
            }
        }
        if (in_array('kimage', $_array) && in_array('kcontent', $_array)) {
            //如果有选择第一个图作为缩略图 并 kimage在列表里
            if (kc_post('isoneimage')) {
                //抓第一张图为缩略图
                if ($oneimage = preg_match('/(<img([^>]*))( src=)(["\'])(.*?)\\4(([^>]*)\\/?>)/is', $_array['kcontent'], $oneimage_array)) {
                    $smartimg = $oneimage_array[5];
                    if (is_file(ROOT . substr($smartimg, strlen($king->config('inst'))))) {
                        //判断是否为本地文件
                        $_array['kimage'] = substr($smartimg, strlen($king->config('inst')));
                    } else {
                        //若是远程文件,则抓取
                        if ($path = kc_grab_get($smartimg)) {
                            //抓取成功
                            if ($path != $smartimg) {
                                //值不一样,说明抓取成功
                                $_array['kimage'] = $path;
                            }
                        }
                    }
                }
            }
        }
        //listid & kid1
        $_array['listid'] = $data['listid'];
        $_array['kid1'] = $data['kid1'] ? $data['kid1'] : 0;
        /**
        		检查kpath是否在键名列表里,如果有则判断是否为空值
        		如果没有,则补充
        */
        if (empty($_array['kpath'])) {
            $_array['kpath'] = $king->portal->depathMode($info);
        }
        /**
        		检查kkeywords,如果没有,则自动补充其值
        		如果有,则更新列表
        */
        $_array['kkeywords'] = !empty($data['kkeywords']) ? $king->portal->getKey($_array['ktitle'], $_array['kkeywords']) : $king->portal->getKey($_array['ktitle']);
        /**
        	关键字替换功能的实现概论
        	从$_array['kkeywords']中获得关键字列表,从预置的[关键字链接页/待做的表]中查找相关关键字
        	kname 关键字
        	kkeywords 关键字相关关键字
        	kpath 关键字链接网址
        	preg_replace('',$rs['kpath'],$_array['kcontent'],1);
        */
        /**
        		检查ktag,如果没有,则自动补充其值
        		如果有,则更新列表
        */
        $_array['ktag'] = !empty($data['ktag']) ? $king->portal->getTag($_array['ktitle'], $_array['ktag']) : $king->portal->gettag($_array['ktitle']);
        /**
        		如果description值为空,则从content中获取
        */
        if (empty($data['kdescription']) && !empty($data['kcontent'])) {
            $kdescription = strip_tags($data['kcontent']);
            $kdescription = preg_replace('/(\\&[a-z]{1,6};)|\\s/', '', $kdescription);
            $_array['kdescription'] = kc_substr($kdescription, 0, 200);
        }
        //副标题长度
        $_array['nsublength'] = isset($data['ksubtitle']) ? kc_strlen($data['ksubtitle']) : 0;
        //更新时间
        $_array['nlastdate'] = time();
        //如果有kid1值,则对kid1对应的nlastdate进行更新
        if ($kid1) {
            $king->db->update('%s__' . $model['modeltable'], array('nlastdate' => time()), 'kid=' . $kid1);
        }
        //图片框写远程路径的时候,抓图
        foreach ($model['field']['image'] as $key => $val) {
            if (isset($_array[$key])) {
                //当有image类型的字段的时候,检查一下其值
                if (kc_validate($_array[$key], 6)) {
                    //若为网址类型的话,自动抓图到本地
                    $_array[$key] = kc_grab_get($_array[$key]);
                }
            }
        }
        //添加&更新数据
        if ($kid) {
            //update
            $king->db->update('%s__' . $model['modeltable'], $_array, 'kid=' . $kid);
            $_nlog = 7;
        } else {
            $_array['ndate'] = time();
            $_array['adminid'] = $king->admin['adminid'];
            $_array['userid'] = -1;
            $_array['norder'] = $king->db->neworder('%s__' . $model['modeltable']);
            //不同的浏览器不同的分页标签,前台不支持
            switch (strtolower($king->admin['admineditor'])) {
                case 'fckeditor':
                    $pagebreak = '<div style="page-break-after: always"><span style="display: none">&nbsp;</span></div>';
                    break;
                case 'tiny_mce':
                    $pagebreak = '<!-- pagebreak -->';
                    break;
                case 'edit_area':
                    $pagebreak = '<!-- pagebreak -->';
                    break;
            }
            if (isset($pagebreak) && isset($_array['kcontent'])) {
                $array = explode($pagebreak, $_array['kcontent']);
                foreach ($array as $key => $val) {
                    $_array['kcontent'] = $val;
                    $_array['norder']++;
                    if ($key === 0) {
                        //第一个
                        $kid = $king->db->insert('%s__' . $model['modeltable'], $_array);
                    } else {
                        $_array['kpath'] = $king->portal->depathMode($info);
                        $_array['kid1'] = $data['kid1'] ? $data['kid1'] : $kid;
                        $king->db->insert('%s__' . $model['modeltable'], $_array);
                    }
                }
            } else {
                $kid = $king->db->insert('%s__' . $model['modeltable'], $_array);
            }
            $_nlog = 5;
            if ($kid == 0) {
                kc_error($king->lang->get('system/error/insert') . kc_clew(__FILE__, __LINE__, nl2br(print_r($_array, 1))));
            }
        }
        //更新列表信息
        $king->portal->lastUpdated($listid, 'list');
        //删除缓存重建缓存
        $king->cache->del('portal/list/' . $listid);
        kc_f_delete($king->config('xmlpath', 'portal') . '/portal/' . $info['modelid'] . '/' . wordwrap($kid, 1, '/', 1) . '.xml');
        $id = $king->portal->infoID($listid, $kid);
        if ($kid1) {
            kc_f_delete($king->config('xmlpath', 'portal') . '/portal/' . $info['modelid'] . '/' . wordwrap($kid1, 1, '/', 1) . '.xml');
            $id = $king->portal->infoID($listid, $kid1);
        }
        //生成操作
        if ($info['npage'] == 0) {
            if ($info['npagenumber'] == 1) {
                $king->portal->createPage($listid, $kid1 ? $kid1 : $kid);
                //$listid,$kid,$pid=1,$is=null
                $subkid = $id['subkid'];
                if ($subkid) {
                    $subid = explode(',', $subkid);
                    foreach ($subid as $sid) {
                        $king->portal->createPage($listid, $sid);
                    }
                }
            } else {
                $pcount = ceil($id['ncount'] / $info['npagenumber']);
                for ($i = 1; $i <= $pcount; $i++) {
                    $king->portal->createPage($listid, $kid1 ? $kid1 : $kid, $i);
                }
            }
        }
        //写log
        $king->log($_nlog, $model['modeltable'] . ':' . $data['ktitle']);
        //		if(kc_post('pag')[0]==1){
        if (kc_post('pag') == 1) {
            $s = kc_goto($king->lang->get('system/goto/saveok'), 'manage.content.php?action=edtpag&listid=' . $data['listid'] . '&kid1=' . ($kid1 ? $kid1 : $kid));
        } else {
            if ($kid1) {
                kc_goto($king->lang->get('system/goto/is'), 'manage.content.php?action=edtpag&listid=' . $data['listid'] . '&kid1=' . $kid1, 'manage.content.php?action=pag&listid=' . $data['listid'] . '&kid1=' . $kid1);
            } else {
                kc_goto($king->lang->get('system/goto/is'), 'manage.content.php?action=edt&listid=' . $data['listid'], 'manage.content.php?listid=' . $data['listid']);
            }
        }
    }
    list($left, $right) = king_inc_list();
    $king->skin->output($info['ktitle'], $left, $right, $s);
}
Beispiel #4
0
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);
}
Beispiel #5
0
function king_safe()
{
    global $king;
    $user = $king->user->access();
    $sql = 'useranswer,userask';
    if ($GLOBALS['ismethod']) {
        //POST过程
        $data = $_POST;
    } else {
        if ($data = $king->db->getRows_one("select {$sql} from %s_user where userid=" . $user['userid'])) {
        }
    }
    $fields = explode(',', $sql);
    $data = kc_data($fields, $data);
    $s = $king->openForm('index.php?action=safe');
    $_array = array(array('userask', 0, 1, 30));
    $s .= $king->htmForm($king->lang->get('user/label/ask'), kc_htm_input('userask', $data['userask'], 30, 200), $_array);
    $_array = array(array('useranswer', 0, 1, 16));
    $s .= $king->htmForm($king->lang->get('user/label/answer'), kc_htm_input('useranswer', $data['useranswer'], 30, 200), $_array);
    $s .= $king->closeForm($king->lang->get('system/common/save'));
    if ($GLOBALS['ischeck']) {
        //删除用户信息
        $king->user->delUserInfo($king->user->userid);
        $array = array();
        $array_sql = explode(',', $sql);
        foreach ($array_sql as $val) {
            $array[$val] = $data[$val];
        }
        $king->db->update('%s_user', $array, "userid={$user['userid']}");
        $array = array('<a href="index.php">' . $king->lang->get('portal/user/return/uc') . '</a>', '<a href="/">' . $king->lang->get('portal/user/return/home') . '</a>', '<a href="index.php?action=safe">' . $king->lang->get('system/common/continueedit') . '</a>');
        $s = kc_htm_ol($king->lang->get('system/ok/save'), $array, 'index.php');
    }
    $tmp = new KC_Template_class($king->config('templateuser', 'user'), $king->config('templatepath') . '/inside/user/safe.htm');
    $tmp->assign('main', $s);
    $tmp->assign('userid', $king->user->userid);
    $tmp->assign('nav', $king->lang->get('user/title/safe'));
    $tmp->assign('title', $king->lang->get('user/title/safe'));
    echo $tmp->output();
}
Beispiel #6
0
function king_edt()
{
    global $king;
    $king->access("portal_tag_edt");
    $kid = kc_get('kid');
    $_sql = 'ktag,kimage,kkeywords,kdescription,kcolor,nsize,isbold,iscommend,ktemplate1,ktemplate2';
    if ($GLOBALS['ismethod'] || $kid == '') {
        //POST过程或新添加的过程
        $data = $_POST;
        if (!$GLOBALS['ismethod']) {
            //初始化新添加的数据
            $data['kcolor'] = '#000000';
            $data['nsize'] = 12;
            $tpath = $king->config('templatepath');
            $tdefa = $king->config('templatedefault');
            $ktemplate1 = $tpath . '/' . $tdefa;
            $data['ktemplate1'] = is_file(ROOT . $ktemplate1) ? $ktemplate1 : '';
            $ktemplate2 = $tpath . '/inside/tag/' . $tdefa;
            $data['ktemplate2'] = is_file(ROOT . $ktemplate2) ? $ktemplate2 : '';
        }
    } else {
        //编辑数据,从数据库读出
        $data = $king->db->getRows_one('select ' . $_sql . ' from %s_tag where kid=' . $kid . ' limit 1;');
    }
    $fields = explode(',', $_sql);
    $data = kc_data($fields, $data);
    $s = $king->openForm('manage.tag.php?action=edt');
    //ktag
    $_array = array(array('ktag', 0, 1, 100));
    $kid ? array_push($_array, array('ktag', 12, $king->lang->get('system/check/none'), $king->db->getRows_one("select kid from %s_tag where ktag='" . $king->db->escape($data['ktag']) . "' and kid<>{$kid};"))) : array_push($_array, array('ktag', 12, $king->lang->get('system/check/none'), $king->db->getRows_one("select kid from %s_tag where ktag='" . $king->db->escape($data['ktag']) . "';")));
    $s .= $king->htmForm($king->lang->get('portal/label/ktag') . ' (1-100)', '<input class="k_in w200" type="text" name="ktag" value="' . htmlspecialchars($data['ktag']) . '" maxlength="100" />', $_array);
    //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);
    //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);
    //kimage
    $_array = array(array('kimage', 0, 0, 255));
    $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);
    //iscommend
    $data['iscommend'] == 1 ? $checked = 'checked="checked"' : ($checked = '');
    $str = '<span><input type="checkbox" name="iscommend" id="iscommend" value="1" ' . $checked . '/><label for="iscommend">' . $king->lang->get('portal/label/attrib/iscommend') . '</label></span>';
    $s .= $king->htmForm($king->lang->get('system/common/attrib'), $str);
    //kcolor,nsize,isbold
    $_array = array(array('kcolor', 0, 7, 7), array('nsize', 0, 1, 2), array('nsize', 2), array('kcolor', 13));
    $str = '<span><input type="text" class="k_in w60" name="nsize" value="' . $data['nsize'] . '"  maxlength="2"/><label> px</label>';
    $data['isbold'] == 1 ? $checked = 'checked="checked"' : ($checked = '');
    $str .= ' <input type="checkbox" name="isbold" id="isbold" value="1" ' . $checked . '/><label for="isbold">' . $king->lang->get('portal/label/bold') . '</label>';
    $str .= ' <label for="kcolor">' . $king->lang->get('portal/label/kcolor') . ':</label><input class="k_in w50" type="text" id="kcolor" name="kcolor" value="' . htmlspecialchars($data['kcolor']) . '" maxlength="7"' . (kc_validate($data['kcolor'], 13) ? ' style="background:' . $data['kcolor'] . '"' : '') . ' />' . kc_f_color('kcolor', $data['kcolor']) . '</span>';
    $s .= $king->htmForm($king->lang->get('system/common/style'), $str, $_array);
    //ktemplate1
    $_array = array(array('ktemplate1', 0, 5, 255), array('ktemplate1', 15));
    $s .= $king->htmForm($king->lang->get('portal/label/templatetag1') . ' (5-255)', '<input class="k_in w400" type="text" name="ktemplate1" id="ktemplate1" value="' . htmlspecialchars($data['ktemplate1']) . '" maxlength="255" />' . kc_f_brow('ktemplate1', $king->config('templatepath'), 2) . kc_help('portal/help/template', 455, 455), $_array);
    //ktemplate2
    $_array = array(array('ktemplate2', 0, 5, 255), array('ktemplate2', 15));
    $s .= $king->htmForm($king->lang->get('portal/label/templatetag2') . ' (5-255)', '<input class="k_in w400" type="text" name="ktemplate2" id="ktemplate2" value="' . htmlspecialchars($data['ktemplate2']) . '" maxlength="255" />' . kc_f_brow('ktemplate2', $king->config('templatepath') . '/inside/tag', 2), $_array);
    $s .= kc_htm_hidden(array('kid' => $kid));
    $s .= $king->closeForm('save');
    if ($GLOBALS['ischeck']) {
        $array = array();
        $array_sql = explode(',', $_sql);
        $data['isbold'] == 1 ? $data['isbold'] = 1 : ($data['isbold'] = 0);
        $data['iscommend'] ? $data['iscommend'] = 1 : ($data['iscommend'] = 0);
        foreach ($array_sql as $val) {
            $array += array($val => $data[$val]);
        }
        /**
        		检查kkeywords,如果没有,则自动补充其值
        		如果有,则更新列表
        */
        if (!$array['kkeywords']) {
            $array += array('kkeywords' => $king->portal->getkey($array['ktag']));
        } else {
            $array['kkeywords'] = $king->portal->getkey($array['ktag'], $array['kkeywords']);
        }
        if ($kid) {
            //update
            $king->db->update('%s_tag', $array, 'kid=' . $kid);
            $nlog = 7;
        } else {
            //insert
            $array += array('norder' => $king->db->neworder('%s_tag'));
            $king->db->insert('%s_tag', $array);
            $nlog = 5;
        }
        $md5path = preg_replace('/(\\w{2})(\\w+)/', "\$1/\$2", md5($data['ktag']));
        $xmlpath = $king->config('xmlpath', 'portal') . '/portal/tag/' . $md5path . '.xml';
        kc_f_delete($xmlpath);
        //写log
        $king->log($nlog, 'Tag:' . $data['ktag']);
        kc_goto($king->lang->get('system/goto/is'), 'manage.tag.php?action=edt', 'manage.tag.php');
    }
    list($left, $right) = king_inc_list();
    $king->skin->output($king->lang->get('portal/title/tag' . ($kid ? 'edt' : 'add')), $left, $right, $s);
}
Beispiel #7
0
function king_lnkedt()
{
    global $king;
    $king->access('#lnk');
    $kid = kc_get('kid', 2);
    $adminid = kc_get('adminid', 2) ? kc_get('adminid', 2, 1) : $king->admin['adminid'];
    //当提交过来的adminid和当前管理员id不同的时候,验证管理员的级别
    if ($adminid != $king->admin['adminid']) {
        $king->access('admin');
    }
    $sql = 'kname,ktitle,kpath,adminid,kimage,isblank,konclick,isflo';
    if ($GLOBALS['ismethod'] || $kid == '') {
        //POST过程或新添加的过程
        $data = $_POST;
        if (!$GLOBALS['ismethod']) {
            //初始化新添加的数据
            $data['kimage'] = 'lnk.gif';
            $data['adminid'] = $adminid;
        }
    } else {
        if (!($data = $king->db->getRows_one("select {$sql} from %s_lnk where kid={$kid} limit 1;"))) {
            kc_error($king->lang->get('system/error/param') . '<br/>File:' . basename(__FILE__) . ';Line:' . __LINE__);
        }
    }
    $fields = explode(',', $sql);
    $data = kc_data($fields, $data);
    $s = $king->openForm('manage.php?action=lnkedt');
    //kname
    $_array = array(array('kname', 0, 1, 20));
    $s .= $king->htmForm($king->lang->get('system/lnk/kname') . ' (1-20)', '<input class="k_in w200" type="text" name="kname" value="' . htmlspecialchars($data['kname']) . '" maxlength="20" />', $_array);
    //ktitle
    $_array = array(array('ktitle', 0, 0, 100));
    $s .= $king->htmForm($king->lang->get('system/lnk/ktitle') . ' (0-100)', '<input class="k_in w400" type="text" name="ktitle" value="' . htmlspecialchars($data['ktitle']) . '" maxlength="100" />', $_array);
    //kpath
    $_array = array(array('kpath', 0, 1, 100));
    $s .= $king->htmForm($king->lang->get('system/lnk/kpath') . ' (1-100)', '<input class="k_in w400" type="text" name="kpath" value="' . htmlspecialchars($data['kpath']) . '" maxlength="100" />', $_array);
    //konclick
    $_array = array(array('konclick', 0, 0, 255));
    $s .= $king->htmForm($king->lang->get('system/lnk/konclick') . ' (0-255)', '<input class="k_in w400" type="text" name="konclick" value="' . htmlspecialchars($data['konclick']) . '" maxlength="255" />', $_array);
    //isblank&isflo
    $array_blank = array(1 => $king->lang->get('system/lnk/blank'));
    $array_flo = array(1 => $king->lang->get('system/lnk/flo'));
    $s .= $king->htmForm($king->lang->get('system/lnk/attrib'), kc_htm_checkbox('isblank', $array_blank, $data['isblank']) . kc_htm_checkbox('isflo', $array_flo, $data['isflo']));
    //kimage
    $_array = array(array('kimage', 0, 1, 100));
    $array = kc_f_getdir('system/images/lnk', 'gif|png|jpg');
    $image = '<div id="lnksel"><p>';
    $i = 1;
    foreach ($array as $val) {
        $image .= '<a href="javascript:;" onclick="$(\'#kimage\').val(\'' . $val . '\');lnksel();"><img src="images/lnk/' . $val . '"/></a>';
        if ($i++ == 6) {
            $image .= '</p><p>';
            $i = 1;
        }
    }
    $image .= '</p></div>';
    $s .= $king->htmForm($king->lang->get('system/lnk/image'), '<table class="k_side" cellspacing="0"><tr><td><img src="images/lnk/' . htmlspecialchars($data['kimage']) . '" id="klnkimage"/></td><td>' . $image . '</td></tr></table>', $_array, null, kc_help('system/help/lnkimg'));
    $s .= kc_htm_hidden(array('adminid' => $data['adminid'], 'kimage' => htmlspecialchars($data['kimage']), 'kid' => $kid));
    $s .= '<script>function lnksel(){var kimage=$(\'#kimage\').val();$(\'#klnkimage\').attr(\'src\',\'images/lnk/\'+kimage);}</script>';
    $s .= $king->closeForm('save');
    if ($GLOBALS['ischeck']) {
        //	$sql='kname,ktitle,kpath,adminid,kimage,isblank,konclick,isflo';
        $array = array();
        foreach ($fields as $val) {
            $array[$val] = $data[$val];
        }
        $_array = array('isblank', 'isflo');
        foreach ($_array as $val) {
            $array[$val] = $data[$val] ? 1 : 0;
        }
        if ($kid) {
            //update
            $king->db->update('%s_lnk', $array, "kid={$kid}");
            $nlog = 7;
        } else {
            //insert
            $array['norder'] = $king->db->neworder('%s_lnk', "adminid={$data['adminid']}");
            $nlog = 5;
            $king->db->insert('%s_lnk', $array);
        }
        $king->cache->del('system/lnk/' . $data['adminid']);
        $king->cache->del('system/lnk/flo_' . $data['adminid']);
        //写log
        $king->log($nlog, $data['kname']);
        kc_goto($king->lang->get('system/goto/is'), 'manage.php?action=lnkedt&adminid=' . $data['adminid'], 'manage.php?action=lnk&adminid=' . $data['adminid']);
    }
    $king->skin->output($king->lang->get('system/title/lnk'), king_inc_lnk_left(), '', $s);
}
Beispiel #8
0
function king_ajax_orders()
{
    global $king;
    //显示物流方式选择页,并显示对应的物流费用
    //订单insert到数据库,并返回订单号。以便客户查询订单,也为邮政付款的用户提供收据上传功能
    //清空购物记录
    $king->Load('user');
    $tip = ($user = $king->user->checkLogin()) ? '' : '<a href="javascript:;" class="k_user_login">' . $king->lang->get('portal/user/nologin') . '</a> <a href="javascript:;" class="k_user_register">' . $king->lang->get('portal/user/regshop') . '</a>';
    $array_sql = array('usermail', 'realname', 'useraddress', 'userpost', 'usertel', 'kfeedback');
    if ($GLOBALS['ismethod']) {
        $data = $_POST;
    } else {
        $data = array();
        if (is_array($user)) {
            //用户已登录
            foreach ($array_sql as $val) {
                $data[$val] = kc_val($user, $val);
            }
        }
    }
    $data = kc_data($array_sql, $data);
    //kconsignee
    $array = array(array('realname', 0, 2, 30));
    $s = $king->htmForm($king->lang->get('portal/orders/realname'), kc_htm_input('realname', $data['realname'], 30, 100), $array, null, $tip);
    //ktel
    $array = array(array('usertel', 0, 6, 30));
    $s .= $king->htmForm($king->lang->get('portal/orders/tel'), kc_htm_input('usertel', $data['usertel'], 30, 200), $array);
    //kmail
    $array = array(array('usermail', 0, 6, 32), array('usermail', 5));
    $s .= $king->htmForm($king->lang->get('portal/orders/mail'), kc_htm_input('usermail', $data['usermail'], 32, 200), $array);
    //kaddress
    $array = array(array('useraddress', 0, 5, 250));
    $s .= $king->htmForm($king->lang->get('portal/orders/address'), '<textarea cols="10" id="useraddress" name="useraddress" rows="3" class="k_in w400">' . htmlspecialchars($data['useraddress']) . '</textarea>', $array);
    //kpost
    $array = array(array('userpost', 0, 6, 6), array('userpost', 2));
    $s .= $king->htmForm($king->lang->get('portal/orders/post'), kc_htm_input('userpost', $data['userpost'], 6, 50), $array);
    //kfeedback
    $array = array(array('kfeedback', 0, 0, 255));
    $s .= $king->htmForm($king->lang->get('portal/orders/feedback'), '<textarea cols="10" rows="4" name="kfeedback" id="kfeedback" class="k_in w400">' . htmlspecialchars($data['kfeedback']) . '</textarea>', $array);
    if ($GLOBALS['ischeck']) {
        $cart = kc_cookie('KingCMS_Cart');
        $eid = kc_post('eid');
        if (!($cart && isset($eid))) {
            kc_error($king->lang->get('system/error/param'));
        }
        $weight = 0;
        $total = 0;
        $nnum = 0;
        $cart_array = unserialize($cart);
        //要过滤掉的内容
        $array_black = str_split('<>\'"%');
        foreach ($cart_array as $key => $number) {
            list($listid, $kid) = explode('-', $key);
            $ID = $king->portal->infoID($listid, $kid);
            if ($total === 0) {
                //第一次运算
                $mch_name = kc_substr(str_replace($array_black, '', $ID['ktitle']), 0, 16);
            }
            $weight += $number * $ID['nweight'];
            $total += $number * $ID['nprice'];
            $nnum += $number;
        }
        $nexpress = 0;
        //运费
        if ($weight !== 0) {
            $express = $king->portal->getExpress();
            $nexpress = $express[$eid]['nsprice'] + $express[$eid]['niprice'] * ceil($weight > 500 ? $weight / 500 - 1 : 0);
        }
        $ono = kc_formatdate(time(), 'Ymd') . sprintf("%08.0d", $king->db->neworder('%s_orders', '', 'oid'));
        $array = array('kname' => $mch_name, 'userid' => is_array($user) ? $user['userid'] : 0, 'kcontent' => $cart, 'ndate' => time(), 'nip' => kc_getip(), 'eid' => $eid, 'ntotal' => round($total, 2), 'ono' => $ono, 'nnumber' => $nnum, 'kfeedback' => $data['kfeedback'], 'nweight' => $weight, 'nexpress' => $nexpress);
        foreach ($array_sql as $val) {
            $array[$val] = kc_val($data, $val);
        }
        $oid = $king->db->insert('%s_orders', $array);
        setcookie('KingCMS_Cart', '', -86400000, $king->config('inst'));
        $js = "\$.kc_ajax('{URL:\\'" . $king->config('inst') . "portal/cart.php\\',CMD:\\'payment\\',IS:1,oid:{$oid}}')";
        kc_ajax('', '', '', $js);
    }
    $but = kc_htm_a($king->lang->get('portal/cart/backcart'), "{URL:'" . $king->config('inst') . "portal/cart.php',CMD:'buy',IS:1}");
    $but .= kc_htm_a($king->lang->get('portal/cart/suborders'), "{URL:'" . $king->config('inst') . "portal/cart.php',CMD:'orders',eid:" . kc_post('eid') . ",IS:1}");
    kc_ajax($king->lang->get('portal/cart/suborders'), $s, $but, '', 600, 350 + $GLOBALS['check_num'] * 15);
}
Beispiel #9
0
function king_edt()
{
    global $king;
    $king->load('user');
    //初始化zf
    $listid = kc_get('listid', 2, 1);
    //$info['listid'];
    $info = $king->portal->infoList($listid);
    $model = $king->portal->infoModel($info['modelid']);
    $kid = kc_get('kid', 2);
    $kid1 = kc_get('kid1', 2);
    $isuser = $kid1 ? 'isuser2' : 'isuser1';
    //次页:首页
    $array_field = array_keys($model['field'][$isuser]);
    $sql_field = implode(',', $array_field);
    //[tablemodel]字段调用
    //读取管理员列表
    $editors = $king->portal->getListEditor($listid);
    if (!is_array($editors)) {
        $editors = array();
    }
    //用户权限及登录验证
    if ($info['gidpublish'] == -1) {
        $user = array('userid' => 0, 'username' => '[' . $king->lang->get('user/name/guest') . ']');
    } else {
        $user = $king->user->access();
        if (!in_array($king->user->userid, $editors) && $info['gidpublish']) {
            //非栏目编辑 并 限制组会员 ;栏目编辑员则跳过此验证
            $king->user->access($info['gidpublish']);
        }
    }
    //发帖验证,检查是否为不允许发布
    //0不允许发布|1直接发布|2验证后发布
    if (!in_array($user['userid'], $editors)) {
        //栏目编辑员无需验证
        if ((int) $info['ispublish' . ($kid1 ? 2 : 1)] === 0) {
            $king->portal->error($king->lang->get('portal/title/stop'), $king->lang->get('portal/error/stop'));
        }
    }
    //当kid有值的时候(编辑),进行所有权验证
    if ($kid) {
        $user = empty($user) ? $king->user->access() : $user;
        //如果$user为null则进行登录验证,目的是要获得userid
        $id = $king->portal->infoID($listid, $kid);
        if (in_array($king->user->userid, $editors) || (int) $id['userid'] === (int) $king->user->userid) {
            if (!in_array($king->user->userid, $editors)) {
                //如果不是栏目管理员,则进行有效期验证
                if (time() - $model['nlocktime'] * 3600 > $id['ndate'] && (int) $model['nlocktime'] !== 0) {
                    //如果超过可允许编辑时间期限 并 可编辑时间不能为0,则提示错误
                    $king->portal->error($king->lang->get('portal/title/stop'), $king->lang->get('portal/error/timeout'));
                }
            }
        } else {
            $king->portal->error($king->lang->get('portal/title/stop'), $king->lang->get('portal/error/noaccess'));
        }
    }
    $fields = explode(',', $sql_field);
    if ($GLOBALS['ismethod'] || $kid == '') {
        //POST过程或新添加的过程
        $data = $_POST;
        if (!$GLOBALS['ismethod']) {
            //初始化新添加的数据
            $data['kpath'] = $king->portal->depathMode($info);
            $data['nshow'] = 1;
            $array_field_default = $model['field']['default'];
            foreach ($array_field_default as $key => $val) {
                $data[$key] = $val;
            }
            //从URL中获取初始值
            foreach ($fields as $val) {
                if (isset($_GET[$val])) {
                    $data[$val] = $_GET[$val];
                }
            }
        }
    } else {
        //编辑数据,从数据库读出
        //判断是否为栏目编辑 或 所有人
        if (!($data = $king->db->getRows_one('select ' . $sql_field . ' from %s__' . $model['modeltable'] . ' where kid=' . $kid . ' limit 1;'))) {
            kc_error($king->lang->get('system/error/param') . '<br/>select ' . $sql_field . ' from %s__' . $model['modeltable'] . ' where kid=' . $kid . ' limit 1;' . '<br/>File:' . basename(__FILE__) . ';Line:' . __LINE__);
        }
    }
    $data = kc_data($fields, $data);
    $data['kid'] = $kid;
    if (!($res = $king->db->getRows("select * from %s_field where modelid={$info['modelid']} and {$isuser}=1 and kid1=0 order by norder,kid;"))) {
        //全部调用
        $res = array();
    }
    $s = $king->openForm('index.php?action=edt');
    $s .= kc_htm_hidden(array('listid' => $listid, 'kid' => $kid, 'kid1' => $kid1));
    //这个隐藏域不要放在下面
    foreach ($res as $rs) {
        $s .= $king->portal->formdecode($rs, $data, $info, 0, $kid1 ? 2 : 1);
    }
    $s .= $king->closeForm($king->lang->get('system/common/publish'));
    //数据处理
    if ($GLOBALS['ischeck']) {
        $_array = array();
        //设置为空数组
        //收集字段的值
        foreach ($array_field as $val) {
            if (substr($val, 0, 1) == 'n') {
                $_array[$val] = $data[$val] ? 1 : 0;
            } else {
                if (is_array($data[$val])) {
                    $_array[$val] = implode(',', $data[$val]);
                } else {
                    $_array[$val] = $data[$val];
                }
            }
        }
        //listid & kid1
        $_array['listid'] = $data['listid'];
        $_array['kid1'] = $data['kid1'] ? $data['kid1'] : 0;
        /**
        		检查kpath是否在键名列表里,如果有则判断是否为空值
        		如果没有,则补充
        */
        if (empty($_array['kpath'])) {
            $_array['kpath'] = $king->portal->depathMode($info);
        }
        /**
        		检查kkeywords,如果没有,则自动补充其值
        		如果有,则更新列表
        */
        $_array['kkeywords'] = !empty($data['kkeywords']) ? $king->portal->getKey($_array['ktitle'], $_array['kkeywords']) : $king->portal->getKey($_array['ktitle']);
        /**
        		检查ktag,如果没有,则自动补充其值
        		如果有,则更新列表
        */
        $_array['ktag'] = !empty($data['ktag']) ? $king->portal->getTag($_array['ktitle'], $_array['ktag']) : $king->portal->gettag($_array['ktitle']);
        /**
        		如果description值为空,则从content中获取
        */
        if (empty($data['kdescription']) && !empty($data['kcontent'])) {
            $kdescription = strip_tags($data['kcontent']);
            $kdescription = preg_replace('/\\&[a-z]{1,6};/', '', $kdescription);
            $_array['kdescription'] = kc_substr($kdescription, 0, 200);
        }
        //副标题长度
        $_array['nsublength'] = isset($data['ksubtitle']) ? kc_strlen($data['ksubtitle']) : 0;
        //更新时间
        $_array['nlastdate'] = time();
        //如果有kid1值,则对kid1对应的nlastdate进行更新
        if ($kid1) {
            $king->db->update('%s__' . $model['modeltable'], array('nlastdate' => time()), 'kid=' . $kid1 . ' limit 1');
        }
        //添加&更新数据
        if ($kid) {
            //update
            $king->db->update('%s__' . $model['modeltable'], $_array, 'kid=' . $kid);
            $_nlog = 7;
        } else {
            $_array['ndate'] = time();
            $_array['norder'] = $king->db->neworder('%s__' . $model['modeltable']);
            $_array['userid'] = $user['userid'];
            $_array['nshow'] = $info['ispublish' . ($kid1 ? 2 : 1)];
            $kid = $king->db->insert('%s__' . $model['modeltable'], $_array);
            $_nlog = 5;
            if ($kid == 0) {
                kc_error($king->lang->get('system/error/insert') . kc_clew(__FILE__, __LINE__, nl2br(print_r($_array, 1))));
            }
        }
        //更新列表信息
        $king->portal->lastUpdated($listid, 'list');
        //删除缓存重建缓存
        $king->cache->del('portal/list/' . $listid);
        kc_f_delete($king->config('xmlpath', 'portal') . '/portal/' . $info['modelid'] . '/' . wordwrap($kid, 1, '/', 1) . '.xml');
        $id = $king->portal->infoID($listid, $kid);
        if ($kid1) {
            kc_f_delete($king->config('xmlpath', 'portal') . '/portal/' . $info['modelid'] . '/' . wordwrap($kid1, 1, '/', 1) . '.xml');
            $id = $king->portal->infoID($listid, $kid1);
        }
        //生成操作
        if ($info['npage'] == 0) {
            if ($info['npagenumber'] == 1) {
                $king->portal->createPage($listid, $kid1 ? $kid1 : $kid);
                //$listid,$kid,$pid=1,$is=null
                $subkid = $id['subkid'];
                if (isset($subkid)) {
                    $subid = explode(',', $subkid);
                    foreach ($subid as $sid) {
                        $king->portal->createPage($listid, $sid);
                    }
                }
            } else {
                $pcount = ceil($id['ncount'] / $info['npagenumber']);
                for ($i = 1; $i <= $pcount; $i++) {
                    $king->portal->createPage($listid, $kid1 ? $kid1 : $kid, $i);
                }
            }
        }
        //跳转,当留言反馈类型的时候,这个跳转需要改动
        echo "<script type=\"text/javascript\">parent.location='" . $king->portal->pathPage($info, $id['kid'], $id['kpath']) . "'</script>";
    }
    $tmp = new KC_Template_class($model['ktemplatepublish']);
    $tmp->assign('inside', $s);
    $tmp->assign('listid', $listid);
    $tmp->assign('title', $info['klistname']);
    $tmp->assign('type', 'edit');
    echo $tmp->output();
    //	list($left,$right)=king_inc_list();
    //	$king->skin->output($king->lang->get('portal/title/content'.($kid?'edt':'add')),$left,$right,$s);
}
Beispiel #10
0
/**
	添加/编辑碎片
*/
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);
}
Beispiel #11
0
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();
}
Beispiel #12
0
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);
}
Beispiel #13
0
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);
}