Jump to content

Rhialto

New Members
  • Posts

    7
  • Joined

  • Last visited

    Never

Everything posted by Rhialto

  1. With over 10K posts and tagged recommended, should I assume you are giving us the best solution?
  2. Did I say it was on? If anyone else was reading I wanted to let them know your solution could be problematic if it was on.
  3. Thank you for your answer. I've read it's not safe to use when register_globals is on. The constant would be a similar and better option? That's the one I'm currently playing with ans it works great but now I must debug elsewhere... the joy of coding!
  4. I'm doing my homework by searching around and yet I found a few solutions but I don't know which one to use so advices are welcome. <?php if (eregi("INCLUDE_FILE", $_SERVER['PHP_SELF'])) { header('Location: index.php'); } ?> or <?php if ($_SERVER['SCRIPT_FILENAME'] == '<path to php include file>') { header('Location: index.php'); } ?> Another idea is to check for a constant defined in index.php: <?php if(!defined('IndexRead'){header('Location: index.php');} ?> Which one is the recommended one and why? Thanks
  5. I want to load a second page from index.php and for that I use "include second page" in it. Then on the second page I wanted to use the well known JS "if (self == top)" in the beginning so if someone wanted to load that second page directly it would be redirected to index.php first but it's not working because when the index.php execute the include it triggers the JS. Anyone have a solution for that? Thanks
  6. I came too late, cannot edit. :-\ Well I think I found out what's happening. The fact that the index.php have an include instead of loading index_xx.php, it triggers the javascript I added (look 1st post) to prevent visitor to view index_xx.php pages. Any suggestion?
  7. Hello, I will tell you whant I want to do first and what I've done so far and hopefuly someone will be able to help. What I hope for is to have one unique index.php that will work everywhere. I don't mind if I have to modify each and add path where it is located since this won't happen often. It needs to take car of preferred language and if someone land in a directory, I want it to load the index.php there. I also look to not expose hidden URL in the browser URL box. See *note 1 below. My directory structure is as follow: /index.php /about/index.php /blahblah/index.php The current index.php I'm trying to build looks like this: <?php if (preg_match('/^www.(.+)$/i', $_SERVER['HTTP_HOST'], $matches)) { header("Status: 301 Move permanently", false, 301); header('Location: http://'.$matches[1].$_SERVER['REQUEST_URI']); exit; } session_start(); $Lang = $_SESSION['lang']; if (!isset($Lang)) { if (isset($_SERVER['HTTP_ACCEPT_LANGUAGE'])) { $Lang = explode(",",$_SERVER['HTTP_ACCEPT_LANGUAGE']); $Lang = strtolower(substr(chop($Lang[0]),0,2)); if ($Lang !== 'fr' && $Lang !== 'en') { $Lang = "en"; } } else { $Lang = "en"; } $_SESSION['lang'] = $Lang; } include $_SERVER["DOCUMENT_ROOT"] . ("/index_" . $_SESSION['lang'] . ".php"); ?> First I remove "www." in the address when applies. Not a must but I like that. Then I check if Language is already set, if not I detect and set it for next pages. I finally load the proper page according to language with an "include" so index_en.php remain secret (sort of). *note 1: all my index_xx.php pages in every directory have this: <script language="javascript" type="text/javascript"> if (self == top) top.location.href="directory/index.php"; </script> When in the root, it seems to work and I get the proper page but if I place this in /about/ then when I tried to load /about/index.php it doesn't work. I think the include on the last line could be the problem. I'm either close or far from it, I don't know. Thank you.
×
×
  • 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.