本文整理汇总了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();
}
}
示例2: getCityListByProvince
/**
* 通过省份获取城市列表
*/
public function getCityListByProvince()
{
$provinceId = (int) I('provinceId');
$m = D('Home/Areas');
$cityList = $m->getCityListByProvince($provinceId);
$this->ajaxReturn($cityList);
}
示例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;
}
}
}
示例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');
}
示例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();
}
}
示例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();
}
示例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);
}
}
示例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'];
}
示例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];
}
示例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);
}
示例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('用户名与密码不符!');
}
}
}
示例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();
}
示例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');
}
}
示例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'));
}
示例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;
}