コード例 #1
1
ファイル: class_email.php プロジェクト: cozylife/tht-reworked
 public function smtp()
 {
     global $dbh, $postvar, $getvar, $instance;
     $body = eregi_replace("[\\]", '', $body);
     $users_data = $dbh->select("users", array("email", "=", $instance->email['to']), 0, "1");
     $to_name = $users_data['firstname'] . " " . $users_data['lastname'];
     if ($to_name == " ") {
         $staff_data = $dbh->select("staff", array("email", "=", $instance->email['to']), 0, "1");
         $to_name = $staff_data['name'];
     }
     if (!class_exists("PHPMailer")) {
         include INC . "/smtp/class_phpmailer.php";
     }
     $mail = new PHPMailer();
     $mail->IsSMTP();
     // telling the class to use SMTP
     $mail->SMTPAuth = true;
     // enable SMTP authentication (Log in with credentials to send)
     $mail->SMTPKeepAlive = true;
     // SMTP connection will not close after each email sent
     $mail->Host = $instance->details['smtp_host'];
     // sets the SMTP server
     $mail->Port = $dbh->config('smtp_port');
     // set the SMTP port for the SMTP server
     $mail->Username = $instance->details['smtp_user'];
     // SMTP account username
     $mail->Password = $instance->details['smtp_password'];
     // SMTP account password
     $mail->SetFrom($instance->details['from'], $dbh->config('name'));
     $mail->AddReplyTo($instance->details['from'], $dbh->config('name'));
     $mail->Subject = $instance->email['subject'];
     $mail->MsgHTML($instance->email['content']);
     $mail->AddAddress($instance->email['to'], $to_name);
     if (!$mail->Send()) {
         $response = "Mailer Error (" . $instance->email['to'] . ') ' . $mail->ErrorInfo . "\n";
         main::thtlog("SMTP Error", $response, main::userid());
         $mail->ClearAddresses();
         return false;
     }
     $mail->ClearAddresses();
     return true;
 }
コード例 #2
0
ファイル: users.php プロジェクト: cozylife/tht-reworked
 private function ConfirmClientEmail($client)
 {
     global $dbh, $postvar, $getvar, $instance;
     $dbh->update("users", array("status" => "1"), array("id", "=", $client['id']));
     $dbh->update("users_bak", array("status" => "1"), array("uid", "=", $client['id']));
     main::thtlog("Account Confirmed", "Account/E-mail Confirmed - By Admin", $client['id']);
     main::redirect("?page=users&sub=search&do=" . $client['id']);
 }
コード例 #3
0
ファイル: logs.php プロジェクト: cozylife/tht-reworked
 public function content()
 {
     global $dbh, $postvar, $getvar, $instance;
     if (is_numeric($getvar['dellogid'])) {
         $dbh->delete("logs", array("id", "=", $getvar['dellogid']), "1");
         main::errors("Log entry deleted.");
     }
     if (is_numeric($getvar['removeall'])) {
         if ($getvar['confirm'] != '1') {
             main::errors("Are you sure you wish to remove ALL log entries?   <a href = '?page=logs&removeall=" . $getvar['removeall'] . "&confirm=1'>Yes</a>    |    <a href = '?page=logs'>No</a>");
         } else {
             $dbh->delete("logs", 0, 0, 1);
             main::thtlog("Logs Cleared", "All Logs were removed.", $_SESSION['user'], "", "staff");
             main::redirect("?page=logs");
         }
     }
     if (is_numeric($getvar['logid'])) {
         $loginfo = $dbh->select("logs", array("id", "=", $getvar['logid']));
         $admin_log_view_array['MESSAGE'] = $loginfo['message'];
         echo style::replaceVar("tpl/admin/logs/admin-log-view.tpl", $admin_log_view_array);
     } else {
         $per_page = $getvar['limit'];
         $start = $getvar['start'];
         if (!$postvar['show']) {
             $show = $getvar['show'];
         } else {
             $show = $postvar['show'];
             $start = 0;
         }
         if (!$show) {
             $show = "all";
         }
         if (!$per_page) {
             $per_page = 10;
         }
         if (!$start) {
             $start = 0;
         }
         if ($show != "all") {
             $logs_query = $dbh->select("logs", array("logtype", "=", $show), array("logtime", "DESC"), $start . ", " . $per_page, 1);
         } else {
             $logs_query = $dbh->select("logs", 0, array("logtime", "DESC"), $start . ", " . $per_page, 1);
         }
         $all_logs_query = $dbh->select("logs");
         $num_logs = $dbh->num_rows($all_logs_query);
         $pages = ceil($num_logs / $per_page);
         if ($num_logs == 0) {
             $admin_logs_list_array['LOGS'] = "";
             $admin_logs_list_array['PAGING'] = "";
             main::errors("No logs found.");
         } else {
             while ($logs_data = $dbh->fetch_array($logs_query)) {
                 $message_data = explode("<", substr($logs_data['message'], 0, 100));
                 $admin_log_item_array['USER'] = $logs_data['loguser'];
                 $admin_log_item_array['DATE'] = main::convertdate("n/d/Y", $logs_data['logtime']);
                 $admin_log_item_array['TIME'] = main::convertdate("g:i A", $logs_data['logtime']);
                 $admin_log_item_array['MESSAGE'] = $message_data[0];
                 $admin_log_item_array['LOGID'] = $logs_data['id'];
                 $admin_logs_list_array['LOGS'] .= style::replaceVar("tpl/admin/logs/admin-log-item.tpl", $admin_log_item_array);
             }
         }
         if ($start != 0) {
             $back_page = $start - $per_page;
             $admin_logs_list_array['PAGING'] = '<a href="?page=logs&show=' . $show . '&start=' . $back_page . '&limit=' . $per_page . '">BACK</a>&nbsp;';
         }
         for ($i = 1; $i <= $pages; $i++) {
             $start_link = $per_page * ($i - 1);
             if ($start_link == $start) {
                 $admin_logs_list_array['PAGING'] .= '&nbsp;<b>' . $i . '</b>&nbsp;';
             } else {
                 $admin_logs_list_array['PAGING'] .= '&nbsp;<a href="?page=logs&show=' . $show . '&start=' . $start_link . '&limit=' . $per_page . '">' . $i . '</a>&nbsp;';
             }
         }
         if (($start + $per_page) / $per_page < $pages && $pages != 1) {
             $next_page = $start + $per_page;
             $admin_logs_list_array['PAGING'] .= '&nbsp;<a href="?page=logs&show=' . $show . '&start=' . $next_page . '&limit=' . $per_page . '">NEXT</a>';
         }
         $shown = array();
         $log_type_values[] = array("Show All", "all");
         $logs_query = $dbh->select("logs", 0, array("logtype", "ASC"), 0, 1);
         while ($logs_data = $dbh->fetch_array($logs_query)) {
             if (!in_array($logs_data['logtype'], $shown)) {
                 $log_type_values[] = array($logs_data['logtype'], $logs_data['logtype']);
                 $shown[] = $logs_data['logtype'];
             }
         }
         $admin_logs_list_array['SHOW_TYPE'] = main::dropdown("show", $log_type_values);
         echo style::replaceVar("tpl/admin/logs/admin-logs-list.tpl", $admin_logs_list_array);
     }
 }
コード例 #4
0
ファイル: da.php プロジェクト: cozylife/tht-reworked
 public function signup($server, $reseller, $user, $email, $pass, $domain, $server_pack, $extra = array(), $domsub)
 {
     global $dbh, $postvar, $getvar, $instance;
     $this->server = $server;
     $server_details = $this->serverDetails($this->server);
     $ip = gethostbyname($server_details['host']);
     $string = "action=create&add=Submit&username="******"" . "&passwd=" . $pass . "" . "&passwd2=" . $pass . "" . "&domain=" . $domain . "" . "&package=" . str_replace(" ", "%20", $server_pack) . "" . "¬ify=no" . "&email=" . $email . "";
     if ($reseller) {
         $define = "CMD_API_ACCOUNT_RESELLER";
         $string .= "&ip=shared";
     } else {
         $define = "CMD_API_ACCOUNT_USER";
         $string .= "&ip=" . $ip;
     }
     //echo $action."<br />". $reseller;
     $command = $this->remote($define, $string);
     if ($command['error']) {
         $order_error = "DA Error: <strong>" . $command['text'] . "</strong><br />" . $command['details'];
         main::thtlog("DA Error", nl2br(htmlspecialchars($order_error, ENT_QUOTES)));
         return "An error has occurred. Please inform your system administrator.";
     } else {
         return true;
     }
 }
コード例 #5
0
ファイル: kloxo.php プロジェクト: cozylife/tht-reworked
 public function signup($server, $reseller, $user, $email, $pass, $domain, $server_pack, $extra = array(), $domsub)
 {
     global $dbh, $postvar, $getvar, $instance;
     $this->server = $server;
     $server_details = $this->serverDetails($this->server);
     $ip = gethostbyname($server_details['host']);
     $package = str_replace(" ", "", $server_pack);
     if ($this->welcome_email) {
         $send_email_kloxo = "on";
     } else {
         $send_email_kloxo = "off";
     }
     $string = "action=add&class=client&name=" . $user . "" . "&v-password="******"" . "&v-domain_name=" . $domain . "" . "&v-dnstemplate_name=" . $this->dnstemplate . "" . "&v-plan_name=" . $package . "" . "&v-send_welcome_f=" . $send_email_kloxo . "&v-contactemail=" . $email . "";
     // Reseller or Not?
     if ($reseller) {
         $string .= "&v-type=reseller";
     } else {
         $string .= "&v-type=customer";
     }
     //echo $action."<br />". $reseller;
     $command = $this->remote($string);
     if ($command == true) {
         return true;
     } else {
         $order_error = "ORDER ERROR: There was an error on the order form.  Below are the details to help you diagnose this.\n\n                                        Data sent to the server:\n                                        Sent to: " . $this->diagnostics["SENT"] . "\n\n                                        Response from server:\n\n                                        Data:\n                                        " . $this->diagnostics["RECV"];
         main::thtlog("Kloxo Error", nl2br(htmlspecialchars($order_error, ENT_QUOTES)));
         return "An error has occurred. Please inform your system administrator.";
     }
 }
コード例 #6
0
 public function do_upgrade($upgradeid, $mode, $no_errors_out = 0)
 {
     global $dbh, $postvar, $getvar, $instance;
     //$mode
     //
     //Init   - When the upgrade info is added, we call this function.
     //Update - When cron or an admin does something with this function, we check to see if various tasks are ready to be performed.
     //Flag meaning:
     //
     //IMMEDIATE UPGRADE FLAGS
     //
     //0 - Upgrade is immediate.
     //5 - If admin approves the upgrade, then the upgrade will be immediate.
     //
     //6 - If admin approves the upgrade, then the new account will be created on the new server and the
     //    admin will know that they are moving to a new server so they can manually close the old account
     //    when they're ready.
     //
     //7 - The new account on the new server will be immediately created and the admin will be notified that
     //    the user is switching servers.
     //
     //NEXT MONTH UPGRADE FLAGS
     //
     //1 - Cron will upgrade them next month.
     //2 - If admin approves this, then it will be set to 1 for cron to upgrade them next month.
     //3 - The admin will be notified that the user wishes to be upgraded and if they approve it,
     //    then an account on the new server will be created so they can migrate to the new server.
     //    the admin can opt to switch the account over before next month if they both agree and the
     //    switch will be made in the admin area manually.
     //
     //4 - Cron will create a new account on the new server next month and inform the admin that the
     //    user is changing to the new server.
     //
     $upgrade_data = $dbh->select("upgrade", array("id", "=", $upgradeid));
     $userid = $upgrade_data['uid'];
     $newpack = $upgrade_data['newpack'];
     $flags = $upgrade_data['flags'];
     $created = $upgrade_data['created'];
     $coupcode = $upgrade_data['coupcode'];
     $user_data = main::uidtopack($userid);
     $current_pack_type = $user_data['packages']['type'];
     $current_pack_name = $user_data['packages']['name'];
     $current_pack_id = $user_data['packages']['id'];
     $user_info = $dbh->select("users", array("id", "=", $userid));
     $user_email = $user_info['email'];
     $username = $user_info['user'];
     $new_plan_data = $dbh->select("packages", array("id", "=", $newpack));
     $newpack_name = $new_plan_data['name'];
     $new_plan_additional = type::additional($newpack);
     $new_server_data = $dbh->select("servers", array("id", "=", $new_plan_data['server']));
     $new_server_name = $new_server_data['name'];
     $old_server_data = $dbh->select("servers", array("id", "=", $user_data['packages']['server']));
     $old_server_name = $old_server_data['name'];
     switch ($flags) {
         case "0":
             $upgrade = 1;
             break;
         case "1":
             $upgrade_today = self::upgrade_today($current_pack_type, $userid);
             if ($upgrade_today) {
                 $upgrade = 1;
             }
             break;
         case "2":
             if ($mode = "Init") {
                 $admin_approval = 1;
             } else {
                 //If its already the day for the upgrade, then we can do the upgrade now.
                 $upgrade_today = self::upgrade_today($current_pack_type, $userid);
                 if ($upgrade_today) {
                     $upgrade = 1;
                 }
                 if (!$upgrade) {
                     $dbh->update("upgrade", array("flags" => "1"), array("id", "=", $upgradeid), "1");
                 }
             }
             break;
         case "3":
             if ($mode = "Init") {
                 $admin_approval = 1;
                 $new_server = 1;
             } else {
                 //If its already the day for the upgrade, then we can do the upgrade now.
                 $upgrade_today = self::upgrade_today($current_pack_type, $userid);
                 if ($upgrade_today) {
                     $upgrade = 1;
                     $new_server = 1;
                 }
                 if (!$upgrade) {
                     $dbh->update("upgrade", array("flags", "=", "4"), array("id", "=", $upgradeid), "1");
                 }
             }
             break;
         case "4":
             //If its already the day for the upgrade, then we can do the upgrade now.
             $upgrade_today = self::upgrade_today($current_pack_type, $userid);
             if ($upgrade_today) {
                 $upgrade = 1;
                 $new_server = 1;
                 $admin_inform = 1;
             }
             break;
         case "5":
             if ($mode = "Init") {
                 $admin_approval = 1;
                 $immediate = 1;
             } else {
                 $upgrade = 1;
             }
             break;
         case "6":
             if ($mode = "Init") {
                 $admin_approval = 1;
                 $new_server = 1;
                 $immediate = 1;
             } else {
                 $upgrade = 1;
                 $new_server = 1;
             }
             break;
         case "7":
             $upgrade = 1;
             $new_server = 1;
             $admin_inform = 1;
             break;
     }
     $adminmsg_array['USER'] = $username;
     $adminmsg_array['NEWPLAN'] = $newpack_name;
     $adminmsg_array['OLDPLAN'] = $current_pack_name;
     $adminmsg_array['NEWSERVER'] = $new_server_name;
     $adminmsg_array['OLDSERVER'] = $old_server_name;
     if ($immediate) {
         $adminmsg_array['NEXTMONTH_IMMEDIATELY'] = "immediately";
     } else {
         $adminmsg_array['NEXTMONTH_IMMEDIATELY'] = "next billing cycle";
     }
     $url = $dbh->config("url");
     if (ADMINDIR) {
         $admin_dir = ADMINDIR;
     } else {
         $admin_dir = "admin";
     }
     $adminmsg_array['APPROVE_LINK'] = $url . $admin_dir . "/?page=users&sub=upgrade";
     if ($upgrade) {
         if ($new_plan_data['type'] == "paid") {
             $new_invoice_text = "  A new invoice has been generated.";
             if ($current_pack_type == "paid" && $user_data['additional']['monthly'] >= $new_plan_additional['monthly']) {
                 unset($new_invoice_text);
             }
         }
         $serverfile = server::createServer($newpack);
         if ($new_server) {
             $new_serv_pass_for_email = time();
             $domsub = "sub";
             //Checks to see if the domain contains 3 or more segments and fails if there are more than 3 and if the last one two aren't TLD portions, it fails,
             //so we can see if this is a subdomain this way.
             if (check::domain($user_data['user_data']['domain'])) {
                 $domsub = "dom";
             }
             $done = $serverfile->signup(type::packageserver($newpack), $new_plan_data['reseller'], $username, $user_email, $new_serv_pass_for_email, $user_data['user_data']['domain'], type::packageBackend($newpack), $domsub);
             if ($done === true) {
                 if ($new_plan_data['reseller']) {
                     $uemaildata = email::emailTemplate("upgrade-newserv-resell-welcome");
                 } else {
                     $uemaildata = email::emailTemplate("upgrade-newserv-welcome");
                 }
                 $change_tht = 1;
                 main::errors("Your upgrade request has been completed.  An email has been sent to you detailing your upgraded account on the new server." . $new_invoice_text);
             } else {
                 return false;
             }
         } else {
             if ($serverfile->canupgrade) {
                 $done = $serverfile->do_upgrade($new_plan_data['server'], type::packageBackend($newpack), $username);
                 if ($done === true) {
                     if ($new_plan_data['reseller']) {
                         $uemaildata = email::emailTemplate("upgrade-resell-welcome");
                     } else {
                         $uemaildata = email::emailTemplate("upgrade-welcome");
                     }
                     $change_tht = 1;
                     main::errors("Your upgrade request has been completed.  An email has been sent to you detailing your upgraded account." . $new_invoice_text);
                 } else {
                     return false;
                 }
             } else {
                 $emaildata = email::emailTemplate("manual-upgrade-request");
                 main::errors("Your upgrade request has been added and the administrator has been emailed.");
             }
         }
         if ($uemaildata) {
             $welcomeemail_array['USER'] = $username;
             $welcomeemail_array['EMAIL'] = $user_email;
             $welcomeemail_array['PACKAGE'] = $newpack_name;
             $welcomeemail_array['SERVERIP'] = $new_server_data['ip'];
             $welcomeemail_array['LNAME'] = $user_info['lastname'];
             $welcomeemail_array['FNAME'] = $user_info['firstname'];
             $welcomeemail_array['CPPORT'] = $new_server_data['port'];
             $welcomeemail_array['PASS'] = $new_serv_pass_for_email;
             $welcomeemail_array['RESELLERPORT'] = $new_server_data['resellerport'];
             $welcomeemail_array['NAMESERVERS'] = nl2br($new_server_data['nameservers']);
             $welcomeemail_array['DOMAIN'] = $user_data['user_data']['domain'];
             email::send($user_email, $uemaildata['subject'], $uemaildata['content'], $welcomeemail_array);
         }
     } else {
         main::errors("Your upgrade request has been added.");
     }
     //Now we need to send the admin a dozen emails.  lol  FIRE!  Nah, we'll only ever send them one email at a time.  ;)
     if ($admin_approval) {
         if ($new_server) {
             $emaildata = email::emailTemplate("upgrade-newserv-adminval");
         } else {
             $emaildata = email::emailTemplate("upgrade-adminval");
         }
     }
     if ($admin_inform) {
         $emaildata = email::emailTemplate("notify-upgrade-new-server");
     }
     if (!$emaildata && $change_tht) {
         $emaildata = email::emailTemplate("notify-upgrade");
     }
     if ($emaildata) {
         email::staff($emaildata['subject'], $emaildata['content'], $adminmsg_array);
     }
     if ($change_tht) {
         main::thtlog("Client Upgraded", "Upgraded from " . $current_pack_name . " to " . $newpack_name, $userid, "");
         if ($current_pack_type == "paid") {
             unset($where);
             $where[] = array("uid", "=", $userid, "AND");
             $where[] = array("pid", "=", "");
             $dbh->update("invoices", array("pid" => $current_pack_id), $where);
         }
         if ($new_plan_data['type'] != "p2h") {
             $dbh->delete("coupons_p2h", array("uid", "=", $userid));
         }
         $user_pack_data = $user_data['user_data'];
         $users_update = array("pid" => $newpack, "domain" => $user_pack_data['domain'], "additional" => $user_pack_data['additional']);
         $dbh->update("users", $users_update, array("id", "=", $userid), "1");
         $dbh->update("users_bak", $users_update, array("id", "=", $userid), "1");
         if ($current_pack_type == "paid") {
             unset($where);
             $where[] = array("user", "=", $userid, "AND");
             $where[] = array("disabled", "=", "0");
             $coupons_used_query = $dbh->select("coupons_used", $where, 0, 0, 1);
             while ($coupons_used_data = $dbh->fetch_array($coupons_used_query)) {
                 $had_coupons .= $coupons_used_data['coupcode'] . ",";
                 $couponvals .= $coupons_used_data['paiddisc'] . ",";
             }
             $had_coupons = substr($had_coupons, 0, strlen($had_coupons) - 1);
             $couponvals = substr($couponvals, 0, strlen($couponvals) - 1);
             if (!$had_coupons) {
                 $had_coupons = "0";
                 $couponvals = "0";
             }
             $invoices_update = array("changed_plan" => "1", "hadcoupons" => $had_coupons, "couponvals" => $couponvals);
             unset($where);
             $where[] = array("uid", "=", $userid, "AND");
             $where[] = array("hadcoupons", "=", "");
             $dbh->update("invoices", $invoices_update, $where);
         }
         $multi_coupons = $dbh->config("multicoupons");
         if ($coupcode || $new_plan_data['type'] == "free") {
             if (!$multi_coupons || $new_plan_data['type'] == "free") {
                 $coupons_used_update = array("disabled" => "2", "datedisabled" => time());
                 $dbh->update("coupons_used", $coupons_used_update, array("user", "=", $userid));
             }
         }
         if ($new_plan_data['type'] != "free") {
             if ($new_plan_data['type'] == "paid") {
                 unset($where);
                 $where[] = array("uid", "=", $userid, "AND");
                 $where[] = array("pid", "=", $current_pack_id);
                 $last_invoice = $dbh->select("invoices", $where, array("id", "DESC"), "1");
                 if ($user_data['additional']['monthly'] < $new_plan_additional['monthly'] && $current_pack_type == "paid" && $last_invoice) {
                     unset($where);
                     $where[] = array("uid", "=", $userid, "AND");
                     $where[] = array("pid", "=", $current_pack_id);
                     $last_invoice = $dbh->select("invoices", $where, array("id", "DESC"), "1");
                     if (!$multi_coupons) {
                         unset($where);
                         $where[] = array("user", "=", $userid, "AND");
                         $where[] = array("disabled", "=", "0");
                         $current_coupon = $dbh->select("coupons_used", $where);
                         $coupcode = $current_coupon['coupcode'];
                         coupons::remove_coupon($current_coupon['id'], $newpack, $last_invoice['id'], $userid);
                     } else {
                         unset($where);
                         $where[] = array("user", "=", $userid, "AND");
                         $where[] = array("disabled", "=", "0");
                         $coupons_used_query = $dbh->select("coupons_used", $where, 0, 0, 1);
                         while ($coupons_used_data = $dbh->fetch_array($coupons_used_query)) {
                             $use_coupons[] = $coupons_used_data['coupcode'];
                             coupons::remove_coupon($coupons_used_data['id'], $newpack, $last_invoice['id'], $userid);
                         }
                     }
                     unset($where);
                     $where[] = array("uid", "=", $userid, "AND");
                     $where[] = array("pid", "=", $current_pack_id);
                     $last_invoice = $dbh->select("invoices", $where, array("id", "DESC"), "1");
                     $invoice_update_array = array("amount" => $new_plan_additional['monthly'], "due" => $last_invoice['due'] + 7 * 24 * 60 * 60, "pid" => $newpack, "hadcoupons" => "", "couponvals" => "", "changed_plan" => "0", "is_paid" => "0");
                     $where[] = array("id", "=", $last_invoice['id']);
                     $dbh->update("invoices", $invoice_update_array, $where);
                 } else {
                     $amount = $new_plan_additional['monthly'];
                     if (!$coupcode) {
                         unset($where);
                         $where[] = array("user", "=", $userid, "AND");
                         $where[] = array("disabled", "=", "0");
                         $coupcode = $dbh->select("coupons_used", $where);
                         $coupcode = $coupcode['coupcode'];
                     }
                     $coupon_data = coupons::coupon_data($coupcode);
                     $coupon_data['paiddisc'] = coupons::percent_to_value("paid", "paidtype", "paiddisc", $amount);
                     if ($multi_coupons) {
                         $amount = coupons::get_discount("paid", $amount, $userid) - $coupon_data['paiddisc'];
                     } else {
                         $amount = max(0, $amount - $coupon_data['paiddisc']);
                     }
                     $due = time() + 2592000;
                     $notes = "Your hosting package invoice for this billing cycle. Package: " . $newpack_name;
                     invoice::create($userid, $amount, $due, $notes);
                     $last_invoice = $dbh->select("invoices", array("uid", "=", $userid), array("id", "DESC"), "1");
                     $dbh->update("invoices", array("pid" => $newpack), array("id", "=", $last_invoice['id']), "1");
                     unset($where);
                     $where[] = array("uid", "=", $userid, "AND");
                     $where[] = array("pid", "=", $newpack);
                     $last_invoice = $dbh->select("invoices", $where, array("id", "DESC"), "1");
                     if (!$multi_coupons) {
                         unset($where);
                         $where[] = array("user", "=", $userid, "AND");
                         $where[] = array("disabled", "=", "0");
                         $current_coupon = $dbh->select("coupons_used", $where);
                         coupons::remove_coupon($current_coupon['id'], $newpack, $last_invoice['id'], $userid);
                     } else {
                         unset($where);
                         $where[] = array("user", "=", $userid, "AND");
                         $where[] = array("disabled", "=", "0");
                         $coupons_used_query = $dbh->select("coupons_used", $where, 0, 0, 1);
                         while ($coupons_used_data = $dbh->fetch_array($coupons_used_query)) {
                             $use_coupons[] = $coupons_used_data['coupcode'];
                             coupons::remove_coupon($coupons_used_data['id'], $newpack, $last_invoice['id'], $userid);
                         }
                     }
                 }
             }
             unset($where);
             $where[] = array("uid", "=", $userid, "AND");
             $where[] = array("pid", "=", $newpack);
             $last_invoice = $dbh->select("invoices", $where, array("id", "DESC"), "1");
             if ($coupcode) {
                 $coupon_data = $dbh->select("coupons", array("coupcode", "=", $coupcode));
                 coupons::use_coupon($coupon_data['id'], $newpack, $last_invoice['id'], $userid, "orders");
             }
             if ($multi_coupons && $use_coupons) {
                 for ($i = 0; $i < count($use_coupons); $i++) {
                     $coupcode = $use_coupons[$i];
                     $coupon_data = $dbh->select("coupons", array("coupcode", "=", $coupcode));
                     coupons::use_coupon($coupon_data['id'], $newpack, $last_invoice['id'], $userid, "orders");
                 }
             }
         }
         //We now remove the upgrade stub.
         $dbh->delete("upgrade", array("uid", "=", $userid));
     }
     unset($where);
     $where[] = array("amount", "=", "0", "OR");
     $where[] = array("amount", "=", "0.00");
     $dbh->update("invoices", array("is_paid" => "1"), $where);
     if (!$no_errors_out) {
         echo "<ERRORS>";
     }
 }
コード例 #7
0
ファイル: zpanel.php プロジェクト: cozylife/tht-reworked
 public function signup($server, $reseller, $user, $email, $pass, $domain, $server_pack, $extra = array(), $domsub)
 {
     global $dbh, $postvar, $getvar, $instance;
     $this->server = $server;
     $fullname = $extra['firstname'] . " " . $extra['lastname'];
     $address = $extra['address'] . "<br>" . $extra['city'] . ", " . $extra['state'] . " " . $extra['zip'] . " " . $extra['country'];
     $zip_code = $extra['zip'];
     $phone = $extra['phone'];
     $packages_data = $dbh->select("packages", array("backend", "=", $server_pack), 0, "1");
     $groupid = $packages_data['groupid'];
     $send_email = $packages_data['send_email'];
     $email_subject = $packages_data['email_subject'];
     $email_body = $packages_data['email_body'];
     if (!$email_subject) {
         $email_subject = $this->email_subject;
     }
     if (!$email_body) {
         $email_body = $this->email_body;
     }
     $server_details = $this->serverDetails($this->server);
     $reseller_id = $server_details['reseller_id'];
     if (!is_numeric($server_pack) || strpos($server_pack, ".")) {
         //The package backend must be the ID (number) of the package.  You can find that by editing the
         //created package and looking at the URL.
         //Ex: ?module=packages&show=Edit&other=PACKAGEID
         //
         //Enter the package ID for the package instead of using the name of the package.
         return "An package error has occurred. Please inform your system administrator.";
     }
     if (!is_numeric($groupid) || strpos($groupid, ".")) {
         //The group ID must be the ID (number) of the group.  You can find that by editing the
         //created group and looking at the URL.
         //Ex: ?module=manage_groups&show=Edit&other=GROUPID
         //
         //Enter the group ID for the group instead of using the name of the group.
         return "An grouping error has occurred. Please inform your system administrator.";
     }
     if ($email_body) {
         $email_body = str_replace("\n", "", $email_body);
     }
     $content_str = "<resellerid>" . $reseller_id . "</resellerid>\n                                <packageid>" . $server_pack . "</packageid>\n                                <groupid>" . $groupid . "</groupid>\n\n                                <fullname>" . $fullname . "</fullname>\n                                <email>" . $email . "</email>\n                                <address>" . $address . "</address>\n                                <postcode>" . $zip_code . "</postcode>\n                                <phone>" . $phone . "</phone>\n\n                                <username>" . $user . "</username>\n                                <password>" . $pass . "</password>\n\n                                <sendemail>" . $send_email . "</sendemail>\n                                <emailsubject>" . $email_subject . "</emailsubject>\n                                <emailbody>" . $email_body . "</emailbody>";
     $command = $this->remote("manage_clients", "CreateClient[][]" . $content_str);
     if ($command === true) {
         //If we're using a domain and not a sub domain
         if ($domsub == "dom") {
             $domain_exists = $this->domain_exists($domain);
             if (!$domain_exists) {
                 $uid = $this->ZPanel_UID($user);
                 if ($uid) {
                     $content_str = "<uid>" . $uid . "</uid>\n                                                <domain>" . $domain . "</domain>\n                                                <destination></destination>\n                                                <autohome>1</autohome>";
                     $command = $this->remote("domains", "CreateDomain[][]" . $content_str);
                 }
             }
         }
         //No matter what we return true because the user can always add a domain in ZPanel if automatic creation fails.
         return true;
     } else {
         if ($this->response_number != "9999") {
             $order_error = "ORDER ERROR: There was an error on the order form.  Below are the details to help you diagnose this.\n\n                                        Error number code list:\n                                        1101 - Request successful.\n                                        1102 - Request not found (class does not exist in ZPanel). (Suggestion: Report this on the forums for help.)\n                                        1103 - Server API key validation failed.  (Suggestion: Check your server settings.)\n                                        1104 - User authentication required and not specified.  (Suggestion: Check your server settings.)\n                                        1105 - Username and password validation failed.  (Suggestion: Check your server settings.)\n                                        1106 - Request not valid (required tags not supplied) No post data etc. (Suggestion: Report this on the forums for help.)\n                                        1107 - Modular web service not found (eg. No file in the module named 'webservice.ext.php') (Suggestion: Report this on the forums for help.)\n\n                                        9999 - Username already exists in ZPanel (This should never show in the logs.  The user will see this and be able to go back and change their username.)\n                                        9997 - The account could not be created on the server.  (Most likely the email address for the client already exists on ZPanel's accounts table.)\n\n                                        Error code given: " . $this->response_number . "\n                                        Server type: ZPanel\n\n                                        Data sent to the server:\n                                        Sent to: " . $this->diagnostics["SENT"]["URL"] . "\n                                        \n                                        Data:\n                                        " . $this->diagnostics["SENT"]["POST"] . "\n\n                                        Response from server:\n                                        \n                                        Data:\n                                        " . $this->diagnostics["RECV"] . "\n\n                                        If the solution to this problem was to request help on the forums, be sure you've patched ZPanel and are using the latest version of this module and THT.  Also check to see if you're running a compatible version of ZPanel.";
             main::thtlog("ZPanel Error", nl2br(htmlspecialchars($order_error, ENT_QUOTES)));
             return "An error has occurred. Please inform your system administrator.";
         } else {
             return "That username already exists.";
         }
         return false;
     }
 }
コード例 #8
0
ファイル: whm.php プロジェクト: cozylife/tht-reworked
 public function signup($server, $reseller, $user, $email, $pass, $domain, $server_pack, $extra = array(), $domsub)
 {
     global $dbh, $postvar, $getvar, $instance;
     $this->server = $server;
     $action = "/xml-api/createacct" . "?username="******"" . "&password="******"" . "&domain=" . $domain . "" . "&plan=" . str_replace(" ", "%20", $server_pack) . "" . "&contactemail=" . $email . "";
     if ($reseller) {
         $action .= "&reseller=1";
     }
     //echo $action."<br />". $reseller."<br>";
     $command = $this->remote($action);
     if ($command->result->status == 1) {
         return true;
     } else {
         $order_error = "WHM Error: " . $command->result->statusmsg;
         main::thtlog("WHM Error", nl2br(htmlspecialchars($order_error, ENT_QUOTES)));
         return "An error has occurred. Please inform your system administrator.";
     }
 }
コード例 #9
0
 public function remove_coupon($coupid, $package, $invoiceid, $userid = "")
 {
     global $dbh, $postvar, $getvar, $instance;
     if (!$userid) {
         $userid = $_SESSION['cuser'];
     }
     $used_coupon_info = self::user_coupon_data($userid, 0, "", $coupid);
     $invoice_info = $dbh->select("invoices", array("id", "=", $invoiceid));
     $total = $invoice_info['amount'];
     $pack_info = main::uidtopack($userid);
     $monthly = $pack_info['additional']['monthly'];
     //Disabled 2 means the coupon didn't expire, but it was removed.  If the user re-ads it, we need to put them back on the coupon for the duration
     //left on the coupon.  This prevents users from removing a coupon before it expired and re-adding it for unlimited uses of that discount.
     $coupons_used_update = array("disabled" => "2", "datedisabled" => time());
     unset($where);
     $where[] = array("id", "=", $coupid, "AND");
     $where[] = array("user", "=", $userid);
     $dbh->update("coupons_used", $coupons_used_update, $where, "1");
     $invoice_total = self::get_discount("paid", $monthly, $userid);
     if ($invoice_total > $monthly) {
         $invoice_total = $monthly;
     } else {
         $invoice_total = $invoice_total;
     }
     if ($invoice_total > 0) {
         $invoices_update = array("is_paid" => "0", "amount" => $invoice_total);
     } else {
         $invoices_update = array("amount" => $invoice_total);
     }
     unset($where);
     $where[] = array("id", "=", $invoiceid, "AND");
     $where[] = array("uid", "=", $userid);
     $dbh->update("invoices", $invoices_update, $where, "1");
     //As this simply removes the coupon if the user ID and other info match the records, we need to make sure that somone disn't
     //just type in the url of someone else's coupon.  This way if it failed because they didn't realy remove the coupon, we
     //don't log it.
     $used_coupon_info = self::user_coupon_data($userid, 0, "", $coupid, 0);
     if ($used_coupon_info['disabled'] == "2") {
         main::thtlog("Coupon Removed", "Coupon removed (" . $used_coupon_info['coupcode'] . ")", $userid);
     }
     return true;
 }
コード例 #10
0
 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;
         }
     }
 }