index.php 2.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980
  1. <?php
  2. error_reporting(E_ALL);
  3. /**
  4. * is Xhprof Hierarchical Profiler enabled?
  5. */
  6. $minimalConfig = @parse_ini_file('config/yalf.ini');
  7. if (@$minimalConfig['XHPROF']) {
  8. define('XHPROF', 1);
  9. } else {
  10. define('XHPROF', 0);
  11. }
  12. /**
  13. * rcms-like commons consts defines
  14. */
  15. define('CONFIG_PATH', 'config/');
  16. define('DATA_PATH', 'content/');
  17. define('USERS_PATH', 'content/users/');
  18. define('MODULES_PATH', 'modules/general/');
  19. define('REMOTEAPI_PATH', 'modules/remoteapi/');
  20. /**
  21. * Profiler init
  22. */
  23. if (XHPROF) {
  24. $yalfConf = parse_ini_file(CONFIG_PATH . 'yalf.ini');
  25. if ($yalfConf['XHPROF_PATH']) {
  26. $xhProfLibsPath = $yalfConf['XHPROF_PATH'];
  27. } else {
  28. $xhProfLibsPath = 'xhprof';
  29. }
  30. define("XHPROF_ROOT", __DIR__ . '/' . $xhProfLibsPath);
  31. require_once(XHPROF_ROOT . '/xhprof_lib/utils/xhprof_lib.php');
  32. require_once(XHPROF_ROOT . '/xhprof_lib/utils/xhprof_runs.php');
  33. //append XHPROF_FLAGS_NO_BUILTINS if your PHP instance crashes
  34. xhprof_enable(XHPROF_FLAGS_CPU + XHPROF_FLAGS_MEMORY);
  35. }
  36. /**
  37. * Default headers
  38. */
  39. header('Last-Modified: ' . gmdate('r'));
  40. header('Content-Type: text/html; charset=UTF-8');
  41. header("Cache-Control: no-store, no-cache, must-revalidate");
  42. header("Pragma: no-cache");
  43. /**
  44. * Page generation time counters begins
  45. */
  46. $starttime = explode(' ', microtime());
  47. $starttime = $starttime[1] + $starttime[0];
  48. $query_counter = 0;
  49. /**
  50. * System initialization
  51. */
  52. require_once('api/autoloader.php'); //preloading required libs
  53. define('LOGGED_IN', $system->getLoggedInState()); //emulating RCMS LOGGED_IN state
  54. require_once($system->getIndexModulePath()); //react to some module routes
  55. if (XHPROF) {
  56. $xhprof_data = xhprof_disable();
  57. $xhprof_runs = new XHProfRuns_Default();
  58. $xhprof_run_id = $xhprof_runs->save_run($xhprof_data, "xhprof_yalf");
  59. $xhprof_run_url = $xhProfLibsPath . '/xhprof_html/index.php?run=' . $xhprof_run_id . '&source=xhprof_yalf';
  60. $xhprof_frame = wf_tag('iframe', false, '', 'src="' . $xhprof_run_url . '" width="100%" height="750"') . wf_tag('iframe', true);
  61. $xhprof_link = wf_modal(wf_img_sized('skins/xhprof.png', __('XHPROF'), 20), 'XHProf current page results', $xhprof_frame, '', '1024', '768');
  62. }
  63. //web based renderer template load
  64. if ($system->getRenderer() == 'WEB') {
  65. require_once($system->getSkinPath() . $system::SKIN_TEMPLATE_NAME);
  66. }