コード例 #1
0
ファイル: HomeController.php プロジェクト: eezhal92/not-gojek
 public function getLogin()
 {
     if (Session::exists(Config::get('session.name'))) {
         return Redirect::to('/');
     }
     return view('auth.login');
 }
コード例 #2
0
ファイル: Redirect.php プロジェクト: eezhal92/not-gojek
 /**
  * Redirect kembali ke halaman sebelumnya.
  *
  * @param array $data
  * @return response
  */
 public static function back($data = [])
 {
     if (count($data) == 1) {
         Session::flash(key($data), current($data));
     }
     header('Location: ' . $_SERVER['HTTP_REFERER']);
 }
コード例 #3
0
ファイル: AuthController.php プロジェクト: eezhal92/not-gojek
 public function getLogout()
 {
     if (Auth::check()) {
         Session::delete(Config::get('session.name'));
     }
     return Redirect::to('/');
 }
コード例 #4
0
ファイル: Token.php プロジェクト: eezhal92/not-gojek
 /**
  * Mengecek apakah token yang dikirimkan sama dengan token yang disimpan di session.
  *
  * @return string $token
  * @return bool
  */
 public static function match($token)
 {
     $token_name = Config::get('session.token_name');
     if (Session::exists($token_name) && $token === Session::get($token_name)) {
         Session::delete($token_name);
         return true;
     }
     return false;
 }
コード例 #5
0
ファイル: MediasController.php プロジェクト: bofiss/lavalprod
 public function index($id = null)
 {
     if ($id) {
         if ($idmedia = $this->Media->read($id)) {
             $currentMedia = Request::cleanInput($idmedia);
             $this->view->currentMedia = $currentMedia;
         } else {
             Session::setFlash("This Media doesn't exist", "warning");
         }
     }
     $this->view->medias = $this->Media->read();
     $this->view->render('medias/index');
 }
コード例 #6
0
ファイル: Controller.php プロジェクト: bofiss/lavalprod
<?php

namespace App\Core\Controller;

use App\Core\View\View;
use App\Core\Session;
// Initialisation de la session dans tous les controleurs
Session::init();
/**
 * @Controlleur principal
 */
class Controller
{
    protected $model = null;
    function __construct()
    {
        /* main controller */
        $this->view = new View();
    }
    public function loadModel($name)
    {
        /* recupere le chemin du model */
        $n = ucfirst($name);
        $name .= "S";
        $path = '../App/Model/' . $n . '.php';
        /* vérifie si le model exixte et l' initialise */
        if (file_exists($path)) {
            require '../App/Model/' . $n . '.php';
            $this->{$n} = new $n($name);
            // modification, pour pourvoir faire par exemple $this->User->method
            // $this->model = new $name();
コード例 #7
0
ファイル: Auth.php プロジェクト: eezhal92/not-gojek
 public static function user()
 {
     return self::check() ? Session::get(Config::get('session.name')) : false;
 }
コード例 #8
0
ファイル: Validator.php プロジェクト: bofiss/lavalprod
 public static function is_connected($user)
 {
     return Session::get($user);
 }
コード例 #9
0
ファイル: UsersController.php プロジェクト: bofiss/lavalprod
 public function logout()
 {
     Session::destroy('user');
     $this->setFlash("Log Out successfull !", 'success');
     $this->view->redirect_to('');
 }
コード例 #10
0
ファイル: Media.php プロジェクト: bofiss/lavalprod
 /**
      * @return array|bool
 
     public function create(){
 		$sql= "INSERT INTO tmedias (title, url, type) VALUES ('".$this->title."', '".$this->url."', '".$this->type."')";
 		return $this->db->query($sql);
 	}*/
 public function upload($datas, $names)
 {
     $target_path = 'medias/';
     $uploadOk = 1;
     for ($i = 0; $i < count($datas); $i++) {
         $name = $names[$i];
         $temp_name = $datas[$i];
         $target_path = $target_path . basename($name);
         if (file_exists($target_path)) {
             $uploadOk = 0;
         }
         if ($uploadOk == 0) {
             Session::setFlash('File already exist', 'warning');
         } else {
             if (move_uploaded_file($temp_name, $target_path)) {
                 Session::setFlash("The file " . basename($name) . " has been uploaded.", 'warning');
             } else {
                 Session::setFlash("Sorry, there was an error uploading your file", 'warning');
             }
         }
     }
 }
コード例 #11
0
ファイル: filters.php プロジェクト: eezhal92/not-gojek
<?php

use App\Core\Session;
use App\Core\Config;
use App\Core\Redirect;
use App\Core\Middleware;
$middleware = new Middleware();
/**
 * Berhubung isu method next pada Middleware.
 * Sekarang hanya bisa menggunakan before middleware/filter. 
 * Note: Dikarenakan fungsi exit() pada helper view().
 */
$middleware->add('auth', function ($params) use($middleware) {
    // echo "auth <br>";
    if (!Session::exists(Config::get('session.name'))) {
        if (is_ajax()) {
            http_response_code(401);
            exit;
        } else {
            Redirect::route('get-login');
        }
    }
    $middleware->next($params);
});
$middleware->add('admin', function ($params) use($middleware) {
    // do something
    $middleware->next($params);
});
$middleware->add('something', function ($params) use($middleware) {
    // do something
    $middleware->next($params);
コード例 #12
0
ファイル: BricksController.php プロジェクト: bofiss/lavalprod
 public function UpdateBrick($id)
 {
     $this->data = Request::all();
     if ($this->Brick->UpdateBrick($id, $this->data)) {
         Session::setFlash('The brick has been updated', "success");
         $this->view->redirect_to('/brick/edit');
     } else {
         Session::setFlash("Problem occur while updating", "warning");
         $this->view->redirect_to('/brick/edit');
     }
 }