pop.php
上传用户:gzy2002
上传日期:2010-02-11
资源大小:1785k
文件大小:6k
- <?php
- // +-------------------------------------------------------------+
- // | DeskPRO v [2.0.1 Production]
- // | Copyright (C) 2001 - 2004 Headstart Solutions Limited
- // | Supplied by WTN-WDYL
- // | Nullified by WTN-WDYL
- // | Distribution via WebForum, ForumRU and associated file dumps
- // +-------------------------------------------------------------+
- // | DESKPRO IS NOT FREE SOFTWARE
- // +-------------------------------------------------------------+
- // | License ID : Full Enterprise License =) ...
- // | License Owner : WTN-WDYL Team
- // +-------------------------------------------------------------+
- // | $RCSfile: pop.php,v $
- // | $Date: 2004/02/11 01:28:14 $
- // | $Revision: 1.16 $
- // +-------------------------------------------------------------+
- // | File Details:
- // | - POP3 gateway account maintenance (administration interface)
- // +-------------------------------------------------------------+
- error_reporting(E_ALL & ~E_NOTICE);
- require_once('./global.php');
- //Nullify WTN-WDYL Team
- // default do
- $_REQUEST['do'] = trim($_REQUEST['do']);
- if (!isset($_REQUEST['do']) or $_REQUEST['do'] == "") {
- $_REQUEST['do'] = "view";
- }
- // globalise variables
- $global = array (
- array('id', 'number')
- );
- rg($global);
- include('./settings_include.php');
- ############################### CREATE ACCOUNT ###############################
- if ($_REQUEST['do'] == "add2") {
- $db->query("SELECT id FROM gateway_accounts WHERE id = '$_REQUEST[accountid]'");
- if (!$db->num_rows()) {
- $_REQUEST['accountid'] = 0;
- }
- if ($_REQUEST['target'] != 'user') {
- $_REQUEST['accountid'] = 0;
- }
- $db->query("INSERT INTO gateway_pop_accounts SET
- accountid = '" . mysql_escape_string($_REQUEST['accountid']) . "',
- server = '" . mysql_escape_string($_REQUEST['server']) . "',
- username = '" . mysql_escape_string($_REQUEST['username']) . "',
- password = '" . mysql_escape_string($_REQUEST['password']) . "',
- target = '" . mysql_escape_string($_REQUEST['target']) . "'
- ");
- $id = $db->last_id();
- jump('pop.php?do=view', 'Remote POP3 account added');
- }
- ############################### EDIT ACCOUNT (2) ###############################
- if ($_REQUEST['do'] == "edit2") {
- $db->query("SELECT id FROM gateway_accounts WHERE id = $_REQUEST[accountid]");
- if (!$db->num_rows()) {
- $_REQUEST['accountid'] = 0;
- }
- if ($_REQUEST['target'] != 'user') {
- $_REQUEST['accountid'] = 0;
- }
- $db->query("
- UPDATE gateway_pop_accounts SET
- accountid = '" . mysql_escape_string($_REQUEST['accountid']) . "',
- server = '" . mysql_escape_string($_REQUEST['server']) . "',
- username = '" . mysql_escape_string($_REQUEST['username']) . "',
- password = '" . mysql_escape_string($_REQUEST['password']) . "',
- target = '" . mysql_escape_string($_REQUEST['target']) . "'
- WHERE id = '$id'
- ");
- jump('pop.php?do=view', 'Remote POP3 account added');
- }
- ############################### DELETE ACCOUNT ###############################
- if ($_REQUEST['do'] == "delete") {
- $db->query("DELETE FROM gateway_pop_accounts WHERE id = '$id'");
- jump('pop.php?do=view', 'Remote POP3 account deleted');
- }
- ############################### LIST ACCOUNTS ###############################
- if ($_REQUEST['do'] == "view") {
-
- admin_header('Email Gateway', 'List POP3 Accounts');
- $db->query("SELECT gateway_pop_accounts.*, gateway_accounts.id AS gatewayid, gateway_accounts.email as gatewaymail
- FROM gateway_pop_accounts
- LEFT JOIN gateway_accounts on gateway_pop_accounts.accountid = gateway_accounts.id
- ORDER BY id");
- $cols = array('Linked to Gateway E-mail', 'Handler', 'Server', 'Username', 'Password', 'Edit', 'Delete');
- while ($result = $db->row_array()) {
- if ($result['target'] != 'user') {
- $bit = "<i>Gateway only for user handler</i>";
- } elseif ($result['accountid']) {
- $bit = "<A HREF="email.php?do=edit&id=$result[accountid]">$result[gatewaymail]</A>";
- } else {
- $bit = "<b>Please edit to set gateway</b>";
- }
- $row[] = array($bit,
- $result['target'],
- $result['server'],
- $result['username'],
- $result['password'],
- "<A HREF="pop.php?do=edit&id=$result[id]">Edit</A>",
- jprompt(
- "This will delete the POP3 account \'$result[username]\' on server \'$result[server]\'.",
- "pop.php?do=delete&id=$result[id]",
- 'Delete'
- )
- );
- }
-
- if (!$db->num_rows()) {
- $row[] = "<center>No accounts are currently defined. <A HREF="pop.php?do=add">Add an account.</A></center>";
- }
- table_header("POP3 Accounts");
- table_content($cols, $row);
- table_footer();
- }
- ############################### CREATE / VIEW ACCOUNT ###############################
- if ($_REQUEST['do'] == "add" OR $_REQUEST['do'] == "edit") {
- if ($_REQUEST['do'] == "add") {
- admin_header('Email Gateway', 'Add POP3 Account');
- } else {
- if (!$id) {
- mistake('No ID specified.');
- }
- admin_header('Email Gateway');
- $pop = $db->query_return("SELECT * FROM gateway_pop_accounts WHERE id = $id");
- }
- // get the gateway accounts
- $db->query("SELECT id, email from gateway_accounts ORDER BY email");
- while ($res = $db->row_array()) {
- $gateways[$res['id']] = $res['email'];
- }
- $handlers = array('user', 'tech', 'return', 'techemail');
- $bit = form_select('target', $handlers, NULL, iff($pop['target'], $pop['target'], 'user'), 1);
- $table[] = array('<B>Handler</B><br />Specify which gateway handler will handle messages sent to this address:', $bit);
- $bit = form_select('accountid', $gateways, NULL, iff($pop['accountid'], $pop['accountid']));
- $table[] = array('<b>Linked to Gateway Account</b><br />This only applies when the handler is set to <b>user</b>', $bit);
- $bit = form_input('server', iff($pop['server'], $pop['server'], NULL));
- $table[] = array('<b>POP3 Server</b><br />Remote POP3 server to download from', $bit);
- $bit = form_input('username', iff($pop['username'], $pop['username'], NULL));
- $table[] = array('<b>POP3 Username</b><br />Username to login with', $bit);
- $bit = form_input('password', iff($pop['password'], $pop['password'], NULL));
- $table[] = array('<b>POP3 Password</b><br />Password to authenticate with', $bit);
- if ($_REQUEST['do'] == 'add') {
- table_header('Create Gateway POP3 Account', 'pop.php', array('do' => 'add2'));
- table_content('', $table);
- table_footer('Create POP3 Account');
- } else {
- table_header('Update Gateway POP3 Account', 'pop.php', array('do' => 'edit2', 'id' => $pop['id']));
- table_content('', $table);
- table_footer('Update POP3 Account');
- }
- }
- ?>