PageRenderTime 65ms CodeModel.GetById 29ms RepoModel.GetById 0ms app.codeStats 1ms

/manager/includes/document.parser.class.inc.php

https://github.com/HenrikNielsen/evolution
PHP | 2851 lines | 2388 code | 215 blank | 248 comment | 589 complexity | 449c38c80d0ee0bd5012b61a79b59a25 MD5 | raw file
Possible License(s): GPL-2.0, LGPL-2.1, BSD-3-Clause, AGPL-1.0

Large files files are truncated, but you can click here to view the full file

  1. <?php
  2. /**
  3. * MODx Document Parser
  4. * Function: This class contains the main document parsing functions
  5. *
  6. */
  7. class DocumentParser {
  8. var $db; // db object
  9. var $event, $Event; // event object
  10. var $pluginEvent;
  11. var $config= null;
  12. var $rs, $result, $sql, $table_prefix, $debug, $documentIdentifier, $documentMethod, $documentGenerated, $documentContent, $tstart, $minParserPasses, $maxParserPasses, $documentObject, $templateObject, $snippetObjects, $stopOnNotice, $executedQueries, $queryTime, $currentSnippet, $documentName, $aliases, $visitor, $entrypage, $documentListing, $dumpSnippets, $chunkCache, $snippetCache, $contentTypes, $dumpSQL, $queryCode, $virtualDir, $placeholders, $sjscripts, $jscripts, $loadedjscripts, $documentMap;
  13. var $forwards= 3;
  14. // constructor
  15. function DocumentParser() {
  16. $this->loadExtension('DBAPI') or die('Could not load DBAPI class.'); // load DBAPI class
  17. $this->dbConfig= & $this->db->config; // alias for backward compatibility
  18. $this->jscripts= array ();
  19. $this->sjscripts= array ();
  20. $this->loadedjscripts= array ();
  21. // events
  22. $this->event= new SystemEvent();
  23. $this->Event= & $this->event; //alias for backward compatibility
  24. $this->pluginEvent= array ();
  25. // set track_errors ini variable
  26. @ ini_set("track_errors", "1"); // enable error tracking in $php_errormsg
  27. }
  28. // loads an extension from the extenders folder
  29. function loadExtension($extname) {
  30. global $database_type;
  31. switch ($extname) {
  32. // Database API
  33. case 'DBAPI' :
  34. if (!include_once MODX_BASE_PATH . 'manager/includes/extenders/dbapi.' . $database_type . '.class.inc.php')
  35. return false;
  36. $this->db= new DBAPI;
  37. return true;
  38. break;
  39. // Manager API
  40. case 'ManagerAPI' :
  41. if (!include_once MODX_BASE_PATH . 'manager/includes/extenders/manager.api.class.inc.php')
  42. return false;
  43. $this->manager= new ManagerAPI;
  44. return true;
  45. break;
  46. default :
  47. return false;
  48. }
  49. }
  50. function getMicroTime() {
  51. list ($usec, $sec)= explode(' ', microtime());
  52. return ((float) $usec + (float) $sec);
  53. }
  54. function sendRedirect($url, $count_attempts= 0, $type= '', $responseCode= '') {
  55. if (empty ($url)) {
  56. return false;
  57. } else {
  58. if ($count_attempts == 1) {
  59. // append the redirect count string to the url
  60. $currentNumberOfRedirects= isset ($_REQUEST['err']) ? $_REQUEST['err'] : 0;
  61. if ($currentNumberOfRedirects > 3) {
  62. $this->messageQuit('Redirection attempt failed - please ensure the document you\'re trying to redirect to exists. <p>Redirection URL: <i>' . $url . '</i></p>');
  63. } else {
  64. $currentNumberOfRedirects += 1;
  65. if (strpos($url, "?") > 0) {
  66. $url .= "&err=$currentNumberOfRedirects";
  67. } else {
  68. $url .= "?err=$currentNumberOfRedirects";
  69. }
  70. }
  71. }
  72. if ($type == 'REDIRECT_REFRESH') {
  73. $header= 'Refresh: 0;URL=' . $url;
  74. }
  75. elseif ($type == 'REDIRECT_META') {
  76. $header= '<META HTTP-EQUIV="Refresh" CONTENT="0; URL=' . $url . '" />';
  77. echo $header;
  78. exit;
  79. }
  80. elseif ($type == 'REDIRECT_HEADER' || empty ($type)) {
  81. // check if url has /$base_url
  82. global $base_url, $site_url;
  83. if (substr($url, 0, strlen($base_url)) == $base_url) {
  84. // append $site_url to make it work with Location:
  85. $url= $site_url . substr($url, strlen($base_url));
  86. }
  87. if (strpos($url, "\n") === false) {
  88. $header= 'Location: ' . $url;
  89. } else {
  90. $this->messageQuit('No newline allowed in redirect url.');
  91. }
  92. }
  93. if ($responseCode && (strpos($responseCode, '30') !== false)) {
  94. header($responseCode);
  95. }
  96. header($header);
  97. exit();
  98. }
  99. }
  100. function sendForward($id, $responseCode= '') {
  101. if ($this->forwards > 0) {
  102. $this->forwards= $this->forwards - 1;
  103. $this->documentIdentifier= $id;
  104. $this->documentMethod= 'id';
  105. $this->documentObject= $this->getDocumentObject('id', $id);
  106. if ($responseCode) {
  107. header($responseCode);
  108. }
  109. $this->prepareResponse();
  110. exit();
  111. } else {
  112. header('HTTP/1.0 500 Internal Server Error');
  113. die('<h1>ERROR: Too many forward attempts!</h1><p>The request could not be completed due to too many unsuccessful forward attempts.</p>');
  114. }
  115. }
  116. function sendErrorPage() {
  117. // invoke OnPageNotFound event
  118. $this->invokeEvent('OnPageNotFound');
  119. // $this->sendRedirect($this->makeUrl($this->config['error_page'], '', '&refurl=' . urlencode($_SERVER['PHP_SELF'] . '?' . $_SERVER['QUERY_STRING'])), 1);
  120. $this->sendForward($this->config['error_page'] ? $this->config['error_page'] : $this->config['site_start'], 'HTTP/1.0 404 Not Found');
  121. exit();
  122. }
  123. function sendUnauthorizedPage() {
  124. // invoke OnPageUnauthorized event
  125. $_REQUEST['refurl'] = $this->documentIdentifier;
  126. $this->invokeEvent('OnPageUnauthorized');
  127. if ($this->config['unauthorized_page']) {
  128. $unauthorizedPage= $this->config['unauthorized_page'];
  129. } elseif ($this->config['error_page']) {
  130. $unauthorizedPage= $this->config['error_page'];
  131. } else {
  132. $unauthorizedPage= $this->config['site_start'];
  133. }
  134. $this->sendForward($unauthorizedPage, 'HTTP/1.1 401 Unauthorized');
  135. exit();
  136. }
  137. // function to connect to the database
  138. // - deprecated use $modx->db->connect()
  139. function dbConnect() {
  140. $this->db->connect();
  141. $this->rs= $this->db->conn; // for compatibility
  142. }
  143. // function to query the database
  144. // - deprecated use $modx->db->query()
  145. function dbQuery($sql) {
  146. return $this->db->query($sql);
  147. }
  148. // function to count the number of rows in a record set
  149. function recordCount($rs) {
  150. return $this->db->getRecordCount($rs);
  151. }
  152. // - deprecated, use $modx->db->getRow()
  153. function fetchRow($rs, $mode= 'assoc') {
  154. return $this->db->getRow($rs, $mode);
  155. }
  156. // - deprecated, use $modx->db->getAffectedRows()
  157. function affectedRows($rs) {
  158. return $this->db->getAffectedRows($rs);
  159. }
  160. // - deprecated, use $modx->db->getInsertId()
  161. function insertId($rs) {
  162. return $this->db->getInsertId($rs);
  163. }
  164. // function to close a database connection
  165. // - deprecated, use $modx->db->disconnect()
  166. function dbClose() {
  167. $this->db->disconnect();
  168. }
  169. function getSettings() {
  170. if (!is_array($this->config) || empty ($this->config)) {
  171. if ($included= file_exists(MODX_BASE_PATH . 'assets/cache/siteCache.idx.php')) {
  172. $included= include_once (MODX_BASE_PATH . 'assets/cache/siteCache.idx.php');
  173. }
  174. if (!$included || !is_array($this->config) || empty ($this->config)) {
  175. include_once MODX_BASE_PATH . "/manager/processors/cache_sync.class.processor.php";
  176. $cache = new synccache();
  177. $cache->setCachepath(MODX_BASE_PATH . "/assets/cache/");
  178. $cache->setReport(false);
  179. $rebuilt = $cache->buildCache($this);
  180. $included = false;
  181. if($rebuilt && $included= file_exists(MODX_BASE_PATH . 'assets/cache/siteCache.idx.php')) {
  182. $included= include MODX_BASE_PATH . 'assets/cache/siteCache.idx.php';
  183. }
  184. if(!$included) {
  185. $result= $this->db->query('SELECT setting_name, setting_value FROM ' . $this->getFullTableName('system_settings'));
  186. while ($row= $this->db->getRow($result, 'both')) {
  187. $this->config[$row[0]]= $row[1];
  188. }
  189. }
  190. }
  191. // added for backwards compatibility - garry FS#104
  192. $this->config['etomite_charset'] = & $this->config['modx_charset'];
  193. // store base_url and base_path inside config array
  194. $this->config['base_url']= MODX_BASE_URL;
  195. $this->config['base_path']= MODX_BASE_PATH;
  196. $this->config['site_url']= MODX_SITE_URL;
  197. // load user setting if user is logged in
  198. $usrSettings= array ();
  199. if ($id= $this->getLoginUserID()) {
  200. $usrType= $this->getLoginUserType();
  201. if (isset ($usrType) && $usrType == 'manager')
  202. $usrType= 'mgr';
  203. if ($usrType == 'mgr' && $this->isBackend()) {
  204. // invoke the OnBeforeManagerPageInit event, only if in backend
  205. $this->invokeEvent("OnBeforeManagerPageInit");
  206. }
  207. if (isset ($_SESSION[$usrType . 'UsrConfigSet'])) {
  208. $usrSettings= & $_SESSION[$usrType . 'UsrConfigSet'];
  209. } else {
  210. if ($usrType == 'web')
  211. $query= $this->getFullTableName('web_user_settings') . ' WHERE webuser=\'' . $id . '\'';
  212. else
  213. $query= $this->getFullTableName('user_settings') . ' WHERE user=\'' . $id . '\'';
  214. $result= $this->db->query('SELECT setting_name, setting_value FROM ' . $query);
  215. while ($row= $this->db->getRow($result, 'both'))
  216. $usrSettings[$row[0]]= $row[1];
  217. if (isset ($usrType))
  218. $_SESSION[$usrType . 'UsrConfigSet']= $usrSettings; // store user settings in session
  219. }
  220. }
  221. if ($this->isFrontend() && $mgrid= $this->getLoginUserID('mgr')) {
  222. $musrSettings= array ();
  223. if (isset ($_SESSION['mgrUsrConfigSet'])) {
  224. $musrSettings= & $_SESSION['mgrUsrConfigSet'];
  225. } else {
  226. $query= $this->getFullTableName('user_settings') . ' WHERE user=\'' . $mgrid . '\'';
  227. if ($result= $this->db->query('SELECT setting_name, setting_value FROM ' . $query)) {
  228. while ($row= $this->db->getRow($result, 'both')) {
  229. $usrSettings[$row[0]]= $row[1];
  230. }
  231. $_SESSION['mgrUsrConfigSet']= $musrSettings; // store user settings in session
  232. }
  233. }
  234. if (!empty ($musrSettings)) {
  235. $usrSettings= array_merge($musrSettings, $usrSettings);
  236. }
  237. }
  238. $this->config= array_merge($this->config, $usrSettings);
  239. }
  240. }
  241. function getDocumentMethod() {
  242. // function to test the query and find the retrieval method
  243. if (isset ($_REQUEST['q'])) {
  244. return "alias";
  245. }
  246. elseif (isset ($_REQUEST['id'])) {
  247. return "id";
  248. } else {
  249. return "none";
  250. }
  251. }
  252. function getDocumentIdentifier($method) {
  253. // function to test the query and find the retrieval method
  254. $docIdentifier= $this->config['site_start'];
  255. switch ($method) {
  256. case 'alias' :
  257. $docIdentifier= $this->db->escape($_REQUEST['q']);
  258. break;
  259. case 'id' :
  260. if (!is_numeric($_REQUEST['id'])) {
  261. $this->sendErrorPage();
  262. } else {
  263. $docIdentifier= intval($_REQUEST['id']);
  264. }
  265. break;
  266. }
  267. return $docIdentifier;
  268. }
  269. // check for manager login session
  270. function checkSession() {
  271. if (isset ($_SESSION['mgrValidated'])) {
  272. return true;
  273. } else {
  274. return false;
  275. }
  276. }
  277. function checkPreview() {
  278. if ($this->checkSession() == true) {
  279. if (isset ($_REQUEST['z']) && $_REQUEST['z'] == 'manprev') {
  280. return true;
  281. } else {
  282. return false;
  283. }
  284. } else {
  285. return false;
  286. }
  287. }
  288. // check if site is offline
  289. function checkSiteStatus() {
  290. $siteStatus= $this->config['site_status'];
  291. if ($siteStatus == 1) {
  292. // site online
  293. return true;
  294. }
  295. elseif ($siteStatus == 0 && $this->checkSession()) {
  296. // site offline but launched via the manager
  297. return true;
  298. } else {
  299. // site is offline
  300. return false;
  301. }
  302. }
  303. function cleanDocumentIdentifier($qOrig) {
  304. (!empty($qOrig)) or $qOrig = $this->config['site_start'];
  305. $q= $qOrig;
  306. /* First remove any / before or after */
  307. if ($q[strlen($q) - 1] == '/')
  308. $q= substr($q, 0, -1);
  309. if ($q[0] == '/')
  310. $q= substr($q, 1);
  311. /* Save path if any */
  312. /* FS#476 and FS#308: only return virtualDir if friendly paths are enabled */
  313. if ($this->config['use_alias_path'] == 1) {
  314. $this->virtualDir= dirname($q);
  315. $this->virtualDir= ($this->virtualDir == '.' ? '' : $this->virtualDir);
  316. $q= basename($q);
  317. } else {
  318. $this->virtualDir= '';
  319. }
  320. $q= str_replace($this->config['friendly_url_prefix'], "", $q);
  321. $q= str_replace($this->config['friendly_url_suffix'], "", $q);
  322. if (is_numeric($q) && !$this->documentListing[$q]) { /* we got an ID returned, check to make sure it's not an alias */
  323. /* FS#476 and FS#308: check that id is valid in terms of virtualDir structure */
  324. if ($this->config['use_alias_path'] == 1) {
  325. if ((($this->virtualDir != '' && !$this->documentListing[$this->virtualDir . '/' . $q]) || ($this->virtualDir == '' && !$this->documentListing[$q])) && (($this->virtualDir != '' && in_array($q, $this->getChildIds($this->documentListing[$this->virtualDir], 1))) || ($this->virtualDir == '' && in_array($q, $this->getChildIds(0, 1))))) {
  326. $this->documentMethod= 'id';
  327. return $q;
  328. } else { /* not a valid id in terms of virtualDir, treat as alias */
  329. $this->documentMethod= 'alias';
  330. return $q;
  331. }
  332. } else {
  333. $this->documentMethod= 'id';
  334. return $q;
  335. }
  336. } else { /* we didn't get an ID back, so instead we assume it's an alias */
  337. if ($this->config['friendly_alias_urls'] != 1) {
  338. $q= $qOrig;
  339. }
  340. $this->documentMethod= 'alias';
  341. return $q;
  342. }
  343. }
  344. function checkCache($id) {
  345. $cacheFile= "assets/cache/docid_" . $id . ".pageCache.php";
  346. if (file_exists($cacheFile)) {
  347. $this->documentGenerated= 0;
  348. $flContent= implode("", file($cacheFile));
  349. $flContent= substr($flContent, 37); // remove php header
  350. $a= explode("<!--__MODxCacheSpliter__-->", $flContent, 2);
  351. if (count($a) == 1)
  352. return $a[0]; // return only document content
  353. else {
  354. $docObj= unserialize($a[0]); // rebuild document object
  355. // check page security
  356. if ($docObj['privateweb'] && isset ($docObj['__MODxDocGroups__'])) {
  357. $pass= false;
  358. $usrGrps= $this->getUserDocGroups();
  359. $docGrps= explode(",", $docObj['__MODxDocGroups__']);
  360. // check is user has access to doc groups
  361. if (is_array($usrGrps)) {
  362. foreach ($usrGrps as $k => $v)
  363. if (in_array($v, $docGrps)) {
  364. $pass= true;
  365. break;
  366. }
  367. }
  368. // diplay error pages if user has no access to cached doc
  369. if (!$pass) {
  370. if ($this->config['unauthorized_page']) {
  371. // check if file is not public
  372. $tbldg= $this->getFullTableName("document_groups");
  373. $secrs= $this->db->query("SELECT id FROM $tbldg WHERE document = '" . $id . "' LIMIT 1;");
  374. if ($secrs)
  375. $seclimit= mysql_num_rows($secrs);
  376. }
  377. if ($seclimit > 0) {
  378. // match found but not publicly accessible, send the visitor to the unauthorized_page
  379. $this->sendUnauthorizedPage();
  380. exit; // stop here
  381. } else {
  382. // no match found, send the visitor to the error_page
  383. $this->sendErrorPage();
  384. exit; // stop here
  385. }
  386. }
  387. }
  388. // Grab the Scripts
  389. if (isset($docObj['__MODxSJScripts__'])) $this->sjscripts = $docObj['__MODxSJScripts__'];
  390. if (isset($docObj['__MODxJScripts__'])) $this->jscripts = $docObj['__MODxJScripts__'];
  391. // Remove intermediate variables
  392. unset($docObj['__MODxDocGroups__'], $docObj['__MODxSJScripts__'], $docObj['__MODxJScripts__']);
  393. $this->documentObject= $docObj;
  394. return $a[1]; // return document content
  395. }
  396. } else {
  397. $this->documentGenerated= 1;
  398. return "";
  399. }
  400. }
  401. function outputContent($noEvent= false) {
  402. $this->documentOutput= $this->documentContent;
  403. if ($this->documentGenerated == 1 && $this->documentObject['cacheable'] == 1 && $this->documentObject['type'] == 'document' && $this->documentObject['published'] == 1) {
  404. if (!empty($this->sjscripts)) $this->documentObject['__MODxSJScripts__'] = $this->sjscripts;
  405. if (!empty($this->jscripts)) $this->documentObject['__MODxJScripts__'] = $this->jscripts;
  406. }
  407. // check for non-cached snippet output
  408. if (strpos($this->documentOutput, '[!') > -1) {
  409. $this->documentOutput= str_replace('[!', '[[', $this->documentOutput);
  410. $this->documentOutput= str_replace('!]', ']]', $this->documentOutput);
  411. // Parse document source
  412. $this->documentOutput= $this->parseDocumentSource($this->documentOutput);
  413. }
  414. // Moved from prepareResponse() by sirlancelot
  415. // Insert Startup jscripts & CSS scripts into template - template must have a <head> tag
  416. if ($js= $this->getRegisteredClientStartupScripts()) {
  417. // change to just before closing </head>
  418. // $this->documentContent = preg_replace("/(<head[^>]*>)/i", "\\1\n".$js, $this->documentContent);
  419. $this->documentOutput= preg_replace("/(<\/head>)/i", $js . "\n\\1", $this->documentOutput);
  420. }
  421. // Insert jscripts & html block into template - template must have a </body> tag
  422. if ($js= $this->getRegisteredClientScripts()) {
  423. $this->documentOutput= preg_replace("/(<\/body>)/i", $js . "\n\\1", $this->documentOutput);
  424. }
  425. // End fix by sirlancelot
  426. // remove all unused placeholders
  427. if (strpos($this->documentOutput, '[+') > -1) {
  428. $matches= array ();
  429. preg_match_all('~\[\+(.*?)\+\]~', $this->documentOutput, $matches);
  430. if ($matches[0])
  431. $this->documentOutput= str_replace($matches[0], '', $this->documentOutput);
  432. }
  433. $this->documentOutput= $this->rewriteUrls($this->documentOutput);
  434. // send out content-type and content-disposition headers
  435. if (IN_PARSER_MODE == "true") {
  436. $type= !empty ($this->contentTypes[$this->documentIdentifier]) ? $this->contentTypes[$this->documentIdentifier] : "text/html";
  437. header('Content-Type: ' . $type . '; charset=' . $this->config['modx_charset']);
  438. // if (($this->documentIdentifier == $this->config['error_page']) || $redirect_error)
  439. // header('HTTP/1.0 404 Not Found');
  440. if (!$this->checkPreview() && $this->documentObject['content_dispo'] == 1) {
  441. if ($this->documentObject['alias'])
  442. $name= $this->documentObject['alias'];
  443. else {
  444. // strip title of special characters
  445. $name= $this->documentObject['pagetitle'];
  446. $name= strip_tags($name);
  447. $name= strtolower($name);
  448. $name= preg_replace('/&.+?;/', '', $name); // kill entities
  449. $name= preg_replace('/[^\.%a-z0-9 _-]/', '', $name);
  450. $name= preg_replace('/\s+/', '-', $name);
  451. $name= preg_replace('|-+|', '-', $name);
  452. $name= trim($name, '-');
  453. }
  454. $header= 'Content-Disposition: attachment; filename=' . $name;
  455. header($header);
  456. }
  457. }
  458. $totalTime= ($this->getMicroTime() - $this->tstart);
  459. $queryTime= $this->queryTime;
  460. $phpTime= $totalTime - $queryTime;
  461. $queryTime= sprintf("%2.4f s", $queryTime);
  462. $totalTime= sprintf("%2.4f s", $totalTime);
  463. $phpTime= sprintf("%2.4f s", $phpTime);
  464. $source= $this->documentGenerated == 1 ? "database" : "cache";
  465. $queries= isset ($this->executedQueries) ? $this->executedQueries : 0;
  466. $out =& $this->documentOutput;
  467. if ($this->dumpSQL) {
  468. $out .= $this->queryCode;
  469. }
  470. $out= str_replace("[^q^]", $queries, $out);
  471. $out= str_replace("[^qt^]", $queryTime, $out);
  472. $out= str_replace("[^p^]", $phpTime, $out);
  473. $out= str_replace("[^t^]", $totalTime, $out);
  474. $out= str_replace("[^s^]", $source, $out);
  475. //$this->documentOutput= $out;
  476. // invoke OnWebPagePrerender event
  477. if (!$noEvent) {
  478. $this->invokeEvent("OnWebPagePrerender");
  479. }
  480. echo $this->documentOutput;
  481. ob_end_flush();
  482. }
  483. function checkPublishStatus() {
  484. $cacheRefreshTime= 0;
  485. @include $this->config["base_path"] . "assets/cache/sitePublishing.idx.php";
  486. $timeNow= time() + $this->config['server_offset_time'];
  487. if ($cacheRefreshTime <= $timeNow && $cacheRefreshTime != 0) {
  488. // now, check for documents that need publishing
  489. $sql = "UPDATE ".$this->getFullTableName("site_content")." SET published=1, publishedon=".time()." WHERE ".$this->getFullTableName("site_content").".pub_date <= $timeNow AND ".$this->getFullTableName("site_content").".pub_date!=0 AND published=0";
  490. if (@ !$result= $this->db->query($sql)) {
  491. $this->messageQuit("Execution of a query to the database failed", $sql);
  492. }
  493. // now, check for documents that need un-publishing
  494. $sql= "UPDATE " . $this->getFullTableName("site_content") . " SET published=0, publishedon=0 WHERE " . $this->getFullTableName("site_content") . ".unpub_date <= $timeNow AND " . $this->getFullTableName("site_content") . ".unpub_date!=0 AND published=1";
  495. if (@ !$result= $this->db->query($sql)) {
  496. $this->messageQuit("Execution of a query to the database failed", $sql);
  497. }
  498. // clear the cache
  499. $basepath= $this->config["base_path"] . "assets/cache/";
  500. if ($handle= opendir($basepath)) {
  501. $filesincache= 0;
  502. $deletedfilesincache= 0;
  503. while (false !== ($file= readdir($handle))) {
  504. if ($file != "." && $file != "..") {
  505. $filesincache += 1;
  506. if (preg_match("/\.pageCache/", $file)) {
  507. $deletedfilesincache += 1;
  508. while (!unlink($basepath . "/" . $file));
  509. }
  510. }
  511. }
  512. closedir($handle);
  513. }
  514. // update publish time file
  515. $timesArr= array ();
  516. $sql= "SELECT MIN(pub_date) AS minpub FROM " . $this->getFullTableName("site_content") . " WHERE pub_date>$timeNow";
  517. if (@ !$result= $this->db->query($sql)) {
  518. $this->messageQuit("Failed to find publishing timestamps", $sql);
  519. }
  520. $tmpRow= $this->db->getRow($result);
  521. $minpub= $tmpRow['minpub'];
  522. if ($minpub != NULL) {
  523. $timesArr[]= $minpub;
  524. }
  525. $sql= "SELECT MIN(unpub_date) AS minunpub FROM " . $this->getFullTableName("site_content") . " WHERE unpub_date>$timeNow";
  526. if (@ !$result= $this->db->query($sql)) {
  527. $this->messageQuit("Failed to find publishing timestamps", $sql);
  528. }
  529. $tmpRow= $this->db->getRow($result);
  530. $minunpub= $tmpRow['minunpub'];
  531. if ($minunpub != NULL) {
  532. $timesArr[]= $minunpub;
  533. }
  534. if (count($timesArr) > 0) {
  535. $nextevent= min($timesArr);
  536. } else {
  537. $nextevent= 0;
  538. }
  539. $basepath= $this->config["base_path"] . "assets/cache";
  540. $fp= @ fopen($basepath . "/sitePublishing.idx.php", "wb");
  541. if ($fp) {
  542. @ flock($fp, LOCK_EX);
  543. @ fwrite($fp, "<?php \$cacheRefreshTime=$nextevent; ?>");
  544. @ flock($fp, LOCK_UN);
  545. @ fclose($fp);
  546. }
  547. }
  548. }
  549. function postProcess() {
  550. // if the current document was generated, cache it!
  551. if ($this->documentGenerated == 1 && $this->documentObject['cacheable'] == 1 && $this->documentObject['type'] == 'document' && $this->documentObject['published'] == 1) {
  552. $basepath= $this->config["base_path"] . "assets/cache";
  553. // invoke OnBeforeSaveWebPageCache event
  554. $this->invokeEvent("OnBeforeSaveWebPageCache");
  555. if ($fp= @ fopen($basepath . "/docid_" . $this->documentIdentifier . ".pageCache.php", "w")) {
  556. // get and store document groups inside document object. Document groups will be used to check security on cache pages
  557. $sql= "SELECT document_group FROM " . $this->getFullTableName("document_groups") . " WHERE document='" . $this->documentIdentifier . "'";
  558. $docGroups= $this->db->getColumn("document_group", $sql);
  559. // Attach Document Groups and Scripts
  560. if (is_array($docGroups)) $this->documentObject['__MODxDocGroups__'] = implode(",", $docGroups);
  561. $docObjSerial= serialize($this->documentObject);
  562. $cacheContent= $docObjSerial . "<!--__MODxCacheSpliter__-->" . $this->documentContent;
  563. fputs($fp, "<?php die('Unauthorized access.'); ?>$cacheContent");
  564. fclose($fp);
  565. }
  566. }
  567. // Useful for example to external page counters/stats packages
  568. $this->invokeEvent('OnWebPageComplete');
  569. // end post processing
  570. }
  571. function mergeDocumentMETATags($template) {
  572. if ($this->documentObject['haskeywords'] == 1) {
  573. // insert keywords
  574. $keywords = $this->getKeywords();
  575. if (is_array($keywords) && count($keywords) > 0) {
  576. $keywords = implode(", ", $keywords);
  577. $metas= "\t<meta name=\"keywords\" content=\"$keywords\" />\n";
  578. }
  579. // Don't process when cached
  580. $this->documentObject['haskeywords'] = '0';
  581. }
  582. if ($this->documentObject['hasmetatags'] == 1) {
  583. // insert meta tags
  584. $tags= $this->getMETATags();
  585. foreach ($tags as $n => $col) {
  586. $tag= strtolower($col['tag']);
  587. $tagvalue= $col['tagvalue'];
  588. $tagstyle= $col['http_equiv'] ? 'http-equiv' : 'name';
  589. $metas .= "\t<meta $tagstyle=\"$tag\" content=\"$tagvalue\" />\n";
  590. }
  591. // Don't process when cached
  592. $this->documentObject['hasmetatags'] = '0';
  593. }
  594. if ($metas) $template = preg_replace("/(<head>)/i", "\\1\n\t" . trim($metas), $template);
  595. return $template;
  596. }
  597. // mod by Raymond
  598. function mergeDocumentContent($template) {
  599. $replace= array ();
  600. preg_match_all('~\[\*(.*?)\*\]~', $template, $matches);
  601. $variableCount= count($matches[1]);
  602. $basepath= $this->config["base_path"] . "manager/includes";
  603. for ($i= 0; $i < $variableCount; $i++) {
  604. $key= $matches[1][$i];
  605. $key= substr($key, 0, 1) == '#' ? substr($key, 1) : $key; // remove # for QuickEdit format
  606. $value= $this->documentObject[$key];
  607. if (is_array($value)) {
  608. include_once $basepath . "/tmplvars.format.inc.php";
  609. include_once $basepath . "/tmplvars.commands.inc.php";
  610. $w= "100%";
  611. $h= "300";
  612. $value= getTVDisplayFormat($value[0], $value[1], $value[2], $value[3], $value[4]);
  613. }
  614. $replace[$i]= $value;
  615. }
  616. $template= str_replace($matches[0], $replace, $template);
  617. return $template;
  618. }
  619. function mergeSettingsContent($template) {
  620. $replace= array ();
  621. $matches= array ();
  622. if (preg_match_all('~\[\(([a-z\_]*?)\)\]~', $template, $matches)) {
  623. $settingsCount= count($matches[1]);
  624. for ($i= 0; $i < $settingsCount; $i++) {
  625. if (array_key_exists($matches[1][$i], $this->config))
  626. $replace[$i]= $this->config[$matches[1][$i]];
  627. }
  628. $template= str_replace($matches[0], $replace, $template);
  629. }
  630. return $template;
  631. }
  632. function mergeChunkContent($content) {
  633. $replace= array ();
  634. $matches= array ();
  635. if (preg_match_all('~{{(.*?)}}~', $content, $matches)) {
  636. $settingsCount= count($matches[1]);
  637. for ($i= 0; $i < $settingsCount; $i++) {
  638. if (isset ($this->chunkCache[$matches[1][$i]])) {
  639. $replace[$i]= $this->chunkCache[$matches[1][$i]];
  640. } else {
  641. $sql= "SELECT `snippet` FROM " . $this->getFullTableName("site_htmlsnippets") . " WHERE " . $this->getFullTableName("site_htmlsnippets") . ".`name`='" . $this->db->escape($matches[1][$i]) . "';";
  642. $result= $this->db->query($sql);
  643. $limit= $this->db->getRecordCount($result);
  644. if ($limit < 1) {
  645. $this->chunkCache[$matches[1][$i]]= "";
  646. $replace[$i]= "";
  647. } else {
  648. $row= $this->db->getRow($result);
  649. $this->chunkCache[$matches[1][$i]]= $row['snippet'];
  650. $replace[$i]= $row['snippet'];
  651. }
  652. }
  653. }
  654. $content= str_replace($matches[0], $replace, $content);
  655. }
  656. return $content;
  657. }
  658. // Added by Raymond
  659. function mergePlaceholderContent($content) {
  660. $replace= array ();
  661. $matches= array ();
  662. if (preg_match_all('~\[\+(.*?)\+\]~', $content, $matches)) {
  663. $cnt= count($matches[1]);
  664. for ($i= 0; $i < $cnt; $i++) {
  665. $v= '';
  666. $key= $matches[1][$i];
  667. if (is_array($this->placeholders) && array_key_exists($key, $this->placeholders))
  668. $v= $this->placeholders[$key];
  669. if ($v === '')
  670. unset ($matches[0][$i]); // here we'll leave empty placeholders for last.
  671. else
  672. $replace[$i]= $v;
  673. }
  674. $content= str_replace($matches[0], $replace, $content);
  675. }
  676. return $content;
  677. }
  678. // evalPlugin
  679. function evalPlugin($pluginCode, $params) {
  680. $etomite= $modx= & $this;
  681. $modx->event->params= & $params; // store params inside event object
  682. if (is_array($params)) {
  683. extract($params, EXTR_SKIP);
  684. }
  685. ob_start();
  686. eval ($pluginCode);
  687. $msg= ob_get_contents();
  688. ob_end_clean();
  689. if ($msg && isset ($php_errormsg)) {
  690. if (!strpos($php_errormsg, 'Deprecated')) { // ignore php5 strict errors
  691. // log error
  692. $this->logEvent(1, 3, "<b>$php_errormsg</b><br /><br /> $msg", $this->Event->activePlugin . " - Plugin");
  693. if ($this->isBackend())
  694. $this->Event->alert("An error occurred while loading. Please see the event log for more information.<p />$msg");
  695. }
  696. } else {
  697. echo $msg;
  698. }
  699. unset ($modx->event->params);
  700. }
  701. function evalSnippet($snippet, $params) {
  702. $etomite= $modx= & $this;
  703. $modx->event->params= & $params; // store params inside event object
  704. if (is_array($params)) {
  705. extract($params, EXTR_SKIP);
  706. }
  707. ob_start();
  708. $snip= eval ($snippet);
  709. $msg= ob_get_contents();
  710. ob_end_clean();
  711. if ($msg && isset ($php_errormsg)) {
  712. if (!strpos($php_errormsg, 'Deprecated')) { // ignore php5 strict errors
  713. // log error
  714. $this->logEvent(1, 3, "<b>$php_errormsg</b><br /><br /> $msg", $this->currentSnippet . " - Snippet");
  715. if ($this->isBackend())
  716. $this->Event->alert("An error occurred while loading. Please see the event log for more information<p />$msg");
  717. }
  718. }
  719. unset ($modx->event->params);
  720. return $msg . $snip;
  721. }
  722. function evalSnippets($documentSource) {
  723. preg_match_all('~\[\[(.*?)\]\]~ms', $documentSource, $matches);
  724. $etomite= & $this;
  725. if ($matchCount= count($matches[1])) {
  726. for ($i= 0; $i < $matchCount; $i++) {
  727. $spos= strpos($matches[1][$i], '?', 0);
  728. if ($spos !== false) {
  729. $params= substr($matches[1][$i], $spos, strlen($matches[1][$i]));
  730. } else {
  731. $params= '';
  732. }
  733. $matches[1][$i]= str_replace($params, '', $matches[1][$i]);
  734. $snippetParams[$i]= $params;
  735. }
  736. $nrSnippetsToGet= $matchCount;
  737. for ($i= 0; $i < $nrSnippetsToGet; $i++) { // Raymond: Mod for Snippet props
  738. if (isset ($this->snippetCache[$matches[1][$i]])) {
  739. $snippets[$i]['name']= $matches[1][$i];
  740. $snippets[$i]['snippet']= $this->snippetCache[$matches[1][$i]];
  741. if (array_key_exists($matches[1][$i] . "Props", $this->snippetCache))
  742. $snippets[$i]['properties']= $this->snippetCache[$matches[1][$i] . "Props"];
  743. } else {
  744. // get from db and store a copy inside cache
  745. $sql= "SELECT `name`, `snippet`, `properties` FROM " . $this->getFullTableName("site_snippets") . " WHERE " . $this->getFullTableName("site_snippets") . ".`name`='" . $this->db->escape($matches[1][$i]) . "';";
  746. $result= $this->db->query($sql);
  747. $added = false;
  748. if ($this->db->getRecordCount($result) == 1) {
  749. $row= $this->db->getRow($result);
  750. if($row['name'] == $matches[1][$i]) {
  751. $snippets[$i]['name']= $row['name'];
  752. $snippets[$i]['snippet']= $this->snippetCache[$row['name']]= $row['snippet'];
  753. $snippets[$i]['properties']= $this->snippetCache[$row['name'] . "Props"]= $row['properties'];
  754. $added = true;
  755. }
  756. }
  757. if(!$added) {
  758. $snippets[$i]['name']= $matches[1][$i];
  759. $snippets[$i]['snippet']= $this->snippetCache[$matches[1][$i]]= "return false;";
  760. $snippets[$i]['properties']= '';
  761. }
  762. }
  763. }
  764. for ($i= 0; $i < $nrSnippetsToGet; $i++) {
  765. $parameter= array ();
  766. $snippetName= $this->currentSnippet= $snippets[$i]['name'];
  767. // FIXME Undefined index: properties
  768. if (array_key_exists('properties', $snippets[$i])) {
  769. $snippetProperties= $snippets[$i]['properties'];
  770. } else {
  771. $snippetProperties= '';
  772. }
  773. // load default params/properties - Raymond
  774. // FIXME Undefined variable: snippetProperties
  775. $parameter= $this->parseProperties($snippetProperties);
  776. // current params
  777. $currentSnippetParams= $snippetParams[$i];
  778. if (!empty ($currentSnippetParams)) {
  779. $tempSnippetParams= str_replace("?", "", $currentSnippetParams);
  780. $splitter= "&";
  781. if (strpos($tempSnippetParams, "&amp;") > 0)
  782. $tempSnippetParams= str_replace("&amp;", "&", $tempSnippetParams);
  783. //$tempSnippetParams = html_entity_decode($tempSnippetParams, ENT_NOQUOTES, $this->config['etomite_charset']); //FS#334 and FS#456
  784. $tempSnippetParams= explode($splitter, $tempSnippetParams);
  785. $snippetParamCount= count($tempSnippetParams);
  786. for ($x= 0; $x < $snippetParamCount; $x++) {
  787. if (strpos($tempSnippetParams[$x], '=', 0)) {
  788. if ($parameterTemp= explode("=", $tempSnippetParams[$x])) {
  789. $parameterTemp[0] = trim($parameterTemp[0]);
  790. $parameterTemp[1] = trim($parameterTemp[1]);
  791. $fp= strpos($parameterTemp[1], '`');
  792. $lp= strrpos($parameterTemp[1], '`');
  793. if (!($fp === false && $lp === false))
  794. $parameterTemp[1]= substr($parameterTemp[1], $fp +1, $lp -1);
  795. $parameter[$parameterTemp[0]]= $parameterTemp[1];
  796. }
  797. }
  798. }
  799. }
  800. $executedSnippets[$i]= $this->evalSnippet($snippets[$i]['snippet'], $parameter);
  801. if ($this->dumpSnippets == 1) {
  802. echo "<fieldset><legend><b>$snippetName</b></legend><textarea style='width:60%; height:200px'>" . htmlentities($executedSnippets[$i]) . "</textarea></fieldset><br />";
  803. }
  804. $documentSource= str_replace("[[" . $snippetName . $currentSnippetParams . "]]", $executedSnippets[$i], $documentSource);
  805. }
  806. }
  807. return $documentSource;
  808. }
  809. function makeFriendlyURL($pre, $suff, $alias) {
  810. $Alias = explode('/',$alias);
  811. $alias = array_pop($Alias);
  812. $dir = implode('/', $Alias);
  813. unset($Alias);
  814. return ($dir != '' ? "$dir/" : '') . $pre . $alias . $suff;
  815. }
  816. function rewriteUrls($documentSource) {
  817. // rewrite the urls
  818. if ($this->config['friendly_urls'] == 1) {
  819. $aliases= array ();
  820. foreach ($this->aliasListing as $item) {
  821. $aliases[$item['id']]= (strlen($item['path']) > 0 ? $item['path'] . '/' : '') . $item['alias'];
  822. }
  823. $in= '!\[\~([0-9]+)\~\]!ise'; // Use preg_replace with /e to make it evaluate PHP
  824. $isfriendly= ($this->config['friendly_alias_urls'] == 1 ? 1 : 0);
  825. $pref= $this->config['friendly_url_prefix'];
  826. $suff= $this->config['friendly_url_suffix'];
  827. $thealias= '$aliases[\\1]';
  828. $found_friendlyurl= "\$this->makeFriendlyURL('$pref','$suff',$thealias)";
  829. $not_found_friendlyurl= "\$this->makeFriendlyURL('$pref','$suff','" . '\\1' . "')";
  830. $out= "({$isfriendly} && isset({$thealias}) ? {$found_friendlyurl} : {$not_found_friendlyurl})";
  831. $documentSource= preg_replace($in, $out, $documentSource);
  832. } else {
  833. $in= '!\[\~([0-9]+)\~\]!is';
  834. $out= "index.php?id=" . '\1';
  835. $documentSource= preg_replace($in, $out, $documentSource);
  836. }
  837. return $documentSource;
  838. }
  839. /**
  840. * name: getDocumentObject - used by parser
  841. * desc: returns a document object - $method: alias, id
  842. */
  843. function getDocumentObject($method, $identifier) {
  844. $tblsc= $this->getFullTableName("site_content");
  845. $tbldg= $this->getFullTableName("document_groups");
  846. // allow alias to be full path
  847. if($method == 'alias') {
  848. $identifier = $this->cleanDocumentIdentifier($identifier);
  849. $method = $this->documentMethod;
  850. }
  851. if($method == 'alias' && $this->config['use_alias_path'] && array_key_exists($identifier, $this->documentListing)) {
  852. $method = 'id';
  853. $identifier = $this->documentListing[$identifier];
  854. }
  855. // get document groups for current user
  856. if ($docgrp= $this->getUserDocGroups())
  857. $docgrp= implode(",", $docgrp);
  858. // get document
  859. $access= ($this->isFrontend() ? "sc.privateweb=0" : "1='" . $_SESSION['mgrRole'] . "' OR sc.privatemgr=0") .
  860. (!$docgrp ? "" : " OR dg.document_group IN ($docgrp)");
  861. $sql= "SELECT sc.*
  862. FROM $tblsc sc
  863. LEFT JOIN $tbldg dg ON dg.document = sc.id
  864. WHERE sc." . $method . " = '" . $identifier . "'
  865. AND ($access) LIMIT 1;";
  866. $result= $this->db->query($sql);
  867. $rowCount= $this->db->getRecordCount($result);
  868. if ($rowCount < 1) {
  869. if ($this->config['unauthorized_page']) {
  870. // method may still be alias, while identifier is not full path alias, e.g. id not found above
  871. if ($method === 'alias') {
  872. $q = "SELECT dg.id FROM $tbldg dg, $tblsc sc WHERE dg.document = sc.id AND sc.alias = '{$identifier}' LIMIT 1;";
  873. } else {
  874. $q = "SELECT id FROM $tbldg WHERE document = '{$identifier}' LIMIT 1;";
  875. }
  876. // check if file is not public
  877. $secrs= $this->db->query($q);
  878. if ($secrs)
  879. $seclimit= mysql_num_rows($secrs);
  880. }
  881. if ($seclimit > 0) {
  882. // match found but not publicly accessible, send the visitor to the unauthorized_page
  883. $this->sendUnauthorizedPage();
  884. exit; // stop here
  885. } else {
  886. $this->sendErrorPage();
  887. exit;
  888. }
  889. }
  890. # this is now the document :) #
  891. $documentObject= $this->db->getRow($result);
  892. // load TVs and merge with document - Orig by Apodigm - Docvars
  893. $sql= "SELECT tv.*, IF(tvc.value!='',tvc.value,tv.default_text) as value ";
  894. $sql .= "FROM " . $this->getFullTableName("site_tmplvars") . " tv ";
  895. $sql .= "INNER JOIN " . $this->getFullTableName("site_tmplvar_templates")." tvtpl ON tvtpl.tmplvarid = tv.id ";
  896. $sql .= "LEFT JOIN " . $this->getFullTableName("site_tmplvar_contentvalues")." tvc ON tvc.tmplvarid=tv.id AND tvc.contentid = '" . $documentObject['id'] . "' ";
  897. $sql .= "WHERE tvtpl.templateid = '" . $documentObject['template'] . "'";
  898. $rs= $this->db->query($sql);
  899. $rowCount= $this->db->getRecordCount($rs);
  900. if ($rowCount > 0) {
  901. for ($i= 0; $i < $rowCount; $i++) {
  902. $row= $this->db->getRow($rs);
  903. $tmplvars[$row['name']]= array (
  904. $row['name'],
  905. $row['value'],
  906. $row['display'],
  907. $row['display_params'],
  908. $row['type']
  909. );
  910. }
  911. $documentObject= array_merge($documentObject, $tmplvars);
  912. }
  913. return $documentObject;
  914. }
  915. /**
  916. * name: parseDocumentSource - used by parser
  917. * desc: return document source aftering parsing tvs, snippets, chunks, etc.
  918. */
  919. function parseDocumentSource($source) {
  920. // set the number of times we are to parse the document source
  921. $this->minParserPasses= empty ($this->minParserPasses) ? 2 : $this->minParserPasses;
  922. $this->maxParserPasses= empty ($this->maxParserPasses) ? 10 : $this->maxParserPasses;
  923. $passes= $this->minParserPasses;
  924. for ($i= 0; $i < $passes; $i++) {
  925. // get source length if this is the final pass
  926. if ($i == ($passes -1))
  927. $st= strlen($source);
  928. if ($this->dumpSnippets == 1) {
  929. echo "<fieldset><legend><b style='color: #821517;'>PARSE PASS " . ($i +1) . "</b></legend>The following snippets (if any) were parsed during this pass.<div style='width:100%' align='center'>";
  930. }
  931. // invoke OnParseDocument event
  932. $this->documentOutput= $source; // store source code so plugins can
  933. $this->invokeEvent("OnParseDocument"); // work on it via $modx->documentOutput
  934. $source= $this->documentOutput;
  935. // combine template and document variables
  936. $source= $this->mergeDocumentContent($source);
  937. // replace settings referenced in document
  938. $source= $this->mergeSettingsContent($source);
  939. // replace HTMLSnippets in document
  940. $source= $this->mergeChunkContent($source);
  941. // insert META tags & keywords
  942. $source= $this->mergeDocumentMETATags($source);
  943. // find and merge snippets
  944. $source= $this->evalSnippets($source);
  945. // find and replace Placeholders (must be parsed last) - Added by Raymond
  946. $source= $this->mergePlaceholderContent($source);
  947. if ($this->dumpSnippets == 1) {
  948. echo "</div></fieldset><br />";
  949. }
  950. if ($i == ($passes -1) && $i < ($this->maxParserPasses - 1)) {
  951. // check if source length was changed
  952. $et= strlen($source);
  953. if ($st != $et)
  954. $passes++; // if content change then increase passes because
  955. } // we have not yet reached maxParserPasses
  956. }
  957. return $source;
  958. }
  959. function executeParser() {
  960. //error_reporting(0);
  961. if (version_compare(phpversion(), "5.0.0", ">="))
  962. set_error_handler(array (
  963. & $this,
  964. "phpError"
  965. ), E_ALL);
  966. else
  967. set_error_handler(array (
  968. & $this,
  969. "phpError"
  970. ));
  971. $this->db->connect();
  972. // get the settings
  973. if (empty ($this->config)) {
  974. $this->getSettings();
  975. }
  976. // IIS friendly url fix
  977. if ($this->config['friendly_urls'] == 1 && strpos($_SERVER['SERVER_SOFTWARE'], 'Microsoft-IIS') !== false) {
  978. $url= $_SERVER['QUERY_STRING'];
  979. $err= substr($url, 0, 3);
  980. if ($err == '404' || $err == '405') {
  981. $k= array_keys($_GET);
  982. unset ($_GET[$k[0]]);
  983. unset ($_REQUEST[$k[0]]); // remove 404,405 entry
  984. $_SERVER['QUERY_STRING']= $qp['query'];
  985. $qp= parse_url(str_replace($this->config['site_url'], '', substr($url, 4)));
  986. if (!empty ($qp['query'])) {
  987. parse_str($qp['query'], $qv);
  988. foreach ($qv as $n => $v)
  989. $_REQUEST[$n]= $_GET[$n]= $v;
  990. }
  991. $_SERVER['PHP_SELF']= $this->config['base_url'] . $qp['path'];
  992. $_REQUEST['q']= $_GET['q']= $qp['path'];
  993. }
  994. }
  995. // check site settings
  996. if (!$this->checkSiteStatus()) {
  997. header('HTTP/1.0 503 Service Unavailable');
  998. if (!$this->config['site_unavailable_page']) {
  999. // display offline message
  1000. $this->documentContent= $this->config['site_unavailable_message'];
  1001. $this->outputContent();
  1002. exit; // stop processing here, as the site's offline
  1003. } else {
  1004. // setup offline page document settings
  1005. $this->documentMethod= "id";
  1006. $this->documentIdentifier= $this->config['site_unavailable_page'];
  1007. }
  1008. } else {
  1009. // make sure the cache doesn't need updating
  1010. $this->checkPublishStatus();
  1011. // find out which document we need to display
  1012. $this->documentMethod= $this->getDocumentMethod();
  1013. $this->documentIdentifier= $this->getDocumentIdentifier($this->documentMethod);
  1014. }
  1015. if ($this->documentMethod == "none") {
  1016. $this->documentMethod= "id"; // now we know the site_start, change the none method to id
  1017. }
  1018. if ($this->documentMethod == "alias") {
  1019. $this->documentIdentifier= $this->cleanDocumentIdentifier($this->documentIdentifier);
  1020. }
  1021. if ($this->documentMethod == "alias") {
  1022. // Check use_alias_path and check if $this->virtualDir is set to anything, then parse the path
  1023. if ($this-

Large files files are truncated, but you can click here to view the full file