Exemplo n.º 1
0
 /**
  * Return files in path
  *
  * @param string $path
  *
  * @return mixed
  */
 public function getFiles($path)
 {
     $files = File::files($this->getPath($path));
     return array_map(function ($val) {
         return $this->sanitizePath($val);
     }, $files);
 }
Exemplo n.º 2
0
 public function run()
 {
     // get files in database/seeds folder
     $path = base_path('database/seeds');
     $files = array_map(function ($filename) {
         return str_replace(".php", "", $filename);
     }, array_map('basename', File::files($path)));
     // get entries in database
     $seeded = DB::table('seeded')->lists('seeder');
     // find seeds that need to be done
     foreach ($files as $file) {
         if ($file == 'DatabaseSeeder') {
             continue;
         }
         if (in_array($file, $seeded)) {
             continue;
         }
         // call the seeder
         Model::unguard();
         $this->command->info("Calling {$file}");
         try {
             $this->call($file);
             DB::table('seeded')->insert(['seeder' => $file]);
         } catch (Exception $e) {
             $this->command->error("Error in {$file}");
         }
         Model::reguard();
     }
 }
Exemplo n.º 3
0
 /**
  * Gets the files in the folder and returns their path
  * with the route relative to the public folder
  * @param $path
  * @return mixed
  */
 private function getAngularLocation($path)
 {
     $files = File::files($this->js_path . $path);
     foreach ($files as &$location) {
         $location = str_replace(public_path(), '', $location);
     }
     return $files;
 }
Exemplo n.º 4
0
 public function getPhotosList()
 {
     $photos = null;
     $folderPath = $this->property('photos_folder');
     if (File::exists($folderPath)) {
         $photos = File::files($folderPath);
     }
     return $photos;
 }
 private function cleanUp()
 {
     $files = File::files(storage_path());
     foreach ($files as $file) {
         if (strpos(File::mimeType($file), 'image') != false) {
             File::delete($file);
         }
     }
 }
Exemplo n.º 6
0
 public function test_with_alpha3_lowercase_names()
 {
     $exitCode = Artisan::call('prep:country-flags', ['--name' => 2, '--case' => 'lower']);
     $this->assertEquals(0, $exitCode, 'Assert exit code is 0');
     $this->assertTrue(File::isDirectory($this->dest), 'Assert flags directory was created');
     $files = File::files($this->dest);
     $this->assertContains($this->dest . '/ukr.svg', $files, 'Assert img files were created with appropriate naming conventions');
     $this->assertGreaterThan(200, count($files), 'Assert that count of generated flags is in expected range');
 }
 /**
  * Get the images to load for a selected folder
  *
  * @return mixed
  */
 public function getItems()
 {
     $type = Input::get('type');
     $view = $this->getView();
     $path = parent::getPath();
     $files = File::files($path);
     $file_info = $this->getFileInfos($files, $type);
     $directories = parent::getDirectories($path);
     $thumb_url = parent::getUrl('thumb');
     return view($view)->with(compact('type', 'file_info', 'directories', 'thumb_url'));
 }
Exemplo n.º 8
0
 /**
  * Get the images to load for a selected folder
  *
  * @return mixed
  */
 public function getItems()
 {
     $type = Input::get('type');
     $view = $this->getView($type);
     $path = $this->file_location . Input::get('working_dir');
     $files = File::files(base_path($path));
     $file_info = $this->getFileInfos($files, $type);
     $directories = parent::getDirectories($path);
     $thumb_url = parent::getUrl('thumb');
     return View::make($view)->with(compact('files', 'file_info', 'directories', 'thumb_url'));
 }
Exemplo n.º 9
0
 /**
  * Fetches all template files in views/templates
  * Cuts out blade and extension stuff
  * @return array
  */
 public static function getTemplateOptions()
 {
     $templateFiles = File::files(__DIR__ . '/../../views/templates');
     $array = array();
     foreach ($templateFiles as $template) {
         $file = pathinfo($template);
         list($filename) = explode(".", $file['basename']);
         $array[$filename] = ucfirst($filename);
     }
     return $array;
 }
 /**
  * Execute the command.
  *
  * @return void
  */
 public function handle()
 {
     // get paths of registered namespace hints
     // e.g user in @lang('user::myview') resolving to app/Modules/User/Resources
     $resDirs = Config::get('langcheck.usehints') ? Lang::getHints() : array();
     $resDirs[base_path() . '/resources/lang'] = 'app';
     // check each resource directory
     foreach ($resDirs as $path => $hint) {
         // skip vendor directories
         if (Config::get('langcheck.skipvendor') && strpos($path, "vendor/") !== false) {
             continue;
         }
         // generate path relative to project root
         $shortPath = substr($path, strlen(base_path() . '/'));
         $this->info("Checking '{$shortPath}'...");
         // load translation files into arrays
         $langDirs = File::directories($path);
         $languageData = array();
         foreach ($langDirs as $langDir) {
             $langCode = basename($langDir);
             $arrays = File::files($langDir);
             foreach ($arrays as $file) {
                 $fileName = basename($file);
                 $languageData[$langCode][$fileName] = File::getRequire($file);
             }
         }
         // compare language arrays with each other and find missing entries
         foreach ($languageData as $langCodeA => $langArraysA) {
             foreach ($langArraysA as $fileNameA => $langArrayA) {
                 foreach ($languageData as $langCodeB => $langArraysB) {
                     if ($langCodeA == $langCodeB) {
                         continue;
                     }
                     if (array_key_exists($fileNameA, $langArraysB)) {
                         $result = $this->array_diff_key_recursive($langArrayA, $langArraysB[$fileNameA]);
                         if (!empty($result)) {
                             $keys = implode($this->arrayKeysRecursive($result), ', ');
                             $this->error(" * File '{$fileNameA}':");
                             $this->error("   - Locale '{$langCodeB}' missing [{$keys}] existing in locale '{$langCodeA}'");
                         }
                     } else {
                         $this->error(" * File '{$fileNameA}' existing in locale '{$langCodeA}' is missing for locale '{$langCodeB}'");
                     }
                 }
             }
         }
         $this->info('');
     }
 }
Exemplo n.º 11
0
 public static function getList($dir, $file_types = array('gif' => 'image/gif', 'png' => 'image/png', 'jpg' => 'image/jpeg'))
 {
     $images = array();
     if (is_dir($dir)) {
         foreach (File::files($dir) as $entry) {
             /* return $entry; */
             if (!is_dir($entry)) {
                 if (in_array(mime_content_type($entry), $file_types)) {
                     $images[] = $entry;
                 }
             }
         }
     }
     return $images;
 }
 /**
  * Delete image and associated thumbnail
  *
  * @return mixed
  */
 public function getDelete()
 {
     $to_delete = Input::get('items');
     $base = Input::get("base");
     if ($base != "/") {
         if (File::isDirectory(base_path() . "/" . $this->file_location . $base . "/" . $to_delete)) {
             // make sure the directory is empty
             if (sizeof(File::files(base_path() . "/" . $this->file_location . $base . "/" . $to_delete)) == 0) {
                 File::deleteDirectory(base_path() . "/" . $this->file_location . $base . "/" . $to_delete);
                 return "OK";
             } else {
                 return "You cannot delete this folder because it is not empty!";
             }
         } else {
             if (File::exists(base_path() . "/" . $this->file_location . $base . "/" . $to_delete)) {
                 File::delete(base_path() . "/" . $this->file_location . $base . "/" . $to_delete);
                 if (Session::get('lfm_type') == "Images") {
                     File::delete(base_path() . "/" . $this->file_location . $base . "/" . "thumbs/" . $to_delete);
                 }
                 return "OK";
             } else {
                 return base_path() . "/" . $this->file_location . $base . "/" . $to_delete . " not found!";
             }
         }
     } else {
         $file_name = base_path() . "/" . $this->file_location . $to_delete;
         if (File::isDirectory($file_name)) {
             // make sure the directory is empty
             if (sizeof(File::files($file_name)) == 0) {
                 File::deleteDirectory($file_name);
                 return "OK";
             } else {
                 return "You cannot delete this folder because it is not empty!";
             }
         } else {
             if (File::exists($file_name)) {
                 File::delete($file_name);
                 if (Session::get('lfm_type') == "Images") {
                     File::delete(base_path() . "/" . $this->file_location . "thumbs/" . $to_delete);
                 }
                 return "OK";
             } else {
                 return $file_name . " not found!";
             }
         }
     }
 }
Exemplo n.º 13
0
 public function run()
 {
     DB::statement('SET FOREIGN_KEY_CHECKS = 0');
     // disable foreign key constraints
     // Reset table
     DB::table('files')->truncate();
     // Delete /public/upload
     FileSystem::deleteDirectory(public_path('upload'));
     // Delete /app/storage/views/*.*
     foreach (FileSystem::files(storage_path() . '/views') as $file) {
         if ($file != '.gitignore') {
             FileSystem::delete($file);
         }
     }
     // Faker data
     $faker = Faker\Factory::create();
     DB::statement('SET FOREIGN_KEY_CHECKS = 1');
     // enable foreign key constraints
 }
Exemplo n.º 14
0
 /**
  * Run the database seeds.
  *
  * @return void
  */
 public function run()
 {
     Model::unguard();
     $this->call(HochschulkompassSeeder::class);
     // call all seeders in "database/seeds/universities"
     foreach (File::files("database/seeds/universities") as $path) {
         $filename = pathinfo($path)["filename"];
         // create and execute seeder
         $seeder = new $filename();
         if ($seeder instanceof UniversitySeeder) {
             $seeder->run();
             // log
             if (isset($this->command)) {
                 $this->command->getOutput()->writeln("<info>Published:</info> " . $filename);
             }
         }
     }
     Model::reguard();
 }
Exemplo n.º 15
0
 /**
  * Get all builds.
  *
  * @return array Array of build objects
  */
 public function all()
 {
     $files = File::files($this->directory);
     $builds = array();
     foreach ($files as $file) {
         $json = File::get($file);
         $data = json_decode($json);
         $data->id = basename($file, '.json');
         $data = $this->convertTypeForObjcect($data);
         $builds[] = $data;
     }
     // Sorting by started_at in descending order
     usort($builds, function ($a, $b) {
         if ($a->started_at === $b->started_at) {
             return 0;
         }
         return $a->started_at < $b->started_at ? 1 : -1;
     });
     return $builds;
 }
Exemplo n.º 16
0
 /**
  * Delete image and associated thumbnail
  *
  * @return mixed
  */
 public function getDelete()
 {
     $to_delete = Input::get('items');
     $base = Input::get("base");
     if ($base != "/") {
         if (File::isDirectory(base_path() . "/" . Config::get('sfm.dir') . $to_delete)) {
             File::delete(base_path() . "/" . Config::get('sfm.dir') . $base . "/" . $to_delete);
             return "OK";
         } else {
             if (File::exists(base_path() . "/" . Config::get('sfm.dir') . $base . "/" . $to_delete)) {
                 if (@getimagesize(base_path() . "/" . Config::get('sfm.dir') . $base . "/" . $to_delete)) {
                     File::delete(base_path() . "/" . Config::get('sfm.dir') . $base . "/.thumbs/" . $to_delete);
                 }
                 File::delete(base_path() . "/" . Config::get('sfm.dir') . $base . "/" . $to_delete);
                 return "OK";
             } else {
                 return Lang::get('filemanager::sfm.not_found', ['file' => Config::get('sfm.dir') . $base . "/" . $to_delete]);
             }
         }
     } else {
         $file_name = base_path() . "/" . Config::get('sfm.dir') . $to_delete;
         if (File::isDirectory($file_name)) {
             // make sure the directory is empty
             if (sizeof(File::files($file_name)) == 0) {
                 File::deleteDirectory($file_name);
                 return "OK";
             } else {
                 return Lang::get('filemanager::sfm.not_empty');
             }
         } else {
             if (File::exists($file_name)) {
                 if (@getimagesize($file_name)) {
                     File::delete(base_path() . "/" . Config::get('sfm.dir') . "/.thumbs/" . $to_delete);
                 }
                 File::delete($file_name);
                 return "OK";
             }
         }
     }
 }
 /**
  * Get the images to load for a selected folder
  *
  * @return mixed
  */
 public function getImages()
 {
     if (Input::has('base')) {
         $files = File::files(base_path($this->file_location . Input::get('base')));
         $all_directories = File::directories(base_path($this->file_location . Input::get('base')));
     } else {
         $files = File::files(base_path($this->file_location));
         $all_directories = File::directories(base_path($this->file_location));
     }
     $directories = [];
     foreach ($all_directories as $directory) {
         if (basename($directory) != "thumbs") {
             $directories[] = basename($directory);
         }
     }
     $file_info = [];
     foreach ($files as $file) {
         $file_name = $file;
         $file_size = number_format(Image::make($file)->filesize() / 1024, 2, ".", "");
         if ($file_size > 1000) {
             $file_size = number_format(Image::make($file)->filesize() / 1024, 2, ".", "") . " Mb";
         } else {
             $file_size = $file_size . " Kb";
         }
         $file_created = filemtime($file);
         $file_type = Image::make($file)->mime();
         $file_info[] = ['name' => $file_name, 'size' => $file_size, 'created' => $file_created, 'type' => $file_type];
     }
     if (Session::has('lfm_type') && Session::get('lfm_type') == "Images") {
         $dir_location = Config::get('lfm.images_url');
     } else {
         $dir_location = Config::get('lfm.files_url');
     }
     if (Input::get('show_list') == 1) {
         return View::make('laravel-filemanager::images-list')->with('directories', $directories)->with('base', Input::get('base'))->with('file_info', $file_info)->with('dir_location', $dir_location);
     } else {
         return View::make('laravel-filemanager::images')->with('files', $files)->with('directories', $directories)->with('base', Input::get('base'))->with('dir_location', $dir_location);
     }
 }
Exemplo n.º 18
0
 /**
  * Delete image and associated thumbnail
  *
  * @return mixed
  */
 public function getDelete()
 {
     $name_to_delete = Input::get('items');
     $file_path = parent::getPath();
     $file_to_delete = $file_path . $name_to_delete;
     $thumb_to_delete = parent::getPath('thumb') . $name_to_delete;
     if (!File::exists($file_to_delete)) {
         return $file_to_delete . ' not found!';
     }
     if (File::isDirectory($file_to_delete)) {
         if (sizeof(File::files($file_to_delete)) != 0) {
             return Lang::get('laravel-filemanager::lfm.error-delete');
         }
         File::deleteDirectory($file_to_delete);
         return 'OK';
     }
     File::delete($file_to_delete);
     if (Session::get('lfm_type') == 'Images') {
         File::delete($thumb_to_delete);
     }
     return 'OK';
 }
Exemplo n.º 19
0
 public function postRestore(Request $request)
 {
     $file = $request->file('file');
     $nome_arquivo = $file->getClientOriginalName();
     $arquivo = storage_path("backups/");
     $arquivo .= $nome_arquivo;
     if (!$file->isValid()) {
         return redirect('manutencao/restore')->withErrors($validator)->withInput();
     }
     $comando = "gunzip {$arquivo}";
     exec($comando);
     $files = File::files(storage_path('backups'));
     //$artisan = "mysql:restore 20151218161323.sql";
     //Artisan::call ($artisan);
     $host = env('DB_HOST');
     $database = env('DB_DATABASE');
     $username = env('DB_USERNAME');
     $password = env('DB_PASSWORD');
     $comando = "mysql -u {$username} -p{$password} {$database} < {$files['0']}";
     exec($comando);
     flash('Banco de dados importado com sucesso');
     return redirect('manutencao/restore');
 }
Exemplo n.º 20
0
 public function handle()
 {
     if (!($path = $this->folderExists())) {
         throw new Exception('Folder "' . $this->getFullPath() . '" does not exist');
     }
     $files = File::files($path);
     $identifiers = [];
     foreach ($files as $file) {
         $fields = Parser::parse($file);
         if (!isset($fields['identifier'])) {
             $fields['identifier'] = explode('.', basename($file))[0];
         }
         $data = Parser::process($fields);
         $post = Post::where('identifier', $data['identifier'])->first();
         if ($post) {
             $post = $this->update($post, $data);
         } else {
             $post = $this->create($data);
         }
         array_push($identifiers, $post->identifier);
         Parser::handle($fields, $post);
     }
     $this->delete($identifiers);
 }
Exemplo n.º 21
0
 public function getFiles($img = true)
 {
     if (Input::has('base') && strpos(Input::has('base'), '..') === false) {
         $files = File::files(base_path(Config::get('sfm.dir') . Input::get('base')));
         $all_directories = File::directories(base_path(Config::get('sfm.dir') . Input::get('base')));
     } else {
         $files = File::files(base_path(Config::get('sfm.dir')));
         $all_directories = File::directories(base_path(Config::get('sfm.dir')));
     }
     $filter_images = Input::get('filter') == 'images';
     $directories = [];
     foreach ($all_directories as $directory) {
         if (basename($directory) != ".thumbs") {
             $directories[] = basename($directory);
         }
     }
     $file_info = [];
     $finfo = new \finfo(FILEINFO_MIME);
     foreach ($files as $file) {
         $file_name = $file;
         $ext = strtolower(pathinfo($file, PATHINFO_EXTENSION));
         $is_image = in_array($ext, ['jpeg', 'jpg', 'png', 'gif']);
         if ($filter_images && !$is_image) {
             continue;
         }
         $file_created = filemtime($file);
         $file_type = explode(';', $finfo->file($file))[0];
         $file_info[] = ['basename' => basename($file_name), 'name' => $file_name, 'size' => $this->formatSize(filesize($file)), 'created' => $file_created, 'type' => $file_type, 'ext' => $ext, 'icon' => Icons::getIcon($ext), 'image' => $is_image];
     }
     $dir_location = Config::get('sfm.url');
     if (Input::get('show_list') == 1) {
         return View::make('filemanager::images-list')->with('directories', $directories)->with('base', Input::get('base'))->with('file_info', $file_info)->with('dir_location', $dir_location);
     } else {
         return View::make('filemanager::images')->with('files', $file_info)->with('directories', $directories)->with('base', Input::get('base'))->with('dir_location', $dir_location);
     }
 }
 public function generate($namespace, $base, $table)
 {
     if (!File::isDirectory(database_path('migrations') . '/' . $namespace . '/' . $base)) {
         if (!File::isDirectory(database_path('migrations') . '/' . $namespace)) {
             if (!File::makeDirectory(database_path('migrations') . '/' . $namespace)) {
                 return ['success' => false, 'error' => 'Cannot create ' . database_path('migrations') . '/' . $namespace . ' directory'];
             }
         }
         if (!File::makeDirectory(database_path('migrations') . '/' . $namespace . '/' . $base)) {
             return ['success' => false, 'error' => 'Cannot create ' . database_path('migrations') . '/' . $namespace . '/' . $base . ' directory'];
         }
     }
     $nameMigration = 'create_' . $table . '_table_' . time();
     $migration = Artisan::call('make:migration', ['name' => $nameMigration, '--create' => $table, '--table' => $table, '--path' => 'database/migrations/' . $namespace . '/' . $base]);
     $files = File::files(database_path('migrations') . '/' . $namespace . '/' . $base);
     $fileMigration = end($files);
     $find = '$table->increments(\'id\');';
     $find .= "\n";
     $replace = $find;
     $replace .= '            $table->string(\'name\');';
     $replace .= "\n";
     File::put($fileMigration, str_replace($find, $replace, file_get_contents($fileMigration)));
     return ['success' => true, 'message' => 'Migration created in: ' . $fileMigration];
 }
Exemplo n.º 23
0
 /**
  * Get list of all files in the views folder
  * @return mixed
  */
 public function viewsFilesList($dir_path)
 {
     $dir_files = File::files($dir_path);
     $files = [];
     foreach ($dir_files as $file) {
         $path = basename($file);
         $name = strstr(basename($file), '.', true);
         $files[$name] = $path;
     }
     return $files;
 }
Exemplo n.º 24
0
 public function removeFile()
 {
     $filename = Request::get('filename');
     $destinationPath = 'uploads/';
     File::delete($destinationPath . $filename);
     $images = File::files('uploads');
     return $images;
 }
Exemplo n.º 25
0
 /**
  * List templates files from directory.
  *
  * @return array
  */
 public function templates()
 {
     try {
         $directory = $this->getTemplateDir();
         $files = File::files($directory);
     } catch (Exception $e) {
         $files = File::files(base_path('vendor/typicms/pages/src/resources/views/public'));
     }
     $templates = [];
     foreach ($files as $file) {
         $filename = File::name($file);
         $name = str_replace('.blade', '', $filename);
         if ($name[0] != '_' && $name != 'master') {
             $templates[$name] = ucfirst($name);
         }
     }
     return ['' => ''] + $templates;
 }
Exemplo n.º 26
0
 /**
  * Send all the raw data - generated by the cron job - as a zip
  * @return void
  */
 private function sendAllInZip()
 {
     $root = base_path() . '/resources/measurements/';
     $dir = File::get($root . 'finished.txt');
     $files = File::files($root . 'session ' . $dir . '/');
     $zip = new ZipStream(Carbon::today()->toDateString() . '.zip');
     foreach ($files as $file) {
         $zip->addFileFromPath(basename($file), $file);
     }
     $zip->finish();
 }
Exemplo n.º 27
0
 /**
  * @return Collection
  *
  * get all custom partials as an Eloquent Collection
  */
 public static function allCustomPartials()
 {
     $partials = new Collection();
     $files = File::files(static::CUSTOM_PATH);
     foreach ($files as $file) {
         $partial = new Partial();
         $partial->name = static::nameFromFilename($file);
         $partial->content = file_get_contents($file);
         $partials->add($partial);
     }
     return $partials;
 }
Exemplo n.º 28
0
 /**
  * @param null $layoutDirectory
  *
  * @return array
  */
 public function parsePartialsFromFiles()
 {
     $layoutDirectory = $this->partialsDirectory;
     $partials = File::files($layoutDirectory);
     $records = $this->parser->parsePartials($partials);
     return $records;
 }
Exemplo n.º 29
0
 private function fontellozips()
 {
     $zips = array_filter(array_map('basename', File::files($this->download_path)), function ($filename) {
         return substr($filename, 0, 8) === 'fontello' && substr($filename, -4) === '.zip';
     });
     return $zips;
 }
Exemplo n.º 30
0
 /**
  * @param $id
  * @return $this
  */
 public function edit($id)
 {
     $news = News::find($id);
     $page_name = "Editar notícia";
     return view('dashboard.news.edit')->with('page_name', $page_name)->with('edit_news', $news)->with('images', File::files('img/news/' . $news->id));
 }