예제 #1
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);
}
예제 #2
0
 /**
 	添加日志
 	@param string $nlog  日志类型
 		1  成功登录
 		2  登录失败
 		3  注销
 		4  非法登录
 		5  新建
 		6  删除
 		7  编辑
 	@param string $text  内容
 	@return
 */
 public function log($nlog, $text)
 {
     if ($nlog <= 4) {
         $adminname = $text;
     } else {
         $adminname = $this->admin['adminname'];
     }
     $_array = array('adminname' => $adminname, 'nip' => kc_getip(), 'nlog' => $nlog, 'ndate' => time(), 'ktext' => $text);
     $this->db->insert("%s_log", $_array);
 }
예제 #3
0
function king_ajax_comment()
{
    global $king;
    $kid = kc_get('kid', 2, 1);
    $modelid = kc_get('modelid', 22, 1);
    $kcontent = kc_get('kcontent', 0, 1);
    $commenttime = kc_cookie("commenttime");
    if ($commenttime < time() - 120) {
        //限制2分钟内只能发一次评论
        setcookie("commenttime", time(), time() + 86400, '/');
    } else {
        kc_error($king->lang->get('portal/tip/nocomment'));
    }
    if (kc_strlen($kcontent) > 10) {
        $kcontent = preg_replace('/<a ([^>]*)>|<\\/a>/is', '', $kcontent);
        //过滤链接
        $kcontent = preg_replace('/<(table|tbody|thead|tr|td|th|caption) ?([^>]*)>|<\\/(table|tbody|thead|tr|td|th|caption)>/is', '', $kcontent);
        //过滤表格
        $kcontent = preg_replace('/(<([^>]*))( style=)(["\'])(.*?)\\4(([^>]*)\\/?>)/is', '$1 $6', $kcontent);
        //过滤样式
        $kcontent = preg_replace('/(<([^>]*))( id=)(["\'])(.*?)\\4(([^>]*)\\/?>)/is', '$1 $6', $kcontent);
        $kcontent = preg_replace('/(<([^>]*))( class=)(["\'])(.*?)\\4(([^>]*)\\/?>)/is', '$1 $6', $kcontent);
    }
    if (kc_strlen($kcontent) < 5) {
        kc_ajax($king->lang->get('system/title/tip'), $king->lang->get('portal/tip/nocontent'));
        return;
    }
    $model = $king->portal->infoModel($modelid);
    if ($res = $king->db->getRows_one("select ncomment from %s__{$model['modeltable']} where kid={$kid}")) {
        $ncomment = $res['ncomment'] + 1;
        $_array = array('ncomment' => $ncomment);
        $king->db->update('%s__' . $model['modeltable'], $_array, "kid={$kid}");
    } else {
        kc_error($king->lang->get('portal/error/notq'));
        return;
    }
    $king->load('user');
    if ($user = $king->user->checkLogin()) {
        //已登录
        $username = $user['username'];
        unset($user);
    } else {
        //未登录
        $username = '';
    }
    $_array = array('kid' => $kid, 'modelid' => $modelid, 'kcontent' => $kcontent, 'username' => $username, 'nip' => kc_getip(), 'ndate' => time(), 'isshow' => 1);
    $king->db->insert("%s_comment", $_array);
    $xmlpath = $king->config('xmlpath', 'portal') . '/portal/' . $modelid . '/' . wordwrap($kid, 1, '/', 1) . '.xml';
    kc_f_delete($xmlpath);
    $cachepath = 'portal/comment/' . $modelid . '/' . $kid;
    $king->cache->del($cachepath);
    $js = "\$('#k_comment').html({$ncomment});\$('#kcontent').html('');";
    kc_ajax('OK', '<p class="k_ok">' . $king->lang->get('portal/ok/submit') . '</p>', 0, $js);
}