exists() public static method

Determine if a file or directory exists.
public static exists ( string $path ) : boolean
$path string
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
 public function copy($destination, $overwrite = false, $mt = false)
 {
     //    if (dirname($destination) == ".") {
     //      $destination = $this->getDirectory() . DS . $destination;
     //    }
     $destination = $this->preparePath($destination);
     if (strcmp(substr($destination, -1), DS) == 0) {
         $destination .= $this->getName();
     }
     $file = new File($destination);
     $dir = new Directory($file->getDirectory());
     if (!$dir->exists() && !$dir->make()) {
         throw new FileException(array("Directory '%s' not exists.", $dir->getPath()));
     }
     if (!$overwrite && $file->exists()) {
         throw new FileException(array("File '%s' already exists.", $file->getPath()));
     }
     if ($file->exists() && !$file->delete()) {
         throw new FileException(array("File '%s' cannot be deleted.", $file->getPath()));
     }
     if (!copy($this->pathAbsolute, $file->getPathAbsolute())) {
         throw new FileException(array("Failed to copy file '%s'.", $this->path));
     }
     if ($mt) {
         $filemtime = $this->getModificationTime();
         @touch($file->getPathAbsolute(), $filemtime);
     }
     return $file;
 }
 public function build()
 {
     $this->file = wfLocalFile($this->title);
     if ($this->file && $this->file->exists()) {
         $this->fileText();
     }
     return $this->doc;
 }
Example #4
0
 function testSystemCall()
 {
     $command = "touch " . SITE_ROOT_PATH . "/tmp/prova.txt";
     system($command);
     $f = new File("/tmp/prova.txt");
     $this->assertTrue($f->exists(), "Il file non e' stato creato!!");
     if ($f->exists()) {
         $f->delete();
     }
 }
 /**
  * Returns the content of the array in the file.
  *
  * If no array with the specified name exists, an empty array will be returned.
  *
  * @return array Array read from the file.
  */
 function get()
 {
     if ($this->file->exists() == true) {
         @(include $this->file->relPath());
     }
     if (isset(${$this->varname}) == false) {
         ${$this->varname} = array();
     }
     return ${$this->varname};
 }
Example #6
0
 function testBlackHole()
 {
     $f = new File("/" . FRAMEWORK_CORE_PATH . "tests/io/black_hole_test.php");
     $this->assertTrue($f->exists(), "Il file del test non esiste!!");
     $content = $f->getContent();
     $f->delete();
     $this->assertFalse($f->exists(), "Il file del test black hole non e' stato eliminato!!");
     $f->touch();
     $f->setContent($content);
     $this->assertTrue($f->exists(), "Il file del test black hole non e' stato rigenerato!!");
 }
 public function parse()
 {
     $this->setTimeOut();
     $this->cacheFile = new \File($this->cacheFilePath, true);
     if (!$this->cacheFile->exists()) {
         return;
     }
     $this->getCacheFromFile();
     if (empty($this->cacheUrl)) {
         return;
     }
     $this->buildCache();
 }
 /**
  * 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}");
 }
Example #9
0
 /**
  * Handle an incoming request.
  *
  * @param  \Illuminate\Http\Request  $request
  * @param  \Closure  $next
  * @return mixed
  */
 public function handle($request, Closure $next)
 {
     if (\File::exists(base_path() . '/config/invoicer.php')) {
         return $next($request);
     }
     return redirect('install');
 }
 /**
  * Update the specified powerful in storage.
  *
  * @param  int  $id
  * @return Response
  */
 public function update($id)
 {
     $powerful = Powerful::findOrFail($id);
     $rules = array('name' => 'required', 'icon' => 'image');
     $validator = Validator::make($data = Input::all(), $rules);
     if ($validator->fails()) {
         return Redirect::back()->withErrors($validator)->withInput();
     }
     //upload powerful icon
     if (Input::hasFile('icon')) {
         //delete old icon
         if (File::exists($powerful->icon)) {
             File::delete($powerful->icon);
         }
         //create new icon
         $name = md5(time() . Input::file('icon')->getClientOriginalName()) . '.' . Input::file('icon')->getClientOriginalExtension();
         $folder = "public/uploads/powerful";
         Input::file('icon')->move($folder, $name);
         $path = $folder . '/' . $name;
         //update new path
         $data['icon'] = $path;
     } else {
         unset($data['icon']);
     }
     $powerful->update($data);
     return Redirect::route('admin.powerful.index')->with('message', 'Item had updated!');
 }
Example #11
0
 /**
  * Remove the specified company from storage.
  *
  * @param $company
  * @return Response
  */
 public function postDelete($model)
 {
     // Declare the rules for the form validation
     $rules = array('id' => 'required|integer');
     // Validate the inputs
     $validator = Validator::make(Input::All(), $rules);
     // Check if the form validates with success
     if ($validator->passes()) {
         $id = $model->id;
         $model->delete();
         $file_path = public_path() . '/uploads/' . $model->filename;
         $file_ok = true;
         if (File::exists($file_path)) {
             $file_ok = false;
             File::delete($file_path);
             if (!File::exists($file_path)) {
                 $file_ok = true;
             }
         }
         // Was the blog post deleted?
         $Model = $this->modelName;
         $model = $Model::find($id);
         if (empty($model) && $file_ok) {
             // Redirect to the blog posts management page
             return Response::json(['success' => 'success', 'reload' => true]);
         }
     }
     // There was a problem deleting the blog post
     return Response::json(['error' => 'error', 'reload' => false]);
 }
 /**
  * Render a single message content element.
  *
  * @param RenderMessageContentEvent $event
  *
  * @return string
  */
 public function renderContent(RenderMessageContentEvent $event)
 {
     global $container;
     $content = $event->getMessageContent();
     if ($content->getType() != 'downloads' || $event->getRenderedContent()) {
         return;
     }
     /** @var EntityAccessor $entityAccessor */
     $entityAccessor = $container['doctrine.orm.entityAccessor'];
     $context = $entityAccessor->getProperties($content);
     $context['files'] = array();
     foreach ($context['downloadSources'] as $index => $downloadSource) {
         $context['downloadSources'][$index] = $downloadSource = \Compat::resolveFile($downloadSource);
         $file = new \File($downloadSource, true);
         if (!$file->exists()) {
             unset($context['downloadSources'][$index]);
             continue;
         }
         $context['files'][$index] = array('url' => $downloadSource, 'size' => \System::getReadableSize(filesize(TL_ROOT . DIRECTORY_SEPARATOR . $downloadSource)), 'icon' => 'assets/contao/images/' . $file->icon, 'title' => basename($downloadSource));
     }
     if (empty($context['files'])) {
         return;
     }
     $template = new \TwigTemplate('avisota/message/renderer/default/mce_downloads', 'html');
     $buffer = $template->parse($context);
     $event->setRenderedContent($buffer);
 }
Example #13
0
 /**
  * Read a key from the cache
  *
  * @param string $key Identifier for the data
  * @return mixed The cached data, or false if the data doesn't exist, has expired, or if there was an error fetching it
  * @access public
  */
 function read($key)
 {
     // Modifications by webligo
     $key .= '.php';
     // end modifications
     if ($this->__setKey($key) === false || !$this->__init || !$this->__File->exists()) {
         return false;
     }
     if ($this->settings['lock']) {
         $this->__File->lock = true;
     }
     // Modifications by webligo
     $this->__File->open('rb');
     fgets($this->__File->handle);
     // Strip off die
     $key .= '.php';
     // end modifications
     $time = time();
     $cachetime = intval($this->__File->read(11));
     if ($cachetime !== false && ($cachetime < $time || $time + $this->settings['duration'] < $cachetime)) {
         $this->__File->close();
         return false;
     }
     $data = $this->__File->read(true);
     if ($data !== '' && !empty($this->settings['serialize'])) {
         if ($this->settings['isWindows']) {
             $data = str_replace('\\\\\\\\', '\\', $data);
         }
         $data = unserialize((string) $data);
     }
     $this->__File->close();
     return $data;
 }
Example #14
0
 /**
  * Read a key from the cache
  *
  * @param string $key Identifier for the data
  * @return mixed The cached data, or false if the data doesn't exist, has expired, or if there was an error fetching it
  * @access public
  */
 function read($key)
 {
     if ($this->__setKey($key) === false || !$this->__init || !$this->__File->exists()) {
         return false;
     }
     if ($this->settings['lock']) {
         $this->__File->lock = true;
     }
     $time = time();
     $cachetime = intval($this->__File->read(11));
     if ($cachetime !== false && ($cachetime < $time || $time + $this->settings['duration'] < $cachetime)) {
         $this->__File->close();
         $this->__File->delete();
         return false;
     }
     $data = $this->__File->read(true);
     if ($data !== '' && !empty($this->settings['serialize'])) {
         if ($this->settings['isWindows']) {
             $data = str_replace('\\\\\\\\', '\\', $data);
         }
         $data = unserialize((string) $data);
     }
     $this->__File->close();
     return $data;
 }
Example #15
0
File: yaml.php Project: nob/joi
 /**
  * Specifically parses a file
  *
  * @param string  $file  YAML-formatted File to parse
  * @return array
  */
 public static function parseFile($file)
 {
     if (File::exists($file)) {
         return self::parse($file);
     }
     return array();
 }
Example #16
0
 public function testUploadFile()
 {
     $album = $this->Album->init();
     $tmp_file = "/tmp/111111111.jpg";
     # Generate custom image to test upload
     $im = imagecreatetruecolor(120, 20);
     $text_color = imagecolorallocate($im, 233, 14, 91);
     imagestring($im, 1, 5, 5, 'A Simple Text String', $text_color);
     imagejpeg($im, $tmp_file);
     # Generate path to save file
     $file_path = $this->Picture->generateFilePath($album['Album']['id'], 'picturetests.jpg');
     $file = new File($file_path);
     # Get resize options
     $resize_attrs = $this->Picture->getResizeToSize();
     # Upload and save
     $should_return_3 = $this->Picture->uploadFile($file_path, $album['Album']['id'], 'samplepicture.jpg', $tmp_file, $resize_attrs['width'], $resize_attrs['height'], $resize_attrs['action'], true);
     # File was saved?
     $this->assertEqual(3, $should_return_3);
     # File was uploaded?
     $this->assertTrue($file->exists());
     # Should rise exception
     try {
         $this->Picture->uploadFile($file_path, null, 'samplepicture.jpg', $tmp_file, $resize_attrs['width'], $resize_attrs['height'], $resize_attrs['action'], true);
     } catch (ForbiddenException $e) {
         $this->assertEqual($e->getMessage(), "The album ID is required");
     }
 }
Example #17
0
 /**
  * Determine the format of given database
  *
  * @param mixed $db
  */
 function format($db)
 {
     if (empty($db)) {
         return null;
     }
     if (is_array($db)) {
         return 'Array';
     }
     if (!is_string($db)) {
         return null;
     }
     $File = new File($db);
     if ($File->exists()) {
         if ($File->ext() === 'php') {
             return 'PHP';
         }
         $File->open('rb');
         $head = $File->read(4096);
         if (preg_match('/^(\\d{2}:)?[-\\w.+]*\\/[-\\w.+]+:[\\*\\.a-zA-Z0-9]*$/m', $head)) {
             return 'Freedesktop Shared MIME-info Database';
         } elseif (preg_match('/^[-\\w.+]*\\/[-\\w.+]+\\s+[a-zA-Z0-9]*$/m', $head)) {
             return 'Apache Module mod_mime';
         }
     }
     return null;
 }
Example #18
0
 public function __construct($imagePath = "", $width = 0, $height = 0, $extType = "")
 {
     // If you're using the constructor to create an image from a file:
     if ($imagePath != "" and File::exists($imagePath)) {
         if ($width == 0 or $height == 0 or $extType == "") {
             $info = getimagesize($imagePath);
             $this->width = $info[0];
             $this->height = $info[1];
             $this->mime = $info['mime'];
         } else {
             $this->width = $width;
             $this->height = $height;
             switch ($extType) {
                 case "jpg":
                     $this->mime = "image/jpeg";
                     break;
                 case "png":
                     $this->mime = "image/png";
                     break;
                 case "gif":
                     $this->mime = "image/gif";
                     break;
             }
         }
         // Generate Image Object
         switch ($this->mime) {
             case "image/jpeg":
                 $this->resource = imagecreatefromjpeg($imagePath);
                 break;
             case "image/png":
                 $this->resource = imagecreatefrompng($imagePath);
                 break;
             case "image/gif":
                 $this->resource = imagecreatefromgif($imagePath);
                 break;
         }
     } else {
         if ($imagePath == "" and $extType != "") {
             switch ($extType) {
                 case "jpg":
                     $this->mime = "image/jpeg";
                     break;
                 case "png":
                     $this->mime = "image/png";
                     break;
                 case "gif":
                     $this->mime = "image/gif";
                     break;
             }
             if ($this->mime == "") {
                 return;
             }
             $this->width = $width;
             $this->height = $height;
             $this->resource = imagecreatetruecolor($this->width, $this->height);
             $transColor = imagecolorallocatealpha($this->resource, 0, 0, 0, 127);
             imagefill($this->resource, 0, 0, $transColor);
         }
     }
 }
 private function accountUpdate($post)
 {
     try {
         $user = Auth::user();
         if ($uploaded = AdminUploadsController::createImageInBase64String('avatar')) {
             if (!empty($user->photo) && File::exists(Config::get('site.uploads_photo_dir') . '/' . $user->photo)) {
                 File::delete(Config::get('site.uploads_photo_dir') . '/' . $user->photo);
             }
             if (!empty($user->photo) && File::exists(Config::get('site.uploads_thumb_dir') . '/' . $user->thumbnail)) {
                 File::delete(Config::get('site.uploads_thumb_dir') . '/' . $user->thumbnail);
             }
             $user->photo = @$uploaded['main'];
             $user->thumbnail = @$uploaded['thumb'];
         }
         $user->name = $post['name'];
         $user->surname = $post['surname'];
         $user->city = $post['city'];
         $user->phone = $post['phone'];
         $user->sex = $post['sex'];
         $bdate = Carbon::createFromFormat('Y-m-d', $post['yyyy'] . '-' . $post['mm'] . '-' . $post['dd'])->format('Y-m-d 00:00:00');
         $user->bdate = $bdate;
         $user->save();
         $user->touch();
     } catch (Exception $e) {
         return FALSE;
     }
     return TRUE;
 }
    /**
     * @inheritdoc
     */
    public function handle()
    {
        foreach ($this->dumper_config as $class => $file) {
            if (\File::exists($file)) {
                if (!$this->confirm("file {$file} exists, are you sure to OVERWRITE it? [y|N]")) {
                    continue;
                }
                \File::delete($file);
            }
            $instance = new $class();
            $config = FormDumper::dump($instance);
            $php = var_export($config, true);
            $now = date('Y-m-d H:i:s', time());
            $data = <<<DATA
<?php
/**
 * Created by FormDumper
 * Date: {$now}
 */

 return {$php};
DATA;
            \File::append($file, $data);
        }
    }
Example #21
0
 public function buildTemplate($type)
 {
     if (\File::exists('app/views/fields/' . $type . '.blade.php')) {
         return 'fields/' . $type;
     }
     return 'fields/default';
 }
 /**
  * Check if a directory exists, if so delete it
  * @param string $model
  */
 public static function deleteDirectory($model)
 {
     $path = public_path('assets/img/' . $model->getTable() . '/' . $model->id);
     if (\File::exists($path)) {
         \File::deleteDirectory(public_path($path));
     }
 }
 public function update($id, Request $request)
 {
     $validator = Validator::make($request->all(), ['first_name' => 'required', 'last_name' => 'required']);
     if ($validator->fails()) {
         $messages = $validator->messages();
         return Redirect::back()->withErrors($validator)->withInput();
     } else {
         \DB::statement('SET FOREIGN_KEY_CHECKS = 0');
         $supplier = Supplier::find($id);
         $supplier->fill($request->except('_token'));
         $supplier->parent_id = 0;
         if ($request->password != '') {
             $supplier->password = Hash::make($request->password);
         }
         if (Input::hasFile('profileimage')) {
             $file = Input::file('profileimage');
             $imagename = time() . '.' . $file->getClientOriginalExtension();
             if (\File::exists(public_path('upload/supplierprofile/' . $supplier->image))) {
                 \File::delete(public_path('upload/supplierprofile/' . $supplier->image));
             }
             $path = public_path('upload/supplierprofile/' . $imagename);
             $image = \Image::make($file->getRealPath())->save($path);
             $th_path = public_path('upload/supplierprofile/thumb/' . $imagename);
             $image = \Image::make($file->getRealPath())->resize(128, 128)->save($th_path);
             $supplier->image = $imagename;
         }
         $supplier->save();
         \DB::statement('SET FOREIGN_KEY_CHECKS = 1');
         return Redirect::route('supplier_master_list')->with('succ_msg', 'Supplier has been created successfully!');
     }
 }
Example #24
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']);
     }
 }
Example #25
0
File: Dba.php Project: schpill/thin
 public function __construct($database, $readonly = true, $useCache = true)
 {
     $this->useCache = $useCache;
     $file_exists = File::exists($database);
     if (!$file_exists) {
         $readonly = false;
     }
     if ($readonly) {
         $opt = 'rl';
         if (!is_readable($database)) {
             throw new Exception('database is not readable: ' . $database);
             return false;
         }
     } else {
         $opt = 'cl';
         if ($file_exists) {
             if (!is_writable($database)) {
                 throw new Exception('database is not writeable: ' . $database);
                 return false;
             }
         } else {
             if (!is_writable(dirname($database))) {
                 throw new Exception('database is not inside a writeable directory: ' . $database);
                 return false;
             }
         }
     }
     $this->dbHandler = dba_open($database, $opt, self::HANDLER);
     if (!$this->dbHandler) {
         throw new Exception('cannot open database: ' . $database);
         return false;
     }
     return $this;
 }
Example #26
0
 /**
  * Execute the console command.
  *
  * @return void
  */
 public function fire()
 {
     // if clean option is checked empty iSeed template in DatabaseSeeder.php
     if ($this->option('clean')) {
         app('iseed')->cleanSection();
     }
     $tables = explode(",", $this->argument('tables'));
     $chunkSize = intval($this->option('max'));
     if ($chunkSize < 1) {
         $chunkSize = null;
     }
     foreach ($tables as $table) {
         $table = trim($table);
         // generate file and class name based on name of the table
         list($fileName, $className) = $this->generateFileName($table);
         // if file does not exist or force option is turned on generate seeder
         if (!\File::exists($fileName) || $this->option('force')) {
             $this->printResult(app('iseed')->generateSeed($table, $this->option('database'), $chunkSize), $table);
             continue;
         }
         if ($this->confirm('File ' . $className . ' already exist. Do you wish to override it? [yes|no]')) {
             // if user said yes overwrite old seeder
             $this->printResult(app('iseed')->generateSeed($table, $this->option('database'), $chunkSize), $table);
         }
     }
     return;
 }
 /**
  * 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);
 }
 /**
  * Execute the console command.
  *
  * @return mixed
  */
 public function fire()
 {
     $this->info("Checking for existing config file...");
     $fileName = $this->env->configFileName();
     if (File::exists($fileName)) {
         $this->error("File {$fileName} already exists - please delete it!");
         $this->abort();
     } else {
         $this->error("No config file exists! Enter database details to create your file:");
         $type = $this->ask("What database driver type are you using? [mysql|sqlite|pgsql|sqlsrv]: ");
         $file = null;
         $host = '';
         $name = '';
         $user = '';
         $pass = '';
         if ($type == 'sqlite') {
             $file = $this->ask('Where is your sqlite database file located (from base root)? Leave blank for the default app/database/production.sqlite file: ');
             $file == '' ? $file = null : ($file = $file);
         } elseif ($type == 'mysql' || $type == 'pgsql' || $type == 'sqlsrv') {
             $host = $this->ask('Your database hostname:');
             $name = $this->ask('Your database name:');
             $user = $this->ask('Your database user:'******'Your database user password:');
         } else {
             $this->error("Invalid database driver type.");
             $this->abort();
         }
         try {
             File::put($fileName, $this->getTemplate($type, $host, $name, $user, $pass, $file));
             $this->info("Config file {$fileName} successfully created!");
         } catch (Exception $e) {
             $this->error("An error occured creating the file: " . $e->getMessage());
         }
     }
 }
Example #29
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);
     }
 }
 /**
  * get video data from file
  * @param File $file
  * @param boolean $premiumOnly
  * @return array|null  $video
  */
 public function getVideoDataByFile($file, $premiumOnly = false)
 {
     $app = F::app();
     $app->wf->ProfileIn(__METHOD__);
     $video = null;
     if ($file instanceof File && $file->exists() && F::build('WikiaFileHelper', array($file), 'isFileTypeVideo')) {
         if (!($premiumOnly && $file->isLocal())) {
             $fileMetadata = $file->getMetadata();
             $userId = $file->getUser('id');
             $addedAt = $file->getTimestamp() ? $file->getTimestamp() : $this->wf->Timestamp(TS_MW);
             $duration = 0;
             $hdfile = 0;
             if ($fileMetadata) {
                 $fileMetadata = unserialize($fileMetadata);
                 if (array_key_exists('duration', $fileMetadata)) {
                     $duration = $fileMetadata['duration'];
                 }
                 if (array_key_exists('hd', $fileMetadata)) {
                     $hdfile = $fileMetadata['hd'] ? 1 : 0;
                 }
             }
             $premium = $file->isLocal() ? 0 : 1;
             $video = array('videoTitle' => $file->getTitle()->getDBKey(), 'addedAt' => $addedAt, 'addedBy' => $userId, 'duration' => $duration, 'premium' => $premium, 'hdfile' => $hdfile);
         }
     }
     $app->wf->ProfileOut(__METHOD__);
     return $video;
 }