예제 #1
0
 public function users()
 {
     $users = \User::all();
     $deleted_users = \User::onlyTrashed()->lists('username', 'id');
     $suspended_users = \Throttle::where('suspended', 1)->count();
     $banned_users = \Throttle::where('banned', 1)->lists('user_id', 'user_id');
     $users_list = \User::all()->lists('username', 'id');
     $roles_list = \Role::lists('name', 'id');
     return \View::make('admin.users', compact('users', 'deleted_users', 'suspended_users', 'users_list', 'banned_users', 'roles_list'));
 }
예제 #2
0
 public function run()
 {
     //removes existing throttle records from table
     DB::table('throttle')->delete();
     $now = date('Y-m-d H:i:s');
     $faker = Faker::create();
     foreach (range(1, 21) as $index) {
         Throttle::create(['user_id' => $faker->unique()->numberBetween(1, 21), 'last_activity' => $now, 'last_login' => $now]);
     }
 }
예제 #3
0
 public function getAllUsersData()
 {
     try {
         $users = array();
         $tempUsers = \User::all()->toArray();
         foreach ($tempUsers as $user) {
             $banned = false;
             $suspended = false;
             $loginAttempt = 0;
             $usersThrottle = \Throttle::where('user_id', $user['id'])->get()->toArray();
             if (sizeof($usersThrottle) != 0) {
                 foreach ($usersThrottle as $userThrottle) {
                     if ($userThrottle['banned'] == true) {
                         $banned = true;
                     }
                     if ($userThrottle['suspended'] == true) {
                         $suspended = true;
                     }
                     $loginAttempt = $loginAttempt + $userThrottle['attempts'];
                 }
                 $user['banned'] = $banned;
                 $user['suspended'] = $suspended;
                 $user['loginAttempt'] = $loginAttempt;
             } else {
                 $user['banned'] = false;
                 $user['suspended'] = false;
                 $user['loginAttempt'] = 0;
             }
             $groupUser = \Sentry::findUserById($user['id']);
             $groups = $groupUser->getGroups()->toArray();
             if (sizeof($groups) != 0) {
                 $user['role'] = $groups[0]['name'];
             } else {
                 $user['role'] = '';
             }
             $users[] = $user;
         }
         return $users;
     } catch (\Exception $e) {
         \Log::error('Something Went Wrong in User Repository - getAllUsersData():' . $e->getMessage());
         throw new SomeThingWentWrongException();
     }
 }
예제 #4
0
 public function processSignUp()
 {
     $data = Input::all();
     $validator = User::validate_registration($data);
     if ($validator->fails()) {
         return Redirect::back()->withErrors($validator)->withInput(Input::except('password', 'password_confirm'));
     }
     $code = str_random(32);
     $user = User::create(['username' => $data['username'], 'email' => $data['email'], 'password' => Hash::make($data['password']), 'activation_code' => $code, 'activated' => 0]);
     $user->assignMemberRole();
     Throttle::create(['user_id' => $user->id]);
     Profile::create(['user_id' => $user->id]);
     $activation_link = URL::route('activate', $code);
     //$user->email is out of scope for the mail closure, hence to access it, we have defined "use ($user)"
     Mail::send('emails.users.activate', ['link' => $activation_link, 'username' => Input::get('username')], function ($message) use($user) {
         $message->to($user->email, $user->username)->subject('Activate Your Account');
     });
     return Redirect::to('login')->withActivationMessage(Lang::get('larabase.signup_success'));
 }
예제 #5
0
 function throttleCheck($amount)
 {
     if (!$this->to_holder['throttle_id']) {
         return;
     }
     $from = $this->from_holder;
     require_once "models/Throttle.php";
     $Throttle = new Throttle();
     $Throttle->get(array('brand_id' => array($from['brand_id']), 'user_id' => $from["user_id"], 'throttle_id' => $this->to_holder['throttle_id']));
     if ($Throttle->unusedAmt < $amount) {
         return "The transaction amount exceeds the calculated throttle limit of {$Throttle->unusedAmt}. Please try again at around " . round($Throttle->period / 2) . " seconds.";
     }
 }
예제 #6
0
 public static function sendLinkedinMessage($token, $LinkedinId, $message, $subject)
 {
     $xmlData = "<?xml version='1.0' encoding='UTF-8'?>\n\t\t<mailbox-item>\n\t\t<recipients>\n\t\t  <recipient>\n\t\t    <person path='/people/{$LinkedinId}'/>\n\t\t  </recipient>\n\t\t</recipients>\n\t\t<subject>{$subject}</subject> \n\t\t<body>{$message}</body>\n\t\t</mailbox-item>";
     $message_url = "https://api.linkedin.com/v1/people/~/mailbox?oauth2_access_token={$token}";
     $ch = curl_init();
     curl_setopt($ch, CURLOPT_URL, $message_url);
     curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, FALSE);
     curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, FALSE);
     curl_setopt($ch, CURLOPT_POST, true);
     curl_setopt($ch, CURLOPT_HTTPHEADER, array('Content-Type: text/xml'));
     curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
     curl_setopt($ch, CURLOPT_POSTFIELDS, $xmlData);
     $result = curl_exec($ch);
     curl_close($ch);
     // set throttle limit in database on the basis of result
     if ($result == '') {
         $CurrentUser = Auth::User();
         $throttle = DB::table('throttles')->where('throttles.user_id', '=', $CurrentUser->id)->first();
         if (empty($throttle)) {
             DB::table('throttles')->where('user_id', '=', $CurrentUser->id)->delete();
         }
         return true;
     } else {
         $CurrentUser = Auth::User();
         $throttle = DB::table('throttles')->where('throttles.user_id', '=', $CurrentUser->id)->first();
         if (empty($throttle)) {
             $user = new Throttle();
             $user->user_id = $CurrentUser->id;
             $user->totalMessageCount = 10;
             $user->save();
         }
         return false;
     }
     /*return $result;*/
 }
예제 #7
0
 private function getUnactionedUserCount()
 {
     $not_active = User::where('activated', 0)->get()->toArray();
     foreach ($not_active as $index => $user) {
         $throttled = Throttle::where('user_id', $user['id'])->get()->toArray();
         if (isset($throttled[0]) && ($throttled[0]['suspended'] == 1 || $throttled[0]['banned'] == 1)) {
             // Remove this user
             unset($not_active[$index]);
         }
     }
     return array('unactionedUserCount' => count($not_active));
 }