Jump to content

[SOLVED] md5 argument...


eaglelegend

Recommended Posts

Hey, I am trying to get my files a little bit safer, and less security holes, however, md5 dont like it, look...

Warning: md5() expects parameter 1 to be string, array given in /misc/39/000/171/334/2/user/web/eaglelegend.com/register.php on line 6

Warning: md5() expects parameter 1 to be string, array given in /misc/39/000/171/334/2/user/web/eaglelegend.com/register.php on line 7

 

here is register, however, for your conveniance, I have not inclided the actual form where you "sighn up", just the code.

 

<?php
include("header.php");
?>
<?php
$username = strip_tags(stripslashes($_POST));
$password = strip_tags(stripslashes(md5($_POST)));
$password_confirm = strip_tags(stripslashes(md5($_POST)));
$email = strip_tags(stripslashes($_POST));
$sql = mysql_query("UPDATE members SET ip ='{$_SERVER['REMOTE_ADDR']}' WHERE username='$username' LIMIT 1");

if($username && $password && $password_confirm && $email) {

Function RemoveXSS($val) {

   $val = preg_replace('/([\x00-\x08][\x0b-\x0c][\x0e-\x20])/', '', $val);
   
   $search = 'abcdefghijklmnopqrstuvwxyz';
   $search .= 'ABCDEFGHIJKLMNOPQRSTUVWXYZ';
   $search .= '1234567890!@#$%^&*()';
   $search .= '~`";:?+/={}[]-_|\'\\';
   for ($i = 0; $i < strlen($search); $i++) {

      $val = preg_replace('/(&#[xX]0{0,8}'.dechex(ord($search[$i])).';?)/i', $search[$i], $val); 

      $val = preg_replace('/(&#0{0,8}'.ord($search[$i]).';?)/', $search[$i], $val); 
   }
   
   $ra1 = Array('javascript', 'vbscript', 'expression', 'applet', 'meta', 'xml', 'blink', 'link', 'style', 'script', 'embed', 'object', 'iframe', 'frame', 'frameset', 'ilayer', 'layer', 'bgsound', 'title', 'base');
   $ra2 = Array('onabort', 'onactivate', 'onafterprint', 'onafterupdate', 'onbeforeactivate', 'onbeforecopy', 'onbeforecut', 'onbeforedeactivate', 'onbeforeeditfocus', 'onbeforepaste', 'onbeforeprint', 'onbeforeunload', 'onbeforeupdate', 'onblur', 'onbounce', 'oncellchange', 'onchange', 'onclick', 'oncontextmenu', 'oncontrolselect', 'oncopy', 'oncut', 'ondataavailable', 'ondatasetchanged', 'ondatasetcomplete', 'ondblclick', 'ondeactivate', 'ondrag', 'ondragend', 'ondragenter', 'ondragleave', 'ondragover', 'ondragstart', 'ondrop', 'onerror', 'onerrorupdate', 'onfilterchange', 'onfinish', 'onfocus', 'onfocusin', 'onfocusout', 'onhelp', 'onkeydown', 'onkeypress', 'onkeyup', 'onlayoutcomplete', 'onload', 'onlosecapture', 'onmousedown', 'onmouseenter', 'onmouseleave', 'onmousemove', 'onmouseout', 'onmouseover', 'onmouseup', 'onmousewheel', 'onmove', 'onmoveend', 'onmovestart', 'onpaste', 'onpropertychange', 'onreadystatechange', 'onreset', 'onresize', 'onresizeend', 'onresizestart', 'onrowenter', 'onrowexit', 'onrowsdelete', 'onrowsinserted', 'onscroll', 'onselect', 'onselectionchange', 'onselectstart', 'onstart', 'onstop', 'onsubmit', 'onunload');
   $ra = array_merge($ra1, $ra2);
   
   $found = true; 
   while ($found == true) {
      $val_before = $val;
      for ($i = 0; $i < sizeof($ra); $i++) {
         $pattern = '/';
         for ($j = 0; $j < strlen($ra[$i]); $j++) {
            if ($j > 0) {
               $pattern .= '(';
               $pattern .= '(&#[xX]0{0,8}([9ab])';
               $pattern .= '|';
               $pattern .= '|(&#0{0,8}([9|10|13])';
               $pattern .= ')*';
            }
            $pattern .= $ra[$i][$j];
         }
         $pattern .= '/i';
         $replacement = substr($ra[$i], 0, 2).'<x>'.substr($ra[$i], 2); 
         $val = preg_replace($pattern, $replacement, $val);
         if ($val_before == $val) {
            
            $found = false;
         }
      }
   }
   return $val;
}

$siteurl = preg_replace( "/[^a-zA-Z0-9s]/", "", $siteurl );

$check_user = mysql_num_rows(mysql_query("SELECT * FROM `members` WHERE `username`=\"$username\""));
$check_site = mysql_num_rows(mysql_query("SELECT * FROM `members` WHERE `url`=\"$siteurl\""));

if($check_user == 0) {

 	if($password == $password_confirm) {
 	 	$newpass = md5($password);
 	 	$date = date("m/d/y");

		$sql = mysql_query("SELECT * FROM `sites` WHERE `url`='$Z'");
		while($r = mysql_fetch_array($sql)) {
		 	$money = $r["money"];
		 	$points = $r["points"];
		}

		$insert = mysql_query("INSERT INTO `members` (`admin`, `date`, `username`, `password`, `email`, `points`, `money`) VALUES('0', '$date', \"$username\", \"$newpass\", \"$email\", '$points', '$money')"); 
		$sql = mysql_query("UPDATE members SET ip ='{$_SERVER['REMOTE_ADDR']}' WHERE username='$username' LIMIT 1");
		if($insert) {


			print "<h2>Congratulations!</h2><p>
			You are now a registered member of this site!<p>
			Username: $username<br>
			Password: $password<p>
			You can login using the form to the right!";
		}
		else {
		 	print mysql_error();
		}
	}
	else {
	 	print "<p>Passwords do not match!</p>";
	}
}
else {
 	if($check_user > 0) {
 		print "<p>That username already exists!</p>"; 
 	}
}
}
else {
?>

Link to comment
Share on other sites

The error tells you the problem.  $_POST is an array of all your posted variables.  md5 expects a string.  You need to break it down to $_POST['blah'] etc.. one for each of your posted vars

 

EG:

$username = strip_tags(stripslashes($_POST['username'])); //assuming 'username' is the name of your form var
$password = strip_tags(stripslashes(md5($_POST['password']))); // ditto on 'password'

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.