Location: PHPKode > scripts > PHP Link Directory Script > linkdirectory/www/lib/sendmail.php
<?php
/* PHP Link Directory Copyright 2011 Robert Rook */
/* Link for a user to verify their email address */
function sendmail_verification_byid($id) {
	global $site_title, $site_url, $site_email, $db, $prefix;
	$res = mysql_query("SELECT ltitle, lurl, verifkey, lfname, lemail, linkid, ctitle FROM {$prefix}link WHERE linkid='{$id}'", $db);
	if(!mysql_num_rows($res)) { return false; }
	$row = mysql_fetch_array($res);
	
	$message = file_get_contents("data/mail_verify.txt");	
	$message = str_replace(array(":SITE_TITLE:", ":SITE_URL:", ":SITE_EMAIL:", ":LINK_FULLNAME:", ":LINK_URL:", ":LINK_TITLE:", ":LINK_KEY:", ":LINK_ID:", ":CATEGORY_TITLE:"), array($site_title, $site_url, $site_email, $row['lfname'], $row['lurl'], $row['ltitle'], $row['verifkey'], $row['linkid'], $row['ctitle']), $message);
	
	return mail($row['lemail'], "Email Verification Link", $message, "From: {$site_email}\r\n");
}
/* Link for a user to delete their link from the directory */
function sendmail_deletion_byid($id) {
	global $site_title, $site_url, $site_email, $db, $prefix;
	$res = mysql_query("SELECT ltitle, lurl, verifkey, lfname, lemail, linkid, ctitle FROM {$prefix}link WHERE linkid='{$id}'", $db);
	if(!mysql_num_rows($res)) { return false; }
	$row = mysql_fetch_array($res);
	
	$message = file_get_contents("data/mail_delete.txt");	
	$message = str_replace(array(":SITE_TITLE:", ":SITE_URL:", ":SITE_EMAIL:", ":LINK_FULLNAME:", ":LINK_URL:", ":LINK_TITLE:", ":LINK_KEY:", ":LINK_ID:", ":CATEGORY_TITLE:"), array($site_title, $site_url, $site_email, $row['lfname'], $row['lurl'], $row['ltitle'], $row['verifkey'], $row['linkid'], $row['ctitle']), $message);
	
	return mail($row['lemail'], "Link Removal Request", $message, "From: {$site_email}\r\n");
}
/* Email containing new password for an administrator */
function sendmail_password_reset_byid($id) {
	global $site_title, $site_url, $site_email, $db, $prefix;
	$res = mysql_query("SELECT username, password, email, fullname FROM {$prefix}users WHERE bstatus=1 AND userid='{$id}'", $db);
	if(!mysql_num_rows($res)) { return false; }
	$row = mysql_fetch_array($res);
	
$message = <<<ENDVAR
Dear {$row['fullname']},
Your password has been reset and you login information is now as below:

Username: {$row['username']}
Password: {$row['password']}

You can login to the members area at:

{$site_url}/login.php

Please do so as soon as possible and change your password to prevent security risks.
{$site_title}
ENDVAR;

	return mail($row['email'], "Password Reset", $message, "From: {$site_email}\r\n");
}
/* Email containing verification link for an administrator */
function sendmail_admin_email_verify_byid($id) {
	/* This function is not currently used */
}
?>
Return current item: PHP Link Directory Script