PHP User::all Examples

PHP User::all - 30 examples found. These are the top rated real world PHP examples of User::all extracted from open source projects. You can rate examples to help us improve the quality of examples.
 public static function index()
 {
     self::check_admin_logged_in();
     $name = self::get_search_term();
     $users = User::all($name);
     View::make('user/index.html', array('users' => $users));
 }
Example #2
0
 public function register()
 {
     if (RequestMethods::post('register')) {
         $pass = RequestMethods::post("pass");
         $cpass = RequestMethods::post("cpass");
         $salt = strtr(base64_encode(mcrypt_create_iv(16, MCRYPT_DEV_URANDOM)), '+', '.');
         $cost = 10;
         $salt = sprintf("\$2a\$%02d\$", $cost) . $salt;
         $crypt = crypt($pass, $salt);
         $user = new User(array("full_name" => RequestMethods::post("full_name"), "email" => RequestMethods::post("email"), "password" => $crypt));
         $exist = User::all(array('email = ?' => RequestMethods::post("email")));
         if (empty($exist)) {
             if ($pass == $cpass) {
                 if ($user->validate()) {
                     $user->save();
                     return "success";
                 } else {
                     return "validation not good";
                 }
             } else {
                 return "Passwords do not match";
             }
         } else {
             return "User exists";
         }
     } else {
         header('Location: /');
     }
 }
Example #3
0
 /**
  * Display a listing of the resource.
  *
  * @return Response
  */
 public function index()
 {
     $users = User::all();
     $book_count = Book::all()->count();
     $chapter_count = Chapter::all()->count();
     return View::make('admin.admin_panel', array('pageTitle' => 'Admin Panel', 'users' => $users, 'book_count' => $book_count, 'chapter_count' => $chapter_count));
 }
 public function doRegister()
 {
     $username = Input::get('username');
     $password = Input::get('password');
     $password = Hash::make($password);
     if ($username != "" && $password != "") {
         $users = User::all();
         $usernames = array();
         foreach ($users as $user) {
             $usernames[] = $user->username;
         }
         if (!in_array($username, $usernames)) {
             $user = new User();
             $user->username = $username;
             $user->password = $password;
             $user->save();
             $userdata = array('username' => Input::get('username'), 'password' => Input::get('password'));
             if (Auth::attempt($userdata)) {
                 $user = Auth::user();
                 return Response::json(array('error' => false, 'userdata' => $user), 200);
             } else {
                 return Response::json(array('error' => true, 'reason' => 'login failed'), 200);
             }
         } else {
             return Response::json(array('error' => true, 'reason' => 'username not unique'), 200);
         }
     } else {
         return Response::json(array('error' => true, 'reason' => 'username or password is empty'), 200);
     }
 }
Example #5
0
 public function init($id_tovar)
 {
     $data = $_REQUEST;
     $join = "INNER JOIN koncentrator_tovarishestvo c ON(user.concetrator = c.name_konc)";
     $this->_Users = User::all(array('conditions' => array("is_admin <> ? and id_tovar= ?", 1, $id_tovar), 'joins' => $join));
     $this->id_tovar = $id_tovar;
     /* if (!isset($data[Users::PAGE])) {
               $this->_Users = User::find('all', array('limit' => 2), array('conditions' => "is_admin <> 1"));
               //var_dump($_Users);
               } else {
     
     
               $this->_Users = User::find('all', array('conditions' => "is_admin <> 1", 'limit' => 2, 'offset' => (($data[Users::PAGE] * 2) - 2)));
               //var_dump($_Users);
               } */
     $this->countPage = ceil(User::count(array('conditions' => "is_admin <> 1")) / 2);
     if (isset($data[self::BUTTON_DELETE])) {
         $User = User::find_by_login($data['login']);
         if ($User instanceof User) {
             $User->delete();
             Flight::redirect('/admin/users/' . $this->id_tovar . '?success=3');
         }
     }
     if (isset($data['saveUser'])) {
         if ($data['idUser'] === 'newUser') {
             return $this->addNewUser();
         } else {
             return $this->changeUser();
         }
     }
 }
Example #6
0
 function write_user_list()
 {
     $this->write_block_begin('User list');
     $this->write_form_begin('user_group_add.php', 'get');
     $this->write_form_preserve('redirect');
     echo '<label>Search for users: ';
     $this->write_form_field('text', 'user_filter', @$_REQUEST['user_filter']);
     echo '</label>';
     $this->write_form_end('Show');
     echo '<small>Make sure your lab partner has logged in with Justitia at least once.</small>';
     if (!isset($_REQUEST['user_filter'])) {
         return;
     }
     $filter = '%' . @$_REQUEST['user_filter'] . '%';
     echo '<table class="user-list">' . "\n";
     $users = User::all($filter);
     foreach ($users as $user) {
         echo '<tr>';
         echo '<td>', htmlspecialchars($user->name_and_login()), '</td>';
         if (UserGroup::contains($user)) {
             echo '<td>[already in group]</td>';
         } else {
             echo '<td><a href="user_group_add.php?add=' . $user->userid . '&amp;redirect=' . urlencode($_REQUEST['redirect']) . '">[add to group]</a></td>';
         }
         echo "</tr>\n";
     }
     echo '</table>';
     $this->write_block_end();
 }
 public function loginView()
 {
     $users = User::all();
     if (count($users) == 0) {
         $token = Utilities::generateTokenForm();
         $action = $this->app->urlFor('add_admin');
         $vars = array();
         if (isset($_SESSION['vars'])) {
             $vars = $_SESSION['vars'];
             unset($_SESSION['vars']);
         }
         $this->view = new NewAdmin($action, $token['token'], $vars);
         $this->view->display();
     } else {
         $action = $this->app->urlFor('login_post');
         $token = Utilities::generateTokenForm();
         $vars = array();
         if (isset($_SESSION['vars'])) {
             $vars = $_SESSION['vars'];
             unset($_SESSION['vars']);
         }
         $this->view = new LoginView($action, $token['token'], $vars);
         $this->view->display();
     }
 }
Example #8
0
 public function get_add()
 {
     $this->data['pools'] = Koki::to_dropdown(Pool::all(), 'id', 'pool_name', array(0 => 'All'));
     $this->data['users'] = Koki::to_dropdown(User::all(), 'id', 'first_name');
     $this->data['create'] = true;
     return View::make('themes.modul.' . $this->views . '.form', $this->data);
 }
 public function run()
 {
     $users = User::all();
     for ($i = 0, $length = count($users); $i < $length; $i++) {
         BusinessUser::create(['user_id' => $users[$i]->user_id, "business_name" => "企业名称_" . ($i + 1), "business_licence_no" => "1111111111111111" . ($i + 1), "business_licence_scan_path" => "http://7sbxao.com1.z0.glb.clouddn.com/avatar.jpg", "operational_name" => "logan", "operational_card_no" => "480023196807150234" . ($i + 1), "operational_phone" => "15902345624" . ($i + 1), "bank_account" => "315247183127" . ($i + 1), "deposit_bank" => "工商银行", "bank_outlets" => "大韩民国宇宙中心支行", "id_card_front_scan_path" => "http://7sbxao.com1.z0.glb.clouddn.com/avatar.jpg", "id_card_back_scan_path" => "http://7sbxao.com1.z0.glb.clouddn.com/avatar.jpg"]);
     }
 }
Example #10
0
 protected function createFakerAd()
 {
     $faker = Faker::create();
     $adtype = array("Informal Jam", "Formal Jam/Practice/Rehearsal", "Payed Gig", "Offering Lessons", "Wanting Lessons");
     $level = array("Beginner", "Intermediate", "Semi-Pro", "Professional");
     $original = array("Originals", "Covers", "Both");
     $venuetype = array("House", "Venue", "Recording Studio", "Event");
     $usertype = array("Band", "Musician");
     $genre = array("Acoustic Blues", "Electric Blues", "Bluegrass", "Classical", "Pop Country", "Traditional Country", "House", "Deep House", "Dubstep", "Trap", "Techno", "Downtempo", "Ambient", "Drums & Bass", "Video Game", "Americana", "Acoustic Folk", "Cajun Folk", "Celtic Folk", "Singer/Songwriter Folk", "Combo Jazz", "Dixieland Jazz", "Ensemble Jazz", "Fusion Jazz", "Latin Jazz", "Standards", "Acid Jazz", "Latin", "New Age", "Ambient", "Christian", "Classic Rock", "Dance", "Hard Rock", "Heavy Metal", "Indie Rock", "Latin Rock", "New Wave", "Pop", "Psychedelic", "Punk Rock", "Rock & Roll", "Rockabilly", "Singer/Songwriter", "Ska", "Soft Rock", "Southern Rock", "Top 40", "Hip Hop/Rap", "Classic Soul", "Neo-Soul", "Gospel", "Contemporary R&B", "Reggae", "Soundtrack", "World Music");
     $instrument = array("Full Band, Acoustic Guitar", "Classical Guitar", "Electric Guitar", "Steel Guitar", "Electric Bass", "Double Bass", "Ukelele", "Piano", "Keyboard", "Organ", "Accordion", "Drums", "Lead Rock/Pop Vocals", "Lead Jazz Vocals", "Bass Singer", "Baritone Singer", "Tenor Singer", "Alto Singer", "Mezzo-Soprano Singer", "Soprano Singer", "Cello", "Viola", "Violin", "Fiddle", "Banjo", "Harp", "Mandolin", "Trumpet", "Trombone", "Tuba", "French Horn", "Alto Sax", "Tenor Sax", "Flute", "Oboe", "Clarinet", "Harmonica", "Piccolo", "Bassoon");
     $equipment = array("P/A System", "Guitar Amp", "Bass Amp", "Drum Set", "Keyboard");
     for ($i = 1; $i <= 200; $i++) {
         $ad = new Ad();
         $ad->ad_type = $faker->randomElement($adtype);
         $ad->ad_need = implode(", ", $faker->randomElements($instrument, $count = rand(1, 3)));
         $ad->ad_title = $faker->state . " " . $faker->lastName;
         $ad->level = $faker->randomElement($level);
         $ad->comp = rand(0, 200);
         $ad->genre = implode(", ", $faker->randomElements($genre, $count = rand(1, 3)));
         $ad->date = $faker->dateTimeBetween($startDate = 'now', $endDate = '3 months');
         $ad->start_time = $faker->time($format = 'H:i:s', $min = 'now');
         $ad->description = $faker->realText;
         $ad->equipment = implode(", ", $faker->randomElements($equipment, $count = rand(0, 5)));
         $ad->venue_type = $faker->randomElement($venuetype);
         $ad->venue = "Tycoon Flats";
         $ad->address = "2926 N. St. Marys Street";
         $ad->city = "San Antonio";
         $ad->state = "TX";
         $ad->zip_code = "78212";
         $ad->user_id = User::all()->random(1)->id;
         $ad->ad_img = $faker->imageUrl($width = 640, $height = 480, $category = 'nightlife');
         $ad->save();
     }
 }
Example #11
0
 /**
  * Index Page for this controller.
  *
  * Maps to the following URL
  * 		http://example.com/index.php/welcome
  *	- or -
  * 		http://example.com/index.php/welcome/index
  *	- or -
  * Since this controller is set as the default controller in
  * config/routes.php, it's displayed at http://example.com/
  *
  * So any other public methods not prefixed with an underscore will
  * map to /index.php/welcome/<method_name>
  * @see http://codeigniter.com/user_guide/general/urls.html
  */
 public function index()
 {
     $this->load->model('User');
     $foos['results'] = User::all();
     $data['name'] = 'Mehdi';
     $this->twig->render('hello', $data);
 }
Example #12
0
 public function staff($app)
 {
     $app->output->addBreadcrumb('', 'CSGOShop');
     $app->output->addBreadcrumb('about/staff', 'Staff Team');
     $app->output->setTitle('Staff Team');
     $app->output->setActiveTab('about');
     $staff = User::all(['conditions' => ['rank >= ?', User::RANK_MODERATOR], 'order' => 'rank DESC']);
     $steamIDs = [];
     foreach ($staff as $user) {
         if ($user->requiresSync()) {
             $steamIDs[] = $user->id;
         }
     }
     if (count($steamIDs) > 0) {
         $data = $app->steam->getUser($steamIDs);
         foreach ($staff as $user) {
             if ($user->requiresSync()) {
                 $user->name = $data[$user->id]->personaname;
                 $user->avatar_url = $data[$user->id]->avatarfull;
                 $user->steam_status = $data[$user->id]->personastate > 0 ? 1 : 0;
                 $user->last_sync = time() + 600;
                 $user->save();
             }
         }
     }
     $app->output->render('about.staff', ['staff' => $staff]);
 }
Example #13
0
 public function setupDatabases()
 {
     $name = $this->call('migrate', array('--path' => 'app/database/migrations/setup/'));
     $name = $this->call('migrate');
     // create the roles
     $roles = ['Admin', 'Writer', 'Reader'];
     foreach ($roles as $r) {
         $role = Role::whereName($r)->first();
         if ($role == null) {
             $role = new Role();
             $role->name = $r;
             $role->display_name = $r;
             $role->save();
             $this->info("{$role->id} Creating Role:{$r}");
         }
     }
     foreach (User::all() as $u) {
         $this->info("{$u->id} : user: {$u->username}");
     }
     // add core assets
     $m = Asset::findFromTag('missing-user-image');
     if ($m == NULL) {
         $m = new Asset();
         $m->path = "assets/content/uploads";
         $m->saveLocalFile(public_path('assets/content/common/missing/profile-default.png'), 'profile-default.png');
         $m->tag = 'missing-user-image';
         $m->shared = 1;
         $m->type = Asset::ASSET_TYPE_IMAGE;
         $m->save();
     }
     $this->comment("****\tAll Databases for Halp have been setup :-) \t****");
     return;
 }
 public function index()
 {
     if (!(Auth::check() && Auth::user()->canManageUsers())) {
         return Redirect::to('/');
     }
     return View::make('users.index', array('css' => 'users', 'users' => User::all()));
 }
Example #15
0
 public function getUsers()
 {
     if (empty($this->users)) {
         $this->users = User::all();
     }
     return $this->users;
 }
Example #16
0
 /**
  * Sends newsletter to User groups
  */
 protected function _newsletters()
 {
     $now = date('Y-m-d');
     $emails = array();
     $newsletters = Newsletter::all(array("scheduled = ?" => $now), array("template_id", "group_id"));
     foreach ($newsletters as $n) {
         $template = Template::first(array("id = ?" => $n->template_id));
         $group = Group::first(array("id = ?" => $n->group_id), array("users"));
         $results = json_decode($group->users);
         if (count($results) == 1 && $results[0] == "*") {
             $users = User::all(array(), array("email"));
             foreach ($users as $user) {
                 array_push($emails, $user->email);
             }
         } else {
             foreach ($results as $r) {
                 array_push($emails, $r->email);
             }
         }
         $batches = array_chunk($emails, 100);
         foreach ($batches as $batch) {
             $e = implode(",", $batch);
             $this->notify(array("template" => "newsletter", "subject" => $template->subject, "message" => $template->body, "track" => true, "emails" => $e));
         }
     }
 }
 /**
  * This function will create a new user object and return the newly created user object.
  *
  * @param array $userInfo This should have the properties: username, firstname, lastname, password, ui_language
  *
  * @return mixed
  */
 public function registerUser(array $userInfo, $userLanguage)
 {
     $user = \User::create($userInfo);
     //make the first user an admin
     if (\User::all()->count() <= 1) {
         $user->is_admin = 1;
     }
     // Trim trailing whitespace from user first and last name.
     $user->firstname = trim($user->firstname);
     $user->lastname = trim($user->lastname);
     $user->save();
     \Setting::create(['ui_language' => $userLanguage, 'user_id' => $user->id]);
     /* Add welcome note to user - create notebook, tag and note */
     //$notebookCreate = Notebook::create(array('title' => Lang::get('notebooks.welcome_notebook_title')));
     $notebookCreate = new \Notebook();
     $notebookCreate->title = Lang::get('notebooks.welcome_notebook_title');
     $notebookCreate->save();
     $notebookCreate->users()->attach($user->id, ['umask' => \PaperworkHelpers::UMASK_OWNER]);
     //$tagCreate = Tag::create(array('title' => Lang::get('notebooks.welcome_note_tag'), 'visibility' => 0));
     $tagCreate = new \Tag();
     $tagCreate->title = Lang::get('notebooks.welcome_note_tag');
     $tagCreate->visibility = 0;
     $tagCreate->user_id = $user->id;
     $tagCreate->save();
     //$tagCreate->users()->attach($user->id);
     $noteCreate = new \Note();
     $versionCreate = new \Version(['title' => Lang::get('notebooks.welcome_note_title'), 'content' => Lang::get('notebooks.welcome_note_content'), 'content_preview' => mb_substr(strip_tags(Lang::get('notebooks.welcome_note_content')), 0, 255), 'user_id' => $user->id]);
     $versionCreate->save();
     $noteCreate->version()->associate($versionCreate);
     $noteCreate->notebook_id = $notebookCreate->id;
     $noteCreate->save();
     $noteCreate->users()->attach($user->id, ['umask' => \PaperworkHelpers::UMASK_OWNER]);
     $noteCreate->tags()->sync([$tagCreate->id]);
     return $user;
 }
Example #18
0
 public function update()
 {
     $id_user = Input::get('id');
     $user = User::find($id_user);
     $clave = Input::get('password');
     $user->first_name = Input::get('first_name');
     $user->last_name = Input::get('last_name');
     $user->email = Input::get('email');
     $user->username = Input::get('username');
     $user->password = Hash::make($clave);
     $user->tipo_usuario = Input::get('tipo_usuario');
     $user->save();
     $users = User::all();
     return View::make('lista_usuarios')->with('users', $users);
     //$data = Input::get('id');
     /*$user = User::find(1);
     		$user->first_name = Input::get('first_name');
     		$user->save();*/
     /*if (is_null ($user))
             {
                 App::abort(404);
             }
             $data = Input::all();
     
                 // Si la data es valida se la asignamos al usuario
                 $user->fill($data);
                 // Guardamos el usuario
                 $user->save();
                 // Y Devolvemos una redirección a la acción show para mostrar el usuario
                 return View::make('lista_usuarios')->with('users', $users);
      
                 // En caso de error regresa a la acción edit con los datos y los errores encontrados*/
 }
 public function all()
 {
     if (!Auth::user()->is_superadmin) {
         App::abort(403, 'Unauthorized action.');
     }
     return View::make("users/list", array("users" => User::all()));
 }
Example #20
0
 /**
  * @before _secure
  */
 public function manage()
 {
     $this->seo(array("title" => "Manage Account"));
     $view = $this->getActionView();
     $users = User::all(['type' => Db::convertType('admin|adm|afm', 'regex'), "org_id" => $this->org->_id]);
     $view->set('users', $users);
 }
 public function run()
 {
     $faker = Faker::create();
     foreach (range(1, 20) as $index) {
         CalendarEvent::create(['event_name' => $faker->bs, 'creator_id' => User::all()->random()->id, 'location_id' => Location::all()->random()->id, 'start_time' => $faker->time, 'end_time' => $faker->time, 'cost' => $faker->numberBetween($min = 25, $max = 500), 'description' => $faker->text($maxNbChars = 200), 'event_image' => $faker->image]);
     }
 }
 public static function hallinto()
 {
     $user = self::get_user_logged_in();
     $users = User::all();
     $categories = Category::all();
     View::make('hallinto.html', array('categories' => $categories, 'users' => $users, 'user' => $user));
 }
Example #23
0
 /**
  * [getData]
  * @return [type] [description]
  */
 public function getData()
 {
     $Model = $this->modelName;
     $all_reminders = $Model::all($this->dataTableColumns);
     $data = [];
     foreach ($all_reminders as $reminder) {
         // load relations
         $load_curr_project = $reminder->project;
         $load_curr_user = $reminder->user;
         $curr_reminder = $reminder;
         Debugbar::info($reminder);
         if (isset($reminder->user_id) && isset($reminder->project_id)) {
             $curr_proj = (object) ['id' => $reminder->reminder_id, 'name' => $reminder->project->name];
             $curr_user = (object) ['id' => $reminder->user_id, 'username' => $reminder->user->username];
             $curr_entry = (object) ['DT_RowId' => 'row_' . $reminder->id, 'reminders' => $curr_reminder, 'users' => $curr_user, 'projects' => $curr_proj];
             $data[] = $curr_entry;
         }
     }
     $all_projects = Project::orderBy('name', 'DESC')->get(['id', 'name']);
     $projects = [];
     foreach ($all_projects as $project) {
         $tmp_project = (object) ['value' => $project->id, 'label' => $project->name];
         $projects[] = $tmp_project;
     }
     $all_users = User::all(['id', 'username']);
     $users = [];
     foreach ($all_users as $user) {
         $tmp_user = (object) ['value' => $user->id, 'label' => $user->username];
         $users[] = $tmp_user;
     }
     $ret = ['data' => $data, 'projects' => $projects, 'users' => $users];
     return Response::json($ret);
 }
 public static function index()
 {
     self::check_logged_in();
     self::check_admin();
     $users = User::all();
     View::make('user/index.html', array('users' => $users));
 }
 public function elegant()
 {
     $users = User::all();
     foreach ($users as $user) {
         echo $user->name;
     }
 }
 public function callback()
 {
     //dd(Input::all());
     if (!$this->fb->generateSessionFromRedirect()) {
         return Redirect::to('/')->with('message', 'Error Facebook Connection!');
     } else {
         $user_fb = $this->fb->getGraph();
         $user = new User();
         $_SESSION['userFbID'] = $user_fb->getProperty('id');
         $name = $user_fb->getProperty('name');
         $id = $_SESSION['userFbID'];
         $email = $user_fb->getProperty('email');
         //$location = $user_fb->getProperty('location');
         $image = 'http://graph.facebook.com/' . $user_fb->getProperty('id') . '/picture?width=300';
         $user->name = $name;
         $user->fbId = $id;
         $user->email = $email;
         $user->image = $image;
         //$user->location = $location;
         $findUsers = User::all();
         $count = 0;
         foreach ($findUsers as $findUser) {
             if ($findUser['fbId'] == $_SESSION['userFbID']) {
                 $count = +1;
             }
         }
         if ($count == 0) {
             $user->save();
         }
         Auth::login($user);
         return Redirect::to('/home');
     }
 }
Example #27
0
 public function run()
 {
     $faker = Faker::create();
     for ($i = 0; $i < 30; $i++) {
         $tags = ['funny', 'troll', 'sad', 'current', 'serious', 'music', 'gaming', 'technology', 'business'];
         $j = 0;
         $tempArray = [];
         $randomNum = mt_rand(1, 3);
         $post = new Post();
         $post->title = $faker->catchPhrase . " " . $faker->catchPhrase;
         $post->body = $faker->realText(200, 2);
         $post->picture = $faker->image($dir = '/tmp', $width = 640, $height = 480);
         $post->user_id = User::all()->random(1)->id;
         do {
             $tag = $tags[mt_rand(0, sizeof($tags) - 1)];
             if ($j <= 1) {
                 array_push($tempArray, $tag);
                 unset($tags[$tag]);
             } else {
                 $tempArray = ["{$tag}"];
                 unset($tags[$tag]);
             }
             //var j to determine how many elements have been pushed
             $j++;
             $randomNum--;
         } while ($randomNum == 0);
         $post->tags = implode(", ", $tempArray);
         $post->save();
     }
 }
 public function index()
 {
     $user = new User($this->db);
     $this->f3->set('users', $user->all());
     $this->f3->set('page_head', 'Item List');
     $this->f3->set('view', 'user/list.html');
 }
Example #29
0
 /**
  * Список пользователей
  */
 public function index()
 {
     $list = Request::input('list', 'all');
     $login = Request::input('login');
     if (Request::isMethod('post')) {
         $users = User::all(array('select' => 'login', 'order' => 'point DESC, login ASC'));
         foreach ($users as $key => $val) {
             if (strtolower($login) == strtolower($val->login)) {
                 $position = $key + 1;
             }
         }
         if (isset($position)) {
             $page = ceil($position / Setting::get('users_per_page'));
             App::setFlash('success', 'Позиция в рейтинге: ' . $position);
             App::redirect("/users?page={$page}&login={$login}");
         } else {
             App::setFlash('danger', 'Пользователь с данным логином не найден!');
         }
     }
     $count['users'] = $total = User::count();
     $count['admins'] = User::count(['conditions' => ['level in (?)', ['moder', 'admin']]]);
     $condition = [];
     if ($list == 'admins') {
         $total = $count['admins'];
         $condition = ['level IN(?)', ['moder', 'admin']];
     }
     $page = App::paginate(Setting::get('users_per_page'), $total);
     $users = User::all(array('conditions' => $condition, 'offset' => $page['offset'], 'limit' => $page['limit'], 'order' => 'point DESC, login ASC'));
     App::view('users.index', compact('users', 'page', 'count', 'list', 'login'));
 }
 public function getIndex()
 {
     if (Auth::guest() || Auth::user()->isAdmin == 0) {
         return Redirect::secure('/');
     }
     // layouts variables
     $this->layout->title = 'Админ панел | Нещо Шантаво';
     $this->layout->canonical = 'https://neshto.shantavo.com/admin/';
     $this->layout->robots = 'noindex,nofollow,noodp,noydir';
     $users = count(User::all());
     $admins = count(User::where('isAdmin', ">", 0)->get());
     $categories = count(Category::all());
     $albums = count(Album::all());
     $votes = count(DB::table('votes')->get());
     $pictures = count(Picture::all());
     $pictureSize = 0;
     foreach (Picture::all() as $p) {
         $pictureSize += $p->size;
     }
     // get disqus stats
     include app_path() . '/config/_disqus.php';
     $disqus = new DisqusAPI(getDisqusKey());
     $disqus->setSecure(false);
     $comments = $disqus->posts->list(array('forum' => 'shantavo'));
     // nesting the view into the layout
     $this->layout->nest('content', 'admin.index', array('users' => $users, 'admins' => $admins, 'votes' => $votes, 'categories' => $categories, 'albums' => $albums, 'pictures' => $pictures, 'pictureSize' => $pictureSize, 'comments' => $comments));
 }