本文整理匯總了PHP中Filter::int方法的典型用法代碼示例。如果您正苦於以下問題:PHP Filter::int方法的具體用法?PHP Filter::int怎麽用?PHP Filter::int使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類Filter
的用法示例。
在下文中一共展示了Filter::int方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: detailAction
/**
* 詳請
*
* @author mrmsl <msl-138@163.com>
* @date 2013-02-21 13:47:40
* @lastmodify 2013-04-26 23:13:01
*
* @return void 無返回值
*/
public function detailAction()
{
$blog_id = Filter::int('id', 'get');
$date = Filter::int('date', 'get');
if (!$blog_id || !$date) {
//非法參數
$log = get_method_line(__METHOD__, __LINE__, LOG_INVALID_PARAM) . "date=({$date}),id=({$blog_id})";
trigger_error($log);
$this->_showMessage('error' . $blog_id . $date, null, 404);
}
if ($blog_info = $this->_model->find($blog_id)) {
if (date('Ymd', $blog_info['add_time']) != $date) {
//日期與id不匹配
$log = get_method_line(__METHOD__, __LINE__, LOG_INVALID_PARAM) . "date=({$date}),id=({$blog_id})";
trigger_error($log);
$this->_showMessage('error' . $blog_id . ',' . $date, null, 404);
}
$filename = str_replace(BASE_SITE_URL, WWWROOT, $blog_info['link_url']);
new_mkdir(dirname($filename));
$o = $this->getViewTemplate('build_html')->assign('blog_info', $blog_info)->assign(array('web_title' => L('MINIBLOG,DETAIL') . TITLE_SEPARATOR . L('MINIBLOG'), 'comments_html' => $this->_getBlogComments($blog_id)));
$content = $o->fetch(CONTROLLER_NAME, 'detail', $blog_id);
//file_put_contents($filename, $content);
echo $content;
} else {
//微博不存在
$this->_showMessage(L('MINIBLOG,NOT_EXIST'), null, 404);
}
}
示例2: insertResult
public function insertResult($resultXML, $resultKbn)
{
$jkfResult = $resultXML->body->list->jkfResult;
$this->db->dosql("LOCK TABLES tiny_result,tiny_result_list WRITE");
//mysql_query("SET AUTOCOMMIT=0");
$retVal = $this->resultModel->fields("result_seq")->order("result_seq desc")->limit(1)->select();
if (!isset($retVal) || !isset($retVal[0]["result_seq"])) {
$retVal[0]["result_seq"] = 0;
}
$resultSeq = 1 + Filter::int($retVal[0]["result_seq"]);
$sqlRet = $this->resultModel->data(array('result_seq' => $resultSeq, 'company_code' => Filter::str($jkfResult->companyCode), 'business_no' => Filter::str($jkfResult->businessNo), 'business_type' => Filter::str($jkfResult->businessType), 'result_kbn' => Filter::str($resultKbn), 'declare_type' => Filter::str($jkfResult->declareType), 'chk_mark' => Filter::str($jkfResult->chkMark), 'notice_date' => Filter::str($jkfResult->noticeDate), 'notice_time' => Filter::str($jkfResult->noticeTime), 'note' => Filter::str($jkfResult->note)))->insert();
if (!$sqlRet) {
$jkfResultList = $resultXML->body->list->jkfResult->resultList;
foreach ($jkfResultList->jkfResultDetail as $detail) {
$retVal = $this->resultListModel->fields("result_list_seq")->where("result_seq = {$resultSeq}")->order("result_list_seq desc")->find();
if (!isset($retVal) || !isset($retVal["result_list_seq"])) {
$retVal["result_list_seq"] = 0;
}
$resultListSeq = 1 + Filter::int($retVal["result_list_seq"]);
$this->resultListModel->data(array('result_seq' => $resultSeq, 'result_list_seq' => $resultListSeq, 'result_info' => Filter::str($detail->resultInfo)))->insert();
}
}
$this->db->dosql("UNLOCK TABLES");
//mysql_query('ROLLBACK');
//mysql_query("END");
//mysql_query("SET AUTOCOMMIT=1");
}
示例3: parsePorm
public function parsePorm($prom)
{
$type = $prom['type'];
$expr = $prom['expression'];
$result = array('total_amount' => $this->total_amount, 'value' => 0.0);
switch ($type) {
case '0':
$result['total_amount'] = $this->total_amount * $expr / 100;
$result['note'] = "省" . $this->total_amount * (100 - $expr) / 100 . "(" . $expr / 10 . "折)";
$result['value'] = floatval($this->total_amount * (100 - $expr) / 100);
break;
case '1':
$result['total_amount'] = $this->total_amount - $expr;
$result['note'] = "省" . $expr . "(立減" . $expr . ")";
$result['value'] = floatval($expr);
break;
case '2':
$result['value'] = intval($expr);
$result['note'] = "送" . $expr . "倍積分";
break;
case '3':
$model = new Model("voucher_template");
$voucher = $model->where("id=" . Filter::int($expr))->find();
if ($voucher) {
$result['note'] = "麵值" . $voucher['value'] . "優惠券";
} else {
$result['note'] = "所送的優惠券已不存在";
}
break;
case '4':
$result['note'] = "免運費";
break;
}
return $result;
}
示例4: listAction
/**
* 列表
*
* @author mrmsl <msl-138@163.com>
* @date 2013-06-07 11:09:51
*
* @return void 無返回值
*/
public function listAction()
{
$sort = Filter::string('sort', 'get', $this->_pk_field);
//排序字段
if (!in_array($sort, $this->_getDbFields())) {
$log = __METHOD__ . ': ' . __LINE__ . ',' . L('QUERY,CONTROLLER_NAME,%。,ORDER,COLUMN') . $sort . L('NOT_EXIST');
C('TRIGGER_ERROR', array($log));
$this->_model->addLog($log, LOG_TYPE_INVALID_PARAM);
$this->_ajaxReturn(false, L('SERVER_ERROR'));
}
$order = !empty($_GET['dir']) ? Filter::string('dir', 'get') : Filter::string('order', 'get');
//排序
$order = toggle_order($order);
$keyword = Filter::string('keyword', 'get');
//關鍵字
$date_start = Filter::string('date_start', 'get');
//開始時間
$date_end = Filter::string('date_end', 'get');
//結束時間
$template_id = Filter::int('template_id', 'get');
//
$column = Filter::string('column', 'get');
//搜索字段
$where = array();
if ('' !== $keyword && in_array($column, array('subject', 'content', 'email'))) {
$where[$column] = $this->_buildMatchQuery($column, $keyword, Filter::string('match_mode', 'get'));
}
if ($date_start && ($date_start = strtotime($date_start))) {
$where['add_time'][] = array('EGT', $date_start);
}
if ($date_end && ($date_end = strtotime($date_end))) {
$where['add_time'][] = array('ELT', $date_end);
}
if (isset($where['add_time']) && count($where['add_time']) == 1) {
$where['add_time'] = $where['add_time'][0];
}
if ($template_id) {
$where['template_id'] = $template_id;
}
$total = $this->_model->where($where)->count();
if ($total === false) {
//查詢出錯
$this->_sqlErrorExit(L('QUERY,CONTROLLER_NAME') . L('TOTAL_NUM,ERROR'));
} elseif ($total == 0) {
//無記錄
$this->_ajaxReturn(true, '', null, $total);
}
$page_info = Filter::page($total);
$data = $this->_model->where($where)->limit($page_info['limit'])->order('' . $sort . ' ' . $order)->select();
$data === false && $this->_sqlErrorExit(L('QUERY,CONTROLLER_NAME') . L('LIST,ERROR'));
//出錯
$templates = $this->_getCache(false, 'Mail');
foreach ($data as &$v) {
$v['template_name'] = isset($templates[$id = $v['template_id']]) ? $templates[$id]['template_name'] : '';
}
$this->_ajaxReturn(true, '', $data, $total);
}
示例5: set_online
public function set_online()
{
$id = Req::args("id");
if (is_array($id)) {
$id = implode(',', $id);
}
$status = Filter::int(Req::args('status'));
if ($status != 0 && $status != 1) {
$status = 0;
}
$model = new Model('goods');
$model->data(array('is_online' => $status))->where("id in({$id})")->update();
$this->redirect("goods_list");
}
示例6: listAction
/**
* 列表
*
* @author mrmsl <msl-138@163.com>
* @lastmodify 2013-01-22 10:40:26 by mrmsl
*
* @return void 無返回值
*/
public function listAction()
{
$sort = Filter::string('sort', 'get', $this->_pk_field);
//排序字段
$sort = in_array($sort, $this->_getDbFields()) ? $sort : $this->_pk_field;
$order = !empty($_GET['dir']) ? Filter::string('dir', 'get') : Filter::string('order', 'get');
//排序
$order = toggle_order($order);
$keyword = Filter::string('keyword', 'get');
//關鍵字
$date_start = Filter::string('date_start', 'get');
//注冊開始時間
$date_end = Filter::string('date_end', 'get');
//注冊結束時間
$log_type = Filter::int('log_type', 'get');
//日誌類型
$where = $log_type != LOG_TYPE_ALL ? array('log_type' => $log_type) : array();
if ($keyword !== '') {
$where['content'] = $this->_buildMatchQuery('content', $keyword, Filter::string('match_mode', 'get'));
}
if ($date_start && ($date_start = strtotime($date_start))) {
$where['log_time'][] = array('EGT', $date_start);
}
if ($date_end && ($date_end = strtotime($date_end))) {
$where['log_time'][] = array('ELT', $date_end);
}
if (isset($where['log_time']) && count($where['log_time']) == 1) {
$where['log_time'] = $where['log_time'][0];
}
$total = $this->_model->where($where)->count();
if ($total === false) {
//查詢出錯
$this->_sqlErrorExit(L('QUERY,CONTROLLER_NAME_LOG') . L('TOTAL_NUM,ERROR'));
} elseif ($total == 0) {
//無記錄
$this->_ajaxReturn(true, '', null, $total);
}
$page_info = Filter::page($total);
$data = $this->_model->where($where)->field('*,INET_NTOA(user_ip) AS user_ip')->limit($page_info['limit'])->order('' . $sort . ' ' . $order)->select();
$data === false && $this->_sqlErrorExit(L('QUERY,CONTROLLER_NAME_LOG') . L('LIST,ERROR'));
//出錯
$this->_ajaxReturn(true, '', $data, $total);
}
示例7: address_save
public function address_save($redirect = null)
{
$rules = array('zip:zip:郵政編碼格式不正確!', 'addr:required:內容不能為空!', 'accept_name:required:收貨人姓名不能為空!,mobile:mobi:手機格式不正確!,phone:phone:電話格式不正確', 'province:[1-9]\\d*:選擇地區必需完成', 'city:[1-9]\\d*:選擇地區必需完成', 'county:[1-9]\\d*:選擇地區必需完成');
$info = Validator::check($rules);
if (!is_array($info) && $info == true) {
Filter::form(array('sql' => 'accept_name|mobile|phone', 'txt' => 'addr', 'int' => 'province|city|county|zip|is_default|id'));
$is_default = Filter::int(Req::args("is_default"));
if ($is_default == 1) {
$this->model->table("address")->where("user_id=" . $this->user['id'])->data(array('is_default' => 0))->update();
} else {
Req::args("is_default", "0");
}
Req::args("user_id", $this->user['id']);
$id = Filter::int(Req::args('id'));
if ($id) {
$this->model->table("address")->where("id={$id} and user_id=" . $this->user['id'])->update();
} else {
$obj = $this->model->table("address")->where('user_id=' . $this->user['id'])->fields("count(*) as total")->find();
if ($obj && $obj['total'] >= 20) {
$this->assign("msg", array("error", '地址最大允許添加20個'));
$this->redirect("address_other", false, Req::args());
exit;
} else {
$address_id = $this->model->table("address")->insert();
$order_status = Session::get("order_status");
$order_status['address_id'] = $address_id;
Session::set("order_status", $order_status);
}
}
$this->assign("msg", array("success", "地址編輯成功!"));
Req::args("id", null);
//$this->redirect("address_other",false);
if ($redirect == null) {
echo "<script>parent.location.reload();</script>";
} else {
$this->redirect($redirect);
}
exit;
} else {
$this->assign("msg", array("error", $info['msg']));
$this->redirect("address_other", false, Req::args());
}
}
示例8: publicAreaAction
/**
* 所屬地區
*
* @author mrmsl <msl-138@163.com>
* @date 2012-07-19 11:39:11
* @lastmodify 2013-01-28 11:23:08 by mrmsl
*
* @return void 無返回值
*/
public function publicAreaAction()
{
$area_id = Filter::int('node', 'get');
$data = $this->_getTreeData($area_id, 'nochecked');
if (!$area_id) {
//非加載指定節點
//增加頂級菜單
$this->_unshift && array_unshift($data, array('area_id' => 0, 'area_name' => L('TOP_LEVEL_AREA'), 'leaf' => true));
$parent_id = Filter::int('parent_id', 'get');
//添加指定地區子級地區,獲取指定地區信息by mashanlng on 2012-08-21 13:51:25
if ($parent_id && ($parent_info = $this->_getCache($parent_id))) {
$parent_info = array('area_id' => $parent_id, 'area_name' => $parent_info['area_name'], 'node' => $parent_info['node']);
$this->_ajaxReturn(array('data' => $data, 'parent_data' => $parent_info));
}
}
$this->_ajaxReturn(true, '', $data);
}
示例9: publicCategoryAction
/**
* 所屬分類
*
* @author mrmsl <msl-138@163.com>
* @date 2013-03-21 13:58:09
*
* @return void 無返回值
*/
public function publicCategoryAction()
{
$data = $this->_getCategory();
//增加頂級分類
$this->_unshift && array_unshift($data, array('cate_id' => 0, 'cate_name' => isset($_GET['emptyText']) ? Filter::string('emptyText', 'get') : L('TOP_LEVEL_CATEGORY'), 'leaf' => true));
$parent_id = Filter::int('parent_id', 'get');
//添加指定分類子分類,獲取指定分類信息by mashanlng on 2012-08-21 13:53:35
if ($parent_id && ($parent_info = $this->cache($parent_id))) {
$parent_info = array('cate_id' => $parent_id, 'parent_name' => $parent_info['cate_name']);
$this->_ajaxReturn(array('data' => $data, 'parent_data' => $parent_info));
}
$this->_ajaxReturn(true, '', $data);
}
示例10: publicTreeAction
/**
* 導航功能菜單
*
* @author mrmsl <msl-138@163.com>
* @lastmodify 2013-01-22 10:48:51 by mrmsl
*
* @return void 無返回值
*/
public function publicTreeAction()
{
$data = $this->_getTree();
//增加頂級菜單
$this->_unshift && array_unshift($data, array('menu_id' => 0, 'menu_name' => isset($_GET['emptyText']) ? Filter::string('emptyText', 'get') : L('TOP_LEVEL_MENU'), 'leaf' => true));
$parent_id = Filter::int('parent_id', 'get');
//添加指定菜單子菜單,獲取指定菜單信息by mashanlng on 2012-08-21 13:53:35
if ($parent_id && ($parent_info = $this->_getCache($parent_id))) {
$parent_info = array('menu_id' => $parent_id, 'controller' => $parent_info['controller'], 'parent_name' => $parent_info['menu_name'], '_priv_id' => join(',', array_keys($parent_info['priv'])), 'priv' => join(',', $parent_info['priv']));
$this->_ajaxReturn(array('data' => $data, 'parent_data' => $parent_info));
}
$this->_ajaxReturn(true, '', $data);
}
示例11: email_message_validator
public function email_message_validator()
{
$rules = array('title:required:消息標題不能為空!', 'content:required:消息內容不能為空!');
$info = Validator::check($rules);
if (Req::args('status') == null) {
Req::args('status', "0");
}
$status = Filter::int(Req::args('status'));
$trigger = Filter::int(Req::args('trigger'));
$id = Filter::int(Req::args('id'));
if ($info == true) {
$model = new Model('email_message');
$objs = $model->where('`trigger`=' . $trigger . ' and status=1')->findAll();
if (count($objs) > 1) {
return array('name' => null, 'msg' => '同一觸發條件隻能存在一條激活的信息模板!');
} else {
if (count($objs) == 1) {
if ($id != $objs[0]['id'] && $status == 1) {
return array('name' => null, 'msg' => '同一觸發條件隻能存在一條激活的信息模板!');
}
}
}
}
return $info;
}
示例12: viewAction
/**
* 查看某一條留言評論
*
* @author mrmsl <msl-138@163.com>
* @date 2013-06-01 11:00:03
*
* @return void 無返回值
*/
public function viewAction()
{
$comment_id = Filter::int($this->_pk_field, 'get');
$add_time = Filter::int('add_time', 'get');
$field = '*,INET_NTOA(user_ip) AS user_ip';
if (!$comment_id && !$add_time) {
//非法參數
$log = L('CN_CHAKAN,CONTROLLER_NAME,%.,INVALID_PARAM') . "{$this->_pk_field}({$comment_id}),add_time({$add_time})";
$msg = L('INVALID_PARAM');
} elseif (!($comment_info = $this->_model->field($field)->where(array($this->_pk_field => $comment_id, 'add_time' => $add_time))->select())) {
//不存在
$log = L('CN_CHAKAN,CONTROLLER_NAME') . ".{$this->_pk_field}({$comment_id}),add_time({$add_time})" . L('NOT_EXIST');
$msg = L('CONTROLLER_NAME,NOT_EXIST');
}
if (!empty($msg)) {
//錯誤
$log = get_method_line(__METHOD__, __LINE__, LOG_INVALID_PARAM) . $log;
trigger_error($log, E_USER_ERROR);
$this->_ajaxReturn(false, $msg);
}
$store = array($this->_pk_field => $comment_id, 'add_time' => $add_time, 'content' => '');
$info = $comment_info[0];
if (COMMENT_REPLY_TYPE_REPLIED == $info['admin_reply_type']) {
//
$reply_content = $this->_model->where('admin_reply_type=' . COMMENT_REPLY_TYPE_ADMIN . ' AND real_parent_id=' . $info[$this->_pk_field])->getField('content');
$store['content'] = $reply_content;
}
if ($parent_id = $info['parent_id']) {
$node_arr = explode(',', $info['node']);
$comment_info = $this->_model->field($field)->where("type={$info['type']} AND (node LIKE '{$node_arr[0]},%' OR {$this->_pk_field} = {$node_arr[0]}) AND comment_id<={$comment_id}")->select();
}
$this->_ajaxReturn(true, $store, Tree::array2tree($comment_info, $this->_pk_field));
}
示例13: convert
/**
* Converts the type of values like "true", "false", "null" or "123".
*
* @param string $value
* @param int $options
* @return mixed
*/
public static function convert($value, $options = self::VAR_STRING)
{
$options = (int) $options;
if ($options & self::VAR_STRING && !empty($value)) {
return trim(Filter::stripQuotes($value));
}
if ($options & self::VAR_FLOAT) {
return Filter::float($value, 12);
}
if ($options & self::VAR_INT) {
return Filter::int($value);
}
if ($options & self::VAR_BOOL || $options & self::VAR_NULL) {
if (null === $value || 'null' === strtolower(trim($value))) {
return null;
}
return Filter::bool($value);
}
return (string) $value;
}
示例14: detailAction
/**
* 詳請
*
* @author mrmsl <msl-138@163.com>
* @date 2013-02-21 15:26:00
* @lastmodify 2013-04-23 14:32:00 by mrmsl
*
* @return void 無返回值
*/
public function detailAction()
{
$blog_id = Filter::int('id', 'get');
$date = Filter::int('date', 'get');
if (!$blog_id || !$date) {
//非法參數
$this->triggerError(__METHOD__ . ': ' . __LINE__ . ',' . "date=({$date}),id=({$blog_id})");
$this->_showMessage('error' . $blog_id . $date, null, 404);
}
if ($blog_info = $this->_model->find($blog_id)) {
if (date('Ymd', $blog_info['add_time']) != $date) {
//日期與id不匹配
$this->triggerError(__METHOD__ . ': ' . __LINE__ . ',' . "date=({$date}),id=({$blog_id})");
$this->_showMessage('error' . $blog_id . ',' . $date, null, 404);
}
if (!$blog_info['is_issue'] || $blog_info['is_delete']) {
//未發布或已刪除
$this->triggerError(__METHOD__ . ': ' . __LINE__ . ',' . "is_delete=({$blog_info['is_delete']}),is_issue=({$blog_info['is_issue']})");
$this->_showMessage('error' . $blog_info['is_issue'] . ',' . $blog_info['is_delete'], null, 404);
}
$filename = str_replace(BASE_SITE_URL, WWWROOT, $blog_info['link_url']);
new_mkdir(dirname($filename));
$o = $this->getViewTemplate('build_html')->assign($this->_getNextAndPrevBlog($blog_id))->assign('blog_info', $blog_info)->assign(array('web_title' => $blog_info['title'] . TITLE_SEPARATOR . $this->nav($blog_info['cate_id'], 'cate_name', 'Category', TITLE_SEPARATOR) . TITLE_SEPARATOR . L('CN_WANGWEN'), 'seo_keywords' => $blog_info['seo_keyword'], 'seo_description' => $blog_info['seo_description'], 'tags' => $this->tags($blog_info['seo_keyword']), 'relative_blog' => $this->_getRelativeBlog($blog_id, $blog_info['seo_keyword']), 'comments_html' => $this->_getBlogComments($blog_id)));
$content = $o->fetch(CONTROLLER_NAME, 'detail', $blog_id);
//file_put_contents($filename, $content);
echo $content;
} else {
//博客不存在
$this->_showMessage(L('BLOG,NOT_EXIST'), null, 404);
}
}
示例15: moveAction
/**
* 移動所屬分類
*
* @author mrmsl <msl-138@163.com>
* @date 2013-03-31 19:27:28
*
* @return void 無返回值
*/
function moveAction()
{
$field = 'cate_id';
//定段
$cate_id = Filter::int($field);
//所屬分類id
$msg = L('MOVE');
//提示
$log_msg = $msg . L('CONTROLLER_NAME_BLOG,FAILURE');
//錯誤日誌
$error_msg = $msg . L('FAILURE');
//錯誤提示信息
if ($cate_id) {
//分類id
$cate_info = $this->_getCache($cate_id, 'Category');
if (!$cate_info) {
//分類不存在
$this->_model->addLog($log_msg . '<br />' . L("INVALID_PARAM,%:,BELONG_TO_CATEGORY,%{$field}({$cate_id}),NOT_EXIST"), LOG_TYPE_INVALID_PARAM);
$this->_ajaxReturn(false, $error_msg);
}
$cate_name = $cate_info['cate_name'];
} else {
//非法參數
$this->_model->addLog($log_msg . '<br />' . L("INVALID_PARAM,%: {$field},IS_EMPTY"), LOG_TYPE_INVALID_PARAM);
$this->_ajaxReturn(false, $error_msg);
}
$this->_setField($field, $cate_id, $msg, L('TO') . $cate_name);
}