forgot to add includes/MySmarty.class.php :(
moved a couple of things into an override of Smarty::display()
This commit is contained in:
parent
137d715568
commit
db7808688f
17 changed files with 61 additions and 53 deletions
|
@ -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;
|
||||
|
|
|
@ -203,8 +203,6 @@ try {
|
|||
$smarty->assign('eventid', $eventid);
|
||||
}
|
||||
$smarty->assign('userid', $userid);
|
||||
$smarty->assign('isadmin', $_SESSION['admin']);
|
||||
$smarty->assign('opt', $smarty->opt());
|
||||
$smarty->display('event.tpl');
|
||||
}
|
||||
catch (PDOException $e) {
|
||||
|
|
|
@ -185,8 +185,6 @@ try {
|
|||
if (isset($message)) {
|
||||
$smarty->assign('message', $message);
|
||||
}
|
||||
$smarty->assign('isadmin', $_SESSION["admin"]);
|
||||
$smarty->assign('opt', $smarty->opt());
|
||||
$smarty->display('families.tpl');
|
||||
}
|
||||
catch (PDOException $e) {
|
||||
|
|
|
@ -57,7 +57,6 @@ if (isset($_POST["action"]) && $_POST["action"] == "forgot") {
|
|||
}
|
||||
$smarty->assign('action', $_POST["action"]);
|
||||
$smarty->assign('username', $username);
|
||||
$smarty->assign('opt', $smarty->opt());
|
||||
$smarty->display('forgot.tpl');
|
||||
}
|
||||
catch (PDOException $e) {
|
||||
|
@ -65,7 +64,6 @@ if (isset($_POST["action"]) && $_POST["action"] == "forgot") {
|
|||
}
|
||||
}
|
||||
else {
|
||||
$smarty->assign('opt', $smarty->opt());
|
||||
$smarty->display('forgot.tpl');
|
||||
}
|
||||
?>
|
||||
|
|
34
src/includes/MySmarty.class.php
Normal file
34
src/includes/MySmarty.class.php
Normal file
|
@ -0,0 +1,34 @@
|
|||
<?php
|
||||
|
||||
define('SMARTY_DIR', dirname(__FILE__) . "/Smarty-3.1.12/libs/");
|
||||
require_once(SMARTY_DIR . "Smarty.class.php");
|
||||
require_once(dirname(__FILE__) . "/config.php");
|
||||
|
||||
class MySmarty extends Smarty {
|
||||
public function __construct() {
|
||||
parent::__construct();
|
||||
}
|
||||
|
||||
public function dbh() {
|
||||
$opt = $this->opt();
|
||||
return new PDO(
|
||||
$opt["pdo_connection_string"],
|
||||
$opt["pdo_username"],
|
||||
$opt["pdo_password"]);
|
||||
}
|
||||
|
||||
public function opt() {
|
||||
static $opt;
|
||||
if (!isset($opt)) {
|
||||
$opt = getGlobalOptions();
|
||||
}
|
||||
return $opt;
|
||||
}
|
||||
|
||||
public function display($t) {
|
||||
parent::assign('isadmin', $_SESSION['admin']);
|
||||
parent::assign('opt', $this->opt());
|
||||
parent::display($t);
|
||||
}
|
||||
}
|
||||
?>
|
|
@ -283,7 +283,5 @@ if (isset($approval)) {
|
|||
$smarty->assign('approval', $approval);
|
||||
}
|
||||
$smarty->assign('userid', $userid);
|
||||
$smarty->assign('isadmin', $_SESSION['admin']);
|
||||
$smarty->assign('opt', $smarty->opt());
|
||||
$smarty->display('home.tpl');
|
||||
?>
|
||||
|
|
|
@ -293,7 +293,5 @@ $smarty->assign('image_filename', $image_filename);
|
|||
$smarty->assign('comment', $comment);
|
||||
$smarty->assign('categories', $categories);
|
||||
$smarty->assign('ranks', $ranks);
|
||||
$smarty->assign('isadmin', $_SESSION["admin"]);
|
||||
$smarty->assign('opt', $smarty->opt());
|
||||
$smarty->display('item.tpl');
|
||||
?>
|
||||
|
|
|
@ -50,11 +50,9 @@ if (!empty($_POST["username"])) {
|
|||
}
|
||||
|
||||
$smarty->assign('username', $username);
|
||||
$smarty->assign('opt', $smarty->opt());
|
||||
$smarty->display('login.tpl');
|
||||
}
|
||||
else {
|
||||
$smarty->assign('opt', $smarty->opt());
|
||||
$smarty->display('login.tpl');
|
||||
}
|
||||
?>
|
||||
|
|
|
@ -58,8 +58,6 @@ try {
|
|||
$smarty->assign('recipients', $recipients);
|
||||
$smarty->assign('rcount', $rcount);
|
||||
$smarty->assign('userid', $userid);
|
||||
$smarty->assign('isadmin', $_SESSION["admin"]);
|
||||
$smarty->assign('opt', $smarty->opt());
|
||||
$smarty->display('message.tpl');
|
||||
}
|
||||
catch (PDOException $e) {
|
||||
|
|
|
@ -81,8 +81,6 @@ try {
|
|||
$smarty->assign('totalprice', formatPrice($totalprice, $opt));
|
||||
$smarty->assign('itemcount', $itemcount);
|
||||
$smarty->assign('userid', $userid);
|
||||
$smarty->assign('isadmin', $_SESSION["admin"]);
|
||||
$smarty->assign('opt', $smarty->opt());
|
||||
$smarty->display('mylist.tpl');
|
||||
}
|
||||
catch (PDOException $e) {
|
||||
|
|
|
@ -89,8 +89,6 @@ try {
|
|||
$smarty->assign('email', $row["email"]);
|
||||
$smarty->assign('email_msgs', $row["email_msgs"]);
|
||||
$smarty->assign('comment', $row["comment"]);
|
||||
$smarty->assign('isadmin', $_SESSION["admin"]);
|
||||
$smarty->assign('opt', $smarty->opt());
|
||||
$smarty->display('profile.tpl');
|
||||
}
|
||||
else {
|
||||
|
|
|
@ -162,7 +162,5 @@ if (isset($rendered_error)) {
|
|||
}
|
||||
$smarty->assign('ranking', $_GET["ranking"]);
|
||||
$smarty->assign('haserror', $haserror);
|
||||
$smarty->assign('isadmin', $_SESSION["admin"]);
|
||||
$smarty->assign('opt', $smarty->opt());
|
||||
$smarty->display('ranks.tpl');
|
||||
?>
|
||||
|
|
|
@ -105,8 +105,6 @@ try {
|
|||
$smarty->assign('quantity', $quantity);
|
||||
$smarty->assign('itemid', $itemid);
|
||||
$smarty->assign('userid', $userid);
|
||||
$smarty->assign('isadmin', $_SESSION["admin"]);
|
||||
$smarty->assign('opt', $smarty->opt());
|
||||
$smarty->display('receive.tpl');
|
||||
}
|
||||
catch (PDOException $e) {
|
||||
|
|
|
@ -223,7 +223,5 @@ $smarty->assign('userid', $userid);
|
|||
if (isset($message)) {
|
||||
$smarty->assign('message', $message);
|
||||
}
|
||||
$smarty->assign('isadmin', $_SESSION["admin"]);
|
||||
$smarty->assign('opt', $smarty->opt());
|
||||
$smarty->display('shop.tpl');
|
||||
?>
|
||||
|
|
|
@ -82,8 +82,6 @@ try {
|
|||
$smarty->assign('totalprice', formatPrice($totalprice, $opt));
|
||||
$smarty->assign('itemcount', $itemcount);
|
||||
$smarty->assign('userid', $userid);
|
||||
$smarty->assign('isadmin', $_SESSION["admin"]);
|
||||
$smarty->assign('opt', $smarty->opt());
|
||||
$smarty->display('shoplist.tpl');
|
||||
}
|
||||
catch (PDOException $e) {
|
||||
|
|
|
@ -104,7 +104,5 @@ $smarty->assign('action', $_POST["action"]);
|
|||
if (isset($error)) {
|
||||
$smarty->assign('error', $error);
|
||||
}
|
||||
$smarty->assign('isadmin', $_SESSION['admin']);
|
||||
$smarty->assign('opt', $smarty->opt());
|
||||
$smarty->display('signup.tpl');
|
||||
?>
|
||||
|
|
|
@ -109,7 +109,6 @@ else if ($action == "edit") {
|
|||
$approved = $row["approved"];
|
||||
$userisadmin = $row["admin"];
|
||||
}
|
||||
mysql_free_result($rs);
|
||||
}
|
||||
else if ($action == "") {
|
||||
$username = "";
|
||||
|
@ -197,7 +196,6 @@ $users = array();
|
|||
while ($row = $stmt->fetch()) {
|
||||
$users[] = $row;
|
||||
}
|
||||
mysql_free_result($rs);
|
||||
|
||||
$smarty->assign('action', $action);
|
||||
$smarty->assign('username', $username);
|
||||
|
@ -223,7 +221,5 @@ if (isset($message)) {
|
|||
$smarty->assign('message', $message);
|
||||
}
|
||||
$smarty->assign('userid', $userid);
|
||||
$smarty->assign('isadmin', $_SESSION["admin"]);
|
||||
$smarty->assign('opt', $smarty->opt());
|
||||
$smarty->display('users.tpl');
|
||||
?>
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue