go-mailzu/MultipleAdmin.php

159 lines
4.1 KiB
PHP
Raw Permalink Normal View History

2011-02-11 15:11:43 +01:00
<?php
/**
* Display pending requests for logged in users.
*
* @author Brian Wong
* @author Jeremy Fowler <jfowler06@users.sourceforge.net>
* @version 04-03-07
* @package MailZu
*
* Copyright (C) 2005 - 2007 MailZu
* License: GPL, see LICENSE
*/
/**
* Include Template class
*/
include_once('lib/Template.class.php');
/**
* Include common output functions
*/
include_once('templates/common.template.php');
/**
* Include quarantine-specific output functions
*/
include_once('templates/quarantine.template.php');
/**
* Include DB class
*/
include_once('lib/DBEngine.class.php');
if (!Auth::is_logged_in()) {
Auth::print_login_msg(); // Check if user is logged in
}
//Get content type
$content_type = (CmnFns::get_ctype() ? CmnFns::get_ctype() : 'A');
$_SESSION['sessionNav'] = "Multiple Accounts";
$t = new Template(translate('Multiple Accounts'));
$db = new DBEngine();
$t->printHTMLHeader();
$t->printWelcome();
$t->startMain();
// Break table into 2 columns, put quick links on left side and all other tables on the right
startQuickLinksCol();
showQuickLinks(); // Print out My Quick Links
startDataDisplayCol();
echo '<br>';
// Print a loading message until database returns...
printMessage(translate('Retrieving Messages...'));
// Connect to mysql and database
$db_connect = @mysql_pconnect($conf['db']['hostSpec'],$conf['db']['dbUser'],$conf['db']['dbPass']) or die ("<html><body><h1>ERROR connecting to server</h1><br></body></html>"."\n");
mysql_select_db ( $conf['db']['dbName'], $db_connect ) or die ("<html><body><h1>ERROR opening db</h1><br></body></html>"."\n");
// A simple query to the "Multiple" table to detect if we need to create one
if(!(mysql_query("SELECT * FROM mailzu_multiple")))
{
// It didn exist so create one.
$sql_mult_create = mysql_query("
CREATE TABLE IF NOT EXISTS `mailzu_multiple` (
`mult_id` int(11) NOT NULL auto_increment,
`mult_email` varchar(64) default NULL,
`mult_attach` varchar(64) default NULL,
PRIMARY KEY (`mult_id`)
)
");
// Simple Javascript to force a page reload
echo "
<script language=\"javascript\">
window.location=\"./MultipleAdmin.php\";
</script>
";
}
else
{
// Fetch all entries query
$sql_emails_query = mysql_query("SELECT * FROM mailzu_multiple ORDER BY mult_email");
$sql_emails_rows = mysql_num_rows($sql_emails_query);
// Delete entry
if ($_GET['del']>='0')
{
$multi_delete = "DELETE FROM mailzu_multiple WHERE mult_id='".$_GET['del']."'";
mysql_query($multi_delete);
echo "
// Reload page
<script language=\"javascript\">
window.location=\"./MultipleAdmin.php\";
</script>
";
}
// Insert entry
else if ($_GET['edit']>='new')
{
mysql_query("insert into mailzu_multiple(mult_email,mult_attach) values('".$_POST[mult_emailacc]."','".$_POST[mult_emailatt]."')");
echo "
// Reload page
<script language=\"javascript\">
window.location=\"./MultipleAdmin.php\";
</script>
";
}
else
{
// Draw the table
echo '
<table border=\"1\">
<tr>
<td><b>'; echo translate('Email address'); echo '</b></td>
<td><b>'; echo translate('Attached Email'); echo '</b></td>
</tr>
';
// Fetch entries one by one
while($fetch_row = mysql_fetch_array($sql_emails_query))
{
if ($sql_emails_rows!=0)
{
extract($fetch_row);
echo "
<tr>
<td>$mult_email</td>
<td>$mult_attach</td>
<td><A HREF=\"./MultipleAdmin.php?del=$mult_id\"><IMG border=\"0\" SRC=\"./img/delete.gif\"></A></td>
</tr>";
}
}
// Display option to create a new entry
echo "
<tr>
<FORM name=\"mult_form\" method=\"post\" action=\"./MultipleAdmin.php?edit=new\">
<td><input type=\"text\" maxlength=\"59\" name=\"mult_emailacc\"></td>
<td><input type=\"text\" maxlength=\"59\" name=\"mult_emailatt\"></td>
<td><A HREF=\"javascript:document.mult_form.submit()\"><IMG border=\"0\" SRC=\"./img/edit.gif\"></A></td>
</FORM>
</tr>
</table>
";
}
}
// Hide the message after the table loads.
hideMessage(translate('Retrieving Messages...'));
endDataDisplayCol();
$t->endMain();
$t->printHTMLFooter();
?>