TalkPHP
 
 
Account Login
Latest Articles
» The basic usage of PHPTAL, a XML/XHTML template library for PHP
» Vulnerable methods and the areas they are commonly trusted in.
» Simple way to protect a form from bot
» The Basics On: How Session Stealing Works
» How to keep your forms from double posting data
IRC Channel
IRC Speech Bubble Join the friendly bunch on IRC...
(#TalkPHP on Freenode)

...Also available via a web interface.

See this thread for information on the TalkPHP Free Hugs Initiative™. Subject to availability.
Associates
Associates
CSS Tutorials
Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old 11-21-2008, 06:33 PM   #1 (permalink)
Super Moderator
Inquisitive 
 
codefreek's Avatar
 
Join Date: Sep 2007
Location: Near you.
Posts: 791
Thanks: 241
codefreek is on a distinguished road
Box Might lead us to something good

hello i was bored so i started to make a script
but i just wrote some jibrish don't know if it will work
or so i just thought i share it and maybe some one will
see something i don't see and develop it to a working stage :P

PHP Code:
function spamblocker($bWork,$makeSelection,$check) {
session_start();
$_SESSION['makeSelection'] = $makeSelection;
$makeSelection rand("1234567890qwertyuiopasdfghjklzxcvbnm");
if (
$_POST == true) {
//do
$bWork strip_tags($_POST);
//and
$check ".$makeSelection.";
}
return 
$check;

if(
$check == true) {
print 
"ok";
} else {
print 
"error";



..Enjoy..
no flame is needed i have never said it was a good
script or so, this is how i learn by doing jibrish code :P

thoughts and reedit of the code please share it here
hehe just plain fun come on!

you never know maybe someone posts a working code
with a great use :P xD

Last edited by codefreek : 11-22-2008 at 06:06 AM.
codefreek is offline  
Reply With Quote
Old 11-21-2008, 07:09 PM   #2 (permalink)
The Contributor
 
Join Date: Mar 2008
Posts: 62
Thanks: 2
Seraskier is on a distinguished road
Default

I'm not too sure on what this does, it makes no sense, but (not trying to flame) there are errors and unneeded sections of code.

PHP Code:
//lets put this up here so that everytime we use the spamblocker() function, the script won't keep "opening up" sessions
session_start();

function 
spamblocker()
{
    
$makeSelection=rand(1,9); //this needs to be called first before you try to make it a session
    
$_SESSION['selection']=$makeSelection//for use anywhere? no need when its in a function

    
if($_POST['VARIABLE_NEEDS_TO_BE_HERE']==true)
    {
        
$bWork=strip_tags($_POST['VARIABLE_HERE']);
    }

    if(
$makeSelection==true)
    {
        return 
true;
        
//insert code here
    
}
    else
    {
        return 
false;
        echo 
"dont spam!";
    }

again, I have no idea how this is subpossed to work by stopping spam, you will need more code. I just re-wrote it (I did not check to make sure it worked at all) to where I think you wanted it.

Jordan
Send a message via MSN to Seraskier
Seraskier is offline  
Reply With Quote
The Following User Says Thank You to Seraskier For This Useful Post:
codefreek (11-21-2008)
Old 11-21-2008, 07:20 PM   #3 (permalink)
Super Moderator
Inquisitive 
 
codefreek's Avatar
 
Join Date: Sep 2007
Location: Near you.
Posts: 791
Thanks: 241
codefreek is on a distinguished road
Default

ty, well we will see what we end up with later on :P
codefreek is offline  
Reply With Quote
Old 11-21-2008, 11:55 PM   #4 (permalink)
La Vida es Sueño
Advanced Programmer Top Contributor 
 
Wildhoney's Avatar
 
Join Date: Sep 2007
Location: Oldham
Posts: 2,280
Thanks: 90
Wildhoney is on a distinguished road
Default

Talking of unneeded code.

php Code:
return false;
echo "dont spam!";

Hehe. You'll never see that message!
__________________
The man who comes back through the Door in the Wall will never be quite the same as the man who went out.
Send a message via AIM to Wildhoney Send a message via MSN to Wildhoney Send a message via Yahoo to Wildhoney
Wildhoney is offline  
Reply With Quote
Old 11-22-2008, 01:06 AM   #5 (permalink)
The Contributor
 
Join Date: Mar 2008
Posts: 62
Thanks: 2
Seraskier is on a distinguished road
Default

Quote:
Originally Posted by Wildhoney View Post
Talking of unneeded code.

php Code:
return false;
echo "dont spam!";

Hehe. You'll never see that message!
heh

how about

PHP Code:
return false
Send a message via MSN to Seraskier
Seraskier is offline  
Reply With Quote
Old 11-22-2008, 02:50 AM   #6 (permalink)
The Addict
 
zxt3st's Avatar
 
Join Date: Apr 2008
Posts: 200
Thanks: 18
zxt3st is on a distinguished road
Default

PHP Code:
session_start(); 

function 
spamblocker() 

    
$makeSelection=rand(1,9); 
    
$_SESSION['selection']=$makeSelection

    if(
$_POST['VARIABLE_NEEDS_TO_BE_HERE']==true
    { 
        
$bWork=strip_tags($_POST['VARIABLE_HERE']); 
    } 

    if(
$makeSelection==true
    { 
        return 
true
       
#do something
    

    else 
    { 
        return 
false;  
      
#nothing to do here, coz it wont be executed
    


__________________
Serenity Project - 5% (Layout) - Ongoing....
Project Serenity Free Life!....
zxt3st is offline  
Reply With Quote
Old 11-22-2008, 03:54 AM   #7 (permalink)
Super Moderator
Inquisitive 
 
codefreek's Avatar
 
Join Date: Sep 2007
Location: Near you.
Posts: 791
Thanks: 241
codefreek is on a distinguished road
Default

see already we are making some changes :)
keep on going :D
codefreek is offline  
Reply With Quote
Old 11-22-2008, 05:28 AM   #8 (permalink)
The Frequenter
Zend Certified 
 
Join Date: Sep 2007
Location: Denmark
Posts: 352
Thanks: 8
Kalle is on a distinguished road
Default

You're using rand incorrectly:
PHP Code:
$makeSelection rand("1234567890qwertyuiopasdfghjklzxcvbnm"); 
Use something like:
PHP Code:
static $makeSelection$makeSelection_len;

if(!
$makeSelection)
{
    
$makeSelection array_merge(range(09), range('a''z'));
    
$makeSelection_len sizeof($makeSelection);
}

/* ... */

$makeSelection rand(0$makeSelection_len 1);

/* ... */ 
ps. Remember to seed rand!

Also I don't see the point of calling session_start() inside the function?

:)
__________________
Send a message via MSN to Kalle Send a message via Skype™ to Kalle
Kalle is offline  
Reply With Quote
Old 11-22-2008, 06:01 AM   #9 (permalink)
Super Moderator
Inquisitive 
 
codefreek's Avatar
 
Join Date: Sep 2007
Location: Near you.
Posts: 791
Thanks: 241
codefreek is on a distinguished road
Box

Thank you kalle for bringing us closer to making a good script :D
and the point of session_start() i know that yes not suppose to be inside there i just put it there so we have everything in same place :P sorry if that has confused some of you :)

//let's keep this ball up in the air people you never know what we might do :)


PHP Code:
/* so i thought we might make a ip log as well for the spamblocker */
function iplog() 

$useragent $_SERVER['HTTP_USER_AGENT'];
$httpreferrer $_SERVER['HTTP_REFERER'];
$HttpClientIP $_SERVER['HTTP_CLIENT_IP'];
$RemAddr $_SERVER['REMOTE_ADDR'];
$CacheControl $_SERVER['HTTP_CACHE_CONTROL'];
$XForward $_SERVER['HTTP_X_FORWARDED_FOR'];
$querystring $_SERVER['QUERY_STRING'];

$filename 'log.txt';
$somecontent "User Agent: $useragent\n HTTP Referrer: $httpreferrer\n HTTP Client IP: $HttpClientIP\n Remote Address: $RemAddr\n Cache Control: $CacheControl\n X Forward: $XForward\n Query String: $querystring\n";

if (
is_writable($filename)) {

if (!
$handle fopen($filename'a')) {
echo 
"Cannot open file ($filename)";
exit;
}

if (
fwrite($handle$somecontent) === FALSE) {
echo 
"Cannot write to file ($filename)";
exit;
}

fclose($handle);

} else {
echo 
"The file $filename is not writable";
}
return 
$somecontent;

keep it up guys
:D

Last edited by codefreek : 11-22-2008 at 06:22 AM.
codefreek is offline  
Reply With Quote
Old 11-22-2008, 06:16 AM   #10 (permalink)
The Frequenter
Zend Certified 
 
Join Date: Sep 2007
Location: Denmark
Posts: 352
Thanks: 8
Kalle is on a distinguished road
Default

Hmm your parameters on that iplog function doesn't really make sense as you're overriding them just below.

Also you may need to know that some of the _SERVER values such as HTTP_CACHE_CONTROL, HTTP_CLIENT_IP and HTTP_X_FORWARDED_FOR. Even HTTP_USER_AGENT may emit an E_NOTICE because its not required and requests sent to the script with eg. curl or custom made programs may not send get User-Agent header.

Also the _GET['cookie'], unless its script specific and you want to get all the cookies then you should use the _COOKIE magic array ofcourse :)
__________________
Send a message via MSN to Kalle Send a message via Skype™ to Kalle
Kalle is offline  
Reply With Quote
The Following User Says Thank You to Kalle For This Useful Post:
codefreek (11-22-2008)
Old 11-22-2008, 06:21 AM   #11 (permalink)
Super Moderator
Inquisitive 
 
codefreek's Avatar
 
Join Date: Sep 2007
Location: Near you.
Posts: 791
Thanks: 241
codefreek is on a distinguished road
Default

you are just full of knowledge :)
thanks mate!
codefreek is offline  
Reply With Quote
Old 11-26-2008, 05:17 AM   #12 (permalink)
The Addict
 
zxt3st's Avatar
 
Join Date: Apr 2008
Posts: 200
Thanks: 18
zxt3st is on a distinguished road
Default

hmm, nice changes :) lets keep this going, we might get something interesting out of it :)
__________________
Serenity Project - 5% (Layout) - Ongoing....
Project Serenity Free Life!....
zxt3st is offline  
Reply With Quote
Reply



Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


All times are GMT. The time now is 04:27 PM.

 
     

Powered by vBulletin® Version 3.6.8
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.1.0
Inactive Reminders By Icora Web Design