Current File : //etc/sentora/panel/modules/authentication/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 $error;
static $alreadyexists;
static $blank;
static $badname;
static $invalidPath;
static $ok;
static $delete;
static $reset;
static $create;
static $endkim;
/**
* The 'worker' methods.
*/
static function ListDkim($uid)
{
global $zdbh;
$currentuser = ctrl_users::GetUserDetail($id);
//$sql = "SELECT * FROM x_dns WHERE dn_acc_fk=:userid AND dn_name_vc IN (SELECT vh_name_vc FROM x_vhosts WHERE vh_id_pk IN(SELECT x_domain_id FROM x_main_domain WHERE x_user_id=:userid) AND vh_deleted_ts IS NULL) AND dn_type_vc='TXT' AND dn_deleted_ts IS NULL";
$sql = "SELECT * FROM x_dns WHERE dn_acc_fk=:userid AND dn_name_vc IN (SELECT vh_name_vc FROM x_vhosts WHERE vh_deleted_ts IS NULL) AND dn_type_vc='TXT' AND dn_deleted_ts IS NULL AND dn_target_vc like '%dkim%'";
$numrows = $zdbh->prepare($sql);
$numrows->bindParam(':userid', $currentuser['userid']);
$numrows->execute();
$dkim = $numrows->fetchColumn();
if ($dkim != 0) {
return true;
} else {
return false;
}
}
static function getshowtarget()
{
global $zdbh;
$currentuser = ctrl_users::GetUserDetail($id);
//$sql = "SELECT * FROM x_dns WHERE dn_acc_fk=:userid AND dn_name_vc IN (SELECT vh_name_vc FROM x_vhosts WHERE vh_id_pk IN(SELECT x_domain_id FROM x_main_domain WHERE x_user_id=:userid) AND vh_deleted_ts IS NULL) AND dn_type_vc='TXT' AND dn_deleted_ts IS NULL";
$sql = "SELECT * FROM x_dns WHERE dn_acc_fk=:userid AND dn_name_vc IN (SELECT vh_name_vc FROM x_vhosts WHERE vh_deleted_ts IS NULL) AND dn_type_vc='TXT' AND dn_deleted_ts IS NULL AND dn_target_vc like '%dkim%'";
$numrows = $zdbh->prepare($sql);
$numrows->bindParam(':userid', $currentuser['userid']);
$numrows->execute();
$dkim = $numrows->fetchColumn();
if ($dkim != 0) {
$sql = $zdbh->prepare($sql);
$sql->bindParam(':userid', $currentuser['userid']);
$sql->execute();
$res = array();
while ($rowdomain = $sql->fetch()) {
$res[] = array('domain' => $rowdomain['dn_name_vc'],'target' => $rowdomain['dn_target_vc']);
//print_r($res);
//exit;
}
return $res;
}
else {
return false;
}
return "";
}
static function getshowtargetspf()
{
global $zdbh;
$currentuser = ctrl_users::GetUserDetail($id);
//$sql = "SELECT * FROM x_dns WHERE dn_acc_fk=:userid AND dn_name_vc IN (SELECT vh_name_vc FROM x_vhosts WHERE vh_id_pk IN(SELECT x_domain_id FROM x_main_domain WHERE x_user_id=:userid) AND vh_deleted_ts IS NULL) AND dn_type_vc='SPF' AND dn_deleted_ts IS NULL";
$sql = "SELECT * FROM x_dns WHERE dn_acc_fk=:userid AND dn_name_vc IN (SELECT vh_name_vc FROM x_vhosts WHERE vh_deleted_ts IS NULL) AND dn_type_vc='TXT' AND dn_deleted_ts IS NULL AND dn_target_vc like '%spf%'";
$numrows = $zdbh->prepare($sql);
$numrows->bindParam(':userid', $currentuser['userid']);
$numrows->execute();
$dkim = $numrows->fetchColumn();
if ($dkim != 0) {
$sql = $zdbh->prepare($sql);
$sql->bindParam(':userid', $currentuser['userid']);
$sql->execute();
$res = array();
while ($rowdomain = $sql->fetch()) {
$res[] = array('domain' => $rowdomain['dn_name_vc'],'target' => $rowdomain['dn_target_vc']);
//print_r($res);
//exit;
}
return $res;
}
else {
return false;
}
return "";
}
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 ListSpf($uid)
{
global $zdbh;
$currentuser = ctrl_users::GetUserDetail($id);
//echo $currentuser['userid'];
//print_r($currentuser);
//$sql = "SELECT * FROM x_dns WHERE dn_acc_fk=:userid AND dn_name_vc IN (SELECT vh_name_vc FROM x_vhosts WHERE vh_id_pk IN(SELECT x_domain_id FROM x_main_domain WHERE x_user_id=:userid) AND vh_deleted_ts IS NULL) AND dn_type_vc='SPF' AND dn_deleted_ts IS NULL";
$sql = "SELECT * FROM x_dns WHERE dn_acc_fk=:userid AND dn_name_vc IN (SELECT vh_name_vc FROM x_vhosts WHERE vh_deleted_ts IS NULL) AND dn_type_vc='TXT' AND dn_deleted_ts IS NULL AND dn_target_vc like '%spf%'";
$numrows = $zdbh->prepare($sql);
$numrows->bindParam(':userid', $currentuser['userid']);
$numrows->execute();
$dkim = $numrows->fetchColumn();
if ($dkim != 0) {
$sql = $zdbh->prepare($sql);
$sql->bindParam(':userid', $uid);
$sql->execute();
return true;
} else {
return false;
}
}
static function getDkimList()
{
$currentuser = ctrl_users::GetUserDetail();
$clientlist = self::ListDkim($currentuser['userid']);
return $clientlist;
}
static function getSpfList()
{
$currentuser = ctrl_users::GetUserDetail();
$clientlist = self::ListSpf($currentuser['userid']);
return $clientlist;
}
static function getCurrentID()
{
global $controller;
$id = $controller->GetControllerRequest('URL', 'id');
return ($id) ? $id : '';
}
static function getisEnableDKIM()
{
global $controller;
$urlvars = $controller->GetAllControllerRequests('URL');
return (isset($urlvars['show'])) && ($urlvars['show'] == 'Enable');
}
static function doEnableDKIM()
{
global $controller;
runtime_csfr::Protect();
$formvars = $controller->GetAllControllerRequests('FORM');
if (isset($formvars['inEnable'])) {
if (self::ExecuteEnableDKIM($formvars['inEnable'])) {
self::$endkim = TRUE;
return true;
}
}
return false;
}
static function ExecuteEnableDKIM($id)
{
global $zdbh;
echo "hai";
exit;
$sql = $zdbh->prepare("UPDATE x_ssl
SET ssl_delete=:time
WHERE ssl_no=:id");
$time = time();
$sql->bindParam(':time', $time);
$sql->bindParam(':id', $id);
//$sql->execute();
$retval = TRUE;
return $retval;
}
static function getResult()
{
if (!fs_director::CheckForEmptyValue(self::$blank)) {
return ui_sysmessage::shout(ui_language::translate("You must enter a valid username and password to create your FTP account."), "zannounceerror");
}
if (!fs_director::CheckForEmptyValue(self::$alreadyexists)) {
return ui_sysmessage::shout(ui_language::translate("An FTP account with that name already exists."), "zannounceerror");
}
if (!fs_director::CheckForEmptyValue(self::$error)) {
return ui_sysmessage::shout(ui_language::translate("There was an error updating your FTP accounts."), "zannounceerror");
}
if (!fs_director::CheckForEmptyValue(self::$badname)) {
return ui_sysmessage::shout(ui_language::translate("Your ftp account name is not valid. Please enter a valid ftp account name."), "zannounceerror");
}
if (!fs_director::CheckForEmptyValue(self::$endkim)) {
return ui_sysmessage::shout(ui_language::translate("SSL Certificate deleted successfully."), "zannounceok");
}
if (!fs_director::CheckForEmptyValue(self::$invalidPath)) {
return ui_sysmessage::shout(ui_language::translate("Invalid Folder."), "zannounceok");
}
if (!fs_director::CheckForEmptyValue(self::$ok)) {
return ui_sysmessage::shout(ui_language::translate("FTP accounts updated successfully."), "zannounceok");
}
return;
}
/**
* Webinterface sudo methods.
*/
}