Ejemplo n.º 1
0
 public static function logs($logfile)
 {
     $file = File::get(path('storage') . '/logs/' . $logfile . '.log');
     $array = array_reverse(explode("\n", $file));
     unset($array[0]);
     return $array;
 }
Ejemplo n.º 2
0
 /**
  * Activate a valid iBundle.
  *
  * @param  string  $bundle
  * @return boolean
  */
 public function activate($bundle)
 {
     // Activated bundles
     $bundles = $this->activated();
     // Already activated or iBundle is not available.
     if (!array_key_exists($bundle, $this->available()) or array_key_exists($bundle, $bundles)) {
         return false;
     }
     // Path to the iBundle JSON file
     $meta_data = ibundle_config('path') . $bundle . DIRECTORY_SEPARATOR . 'ibundle.json';
     // You need to chmod the ibundle.json file.
     if (!Laravel_File::exists($meta_data) or !is_readable($meta_data)) {
         return false;
     }
     // Get meta data proper
     $meta_data = (array) json_decode(Laravel_File::get($meta_data));
     // Invalid meta data. grr.
     if (!$this->valid_meta_data($meta_data)) {
         return false;
     }
     // Set as activated, along with meta data
     $this->activated[$bundle] = $meta_data;
     // Set fresh data
     $this->_data = $this->_prep_data($this->activated);
     // Save
     return (bool) $this->save();
 }
Ejemplo n.º 3
0
 /**
  * Set the session driver to a given value.
  *
  * @param  string  $driver
  * @return void
  */
 protected function driver($driver)
 {
     // By default no session driver is set within the configuration.
     // This method will replace the empty driver option with the
     // driver specified in the arguments.
     $config = File::get(path('app') . 'config/session' . EXT);
     $config = str_replace("'driver' => '',", "'driver' => 'database',", $config);
     File::put(path('app') . 'config/session' . EXT, $config);
 }
Ejemplo n.º 4
0
 /**
  * Get the stub migration with the proper class name.
  *
  * @param  string  $bundle
  * @param  string  $migration
  * @return string
  */
 protected function stub($bundle, $migration)
 {
     $stub = File::get(Bundle::path('doctrine') . 'migration_stub' . EXT);
     $prefix = Bundle::class_prefix($bundle);
     // The class name is formatted simialrly to tasks and controllers,
     // where the bundle name is prefixed to the class if it is not in
     // the default "application" bundle.
     $class = $prefix . Str::classify($migration);
     return str_replace('{{class}}', $class, $stub);
 }
Ejemplo n.º 5
0
 /**
  * Write a stub phpunit.xml file to the base directory.
  *
  * @param  string  $directory
  * @return void
  */
 protected function stub($directory)
 {
     $path = path('sys') . 'cli/tasks/test/';
     $stub = File::get($path . 'stub.xml');
     // The PHPUnit bootstrap file contains several items that are swapped
     // at test time. This allows us to point PHPUnit at a few different
     // locations depending on what the developer wants to test.
     foreach (array('bootstrap', 'directory') as $item) {
         $stub = $this->{"swap_{$item}"}($stub, $path, $directory);
     }
     File::put(path('base') . 'phpunit.xml', $stub);
 }
Ejemplo n.º 6
0
 protected function minify_style($assets, $attributes, $files_to_compile, $output_file, $compile)
 {
     if ($compile) {
         $output_file_contents = '';
         foreach ($files_to_compile as $file) {
             $asset_content = File::get(path('public') . $file);
             $output_file_contents .= Compressor::process($asset_content);
         }
         File::put($this->config['cache_dir_path'] . $output_file, $output_file_contents);
     }
     return HTML::style($this->config['cache_dir'] . $output_file . '?t=' . File::modified($this->config['cache_dir_path'] . $output_file), $attributes);
 }
Ejemplo n.º 7
0
 public static function set_app_installed()
 {
     // Set application config file index.php
     $config_path = path('app') . 'config' . DS . 'application' . EXT;
     $config = File::get($config_path);
     $newConfig = str_replace("'installed' => false,", "'installed' => true,", $config, $count);
     if (isset($newConfig) and $newConfig != '') {
         if ($count > 0) {
             File::put($config_path, $newConfig);
             Log::info('App flag installed set');
         }
     } else {
         Log::error('App flag installed failed.');
     }
 }
Ejemplo n.º 8
0
 /**
  * List available artisan commands. 
  *
  * @return void
  */
 public function commands()
 {
     // read help contents
     $command_data = json_decode(File::get(__DIR__ . '/help.json'));
     // format and display help contents
     $i = 0;
     foreach ($command_data as $category => $commands) {
         if ($i++ != 0) {
             echo PHP_EOL;
         }
         echo PHP_EOL . "# {$category}" . PHP_EOL;
         foreach ($commands as $command => $details) {
             echo PHP_EOL . str_pad($command, 20) . str_pad($details->description, 30);
         }
     }
 }
Ejemplo n.º 9
0
 /**
  * Generate a random key for the application.
  *
  * @param  array  $arguments
  * @return void
  */
 public function generate($arguments = array())
 {
     // By default the Crypter class uses AES-256 encryption which uses
     // a 32 byte input vector, so that is the length of string we will
     // generate for the application token unless another length is
     // specified through the CLI.
     $key = Str::random(array_get($arguments, 0, 32));
     $config = File::get($this->path);
     $config = str_replace("'key' => '',", "'key' => '{$key}',", $config, $count);
     File::put($this->path, $config);
     if ($count > 0) {
         echo "Configuration updated with secure key!";
     } else {
         echo "An application key already exists!";
     }
     echo PHP_EOL;
 }
Ejemplo n.º 10
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);
 }
Ejemplo n.º 11
0
 /**
  * Create a new download response instance.
  *
  * <code>
  *		// Create a download response to a given file
  *		return Response::download('path/to/file.jpg');
  *
  *		// Create a download response with a given file name
  *		return Response::download('path/to/file.jpg', 'your_file.jpg');
  * </code>
  *
  * @param  string    $path
  * @param  string    $name
  * @param  array     $headers
  * @return Response
  */
 public static function download($path, $name = null, $headers = array())
 {
     if (is_null($name)) {
         $name = basename($path);
     }
     // We'll set some sensible default headers, but merge the array given to
     // us so that the developer has the chance to override any of these
     // default headers with header values of their own liking.
     $headers = array_merge(array('Content-Description' => 'File Transfer', 'Content-Type' => File::mime(File::extension($path)), 'Content-Transfer-Encoding' => 'binary', 'Expires' => 0, 'Cache-Control' => 'must-revalidate, post-check=0, pre-check=0', 'Pragma' => 'public', 'Content-Length' => File::size($path)), $headers);
     // Once we create the response, we need to set the content disposition
     // header on the response based on the file's name. We'll pass this
     // off to the HttpFoundation and let it create the header text.
     $response = new static(File::get($path), 200, $headers);
     $d = $response->disposition($name);
     return $response->header('Content-Disposition', $d);
 }
Ejemplo n.º 12
0
 /**
  * Fetches activated bundle list from the filesystem.
  *
  * @return array
  */
 protected function fetch()
 {
     return Laravel_File::get(ibundle_config('file'), null);
 }
Ejemplo n.º 13
0
 /**
  * Get a created placeholdr image content.
  *
  * @param  integer  $width
  * @param  integer $height
  * @param  string  $text
  * @return string
  */
 public function get($width, $height = 0, $text = '')
 {
     if (!($image_file = $this->make($width, $height, $text))) {
         throw new Exception('Failed to create placeholdr.');
     }
     // Get image file contents
     $image_file_contents = File::get($image_file);
     if (Config::get('placeholdr::placeholdr.gd.save_created_placeholdrs') !== true) {
         File::delete($image_file);
     }
     return $image_file_contents;
 }
Ejemplo n.º 14
0
 public static function download($path, $name = null, $headers = array())
 {
     if (is_null($name)) {
         $name = basename($path);
     }
     $headers = array_merge(array('Content-Description' => 'File Transfer', 'Content-Type' => File::mime(File::extension($path)), 'Content-Transfer-Encoding' => 'binary', 'Expires' => 0, 'Cache-Control' => 'must-revalidate, post-check=0, pre-check=0', 'Pragma' => 'public', 'Content-Length' => File::size($path)), $headers);
     $response = new static(File::get($path), 200, $headers);
     $d = $response->disposition($name);
     return $response->header('Content-Disposition', $d);
 }
Ejemplo n.º 15
0
 /**
  * Checks if the module is valid
  * and can be loaded
  * 
  * @return Module
  */
 public function is_valid()
 {
     $info_file_path = '';
     if (!file_exists($this->path)) {
         $this->errors->add($this->slug, 'Module [' . $this->slug . '] was not found');
         return false;
     }
     $info_files = glob($this->path . 'info.*');
     if (empty($info_files)) {
         $this->errors->add($this->slug, 'The information file for [' . $this->slug . '] module is missing');
         return false;
     }
     $info_file_path = $info_files['0'];
     $this->file_info_type = file_extension($info_file_path);
     // create method to decode
     // other types of info files
     $json_module_info = json_decode(File::get($info_file_path), true);
     if (!isset($json_module_info) or empty($json_module_info)) {
         $this->errors->add('module', 'The information file for module [' . $this->slug . '] is malformed');
         return false;
     }
     foreach ($json_module_info as $property => $value) {
         if (property_exists($this, $property)) {
             $this->{$property} = $value;
         }
     }
     $this->exist = true;
     return $this;
 }
Ejemplo n.º 16
0
 /**
  * Get the stub migration with the proper class name.
  *
  * @param  string  $bundle
  * @param  string  $migration
  * @return string
  */
 protected function stub($bundle, $migration)
 {
     $stub = File::get(path('sys') . 'cli/tasks/migrate/stub' . EXT);
     // The class name is formatted simialrly to tasks and controllers,
     // where the bundle name is prefixed to the class if it is not in
     // the default bundle.
     $class = Bundle::class_prefix($bundle) . Str::classify($migration);
     return str_replace('{{class}}', $class, $stub);
 }