コード例 #1
0
 public function store()
 {
     $rules = ["project_name" => "required|alpha_dash", "asset_name" => "alpha_dash", "image_name" => "alpha_dash", "css_name" => "alpha_dash", "js_name" => "alpha_dash", "plugin_name" => "alpha_dash"];
     $validator = Validator::make(Input::all(), $rules);
     if ($validator->fails()) {
         return \Redirect::route("generate")->withInput()->withErrors($validator);
     }
     $asset_name = Input::has("asset_name") ? Input::get("asset_name") : "assets";
     $css_name = Input::has("css_name") ? Input::get("css_name") : "css";
     $image_name = Input::has("image_name") ? Input::get("image_name") : "images";
     $js_name = Input::has("js_name") ? Input::get("js_name") : "js";
     $plugin_name = Input::has("plugin_name") ? Input::get("plugin_name") : "plugins";
     $favicon = Input::has("favicon") && Input::get("favicon") != "" ? true : false;
     $opengraph = Input::has("opengraph") && Input::get("opengraph") != "" ? true : false;
     $twittercard = Input::has("twittercard") && Input::get("twittercard") != "" ? true : false;
     $jquery = Input::has("jquery") && Input::get("jquery") != "" ? true : false;
     $jqueryui = Input::has("jqueryui") && Input::get("jqueryui") != "" ? true : false;
     $normalize = Input::has("normalize") && Input::get("normalize") != "" ? true : false;
     $meyerreset = Input::has("meyerreset") && Input::get("meyerreset") != "" ? true : false;
     $fontawesome = Input::has("fontawesome") && Input::get("fontawesome") != "" ? true : false;
     $animate = Input::has("animate") && Input::get("animate") != "" ? true : false;
     $bootstrap = Input::has("bootstrap") && Input::get("bootstrap") != "" ? true : false;
     $prettyphoto = Input::has("prettyphoto") && Input::get("prettyphoto") != "" ? true : false;
     $indexContent = \View::make("source")->with(array("project_name" => Input::get("project_name"), "asset_name" => $asset_name, "image_name" => $image_name, "css_name" => $css_name, "js_name" => $js_name, "plugin_name" => $plugin_name, "favicon" => $favicon, "opengraph" => $opengraph, "twittercard" => $twittercard, "jquery" => $jquery, "jqueryui" => $jqueryui, "normalize" => $normalize, "meyerreset" => $meyerreset, "fontawesome" => $fontawesome, "animate" => $animate, "bootstrap" => $bootstrap, "prettyphoto" => $prettyphoto));
     $zipname = str_random(40);
     $zip = Zipper::make(public_path() . "/projects/" . $zipname . ".zip");
     $zip->addString("index.html", $indexContent);
     $zip->folder($asset_name . "/" . $css_name)->addString("custom.css", null);
     $zip->folder($asset_name . "/" . $css_name)->addString("core.css", null);
     $zip->folder($asset_name . "/" . $js_name)->addString("custom.js", null);
     $zip->folder($asset_name . "/" . $js_name)->addString("core.js", null);
     if ($favicon) {
         $zip->folder($asset_name . "/" . $image_name)->addString("favicon.ico", null);
     }
     if ($animate) {
         $zip->folder($asset_name . "/" . $plugin_name . "/animate")->add(storage_path() . "/assets/animate/");
     }
     if ($bootstrap) {
         $zip->folder($asset_name . "/" . $plugin_name . "/bootstrap")->add(storage_path() . "/assets/bootstrap/");
     }
     if ($jquery) {
         $zip->folder($asset_name . "/" . $plugin_name . "/jquery")->add(storage_path() . "/assets/jquery/");
     }
     if ($jqueryui) {
         $zip->folder($asset_name . "/" . $plugin_name . "/jqueryui")->add(storage_path() . "/assets/jqueryui/");
     }
     if ($meyerreset) {
         $zip->folder($asset_name . "/" . $plugin_name . "/meyerreset")->add(storage_path() . "/assets/meyerreset/");
     }
     if ($normalize) {
         $zip->folder($asset_name . "/" . $plugin_name . "/normalize")->add(storage_path() . "/assets/normalize/");
     }
     if ($prettyphoto) {
         $zip->folder($asset_name . "/" . $plugin_name . "/prettyphoto")->add(storage_path() . "/assets/prettyphoto/");
     }
     $zip->close();
     return ResponseHelper::downloadAndDelete(public_path() . "/projects/" . $zipname . ".zip", Input::get("project_name") . ".zip");
 }
コード例 #2
0
ファイル: SystemBackup.php プロジェクト: chromahoen/snipe-it
 /**
  * Execute the console command.
  *
  * @return mixed
  */
 public function fire()
 {
     //
     $files['avatars'] = glob(public_path() . '/uploads/avatars/*');
     $files['models'] = glob(public_path() . '/uploads/models/*');
     $files['suppliers'] = glob(public_path() . '/uploads/suppliers/*');
     $files['private_uploads'] = glob(app_path() . '/private_uploads/*');
     $base_filename = date('Ymdgis');
     $zip_file = app_path() . '/storage/dumps/' . $base_filename . '-backup.zip';
     $db_dump = Config::get('backup::path') . $base_filename . '-db.sql';
     $this->call('db:backup', array('filename' => $db_dump));
     Zipper::make($zip_file)->folder('avatars')->add($files['avatars'])->folder('models')->add($files['models'])->folder('suppliers')->add($files['suppliers'])->folder('private_uploads')->add($files['private_uploads'])->folder('database')->add($db_dump)->close();
     $this->info('Backup file created at ' . $zip_file);
     $this->info('Removing SQL dump at ' . $db_dump);
     unlink($db_dump);
 }
コード例 #3
0
 /**
  *handle language file uploading
  *@return response  
  */
 public function postForm()
 {
     // getting all of the post data
     $file = array('File' => Input::file('File'), 'language-name' => Input::input('language-name'), 'iso-code' => Input::input('iso-code'));
     // setting up rules
     $rules = array('File' => 'required|mimes:zip|max:30000', 'language-name' => 'required', 'iso-code' => 'required|max:2');
     // and for max size
     // doing the validation, passing post data, rules and the messages
     $validator = Validator::make($file, $rules);
     if ($validator->fails()) {
         // send back to the page with the input data and errors
         return Redirect::back()->withInput()->withErrors($validator);
     } else {
         //Checking if package already exists or not in lang folder
         $path = '../resources/lang';
         if (in_array(Input::get('iso-code'), scandir($path))) {
             //sending back with error message
             Session::flash('fails', "Language package already exists.");
             Session::flash('link', "change-language/" . Input::get('iso-code'));
             return Redirect::back()->withInput();
         } elseif (!array_key_exists(Input::get('iso-code'), Config::get('languages'))) {
             //Checking Valid ISO code form Languages.php
             //sending back with error message
             Session::flash('fails', "Enter correct ISO-code");
             return Redirect::back()->withInput();
         } else {
             // checking file is valid.
             if (Input::file('File')->isValid()) {
                 $name = Input::file('File')->getClientOriginalName();
                 //uploaded file's original name
                 $destinationPath = '../public/uploads/';
                 // defining uploading path
                 $extractpath = '../resources/lang/' . Input::get('iso-code');
                 //defining extracting path
                 mkdir($extractpath);
                 //creating directroy for extracting uploadd file
                 //mkdir($destinationPath);
                 Input::file('File')->move($destinationPath, $name);
                 // uploading file to given path
                 \Zipper::make($destinationPath . '/' . $name)->extractTo($extractpath);
                 //extracting file to give path
                 //check if Zip extract foldercontains any subfolder
                 $directories = File::directories($extractpath);
                 //$directories = glob($extractpath. '/*' , GLOB_ONLYDIR);
                 if (!empty($directories)) {
                     //if extract folder contains subfolder
                     $success = File::deleteDirectory($extractpath);
                     //remove extracted folder and it's subfolder from lang
                     //$success2 = File::delete($destinationPath.'/'.$name);
                     if ($success) {
                         //sending back with error message
                         Session::flash('fails', 'Error in directory structure. Zip file must contain language php files only. Try Again.');
                         return Redirect::back()->withInput();
                     }
                 } else {
                     // sending back with success message
                     Session::flash('success', "uploaded successfully.");
                     Session::flash('link', "change-language/" . Input::get('iso-code'));
                     return Redirect::route('LanguageController');
                 }
             } else {
                 // sending back with error message.
                 Session::flash('fails', 'uploaded file is not valid');
                 return Redirect::route('form');
             }
         }
     }
 }
コード例 #4
0
ファイル: bc.php プロジェクト: hareaca/youtube-mp3
 public function downloadlist(Request $request)
 {
     if ($videos = $request->get('__v_')) {
         $videosSIZE = 0;
         $videosLENGTH = 0;
         $videoINFOARRAY = [];
         foreach ($videos as $videoID) {
             if ($videoINFO = $this->getVIDEOINFO($videoID)) {
                 if (($videoINFO === false || isset($videoINFO->status) === false || strtolower($videoINFO->status) === 'fail') === false) {
                     if ($videURL = $this->getVIDEOURL($videoINFO)) {
                         $videosLENGTH += (int) $videoINFO->length_seconds;
                         $videosSIZE += $this->getFILESIZE($videURL);
                         $videoINFOARRAY[] = (object) ['videoURL' => $videURL, 'title' => $videoINFO->title];
                     }
                 }
             }
         }
         // create an directory for playlist
         $archiveDIRECTORY = "{$this->storagePATH()}{$this->generateRandomFILENAME($this->storagePATH(), null, 8)}";
         mkdir($archiveDIRECTORY, 0777, true);
         $this->TEMPFOLDERS[] = $archiveDIRECTORY;
         // collect progress information
         $progressINFO = (object) ['multiple' => true, 'videosSIZE' => $videosSIZE, 'videosLENGTH' => $videosLENGTH, 'videosDIR' => $archiveDIRECTORY];
         $progressFILE = "{$this->storagePATH()}{$request->get('i')}";
         $this->TEMPFILES[] = $progressFILE;
         File::put($progressFILE, json_encode($progressINFO));
         foreach ($videoINFOARRAY as $videoINFO) {
             $videoFILENAME = "{$archiveDIRECTORY}/{$this->generateRandomFILENAME($archiveDIRECTORY, null, 8)}";
             $mp3FILETITTLE = $this->sanitize($videoINFO->title);
             $mp3FILENAME = "{$archiveDIRECTORY}/{$mp3FILETITTLE}.mp3";
             if ($videoFILE = $this->downloadFILE($videoINFO->videoURL, $videoFILENAME)) {
                 try {
                     $mp3FILE = $this->mp3CONVERT($videoFILE, $mp3FILENAME);
                     $this->TEMPFILES[] = $mp3FILENAME;
                 } catch (\Exception $e) {
                     /* failed to convert video to mp3 */
                 }
             }
         }
         // archive mp3 files
         $archive = "{$this->storagePATH()}{$this->generateRandomFILENAME($this->storagePATH(), 'zip', 8)}";
         \Zipper::make($archive)->add(glob("{$archiveDIRECTORY}/*.mp3"))->close();
         // set up cookie to announce js that download started
         $this->setTOKEN($request->get('t'), $request->get('tv'), false);
         return response()->download($archive)->deleteFileAfterSend(true);
     }
     return 'Whoops! An error occurred.';
 }
コード例 #5
0
 /**
  *handle language file uploading
  *@return response  
  */
 public function postForm()
 {
     // getting all of the post data
     $file = array('File' => Input::file('File'), 'language-name' => Input::input('language-name'), 'iso-code' => Input::input('iso-code'));
     // setting up rules
     $rules = array('File' => 'required|mimes:zip|max:30000', 'language-name' => 'required', 'iso-code' => 'required|max:2');
     // and for max size
     // doing the validation, passing post data, rules and the messages
     $validator = Validator::make($file, $rules);
     if ($validator->fails()) {
         // send back to the page with the input data and errors
         return Redirect::back()->withInput()->withErrors($validator);
     } else {
         //Checking if package already exists or not in lang folder
         $path = '../resources/lang';
         if (in_array(strtolower(Input::get('iso-code')), scandir($path))) {
             //sending back with error message
             Session::flash('fails', Lang::get('lang.package_exist'));
             Session::flash('link', "change-language/" . strtolower(Input::get('iso-code')));
             return Redirect::back()->withInput();
         } elseif (!array_key_exists(strtolower(Input::get('iso-code')), Config::get('languages'))) {
             //Checking Valid ISO code form Languages.php
             //sending back with error message
             Session::flash('fails', Lang::get('lang.iso-code-error'));
             return Redirect::back()->withInput();
         } else {
             // checking file is valid.
             if (Input::file('File')->isValid()) {
                 $name = Input::file('File')->getClientOriginalName();
                 //uploaded file's original name
                 $destinationPath = '../public/uploads/';
                 // defining uploading path
                 $extractpath = '../resources/lang/' . strtolower(Input::get('iso-code'));
                 //defining extracting path
                 mkdir($extractpath);
                 //creating directroy for extracting uploadd file
                 //mkdir($destinationPath);
                 Input::file('File')->move($destinationPath, $name);
                 // uploading file to given path
                 \Zipper::make($destinationPath . '/' . $name)->extractTo($extractpath);
                 //extracting file to give path
                 //check if Zip extract foldercontains any subfolder
                 $directories = File::directories($extractpath);
                 //$directories = glob($extractpath. '/*' , GLOB_ONLYDIR);
                 if (!empty($directories)) {
                     //if extract folder contains subfolder
                     $success = File::deleteDirectory($extractpath);
                     //remove extracted folder and it's subfolder from lang
                     //$success2 = File::delete($destinationPath.'/'.$name);
                     if ($success) {
                         //sending back with error message
                         Session::flash('fails', Lang::get('lang.zipp-error'));
                         Session::flash('link2', "http://www.ladybirdweb.com/support/show/how-to-translate-faveo-into-multiple-languages");
                         return Redirect::back()->withInput();
                     }
                 } else {
                     // sending back with success message
                     Session::flash('success', Lang::get("lang.upload-success"));
                     Session::flash('link', "change-language/" . strtolower(Input::get('iso-code')));
                     return Redirect::route('LanguageController');
                 }
             } else {
                 // sending back with error message.
                 Session::flash('fails', Lang::get("lang.file-error"));
                 return Redirect::route('form');
             }
         }
     }
 }
コード例 #6
0
 /**
  * After plugin post
  * @param Request $request
  * @return type
  */
 public function PostPlugins(Request $request)
 {
     $v = $this->validate($request, ['plugin' => 'required|mimes:application/zip,zip,Zip']);
     $plug = new Plugin();
     $file = $request->file('plugin');
     //dd($file);
     $destination = app_path() . '/Plugins';
     $zipfile = $file->getRealPath();
     /**
      * get the file name and remove .zip
      */
     $filename2 = $file->getClientOriginalName();
     $filename2 = str_replace('.zip', '', $filename2);
     $filename1 = ucfirst($file->getClientOriginalName());
     $filename = str_replace('.zip', '', $filename1);
     mkdir($destination . '/' . $filename);
     /**
      * extract the zip file using zipper
      */
     \Zipper::make($zipfile)->folder($filename2)->extractTo($destination . '/' . $filename);
     $file = app_path() . '/Plugins/' . $filename;
     // Plugin file path
     if (file_exists($file)) {
         $seviceporvider = $file . '/ServiceProvider.php';
         $config = $file . '/config.php';
         if (file_exists($seviceporvider) && file_exists($config)) {
             /**
              * move to faveo config
              */
             $faveoconfig = config_path() . '/plugins/' . $filename . '.php';
             if ($faveoconfig) {
                 //copy($config, $faveoconfig);
                 /**
                  * write provider list in app.php line 128
                  */
                 $app = base_path() . '/config/app.php';
                 $str = "\n\n\t\t\t'App\\Plugins\\{$filename}" . "\\ServiceProvider',";
                 $line_i_am_looking_for = 144;
                 $lines = file($app, FILE_IGNORE_NEW_LINES);
                 $lines[$line_i_am_looking_for] = $str;
                 file_put_contents($app, implode("\n", $lines));
                 $plug->create(['name' => $filename, 'path' => $filename, 'status' => 1]);
                 return redirect()->back()->with('success', 'Installed SuccessFully');
             } else {
                 /**
                  * delete if the plugin hasn't config.php and ServiceProvider.php
                  */
                 $this->deleteDirectory($file);
                 return redirect()->back()->with('fails', 'Their is no ' . $file);
             }
         } else {
             /**
              * delete if the plugin hasn't config.php and ServiceProvider.php
              */
             $this->deleteDirectory($file);
             return redirect()->back()->with('fails', 'Their is no <b>config.php or ServiceProvider.php</b>  ' . $file);
         }
     } else {
         /**
          * delete if the plugin Name is not equal to the folder name
          */
         $this->deleteDirectory($file);
         return redirect()->back()->with('fails', '<b>Plugin File Path is not exist</b>  ' . $file);
     }
 }
コード例 #7
0
 /**
  * CONSTRUYENDO (no usar)
  */
 public function generate_all()
 {
     $data = User::all();
     $ds = DIRECTORY_SEPARATOR;
     $gp = str_replace('/index.php', '', url('assets' . $ds . 'generator') . $ds);
     $stylesheet = file_get_contents($gp . 'liquidacion.css');
     $html = file_get_contents($gp . 'liquidacion.php');
     $time = time();
     mkdir(storage_path($time), 777);
     foreach ($data as $user) {
         $mpdf = new mPDF("en", "Letter", "15");
         $mpdf->WriteHTML($stylesheet, 1);
         $mpdf->WriteHTML(str_replace(['%GP%', '%NOMBRE%', '%RUT%', '%CARGO%'], [$gp, $user->name, $user->rut, '-'], $html), 2);
         $mpdf->Output(storage_path($time . '/planilla-' . $user->rut . '-' . str_replace(' ', '_', $user->name) . '-12-15' . '.pdf'), 'F');
     }
     $mytime = Carbon::now();
     $files = glob(storage_path($time . $ds . '*'));
     $filename = str_replace([' ', ':'], ['_', '-'], storage_path() . $ds . $mytime->toDateTimeString() . '.zip');
     echo $filename;
     \Zipper::make($filename)->add($files);
     File::deleteDirectory(storage_path($time) . $ds . $time);
     exit;
 }