, March 2004. $Id: mailcky.hack,v 1.3 2004/03/29 14:00:39 cky Exp $ Copyright (c) 2004 Chris K. Young. All rights reserved. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public Licence as published by the Free Software Foundation; either version 2 of the Licence, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public Licence for more details. You should have received a copy of the GNU General Public Licence along with this program; if not, write to Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA. */ class mailcky { var $tmpl; function print_header() { $this->tmpl = new template('The mailcky gimmick'); $this->tmpl->set_rcsid('$Id: mailcky.hack,v 1.3 2004/03/29 14:00:39 cky Exp $'); $this->tmpl->print_header(); } function validate_input() { switch ($_SERVER['REMOTE_ADDR']) { case '65.248.4.183': case '210.55.69.57': case '203.167.190.199': return isset($_FILES['file']) && is_uploaded_file($_FILES['file']['tmp_name']); default: return false; } } function process_input() { $mime = new Mail_mime("\n"); $mime->setTxtBody($_POST['text']); $file = $_FILES['file']; $mime->addAttachment($file['tmp_name'], $file['type'], $file['name'], true); $body = $mime->get(); $header = $mime->headers(array('Subject' => "Message from {$_SERVER['REMOTE_ADDR']}")); $mailer = Mail::factory('mail'); if ($mailer->send('cky@spillville.com', $header, $body)) { ?>

Yay, your message has successfully been sent to the author.

Whoops, your message hasn't successfully been sent to the author.

The mailcky gimmick sends an email to the author, with an attachment. For security reasons, only selected IP addresses can use this.


tmpl->print_footer(); } } ?>