public function findByUserNameOrCreate($userData) { $user = User::where('social_id', '=', $userData->id)->first(); if (!$user) { $user = new User(); $user->social_id = $userData->id; $user->email = $userData->email; $user->first_name = $userData->user['first_name']; $user->last_name = $userData->user['last_name']; $name = str_random(32); while (!User::where('avatar', '=', $name . '.jpg')->get()->isEmpty()) { $name = str_random(32); } $filename = $name . '.' . 'jpg'; Image::make($userData->avatar_original)->fit(1024, 1024)->save(public_path() . '/avatars_large/' . $filename); Image::make(public_path() . '/avatars_large/' . $filename)->resize(200, 200)->save(public_path() . '/avatars/' . $filename); $user->avatar = $filename; $user->gender = $userData->user['gender']; $user->verified = $userData->user['verified']; $user->save(); \Session::put('auth_photo', $filename); } else { $this->checkIfUserNeedsUpdating($userData, $user); \Session::put('auth_photo', $user->avatar); } return $user; }
public static function poll($polls) { $polls = json_decode($polls); $_results = array(); if (is_array($polls) && count($polls) > 0) { foreach ($polls as $i => $_poll) { switch ($_poll->type) { case "template": $_results[$_poll->id] = array('type' => 'html', 'args' => Theme::make($_poll->func, array('value' => $_poll->value))->render()); break; case "plugin": if ($_poll->func) { $_results[$_poll->id] = call_user_func($_poll->func, $_poll->value); } break; case "check_logs": $list = Dashboard::activity(); Session::put('usersonline_lastcheck', time()); $_results[$_poll->id] = array('type' => 'function', 'func' => 'fnUpdateGrowler', 'args' => $list); break; } } } return $_results; }
public function __construct() { // Asset::add('jquery.dropdown.css', 'css/jquery.dropdown.css'); Asset::add('bootstrap', 'css/bootstrap.min.css'); Asset::add('bootstrap-responsive', 'css/bootstrap-responsive.css'); Asset::add('common', 'css/common.css'); // Asset::add('style', 'css/style.css'); Asset::add('fontawsome', 'css/fontawesome.css'); Asset::add('flickcss', 'css/flick/jquery-ui-1.10.2.custom.css'); Asset::add('jquery', 'js/jquery-1.9.1.js'); Asset::add('jquery-migrate-1.1.1.js', 'js/jquery-migrate-1.1.1.js'); Asset::add('bootstrap-js', 'js/bootstrap.js'); Asset::add('jqueryui', 'js/jquery-ui-1.10.2.custom.min.js'); Asset::add('jquery.tablesorter.js', 'js/jquery.tablesorter.js'); Asset::add('jquery.tablesorter.pager.js', 'js/jquery.tablesorter.pager.js'); // $files = glob("public/css/pikachoose/*.css", GLOB_BRACE); // foreach($files as $file) // { // Asset::add($file, substr($file, 7)); // } if (Session::has('id') && Auth::check()) { $account = Account::find(Session::get('id')); if ($account->admin == 1) { Session::put('admin', '1'); } else { Session::put('admin', '0'); } if ($account->blocked == 1) { Session::put('alert', "Your account has been banned. Please contact the admin for more details"); Session::forget('id'); Auth::logout(); } else { } } }
public function dologin() { $rules = array('username' => 'required', 'password' => 'required'); $message = array('required' => 'Data :attribute harus diisi', 'min' => 'Data :attribute minimal diisi :min karakter'); $validator = Validator::make(Input::all(), $rules, $message); if ($validator->fails()) { return Redirect::to('/')->withErrors($validator)->withInput(Input::except('password')); } else { $data = array('username' => Input::get('username'), 'password' => Input::get('password')); if (Auth::attempt($data)) { $data = DB::table('user')->select('user_id', 'level_user', 'username')->where('username', '=', Input::get('username'))->first(); //print_r($data); //echo $data->id_users; Session::put('user_id', $data->user_id); Session::put('level', $data->level_user); Session::put('username', $data->username); //print_r(Session::all()); return Redirect::to("/admin/beranda"); } else { Session::flash('messages', ' <div class="alert alert-danger alert-dismissable" > <button type="button" class="close" data-dismiss="alert" aria-hidden="true">×</button> <strong>Peringatan...</strong><br> Username dan password belum terdaftar pada sistem ! </div> '); return Redirect::to('/')->withInput(Input::except('password')); } } }
/** * Validates that no more than 3 failed attempts login to the user sent as a parameter * * @param String $email * @return View */ public static function validateUser($email) { $count = User::where(['user' => $email])->count(); if ($count > 0) { if (Session::has($email)) { $value = Session::get($email); if ($value >= 2) { $user = new BlockedUser(); $user->user = $email; $user->date = new MongoDate(); try { $user->save(); } catch (MongoDuplicateKeyException $e) { } $user = User::first(['user' => $email]); $info = UserController::getUser($user); $data = array('name' => strtoupper($info->name)); Mail::send('emails.block-user', $data, function ($message) use($email) { $message->to($email)->subject(Lang::get('login.blocked_title')); }); return Redirect::back()->withErrors(array('error' => Lang::get('login.attemp') . ' [' . $email . '] ' . Lang::get('login.blocked') . 30 . Lang::get('login.minute'))); } else { $value += 1; Session::put($email, $value); } } else { Session::put($email, 1); } } return Redirect::back()->withErrors(array('error' => Lang::get('login.invalid_user'))); }
public static function generate() { $token = bin2hex(openssl_random_pseudo_bytes(32)); if (Session::put(Config::get('session_for_csrf_form_token/timestamp_name'), time())) { return Session::put(Config::get('session_for_csrf_form_token/name'), $token); } }
private function generateOTP() { function generatePassword($length, $strength) { $vowels = 'aeuy'; $consonants = 'bdghjmnpqrstvz'; if ($strength & 1) { $consonants .= 'BDGHJLMNPQRSTVWXZ'; } if ($strength & 2) { $vowels .= "AEUY"; } if ($strength & 4) { $consonants .= '23456789'; } if ($strength & 8) { $consonants .= '@#$%'; } $password = ''; $alt = time() % 2; for ($i = 0; $i < $length; $i++) { if ($alt == 1) { $password .= $consonants[rand() % strlen($consonants)]; $alt = 0; } else { $password .= $vowels[rand() % strlen($vowels)]; $alt = 1; } } return $password; } $this->_CODE = generatePassword(8, 4); Session::put('OTPCode', $this->_CODE); }
/** * Invokes the user registration on WS. * * @return response * @throws Exception in case of WS error */ public function registerUser() { try { $userService = new SoapClient(Config::get('wsdl.user')); $user = new UserModel(Input::all()); $array = array("user" => $user, "password" => Input::get('password'), "invitationCode" => Input::get('code')); if (Input::get('ref')) { $array['referrerId'] = Input::get('ref'); } $result = $userService->registerUser($array); $authService = new SoapClient(Config::get('wsdl.auth')); $token = $authService->authenticateEmail(array("email" => Input::get('email'), "password" => Input::get('password'), "userAgent" => NULL)); ini_set('soap.wsdl_cache_enabled', '0'); ini_set('user_agent', "PHP-SOAP/" . PHP_VERSION . "\r\n" . "AuthToken: " . $token->AuthToken); Session::put('user.token', $token); try { $userService = new SoapClient(Config::get('wsdl.user')); $result = $userService->getUserByEmail(array("email" => Input::get('email'))); $user = $result->user; /* if ($user -> businessAccount == true) { if (isset($user -> addresses) && is_object($user -> addresses)) { $user -> addresses = array($user -> addresses); } } */ Session::put('user.data', $user); return array('success' => true); } catch (InnerException $ex) { //throw new Exception($ex -> faultstring); return array('success' => false, 'faultstring' => $ex->faultstring); } } catch (Exception $ex) { return array('success' => false, 'faultstring' => $ex->faultstring); } }
public function post_profile($table, $col_name, $type) { $this->object = database::get_instance(); $users = DB::table('users_login')->orderBy('id', 'desc')->first(); $stu_id = $users->user_session; $id = $this->object->view($table, "where_pluck", $col_name, '=', $stu_id, 'id'); $profile_image = $this->object->view($table, "where_pluck", 'id', '=', $id, 'profile_image'); Session::put('table', $table); if (Auth::attempt(array('password' => Input::get('old_pass')))) { if (Input::get('new_pass') == Input::get('pass_confirm')) { $this->add_file = $this->object->upload_file('profile_images', $table, 'upload', 'profile_image', "update", 'id', $id, $profile_image); $val = array('password' => Hash::make(Input::get('new_pass'))); $this->object->update($table, 'id', $id, $val); } else { $return = Redirect::to('profile=' . $type)->with('exists', 'Please Enter Correct new password'); } } else { $return = Redirect::to('profile=' . $type)->with('exists', 'Please Enter Correct Old password'); } if ($this->add_file) { $return = Redirect::to('profile=' . $type)->with('success', 'You successfully Update Your Profile.'); } else { $return = Redirect::to('profile=' . $type)->with('exists', 'Please Select a file'); } return $return; }
public function get_instagram() { // make sure user is logged in if (!Auth::user()) { return Redirect::to('/')->withInput()->withErrors('You must be logged in to access the Instagram panel.'); } // configure the API values $auth_config = array('client_id' => CLIENT_ID, 'client_secret' => CLIENT_SECRET, 'redirect_uri' => REDIRECT_URI); // create a new Auth object using the config values $auth = new Instagram\Auth($auth_config); // authorize app if not already authorized if (!Input::get('code')) { $auth->authorize(); } // get the code value returned from Instagram $code = Input::get('code'); $title = 'ImgHost - Instagram'; // save the access token if not already saved if (!Session::get('instagram_access_token')) { Session::put('instagram_access_token', $auth->getAccessToken($code)); } // create a new Instagram object $instagram = new Instagram\Instagram(); // set the access token on the newly created Instagram object $instagram->setAccessToken(Session::get('instagram_access_token')); // get the ID of the authorized user $current_user = $instagram->getCurrentUser(); // access the media of the authorized user $media = $current_user->getMedia(); $db_images = DB::table('images')->get(); return View::make('instagram')->with('title', $title)->with('instagram_images', $media)->with('db_images', $db_images); }
public function update($id, $quantity) { $cart = \Session::get('cart'); $cart[$id]->quantity = $quantity; \Session::put('cart', $cart); return redirect()->route('cart-show'); }
/** * @param $code * @return string */ public function login($code) { $this->client->authenticate($code); $token = $this->client->getAccessToken(); \Session::put('token', $token); return $token; }
public function Authenticate($Username = false, $Password = false, $Remember = false) { if ($Username !== false && $Password !== false) { //Confirm Input $UserData = DB::getInstance()->table("Users")->where("Username", $Username)->get(1)[0]; $HashedPassAttempt = Hash::make(Input::get("Password"), $UserData->Salt); if ($HashedPassAttempt == $UserData->Password) { Session::put("UserID", $UserData->UserID); if ($Remember == 'on') { //Was Remember Me Checkbox ticked? $hashCheck = DB::getInstance()->table("user_sessions")->where('user_id', $UserData->UserID)->get(); //Check for existing session if (count($hashCheck) == 0) { //If there is not an existing hash $hash = Hash::unique(); DB::getInstance()->table('user_sessions')->insert(array('user_id' => $UserData->UserID, 'hash' => $hash)); } else { //use existing hash if found $hash = $hashCheck[0]->hash; } $Cookie = Cookie::put(Config::get("remember/cookie_name"), $hash, Config::get("remember/cookie_expiry")); //Set cookie } return $this->form($UserData->UserID); //Return User MetaTable } else { throw new Exception('Invalid Username or Password'); } } else { throw new Exception('Invalid Username or Password'); } return false; }
/** * Display customer login screen. * * @return Response */ public function login() { if (Auth::check()) { return Redirect::route('profile'); } elseif (Request::isMethod('post')) { $loginValidator = Validator::make(Input::all(), array('email' => 'required', 'password' => 'required')); if ($loginValidator->passes()) { $inputCredentials = array('email' => Input::get('email'), 'password' => Input::get('password')); if (Auth::attempt($inputCredentials)) { $customer = Customer::find(Auth::id()); if ($customer->admin_ind) { Session::put('AdminUser', TRUE); } if (is_null($customer->address)) { // If customer does not have address, redirect to create address. return Redirect::route('customer.address.create', Auth::id())->with('message', 'No address found for account. Please enter a valid address.'); } return Redirect::intended('profile')->with('message', 'Login successful.'); } return Redirect::back()->withInput()->withErrors(array('password' => array('Credentials invalid.'))); } else { return Redirect::back()->withInput()->withErrors($loginValidator); } } $this->layout->content = View::make('customers.login'); }
public function getIndex() { Session::put('flag', 11); $dados["status_notificacao"] = 2; $result = DB::table('pedidos')->where("status_notificacao", 1)->update($dados); return View::make("pedidos.pedidos"); }
public function testClearUserAddSelftProfile() { \Session::put('Giftertipster\\Service\\Add\\AddProfileMgr.user_add_self_profile', 'test'); assertThat(\Session::has('Giftertipster\\Service\\Add\\AddProfileMgr.user_add_self_profile'), identicalTo(true)); $this->add_profile_mgr->clearUserAddSelfProfile(); assertThat(\Session::has('Giftertipster\\Service\\Add\\AddProfileMgr.user_add_self_profile'), identicalTo(false)); }
public function Login() { $user = Input::get('username'); $pass = Input::get('password'); $validar_ldap = $this->ValidarLDAP($user, $pass); switch ($validar_ldap) { case "ERROR_LOGIN": Session::put('error', 'Login Incorrecto'); Session::forget('username'); break; case "ACCESO_NEGADO": Session::put('error', 'Acceso Denegado'); Session::forget('username'); break; default: Session::forget('error'); Session::put('username', $validar_ldap); $userinfo = explode("|", $validar_ldap); $nickname = $userinfo[1]; Session::put('NickNameUsuario', $nickname); Session::put('activity', time()); break; } if (Session::get('username') && Session::get('username') != '') { return Redirect::route('index'); } else { return Redirect::route('login', array('error' => Session::get('error'))); } }
/** * Show the form for creating a new resource. * * @return Response */ public function sign_up() { // $user = Input::get('username'); $realname = Input::get('realname'); $pass = Input::get('password'); $response = DB::table('users')->select('iduser', 'realname', 'username')->where('password', $pass)->where(function ($query) use($user) { $query->orWhere('username', $user); })->get(); if (!$response) { $response = DB::table('users')->select('iduser', 'realname', 'username')->where(function ($query) use($user) { $query->orWhere('username', $user); })->get(); if ($response) { return Response::json(array('user' => false)); } DB::table('users')->insert(array('username' => $user, 'realname' => $realname, 'password' => $pass)); $response = DB::table('users')->select('iduser', 'realname', 'username')->where('password', $pass)->where(function ($query) use($user) { $query->orWhere('username', $user); })->get(); if (!$response) { return Response::json(array('user' => false)); } else { Session::put('user', $response[0]); Session::save(); return Response::json(array('user' => Session::get('user'))); } } else { Session::put('user', $response[0]); Session::save(); return Response::json(array('user' => Session::get('user'))); } }
public function get() { $user_id = false; if (Auth::check()) { // Authenticating A User And "Remembering" Them Session::regenerate(); $user_id = Auth::user()->id; if (Auth::user()->accountType == 1) { if (Session::has('admin_session')) { Log::info("admin_session already created before - " . Session::get('admin_session')); } else { Session::put('admin_session', $user_id); Log::info("admin_session created"); } } // Log::info("Session cre8 - " . Session::get('admin_session')); } // else if (Auth::viaRemember()) { // // Determining If User Authed Via Remember // $user_id = Auth::user()->id; // } if (!$user_id) { $error_response = array('error' => array('message' => 'User not logged in.', 'type' => 'OAuthException', 'code' => 400)); Log::info("User not logged in"); return Response::json($error_response, 400)->setCallback(Input::get('callback')); } $user = User::find(Auth::user()->id); return Response::json($user)->setCallback(Input::get('callback')); }
/** * Gera um token e armazena na session */ public static function generate() { if (Session::exists('token')) { Session::delete('token'); } return Session::put(Config::get('session/token_name'), md5(uniqid())); }
/** * Return captcha image * @param number $maxChar */ public function generate($maxChar = 4) { // $characters = '23456789abcdefghjkmnpqrstuvwxyzABCDEFGHJKLMNPQRSTUVWXYZ'; $characters = 'ABCDEFGHKMNPQRST'; $captchaText = ''; for ($i = 0; $i < $maxChar; $i++) { $captchaText .= $characters[rand(0, strlen($characters) - 1)]; } strtoupper(substr(md5(microtime()), 0, 7)); \Session::put('captchaHash', \Hash::make($captchaText)); $image = imagecreate(30 * $maxChar, 35); $background = imagecolorallocatealpha($image, 255, 255, 255, 1); $textColor = imagecolorallocatealpha($image, 206, 33, 39, 1); $x = 5; $y = 20; $angle = 0; for ($i = 0; $i < 7; $i++) { $fontSize = 16; $text = substr($captchaText, $i, 1); imagettftext($image, $fontSize, $angle, $x, $y, $textColor, public_path('/fonts/LibreBaskerville/librebaskerville-regular.ttf'), $text); $x = $x + 17 + mt_rand(1, 10); $y = mt_rand(18, 25); $angle = mt_rand(0, 20); } header('Cache-Control: no-cache, no-store, max-age=0, must-revalidate'); header('Pragma: no-cache'); header('Content-type: image/jpeg'); imagejpeg($image, null, 100); imagedestroy($image); }
public function postSettings() { // Hex RGB Custom Validator Validator::extend('hex', function ($attribute, $value, $parameters) { return preg_match("/^\\#[0-9A-Fa-f]{6}\$/", $value); }); // Validation Rules $rules = ['nc-color' => 'required|hex', 'tr-color' => 'required|hex', 'vs-color' => 'required|hex', 'time-format' => 'required|in:12,24']; // Validation $validator = Validator::make(Input::all(), $rules); if ($validator->fails()) { return Redirect::back(); } // Save Hex and Dark Hex colors to Session foreach (['nc', 'tr', 'vs'] as $faction) { $color = strtolower(Input::get("{$faction}-color")); // Chosen color Session::put("faction-colors.{$faction}.default", $color); // Color darkened by 50% Session::put("faction-colors.{$faction}.dark", $this->adjustColorLightenDarken($color, 50)); // Outline color if ($color == Config::get("ps2maps.faction-colors.{$faction}.default")) { // If color is default color, use white outline $outline = "#FFF"; } else { // Otherwise use calculated outline color $outline = $this->closerToBlackOrWhite(Input::get("{$faction}-color")) == "#FFF" ? "#000" : "#FFF"; } Session::put("faction-colors.{$faction}.outline", $outline); } // Save time format to session Session::put('time-format', Input::get('time-format')); return Redirect::back()->with('message', 'Settings Saved'); }
public function sendPayment() { $data = array(); // if ($x = Booking::find(Booking::max('id'))) { // $data['reference_number'] = ++$x->reference_number; // } else { // $data['reference_number'] = 10000000; // } // $reference_number = $data['reference_number']; $data = array('details' => 'thilina', 'ip_address' => $_SERVER['REMOTE_ADDR'], 'amount' => 0.1, 'payment_status' => 0, 'my_booking' => 2); $reserv_id = Payment::create($data); $data_tab_HSBC_payment = array('currency' => 'USD'); $tab_HSBC_payment_id = HsbcPayment::create($data_tab_HSBC_payment); $stamp = strtotime("now"); $payment_id = Payment::orderBy('created_at', 'desc')->first()->id; $orderid = "{$stamp}" . 'B' . "{$payment_id}"; $last_res_resid = str_replace(".", "", $orderid); $hsbc_id = HsbcPayment::orderBy('created_at', 'desc')->first()->id; $hsbc_payment_id_pre = "{$stamp}" . 'HSBC' . "{$hsbc_id}"; $hsbc_payment_id = str_replace(".", "", $hsbc_payment_id_pre); if ($last_res_resid) { $payment = DB::table('payments')->where('id', $payment_id)->update(array('reference_number' => $last_res_resid, 'HSBC_payment_id' => $hsbc_payment_id)); $data_tab_HSBC_payment = DB::table('hsbc_payments')->where('id', $hsbc_id)->update(array('HSBC_payment_id' => $hsbc_payment_id)); } $amount = Input::get('amount'); Session::put('payment_amount', $amount); // $hsbc_payment_id = 1000; $currency = 'USD'; $total_price_all_hsbc = 0.1 * 100; // $last_res_resid = 101; //dd($hsbc_payment_id.'/'.$currency.'/'.$total_price_all_hsbc.'/'.$last_res_resid); HsbcPayment::goto_hsbc_gateway($hsbc_payment_id, $currency, $total_price_all_hsbc, $last_res_resid); }
public function __construct() { /* I just figured that I could've just checked for sessions here (constructor) * instead of checking it in each method of each class. * But I guess I've gone too far on this project that it'll be time wasting to change my codes. * I'm gonna continue checking sessions per method per class on this project... * But in my next projects, I'll do the non-specific session checking in the constructors <3 * * -Christian (Programmer) * */ if (Session::has('username')) { date_default_timezone_set("Asia/Manila"); $user = User::where('username', '=', Session::get("username"))->first(); if (!$user) { Session::flush(); return Redirect::to("/"); } Session::put('user_id', $user->id); Session::put('username', $user->username); Session::put('first_name', $user->first_name); Session::put('last_name', $user->last_name); Session::put('user_type', $user->user_type); } }
public function postTerminal() { if (\Request::ajax()) { $terminal_password = \Config::get('laraedit::laraedit.terminal.password'); $command = ''; if (!empty($_POST['command'])) { $command = $_POST['command']; } if (strtolower($command == 'exit')) { \Session::put('term_auth', false); $output = '[CLOSED]'; } else { if (\Session::get('term_auth') !== true) { if ($command == $terminal_password) { \Session::put('term_auth', true); $output = '[AUTHENTICATED]'; } else { $output = 'Enter Password:'******''; $command = explode("&&", $command); foreach ($command as $c) { $Terminal->command = $c; $output .= $Terminal->Process(); } } } return \Response::json(htmlentities($output)); } }
public static function add($type, $message) { if (in_array($type, static::$types)) { $messages = array_merge((array) Session::get('messages.' . $type), (array) $message); Session::put('messages.' . $type, $messages); } }
public function harian() { $bil = 1; $laporans = Laporan::latest('tarikh')->assigned()->today()->get(); \Session::put('lastReport', \Route::currentRouteName()); return View('members.technician.harian', compact('bil', 'laporans')); }
/** * Upload un torrent * * @access public * @return View torrent.upload * */ public function upload() { $user = Auth::user(); // Post et fichier upload if (Request::isMethod('post')) { // No torrent file uploaded OR an Error has occurred if (Input::hasFile('torrent') == false) { Session::put('message', 'You must provide a torrent for the upload'); return View::make('torrent.upload', array('categories' => Category::all(), 'user' => $user)); } else { if (Input::file('torrent')->getError() != 0 && Input::file('torrent')->getClientOriginalExtension() != 'torrent') { Session::put('message', 'An error has occurred'); return View::make('torrent.upload', array('categories' => Category::all(), 'user' => $user)); } } // Deplace et decode le torrent temporairement TorrentTools::moveAndDecode(Input::file('torrent')); // Array from decoded from torrent $decodedTorrent = TorrentTools::$decodedTorrent; // Tmp filename $fileName = TorrentTools::$fileName; // Info sur le torrent $info = Bencode::bdecode_getinfo(getcwd() . '/files/torrents/' . $fileName, true); // Si l'announce est invalide ou si le tracker et privée if ($decodedTorrent['announce'] != route('announce', ['passkey' => $user->passkey]) && Config::get('other.freeleech') == true) { Session::put('message', 'Your announce URL is invalid'); return View::make('torrent.upload', array('categories' => Category::all(), 'user' => $user)); } // Find the right category $category = Category::find(Input::get('category_id')); // Create the torrent (DB) $torrent = new Torrent(['name' => Input::get('name'), 'slug' => Str::slug(Input::get('name')), 'description' => Input::get('description'), 'info_hash' => $info['info_hash'], 'file_name' => $fileName, 'num_file' => $info['info']['filecount'], 'announce' => $decodedTorrent['announce'], 'size' => $info['info']['size'], 'nfo' => Input::hasFile('nfo') ? TorrentTools::getNfo(Input::file('nfo')) : '', 'category_id' => $category->id, 'user_id' => $user->id]); // Validation $v = Validator::make($torrent->toArray(), $torrent->rules); if ($v->fails()) { if (file_exists(getcwd() . '/files/torrents/' . $fileName)) { unlink(getcwd() . '/files/torrents/' . $fileName); } Session::put('message', 'An error has occured may bee this file is already online ?'); } else { // Savegarde le torrent $torrent->save(); // Compte et sauvegarde le nombre de torrent dans cette catégorie $category->num_torrent = Torrent::where('category_id', '=', $category->id)->count(); $category->save(); // Sauvegarde les fichiers que contient le torrent $fileList = TorrentTools::getTorrentFiles($decodedTorrent); foreach ($fileList as $file) { $f = new TorrentFile(); $f->name = $file['name']; $f->size = $file['size']; $f->torrent_id = $torrent->id; $f->save(); unset($f); } return Redirect::route('torrent', ['slug' => $torrent->slug, 'id' => $torrent->id])->with('message', trans('torrent.your_torrent_is_now_seeding')); } } return View::make('torrent.upload', array('categories' => Category::all(), 'user' => $user)); }
public function login($username = null, $password = null, $remember = false) { if (!$username && !$password && $this->exists()) { Session::put($this->_sessionName, $this->data()->id); } else { $user = $this->find($username); if ($user) { if ($this->data()->password === Hash::make($password, $this->data()->salt)) { Session::put($this->_sessionName, $this->data()->id); if ($remember) { $hash = Hash::unique(); $hashCheck = $this->_db->get('users_session', array('user_id', '=', $this->data()->id)); if (!$hashCheck->count()) { $this->_db->insert('users_session', array('user_id' => $this->data()->id, 'hash' => $hash)); } else { $hash = $hashCheck->first()->hash; } Cookie::put($this->_cookieName, $hash, Config::get('remember.cookie_expiry')); } return true; } } } return false; }
public static function setUsuario($id) { $usuario = DB::table('usuarios')->where('id', $id)->first(); Session::put('user.id', $usuario->id); Session::put('user.name', $usuario->nome); Session::put('user.icon', $usuario->icone); }