intodesi Posted April 20, 2008 Share Posted April 20, 2008 Ok I had another post concerning the security of one of my scripts, I want to modify that script to do something else, but not sure how it would all work out. Here is the code: $dir = array('/clients/','/clients/clients/'); $pass = array('web','services','print','pricing','other','main','host','grx','contact','referrals','links','clientarea','pricewatch','register_','register','emailpass_','emailpass','redirect','suzy'); if (in_array($_GET['p'], $pass)) { include ($_SERVER['DOCUMENT_ROOT'] . '/pages/' . $_GET['p'] . '.php'); } elseif (in_array($_GET['c'], $pass)) { include ($_SERVER['DOCUMENT_ROOT'] .$dir. $_GET['c'] .'.php'); } else { include ($_SERVER['DOCUMENT_ROOT'] .'/pages'. '/main.php'); } so i have the $dir = array('/clients/','/clients/clients/'); and then include ($_SERVER['DOCUMENT_ROOT'] .$dir. $_GET['c'] .'.php'); and what i would like it to do is use both those directories i have in my $dir array. But its not working... I get the following error Warning: main(/home/techurch/public_html/zintoArrayclientarea.php) [function.main]: failed to open stream: No such file or directory in /home/techurch/public_html/zinto/index.php on line 123 Warning: main(/home/techurch/public_html/zintoArrayclientarea.php) [function.main]: failed to open stream: No such file or directory in /home/techurch/public_html/zinto/index.php on line 123 Warning: main() [function.include]: Failed opening '/home/techurch/public_html/zintoArrayclientarea.php' for inclusion (include_path='.:/usr/php4/lib/php:/usr/local/php4/lib/php') in /home/techurch/public_html/zinto/index.php on line 123 Thanks for any advice. Link to comment https://forums.phpfreaks.com/topic/101942-solved-will-this-type-of-array-work/ Share on other sites More sharing options...
AP81 Posted April 20, 2008 Share Posted April 20, 2008 include ($_SERVER['DOCUMENT_ROOT'] .$dir. $_GET['c'] .'.php'); ??? $dir is an array. This will not work. Link to comment https://forums.phpfreaks.com/topic/101942-solved-will-this-type-of-array-work/#findComment-521703 Share on other sites More sharing options...
intodesi Posted April 20, 2008 Author Share Posted April 20, 2008 how would i make that work? or what else could i do to get a similiar result to what i want to do? what I want to do is use this include ($_SERVER['DOCUMENT_ROOT'] .$dir. $_GET['c'] .'.php'); and where the $dir i would like it to either use one directory or another, or look in both for the page that was requested so if one page is in clients then the code would go to the directory and grab that page, and so then the person clicks on another page but it resides in clients/clients that page would be displayed.. as of right now with the $dir variable it wont work. if i just replace dir with '/clients/' it works. but that restricts them from opening anything in the clients folder under that directory. which i need to be able to do could i use another elseif statement? or? any ideas would be apreciated. Thanks Intodesi Link to comment https://forums.phpfreaks.com/topic/101942-solved-will-this-type-of-array-work/#findComment-521710 Share on other sites More sharing options...
AP81 Posted April 20, 2008 Share Posted April 20, 2008 elseif (in_array($_GET['c'], $pass)) { $file = $_SERVER['DOCUMENT_ROOT'] . $dir[0] . $_GET['c'] .'.php'; if (file_exists($file)) { include ($file); } else { $file = $_SERVER['DOCUMENT_ROOT'] . $dir[1] . $_GET['c'] .'.php'; if (file_exists($file)) include ($file); } OR, a better way elseif (in_array($_GET['c'], $pass)) { foreach ($dir as $val) { $file = $_SERVER['DOCUMENT_ROOT'] . $val . $_GET['c'] .'.php'; if (file_exists($file)) { include($file); break; } } } Link to comment https://forums.phpfreaks.com/topic/101942-solved-will-this-type-of-array-work/#findComment-521724 Share on other sites More sharing options...
intodesi Posted April 20, 2008 Author Share Posted April 20, 2008 Perfect, Thank you so much AP81.. now if i can figure out how to give each of those pages a title... Link to comment https://forums.phpfreaks.com/topic/101942-solved-will-this-type-of-array-work/#findComment-521731 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.