Tag Archives: php

PHP cannot exec ping

In httpd error_log, it got icmp open socket: Permission denied It is because the seLinux blocking the httpd for security reason. Two solutions: 1. Disable seLinux (high risk) 2. Build a custom policy to unblock partial permission for httpd To build custom policy, use audit2allow command (may require install) Ref.: http://wiki.centos.org/HowTos/SELinux 1. install audit2allow module… Read More »

php問題-備忘錄

Check sequence – Plugin library – Error message display (ini_set + error_reporting) – PHP version – Linux/Unix vs Windows vs ??? server – exec (Not all hosting have exec permission)

php上載大容量檔案時的設定

Google了一下, php預設設定只支援2MB以下大小的檔案。 要上載更大檔案時,必須修改php.ini。 以下這篇文章有提及設定方法~ http://www.radinks.com/upload/config.php (沒看完,待補完。一直在用form upload+AJAX+iframe)

php的endif endwhile格式

寫了這麼久php,還是第一次看到endif endwhile這一種格式 (剛剛在查看某wordpress template時看到) 於是就google看看 原來這款格式是php3時候就有了,格式如下 if ($foo): echo “yep\n”; elseif ($bar): echo “almost\n”; else: echo “nope\n”; endif; 除此之外,還有endwhile / endswitch等等~ (想看詳細doc的,請到source中的php.net連結) source: http://www.phpbuilder.com/manual/en/migration.if-endif.php http://docs.php.net/manual/control-structures.alternative-syntax.php

OsCommerce 的session系統

OsC這一套系統可以說是古董(2.2還support php3的說 = =) 它的session系統是自建的(以php4的session結構上再加建,php3的話就全寫) 因為太舊的關係(legacy coding),使它的session非常不好用 pass variable變得混亂 e.g. 要存寫session就要這樣做 tep_session_register(‘variable1′) $variable1=’content to store’ 那osc就會把東西存到session了 使用tep_session_register()後, osc會建立一個 global variable給你直接修改 variable的內容, 相對的是這些global variable會使建構變得很混亂 讀取的話,osc在application_top之後 便會把所有session的variables 放到global variables中, 通常先用tep_session_is_registered(‘variable name’)查看session variable是否存在 p.s.1 要integrate的話,原廠來的session name是oscid 不能夠直接用session_start() + $_session[‘var_name’] access p.s.2 php5中,session的寫法是$_session[‘var_name’]=content php4中是 session_register(‘var_name’); $var_name=content