vyb3 Posted October 20, 2008 Share Posted October 20, 2008 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! Quote Link to comment https://forums.phpfreaks.com/topic/129224-alternative-code-for-this/ Share on other sites More sharing options...
GKWelding Posted October 20, 2008 Share Posted October 20, 2008 you should probably also have a 'default' case just in case vyb3 is null... Quote Link to comment https://forums.phpfreaks.com/topic/129224-alternative-code-for-this/#findComment-669945 Share on other sites More sharing options...
ranjuvs Posted October 20, 2008 Share Posted October 20, 2008 What about this <?php if(isset($_GET['vyb3'])){ $vyb3=$_GET['vyb3']; $filename = $vyb3 . '.php'; if(file_exists($filename)) { include($filename); } } Quote Link to comment https://forums.phpfreaks.com/topic/129224-alternative-code-for-this/#findComment-669947 Share on other sites More sharing options...
MadTechie Posted October 20, 2008 Share Posted October 20, 2008 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); } } ?> Quote Link to comment https://forums.phpfreaks.com/topic/129224-alternative-code-for-this/#findComment-669951 Share on other sites More sharing options...
MasterACE14 Posted October 20, 2008 Share Posted October 20, 2008 use ranjuvs code, but add a default page... <?php if(isset($_GET['vyb3'])){ $vyb3=$_GET['vyb3']; $filename = $vyb3 . '.php'; if(file_exists($filename)) { include($filename); } else { include("index.php"); } } Quote Link to comment https://forums.phpfreaks.com/topic/129224-alternative-code-for-this/#findComment-669957 Share on other sites More sharing options...
vyb3 Posted October 20, 2008 Author Share Posted October 20, 2008 Ok I'l gonna try it now how do i add a default? say if i want the default to be index.php?vyb3=main Quote Link to comment https://forums.phpfreaks.com/topic/129224-alternative-code-for-this/#findComment-670084 Share on other sites More sharing options...
vyb3 Posted October 20, 2008 Author Share Posted October 20, 2008 nevermind, im a noob lol Quote Link to comment https://forums.phpfreaks.com/topic/129224-alternative-code-for-this/#findComment-670090 Share on other sites More sharing options...
aximbigfan Posted October 20, 2008 Share Posted October 20, 2008 why not just include $_GET['page'] . '.php'; ? then make you site like this yoursite.com?page=2005.php Chris Quote Link to comment https://forums.phpfreaks.com/topic/129224-alternative-code-for-this/#findComment-670100 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.