PageRenderTime 24ms CodeModel.GetById 19ms RepoModel.GetById 1ms app.codeStats 0ms

/index.php

http://pixie-cms.googlecode.com/
PHP | 548 lines | 429 code | 37 blank | 82 comment | 97 complexity | 051f1943548f39c0fb9c21fd7648b1f1 MD5 | raw file
  1. <?php
  2. header('Content-Type: text/html; charset=UTF-8');
  3. /**
  4. * Pixie: The Small, Simple, Site Maker.
  5. *
  6. * Licence: GNU General Public License v3
  7. * Copyright (C) 2010, Scott Evans
  8. *
  9. * This program is free software: you can redistribute it and/or modify
  10. * it under the terms of the GNU General Public License as published by
  11. * the Free Software Foundation, either version 3 of the License, or
  12. * (at your option) any later version.
  13. *
  14. * This program is distributed in the hope that it will be useful,
  15. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  16. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  17. * GNU General Public License for more details.
  18. *
  19. * You should have received a copy of the GNU General Public License
  20. * along with this program. If not, see http://www.gnu.org/licenses/
  21. *
  22. * Title: Index
  23. *
  24. * @package Pixie
  25. * @copyright 2008-2010 Scott Evans
  26. * @author Scott Evans
  27. * @author Sam Collett
  28. * @author Tony White
  29. * @author Isa Worcs
  30. * @link http://www.getpixie.co.uk
  31. * @license http://www.gnu.org/licenses/gpl-3.0.html GNU General Public License v3
  32. * @todo Tag release for Pixie 1.04
  33. *
  34. */
  35. /* Prevent any kind of predefinition of DIRECT_ACCESS or PIXIE_DEBUG */
  36. if ((defined('DIRECT_ACCESS')) or (defined('PIXIE_DEBUG'))) {
  37. require_once 'admin/lib/lib_misc.php';
  38. pixieExit();
  39. exit();
  40. }
  41. /* 1 for yes */
  42. define('DIRECT_ACCESS', 1);
  43. /* Check for config */
  44. if ((!file_exists('admin/config.php')) or (filesize('admin/config.php') < 10)) {
  45. /* redirect to installer */
  46. if (file_exists('admin/install/index.php')) {
  47. header('Location: admin/install/');
  48. exit();
  49. }
  50. /* Redirect to an error page if down */
  51. if (!file_exists('admin/install/index.php')) {
  52. require_once 'admin/lib/lib_db.php';
  53. db_down();
  54. exit();
  55. }
  56. }
  57. /* Set default php charset */
  58. ini_set('default_charset', 'utf-8');
  59. /* Perform basic sanity checks */
  60. require_once 'admin/lib/lib_misc.php';
  61. /* Check URL size */
  62. bombShelter();
  63. /* Set error reporting up if debug is enabled */
  64. if (PIXIE_DEBUG == 'yes') {
  65. error_reporting(-1);
  66. } else {
  67. error_reporting(0);
  68. }
  69. /* Prevent superglobal poisoning before extraction */
  70. globalSec('Main index.php', 1);
  71. /* Access to form vars if register globals is off */
  72. /* note : NOT setting a prefix yet, not looked at it yet */
  73. extract($_REQUEST);
  74. /* Load configuration */
  75. require_once 'admin/config.php';
  76. /* Import the database function library */
  77. include_once 'admin/lib/lib_db.php';
  78. /* Turn the prefs into an array */
  79. $prefs = get_prefs();
  80. /* Add prefs to globals using php's extract function */
  81. extract($prefs);
  82. /* Timezone fix (php 5.1.0 or newer will set it's server timezone using function date_default_timezone_set!) */
  83. define('TZ', "$timezone");
  84. if (strnatcmp(phpversion(), '5.1.0') >= 0) {
  85. if (isset($server_timezone)) {
  86. } else {
  87. $server_timezone = 'Europe/London';
  88. }
  89. /* New! Built in php function. Tell php what the server timezone is so that we can use php 5's rewritten time and date functions with the correct time and without error messages */
  90. date_default_timezone_set("$server_timezone");
  91. }
  92. include_once 'admin/lib/lib_logs.php';
  93. /* Start the runtime clock */
  94. pagetime('init');
  95. /* Import the validate library */
  96. include_once 'admin/lib/lib_validate.php';
  97. /* Import the date library */
  98. include_once 'admin/lib/lib_date.php';
  99. /* Import the paginator library */
  100. include_once 'admin/lib/lib_paginator.php';
  101. /* Import the pixie library */
  102. include_once 'admin/lib/lib_pixie.php';
  103. /* Import the rss library */
  104. include_once 'admin/lib/lib_rss.php';
  105. /* Import the tags library */
  106. include_once 'admin/lib/lib_tags.php';
  107. /* No spam please */
  108. include_once 'admin/lib/bad-behavior-pixie.php';
  109. /* Because pie should be simple */
  110. if (strnatcmp(phpversion(), '5.0.0') >= 0) {
  111. /* Load the php5 version of simplepie if you are running php5 */
  112. include_once 'admin/lib/lib_simplepie_php5.php';
  113. } else {
  114. include_once 'admin/lib/lib_simplepie.php';
  115. }
  116. /* Current site visitors */
  117. users_online();
  118. /* Let the magic begin */
  119. pixie();
  120. /* Referral */
  121. referral();
  122. /* Get the language file */
  123. include_once "admin/lang/{$language}.php";
  124. /* Load the current themes settings */
  125. include_once "admin/themes/{$site_theme}/settings.php";
  126. if ((isset($s)) && ($s == 404)) {
  127. /* Send correct header for 404 pages */
  128. header('HTTP/1.0 404 Not Found');
  129. }
  130. if ($m == 'rss') {
  131. if (isset($s)) {
  132. /* RSS */
  133. rss($s, $page_display_name, $page_id);
  134. }
  135. } else {
  136. if (isset($s)) {
  137. /* Load this page's description */
  138. $page_description = safe_field('page_description', 'pixie_core', "page_name='$s'");
  139. }
  140. if ($page_type == 'module') {
  141. if (isset($s)) {
  142. if (file_exists("admin/modules/{$s}_functions.php")) {
  143. include("admin/modules/{$s}_functions.php");
  144. }
  145. /* Load the module in pre mode */
  146. $do = 'pre';
  147. include("admin/modules/{$s}.php");
  148. }
  149. }
  150. if ((isset($s)) && ($s == 'contact')) {
  151. if (session_id() != 'contact') {
  152. /* Retrieve the value of the hidden field in the contact module */
  153. session_id('contact');
  154. session_cache_limiter('nocache');
  155. session_start();
  156. }
  157. }
  158. /* Theme Override Super Feature */
  159. if (file_exists("admin/themes/{$site_theme}/theme.php")) {
  160. /* New! Your custom theme file must be named theme.php instead of index.php */
  161. include_once("admin/themes/{$site_theme}/theme.php");
  162. } else {
  163. /* By default use the regular Pixie template */
  164. if ((isset($gzip_theme_output)) && ($gzip_theme_output == 'yes') && (!substr_count($_SERVER['HTTP_ACCEPT_ENCODING'], 'gzip')) && (!@extension_loaded('zlib')) && (!@ob_start("ob_gzhandler"))) /* Start gzip compression */ {
  165. if (!@ob_start()) {
  166. $gzip_theme_output = 'no';
  167. }
  168. } else {
  169. $gzip_theme_output = 'no';
  170. }
  171. ?>
  172. <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
  173. <html xmlns="http://www.w3.org/1999/xhtml" lang="en">
  174. <head>
  175. <!--
  176. Pixie Powered (www.getpixie.co.uk)
  177. Licence: GNU General Public License v3
  178. Copyright (C) <?php
  179. print date('Y');
  180. ?>, Scott Evans
  181. This program is free software: you can redistribute it and/or modify
  182. it under the terms of the GNU General Public License as published by
  183. the Free Software Foundation, either version 3 of the License, or
  184. (at your option) any later version.
  185. This program is distributed in the hope that it will be useful,
  186. but WITHOUT ANY WARRANTY; without even the implied warranty of
  187. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  188. GNU General Public License for more details.
  189. You should have received a copy of the GNU General Public License
  190. along with this program. If not, see http://www.gnu.org/licenses/
  191. www.getpixie.co.uk
  192. -->
  193. <!-- Meta tags -->
  194. <meta http-equiv="Content-Type" content="text/html;charset=UTF-8" />
  195. <meta name="keywords" content="<?php
  196. print $site_keywords;
  197. ?>" />
  198. <meta name="description" content="<?php
  199. if (isset($pinfo)) {
  200. print strip_tags($pinfo);
  201. } else {
  202. print strip_tags($page_description);
  203. }
  204. ?>" />
  205. <meta http-equiv="imagetoolbar" content="no" />
  206. <meta name="revisit-after" content="7 days" />
  207. <meta name="author" content="<?php
  208. print $site_author;
  209. ?>" />
  210. <meta name="copyright" content="<?php
  211. print $site_copyright;
  212. ?>" />
  213. <meta name="generator" content="Pixie <?php
  214. print $version;
  215. ?> - Copyright (C) 2006 - <?php
  216. print date('Y');
  217. ?>." />
  218. <!-- Title -->
  219. <title><?php
  220. if ((isset($ptitle)) && ($ptitle)) {
  221. echo $ptitle;
  222. } else {
  223. build_title();
  224. }
  225. ?></title>
  226. <?php
  227. if (!isset($theme_g_apis_jquery)) {
  228. $theme_g_apis_jquery = 'no';
  229. }
  230. if (!isset($theme_g_apis_jquery_loc)) {
  231. $theme_g_apis_jquery_loc = NULL;
  232. }
  233. if (!isset($theme_swfobject_g_apis)) {
  234. $theme_swfobject_g_apis = 'no';
  235. }
  236. if (!isset($theme_swfobject_g_apis_loc)) {
  237. $theme_swfobject_g_apis_loc = NULL;
  238. }
  239. ?>
  240. <?php
  241. /* Chain stuff to load by condition, either yes or no */
  242. if ($theme_g_apis_jquery == 'yes') {
  243. $jquery = 'yes';
  244. }
  245. ?>
  246. <!-- Javascript -->
  247. <?php
  248. if ($jquery == 'yes') {
  249. ?>
  250. <?php
  251. if ($theme_g_apis_jquery == 'yes') {
  252. /* Use jQuery from googleapis */
  253. ?>
  254. <script type="text/javascript" src="<?php
  255. print $theme_g_apis_jquery_loc;
  256. ?>"></script>
  257. <?php
  258. } else {
  259. ?>
  260. <script type="text/javascript" src="<?php
  261. print $rel_path;
  262. ?>admin/jscript/jquery.js"></script>
  263. <?php
  264. }
  265. /* End Use jQuery from googleapis */
  266. ?>
  267. <?php
  268. if ($theme_swfobject_g_apis == 'yes') {
  269. /* Use swfobject from googleapis */
  270. ?>
  271. <script type="text/javascript" src="<?php
  272. print $theme_swfobject_g_apis_loc;
  273. ?>"></script>
  274. <?php
  275. } else {
  276. ?>
  277. <script type="text/javascript" src="<?php
  278. print $rel_path;
  279. ?>admin/jscript/swfobject.js"></script>
  280. <?php
  281. }
  282. /* End Use swfobject from googleapis */
  283. ?>
  284. <script type="text/javascript" src="<?php
  285. print $rel_path;
  286. ?>admin/jscript/public.js.php<?php
  287. if (isset($s)) {
  288. print "?s={$s}";
  289. }
  290. ?>"></script>
  291. <?php
  292. }
  293. /* End jquery = yes */
  294. ?>
  295. <!-- Bad Behavior -->
  296. <?php
  297. bb2_insert_head();
  298. ?>
  299. <!-- CSS -->
  300. <link rel="stylesheet" href="<?php
  301. print $rel_path;
  302. ?>admin/themes/style.php?theme=<?php
  303. print $site_theme;
  304. ?>&amp;s=<?php
  305. print $style;
  306. ?>" type="text/css" media="screen" />
  307. <link rel="stylesheet" href="<?php
  308. print $rel_path;
  309. ?>admin/themes/<?php
  310. print $site_theme;
  311. ?>/print.css" type="text/css" media="print" />
  312. <?php
  313. /* Check for IE specific style files */
  314. $cssie = "{$rel_path}admin/themes/{$site_theme}/ie.css";
  315. $cssie6 = "{$rel_path}admin/themes/{$site_theme}/ie6.css";
  316. $cssie7 = "{$rel_path}admin/themes/{$site_theme}/ie7.css";
  317. if (file_exists($cssie)) {
  318. echo "\n\t<!--[if IE]><link href=\"{$cssie}\" type=\"text/css\" rel=\"stylesheet\" media=\"screen\" /><![endif]-->\n";
  319. }
  320. if (file_exists($cssie6)) {
  321. echo "\n\t<!--[if IE 6]><link href=\"{$cssie6}\" type=\"text/css\" rel=\"stylesheet\" media=\"screen\" /><![endif]-->\n";
  322. }
  323. if (file_exists($cssie7)) {
  324. echo "\n\t<!--[if IE 7]><link href=\"{$cssie7}\" type=\"text/css\" rel=\"stylesheet\" media=\"screen\" /><![endif]-->\n";
  325. }
  326. /* Check for handheld style file */
  327. $csshandheld = "{$rel_path}admin/themes/{$site_theme}/handheld.css";
  328. if (file_exists($csshandheld)) {
  329. echo "\n\t<link href=\"{$csshandheld}\" rel=\"stylesheet\" media=\"handheld\" />\n";
  330. }
  331. ?>
  332. <!-- Site icons-->
  333. <link rel="Shortcut Icon" type="image/x-icon" href="<?php
  334. print $rel_path;
  335. ?>admin/themes/<?php
  336. print $site_theme;
  337. ?>/favicon.ico" />
  338. <link rel="apple-touch-icon" href="<?php
  339. print $site_url;
  340. ?>files/images/apple_touch_icon.jpg"/>
  341. <!-- RSS feeds-->
  342. <?php
  343. build_rss();
  344. ?>
  345. <?php
  346. $do = 'head';
  347. if (($page_type == 'module') && (isset($s))) {
  348. include("admin/modules/{$s}.php");
  349. }
  350. ?>
  351. </head>
  352. <?php
  353. if ($gzip_theme_output == 'yes') {
  354. @ob_flush();
  355. }
  356. flush();
  357. /* Send the head so that the browser has something to do whilst it waits */
  358. ?>
  359. <body id="pixie" class="pixie <?php
  360. $date_array = getdate();
  361. print "y{$date_array['year']}";
  362. print " m{$date_array['mon']}";
  363. print " d{$date_array['mday']}";
  364. print " h{$date_array['hours']}";
  365. if ((isset($s)) && ($s)) {
  366. print " s_{$s}";
  367. }
  368. if ($m) {
  369. print " m_{$m}";
  370. }
  371. if ($x) {
  372. print " x_{$x}";
  373. }
  374. if ($p) {
  375. print " p_{$p}";
  376. }
  377. ?>">
  378. <?php
  379. build_head();
  380. ?>
  381. <div id="wrap" class="hfeed">
  382. <!-- Use for extra style as required -->
  383. <div id="extradiv_a"><span></span></div>
  384. <div id="extradiv_b"><span></span></div>
  385. <div id="placeholder">
  386. <!-- Use for extra style as required -->
  387. <div id="extradiv_1"><span></span></div>
  388. <div id="extradiv_2"><span></span></div>
  389. <div id="header">
  390. <div id="tools">
  391. <ul id="tools_list">
  392. <li id="tool_skip_navigation"><a href="#navigation" title="<?php
  393. print $lang['skip_to_nav'];
  394. ?>"><?php
  395. print $lang['skip_to_nav'];
  396. ?></a></li>
  397. <li id="tool_skip_content"><a href="#content" title="<?php
  398. print $lang['skip_to_content'];
  399. ?>"><?php
  400. print $lang['skip_to_content'];
  401. ?></a></li>
  402. </ul>
  403. </div>
  404. <h1 id="site_title" title="<?php
  405. print $site_name;
  406. ?>"><a href="<?php
  407. print $site_url;
  408. ?>" rel="home" class="replace"><?php
  409. print $site_name;
  410. ?><span></span></a></h1>
  411. <h2 id="site_strapline" title="<?php
  412. if (isset($pinfo)) {
  413. print strip_tags($pinfo);
  414. } else {
  415. print strip_tags($page_description);
  416. }
  417. ?>" class="replace"><?php
  418. if (isset($pinfo)) {
  419. print strip_tags($pinfo);
  420. } else {
  421. print strip_tags($page_description);
  422. }
  423. ?><span></span></h2>
  424. </div>
  425. <div id="navigation"><?php
  426. build_navigation();
  427. ?></div>
  428. <div id="pixie_body">
  429. <?php
  430. if ($contentfirst == 'no') {
  431. echo "\n";
  432. ?>
  433. <div id="content_blocks"><?php
  434. build_blocks();
  435. ?></div>
  436. <?php
  437. }
  438. echo "\n";
  439. ?>
  440. <div id="content"><?php
  441. $do = 'default';
  442. if ($page_type == 'static') {
  443. include('admin/modules/static.php');
  444. } else if ($page_type == 'dynamic') {
  445. include('admin/modules/dynamic.php');
  446. } else {
  447. if (isset($s)) {
  448. include("admin/modules/{$s}.php");
  449. }
  450. }
  451. ?></div>
  452. <?php
  453. if ($contentfirst == 'yes') {
  454. echo "\n";
  455. ?>
  456. <div id="content_blocks"><?php
  457. build_blocks();
  458. ?></div>
  459. <?php
  460. }
  461. echo "\n";
  462. ?>
  463. </div>
  464. <!-- Use for extra style as required -->
  465. <div id="extradiv_3"><span></span></div>
  466. <div id="extradiv_4"><span></span></div>
  467. </div>
  468. <div id="footer">
  469. <div id="credits">
  470. <ul id="credits_list">
  471. <?php
  472. if (public_page_exists('rss')) {
  473. echo "<li id=\"cred_rss\"><a href=\"" . createURL('rss') . "\" title=\"Subscribe\">Subscribe</a></li>\n";
  474. } else {
  475. echo "\n";
  476. }
  477. ?>
  478. <!-- The attribution at the bottom of every page -->
  479. <li id="cred_pixie"><a href="http://www.getpixie.co.uk" title="Get Pixie">Pixie Powered</a></li>
  480. <li id="cred_theme"><?php
  481. print $lang['theme'];
  482. print " : {$theme_name}";
  483. ?> by <a href="<?php
  484. print $theme_link;
  485. ?>" title="<?php
  486. print "{$theme_name} by {$theme_creator}";
  487. ?>"><?php
  488. print $theme_creator;
  489. ?></a></li>
  490. </ul>
  491. </div>
  492. </div>
  493. <!-- Use for extra style as required -->
  494. <div id="extradiv_c"><span></span></div>
  495. <div id="extradiv_d"><span></span></div>
  496. </div>
  497. </body>
  498. </html>
  499. <!-- Page generated in : <?php
  500. pagetime('print');
  501. ?> -->
  502. <?php
  503. if ($gzip_theme_output == 'yes') {
  504. @ob_end_flush();
  505. }
  506. ?><?php
  507. }
  508. ?>
  509. <?php
  510. }
  511. ?>