本文整理汇总了PHP中sql_replace函数的典型用法代码示例。如果您正苦于以下问题:PHP sql_replace函数的具体用法?PHP sql_replace怎么用?PHP sql_replace使用的例子?那么, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了sql_replace函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: search
/**
* 搜索用户
*/
public function search()
{
$page = isset($GLOBALS['page']) ? intval($GLOBALS['page']) : 1;
$page = max($page, 1);
$uid = $this->memberinfo['uid'];
$publisher = $this->memberinfo['username'];
$username = isset($GLOBALS['username']) ? sql_replace($GLOBALS['username']) : MSG('请输入会员名');
$cityid = get_cookie('cityid');
$result_rs = $this->db->get_list('member', "`username` LIKE '%{$username}%'", '*', 0, 20, $page, 'uid DESC');
$result = array();
foreach ($result_rs as $r) {
$r['member_info'] = $r;
$v1 = $this->db->get_one('myfriend', array('myuid' => $r['uid'], 'uid' => $uid));
$v2 = $this->db->get_one('myfriend', array('myuid' => $uid, 'uid' => $r['uid']));
if ($v2 && $v1) {
//相互关注
$r['rtype'] = 1;
} elseif ($v2) {
$r['rtype'] = 2;
//已添加
} elseif ($v1) {
$r['rtype'] = 3;
//请求添加
}
$result[] = $r;
}
$pages = $this->db->pages;
$total = $this->db->number;
include T('member', 'friend_search_listing');
}
示例2: listing
public function listing()
{
$where = '';
$keywords = '';
$cid = intval($GLOBALS['cid']);
$categorys = get_cache('category', 'content');
$modelid = $categorys[$cid]['modelid'];
$model_r = $this->db->get_one('model', array('modelid' => $modelid));
$master_table = $model_r['master_table'];
$where = "cid='{$cid}'";
if (isset($GLOBALS['keywords'])) {
if (isset($GLOBALS['charset']) && strtolower(CHARSET) == 'gbk') {
$keywords = iconv('utf-8', 'gbk', $GLOBALS['keywords']);
} else {
$keywords = $GLOBALS['keywords'];
}
$keywords = trim(sql_replace($keywords));
// $master_table = 'content_share';
if (isset($GLOBALS['keytype']) && $GLOBALS['keytype'] == 'username') {
$where .= " AND `publisher` = '{$keywords}'";
} else {
$GLOBALS['keytype'] = 'keywords';
$where .= "AND `title` LIKE '%{$keywords}%'";
}
}
$page = isset($GLOBALS['page']) ? intval($GLOBALS['page']) : 1;
$result = $this->db->get_list($master_table, $where, '*', 0, 10, $page, 'id DESC');
$form = load_class('form');
include $this->template('relation_listing');
}
示例3: adduser
public function adduser()
{
if ($GLOBALS['submit']) {
$username = sql_replace($GLOBALS['username']);
$r = $this->db->get_one('member', array('username' => $username));
if (!$r) {
MSG('用户名不存在');
}
$rs = $this->db->get_one('admin', array('uid' => $r['uid']));
if (!$rs) {
MSG('请先在添加管理员处,添加该用户');
}
$workflowid = intval($GLOBALS['workflowid']);
$level = intval($GLOBALS['level']);
$wr = $this->db->get_one('workflow', array('workflowid' => $workflowid));
$users = array();
if ($wr['level' . $level . '_user'] != '') {
$users = unserialize($wr['level' . $level . '_user']);
}
$users[$r['uid']] = $rs['truename'] ? $rs['truename'] : $username;
$users = serialize($users);
$this->db->update('workflow', array('level' . $level . '_user' => $users), array('workflowid' => $workflowid));
MSG(L('add success'), $GLOBALS['forward']);
} else {
$show_formjs = 1;
include $this->template('workflow_adduser');
}
}
示例4: envoi_replace_fragments
function envoi_replace_fragments($replaces)
{
$desc = $GLOBALS['tables_auxiliaires']['spip_versions_fragments'];
foreach ($replaces as $r) {
sql_replace('spip_versions_fragments', $r, $desc);
}
}
示例5: listing
/**
* 后台用户列表
*/
public function listing()
{
$page = max(1, isset($GLOBALS['page']) ? intval($GLOBALS['page']) : 1);
$keyArr = array('username' => '用户名', 'uid' => 'UID', 'email' => 'Email', 'mobile' => '手机');
$keyType = isset($GLOBALS['keyType']) && isset($keyArr[$GLOBALS['keyType']]) ? $GLOBALS['keyType'] : 'username';
$keyValue = isset($GLOBALS['keyType']) ? sql_replace($GLOBALS['keyValue']) : '';
$regTimeStart = isset($GLOBALS['regTimeStart']) ? strtotime($GLOBALS['regTimeStart']) : '';
$regTimeEnd = isset($GLOBALS['regTimeEnd']) ? strtotime($GLOBALS['regTimeEnd']) : '';
$loginTimeStart = isset($GLOBALS['loginTimeStart']) ? strtotime($GLOBALS['loginTimeStart']) : '';
$loginTimeEnd = isset($GLOBALS['loginTimeEnd']) ? strtotime($GLOBALS['loginTimeEnd']) : '';
$groupid = isset($GLOBALS['groupid']) ? intval($GLOBALS['groupid']) : '';
$where = '';
if (isset($GLOBALS['search'])) {
if ($keyValue) {
$where = ' AND ' . $keyType . '="' . $keyValue . '"';
} else {
$where .= $groupid ? ' AND groupid = ' . $groupid : '';
$where .= $regTimeStart ? ' AND regtime >= ' . $regTimeStart : '';
$where .= $regTimeEnd ? ' AND regtime <= ' . $regTimeEnd + 86400 : '';
$where .= $loginTimeStart ? ' AND lasttime >= ' . $loginTimeStart : '';
$where .= $loginTimeEnd ? ' AND lasttime <= ' . $loginTimeEnd + 86400 : '';
}
$where = substr($where, 4);
}
$result = $this->db->get_list('member', $where, '*', 0, 20, $page, 'uid DESC');
$pages = $this->db->pages;
$group = $this->group;
include $this->template('member_listing', M);
}
示例6: keyword
private function keyword($field, $value)
{
if ($value == '') {
return '';
}
$data = array();
if (strpos($value, ',') === false) {
$data = explode(' ', $value);
} else {
$data = explode(',', $value);
}
foreach ($data as $v) {
$v = sql_replace($v);
$v = str_replace(array('/', '#', '.'), '', $v);
$tag_info = $this->db->get_one('tag', array('tag' => $v), 'tid');
if (empty($tag_info)) {
$tid = $this->db->insert('tag', array('tag' => $v, 'addtime' => SYS_TIME));
$this->keyword_pro($v, $tid);
} else {
$tid = $tag_info['tid'];
}
$id = $this->id;
$exists_where = array('tid' => $tid, 'modelid' => $this->modelid, 'cid' => $this->cid, 'id' => $id);
if (!$this->db->get_one('tag_data', $exists_where)) {
$this->db->insert('tag_data', $exists_where);
$this->db->update('tag', "`number`=(`number`+1)", array('tid' => $tid));
}
}
}
示例7: getit
/**
* 优惠券激活
*/
public function getit()
{
$order_no = sql_replace($GLOBALS['order_no']);
$r = $this->db->get_one('coupon_card', "`card_no`='{$order_no}'");
if ($r) {
if ($r['status'] == 2) {
MSG('您输入的优惠券已经被激活,不能重复使用');
}
$memberinfo = $this->memberinfo;
$formdata = array();
$formdata['cardid'] = $r['cardid'];
$formdata['card_no'] = $r['card_no'];
$formdata['title'] = $r['title'];
$formdata['remark'] = $r['remark'];
$formdata['mount'] = $r['mount'];
$formdata['id'] = $r['id'];
$formdata['addtime'] = SYS_TIME;
$formdata['endtime'] = $r['endtime'];
$formdata['url'] = $r['url'];
$formdata['uid'] = $memberinfo['uid'];
$formdata['status'] = 0;
$this->db->insert('coupon_card_active', $formdata);
$formdata2 = array();
if ($r['usetype']) {
$formdata2 = array('uid' => $memberinfo['uid']);
} else {
//仅能使用一次
$formdata2 = array('uid' => $memberinfo['uid'], 'status' => 2);
}
$this->db->update('coupon_card', $formdata2, array('cardid' => $r['cardid']));
MSG('优惠券激活成功', 'index.php?m=coupon&f=coupon&v=listing');
} else {
MSG('您输入的优惠券不存在');
}
}
示例8: show
/**
* 内容页面
* url规则 /index.php?m=tags&f=index&v=show&tid=2,tid=id/pinyin/tag/其中一个
*/
public function show()
{
$siteconfigs = $this->siteconfigs;
$page = max(1, output($GLOBALS, 'page'));
if (isset($GLOBALS['tid']) && is_numeric($GLOBALS['tid'])) {
$tid = intval($GLOBALS['tid']);
$where = array('tid' => $tid);
} elseif (isset($GLOBALS['tid']) && ctype_alnum($GLOBALS['tid'])) {
$tid = sql_replace($GLOBALS['tid']);
$where = array('pinyin' => $tid);
} else {
if (strtolower(CHARSET) == 'gbk') {
$tid = iconv('utf-8', 'gbk', urldecode($GLOBALS['tid']));
} else {
$tid = urldecode($GLOBALS['tid']);
}
$where = array('tag' => $tid);
}
$tag_info = $this->db->get_one('tag', $where);
if (empty($tag_info)) {
MSG(L('parameter_error'));
}
$tid = is_numeric($tid) ? $tid : $tag_info['tid'];
$this->html_tags->show($tid, $tag_info);
}
示例9: init
/**
* 公共模型搜索
*/
public function init()
{
$siteconfigs = $this->siteconfigs;
$seo_title = '搜索 - ' . $siteconfigs['sitename'];
$seo_keywords = $siteconfigs['seo_keywords'];
$seo_description = $siteconfigs['seo_description'];
$categorys = get_cache('category', 'content');
$keywords = sql_replace($GLOBALS['keywords']);
$starttime = isset($GLOBALS['starttime']) ? intval($GLOBALS['starttime']) : 0;
$runtime = '';
$history_result = array();
$search_cookie = get_cookie('search_cookie');
$history_result = explode('||', $search_cookie);
$models = get_cache('model_content', 'model');
$modelid = isset($GLOBALS['modelid']) ? intval($GLOBALS['modelid']) : 0;
if ($keywords) {
if ($starttime) {
$stime = SYS_TIME - $starttime * 86400;
$where = "`status`=9 AND (`addtime`>{$stime} AND `title` LIKE '%{$keywords}%') or (`addtime`>{$stime} AND `remark` LIKE '%{$keywords}%')";
} else {
$where = "`status`=9 AND `title` LIKE '%{$keywords}%' or `remark` LIKE '%{$keywords}%'";
}
$page = intval($GLOBALS['page']);
if ($modelid) {
$tablename = $models[$modelid]['master_table'];
} else {
$tablename = 'content_share';
}
$result = $this->db->get_list($tablename, $where, '*', 0, 20, $page, 'id DESC');
$result_pages = $this->db->pages;
$total_number = $this->db->number;
if ($search_cookie) {
if (!in_array($keywords, $history_result)) {
$search_cookie = $keywords . "||" . $search_cookie;
}
} else {
$search_cookie = $keywords;
}
set_cookie('search_cookie', $search_cookie, SYS_TIME + 86400 * 30);
$_endTime = microtime(true);
$runtime = $_endTime - $GLOBALS['_startTime'];
$runtime = sprintf("%.3f", $runtime);
} else {
$result = array();
$page = 0;
$result_pages = '';
$total_number = 0;
$runtime = '0.00001';
}
if ($search_cookie) {
if (count($history_result) > 10) {
array_pop($history_result);
$search_cookie = implode('||', $history_result);
set_cookie('search_cookie', $search_cookie, SYS_TIME + 86400 * 30);
}
}
include T('content', 'search', TPLID);
}
示例10: listing
public function listing()
{
$show_dialog = 1;
$result = array();
$stype = isset($GLOBALS['stype']) ? intval($GLOBALS['stype']) : 1;
$status = isset($GLOBALS['status']) ? intval($GLOBALS['status']) : 9;
$cid = isset($GLOBALS['cid']) ? intval($GLOBALS['cid']) : 0;
$keywords = isset($GLOBALS['keywords']) ? sql_replace($GLOBALS['keywords']) : '';
$start = isset($GLOBALS['start']) ? $GLOBALS['start'] : '';
$end = isset($GLOBALS['end']) ? $GLOBALS['end'] : '';
$modelid = $GLOBALS['modelid'];
$form = load_class('form');
$where = array('modelid' => $modelid);
$categorys = $this->db->get_list('category', $where, '*', 0, 200, 0, '', '', 'cid');
$options = array(1 => '标题', 2 => '描述', 3 => '发布人');
$model_r = $this->db->get_one('model', array('modelid' => $modelid));
$master_table = $model_r['master_table'];
$where = "status=9";
$model_r = $this->db->get_one('model', array('modelid' => $modelid));
$master_table = $model_r['master_table'];
if ($cid) {
$where = "`cid`='{$cid}' AND `status`='{$status}'";
} else {
$where = "`status`='{$status}'";
}
switch ($stype) {
case 1:
if ($keywords) {
$where .= " AND `title` LIKE '%{$keywords}%'";
}
break;
case 2:
if ($keywords) {
$where .= " AND `remark` LIKE '%{$keywords}%'";
}
break;
case 3:
if ($keywords) {
$where .= " AND `publisher`='{$keywords}'";
}
break;
}
if ($start) {
$where .= " AND `addtime`>'" . strtotime($start) . "'";
}
if ($end) {
$where .= " AND `addtime`<'" . strtotime($end) . "'";
}
$page = intval($GLOBALS['page']);
$page = max($page, 1);
$result = $this->db->get_list($master_table, $where, '*', 0, 20, $page, 'sort DESC');
$pages = $this->db->pages;
$form = load_class('form');
include $this->template('sundry_listing');
}
示例11: init
public function init()
{
$uid = get_cookie('_uid');
if (!$uid) {
exit('0');
}
$serverId = $GLOBALS['serverId'];
$localId = md5($GLOBALS['localId']);
//$r = $this->db->get_one('weixin_uploadfile', array('uid'=>$uid,'localId' => $localId));
//if($r) exit('1');
$formdata = array();
$formdata['uid'] = $uid;
$formdata['pageid'] = sql_replace($GLOBALS['pageid']);
$formdata['localId'] = $localId;
$formdata['serverId'] = strip_tags($serverId);
$formdata['addtime'] = SYS_TIME;
$formdata['ip'] = get_ip();
$this->db->insert('weixin_uploadfile', $formdata);
echo '1';
}
示例12: add
public function add()
{
$seo_title = '发私信';
$memberinfo = $this->memberinfo;
if (isset($GLOBALS['submit'])) {
$tousername = sql_replace($GLOBALS['tousername']);
if ($tousername == '') {
MSG('用户名错误');
}
$r = $this->db->get_one('member', array('username' => $tousername));
if (!$r) {
MSG('用户名错误');
}
$content = remove_xss($GLOBALS['content']);
$this->db->insert('message', array('uid' => $memberinfo['uid'], 'touid' => $r['uid'], 'username' => $memberinfo['username'], 'addtime' => SYS_TIME, 'content' => $content));
MSG('私信发送成功', HTTP_REFERER);
} else {
$username = isset($GLOBALS['username']) ? remove_xss($GLOBALS['username']) : '';
include T('message', 'add');
}
}
示例13: add
/**
* 添加推荐用户
*/
public function add()
{
if (isset($GLOBALS['submit'])) {
$username = sql_replace($GLOBALS['username']);
$r = $this->db->get_one('member', array('username' => $username));
if (!$r) {
MSG('用户不存在');
}
$formdata = array();
$formdata['cityid'] = intval($GLOBALS['cityid']);
$formdata['uid'] = $r['uid'];
$this->db->insert('friend_elite', $formdata);
MSG(L('operation_success'), '?m=member&f=friend&v=listing' . $this->su());
} else {
$group = $this->group;
$form = load_class('form');
$where = array('modelid' => 3);
$categorys = $this->db->get_list('category', $where, '*', 0, 2000, 0, '', '', 'cid');
$show_formjs = 1;
include $this->template('friend_add');
}
}
示例14: action_petitionner_dist
function action_petitionner_dist() {
include_spip('inc/autoriser');
$securiser_action = charger_fonction('securiser_action', 'inc');
$arg = $securiser_action();
$id_article = intval($arg);
if (!autoriser('modererpetition', 'article', $id_article))
return;
switch(_request('change_petition')) {
case 'on':
$email_unique = (_request('email_unique') == 'on') ? 'oui' : 'non';
$site_obli = (_request('site_obli') == 'on') ? 'oui' : 'non';
$site_unique = (_request('site_unique') == 'on') ? 'oui' : 'non';
$message = (_request('message') == 'on') ? 'oui' : 'non';
include_spip('base/auxiliaires');
sql_replace('spip_petitions',
array('id_article' => $id_article,
'email_unique' => $email_unique,
'site_obli' => $site_obli,
'site_unique' => $site_unique,
'message' => $message),
$GLOBALS['tables_auxiliaires']['spip_petitions']);
include_spip('inc/modifier');
revision_petition($id_article,
array('texte' => _request('texte_petition'))
);
break;
case 'off':
sql_delete("spip_petitions", "id_article=$id_article");
break;
}
}
示例15: login
/**
* 预约卡登陆
*/
public function login()
{
if (isset($GLOBALS['card_no'])) {
if (empty($GLOBALS['card_no']) || empty($GLOBALS['password'])) {
MSG('卡号和密码必须填写', '?m=order&f=card&v=login', 2000);
}
$card_no = sql_replace($GLOBALS['card_no']);
$r = $this->db->get_one('order_card', array('card_no' => $card_no));
if ($r) {
$password = decode($r['password'], 'Hx0si1');
if ($password != $GLOBALS['password']) {
MSG('卡号或者密码错误');
}
if ($r['status'] == 2) {
MSG('您的预约卡已经使用过,不能重复预约,您可以通过登录“会员中心”查看详情!');
}
//验证成功
$mr = $this->db->get_one('member', array('username' => $card_no));
if ($mr) {
$formdata = $mr;
} else {
$factor = random_string('diy', 6, 'abcdefghigklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789');
$password = md5(md5($password) . $factor);
$formdata = array('username' => $card_no, 'password' => $password, 'factor' => $factor, 'groupid' => 6, 'points' => 0, 'modelid' => 10, 'email' => '', 'regtime' => SYS_TIME, 'lasttime' => SYS_TIME);
$formdata['uid'] = $this->db->insert('member', $formdata);
$this->db->update('order_card', array('uid' => $formdata['uid']), array('cardid' => $r['cardid']));
}
$this->create_cookie($formdata, SYS_TIME + 604800);
MSG('欢迎您的光临,即将进入预约信息页', '?m=order&f=order_form&v=order_workflow&acbar=3');
} else {
MSG('卡号或者密码错误');
}
} else {
include T('order', 'index');
}
}