Current File : //etc/zpanel/panel/modules/parkeddomainlist/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 $complete;
    static $error;
    static $writeerror;
    static $nosub;
    static $alreadyexists;
    static $badname;
    static $blank;
    static $ok;
	static $ok_switch;
	static $ans_switch="";
    /**
     * The 'worker' methods.
     */
	 static function getisadmin()
	 {
		 global $controller;
        $currentuser = ctrl_users::GetUserDetail();
        if ($currentuser['usergroup'] == "Administrators" || $currentuser['usergroup'] == "Resellers") {
            return true;
        } else {
            return false;
        }
		 
	 }
	
    static function ListDomains($uid = 0)
    {
              global $zdbh;
            // $sql = "SELECT * FROM x_vhosts WHERE vh_deleted_ts IS NULL AND vh_type_in=2 ORDER BY vh_name_vc ASC";
			 $sql = "SELECT vh_acc_fk,vh_name_vc,vh_directory_vc,vh_id_pk,ac_user_vc FROM x_vhosts,x_accounts WHERE x_accounts.ac_id_pk=x_vhosts.vh_acc_fk AND vh_deleted_ts IS NULL AND vh_type_in=3 ORDER BY vh_name_vc ASC";
            $numrows = $zdbh->prepare($sql);
        
        //$numrows = $zdbh->query($sql);
        $numrows->execute();
        if ($numrows->fetchColumn() <> 0) {
                $sql = $zdbh->prepare($sql);
           
            $res = array();
            $sql->execute();
            while ($rowdomains = $sql->fetch()) {
				
                array_push($res, array(
                    'uid' => $rowdomains['vh_acc_fk'],
                    'name' => $rowdomains['vh_name_vc'],
                    'directory' => $rowdomains['vh_directory_vc'],
					'username' => $rowdomains['ac_user_vc'],
                    'id' => $rowdomains['vh_id_pk'],
                ));
            }
            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 getDomainList()
    {
		global $zdbh;
        $currentuser=1;
        $domains = self::ListDomains($currentuser);
        if (!fs_director::CheckForEmptyValue($domains)) {
            foreach ($domains as $row) {
				// NEED TO WRITE A SUBQUERY 
			   $sql1 = "SELECT vh_name_vc FROM x_vhosts WHERE vh_id_pk=(SELECT x_domain_id FROM x_main_domain WHERE x_user_id='". $row['uid']."') AND vh_deleted_ts IS NULL";
			
				$maindomain="";  
				//$numrows1 = $zdbh->prepare($sql1);
				//$numrows1->execute();
				//if ($numrows1->fetchColumn() <> 0) {		
				$sql1 = $zdbh->prepare($sql1);
				$sql1->execute();
				$rowdomains1 = $sql1->fetch();
				$maindomain=$rowdomains1['vh_name_vc'];
				//}
                $res[] = array('name' => $row['name'],
                    'directory' => $row['directory'],
                    'username' => $row['username'],
					'maindomain'=>$maindomain,
                    'id' => $row['id']);
            }
				//exit;
            return $res;
        } else {
            return false;
        }
    }

    /**
     * Webinterface sudo methods.
     */
	 
}