public function saveApk($file, $label, $name, $icon)
 {
     $fileSystem = new Filesystem();
     $parser = new ApkParser\Parser($file->getRealPath());
     $version = $parser->getManifest()->getVersionCode();
     $bundle = $parser->getManifest()->getPackageName();
     if (!$fileSystem->exists(public_path() . '/builds')) {
         $fileSystem->makeDirectory(public_path() . '/builds');
     }
     if (!$fileSystem->exists(public_path() . '/builds/android')) {
         $fileSystem->makeDirectory(public_path() . '/builds/android');
     }
     if (!$fileSystem->exists(public_path() . '/builds/android/' . $label)) {
         $fileSystem->makeDirectory(public_path() . '/builds/android/' . $label);
     }
     if (!$fileSystem->exists(public_path() . '/builds/android/' . $label . '/' . $version)) {
         $fileSystem->makeDirectory(public_path() . '/builds/android/' . $label . '/' . $version);
     }
     $label_model = Label::where('label_name', '=', $label)->where('build_type_id', '=', self::BUILD_ANDROID_TYPE_ID)->first();
     if ($label_model != null) {
         $version_model = $label_model->versions()->where('version', '=', $version)->first();
         if ($version_model != null) {
             $build_version_count = Build::where('version_id', '=', $version_model->id)->count();
             $build = Build::create(array('bundle' => $bundle, 'name' => $name, 'version_id' => $version_model->id, 'build' => $build_version_count + 1));
         } else {
             $version_model = Version::create(array('version' => $version, 'label_id' => $label_model->id));
             $build = Build::create(array('bundle' => $bundle, 'name' => $name, 'version_id' => $version_model->id, 'build' => 1));
         }
     } else {
         $label_model = Label::create(array('label_name' => $label, 'build_type_id' => self::BUILD_ANDROID_TYPE_ID));
         $version_model = Version::create(array('version' => $version, 'label_id' => $label_model->id));
         $build = Build::create(array('bundle' => $bundle, 'name' => $name, 'version_id' => $version_model->id, 'build' => 1));
     }
     $fn = public_path() . '/builds/android/' . $label . '/' . $version . '/' . $build->build . '/' . $bundle . '.apk';
     if (!$fileSystem->exists(public_path() . '/builds/android/' . $label . '/' . $version . '/' . $build->build)) {
         $fileSystem->makeDirectory(public_path() . '/builds/android/' . $label . '/' . $version . '/' . $build->build);
     }
     $fileSystem->move($file->getRealPath(), $fn);
     $fileSystem->move($icon->getRealPath(), public_path() . '/builds/android/' . $label . '/' . $version . '/' . $build->build . '/' . $bundle . '.png');
     return Config::get("app.domain") . "/android/builds/{$label}/{$version}/{$build->build}";
 }
Example #2
0
 /**
  * @return bool
  * @throws Exception
  */
 public function save()
 {
     if ($this->isReadOnly() and !$this->isNew()) {
         return false;
     }
     $status = true;
     if ($this->isNew()) {
         $newFilename = normalize_path($this->basePath . DIRECTORY_SEPARATOR . $this->changed['name']);
         $status = touch($newFilename) !== false;
         if ($status) {
             chmod($newFilename, 0777);
             $this->file = new SplFileObject($newFilename);
         }
     } elseif ($this->isChanged('name')) {
         $newFilename = normalize_path($this->getPath() . '/' . $this->changed['name']);
         if ($newFilename != $this->getRealPath()) {
             $status = @$this->filesSystem->move($this->getRealPath(), $newFilename);
         }
         if ($status) {
             $this->file = new SplFileObject($newFilename);
         }
     }
     if ($status and $this->isChanged('content')) {
         $status = $this->filesSystem->put($this->getRealPath(), $this->changed['content']) !== false;
     }
     $this->changed = [];
     return $status;
 }
Example #3
0
 /**
  * write log
  * @param  string $logContent [logContent]
  * @param  string $logDirPath [filepath]
  */
 public function logInfo($logContent, $logDirPath)
 {
     $filesystem = new Filesystem();
     if (!$logContent || !$logDirPath) {
         return false;
     }
     if ($this->getMailLog()) {
         // log file all path
         $logPath = $logDirPath . $this->getLogName();
         if ($filesystem->exists($logPath)) {
             // everyDay new a file
             $content = $filesystem->get($logPath);
             if ($logTime = substr($content, 1, 10)) {
                 if (Carbon::now($this->local)->toDateString() == $logTime) {
                     $filesystem->append($logPath, $logContent . PHP_EOL);
                 } else {
                     $new_log_path = $logDirPath . $logTime . $this->getLogName();
                     if (!$filesystem->exists($new_log_path)) {
                         $filesystem->move($logPath, $new_log_path);
                     }
                     $filesystem->put($logPath, $logContent);
                 }
             }
         } else {
             $filesystem->put($logPath, $logContent);
         }
     }
 }
Example #4
0
 /**
  * Rename models and repositories.
  */
 public function renameModelsAndRepositories()
 {
     $moduleDir = base_path('Modules/' . $this->module);
     $paths = [$moduleDir . '/Models/Object.php', $moduleDir . '/Models/ObjectTranslation.php', $moduleDir . '/Repositories/ObjectInterface.php', $moduleDir . '/Repositories/EloquentObject.php'];
     foreach ($paths as $path) {
         $this->files->move($path, $this->transformFilename($path));
     }
 }
Example #5
0
 protected function moveAssets()
 {
     // 移動 css 檔
     $this->filesystem->move(base_path('resources/views/css/ccu.css.php'), cdn_path('css/ccu.min.css'));
     // 移動 js 檔
     $this->filesystem->move(temp_path('vendors.min.js'), cdn_path('js/vendors.min.js'));
     $this->info('Move assets successfully!');
 }
 /**
  * Create date folder structure and move migrations into.
  *
  * @return void
  */
 public function fire()
 {
     $this->basePath = $this->getMigrationPath();
     $migrations = $this->migrator->getMigrationFiles($this->basePath);
     $count = count($migrations);
     if ($count == 0) {
         $this->comment('No migrations to move');
         return;
     }
     foreach ($migrations as $migration) {
         $datePath = $this->migrator->getDateFolderStructure($migration);
         // Move the migration into base migration folder
         $this->files->move($this->basePath . '/' . $datePath . $migration . '.php', $this->basePath . '/' . $migration . '.php');
     }
     $this->info('Migrations disorganised successfully (' . $count . ' migrations moved)');
     $this->cleanup();
 }
Example #7
0
 /**
  * Execute the console command.
  *
  * @return mixed
  */
 public function fire()
 {
     $defaultEnvironmentFile = 'bootstrap/environment.local.php';
     $environmentFile = 'bootstrap/environment.php';
     $this->line('Welcome to TypiCMS');
     if (!$this->files->exists($environmentFile) && $this->files->exists($defaultEnvironmentFile)) {
         // move default environment file so current environment will be local.
         $this->files->move($defaultEnvironmentFile, $environmentFile);
         // set environment to local
         $this->laravel['env'] = 'local';
         $this->line('----------------------');
         $this->info('Environment set to local');
         $this->line('----------------------');
     }
     $this->checkThatEnvTemplateExists();
     // Ask for database name
     $dbName = $this->ask('What is your database name? ');
     // Set database credentials in env.local.php and migrate
     $this->call('typicms:database', array('database' => $dbName));
     $this->line('----------------------');
     // Set cache key prefix
     $this->call('cache:prefix', array('prefix' => $dbName));
     $this->line('----------------------');
     // Composer install
     if (function_exists('system')) {
         $this->info('Running npm install...');
         system('npm install');
         $this->info('npm packages installed');
         $this->line('----------------------');
         $this->info('Running bower install...');
         system('bower install');
         $this->info('Bower packages installed');
         $this->line('----------------------');
         system('chmod -R 777 app/storage');
         $this->info('app/storage is now writable');
         system('chmod -R 777 public/uploads');
         $this->info('public/uploads is now writable');
     } else {
         $this->line('You can now make app/storage and public/uploads writable');
         $this->line('and run composer install, npm install and bower install.');
     }
     // Done
     $this->line('----------------------');
     $this->line('Done. Enjoy TypiCMS!');
 }
Example #8
0
 protected function backup($file)
 {
     $backupPath = $this->app->make('path.storage') . '/packages/backup/' . $this->package->getName();
     if (!$this->filesystem->isDirectory($backupPath)) {
         $this->filesystem->makeDirectory($backupPath, 0755, true);
     }
     $newFile = $backupPath . '/' . date('Ymdhis') . '_' . basename($file);
     $this->filesystem->move($file, $newFile);
 }
 /**
  * Execute the command.
  *
  * @return void
  */
 public function handle(ValidateFilenameService $validateFilename, Filesystem $filesystem)
 {
     $files = [];
     foreach ($this->files as $file) {
         $filename = $validateFilename->execute($this->targetDir, $file);
         $filesystem->move($this->originDir . '/' . $file, $this->targetDir . '/' . $filename);
         $files[] = $filename;
     }
     return $files;
 }
 /**
  * Create date folder structure and move migrations into.
  *
  * @return void
  */
 public function fire()
 {
     $basePath = $this->getMigrationPath();
     $migrations = $this->migrator->getMigrationFiles($basePath, false);
     $count = count($migrations);
     if ($count == 0) {
         $this->comment('No migrations to move');
         return;
     }
     foreach ($migrations as $migration) {
         $datePath = $this->migrator->getDateFolderStructure($migration);
         // Create folder if it does not already exist
         if (!$this->files->exists($basePath . '/' . $datePath)) {
             $this->files->makeDirectory($basePath . '/' . $datePath, 0775, true);
         }
         // Move the migration into its new folder
         $this->files->move($basePath . '/' . $migration . '.php', $basePath . '/' . $datePath . $migration . '.php');
     }
     $this->info('Migrations organised successfully (' . $count . ' migrations moved)');
 }
Example #11
0
 /**
  * Function to move files / folders given in the template
  * configuration from the given source to the
  * given destination.  
  * 
  * @return void
  */
 public function move()
 {
     $key = str_replace(TemplateReader::STRUCTURE . '.', '', TemplateReader::STRUCTURE_MOVE);
     $data = array_get($this->config, $key);
     foreach ($data as $mv) {
         if (!empty($mv['from']) && !empty($mv['to'])) {
             $from = Path::absolute($mv['from'], $this->appDir);
             $to = Path::absolute($mv['to'], $this->appDir);
             $this->command->comment("Move", "from {$from} to {$to}");
             $this->filesystem->move($from, $to);
         }
     }
 }
Example #12
0
 /**
  * @param Filesystem $files
  * @param AccountManager $manager
  * @return mixed
  */
 public function handle(Filesystem $files, AccountManager $manager)
 {
     $temp_dir = storage_path('media') . '/' . $this->owner->getMediaFolder('images');
     $name = $this->uniqueName();
     $this->image->move($temp_dir, $name);
     $temp_file = $temp_dir . $name;
     $name_with_extension = $name . $this->extension($temp_file);
     $final_path = $temp_file . $name_with_extension;
     $files->move($temp_file, $final_path);
     $image = $this->dispatch(new StoreNewImage($manager->account(), $this->owner, $final_path));
     $files->delete($final_path);
     return $image;
 }
 public function store()
 {
     $filesystem = new Filesystem();
     $advertising = Advertising::where('name', '=', Input::get('name'));
     if (!$advertising->count() > 0) {
         $advertising = Advertising::create(['name' => Input::get('name'), 'bio' => Input::get('bio')]);
     }
     if (Input::has('image')) {
         $destination = public_path() . "/images/advertising/";
         $filename = Input::file('image');
         $file = $filesystem->move($destination, $filename);
         if ($file) {
             $advertising->image = $filename;
         }
         $advertising->save();
     }
     if ($advertising) {
         return Redirect::to('admin/advertising/' . $advertising->id . '/show', ['advertising' => $advertising, 'add_failed' => 'false']);
     }
     return View::make('admin.advertising.add', ['add_failed' => 'true']);
     /*
             if (\Input::get('name')) {
                 $filesystem = new Filesystem;
                 $advertising = \Advertising::findOrCreate(\Input::get('name'));
                 //$advertising_exists = \Advertising::where('name', '=', \Input::get('name'));
                     if ($exists->id) {
                         return \View::make('admin.advertising.add', ['add_failed'=> 'true', 'error_msg' => 'An entry for this advertising already exists!']);
                     }
                     //$new_advertising = \Advertising::create(\Input::only(['name', 'image', 'bio']));
                     $advertising->name = \Input::get('name');
                     $advertising->bio = \Input::get('bio');
     
                     if (\Input::has('image')) {
                         $destination = public_path() . "/images/advertising/";
                         $filename = \Input::file('image');
                         $upload_success = $filesystem->move($destination, $filename);
                         //$upload_success = \Input::file('image')->move($destinationPath, $filename);
                         if ($upload_success) {
                                $advertising->image = $filename;
                         }
                     }
                     $advertising->save();
                     return \View::make('admin.advertising.add', ['add_failed' => 'true']);
     
             }*/
 }
 /**
  * @param Gravatar $gravatar
  * @param Filesystem $files
  * @param AccountManager $manager
  * @throws \Exception
  */
 public function handle(Gravatar $gravatar, Filesystem $files, AccountManager $manager)
 {
     if ($gravatar->exists($this->user->email)) {
         $gravatar->setAvatarSize(512);
         $url = $gravatar->get($this->user->email);
         $content = file_get_contents($url);
         $tmpDir = storage_path('media' . '/' . $this->user->getMediaFolder());
         if (!$files->isDirectory($tmpDir)) {
             $files->makeDirectory($tmpDir, 0755, true);
         }
         $path = $tmpDir . sha1(time() . 'user-profile-pic' . $this->user->id);
         $files->put($path, $content);
         $finalPath = $this->pathWithExtension($path);
         $files->move($path, $finalPath);
         $this->dispatch(new StoreNewImage($manager->account(), $this->user, $finalPath));
         $files->delete($finalPath);
     }
 }
Example #15
0
 /**
  * 将非必要文件转移至备份文件夹,以减小 vendor 目录体积
  * @return void
  */
 public static function backup()
 {
     $Filesystem = new Filesystem();
     $vendorDir = dirname(dirname(dirname(dirname(__DIR__))));
     $topDir = dirname($vendorDir);
     $backupDir = $topDir . '/VendorCleanerBackup';
     // 获取主要规则文件
     // 若 vendor 同级目录下存在用户自定义文件,则使用用户自定义文件
     if ($Filesystem->exists($topDir . '/VendorCleaner.config.php')) {
         $rules = (require $topDir . '/VendorCleaner.config.php');
     } else {
         $rules = (require 'VendorCleaner/VendorCleaner.config.php');
     }
     // 分别处理各个资源包
     foreach ($rules as $packageDir => $rule) {
         if (!file_exists($vendorDir . '/' . $packageDir)) {
             continue;
         }
         // 拆分子规则
         $patterns = explode(' ', $rule);
         // 执行拆分后的规则
         foreach ($patterns as $pattern) {
             $Finder = new Finder();
             try {
                 foreach ($Finder->name($pattern)->in($vendorDir . '/' . $packageDir) as $file) {
                     $backup = str_replace($vendorDir, $backupDir, $file);
                     if ($file->isDir()) {
                         // 文件夹处理
                         $Filesystem->copyDirectory($file, $backup);
                         $Filesystem->deleteDirectory($file);
                     } elseif ($file->isFile()) {
                         // 文件处理
                         $Filesystem->move($file, $backup);
                     }
                 }
             } catch (\Exception $e) {
             }
         }
     }
 }
 public function put(UploadedFile $file, $whereToPut)
 {
     $this->file->move($file->getRealPath(), $whereToPut . "/" . $file->getFilename());
 }
 public function rename()
 {
     $this->login();
     set_time_limit(0);
     $file = new Filesystem();
     $re = $file->files('/Users/tingliu/Downloads/head_img');
     $count = 1;
     foreach ($re as $key => $path) {
         $new_name = $count . '.' . $file->extension($path);
         $path_seg = explode('/', $path);
         array_pop($path_seg);
         $new_path = implode('/', $path_seg);
         $new_path = '/' . $new_path . '/' . $new_name;
         $file->move($path, $new_path);
         $count++;
     }
     echo "DONE";
 }
Example #18
0
function setDone($id)
{
    //query the records having thex` passed id
    $obj = PurchaseOrderQuery::create();
    $filename = $obj->findPK($id);
    $num_rows = $obj->filterById($id)->count();
    if ($num_rows === 1) {
        $newFile = $filename->getFilename();
        $dirname = $filename->getStore();
        $fs = new Filesystem();
        $filePath = '../Repo/' . $dirname . '/';
        //set timezone
        date_default_timezone_set('Asia/Manila');
        echo $current_date = date('m/d/Y');
        if ($fs->exists($filePath . $newFile)) {
            PurchaseOrderQuery::create()->filterByFilename($newFile)->filterByStore($dirname)->update(array('DateCreated' => $current_date, 'IsSync' => '1'));
            $fs->move($filePath . $newFile, '../Repo/' . 'done/' . $dirname . '/' . $newFile);
            logMessage("Database updated: SET DONE COMPLETE " . date('m/d/Y h:i:s') . ".\n");
            //log something
        }
    } else {
        logMessage("Unable to update the database" . date('m/d/Y h:i:s') . '\\n');
        //log something
    }
}
Example #19
0
 /**
  * @param Filesystem $fs
  * @param string $source
  * @param string $destination
  */
 protected function moveFileOrDirectory(Filesystem $fs, $source, $destination)
 {
     if (is_dir($source)) {
         $fs->copyDirectory($source, $destination);
         $fs->deleteDirectory($source);
     } else {
         // Create directory if it doesn't exist
         $parentDirectory = dirname($destination);
         if (!$fs->exists($parentDirectory)) {
             $fs->makeDirectory($parentDirectory, 0777, true);
         }
         $fs->move($source, $destination);
     }
 }
 /**
  * Moves a file from the specified path to the other
  *
  * @param $fromPath
  * @param $toPath
  * @return bool
  */
 public function move($fromPath, $toPath)
 {
     return $this->storage->move($this->storagePath($fromPath), $this->storagePath($toPath));
 }
 public function addBundle()
 {
     if (!Input::hasFile('ipa')) {
         exit(0);
     } else {
         $ipa = Input::file('ipa');
     }
     $payload = exec("unzip -l " . $ipa->getRealPath() . " | sed -e 's/ /\\n/g' | grep app/Info.plist | sed -e 's/Info.plist//g'");
     $default_icon = public_path() . "/images/default_icon.png";
     $fileSystem = new Filesystem();
     if (!$fileSystem->exists('/tmp/bundle')) {
         $fileSystem->makeDirectory('/tmp/bundle');
     }
     if (!$fileSystem->exists('/tmp/bundle/tmp')) {
         $fileSystem->makeDirectory('/tmp/bundle/tmp');
     }
     $path = "/tmp/bundle" . $ipa->getRealPath();
     if ($fileSystem->exists($path)) {
         $fileSystem->deleteDirectory($path);
     }
     $fileSystem->makeDirectory($path);
     $zip = new ZipArchive();
     $res = $zip->open($ipa->getRealPath());
     if ($res === TRUE) {
         $zip->extractTo($path);
         $zip->close();
     }
     $dirs = scandir($path);
     array_shift($dirs);
     array_shift($dirs);
     $APP_PATH = $path . "/" . $dirs[0];
     $dirs = scandir($APP_PATH);
     array_shift($dirs);
     array_shift($dirs);
     $APP_PATH = $APP_PATH . "/" . $dirs[0];
     $plist = CFPropertyList::getInstance();
     $plist->setFile($APP_PATH . "/Info.plist");
     $plist->load();
     $info = $plist->toArray();
     $name = $info['CFBundleName'];
     $build = isset($info['CFBundleVersion']) && array_key_exists("CFBundleVersion", $info) ? $info['CFBundleVersion'] : 1;
     $version = isset($info['CFBundleShortVersionString']) && array_key_exists("CFBundleShortVersionString", $info) ? $info['CFBundleShortVersionString'] : 0;
     if (array_key_exists("CFBundleIconFiles", $info)) {
         $icons = $info['CFBundleIconFiles'];
     } else {
         if (array_key_exists("CFBundleIcons", $info)) {
             $icons = $info["CFBundleIcons"]["CFBundlePrimaryIcon"]["CFBundleIconFiles"];
         } else {
             $icons = array();
         }
     }
     $bundle = $info['CFBundleIdentifier'];
     $label = $_POST['label'];
     if (!$fileSystem->exists(public_path() . '/builds')) {
         $fileSystem->makeDirectory(public_path() . '/builds');
     }
     if (!$fileSystem->exists(public_path() . '/builds/ios')) {
         $fileSystem->makeDirectory(public_path() . '/builds/ios');
     }
     if (!$fileSystem->exists(public_path() . '/builds/ios/' . $label)) {
         $fileSystem->makeDirectory(public_path() . '/builds/ios/' . $label);
     }
     if (!$fileSystem->exists(public_path() . '/builds/ios/' . $label . '/' . $version)) {
         $fileSystem->makeDirectory(public_path() . '/builds/ios/' . $label . '/' . $version);
     }
     $icons_ready = array();
     foreach ($icons as $icon) {
         $img = "{$path}/tmp5646431.png";
         $icon = str_replace(".png", "", $icon) . ".png";
         $processor = PPngUncrush::getInstance();
         if (is_file("{$APP_PATH}/{$icon}")) {
             $processor->setFilePath("{$APP_PATH}/{$icon}");
             try {
                 $processor->decode($img . $icon);
             } catch (ErrorException $e) {
                 $img = $default_icon;
                 $icon = "";
             }
             $sz = getimagesize($img . $icon);
             $icons_ready[] = array("image" => $img . $icon, "size" => $sz);
         }
         //            $fileSystem->copy($img.$icon ,public_path().'/builds/ios/'.$label.'/'.$version.'/'.$bundle.$sz[0].'x'.$sz[1].'.png');
     }
     $label_model = Label::where('label_name', '=', $label)->where('build_type_id', '=', self::BUILD_IOS_TYPE_ID)->first();
     if ($label_model != null) {
         $version_model = $label_model->versions()->where('version', '=', $version)->first();
         if ($version_model != null) {
             $build_version_count = Build::where('version_id', '=', $version_model->id)->count();
             $build = Build::create(array('bundle' => $bundle, 'name' => $name, 'version_id' => $version_model->id, 'build' => $build_version_count + 1));
         } else {
             $version_model = Version::create(array('version' => $version, 'label_id' => $label_model->id));
             $build = Build::create(array('bundle' => $bundle, 'name' => $name, 'version_id' => $version_model->id, 'build' => 1));
         }
     } else {
         $label_model = Label::create(array('label_name' => $label, 'build_type_id' => self::BUILD_IOS_TYPE_ID));
         $version_model = Version::create(array('version' => $version, 'label_id' => $label_model->id));
         $build = Build::create(array('bundle' => $bundle, 'name' => $name, 'version_id' => $version_model->id, 'build' => 1));
     }
     $fn = public_path() . '/builds/ios/' . $label . '/' . $version . '/' . $build->build . '/' . $bundle . '.ipa';
     if (!$fileSystem->exists(public_path() . '/builds/ios/' . $label . '/' . $version . '/' . $build->build)) {
         $fileSystem->makeDirectory(public_path() . '/builds/ios/' . $label . '/' . $version . '/' . $build->build);
     }
     $fileSystem->move($ipa->getRealPath(), $fn);
     $max_size = 0;
     foreach ($icons_ready as $icon) {
         if ($icon["size"][0] > $max_size) {
             $max_size = $icon["size"][0];
         }
     }
     foreach ($icons_ready as $icon) {
         if ($icon["size"][0] == $max_size) {
             $fileSystem->copy($icon["image"], public_path() . '/builds/ios/' . $label . '/' . $version . '/' . $build->build . '/' . $bundle . '.png');
         }
     }
     if (empty($icons_ready)) {
         $fileSystem->copy($default_icon, public_path() . '/builds/ios/' . $label . '/' . $version . '/' . $build->build . '/' . $bundle . '.png');
     }
     $fileSystem->deleteDirectory('/tmp/bundle/tmp');
     echo Config::get("app.domain") . "/ios/builds/{$label}/{$version}/{$build->build}\n";
     return "";
 }
Example #22
0
 public function testNoVendorFolder()
 {
     $this->initiate('yml');
     $filesystem = new Filesystem();
     $this->prepareInput();
     $filesystem->move(TEST_PATH . '/vendor', TEST_PATH . '/vendor1');
     try {
         $this->testInstance->run($this->inputMock, $this->outputMock);
     } catch (\Exception $e) {
         $this->assertTrue($e instanceof \Exception);
     }
     $filesystem->move(TEST_PATH . '/vendor1', TEST_PATH . '/vendor');
 }
Example #23
0
 public function download($url, $dir = null, $createDimensions = false, $dimensions = [])
 {
     if (!$url) {
         return false;
     }
     $file = file_get_contents($url);
     $ext = pathinfo($url, PATHINFO_EXTENSION);
     $tmp_file = storage_path() . '/download-' . str_random(8) . '.' . $ext;
     $fp = fopen($tmp_file, 'w');
     fwrite($fp, $file);
     fclose($fp);
     $fs = new Filesystem();
     $filename = hash('sha256', uniqid()) . '.png';
     $destination = Config::get('image.upload_path') . $dir . '/' . $filename;
     $path = Config::get('image.upload_dir') . '/' . $dir . '/' . $filename;
     $uploaded = $fs->move($tmp_file, $destination);
     if ($uploaded) {
         if ($createDimensions) {
             $this->createDimensions($path, $dimensions);
         }
         return $filename;
     }
     return false;
 }
Example #24
0
function setDone($id)
{
    //query the records having the passed id
    $filename = PurchaseOrderQuery::create()->findPK($id);
    $newFile = $filename->getFilename();
    $dirname = $filename->getStore();
    $fs = new Filesystem();
    $filePath = '../Repo/' . $dirname . '/';
    if ($fs->exists($filePath . $newFile)) {
        PurchaseOrderQuery::create()->filterByFilename($newFile)->filterByStore($dirname)->update(array('IsSync' => '1'));
        $fs->move($filePath . $newFile, '../Repo/' . 'done/' . $dirname . '/' . $newFile);
    }
}
 /**
  * Rename the folder
  * @param $directory
  * @return $this
  */
 protected function rename($directory)
 {
     $this->filesystem->move(__DIR__ . '/BackPack-master', $directory);
     return $this;
 }
Example #26
0
 /**
  * Move a file to a new location.
  *
  * @param string $path
  * @param string $target
  * @return bool 
  * @static 
  */
 public static function move($path, $target)
 {
     return \Illuminate\Filesystem\Filesystem::move($path, $target);
 }
Example #27
0
    /**
     * Execute the console command.
     *
     * @return mixed
     */
    public function fire()
    {
        $welcome = <<<EOT
\t______                            _              _                                     _
\t| ___ \\                          | |            | |                                   | |
\t| |_/ /___ __      __ ___  _ __  | |__   _   _  | |      __ _  _ __  __ _ __   __ ___ | |
\t|  __// _ \\ \\ /\\ / // _ \\| '__| | '_ \\ | | | | | |     / _` || '__|/ _` |\\ \\ / // _ \\| |
\t| |  | (_) |\\ V  V /|  __/| |    | |_) || |_| | | |____| (_| || |  | (_| | \\ V /|  __/| |
\t\\_|   \\___/  \\_/\\_/  \\___||_|    |_.__/  \\__, | \\_____/ \\__,_||_|   \\__,_|  \\_/  \\___||_|
\t                                          __/ |
\t                                         |___/
\t  ========================================================
\t                                           phphub.org
EOT;
        $this->info($welcome);
        //force to local env.
        $this->laravel['env'] = 'local';
        //check env templates
        $this->info('1. Check Env Templates..');
        $this->checkEnvTemplates();
        $this->line('----------------------');
        // run install
        if (function_exists('system')) {
            $this->info('2. Running `npm install` ... Running on OS [' . PHP_OS . "] HostName [" . gethostname() . ']');
            $option = '';
            //check if is running on homestead
            if ('homestead' == gethostname()) {
                $option = ' --no-bin-links';
            }
            //npm install
            if (system('npm install' . $option)) {
                $this->info('npm packages installed.');
                $this->line('----------------------');
                $this->line('----------------------');
            } else {
                $this->error('npm install error');
            }
            //gulp task
            $this->info('3. Running `gulp build`...');
            if (system('gulp build')) {
                $this->info('Gulp Build Success ');
                $this->line('----------------------');
                $this->line('----------------------');
            } else {
                $this->error('gulp build error');
            }
            // mv .env.example.php to .env.local.php
            $this->info('4. Moving `.env.example.php` to `.env.local.php`');
            $envVariables = $this->getEnvFile();
            if ($this->files->move('.env.example.php', '.env.local.php')) {
                $this->info('Move Success!');
            } else {
                throw new Exception('Error while moving .env.example.php file');
            }
            //set datebase config to laravel config
            $this->laravel['config']['database.connections.mysql.database'] = $envVariables['DB_NAME'];
            $this->laravel['config']['database.connections.mysql.username'] = $envVariables['DB_USERNAME'];
            $this->laravel['config']['database.connections.mysql.password'] = $envVariables['DB_PASSWORD'];
            // migration && seed
            if ($this->confirm('Do you wish to migration? [yes|no]')) {
                // Migrate DB
                if (!Schema::hasTable('migrations')) {
                    $this->call('migrate');
                } else {
                    $this->error('A migrations table was found in database, No migrations will be run.');
                }
                // Seed
                if ($this->confirm('Do you wish to seed some fake data? [yes|no]')) {
                    $this->call('db:seed');
                }
            }
        } else {
            $this->line('Please run `npm install` and `gulp build` manually');
        }
        // Done
        $this->line('----------------------');
        $this->line('All Done. Enjoy Phphub!');
    }