forgot to add includes/MySmarty.class.php :(

moved a couple of things into an override of Smarty::display()
This commit is contained in:
Ryan Walberg 2012-11-26 02:30:26 +00:00
parent 137d715568
commit db7808688f
17 changed files with 61 additions and 53 deletions

View file

@ -13,9 +13,10 @@
// along with this program; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
include("config.php");
include("db.php");
include("funcLib.php");
require_once(dirname(__FILE__) . "/includes/funcLib.php");
require_once(dirname(__FILE__) . "/includes/MySmarty.class.php");
$smarty = new MySmarty();
$opt = $smarty->opt();
session_start();
if (!isset($_SESSION["userid"])) {
@ -32,46 +33,51 @@ else {
$action = $_GET["action"];
if ($action == "approve") {
$pwd = generatePassword();
$pwd = generatePassword($opt);
if ($_GET["familyid"] != "") {
$query = "INSERT INTO {$OPT["table_prefix"]}memberships(userid,familyid) VALUES(" . $_GET["userid"] . "," . $_GET["familyid"] . ")";
mysql_query($query) or die("Could not query: " . mysql_error());
$stmt = $smarty->dbh()->prepare("INSERT INTO {$opt["table_prefix"]}memberships(userid,familyid) VALUES(?, ?)");
$stmt->bindValue(1, (int) $_GET["userid"], PDO::PARAM_INT);
$stmt->bindValue(2, (int) $_GET["familyid"], PDO::PARAM_INT);
$stmt->execute();
}
$query = "UPDATE {$OPT["table_prefix"]}users SET approved = 1, password = {$OPT["password_hasher"]}('$pwd') WHERE userid = " . $_GET["userid"];
mysql_query($query) or die("Could not query: " . mysql_error());
$stmt = $smarty->dbh()->prepare("UPDATE {$opt["table_prefix"]}users SET approved = 1, password = {$opt["password_hasher"]}(?) WHERE userid = ?");
$stmt->bindParam(1, $pwd, PDO::PARAM_INT);
$stmt->bindValue(2, (int) $_GET["userid"], PDO::PARAM_INT);
$stmt->execute();
// send the e-mails
$query = "SELECT username, email FROM {$OPT["table_prefix"]}users WHERE userid = " . $_GET["userid"];
$rs = mysql_query($query) or die("Could not query: " . mysql_error());
if ($row = mysql_fetch_array($rs,MYSQL_ASSOC)) {
$stmt = $smarty->dbh()->prepare("SELECT username, email FROM {$opt["table_prefix"]}users WHERE userid = ?");
$stmt->bindValue(1, (int) $_GET["userid"], PDO::PARAM_INT);
$stmt->execute();
if ($row = $stmt->fetch()) {
mail(
$row["email"],
"Gift Registry application approved",
"Your Gift Registry application was approved by " . $_SESSION["fullname"] . ".\r\n" .
"Your username is " . $row["username"] . " and your password is $pwd.",
"From: {$OPT["email_from"]}\r\nReply-To: {$OPT["email_reply_to"]}\r\nX-Mailer: {$OPT["email_xmailer"]}\r\n"
"From: {$opt["email_from"]}\r\nReply-To: {$opt["email_reply_to"]}\r\nX-Mailer: {$opt["email_xmailer"]}\r\n"
) or die("Mail not accepted for " . $row["email"]);
}
mysql_free_result($rs);
header("Location: " . getFullPath("index.php"));
exit;
}
else if ($action == "reject") {
// send the e-mails
$query = "SELECT email FROM {$OPT["table_prefix"]}users WHERE userid = " . $_GET["userid"];
$rs = mysql_query($query) or die("Could not query: " . mysql_error());
if ($row = mysql_fetch_array($rs,MYSQL_ASSOC)) {
$stmt = $smarty->dbh()->prepare("SELECT email FROM {$opt["table_prefix"]}users WHERE userid = ?");
$stmt->bindValue(1, (int) $_GET["userid"], PDO::PARAM_INT);
$stmt->execute();
if ($row = $stmt->fetch()) {
mail(
$row["email"],
"Gift Registry application denied",
"Your Gift Registry application was denied by " . $_SESSION["fullname"] . ".",
"From: {$OPT["email_from"]}\r\nReply-To: {$OPT["email_reply_to"]}\r\nX-Mailer: {$OPT["email_xmailer"]}\r\n"
"From: {$opt["email_from"]}\r\nReply-To: {$opt["email_reply_to"]}\r\nX-Mailer: {$opt["email_xmailer"]}\r\n"
) or die("Mail not accepted for " . $row["email"]);
}
mysql_free_result($rs);
$query = "DELETE FROM {$OPT["table_prefix"]}users WHERE userid = " . $_GET["userid"];
mysql_query($query) or die("Could not query: " . mysql_error());
$stmt = $smarty->dbh()->prepare("DELETE FROM {$opt["table_prefix"]}users WHERE userid = ?");
$stmt->bindValue(1, (int) $_GET["userid"], PDO::PARAM_INT);
$stmt->execute();
header("Location: " . getFullPath("index.php"));
exit;