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, Program
ftp_put, php, solve
由於看到網上很多錯誤資訊, 所以自己寫下對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’]
PHP, Program
header, location, session
<?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
Database, MYSQL, PHP, Program
COLLATE, Illegal mix of collations, mysql
由於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();
PHP, Program
bot, filter, php, session, user agent
在一些header設定
define(‘ROOT’, TRUE);
在include file設定
<?php if(!defined(‘ROOT‘)) { exit(‘Access Denied‘); }
如果打開了allow_url_include, 這個方法就可以防止訪問, “ROOT” 可以更改你喜歡的變量, 如果有人利用你一些config file,也需要時間猜你的變量
PHP, Program
allow_url_include, define
if (isset($_REQUEST[‘GLOBALS’]) OR isset($_FILES[‘GLOBALS’])) {
exit(‘Request tainting attempted.’);
}
眾所周知,當php.ini裡面的register_globals=on時,各種變量都被注入代碼,例如來自HTML 表單的請求變量。再加上PHP 在使用變量之前是無需進行初始化的。那麼就有可能導致不安全,假如有人惡意發出這麼一個get請求”http://yourdomain /unsafe.php?GLOBALS=”,那麼就會清除$GLOBALS變量的值而導致不安全。所以我們可以這樣子寫
PHP, Program
files, globals, php, request, 安全