本文整理汇总了PHP中Q函数的典型用法代码示例。如果您正苦于以下问题:PHP Q函数的具体用法?PHP Q怎么用?PHP Q使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了Q函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: prefs_list
/**
* Handler for user preferences form (preferences_list hook)
*/
function prefs_list($args)
{
if ($args['section'] != 'mailbox') {
return $args;
}
// Load configuration
$this->load_config();
// Load localization and configuration
$this->add_texts('localization/');
if (!empty($_REQUEST['_framed'])) {
$this->rc->output->add_label('newmail_notifier.title', 'newmail_notifier.testbody', 'newmail_notifier.desktopunsupported', 'newmail_notifier.desktopenabled', 'newmail_notifier.desktopdisabled');
$this->include_script('newmail_notifier.js');
}
// Check that configuration is not disabled
$dont_override = (array) $this->rc->config->get('dont_override', array());
foreach (array('basic', 'desktop', 'sound') as $type) {
$key = 'newmail_notifier_' . $type;
if (!in_array($key, $dont_override)) {
$field_id = '_' . $key;
$input = new html_checkbox(array('name' => $field_id, 'id' => $field_id, 'value' => 1));
$content = $input->show($this->rc->config->get($key)) . ' ' . html::a(array('href' => '#', 'onclick' => 'newmail_notifier_test_' . $type . '()'), $this->gettext('test'));
$args['blocks']['new_message']['options'][$key] = array('title' => html::label($field_id, Q($this->gettext($type))), 'content' => $content);
}
}
return $args;
}
示例2: sendEmail
public function sendEmail()
{
$username = Q('username');
$email = Q('email');
if (!$username || !$email) {
$this->error('参数错误');
} else {
$Model = M('user');
$user = $Model->where(array('username' => $username, 'email' => $email))->find();
if (!$user) {
$this->error('用户不存在');
} else {
$data = array();
$data['uid'] = $user['uid'];
$data['code'] = substr(md5(mt_rand(1, 1000) . time()), 0, 8);
$newPassword = substr(md5(mt_rand(1, 1000) . time()), 0, 6);
$data['password'] = md5($newPassword . $data['code']);
$Model->save($data);
$emailCon = "您在" . C('WEB_NAME') . "的新密码为:{$newPassword},请即刻修改密码!!!";
$state = Mail::send($email, $user['username'], C('WEBNAME'), $emailCon);
if ($state) {
$message = "我们已经向" . $email . '发送了重置密码邮件<br/>请登录邮箱查看新密码';
} else {
$masterEmail = C('EMAIL');
$message = "邮件发送失败,请联系管理员<a href='mailto:{$masterEmail}'>{$masterEmail}</a>";
}
}
}
$this->assign('message', $message);
$this->display();
}
示例3: checkEmail
public function checkEmail()
{
$email = Q("post.email");
$this->db->where("uid<>{$_SESSION['user']['uid']}");
echo $this->db->find("email='{$email}'") ? 0 : 1;
exit;
}
示例4: html_output
/**
* This callback function adds a box below the message content
* if there is a vcard attachment available
*/
function html_output($p)
{
$attach_script = false;
$icon = 'plugins/vcard_attachments/' . $this->local_skin_path() . '/vcard_add_contact.png';
foreach ($this->vcard_parts as $part) {
$vcards = rcube_vcard::import($this->message->get_part_content($part, null, true));
// successfully parsed vcards?
if (empty($vcards)) {
continue;
}
// remove part's body
if (in_array($part, $this->vcard_bodies)) {
$p['content'] = '';
}
foreach ($vcards as $idx => $vcard) {
// skip invalid vCards
if (empty($vcard->email) || empty($vcard->email[0])) {
continue;
}
$display = $vcard->displayname . ' <' . $vcard->email[0] . '>';
// add box below message body
$p['content'] .= html::p(array('class' => 'vcardattachment'), html::a(array('href' => "#", 'onclick' => "return plugin_vcard_save_contact('" . JQ($part . ':' . $idx) . "')", 'title' => $this->gettext('addvcardmsg')), html::span(null, Q($display))));
}
$attach_script = true;
}
if ($attach_script) {
$this->include_script('vcardattach.js');
$this->include_stylesheet($this->local_skin_path() . '/style.css');
}
return $p;
}
示例5: download
public function download()
{
$filename = Q('filename');
$cid = Q('cid', 0, 'intval');
if (empty($filename) || !$cid) {
$this->error('参数错误');
}
$db = M('upload');
$map['filename'] = array('EQ', $filename);
$file = $db->where($map)->find();
if (empty($file)) {
$this->error('文件不存在');
}
$category = M('category')->find($cid);
//不扣分
if ($category['show_credits'] == 0) {
header("Content-type:application/octet-stream");
//二进制文件
$fileName = $file['name'] . '.' . $file['ext'];
//获得文件名
header("Content-Disposition:attachment;filename={$fileName}");
//下载窗口中显示的文件名
header("Accept-ranges:bytes");
//文件尺寸单位
header("Accept-length:" . filesize($file['size']));
//文件大小
readfile($file['path']);
//读出文件内容
}
}
示例6: follow
/**
* 用户关注处理
*/
public function follow()
{
$uid = Q('uid', 0, 'intval');
if ($uid) {
$username = M('user')->where('uid=' . $uid)->getField('username');
$db = M('user_follow');
$result = $db->where("uid={$uid} AND fans_uid={$_SESSION['uid']}")->find();
if ($result) {
//取消关注
$db->where("uid={$uid} AND fans_uid={$_SESSION['uid']}")->del();
$this->_ajax(1, array('message' => '取消关注成功', 'follow' => '关注'));
} else {
if ($db->add(array('uid' => $uid, 'fans_uid' => $_SESSION['uid']))) {
$Dlink = "<a target='_blank' href='?a=Member&c=Space&m=index&u={$uid}'>{$username}</a>";
//============记录动态
$UserDynamicModel = K('UserDynamic');
$UserDynamicModel->addDynamic('关注了' . $Dlink);
if ($db->where("uid={$_SESSION['uid']} AND fans_uid={$uid}")->find()) {
$this->_ajax(1, array('message' => '关注成功', 'follow' => '互相关注'));
} else {
$this->_ajax(1, array('message' => '关注成功', 'follow' => '已关注'));
}
} else {
$this->_ajax(0, '操作失败');
}
}
} else {
$this->_ajax(0, '参数错误');
}
}
示例7: index
/**
* 首次登录
*/
public function index()
{
if (!Q("session.UserInfo")) {
$this->error("页面不存在!");
}
$this->display();
}
示例8: login
public function login()
{
if (session('aid')) {
go("Index/index");
}
if (IS_POST) {
$username = Q("post.username");
//对登录帐号的验证
if (!($user = $this->_db->where("username='{$username}'")->find())) {
$this->error('帐号输入错误');
}
//对密码的验证
if ($user['password'] != md5($_POST['password'])) {
$this->error('密码输入错误');
}
//当帐号密码输入正确时记录登录状态
$_SESSION['aid'] = $user['aid'];
$_SESSION['username'] = $user['username'];
//跳转到后台界面
go('Index/index');
} else {
//显示登录界面
$this->display();
}
}
示例9: gen_form
function gen_form()
{
list($form_start, $form_end) = get_form_tags(null, 'plugin.changepasswd_AD.save');
// return the complete form as table
$out = $form_start;
$table = new html_table(array('cols' => 2));
// show old password field
$field_id = 'rcmfd_curpwd';
$input_curpasswd = new html_passwordfield(array('name' => '_curpasswd', 'id' => $field_id));
$table->add('title', html::label($field_id, Q($this->gettext('curpasswd'))));
$table->add(null, $input_curpasswd->show());
// show new password field
$field_id = 'rcmfd_newpwd';
$input_newpasswd = new html_passwordfield(array('name' => '_newpasswd', 'id' => $field_id));
$table->add('title', html::label($field_id, Q($this->gettext('newpasswd'))));
$table->add(null, $input_newpasswd->show());
// show new password confirm field
$field_id = 'rcmfd_cnfpwd';
$input_confpasswd = new html_passwordfield(array('name' => '_confpasswd', 'id' => $field_id));
$table->add('title', html::label($field_id, Q($this->gettext('confpasswd'))));
$table->add(null, $input_confpasswd->show());
$out .= $table->show();
$out .= $form_end;
return $out;
}
示例10: __init
public function __init()
{
if (is_file(MODULE_PATH . 'Lock.php') && ACTION != 'isLock') {
go('isLock');
}
$this->step = Q('step', 1, 'intval');
}
示例11: index
public function index()
{
$u = preg_replace('@[^\\w]@', '', Q('u'));
$pre = C('DB_PREFIX');
$sql = "SELECT uid,nickname,rname,r.rid,spec_num,credits,regtime,logintime,domain,icon FROM {$pre}user AS u\n INNER JOIN {$pre}role AS r ON u.rid=r.rid\n WHERE u.uid='{$u}' OR domain='{$u}'";
if (!($user = M()->query($sql))) {
_404('会员不存在');
}
$user = $user[0];
//--------------------------增加空间访问次数
if (!isset($_SESSION['uid']) or $_SESSION['uid'] != $user['uid']) {
$sql = "UPDATE {$pre}user SET spec_num=spec_num+1";
M()->exe($sql);
}
//---------------------------获得文章列表
$where = 'uid=' . $user['uid'] . ' AND content_state=1 ';
$db = M('content');
$count = $db->where($where)->count();
$page = new Page($count, 10);
$data = $db->where($where)->limit($page->limit())->all();
$this->data = $data;
$this->page = $page->show();
$this->user = $user;
//------------------------------获得访问数据
$guest = $this->getGuest($user['uid']);
$this->assign('guest', $guest);
$this->display();
}
示例12: prefs_list
function prefs_list($args)
{
if ($args['section'] == 'mailbox') {
$RCMAIL = rcmail::get_instance();
$field_id = 'rcmfd_html5_notifier';
$select_duration = new html_select(array('name' => '_html5_notifier_duration', 'id' => $field_id));
$select_duration->add($this->gettext('off'), '0');
$times = array('3', '5', '8', '10', '12', '15', '20', '25', '30');
foreach ($times as $time) {
$select_duration->add($time . ' ' . $this->gettext('seconds'), $time);
}
$select_duration->add($this->gettext('durable'), '-1');
$select_smbox = new html_select(array('name' => '_html5_notifier_smbox', 'id' => $field_id));
$select_smbox->add($this->gettext('no_mailbox'), '0');
$select_smbox->add($this->gettext('short_mailbox'), '1');
$select_smbox->add($this->gettext('full_mailbox'), '2');
$content = $select_duration->show($RCMAIL->config->get('html5_notifier_duration') . '');
$content .= $select_smbox->show($RCMAIL->config->get('html5_notifier_smbox') . '');
$content .= html::a(array('href' => '#', 'id' => 'rcmfd_html5_notifier_browser_conf', 'onclick' => 'rcmail_browser_notifications(); return false;'), $this->gettext('conf_browser')) . ' ';
$content .= html::a(array('href' => '#', 'onclick' => 'rcmail_browser_notifications_test(); return false;'), $this->gettext('test_browser'));
$args['blocks']['new_message']['options']['html5_notifier'] = array('title' => html::label($field_id, Q($this->gettext('shownotifies'))), 'content' => $content);
$check_only_new = new html_checkbox(array('name' => '_html5_notifier_only_new', 'id' => $field_id . '_only_new', 'value' => 1));
$content = $check_only_new->show($RCMAIL->config->get('html5_notifier_only_new', false));
$args['blocks']['new_message']['options']['html5_notifier_only_new'] = array('title' => html::label($field_id, Q($this->gettext('onlynew'))), 'content' => $content);
$field_id .= '_excluded';
$input_excluded = new html_inputfield(array('name' => '_html5_notifier_excluded_directories', 'id' => $field_id));
$args['blocks']['new_message']['options']['html5_notifier_excluded_directories'] = array('title' => html::label($field_id, Q($this->gettext('excluded_directories'))), 'content' => $input_excluded->show($RCMAIL->config->get('html5_notifier_excluded_directories') . ''));
$RCMAIL->output->add_script("\$(document).ready(function(){ rcmail_browser_notifications_colorate(); });");
}
return $args;
}
示例13: __construct
/**
*
* 构造函数
*
* @param int $mid 模型mid
*/
public function __construct($mid)
{
$this->mid = $mid;
$this->cid = Q('cid', 0, 'intval');
$this->field = S('field' . $this->mid);
$this->category = S('category');
}
示例14: index
/**
* 后台登录
*/
public function index()
{
if (IS_POST) {
//查找用户名
$username = Q('post.username');
$userData = M('user')->where("username='{$username}'")->find();
if (!$userData) {
$this->error('用户名或密码错误');
}
if ($userData['is_admin'] == 0) {
$this->error('没有管理员权限');
}
//比对密码
if ($userData['password'] != Q('post.password', '', 'md5')) {
$this->error('用户名或密码错误');
}
if (session('code') != Q('post.code', '', 'strtoupper')) {
$this->error('验证码错误');
}
//登录成功存入session
session('aname', $userData['username']);
session('aid', $userData['uid']);
$this->success('登录成功', U('Admin/Index/index'));
}
$this->display();
}
示例15: __construct
public function __construct($podId)
{
$this->podId = $podId;
//BAKERT what if there have been no completed matches/no pairings?
$sql = 'SELECT SUM(pm1.wins) AS wins, SUM(pm2.wins) AS losses, ' . 'SUM(CASE WHEN pm1.wins > pm2.wins ' . 'THEN 3 ELSE (' . 'CASE WHEN pm1.wins = pm2.wins THEN 1 ELSE 0 END ' . ') END) AS points, ' . 'pe1.name AS name, pe1.url, pe1.player_id AS playerId ' . 'FROM `match` AS m ' . 'INNER JOIN round AS r ON r.id = m.round_id ' . 'INNER JOIN pod AS p ON p.id = r.pod_id ' . 'INNER JOIN player_match AS pm1 ON pm1.match_id = m.id ' . 'INNER JOIN player_match AS pm2 ON pm2.match_id = m.id ' . 'AND pm2.player_id != pm1.player_id ' . 'INNER JOIN player_event AS pe1 ON pe1.player_id = pm1.player_id AND pe1.event_id = p.event_id ' . 'LEFT JOIN player_event AS pe2 ON pe2.player_id = pm2.player_id AND pe2.event_id = p.event_id ' . 'WHERE r.pod_id = ' . Q($this->podId) . ' AND pm1.player_id != 0 ' . 'GROUP BY pm1.player_id ' . 'ORDER BY points DESC, SUM(pm1.wins - pm2.wins) DESC';
$this->standings = D()->execute($sql);
}