files() public static method

Get an array of all files in a directory.
public static files ( string $directory ) : array
$directory string
return array
Example #1
1
 public function documentos()
 {
     $files = File::files(public_path() . "/docs");
     if (Input::hasFile('file')) {
         $validator = Validator::make(Input::all(), array('file' => 'mimes:jpeg,bmp,png,doc,docx,xls,xlsx,pdf,ppt,pptx,txt|max:10240'));
         if ($validator->fails()) {
             return Redirect::to('admin/Documentos')->withFiles($files)->withErrors($validator)->withActivo('documentos');
         }
         Input::file('file')->move(public_path() . "/docs/", quitar_tildes(Input::file('file')->getClientOriginalName()));
         $files = File::files(public_path() . "/docs");
     }
     if (Input::has('path')) {
         if (Event::fire('eliminarArchivo', public_path() . "/docs/" . Input::get('path'))) {
             return "Documento Eliminado Correctamente";
         } else {
             return "No Se Pudo Eliminar El Documento";
         }
     }
     $documentos = Documento::all();
     return View::make('admin.documentos')->withFiles($files)->withDocumentos($documentos)->withActivo('documentos');
 }
Example #2
0
function getStoreBanner($store_name)
{
    $dir = 'assets/img/store/' . $store_name . '/banner';
    if (!file_exists($dir)) {
        mkdir($dir, 0777, true);
    }
    $listFiles = [];
    $files = \File::files($dir);
    foreach ($files as $path) {
        $listFiles[] = pathinfo($path);
    }
    $count = 0;
    foreach ($listFiles as $prodpath) {
        if ($count == 0) {
            $dirname = $prodpath['dirname'];
            $basename = $prodpath['basename'];
        }
        $count++;
    }
    if ($count > 0) {
        return $dirname . '/' . $basename;
    } else {
        return 'assets/img/nobanner.png';
    }
}
Example #3
0
 /**
  * 文件上传处理
  *
  * @param string $name
  *
  * @return bool
  */
 protected static function deal($name = 'file')
 {
     // 判断文件是否上传
     if (!isset($_FILES[$name])) {
         self::$error = '上传文件不能为空!';
         return false;
     }
     // 获取上传文件相关信息
     self::$files = $_FILES[$name];
     // 判断文件上传是否成功
     if ($msg = self::getFailed()) {
         self::$error = $msg;
         return false;
     }
     // 判断上传文件类型是否合法
     if (!self::isAllowType()) {
         self::$error = '上传文件类型不允许!';
         return false;
     }
     // 判断上传文件大小是否合法
     if (!self::isAllowSize()) {
         self::$error = '上传文件大小不允许!';
         return false;
     }
     return true;
 }
Example #4
0
 /** @test */
 public function it_does_not_cause_change_to_sql_directory()
 {
     $pre_contents = \File::files(config('csvimport.sql_directory'));
     $this->importer->import();
     $post_contents = \File::files(config('csvimport.sql_directory'));
     $this->assertEquals($pre_contents, $post_contents);
 }
Example #5
0
 public function send(JustifFormRequest $request)
 {
     \Mail::send('emails.justificatif', array('username' => $request->get('username'), 'email' => $request->get('email'), 'justif' => $request->get('justificatif')), function ($message) use($request) {
         $email = $request->email;
         $username = $request->username;
         $justif = $request->file('justificatif');
         if ($justif->isValid()) {
             $path = config('images.inscription');
             $files = \File::files($path);
             $newfile = $path . '/' . $username;
             foreach ($files as $file) {
                 $fileWithoutExtension = substr($file, 0, -4);
                 if ($fileWithoutExtension === $newfile) {
                     \File::Delete($fileWithoutExtension . '.png');
                     \File::Delete($fileWithoutExtension . '.pdf');
                     \File::Delete($fileWithoutExtension . '.jpg');
                 }
             }
             $extension = $justif->getClientOriginalExtension();
             $name = $username . '.' . $extension;
             $justif->move($path, $name);
         }
         $file = $path . '/' . $name;
         $message->attach($file);
         $message->from($request->email);
         $message->to('*****@*****.**', 'Equipe Roadweb')->subject('envoi de justificatif');
         $message->setReplyTo($email);
     });
     return \Redirect::route('compte')->with('message', 'Votre justificatif a bien été envoyé ! Vous serez informé de la validation de vos droits dans les 24 à 48h.');
 }
 /**
  *
  */
 private function bindRepositories()
 {
     // Load config parameters needed.
     $repositoriesBasePath = config('lararepo.path');
     $baseNamespace = rtrim(config('lararepo.namespace'), '\\') . '\\';
     $implementation = config('lararepo.implementation');
     $skipRepositories = config('lararepo.skip');
     $allRepos = \File::files($repositoriesBasePath);
     foreach ($allRepos as $repo) {
         $interface = basename($repo);
         if (in_array($interface, $skipRepositories)) {
             continue;
         } else {
             $interfaceName = str_replace('.php', '', $interface);
             $commonName = str_replace('Interface', '', $interfaceName);
             $interfaceFullClassName = $baseNamespace . $interfaceName;
             $implementationFullClassName = $baseNamespace . $implementation . '\\' . $commonName;
             if (class_exists($implementationFullClassName)) {
                 // Bind the class.
                 $this->app->bind($interfaceFullClassName, function ($app) use($implementationFullClassName) {
                     return $app->make($implementationFullClassName);
                 });
             }
         }
     }
 }
Example #7
0
 protected function copyFiles()
 {
     $files = \File::files(base_path());
     foreach ($files as $file) {
         $path = str_replace(base_path(), '', $file);
         \File::copy($file, base_path() . '/backup/' . $this->timestamp . '/' . $path);
     }
 }
Example #8
0
 /**
  * Get the model names from their filename.
  *
  * @return array
  */
 protected function getModels()
 {
     $files = File::files(base_path() . '/app/models');
     foreach ($files as $file) {
         $models[] = pathinfo($file, PATHINFO_FILENAME);
     }
     return $models;
 }
Example #9
0
 public function getAvailableTemplates()
 {
     $template = \CMS::getTemplatePath();
     $files = \File::files('../app/views/templates/' . $template . '/pages');
     foreach ($files as $index => $file) {
         $files[$index] = str_replace('../app/views/templates/' . $template . '/', '', $file);
     }
     return $files;
 }
 /**
  * @return array
  */
 public function getImages($folder)
 {
     $base = config('gallery-settings.home_dir');
     $path = trim($folder, '/');
     $pathname = $base . $path;
     $pictures = array_chunk(\File::files($pathname), 2);
     foreach ($pictures as $chunk) {
         $this->dispatch(new GenerateThumbnails($chunk));
     }
 }
 private function seedOperators()
 {
     $sql_files = File::files($this->operatorsPath);
     $index = 0;
     foreach ($sql_files as $sql) {
         $current[$index] = File::get($sql);
         Queue::push('OperaterInsertQueue', $current[$index]);
         unset($current[$index]);
         $index++;
     }
 }
Example #12
0
 private function init()
 {
     $this->classes = [];
     $dir = config('cms.path.data');
     foreach (\File::files($dir) as $file) {
         $basename = basename($file, '.php');
         $className = '\\App\\CMS\\Data\\' . $basename;
         $class = new $className();
         $this->classes[$class->getAccessor()] = $class;
     }
 }
Example #13
0
 public function getKeys($path, $langs)
 {
     $keys = [];
     foreach ($langs as $lang) {
         foreach (File::files($path . '/' . trim($lang, '/')) as $file) {
             $translation = (require $file);
             $keys = array_merge($keys, $this->extractKeys($translation, str_replace('.php', '', basename($file))));
         }
     }
     return array_unique($keys);
 }
Example #14
0
 /**
  * Check last backup time
  *
  * Checks the modification time of files in authenticated user archive folder and if one of them is less than
  * 5 minutes ago.
  *
  * @param User $user
  *
  * @return bool  False if last backup was made less than 5 minutes ago, true otherwise
  */
 public static function checkLastBackupTime(User $user)
 {
     $zipFiles = File::files(storage_path() . '/backups/' . $user->getId() . '/zip/');
     foreach ($zipFiles as $zipFile) {
         $timeOfBackup = File::lastModified($zipFile);
         if ($timeOfBackup > strtotime('-5 minutes')) {
             return false;
         }
     }
     return true;
 }
Example #15
0
 public function testConstruction()
 {
     $kirby = $this->kirbyInstance();
     $site = $this->siteInstance($kirby);
     $page = new Page($site, '1-a');
     $files = new Files($page);
     $file = new File($files, 'test.js');
     $this->assertInstanceOf('Kirby', $file->kirby());
     $this->assertEquals($kirby, $file->kirby());
     $this->assertInstanceOf('Site', $file->site());
     $this->assertEquals($site, $file->site());
     $this->assertInstanceOf('Page', $file->page());
     $this->assertEquals($page, $file->page());
     $this->assertInstanceOf('Files', $file->files());
     $this->assertEquals($files, $file->files());
     $this->assertInstanceOf('Media', $file);
     $this->assertEquals($page->root() . DS . 'test.js', $file->root());
     $this->assertEquals($page->contentUrl() . '/test.js', $file->url());
     $this->assertEquals($file->root(), (string) $file);
 }
Example #16
0
 public function browseImage(Request $request)
 {
     DB::table('test')->insert(['msg' => 'work fine']);
     // $send = SendMail::all();
     $test = $_GET['CKEditorFuncNum'];
     $images = [];
     $files = \File::files(public_path() . '/uploads/about');
     foreach ($files as $file) {
         $images[] = pathinfo($file);
     }
     return view('page.home', ['files' => $images, 'test' => $test]);
 }
Example #17
0
 public function getTaskLogs($task_id, $limit = 100)
 {
     $ret = [];
     $files = \File::files(Config::get('overseer::external_log_folder') . '/');
     rsort($files);
     $files = array_slice($files, 0, $limit);
     foreach ($files as $k => $f) {
         if (!($dat = $this->parseLogFileName($f, $task_id))) {
             continue;
         }
         $ret[] = $dat;
     }
     return $ret;
 }
 /**
  * Display a listing of documentos
  *
  * @return Response
  */
 public function index()
 {
     $documentos = Documento::select("id", "titulo", "morosos", "activo")->activo()->get();
     $list = [];
     foreach (File::files(public_path() . "/docs") as $documento) {
         $list[] = array("titulo" => substr(strrchr($documento, '/'), 1), "url" => asset('docs/' . substr(strrchr($documento, '/'), 1)), "mime" => substr(strrchr($documento, '.'), 1));
     }
     $docs = array_where($list, function ($key, $documento) {
         return $documento["titulo"] != 'index.html';
     });
     $data["documentos_dinamicos"] = $documentos;
     $data["documentos_clasicos"] = array_values($docs);
     return Response::json($data, 200);
 }
Example #19
0
 /**
  * Varre o diretorio em busca de arquivos de traducao
  * 
  * @return array
  */
 public function _getTransFiles($langpack)
 {
     $arrExclude = array('auth', 'pagination', 'passwords', 'validation');
     // Pega todos os arquivos do diretorio
     $configs = \File::files(mkny_lang_path($langpack . '/'));
     // Monta o array
     $arrConfig = array();
     foreach ($configs as $config) {
         $c_data = substr(class_basename($config), 0, -4);
         if (in_array($c_data, $arrExclude)) {
             continue;
         }
         $arrConfig[] = $c_data;
     }
     return $arrConfig;
 }
Example #20
0
 protected function migrations()
 {
     $this->info('Creating migration!');
     $files = \File::files($this->laravel['path.database'] . '/migrations');
     foreach ($files as $file) {
         if (ends_with((string) $file, '_cms_core_tables.php')) {
             throw new \Exception("You could have a similar migration on {$file}!");
         }
     }
     $path = $this->laravel['path.database'] . '/migrations/' . date('Y_m_d_His') . '_cms_core_tables.php';
     $stub = __DIR__ . '/../stubs/core.stub';
     if (!\File::copy($stub, $path)) {
         throw new \Exception('We could not create the migration!');
     }
     $this->info('Run migration!');
     Artisan::call('migrate');
 }
Example #21
0
 protected function toolBackup()
 {
     if (!file_exists(storage_path("backup"))) {
         mkdir(storage_path("backup"));
     }
     exec('mysqldump  -R --triggers --quick --single-transaction -u ' . \Config::get('database.connections.mysql.username') . ' -P ' . \Config::get('database.connections.mysql.port') . ' -h ' . \Config::get('database.connections.mysql.host') . ' -p' . \Config::get('database.connections.mysql.password') . ' ' . \Config::get('database.connections.mysql.database') . ' | gzip -c > ' . storage_path('backup') . '/' . date('YmdHi') . '.dump.gz');
     $keep = intval(\Config::get('laraext.db.backup_keep'));
     if ($keep <= 0) {
         return;
     }
     $old = \File::files(storage_path("backup"));
     rsort($old);
     foreach ($old as $num => $file) {
         if ($num >= \Config::get('laraext.db.backup_keep')) {
             unlink($file);
         }
     }
 }
Example #22
0
 /**
  * 动作:快速安装应用程序
  * @return Response
  */
 public function postCreate()
 {
     $classArray = array();
     foreach (File::files(__DIR__ . '/../database') as $key => $value) {
         $classArray[] = App::make('Assists_database_' . str_replace('.php', '', basename($value)));
     }
     switch (Input::get('type')) {
         case 'base':
             foreach ($classArray as $key => $value) {
                 $value->refresh();
             }
             break;
         case 'all':
             foreach ($classArray as $key => $value) {
                 $value->refresh();
                 $value->seedDemo();
             }
             break;
     }
     return Redirect::back()->withErrors(array('succ' => '安装完成。'));
 }
Example #23
0
 public function folder($action = 'load')
 {
     $path = $_POST['path'];
     if (isset($_POST['folder'])) {
         $tree = $_POST['folder'];
     } else {
         $tree = 0;
     }
     $this->root = dirname(ROOT) . DS;
     $arr = array();
     if ($action == 'load') {
         include_once ROOT . DS . 'includes' . DS . 'file.php';
         $file = new File();
         $folders = $file->folders($this->root . $path);
         $arr['folder'] = $folders;
         if ($tree != 1) {
             $files = $file->files($this->root . $path);
             $arr['files'] = $files;
         }
     }
     echo json_encode($arr);
 }
 /**
  * Execute the console command.
  *
  * @return mixed
  */
 public function fire()
 {
     $namespace = "Tablas";
     //borrramos generaciones previas
     File::deleteDirectory(app_path('contraladores_generados'));
     //creamos el directorio en app..
     File::makeDirectory(app_path('contraladores_generados'), 777);
     $this->info("Buscando modelos");
     $models = File::files(app_path('models'));
     foreach ($models as $model) {
         if (File::isFile($model)) {
             $baseText = File::get(app_path('controllers/templates/Template.txt'));
             $controllerName = str_plural_spanish(str_replace('.php', '', basename($model))) . 'Controller';
             $this->info("Generando controller: " . $controllerName);
             //replace class name..
             $baseText = str_replace('@class_name@', $controllerName, $baseText);
             //replace namespace..
             $baseText = str_replace('@namespace@', $namespace, $baseText);
             File::put(app_path('contraladores_generados/' . $controllerName . '.php'), $baseText);
         }
     }
 }
Example #25
0
 /**
  * Execute the console command.
  *
  * @return mixed
  */
 public function fire()
 {
     //borrramos generaciones previas
     File::deleteDirectory(app_path('vistas_generadas'));
     //creamos el directorio en app..
     File::makeDirectory(app_path('vistas_generadas'), 777);
     $this->info("Buscando modelos");
     $models = File::files(app_path('models'));
     foreach ($models as $model) {
         if (File::isFile($model)) {
             $modelName = str_replace('.php', '', basename($model));
             if ($modelName != 'BaseModel') {
                 $modelInstance = new $modelName();
                 $collectionName = lcfirst(str_plural_spanish($modelName));
                 $baseText = File::get(app_path('controllers/templates/View.txt'));
                 $baseText = str_replace('@model_name@', $modelName, $baseText);
                 $baseText = str_replace('@pretty_name@', $modelInstance->getPrettyName(), $baseText);
                 $baseText = str_replace('@collection_name@', $collectionName, $baseText);
                 $basePath = app_path('vistas_generadas');
                 $this->info("Generando vista: " . $collectionName);
                 File::put($basePath . '/' . $collectionName . '.blade.php', $baseText);
                 $baseText = File::get(app_path('controllers/templates/Form.txt'));
                 $baseText = str_replace('@var_name@', lcfirst($modelName), $baseText);
                 $baseText = str_replace('@pretty_name@', $modelInstance->getPrettyName(), $baseText);
                 $baseText = str_replace('@collection_name@', $collectionName, $baseText);
                 $fieldsStr = "";
                 $fields = $modelInstance->getFillable();
                 foreach ($fields as $key) {
                     $fieldsStr .= "{{Form::btInput(\$" . lcfirst($modelName) . ", '" . $key . "', 6)}}" . PHP_EOL;
                 }
                 $baseText = str_replace('@fields@', $fieldsStr, $baseText);
                 $basePath = app_path('vistas_generadas');
                 $this->info("Generando formulario: " . $collectionName);
                 File::put($basePath . '/' . $collectionName . 'form.blade.php', $baseText);
             }
         }
     }
 }
 public function postImages()
 {
     $id = Input::get('product_id');
     $skuAsset = sprintf("%06s", $id);
     $sku = 'INDE' . $skuAsset;
     $image_directory = 'public/images/products/' . $sku;
     if (!is_dir($image_directory)) {
         mkdir($image_directory);
         $image = Input::file('file');
         $original = $image->getClientOriginalName();
         $originalArray = explode('.', $original);
         Image::make($image->getRealPath())->resize(320, 320)->save($image_directory . '/' . $id . '-' . '1.' . $originalArray[1]);
         return "image uploaded successfully";
     } else {
         $image = Input::file('file');
     }
     $original = $image->getClientOriginalName();
     $originalArray = explode('.', $original);
     $files = File::files($image_directory);
     $count = sizeof($files);
     $count++;
     Image::make($image->getRealPath())->save($image_directory . '/' . $id . '-' . $count . '.jpg', 100);
     return "image uploaded successfully";
 }
 $sectionValues = ['name_of_section' => Input::get('name_of_section'), 'sub_section' => Input::get('sub_section'), 'shortname' => Input::get('shortname')];
 $rule = array('name_of_section' => 'required', 'shortname' => 'required');
 $validator = Validator::make($sectionValues, $rule);
 if ($validator->fails()) {
     return Redirect::to('/editSection?id=' . $sections->id)->withErrors($validator->messages());
 } else {
     if (Input::get('sub_section') != "CWC References" && Input::get('sub_section') != "CWC Calculators") {
         if (File::exists($sections->section_url)) {
             File::makeDirectory($path, $mode = 0777, true, true);
             if ($pages->count() > 1) {
                 /* foreach ($pages as $p) {
                      if(File::exists($p->page_url)){
                         File::copy($p->page_url, $path.'\\'.$p->page_shortname.'.xml');
                      } 
                    }*/
                 $files = File::files($sections->section_url);
                 $fileDetails = [];
                 foreach ($files as $f) {
                     if (File::exists($f)) {
                         $fileDetails = pathinfo($f);
                         File::copy($f, $path . '\\' . $fileDetails['basename']);
                     }
                 }
             }
             File::deleteDirectory($sections->section_url);
             if (File::exists($Uploadpath . ".zip")) {
                 File::delete($Uploadpath . ".zip");
             }
         }
     }
     if ($pages->count() > 1) {
Example #28
0
 public static function getViewFolderTree($dir, $ret = array())
 {
     $tmp = new \stdClass();
     $dirArr = explode('/', $dir);
     $tmp->directory = end($dirArr);
     $tmp->path = $dir;
     $tmp->files = \File::files($dir);
     foreach ($tmp->files as $fk => $file) {
         $filArr = explode('/', $file);
         $tmp->files[$fk] = end($filArr);
     }
     $tmp->folders = \File::directories($dir);
     foreach ($tmp->folders as $fk => $folder) {
         $tmp->folders[$fk] = static::getViewFolderTree($folder, $ret);
     }
     $ret = $tmp;
     return $ret;
 }
 public function boot()
 {
     if (config('cudl.enable')) {
         $files = \File::files(config('cudl.model_path'));
         foreach ($files as $path) {
             include_once $path;
         }
         $namespace = config('cudl.model_namespace');
         $models = collect(get_declared_classes())->map(function ($className) use($namespace) {
             return starts_with($className, $namespace) && $className == $namespace . '\\' . class_basename($className) ? $className : null;
         })->reject(function ($className) {
             return is_null($className);
         })->toArray();
         foreach ($models as $modelName) {
             $model = new $modelName();
             $model::created(function ($model) {
                 $action = 'create';
                 $tableName = $model->getTable();
                 $id = $model->getKey();
                 $fields = $model->getAttributes();
                 $createdAt = Carbon::now();
                 $createdId = \Auth::check() ? \Auth::User()->getKey() : 0;
                 foreach ($fields as $fieldName => $fieldValue) {
                     if (is_array($fieldValue)) {
                         $fieldValue = json_encode($fieldValue);
                     }
                     $cudl = new CudLog();
                     $cudl->action = $action;
                     $cudl->table_name = $tableName;
                     $cudl->foreign_key = $id;
                     $cudl->field_name = $fieldName;
                     $cudl->field_after = $fieldValue;
                     $cudl->created_at = $createdAt;
                     $cudl->created_id = $createdId;
                     $cudl->save();
                 }
             });
             $model::updating(function ($model) {
                 if (method_exists($model, 'getDifferences')) {
                     $action = 'update';
                     $tableName = $model->getTable();
                     $fields = $model->getDifferences();
                     $id = $model->getKey();
                     $createdAt = Carbon::now();
                     $createdId = \Auth::check() ? \Auth::User()->getKey() : 0;
                     foreach ($fields as $fieldName => $field) {
                         $cudl = new CudLog();
                         $cudl->action = $action;
                         $cudl->table_name = $tableName;
                         $cudl->foreign_key = $id;
                         $cudl->field_name = $fieldName;
                         $cudl->field_before = is_array($model->getOriginal($fieldName)) ? json_encode($model->getOriginal($fieldName)) : $model->getOriginal($fieldName);
                         $cudl->field_after = is_array($model->getAttribute($fieldName)) ? json_encode($model->getAttribute($fieldName)) : $model->getAttribute($fieldName);
                         $cudl->created_at = $createdAt;
                         $cudl->created_id = $createdId;
                         $cudl->save();
                     }
                 }
             });
             $model::deleting(function ($model) {
                 $action = 'delete';
                 $tableName = $model->getTable();
                 $id = $model->getKey();
                 $createdAt = Carbon::now();
                 $createdId = \Auth::check() ? \Auth::User()->getKey() : 0;
                 $cudl = new CudLog();
                 $cudl->action = $action;
                 $cudl->table_name = $tableName;
                 $cudl->foreign_key = $id;
                 $cudl->created_at = $createdAt;
                 $cudl->created_id = $createdId;
                 $cudl->save();
             });
         }
     }
 }
Example #30
0
 public function browseImage(Request $request)
 {
     $test = $_GET['CKEditorFuncNum'];
     $images = [];
     $files = \File::files(public_path() . '/upload/article');
     foreach ($files as $file) {
         $images[] = pathinfo($file);
     }
     return view('admin.article.image', ['files' => $images, 'test' => $test]);
 }