
Originally Posted by
wesman2232
I don't have access to the VPN that the script is hosted on. I just have the exact same files on my localhost, then send updates to the hoster. Which is why im using the ini_set function.
I'm just confused on the part where it says "t@to.com", "f@from.com"
'From', ok, but wouldnt the 'to' need a email grabbed from the DB and then set there so any of the users could reset their pass?
(This is part of the Forgot Password function in the web)
Is the mail server required to be on that VPN or can it still be defined with the ini_set function?
I could just write a script for you? Wouldnt be hard, lemme wip something up. Really quick. I don't have access to the a db so i cant really right the queries off memory so someone else your you will have to do it.
Edit:
Like I said I didnt write any queries for this, so i left them blank you can edit the queries, i explained what each one needs todo and an example of it might be. Like I said I dont have access to a db so im unsure. This may require more or less queries than I put but this should be correct. I'm sure someone here will correct me if im wrong.
Note: I wrote this as a function so you can just use the example below it.
PHP Code:
<?php
//maybe not the best anti-sql but ya, anyone feel free to make it better.
function anti_injection($str) {
$str = preg_replace(sql_regcase("/(from|select|insert|delete|where|drop table|show tables|#|\*|--|\\\\)/"),"",$sql);
$str = trim($sql);
$str = strip_tags($sql);
$str = addslashes($sql);
return $str;
}
function sendEmail($to, $from, $subject, $message)
{
$headers = "MIME-Version: 1.0rn";
$headers .= "Content-type: text/html; charset=iso-8859-1rn";
$headers .= "From: ".$from."\r\n";
if (mail($to, $subject, $message, $headers)){
return true;
} else {
return false;
}
}
function passwordReset($email){
if($email != NULL)
{
//query to do something like select email from user(table) where email = $email
$query_ch_email = mysql_query("EDIT ME!!!!!!!!!!") or die(mysql_error());
if (mysql_num_rows($query_ch_email) > 0)
{
//query to get userid ex: select * from user(table) where email = $email
$query_get_userid = mysql_query("EDIT ME!!!!!!!!!!") or die(mysql_error());
$user_array = mssql_fetch_assoc($query_get_userid);
$userid = $user_array['userid']; //not sure if this is correct
//I dont think passwords are stored in the same table as the emails, pretty sure its login table so ex:
//select * from login(table) where userid = $userid
$query_get_password = mysql_query("EDIT ME!!!!!!!!!!") or die(mysql_error());
$login_array = mssql_fetch_assoc($query_get_password);
$password = $login_array['Password']; //not sure if correct
//Subject EDIT THIS
$subject = "GunZServer - Password Reset";
//To / From
/////////////////////////!! EDIT ME ////////////////////////////////////////
$from = "no-reply@yourwebsite.com";
$to = $email;
//Html Message EDIT THIS
$message = "<html>
<body>
Your <b>GunZServer</b> password is: <b>".$pass."</b><br />
- GunZServer
</body>
</html>";
if(sendEmail($to, $email, $subject, $message))
{
$msg = "Password Sent, You should be Recieving it Soon!";
return $msg;
} else {
$msg = "Unable to Send Password at this Time. Please inform the administrator if this continues.";
return $msg;
}
} else {
$msg = "Email Does Not Exists";
return $msg;
}
} else {
return;
}
}
?>
Heres a quick script using the functions, with the html form. You can just include the stuff above with one of your function files, or something and below integrate it to your website how ever you please, I would but I have no idea what website files your using.
PHP Code:
<?php
if(isset($_GET['do']))
{
if($_GET['do'] == "sendEmail")
{
if($_POST['email'] != NULL)
{
$email = $_POST['email'];
if(filter_var($email, FILTER_VALIDATE_EMAIL))
{
$email = anti_injection($email);
$msg = passwordReset($email);
echo '<script type="text/javascript">alert("' . $msg . '"); </script>';
} else {
echo '<script type="text/javascript">alert("Email is not Valid."); </script>';
}
} else {
echo '<script type="text/javascript">alert("Email Field is Blank"); </script>';
}
}
}
?>
<B>Password Reset</b><br />
<form name="input" action="<?php echo $_SERVER['PHP_SELF']; ?>?do=sendEmail" method="POST">
Email: <input type="text" name="email">
<input type="submit" value="Submit">
</form>
Make sure you read the comments so you understand where to edit like the $from and the queries, enjoy.
However you will still need to fix your issues with your smtp server.
- Secured.
Edit 2:
Wasn't paying any attention and used mysql_real_escape_string() =-=" well anyways I edited it to use a the include sql injection function, maybe not the best one but ya.
Edit 3:
Little Syntax Error,
PHP Code:
passwordReset($email);
$msg = passwordReset($email);
Should be:
PHP Code:
$msg = passwordReset($email);