Example #1
2
 /**
  * Execute the console command.
  *
  * @return void
  */
 public function fire()
 {
     // Set directories
     $inputPath = base_path('resources/views');
     $outputPath = storage_path('gettext');
     // Create $outputPath or empty it if already exists
     if (File::isDirectory($outputPath)) {
         File::cleanDirectory($outputPath);
     } else {
         File::makeDirectory($outputPath);
     }
     // Configure BladeCompiler to use our own custom storage subfolder
     $compiler = new BladeCompiler(new Filesystem(), $outputPath);
     $compiled = 0;
     // Get all view files
     $allFiles = File::allFiles($inputPath);
     foreach ($allFiles as $f) {
         // Skip not blade templates
         $file = $f->getPathName();
         if ('.blade.php' !== substr($file, -10)) {
             continue;
         }
         // Compile the view
         $compiler->compile($file);
         $compiled++;
         // Rename to human friendly
         $human = str_replace(DIRECTORY_SEPARATOR, '-', ltrim($f->getRelativePathname(), DIRECTORY_SEPARATOR));
         File::move($outputPath . DIRECTORY_SEPARATOR . sha1($file) . '.php', $outputPath . DIRECTORY_SEPARATOR . $human);
     }
     if ($compiled) {
         $this->info("{$compiled} files compiled.");
     } else {
         $this->error('No .blade.php files found in ' . $inputPath);
     }
 }
 /**
  * Register any application services.
  *
  * @return void
  */
 public function register()
 {
     $this->app->singleton('League\\Glide\\Server', function ($app) {
         $filesystem = $app->make('Illuminate\\Contracts\\Filesystem\\Filesystem');
         return \League\Glide\ServerFactory::create(['source' => storage_path(), 'cache' => storage_path(), 'source_path_prefix' => 'app/', 'cache_path_prefix' => 'app/.cache', 'base_url' => 'img']);
     });
 }
 /**
  * Used in order to setup the cache directory for future use.
  * 
  * @param string The configuration to use
  * @return string The folder that is being cached to
  */
 private function setup_cache_directory($configuration)
 {
     // Check if caching is enabled
     $cache_enabled = $this->read_config($configuration, 'cache.enabled', false);
     // Is caching enabled?
     if (!$cache_enabled) {
         // It is disabled, so skip it
         return false;
     }
     // Grab the cache location
     $cache_location = storage_path($this->read_config($configuration, 'cache.location', 'rss-feeds'));
     // Is the last character a slash?
     if (substr($cache_location, -1) != DIRECTORY_SEPARATOR) {
         // Add in the slash at the end
         $cache_location .= DIRECTORY_SEPARATOR;
     }
     // Check if the folder is available
     if (!file_exists($cache_location)) {
         // It didn't, so make it
         mkdir($cache_location, 0777);
         // Also add in a .gitignore file
         file_put_contents($cache_location . '.gitignore', '!.gitignore' . PHP_EOL . '*');
     }
     return $cache_location;
 }
Example #4
0
 public function __construct()
 {
     $this->processBuilder = new ProcessBuilder();
     $this->git_location = config('gitcontrol.gitpath', '/usr/bin/git');
     $this->git_tmp = config('gitcontrol.tmppath', storage_path('tmp'));
     $this->git_mirror = config('gitcontrol.mirrorpath', storage_path('git'));
 }
Example #5
0
 public function download($id)
 {
     $file = File::findOrFail($id);
     $pathToFile = 'get_link_to_download/' . md5($file->name . time());
     FileHelpers::copy(storage_path('app') . '/' . $file->local_name, $pathToFile);
     return response()->download($pathToFile, $file->name, ['Content-Type'])->deleteFileAfterSend(true);
 }
Example #6
0
 /**
  * Create a new job instance.
  *
  * @return void
  */
 public function __construct(Chapter $chapter)
 {
     $this->chapter = $chapter;
     $this->fileName = storage_path('app/pdfs/') . $this->chapter->url;
     $this->pdfPreview = new \FPDI('portrait', 'pt', 'A4');
     $this->totalPageNumber = $this->pdfPreview->setSourceFile($this->fileName);
 }
 /**
  * Create a new command instance.
  *
  * @return void
  */
 public function __construct($file = 'forever.js')
 {
     parent::__construct();
     $this->file = $file;
     $this->filePath = base_path($file);
     $this->options = ['-l' => storage_path('logs/forever.log'), '-o' => storage_path('logs/forever.out.log'), '-e' => storage_path('logs/forever.err.log'), '--id' => strtolower(config('app.title')), '--append' => '', '--verbose' => ''];
 }
Example #8
0
 /**
  * Register any application services.
  *
  * @return void
  */
 public function register()
 {
     parent::register();
     $this->app->singleton(['server' => Contracts\Factory::class], function ($app) {
         return new Server\Factory($app, storage_path('server'));
     });
 }
 public function image()
 {
     if (!empty($this->photo_url) && File::exists(storage_path($this->photo_url))) {
         return 'images/image.php?id=' . $this->photo_url;
     }
     return 'images/missing.png';
 }
 /**
  * Execute the console command.
  *
  * @return mixed
  */
 public function fire()
 {
     $market = $this->argument('market');
     $fileName = storage_path() . '/app/' . time() . '.xls';
     file_put_contents($fileName, $this->getHtmlContent($this->argument('url')));
     $reader = PHPExcel_IOFactory::createReader('Excel5');
     $excel = $reader->load($fileName);
     $sheet = $excel->getSheet();
     $i = 2;
     while ($sheet->getCell("A{$i}") != "") {
         $code = $sheet->getCell("B{$i}");
         $name = $sheet->getCell("C{$i}");
         $issue = Issue::where('code', $code)->first();
         if (!$issue) {
             $issue = new Issue();
         }
         $issue->code = $code;
         $issue->name = $name;
         $issue->market = $market;
         if ($issue->getOriginal() != $issue->getAttributes()) {
             $issue->save();
         }
         $i++;
     }
     unlink($fileName);
 }
Example #11
0
 /**
  * Create a new command instance.
  *
  * @param \Illuminate\Filesystem\Filesystem
  *
  * @return void
  */
 public function __construct(Filesystem $files)
 {
     parent::__construct();
     $this->deletable = time() - 60 * 60 * 1.5;
     $this->base = storage_path('releases');
     $this->files = $files;
 }
Example #12
0
 public function __construct(Filesystem $filesystem)
 {
     $this->file = $filesystem;
     $this->path = storage_path('realtime') . '/';
     //ensure existence
     $this->file->makeDirectory($this->path, 0777, true, true);
 }
 /**
  * Execute the job.
  *
  * @return void
  */
 public function handle()
 {
     echo "Run task: #" . $this->job_id, "\n";
     $task = Tasks::find($this->job_id);
     $task->status = Tasks::RUN;
     $task->save();
     $client = new \Hoa\Websocket\Client(new \Hoa\Socket\Client('tcp://127.0.0.1:8889'));
     $client->setHost('127.0.0.1');
     $client->connect();
     $client->send(json_encode(["command" => webSocket::BROADCASTIF, "jobid" => $this->job_id, "msg" => json_encode(["jid" => $this->job_id, "status" => Tasks::RUN])]));
     $builder = new ProcessBuilder();
     $builder->setPrefix('ansible-playbook');
     $builder->setArguments(["-i", "inv" . $this->job_id, "yml" . $this->job_id]);
     $builder->setWorkingDirectory(storage_path("roles"));
     $process = $builder->getProcess();
     $process->run();
     //echo $process->getOutput() . "\n";
     $client->send(json_encode(["command" => webSocket::BROADCASTIF, "jobid" => $this->job_id, "msg" => json_encode(["jid" => $this->job_id, "status" => Tasks::FINISH])]));
     $client->close();
     $task->status = Tasks::FINISH;
     $task->content = file_get_contents(storage_path("tmp/log" . $this->job_id . ".txt"));
     $task->save();
     unlink(storage_path("roles/yml" . $this->job_id));
     unlink(storage_path("roles/inv" . $this->job_id));
     unlink(storage_path("tmp/log" . $this->job_id . ".txt"));
     echo "End task: #" . $this->job_id, "\n";
 }
Example #14
0
 /**
  * Seed the form with defaults that are stored in the session
  *
  * @param Model $model
  * @param CrudController $crudController
  */
 public function onCrudSaved(Model $model, CrudController $crudController)
 {
     $fb = $crudController->getFormBuilder();
     foreach ($fb->getElements() as $name => $element) {
         if (!$element instanceof FileElement) {
             continue;
         }
         if ($model instanceof File) {
             $file = $model;
         } else {
             $file = new File();
         }
         if ($uploaded = Input::file($name)) {
             // Save the file to the disk
             $uploaded->move(storage_path($element->getPath()), $uploaded->getClientOriginalName());
             // Update the file model with metadata
             $file->name = $uploaded->getClientOriginalName();
             $file->extension = $uploaded->getClientOriginalExtension();
             $file->size = $uploaded->getClientSize();
             $file->path = $element->getPath() . '/' . $uploaded->getClientOriginalName();
             $file->save();
             if (!$model instanceof File) {
                 $model->{$name} = $element->getPath() . '/' . $uploaded->getClientOriginalName();
                 $model->save();
             }
         }
     }
 }
Example #15
0
 /**
  * Execute the console command.
  *
  * @return mixed
  */
 public function fire()
 {
     parent::fire();
     $serverHost = $this->option('host');
     $serverPort = $this->option('port');
     $serverEnv = $this->option('env');
     $assetsServerHost = $this->option('larasset-host');
     $assetsServerPort = $this->option('larasset-port');
     putenv('LARASSET_PORT=' . $assetsServerPort);
     if ($this->option('larasset-environment')) {
         // TODO: Remove the DEPRECATED stuff in the next minor version (0.10.0 or 1.0.0)
         $this->comment("WARN: The '--larasset-environment' option is DEPRECATED, use '--larasset-env' option instead please.");
         $assetsServerEnv = $this->option('larasset-environment');
     } else {
         $assetsServerEnv = $this->option('larasset-env');
     }
     // Run assets server in a background process
     $command = "php artisan larasset:serve --port=" . $assetsServerPort . " --host=" . $assetsServerHost . " --assets-env=" . $assetsServerEnv;
     $this->info("Start the assets server...");
     $serverLogsPath = $this->normalizePath(storage_path('logs/larasset_server.log'));
     $this->line('Assets server logs are stored in "' . $serverLogsPath . '"');
     $this->execInBackground($command, $serverLogsPath);
     // Run PHP application server
     $this->call('serve', ['--host' => $serverHost, '--port' => $serverPort, '--env' => $serverEnv]);
 }
 protected function installCommand()
 {
     $this->app->bind('Flarum\\Install\\Prerequisite\\PrerequisiteInterface', function () {
         return new Composite(new PhpVersion('5.5.0'), new PhpExtensions(['dom', 'fileinfo', 'gd', 'json', 'mbstring', 'openssl', 'pdo_mysql']), new WritablePaths([public_path(), public_path('assets'), public_path('extensions'), storage_path()]));
     });
     $this->commands([InstallCommand::class]);
 }
 /**
  * Register the application services.
  *
  * @return void
  */
 public function register()
 {
     $configPath = __DIR__ . '/../config/sql-logging.php';
     $this->mergeConfigFrom($configPath, 'sql-logging');
     if (config('sql-logging.log', false)) {
         Event::listen('illuminate.query', function ($query, $bindings, $time) {
             $data = compact('bindings', 'time');
             // Format binding data for sql insertion
             foreach ($bindings as $i => $binding) {
                 if ($binding instanceof \DateTime) {
                     $bindings[$i] = $binding->format('\'Y-m-d H:i:s\'');
                 } else {
                     if (is_string($binding)) {
                         $bindings[$i] = "'{$binding}'";
                     }
                 }
             }
             // Insert bindings into query
             $query = str_replace(array('%', '?'), array('%%', '%s'), $query);
             $query = vsprintf($query, $bindings);
             $log = new Logger('sql');
             $log->pushHandler(new StreamHandler(storage_path() . '/logs/sql-' . date('Y-m-d') . '.log', Logger::INFO));
             // add records to the log
             $log->addInfo($query, $data);
         });
     }
 }
Example #18
0
 public function postRestore()
 {
     // validasi
     $input = Input::all();
     $rules = array('sql' => 'required|sql');
     $validasi = Validator::make(Input::all(), $rules);
     // tidak valid
     if ($validasi->fails()) {
         // pesan
         $sql = $validasi->messages()->first('sql') ?: '';
         return Response::json(compact('sql'));
         // valid
     } else {
         // ada sql
         if (Input::hasFile('sql')) {
             // nama sql
             $sql = date('dmYHis') . '.sql';
             // unggah sql ke dir "app/storage/restores"
             Input::file('sql')->move(storage_path() . '/restores/', $sql);
             // path file
             $file = storage_path() . '/restores/' . $sql;
             // dump database
             $dump = new Dump();
             $dump->file($file)->dsn($this->dsn)->user($this->user)->pass($this->pass);
             new Import($dump);
             // hapus file restore
             unlink($file);
             // tidak ada sql
         } else {
             // pesan
             $sql = 'Sql gagal diunggah.';
             return Response::json(compact('sql'));
         }
     }
 }
Example #19
0
 /**
  * Execute the console command.
  *
  * @return mixed
  */
 public function fire()
 {
     $database = $this->option('database') ?: $this->config->get('database.default');
     if (!is_dir(storage_path() . '/aperture')) {
         mkdir(storage_path() . '/aperture');
     }
     $selection = array();
     foreach (scandir(storage_path() . '/aperture', SCANDIR_SORT_DESCENDING) as $file) {
         if (strpos($file, $this->argument('table') . '_' . $database)) {
             $selection[] = $file;
         }
     }
     if (count($selection) === 0) {
         return $this->error('No snapshots found.');
     } elseif (count($selection) === 1) {
         $choice = 0;
     } else {
         foreach ($selection as $key => $file) {
             echo '[' . $key . '] Snapshot from ';
             $parts = explode('_', $file);
             echo date('H:i, M jS', $parts[0]) . "\n";
         }
         $choice = (int) $this->ask('Which snapshot do you want to restore from? ');
     }
     if ($this->snapshot->hasRows($database, $this->argument('table'), $this->option('chunk')) && !$this->confirm('This will clear any existing data in ' . $this->argument('table') . '. Continue? [y|N]', false)) {
         return $this->error('Restoration aborted');
     }
     $file = fopen(storage_path() . '/aperture/' . $selection[$choice], 'r');
     $this->snapshot->handle = $file;
     $this->snapshot->restore($database, $this->argument('table'), $this->option('chunk'));
     fclose($file);
     $this->info('Snapshot restored!');
 }
Example #20
0
 public function __construct(Filesystem $filesystem, Definition $definition)
 {
     $this->filesystem = $filesystem;
     $this->definition = $definition;
     $this->path = storage_path('installation.json');
     $this->fetchData();
 }
Example #21
0
 /**
  * Store a newly created resource in storage.
  *
  * @return Response
  */
 public function store()
 {
     $a = new \App\Popups();
     $a->judul = Input::get('judul');
     $a->slug = str_slug(Input::get('judul'));
     $a->deskripsi = Input::get('keterangan');
     $a->tipe_valid = Input::get('type_valid');
     if ($a->tipe_valid == "by_datetime" or $a->tipe_valid == "by_date") {
         $a->date_valid_start = date_format(date_create(Input::get('date_valid_start')), "Y-m-d");
         $a->date_valid_end = date_format(date_create(Input::get('date_valid_end')), "Y-m-d");
     }
     if ($a->tipe_valid == "by_datetime" or $a->tipe_valid == "by_time") {
         $a->time_valid_start = date_format(date_create(Input::get('time_valid_start')), "H:i:s");
         $a->time_valid_end = date_format(date_create(Input::get('time_valid_end')), "H:i:s");
     }
     if (Input::hasFile('image') and Input::file('image')->isValid()) {
         $image = date("YmdHis") . uniqid() . "." . Input::file('image')->getClientOriginalExtension();
         Input::file('image')->move(storage_path() . '/popup_image', $image);
         $a->image = $image;
     }
     $a->keep_open = Input::get('keep_open');
     $a->hotlink = Input::get('hotlink');
     $a->idpengguna = Auth::user()->id;
     $a->save();
     return redirect(url('admin/popups'));
 }
function upsfile($stock)
{
    //<--- Function to copy a stock quote CSV from Yahoo to the local cache. CSV contains symbol, price, and change
    if (checkRemoteFile("http://finance.yahoo.com/d/quotes.csv?s={$stock}&f=sl1c1&e=.csv")) {
        copy("http://finance.yahoo.com/d/quotes.csv?s={$stock}&f=sl1c1&e=.csv", storage_path() . DS . 'cache' . DS . $stock . ".csv");
    }
}
 /**
  * Execute the job.
  * @return void
  */
 public function handle()
 {
     $s3 = \App::make('aws');
     $s3->createClient('s3')->putObject(['Bucket' => 'transcoderinput435983', 'Key' => $this->key_input, 'SourceFile' => storage_path() . '/app/' . $this->key_input]);
     $s3->createClient('ElasticTranscoder')->createJob(['PipelineId' => env('PIPLINE_ID'), 'Input' => ['Key' => $this->key_input, 'FrameRate' => 'auto', 'Resolution' => 'auto', 'AspectRatio' => 'auto', 'Interlaced' => 'auto', 'Container' => 'auto'], 'Output' => ['Key' => $this->key_output, 'ThumbnailPattern' => $this->time . '_thumb{count}', 'Rotate' => 'auto', 'PresetId' => '1452215960232-me3asn']]);
     \File::delete(storage_path() . '/app/' . $this->key_input);
 }
 public function index(Request $request, $path)
 {
     // Setup Glide server
     $server = ServerFactory::create(['response' => new LaravelResponseFactory(), 'source' => storage_path(), 'cache' => storage_path('media/cache')]);
     // But, a better approach is to use information from the request
     $server->outputImage($path, $request->all());
 }
Example #25
0
 /**
  * Returns the current context
  *
  * @param boolean $locale True to add locale object to context, false if not
  * @return \Aimeos\MShop\Context\Item\Iface Context object
  */
 public function get($locale = true)
 {
     if (self::$context === null) {
         $context = new \Aimeos\MShop\Context\Item\Standard();
         $config = $this->getConfig();
         $context->setConfig($config);
         $dbm = new \Aimeos\MW\DB\Manager\PDO($config);
         $context->setDatabaseManager($dbm);
         $fs = new \Aimeos\MW\Filesystem\Manager\Laravel(app('filesystem'), $config, storage_path('aimeos'));
         $context->setFilesystemManager($fs);
         $mail = new \Aimeos\MW\Mail\Swift(function () {
             return app('mailer')->getSwiftMailer();
         });
         $context->setMail($mail);
         $logger = \Aimeos\MAdmin\Log\Manager\Factory::createManager($context);
         $context->setLogger($logger);
         $cache = new \Aimeos\MAdmin\Cache\Proxy\Standard($context);
         $context->setCache($cache);
         self::$context = $context;
     }
     $context = self::$context;
     if ($locale === true) {
         $localeItem = $this->getLocale($context);
         $langid = $localeItem->getLanguageId();
         $context->setLocale($localeItem);
         $context->setI18n(app('\\Aimeos\\Shop\\Base\\I18n')->get(array($langid)));
     }
     $session = new \Aimeos\MW\Session\Laravel5($this->session);
     $context->setSession($session);
     $this->addUser($context);
     return $context;
 }
 public function uploadpcount(Request $request)
 {
     $destinationPath = storage_path() . '/uploads/pcount/';
     $fileName = $request->file('data')->getClientOriginalName();
     $request->file('data')->move($destinationPath, $fileName);
     return response()->json(array('msg' => 'file uploaded', 'status' => 0));
 }
Example #27
0
 public function __construct()
 {
     // Carbon Language
     Carbon::setLocale('tr');
     // create home page if non exist
     count(Menu::where('slug', '/anasayfa')->get()) == 0 ? Menu::create(['title' => 'Anasayfa', 'slug' => '/anasayfa', 'eng_title' => 'Home', 'eng_slug' => '/home'])->save() : null;
     // create config file if non exist
     !\File::exists(storage_path('.config')) ? \File::put(storage_path('.config'), json_encode(['brand' => 'Brand Name', 'mail' => '*****@*****.**', 'active' => 1, 'eng' => '0', 'one_page' => '0', 'googlemap' => '', 'header' => ''])) : null;
     $this->config = json_decode(\File::get(storage_path('.config')));
     !\File::exists(storage_path('app/custom/css')) ? \File::makeDirectory(storage_path('app/custom/css'), 0755, true) : null;
     !\File::exists(storage_path('app/custom/js')) ? \File::makeDirectory(storage_path('app/custom/js'), 0755, true) : null;
     // get css & js files from custom folder
     // css
     $css = \File::allFiles(storage_path('app/custom/css'));
     if (!empty($css)) {
         foreach ($css as $cs) {
             $this->css[$cs->getCtime()] = $cs->getRelativePathname();
         }
         // sort by date
         ksort($this->css);
     }
     // js
     $js = \File::allFiles(storage_path('app/custom/js'));
     if (!empty($js)) {
         foreach ($js as $j) {
             $this->js[$j->getCtime()] = $j->getRelativePathname();
         }
         // sort by date
         ksort($this->js);
     }
 }
 /**
  * Execute the console command.
  *
  * @return mixed
  */
 public function handle()
 {
     foreach ($this->files->files(storage_path() . '/framework/sessions') as $file) {
         $this->files->delete($file);
     }
     $this->info('Session files deleted from storage');
 }
Example #29
0
 public function __construct(Filesystem $fs, Factory $viewFactory = null, $cachePath = null)
 {
     $this->viewFactory = $viewFactory;
     $this->fs = $fs;
     $cachePath = $cachePath === null ? storage_path('blade') : $cachePath;
     $this->setCachePath($cachePath);
 }
 /**
  * Store a newly created resource in storage.
  *
  * @param  StoreMediaRequest  $request
  * @return Response
  */
 public function store(StoreMediaRequest $request)
 {
     if ($request->ajax()) {
         $response = ['error' => 1, 'path' => ''];
         if ($request->hasFile('file')) {
             $file = $request->file('file');
             $path = '/uploads/posts/' . date('Y-m-d');
             $destination = storage_path('app' . $path);
             $hashed = sha1(Str::slug($file->getClientOriginalName() . time())) . '.' . $file->getClientOriginalExtension();
             if (!\File::exists($destination)) {
                 \File::makeDirectory($destination);
             }
             if ($file->move($destination, $hashed)) {
                 $medium = $this->medium->create(['path' => $path . '/' . $hashed]);
                 if ($medium) {
                     $response['error'] = 0;
                     $response['path'] = $path . '/' . $hashed;
                     return response($response, 200);
                 }
                 // TODO: ln -s /path/to/public_html/storage/app/uploads /path/to/public_html/public/uploads
             }
         }
     }
     return response('error', 400);
 }