Current time: 04-20-2014, 05:04 PM Hello There, Guest! (LoginRegister)

Post Reply 
 
Thread Rating:
  • 0 Votes - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Froxlor and THT Integration
02-23-2012, 10:59 AM (This post was last modified: 02-23-2012 10:59 AM by ineedhelp.)
Post: #1
Froxlor and THT Integration
Hello,

i recently found this thread here where a user offered his Froxlor class for THT, but I don't know how to use it. Could anyone help me?

Code:
<?php

class altruFroxlor {
        private $logWriter;
        private $froxlorDB;
        private $admin_id;
        private $ip_id;
        private $ssl_ip_id;
        private $docroot_path;
        
        function __construct($ip,$port,$frox_db_username,$frox_db_password,$frox_db_name){
                include("config/config.inc.php");
                include("config/froxlor.inc.php");
                include_once("classes/altrulog.class.php");
                require_once('MDB2.php');

                //global $error_log;
                //global $debug_log;
                //global $debug;
                $this->logWriter = new altruLogging($error_log,$debug_log,$debug);              

                $this->admin_id = $froxlor_admin_id;
                $this->logWriter->debugwrite("altrufroxlor.class.php - __Construct - admin_id = $this->admin_id");
                $this->ip_id = $froxlor_ip_id;
                $this->logWriter->debugwrite("altrufroxlor.class.php - __Construct - ip_id = $this->ip_id");
                $this->ssl_ip_id = $froxlor_ssl_ip_id;
                $this->logWriter->debugwrite("altrufroxlor.class.php - __Construct - ssl_ip_id = $this->ssl_ip_id");
                $this->docroot_path = $froxlor_docroot_path;
                $this->logWriter->debugwrite("altrufroxlor.class.php - __Construct - docroot_path = $this->docroot_path");
                
                $strFroxlorDB = "mysql://$frox_db_username:$frox_db_password@$ip:$port/$frox_db_name";
                $this->logWriter->debugwrite("altrufroxlor.class.php - __Construct - using db connection string: $strFroxlorDB");
                $this->froxlorDB = MDB2::connect($strFroxlorDB);
                if (MDB2::isError($this->froxlorDB)) {
                        $this->logWriter->writelog("altrufroxlor.class.php - __Construct - Error openning DB: " .
                        MDB2::errorMessage($this->froxlorDB));
                        die();
                }
                //$this->froxlorDB->loadModule('Extended');
        }
        
        public function createCustomer($uid,$pwd,$hdd,$transfer,$name,$firstname,$eml,$dbqty,
                $emlqty,$ftpqty,$domqty,$apsqty){
                $cust_qry = "INSERT INTO  panel_customers (`adminid`, `loginname`, `password`, `name`,
                `firstname`, `company`, `street`, `zipcode`, `city`, `phone`, `fax`, `email`,
                `customernumber`, `def_language`, `documentroot`, `guid`, `diskspace`, `traffic`,
                `subdomains`, `emails`, `email_accounts`, `email_forwarders`, `email_quota`, `ftps`,
                `tickets`, `mysqls`, `standardsubdomain`, `phpenabled`, `imap`, `pop3`, `aps_packages`,
                `perlenabled`, `email_autoresponder`) VALUES (?,?,?,?,?,'','','','','','',?,'',
                'English',?,'',?,?,?,?,?,?,?,?,0,?,0,1,1,1,?,1,0)";
                $values = array($this->admin_id,$uid,md5($pwd),$name,$firstname,$eml,$this->docroot_path.$uid."/",$hdd*1024,
                $transfer*1024*1024,$domqty,$emlqty,$emlqty,$emlqty,"100",$ftpqty,$dbqty,$apsqty);
                $cust_ps = $this->froxlorDB->prepare($cust_qry);
                if (MDB2::isError($cust_ps)) {
                        $this->logWriter->writelog("altrufroxlor.class.php - createCustomer - error preparing cust_qry: " .
                        MDB2::errorMessage($cust_ps));
                        die();
                }
                $cust_rslt = $cust_ps->execute($values);
                if (MDB2::isError($cust_rslt)) {
                        $this->logWriter->writelog("altrufroxlor.class.php - createCustomer - error executing cust_qry: " .
                        MDB2::errorMessage($cust_rslt). "\n" . $cust_rslt->getDebugInfo());
                        die();
                }
                $cust_id = mysql_insert_id();
                $gid = $cust_id + 10000;
                $cust_gid_qry = "Update panel_customers set guid = $gid where customerid = $cust_id";
                $cust_gid_rslt = $this->froxlorDB->query($cust_gid_qry);
                if (MDB2::isError($cust_gid_rslt)) {
                        $this->logWriter->writelog("altrufroxlor.class.php - createCustomer - error executing cust_gid_qry: " .
                        MDB2::errorMessage($cust_gid_rslt));
                        die();
                }
                $ftp_qry = "INSERT INTO ftp_users (`customerid`, `username`, `password`, `homedir`,
                `login_enabled`, `uid`, `gid`) " . "VALUES (?,?,ENCRYPT(?),?,'Y',?,?)";
                $values = array($cust_id,$uid,$pwd,$this->docroot_path.$uid,$gid,$gid);
                $ftp_ps = $this->froxlorDB->prepare($ftp_qry);
                if (MDB2::isError($ftp_ps)) {
                        $this->logWriter->writelog("altrufroxlor.class.php - createCustomer - error preparing ftp_qry: " .
                        MDB2::errorMessage($ftp_ps));
                        die();
                }
                $ftp_rslt = $ftp_ps->execute($values);
                if (MDB2::isError($ftp_rslt)) {
                        $this->logWriter->writelog("altrufroxlor.class.php - createCustomer - error executing ftp_qry: " .
                        MDB2::errorMessage($ftp_rslt));
                        die();
                }      
                $ftp_grp_qry = "INSERT INTO ftp_groups (`groupname`,`gid`,`members`,`customerid`) Values(?,?,?,?)";
                $values = array($uid,$gid,$uid,$cust_id);
                $ftp_grp_ps = $this->froxlorDB->prepare($ftp_grp_qry);
                if (MDB2::isError($ftp_grp_ps)) {
                        $this->logWriter->writelog("altrufroxlor.class.php - createCustomer - error preparing ftp_grp_qry: " .
                        MDB2::errorMessage($ftp_grp_ps));
                        die();
                }
                $ftp_grp_rslt = $ftp_grp_ps->execute($values);
                if (MDB2::isError($ftp_grp_rslt)) {
                        $this->logWriter->writelog("altrufroxlor.class.php - createCustomer - error executing ftp_grp_qry: " .
                        MDB2::errorMessage($ftp_grp_rslt));
                        die();
                }      
                $add_cron_task = "Insert into panel_tasks (type) Values(5)";
                $rslt_qry = $this->froxlorDB->query($add_cron_task);
                $add_cron_task = "Insert into panel_tasks (type) Values(4)";
                $rslt_qry = $this->froxlorDB->query($add_cron_task);
                $add_cron_task = "Insert into panel_tasks (type) Values(1)";
                $rslt_qry = $this->froxlorDB->query($add_cron_task);
                return $cust_id;                
        }
        
        public function createDomain($cust_id, $domain, $uid){
                $dom_qry = "Insert into `panel_domains` (`domain`,`adminid`,`customerid`,`documentroot`,`ipandport`,`isbinddomain`,
                `isemaildomain`,`ssl`,`ssl_redirect`,`ssl_ipandport`) Values(?,?,?,?,?,1,1,1,0,?)";
                $values = array($domain,$this->admin_id,$cust_id,$this->docroot_path.$uid,$this->ip_id,
                $this->ssl_ip_id);
                $dom_ps = $this->froxlorDB->prepare($dom_qry);
                if (MDB2::isError($dom_ps)) {
                        $this->logWriter->writelog("altrufroxlor.class.php - createDomain - error preparing dom_qry: " .
                        MDB2::errorMessage($dom_ps));
                        die();
                }
                $dom_rslt = $dom_ps->execute($values);
                if (MDB2::isError($dom_rslt)) {
                        $this->logWriter->writelog("altrufroxlor.class.php - createCustomer - error executing dom_qry: " .
                        MDB2::errorMessage($dom_rslt));
                        //die();
                }
                $dom_id = mysql_insert_id();
                return $dom_id;
        }
        public function addAPSInstall($cust_id,$package_id,$settings){
                $instance_qry = "Insert into aps_instances (CustomerID,PackageID,Status)
                        Values(?,?,1)";
                $values = array($cust_id,$package_id);
                $instance_ps = $this->froxlorDB->prepare($instance_qry);
                if (MDB2::isError($instance_ps)) {
                        $this->logWriter->writelog("altrufroxlor.class.php - addAPSInstall - error preparing instance_qry: " .
                        MDB2::errorMessage($instance_ps));
                        die();
                }
                $rslt = $instance_ps->execute($values);
                if (MDB2::isError($rslt)) {
                        $this->logWriter->writelog("altrufroxlor.class.php - addAPSInstall - error executing instance_qry: " .
                        MDB2::errorMessage($rslt));
                        die();
                }
                $instance_id = mysql_insert_id();
                
                $settings_qry = "Insert into aps_settings (InstanceID,Name,Value)
                        Values(?,?,?)";
                $settings_ps = $this->froxlorDB->prepare($settings_qry);
                if (MDB2::isError($settings_ps)) {
                        $this->logWriter->writelog("altrufroxlor.class.php - addAPSInstall - error preparing settings_qry: " .
                        MDB2::errorMessage($settings_ps));
                        die();
                }
                foreach ($settings as $name => $value) {
            $values = array ($instance_id,$name,$value);
            $rslt = $settings_ps->execute($values);
                        if (MDB2::isError($rslt)) {
                                $this->logWriter->writelog("altrufroxlor.class.php - addAPSInstall - error executing settings_qry: " .
                                MDB2::errorMessage($rslt));
                                $this->logWriter->writelog("Name: $name, Value: $value");
                                die();
                        }      
        }
        
        $task_qry = "Insert into aps_tasks (InstanceID,Task)
                        Values($instance_id,1)";
                $rslt = $this->froxlorDB->query($task_qry);
                if (MDB2::isError($rslt)) {
                        $this->logWriter->writelog("altrufroxlor.class.php - addAPSInstall - error executing task_qry: " .
                        MDB2::errorMessage($rslt));
                        die();
                }
        }
}
function renderOpenCP($uid,$pwd,$server,$bAutoClick=false,$bNewWindow=true){
        if ($bAutoClick) {
                echo "<body onLoad=\"document.forms['loginform'].submit();\">\n";
        }
        echo "<form ";
        if ($bNewWindow) {
                echo "target=_blank ";
        }
        echo "action=\"https://$server/index.php\" method=\"post\" name=\"loginform\">
        <input type=\"hidden\" name=\"loginname\" value=\"$uid\">
        <input type=\"hidden\" name=\"password\" value=\"$pwd\">
        <input type=\"hidden\" name=\"language\" value=\"profile\">
        <input type=\"hidden\" name=\"send\" value=\"send\">
        <input type=\"hidden\" name=\"action\" value=\"login\">
        <input type=\"submit\" value=\"Froxlor CP\" title=\"Open Froxlor Control Panel\" class=\"stnd_btn\">
        </form>";
}
?>

I just created a new file in /includes/servers called froxlor.php and inserted the whole code there but i doesn't appear in the "add server"-section in THT, what do I have to do?

I would really appreciate it if someone out there could help me.
Sorry for my bad english.

ineedhelp Smile
Find all posts by this user
Quote this message in a reply
Post Reply 


Messages In This Thread
Froxlor and THT Integration - ineedhelp - 02-23-2012 10:59 AM
RE: Froxlor and THT Integration - Kevin - 02-24-2012, 10:31 PM
RE: Froxlor and THT Integration - Liam D. - 02-25-2012, 07:32 AM
RE: Froxlor and THT Integration - Kevin - 02-26-2012, 07:02 PM
RE: Froxlor and THT Integration - Liam D. - 03-01-2012, 08:10 AM
RE: Froxlor and THT Integration - Kevin - 03-01-2012, 09:53 PM
RE: Froxlor and THT Integration - Liam D. - 03-06-2012, 07:45 AM
RE: Froxlor and THT Integration - zbdblues - 09-28-2013, 06:02 AM
RE: Froxlor and THT Integration - Kevin - 09-29-2013, 01:23 AM

Forum Jump:


User(s) browsing this thread: 1 Guest(s)