Exemplo n.º 1
0
 /**
  * Delete the folder with the given path
  *
  * @param string $folder
  *
  * @return boolean
  * @throws DirectoryDoesNotExists
  */
 public function folderDelete($folder)
 {
     if (!File::isDirectory($this->getPath($folder))) {
         throw new DirectoryDoesNotExists();
     }
     return File::deleteDirectory($this->getPath($folder));
 }
Exemplo n.º 2
0
 public function getSubmissionVerdict($srcContent, $srcExt)
 {
     assert($srcExt == "cpp" || $srcExt == "java" || $srcExt == "py", "'Source code language must be C++, Java or Python'");
     $judgingBaseFolder = '../judging/';
     $submissionFolderName = uniqid();
     $submissionFolder = "{$judgingBaseFolder}{$submissionFolderName}/";
     // Write the source code file
     $srcFpath = "{$submissionFolder}main.{$srcExt}";
     File::makeDirectory($submissionFolder);
     File::put($srcFpath, $srcContent);
     // Create the required test case files
     $caseNo = 1;
     $testcases = $this->testcases()->get();
     foreach ($testcases as $tc) {
         $inFname = "test{$caseNo}.in";
         $outFname = "test{$caseNo}.ans";
         $inFpath = $submissionFolder . $inFname;
         $outFpath = $submissionFolder . $outFname;
         File::put($inFpath, $tc->input);
         File::put($outFpath, $tc->output);
         $caseNo += 1;
     }
     // Judge!
     $judgingScript = "python \"{$judgingBaseFolder}judge.py\"";
     $judgingArguments = sprintf('"%s" "%s" %d', $srcFpath, $submissionFolder, $this['time_limit']);
     $judgeCommand = "{$judgingScript} {$judgingArguments}";
     $verdict = shell_exec($judgeCommand);
     // Clean-up the submission directory
     File::deleteDirectory($submissionFolder);
     return $verdict;
 }
 /**
  * Reverse the migrations.
  *
  * @return void
  */
 public function down()
 {
     Schema::drop('pictures');
     //delete everything inside the images directory
     $path = public_path() . '/content/images/';
     File::deleteDirectory($path, true);
 }
Exemplo n.º 4
0
 /**
  * @param $id
  * @return \Illuminate\Http\RedirectResponse|\Illuminate\Routing\Redirector
  */
 public function delete($id)
 {
     $news = News::find($id);
     $deleteDir = File::deleteDirectory(base_path() . '/public/' . 'img/news/' . $news->id);
     $news->delete();
     Flash::success('Notícia deletada!');
     return redirect(route('news.index'));
 }
Exemplo n.º 5
0
 public static function deletePhotosByUser($userId)
 {
     $directory = "assets/images/_upload/fotos/" . $userId;
     File::deleteDirectory($directory);
     $finalists = Finalists::where('category', 'fotos')->get();
     foreach ($finalists as $finalist) {
         self::where('photosId', '=', $finalist->idCategory)->where('usersId', '=', $userId)->delete();
     }
     return self::where('usersId', $userId)->delete();
 }
Exemplo n.º 6
0
 public static function boot()
 {
     parent::boot();
     static::deleted(function ($project) {
         $path = public_path('files/projects/' . $project->id);
         if (File::exists($path)) {
             File::deleteDirectory($path);
         }
     });
 }
Exemplo n.º 7
0
 /**
  * Execute the console command.
  *
  * @return mixed
  */
 public function fire()
 {
     $this->info('Start housekeeping.');
     $maxBuilds = intval($this->option('max-builds'));
     $targetBuilds = $this->build->byGeneration($maxBuilds);
     foreach ($targetBuilds as $targetBuild) {
         $this->build->deleteById($targetBuild->id);
         File::deleteDirectory(public_path($targetBuild->artifact));
     }
     $this->info('Finish housekeeping.');
 }
Exemplo n.º 8
0
 public static function removeRtmpServer($key)
 {
     $channel_records_path = $_ENV['CHANNEL_RECORDS_PATH'];
     $app_conf_path = $_ENV['RTMP_APPS_CONF_PATH'];
     if (is_dir($channel_records_path . $key)) {
         File::deleteDirectory($channel_records_path . $key);
     }
     if (File::exists($app_conf_path . $key . '.conf')) {
         File::delete($app_conf_path . $key . '.conf');
     }
 }
 /**
  * Remove the specified resource from storage.
  *
  * @param CategoryRequest $request
  * @param $categoryId
  * @return \Illuminate\Http\Response
  */
 public function destroy(CategoryRequest $request, $categoryId)
 {
     $category = Category::findOrFail($categoryId);
     $children = $category->getChildren();
     foreach ($children as $child) {
         File::deleteDirectory(public_path('images/categories/' . $child->id));
     }
     File::deleteDirectory(public_path('images/categories/' . $category->id));
     $category->deleteSubtree(true);
     return $this->response->noContent();
 }
Exemplo n.º 10
0
 /**
  * Event to delete files in public/html folder
  *
  * @return void
  */
 public static function boot()
 {
     parent::boot();
     if (config('typicms.html_cache')) {
         static::saved(function ($model) {
             File::deleteDirectory(public_path() . '/html');
         });
         static::deleted(function ($model) {
             File::deleteDirectory(public_path() . '/html');
         });
     }
 }
Exemplo n.º 11
0
 /**
  * Execute the console command.
  *
  * @return void
  */
 public function fire()
 {
     switch ($this->argument('mode')) {
         case 'build':
             App::make('script-auto-compiler-l4')->build();
             break;
         case 'clear':
             File::deleteDirectory(Config::get('script-auto-compiler-l4::config.tmp'));
             break;
         default:
             break;
     }
 }
Exemplo n.º 12
0
 /**
  * Delete published assets
  *
  * @return void
  */
 public function clean()
 {
     $assetsDir = public_path() . '/' . $this->config->get('asset::public_dir');
     foreach (array_keys($this->processed) as $typeDir) {
         File::deleteDirectory($assetsDir . '/' . $typeDir);
     }
     foreach ($this->getGroupNames('styles') as $group) {
         Cache::forget('asset.styles.groups.' . $group);
     }
     foreach ($this->getGroupNames('scripts') as $group) {
         Cache::forget('asset.scripts.groups.' . $group);
     }
 }
Exemplo n.º 13
0
 /**
  * Run the database seeds.
  *
  * @return void
  */
 public function run()
 {
     DB::table('users')->delete();
     User::create(array('firstname' => 'User', 'lastname' => 'Name', 'username' => 'username1', 'email' => '*****@*****.**', 'password' => 'usernameone'));
     // create directories //
     // check to see if directory is created //
     if (File::exists(public_path() . '/../storage/uploads')) {
         File::deleteDirectory(public_path() . '/../storage/uploads');
     }
     File::makeDirectory(public_path() . '/../storage/uploads');
     File::makeDirectory(public_path() . '/../storage/uploads/username1');
     // chmod directory //
     chmod("/../storage/uploads/username1", 777);
 }
 /**
  * Perform the given conversions for the given media.
  *
  * @param \Spatie\MediaLibrary\Conversion\ConversionCollection $conversions
  * @param \Spatie\MediaLibrary\Media                           $media
  */
 public function performConversions(ConversionCollection $conversions, Media $media)
 {
     $tempDirectory = $this->createTempDirectory();
     $copiedOriginalFile = $tempDirectory . '/' . str_random(16) . '.' . $media->extension;
     app(Filesystem::class)->copyFromMediaLibrary($media, $copiedOriginalFile);
     if ($media->type == Media::TYPE_PDF) {
         $copiedOriginalFile = $this->convertToImage($copiedOriginalFile);
     }
     foreach ($conversions as $conversion) {
         $conversionResult = $this->performConversion($media, $conversion, $copiedOriginalFile);
         $renamedFile = MediaLibraryFileHelper::renameInDirectory($conversionResult, $conversion->getName() . '.' . $conversion->getResultExtension(pathinfo($copiedOriginalFile, PATHINFO_EXTENSION)));
         app(Filesystem::class)->copyToMediaLibrary($renamedFile, $media, 'conversions');
     }
     File::deleteDirectory($tempDirectory);
 }
Exemplo n.º 15
0
 public static function generateDocs()
 {
     $appDir = config('swagger-lume.paths.annotations');
     $docDir = config('swagger-lume.paths.docs');
     if (!File::exists($docDir) || is_writable($docDir)) {
         // delete all existing documentation
         if (File::exists($docDir)) {
             File::deleteDirectory($docDir);
         }
         File::makeDirectory($docDir);
         $excludeDirs = config('swagger-lume.paths.excludes');
         $swagger = \Swagger\scan($appDir, $excludeDirs);
         $filename = $docDir . '/api-docs.json';
         $swagger->saveAs($filename);
     }
 }
 /**
  * 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.º 17
0
 public function handle()
 {
     if (($table = $this->option('table')) === null) {
         $tables = $this->DBHelper->listTables();
         $table = $this->choice('Choose table:', $tables, null);
     }
     $columns = collect($this->DBHelper->listColumns($table));
     $this->transformer->setColumns($columns);
     $namespace = config('thunderclap.namespace');
     $moduleName = str_replace('_', '', title_case($table));
     $containerPath = config('thunderclap.target_dir', base_path('modules'));
     $modulePath = $containerPath . DIRECTORY_SEPARATOR . $moduleName;
     // 1. check existing module
     if (is_dir($modulePath)) {
         $overwrite = $this->confirm("Folder {$modulePath} already exist, do you want to overwrite it?");
         if ($overwrite) {
             File::deleteDirectory($modulePath);
         } else {
             return false;
         }
     }
     // 2. create modules directory
     $this->info('Creating modules directory...');
     $this->packerHelper->makeDir($containerPath);
     $this->packerHelper->makeDir($modulePath);
     // 3. copy module skeleton
     $stubs = __DIR__ . '/../../stubs';
     $this->info('Copying module skeleton into ' . $modulePath);
     File::copyDirectory($stubs, $modulePath);
     $templates = ['module-name' => str_replace('_', '-', $table), 'route-prefix' => config('thunderclap.routes.prefix')];
     // 4. rename file and replace common string
     $search = [':Namespace:', ':module_name:', ':module-name:', ':module name:', ':Module Name:', ':moduleName:', ':ModuleName:', ':FILLABLE:', ':TRANSFORMER_FIELDS:', ':VALIDATION_RULES:', ':LANG_FIELDS:', ':TABLE_HEADERS:', ':TABLE_FIELDS:', ':DETAIL_FIELDS:', ':FORM_CREATE_FIELDS:', ':FORM_EDIT_FIELDS:', ':VIEW_EXTENDS:', ':route-prefix:', ':route-middleware:', ':route-url-prefix:'];
     $replace = [$namespace, snake_case($table), $templates['module-name'], str_replace('_', ' ', strtolower($table)), ucwords(str_replace('_', ' ', $table)), str_replace('_', '', camel_case($table)), str_replace('_', '', title_case($table)), $this->transformer->toFillableFields(), $this->transformer->toTransformerFields(), $this->transformer->toValidationRules(), $this->transformer->toLangFields(), $this->transformer->toTableHeaders(), $this->transformer->toTableFields(), $this->transformer->toDetailFields(), $this->transformer->toFormCreateFields(), $this->transformer->toFormUpdateFields(), config('thunderclap.view.extends'), $templates['route-prefix'], $this->toArrayElement(config('thunderclap.routes.middleware')), $this->getRouteUrlPrefix($templates['route-prefix'], $templates['module-name'])];
     foreach (File::allFiles($modulePath) as $file) {
         if (is_file($file)) {
             $newFile = $deleteOriginal = false;
             if (Str::endsWith($file, '.stub')) {
                 $newFile = Str::substr($file, 0, -5);
                 $deleteOriginal = true;
             }
             $this->packerHelper->replaceAndSave($file, $search, $replace, $newFile, $deleteOriginal);
         }
     }
     $this->warn('Add following service provider to config/app.php ====> ' . $namespace . '\\' . ucwords(str_replace('_', ' ', $table)) . '\\ServiceProvider::class,');
 }
Exemplo n.º 18
0
 /**
  * Perform the given conversions for the given media.
  *
  * @param \Spatie\MediaLibrary\Conversion\ConversionCollection $conversions
  * @param \Spatie\MediaLibrary\Media $media
  */
 public function performConversions(ConversionCollection $conversions, Media $media)
 {
     $imageGenerator = $this->determineImageGenerator($media);
     if (!$imageGenerator) {
         return;
     }
     $tempDirectory = $this->createTempDirectory();
     $copiedOriginalFile = $tempDirectory . '/' . str_random(16) . '.' . $media->extension;
     app(Filesystem::class)->copyFromMediaLibrary($media, $copiedOriginalFile);
     foreach ($conversions as $conversion) {
         $copiedOriginalFile = $imageGenerator->convert($copiedOriginalFile, $conversion);
         $conversionResult = $this->performConversion($media, $conversion, $copiedOriginalFile);
         $renamedFile = MediaLibraryFileHelper::renameInDirectory($conversionResult, $conversion->getName() . '.' . $conversion->getResultExtension(pathinfo($copiedOriginalFile, PATHINFO_EXTENSION)));
         app(Filesystem::class)->copyToMediaLibrary($renamedFile, $media, true);
         event(new ConversionHasBeenCompleted($media, $conversion));
     }
     File::deleteDirectory($tempDirectory);
 }
Exemplo n.º 19
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.º 20
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";
             }
         }
     }
 }
Exemplo n.º 21
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.º 22
0
 public function tearDown()
 {
     File::deleteDirectory($this->dest);
 }
 /**
  * @param Request $request
  */
 private function checkFiles(Request $request)
 {
     $fileNameWithoutExt = str_random(32);
     $fileName = $fileNameWithoutExt . '.' . $request->file('file')->getClientOriginalExtension();
     $directory = public_path() . '/resources/uploads/';
     $request->file('file')->move($directory, $fileName);
     $zipper = new Zipper();
     File::makeDirectory($directory . $fileNameWithoutExt);
     $zipper->make($directory . $fileName)->extractTo($directory . $fileNameWithoutExt);
     $createdProductCategories = [];
     $dataTransferResultErrors = ['productCategories' => array(), 'productLines' => array(), 'products' => array(), 'otherErrors' => array()];
     $dataTransferResultWarnings = ['productCategories' => array(), 'productLines' => array(), 'products' => array()];
     $findResults = File::glob($directory . $fileNameWithoutExt . '/img/');
     if (count($findResults) == 0) {
         array_push($dataTransferResultErrors['otherErrors'], 'отсутствует папка с изображениями img');
     }
     $findResults = File::glob($directory . $fileNameWithoutExt . '/products.xlsx');
     if (count($findResults) == 0) {
         array_push($dataTransferResultErrors['otherErrors'], 'отсутствует файл Excel версии 2007 и выше. Убедитесь, что структура архива соотвествует образцу. Обратите внимание, что папка img и файл Excel находятся в корне архива, а не в папке, которая находится в корне архива');
     }
     if (count($dataTransferResultErrors['otherErrors'])) {
         Session::put('dataTransferResult.Errors', $dataTransferResultErrors);
         Session::put('dataTransferResult.Warnings', $dataTransferResultWarnings);
         File::delete($directory . $fileName);
         File::deleteDirectory($directory . $fileNameWithoutExt);
         return;
     }
     Excel::selectSheets('Категории')->load($directory . $fileNameWithoutExt . '/products.xlsx', function ($reader) use($directory, $fileNameWithoutExt, $createdProductCategories, $dataTransferResultErrors, $dataTransferResultWarnings, $fileName, $request) {
         $productCategories = [];
         foreach ($reader->toArray() as $row) {
             if ($row['nomer'] == null) {
                 continue;
             }
             array_push($productCategories, $row['nomer']);
             $imagePattern = '/img/product-category-' . $row['nomer'];
             $findResults = File::glob($directory . $fileNameWithoutExt . $imagePattern . '*');
             if (count($findResults) == 0) {
                 $dataTransferResultErrors['productCategories'][$row['nomer']] = 'У категории с номером ' . $row['nomer'] . ' отсутствует изображение: ' . $imagePattern;
             }
             if ($row['nomer'] <= ProductCategory::max('id')) {
                 $dataTransferResultErrors['productCategories'][$row['nomer'] . ' дублирование данных (категория)'] = 'Категория с номером ' . $row['nomer'] . ' возможно уже присутствует в базe. Проверьте условие минимальности номера категории';
             }
         }
         Excel::selectSheets('Линейки продукции')->load($directory . $fileNameWithoutExt . '/products.xlsx', function ($reader) use($directory, $fileNameWithoutExt, $createdProductCategories, $dataTransferResultErrors, $dataTransferResultWarnings, $fileName, $productCategories, $request) {
             $productLines = [];
             foreach ($reader->toArray() as $row) {
                 if ($row['nomer'] == null) {
                     continue;
                 }
                 array_push($productLines, $row['nomer']);
                 if (!in_array($row['kategoriya'], $productCategories) && ProductCategory::find($row['kategoriya']) == null) {
                     $dataTransferResultErrors['productLines'][$row['nomer'] . ' целостость данных (категория)'] = 'У линейки продукции указана несущестующая категория: ' . $row['kategoriya'];
                 }
                 $imagePattern = '/img/product-line-' . $row['nomer'];
                 $findResults = File::glob($directory . $fileNameWithoutExt . $imagePattern . '*');
                 if (count($findResults) == 0) {
                     $dataTransferResultErrors['productLines'][$row['nomer']] = 'У линейки продукции с номером ' . $row['nomer'] . ' отсутствует изображение: ' . $imagePattern;
                 }
                 if ($row['nomer'] <= ProductLine::max('id')) {
                     $dataTransferResultErrors['productLines'][$row['nomer'] . ' дублирование данных (линейка продукции)'] = 'Линейка продукции с номером ' . $row['nomer'] . ' возможно уже присутствует в базe. Проверьте условие минимальности номера линейки продукции';
                 }
             }
             Excel::selectSheets('Продукция')->load($directory . $fileNameWithoutExt . '/products.xlsx', function ($reader) use($directory, $fileNameWithoutExt, $createdProductCategories, $dataTransferResultErrors, $dataTransferResultWarnings, $fileName, $productLines, $productCategories, $request) {
                 foreach ($reader->toArray() as $row) {
                     if ($row['nomer'] == null) {
                         continue;
                     }
                     if ($row['kategoriya'] == null && $row['lineyka_produktsii'] == null) {
                         $dataTransferResultErrors['products'][$row['nomer'] . ' целостость данных (нет привязки)'] = 'У продукции должна быть либо категория либо линейка продукции';
                     }
                     if ($row['kategoriya'] != null && $row['lineyka_produktsii'] != null) {
                         $dataTransferResultErrors['products'][$row['nomer'] . ' целостость данных (плохая привязка)'] = 'У продукции не может быть одновременно категории и линейка продукции';
                     }
                     if ($row['kategoriya'] != null && !in_array($row['kategoriya'], $productCategories) && ProductCategory::find($row['kategoriya']) == null) {
                         $dataTransferResultErrors['products'][$row['nomer'] . ' целостость данных (категория)'] = 'У продукции указана несущестующая категория: ' . $row['kategoriya'];
                     }
                     if ($row['lineyka_produktsii'] != null && !in_array($row['lineyka_produktsii'], $productLines) && ProductLine::find($row['lineyka_produktsii']) == null) {
                         $dataTransferResultErrors['products'][$row['nomer'] . ' целостость данных (категория)'] = 'У продукции указана несущестующая категория: ' . $row['lineyka_produktsii'];
                     }
                     $imagePattern = '/img/product-' . $row['nomer'];
                     $findResults = File::glob($directory . $fileNameWithoutExt . $imagePattern . '*');
                     if (count($findResults) == 0) {
                         $dataTransferResultErrors['products'][$row['nomer']] = 'У продукции с номером ' . $row['nomer'] . ' отсутсвует основное изображение: ' . $imagePattern;
                     }
                     $imagePattern = '/img/product-' . $row['nomer'] . '-color-';
                     $findResults = File::glob($directory . $fileNameWithoutExt . $imagePattern . '*');
                     $notFoundProductColorImages = [];
                     foreach ($findResults as $findResult) {
                         $colorNumber = substr($findResult, strpos($findResult, 'color') + 6, strpos($findResult, '.') - strpos($findResult, 'color') - 6);
                         $imagePattern = '/img/product-' . $row['nomer'] . '-image-' . $colorNumber;
                         $findProductColorImageResults = File::glob($directory . $fileNameWithoutExt . $imagePattern . '*');
                         if (count($findProductColorImageResults) == 0) {
                             array_push($notFoundProductColorImages, $imagePattern);
                         }
                     }
                     if (count($notFoundProductColorImages) > 0) {
                         $dataTransferResultWarnings['products'][$row['nomer'] . ' предупреждение об изображении для палитры'] = 'У продукции с номером ' . $row['nomer'] . ' отсутсвуют изображения продукта для цветовой палитры: ';
                         foreach ($notFoundProductColorImages as $foundProductColorImage) {
                             $dataTransferResultWarnings['products'][$row['nomer'] . ' предупреждение об изображении для палитры'] .= $foundProductColorImage . ', ';
                         }
                     }
                     $imagePattern = '/img/product-' . $row['nomer'] . '-image-';
                     $findResults = File::glob($directory . $fileNameWithoutExt . $imagePattern . '*');
                     $notFoundProductColors = [];
                     foreach ($findResults as $findResult) {
                         $colorNumber = substr($findResult, strpos($findResult, 'image') + 6, strpos($findResult, '.') - strpos($findResult, 'color') - 6);
                         $colorPattern = '/img/product-' . $row['nomer'] . '-color-' . $colorNumber;
                         $findProductColorResults = File::glob($directory . $fileNameWithoutExt . $colorPattern . '*');
                         if (count($findProductColorResults) == 0) {
                             array_push($notFoundProductColors, $colorPattern);
                         }
                     }
                     if (count($notFoundProductColors) > 0) {
                         $dataTransferResultWarnings['products'][$row['nomer'] . ' предупреждение о самом изображении палитры'] = 'У продукции с номером ' . $row['nomer'] . ' отсутсвуют изображения самой цветовой палитры: ';
                         foreach ($notFoundProductColors as $notFoundProductColor) {
                             $dataTransferResultWarnings['products'][$row['nomer'] . ' предупреждение о самом изображении палитры'] .= $notFoundProductColor . ', ';
                         }
                     }
                 }
                 Session::put('dataTransferResult.Errors', $dataTransferResultErrors);
                 Session::put('dataTransferResult.Warnings', $dataTransferResultWarnings);
                 if (count($dataTransferResultErrors['productCategories']) == 0 && count($dataTransferResultErrors['productLines']) == 0 && count($dataTransferResultErrors['products']) == 0) {
                     Session::put('dataTransferResult.FilesPath', $directory . $fileNameWithoutExt);
                 } else {
                     File::delete($directory . $fileName);
                     File::deleteDirectory($directory . $fileNameWithoutExt);
                 }
             });
         });
     });
 }
Exemplo n.º 24
0
 public function deleteFile()
 {
     if (Auth::user()->check()) {
         $name = Input::get('del_file');
         $image_id = Input::get('image_id');
         $page = Input::get('page') ? Input::get('page') : '1';
         $result = array();
         try {
             $image = VIImage::findorFail($image_id);
             $store = $image->store;
             $image->delete();
             if ($store == 'dropbox') {
                 try {
                     $this->filesystem->delete($name);
                 } catch (\Dropbox\Exception $e) {
                     echo $e->getMessage();
                 }
             } else {
                 if ($store == null || $store == '') {
                     $path = public_path('assets' . DS . 'upload' . DS . 'images' . DS . $image_id);
                     $path = str_replace(['\\', '/'], DS, $path);
                     try {
                         File::deleteDirectory($path);
                     } catch (Exception $e) {
                         //echo $e->getMessage();
                     }
                 }
             }
             $result = 'Your image has removed successfully!';
             //return Response::json("{}", 200);
         } catch (Exception $e) {
             //$result = $e;
         }
         Session::flash('message', $result);
         //return Redirect::route('upload-page');
         return Redirect::route('upload-page', array('page' => $page));
     }
     return Redirect::route('account-sign-in');
 }
Exemplo n.º 25
0
 public function deleteDownloadPhoto($type)
 {
     if ($type == 'floorplan') {
         $photos = $this->floorplans;
     } else {
         $photos = $this->photos;
     }
     $folder = $photos->first()->getFolder() . 'download_' . $this->id . '/';
     File::deleteDirectory($folder, true);
 }
Exemplo n.º 26
0
 /**
  * @param ComponentRequest $request
  * @return \Illuminate\Http\RedirectResponse
  */
 public function store(ComponentRequest $request)
 {
     Cache::forget('_components');
     ini_set('max_execution_time', 0);
     File::delete(base_path('components/Component.php'));
     File::deleteDirectory(base_path('components/tmp'));
     $file_path = base_path('components/tmp/');
     $orginal_name = $request->file('file')->getClientOriginalName();
     if ($request->file('file')->move($file_path, $orginal_name)) {
         Zipper::make($file_path . $orginal_name)->extractTo(base_path('components'));
         $component = (require_once base_path('components/Component.php'));
         $composer_file_path = base_path('composer.json');
         $composer_file = file($composer_file_path);
         if (isset($component['composer']) && count($component['composer']) > 0) {
             foreach ($composer_file as $line) {
                 $ok = false;
                 if (trim($line) == '"App\\\\": "app/"' || trim($line) == '"App\\\\": "app/",') {
                     if (count($component['composer']) > 0) {
                         foreach ($component['composer'] as $composer) {
                             $lines[] = "            " . $composer . ",\r\n";
                         }
                     }
                     $lines[] = $line;
                     $ok = true;
                 } else {
                     if (!$ok) {
                         $lines[] = $line;
                     }
                 }
             }
             file_put_contents($composer_file_path, $lines);
             unset($lines);
             exec("cd " . base_path() . " && composer update", $sonuc);
             exec("cd " . base_path() . " && composer dump-autoload", $sonuc);
             Logs::add('process', trans('whole::http/controllers.components_log_1'));
         }
         unset($lines);
         $app_file_path = base_path('config/app.php');
         $app_file = file($app_file_path);
         foreach ($app_file as $line) {
             $lines[] = $line;
             if (isset($component['providers']) && count($component['providers']) > 0) {
                 if (trim($line) == "//include components providers") {
                     foreach ($component['providers'] as $provider) {
                         $lines[] = "\t\t" . $provider . ",\n";
                     }
                 }
             }
             if (isset($component['aliases']) && count($component['aliases']) > 0) {
                 if (trim($line) == "//include components aliases") {
                     foreach ($component['aliases'] as $alias) {
                         $lines[] = "\t\t" . $alias . ",\n";
                     }
                 }
             }
         }
         file_put_contents($app_file_path, $lines);
         unset($lines);
         if ($component['vendor']) {
             exec("php " . base_path("artisan") . " vendor:publish", $sonuc);
             exec("cd " . base_path() . " && composer dump-autoload", $sonuc);
         }
         if ($component['migrate']) {
             exec("cd " . base_path() . " && composer dump-autoload", $sonuc);
             exec("php " . base_path("artisan") . " migrate", $sonuc);
             Logs::add('process', trans('whole::http/controllers.components_log_2'));
         }
         if (isset($component['settings']) && count($component['settings']) > 0) {
             $message = $this->component->create($component['settings']) ? ['success', trans('whole::http/controllers.components_flash_1')] : ['error', trans('whole::http/controllers.components_flash_2')];
             if ($message[0] == "success") {
                 Logs::add('process', trans('whole::http/controllers.components_log_3', ['name' => $component['settings']['name']]));
             } else {
                 Logs::add('errors', "Bileşen Eklenemedi");
             }
             Flash::$message[0]($message[1]);
         }
         if (isset($component['sidebar']) && count($component['sidebar']) > 0) {
             $component['sidebar']['top_id'] = isset($component['sidebar']['top_id']) ? $component['sidebar']['top_id'] : "10";
             $component['sidebar']['children_menu'] = isset($component['sidebar']['children_menu']) ? $component['sidebar']['children_menu'] : "0";
             foreach ($component['pages'] as $page) {
                 $this->all_page->saveData('create', ['path' => $page]);
             }
             if ($this->sidebar->saveData('create', $component['sidebar'])) {
                 Logs::add('process', trans('whole::http/controllers.components_log_4', ['name' => $component['settings']['name']]));
             } else {
                 Logs::add('errors', trans('whole::http/controllers.components_log_5', ['name' => $component['settings']['name']]));
             }
         }
         File::delete(base_path('components/Component.php'));
         File::deleteDirectory(base_path('components/tmp'));
         return redirect()->route('admin.component.index');
     }
     Flash::error(trans('whole.http.controllers.components_flash_3'));
     return redirect()->route('admin.component.index');
 }
Exemplo n.º 27
0
 /**
  * Remove the specified resource from storage.
  *
  * @param  int  $id
  * @return \Illuminate\Http\Response
  */
 public function destroy($id)
 {
     //TODO check if user is admin
     if (\Auth::user()->isUserAdmin()) {
         $snippet = Snippet::where('id', $id)->orWhere('slug', $id)->firstOrFail();
         File::deleteDirectory($snippet->path_to_material);
         $snippet->delete();
         return redirect('/snippets');
     }
 }
Exemplo n.º 28
0
 /**
  * Remove the specified resource from storage.
  *
  * @param  int  $id
  * @return Response
  */
 public function destroy($id)
 {
     try {
         $folder = $this->template->find($id)->folder;
         File::deleteDirectory(storage_path('tmp'));
         File::deleteDirectory(public_path('assets/' . $folder));
         File::deleteDirectory(base_path('resources/views/' . $folder));
     } catch (\Exception $e) {
         Flash::error(trans('whole::http/controllers.templates_flash_4'));
         return redirect()->route('admin.template.index');
     }
     $message = $this->template->delete($id) ? ['success', trans('whole::http/controllers.templates_flash_5')] : ['error', trans('whole::http/controllers.templates_flash_6')];
     Flash::$message[0]($message[1]);
     if ($message[0] == "success") {
         Logs::add('process', trans('whole::http/controllers.templates_log_3', ['id' => $id]));
     } else {
         Logs::add('errors', trans('whole::http/controllers.templates_log_4', ['id' => $id]));
     }
     return redirect()->route('admin.template.index');
 }
 public function delete(Request $request)
 {
     if (!ACL::hasPermission('projects', 'delete')) {
         return redirect(route('projects'))->withErrors(['You don\'t have permission for delete the projects.']);
     }
     //DELETE FOLDER BEFORE DELETE IN DATABASE
     $directory = $this->folder . $request->get('projectsId');
     File::deleteDirectory($directory);
     ProjectsGallery::deleteGalleryByProject($request->get('projectsId'));
     ProjectsMovie::deleteMoviesByProject($request->get('projectsId'));
     Projects::find($request->get('projectsId'))->delete();
     $success = "Project deleted successfully.";
     return redirect(route('projects'))->with(compact('success'));
 }
Exemplo n.º 30
0
 /**
  *  Function to delete attachment
  *
  * @access	public
  * @param   string      $routesConfigFile
  * @param   string      $resource
  * @param   integer     $objectId
  * @param   string      $lang
  * @return  boolean     $response
  */
 public static function deleteAttachment($routesConfigFile, $resource, $objectId, $lang = null)
 {
     Attachment::deleteAttachment(['lang_id_016' => $lang, 'resource_id_016' => $resource, 'object_id_016' => $objectId]);
     if (isset($lang)) {
         if (!empty($objectId) && !empty($lang)) {
             // delete all attachments from this object
             $response = File::deleteDirectory(public_path() . config($routesConfigFile . '.attachmentFolder') . '/' . $objectId . '/' . $lang);
         } else {
             throw new InvalidArgumentException('Object Id, is not defined to delete attachment files');
         }
     } else {
         if (!empty($objectId)) {
             // delete all attachments from this object
             $response = File::deleteDirectory(public_path() . config($routesConfigFile . '.attachmentFolder') . '/' . $objectId);
         } else {
             throw new InvalidArgumentException('Object Id, is not defined to delete attachment files');
         }
     }
     return $response;
 }