Jump to content

CBaZ

Members
  • Posts

    128
  • Joined

  • Last visited

Posts posted by CBaZ

  1. this is how I get it to insert just doesn't delete and username here is working so I am not sure whats going on for the delete.

    <code>

    <?php

     

    include("dbinfo.php");

     

     

    global $HTTP_SERVER_VARS;

     

     

    // Set length of session to twenty minutes

    define("SESSION_LENGTH", 20);

     

    $userIP = $HTTP_SERVER_VARS["REMOTE_ADDR"];

     

    $sConn = @mysql_connect($dbServer, $dbUser, $dbPass)

    or die("Couldnt connect to database");

     

    $dbConn = @mysql_select_db($dbName, $sConn)

    or die("Couldnt select database $dbName");

     

    $timeMax = time() - (60 * "SESSION_LENGTH");

    $result = mysql_query("select count(*) from usersOnline where unix_timestamp(dateAdded) >= '$timeMax' and userIP = '$userIP'");

     

    $recordExists = mysql_result($result, 0, 0) > 0 ? true : false;

    if(!$recordExists) $usersonline = mysql_num_rows($recordExists);

    {

    // Add a record for this user

    @mysql_query("INSERT INTO usersOnline(userIP, username, permission, user_id) values ('$userIP', '$_SESSION[username]', '$_SESSION[permission]', '$_SESSION[id]')"); 

    @mysql_query("DELETE FROM usersOnline WHERE dateAdded < $timeMax");

    mysql_close();

    return $usersonline;

    }

    ?> </code>

  2. I am inserting with this script but not deleting still have tryed various things not sure as to why its not deleting yet.

    any help greatly appreciated.

     

    
    <?php 
    
    include("dbinfo.php"); 
    
    
    global $HTTP_SERVER_VARS; 
    
    
    // Set length of session to twenty minutes 
    define("SESSION_LENGTH", 20); 
    
    $userIP = $HTTP_SERVER_VARS["REMOTE_ADDR"]; 
    
    $sConn = @mysql_connect($dbServer, $dbUser, $dbPass) 
    or die("Couldnt connect to database"); 
    
    $dbConn = @mysql_select_db($dbName, $sConn) 
    or die("Couldnt select database $dbName"); 
    
    $timeMax = time() - (60 * "SESSION_LENGTH"); 
    $result = mysql_query("select count(*) from usersOnline where unix_timestamp(dateAdded) >= '$timeMax' and userIP = '$userIP'"); 
    
    $recordExists = mysql_result($result, 0, 0) > 0 ? true : false; 
    if(!$recordExists) $usersonline = mysql_num_rows($recordExists);
    { 
    // Add a record for this user 
    @mysql_query("INSERT INTO usersOnline(userIP, username, permission, user_id) values ('$userIP', '$_SESSION[username]', '$_SESSION[permission]', '$_SESSION[id]')");   
    @mysql_query("DELETE FROM usersOnline WHERE dateAdded < $timeMax");
    mysql_close();
    return $usersonline; 
    } 
    ?> 

  3. <?php 
    include ("password/dbinfo.php")
    $sConn = @mysql_connect($dbServer, $dbUser, $dbPass) 
    or die("Couldnt connect to database"); 
    
    $dbConn = @mysql_select_db($dbName, $sConn) 
    or die("Couldnt select database $dbName"); 
    // Delete a record for this user 
    $timeMax = time() - (60 * SESSION_LENGTH);
    $userIP = $HTTP_SERVER_VARS["REMOTE_ADDR"]; 
    $result = mysql_query("select count(*) from usersOnline where unix_timestamp(dateAdded) >= '$timeMax' and userIP = '$userIP'"); 
    mysql_query($result);
    
    $q = mysql_query("DELETE FROM usersOnline WHERE unix_timestamp(dateAdded) >= '$timeMax' and username = '$username'");
         mysql_query($q);
    ?>
    

  4. i get a blank screen from this any ideas?

     

    <?
    session_start();
    if ($yes) {
    
    include ("password/dbinfo.php")
    
    define("SESSION_LENGTH", 60); 
    
    $sConn = @mysql_connect($dbServer, $dbUser, $dbPass) 
    or die("Couldnt connect to database"); 
    
    $dbConn = @mysql_select_db($dbName, $sConn) 
    or die("Couldnt select database $dbName"); 
    
    $timeMax = time() - (60 * SESSION_LENGTH);
    { 
    // Delete a record for this user 
    $delete = mysql_query("DELETE FROM usersOnline WHERE dateAdded<$timeMax") or die("Unable remove timed outusers");
    $d = mysql_query($delete);
    } 
    session_destroy();  
    }
    ?>
    </code>

  5. i am not getting the id for the usernames being added in the above code where its insert.  it gives me id's that have nothing to do with the ones just added. do you have an example of how i would search the database like with another select from or something have been trying to google it just can't think of it.

  6. 2 issues in this script. one being I don't want it to keep entering the same usernames over and over i need a check if exist type thing and its not working what I currently have in place...

     

    also the profile2.php link at the bottom does not generate the correct id. the id needs to be for $triv usernames. not sure if this can be figured out with just this script by itself please let me know if you need more info.

     

    <?php

    echo mysql_error();

    $connect = mysql_connect("localhost", "user", "pw") or die ("Could not connect to database: " . mysql_error());

    mysql_select_db("db", $connect) or die ("Could not select database");

    $query = mysql_query("SELECT * FROM users WHERE username != '$username'") or die("QUERY FAILED: " . mysql_error());

    $triv = file("users_online2.txt");

    $date = date("YmdHis");

    echo $triv;

    if (mysql_num_rows($query) > 1 ) {

    // loop though array

    for($i=0;$i<count($triv);$i++) {

    // and add each entry to SQL

    $result = "INSERT INTO users (username,created) VALUES ('$triv[$i]', '$date')";

    $row2 = mysql_query($result);

    }} else {

    $connect = mysql_connect("localhost", "user", "pw") or die ("Could not connect to database: " . mysql_error());

    mysql_select_db("db", $connect) or die ("Could not select database");

    $sql = mysql_query("SELECT user_id FROM users WHERE username != '$username' ORDER by created");

    $row = mysql_fetch_assoc($sql);

    echo '</div><div class="title" id="top_bar_right"><a href="profile2.php?user_id='.$row['user_id'].'" target="RSIFrame2">'$triv'</div></div>';

    }

    ?>

  7. ok it runs this way but it does not add to the database and i am not sure if it will put each line from txt into a seperate line of my mysql.  also the user_id does not come up not sure as to why.

     

    <?php

    echo mysql_error();

    $connect = mysql_connect("localhost", "user", "pw") or die ("Could not connect to database: " . mysql_error());

    mysql_select_db("db", $connect) or die ("Could not select database");

    $query = mysql_query("SELECT * FROM users WHERE username != '$username'") or die("QUERY FAILED: " . mysql_error());

    $triv = file_get_contents("users_online2.txt");

    $date = date("YmdHis");

    echo $triv;

    if (mysql_num_rows($query) <= 0) {

    $result = "INSERT INTO users (username,created) VALUES ('$triv', '$date')";

            $row2 = mysql_query($result);

    } else if (mysql_num_rows($query) >= 1) {

    echo "number of rows: '".mysql_num_rows($query);

    }

    $sql = mysql_query("SELECT user_id FROM users WHERE user_id = '$user_id' ORDER BY created");

    echo '</div><div class="title" id="top_bar_right"><a href="profile2.php?user_id='.$sql['user_id'].'" target="RSIFrame2">'.$triv.'[/url]</div></div>';

    ?>

  8. <?php

    echo mysql_error();

    $connect = mysql_connect("localhost", "user", "pw") or die ("Could not connect to database: " . mysql_error());

    mysql_select_db("db", $connect) or die ("Could not select database");

    $query = mysql_query("SELECT * FROM users WHERE username != '$username'") or die("QUERY FAILED: " . mysql_error());

    $triv = file_get_contents("users_online2.txt");

    $date = date("YmdHis");

    echo $triv;

    if (mysql_num_rows($query) <= 0) {

    $result = "INSERT INTO users (username,created) values ('$triv', '$date')";

    } else if (mysql_num_rows($query) >= 1) {

    echo "number of rows: '".mysql_num_rows($query);          //it's working up to this point

    }

    $row2 = mysql_query($result) or die("QUERY FAILED: " . mysql_error());

    $sql = mysql_query("SELECT * FROM users WHERE user_id ='$user_id' ORDER BY created");

    echo '</div><div class="title" id="top_bar_right"><a href="profile2.php?user_id='.$sql['user_id'].'" target="RSIFrame">'.$triv.'[/url]</div></div>';

    ?>

  9. also this seems to add the same usernames continously any way to make it check for existing and skip?

    <?php

    error_reporting(E_ALL);

    $connect = mysql_connect("localhost", "username", "pw") or die ("Could not connect to database: " . mysql_error()); mysql_select_db("db", $connect) or die ("Could not select database");

    $query = mysql_query("SELECT * FROM users WHERE username != '" . $username . "'") or die("QUERY FAILED: " . mysql_error());

    $triv = file_get_contents("users_online2.txt");

    $date = date("YmdHis");

    echo " ".$triv."";

    if (mysql_num_rows($query) > 0) {

    $result = "INSERT INTO users (username, created) values ('".$triv."', '".$date."')" ;

    } else {

    echo "number of rows: '".mysql_num_rows($query)."'<br>";

    exit;

    }

    $row2 = mysql_query($result) or die("QUERY FAILED: " . mysql_error());

    $sql = mysql_query("SELECT * FROM users WHERE user_id != '$user_id' ORDER BY created");

    echo '

    </div>

    <div class="title" id="top_bar_right"><a href="profile2.php?user_id=$sql" target="RSIFrame">'.$triv.'</a></div>

    </div>

    ';

     

    ?>

  10. this is my code to showing how many users are online.

    I am trying to do this with admin, regulars and guests.

    it shows only regular users as of now and doesn't remove them when they sign out. any ideas greatly appreciated.

     

    include("dbinfo.php");

     

    // Set length of session to twenty minutes

    define("SESSION_LENGTH", 20);

     

    $sConn = @mysql_connect($dbServer, $dbUser, $dbPass)

    or die("Couldnt connect to database");

     

    $dbConn = @mysql_select_db($dbName, $sConn)

    or die("Couldnt select database $dbName");

     

     

    $timeMax = time() - (60* SESSION_LENGTH);

     

    $result = mysql_query("select count(*) from usersOnline where unix_timestamp(dateAdded) >= '$timeMax' and permission = '0'");

    $usersOnline = mysql_result($result, 0, 0);

     

    $resulta = mysql_query("select count(*) from usersOnline where unix_timestamp(dateAdded) >= '$timeMax' and permission = '1'");

    $usersOnline2 = mysql_result($resulta, 0, 0);

     

    $resultb = mysql_query("select count(*) from usersOnline where unix_timestamp(dateAdded) >= '$timeMax' and username = 'Guest'");

    $usersOnline3 = mysql_result($resultb, 0, 0);

     

     

     

    $connect = mysql_connect("localhost", "login", "password") or die("Could not connect to database: " . mysql_error());

    mysql_select_db("database", $connect) or die("Could not select database");

    $result3 = mysql_query("SELECT COUNT(*) AS count FROM users WHERE permission = '0'");

    $row = mysql_fetch_array($result3);

     

    $result4 = mysql_query("SELECT COUNT(*) AS count FROM users WHERE permission = '1'");

    $row2 = mysql_fetch_array($result4);

     

    echo "" . ($usersOnline2 != 1 ? "" : "") . " $usersOnline2 Admin" . ($usersOnline2 != 1 ? "s" : "") ." of $row2[count]. ". " </br> ". ($usersOnline3 != 1 ? "" : "") . " $usersOnline3 Guest" . ($usersOnline3 != 1 ? "s" : "") ."." . " </br> " . ($usersOnline != 1 ? "" : "") . " $usersOnline User" . ($usersOnline != 1 ? "s" : "") ." of $row[count]" . ". ";

    ?>

  11. my security image does not include letters eventhough i believe its supposed to.

     

    <?php
    class passGen {
    
        var $size;
        var $password;
    
    // ------------------------------------------------
    
        function passGen($size=0){
                    $this->size = $size;
        }
    
    // ------------------------------------------------
    
            function password($return_letters=1, $return_numbers=1){
    
            $letters = 'abcdefghijklmnopqrstuvwxyz';
            $numbers = '0123456789';
    
            $passString = '';
                $option = $return_letters . $return_numbers;
    
            for($i = 0; $i < $this->size; $i++){
                    switch($option){
                    case '01':
                            $c = $numbers[mt_rand(0, 9)];
                    break;
                    case '10':
                            $c = $letters[mt_rand(0, 25)];
                    break;
                    case '11':
                        $j = mt_rand(0, 1);
                                            $c = ($j == 0 ? $letters[mt_rand(0, 25)] : $numbers[mt_rand(0, 9)]);
                    break;
                }
                $this->password[$i] = $c;
                $passString .= $c;
            }
            return md5($passString);
        }
    
    // ------------------------------------------------
    
            function images($path, $extension, $preImage='', $width='', $height='', $css=''){
            $images='';
                for($i = 0; $i < $this->size; $i++){
                    $images .= '<img';
                if($css != ''){ $images .= ' class="'. $css .'"'; }
                $images .= ' src="'. $path .'/'. $preImage . $this->password[$i] .'.'. $extension .'" width="'. $width .'"  height="'. $height .'" alt="" border=0>';
            }
            return $images;
        }
    
    // ------------------------------------------------
    
            function verify($input, $hash){
                    if(md5($input) == $hash){ return true ; }
            else { return false; }
        }
    
    // ------------------------------------------------
    
    }
    
    ?>
    

     

    2nd part

    <?include('class.passgen.php');
    $passGen = new passGen(5);
    
        $validate = 0;
    
        if(isset($_POST['submit'])){
        	$hash = $_POST['hash'];
            $pass = $_POST['pass'];
    
            if($passGen->verify($pass, $hash)){
            	$validate = 1;
                echo 'Validation OK';
            }
            else {
            	echo 'Validation not OK';
            }
            echo '<br>';
        }
    
        if($validate == 0){
        $hash = $passGen->password(0, 1);
    
        echo '<br>';
        echo $passGen->images('font', 'gif', 'f_', '16', '20');
        echo '<br><br>';
        echo'<p><label for="securitycode">Anti-Spam Security: (Required)</label><span style="color:#FF0000;">*</span><br>';
    echo '<small>Type The Combination Shown In The Picture.</small><br>';
                        echo '<input type="hidden" value="'. $hash .'" name="hash">';
        echo '<input type="text" value="'. $pass .'" name="pass" size="5" maxlength="5">';
            echo '<br><br>';
        	    
        }
    
    ?>
    
    

  12. it was deleted after all but doesnt echo out the line above the table still I think.

    here is the read out

     

    ../banip/banip.txt exists and is readable and writable 
    ../banip/issues_deleted.txt exists and is readable and writable 
    Opening ../banip/banip.txt
    File contents: 
    
    Array
    (
        ** REMOVED **
    )
    
    
    Opening ../banip/issues_deleted.txt
    File contents: 
    
    Array
    (
    )
    
    
    Entered delete routine
    
    
    Array
    (
        [action] => delete
        [todelete] => Array
            (
                [0] => xx.xxx.xxx.x, 07.09.2007  23:01:40, Opera/9.0 (Windows NT 5.1; U; en), NA
            )
    
    )
    
    
    Opening ../banip/issues_deleted.txt
    
    x.xxx.xxx.x, 07.09.2007 23:01:40, Opera/9.0 (Windows NT 5.1; U; en), NA exists in ../banip/banip.txt
    Getting key from $ban_ips
    key retrived - Key:0
    Deleted: x.xxx.xxx.x, 07.09.2007 23:01:40, Opera/9.0 (Windows NT 5.1; U; en), NA and has been written to ../banip/issues_deleted.txt
    
    Closed ../banip/issues_deleted.txt
    
    Opening ../banip/banip.txt
    
    ** REMOVED **
    
    Closing ../banip/banip.txt[code]
    
      
    

    [/code]

  13. ok here we go

    also this code doesn't seem to echo out the line to the user that it's being deleted my original code did.

     

    not sure why that is but may be a sign hinting its not getting somehing.

     

    ../banip/banip.txt exists and is readable and writable 
    ../banip/issues_deleted.txt exists and is readable and writable 
    Opening ../banip/banip.txt
    File contents: 
    
    Array
    (
        ** REMOVED **
    )
    
    
    Opening ../banip/issues_deleted.txt
    File contents: 
    
    Array
    (
    )
    
    
    Entered delete routine
    
    
    Array
    (
        [action] => delete
        [todelete] => Array
            (
                [0] => 66.162.135.6, 07.09.2007  23:01:40, Opera/9.0 (Windows NT 5.1; U; en), NA
    
            )
    
    )
    
    
    Opening ../banip/issues_deleted.txt
    
    Closed ../banip/issues_deleted.txt
    
    Opening ../banip/banip.txt
    
    ** REMOVED **
    
    Closing ../banip/banip.txt

     

     

  14. example data for banip.txt ... its in another folder the banip.txt would it matter?

    i changed these values back of course in my file in your code.

     

    65.125.151.21, 09.09.2007  01:41:18, Opera/9.0 (Windows NT 5.1; U; en), host-65-125-151-21.lextron

    ip                        date    time          browser                                      host

     

     

×
×
  • 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.