Location: PHPKode > scripts > Ramui web hosting directory script > Ramui web hosting directory script/gb/include/clsextend.php
<?php
/*
Copyright (c) 2011 http://ramui.com. All right reserved.
This product is protected by copyright and distributed under licenses restricting copying, distribution. Permission is granted to the public to download and use this script provided that this Notice and any statement of authorship are reproduced in every page on all copies of the script.
*/
class extension extends connection
{
function __construct($root)
{
        parent::__construct($root);
        if(($this->site['blocksite'])&&(empty($this->admin))){include "include/blocksite.php";exit;}
        if(!(isset($_SESSION['fw_user']))||($_SESSION['fw_user']!==md5($_SERVER['REMOTE_ADDRESS']))){echo '<h1>Your session has been expired!</h1><p>Please <a href="../index.php">Click here</a>to start a new session.</p>';exit;}
}

public function get_query()
{
		$query=@$_GET['query'];
		$qur= explode("M", $query);
		switch ($qur[0]){
			case "1":
				$this->contact_author($qur[1]);
			break;
			case "2":
				$this->send_mail($qur[1]);
			break;
			case "3":
				$this->save_report($qur[1]);
			break;
			case "4":
				$this->save_report($qur[1],$qur[2]);
			break;
			case "5":
				$this->contact();
			break;
			case "6":
				$this->contact_admin();
			break;
			case "7":
				$this->report_post($qur[1]);
			break;
			case "8":
				$this->report_comment($qur[1],$qur[2]);
			break;
			case "9":
				$this->affiliates($qur[1]);
			break;
			default: exit;
		}
}
private function contact_author($uid)
{
		if($this->site['allowemail']!=1){echo '<h1>Email system disabled</h1><p>Email system has been disabled by the administrator.</p>'; exit;}
		$max=$this->get_messagesize();
		$title='Contact author';
		$submit='2M'.$uid;
		include "include/contactform.php";
}
private function contact_admin()
{
		$max=$this->get_messagesize();
		$title='Contact admin';
		$submit='5M';
		include "include/contactform.php";
}
private function report_post($pid)
{
		$max=$this->get_messagesize();
		$title='Report against';
		$submit='3M'.$pid;
		include "include/contactform.php";
}
private function report_comment($pid,$cid)
{
		$max=$this->get_messagesize();
		$title='Report against';
		$submit='4M'.$pid.'M'.$cid;
		include "include/contactform.php";
}
private function get_messagesize()
{
		$result=@mysql_query("SELECT messagesize FROM ".$this->prefix."mailsettings");
		$row= @mysql_fetch_array($result, MYSQL_ASSOC);
		$max=(empty($row['messagesize'])? 1000:$row['messagesize']);
		return $max;
}
private function send_mail($id)
{
		$verify=trim(fw_strip_slashes(rawurldecode($_POST['verify'])));
		if((empty($_SESSION['fw_email_code']))||(md5($verify)!==($_SESSION['fw_email_code']))){
		echo '<span style="color:red; background-color:white;">Error! wrong verification code. Please try again.</span>';
		exit;}
		unset($_SESSION['fw_email_code']);
		$today = gmdate("F j, Y, g:i a");
		$name=trim(fw_strip_slashes(rawurldecode($_POST['name'])));
		$subject=trim(fw_strip_slashes(rawurldecode($_POST['subject'])));
		$from=trim(fw_strip_slashes(rawurldecode($_POST['from'])));
		if(!fw_validate_email($from)){echo '<span style="color:red">System error! please try again later.</span>';exit;}
		$message=trim(fw_strip_slashes(rawurldecode($_POST['message'])));
		$message=fw_remove_smarttag($message);
		$message.="\n\n--------------------------------------\n\nThis message is sent from http://".getenv('HTTP_HOST')."/\n";
		$message.="Sender I.P. ".$_SERVER['REMOTE_ADDR']."\nSender name: $name\nDate: $today GMT";
		$message.="\nIf you do not want to receive any further email from this site please login to your user control panel and uncheck \"Receive email\" option.\n";
		$message.="http://".getenv('HTTP_HOST').fw_get_docroot()."gb/user/index.php";
		
		$query=sprintf("SELECT name, email email ".$this->prefix."user WHERE id=%d AND allowemail = 'Y'",$id);
		$result = @mysql_query($query);
		$num=@mysql_num_rows($result);
		if($num<1){echo '<span style="color:red; background-color:white;">Sorry! unable to sent message.</span>';exit;}
		$row = @mysql_fetch_array($result, MYSQL_ASSOC);
		if(@mail($row['email'],$subject, $message, 'From: '.$from)){echo '<span style="color:green">Message has been successfully sent.</span>';}
		else{echo '<span style="color:red">System error! please try again later.</span>';}
}
private function save_report($pid,$cid='')
{
		$verify=trim(fw_strip_slashes(rawurldecode($_POST['verify'])));
		if((empty($_SESSION['fw_email_code']))||(md5($verify)!==($_SESSION['fw_email_code']))){
		echo '<span style="color:red; background-color:white;">Error! wrong verification code. Please try again.</span>';
		exit;}
		unset($_SESSION['fw_email_code']);
		$dt=time();
		$name=trim(fw_strip_slashes(rawurldecode($_POST['name'])));
		$subject=trim(fw_strip_slashes(rawurldecode($_POST['subject'])));
		$from=trim(fw_strip_slashes(rawurldecode($_POST['from'])));
		if(!fw_validate_email($from)){echo '<span style="color:red">System error! please try again later.</span>';exit;}
		$message=trim(fw_strip_slashes(rawurldecode($_POST['message'])));
		$message=fw_remove_smarttag($message);
		$message.="\n\n--------------------------------------\n\n";
		$message.="Sender I.P. ".$_SERVER['REMOTE_ADDR'];
		$query="INSERT INTO ".$this->prefix."report(name, subject, email, pid, cid, message, new, date) VALUES ('%s','%s','%s', %u, %u, '%s', 1, $dt)";
		$query=sprintf($query,mysql_real_escape_string($name),mysql_real_escape_string($subject),mysql_real_escape_string($from),$pid,$cid,mysql_real_escape_string($message));
		if(@mysql_query($query)){echo '<span style="color:green">Message has been successfully sent.</span>';}
		else{echo '<span style="color:red">System error! please try again later.</span>';}
}

private function contact()
{
		$verify=trim(fw_strip_slashes(rawurldecode($_POST['verify'])));
		if((empty($_SESSION['fw_email_code']))||(md5($verify)!==($_SESSION['fw_email_code']))){
		echo '<span style="color:red; background-color:white;">Error! wrong verification code. Please try again.</span>';
		exit;}
		unset($_SESSION['fw_email_code']);
		$dt=time();
		$name=trim(fw_strip_slashes(rawurldecode($_POST['name'])));
		$subject=trim(fw_strip_slashes(rawurldecode($_POST['subject'])));
		$from=trim(fw_strip_slashes(rawurldecode($_POST['from'])));
		if(!fw_validate_email($from)){echo '<span style="color:red">System error! please try again later.</span>';exit;}
		$msg=trim(fw_strip_slashes(rawurldecode($_POST['message'])));
		$msg=fw_remove_smarttag($msg);
		$message=$msg."\n\n--------------------------------------\n\n";
		$message.="Sender I.P. ".$_SERVER['REMOTE_ADDR'];
		$query="INSERT INTO ".$this->prefix."inbox(name,subject, email, message, new, date) VALUES ('%s','%s','%s', '%s', 1, $dt)";
		$query=sprintf($query,mysql_real_escape_string($name),mysql_real_escape_string($subject),mysql_real_escape_string($from),mysql_real_escape_string($message));
		if(@mysql_query($query)){
			@mysql_query("SELECT* FROM ".$this->prefix."mailsettings LIMIT 0,1");
			$row= @mysql_fetch_array($result, MYSQL_ASSOC);
			if($row['autoresponder']){
				$s1=str_replace("%%SENDER%%",$name,$row['response']);
				$s1=str_replace("%%EMAIL%%",$from,$s1);
				$s1=str_replace("%%MESSAGE%%",$msg,$s1);
				@mail($from,'Re: '.$subject, $s1, 'From: '.$row['defaultfrom']);}
			echo '<span style="color:green">Message has been successfully sent.</span>';}
		else{echo '<span style="color:red">System error! please try again later.</span>';}
}
private function affiliates($id)
{
		$query=sprintf("SELECT url, afflink FROM ".$this->prefix."post WHERE id = %d",$id);
		$result=@mysql_query($query);
		$row= @mysql_fetch_array($result, MYSQL_ASSOC);
		$url=(empty($row['afflink'])? $row['url'] : $row['afflink']);
		@header("Location: $url");exit;
}
}
?>
Return current item: Ramui web hosting directory script