当前位置: 首页>>代码示例>>PHP>>正文


PHP Error::getRetString方法代码示例

本文整理汇总了PHP中Error::getRetString方法的典型用法代码示例。如果您正苦于以下问题:PHP Error::getRetString方法的具体用法?PHP Error::getRetString怎么用?PHP Error::getRetString使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Error的用法示例。


在下文中一共展示了Error::getRetString方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: control

    /**
     * 发送控制指令
     * 
     * @param params    params
     */
    protected static function control($params, $cmd)
    {
        if (!isset($params["mid"])) {
            return Error::getRetString(10007);
        }
        $mid = $params["mid"];
        $uuid = $_GET["uuid"];
        $udid = $_GET["udid"];
        $db = Db::init();
        //验证用户
        $user = $db->get_var("select user from user where uuid=\"{$uuid}\"");
        if (!isset($user)) {
            return Error::getRetString(10009);
        }
        //uuid无效
        if ($db->query(<<<EOD
select mid from device_modules where mid="{$mid}" and udid="{$udid}"
and exists(select udid from user_device where user="{$user}" and udid="{$udid}")
EOD
)) {
            //本地验证成功,开始与设备进行通信
            $string = file_get_contents("php://input");
            return self::sendToDevice($string, $uuid, $udid, $uuid);
            return Error::getRetString(0);
        } else {
            return Error::getRetString(10016);
        }
        return Error::getRetString(0, array("uuid" => $uuid, "udid" => $udid, "cmd" => $cmd));
    }
开发者ID:seathiefwang,项目名称:platserver,代码行数:34,代码来源:DeviceControl.php

示例2: _List

 /**
  * 
  * @param params    params
  */
 public static function _List($params)
 {
     $email = $_GET["u"];
     $db = Db::init();
     $notifies = array();
     $recs = $db->get_results("select mid,time from user_notify where email='{$email}'order by id DESC LIMIT 20 ");
     if (isset($recs[0])) {
         foreach ($recs as $mid) {
             $notifies[] = self::getInfo($mid->mid, $mid->time);
         }
     }
     return Error::getRetString(0, array("notifies" => $notifies));
 }
开发者ID:seathiefwang,项目名称:SmartServer,代码行数:17,代码来源:_Notify.php

示例3: _Login

 /**
  * 
  * @param params    params
  */
 public static function _Login($params)
 {
     if (is_array($params) && isset($params["account"])) {
         $account = $params["account"];
         $db = Db::init();
         $uuid = self::createUUID();
         if ($db->query("select email from user where email=\"{$account}\"")) {
             $db->query("update user set uuid=\"{$uuid}\" where email=\"{$account}\"");
             return Error::getRetString(0, array("uuid" => $uuid));
         }
     } else {
         return Error::getRetString(10007);
     }
 }
开发者ID:seathiefwang,项目名称:SmartServer,代码行数:18,代码来源:_User.php

示例4: onMessage

 /**
  * 处理请求事件
  * 
  * @param data
  * @param class_dir    class_dir
  */
 public static function onMessage($data, $class_dir)
 {
     // 判断数据是否正确
     if (empty($data['class']) || empty($data['method'])) {
         return json_encode(array('code' => 1, 'msg' => 'bad request', 'data' => null));
     }
     // 获得要调用的类、方法、及参数
     $class = $data['class'];
     $method = $data['method'];
     if (isset($data['params'])) {
         $param_array = $data['params'];
     } else {
         $param_array = array();
     }
     $class = "_" . $class;
     $method = "_" . $method;
     $success = false;
     // 判断类对应文件是否载入
     if (!class_exists($class)) {
         $include_file = $class_dir . "/{$class}.php";
         if (is_file($include_file)) {
             require_once $include_file;
         }
         if (!class_exists($class)) {
             $code = 33404;
             $msg = "class {$class} not found";
             // 发送数据给客户端 类不存在
             //var_dump($connection);
             //return json_encode(array('code'=>$code, 'msg'=>$msg));
             return Error::getRetString($code);
         }
     }
     // 调用类的方法
     try {
         $ret = call_user_func_array(array($class, $method), array($param_array));
         // 发送数据给客户端,调用成功,data下标对应的元素即为调用结果
         if (isset($ret)) {
             //var_dump($ret);
             return $ret;
         } else {
             //return json_encode(array('code'=>33405, 'msg'=>"Method $class.$method invoke error"));
             return Error::getRetString(33405);
         }
     } catch (Exception $e) {
         // 发送数据给客户端,发生异常,调用失败
         $code = $e->getCode() ? $e->getCode() : 500;
         return json_encode(array('code' => $code, 'msg' => $e->getMessage(), 'result' => $e));
     }
 }
开发者ID:seathiefwang,项目名称:SmartServer,代码行数:55,代码来源:Event.php

示例5: _List

 /**
  * 
  * @param params    params
  */
 public static function _List($params)
 {
     if (isset($params["pageNO"]) && isset($params["pageRecs"])) {
         $email = $_GET["u"];
         $db = Db::init();
         $notifies = array();
         $pageTotal = 0;
         $total = 0;
         $page = (int) $params["pageNO"];
         $limit = (int) $params["pageRecs"];
         //限制每页条数
         $offset = $page * $limit;
         $resmid = $db->get_results("select mid from udevice where email='{$email}'");
         if (isset($resmid[0])) {
             $tmp = $resmid[0]->mid;
             $cmd = " mid='{$tmp}' ";
             for ($i = 1; $i < count($resmid); $i++) {
                 $tmp = $resmid[$i]->mid;
                 $cmd = $cmd . "or mid='{$tmp}' ";
             }
             $recs = $db->get_results("select mid, did, email, time, msg from user_notify where {$cmd} order by id DESC LIMIT {$offset},{$limit} ");
             $total = (int) $db->get_var("select count(*) from user_notify where {$cmd} order by id");
             $pageTotal = ceil($total / $limit);
             if (isset($recs[0])) {
                 foreach ($recs as $rec) {
                     $_info = self::getInfo($rec);
                     if (isset($_info)) {
                         $notifies[] = $_info;
                     }
                 }
             }
         }
         return Error::getRetString(0, array("notifies" => $notifies, "pageTotal" => $pageTotal, "pageRecs" => $limit, "recsTotal" => $total));
     } else {
         return Error::getRetString(10007);
     }
 }
开发者ID:seathiefwang,项目名称:platserver,代码行数:41,代码来源:_Notify.php

示例6: onMessage

 public static function onMessage($data, $class_dir)
 {
     if (empty($data['class']) || empty($data['method'])) {
         return json_encode(array('code' => 1, 'msg' => 'bad_request'));
     }
     $class = $data['class'];
     $method = $data['method'];
     if (isset($data['params'])) {
         $params_array = $data['params'];
     } else {
         $params_array = array();
     }
     $class = '_' . $class;
     $method = '_' . $method;
     $success = false;
     if (!class_exists($class)) {
         $include_file = $class_dir . "/{$class}.php";
         if (is_file($include_file)) {
             require_once $include_file;
         } else {
             $code = 33404;
             $msg = "class {$class} not found";
             return Error::getRetString($code);
         }
     }
     try {
         $ret = call_user_func_array(array($class, $method), array($params_array));
         if (isset($ret)) {
             return $ret;
         } else {
             return Error::getRetString(33405);
         }
     } catch (Exception $e) {
         $code = $e->getCode() ? $e->getCode() : 500;
         return json_encode(array('code' => $code, 'msg' => $e->getMessage(), 'result' => $e));
     }
 }
开发者ID:seathiefwang,项目名称:platserver,代码行数:37,代码来源:Event.php

示例7: _List

 /**
  * 
  * @param params    params
  */
 public static function _List($params)
 {
     $db = Db::init();
     $email = $_GET["u"];
     $re = array("houses" => array());
     $results = $db->get_results("select houseid,name,mid,vercode from house where email=\"{$email}\"");
     if (isset($results[0])) {
         foreach ($results as $rec) {
             $re["houses"][] = array("houseid" => intval($rec->houseid), "name" => (string) $rec->name, "mid" => (string) $rec->mid, "vercode" => (string) $rec->vercode);
         }
     }
     return Error::getRetString(0, $re);
 }
开发者ID:seathiefwang,项目名称:SmartServer,代码行数:17,代码来源:_House.php

示例8: _List

    /**
     * 
     * @param params    params
     */
    public static function _List($params)
    {
        if (is_array($params) && isset($params["houseid"])) {
            $db = Db::init();
            $email = $_GET["u"];
            $houseid = $params["houseid"];
            $re = array("rooms" => array());
            $results = $db->get_results(<<<EOD
select roomid,name from room where houseid={$houseid} and exists(select houseid from house where houseid={$houseid} and email="{$email}") 
EOD
);
            if (isset($results[0])) {
                foreach ($results as $rec) {
                    $re["rooms"][] = array("roomid" => $rec->roomid * 1, "name" => $rec->name);
                }
            }
            return Error::getRetString(0, $re);
        } else {
            return Error::getRetString(10007);
        }
    }
开发者ID:seathiefwang,项目名称:SmartServer,代码行数:25,代码来源:_Room.php

示例9: _ListAll

 /**
  * 
  * @param params    params
  */
 public static function _ListAll($params)
 {
     $uuid = $_GET["uuid"];
     $db = Db::init();
     $user = $db->get_var("select user from user where uuid=\"{$uuid}\"");
     if (!isset($user)) {
         return Error::getRetString(10009);
     }
     //uuid无效
     $re = array("rooms" => array());
     $results = $db->get_results("select roomid,name from user_room where user=\"{$user}\"");
     if (isset($results[0])) {
         foreach ($results as $rec) {
             $roomid = $rec->roomid * 1;
             $list = array();
             $modules = $db->get_results("select * from device_modules where roomid={$roomid}");
             //有模块
             if (isset($modules[0])) {
                 foreach ($modules as $mod) {
                     $ch_info = array();
                     $m = $mod->mid;
                     $children = $db->get_results("select * from device_modules_child where mid=\"{$m}\" order by no");
                     foreach ($children as $child) {
                         $ch_name = $child->name;
                         $ch_no = $child->no * 1;
                         $ch_info[] = array("no" => $ch_no, "name" => $ch_name);
                     }
                     $list[] = array("udid" => $mod->udid, "mid" => $mod->mid, "devclass" => $mod->type, "name" => $ch_info);
                 }
             }
             $re["rooms"][] = array("roomid" => $roomid, "name" => $rec->name, "devices" => $list);
         }
     }
     return Error::getRetString(0, $re);
 }
开发者ID:seathiefwang,项目名称:SmartServer,代码行数:39,代码来源:_Modules.php

示例10: _Excute

 /**
  * 执行情景模式
  * 
  * @param params    params
  */
 public static function _Excute($params)
 {
     return Error::getRetString(0);
 }
开发者ID:seathiefwang,项目名称:platserver,代码行数:9,代码来源:_Assistant.php

示例11: _Rename

    /**
     * 
     * @param params    参数列表
     */
    public static function _Rename($params)
    {
        if (is_array($params) && isset($params["user"]) && isset($params["udid"]) && isset($params["name"])) {
            $user = $params["user"];
            $name = $params["name"];
            $uuid = $_GET["uuid"];
            $udid = $params["udid"];
            $db = Db::init();
            //执行主机改名
            if ($db->query(<<<EOD
update user_device set name="{$name}" WHERE EXISTS(SELECT user FROM user WHERE uuid="{$uuid}" and user="{$user}" and priv=3) and user="{$user}" and udid="{$udid}";
EOD
)) {
                return Error::getRetString(0);
            } else {
                return Error::getRetString(10016);
            }
        } else {
            return Error::getRetString(10007);
        }
    }
开发者ID:seathiefwang,项目名称:SmartServer,代码行数:25,代码来源:_Device.php

示例12: _List

    /**
     * 
     * @param params    params
     */
    public static function _List($params)
    {
        if (is_array($params) && isset($params["mid"]) && isset($params["vercode"])) {
            $db = Db::init();
            $email = $_GET["u"];
            $mid = $params["mid"];
            $vercode = $params["vercode"];
            $re = array("rooms" => array());
            $results = $db->get_results(<<<EOD
select roomid,name from room where mid='{$mid}' and exists(select mid from mdevice where mid='{$mid}' and vercode='{$vercode}') 
EOD
);
            if (isset($results[0])) {
                foreach ($results as $rec) {
                    $re["rooms"][] = array("roomid" => $rec->roomid * 1, "name" => $rec->name);
                }
            }
            return Error::getRetString(0, $re);
        } else {
            return Error::getRetString(10007);
        }
    }
开发者ID:seathiefwang,项目名称:platserver,代码行数:26,代码来源:_Room.php

示例13: header

<?php

require_once __DIR__ . "/../libs/Event.php";
require_once __DIR__ . "/../libs/Error.php";
require_once __DIR__ . "/../db/Db.php";
header('Expires: Mon, 26 Jul 1997 05:00:00 GMT');
header('Last-Modified: ' . gmdate('D, d M Y H:i:s') . 'GMT');
header('Cache-Control: no-cache, must-revalidate');
header('Pragma: no-cache');
if (!isset($_GET["u"])) {
    exit(Error::getRetString(1));
}
$json_string = file_get_contents("php://input");
// $json_string = $GLOBALS['HTTP_RAW_POST_DATA'];
$array = json_decode($json_string, true);
echo Event::onMessage($array, __DIR__ . "/../base/");
// file_put_contents("./test.txt", $_GET["u"]."\n".$json_string, FILE_APPEND);
开发者ID:seathiefwang,项目名称:platserver,代码行数:17,代码来源:base.php

示例14: _GetInfo

    /**
     * 
     * @param params    params
     */
    public static function _GetInfo($params)
    {
        if (isset($params["email"])) {
            $db = Db::init();
            $email = $params["email"];
            //是否已存在
            if (!$db->query(<<<EOD
select email from user where email="{$email}"
EOD
)) {
                return Error::getRetString(10020);
            }
            $info = $db->get_row("select * from user where email='{$email}'");
            return Error::getRetString(0, array("name" => $info->name, "email" => $info->email, "sex" => $info->sex, "phone" => $info->phone, "QQ" => $info->QQ, "address" => $info->address));
        } else {
            return Error::getRetString(10007);
        }
    }
开发者ID:seathiefwang,项目名称:platserver,代码行数:22,代码来源:_User.php

示例15: _VerifyUUID

 public static function _VerifyUUID($params)
 {
     if (is_array($params) && isset($params['uuid']) && isset($params['email'])) {
         $uuid = $params['uuid'];
         $email = $params['email'];
         $db = Db::init();
         if ($db->query("select email from user where email=\"{$email}\"")) {
             $results = $db->get_result("select uuid from user where email=\"{$email}\"");
             if (isset($results[0])) {
                 foreach ($results as $re) {
                     if ($re['uuid'] === $uuid) {
                         $results = $db->get_result("select mid,vercode,name from udevice where email=\"{$email}\"");
                         return Error::getRetString(0, results);
                     }
                 }
             }
         } else {
             return Error::getRetString(10007);
         }
     }
 }
开发者ID:seathiefwang,项目名称:platserver,代码行数:21,代码来源:User.php


注:本文中的Error::getRetString方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。