版權(quán)說(shuō)明:本文檔由用戶提供并上傳,收益歸屬內(nèi)容提供方,若內(nèi)容存在侵權(quán),請(qǐng)進(jìn)行舉報(bào)或認(rèn)領(lǐng)
文檔簡(jiǎn)介
1、/* 獲得一個(gè) select* param unknown_type $dbNameOrArray數(shù)據(jù)庫(kù)名稱或一位數(shù)組* param unknown_type $namename 與id ,數(shù)據(jù)庫(kù)取值用字段* param unknown_type $value值* param unknown_type $choose當(dāng)前選中的值* param unknown_type $where數(shù)據(jù)庫(kù)條件* param unknown_type $attribute屬性* param unknown_type $isSelect是否有標(biāo)題選擇* param unknown_type $titleName標(biāo)題
2、名稱* return string返回*/public functiongetSelectByWhere($dbNameOrArray,$name,$value,$choose,$where=null,$attribute='',$isSelect=true,$titleName='請(qǐng)選擇')$selected.="<select$attribute$stylename='$name'id='$name'>"$isSelect?$selected.="<option value=
3、39; '>$titleName</option>":""if(is_array($dbNameOrArray)/foreach($dbNameOrArray as $key=>$val)/$selectTrue=($key=$choose &&$choose!='')?"selected=true":""$selected.="<option value='$key' $selectTrue >"$selecte
4、d.="$val"$selected.="</option>"/else$m=M($dbNameOrArray);$list=$m->where($where)->select();/foreach($list as $key=>$val)/$selectTrue=($val'id'=$choose)?"selected=true":""$selected.="<option value='$val"id"' $sel
5、ectTrue >"$selected.="$val$value"$selected.="</option>"/$selected.="</select>"return $selected;/* 獲取值* param unknown_type $dbName數(shù)據(jù)庫(kù)名* param unknown_type $name字段值名稱* param unknown_type $valuevalue(id)* return Ambigous <>*/public function getVal
6、ue($dbName,$name,$value)$m=M($dbName);$list=$m->find($value);return $list$name;/* session 管理函數(shù)* param string|array $name session 名稱如果為數(shù)組則表示進(jìn)行session 設(shè)置* param mixed $value session 值* return mixed*/function session($name='',$value='') $prefix=C('SESSION_PREFIX');if(is_array
7、($name) / session 初始化 在 session_start 之前調(diào)用if(isset($name'prefix') C('SESSION_PREFIX',$name'prefix');if(C('VAR_SESSION_ID') &&isset($_REQ('VAR_SESSION_ID')session_id($_REQ('VAR_SESSION_ID');elseif(isset($name'id') session_id($name'id
8、');if('common' != APP_MODE) / 其它模式可能不支持ini_set('session.auto_start', 0);if(isset($name'name')session_name($name'name');if(isset($name'path')session_save_path($name'path');if(isset($name'domain')ini_set('session.cookie_domain', $name
9、'domain');if(isset($name'expire')ini_set('session.gc_maxlifetime',$name'expire');if(isset($name'use_trans_sid')ini_set('session.use_trans_sid',$name'use_trans_sid'?1:0);if(isset($name'use_cookies')ini_set('session.use_cookies',$
10、name'use_cookies'?1:0);if(isset($name'cache_limiter')session_cache_limiter($name'cache_limiter');if(isset($name'cache_expire')session_cache_expire($name'cache_expire');if(isset($name'type')C('SESSION_TYPE',$name'type');if(C('SESSION
11、_TYPE') /session 驅(qū)動(dòng)$type=C('SESSION_TYPE');$class=strpos($type,'')? $type :'ThinkSessionDriver'. ucwords(strtolower($type);$hander =new $class();session_set_save_handler(array(&$hander,"open"),array(&$hander,""),array(&$hander,"")
12、,array(&$hander,"write"),array(&$hander,"destroy"),array(&$hander,"gc");/ 啟動(dòng) sessionif(C('SESSION_AUTO_START')session_start();elseif('' = $value)if(''=$name)/獲取全部的 sessionreturn $prefix ? $_SESSION$prefix : $_SESSION;elseif(0=strpos($
13、name,'') / session 操作if('pause'=$name) / 暫停 sessionsession_write_();elseif('start'=$name) / 啟動(dòng) sessionsession_start();elseif('destroy'=$name) / 銷毀 session$_SESSION =array();session_unset();session_destroy();elseif('regenerate'=$name) / 重新生成 idsession_regenerat
14、e_id();elseif(0=strpos($name,'?') / 檢查 session$name=substr($name,1);if(strpos($name,'.') / 支持?jǐn)?shù)組list($name1,$name2) =explode('.',$name);return$prefix?isset($_SESSION$prefix$name1$name2):isset($_SESSION$name1$name2);elsereturn$prefix?isset($_SESSION$prefix$name):isset($_SESSION
15、$name);elseif(is_null($name) / 清空 sessionif($prefix) unset($_SESSION$prefix);else$_SESSION = array();elseif($prefix) / 獲取 sessionif(strpos($name,'.')list($name1,$name2) =explode('.',$name);returnisset($_SESSION$prefix$name1$name2)?$_SESSION$prefix$name1$name2:null;elsereturnisset($_S
16、ESSION$prefix$name)?$_SESSION$prefix$name:null;elseif(strpos($name,'.')list($name1,$name2) =explode('.',$name);returnisset($_SESSION$name1$name2)?$_SESSION$name1$name2:null;elsereturnisset($_SESSION$name)?$_SESSION$name:null;elseif(is_null($value) / 刪除 sessionif($prefix)unset($_SESSI
17、ON$prefix$name);elseunset($_SESSION$name);else / 設(shè)置 sessionif($prefix)if (!isset($_SESSION$prefix) $_SESSION$prefix = array();$_SESSION$prefix$name=$value;else$_SESSION$name=$value;/組裝請(qǐng)求 xmlpublic function xmlCreate($phone,$getContent)$spid='22487966040003'/spid$serviceKey='69316940b2a24
18、fc1a4d4aa02a0ade331'/serviceKey$appId='01156129'/應(yīng)用 ID$appKey="918d761c9a57489083ba430ec4c7479b"/應(yīng)用 key$="02157862572"/ECP 號(hào)碼$type="0"$phone2=$phone; /接收號(hào)碼$functions="sendSms"/的,此不能修改,修改后會(huì)導(dǎo)致不能$content=$getContent; /內(nèi)容date_default_timezone_set('
19、Asia/Chongqing');/時(shí)間同步$now = getdate(time();$cur_wday=$now'wday'$date = date("Y-m-d H:i:s",time(); /獲得時(shí)間$timeStamp= str_replace(' ','',str_replace(':','',str_replace('-','',$date) ;/將時(shí)間去- 去空格去:$SiCode=$this->encrypt1($spid.$ser
20、viceKey,$serviceKey);/SiCode加密由 spid+ServiceKey 進(jìn)行 DES 加密而成,密鑰為 ServiceKey$appCode=$this->encrypt1($appId.$appKey,$appKey);/AppCode加密 由 appid+appkey 進(jìn)行 DES 加密而成,密鑰為 appkey$sign=md5($spid.$serviceKey.$appId.$appKey.$timeStamp); /簽名,spid+ServiceKey+appid+appkey+TimeStamp 進(jìn)行 MD5 加密而成。注:簽名的各個(gè)參數(shù)順序不能顛倒
21、$no=$this->create_guid();/UUID/xml 拼接$sendContent = "<?xml version='1.0'encoding='utf-8'?>"$sendContent.="<xml>"$sendContent.='<SiCode>'. $SiCode . '</SiCode>'$sendContent.='<AppCode>' . $appCode .'</
22、AppCode>'$sendContent.='<appID>' . $appId . '</appID>'$sendContent.='<TimeStamp>' . $timeStamp .'</TimeStamp>'$sendContent.='<sign>' . $sign . '</sign>'$sendContent.='<function>' . $functions .
23、39;</function>'$sendContent.='<RequestData>'$sendContent.='<>' . $.'</>'$sendContent.='<DestinationAddresses>' . $phone2 .'</DestinationAddresses>'$sendContent.='<Message>'.$content .'</Message>
24、39;$sendContent.='</RequestData>'$sendContent.='</xml>'return $sendContent.trim();/生成 UUIDfunction create_guid()$microTime = microtime();list($a_dec, $a_sec) = explode(" ", $microTime);$dec_hex = dechex($a_dec* 1000000);$sec_hex = dechex($a_sec);$this->ensure
25、_length($dec_hex, 5);$this->ensure_length($sec_hex, 6);$guid = ""$guid .= $dec_hex;$guid .=$this->create_guid_section(3);$guid .= '-'$guid .= $this->create_guid_section(4);$guid .= '-'$guid .=$this->create_guid_section(4);$guid .= '-'$guid .=$this->cr
26、eate_guid_section(4);$guid .= '-'$guid .= $sec_hex;$guid .=$this->create_guid_section(6);return $guid;function create_guid_section($characters)$return = ""for($i=0; $i<$characters; $i+)$return .= dechex(mt_rand(0,15);return $return;function ensure_length(&$string, $length
27、)$strlen = strlen($string);if($strlen < $length)$string = str_pad($string,$length,"0");else if($strlen > $length)$string = substr($string, 0, $length);/DES 加密str 為加密的明文, key 為加密的密鑰function encrypt1($str,$key) $iv='$r#e2W1Q'$size = mcrypt_get_block_size(MCRYPT_DES,MCRYPT_MODE_
28、CBC);$str =$this->pkcs5Pad($str, $size);$result= base64_encode(mcrypt_cbc(MCRYPT_DES,$key, $str, MCRYPT_ENCRYPT, $iv);return $result;/public function pkcs5Pad($text, $blocksize) /$pad = $blocksize - (strlen($text) % $blocksize);/return $text . str_repeat(chr($pad), $pad);/DES 加密str 為加密的明文, key 為加
29、密的密鑰public function encrypt($str) $key='jTanGEcP'$iv='$r#e2W1Q'$size = mcrypt_get_block_size(MCRYPT_DES,MCRYPT_MODE_CBC);$str = $this->pkcs5Pad($str, $size);$result= base64_encode(mcrypt_cbc(MCRYPT_DES,$key, $str, MCRYPT_ENCRYPT, $iv);return $result;function pkcs5Pad($text, $block
30、size) $pad = $blocksize - (strlen($text) % $blocksize);return $text . str_repeat(chr($pad), $pad);/外部調(diào)用接口public function sendMessageExternal()if(trim($_SERVER"REMOTE_ADDR")!='120.26.111.81')echo 'N'die;if(isset($_REQUEST'phone')$phone=$_REQUEST'phone'$messag
31、e=$_REQUEST'message'$this->sendMessage($phone,$message);echo 'Y'die;/發(fā)送public function sendMessage($phone,$message)$xml=$this->xmlCreate($phone,iconv('UTF-8','GB2312',$message);/生成 xml/echo "<p>請(qǐng)求參數(shù):</p>"/轉(zhuǎn)移<>否則 xml 輸出不$beforexml=$xml
32、;$beforexml = str_replace("<", "<", $beforexml);$beforexml = str_replace(">", ">", $beforexml);$beforexml = str_replace("n", "<br />", $beforexml);/echo $beforexml;$desxml=$this->encrypt($xml);/對(duì) xml 進(jìn)行加密$desxml
33、len=strlen($desxml);/加密后 xml 的長(zhǎng)度$wsdl ="" /地址$=new Soap($wsdl);$param = array("args0"=>$desxmllen,"args1"=>$desxml);/參數(shù)$str=$->extendService($param); /調(diào)用/ 獲取 SOAP 類型列表(Returns list of SOAP types )$arr=get_object_vars($str);/echo "<p>返回結(jié)果: </p>&
34、quot;/轉(zhuǎn)移<>否則 xml 輸出不foreach( $arr as $key=>$val)$val = str_replace("<", "<", $val);$val = str_replace(">", ">", $val);$val = str_replace("n", "<br />", $val);/echo $val;/支付public function weChatPay()$url=&
35、quot;".trim($this->oid)."&total_fee=1"$json=file_get_contents($url);return $json;/支付調(diào)用public function createSign()if($this->oid)$appid="wxb07a0043252ac3d2"$mch_id="1286770801"$device_info="1000"$body="test"$nonce_str = $this->random
36、Str(16);$stringA="appid=".$appid."&body=".$body."&device_info=".$device_info."&mch_id=".$mch_id."&nonce_str=".$nonce_str;$key="a10add3849ba56abbe56e056f20f883f"$stringSignTemp=$stringA."&key=".$key;$sign= strto
37、upper(MD5($stringSignTemp);$xml.="<xml>"$xml.="<appid>".$appid."</appid>"$xml.="<attach>支付測(cè)試</attach>"$xml.="<body>JSAPI 支付測(cè)試</body>"$xml.="<mch_id>".$mch_id."</mch_id>"$xml.=&
38、quot;<nonce_str>".$nonce_str."</nonce_str>"$xml.="<notify_url>gList</notify_url>"$xml.="<openid>".$this->oid."</openid>"$xml.="<out_trade_no>".time()."</out_trade_no>"$xml.="<s
39、pbill_create_ip>".$_SERVER"REMOTE_ADDR"."</spbill_create_ip>"$xml.="<total_fee>1</total_fee>"$xml.="<trade_type>JSAPI</trade_type>"$xml.="<sign>".$sign."</sign>"$xml.="</xml>"
40、;$d= $this->postXmlCurl($xml,'');echo $d;die;/生成隨機(jī)字符串public function randomStr($number)$arr=array('1','2','3','4','5','6','7','8','9','0','a','b','c','d','e','f'
41、,'g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z','A','B','C','D','E'
42、,'F','G','H','I','J','K','L','M','N','O','P','Q','R','S','T','U','V','W','X','Y','Z');$str=""for ($i=1;$i<=$number;$i+)
43、$randStr=rand(0,61);$str.=$arr$randStr;return $str;/* 以 post 方式提交 xml 到對(duì)應(yīng)的接口 url* param string $xml需要 post 的 xml 數(shù)據(jù)* param string $urlurl* param bool $useCert 是否需要,默認(rèn)不需要* param int $secondurl 執(zhí)行超時(shí)時(shí)間,默認(rèn) 30s* throws WxPayException*/privatefunction postXmlCurl($xml, $url, $useCert = false,$second = 30)
44、$ch = curl_init();/設(shè)置超時(shí)curl_setopt($ch, CURLOPT_TIMEOUT, $second);curl_setopt($ch,CURLOPT_URL, $url);curl_setopt($ch,CURLOPT_SSL_VERIFYPEER,TRUE);curl_setopt($ch,CURLOPT_SSL_VERIFYHOST,2);/嚴(yán)格校驗(yàn)/設(shè)置 headercurl_setopt($ch, CURLOPT_HEADER, FALSE);/要求結(jié)果為字符串且輸出到屏幕上curl_setopt($ch, CURLOPT_RETURNTRANSFER,
45、TRUE);/post 提交方式curl_setopt($ch, CURLOPT_POST, TRUE);curl_setopt($ch, CURLOPT_POSTFIELDS, $xml);/運(yùn)行 curl$data = curl_exec($ch);/返回結(jié)果if($data)curl_($ch);return $data; else $error = curl_errno($ch);curl_($ch);return "錯(cuò)誤"public function shjList()/機(jī)查看列表/機(jī)$where'equipmentType'='1
46、9;/搜索條件$_REQUEST'devicesId'?$where'equipment.devicesId'=trim($_REQUEST'devicesId'):""$_REQUEST'equipmentName'?$where'equipmentName'=array('like','%'.trim( $_REQUEST'equipmentName').'%'):""$where'status
47、9;=$_REQUEST'status'?$_REQUEST'status':'1'if($_REQUEST'network'='0')/$where'network'=array('lt','0','or');/$where'network'=array('exp','is null');$where'network' = array(array('lt','0&
48、#39;),array('exp','is null'), 'or') ;elseif($_REQUEST'network'='1')$where'network'=array('egt','0');if ($_SESSION'user''groups'!='1')/如果不是超級(jí)管理員$did=explode(',', $_SESSION'user''did');$wher
49、e'equipment.id'=array('in',$did);$_REQUEST'holderId'?$where'holderId'=$_REQUEST'holderId':''/print_r($where);$equipmentList=$this->equipmentM->getListPageByWhere($where,true,'work desc');/echo $this->equipmentM->getLastSql();/商戶選擇$s
50、hList=$this->adminM->where(array('groups'=>'4')->select();$this->assign('shList',$shList);if(isset($_REQUEST'startTime')$startTime=strtotime($_REQUEST'startTime'.' 00:00:00');$endTime=strtotime($_REQUEST'endTime'.' 23:59:59
51、39;);else/默認(rèn)當(dāng)天時(shí)間戳$startTime=strtotime(date('Y-m-d',time().' 00:00:00');$endTime=strtotime(date('Y-m-d',time().' 23:59:59');/得到所有應(yīng)該顯示的$eqlist=$this->equipmentM->field('equipment.*')->join('devicestate ondevicestate.devicesId=equipment.devicesId'
52、;)->where($where)->select();/echo $this->equipmentM->getLastSql();foreach ($eqlist as $eq)$eqarr=$eq'devicesId'/print_r($eqarr);$totalhaving'dealState'='3'$totalhaving'goodsChange'=array('$ne' => '0');$totalhaving'nowTime'=array('$gt' =>$startTime.'','$lt'=>
溫馨提示
- 1. 本站所有資源如無(wú)特殊說(shuō)明,都需要本地電腦安裝OFFICE2007和PDF閱讀器。圖紙軟件為CAD,CAXA,PROE,UG,SolidWorks等.壓縮文件請(qǐng)下載最新的WinRAR軟件解壓。
- 2. 本站的文檔不包含任何第三方提供的附件圖紙等,如果需要附件,請(qǐng)聯(lián)系上傳者。文件的所有權(quán)益歸上傳用戶所有。
- 3. 本站RAR壓縮包中若帶圖紙,網(wǎng)頁(yè)內(nèi)容里面會(huì)有圖紙預(yù)覽,若沒(méi)有圖紙預(yù)覽就沒(méi)有圖紙。
- 4. 未經(jīng)權(quán)益所有人同意不得將文件中的內(nèi)容挪作商業(yè)或盈利用途。
- 5. 人人文庫(kù)網(wǎng)僅提供信息存儲(chǔ)空間,僅對(duì)用戶上傳內(nèi)容的表現(xiàn)方式做保護(hù)處理,對(duì)用戶上傳分享的文檔內(nèi)容本身不做任何修改或編輯,并不能對(duì)任何下載內(nèi)容負(fù)責(zé)。
- 6. 下載文件中如有侵權(quán)或不適當(dāng)內(nèi)容,請(qǐng)與我們聯(lián)系,我們立即糾正。
- 7. 本站不保證下載資源的準(zhǔn)確性、安全性和完整性, 同時(shí)也不承擔(dān)用戶因使用這些下載資源對(duì)自己和他人造成任何形式的傷害或損失。
最新文檔
- 綜合消費(fèi)受托支付合同(2篇)
- 銀行貸款進(jìn)貨合同(2篇)
- 2024-2025學(xué)年初中同步測(cè)控優(yōu)化設(shè)計(jì)物理八年級(jí)下冊(cè)配人教版第11章 第4節(jié) 機(jī)械能及其轉(zhuǎn)化含答案
- 荷花 作文 課件
- 西京學(xué)院《中國(guó)文化經(jīng)典選讀》2022-2023學(xué)年第一學(xué)期期末試卷
- 西京學(xué)院《土木工程施工技術(shù)與組織》2022-2023學(xué)年第一學(xué)期期末試卷
- 西京學(xué)院《建筑工程計(jì)量與計(jì)價(jià)》2022-2023學(xué)年第一學(xué)期期末試卷
- 西京學(xué)院《非線性編輯》2022-2023學(xué)年第一學(xué)期期末試卷
- 西京學(xué)院《大數(shù)據(jù)存儲(chǔ)與管理技術(shù)》2023-2024學(xué)年期末試卷
- 西華師范大學(xué)《學(xué)科課程標(biāo)準(zhǔn)與教材研究》2021-2022學(xué)年第一學(xué)期期末試卷
- 歷史與當(dāng)代珠寶設(shè)計(jì)風(fēng)格的傳承與演變
- 小學(xué)作業(yè)設(shè)計(jì)比賽評(píng)分標(biāo)準(zhǔn)
- 2024年電商直播行業(yè)現(xiàn)狀及發(fā)展趨勢(shì)研究
- 2021年4月自考04735數(shù)據(jù)庫(kù)系統(tǒng)原理試題及答案含解析
- 農(nóng)貿(mào)市場(chǎng)食品安全事故處置方案
- 單元三 注塑模具的使用(任務(wù)3 注塑模具的安裝)
- 六年級(jí)語(yǔ)文總復(fù)習(xí)課《修改病句》修改課件市公開(kāi)課一等獎(jiǎng)省賽課獲獎(jiǎng)?wù)n件
- 承德永輝礦業(yè)集團(tuán)有限公司紅山咀鐵礦礦山地質(zhì)環(huán)境保護(hù)與土地復(fù)墾方案
- 餐廳食品安全保障
- 藥品經(jīng)營(yíng)與管理大學(xué)生職業(yè)規(guī)劃
- 抽屜原理上課課件
評(píng)論
0/150
提交評(píng)論