Location: PHPKode > scripts > Ramui web hosting directory script > Ramui web hosting directory script/gb/admin/include/clsreport.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 clsreport extends clsmain
{
private function show_report($page)
{
        $search='';
        if(!empty($_GET['SearchFileString'])){$search=htmlspecialchars(fw_strip_slashes($_GET['SearchFileString']));}
        $this->build_head("Message list", "");
		$query="SELECT id FROM ".$this->prefix."report WHERE subject LIKE '%%%s%%' OR message LIKE '%%%s%%' OR email LIKE '%%%s%%'";
        $result = @mysql_query(sprintf($query,mysql_real_escape_string($search),mysql_real_escape_string($search),mysql_real_escape_string($search)));
        $num_rows = @mysql_num_rows($result);
        $start_count=($page-1)*$this->list_perpage;
        $totalpage=fw_total_page($num_rows, $this->list_perpage);
		$query ="SELECT id, subject, email, new, date FROM ".$this->prefix."report WHERE subject LIKE '%%%s%%' OR message LIKE '%%%s%%' OR email LIKE '%%%s%%'";
		$query.="ORDER BY date Desc LIMIT ".$start_count.", ".$this->list_perpage;
		$query=sprintf($query,mysql_real_escape_string($search),mysql_real_escape_string($search),mysql_real_escape_string($search));
        echo '<table id="list"><tr><td width="66%" class="heading" style="border-left:1px solid #888888;">Subject</td>';
		echo '<td width="20%" class="heading" style="border-right:#888888;">From</td>';
		echo '<td width="14%" class="heading" style="border-right:#888888;">Date</td></tr>';
		echo '<tr><td colspan="3"><a title="Remove filter" href="index.php?qur=5M">Message list:</a></td></tr>';
        $result = @mysql_query($query);
        while($row = @mysql_fetch_array($result, MYSQL_ASSOC))
        {
            echo '<tr onMouseOver="this.className=\'highlight\'" onMouseOut="this.className=\'normal\'">';
			$src='<img title= "Read" src="images/mailread.gif" alt="R" />';$class='approved';
			if($row['new']){$src='<img title="Unread" src="images/mailunread.gif" alt="U" />';$class='pending';}
            echo '<td>'.$src.'<a class="'.$class.'" href="index.php?qur=5M1M'.$row['id'].'">'.$row['subject'].'</a></td>';
			echo '<td>'.$row['email'].'</td>';
            echo '<td>'.gmdate("M d, H:i", $row['date']).'</td></tr>';
        }
        echo '<tr><td colspan="3"><b>No. of pages:&nbsp;'.$totalpage.'</b>&nbsp;&nbsp;&nbsp;';
        $start=(($page>10)? $page-10 : 1);
        $end=(($totalpage<=21)? $totalpage : $start+20);
        echo(($page>1)? '<a href="index.php?qur=5M6M'.($page-1).'&SearchFileString='.$search.'">Back</a>&nbsp;' : '<span style="color:#808080;">Back</span>&nbsp;');
        for($p=$start; $p<=$end; $p++){
             if($p==$page){echo '<span style="color:#808080;">['.$p.']</span>&nbsp;';}
             else{echo '[<a href="index.php?qur=5M6M'.$p.'&SearchFileString='.$search.'">'.$p.'</a>]&nbsp;';}
        }
        echo(($page<$totalpage)? '<a href="index.php?qur=5M6M'.($page+1).'&SearchFileString='.$search.'">Next</a>&nbsp;' : '<span style="color:#808080;">Next</span>&nbsp;');
        echo '</td></tr>';
        echo '<tr><td colspan="3" style="background:#e0e0e0; padding-bottom:0;">';
        echo '<form name="frmSearchList" style="float:right; margin:0; color:#000000;" onSubmit="return fw_search(\'index.php?qur=5M6M1\');">';
        echo 'Search file:&nbsp;<input name="txtSearch" style="padding-left:5px; width:180px; font-size:11px; color:#666666;" type="text" value="';
        echo (($search=='')? 'Type few characters...' : $search);
        echo '" size="20" onclick="fw_cleartext(this,\'Type few characters...\');">&nbsp;<input name="Submit" type="button" style="width:80px; font-size:11px; color:#333333;" value="Search" onClick="fw_search(\'index.php?qur=5M6M1\');"></form></td></tr></table>';
        echo '</div>';
        $this->build_footer();
}
private function show_message($id)
{
        @mysql_query(sprintf("UPDATE ".$this->prefix."report SET new = 0 WHERE id = %d",$id));
		$query=sprintf("SELECT* FROM ".$this->prefix."report WHERE id = %d",$id);
        $result= @mysql_query($query);
        $row = @mysql_fetch_array($result, MYSQL_ASSOC);
		$message=nl2br(htmlentities($row['message']));
		$against='<a target="_blank" href="http://'.getenv('HTTP_HOST').fw_get_docroot().'index.php?pid='.$row['pid'].((empty($row['cid']))? '' : '#'.$row['cid']).'">Open</a> | <a href="index.php?qur=';
		$against.=(empty($row['cid'])? '2M1M'.$row['pid']:'9M1M'.$row['cid']).'">Edit</a>';
		$this->build_head("Report: ".$id,'<script type="text/javascript" src="script/mailreport.js"></script>');
        include 'include/showreport.php';
        $this->build_footer();
}
private function delete_message($id)
{
		@mysql_query(sprintf("DELETE FROM ".$this->prefix."report WHERE id = %d",$id));
		@header("Location: index.php?qur=5M");exit;
}
private function download_message($id)
{
        $query=sprintf("SELECT* FROM ".$this->prefix."report WHERE id = %d",$id);
        $result= @mysql_query($query);
        $row = @mysql_fetch_array($result, MYSQL_ASSOC);
		$s="Message from: ".(empty($row['name'])? "Unknown sender" : $row['name'])." (".$row['email'].")\r\n";
		$s.="Report against: http://".getenv('HTTP_HOST').fw_get_docroot()."index.php?pid=".$row['pid'].((empty($row['cid']))? "" : "#".$row['cid']);
		$s.="\r\nSubject: ".$row['subject']."\r\nDate: ".gmdate("M d, H:i", $row['date'])."\r\n------------------------------------------------------------\r\n\r\n";
		$s.=$row['message'];
		$f='message'.$row['id'].'.rtf';
        @header("Content-type: application/text");
        @header("Content-Disposition: attachment; filename=$f");
        echo $s;
        exit;
}
public function get_query($query)
{
if ($this->validate_user()){
      switch ($query[1]) {
          case "1":
              $this->show_message($query[2]);
          break;
          case "2":
              $this->delete_message($query[2]);
          break;
          case "3":
              $this->download_message($query[2]);
          break;
          case "5":
              $this->log_out();
          break;
          case "6":
              $this->show_report($query[2]);
          break;
          default :
              $this->show_report(1);
      }
}
else {if(($query[1]==6)||($query[1]==1)||empty($query[1])){$this->log_in();}}
}
}
?>
Return current item: Ramui web hosting directory script