Current File : //etc/sentora/panel/modules/mailq_management/code/controller.ext.php |
<?php
/**
* @copyright 2014-2015 Sentora Project (http://www.sentora.org/)
* Sentora is a GPL fork of the ZPanel Project whose original header follows:
*
* ZPanel - A Cross-Platform Open-Source Web Hosting Control panel.
*
* @package ZPanel
* @version $Id$
* @author Bobby Allen - ballen@bobbyallen.me
* @copyright (c) 2008-2014 ZPanel Group - http://www.zpanelcp.com/
* @license http://opensource.org/licenses/gpl-3.0.html GNU Public License v3
*
* This program (ZPanel) 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, either version 3 of the License, 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 License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
*/
class module_controller extends ctrl_module
{
static $socket_err;
static $ok;
static function getLogInfo()
{
$cmd='mailq 2>&1';
$line="";
$line="<pre>";
$line.="</br>-----------------------------------------------------------------------</br>";
$line.=shell_exec($cmd);
$line.="</pre>";
return $line;
}
static function gethelpicon()
{
global $zdbh;
global $controller;
$temp=$controller->GetControllerRequest('URL','module') ;
$val = '/assets/one.txt';
$val1 = '/modules/';
$name=file_get_contents("modules/$temp/assets/helpicon.txt");
return $name;
}
static function getMailList()
{
$cmd="mailq | tail -n +2 | awk '{print $1}' 2>&1 ";
$output=array();
$out=shell_exec($cmd);
$output=explode("\n",$out);
$res=array();
for($i=0; $i<count($output)-1; $i++)
{
if(strpos($output[$i],'@')===false && strpos($output[$i],'(')===false && trim($output[$i])!="")
{
//$line.=$output[$i]." - ".$output[$i+2]."</br/>";
if(($i+2)<(count($output)))
{
$temp=array();
$temp["email_id"]=$output[$i];
$temp["receipient"]=$output[$i+2];
array_push($res, $temp);
}
}
}
return $res;
}
static function doEditMail()
{
if($_POST['do_operation']=="Delete")
{
$command="Dltmailq ".str_replace("*","",$_POST['do_value']);
$service_port = 4444 ;
$address = gethostbyname('localhost');
$socket = socket_create(AF_INET, SOCK_STREAM, SOL_TCP);
if ($socket === false) {
self::$socket_err = true;
return false;
}
$result = socket_connect($socket, $address, $service_port);
if ($result === false) {
self::$socket_err = true;
return false;
}
socket_set_option($socket, SOL_SOCKET, SO_RCVTIMEO, array("sec" =>1, "usec" =>0));
$in="command " . $command ;
$out = '';
socket_write($socket, $in, strlen($in));
$output = "" ;
socket_close($socket);
self::$ok = true;
return true;
}
else if($_POST['do_operation']=="DeleteAll")
{
$command="DltAllMailq";
$service_port = 4444 ;
$address = gethostbyname('localhost');
$socket = socket_create(AF_INET, SOCK_STREAM, SOL_TCP);
if ($socket === false) {
self::$socket_err = true;
return false;
}
$result = socket_connect($socket, $address, $service_port);
if ($result === false) {
self::$socket_err = true;
return false;
}
socket_set_option($socket, SOL_SOCKET, SO_RCVTIMEO, array("sec" =>1, "usec" =>0));
$in="command " . $command ;
$out = '';
socket_write($socket, $in, strlen($in));
$output = "" ;
socket_close($socket);
self::$ok = true;
return true;
}
else if($_POST['do_operation']=="DeleteSelected")
{
$command="DltSelMailq ".$_POST['do_value'];
$service_port = 4444 ;
$address = gethostbyname('localhost');
$socket = socket_create(AF_INET, SOCK_STREAM, SOL_TCP);
if ($socket === false) {
self::$socket_err = true;
return false;
}
$result = socket_connect($socket, $address, $service_port);
if ($result === false) {
self::$socket_err = true;
return false;
}
socket_set_option($socket, SOL_SOCKET, SO_RCVTIMEO, array("sec" =>1, "usec" =>0));
$in="command " . $command ;
$out = '';
socket_write($socket, $in, strlen($in));
$output = "" ;
socket_close($socket);
self::$ok = true;
return true;
}
else if($_POST['do_operation']=="DeleteAllDeferred")
{
$command="DeleteAllDeferred ";
$service_port = 4444 ;
$address = gethostbyname('localhost');
$socket = socket_create(AF_INET, SOCK_STREAM, SOL_TCP);
if ($socket === false) {
self::$socket_err = true;
return false;
}
$result = socket_connect($socket, $address, $service_port);
if ($result === false) {
self::$socket_err = true;
return false;
}
socket_set_option($socket, SOL_SOCKET, SO_RCVTIMEO, array("sec" =>1, "usec" =>0));
$in="command " . $command ;
$out = '';
socket_write($socket, $in, strlen($in));
$output = "" ;
socket_close($socket);
self::$ok = true;
return true;
}
}
static function getshowmessage()
{
$output=shell_exec("postcat -q 34E5A6A0D44");
return $output."------------------------------------";
}
static function getResult()
{
if (!fs_director::CheckForEmptyValue(self::$socket_err)) {
return ui_sysmessage::shout(ui_language::translate("Could you please try again later.."), "Error");
}
if (!fs_director::CheckForEmptyValue(self::$ok)) {
return ui_sysmessage::shout(ui_language::translate("Message removed successfully.."), "Success");
}
}
}