/** * @brief 设置数据库读写分离并且执行SQL语句 * @param string $sql 要执行的SQL语句 * @return int or bool SQL语句执行的结果 */ public function query($sql) { //取得SQL类型 self::$sqlType = $this->getSqlType($sql); //读方式 if (self::$sqlType == 'select' || self::$sqlType == 'show') { if (self::$rTarget == NULL || !is_resource(self::$rTarget)) { //多数据库支持并且读写分离 if (isset(IWeb::$app->config['DB']['read'])) { //获取ip地址 $ip = IClient::getIP(); $this->connect(IHash::hash(IWeb::$app->config['DB']['read'], $ip)); } else { $this->connect(IWeb::$app->config['DB']); } self::$rTarget = $this->linkRes; } } else { if (self::$wTarget == NULL || !is_resource(self::$wTarget)) { //多数据库支持并且读写分离 if (isset(IWeb::$app->config['DB']['write'])) { $this->connect(IWeb::$app->config['DB']['write']); } else { $this->connect(IWeb::$app->config['DB']); } self::$wTarget = $this->linkRes; } } if (is_resource($this->linkRes)) { return $this->doSql($sql); } else { return false; } }
/** * @brief 构造函数 * @param string $ctrlId 控制器ID标识符 * @param string $module 控制器所包含的模块 */ public function __construct($module, $controllerId) { $this->module = $module; $this->ctrlId = $controllerId; //初始化theme方案 if (isset($this->module->config['theme'])) { //根据不同的客户端进行智能选择 if (is_array($this->module->config['theme'])) { $client = IClient::getDevice(); $this->theme = isset($this->module->config['theme'][$client]) ? $this->module->config['theme'][$client] : current($this->module->config['theme']); } else { $this->theme = $this->module->config['theme']; } } //初始化skin方案 if (isset($this->module->config['skin'])) { //根据不同的客户端进行智能选择 if (is_array($this->module->config['skin'])) { $client = IClient::getDevice(); $this->skin = isset($this->module->config['skin'][$client]) ? $this->module->config['skin'][$client] : current($this->module->config['skin']); } else { $this->skin = $this->module->config['skin']; } } //初始化lang方案 $this->lang = $this->module->language; //修正runtime配置 $this->module->runtimePath = $this->module->getRuntimePath() . $this->theme . '/'; $this->module->webRunPath = $this->module->getWebRunPath() . $this->theme . '/'; }
/** * @brief 发送短信 * @param string $mobile 手机号 * @param string $content 短信内容 * @param int $delay 延迟设置 * @return success or fail */ public static function send($mobile, $content, $delay = 1) { if (self::$smsInstance == null) { $platform = self::getPlatForm(); switch ($platform) { case "zhutong": $classFile = IWeb::$app->getBasePath() . 'plugins/hsms/zhutong.php'; require $classFile; self::$smsInstance = new zhutong(); break; default: $classFile = IWeb::$app->getBasePath() . 'plugins/hsms/haiyan.php'; require $classFile; self::$smsInstance = new haiyan(); } } if (IValidate::mobi($mobile) && $content) { $ip = IClient::getIp(); if ($ip) { if ($delay == 1) { $mobileKey = md5($ip); $sendTime = ISession::get($mobileKey); if ($sendTime && time() - $sendTime < 60) { return false; } ISession::set($mobileKey, time()); } return self::$smsInstance->send($mobile, $content); } } return false; }
/** * @brief theme和skin进行选择 */ public static function onCreateController() { $controller = func_num_args() > 0 ? func_get_arg(0) : IWeb::$app->controller; //判断是否为后台管理控制器 if (in_array($controller->getId(), self::$syscontroller)) { defined("IWEB_SCENE") ? "" : define("IWEB_SCENE", self::SCENE_SYSDEFAULT); $controller->theme = self::$sysTheme; $controller->skin = self::$sysSkin; } elseif (in_array($controller->getId(), self::$sellercontroller)) { defined("IWEB_SCENE") ? "" : define("IWEB_SCENE", self::SCENE_SYSSELLER); $controller->theme = self::$sysSellerTheme; $controller->skin = self::$sysSellerSkin; } else { defined("IWEB_SCENE") ? "" : define("IWEB_SCENE", self::SCENE_SITE); /** * 对于theme和skin的判断流程 * 1,直接从URL中获取是否已经设定了方案__theme,__skin * 2,获取cookie中的方案名称 * 3,读取config配置中的默认方案 */ $urlTheme = IReq::get('__theme'); $urlSkin = IReq::get('__skin'); if ($urlTheme && $urlSkin && preg_match('|^\\w+$|', $urlTheme) && preg_match('|^\\w+$|', $urlSkin)) { ISafe::set('__theme', $controller->theme = $urlTheme); ISafe::set('__skin', $controller->skin = $urlSkin); } elseif (ISafe::get('__theme') && ISafe::get('__skin')) { $controller->theme = ISafe::get('__theme'); $controller->skin = ISafe::get('__skin'); } else { if (isset(IWeb::$app->config['theme'])) { //根据不同的客户端进行智能选择 if (is_array(IWeb::$app->config['theme'])) { $client = IClient::getDevice(); $controller->theme = isset(IWeb::$app->config['theme'][$client]) ? IWeb::$app->config['theme'][$client] : current(IWeb::$app->config['theme']); } else { $controller->theme = IWeb::$app->config['theme']; } } if (isset(IWeb::$app->config['skin'])) { //根据不同的客户端进行智能选择 if (is_array(IWeb::$app->config['skin'])) { $client = IClient::getDevice(); $controller->skin = isset(IWeb::$app->config['skin'][$client]) ? IWeb::$app->config['skin'][$client] : current(IWeb::$app->config['skin']); } else { $controller->skin = IWeb::$app->config['skin']; } } } } //修正runtime配置 IWeb::$app->runtimePath = IWeb::$app->getRuntimePath() . $controller->theme . '/'; IWeb::$app->webRunPath = IWeb::$app->getWebRunPath() . $controller->theme . '/'; }
function login_act() { $admin_name = IFilter::act(IReq::get('admin_name')); $password = IReq::get('password'); $captcha = IReq::get('captcha', 'post'); $message = ''; if ($admin_name == '') { $message = '登录名不能为空'; } else { if ($password == '') { $message = '密码不能为空'; } else { if ($captcha != ISafe::get('Captcha')) { $message = '验证码输入不正确'; } else { $adminObj = new IModel('admin'); $adminRow = $adminObj->getObj('admin_name = "' . $admin_name . '"'); if (!empty($adminRow) && $adminRow['password'] == md5($password) && $adminRow['is_del'] == 0) { $dataArray = array('last_ip' => IClient::getIp(), 'last_time' => ITime::getDateTime()); $adminObj->setData($dataArray); $where = 'id = ' . $adminRow["id"]; $adminObj->update($where); //根据角色分配权限 if ($adminRow['role_id'] == 0) { ISafe::set('admin_right', 'administrator'); ISafe::set('admin_role_name', '超级管理员'); } else { $roleObj = new IModel('admin_role'); $where = 'id = ' . $adminRow["role_id"] . ' and is_del = 0'; $roleRow = $roleObj->getObj($where); ISafe::set('admin_right', $roleRow['rights']); ISafe::set('admin_role_name', $roleRow['name']); } ISafe::set('admin_id', $adminRow['id']); ISafe::set('admin_name', $adminRow['admin_name']); ISafe::set('admin_pwd', $adminRow['password']); $this->redirect('/system/default'); } else { $message = '用户名与密码不匹配'; } } } } if ($message != '') { $this->admin_name = $admin_name; $this->redirect('index', false); Util::showMessage($message); } }
/** * @brief 设置数据库读写分离并且执行SQL语句 * @param string $sql 要执行的SQL语句 * @return int or bool SQL语句执行的结果 */ public function query($sql) { //取得SQL类型 self::$sqlType = $this->getSqlType($sql); //读方式 if (self::$sqlType == 'select' || self::$sqlType == 'show') { if (self::$rTarget == NULL) { //多数据库支持并且读写分离 if (isset(IWeb::$app->config['DB']['read'])) { //获取ip地址 $ip = IClient::getIP(); self::$rTarget = $this->connect(IHash::hash(IWeb::$app->config['DB']['read'], $ip)); } else { self::$rTarget = $this->connect(IWeb::$app->config['DB']); } } $this->switchLink("r"); $result = $this->doSql($sql); if ($result === false) { throw new IException("{$sql}\n -- " . $this->linkRes->error, 1000); return false; } return $result; } else { if (self::$wTarget == NULL) { //多数据库支持并且读写分离 if (isset(IWeb::$app->config['DB']['write'])) { self::$wTarget = $this->connect(IWeb::$app->config['DB']['write']); } else { self::$wTarget = $this->connect(IWeb::$app->config['DB']); } //写链接启用事务 $this->switchLink("w"); $this->autoCommit(); } $this->switchLink("w"); $result = $this->doSql($sql); if ($result === false) { $errorMsg = $this->linkRes->error; $this->rollback(); throw new IException("{$sql}\n -- " . $errorMsg, 1000); return false; } return $result; } }
function adminlogin() { $signup_name = IFilter::act(IReq::get('signup_name')); $signup_password = IFilter::act(IReq::get('signup_password')); if (!empty($signup_name)) { $userinfo = $this->mysql->select_one("select * from " . Mysite::$app->config['tablepre'] . "admin where username ='******'"); if (empty($signup_password)) { $this->message('signup_password_tip'); } if ($userinfo['password'] != md5($signup_password)) { $this->message('signup_password_tip'); } $data['loginip'] = IClient::getIp(); $data['logintime'] = time(); $this->mysql->update(Mysite::$app->config['tablepre'] . 'admin', $data, "uid='" . $userinfo['uid'] . "'"); ICookie::set('adminname', $userinfo['username'], 86400); ICookie::set('adminpwd', $signup_password, 86400); ICookie::set('adminuid', $userinfo['uid'], 86400); $this->success('操作成功'); } }
public function getPaymentListByOnline() { $where = " type = 1 and status = 0 and class_name not in ('balance','offline') "; switch (IClient::getDevice()) { //移动支付 case IClient::MOBILE: $where .= ' and client_type in(2,3) '; //如果不是微信客户端,去掉微信专用支付 if (IClient::isWechat() == false) { $where .= " and class_name != 'wap_wechat'"; } break; //pc支付 //pc支付 case IClient::PC: $where .= ' and client_type in(1,3) '; break; } $paymentDB = new IModel('payment'); return $paymentDB->query($where); }
function Iptoposition($coor = 'bd09ll') { //样式 若需要返回百度墨卡托坐标 则初始化值时候 new baidumap(''); new baidumap() 则返回百度百度经纬度坐标 $this->shorturl = '/location/ip'; $this->intparam(); //初始化参数 $this->param['ip'] = IClient::getIp(); // $this->caculateAKSN();//获取SN 不要签名 ksort($this->param); $this->param['coor'] = $coor; //设置返坐标 $info = $this->dolink(); if (isset($info['status'])) { if ($info['status'] == 0) { return $info['content']['address_detail']['city']; } else { return ''; } } else { return ''; } }
function regester($email, $tname, $password, $phone, $group, $userlogo = '', $address = '', $cost = 0, $score = 0) { if (empty($email) && empty($phone)) { $this->error = '邮箱和手机不能同时为空'; return false; } if (!empty($email)) { if (!IValidate::email($email)) { $this->error = '邮箱格式错误'; return false; } $userinfo = $this->mysql->select_one("select * from " . Mysite::$app->config['tablepre'] . "member where email='" . $email . "' "); if (!empty($userinfo)) { $this->error = '邮箱已存在,不可注册'; return false; } } if (!empty($phone)) { if (!IValidate::suremobi($phone)) { $this->error = '手机格式错误'; return false; } $userinfo = $this->mysql->select_one("select * from " . Mysite::$app->config['tablepre'] . "member where phone='" . $phone . "' "); if (!empty($userinfo)) { $this->error = '手机已存在,不可注册'; return false; } } if (!IValidate::len($tname, 3, 20)) { //$this->error = '用户名长度大于3小于20'.$tname; //return false; } if (!IValidate::len($password, 6, 20)) { $this->error = '密码长度大于6小于20'; return false; } $userinfo = $this->mysql->select_one("select * from " . Mysite::$app->config['tablepre'] . "member where username='******' "); if (!empty($userinfo)) { //$this->error = '用户名已存在,不可注册'; //return false; } $arr['username'] = $tname; $arr['phone'] = $phone; $arr['address'] = $address; $arr['password'] = md5($password); $arr['email'] = $email; $arr['creattime'] = time(); $arr['score'] = $score == 0 ? Mysite::$app->config['regesterscore'] : $score; $arr['logintime'] = time(); $arr['logo'] = $userlogo; $arr['loginip'] = IClient::getIp(); $arr['group'] = $group; $arr['cost'] = $cost; $arr['parent_id'] = intval(ICookie::get('logincode')); $this->mysql->insert(Mysite::$app->config['tablepre'] . 'member', $arr); $this->uid = $this->mysql->insertid(); if ($arr['score'] > 0) { $this->addlog($this->uid, 1, 1, $arr['score'], '注册送积分', '注册送积分' . $arr['score'], $arr['score']); } $logintype = ICookie::get('adlogintype'); $token = ICookie::get('adtoken'); $openid = ICookie::get('adopenid'); if (!empty($logintype)) { $apiinfo = $this->mysql->select_one("select * from " . Mysite::$app->config['tablepre'] . "otherlogin where loginname='" . $logintype . "' "); if (!empty($apiinfo)) { //更新 $tempuid = $this->uid; $this->mysql->update(Mysite::$app->config['tablepre'] . 'oauth', array('uid' => $tempuid), "openid='" . $openid . "' and type = '" . $logintype . "'"); ICookie::set('logintype', $logintype, 86400); } } if (Mysite::$app->config['regester_juan'] == 1) { //注册送优惠券 $nowtime = time(); $endtime = $nowtime + Mysite::$app->config['regester_juanday'] * 24 * 60 * 60; $juandata['card'] = $nowtime . rand(100, 999); $juandata['card_password'] = substr(md5($juandata['card']), 0, 5); $juandata['status'] = 1; // 状态,0未使用,1已绑定,2已使用,3无效 $juandata['creattime'] = $nowtime; // 制造时间 $juandata['cost'] = Mysite::$app->config['regester_juancost']; // 优惠金额 $juandata['limitcost'] = Mysite::$app->config['regester_juanlimit']; // 购物车限制金额下限 $juandata['endtime'] = $endtime; // 失效时间 $juandata['uid'] = $this->uid; // 用户ID $juandata['username'] = $arr['username']; // 用户名 $juandata['name'] = '注册账号赠送优惠券'; // 优惠券名称 $this->mysql->insert(Mysite::$app->config['tablepre'] . 'juan', $juandata); } return true; }
echo isset($item['version']) ? $item['version'] : ""; ?> </td></tr> <tr><th>时间:</th><td><?php echo isset($item['time']) ? $item['time'] : ""; ?> </td></tr> <tr><th>简介:</th><td><?php echo isset($item['info']) ? $item['info'] : ""; ?> </td></tr> <tr> <th>操作:</th> <td> <?php foreach (IClient::supportClient() as $key => $client) { ?> <a href="<?php echo IUrl::creatUrl("/system/applyTheme/theme/" . $theme . "/client/" . $client . ""); ?> " class='orange'>立即应用于<?php echo isset($client) ? $client : ""; ?> 端</a> <?php } ?> <?php if (Common::isThemeUsed($theme)) {
/** * @brief 得到session安全码 * @return String session安全码 */ private static function sessionId() { $level = self::getLevel(); if ($level == 'none') { return ''; } else { if ($level == 'normal') { return md5(IClient::getIP()); } } return md5(IClient::getIP() . $_SERVER["HTTP_USER_AGENT"]); }
/** * @brief 商品上下架 */ function goods_stats() { //post数据 $id = IFilter::act(IReq::get('id'), 'int'); $type = IFilter::act(IReq::get('type')); //生成goods对象 $tb_goods = new IModel('goods'); if ($type == 'up') { $updateData = array('is_del' => 0, 'up_time' => ITime::getDateTime(), 'down_time' => null); } else { if ($type == 'down') { $updateData = array('is_del' => 2, 'up_time' => null, 'down_time' => ITime::getDateTime()); } else { if ($type == 'check') { $updateData = array('is_del' => 3, 'up_time' => null, 'down_time' => null); } } } $tb_goods->setData($updateData); if ($id) { $tb_goods->update(Util::joinStr($id)); } else { Util::showMessage('请选择要操作的数据'); } if (IClient::isAjax() == false) { $this->redirect("goods_list"); } }
} else { ICookie::set('adlogintype', $logintype, 86400); ICookie::set('adtoken', $acs, 86400); ICookie::set('adopenid', $opid, 86400); ICookie::set('nickname', $opid, 86400); } } else { if ($uid > 0) { $link = IUrl::creatUrl('member/base'); /*跳转到用户中心*/ } else { $userinfo = $this->mysql->select_one("select * from " . Mysite::$app->config['tablepre'] . "member where uid = '" . $oauthinfo['uid'] . "'"); if (empty($userinfo)) { $this->message('账号未查找到,关联账号是否被删除'); } $data['loginip'] = IClient::getIp(); $data['logintime'] = time(); $checktime = date('Y-m-d', time()); $checktime = strtotime($checktime); if ($userinfo['logintime'] < $checktime) { if (Mysite::$app->config['loginscore'] > 0) { $data['score'] = $userinfo['score'] + Mysite::$app->config['loginscore']; $mess['content'] = '用户登陆赠送积分' . Mysite::$app->config['loginscore'] . '总积分' . $data['score']; $this->memberCls->addlog($userinfo['uid'], 1, 1, Mysite::$app->config['loginscore'], '每天登陆', $mess['content'], $data['score']); // $this->mysql->insert(Mysite::$app->config['tablepre']."message",$mess); } } $this->mysql->update(Mysite::$app->config['tablepre'] . 'member', $data, "uid='" . $userinfo['uid'] . "'"); ICookie::set('logintype', $logintype, 86400); ICookie::set('uid', $userinfo['uid'], 86400); $link = IUrl::creatUrl('member/base');
/** * @brief Ajoute un client à la liste du serveur * @param $client IClient un objet encapsulant la socket du client * @return void */ public function bindClient(IClient &$client) { $uid = md5(uniqid(rand())); while (array_key_exists($uid, $this->_clients)) { $uid = md5(uniqid(rand())); } $client->setUID($uid); $this->_clients[$uid] =& $client; }
/** * Get server connection object to perform requests * @param boolean $recreate_object force to recreate object * @return ClientRequester server requester */ public static function server($recreate_object = false) { if (self::$client_requester == null || $recreate_object == true) { // include php file $dir = self::Instance()->get_module_dir(); require_once $dir . 'ClientRequester.php'; // create object self::$client_requester = new ClientRequester(self::get_server_url()); self::$client_requester->set_client_license_key(self::get_license_key()); } return self::$client_requester; }
function regesterTem($email = "", $mobile, $group = "5", $userlogo = '', $addressdet, $cost = 0, $score = 0) { if (!empty($mobile)) { $userinfo = $this->mysql->select_one("select * from " . Mysite::$app->config['tablepre'] . "member where phone='" . $mobile . "' "); if (!empty($userinfo)) { return false; } } $password = '******' . rand(0, 9) . rand(0, 9) . rand(0, 9) . rand(0, 9) . rand(0, 9) . rand(0, 9); $arr['username'] = $mobile; $arr['phone'] = $mobile; $arr['address'] = $addressdet; $arr['password'] = md5($password); $arr['email'] = $email; $arr['creattime'] = time(); $arr['score'] = $score == 0 ? Mysite::$app->config['regesterscore'] : $score; $arr['logintime'] = time(); $arr['logo'] = $userlogo; $arr['loginip'] = IClient::getIp(); $arr['group'] = $group; $arr['cost'] = $cost; $arr['parent_id'] = intval(ICookie::get('logincode')); $this->mysql->insert(Mysite::$app->config['tablepre'] . 'member', $arr); $this->uid = $this->mysql->insertid(); if ($arr['score'] > 0) { $this->addlog($this->uid, 1, 1, $arr['score'], '注册送积分', '注册送积分' . $arr['score'], $arr['score']); } $logintype = ICookie::get('adlogintype'); $token = ICookie::get('adtoken'); $openid = ICookie::get('adopenid'); if (!empty($logintype)) { $apiinfo = $this->mysql->select_one("select * from " . Mysite::$app->config['tablepre'] . "otherlogin where loginname='" . $logintype . "' "); if (!empty($apiinfo)) { //更新 $tempuid = $this->uid; $this->mysql->update(Mysite::$app->config['tablepre'] . 'oauth', array('uid' => $tempuid), "openid='" . $openid . "' and type = '" . $logintype . "'"); ICookie::set('logintype', $logintype, 31536000); } } if (Mysite::$app->config['regester_juan'] == 1) { //注册送优惠券 $nowtime = time(); $endtime = $nowtime + Mysite::$app->config['regester_juanday'] * 24 * 60 * 60; $juandata['card'] = $nowtime . rand(100, 999); $juandata['card_password'] = substr(md5($juandata['card']), 0, 5); $juandata['status'] = 1; // 状态,0未使用,1已绑定,2已使用,3无效 $juandata['creattime'] = $nowtime; // 制造时间 $juandata['cost'] = Mysite::$app->config['regester_juancost']; // 优惠金额 $juandata['limitcost'] = Mysite::$app->config['regester_juanlimit']; // 购物车限制金额下限 $juandata['endtime'] = $endtime; // 失效时间 $juandata['uid'] = $this->uid; // 用户ID $juandata['username'] = $arr['username']; // 用户名 $juandata['name'] = '注册账号赠送优惠券'; // 优惠券名称 $res = $this->mysql->insert(Mysite::$app->config['tablepre'] . 'juan', $juandata); } ICookie::set('memberpwd', $password, 86400 * 365); ICookie::set('membername', $mobile, 86400 * 365); ICookie::set('uid', $this->uid, 86400 * 365); return true; }
/** * @param Request * @return Response */ protected function process(Request $request) { return $this->client->process($request); }
public function __construct(IClient &$client) { parent::__construct(); $this->_clientControl =& $client; $client->addEventListener($this); }