Пример #1
0
 public function content()
 {
     global $dbh, $postvar, $getvar, $instance;
     unset($where);
     $where[] = array("reply", "=", "0", "AND");
     $where[] = array("userid", "=", $_SESSION['cuser']);
     $all_tickets_query = $dbh->select("tickets", $where, 0, 0, 1);
     $client_home_array['TICKETS'] = $dbh->num_rows($all_tickets_query);
     unset($where);
     $where[] = array("reply", "=", "0", "AND");
     $where[] = array("status", "=", "1", "AND");
     $where[] = array("userid", "=", $_SESSION['cuser']);
     $open_tickets_query = $dbh->select("tickets", $where, 0, 0, 1);
     $client_home_array['OPENTICKETS'] = $dbh->num_rows($open_tickets_query);
     unset($where);
     $where[] = array("reply", "=", "0", "AND");
     $where[] = array("status", "=", "3", "AND");
     $where[] = array("userid", "=", $_SESSION['cuser']);
     $closed_tickets_query = $dbh->select("tickets", $where, 0, 0, 1);
     $client_home_array['CLOSEDTICKETS'] = $dbh->num_rows($closed_tickets_query);
     unset($where);
     $where[] = array("uid", "=", $_SESSION['cuser'], "AND");
     $where[] = array("message", "LIKE", "Login%");
     $log_data = $dbh->select("logs", $where, array("id", "DESC"), "1");
     if ($log_data['logtime']) {
         $client_home_array['LASTDATE'] = main::convertdate("n/d/Y", $log_data['logtime']);
         $client_home_array['LASTTIME'] = main::convertdate("g:i a", $log_data['logtime']);
         $client_home_array['LASTLOGIN'] = $client_home_array['LASTDATE'] . " at " . $client_home_array['LASTTIME'];
     } else {
         $client_home_array['LASTLOGIN'] = "******";
     }
     $client_data = $dbh->client($_SESSION['cuser']);
     $client_home_array['DATE'] = main::convertdate("n/d/Y", $client_data['signup']);
     $client_home_array['EMAIL'] = $client_data['email'];
     $client_home_array['ALERTS'] = $dbh->config('alerts');
     $client_home_array['UNAME'] = $client_data['user'];
     $packages_data = $dbh->select("packages", array("id", "=", $client_data['pid']));
     $client_home_array['PACKAGE'] = $packages_data['name'];
     unset($where);
     $where[] = array("uid", "=", $client_data['id'], "AND");
     $where[] = array("is_paid", "=", "0");
     $invoices_query = $dbh->select("invoices", $where, 0, 0, 1);
     $client_home_array['INVOICES'] = $dbh->num_rows($invoices_query);
     unset($where);
     $where[] = array("uid", "=", $client_data['id'], "AND");
     $where[] = array("message", "LIKE", "Suspended (%");
     $suspended_data = $dbh->select("logs", $where, array("id", "DESC"), "1");
     switch ($client_data['status']) {
         default:
             $client_home_array['STATUS'] = "Other";
             break;
         case "1":
             $client_home_array['STATUS'] = "Active";
             break;
         case "2":
             $client_home_array['STATUS'] = "Suspended";
             $suspended_message = str_replace(")", "", $suspended_data['message']);
             $suspended_message = str_replace("Suspended (", "", $suspended_message);
             $client_home_array['STATUS_REASON'] = "<br><br><b>Suspended for:</b> " . $suspended_message;
             break;
         case "4":
             $client_home_array['STATUS'] = "Awaiting Payment";
             break;
         case "5":
             $client_home_array['STATUS'] = "Awaiting Email Confirmation";
             break;
         case "9":
             $client_home_array['STATUS'] = "Cancelled";
             break;
     }
     if (!$client_home_array['STATUS_REASON']) {
         $client_home_array['STATUS_REASON'] = "";
     }
     $typename = type::packagetype($client_data['pid']);
     $type_instance = $instance->packtypes[$typename];
     if (method_exists($type_instance, "clientBox")) {
         $box = $type_instance->clientBox();
         $client_home_array['BOX'] = main::sub($box[0], $box[1]);
     } else {
         $clienthome_array['BOX'] = "";
     }
     if ($dbh->config('alerts')) {
         $client_home_array['ALERTS'] = "<font size = '3'><b>Announcements:</b></font><br><font size = '2'>" . $dbh->config('alerts') . "</font><br><hr size = '1' noshade'><br>";
     } else {
         $client_home_array['ALERTS'] = "";
     }
     echo style::replaceVar("tpl/client/client-home.tpl", $client_home_array);
 }
Пример #2
0
 private function ViewClient($client)
 {
     global $dbh, $postvar, $getvar, $instance;
     $client_details_array['DATE'] = main::convertdate("n/d/Y", $client['signup']);
     $client_details_array['EMAIL'] = $client['email'];
     $client_details_array['UPGRADEINFO'] = "";
     $existing_upgrade = $dbh->select("upgrade", array("uid", "=", $client['id']));
     $all_packs_query = $dbh->select("packages", array("is_disabled", "=", "0"), array("type", "ASC"), 0, 1);
     while ($all_packs_data = $dbh->fetch_array($all_packs_query)) {
         $additional = type::additional($all_packs_data['id']);
         $monthly = $additional['monthly'];
         $signup = $additional['signup'];
         unset($info);
         if ($all_packs_data['type'] == "p2h") {
             $info = "[Signup Posts: " . $signup . ", Monthly Posts: " . $monthly . "] ";
         } elseif ($all_packs_data['type'] == "paid") {
             $info = "[" . main::money($monthly) . "] ";
         }
         $packages[] = array("[" . $all_packs_data['type'] . "] " . $info . $all_packs_data['name'], $all_packs_data['id']);
         if ($existing_upgrade && $existing_upgrade['newpack'] == $all_packs_data['id']) {
             if ($all_packs_data['admin']) {
                 $admin = " after you approve them";
             }
             if ($existing_upgrade['flags'] && $existing_upgrade['flags'] < 5) {
                 $next_cycle = " next billing cycle";
             }
             $client_details_array['UPGRADEINFO'] = "NOTE: This user is slated for an upgrade to \"" . $all_packs_data['name'] . "\"" . $next_cycle . $admin . ".<br><br>";
         }
     }
     $client_details_array['PACKAGE'] = main::dropdown("newpackage", $packages, $client['pid']);
     $client_details_array['USER'] = $client['user'];
     $client_details_array['DOMAIN'] = $client['domain'];
     $client_details_array['CLIENTIP'] = $client['ip'];
     $client_details_array['FIRSTNAME'] = $client['firstname'];
     $client_details_array['LASTNAME'] = $client['lastname'];
     $client_details_array['ADDRESS'] = $client['address'];
     $client_details_array['CITY'] = $client['city'];
     $client_details_array['STATE'] = $client['state'];
     $client_details_array['ZIP'] = $client['zip'];
     $client_details_array['COUNTRY'] = strtolower($client['country']);
     $client_details_array['FULLCOUNTRY'] = main::country_code_to_country($client['country']);
     $client_details_array['PHONE'] = $client['phone'];
     unset($where);
     $where[] = array("uid", "=", $client['id'], "AND");
     $where[] = array("is_paid", "=", "0");
     $invoices_query = $dbh->select("invoices", $where, 0, 0, 1);
     $client_details_array['INVOICES'] = $dbh->num_rows($invoices_query);
     switch ($client['status']) {
         default:
             $client_details_array['STATUS'] = "Other";
             break;
         case "1":
             $client_details_array['STATUS'] = "Active";
             break;
         case "2":
             $client_details_array['STATUS'] = "Suspended";
             break;
         case "3":
             $client_details_array['STATUS'] = "Awaiting Validation";
             break;
         case "4":
             $client_details_array['STATUS'] = "Awaiting Payment";
             break;
         case "5":
             $client_details_array['STATUS'] = "Awaiting Email Confirmation";
             break;
         case "9":
             $client_details_array['STATUS'] = "Cancelled";
             break;
     }
     $class = type::packagetype($client['pid']);
     $packtype = $instance->packtypes[$class];
     if (method_exists($packtype, "acpBox")) {
         $box = $packtype->acpBox();
         $clientview_array['BOX'] = main::sub($box[0], $box[1]);
     } else {
         $clientview_array['BOX'] = "";
     }
     $clientview_array['CONTENT'] = style::replaceVar("tpl/admin/clients/client-details.tpl", $client_details_array);
     return $clientview_array;
 }
Пример #3
0
 public function couponcheck()
 {
     global $dbh, $postvar, $getvar, $instance;
     if (empty($getvar['coupon'])) {
         echo 1;
         return;
     } else {
         $package_type = type::packagetype($getvar['package']);
         if ($package_type == "free") {
             echo 0;
             return;
         }
         $coupon_text = coupons::validate_coupon($getvar['coupon'], $getvar['location'], $getvar['username'], $getvar['package']);
         if ($coupon_text) {
             echo $coupon_text;
             return;
         } else {
             echo 0;
             return;
         }
     }
 }
Пример #4
0
 $order_form_array['ADDRESS'] = $postvar['address'];
 $order_form_array['CITY'] = $postvar['city'];
 $order_form_array['STATE'] = $postvar['state'];
 $order_form_array['ZIP'] = $postvar['zip'];
 $order_form_array['PHONE'] = $postvar['phone'];
 $order_form_array['COUPON'] = $postvar['coupon'] == "" ? $getvar['coupon'] : $postvar['coupon'];
 $order_form_array['PACKID'] = $getvar['package'];
 $domain_array['DOMAIN'] = $postvar['cdom'];
 if (empty($domain_array['DOMAIN'])) {
     $domain_array['DOMAIN'] = $postvar['csub'];
 }
 $order_form_array['TOS'] = $dbh->config("tos");
 $order_form_array['TZADJUST'] = main::tzlist($tz_default);
 $order_form_array['COUNTRIES'] = main::countries(1, $postvar['country']);
 //1 = Make it a drop down instead of pulling an array.  The second part makes it set it's default.
 $ptype = type::packagetype($getvar['package']);
 $order_form_array['TYPESPECIFIC'] = type::orderForm($ptype);
 if ($getvar['domsub'] == "dom") {
     $order_form_array['DOMORSUB'] = style::replaceVar("tpl/order/domain.tpl", $domain_array);
 } else {
     $pack = $getvar['package'];
     $server_type = type::packageserver($pack);
     $serverfile = server::createServer($server_type);
     $can_create_subs = $serverfile->subdomains;
     if ($can_create_subs == false) {
         $maincontent = main::table("Subdomain Error", "Sorry, but the server for this package doesn't allow subdomains to be used without a unique domain present on the account.  If you'd like to\n                                                                   use a domain, please go back and select the domain option.");
     } else {
         $subdomains_query = $dbh->select("subdomains", array("server", "=", $server_type), array("subdomain", "ASC"), 0, 1);
         while ($subdomains_data = $dbh->fetch_array($subdomains_query)) {
             $subdomains[] = array($subdomains_data['domain'], $subdomains_data['domain']);
         }
Пример #5
0
 public function cron()
 {
     global $dbh, $postvar, $getvar, $instance;
     if ($dbh->config("p2hcheck") == "") {
         // Probably a new install. Cron has never run before.
         $dbh->updateConfig("p2hcheck", "0:0:0");
     }
     $checkdate = explode(":", $dbh->config("p2hcheck"));
     if ($checkdate === array($dbh->config("p2hcheck"))) {
         $dbh->updateConfig("p2hcheck", $dbh->config("p2hcheck") . ":0:0");
         $checkdate = explode(":", $dbh->config("p2hcheck"));
     } elseif (array_key_exists(1, $checkdate)) {
         if ($checkdate[1] == "") {
             $dbh->updateConfig("p2hcheck", $checkdate[0] . ":0:0");
             $checkdate = explode(":", $dbh->config("p2hcheck"));
         }
     }
     // If today is the last day of the month (and hasn't been run yet)
     if (date("d") == date("t") && ((int) $checkdate[0] < (int) date("m") || (int) $checkdate[0] == (int) date("m") && $checkdate[2] == "0")) {
         $users_query = $dbh->select("users");
         while ($users_data = $dbh->fetch_array($users_query)) {
             //Skip this user if its marked as a free user.
             if ($users_data['freeuser']) {
                 continue;
             }
             $ptype = type::packagetype($users_data['pid']);
             if ($ptype == "p2h") {
                 $fuser = type::userAdditional($users_data['id']);
                 $forum = type::additional($users_data['pid'], 'forum');
                 $this->con = $this->forumCon($forum);
                 $posts = coupons::totalposts($users_data['id']);
                 $mposts = $this->getMonthly($users_data['pid'], $users_data['id']);
                 if ($posts < $mposts) {
                     // If the user haven't posted enough...
                     $user = $dbh->client($users_data['id']);
                     $grace_period = $dbh->config("p2hgraceperiod");
                     //The grace period in days
                     $grace_period = $grace_period * 24 * 60 * 60;
                     if (strtotime(date("Y-m-d") . " 00:00:00") > $users_data['signup'] + $grace_period) {
                         //This gives the user a grace period.
                         // Suspend the user.
                         server::suspend($users_data['id'], "Only posted {$posts} post out of the required {$mposts} monthly posts");
                         // Output to the cron.
                         echo "<strong>" . $user['user'] . " (" . $fuser['fuser'] . "):</strong> Suspended for not posting the required amount. ({$posts} out of {$mposts})<br />";
                     }
                 }
             }
         }
         // We're done for this month. Prepare for the next.
         if (date("m") == 12) {
             $checkmonth = "0";
         } else {
             $checkmonth = date("m");
         }
     } elseif ((int) date("d") == $dbh->config("p2hwarndate") && (int) $checkdate[1] != 1) {
         $users_query = $dbh->select("users");
         while ($users_data = $dbh->fetch_array($users_query)) {
             //Skip this user if its marked as a free user.
             if ($users_data['freeuser']) {
                 continue;
             }
             $ptype = type::packagetype($users_data['pid']);
             if ($ptype == "p2h") {
                 $fuser = type::userAdditional($users_data['id']);
                 $forum = type::additional($users_data['pid'], 'forum');
                 $this->con = $this->forumCon($forum);
                 $posts = coupons::totalposts($users_data['id']);
                 $posts_text = main::s($posts, " Post");
                 $mposts = $this->getMonthly($users_data['pid'], $users_data['id']);
                 $mposts_text = main::s($mposts, " post");
                 $config_url_data = $dbh->select("p2h", array("forumname", "=", $forum));
                 $furl = $config_url_data['value'];
                 // If the user hasn't posted enough yet
                 $grace_period = $dbh->config("p2hgraceperiod");
                 //The grace period in days
                 $grace_period = $grace_period * 24 * 60 * 60;
                 $userinfo = $dbh->client($users_data['id']);
                 $signup_date = $userinfo['signup'];
                 if (date("m") != date("m", $signup_date + $grace_period)) {
                     //If they won't be suspended on this months check, then we don't need to warn them.
                     $no_email = 1;
                 }
                 if ($posts < $mposts && !$no_email) {
                     $emaildata = email::emailTemplate("p2h-low-post-warning");
                     $p2hwarning_array['USERPOSTS'] = $posts;
                     $p2hwarning_array['MONTHLY'] = $mposts;
                     $p2hwarning_array['URL'] = $furl;
                     // Warn the user that they still have some more posting to do!
                     email::send($users_data['email'], $emaildata['subject'], $emaildata['content'], $p2hwarning_array);
                     // Output to the cron.
                     echo "<strong>" . $users_data['user'] . " (" . $fuser['fuser'] . "):</strong> Warned for not yet posting the required monthly amount. ({$posts_text} posted out of {$mposts_text}/month)<br />";
                 }
             }
         }
         // This prevents the post warnings from being sent again today/this month.
         $dbh->updateConfig("p2hcheck", $checkdate[0] . ":1:0");
     }
 }
Пример #6
0
 public function coupon($coupon, $user, $package)
 {
     if (empty($coupon)) {
         return true;
     }
     if (type::packagetype($package) == "free") {
         return false;
     }
     $coupon_text = coupons::validate_coupon($coupon, "orders", $user, $package);
     if ($coupon_text) {
         return $coupon_text;
     }
     return false;
 }
Пример #7
0
 public function validate_coupon($coupcode, $areaused, $uname, $package)
 {
     global $dbh, $postvar, $getvar, $instance;
     $userid = main::userid($uname);
     $coupon_info = self::coupon_data($coupcode);
     if (empty($coupon_info)) {
         return false;
     }
     if ($coupon_info['expiredate'] != "99/99/9999") {
         $today = time();
         $coupon_expiry = explode("/", $coupon_info['expiredate']);
         $expiry_time = mktime(date("H"), date("i"), date("s"), ltrim($coupon_expiry[0]), ltrim($coupon_expiry[1]), $coupon_expiry[2]);
         if ($today >= $expiry_time) {
             return false;
         }
     }
     if ($coupon_info['area'] != "both" && $coupon_info['area'] != $areaused) {
         return false;
     }
     if ($coupon_info['user'] != "all" && $coupon_info['user'] != $uname) {
         return false;
     }
     if ($coupon_info['packages'] != "all") {
         $available_packs = explode(",", $coupon_info['packages']);
         if (!in_array($package, $available_packs)) {
             return false;
         }
     }
     if ($coupon_info['limited']) {
         $coupons_used_query = $dbh->select("coupons_used", array("coupcode", "=", $coupcode), 0, 0, 1);
         $coupons_used_rows = $dbh->num_rows($coupons_used_query);
         if ($coupons_used_rows >= $coupon_info['limited']) {
             return false;
         }
     }
     $coupon_used = self::user_coupon_data($userid, 0, $coupcode);
     if (!empty($coupon_used) && $coupon_used['disabled'] != '2') {
         return false;
     }
     //All checks passed.
     //
     //Brok
     //    en
     //        Eng
     //           lish
     //                   lol
     $package_type = type::packagetype($package);
     $package_info = type::additional($package);
     $package_monthly = $package_info['monthly'];
     $package_p2hinit = $package_info['signup'];
     $paidtype = $coupon_info['paidtype'];
     $p2hinittype = $coupon_info['p2hinittype'];
     $p2hmonthlytype = $coupon_info['p2hmonthlytype'];
     $coupon_info['paiddisc'] = self::percent_to_value("paid", $paidtype, $coupon_info['paiddisc'], $package_monthly);
     $coupon_info['p2hinitdisc'] = self::percent_to_value("p2h", $p2hinittype, $coupon_info['p2hinitdisc'], $package_p2hinit);
     $coupon_info['p2hmonthlydisc'] = self::percent_to_value("p2h", $p2hmonthlytype, $coupon_info['p2hmonthlydisc'], $package_monthly);
     if ($package_type == "paid") {
         if ($coupon_info['paiddisc'] >= $package_monthly) {
             $coupon_text = "Free ";
         } else {
             $they_pay = $package_monthly - $coupon_info['paiddisc'];
             $currency = main::money($they_pay);
             $coupon_text = "Only pay " . $currency . " ";
             $pay_per_month = "/month";
         }
     } else {
         $init_required = $package_p2hinit - $coupon_info['p2hinitdisc'];
         $monthly_required = $package_monthly - $coupon_info['p2hmonthlydisc'];
         if ($init_required > 1) {
             $s = "s";
         }
         if ($monthly_required > 1) {
             $s2 = "s";
         }
         if ($coupon_info['p2hinitdisc'] >= $package_p2hinit) {
             $coupon_p2hdisc = "0 Posts";
         } else {
             $coupon_p2hdisc = $init_required . " Post" . $s . " required";
         }
         if ($coupon_info['p2hmonthlydisc'] >= $package_monthly) {
             $coupon_p2hmonth = "0 Posts";
         } else {
             $coupon_p2hmonth = $monthly_required . " Post" . $s2 . " required";
         }
         if ($coupon_info['p2hinitdisc'] > 0 && $coupon_info['p2hmonthlydisc'] > 0) {
             $coupon_text = $coupon_p2hdisc . " to sign up and " . $coupon_p2hmonth . " for the month";
         } else {
             if ($coupon_info['p2hinitdisc'] > 0) {
                 $coupon_text = $coupon_p2hdisc . " to sign up";
                 $no_goodfor = "1";
                 //YOU!  lol  Good for nothing?  lol
             } else {
                 $coupon_text = $coupon_p2hmonth . " for the month";
             }
         }
     }
     if ($coupon_info['goodfor'] == "life") {
         $coupon_text .= $pay_per_month . " for the lifetime of the account.";
     }
     if ($coupon_info['goodfor'] == "current") {
         $coupon_text .= " for the current month.";
     }
     if ($coupon_info['goodfor'] == "months") {
         if ($coupon_info['monthsgoodfor'] > 1) {
             $s3 = "s";
         }
         if ($no_goodfor != '1') {
             $coupon_text .= $pay_per_month . " for the next " . $coupon_info['monthsgoodfor'] . " month" . $s3 . ".";
         } else {
             $coupon_text .= ".";
             //<- It's a period.  lol
         }
     }
     $coupon_text = "<font color = '#779500'>Good for: " . $coupon_text . "</font>";
     return $coupon_text;
 }
Пример #8
0
function client()
{
    global $dbh, $postvar, $getvar, $instance;
    ob_start();
    // Stop the output buffer
    if (!$getvar['page']) {
        $getvar['page'] = "home";
    }
    $page = $dbh->select("clientnav", array("link", "=", $getvar['page']), array("id", "ASC"));
    $header = $page['visual'];
    $link = "pages/" . $getvar['page'] . ".php";
    if (!file_exists($link)) {
        $html = "That page doesn't exist.";
    } else {
        if (preg_match("/[\\.*]/", $getvar['page']) == 0) {
            include $link;
            $content = new page();
            // Main Side Bar HTML
            $nav = "Sidebar";
            if (!$dbh->config("delacc")) {
                $clientnav_query = $dbh->select("clientnav", array("link", "!=", "delete"), array("id", "ASC"), 0, 1);
            } else {
                $clientnav_query = $dbh->select("clientnav", 0, array("id", "ASC"), 0, 1);
            }
            while ($clientnav_data = $dbh->fetch_array($clientnav_query)) {
                $sidebar_link_array['IMGURL'] = $clientnav_data['icon'];
                $sidebar_link_array['LINK'] = "?page=" . $clientnav_data['link'];
                $sidebar_link_array['VISUAL'] = $clientnav_data['visual'];
                $sidebar_array['LINKS'] .= style::replaceVar("tpl/sidebar-link.tpl", $sidebar_link_array);
            }
            // Types Navbar
            $client = $dbh->client($_SESSION['cuser']);
            $packtype = $instance->packtypes[type::packagetype($client['pid'])];
            if ($packtype->clientNav) {
                foreach ($packtype->clientNav as $key2 => $value) {
                    $sidebar_link_array['IMGURL'] = $value[2];
                    $sidebar_link_array['LINK'] = "?page=type&type=" . type::packagetype($client['pid']) . "&sub=" . $value[1];
                    $sidebar_link_array['VISUAL'] = $value[0];
                    $sidebar_array['LINKS'] .= style::replaceVar("tpl/sidebar-link.tpl", $sidebar_link_array);
                    if ($getvar['page'] == "type" && $getvar['type'] == type::packagetype($client['pid']) && $getvar['sub'] == $value[1]) {
                        define("SUB", $value[3]);
                        $header = $value[3];
                        $getvar['myheader'] = $value[3];
                    }
                }
            }
            $sidebar_link_array['IMGURL'] = "delete.png";
            $sidebar_link_array['LINK'] = "?page=logout";
            $sidebar_link_array['VISUAL'] = "Logout";
            $sidebar_array['LINKS'] .= style::replaceVar("tpl/sidebar-link.tpl", $sidebar_link_array);
            $sidebar = style::replaceVar("tpl/sidebar.tpl", $sidebar_array);
            //Page Sidebar
            if ($content->navtitle) {
                $subnav = $content->navtitle;
                foreach ($content->navlist as $key => $value) {
                    $sidebar_link_array['IMGURL'] = $value[1];
                    $sidebar_link_array['LINK'] = "?page=" . $getvar['page'] . "&sub=" . $value[2];
                    $sidebar_link_array['VISUAL'] = $value[0];
                    $sub_sidebar_array['LINKS'] .= style::replaceVar("tpl/sidebar-link.tpl", $sidebar_link_array);
                }
                $subsidebar = style::replaceVar("tpl/sidebar.tpl", $sub_sidebar_array);
            }
            if ($getvar['sub'] == "delete" && isset($getvar['do']) && !$_POST && !$getvar['confirm']) {
                foreach ($postvar as $key => $value) {
                    $warning_array['HIDDEN'] .= '<input name="' . $key . '" type="hidden" value="' . $value . '" />';
                }
                $warning_array['HIDDEN'] .= " ";
                $html = style::replaceVar("tpl/warning.tpl", $warning_array);
            } elseif ($getvar['sub'] == "delete" && isset($getvar['do']) && $_POST && !$getvar['confirm']) {
                if ($postvar['yes']) {
                    foreach ($getvar as $key => $value) {
                        if ($i) {
                            $i = "&";
                        } else {
                            $i = "?";
                        }
                        $url .= $i . $key . "=" . $value;
                    }
                    $url .= "&confirm=1";
                    main::redirect($url);
                } elseif ($postvar['no']) {
                    main::done();
                }
            } else {
                if (isset($getvar['sub'])) {
                    ob_start();
                    $content->content();
                    $html = ob_get_contents();
                    // Retrieve the HTML
                    ob_clean();
                    // Flush the HTML
                } elseif ($content->navlist) {
                    if ($content->description()) {
                        $html = $content->description() . "<br><br>";
                    }
                    $html .= "Select a sub-page from the sidebar.";
                } else {
                    ob_start();
                    $content->content();
                    $html = ob_get_contents();
                    // Retrieve the HTML
                    ob_clean();
                    // Flush the HTML
                }
            }
        }
    }
    if ($getvar['sub'] && $getvar['page'] != "type") {
        foreach ($content->navlist as $key => $value) {
            if ($value[2] == $getvar['sub']) {
                define("SUB", $value[0]);
                $header = $value[0];
            }
        }
    }
    $staffuser = $dbh->client($_SESSION['cuser']);
    define("SUB", $header);
    define("INFO", '<b>Welcome back, ' . $staffuser['user'] . '</b><br />' . SUB);
    echo '<div id="left">';
    echo main::table($nav, $sidebar);
    if ($content->navtitle) {
        echo "<br />";
        echo main::table($subnav, $subsidebar);
    }
    echo '</div>';
    echo '<div id="right">';
    echo main::table($header, $html);
    echo '</div>';
    $html_buff = ob_get_contents();
    ob_clean();
    return $html_buff;
}
Пример #9
0
 public function signup($data)
 {
     global $dbh, $postvar, $getvar, $instance;
     $domain = $data['domain'];
     $username = $data['username'];
     $password = $data['password'];
     $user_email = $data['user_email'];
     $firstname = $data['firstname'];
     $lastname = $data['lastname'];
     $address = $data['address'];
     $city = $data['city'];
     $state = $data['state'];
     $zip = $data['zip'];
     $country = $data['country'];
     $phone = $data['phone'];
     $tzones = $data['tzones'];
     $coupon = $data['coupon'];
     $package = $data['package'];
     $domsub = $data['domsub'];
     $additional = $data['additional'];
     $subdomain = empty($data['subdomain']) ? 0 : $data['subdomain'];
     //Let's make sure we're actually receiving an integer as a string.
     if (!is_numeric($package) || strpos($package, ".") !== false) {
         return "The package specified is invalid.";
     }
     //Check to see if we have a valid domain type.
     if ($domsub != "dom" && $domsub != "sub") {
         return "The domain/subdomain type is unspecified in the URL.";
     }
     if ($domsub == "dom") {
         $cdom = $domain;
     } else {
         $csub2 = $domain;
         $csub = $subdomain;
     }
     unset($where);
     $where[] = array("id", "=", $package, "AND");
     $where[] = array("is_disabled", "=", "0");
     $packages_data = $dbh->select("packages", $where);
     if (!$packages_data['id']) {
         return "This package is disabled or doesn't exist.";
     }
     $package_server = $packages_data['server'];
     if ($domsub == "dom") {
         $use_dom = $cdom;
     }
     if ($domsub == "sub") {
         unset($where);
         $where[] = array("server", "=", $package_server, "AND");
         $where[] = array("domain", "=", $csub2);
         $subdomains_data = $dbh->select("subdomains", $where, 0, "1");
         if (!$subdomains_data['id']) {
             return "The chosen domain for your subdomain is not in the allowed list of domains.";
         }
         $use_dom = $csub . "." . $csub2;
     }
     if ($coupon && $packages_data['type'] != 'free') {
         $coupon_response = coupons::validate_coupon($coupon, "orders", $username, $package);
         if (!$coupon_response) {
             return "Please enter a valid coupon.";
         } else {
             $coupon_info = coupons::coupon_data($coupon);
         }
     }
     $packtype_instance = $instance->packtypes[$packages_data['type']];
     if (method_exists($packtype_instance, "signup")) {
         $packtype_signup = $packtype_instance->signup();
         //If this gives any response, it means it failed to validate the signup.
         if ($packtype_signup) {
             return $packtype_signup;
         }
     }
     $server_package_name = type::packageBackend($package);
     $serverfile = self::createServer($package);
     $packages_data = $dbh->select("packages", array("id", "=", $package));
     $extra['firstname'] = $firstname;
     $extra['lastname'] = $lastname;
     $extra['address'] = $address;
     $extra['city'] = $city;
     $extra['state'] = $state;
     $extra['zip'] = $zip;
     $extra['country'] = strtoupper($country);
     $extra['phone'] = $phone;
     $server_response = $serverfile->signup(type::packageserver($package), $packages_data['reseller'], $username, $user_email, $password, $use_dom, $server_package_name, $extra, $use_dom);
     if ($server_response !== true) {
         return $server_response;
     } else {
         $time = time();
         $ip = $_SERVER['REMOTE_ADDR'];
         $salt = crypto::salt();
         $password_hash = crypto::passhash($password, $salt);
         if ($packages_data['admin'] == "1") {
             $status = "3";
         } else {
             if ($packages_data['type'] == "paid") {
                 $status = "4";
             } else {
                 $status = "1";
             }
         }
         $users_insert = array("user" => $username, "email" => $user_email, "password" => $password_hash, "salt" => $salt, "signup" => $time, "ip" => $ip, "firstname" => $firstname, "lastname" => $lastname, "address" => $address, "city" => $city, "state" => $state, "zip" => $zip, "country" => $country, "phone" => $phone, "status" => $status, "tzadjust" => $tzones, "domain" => $use_dom, "pid" => $package, "additional" => $additional);
         $dbh->insert("users", $users_insert);
         $users_data = $dbh->select("users", array("user", "=", $username), 0, "1");
         $users_bak_insert = array("uid" => $users_data['id'], "user" => $username, "email" => $user_email, "password" => $password_hash, "salt" => $salt, "signup" => $time, "ip" => $ip, "firstname" => $firstname, "lastname" => $lastname, "address" => $address, "city" => $city, "state" => $state, "zip" => $zip, "country" => $country, "phone" => $phone, "status" => $status, "tzadjust" => $tzones, "domain" => $use_dom, "pid" => $package, "additional" => $additional);
         $dbh->insert("users_bak", $users_bak_insert);
         main::thtlog("Client Registered", 'Registered.', $users_data['id']);
         if (!$users_data['id']) {
             $return = "Your account could not be created.  Please contact your system administrator.";
         } else {
             if (!empty($coupon_info)) {
                 main::thtlog("Coupon Used", "Coupon used (" . $coupon_info['coupcode'] . ")", $users_data['id']);
                 $package_info = type::additional($package);
                 $packmonthly = $package_info['monthly'];
                 if ($packages_data['type'] == "paid") {
                     $coupon_info['p2hmonthlydisc'] = "0";
                     $coupon_info['paiddisc'] = coupons::percent_to_value("paid", $coupon_info['paidtype'], $coupon_info['paiddisc'], $packmonthly);
                 } else {
                     $coupon_info['paiddisc'] = "0";
                     $coupon_info['p2hmonthlydisc'] = coupons::percent_to_value("p2h", $coupon_info['p2hmonthlytype'], $coupon_info['p2hmonthlydisc'], $packmonthly);
                 }
                 $insert_array = array("user" => $users_data['id'], "coupcode" => $coupon_info['coupcode'], "timeapplied" => time(), "packages" => $package, "goodfor" => $coupon_info['goodfor'], "monthsgoodfor" => $coupon_info['monthsgoodfor'], "paiddisc" => $coupon_info['paiddisc'], "p2hmonthlydisc" => $coupon_info['p2hmonthlydisc']);
                 $dbh->insert("coupons_used", $insert_array);
             }
             $servers_data = $dbh->select("servers", array("id", "=", $package_server), 0, "1");
             $server_host = $servers_data['host'];
             $server_ip = $servers_data['ip'];
             $server_nameservers = $servers_data['nameservers'];
             $server_port = $servers_data['port'];
             $server_resellerport = $servers_data['resellerport'];
             $url = $dbh->config("url");
             $new_acc_email_array['CPPORT'] = $server_port;
             $new_acc_email_array['RESELLERPORT'] = $server_resellerport;
             $new_acc_email_array['SERVERIP'] = $server_ip;
             $new_acc_email_array['NAMESERVERS'] = nl2br($server_nameservers);
             $new_acc_email_array['USER'] = $username;
             $new_acc_email_array['PASS'] = $password;
             $new_acc_email_array['EMAIL'] = $user_email;
             $new_acc_email_array['FNAME'] = $firstname;
             $new_acc_email_array['LNAME'] = $lastname;
             $new_acc_email_array['DOMAIN'] = $use_dom;
             $new_acc_email_array['CONFIRM'] = $url . "client/confirm.php?u=" . $username . "&c=" . $time;
             $new_acc_email_array['PACKAGE'] = $packages_data['name'];
             if ($packages_data['admin'] == 0) {
                 if ($packages_data['reseller'] == "1") {
                     $new_acc_email = email::emailTemplate("new-reseller-account");
                 } else {
                     $new_acc_email = email::emailTemplate("new-account");
                 }
                 $return = "<strong>Your account has been created!</strong><br />You may now <a href = '../client'>login</a> to see your client area or proceed to your <a href = 'http://" . $server_host . ":" . $server_port . "'>control panel</a>. An email has been dispatched to the address on file.";
                 if (type::packagetype($package) == "paid") {
                     //Set the user up for when they finish their payment.
                     $_SESSION['clogged'] = 1;
                     $_SESSION['cuser'] = $users_data['id'];
                 }
                 $donecorrectly = true;
             } else {
                 if ($serverfile->suspend($username, type::packageserver($package), 1) == false) {
                     $return = "We could not suspend your account!  Please contact the admin to suspend it until they validate it.  lol";
                 } else {
                     $dbh->update("users", array("status" => "3"), array("id", "=", $users_data['id']));
                     if ($packages_data['reseller'] == "1") {
                         $new_acc_email = email::emailTemplate("new-reseller-account-adminval");
                     } else {
                         $new_acc_email = email::emailTemplate("new-account-adminval");
                     }
                     $admin_val_email = email::emailTemplate("admin-validation-requested");
                     $valarray['LINK'] = $dbh->config("url") . ADMINDIR . "/?page=users&sub=search&do=" . $users_data['id'];
                     email::staff($admin_val_email['subject'], $admin_val_email['content'], $valarray);
                     $return = "<strong>Your account is awaiting admin validation!</strong><br />An email has been dispatched to the address on file. You will recieve another email when the admin has looked over your account.";
                     $donecorrectly = true;
                 }
             }
             email::send($new_acc_email_array['EMAIL'], $new_acc_email['subject'], $new_acc_email['content'], $new_acc_email_array);
         }
         if ($donecorrectly && type::packagetype($package) == "paid") {
             $amountinfo = type::additional($package);
             $amount = $amountinfo['monthly'];
             $due = time() + 2592000;
             $notes = "Your hosting package invoice for this billing cycle. Package: " . $packages_data['name'];
             if (!empty($coupon_info)) {
                 $amount = max(0, $amount - $coupon_info['paiddisc']);
             }
             invoice::create($users_data['id'], $amount, $due, $notes);
             $serverfile->suspend($username, type::packageserver($package), 0, 1);
             $dbh->update("users", array("status" => $status), array("id", "=", $users_data['id']));
             if ($packages_data['admin'] != "1") {
                 $return = '<div class="errors"><b>You are being redirected to payment! It will load in a couple of seconds.</b></div>';
                 return true;
             }
         }
         return $return;
     }
 }