Exemplo n.º 1
0
<?php

set_time_limit(30);
//无限请求超时时间
require_once dirname(dirname(__FILE__)) . '/Common/index.php';
$uid = post('uid');
$time = time() - 60 * 5;
$socket = MysqlRowSelect('lgsc_socket', '*', " (  touserid = '{$user['userid']}'  and userid = '{$uid}' )  and state = '0' order by createTime asc");
$issocket = MysqlOneSelect('lgsc_socket', '*', "touserid = '{$uid}' and state = '0' ");
if ($socket == '-1') {
    exit;
} else {
    $write = '';
    for ($i = 0, $n = count($socket); $i < $n; $i++) {
        MysqlOneExc('lgsc_socket', 'state=1', 'update', "id=" . $socket[$i]['id']);
        $member = MysqlOneSelect('lgsc_member', 'avatar,username,cnname', "id=" . $socket[$i]['userid']);
        $shop = MysqlOneSelect('lgsc_shops', 'shopname,shop_username', "userid=" . $socket[$i]['userid']);
        if ($shop != -1) {
            $name = $shop['shopname'] . "-" . $member['cnname'];
        } else {
            $name = $member['username'];
        }
        if ($socket[$i]['touserid'] != $user['userid']) {
            $write .= '<div class="im-item im-me">';
            $td = '<td class="lm"></td>';
        } else {
            $write .= '<div class="im-item im-others">';
            $td = '<td class="lm"><span></span></td>';
        }
        $write .= '
        	<div class="im-message clearfix">
Exemplo n.º 2
0
function scanlog($user = '', $id)
{
    if ($user == '') {
        //Cookie记录
        if (isset($_COOKIE['goodsid'])) {
            //echo strpos($id,$_COOKIE['goodsid']);
            //echo $id;
            $string = AuthCode($_COOKIE['goodsid'], 'DECODE');
            if (strpos("{$string}", $id) === false) {
                $_COOKIE['goodsid'] = AuthCode($_COOKIE['goodsid'], 'DECODE');
                $_COOKIE['goodsid'] = AuthCode($_COOKIE['goodsid'] . "{$id},", 'ENCODE');
                setcookie('goodsid', $_COOKIE['goodsid'], time() * 3600 * 24, '/');
            }
            //echo AuthCode($_COOKIE['goodsid'],'DECODE');
        } else {
            setcookie('goodsid', AuthCode($id . ",", 'ENCODE'), time() * 3600 * 24, '/');
        }
    } else {
        //存入数据库
        $post['goodsid'] = $id;
        $post['userid'] = $user['userid'];
        $post['createTime'] = time();
        if (isset($_COOKIE['goodsid'])) {
            $goodsid = AuthCode($_COOKIE['goodsid'], 'DECODE');
            $goodsid = substr($goodsid, '0', '-1');
            $goodsidArr = explode(',', $goodsid);
            for ($i = 0, $n = count($goodsidArr); $i < $n; $i++) {
                $r = MysqlOneSelect("lgsc_scanlog", "count(*) as total", "userid='{$user['userid']}'");
                $total = $r['total'];
                if ($total == 8) {
                    $delRest = MysqlDel('lgsc_scanlog', "userid='{$user['id']}' order by createTime desc limit 1");
                }
                $post['goodsid'] = $goodsidArr[$i];
                $scanlog = MysqlOneSelect("lgsc_scanlog", "*", "userid='{$user['userid']}' and goodsid = '{$goodsidArr[$i]}'");
                if ($scanlog == '-1') {
                    MysqlOneExc('lgsc_scanlog', $post);
                } else {
                    MysqlOneExc('lgsc_scanlog', "createTime=" . time(), 'update', "goodsid='{$goodsidArr[$i]}'");
                }
            }
            setcookie('goodsid', AuthCode($id . ",", 'ENCODE'), -time() * 3600 * 24, '/');
            return true;
        }
        $r = MysqlOneSelect("lgsc_scanlog", "count(*) as total", "userid='{$user['userid']}'");
        $total = $r['total'];
        if ($total == 8) {
            $delRest = MysqlDel('lgsc_scanlog', "userid='{$user['id']}' order by createTime desc limit 1");
        }
        $scanlog = MysqlOneSelect("lgsc_scanlog", "*", "userid='{$user['userid']}' and goodsid = '{$id}'");
        if ($scanlog == '-1') {
            MysqlOneExc('lgsc_scanlog', $post);
        } else {
            MysqlOneExc('lgsc_scanlog', "createTime=" . time(), 'update', "goodsid='{$id}'");
        }
    }
}