apply code-formating-cleanup-convert-DOS-to-UNIX-text-form from https://github.com/zedzedtop/mailzu
This commit is contained in:
@@ -43,7 +43,6 @@ else {
|
||||
* Provide all database access/manipulation functionality
|
||||
*/
|
||||
class DBEngine {
|
||||
|
||||
// Reference to the database object
|
||||
var $db;
|
||||
|
||||
@@ -59,10 +58,10 @@ class DBEngine {
|
||||
var $dbUser;
|
||||
// Password for database user
|
||||
var $dbPass;
|
||||
|
||||
|
||||
var $err_msg = '';
|
||||
var $numRows;
|
||||
|
||||
|
||||
/**
|
||||
* DBEngine constructor to initialize object
|
||||
* @param none
|
||||
@@ -78,20 +77,19 @@ class DBEngine {
|
||||
|
||||
$this->db_connect();
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Create a persistent connection to the database
|
||||
* @param none
|
||||
* @global $conf
|
||||
*/
|
||||
function db_connect() {
|
||||
|
||||
/***********************************************************
|
||||
/ This uses PEAR::DB
|
||||
/ See http://www.pear.php.net/manual/en/package.database.php#package.database.db
|
||||
/ for more information and syntax on PEAR::DB
|
||||
/**********************************************************/
|
||||
|
||||
|
||||
// Data Source Name: This is the universal connection string
|
||||
// See http://www.pear.php.net/manual/en/package.database.php#package.database.db
|
||||
// for more information on DSN
|
||||
@@ -121,7 +119,7 @@ class DBEngine {
|
||||
|
||||
global $conf;
|
||||
|
||||
$return = array();
|
||||
$rval = array();
|
||||
$total = array( 'spam' => 0, 'banned' => 0, 'virus' => 0, 'header' => 0, 'pending' => 0, 'total' => 0);
|
||||
|
||||
$query = "SELECT date,
|
||||
@@ -147,7 +145,7 @@ class DBEngine {
|
||||
COUNT(msgs.content) AS banned,
|
||||
0 AS viruses,
|
||||
0 AS badheaders,
|
||||
0 AS pending
|
||||
0 AS pending
|
||||
FROM msgs INNER JOIN msgrcpt ON msgs.mail_id=msgrcpt.mail_id
|
||||
WHERE msgs.content='B' AND NOT (msgs.quar_type = '')
|
||||
AND msgrcpt.rs IN ('','v')
|
||||
@@ -199,7 +197,7 @@ class DBEngine {
|
||||
$timestamp = CmnFns::formatDateISO($rs['date']);
|
||||
$date = CmnFns::formatDate($timestamp);
|
||||
$totalthisdate = $rs['spam'] + $rs['banned'] + $rs['viruses'] + $rs['badheaders'] + $rs['pending'];
|
||||
$return[$date] = array('spam' => $rs['spam'],
|
||||
$rval[$date] = array('spam' => $rs['spam'],
|
||||
'banned' => $rs['banned'],
|
||||
'virus' => $rs['viruses'],
|
||||
'header' => $rs['badheaders'],
|
||||
@@ -208,16 +206,16 @@ class DBEngine {
|
||||
}
|
||||
|
||||
// Total the data
|
||||
foreach ($return as $date => $typearray) {
|
||||
foreach ($rval as $date => $typearray) {
|
||||
foreach ($typearray as $type => $count) {
|
||||
$total[$type] += $count;
|
||||
}
|
||||
}
|
||||
|
||||
$return['Total'] = $total;
|
||||
$rval['Total'] = $total;
|
||||
$result->free();
|
||||
|
||||
return $return;
|
||||
return $rval;
|
||||
}
|
||||
|
||||
// User methods -------------------------------------------
|
||||
@@ -231,7 +229,7 @@ class DBEngine {
|
||||
|
||||
global $conf;
|
||||
|
||||
$return = array();
|
||||
$rval = array();
|
||||
$total = array('spam' => 0, 'banned' => 0, 'virus' => 0, 'header' => 0, 'pending' => 0, 'total' => 0);
|
||||
|
||||
// Get where clause for recipient email address(es)
|
||||
@@ -268,7 +266,7 @@ class DBEngine {
|
||||
COUNT(msgs.content) AS banned,
|
||||
0 AS viruses,
|
||||
0 AS badheaders,
|
||||
0 AS pending
|
||||
0 AS pending
|
||||
FROM msgs INNER JOIN msgrcpt ON msgs.mail_id=msgrcpt.mail_id
|
||||
$join_type maddr AS recip ON msgrcpt.rid=recip.id
|
||||
WHERE msgs.content='B' AND NOT (msgs.quar_type = '') AND msgrcpt.rs IN ('','v')
|
||||
@@ -325,7 +323,7 @@ class DBEngine {
|
||||
$timestamp = CmnFns::formatDateISO($rs['date']);
|
||||
$date = CmnFns::formatDate($timestamp);
|
||||
$totalthisdate = $rs['spam'] + $rs['banned'] + $rs['viruses'] + $rs['badheaders'] + $rs['pending'];
|
||||
$return[$date] = array('spam' => $rs['spam'],
|
||||
$rval[$date] = array('spam' => $rs['spam'],
|
||||
'banned' => $rs['banned'],
|
||||
'virus' => $rs['viruses'],
|
||||
'header' => $rs['badheaders'],
|
||||
@@ -334,16 +332,16 @@ class DBEngine {
|
||||
}
|
||||
|
||||
// Total the data
|
||||
foreach ($return as $date => $typearray) {
|
||||
foreach ($rval as $date => $typearray) {
|
||||
foreach ($typearray as $type => $count) {
|
||||
$total[$type] += $count;
|
||||
}
|
||||
}
|
||||
|
||||
$return['Total'] = $total;
|
||||
$rval['Total'] = $total;
|
||||
$result->free();
|
||||
|
||||
return $return;
|
||||
return $rval;
|
||||
}
|
||||
|
||||
|
||||
@@ -375,7 +373,7 @@ class DBEngine {
|
||||
$sizeLimit = isset ( $conf['app']['displaySizeLimit'] ) && is_numeric( $conf['app']['displaySizeLimit'] ) ?
|
||||
$conf['app']['displaySizeLimit'] : 50;
|
||||
|
||||
$return = array();
|
||||
$rval = array();
|
||||
|
||||
if (is_array($search_array)) {
|
||||
$search_clause = "";
|
||||
@@ -418,20 +416,27 @@ class DBEngine {
|
||||
}
|
||||
}
|
||||
|
||||
$query = "SELECT msgs.time_num, msgs.from_addr,
|
||||
msgs.mail_id, msgs.subject, msgs.spam_level, msgs.content,
|
||||
msgrcpt.rs, msgs.quar_type, recip.email
|
||||
$query = "SELECT
|
||||
msgs.time_num,
|
||||
msgs.from_addr,
|
||||
msgs.mail_id,
|
||||
msgs.subject,
|
||||
msgs.spam_level,
|
||||
msgs.content,
|
||||
msgrcpt.rs,
|
||||
msgs.quar_type,
|
||||
recip.email
|
||||
FROM msgs
|
||||
INNER JOIN msgrcpt ON msgs.mail_id=msgrcpt.mail_id
|
||||
$join_type maddr AS sender ON msgs.sid=sender.id
|
||||
$join_type maddr AS recip ON msgrcpt.rid=recip.id
|
||||
INNER JOIN msgrcpt ON msgs.mail_id = msgrcpt.mail_id
|
||||
$join_type maddr AS sender ON msgs.sid = sender.id
|
||||
$join_type maddr AS recip ON msgrcpt.rid = recip.id
|
||||
WHERE $type_clause"
|
||||
// Only check against the email address when not admin
|
||||
. ($msgs_all ? ' ' : $emailaddr_clause)
|
||||
. " $rs_clause
|
||||
$search_clause
|
||||
AND msgs.quar_type <> ''
|
||||
ORDER BY $order $vert ";
|
||||
$search_clause
|
||||
AND msgs.quar_type <> ''
|
||||
ORDER BY $order $vert ";
|
||||
|
||||
// Prepare query
|
||||
$q = $this->db->prepare($query);
|
||||
@@ -456,7 +461,7 @@ class DBEngine {
|
||||
|
||||
if ( $get_all ) {
|
||||
while ($rs = $result->fetchRow()) {
|
||||
$return[] = $this->cleanRow($rs);
|
||||
$rval[] = $this->cleanRow($rs);
|
||||
}
|
||||
} else {
|
||||
// the row to start fetching
|
||||
@@ -469,13 +474,13 @@ class DBEngine {
|
||||
if (!$row = $result->fetchrow(DB_FETCHMODE_ASSOC, $rownum)) {
|
||||
break;
|
||||
}
|
||||
$return[] = $this->cleanRow($row);
|
||||
$rval[] = $this->cleanRow($row);
|
||||
}
|
||||
}
|
||||
|
||||
$result->free();
|
||||
|
||||
return $return;
|
||||
return $rval;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -486,7 +491,6 @@ class DBEngine {
|
||||
* @return array of message(s)
|
||||
*/
|
||||
function get_message($emailaddress, $mail_id) {
|
||||
|
||||
global $conf;
|
||||
|
||||
# MySQL seems to run faster with a LEFT JOIN
|
||||
@@ -498,7 +502,7 @@ class DBEngine {
|
||||
|
||||
$recipEmailClause = $this->convertEmailaddresses2SQL($emailaddress);
|
||||
|
||||
$return = array();
|
||||
$rval = array();
|
||||
|
||||
$query = 'SELECT msgs.time_num, msgs.secret_id, msgs.subject, msgs.from_addr, msgs.spam_level,'
|
||||
. ' msgrcpt.rs, recip.email, msgs.host, msgs.content, msgs.quar_type, msgs.quar_loc'
|
||||
@@ -522,12 +526,12 @@ class DBEngine {
|
||||
return NULL;
|
||||
}
|
||||
while ($rs = $result->fetchRow()) {
|
||||
$return[] = $this->cleanRow($rs);
|
||||
$rval[] = $this->cleanRow($rs);
|
||||
}
|
||||
|
||||
$result->free();
|
||||
|
||||
return $return;
|
||||
return $rval;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -539,7 +543,6 @@ class DBEngine {
|
||||
* @return array of message(s)
|
||||
*/
|
||||
function update_msgrcpt_rs($mail_id, $mail_rcpt, $flag) {
|
||||
|
||||
// If its a pending message, do not set the rs flag to 'v'
|
||||
$cur_msg_array = $this->get_message($mail_rcpt, $mail_id);
|
||||
$msg_status = $cur_msg_array[0];
|
||||
@@ -561,7 +564,6 @@ class DBEngine {
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Function that returns number of entries for logged in user
|
||||
* where RS flag is equal to $flag
|
||||
@@ -570,12 +572,11 @@ class DBEngine {
|
||||
* @return number of message(s)
|
||||
*/
|
||||
function get_count_rs($emailaddresses, $flag) {
|
||||
|
||||
// Get where clause for recipient email address(es)
|
||||
$emailaddr_clause = $this->convertEmailaddresses2SQL($emailaddresses);
|
||||
if ( $emailaddr_clause != '' )
|
||||
$emailaddr_clause = ' AND ' . $emailaddr_clause;
|
||||
|
||||
|
||||
$query = 'SELECT mail_id FROM msgrcpt, maddr as recip'
|
||||
. ' WHERE msgrcpt.rid=recip.id'
|
||||
. $emailaddr_clause
|
||||
@@ -588,12 +589,12 @@ class DBEngine {
|
||||
// Execute query
|
||||
$result = $this->db->execute($q, $values);
|
||||
// Check if error
|
||||
$this->check_for_error($result, $query);
|
||||
|
||||
$this->check_for_error($result, $query);
|
||||
|
||||
$count = $result->numRows();
|
||||
|
||||
|
||||
$result->free();
|
||||
|
||||
|
||||
return $count;
|
||||
}
|
||||
|
||||
@@ -617,7 +618,6 @@ class DBEngine {
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if (Auth::isMailAdmin()) {
|
||||
$values = array($mail_id);
|
||||
$query = 'SELECT' . $mail_text_column . ' FROM quarantine ' .
|
||||
@@ -640,14 +640,14 @@ class DBEngine {
|
||||
if ($result->numRows() <= 0){
|
||||
return false;
|
||||
}
|
||||
$return = "";
|
||||
$rval = "";
|
||||
while ($rs = $result->fetchRow()) {
|
||||
$return .= $rs['mail_text'];
|
||||
$rval .= $rs['mail_text'];
|
||||
}
|
||||
|
||||
$result->free();
|
||||
|
||||
return $return;
|
||||
return $rval;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -673,7 +673,7 @@ class DBEngine {
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Strips out slashes for all data in the return row
|
||||
* - THIS MUST ONLY BE ONE ROW OF DATA -
|
||||
@@ -681,11 +681,11 @@ class DBEngine {
|
||||
* @return array with same key => value pairs (except slashes)
|
||||
*/
|
||||
function cleanRow($data) {
|
||||
$return = array();
|
||||
$rval = array();
|
||||
|
||||
foreach ($data as $key => $val)
|
||||
$return[$key] = stripslashes($val);
|
||||
return $return;
|
||||
$rval[$key] = stripslashes($val);
|
||||
return $rval;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -705,11 +705,9 @@ class DBEngine {
|
||||
* @return array containing SQL code
|
||||
*/
|
||||
function convertSearch2SQL($field, $criterion, $string) {
|
||||
|
||||
$result = array();
|
||||
|
||||
if ( $string != '' ) {
|
||||
|
||||
if ( $string != '' ) {
|
||||
switch ($criterion) {
|
||||
case "contains":
|
||||
$search_clause = "(" . $field . " LIKE '%" . $string . "%')" ;
|
||||
@@ -728,7 +726,6 @@ class DBEngine {
|
||||
}
|
||||
array_push($result, $search_clause);
|
||||
}
|
||||
|
||||
return $result;
|
||||
}
|
||||
|
||||
@@ -796,8 +793,8 @@ class DBEngine {
|
||||
$this->check_for_error($result, $query);
|
||||
|
||||
if ($result->numRows() == 1) {
|
||||
$return = $result->fetchRow();
|
||||
return $return['id'];
|
||||
$rval = $result->fetchRow();
|
||||
return $rval['id'];
|
||||
} else if ($result->numRows() == 0
|
||||
&& strpos($recip_email,"@")) {
|
||||
|
||||
@@ -927,7 +924,7 @@ class DBEngine {
|
||||
|
||||
function get_user_control_list( $emailaddresses, $order = 'sender', $vert = 'ASC', $search_array, $page, $all = false) {
|
||||
global $conf;
|
||||
$return = Array();
|
||||
$rval = Array();
|
||||
|
||||
// grab the display size limit set in config.php
|
||||
$sizeLimit = (isset ( $conf['app']['displaySizeLimit'] ) && is_numeric( $conf['app']['displaySizeLimit'] ) ?
|
||||
@@ -980,13 +977,13 @@ class DBEngine {
|
||||
if (!$row = $result->fetchrow(DB_FETCHMODE_ASSOC, $rownum)) {
|
||||
break;
|
||||
}
|
||||
$return[] = $this->cleanRow($row);
|
||||
$rval[] = $this->cleanRow($row);
|
||||
}
|
||||
|
||||
|
||||
$result->free();
|
||||
|
||||
return $return;
|
||||
return $rval;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user