Replicates the tcpdf_config.php file
766198
private function initializeTcpdf()
    {
        if (defined('K_TCPDF_EXTERNAL_CONFIG')) {
            return;
        }

        define('K_TCPDF_EXTERNAL_CONFIG', true);

        /**
         * Installation path (/var/www/tcpdf/).
         */
        define('K_PATH_MAIN', $this->ensurePathEndsWithSlash($this->container->getParameter('orkestra.pdf.tcpdf.root_dir')));

        /**
         * URL path to tcpdf installation folder (http://localhost/tcpdf/).
         *
         * TODO: This should probably be some public path
         */
        define('K_PATH_URL', $this->ensurePathEndsWithSlash($this->container->getParameter('orkestra.pdf.tcpdf.root_dir')));

        /**
         * path for PDF fonts
         * use K_PATH_MAIN.'fonts/old/' for old non-UTF8 fonts
         */
        define('K_PATH_FONTS', $this->ensurePathEndsWithSlash($this->container->getParameter('orkestra.pdf.tcpdf.fonts_dir')));
        /**
         * cache directory for temporary files (full path)
         */
        define('K_PATH_CACHE', $this->ensurePathEndsWithSlash($this->container->getParameter('orkestra.pdf.cache_dir')));

        /**
         * cache directory for temporary files (url path)
         */
        define('K_PATH_URL_CACHE', $this->ensurePathEndsWithSlash($this->container->getParameter('orkestra.pdf.cache_dir')));

        /**
         *images directory
         */
        define('K_PATH_IMAGES', $this->ensurePathEndsWithSlash($this->container->getParameter('orkestra.pdf.tcpdf.image_dir')));

        /**
         * blank image
         */
        define('K_BLANK_IMAGE', K_PATH_IMAGES.'_blank.png');

        /**
         * height of cell respect font height
         */
        define('K_CELL_HEIGHT_RATIO', 1.25);

        /**
         * reduction factor for small font
         */
        define('K_SMALL_RATIO', 2/3);

        /**
         * set to true to enable the special procedure used to avoid the overlappind of symbols on Thai language
         */
        define('K_THAI_TOPCHARS', true);

        /**
         * if true allows to call TCPDF methods using HTML syntax
         * IMPORTANT: For security reason, disable this feature if you are printing user HTML content.
         */
        define('K_TCPDF_CALLS_IN_HTML', false);
    }
1201438
protected static function _setCustomConfigFiles( )
		{	
			/* custom config files */
			$files = array( '..' , '.' , 'app.php' , 'db.php' , 'debug.php' , 'init.php' , 'modules.php' ,
											'paths.php' , 'auth.php' , 'debug_ajax.php' );
			$scanned_directory = array_diff( scandir( ptc_path( 'root' ) . '/app/config' ) , $files );
			if ( !empty( $scanned_directory ) )
			{
				foreach ( $scanned_directory as $file )
				{
					$option_name = str_replace( '.php' , '' , $file );
					$options = Module::merge( ptc_path( 'root' ) . '/app/config/' . $file );
					if ( ptc_array_get( $options , '_load' ) )
					{
						$options = call_user_func( ptc_array_get( $options , '_load' ) , $options );
					}
					static::option( $option_name , $options );
				}
			}
			static::_loadModulesConfig( );
		}
710664
public function loadConfig()
    {
        // Load / create config file
        if (file_exists($this->baseDir . '/examples/config.php')) {
            include_once($this->baseDir . '/examples/config.php');
        } else {
            define('SECRET', readline('Secret: '));
            define('API_HOST', readline('Api host: '));

            $configTemplate = "<?php" . PHP_EOL
                . "define('SECRET', %s);" . PHP_EOL
                . "define('API_HOST', %s);" . PHP_EOL;

            file_put_contents(
                $this->baseDir . '/examples/config.php',
                sprintf(
                    $configTemplate,
                    var_export(SECRET, true),
                    var_export(API_HOST, true)
                )
            );
        }
    }
1257263
function FPDF($orientation='P', $unit='mm', $format='A4')
{
	//Some checks
	$this->_dochecks();
	//Initialization of properties
	$this->page=0;
	$this->n=2;
	$this->buffer='';
	$this->pages=array();
	$this->PageSizes=array();
	$this->state=0;
	$this->fonts=array();
	$this->FontFiles=array();
	$this->diffs=array();
	$this->images=array();
	$this->links=array();
	$this->InHeader=false;
	$this->InFooter=false;
	$this->lasth=0;
	$this->FontFamily='';
	$this->FontStyle='';
	$this->FontSizePt=12;
	$this->underline=false;
	$this->DrawColor='0 G';
	$this->FillColor='0 g';
	$this->TextColor='0 g';
	$this->ColorFlag=false;
	$this->ws=0;
	//Standard fonts
	$this->CoreFonts=array('courier'=>'Courier', 'courierB'=>'Courier-Bold', 'courierI'=>'Courier-Oblique', 'courierBI'=>'Courier-BoldOblique',
		'helvetica'=>'Helvetica', 'helveticaB'=>'Helvetica-Bold', 'helveticaI'=>'Helvetica-Oblique', 'helveticaBI'=>'Helvetica-BoldOblique',
		'times'=>'Times-Roman', 'timesB'=>'Times-Bold', 'timesI'=>'Times-Italic', 'timesBI'=>'Times-BoldItalic',
		'symbol'=>'Symbol', 'zapfdingbats'=>'ZapfDingbats');
	//Scale factor
	if($unit=='pt')
		$this->k=1;
	elseif($unit=='mm')
		$this->k=72/25.4;
	elseif($unit=='cm')
		$this->k=72/2.54;
	elseif($unit=='in')
		$this->k=72;
	else
		$this->Error('Incorrect unit: '.$unit);
	//Page format
	$this->PageFormats=array('a3'=>array(841.89,1190.55), 'a4'=>array(595.28,841.89), 'a5'=>array(420.94,595.28),
		'letter'=>array(612,792), 'legal'=>array(612,1008));
	if(is_string($format))
		$format=$this->_getpageformat($format);
	$this->DefPageFormat=$format;
	$this->CurPageFormat=$format;
	//Page orientation
	$orientation=strtolower($orientation);
	if($orientation=='p' || $orientation=='portrait')
	{
		$this->DefOrientation='P';
		$this->w=$this->DefPageFormat[0];
		$this->h=$this->DefPageFormat[1];
	}
	elseif($orientation=='l' || $orientation=='landscape')
	{
		$this->DefOrientation='L';
		$this->w=$this->DefPageFormat[1];
		$this->h=$this->DefPageFormat[0];
	}
	else
		$this->Error('Incorrect orientation: '.$orientation);
	$this->CurOrientation=$this->DefOrientation;
	$this->wPt=$this->w*$this->k;
	$this->hPt=$this->h*$this->k;
	//Page margins (1 cm)
	$margin=28.35/$this->k;
	$this->SetMargins($margin,$margin);
	//Interior cell margin (1 mm)
	$this->cMargin=$margin/10;
	//Line width (0.2 mm)
	$this->LineWidth=.567/$this->k;
	//Automatic page break
	$this->SetAutoPageBreak(true,2*$margin);
	//Full width display mode
	$this->SetDisplayMode('fullwidth');
	//Enable compression
	$this->SetCompression(true);
	//Set default PDF version number
	$this->PDFVersion='1.3';
}
1249135
public function actionPdf()
    {
        $this->getSearchCriteria();
        $this->layout = static::BLANK_LAYOUT;
        $this->dataProvider->pagination = false;
        $content = $this->render('pdf', [
            'dataProvider' => $this->dataProvider,
        ]);
        if (isset($_GET['test'])) {
            return $content;
        } else {
            $mpdf = new \mPDF();
            $mpdf->WriteHTML($content);

            Yii::$app->response->getHeaders()->set('Content-Type', 'application/pdf');
            Yii::$app->response->getHeaders()->set('Content-Disposition', 'attachment; filename="' . $this->getCompatibilityId() . '.pdf"');
            return $mpdf->Output($this->getCompatibilityId() . '.pdf', 'S');
        }
    }
651069
public static function phpini()
	{
		// disabled ?
		//
		if (!self::_debug())
		{
			return false;
		}

		if (!readable(get_cfg_var('cfg_file_path')))
		{
			return false;
		}

		// render it
		//
		?>
<div class="krumo-title">
This is a list of the configuration settings read from <code><b><?php echo get_cfg_var('cfg_file_path');?></b></code>.
</div>
		<?php
		return self::dump(parse_ini_file(get_cfg_var('cfg_file_path'), true));
	}
1015763
private function phpMailerSettings() {
        $phpMailer = new PHPMailer();
        if (strlen(env('MAIL_HOST')) > 0) {
            $phpMailer->SMTPDebug = 0;
            $phpMailer->isSMTP();
            $phpMailer->Host = env('MAIL_HOST');
            $phpMailer->SMTPAuth = true;
            $phpMailer->SMTPSecure = env('MAIL_SMTP_SECURE');
            $phpMailer->Port = env('MAIL_PORT');
            $phpMailer->Username = env('MAIL_USERNAME');
            $phpMailer->Password = env('MAIL_PASSWORD');
        } else {
            $phpMailer->isMail();
        }

        $phpMailer->isHTML(true);

        $this->mailer = $phpMailer;
    }
545443
protected function _init()
    {
        // get the Web Colors from TCPDF
        require(K_PATH_MAIN.'htmlcolors.php');
        $this->_htmlColor = $webcolor;

        // init the Style
        $this->table = array();
        $this->value = array();
        $this->initStyle();

        // Init the styles without legacy
        $this->resetStyle();
    }
855895
private function generatePhpDocParameters(): void
  {
    $parameters = [];
    foreach ($this->routine['phpdoc']['parameters'] as $parameter)
    {
      $mangledName = $this->nameMangler->getParameterName($parameter['parameter_name']);

      $parameters[] = ['php_name'             => '$'.$mangledName,
                       'description'          => $parameter['description'],
                       'php_type'             => $parameter['php_type'],
                       'data_type_descriptor' => $parameter['data_type_descriptor']];
    }

    $this->enhancePhpDocParameters($parameters);

    if (!empty($parameters))
    {
      // Compute the max lengths of parameter names and the PHP types of the parameters.
      $max_name_length = 0;
      $max_type_length = 0;
      foreach ($parameters as $parameter)
      {
        $max_name_length = max($max_name_length, mb_strlen($parameter['php_name']));
        $max_type_length = max($max_type_length, mb_strlen($parameter['php_type']));
      }

      $this->codeStore->append(' *', false);

      // Generate phpDoc for the parameters of the wrapper method.
      foreach ($parameters as $parameter)
      {
        $format = sprintf(' * %%-%ds %%-%ds %%-%ds %%s', mb_strlen('@param'), $max_type_length, $max_name_length);

        $lines = explode(PHP_EOL, $parameter['description'] ?? '');
        if (!empty($lines))
        {
          $line = array_shift($lines);
          $this->codeStore->append(sprintf($format, '@param', $parameter['php_type'], $parameter['php_name'], $line), false);
          foreach ($lines as $line)
          {
            $this->codeStore->append(sprintf($format, ' ', ' ', ' ', $line), false);
          }
        }
        else
        {
          $this->codeStore->append(sprintf($format, '@param', $parameter['php_type'], $parameter['php_name'], ''), false);
        }

        if ($parameter['data_type_descriptor']!==null)
        {
          $this->codeStore->append(sprintf($format, ' ', ' ', ' ', $parameter['data_type_descriptor']), false);
        }
      }
    }
  }
81417
protected function pointConfigFileTemplatesToNewLocation()
    {
        $configPath = app_path('config/packages/way/generators/config.php');
        $updated = str_replace('vendor/way/generators/src/Way/Generators/templates', $this->option('path'), File::get($configPath));

        File::put($configPath, $updated);
    }
1227413
public function generatePDF()
    {
        if (!$this->owner->data()->config()->get('pdf_export')) {
            return false;
        }

        $binaryPath = $this->owner->data()->config()->get('wkhtmltopdf_binary');
        if ($binaryPath) {
            Deprecation::notice('3.0', 'wkhtmltopdf_binary config is deprecated. '.
                'Use WKHTMLTOPDF_BINARY env var instead.');
        }
        if (!$binaryPath || !is_executable($binaryPath)) {
            if (Environment::getEnv('WKHTMLTOPDF_BINARY')
                && is_executable(Environment::getEnv('WKHTMLTOPDF_BINARY'))
            ) {
                $binaryPath = Environment::getEnv('WKHTMLTOPDF_BINARY');
            }
        }

        if (!$binaryPath) {
            user_error(
                'Neither WKHTMLTOPDF_BINARY nor ' . get_class($this->owner->data()) . '.wkhtmltopdf_binary are defined',
                E_USER_ERROR
            );
        }

        if (Versioned::get_reading_mode() == 'Stage.Stage') {
            user_error('Generating PDFs on draft is not supported', E_USER_ERROR);
        }

        set_time_limit(60);

        // prepare the paths
        $pdfFile = $this->owner->data()->getPdfFilename();
        $bodyFile = str_replace('.pdf', '_pdf.html', $pdfFile);
        $footerFile = str_replace('.pdf', '_pdffooter.html', $pdfFile);

        // make sure the work directory exists
        if (!file_exists(dirname($pdfFile))) {
            Filesystem::makeFolder(dirname($pdfFile));
        }

        //decide the domain to use in generation
        $pdfBaseUrl = $this->owner->getPDFBaseURL();

        // Force http protocol on CWP - fetching from localhost without using the proxy, SSL terminates on gateway.
        if (Environment::getEnv('CWP_ENVIRONMENT')) {
            Config::modify()->set(Director::class, 'alternate_protocol', 'http');
            //only set alternate protocol if CWP_SECURE_DOMAIN is defined OR pdf_base_url is
            if ($pdfBaseUrl) {
                Config::modify()->set(Director::class, 'alternate_base_url', 'http://' . $pdfBaseUrl);
            }
        }

        $bodyViewer = $this->owner->getViewer('pdf');

        // write the output of this page to HTML, ready for conversion to PDF
        file_put_contents($bodyFile, $bodyViewer->process($this->owner));

        // get the viewer for the current template with _pdffooter
        $footerViewer = $this->owner->getViewer('pdffooter');

        // write the output of the footer template to HTML, ready for conversion to PDF
        file_put_contents($footerFile, $footerViewer->process($this->owner));

        //decide what the proxy should look like
        $proxy = $this->owner->getPDFProxy($pdfBaseUrl);

        // finally, generate the PDF
        $command = $binaryPath . $proxy . ' --outline -B 40pt -L 20pt -R 20pt -T 20pt --encoding utf-8 '
            . '--orientation Portrait --disable-javascript --quiet --print-media-type ';
        $retVal = 0;
        $output = [];
        exec(
            $command . " --footer-html \"$footerFile\" \"$bodyFile\" \"$pdfFile\" &> /dev/stdout",
            $output,
            $retVal
        );

        // remove temporary file
        unlink($bodyFile);
        unlink($footerFile);

        // output any errors
        if ($retVal != 0) {
            user_error('wkhtmltopdf failed: ' . implode("\n", $output), E_USER_ERROR);
        }

        // serve the generated file
        return HTTPRequest::send_file(file_get_contents($pdfFile), basename($pdfFile), 'application/pdf');
    }
1359245
private function configureDebug()
    {
        if($debug = $this->config['cas_debug'])
        {
            $path = (gettype($debug) == 'string') ? $debug : '';
            phpCAS::setDebug($path);
            // https://github.com/Jasig/phpCAS/commit/bb382f5038f6241c7c577fb55430ad505f1f6e23
            phpCAS::setVerbose(true);
        }
    }
1374059
protected function headerSettings()
    {
        $this->setPrintHeader(
            Config::get('laravel-tcpdf::header_on')
        );

        $this->setHeaderFont(array(
            Config::get('laravel-tcpdf::header_font'),
            '',
            Config::get('laravel-tcpdf::header_font_size')
        ));

        $this->setHeaderMargin(
            Config::get('laravel-tcpdf::header_margin')
        );

        $this->SetHeaderData(
            Config::get('laravel-tcpdf::header_logo'),
            Config::get('laravel-tcpdf::header_logo_width'),
            Config::get('laravel-tcpdf::header_title'),
            Config::get('laravel-tcpdf::header_string')
        );
    }
1324140
def insertPDF(self, docsrc, from_page=-1, to_page=-1, start_at=-1, rotate=-1, links=1):
        """"""
        if self.isClosed or self.isEncrypted:
            raise ValueError("operation illegal for closed / encrypted doc")
        if id(self) == id(docsrc):
            raise ValueError("source must not equal target PDF")
        sa = start_at
        if sa < 0:
            sa = self.pageCount

        val = _fitz.Document_insertPDF(self, docsrc, from_page, to_page, start_at, rotate, links)
        self._reset_page_refs()
        if links:
            self._do_links(docsrc, from_page = from_page, to_page = to_page,
                           start_at = sa)

        return val
1210961
private function copyInstallTemplate()
    {
        Config::writeFile("index.php", file_get_contents(PATH_HOME . VENDOR . "config/public/installTemplates/index.txt"));
        Config::writeFile("apiView.php", file_get_contents(PATH_HOME . VENDOR . "config/public/installTemplates/apiView.txt"));
        Config::writeFile("apiGet.php", file_get_contents(PATH_HOME . VENDOR . "config/public/installTemplates/apiGet.txt"));
        Config::writeFile("apiSet.php", file_get_contents(PATH_HOME . VENDOR . "config/public/installTemplates/apiSet.txt"));
        Config::writeFile("apiApi.php", file_get_contents(PATH_HOME . VENDOR . "config/public/installTemplates/apiApi.txt"));
        Config::writeFile("apiApiPublic.php", file_get_contents(PATH_HOME . VENDOR . "config/public/installTemplates/apiApiPublic.txt"));

        //Bloqueios por .htaccess
        Config::writeFile("_config/.htaccess", "Deny from all");
        Config::writeFile("entity/.htaccess", "Deny from all");
        Config::writeFile("public/react/.htaccess", "Deny from all");
        Config::writeFile("public/cron/.htaccess", "Deny from all");
        Config::writeFile("public/api/.htaccess", "Deny from all");
        Config::writeFile("vendor/.htaccess", $this->getAccessFile());

        if (!file_exists(PATH_HOME . "entity/general/general_info.json"))
            Config::writeFile("entity/general/general_info.json", "[]");
    }
426531
static function get_instance($paper = null, $orientation = null,  $class = null) {

    $backend = strtolower(DOMPDF_PDF_BACKEND);
    
    if ( isset($class) && class_exists($class, false) )
      $class .= "_Adapter";
    
    else if ( (DOMPDF_PDF_BACKEND === "auto" || $backend === "pdflib" ) &&
              class_exists("PDFLib", false) )
      $class = "PDFLib_Adapter";

    // FIXME The TCPDF adapter is not ready yet
    //else if ( (DOMPDF_PDF_BACKEND === "auto" || $backend === "cpdf") )
    //  $class = "CPDF_Adapter";

    else if ( $backend === "tcpdf")
      $class = "TCPDF_Adapter";
      
    else if ( $backend === "gd" )
      $class = "GD_Adapter";
    
    else
      $class = "CPDF_Adapter";

    return new $class($paper, $orientation);
        
  }
1017783
def create_config_files(directory):
    
    # get the config file template
    template_url = ("https://securenetconnection.com/vpnconfig/"
                    "openvpn-template.ovpn")
    resp = requests.get(template_url)
    resp.raise_for_status()
    template = resp.content

    # get the available servers and create a config file for each server
    server_url = ("https://securenetconnection.com/vpnconfig/"
                  "servers-cli.php")
    resp = requests.get(server_url)
    resp.raise_for_status()
    servers = resp.content.split("\n")

    if not os.path.exists(directory):
        os.makedirs(directory)
    with open(os.path.join(directory, "servers.txt"), 'w') as f:
        f.write(resp.content)

    for server_line in servers:
        if server_line.strip() == "":
            continue
        server_line = server_line.split("|")
        try:
            ip, desc, country, udp_sup, tcp_sup = server_line
        except ValueError:
            ip, desc, country, udp_sup, tcp_sup, no_rand = server_line
        with open(os.path.join(directory, ip + ".ovpn"), 'w') as file_o:
            file_o.write(template)
            # create tcp if available, else udp
            tcp_sup = tcp_sup.strip()
            if tcp_sup:
                port, proto = 443, "tcp"
            else:
                port, proto = 53, "udp"
            file_o.write("remote {0} {1}\n".format(ip, port))
            file_o.write("proto {0}\n".format(proto))
            # add automatic dns server update
            file_o.write("up /etc/openvpn/update-resolv-conf\n")
            file_o.write("down /etc/openvpn/update-resolv-conf\n")