email; //$recipientEmail = $adminEmail; } $mail = new htmlMimeMail(); $mail->setHtml($body); $mail->setReturnPath($fromEmail); if($from != null){ $mail->setFrom($fromEmail); } $mail->setSubject($subject); $mail->setHeader('X-Mailer', 'SHHA Mailer'); $result = $mail->send(array($recipientEmail), 'smtp'); if($result){ return true; }else{ print_r($mail->errors); } return false; /* if(mail($recipientEmail, $subject, $body)){ return true; }else{ return false; }*/ } function editProfile($userId, $username, $password, $email, $firstName, $lastName, $active = null){ include('database.php'); mysql_select_db($database_name, $database_connection); if($active){ $sqlAdd = ", active = " . quote_smart($active); } if($password != ""){ $sqlAdd .= ", password = " . quote_smart($password); } $sql = "UPDATE userWHMIS SET username = " . quote_smart($username) . ", email = " . quote_smart($email) . ", firstName = " . quote_smart($firstName) . ", lastName = " . quote_smart($lastName) . " $sqlAdd WHERE userId = " . quote_smart($userId) . ""; if(mysql_query($sql, $database_connection)){ return true; }else{ return false; } } function editAdminProfile($adminId, $username, $password, $email){ include('database.php'); mysql_select_db($database_name, $database_connection); if($password != ""){ $sqlAdd .= ", password = " . quote_smart($password); } $sql = "UPDATE adminWHMIS SET username = " . quote_smart($username) . ", email = " . quote_smart($email) . " $sqlAdd WHERE adminId = " . quote_smart($adminId) . ""; if(mysql_query($sql, $database_connection)){ return true; }else{ return false; } } function deleteMember($userId){ include('database.php'); mysql_select_db($database_name, $database_connection); $sql = "DELETE FROM userWHMIS WHERE userId = " . quote_smart($userId); if(mysql_query($sql, $database_connection)){ return true; }else{ return false; } } function quote_smart($value) { // Stripslashes if (get_magic_quotes_gpc()) { $value = stripslashes($value); } // Quote if not integer if (!is_numeric($value)) { $value = "'" . mysql_real_escape_string($value) . "'"; } return $value; } function emailAvailable($email){ include('database.php'); mysql_select_db($database_name, $database_connection); $sql = "SELECT email, count(userId) AS count FROM userWHMIS WHERE email = " . quote_smart($email); $RS = mysql_query($sql, $database_connection); $row = mysql_fetch_assoc($RS); if($row["count"] == 0 || $row["email"] == 'NULL'){ return true; }else{ return false; } } function usernameAvailable($userName){ include('database.php'); mysql_select_db($database_name, $database_connection); $sql = "SELECT count(userId) AS count FROM userWHMIS WHERE username = " . quote_smart($userName); $RS = mysql_query($sql, $database_connection); $row = mysql_fetch_assoc($RS); if($row["count"] == 0){ return true; }else{ return false; } } function adminEmailAvailable($email){ include('database.php'); mysql_select_db($database_name, $database_connection); $sql = "SELECT count(adminId) AS count FROM adminWHMIS WHERE email = " . quote_smart($email); $RS = mysql_query($sql, $database_connection); $row = mysql_fetch_assoc($RS); if($row["count"] == 0){ return true; }else{ return false; } } function adminUsernameAvailable($userName){ include('database.php'); mysql_select_db($database_name, $database_connection); $sql = "SELECT count(adminId) AS count FROM adminWHMIS WHERE username = " . quote_smart($userName); $RS = mysql_query($sql, $database_connection); $row = mysql_fetch_assoc($RS); if($row["count"] == 0){ return true; }else{ return false; } } function getUser($userId){ include('database.php'); mysql_select_db($database_name, $database_connection); $sql = "SELECT * FROM userWHMIS WHERE userId = " . quote_smart($userId) . " LIMIT 1"; $RS = mysql_query($sql, $database_connection); if($row = mysql_fetch_assoc($RS)){ return $row; } } function getAllUsers(){ include('database.php'); mysql_select_db($database_name, $database_connection); $sql = "SELECT * FROM userWHMIS ORDER BY firstName ASC, lastName ASC"; $RS = mysql_query($sql, $database_connection); $users = ""; while($row = mysql_fetch_assoc($RS)){ $users[] = $row; } return $users; } function getSurveys($userId){ include('database.php'); mysql_select_db($database_name, $database_connection); $whimsSql = "SELECT * FROM whims WHERE userId = " . quote_smart($userId); $whimsRS = mysql_query($whimsSql, $database_connection) or die(mysql_error()); $surveys = ""; while($row = mysql_fetch_assoc($whimsRS)){ $row["surveyType"] = "whims"; $surveys[] = $row; } return $surveys; } function getSurveyResults($surveyType, $surveyId){ include('database.php'); mysql_select_db($database_name, $database_connection); $sql = "SELECT * FROM $surveyType WHERE surveyId = " . quote_smart($surveyId) . " LIMIT 1"; $RS = mysql_query($sql, $database_connection); if($row = mysql_fetch_assoc($RS)){ return $row; } return false; } function editActivation($activation, $userId){ include('database.php'); mysql_select_db($database_name, $database_connection); $sql = "UPDATE userWHMIS SET active = " . quote_smart($activation) . " WHERE userId = " . quote_smart($userId); mysql_query($sql, $database_connection); } function deleteUser($userId){ include('database.php'); mysql_select_db($database_name, $database_connection); $sql = "DELETE FROM userWHMIS WHERE userId = " . quote_smart($userId); mysql_query($sql, $database_connection); } function getAdmin($adminId){ include('database.php'); mysql_select_db($database_name, $database_connection); $sql = "SELECT * FROM adminWHMIS WHERE adminId = " . quote_smart($adminId) . " LIMIT 1"; $RS = mysql_query($sql, $database_connection); if($row = mysql_fetch_assoc($RS)){ return $row; } } function rhpComplete($userId){ include('database.php'); mysql_select_db($database_name, $database_connection); $sql = "SELECT score FROM rhp WHERE userId = " . quote_smart($userId) . " LIMIT 1"; $RS = mysql_query($sql, $database_connection); while($row = mysql_fetch_assoc($RS)){ if($row["score"] >= 8){ return true; }else{ return false; } } return false; } function cssComplete($userId){ include('database.php'); mysql_select_db($database_name, $database_connection); $sql = "SELECT score FROM css WHERE userId = " . quote_smart($userId) . " LIMIT 1"; $RS = mysql_query($sql, $database_connection); while($row = mysql_fetch_assoc($RS)){ if($row["score"] >= 8){ return true; }else{ return false; } } return false; } function ncssComplete($userId){ include('database.php'); mysql_select_db($database_name, $database_connection); $sql = "SELECT score FROM ncss WHERE userId = " . quote_smart($userId) . " LIMIT 1"; $RS = mysql_query($sql, $database_connection); while($row = mysql_fetch_assoc($RS)){ if($row["score"] >= 8){ return true; }else{ return false; } } return false; } function mdsComplete($userId){ include('database.php'); mysql_select_db($database_name, $database_connection); $sql = "SELECT score FROM mds WHERE userId = " . quote_smart($userId) . " LIMIT 1"; $RS = mysql_query($sql, $database_connection); while($row = mysql_fetch_assoc($RS)){ if($row["score"] >= 8){ return true; }else{ return false; } } return false; } ?>