Jump to content

jimboppin

Members
  • Posts

    41
  • Joined

  • Last visited

Everything posted by jimboppin

  1. is it ok to use require alot too? i used to use includes but they all seem to do the same thing...
  2. hows this... <?php // Directory Of Page_Include const INCLUDE_BASEDIR = __DIR__.'/page_include/'; // Directory Of Pages const PAGES_BASEDIR = __DIR__.'/pages/'; require_once INCLUDE_BASEDIR.'page_config.php'; if ($detect->isMobile()) { header('Location: mobile.php'); exit(0); } const PAGES = [ // Array Of Active Pages 'home', ]; if (!isset($_GET['page'])) { // Default Index Page i.e "home" require PAGES_BASEDIR.'home.php'; } else if (in_array($_GET['page'], PAGES, true) && is_readable(PAGES_BASEDIR.$_GET['page'].'.php')) { // Displays The Called Link i.e index.php/?page=home require PAGES_BASEDIR.$_GET['page'].'.php'; } else { http_response_code(404); // Display Error404 Page require PAGES_BASEDIR.'Error404.php'; } require INCLUDE_BASEDIR.'page_footer.php'; ?> iv been working on this none stop haha its a little addictive Jimbo.
  3. well i did it! thankyou again! if you could just check it for me // Directory Of Pages const PAGES_BASEDIR = __DIR__.'/pages/'; const PAGES = [ // Array Of Active Pages 'home', ]; if (!isset($_GET['page'])) { // Default Index Page i.e "home" require('pages/home.php'); } else if (in_array($_GET['page'], PAGES, true) && is_readable(PAGES_BASEDIR.$_GET['page'].'.php')) { // Displays The Called Link i.e index.php/?page=home require PAGES_BASEDIR.$_GET['page'].'.php'; } else { http_response_code(404); // Display Error404 Page require('pages/Error404.php'); } Jimbo.
  4. ah i see what you mean now.. as i said im not a coder this is just a hobby for me i learn alot from it. Would you be able to apply that to my code please so i can see how it is suposed to be? Would be appreciated Jimbo.
  5. here is my site i feel its working well so far.. index https://www.zonepimps.co.uk wrong link https://www.zonepimps.co.uk/?page=wronglink then just my homepage but being called thru the links http://www.zonepimps.co.uk/?page=home i think iv managed realy well with a little help from yourself Jimbo.
  6. // Directory Of Pages const PAGES_BASEDIR = __DIR__.'/pages/'; const PAGES = [ // Array Of Active Pages 'home', ]; if (isset($_GET['page']) && in_array($_GET['page'], PAGES, true) && is_readable(PAGES_BASEDIR.$_GET['page'].'.php')) { // Displays The Called Link i.e index.php/?page=home require PAGES_BASEDIR.$_GET['page'].'.php'; } else { // Check To Display Error Or Home if (isset($_GET['page'])) { http_response_code(404); // Display Error404 Page require('pages/Error404.php'); } else { // Default Index Page i.e "home" require('pages/home.php'); } } do you mean like this... im not a coder just learn fast i did alot in my teens but forgot alot of it. JImbo.
  7. hi iv done it finaly worked it out.. for anyone wanting to have a links system within your index page and still have your index as index this works fine for me and it shows error page if any wrong links are called. const PAGES_BASEDIR = __DIR__.'/pages/'; const PAGES = [ 'home', ]; if (isset($_GET['page']) && in_array($_GET['page'], PAGES, true) && is_readable(PAGES_BASEDIR.$_GET['page'].'.php')) { require PAGES_BASEDIR.$_GET['page'].'.php'; } else { if (isset($_GET['page'])) { http_response_code(404); // display error page require('pages/error.php'); } else { require('pages/home.php'); } } Thankyou for your time. Jimbo.
  8. i imagine something like this... if (!isset($_GET['page'])) { $action = $_GET['page']; $action = basename($action); require('pages/$action.php'); } else { require('pages/error.php'); } else { require('pages/home.php'); } but i dont know how to make it work
  9. hi i have updated my code from what you have posted here and my errors have stopt now and if there is a wrong link being called it just ignores it and gose home.. but i still would like it to go to an error page if the link called is not valid to the contents of my pages/ dir here is my updated code, not changed alot just cleaned it i think... if (!isset($_GET['page'])) { $action = $_GET['page']; $action = basename($action); require('pages/$action.php'); } else { require('pages/home.php'); } Jimbo.
  10. is it possible to add this? so i can have a default then the called link then if link called is wrong or file not there then error page... i would like to update my index with this code if this is possible Jimbo.
  11. I think this post would be usefull to some one, if you can think of a better title then "please help" then maybe people will find this answer easyer Jimbo.
  12. awesome man, thats just what i need, just one thing though i need a default page with it being index.php the default page would be "home" .. but not called as the link just "pages/home.php" thankyou for your help so far! Jimbo
  13. thankyou for fast reply, how can i get that code to deny ALL that is not in my "pages/" folder ?? i dont want a array of blacklisted names becouse there are still thousands of other words that could still create this error im getting.. i hope you understand as im not too good at explaining Jimbo
  14. Hi basicly i have my index.php and from there i use this code to get the content etc.. you will understand more then me i just know what it dose haha.. <?php require_once('page_include/page_config.php'); if ($detect->isMobile()) { header('Location: mobile.php'); exit(0); } if (!empty($_GET['page'])) { $action = $_GET['page']; $action = basename($action); include('pages/$action.php'); } else { include('pages/home.php'); } include('page_include/page_footer.php'); ?>so this works fine for me but if some one tries to call a "non existing" .php file from the pages folder i will get an error here is a link for example https://zonepimps.co.uk/?page=stats .. my stats page is no more but google bots still call it witch is how i found this bug.. here is the error [26-Oct-2016 22:27:55 UTC] PHP Warning: include(pages/stats.php): failed to open stream: No such file or directory in /home/#######/public_html/index.php on line 15 [26-Oct-2016 22:27:55 UTC] PHP Warning: include(pages/stats.php): failed to open stream: No such file or directory in /home/#######/public_html/index.php on line 15 [26-Oct-2016 22:27:55 UTC] PHP Warning: include(): Failed opening 'pages/stats.php' for inclusion (include_path='.:/opt/alt/php56/usr/share/pear:/opt/alt/php56/usr/share/php') in /home/#######/public_html/index.php on line 15 if someone could point me in the right direction or help me with this i would be greatfull, i used this code years ago and i added elseif and if a link was called and the file was not in the directory it would display an error page but i lost all that code! iv been spending hours trying to recover hdd partitions and found nothing.. so here i am JIMBO.
×
×
  • 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.