Banner

Sponsor

Login


Welcome Back!
Guest
Guest

Register

Lost your password?

103 users online



Problem with headers.

Problem with headers.

Currently viewing this thread: 1 (0 members and 1 guests)


Page 1 out of 2
trunks

trunks

asdf
Status: Offline!

Problem with headers.

I'm making a shoutbox script, that I want people to use. The problem is that I use cookies as one of the anti-spam features.. and of course I'm getting headers already sent when I include the script in a website.

I tried ob_start and ob_end_flush at the start and end of the shoutbox script, but that doesn't work, I would have to put it in the website's layout. But I don't want people to have to do it themselves, it's a pain in the *** to tell people to do all this just to make your script to work.. They never understand :P

So, any suggestions??

trunks

trunks

asdf
Status: Offline!

By the way, I don't want them to HAVE to use an iFrame.. I want them to have the choice between an iFrame (where there's no problems with headers) and a simple include();

Phil

Phil

with Mr. Jones
Status: Offline!

you could just log the last time ipX made a shout and compare against that. no cookies.

___________________

http://www.philbrodeur.com - Expert PHP Development and Tutorials

trunks

trunks

asdf
Status: Offline!

Wow, thanks for the idea. that was some sport!

here's how I did my ip checker..

PHP:

<?php

    
function read_log() {
        if (!
file_exists("iplog.dat")) { 
            
touch("iplog.dat");
            
chmod("iplog.dat",0666);
            
$file fopen("iplog.dat""w");
            
fwrite($fileserialize(array(array('',''),array('',''),array('',''),array('',''))));
            
fclose($file);
        }
        
$lines file("iplog.dat");
        return 
unserialize($lines[0]);
    }
    function 
write_log() {
        
$userIp $_SERVER["REMOTE_ADDR"];
        
$newArray = array($userIp,time());
        
$array read_log();
        
$array[3] = $array[2];
        
$array[2] = $array[1];
        
$array[1] = $array[0];
        
$array[0] = $newArray;
        
$newIpList serialize($array);
        
$file fopen("iplog.dat""w");
        
fwrite($file$newIpList);
        
fclose($file);
    }
    function 
verif_ip() {
        
$userIp $_SERVER["REMOTE_ADDR"];
        
$array read_log();
        foreach (
$array as $thearray) {
            if (
in_array($userIp,$thearray)) {
                if ((
time() - $thearray[1]) < 30) {
                    echo 
"spam protection.. wait 30 seconds";
                    return 
false;
                }
                else { return 
true; }
            }
            else { return 
true; }
        }
    }
?>

(maybe someone, someday could get help from this)

Last edited by trunks, August 8th, 2003 12:35 AM (Edited 1 times)

CDude

CDude

nothing
Status: Offline!

that's quite long and complex. Mine is a simple array with the keys of the array being the user's IP and the values being the last post time.

like this

$array[ $_SERVER['REMOTE_ADDR'] ] = time ( );

Everytime someone posts, i check if $array[ $_SERVER['REMOTE_ADDR'] ] exists. If it does, i subtract the value from time ( ) and see if it's smaller than $timeout. If it is, then display spamming message. If it doesn't exists or the difference between the time is greater than $timeout. I reset the time. You can do use exactly the same format for users online scripts. $users_online = count ( $array ); Just remember to loop through the array and remove "expired" users before you count ; ).

___________________

http://celerondude.com

Last edited by CDude, August 8th, 2003 02:36 AM (Edited 1 times)

trunks

trunks

asdf
Status: Offline!

I thought that adding something to an array was temporary..
Meaning the script will not remember the array if someone else executes the script it would only have his ip and lose the guy before's.. no? that's why I write it in a file.. maybe you could explain more? heh

Last edited by trunks, August 8th, 2003 04:34 PM (Edited 1 times)

Phil

Phil

with Mr. Jones
Status: Offline!

serialize() array and store that in the textfile. Then just load textfile, unserialize contents and you have array

___________________

http://www.philbrodeur.com - Expert PHP Development and Tutorials

trunks

trunks

asdf
Status: Offline!

yeah, so that's basically what I'm doing..

Phil

Phil

with Mr. Jones
Status: Offline!

but you COULD do it in maybe 6 lines...

___________________

http://www.philbrodeur.com - Expert PHP Development and Tutorials

trunks

trunks

asdf
Status: Offline!

I don't think I could do it in 6 lines unless I'd want the array to become huge, which I don't.. I only wanna keep it to a few ips logged. What takes space(characters) is the part to cycle the ips..

I do agree that my code is not the smallest code you could have to do this though..

Page 1 out of 2
Quick Jump:

Main Navigation


Site & Graphic Design by Aeon Tan
Developed by Jeremie Pelletier & Scott Roach


NeverAPI generated this page in 0.01 seconds.