Esempio n. 1
0
/**
	搜索结果显示页

	########## 搜索结果和所属网站做绑定,根据URL判断 ##########
*/
function king_search()
{
    global $king;
    $king->Load('portal');
    //获得modelid
    if (!($modelTables = getModelTables())) {
        $king->portal->error($king->lang->get('portal/common/error'), $king->lang->get('portal/error/notmodel'));
    }
    $currentArray = current($modelTables);
    $modelid = isset($_GET['modelid']) ? $_GET['modelid'] : $currentArray['modelid'];
    $model = $king->portal->infoModel($modelid);
    $query = kc_get('query', 0);
    $querys = preg_split("/[,\\*\\%\\.\\(\\)\\'\\`><\\}\\{ ]/", $query);
    $querys = array_diff($querys, array(''));
    $q = implode("%' or ktitle like '%", $querys);
    if (isset($q[0])) {
        $q = " and (ktitle like '%" . $q . "%')";
    }
    if (is_array($model['field']['issearch'])) {
        foreach ($model['field']['issearch'] as $key => $val) {
            $getVal = kc_get(substr($key, 1), 0);
            if (isset($getVal[0])) {
                $q .= " and {$key}='" . $king->db->escape($getVal) . "'";
            }
        }
    }
    foreach ($model['field']['id'] as $val) {
        $getVal = kc_val($_GET, $val);
        //kc_get($val,2);
        if (isset($getVal[0])) {
            if (kc_validate($getVal, 2)) {
                $q .= " and {$val}='{$getVal}'";
            } else {
                $q .= " and {$val} in ({$getVal})";
            }
        }
    }
    $pid = isset($_GET['pid']) ? kc_get('pid', 2, 1) : 1;
    $rn = isset($_GET['rn']) ? kc_get('rn', 2, 1) : 20;
    if ($rn > 100) {
        $rn = 100;
    }
    $tmp = new KC_Template_class($model['ktemplatesearch'], $king->config('templatepath') . '/inside/search/' . strtolower($model['modeltable']) . '[page].htm');
    $tmp->assign('type', 'search');
    $tmp->assign('pid', $pid);
    $tmp->assign('rn', $rn);
    $tmp->assign('search', $q);
    //传递搜索条件,也就是where条件
    $tmp->assign('modelid', $modelid);
    //传递模型类型
    //	$tmp->assign('siteid');//这个还得获取
    $tmp->assign('title', $king->lang->get('system/common/search'));
    echo $tmp->output();
}
Esempio n. 2
0
function king_ajax_openlist()
{
    global $king;
    $king->access('portal');
    $is = kc_get('is', 2, 1);
    $space = kc_get('space', 2, 1);
    $ID = kc_get('ID', 4, 1);
    $listid = substr($ID, 4);
    //获得listid
    if (!kc_validate($listid, 2)) {
        kc_error($king->lang->get('system/error/param'));
    }
    $s = kc_icon($is ? 'l1' : 'k1');
    $js = "\$('#{$ID}').attr('rel','{CMD:\\'openlist\\',is:" . (1 - $is) . ",ID:\\'{$ID}\\',IS:2,listid:{$listid},space:{$space}}');";
    if ($is) {
        if ($res = $king->db->getRows("select listid,isexist from %s_list where listid1={$listid} order by norder desc,listid desc;")) {
            $array = array();
            $isopen = '';
            if (isset($_COOKIE['portal_isopen'])) {
                $array = explode(',', $_COOKIE['portal_isopen']);
                $isopen = $_COOKIE['portal_isopen'] . (in_array($listid, $array) ? '' : ',' . $listid);
            } else {
                $isopen = $listid;
            }
            foreach ($res as $rs) {
                $info = $king->portal->infoList($rs['listid']);
                $str = $king->tdList(array($info['listid'], $info['modelid'], $info['klistname'], kc_getlang($info['klanguage']), $space + 1, $info['isexist'], $info['ncount'], $info['ncountall'], addslashes($king->portal->pathList($info))), 2);
                $js .= "\$('#tr_{$listid}').after({$str});\$.kc_ready('#tr_{$info['listid']}');";
                if ($rs['isexist'] == 1 && in_array($rs['listid'], $array)) {
                    $js .= "\$.kc_ajax('{CMD:\\'openlist\\',is:1,ID:\\'ico_{$rs['listid']}\\',IS:2,listid:{$rs['listid']},space:" . ($space + 1) . "}');";
                }
                unset($info);
            }
        } else {
            //当没有下级栏目的时候,删掉
            $king->cache->del('portal/list/' . $listid);
            kc_ajax('', kc_icon(''));
        }
    } else {
        $js .= "tr_remove({$listid},{$space});";
        //\$('#tr_{$listid} ~ tr').remove();
        $array = explode(',', $_COOKIE['portal_isopen']);
        $array = array_diff($array, array($listid));
        //删掉当前的listid
        $isopen = implode(',', $array);
    }
    kc_setCookie('portal_isopen', $isopen, 86400 * 366);
    //写isopen值
    kc_ajax('', $s, '', $js);
}
Esempio n. 3
0
function king_ajax_bind_edt()
{
    global $king;
    $king->access('block_edt');
    $ntype = kc_post('ntype', 2, 1);
    $bid = kc_post('bid');
    $kcontent = kc_post('kcontent');
    $kid = kc_post('kid');
    $kid1 = kc_post('kid1', 2, 1);
    //bid
    if (!isset($bid[0])) {
        kc_error($king->lang->get('block/error/bid', 0));
    }
    if (!kc_validate($bid, 2)) {
        kc_error($king->lang->get('block/error/bid', 1));
    }
    //kcontent
    if (!isset($kcontent[0])) {
        kc_error($king->lang->get('block/error/name', 3));
    }
    /**
    	补充相同验证 ntype bid
    */
    if (empty($kid)) {
        //insert
        //验证重复
        if ($king->db->getRows_one("select kid from %s_block where kid1={$kid1} and ntype={$ntype} and bid={$bid}")) {
            kc_error($king->lang->get('block/error/bind'));
        }
        $block = $king->block->infoBlock($kid1);
        $array = array('kname' => $block['kname'], 'kcontent' => $kcontent, 'kid1' => $kid1, 'ntype' => $ntype, 'bid' => $bid, 'norder' => $king->db->neworder('%s_block'));
        $king->db->insert('%s_block', $array);
        $cmd = 'add';
        $url = "<a href=\"manage.php?action=edt&kid={$kid1}\">" . $king->lang->get('system/common/enter') . "</a>";
    } else {
        //kid
        $kid = kc_post('kid', 2, 1);
        //验证重复
        if ($king->db->getRows_one("select kid from %s_block where kid1={$kid1} and ntype={$ntype} and bid={$bid} and kid<>{$kid}")) {
            kc_error($king->lang->get('block/error/bind'));
        }
        $array = array('kcontent' => $kcontent, 'ntype' => $ntype, 'bid' => $bid);
        $king->db->update('%s_block', $array, "kid={$kid}");
        $king->cache->del("block/info/{$kid1}");
        $cmd = 'edt';
        $url = 0;
    }
    kc_ajax('OK', '<p class="k_ok">' . $king->lang->get("block/ok/{$cmd}") . '</p>', $url);
    //编辑成功后返回的地址
}
Esempio n. 4
0
 public function __construct()
 {
     $cookie = kc_cookie('userauth');
     $cookiePass = substr($cookie, 0, 32);
     $ischeck = true;
     //是否审核cookie
     $GLOBALS['db'] = new db();
     global $db;
     if (empty($cookie) && !empty($_GET['jsoncallback']) && !empty($_GET['USERID']) && !empty($_GET['SIGN'])) {
         $get_userid = $_GET['USERID'];
         $get_sign = $_GET['SIGN'];
         $sign = md5($get_userid . SITEURL . kc_config('system.salt'));
         $userid = $sign == $get_sign ? $get_userid : 0;
         $ischeck = false;
         //$userid=$get['USERID'];
     } else {
         $userid = substr($cookie, 32);
     }
     if (!kc_validate($userid, 2)) {
         $userid = 0;
     }
     if (empty($userid)) {
         $user = array('userpass' => 'x', 'openid' => 'xx');
     } else {
         $user = $db->getRows_one('%s_user', '*', 'userid=' . $userid);
         if (empty($user)) {
             $user = array('userpass' => 'x', 'openid' => 'xx');
         }
     }
     //用户已登录
     if (md5($user['userpass']) == $cookiePass || $ischeck == false || md5($user['openid']) == $cookiePass) {
         //更新在线时间
         $zx = time() - $user['datezx'];
         if ($zx < 300) {
             $array = array('[zaixian]' => 'zaixian+' . $zx, 'datezx' => time());
         } else {
             $array = array('datezx' => time());
         }
         $db->update('%s_user', $array, 'userid=' . $userid);
         unset($user['userpass']);
         $user['islogin'] = true;
     } else {
         $user = array('ismanage' => 0, 'userid' => 0, 'username' => '[匿名]', 'islogin' => false, 'name' => '', 'tel' => '', 'email' => '', 'msn' => '', 'qq' => '', 'userstatu' => false);
     }
     $this->info = $user;
     unset($user);
     return $this->info;
 }
Esempio n. 5
0
 public function __construct()
 {
     //当前页数
     $pid = isset($_GET['pid']) ? $_GET['pid'] : 1;
     $rn = isset($_GET['rn']) ? $_GET['rn'] : 20;
     $this->pid = kc_validate($pid, 2) ? $pid : 1;
     if ($this->pid == 0) {
         $this->pid = 1;
     }
     //每页显示数
     $this->rn = kc_validate($rn, 2) ? $rn : 20;
     if ($this->rn > 100) {
         $this->rn = 100;
     }
     //限制 rn 最大值为100
 }
Esempio n. 6
0
function king_ajax_add()
{
    global $king;
    $fbtime = kc_cookie("fbtime");
    //获得上次操作时间
    $ktitle = kc_post('ktitle');
    $kname = kc_post('kname');
    $kemail = kc_post('kemail');
    $kphone = kc_post('kphone');
    $kqq = kc_post('kqq');
    $kcontent = kc_post('kcontent');
    //check ktitle
    if (!isset($ktitle[1]) || strlen($ktitle) > 50) {
        kc_error($king->lang->get('feedback/error/name', 0));
    }
    //check kname
    if (!isset($kname[1]) || strlen($kname) > 30) {
        kc_error($king->lang->get('feedback/error/name', 1));
    }
    //check kemail
    if (!kc_validate($kemail, 5)) {
        kc_error($king->lang->get('feedback/error/name', 2));
    }
    //check kcontent
    if (!isset($kcontent[9])) {
        kc_error($king->lang->get('feedback/error/name', 3));
    }
    if ($fbtime > time() - 3600) {
        kc_ajax($king->lang->get('system/common/tip'), $king->lang->get('feedback/error/name', 5), 0);
    } else {
        //记录本次发布时间
        setcookie("fbtime", time(), time() + 3600, '/');
        $array = array('ktitle' => $ktitle, 'kname' => $kname, 'kemail' => $kemail, 'kphone' => $kphone, 'kqq' => $kqq, 'kcontent' => $kcontent, 'norder' => $king->db->neworder('%s_feedback'), 'ndate' => time());
        $king->db->insert('%s_feedback', $array);
        kc_ajax('OK', '<p class="k_ok">' . $king->lang->get('feedback/ok/add') . '</p>', "<a href=\"index.php\">" . $king->lang->get('system/common/enter') . "</a>");
        //添加成功后返回的地址
    }
}
Esempio n. 7
0
 /**
 	数组转换为xml文档
 	@param array  $array 数组
 	@param int    $is    递归时用的参数
 	@return string
 */
 public function array2xml($array, $is = 0)
 {
     $str = '';
     foreach ($array as $key => $val) {
         if (is_array($val)) {
             //若为数组
             $str .= "<{$key}>" . NL . $this->array2xml($val, 1) . NL . "</{$key}>" . NL;
         } elseif (kc_validate($key, 23)) {
             kc_validate($val, 4) || $val == null ? $str .= "<{$key}>{$val}</{$key}>" . NL : ($str .= "<{$key}><![CDATA[" . $val . "]]></{$key}>" . NL);
             /*
             */
         }
     }
     if ($is == 0) {
         $s = '<?xml version="1.0" encoding="UTF-8"?>';
         $s .= '<kingcms>';
         $s .= $str;
         $s .= '</kingcms>';
     } else {
         $s = $str;
     }
     return $s;
 }
Esempio n. 8
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);
}
Esempio n. 9
0
 public function infoGroup($gid)
 {
     global $king;
     $cachepath = "user/group/" . $gid;
     if (!($array = $king->cache->get($cachepath, 1))) {
         if ($gid == 0) {
             $array = array('gid' => 0, 'kname' => $king->lang->get('user/group/default'), 'norder' => 0, 'kaccess' => '', 'kremark' => '', 'kmenu' => '');
         } elseif ($res = $king->db->getRows_one("select * from %s_usergroup where gid={$gid}")) {
             $array = array();
             foreach ($res as $key => $val) {
                 if (!kc_validate($key, 2)) {
                     $array[$key] = htmlspecialchars($val);
                 }
             }
         } else {
             return False;
         }
         $king->cache->put($cachepath, $array);
     }
     return $array;
 }
Esempio n. 10
0
/**
	重命名文件或文件夹
*/
function king_ajax_rename()
{
    global $king;
    $king->access('webftp_rename');
    $isdir = kc_post('isdir', 2, 1);
    $path = kc_post('path');
    $file = kc_post('file', 0, 1);
    $id = kc_post('id');
    $new = kc_post($id);
    if (!kc_validate($new, '/^[A-Za-z0-9\\.\\_]+$/')) {
        kc_ajax('', kc_icon('a1'), '', "alert('" . $king->lang->get('webftp/error/newname') . "')");
    }
    kc_f_rename($path . $file, $path . $new);
    $s = "<a rel=\"{CMD:'right',path:'{$path}{$new}/',ID:'ftp_root',leftopen:1,IS:2}\" class=\"k_ajax\" href=\"javascript:;\">{$new}</a>";
    $js = '';
    $oldID = 'k_brow_right_' . _path2id($path . $file);
    $newID = 'k_brow_right_' . _path2id($path . $new);
    if ($isdir) {
        //目录
        //在原有的项目下面添加一个新的,并在下面中删除掉老的
        $js .= "\$('#{$oldID}').after(iii('b1','{$path}','{$new}','--','" . kc_formatdate(kc_f_mtime($path . $new)) . "'));";
    } else {
        $js .= "\$('#{$oldID}').after(iii('" . kc_f_ico($new) . "','{$path}','{$new}','" . kc_f_size(kc_f_filesize($path . $new)) . "','" . kc_formatdate(kc_f_mtime($path . $new)) . "'));";
    }
    $js .= "\$.kc_ready('#{$newID}');";
    $js .= "\$('#{$oldID}').remove();";
    $cachepath = "system/filemanage/{$path}index";
    $king->cache->del($cachepath);
    //清理缓存
    $js .= "\$.kc_close();";
    kc_ajax('', '', '', $js);
}
Esempio n. 11
0
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);
}
Esempio n. 12
0
function king_ajax_hit()
{
    global $king;
    //在增加hit统计的时候,不要每次都对数据库进行更新,而是累计20次后一次性进行更新。
    $kid = kc_get('kid', 2, 1);
    $modelid = kc_get('modelid', 22, 1);
    $cachepath = 'portal/hit';
    if (!($array = $king->cache->get($cachepath))) {
        //若读取的是空缓存,则需要设置一个$array['count']默认值,否则下面+1运算的时候出现警告
        $array['count'] = 0;
    }
    $hittime = kc_cookie("hittime_{$modelid}_{$kid}");
    //上次访问时间
    if (isset($array[$modelid . '|' . $kid])) {
        //若有数组,则++
        if ($hittime < time() - 86400) {
            //上次评论时间超过1天则计数并更新Cookies
            $array[$modelid . '|' . $kid]['count']++;
            setcookie("hittime_{$modelid}_{$kid}", time(), time() + 86400, '/');
            $array['count'] += 1;
        }
        $nhit = $array[$modelid . '|' . $kid]['count'] + $array[$modelid . '|' . $kid]['nhit'];
    } else {
        $model = $king->portal->infoModel($modelid);
        if ($res = $king->db->getRows_one("select nhit from %s__{$model['modeltable']} where kid={$kid}")) {
            $hit = $res['nhit'];
        } else {
            return;
        }
        setcookie("hittime_{$modelid}_{$kid}", time(), time() + 86400, '/');
        //清空缓存后没人访问过的状态直接写Cookies
        $array[$modelid . '|' . $kid] = array('nhit' => $hit, 'count' => 1);
        $array['count'] += 1;
        $nhit = $hit + 1;
    }
    //循环更新数据
    if ($array['count'] > 5) {
        //这个值过大的话,SQLite会出错。
        foreach ($array as $key => $val) {
            list($modelid, $kid) = explode('|', $key);
            //重新获得modelid和kid,和上面无任何关系
            if (kc_validate($kid, 2)) {
                $model = $king->portal->infoModel($modelid);
                $_array = array('nhit' => "[[nhit+{$val['count']}]]", 'nhitlate' => "[[(nhitlate*nhit+" . time() * $val['count'] . ")/(nhit+{$val['count']})]]");
                $king->db->update('%s__' . $model['modeltable'], $_array, "kid={$kid}");
                kc_f_delete($king->config('xmlpath', 'portal') . '/portal/' . $modelid . '/' . wordwrap($kid, 1, '/', 1) . '.xml');
                //$array[$key]=array('nhit'=>$val['nhit']+$val['count'],'count'=>0);
            }
        }
        //		kc_error('cc');
        //清空array
        $king->cache->del($cachepath);
    } else {
        $king->cache->put($cachepath, $array);
    }
    //kc_error(nl2br(print_r($array,1)));
    $js = "\$('#k_hit').html({$nhit});";
    kc_ajax('', '', '', $js);
}
Esempio n. 13
0
 private function tag_select($inner, $attrib)
 {
     $table = kc_val($attrib, 'table');
     if (!kc_validate($table, '/\\%s_[A-Za-z0-9_]/')) {
         return False;
     }
     //判断table数据类型
     $where = isset($attrib['where']) ? ' where ' . $attrib['where'] : '';
     $sql = isset($attrib['sql']) ? kc_val($attrib, 'sql') : '*';
     $number = isset($attrib['number']) ? $attrib['number'] : 10;
     if (!kc_validate($number, 2)) {
         $number = 10;
     }
     $skip = isset($attrib['skip']) ? $attrib['skip'] : 0;
     //跳过skip个后读取
     if (!kc_validate($skip, 2)) {
         $skip = 0;
     }
     $orderby = isset($attrib['orderby']) ? ' order by ' . $attrib['orderby'] : '';
     $limit = 'limit ' . $skip . ',' . $number;
     $s = '';
     if ($res = $this->db->getRows("select {$sql} from {$table} {$where} {$orderby} {$limit}")) {
         $tmp = new KC_Template_class();
         foreach ($res as $rs) {
             foreach ($rs as $key => $val) {
                 $tmp->assign($key, $val);
             }
             $s .= $tmp->output($inner);
         }
     } else {
         return False;
     }
     return $s;
 }
Esempio n. 14
0
 /**
 	对king:portal.comment的解析
 	Code By: CiBill
 	@param
 	@return
 */
 private function tag_comment($inner, $attrib)
 {
     global $king;
     //读取数量
     $number = kc_val($attrib, 'number', 30);
     $number = kc_validate($number, 2) ? $number : 30;
     //跳过条数
     $skip = kc_val($attrib, 'skip', 0);
     $skip = kc_validate($skip, 2) ? $skip : 0;
     //查询条件
     $whereArray = array();
     $modelid = kc_val($attrib, 'modelid');
     //modelid
     if (!kc_validate($modelid, 2)) {
         //如果没有modelid传入,则通过listid获取modelid
         $listid = kc_val($attrib, 'listid');
         //listid
         if (kc_validate($listid, 2)) {
             //listid为数字时,读取单个modelid
             if ($list = $king->portal->infoList($listid)) {
                 $modelid = $list['modelid'];
                 $whereArray[] = "modelid={$modelid}";
             } else {
                 return false;
             }
         } elseif (kc_validate($listid, 3)) {
             $listid = explode(',', $listid);
             $modelid = array();
             foreach ($listid as $val) {
                 if ($list = $king->portal->infoList($val)) {
                     $modelid[] = $list['modelid'];
                 }
             }
             if ($modelid) {
                 $modelid = implode(',', $modelid);
                 $whereArray[] = "modelid in ({$modelid})";
             } else {
                 return false;
             }
         }
     }
     $kid = kc_val($attrib, 'kid');
     //文章id
     if (kc_validate($kid, 2)) {
         $whereArray[] = "kid={$kid}";
     } elseif (kc_validate($kid, 3)) {
         $whereArray[] = "kid in ({$kid})";
     }
     $orderby = isset($attrib['orderby']) ? ' ORDER BY ' . $attrib['orderby'] : ' ORDER BY cid desc';
     $where = $whereArray ? 'where ' . implode(' and ', $whereArray) : '';
     $limit = 'limit ' . $skip . ',' . $number;
     $tmp = new KC_Template_class();
     /*if($skip==0 && $number==30 && kc_validate($kid,2) && kc_validate($modelid,2)){
     		$comment=$king->portal->infoComment($modelid,$kid);
     		if(!$comment)return false;
     	}else*/
     if (!($comment = $king->db->getRows("select * from %s_comment {$where} {$orderby} {$limit}"))) {
         return false;
     }
     $s = '';
     foreach ($comment as $rs) {
         $tmp->assign('id', $rs['cid']);
         $tmp->assign('kid', $rs['kid']);
         $tmp->assign('modelid', $rs['modelid']);
         $tmp->assign('username', $rs['username']);
         $content = $rs['kcontent'];
         if (substr($content, 0, 7) == '[quote]') {
             $rid = intval(substr($content, 7, 10));
             if ($r = $king->db->getRows_One("select * from %s_comment where cid={$rid}")) {
                 $r['kcontent'] = preg_replace("/\\[quote].*\\[\\/quote]/siU", '', $r['kcontent']);
                 $ypost = "Originally posted by <i><b>" . ($r['username'] != '' ? $r['username'] : '******') . "</b></i> at " . kc_formatdate($r['ndate'], 'Y-m-d') . ":<br>";
                 $include = "<table border=0 width='100%' cellspacing=1 cellpadding=10 bgcolor='#cccccc'><tr><td width='100%' bgcolor='#FFFFFF' style='word-break:break-all'>" . $ypost . $r['kcontent'] . "</td></tr></table>";
                 $content = str_replace("[quote]" . $rid . "[/quote]", $include, $content);
             }
         }
         $tmp->assign('content', $content);
         $tmp->assign('ip', long2ip($rs['nip']));
         $tmp->assign('date', $rs['ndate']);
         $s .= $tmp->output($inner);
     }
     return $s;
 }
Esempio n. 15
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);
}
Esempio n. 16
0
 function synlogin($get, $post)
 {
     $uid = $get['uid'];
     $username = $get['username'];
     if (!API_SYNLOGIN) {
         return API_RETURN_FORBIDDEN;
     }
     //note 同步登录 API 接口
     global $king;
     if (!kc_validate($uid, 2)) {
         return API_RETURN_FAILED;
     }
     if ($userinfo = $king->db->getRows_one("SELECT userid FROM %s_user WHERE username='******'")) {
         $userid = $userinfo['userid'];
         unset($userinfo);
         $king->user->userLogin($userid, 2592000);
     }
 }
Esempio n. 17
0
 /**
 列表 - 开始
 @param array $_cmd     命令列表
 	array(
 		$key=>$value,
 		'delete'=>'删除',
 		'-',
 		'create'=>'生成',
 	)
 @param array $right    右键菜单
 	array(
 		
 	);
 @param array $_js      构造javascript函数function ll()
 	array(
 	$value,
 	每个值对应的是一个HTML标签:<td>$value</td>
 	)
 @param string $_plist  分页HTML代码
 @param array  $_val    预设的隐藏域 及值
 @return string
 */
 public function openList($_cmd = null, $right = array(), $_js = null, $_plist = null, $_ext = array())
 {
     $i = 0;
     $fly = '';
     $s = '<form id="k_form_list" name="k_form_list">' . kc_htm_hidden($_ext) . '<script type="text/javascript">var REQUEST_URL=\'' . $_SERVER['PHP_SELF'] . '?' . $_SERVER['QUERY_STRING'] . '\';';
     $s .= 'function kc_button(){var I1=\'';
     $s .= '<table cellspacing="0" class="k_button"><tr><td><div class="k_submit">';
     if (is_array($_cmd)) {
         $s_but = '<span class="select"><a href="javascript:;" class="k_aselect" >' . addslashes($this->lang->get('system/common/aselect')) . '</a>/';
         //onClick="kc_aselect()"
         $s_but .= '<a href="javascript:;" class="k_rselect">' . addslashes($this->lang->get('system/common/rselect')) . '</a></span>';
         $but = '';
         $cmd = "<a href=\"javascript:;\" class=\"k_cmd\">" . $this->lang->get('system/common/morecmd') . "</a>";
         $fly = '<ul id="k_cmd_Fly" style="display:none;">';
         $is = False;
         foreach ($_cmd as $key => $val) {
             if (kc_validate($key, 2)) {
                 if ($val == '-') {
                     $is = True;
                 } else {
                     $fly .= '<li class="hr2">' . $val . '</li>';
                 }
             } else {
                 $fly .= '<li' . ($is ? ' class="hr1"' : '') . '><a href="javascript:;" class="k_ajax" rel="{CMD:\'' . $key . '\',FORM:\'k_form_list\'}">' . $val . '</a></li>';
                 $is = 0;
                 if ($key == 'create') {
                     //有create的时候,设置but
                     $but .= '<a href="javascript:;" class="button k_ajax" rel="{CMD:\\\'' . $key . '\\\',FORM:\\\'k_form_list\\\'}">' . addslashes($this->lang->get('system/common/create')) . '</a>';
                 }
                 if ($key == 'delete' || substr($key, 0, 7) == 'delete_') {
                     //有delete的时候,设置but
                     $but .= '<a href="javascript:;" class="button k_ajax" rel="{CMD:\\\'' . $key . '\\\',FORM:\\\'k_form_list\\\'}">' . addslashes($this->lang->get('system/common/del')) . '</a>';
                 }
             }
         }
         $fly .= '</ul>';
         $s .= $s_but . $but . (count($_cmd) == 1 && isset($but[0]) ? '' : $cmd);
     }
     if (is_array($right)) {
         $fly .= "<div id=\"k_list_right_Fly\" class=\"none\" onClick=\"\$(this).fadeOut(300)\">";
         foreach ($right as $key => $val) {
             if ($val == '-') {
                 $fly .= '<i></i>';
             } else {
                 if (is_array($val)) {
                     $ico = kc_val($val, 'ico');
                     $href = kc_val($val, 'href');
                 } else {
                     $ico = '';
                     $href = $val;
                 }
                 if (substr($href, 0, 1) == '{' || substr($href, -1, 1) == '}') {
                     //ajax操作
                     $fly .= "<a href=\"javascript:;\" class=\"k_ajax\" rel=\"{$href}\">" . kc_icon($ico) . $key . "</a>";
                 } else {
                     $fly .= "<a href=\"{$href}\">" . kc_icon($ico) . $key . "</a>";
                 }
             }
         }
         $fly .= "<i></i>";
         $fly .= "<a href=\"javascript:;\" onClick=\"\$('k_list_right_Fly').fadeOut(300)\">" . kc_icon('k8') . $this->lang->get('system/common/cancel') . "</a>";
         $fly .= "</div>";
     }
     $s .= '</div></td>\'';
     //</div>
     if ($_plist != null) {
         $s .= '+\'<td>' . addslashes($_plist) . '</td>\'';
     }
     $s .= '+\'</tr></table>\';return I1;};document.write(kc_button());';
     $s .= 'function ll(){var K=ll.arguments;if(K[K.length-1]==1){for(i=0;i<K.length-1;i++){if(K[i]!=\'manage\'){document.write(\'<th class="th\'+i+\'">\'+K[i]+\'</th>\')}else{document.write(\'<th class="th\'+i+\'">' . $this->lang->get('system/common/manage') . '</th>\')}}}else{var II=\'<tr id="tr_\'+K[0]+\'">\'' . NL;
     if (is_array($_js)) {
         foreach ($_js as $_value) {
             $s .= '+\'<td id="td_\'+K[0]+\'_' . ++$i . '">\'+$.kc_nbsp(' . $_value . ')+\'</td>\'' . NL;
         }
     }
     $s .= '+\'</tr>\';if(K[K.length-1]==0){document.write(II)}else{return II}}};' . NL;
     $s .= 'document.write(\'<table class="k_table_list" cellspacing="0" id="k_table_list">\');' . NL;
     $this->mList = NL . 'document.write(\'</table>\'+kc_button());';
     $this->mList .= '</script></form>' . $fly;
     //灰调显示按钮
     return $s;
 }
Esempio n. 18
0
function king_ajax_buy()
{
    global $king;
    $cart = isset($_COOKIE['KingCMS_Cart']) ? unserialize($_COOKIE['KingCMS_Cart']) : array();
    $listid = kc_get('listid', 2);
    if ($listid) {
        //当有listid和kid值的时候,更新Cookie
        $kid = kc_get('kid', 2, 1);
        if (kc_post('number')) {
            if (!kc_validate(kc_post('number'), 2)) {
                $js = "alert('" . $king->lang->get('portal/error/number') . "');\$.kc_ajax('{URL:\\'" . $king->config('inst') . "portal/cart.php\\',CMD:\\'buy\\',IS:1}')";
                kc_ajax('', '', '', $js);
            }
        }
        $num = isset($cart[$listid . '-' . $kid]) ? $cart[$listid . '-' . $kid] : 1;
        if (kc_post('number')) {
            $num = kc_post('number');
        }
        //		$num=kc_post('number') ? kc_post('number') : $cart[$listid.'-'.$kid];
        $cart[$listid . '-' . $kid] = $num ? $num : 1;
        setcookie('KingCMS_Cart', serialize($cart), time() + 86400000, $king->config('inst'));
    }
    if (!$cart) {
        //如果购物车为空,则输出错误提示
        kc_ajax($king->lang->get('system/common/error'), '<p class="k_err">' . $king->lang->get('portal/cart/not') . '</p>');
    }
    $s = '<table class="k_table_list" cellspacing="0">';
    $s .= '<tr><th class="c">ID</th><th>' . $king->lang->get('portal/list/prodname') . '</th><th class="c">' . $king->lang->get('portal/list/unitprice') . '</th><th>' . $king->lang->get('system/common/number') . '</th><th class="c">' . $king->lang->get('system/common/subtotal') . '</th><th class="c">' . $king->lang->get('system/common/del') . '</th></tr>';
    $weight = 0;
    //总重
    $total = 0;
    //物品费用
    $i = 0;
    foreach ($cart as $key => $number) {
        list($listid, $kid) = explode('-', $key);
        $ID = $king->portal->infoID($listid, $kid);
        $s .= '<tr><td class="c">' . $kid . '</td><td title="' . addslashes($ID['ktitle']) . '">' . kc_substr($ID['ktitle'], 0, 40) . '</td>';
        $s .= '<td class="c">' . number_format($ID['nprice'], 2) . '</td>';
        $s .= "<td><input id=\"k_orders_{$i}\" type=\"text\" class=\"k_in w50\" size=\"2\" maxlength=\"6\" value=\"{$number}\" onKeydown=\"if(event.keyCode==13){\$.kc_ajax('{URL:\\'" . $king->config('inst') . "portal/cart.php\\',CMD:\\'buy\\',number:\\''+\$(this).val()+'\\',listid:{$listid},kid:{$kid}}');}\"/>";
        $s .= "<a href=\"javascript:;\" class=\"k_ajax\" rel=\"{URL:'" . $king->config('inst') . "portal/cart.php',CMD:'buy',number:\$('#k_orders_{$i}').val(),listid:{$listid},kid:{$kid},IS:1}\">" . kc_icon('o7', $king->lang->get('system/common/up')) . "</a></td>";
        $s .= '<td class="c">' . number_format($number * $ID['nprice'], 2) . '</td>';
        $s .= "<td class=\"c\"><a href=\"javascript:;\" class=\"k_ajax\" rel=\"{URL:'" . $king->config('inst') . "portal/cart.php',CMD:'delete_prod',listid:{$listid},kid:{$kid},IS:1}\">" . kc_icon('j2') . "</a></td></tr>";
        $weight += $number * $ID['nweight'];
        $total += $number * $ID['nprice'];
        $i++;
    }
    $s .= '</table><br/>';
    $array = array();
    $express = $king->portal->getExpress();
    $default = isset($_COOKIE['orders_express_default']) ? $_COOKIE['orders_express_default'] : 1;
    $_array = array();
    foreach ($express as $eid => $rs) {
        $price = $rs['nsprice'] + $rs['niprice'] * ceil($weight > 500 ? $weight / 500 - 1 : 0);
        $array[$eid] = htmlspecialchars($rs['kname']) . '(' . $price . '元)';
        $_array[$eid] = $price;
    }
    $s .= '<script type="text/javascript" charset="UTF-8">' . kc_js2array('K_ORDERS_EXPRESS', $_array) . '</script>';
    $s .= '<table class="k_table_list" cellspacing="0">';
    $s .= '<tr><th class="w150">' . $king->lang->get('portal/list/total') . '</th><td>' . number_format($total, 2) . '<input type="hidden" id="k_orders_total" value="' . $total . '"/></td></tr>';
    if ($weight === 0) {
        //若重量为0,无需物流
        $s .= '<tr><th>' . $king->lang->get('portal/list/selexpress') . '</th><td>' . $king->lang->get('portal/list/notexpress') . kc_htm_hidden(array('eid' => 0)) . '</td></tr>';
        $s .= '<tr><th>' . $king->lang->get('portal/list/alltotal') . '</th><td>' . number_format($total, 2) . '</td></tr>';
        $js = '';
    } else {
        $s .= '<tr><th>' . $king->lang->get('portal/list/selexpress') . '</th><td>' . kc_htm_select('eid', $array, $default, "onChange=\"\$('#k_orders_alltotal').text(\$.number_format(\$('#k_orders_total').val()*1+K_ORDERS_EXPRESS[\$(this).val()]*1,2));\$.setCookie('orders_express_default',\$(this).val())\"") . '</td></tr>';
        $js = '$(\'#k_orders_alltotal\').text($.number_format($(\'#k_orders_total\').val()*1 + K_ORDERS_EXPRESS[$(\'#eid\').val()]*1,2));';
        $js .= '$.setCookie(\'orders_express_default\',$(\'#eid\').val())';
        $s .= '<tr><th>' . $king->lang->get('portal/list/alltotal') . '</th><td id="k_orders_alltotal"></td></tr>';
    }
    $s .= '</table>';
    $s .= '<p>';
    $s .= '<a href="javascript:;" class="k_ajax" rel="{URL:\'' . $king->config('inst') . 'portal/cart.php\',CMD:\'buy\',IS:1}">' . kc_icon('o3') . $king->lang->get('portal/cart/refresh') . '</a>';
    $s .= '<a href="javascript:;" class="k_ajax" rel="{URL:\'' . $king->config('inst') . 'portal/cart.php\',CMD:\'clear_cookie\',IS:1}">' . kc_icon('p3') . $king->lang->get('portal/cart/clear') . '</a>';
    $s .= '<a href="javascript:;" class="k_ajax" rel="{URL:\'' . $king->config('inst') . 'portal/cart.php\',CMD:\'orders\',METHOD:\'GET\',IS:1}">' . kc_icon('q3') . $king->lang->get('portal/cart/checkout') . '</a>';
    $s .= '</p>';
    $but = kc_htm_a($king->lang->get('portal/cart/checkout'), '{URL:\'' . $king->config('inst') . 'portal/cart.php\',CMD:\'orders\',METHOD:\'GET\',IS:1}');
    kc_ajax($king->lang->get('portal/title/mycart'), $s, $but, $js, 600, 350);
}
Esempio n. 19
0
 /**
 	格式化字符串
 
 	@param string $s    : 字符模板
 	@paran string $attrib : 字符串属性,应该是size="20"这种类型的,具体做的时候还得进行输出判断,attrib可能的取值如下
 		width,height : 如果有这两个或一个属性,则对$str进行文件判断,如果是则进行相关图片处理操作
 		replace      : 字符串替换,replace="A|B",A替换为B
 		size         : 字符长度设置
 		code         : 字符转换js/html
 		none         : 空值替换属性
 */
 private function str_format($s, $attrib)
 {
     if (empty($attrib)) {
         return $s;
     }
     //如果是空值,则直接返回s值
     //转换
     if (array_key_exists('formatstr', $attrib)) {
         $code = $attrib['formatstr'];
         if (isset($code[0])) {
             switch (strtolower($code)) {
                 case 'javascript':
                     $s = str_replace(array('\'', "\n", chr(13)), array('\\\'', '\\n', ''), $s);
                     break;
                 case 'urlencode':
                     $s = urlencode($s);
                     break;
                 case 'addslashes':
                     $s = addslashes($s);
                     break;
                 case 'md5':
                     $s = md5($s);
                     break;
             }
         }
     }
     //应用函数
     if (array_key_exists('fun', $attrib)) {
         $fun = $attrib['fun'];
         $funs = explode(',', $fun);
         $array = array(1 => $s);
         foreach ($funs as $fun) {
             if (function_exists($fun)) {
                 //如果有指定的函数,则应用
                 $array1 = array_map($fun, $array);
             }
         }
         $s = $array1[1];
     }
     //替换
     if (array_key_exists('replace', $attrib)) {
         $replace = $attrib['replace'];
         if (is_array($replace)) {
             foreach ($replace as $key => $val) {
                 $s = str_replace($key, $val, $s);
             }
         }
         /*
         		if(isset($replace{0})){
         			list($find,$new)=kc_explode('|',$replace,2);
         			$s=str_replace($find,$new,$s);
         		}
         */
     }
     //长度
     if (array_key_exists('size', $attrib)) {
         $size = $attrib['size'];
         if ($size) {
             if (kc_validate($size, 2)) {
                 $s = kc_substr($s, 0, $size);
             }
         }
     }
     //日期格式化
     if (array_key_exists('formatdate', $attrib)) {
         $format = $attrib['formatdate'];
         if (kc_validate($s, 2)) {
             //默认的时间是int类型的
             $s = kc_formatdate($s, $format);
         } elseif (kc_validate($s, 9)) {
             //日期类型 2008-11-9这种格式
             list($yy, $mm, $dd) = explode('-', $s);
             $s = kc_formatdate(gmmktime(0, 0, 0, $mm, $dd, $yy), $format);
             //需要转换一下字符
         }
     }
     //数字格式化
     if (array_key_exists('formatnumber', $attrib)) {
         if (kc_validate($attrib['formatnumber'], 2)) {
             $s = number_format($s, $attrib['formatnumber']);
         }
     }
     //缩略图
     if (array_key_exists('width', $attrib) || array_key_exists('height', $attrib)) {
         if (array_key_exists('width', $attrib)) {
             $width = $attrib['width'];
         }
         if (array_key_exists('height', $attrib)) {
             $height = $attrib['height'];
         }
         if (($width || $height) && isset($s[0])) {
             $s = kc_image($s, $attrib);
         }
     }
     //默认填充
     if (array_key_exists('none', $attrib)) {
         $none = $attrib['none'];
         if (!isset($s[0])) {
             $s = $none;
         }
     }
     //前面插入
     if (array_key_exists('before', $attrib)) {
         $before = $attrib['before'];
         if (isset($before[0]) && isset($s[0])) {
             $s = $before . $s;
         }
     }
     //后面插入,条件是$s不能为空
     if (array_key_exists('after', $attrib)) {
         $after = $attrib['after'];
         if (isset($after[0]) && isset($s[0])) {
             $s .= $after;
         }
     }
     return $s;
 }
Esempio n. 20
0
function king_ajax_brow_md()
{
    global $king;
    $king->access('#brow_md');
    $path = '';
    $info = inc_brow();
    extract($info);
    $isopen = kc_post('isopen', 2, 1);
    if ($isopen) {
        $cmd = "\$.kc_ajax('" . addslashes("{{$verbs},CMD:'brow_md',isopen:0,path:'{$path}',IS:1,ID:'brow_top',VAL:'brow_md_name'}") . "')";
        $s = "<tr id=\"brow_md\"><th colspan=\"3\">";
        $s .= "<p class=\"c\">" . $king->lang->get('system/common/folder') . ":" . kc_htm_input('brow_md_name', '', 200, 200);
        $s .= " <input onClick=\"{$cmd}\" type=\"button\" value=\"" . $king->lang->get('system/common/new') . "\"/></p>";
        $s .= "</th></tr>";
        $js = "\$('#brow_top').after('" . addslashes($s) . "');";
        $js .= "\$('#a_brow_md').attr('rel','" . addslashes("{{$verbs},CMD:'brow_md',isopen:0,path:'{$path}',IS:1,ID:'brow_top'}") . "');";
        $js .= "\$('#brow_md_name').keydown(function(e){\$(e).unbind();if(e.keyCode==13){$cmd}})";
    } else {
        $js = '';
        $brow_md_name = kc_post('brow_md_name');
        if (isset($brow_md_name[0])) {
            //如果有值的话,就创建目录
            if (kc_validate($brow_md_name, 24)) {
                //验证ok的话
                kc_f_md($path . $brow_md_name);
                //创建目录
                $js .= "\$.kc_ajax({{$verbs},CMD:'brow_right',path:'{$path}{$brow_md_name}/',ID:'browright'});";
                //进入到新建的目录里
            } else {
                $js .= "alert('" . addslashes($king->lang->get('system/error/dir')) . "');";
            }
        }
        $js .= "\$('#brow_md').remove();";
        $js .= "\$('#a_brow_md').attr('rel','" . addslashes("{{$verbs},CMD:'brow_md',isopen:1,path:'{$path}',IS:1,ID:'brow_top'}") . "')";
    }
    kc_ajax('', '', '', $js);
}
Esempio n. 21
0
/**
	判断路径的函数
	@param string $s 路径
	@return string
*/
function kc_FullPath($s)
{
    global $king;
    return kc_validate($s, 6) || substr($s, 0, 1) == '/' ? $s : $king->config('inst') . $s;
}
Esempio n. 22
0
function king_ajax_config()
{
    global $king;
    //dbtype
    $dbtype = kc_post('dbtype');
    if (!in_array($dbtype, array('mysql', 'sqlite'))) {
        kc_error($king->lang->get('system/install/dbtypeerr'));
    }
    //licensed
    $license = kc_post('license');
    if ($license != 1) {
        kc_error($king->lang->get('system/install/licenseerr'));
    }
    $host = kc_post('host');
    $data = kc_post('data');
    $user = kc_post('user');
    $pass = kc_post('pass');
    $sqlitedata = kc_post('sqlitedata');
    //验证
    if ($dbtype == 'mysql') {
        //host
        if (!kc_validate($host, '/^[A-Za-z0-9\\.\\:\\/]+$/')) {
            kc_error($king->lang->get('system/install/ckhost'));
        }
        //data
        if (!kc_validate($data, '/^[A-Za-z0-9\\-\\_]+$/')) {
            kc_error($king->lang->get('system/install/ckdata'));
        }
        //user
        if (!kc_validate($user, '/^[A-Za-z0-9\\-\\_]+$/')) {
            kc_error($king->lang->get('system/install/ckuser'));
        }
    } else {
        //sqlitedata
        if (!kc_validate($sqlitedata, '/^[A-Za-z0-9\\-\\_\\.]+$/')) {
            kc_error($king->lang->get('system/install/ckdata'));
        }
    }
    //pre
    $pre = kc_post('pre');
    if (!kc_validate($pre, '/^[A-Za-z0-9\\_]+$/')) {
        kc_error($king->lang->get('system/install/ckpre'));
    }
    //preadmin
    $preadmin = kc_post('preadmin');
    if (!kc_validate($preadmin, '/^[A-Za-z0-9\\_]+$/')) {
        kc_error($king->lang->get('system/install/ckpreadmin'));
    }
    //adminname
    $adminname = kc_get('adminname', 1, 1);
    if (strlen($adminname) < 2 || strlen($adminname) > 12) {
        kc_error($king->lang->get('system/install/ckadminname'));
    }
    //adminpass
    $adminpass = kc_get('adminpass', 0, 1);
    if (strlen($adminpass) < 6 || strlen($adminname) > 30) {
        kc_error($king->lang->get('system/install/ckadminpass'));
    }
    //cache
    $cache = kc_post('cache');
    if (!kc_validate($cache, '/^[A-Za-z0-9\\_]+$/')) {
        kc_error($king->lang->get('system/install/ckcache'));
    }
    //inst
    $inst = kc_post('inst');
    //timediff
    $timediff = kc_get('timediff', 2, 1);
    //debug
    $debug = kc_post('debug') == 1 ? 'True' : 'False';
    //isdelete
    $isdelete = kc_post('isdelete') == 1 ? 1 : 0;
    $s = kc_f_get_contents('config.php');
    $s = preg_replace("%(define\\('DB_TYPE',')([A-Za-z]+)('\\))%s", "\${1}{$dbtype}\${3}", $s);
    $s = preg_replace("%(define\\('DB_PRE',')([A-Za-z0-9\\_]*)('\\))%s", "\${1}{$pre}\${3}", $s);
    $s = preg_replace("%(define\\('KC_DB_ADMIN',')([A-Za-z0-9\\_]*)('\\))%s", "\${1}{$preadmin}\${3}", $s);
    //sqlite
    $s = preg_replace("%(define\\('DB_SQLITE',')([A-Za-z0-9\\-\\_\\.\\/]+)('\\))%s", "\${1}{$sqlitedata}\${3}", $s);
    //mysql
    $s = preg_replace("%(define\\('DB_HOST',')([A-Za-z0-9\\.\\:\\/]+)('\\))%s", "\${1}{$host}\${3}", $s);
    $s = preg_replace("%(define\\('DB_DATA',')([A-Za-z0-9\\-\\_]+)('\\))%s", "\${1}{$data}\${3}", $s);
    $s = preg_replace("%(define\\('DB_USER',')([A-Za-z0-9\\-\\_]+)('\\))%s", "\${1}{$user}\${3}", $s);
    $s = preg_replace("%(define\\('DB_PASS',')([^']*)('\\))%s", "\${1}{$pass}\${3}", $s);
    $s = preg_replace("%(define\\('PATH_CACHE',')([A-Za-z0-9\\_]*)('\\))%s", "\${1}{$cache}\${3}", $s);
    $s = preg_replace("%(define\\('DEBUG',)(True|False)(\\))%s", "\${1}{$debug}\${3}", $s);
    if (kc_f_put_contents('config.php', $s)) {
        //写入成功
        $js = "\$.kc_ajax('{CMD:\\'install\\',adminname:\\'{$adminname}\\',adminpass:\\'{$adminpass}\\',timediff:\\'{$timediff}\\',inst:\\'{$inst}\\',isdelete:\\'{$isdelete}\\'}')";
        kc_ajax('OK', "<p class=\"k_ok\">" . $king->lang->get('system/install/crtdb') . "</p>", "<a href=\"javascript:;\">" . $king->lang->get('system/common/cancel') . "</a>", $js);
    } else {
        kc_error($king->lang->get('system/install/puterror'));
    }
    //写config.php,并输出ajax执行程序,进入下一步install
}