/** * Delete a radius account */ function p_delete() { $db =& DB(); $db->Execute(sqlDelete($db, "radius", "service_id={$this->service['id']}")); $db->Execute(sqlDelete($db, "radius_service", "service_id={$this->service['id']}")); return true; }
/** * Allow user to delete a card on file */ function user_delete($VAR) { # Verify the current account owns this billing record $dbx =& DB(); $sql = 'SELECT * FROM ' . AGILE_DB_PREFIX . 'account_billing WHERE id = ' . $dbx->qstr(@$VAR['id']) . ' AND account_id = ' . $dbx->qstr(SESS_ACCOUNT) . ' AND site_id = ' . $dbx->qstr(DEFAULT_SITE); $rs = $dbx->Execute($sql); if (@$rs->RecordCount() == 0) { return false; } global $C_debug, $C_translate; # Validate this isn't the only card on file $rs = $dbx->Execute(sqlSelect($dbx, "account_billing", "id", "id=::" . $VAR['id'] . "::")); if ($rs && $rs->RecordCount()) { $msg = $C_translate->translate('card_in_use', 'account_billing', ''); $C_debug->alert($msg); return false; } # Validate the card isn't in use $rs = $dbx->Execute(sqlSelect($dbx, "service", "id", "account_billing_id=::" . $VAR['id'] . ":: AND account_id=::" . SESS_ACCOUNT . ":: AND active=1")); if ($rs && $rs->RecordCount()) { $msg = $C_translate->translate('card_in_use', 'account_billing', ''); $C_debug->alert($msg); return false; } # Delete the card $sql = sqlDelete($dbx, "account_billing", "id=::" . $VAR['id'] . ":: AND account_id=::" . SESS_ACCOUNT . "::"); $dbx->Execute($sql); $msg = $C_translate->translate('card_removed', 'account_billing', ''); $C_debug->alert($msg); return true; }
function update($VAR) { global $C_list, $C_debug; if (!$this->checkLimits()) { return false; } // check account limits // validate the tax_id global $VAR; require_once PATH_MODULES . 'tax/tax.inc.php'; $taxObj = new tax(); $tax_arr = @$VAR['account_admin_tax_id']; if (is_array($tax_arr)) { foreach ($tax_arr as $country_id => $tax_id) { if ($country_id == $VAR['account_admin_country_id']) { $exempt = @$VAR["account_tax_id_exempt"][$country_id]; if (!($txRs = $taxObj->TaxIdsValidate($country_id, $tax_id, $exempt))) { $this->validated = false; global $C_translate; $this->val_error[] = array('field' => 'account_admin_tax_id', 'field_trans' => $taxObj->errField, 'error' => $C_translate->translate('validate_general', "", "")); } if ($exempt) { $VAR['account_admin_tax_id'] = false; } else { $VAR['account_admin_tax_id'] = $tax_id; } } } } #################################################################### ### Get required static_Vars and validate them... return an array ### w/ ALL errors... #################################################################### require_once PATH_CORE . 'static_var.inc.php'; $static_var = new CORE_static_var(); if (!isset($this->val_error)) { $this->val_error = false; } $all_error = $static_var->validate_form('account', $this->val_error); if ($all_error != false && gettype($all_error) == 'array') { $this->validated = false; } else { $this->validated = true; } #################################################################### # If validation was failed, skip the db insert & # set the errors & origonal fields as Smarty objects, # and change the page to be loaded. #################################################################### if (!$this->validated) { global $smarty; # set the errors as a Smarty Object $smarty->assign('form_validation', $all_error); # set the page to be loaded if (!defined("FORCE_PAGE")) { define('FORCE_PAGE', $VAR['_page_current']); } return; } ### Get the old username ( for db mapping ) $db =& DB(); $sql = 'SELECT username FROM ' . AGILE_DB_PREFIX . 'account WHERE site_id = ' . $db->qstr(DEFAULT_SITE) . ' AND id = ' . $db->qstr($VAR['account_admin_id']); $result = $db->Execute($sql); if ($result->RecordCount() > 0) { $old_username = $result->fields['username']; } ### Update the password: $update_password = false; if (!empty($VAR['_password'])) { $VAR['account_admin_password'] = $VAR['_password']; /* check if new password is ok */ if ($C_list->is_installed('account_password_history')) { include_once PATH_MODULES . 'account_password_history/account_password_history.inc.php'; $accountHistory = new account_password_history(); if (!$accountHistory->getIsPasswordOk($VAR['account_admin_id'], $VAR['account_admin_password'], false)) { $C_debug->alert("The password you have selected has been used recently and cannot be used again at this time for security purposes."); unset($VAR['account_admin_password']); } else { $update_password = true; } } } ### Update the record $type = "update"; $this->method["{$type}"] = explode(",", $this->method["{$type}"]); $db = new CORE_database(); $ok = $db->update($VAR, $this, $type); if ($ok) { /* password logging class */ if ($update_password && is_object($accountHistory)) { $accountHistory->setNewPassword($VAR['account_admin_id'], $VAR["account_admin_password"], false); } ### Update the static vars: $static_var->update($VAR, 'account', $VAR['account_admin_id']); ### Do any db_mapping if ($C_list->is_installed('db_mapping')) { include_once PATH_MODULES . 'db_mapping/db_mapping.inc.php'; $db_map = new db_mapping(); if (!empty($VAR['account_admin_password'])) { $db_map->plaintext_password = $VAR['account_admin_password']; } else { $db_map->plaintext_password = false; } $db_map->account_edit($VAR['account_admin_id'], $old_username); } // remove login lock if ($VAR['account_admin_status']) { $db =& DB(); $delrs = $db->Execute($sql = sqlDelete($db, "login_lock", "account_id={$VAR['account_admin_id']}")); $delrs = $db->Execute($sql = sqlDelete($db, "login_log", "account_id={$VAR['account_admin_id']} AND status=0")); } return true; } }
function importFaults() { $rawusers = fopen(FIRSTBASE . "/import/hdusers.csv", "r"); $baka = sqlPull(array("table" => "users", "where" => "personid=" . $_SESSION["userid"], "onerow" => 1)); print "I know who you are, " . $baka["firstname"] . "..."; exit; $where = "1=1"; sqlDelete(array("table" => "fs_faults", "where" => $where)); $userlist = array(); while (!feof($rawusers)) { $rawline = fgets($rawusers, 4096); $rawarray = explode(";", $rawline); $id = str_replace("\"", "", $rawarray[0]); $firstname = str_replace("\"", "", $rawarray[2]); $firstname = str_replace("-", "", $firstname); $firstname = str_replace(" ", "", $firstname); $lastname = str_replace("\"", "", $rawarray[1]); if ($firstname && $lastname) { $where = "firstname LIKE '" . $firstname . "' AND lastname LIKE '" . $lastname . "'"; $username = strtolower("del" . $lastname . $firstname[0]); $username = str_replace(" ", "", $username); $userlist[$id]["username"] = $username; $userlist[$id]["firstname"] = $firstname; $userlist[$id]["lastname"] = $lastname; } } fclose($rawusers); //importUsers(); $rawdata = fopen(FIRSTBASE . "/import/helpdesk.csv", "r"); while (!feof($rawdata)) { $rawline = fgets($rawdata, 4096); $rawline = str_replace("\"", "", $rawline); $rawarray = explode(";", $rawline); $source = sqlPull(array("table" => "users", "where" => "firstname LIKE '" . $firstsource . "'")); $firstsource = $userlist[$rawarray[3]]["firstname"]; $lastsource = $userlist[$rawarray[3]]["lastname"]; $source = sqlPull(array("table" => "users", "where" => "firstname LIKE '" . $firstsource . "' AND lastname LIKE '" . $lastsource . "'", "onerow" => 1)); $comment = str_replace("'", "", $rawarray[2]); $firstit = $userlist[$rawarray[5]]["firstname"]; $lastit = $userlist[$rawarray[5]]["lastname"]; $it = sqlPull(array("table" => "users", "where" => "firstname LIKE '" . $firstit . "' AND lastname LIKE '" . $lastit . "'", "onerow" => 1)); $startdate = strtotime($rawarray[1]); $enddate = strtotime($rawarray[7]); $data["itid"] = $it["personid"]; $data["sourceid"] = $source["personid"]; $data["typeid"] = -1; $data["comment"] = $comment; $data["date"] = $startdate; $data["complete"] = $enddate; if ($enddate) { sqlCreate(array("table" => "fs_faults", "fields" => $data)); } } fclose($rawdata); }
function update($VAR) { global $VAR; ### Check that user is logged in: if (SESS_LOGGED != '1') { echo "Sorry, you must be logged in!"; } /* check for sub account */ $issubaccount = false; if (!empty($VAR['account_id']) && $VAR['account_id'] != SESS_ACCOUNT) { if ($this->isParentAccount($VAR['account_id'])) { $VAR['id'] = $VAR['account_id']; global $smarty; $issubaccount = true; } else { return false; } } else { $VAR['id'] = SESS_ACCOUNT; $VAR['account_id'] = SESS_ACCOUNT; } $VAR['account_date_last'] = time(); // validate the tax_id require_once PATH_MODULES . 'tax/tax.inc.php'; $taxObj = new tax(); $tax_arr = @$VAR['account_tax_id']; if (is_array($tax_arr)) { foreach ($tax_arr as $country_id => $tax_id) { if ($country_id == $VAR['cid']) { $exempt = @$VAR["account_tax_id_exempt"][$country_id]; if (!($txRs = $taxObj->TaxIdsValidate($country_id, $tax_id, $exempt))) { $this->validated = false; global $C_translate; $this->val_error[] = array('field' => 'account_tax_id', 'field_trans' => $taxObj->errField, 'error' => $C_translate->translate('validate_general', "", "")); } if ($exempt) { $VAR['account_tax_id'] = false; } else { $VAR['account_tax_id'] = $tax_id; } } } } #################################################################### ### Get required static_Vars and validate them... return an array ### w/ ALL errors... #################################################################### require_once PATH_CORE . 'static_var.inc.php'; $static_var = new CORE_static_var(); if (!isset($this->val_error)) { $this->val_error = false; } $all_error = $static_var->validate_form('account', $this->val_error); if ($all_error != false && gettype($all_error) == 'array') { $this->validated = false; } else { $this->validated = true; } #################################################################### # If validation was failed, skip the db insert & # set the errors & origonal fields as Smarty objects, # and change the page to be loaded. #################################################################### if (!$this->validated) { global $smarty; # set the errors as a Smarty Object $smarty->assign('form_validation', $all_error); # set the page to be loaded if (!defined("FORCE_PAGE")) { define('FORCE_PAGE', $VAR['_page_current']); } return; } ### Change password $password_changed = false; if (isset($VAR['account_password']) && $VAR['account_password'] != "") { if (isset($VAR['confirm_password']) && $VAR['account_password'] == $VAR['confirm_password']) { $password = $VAR['account_password']; unset($VAR['account_password']); @($VAR["account_password"] = $password); ### Alert: the password has been changed! global $C_debug, $C_translate; $C_debug->alert($C_translate->translate('password_changed', 'account', '')); $password_changed = true; /* check if new password is ok */ global $C_list; if ($C_list->is_installed('account_password_history')) { include_once PATH_MODULES . 'account_password_history/account_password_history.inc.php'; $accountHistory = new account_password_history(); if (!$accountHistory->getIsPasswordOk(SESS_ACCOUNT, $VAR['account_password'], false)) { $C_debug->alert("The password you have selected has been used recently and cannot be used again at this time for security purposes."); unset($VAR["account_password"]); $password_changed = false; } } } else { ### ERROR: The passwords provided do not match! global $C_debug, $C_translate; $C_debug->alert($C_translate->translate('password_change_match', 'account', '')); unset($VAR["account_password"]); } } else { unset($VAR["account_password"]); } ### Change theme if (isset($VAR['tid']) && $VAR['tid'] != "") { @($VAR["account_theme_id"] = $VAR['tid']); } ### Change Language if (isset($VAR['lid']) && $VAR['lid'] != "") { @($VAR["account_language_id"] = $VAR['lid']); } ### Change country if (isset($VAR['cid']) && $VAR['cid'] != "") { @($VAR["account_country_id"] = $VAR['cid']); } ### Change currency if (isset($VAR['cyid']) && $VAR['cyid'] != "") { @($VAR["account_currency_id"] = $VAR['cyid']); } ### Get the old username ( for db mapping ) $db =& DB(); $sql = 'SELECT username FROM ' . AGILE_DB_PREFIX . 'account WHERE site_id = ' . $db->qstr(DEFAULT_SITE) . ' AND id = ' . $db->qstr(SESS_ACCOUNT); $result = $db->Execute($sql); if ($result->RecordCount() > 0) { $old_username = $result->fields['username']; } ### Update the record $this->account_construct(); $type = "update"; $this->method["{$type}"] = split(",", $this->method["{$type}"]); $db = new CORE_database(); $db->update($VAR, $this, $type); /* password logging class */ if ($password_changed && is_object($accountHistory)) { $accountHistory->setNewPassword(SESS_ACCOUNT, $VAR['account_password'], false); } ### Update the static vars: $static_var->update($VAR, 'account', SESS_ACCOUNT); ### Do any db_mapping global $C_list; if ($C_list->is_installed('db_mapping')) { include_once PATH_MODULES . 'db_mapping/db_mapping.inc.php'; $db_map = new db_mapping(); if (!empty($password)) { $db_map->plaintext_password = $password; } else { $db_map->plaintext_password = false; } $db_map->account_edit(SESS_ACCOUNT, $old_username); } /* update groups for subaccount */ if ($issubaccount) { $db =& DB(); $db->Execute(sqlDelete($db, "account_group", "group_id>2 and \n\t\t\t\t(service_id is null or service_id=0 or service_id='') \n\t\t\t\tand account_id=" . $db->qstr($VAR['account_id']))); if (!empty($VAR['groups'])) { global $C_auth; foreach ($VAR['groups'] as $gid => $val) { if ($gid == $val && $C_auth->auth_group_by_id($gid)) { $fields = array('account_id' => $VAR['account_id'], 'group_id' => $gid, 'active' => 1, 'date_orig' => time()); $db->Execute(sqlInsert($db, "account_group", $fields)); } } } } }
/** Save updated rate tables for product */ function products($VAR) { $product = $VAR['product']; $avail = $VAR['avail']; $assigned = @$VAR['assigned']; $db =& DB(); // clean out any selected ids from the 'assigned' array if (is_array($assigned)) { foreach ($assigned as $voip_rate_id) { $db->Execute(sqlDelete($db, "voip_rate_prod", " product_id = ::{$product}:: AND voip_rate_id = {$voip_rate_id}")); } } // add any selected ids from the 'avail' array if (is_array($avail)) { foreach ($avail as $voip_rate_id) { $fields = array('product_id' => $product, 'voip_rate_id' => $voip_rate_id); $id = $db->Execute(sqlInsert($db, "voip_rate_prod", $fields)); } } }
function delete_voicemail(&$didClass) { $db =& DB(); if (!is_a($didClass, 'voipDID')) { die('parameter must be of voipDID'); } $db->Execute($sql = sqlDelete($db, "voip_vm", "context=::default:: and mailbox=::" . $didClass->getDID() . "::")); #echo $sql."<BR />"; }
/** * Change the quantity of an item */ function changeqty($VAR) { if (empty($this->account_id)) { $this->account_id = SESS_ACCOUNT; } if (empty($this->session_id)) { $this->session_id = SESS; } @($id = $VAR['id']); @($qty = $VAR['qty']); if ($id <= 0) { return; } $db =& DB(); if ($qty == '0') { # Product Plugin Level deletion $cartid =& $db->Execute($sql = sqlSelect($db, "cart", "*", "id=::{$id}:: AND session_id = ::{$this->session_id}::")); if ($cartid) { $product =& $db->Execute($sql = sqlSelect($db, "product", "*", "id=::{$cartid->fields['product_id']}::")); } if (!empty($product->fields['prod_plugin']) && !empty($product->fields['prod_plugin_data'])) { $prodplgfile = PATH_PLUGINS . 'product/' . $product->fields['prod_plugin_file'] . '.php'; if (is_file($prodplgfile)) { include_once PATH_PLUGINS . 'product/' . $product->fields['prod_plugin_file'] . '.php'; eval('$prodplg = new plgn_prov_' . $product->fields['prod_plugin_file'] . ';'); if (is_object($prodplg)) { if (is_callable(array($prodplg, 'delete_cart'))) { $prodplg->delete_cart($VAR, $cartid->fields); } } } } # delete main cart items & subitems: $sql = ''; if (empty($this->admin)) { $sql = "AND session_id = ::{$this->session_id}::"; } $rs =& $db->Execute($sql = sqlDelete($db, "cart", "(id=::{$id}:: OR cart_parent_id=::{$id}:: ) {$sql}")); global $smarty; $smarty->assign('js', false); return false; } # update the quantity: if (!eregi("^[0-9]{1,5}\$", $qty)) { $qty = 1; } if ($qty < 1) { $qty = 1; } if (!$this->admin) { $sql_extra = " AND session_id=::{$this->session_id}::"; } else { $sql_extra = ''; } if ($VAR["type"] == 1) { $fields = array('quantity' => $qty); $db->Execute($sql = sqlUpdate($db, "cart", $fields, "id=::{$id}:: {$sql_extra}")); } else { if ($VAR["type"] == 2) { $fields = array('recurr_schedule' => $VAR["schedule"]); $db->Execute($sql = sqlUpdate($db, "cart", $fields, "id=::{$id}:: {$sql_extra}")); } else { if ($VAR["type"] == 3) { # change domain term $fields = array('domain_term' => $VAR["term"]); $db->Execute($sql = sqlUpdate($db, "cart", $fields, "id=::{$id}:: {$sql_extra}")); } } } # get the product id: $result = $db->Execute(sqlSelect($db, "cart", "*", "id={$id} {$sql_extra}", "cart_type,date_orig")); # get the product details: $product = $db->Execute(sqlSelect($db, "product", "*", "id={$result->fields["product_id"]}")); if ($result->fields["cart_type"] == "2") { # domain name, get pricing include_once PATH_MODULES . 'host_tld/host_tld.inc.php'; $tldObj = new host_tld(); $tldprice = $tldObj->price_tld_arr($result->fields["domain_tld"], $result->fields["host_type"], false, false, false, $this->account_id); $qty = $result->fields["domain_term"]; $base_price = $tldprice[$qty]; $setup_price = 0; } else { if ($result->fields["cart_type"] == "3") { # ad-hoc, get price $base_price = $result->fields["ad_hoc_amount"] * $result->fields["quantity"]; $setup_price = $result->fields["ad_hoc_setup"] * $result->fields["quantity"]; } else { include_once PATH_MODULES . 'product/product.inc.php'; $productObj = new product(); # get pricing for this product: $prod_price = $productObj->price_prod($product->fields, $result->fields["recurr_schedule"], $this->account); $setup_price = $prod_price["setup"] * $result->fields["quantity"]; $base_price = $prod_price["base"] * $result->fields["quantity"]; # get pricing for any attributes: $attr_price = $productObj->price_attr($product->fields, $result->fields["product_attr"], $result->fields["recurr_schedule"], $this->account); $setup_price += $attr_price["setup"] * $result->fields["quantity"]; $base_price += $attr_price["base"] * $result->fields["quantity"]; # get the qty $qty = $result->fields["quantity"]; } } # set the smarty fields: global $smarty; $smarty->assign('qty', $qty); $smarty->assign('base', $base_price); $smarty->assign('setup', $setup_price); $smarty->assign('js', true); return; }
/** fleetdayHandler::deleteSlider($id) * Delete a slider * @param INT $slider which slider do we delete? * @return BOOL TRUE on success. FALSE otherwise. */ public function deleteSlider($id) { //: Tests if (is_int($id) === FALSE) { return FALSE; } //: End //: Confirm record exists $sql = (string) 'SELECT * FROM `sliders` WHERE id=' . $id; $data = (array) sqlQuery($sql); if (array_key_exists(0, $data) === FALSE) { return FALSE; } if (array_key_exists('id', $data[0]) === FALSE) { return FALSE; } syslog(LOG_INFO, 'slider deleted: ' . serialize($data[0])); //: End //: Delete it sqlDelete(array('table' => 'sliders', 'where' => 'id=' . $data[0]['id'])); //: End return TRUE; }
function updatePageRights() { $conf = $_POST["conf"]; sqlDelete(array("table" => "rights_pages", "where" => "pagecode LIKE '" . $conf["pagecode"] . "'")); foreach ($conf["groups"] as $grpkey => $grpval) { if (!$grpval["access"]) { $grpval["access"] = 0; } commitPageRights($conf["pagecode"], $grpval); } goHere("index.php?mode=maxine/index&action=pagerights&code=" . $conf["pagecode"]); }
/** * Create the Invoice Record and send user to checkout */ function checkoutnow($VAR) { global $C_translate, $C_list, $smarty; $db =& DB(); // Validate user is logged in: if (!SESS_LOGGED) { echo '<script language="JavaScript">alert("You must be logged in to complete this purchase! Please refresh this page in your browser to login now...");</script>'; return false; } // check for admin if (!$this->admin_checkout && !empty($VAR['account_id'])) { global $C_auth; if (!empty($VAR['account_id']) && $C_auth->auth_method_by_name('checkout', 'admin_checkoutnow')) { $this->account_id = $VAR['account_id']; $this->admin_checkout = true; } else { $this->account_id = SESS_ACCOUNT; } } if (empty($this->session_id)) { $this->session_id = SESS; } if (empty($this->account_id)) { $this->account_id = SESS_ACCOUNT; } include_once PATH_MODULES . '/cart/cart.inc.php'; $cartObj = new cart(); $cartObj->account_id = $this->account_id; $cartObj->session_id = $this->session_id; $result = $cartObj->get_contents($db); if ($result->RecordCount() == 0) { return false; } // load invoice object include_once PATH_MODULES . 'invoice/invoice.inc.php'; $invoice = new invoice(); $invoice->account_id = $this->account_id; $invoice->initNew(0); // Get the account details: $account = $db->Execute(sqlSelect($db, "account", "*", "id=::{$this->account_id}::")); $invoice->country_id = $account->fields['country_id']; $invoice->state = $account->fields['state']; // load tax object for tax calculation include_once PATH_MODULES . 'tax/tax.inc.php'; $taxObj = new tax(); // load discount object for discount calculation include_once PATH_MODULES . 'discount/discount.inc.php'; $discountObj = new discount(); $discountObj->available_discounts($invoice->account_id); // put cart contents into invoice format $cartObj->put_contents_invoice($db, $result, $invoice, $smart, $taxObj, $discountObj); // Validate and init a checkout plugin $checkout = false; if ($this->admin_checkout_option) { // admin checkout option specified include_once PATH_MODULES . 'checkout/checkout_admin.inc.php'; $PLG = new checkout_admin(); $checkout = true; $invoice->checkout_plugin_id = false; } else { // get available checkout options and check against the one provided $invoice->checkout_plugin_id = $VAR['option']; foreach ($invoice->invoice_item as $item) { if (!empty($item['product_id'])) { $product_arr[] = $item['product_id']; } } $checkout_options = $this->get_checkout_options($this->account_id, $invoice->total_amt, @$product_arr, $invoice->country_id, $invoice->any_new, $invoice->any_trial, $invoice->any_recurring); if ($checkout_options) { foreach ($checkout_options as $a) { if ($a['fields']['id'] == $invoice->checkout_plugin_id) { // load the selected checkout plugin and run pre-validation $checkout_plugin = $a['fields']['checkout_plugin']; $plugin_file = PATH_PLUGINS . 'checkout/' . $checkout_plugin . '.php'; include_once $plugin_file; eval('$PLG = new plg_chout_' . $checkout_plugin . '("' . $invoice->checkout_plugin_id . '");'); $plugin_validate = $PLG->validate($VAR, $this); if ($plugin_validate != true) { echo $plugin_validate; return false; } $checkout = true; break; } } } } if (!$checkout) { echo '<script language=Javascript> alert("Unable to checkout with the selected method, please select another."); </script> '; return false; } // validate credit card on file details global $VAR; if (!empty($VAR['account_billing_id']) && @$VAR['new_card'] == 2) { $invoice->account_billing_id = $VAR['account_billing_id']; /* validate credit card on file details */ if (!$PLG->setBillingFromDB($this->account_id, $invoice->account_billing_id, $invoice->checkout_plugin_id)) { global $C_debug; $C_debug->alert("Sorry, we cannot use that billing record for this purchase."); return false; } } else { /* use passed in vars */ $PLG->setBillingFromParams($VAR); } // validate recurring processing options if ($PLG->recurr_only) { if ($invoice->recur_amt <= 0) { echo '<script language=Javascript> alert("Cannot process non-recurring charges with this payment option, please select another payment option."); </script> '; return false; } if (is_array($invoice->recur_arr) && count($invoice->recur_arr) > 1) { $recurring = true; // validate recur day and recurring schedule are the same for both products foreach ($invoice->recur_arr as $a) { foreach ($invoice->recur_arr as $b) { foreach ($b as $key => $val) { if ($key != 'price' && $key != 'recurr_week' && $a[$key] != $val) { $recurring = false; break; } } } } if (!$recurring) { echo '<script language=Javascript> alert("This payment option cannot be used when ordering both prorated and non-prorated subscriptions, or when ordering two or more subscriptions with different billing schedules selected. Please make sure all your subscriptions have the same billing schedule selected, try another payment option, or order one subscription at a time. We apologize for any inconvenience."); </script> '; return false; } } } # Affiliate if (empty($this->affiliate_id)) { if (!empty($account->fields['affiliate_id'])) { $invoice->affiliate_id = $account->fields['affiliate_id']; } else { $invoice->affiliate_id = SESS_AFFILIATE; } } # Campaign if (empty($this->campaign_id)) { if (!empty($account->fields['campaign_id'])) { $invoice->campaign_id = $account->fields['campaign_id']; } else { $invoice->campaign_id = SESS_CAMPAIGN; } } $invoice->record_id = sqlGenID($db, "invoice"); $invoice->actual_billed_currency_id = SESS_CURRENCY; $invoice->billed_currency_id = DEFAULT_CURRENCY; $invoice->checkout_type = $PLG->type; // initial invoice status if ($invoice->total_amt == 0 || $PLG->type == 'gateway') { $invoice->billing_status = 1; $invoice->actual_billed_amt = $C_list->format_currency_decimal($invoice->total_amt, SESS_CURRENCY); $invoice->billed_amt = $invoice->total_amt; } // Currency conversion: if (SESS_CURRENCY != DEFAULT_CURRENCY) { $bill_amt = $C_list->format_currency_decimal($invoice->total_amt, SESS_CURRENCY); $recur_amt = $C_list->format_currency_decimal($invoice->recur_amt, SESS_CURRENCY); } else { $bill_amt = round($invoice->total_amt, 2); $recur_amt = round($invoice->recur_amt, 2); } // Get currency ISO (three_digit) for checkout plugin $currrs = $db->Execute(sqlSelect($db, "currency", "three_digit", "id=" . SESS_CURRENCY)); if ($currrs && $currrs->RecordCount()) { $currency_iso = $currrs->fields['three_digit']; } // Run the plugin bill_checkout() method: $currency_iso = $C_list->currency_iso(SESS_CURRENCY); $invoice->checkout_plugin_data = $PLG->bill_checkout($bill_amt, $invoice->record_id, $currency_iso, $account->fields, $recur_amt, $invoice->recur_arr); if ($invoice->checkout_plugin_data === false || $invoice->checkout_plugin_data == '') { if (!empty($PLG->redirect)) { echo $PLG->redirect; } return false; } elseif ($PLG->type == "gateway" || empty($PLG->redirect)) { $VAR['id'] = $invoice->record_id; if (!$this->admin_checkout) { $VAR['_page'] = "invoice:thankyou"; } $invoice->checkout_plugin_data = false; } elseif (!$this->admin_checkout) { echo "<html><head></head><body><center>\n\t\t\t\tPlease wait while we redirect you to the secure payment site....\n\t\t\t\t{$PLG->redirect}</center></body></html>"; } // Call the Plugin method for storing the checkout data: $invoice->account_billing_id = $PLG->store_billing($VAR, $invoice->account_id); // clear user discounts $fields = array('discounts' => ""); $db->Execute(sqlUpdate($db, "session", $fields, "id = ::" . SESS . "::")); // admin options $email = true; if ($this->admin_checkout) { if (empty($VAR['send_email']) || $VAR['send_email'] == 'false') { $email = false; } else { $email = true; } if (!empty($VAR['due_date'])) { $invoice->due_date = $this->getInputDate($VAR['due_date']); } if (!empty($VAR['grace_period'])) { $invoice->grace_period = $VAR['grace_period']; } if (!empty($VAR['notice_max'])) { $invoice->notice_max = $VAR['notice_max']; } } if ($invoice->commitNew($taxObj, $discountObj, $email)) { // delete all cart items $db->Execute(sqlDelete($db, "cart", "(session_id=::" . SESS . ":: OR account_id={$invoice->account_id})")); // admin redirect if ($this->admin_checkout) { $url = URL . 'admin.php?_page=invoice:view&id=' . $invoice->record_id; echo '<script language="javascript"> parent.location.href=\'' . $url . '\';</script>'; } } return false; }
function p_delete() { $db =& DB(); # determine the prepaid type: switch ($this->product_attr['type']) { case 'ani': $sql = sqlDelete($db, "voip_prepaid", "pin=::{$this->prod_attr_cart['ani_new']}::"); $db->Execute($sql); break; case 'did': include_once PATH_PLUGINS . 'product/VOIP.php'; $voip = new plgn_prov_VOIP(); $voip->p_one($this->service_id); break; } $rs = $db->Execute($sql = sqlSelect($db, "voip_did", "id,did", "service_id = {$this->service_id}")); $did_id = $rs->fields['id']; $db->Execute($sql = sqlDelete($db, "voip_prepaid", "voip_did_id = {$did_id}")); return true; }