Jump to content

Recommended Posts

Right i've been having problems with my site (www.vyb3.co.uk) loading sometimes it will load properly then other times it appears to time out and only half load... I've tested it on serveral computers and it happens on them all, i've also spoke to my webhost but they haven't responded so I tried to figure out what the problem was my self and I believe its this code:

 

<?php 
if(isset($_GET['vyb3'])) $vyb3=$_GET['vyb3'];
else $vyb3='';

switch ($vyb3)
{
case "main": include('main.php'); break;
case "about": include('about.php'); break;
case "contact": include('contact.php'); break;
case "news": include('news.php'); break;
case "forums": include('forums.php'); break;
case "sounds": include('sounds.php'); break;
case "downloads": include('downloads.php'); break;
case "links": include('links.php'); break;
case "linktous": include('linktous.php'); break;
case "sponsors": include('sponsors.php'); break;
case "riddims": include('riddims.php'); break;
case "disclaimer": include('disclaimer.php'); break;
case "artistsmyspace": include('artistsmyspace.php'); break;
case "acapellas": include('acapellas.php'); break;
case "instrumentals": include('instrumentals.php'); break;
case "greensleeves": include('greensleeves.php'); break;
case "chineseassassin": include('chineseassassin.php'); break;
case "federationinvasionmixtapes": include('federationinvasionmixtapes.php'); break;
case "october2008": include('october2008.php'); break;
case "october2008mixtapes": include('october2008mixtapes.php'); break; 
case "september2008": include('september2008.php'); break;
case "september2008mixtapes": include('september2008mixtapes.php'); break;
case "august2008": include('august2008.php'); break;
case "august2008mixtapes": include('august2008mixtapes.php'); break;
case "july2008": include('july2008.php'); break;
case "july2008mixtapes": include('july2008mixtapes.php'); break;
case "june2008": include('june2008.php'); break;
case "june2008mixtapes": include('june2008mixtapes.php'); break;
case "may2008": include('may2008.php'); break;
case "may2008mixtapes": include('may2008mixtapes.php'); break;
case "april2008": include('april2008.php'); break;
case "april2008mixtapes": include('april2008mixtapes.php'); break;
case "march2008": include ('march2008.php'); break;
case "march2008mixtapes": include('march2008mixtapes.php'); break;
case "february2008": include('february2008.php'); break;
case "february2008mixtapes": include('february2008mixtapes.php'); break;
case "january2008": include('january2008.php'); break;
case "january2008mixtapes": include('january2008mixtapes.php'); break;
case "q42007": include('q42007.php'); break;
case "q42007mixtapes": include('q42007mixtapes.php'); break;
case "q32007": include('q32007.php'); break;
case "q32007mixtapes": include('q32007mixtapes.php'); break;
case "q22007": include('q22007.php'); break;
case "q22007mixtapes": include('q22007mixtapes.php'); break;
case "q12007": include('q12007.php'); break;
case "q12007mixtapes": include('q12007mixtapes.php'); break;
case "2006": include('2006.php'); break;
case "2005": include('2005.php'); break;
case "2004": include('2004.php'); break;
case "2003": include('2003.php'); break;
case "2002": include('2002.php'); break;
case "2001": include('2001.php'); break;
case "2000": include('2000.php'); break;
case "19901999": include('19901999.php'); break;
case "pre1990": include('pre1990.php'); break;
case "19901999mixtapes": include('19901999mixtapes.php'); break;
case "pre1990mixtapes": include('pre1990mixtapes.php'); break;
case "2006mixtapes": include('2006mixtapes.php'); break;
case "2005mixtapes": include('2005mixtapes.php'); break;
case "2004mixtapes": include('2004mixtapes.php'); break;
case "2003mixtapes": include('2003mixtapes.php'); break;
case "2002mixtapes": include('2002mixtapes.php'); break;
case "2001mixtapes": include('2001mixtapes.php'); break;
case "2000mixtapes": include('2000mixtapes.php'); break;
}

?>

 

Is there any more efficient way to do this? I need to keep the variable set to vyb3 and I could do with keeping all my pages in the same directory as It would be a hell of a lot of hassle to change everything. But I need a navigation system that doesnt time out sometimes.... Thats if this is even the problem.... ARGH its driving me mad!

Link to comment
https://forums.phpfreaks.com/topic/129224-alternative-code-for-this/
Share on other sites

I agree with ranjuvs but just a little security addional (if you wanted)

<?php 
if(isset($_GET['vyb3'])){
$vyb3=$_GET['vyb3'];
//Security Addition
$allowed = array("main", "about", "ect");
//Security Check
if(!in_array($vyb3, $allowed) return die('Error Loading');

$filename = $vyb3 . '.php';
if(file_exists($filename)) {
   include($filename);
}
}
?>

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.