Page 2 of 2 FirstFirst 12
Results 11 to 20 of 20

Thread: Block from URL allow from Script?

  1. #11
    Join Date
    Jun 2005
    Location
    英国
    Posts
    11,876
    Thanks
    1
    Thanked 180 Times in 172 Posts
    Blog Entries
    2

    Default

    The untested code above was missing a few things... well 2... I figured you were testing me
    Er... yes. Yes, of course.

    I'm evidently tired (it's 0100 here). Here's the one that works:
    Code:
    <?php if(isset($_POST['id'])) {
      $p = array(
        1 => array('RED', '/red/index.php'),
        2 => array('BLUE', '/blue/index.php'),
        3 => array('YELLOW', '/yellow/index.php'),
        4 => array('GREEN', '/green/index.php')
      );
      if($_POST['pass'] === $p[$_POST['id']][0])
        header('Location: http://' . $_SERVER['HTTP_HOST'] . $p[$_POST['id']][1] . '?pass=' . $_POST['pass']);
      else
        header('Location: http://' . $_SERVER['HTTP_HOST'] . substr($_SERVER['REQUEST_URI'], 0, strrpos($_SERVER['REQUEST_URI'], '/')) . '/error.php');
    } else { ?>
    Nonono. The pages you're redirecting to must also check that the password is correct! It will be available as a GET variable.
    Twey | I understand English | 日本語が分かります | mi jimpe fi le jbobau | mi esperanton komprenas | je comprends français | entiendo español | tôi ít hiểu tiếng Việt | ich verstehe ein bisschen Deutsch | beware XHTML | common coding mistakes | tutorials | various stuff | argh PHP!

  2. #12
    Join Date
    Aug 2005
    Location
    Other Side of My Monitor
    Posts
    3,494
    Thanks
    5
    Thanked 105 Times in 104 Posts
    Blog Entries
    1

    Default

    Quote Originally Posted by Twey
    Nonono. The pages you're redirecting to must also check that the password is correct! It will be available as a GET variable.

    I have the code on ALL pages, all are exactly the same right now for testing...

    I tried your new one, and the input boxes didn't work at all, LOL it kept refreshing the same page, but never left index.php...

    {CWoT - Riddle } {Freelance Copywriter} {Learn to Write}
    Follow Me on Twitter: @InkingHubris
    PHP Code:
    $result mysql_query("SELECT finger FROM hand WHERE id=3");
    echo 
    $result

  3. #13
    Join Date
    Jun 2005
    Location
    英国
    Posts
    11,876
    Thanks
    1
    Thanked 180 Times in 172 Posts
    Blog Entries
    2

    Default

    The code above goes on the redirecting page. On the pages to be redirected TO, you'd do something like:
    Code:
    if(!isset($_GET['pass']) || $_GET['pass'] !== "RED")
      header('Location: http://' . $_SERVER['HTTP_HOST'] . substr($_SERVER['REQUEST_URI'], 0, strrpos($_SERVER['REQUEST_URI'], '/')) . '/error.php');
    And you still haven't answered: why does this all have to be on different pages?
    Twey | I understand English | 日本語が分かります | mi jimpe fi le jbobau | mi esperanton komprenas | je comprends français | entiendo español | tôi ít hiểu tiếng Việt | ich verstehe ein bisschen Deutsch | beware XHTML | common coding mistakes | tutorials | various stuff | argh PHP!

  4. #14
    Join Date
    Aug 2005
    Location
    Other Side of My Monitor
    Posts
    3,494
    Thanks
    5
    Thanked 105 Times in 104 Posts
    Blog Entries
    1

    Default

    OHHH I get it.. okay, that makes sense. I will give that a try.

    answering your question: This is just a little fun project I am trying to make. I will have many pages, and each page will link to another (using this script we have been working on), and eaach to another 4 and so on and so on...

    The layout for each is the same, so I am trying to get a template that will work and then all I will change is the password variable on each.

    This is why I was wondering if there was a htaccess or similar something I could do so I wouldn't have to put all that code on each page.

    Either way, once I have a working one it's all just copy/paste/edit to fit.
    {CWoT - Riddle } {Freelance Copywriter} {Learn to Write}
    Follow Me on Twitter: @InkingHubris
    PHP Code:
    $result mysql_query("SELECT finger FROM hand WHERE id=3");
    echo 
    $result

  5. #15
    Join Date
    Jun 2005
    Location
    英国
    Posts
    11,876
    Thanks
    1
    Thanked 180 Times in 172 Posts
    Blog Entries
    2

    Default

    This is why I was wondering if there was a htaccess or similar something I could do so I wouldn't have to put all that code on each page.
    This is why we seperate content, logic, and design. I like to do something like this:
    Code:
    <?php
    
    session_start();
    
    define('BASE_PATH', 'http://80.4.194.222/tcc/');
    
    require_once("includes/functions.inc.php");
    
    ob_start();
    require_once("includes/header.inc.php");
    $header = ob_get_clean();
    
    $parm = "";
    
    $conn = mysql_pconnect("localhost", "twey_tcc", "dbaccess14*");
    mysql_select_db("twey_tcc");
    
    // module-selection stuff, removed for brevity
    
    ob_start();
    require_once("includes/sidebar.inc.php");
    $footer = ob_get_clean();
    
    ob_start();
    require_once("includes/footer.inc.php");
    $footer = ob_get_clean();
    
    if(!isset($forum)) require("includes/template.inc.php");
    ?>
    That's an example directly lifted from the site I've been working on, so it's got more cruft than is strictly necessary, but you get the idea. template.inc.php simply contains:
    Code:
    <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
    <!--
    Copyleft: Any portion of this site may be copied, modified, or redistributed, for free or for profit, by any means possible, with the stipulations that:
    	a) credit is given to me, Twey, the author;
    	b) this license also applies to any derivative works.
     -->
    <html>
    	<head>
    		<title>
    			twey.co.uk :: <?php echo($cat); ?> :: <?php echo($title); ?>
    		</title>
    		<link rel="stylesheet" type="text/css" href="style.css.php">
    		<!--[if IE]><link rel="stylesheet" type="text/css" href="iehacks.css.php"><![endif]-->
    	</head>
    	<body>
    		<div id="corner">
    			<p id="logocontainer">
    				<a href="#content"><img src="images/invisible.gif" alt="Skip to content" style="border: 0 none;"></a>
    				<img src="images/logo.png" id="logo" alt="Twey's Logo">
    			</p>
    		</div>
    		<div id="header">
    			<?php echo($header); ?>
    		</div>
    		<div id="sidebar">
    			<?php echo($sidebar); ?>
    		</div>
    		<div id="content">
    			<h2><a href="?q=catdisp&amp;c=<?php echo($catrow['id']); ?>"><?php echo($cat); ?></a><span style="font-size: 150%;"> :: </span><?php echo($title); ?> ( <?php echo($parm); ?> ) ;</h2>
    			<?php echo($content); ?>
    		</div>
    		<div id="footer">
    			<?php echo($footer); ?>
    		</div>
    	</body>
    </html>
    Twey | I understand English | 日本語が分かります | mi jimpe fi le jbobau | mi esperanton komprenas | je comprends français | entiendo español | tôi ít hiểu tiếng Việt | ich verstehe ein bisschen Deutsch | beware XHTML | common coding mistakes | tutorials | various stuff | argh PHP!

  6. #16
    Join Date
    Aug 2005
    Location
    Other Side of My Monitor
    Posts
    3,494
    Thanks
    5
    Thanked 105 Times in 104 Posts
    Blog Entries
    1

    Default

    interesting.

    making a mental difference between logic, design, and content.. what a novel approach... I may have to try that one day
    {CWoT - Riddle } {Freelance Copywriter} {Learn to Write}
    Follow Me on Twitter: @InkingHubris
    PHP Code:
    $result mysql_query("SELECT finger FROM hand WHERE id=3");
    echo 
    $result

  7. #17
    Join Date
    Jun 2005
    Location
    英国
    Posts
    11,876
    Thanks
    1
    Thanked 180 Times in 172 Posts
    Blog Entries
    2

    Default

    what a novel approach... I may have to try that one day
    Lol, ouch! How do you survive copying and pasting all that code between pages?
    Twey | I understand English | 日本語が分かります | mi jimpe fi le jbobau | mi esperanton komprenas | je comprends français | entiendo español | tôi ít hiểu tiếng Việt | ich verstehe ein bisschen Deutsch | beware XHTML | common coding mistakes | tutorials | various stuff | argh PHP!

  8. #18
    Join Date
    Aug 2005
    Location
    Other Side of My Monitor
    Posts
    3,494
    Thanks
    5
    Thanked 105 Times in 104 Posts
    Blog Entries
    1

    Default

    Well normally because of the nature of my site almost every page is identical (in coding) so I make one page, then upload it to the server, then rename and upload, then rename upload... just changing the small bits that need changing as I go..

    I don't do 400 pages a day, more like 3 or 4 so it's not so bad, LOL

    Everything I know I have basically taught myself (through trial and error, not so much books and lessons), so when something works I usually stick with it
    {CWoT - Riddle } {Freelance Copywriter} {Learn to Write}
    Follow Me on Twitter: @InkingHubris
    PHP Code:
    $result mysql_query("SELECT finger FROM hand WHERE id=3");
    echo 
    $result

  9. #19
    Join Date
    Mar 2006
    Location
    Illinois, USA
    Posts
    12,164
    Thanks
    265
    Thanked 690 Times in 678 Posts

    Default

    But what if you need to change something on, say, 200 of those 400 pages? AH!
    Daniel - Freelance Web Design | <?php?> | <html>| español | Deutsch | italiano | português | català | un peu de français | some knowledge of several other languages: I can sometimes help translate here on DD | Linguistics Forum

  10. #20
    Join Date
    Aug 2005
    Location
    Other Side of My Monitor
    Posts
    3,494
    Thanks
    5
    Thanked 105 Times in 104 Posts
    Blog Entries
    1

    Default

    Then I come here and go "TWEYYYYYYYYYY I NEED HELP!!!!!!!"

    Then pour a cup of coffee and wait for a response.

    LMAO!
    {CWoT - Riddle } {Freelance Copywriter} {Learn to Write}
    Follow Me on Twitter: @InkingHubris
    PHP Code:
    $result mysql_query("SELECT finger FROM hand WHERE id=3");
    echo 
    $result

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •