當前位置: 首頁>>代碼示例>>PHP>>正文


PHP main::uname方法代碼示例

本文整理匯總了PHP中main::uname方法的典型用法代碼示例。如果您正苦於以下問題:PHP main::uname方法的具體用法?PHP main::uname怎麽用?PHP main::uname使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在main的用法示例。


在下文中一共展示了main::uname方法的6個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1: TerminateClient

 private function TerminateClient($client)
 {
     global $dbh, $postvar, $getvar, $instance;
     if (!$postvar['submitreason']) {
         $client_uname = main::uname($client['id']);
         $reason_array['WARNTEXT'] = 'CAUTION: If you proceed, the account "' . $client_uname . '" will be completely and irrevocably removed from the server and THT.<br><br>Why are you terminating this account? Leave blank if you just feel like terminating them.';
         $reason_array['ACTION'] = 'terminating';
         $reason_array['ACTIONBUTT'] = 'Terminate Client';
         $clientview_array['BOX'] = "";
         $clientview_array['CONTENT'] = style::replaceVar("tpl/admin/clients/reason.tpl", $reason_array);
         return $clientview_array;
     } else {
         $command = server::terminate($client['id'], $postvar['reason']);
         if ($command == true) {
             //Terminated
             main::done();
         } else {
             main::errors($command);
         }
     }
 }
開發者ID:cozylife,項目名稱:tht-reworked,代碼行數:21,代碼來源:users.php

示例2: content

 public function content()
 {
     global $dbh, $postvar, $getvar, $instance;
     if (main::isint(str_replace("P2H-", "", $getvar['view']))) {
         //Display the invoice
         if (substr_count($getvar['view'], "P2H-")) {
             $p2hid = str_replace("P2H-", "", $getvar['view']);
             $userid = $dbh->select("users", array("id", "=", $p2hid));
             $userid = $userid['id'];
             $userdata = coupons::admin_userdata($userid);
         } else {
             $invoiceid = $getvar['view'];
             $invoice_data_top = $dbh->select("invoices", array("id", "=", $invoiceid));
             $pid = $invoice_data_top['pid'];
             $userid = $invoice_data_top['uid'];
             $uidtopack = main::uidtopack($userid, $pid);
             if (!$pid) {
                 $dbh->update("invoices", array("pid" => $uidtopack['pid']), array("id", "=", $invoice_data_top['id']));
             }
             $userdata = coupons::admin_userdata($userid);
         }
         if ($_POST['submitaddcoupon']) {
             if (!$postvar['addcoupon']) {
                 main::errors("Please enter a coupon code.");
             } else {
                 $coupcode = $postvar['addcoupon'];
                 $user = main::uname($userid);
                 $pack_data = main::uidtopack($userid, $pid);
                 $packid = $pack_data['packages']['id'];
                 $multi_coupons = $dbh->config("multicoupons");
                 if ($p2hid) {
                     $monthly = $pack_data['additional']['monthly'];
                     $monthly = coupons::get_discount("p2hmonthly", $monthly, $userid);
                     $total_posted = coupons::totalposts($userid);
                     $amt_owed = max(0, $monthly - $total_posted);
                 } else {
                     $invoice_info = $dbh->select("invoices", array("id", "=", $invoiceid));
                     if ($invoice_info['pid'] != $pack_data['pid']) {
                         $pack_data = upgrade::pidtobak($invoice_info['pid'], $invoice_info["uid"]);
                     }
                     $total_paid = coupons::totalpaid($invoiceid);
                     $amt_owed = max(0, $invoice_info['amount'] - $total_paid);
                 }
                 if ($amt_owed == 0) {
                     main::errors("The user's balance is already paid in full, so you can't add another coupon.");
                 } else {
                     $coupon_info = coupons::coupon_data($coupcode);
                     $coupid = $coupon_info['id'];
                     $use_coupon = coupons::use_coupon($coupid, $packid, $invoiceid, $userid);
                     if (!$use_coupon) {
                         if (!$multi_coupons) {
                             main::errors("Coupon code entered was invalid or user is already using a coupon.  You can give them a credit instead.");
                         } else {
                             main::errors("Coupon code entered was invalid or the user is already using this coupon.");
                         }
                     } else {
                         main::redirect("?page=invoices&view=" . $getvar['view']);
                     }
                 }
             }
         }
         if ($_POST['submitcredit']) {
             $postvar['credit'] = str_replace(array(" ", ","), array("", "."), $postvar['credit']);
             if (!is_numeric($postvar['credit'])) {
                 main::errors("Please enter the amount to be credited or debited.");
             } else {
                 if ($postvar['creditreason']) {
                     $creditreason = $postvar['creditreason'];
                     $creditreason = ' <a title="' . $creditreason . '" class="tooltip"><img src="<URL>themes/icons/information.png"></a>';
                     $creditreason = str_replace(",", "", $creditreason);
                     //Can't have commas, no way no how!  ;)  lol  We need to be able to explode(",", $invoice_info['txn']);
                 }
                 if ($p2hid) {
                     $credit_fee = $postvar['credit'];
                 } else {
                     $credit_fee = main::addzeros($postvar['credit']);
                 }
                 if ($credit_fee != 0) {
                     if (substr_count($credit_fee, "-")) {
                         $creditfee_lable = "CHARGE";
                     } else {
                         $creditfee_lable = "CREDIT";
                     }
                     $packinfo = main::uidtopack($userid, $pid);
                     if (!$packinfo['user_data']['pid'] && !$p2hid) {
                         $packinfo = upgrade::pidtobak($pid, $userid);
                     }
                     $monthly = $packinfo['additional']['monthly'];
                     if ($p2hid) {
                         $amt_owed = max(0, $monthly - coupons::totalposts($userid));
                     } else {
                         $amt_owed = max(0, $monthly - coupons::totalpaid($invoiceid));
                     }
                     if ($amt_owed == 0 && $creditfee_lable == "CREDIT") {
                         main::errors("The user's balance is already paid in full, so you can't add a credit.");
                     } else {
                         if ($p2hid) {
                             $p2h_info = $dbh->select("coupons_p2h", array("uid", "=", $userid));
                             if ($p2h_info['datepaid']) {
                                 $comma = ",";
//.........這裏部分代碼省略.........
開發者ID:cozylife,項目名稱:tht-reworked,代碼行數:101,代碼來源:invoices.php

示例3: prorate

 public function prorate($pid, $coupcode = "", $userid = "", $admin = "")
 {
     global $dbh, $postvar, $getvar, $instance;
     if (!$userid) {
         $userid = $_SESSION['cuser'];
     }
     $upackinfo = main::uidtopack($userid);
     $umonthly = $upackinfo['additional']['monthly'];
     $usignup = $upackinfo['additional']['signup'];
     $utype = $upackinfo['packages']['type'];
     $pack_data = $dbh->select("packages", array("id", "=", $pid));
     $packinfo = type::additional($pid);
     $monthly = $packinfo['monthly'];
     $signup = $packinfo['signup'];
     $pack_type = $pack_data['type'];
     //For P2H
     $umonthly_discount = max(0, coupons::get_discount("p2hmonthly", $umonthly, $userid));
     if ($coupcode) {
         $user = main::uname($userid);
         $response = coupons::validate_coupon($coupcode, "orders", $user, $pid);
         if ($response) {
             $coup_data = coupons::coupon_data($coupcode);
             $signup = max(0, $signup - $coup_data['p2hinitdisc']);
         }
     }
     switch ($utype) {
         case "free":
             switch ($pack_type) {
                 case "free":
                     //No need to prorate it.
                     return "now";
                     break;
                 case "paid":
                     //No need to prorate it.
                     return "now";
                     break;
                 case "p2h":
                     if ($upackinfo['uadditional']['fuser']) {
                         $total_posts = coupons::totalposts($userid, $pid);
                         if ($total_posts < $signup) {
                             $inelegible = 1;
                         }
                     } else {
                         $check = 1;
                     }
                     if (!$inelegible && !$check || $admin && !$check) {
                         //They haven't paid yet, so they can get the account changed now.
                         return "now";
                     } elseif ($inelegible && !$admin) {
                         //They don't have the required number of posts made to be allowed to switch to this plan.
                         return "inelegible";
                     } elseif ($check) {
                         //We need to check if they have enough posts to be allowed to change the plan.  This means the user has to enter their credentials for the forum since we don't have it yet.
                         return "check";
                     }
                     break;
             }
             break;
         case "paid":
             unset($where);
             $where[] = array("uid", "=", $userid, "AND");
             $where[] = array("changed_plan", "=", "0");
             $invoices_query = $dbh->select("invoices", $where, 0, 0, 1);
             while ($invoices_data = $dbh->fetch_array($invoices_query)) {
                 $paid = coupons::totalpaid($invoices_data['id']);
                 if ($paid >= $invoices_data['amount'] && $paid > 0) {
                     $amt_owed = $monthly - $paid;
                     $prorate = 1;
                 }
                 if ($paid < $invoices_data['amount']) {
                     //They change to a different paid plan only.  The new plan will be added to the newest invoice anyway.
                     $owes_money = 1;
                 }
                 if ($not_first_pull) {
                     //This avoids having someone upgrade and not pay that bill, then upgrade again and not pay that bit, etc.  The system only charges
                     //the upgrade price and keeps the transactions on the last invoice.  This means that if you have a plan for $2, $3, $4, and $5, then
                     //the user can simply upgrade until they're on the highest plan and and pay only a couple bucks more than the plan they started on,
                     //all the while receiving free months of service.  Then they downgrade to the lowest plan the next month and it starts over again.
                     //So we need to know if the user paid last month's bill along with the other bills before it so they can upgrade only if they did.
                     $cant_upgrade = $owes_money;
                 }
                 $not_first_pull = 1;
             }
             switch ($pack_type) {
                 case "free":
                     if ($owes_money && !$admin) {
                         //Total paid is less than $0, so that means they've been charged for something.  We can't let then leave the paid plan system so the invoice isn't lost.
                         return "owe";
                     } else {
                         //Next month they become a free member
                         $upgrade_today = self::upgrade_today($utype, $userid);
                         if ($upgrade_today) {
                             return "now";
                         } else {
                             return "next";
                         }
                     }
                     break;
                 case "paid":
                     if ($monthly > $umonthly && $owes_money || !$owes_money && !$cant_upgrade) {
//.........這裏部分代碼省略.........
開發者ID:cozylife,項目名稱:tht-reworked,代碼行數:101,代碼來源:class_upgrade.php

示例4: content

 public function content()
 {
     global $dbh, $postvar, $getvar, $instance;
     $upackinfo = main::uidtopack();
     $currentpack = $upackinfo['user_data']['pid'];
     $packsid = $postvar['packs'];
     if (!$packsid) {
         $packsid = $getvar['package'];
     }
     unset($where);
     if (is_numeric($packsid)) {
         $where[] = array("id", "=", $packsid, "AND");
     } else {
         $where[] = array("is_hidden", "=", "0", "AND");
     }
     $where[] = array("is_disabled", "=", "0", "AND");
     $where[] = array("id", "!=", $currentpack);
     $packages_order[] = array("type", "ASC");
     $packages_order[] = array("name", "ASC");
     $packages_query = $dbh->select("packages", $where, $packages_order, 0, 1);
     $upgrade_array['PACK'] = "";
     while ($packages_data = $dbh->fetch_array($packages_query)) {
         $additional = type::additional($packages_data['id']);
         $monthly = $additional['monthly'];
         $signup = $additional['signup'];
         unset($info);
         if ($packages_data['type'] == "p2h") {
             $info = "[Signup Posts: " . $signup . ", Monthly Posts: " . $monthly . "] ";
             $contribution = "<strong>Signup Posts:</strong> " . $signup . "<br><strong>Monthly Posts:</strong> " . $monthly;
         } elseif ($packages_data['type'] == "paid") {
             $info = "[" . main::money($monthly) . "] ";
             $contribution = main::money($monthly);
         } else {
             $contribution = "Free";
         }
         $packages[] = array("[" . $packages_data['type'] . "] " . $info . $packages_data['name'], $packages_data['id']);
         if ($packsid && $packsid == $packages_data['id']) {
             $prorate = upgrade::prorate($packages_data['id'], $postvar['coupon']);
             $package_array['DISABLED'] = "";
             if ($prorate == "inelegible") {
                 main::errors("You are currently not elegible for the plan selected because you do not have enough posts.<br><br>");
                 $package_array['DISABLED'] = "disabled";
             }
             if ($prorate == "owe") {
                 main::errors("You have outstanding charges on your account and can only upgrade your paid package.  Your charges are outstanding!  Keep up the good work.  lol<br><br>");
                 $package_array['DISABLED'] = "disabled";
             }
             if ($prorate == "oweposts") {
                 main::errors("You still owe your required monthly posts and can only upgrade to a paid plan until you finish your posting quota.  Our forum is a lot of fun, so come join us!  =)<br><br>");
                 $package_array['DISABLED'] = "disabled";
             }
             if ($prorate == "next" || $prorate == "check next") {
                 main::errors("If you choose this package, you'll be upgraded at the start of your next billing cycle.  If you do not wish to wait, please contact us.<br><br>");
                 $next_month = 1;
             }
             if (is_numeric($prorate) && $prorate > 0) {
                 $contribution .= " (You pay only <font color = '#FF0055'>" . main::money($prorate) . "</font> more today to upgrade.)";
             }
             if ($prorate == "check" || $prorate == "check next" || $prorate == "check now") {
                 $fuser = $postvar['fuser'];
                 $fpass = $postvar['fpass'];
                 $forum_credentials_array['FUSER'] = $fuser;
                 $forum_credentials_array['FPASS'] = $fpass;
                 $package_array['FORUMINFO'] = style::replaceVar("tpl/upgrade/forum-credentials.tpl", $forum_credentials_array);
             } else {
                 if ($packages_data['type'] == "p2h") {
                     $fuser = $upackinfo['uadditional']['fuser'];
                     $fpass = $upackinfo['uadditional']['fpass'];
                     $no_fcheck = 1;
                 }
                 $package_array['FORUMINFO'] = "";
             }
             $coupon_entry_array['COUPCODE'] = "";
             $coupon_entry_array['COUPTEXT'] = "";
             $coupon_entry_array['COUPCODEVALID'] = "";
             if ($packages_data['type'] == "p2h" && $prorate != "owe") {
                 //Paid users can enter them when they pay the invoice and free users don't need coupons.
                 $coupcode = $postvar['coupon'];
                 $validcoupon = $postvar['validcoupon'];
                 if ($postvar['addcoupon']) {
                     $uname = main::uname($_SESSION['cuser']);
                     if ($coupcode) {
                         $response = coupons::validate_coupon($coupcode, "orders", $uname, $packsid);
                         if ($response) {
                             $coup_data = coupons::coupon_data($coupcode);
                             $discount = $coup_data['p2hinitdisc'];
                             $multi_coupons = $dbh->config("multicoupons");
                             if ($multi_coupons) {
                                 $discount = $discount + upgrade::get_init_discount();
                             }
                             $total_posts = coupons::totalposts($_SESSION['cuser'], $packages_data['id']) + $discount;
                             if ($total_posts < $signup) {
                                 $error = 1;
                                 main::errors("You are currently not elegible for the plan selected because you do not have enough posts.<br><br>");
                                 $package_array['DISABLED'] = "disabled";
                                 $coupon_entry_array['COUPCODEVALID'] = "";
                             } else {
                                 $prorate = upgrade::prorate($packages_data['id'], $coupcode);
                                 if ($prorate == "next" || $prorate == "check next" || $prorate == "inelegible") {
                                     //We know they're eligible or they wouldn't be at this stage.  It just doesn't check existing coupons.
//.........這裏部分代碼省略.........
開發者ID:cozylife,項目名稱:tht-reworked,代碼行數:101,代碼來源:upgrade.php

示例5: use_coupon

 public function use_coupon($coupid, $package, $invoiceid = "", $userid = "", $area = "invoices")
 {
     global $dbh, $postvar, $getvar, $instance;
     if (!$userid) {
         $userid = $_SESSION['cuser'];
     }
     $user = main::uname($userid);
     $multi_coupons = $dbh->config("multicoupons");
     $coupon_info = self::coupon_data("", $coupid);
     $coupon_vailidate = self::validate_coupon($coupon_info['coupcode'], $area, $user, $package);
     if ($coupon_vailidate) {
         unset($where);
         $where[] = array("user", "=", $userid, "AND");
         $where[] = array("disabled", "=", 0);
         $user_has_coupons = $dbh->select("coupons_used", $where);
         if ($multi_coupons || empty($user_has_coupons)) {
             unset($where);
             $where[] = array("user", "=", $userid, "AND");
             $where[] = array("coupcode", "=", ${$coupon_info}['coupcode']);
             $user_coupon = $dbh->select("coupons_used", $where);
             $pack_info = main::uidtopack($userid);
             $monthly = $pack_info['additional']['monthly'];
             if ($user_coupon['disabled'] == '2') {
                 //This prevents the user from removing the coupon before its expired and then adding it back in so they can reset its expiration date.
                 $datedisabled = $user_coupon['datedisabled'];
                 $timeapplied = $user_coupon['timeapplied'];
                 $difference = $datedisabled - $timeapplied;
                 $time = time();
                 $timeapplied = $time - $difference;
                 $update = array("disabled" => "0", "timeapplied" => $timeapplied);
                 $where[] = array("user", "=", $userid, "AND");
                 $where[] = array("coupcode", "=", $coupon_info['coupcode']);
                 $dbh->update("coupons_used", $update, $where);
                 main::thtlog("Coupon Re-Enabled", "Coupon renabled (" . $coupon_info['coupcode'] . ")", $userid);
             } else {
                 $coupon_info['paiddisc'] = self::percent_to_value("paid", $coupon_info['paidtype'], $coupon_info['paiddisc'], $monthly);
                 $coupon_info['p2hmonthlydisc'] = self::percent_to_value("p2h", $coupon_info['p2hmonthlytype'], $coupon_info['p2hmonthlydisc'], $monthly);
                 $coupons_used_insert = array("user" => $userid, "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", $coupons_used_insert);
                 main::thtlog("Coupon Used", "Coupon used (" . $coupon_info['coupcode'] . ")", $userid);
             }
             if ($invoiceid) {
                 $total = self::get_discount("paid", $monthly, $userid);
                 if ($total) {
                     $paid = "0";
                 } else {
                     $paid = "1";
                 }
                 $update = array("amount" => $total, "is_paid" => $paid);
                 $where[] = array("id", "=", $invoiceid);
                 $dbh->update("invoices", $update, $where);
             }
             return true;
         } else {
             return false;
         }
     } else {
         return false;
     }
 }
開發者ID:cozylife,項目名稱:tht-reworked,代碼行數:60,代碼來源:class_coupons.php

示例6: content

 public function content()
 {
     global $dbh, $postvar, $getvar, $instance;
     if (is_numeric($getvar['view'])) {
         //Show the invoice
         unset($where);
         $where[] = array("uid", "=", $_SESSION['cuser'], "AND");
         $where[] = array("id", "=", $getvar['view']);
         $invoice_info_top = $dbh->select("invoices", $where);
         $pack_data_top = main::uidtopack();
         if (!$invoice_info_top['pid']) {
             $dbh->update("invoices", array("pid" => $pack_data_top['user_data']['pid']), array("id", "=", $invoice_info_top['id']));
             $invoice_info_top['pid'] = $pack_data_top['user_data']['pid'];
         }
         if ($_POST['submitaddcoupon']) {
             if (!$postvar['addcoupon']) {
                 main::errors("Please enter a coupon code or click the checkout button.");
             } else {
                 $coupcode = $postvar['addcoupon'];
                 $user = main::uname($_SESSION['cuser']);
                 $pack_data = main::uidtopack();
                 if ($invoice_info_top['pid'] != $pack_data['user_data']['pid']) {
                     $pack_data = upgrade::pidtobak($invoice_info_top['pid']);
                 }
                 $packid = $pack_data['packages']['id'];
                 $multi_coupons = $dbh->config("multicoupons");
                 $coupon_info = coupons::coupon_data($coupcode);
                 $coupid = $coupon_info['id'];
                 $use_coupon = coupons::use_coupon($coupid, $packid, $getvar['view']);
                 if (!$use_coupon) {
                     if (!$multi_coupons) {
                         main::errors("Coupon code entered was invalid or you're already using a coupon.");
                     } else {
                         main::errors("Coupon code entered was invalid.");
                     }
                 } else {
                     main::redirect("?page=invoices&view=" . $getvar['view']);
                 }
             }
         }
         unset($where);
         $where[] = array("uid", "=", $_SESSION['cuser'], "AND");
         $where[] = array("id", "=", $getvar['view']);
         $invoice_info = $dbh->select("invoices", $where);
         if (empty($invoice_info)) {
             main::redirect("?page=invoices");
             exit;
         }
         $package = $dbh->select("packages", array("id", "=", $invoice_info['pid']));
         $monthly = type::additional($package['id']);
         $subtotal = $monthly['monthly'];
         if (is_numeric($getvar['remove'])) {
             $remove_id = $getvar['remove'];
             $remove = coupons::remove_coupon($remove_id, $package['id'], $invoice_info['id'], $_SESSION['cuser']);
             main::redirect("?page=invoices&view=" . $invoice_info['id']);
             exit;
         }
         $total_paid_real = coupons::totalpaid($getvar['view']);
         if ($total_paid_real < 0) {
             $total_paid = "0.00";
         } else {
             $total_paid = $total_paid_real;
         }
         $acct_balance = coupons::get_discount("paid", $subtotal) - $total_paid_real;
         if ($acct_balance < 0) {
             $acct_balance = "0.00";
         }
         $acct_balance = main::addzeros($acct_balance);
         if ($acct_balance == 0 && $invoice_info['is_paid'] == '0') {
             $dbh->update("invoices", array("is_paid" => "1"), array("id", "=", $invoice_info['id']), "1");
             main::redirect("?page=invoices&view=" . $invoice_info['id']);
         }
         if ($acct_balance > 0 && $invoice_info['is_paid'] == '1') {
             $dbh->update("invoices", array("is_paid" => "0"), array("id", "=", $invoice_info['id']), "1");
             main::redirect("?page=invoices&view=" . $invoice_info['id']);
         }
         if ($_POST['checkout']) {
             $postvar['paythis'] = str_replace(array(" ", ","), array("", "."), $postvar['paythis']);
             if (!is_numeric($postvar['paythis'])) {
                 main::errors("Please enter the amount you wish to pay today.");
             } else {
                 if ($postvar['paythis'] > $acct_balance || $acct_balance <= 0) {
                     main::errors("You can't pay more than you owe.  =)");
                 } else {
                     $dbh->update("invoices", array("pay_now" => $postvar['paythis']), array("id", "=", $getvar['view']));
                     main::redirect("?page=invoices&iid=" . $getvar['view']);
                     exit;
                 }
             }
         }
         $created = $invoice_info['created'];
         $thirty_days = 30 * 24 * 60 * 60;
         $orig_due = $created + $thirty_days;
         if (main::convertdate("n/d/Y", $invoice_info['due']) != main::convertdate("n/d/Y", $created + $thirty_days)) {
             $due_text = " (Originally " . main::convertdate("n/d/Y", $orig_due) . ")";
         }
         $due = main::convertdate("n/d/Y", $invoice_info['due']);
         $client = $dbh->client($_SESSION['cuser']);
         $invoice_transactions_array['TOTALAMOUNT'] = main::money($acct_balance);
         $invoice_transactions_array['TOTALPAID'] = main::money($total_paid);
//.........這裏部分代碼省略.........
開發者ID:cozylife,項目名稱:tht-reworked,代碼行數:101,代碼來源:invoices.php


注:本文中的main::uname方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。