TalkPHP

TalkPHP (http://www.talkphp.com/forums.php)
-   Absolute Beginners (http://www.talkphp.com/absolute-beginners/)
-   -   Hum well u need to see it :P (http://www.talkphp.com/absolute-beginners/3636-hum-well-u-need-see-p.html)

codefreek 11-21-2008 06:33 PM

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

Seraskier 11-21-2008 07:09 PM

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

codefreek 11-21-2008 07:20 PM

ty, well we will see what we end up with later on :P

Wildhoney 11-21-2008 11:55 PM

Talking of unneeded code.

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

Hehe. You'll never see that message!

Seraskier 11-22-2008 01:06 AM

Quote:

Originally Posted by Wildhoney (Post 19799)
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


zxt3st 11-22-2008 02:50 AM

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
    




codefreek 11-22-2008 03:54 AM

see already we are making some changes :)
keep on going :D

Kalle 11-22-2008 05:28 AM

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?

:)

codefreek 11-22-2008 06:01 AM

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

Kalle 11-22-2008 06:16 AM

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 :)

codefreek 11-22-2008 06:21 AM

you are just full of knowledge :)
thanks mate!

zxt3st 11-26-2008 05:17 AM

hmm, nice changes :) lets keep this going, we might get something interesting out of it :)


All times are GMT. The time now is 08:47 AM.

Powered by vBulletin® Version 3.6.8
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.1.0