Example #1
0
 public function appControllerLoad()
 {
     $TestModel = new TestModel();
     $list = $TestModel->getList();
     json_return($list);
     test();
 }
 public function upload1()
 {
     if (IS_POST) {
         $upload = new \Think\Upload();
         // 实例化上传类
         $upload->maxSize = 3145728;
         // 设置附件上传大小
         $upload->exts = array('jpg', 'gif', 'png', 'jpeg');
         // 设置附件上传类型
         $upload->rootPath = './Uploads/';
         // 设置附件上传根目录
         $upload->savePath = 'mytest/';
         // 设置附件上传(子)目录
         // 上传文件
         $info = $upload->upload();
         if (!$info) {
             // 上传错误提示错误信息
             // $this->ajaxReturn($upload->getError(),"AJAX_UPLOAD");
             $this->ajaxReturn(sp_ajax_return(array(), $upload->getError(), 0), "AJAX_UPLOAD");
         } else {
             // 上传成功
             // $this->ajaxReturn('ssss',"AJAX_UPLOAD");
             // $this->ajaxReturn(sp_ajax_return(array("file"=>array(1,2,3)),"上传成功!",1),"AJAX_UPLOAD");
             echo json_return($info, 'ooo', 1);
             // echo 'okkkk';
         }
     } else {
         $this->display();
     }
 }
 public function see_tmp_qrcode()
 {
     if (empty($_GET['qrcode_id'])) {
         json_return(1, '无法得到二维码图片!');
     }
     $qrcode_return = M('Recognition')->get_tmp_qrcode($_GET['qrcode_id']);
     json_return(0, $qrcode_return);
 }
 function message_weidu_count()
 {
     $friendrequest = D('friendrequest');
     $count = $this->Message->where("receiver_en_id = '%s' and readed = 0 and deleted = 0", array($this->myenid))->count();
     $num = $friendrequest->where("receiver_en_id = '%s'", array($this->myenid))->count();
     $sum = $count + $num;
     json_return(200, 'success', $sum);
 }
 function area()
 {
     $city_code = I('get.city_code');
     is_numeric($city_code) ? $city_code : json_return(400, '城市code不符合要求');
     $citys = D('citys');
     $where['parentId'] = $city_code;
     $data = $citys->field('name,code')->where($where)->select();
     empty($data) ? json_return(400, '为空') : json_return(200, '成功', $data);
 }
Example #6
0
/**
 * AwayAPI 运行文件,执行框架初始化,运行等
 *
 * @copyright  Copyright (c) 2013-2014 Awaysoft.Com (http://www.awaysoft.com)
 * @license    http://www.apache.org/licenses/LICENSE-2.0   Apache License, Version 2.0
 * @version    Version 0.1.0
 * @link       http://AwayAPI.awaysoft.com
 * @since      File available since Release 0.1.0
 * @author     Tom <*****@*****.**>
 */
function awayErrorHandle($errno, $errstr, $errfile, $errline, $errarg)
{
    /* 调试模式启用 */
    if (RUN_MODE === 1) {
        $log = '[' . $errno . ']' . $errstr . ':' . $errfile . ':' . $errline;
        Log::write($log);
        if ($errno === E_ERROR || $errno === E_USER_ERROR) {
            $debugBacktrace = debug_backtrace();
            array_shift($debugBacktrace);
            Log::save();
            json_return($debugBacktrace, 1, '发生严重错误');
        }
    }
    /* 继续交由error_reporting()处理 */
    return false;
}
Example #7
0
function get_usercoupon_list($wap_user)
{
    $page = $_POST['page'] ? $_POST['page'] : '1';
    $type = $_REQUEST['type'];
    $time = time();
    //$type = 'used';
    $type_arr = array('all', 'used', 'unused');
    if (!in_array($type, $type_arr)) {
        $type = 'all';
    }
    $where = array();
    switch ($type) {
        case 'unused':
            $where['is_use'] = 0;
            $where['end_time'] = array('>', $time);
            break;
        case 'used':
            $where['is_use'] = 1;
            break;
        case 'expired':
            $where['is_use'] = 0;
            $where['end_time'] = array('<', $time);
            break;
        default:
            break;
    }
    $where['delete_flg'] = '0';
    $where['uid'] = $wap_user['uid'];
    if ($page == 1) {
        $json_return['count'] = D('User_coupon')->where($where)->count('id');
    }
    //$order_by = "";
    $limit = 10;
    $offset = ($page - 1) * $limit;
    $order_by = '';
    $coupon_list = M('User_coupon')->getList($where, $order_by, $limit, $offset);
    $store_id_list = array();
    foreach ($coupon_list as $coupon) {
        $store_id_list[$coupon['store_id']] = $coupon['store_id'];
    }
    $store_list = M('Store')->getStoreName($store_id_list);
    $json_return['list'] = $coupon_list;
    if (count($json_return['list']) < 10) {
        $json_return['noNextPage'] = true;
    }
    json_return(0, $json_return);
}
Example #8
0
 private function _collect($uid)
 {
     $type = $_GET['type'];
     $dataid = $_GET['dataid'];
     $time = time();
     if (!in_array($type, array(1, 2)) || !isset($dataid)) {
         echo json_return(501, '非法操作');
     }
     $data['user_id'] = $where['user_id'] = $uid;
     $data['type'] = $where['type'] = $type;
     $data['dataid'] = $where['dataid'] = $dataid;
     $data['add_time'] = $time;
     $collect = D('User_collect')->where($where)->find();
     if ($collect) {
         echo json_return(502, '已收藏');
     }
     if (D('User_collect')->data($data)->add()) {
         json_return(0, '保存成功');
     } else {
         json_return(503, '保存失败');
     }
 }
 /**
 * halt
 +-----------------------------------------
 * @access public
 * @param ErrorException $e
 * @return void
 */
 static function halt($e)
 {
     self::append($e);
     if (IS_AJAX) {
         $code = $e->getCode();
         json_return(null, $code ? $code : 9999, $e->getMessage());
     }
     if (DEBUG) {
         $traceInfo = '';
         $trace = $e->getTrace();
         foreach ($trace as $t) {
             $traceInfo .= $t['file'] . ' (' . $t['line'] . ') ';
             $traceInfo .= $t['class'] . $t['type'] . $t['function'] . '(';
             foreach ($t['args'] as $k => $arg) {
                 if ($k != 0) {
                     $traceInfo .= ',';
                 }
                 switch (gettype($arg)) {
                     case 'object':
                     case 'array':
                         $traceInfo .= '<b title="' . addslashes(var_export($arg)) . '">' . ucfirst(gettype($arg)) . '</b>';
                         break;
                     default:
                         $traceInfo .= $arg;
                 }
             }
             $traceInfo .= ")\n";
         }
         $message = $e->getMessage() . ' File:' . $e->getFile() . ' Line:' . $e->getLine();
         debug::log($message, 'Error');
         include COMMON_PATH . '500.php';
         exit;
     } else {
         //否则定向到错误页面
         redirect(WEB_PATH . '500.html');
     }
     exit;
 }
Example #10
0
            $database_user = D('User');
            if ($database_user->field('`uid`')->where(array('phone' => $_POST['phone']))->find()) {
                json_return(1014, '手机号码已存在');
            }
            $data = array();
            $data['phone'] = trim($_POST['phone']);
            $data['nickname'] = '';
            $data['password'] = md5(trim($_POST['pwd']));
            $data['check_phone'] = 1;
            $data['login_count'] = 1;
            if (!empty($_SESSION['openid'])) {
                $data['openid'] = $_SESSION['openid'];
            }
            $add_result = M('User')->add_user($data);
            if ($add_result['err_code'] == 0) {
                $_SESSION['wap_user'] = $add_result['err_msg'];
                mergeSessionUserInfo(session_id(), $add_result['err_msg']['uid']);
                json_return(0, '注册成功');
            } else {
                json_return(1, $add_result['err_msg']);
            }
    }
} else {
    //回调地址
    $redirect_uri = $_GET['referer'] ? $_GET['referer'] : ($_SERVER['HTTP_REFERER'] ? $_SERVER['HTTP_REFERER'] : ($_COOKIE['wap_store_id'] ? './home.php?id=' . $_COOKIE['wap_store_id'] : $config['site_url']));
    if (!empty($_SESSION['wap_user'])) {
        redirect($redirect_uri);
    }
    include display('login');
    echo ob_get_clean();
}
Example #11
0
if (empty($ret)) {
    $errmsg = A($class)->act_getErrorMsg();
    if (!empty($errmsg)) {
        json_return($errmsg);
    }
}
//对返回数据进行封装
$package = !empty($data[0]['extend_package']) ? $data[0]['extend_package'] : 'Package:commonPackage';
list($pclass, $pfun) = explode(':', $package);
$pmethod = ucfirst($pclass . "Act");
$pfun = 'act_' . $pfun;
if (!class_exists($pmethod)) {
    json_return(10176);
}
if (!method_exists($pmethod, $pfun)) {
    json_return(10176);
}
$ret = A($pclass)->{$pfun}($ret);
$callback = isset($_GET['callback']) ? $_GET['callback'] : "";
$jsonp = isset($_GET['jsonp']) ? $_GET['jsonp'] : "";
$data = array("errCode" => 200, "errMsg" => get_promptmsg(10172), "status" => true, "data" => $ret);
if (!empty($callback)) {
    if (!empty($jsonp)) {
        echo "try{ " . $callback . "(" . json_encode($data) . "); }catch(){alert(e);}";
    } else {
        echo $callback . "(" . json_encode($data) . ");";
    }
} else {
    echo json_encode($data);
}
exit;
Example #12
0
<?php

/**
 * Created by PhpStorm.
 * User: pigcms_21
 * Date: 2015/5/11
 * Time: 10:29
 */
require_once dirname(__FILE__) . '/global.php';
if (IS_POST && empty($_SESSION['wap_user'])) {
    json_return(10000, '操作失败,您还未登录');
} else {
    if (empty($_SESSION['wap_user'])) {
        redirect('./login.php');
    }
}
if (!option('config.open_store_drp')) {
    //未开启排他分销
    if (!empty($_COOKIE['wap_store_id'])) {
        redirect('./ucenter.php?id=' . $_COOKIE['wap_store_id']);
    } else {
        pigcms_tips('抱歉,您没有权限访问', 'none');
    }
}
$flag = true;
$tmp_store = D('Store')->field('uid,open_drp_limit,drp_limit_buy,drp_limit_share,drp_limit_condition')->where(array('store_id' => $_GET['id']))->find();
if (!empty($tmp_store['open_drp_limit']) && $_SESSION['wap_user']['uid'] != $tmp_store['uid']) {
    //分销限制
    if (!empty($tmp_store['drp_limit_buy'])) {
        //消费满多少
        $array = array();
Example #13
0
 private function _reward_edit()
 {
     $id = $_REQUEST['id'] + 0;
     if (empty($id)) {
         json_return(1001, '缺少最基本的参数ID');
         exit;
     }
     $reward_model = M('Reward');
     $where = array();
     $where['uid'] = $_SESSION['store']['uid'];
     $where['store_id'] = $_SESSION['store']['store_id'];
     $where['id'] = $id;
     $reward = $reward_model->getReward($where);
     if (empty($reward)) {
         json_return(1001, '未找到相应的优惠活动');
         exit;
     }
     if (IS_POST && isset($_POST['is_submit'])) {
         $name = $_POST['name'];
         $start_time = $_POST['start_time'];
         $end_time = $_POST['end_time'];
         $is_all = $_POST['is_all'];
         $reward_str = $_POST['reward_str'];
         $product_id = $_POST['product_id'];
         if (empty($name)) {
             json_return(1001, '活动名称没有填写,请填写');
         }
         if (empty($start_time)) {
             json_return(1001, '请选择活动开始时间');
         }
         if (empty($end_time)) {
             json_return(1001, '请选择活动结束时间');
         }
         if (empty($reward_str)) {
             json_return(1001, '请至少设置一个优惠门槛');
         }
         // 查找参与活动的产品列表
         $product_exist = '';
         $time = time();
         $where = array();
         $where['store_id'] = $_SESSION['store']['store_id'];
         $where['uid'] = $_SESSION['store']['uid'];
         $where['status'] = 1;
         $where['start_time'] = array('<=', $time);
         $where['end_time'] = array('>=', $time);
         $where['is_all'] = 1;
         if (!empty($id)) {
             $where['id'] = array("!=", $id);
         }
         $reward = M('Reward')->getReward($where);
         if (!empty($reward)) {
             $product_exist = 'ALL';
         } else {
             $product_exist = M('Reward_product')->getProductIDList($id);
         }
         if ($product_exist == 'ALL') {
             json_return(1001, '您有其他正在进行的满就减活动,无法设置商品参与');
         } else {
             if ($is_all == 'all' && !empty($product_exist)) {
                 json_return(1001, '您有其他正在进行的满就减活动,无法设置商品参与');
             } else {
                 $product_id_arr = explode(',', $product_id);
                 if (array_intersect($product_id_arr, $product_exist)) {
                     json_return(1001, '您有其他正在进行的满就减活动,无法设置商品参与');
                 }
             }
         }
         // 优惠门槛格式:12,cash:12,postage:1,score:12,coupon:11,present:1
         $reward_arr = explode('|', $reward_str);
         $reward_condition_arr = array();
         foreach ($reward_arr as $tmp) {
             $reward_each_arr = explode(',', $tmp);
             if (count($reward_each_arr) == 1 && $reward_each_arr[0] + 0 < 0) {
                 json_return(1001, '您设置一个优惠门槛有误,请重新设置');
             }
             $data = array();
             foreach ($reward_each_arr as $key => $tmp) {
                 if ($key == 0) {
                     continue;
                 }
                 list($condition, $value) = explode(':', $tmp);
                 $data[$condition] = $value;
                 if ($condition == 'cash') {
                     $value += 0;
                     $value = max(0, $value);
                     if (empty($value)) {
                         json_return(1001, '请正确填写减的金额');
                     }
                 } else {
                     if ($condition == 'score') {
                         $value += 0;
                         $value = ceil(max(0, $value));
                         if (empty($value)) {
                             json_return(1001, '请正确填写减的金额');
                         }
                     } else {
                         if ($condition == 'coupon') {
                             $value += 0;
                             $value = ceil(max(0, $value));
                             if (empty($value)) {
                                 json_return(1001, '请正确选择优惠');
                             }
                         } else {
                             if ($condition == 'present') {
                                 $value += 0;
                                 $value = ceil(max(0, $value));
                                 if (empty($value)) {
                                     json_return(1001, '请正确选择赠品');
                                 }
                             }
                         }
                     }
                 }
             }
             $reward_condition_arr[] = array('money' => $reward_each_arr[0], 'data' => $data);
         }
         if ($is_all == 'part' && empty($product_id)) {
             json_return(1001, '请至少选择一个产品参与活动');
         } else {
             if ($is_all == 'part') {
                 $product_id_arr = explode(',', $product_id);
                 $where = array();
                 $where['status'] = 1;
                 $where['product_id'] = array('in', $product_id_arr);
                 $where['store_id'] = $_SESSION['store']['store_id'];
                 $where['quantity'] = array('>', 0);
                 $product_list = D('Product')->where($where)->select();
                 if (empty($product_list)) {
                     json_return(1001, '您选择的产品不能参加活动');
                 }
             }
         }
         // 有效期修正
         $start_time = strtotime($start_time);
         $end_time = strtotime($end_time);
         if ($start_time > $end_time) {
             $tmp = $end_time;
             $end_time = $start_time;
             $start_time = $tmp;
         }
         // 插入数据库
         $data = array();
         $data['name'] = $name;
         $data['uid'] = $_SESSION['store']['uid'];
         $data['store_id'] = $_SESSION['store']['store_id'];
         $data['start_time'] = $start_time;
         $data['end_time'] = $end_time;
         $data['type'] = count($reward_condition_arr) == 1 ? 1 : 2;
         $data['is_all'] = $is_all == 'part' ? 2 : 1;
         D('Reward')->where(array('id' => $id))->data($data)->save();
         $key_arr = array('cash', 'postage', 'score', 'coupon', 'present');
         // 删除之前的优惠条件
         M('Reward_condition')->delete(array('rid' => $id));
         foreach ($reward_condition_arr as $reward_condition) {
             $reward_condition_data = array();
             $reward_condition_data['rid'] = $id;
             $reward_condition_data['money'] = $reward_condition['money'];
             foreach ($reward_condition['data'] as $key => $val) {
                 if (!in_array($key, $key_arr)) {
                     continue;
                 }
                 $reward_condition_data[$key] = $val;
             }
             D('Reward_condition')->data($reward_condition_data)->add();
         }
         // 删除之前的优惠条件
         $reward_product_model = M('Reward_product');
         M('Reward_product')->delete(array('rid' => $id));
         if ($is_all == 'part') {
             foreach ($product_list as $product) {
                 unset($data);
                 $data['rid'] = $id;
                 $data['product_id'] = $product['product_id'];
                 D('Reward_product')->data($data)->add();
             }
         }
         json_return(0, '修改成功');
     }
     // 优惠条件
     $where = array();
     $where['rid'] = $id;
     $reward_condition_list = M('Reward_condition')->getList($where);
     // 优惠活动产品
     $product_list = M('Reward_product')->getProductListByRid($id);
     // 店铺产品分组
     $product_group_list = M('Product_group')->get_all_list($_SESSION['store']['store_id']);
     $time = time();
     $where = array();
     $where['uid'] = $_SESSION['store']['uid'];
     $where['store_id'] = $_SESSION['store']['store_id'];
     $where['status'] = 1;
     $where['start_time'] = array('<=', $time);
     $where['end_time'] = array('>=', $time);
     // 优惠券
     $coupon_list = M('Coupon')->getList($where);
     // 店铺赠品
     $present_list = M('Present')->getList($where);
     // 变量分配
     $this->assign('reward', $reward);
     $this->assign('reward_condition_list', $reward_condition_list);
     $this->assign('product_list', $product_list);
     $this->assign('product_group_list', $product_group_list);
     $this->assign('coupon_list', $coupon_list);
     $this->assign('present_list', $present_list);
 }
 public function addSerialNumber()
 {
     if (IS_AJAX) {
         $goods_name = trim($_POST['goods_name']);
         $goods_id = M('Goods')->where(array('goods_name' => $goods_name))->getField('goods_id');
         json_return(200, $goods_id, $goods_id);
     } elseif (IS_POST) {
         $data['goods_id'] = intval($_POST['goods_id']);
         $data['serial_number'] = trim($_POST['serial_number']);
         $res = M('Serial')->add($data);
         if ($res) {
             $this->success('添加序列号成功');
         } else {
             $this->error('添加序列号失败');
         }
     } elseif (IS_GET) {
         $serial_number = trim($_GET['serial_number']);
         $this->info = M('Serial')->where(array('serial_number' => $serial_number))->find();
         $this->display();
     }
 }
Example #15
0
        //trim($cover[0]);
        // save picture
        @file_put_contents(PT_PATH . 'picture/' . $product['id'] . '.jpg', base64_decode($cover[1]));
    }
}
// preg product's star
if (preg_match('/5つ星のうち ([0-9.]+)/i', $html, $star)) {
    $product['star'] = $star[1];
}
$db->beginTrans();
$product = filter::apply('refresh', $product, $html);
// Save
$id = $product['id'];
unset($product['id']);
list($sql, $value) = array_values(update_array($product));
$value[':id'] = $id;
$rs = $db->prepare("UPDATE `a_good` SET {$sql} WHERE `id`=:id")->execute($value);
if ($rs === false) {
    $db->rollback();
    json_return(null, 1, 'Load page\'s data fail, please retry.');
}
// Commit
if (!$db->commit()) {
    $db->rollback();
    json_return(null, 9, 'Load page\'s data fail, please retry.');
}
$product['id'] = $id;
template::assign('v', $product);
$html = template::fetch('_tr');
json_return($html);
Example #16
0
 public function getImgList()
 {
     $database_attachment = D('Attachment');
     $condition_attachment['store_id'] = $this->store_session['store_id'];
     $condition_attachment['status'] = '1';
     $condition_attachment['type'] = '0';
     $count = $database_attachment->where($condition_attachment)->count('pigcms_id');
     import('user_page');
     $p = new Page($count, 27);
     $image_list = $database_attachment->field('`pigcms_id`,`name`,`file`,`size`,`width`,`height`')->where($condition_attachment)->order('`pigcms_id` DESC')->limit($p->firstRow . ',' . $p->listRows)->select();
     foreach ($image_list as &$value) {
         $value['file'] = getAttachmentUrl($value['file']);
     }
     $err_msg['image_list'] = $image_list;
     $err_msg['page_bar'] = $p->show();
     $err_msg['count'] = $count;
     json_return(0, $err_msg);
 }
Example #17
0
         if (!empty($_SESSION['wap_user']['uid'])) {
             $uid = $_SESSION['wap_user']['uid'];
             if ($store_info = $store->getUserDrpStore($uid, $store_id, 0)) {
                 //已有分销店铺,跳转到分销管理页面
                 $_SESSION['wap_drp_store'] = $store_info;
                 $flag = true;
             }
             $common_data->setDrpSellerQty();
         }
         if ($flag) {
             json_return(0, './drp_ucenter.php');
         } else {
             json_return(1001, '店铺创建失败');
         }
     } else {
         json_return(1001, '店铺创建失败');
     }
 } else {
     if (IS_GET && $_GET['a'] == 'view' && isset($_GET['level'])) {
         if (empty($_SESSION['wap_drp_store'])) {
             redirect('./ucenter.php?id=' . intval(trim($_COOKIE['wap_store_id'])));
         }
         $store_supplier = M('Store_supplier');
         $store_model = M('Store');
         $order = M('Order');
         $fx_order = M('Fx_order');
         $level = isset($_GET['level']) ? trim(trim($_GET['level'])) : 1;
         $levels = array(1 => '一', 2 => '二');
         $store = $_SESSION['wap_drp_store'];
         $store_url = option('config.wap_site_url') . '/home.php?id=' . $store['store_id'];
         //当前分销商级别
Example #18
0
        case 'species':
            json_return(GetSpeciesWatch($loginState, $result['id']));
            break;
    }
    json_return([]);
}
if (isset($_POST['setrare'])) {
    json_return(SetRareWatch($loginState, $_POST['setrare'], isset($_POST['quality']) ? intval($_POST['quality'], 10) : 0, isset($_POST['itemclass']) ? intval($_POST['itemclass'], 10) : null, isset($_POST['minlevel']) ? intval($_POST['minlevel'], 10) : null, isset($_POST['maxlevel']) ? intval($_POST['maxlevel'], 10) : null, isset($_POST['crafted']) ? !!intval($_POST['crafted'], 10) : false, isset($_POST['vendor']) ? !!intval($_POST['vendor'], 10) : false, isset($_POST['days']) ? intval($_POST['days'], 10) : null));
}
if (isset($_POST['getrare'])) {
    json_return(GetRareWatches($loginState, $_POST['getrare']));
}
if (isset($_POST['deleterare'])) {
    json_return(DeleteRareWatch($loginState, isset($_POST['house']) ? $_POST['house'] : 0, $_POST['deleterare']));
}
json_return([]);
///////////////////////////////
function GetLoginParams($loginFrom, $region, $locale)
{
    global $VALID_LOCALES;
    if (GetLoginState()) {
        return [];
    }
    $loginFrom = substr($loginFrom, 0, 120);
    if ($region != 'EU') {
        $region = 'US';
    }
    if (!in_array($locale, $VALID_LOCALES)) {
        $locale = $VALID_LOCALES[0];
    }
    $json = ['clientId' => BATTLE_NET_KEY, 'authUri' => BATTLE_NET_AUTH_URI, 'redirectUri' => 'https://' . strtolower($_SERVER["HTTP_HOST"]) . $_SERVER["SCRIPT_NAME"], 'state' => MakeNewState(['from' => $loginFrom, 'locale' => $locale, 'region' => $region])];
                }
            }
        } elseif ($task == "edit_user") {
            $email = trim($_POST['email']);
            $pass = trim($_POST['pass']);
            $user_id = trim($_POST['user_id']);
            $level = trim($_POST['level']);
            if (strlen($email) <= 0 || strlen($user_id) <= 0) {
                json_return(400, "Bad Request", NULL);
            } else {
                $headers = apache_request_headers();
                if (isset($headers['Authorization'])) {
                    $auth_array = split(":", $headers['Authorization']);
                    if (trim($auth_array[0]) == session_id() && trim($auth_array[1]) == $_SESSION['api_key']) {
                        $main = new Main();
                        $main->editUser($email, $pass, $user_id, $level);
                    } else {
                        json_return(401, "Unauthorized Request", NULL);
                    }
                } else {
                    json_return(401, "Unauthorized Request", NULL);
                }
            }
        } else {
            json_return(404, "Not Found", NULL);
        }
        break;
    default:
        json_return(404, "Not Found", NULL);
        break;
}
Example #20
0
 public function delete()
 {
     $id = $_GET['id'] + 0;
     if (empty($id)) {
         json_return(1001, '缺少最基本的参数ID');
     }
     $present_model = M('Present');
     $where = array();
     $where['uid'] = $_SESSION['store']['uid'];
     $where['store_id'] = $_SESSION['store']['store_id'];
     $where['id'] = $id;
     $present = $present_model->getPresent($where);
     if (empty($present)) {
         json_return(1001, '未找到相应的赠品');
     }
     $present_model->delete(array('id' => $present['id']));
     json_return(0, '操作完成');
 }
 public function getUsersForAdmins()
 {
     if ($_SESSION['level'] == 0) {
         $user_id = $_SESSION['user_id'];
         $results = array();
         $sql = "SELECT * FROM users WHERE _id != '{$user_id}' AND level != '0' ORDER BY _id DESC";
         $query = pg_query($this->conn, $sql) or die(pg_last_error($this->conn));
         while ($row = pg_fetch_array($query)) {
             $results[] = array('id' => $row['_id'], 'email' => $row['email'], 'level' => $row['level']);
         }
         json_return(200, "Users Read Succeeded", $results);
     } else {
         json_return(401, "Unauthorized Request", $results);
     }
 }
Example #22
0
                    $database_order_product->data($data_order_product)->add();
                }
                $suppliers = array_unique($suppliers);
                //分销商
                $suppliers = implode(',', $suppliers);
                if (!empty($suppliers)) {
                    //修改订单,设置分销商
                    $data = array();
                    $data['suppliers'] = $suppliers;
                    if (!empty($suppliers) && $suppliers != $_POST['storeId']) {
                        $data['is_fx'] = 1;
                    }
                    $database->where(array('order_id' => $order_id))->data($data)->save();
                }
                //删除购物车商品
                $condition_user_cart['pigcms_id'] = array('in', $_POST['ids']);
                if (!empty($wap_user['uid'])) {
                    $condition_user_cart['uid'] = $wap_user['uid'];
                } else {
                    $condition_user_cart['session_id'] = session_id();
                }
                D('User_cart')->where($condition_user_cart)->delete();
                // 产生提醒
                import('source.class.Notify');
                Notify::createNoitfy($_POST['storeId'], option('config.orderid_prefix') . $order_no);
                json_return(0, $config['orderid_prefix'] . $order_no);
            }
        }
    }
}
echo ob_get_clean();
 function dologin()
 {
     extract($_POST);
     $name = trim($name);
     $password = trim($password);
     if (strlen($password) < 6 || strlen($password) > 20) {
         json_return(400, '密码长度不符合要求');
     }
     // if(!check_verify($checkCode, 2)){    //验证验证码
     //     json_return(400,'验证码错误');
     // }
     if (preg_match('/^[\\w-]+(\\.[\\w-]+)*@[\\w-]+(\\.[\\w-]+)+$/', $name)) {
         //邮箱登录
         $pass = $this->User->field('password,user_id,user_en_id,nickname')->where("email = '%s'", array($name))->find();
         //正确的密码
         if ($pass['password'] == password_encode($password)) {
             session('nickname', $pass['nickname']);
             session('user_en_id', $pass['user_en_id']);
             session('user_id', $pass['user_id']);
             json_return(200, '正确');
         } else {
             json_return(400, '用户名或密码错误');
         }
     } else {
         //用户名登录
         $pass = $this->User->field('password,user_id,user_en_id,nickname')->where("user_name = '%s'", array($name))->find();
         //正确的密码
         if ($pass['password'] == password_encode($password)) {
             session('nickname', $pass['nickname']);
             session('user_en_id', $pass['user_en_id']);
             session('user_id', $pass['user_id']);
             json_return(200, '正确');
         } else {
             json_return(400, '用户名或密码错误');
         }
     }
 }
Example #24
0
 public function check_password()
 {
     $password = isset($_POST['password']) ? trim($_POST['password']) : '';
     if ($password) {
         $password = md5($password);
     }
     $uid = $this->user_session['uid'];
     if (D('User')->where(array('uid' => $uid, 'password' => $password))->count('uid')) {
         json_return(0, '密码正确');
     } else {
         json_return(1001, '密码错误');
     }
 }
 /**
  * 防伪查询
  */
 public function antiForgery()
 {
     if (IS_AJAX) {
         $serial_number = trim($_POST['serial_number']);
         $info = M('Serial')->where(array('serial_number' => $serial_number))->find();
         if (empty($info)) {
             json_return(300, '抱歉,您查询的商品验证码' . $serial_number . ',没有通过防伪认证.');
         } else {
             $info['Goods'] = D('Goods')->relation(true)->where(array('goods_id' => $info['goods_id']))->find();
             $info['Order'] = M('Order')->where(array('order_id' => $info['order_id']))->find();
             $data['Goods']['goods_name'] = $info['Goods']['goods_name'];
             $data['Order']['order_sn'] = $info['Order']['order_sn'];
             $data['Goods']['goods_brand'] = $info['Goods']['GoodsBrand']['brand_name'];
             $data['Order']['order_time'] = date('Y-m-d H:i:s', $info['Order']['add_time']);
             json_return(200, '您的商品经过防伪认证', $data);
         }
     } elseif (IS_GET) {
         $this->display();
     }
 }
Example #26
0
function test()
{
    json_return("Test");
}
Example #27
0
        $data['size'] = $uploadList[0]['size'];
        $data['add_time'] = $_SERVER['REQUEST_TIME'];
        $data['ip'] = get_client_ip(1);
        $data['agent'] = $_SERVER['HTTP_USER_AGENT'];
        if ($type == 0) {
            list($data['width'], $data['height']) = getimagesize('../upload/' . $rand_num . $uploadList[0]['savename']);
        }
        $pigcms_id = M('Attachment_user')->add($data);
        if (!$pigcms_id) {
            unlink($upload_dir . $uploadList[0]['name']);
            json_return(1002, '图片上传失败1');
            exit;
        } else {
            $attachment_upload_type = option('config.attachment_upload_type');
            // 上传到又拍云服务器
            if ($attachment_upload_type == '1') {
                import('source.class.upload.upyunUser');
                upyunUser::upload('../upload/' . $rand_num . $uploadList[0]['savename'], '/' . $rand_num . $uploadList[0]['savename']);
            }
            json_return(0, array('id' => $pigcms_id, 'file' => getAttachmentUrl($rand_num . $uploadList[0]['savename'])));
            exit;
        }
    } else {
        json_return(1002, '图片上传失败2');
        exit;
    }
} else {
    json_return(1002, '图片上传失败3');
    exit;
}
echo ob_get_clean();
Example #28
0
require_once '../../incl/api.incl.php';
if (!isset($_GET['house']) || !isset($_GET['id'])) {
    json_return(array());
}
$house = intval($_GET['house'], 10);
$page = preg_replace('/[^a-z]/', '', strtolower(trim($_GET['id'])));
$resultFunc = 'TransmogResult_' . $page;
if (!function_exists($resultFunc)) {
    json_return(array());
}
$canCache = true;
BotCheck();
if ($canCache) {
    HouseETag($house);
}
json_return($resultFunc($house));
function TransmogResult_cloth($house)
{
    return TransmogArmor($house, 'i.class = 4 and i.subclass = 1');
}
function TransmogResult_leather($house)
{
    return TransmogArmor($house, 'i.class = 4 and i.subclass = 2');
}
function TransmogResult_mail($house)
{
    return TransmogArmor($house, 'i.class = 4 and i.subclass = 3');
}
function TransmogResult_plate($house)
{
    return TransmogArmor($house, 'i.class = 4 and i.subclass = 4');
Example #29
0
$headers['From'] = 'Contact Form <*****@*****.**>';
if (preg_match('/\\b[A-Z0-9._%+-]+@[A-Z0-9.-]+\\.[A-Z]{2,4}\\b/i', $_POST['from'], $res) > 0) {
    $headers['Reply-To'] = $res[0];
}
$_POST['message'] = preg_replace('/\\r\\n?/', "\n", $_POST['message']);
$body = "Date: " . date('Y-m-d H:i:s') . "\nFrom: " . $_POST['from'] . "\nIP: " . $_SERVER['REMOTE_ADDR'] . "\nUser Agent: " . $_SERVER['HTTP_USER_AGENT'] . "\n";
$banned = BotCheck(true);
$body .= "Banned: " . ($banned['isbanned'] ? 'yes: ' . $banned['reason'] . ' ' . $banned['ip'] : 'no') . "\n";
$loginState = GetLoginState();
$body .= "User: "******"\n";
if (isset($loginState['id'])) {
    $body .= "Paid until: " . date('Y-m-d H:i:s', GetUserPaidUntil($loginState['id'])) . "\n";
}
if (isset($_POST['region'])) {
    $body .= "Region: " . $_POST['region'] . "\n";
}
if (isset($_POST['realm'])) {
    $body .= "Realm: " . $_POST['realm'] . "\n";
}
if (isset($_POST['house'])) {
    $body .= "House: " . $_POST['house'] . "\n";
}
$body .= "\n---------------\n" . $_POST['message'];
$body = wordwrap(base64_encode($body), 70, "\n", true);
$headerString = '';
foreach ($headers as $k => $v) {
    $headerString .= ($headerString == '' ? '' : "\n") . "{$k}: {$v}";
}
$result = mail('The Editor <*****@*****.**>', 'Letter to the Editor', $body, $headerString, '*****@*****.**');
json_return($result ? array() : false);
Example #30
0
<?php

//狗扑源码社区 www.gope.cn
require_once dirname(__FILE__) . '/global.php';
if (IS_POST) {
    if (!in_array($_POST['type'], array('reg'))) {
        json_return(1000, '非法请求');
    }
    $_SESSION['wap_' . $_POST['type'] . '_code'] = 123456;
    json_return(0, $config['register_phone_again_time']);
}