Inheritance: extends Model
 /**
  * Removes the $userId from this project.
  * Note that you still need to call write() to persist the model.
  * @param string $userId
  */
 public function removeUser($userId)
 {
     $this->_removeUser($userId);
     $userModel = new UserModel($userId);
     $userModel->_removeProject($this->id);
     $userModel->write();
 }
Beispiel #2
0
 /**
  * 节的详细页(视频学习页)
  *
  */
 function infoAction()
 {
     $videoId = (int) $this->get("video_id", 0);
     $videoId = $videoId ? $videoId : $this->section['video_id'];
     $videoModel = new VideoModel();
     $video = $videoModel->getVideo($videoId);
     $video['is_user_like'] = $videoModel->isUserLikeOrDislike($this->uid, $videoId);
     $data = array('course_id' => $this->course['id'], 'course_name' => $this->course['name'], 'chapter_id' => $this->chapter['id'], 'chapter_name' => $this->chapter['name'], 'chatper_seq' => $this->chapter['seq'], 'section_id' => $this->section['id'], 'section_name' => $this->section['name'], 'section_seq' => $this->section['seq'], 'video_id' => $video['id'], 'video_url' => $video['url'], 'video_duration' => $video['duration'], 'duration' => $video['duration'], 'video_image' => $video['image'], 'video_like_num' => $video['like_num'], 'video_dislike_num' => $video['dislike_num'], 'video_view_num' => $video['view_num'], 'is_user_like' => $video['is_user_like']);
     if (!$this->teacher || $this->teacher['id'] != $video['user_id']) {
         $userModel = new UserModel();
         $this->teacher = $userModel->getTeacher($video['user_id']);
     }
     $data['teacher'] = array('id' => $this->teacher['id'], 'name' => $this->teacher['name'], 'job_title' => $this->teacher['job_title'], 'avator' => $this->teacher['avator']);
     if ($this->isMobile) {
         $this->displayJson(Common_Error::ERROR_SUCCESS, $data);
     }
     if ($this->course['type'] == 1) {
         $practiseModel = new PractiseModel();
         $practise = $practiseModel->getVideoBelongPractise($videoId, $this->course['id']);
         $this->assign("practise", $practise);
     }
     $this->assign("course", $this->course);
     $this->assign("chapter", $this->chapter);
     $this->assign("section", $this->section);
     $this->assign("teacher", $this->teacher);
     $this->assign("video", $video);
 }
Beispiel #3
0
 public function run()
 {
     $autorize = Project::getSecurityManager()->getAutorize();
     $controller_class = $autorize->getController()->name;
     $controller = new $controller_class();
     $controller->init($autorize->getController(), $autorize->getAction());
     $action_function = $autorize->getAction()->name . 'Action';
     setcookie('PHPSESSID', session_id(), null, null, Project::getUser()->getDbUser()->login . '.next24.ru');
     $controller->{$action_function}();
     $this->_request_complete = true;
     // Сохраняем время пользователя на серваке
     $user = Project::getUser()->getDbUser();
     if ($user->id) {
         $userModel = new UserModel();
         $userModel->refreshUsersOnline();
         if (!$userModel->isUserOnline($user->id)) {
             $userModel->addUserOnline($user->id);
         } else {
             $userModel->updateUserOnline($user->id);
         }
         $userModel = new UserModel();
         $user = $userModel->getUserById($user->id);
         $userModel->checkForUserBans($user);
     }
     // END Сохраняем время пользователя на серваке
     return $controller;
 }
 public function allPaginated(User $user)
 {
     if ($user->access() < 3) {
         return CreditModel::with('user', 'user.staff')->where('staff_id', $user->staff->id)->paginate($this->resultsPerPage);
     }
     return CreditModel::with('user', 'user.staff')->paginate($this->resultsPerPage);
 }
    /**
     * Load user by a particular field
     * @param  string $field    The field to find by
     * @param  string $value    The field value
     * @return UserModel
     */
    public static function loadBy($field, $value)
    {
        global $wpdb;

        $UserModel = new UserModel();
        switch ($field) {
            case 'id':
                $memberData = $wpdb->get_row($wpdb->prepare("SELECT * FROM {$wpdb->prefix}{$UserModel->_tableName} WHERE user_id = %d AND status != 'deleted'", $value), ARRAY_A);
                break;
            case 'verification_code':
                $memberData = $wpdb->get_row($wpdb->prepare("SELECT * FROM {$wpdb->prefix}{$UserModel->_tableName} WHERE verification_code = %s AND status != 'deleted'", $value), ARRAY_A);
                break;
            case 'reset_password_code':
                $memberData = $wpdb->get_row($wpdb->prepare("SELECT * FROM {$wpdb->prefix}{$UserModel->_tableName} WHERE reset_password_code = %s AND status != 'deleted'", $value), ARRAY_A);
                break;
            case 'email_address':
                $memberData = $wpdb->get_row($wpdb->prepare("SELECT * FROM {$wpdb->prefix}{$UserModel->_tableName} WHERE email_address = %s AND status != 'deleted'", $value), ARRAY_A);
                break;
        }

        if ($memberData) {
            $UserModel->setId($memberData['user_id']);
            $UserModel->populateFromArray($memberData);

            if ($UserModel->getStatus() == 'deleted') {
                return new UserModel();
            }
        }

        return $UserModel;
    }
Beispiel #6
0
 public function onedaysummaryAction()
 {
     $now = time();
     $onedaybefore = $now - 60 * 60 * 24;
     $threadModel = new ThreadModel();
     $newThread = $threadModel->newThreadsFrom($onedaybefore);
     $topThread = $threadModel->topThreadsFrom(10, $onedaybefore);
     $bbsHero = $threadModel->topBbsHero(10, $onedaybefore);
     $newscenter = new NewscenterModel();
     $news = $newscenter->news(1, 10, "apple");
     $data = array();
     $data["newThread"] = $newThread;
     $data["topThread"] = $topThread;
     $data["bbsHero"] = $bbsHero;
     $data["news"] = $news;
     $mail = new MailModel();
     $userModel = new UserModel();
     $users = $userModel->dailyNewsUser();
     foreach ($users as $user) {
         $data["user"] = $user;
         $page = $this->makePage("MailTemplate", "dailysummary", $data);
         $mail->generateMail($user["email"], "OurCoders社区 <*****@*****.**>", "OurCoders社区每日精选", $page, 0);
     }
     echo "ok";
 }
Beispiel #7
0
 public function indexAction()
 {
     $p = $_REQUEST;
     $pPhone = empty($p['phone']) ? '' : trim($p['phone']);
     $pNewptxt = empty($p['newptxt']) ? '' : trim($p['newptxt']);
     $pCode = empty($p['code']) ? '' : intval(trim($p['code']));
     $tTime = time();
     if (empty($pPhone)) {
         Tool_Fnc::ajaxMsg('请输入手机号码');
     }
     if (empty($pNewptxt)) {
         Tool_Fnc::ajaxMsg('请输入新密码');
     }
     if (!Tool_Validate::mo($pPhone)) {
         Tool_Fnc::ajaxMsg('手机号不正确');
     }
     $tMO = new UserModel();
     $tRow = $tMO->field('*')->where('phone = \'' . $pPhone . '\'')->fRow();
     if (empty($tRow['id'])) {
         Tool_Fnc::ajaxMsg('用户不存在');
     }
     $tCodeMO = new PhonecodeModel();
     $tCodeCRow = $tCodeMO->check($pPhone, 2, $pCode);
     if ($tCodeCRow['status'] == 0) {
         Tool_Fnc::ajaxMsg($tCodeCRow['msg']);
     }
     $tKey = Tool_Fnc::newrand(4);
     $tMd5str = Tool_Fnc::markmd5($pNewptxt, $tKey);
     $tData = array('passwd' => $tMd5str, 'id' => $tRow['id'], 'private_key' => $tKey);
     if ($tMO->update($tData)) {
         Tool_Fnc::ajaxMsg('密码修改成功', 1);
     }
     Tool_Fnc::ajaxMsg('密码修改失败');
 }
Beispiel #8
0
 public function index()
 {
     //var_dump($_SESSION['qq']);
     $articleId = $_GET['articleId'];
     $article = new ArticleModel();
     $content = $article->getArticleById($articleId);
     $collect = new CollectModel();
     $comment = new CommentModel();
     $commentNum = $comment->getCommentCountByArticleId($articleId);
     $content['commentNum'] = $commentNum;
     if ($this->isLogin()) {
         if ($collect->getCollects($article, $_SESSION['qq']['userId'])) {
             $this->assign('collects', '已收藏');
         } else {
             $collectNum = $collect->getCollectCountByuserId($article);
             $this->assign('collectNum', $collectNum);
             $this->assign('collects', '收藏');
         }
     }
     $this->assign('article', $content);
     //评论查询
     $comments = $comment->getComment($articleId);
     $user = new UserModel();
     $arr = array();
     foreach ($comments as $key => $val) {
         $val[$key]['user'] = $user->getUserById($val['userId']);
     }
     $this->assign('comments', $comments);
     $this->display();
 }
Beispiel #9
0
 public function DebuguserresetMethod()
 {
     $this->bAjaxMethod = true;
     $oUser = new UserModel();
     echo $oUser->DebugUserReset();
     $oUser->oPDO = NULL;
 }
Beispiel #10
0
 public function indexAction()
 {
     $auth = Zend_Auth::getInstance();
     if (!$auth->hasIdentity()) {
         throw new Exception("Please login");
     }
     $user = User::factory($auth->getIdentity());
     if (!$user->isAdmin()) {
         throw new Exception("You must be an admin to view this page.");
     }
     $this->_helper->viewRenderer->setNoRender();
     Zend_Loader::loadClass("UserModel");
     $usermodel = new UserModel();
     $users = $usermodel->getUserList();
     foreach ($users as $username) {
         $user = User::factory($username);
         $memcount = $usermodel->getMemberCount($user);
         for ($i = 0; $i < $memcount; $i++) {
             $member = $usermodel->getMember($user, $i);
             if (!empty($member->email)) {
                 echo "{$member->email}, ";
             }
         }
     }
 }
 /**
  * Returns whether or not the user meets the criteria necessary to trigger the event
  *
  * @param mixed     $options
  * @param UserModel $user
  * @param array     $params
  *
  * @return bool
  */
 public function validateOptions($options, UserModel $user, array $params = array())
 {
     $isNewUser = isset($params['isNewUser']) && $params['isNewUser'];
     $onlyWhenNew = isset($options['usersSaveUserOnlyWhenNew']) && $options['usersSaveUserOnlyWhenNew'];
     // If any user groups were checked
     // Make sure the user is in one of the groups
     if (!empty($options['usersSaveUserGroupIds']) && count($options['usersSaveUserGroupIds'])) {
         $inGroup = false;
         $userGroups = $user->getGroups('id');
         foreach ($options['usersSaveUserGroupIds'] as $groupId) {
             if (array_key_exists($groupId, $userGroups)) {
                 $inGroup = true;
             }
         }
         if (!$inGroup) {
             return false;
         }
     }
     // If only new users was checked
     // Make sure this user is new
     if (!$onlyWhenNew || $onlyWhenNew && $isNewUser) {
         return true;
     }
     return false;
 }
Beispiel #12
0
 public function getStaffDetails($userid)
 {
     $user_model = new UserModel();
     //GET NECESSARY USER DETAILS FROM MODEL
     $staff_details = $user_model->getUserDetails($userid);
     //GET USER EXISTING ROLE(S)
     $user_roles = $user_model->getUserRoles($userid);
     //EXTRACT ROLE ID(S)
     $user_role_ids = array();
     foreach ($user_roles as $role) {
         array_push($user_role_ids, $role[PermissionRoleTable::staff_role_id]);
     }
     //GET ALL STAFF ROLES
     $all_roles = $user_model->getAllRoles();
     //COMPARE USER EXISTING ROLE(S) WITH ALL STAFF ROLES TO EXTRACT
     //UNASSIGNED ROLES
     $available_roles = array();
     foreach ($all_roles as $role) {
         if (!in_array($role[StaffRoleTable::staff_role_id], $user_role_ids)) {
             array_push($available_roles, $role);
         }
     }
     //POPULATE ROLES IN RESPONSE ACCORDING TO AVAILABILITY
     $staff_details[ROLES][EXISTING] = $user_roles;
     $staff_details[ROLES][AVAILABLE] = $available_roles;
     return $staff_details;
 }
Beispiel #13
0
 public function indexAction()
 {
     $model = new UserModel();
     $user = $model->findById(1);
     echo $user->id;
     return FALSE;
 }
Beispiel #14
0
 public function actionInsert()
 {
     if (isset($_POST['submit']) && $_POST['submit'] == 'Insert Procuct') {
         $pro = new ProModel();
         $pro->name = $_POST['product_name'];
         $pro->description = $_POST['product_desc'];
         $product_image = $_FILES['product_image']['name'];
         $product_image_tmp = $_FILES['product_image']['tmp_name'];
         move_uploaded_file($product_image_tmp, "img/{$product_image}");
         $pro->image = $product_image;
         $pro->price = $_POST['product_price'];
         $pro->save();
         header('Location: http://localhost/task/task2/admin_area/index.php');
         exit;
     }
     if (isset($_POST['sub'])) {
         $user = new UserModel();
         $user->first_name = $_POST['fn'];
         $user->last_name = $_POST['ln'];
         $user->email = $_POST['em'];
         $user->save();
         $ord = new OrdersModel();
         $ord->user_id = $_POST['id'];
         $ord->sum = $_POST['price'];
         $ord->order_date = date("Y/m/d h:i:s");
         $ord->save();
         $ordPro = new OrdersProModel();
         $ordPro->order_id = $_POST['id'];
         $ordPro->product_id = $_POST['id'];
         $ordPro->qty = $_POST['quantity'];
         $ordPro->save();
         header('Location: http://localhost/task/task2/admin_area/index.php');
         exit;
     }
 }
Beispiel #15
0
 /**
  * construct function
  */
 public function __construct($controller, $action)
 {
     parent::__construct($controller, $action);
     $um = new UserModel();
     $this->user = $um->loadUser();
     $this->setView('curUser', $this->user);
 }
Beispiel #16
0
 /**
  * 处理已读消息
  */
 public function setReadAction()
 {
     echo date('Y-m-d H:i:s') . ' setRead is started!' . PHP_EOL;
     $queueKey = Yaf\Application::app()->getConfig()->redisKeys->setReadQueue;
     $readKeyPrefix = Yaf\Application::app()->getConfig()->redisKeys->readKeyPrefix;
     $redis = RedisFactory::instance('ims', true);
     while (true) {
         while ($userId = $redis->lPop($queueKey)) {
             $key = $readKeyPrefix . '_' . $userId;
             while ($messageId = $redis->lpop($key)) {
                 $messageModel = new MessageModel($userId);
                 $messageModel->setIsRead($messageId);
             }
             //推送未读消息变动通知
             $userModel = new UserModel();
             pushModel::unreadMessageNotice($userModel->getUnreadMessageList(true));
         }
         try {
             // 闲置时检查Redis连接
             $redis->ping();
         } catch (\Exception $e) {
             $redis = RedisFactory::instance('ims', true, true);
             //重连
         }
         sleep(1);
     }
     exit;
 }
Beispiel #17
0
 public function modelAction()
 {
     $model = new \UserModel();
     $result = $model->fetchListByUids(array(1, 2));
     var_dump($result);
     return false;
 }
Beispiel #18
0
 public function getAction()
 {
     $appid = isset($_REQUEST['appid']) ? trim($_REQUEST['appid']) : '';
     $token = isset($_REQUEST['token']) ? trim($_REQUEST['token']) : '';
     $timestamp = isset($_REQUEST['timestamp']) ? trim($_REQUEST['timestamp']) : '';
     $version = isset($_REQUEST['version']) ? trim($_REQUEST['version']) : '';
     $sign_type = isset($_REQUEST['sign_type']) ? trim($_REQUEST['sign_type']) : 'md5';
     $sign = isset($_REQUEST['sign']) ? trim($_REQUEST['sign']) : '';
     $sing_arr = array('appid' => $appid, 'token' => $token, 'timestamp' => $timestamp, 'version' => $version, 'sign_type' => $sign_type);
     ksort($sing_arr);
     $concat = '';
     $signp = '';
     foreach ($sing_arr as $key => $value) {
         $signp = $signp . $key . '=' . urlencode($value);
         $concat = '&';
     }
     $usermodel = new UserModel($this->_basemodel);
     $userapp = $usermodel->getApp($appid);
     $mediauser = NULL;
     if ($userapp) {
         if ($sign == md5($signp . $userapp['app_key'])) {
             $mediauser = $usermodel->getMedia_user($appid, $token);
         } else {
             echo 'sign error';
         }
     }
     echo json_encode($mediauser);
     exit;
 }
 /**
  * Start a new conversation.
  *
  * @since 2.0.0
  * @access public
  *
  * @param string $Recipient Username of the recipient.
  */
 public function Add($Recipient = '')
 {
     $this->Form->SetModel($this->ConversationModel);
     if ($this->Form->AuthenticatedPostBack()) {
         $RecipientUserIDs = array();
         $To = explode(',', $this->Form->GetFormValue('To', ''));
         $UserModel = new UserModel();
         foreach ($To as $Name) {
             if (trim($Name) != '') {
                 $User = $UserModel->GetByUsername(trim($Name));
                 if (is_object($User)) {
                     $RecipientUserIDs[] = $User->UserID;
                 }
             }
         }
         $this->Form->SetFormValue('RecipientUserID', $RecipientUserIDs);
         $ConversationID = $this->Form->Save($this->ConversationMessageModel);
         if ($ConversationID !== FALSE) {
             $Target = $this->Form->GetFormValue('Target', 'messages/' . $ConversationID);
             $this->RedirectUrl = Url($Target);
         }
     } else {
         if ($Recipient != '') {
             $this->Form->SetValue('To', $Recipient);
         }
     }
     if ($Target = Gdn::Request()->Get('Target')) {
         $this->Form->AddHidden('Target', $Target);
     }
     $this->Title(T('New Conversation'));
     $this->SetData('Breadcrumbs', array(array('Name' => T('Inbox'), 'Url' => '/messages/inbox'), array('Name' => $this->Data('Title'), 'Url' => 'messages/add')));
     $this->Render();
 }
 function resetAction()
 {
     Zend_Loader::loadClass("UserModel");
     $userm = new UserModel();
     $user = $this->_request->get("user");
     $key = $this->_request->get("key");
     $obj = $userm->getRow($user);
     if (empty($obj) or empty($key)) {
         $this->_redirect("/");
     }
     $savedkey = $this->cache->load($user);
     if ($savedkey != $key) {
         $this->_redirect("/");
     }
     $this->cache->remove($user);
     $pass = "";
     for ($i = 0; $i < 8; $i++) {
         $pass = $pass . mt_rand(0, 9);
     }
     /* send email */
     $mail = Mailer::get_mailer();
     $baseurl = Zend_Controller_Front::getInstance()->getBaseUrl();
     if ($baseurl == "/") {
         $baseurl = "";
     }
     $mail->setBodyText("\n\nYou are receiving this email because you wished to reset your password\non http://{$_SERVER['SERVER_NAME']}{$baseurl}.\n\nWe have changed your password to: {$pass}\n\nPlease try logging in using this password and change it as soon as\npossible.\n\n");
     $mail->addTo($userm->getMember($obj, 0)->email, $userm->getMember($obj, 0)->name);
     $mail->setSubject("Password Reset");
     $mail->send();
     $obj->setPassword($pass);
 }
 /**
  * @param \Symfony\Component\Console\Input\InputInterface $input
  * @param \Symfony\Component\Console\Output\OutputInterface $output
  * @return int|void
  */
 protected function execute(InputInterface $input, OutputInterface $output)
 {
     $this->detectContao($output, true);
     if ($this->initContao()) {
         // Username
         if (($username = $input->getArgument('username')) === null) {
             $dialog = $this->getHelperSet()->get('dialog');
             $username = $dialog->ask($output, '<question>Username:</question>');
         }
         // Email
         if (($email = $input->getArgument('email')) === null) {
             $dialog = $this->getHelperSet()->get('dialog');
             $email = $dialog->ask($output, '<question>Email:</question>');
         }
         // Password
         if (($password = $input->getArgument('password')) === null) {
             $dialog = $this->getHelperSet()->get('dialog');
             $password = $dialog->ask($output, '<question>Password:</question>');
         }
         // Name
         if (($name = $input->getArgument('name')) === null) {
             $dialog = $this->getHelperSet()->get('dialog');
             $name = $dialog->ask($output, '<question>Name:</question>');
         }
         // create new user
         $user = new \UserModel();
         $user->setRow(array('username' => $username, 'name' => $name, 'email' => $email, 'password' => \Encryption::hash($password), 'admin' => 1))->save();
         $user->save();
         $output->writeln('<info>User <comment>' . $username . '</comment> successfully created</info>');
     }
 }
 private function Get_Last_User()
 {
     global $templates;
     $user = new UserModel();
     $row = $user->Get_Last_User();
     $templates->assgin('Last_User', $row);
 }
Beispiel #23
0
 /**
  * Controller的init方法会被自动首先调用
  */
 public function init()
 {
     //调试mysql
     if (isset($_GET['debug6429360'])) {
         $this->debug = true;
         DB_Mysqli::$DEBUG = 1;
     }
     $this->platform = isset($_REQUEST['platform']) ? $_REQUEST['platform'] : $this->platform;
     Yaf_Registry::set("platform", $this->platform);
     $this->isMobile = $this->platform == 'ios' || $this->platform == 'android';
     $this->wap = !$this->isMobile && Common_Mobile::isMobile();
     $this->uid = $this->get('uid', $this->post('uid', false));
     $this->controllerName = $this->getRequest()->getControllerName();
     $this->actionName = $this->getRequest()->getActionName();
     $userModel = new UserModel();
     /*        if (!isset(Common_Config::$NotNeedLogin[$this->controllerName][$this->actionName])
                 && $this->isMobile 
                 && $this->needLogin 
                 && !$this->debug) 
             {
                 $token = $this->get("token", $this->post("token", false));
                 if (!$token) {
                     $this->redirect(NULL, Common_Error::ERROR_TOKEN_NOT_EXISTS);
                 }
     
                 $api = $this->getRequestApi();
                 $check = Common_Token::check($token, $this->uid, strtolower($api));
                 if (!$check) {          
                     $this->redirect(NULL, Common_Error::ERROR_TOKEN);
                 }
             }*/
     $this->uid = $this->uid ? $this->uid : $userModel->getUid();
     /**
      * 如果是Ajax请求, 则关闭HTML输出
      */
     if ($this->getRequest()->isXmlHttpRequest() || 'POST' == $this->getRequest()->getMethod()) {
         $this->ajax = true;
         Yaf_Dispatcher::getInstance()->disableView();
     } else {
         //$path = $this->getView()->getScriptPath();
         //$path[0] = $path[0] . "/" . strtolower($this->getRequest()->getControllerName());
         //$this->getView()->setScriptPath($path[0]);
     }
     //print_r($this->uid?$this->uid:"null");
     //验证登录
     /*if (
                 !isset(Common_Config::$NotNeedLogin[$this->controllerName][$this->actionName]) 
                 && $this->needLogin 
                 && !$this->uid) {
                 $this->redirect("/user/login?from=" . (isset($_SERVER['HTTP_REFERER']) ? $_SERVER['HTTP_REFERER'] : ""), Common_Error::ERROR_USER_NOT_LOGIN);
     
                 $this->redirect("/user/verify", Common_Error::ERROR_USER_NOT_LOGIN);
             }*/
     //用户信息
     /*        if($this->uid) {
                 $user = $userModel->getUser($this->uid);
                 $this->assign("uInfo", $user);
                 Yaf_Registry::set("uid", $this->uid);
             }*/
 }
Beispiel #24
0
 public function testModel()
 {
     $model = new \UserModel();
     $result = $model->fetchListByUids(array(1, 2));
     $this->assertEquals(1, $result[0]['id']);
     $this->assertEquals('xiaocai', $result[0]['name']);
 }
Beispiel #25
0
 public function index()
 {
     $msg = new MsgModel();
     $str = "";
     $p = isset($_GET['p']) ? $_GET['p'] : 1;
     $pageSize = 12;
     $curPage = ($p - 1) * $pageSize;
     $limit = $curPage . ',' . $pageSize;
     $message = $msg->getMsg($limit);
     if (isset($_SESSION['user'])) {
         $mark = 1;
         $user = new UserModel();
         $uerinfo = $user->userInfo($_SESSION['user']);
         $this->assign('info', $uerinfo);
     } else {
         $mark = 0;
     }
     $counts = $msg->msgCount();
     if ($counts > $pageSize) {
         $page = new Page($counts, $p, $pageSize);
         $str = $page->show('themeuk.php');
     }
     $this->assign('page', $str);
     $this->assign('msg', $message);
     $this->assign('mark', $mark);
     $this->display();
 }
Beispiel #26
0
 public function indexAction()
 {
     $p = $_REQUEST;
     $pNewptxt = empty($p['newptxt']) ? '' : trim($p['newptxt']);
     $pOldptxt = empty($p['oldptxt']) ? '' : trim($p['oldptxt']);
     $tTime = time();
     if (empty($pOldptxt)) {
         Tool_Fnc::ajaxMsg('请输入旧密码');
     }
     if (empty($pNewptxt)) {
         Tool_Fnc::ajaxMsg('请输入新密码');
     }
     $tUMO = new UserModel();
     $tRow = $tUMO->field('id,passwd,private_key')->where('id = ' . $this->tUid)->fRow();
     if (!count($tRow)) {
         Tool_Fnc::ajaxMsg('读取信息失败');
     }
     $tOldptxt = Tool_Fnc::markmd5($pOldptxt, $tRow['private_key']);
     if ($tRow['passwd'] != $tOldptxt) {
         Tool_Fnc::ajaxMsg('旧密码不正确');
     }
     $tKey = Tool_Fnc::newrand(4);
     $tMd5str = Tool_Fnc::markmd5($pNewptxt, $tKey);
     $tData = array('id' => $tRow['id'], 'passwd' => $tMd5str, 'private_key' => $tKey, 'updated' => $tTime);
     if ($tUMO->update($tData)) {
         Tool_Fnc::ajaxMsg('密码修改成功', 1);
     }
     Tool_Fnc::ajaxMsg('密码修改失败');
 }
Beispiel #27
0
    public function showFriendsInGroup($user_id, $group_id)
    {
        $friendModel = new FriendModel();
        $aFirends = $friendModel->getFriendsInGroup($user_id, $group_id);
        $htmlStr = "";
        $counter = count($aFirends);
        $i = 1;
        $userModel = new UserModel();
        foreach ($aFirends as $friend) {
            $user_default_avatar = $userModel->getUserAvatar($friend['id']);
            $avator_path = $user_default_avatar['sys_av_id'] ? $user_default_avatar['sys_path'] : $user_default_avatar['path'];
            if (!$avator_path || $avator_path == 'no.png') {
                $avator_path = $this->image_url . 'avatar/no25.jpg';
            } else {
                $avator_path = $this->image_url . 'avatar/' . $avator_path;
            }
            $htmlStr .= '<dd class="friend-list-dd ' . ($counter == $i ? 'last' : '') . '">
							<a class="nm" href="' . Project::getRequest()->createUrl('User', 'Profile', null, $friend['login']) . '">' . $friend['login'] . '<img src="' . $avator_path . '" class="avatar" alt="' . $user_default_avatar['av_name'] . '" /></a>
							<span class="memo">( <span>Заметка</span>: ' . $friend['note'] . ' )</span>
							<div class="act">
	               				<form name="editForm" method="post" action="' . Project::getRequest()->createUrl('Messages', 'Friend') . '">
	               					<input type="hidden" value="changeFriend" name="messageAction" />
	               					<input type="hidden" value="' . $friend['id'] . '" name="friend_table_id"/>
	               					<a onclick="this.parentNode.submit(); return false;" href="#">редактировать</a>
	               				</form>													
							</div>
						</dd>';
            $i++;
        }
        return $htmlStr;
    }
 /**
  * Add a new conversations.
  */
 public function Add($Recipient = '')
 {
     $this->Form->SetModel($this->ConversationModel);
     if ($this->Form->AuthenticatedPostBack()) {
         $RecipientUserIDs = array();
         $To = explode(',', $this->Form->GetFormValue('To', ''));
         $UserModel = new UserModel();
         foreach ($To as $Name) {
             if (trim($Name) != '') {
                 $User = $UserModel->GetByUsername(trim($Name));
                 if (is_object($User)) {
                     $RecipientUserIDs[] = $User->UserID;
                 }
             }
         }
         $this->Form->SetFormValue('RecipientUserID', $RecipientUserIDs);
         $ConversationID = $this->Form->Save($this->ConversationMessageModel);
         if ($ConversationID !== FALSE) {
             $this->RedirectUrl = Url('messages/' . $ConversationID);
         }
     } else {
         if ($Recipient != '') {
             $this->Form->SetFormValue('To', $Recipient);
         }
     }
     $this->Render();
 }
Beispiel #29
0
 /**
  * Login user and store user informations in session
  * @param  string $login User login
  * @param  string $pass User password
  * @param  string $mode authorization method email/login
  * @param  string $role webmaster/administrator/admin
  * @return boolean
  */
 function loginUser($login, $password, $mode = "email", $role = "webmaster")
 {
     if (empty($login)) {
         return false;
     }
     $users = new UserModel();
     $c = new Criteria();
     if ($mode == "login") {
         $c->add("login", $login);
     } else {
         $c->add("email", $login);
     }
     $c->add("password", $password);
     $c->add("role", $role);
     $c->add("active", "1");
     $row = $users->find($c);
     if (!empty($row)) {
         foreach ($row as $key => $value) {
             $this->set($key, $value);
         }
         if (empty($row['login'])) {
             $this->set("login", $row['email']);
         }
         return true;
     }
     return false;
 }
Beispiel #30
0
 public function login()
 {
     //header('content-type:text/html;charset=utf-8');
     $qq = new QQLogin(self::QQAppid, self::QQCallback, self::QQAppkey);
     $openId = $qq->getOpenId();
     $user = new UserModel();
     if ($row = $user->getUserByOpenId($openId)) {
         //echo 123;
         $_SESSION['qq'] = $row;
         header('location:' . $qq->state);
     } else {
         //echo 456;
         //var_dump($qq->state);
         $arr = $qq->getUserInfo();
         //var_dump($arr);
         $data['openId'] = $openId;
         $data['userName'] = Data::filter($arr['nickname'], 9);
         $data['face'] = $arr['figureurl_qq_1'];
         $data['source'] = 'QQ';
         //var_dump($data);
         $row = $user->addUser($data);
         //var_dump($row);
         //var_dump($qq->state);
         if ($row) {
             $array = $user->getUserByOpenId($openId);
             $_SESSION['qq'] = $array;
             header('location:' . $qq->state);
         } else {
             E('对不起,亲,注册失败了');
         }
     }
 }