コード例 #1
0
 public function sendEmailChangeMailAdmin($newEmail)
 {
     $to = ADMIN_EMAIL;
     $subject = 'AI Club - Email Changed';
     $arrData['{EMAIL}'] = $newEmail;
     $objEmail = new email();
     $EmailBody = $objEmail->emailTemplate('member_email_changed_admin', $arrData);
     $objEmail->sendmail($to, $subject, $EmailBody);
 }
コード例 #2
0
 public function sendPasswordChangedEmail1($row)
 {
     global $objComm, $DB;
     $to = ADMIN_EMAIL;
     $subject = 'AI Club - Password Change‏‏d';
     $arrData['{NAME}'] = $row->fname;
     $arrData['{EMAIL}'] = $row->email_address;
     $arrData['{BIRTHDATE}'] = $row->birth_date;
     $objEmail = new email();
     $EmailBody = $objEmail->emailTemplate('new_password_changed', $arrData);
     $objEmail->sendmail($to, $subject, $EmailBody);
 }
コード例 #3
0
 public function sendmail()
 {
     $to = $this->row->email_address;
     //$to 	 = '*****@*****.**';
     $subject = 'AI Club - Your Memeber account created successfully';
     $arrData['{FIRST_NAME}'] = $this->row->fname;
     $arrData['{EMAIL}'] = $this->row->email_address;
     $arrData['{PASSWORD}'] = $_REQUEST['data_password'];
     $arrData['{URL}'] = SITE_PATH . "/index.php";
     $objEmail = new email();
     $EmailBody = $objEmail->emailTemplate('member_login', $arrData);
     $objEmail->sendmail($to, $subject, $EmailBody);
 }
コード例 #4
0
 public function create($uid, $amount, $due, $notes)
 {
     global $dbh, $postvar, $getvar, $instance;
     $client = $dbh->client($uid);
     $emailtemp = email::emailTemplate("new-invoice");
     $newinvoice_array['USER'] = $client['user'];
     $newinvoice_array['AMOUNT'] = main::addzeros($amount);
     $newinvoice_array['LINK'] = $dbh->config("url") . "/client/?page=invoices";
     $newinvoice_array['DUE'] = main::convertdate("n/d/Y", $due, $uid);
     $is_paid = $newinvoice_array['AMOUNT'] == "0.00" ? "1" : "0";
     email::send($client['email'], $emailtemp['subject'], $emailtemp['content'], $newinvoice_array);
     unset($where);
     $where[] = array("amount", "=", "0", "OR");
     $where[] = array("amount", "=", "0.00");
     $dbh->update("invoices", array("is_paid" => "1"), $where);
     //This way people won't see unpaid invoices for $0.
     $invoices_insert = array("uid" => $uid, "amount" => $amount, "created" => time(), "due" => $due, "notes" => $notes, "pay_now" => $amount, "is_paid" => $is_paid);
     $response = $dbh->insert("invoices", $invoices_insert);
     return $response;
 }
コード例 #5
0
ファイル: users.php プロジェクト: cozylife/tht-reworked
 private function ApproveClientUpgrades()
 {
     global $dbh, $postvar, $getvar, $instance;
     if (is_numeric($getvar['do'])) {
         $upgrade_stubid = $getvar['do'];
         $upgrade_stub_data = $dbh->select("upgrade", array("id", "=", $upgrade_stubid));
         $client = $dbh->client($upgrade_stub_data['uid']);
         $user_data = main::uidtopack($upgrade_stub_data['uid']);
         $new_pack_data = $dbh->select("packages", array("id", "=", $upgrade_stub_data['newpack']));
         if ($getvar['accept']) {
             switch ($upgrade_stub_data['flags']) {
                 case "2":
                     $dbh->update("upgrade", array("flags" => "1"), array("id", "=", $upgrade_stubid), "1");
                     if (upgrade::do_upgrade($upgrade_stubid, "Update", 1) === false) {
                         $dbh->update("upgrade", array("flags" => "2"), array("id", "=", $upgrade_stubid), "1");
                         echo "<br><br>";
                     } else {
                         main::errors("The user has been prepared for their upgrade at the end of their current billing cycle.<br>");
                     }
                     break;
                 case "3":
                     $dbh->update("upgrade", array("flags" => "4"), array("id", "=", $upgrade_stubid), "1");
                     if (upgrade::do_upgrade($upgrade_stubid, "Update", 1) === false) {
                         $dbh->update("upgrade", array("flags" => "3"), array("id", "=", $upgrade_stubid), "1");
                         echo "<br><br>";
                     } else {
                         main::errors("The user has been prepared for their upgrade <font color = '#779500'>on the new server</font> at the end of their current billing cycle.<br>");
                     }
                     break;
                 case "5":
                     $dbh->update("upgrade", array("flags" => "0"), array("id", "=", $upgrade_stubid), "1");
                     if (upgrade::do_upgrade($upgrade_stubid, "Update", 1) === false) {
                         $dbh->update("upgrade", array("flags" => "5"), array("id", "=", $upgrade_stubid), "1");
                         echo "<br><br>";
                     } else {
                         main::errors("The user has been upgraded.<br>");
                     }
                     break;
                 case "6":
                     $dbh->update("upgrade", array("flags" => "7"), array("id", "=", $upgrade_stubid), "1");
                     if (upgrade::do_upgrade($upgrade_stubid, "Update", 1) === false) {
                         $dbh->update("upgrade", array("flags" => "6"), array("id", "=", $upgrade_stubid), "1");
                         echo "<br><br>";
                     } else {
                         main::errors("The user has been upgraded and is now <font color = '#779500'>on the new server</font>.  Please be sure to remove the account on the old server when the user has migrated their website.<br>");
                     }
                     break;
             }
         } else {
             $dbh->delete("upgrade", array("id", "=", $upgrade_stubid), "1");
             main::errors("The user's upgrade request has been denied.<br>");
             $deny_array['OLDPLAN'] = $user_data['packages']['name'];
             $deny_array['NEWPLAN'] = $new_pack_data['name'];
             $uemaildata = email::emailTemplate("client-upgrade-denied");
             email::send($client['email'], $uemaildata['subject'], $uemaildata['content'], $deny_array);
             main::thtlog("Upgrade Denied", "Upgrade denied for " . $client['user'] . " <br><b>Current package: </b>" . $user_data['packages']['name'] . " <br><b>Requested package: </b>" . $new_pack_data['name'], $upgrade_stub_data['uid']);
         }
     }
     unset($where);
     $where[] = array("flags", "=", "2", "OR");
     $where[] = array("flags", "=", "3", "OR");
     $where[] = array("flags", "=", "5", "OR");
     $where[] = array("flags", "=", "6");
     $upgrade_req_query = $dbh->select("upgrade", $where, 0, 0, 1);
     if ($dbh->num_rows($upgrade_req_query) == 0) {
         echo "<ERRORS>No clients are awaiting upgrade approval.";
     } else {
         $tpl .= "<ERRORS>The users listed here have prequalified for upgrades, but admin approval was needed on the packages they selected.";
         while ($upgrade_req_data = $dbh->fetch_array($upgrade_req_query)) {
             $client = $dbh->client($upgrade_req_data['uid']);
             $user_data = main::uidtopack($upgrade_req_data['uid']);
             $new_pack_data = $dbh->select("packages", array("id", "=", $upgrade_req_data['newpack']));
             if ($upgrade_req_data['flags'] == "2" || $upgrade_req_data['flags'] == "3") {
                 $approve_upgrades_array['EFFECTIVE'] = "Next Billing Cycle";
             } else {
                 $approve_upgrades_array['EFFECTIVE'] = "Immediately";
             }
             $approve_upgrades_array['USER'] = $client['user'];
             $approve_upgrades_array['EMAIL'] = $client['email'];
             $approve_upgrades_array['DOMAIN'] = $user_data['user_data']['domain'];
             $approve_upgrades_array['OLDPLAN'] = $user_data['packages']['name'];
             $approve_upgrades_array['NEWPLAN'] = $new_pack_data['name'];
             $approve_upgrades_array['NEWSERVER'] = $user_data['packages']['server'] != $new_pack_data['server'] ? "<font color = '#FF0055'>Yes</font>" : "<font color = '#779500'>No</font>";
             $approve_upgrades_array['ID'] = $upgrade_req_data['id'];
             $approve_upgrades_array['CLIENTID'] = $upgrade_req_data['uid'];
             $tpl .= style::replaceVar("tpl/admin/upgrades/approve-upgrades.tpl", $approve_upgrades_array);
         }
         echo $tpl;
     }
 }
コード例 #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
ファイル: p2h.php プロジェクト: cozylife/tht-reworked
 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");
     }
 }
コード例 #8
0
ファイル: index.php プロジェクト: cozylife/tht-reworked
             $where[] = array("user", "=", $user, "AND");
             $where[] = array("email", "=", $user_email);
             $find_staff_query = $dbh->select("staff", $where, 0, 0, 1);
             if ($dbh->num_rows($find_staff_query) == 0) {
                 main::errors("That account doesn't exist!");
             } else {
                 $curstaff = $dbh->fetch_array($find_staff_query);
                 $password = rand(0, 999999);
                 $salt = crypto::salt();
                 $newpass = crypto::passhash($password, $salt);
                 $update_staff = array("password" => $newpass, "salt" => $salt);
                 $dbh->update("staff", $update_staff, array("id", "=", $curstaff['id']));
                 main::errors("Password reset!");
                 $forgotpass_email_array['PASS'] = $password;
                 $forgotpass_email_array['LINK'] = $dbh->config("url") . ADMINDIR;
                 $emaildata = email::emailTemplate("admin-password-reset");
                 email::send($user_email, $emaildata['subject'], $emaildata['content'], $forgotpass_email_array);
             }
         }
     }
     echo '<div align="center">' . main::table("Admin Area - Reset Password", style::replaceVar("tpl/admin/login/admin-password-reset.tpl"), "300px") . '</div>';
     echo style::get("footer.tpl");
 } else {
     define("SUB", "Login");
     define("INFO", "<b>Welcome to <NAME></b><br>" . SUB);
     if ($_POST) {
         // If user submitts form
         if (main::staffLogin($postvar['user'], $postvar['pass'])) {
             $queryString = $_SERVER["QUERY_STRING"];
             if ($queryString == "") {
                 $queryString = "page=home";
コード例 #9
0
ファイル: tickets.php プロジェクト: cozylife/tht-reworked
 public function content()
 {
     global $dbh, $postvar, $getvar, $instance;
     if ($getvar['mode'] == 'ticketsall') {
         $no_tickets_msg = "You currently have no tickets.";
         $view_mode_text = "<center><i><u><a href=\"?page=tickets\" title=\"View open tickets\">View open tickets</a></u></i></center>";
     } else {
         $where[] = array("status", "!=", "3", "AND");
         $no_tickets_msg = "You currently have no new tickets! <i><u><a href=\"?page=tickets&mode=ticketsall\" title=\"View all tickets.\">View all tickets</a></u></i>";
         $view_mode_text = "<center><i><u><a href=\"?page=tickets&mode=ticketsall\" title=\"View all tickets\">View all tickets</a></u></i></center>";
     }
     if (!$getvar['do']) {
         $where[] = array("reply", "=", "0");
         $tickets_query = $dbh->select("tickets", $where, array("time", "DESC"), 0, 1);
         if (!$dbh->num_rows($tickets_query)) {
             echo $no_tickets_msg;
         } else {
             if ($getvar['mode'] == 'ticketsall') {
                 echo "<div style=\"display: none;\" id=\"nun-tickets\">You currently have no tickets!</div>";
             } else {
                 echo "<div style=\"display: none;\" id=\"nun-tickets\">You currently have no new tickets!</div>";
             }
             $num_rows = $dbh->num_rows($tickets_query);
             echo style::replaceVar("tpl/admin/tickets/tickets-js.tpl", array('NUM_TICKETS' => $num_rows));
             while ($tickets_data = $dbh->fetch_array($tickets_query)) {
                 $ticket_view_box_array['TITLE'] = $tickets_data['title'];
                 $ticket_view_box_array['UPDATE'] = $this->lastUpdated($tickets_data['id']);
                 $ticket_view_box_array['STATUS'] = $tickets_data['status'];
                 $ticket_view_box_array['STATUSMSG'] = $this->status($tickets_data['status']);
                 $ticket_view_box_array['ID'] = $tickets_data['id'];
                 $ticket_view_box_array['URGENCYTEXT'] = $tickets_data['urgency'];
                 $ticket_view_box_array['URGENCY_CLASS'] = strtolower(str_replace(" ", "_", $tickets_data['urgency']));
                 echo style::replaceVar("tpl/admin/tickets/ticket-view-box.tpl", $ticket_view_box_array);
             }
             echo $view_mode_text;
         }
     } else {
         unset($where);
         $where[] = array("id", "=", $getvar['do'], "OR");
         $where[] = array("ticketid", "=", $getvar['do']);
         $tickets_query = $dbh->select("tickets", $where, array("time", "ASC"), 0, 1);
         if (!$dbh->num_rows($tickets_query)) {
             echo "That ticket doesn't exist!";
         } else {
             if ($_POST) {
                 check::empty_fields(array("admin"));
                 if (!main::errors()) {
                     $time = time();
                     $tickets_insert = array("title" => $postvar['title'], "content" => $postvar['content'], "time" => $time, "userid" => $_SESSION['user'], "reply" => "1", "ticketid" => $getvar['do'], "staff" => "1");
                     $dbh->insert("tickets", $tickets_insert);
                     main::errors("Reply has been added!");
                     $last_ticket_data = $dbh->select("tickets", array("time", "=", $time), 0, "1");
                     $tickets_data = $dbh->fetch_array($tickets_query);
                     $client = $dbh->staff($_SESSION['user']);
                     $user = $dbh->client($tickets_data['userid']);
                     $template = email::emailTemplate("ticket-staff-responded");
                     $clientresponse_array['TITLE'] = $tickets_data['title'];
                     $clientresponse_array['STAFF'] = $client['name'];
                     $clientresponse_array['CONTENT'] = $postvar['content'];
                     $clientresponse_array['LINK'] = $dbh->config("url") . "/client/?page=tickets&sub=view&do=" . $last_ticket_data['ticketid'];
                     email::send($user['email'], $template['subject'], $template['content'], $clientresponse_array);
                     main::redirect("?page=tickets&sub=view&do=" . $getvar['do']);
                 }
             }
             $tickets_data = $dbh->fetch_array($tickets_query);
             $view_ticket_array['AUTHOR'] = $this->determineAuthor($tickets_data['userid'], $tickets_data['staff']);
             $view_ticket_array['TIME'] = main::convertdate("n/d/Y - g:i A", $tickets_data['time']);
             $view_ticket_array['NUMREPLIES'] = $dbh->num_rows($tickets_query) - 1;
             $view_ticket_array['UPDATED'] = $this->lastUpdated($tickets_data['id']);
             $view_ticket_array['ORIG'] = $this->showReply($tickets_data['id']);
             $view_ticket_array['URGENCY'] = $tickets_data['urgency'];
             $view_ticket_array['STATUS'] = $this->status($tickets_data['status']);
             switch ($tickets_data['status']) {
                 case "1":
                     $view_ticket_array['STATUSCOLOR'] = "779500";
                     break;
                 case "2":
                     $view_ticket_array['STATUSCOLOR'] = "FF9500";
                     break;
                 case "3":
                     $view_ticket_array['STATUSCOLOR'] = "FF0000";
                     break;
                 default:
                     $view_ticket_array['STATUSCOLOR'] = "000000";
                     break;
             }
             $view_ticket_array['REPLIES'] = "";
             $n = 0;
             while ($reply = $dbh->fetch_array($tickets_query)) {
                 if (!$n) {
                     $view_ticket_array['REPLIES'] .= "<br /><b>Replies</b>";
                 }
                 $view_ticket_array['REPLIES'] .= $this->showReply($reply['id']);
                 $n++;
             }
             $view_ticket_array['ADDREPLY'] .= "<br /><b>Change Ticket Status</b>";
             $values[] = array("Open", 1);
             $values[] = array("On Hold", 2);
             $values[] = array("Closed", 3);
             $change_status_array['DROPDOWN'] = main::dropdown("status", $values, $tickets_data['status'], 0);
             $change_status_array['ID'] = $tickets_data['id'];
             $view_ticket_array['ADDREPLY'] .= style::replaceVar("tpl/tickets/change-status.tpl", $change_status_array);
             $view_ticket_array['ADDREPLY'] .= "<br /><b>Add Reply</b>";
             $add_reply_array['TITLE'] = "RE: " . $tickets_data['title'];
             $view_ticket_array['ADDREPLY'] .= style::replaceVar("tpl/tickets/add-reply.tpl", $add_reply_array);
             echo style::replaceVar("tpl/tickets/view-ticket.tpl", $view_ticket_array);
         }
     }
 }
コード例 #10
0
 public function sendmail($to, $RandomString)
 {
     $subject = 'AI Club - verify your account';
     $arrData['{FIRST_NAME}'] = $this->arrField['fname'];
     $arrData['{URL}'] = SITE_PATH . "/verification.php?code=" . $RandomString;
     $objEmail = new email();
     $EmailBody = $objEmail->emailTemplate('member_register', $arrData);
     $objEmail->sendmail($to, $subject, $EmailBody);
 }
コード例 #11
0
ファイル: tickets.php プロジェクト: cozylife/tht-reworked
 public function content()
 {
     global $dbh, $postvar, $getvar, $instance;
     switch ($getvar['sub']) {
         default:
             if ($_POST) {
                 check::empty_fields();
                 if (!main::errors()) {
                     $time = time();
                     $tickets_insert = array("title" => $postvar['title'], "content" => $postvar['content'], "urgency" => $postvar['urgency'], "time" => $time, "userid" => $_SESSION['cuser']);
                     $dbh->insert("tickets", $tickets_insert);
                     $last_ticket_data = $dbh->select("tickets", array("time", "=", $time), 0, "1");
                     $template = email::emailTemplate("new-ticket");
                     $newticket_array['TITLE'] = $postvar['title'];
                     $newticket_array['URGENCY'] = $postvar['urgency'];
                     $newticket_array['CONTENT'] = $postvar['content'];
                     $newticket_array['LINK'] = $dbh->config("url") . ADMINDIR . "/?page=tickets&sub=view&do=" . $last_ticket_data['id'];
                     email::staff($template['subject'], $template['content'], $newticket_array);
                     main::errors("Ticket has been added!");
                 }
             }
             echo style::replaceVar("tpl/client/tickets/add-ticket.tpl");
             break;
         case "view":
             if (is_numeric($getvar['deltid'])) {
                 $userid = $_SESSION['cuser'];
                 $tid = $getvar['deltid'];
                 unset($where);
                 $where[] = array("id", "=", $tid, "AND");
                 $where[] = array("userid", "=", $userid);
                 $user_check = $dbh->select("tickets", $where, 0, "1", 1);
                 $user_check_rows = $dbh->num_rows($user_check);
                 if ($user_check_rows == "0") {
                     echo "<font color = '#FF0000'>This ticket is not yours to delete or does not exist.</font><br>";
                 } else {
                     unset($where);
                     $where[] = array("id", "=", $tid, "OR");
                     $where[] = array("ticketid", "=", $tid);
                     $dbh->delete("tickets", $where);
                 }
             }
             if (!$getvar['do']) {
                 unset($where);
                 $where[] = array("userid", "=", $_SESSION['cuser'], "AND");
                 $where[] = array("reply", "=", "0");
                 $tickets_query = $dbh->select("tickets", $where, 0, 0, 1);
                 if (!$dbh->num_rows($tickets_query)) {
                     echo "You currently have no tickets!";
                 } else {
                     while ($tickets_data = $dbh->fetch_array($tickets_query)) {
                         $ticket_view_box_array['TITLE'] = $tickets_data['title'];
                         $ticket_view_box_array['UPDATE'] = $this->lastUpdated($tickets_data['id']);
                         $ticket_view_box_array['ID'] = $tickets_data['id'];
                         $ticket_view_box_array['STATUS'] = $tickets_data['status'];
                         $ticket_view_box_array['STATUSMSG'] = $this->status($tickets_data['status']);
                         echo style::replaceVar("tpl/client/tickets/ticket-view-box.tpl", $ticket_view_box_array);
                     }
                 }
             } else {
                 unset($where);
                 $where[] = array("id", "=", $getvar['do'], "OR");
                 $where[] = array("ticketid", "=", $getvar['do']);
                 $tickets_query = $dbh->select("tickets", $where, array("time", "ASC"), 0, 1);
                 if (!$dbh->num_rows($tickets_query)) {
                     echo "That ticket doesn't exist!";
                 } else {
                     if ($_POST) {
                         check::empty_fields();
                         if (!main::errors()) {
                             $time = time();
                             $tickets_insert = array("title" => $postvar['title'], "content" => $postvar['content'], "time" => $time, "userid" => $_SESSION['cuser'], "reply" => "1", "ticketid" => $getvar['do']);
                             $dbh->insert("tickets", $tickets_insert);
                             $last_ticket_data = $dbh->select("tickets", array("time", "=", $time), 0, "1");
                             $tickets_data = $dbh->fetch_array($tickets_query);
                             $client = $dbh->client($_SESSION['cuser']);
                             $template = email::emailTemplate("ticket-client-responded");
                             $newresponse_array['TITLE'] = $tickets_data['title'];
                             $newresponse_array['USER'] = $client['user'];
                             $newresponse_array['CONTENT'] = $postvar['content'];
                             $newresponse_array['LINK'] = $dbh->config("url") . ADMINDIR . "/?page=tickets&sub=view&do=" . $last_ticket_data['ticketid'];
                             email::staff($template['subject'], $template['content'], $newresponse_array);
                             main::redirect("?page=tickets&sub=view&do=" . $getvar['do']);
                         }
                     }
                     $tickets_data = $dbh->fetch_array($tickets_query);
                     $view_ticket_array['AUTHOR'] = $this->determineAuthor($tickets_data['userid'], $tickets_data['staff']);
                     $view_ticket_array['TIME'] = main::convertdate("n/d/Y - g:i A", $tickets_data['time']);
                     $view_ticket_array['NUMREPLIES'] = $dbh->num_rows($tickets_query) - 1;
                     $view_ticket_array['UPDATED'] = $this->lastUpdated($tickets_data['id']);
                     $view_ticket_array['ORIG'] = $this->showReply($tickets_data['id']);
                     $view_ticket_array['URGENCY'] = $tickets_data['urgency'];
                     $view_ticket_array['STATUS'] = $this->status($tickets_data['status']);
                     switch ($tickets_data['status']) {
                         case "1":
                             $view_ticket_array['STATUSCOLOR'] = "779500";
                             break;
                         case "2":
                             $view_ticket_array['STATUSCOLOR'] = "FF9500";
                             break;
                         case "3":
                             $view_ticket_array['STATUSCOLOR'] = "FF0000";
                             break;
                         default:
                             $view_ticket_array['STATUSCOLOR'] = "000000";
                             break;
                     }
                     $n = 0;
                     $view_ticket_array['REPLIES'] = "";
                     while ($reply = $dbh->fetch_array($tickets_query)) {
                         if (!$n) {
                             $view_ticket_array['REPLIES'] .= "<br /><b>Replies</b>";
                         }
                         $view_ticket_array['REPLIES'] .= $this->showReply($reply['id']);
                         $n++;
                     }
                     $view_ticket_array['ADDREPLY'] .= "<br /><b>Change Ticket Status</b>";
                     $values[] = array("Open", 1);
                     $values[] = array("On Hold", 2);
                     $values[] = array("Closed", 3);
                     $client_change_status_array['DROPDOWN'] = main::dropdown("status", $values, $tickets_data['status'], 0);
                     $client_change_status_array['ID'] = $tickets_data['id'];
                     $view_ticket_array['ADDREPLY'] .= style::replaceVar("tpl/tickets/change-status.tpl", $client_change_status_array);
                     $view_ticket_array['ADDREPLY'] .= "<br /><b>Add Reply</b>";
                     $add_reply_array['TITLE'] = "RE: " . $tickets_data['title'];
                     $view_ticket_array['ADDREPLY'] .= style::replaceVar("tpl/tickets/add-reply.tpl", $add_reply_array);
                     echo style::replaceVar("tpl/tickets/view-ticket.tpl", $view_ticket_array);
                 }
             }
             break;
     }
 }
コード例 #12
0
ファイル: index.php プロジェクト: cozylife/tht-reworked
         if (!main::errors()) {
             $user = $postvar['user'];
             $email_reset = $postvar['email'];
             unset($where);
             $where[] = array("user", "=", $user, "AND");
             $where[] = array("email", "=", $email_reset);
             $client = $dbh->select("users", $where);
             if (!$client['user']) {
                 main::errors("That account doesn't exist!");
             } else {
                 $password = rand();
                 $cmd = main::changeClientPassword($client['id'], $password);
                 main::errors("Password reset!");
                 $forgot_pass_array['PASS'] = $password;
                 $forgot_pass_array['LINK'] = $dbh->config("url") . "/client";
                 $emaildata = email::emailTemplate("client-password-reset");
                 email::send($email_reset, $emaildata['subject'], $emaildata['content'], $forgot_pass_array);
             }
         }
     }
     echo '<div align="center">' . main::table("Client Area - Reset Password", style::replaceVar("tpl/client/login/client-password-reset.tpl"), "300px") . '</div>';
     echo style::get("footer.tpl");
 } else {
     define("SUB", "Login");
     define("INFO", "<b>Welcome to <NAME></b><br>" . SUB);
     if ($_POST) {
         if (main::clientLogin($postvar['user'], $postvar['pass'])) {
             main::redirect("?page=home");
         } else {
             main::errors("Incorrect username or password or account not active!");
         }
コード例 #13
0
 public function unsuspend($id, $noemail = 0)
 {
     global $dbh, $postvar, $getvar, $instance;
     unset($where);
     $where[] = array("id", "=", $id, "AND");
     $where[] = array("status", "=", "2", "OR", 1);
     $where[] = array("status", "=", "3", "OR");
     $where[] = array("status", "=", "4", "", 1);
     $users_data = $dbh->select("users", $where);
     if (!$users_data['id']) {
         $error_array['Error'] = "That package doesn't exist or cannot be unsuspended!";
         $error_array['User PID'] = $id;
         main::error($error_array);
         return;
     } else {
         $server = type::packageserver($users_data['pid']);
         $serverfile = self::createServer($users_data['pid']);
         if ($serverfile->unsuspend($users_data['user'], $server) == true) {
             if (!$noemail) {
                 $emaildata = email::emailTemplate("account-unsuspended");
                 email::send($users_data['email'], $emaildata['subject'], $emaildata['content']);
                 $package_server_data = $dbh->select("servers", array("id", "=", type::packageserver($client['pid'])));
                 $admin_notifyunsuspend = email::emailTemplate("notify-admin-of-unsuspension");
                 $notifyunsuspend_array['USER'] = $users_data['user'];
                 $notifyunsuspend_array['SERV_TYPE'] = $package_server_data['type'];
                 $notifyunsuspend_array['SERV_NAME'] = $package_server_data['name'];
                 email::staff($admin_notifyunsuspend['subject'], $admin_notifyunsuspend['content'], $notifyunsuspend_array);
             }
             $dbh->update("users_bak", array("status" => "1"), array("id", "=", $users_data['id']));
             $dbh->update("users", array("status" => "1"), array("id", "=", $users_data['id']));
             main::thtlog("Client Account Unsuspended", "Unsuspended", $users_data['id']);
             return true;
         } else {
             return false;
         }
     }
 }