一、微力後臺上傳圖片有運營反饋無端被刪除的問題[生產線多臺服務器,圖片的上傳和刪除]php
cd /data/logs/weili_sz/app/ cat api_20190111.log |grep image/delete|grep 圖片名稱
二、微信JSSDK接入示例利用PHP文件作緩存html
<?php class JSSDK { private $appId; private $appSecret; public function __construct($appId, $appSecret) { $this->appId = $appId; $this->appSecret = $appSecret; } public function getSignPackage() { $jsapiTicket = $this->getJsApiTicket(); // 注意 URL 必定要動態獲取,不能 hardcode. $protocol = (!empty($_SERVER['HTTPS']) && $_SERVER['HTTPS'] !== 'off' || $_SERVER['SERVER_PORT'] == 443) ? "https://" : "http://"; $url = "$protocol$_SERVER[HTTP_HOST]$_SERVER[REQUEST_URI]"; $timestamp = time(); $nonceStr = $this->createNonceStr(); // 這裏參數的順序要按照 key 值 ASCII 碼升序排序 $string = "jsapi_ticket=$jsapiTicket&noncestr=$nonceStr×tamp=$timestamp&url=$url"; $signature = sha1($string); $signPackage = array( "appId" => $this->appId, "nonceStr" => $nonceStr, "timestamp" => $timestamp, "url" => $url, "signature" => $signature, "rawString" => $string ); return $signPackage; } private function createNonceStr($length = 16) { $chars = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789"; $str = ""; for ($i = 0; $i < $length; $i++) { $str .= substr($chars, mt_rand(0, strlen($chars) - 1), 1); } return $str; } private function getJsApiTicket() { // jsapi_ticket 應該全局存儲與更新,如下代碼以寫入到文件中作示例 $data = json_decode($this->get_php_file("jsapi_ticket.php")); if ($data->expire_time < time()) { $accessToken = $this->getAccessToken(); // 若是是企業號用如下 URL 獲取 ticket // $url = "https://qyapi.weixin.qq.com/cgi-bin/get_jsapi_ticket?access_token=$accessToken"; $url = "https://api.weixin.qq.com/cgi-bin/ticket/getticket?type=jsapi&access_token=$accessToken"; $res = json_decode($this->httpGet($url)); $ticket = $res->ticket; if ($ticket) { $data->expire_time = time() + 7000; $data->jsapi_ticket = $ticket; $this->set_php_file("jsapi_ticket.php", json_encode($data)); } } else { $ticket = $data->jsapi_ticket; } return $ticket; } private function getAccessToken() { // access_token 應該全局存儲與更新,如下代碼以寫入到文件中作示例 $data = json_decode($this->get_php_file("access_token.php")); if ($data->expire_time < time()) { // 若是是企業號用如下URL獲取access_token // $url = "https://qyapi.weixin.qq.com/cgi-bin/gettoken?corpid=$this->appId&corpsecret=$this->appSecret"; $url = "https://api.weixin.qq.com/cgi-bin/token?grant_type=client_credential&appid=$this->appId&secret=$this->appSecret"; $res = json_decode($this->httpGet($url)); $access_token = $res->access_token; if ($access_token) { $data->expire_time = time() + 7000; $data->access_token = $access_token; $this->set_php_file("access_token.php", json_encode($data)); } } else { $access_token = $data->access_token; } return $access_token; } private function httpGet($url) { $curl = curl_init(); curl_setopt($curl, CURLOPT_RETURNTRANSFER, true); curl_setopt($curl, CURLOPT_TIMEOUT, 500); // 爲保證第三方服務器與微信服務器之間數據傳輸的安全性,全部微信接口採用https方式調用,必須使用下面2行代碼打開ssl安全校驗。 // 若是在部署過程當中代碼在此處驗證失敗,請到 http://curl.haxx.se/ca/cacert.pem 下載新的證書判別文件。 curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, true); curl_setopt($curl, CURLOPT_SSL_VERIFYHOST, true); curl_setopt($curl, CURLOPT_URL, $url); $res = curl_exec($curl); curl_close($curl); return $res; } private function get_php_file($filename) { return trim(substr(file_get_contents($filename), 15)); } private function set_php_file($filename, $content) { $fp = fopen($filename, "w"); fwrite($fp, "<?php exit();?>" . $content); fclose($fp); } }
jsapi_ticket.phpgit
<?php exit();?> {"jsapi_ticket":"","expire_time":0}
三、github Composer的使用github
PHP 中文工具類,支持漢字轉拼音、拼音分詞、簡繁互轉、數字、金額大寫json
https://github.com/Yurunsoft/ChineseUtilapi
composer require yurunsoft/chinese-util
跨域
"require": { "yurunsoft/chinese-util" : "~1.0" }
<?php
//在github示例的基礎上新加以下一行代碼 include './autoload.php'; use \Yurun\Util\Chinese; use \Yurun\Util\Chinese\Pinyin; $string = '恭喜發財!123'; //echo $string, PHP_EOL; /*echo '全拼:', PHP_EOL; var_dump(Chinese::toPinyin($string, Pinyin::CONVERT_MODE_PINYIN));*/ echo '首字母:', PHP_EOL; print_r(Chinese::toPinyin($string, Pinyin::CONVERT_MODE_PINYIN_FIRST)); /*echo '讀音:', PHP_EOL; var_dump(Chinese::toPinyin($string, Pinyin::CONVERT_MODE_PINYIN_SOUND)); echo '讀音數字:', PHP_EOL; var_dump(Chinese::toPinyin($string, Pinyin::CONVERT_MODE_PINYIN_SOUND_NUMBER)); echo '自選返回格式 + 以文本格式返回 + 自定義分隔符:', PHP_EOL; var_dump(Chinese::toPinyin($string, Pinyin::CONVERT_MODE_PINYIN | Pinyin::CONVERT_MODE_PINYIN_SOUND_NUMBER, ' ')); echo '全部結果:', PHP_EOL; var_dump(Chinese::toPinyin($string)); echo '不分割無拼音字符:', PHP_EOL; var_dump(Chinese::toPinyin($string, Pinyin::CONVERT_MODE_PINYIN, ' ', false));*/
四、spl_autoload_register自動加載,實現多個__autoload()函數緩存
$autoload_function
[, bool $throw
= true [, bool $prepend
= false ]]] ) : bool
將函數註冊到SPL __autoload函數隊列中。若是該隊列中的函數還沒有激活,則激活它們。安全
若是在你的程序中已經實現了__autoload()函數,它必須顯式註冊到__autoload()隊列中。由於 spl_autoload_register()函數會將Zend Engine中的__autoload()函數取代爲spl_autoload()或spl_autoload_call()。 服務器
若是須要多條 autoload 函數,spl_autoload_register() 知足了此類需求。 它實際上建立了 autoload 函數的隊列,按定義時的順序逐個執行。相比之下, __autoload() 只能夠定義一次。
五、打包建議用tar命令,--exclude排除打包的文件或者目錄
tar -zcvf afish.tar.gz pardir --exclude=pardir/file1 --exclude=pardir/dir1
六、壓縮包的上傳
去掉勾選 Upload files as ASCII
binary 上傳 sudo rz -by
ascii 上傳 sudo rz -ay
七、
跨域jsonp get請求
八、codeigniter項目開啓錯誤日誌頁面顯示
index.php
九、div標籤屬性style pointer-events: none 禁止頁面點擊事件,適合把頁面做爲預覽圖。
<div class="box1" style="margin-top:0; pointer-events: none"> <p class="txt"> </p> <center> test大轉盤 </center> <p></p> <!-- <img src="http://weili.dev.com.cn/uploads/activity_13_1501480292.jpg" class="logo" /> --> <iframe src="http://activity.cytxl.com.cn/static/html/super_lottery/h5/round_8/index.html?super_lottery_id=22" style="width: 320px; height: 568px; border: none; "></iframe> </div>