Created
April 6, 2010 01:17
-
-
Save SeanJA/357089 to your computer and use it in GitHub Desktop.
a bad way to do mvc...
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
$location = isset($_GET['location'])? $_GET['location'] : 'home'; | |
/// include the correct page if it is in our list, or open the home page | |
switch($location){ | |
case 'blog': | |
case 'comments': | |
case 'new_comment': | |
case 'new_post': | |
case 'archives': | |
case 'old_posts': | |
break; | |
case 'home': | |
case '': | |
$location = 'home'; | |
break; | |
case '404': | |
default: | |
$location = '404'; | |
break; | |
} | |
include $location . '.php'; | |
exit; | |
?> | |
<?php | |
// alternatively it could be this: | |
$pages = array( | |
'blog', | |
'comments', | |
'new_comment', | |
'new_post', | |
'archives', | |
'old_posts', | |
'home', | |
'404', | |
); | |
$location = isset($_GET['location'])? $_GET['location'] : 'home'; | |
if(in_array($location, $pages)){ | |
include $page . '.php'; | |
} else { | |
include '404.php'; | |
} | |
?> | |
<?php | |
/// a third (possibly less secure) way would be something like this: | |
$location = isset($_GET['location'])? $_GET['location'] : 'home'; | |
//don't let them have . in the location url so they cannot go backwards up the filetree | |
if(strpos('.', $location) !== false)){ | |
$location = '404'; | |
} | |
if(file_exists(MY_SITE_FOLDER.DIRECTORY_SEPARATOR.$location)){ | |
include MY_SITE_FOLDER.DIRECTORY_SEPARATOR.$location . '.php'; | |
} else { | |
include MY_SITE_FOLDER.DIRECTORY_SEPARATOR.'404.php'; | |
} | |
?> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/// taken from http://github.com/esokullu/grou.ps/blob/master/index.php | |
switch($function) { | |
case 'join': | |
if(!$access_isGroupMember) { | |
if(!isAuthenticated()) { | |
$pg->setLayout($pg->EqualColumns); | |
$signin = "<form method=\"POST\" action=\"{$service_host}?function=signin\">"; | |
$temp_translation_string_1 = $treng->_("Email","groupjoin"); | |
$temp_translation_string_2 = $treng->_("Password","groupjoin"); | |
$temp_translation_string_3 = $treng->_("Keep me signed in unless I sign out","groupjoin"); | |
$temp_translation_string_4 = $treng->_("Sign In","groupjoin"); | |
$trengvar = array($service_host,$group_name); | |
$temp_translation_string_5 = $treng->_("Forgot your username and/or password? <a href=\"%TRENGVAR_1%%TRENGVAR_2%/recover\">Recover</a>!<br />Alternatively, you can sign in via your <a href=\"%TRENGVAR_1%%TRENGVAR_2%/openid\">OpenID</a>","authentication",$trengvar); | |
$temp_translation_string_6 = $treng->_("Sign Up","groupjoin"); | |
$signin .= <<<EOS | |
<input type="hidden" name="join" value="1" /> | |
<div style="height:30px;width:100%;padding:5px;"> | |
<div style="float:left;width:100px;font-weight:bold;">{$temp_translation_string_1}</div> | |
<div style="float:left;width:auto;"><input type="text" name="username"></div> | |
</div> | |
<div style="height:30px;width:100%;padding:5px;"> | |
<div style="float:left;width:100px;font-weight:bold;">{$temp_translation_string_2}</div> | |
<div style="float:left;width:auto;"><input type="password" name="password"></div> | |
</div> | |
<div style="height:30px;width:100%;padding:5px;"> | |
<input type="checkbox" name="rememberme" value="1" checked /> {$temp_translation_string_3} | |
</div> | |
<div style="padding:5px;"> | |
<input type="submit" value="{$temp_translation_string_4}" /> | |
</div> | |
<div style="padding:5px; margin: 5px 0 0 0;"> | |
{$temp_translation_string_5} | |
</div> | |
</form> | |
EOS; | |
//[ ... and it continues on for 100s of lines ...] |
In the first example if $location == "home" then it will take you to a 404.
Fixed it!
Second file is bringing back nightmares of legacy projects
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
don't do this...