função para gerar o boleto

@param string $dest tipo de destino const BOLETOPDF_DEST_STANDARD | BOLETOPDF_DEST_DOWNLOAD | BOLETOPDF_DEST_SAVE | BOLETOPDF_DEST_STRING
@param null $save_path

@return string
@throws \Exception
767369
public function gerarBoleto($dest = self::OUTPUT_STANDARD, $save_path = null, $nameFile = null)
    {
        if ($this->totalBoletos == 0) {
            throw new \Exception('Nenhum Boleto adicionado');
        }

        for ($i = 0; $i < $this->totalBoletos; $i++) {
            $this->SetDrawColor('0', '0', '0');
            $this->AddPage();
            $this->instrucoes($i)->logoEmpresa($i)->Topo($i)->Bottom($i)->codigoBarras($i);
        }
        if ($dest == self::OUTPUT_SAVE) {
            $this->Output($save_path, $dest, $this->print);
            return $save_path;
        }
        if ($nameFile == null) {
            $nameFile = str_random(32);
        }
        
        return $this->Output($nameFile . '.pdf', $dest, $this->print);
    }
155122
public function checkPath($path = null)
  {
    if($path === null)
    {
      $path = $this->path;
    }

    if(strlen($path) == 0)
    {
      return TRUE;
    }

    $pattern = "/^" . $this->regex["path"] . "$/";
    $status = @preg_match($pattern, $path);

    if($status === FALSE)
    {
      throw new Exception("URI path validation failed");
    }

    return ($status == 1);
  }
196439
protected function _downloadFile($path) {
        // Push up memory_limit to deal with large files
        $mem = new Garp_Util_Memory();
        $mem->useHighMemory();

        $bytes = @file_get_contents($path);
        if (!$bytes) {
            throw new Zend_Controller_Action_Exception('File not found.', 404);
        }

        $download = Zend_Controller_Action_HelperBroker::getStaticHelper('download');
        $download->force($bytes, basename($path), $this->_response);

        Zend_Controller_Front::getInstance()->setParam('noViewRenderer', true);
        $this->_helper->viewRenderer->setNoRender();
    }
345966
protected function handleFileContent(
        $dest_path,
        $dest_name,
        $content,
        $contentType = '',
        $extract = false,
        $clean = false,
        $check_exist = false
    ){
        $ext = FileUtilities::getFileExtension($dest_name);
        if (empty($contentType)) {
            $contentType = FileUtilities::determineContentType($ext, $content);
        }
        if ((FileUtilities::isZipContent($contentType) || ('zip' === $ext)) && $extract) {
            // need to extract zip file and move contents to storage
            $tempDir = rtrim(sys_get_temp_dir(), DIRECTORY_SEPARATOR) . DIRECTORY_SEPARATOR;
            $tmpName = $tempDir . $dest_name;
            file_put_contents($tmpName, $content);
            $zip = new \ZipArchive();
            $code = $zip->open($tmpName);
            if (true !== $code) {
                unlink($tmpName);

                throw new InternalServerErrorException('Error opening temporary zip file. code = ' . $code);
            }

            $results = $this->extractZipFile($dest_path, $zip, $clean);
            unlink($tmpName);

            return $results;
        } else {
            $fullPathName = FileUtilities::fixFolderPath($dest_path) . $dest_name;
            $this->driver->writeFile($this->container, $fullPathName, $content, false, $check_exist);

            return ['name' => $dest_name, 'path' => $fullPathName, 'type' => 'file'];
        }
    }
932030
public function saveUrl($path, $url)
    {
        //Path and URL cannot be null
        if (is_null($path) || is_null($url)) {
            throw new Exceptions\BoxClientException("Path and URL cannot be null.");
        }

        //Save URL
        $response = $this->postToAPI('/files/save_url', ['path' => $path, 'url' => $url]);
        $body = $response->getDecodedBody();

        if (!isset($body['async_job_id'])) {
            throw new Exceptions\BoxClientException("Could not retrieve Async Job ID.");
        }

        //Return the Asunc Job ID
        return $body['async_job_id'];
    }
424286
public function make($src, $dest)
    {
        $windows = PlatformHelper::isWindows();

        $src  = str_replace(['/', '\\'], DIRECTORY_SEPARATOR, $src);
        $dest = str_replace(['/', '\\'], DIRECTORY_SEPARATOR, $dest);

        if ($windows) {
            return exec("mklink /D {$dest} {$src}");
        } else {
            return exec("ln -s {$src} {$dest}");
        }
    }
20369
public function save($path='',array $options=array()){
		if(!$path){
			if(!$this->path){
				throw new Exception("Wrong path specified");
			}
			$path=$this->path;
		}
		else if(substr($path,-1)=='/'){
			if(!$this->path){
				throw new Exception("Wrong path specified");
			}
			$path.=pathinfo($this->path,PATHINFO_BASENAME);
		}
		if(!file_put_contents($path,$this->adapter->getContents($options))){
			throw new Exception("Error encountered while saving '$path'");
		}
		$this->path=$path;
		return $path;
	}
1168001
protected function parseConnectionsFromSavePath($savePath)
    {
        $connections = (array) explode(',', $savePath);
        $connections = array_map('trim', $connections);

        return array_map([$this, 'parseConnectionItemFromSavePath'], $connections);
    }
155859
private function zSavePemFiles($x509certdata)
    {
        if (empty($this->pathCerts)) {
            throw new Exception(
                'Não está definido o diretório para armazenar os certificados.'
            );
        }
        if (! is_dir($this->pathCerts)) {
            throw new Exception(
                'Não existe o diretório para armazenar os certificados.'
            );
        }
        //recriar os arquivos pem com o arquivo pfx
        if (! file_put_contents($this->priKeyFile, $x509certdata['pkey'])) {
            throw new Exception(
                'Falha de permissão de escrita na pasta dos certificados!!'
            );
        }
        file_put_contents($this->pubKeyFile, $x509certdata['cert']);
        file_put_contents($this->certKeyFile, $x509certdata['pkey'] . "\r\n" . $x509certdata['cert']);
    }
1081449
private function getDownloadUrlForFile($path)
    {
        $metadataRaw = $this->getMetadata($path)->getBody()->getContents();
        $metadata = json_decode($metadataRaw);

        return $metadata->{'@content.downloadUrl'};
    }
365076
public function getDestDir($path = null) {
        if (!$path) {
            $dir = App::icfg('dir@media', App::icfg('upload.dir', 1));
            switch ($dir) {
                case 0:
                    $path = date('/Y/');
                    break;
                case 1:
                    $path = date('/Y/n/');
                    break;
                default:
                    $path = date('/Y/n/d/');
            }
            $rand_cnt = App::icfg('group_num@media', App::icfg('upload.group', 0));
            if ($rand_cnt > 1) {
                $cnt  = rand(0, $rand_cnt - 1);
                $path .= $cnt . '/';
            }
        }
        $uploadPath = App::cfg('upload.path', 'files');
        if ($path{0} == '@') {
            return substr($path, 1);
        } else if ($path{0} == '~') {
            $save_path = App::cfg('save_path@media', $uploadPath);
            if (!$save_path) {
                $save_path = 'files';
            }

            return trailingslashit($save_path) . substr($path, 1);
        } else {
            $save_path = App::cfg('save_path@media', $uploadPath);
            if (!$save_path) {
                $save_path = 'files';
            }

            return $save_path . $path;
        }
    }
426341
public function saveReport($path){
        if (!isset($this->rawreport)){
            return false;
        }
        try{
            file_put_contents($path, $this->rawreport);
            $this->log("Successfully saved report #".$this->options['ReportId']." at $path");
        } catch (Exception $e){
            $this->log("Unable to save report #".$this->options['ReportId']." at $path: $e",'Urgent');
            return false;
        }
    }
84775
public function generate($dest_folder, $dest_name, $orig_ext)
    {
        // Убираем из имени файла цифры в скобках, если они есть
        $dest_name = preg_replace('/\(.+\)/i', '', $dest_name);

        $file_name = $dest_name . '.' . $orig_ext;

        $check = $dest_folder . $file_name;
        $inc = 1;
        while (is_readable($check) && is_file($check)) {
            $file_name = $dest_name . '(' . $inc . ').' . $orig_ext;
            $check = $dest_folder . $file_name;
            $inc++;
        }

        return $file_name;
    }
277701
public static function parseFile($path)
    {
        if(!is_file($path))
        {
            throw new Exception('Invalid file path');
        }

        $toml = file_get_contents($path);

        // Remove BOM if present
        $toml = preg_replace('/^' . pack('H*','EFBBBF') . '/', '', $toml);

        return self::parse($toml);
    }
140010
public static function copy($path, $dest)
    {
		// Если это папка
        if (is_dir($path)) {
			// Создадим папку в том месте куда нужно копировать, если её там нет
            if (!file_exists($dest)) mkdir($dest, 0755, TRUE);

			// Получим содержание текущей папки
            $files = scandir($path);

			// Получим количетсво файлов в папке
            $files_count = sizeof($files);

			// Переберем полученные файлы
            for ($i = 2; $i < $files_count; $i++) {
				// Получим имя текущего файла
                $file = &$files[$i];

				// Получим полный путь к файлу источнику
                $source_path = $path . '/' . $file;

				// Получим полный путь к новому файлу
                $dest_path = $dest . '/' . $file;

				// Углубимся в рекурсию
                self::copy($source_path, $dest_path);
			}

			return TRUE;
        } // Просто скопируем файл
        else if (is_file($path)) {
			// Если передана папка как новый файл - получим имя файла
            if (is_dir($dest)) $dest .= pathinfo($path, PATHINFO_FILENAME) . '.' . pathinfo($path, PATHINFO_EXTENSION);

            return copy($path, $dest);
        } // Выходим
        else return FALSE;
    }
86500
public static function readFile($file_path)
    {
        try {
            $file = fopen($file_path, 'r');
            $content = fread($file, filesize($file_path));
            fclose($file);
            return $content;
        } catch (\Exception $e) {
            return '';
        }
    }
1260983
public static function copyResources($dest, $force, $filename_path, $debug)
    {
        if (file_exists($filename_path)) {
            $destfolder = basename($filename_path);
            if (!file_exists(WEB_DIR . $dest . DIRECTORY_SEPARATOR . $destfolder) || $debug || $force) {
                if (is_dir($filename_path)) {
                    self::copyr($filename_path, WEB_DIR . $dest . DIRECTORY_SEPARATOR . $destfolder);
                } else {
                    if (@copy($filename_path, WEB_DIR . $dest . DIRECTORY_SEPARATOR . $destfolder) === FALSE) {
                        throw new ConfigException("Can't copy " . $filename_path . " to " . WEB_DIR . $dest . DIRECTORY_SEPARATOR . $destfolder);
                    }
                }
            }
        }
    }