예제 #1
0
파일: topicpost.php 프로젝트: caidongyun/CS
function checklogin()
{
    $login = new Login();
    $json = new JSON();
    if (!$login->check($_POST['sid'])) {
        $code = '200';
        $data_array[0] = array('result' => 'login first');
        $json_string = $json->ArrayGetjson($data_array, $code);
        echo $json_string;
        die;
    }
    return true;
}
예제 #2
0
파일: advice.php 프로젝트: caidongyun/CS
    }
    $sql = "INSERT INTO `" . DB_PRE . "count_install_app` (`uip`, `time`, `hardtype`) VALUES ('" . $uip . "', '" . $time . "', '" . $hardtypein . "');";
    $result = $db->query($sql);
    if ($result) {
        $code = 200;
        $end = 'count succ';
    } else {
        $code = 500;
        $end = 'count failed';
    }
} else {
    $code = 404;
    $end = 'unknown error';
}
if (!empty($code) && !empty($end)) {
    $json_string = $json->ArrayGetjson(array(array('result' => $end)), $code);
    echo $json_string;
}
//获取ip
function getip()
{
    if (!empty($_SERVER["HTTP_CLIENT_IP"])) {
        $cip = $_SERVER["HTTP_CLIENT_IP"];
    } else {
        if (!empty($_SERVER["HTTP_X_FORWARDED_FOR"])) {
            $cip = $_SERVER["HTTP_X_FORWARDED_FOR"];
        } else {
            if (!empty($_SERVER["REMOTE_ADDR"])) {
                $cip = $_SERVER["REMOTE_ADDR"];
            } else {
                $cip = "";
예제 #3
0
파일: topiclist.php 프로젝트: caidongyun/CS
            $str = 'ORDER BY lastpost desc';
            break;
    }
    return $str;
}
if ($type == '') {
    echo 'param error';
    exit;
}
//实例化类
$topic = new Topic();
$db = new DB();
$json = new JSON();
$order_array = array('second1', 'second2', 'second3', 'second4', 'second5', 'second6', 'index2', 'index4', 'index5', 'third1', 'third2', 'third3', 'third4', 'third5', 'third6', 'thread_list', 'top_thread', 'digest_thread');
if ($type == 'top_name_list') {
    echo $json->ArrayGetjson($name_array, '200');
    exit;
}
if ($type == 'thread_detail' && $addtype == 'only_owner') {
    $authorid_sql = $topic->getSql('owner_authorid');
    $owner_info = $db->fetch_all($authorid_sql);
    $authorid = $owner_info[0]['authorid'];
    $_GET['authorid'] = $authorid;
}
if ($type == 'thread_detail') {
    $sql = $topic->getSql('thread_detail_getpid', $pageno, $pagesize, '', $addtype);
} else {
    $sql = $topic->getSql($type, $pageno, $pagesize, '', $addtype);
}
if (in_array($type, $order_array)) {
    switch ($type) {
예제 #4
0
<?php

require_once './class/db.class.php';
require_once './class/json.class.php';
if (UCDBON == 1) {
    require_once 'dbuc.class.php';
}
$db = new DB();
$json = new JSON();
//存储ios设备device token的接口API
$len = strlen($_POST['token']);
if ($len == 64) {
    $sql = "INSERT INTO `" . DB_PRE . "common_devicetoken` (`token`) VALUES('" . $_POST['token'] . "')";
    $result = $db->query($sql);
    if ($result) {
        $code = '200';
        $data_array[0] = array('result' => 'token save succ');
    } else {
        $code = '200';
        $data_array[0] = array('result' => 'token save failed');
    }
} else {
    $code = '200';
    $data_array[0] = array('result' => 'input token error');
}
$json_string = $json->ArrayGetjson($data_array, $code);
echo $json_string;
예제 #5
0
 function doLogin($acc = '', $pw = '')
 {
     $dbl = new DB();
     $json = new JSON();
     if (strtoupper(DBCHARSET) == 'GBK') {
         $acc = mb_convert_encoding($acc, 'GBK', 'UTF-8');
     }
     //查用户名
     if (UCDBON == 1) {
         $db = new DBUC();
         $sql = "SELECT uid,username,password,salt FROM `" . UC_PRE . "members` WHERE username = '******'";
         $pwcheck = $db->fetch_all($sql);
     } else {
         $sql = "SELECT uid,username,password,salt FROM `" . UC_PRE . "members` WHERE username = '******'";
         $pwcheck = $dbl->fetch_all($sql);
     }
     //判断是否是GBK编码的数据库
     if (strtoupper($dbcharset) == 'GBK') {
         if (!empty($pwcheck[0])) {
             foreach ($pwcheck[0] as $k => $v) {
                 $pwcheck[0][$k] = mb_convert_encoding($v, 'GBK', 'UTF-8');
             }
         }
     }
     if (!empty($pwcheck)) {
         if (md5($pw . $pwcheck[0]['salt']) == $pwcheck[0]['password']) {
             //查是否登陆过
             $sql = "SELECT sid FROM `" . DB_PRE . "common_session_app` WHERE uid = '" . $pwcheck[0]['uid'] . "'";
             $sescheck = $dbl->fetch_all($sql);
             if (empty($sescheck)) {
                 //设置sid
                 $sql = "INSERT INTO `" . DB_PRE . "common_session_app` (`sid`, `ip`, `uid`, `username`, `lastlogin`) VALUES ('" . md5($pwcheck[0]['password'] . time()) . "', '" . $_SERVER['REMOTE_ADDR'] . "', '" . $pwcheck[0]['uid'] . "', '" . $pwcheck[0]['username'] . "', '" . time() . "');";
                 $sesset = $dbl->query($sql);
                 if ($sesset) {
                     $sid = md5($pwcheck[0]['password'] . time());
                 } else {
                     $sid = 500;
                 }
             } else {
                 //更新最近登陆时间
                 $sql = "UPDATE `" . DB_PRE . "common_session_app` SET `lastlogin` = '" . time() . "' WHERE `sid` = '" . $sescheck[0]['sid'] . "'";
                 $upsid = $dbl->query($sql);
                 if ($upsid) {
                     $sid = $sescheck[0]['sid'];
                 } else {
                     $sid = 500;
                 }
             }
         } else {
             $sid = 'aperror';
         }
     } else {
         $sid = 'aperror';
     }
     //输出json
     if (empty($sid)) {
         $code = '404';
         $data_array = array();
     } else {
         if (!empty($sid)) {
             $code = '200';
             $data_array[0] = array('sessionid' => $sid, 'uid' => $pwcheck[0]['uid'], 'groupid' => $pwcheck[0]['groupid']);
         } elseif ($sid == 500) {
             $code = '500';
             $data_array = array();
         }
     }
     $json_string = $json->ArrayGetjson($data_array, $code);
     echo $json_string;
 }