Пример #1
0
 public function run()
 {
     $nickName = Yii::app()->request->getParam('nickName');
     $gender = Yii::app()->request->getParam('gender');
     $birthday = Yii::app()->request->getParam('birthday');
     $mobile = Yii::app()->request->getParam('mobile');
     $email = Yii::app()->request->getParam('email');
     $portrait = Yii::app()->request->getParam('portrait');
     $background = Yii::app()->request->getParam('background');
     $work = Yii::app()->request->getParam('work');
     $userType = Yii::app()->request->getParam('userType');
     $company = Yii::app()->request->getParam('company');
     $role = Yii::app()->request->getParam('role');
     $title = Yii::app()->request->getParam('title');
     $followers = Yii::app()->request->getParam('followers');
     $floor = Yii::app()->request->getParam('floor');
     $location = Yii::app()->request->getParam('location');
     $skills = Yii::app()->request->getParam('skills');
     $interests = Yii::app()->request->getParam('interests');
     $website = Yii::app()->request->getParam('website');
     $wechatid = Yii::app()->request->getParam('wechat');
     $facebook = Yii::app()->request->getParam('facebook');
     $twitter = Yii::app()->request->getParam('twitter');
     $instagram = Yii::app()->request->getParam('instagram');
     $description = Yii::app()->request->getParam('content');
     $linkedin = Yii::app()->request->getParam('linkedin');
     $data = array('nickName' => $nickName, 'gender' => $gender, 'birthday' => $birthday, 'mobile' => $mobile, 'email' => $email, 'portrait' => $portrait, 'background' => $background, 'work' => $work, 'userType' => $userType, 'company' => $company, 'role' => $role, 'title' => $title, 'followers' => $followers, 'floor' => $floor, 'location' => $location, 'skills' => $skills, 'interests' => $interests, 'website' => $website, 'wechatid' => $wechatid, 'facebookid' => $facebook, 'twitterid' => $twitter, 'instagramid' => $instagram, 'linkedinid' => $linkedin, 'description' => $description);
     $proxy = new BAuth();
     $result = $proxy->createUser($data);
     if ($result['code'] == 200) {
         $this->controller->redirect('/user/list');
     } else {
         throw new CHttpException($result['code'], $result['message']);
     }
 }
Пример #2
0
 public function run()
 {
     $id = Yii::app()->request->getParam('id');
     $proxy = new BAuth();
     $result = $proxy->deleteUser($id);
     echo CJSON::encode($result);
 }
Пример #3
0
 public function run()
 {
     $proxy = new BAuth();
     $result = $proxy->getUserInfo($id);
     $type = $proxy->getUserType();
     $dp = new Companys();
     $dh = new Hubs();
     $company = $dp->getCompany();
     $hub = $dh->getHub();
     $this->controller->render('edit', array('type' => $type, 'company' => $company, 'hub' => $hub));
 }
Пример #4
0
 public function run()
 {
     $id = Yii::app()->request->getParam('id');
     $proxy = new BAuth();
     $result = $proxy->getUserInfo($id);
     if ($result['code'] == 200) {
         $this->controller->renderPartial('view', array('id' => $id, 'data' => $result['data']));
     } else {
         throw new CHttpException($result['code'], $result['message']);
     }
 }
Пример #5
0
 public function run()
 {
     $start = Yii::app()->request->getParam('start');
     $proxy = new BAuth();
     $result = $proxy->getUserList($start, 10);
     $count = $result['count'];
     if (Yii::app()->request->isAjaxRequest) {
         $data = array('recordsTotal' => $count, 'recordsFiltered' => $count, 'data' => $result['data']);
         echo CJSON::encode($data);
     } else {
         $this->controller->render('list', array('count' => $count));
     }
 }
Пример #6
0
 public function run()
 {
     $id = Yii::app()->request->getParam('id');
     $name = Yii::app()->request->getParam('name');
     $loginName = Yii::app()->request->getParam('loginName');
     $passowrd = Yii::app()->request->getParam('password');
     $level = Yii::app()->request->getParam('level');
     $data = array('name' => $name, 'loginName' => $loginName, 'password' => md5($password), 'level' => $level);
     $proxy = new BAuth();
     $result = $proxy->addAdmin($data);
     if ($result['code'] == 200) {
         $this->controller->redirect('/admin/list');
     } else {
         throw new CHttpException($result['code'], $result['message']);
     }
 }
Пример #7
0
 public function run()
 {
     $id = Yii::app()->request->getParam('id');
     $nickName = Yii::app()->request->getParam('nickName');
     $gender = Yii::app()->request->getParam('gender');
     $birthday = Yii::app()->request->getParam('birthday');
     $mobile = Yii::app()->request->getParam('mobile');
     $email = Yii::app()->request->getParam('email');
     $portrait = Yii::app()->request->getParam('portrait');
     $background = Yii::app()->request->getParam('background');
     $work = Yii::app()->request->getParam('work');
     $userType = Yii::app()->request->getParam('userType');
     $company = Yii::app()->request->getParam('company');
     $role = Yii::app()->request->getParam('role');
     $title = Yii::app()->request->getParam('title');
     $followers = Yii::app()->request->getParam('followers');
     $floor = Yii::app()->request->getParam('floor');
     $location = Yii::app()->request->getParam('location');
     $skills = Yii::app()->request->getParam('skills');
     $interests = Yii::app()->request->getParam('interests');
     $wechatid = Yii::app()->request->getParam('wechat');
     $website = Yii::app()->request->getParam('website');
     $facebook = Yii::app()->request->getParam('facebook');
     $twitter = Yii::app()->request->getParam('twitter');
     $instagram = Yii::app()->request->getParam('instagram');
     $description = Yii::app()->request->getParam('content');
     $linkedin = Yii::app()->request->getParam('linkedin');
     $data = array('nickName' => $nickName, 'gender' => $gender, 'birthday' => $birthday, 'mobile' => $mobile, 'email' => $email, 'portrait' => $portrait, 'background' => $background, 'work' => $work, 'userType' => $userType, 'company' => $company, 'role' => $role, 'title' => $title, 'followers' => $followers, 'floor' => $floor, 'location' => $location, 'skills' => $skills, 'interests' => $interests, 'website' => $website, 'wechatid' => $wechatid, 'facebookid' => $facebook, 'twitterid' => $twitter, 'instagramid' => $instagram, 'linkedinid' => $linkedin, 'description' => $description);
     $proxy = new BAuth();
     if (Yii::app()->request->isAjaxRequest) {
         $result = $proxy->updateUser($data, $id);
         echo CJSON::encode($result);
     } else {
         $result = $proxy->getUserInfo($id);
         $type = $proxy->getUserType();
         $dp = new Companys();
         $dh = new Hubs();
         $company = $dp->getCompany();
         $hub = $dh->getHub();
         if ($result['code'] == 200) {
             $this->controller->render('edit', array('data' => $result['data'], 'type' => $type, 'company' => $company, 'hub' => $hub));
         } else {
             throw new CHttpException($result['code'], $result['message']);
         }
     }
 }
 public static function get_logged_in_members_level()
 {
     $auth = BAuth::get_instance();
     if (!$auth->is_logged_in()) {
         return bUtils::_("User is not logged in.");
     }
     return $auth->get('membership_level');
 }
Пример #9
0
 public function run()
 {
     $id = Yii::app()->request->getParam('id');
     $name = Yii::app()->request->getParam('name');
     $loginName = Yii::app()->request->getParam('loginName');
     $passowrd = Yii::app()->request->getParam('password');
     $level = Yii::app()->request->getParam('level');
     $data = array('name' => $name, 'loginName' => $loginName, 'password' => md5($password), 'level' => $level);
     $proxy = new BAuth();
     if (Yii::app()->request->isAjaxRequest) {
         $result = $proxy->updateAdmin($data, $id);
         echo CJSON::encode($result);
     } else {
         $result = $proxy->getAdminInfo($id);
         if ($result['code'] == 200) {
             $this->controller->render('edit', array('data' => $result['data']));
         } else {
             throw new CHttpException($result['code'], $result['message']);
         }
     }
 }
 public function edit()
 {
     global $wpdb;
     $auth = BAuth::get_instance();
     if (!$auth->is_logged_in()) {
         return;
     }
     $user_data = (array) $auth->userData;
     unset($user_data['permitted']);
     $form = new BForm($user_data);
     if ($form->is_valid()) {
         global $wpdb;
         $member_info = $form->get_sanitized();
         // update corresponding wp user.
         BUtils::update_wp_user($auth->get('user_name'), $member_info);
         if (isset($member_info['plain_password'])) {
             unset($member_info['plain_password']);
         }
         $wpdb->update($wpdb->prefix . "swpm_members_tbl", $member_info, array('member_id' => $auth->get('member_id')));
         $auth->reload_user_data();
         $message = array('succeeded' => true, 'message' => 'Profile Updated.');
         BTransfer::get_instance()->set('status', $message);
     } else {
         $message = array('succeeded' => false, 'message' => BUtils::_('Please correct the following'), 'extra' => $form->get_errors());
         BTransfer::get_instance()->set('status', $message);
         return;
     }
 }
 public function filter_post($id, $content)
 {
     if (in_array($id, $this->moretags)) {
         return $content;
     }
     if ($this->can_i_read_post($id)) {
         return $content;
     }
     $moretag = BSettings::get_instance()->get_value('enable-moretag');
     if (empty($moretag)) {
         return $this->lastError;
     }
     $post = get_post($id);
     $post_segments = explode('<!--more-->', $post->post_content);
     if (count($post_segments) >= 2) {
         if (BAuth::get_instance()->is_logged_in()) {
             $error_msg = '<div class="swpm-margin-top-10">' . BUtils::_(" The rest of the content is not permitted for your membership level.") . '</div>';
             $this->lastError = apply_filters('swpm_restricted_more_tag_msg', $error_msg);
         } else {
             $error_msg = '<div class="swpm-margin-top-10">' . BUtils::_("You need to login to view the rest of the content. ") . BSettings::get_instance()->get_login_link() . '</div>';
             $this->lastError = apply_filters('swpm_not_logged_in_more_tag_msg', $error_msg);
         }
         return do_shortcode($post_segments[0]) . $this->lastError;
     }
     return $this->lastError;
 }
Пример #12
0
 private function validate()
 {
     $auth_cookie_name = is_ssl() ? SIMPLE_WP_MEMBERSHIP_SEC_AUTH : SIMPLE_WP_MEMBERSHIP_AUTH;
     if (!isset($_COOKIE[$auth_cookie_name]) || empty($_COOKIE[$auth_cookie_name])) {
         return false;
     }
     $cookie_elements = explode('|', $_COOKIE[$auth_cookie_name]);
     if (count($cookie_elements) != 3) {
         return false;
     }
     Blog::log_simple_debug("validate:" . $_COOKIE[$auth_cookie_name], true);
     list($username, $expiration, $hmac) = $cookie_elements;
     $expired = $expiration;
     // Allow a grace period for POST and AJAX requests
     if (defined('DOING_AJAX') || 'POST' == $_SERVER['REQUEST_METHOD']) {
         $expired += HOUR_IN_SECONDS;
     }
     // Quick check to see if an honest cookie has expired
     if ($expired < time()) {
         $this->lastStatusMsg = BUtils::_("Session Expired.");
         //do_action('auth_cookie_expired', $cookie_elements);
         return false;
     }
     Blog::log_simple_debug("validate:Session Expired", true);
     global $wpdb;
     $query = " SELECT * FROM " . $wpdb->prefix . "swpm_members_tbl WHERE user_name = %s";
     $user = $wpdb->get_row($wpdb->prepare($query, $username));
     if (empty($user)) {
         $this->lastStatusMsg = BUtils::_("Invalid User Name");
         return false;
     }
     Blog::log_simple_debug("validate:Invalid User Name:" . serialize($user), true);
     $pass_frag = substr($user->password, 8, 4);
     $key = BAuth::b_hash($username . $pass_frag . '|' . $expiration);
     $hash = hash_hmac('md5', $username . '|' . $expiration, $key);
     if ($hmac != $hash) {
         $this->lastStatusMsg = BUtils::_("Sorry! Something went wrong");
         return false;
     }
     Blog::log_simple_debug("validate:bad hash", true);
     if ($expiration < time()) {
         $GLOBALS['login_grace_period'] = 1;
     }
     $this->userData = $user;
     return $this->check_constraints();
 }