Example #1
0
 /**
  * Return array of HTTP header names and values.
  * This method returns the _original_ header name
  * as specified by the end user.
  *
  * @return array
  */
 public function all()
 {
     $all = parent::all();
     $out = [];
     foreach ($all as $key => $props) {
         $out[$props['originalKey']] = $props['value'];
     }
     return $out;
 }
Example #2
0
 public function getHeaders()
 {
     $headers = array();
     $parameters = $this->server->all();
     foreach ($parameters as $key => $value) {
         if (0 === strpos($key, 'HTTP_')) {
             $headers[substr($key, 5)] = $value;
         } elseif (in_array($key, array('CONTENT_LENGTH', 'CONTENT_MD5', 'CONTENT_TYPE'))) {
             $headers[$key] = $value;
         }
     }
     if (isset($this->parameters['PHP_AUTH_USER'])) {
         $headers['PHP_AUTH_USER'] = $this->parameters['PHP_AUTH_USER'];
         $headers['PHP_AUTH_PW'] = isset($this->parameters['PHP_AUTH_PW']) ? $this->parameters['PHP_AUTH_PW'] : '';
     } else {
         /*
          * php-cgi under Apache does not pass HTTP Basic user/pass to PHP by default
          * For this workaround to work, add this line to your .htaccess file:
          * RewriteRule .* - [E=HTTP_AUTHORIZATION:%{HTTP:Authorization}]
          *
          * A sample .htaccess file:
          * RewriteEngine On
          * RewriteRule .* - [E=HTTP_AUTHORIZATION:%{HTTP:Authorization}]
          * RewriteCond %{REQUEST_FILENAME} !-f
          * RewriteRule ^(.*)$ app.php [QSA,L]
          */
         $authorizationHeader = null;
         if (isset($this->parameters['HTTP_AUTHORIZATION'])) {
             $authorizationHeader = $this->parameters['HTTP_AUTHORIZATION'];
         } elseif (isset($this->parameters['REDIRECT_HTTP_AUTHORIZATION'])) {
             $authorizationHeader = $this->parameters['REDIRECT_HTTP_AUTHORIZATION'];
         }
         // Decode AUTHORIZATION header into PHP_AUTH_USER and PHP_AUTH_PW
         if (null !== $authorizationHeader) {
             $exploded = explode(':', base64_decode(substr($authorizationHeader, 6)));
             if (count($exploded) == 2) {
                 list($headers['PHP_AUTH_USER'], $headers['PHP_AUTH_PW']) = $exploded;
             }
         }
     }
     // PHP_AUTH_USER/PHP_AUTH_PW
     if (isset($headers['PHP_AUTH_USER'])) {
         $headers['AUTHORIZATION'] = 'Basic ' . base64_encode($headers['PHP_AUTH_USER'] . ':' . $headers['PHP_AUTH_PW']);
     }
     return $headers;
 }
Example #3
0
 public static function __callStatic($name, $arguments)
 {
     $collection = new Collection($arguments[0]);
     switch ($name) {
         case '_columns':
             return $collection->columns($arguments[1]);
         case '_where':
             return $collection->where($arguments[1]);
         case '_join':
             return $collection->join($arguments[1]);
         case '_order':
             return $collection->order($arguments[1], $arguments[2]);
         case '_group':
             return $collection->group($arguments[1]);
         case '_limit':
             return $collection->limit($arguments[1]);
         case '_offset':
             return $collection->offset($arguments[1]);
         case '_all':
             return $collection->all();
         default:
             throw new \Bacon\Exceptions\MethodNotFound();
     }
 }
Example #4
0
 /**
  * Display a listing of the resource.
  *
  * @return Response
  */
 public function index()
 {
     $this->layout->content = View::make('collections.index')->with('collections', Collection::all());
 }
Example #5
0
|--------------------------------------------------------------------------
| Application Routes
|--------------------------------------------------------------------------
|
| Here is where you can register all of the routes for an application.
| It's a breeze. Simply tell Laravel the URIs it should respond to
| and give it the Closure to execute when that URI is requested.
|
*/
Route::get('/', function () {
    $t = 1;
    $inventories = Inventory::all();
    return View::make('main/index')->with('inventories', $inventories)->with('t', $t);
});
Route::get('/albums', function () {
    $albums = Collection::all();
    return View::make('main/albums')->with('albums', $albums);
});
Route::get('/album/{albums}', function ($albums) {
    $albums = Collection::find($albums);
    return View::make('main/album')->with(array('albums' => $albums));
});
Route::get('/albums/{album}/image/{image}', function ($album, $image) {
    $album = Collection::find($album);
    $image = Inventory::find($image);
    return View::make('main/image')->with(array('album' => $album, 'image' => $image));
});
Route::get('/login', function () {
    return View::make('main/login');
});
//// ADMIN ROUTES BELOW
Example #6
0
 /**
  * Show the form for editing the specified resource.
  *
  * @param  int  $id
  * @return Response
  */
 public function edit($id)
 {
     $inventory = Inventory::find($id);
     $this->layout->content = View::make('inventories.edit')->with('inventory', $inventory)->with('collections', Collection::all()->lists('name', 'id'));
 }