[Solve]PHP Warning: ftp_put(): PORT command successful
PHP Warning: ftp_put(): PORT command successful. in /mnt/drive2/cron_job/ftp.php on line 49
I got this problem. And I check the solution on the website – add the ftp_pasv() after ftp_login()
But I still got this problem. And I found out the problem in PHP. The problem is the command exceed the length. Please check your path.
PHP export Excel Currency Style
<html xmlns:o=”urn:schemas-microsoft-com:office:office”
xmlns:x=”urn:schemas-microsoft-com:office:excel”
xmlns=”http://www.w3.org/TR/REC-html40″>
<!DOCTYPE html PUBLIC “-//W3C//DTD XHTML 1.0 Transitional//EN” “http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd”>
<html>
<head>
<meta http-equiv=”Content-type” content=”text/html;charset=utf-8″ />
<style id=”Classeur1_16681_Styles”>
.hkd {
mso-number-format: “\0022HKD\0022\#\,\#\#0\.00”;
}
.usd {
mso-number-format: “\0022USD\0022\#\,\#\#0\.00”;
}
.currency{
mso-number-format: “\0022$\0022\#\,\#\#0\.00”;
}
</script>
</head>
<body><div id=”Classeur1_16681″ align=center x:publishsource=”Excel”>
<table>
<tr>
<td class=”usd”>123,456</td>
</tr>
</table>
</div>
</body>
</html>
Other format
- Plain Text: mso-number-format:\@
- Format a number to 2 decimal places: mso-number-format:”0\.00″
- Comma separators with 2 decimal places: mso-number-format:\#\,\#\#0\.00
- Date \ Time Formating:
- American date: mso-number-format:mm\/dd\/yy
- Month name: mso-number-format:d\\-mmm\\-yyyy
- Date and Time: mso-number-format:d\/m\/yyyy\ h\:mm\ AM\/PM
- Short Date: mso-number-format:”Short Date” (05/06/2011)
- Medium Date: mso-number-format:”Medium Date” (10-jan-2011)
- Short Time: mso-number-format:”Short Time” (8:67)
- Medium Time: mso-number-format:”Medium Time” (8:67 AM)
- Long Time: mso-number-format:”Long Time” (8:67:25:00)
- Percentage: mso-number-format:Percent (To two decimal places)
- Scientific Notation: mso-number-format:”0\.E+00″
- Fractions – up to 3 digits: mso-number-format:”\#\ ???\/???”
- Currency (£12.76): mso-number-format:”\0022£\0022\#\,\#\#0\.00″
- 2 decimals, negative numbers in red and signed: mso-number-format:”\#\,\#\#0\.00_ \;\[Red\]\-\#\,\#\#0\.00\ ” (1.86-1.66)
- Accounting Format –5,(5): mso-number-format:”\\#\\,\\#\\#0\\.00_\\)\\;\\[Black\\]\\\\(\\#\\,\\#\\#0\\.00\\\\)”
當session遇上header location儲存問題
由於看到網上很多錯誤資訊, 所以自己寫下對session的行動, 研究在於function session_set_save_handler 所得出來的結論, 如有問題, 請指教
由session_start();開始, session只會做普通variable的動作
action.php
session_start();
$_SESSION[‘user’] = ‘abc’;
$_SESSION[‘user’] = ‘ddd’;
直到讀到file完結才會真正儲存session file
所以當action.php session有修改的時候, 最後加了
session_start();
$_SESSION[‘user’] = ‘abc’;
$_SESSION[‘user’] = ‘ddd’;
header(‘Location: index.php’);
exit();
就會即時跳到index.php, 這暫時不會儲存action.php的session, 也當沒有做過東西將他放了一個黑洞(無人不知的地方),直到index.php行完, 才會返回action.php儲存action.php的session
所以當index.php讀取$_SESSION[‘user’], 只會拿回沒有被修改的$_SESSION[‘user’]
解決彈出層被flash遮罩住
http://www.uedcss.com/post/flash-Pop-up-layer.html
從網上找了2個方法, 解決彈出層被flash遮罩住
一:flash插入方式如下的,採用方法
1.在<object> 裡添加 <param name=”wmode” value=”transparent”>
2.在<embed> 設置 wmode=”opaque”
也可以實現
二:采用JavaScript插入flash方式如下:
var flashvars = {};
var params = {wmode:”opaque”};
swfobject.embedSWF(‘images/logo.swf’, ‘logo’, ‘179’, ’57’, “9.0.0”,”expressInstall.swf”,flashvars,params);
JQuery – substring some keyword
substring some keyword
var keyword = ‘abc’;
var index = ($(“#content”).val().indexOf(keyword));
if(index != -1){
var pre = $(“#content”).val().substring(0, index);
var pos = $(“#content”).val().substring(index+keyword.length);
$(“#content”).val(pre+pos);
}
MYSQL – Illegal mix of collations
<?php mysql_query(“SET NAMES ‘utf8′”); ?>
由於php mysql set utf8_general_ci, 但是在table column set左latin1_swedish_ci, 就會產生
#1267 – Illegal mix of collations (latin1_swedish_ci,IMPLICIT) and (utf8_general_ci,COERCIBLE) for operation ‘like’
SELECT * FROM `table` WHERE `field` like ‘%這些%’
改成
SELECT * FROM `table` WHERE `field` like ‘%這些%’ COLLATE utf8_general_ci
PHP Filter User agent in session – Bot
由於php session 儲存在 database, 所以當有bot出現的時候, 我看到session 會儲存大量bot session, 所以要檢查user agent 是否bot. 那bot 就不會儲存session (database, file).
function isNotBot(){
$bots = array(
‘msn’ => ‘http://search.msn.com/msnbot.htm’,
‘yahoo’ => ‘http://help.yahoo.com/help/us/ysearch/slurp’,
‘WebAlta’ => ‘http://www.webalta.net/ru/about_webmaster.html’,
‘google’ => ‘http://www.google.com/bot.html’,
‘media_google’ => ‘mediapartners-google’,
‘soso’ => ‘http://help.soso.com/webspider.htm’
);$agent = strtolower($_SERVER[‘HTTP_USER_AGENT’]);
foreach($bots as $name => $bot)
{
if(stripos($agent,$bot)!==false)
{
//echo $name;
return false;
}
}//if( strpos( $_SERVER[‘HTTP_USER_AGENT’], “Googlebot” ) !== false )
//return false;
return true;
}if(isNotBot())
session_start();
Javascript – 列印所選取的位置
列印網上資料都會有很多不相關資料在附近, 因此做法有很多
例如:
1. 是開一個page, 用來給人列印, 之後在瀏覽器按列印
2. 有時在css print set display: none, 另周邊資料不顯示
3. 用iframe顯示所需資料之後整一個button 列印 iframe page
但近來看到一些新方法, 看法都簡單所以放上來分享, 第2給自己空閒時用來溫習. 這個方法就是用js解決
function printSelection(node){
var title = ”;
var content=document.getElementById(node).innerHTML;
var pwin=window.open(”,’print_content’,’width=750,height=600,titlebar=no,location=0,toolbar=0,menubar=0,directions=0′);pwin.document.open();pwin.document.write(‘<html><head><title>’ + title + ‘</title><style>body table{font-size:10px}</style></head><body onload=”window.print()”>’+content+'</body></html>’);pwin.document.close();setTimeout(function(){pwin.close();},1000);}