當前位置: 首頁>>代碼示例>>PHP>>正文


PHP I函數代碼示例

本文整理匯總了PHP中I函數的典型用法代碼示例。如果您正苦於以下問題:PHP I函數的具體用法?PHP I怎麽用?PHP I使用的例子?那麽, 這裏精選的函數代碼示例或許可以為您提供幫助。


在下文中一共展示了I函數的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1: lists

 public function lists($productId)
 {
     if (IS_AJAX) {
         $page_size = 10;
         $page = I('page', 1, 'intval');
         $start = ($page - 1) * $page_size;
         $map = array('product_id' => $productId, 'status' => 1);
         $ProductBid = M('ProductBid');
         $total_count = $ProductBid->where($map)->count();
         if ($total_count) {
             $total_page = ceil($total_count / $page_size);
             $bid_list = $ProductBid->where($map)->order('bid_id desc')->limit($start . ',' . $page_size)->select();
             $User = M('User');
             foreach ($bid_list as $key => $value) {
                 $bid_list[$key]['user_info'] = $User->find($value['user_id']);
             }
             $this->assign('bid_list', $bid_list);
             $product_info = M('Product')->where($map)->find();
             $this->assign('product_info', $product_info);
             $range_price = $product_info['range_price'];
             $content = $this->fetch('ajaxLists');
             if ($product_info['product_type'] == 3) {
                 $value = array('info' => array('currentPrice' => $product_info['range_price'], 'bidPrice' => $product_info['range_price'], 'lastId' => 1), 'htmlString' => $content, 'isNextPage' => $total_page == 1 || $total_page == $page ? false : true, 'page' => $page, 'pageSize' => $page_size, 'totalCount' => $total_count, 'totalPage' => $total_page);
             } else {
                 $max_bid_price = $ProductBid->where($map)->max('bid_price');
                 $value = array('info' => array('currentPrice' => $max_bid_price, 'bidPrice' => $max_bid_price + $range_price, 'lastId' => 1), 'htmlString' => $content, 'isNextPage' => $total_page == 1 || $total_page == $page ? false : true, 'page' => $page, 'pageSize' => $page_size, 'totalCount' => $total_count, 'totalPage' => $total_page);
             }
         } else {
             $value = array('htmlString' => '', 'isNextPage' => false, 'page' => $page, 'pageSize' => $page_size, 'totalCount' => $total_count, 'totalPage' => 1);
         }
         $this->resultSuccess('加載中...', $value);
     } else {
         //$this->display();
     }
 }
開發者ID:wuwenbao,項目名稱:paimai,代碼行數:35,代碼來源:BidController.class.php

示例2: getCityListByProvince

 /**
  * 通過省份獲取城市列表
  */
 public function getCityListByProvince()
 {
     $provinceId = (int) I('provinceId');
     $m = D('Home/Areas');
     $cityList = $m->getCityListByProvince($provinceId);
     $this->ajaxReturn($cityList);
 }
開發者ID:skykain,項目名稱:wstmall,代碼行數:10,代碼來源:AreasAction.class.php

示例3: documentSaveComplete

 /**
  * 文檔保存成功後執行行為
  * @param  array  $data     文檔數據
  * @param  array  $catecory 分類數據
  */
 public function documentSaveComplete($param)
 {
     if (MODULE_NAME == 'Home') {
         list($data, $category) = $param;
         /* 附件默認配置項 */
         $default = C('ATTACHMENT_DEFAULT');
         /* 合並當前配置 */
         $config = $category['extend']['attachment'];
         $config = empty($config) ? $default : array_merge($default, $config);
         $attach = I('post.attachment');
         /* 該分類不允許上傳附件 */
         if (!$config['is_upload'] || !in_array($attach['type'], str2arr($config['allow_type']))) {
             return;
         }
         switch ($attach['type']) {
             case 1:
                 //外鏈
                 # code...
                 break;
             case 2:
                 //文件
                 $info = json_decode(think_decrypt($attach['info']), true);
                 if (!empty($info)) {
                     $Attachment = D('Addons://Attachment/Attachment');
                     $Attachment->saveFile($info['name'], $info, $data['id']);
                 } else {
                     return;
                     //TODO:非法附件上傳,可記錄日誌
                 }
                 break;
         }
     }
 }
開發者ID:kissthink,項目名稱:Hackme,代碼行數:38,代碼來源:AttachmentAddon.class.php

示例4: preview

 function preview()
 {
     $vote_id = I('id', 0, 'intval');
     $url = addons_url('Invite://Wap/index', array('id' => $vote_id));
     $this->assign('url', $url);
     $this->display(SITE_PATH . '/Application/Home/View/default/Addons/preview.html');
 }
開發者ID:chenpusn,項目名稱:haozhixian_bak,代碼行數:7,代碼來源:InviteController.class.php

示例5: index

 public function index()
 {
     if (IS_POST) {
         $login = array();
         switch (I('user', null, false)) {
             case 'admin':
                 $login['uid'] = 1;
                 $login['user'] = 'admin';
                 break;
             case 'test':
                 $login['uid'] = 2;
                 $login['user'] = 'test';
                 break;
             case 'guest':
                 $login['uid'] = 3;
                 $login['user'] = 'guest';
                 break;
             default:
                 $this->error('用戶不存在');
         }
         if (count($login)) {
             session('auth', $login);
             $this->success('登陸成功', U('Index/index'));
         }
     } else {
         $this->display();
     }
 }
開發者ID:lilili001,項目名稱:think,代碼行數:28,代碼來源:LoginController.class.php

示例6: login

 public function login()
 {
     #是否顯示驗證碼
     $msg = '';
     if (IS_POST) {
         $name = I('name');
         $password = I('password');
         if (!empty($name) && !empty($password)) {
             #驗證用戶信息
             $user_info = D('Common/Admin')->loginCheck($name, $password);
             #記錄登錄日誌
             $log_data = array('admin_id' => isset($user_info['id']) ? $user_info['id'] : 0, 'login_time' => date('Y-m-d H:i:s'), 'login_ip' => get_client_ip());
             $log_result = D('Common/Adminlog')->log_add($log_data);
             #跳轉
             if (isset($user_info['id'])) {
                 session('user', $user_info['id']);
                 redirect(U('admin/Index/index'));
             } else {
                 $this->error('登錄失敗,用戶名或密碼錯誤。');
             }
         } else {
             $this->error('登錄失敗,用戶名或密碼錯誤。');
         }
     }
     $this->display();
 }
開發者ID:cassileShu,項目名稱:ebxzj,代碼行數:26,代碼來源:IndexController.class.php

示例7: energy_time

 /**
  * 時刻記錄
  * Enter description here ...
  */
 public function energy_time()
 {
     $uid = I('uid', '0', 'intval');
     $start_time = mktime(0, 0, 0, date("m"), 1, date("Y"));
     $end_time = mktime(23, 59, 59, date("m"), date("t"), date("Y"));
     $res = $this->_mod->where('uid =' . $uid . ' and add_time >= ' . $start_time . ' and add_time <= ' . $end_time)->order('add_time')->select();
     $date_array = array();
     foreach ($res as $key => $val) {
         $res[$key]['add_time'] = date('m.d', $val['add_time']);
         $res[$key]['time'] = date('H:i', $val['add_time']);
         if (!in_array($res[$key]['add_time'], $date_array)) {
             array_push($date_array, $res[$key]['add_time']);
         }
     }
     foreach ($date_array as $value) {
         foreach ($res as $k => $v) {
             if ($value == $v['add_time']) {
                 $result[$v['add_time']][] = $v;
                 //按日期分組
             }
         }
     }
     $appjson = $result;
     if (C('APP_JSON_RETURN')) {
         $this->jsonReturn($appjson);
     }
 }
開發者ID:lzstg,項目名稱:guangchangwu_web,代碼行數:31,代碼來源:energyAction.class.php

示例8: _after_update

 function _after_update($data, $options)
 {
     $pid = $data['id'];
     $data_detail['pid'] = $pid;
     $subject = array_filter(I('subject'));
     $model_detail = M("DailyReportDetail");
     $model_detail->where($data_detail)->delete();
     foreach ($subject as $key => $val) {
         $data_detail['type'] = 1;
         $data_detail['subject'] = $val;
         $data_detail['item'] = implode("|||", I("item_{$key}"));
         $data_detail['start_time'] = implode("|||", I("start_time_{$key}"));
         $data_detail['end_time'] = implode("|||", I("end_time_{$key}"));
         $data_detail['status'] = implode("|||", I("status"));
         $model_detail->add($data_detail);
     }
     $plan_subject = array_filter(I('plan_subject'));
     $plan_item = I('plan_item');
     $plan_start_time = I('plan_start_time');
     $plan_end_time = I('plan_end_time');
     $plan_priority = I('plan_priority');
     $is_need_help = I('is_need_help');
     foreach ($plan_subject as $key => $val) {
         $data_detail['type'] = 2;
         $data_detail['subject'] = $val;
         $data_detail['item'] = $plan_item[$key];
         $data_detail['start_time'] = $plan_start_time[$key];
         $data_detail['end_time'] = $plan_end_time[$key];
         $data_detail['priority'] = $plan_priority[$key];
         $data_detail['is_need_help'] = $is_need_help[$key];
         $model_detail->add($data_detail);
     }
     $plan_subject = $data['plan_subject'];
 }
開發者ID:hongweipeng,項目名稱:oa,代碼行數:34,代碼來源:DailyReportModel.class.php

示例9: confirm_stock_in

 public function confirm_stock_in($id, $current_node)
 {
     if (!I('get.workflow_submit')) {
         return ['pause' => 'true', 'type' => 'redirect', 'url' => '/storage/stockIn/confirm/bill/' . $id . '/node/' . $current_node['id']];
     }
     $detail_service = D('Storage/StockInDetail');
     $stock_service = D('Storage/Stock');
     $log_service = D('Storage/StockLog');
     $this->startTrans();
     $rows = I('post.rows');
     foreach ($rows as $k => $row) {
         if (!$row['id'] || !$row['this_time_in_quantity'] || !$row['storage_id'] || !$row['product_id'] || !$row['product_unique_id']) {
             continue;
         }
         $detail_service->where(['id' => $row['id']])->setInc('already_in', $row['this_time_in_quantity']);
         $rows[$k]['quantity'] = $row['this_time_in_quantity'];
         // 寫庫存操作記錄
         if (false === $log_service->record(['source_model' => 'storage.stockIn', 'source_id' => $id, 'direction' => 'in', 'product_id' => $row['product_id'], 'product_unique_id' => $row['product_unique_id'], 'quantity' => $row['this_time_in_quantity']])) {
             $this->error = 'storage.Trigger error when record stock log';
             $this->rollback();
             return false;
         }
     }
     // 更新庫存清單
     if (false === $stock_service->change_quantity('+', $rows)) {
         $this->error = __('storage.Trigger error when update stock balance');
         $this->rollback();
         return false;
     }
     $this->commit();
     return ['type' => 'redirect', 'url' => '/storage/stockIn/view/bill/' . $id];
 }
開發者ID:joncv,項目名稱:ones,代碼行數:32,代碼來源:StockInService.class.php

示例10: download

 public function download()
 {
     $r_mac = I('param.mac', '');
     $Public = A('Public');
     $webid = I('get.id', '');
     $Web = M('website');
     $web = $Web->join('rou_ap_main on rou_ap_main.id=rou_website.rid')->where('rou_ap_main.mac=' . $r_mac)->find();
     foreach ($web as $k => $v) {
         if ($v === '') {
             $Public->error('請先配置站點');
         }
     }
     $WebNav = M('webnav');
     $nav = $WebNav->where(array('wid' => $webid, 'is_show' => 1))->select();
     $navStr = '';
     foreach ($nav as $item) {
         $navStr .= '<option>' . $item['navname'] . '</option>';
     }
     $path = '/Down/' . $web['filename'] . '/';
     //生成配置文件
     $config = '<title>' . $web['web_name'] . '</title>
     <address>' . $web['address'] . '</address>
     <phone>' . $web['phone'] . '</phone>
     <email>' . $web['email'] . '</email>
     <nav>' . $navStr . '</nav>';
     $suffix = date('YmdHis', time()) . '_' . rand(0, 999);
     $hd = fopen(WEB_ROOT . $path . 'config_' . $suffix . '.txt', 'w') or die('無法打開文件');
     fwrite($hd, $config);
     fclose($hd);
     $zip = new \Org\Util\PHPZip();
     $zip->ZipAndDownload(WEB_ROOT . $path);
 }
開發者ID:leifuchen0111,項目名稱:company,代碼行數:32,代碼來源:IndexController.class.php

示例11: submit

 public function submit()
 {
     $ip_false = M('option')->where("meta_key='ip_false' AND type='user'")->getField('meta_value', true);
     if ($ip_false && in_array(mc_user_ip(), $ip_false)) {
         $this->error('您的IP被永久禁止登陸!');
     } else {
         $page_id = M('meta')->where("meta_key='user_name' AND meta_value='" . mc_magic_in(I('param.user_name')) . "' AND type='user'")->getField('page_id');
         $user_pass_true = mc_get_meta($page_id, 'user_pass', true, 'user');
         if ($_POST['user_name'] && $_POST['user_pass'] && md5($_POST['user_pass'] . mc_option('site_key')) == $user_pass_true) {
             $user_pass = md5(I('param.user_pass') . mc_option('site_key'));
             cookie('user_name', I('param.user_name'), 36000000000);
             cookie('user_pass', $user_pass, 36000000000);
             $ip_array = M('action')->where("page_id='" . mc_user_id() . "' AND action_key='ip'")->getField('action_value', true);
             if ($ip_array && in_array(mc_user_ip(), $ip_array)) {
             } else {
                 if (!mc_is_admin()) {
                     mc_add_action(mc_user_id(), 'ip', mc_user_ip());
                 }
             }
             if ($_POST['comefrom']) {
                 $this->success('登陸成功', $_POST['comefrom']);
             } else {
                 if (mc_is_mobile()) {
                     $this->success('登陸成功', U('user/index/pro?id=' . mc_user_id()));
                 } else {
                     $this->success('登陸成功', U('user/index/index?id=' . mc_user_id()));
                 }
             }
         } else {
             $this->error('用戶名與密碼不符!');
         }
     }
 }
開發者ID:xiaowei521,項目名稱:vamshop,代碼行數:33,代碼來源:LoginController.class.php

示例12: user

 /**
  * 微站管理員清單
  * 和修改刪除方法
  */
 function user()
 {
     $params = '';
     $user = $this->getModel('User');
     $count = $user->where(array('role_id' => 4, 'agent_id' => array('gt', 0)))->count();
     $page = new Page($count, C('APPLICATION_LIST_PAGE_SIZE'), $params);
     $rs = $user->where(array('role_id' => 4, 'agent_id' => array('gt', 0)))->order('id DESC')->limit($page->firstRow, $page->listRows)->select();
     foreach ($rs as $key => $value) {
         $rs[$key]['role'] = $this->USER_ROLE[$rs[$key]['role_id']];
         $rs[$key]['status'] = $this->USER_STATUS[$rs[$key]['status']];
         unset($rs[$key]['password']);
     }
     $this->assign('count', $count);
     $this->assign('list', $rs);
     $this->assign('page', $page->show());
     $this->assign('salt', md5(time()));
     $id = I('get.id');
     if (preg_match("/^[0-9]+\$/", $id)) {
         // 提取信息準備修改
         $rs = $user->find($id);
         if ($rs == null) {
         } else {
             $this->assign('info', $rs);
         }
     }
     $this->assign('roles', $this->USER_ROLE);
     $this->display();
 }
開發者ID:jackycgq,項目名稱:wechat-3,代碼行數:32,代碼來源:SiteController.class.php

示例13: ng_index

 public function ng_index()
 {
     $page = I('get.index_page');
     //The request page number
     $page = $page ? $page : 1;
     /**
      * 1.我的動態
      * 2.我關注的人的動態
      * 3.公開的
      * 4.按時間排序
      * 關聯的模型: hs_user,hs_piece,hs_piece_comment
      */
     /*$sql = "SELECT u.id,u.userName,u.avatar,p.piece_id,p.user_id,p.date,p.tag,p.content from hs_user as u,hs_piece as p 
       where p.visible=1 AND u.id=p.user_id AND p.user_id in (SELECT followed_id as id from hs_follow where follower_id=".$this->user_id." 
       union SElECT id from hs_user where id=".$this->user_id.") order by p.date desc limit ".$page*$this->piece_nums_per_page.
       ",".$this->piece_nums_per_page;*/
     $sql2 = "select count(c.comment_id) as comments_num,u.userName,u.avatar,p.piece_id,p.user_id,p.date,p.tag,p.content,p.visible,p.visible_tag \r\n        from hs_piece as p join hs_user as u on p.user_id=u.id left join hs_piece_comment as c on p.piece_id=c.piece_id where p.user_id=" . $this->user_id . " or p.user_id in (select f.followed_id from hs_follow as f where f.follower_id=" . $this->user_id . ") and p.visible=1 group by p.piece_id order by p.date desc ";
     $pieces = $this->piece_model->query($sql2);
     if ($pieces !== false) {
         if ($pieces == NULL) {
             $this->ajaxReturn(array('pieces' => $pieces, 'error' => 2, 'msg' => '暫無記錄!'), 'json');
         }
         if (count($pieces)) {
             $pieces = A('Auth')->filter_invisible_piece($pieces);
             //過濾不可見的碎片
             $pieces = Util::pageOfArray($pieces, $page, $this->piece_nums_per_page);
             //分頁
         }
         $this->ajaxReturn(array('pieces' => $pieces, 'error' => 0), 'json');
     } else {
         $this->ajaxReturn(array('pieces' => $pieces, 'error' => 1, 'msg' => '查詢失敗!'), 'json');
     }
 }
開發者ID:Hishengs,項目名稱:Heysoo,代碼行數:33,代碼來源:IndexController.class.php

示例14: login

 /**
  * 後台登陸控製器
  */
 public function login()
 {
     $arr = array('user_login' => I('user_login'), 'user_pass' => encrypt(I('user_pass'), C('ENCRYPTION_KEY')), 'remember-me' => I('remember-me'));
     //處理下次自動登錄
     if ($arr['remember-me'] == 1) {
         $account = $arr['user_login'];
         $ip = get_client_ip(0, true);
         $value = $account . '|' . $ip;
         $value = encrypt($value, C('ENCRYPTION_KEY'));
         @setcookie('remember-me', $value, time() + 7 * 24 * 3600, "/");
     }
     $user = M('user')->where(array('user_login' => $arr['user_login']))->find();
     $userinfo = D('user')->getInfo($user['id']);
     if ($user['user_status'] == 0) {
         $this->error('賬號被禁用,請聯係管理員...');
     }
     if ($user['user_type'] != '管理員') {
         $this->error('無權限登錄...');
     }
     if (!$user || $user['user_pass'] != $arr['user_pass']) {
         $this->error('賬號密碼錯誤,請重試...');
     }
     $data = array('id' => $user['id'], 'last_login_ip' => get_client_ip(0, true), 'last_login_time' => date("Y-m-d H:i:s"));
     $result = M('user')->save($data);
     if (!$result) {
         $this->error('登錄失敗,請重試...');
     }
     session('uid', $user['id']);
     session('username', $userinfo['username']);
     session('last_login_time', $data['last_login_time']);
     session('last_login_ip', $data['last_login_ip']);
     $this->success('登陸成功', U('Index/index'));
 }
開發者ID:lizhi0610,項目名稱:hgnu,代碼行數:36,代碼來源:LoginController.class.php

示例15: do_data

 /**
  * 讀取數據 do_data
  */
 public function do_data()
 {
     $topic_id = I('get.id');
     /* 判斷是否存在緩存 */
     $cache = S('HOME_TOPIC_ARTICLE_ID_' . $topic_id);
     if ($cache) {
         $data = $cache;
     } else {
         /* 查詢條件 */
         $field = 'topic.id as topic_id,topic.upfile,topic.content,topic.province,topic.city,topic.create_time,
                   user.nick_name,user.sex,user.upfile_head as user_upfile_head';
         $where['topic.id'] = array('EQ', $topic_id);
         $where['topic.status'] = array('EQ', 1);
         $where['topic.display'] = array('EQ', 1);
         $where['user.status'] = array('EQ', 1);
         $where['user.display'] = array('EQ', 1);
         /* 查詢數據 */
         $data = $this->alias('topic')->field($field)->where($where)->join('__USER__ user on topic.user_id = user.id')->find();
         /* 讀取用戶頭像 */
         if ($data['user_upfile_head'] && !strstr($data['user_upfile_head'], 'http://')) {
             $data['user_upfile_head'] = C('APP_URL') . '/Uploads/Images/User/' . $data['user_upfile_head'];
         }
         /* 轉換數據 */
         if ($data['content']) {
             $data['content'] = urldecode($data['content']);
         }
         /* 設置緩存 */
         S('HOME_TOPIC_ARTICLE_ID_' . $topic_id, $data, C('CACHE_TIME'));
     }
     /* 下載鏈接 */
     $data['data_setting'] = S('data_setting');
     return $data;
 }
開發者ID:liqihua,項目名稱:yanzhihui,代碼行數:36,代碼來源:TopicModel.class.php


注:本文中的I函數示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。