本文整理汇总了PHP中UserUtil类的典型用法代码示例。如果您正苦于以下问题:PHP UserUtil类的具体用法?PHP UserUtil怎么用?PHP UserUtil使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了UserUtil类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: run
/**
* run this action
* @param: NULL
* @return: NULL
* @access: public
*/
public function run()
{
//取得参数
$id = $this->getParameterFromGET('id');
if (!$id) {
$this->AlertAndBack(USER_IS_EMPTY);
return;
}
//检查用户名是否存在
$sql = 'select count(*) as num from base_user_info where id=?';
$sth = $this->db->Prepare($sql);
$res = $this->db->Execute($sth, array($id));
$rows = $res->FetchRow();
if (!$rows['num']) {
$this->AlertAndBack(USER_IS_NOT_EXISTS);
return;
}
$name = UserUtil::getUserNameById($this->db, $id);
//检查用户是否已经在黑名单中
$sql = 'select count(*) as num from black_list_by_user 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_HAD_BEEN_ADDED);
return;
}
$sql = 'insert into black_list_by_user (user_name) values (?)';
$sth = $this->db->Prepare($sql);
$this->db->Execute($sth, array($name));
$this->AlertAndBack(USER_HAD_BEEN_SUCCESS_ADDED);
return;
}
示例2: pageLock
public function pageLock($args)
{
$lockName = $args['lockName'];
$returnUrl = (array_key_exists('returnUrl', $args) ? $args['returnUrl'] : null);
$ignoreEmptyLock = (array_key_exists('ignoreEmptyLock', $args) ? $args['ignoreEmptyLock'] : false);
$uname = UserUtil::getVar('uname');
$lockedHtml = '';
if (!empty($lockName) || !$ignoreEmptyLock) {
PageUtil::AddVar('javascript', 'zikula.ui');
PageUtil::AddVar('javascript', 'system/PageLock/javascript/pagelock.js');
PageUtil::AddVar('stylesheet', ThemeUtil::getModuleStylesheet('pagelock'));
$lockInfo = ModUtil::apiFunc('pagelock', 'user', 'requireLock',
array('lockName' => $lockName,
'lockedByTitle' => $uname,
'lockedByIPNo' => $_SERVER['REMOTE_ADDR']));
$hasLock = $lockInfo['hasLock'];
if (!$hasLock) {
$view = Zikula_View::getInstance('pagelock');
$view->assign('lockedBy', $lockInfo['lockedBy']);
$lockedHtml = $view->fetch('PageLock_lockedwindow.tpl');
}
} else {
$hasLock = true;
}
$html = "<script type=\"text/javascript\">/* <![CDATA[ */ \n";
if (!empty($lockName)) {
if ($hasLock) {
$html .= "document.observe('dom:loaded', PageLock.UnlockedPage);\n";
} else {
$html .= "document.observe('dom:loaded', PageLock.LockedPage);\n";
}
}
$lockedHtml = str_replace("\n", "", $lockedHtml);
$lockedHtml = str_replace("\r", "", $lockedHtml);
// Use "PageLockLifetime*2/3" to add a good margin to lock timeout when pinging
// disabled due to #2556 and #2745
// $returnUrl = DataUtil::formatForDisplayHTML($returnUrl);
$html .= "
PageLock.LockName = '$lockName';
PageLock.ReturnUrl = '$returnUrl';
PageLock.PingTime = " . (PageLockLifetime*2/3) . ";
PageLock.LockedHTML = '" . $lockedHtml . "';
/* ]]> */</script>";
PageUtil::addVar('header', $html);
return true;
}
示例3: actionCropBg
public function actionCropBg()
{
if (EnvUtil::submitCheck("bgSubmit") && !empty($_POST["src"])) {
$params = $_POST;
if (!isset($params) && empty($params)) {
return null;
}
$tempBg = $params["src"];
$bgPath = "data/home/";
$bgBig = UserUtil::getBg($params["uid"], "big");
$bgMiddle = UserUtil::getBg($params["uid"], "middle");
$bgSmall = UserUtil::getBg($params["uid"], "small");
if (LOCAL) {
FileUtil::makeDirs($bgPath . dirname($bgBig));
}
FileUtil::createFile("data/home/" . $bgBig, "");
FileUtil::createFile("data/home/" . $bgMiddle, "");
FileUtil::createFile("data/home/" . $bgSmall, "");
Ibos::import("ext.ThinkImage.ThinkImage", true);
$imgObj = new ThinkImage(THINKIMAGE_GD);
if (!isset($params["noCrop"])) {
$imgObj->open($tempBg)->crop($params["w"], $params["h"], $params["x"], $params["y"], 1000, 300)->save($tempBg);
}
$imgObj->open($tempBg)->thumb(1000, 300, 1)->save($bgPath . $bgBig);
$imgObj->open($tempBg)->thumb(520, 156, 1)->save($bgPath . $bgMiddle);
$imgObj->open($tempBg)->thumb(400, 120, 1)->save($bgPath . $bgSmall);
if (isset($params["commonSet"]) && $params["commonSet"]) {
$this->setCommonBg($bgPath . $bgBig);
}
$this->ajaxReturn(array("isSuccess" => true));
exit;
}
}
示例4: __construct
/**
* Construct.
*
* @param int $objectId Object ID.
* @param int $areaId A blockinfo structure.
* @param string $module Module.
* @param string $urlString Url.
* @param Zikula_ModUrl $urlObject Url object.
*/
function __construct($objectId, $areaId, $module, $urlString = null, Zikula_ModUrl $urlObject = null)
{
parent::__construct($objectId, $areaId, $module, $urlString, $urlObject);
$args = $urlObject->getArgs();
$ot = $args['ot'];
if ($ot == 'posting') {
$posting = ModUtil::apiFunc('MUBoard', 'selection', 'getEntity', array('ot' => 'posting', 'id' => $this->getObjectId()));
// the Api checks for perms and there is nothing else to check
if ($posting) {
$userid = $posting->getCreatedUserId();
$date = $posting->getCreatedDate();
$title = $posting->getTitle();
$this->setObjectAuthor(UserUtil::getVar('uname', $userid));
$this->setObjectDate($date);
$this->setObjectTitle($title);
}
}
if ($ot == 'picture') {
$picture = ModUtil::apiFunc('MUImage', 'selection', 'getEntity', array('ot' => 'picture', 'id' => $this->getObjectId()));
// the Api checks for perms and there is nothing else to check
if ($picture) {
$userid = $picture->getCreatedUserId();
$date = $picture->getCreatedDate();
$title = $picture->getTitle();
$this->setObjectAuthor(UserUtil::getVar('uname', $userid));
$this->setObjectDate($date);
$this->setObjectTitle($title);
}
}
}
示例5: index
public function index()
{
$error = '';
if (RequestUtil::isPost()) {
$validate = new ValidateUtil();
$validate->required('user_name');
$validate->required('password');
$validate->required('verify_code');
$params = RequestUtil::postParams();
if ($params['verify_code'] != UserUtil::getVerifyCode()) {
$error = '验证码错误!';
} else {
if ($validate->run()) {
$userModel = new UserModel();
$params['password'] = $userModel->encodePassword($params['password']);
$where = array('user_name' => $params['user_name'], 'password' => $params['password']);
$user = (new CurdUtil($userModel))->readOne($where, 'user_id desc', '*, user_type+0 as type');
if (!$user) {
$error = '登录失败,账号或者密码错误,请重试!';
} else {
(new CurdUtil($userModel))->update($where, array('last_login_time' => DateUtil::now()));
UserUtil::saveUser($user);
if (UserUtil::isAdmin()) {
ResponseUtil::redirect(UrlUtil::createBackendUrl('project/index'));
} else {
ResponseUtil::redirect(UrlUtil::createBackendUrl('beautician/index'));
}
}
}
}
}
$this->load->view('backend/login', array('error' => $error));
}
示例6: setupForgotPassword
public static function setupForgotPassword($email)
{
$sdb = SDB::getInstance();
$user = UserUtil::getUser($email);
$ufid = SDB::uuid();
$aa = array('uid' => $user['id'], 'createdAt' => date('Y-m-d'));
if (!$sdb->put(self::$DOMAIN_USERS_FORGOT, $ufid, $aa, true)) {
return false;
}
$activationLink = 'http://' . $_SERVER['HTTP_HOST'] . '/home/login/passwordReset?ufid=' . $ufid;
$to = $email;
$subject = 'AdWhirl Password Reset';
$message = 'Hello AdWhirl User,
We received a request to reset your password. Click on the link below to set up a new password for your account.
' . $activationLink . '
If you did not request to reset your password, ignore this email - the link will expire on its own.
Best,
AdWhirl Team
';
mail($to, $subject, $message);
return true;
}
示例7: 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;
}
示例8: display
/**
* Display the block.
*
* @param array $blockinfo the blockinfo structure
*
* @return string output of the rendered block
*/
public function display($blockinfo)
{
// only show block content if the user has the required permissions
if (!SecurityUtil::checkPermission('Reviews:ModerationBlock:', "{$blockinfo['title']}::", ACCESS_OVERVIEW)) {
return false;
}
// check if the module is available at all
if (!ModUtil::available('Reviews')) {
return false;
}
if (!UserUtil::isLoggedIn()) {
return false;
}
ModUtil::initOOModule('Reviews');
$this->view->setCaching(Zikula_View::CACHE_DISABLED);
$template = $this->getDisplayTemplate($vars);
$workflowHelper = new Reviews_Util_Workflow($this->serviceManager);
$amounts = $workflowHelper->collectAmountOfModerationItems();
// assign block vars and fetched data
$this->view->assign('moderationObjects', $amounts);
// set a block title
if (empty($blockinfo['title'])) {
$blockinfo['title'] = $this->__('Moderation');
}
$blockinfo['content'] = $this->view->fetch($template);
// return the block to the theme
return BlockUtil::themeBlock($blockinfo);
}
示例9: validate
/**
* @see Form::validate()
*/
public function validate()
{
// check valide email from guest
if (!WCF::getUser()->userID) {
if (empty($this->email)) {
throw new UserInputException('email');
}
if (!UserUtil::isValidEmail($this->email)) {
throw new UserInputException('email', 'notValid');
}
// check empty username
if (empty($this->username)) {
throw new UserInputException('username');
}
}
// check empty subject
if (empty($this->subject)) {
throw new UserInputException('subject');
}
// check empty message
if (empty($this->message)) {
throw new UserInputException('message');
}
parent::validate();
}
示例10: 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;
}
}
示例11: actionShare
public function actionShare()
{
if (empty($_GET["curid"])) {
$map["feedid"] = EnvUtil::getRequest("sid");
} else {
$map["feedid"] = EnvUtil::getRequest("curid");
}
$map["isdel"] = 0;
$isExist = Feed::model()->countByAttributes($map);
if ($isExist == 0) {
$return["isSuccess"] = false;
$return["data"] = "内容已被删除,转发失败";
$this->ajaxReturn($return);
}
$return = Feed::model()->shareFeed($_GET, "share");
if ($return["isSuccess"]) {
$module = $_GET["module"];
if ($module == "weibo") {
UserUtil::updateCreditByAction("forwardweibo", Ibos::app()->user->uid);
$suid = Ibos::app()->db->createCommand()->select("uid")->from("{{feed}}")->where(sprintf("feedid = %d AND isdel = 0", $map["feedid"]))->queryScalar();
$suid && UserUtil::updateCreditByAction("forwardedweibo", $suid);
}
}
$this->ajaxReturn($return, "JSONP");
}
示例12: confirm
public function confirm()
{
$_SESSION = array();
$uid = $_GET['uid'];
$result = UserUtil::confirmUser($uid);
return $this->smarty->fetch('../tpl/www/home/confirmProcessed.tpl');
}
示例13: 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');
}
示例14: actionCropImg
public function actionCropImg()
{
if (EnvUtil::submitCheck("userSubmit")) {
$params = $_POST;
if (!isset($params) && empty($params)) {
return null;
}
$tempAvatar = $params["src"];
$avatarPath = "data/avatar/";
$avatarBig = UserUtil::getAvatar($params["uid"], "big");
$avatarMiddle = UserUtil::getAvatar($params["uid"], "middle");
$avatarSmall = UserUtil::getAvatar($params["uid"], "small");
if (LOCAL) {
FileUtil::makeDirs($avatarPath . dirname($avatarBig));
}
FileUtil::createFile("data/avatar/" . $avatarBig, "");
FileUtil::createFile("data/avatar/" . $avatarMiddle, "");
FileUtil::createFile("data/avatar/" . $avatarSmall, "");
Ibos::import("ext.ThinkImage.ThinkImage", true);
$imgObj = new ThinkImage(THINKIMAGE_GD);
$imgObj->open($tempAvatar)->crop($params["w"], $params["h"], $params["x"], $params["y"])->save($tempAvatar);
$imgObj->open($tempAvatar)->thumb(180, 180, 1)->save($avatarPath . $avatarBig);
$imgObj->open($tempAvatar)->thumb(60, 60, 1)->save($avatarPath . $avatarMiddle);
$imgObj->open($tempAvatar)->thumb(30, 30, 1)->save($avatarPath . $avatarSmall);
$this->success(Ibos::lang("Upload avatar succeed"), $this->createUrl("home/personal", array("op" => "avatar")));
exit;
}
}
示例15: display
function display()
{
$prevpage = null;
$nextpage = null;
$page = ModUtil::apiFunc('Content', 'Page', 'getPage', array('id' => $this->pageId));
$tables = DBUtil::getTables();
$pageTable = $tables['content_page'];
$pageColumn = $tables['content_page_column'];
$options = array('makeTree' => true);
$options['orderBy'] = 'position';
$options['orderDir'] = 'desc';
$options['pageSize'] = 1;
$options['filter']['superParentId'] = $page['parentPageId'];
if ($page['position'] > 0) {
$options['filter']['where'] = "{$pageColumn['level']} = {$page['level']} and {$pageColumn['position']} < {$page['position']}";
$pages = ModUtil::apiFunc('Content', 'Page', 'getPages', $options);
if (count($pages) > 0) {
$prevpage = $pages[0];
}
}
if (isset($page['position']) && $page['position'] >= 0) {
$options['orderDir'] = 'asc';
$options['filter']['where'] = "{$pageColumn['level']} = {$page['level']} and {$pageColumn['position']} > {$page['position']}";
$pages = ModUtil::apiFunc('Content', 'Page', 'getPages', $options);
if (count($pages) > 0) {
$nextpage = $pages[0];
}
}
$this->view->assign('loggedin', UserUtil::isLoggedIn());
$this->view->assign('prevpage', $prevpage);
$this->view->assign('nextpage', $nextpage);
return $this->view->fetch($this->getTemplate());
}