public static function check_money($id,$money) { $where=array(); $where['id']=$id; $orders=orders::getInstance()->getrow($where); $archive=archive::getInstance()->getrow($orders['aid']); $prices = getPrices($archive['attr2']); $archive['attr2'] = $prices['price']; $where=array(); $where['pay_code']=$_GET['code']; $pay=pay::getInstance()->getrows($where); $logisticsid = substr($_GET['subject'],15,1); $where=array(); $where['id'] = $logisticsid; $logistics=logistics::getInstance()->getrows($where); if($logistics[0]['cashondelivery']) { $logistics[0]['price'] = 0.00; }else { if($logistics[0]['insure']) { $logistics[0]['price'] = $logistics[0]['price'] +($archive['attr2'] * $orders['pnums'])*($logistics[0]['insureproportion']/100); } } $pay[0]['pay_fee'] = $pay[0]['pay_fee']/100; $total = $archive['attr2'] * $orders['pnums'] +$logistics[0]['price'] +($archive['attr2'] * $orders['pnums'] * $pay[0]['pay_fee']); $amount = $total; if($money == $amount) { return true; }else { return false; } }
function getStation($id) { global $db; $o = mysqli_fetch_assoc(mysqli_query($db, "SELECT * FROM `it_stations` WHERE `id` Like \"{$id}\" ")); $o["prices"] = getPrices($id); return $o; }
<?php require_once $_SERVER['DOCUMENT_ROOT'] . 'cloud/models/main/index.php'; ini_set('display_errors', 1); error_reporting(E_ALL); session_start(); $_SESSION['count'] = 1; $resp = getPrices(); echo json_encode($resp); //prop function getPrices() { $data = array(); $rData = array(); //$startDate = "2012-01-01"; $theDate = date('Y-m-d'); //echo($theDate); //echo("http://www.quandl.com/api/v1/datasets/BITCOIN/BITSTAMPUSD?auth_token=6sQU_EYPwHRMkJsReFG9"); $info = file_get_contents("https://www.bitstamp.net/api/ticker/"); $tInfo = json_decode($info, true); $data = $tInfo; $high = floatval($data['high']); $low = floatval($data['low']); $volume = floatval($data['volume']); $ask = floatval($data['ask']); $bid = floatval($data['bid']); $current = floatval($data['last']); dbQuery("INSERT INTO minuteCoin ( high, low, volume, ask, bid, current, tDate) VALUES ({$high}, {$low}, {$volume}, {$ask}, {$bid}, {$current}, '{$theDate}')"); echo "INSERT INTO minuteCoin ( high, low, volume, ask, bid, current, tDate) VALUES ({$high}, {$low}, {$volume}, {$ask}, {$bid}, {$current}, '{$theDate}')"; $cex = file_get_contents("https://cex.io/api/ticker/BTC/USD"); $tInfo1 = json_decode($cex, true);
function archive($catid='0',$typeid='0',$spid=0,$area='0,0,0',$length=20,$ordertype='aid',$limit=10,$image=false,$attr1=null,$son=true,$wheretype='',$tpl=null,$intro_len='0',$istop=0) { $_ordertype=$ordertype; $cache_id=md5($catid.$typeid.$spid.$area.$length.$ordertype.$limit.$son.$wheretype.$tpl.$intro_len.$istop); if ($ordertype == 'rand()') $cache_id=$cache_id.time(); if (cache::get($cache_id)) $archives=cache::get($cache_id); else { $ordertype=str_replace('-',' ',$ordertype); $wheretype=str_replace('-',' ',$wheretype); $order = 'listorder=0,listorder ASC '; if (preg_match('/^\w+$/',$ordertype)) $order .= ','.$ordertype.' desc'; elseif ($ordertype) $order .= ','.$ordertype; $where=array(); if ($wheretype) foreach (explode(',',$wheretype) as $_wheretype) switch ($_wheretype) { case 'day': $where[]='adddate>'.date('Y-m-d H:i:s',time() -3600 * 24); break; case 'week': $where[]='adddate>'.date('Y-m-d H:i:s',time() -3600 * 24 * 7); break; case 'month': $where[]='adddate>'.date('Y-m-d H:i:s',time() -3600 * 24 * 30); break; default: if (preg_match('/commend=(\d+)/i',$_wheretype,$match)) $where[]=" attr1 REGEXP '(^|,)$match[1](,|$)' "; else if (preg_match('/^\w+$/',$_wheretype)) $where[]=$_wheretype."<>''"; else $where[]=$_wheretype; break; } if (!empty($where)) $where=' and '.implode(' and ',$where); else $where=''; $archive=archive::getInstance(); $category=category::getInstance(); $categories=array(); if (isset($catid) &&$catid != '0') { $catid=explode('-',$catid); //var_dump($catid); $categories=$catid; $_categories1=array(); if ($son) { foreach ($categories as $key=>$val) { $_categories[$key]=$category->sons($val); $_categories1=array_merge($_categories[$key],$_categories1); } //var_dump($_categories); } //var_dump($categories); $categories=array_merge($categories,$_categories1); //var_dump($categories); } //var_dump($categories); $type=type::getInstance(); $types=array(); if (isset($typeid) &&$typeid != '0') { $types[]=$typeid; if ($son) { $_types=$type->sons($typeid); } $types=array_merge($types,$_types); } $where='1'; if (!empty($types)) $where.=' and typeid in ('.implode(',',$types).')'; if (!empty($categories)) $where.=' and catid in ('.implode(',',$categories).')'; if ($spid) $where.=' and spid='.$spid; list($province_id,$city_id,$section_id)=explode(',',$area); if ($province_id) $where.=' and province_id='.$province_id; if ($city_id) $where.=' and city_id='.$city_id; if ($section_id) $where.=' and section_id='.$section_id; if ($image) $where.=' and thumb <> "" '; if ($attr1) $where.=" and FIND_IN_SET('$attr1',attr1) "; if ($_ordertype == 'aid-asc') { $order .=',aid asc'; } if ($_ordertype == 'new') { $order .= ',adddate desc'; } if($istop){ $tops = $archive->getrows($where." AND checked=1 AND state=1 AND toppost!=0",0,'toppost DESC,listorder=0,listorder ASC,aid DESC'); } $archives = $archive->getrows($where.' AND state=1 AND checked=1',$limit-count($tops),$order,$archive->getcols('list')); if(is_array($tops) && !empty($tops)){ foreach($tops as $order => $arc){ if($arc['toppost'] == 3){ $tops[$order]['title'] = "[全站置顶]".$arc['title']; } if($arc['toppost'] == 2){ $subcatids = $category->sons($arc['catid']); if($arc['catid'] != $catid[0] && !in_array($catid[0], $subcatids)){ unset($tops[$order]); }else{ $tops[$order]['title'] = "[栏目置顶]".$arc['title']; } } } $archives = array_merge($tops , $archives); } foreach ($archives as $order=>$arc) { if (!$arc['introduce']) $arc['introduce']=cut($arc['content'],$arc['introduce_len'] ?$arc['introduce_len'] : 200); $archives[$order]['url']=$arc['linkto'] ?$arc['linkto'] : archive::url($arc); $archives[$order]['catname']=category::name($arc['catid']); $archives[$order]['caturl']=category::url($arc['catid']); $archives[$order]['image']=@strstr($arc['image'],"http://") ?$arc['image'] : config::get('base_url').'/'.$arc['image']; $archives[$order]['adddate']=sdate($arc['adddate']); $archives[$order]['stitle']=strip_tags($arc['title']); $archives[$order]['title']=tool::cn_substr($arc['title'],$length); $archives[$order]['strgrade'] = archive::getgrade($arc['grade']); $archives[$order]['buyurl']=url('archive/orders/aid/'.$arc['aid']); $prices = getPrices($arc['attr2']); $archives[$order]['oldprice'] = $prices['oldprice']; $archives[$order]['attr2'] = $prices['price']; if(!$intro_len){ $archives[$order]['intro'] = ''; }else if($intro_len == '-1'){ $archives[$order]['intro'] = $arc['introduce']; }else{ $archives[$order]['intro'] = cut($arc['introduce'],$intro_len); } if(strtolower(substr($arc['thumb'],0,7)) == 'http://'){ $archives[$order]['sthumb'] = $arc['thumb']; }else{ $archives[$order]['sthumb'] = config::get('base_url').'/'.$arc['thumb']; } if($arc['strong']){ $archives[$order]['title'] = '<strong>'.$archives[$order]['title'].'</strong>'; } if($arc['color'] !="#000000"){ $archives[$order]['title'] = '<font style="color:'.$arc['color'].';">'.$archives[$order]['title'].'</font>'; } cb_data($archives[$order]); /*if($arc['toppost'] == '3'){ $tmp[] = $archives[$order]; unset($archives[$order]); } if($arc['toppost'] == '2' && front::get('catid') == $arc['catid']) { $tmp2[] = $archives[$order]; unset($articles[$order]); }*/ /*foreach ($archives[$order] as $key => $value){ if(!preg_match('/^my/',$key) || !$value) continue; $category = category::getInstance(); $sonids = $category->sons(setting::$var['archive'][$key]['catid']); if(setting::$var['archive'][$key]['catid'] != $archive['catid'] && !in_array($archive['catid'],$sonids) && (setting::$var['archive'][$key]['catid'])){ unset($field[$key]); continue; $archives[$order][$key] = $value; } }*/ } /*if(is_array($tmp)){ $archives = array_merge($tmp,$archives); }*/ if ($ordertype != 'rand()') cache::set($cache_id,$archives); } //run::_start(); if ($tpl) { front::$view->_var->articles=$archives; return template($tpl); } else return $archives; }
} //2. wurde löschen geklickt? $res = getPrices($unterkunft_id, $link); while ($d = mysqli_fetch_array($res)) { $preis_id = $d["PK_ID"]; if (isset($_POST["loeschen_" . $preis_id])) { deletePreis($preis_id); $nachricht = "Der Preis wurde erfolgreich gelöscht."; $nachricht = getUebersetzung($nachricht, $sprache, $link); include_once "./preis.php"; exit; } } //3. aendern der attribute: if (isset($_POST["aendern"])) { $res = getPrices($unterkunft_id, $link); //gehe alle preise durch ob sie evt. verändert wurden: while ($d = mysqli_fetch_array($res)) { $preis_id = $d["PK_ID"]; if (!isset($_POST["preis_" . $preis_id]) || empty($_POST["preis_" . $preis_id])) { $fehler = true; $nachricht = "Der Preis muss eingegeben werden."; $nachricht = getUebersetzung($nachricht, $sprache, $link); include_once "./preis.php"; exit; } $preis = $_POST["preis_" . $preis_id]; $preis = str_replace(",", ".", $preis); //prüfe ob preis ein float oder integer: if (!is_numeric($preis)) { $fehler = true;
function orders_action() { $this->view->aid = trim(front::get('aid')); if (front::post('submit')) { $this->orders = new orders(); $row = $this->orders->getrow("","adddate DESC"); //var_dump(time()); if($row['adddate'] && time() - $row['adddate'] <= intval(config::get('order_time'))){ alerterror('操作频繁,请稍后再试'); return; } if (front::$post['telphone'] == '') { alerterror('联系电话为必填!'); return; } front::$post['mid'] = $this->view->user['userid'] ? $this->view->user['userid'] : 0; front::$post['adddate'] = time(); front::$post['ip'] = front::ip(); if (isset(front::$post['aid'])) { $aidarr = front::$post['aid']; unset(front::$post['aid']); foreach ($aidarr as $val) { front::$post['aid'].=$val . ','; front::$post['pnums'].=front::$post['thisnum'][$val] . ','; } } else { front::$post['aid'] = $this->view->aid; } if (!isset(front::$post['logisticsid'])) front::$post['logisticsid'] = 0; front::$post['oid'] = date('YmdHis') . '-' . front::$post['logisticsid'] . '-' . front::$post['mid'] . '-' . front::$post['payname']; $insert = $this->orders->rec_insert(front::$post); if ($insert < 1) { front::flash($this->tname . lang('添加失败!')); } else { if (config::get('sms_on') && config::get('sms_order_on')) { sendMsg(front::$post['telphone'], config::get('sms_order')); } if (config::get('sms_on') && config::get('sms_order_admin_on') && $mobile = config::get('site_mobile')) { sendMsg($mobile, '网站在' . date('Y-m-d H:i:s') . '有新订单了'); //echo 11; } $user = $this->view->user; if(config::get('email_order_send_cust') && $user['e_mail']){ $title = "您在".config::get('sitename')."的订单".front::get('oid')."已提交"; $this->sendmail($user['e_mail'], $title, $title); } if(config::get('email_order_send_admin') && config::get('email')){ $title = '网站在' . date('Y-m-d H:i:s') . '有新订单了'; $this->sendmail(config::get('email'), $title, $title); } if (front::$post['payname'] && front::$post['payname'] != 'nopay') { echo '<script type="text/javascript">alert("' . lang('orderssuccess') . ' ' . lang('现在转入支付页面') . '");window.location.href="' . url('archive/payorders/oid/' . front::$post['oid'], true) . '";</script>'; } echo '<script type="text/javascript">alert("' . lang('orderssuccess') . '");window.location.href="' . url('archive/orders/oid/' . front::$post['oid'], true) . '";</script>'; } } elseif (front::get('oid')) { preg_match_all("/-(.*)-(.*)-(.*)/isu", front::get('oid'), $oidout); $this->view->paytype = $oidout[3][0]; if($oidout[2][0] != $this->view->user['userid']){ alertinfo('查看订单失败', url::create('index/index')); } $where = array(); $where['oid'] = front::get('oid'); $this->view->orders = orders::getInstance()->getrow($where); $this->view->statusnum = $data['status'] = $this->view->orders['status']; switch ($data['status']) { case 1: $data['status'] = lang('完成'); break; case 2: $data['status'] = lang('处理中'); break; case 3: $data['status'] = lang('已发货'); break; case 4: $data['status'] = lang('客户已付款,待审核'); break; case 5: $data['status'] = lang('已核实客户支付'); break; default: $data['status'] = lang('新订单'); break; } $this->view->orders['status'] = $data['status']; if ($this->view->paytype) { $this->view->gotopaygateway = '<a href="' . url('archive/payorders/oid/' . front::get('oid'), true) . '">进入支付页面</a>'; } //var_dump($this->view->user);var_dump($_SESSION);exit(); $this->out('message/orderssuccess.html'); } elseif (front::get('aid')) { $this->view->archive = archive::getInstance()->getrow(front::get('aid')); $this->view->categorys = category::getpositionlink2($this->view->archive['catid']); $this->view->paylist = pay::getInstance()->getrows('', 50); $this->view->logisticslist = logistics::getInstance()->getrows('', 50); $prices = getPrices($this->view->archive['attr2']); $this->view->archive['attr2'] = $prices['price']; if (!is_array($this->view->archive)) $this->out('message/error.html'); if ($this->view->archive['checked'] < 1) exit(lang('未审核!')); if (!rank::arcget(front::get('aid'), $this->view->usergroupid)) { $this->out('message/error.html'); } } else { $oreders_c = cookie::get('ce_orders_cookie'); if(preg_match('/union/i', $oreders_c)){ alerterror("非法字符"); } $oreders_c = stripslashes(htmlspecialchars_decode($oreders_c)); $aid = !empty($oreders_c) ? unserialize($oreders_c) : 0; if ($aid) { foreach ($aid as $key => $val) { $archive = archive::getInstance()->getrow(intval($val['aid'])); $val['title'] = $archive['title']; $prices = getPrices($archive['attr2']); $val['attr2'] = $prices['price']; $aid[$key] = $val; } $this->view->orderaidlist = $aid; $this->view->paylist = pay::getInstance()->getrows('', 50); $this->view->logisticslist = logistics::getInstance()->getrows('', 50); } else { if (isset(front::$get['oid'])) { //echo '<script type="text/javascript">alert("' . lang('请输入订单编号!') . '");'; if ($_SERVER['HTTP_REFERER']) { front::refresh($_SERVER['HTTP_REFERER']); //echo 'window.location.href="' . $_SERVER['HTTP_REFERER'] . '";'; } else { front::refresh(url('index')); //echo 'window.location.href="' . url('index') . '";'; } //echo '</script>'; exit; } echo '<script type="text/javascript">alert("' . lang('购物车暂无商品!') . '");'; if ($_SERVER['HTTP_REFERER']) { //front::refresh($_SERVER['HTTP_REFERER']); echo 'window.location.href="' . $_SERVER['HTTP_REFERER'] . '";'; } else { //front::refresh(url('index')); echo 'window.location.href="' . url('index') . '";'; } echo '</script>'; } } }
$foursquare_data .= '&section=drinks'; $foursquare_data .= '&sortByDistance=1'; $foursquare_data .= '&openNow=1'; $foursquare_data .= '&client_id=WTOCBAXWSLCPNIR4RIEPMGSKAGOF2YFWPE5W2GBLWKO5NRNJ&client_secret=K3S4LHTYSIR1YWWSGRFZ0A5DIST5H1C3XM55IVXBLEVTDR0O'; $foursquare_data .= '&v=20140806&m=foursquare'; $foursquare_results = fourSquareAPI($foursquare_url, $foursquare_data); $return_data = $foursquare_results->response->groups[0]; $check_items = array_reverse($return_data->items); $encoded_data = json_encode($return_data); $keep_checking = true; for ($i = 0; $i < count($check_items); $i++) { $venue = $check_items[$i]->venue; $venueLat = $venue->location->lat; $venueLon = $venue->location->lng; if ($keep_checking) { $price_to_venue = getPrices($user_longitude, $user_latitude, $venueLon, $venueLat); if (intval($price_to_venue->prices[0]->high_estimate) > intval($max_price)) { } else { $keep_checking = false; } } else { $final_items[] = $check_items[$i]; } } $final_items = array_reverse($final_items); print_r(json_encode($final_items)); return; } else { $foursquare_url = 'https://api.foursquare.com/v2/venues/search'; $foursquare_data = '?ll=' . $user_latitude . ',' . $user_longitude; $foursquare_data .= '&radius=10000';
<?php require_once $_SERVER['DOCUMENT_ROOT'] . 'cloud/models/main/index.php'; ini_set('display_errors', 1); error_reporting(E_ALL); session_start(); $_SESSION['count'] = 1; $store = false; if (!isset($_REQUEST['days'])) { $store = true; $days = 1; } else { $days = intval($_REQUEST['days']); } $resp = getPrices($days, $store); echo json_encode($resp); //prop function getPrices($limit = 1, $store) { $data = array(); $rData = array(); //$startDate = "2012-01-01"; for ($i = 0; $i < $limit; $i++) { $theDate = date('Y-m-d'); //echo($theDate); //echo("http://www.quandl.com/api/v1/datasets/BITCOIN/BITSTAMPUSD?auth_token=6sQU_EYPwHRMkJsReFG9"); $info = file_get_contents("http://www.quandl.com/api/v1/datasets/BITCOIN/BITSTAMPUSD?auth_token=6sQU_EYPwHRMkJsReFG9"); $tInfo = json_decode($info, true); $data = $tInfo['data'][0]; $open = floatval($data[1]); $high = floatval($data[2]);
<?php require_once $_SERVER['DOCUMENT_ROOT'] . 'cloud/models/main/index.php'; ini_set('display_errors', 1); error_reporting(E_ALL); session_start(); $_SESSION['count'] = 1; $resp = getPrices(365); echo json_encode($resp); //prop function getPrices($limit = 2) { $startDate = "2012-01-01"; for ($i = 0; $i < $limit; $i++) { $theDate = date('Y-m-d', strtotime($startDate . ' + ' . $i . ' days')); echo $theDate; echo "time = http://www.quandl.com/api/v1/datasets/BITCOIN/BITSTAMPUSD?&trim_start=" . $theDate . "&trim_end=" . $theDate . "&auth_token=6sQU_EYPwHRMkJsReFG9"; $info = file_get_contents("http://www.quandl.com/api/v1/datasets/BITCOIN/BITSTAMPUSD?&trim_start=" . $theDate . "&trim_end=" . $theDate . "&auth_token=6sQU_EYPwHRMkJsReFG9"); $tInfo = json_decode($info, true); $data = $tInfo['data'][0]; $open = floatval($data[1]); $high = floatval($data[2]); $low = floatval($data[3]); $close = floatval($data[4]); $volume = floatval($data[5]); $volumeC = floatval($data[6]); $weightedPrice = floatval($data[7]); $avg = floatval(($high + $low) / 2); dbQuery("INSERT INTO btcHistory (open, high, low, close, volume, volumeUSD, weightedPrice, avg, tDate) VALUES ({$open}, {$high}, {$low}, {$close}, {$volume}, {$volumeC}, {$weightedPrice}, {$avg}, '{$theDate}')"); echo "INSERT INTO btcHistory (open, high, low, close, volume, volumeUSD, weightedPrice, avg, tDate) VALUES ({$open}, {$high}, {$low}, {$close}, {$volume}, {$volumeC}, {$weightedPrice}, {$avg}, '{$theDate}')"; }
<?php include 'functions.php'; $totalPrice = !empty($_POST['total_price']) ? (int) $_POST['total_price'] : 0; if (!$totalPrice) { return; } $taxes = array('vat_tax' => 0.2, 'resort_tax' => 0.01); $allPrices = getPrices($totalPrice, $taxes); // ajax if (!empty($_POST['is_ajax'])) { echo json_encode($allPrices); exit; }
function getTodayPrices() { //$todayDate = date("Y").date("m").date("d"); //today getPrices(date("Y"), date("m"), date("d")); }