funchat/modules/contact/contact.output.php

76 lines
3.2 KiB
PHP

<?php
/**
* Project: astat - simple site engine
* File: /modules/contact/contact.output.php
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; version 2 of the License.
*
* 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 License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*
* @link http://www.astat.org SVN: $URL$
* @copyright 2009 becast.at
* @author Bernhard Jaud <bernhard at becast dot at>
* @package astat core
* @license http://opensource.org/licenses/gpl-license.php GNU Public License
* @version $Id$
*/
If (!defined("INBCWE")) {
die("Dieses Script kann nicht ausserhalb des Frameworks laufen!");
}
$session->page_begin("Contactform", FALSE);
class contact extends module{
function output(){
global $module,$config,$db,$log,$core,$error;
$emsg=FALSE;
if(isset($_POST['submit'])){
if(!isset($_POST['name']) || $_POST['name']==""){
$emsg.='<span style="color:red; font-weight:bold">Du musst deinen Namen eingeben!</span><br />';
}elseif(!isset($_POST['email']) || $_POST['email']==""){
$emsg.='<span style="color:red; font-weight:bold">Du musst deine E-Mailadresse eingeben!</span><br />';
}elseif(!isset($_POST['subject']) || $_POST['subject']==""){
$emsg.='<span style="color:red; font-weight:bold">Du musst einen Betreff eingeben!</span><br />';
}elseif(!isset($_POST['message']) || $_POST['message']==""){
$emsg.='<span style="color:red; font-weight:bold">Du musst eine Nachricht eingeben!</span><br />';
}
if(!preg_match("/^[_a-zA-Z0-9-]+(\.[_a-zA-Z0-9-]+)*@[a-zA-Z0-9-]+(\.[a-zA-Z0-9-]+)*\.(([0-9]{1,3})|([a-zA-Z]{2,3})|(aero|coop|info|museum|name))$/",$_POST['email'])){
$emsg.='<span style="color:red; font-weight:bold">Deine E-Mail ist ung&uuml;ltig!</span><br />';
}
if($config['contact_captcha']==1){
include ('thirdparty/securimage/securimage.php');
$img = new Securimage();
if(!$img->check($_POST['captcha'])){
$emsg.='<span style="color:red; font-weight:bold">Das CAPTCHA ist ung&uuml;ltig!</span><br />';
}
}
if(!$emsg){
$mail=new mail();
$mail->set_header("From",$config["sitetitle"]." <".$config["siteemail"].">");
$this->tpl->assign('post',$_POST);
$this->tpl->assign("sitename",$config["sitetitle"]);
$mailbody=$this->tpl->fetch('contact_mail.tpl');
$mail->bodytext($mailbody);
$mail->sendmail($config["contact_email"],"Kontakt von ".$_POST["name"]);
$core->message("Danke","Deine Nachricht wurde versendet.<br />Wir werden so schnell wie m&ouml;glich Kontakt mit Dir aufnehmen.",TRUE,$config["path"]."/index.php",3);
}
}
$this->tpl->assign('post',$_POST);
$this->tpl->assign('emsg',$emsg);
$this->tpl->assign('captcha',$config['contact_captcha']);
$this->tpl->assign('sid',md5(uniqid(time())));
return $this->tpl->fetch('contactform.tpl', 'contactform');
}
}
?>