Example #1
1
 public static function write($type, $message, $pretty_print = false)
 {
     $message = $pretty_print ? print_r($message, true) : $message;
     if (Event::listeners('laravel.log')) {
         Event::fire('laravel.log', array($type, $message));
     }
     $message = static::format($type, $message);
     File::append(path('storage') . 'logs/' . date('Y-m-d') . '.log', $message);
 }
Example #2
0
 /**
  * Attach the Profiler's event listeners.
  *
  * @return void
  */
 public static function attach()
 {
     \Laravel\Profiling\Profiler::attach();
     Event::listen('laravel.mongoquery', function ($db, $sql, $bindings, $time) {
         MongoProfiler::mongo_query($db, $sql, $bindings, $time);
     });
 }
Example #3
0
 /**
  * Render the view.
  *
  * @return string
  * @throws \Exception
  */
 public function render()
 {
     // Events
     Event::fire("laravel.composing: {$this->view}", array($this));
     // Buffer the output
     ob_start();
     try {
         // array of paths where to find the views
         $paths = Config::get('weed::weed.paths');
         // build the Twig object
         $loader = new Twig\Weed\Loader\Filesystem($paths);
         // define the Twig environment
         $config = array('cache' => Config::get('weed::weed.cache'), 'debug' => Config::get('weed::weed.debug'), 'auto_reload' => Config::get('weed::weed.auto_reload'));
         $twig = new \Twig_Environment($loader, $config);
         // register the desired extensions
         foreach (Config::get('weed::weed.extensions') as $extension) {
             $twig->addExtension(new $extension());
         }
         // output the rendered template :-)
         echo $twig->render($this->template, $this->data());
     } catch (\Exception $e) {
         ob_get_clean();
         throw $e;
     }
     return ob_get_clean();
 }
Example #4
0
 public function create_inventory($user_uuid)
 {
     if (!isset($user_uuid) or empty($user_uuid)) {
         return null;
     }
     $inventory_uuid = UUID::random();
     $inventory = array('Textures' => array('folderName' => 'Textures', 'type' => 0, 'version' => 1, 'folderID' => UUID::random(), 'agentID' => $user_uuid, 'parentFolderID' => $inventory_uuid), 'Sounds' => array('folderName' => 'Sounds', 'type' => 1, 'version' => 1, 'folderID' => UUID::random(), 'agentID' => $user_uuid, 'parentFolderID' => $inventory_uuid), 'Calling Cards' => array('folderName' => 'Calling Cards', 'type' => 2, 'version' => 1, 'folderID' => UUID::random(), 'agentID' => $user_uuid, 'parentFolderID' => $inventory_uuid), 'Landmarks' => array('folderName' => 'Landmarks', 'type' => 3, 'version' => 1, 'folderID' => UUID::random(), 'agentID' => $user_uuid, 'parentFolderID' => $inventory_uuid), 'My Inventory' => array('folderName' => 'My Inventory', 'type' => 9, 'version' => 1, 'folderID' => $inventory_uuid, 'agentID' => $user_uuid, 'parentFolderID' => UUID::ZERO), 'Photo Album' => array('folderName' => 'Photo Album', 'type' => 15, 'version' => 1, 'folderID' => UUID::random(), 'agentID' => $user_uuid, 'parentFolderID' => $inventory_uuid), 'Clothing' => array('folderName' => 'Clothing', 'type' => 5, 'version' => 3, 'folderID' => UUID::random(), 'agentID' => $user_uuid, 'parentFolderID' => $inventory_uuid), 'Objects' => array('folderName' => 'Objects', 'type' => 6, 'version' => 1, 'folderID' => UUID::random(), 'agentID' => $user_uuid, 'parentFolderID' => $inventory_uuid), 'Notecards' => array('folderName' => 'Notecards', 'type' => 7, 'version' => 1, 'folderID' => UUID::random(), 'agentID' => $user_uuid, 'parentFolderID' => $inventory_uuid), 'Scripts' => array('folderName' => 'Scripts', 'type' => 10, 'version' => 1, 'folderID' => UUID::random(), 'agentID' => $user_uuid, 'parentFolderID' => $inventory_uuid), 'Body Parts' => array('folderName' => 'Body Parts', 'type' => 13, 'version' => 5, 'folderID' => UUID::random(), 'agentID' => $user_uuid, 'parentFolderID' => $inventory_uuid), 'Trash' => array('folderName' => 'Trash', 'type' => 14, 'version' => 1, 'folderID' => UUID::random(), 'agentID' => $user_uuid, 'parentFolderID' => $inventory_uuid), 'Lost And Found' => array('folderName' => 'Lost And Found', 'type' => 16, 'version' => 1, 'folderID' => UUID::random(), 'agentID' => $user_uuid, 'parentFolderID' => $inventory_uuid), 'Animations' => array('folderName' => 'Animations', 'type' => 20, 'version' => 1, 'folderID' => UUID::random(), 'agentID' => $user_uuid, 'parentFolderID' => $inventory_uuid), 'Gestures' => array('folderName' => 'Gestures', 'type' => 21, 'version' => 1, 'folderID' => UUID::random(), 'agentID' => $user_uuid, 'parentFolderID' => $inventory_uuid));
     $modified_inventory = Event::until('opensim.model.os.inventoryfolder.create_inventory', array($inventory_uuid, $inventory));
     if (!is_null($modified_inventory)) {
         $inventory = $modified_inventory;
     }
     $this->insert($inventory);
     return $inventory;
 }
 /**
  * Sends email
  *
  * @param string $to Recipient email address
  * @param string $subject Subject of the email
  * @param string $htmlBody HTML body of the email
  * @param string $plainBody Plain text body of the email
  * @param string $connConfigName Connection configuration name to be used
  *
  * @throws InvalidConnectionConfigException
  *
  * @return bool
  *
  * @author Mert Hurturk <*****@*****.**>
  **/
 public function sendEmail($to, $subject, $htmlBody, $plainBody, $connConfigName = null)
 {
     $config = $this->_getConfigurationArray($connConfigName);
     if (!is_array($config)) {
         throw new InvalidConnectionConfigException('Invalid Sendersuite connection configuration key: "' . $connConfigName . '"');
     }
     $data = array('to' => $to, 'subject' => $subject, 'htmlbody' => $htmlBody, 'plainbody' => $plainBody);
     try {
         $this->_connection->send($data, $config);
         return true;
     } catch (Exception $e) {
         \Laravel\Event::fire('sendersuite.email.error', array($data, $config, $e));
         return false;
     }
 }
Example #6
0
 /**
  * Attach the Profiler's event listeners.
  *
  * @return void
  */
 public static function attach()
 {
     // First we'll attach to the query and log events. These allow us to catch
     // all of the SQL queries and log messages that come through Laravel,
     // and we will pass them onto the Profiler for simple storage.
     Event::listen('laravel.log', function ($type, $message) {
         Profiler::log($type, $message);
     });
     Event::listen('laravel.query', function ($sql, $bindings, $time) {
         Profiler::query($sql, $bindings, $time);
     });
     // We'll attach the profiler to the "done" event so that we can easily
     // attach the profiler output to the end of the output sent to the
     // browser. This will display the profiler's nice toolbar.
     Event::listen('laravel.done', function ($response) {
         echo Profiler::render($response);
     });
 }
Example #7
0
 /**
  * Call an action method on a controller.
  *
  * <code>
  *		// Call the "show" method on the "user" controller
  *		$response = Controller::call('user@show');
  *
  *		// Call the "user/admin" controller and pass parameters
  *		$response = Controller::call('user.admin@profile', array($username));
  * </code>
  *
  * @param  string    $destination
  * @param  array     $parameters
  * @return Response
  */
 public static function call($destination, $parameters = array())
 {
     static::references($destination, $parameters);
     list($bundle, $destination) = Bundle::parse($destination);
     // We will always start the bundle, just in case the developer is pointing
     // a route to another bundle. This allows us to lazy load the bundle and
     // improve speed since the bundle is not loaded on every request.
     Bundle::start($bundle);
     list($controller, $method) = explode('@', $destination);
     $controller = static::resolve($bundle, $controller);
     // If the controller could not be resolved, we're out of options and
     // will return the 404 error response. If we found the controller,
     // we can execute the requested method on the instance.
     if (is_null($controller)) {
         return Event::first('404');
     }
     return $controller->execute($method, $parameters);
 }
Example #8
0
 /**
  * Load a bundle by running it's start-up script.
  *
  * If the bundle has already been started, no action will be taken.
  *
  * @param  string  $bundle
  * @return void
  */
 public static function start($bundle)
 {
     if (static::started($bundle)) {
         return;
     }
     if (!static::exists($bundle)) {
         throw new \Exception("Bundle [{$bundle}] has not been installed.");
     }
     // Each bundle may have a "start" script which is responsible for preparing
     // the bundle for use by the application. The start script may register any
     // classes the bundle uses with the auto-loader, etc.
     if (file_exists($path = static::path($bundle) . 'start' . EXT)) {
         require $path;
     }
     // Each bundle may also have a "routes" file which is responsible for
     // registering the bundle's routes. This is kept separate from the
     // start script for reverse routing efficiency purposes.
     static::routes($bundle);
     Event::fire("started: {$bundle}");
     static::$started[] = strtolower($bundle);
 }
Example #9
0
 /**
  * Register the Blade view engine with Laravel.
  *
  * @return void
  */
 public static function sharpen()
 {
     Event::listen(View::engine, function ($view) {
         // The Blade view engine should only handle the rendering of views which
         // end with the Blade extension. If the given view does not, we will
         // return false so the View can be rendered as normal.
         if (!str_contains($view->path, BLADE_EXT)) {
             return;
         }
         $compiled = Blade::compiled($view->path);
         // If the view doesn't exist or has been modified since the last time it
         // was compiled, we will recompile the view into pure PHP from it's
         // Blade representation, writing it to cached storage.
         if (!file_exists($compiled) or Blade::expired($view->view, $view->path)) {
             file_put_contents($compiled, Blade::compile($view));
         }
         $view->path = $compiled;
         // Once the view has been compiled, we can simply set the path to the
         // compiled view on the view instance and call the typical "get"
         // method on the view to evaluate the compiled PHP view.
         return ltrim($view->get());
     });
 }
Example #10
0
 /**
  * Log the query and fire the core query event.
  *
  * @param  string  $sql
  * @param  array   $bindings
  * @param  int     $start
  * @return void
  */
 protected function log($sql, $bindings, $start)
 {
     $time = number_format((microtime(true) - $start) * 1000, 2);
     Event::fire('laravel.query', array($sql, $bindings, $time));
     static::$queries[] = compact('sql', 'bindings', 'time');
 }
Example #11
0
 /**
  * Get the evaluated string content of the view.
  *
  * @return string
  */
 public function render()
 {
     Event::fire("laravel.composing: {$this->view}", array($this));
     // If there are listeners to the view engine event, we'll pass them
     // the view so they can render it according to their needs, which
     // allows easy attachment of other view parsers.
     if (Event::listeners(static::engine)) {
         $result = Event::until(static::engine, array($this));
         if (!is_null($result)) {
             return $result;
         }
     }
     return $this->get();
 }
 public function send($data = array(), $config = array())
 {
     \Laravel\Event::fire('sendersuite.email.debug', array($data, $config));
 }
Example #13
0
 protected function log($command, $start, $arguments)
 {
     $time = number_format((microtime(true) - $start) * 1000, 2);
     \Laravel\Event::fire('laravel.mongoquery', array($this->_db, $command, $arguments, $time));
 }
Example #14
0
 /**
  * Load all of the configuration items from a configuration file.
  *
  * @param  string  $bundle
  * @param  string  $file
  * @return bool
  */
 public static function load($bundle, $file)
 {
     if (isset(static::$items[$bundle][$file])) {
         return true;
     }
     // We allow a "config.loader" event to be registered which is responsible for
     // returning an array representing the configuration for the bundle and file
     // requested. This allows many types of config "drivers".
     $config = Event::first(static::loader, func_get_args());
     // If configuration items were actually found for the bundle and file we
     // will add them to the configuration array and return true, otherwise
     // we will return false indicating the file was not found.
     if (count($config) > 0) {
         static::$items[$bundle][$file] = $config;
     }
     return isset(static::$items[$bundle][$file]);
 }
Example #15
0
 /**
  * Resolve a given type to an instance.
  *
  * <code>
  *		// Get an instance of the "mailer" object registered in the container
  *		$mailer = IoC::resolve('mailer');
  *
  *		// Get an instance of the "mailer" object and pass parameters to the resolver
  *		$mailer = IoC::resolve('mailer', array('test'));
  * </code>
  *
  * @param  string  $type
  * @param  array   $parameters
  * @return mixed
  */
 public static function resolve($type, $parameters = array())
 {
     // If an instance of the type is currently being managed as a singleton, we will
     // just return the existing instance instead of instantiating a fresh instance
     // so the developer can keep re-using the exact same object instance from us.
     if (isset(static::$singletons[$type])) {
         return static::$singletons[$type];
     }
     // If we don't have a registered resolver or concrete for the type, we'll just
     // assume the type is the concrete name and will attempt to resolve it as is
     // since the container should be able to resolve concretes automatically.
     if (!isset(static::$registry[$type])) {
         $concrete = $type;
     } else {
         $concrete = array_get(static::$registry[$type], 'resolver', $type);
     }
     // We're ready to instantiate an instance of the concrete type registered for
     // the binding. This will instantiate the type, as well as resolve any of
     // its nested dependencies recursively until they are each resolved.
     if ($concrete == $type or $concrete instanceof Closure) {
         $object = static::build($concrete, $parameters);
     } else {
         $object = static::resolve($concrete);
     }
     // If the requested type is registered as a singleton, we want to cache off
     // the instance in memory so we can return it later without creating an
     // entirely new instances of the object on each subsequent request.
     if (isset(static::$registry[$type]['singleton']) && static::$registry[$type]['singleton'] === true) {
         static::$singletons[$type] = $object;
     }
     Event::fire('laravel.resolving', array($type, $object));
     return $object;
 }
Example #16
0
 /**
  * Log the user out of the driver's auth context.
  *
  * @return void
  */
 public function logout()
 {
     $this->user = null;
     $this->cookie($this->recaller(), null, -2000);
     Session::forget($this->token());
     Event::fire('laravel.auth: logout');
     $this->token = null;
 }
Example #17
0
|
| We'll send the response back to the browser here. This method will also
| send all of the response headers to the browser as well as the string
| content of the Response. This should make the view available to the
| browser and show something pretty to the user.
|
*/
$response->send();
/*
|--------------------------------------------------------------------------
| And We're Done!
|--------------------------------------------------------------------------
|
| Raise the "done" event so extra output can be attached to the response.
| This allows the adding of debug toolbars, etc. to the view, or may be
| used to do some kind of logging by the application.
|
*/
Event::fire('laravel.done', array($response));
/*
|--------------------------------------------------------------------------
| Finish the request for PHP-FastCGI
|--------------------------------------------------------------------------
|
| Stopping the PHP process for PHP-FastCGI users to speed up some
| PHP queries. Acceleration is possible when there are actions in the
| process of script execution that do not affect server response.
| For example, saving the session in memcached can occur after the page
| has been formed and passed to a web server.
*/
$response->foundation->finish();
 /**
  * Resolve a bundle and controller name to a controller instance.
  *
  * @param  string      $bundle
  * @param  string      $controller
  * @return Controller
  */
 public static function resolve($bundle, $controller)
 {
     if (!static::load($bundle, $controller)) {
         return;
     }
     $identifier = Bundle::identifier($bundle, $controller);
     // If the controller is registered in the IoC container, we will resolve
     // it out of the container. Using constructor injection on controllers
     // via the container allows more flexible applications.
     $resolver = 'controller: ' . $identifier;
     if (IoC::registered($resolver)) {
         return IoC::resolve($resolver);
     }
     $controller = static::format($bundle, $controller);
     // If we couldn't resolve the controller out of the IoC container we'll
     // format the controller name into its proper class name and load it
     // by convention out of the bundle's controller directory.
     if (Event::listeners(static::factory)) {
         return Event::first(static::factory, $controller);
     } else {
         return new $controller();
     }
 }
Example #19
0
 /**
  * Log the query and fire the core query event.
  *
  * @param  string  $sql
  * @param  array   $bindings
  * @param  int     $time
  * @return void
  */
 protected function log($sql, $bindings, $time)
 {
     Event::fire('laravel: query', array($sql, $bindings, $time));
     static::$queries = compact('sql', 'bindings', 'time');
 }
Example #20
0
 /**
  * Get the evaluated string content of the view.
  *
  * @return string
  */
 public function render()
 {
     // To allow bundles or other pieces of the application to modify the
     // view before it is rendered, we will fire an event, passing in the
     // view instance so it can modified.
     Event::fire("laravel.composing: {$this->view}", array($this));
     $data = $this->data();
     ob_start() and extract($data, EXTR_SKIP);
     // If the view is Bladed, we need to check the view for changes and
     // get the path to the compiled view file. Otherwise, we'll just
     // use the regular path to the view.
     //
     // Also, if the Blade view has expired or doesn't exist it will be
     // re-compiled and placed in the view storage directory. The Blade
     // views are re-compiled the original view changes.
     if (strpos($this->path, BLADE_EXT) !== false) {
         $this->path = $this->compile();
     }
     try {
         include $this->path;
     } catch (\Exception $e) {
         ob_get_clean();
         throw $e;
     }
     return ob_get_clean();
 }
 /**
  * Get the evaluated string content of the view.
  *
  * @return string
  */
 public function render()
 {
     // To allow bundles or other pieces of the application to modify the
     // view before it is rendered, we'll fire an event, passing in the
     // view instance so it can modified.
     $composer = "laravel.composing: {$this->view}";
     Event::fire($composer, array($this));
     // If there are listeners to the view engine event, we'll pass them
     // the view so they can render it according to their needs, which
     // allows easy attachment of other view parsers.
     if (Event::listeners(static::engine)) {
         $result = Event::first(static::engine, array($this));
         if ($result !== false) {
             return $result;
         }
     }
     return $this->get();
 }
 /**
  * Load all of the language lines from a language file.
  *
  * @param  string  $bundle
  * @param  string  $language
  * @param  string  $file
  * @return bool
  */
 public static function load($bundle, $language, $file)
 {
     if (isset(static::$lines[$bundle][$language][$file])) {
         return true;
     }
     // We use a "loader" event to delegate the loading of the language
     // array, which allows the develop to organize the language line
     // arrays for their application however they wish.
     $lines = Event::first(static::loader, func_get_args());
     static::$lines[$bundle][$language][$file] = $lines;
     return count($lines) > 0;
 }
Example #23
0
 /**
  * Get the evaluated contents of the view.
  *
  * @return string
  */
 public function get()
 {
     $__data = $this->data();
     // The contents of each view file is cached in an array for the
     // request since partial views may be rendered inside of for
     // loops which could incur performance penalties.
     $__contents = $this->load();
     ob_start() and extract($__data, EXTR_SKIP);
     // We'll include the view contents for parsing within a catcher
     // so we can avoid any WSOD errors. If an exception occurs we
     // will throw it out to the exception handler.
     try {
         eval('?>' . $__contents);
     } catch (\Exception $e) {
         ob_get_clean();
         throw $e;
     }
     $content = ob_get_clean();
     // The view filter event gives us a last chance to modify the
     // evaluated contents of the view and return them. This lets
     // us do something like run the contents through Jade, etc.
     if (Event::listeners('view.filter')) {
         return Event::first('view.filter', array($content, $this->path));
     }
     return $content;
 }
Example #24
0
 /**
  * Fire a given event for the model.
  *
  * @param  string  $event
  * @return array
  */
 protected function fire_event($event)
 {
     $events = array("eloquent.{$event}", "eloquent.{$event}: " . get_class($this));
     Event::fire($events, array($this));
 }
Example #25
0
 public function create_account($user, $default_avatar_name = 'ruth')
 {
     // Check if user already exists
     $user_account = self::where_PrincipalID($user->uuid)->first();
     if (!isset($user_account)) {
         $ServiceURLs = 'HomeURI= GatekeeperURI= InventoryServerURI= AssetServerURI=';
         $user_account = new self();
         $user_account->PrincipalID = $user->uuid;
         $user_account->ScopeID = UUID::ZERO;
         $user_account->FirstName = $user->avatar_first_name;
         $user_account->LastName = $user->avatar_last_name;
         $user_account->Email = $user->email;
         $user_account->ServiceURLs = $ServiceURLs;
         $user_account->Created = time();
         $user_account->UserLevel = 0;
         $user_account->UserFlags = 0;
         $user_account->UserTitle = '';
         $user_account->save();
     }
     // Set passwords
     $account_auth = Auth::where_UUID($user->uuid)->first();
     // Check if there is no
     // password already set for this account
     if (!isset($account_auth)) {
         $account_auth = new Auth();
         if ($user->status == 'active') {
             $account_auth->passwordHash = $user->hash;
             $account_auth->passwordSalt = $user->salt;
         } else {
             $account_auth->passwordHash = $user->status;
             $account_auth->passwordSalt = $user->status;
         }
         $account_auth->UUID = $user->uuid;
         $account_auth->webLoginKey = UUID::ZERO;
         $account_auth->accountType = 'UserAccount';
         $account_auth->save();
     }
     // Set home location
     $home_location = \Settings\Model\Setting::where_module_slug('opensim')->where_slug('opensim_home_location')->first();
     if (isset($home_location->value) and \Opensim\UUID::is_valid($home_location->value)) {
         $home_location_data = array('UserID' => $user->uuid, 'HomeRegionID' => $home_location->value, 'HomePosition' => '<0,0,0>', 'HomeLookAt' => '<0,0,0>', 'LastRegionID' => $home_location->value, 'LastPosition' => '<128,128,22>', 'LastLookAt' => '<0,1,0>', 'Online' => 'False', 'Login' => $user->created_at->getTimestamp(), 'Logout' => $user->created_at->getTimestamp());
         Griduser::insert($home_location_data);
     }
     // create inventory
     $account_inventory = InventoryFolder::where_agentID($user->uuid)->get();
     if (!isset($account_inventory) or empty($account_inventory)) {
         $account_inventory = new InventoryFolder();
         $account_inventory = $account_inventory->create_inventory($user->uuid);
     } else {
         $acc_inv = array();
         foreach ($account_inventory as $folder_name => $folder) {
             $acc_inv[$folder->foldername] = array('folderName' => $folder->foldername, 'type' => $folder->type, 'version' => $folder->version, 'folderID' => $folder->folderid, 'agentID' => $folder->agentid, 'parentFolderID' => $folder->parentfolderid);
         }
         $account_inventory = $acc_inv;
     }
     // Load avatar initial items items
     $items = Event::until('opensim.load.avatar.items', array($default_avatar_name, $user, $account_inventory));
     if (is_null($items)) {
         $items = \Opensim\load_ruth_items($user->uuid, $account_inventory);
     }
     if (isset($items) and !empty($items)) {
         $invento = InventoryItem::insert($items);
     }
     // Load Avatar appearance
     $items_array = Event::until('opensim.load.avatar.appearance', array($default_avatar_name, $user));
     if (is_null($items_array)) {
         $items_array = \Opensim\load_ruth_appearance($user->uuid);
     }
     // Save appearance
     $avatar_apearance = \Opensim\Model\Os\Avatar::insert($items_array);
 }