public function build()
 {
     \yii\base\Event::on(\denoll\filekit\Storage::className(), \denoll\filekit\Storage::EVENT_BEFORE_SAVE, function ($event) {
         /** @var \denoll\filekit\Storage $storage */
         $storage = $event->sender;
         if (!$storage->getFilesystem()->has('.dirindex')) {
             $storage->getFilesystem()->write('.dirindex', 1);
             $dirindex = 1;
         } else {
             $dirindex = $storage->getFilesystem()->read('.dirindex');
         }
         if ($storage->maxDirFiles !== -1) {
             if ($storage->getFilesystem()->has($dirindex)) {
                 $filesCount = count($storage->getFilesystem()->listContents($dirindex));
                 if ($filesCount > $storage->maxDirFiles) {
                     $dirindex++;
                     $storage->getFilesystem()->createDir($dirindex);
                 }
             } else {
                 $storage->getFilesystem()->createDir($dirindex);
             }
         }
     });
     $client = new \Sabre\DAV\Client(['baseUri' => 'https://webdav.yandex.ru']);
     $client->addCurlSetting(CURLOPT_SSL_VERIFYPEER, false);
     $client->addCurlSetting(CURLOPT_HTTPHEADER, ['Authorization: OAuth TOKENTOKENTOKEN', 'Accept: */*', 'Host: webdav.yandex.ru']);
     $adapter = new WebDAVAdapter($client, '/');
     $flysystem = new Filesystem($adapter);
     if (!$flysystem->has($this->pathPrefix)) {
         $flysystem->createDir($this->pathPrefix);
     }
     $adapter->setPathPrefix($this->pathPrefix);
     return $flysystem;
 }
 public function system()
 {
     $adapter = new Local(__DIR__ . '/../../storage/');
     $filesystem = new Filesystem($adapter);
     $filesystem->createDir($this->getZipName());
     return $filesystem;
 }
예제 #3
0
 /**
  * {@inheritdoc}
  */
 public function mkdir($path)
 {
     if ($this->file_exists($path)) {
         return false;
     }
     return $this->flysystem->createDir($this->buildPath($path));
 }
 /**
  * @param $properties
  * @param $content
  */
 private function handleDirectory(Collection $properties, $content)
 {
     $properties->push($content['filename']);
     $this->filesystem->createDir('Api/' . $this->endpoint->first());
     $generator = new EndpointGenerator($this->inputInterface, $this->out, $this->dialogHelper);
     $endpoint = str_replace("Request/", "", $content['path']);
     $generator->generateForEndpoint($endpoint);
 }
예제 #5
0
 /**
  * @inheritdoc
  */
 protected function _mkdir($path, $name)
 {
     $path = $this->_joinPath($path, $name);
     if ($this->fs->createDir($path)) {
         return $path;
     }
     return false;
 }
예제 #6
0
 /**
  * @inheritdoc
  */
 public function createDir($dirname, array $config = [])
 {
     $innerDirname = $this->getInnerPath($dirname);
     $return = $this->fileSystem->createDir($innerDirname, $config);
     if ($return !== false) {
         $this->invokePlugin("addPathToIndex", [$dirname, $innerDirname], $this);
     }
     return $return;
 }
예제 #7
0
 public function createArchiveFolder()
 {
     // Set the name of the dated archive folder
     $this->archive_folder = date('YmdHi');
     // Create the output folder
     if (!$this->localAdapter->createDir($this->relativeDumpPath())) {
         throw \Exception("Couldn't create folder");
     }
 }
예제 #8
0
 public function index()
 {
     $accessToken = 'Z8PuqT2g6U0AAAAAAAAACVpHcg95JybQkwwVJ6-Qj3L0zoxAcPcXqDZG5RW7aynW';
     $appSecret = 'fsd52oajpnywijp';
     $client = new Client($accessToken, $appSecret);
     $adapter = new DropboxAdapter($client);
     $filesystem = new Filesystem($adapter);
     //$file = $filesystem->get('hello.txt');
     $filesystem->createDir('/classrequests');
     //$token->get('');
     return 'success';
 }
예제 #9
0
 /**
  * @param Filesystem $source      The source file system to archive
  * @param string     $archiveFile The name of the archive/zip file. Extension is optional, allowing me to decide
  *
  * @return bool|string If successful, the actual file name (without a path) is return. False otherwise
  */
 protected static function archiveTree(Filesystem $source, $archiveFile)
 {
     //  Add file extension if missing
     $archiveFile = static::ensureFileSuffix('.zip', $archiveFile);
     //  Create our zip container
     $_archive = new Filesystem(new ZipArchiveAdapter($archiveFile));
     try {
         foreach ($source->listContents('', true) as $_file) {
             if ('dir' == $_file['type']) {
                 $_archive->createDir($_file['path']);
             } elseif ('link' == $_file['type']) {
                 $_archive->put($_file['path'], $_file['target']);
             } elseif ('file' == $_file['type']) {
                 file_exists($_file['path']) && static::writeStream($_archive, $_file['path'], $_file['path']);
             }
         }
     } catch (\Exception $_ex) {
         \Log::error('Exception exporting instance storage: ' . $_ex->getMessage());
         return false;
     }
     //  Force-close the zip
     static::flushZipArchive($_archive);
     return basename($archiveFile);
 }
예제 #10
0
 public function reactivate($identifier)
 {
     $adapter = new Local('/var/www/crm_container');
     $filesystem = new Filesystem($adapter);
     $filesystem->createDir('disabled');
     if ($this->checkExistance($identifier) === true) {
         exec('mv /var/www/crm_container/disabled/' . $identifier . ' /var/www/crm_container/');
         return true;
     } else {
         return 'error';
     }
 }
예제 #11
0
 public function testCreateDir()
 {
     $this->prophecy->createDir('dirname', $this->config)->willReturn(['path' => 'dirname', 'type' => 'dir']);
     $output = $this->filesystem->createDir('dirname');
     $this->assertTrue($output);
 }
예제 #12
0
    public function write()
    {
        $adapter = new Adapter("/");
        $filesystem = new Filesystem($adapter);
        if ( ! $filesystem->has($this->path)) {
            $filesystem->createDir($this->path);
        }

        $filename = $this->path . $this->getFileName();

        $writer   = new CsvWriter( "," );
        $writer->setStream( fopen( $filename, 'w' ) );

        $header = $this->getPrologHeader();
        if ($this->includeProlog) {
            $header[ 1 ][ 0 ] = 'uri';
            ksort($header[1]);
            $header[ 2 ][ 0 ] = 'lang';
            $header[ 2 ][ 1 ] = $this->getSchema()->getLanguage(); //default language
            ksort($header[2]);
            $header[ 3 ][ 0 ] = 'type';
            $header[ 3 ][ 1 ] = 'uri'; //default type
            ksort($header[3]);
        }

        foreach ( $header as $line )
        {
            $writer->writeItem( $line );
        }

        if ($this->includeProlog) {

            $metadata = $this->getMetadata();
            foreach ($metadata as $line) {
                $writer->writeItem($line);
            }

            $prefixRows = $this->getPrefixRows();
            foreach ($prefixRows as $line) {
                $writer->writeItem($line);
            }
        }
        //get the data
        if ( $this->populate )
        {
            $prefixes = $this->getPrefixes();
            $prefixPattern = array();
            $prefixReplacement = array();
            foreach ( $prefixes as $prefix => $namespace )
            {
                if (trim($prefix)) {
                    if ( ! is_int($prefix)) {
                        $prefixPattern[] = "|" . $namespace . "|";
                        $prefixReplacement[] = $prefix . ":";
                    }
                }
            }

            $map = $this->getHeaderMap();
            $c   = new \Criteria();
            $c->clearSelectColumns();
            if ('schema' === $this->type) {
                $c->addSelectColumn(\SchemaPropertyPeer::ID);
                $c->add(\SchemaPropertyPeer::SCHEMA_ID, $this->schema->getId());
                if ($this->excludeDeprecated) {
                    $c->add(\SchemaPropertyPeer::STATUS_ID, 8, \Criteria::NOT_EQUAL);
                }
                $c->addAscendingOrderByColumn(\SchemaPropertyPeer::URI);
                $properties = \SchemaPropertyPeer::doSelectRS($c);
            } else {
                $c->addSelectColumn(\ConceptPeer::ID);
                $c->addSelectColumn(\ConceptPeer::URI);
                $c->addSelectColumn(\ConceptPeer::STATUS_ID);
                $c->add(\ConceptPeer::VOCABULARY_ID, $this->schema->getId());
                if ($this->excludeDeprecated) {
                    $c->add(\ConceptPeer::STATUS_ID, 8, \Criteria::NOT_EQUAL);
                }
                $c->addAscendingOrderByColumn(\ConceptPeer::URI);
                $properties = \ConceptPeer::doSelectRS($c);
            }
            foreach ( $properties as $property )
            {
                $line    = array_fill( 0, $this->getHeaderCount(), '' );
                $line[0] = $property[0];
                $map     = $this->getHeaderMap();

                $ce = new \Criteria();
                if ('schema' === $this->type) {
                    $ce->add(\BaseSchemaPropertyElementPeer::SCHEMA_PROPERTY_ID, $property[0]);
                    if (!$this->includeDeleted) {
                        $ce->add(\BaseSchemaPropertyElementPeer::DELETED_AT, null);
                    }
                    if ($this->includeDeleted) {
                        $ce->addAscendingOrderByColumn(\SchemaPropertyElementPeer::UPDATED_AT);
                    }
                    $elements = \SchemaPropertyElementPeer::doSelectJoinProfileProperty($ce);
                } else {
                    $ce->add(\ConceptPropertyPeer::CONCEPT_ID, $property[0]);
                    if (!$this->includeDeleted) {
                        $ce->add(\ConceptPropertyPeer::DELETED_AT, null);
                    }
                    if ($this->includeDeleted) {
                        $ce->addAscendingOrderByColumn(\ConceptPropertyPeer::UPDATED_AT);
                    }
                    $elements = \ConceptPropertyPeer::doSelectJoinProfilePropertyRelatedBySkosPropertyId($ce);
                    $line[array_search('uri', $header[0])] = $property[1];
                    $line[array_search('status', $header[0])] = $property[2];
                }
                /** @var \SchemaPropertyElement $element */
                foreach ($elements as $element )
                {
                    if ($this->excludeGenerated and $element->getIsGenerated()) {
                        continue;
                    }
                    /** @var \ProfileProperty $profileProperty */
                    $profileProperty = $element->getProfileProperty();
                    $propertyId      = $profileProperty->getId();
                    if ('schema' === $this->type and in_array( $propertyId, [ 6, 9, ] ) and $element->getIsSchemaProperty() )
                    {
                        $language = 'parent';
                    }
                    else
                    {
                        $language = $profileProperty->getHasLanguage() ? $element->getLanguage() : '';
                    }
                    $index = $propertyId . $language;
                    if (isset($map[ $index ])) {
                        foreach ($map[ $index ] as &$column) {
                            if (false !== $column) {
                                $line[ $column ] = $element->getObject();
                                $column = false;
                                break;
                            }
                        }
                    }
                }

                $writer->writeItem( preg_replace( $prefixPattern, $prefixReplacement, $line ));

                unset($line, $elements);
            }
        }

        //add an empty line at the end
        $line = array_fill( 0, $this->getHeaderCount(), '' );
        $writer->writeItem( $line );
        $writer->finish();
    }
예제 #13
0
 /**
  * Create folder if not exists.
  *
  * @param $folder
  */
 public function createFolderIfNotExists($folder)
 {
     if ($this->system->has($folder) === false) {
         $this->system->createDir($folder);
     }
 }
예제 #14
0
 /**
  * Create a directory.
  *
  * @param string $dirname The name of the new directory.
  * @param array  $config  An optional configuration array.
  *
  * @return bool True on success, false on failure.
  */
 public function createDir($dirname, array $config = [])
 {
     $result = parent::createDir($dirname, $config);
     if ($result && ($resource = $this->get($dirname))) {
         return $this->dispatch(new SyncFolder($resource));
     }
     return $result;
 }
예제 #15
0
 /**
  * Create a directory.
  *
  * @param string $dirname The name of the new directory.
  * @param array  $config  An optional configuration array.
  *
  * @return bool True on success, false on failure.
  */
 public function createDir($dirname, array $config = [])
 {
     return $this->filesystem->createDir($dirname, $config);
 }
예제 #16
0
 public function createDir($directory)
 {
     $this->flysystem->createDir($directory);
 }
 public function saveAsZip($identifier)
 {
     //initialize variables
     $archives = new Filesystem(new Local($this->container_path));
     $local = new Filesystem(new Local($this->container_path . $identifier));
     $zip = new Filesystem(new ZipArchiveAdapter($this->archives_path . time() . '-' . $identifier . '.zip'));
     //make sure the directory exists
     $archives->createDir('archives');
     //list dir for CMS
     $contents = $local->listContents('', true);
     foreach ($contents as $info) {
         if ($info['type'] === 'dir') {
             continue;
         }
         $zip->write($info['path'], $local->read($info['path']));
     }
     // This will trigger saving the zip.
     $zip = null;
     return true;
 }
예제 #18
0
 function it_should_unsuccessfully_create_directory($path, Filesystem $filesystem)
 {
     $filesystem->createDir($path)->willReturn(false);
     $this->createDirectory($path)->shouldReturn(false);
     $filesystem->createDir($path)->shouldBeCalled();
 }
 /** @inheritdoc */
 public function import($request)
 {
     $_from = null;
     $_instance = $request->getInstance();
     $_mount = $_instance->getStorageMount();
     $this->info('[provisioning:storage:import] instance "' . $_instance->instance_id_text . '" begin');
     //  Grab the target (zip archive) and pull out the target of the import
     $_zip = $request->getTarget();
     /** @var \ZipArchive $_archive */
     /** @noinspection PhpUndefinedMethodInspection */
     $_archive = $_zip->getAdapter()->getArchive();
     $_path = null;
     foreach ($_zip->listContents() as $_file) {
         if ('dir' != $_file['type'] && false !== strpos($_file['path'], '.storage.zip')) {
             $_from = Disk::segment([sys_get_temp_dir(), 'dfe', 'import', sha1($_file['path'])], true);
             if (!$_archive->extractTo($_from, $_file['path'])) {
                 throw new \RuntimeException('Unable to unzip archive file "' . $_file['path'] . '" from snapshot.');
             }
             $_path = Disk::path([$_from, $_file['path']], false);
             if (!$_path || !file_exists($_path)) {
                 throw new \InvalidArgumentException('$from file "' . $_file['path'] . '" missing or unreadable.');
             }
             $_from = new Filesystem(new ZipArchiveAdapter($_path));
             break;
         }
     }
     if (!$_mount instanceof Filesystem) {
         $_mount = new Filesystem(new ZipArchiveAdapter($_mount));
     }
     //  If "clean" == true, storage is wiped clean before restore
     if (true === $request->get('clean', false)) {
         $_mount->deleteDir('./');
     }
     //  Extract the files
     $_restored = [];
     /** @type Filesystem $_archive */
     foreach ($_from->listContents() as $_file) {
         $_filename = $_file['path'];
         if ('dir' == array_get($_file, 'type')) {
             $_mount->createDir($_filename);
         } else {
             $_mount->writeStream($_filename, $_archive->readStream($_filename));
         }
         $_restored[] = $_file;
     }
     unset($_from);
     $_path && is_dir(dirname($_path)) && Disk::deleteTree(dirname($_path));
     //  Fire off a "storage.imported" event...
     \Event::fire('dfe.storage.imported', [$this, $request]);
     $this->info('[provisioning:storage:import] instance "' . $_instance->instance_id_text . '" complete');
     return $_restored;
 }
 /**
  * 3.txt
  * 2.txt
  * test/1.txt.
  */
 public function testCreateDir()
 {
     $this->assertTrue($this->filesystem->createDir('test'));
     $this->assertTrue($this->filesystem->copy('2.txt', 'test/1.txt'));
 }
예제 #21
0
 public function createDirectory($path)
 {
     return $this->filesystem->createDir($path);
 }
예제 #22
0
 public function postcreaterequest(Request $request)
 {
     $req_name = $request->input('req_name');
     $req_desc = $request->input('req_desc');
     $deadline = $request->input('deadline');
     $size_limit = $request->input('size_limit');
     $byte = $request->input('byte');
     if ($byte == 'kb') {
         $size_limit = $size_limit * 1024;
     } elseif ($byte == 'mb') {
         $size_limit = $size_limit * 1024 * 1024;
     }
     $mime_type = $request->input('mime');
     $class_name = $request->input('class_name');
     $username = $request->session()->get('username');
     //$accessToken = 	'Z8PuqT2g6U0AAAAAAAAACVpHcg95JybQkwwVJ6-Qj3L0zoxAcPcXqDZG5RW7aynW';
     //$user = DB::table('users')->where('username', '=', $username)->get();
     //$users = DB::table('users')->where('votes', '=', 100)
     // $students = DB::select('select * from users where username = "******"');
     $token = DB::table('users')->where('username', $username)->lists('token');
     //$accessToken = ozuk1EzTbfAAAAAAAAAAO8msCxB-ctDGw0O28cMA05NGe0_ma348UgW-0HdBUNyk;
     $accessToken = $token[0];
     //return $accessToken;
     //$accessToken = 'ozuk1EzTbfAAAAAAAAAAPXwlC1sc5yxV0JsonmziwqiN2WzQfVDqjZnyCLKVczIc';
     //return $accessToken;
     $appSecret = 'fsd52oajpnywijp';
     $client = new Client($accessToken, $appSecret);
     $adapter = new DropboxAdapter($client);
     $filesystem = new Filesystem($adapter);
     //$file = $filesystem->get('hello.txt');
     $filesystem->createDir('/' . $req_name);
     //$token->get('');
     DB::insert('insert into requests (req_name, req_desc, deadline, size_limit, class_name, dropbox_path ) values (?, ?, ?, ?, ?, ?)', [$req_name, $req_desc, $deadline, $size_limit, $class_name, '/' . $req_name]);
     $columns = DB::connection()->getSchemaBuilder()->getColumnListing("mime_types");
     $req_id = DB::table('requests')->where('req_name', $req_name)->lists('req_id');
     $id = $req_id[0];
     $count = 0;
     foreach ($columns as $mimes) {
         if ($count == 0) {
             DB::table('mime_types')->insert([['req_id' => $id]]);
             $count++;
         } else {
             if ($mimes == $mime_type[$count - 1]) {
                 DB::table('mime_types')->insert([[$columns => true]]);
             }
             $count++;
         }
     }
     return view('/');
 }
예제 #23
0
파일: Part.php 프로젝트: sethathay/PPBakery
 public function setupPackage($composer, Filesystem $target)
 {
     $target->createDir('src');
     $target->createDir('tests');
     $this->copyTo(__DIR__ . '/stubs/gitignore.txt', $target, '.gitignore');
 }
예제 #24
0
파일: Update.php 프로젝트: elkuku/Jmd5check
 private function cleanup()
 {
     if ($this->keepFiles) {
         // Don't cleanup
         return $this;
     }
     $filesystem = new Filesystem(new Local($this->outPath));
     $filesystem->deleteDir('zips');
     $filesystem->createDir('zips');
     $filesystem->deleteDir('sources');
     $filesystem->createDir('sources');
     return $this;
 }
 /**
  * Creates a new folder in
  * @param string $directoryName
  *
  * @return bool
  */
 public function createDirectory($directoryName)
 {
     return $this->fs->createDir($directoryName);
 }