Hi, I urgently need some help with my website which is suddenly running so slow that it's almost unusable. It's running PHPbb 2.0.22, PHP Weather and PHP Fetch All. There seem to be problems with the code or mySQL database that are causing the whole site to run painfully slow.
I really need an expert to help me by looking at my PHP code and suggesting changes to speed up the whole site. This is the index.php page (with website name removed)....
<?php
$phpbb_root_path = './phpBB2/';
define ('IN_PHPBB', true);
if (!file_exists($phpbb_root_path . 'extension.inc'))
{
die ('<tt><b>phpBB Fetch All:</b>
$phpbb_root_path is wrong and does not point to your forum.</tt>');
}
include_once ($phpbb_root_path . 'extension.inc');
include_once ($phpbb_root_path . 'common.' . $phpEx);
include_once ($phpbb_root_path . 'includes/bbcode.' . $phpEx);
include_once ($phpbb_root_path . 'mods/phpbb_fetch_all/common.' . $phpEx);
include_once ($phpbb_root_path . 'mods/phpbb_fetch_all/posts.' . $phpEx);
$userdata = session_pagestart($user_ip, PAGE_INDEX);
init_userprefs($userdata);
// fetch latest postings
$CFG['posts_limit'] = 12;
$recent = phpbb_fetch_posts(null, POSTS_FETCH_LAST);
phpbb_disconnect();
?>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<html>
<head>
<title>website">
<meta name="description" content="website.">
<meta name="robots" content="index,follow">
<meta name="revisit-after" content="2 Days">
<link rel="alternate" type="application/rss+xml" title="website News" href="http://www.website.com/news.xml">
<link rel="stylesheet" href="<?php echo $phpbb_root_path; ?>templates/subSilver/subSilver.css" type="text/css" />
<LINK REL="SHORTCUT ICON" HREF="http://www.website.com/favicon.ico">
<script type="text/javascript">
<!--
This is the second half of the page....
<!--// Weather Spot Code //-->
<?php
// prints the weather information and the date
require("weather/phpweather.php");
require("weather/pw_utilities.php");
require("weather/output/pw_images.php");
require("weather/output/pw_text_en.php"); $start_time = explode(' ', microtime()); $weather = new phpweather();
$data = $weather->decode_metar();
$icons = new pw_images($weather); $visibleMiles = $data["visibility"][0]["miles"]; $type = 'pw_text_en';
$text = new $type($weather);
$prettyTime = $text->print_pretty_time($data["time"]);
$prettyTime = str_replace(',',',<br/>',$prettyTime); $prettyLocation = $text->print_pretty_location($data["location"]);
$prettyLocation = str_replace(',',',<br/>',$prettyLocation);
?>
<table border="0" cellpadding="0" cellspacing="2">
<tr align="center" style="font-size: 8pt;">
<td width="30%" class="shadow" valign="top" align="center">
Sky<br/>
<img src="<?php echo $icons->get_sky_image();?>" height="40" width="48" border="0" alt="Current conditions and visibility"/>
<br/>
<?php echo $visibleMiles; ?>
miles </td>
<td class="shadow" valign="top" align="center" width="30%">
Temp<br/>
<img src="<?php echo $icons->get_temp_image(); ?>" height="40" width="25" align="middle" border="0" alt="Current temperature in website" />
<br/>
<?php echo $data["temperature"]["temp_c"]; ?>
° c </td>
<td width="30%" class="shadow" valign="top" align="center">
Wind<br/>
<img src="<?php echo $icons->get_winddir_image(); ?>" height="40" width="40" align="middle" border="0" alt="Current wind conditions in website" />
<br/>
<?php echo $data["wind"]["miles_per_hour"]; ?>
mph </td>
</tr>
<tr style="font-size: 8pt;">
<td colspan="3" align="center"> <br/>
</td>
</tr>
</table>
</div>
</td>
</tr>
</table>
<p><a href="webcam/"><img src="button-webcam1.gif" width="189" height="57" border="0" alt="website Webcam"></a><br>
</p>
<table width="180" border="0">
<tr>
<td width="180">
<!-- RECENT -->
<?php if (isset($recent)) { ?>
<table width="180" cellpadding="2" cellspacing="1" border="0" class="forumline">
<tr>
<td class="catHead" height="28"><span class="cattitle">
<img src="topics.gif" width="177" height="35"> </span></td>
</tr>
<tr>
<td class="row1" align="left" width="180"> <span class="gensmall">
<?php for ($i = 0; $i < count($recent); $i++) { ?>
<?php echo create_date($board_config['default_dateformat'], $recent[$i]['post_time'], $board_config['board_timezone']); ?>
<a href="<?php echo append_sid($phpbb_root_path . 'profile.php?mode=viewprofile&u=' . $recent[$i]['user_id']); ?>">
<?php echo $recent[$i]['username']; ?>
</a><br />
<img src="<?php echo $phpbb_root_path; ?>templates/subSilver/images/icon_latest_reply.gif" border="0" align="absmiddle" />
<a href="<?php echo append_sid($phpbb_root_path . 'viewtopic.php?p=' . $recent[$i]['post_id'] . '#' . $recent[$i]['post_id']); ?>"><b>
<?php echo $recent[$i]['topic_title']; ?>
<?php if ($recent[$i]['topic_trimmed']) { echo '...'; } ?>
</b></a><br />
<?php } ?>
</span> </td>
</tr>
</table>
<br />
<?php } ?>
<!-- RECENT -->
</table>