public function getSumReport($dateFrom, $dateTo)
 {
     $sum = 0;
     $res = Yii::app()->db->createCommand("select sum(paid) 'sum' from tbl_orders where order_date between '{$dateFrom}' and '{$dateTo}'")->queryRow();
     $sum = doubleval($res['sum']);
     return $sum;
 }
 public static function SubjectEdit(Ab_Database $db, $d)
 {
     $proj = bkint($d->project1) . ',' . bkint($d->project2);
     $hours = doubleval($d->numhours1) . '/' . doubleval($d->numhours2);
     $sql = "\n\t\t\tUPDATE " . $db->prefix . "rb_subject\n\t\t\tSET \n\t\t\t\tnamesubject='" . bkstr($d->namesubject) . "',\n\t\t\t\tformcontrol='" . bkstr($d->formcontrol) . "',\n\t\t\t\tnumcrs=" . bkint($d->numcrs) . ",\n\t\t\t\tsemestr=" . bkint($d->semestr) . ",\n\t\t\t\tnumhours='" . $hours . "',\n\t\t\t\tproject='" . $proj . "'\n\t\t\tWHERE subjectid=" . bkint($d->subjectid) . " AND fieldid=" . bkint($d->id) . "\n\t\t\tLIMIT 1\n\t\t";
     $db->query_write($sql);
 }
Beispiel #3
0
 /**
  * Measure time between two events
  *
  * First call should be to $key = Debug::timer() with no params, or provide your own key that's not already been used
  * Second call should pass the key given by the first call to get the time elapsed, i.e. $time = Debug::timer($key).
  * Note that you may make multiple calls back to Debug::timer() with the same key and it will continue returning the 
  * elapsed time since the original call. If you want to reset or remove the timer, call removeTimer or resetTimer.
  *
  * @param string $key 
  * 	Leave blank to start timer. 
  *	Specify existing key (string) to return timer. 
  *	Specify new made up key to start a named timer. 
  * @param bool $reset If the timer already exists, it will be reset when this is true. 
  * @return string|int
  *
  */
 public static function timer($key = '', $reset = false)
 {
     // returns number of seconds elapsed since first call
     if ($reset && $key) {
         self::removeTimer($key);
     }
     if (!$key || !isset(self::$timers[$key])) {
         // start new timer
         preg_match('/(\\.[0-9]+) ([0-9]+)/', microtime(), $time);
         $startTime = doubleval($time[1]) + doubleval($time[2]);
         if (!$key) {
             $key = $startTime;
             while (isset(self::$timers[$key])) {
                 $key .= ".";
             }
         }
         self::$timers[$key] = $startTime;
         $value = $key;
     } else {
         // return timer
         preg_match('/(\\.[0-9]*) ([0-9]*)/', microtime(), $time);
         $endTime = doubleval($time[1]) + doubleval($time[2]);
         $startTime = self::$timers[$key];
         $runTime = number_format($endTime - $startTime, 4);
         $value = $runTime;
     }
     return $value;
 }
Beispiel #4
0
 function filterPrice($price)
 {
     $price = str_replace('Rp ', '', $price);
     $price = str_replace(',', '', $price);
     $num_price = doubleval($price);
     return $num_price;
 }
 /**
  * Prepocte bodovou hodnotu zaplavaneho casu
  * @param string $year        Rok pro vyber zakladnich casu
  * @param string $id          Identifikator radku
  * @param string $id_event    Identifikator zavodu
  * @param string $id_stroke   Identifikator stylu
  * @param string $id_swimmer  Identifikator plavce
  * @param string $time        Zaplavany cas
  * @return int                Vypocteny pocet bodu
  */
 private function prepocetBodu($year, $id, $id_event, $id_stroke, $id_swimmer, $time)
 {
     // Dotaz na delku bazenu (1 - 50m tzn. LCM, 0 - 25m tzn. SCM)
     $lcm = $this->database->query('select lcm from sm_event where id = ?', $id_event)->fetchField();
     if ($lcm == 0) {
         $lcm = 'SCM';
     } else {
         $lcm = 'LCM';
     }
     // Dotaz na pohlavi plavce (M - muz, Z - zena)
     $sex = $this->database->query('select sex from sm_swimmer where id = ?', $id_swimmer)->fetchField();
     if ($sex == 'Z') {
         $sex = 'F';
     }
     // Dotaz na zakladni cas
     $b = $this->database->query('select basetime_s from sm_bt ' . 'where year=? and course=? and sex=? and relay=1 and stroke=?', $year, $lcm, $sex, $id_stroke)->fetchField();
     // Prevod zaplavaneho casu na sekundy (mm:ss,ss)
     $t1 = doubleval(substr($time, 0, 2)) * 60;
     // Minuty
     $t2 = doubleval(substr(str_replace(',', '.', $time), 3));
     // Sekundy
     $t = $t1 + $t2;
     // Vlastni vypocet bodu
     $p = round(1000 * pow($b / $t, 3));
     // Zapis prepoctene hodnoty bodu do tabulky
     //$this->database->query('UPDATE sm_time_pom SET point=? WHERE id=?', $p, $id);
     $this->database->table($this->tableName)->where('id', $id)->update(['point' => $p]);
     //$p]);
     return $p;
 }
 /**
  *
  * @param string $latLong
  * @param bool $forceReload
  * @return \models\entities\GeocodeCached Description
  *
  */
 public function lookUp($latLong, $forceReload = false)
 {
     list($lat, $long) = explode(',', $latLong);
     $preciseLat = round(doubleval($lat), self::GEOCODE_PRECISION);
     $preciseLong = round(doubleval($long), self::GEOCODE_PRECISION);
     if (!$forceReload) {
         $lookUpWhere = (new \DbTableWhere())->where('longitude', $preciseLong)->where('latitude', $preciseLat)->setLimitAndOffset(1);
         $cachedList = \models\entities\GeocodeCached::manager()->getEntitiesWhere($lookUpWhere);
         if (count($cachedList)) {
             return $cachedList[0];
         }
     }
     foreach ($this->serviceProviderList as $serviceProvier) {
         $lookUpResult = $serviceProvier->lookUp($preciseLong, $preciseLat);
         \SystemLogger::debug("Making call with: ", $serviceProvier->getClassBasic());
         if ($lookUpResult && ($lookUpResult->getCity() || $lookUpResult->getPostalCode())) {
             //var_dump($lookUpResult);exit;
             return $this->cacheLookup($lookUpResult, $preciseLong, $preciseLat);
         } else {
             if ($lastError = $serviceProvier->getLastError(true)) {
                 \SystemLogger::warn("Error: {$lastError->getMessage()} TYPE: {$lastError->getType()}");
             }
             if ($lastError && !$lastError->isRateLimit()) {
                 break;
             }
         }
     }
     return null;
 }
 /**
  * Display the specified resource.
  *
  * @param \Illuminate\Http\Request $request
  *
  * @return \Illuminate\Http\Response
  * @internal param \Illuminate\Http\Request $request
  * @internal param int $id
  */
 public function index(Request $request)
 {
     // Get lat / lng
     $lat = $request->get('lat', false);
     $lng = $request->get('lng', false);
     if (!$lat || !$lng) {
         return response()->json(['message' => 'Both latitude and longitude are required.'], Response::HTTP_BAD_REQUEST);
     }
     if (!is_numeric($lat) || !is_numeric($lng)) {
         return response()->json(['message' => 'Both latitude and longitude must be double values.'], Response::HTTP_BAD_REQUEST);
     }
     $stationRepository = StationRepository::getInstance();
     $station = $stationRepository->getCaqiForLocation(doubleval($lat), doubleval($lng));
     if (!empty($station)) {
         // Get measurements for components
         $componentsRepository = ComponentRepository::getInstance();
         $measurementRepository = MeasurementRepository::getInstance();
         $components = $componentsRepository->getAll();
         $componentMeasurements = [];
         /** @var Component $component */
         foreach ($components as $component) {
             // Get latest measurement!
             $measurement = $measurementRepository->getLatestForStationAndComponent($station, $component);
             $componentMeasurements[$component->getSepaId()]['measurement'] = $measurement;
             $componentMeasurements[$component->getSepaId()]['component'] = $component;
         }
         $responseData = ['station' => $station, 'components' => $componentMeasurements];
         return response()->json($responseData);
     }
     return response()->json([], Response::HTTP_NO_CONTENT);
 }
Beispiel #8
0
 function __set($key, $value)
 {
     if (!isset(static::$fields[$key])) {
         throw new exception("CTwiz property field " . $key . " doesn't exist");
     }
     if (gettype($value) == static::$fields[$key]) {
         $this->data[$key] = $value;
         return true;
     }
     switch (static::$fields[$key]) {
         case 'boolean':
             $this->data[$key] = $value ? true : false;
             return true;
         case 'string':
             $this->data[$key] = "" + $value;
             return true;
         case 'integer':
             $parts = explode("-", $value);
             $max = max($parts);
             $this->data[$key] = intval($max);
             return true;
         case 'double':
             $parts = explode("-", $value);
             $max = max($parts);
             $this->data[$key] = doubleval($max);
             return true;
     }
     throw new exception("CTwiz property wrong data type " . gettype($value) . " for " . $key . ". Should be " . static::$fields[$key]);
 }
function olc_format_price_order($price_string, $price_special, $currency, $show_currencies = 1)
{
    if (doubleval($price_string) != 0) {
        include DIR_FS_INC . 'olc_get_currency_parameters.inc.php';
        if ($calculate_currencies == TRUE_STRING_S) {
            $price_string = $price_string * CURRENCY_VALUE;
        }
        // round price
        $price_string = olc_precision($price_string, CURRENCY_DECIMAL_PLACES);
        if ($price_special == '1') {
            $price_string = number_format($price_string, CURRENCY_DECIMAL_PLACES, CURRENCY_DECIMAL_POINT, CURRENCY_THOUSANDS_POINT);
            if ($show_currencies == 1) {
                $price_string = CURRENCY_SYMBOL_LEFT . $price_string . CURRENCY_SYMBOL_RIGHT;
            }
        }
        //1,00 -> 1,--
        global $is_print_version, $is_pdf;
        if ($is_print_version) {
            if ($is_pdf) {
                $s = CURRENCY_DECIMAL_ZEROES_DASHES_PRINT_PDF;
            } else {
                $s = CURRENCY_DECIMAL_ZEROES_DASHES_PRINT;
            }
        } else {
            $s = CURRENCY_DECIMAL_ZEROES_DASHES;
        }
        $price_string = str_replace(CURRENCY_DECIMAL_ZEROES, $s, $price_string);
    } else {
        $price_string = EMPTY_STRING;
    }
    return $price_string;
}
Beispiel #10
0
 function normalizarvalor($valor, $tipo, $largo = 0, $definido = "")
 {
     $valor = !get_magic_quotes_gpc() ? addslashes($valor) : $valor;
     switch ($tipo) {
         case "varchar":
             $valor = !empty($valor) ? substr(strtoupper($valor), 0, intval($largo)) : "NULL";
             break;
         case "int":
             $valor = !empty($valor) ? intval($valor) : "NULL";
             break;
         case "tinyint":
             $valor = !empty($valor) ? intval($valor) : "NULL";
             break;
         case "double":
             $valor = $valor != "" ? doubleval($valor) : "NULL";
             break;
         case "date":
             $valor = $valor != "" ? $valor : "NULL";
             break;
         case "enum":
             $valor = !empty($valor) ? $valor : $definido;
             break;
     }
     return strtoupper($valor);
 }
Beispiel #11
0
 /**
  * Calculate
  *
  * @return void
  */
 public function calculate()
 {
     $zones = $this->getZonesList();
     $memebrship = $this->getMembership();
     foreach ($this->getTaxes() as $tax) {
         $previousItems = array();
         $previousClasses = array();
         $cost = 0;
         $ratesExists = false;
         foreach ($tax->getFilteredRates($zones, $memebrship) as $rate) {
             $ratesExists = true;
             $productClass = $rate->getProductClass() ?: null;
             if (!in_array($productClass, $previousClasses)) {
                 $items = $this->getTaxableItems($productClass, $previousItems);
                 if ($items) {
                     foreach ($items as $item) {
                         $previousItems[] = $item->getProduct()->getProductId();
                     }
                     $cost += $rate->calculate($items);
                 }
                 $previousClasses[] = $productClass;
             }
         }
         if ($cost) {
             $this->addOrderSurcharge($this->code . '.' . $tax->getId(), doubleval($cost), false, $ratesExists);
         }
     }
 }
Beispiel #12
0
 /**
  * Perform verification of the payment, this is called from the payment gateway
  *
  * @return	bool	Whether the payment is valid
  */
 function verify_payment()
 {
     $this->registry->input->clean_array_gpc('p', array('pay_to_email' => TYPE_STR, 'merchant_id' => TYPE_STR, 'transaction_id' => TYPE_STR, 'mb_transaction_id' => TYPE_UINT, 'status' => TYPE_STR, 'md5sig' => TYPE_STR, 'amount' => TYPE_STR, 'currency' => TYPE_STR, 'mb_amount' => TYPE_STR, 'mb_currency' => TYPE_STR));
     if (!$this->test()) {
         $this->error = 'Payment processor not configured';
         return false;
     }
     $this->transaction_id = $this->registry->GPC['mb_transaction_id'];
     $check_hash = strtoupper(md5($this->registry->GPC['merchant_id'] . $this->registry->GPC['transaction_id'] . strtoupper(md5(strtolower($this->settings['mbsecret']))) . $this->registry->GPC['mb_amount'] . $this->registry->GPC['mb_currency'] . $this->registry->GPC['status']));
     if ($check_hash == $this->registry->GPC['md5sig'] and strtolower($this->registry->GPC['pay_to_email']) == strtolower($this->settings['mbemail'])) {
         if (intval($this->registry->GPC['status']) == 2) {
             $this->paymentinfo = $this->registry->db->query_first("\n\t\t\t\t\tSELECT paymentinfo.*, user.username\n\t\t\t\t\tFROM " . TABLE_PREFIX . "paymentinfo AS paymentinfo\n\t\t\t\t\tINNER JOIN " . TABLE_PREFIX . "user AS user USING (userid)\n\t\t\t\t\tWHERE hash = '" . $this->registry->db->escape_string($this->registry->GPC['transaction_id']) . "'\n\t\t\t\t");
             // lets check the values
             if (!empty($this->paymentinfo)) {
                 $sub = $this->registry->db->query_first("SELECT * FROM " . TABLE_PREFIX . "subscription WHERE subscriptionid = " . $this->paymentinfo['subscriptionid']);
                 $cost = unserialize($sub['cost']);
                 $this->paymentinfo['currency'] = strtolower($this->registry->GPC['currency']);
                 $this->paymentinfo['amount'] = floatval($this->registry->GPC['amount']);
                 if (doubleval($this->registry->GPC['amount']) == doubleval($cost["{$this->paymentinfo[subscriptionsubid]}"]['cost'][strtolower($this->registry->GPC['currency'])])) {
                     $this->type = 1;
                     return true;
                 }
             }
         }
     }
     return false;
 }
 /**
  * 验证字段是否符合注解数据参数约定条件,如果不能满足条件,返回错误结束该请求。
  *
  * @param string $key 传入的域的值
  * @param int $value
  * @param array $params 基于类模板读取的注解数组。
  */
 public function validator($key, $value, $params)
 {
     //是否必须检测
     if (isset($params[DoubleValidator::$_REQUIRED]) && $params[DoubleValidator::$_REQUIRED] == true) {
         if (!is_numeric($value)) {
             ResponseApi::sendErrorAndEnd($key . "=" . $value . "是必填项)", Message::$_ERROR_FORMAT);
         }
     }
     if ($value != null) {
         //类型检查
         if (!is_numeric($value)) {
             ResponseApi::sendErrorAndEnd($key . "=" . $value . "必须是double型)", Message::$_ERROR_FORMAT);
         }
         $dvalue = doubleval($value);
         if (isset($params[DoubleValidator::$_MIN])) {
             $min_d = $params[DoubleValidator::$_MIN];
             if (isset($min_d)) {
                 if ($min_d && $dvalue < $min_d) {
                     ResponseApi::sendErrorAndEnd($key . "=" . $value . "是最小值是" . $min_d . ")", Message::$_ERROR_FORMAT);
                 }
             }
         }
         if (isset($params[DoubleValidator::$_MAX])) {
             $max_d = $params[DoubleValidator::$_MAX];
             if (isset($max_d)) {
                 if ($max_d && $dvalue > $max_d) {
                     ResponseApi::sendErrorAndEnd($key . "=" . $value . "是最大值是" . $max_d . ")", Message::$_ERROR_FORMAT);
                 }
             }
         }
     }
 }
 /**
  * Update the specified resource in storage.
  *
  * @param  \Illuminate\Http\Request $request
  *
  * @return \Illuminate\Http\Response
  *
  */
 public function store(Request $request)
 {
     // Read subscriber details
     $uuid = $request->json('uuid');
     $latitude = $request->json('latitude');
     $longitude = $request->json('longitude');
     // Validate latitude/longitude
     if (!is_numeric($latitude)) {
         return response()->json(['message' => "Latitude must be a number."], Response::HTTP_BAD_REQUEST);
     }
     if (!is_numeric($longitude)) {
         return response()->json(['message' => "Longitude must be a number."], Response::HTTP_BAD_REQUEST);
     }
     // Check if user is already subscribed
     $repository = SubscriberRepository::getInstance();
     $subscriber = $repository->getByUuid($uuid);
     if (!empty($subscriber)) {
         return response()->json(['message' => "Already subscribed."], Response::HTTP_BAD_REQUEST);
     }
     $subscriber = new Subscriber();
     $subscriber->setUuid($uuid);
     $subscriber->setLatitude(doubleval($latitude));
     $subscriber->setLongitude(doubleval($longitude));
     try {
         $subscriber->save();
     } catch (QueryException $exception) {
         return response()->json(['message' => "Oops, something went wrong."], Response::HTTP_INTERNAL_SERVER_ERROR);
     }
     return response()->json([], Response::HTTP_CREATED);
 }
 public function loadDataSources()
 {
     $chartInitialData = array();
     $sipAccountNames = array();
     $chartSeriesData = array();
     $criteria = new CDbCriteria();
     $criteria->order = "vici_user ASC";
     $allRemoteModels = RemoteDataCache::model()->findAll($criteria);
     foreach ($allRemoteModels as $key => $currentRemoteData) {
         $tempColorContainer = "red";
         //collect sip accounts
         $sipAccountNames[$key] = $currentRemoteData->sub_user;
         //register chart data array
         $chartInitialData = array("name" => $currentRemoteData->sub_user, "data" => $currentRemoteData->exact_balance);
         if (doubleval($currentRemoteData->exact_balance) >= 5) {
             $tempColorContainer = "#7CB5EC";
         } else {
             if ($currentRemoteData->exact_balance > 3) {
                 $tempColorContainer = "orange";
             }
         }
         //register series data
         $chartSeriesData[$key] = array("y" => doubleval($currentRemoteData->exact_balance), "color" => $tempColorContainer);
     }
     return array('iniChartData' => $chartInitialData, 'sipAccountStr' => $sipAccountNames, 'chartSeriesData' => $chartSeriesData);
 }
Beispiel #16
0
 public function actionNewui()
 {
     $data = DataPlaceholder::generateFakeData();
     $tempAveHoldTime = doubleval($data['aveHoldTime']);
     if ($tempAveHoldTime != 0) {
         /*store to session */
         Yii::app()->request->cookies['aveHoldTime'] = new CHttpCookie('aveHoldTime', $tempAveHoldTime);
         // echo "here";
     } else {
         // echo "here else";
         $tempAveHoldTime = Yii::app()->request->cookies['aveHoldTime']->value;
     }
     $tempAveHoldTime = doubleval($tempAveHoldTime);
     $tempAveHoldTime = ceil($tempAveHoldTime);
     $orig_averageHoldTime = $tempAveHoldTime;
     $tempAveHoldTime = sprintf("%02d:%02d", intval($tempAveHoldTime / 60), $tempAveHoldTime % 60);
     if (Yii::app()->request->isAjaxRequest) {
         $data['liveRevDvalue'] = $data['liveRevDvalue'];
         $data['convertedDealRaw'] = $data['convertedDeal'];
         $data['convertedDeal'] = "&pound;" . number_format(doubleval($data['convertedDeal']));
         $data["converRate"] = $data['converRate'];
         $data['aveHoldTime'] = $tempAveHoldTime;
         //convert and format
         $data['convertedDealCount'] = empty($data['convertedDealCount']) ? 0 : $data['convertedDealCount'];
         $data['orig_averageHoldTime'] = $orig_averageHoldTime;
         echo json_encode($data);
         Yii::app()->end();
     }
     $this->render('newui', array('revDVal' => rand(50, 150), 'waiting' => $data['waiting'], "called" => $data['called'], "convertedDeal" => doubleval($data['convertedDeal']), "convertedDealCount" => empty($data['convertedDealCount']) ? 0 : $data['convertedDealCount'], "converRate" => $data['converRate'], "averageHoldTime" => $tempAveHoldTime, "tbc" => $data['tbc'], "orig_tbc" => $data['orig_tbc'], "orig_averageHoldTime" => $orig_averageHoldTime, "leads" => $data['leads'], "contacted" => $data['contacted']));
 }
Beispiel #17
0
 function GetSQLValueString($theValue, $theType, $theDefinedValue = "", $theNotDefinedValue = "")
 {
     if (PHP_VERSION < 6) {
         $theValue = get_magic_quotes_gpc() ? stripslashes($theValue) : $theValue;
     }
     //在magic_quotes_gpc=On的情况下,如果输入的数据有单引号(’)、双引号(”)、反斜线()与 NUL(NULL 字符)等字符都会被加上反斜线,以确保这些数据不会引起程序,特别是数据库语句因为特殊字符引起的污染而出现致命的错误
     //如果magic_quotes_gpc=On,则用stripslashes去掉多余的"/",
     $theValue = function_exists("mysql_real_escape_string") ? mysql_real_escape_string($theValue) : mysql_escape_string($theValue);
     switch ($theType) {
         case "text":
             $theValue = $theValue != "" ? "'" . $theValue . "'" : "NULL";
             break;
         case "long":
         case "int":
             $theValue = $theValue != "" ? intval($theValue) : "NULL";
             break;
         case "double":
             $theValue = $theValue != "" ? doubleval($theValue) : "NULL";
             break;
         case "date":
             $theValue = $theValue != "" ? "'" . $theValue . "'" : "NULL";
             break;
         case "defined":
             $theValue = $theValue != "" ? $theDefinedValue : $theNotDefinedValue;
             break;
     }
     return $theValue;
 }
 public function consultar($arrStrFiltros)
 {
     $arrStrDados = RepoFluxoCaixa::getInstance()->consultar($arrStrFiltros);
     $arrObjsRetorno = null;
     if ($arrStrDados != null) {
         if (count($arrStrDados) > 0) {
             $arrObjs = array();
             $douTotalLancamentos = 0;
             for ($intI = 0; $intI < count($arrStrDados); $intI++) {
                 $douTotalLancamentos += doubleval($arrStrDados[$intI]["LCA_Valor"]);
                 $arrObjs[$intI] = $this->factory($arrStrDados[$intI]);
                 // formata��es
                 $arrStrDados[$intI]["LCA_DataMovimento"] = DataHelper::getInstance()->converterDataBancoParaDataUsuario($arrStrDados[$intI]["LCA_DataMovimento"]);
                 $arrStrDados[$intI]["LCA_Valor"] = NumeroHelper::getInstance()->formatarMoeda($arrStrDados[$intI]["LCA_Valor"]);
             }
             // responsável por exibir dados na grid
             $arrObjsRetorno = array();
             $arrObjsRetorno["objects"] = $arrObjs;
             $arrObjsRetorno["rows"] = $arrStrDados;
             $arrObjsRetorno["totalLancamentos"] = NumeroHelper::getInstance()->formatarMoeda($douTotalLancamentos);
             // identifica o total de registros referente a consulta
             $arrStrFiltros["TOT_Total"] = true;
             $arrStrDadosTotal = RepoFluxoCaixa::getInstance()->consultar($arrStrFiltros);
             $arrObjsRetorno["num_rows"] = $arrStrDadosTotal[0]["Total"];
         }
     }
     return $arrObjsRetorno;
 }
 /**
  * Perform verification of the payment, this is called from the payment gateway
  *
  * @return	bool	Whether the payment is valid
  */
 function verify_payment()
 {
     $this->registry->input->clean_array_gpc('p', array('pay_to_email' => vB_Cleaner::TYPE_STR, 'merchant_id' => vB_Cleaner::TYPE_STR, 'transaction_id' => vB_Cleaner::TYPE_STR, 'mb_transaction_id' => vB_Cleaner::TYPE_UINT, 'status' => vB_Cleaner::TYPE_STR, 'md5sig' => vB_Cleaner::TYPE_STR, 'amount' => vB_Cleaner::TYPE_STR, 'currency' => vB_Cleaner::TYPE_STR, 'mb_amount' => vB_Cleaner::TYPE_STR, 'mb_currency' => vB_Cleaner::TYPE_STR));
     if (!$this->test()) {
         $this->error = 'Payment processor not configured';
         return false;
     }
     $this->transaction_id = $this->registry->GPC['mb_transaction_id'];
     $check_hash = strtoupper(md5($this->registry->GPC['merchant_id'] . $this->registry->GPC['transaction_id'] . strtoupper(md5(strtolower($this->settings['mbsecret']))) . $this->registry->GPC['mb_amount'] . $this->registry->GPC['mb_currency'] . $this->registry->GPC['status']));
     if ($check_hash == $this->registry->GPC['md5sig'] and strtolower($this->registry->GPC['pay_to_email']) == strtolower($this->settings['mbemail'])) {
         if (intval($this->registry->GPC['status']) == 2) {
             $this->paymentinfo = vB::getDbAssertor()->getRow('vBForum:getPaymentinfo', array('hash' => $this->registry->GPC['item_number']));
             // lets check the values
             if (!empty($this->paymentinfo)) {
                 $sub = vB::getDbAssertor()->getRow('vBForum:subscription', array('subscriptionid' => $this->paymentinfo['subscriptionid']));
                 $cost = unserialize($sub['cost']);
                 $this->paymentinfo['currency'] = strtolower($this->registry->GPC['currency']);
                 $this->paymentinfo['amount'] = floatval($this->registry->GPC['amount']);
                 if (doubleval($this->registry->GPC['amount']) == doubleval($cost["{$this->paymentinfo[subscriptionsubid]}"]['cost'][strtolower($this->registry->GPC['currency'])])) {
                     $this->type = 1;
                     return true;
                 }
             }
         }
     }
     return false;
 }
Beispiel #20
0
 public function _doBill(Invoice $invoice, $doFirst, CcRecord $cc, Am_Paysystem_Result $result)
 {
     $user = $invoice->getUser();
     if ($cc->user_id != $user->pk()) {
         throw new Am_Exception_Paysystem("Assertion failed: cc.user_id != user.user_id");
     }
     // will be stored only if cc# or expiration changed
     $this->storeCreditCard($cc, $result);
     if (!$result->isSuccess()) {
         return;
     }
     $user->refresh();
     // we have both profile id and payment id, run the necessary transaction now if amount > 0
     $result->reset();
     if ($doFirst && doubleval($invoice->first_total) <= 0) {
         // free trial
         $tr = new Am_Paysystem_Transaction_Free($this);
         $tr->setInvoice($invoice);
         $tr->process();
         $result->setSuccess($tr);
     } else {
         $request = array($this->getConfig('key'), $this->getConfig('testing'), $user->data()->get(self::CUSTOMER_VAULT_ID), null, $this->getConfig('project'), '', '', '', $doFirst ? intval($invoice->first_total * 100) : intval($invoice->second_total * 100), $invoice->currency, $invoice->getLineDescription(), $invoice->getLineDescription(), $user->remote_addr ? $user->remote_addr : $_SERVER['REMOTE_ADDR']);
         $tr = new Am_Paysystem_Transaction_MicropaymentDbtSale($this, $invoice, $request, $doFirst);
         $tr->run($result);
     }
 }
Beispiel #21
0
 public function getSeries()
 {
     $times = tokenize_time($this->begin, $this->end, $this->mode, $this->step);
     $results = array();
     $categories = array();
     $CI =& get_instance();
     for ($i = 0; $i <= count($times) - 2; $i++) {
         $rows = $this->queryRows($times[$i], $times[$i + 1]);
         if (count($rows)) {
             $categories[] = $times[$i]->format('Y-m-d');
         }
         foreach ($rows as $row) {
             $item = $row[0];
             $method = 'report_label_' . $this->name;
             if (method_exists($CI, $method)) {
                 $item = $CI->{$method}($row[0]);
             }
             $value = doubleval($row[1]);
             $index = $this->getRowIndex($results, $item);
             if ($index === null) {
                 $results[] = array('name' => $item, 'data' => array($value));
             } else {
                 $results[$index]['data'][] = $value;
             }
         }
     }
     $this->xAxis->categories = $categories;
     $this->series = $results;
 }
 /**
  * @description 导入果乐乐数据到t_anti_products
  */
 public function import($file_name = 'result.txt')
 {
     $contents = file_get_contents($file_name);
     $lines = explode("\r\n", $contents);
     foreach ($lines as $line) {
         $values = explode('&&', $line);
         print_r($values);
         if (count($values) > 1) {
             $name = $values[0];
             $prod_id = $values[1];
             $price = doubleval($values[2]) * 100;
             $cates = $values[3];
             $prop = $values[4];
             if (preg_match('/\\d+/', $values[5], $matches)) {
                 $values[5] = $matches[0];
             }
             $total_price = $values[5] * 100;
             $url = $values[6];
         }
         $anti_product = array('site_id' => 22, 'prod_id' => $prod_id, 'price' => $price, 'cate' => $cates, 'name' => $name, 'prop' => $prop, 'total_price' => $total_price, 'created_time' => $this->input->server('REQUEST_TIME'), 'updated_time' => $this->input->server('REQUEST_TIME'));
         $history = $this->MAnti_products->get_one('*', array('site_id' => 22, 'prod_id' => $prod_id));
         if (empty($history)) {
             $this->MAnti_products->create($anti_product);
         } else {
             $this->MAnti_products->update_info(array('price' => $price, 'total_price' => $total_price), array('site_id' => 22, 'prod_id' => $prod_id));
         }
     }
 }
 function GetSQLValueString($theValue, $theType, $theDefinedValue = "", $theNotDefinedValue = "")
 {
     if (PHP_VERSION < 6) {
         $theValue = get_magic_quotes_gpc() ? stripslashes($theValue) : $theValue;
     }
     //$theValue = function_exists("mysqli_real_escape_string") ? mysqli_real_escape_string($conexion , $theValue) : mysqli_escape_string( $conexion , $theValue);
     if (function_exist) {
         $obj = new database();
         $link = $obj->connect();
         $theValue = mysqli_real_escape_string($link, $theValue);
     }
     switch ($theType) {
         case "text":
             $theValue = $theValue != "" ? "'" . $theValue . "'" : "NULL";
             break;
         case "long":
         case "int":
             $theValue = $theValue != "" ? intval($theValue) : "NULL";
             break;
         case "double":
             $theValue = $theValue != "" ? doubleval($theValue) : "NULL";
             break;
         case "date":
             $theValue = $theValue != "" ? "'" . $theValue . "'" : "NULL";
             break;
         case "defined":
             $theValue = $theValue != "" ? $theDefinedValue : $theNotDefinedValue;
             break;
     }
     return $theValue;
 }
 public function getSearchType()
 {
     $dataReceived = Input::get("data");
     $data_arr = $dataReceived['data'][0];
     $action = $data_arr['action'];
     $type = $data_arr['type'];
     $gender = $data_arr['gender'];
     $ageFrom = intval($data_arr['ageFrom']);
     $ageTo = intval($data_arr['ageTo']);
     $range = intval($data_arr['range']);
     $lati = doubleval($data_arr['lati']);
     $longi = doubleval($data_arr['longi']);
     $distance = new Compatability();
     $users = $users = DB::table('users')->orderBy($type, 'desc')->get();
     $result = array();
     $i = 0;
     foreach ($users as $user) {
         $newDistance = $distance->haversineGreatCircleDistance($lati, $longi, $user->latitude, $user->longitude);
         if ($newDistance <= $range && $user->age >= $ageFrom && $user->age <= $ageTo && $user->gender == $gender) {
             $geocodeFromLatLong = file_get_contents('http://maps.googleapis.com/maps/api/geocode/json?latlng=' . trim($user->latitude) . ',' . trim($user->longitude) . '&sensor=false');
             $output = json_decode($geocodeFromLatLong);
             $status = $output->status;
             $location = $status == "OK" ? $output->results[1]->formatted_address : '';
             $geocodeFromLatLong2 = file_get_contents('http://maps.googleapis.com/maps/api/geocode/json?latlng=' . trim($lati) . ',' . trim($longi) . '&sensor=false');
             $output2 = json_decode($geocodeFromLatLong);
             $status2 = $output->status;
             $location2 = $status == "OK" ? $output->results[1]->formatted_address : '';
             $result[$i] = array('username' => $user->username, 'age' => $user->age, 'firstName' => $user->firstName, 'lastName' => $user->lastName, 'photo' => $user->photo, 'locations' => $location, 'location2' => $location2, 'gender' => $gender, 'ageFrom' => $ageFrom, 'ageTo' => $ageTo, 'range' => $range, 'lati' => $lati, 'longi' => $longi, 'gendr' => $gender, 'distance' => $newDistance);
             $i++;
         }
     }
     // dd($result);
     return json_encode($result);
 }
function GetSQLValueString($theValue, $theType, $theDefinedValue = "", $theNotDefinedValue = "")
{
    $theValue = function_exists("mysql_real_escape_string") ? mysql_real_escape_string($theValue) : mysql_escape_string($theValue);
    switch ($theType) {
        case "text":
            $theValue = $theValue != "" ? "'" . $theValue . "'" : "NULL";
            break;
        case "long":
        case "int":
            $theValue = $theValue != "" ? intval($theValue) : "NULL";
            break;
        case "double":
            $theValue = $theValue != "" ? "'" . doubleval($theValue) . "'" : "NULL";
            break;
        case "date":
            $theValue = $theValue != "" ? "'" . date("Y-m-d", strtotime($theValue)) . "'" : "NULL";
            break;
        case "time":
            $theValue = $theValue != "" ? "'" . date("H:i:s", strtotime($theValue)) . "'" : "NULL";
            break;
        case "datetime":
            $theValue = $theValue != "" ? "'" . date("Y-m-d H:i:s", strtotime($theValue)) . "'" : "NULL";
            break;
        case "defined":
            $theValue = $theValue != "" ? $theDefinedValue : $theNotDefinedValue;
            break;
    }
    return $theValue;
}
Beispiel #26
0
 private function assertDouble($valor)
 {
     if (!is_null($valor) && strcmp(number_format(doubleval($valor), 2, '', ''), number_format($valor, 2, '', '')) !== 0) {
         throw new InvalidTypeException($valor, 'double');
     }
     return doubleval($valor);
 }
Beispiel #27
0
 public function getRealValue()
 {
     if (!$this->isValid()) {
         throw new BindingException('Not a valid Double value');
     }
     return doubleval($this->value);
 }
Beispiel #28
0
 /**
  * Perform verification of the payment, this is called from the payment gateway
  *
  * @return	bool	Whether the payment is valid
  */
 function verify_payment()
 {
     $this->registry->input->clean_array_gpc('r', array('callbackPW' => TYPE_STR, 'desc' => TYPE_STR, 'transStatus' => TYPE_STR, 'authMode' => TYPE_STR, 'cost' => TYPE_NUM, 'currency' => TYPE_STR, 'transId' => TYPE_STR));
     if (!$this->test()) {
         $this->error = 'Payment processor not configured';
         return false;
     }
     $this->transaction_id = $this->registry->GPC['transId'];
     if ($this->registry->GPC['callbackPW'] == $this->settings['worldpay_password']) {
         $this->paymentinfo = $this->registry->db->query_first("\n\t\t\t\tSELECT paymentinfo.*, user.username\n\t\t\t\tFROM " . TABLE_PREFIX . "paymentinfo AS paymentinfo\n\t\t\t\tINNER JOIN " . TABLE_PREFIX . "user AS user USING (userid)\n\t\t\t\tWHERE hash = '" . $this->registry->db->escape_string($this->registry->GPC['desc']) . "'\n\t\t\t");
         // lets check the values
         if (!empty($this->paymentinfo)) {
             $sub = $this->registry->db->query_first("SELECT * FROM " . TABLE_PREFIX . "subscription WHERE subscriptionid = " . $this->paymentinfo['subscriptionid']);
             $cost = unserialize($sub['cost']);
             $this->paymentinfo['currency'] = strtolower($this->registry->GPC['currency']);
             $this->paymentinfo['amount'] = floatval($this->registry->GPC['cost']);
             if ($this->registry->GPC['transStatus'] == 'Y' and ($this->registry->GPC['authMode'] == 'A' or $this->registry->GPC['authMode'] == 'O')) {
                 if (doubleval($this->registry->GPC['cost']) == doubleval($cost["{$this->paymentinfo[subscriptionsubid]}"]['cost'][strtolower($this->registry->GPC['currency'])])) {
                     $this->type = 1;
                 }
             }
             return true;
         }
     }
     return false;
 }
Beispiel #29
0
 function GetSQLValueString($theValue, $theType, $theDefinedValue = "", $theNotDefinedValue = "")
 {
     if (PHP_VERSION < 6) {
         $theValue = get_magic_quotes_gpc() ? stripslashes($theValue) : $theValue;
     }
     $theValue = function_exists("mysql_real_escape_string") ? mysql_real_escape_string($theValue) : mysql_escape_string($theValue);
     switch ($theType) {
         case "text":
             $theValue = $theValue != "" ? "'" . $theValue . "'" : "NULL";
             break;
         case "long":
         case "int":
             $theValue = $theValue != "" ? intval($theValue) : "NULL";
             break;
         case "double":
             $theValue = $theValue != "" ? doubleval($theValue) : "NULL";
             break;
         case "date":
             $theValue = $theValue != "" ? "'" . $theValue . "'" : "NULL";
             break;
         case "defined":
             $theValue = $theValue != "" ? $theDefinedValue : $theNotDefinedValue;
             break;
     }
     return $theValue;
 }
 /**
  * Returns all in all top up value
  */
 public function topUpAllTotal($actionType)
 {
     $command = Yii::app()->db->createCommand("select sum(topUpValue) from tbl_vici_log_action where = :action_type");
     $command->bindParam(":action_type", $actionType, PDO::PARAM_STR);
     $ret = $command->queryColumn();
     return doubleval($ret);
 }