$layoutobj->content1 = "<br><br>" . $bhlang['error:username_invalid']; $layoutobj->display(); } else { # Generate a random new ten-letter password $alphabetanumba = "abcdefghijklmnopqrstuvwxyz0123456789"; $newpass = ""; $max = strlen($alphabetanumba) - 1; $length = 10; for ($i = 0; $i <= $length; $i++) { $newpass .= substr($alphabetanumba, rand(0, $max), 1); } $userirows = select_bhdb("userinfo", array("username" => $resetrows[0]['username'], "itemname" => "email"), ""); $emailaddr = $userirows[0]['itemcontent']; # Send the email with the new password # Email them about it with the validation link $emailobj = new bhemail($emailaddr); $emailobj->subject = str_replace("#SITENAME#", $bhconfig['sitename'], $bhlang['emailsubject:passreset_new_password']); $emailobj->message = str_replace("#PASSWORD#", $newpass, $bhlang['email:passreset_new_password']); $emailaway = $emailobj->send(); if ($emailaway == false) { # Open layout object $layoutobj = new bhlayout("generic"); # Send the file listing to the layout, along with directory name $layoutobj->title = $bhlang['title:signup']; $layoutobj->content1 = "<br><br>" . $bhlang['error:email_error']; $layoutobj->display(); } else { # Update the database with it. bh_auth_set_password($resetrows[0]['username'], $newpass); # Open layout object $layoutobj = new bhlayout("generic");
function bh_log($message, $type) { global $bhlang, $bhcurrent, $bhconfig, $bherrors; # This is the all-singing, all-dancing logging system. # First, retrieve all actions matching this type from the database $matchingactions = select_bhdb("logactions", array("type" => $type), ""); # Then, see if there are some, and go through them if there are. if (!empty($matchingactions)) { foreach ($matchingactions as $matchingaction) { # Try to match the action to the ones we know about. switch ($matchingaction['action']) { case "fileappend": case "logtofile": # Append to a file. Check if we have a filename, or just log to the default one. if (!empty($matchingaction['parameters'])) { $fn = @fopen($bhconfig['bhfilepath'] . "/" . $matchingaction['parameters'], "a"); @fputs($fn, time() . ":" . $_SERVER['REMOTE_ADDR'] . ":" . $message . "\n"); @fclose($fn); } elseif (!empty($bhconfig['logfile'])) { $fn = @fopen($bhconfig['bhfilepath'] . "/" . $bhconfig['logfile'], "a"); @fputs($fn, time() . ":" . $_SERVER['REMOTE_ADDR'] . ":" . $message . "\n"); @fclose($fn); } else { $fn = @fopen($bhconfig['bhfilepath'] . "/log", "a"); @fputs($fn, time() . ":" . $_SERVER['REMOTE_ADDR'] . ":" . $message . "\n"); @fclose($fn); } break; case "email": # Email it to someone. Check for a specified email address, or fail. if (!empty($matchingaction['parameters'])) { $emailobj = new bhemail($matchingaction['parameters']); $emailobj->subject = "Notification from ByteHoard @ " . $_SERVER['HTTP_HOST']; $emailobj->sig = "\n\n\nPowered by ByteHoard " . $bhconfig['version'] . " / Sent at " . date("l dS F Y h:i:s A"); $emailobj->message = $message; $emailobj->send(); } else { # Nothing to do. Oh well. } break; case "emailtype": # Email it to them. Check for a specified type, or fail. if (!empty($matchingaction['parameters'])) { $emailobj = new bhemail(); $emailobj->subject = "Notification from ByteHoard @ " . $_SERVER['HTTP_HOST']; $emailobj->sig = "\n\n\nPowered by ByteHoard " . $bhconfig['version'] . " / Sent at " . date("l dS F Y h:i:s A"); $emailobj->message = $message; $emailobj->sendtotype($matchingaction['parameters']); } else { # Nothing to do. Oh well. } break; case "onscreen": # Set error in template thingmywatsit. $bherrors[] = array('message' => $message, 'type' => $matchingaction['parameters']); break; } } } else { # Set error in template thingmywatsit. $bherrors[] = array('message' => $message, 'type' => 'warning'); } }
if (empty($email)) { if (empty($_POST['filemail']['email'])) { bh_log($bhlang['error:no_emailaddr'], "BH_ERROR"); } } elseif (strpos($email, "@") === FALSE) { bh_log(str_replace("#EMAIL#", $email, $bhlang['error:invalid_email_#EMAIL#']), "BH_ERROR"); } else { if ($_POST['filemail']['notify'] == "on") { $notify = 1; } else { $notify = 0; } $userobj = new bhuser($bhsession['username']); $emailfrom = $userobj->userinfo['email']; $filecode = bh_filelink_add($filepath, $expires, $bhsession['username'], $email, $notify); $emailobj = new bhemail($email); $emailobj->subject = $_POST['filemail']['subject']; $fileobj = new bhfile($filepath); $filesize = bh_humanise_filesize($fileobj->fileinfo['filesize']); $findarr = array("#DATE#", "#LINK#", "#SYSTEMNAME#", "#FILENAME#", "#FILESIZE#", "#MD5#"); $replarr = array(date("l dS F Y g:i A", $expires), bh_filelink_uri($filecode), $bhconfig['sitename'], bh_get_filename($filepath), $filesize, $fileobj->md5()); $emailobj->message = $_POST['filemail']['message'] . "\n\n" . str_replace($findarr, $replarr, $bhlang['email:filemail_footer']); if (!empty($emailfrom)) { $emailobj->from = $emailfrom; } $emailobj->send(); bh_log(str_replace("#EMAIL#", $email, $bhlang['notice:email_sent_to_#EMAIL#']), "BH_NOTICE"); } } } } else {