/** * Store a newly created resource in storage. * * @return Response */ public function store() { $file = Request::file('xmlfile'); $type = Input::get('type'); $userid = Input::get('userid'); $alpha = Input::get('alpha'); $extension = $file->getClientOriginalExtension(); $oname = $file->getClientOriginalName(); Storage::disk('local')->put("uploads/" . $file->getClientOriginalName(), File::get($file)); $parser = new Parser(); $contents = Storage::get("uploads/" . $file->getClientOriginalName()); $rawxml = $parser->xml($contents); $importer = new Importer(); if ($type == 'recipes') { $importer->parseRecipe($rawxml, $userid, $alpha, 1); } if ($type == 'blocks') { $importer->parseBlocks($rawxml, $userid, $alpha, 1); } if ($type == 'materials') { $importer->parseMaterial($rawxml, $userid, $alpha, 1); } if ($type == 'items') { $importer->parseItems($rawxml, $userid, $alpha, 1); } //Flash::success('You successfully imported a '.$type.' xml file for 7 Days to Die Alpha '.$alpha.'!'); return view('pages.import'); }
/** * Read last visited timestamp from file and return * timestamp as Carbon object or return zero. * * @return int|\Carbon\Carbon */ protected function getLastVisit() { if (Storage::exists('visited.txt')) { return Carbon::createFromTimestamp(Storage::get('visited.txt')); } return 0; }
/** * Norwegian map with municipalities where Alternativet is represented highlighted */ public function membersMapNorway() { $data = ""; if (!Storage::exists('members-norway-map.svg') || Storage::lastModified('members-norway-map.svg') <= time() - 60 * 60 * 24) { $svg = simplexml_load_file(base_path() . '/resources/svg/Norway_municipalities_2012_blank.svg'); // Determine which municipalities there are members in $result = DB::select(DB::raw("\n select postal_areas.municipality_code, count(*) as count\n from users\n left join postal_areas\n on (users.postal_code = postal_areas.postal_code)\n group by municipality_code")); $municipalities = []; foreach ($result as $row) { if ($row->municipality_code) { $municipalities[] = $row->municipality_code; } } foreach ($svg->g as $county) { foreach ($county->path as $path) { if (in_array($path['id'], $municipalities)) { // There are members in this municipality $path['style'] = 'fill:#0f0;fill-opacity:1;stroke:none'; } else { $path['style'] = 'fill:#777;fill-opacity:1;stroke:none'; } } } $data = $svg->asXML(); Storage::put('members-norway-map.svg', $data); } if (empty($data)) { $data = Storage::get('members-norway-map.svg'); } return response($data)->header('Content-Type', 'image/svg+xml'); }
/** * Get the raw page content * @param string $path file path * @return string */ public function getRawPageContent($path) { $content = null; if (Storage::exists($path) === true) { $content = Storage::get($path); } return $content; }
public function GetColumnAudioSample($syllabaryId, $columnId) { $column = SyllabaryColumnHeader::where('syllabary_id', '=', $syllabaryId)->where('id', '=', $columnId)->first(); if ($column == NULL || $column->audio_sample == NULL) { return ''; } return response()->make(Storage::get($column->audio_sample)); }
/** * Bind data to the view. * * @param View $view * * @return void */ public function compose(View $view) { $locale = app()->getLocale(); $filename = Request::route()->getName() . '.md'; $filepath = 'userhelp' . DIRECTORY_SEPARATOR . $locale . DIRECTORY_SEPARATOR . $filename; $help = Storage::exists($filepath) ? Markdown::convertToHtml(Storage::get($filepath)) : ''; $view->with('help', $help); }
/** * Handle an incoming request. * * @param \Illuminate\Http\Request $request * @param \Closure $next * @return mixed */ public function handle($request, Closure $next) { if (!Cache::has('settings')) { $settings = json_decode(Storage::get('settings.json'), true); Cache::forever('settings', $settings); } return $next($request); }
/** * Display the specified resource. * * @param int $id * @return \Illuminate\Http\Response */ public function show($path) { $entry = FileEntry::where('filename', '=', $path)->first(); if ($entry == null || !Storage::exists($path)) { return response('NotFound', 404); } else { $file = Storage::get($entry->filename); return response($file)->header('Content-Type', $entry->mime); } }
public function get($filename) { $path = config('images.path') . $filename; if (!Storage::exists($path)) { throw new ImageNotFoundHttpException(); } $data = Storage::get($path); $mime = finfo_buffer(finfo_open(FILEINFO_MIME_TYPE), $data); return Response::make($data)->header('Content-Type', $mime)->header('Content-Length', strlen($data)); }
public static function cards() { $sets = json_decode(Storage::get('raw.json'), true); foreach ($sets as $cards) { foreach ($cards as $card) { unset($card['mechanics']); HearthstoneCards::create($card); } } }
/** * Crée un RSS a partir du flux (fb ou non) et le store * @param $feed : feed got from the database * @return string * @throws \Facebook\FacebookRequestException */ public function getRSS($feed) { //get directly the rss in the storage if exists if (Storage::exists($this->rssDirectory . 'feed_' . $feed->id . '.xml')) { return Storage::get($this->rssDirectory . 'feed_' . $feed->id . '.xml'); } //if it's a facebook page : convert to rss if ($feed->is_facebook) { $url = parse_url($feed->url); $page = $url['path']; $application = array('app_id' => getenv('FACEBOOK_APP_ID'), 'app_secret' => getenv('FACEBOOK_APP_SECRET')); FacebookSession::setDefaultApplication($application['app_id'], $application['app_secret']); $session = new FacebookSession($application['app_id'] . '|' . $application['app_secret']); $request = new FacebookRequest($session, 'GET', '/' . $page . '/feed'); $response = $request->execute(); $graphObject = $response->getGraphObject(); $facebook_feed = $graphObject->asArray(); $xml = ' <?xml version="1.0"?> <rss version="2.0"> <channel> <title>RSS ' . $feed->name . '</title> <description></description> '; foreach ($facebook_feed['data'] as $entry) { //récupere l'id de la page et l'id du post $ids = explode('_', $entry->id); if ($entry->from->id == $ids[0] && isset($entry->message)) { //si il y a un message et que la page est auteur $title = Str::words($entry->message, 20, '...'); //limit mots $pubDate = date("D, d M Y H:i:s T", strtotime($entry->created_time)); $item = ' <item> <title><![CDATA[' . $title . ']]></title> <link>http://www.facebook.com/' . $ids[0] . '/posts/' . $ids[1] . '</link> <pubDate>' . date("r", strtotime($pubDate)) . '</pubDate> </item>'; $xml .= $item; } } $xml .= '</channel></rss>'; } else { $context = stream_context_create(array('http' => array('user_agent' => 'Mozilla/5.0 (Windows NT 5.1) AppleWebKit/536.11 (KHTML, like Gecko) Chrome/20.0.1132.57 Safari/536.11'))); $xml = @file_get_contents($feed->url, FALSE, $context); } $xml = trim($xml); // if the file is not xml return false $xml_is_valid = @simplexml_load_string($xml); if (!$xml_is_valid) { throw new \Exception('invalid xml'); } Storage::put($this->rssDirectory . 'feed_' . $feed->id . '.xml', $xml); return $xml; }
public function download(Request $request, $original_filename) { $entry = FileEntry::where('original_filename', '=', $original_filename)->firstOrFail(); if (Storage::has($request->user()->id . '/' . $entry->original_filename)) { $file = Storage::get($request->user()->id . '/' . $entry->original_filename); return (new Response($file, 200))->header('Content-Description', 'File Transfer')->header('Content-Type', $entry->mime)->header('Content-Disposition', 'attachment; filename=' . $entry->original_filename)->header('Content-Transfer-Encoding', 'binary')->header('Connection', 'Keep-Alive')->header('Expires', 0)->header('Cache-Control', 'must-revalidate, post-check=0, pre-check=0')->header('Pragma', 'public')->header('Content-Length', $entry->size); // ->header('Content-Type', $entry->mime); } $sys_notifications[] = array('type' => 'danger', 'message' => 'O arquivo não existe!'); $request->session()->flash('sys_notifications', $sys_notifications); return back()->withInput($request->all()); }
/** * Display the specified resource. * * @param int $filename * @return Response */ public function show($filename) { $publicMessageFile = PublicMessageFile::whereFilename($filename)->firstOrFail(); $file = Storage::get($publicMessageFile->filepath); $headers = array(); $headers['Content-type'] = $publicMessageFile->mime; // force the file to download if its not an image if (!$publicMessageFile->isImage()) { $headers['Content-Disposition'] = 'attachment; filename="' . $publicMessageFile->filename . '"'; } return response($file, 200, $headers); }
/** * Run the database seeds. * * @return void */ public function run() { $modules = json_decode(Storage::get('packages.json')); foreach ($modules as $module) { $module = Module::create(['packname' => $module->packname, 'provider' => $module->provider, 'name' => $module->name, 'status' => $module->status, 'icon' => $module->icon, 'tables' => $module->tables, 'seeder' => $module->seeder, 'description' => $module->description]); if ($module->status > 0) { if (!$module->checkMigration()) { Artisan::call('vendor:publish'); Artisan::call('migrate'); Artisan::call('db:seed', ["--class" => $module->seeder]); } } } }
/** * Run the database seeds. * * @return void */ public function run() { $json = Storage::get('questions.json'); $this->command->info($json); $questions = json_decode($json, true); foreach ($questions['questions'] as $question_keys => $question) { $this->command->info("Adding Question: " . $question_keys . "..."); if ($question["type"] != "true-false") { $answers = $question['answers']; unset($question['answers']); } $q = new Question($question); $q->save(); foreach ($question as $question_attribute_name => $question_attribute_value) { $this->command->info($question_attribute_name); } if ($q->type == "true-false") { $this->command->info("Adding True/False Question..."); $answer = $question['answer']; $aFalse; $aTrue; if (Answer::where('text', 'true')->count() >= 1) { $aTrue = Answer::where('text', 'true')->first(); } else { $aTrue = new Answer(['text' => 'true']); $aTrue->save(); } if (Answer::where('text', 'false')->count() >= 1) { $aFalse = Answer::where('text', 'false')->first(); } else { $aFalse = new Answer(['text' => 'false']); $aFalse->save(); } $q->answers()->save($aFalse, ['is_correct' => $answer ? 0 : 1]); $q->answers()->save($aTrue, ['is_correct' => $answer ? 1 : 0]); } else { $this->command->info("Adding answers..."); $answer_ids = array(); foreach ($answers as $answer_index => $answer) { $this->command->info("Adding " . ($answer_index + 1) . "..."); $a = new Answer($answer); $a->save(); $q->answers()->save($a, ['is_correct' => $answer['is_correct'] === "false" ? 0 : 1]); } } $this->command->info(""); } }
/** * Show the requestet file and calculate headers * * @param string $filename * @return mixed */ public function show($filename) { $path = getUploadDirectory() . '/' . $filename . '/default'; if (Storage::exists($path)) { clearstatcache(); $file = Storage::get($path); $lastModified = filemtime(storage_path('/app/') . $path); $etagFile = md5_file(storage_path('/app/') . $path); $etagHeader = isset($_SERVER['HTTP_IF_NONE_MATCH']) ? trim($_SERVER['HTTP_IF_NONE_MATCH']) : false; $responseCode = 200; if (@strtotime($_SERVER['HTTP_IF_MODIFIED_SINCE']) == $lastModified || $etagHeader == $etagFile) { $responseCode = 304; } return response($file, $responseCode)->header('Content-Type', getFileContentTypeByFilename($filename))->header('Last-Modified', gmdate('D, d M Y H:i:s', $lastModified) . ' GMT')->header('Etag', $etagFile)->header('Cache-Control', 'public'); } abort(404); }
/** * @return Boek[] * @throws Exception */ public function retreive() { if (Storage::exists($this->database)) { $objectedBoeken = json_decode(Storage::get($this->database)); if ($objectedBoeken || is_array($objectedBoeken)) { $boeken = []; foreach ($objectedBoeken as $boekObject) { $boek = new Boek(); $boek->setId($boekObject->id)->setIsbn($boekObject->isbn)->setTitel($boekObject->titel)->setGewicht((int) $boekObject->gewicht)->setIntroductie($boekObject->introductie); $boeken[$boek->getId()] = $boek; } return $boeken; } else { throw new Exception('Database error: wrong file format'); } } return []; }
/** * Restore attributes collection * @return Collection */ private function getCollection() { if ($this->__laCollection == null) { $cached_collection = Cache::rememberForever($this->getCacheQuequeMask(), function () { if (config('lauser.save_type') == 'file') { $path = $this->getLaUserFilePathById($this->id); if (Storage::exists($path)) { return new Collection(json_decode(Storage::get($path), true)); } else { return new Collection([]); } } else { return new Collection($this->getLaUserAttributesFromDatabase($this->id)); } }); $this->__laCollection = $cached_collection; } return $this->__laCollection; }
/** * Execute the console command. * * @return mixed */ public function handle() { $tables = ['maven_faqs', 'maven_tags', 'maven_unique_keys']; $dt = Carbon::now(); foreach ($tables as $table) { \DB::table($table)->truncate(); $json = Storage::get('maven/' . $table . '.json'); if (!empty($json)) { $json_data = json_decode($json, true); if (count($json_data) > 0) { foreach ($json_data as $json_values) { $json_values['created_at'] = $dt; $json_values['updated_at'] = $dt; \DB::table($table)->insert($json_values); } } $this->info('"' . $table . '" imported!'); } } }
/** * this is the only method u need to call from ur controller. * * @param [type] $new_name [description] * * @return [type] [description] */ public function upload_files() { $adapter = new GoogleDriveAdapter($this->service, Cache::get('folder_id')); $filesystem = new Filesystem($adapter); // here we are uploading files from local storage // we first get all the files $files = Storage::files(); // loop over the found files foreach ($files as $file) { // remove file from google drive in case we have something under the same name // comment out if its okay to have files under the same name $this->remove_duplicated($file); // read the file content $read = Storage::get($file); // save to google drive $filesystem->write($file, $read); // remove the local file Storage::delete($file); } }
/** * Store a newly created resource in storage. * * @param Request $request * @return Response */ public function store(Request $request) { // $this->validate($request, ['သီခ်င္းေခါင္းစဥ္' => 'required|max:1000', 'image' => 'required|mimes:jpeg,png,jpg', 'singer' => 'required|max:255', 'content' => 'required']); $singlemusic = new SingleMusic(); $singlemusic->title = $request->input('သီခ်င္းေခါင္းစဥ္'); $singlemusic->image = $request->input('photo'); $singlemusic->singer = $request->input('singer'); $singlemusic->mtv = $request->input('mtv'); $mp3path = public_path() . '/upload/mp3'; if (\Input::hasfile('mp3')) { if (\Input::file('mp3')->getClientOriginalExtension() != "mp3") { $error = array(); $error[] = "File type must be mp3"; $validator = $error; return redirect()->route('music.create')->withInput()->withErrors($validator); } else { $mp3name = \Input::file('mp3')->getClientOriginalname(); $mp3rename = str_random(20); \Input::file('mp3')->move($mp3path, $mp3rename); $uploadedfile = Storage::get($mp3rename); Storage::disk('s3')->put($mp3name, $uploadedfile); \File::delete(public_path() . "/upload/mp3/" . $mp3rename); $singlemusic->mp3 = "https://s3-us-west-2.amazonaws.com/myanmarmusicart/" . $mp3name; } } $imagepath = public_path() . '/upload/image'; $imagename = \Input::file('image')->getClientOriginalExtension(); $imgrename = str_random(20); $imgFileName = $imgrename . "." . $imagename; \Input::file('image')->move($imagepath, $imgrename . "." . $imagename); $singlemusic->language = $request->input('language'); $singlemusic->categories = $request->input('categories'); $singlemusic->content = $request->input('content'); $singlemusic->author = Auth::user()->nickname; $singlemusic->image = asset('/upload/image/' . $imgrename . "." . $imagename); $singlemusic->imageName = $imgFileName; $singlemusic->save(); return redirect()->route('music.index'); }
/** * Execute the job. * * @return void */ public function handle() { $google = App::make('App\\Services\\Google'); $client = $google->getClient(); $client->setAccessToken($this->image->user->access_token); $service = new Google_Service_Drive($client); $file = new Google_Service_Drive_DriveFile(); $file->setTitle($this->image->filename); $file->setMimeType($this->image->mime_type); $data = Storage::get('images/' . $this->image->path); $createdFile = $service->files->insert($file, ['data' => $data, 'ocr' => true, 'mimeType' => $file->getMimeType(), 'uploadType' => 'multipart']); $exportLinks = $createdFile->getExportLinks(); $plainTextUrl = $exportLinks['text/plain']; $request = new Google_Http_Request($plainTextUrl, 'GET', null, null); $httpRequest = $service->getClient()->getAuth()->authenticatedRequest($request); if ($httpRequest->getResponseHttpCode() == 200) { $this->image->text = $httpRequest->getResponseBody(); $this->image->status = Image::STATUS_COMPLETE; $this->image->save(); $service->files->delete($createdFile->getId()); } }
/** * Send email to admin * * @param Request $request * @return string */ public function postSend(Request $request) { $input = $request->all(); $validator = Validator::make($input, ['name' => 'required|max:70', 'surname' => 'max:70', 'email' => 'required|email', 'message' => 'required', 'image' => 'mimes:jpeg,bmp,png']); if (!$validator->fails()) { $image = $request->file('image'); Mail::send('message', ['msg' => $input["message"]], function ($message) use($input, $image) { $admin = Storage::get('admin.txt'); $name = $input["name"] . " " . $input["surname"]; $message->from($input["email"], $name); $message->to($admin)->subject('Support Request'); if ($image) { $mime = $image->getMimeType(); $filename = $image->getClientOriginalName(); $message->attach($image, ['as' => $filename, 'mime' => $mime]); } }); return "Your message Has been successfully sent! <a href='/'>Return</a>"; } else { exit("Your input is not correct! <a href='/'>Return</a>"); } }
public function index() { $keywords = Storage::get('filter.txt'); return view('admin.keyword.index', compact('keywords')); }
/** * Render file specified by path. * * @param Request $request * * @return \Illuminate\Http\Response */ public function render(Request $request) { $path = $request->get('path'); return Storage::get($path); }
/** * Download action * * @return mixed */ public function download() { $filename = config('data.filename'); return response(Storage::get($filename))->header('Content-Type', 'application/pdf')->header('Content-Length', Storage::size($filename)); }
/** * Display a listing of the resource. * * @return Response */ public function getIndex() { $settings = json_decode(Storage::get('settings.json')); return view('admin.settings.index', compact('settings')); }
/** * Display a listing of the resource. * * @return \Illuminate\Http\Response */ public function index(Filesystem $filesystem) { $file = Storage::get('asian_1.jpg'); $image = Image::make($file); return $image->response(); }
public function getRealPathAttribute() { Storage::get($this->path); }
/** * Display the specified resource. * * @param int $id * @return Response */ public function show($id) { $mime = File::mimeType(storage_path('app/comprovante_aporte/' . $id)); if (Storage::exists('app/comprovante_aporte/' . $id)) { return 'Arquivo não encontrado'; } $contents = Storage::get('comprovante_aporte/' . $id); return (new Response($contents, 200))->header('Content-Type', 'image/png'); // dd($contents); }