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!


Page 1 of 2 12 LastLast
Results 1 to 10 of 14
  1. #1
    Join Date
    Apr 2006
    Location
    Leamington Spa
    Posts
    1,375
    Tokens
    72

    Latest Awards:

    Default Log installs of a script.

    I made this so I can see the Domain and User's IP of all the people that install my script.

    Not sure why I'm posting it, guess I'm just that bored.
    On your script installer page add:

    PHP Code:
    $domain $_SERVER['HTTP_HOST'];
    $ip $_SERVER['REMOTE_ADDR'];
    echo(
    "<iframe src=\"http://URL OF THE SITE THEY DOWNLOADED IT FROM/install_logger.php?d=$domain&i=$ip\" height=\"1\" width=\"1\" frameborder=\"0\">"); 
    All that does is sends the domain name and the users IP of the person who installed the script.

    Now create a file called install_logger.php:
    PHP Code:
    <?php
    $d 
    $_GET['d'];
    $i $_GET['i'];
    $conn mysql_connect("localhost","root","");
    mysql_select_db(test) or die(mysql_error());
    mysql_query("INSERT INTO `logs` (`ip` ,`domain`) VALUES ('$i', '$d');");
    ?>
    This page sends the Users IP and Domain to the database, edit this file appropriatley.

    Now, I'm happy enough viewing the logs in my phpMyAdmin, but if you don't have phpMyAdmin or don't know how to use it;

    Create a file called logs_view.php:

    PHP Code:
    <?php
    $conn 
    mysql_connect("localhost","root","");
    mysql_select_db(test) or die(mysql_error());
    $get mysql_query("SELECT * FROM `logs` order by id asc");
    while (
    $logs mysql_fetch_array($get))
    {
    echo (
    "Installed on: $logs[domain]. By (IP Address): $logs[ip].<br />");
    }
    ?>
    Edit the database connection info here aswell. Also, you may want to password protect that file and edit it to add a Clear Logs, but I can't be bothered posting one as I do it through phpMyAdmin.

    Rate my code please?

    NOTE: The viewer is edited TechTuts code as I couldn't be bothered doing it myself.
    Last edited by lolwut; 21-10-2007 at 12:47 PM.
    i've been here for over 8 years and i don't know why

  2. #2
    Join Date
    Aug 2006
    Location
    Manchester, UK
    Posts
    2,016
    Tokens
    141
    Habbo
    florx

    Latest Awards:

    Default

    You need to make sure that you add % into the allowed users to access the mysql database

  3. #3
    Join Date
    May 2005
    Location
    San Francisco, CA
    Posts
    7,160
    Tokens
    2,331

    Latest Awards:

    Default

    PHP Code:
    $domain $_SERVER['HTTP_HOST'];
    $ip $_SERVER['REMOTE_ADDR'];
    echo(
    "<iframe src=\"http://URL OF THE SITE THEY DOWNLOADED IT FROM/install_logger.php?d=$domain&i=$ip\" height=\"1\" width=\"1\" frameborder=\"0\">"); 
    >

    PHP Code:
    $domain $_SERVER['HTTP_HOST'];
    $ip $_SERVER['REMOTE_ADDR'];
    $report file_get_contents("http://URL OF THE SITE THEY DOWNLOADED IT FROM/install_logger.php?d=".$domain."&i=".$ip.""); 
    ---

    PHP Code:
    <?php
    $d 
    $_GET['d'];
    $i $_GET['i'];
    $conn mysql_connect("localhost","root","");
    mysql_select_db(test) or die(mysql_error());
    mysql_query("INSERT INTO `logs` (`ip` ,`domain`) VALUES ('$i', '$d');");
    ?>
    >

    PHP Code:
    <?php

        
    function clean($var)
        {
            
            
    $var htmlspecialchars$varENT_QUOTES );

            if( 
    get_magic_quotes_gpc(   ) ) {
        
                
    $var stripslashes$var );
                        
            }
                    
            
    $var str_replace"\""""$var );
            
    $var htmlentities$var );
            
    $var mysql_real_escape_string$var );
            
            return 
    $var;
        
        }

    $d $_GET['d'];
    $d clean($d);

    $i $_GET['i'];
    $i clean($d);

    $conn mysql_connect("localhost","root","") or die("Error on connecting to server, error msg: ".mysql_error());

    $select_db mysql_select_db("test") or die("Error on selecting database, error msg: ".mysql_error());

    mysql_query("INSERT INTO `logs` (`ip` ,`domain`) VALUES ('".$i."', '".$d."')") or die("Error on SQL Query, error msg: ".mysql_error());

    ?>
    --

    PHP Code:
    <?php
    $conn 
    mysql_connect("localhost","root","");
    mysql_select_db(test) or die(mysql_error());
    $get mysql_query("SELECT * FROM `logs` order by id asc");
    while (
    $logs mysql_fetch_array($get))
    {
    echo (
    "Installed on: $logs[domain]. By (IP Address): $logs[ip].<br />");
    }
    ?>
    >

    PHP Code:
    <?php
    $conn 
    mysql_connect("localhost","root","") or die("Error on connecting to server, error msg: ".mysql_error());

    $select_db mysql_select_db("test") or die("Error on connecting to server, error msg: ".mysql_error());

    $get mysql_query("SELECT * FROM `logs` ORDER BY `id` ASC");

    while ( 
    $logs mysql_fetch_array$get ) )
    {

    echo (
    "Installed on: ".$logs["domain"].". By (IP Address): ".$logs["ip"].".<br />");

    }
    ?>
    Last edited by Invent; 21-10-2007 at 03:54 PM.

  4. #4
    Join Date
    Oct 2007
    Location
    Luton, England
    Posts
    1,548
    Tokens
    388
    Habbo
    DeejayMachoo

    Latest Awards:

    Default

    looks ok but would it not work using an include instead of an iframe?


    EDIT: simon's way is even better lol

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

    Latest Awards:

    Default

    Simon stop owning me at everything.
    I only made this so I can log installs, aslong as it works, I'm fine.
    Last edited by lolwut; 21-10-2007 at 04:07 PM.
    i've been here for over 8 years and i don't know why

  6. #6
    Join Date
    May 2005
    Location
    San Francisco, CA
    Posts
    7,160
    Tokens
    2,331

    Latest Awards:

    Default

    I only made this so I can log installs, aslong as it works, I'm fine.
    As long as you don't clean the GET vars you're not fine.

  7. #7
    Join Date
    Aug 2006
    Location
    Manchester, UK
    Posts
    2,016
    Tokens
    141
    Habbo
    florx

    Latest Awards:

    Default

    Quote Originally Posted by Invent View Post
    As long as you don't clean the GET vars you're not fine.
    As you found out...

  8. #8
    Join Date
    May 2005
    Location
    San Francisco, CA
    Posts
    7,160
    Tokens
    2,331

    Latest Awards:

    Default

    As you found out...
    Wth? On my script I cleaned my vars...I don't think you know what cleaning your vars means, lol.

  9. #9
    Join Date
    Aug 2006
    Location
    Manchester, UK
    Posts
    2,016
    Tokens
    141
    Habbo
    florx

    Latest Awards:

    Default

    Uhh remember when your logging script got owned with iframes, redirects, e.t.c.

    POWERpanel

  10. #10
    Join Date
    Oct 2007
    Location
    Luton, England
    Posts
    1,548
    Tokens
    388
    Habbo
    DeejayMachoo

    Latest Awards:

    Default

    Quote Originally Posted by Invent View Post
    PHP Code:
    <?php

        
    function clean($var)
        {
            
            
    $var htmlspecialchars$varENT_QUOTES );

            if( 
    get_magic_quotes_gpc(   ) ) {
        
                
    $var stripslashes$var );
                        
            }
                    
            
    $var str_replace"\""""$var );
            
    $var htmlentities$var );
            
    $var mysql_real_escape_string$var );
            
            return 
    $var;
        
        }

    $d $_GET['d'];
    $d clean($d);

    $i $_GET['i'];
    $i clean($d);

    $conn mysql_connect("localhost","root","") or die("Error on connecting to server, error msg: ".mysql_error());

    $select_db mysql_select_db("test") or die("Error on selecting database, error msg: ".mysql_error());

    mysql_query("INSERT INTO `logs` (`ip` ,`domain`) VALUES ('".$i."', '".$d."')") or die("Error on SQL Query, error msg: ".mysql_error());

    ?>
    PHP Code:
    <?php
    $conn 
    mysql_connect("localhost","root","") or die("Error on connecting to server, error msg: ".mysql_error());
     
     
    $select_db mysql_select_db("test") or die("Error on selecting database, error msg: ".mysql_error());

        function 
    clean($var)
        {
            
            
    $var htmlspecialchars$varENT_QUOTES );

            if( 
    get_magic_quotes_gpc(   ) ) {
        
                
    $var stripslashes$var );
                        
            }
                    
            
    $var str_replace"\""""$var );
            
    $var htmlentities$var );
            
    $var mysql_real_escape_string$var );
            
            return 
    $var;
        
        }

    $d $_GET['d'];
    $d clean($d);

    $i $_GET['i'];
    $i clean($i);

    mysql_query("INSERT INTO `logs` (`ip` ,`domain`) VALUES ('".$i."', '".$d."')") or die("Error on SQL Query, error msg: ".mysql_error());

    ?>
    Two errors, need to define db first also,

    $i = $_GET['i'];
    $i = clean($d);

    also cleaning wrong var?
    Last edited by DeejayMachoo$; 21-10-2007 at 04:31 PM.

Page 1 of 2 12 LastLast

Posting Permissions

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