Example #1
0
 /**
  * 获取热门排行
  */
 public static function hot()
 {
     try {
         // 根据内容id获取排行语句
         $sql = "select * from hit order by count desc limit 6";
         $connect = Db::getInstance()->connect();
         $hitSelect = mysql_query($sql, $connect);
         $hitIds = $newsMap = array();
         while ($row = mysql_fetch_assoc($hitSelect)) {
             $hitIds[] = $row['news_id'];
         }
         $newsSql = "select * from news where id in (" . implode(',', $hitIds) . ") and image != ''";
         $newsSelect = mysql_query($newsSql, $connect);
         $newsList = array();
         while ($row = mysql_fetch_assoc($newsSelect)) {
             $newsList[$row['id']] = $row;
         }
         // 组装新数据
         foreach ($hitIds as $hitId) {
             if (!isset($newsList[$hitId])) {
                 continue;
             }
             $newsMap[] = $newsList[$hitId];
         }
         //var_dump($newsMap);exit;
     } catch (Exception $e) {
         return Response::show(400, '数据获取有误');
     }
     if ($newsMap) {
         return Response::show(200, '热门排行数据返回成功', $newsMap);
     } else {
         return Response::show(200, '数据返回成功', $newsMap);
     }
 }
Example #2
0
File: error.php Project: 51nw/php--
 public function index()
 {
     $this->check();
     $errorLog = isset($_POST['error_log']) ? $_POST['error_log'] : '';
     if (!$errorLog) {
         return Response::show(401, '日志为空');
     }
     $sql = "insert into \n\t\t\t\t\terror_log(\n\t\t\t\t\t\t`app_id`,\n\t\t\t\t\t\t`did`,\n\t\t\t\t\t\t`version_id`,\n\t\t\t\t\t\t`version_mini`,\n\t\t\t\t\t\t`error_log`,\n\t\t\t\t\t\t`create_time`)\n\t\t\t\t\tvalues(\n\t\t\t\t\t\t" . $this->params['app_id'] . ",\n\t\t\t\t\t\t'" . $this->params['did'] . "',\n\t\t\t\t\t\t" . $this->params['version_id'] . ",\n\t\t\t\t\t\t" . $this->params['version_mini'] . ",\n\t\t\t\t\t\t'" . $errorLog . "',\n\t\t\t\t\t\t" . time() . "\n\t\t\t\t\t)";
     $connect = Db::getInstance()->connect();
     if (mysql_query($sql, $connect)) {
         return Response::show(200, '错误信息插入成功');
     } else {
         return Response::show(400, '错误信息插入失败');
     }
 }
Example #3
0
File: init.php Project: jzfan/test
 public function index()
 {
     $this->check();
     // 获取版本升级信息
     $versionUpgrade = $this->getversionUpgrade($this->app['id']);
     if ($versionUpgrade) {
         if ($versionUpgrade['type'] && $this->params['version_id'] < $versionUpgrade['version_id']) {
             $versionUpgrade['is_upload'] = $versionUpgrade['type'];
         } else {
             $versionUpgrade['is_upload'] = 0;
         }
         return Response::show(200, '版本升级信息获取成功', $versionUpgrade);
     } else {
         return Response::show(400, '版本升级信息获取失败');
     }
 }
Example #4
0
 public function check()
 {
     $this->params['app_id'] = $appId = isset($_POST['app_id']) ? $_POST['app_id'] : '';
     $this->params['version_id'] = $versionId = isset($_POST['version_id']) ? $_POST['version_id'] : '';
     $this->params['version_mini'] = $versionMini = isset($_POST['version_mini']) ? $_POST['version_mini'] : '';
     $this->params['did'] = $did = isset($_POST['did']) ? $_POST['did'] : '';
     $this->params['encrypt_did'] = $encryptDid = isset($_POST['encrypt_did']) ? $_POST['encrypt_did'] : '';
     if (!is_numeric($appId) || !is_numeric($versionId)) {
         return Response::show(401, '参数不合法');
     }
     // 判断APP是否需要加密
     $this->app = $this->getApp($appId);
     if (!$this->app) {
         return Response::show(402, 'app_id不存在');
     }
     if ($this->app['is_encryption'] && $encryptDid != md5($did . $this->app['key'])) {
         return Response::show(403, '没有该权限');
     }
 }
Example #5
0
 function sendSMS()
 {
     $token = self::randToken();
     $data = array('zh' => $this->id, 'mm' => $this->pwd, 'dxlbid' => $this->product, 'extno' => $this->product, 'hm' => $this->mobile);
     $data['nr'] = '暖暖的用户,您的验证码为' . $token . ',如非本人操作,请忽略本短信【暖暖购物】';
     //$data['message'] =urlencode('尊敬的用户,您的验证码为'.$token.'【暖暖】') ;
     $status = self::postFn($data, $this->url . ':' . $this->port . '/Service.asmx/sendsms');
     $status = 0;
     //跳过短信环节;
     $re = new Token();
     $arr = array('tel' => $this->mobile, 'token' => $token, 'timeout' => time() + 300);
     //失效时间为5分钟
     $arr_search = array('tel' => $this->mobile);
     $reponse = new Response();
     if (mysql_fetch_assoc($re->token_select($arr_search, 1))) {
         $re->token_update($arr, "tel={$this->mobile}");
     } else {
         $re->token_insert($arr);
     }
     if (!$status) {
         echo $reponse->show(200);
     }
     //echo $token;
 }
Example #6
0
 $arr['registerDate'] = date("Y/m/d");
 $condition = isset($arr['tel']) ? 'tel=\'' . $arr['tel'] . '\'' : 'uid=\'' . $arr['uid'] . '\'';
 $setUser = new UserInfo();
 $re_select = $setUser->userinfo_select($arr_select, 1);
 //uid如果已经存在的用户,更新资料
 if (mysql_fetch_row($re_select)) {
     $arr['gender'] = isset($arr['gender']) ? $arr['gender'] : 0;
     $arr['age'] = isset($arr['age']) ? $arr['age'] : 0;
     $arr['idCard'] = isset($arr['idCard']) ? $arr['idCard'] : '';
     $arr['realName'] = isset($arr['realName']) ? $arr['realName'] : '';
     $arr['birthDate'] = isset($arr['birthDate']) ? $arr['birthDate'] : '';
     $checkArr = array('uid' => $arr['uid']);
     //更新个人信息
     $r = $setUser->userinfo_select($checkArr, 1);
     if (!mysql_fetch_assoc($r)) {
         echo $res->show(407);
         exit;
     }
     $re = $setUser->userinfo_update($arr, $condition);
     if ($re == 1) {
         echo $res->show(200, mysql_fetch_assoc($setUser->userinfo_select($arr_select, 1)));
     } else {
         echo $res->show(407);
     }
     exit;
 }
 //不存在的用户,新创建
 if (isset($arr['token'])) {
     //找回密码,要验证token
     if (isset($arr['tel'])) {
         $token = $arr['token'];
Example #7
0
File: list.php Project: pengfen/app
<?php

// http://www.app.com/list.php?page=1&pagesize=12
require_once '../basic/format.php';
require_once '../core/cache.php';
// 加载缓存文件
$file = new File();
$data = $file->cacheData('index_cache');
if ($data) {
    return Response::show(200, '首页数据获取成功', $data);
} else {
    return Response::show(400, '首页数据获取失败', $data);
}
exit;
$page = isset($_GET['page']) ? $_GET['page'] : 1;
$pageSize = isset($_GET['pagesize']) ? $_GET['pagesize'] : 1;
if (!is_numeric($page) || !is_numeric($pagesize)) {
    return Response::show(401, '数据不合法', '', 'xml');
}
$offset = ($page - 1) * $pagesize;
$sql = "select * from areas";
Example #8
0
<?php

header("Content-Type: application/json;charset=utf-8");
header("Access-Control-Allow-Origin:*");
header("Access-Control-Allow-Methods:POST,GET");
require_once "./Db.php";
require_once "./Response.php";
$username = Response::_post('username');
$userpass = Response::_post('userpass');
if (!isset($username) || !isset($userpass)) {
    Response::show(400, '输入的数据不正确');
} else {
    $connect = Db::getInstance()->connect();
    $sql = "select * from users where user_name='" . $username . "'and user_psd='" . $userpass . "'";
    $result = mysql_query($sql, $connect);
    if (!mysql_num_rows($result)) {
        Response::show(400, '输入的用户名或密码不正确');
    } else {
        $results = mysql_fetch_assoc($result);
        Response::show(200, 'success', $results);
    }
}
Example #9
0
<?php

//父母基本信息接口
require_once '../../models/Response.php';
require_once '../../models/data/ParentInfo.php';
if (isset($_GET['uid'])) {
    $uid = $_GET['uid'];
    $arr = array('childID' => $uid);
    $re = new ParentInfo();
    $userinfo = $re->parentinfo_select($arr, 5);
    //个人信息
    $data = array();
    $r = '';
    while ($r = mysql_fetch_assoc($userinfo)) {
        $data[$r['isMum'] == 1 ? 'mum' : 'dad'] = $r;
    }
    $msg = new Response();
    echo $msg->show('200', $data);
}
Example #10
0
require_once '../../models/Token.php';
error_reporting(0);
require_once '../../models/Response.php';
$res = new Response();
if ($_GET['tel'] && $_GET['send'] == 1) {
    $obj = new Token_SMS();
    $tel = $_GET['tel'];
    $uid = '';
    $obj->__set($uid, $tel);
    $token = $obj->sendSMS();
} elseif ($_GET['tel'] && isset($_GET['token'])) {
    $token = $_GET['token'];
    $tel = $_GET['tel'];
    $status = checkToken($tel, $token);
    $res->show($status);
} else {
    $res->show(400);
}
//检查验证码与tel对应关系
function checkToken($tel, $token)
{
    $obj = new Token_SMS();
    $uid = '';
    $obj->__set($uid, $tel);
    return $obj->getToken($tel, $token);
}
/*
$obj = new Sms();
 $tel = '15911122086';
$uid = md5($tel);
Example #11
0
<?php

require_once './format.php';
$data = array('id' => 1, 'name' => 'apeng', 'type' => array(1, 2, 3), 'test' => array(1, 2, 3 => array(123, 'type')));
Response::show(200, 'success', $data, 'array');
Example #12
0
//收藏、取消收藏接口
//$islike =1  收藏  $islike=0 取消收藏
$res = new Response();
$ul = new UserLike();
if (isset($_POST['islike']) && isset($_POST['uid']) && isset($_POST['itemID'])) {
    $islike = $_POST['islike'];
    $uid = $_POST['uid'];
    $itemid = $_POST['itemID'];
    if (1 == $islike) {
        $arr = array('userid' => $uid);
        $limit = 1;
        $re = mysql_fetch_assoc($ul->userlike_select($arr, $limit));
        $like_arr_items = explode(',', $re['items']);
        if ($re) {
            if (in_array($itemid, $like_arr_items)) {
                echo $res->show(200);
                exit;
            }
            $arr = array('items' => $re['items'] . ',' . $itemid);
            $condition = '`userid`=' . $uid;
            $re = $ul->userlike_update($arr, $condition);
            if ($re) {
                echo $res->show(200);
            } else {
                echo $res->show(500);
            }
        } else {
            $arr = array('items' => $itemid, 'userid' => $uid);
            $re = $ul->userlike_insert($arr);
            if ($re) {
                echo $res->show(200);
Example #13
0
//用户基本信息接口
require_once '../../models/Response.php';
require_once '../..//models/UserProfile.php';
require_once '../../models/UserProfile.php';
$msg = new Response();
$page = isset($_GET['page']) ? $_GET['page'] : null;
if (isset($_GET['uid']) || $_GET['tel']) {
    $uid = $_GET['uid'];
    $re = new UserProfile();
    if (isset($_GET['password']) && isset($_GET['tel'])) {
        $tel = $_GET['tel'];
        $pwd = md5($_GET['password']);
        $userinfo = $re->checkAuth($tel, $pwd);
        //登录验证密码
        if ($userinfo == FALSE) {
            echo $msg->show('406');
        } else {
            $userinfo = $re->userinfo(null, $tel);
            if (!isset($userinfo['nickname'])) {
                $data = array('nickname' => $tel);
                $condition = '`tel`=' . $tel;
                $re->updateUserInfo($data, $condition);
            }
            $parentpercent = $re->parentpercent($uid);
            //父母信息完成比例
            $likeNum = $re->likeNum($uid);
            //收藏个数
            $data = array('userinfo' => $userinfo, 'parentpercent' => $parentpercent, 'likeNum' => $likeNum);
            echo $msg->show('200', $data);
        }
        exit;
Example #14
0
<?php

require_once '../../models/data/UserInfo.php';
require_once '../../models/upAddress.php';
require_once '../../models/Response.php';
//增加地址接口
$response = new Response();
$add = new UpAddress();
//更新个人资料
if (isset($_POST['uid']) && $_POST['data'] && $_POST['isParent'] == 0) {
    $uid = $_POST['uid'];
    $data = $_POST['data'];
    $re = $add->upAddress($data, $uid);
    echo $response->show(200, $re);
} elseif (isset($_POST['uid']) && $_POST['data'] && $_POST['isParent'] == 1) {
    $uid = $_POST['uid'];
    $data = $_POST['data'];
    $isParent = $_POST['isParent'];
    $isMum = $_POST['isMum'];
    $re = $add->upAddress($data, $uid, $isParent, $isMum);
    echo $response->show(200, $re);
} else {
    echo $response->show(400);
}
Example #15
0
<?php

//发现页面数据调用接口
require_once '../../models/Response.php';
require_once '../..//models/Discovery.php';
$style = new Response();
$gender = isset($_GET['gender']) ? $_GET['gender'] : NULL;
$pageId = isset($_GET['page']) ? $_GET['page'] : 1;
$uid = isset($_GET['uid']) ? $_GET['uid'] : 1;
$type = isset($_GET['type']) ? $_GET['type'] : NULL;
$re = new Discovery();
$data = $re->presentForHuman($gender, $type, $pageId, $uid);
echo $style->show('200', $data);
Example #16
0
<?php

require_once '../../models/data/UserInfo.php';
require_once '../../models/UserProfile.php';
require_once '../../models/Response.php';
//更换用户头像接口
$response = new Response();
if ($_POST['uid'] && $_FILES) {
    $uid = $_POST['uid'];
    $data = new UserProfile();
    $im = $data->upProfileImage($_FILES, $uid);
    if ($im != 400) {
        echo $response->show(200, $im);
    } else {
        echo $response->show(407);
    }
} else {
    echo $response->show(400);
}
Example #17
0
if (!is_numeric($page) || !is_numeric($pageSize)) {
    return Response::show(401, "数据不合法");
}
$offset = ($page - 1) * $pageSize;
$sql = "select * from t_user limit " . $offset . ',' . $pageSize;
$cache = new Cache();
$rows = array();
if (!($rows = $cache->cacheData('cache' . $page . '-' . $pageSize))) {
    //echo 'fjsjfjsf';exit;
    try {
        $connect = DB::getInstance()->connect();
    } catch (Exception $exc) {
        return Response::show(403, '数据库连接失败');
        // echo $exc->getTraceAsString();
    }
    //var_dump($connect);
    $result = mysql_query($sql, $connect);
    //var_dump($result);
    while ($row = mysql_fetch_assoc($result)) {
        $rows[] = $row;
    }
    if ($rows) {
        $cache->cacheData('cache' . $page . '-' . $pageSize, $rows, 10);
    }
}
//var_dump($rows);
if ($rows) {
    return Response::show(200, '首页获取数据成功', $rows);
} else {
    return Resonse::show(400, '首页数据获取失败');
}
Example #18
0
<?php

require_once '../..//models/Discovery.php';
require_once '../..//models/Response.php';
//获取发现页中的给爸/妈礼物数量
$re = new Discovery();
$data['father'] = $re->numForHuman(1);
$data['mother'] = $re->numForHuman(0);
echo Response::show('200', $data);
Example #19
0
 function test()
 {
     Response::show(00, 'this is test message');
 }
Example #20
0
<?php

error_reporting(0);
require_once '../../../models/subjectview.php';
require_once '../../../models/Response.php';
$re = new Response();
$name = $_POST['subjectName'];
$file = $_FILES;
$url = $_POST['subjectUrl'];
if (isset($name) && isset($file) & isset($url)) {
    $a = new SubjectView();
    if ($a->addSubject($name, $file, $url)) {
        header('Location:' . $_SERVER['HTTP_REFERER']);
    } else {
        echo $re->show(400);
    }
} else {
    echo $re->show(400);
}
Example #21
0
function cResponse($names)
{
    if ($names) {
        return Response::show(200, 'success', $names);
    } else {
        //return Response::show(404, 'not found:没找到数据!', $names);
        customJsonRes('404', 'not found:没找到数据!', 'null', 'null');
    }
}
Example #22
0
<?php

//物品详情相似物品推荐接口
error_reporting(E_ALL);
require_once '../../models/Response.php';
require_once '../../models/ItemsProfile.php';
$style = new Response();
if ($_GET['itemID'] && $_GET['page']) {
    $itemID = $_GET['itemID'];
    $pageID = $_GET['page'];
    $rec = new ItemsProfile();
    $data = $rec->relatedItems($itemID, $pageID);
    $res = new Response();
    echo $res->show('200', $data);
} else {
    echo Response::show('400');
}
Example #23
0
//require_once 'admin/itemImport.php';
$style = new Response();
if ($_GET['key'] && !$_GET['type']) {
    $data = array();
    $uid = isset($_GET['uid']) ? $_GET['uid'] : null;
    $page = isset($_GET['page']) ? $_GET['page'] : 1;
    $n = isset($_GET['limit']) ? $_GET['limit'] : null;
    $search = new Search();
    $like = new UserLikeModel();
    $re = $search->search($_GET['key'], $page, $uid, $n);
    while ($line = mysql_fetch_array($re, MYSQL_ASSOC)) {
        $line['islike'] = $like->checkUserLike($uid, $line['id']);
        $line['likesum'] = $like->itemLikeSum($line['id']);
        $data[] = $line;
    }
    echo $style->show(200, $data);
} elseif ($_GET['key'] && $_GET['type']) {
    $data = array();
    $uid = isset($_GET['uid']) ? $_GET['uid'] : null;
    $page = isset($_GET['page']) ? $_GET['page'] : 1;
    if (isset($_GET['type'])) {
        $type = type($_GET['type']);
    }
    $search = new Search();
    $like = new UserLikeModel();
    $re = $search->search_admin($_GET['key'], $type, $page);
    while ($line = mysql_fetch_array($re, MYSQL_ASSOC)) {
        $line['islike'] = $like->checkUserLike($uid, $line['id']);
        $line['likesum'] = $like->itemLikeSum($line['id']);
        $data[] = $line;
    }
Example #24
0
$page = isset($_GET['page']) ? $_GET['page'] : 1;
$pageSize = isset($_GET['pagesize']) ? $_GET['pagesize'] : 6;
if (!is_numeric($page) || !is_numeric($pageSize)) {
    return Response::show(401, '数据不合法');
}
$offset = ($page - 1) * $pageSize;
$sql = "select * from video where status = 1 order by orderby desc limit " . $offset . " , " . $pageSize;
$cache = new File();
$videos = array();
if (!($videos = $cache->cacheData('index_mk_cache' . $page . '-' . $pageSize))) {
    echo 1;
    exit;
    try {
        $connect = Db::getInstance()->connect();
    } catch (Exception $e) {
        // $e->getMessage();
        return Response::show(403, '数据库链接失败');
    }
    $result = mysql_query($sql, $connect);
    while ($video = mysql_fetch_assoc($result)) {
        $videos[] = $video;
    }
    if ($videos) {
        $cache->cacheData('index_mk_cache' . $page . '-' . $pageSize, $videos, 1200);
    }
}
if ($videos) {
    return Response::show(200, '首页数据获取成功', $videos);
} else {
    return Response::show(400, '首页数据获取失败', $videos);
}
Example #25
0
<?php

//搜索热词接口
require_once '../../models/Response.php';
require_once '../..//models/HotKeys.php';
$re = new HotKeys();
$data = $re->showKey();
$style = new Response();
echo $style->show(200, $data);