Current time: 02-09-2012, 01:55 AM Hello There, Guest! (LoginRegister)

Thread Closed 
 
Thread Rating:
  • 0 Votes - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Application
11-29-2009, 03:52 PM (This post was last modified: 11-29-2009 03:53 PM by Nelson.)
Post: #1
Application
Your Name: Nelson (but just call me simmaster. DO IT)

Your Programming Skills: PHP, (X)HTML 1.1, CSS 3.0, Bash, C#, VB.NET

Experience with Version Control Systems: Getting started with Subversion / CVS

Past Projects: Simple SMF-integrated cPanel manager (screenie)

Why Do You Want to Be a Part of This Project: I use THT for my own host and I want to make it better. I'm a wiki contributor at the moment and I want to get involved in development, especially since I'm obsessed with PHP. Big Grin

Nelson - Retired TheHostingTool Developer
[Image: sleek.png]
Find all posts by this user
11-29-2009, 04:07 PM
Post: #2
Application
Your application is currently pending. Wink

Kevin Mark - TheHostingTool Lead Developer
Visit this user's website Find all posts by this user
12-02-2009, 04:31 PM
Post: #3
RE: Application
I find it cruelly hilarious how I delete my SMF cP manager and replace it with THT. The minute I read Jonny's PM about the application, he asks for the code from it.

Nelson - Retired TheHostingTool Developer
[Image: sleek.png]
Find all posts by this user
12-02-2009, 04:47 PM
Post: #4
RE: Application
D:. well, he needs to see your skills Big Grin

Nick - TheHostingTool Staff Coordinator

[Image: standard.png]

Visit this user's website Find all posts by this user
12-02-2009, 06:36 PM
Post: #5
RE: Application
Just send us any sort of code you've done. Build anything. Just want to see some work Tongue

Jonny H - THT Main Developer & Founder
Find all posts by this user
12-02-2009, 07:35 PM
Post: #6
RE: Application
I'm working on it! Tongue

Nelson - Retired TheHostingTool Developer
[Image: sleek.png]
Find all posts by this user
12-05-2009, 11:59 AM
Post: #7
RE: Application
So here's my incomplete OOP code:
WHM.php
Code:
<?php
if(!defined("Hosticali"))
    die();
class WHM
{
    private var $sess = array();
    private var $currSess;
    private var $defaultserv;
    private var $core;
    private var $log;
    public function __construct()
    {
        global $url;
        require_once($url . "/lib/Core.php");
        require_once($url . "/lib/Log.php");
        $this->core = new Core();
        $this->log  = new Logs();
        $this->core->Query("SELECT * FROM `<PRE>whm_servs`");
        while($arr = $this->core->GetArray())
        {
            if($arr['default'] === TRUE)
            {
                $this->currSess = $arr['identifier'];
                $this->defaultserv = $arr['identifier'];
            }
            $sess[$arr['identifier']] = array(
                'host' => $arr['host'],
                'user' => $arr['user'],
                'hash' => $arr['hash'],
                'chsh' => preg_replace('(/r|/n)', "", $arr['hash']),
                'sslc' => $arr['sslc']
            );
        }
    }
    public function switchSess($identifier)
    {
        if(!$this->sess[$identifier])
            return false;
        $this->currSess = $identifier;
        return true;
    }
    private function api($url)
    {
        $accessURL = "http" . ($this->sess[$this->currSess]['sslc'] === TRUE ? "s" : "") . "://" . $data['host'] . ":208" . ($this->sess[$this->currSess]['sslc'] === TRUE ? "7" : "6") . "/xml-api/" . $url;
        $ch = curl_init();
        curl_setopt($ch, CURLOPT_URL, $accessURL);
        if($this->sess[$this->currSess]['sslc'] === TRUE)
        {
            curl_setopt($ch, CURLOPT_HTTPAUTH, CURLAUTH_ANY);
            curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
        }
        curl_setopt($ch, CURLOPT_HEADER, 0);
        curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
        $curlheaders[0] = "Authorization: WHM " . $this->sess[$this->currSess]['chsh'];
        curl_setopt($ch, CURLOPT_HTTPHEADER, $curlheaders);
        $data = curl_exec($ch);
        curl_close($ch);
        $xml = new SimpleXMLElement($data);
        return $xml;
    }
    public function Create($postVars)
    {
        $username = $postVars['user'];
        $domain   = $postVars['domain'];
        $plan     = $postVars['plan'];
        $resell   = $postVars['isReseller'];
    }
    public function toggleSuspend($user, $reason = false)
    {
        $this->core->Query('SELECT * FROM `<PRE>whm_users` WHERE `user` = "' . mysql_real_escape_string($user) . '" LIMIT 1');
        $arr = $this->core->GetArray();
        if($arr['suspended'] === FALSE)
        {
            $result = new SimpleXMLElement($this->api("suspendacct?user=" . $user . ($reason !=== false ? "&reason=" . $reason : "")))
            if($result->result[0]->status[0] != 1)
                return $result;
            $this->core->Query('UPDATE `<PRE>whm_users` SET `suspended` = "TRUE", `reason` = "' . mysql_real_escape_string($reason) . '" WHERE `user` = "' . mysql_real_escape_string($user) . '" LIMIT 1');
            $this->log->AddEntry('Suspended [[Username:;:' . mysql_real_escape_string($user) . ']]' . ($reason !=== false ? " for [[Reason:;:" . mysql_real_escape_string($reason) . "]]" : ""));
        }
        else
        {
            $result = new SimpleXMLElement($this->api("unsuspendacct?user=" . $user));
            if($result->result[0]->status[0] != 1)
                return $result;
            $this->core->Query('UPDATE `<PRE>whm_users` SET `suspended` = "FALSE", `reason` = "" WHERE `user` = "' . mysql_real_escape_string($user) . '" LIMIT 1');
            $this->log->AddEntry();
        }
        return true;
    }
    public function Terminate($user, $reason = false)
    {
        $result = new SimpleXMLElement($this->api("removeacct?user=" . $user));
        if($result->result[0]->status[0] != 1)
            return $result;
        $this->log->AddEntry();
        return true;
    }
    public function changePwd($user, $pwd)
    {
    }
    public function changePkg($user, $pkg)
    {
    }
    public function Summary($user)
    {
    }
    public function listSuspended()
    {
    }
    public function Privileges($user)
    {
    }
    public function toggleResell($user)
    {
    }
    public function listResellers()
    {
    }
    public function LoadAvg()
    {
    }
}
?>

Core.php
Code:
<?php
if(!defined("Hosticali"))
    die();
class Core
{    
    /**** Database Session Variables ***/
    public var $result;
    public var $sess = array();
    public var $currentSess;
    public var $handle = array();
    
    public function __construct()
    {
        global $url;
        $settings = getSettings();
        $sess['default'] = array(
            'host' => $host,
            'user' => $user,
            'pass' => $pass,
            'dbse' => $dbse,
            'pfix' => $pfix
        );
        $this->currentSess = 'default';
        $this->handle['default'] = mysql_connect(
            $this->sess[$this->currentSess]['host'],
            $this->sess[$this->currentSess]['user'],
            $this->sess[$this->currentSess]['pass']
        );
        if(!$this->checkErr('handle', 'default'))
            return false;
        mysql_select_db(
            $this->sess[$this->currentSess]['dbse'],
            $this->handle[$this->currentSess]
        );
        if(!$this->checkErr('handle', 'default'))
            return false;
        else
            return true;
    }
    public function checkErr($type, $id = false)
    {
        if($type == "result")
        {
            if(!$this->result)
                return false;
            else
                return true;
        }
        else
        {
            if(!$this->handle[$id])
                return false;
            else
                return true;
        }
    }
    public function switchSess($identifier)
    {
        if(!$this->handle[$identifier])
            return false;
        $this->currentSess = $identifier;
        $this->result = false;
        $this->handle[$identifier] = mysql_connect(
            $this->sess[$this->currentSess]['host'],
            $this->sess[$this->currentSess]['user'],
            $this->sess[$this->currentSess]['pass']
        );
        if(!$this->checkErr('handle', $identifier))
            return false;
        mysql_select_db(
            $this->sess[$this->currentSess]['dbse'],
            $this->handle
        );
        if(!$this->checkErr('handle', $identifier))
            return false;
        else
            return true;
    }
    public function addSess($identifier, $host, $user, $pass, $dbse, $pfix)
    {
        $this->sess[$identifier] = array(
            'host' => $host,
            'user' => $user,
            'pass' => $pass,
            'dbse' => $dbse,
            'pfix' => $pfix
        );
        return true;
    }
    public function destroySess($identifier)
    {
        mysql_close($this->handle[$identifier]);
        unset($this->handle[$identifier], $this->sess[$identifier]);
        return true;
    }
    public function Query($sql)
    {
        $this->result = mysql_query(str_ireplace("<PRE>", $this->sess[$this->currentSess]['pfix'], $sql), $this->handle[$currentSess]);
        if(!$this->checkErr('result'))
            return false;
        else
            return true;
    }
    public function FreeResult()
    {
        $oldResult = $this->result;
        mysql_free_result($this->result, $this->handle[$currentSess]);
        if(!$this->checkErr('result'))
        {
            $this->result = $oldResult;
            return false;
        }
        else
            return true;
    }
    public function Clean($sql)
    {
        return mysql_real_escape_string($sql, $this->handle[$currentSess]);
    }
    public function GetArray()
    {
        return mysql_fetch_assoc($this->result);
    }
    public function NumRows()
    {
        return mysql_num_rows($this->result);
    }
    public function Affected()
    {
        return mysql_affected_rows($this->handle[$currentSess]);
    }
}
?>

Nelson - Retired TheHostingTool Developer
[Image: sleek.png]
Find all posts by this user
12-05-2009, 12:25 PM
Post: #8
RE: Application
Excellent.

Jonny H - THT Main Developer & Founder
Find all posts by this user
12-09-2009, 01:12 AM
Post: #9
Application
Your developer application has been accepted! Welcome to TheHostingTool Dev Team!

Kevin Mark - TheHostingTool Lead Developer
Visit this user's website Find all posts by this user
Thread Closed 


Forum Jump:


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