/**
  * Get the current user of the application.
  *
  * If the user is a guest, null should be returned.
  *
  * @param  int  $id
  * @return mixed|null
  */
 public function retrieve($id)
 {
     if (filter_var($id, FILTER_VALIDATE_INT) !== false) {
         // We want to return the object as an array.
         $current = Config::get('database.fetch');
         Config::set('database.fetch', \PDO::FETCH_ASSOC);
         // Grab user and return fetch to what it was before the query.
         $user = DB::table(Config::get('auth.table'))->where('UsersId', '=', $id)->first();
         Config::set('database.fetch', $current);
         return $user;
     }
 }
Beispiel #2
0
 /**
  * Create a response that will force a image to be displayed inline.
  *
  * @param string $path Path to the image
  * @param string $name Filename
  * @param int $lifetime Lifetime in browsers cache
  * @return Response
  */
 public static function inline($path, $name = null, $lifetime = 0)
 {
     if (is_null($name)) {
         $name = basename($path);
     }
     $filetime = filemtime($path);
     $etag = md5($filetime . $path);
     $time = gmdate('r', $filetime);
     $expires = gmdate('r', $filetime + $lifetime);
     $length = filesize($path);
     $headers = array('Content-Disposition' => 'inline; filename="' . $name . '"', 'Last-Modified' => $time, 'Cache-Control' => 'must-revalidate', 'Expires' => $expires, 'Pragma' => 'public', 'Etag' => $etag);
     // If enabled, we need to disable the profiler
     LaravelConfig::set('application.profiler', false);
     // Check the Browsers cache
     $headerTest1 = isset($_SERVER['HTTP_IF_MODIFIED_SINCE']) && $_SERVER['HTTP_IF_MODIFIED_SINCE'] == $time;
     $headerTest2 = isset($_SERVER['HTTP_IF_NONE_MATCH']) && str_replace('"', '', stripslashes($_SERVER['HTTP_IF_NONE_MATCH'])) == $etag;
     if ($headerTest1 || $headerTest2) {
         //image is cached by the browser, we dont need to send it again
         return static::make('', 304, $headers);
     }
     $fileinfos = Imwg::imageInfo($path);
     $headers = array_merge($headers, array('Content-Type' => $fileinfos['mime'], 'Content-Length' => $length));
     return static::make(File::get($path), 200, $headers);
 }
use Laravel\Bundle;
use Laravel\Config;
use Laravel\Request;
/**
 * Fire up the default bundle. This will ensure any dependencies that
 * need to be registered in the IoC container are registered and that
 * the auto-loader mappings are registered.
 */
Bundle::start(DEFAULT_BUNDLE);
/**
 * The default database connection may be set by specifying a value
 * for the "database" CLI option. This allows migrations to be run
 * conveniently for a test or staging database.
 */
if (!is_null($database = get_cli_option('db'))) {
    Config::set('database.default', $database);
}
/**
 * We will register all of the Laravel provided tasks inside the IoC
 * container so they can be resolved by the task class. This allows
 * us to seamlessly add tasks to the CLI so that the Task class
 * doesn't have to worry about how to resolve core tasks.
 */
require path('sys') . 'cli/dependencies' . EXT;
/**
 * We will wrap the command execution in a try / catch block and
 * simply write out any exception messages we receive to the CLI
 * for the developer. Note that this only writes out messages
 * for the CLI exceptions. All others will be not be caught
 * and will be totally dumped out to the CLI.
 */
Beispiel #4
0
 /**
  * Create a new Eloquent model instance.
  *
  * @param  array  $attributes
  * @return void
  */
 public function __construct($attributes = array())
 {
     $params = Bootstrap::$bag['config']->getDatabase();
     Config::set('database.default', 'mysql');
     Config::set('database.connections', array('mysql' => array('driver' => 'mysql', 'host' => $params->getHost(), 'database' => $params->getDbname(), 'username' => $params->getUsername(), 'password' => $params->getPassword(), 'charset' => 'utf8')));
     $this->fill($attributes);
 }
Beispiel #5
0
 public static function uninstall($module_slug)
 {
     if (empty($module_slug)) {
         static::$errors->add('installer', 'Failed to uninstall module [' . $module_slug . ']');
         return false;
     }
     $module = Model\Module::where('slug', '=', $module_slug)->first();
     if (isset($module)) {
         if (static::schema('uninstall', $module->slug)) {
             //clean any message from schema
             ob_get_clean();
             if (static::migrate($module->slug, 'rollback')) {
                 //clean any message from migration
                 ob_get_clean();
                 // Remove the module from the config array
                 // updates information if we are in the same
                 // request eg: (ajax)
                 $installed_modules = Config::get('installed_modules');
                 unset($installed_modules[$module_slug]);
                 Config::set('installed_modules', $installed_modules);
                 // Remove from DB
                 $module->delete();
                 return true;
             } else {
                 static::$errors->add('installer', 'Failed to rollback migrations for module ' . $module_slug . '.');
                 return false;
             }
         } else {
             static::$errors->add('installer', 'Failed to uninstall data schema for module ' . $module_slug . '.');
             return false;
         }
     } else {
         static::$errors->add('installer', 'Module ' . $module_slug . ' was not found.');
         return false;
     }
 }
error_reporting(-1);
Bundle::start(DEFAULT_BUNDLE);
foreach (Bundle::$bundles as $bundle => $config) {
    if ($config['auto']) {
        Bundle::start($bundle);
    }
}
Router::register('*', '(:all)', function () {
    return Event::first('404');
});
$uri = URI::current();
$languages = Config::get('application.languages', array());
$languages[] = Config::get('application.language');
foreach ($languages as $language) {
    if (preg_match("#^{$language}(?:\$|/)#i", $uri)) {
        Config::set('application.language', $language);
        $uri = trim(substr($uri, strlen($language)), '/');
        break;
    }
}
if ($uri == '') {
    $uri = '/';
}
URI::$uri = $uri;
Request::$route = Router::route(Request::method(), $uri);
$response = Request::$route->call();
$response->render();
if (Config::get('session.driver') !== '') {
    Session::save();
}
$response->send();
Beispiel #7
0
defined('DS') or die('No direct script access.');
use Laravel\Bundle;
use Laravel\Config;
/**
 * Fire up the default bundle. This will ensure any dependencies that
 * need to be registered in the IoC container are registered and that
 * the auto-loader mappings are registered.
 */
Bundle::start(DEFAULT_BUNDLE);
/**
 * The default database connection may be set by specifying a value
 * for the "database" CLI option. This allows migrations to be run
 * conveniently for a test or staging database.
 */
if (isset($_SERVER['CLI']['DB'])) {
    Config::set('database.default', $_SERVER['CLI']['DB']);
}
/**
 * We will register all of the Laravel provided tasks inside the IoC
 * container so they can be resolved by the task class. This allows
 * us to seamlessly add tasks to the CLI so that the Task class
 * doesn't have to worry about how to resolve core tasks.
 */
require path('sys') . 'cli/dependencies' . EXT;
/**
 * We will wrap the command execution in a try / catch block and
 * simply write out any exception messages we receive to the CLI
 * for the developer. Note that this only writes out messages
 * for the CLI exceptions. All others will be not be caught
 * and will be totally dumped out to the CLI.
 */