Discover Habbo's history
Treat yourself with a Secret Santa gift.... of a random Wiki page for you to start exploring Habbo's history!
Happy holidays!
Celebrate with us at Habbox on the hotel, on our Forum and right here!
Join Habbox!
One of us! One of us! Click here to see the roles you could take as part of the Habbox community!


Results 1 to 3 of 3
  1. #1
    Join Date
    Apr 2006
    Location
    Leamington Spa
    Posts
    1,375
    Tokens
    72

    Latest Awards:

    Default [TUT] PHP - Alert User By IP (FLATFILES)

    I've commented the code. So read the orange bits if you don't get it.

    Step 1) Create a ip.txt file, leave it blank for now. It's the file that remember's the IP you are alerting.
    Step 2) Create a alert.txt file, leave it blank for now. It's the file that will remember the alert.
    Step 3) Create a alert.php file, use the following code.
    PHP Code:
    <?php
    $ip 
    file_get_contents("ip.txt"); // This code gets the ip.txt file and variable-ises it.
    $alert file_get_contents("alert.txt"); // This code gets the alert.txt file and variable-ises it.

    if($_SERVER['REMOTE_ADDR'] == $ip){ // If the users IP IS the one specified in ip.txt, do this:
    echo("
    <script language=\"JavaScript\">
    <!--
    alert('
    $alert');
    //-->
    </script> 
    "
    );// The above lines print a JavaScript alert using the text in alert.txt to the user speicified in ip.txt
    }else{ // If the users IP IS NOT the one speicified in ip.txt, do this:
    echo("<br />");
    // End the script.
    ?>
    Step 4) Edit the ip.txt and alert.txt files, ip.txt to whatever you want the IP of the user you're going to alert to be. And set alert.txt to whatever you want the message the user will send.

    Please note: Some hosts, mostly non-cPanel ones, do NOT support the use of the file_get_contents(); PHP function. This is for reasons I don't quite understand, but that's the way it is.

    Last edited by lolwut; 29-09-2007 at 09:43 AM.
    i've been here for over 8 years and i don't know why

  2. #2
    Join Date
    Jul 2007
    Location
    Swindon
    Posts
    990
    Tokens
    125

    Default

    Its ok nicely commented but its not too secure, anyone could use it couldnt they :S just have to make sure permissions are set properly !
    what you could do is make a form that saves to a flatfile with the ip and what to alert them and just have a basic login for security ! well done on the whole.

  3. #3
    Join Date
    Apr 2006
    Location
    Leamington Spa
    Posts
    1,375
    Tokens
    72

    Latest Awards:

    Default

    Quote Originally Posted by Eccentric View Post
    Its ok nicely commented but its not too secure, anyone could use it couldnt they :S just have to make sure permissions are set properly !
    what you could do is make a form that saves to a flatfile with the ip and what to alert them and just have a basic login for security ! well done on the whole.
    I considered, but I've already done this differently to use as part of my site panel. Thanks anyway, +Rep
    i've been here for over 8 years and i don't know why

Posting Permissions

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