本文整理汇总了PHP中UserUtil::getUserId方法的典型用法代码示例。如果您正苦于以下问题:PHP UserUtil::getUserId方法的具体用法?PHP UserUtil::getUserId怎么用?PHP UserUtil::getUserId使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类UserUtil
的用法示例。
在下文中一共展示了UserUtil::getUserId方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: run
/**
* 显示用户发送短信的界面
*/
public function run()
{
$id = $this->getParameterFromPOST('id');
$type = $this->getParameterFromPOST('type');
if ($type != 'topic') {
$type = 'topic';
}
//
//拿到userid
$user_id = UserUtil::getUserId($this->db, $_SESSION['user']['name']);
$favor_dir = $this->getParameterFromPOST('favor_dir');
$add_new_favor_dir = $this->getParameterFromPOST('add_new_favor_dir');
if ($add_new_favor_dir) {
//我们将添加一个收藏目录
$sql = 'insert into favor_dir ( user_id, dir_name ) values (?, ?)';
$stmt = $this->db->prepare($sql);
$this->db->Execute($stmt, array($user_id, $add_new_favor_dir));
$favor_dir = $this->db->Insert_ID();
} else {
//检查用户选择的收藏目录ID
$sql = 'select count(*) as num from favor_dir where user_id=? and id=?';
$stmt = $this->db->Prepare($sql);
$res = $this->db->Execute($stmt, array($user_id, $favor_dir));
$rows = $res->FetchRow();
if (!$rows['num']) {
$this->AlertAndBack(SF_FAVOR_DIR_NOT_BE_CHOICE);
return;
}
}
//检查用户传入的topic是否存在
$sql = 'select count(*) as num from bbs_subject where id=?';
$stmt = $this->db->prepare($sql);
$res = $this->db->Execute($stmt, array($id));
$rows = $res->FetchRow();
if (!$rows['num']) {
$this->AlertAndForward(SF_TOPIC_IS_NOT_EXISTS);
return;
}
$back_url = $this->getParameterFromPOST('backurl');
//检查是否已经添加了该收藏到指定的目录中了
$sql = 'select count(*) as num from favor where user_id=? and dir_id=? and ' . ' type=? and favor_id=? ';
$stmt = $this->db->prepare($sql);
$res = $this->db->execute($stmt, array($user_id, $favor_dir, $type, $id));
$rows = $res->FetchRow();
if ($rows['num']) {
$this->AlertAndForward(SF_FAVOR_HAD_BEEN_ADD, base64_decode($back_url));
return;
}
//加入收藏
$sql = 'insert into favor (user_id, dir_id, type, favor_id, add_date ) ' . ' values (?, ?, ?, ?, ?) ';
$stmt = $this->db->prepare($sql);
$this->db->Execute($stmt, array($user_id, $favor_dir, $type, $id, getNoFormateCurrentDate()));
if ($this->db->ErrorNo()) {
$this->AlertAndForward($this->db->ErrorMsg());
return;
} else {
$this->TipsAndForward(SF_ADD_SUCCESS, base64_decode($back_url));
return;
}
}
示例2: run
/**
* 改变外观
*/
public function run()
{
//求得用户的id
$user_id = UserUtil::getUserId($this->db, $_SESSION['user']['name']);
//取得用户传入的参数
$theme = $this->getParameterFromGET('id');
if ($theme != 'default' && $theme != 'new' && $theme != 'newll') {
$theme = 'new';
}
$this->db->debug = true;
$sql = 'select count(*) as num from user_setting where user_id=?';
$sth = $this->db->Prepare($sql);
$res = $this->db->Execute($sth, array($user_id));
$rows = $res->FetchRow();
if ($rows['num']) {
$sql = 'update user_setting set user_theme=? ' . ' where user_id=?';
$sth = $this->db->Prepare($sql);
$this->db->Execute($sth, array($theme, $user_id));
} else {
$sql = 'insert into user_setting (user_theme, ' . ' user_id ) values (?, ? ) ';
$sth = $this->db->Prepare($sql);
$this->db->Execute($sth, array($theme, $user_id));
}
//更新Session设置
$_SESSION['user']['theme'] = $theme;
//送cookie
if ($_COOKIE['user']) {
$str_user_info = serialize($_SESSION['user']);
setcookie('user', $str_user_info, time() + 60 * 60 * 24 * 365, '/', $global_config_web_domain);
}
setcookie('5abb_cookie_theme', $theme, time() + 60 * 60 * 24 * 365, '/', $global_config_web_domain);
$this->forward('index.php');
}
示例3: run
/**
* 显示用户更改邮件和密码的界面
* @param: NULL
* @return: NULL
* @access: public
*/
public function run()
{
//求得用户的id
$user_id = UserUtil::getUserId($this->db, $_SESSION['user']['name']);
$smarty = $this->getSmarty();
$user_name = $_SESSION['user']['name'];
$smarty->assign('view_user_name', $user_name);
//用户的所在组
$sql = 'select b.group_name from base_user_info as a join sys_group as b on ' . ' a.group_dep = b.id where a.id=?';
$sth = $this->db->Prepare($sql);
$res = $this->db->Execute($sth, array($user_id));
$rows = $res->FetchRow();
$smarty->assign('user_roles', $rows['group_name']);
//查询用户现在的情况
$sql = 'select user_lang, user_theme, user_whether_receive_email, receive_system_message ' . ' from user_setting where user_id=?';
$sth = $this->db->Prepare($sql);
$res = $this->db->Execute($sth, array($user_id));
$rows = $res->FetchRow();
$user_lang = 'zh';
$user_theme = 'default';
$user_receive_email = 1;
$user_receive_message = 1;
if ($rows['user_lang']) {
$user_lang = $rows['user_lang'];
}
if ($rows['user_theme']) {
$user_theme = $rows['user_theme'];
}
if ($rows['user_whether_receive_email']) {
$user_receive_email = $rows['user_whether_receive_email'];
} else {
$user_receive_email = 0;
}
if ($rows['receive_system_message']) {
$user_receive_message = $rows['receive_system_message'];
} else {
$user_receive_message = 0;
}
$smarty->assign('user_email_1', $user_receive_email);
$smarty->assign('user_message_1', $user_receive_message);
$user_lang_option = '';
foreach ($this->system_lang as $lang) {
$user_lang_option .= "<option value=\"" . $lang . "\"";
if ($user_lang == $lang) {
$user_lang_option .= " selected ";
}
$user_lang_option .= ">{$lang}</option>\n";
}
$smarty->assign('user_lang_option', $user_lang_option);
$user_theme_option = '';
foreach ($this->system_theme as $theme_key => $theme_name) {
$user_theme_option .= "<option value=\"" . $theme_key . "\"";
if ($user_theme == $theme_key) {
$user_theme_option .= " selected ";
}
$user_theme_option .= ">{$theme_name}</option>\n";
}
$smarty->assign('user_theme_option', $user_theme_option);
$smarty->display('bbsoption.tmpl');
}
示例4: run
/**
* run this action
* @param: NULL
* @return: NULL
* @access: public
*/
public function run()
{
global $global_config_web_domain;
$db = $this->getDB();
if (!isset($_SESSION['user'])) {
$this->forward('index.php');
}
setcookie('user', '', time() - 3600, '/', $global_config_web_domain);
$user_name = $_SESSION['user']['name'];
//user logout
unset($_SESSION['user']);
//记录用户的登出动作
$user_id = UserUtil::getUserId($db, $user_name);
$sql = 'select count(*) as num from user_last_time_logout where user_id=?';
$sth = $db->Prepare($sql);
$res = $db->Execute($sth, array($user_id));
$rows = $res->FetchRow();
$now = time();
if ($rows['num']) {
$update_sql = 'update user_last_time_logout set last_time=? where user_id=?';
$update_sth = $db->Prepare($update_sql);
$db->Execute($update_sth, array($now, $user_id));
} else {
$insert_sql = 'insert into user_last_time_logout (user_id, ' . ' last_time) values (?, ?)';
$insert_sth = $db->Prepare($insert_sql);
$db->Execute($insert_sth, array($user_id, $now));
}
$session_id = session_id();
$sql = 'update online_user set user_name = ? where session_id=?';
$stmt = $db->Prepare($sql);
$db->Execute($stmt, array($session_id, $session_id));
$this->forward('index.php');
return;
}
示例5: run
/**
* 删除用户选定的短信
*/
public function run()
{
//得到用户的id
$user_id = UserUtil::getUserId($this->db, $_SESSION['user']['name']);
//得到用户请求的id
$id_array = $this->getParameterFromPOST('id');
if (!is_array($id_array)) {
$this->AlertAndBack(DM_SYSTEM_ERROR);
return;
}
//进行身份的判断
$sql = 'select count(*) as num from message_outbox where user_id=? and id=?';
$sth = $this->db->Prepare($sql);
foreach ($id_array as $id) {
$res = $this->db->Execute($sth, array($user_id, $id));
$rows = $res->FetchRow();
if (!$rows['num']) {
$this->AlertAndBack(DM_ID_IS_NOT_YOUR);
return;
}
}
//身份判断通过。
//开始删除
reset($id_array);
$sql = 'delete from message_outbox where id in (' . implode(',', $id_array) . ')';
$this->db->Execute($sql);
$this->forward('index.php?module=message&action=send');
}
示例6: run
/**
* run this action
* @param: NULL
* @return: NULL
* @access: public
*/
public function run()
{
//取得参数
$name = $this->getParameterFromPOST('username');
$layout_id = $this->getParameterFromPOSt('id');
if (!$name) {
$this->AlertAndBack(USER_IS_EMPTY);
return;
}
if (!$layout_id) {
$this->AlertAndBack(LAYOUT_IS_EMPTY);
return;
}
//检查用户名是否存在
$sql = 'select count(*) as num from base_user_info where lower(user_name)=?';
$sth = $this->db->Prepare($sql);
$res = $this->db->Execute($sth, array(strtolower($name)));
$rows = $res->FetchRow();
if (!$rows['num']) {
$this->AlertAndBack(USER_IS_NOT_EXISTS);
return;
}
$user_id = UserUtil::getUserId($this->db, $name);
//检查版块时候存在
$sql = 'select count(*) as num from bbs_layout where id=?';
$sth = $this->db->prepare($sql);
$res = $this->db->Execute($sth, array($layout_id));
$rows = $res->FetchRow();
if (!$rows['num']) {
$this->AlertAndBack(LAYOUT_IS_NOT_EXISTS);
return;
}
//求该版块的parent id
$sql = 'select parent_id from bbs_layout where id=?';
$sth = $this->db->prepare($sql);
$res = $this->db->Execute($sth, array($layout_id));
$rows = $res->FetchRow();
$parent_id = $rows['parent_id'];
//检查用户是否已经是版主
$sql = 'select count(*) as num from bbs_layout_manager where user_id=? and layout_id=?';
$sth = $this->db->Prepare($sql);
$res = $this->db->Execute($sth, array($user_id, $layout_id));
$rows = $res->FetchRow();
if ($rows['num']) {
$this->AlertAndBack(USER_HAD_BEEN_ADDED_AS_MANAGER);
return;
}
$sql = 'insert into bbs_layout_manager(user_id, layout_id) values (?, ?)';
$sth = $this->db->Prepare($sql);
$this->db->Execute($sth, array($user_id, $layout_id));
$this->forward('index.php?action=layout&parent=' . $parent_id);
return;
}
示例7: run
/**
* 保存用户的个人签名
* @param: NULL
* @return: NULL
* @access: public
*/
public function run()
{
//求得用户的id
$user_id = UserUtil::getUserId($this->db, $_SESSION['user']['name']);
//收集用户输入的个人签名
$user_sign = $this->getParameterFromPOST('usersign');
if (strlen($user_sign) > 250) {
$this->AlertAndBack('SU_USER_SIGN_TOO_LONGER');
return;
}
$sql = 'update base_user_info set user_sign=? where id=?';
$sth = $this->db->Prepare($sql);
$this->db->Execute($sth, array($user_sign, $user_id));
$this->forward('index.php?module=user&action=sign');
}
示例8: run
/**
* 显示用户的控制面板
*/
public function run()
{
//求得用户的id
$user_id = UserUtil::getUserId($this->db, $_SESSION['user']['name']);
$smarty = $this->getSmarty();
$user_name = $_SESSION['user']['name'];
//取得用户正在访问的收藏目录
$dir = $this->getParameterFromPOST('dir');
if (!$dir) {
$dir = 0;
}
$smarty->assign('dir', $dir);
//取得用户正在访问的页面
$page = $this->getParameterFromPOST('page');
//得到用户请求的id
$id_array = $this->getParameterFromPOST('id');
if (!is_array($id_array)) {
$this->AlertAndBack(DM_SYSTEM_ERROR);
return;
}
//进行身份的判断
$sql = 'select count(*) as num from favor where user_id=? and id=?';
$sth = $this->db->Prepare($sql);
foreach ($id_array as $id) {
$res = $this->db->Execute($sth, array($user_id, $id));
$rows = $res->FetchRow();
if (!$rows['num']) {
$this->AlertAndBack(DM_ID_IS_NOT_YOUR);
return;
}
}
//身份判断通过。
//开始删除
reset($id_array);
$sql = 'delete from favor where id in (' . implode(',', $id_array) . ')';
$this->db->Execute($sql);
//删除成功
if ($this->db->ErrorNo()) {
$this->AlertAndBack($this->db->ErrorMsg());
} else {
$this->TipsAndForward(DM_DELETE_SUCCESS, 'index.php?module=favor&dir=' . $dir . '&page=' . $page);
}
}
示例9: run
/**
* 显示用户发送短信的界面
*/
public function run()
{
$id = $this->getParameterFromGET('id');
$type = $this->getParameterFromGET('type');
if ($type != 'topic') {
$type = 'topic';
}
//拿到userid
$user_id = UserUtil::getUserId($this->db, $_SESSION['user']['name']);
$sql = 'select id, dir_name from favor_dir where user_id=?';
$stmt = $this->db->prepare($sql);
$res = $this->db->Execute($stmt, array($user_id));
$rows = $res->GetAll();
$smarty = $this->getSmarty();
$smarty->assign('favor_type', $type);
$smarty->assign('id', $id);
$smarty->assign('favor', $rows);
$smarty->assign('backurl', $this->getParameter('backurl'));
$smarty->display('showaddfavor.tmpl');
}
示例10: run
/**
* 显示用户发送短信的界面
*/
public function run()
{
//拿到userid
$user_id = UserUtil::getUserId($this->db, $_SESSION['user']['name']);
$favor_dir = $this->getParameterFromGET('dirname');
$favor_dir_id = 0;
if ($favor_dir) {
//我们将添加一个收藏目录
$sql = 'insert into favor_dir ( user_id, dir_name ) values (?, ?)';
$stmt = $this->db->prepare($sql);
$this->db->Execute($stmt, array($user_id, $favor_dir));
$favor_dir_id = $this->db->Insert_ID();
}
if ($this->db->ErrorNo()) {
$this->AlertAndForward($this->db->ErrorMsg());
return;
} else {
$this->TipsAndForward(SF_ADD_SUCCESS, 'index.php?module=favor&dir=' . $favor_dir_id);
return;
}
}
示例11: run
/**
* 显示用户的控制面板
*/
public function run()
{
//求得用户的id
$user_id = UserUtil::getUserId($this->db, $_SESSION['user']['name']);
$smarty = $this->getSmarty();
$user_name = $_SESSION['user']['name'];
//取得用户要删除的收藏目录
$dir = $this->getParameterFromGET('dir');
if (!$dir) {
$dir = 0;
}
//进行身份的判断
$sql = 'select count(*) as num from favor_dir where user_id=? and id=?';
$sth = $this->db->Prepare($sql);
$res = $this->db->Execute($sth, array($user_id, $dir));
$rows = $res->FetchRow();
if (!$rows['num']) {
$this->AlertAndBack(DM_ID_IS_NOT_YOUR);
return;
}
//身份判断通过。
//开始删除收藏
$sql = 'select id from favor where dir_id=?';
$stmt = $this->db->prepare($sql);
$res = $this->db->Execute($stmt, array($dir));
$id_array = array();
while ($rows = $res->FetchRow()) {
$id_array[] = $rows['id'];
}
$sql = 'delete from favor where id in (' . implode(',', $id_array) . ')';
$this->db->Execute($sql);
$sql = 'delete from favor_dir where id=?';
$this->db->Execute($sql, array($dir));
//删除成功
if ($this->db->ErrorNo()) {
$this->AlertAndBack($this->db->ErrorMsg());
} else {
$this->TipsAndForward(DM_DELETE_SUCCESS, 'index.php?module=favor');
}
}
示例12: run
/**
* 显示用户的基本信息
* @param: NULL
* @return: NULL
* @access: public
*/
public function run()
{
//求得用户的id
$user_id = UserUtil::getUserId($this->db, $_SESSION['user']['name']);
$smarty = $this->getSmarty();
$user_name = $_SESSION['user']['name'];
$smarty->assign('view_user_name', $user_name);
//用户的所在组
$sql = 'select b.group_name from base_user_info as a join sys_group as b on ' . ' a.group_dep = b.id where a.id=?';
$sth = $this->db->Prepare($sql);
$res = $this->db->Execute($sth, array($user_id));
$rows = $res->FetchRow();
$smarty->assign('user_roles', $rows['group_name']);
//查询用户的个人信息
$sql = 'select user_gender, user_birthday, public_birthday, user_website, public_website, ' . 'user_icq, public_user_icq, user_AIM, public_user_AIM, user_msn, public_user_msn, ' . 'user_yahoo, public_user_yahoo, user_skype, public_user_skype, user_qq, public_user_qq, ' . 'user_hometown, user_favor from base_user_info where id=?';
$sth = $this->db->Prepare($sql);
$res = $this->db->Execute($sth, array($user_id));
$rows = $res->FetchRow();
$smarty->assign('user_gender', $rows['user_gender']);
$smarty->assign('user_birthday', $rows['user_birthday']);
$smarty->assign('public_birthday', $rows['public_birthday']);
$smarty->assign('user_website', $rows['user_website']);
$smarty->assign('public_website', $rows['public_website']);
$smarty->assign('user_icq', $rows['user_icq']);
$smarty->assign('public_icq', $rows['public_user_icq']);
$smarty->assign('user_aim', $rows['user_AIM']);
$smarty->assign('public_aim', $rows['public_user_AIM']);
$smarty->assign('user_msn', $rows['user_msn']);
$smarty->assign('public_msn', $rows['public_user_msn']);
$smarty->assign('user_yahoo', $rows['user_yahoo']);
$smarty->assign('public_yahoo', $rows['public_user_yahoo']);
$smarty->assign('user_skype', $rows['user_skype']);
$smarty->assign('public_skype', $rows['public_user_skype']);
$smarty->assign('user_qq', $rows['user_qq']);
$smarty->assign('public_qq', $rows['public_user_qq']);
$smarty->assign('user_hometown', $rows['user_hometown']);
$smarty->assign('user_favor', $rows['user_favor']);
$smarty->display('baseinfo.tmpl');
}
示例13: run
/**
* 保存用户的个人签名
* @param: NULL
* @return: NULL
* @access: public
*/
public function run()
{
//求得用户的id
$user_id = UserUtil::getUserId($this->db, $_SESSION['user']['name']);
//取得用户传入的参数
$user_lang = $this->getParameterFromPOST('user_lang');
if (!$user_lang) {
$user_lang = 'zh';
}
$user_theme = $this->getParameterFromPOST('user_theme');
if (!$user_theme) {
$user_theme = 'default';
}
$user_recieve_email = $this->getParameterFromPOST('receive_email');
if ($user_recieve_email != 0) {
$user_recieve_email = 1;
}
$user_recieve_message = $this->getParameterFromPOST('receive_message');
if ($user_recieve_message != 0) {
$user_recieve_message = 1;
}
$sql = 'select count(*) as num from user_setting where user_id=?';
$sth = $this->db->Prepare($sql);
$res = $this->db->Execute($sth, array($user_id));
$rows = $res->FetchRow();
if ($rows['num']) {
$sql = 'update user_setting set user_lang=?, user_theme=?, user_whether_receive_email=?, ' . 'receive_system_message=? where user_id=?';
$sth = $this->db->Prepare($sql);
$this->db->Execute($sth, array($user_lang, $user_theme, $user_recieve_email, $user_recieve_message, $user_id));
} else {
$sql = 'insert into user_setting (user_lang, user_theme, user_whether_receive_email, ' . 'receive_system_message, user_id ) values (?, ?, ?, ?, ? ) ';
$sth = $this->db->Prepare($sql);
$this->db->Execute($sth, array($user_lang, $user_theme, $user_recieve_email, $user_recieve_message, $user_id));
}
//更新Session设置
$_SESSION['user']['lang'] = $user_lang;
$_SESSION['user']['theme'] = $user_theme;
$this->forward('index.php?module=user&action=bbsoption');
}
示例14: run
/**
* 显示用户更改邮件和密码的界面
* @param: NULL
* @return: NULL
* @access: public
*/
public function run()
{
//求得用户的id
$user_id = UserUtil::getUserId($this->db, $_SESSION['user']['name']);
$smarty = $this->getSmarty();
$user_name = $_SESSION['user']['name'];
$smarty->assign('view_user_name', $user_name);
//用户的所在组
$sql = 'select b.group_name from base_user_info as a join sys_group as b on ' . ' a.group_dep = b.id where a.id=?';
$sth = $this->db->Prepare($sql);
$res = $this->db->Execute($sth, array($user_id));
$rows = $res->FetchRow();
$smarty->assign('user_roles', $rows['group_name']);
//查询用户现在的邮件
$sql = 'select user_email, public_user_email from base_user_info where id=?';
$sth = $this->db->Prepare($sql);
$res = $this->db->Execute($sth, array($user_id));
$rows = $res->FetchRow();
$smarty->assign('user_email', $rows['user_email']);
$smarty->assign('public_email', $rows['public_user_email']);
$smarty->display('passwd.tmpl');
}
示例15: __construct
public function __construct()
{
parent::__construct();
if (!UserUtil::getUserId()) {
ResponseUtil::redirect(UrlUtil::createBackendUrl('login'));
}
$controller = strtolower($this->router->class);
$method = strtolower($this->router->method);
if (UserUtil::isShopKeeper()) {
if (!array_key_exists($controller, $this->shopKeeperPermissions)) {
$this->message('你没有权限执行本步骤!');
}
$methods = $this->shopKeeperPermissions[$controller];
if ($methods == '*') {
return true;
} else {
if (!in_array($method, $methods)) {
$this->message('你没有权限执行本步骤!');
} else {
return true;
}
}
}
}