Jump to content

Vars and Server Load


PoKeSaFaRi

Recommended Posts

Recently, i've been coding some stuff on PHP, for a site that at peak times, has over 300 visitors surfing at the same time.  Considering I was told not to use MySQL for this.

As I'm not an expert, I'd like some opinions and (if possible) ways to make this work better.

What I've been doing is the following:

[code]<?
// variables
$number = "10";
$template = "ps";
$sitio = $_GET['sitio'];
$slash  = '/';
$patilla = 'index';
$error = "404.txt";
$ext = ".shtml";
$stringslash = strpos($sitio, $slash);
$stringext = strpos($sitio, $ext);

// GZIP Compression
ob_start("ob_gzhandler");
ob_start("compress");
function compress($buffer) {
  $buffer = str_replace(array("\r"), '', $buffer);
  $buffer = str_replace(array("\t"), '', $buffer);
  return $buffer;
}
// Template Conditionals
if(!isset($_GET['sitio'])){
  $menu = 'lateral.htm';
}
elseif($_GET['sitio'] == "") {
  $menu = 'lateral.htm';
}
elseif(isset($_GET['sitio']) && file_exists($_GET['sitio'].$ext) || $stringext){
  if (
  $stringext && file_exists($_GET['sitio']) ){ include $sitio;
  }
  elseif(
  ($stringext===false) && file_exists($_GET['sitio'].$ext) ){ include  $_GET['sitio'].$ext;
  }
  else {
  include $error;
  }
}
elseif($stringslash) {
    $add = $sitio.$patilla.$ext;
    if(file_exists($add)){
        include  $add;
    }
}
else{
  include $error;
}
?>[/code]

Then, further in the code, all I do is basically print the variables pageTitle and pageContent into the area of layout containing the info. $pageContent contains lots of HTML to build the changing content.

[code]
<html>
<head>
<title><? echo $pageTitle?></title>
</head>
<body>
<? echo $pageContent; ?>
</body>
</html>
[/code]

Finally:
[code]
<?
//Buffer says bye-bye
ob_end_flush();
ob_end_flush();
?>
[/code]

To anyone willing to comment on it, thanks in advance!
Link to comment
https://forums.phpfreaks.com/topic/33249-vars-and-server-load/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.