Input passed to the "fieldkey" parameter in browse_foreigners.php and input passed to the "PMA_sanitize()" function is not properly sanitised before being returned to the user. This can be exploited to execute arbitrary HTML and script code in a user's browser session in context of an affected site.
影響版本:
phpMyAdmin 2.x
解決辦法:
更新至 phpMyAdmin 2.10.1
Reference:
phpMyAdmin Cross-Site Scripting Vulnerabilities
星期二, 5月 01, 2007
PHP 讀取含有「中文」的資料夾會亂碼?
我一開始以為這是「正常」的
在網路上找相關文章都沒有
連一個正面的都沒有
是大家都太厲害了嘛 ><"
大概大家都不用中文來處理
嗯... 這是對的!
不過我的任務現在就是要這樣做 ._.
所以如無特殊要求的話
還是用英文加數字重新命名,再去跟資料庫做對應吧~
資料夾及檔名未經編碼前:

資料夾及檔名經編碼後:

原來的程式:(僅列出部份程式)
更改過後的程式:
雖然 Windows XP 底層是用 UCS-2
這亂碼的情形剛好在我的電腦還有 Server 都發生
我的 Notebook 開發環境如下:
Keyword:
php, readdir, opendir, closedir, iconv, unicode, UTF-8, UCS-2, UTF-16, CP950
在網路上找相關文章都沒有
連一個正面的都沒有
是大家都太厲害了嘛 ><"
大概大家都不用中文來處理
嗯... 這是對的!
不過我的任務現在就是要這樣做 ._.
所以如無特殊要求的話
還是用英文加數字重新命名,再去跟資料庫做對應吧~
資料夾及檔名未經編碼前:

資料夾及檔名經編碼後:

原來的程式:(僅列出部份程式)
$path = $_SERVER['DOCUMENT_ROOT'];
$objDirectory = opendir($path);
while ($strFilename = readdir($objDirectory)) {
if (($strFilename) && ($strFilename != '.') && ($strFilename != '..') && ($strFilename != 'CVS')) {
echo $strFilename.'
';
}
}
closedir($objDirectory);
更改過後的程式:
echo iconv("BIG5", "UTF-8", $strFilename);
雖然 Windows XP 底層是用 UCS-2
這亂碼的情形剛好在我的電腦還有 Server 都發生
我的 Notebook 開發環境如下:
- Windows XP Home Edition SP2 English version
- Control Panel 中的 Regional and Language Options。Location 是 Taiwan;Advanced 中的 Language for non-Unicode programs 是 Chinese(Taiwan)。
- PHP 使用 UTF-8 編碼
- Apache 2.2.4 / PHP 5.2.1
- FreeBSD 6.2-RELEASE i386
(可用 uname -r 查詢) - Apache 2.2.3 / PHP 5.1.6
- Samba 使用 CP950 編碼
Keyword:
php, readdir, opendir, closedir, iconv, unicode, UTF-8, UCS-2, UTF-16, CP950
星期四, 3月 15, 2007
PHP Session 安全性設定
寫程式常常都會使用到 Session
由於 Cookie 是存在 Client 端
所以重要資訊盡量不要用 Cookie 存會比較好
而 Session 跟 Cookie 能夠一起搭配是最好不過的
雖然存放在 /tmp 的 Session files 在重開機後會被自動刪除
但避免 session files 過多,及安全性的議題
所以還是在 session_regenerate_id() 的參數設為 TRUE(預設是 FALSE)會比較好
以下就來舉例介紹:
如果要 php 自動刪除那些無效的 Session files,可以照個下面這樣做:
PHP Security Tip #7
由於 Cookie 是存在 Client 端
所以重要資訊盡量不要用 Cookie 存會比較好
而 Session 跟 Cookie 能夠一起搭配是最好不過的
雖然存放在 /tmp 的 Session files 在重開機後會被自動刪除
但避免 session files 過多,及安全性的議題
所以還是在 session_regenerate_id() 的參數設為 TRUE(預設是 FALSE)會比較好
以下就來舉例介紹:
session_start();
$_SESSION['data'] = time();
session_regenerate_id();
?>
執行了上述程式後到 /tmp 資料夾會看到 sess_82c6980017e100277a63983142fd454c
sess_a4bab88e6dfa6e900ade21e3fbd27a53
再執行一次你會看見 sess_984c5230acca90b5a75eddb89bb48354
sess_a4bab88e6dfa6e900ade21e3fbd27a53
sess_82c6980017e100277a63983142fd454c
再再一次你會看見 sess_984c5230acca90b5a75eddb89bb48354
sess_a4bab88e6dfa6e900ade21e3fbd27a53
sess_82c6980017e100277a63983142fd454c
sess_dd88c05b724d80b30c90309847f2e919
上述每執行一次就會增加一個 Session file,不是因為有另外一個人登入喔!如果要 php 自動刪除那些無效的 Session files,可以照個下面這樣做:
session_start();
$_SESSION['data'] = time();
session_regenerate_id(true);
?>
Reference:PHP Security Tip #7
星期日, 11月 05, 2006
Zend PHP 5 Certification Study Guide
不知何時Zend PHP 5 Certification Study Guide 已經出來了
剛剛在書架上看到 MySQL 5.0 Certification Study Guide 才想到
原本今年想要考證照的
不過依目前渙散的心情
似乎不太可能了...
Book Description
ISBN 0-9738621-4-9, 272 pages.
Zend's new PHP 5 Certification Exam represents an excellent tool for professional PHP developers who want to distinguish themselves in their field.
php|architect's Zend PHP 5 Certification Study Guide, edited and produced by the publishers of php|architect, provides the most comprehensive and thorough preparation tool for developers who wish to take the exam.
This book provides complete coverage of every topic that is part of the exam, for more information, see the chapters & source code.
Written by PHP professionals, and Zend Certified PHP 5 Engineers, Davey Shafik and Ben Ramsey, and reviewed by core PHP developer Derick Rethans, this is the perfect book for every prospective Zend Certified PHP Engineer candidate!
Chapters
php|architect's Zend PHP 5 Certification Guide covers the following subjects:
* PHP Basics
* Functions
* Arrays
* Strings and Patterns
* Web Features
* PHP 4/5 Differences
* Object Oriented Programming
* Design and Theory
* Security
* Databases and SQL
* XML and Web Services
* Files and Streams
Zend and php|architect have worked closely together to ensure that the book covers all material necessary for those wanting to take the exam. We have however, tried to make it a good reference in and of it-self, so even if you're not going to take the exam, you should consider this book as your everyday "digest" reference.
目前天瓏書局似乎還貨,出現了再跟大家報告!
星期三, 10月 11, 2006
千萬不要把程式壓縮放在網站上
網頁程式設計師或許都會有個習慣
可能出門在外或去客戶那邊更新程式
都會把程式壓縮打包好放到客戶的主機上
到了那邊再直接解壓縮即可
以前您這樣做的話
如果您的 Web Server 沒有開啟瀏覽目錄的功能的話
那還不會有問題
不過自從 Google Code Search 服務出來後
你就不能這樣做了喔...
為什麼呢?
剛嘗試了一下這項服務,果然是猛!
Google bot 會將您放在 Web Server 下的壓縮檔統統幫您脫掉
自己將您壓縮檔內的資料紀錄在案(包含程式跟資料庫密碼!)
您不能說這是 Google 侵權
這要怪自己習慣不良
遇到這種情形還是準備個隨身碟或丟到網路硬碟還是 FTP 上吧
否則如果剛好衰小...
放上去沒多久,剛好 Google bot 就來敲門
這樣你們家的主機就會有很多訪客來玩了
其實衍生的還有某些圖片的原始檔等等
小心辛苦了老半天的心血都被人家偷走囉~
可能出門在外或去客戶那邊更新程式
都會把程式壓縮打包好放到客戶的主機上
到了那邊再直接解壓縮即可
以前您這樣做的話
如果您的 Web Server 沒有開啟瀏覽目錄的功能的話
那還不會有問題
不過自從 Google Code Search 服務出來後
你就不能這樣做了喔...
為什麼呢?
剛嘗試了一下這項服務,果然是猛!
Google bot 會將您放在 Web Server 下的壓縮檔統統幫您脫掉
自己將您壓縮檔內的資料紀錄在案(包含程式跟資料庫密碼!)
您不能說這是 Google 侵權
這要怪自己習慣不良
遇到這種情形還是準備個隨身碟或丟到網路硬碟還是 FTP 上吧
否則如果剛好衰小...
放上去沒多久,剛好 Google bot 就來敲門
這樣你們家的主機就會有很多訪客來玩了
其實衍生的還有某些圖片的原始檔等等
小心辛苦了老半天的心血都被人家偷走囉~
星期一, 6月 26, 2006
Apache 2.2 doesn't support PHP 5.1.4
由於最近使用的 Apache 2.0.58 怪怪的
不是當掉就是自己重開
所以今天早上想說乾脆升級到 2.2 好了
其實之前在家就有試過,不過失敗
今天也是一樣加入 PHP 5.1.4 後,Apache 2.2 就開不起來了
google 了一下...
發現了一個晴天霹靂的消息
PS. Linux 上裝過 Apache 2.2.2 & PHP5.1.4 是 OK 的!
Reference:
http://www.daniweb.com/techtalkforums/post221116.html
http://www.ricocheting.com/server/apache.html
Envir.
Windows XP Pro
Apache 2.2.2
PHP 5.1.4
不是當掉就是自己重開
所以今天早上想說乾脆升級到 2.2 好了
其實之前在家就有試過,不過失敗
今天也是一樣加入 PHP 5.1.4 後,Apache 2.2 就開不起來了
google 了一下...
發現了一個晴天霹靂的消息
NOTE: Apache 2.2 will NOT work with any current stable version of PHP (you have to use beta 5.2). So make sure you download Apache 2.0.x也就是說 Windows 上裝 Apache 2.2 跟 PHP 5.1 有問題是正常的
PS. Linux 上裝過 Apache 2.2.2 & PHP5.1.4 是 OK 的!
Reference:
http://www.daniweb.com/techtalkforums/post221116.html
http://www.ricocheting.com/server/apache.html
Envir.
Windows XP Pro
Apache 2.2.2
PHP 5.1.4
星期四, 5月 18, 2006
Let GD support JPG & PNG
之前 compile gd 一直沒遇過這問題
正常的 phpinfo() 畫面

缺了 PNG & JPEG 的畫面

因為看到下面那篇文章,想到 lib 的 devel 套件是專門給 compile 用的
於是乎趕緊查看了一下
兩個都沒有該 lib 的 devel 套件
趕緊給他裝一下囉~
apt-get install libpng
apt-get install libjpeg
不是 debian 系列或沒 apt 功能的 os 可用
yum install libpng
yum install libjpeg
裝完之後記得要 re-compile gd & php 喔!
不過這邊 gd 的 freetype 還是不支援
雖然 freetype & freetype-devel 套件都有
但 phpinfo() 就是不出來
這部份等下回分曉囉...
reference:
http://bugs.php.net/bug.php?id=19542&edit=1
正常的 phpinfo() 畫面

缺了 PNG & JPEG 的畫面

因為看到下面那篇文章,想到 lib 的 devel 套件是專門給 compile 用的
於是乎趕緊查看了一下
shell > rpm -qa | grep png
libpng-1.2.7-1.el4.2
shell > rpm -qa | grep jpeg
libjpeg-6b-33
兩個都沒有該 lib 的 devel 套件
趕緊給他裝一下囉~
apt-get install libpng
apt-get install libjpeg
不是 debian 系列或沒 apt 功能的 os 可用
yum install libpng
yum install libjpeg
裝完之後記得要 re-compile gd & php 喔!
不過這邊 gd 的 freetype 還是不支援
雖然 freetype & freetype-devel 套件都有
但 phpinfo() 就是不出來
這部份等下回分曉囉...
reference:
http://bugs.php.net/bug.php?id=19542&edit=1
星期五, 5月 05, 2006
PHP 5.1.4 released
A critical bug with file uploads as well as the fastcgi sapi has been discovered in PHP 5.1.3 and a new PHP release 5.1.4 has been made available to address these two issues. All PHP users are encouraged to upgrade to this release as soon as possible.
This release provides fixes for the following bugs:
- Fixed problems with file uploads and the $_POST array handling.
- Resolved multiple problems with the FastCGI sapi.
- Fixed possible crash in highlight_string().
- Fixed cloning of DOM Documents and Noded.
- Several fixes to PDO ODBC driver.
前幾天才將 Apche/php 更新到 2.2.2 & 5.1.3
結果今天上去 PHP 上看 function 說明時
赫然看到 5.1.4 & Critical Bug 的字樣
雖然這Bug 跟我建制的環境沒什麼關係
不過還是一起更新囉~
你也趕快去更新吧~
星期二, 4月 25, 2006
PHP5 timezone setting
PHP 5.1.0 開始
date() 會依據 date_default_timezone_get(void) 的設定去抓時區
如果沒有設定,就會依照格林威治標準時間
所以會跟我們差上 8 個小時(in Taiwan)
要在最上層加上:
date_default_timezone_set('Asia/Taipei');
就會正常了!
備註. SQL 的 now() 等日期時間函數不受此限制
Reference:
http://tw.php.net/manual/en/function.date-default-timezone-get.php
http://tw.php.net/manual/en/function.date-default-timezone-set.php
http://tw.php.net/manual/en/timezones.asia.php
date() 會依據 date_default_timezone_get(void) 的設定去抓時區
如果沒有設定,就會依照格林威治標準時間
所以會跟我們差上 8 個小時(in Taiwan)
要在最上層加上:
date_default_timezone_set('Asia/Taipei');
就會正常了!
備註. SQL 的 now() 等日期時間函數不受此限制
Reference:
http://tw.php.net/manual/en/function.date-default-timezone-get.php
http://tw.php.net/manual/en/function.date-default-timezone-set.php
http://tw.php.net/manual/en/timezones.asia.php
星期五, 3月 24, 2006
Step by step :
apache2, mysql(4/5), php(4/5), gd2
It can be used fedora and CentOS(redhat linux like).
gd2
./configure --prefix=/usr/local/gd2
make;make install
php5
./configure --prefix=/usr/local/php5 --with-apxs2=/usr/local/apache2/bin/apxs --with-mysql=/usr/local/mysql --with-config-file-path=/usr/local/php5 --enable-mbstring=tw --enable-ftp --with-zlib --with-regex=php --with-mysqli=/usr/local/mysql/bin/mysql_config --with-gd=/usr/local/gd2
php5.1
--with-zlib --enable-pdo=shared
php.ini
extension=pdo.so
php4
./configure --prefix=/usr/local/php4 --with-apxs2=/usr/local/apache2/bin/apxs --with-mysql=/usr/local/mysql --with-config-file-path=/usr/local/php4 --enable-mbstring=tw --enable-ftp --with-zlib --with-regex=php --with-mysqli=/usr/local/mysql/bin/mysql_config --with-gd=/usr/local/gd2
make;make install
apache2, mysql(4/5), php(4/5), gd2
It can be used fedora and CentOS(redhat linux like).
gd2
./configure --prefix=/usr/local/gd2
make;make install
php5
./configure --prefix=/usr/local/php5 --with-apxs2=/usr/local/apache2/bin/apxs --with-mysql=/usr/local/mysql --with-config-file-path=/usr/local/php5 --enable-mbstring=tw --enable-ftp --with-zlib --with-regex=php --with-mysqli=/usr/local/mysql/bin/mysql_config --with-gd=/usr/local/gd2
php5.1
--with-zlib --enable-pdo=shared
php.ini
extension=pdo.so
php4
./configure --prefix=/usr/local/php4 --with-apxs2=/usr/local/apache2/bin/apxs --with-mysql=/usr/local/mysql --with-config-file-path=/usr/local/php4 --enable-mbstring=tw --enable-ftp --with-zlib --with-regex=php --with-mysqli=/usr/local/mysql/bin/mysql_config --with-gd=/usr/local/gd2
make;make install
訂閱:
文章 (Atom)