private function getFile($name, $prepare = 1, $override = 0, $showit = 0)
 {
     global $dbh, $postvar, $getvar, $instance;
     $link = "../themes/" . THEME . "/" . $name;
     if (!file_exists($link) || $override == 1) {
         $link = INC . "/" . $name;
     }
     if (!file_exists($link)) {
         $link = "../install/" . $name;
     }
     if (!file_exists($link)) {
         $link = $name;
     }
     if (!file_exists($link) && INSTALL == 1) {
         $error['Error'] = "File doesn't exist!";
         $error['Path'] = $link;
         main::error($error);
     } else {
         if ($prepare) {
             return self::prepare(file_get_contents($link));
         } else {
             return file_get_contents($link);
         }
     }
 }
Exemple #2
0
 private function EditEmailTemplates()
 {
     global $dbh, $postvar, $getvar, $instance;
     if (main::isint($getvar['do'])) {
         if ($postvar['edittpl']) {
             check::empty_fields();
             if (!main::errors()) {
                 $dbh->update("templates", array("subject" => $postvar['subject']), array("id", "=", $getvar['do']));
                 $template_info = $dbh->select("templates", array("id", "=", $getvar['do']));
                 $tmpl_file_base = INC . "/tpl/email/" . $template_info['dir'] . "/" . $template_info['name'];
                 if (!is_writable($tmpl_file_base . ".tpl")) {
                     main::errors("In order to make changes to this file (" . $tmpl_file_base . ".tpl), please make it writable.");
                 } else {
                     $contents = stripslashes($postvar['emailcontent']);
                     if ($contents) {
                         $filetochangeOpen = fopen($tmpl_file_base . ".tpl", "w");
                         if (!fputs($filetochangeOpen, $contents)) {
                             main::errors("Could not write the template file, " . $tmpl_file_base . ".tpl");
                         }
                         fclose($filetochangeOpen);
                     }
                     if (!main::errors()) {
                         main::errors("Template edited!");
                     }
                 }
             }
         }
         $template_data = $dbh->select("templates", array("id", "=", $getvar['do']));
         if (!$template_data['id']) {
             $error_array['Error'] = "Template not found.";
             $error_array['Template ID'] = $getvar['do'];
             main::error($error_array);
         } else {
             $tmpl_file_base = INC . "/tpl/email/" . $template_data['dir'] . "/" . $template_data['name'];
             $tmpl_content_file = @file_get_contents($tmpl_file_base . ".tpl");
             $tmpl_descrip_file = @file_get_contents($tmpl_file_base . ".desc.tpl");
             if (!$tmpl_content_file && !$tmpl_descrip_file) {
                 $error_array['Error'] = "One of the template files don't exist.<br>";
                 $error_array['Template Locations'] = "<br>" . $tmpl_file_base . ".tpl<br>" . $tmpl_file_base . ".desc.tpl";
                 main::error($error_array);
             } else {
                 $edit_email_template_array['SUBJECT'] = $template_data['subject'];
                 $edit_email_template_array['DESCRIPTION'] = $tmpl_descrip_file;
                 $edit_email_template_array['TEMPLATE'] = $tmpl_content_file;
             }
         }
         echo style::replaceVar("tpl/admin/mail/edit-email-template.tpl", $edit_email_template_array);
         return;
     }
     if (main::isint($postvar['template'])) {
         main::redirect("?page=email&sub=templates&do=" . $postvar['template']);
     }
     $templates_query = $dbh->select("templates", 0, array("acpvisual", "ASC"));
     while ($templates_data = $dbh->fetch_array($templates_query)) {
         $values[] = array($templates_data['acpvisual'], $templates_data['id']);
     }
     $select_email_template_array['TEMPLATES'] = main::dropDown("template", $values, 0, 1);
     echo style::replaceVar("tpl/admin/mail/select-email-template.tpl", $select_email_template_array);
 }
Exemple #3
0
 public function content()
 {
     global $dbh, $postvar, $getvar, $instance;
     // An honest attempt to make this system a little less painful (for me)...
     if (array_key_exists("sub", $getvar) && !empty($getvar["sub"])) {
         $sub = "_" . strtolower($getvar["sub"]);
         if (method_exists($this, $sub)) {
             $this->{$sub}();
             return;
         }
         main::error(array(__FILE__ => "<code>\$this->{$sub}</code> isn't a method."));
     }
 }
Exemple #4
0
 public function client($id = 0)
 {
     if (!$id) {
         $id = $_SESSION['cuser'];
     }
     $id = $this->strip($id);
     $users_query = $this->select("users", array("id", "=", $id), 0, 0, 1);
     if ($this->num_rows($users_query) == 0) {
         $error['Error'] = "Couldn't retrieve client data!";
         $error['Username'] = $id;
         main::error($error);
     } else {
         $all_values = $this->fetch_array($users_query);
         return $all_values;
     }
 }
Exemple #5
0
 private function remote($action, $url, $get = false, $returnErrors = false)
 {
     $server_details = $this->serverDetails($this->server);
     $ch = curl_init();
     $ip = gethostbyname($server_details['host']);
     if ($server_details['https']) {
         //Usually 2222
         if ($server_details['apiport'] != 443) {
             $port = $server_details['apiport'];
         }
         $serverstuff = "https://" . $server_details['user'] . ":" . $server_details['accesshash'] . "@" . $server_details['host'] . ":" . $port . "/" . $action;
         curl_setopt($ch, CURLOPT_URL, $serverstuff);
         curl_setopt($ch, CURLOPT_HTTPAUTH, CURLAUTH_ANY);
         curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
     } else {
         //Usually 2222
         if ($server_details['apiport'] != 80) {
             $port = $server_details['apiport'];
         }
         $serverstuff = "http://" . $server_details['user'] . ":" . $server_details['accesshash'] . "@" . $server_details['host'] . ":" . $port . "/" . $action;
         curl_setopt($ch, CURLOPT_URL, $serverstuff);
     }
     if ($get) {
         curl_setopt($ch, CURLOPT_URL, $serverstuff . $url);
     } else {
         curl_setopt($ch, CURLOPT_URL, $serverstuff);
         curl_setopt($ch, CURLOPT_POST, 1);
         curl_setopt($ch, CURLOPT_POSTFIELDS, $url);
     }
     curl_setopt($ch, CURLOPT_HEADER, 0);
     curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
     curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
     curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 10);
     curl_setopt($ch, CURLOPT_TIMEOUT, 10);
     $curl_data = curl_exec($ch);
     if ($curl_data === false) {
         if ($returnErrors) {
             return curl_error($ch);
         }
         main::error(array("DA Connection Error" => curl_error($ch)));
         return false;
     }
     curl_close($ch);
     $split = explode("&", $curl_data);
     foreach ($split as $value) {
         $stuff = explode("=", $value);
         $final[$stuff[0]] = $stuff[1];
     }
     return $final;
 }
Exemple #6
0
 private function serverDetails($server)
 {
     global $dbh, $postvar, $getvar, $instance;
     $servers_data = $dbh->select("servers", array("id", "=", $server));
     if (!$servers_data['id']) {
         $error_array['Error'] = "That server doesn't exist!";
         $error_array['Server ID'] = $id;
         main::error($error_array);
         return;
     } else {
         return $servers_data;
     }
 }
 public function emailTemplate($name = 0, $id = 0)
 {
     global $dbh, $postvar, $getvar, $instance;
     if ($name) {
         $templates_data = $dbh->select("templates", array("name", "=", $name));
     } elseif ($id) {
         $templates_data = $dbh->select("templates", array("id", "=", $id));
     } else {
         $error_array['Error'] = "No name/id was sent onto the reciever!";
         main::error($error_array);
         return;
     }
     if (!$templates_data['id']) {
         $error_array['Error'] = "That template doesn't exist!";
         $error_array['Template Name/ID'] = $name . $id;
         main::error($error_array);
     } else {
         $tmpl_file_base = INC . "/tpl/email/" . $templates_data['dir'] . "/" . $templates_data['name'];
         $tmpl_content_file = @file_get_contents($tmpl_file_base . ".tpl");
         $tmpl_descrip_file = @file_get_contents($tmpl_file_base . ".desc.tpl");
         if (!$tmpl_content_file && !$tmpl_descrip_file) {
             $error_array['Error'] = "One of the template files don't exist.<br>";
             $error_array['Template locations'] = "<br>" . $tmpl_file_base . ".tpl<br>" . $tmpl_file_base . ".desc.tpl";
             main::error($error_array);
         } else {
             $template_data = array("id" => $templates_data['id'], "name" => $templates_data['name'], "acpvisual" => $templates_data['acpvisual'], "subject" => $templates_data['subject'], "content" => $tmpl_content_file, "description" => $tmpl_descrip_file);
             return $template_data;
         }
     }
 }
Exemple #8
0
 private function forumCon($id)
 {
     global $dbh, $postvar, $getvar, $instance;
     $forum_conn_details = $this->forumdata($id);
     $forumcon = $dbh->connect($forum_conn_details['hostname'], $forum_conn_details['username'], $forum_conn_details['password'], $forum_conn_details['forumdb']);
     if (is_string($forumcon)) {
         $error_array['Error'] = $forumcon;
         $error_array['Forum ID'] = $id;
         main::error($error_array);
         return;
     } else {
         return $forumcon;
     }
 }
Exemple #9
0
 public function checkPerms($id, $user = 0)
 {
     global $dbh, $postvar, $getvar, $instance;
     if (!$user) {
         $user = $_SESSION['user'];
     }
     $staff_data = $dbh->select("staff", array("id", "=", $user));
     if (!$staff_data['id']) {
         $error_array['Error'] = "Staff member not found";
         $error_array['Staff ID'] = $user;
         main::error($error_array);
     } else {
         $perms = explode(",", $staff_data['perms']);
         foreach ($perms as $value) {
             if ($value == $id) {
                 return false;
             }
         }
         return true;
     }
 }
Exemple #10
0
 public function packageBackend($id)
 {
     global $dbh, $postvar, $getvar, $instance;
     $packages_data = $dbh->select("packages", array("id", "=", $id));
     if (!$packages_data['id']) {
         $error_array['Error'] = "That package doesn't exist!";
         $error_array['Package ID'] = $id;
         main::error($error_array);
         return;
     } else {
         return $packages_data['backend'];
     }
 }
Exemple #11
0
 private function remote($url, $xml = 0, $term = false, $returnErrors = false)
 {
     global $dbh, $postvar, $getvar, $instance;
     $server_details = $this->serverDetails($this->server);
     $cleanaccesshash = preg_replace("'(\r|\n)'", "", $server_details['accesshash']);
     $authstr = $server_details['user'] . ":" . $cleanaccesshash;
     $ch = curl_init();
     if ($server_details['https']) {
         //Usually 2087
         if ($server_details['apiport'] != 443) {
             $port = $server_details['apiport'];
         }
         $serverstuff = "https://" . $server_details['host'] . ":" . $port . $url;
         curl_setopt($ch, CURLOPT_URL, $serverstuff);
         curl_setopt($ch, CURLOPT_HTTPAUTH, CURLAUTH_ANY);
         curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
     } else {
         //Usually 2086
         if ($server_details['apiport'] != 80) {
             $port = $server_details['apiport'];
         }
         $serverstuff = "http://" . $server_details['host'] . ":" . $port . $url;
         curl_setopt($ch, CURLOPT_URL, $serverstuff);
     }
     curl_setopt($ch, CURLOPT_HEADER, 0);
     curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
     $curlheaders[0] = "Authorization: WHM {$authstr}";
     curl_setopt($ch, CURLOPT_HTTPHEADER, $curlheaders);
     $curl_data = curl_exec($ch);
     if ($curl_data === false) {
         if ($returnErrors) {
             return curl_error($ch);
         }
         main::error(array("WHM Connection Error" => curl_error($ch)));
         return false;
     }
     curl_close($ch);
     if ($term == true) {
         return true;
     } elseif (strstr($curl_data, "SSL encryption is required")) {
         if ($returnErrors) {
             return "THT must connect via SSL!";
         }
         main::error(array("WHM Error" => "THT must connect via SSL!"));
         return false;
     } elseif (!$xml) {
         $xml = new SimpleXMLElement($curl_data);
     } else {
         return $curl_data;
     }
     return $xml;
 }
 public function changePwd($id, $newpwd)
 {
     global $dbh, $postvar, $getvar, $instance;
     $client = $dbh->client($id);
     if (!$client['id']) {
         $error_array['Error'] = "That user doesn't exist.";
         $error_array['User PID'] = $id;
         main::error($error_array);
         return;
     } else {
         $server = type::packageserver($client['pid']);
         $serverfile = self::createServer($client['pid']);
         if ($serverfile->changePwd($client['user'], $newpwd, $server)) {
             main::thtlog("Client Password Changed", "Password changed", $client['id']);
             return true;
         } else {
             return false;
         }
     }
 }