本文整理汇总了PHP中Filter::sql方法的典型用法代码示例。如果您正苦于以下问题:PHP Filter::sql方法的具体用法?PHP Filter::sql怎么用?PHP Filter::sql使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Filter
的用法示例。
在下文中一共展示了Filter::sql方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: __construct
/**
* 构造函数
*
* @access public
* @param mixed $name
* @param mixed $password
* @return mixed
*/
public function __construct($name, $password)
{
$safebox = Safebox::getInstance();
$manager = $safebox->get('manager');
if (!isset($manager['id']) || $manager['id'] == '' || $manager['name'] != $name) {
$model = new Model('manager');
$name = Filter::sql($name);
$user = $model->where("name='" . $name . "'")->find();
if (!empty($user)) {
$key = md5($user['validcode']);
$password = substr($key, 0, 16) . $password . substr($key, 16, 16);
if ($user['password'] == md5($password)) {
$this->status = 'online';
$this->properties = $user;
$safebox->set('manager', $this->properties);
} else {
$this->status = 'offline';
$this->properties = null;
}
} else {
$this->status = 'offline';
$this->properties = null;
}
} else {
$this->status = 'online';
$this->properties = $safebox->get('manager');
}
}
示例2: email
public function email()
{
$email = Filter::sql(Req::args('email'));
$info = array('status' => false, 'msg' => '此用户已经注册');
$model = new Model('user');
$obj = $model->where("email='{$email}'")->find();
if (!$obj) {
$info = array('status' => true, 'msg' => '');
}
echo JSON::encode($info);
}
示例3: ad_validator
public function ad_validator()
{
// var_dump(Req::args());exit;
$type = Req::args('type');
$is_open = Req::args("is_open");
if (!$is_open) {
Req::args("is_open", 0);
}
if (!Req::args('id')) {
$number = CHash::random(32, 'char');
$number = preg_replace("/(\\w{8})\\w(\\w{4})\\w(\\w{4})\\w(\\w{4})\\w(\\w{8})/i", "\$1-\$2-\$3-\$4-\$5", $number);
Req::args('number', $number);
}
if ($type == 1 || $type == 2 || $type == 4) {
$path = Req::args('path');
$url = Req::args('url');
$title = Req::args('title');
$content = array();
if ($type == 2) {
foreach ($path as $key => $value) {
$content[$key] = array('path' => $value, 'url' => $url[$key], 'title' => $title[$key]);
}
} else {
$content[0] = array('path' => $path[0], 'url' => $url[0], 'title' => $title[0]);
if ($type == 4) {
$content[0]['position'] = Req::args("position");
$content[0]['is_close'] = Req::args('is_close') ? 1 : 0;
}
}
Req::args('content', serialize($content));
} elseif ($type == 3) {
$title = Req::args("font_title");
$url = Req::args("font_url");
$color = Req::args("font_color");
$content = array('title' => $title, 'url' => $url, 'color' => $color);
Req::args('content', serialize($content));
} else {
$content = Req::args("content");
Req::args('content', Filter::sql($content));
}
}
示例4: oauth_bind_act
/**
* 绑定用户Action
*/
public function oauth_bind_act()
{
$userinfo = Session::get('oauth_user_info');
if ($userinfo) {
$email = Filter::sql(Req::args('email'));
$passWord = Req::post('password');
$rePassWord = Req::post('repassword');
if (!Validator::email($email)) {
$info = array('field' => 'email', 'msg' => '邮箱不能为空!');
} elseif (strlen($passWord) < 6) {
$info = array('field' => 'password', 'msg' => '密码长度必需大于6位!');
} else {
$model = $this->model->table("user as us");
$obj = $model->join("left join customer as cu on us.id = cu.user_id")->fields("us.*,cu.group_id,cu.login_time")->where("us.email='{$email}'")->find();
if ($obj) {
if ($obj['password'] == CHash::md5($passWord, $obj['validcode'])) {
$test = $this->model->table('oauth_user')->where("oauth_type='{$userinfo['oauth_type']}' and open_id='{$userinfo['open_id']}'")->data(array('user_id' => $obj['id']))->update();
$this->safebox->set('user', $obj, 1800);
$this->redirect("/ucenter/index");
} else {
$info = array('field' => 'password', 'msg' => '密码与用户名是不匹配的,无法绑定!');
}
} else {
if ($passWord == $rePassWord) {
$model = $this->model->table("user");
$validcode = CHash::random(8);
$last_id = $model->data(array('email' => $email, 'name' => $userinfo['open_name'], 'password' => CHash::md5($passWord, $validcode), 'validcode' => $validcode))->insert();
$time = date('Y-m-d H:i:s');
$model->table("customer")->data(array('user_id' => $last_id, 'reg_time' => $time, 'login_time' => $time))->insert();
//记录登录信息
$obj = $model->table("user as us")->join("left join customer as cu on us.id = cu.user_id")->fields("us.*,cu.group_id,cu.login_time")->where("us.email='{$email}'")->find();
$this->safebox->set('user', $obj, 1800);
$this->model->table('oauth_user')->where("oauth_type='{$userinfo['oauth_type']}' and open_id='{$userinfo['open_id']}'")->data(array('user_id' => $last_id))->update();
$this->redirect("/ucenter/index");
} else {
$info = array('field' => 'repassword', 'msg' => '两次密码输入不一致!');
}
}
}
$this->assign("invalid", $info);
$this->redirect("/simple/oauth_bind", false, Req::args());
} else {
$this->redirect("/index/index");
}
}
示例5: area_op
public function area_op()
{
$id = Filter::int(Req::args('id'));
$op = Req::args('op');
$model = new Model('area');
$cache = CacheFactory::getInstance();
$info = array('status' => 'success', 'msg' => '');
switch ($op) {
case 'up':
case 'down':
$area = $model->where('id=' . $id)->find();
$objs = $model->where('parent_id=' . $area['parent_id'])->order('sort')->findAll();
$perv = $curr = $next = false;
$last = end($objs);
reset($objs);
foreach ($objs as $obj) {
if ($area['id'] == $obj['id']) {
$curr = $obj;
if ($curr['id'] == $last['id']) {
$next = false;
end($objs);
$prev = prev($objs);
} else {
$next = current($objs);
$prev = prev($objs);
$prev = prev($objs);
}
break;
}
}
if ($op == 'up') {
if ($prev) {
$curr_sort = $prev['sort'];
$prev_sort = $curr['sort'];
$model->data(array('sort' => $curr_sort))->where('id=' . $curr['id'])->update();
$model->data(array('sort' => $prev_sort))->where('id=' . $prev['id'])->update();
$cache->delete("_AreaData");
}
} else {
if ($next) {
$curr_sort = $next['sort'];
$next_sort = $curr['sort'];
$model->data(array('sort' => $curr_sort))->where('id=' . $curr['id'])->update();
$model->data(array('sort' => $next_sort))->where('id=' . $next['id'])->update();
$cache->delete("_AreaData");
}
}
$info = array('status' => 'success', 'msg' => '排序已更新');
break;
case 'add':
$objs = $model->fields('max(sort) as sort')->where('parent_id=' . $id)->query();
if ($objs) {
$sort = $objs[0]['sort'];
$sort++;
} else {
$sort = 1;
}
$name = Filter::sql(Req::args('name'));
$model->data(array('name' => $name, 'parent_id' => $id, 'sort' => $sort))->insert();
$cache->delete("_AreaData");
$info = array('status' => 'success', 'msg' => '成功添加节点');
break;
case 'edit':
$name = Filter::sql(Req::args('name'));
$model->data(array('name' => $name))->where('id=' . $id)->update();
$cache->delete("_AreaData");
$info = array('status' => 'success', 'msg' => '节点已更新');
break;
case 'del':
$obj = $model->where('parent_id=' . $id)->find();
if (!$obj) {
$model->where('id=' . $id)->delete();
$cache->delete("_AreaData");
$info = array('status' => 'success', 'msg' => '节点已经删除');
} else {
$info = array('status' => 'fail', 'msg' => '子节点还有节点,无法删除');
}
break;
}
echo JSON::encode($info);
}
示例6: goods_save
function goods_save()
{
$spec_items = Req::args('spec_items');
$spec_item = Req::args('spec_item');
$items = explode(",", $spec_items);
$values_array = array();
//货品中的一些变量
$pro_no = Req::args("pro_no");
$store_nums = Req::args("store_nums");
$warning_line = Req::args("warning_line");
$weight = Req::args("weight");
$sell_price = Req::args("sell_price");
$market_price = Req::args("market_price");
$cost_price = Req::args("cost_price");
//values的笛卡尔积
$values_dcr = array();
$specs_new = array();
if (is_array($spec_item)) {
foreach ($spec_item as $item) {
$values = explode(",", $item);
foreach ($values as $value) {
$value_items = explode(":", $value);
$values_array[$value_items[0]] = $value_items;
}
}
$value_ids = implode(",", array_keys($values_array));
$values_model = new Model('spec_value');
$spec_model = new Model('goods_spec');
$specs = $spec_model->where("id in ({$spec_items})")->findAll();
$values = $values_model->where("id in ({$value_ids})")->order('sort')->findAll();
$values_new = array();
foreach ($values as $k => $row) {
$current = $values_array[$row['id']];
if ($current[1] != $current[2]) {
$row['name'] = $current[2];
}
if ($current[3] != '') {
$row['img'] = $current[3];
}
$values_new[$row['spec_id']][$row['id']] = $row;
}
foreach ($specs as $key => $value) {
$value['value'] = isset($values_new[$value['id']]) ? $values_new[$value['id']] : null;
$specs_new[$value['id']] = $value;
}
foreach ($spec_item as $item) {
$values = explode(",", $item);
$key_code = ';';
foreach ($values as $k => $value) {
$value_items = explode(":", $value);
$key = $items[$k];
$tem[$key] = $specs_new[$key];
$tem[$key]['value'] = $values_array[$value_items[0]];
$key_code .= $key . ':' . $values_array[$value_items[0]][0] . ';';
}
$values_dcr[$key_code] = $tem;
}
}
//商品处理
$goods = new Model('goods');
Req::args('specs', serialize($specs_new));
$attrs = is_array(Req::args("attr")) ? Req::args("attr") : array();
$imgs = is_array(Req::args("imgs")) ? Req::args("imgs") : array();
Req::args('attrs', serialize($attrs));
Req::args('imgs', serialize($imgs));
Req::args('up_time', date("Y-m-d H:i:s"));
$id = intval(Req::args("id"));
$gdata = Req::args();
$gdata['name'] = Filter::sql($gdata['name']);
//$gdata['sub_title'] = Filter::sql($gdata['sub_title']);
$gdata['content'] = Filter::htmlstr($gdata['content']);
$gdata['sale_protection'] = Filter::htmlstr($gdata['sale_protection']);
if (isset($gdata['pro_no']) && is_array($gdata['pro_no'])) {
$gdata['pro_no'] = $gdata['pro_no'][0];
}
//Tiny::log(__FILE__.__LINE__."-".var_export($gdata, true));
if ($id == 0) {
$gdata['create_time'] = date("Y-m-d H:i:s");
$goods_id = $goods->data($gdata)->save();
Log::op($this->manager['id'], "添加商品", "管理员[" . $this->manager['name'] . "]:添加了商品 " . Req::args('name'));
} else {
$goods_id = $id;
$goods->data($gdata)->where("id =" . $id)->update();
//$sql = Tiny::getSqlLog(); Tiny::log(__FILE__.__LINE__."-".var_export($sql, true));
Log::op($this->manager['id'], "修改商品", "管理员[" . $this->manager['name'] . "]:修改了商品 " . Req::args('name'));
}
//货品添加处理
$g_store_nums = $g_warning_line = $g_weight = $g_sell_price = $g_market_price = $g_cost_price = 0;
$products = new Model("products");
$k = 0;
foreach ($values_dcr as $key => $value) {
$result = $products->where("goods_id = " . $goods_id . " and specs_key = '{$key}'")->find();
$data = array('goods_id' => $goods_id, 'pro_no' => $pro_no[$k], 'store_nums' => $store_nums[$k], 'warning_line' => $warning_line[$k], 'weight' => $weight[$k], 'sell_price' => $sell_price[$k], 'market_price' => $market_price[$k], 'cost_price' => $cost_price[$k], 'specs_key' => $key, 'spec' => serialize($value));
$g_store_nums += $data['store_nums'];
if ($g_warning_line == 0) {
$g_warning_line = $data['warning_line'];
} else {
if ($g_warning_line > $data['warning_line']) {
$g_warning_line = $data['warning_line'];
}
//.........这里部分代码省略.........
示例7: info_save
public function info_save()
{
$rules = array('name:required:昵称不能为空!', 'real_name:required:真实姓名不能为空!', 'sex:int:性别必需选择!', 'birthday:date:生日日期格式不正确!', 'mobile:mobi:手机格式不正确', 'province:[1-9]\\d*:选择地区必需完成', 'city:[1-9]\\d*:选择地区必需完成', 'county:[1-9]\\d*:选择地区必需完成');
$info = Validator::check($rules);
if (is_array($info)) {
$this->redirect("info", false, array('msg' => array("info", $info['msg'])));
} else {
$data = array('name' => Filter::txt(Req::args('name')), 'real_name' => Filter::text(Req::args('real_name')), 'sex' => Filter::int(Req::args('sex')), 'birthday' => Filter::sql(Req::args('birthday')), 'mobile' => Filter::int(Req::args('mobile')), 'phone' => Filter::sql(Req::args('phone')), 'province' => Filter::int(Req::args('province')), 'city' => Filter::int(Req::args('city')), 'county' => Filter::int(Req::args('county')), 'addr' => Filter::text(Req::args('addr')));
$name = Filter::sql(Req::args("name"));
$id = $this->user['id'];
$this->model->table("user")->data(array("name" => $name))->where("id={$id}")->update();
$this->model->table("customer")->data($data)->where("user_id={$id}")->update();
$obj = $this->model->table("user as us")->join("left join customer as cu on us.id = cu.user_id")->fields("us.*,cu.group_id,cu.login_time")->where("us.id={$id}")->find();
$this->safebox->set('user', $obj, $this->cookie_time);
$this->redirect("info", false, array('msg' => array("success", "保存成功!")));
}
}
示例8: pay_received
public function pay_received()
{
$sign = Req::post('sign');
$args = Req::post();
unset($args['sign']);
$total_fee = Filter::float(Req::post('total_fee'));
$attach = Filter::int(Req::post('attach'));
$return['attach'] = $attach;
$return['total_fee'] = $total_fee;
$return['order_no'] = Filter::sql(Req::post('order_no'));
$return['return_url'] = Req::post('return_url');
if (stripos($return['order_no'], 'recharge_') !== false) {
$msg = array('type' => 'fail', 'msg' => '货到贷款方式,不能用于在线充值功能!');
$this->redirect('/index/msg', false, $msg);
exit;
}
if (floatval($return['total_fee']) <= 0 || $return['order_no'] == '' || $return['return_url'] == '') {
$msg = array('type' => 'fail', 'msg' => '支付参数不正确!');
$this->redirect('/index/msg', false, $msg);
} else {
$payment = new Payment($attach);
$paymentInfo = $payment->getPayment();
$pay_balance = new pay_balance();
$filter_param = $pay_balance->filterParam($args);
//对待签名参数数组排序
$para_sort = $pay_balance->argSort($filter_param);
$mysign = $pay_balance->buildSign($para_sort, $paymentInfo['partner_key']);
if ($mysign == $sign) {
$user_id = $this->user['id'];
$model = new Model("customer");
$customer = $model->where("user_id=" . $user_id)->find();
if ($customer) {
$order = $model->table("order")->where("order_no='" . $return['order_no'] . "' and user_id=" . $user_id)->find();
if ($order) {
if ($order['pay_status'] == 0) {
//$flag = $model->table("customer")->where("user_id=".$user_id)->data(array('balance'=>"`balance`-".$total_fee))->update();
$return['order_status'] = 'TINY_SECCESS';
//记录支付日志
//Log::balance((0-$total_fee),$user_id,'通过货到付款的方式进行商品购买,订单编号:'.$return['order_no']);
$filter_param = $pay_balance->filterParam($return);
$para_sort = $pay_balance->argSort($filter_param);
$sign = $pay_balance->buildSign($para_sort, $paymentInfo['partner_key']);
$prestr = $pay_balance->createLinkstring($para_sort);
$nextUrl = urldecode($return['return_url']);
$return_url = $nextUrl;
$return['sign'] = $sign;
$this->redirect("{$return_url}", true, $return);
exit;
} else {
$msg = array('type' => 'fail', 'msg' => '订单已经处理过,请查看订单信息!');
$this->redirect('/index/msg', false, $msg);
exit;
}
} else {
$msg = array('type' => 'fail', 'msg' => '订单不存在!');
$this->redirect('/index/msg', false, $msg);
exit;
}
} else {
$msg = array('type' => 'fail', 'msg' => '用户不存在!');
$this->redirect('/index/msg', false, $msg);
exit;
}
} else {
$msg = array('type' => 'fail', 'msg' => '签名错误!');
$this->redirect('/index/msg', false, $msg);
exit;
}
}
}
示例9: autoLoginUserInfo
static function autoLoginUserInfo()
{
$cookie = new Cookie();
$cookie->setSafeCode(Tiny::app()->getSafeCode());
$autologin = $cookie->get('autologin');
$obj = null;
if ($autologin != null) {
$email = Filter::sql($autologin['email']);
$password = $autologin['password'];
$model = new Model("user as us");
//$obj = $model->join("left join customer as cu on us.id = cu.user_id")->fields("us.*,cu.group_id,cu.login_time")->where("us.mobile='$mobile'")->find();
$obj = $model->join("left join customer as cu on us.id = cu.user_id")->fields("us.*,cu.group_id,cu.login_time")->where("us.email='{$email}'")->find();
if ($obj['password'] != $password) {
$obj = null;
}
}
return $obj;
}
示例10: jst
public function jst()
{
$id = Filter::sql(Req::args("id"));
$model = new Model("ad");
$time = date('Y-m-d');
$ad = $model->where("number = '{$id}' and is_open= 0 and start_time<='{$time}' and end_time >='{$time}'")->find();
$str = '<div id="ad-' . $ad['number'] . '" style="width:' . $ad['width'] . 'px;font-size:20px;padding:10px;overflow: hidden;">' . $ad['description'] . '</div>';
header('Content-type: text/javascript');
echo "document.write('" . $str . "');";
// exit;
}