Someone please help my website is down!

Hi i have a website , http://www.bestcompaniesintheworld.com, until recently (new year!) the site has been fine, but all of a sudden its coming up with an error message when i type in the url, I have copied the page its reffering to the error can anyone help please!! the error message coming up is:

Fatal error: Cannot redeclare date_format() in /home/bestdcom/public_html/libraries/functions.lib.php on line 158

here is functions.lib.php below; please can anyone advise on how to fix? would be appreciated!

<?php ob_start(); if ($cfg['memory_limit']) ini_set('memory_limit',$cfg['memory_limit']); // Set up database connection $db = new db; $db->connect($cfg['db_host'],$cfg['db_user'],$cfg['db_pass'],$cfg['db_name']); $timestamp = date("YmdHis"); $status_array = array( 'R' => 'Reserved', 'P' => 'Paid' ); /* * Build pixel links */ function link_array() { global $cfg; $grid_array = grid_array(); ?>

<?php

if ($grid_array) {

// Patch Details
foreach ($grid_array as $id => $value) {

// Explode patch details
$value = explode ("|",$value);

switch ($value[5]) {
case ‘P’:
// Get image dimensions
$file_size = getimagesize($cfg[‘upload_path’].$value[4]);
?>

<?php break; } } } ?> <?php }

/*

  • Check user session
    */
    function is_user_session() {

session_start();

if ($_SESSION[‘sess_user’] and $_SESSION[‘sess_id’])
return true;
else
return false;
}

/*

  • Check email is valid
    */
    function is_email($email) {

if (ereg("[[:alnum:]][email protected][[:alnum:]]+.[[:alnum:]]+", $email))
return true;
else
return false;
}

/*

  • Check url is valid
    */
    function is_url($url) {

if (!preg_match(’#^http://[a-z0-9-]+.([a-z0-9-]+.)?[a-z]+#i’, $url))
return false;
else
return true;
}

/*

  • Grid array
    */
    function grid_array() {

global $db,$cfg;

$query = $db->query(“SELECT * FROM “.$cfg[‘adverts’].””);
while ($result = $db->fetch_array($query)) {

$grid_array[$result[‘id’]] = $result[‘x’].’|’.$result[‘y’].’|’.$result[‘width’].’|’.$result[‘height’].’|’.$result[‘image’].’|’.$result[‘status’].’|’.$result[‘url’].’|’.$result[‘title’];
}
return $grid_array;
}

/*

  • Global email
    */
    function send_email($email,$subject,$message) {

global $cfg;

// Set HTML Mail Headers
$headers = “MIME-Version: 1.0rn”;
$headers .= “Content-type: text/html; charset=iso-8859-1rn”;
$headers .= "From: ".$cfg[‘site_email’].“rn”;
$headers .= "Reply-To: ".$cfg[‘site_email’].“rn”;

// Send email
mail($email,$subject,$message,$headers);
}

/*

  • Shorten string
    */
    function shrstr($string, $num=“50”) {

// Check string length if grater then $num
if (strlen($string) > $num) {
// Shorten the string with …
$string = substr( $string, 0, $num-2);
$string .= “…”;

return $string;
} else {
// If $num is less then
return $string;
}
}

/*

  • Convert timestamp
    */
    function date_format($date,$format) {

$year = substr($date,0,4);
$month = substr($date,4,2);
$day = substr($date,6,2);
$hour = substr($date,8,2);
$minute = substr($date,10,2);

return date($format,mktime($hour,$minute,0,$month,$day,$year));
}

/*

  • Convert all files supporting ext.
    */
    function convert_file_jpg($image,$ext) {

global $cfg;

// Check the extension of the file
if ($ext == “jpg”) {
// Create new image from JPG
$src = imagecreatefromjpeg($cfg[‘upload_path’].$image);
} elseif ($ext == “gif”) {

// Create new image from GIF
$src = imagecreatefromgif($cfg[‘upload_path’].$image);
}

// Rename new image
$new_image = substr($image,0,-3).’.gif’;

// Delete old image
unlink($cfg[‘upload_path’].$image);

// Create new JPG image
imagegif($src,$cfg[‘upload_path’].$new_image,$cfg[‘jpg_quality’]);

return $new_image;
}

/*

  • Stats
    */
    function stats() {

global $db,$cfg;

// Check global switch
if ($cfg[‘stats_order’] == “random”) {
// Run random order query
$query = $db->query(“SELECT * FROM “.$cfg[‘adverts’].” WHERE status = ‘P’ ORDER BY RAND()”);
} elseif ($cfg[‘stats_order’] == “hits”) {
// Run clicks order query
$query = $db->query(“SELECT * FROM “.$cfg[‘adverts’].” WHERE status = ‘P’ ORDER BY hits DESC”);
}
?>

<?php while ($result = $db->fetch_array($query)) { ?> <?php } ?>
URL Advert Hits
<?php echo shrstr($result['url'],30); ?>[/url] They've had <?php echo $result['hits']; ?> Visitors
<?php }

/*

  • Log errors
    */
    function log_error($timestamp,$error) {

$message = date_format($timestamp,‘d-m-y’).’-’.$error;

$file = fopen(‘error_log.txt’, ‘a’);
fwrite($file, $message);
fclose($file);
}

/*

  • News
    */
    function news() {

global $db,$cfg;

$query = $db->query(“SELECT * FROM “.$cfg[‘news’].” ORDER BY timestamp DESC”);

while ($result = $db->fetch_array($query)) {
?>

<?php echo date_format($result['timestamp'],"d F Y H:i:s"); ?>
<?php echo stripslashes($result['title']); ?>
<?php echo nl2br(stripslashes($result['text'])); ?>
Posted by <?php echo stripslashes($result['name']); ?>
<?php } } ?>

I responded to your thread in the General section http://www.phphelp.com/forums/viewtopic.php?f=1&t=8278

Please don’t post in more than one area.

Sponsor our Newsletter | Privacy Policy | Terms of Service