function addRegistro($data) { $querys = new Querys(); // Data cadastro atual $data[$this->tabela_data_entrada] = date('Y-m-d H:i:s'); // Retorna todos os campos da tabela $result = $this->getCampos(); // Monta sql $sql = "INSERT INTO " . $this->tabela . " SET "; foreach ($result['nome'] as $key => $campo) { if (isset($data[$result['nome'][$key]]) && !empty($data[$result['nome'][$key]])) { if ($result['tipo'][$key] == 'int') { $sql .= $result['nome'][$key] . " = '" . (int) $data[$result['nome'][$key]] . "', "; } else { if ($result['tipo'][$key] == 'real') { $sql .= $result['nome'][$key] . " = " . floatval($data[$result['nome'][$key]]) . ", "; } else { $sql .= $result['nome'][$key] . " = '" . $querys->escape($data[$result['nome'][$key]]) . "', "; } } } } $sql = substr(trim($sql), 0, -1); $result = $querys->query($sql); return $result; }
/** * @see OptionType::getData() */ public function getData($optionData, $newValue) { $newValue = str_replace(' ', '', $newValue); $newValue = str_replace(WCF::getLanguage()->get('wcf.global.thousandsSeparator'), '', $newValue); $newValue = str_replace(WCF::getLanguage()->get('wcf.global.decimalPoint'), '.', $newValue); return floatval($newValue); }
/** * Returns the first found number from an string * Parsing depends on given locale (grouping and decimal) * * Examples for input: * ' 2345.4356,1234' = 23455456.1234 * '+23,3452.123' = 233452.123 * ' 12343 ' = 12343 * '-9456km' = -9456 * '0' = 0 * '2 054,10' = 2054.1 * '2'054.52' = 2054.52 * '2,46 GB' = 2.46 * * @param string|int $value * @return float */ public static function formatPriceToUS($value) { if (is_null($value)) { return null; } if (!is_string($value)) { return floatval($value); } //trim space and apos $value = str_replace('\'', '', $value); $value = str_replace(' ', '', $value); $separatorComa = strpos($value, ','); $separatorDot = strpos($value, '.'); if ($separatorComa !== false && $separatorDot !== false) { if ($separatorComa > $separatorDot) { $value = str_replace('.', '', $value); $value = str_replace(',', '.', $value); } else { $value = str_replace(',', '', $value); } } elseif ($separatorComa !== false) { $value = str_replace(',', '.', $value); } return floatval($value); }
public function upload() { /** import upload library **/ _wpl_import('assets.packages.ajax_uploader.UploadHandler'); $kind = wpl_request::getVar('kind', 0); $params = array(); $params['accept_ext'] = wpl_flex::get_field_options(301); $extentions = explode(',', $params['accept_ext']['ext_file']); $ext_str = ''; foreach ($extentions as $extention) { $ext_str .= $extention . '|'; } // remove last | $ext_str = substr($ext_str, 0, -1); $ext_str = rtrim($ext_str, ';'); $custom_op = array('upload_dir' => wpl_global::get_upload_base_path(), 'upload_url' => wpl_global::get_upload_base_url(), 'accept_file_types' => '/\\.(' . $ext_str . ')$/i', 'max_file_size' => $params['accept_ext']['file_size'] * 1000, 'min_file_size' => 1, 'max_number_of_files' => null); $upload_handler = new UploadHandler($custom_op); $response = json_decode($upload_handler->json_response); if (isset($response->files[0]->error)) { return; } $attachment_categories = wpl_items::get_item_categories('attachment', $kind); // get item category with first index $item_cat = reset($attachment_categories)->category_name; $index = floatval(wpl_items::get_maximum_index(wpl_request::getVar('pid'), wpl_request::getVar('type'), $kind, $item_cat)) + 1.0; $item = array('parent_id' => wpl_request::getVar('pid'), 'parent_kind' => $kind, 'item_type' => wpl_request::getVar('type'), 'item_cat' => $item_cat, 'item_name' => $response->files[0]->name, 'creation_date' => date("Y-m-d H:i:s"), 'index' => $index); wpl_items::save($item); }
public function indexOp() { //查询会员及其附属信息 $result = parent::pointshopMInfo(true); $member_info = $result['member_info']; unset($result); $model_member = Model('member'); //获得会员升级进度 $membergrade_arr = $model_member->getMemberGradeArr(true, $member_info['member_exppoints'], $member_info['level']); Tpl::output('membergrade_arr', $membergrade_arr); //处理经验值计算说明文字 $exppoints_rule = C("exppoints_rule") ? unserialize(C("exppoints_rule")) : array(); $ruleexplain_arr = array(); $exppoints_rule['exp_orderrate'] = floatval($exppoints_rule['exp_orderrate']); if ($exppoints_rule['exp_orderrate'] > 0) { $ruleexplain_arr['exp_order'] = "经验值以有效购物金额作为计算标准,有效购物金额{$exppoints_rule['exp_orderrate']}元=1经验值;"; $exp_ordermax = intval($exppoints_rule['exp_ordermax']); if ($exp_ordermax > 0) { $ruleexplain_arr['exp_order'] .= "单个订单最多获得{$exppoints_rule['exp_ordermax']}经验值;"; } } $exppoints_rule['exp_login'] = intval($exppoints_rule['exp_login']); if ($exppoints_rule['exp_login'] > 0) { $ruleexplain_arr['exp_login'] = "******"; } $exppoints_rule['exp_comments'] = intval($exppoints_rule['exp_comments']); if ($exppoints_rule['exp_comments'] > 0) { $ruleexplain_arr['exp_comments'] = "进行一次订单商品评价将获得{$exppoints_rule['exp_comments']}经验值;"; } Tpl::output('ruleexplain_arr', $ruleexplain_arr); //分类导航 $nav_link = array(0 => array('title' => L('homepage'), 'link' => SHOP_SITE_URL), 1 => array('title' => L('nc_pointprod'), 'link' => urlShop('pointshop', 'index')), 2 => array('title' => '我的成长进度')); Tpl::output('nav_link_list', $nav_link); Tpl::showpage('pointgrade'); }
function perform(&$page, $actionName) { // like in Action_Next $page->isFormBuilt() or $page->buildForm(); $page->handle('display'); $strings = $page->controller->exportValue('page4', 'strings'); $bar = $page->controller->createProgressBar(); do { $percent = $bar->getPercentComplete(); if ($bar->isStringPainted()) { if (substr($strings, -1) == ";") { $str = explode(";", $strings); } else { $str = explode(";", $strings . ";"); } for ($i = 0; $i < count($str) - 1; $i++) { list($p, $s) = explode(",", $str[$i]); if ($percent == floatval($p) / 100) { $bar->setString(trim($s)); } } } $bar->display(); if ($percent == 1) { break; // the progress bar has reached 100% } $bar->sleep(); $bar->incValue(); } while (1); }
/** * Formats a given decimal value to a local aware currency value * * * @link http://framework.zend.com/manual/de/zend.currency.options.html * @param float $value Value can have a coma as a decimal separator * @param array $config * @param string $position where the currency symbol should be displayed * @return float|string */ function smarty_modifier_currency($value, $config = null, $position = null) { if (!Enlight_Application::Instance()->Bootstrap()->hasResource('Currency')) { return $value; } if (!empty($config) && is_string($config)) { $config = strtoupper($config); if (defined('Zend_Currency::' . $config)) { $config = array('display' => constant('Zend_Currency::' . $config)); } else { $config = array(); } } else { $config = array(); } if (!empty($position) && is_string($position)) { $position = strtoupper($position); if (defined('Zend_Currency::' . $position)) { $config['position'] = constant('Zend_Currency::' . $position); } } $currency = Enlight_Application::Instance()->Currency(); $value = floatval(str_replace(',', '.', $value)); $value = $currency->toCurrency($value, $config); if (function_exists('mb_convert_encoding')) { $value = mb_convert_encoding($value, 'HTML-ENTITIES', 'UTF-8'); } $value = htmlentities($value, ENT_COMPAT, 'UTF-8', false); return $value; }
public function postToLaybuy() { $this->load->model('extension/payment/laybuy'); $this->model_extension_payment_laybuy->log('Posting to Laybuy'); if ($this->request->server['REQUEST_METHOD'] == 'POST') { $this->load->model('checkout/order'); $order_info = $this->model_checkout_order->getOrder($this->session->data['order_id']); if ($order_info) { $this->model_extension_payment_laybuy->log('Order ID: ' . $order_info['order_id']); $data = array(); $data['VERSION'] = '0.2'; $data['MEMBER'] = $this->config->get('laybuys_membership_id'); $data['RETURNURL'] = $this->url->link('extension/payment/laybuy/callback', '', true); $data['CANCELURL'] = $this->url->link('extension/payment/laybuy/cancel', '', true); $data['AMOUNT'] = round(floatval($order_info['total']), 2, PHP_ROUND_HALF_DOWN); $data['CURRENCY'] = $order_info['currency_code']; $data['INIT'] = (int) $this->request->post['INIT']; $data['MONTHS'] = (int) $this->request->post['MONTHS']; $data['MIND'] = (int) $this->config->get('laybuy_min_deposit') ? (int) $this->config->get('laybuy_min_deposit') : 20; $data['MAXD'] = (int) $this->config->get('laybuy_max_deposit') ? (int) $this->config->get('laybuy_max_deposit') : 50; $data['CUSTOM'] = $order_info['order_id'] . ':' . md5($this->config->get('laybuy_token')); $data['EMAIL'] = $order_info['email']; $data_string = ''; foreach ($data as $param => $value) { $data_string .= $param . '=' . $value . '&'; } $data_string = rtrim($data_string, '&'); $this->model_extension_payment_laybuy->log('Data String: ' . $data_string); $this->model_extension_payment_laybuy->log('Gateway URL: ' . $this->config->get('laybuy_gateway_url')); $ch = curl_init(); curl_setopt($ch, CURLOPT_URL, $this->config->get('laybuy_gateway_url')); curl_setopt($ch, CURLOPT_POST, true); curl_setopt($ch, CURLOPT_POSTFIELDS, $data_string); curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); curl_setopt($ch, CURLOPT_HEADER, false); curl_setopt($ch, CURLOPT_TIMEOUT, 30); curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false); $result = curl_exec($ch); if (curl_errno($ch)) { $this->model_extension_payment_laybuy->log('cURL error: ' . curl_errno($ch)); } curl_close($ch); $result = json_decode($result, true); $this->model_extension_payment_laybuy->log('Response: ' . print_r($result, true)); if (isset($result['ACK']) && isset($result['TOKEN']) && $result['ACK'] == 'SUCCESS') { $this->model_extension_payment_laybuy->log('Success response. Redirecting to PayPal.'); $this->response->redirect($this->config->get('laybuy_gateway_url') . '?TOKEN=' . $result['TOKEN']); } else { $this->model_extension_payment_laybuy->log('Failure response. Redirecting to checkout/failure.'); $this->response->redirect($this->url->link('checkout/failure', '', true)); } } else { $this->model_extension_payment_laybuy->log('No matching order. Redirecting to checkout/failure.'); $this->response->redirect($this->url->link('checkout/failure', '', true)); } } else { $this->model_extension_payment_laybuy->log('No $_POST data. Redirecting to checkout/failure.'); $this->response->redirect($this->url->link('checkout/failure', '', true)); } }
function realFilesize($filename) { $fp = fopen($filename, 'r'); $return = false; if (is_resource($fp)) { if (PHP_INT_SIZE < 8) { if (0 === fseek($fp, 0, SEEK_END)) { $return = 0.0; $step = 0x7fffffff; while ($step > 0) { if (0 === fseek($fp, -$step, SEEK_CUR)) { $return += floatval($step); } else { $step >>= 1; } } } } else { if (0 === fseek($fp, 0, SEEK_END)) { $return = ftell($fp); } } } return $return; }
/** * @brief Checks whether our assumptions hold on the PHP platform we are on. * * @throws \RunTimeException if our assumptions do not hold on the current * PHP platform. */ public function __construct() { $pow_2_53 = floatval(self::POW_2_53_MINUS_1) + 1.0; if ($this->formatUnsignedInteger($pow_2_53) !== self::POW_2_53) { throw new \RunTimeException('This class assumes floats to be double precision or "better".'); } }
public function index() { $modules = $this->read_modules(); $db_modules = $GLOBALS['db']->getAll("select * from " . DB_PREFIX . "collocation"); foreach ($modules as $k => $v) { foreach ($db_modules as $kk => $vv) { if ($v['class_name'] == $vv['class_name']) { //已安装 $modules[$k]['name'] = $vv['name']; $modules[$k]['id'] = $vv['id']; $modules[$k]['total_amount'] = $vv['total_amount']; $modules[$k]['installed'] = $vv['is_effect']; $modules[$k]['is_effect'] = $vv['is_effect']; $modules[$k]['sort'] = $vv['sort']; break; } } if ($modules[$k]['installed'] != 1) { $modules[$k]['installed'] = 0; } $modules[$k]['is_effect'] = intval($modules[$k]['is_effect']); $modules[$k]['sort'] = intval($modules[$k]['sort']); $modules[$k]['total_amount'] = floatval($modules[$k]['total_amount']); $modules[$k]['reg_url'] = $v['reg_url'] ? $v['reg_url'] : ''; } $this->assign("collocation_list", $modules); $this->display(); }
public function getNonCancelledPaymentOrdersByCurrency($date, $currencyId) { $sql = "SELECT SUM(amount) AS amount FROM `%s` WHERE `cancelled` = 0 AND `paid` = 1 AND currency_id=:id AND `date`<=DATE_ADD('%s' ,INTERVAL 1 DAY)"; $sqlQuery = sprintf($sql, $this->getTableName(), $date); $qty = $this->fetchField($sqlQuery, 'amount', array("id" => $currencyId)); return isset($qty) ? floatval($qty) : 0; }
public function to_money($number, $do_encode = false) { if (!is_numeric($number)) { $number = $this->to_number($number); } if ($number === false) { return ''; } $negative = ''; if (strpos(strval($number), '-') !== false) { $negative = '-'; $number = floatval(substr($number, 1)); } $money = number_format($number, $this->currency['decimals'], $this->currency['decimal_separator'], $this->currency['thousand_separator']); if ($money == '0.00') { $negative = ''; } $symbol_left = !empty($this->currency['symbol_left']) ? $this->currency['symbol_left'] . $this->currency['symbol_padding'] : ''; $symbol_right = !empty($this->currency['symbol_right']) ? $this->currency['symbol_padding'] . $this->currency['symbol_right'] : ''; if ($do_encode) { $symbol_left = html_entity_decode($symbol_left); $symbol_right = html_entity_decode($symbol_right); } return $negative . $symbol_left . $money . $symbol_right; }
function getPrice() { //echo '<pre>';print_r($this->price_filter);exit; $str = $this->getReplaceResult($this->price_filter, $this->html_content, 'price'); if (empty($str)) { for ($i = 0, $len = count($this->price_filter['discount']); $i < $len; $i++) { $str = $this->getReplaceResult($this->price_filter['discount'][$i], $this->html_content); if (strlen($str) > 0) { break; } } if (empty($str)) { $this->error_msg['price_error'] = 'error: empty product price and discount price'; } } if (!isset($this->error_msg['price_error'])) { $str = preg_replace("/^\\D+|\\D+\$/", '', $str); $str = floatval($str); $this->reduce_price_num = floatval($this->reduce_price_num); if ($str - $this->reduce_price_num > 0) { $str = $str - $this->reduce_price_num; } $this->product_info['price'] = $str; } }
/** * index method * * @return void * @access public */ public function index($type = null, $lat = null, $long = null, $opt1 = null, $opt2 = null) { $params = array('limit' => 35, 'page' => 1); if (!empty($type) && !empty($lat) && !empty($long)) { $lat = floatval($lat); $long = floatval($long); $opt1 = floatval($opt1); $opt2 = floatval($opt2); switch ($type) { case 'near': if (!empty($opt1)) { $cond = array('loc' => array('$near' => array($lat, $long), '$maxDistance' => $opt1)); } else { $cond = array('loc' => array('$near' => array($lat, $long))); } break; case 'box': $lowerLeft = array($lat, $long); $upperRight = array($opt1, $opt2); $cond = array('loc' => array('$within' => array('$box' => array($lowerLeft, $upperRight)))); break; case 'circle': $center = array($lat, $long); $radius = $opt1; $cond = array('loc' => array('$within' => array('$center' => array($center, $radius)))); break; } $params['conditions'] = $cond; } else { $params['order'] = array('_id' => -1); } $results = $this->Geo->find('all', $params); $this->set(compact('results')); }
public function editAction() { $p = $_REQUEST; $pId = empty($p['id']) ? Tool_Fnc::ajaxMsg('请选择食物') : intval($p['id']); $pFid = empty($p['fid']) ? Tool_Fnc::ajaxMsg('食物ID不能为空') : intval($p['fid']); $pUnit = empty($p['unit']) ? Tool_Fnc::ajaxMsg('单位不能为空') : Tool_Fnc::safe_string($p['unit']); $pAmount = empty($p['amount']) ? Tool_Fnc::ajaxMsg('数量不能为空') : floatval($p['amount']); $pWeight = empty($p['weight']) ? Tool_Fnc::ajaxMsg('重量不能为空') : floatval($p['weight']); $pMtid = empty($p['mt_id']) ? Tool_Fnc::ajaxMsg('餐类型不能为空') : intval($p['mt_id']); $tTime = time(); $tFMO = new FoodModel(); $tFRow = $tFMO->field('title,protein,thumb_img')->where('id = ' . $pFid)->fRow(); if (!count($tFRow)) { Tool_Fnc::ajaxMsg('食物不存在'); } $tMTMO = new MealtypeModel(); $tMTRow = $tMTMO->field('name')->where('id = ' . $pMtid)->fRow(); if (!count($tMTRow)) { Tool_Fnc::ajaxMsg('餐类型不存在'); } $tRFDMO = new R_FoodaddModel(); $tRFRow = $tRFDMO->field('count(*) c')->where(' id =' . $pId)->fRow(); if (empty($tRFRow['c'])) { Tool_Fnc::ajaxMsg('操作异常'); } $tData = array('id' => $pId, 'title' => $tFRow['title'], 'unit' => $pUnit, 'amount' => $pAmount, 'weight' => $pWeight, 'mt_id' => $pMtid, 'mt_name' => $tMTRow['name'], 'created' => $tTime, 'fid' => $pFid, 'uid' => $this->tUid, 'thumb_img' => $tFRow['thumb_img'], 'protein' => $tFRow['protein'] / 100 * $pWeight); if (!$tRFDMO->update($tData)) { Tool_Fnc::ajaxMsg('更新失败'); } Tool_Fnc::ajaxMsg('更新成功', 1); }
/** * @param int $id * @param float $x * @param float $y */ public function __construct($id, $x, $y) { $this->id = intval($id); $this->x = floatval($x); $this->y = floatval($y); $this->data = array(); }
/** * Filter the arguments for HTTP requests. If the request is to a URL that's part of * something we're handling then filter the arguments accordingly. * * @author John Blackbourn * @param array $args HTTP request arguments. * @param string $url HTTP request URL. * @return array Updated array of arguments. */ public function filter_http_request_args(array $args, $url) { if (preg_match('#://api\\.wordpress\\.org/(?P<type>plugins|themes)/update-check/(?P<version>[0-9\\.]+)/#', $url, $matches)) { switch ($matches['type']) { case 'plugins': return $this->plugin_request($args, floatval($matches['version'])); break; case 'themes': return $this->theme_request($args, floatval($matches['version'])); break; } } $query = parse_url($url, PHP_URL_QUERY); if (empty($query)) { return $args; } parse_str($query, $query); if (!isset($query['_euapi_type']) or !isset($query['_euapi_file'])) { return $args; } if (!($handler = $this->get_handler($query['_euapi_type'], $query['_euapi_file']))) { return $args; } $args = array_merge($args, $handler->config['http']); return $args; }
public function updateBudgetPrediction($event) { $event->name = Crypt::decrypt($event->name); // remove all budget prediction points, if any $event->budgetpredictionpoints()->delete(); $similar = array(); // get all similar budgets from the past: $budgets = Auth::user()->budgets()->where('date', '<=', $event->date)->get(); foreach ($budgets as $budget) { $budget->name = Crypt::decrypt($budget->name); if ($budget->name == $event->name) { $similar[] = $budget->id; } } if (count($similar) > 0) { // get all transactions for these budgets: $amounts = array(); $transactions = Auth::user()->transactions()->orderBy('date', 'DESC')->where('onetime', '=', 0)->whereIn('budget_id', $similar)->get(); foreach ($transactions as $t) { $date = new Carbon($t->date); $day = intval($date->format('d')); $amounts[$day] = isset($amounts[$day]) ? $amounts[$day] + floatval($t->amount) * -1 : floatval($t->amount) * -1; } // then make sure it's "average". foreach ($amounts as $day => $amount) { // save as budget prediction point. $bpp = new Budgetpredictionpoint(); $bpp->budget_id = $event->id; $bpp->amount = $amount / count($similar); $bpp->day = $day; $bpp->save(); } } }
/** * Assign data to info model instance * * @param mixed $data * @return Mage_Payment_Model_Info */ public function assignData($data) { if (!$data instanceof Varien_Object) { $data = new Varien_Object($data); } // salva a bandeira, o numero de parcelas e o token $info = $this->getInfoInstance(); $additionaldata = array('parcels_number' => $data->getParcelsNumber()); if ($data->getToken()) { $tokenData = $this->_getTokenById($data->getToken()); $additionaldata['token'] = $tokenData['token']; $data->setCcType($tokenData['ccType']); } $info->setCcType($data->getCcType())->setCcNumber(Mage::helper('core')->encrypt($data->getCcNumber()))->setCcOwner($data->getCcOwner())->setCcExpMonth($data->getCcExpMonth())->setCcExpYear($data->getCcExpYear())->setCcCid(Mage::helper('core')->encrypt($data->getCcCid()))->setAdditionalData(serialize($additionaldata)); // pega dados de juros $withoutInterest = intval($this->getConfigData('installment_without_interest', $this->getStoreId())); $interestValue = floatval($this->getConfigData('installment_interest_value', $this->getStoreId())); // verifica se há juros if ($data->getParcelsNumber() > $withoutInterest) { $installmentValue = Mage::helper('Query_Cielo')->calcInstallmentValue($info->getQuote()->getGrandTotal(), $interestValue / 100, $data->getParcelsNumber()); $installmentValue = round($installmentValue, 2); $interest = $installmentValue * $data->getParcelsNumber() - $info->getQuote()->getGrandTotal(); $info->getQuote()->setInterest($info->getQuote()->getStore()->convertPrice($interest, false)); $info->getQuote()->setBaseInterest($interest); $info->getQuote()->setTotalsCollectedFlag(false)->collectTotals(); $info->getQuote()->save(); } else { $info->getQuote()->setInterest(0.0); $info->getQuote()->setBaseInterest(0.0); $info->getQuote()->setTotalsCollectedFlag(false)->collectTotals(); $info->getQuote()->save(); } return $this; }
/** * Returns rotated image * * @param WideImage_Image $image * @param numeric $angle * @param int $bgColor * @param bool $ignoreTransparent * @return WideImage_Image */ function execute($image, $angle, $bgColor, $ignoreTransparent) { $angle = -floatval($angle); if ($angle < 0) { $angle = 360 + $angle; } $angle = $angle % 360; if ($angle == 0) { return $image->copy(); } if ($bgColor === null) { if ($image->isTransparent()) { $bgColor = $image->getTransparentColor(); } else { $tc = array('red' => 255, 'green' => 255, 'blue' => 255, 'alpha' => 127); if ($image->isTrueColor()) { $bgColor = $image->getExactColorAlpha($tc); if ($bgColor == -1) { $bgColor = $image->allocateColorAlpha($tc); } } else { $bgColor = $image->getExactColor($tc); if ($bgColor == -1) { $bgColor = $image->allocateColor($tc); } } } } return new WideImage_TrueColorImage(imagerotate($image->getHandle(), $angle, $bgColor, $ignoreTransparent)); }
/** * @return array */ public function getValue() { $original = $this->getOriginalValue(); if (is_array($original)) { return $original; } if (!is_string($original)) { $this->typeError('Array'); } $convert = $this->autoConvert; return array_map(function ($value) use($convert) { $value = trim($value); if (!$convert) { return $value; } if (preg_match('/\\d+\\.\\d+/', $value)) { return floatval($value); } if (preg_match('/\\d+/', $value)) { return intval($value); } if (preg_match('/false|true/', $value)) { return $value === 'true'; } if ($value === 'null') { return null; } return $value; }, explode($this->delimiter, $original)); }
function lib_peak_memory() { $oneMb = 1024 * 1024; $memory = memory_get_peak_usage() / $oneMb; $memory = round($memory, 4); return floatval($memory); }
public function parseParams() { global $_GET; // get zoom from GET paramter $this->zoom = $_GET['zoom'] ? intval($_GET['zoom']) : 0; if ($this->zoom > 18) { $this->zoom = 18; } // get lat and lon from GET paramter list($this->lat, $this->lon) = split(',', $_GET['center']); $this->lat = floatval($this->lat); $this->lon = floatval($this->lon); // get zoom from GET paramter if ($_GET['size']) { list($this->width, $this->height) = split('x', $_GET['size']); $this->width = intval($this->width); $this->height = intval($this->height); } if ($_GET['markers']) { $markers = split('%7C|\\|', $_GET['markers']); foreach ($markers as $marker) { list($markerLat, $markerLon, $markerImage) = split(',', $marker); $markerLat = floatval($markerLat); $markerLon = floatval($markerLon); $markerImage = basename($markerImage); $this->markers[] = array('lat' => $markerLat, 'lon' => $markerLon, 'image' => $markerImage); } } if ($_GET['maptype']) { if (array_key_exists($_GET['maptype'], $this->tileSrcUrl)) { $this->maptype = $_GET['maptype']; } } }
/** * {@inheritDoc} */ public function apply(Rule $rule, $value) { if (is_array($value) || is_object($value)) { return null; } return floatval($value); }
public static function getPrice(&$arPaySystem, $orderPrice, $deliveryPrice, $buyerLocationId) { if (!isset($arPaySystem["PSA_TARIF"]) || strlen($arPaySystem["PSA_TARIF"]) <= 0) { return 0; } $result = 0; $arLoc = CSaleLocation::GetByID($buyerLocationId); $regId = $arLoc["REGION_ID"]; $arTarifs = self::extractFromField($arPaySystem["PSA_TARIF"]); $arTarif = isset($arTarifs[$regId]) ? $arTarifs[$regId] : $arTarifs[0]; $fullPrice = $orderPrice + $deliveryPrice; if ($fullPrice <= 1000) { $tarifNum = "0"; } elseif ($fullPrice <= 5000) { $tarifNum = "1"; } elseif ($fullPrice <= 20000) { $tarifNum = "2"; } elseif ($fullPrice <= 500000) { $tarifNum = "3"; } if (isset($tarifNum)) { $percent = 0; if ($arTarif["TARIFS"][$tarifNum]["UPPER_SUMM"] < $orderPrice) { $percent = floatval($arTarif["TARIFS"][$tarifNum]["PERCENT"]) * floatval($orderPrice) / 100; } $result = floatval($arTarif["TARIFS"][$tarifNum]["FIX"]) + $percent; } return round($result, 0); }
/** * @param $main_account_username * @param $main_account_password * @param $customer_username * @param DateTime $date * @return int * @throws Exception */ public function getTotalUsedCredits($main_account_username, $main_account_password, $customer_username, DateTime $date) { $totalCreditUsed = 0; $this->customer = $customer_username; $this->date = $date; $this->main_account_username = $main_account_username; $this->main_account_password = $main_account_password; $this->date = $this->date->add(new DateInterval("P1D")); //the api call doesnt include the current date so we move a day ahead $dtToday = $this->date->format("Y-m-d"); $requestString = "https://www.voipinfocenter.com/API/Request.ashx?command=calloverview&username={$this->main_account_username}&password={$this->main_account_password}&customer={$this->customer}&date={$dtToday}%2000:00:00&recordcount=500"; $curlRes = curl_init($requestString); curl_setopt($curlRes, CURLOPT_RETURNTRANSFER, true); curl_setopt($curlRes, CURLOPT_SSL_VERIFYPEER, false); curl_setopt($curlRes, CURLOPT_SSL_VERIFYHOST, false); $requestResult = curl_exec($curlRes); $this->date = $this->date->sub(new DateInterval("P1D")); //revert date add if (is_null($requestResult) || empty($requestResult)) { throw new Exception("Empty result from API server"); } $xmlObject = new SimpleXMLElement($requestResult); $callsTempContainer = (array) $xmlObject->Calls; $callsTempContainer = $callsTempContainer['Call']; foreach ($callsTempContainer as $currentCallObj) { // if date is equal to date passed $parsedDate = strtotime($currentCallObj['StartTime']); if ($this->date->format("Y-m-d") === date("Y-m-d", $parsedDate)) { $totalCreditUsed += floatval($currentCallObj['Charge']); } } return $totalCreditUsed; }
protected function execute(InputInterface $input, OutputInterface $output) { // use api parameters from a settings file // Make api call to get list of products $products = $this->getListPromotionProducts(); $productUrls = $this->array_value_recursive('productUrl', $products); // Make api call to get the affiliate url for each product $affiliateUrls = $this->getPromotionLinks($productUrls); /* * Store product feed in db */ // $category = new Category(); // $category->setName('Apparel'); $category = $this->getContainer()->get('doctrine')->getRepository('AppBundle:Category')->find(1); foreach ($products as $key => $p) { $product = new Product(); $product->setCategory($category)->setAliProductId($p['productId'])->setAliProductTitle($p['productTitle'])->setAliProductUrl($p['productUrl'])->setAliSalePrice(round(floatval(substr($p['salePrice'], 4))))->setAli30DaysCommission($p['30daysCommission'])->setAliVolume($p['volume'])->setAliCategoryId($options['categoryId'])->setAliAffiliateUrl($affiliateUrls[$key]['promotionUrl']); $em = $this->getEntityManager('default'); $em->persist($product); $em->persist($category); $em->flush(); // $output->writeln($p['productTitle']); } echo 'just sent ' . count($products) . ' products to the db' . "\n\n"; // call get:photos command for each photo to see scrape pics from ali site }
function lefttime($second) { $times = ''; $day = floor($second / (3600 * 24)); $second = $second % (3600 * 24); //除去整天之后剩余的时间 $hour = floor($second / 3600); $second = $second - $hour * 3600; //除去整小时之后剩余的时间 $minute = floor($second / 60); $second = fmod(floatval($second), 60); //除去整分钟之后剩余的时间 if ($day) { $times = $day . '天'; } if ($hour) { $times .= $hour . '小时'; } if ($minute) { $times .= $minute . '分'; } if ($second) { $times .= $second . '秒'; } //返回字符串 return $times; }
/** * Process this field after being posted * @return array on success, WP_ERROR on failure */ public function get_cart_item_data() { $cart_item_data = array(); foreach ($this->addon['options'] as $key => $option) { $option_key = empty($option['label']) ? $key : sanitize_title($option['label']); $posted = isset($this->value[$option_key]) ? $this->value[$option_key] : ''; if ($posted === '') { continue; } $label = $this->get_option_label($option); $price = $this->get_option_price($option); switch ($this->addon['type']) { case "custom_price": $price = floatval(sanitize_text_field($posted)); if ($price >= 0) { $cart_item_data[] = array('name' => $label, 'value' => $price, 'price' => $price, 'display' => strip_tags(woocommerce_price($price))); } break; case "input_multiplier": $posted = absint($posted); $cart_item_data[] = array('name' => $label, 'value' => $posted, 'price' => $posted * $price); break; default: $cart_item_data[] = array('name' => $label, 'value' => wp_kses_post($posted), 'price' => $price); break; } } return $cart_item_data; }