Put the application in down mode.

@throws Exceptions\FileException

@return bool true if success and false if something fails.
551639
public function setDownMode()
    {
        $file = $this->maintenanceFilePath();

        if (!touch($file)) {
            $message = sprintf(
                'Something went wrong on trying to create maintenance file %s.',
                $file
            );

            throw new Exceptions\FileException($message);
        }

        return true;
    }
1272545
public function close()
    {
        if (false === $this->openned) {
            return false;
        }
        $this->pclzip = $this->filename = null;
        $this->openned = false;
        if (file_exists(self::TMP_DIR)) {
            $this->_rrmdir(self::TMP_DIR);
            rmdir(self::TMP_DIR);
        }
        return true;
    }
1336469
public static function shutdown()
    {
        if (\is_null($e = \error_get_last()) === false) {
            self::exceptionHandler(new \sb\Exception($e['type'], $e['message'], $e['file'], $e['line']));
        }
    }
457850
public function lock()
    {
        if ($this->isRunning())
            return false;

        $pidFile = $this->directory.$this->filename;

        if (!is_writable($this->directory)) {
            throw new \Exception('Can not write to folder: '.$this->directory);
        }

        if (file_exists($pidFile) && !is_writable($pidFile)) {
            throw new \Exception('Can not write to file: '.$pidFile);
        }

        $file = fopen($pidFile, 'w');
        if ($file === false) {
            return false;
        }

        fputs($file, getmypid());
        fclose($file);

        return true;
    }
278372
function drop() {
		if ($this->lazy) // intentional
			$this->data=[];
		if (!$this->dir)
			$this->data=[];
		elseif ($glob=@glob($this->dir.'/*',GLOB_NOSORT))
			foreach ($glob as $file)
				@unlink($file);
	}
858315
public function handleShutdown()
    {
        if ($exception = error_get_last()) {
            if ($this->isFatal($exception['type'])) {
                $this->record($exception);
                $exception['trace'] = '';
                if ($this->container->runningInConsole()) {
                    $this->renderForConsole($exception);
                }

                if (!$this->container->runningInConsole()) {
                    $this->renderHttpResponse($exception);
                }
            }
        }
    }
691510
public function handleShutdown()
	{
		if ( !is_null( $error = error_get_last() ) && in_array( $error['type'], [
				E_ERROR,
				E_CORE_ERROR,
				E_COMPILE_ERROR,
				E_PARSE
			] )
		)
		{
			$this->handleException( new FatalErrorException( $error['message'], $error['type'], 0, $error['file'], $error['line'], 0 ) );
		}
	}
392431
public function handleShutdown()
    {
        if (is_null($error = error_get_last()) || ! $this->isFatal($error['type'])) {
            return;
        }

        if (Config::getEnv("app.debug")) {
            echo "<pre>";
            echo "Exception : " , $error['message'] , "<br>";
            echo "Catch position: " . $error['file'] . " : " . $error['line'];
        } else {
            echo strval(Config::getEnv("app.prod_tip"));
        }

        exit;
    }
603288
public function handleShutdown()
	{
		if (!$this->shutdownHandlerRegistered)
		{
			return;
		}

		$error = error_get_last();
		if ($error && Severity::fromPhpErrorNo($error['type']) >= $this->minSeverityOnShutdown)
		{
			$this->handleError(
				$error['type'],
				$error['message'],
				$error['file'],
				$error['line']
			);
		}
	}
843812
public function gracefulShutdown()
    {
        if ($this->finished) {
            return !$this->writing;
        }

        $this->logoff();

        $this->finish();

        return false;
    }
1017883
public function shutdownHandler()
    {
        // Get last error
        if (null === $lastError = error_get_last()) {
            return;
        }

        if ($this->shouldCaptureFatalError($lastError['type'], $lastError['message'])) {
            $exception = new ErrorException(
                @$lastError['message'], 0, @$lastError['type'],
                @$lastError['file'], @$lastError['line']
            );

            $this->exceptionHandler($exception);
        }
    }
359668
public function stream_eof()
    {
        if ($this->fileHandle === null) {
            return false;
        }
        self::restore();
        $success = feof($this->fileHandle);
        self::register();
        return $success;
    }
1240266
public function handleShutdown()
	{
		$error = error_get_last();

		// If an error has occurred that has not been displayed, we will create a fatal
		// error exception instance and pass it into the regular exception handling
		// code so it can be displayed back out to the developer for information.
		if ( ! is_null($error))
		{
			extract($error);

			if ( ! $this->isFatal($type)) return;

			$this->handleException(new FatalError($message, $type, 0, $file, $line))->send();
		}
	}
153904
protected function moveFile()
    {
        // if there is an error when moving the file, an exception will
        // be automatically thrown by move(). This will properly prevent
        // the entity from being persisted to the database on error
        $this->getFile()->move($this->getUploadRootDir(), $this->path);

        $this->setFile(null);
    }
121409
protected function perform()
    {
        if ($this->isQuietModeDisabled()) {
            $this->fixer->disableQuietMode();
        }

        $spl = new SplFileInfo($this->file->path());

        return (bool) $this->fixer->fixFile($spl);
    }
206178
public static function shutdownError()
    {
        // Load last error if thrown
        $errfile = 'Unknown file';
        $errstr = 'shutdown';
        $errno = E_CORE_ERROR;
        $errline = 0;

        $error = error_get_last();
        if ($error !== null) {
            $errno = $error['type'];
            $errfile = $error['file'];
            $errline = $error['line'];
            $errstr = $error['message'];

            // Log it!
            $thisType = self::getType($errno);
            Factory::getInstance()->output->set_output('');
            self::errorHandler($errno, $errstr, $errfile, $errline);

            if ($thisType == 'ERROR')
            {
               self::http_error('500'); 
            }
        }
    }
230416
private function fileSend()
    {
        $attemptCount = 0;
        $successCount = 0;
        if (isset($this->payload->operations)) {
            foreach ($this->payload->operations as $type => $operation) {
                if (is_object($operation)) {
                    ++$attemptCount;
                    $result = false;
                    $now    = new \DateTime();
                    $this->setLogs($now->format(\DateTime::ISO8601), $type.'started');
                    try {
                        switch ($type) {
                            case 'email':
                                $result = $this->operationEmail($operation);
                                break;

                            case 'ftp':
                                $result = $this->operationFtp($operation);
                                break;

                            case 'sftp':
                                $result = $this->operationSftp($operation);
                                break;

                            case 's3':
                                $result = $this->operationS3($operation);
                                break;
                        }
                    } catch (\Exception $e) {
                        $message = 'Unable to send file to '.$type.': '.$e->getMessage();
                        $this->setLogs($message, $type.'error');
                    }
                    if ($result) {
                        ++$successCount;
                    }
                }
            }
        }
        if (!$attemptCount) {
            $this->setLogs(
                'No file send operations are enabled. Please add a file send operation to be tested',
                'error'
            );
        } elseif ($successCount === $attemptCount) {
            $this->file->setStatus(File::STATUS_SENT);
            $this->valid = true;
        } elseif ($successCount < $attemptCount) {
            $this->file->setStatus(File::STATUS_ERROR);
            $this->valid = false;
        }
        $this->setLogs($this->file->getStatus(), 'fileStatus');
        $this->setLogs($this->valid, 'valid');
        $this->fileEntityAddLogs();
        $this->fileEntitySave();

        return $this;
    }