1
simeon
need help make scipt secure
  • 2005/6/11 10:08

  • simeon

  • Not too shy to talk

  • Posts: 104

  • Since: 2003/12/18


hi there

i´ve got to do an extra register form to combine it with an ordering process.
now i got that script working fine (for my simple needs) but without any security machanisms.I know it should be just a couple of c&p from register.php but i really cant get it to work like this
i know i´m not writing the scipt like it should be in XOOPS but i´m just a beginner and was really glad i got it to work like it is.
it would be very nice if a friendly man can get some time to revisit my script and make it XOOPS valid and secure.
or if this is too much for just help tell me how much it will cost.

thx in advanced for every help.

HERE you can get my primitive first step

2
Mithrandir
Re: need help make scipt secure

// fetch form informations
$paket $HTTP_POST_VARS["paket"];

Use $_POST/$_GET/$_REQUEST instead of long arrays like $HTTP_XXX_VARS

$sql "INSERT INTO orders (status, paket, vname, nname, street, city, email, domain, domsel, domain2, domsel2, domain3, domsel3)
        VALUES ('
$status','$paket','$vname','$nname','$street', '$city','$email','$domain','$domsel','$domain2','$domsel2','$domain3','$domsel3')";


before using a variable in an SQL statement, you should sanitize it.

Integers are sanitized with intval:
$var intval($_POST['var']);


Strings are sanitized with the text sanitizer:
$myts =& MyTextSanitizer::getInstance();
$sanitized_var $myts->addSlashes($_POST['var']);


Also, you should use $xoopsDB->prefix('tablename') instead of hardcoding the table name directly in SQL (others may have different XOOPS prefixes than you)

function writeuser(){
     global 
$pass$uname$email$name$user_regdate$user_from$umode;
     
$sql2 "INSERT INTO portal_users (name, uname, email, user_regdate, user_from, umode, pass)
             VALUES ('
$name','$uname','$email','$user_regdate','$user_from','$umode','$pass')";
     
$result2 mysql_query($sql2);
}
writeuser();


This is better:
$member_handler =& xoops_gethandler('member');
$user =& $member_handler->create();
$user->setVar('name'$name); 
$user->setVar('uname'$_POST['uname']); //Sanitation is done in the class, so no need to addslashes here
$user->setVar('email'$_POST['email']);
$user->setVar('user_regdate'time());
$user->setVar('user_from'$user_from);
$user->setVar('umode'"thread");
$user->setVar('pass'$pass);
if (
$member_handler->insert($user)) {
    
//user was inserted correctly
}
else {
    
//user was not inserted correctly
    //$user->getHtmlErrors() will return an HTML string with error messages
}


Hope this helps

3
simeon
Re: need help make scipt secure
  • 2005/6/15 5:18

  • simeon

  • Not too shy to talk

  • Posts: 104

  • Since: 2003/12/18


thx mith

i´ve reviewed the script and take all your changes in.
and i´ve added a view things so all the check mechanisms should be includet.
if you like, i would be glad if you take a look at is again and tell me if aomethings wrong anymore.

thank for your help
keep up the good work

NEW FILE

4
Mithrandir
Re: need help make scipt secure

$stop userCheck($uname$email$pass$vpass);

$uname, $pass and $vpass are not set.

Also, you use addSlashes in the top of the file and in the userCheck function. Only use it once or you will get additional slashes added to the string.

Lastly, I dislike languaged strings in the code. Use language constants instead.

Login

Who's Online

203 user(s) are online (127 user(s) are browsing Support Forums)


Members: 0


Guests: 203


more...

Donat-O-Meter

Stats
Goal: $100.00
Due Date: May 31
Gross Amount: $0.00
Net Balance: $0.00
Left to go: $100.00
Make donations with PayPal!

Latest GitHub Commits