[轉]三年前旧代码的重构、总结与反思
https://segmentfault.com/a/1190000016179093
https://segmentfault.com/a/1190000016179093
http://www.bitrepository.com/prevent-directory-traversal-attacks-in-php-wordpress.html
http://www.cnblogs.com/it-cen/p/4624939.html
http://www.cnblogs.com/lonelyxmas/p/4717007.html
http://www.cnblogs.com/lonelyxmas/p/4717007.html
http://www.sitepoint.com/forums/showthread.php?645467-Retreiving-the-previous-and-next-row-through-PDO&p=4425809&viewfull=1#post4425809 SELECT i.images_id ,COALESCE( (SELECT images.images_id FROM images WHERE images.images_id < i.images_id ORDER BY images.images_id DESC LIMIT 1), (SELECT images.images_id FROM images ORDER BY images.images_id DESC LIMIT 1) ) AS previous_images_id ,COALESCE( (SELECT images.images_id FROM images WHERE images.images_id > i.images_id ORDER BY images.images_id ASC LIMIT 1), (SELECT images.images_id FROM images ORDER BY images.images_id ASC LIMIT 1) ) AS next_images_id FROM images i WHERE i.images_id = 1 \========== for record, not for page 1、 get all new\_id in array (PDO fetchAll(PDO::FETCH\_ASSOC) ) > $all\_news\_ids = $crud->sql("select news\_id from news"); 2、get $now\_news\_id key for array > $now\_news\_id\_key\_id = array\_search(array('news\_id'=>$now\_news\_id), $ar\_all\_news\_ids); 3、check $now\_news\_id\_key\_id first, if empty > $prive\_news\_id = empty($now\_news\_id\_key\_id)?"":get\_record\_column('news\_id', $all\_news\_ids, $now\_news\_id\_key\_id+1); > $next\_news\_id = empty($now\_news\_id\_key\_id)?"":get\_record\_column('news\_id', $all\_news\_ids, $now\_news\_id\_key\_id-1); > function get\_array\_column($val, $ar){ > return array\_key\_exists($val, $ar)?$ar\[$val\]:""; > } > function get\_record\_column($val, $ar, $rec\_arrow=0){ > return (isset($ar\[$rec\_arrow\]))?get\_array\_column($val, $ar\[$rec\_arrow\]) : ""; > }
http://my.oschina.net/phpfunction/blog/65090 <?php $a = array(); for($i=0; $i<16\*16\*16\*2; $i++){ $a\[$i\] = uniqid(); } $b = array\_count\_values($a); $c = array\_keys($b, 2); if($c){ echo ''; print\_r($c); } echo ''; print\_r(array\_count\_values($a)); exit; ?>
官方說的有夠爛,底下是模擬的方式: 請先登入 官方模擬後台,請查詢官方連結、帳密。 有分兩個部份: 一、是訂單成不成立 二、模擬付款 這兩個分開測的,不是連在一起的,一開始以為是連在一起的。 一、訂單成不成立:在後台->一般訂單查詢->全方位金流訂單(AIO) 如果你是購物車發出訂單,這裡面得到,那就是訂單有成立了,但這樣的模擬付款是不行用的。 二、模擬付款:要能用請,到後台->系統開發管理->模擬交易 利用這個功能開出來的訂單才能進行模擬交易。 所以整個開發測試,請分開測試: 一、先測訂單成不成立,成立後,就沒問題。 二、這時候主力是測 ReturnURL這支程式,模擬付款後,呼叫此程式來進行DB處理,可能成功或失敗。 模擬交易開立的訂單會有輸入MerchantTradeNO,這是自己系統的單號,那在AIO進行模擬時,會(可以)重覆這個MerchantTradeNO模擬付款,建議就直接把DB內的TradeNO改掉,這樣按下模擬付款。 按下模擬付款,兩個部份要處理:A、有真的連到ReturnURL?B、DB有把資料寫進去嗎? A、ReturnURL 看不到有沒有呼叫到?很簡單,再程式最前面,直接呼叫DB寫入某個欄位,如果有寫入,就那至少知道有呼叫到這支程式。 B、DB寫的不完整,或是欄位有Error等等,反正就是沒寫進去,很簡單,把error_code寫到DB某欄位,這樣也知道錯誤訊息是什麼。 以上大概是歐付寶 模擬、測試方式。 PS:模擬付款成功,很多對應欄位資料是無值的
http://www.sitepoint.com/html5-forms-javascript-constraint-validation-api/ 1. progressive enhancement: http://jsfiddle.net/trixta/ru7… http://jsfiddle.net/trixta/ru7jt/ http://stackoverflow.com/questions/12470622/how-can-i-check-the-validity-of-an-html5-form-that-does-not-contain-a-submit-but form.checkValidity() https://html.spec.whatwg.org/multipage/forms.html#dom-form-checkvalidity https://html.spec.whatwg.org/multipage/forms.html#statically-validate-the-constraints ===== var form = document.getElementById(“purchaser_form”); form.noValidate = true; form.onsubmit = validateForm; // set handler to validate the form // onsubmit used for easier cross-browser compatibility function validateForm(event) { if (form.checkValidity()) { return true; } else { field = form.querySelector(‘input:invalid, select:invalid, textarea:invalid’); field.focus(); if (field.checkValidity()) { removeInvalid(field); } else { setInvalid(field); } return false; } } function setInvalid(element) { var message; var parent = element.parentNode; ...
http://www.webteach.tw/?p=591 https://github.com/allpay/AllPayAioExample/blob/master/Allpay_AIO_CreateOrder.php
refrence http://codereview.stackexchange.com/questions/25671/my-perfect-shopping-cart-class Easy way is copy this code to your php editor. 1、const ID, QTY for column name, it’s can change by yourself. 2、session only check isset. 3、array_push_after() maybe use not good way. 4、$item from CartItemtoArray(), this is array(). not class object. 5、getIndexOfEntry() try to get Array $container at index. So use Array to control, no Object. Becasue I don’t know refrence, answer 1 and 2, How to create item add in cart. ID is key. Answer 1 can run, answer 2 is broken. ...
When you use PDO, try to get fetchAll(PDO::FETCH_ASSOC) fetch(PDO::FETCH_ASSOC) return is Array. This Array have rows, it’s mean : array[0] = array[“field1”, “field2”, “field3”] array[1] = array[“field1”, “field2”, “field3”] …… array[10] = array[“field1”, “field2”, “field3”] So get array index or row maybe not exist, when you try to get value, get error code. You can try to make two function: function ar_get($val, $ar){ return array_key_exists($val, $ar)?$ar[$val]:""; } function crud_ar_get($val, $ar, $rec_arrow=0){ return (isset($ar[$rec_arrow]))?ar_get($val, $ar[$rec_arrow]) : “”; } ...
http://avnpc.com/pages/add-nginx-to-xampp
http://www.ido321.com/1424.html PDO支持三种异常模式: 默认模式:PDO::ERRMODE_CLIENT 警告模式:PDO::ERRMODE_WARNING 异常模式:PDO::ERRMODE_EXCEPTION(推荐)
http://www.ido321.com/1546.html ===== good http://phpdebugbar.com/
https://github.com/sjardim/processwire-simple-flickr-album http://www.webinfopedia.com/multiple-file-download-by-creating-zip-file-in-PHP.html http://stackoverflow.com/questions/1754352/download-multiple-files-as-zip-in-php ===== jquery https://github.com/biesiad/jquery-multidownload ** $(’.my_download_trigger’).multiDownload({ delay: 500 }); http://stackoverflow.com/questions/9047645/download-multiple-files-without-using-zip-file https://github.com/sindresorhus/multi-download
2016/03/02 http://www.mikkonen.info/imageutil/ =====2015/11/29 http://www.smashingmagazine.com/2015/06/efficient-image-resizing-with-imagemagick/ From my tests, running ImageMagick with the following settingsproduced the smallest results, while generally being visually indistinguishable from Photoshop’s output: mogrify -path OUTPUT_PATH -filter Triangle -define filter:support=2 -thumbnail OUTPUT_WIDTH -unsharp 0.25x0.25+8+0.065 -dither None -posterize 136 -quality 82 -define jpeg:fancy-upsampling=off -define png:compression-filter=5 -define png:compression-level=9 -define png:compression-strategy=1 -define png:exclude-chunk=all -interlace none -colorspace sRGB -strip INPUT_PATH I looked at 11 different functions and found that -thumbnail does the best job of optimizing quality and file size. ...
phpFlickr authentication to access private photos 1:https://github.com/jrtilson/phpflickr/tree/master/token download index.php & auth.php or my demo 2:edit index.php 2-1 mark: //$f->auth($_SESSION[‘perms’]); //會造成迴圈 //$token = $f->auth_checkToken($_SESSION[‘phpFlickr_auth_token’]); //無用 !!important!! token usually is ok~ and phpFlickr check token is broken. This can check token https://www.flickr.com/services/api/explore/flickr.auth.checkToken 2-2 change: echo “” . $_SESSION[‘phpFlickr_auth_token’][_content] . “”; //要補上[_content] 3:call back URL set THIS FILE:**http://xxxxoooo.com/**auth.php IF not sure, just index.php when you not login. index.php have Set the callback url to: xxxxxxoooooo ...
http://www.angularcode.com/useful-database-helper-class-to-generate-crud-statements-using-php-and-mysql/ 這個看起來更好,滿足我的問題,不用再進crud class中,一個一個改欄位,直接帶什麼改什麼,這樣更快。
http://www.roxyfileman.com/CKEditor-file-browser 檔案下載 filedownload