Ask a Question related to PHP Development, Design and Development.
-
Peter Wilson #1
Creating Function Newbie question
Hi
I have written a small bit of code for my web site that basically is
anti hack code.
$checking = ($HTTP_GET_VARS['UniqueNo']);
if (ereg ("[^0-9]+", $checking) )
{echo "Please Stop Trying to Hack This Site";
exit;}
I would like to change this into a function where I only have to enter
the Http variable. into the functions brackets. How do I do it? Is it
possible?
many thanks
Peter
Motto "A smile aday keeps the blues away"
[url]http://www.sci-comm.clara.net/[/url]
Peter Wilson Guest
-
Creating datasource with mysql- newbie question
Hi all, I have been using a program to connect to mysql database on my shared hosting. I am now setting up a site in dreamweaver and a datasource... -
Creating directories... : Newbie Question
Hey all I have this is a script: <?php $city = $_GET; $state = $_GET; if($file_name !="") { -
Newbie Question: Can PHP communicate with a C function/program
I have several library functions that have been created in 'C' which I would prefer not to have to re-write all of them to PHP. Is there a way to... -
newbie question: function overloading
I need to define a method that performs differently when operated on objects of different type (overloading). Currently I use various if's to check... -
newbie question: creating a new record in a related file
somaBoyMX wrote: You can do it with a Portal in the Contacts file. First, the relationship from the Contacts file as Master to the related... -
Shane Lahey #2
Re: Creating Function Newbie question
On Sun, 6 Jun 2004 21:07:54 +0100, Peter Wilson <pwilson@sci-comm.clara.net> wrote:
// usage: check_if_hacking([variable]);>Hi
>
>I have written a small bit of code for my web site that basically is
>anti hack code.
>
>$checking = ($HTTP_GET_VARS['UniqueNo']);
>if (ereg ("[^0-9]+", $checking) )
>{echo "Please Stop Trying to Hack This Site";
>exit;}
>
>I would like to change this into a function where I only have to enter
>the Http variable. into the functions brackets. How do I do it? Is it
>possible?
>
>many thanks
>
>Peter
>Motto "A smile aday keeps the blues away"
>
>[url]http://www.sci-comm.clara.net/[/url]
function check_if_hacking($variable = false)
{
global $_GET;
if ($variable === false)
$variable = $_GET['UniqueNo'];
if (ereg("[^0-9]+", $variable))
{
die("Stop trying to hack this site");
}
}
// to use the function use either of the following methods
check_if_hacking($_GET['UniqueNo']);
or:
check_if_hacking(); // will use $_GET['UniqueNo']; by default if no variable is passed.
Shane Lahey Guest
-
Colin McKinnon #3
Re: Creating Function Newbie question
Shane Lahey spilled the following:
<snip>> On Sun, 6 Jun 2004 21:07:54 +0100, Peter Wilson
> <pwilson@sci-comm.clara.net> wrote:
>> // usage: check_if_hacking([variable]);>>
>>$checking = ($HTTP_GET_VARS['UniqueNo']);
>>if (ereg ("[^0-9]+", $checking) )
>>{echo "Please Stop Trying to Hack This Site";
>>exit;}
>>
>>I would like to change this into a function where I only have to enter
>>the Http variable. into the functions brackets. How do I do it? Is it
>>possible?
>>
> function check_if_hacking($variable = false)
> {Or for the really techno-funky version, use create_function to generate a> }
>
lambda function.
But I can't help noticing that checking the GET var has at least one digit
in it is hardly going to keep out the most determined of hackers. Suggest
you think of a better algorithm, since 'UniqueNo' will probably be
appearing in your pages, it won't take much effort to find a valid match.
C.
Colin McKinnon Guest
-
Peter Wilson #4
Re: Creating Function Newbie question
>But I can't help noticing that checking the GET var has at least one digit
I idea was to stop the people from being able to break into the page to>in it is hardly going to keep out the most determined of hackers. Suggest
>you think of a better algorithm, since 'UniqueNo' will probably be
>appearing in your pages, it won't take much effort to find a valid match.
>
>C.
do some harm to the DB. I was told that if you can make the page drop by
using contort characters they can then hack eh BD I have no idea how
true this is but the little bit of code stopped it from happening any
way. Also a good point to start learning how to make functions simple
code.
Many thanks for the help
Peter
Motto "A smile aday keeps the blues away"
[url]http://www.sci-comm.clara.net/[/url]
Peter Wilson Guest



Reply With Quote

