Location: PHPKode > projects > ZompLog > plugins/mailnotify/admin.php
<?php
/*
This Zomplog plugin notifies the administrator (or anyone else) when a new post is submitted, or a comment to a post
created by Frank Hoek

version 1.4, March 24th 2007
- I rewrote the coding concerning automatic upgrading

version 1.3, November 12th 2006
 - automatic upgrade
 - strip tags from the post for better presentation in the email

version 1.2, November 11th 2006
 - distinct messages for new post and new comment

www.frankma.nl
*/

ob_start();

include_once("../../admin/functions.php");
include("../../admin/config.php");
include("../../admin/session.php");
include("../../admin/header.php");

$user = loadUser($_SESSION['login'],$link,$table_users);

?>

<div id="submenu"><a href="../../admin/plugins.php" class="sub">plugins</a></div>

<?php
// update fields in table when any change has been submitted
if($_POST["newaddress"]){
// display error when adress-field has been left empty
	if(!$_POST[currentaddress]){
		$messages[]="You did not fill out a (new) emailaddress";
	}
// else update the table
	if(empty($messages)) {
		$newaddress     = addslashes($_POST[currentaddress]);
		$newentrytitle  = addslashes($_POST[currententrytitle]);
		$newname        = addslashes($_POST[currentname]);
		$newday         = addslashes($_POST[currentday]);
		$newpost        = addslashes($_POST[currentpost]);
		$newcomment     = addslashes($_POST[currentcomment]);
		$newentrysubj   = addslashes($_POST[currententrysubj]);
		$newcommentsubj = addslashes($_POST[currentcommentsubj]);
		
		$query="UPDATE $prefix" . "_mailnotify SET address = '$newaddress', entrytitle = '$newentrytitle', name = '$newname', day = '$newday', post = '$newpost', comment = '$newcomment', entrysubj = '$newentrysubj', commentsubj = '$newcommentsubj' WHERE id = '1'";
		$result=mysql_query($query, $link) or die("Died inserting new emailaddress into db.  Error returned if any: ".mysql_error());
		
		header("Location: admin.php?message=updated plugin!");
		ob_end_flush();
	}
}
// get current data from the table
$query = "SELECT * FROM $prefix" . "_mailnotify LIMIT 1";
$result = mysql_query($query, $link);
$currentsetting = mysql_fetch_array($result);

?>

<div id="side">
<div class="title">&nbsp;</div>
<div class="box"><?php
if(!empty($messages)){
	displayErrors($messages);
}

elseif($_GET[message] && empty($messages)){
  	displayMessage($_GET[message]);
}

else{
  	echo "Receive a notification by email for each new post or comment to a post.";
}  
  
?>
</div></div>

<div id="main">
<h1>Get notified by email</h1><br />

<form action="<?php echo $_SERVER["../mailnotify/PHP_SELF"]?>" method="POST">
  <fieldset id="titlediv">
	<h1>
	  <legend>Your current notification email settings: </legend>
    </h1>
	<table width="100%" border="0" cellspacing="0" cellpadding="8" class="text">
	  <tr>
	    <td width="300"><div align="right">your current emailaddress:</div></td>
	    <td valign="bottom"><input name="currentaddress" type="text" id="address" value="<?php echo $currentsetting[address]?>"></td>
      </tr>
	  <tr>
        <td width="300"><div align="right">&quot;posttitle&quot; label, displayed in email-message:</div></td>
        <td valign="bottom"><input name="currententrytitle" type="text" id="address" value="<?php echo $currentsetting[entrytitle]?>"></td>
      </tr>
	  <tr>
	    <td width="300"><div align="right">&quot;comment&quot; label, displayed in email-message:</div></td>
	    <td valign="bottom"><input name="currentcomment" type="text" id="address" value="<?php echo $currentsetting[comment]?>"></td>
      </tr>
	  <tr>
	    <td width="300"><div align="right">&quot;name&quot; label, displayed in email-message:</div></td>
	    <td valign="bottom"><input name="currentname" type="text" id="address" value="<?php echo $currentsetting[name]?>"></td>
      </tr>
	  <tr>
	    <td width="300"><div align="right">&quot;date&quot; label, displayed in email-message:</div></td>
	    <td valign="bottom"><input name="currentday" type="text" id="address" value="<?php echo $currentsetting[day]?>"></td>
      </tr>
	  <tr>
	    <td width="300"><div align="right">&quot;post&quot; label, displayed in email-message:</div></td>
	    <td valign="bottom"><input name="currentpost" type="text" id="address" value="<?php echo $currentsetting[post]?>"></td>
      </tr>
	  
	  <tr>
	    <td width="300"><div align="right">subject of the post notification email:</div></td>
	    <td valign="bottom"><input name="currententrysubj" type="text" id="address" value="<?php echo $currentsetting[entrysubj]?>" size="55"></td>
      </tr>
	    <td width="300"><div align="right">subject of the comment notification email:</div></td>
	    <td valign="bottom"><input name="currentcommentsubj" type="text" id="address" value="<?php echo $currentsetting[commentsubj]?>" size="55"></td>
      </tr>	  <tr>
	    <td width="300"><div align="right"><span class="right">
	        <input type="submit" name="newaddress" value="Submit" id="newaddress">
        </span></div></td>
	    <td><span class="right">
	    </span></td>
      </tr>
	</table>
	</fieldset>
</form>
<br />

</div>
<?php
include("../../admin/footer.php");
?>
Return current item: ZompLog