/** * 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; }
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; }
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; } }
/** * 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); } } }
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)); }
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; }
/** * 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; }
/** * 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); }
/** * @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(); }
/** * 显示用户发送短信的界面 */ 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; } }
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"); }
public function confirm() { $_SESSION = array(); $uid = $_GET['uid']; $result = UserUtil::confirmUser($uid); return $this->smarty->fetch('../tpl/www/home/confirmProcessed.tpl'); }
/** * 删除用户选定的短信 */ 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'); }
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; } }
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()); }
/** * Return an array of items to show in the your account panel * * @return array */ public function getall($args) { $items = array(); $uname = (isset($args['uname'])) ? $args['uname'] : UserUtil::getVar('uname'); // does this user exist? if(UserUtil::getIdFromName($uname)==false) { // user does not exist return $items; } // Create an array of links to return if (SecurityUtil::checkPermission('News::', '::', ACCESS_COMMENT)) { $items[] = array('url' => ModUtil::url('News', 'user', 'newitem'), 'module' => 'News', 'title' => $this->__('Submit an article'), 'icon' => 'news_add.gif'); /* If users can save draft articles and the viewdraft function is implemented, this can be enabled $items[] = array('url' => ModUtil::url('News', 'user', 'viewdraft'), 'module' => 'News', 'title' => __('View personal draft articles', $dom), 'icon' => 'news_draft.gif'); */ } // Return the items return $items; }
function initialize(Zikula_Form_View $view) { $this->id = (int) FormUtil::getPassedValue('id', -1, 'GETPOST'); $objectid = FormUtil::getPassedValue('objectid', '', 'GETPOST'); $redirect = base64_decode(FormUtil::getPassedValue('redirect', '', 'GETPOST')); $view->caching = false; $comment = ModUtil::apiFunc('EZComments', 'user', 'get', array('id' => $this->id)); if ($comment == false || !is_array($comment)) { return LogUtil::registerError($this->__('No such comment found.'), ModUtil::url('EZComments', 'user', 'main')); } // check if user is allowed to modify this content $modifyowntime = (int) ModUtil::getVar('EZComments', 'modifyowntime'); $ts = strtotime($comment['date']); if (!SecurityUtil::checkPermission('EZComments::', '::', ACCESS_ADMIN)) { // user has no admin permissions. Only commenting user should be able to modify if ($comment['uid'] != UserUtil::getVar('uid')) { // foreign content and no admin permissions $view->assign('nomodify', 1); $this->nomodify = 1; } else { if ($modifyowntime > 0 && $ts + $modifyowntime * 60 * 60 < time()) { $view->assign('nomodify', 1); $this->nomodify = 1; } } } else { $view->assign('nomodify', 0); $this->nomodify = 0; } $view->assign('redirect', isset($redirect) && !empty($redirect) ? true : false); // finally asign the comment information $view->assign($comment); return true; }
/** * 显示用户更改邮件和密码的界面 * @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'); }
/** * 显示用户发送短信的界面 */ public function run() { $id = $this->getParameterFromGET('id'); if (!$id) { $this->AlertAndBack(SSE_USER_ID_IS_EMPTY); return; } //验证用户是否存在 if (!UserUtil::isExists($this->db, $id)) { $this->AlertAndBack(SSE_USER_IS_NOT_EXISTS); return; } //查看用户是否公开有邮件。 //如果没有,则不能向这个用户发送邮件 $sql = 'select public_user_email from base_user_info where id=?'; $sth = $this->db->Prepare($sql); $res = $this->db->Execute($sth, array($id)); $rows = $res->FetchRow(); if (!$rows['public_user_email']) { $this->AlertAndBack(SSE_USER_EMAIL_IS_NOT_PUBLIC); return; } $smarty = $this->getSmarty(); $fck = new FCKeditor("content"); $fck->BasePath = FCKEDITOR_BASEPATH; $fck->ToolbarSet = 'Basic'; $fck->Height = '400'; $fck->Width = '98%'; $smarty->assign('fck', $fck); $smarty->assign('id', $id); $smarty->assign('backurl', $this->getParameter('backurl')); $smarty->display('showsendemail.tmpl'); }
/** * get the username associated with a category * */ public function getusercategoryname($args) { $uid = isset($args['uid']) && $args['uid'] ? $args['uid'] : UserUtil::getVar('uid'); $uname = UserUtil::getVar('uname', $uid); $userCatName = "{$uname} [{$uid}]"; return $userCatName; }
/** * avatar search-user * * * @author Frank Schummertz, Carsten Volmer * @return output The search-user admin page. */ public function searchusers() { if (!SecurityUtil::checkPermission('Avatar::', '::', ACCESS_ADMIN)) { return LogUtil::registerPermissionError(); } $username = FormUtil::getPassedValue('username', '', 'GETPOST'); $userid = UserUtil::getIDFromName($username); if ($userid == false) { $username = ''; $avatar = ''; } else { $avatar = UserUtil::getVar('avatar', $userid); } $page = (int) FormUtil::getPassedValue('page', 1, 'GETPOST'); $perpage = (int) FormUtil::getPassedValue('perpage', 50, 'GETPOST'); list($avatarsarray, $allavatarscount) = ModUtil::apiFunc('Avatar', 'user', 'getAvatars', array('page' => $page, 'perpage' => $perpage)); // avoid some vars in the url of the pager unset($_GET['submit']); unset($_POST['submit']); unset($_REQUEST['submit']); $this->view->assign('avatarpath', ModUtil::getVar('Users', 'avatarpath')); $this->view->assign('username', $username); $this->view->assign('userid', $userid); $this->view->assign('avatar', $avatar); $this->view->assign('avatars', $avatarsarray); $this->view->assign('allavatarscount', $allavatarscount); $this->view->assign('page', $page); $this->view->assign('perpage', $perpage); return $this->view->fetch('Avatar_admin_searchusers.htm'); }
/** * 改变外观 */ 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'); }
/** * Constructor. * * @param integer $objectId Identifier of treated object. * @param integer $areaId Name of hook area. * @param string $module Name of the owning module. * @param string $urlString **deprecated** * @param Zikula_ModUrl $urlObject Object carrying url arguments. */ function __construct($objectId, $areaId, $module, $urlString = null, Zikula_ModUrl $urlObject = null) { // call base constructor to store arguments in member vars parent::__construct($objectId, $areaId, $module, $urlString, $urlObject); // derive object type from url object $urlArgs = $urlObject->getArgs(); $objectType = isset($urlArgs['ot']) ? $urlArgs['ot'] : 'review'; $component = $module . ':' . ucwords($objectType) . ':'; $perm = SecurityUtil::checkPermission($component, $objectId . '::', ACCESS_READ); if (!$perm) { return; } $entityClass = $module . '_Entity_' . ucwords($objectType); $serviceManager = ServiceUtil::getManager(); $entityManager = $serviceManager->getService('doctrine.entitymanager'); $repository = $entityManager->getRepository($entityClass); $useJoins = false; /** TODO support composite identifiers properly at this point */ $entity = $repository->selectById($objectId, $useJoins); if ($entity === false || !is_array($entity) && !is_object($entity)) { return; } $this->setObjectTitle($entity->getTitleFromDisplayPattern()); $dateFieldName = $repository->getStartDateFieldName(); if ($dateFieldName != '') { $this->setObjectDate($entity[$dateFieldName]); } else { $this->setObjectDate(''); } if (method_exists($entity, 'getCreatedUserId')) { $this->setObjectAuthor(UserUtil::getVar('uname', $entity['createdUserId'])); } else { $this->setObjectAuthor(''); } }
/** * User category selector. * * Available parameters: * - btnText: If set, the results are assigned to the corresponding variable instead of printed out * - cid: category ID * * Example * {selector_user_category cid="1" assign="category"} * * @param array $params All attributes passed to this function from the template. * @param Zikula_View $view Reference to the Zikula_View object. * * @return string HTML code of the selector. */ function smarty_function_selector_user_category($params, Zikula_View $view) { $field = isset($params['field']) ? $params['field'] : 'id'; $selectedValue = isset($params['selectedValue']) ? $params['selectedValue'] : 0; $defaultValue = isset($params['defaultValue']) ? $params['defaultValue'] : 0; $defaultText = isset($params['defaultText']) ? $params['defaultText'] : ''; $lang = isset($params['lang']) ? $params['lang'] : ZLanguage::getLanguageCode(); $name = isset($params['name']) ? $params['name'] : 'defautlselectorname'; $recurse = isset($params['recurse']) ? $params['recurse'] : true; $relative = isset($params['relative']) ? $params['relative'] : true; $includeRoot = isset($params['includeRoot']) ? $params['includeRoot'] : false; $includeLeaf = isset($params['includeLeaf']) ? $params['includeLeaf'] : true; $all = isset($params['all']) ? $params['all'] : false; $displayPath = isset($params['displayPath']) ? $params['displayPath'] : false; $attributes = isset($params['attributes']) ? $params['attributes'] : null; $assign = isset($params['assign']) ? $params['assign'] : null; $editLink = isset($params['editLink']) ? $params['editLink'] : true; $submit = isset($params['submit']) ? $params['submit'] : false; $multipleSize = isset($params['multipleSize']) ? $params['multipleSize'] : 1; $doReplaceRootCat = false; $userCats = ModUtil::apiFunc('ZikulaCategoriesModule', 'user', 'getusercategories', array('returnCategory' => 1, 'relative' => $relative)); $html = CategoryUtil::getSelector_Categories($userCats, $field, $selectedValue, $name, $defaultValue, $defaultText, $submit, $displayPath, $doReplaceRootCat, $multipleSize); if ($editLink && $allowUserEdit && UserUtil::isLoggedIn() && SecurityUtil::checkPermission('ZikulaCategoriesModule::', "{$category['id']}::", ACCESS_EDIT)) { $url = ModUtil::url('ZikulaCategoriesModule', 'user', 'edituser'); $html .= " <a href=\"{$url}\">" . __('Edit sub-categories') . '</a>'; } if ($assign) { $view->assign($assign, $html); } else { return $html; } }
/** * Vetos (denies) a login attempt, and forces the user to change his password. * * This handler is triggered by the 'user.login.veto' event. It vetos (denies) a * login attempt if the users's account record is flagged to force the user to change * his password maintained by the Users module. If the user does not maintain a * password on his Users account (e.g., he registered with and logs in with a Google * Account or an OpenID, and never established a Users password), then this handler * will not trigger a change of password. * * @param Zikula_Event $event The event that triggered this handler. * * @return void */ public static function forcedPasswordChangeListener(Zikula_Event $event) { $userObj = $event->getSubject(); $userMustChangePassword = UserUtil::getVar('_Users_mustChangePassword', $userObj['uid'], false); if ($userMustChangePassword && ($userObj['pass'] != Users_Constant::PWD_NO_USERS_AUTHENTICATION)) { $event->stop(); $event->setData(array( 'redirect_func' => array( 'modname' => self::$modname, 'type' => 'user', 'func' => 'changePassword', 'args' => array( 'login' => true, ), 'session' => array( 'var' => 'Users_Controller_User_changePassword', 'namespace' => 'Zikula_Users', ) ), )); LogUtil::registerError(__("Your log-in request was not completed. You must change your web site account's password first.")); } }
public function display($blockinfo) { // Security check (1) if (!SecurityUtil::checkPermission('IWmenu:topblock:', "$blockinfo[title]::", ACCESS_READ)) { return false; } // Check if the module is available. (2) if (!ModUtil::available('IWmenu')) { return false; } // Get variables from content block (3) //Get cached user menu $uid = is_null(UserUtil::getVar('uid')) ? '-1' : UserUtil::getVar('uid'); //Generate menu $menu_estructure = ModUtil::apiFunc('IWmenu', 'user', 'getMenuStructure'); // Defaults (4) if (empty($menu_estructure)) { return false; } // Create output object (6) $view = Zikula_View::getInstance('IWmenu'); // assign your data to to the template (7) $view->assign('menu', $menu_estructure); // Populate block info and pass to theme (8) $menu = $view->fetch('IWmenu_block_top.htm'); //$blockinfo['content'] = $menu; //return BlockUtil::themesideblock($blockinfo); return $menu; }
public function addDigg($feedId, $uid) { $data["feedid"] = $feedId; $data["uid"] = $uid; $data["uid"] = !$data["uid"] ? Ibos::app()->user->uid : $data["uid"]; if (!$data["uid"]) { $this->addError("addDigg", "未登录不能赞"); return false; } $isExit = $this->getIsExists($feedId, $uid); if ($isExit) { $this->addError("addDigg", "你已经赞过"); return false; } $data["ctime"] = time(); $res = $this->add($data); if ($res) { $feed = Source::getSourceInfo("feed", $feedId); Feed::model()->updateCounters(array("diggcount" => 1), "feedid = " . $feedId); Feed::model()->cleanCache($feedId); $user = User::model()->fetchByUid($uid); $config["{user}"] = $user["realname"]; $config["{sourceContent}"] = StringUtil::filterCleanHtml($feed["source_body"]); $config["{sourceContent}"] = str_replace("◆", "", $config["{sourceContent}"]); $config["{sourceContent}"] = StringUtil::cutStr($config["{sourceContent}"], 34); $config["{url}"] = $feed["source_url"]; $config["{content}"] = Ibos::app()->getController()->renderPartial("application.modules.message.views.remindcontent", array("recentFeeds" => Feed::model()->getRecentFeeds()), true); Notify::model()->sendNotify($feed["uid"], "message_digg", $config); UserUtil::updateCreditByAction("diggweibo", $uid); UserUtil::updateCreditByAction("diggedweibo", $feed["uid"]); } return $res; }
/** * Performs the actual search processing. */ public function search($args) { ModUtil::dbInfoLoad('Search'); $dbtables = DBUtil::getTables(); $pageTable = $dbtables['content_page']; $pageColumn = $dbtables['content_page_column']; $contentTable = $dbtables['content_content']; $contentColumn = $dbtables['content_content_column']; $contentSearchTable = $dbtables['content_searchable']; $contentSearchColumn = $dbtables['content_searchable_column']; $translatedPageTable = $dbtables['content_translatedpage']; $translatedPageColumn = $dbtables['content_translatedpage_column']; $sessionId = session_id(); // check whether we need to search also in translated content $multilingual = System::getVar('multilingual'); $currentLanguage = ZLanguage::getLanguageCode(); $searchWhereClauses = array(); $searchWhereClauses[] = '(' . Search_Api_User::construct_where($args, array($pageColumn['title']), $pageColumn['language']) . ')'; if ($multilingual) { $searchWhereClauses[] = '(' . Search_Api_User::construct_where($args, array($translatedPageColumn['title']), $translatedPageColumn['language']) . ')'; } $searchWhereClauses[] = '(' . Search_Api_User::construct_where($args, array($contentSearchColumn['text']), $contentSearchColumn['language']) . ')'; // add default filters $whereClauses = array(); $whereClauses[] = '(' . implode(' OR ', $searchWhereClauses) . ')'; $whereClauses[] = $pageColumn['active'] . ' = 1'; $whereClauses[] = "({$pageColumn['activeFrom']} IS NULL OR {$pageColumn['activeFrom']} <= NOW())"; $whereClauses[] = "({$pageColumn['activeTo']} IS NULL OR {$pageColumn['activeTo']} >= NOW())"; $whereClauses[] = $contentColumn['active'] . ' = 1'; $whereClauses[] = $contentColumn['visiblefor'] . (UserUtil::isLoggedIn() ? ' <= 1' : ' >= 1'); $titleFields = $pageColumn['title']; $additionalJoins = ''; if ($multilingual) { // if searching in non-default languages, we need the translated title $titleFields .= ', ' . $translatedPageColumn['title'] . ' AS translatedTitle'; // join also the translation table if required $additionalJoins = "LEFT OUTER JOIN {$translatedPageTable} ON {$translatedPageColumn['pageId']} = {$pageColumn['id']} AND {$translatedPageColumn['language']} = '{$currentLanguage}'"; // prevent content snippets in other languages $whereClauses[] = $contentSearchColumn['language'] . ' = \'' . $currentLanguage . '\''; } $where = implode(' AND ', $whereClauses); $sql = "\n SELECT DISTINCT {$titleFields},\n {$contentSearchColumn['text']} AS description,\n {$pageColumn['id']} AS pageId,\n {$pageColumn['cr_date']} AS createdDate\n FROM {$pageTable}\n JOIN {$contentTable}\n ON {$contentColumn['pageId']} = {$pageColumn['id']}\n JOIN {$contentSearchTable}\n ON {$contentSearchColumn['contentId']} = {$contentColumn['id']}\n {$additionalJoins}\n WHERE {$where}\n "; $result = DBUtil::executeSQL($sql); if (!$result) { return LogUtil::registerError($this->__('Error! Could not load items.')); } $objectArray = DBUtil::marshallObjects($result); foreach ($objectArray as $object) { $pageTitle = $object['page_title']; if ($object['translatedTitle'] != '') { $pageTitle = $object['translatedTitle']; } $searchItemData = array('title' => $pageTitle, 'text' => $object['description'], 'extra' => $object['pageId'], 'created' => $object['createdDate'], 'module' => 'Content', 'session' => $sessionId); if (!\DBUtil::insertObject($searchItemData, 'search_result')) { return \LogUtil::registerError($this->__('Error! Could not save the search results.')); } } return true; }
/** * Zikula_View function to include module specific javascripts * * Available parameters: * - modname module name (if not set, the current module is assumed) * if modname="" than we will look into the main javascript folder * - script name of the external javascript file (mandatory) * - modonly javascript will only be included when the the current module is $modname * - onload function to be called with onLoad handler in body tag, makes sense with assign set only, see example #2 * - assign if set, the tag and the script filename are returned * * Example: {modulejavascript modname=foobar script=module_admin_config.js modonly=1 } * Output: <script type="text/javascript" src="modules/foobar/javascript/module_admin_config.js"> * * Example: {modulejavascript modname=foobar script=module_admin_config.js modonly=1 onload="dosomething()" assign=myjs } * Output: nothing, but assigns a variable containing several values: * $myjs.scriptfile = "modules/foobar/javascript/module_admin_config.js" * $myjs.tag = "<script type=\"text/javascript\" src=\"modules/foobar/javascript/module_admin_config.js\"></script>" * $myjs.onload = "onLoad=\"dosomething()\""; * Possible code in master.tpl would be: * * ... * { $myjs.tag } * </head> * <body { $myjs.onload } > * ... * * which results in * * ... * <script type="text/javascript" src="modules/foobar/javascript/module_admin_config.js"></script> * </head> * <body onLoad="dosomething()" > * ... * * if foobar is the current module. * * @param array $params All attributes passed to this function from the template. * @param Zikula_View $view Reference to the Zikula_View object. * * @return string The tag. */ function smarty_function_modulejavascript($params, Zikula_View $view) { // check if script is set (mandatory) if (!isset($params['script'])) { $view->trigger_error(__f('Error! in %1$s: the %2$s parameter must be specified.', array('modulejavascript', 'script'))); return false; } // check if modname is set and if not, if $modonly is set if (!isset($params['modname'])) { if (isset($params['modonly'])) { // error - we want $modonly only with $modname $view->trigger_error(__f('Error! in %1$s: parameter \'%2$s\' only supported together with \'%3$s\' set.', array('modulejavascript', 'modonly', 'modname'))); return; } // we use the current module name $params['modname'] = ModUtil::getName(); } if (isset($params['modonly']) && $params['modname'] != ModUtil::getName()) { // current module is not $modname - do nothing and return silently return; } // if modname is empty, we will search the main javascript folder if ($params['modname'] == '') { $searchpaths = array('javascript', 'javascript/ajax'); } else { // theme directory $theme = DataUtil::formatForOS(UserUtil::getTheme()); $osmodname = DataUtil::formatForOS($params['modname']); $themepath = "themes/{$theme}/Resources/public/js/{$osmodname}"; // module directory $modinfo = ModUtil::getInfoFromName($params['modname']); $osmoddir = DataUtil::formatForOS($modinfo['directory']); $modpath = "modules/{$osmoddir}/Resources/public/js"; $syspath = "system/{$osmoddir}/Resources/public/js"; $searchpaths = array($themepath, $modpath, $syspath); } $osscript = DataUtil::formatForOS($params['script']); // search for the javascript $scriptsrc = ''; foreach ($searchpaths as $path) { if (is_readable("{$path}/{$osscript}")) { $scriptsrc = "{$path}/{$osscript}"; break; } } // if no module javascript has been found then return no content $tag = empty($scriptsrc) ? '' : '<script type="text/javascript" src="' . $scriptsrc . '"></script>'; // onLoad event handler used? $onload = isset($params['onload']) ? 'onLoad="' . $params['onload'] . '"' : ''; if (isset($params['assign'])) { $return = array(); $return['scriptfile'] = $scriptsrc; $return['tag'] = $tag; $return['onload'] = $onload; $view->assign($params['assign'], $return); } else { return $tag; } }
/** * display theme changing user interface */ public function main() { // check if theme switching is allowed if (!System::getVar('theme_change')) { LogUtil::registerError($this->__('Notice: Theme switching is currently disabled.')); $this->redirect(ModUtil::url('Users', 'user', 'main')); } if (!SecurityUtil::checkPermission('Theme::', '::', ACCESS_COMMENT)) { return LogUtil::registerPermissionError(); } // get our input $startnum = FormUtil::getPassedValue('startnum', isset($args['startnum']) ? $args['startnum'] : 1, 'GET'); // we need this value multiple times, so we keep it $itemsperpage = $this->getVar('itemsperpage'); // get some use information about our environment $currenttheme = ThemeUtil::getInfo(ThemeUtil::getIDFromName(UserUtil::getTheme())); // get all themes in our environment $allthemes = ThemeUtil::getAllThemes(ThemeUtil::FILTER_USER); $previewthemes = array(); $currentthemepic = null; foreach ($allthemes as $key => $themeinfo) { $themename = $themeinfo['name']; if (file_exists($themepic = 'themes/'.DataUtil::formatForOS($themeinfo['directory']).'/images/preview_medium.png')) { $themeinfo['previewImage'] = $themepic; $themeinfo['largeImage'] = 'themes/'.DataUtil::formatForOS($themeinfo['directory']).'/images/preview_large.png'; } else { $themeinfo['previewImage'] = 'system/Theme/images/preview_medium.png'; $themeinfo['largeImage'] = 'system/Theme/images/preview_large.png'; } if ($themename == $currenttheme['name']) { $currentthemepic = $themepic; unset($allthemes[$key]); } else { $previewthemes[$themename] = $themeinfo; } } $previewthemes = array_slice($previewthemes, $startnum-1, $itemsperpage); $this->view->setCaching(Zikula_View::CACHE_DISABLED); $this->view->assign('currentthemepic', $currentthemepic) ->assign('currenttheme', $currenttheme) ->assign('themes', $previewthemes) ->assign('defaulttheme', ThemeUtil::getInfo(ThemeUtil::getIDFromName(System::getVar('Default_Theme')))); // assign the values for the pager plugin $this->view->assign('pager', array('numitems' => sizeof($allthemes), 'itemsperpage' => $itemsperpage)); // Return the output that has been generated by this function return $this->view->fetch('theme_user_main.tpl'); }