public static function uploadFileToStorage(File $file) { $filename = 'file_' . substr(md5(uniqid(rand())), 6) . '_' . $file->getClientOriginalName(); $path = self::uploadPath(); $file->move($path, $filename); return $path . DIRECTORY_SEPARATOR . $filename; }
/** * Handle all files * @return void */ public function upload() { foreach ($this->files as $source => $dest) { $file = new File($source); $file->move($dest['path'], $dest['filename']); } }
public function saveProduct() { $data = Input::all(); if (!Auth::guest()) { $validator = Validator::make($data, Product::$rules); if ($validator->passes()) { $user = Auth::user(); $product = new Product(); $product->user_id = $user->id; $product->product_name = $data['product_name']; $product->description = $data['description']; $product->start_price = $data['start_price']; $product->save(); if (isset($data['categories']) && !empty($data['categories'])) { $product->categories()->attach($data['categories']); } if (Session::has('files')) { $files = Session::get('files'); // get session files foreach ($files as $key => $file) { $directory_file = public_path() . '/product_images/' . $file; if (File::exists($directory_file)) { File::move($directory_file, public_path() . '/product_images/product_' . $product->id . '_' . $key . '.jpg'); } } Session::forget('files'); } return Response::json(array('success' => true, 'product' => $product)); } return Response::json(array('success' => false, 'type' => 'form_error', 'errors' => $validator->messages())); } return Response::json(array('success' => false, 'type' => 'log_error', 'error' => 'In order to save your product, please, log in!')); }
public function update() { $rules = array('name' => 'required', 'desc' => 'required', 'totalposts' => 'required|numeric'); $validator = Validator::make(Input::all(), $rules); $badgeid = Input::get('id'); if ($validator->fails()) { return Redirect::to('admin/editbadge/' . $badgeid)->withErrors($validator)->withInput(); } else { $name = Input::get('name'); if (Input::get('badge')) { $image = explode('/', Input::get('badge')); $image = urldecode(end($image)); $extension = explode(".", $image); $extension = end($extension); $img = Image::make('files/' . $image); $img->resize(160, null, function ($constraint) { $constraint->aspectRatio(); $constraint->upsize(); })->save('files/' . $image); $newname = date('YmdHis') . '_' . Str::slug($name, '_') . '.' . $extension; File::move('files/' . $image, 'badges/' . $newname); } $badge = Badge::find($badgeid); $badge->name = Input::get('name'); $badge->description = Input::get('desc'); if (Input::get('badge')) { $badge->image = $newname; } $badge->total_posts = Input::get('totalposts'); $badge->save(); Session::flash('success', 'Badge updated'); return Redirect::to('admin/badges'); } }
/** * Move or rename a file * * @param string $from The full path of the file to move * @param string $to The full path of the target file * * @return boolean True on success */ public function move($from, $to) { $ret = $this->fileAdapter->move($from, $to); if (!$ret && is_object($this->abstractionAdapter)) { return $this->abstractionAdapter->move($from, $to); } return $ret; }
/** * 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); }
public function whenAccountWasInstalled(AccountWasInstalled $account) { $langPath = app_path('lang'); $enPath = "{$langPath}/en"; $enGbPath = "{$langPath}/en_GB"; if (File::exists($enPath)) { File::move($enPath, $enGbPath); } }
public function move($destination) { $destination = dirname($destination) . '/' . basename($this->source); if (File::move($this->source, $destination)) { $this->source = $destination; return true; } else { return false; } }
/** * @ORM\PostPersist() * @ORM\PostUpdate() */ public function upload() { if (null === $this->file) { return; } // s'il y a une erreur lors du déplacement du fichier, une exception // va automatiquement être lancée par la méthode move(). Cela va empêcher // proprement l'entité d'être persistée dans la base de données si // erreur il y a $this->file->move($this->getUploadRootDir(), $this->src); unset($this->file); }
/** * @ORM\PostPersist() * @ORM\PostUpdate() */ public function upload() { if (null === $this->file) { return; } // s'il y a une erreur lors du déplacement du fichier, une exception // va automatiquement être lancée par la méthode move(). Cela va empêcher // proprement l'entité d'être persistée dans la base de données si // erreur il y a $this->file->move($this->getUploadRootDir(), $this->path); unset($this->file); }
/** * Update the specified resource in storage. * * @param PhotosRequest $request * @param int $id * @return \Illuminate\Http\Response */ public function update(PhotosRequest $request, $id) { $photo = Photos::findOrFail($id); $old_slug = $photo->slug; $input = \Input::all(); $input['slug'] = '/img/photos/' . $photo->id . '/' . \trslug::trslug(\Input::get('title') . '.jpg'); $photo->update($input); \File::move(storage_path('app') . $old_slug, storage_path('app') . $photo->slug); // Photos::findOrFail($id)->update(\Input::all()); return \Redirect::back()->with('message', 'Kaydedildi!'); }
/** * * @ORM\PostPersist() * @ORM\PostUpdate() * */ public function upload() { if (null === $this->file) { return; } //Si ancien fichier on supprime if (null !== $this->tempFileName) { $oldFile = $this->getUploadRootDir() . '/' . $this->id . '.' . $this->tempFileName; if (file_exists($oldFile)) { unlink($oldFile); } } //On deplace $this->file->move($this->getUploadRootDir(), $this->id . '.' . $this->url); // chmod($this->getUploadRootDir().'/'.$this->id.'.'.$this->url,644); }
/** * Called after entity persistence * * @ORM\PostPersist() * @ORM\PostUpdate() */ public function upload() { // The file property can be empty if the field is not required if (null === $this->file) { return; } // Use the original file name here but you should // sanitize it at least to avoid any security issues // move takes the target directory and then the // target filename to move to $this->file->move($this->getUploadRootDir(), $this->path); // Set the path property to the filename where you've saved the file //$this->path = $this->file->getClientOriginalName(); // Clean up the file property as you won't need it anymore $this->file = null; }
function importProcess() { $resultData = File::uploadMultiple('theFile', 'uploads/tmp/'); $total = count($resultData); for ($i = 0; $i < $total; $i++) { $targetPath = ''; $theFile = $resultData[$i]; $sourcePath = ROOT_PATH . $theFile; $shortPath = 'contents/plugins/' . basename($theFile); $targetPath .= $shortPath; File::move($sourcePath, $targetPath); $sourcePath = dirname($sourcePath); rmdir($sourcePath); File::unzipModule($targetPath, 'yes'); $installFile = ROOT_PATH . $shortPath . '/install/update.sql'; if (file_exists($installFile)) { Database::import($installFile); } } }
public function update() { $id = Input::get('id'); $rules = array('image_banner' => 'required'); $validator = Validator::make(Input::all(), $rules); if ($validator->fails()) { return Redirect::to('admin/editbanner/' . $id)->withErrors($validator)->withInput(); } else { $image = explode(url() . '/', Input::get('image_banner')); $realpath = public_path($image[1]); $newname = date('YmdHis') . '.jpg'; File::move($realpath, 'images/slider/' . $newname); // update db $banner = Banner::find($id); $banner->image = 'images/slider/' . $newname; $banner->save(); Session::flash('success', 'Banner updated'); return Redirect::to('admin/banners'); } }
/** * @param $userId * @param $fileUniName * @param $oriFileName * @param $tmpFileUrl * @param $chunk * @param $chunks * @param string $uploadTo * @return AmaotoFile|\Illuminate\Database\Eloquent\Model|mixed|null|static * @throws NeedMoreDataException */ public static function uploadFile($userId, $fileUniName, $oriFileName, $tmpFileUrl, $chunk, $chunks, $uploadTo = 'upload') { $fileMergePath = self::getUploadToPath($uploadTo) . '/' . $fileUniName . '.merge'; if ($chunk === 0) { File::put($fileMergePath, File::get($tmpFileUrl)); } else { File::append($fileMergePath, File::get($tmpFileUrl)); } if (!$chunks || $chunk == $chunks - 1) { //文件已上传完整 //计算哈希值 $fileMd5 = md5_file($fileMergePath); $fileFinalUrl = self::getUploadToPath($uploadTo) . '/' . $fileMd5 . '.' . File::extension($oriFileName); //判断文件是否存在 if (file_exists($fileFinalUrl)) { File::delete($fileMergePath); } else { File::move($fileMergePath, $fileFinalUrl); } if (AmaotoFile::whereMd5($fileMd5)->count() == 0) { $thatFile = new AmaotoFile(); $thatFile->md5 = $fileMd5; $thatFile->name = $oriFileName; $thatFile->size = File::size($fileFinalUrl); $thatFile->url = str_replace(public_path(), '', $fileFinalUrl); $thatFile->user_id = $userId; $thatFile->updateTypeByGetId3(); $thatFile->save(); return $thatFile; } else { $thatFile = AmaotoFile::whereMd5($fileMd5)->first(); return $thatFile; } } throw new NeedMoreDataException('文件未接收完整,请求继续发送数据'); }
/** * Checks for file existence and then creates file.. if the file * already exists we create a new file (clone) * * @param File $file * @param string $serverPath * @param string $originalName * @return string */ private function createFile($file, $serverPath, $originalName) { $newName = $originalName; $info = pathinfo($newName); $sanity = 0; while (file_exists($serverPath . '/' . $newName)) { $dir = $info['dirname'] === '.' ? '' : $info['dirname']; $newName = $dir . $info['filename'] . '.copy.' . $info['extension']; if ($sanity++ > 5) { throw new \Exception("You've got a lot of copies of this file... I'm going to stop trying to make copies..."); } } $file->move($serverPath, $newName); return $newName; }
return ['code' => strtoupper($faker->bothify('??##??#?')), 'style' => rand(0, 4) ? ucwords(join(' ', $faker->words(rand(1, 4)))) : '', 'description' => $faker->paragraph, 'specs' => collect($specs)]; }); $factory->define(App\File::class, function (Faker\Generator $faker) { $generated = $faker->file('/tmp', storage_path()); $filename = \File::name($generated) . '.pdf'; $filepath = public_path() . '/files/' . $filename; $saved = \File::move($generated, $filepath); return ['path' => 'files/' . $filename, 'mime' => \File::mimeType($filepath), 'extension' => \File::extension($filepath), 'size' => \File::size($filepath)]; }); $factory->define(App\SafetyDataSheet::class, function (Faker\Generator $faker) { return ['title' => ucwords(join(' ', $faker->words(rand(1, 4))))]; }); $factory->define(App\DataSheet::class, function (Faker\Generator $faker) { return ['title' => ucwords(join(' ', $faker->words(rand(1, 4))))]; }); $factory->define(App\Brochure::class, function (Faker\Generator $faker) { return ['title' => ucwords(join(' ', $faker->words(rand(1, 4))))]; }); $factory->define(App\Image::class, function (Faker\Generator $faker) { $file = new App\File(); $generated = $faker->image('/tmp', 1024, 768); $filename = \File::name($generated) . '.' . \File::extension($generated); $filepath = public_path() . '/files/' . $filename; $saved = \File::move($generated, $filepath); $fileEntity = App\File::create(['path' => 'files/' . $filename, 'mime' => \File::mimeType($filepath), 'extension' => \File::extension($filepath), 'size' => \File::size($filepath)]); return ['title' => ucwords(join(' ', $faker->words(rand(1, 4)))), 'file_id' => $fileEntity->id]; }); $factory->define(App\Industry::class, function (Faker\Generator $faker) { $name = ucwords(join(' ', $faker->words(rand(1, 4)))); return ['name' => $name, 'slug' => str_slug($name)]; });
/** * Remove the specified resource from storage. * * @param int $id * @return \Response */ public function destroy(Request $request, $id) { $user = auth()->check() ? auth()->user() : null; if (is_null($user)) { return new JsonResponse(['error' => 'not_logged_in']); } if (!$request->has('reason') || trim($request->get('reason')) == '') { return new JsonResponse(['error' => 'invalid_request']); } $reason = trim($request->get('reason')); if ($user->can('delete_video')) { $warnings = []; $vid = Video::find($id); if (!$vid) { return new JsonResponse(['error' => 'video_not_found']); } foreach ($vid->comments as $comment) { $comment->delete(); // delete associated comments } $vid->faved()->detach(); if (!\File::move(public_path() . '/b/' . $vid->file, storage_path() . '/deleted/' . $vid->file)) { $warnings[] = 'Could not move file'; } $vid->delete(); $receiver = $vid->user; if ($user->id != $receiver->id) { Message::send(1, $receiver->id, 'A moderator deleted your video', view('messages.moderation.videodelete', ['video' => $vid, 'reason' => $reason, 'videoinfo' => ['artist' => $vid->interpret, 'songtitle' => $vid->songtitle, 'video_source' => $vid->imgsource, 'category' => $vid->category->name]])); } $log = new ModeratorLog(); $log->user()->associate($user); $log->type = 'delete'; $log->target_type = 'video'; $log->target_id = $id; $log->reason = $reason; $log->save(); return new JsonResponse(['error' => 'null', 'warnings' => $warnings]); } return new JsonResponse(['error' => 'insufficient_permissions']); }
public function markAsHam($file) { File::move($file, str_replace('spam/', '', $file)); }
/** * Update the specified resource in storage. * * @param AccountancyRequest $request * @param int $id * @return \Illuminate\Http\Response */ public function update(AccountancyRequest $request, $id) { // // $input = \Input::except('attach', 'published_at', 'company'); $acc = Accountancy::find($id); $acc->update($input); $acc->published_at = $this->carbon_parse(\Input::get('published_at')); $dir = storage_path('app/accountancy/') . $acc->id . '/'; \File::makeDirectory($dir, 0777, true, true); if (\Input::file('attach')) { $filename = \Input::file('attach')->getClientOriginalName(); \File::move(\Input::file('attach'), $dir . $filename); } $acc->save(); return \Redirect::back()->with('message', 'Kaydedildi!'); }
/** * Removes a file from the repository, deletes (renames) it locally. * To complete this action, you have to call commit. Use this with * caution. * * @return bool success */ public function remove() { $f = new File($this->filename); $f->move($this->filename . '.cvsremove'); return $this->_execute('remove'); }
public function fire($job, $message) { $siteId = $message['siteId']; $buildId = $message['id']; $branch = $message['branch']; $dc = new DC($siteId); $df = new DeployInfo($siteId); $root = (new SystemConfig())->get(SystemConfig::WORK_ROOT_FIELD) . '/' . $siteId; $commitRoot = "{$root}/commit/"; $branchPath = "{$commitRoot}/{$branch}"; $gitOrigin = $dc->get(DC::GIT_ORIGIN); $buildCommand = 'make deploy'; $defaultBranch = 'default'; $developRoot = "{$root}/branch/{$defaultBranch}"; Log::info("\n---------------------------\njob id : {$job->getJobId()} start"); $progress = 0; $redis = app('redis')->connection(); $lock = new \Eleme\Rlock\Lock($redis, JobLock::buildLock($developRoot), array('timeout' => 600000, 'blocking' => false)); if (!$lock->acquire()) { Log::info("Job : {$job->getJobId()} Release"); $job->release(30); return; } try { if (!File::exists($developRoot)) { Log::info('Git clone'); (new Process('mkdir -p ' . $commitRoot))->mustRun(); (new Process('mkdir -p ' . $developRoot))->mustRun(); (new Process('git clone ' . $gitOrigin . ' ' . $developRoot . ' --depth 20'))->setTimeout(600)->mustRun(); } $build = $df->get($buildId); $build['result'] = 'Fetch Origin'; $build['last_time'] = date('Y-m-d H:i:s'); $df->save($build); Log::info("git fetch origin"); (new Process("git fetch origin", $developRoot))->setTimeout(600)->mustRun(); $progress = 1; (new Process("cp -r {$developRoot} {$branchPath}", $commitRoot))->mustRun(); $revParseProcess = new Process("git rev-parse origin/{$branch}", $branchPath); $revParseProcess->run(); if (!$revParseProcess->isSuccessful()) { throw new Exception('Error Message : ' . $revParseProcess->getErrorOutput()); } $commit = trim($revParseProcess->getOutput()); $commitPath = "{$commitRoot}/{$commit}"; $build['result'] = 'Building'; $build['last_time'] = date('Y-m-d H:i:s'); $df->save($build); $needBuild = true; if ($commit !== $branch) { if (File::exists($commitPath)) { File::deleteDirectory($branchPath); $needBuild = false; } else { $progress = 2; File::move($branchPath, $commitPath); } } if ($needBuild) { Log::info("Build {$siteId} branch: {$branch}"); (new Process("git checkout {$commit}", $commitPath))->mustRun(); Log::info("make deploy"); (new Process($buildCommand, $commitPath))->setTimeout(600)->mustRun(); } (new CommitVersion($siteId))->add($commit); $build['commit'] = $commit; $build['result'] = 'Build Success'; $build['last_time'] = date('Y-m-d H:i:s'); $df->save($build); Log::info($job->getJobId() . " finish\n---------------------------"); } catch (Exception $e) { $build['errMsg'] = $e->getMessage(); $build['result'] = 'Error'; $build['last_time'] = date('Y-m-d H:i:s'); $df->save($build); switch ($progress) { case 2: (new Process('rm -rf ' . $commitPath))->run(); case 1: (new Process('rm -rf ' . $branchPath))->run(); } Log::error($e->getMessage()); Log::info($job->getJobId() . " Error Finish\n---------------------------"); } $lock->release(); $job->delete(); }
/** * Moves a file from one location to another within this plugin's namespaced storage * * @param string $filename Name of file to move * @param string $new_filename New file name to move it to * @return boolean */ public function move($filename, $new_filename) { $this->verifyStorageFolder(); $this->isValidFilename($filename); $this->isValidFilename($new_filename); return File::move($this->contextualize($filename), $this->contextualize($new_filename)); }
/** * Moves the file to a new location. * * @param string $dir * @param null $name * * @return \Pimf\Util\File * @throws \RuntimeException If the file has not been uploaded via Http or can not move the file. */ public function move($dir, $name = null) { if ($this->isValid()) { if ($this->test) { return parent::move($dir, $name); } if (is_uploaded_file($this->getPathname())) { $target = $this->getTargetFile($dir, $name); move_uploaded_file($this->getPathname(), $target); chmod($target, 0666 & ~umask()); return $target; } } throw new \RuntimeException("The file {$this->getPathname()} has not been uploaded via Http"); }
public function edit($id) { $path = "uploads/images/product/"; $tmpPath = "uploads/images/product/tmp/"; if (Request::isMethod('post')) { if (Request::ajax()) { $file = Input::file('image'); $input = array('image' => $file); $rules = array('image' => 'image|max:10000'); $validator = Validator::make($input, $rules); if ($validator->fails()) { return Response::json(['success' => false, 'errors' => $validator->getMessageBag()->toArray()]); } else { $file = Input::file('image'); $input = array('image' => $file); $rules = array('image' => 'image|max:10000'); $validator = Validator::make($input, $rules); if ($validator->fails()) { return Response::json(['success' => false, 'errors' => $validator->getMessageBag()->toArray()]); } else { $hash = md5(time()); $filename = "{$hash}.png"; $filenameThumb = "{$hash}_small.png"; Input::file('image')->move($path, $filename); $img = Image::make($path . $filename); /* foreach (Config::get('setting.product.image.size') as $value) { $img->encode('jpg', 75); $img->resize(null, $value['h'], function ($constraint) { $constraint->aspectRatio(); }); $img->save($path . $hash . '_' . $value['name'] . '.png'); }*/ $img->encode('jpg', 75); if ($img->width() > $img->height()) { foreach (Config::get('setting.product.image.size') as $value) { $img->resize($value['w'], null, function ($constraint) { $constraint->aspectRatio(); }); $img->save($path . $hash . '_' . $value['name'] . '.png'); } } else { foreach (Config::get('setting.product.image.size') as $value) { $img->resize(null, $value['h'], function ($constraint) { $constraint->aspectRatio(); }); $img->save($path . $hash . '_' . $value['name'] . '.png'); } } return Response::json(['success' => true, 'thumb' => asset($path . $hash . '_' . $value['name'] . '.png'), 'tmp' => $hash]); } } } $rules = array('category_id' => 'required', 'name' => 'required|min:3', 'price' => 'required|numeric', 'stock' => 'required|integer', 'link' => "required", 'description' => 'required|min:20|max:500', 'content' => 'required|min:20', 'meta_keywords' => 'required', 'images' => 'required'); $validator = Validator::make(Input::all(), $rules); if ($validator->fails()) { $images = Input::get('images'); return Redirect::to("admin/product/{$id}/edit")->with('images', $images)->withErrors($validator)->withInput(Input::except('')); } else { $table = Product::find($id); $images = explode(',', Input::get('images')); $imagesOld = explode(',', $table->images); $delImg = array_diff($imagesOld, $images); foreach ($delImg as $img) { $this->deleteImage($img); } for ($i = 1; $i <= count($images); $i++) { $num = $i - 1; File::move($path . $images[$num] . '.png', "{$tmpPath}{$id}_{$i}.png"); foreach (Config::get('setting.product.image.size') as $value) { File::move($path . $images[$num] . "_{$value['name']}.png", "{$tmpPath}{$id}_{$i}_{$value['name']}.png"); } } $imagesStr = ''; for ($i = 1; $i <= count($images); $i++) { File::move($tmpPath . "{$id}_{$i}.png", "{$path}{$id}_{$i}.png"); foreach (Config::get('setting.product.image.size') as $value) { File::move($tmpPath . "{$id}_{$i}_{$value['name']}.png", "{$path}{$id}_{$i}_{$value['name']}.png"); } if ($i == count($images)) { $imagesStr .= "{$id}_{$i}"; } else { $imagesStr .= "{$id}_{$i},"; } } $table->package_id = Input::get('package_id'); $table->name = Input::get('name'); $table->stock = Input::get('stock'); $table->price = Input::get('price'); $table->currency_id = Input::get('currency_id'); $table->link = Input::get('link'); $table->description = Input::get('description'); $table->content = Input::get('content'); $table->images = $imagesStr; $table->meta_title = Input::get('meta_title') ? Input::get('name') : $table->title; $table->meta_description = Input::get('meta_description') ? Input::get('meta_description') : $table->description; $table->meta_keywords = Input::get('meta_keywords'); $table->active = Input::get('active', 0); if ($table->save()) { $category = Category::find(Input::get('category_id')); $product = Product::find($id); $product->categories()->detach(); $product->categories()->attach($category); $name = trans("name.product"); return Redirect::to("admin/product")->with('success', trans("message.{$this->action}", ['name' => $name])); } return Redirect::to("admin/product")->with('error', trans('message.error')); } } $table = Product::find($id); foreach (Category::all()->toArray() as $category) { $categories["{$category['id']}"] = $category['title']; } $tvPackages = array(0 => '---') + TvPackage::lists('name', 'id'); //var_dump($tvPackages); die; return View::make("admin.shop.product.edit", ['item' => Product::find($id), 'images' => $table->images, 'name' => $this->name, 'categories' => $categories, 'tvPackages' => $tvPackages]); }
<?php $oldFolder = storage_path('app'); $newFolder = storage_path(config('coaster::site.storage_path')); $filesToMove = ['install.txt', 'update.log', 'assets.json']; foreach ($filesToMove as $fileToMove) { if (file_exists($oldFolder . '/' . $fileToMove)) { File::move($oldFolder . '/' . $fileToMove, $newFolder . '/' . $fileToMove); } }
private function downloadCSSFramework() { if ($this->configSettings['downloads']['bootstrap']) { $ch = curl_init("https://github.com/twbs/bootstrap/releases/download/v3.1.1/bootstrap-3.1.1-dist.zip"); $fp = fopen("public/bootstrap.zip", "w"); curl_setopt($ch, CURLOPT_FILE, $fp); curl_setopt($ch, CURLOPT_HEADER, 0); curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true); curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false); curl_exec($ch); curl_close($ch); fclose($fp); $zip = zip_open("public/bootstrap.zip"); if ($zip) { while ($zip_entry = zip_read($zip)) { $foundationFile = "public/" . zip_entry_name($zip_entry); $foundationDir = dirname($foundationFile); $this->fileCreator->createDirectory($foundationDir); if ($foundationFile[strlen($foundationFile) - 1] == "/") { if (!is_dir($foundationDir)) { \File::makeDirectory($foundationDir); } } else { $fp = fopen($foundationFile, "w"); if (zip_entry_open($zip, $zip_entry, "r")) { $buf = zip_entry_read($zip_entry, zip_entry_filesize($zip_entry)); fwrite($fp, "{$buf}"); zip_entry_close($zip_entry); fclose($fp); } } } zip_close($zip); \File::delete('public/bootstrap.zip'); $dirPath = 'public/bootstrap-3.1.1-dist'; $this->fileCreator->copyDirectory($dirPath, 'public/bootstrap'); foreach (new \RecursiveIteratorIterator(new \RecursiveDirectoryIterator($dirPath, \FilesystemIterator::SKIP_DOTS), \RecursiveIteratorIterator::CHILD_FIRST) as $path) { $path->isFile() ? unlink($path->getPathname()) : rmdir($path->getPathname()); } rmdir($dirPath); } $fileReplace = "\t<link href=\"{{ url('bootstrap/css/bootstrap.min.css') }}\" rel=\"stylesheet\">\n"; $fileReplace .= "\t<style>\n"; $fileReplace .= "\t\tbody {\n"; $fileReplace .= "\t\tpadding-top: 60px;\n"; $fileReplace .= "\t\t}\n"; $fileReplace .= "\t</style>\n"; $fileReplace .= "\t<link href=\"{{ url('bootstrap/css/bootstrap-theme.min.css') }}\" rel=\"stylesheet\">\n"; $fileReplace .= "<!--[css]-->\n"; $this->fileContents = str_replace("<!--[css]-->", $fileReplace, $this->fileContents); $this->fileContents = str_replace("<!--[javascript]-->", "<script src=\"{{ url('bootstrap/js/bootstrap.min.js') }}\"></script>\n<!--[javascript]-->", $this->fileContents); } else { if ($this->configSettings['downloads']['foundation']) { $ch = curl_init("http://foundation.zurb.com/cdn/releases/foundation-5.2.2.zip"); $fp = fopen("public/foundation.zip", "w"); curl_setopt($ch, CURLOPT_FILE, $fp); curl_setopt($ch, CURLOPT_HEADER, 0); curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true); curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false); curl_exec($ch); curl_close($ch); fclose($fp); $zip = zip_open("public/foundation.zip"); if ($zip) { while ($zip_entry = zip_read($zip)) { $foundationFile = "public/" . zip_entry_name($zip_entry); $foundationDir = dirname($foundationFile); $this->fileCreator->createDirectory($foundationDir); $fp = fopen("public/" . zip_entry_name($zip_entry), "w"); if (zip_entry_open($zip, $zip_entry, "r")) { $buf = zip_entry_read($zip_entry, zip_entry_filesize($zip_entry)); fwrite($fp, "{$buf}"); zip_entry_close($zip_entry); fclose($fp); } } zip_close($zip); \File::delete('public/index.html'); \File::delete('public/robots.txt'); \File::delete('humans.txt'); \File::delete('foundation.zip'); \File::deleteDirectory('public/js/foundation'); \File::deleteDirectory('public/js/vendor'); \File::move('public/js/foundation.min.js', 'public/js/foundation.js'); } $fileReplace = "\t<link href=\"{{ url ('css/foundation.min.css') }}\" rel=\"stylesheet\">\n<!--[css]-->"; $this->fileContents = str_replace("<!--[css]-->", $fileReplace, $this->fileContents); $this->fileContents = str_replace("<!--[javascript]-->", "<script src=\"{{ url ('/js/foundation.js') }}\"></script>\n<!--[javascript]-->", $this->fileContents); } } }
public function postcvNew() { $flag_save = \Input::get('flag_save'); $exp_type = \Input::get('exp_type'); //return \Input::get('rel'); //return \Input::get('title'); if ($flag_save == "cv_exp_delete") { $ser = \Input::get('ser2'); //$cv_exp->delete($ser); $affectedRows = CvExp::where('ser', '=', $ser)->delete(); } if ($flag_save == "cv_exp") { if ($exp_type != -1) { $user2 = \Auth::user()->id; $cv_exp = new CvExp(); $fdate = new \Carbon\Carbon(\Input::get('from_date')); $todate = new \Carbon\Carbon(\Input::get('to_date')); if ($fdate < $todate) { $cv_exp = CvExp::create(array('id' => $user2, 'title' => \Input::get('title'), 'desc' => \Input::get('desc'), 'tag_id' => \Input::get('tags'), 'exp_type' => \Input::get('exp_type'), 'from_date' => $fdate, 'to_date' => $todate)); $cv_exp->save(); } } } if ($flag_save == "user") { //// Eng info $user_id = \Auth::user()->id; $user = User::find($user_id); $avatar = \Input::get('avatar'); $user->phonenumber = \Input::get('cv_eng_phone'); $user->email = \Input::get('cv_email'); //$user->photo = \Input::get('avatar'); if ($avatar != '') { \File::move(public_path() . '/img/avatar/temp/' . $avatar, 'img/avatar/' . $avatar); /* if ($user->photo) { \File::delete(public_path().'/img/avatar/'.$user->photo); }*/ $user->photo = $avatar; } $user->save(); /// end Eng ifno } ///////////////////////////////////////////////////// if ($flag_save == "cv") { $user = \Auth::user()->id; $fuser = Cv::find($user); if (!empty($fuser)) { $z = \Input::file('cv_attachment'); $z = "CV_" . $user; $user = \Auth::user()->id; $cv = Cv::find($user); $cv->cv_title = \Input::get('cv_title'); $cv->cv_summary = \Input::get('cv_summary'); if (\Input::hasFile('cv_attachment')) { $size = \Input::file('cv_attachment')->getSize(); $mime = \Input::file('cv_attachment')->getMimeType(); if ($size < 500000) { if ($mime == "application/msword") { \Input::file('cv_attachment')->move("img/CV/", $z); $cv->cv_attachment = $z; } elseif ($mime == "application/pdf") { \Input::file('cv_attachment')->move("img/CV/", $z); $cv->cv_attachment = $z; } } } $cv->save(); } else { $cv = Cv::create(array('id' => $user, 'cv_title' => \Input::get('cv_title'), 'cv_summary' => \Input::get('cv_summary'), 'cv_attachment' => \Input::file('cv_attachment'))); $cv->save(); } } return \Redirect::to('user/cv/new'); }
/** * cleanup structure and move files */ public function moveFontelloFiles() { $this->_clearDirectory(array('assets/fontello', 'fontello')); foreach (glob($this->_fontelloStorage . 'fontello-*/*', GLOB_NOSORT) as $file) { if (str_contains($file, 'config.json')) { if (\File::exists(public_path('fontello/') . 'config.json')) { \File::delete(public_path('fontello/') . 'config.json'); } \File::move($file, public_path('fontello/') . 'config.json'); } if (is_dir($file)) { foreach (glob($file) as $index => $path) { $fileName = explode('/', $path); \File::move($path, public_path('assets/fontello/') . end($fileName)); } } } \File::deleteDirectory($this->_fontelloStorage); }