当前位置: 首页>>代码示例>>PHP>>正文


PHP ps_DB::getEscaped方法代码示例

本文整理汇总了PHP中ps_DB::getEscaped方法的典型用法代码示例。如果您正苦于以下问题:PHP ps_DB::getEscaped方法的具体用法?PHP ps_DB::getEscaped怎么用?PHP ps_DB::getEscaped使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在ps_DB的用法示例。


在下文中一共展示了ps_DB::getEscaped方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: COUNT

 /**
  * Validates the Input Parameters onBeforeModuleUpdate
  *
  * @param array $d
  * @return boolean
  */
 function validate_update(&$d)
 {
     global $vmLogger, $VM_LANG;
     if (empty($d['module_name'])) {
         $vmLogger->err($VM_LANG->_('VM_MODULE_ERR_NAME'));
         return False;
     } else {
         $db = new ps_DB();
         $q = "SELECT COUNT(*) AS rowcnt FROM #__{vm}_module WHERE module_name='" . $db->getEscaped($d['module_name']) . "' AND module_id <> " . (int) $d['module_id'];
         $db->query($q);
         $db->next_record();
         if ($db->f("rowcnt") > 0) {
             $vmLogger->err($VM_LANG->_('VM_MODULE_ERR_EXISTS'));
             return False;
         }
     }
     if (empty($d['module_perms'])) {
         $vmLogger->err($VM_LANG->_('VM_MODULE_ERR_PERMS'));
         return false;
     }
     if (empty($d['list_order'])) {
         $d['list_order'] = "99";
     }
     return True;
 }
开发者ID:BackupTheBerlios,项目名称:kmit-svn,代码行数:31,代码来源:ps_module.php

示例2: COUNT

 /**
  * Validates the Input Parameters onBeforeShopperGroupAdd
  *
  * @param array $d
  * @return boolean
  */
 function validate_add(&$d)
 {
     global $VM_LANG;
     $db = new ps_DB();
     $ps_vendor_id = $_SESSION["ps_vendor_id"];
     if (empty($d["shopper_group_name"])) {
         $GLOBALS['vmLogger']->err($VM_LANG->_('SHOPPER_GROUP_MISSING_NAME'));
         return False;
     } else {
         $q = "SELECT COUNT(*) as num_rows FROM #__{vm}_shopper_group";
         $q .= " WHERE shopper_group_name='" . $db->getEscaped(vmGet($d, 'shopper_group_name')) . "'";
         $q .= " AND vendor_id='" . $ps_vendor_id . "'";
         $db->query($q);
         $db->next_record();
         if ($db->f("num_rows") > 0) {
             $GLOBALS['vmLogger']->err($VM_LANG->_('SHOPPER_GROUP_ALREADY_EXISTS'));
             return False;
         }
     }
     if (empty($d["shopper_group_discount"])) {
         $d["shopper_group_discount"] = 0;
     }
     $d["show_price_including_tax"] = isset($d["show_price_including_tax"]) ? $d["show_price_including_tax"] : 0;
     return True;
 }
开发者ID:BackupTheBerlios,项目名称:kmit-svn,代码行数:31,代码来源:ps_shopper_group.php

示例3:

    function validate_update(&$d)
    {
        global $VM_LANG;
        if (!$this->validate($d)) {
            return false;
        }
        $db = $this->get(intval($d["order_status_id"]));
        if ($db->f('order_status_code')) {
            $order_status_code = $db->f('order_status_code');
            // Check if the Order Status Code of protected Order Statuses is to be changed
            if (in_array($order_status_code, $this->_protected_status_codes) && $order_status_code != $d["order_status_code"]) {
                $vmLogger->err($VM_LANG->_('VM_ORDERSTATUS_CHANGE_ERR_CORE'));
                return False;
            }
            if ($order_status_code != $d["order_status_code"]) {
                // If the order Status Code has changed, we need to update all orders with this order status to use the new Status Code
                $dbo = new ps_DB();
                $dbo->query('UPDATE #__{vm}_orders SET 
										order_status=\'' . $dbo->getEscaped($d["order_status_code"]) . '\'
										WHERE order_status=\'' . $order_status_code . '\'');
            }
            return true;
        } else {
            return false;
        }
    }
开发者ID:rafarubert,项目名称:megafiltros,代码行数:26,代码来源:ps_order_status.php

示例4: count

 /**
  * Validates the input parameters onCountryAdd
  *
  * @param array $d
  * @return boolean
  */
 function validate_add($d)
 {
     global $vmLogger;
     $db = new ps_DB();
     if (!$d["country_name"]) {
         $vmLogger->err("You must enter a name for the country.");
         return False;
     }
     if (!$d["country_2_code"]) {
         $vmLogger->err("You must enter a 2 symbol code for the country.");
         return False;
     }
     if (!$d["country_3_code"]) {
         $vmLogger->err('You must enter a 3 symbol code for the country.');
         return False;
     }
     if ($d["country_name"]) {
         $q = "SELECT count(*) as rowcnt from #__{vm}_country where";
         $q .= " country_name='" . $db->getEscaped($d["country_name"]) . "'";
         $db->query($q);
         $db->next_record();
         if ($db->f("rowcnt") > 0) {
             $vmLogger->err("The given country name already exists.");
             return False;
         }
     }
     return True;
 }
开发者ID:BackupTheBerlios,项目名称:kmit-svn,代码行数:34,代码来源:ps_country.php

示例5: validateOnSave

 function validateOnSave(&$d)
 {
     global $vmLogger, $VM_LANG;
     /*
     		if( !$this->validate($d)) {
     			return false;
     		}*/
     switch ($d['type']) {
         case 'date':
             $d['cType'] = 'DATE';
             break;
         case 'editorta':
         case 'textarea':
         case 'multiselect':
         case 'multicheckbox':
             $d['cType'] = 'MEDIUMTEXT';
             break;
         case 'letterman_subscription':
         case 'yanc_subscription':
         case 'anjel_subscription':
         case 'ccnewsletter_subscription':
             // Set params =
             $d['params'] = 'newsletter=' . substr($d['type'], 0, strpos($d['type'], '_')) . "\n";
             $d['type'] = 'checkbox';
         case 'checkbox':
             $d['cType'] = 'TINYINT';
             break;
         case 'euvatid':
             $d['params'] = 'shopper_group_id=' . $d['shopper_group_id'] . "\n";
             $d['cType'] = 'VARCHAR(255)';
             break;
         case 'age_verification':
             $d['params'] = 'minimum_age=' . (int) $d['minimum_age'] . "\n";
         default:
             $d['cType'] = 'VARCHAR(255)';
             break;
     }
     $db = new ps_DB();
     $sql = "SELECT COUNT(*) as num_rows FROM `#__{vm}_userfield` WHERE name='" . $db->getEscaped($d['name']) . "'";
     if (!empty($d['fieldid'])) {
         $sql .= ' AND fieldid != ' . intval($d['fieldid']);
     }
     $db->query($sql);
     $db->next_record();
     if ($db->f('num_rows')) {
         $vmLogger->err(sprintf($VM_LANG->_('VM_USERFIELD_ERR_ALREADY'), $d['name']));
         return false;
     }
     return true;
 }
开发者ID:albertobraschi,项目名称:Hab,代码行数:50,代码来源:ps_userfield.php

示例6: count

 /**
  * Validates the input parameters onBeforeCreditCardAdd
  *
  * @param array $d
  * @return boolean
  */
 function validate_add($d)
 {
     global $vmLogger, $VM_LANG;
     $db = new ps_DB();
     if (!$d["creditcard_name"]) {
         $vmLogger->err($VM_LANG->_('VM_CREDITCARD_ERR_NAME'));
         return False;
     }
     if (!$d["creditcard_code"]) {
         $vmLogger->err($VM_LANG->_('VM_CREDITCARD_ERR_CODE'));
         return False;
     }
     $q = "SELECT count(*) as rowcnt FROM `#__{vm}_creditcard` WHERE";
     $q .= " creditcard_name='" . $db->getEscaped($d["creditcard_name"]) . "' OR ";
     $q .= " creditcard_code='" . $db->getEscaped($d["creditcard_code"]) . "'";
     $db->query($q);
     $db->next_record();
     if ($db->f("rowcnt") > 0) {
         $vmLogger->err($VM_LANG->_('VM_CREDITCARD_EXISTS'));
         return False;
     }
     return True;
 }
开发者ID:noikiy,项目名称:owaspbwa,代码行数:29,代码来源:ps_creditcard.php

示例7: get

 /**
  * Retrieves a record with the specified ID from the table associated with this entitiy type
  * In case of success, returns a ps_DB object with a prepared recordset
  * In case of failure returns false
  * @param mixed $id
  * @return mixed
  */
 function get($id)
 {
     $key = $this->getKey();
     $table = $this->getTable();
     $db = new ps_DB();
     if (!empty($id)) {
         $query = 'SELECT * FROM `' . $table . '` WHERE `' . $key . '`=';
         if (is_numeric($id)) {
             $query .= (int) $id;
         } else {
             $query .= '\'' . $db->getEscaped($id) . '\'';
         }
         $db->query($query);
         $db->next_record();
     }
     return $db;
 }
开发者ID:albertobraschi,项目名称:Hab,代码行数:24,代码来源:vmAbstractObject.class.php

示例8: count

 /**
  * Validate the Input Parameters onBeforeManufacturerCategoryAdd
  *
  * @param array $d
  * @return boolean
  */
 function validate_add($d)
 {
     global $VM_LANG;
     $db = new ps_DB();
     if (!$d["mf_category_name"]) {
         $GLOBALS['vmLogger']->err($VM_LANG->_('VM_MANUF_CAT_ERR_NAME'));
         return False;
     } else {
         $q = "SELECT count(*) as rowcnt from #__{vm}_manufacturer_category where";
         $q .= " mf_category_name='" . $db->getEscaped($d["mf_category_name"]) . "'";
         $db->query($q);
         $db->next_record();
         if ($db->f("rowcnt") > 0) {
             $GLOBALS['vmLogger']->err($VM_LANG->_('VM_MANUF_CAT_ERR_EXISTS'));
             return False;
         }
     }
     return True;
 }
开发者ID:BackupTheBerlios,项目名称:kmit-svn,代码行数:25,代码来源:ps_manufacturer_category.php

示例9: COUNT

 /**
  * Validates the Input Parameters onBeforeShopperGroupAdd
  *
  * @param array $d
  * @return boolean
  */
 function validate_add(&$d)
 {
     $db = new ps_DB();
     $ps_vendor_id = $_SESSION["ps_vendor_id"];
     if (empty($d["shopper_group_name"])) {
         $GLOBALS['vmLogger']->err('You must enter a shopper group name.');
         return False;
     } else {
         $q = "SELECT COUNT(*) as num_rows FROM #__{vm}_shopper_group";
         $q .= " WHERE shopper_group_name='" . $db->getEscaped(vmGet($d, 'shopper_group_name')) . "'";
         $q .= " AND vendor_id='" . $ps_vendor_id . "'";
         $db->query($q);
         $db->next_record();
         if ($db->f("num_rows") > 0) {
             $GLOBALS['vmLogger']->err('Shopper group already exists for this vendor.');
             return False;
         }
     }
     if (empty($d["shopper_group_discount"])) {
         $d["shopper_group_discount"] = 0;
     }
     $d["show_price_including_tax"] = isset($d["show_price_including_tax"]) ? $d["show_price_including_tax"] : 0;
     return True;
 }
开发者ID:albertobraschi,项目名称:Hab,代码行数:30,代码来源:ps_shopper_group.php

示例10: while

 /**
  * Gets the username from joomla if there is one associated to the paypal express payerID
  * @param string $payerID
  * @return string, False on failure
  */
 function ppex_getUsername($payerID)
 {
     global $vmLogger;
     if (empty($payerID)) {
         $vmLogger->debug("Error: No PayerID Given");
         return false;
     }
     $db = new ps_DB();
     $dbb = new ps_DB();
     $q = "SELECT * FROM #__{vm}_user_info WHERE extra_field_3 = '" . $db->getEscaped($payerID) . "' ORDER by mdate DESC";
     $db->query($q);
     if ($db->num_rows() > 0) {
         while ($db->next_record()) {
             $uid = $db->f('user_id');
             //Now lets try and see if the uid has a real username with joomla
             $q2 = "SELECT * FROM #__users WHERE `id` = '" . $db->getEscaped($uid) . "'";
             $dbb->query($q2);
             if ($dbb->num_rows() > 0) {
                 $dbb->next_record();
                 $username = $dbb->f('username');
                 if (!empty($username)) {
                     return $username;
                 }
             }
         }
     }
     return false;
 }
开发者ID:noikiy,项目名称:owaspbwa,代码行数:33,代码来源:ps_paypal_api.php

示例11: update

 /**
  * Updates a Shipping Adress for the specified user info ID
  *
  * @param array $d
  * @return boolean
  */
 function update(&$d)
 {
     global $perm, $VM_LANG;
     require_once CLASSPATH . 'ps_userfield.php';
     $db = new ps_DB();
     $timestamp = time();
     if (!$this->validate_update($d)) {
         return false;
     }
     // Get all fields which where shown to the user
     $shippingFields = ps_userfield::getUserFields('shipping', false, '', true);
     $skip_fields = ps_userfield::getSkipFields();
     foreach ($shippingFields as $userField) {
         if (!in_array($userField->name, $skip_fields)) {
             $fields[$userField->name] = ps_userfield::prepareFieldDataSave($userField->type, $userField->name, vmGet($d, $userField->name, strtoupper($userField->name)));
         }
     }
     // These are pre-defined fields.
     $fields['user_id'] = !$perm->check("admin,storeadmin") ? $_SESSION['auth']['user_id'] : (int) $d["user_id"];
     $fields['address_type'] = 'ST';
     $fields['mdate'] = time();
     $db->buildQuery('UPDATE', '#__{vm}_user_info', $fields, "WHERE user_info_id='" . $db->getEscaped($d["user_info_id"]) . "'" . (!$perm->check("admin,storeadmin") ? " AND user_id=" . $_SESSION['auth']['user_id'] : ''));
     if ($db->query() === false) {
         $GLOBALS['vmLogger']->err($VM_LANG->_('VM_USERADDRESS_UPDATED_FAILED'));
         return false;
     }
     $GLOBALS['vmLogger']->info($VM_LANG->_('VM_USERADDRESS_UPDATED'));
     vmRequest::setVar('ship_to_info_id', $d['user_info_id']);
     return true;
 }
开发者ID:noikiy,项目名称:owaspbwa,代码行数:36,代码来源:ps_user_address.php

示例12: time

 /**
  * Handles a download Request
  *
  * @param array $d
  * @return boolean
  */
 function download_request(&$d)
 {
     global $download_id, $VM_LANG, $vmLogger;
     $db = new ps_DB();
     $download_id = $db->getEscaped(vmGet($d, "download_id"));
     $q = "SELECT * FROM #__{vm}_product_download WHERE";
     $q .= " download_id = '{$download_id}'";
     $db->query($q);
     $db->next_record();
     $download_id = $db->f("download_id");
     $file_name = $db->f("file_name");
     if (strncmp($file_name, 'http', 4) !== 0) {
         $datei = DOWNLOADROOT . $file_name;
     } else {
         $datei = $file_name;
     }
     $download_max = $db->f("download_max");
     $end_date = $db->f("end_date");
     $zeit = time();
     if (!$download_id) {
         $vmLogger->err($VM_LANG->_('PHPSHOP_DOWNLOADS_ERR_INV', false));
         return false;
         //vmRedirect("index.php?option=com_virtuemart&page=shop.downloads", $d["error"]);
     } elseif ($download_max == "0") {
         $q = "DELETE FROM #__{vm}_product_download";
         $q .= " WHERE download_id = '" . $download_id . "'";
         $db->query($q);
         $db->next_record();
         $vmLogger->err($VM_LANG->_('PHPSHOP_DOWNLOADS_ERR_MAX', false));
         return false;
         //vmRedirect("index.php?option=com_virtuemart&page=shop.downloads", $d["error"]);
     } elseif ($end_date != "0" && $zeit > $end_date) {
         $q = "DELETE FROM #__{vm}_product_download";
         $q .= " WHERE download_id = '" . $download_id . "'";
         $db->query($q);
         $db->next_record();
         $vmLogger->err($VM_LANG->_('PHPSHOP_DOWNLOADS_ERR_EXP', false));
         return false;
         //vmRedirect("index.php?option=com_virtuemart&page=shop.downloads", $d["error"]);
     }
     require_once CLASSPATH . 'connectionTools.class.php';
     $download_count = true;
     if (@file_exists($datei)) {
         // Check if this is a request for a special range of the file (=Resume Download)
         $range_request = vmConnector::http_rangeRequest(filesize($datei), false);
         if ($range_request[0] == 0) {
             // this is not a request to resume a download,
             $download_count = true;
         } else {
             $download_count = false;
         }
     } else {
         $download_count = false;
     }
     // Parameter to check if the file should be removed after download, which is only true,
     // if we have a remote file, which was transferred to this server into a temporary file
     $unlink = false;
     if (strncmp($datei, 'http', 4) === 0) {
         require_once CLASSPATH . 'ps_product_files.php';
         $datei_local = ps_product_files::getRemoteFile($datei);
         if ($datei_local !== false) {
             $datei = $datei_local;
             $unlink = true;
         } else {
             $vmLogger->err($VM_LANG->_('VM_DOWNLOAD_FILE_NOTFOUND', false));
             return false;
         }
     } else {
         // Check, if file path is correct
         // and file is
         if (!@file_exists($datei)) {
             $vmLogger->err($VM_LANG->_('VM_DOWNLOAD_FILE_NOTFOUND', false));
             return false;
             //vmRedirect("index.php?option=com_virtuemart&page=shop.downloads", $d["error"]);
         }
         if (!@is_readable($datei)) {
             $vmLogger->err($VM_LANG->_('VM_DOWNLOAD_FILE_NOTREADABLE', false));
             return false;
             //vmRedirect("index.php?option=com_virtuemart&page=shop.downloads", $d["error"]);
         }
     }
     if ($download_count) {
         // decrement the download_max to limit the number of downloads
         $q = "UPDATE `#__{vm}_product_download` SET";
         $q .= " `download_max`=`download_max` - 1";
         $q .= " WHERE download_id = '" . $download_id . "'";
         $db->query($q);
         $db->next_record();
     }
     if ($end_date == "0") {
         // Set the Download Expiry Date, so the download can expire after DOWNLOAD_EXPIRE seconds
         $end_date = time('u') + DOWNLOAD_EXPIRE;
         $q = "UPDATE #__{vm}_product_download SET";
         $q .= " end_date={$end_date}";
//.........这里部分代码省略.........
开发者ID:noikiy,项目名称:owaspbwa,代码行数:101,代码来源:ps_order.php

示例13: AND

 function list_rates(&$d)
 {
     global $VM_LANG, $CURRENCY_DISPLAY, $mosConfig_absolute_path;
     $db = new ps_DB();
     $dbv = new ps_DB();
     $dbc = new ps_DB();
     /** Read current Configuration ***/
     require_once CLASSPATH . "shipping/" . __CLASS__ . ".cfg.php";
     $q = "SELECT * FROM `#__{vm}_user_info`, `#__{vm}_country` WHERE user_info_id='" . $db->getEscaped($d["ship_to_info_id"]) . "' AND ( country=country_2_code OR country=country_3_code)";
     $db->query($q);
     $db->next_record();
     $q = "SELECT * FROM #__{vm}_vendor WHERE vendor_id='" . $_SESSION['ps_vendor_id'] . "'";
     $dbv->query($q);
     $dbv->next_record();
     $order_weight = $d['weight'];
     if ($order_weight > 0) {
         //USPS Username
         $usps_username = USPS_USERNAME;
         //USPS Password
         $usps_password = USPS_PASSWORD;
         //USPS Server
         $usps_server = USPS_SERVER;
         //USPS Path
         $usps_path = USPS_PATH;
         //USPS package size
         $usps_packagesize = USPS_PACKAGESIZE;
         //USPS Package ID
         $usps_packageid = 0;
         //USPS International Per Pound Rate
         $usps_intllbrate = USPS_INTLLBRATE;
         //USPS International handling fee
         $usps_intlhandlingfee = USPS_INTLHANDLINGFEE;
         //Pad the shipping weight to allow weight for shipping materials
         $usps_padding = USPS_PADDING;
         $usps_padding = $usps_padding * 0.01;
         $order_weight = $order_weight * $usps_padding + $order_weight;
         //USPS Machinable for Parcel Post
         $usps_machinable = USPS_MACHINABLE;
         if ($usps_machinable == '1') {
             $usps_machinable = 'TRUE';
         } else {
             $usps_machinable = 'FALSE';
         }
         //USPS Shipping Options to display
         $usps_ship[0] = USPS_SHIP0;
         $usps_ship[1] = USPS_SHIP1;
         $usps_ship[2] = USPS_SHIP2;
         $usps_ship[3] = USPS_SHIP3;
         $usps_ship[4] = USPS_SHIP4;
         $usps_ship[5] = USPS_SHIP5;
         $usps_ship[6] = USPS_SHIP6;
         $usps_ship[7] = USPS_SHIP7;
         $usps_ship[8] = USPS_SHIP8;
         $usps_ship[9] = USPS_SHIP9;
         $usps_ship[10] = USPS_SHIP10;
         foreach ($usps_ship as $key => $value) {
             if ($value == '1') {
                 $usps_ship[$key] = 'TRUE';
             } else {
                 $usps_ship[$key] = 'FALSE';
             }
         }
         $usps_intl[0] = USPS_INTL0;
         $usps_intl[1] = USPS_INTL1;
         $usps_intl[2] = USPS_INTL2;
         $usps_intl[3] = USPS_INTL3;
         $usps_intl[4] = USPS_INTL4;
         $usps_intl[5] = USPS_INTL5;
         $usps_intl[6] = USPS_INTL6;
         $usps_intl[7] = USPS_INTL7;
         $usps_intl[8] = USPS_INTL8;
         // $usps_intl[9] = USPS_INTL9;
         foreach ($usps_intl as $key => $value) {
             if ($value == '1') {
                 $usps_intl[$key] = 'TRUE';
             } else {
                 $usps_intl[$key] = 'FALSE';
             }
         }
         //Title for your request
         $request_title = "Shipping Estimate";
         //The zip that you are shipping from
         $source_zip = substr($dbv->f("vendor_zip"), 0, 5);
         $shpService = 'All';
         //"Priority";
         //The zip that you are shipping to
         $dest_country = $db->f("country_2_code");
         if ($dest_country == "GB") {
             $q = "SELECT state_name FROM #__{vm}_state WHERE state_2_code='" . $db->f("state") . "'";
             $dbc->query($q);
             $dbc->next_record();
             $dest_country_name = $dbc->f("state_name");
         } else {
             $dest_country_name = $db->f("country_name");
         }
         $dest_state = $db->f("state");
         $dest_zip = substr($db->f("zip"), 0, 5);
         //$weight_measure
         if ($order_weight < 1) {
             $shipping_pounds_intl = 0;
//.........这里部分代码省略.........
开发者ID:noikiy,项目名称:owaspbwa,代码行数:101,代码来源:usps.php

示例14: trim

 function process_coupon_code($d)
 {
     global $VM_LANG, $vmLogger;
     /* init the database */
     $coupon_db = new ps_DB();
     /* we need some functions from the checkout module */
     require_once CLASSPATH . "ps_checkout.php";
     $checkout = new ps_checkout();
     if (empty($d['total'])) {
         $totals = $checkout->calc_order_totals($d);
         $d['total'] = $totals['order_subtotal'] + $totals['order_tax'] + $totals['order_shipping'] + $totals['order_shipping_tax'] - $totals['payment_discount'];
     }
     $d['coupon_code'] = trim(vmGet($_REQUEST, 'coupon_code'));
     $coupon_id = vmGet($_SESSION, 'coupon_id', null);
     $q = 'SELECT coupon_id, coupon_code, percent_or_total, coupon_value, coupon_type FROM #__{vm}_coupons WHERE ';
     if ($coupon_id) {
         /* the query to select the coupon coupon_code */
         $q .= 'coupon_id = ' . intval($coupon_id);
     } else {
         /* the query to select the coupon coupon_code */
         $q .= 'coupon_code = \'' . $coupon_db->getEscaped($d['coupon_code']) . '\'';
     }
     /* make the query */
     $coupon_db->query($q);
     /* see if we have any fields returned */
     if ($coupon_db->num_rows() > 0) {
         /* we have a record */
         /* see if we are calculating percent or dollar discount */
         if ($coupon_db->f("percent_or_total") == "percent") {
             /* percent */
             //$subtotal = $checkout->calc_order_subtotal( $d );
             /* take the subtotal for calculation of the discount */
             //$_SESSION['coupon_discount'] = round( ($subtotal * $coupon_db->f("coupon_value") / 100), 2);
             $coupon_value = round($d["total"] * $coupon_db->f("coupon_value") / 100, 2);
             if ($d["total"] < $coupon_value) {
                 $coupon_value = (double) $d['total'] + (double) $d['order_tax'];
                 $vmLogger->info(str_replace('{value}', $GLOBALS['CURRENCY_DISPLAY']->getFullValue($coupon_value), $VM_LANG->_('VM_COUPON_GREATER_TOTAL_SETTO')));
             }
             $_SESSION['coupon_discount'] = $coupon_value;
         } else {
             $coupon_value = $coupon_db->f("coupon_value");
             /* Total Amount */
             if ($d["total"] < $coupon_value) {
                 $coupon_value = (double) $d['total'] + (double) $d['order_tax'];
                 $vmLogger->info(str_replace('{value}', $GLOBALS['CURRENCY_DISPLAY']->getFullValue($coupon_value), $VM_LANG->_('VM_COUPON_GREATER_TOTAL_SETTO')));
             }
             $_SESSION['coupon_discount'] = $GLOBALS['CURRENCY']->convert($coupon_value);
         }
         /* mark this order as having used a coupon so people cant go and use coupons over and over */
         $_SESSION['coupon_redeemed'] = true;
         $_SESSION['coupon_id'] = $coupon_db->f("coupon_id");
         $_SESSION['coupon_code'] = $coupon_db->f("coupon_code");
         $_SESSION['coupon_type'] = $coupon_db->f("coupon_type");
     } else {
         /* no record, so coupon_code entered was not valid */
         $GLOBALS['coupon_error'] = $VM_LANG->_('PHPSHOP_COUPON_CODE_INVALID');
         return false;
     }
 }
开发者ID:BackupTheBerlios,项目名称:kmit-svn,代码行数:59,代码来源:ps_coupon.php

示例15: vmGet

 /**
  * Changes the parameter List Order
  * @author Zdenek Dvorak
  * @param unknown_type $d
  */
 function reorder_parameter(&$d)
 {
     $cb = vmGet($_POST, 'parameter_name', array(0));
     $product_type_id = vmGet($_POST, 'product_type_id', 0);
     $db = new ps_DB();
     switch ($d["task"]) {
         case "orderup":
             $q = "SELECT parameter_list_order FROM #__{vm}_product_type_parameter ";
             $q .= "WHERE product_type_id='" . $product_type_id . "' ";
             $q .= "AND parameter_name='" . $db->getEscaped($cb[0]) . "'";
             $db->query($q);
             $db->next_record();
             $currentpos = $db->f("parameter_list_order");
             // Get the (former) predecessor and update it
             $q = "SELECT parameter_list_order,parameter_name FROM #__{vm}_product_type_parameter WHERE ";
             $q .= "parameter_list_order<'" . $currentpos . "' ";
             $q .= "ORDER BY parameter_list_order DESC";
             $db->query($q);
             $db->next_record();
             $pred = $db->f("parameter_name");
             $pred_pos = $db->f("parameter_list_order");
             // Update the product_type and decrease the list_order
             $q = "UPDATE #__{vm}_product_type_parameter ";
             $q .= "SET parameter_list_order='" . $pred_pos . "' ";
             $q .= "WHERE product_type_id='" . $product_type_id . "' ";
             $q .= "AND parameter_name='" . $db->getEscaped($cb[0]) . "'";
             $db->query($q);
             $q = "UPDATE #__{vm}_product_type_parameter ";
             $q .= "SET parameter_list_order='" . intval($pred_pos + 1) . "' ";
             $q .= "WHERE product_type_id='" . $product_type_id . "' ";
             $q .= "AND parameter_name='" . $db->getEscaped($pred) . "'";
             $db->query($q);
             break;
         case "orderdown":
             $q = "SELECT parameter_list_order FROM #__{vm}_product_type_parameter ";
             $q .= "WHERE product_type_id='" . $product_type_id . "' ";
             $q .= "AND parameter_name='" . $db->getEscaped($cb[0]) . "'";
             $db->query($q);
             $db->next_record();
             $currentpos = $db->f("parameter_list_order");
             // Get the (former) successor and update it
             $q = "SELECT parameter_list_order,parameter_name FROM #__{vm}_product_type_parameter WHERE ";
             $q .= "parameter_list_order>'" . $currentpos . "' ";
             $q .= "ORDER BY parameter_list_order";
             $db->query($q);
             $db->next_record();
             $succ = $db->f("parameter_name");
             $succ_pos = $db->f("parameter_list_order");
             $q = "UPDATE #__{vm}_product_type_parameter ";
             $q .= "SET parameter_list_order='" . $succ_pos . "' ";
             $q .= "WHERE product_type_id='" . $product_type_id . "' ";
             $q .= "AND parameter_name='" . $db->getEscaped($cb[0]) . "'";
             $db->query($q);
             $q = "UPDATE #__{vm}_product_type_parameter ";
             $q .= "SET parameter_list_order='" . intval($succ_pos - 1) . "' ";
             $q .= "WHERE product_type_id='" . $product_type_id . "' ";
             $q .= "AND parameter_name='" . $db->getEscaped($succ) . "'";
             $db->query($q);
             break;
     }
 }
开发者ID:noikiy,项目名称:owaspbwa,代码行数:66,代码来源:ps_product_type_parameter.php


注:本文中的ps_DB::getEscaped方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。