I am getting a parse error :
Parse error: syntax error, unexpected T_STRING, expecting T_OLD_FUNCTION or T_FUNCTION or T_VAR or '}' on line
5
This is running on a server with php 4.4.8
This file (and the rest of the site) has previously worked on my local machine with php 5.2.5 and is currently working live on another server with php 4.4.7
Thanks in advance!
Here is the code:
Code:
<?php
include('nubedo.class.php');
class page extends nubedo {
public $slug;
public $db;
public $checkGallery;
function __construct($noview=false) {
parent::__construct();
$this->getPageData();
if (!$noview) {
$this->slug = $this->getSlug();
if ($this->slug) {
$this->view();
}
}else{
$this->list = $this->listAllPages();
}
$this->checkGallery = false;
}
function getSlug() {
$url = $_SERVER['REQUEST_URI'];
if (INSTALL_URI != '/')
$url = str_replace(INSTALL_URI,'',$url);
if ($url == '/') {
return 'index';
}
if (strrpos($url,'/') == strlen($url) -1) { // kill trailing slash
$url = substr($url,0,strlen($url)-1);
header("HTTP/1.0 301 Moved Permanently"); // redirect to new location
header("Status: 301 Moved Permanently");
header("Location: ".parsePath($url,1));
}
$query = str_replace(array('.html','.php','.htm','../','.'),'',$url);
$query = trim($query,'/');
$query = strpos($query,'/') !== false ? explode('/',$query) : array($query);
$query = array_reverse($query);
if (strlen($query)>0) {
return $query[0];
}else{
return 'index';
}
}
function view() {
if (!$this->slug) header("Location: ".parsePath('',1));
if (!$this->checkGallery) {
$query = "SELECT
p.id, p.parent, p.title, p.body, p.excerpt, p.seoTitle, p.seoBody, p.seoKeyword, p.slug,
pp.slug AS parentSlug, p.template, pp.parent AS pParent, p.flash FROM pages p
LEFT JOIN pages pp ON pp.id = p.parent
WHERE p.slug = '".$this->slug."' AND p.trash = 0 LIMIT 1";
}else{
$query = "SELECT
p.id, p.parent, p.title, p.body, p.seoTitle, p.seoBody, p.seoKeyword, p.slug,
pp.slug AS parentSlug, pp.parent AS pParent FROM gallery p
LEFT JOIN pages pp ON pp.id = p.parent
WHERE p.slug = '".$this->slug."' AND p.trash = 0 LIMIT 1";
}
if (!$result = $this->db->query($query)) die('Error grabbing page data: '.$this->db->error);
if ($result->num_rows > 0) {
$row = $result->fetch_assoc();
$this->data = $row;
$this->data['body'] = $this->setContent($row['body']);
$this->pageTitle = $row['seoTitle'] ? $row['seoTitle'] : $row['title'];
if ($this->checkGallery) {
$this->gallery = true;
$query = 'SELECT id, type, ext, title, body FROM galleryImages WHERE galleryID = '.$this->data['id'].' ORDER BY sort ASC';
if (!$ir = $this->db->query($query)) die('Error grabbing image data: '.$this->db->error);
while($image = $ir->fetch_assoc()) {
$this->images[] = $image;
}
}
}else{
if ($this->slug != 'contact') {
if (file_exists($this->slug.'.php')) {
include($this->slug.'.php');
exit;
}
if ($this->checkGallery != true) {
$this->checkGallery = true;
$this->view();
}elseif ($this->slug != 'error404') {
$this->error404();
$this->view();
}else{
die('<h1>Page Not Found</h1><p>The page you requested was not found.</p>');
}
}
}
}
function setContent($content) {
if (strpos($content,'{--nubedo--}') !== false) {
return explode('{--nubedo--}',$content);
}else{
return array($content);
}
}
function getChildren($level=0,$current=0,$title=true) {
if ($this->pageList[$level]) {
if ($title)
$thePages = '<h3>'.htmlspecialchars($this->pageListFlat[$level]['title']).'</h3>';
$thePages .= "\n<ul class=\"pagelist\">\n";
foreach($this->pageList[$level] AS $key => $page) {
$page['slug'] = $this->pageListFlat[$level] && $level != 0 ? $this->pageListFlat[$level]['slug'].'/'.$page['slug'] : $page['slug'];
$title = $page['seoTitle'] ? $page['seoTitle'] : $page['title'];
$thePages .= "\n<li";
$thePages .= $page['id'] == $current ? ' class="currenta">'.htmlspecialchars($title) : '><a href="/'.$page['slug'].'" title="'.htmlspecialchars($title).'">'.htmlspecialchars($page['title']).'</a>';
$thePages .= "</li>\n";
}
$thePages .= "</ul>\n";
return $thePages;
}else{
if ($this->pageListFlat[$level]['parent'] != 0)
return $this->getChildren($this->pageListFlat[$level]['parent'],$level);
}
}
function listAllPages($level=0) {
if ($this->pageList[$level]) {
$thePages .= "\n<ul class=\"pagelist\">\n";
foreach($this->pageList[$level] AS $key => $page) {
if ($page['slug'] != 'error404') {
$page['slug'] = $this->pageListFlat[$level] && $level != 0 ? $this->pageListFlat[$level]['slug'].'/'.$page['slug'] : $page['slug'];
$title = $page['seoTitle'] ? $page['seoTitle'] : $page['title'];
$thePages .= "\n<li";
$thePages .= $page['id'] == $current ? ' class="currenta">'.htmlspecialchars($title) : '><a href="/'.$page['slug'].'" title="'.htmlspecialchars($title).'">'.htmlspecialchars($page['title']).'</a>';
$thePages .= $this->listAllPages($page['id']);
$thePages .= "</li>\n";
}
}
$thePages .= "</ul>\n";
return $thePages;
}
}
function getSection($id) {
while ($this->pageListFlat[$id]['parent'] != 0) {
$id = $this->pageListFlat[$id]['parent'];
}
return $this->pageListFlat[$id]['slug'];
}
/**
* Get page information, stores in $pageList & $pageListFlat
*
* @return nothing - sets $this->pageList , $this->pageListFlat
* @access public
**/
function getPageData() {
try {
$query = "SELECT p.id,p.parent,p.title,p.slug,p.seoTitle,p.excerpt FROM pages AS p
WHERE trash = 0 AND status = 'public' ORDER BY sort ASC";
if (!$result = $this->db->query($query)) throw new Exception('Could not get user credits.<br>'.$this->db->error);
if ($result->num_rows > 0) {
while ($row = $result->fetch_assoc()) {
$this->pageList[$row['parent']][] = $row;
$this->pageListFlat[$row['id']] = $row;
}
}
$query = "SELECT CONCAT('g',p.id) AS id,p.parent,p.title,p.slug,p.seoTitle FROM gallery AS p
WHERE trash = 0 AND status = 'public' ORDER BY sort ASC";
if (!$result = $this->db->query($query)) throw new Exception('Could not get user credits.<br>'.$this->db->error);
if ($result->num_rows > 0) {
while ($row = $result->fetch_assoc()) {
$this->pageList[$row['parent']][] = $row;
$this->pageListFlat['g'.$row['id']] = $row;
}
}
} catch(Exception $e) {
catchError($e);
}
}
}