
jimboppin
Members-
Posts
41 -
Joined
-
Last visited
Everything posted by jimboppin
-
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.
-
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.
-
// 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.
-
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.
-
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.
-
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.