为当前请求创建上下文
@return void
16489
public static function create()
    {
        $key = static::getContextKey();
        if(!isset(static::$context[$key]))
        {
            static::$context[$key] = RequestContext::getServerBean('ConnectContextStore')->read($key);
        }
    }
956254
public function pushGit()
    {
        if (!isset($this->config['git_address'])) {
            Log::info('Git地址没有配置，请在Config.php文件参照如下方式配置：' );
            Log::info('$config[\'git_address\']=\'git@github.com:seeruo/seeruo.github.io.git\';','error');
        }
        $Git = new GitService($this->config);

                        
        $Git->add();
        $Git->commit();
        $Git->push();
    }
86928
public function upload()
    {
      if ($this->error !== '') {
        return false;
      }

      $isValid = $this->contraintsValidator();

      $isSuccess = $isValid && $this->isSaved($this->_files['tmp_name'], $this->getFullPath());

      return $isSuccess ? $this : false;
    }
54898
public function update()
    {
        $this->setUpVersion();
        $connection = $this->getConnection();
        foreach ($this->folders as $name => $path) {
            $folder = new FolderImpl($path);
            if (!$folder->exists()) {
                continue;
            }
            /** @var File[] $files */
            $files = $folder->listFolder(Folder::LIST_FOLDER_FILES);

            usort($files, function (File $a, File $b) {
                return $this->leadingNumber($a->getFilename()) - $this->leadingNumber($b->getFilename());
            });
            $lastFile = null;
            $version = $this->getVersion($name);
            foreach ($files as $file) {
                if ($file->getExtension() != 'sql') {
                    continue;
                }

                if ($this->leadingNumber($file->getFilename()) <= $version) {
                    continue;
                }

                $stmt = $connection->prepare($file->getContents());
                $stmt->execute();

                while ($stmt->nextRowset()) ; //Polling row sets

                $lastFile = $file;
            }
            if ($lastFile == null) {
                continue;
            }
            $this->setVersion($name, $this->leadingNumber($lastFile->getFilename()));

        }
    }
19640
public function uploadToContentService() {
		/** @var \File $file */
		$file = $this->owner;
		$writer = $this->writer();
		if (!$writer) {
			return;
		}
		$path = $file->getFullPath();
		if (strlen($path) && is_file($path) && file_exists($path)) {

			$mtime = @filemtime($path);
            $name = trim($file->getFilename(), '/');
		if (!$mtime) {
                    $mtime = '0';
                }

			//Insert the file modified time to make file unique-ish
			if ($lastPos = strrpos($name, '/')) {
				// Add in at as last folder name
				$name = substr($name, 0, $lastPos) . '/' . $mtime . substr($name, $lastPos);
			} else {
				//No folder found create one for the mtime
				$name = $mtime . '/' . $name;
			}

			$fileKeyLength = strlen($name);
			if ($fileKeyLength > CDNFile::MAX_FILE_PATH_LENGTH) {
				$lastPos = strrpos($name, '/');
				$ext = '';
				$filename = substr($name, $lastPos + 1);
				// Try and find a file extension
				if (strrpos($name, '.') !== false) {
					// Store and trim extension for later replacement
					$ext = substr($name, strrpos($name, '.'));
					$filename = substr($filename, 0, strrpos($filename, '.'));
				}
				// add 1 here so we can add in a ~ to indictate truncation
				$truncateLength = ($fileKeyLength + strlen($ext) + 1) - CDNFile::MAX_FILE_PATH_LENGTH;
				if (strlen($filename) <= $truncateLength) {
					// Folder length exceeds CDNFile::MAX_FILE_PATH_LENGTH. MD5 file to prevent file loss log error
					SS_Log::log("CDNFile: Total file length (folders + name) exceeds " . CDNFile::MAX_FILE_PATH_LENGTH . " characters and can't be "
							. "trimmed. File key has been MD5 encoded. File key: " . md5($name) . $ext . " Filename: "
							. "$name", SS_Log::ERR);
					$name = md5($name) . $ext;
				} else {
					// Recombine folder and file name while truncating the filename and appending a ~ then extension
					$name = substr($name, 0, $lastPos) . '/' . substr($filename, 0, (0 - $truncateLength)) . '~' . $ext;
				}
			}


			$writer->write(fopen($path, 'r'), $name);

			// writer should now have an id
			$file->CDNFile = $writer->getContentId();
            $file->FileSize = @filesize($path);

            // check whether it's an image, and handle its dimensions
            if ($file instanceof CdnImage) {
                $file->storeDimensions();
            }

			$file->write();

            // confirm the remote upload is there, and delete the local file
            // Oct 2016 - UNLESS the versioned files extension is on, we have to treat it slightly different
            $this->deleteLocalIfExistsOnContentService();
		}
	}
371355
public function upload()
	{
		$response = array('uploaded' => false);

		foreach ((array)$_FILES as $file) {
			$targetFolder = isset($_POST['folder']) ? $_POST['folder'] : '/';
			$response = array_merge($response, $this->uploadFile($file, $targetFolder . '/'));
		}
        $this->returnJson($response);
	}
273201
private function load()
	{
		if ($this->isLoaded())
		{
			return;
		}

		$path = sprintf('%s/../../lang/%s.php', __DIR__, $this->locale);

		if (file_exists($path))
		{
			$this->loaded[$this->locale] = require $path;
		}
	}
1102660
private static function file()
    {
        $files = ['File', 'Filesystem'];
        $folder = static::$root.'Filesystem'.'/';

        self::call($files, $folder);

        $files = ['FileNotFoundException', 'DirectoryNotFoundException'];
        $folder = static::$root.'Filesystem/Exceptions'.'/';

        self::call($files, $folder);
    }
1370439
public function index() {
        $data = $this->request->data;

        if ($this->request->is('post')) {
            $data['FileUpload']['user_id'] = $this->Auth->user('id');

            try {
                if ($this->Model->save($data, true)) {
                    $this->Model->set($data);
                    $this->AdminToolbar->logAction(ActionLog::CREATE, $this->Model, $this->Model->id);

                    $this->AdminToolbar->setFlashMessage(__d('admin', 'Successfully uploaded a new file'));
                    $this->request->data = array();

                    if ($data[$this->Model->alias]['redirect_to'] === 'read') {
                        $this->redirect(array('plugin' => 'admin', 'controller' => 'crud', 'action' => 'read', 'model' => $this->Model->urlSlug, $this->Model->id));
                    }
                }
            } catch (Exception $e) {
                $this->AdminToolbar->setFlashMessage($e->getMessage(), 'is-error');
            }
        }

        if (empty($this->request->data)) {
            $this->request->data['FileUpload'] = Configure::read('Admin.uploads');
        }
    }
187110
public function process ()
		{
			if (!empty( $this->_params ))
			{
				if ($this->getIsUploading())
					$this->uploadChunk();
				else
					$this->testChunk();
			}
		}
907204
public function newAction(): void
    {
        try {
            $maximumFileUploadSize = $this->getMaximumFileUploadSize();
        } catch (FilesException $e) {
            $maximumFileUploadSize = null;
        }

        $this->view->assignMultiple([
            'tags' => $this->tagRepository->findAll(),
            'assetCollections' => $this->assetCollectionRepository->findAll(),
            'maximumFileUploadSize' => $maximumFileUploadSize,
            'humanReadableMaximumFileUploadSize' => Files::bytesToSizeString($maximumFileUploadSize)
        ]);
    }
1281021
public function update()
        {
                $ok = true;

                // perform updates...
                $ok = $this->updateFile(self::FILENAME_RULES);

                if ($ok)
                        $ok = $this->updateFile(self::FILENAME_CONVERTER);

                return $ok;
        }
629844
public function actionFileUpload() {

		$source = $this->config->getCompatibleSource($this->request->source);

		$root = $source->getRoot();
		$path = $source->getPath();

		$this->accessControl->checkPermission($this->getUserRole(), $this->action, $path);

		$messages = [];

		$files = $this->move($source);

		$isImages = [];
		$files = array_map(function (File $file) use ($source, $root, &$isImages) {
			$messages[] = 'File ' . $file->getName() . ' was uploaded';
			$isImages[] = $file->isImage();
			return str_replace($root, '', $file->getPath());
		}, $files);

		if (!count($files)) {
			throw new \Exception('No files have been uploaded', Consts::ERROR_CODE_NO_FILES_UPLOADED);
		}

		return [
			'baseurl' => $source->baseurl,
			'messages' => $messages,
			'files' => $files,
			'isImages' => $isImages
		];
	}
314908
public function actionDelete()
    {
        if(Yii::$app->request->isAjax)
        {
            $file_id = Yii::$app->request->post('file_id');
            $oneFile = OneFile::findOne($file_id);
            $modelName = $oneFile->model;
            $model = $modelName::findOne($oneFile->parent_id);

            $model->deleteFile($oneFile->name, $oneFile->subdir);
            $oneFile->delete();
            
            echo $file_id;
        }
    }
547167
public function doAfter() {
        if ($this->_footerController) {
            $viewPath = ROOT . DS . 'app' . DS . 'views' . DS .
                strtolower($this->_controller->getControllerName()) . DS .
                strtolower($this->_controller->getAction()) . DS . 'footer.php';
            if (file_exists($viewPath)) {
                $this->_controller->addView(FView::create(strtolower($this->_controller->getControllerName()) . DS .
                    strtolower($this->_controller->getAction()) . DS . 'footer.php', $this->getController()->getApp()));
            } elseif ($this->_footerGlobal) {
                $viewPath = ROOT . DS . 'app' . DS . 'views' . DS . 'footer.php';
                if (file_exists($viewPath)) {
                    $this->_controller->addView(FView::create('footer.php', $this->getController()->getApp()));
                }
            }
        }
    }
1046508
public function init() {
		$htmlId = $this->fileUploadControl->getHtmlId();
		
		foreach($this->elements as $type => $value) {
			if($type == "input") {
				$element = Html::el("input type='file' multiple='multiple'")->addAttributes([
					"id" => $htmlId,
					"name" => $this->fileUploadControl->getHtmlName(),
					"data-upload-component" => $htmlId
				]);
			} else if($type == "delete") {
				$element = Html::el("button type='button'")->addAttributes([
					"data-upload-component" => sprintf($this->idTemplate, $htmlId, $type)
				]);
			} else if($type == "imagePreview") {
				$element = Html::el("img")->addAttributes([
					"data-upload-component" => sprintf($this->idTemplate, $htmlId, $type)
				]);
			} else {
				$element = Html::el("div")->addAttributes([
					"data-upload-component" => sprintf($this->idTemplate, $htmlId, $type)
				]);
			}
			
			$this->elements[ $type ] = $element;
		}
	}
258846
public function index() {
		$isAppInstalled = $this->Installer->isAppInstalled();
		$isAppReadyInstall = $this->InstallerCheck->isAppReadyToInstall();
		$phpVesion = $this->InstallerCheck->checkPhpVersion();
		$phpModules = $this->InstallerCheck->checkPhpExtensions();
		$filesWritable = $this->InstallerCheck->checkFilesWritable();
		$connectDB = $this->InstallerCheck->checkConnectDb();

		$this->set(compact(
			'isAppInstalled',
			'isAppReadyInstall',
			'phpVesion',
			'phpModules',
			'filesWritable',
			'connectDB'
		));
	}