This commit is contained in:
Julio Cesar Laura Avendaño
2018-08-22 10:00:39 -04:00
parent 88f050d8e6
commit 4896b04408

View File

@@ -40,47 +40,21 @@
if (!defined('K_TCPDF_EXTERNAL_CONFIG')) { if (!defined('K_TCPDF_EXTERNAL_CONFIG')) {
// DOCUMENT_ROOT fix for IIS Webserver /**
if ((!isset($_SERVER['DOCUMENT_ROOT'])) OR (empty($_SERVER['DOCUMENT_ROOT']))) { * Path of tcpdf library.
if(isset($_SERVER['SCRIPT_FILENAME'])) { */
$_SERVER['DOCUMENT_ROOT'] = str_replace( '\\', '/', substr($_SERVER['SCRIPT_FILENAME'], 0, 0-strlen($_SERVER['PHP_SELF']))); define ('K_PATH_MAIN', PATH_THIRDPARTY . 'tcpdf' . PATH_SEP);
} elseif(isset($_SERVER['PATH_TRANSLATED'])) {
$_SERVER['DOCUMENT_ROOT'] = str_replace( '\\', '/', substr(str_replace('\\\\', '\\', $_SERVER['PATH_TRANSLATED']), 0, 0-strlen($_SERVER['PHP_SELF'])));
} else {
// define here your DOCUMENT_ROOT path if the previous fails (e.g. '/var/www')
$_SERVER['DOCUMENT_ROOT'] = '/';
}
}
// Automatic calculation for the following K_PATH_MAIN constant
$k_path_main = str_replace( '\\', '/', realpath(substr(dirname(__FILE__), 0, 0-strlen('config'))));
if (substr($k_path_main, -1) != '/') {
$k_path_main .= '/';
}
/** /**
* Installation path (/var/www/tcpdf/). * Build the URL
* By default it is automatically calculated but you can also set it as a fixed string to improve performances.
*/ */
define ('K_PATH_MAIN', $k_path_main); $protocol = G::is_https() ? "https://" : "http://";
$host = $_SERVER["SERVER_NAME"] . ($_SERVER["SERVER_PORT"] != "80" ? ":" . $_SERVER["SERVER_PORT"] : "");
// Automatic calculation for the following K_PATH_URL constant
$k_path_url = $k_path_main; // default value for console mode
if (isset($_SERVER['HTTP_HOST']) AND (!empty($_SERVER['HTTP_HOST']))) {
if(isset($_SERVER['HTTPS']) AND (!empty($_SERVER['HTTPS'])) AND strtolower($_SERVER['HTTPS'])!='off') {
$k_path_url = 'https://';
} else {
$k_path_url = 'http://';
}
$k_path_url .= $_SERVER['HTTP_HOST'];
$k_path_url .= str_replace( '\\', '/', substr(K_PATH_MAIN, (strlen($_SERVER['DOCUMENT_ROOT']) - 1)));
}
/** /**
* URL path to tcpdf installation folder (http://localhost/tcpdf/). * URL path to tcpdf installation folder (http://localhost/tcpdf/).
* By default it is automatically calculated but you can also set it as a fixed string to improve performances.
*/ */
define ('K_PATH_URL', $k_path_url); define ('K_PATH_URL', $protocol . $host . "/tcpdf/");
/** /**
* path for PDF fonts * path for PDF fonts