PageRenderTime 44ms CodeModel.GetById 20ms RepoModel.GetById 0ms app.codeStats 0ms

/textpattern/index.php

https://github.com/joebushi/textpattern
PHP | 142 lines | 89 code | 32 blank | 21 comment | 19 complexity | 565a5eab2278d7575f8af864d9c2a57e MD5 | raw file
  1. <?php
  2. /*
  3. This is Textpattern
  4. Copyright 2005 by Dean Allen
  5. www.textpattern.com
  6. All rights reserved
  7. Use of this software indicates acceptance of the Textpattern license agreement
  8. $HeadURL$
  9. $LastChangedRevision$
  10. */
  11. if (@ini_get('register_globals'))
  12. foreach ( $_REQUEST as $name => $value )
  13. unset($$name);
  14. define("txpath", dirname(__FILE__));
  15. define("txpinterface", "admin");
  16. $thisversion = '4.0.8';
  17. $txp_using_svn = true; // set false for releases
  18. ob_start(NULL, 2048);
  19. if (!@include './config.php') {
  20. ob_end_clean();
  21. include txpath.'/setup/index.php';
  22. exit();
  23. } else ob_end_clean();
  24. header("Content-type: text/html; charset=utf-8");
  25. if (isset($_POST['form_preview'])) {
  26. include txpath.'/publish.php';
  27. textpattern();
  28. exit;
  29. }
  30. error_reporting(E_ALL);
  31. @ini_set("display_errors","1");
  32. include_once txpath.'/lib/constants.php';
  33. include txpath.'/lib/txplib_misc.php';
  34. include txpath.'/lib/txplib_db.php';
  35. include txpath.'/lib/txplib_forms.php';
  36. include txpath.'/lib/txplib_html.php';
  37. include txpath.'/lib/txplib_theme.php';
  38. include txpath.'/lib/admin_config.php';
  39. $microstart = getmicrotime();
  40. if ($connected && safe_query("describe `".PFX."textpattern`")) {
  41. $dbversion = safe_field('val','txp_prefs',"name = 'version'");
  42. // global site prefs
  43. $prefs = get_prefs();
  44. extract($prefs);
  45. if (empty($siteurl))
  46. $siteurl = $_SERVER['HTTP_HOST'] . rtrim(dirname(dirname($_SERVER['SCRIPT_NAME'])), '/');
  47. if (empty($path_to_site))
  48. updateSitePath(dirname(dirname(__FILE__)));
  49. define("LANG",$language);
  50. //i18n: define("LANG","en-gb");
  51. define('txp_version', $thisversion);
  52. if (!defined('PROTOCOL')) {
  53. switch (serverSet('HTTPS')) {
  54. case '':
  55. case 'off': // ISAPI with IIS
  56. define('PROTOCOL', 'http://');
  57. break;
  58. default:
  59. define('PROTOCOL', 'https://');
  60. break;
  61. }
  62. }
  63. define("hu",PROTOCOL.$siteurl.'/');
  64. // v1.0 experimental relative url global
  65. define("rhu",preg_replace("/https?:\/\/.+(\/.*)\/?$/U","$1",hu));
  66. if (!empty($locale)) setlocale(LC_ALL, $locale);
  67. $textarray = load_lang(LANG);
  68. // init global theme
  69. $theme = theme::init();
  70. include txpath.'/include/txp_auth.php';
  71. doAuth();
  72. // once more for global plus private prefs
  73. $prefs = get_prefs();
  74. extract($prefs);
  75. $event = (gps('event') ? gps('event') : get_pref('default_event', 'article'));
  76. $step = gps('step');
  77. $app_mode = gps('app_mode');
  78. if (!$dbversion or ($dbversion != $thisversion) or $txp_using_svn)
  79. {
  80. define('TXP_UPDATE', 1);
  81. include txpath.'/update/_update.php';
  82. }
  83. if (!empty($admin_side_plugins) and gps('event') != 'plugin')
  84. load_plugins(1);
  85. // init private theme
  86. $theme = theme::init();
  87. include txpath.'/lib/txplib_head.php';
  88. // ugly hack, for the people that don't update their admin_config.php
  89. // Get rid of this when we completely remove admin_config and move privs to db
  90. if ($event == 'list')
  91. require_privs('article');
  92. else
  93. require_privs($event);
  94. callback_event($event, $step, 1);
  95. $inc = txpath . '/include/txp_'.$event.'.php';
  96. if (is_readable($inc))
  97. include($inc);
  98. callback_event($event, $step, 0);
  99. $microdiff = (getmicrotime() - $microstart);
  100. echo n.comment(gTxt('runtime').': '.substr($microdiff,0,6));
  101. end_page();
  102. } else {
  103. txp_die('DB-Connect was succesful, but the textpattern-table was not found.',
  104. '503 Service Unavailable');
  105. }
  106. ?>