makeDirectory() public static method

Create a directory.
public static makeDirectory ( string $path, integer $mode = 493, boolean $recursive = false, boolean $force = false ) : boolean
$path string
$mode integer
$recursive boolean
$force boolean
return boolean
Example #1
2
 /**
  * Store a newly created resource in storage.
  *
  * @param  \Illuminate\Http\Request  $request
  * @return \Illuminate\Http\Response
  */
 public function store(Request $request)
 {
     $this->validate($request, ['file' => 'required']);
     $file = $request->file('file');
     $original_file_name = $file->getClientOriginalName();
     $file_name = pathinfo($original_file_name, PATHINFO_FILENAME);
     $extension = \File::extension($original_file_name);
     $actual_name = $file_name . '.' . $extension;
     $apk = new \ApkParser\Parser($file);
     $manifest = $apk->getManifest();
     $labelResourceId = $apk->getManifest()->getApplication()->getLabel();
     $appLabel = $apk->getResources($labelResourceId);
     $package_name = $manifest->getPackageName();
     if (Apk::packageExist($package_name)) {
         Session::flash('flash_class', 'alert-danger');
         Session::flash('flash_message', 'Apk namespace already exist.');
         return redirect()->route("apk.create");
     }
     Apk::create(array('app_name' => $appLabel[0], 'pkgname' => $package_name, 'version' => $manifest->getVersionCode(), 'version_name' => $manifest->getVersionName(), 'md5' => md5_file($file), 'filename' => $actual_name, 'filesize' => str_format_filesize(\File::size($file)), 'token' => md5(uniqid(mt_rand(), true))));
     $folderpath = base_path() . '/storage/apk/' . $manifest->getPackageName();
     if (!\File::exists($folderpath)) {
         \File::makeDirectory($folderpath);
     }
     $file_path = $request->file('file')->move($folderpath, $actual_name);
     return redirect()->route("apk.index");
 }
Example #2
0
 /**
  * @covers Kotchasan\File::makeDirectory
  * @todo   Implement testMakeDirectory().
  */
 public function testFile()
 {
     $this->object->makeDirectory('temp/');
     $this->object->makeDirectory('temp/test/');
     $f = fopen('temp/test/index.php', 'w');
     fclose($f);
     $this->object->copyDirectory('temp/test/', 'temp/');
     $result = array();
     $this->object->listFiles('temp/test/', $result);
     $this->object->removeDirectory('temp/');
     $this->assertEquals(array('temp/test/index.php'), $result);
 }
 /**
  * Execute the console command.
  *
  * @return mixed
  */
 public function handle()
 {
     $path = $this->getFilePath();
     $directory = dirname($path);
     if ($this->file->exists($path)) {
         $this->error("A view already exists at {$path}!");
         return false;
     }
     if (!$this->file->exists($directory)) {
         $this->file->makeDirectory($directory, 0777, true);
     }
     $this->file->put($path, $this->getViewContents());
     $this->info("Created a new view at {$path}");
 }
 public function run()
 {
     DB::table('products_sika')->truncate();
     File::cleanDirectory(public_path('assets/img/products/sika'));
     File::makeDirectory(public_path('assets/img/products/sika/tech-carts'), true, true);
     factory(App\ProductSika::class, 10)->create();
 }
Example #5
0
 /**
  * Funcao para edicao da config do [Modulo]
  * @param string $controller Nome do controlador
  * @return void
  */
 public function getFile($controller)
 {
     // $this->logic->_getConfigFiles();
     // Busca o arquivo especificado
     $cfg_file = mkny_model_config_path($controller) . '.php';
     // Field types
     $f_types = array_unique(array_values(app()->make('Mkny\\Cinimod\\Logic\\AppLogic')->_getFieldTypes()));
     // Se o diretorio nao existir
     if (!realpath(dirname($cfg_file))) {
         \File::makeDirectory(dirname($cfg_file));
     }
     // Config file data
     if (!\File::exists($cfg_file)) {
         $stub = \File::get(__DIR__ . '/../Commands/stubs/model_config.stub');
         \Mkny\Cinimod\Logic\UtilLogic::translateStub(array('var_fields_data' => ''), $stub);
         \File::put($cfg_file, $stub);
     }
     // Config file data
     $config_str = \File::getRequire($cfg_file)['fields'];
     // Pula o primeiro indice
     // array_shift($config_str);
     $valOrder = 1;
     // Fornece o tipo "types" para todos os campos, para selecao
     foreach ($config_str as $key => $value) {
         if (!is_array($config_str[$key])) {
             $config_str[$key] = array();
         }
         $config_str[$key]['name'] = $key;
         $config_str[$key]['type'] = isset($value['type']) ? $value['type'] : 'string';
         $config_str[$key]['form_add'] = isset($value['form_add']) ? $value['form_add'] : true;
         $config_str[$key]['form_edit'] = isset($value['form_edit']) ? $value['form_edit'] : true;
         $config_str[$key]['grid'] = isset($value['grid']) ? $value['grid'] : true;
         $config_str[$key]['relationship'] = isset($value['relationship']) ? $value['relationship'] : false;
         $config_str[$key]['required'] = isset($value['required']) ? $value['required'] : false;
         $config_str[$key]['searchable'] = isset($value['searchable']) ? $value['searchable'] : false;
         $config_str[$key]['order'] = isset($value['order']) ? $value['order'] : $valOrder++;
         $config_str[$key]['types'] = array_combine($f_types, $f_types);
     }
     if (isset(array_values($config_str)[1]['order'])) {
         usort($config_str, function ($dt, $db) {
             if (!isset($db['order'])) {
                 $db['order'] = 0;
             }
             if (isset($dt['order'])) {
                 return $dt['order'] - $db['order'];
             } else {
                 return 0;
             }
         });
         $newConfig = [];
         foreach ($config_str as $sortfix) {
             $newConfig[$sortfix['name']] = $sortfix;
         }
         $config_str = $newConfig;
     }
     $data['controller'] = $controller;
     $data['data'] = $config_str;
     return view('cinimod::admin.generator.config_detailed_new')->with($data);
     // return view('cinimod::admin.generator.config_detailed')->with($data);
 }
Example #6
0
 /**
  * @param $file
  * @return array
  */
 public function upload($file)
 {
     if (!$file->getClientOriginalName()) {
         return ['status' => false, 'code' => 404];
     }
     $destinationPath = public_path() . $this->imgDir;
     $fileName = $file->getClientOriginalName();
     $fileSize = $file->getClientSize();
     $ext = $file->guessClientExtension();
     $type = $file->getMimeType();
     $upload_success = Input::file('file')->move($destinationPath, $fileName);
     if ($upload_success) {
         $md5_name = md5($fileName . time()) . '.' . $ext;
         $_uploadFile = date('Ymd') . '/' . $md5_name;
         if (!File::isDirectory($destinationPath . date('Ymd'))) {
             File::makeDirectory($destinationPath . date('Ymd'));
         }
         // resizing an uploaded file
         Image::make($destinationPath . $fileName)->resize($this->width, $this->height)->save($destinationPath . $_uploadFile);
         File::delete($destinationPath . $fileName);
         $data = ['status' => true, 'code' => 200, 'file' => ['disk_name' => $fileName, 'file_name' => $md5_name, 'type' => $type, 'size' => $fileSize, 'path' => $this->imgDir . $_uploadFile]];
         return $data;
     } else {
         return ['status' => false, 'code' => 400];
     }
 }
 /**
  * Store a newly created resource in storage.
  *
  * @return Response
  */
 public function store()
 {
     //
     $authuser = Auth::user();
     $nombreDeUsuario = Input::get('nombreDeUsuario');
     $idproveedor = Input::get('idproveedor');
     if (!File::exists('images/proveedores/' . $nombreDeUsuario . '/galeria')) {
         $result = File::makeDirectory('images/proveedores/' . $nombreDeUsuario . '/galeria', 0777);
     }
     $imagen_intro = Input::file('galeria');
     foreach ($imagen_intro as $file) {
         $rules = array('file' => 'required|mimes:png,gif,jpeg|max:200000000');
         $validator = Validator::make(array('file' => $file), $rules);
         if ($validator->fails()) {
             return Redirect::to("vistausuario/proveedorgaleria")->with(array('usuarioimg' => $authuser->imagen, 'usuarionombre' => $authuser->nombre, 'usuarioid' => $authuser->id))->withErrors($validator)->withInput();
         }
     }
     foreach ($imagen_intro as $file) {
         $proveedores_galeria = new ProveedorGaleria();
         $id = Str::random(4);
         $date_now = new DateTime();
         $destinationPath = 'images/proveedores/' . $nombreDeUsuario . '/galeria';
         $filename = $date_now->format('YmdHis') . $id;
         $mime_type = $file->getMimeType();
         $extension = $file->getClientOriginalExtension();
         $upload_success = $file->move($destinationPath, $filename . '.' . $extension);
         $proveedores_galeria->id = 0;
         $proveedores_galeria->proveedores_idproveedor = $idproveedor;
         $proveedores_galeria->imagen = $filename . '.' . $extension;
         $proveedores_galeria->texto = "";
         $proveedores_galeria->save();
         unset($proveedores_galeria);
     }
     return Redirect::to("vistausuario/proveedorgaleria")->with(array('usuarioimg' => $authuser->imagen, 'usuarionombre' => $authuser->nombre, 'usuarioid' => $authuser->id));
 }
Example #8
0
 public function update($id)
 {
     $setting = Setting::findOrFail($id);
     $validator = Validator::make($data = Input::all(), Setting::$rules);
     if ($validator->fails()) {
         return Redirect::back()->withErrors($validator)->withInput();
     }
     unset($data['logo']);
     // Logo Image Upload
     if (Input::hasFile('logo')) {
         $path = public_path() . "/assets/admin/layout/img/";
         File::makeDirectory($path, $mode = 0777, true, true);
         $image = Input::file('logo');
         $extension = $image->getClientOriginalExtension();
         $filename = "logo.{$extension}";
         $filename_big = "logo-big.{$extension}";
         Image::make($image->getRealPath())->save($path . $filename);
         Image::make($image->getRealPath())->save($path . $filename_big);
         $data['logo'] = $filename;
     }
     $currencyArray = explode(':', $data['currency']);
     $data['currency'] = $currencyArray[1];
     $data['currency_icon'] = $currencyArray[0];
     $setting->update($data);
     Session::flash('success', '<strong>Success! </strong>Updated Successfully');
     return Redirect::route('admin.settings.edit', 'setting');
 }
 public function testAssetImageFound()
 {
     \File::makeDirectory(storage_path('moximanager'), 0755, false, true);
     copy(realpath(__DIR__ . '/../../../data/5601729.gif'), storage_path('moximanager/5601729.gif'));
     $response = $this->call('GET', 'storage/moximanager/5601729.gif');
     $this->assertEquals(200, $response->getStatusCode());
 }
Example #10
0
 /**
  * Store a newly created resource in storage.
  *
  * @param  \Illuminate\Http\Request  $request
  * @return \Illuminate\Http\Response
  */
 public function store(Request $request)
 {
     $project = new Project();
     $project->title = $request->title;
     $directory = public_path() . '/' . $request->title;
     \File::makeDirectory($directory);
     $project->description = $request->description;
     $project->owner = \Auth::user()->id;
     if ($project->save()) {
         if ($request->hasFile('audio')) {
             $file = $request->file('audio');
             $file->move($directory, $file->getClientOriginalName());
             $path = $project->title . '/' . $file->getClientOriginalName();
             if (file_exists($path)) {
                 $layer = new Layer();
                 $layer->label = $request->label;
                 $layer->path = $path;
                 $layer->user_id = \Auth::user()->id;
                 $layer->project_id = $project->id;
                 $layer->save();
             }
         }
     }
     return \Redirect::home();
 }
Example #11
0
 public function fire()
 {
     $options = $this->option();
     $this->seed_path = storage_path('seeder');
     Asset::setFromSeed(true);
     // -------------------------------------
     if (is_true($options['reset'])) {
         if (Config::getEnvironment() == 'production') {
             $really = $this->confirm('This is the *** PRODUCTION *** server are you sure!? [yes|no]');
             if (!$really) {
                 $this->info("**** Exiting ****");
                 exit;
             }
         }
         if (!File::exists($this->seed_path)) {
             File::makeDirectory($this->seed_path);
             $n = 50;
             for ($i = 1; $i <= $n; $i++) {
                 $gender_types = ['men', 'women'];
                 foreach ($gender_types as $gender) {
                     $user_photo_url = "http://api.randomuser.me/portraits/{$gender}/{$i}.jpg";
                     File::put($this->seed_path . "/{$gender}_{$i}.jpg", file_get_contents($user_photo_url));
                 }
                 $this->info("Cache user seed image - {$i}");
             }
         }
         if ($this->confirm('Do you really want to delete the tables? [yes|no]')) {
             // first delete all assets
             if (Schema::hasTable('assets')) {
                 foreach (Asset::all() as $asset) {
                     $asset->delete();
                 }
             }
             $name = $this->call('migrate');
             $name = $this->call('migrate:reset');
             File::deleteDirectory(public_path('assets/content/users'));
             $this->info('--- Halp has been reset ---');
         }
         Auth::logout();
         $this->setupDatabases();
         return;
     }
     // -------------------------------------
     if (is_true($options['setup'])) {
         $this->setupDatabases();
     }
     // -------------------------------------
     if ($options['seed'] == 'all') {
         $this->seed();
     }
     if ($options['seed'] == 'users') {
         $this->seedUsers();
     }
     if ($options['seed'] == 'tasks') {
         $this->seedTasks();
     }
     if ($options['seed'] == 'projects') {
         $this->seedProjects();
     }
 }
Example #12
0
 /**
  * Execute the console command.
  *
  * @return mixed
  */
 public function fire()
 {
     //borrramos generaciones previas
     File::deleteDirectory(app_path('modelos_generados'));
     //creamos el directorio en app..
     File::makeDirectory(app_path('modelos_generados'), 777);
     $tablas = SchemaHelper\Table::getTablesCurrentDatabase();
     $this->info("Buscando tablas..");
     foreach ($tablas as $tabla) {
         $this->info("Generando Modelo de la tabla: " . $tabla->table_name);
         //class name
         $class_name = ucfirst(camel_case(str_singular_spanish($tabla->table_name)));
         $baseString = File::get(app_path('models/Schema/Template.txt'));
         //replace class name..
         $baseString = str_replace('@class_name@', $class_name, $baseString);
         //replace table name..
         $baseString = str_replace('@table_name@', $tabla->table_name, $baseString);
         //replace pretty name..
         $baseString = str_replace('@pretty_name@', $tabla->table_name, $baseString);
         //find columns.
         $columns = $tabla->columns()->whereNotIn('column_name', static::$common_hidden)->get();
         //generate fillable
         $baseString = str_replace('@fillable@', $this->generarFillable($columns), $baseString);
         //generate pretty fields string.
         $baseString = str_replace('@pretty_fields@', $this->generarPrettyFields($columns), $baseString);
         //generate rules..
         $baseString = str_replace('@rules@', $this->genenarRules($columns), $baseString);
         //generate belongs to..
         $baseString = str_replace('@belongs_to@', $this->generarBelongsTo($columns), $baseString);
         File::put(app_path('modelos_generados/' . $class_name . '.php'), $baseString);
     }
     $this->info("Generación terminada.");
 }
Example #13
0
 /**
  * Class constructor
  */
 public function __construct()
 {
     //  folder cache
     $dir = ROOT_PATH . DATA_FOLDER . 'cache/';
     if (\File::makeDirectory($dir)) {
         $this->cache_dir = $dir;
         $this->cache_expire = self::$cfg->get('cache_expire', 5);
         // clear old cache every day
         $d = is_file($dir . 'index.php') ? file_get_contents($dir . 'index.php') : 0;
         if ($d != date('d')) {
             $this->clear();
             $f = @fopen($dir . 'index.php', 'wb');
             if ($f) {
                 fwrite($f, date('d'));
                 fclose($f);
             } else {
                 $message = sprintf(\Language::get('The file or folder %s can not be created or is read-only, please create or adjust the chmod it to 775 or 777.'), 'cache/index.php');
                 log_message('Warning', $message, __FILE__, __LINE__);
             }
         }
     } else {
         $message = sprintf(\Language::get('The file or folder %s can not be created or is read-only, please create or adjust the chmod it to 775 or 777.'), 'cache/');
         log_message('Warning', $message, __FILE__, __LINE__);
     }
 }
Example #14
0
 public function getFile($lang = false, $module = false)
 {
     // dd(view()->shared('controller'));
     // app('request')->attributes->get('controller');
     if (!$lang) {
         $lang = \App::getLocale();
     }
     // Busca o arquivo especificado
     $cfg_file = mkny_lang_path($lang . '/' . $module) . '.php';
     // Field types
     $f_types = array_unique(array_values(app()->make('Mkny\\Cinimod\\Logic\\AppLogic')->_getFieldTypes()));
     // Se o diretorio nao existir
     if (!realpath(dirname($cfg_file))) {
         \File::makeDirectory(dirname($cfg_file));
     }
     // Config file data
     if (!\File::exists($cfg_file)) {
         \File::put($cfg_file, "<?php return array( 'teste' => 'teste' );");
     }
     // Arquivo aberto
     $config_str = \File::getRequire($cfg_file);
     $arrFields = array();
     foreach ($config_str as $field_name => $field_value) {
         if (!is_string($field_value)) {
             $arrFields[$field_name] = array('name' => $field_name, 'trans' => $field_name, 'values' => $field_value, 'type' => 'multi');
         } else {
             $arrFields[$field_name] = array('name' => $field_name, 'trans' => $field_name, 'default_value' => $field_value, 'type' => 'string');
         }
     }
     return view('cinimod::admin.generator.trans_detailed')->with(['form' => app()->make('\\Mkny\\Cinimod\\Logic\\FormLogic', [['fields-default-class' => 'form-control']])->getForm(false, action('\\' . get_class($this) . '@postFile', [$lang, $module]), $arrFields, $module)]);
 }
 public function addCatalog(Request $request)
 {
     log::info('add catalog');
     log::info($request);
     try {
         if ($request->get("img") != null) {
             log::info('if');
             $base64data = $request->get("img");
             $filename = str_random(60);
             $uri = substr($base64data, strpos($base64data, ",") + 1);
             $url = public_path() . '/fm_user/images/fm/catalog/' . $request->get('shop_id') . '/';
             if (!File::exists($url)) {
                 File::makeDirectory($url, $mode = 0777, true, true);
             }
             File::put($url . $filename . '.jpg', base64_decode($uri));
             $catalogData = array('media_url' => $url . $filename . '.jpg');
         }
         $catalogData['location_id'] = $request->get('location_id');
         $catalogData['description'] = $request->get('description');
         $catalogData['name'] = $request->get('name');
         $catalogId = Catalog::create($catalogData)->id;
         return Response::json($catalogId);
     } catch (Exception $e) {
         log::info($e);
         return Response::json('ERROR');
     }
 }
Example #16
0
 public function post_upload()
 {
     // fetch input data
     $input = \Input::all();
     // create rules for validator
     $rules = array('image' => 'required|image|max:5000', 'description' => 'required|max:100');
     // validate the data with set rules
     $v = \Validator::make($input, $rules);
     if ($v->fails()) {
         // if validation fails, redirect back with relevant error messages
         return \Redirect::back()->withInput()->withErrors($v);
     } else {
         $image = \Input::file('image');
         // URL::to('/') can be changed to public_path() on a public domain
         $directory = \URL::to('/') . '/uploads/';
         $mkdir = public_path() . '/uploads/';
         // create directory if it doesn't exist
         if (!file_exists($mkdir)) {
             \File::makeDirectory($mkdir, 0775, true);
         }
         // save the filename with the path and a unique name for the file
         $filename = uniqid() . '.' . $input['image']->getClientOriginalExtension();
         // move the file to the correct path
         $upload_success = $input['image']->move($mkdir, $filename);
         $full_path = $directory . $filename;
         // store image info in the database
         \DB::table('images')->insert(['description' => \Input::get('description'), 'image' => $full_path, 'user_id' => \Auth::user()->id, 'approved' => 0, 'created_at' => \Carbon\Carbon::now()->toDateTimeString()]);
         return \Redirect::back()->withInput()->withErrors('Upload Successful!');
     }
 }
Example #17
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);
     }
 }
 /**
  * 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);
 }
Example #19
0
 function simpan($id)
 {
     if ($this->getCount($id) > 6) {
         echo "not";
     } else {
         $pajak = new Pajak();
         $pajak->id_pengadaan = $id;
         $pajak->jenis_pajak = Input::get('jenis_pajak');
         $pajak->no_pajak = Input::get("no_pajak");
         $pajak->tgl_pajak = date('Y-m-d', strtotime(Input::get('tanggal')));
         $pajak->save();
         $id_pajak = $pajak->id_pajak;
         if (!File::isDirectory(public_path() . '/asset/img/pajak/' . $id)) {
             File::makeDirectory(public_path() . '/asset/img/pajak/' . $id);
         }
         $filenpwp = Input::file('file_npwp');
         $newnpwp = $id . '_' . $id_pajak . '.' . $filenpwp->guessClientExtension();
         Image::make($filenpwp->getRealPath())->save(public_path('/asset/img/pajak/' . $id . '/' . $newnpwp));
         $data = Pajak::find($id_pajak);
         $data->file_pajak = $newnpwp;
         if ($data->save()) {
             echo "ok";
         } else {
             echo "error";
         }
     }
 }
Example #20
0
 /**
  * Upload the image while creating/updating records
  * @param File Object $file
  */
 public function setImageAttribute($file)
 {
     // Only if a file is selected
     if ($file) {
         File::exists(public_path() . '/uploads/') || File::makeDirectory(public_path() . '/uploads/');
         File::exists(public_path() . '/' . $this->images_path) || File::makeDirectory(public_path() . '/' . $this->images_path);
         File::exists(public_path() . '/' . $this->thumbs_path) || File::makeDirectory(public_path() . '/' . $this->thumbs_path);
         $file_name = $file->getClientOriginalName();
         $file_ext = File::extension($file_name);
         $only_fname = str_replace('.' . $file_ext, '', $file_name);
         $file_name = $only_fname . '_' . str_random(8) . '.' . $file_ext;
         $image = Image::make($file->getRealPath());
         if (isset($this->attributes['folder'])) {
             // $this->attributes['folder'] = Str::slug($this->attributes['folder'], '_');
             $this->images_path = $this->attributes['folder'] . '/';
             $this->thumbs_path = $this->images_path . '/thumbs/';
             File::exists(public_path() . '/' . $this->images_path) || File::makeDirectory(public_path() . '/' . $this->images_path);
             File::exists(public_path() . '/' . $this->thumbs_path) || File::makeDirectory(public_path() . '/' . $this->thumbs_path);
         }
         if (isset($this->attributes['image'])) {
             // Delete old image
             $old_image = $this->getImageAttribute();
             File::exists($old_image) && File::delete($old_image);
         }
         if (isset($this->attributes['thumbnail'])) {
             // Delete old thumbnail
             $old_thumb = $this->getThumbnailAttribute();
             File::exists($old_thumb) && File::delete($old_thumb);
         }
         $image->save(public_path($this->images_path . $file_name))->fit(150, 150)->save(public_path($this->thumbs_path . $file_name));
         $this->attributes['image'] = "{$this->attributes['folder']}/{$file_name}";
         $this->attributes['thumbnail'] = "{$this->attributes['folder']}/thumbs/{$file_name}";
         unset($this->attributes['folder']);
     }
 }
 /**
  * Check if a directory exists and create it if necessary
  * @param string $model
  */
 public static function createDirectory($model)
 {
     $path = public_path('assets/img/' . $model->getTable() . '/' . $model->id);
     if (!\File::exists($path)) {
         \File::makeDirectory($path, 0755, true);
     }
 }
Example #22
0
 public function update($id)
 {
     if (Auth::id() != $id) {
         return Redirect::to('http://google.com');
     }
     $user = Auth::User();
     $validator = Validator::make(Input::all(false), ['email' => 'required|email|unique:users,email,' . $id, 'password' => 'min:5|confirmed:password_confirmation', 'first_name' => 'required', 'last_name' => 'required']);
     if ($validator->passes()) {
         $img_ava = $user->avatar_img;
         $password = Input::get('password');
         if (Input::hasFile('avatar_img')) {
             if (File::exists(Config::get('user.upload_user_ava_directory') . $img_ava)) {
                 File::delete(Config::get('user.upload_user_ava_directory') . $img_ava);
             }
             if (!is_dir(Config::get('user.upload_user_ava_directory'))) {
                 File::makeDirectory(Config::get('user.upload_user_ava_directory'), 0755, true);
             }
             $img = Image::make(Input::file('avatar_img'));
             $img_ava = md5(Input::get('username')) . '.' . Input::file('avatar_img')->getClientOriginalExtension();
             if ($img->width() < $img->height()) {
                 $img->resize(100, null, function ($constraint) {
                     $constraint->aspectRatio();
                 })->crop(100, 100)->save(Config::get('user.upload_user_ava_directory') . $img_ava, 90);
             } else {
                 $img->resize(null, 100, function ($constraint) {
                     $constraint->aspectRatio();
                 })->crop(100, 100)->save(Config::get('user.upload_user_ava_directory') . $img_ava, 90);
             }
         }
         $user->update(['username' => null, 'email' => Input::get('email'), 'password' => !empty($password) ? Hash::make($password) : $user->password, 'first_name' => Input::get('first_name'), 'last_name' => Input::get('last_name')]);
         return Redirect::back()->with('success_msg', Lang::get('messages.successupdate'));
     } else {
         return Redirect::back()->withErrors($validator)->withInput();
     }
 }
Example #23
0
 public static function uploadImage($user_id)
 {
     $error_code = ApiResponse::OK;
     if (User::where('user_id', $user_id)->first()) {
         $profile = Profile::where('user_id', $user_id)->first();
         if (Input::hasFile('file')) {
             $file = Input::file('file');
             $destinationPath = public_path() . '/images/' . $user_id . '/avatar';
             $filename = date('YmdHis') . '_' . $file->getClientOriginalName();
             $extension = $file->getClientOriginalExtension();
             if (!File::isDirectory($destinationPath)) {
                 File::makeDirectory($destinationPath, $mode = 0777, true, true);
             }
             $upload_success = $file->move($destinationPath, $filename);
             $profile->image = 'images/' . $user_id . '/avatar/' . $filename;
             $profile->save();
             $data = URL::asset($profile->image);
         } else {
             $error_code = ApiResponse::MISSING_PARAMS;
             $data = null;
         }
     } else {
         $error_code = ApiResponse::UNAVAILABLE_USER;
         $data = ApiResponse::getErrorContent(ApiResponse::UNAVAILABLE_USER);
     }
     return array("code" => $error_code, "data" => $data);
 }
 public function signup()
 {
     if (!Allow::enabled_module('users')) {
         return App::abort(404);
     }
     $json_request = array('status' => FALSE, 'responseText' => '', 'responseErrorText' => '', 'redirect' => FALSE);
     if (Request::ajax()) {
         $validator = Validator::make(Input::all(), User::$rules);
         if ($validator->passes()) {
             $account = User::where('email', Input::get('email'))->first();
             if (is_null($account)) {
                 if ($account = self::getRegisterAccount(Input::all())) {
                     if (Allow::enabled_module('downloads')) {
                         if (!File::exists(base_path('usersfiles/account-') . $account->id)) {
                             File::makeDirectory(base_path('usersfiles/account-') . $account->id, 777, TRUE);
                         }
                     }
                     Mail::send('emails.auth.signup', array('account' => $account), function ($message) {
                         $message->from('*****@*****.**', 'Monety.pro');
                         $message->to(Input::get('email'))->subject('Monety.pro - регистрация');
                     });
                     $json_request['responseText'] = 'Вы зарегистрированы. Мы отправили на email cсылку для активации аккаунта.';
                     $json_request['status'] = TRUE;
                 }
             } else {
             }
         } else {
             $json_request['responseText'] = 'Неверно заполнены поля';
             $json_request['responseErrorText'] = $validator->messages()->all();
         }
     } else {
         return App::abort(404);
     }
     return Response::json($json_request, 200);
 }
Example #25
0
 /**
  * @return mixed
  */
 public static function getTempDirectory()
 {
     $dir = storage_path(config('ignicms.files.temporary_directory', 'upload_temp'));
     if (!is_dir($dir)) {
         \File::makeDirectory($dir);
     }
     return $dir;
 }
 /**
  * Create directories
  *
  * @return void
  */
 protected function registerDirectories()
 {
     $storagePath = GCCompiler::storagePath();
     if (!\File::exists($storagePath)) {
         \File::makeDirectory($storagePath);
         chmod($storagePath, 0757);
     }
 }
Example #27
0
 /**
  * Move the resource to the course folder.
  *
  * @param Course $post
  * @param $path
  */
 public function moveResource(Course $post, $path)
 {
     $old_path = public_path('uploads' . DIRECTORY_SEPARATOR . $path);
     $new_path = public_path('uploads' . DIRECTORY_SEPARATOR . $post->slug);
     \File::makeDirectory($new_path, $mode = 0777, true, true);
     $new_path .= DIRECTORY_SEPARATOR . $path;
     \File::move($old_path, $new_path);
 }
Example #28
0
 public function setUp()
 {
     parent::setUp();
     if (File::exists($this->tempDirectory)) {
         File::deleteDirectory($this->tempDirectory);
     }
     File::makeDirectory($this->tempDirectory);
 }
 public function store($notebookId, $noteId, $versionId)
 {
     $note = self::getNote($notebookId, $noteId, $versionId);
     if ($note->pivot->umask < PaperworkHelpers::UMASK_READWRITE) {
         return PaperworkHelpers::apiResponse(PaperworkHelpers::STATUS_ERROR, array('message' => 'Permission Error'));
     }
     if (Input::hasFile('file') && Input::file('file')->isValid() || Input::json() != null && Input::json() != "") {
         $fileUpload = null;
         $newAttachment = null;
         if (Input::hasFile('file')) {
             $fileUpload = Input::file('file');
             $newAttachment = new Attachment(array('filename' => $fileUpload->getClientOriginalName(), 'fileextension' => $fileUpload->getClientOriginalExtension(), 'mimetype' => $fileUpload->getMimeType(), 'filesize' => $fileUpload->getSize()));
         } else {
             $fileUploadJson = Input::json();
             $fileUpload = base64_decode($fileUploadJson->get('file'));
             $newAttachment = new Attachment(array('filename' => $fileUploadJson->get('clientOriginalName'), 'fileextension' => $fileUploadJson->get('clientOriginalExtension'), 'mimetype' => $fileUploadJson->get('mimeType'), 'filesize' => count($fileUpload)));
         }
         $newAttachment->save();
         // Move file to (default) /app/storage/attachments/$newAttachment->id/$newAttachment->filename
         $destinationFolder = Config::get('paperwork.attachmentsDirectory') . '/' . $newAttachment->id;
         if (!File::makeDirectory($destinationFolder, 0700)) {
             $newAttachment->delete();
             return PaperworkHelpers::apiResponse(PaperworkHelpers::STATUS_ERROR, array('message' => 'Internal Error'));
         }
         // Get Version with versionId
         //$note = self::getNote($notebookId, $noteId, $versionId);
         $tmp = $note ? $note->version()->first() : null;
         $version = null;
         if (is_null($tmp)) {
             $newAttachment->delete();
             File::deleteDirectory($destinationFolder);
             return PaperworkHelpers::apiResponse(PaperworkHelpers::STATUS_NOTFOUND, array('message' => 'version->first'));
         }
         while (!is_null($tmp)) {
             if ($tmp->id == $versionId || $versionId == 0) {
                 $version = $tmp;
                 break;
             }
             $tmp = $tmp->previous()->first();
         }
         if (is_null($version)) {
             $newAttachment->delete();
             File::deleteDirectory($destinationFolder);
             return PaperworkHelpers::apiResponse(PaperworkHelpers::STATUS_NOTFOUND, array('message' => 'version'));
         }
         if (Input::hasFile('file')) {
             $fileUpload->move($destinationFolder, $fileUpload->getClientOriginalName());
         } else {
             file_put_contents($destinationFolder . '/' . $fileUploadJson->get('clientOriginalName'), $fileUpload);
         }
         $version->attachments()->attach($newAttachment);
         // Let's push that parsing job, which analyzes the document, converts it if needed and parses the crap out of it.
         Queue::push('DocumentParserWorker', array('user_id' => Auth::user()->id, 'document_id' => $newAttachment->id));
         return PaperworkHelpers::apiResponse(PaperworkHelpers::STATUS_SUCCESS, $newAttachment);
     } else {
         return PaperworkHelpers::apiResponse(PaperworkHelpers::STATUS_ERROR, array('message' => 'Invalid input'));
     }
 }
 protected static function prepare($type)
 {
     $path = storage_path('logs/wechat');
     $file = $path . '/' . $type . '-' . date('Y-m-d') . '.log';
     if (!\File::isDirectory($path)) {
         \File::makeDirectory($path);
     }
     return $file;
 }