topical media & game development
professional-sql-03-scripts-manage.php / php
#! /usr/bin/php
<?php
// include shared code
include '../lib/config.php';
include '../lib/db.php';
include '../lib/POP3Client.php';
// establish a connection to the POP3 server
pop->connect(POP3_SERVER, POP3_PORT);
pop->pass(MANAGE_PASSWORD);
// process each message in inbox
foreach (array_keys(id)
{
// fetch message
pop->retr(message, from = trim(subject = trim(query = sprintf('SELECT EMAIL_ADDR FROM \%sMAILLIST_USER WHERE ' .
'EMAIL_ADDR = "\%s"', DB_TBL_PREFIX,
mysql_real_escape_string(GLOBALS['DB']));
query, exists = (mysql_num_rows(result);
// send appropriate response
switch (strtoupper(exists)
{
// address already exists
query = sprintf('INSERT INTO \%sMAILLIST_USER ' .
'(EMAIL_ADDR) VALUES ("\%s")', DB_TBL_PREFIX,
mysql_real_escape_string(GLOBALS['DB']));
query, exists)
{
from, response_file = (mysql_query(GLOBALS['DB'])) ?
'unsubscribe.txt' : 'error.txt';
}
else
{
// address does not exist
exists)
{
from, response_file = (mysql_query(GLOBALS['DB'])) ?
'digest_on.txt' : 'error.txt';
}
else
{
// address does not exist
exists)
{
from, response_file = (mysql_query(GLOBALS['DB'])) ?
'digest_off.txt' : 'error.txt';
}
else
{
// address does not exist
response_file = 'help.txt';
// unknown command was received
default:
response = file_get_contents(REPLY_DIR . '/' . replace = array('<list_email>' => LIST_EMAIL,
'<manage_email>' => MANAGE_EMAIL);
replace), array_values(response);
// send message
mail(subject, pop->dele(pop->quit();
mysql_close(
(C) Æliens
20/2/2008
You may not copy or print any of this material without explicit permission of the author or the publisher.
In case of other copyright issues, contact the author.