Current File : //root/panel/modules/mailinfo/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 $BlockOk;
static $UnBlockOk;
static $WhiteOk;
static function getMailInfo()
{
global $zdbh;
global $controller;
$currentuser = ctrl_users::GetUserDetail();
$cmd='';
if ($currentuser['usergroup'] == "Administrators" || $currentuser['usergroup'] == "Resellers") {
$cmd='cat /var/log/mail_php.log | cut -d " " -f3- | sort | uniq -c '." | sed -e 's/^[ \t]*//' ";
}
else
{
$userid=$currentuser['userid'];
$sql="select * from x_vhosts where vh_acc_fk='".$userid."'";
$numrows = $zdbh->prepare($sql);
$numrows->execute();
if ($numrows->fetchColumn() <> 0) {
// $cmd='cat /var/log/mail_php.log | cut -d " " -f3- | sort | uniq -c '." | sed -e 's/^[ \t]*//' ";
$cmd='cat /var/log/mail_php.log ';
$sql = $zdbh->prepare($sql);
$sql->execute();
while ($resultarray = $sql->fetch()) {
if($resultarray['vh_directory_vc']!="")
$cmd.=' | grep "'.$resultarray['vh_directory_vc'].'" ';
}
$cmd.=' | cut -d " " -f3- | sort | uniq -c ';
$cmd.=" | sed -e 's/^[ \t]*//' ";
}
}
if($cmd!='')
{
$line="";
$line="<pre>";
$line.=shell_exec($cmd);
$line.="</pre>";
}else
{
$line="No data available";
}
return $line;
}
static function getViewBlockedList()
{
$currentuser = ctrl_users::GetUserDetail();
return self::ListViewBlockedList($currentuser['userid'],$currentuser['username'],$currentuser['usergroupid']);
}
static function ListViewBlockedList($uid,$username,$groupid)
{
global $zdbh;
global $controller;
$sql="";
if($groupid==1 || $groupid==2 )
{
$sql="select * from x_php_page_block where x_status='0'";
}else
{
$filepath=ctrl_options::GetSystemOption('hosted_dir').$username;
$sql="select * from x_php_page_block where x_status='0' And x_filepath LIKE '%".$filepath."%'";
}
//$numrows = $zdbh->query($sql);
$numrows = $zdbh->prepare($sql);
$numrows->execute();
if ($numrows->fetchColumn() <> 0) {
$sql = $zdbh->prepare($sql);
$res = array();
$sql->execute();
while ($resultarray = $sql->fetch()) {
$scriptname=explode("/",$resultarray['x_filepath']);
$res[] = array(
'path' => $resultarray['x_filepath'],
'scriptname' => $scriptname[count($scriptname)-1],
'id' => $resultarray['x_id']);
}
return $res;
}
else
{
return false;
}
}
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 getViewUnBlockedList()
{
$currentuser = ctrl_users::GetUserDetail();
return self::ListViewUnBlockedList($currentuser['userid'],$currentuser['username'],$currentuser['usergroupid']);
}
static function ListViewUnBlockedList($uid,$username,$groupid)
{
global $zdbh;
global $controller;
$sql="";
if($groupid==1 || $groupid==2 )
{
$sql="select * from x_php_page_block where x_status='1'";
}else
{
$filepath=ctrl_options::GetSystemOption('hosted_dir').$username;
$sql="select * from x_php_page_block where x_status='1' And x_filepath LIKE '%".$filepath."%'";
}
//$numrows = $zdbh->query($sql);
$numrows = $zdbh->prepare($sql);
$numrows->execute();
if ($numrows->fetchColumn() <> 0) {
$sql = $zdbh->prepare($sql);
$res = array();
$sql->execute();
while ($resultarray = $sql->fetch()) {
$scriptname=explode("/",$resultarray['x_filepath']);
$res[] = array(
'path' => $resultarray['x_filepath'],
'scriptname' => $scriptname[count($scriptname)-1],
'id' => $resultarray['x_id']);
}
return $res;
}
else
{
return false;
}
}
static function getViewWhiteList()
{
$currentuser = ctrl_users::GetUserDetail();
return self::ListViewWhiteList($currentuser['userid'],$currentuser['username'],$currentuser['usergroupid']);
}
static function ListViewWhiteList($uid,$username,$groupid)
{
global $zdbh;
global $controller;
$sql="";
if($groupid==1 || $groupid==2 )
{
$sql="select * from x_php_page_block where x_status='2'";
}else
{
$filepath=ctrl_options::GetSystemOption('hosted_dir').$username;
$sql="select * from x_php_page_block where x_status='2' And x_filepath LIKE '%".$filepath."%'";
}
//$numrows = $zdbh->query($sql);
$numrows = $zdbh->prepare($sql);
$numrows->execute();
if ($numrows->fetchColumn() <> 0) {
$sql = $zdbh->prepare($sql);
$res = array();
$sql->execute();
while ($resultarray = $sql->fetch()) {
$scriptname=explode("/",$resultarray['x_filepath']);
$res[] = array(
'path' => $resultarray['x_filepath'],
'scriptname' => $scriptname[count($scriptname)-1],
'id' => $resultarray['x_id']);
}
return $res;
}
else
{
return false;
}
}
static function doUpdateFlag()
{
global $zdbh;
global $controller;
runtime_csfr::Protect();
$currentuser = ctrl_users::GetUserDetail();
$formvars = $controller->GetAllControllerRequests('FORM');
$getflag=$formvars['flag'];
$getid=$formvars['operationid'];
$sql="select * from x_php_page_block where x_id='".$getid."'";
$sql = $zdbh->prepare($sql);
$sql->execute();
$resultarray = $sql->fetch();
$getpath=$resultarray['x_filepath'];
if($getflag=="block")
{
//block
$cmd_chmod="chmod 000 ".$getpath;
passthru($cmd_chmod);
$sql="Update x_php_page_block SET x_count='0',x_status='0' where x_id='".$getid."'";
$sql = $zdbh->prepare($sql);
$sql->execute();
self::$BlockOk=true;
return true;
}
else if($getflag=="unblock")
{
// unblock
$cmd_chmod="chmod 777 ".$getpath;
passthru($cmd_chmod);
$sql="Update x_php_page_block SET x_count='0',x_status='1' where x_id='".$getid."'";
$sql = $zdbh->prepare($sql);
$sql->execute();
self::$UnBlockOk=true;
return true;
}
else if($getflag=="white")
{
// whitelist
$cmd_chmod="chmod 777 ".$getpath;
passthru($cmd_chmod);
$sql="Update x_php_page_block SET x_count='0',x_status='2' where x_id='".$getid."'";
$sql = $zdbh->prepare($sql);
$sql->execute();
self::$WhiteOk=true;
return true;
}
}
static function getResult()
{
if (!fs_director::CheckForEmptyValue(self::$BlockOk)) {
return ui_sysmessage::shout(ui_language::translate("Script have been Blocked successfully!"), "ok");
}
if (!fs_director::CheckForEmptyValue(self::$UnBlockOk)) {
return ui_sysmessage::shout(ui_language::translate("Script have been Unblocked successfully!"), "ok");
}
if (!fs_director::CheckForEmptyValue(self::$WhiteOk)) {
return ui_sysmessage::shout(ui_language::translate("Script have been Whitlisted successfully!"), "ok");
}
return;
}
static function getisadmin()
{
global $controller;
$currentuser = ctrl_users::GetUserDetail();
if ($currentuser['usergroup'] == "Administrators" || $currentuser['usergroup'] == "Resellers") {
return true;
} else {
return false;
}
}
}