babybird11 Posted January 15, 2008 Share Posted January 15, 2008 Hi i have a website , 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(); ?> <img src="grid.php" width="1000" height="1000" usemap="#image-map" border="0"> <map name="image-map"> <?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]); ?> <area shape="rect" coords="<?php echo ($value[0]); ?>,<?php echo ($value[1]); ?>,<?php echo ($value[0]+$file_size[0]); ?>,<?php echo ($value[1]+$file_size[1]); ?>" href="url.php?id=<?php echo $id; ?>" title="<?php echo $value[7]; ?>" target="_blank"> <?php break; } } } ?> </map> <?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:]]+@[[: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.0\r\n"; $headers .= "Content-type: text/html; charset=iso-8859-1\r\n"; $headers .= "From: ".$cfg['site_email']."\r\n"; $headers .= "Reply-To: ".$cfg['site_email']."\r\n"; // 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"); } ?> <!-- BEGIN Statistics --> <table id=stats> <tr > <td class="label">URL</td> <td class="label">Advert</td> <td class="label">Hits</td> </tr> <?php while ($result = $db->fetch_array($query)) { ?> <tr class="row"> <td class="url"><a href="url.php?id=<?php echo $result['id']; ?>" target="_blank"><?php echo shrstr($result['url'],30); ?></a></td> <td class="advert"><img src="<?php echo $cfg['upload_path'].$result['image']; ?>"></td> <td class="hits">They've had <strong><?php echo $result['hits']; ?></strong> Visitors</td> </tr> <!-- END Statistics --> <?php } ?> </table> <?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)) { ?> <table id=news> <tr> <td class="timestamp"><?php echo date_format($result['timestamp'],"d F Y H:i:s"); ?><td> </tr> <tr> <td class="title"><?php echo stripslashes($result['title']); ?><td> </tr> <tr> <td class="text"><?php echo nl2br(stripslashes($result['text'])); ?><td> </tr> <tr> <td class="name">Posted by <?php echo stripslashes($result['name']); ?><td> </tr> </table> <div class="seperator"></div> <?php } } ?> Link to comment https://forums.phpfreaks.com/topic/86142-php-script-help-required-please/ Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.