typo3项目中遇到需要在baseurl之前输出内容的情况,写了一个插件实现.
用法: TS中配置
config.headerComment2 = <!– abcdefg –>
fastcgi自启动可以在init.d里copy一份nginx改名为php-cgi, 改写关键部分后运行rcconf设置为自启动即可.
#! /bin/sh
### BEGIN INIT INFO# Provides: spawn-fcgi # Required-Start: $local_fs $remote_fs $network $syslog# Required-Stop: $local_fs $remote_fs $network $syslog# Default-Start: 2 3 4 5# Default-Stop: 0 1 6# Short-Description: starts the nginx web server# Description: starts nginx using start-stop-daemon### END INIT INFO
PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/binDAEMON=/usr/bin/spawn-fcgiDAEMON_OPTS=”-a 127.0.0.1 -p 9000 -C 5 -u www-data -g www-data -f /usr/bin/php-cgi”NAME=fastcgi DESC=fastcgi
test -x $DAEMON || exit 0
set -e
. /lib/lsb/init-functions
test_nginx_config() { if nginx -t $DAEMON_OPTS then return 0 else return $? fi}
case “$1” in start) echo -n “Starting $DESC: ” start-stop-daemon –start –quiet –pidfile /var/run/$NAME.pid \ –exec $DAEMON — $DAEMON_OPTS || true echo “$NAME.” ;; stop) echo -n “Stopping $DESC: ” pkill -9 php-cgi echo “$NAME.” ;; restart|force-reload) echo -n “Restarting $DESC: ” start-stop-daemon –stop –quiet –pidfile \ /var/run/$NAME.pid –exec $DAEMON || true sleep 1 start-stop-daemon –start –quiet –pidfile \ /var/run/$NAME.pid –exec $DAEMON — $DAEMON_OPTS || true echo “$NAME.” ;; reload) echo -n “Reloading $DESC configuration: ” start-stop-daemon –stop –signal HUP –quiet –pidfile /var/run/$NAME.pid \ –exec $DAEMON || true echo “$NAME.” ;; configtest) echo -n “Testing $DESC configuration: ” if test_nginx_config then echo “$NAME.” else exit $? fi ;; status) status_of_proc -p /var/run/$NAME.pid “$DAEMON” nginx && exit 0 || exit $? ;; *) echo “Usage: $NAME {start|stop|restart|reload|force-reload|status|configtest}” >&2 exit 1 ;;esac
exit 0
Nginx是俄罗斯人编写的十分轻量级的HTTP服务器,以事件驱动的方式编写,所以有非常好的性能,同时也是一个非常高效的反向代理、负载平衡。其拥有匹配Lighttpd的性能,同时还没有Lighttpd的内存泄漏问题,而且Lighttpd的mod_proxy也有一些问题并且很久没有更新。
因此我打算用其替代Apache应用于Linux服务器上。但是Nginx并不支持cgi方式运行,原因是可以减少因此带来的一些程序上的漏洞。那么我们必须使用FastCGI方式来执行PHP程序。 (continue reading…)
魔兽正史
This is a step-by-step tutorial which describes in detail how to setup TYPO3 for a multilingual website with “domain language switching”. It will describe how to properly configure RealURL, extend it’s configuration with simple PHP statements in the RealURL configuration file and last but not least, probably the most important thing: the language switch menu with cross domain support.
I started with a clean TYPO3 installation and created two page trees in order to test the setup in a multiple page tree setup. Therefore I defined that on my local Linux box typo3-ml.local listens to the default language, while typo3-ml-en.local and typo3-ml-it.local – you guessed it – listens to the english and italian language versions of the page tree. (continue reading…)
保证在实现功能的基础上,尽量减少对数据库的访问次数;通过搜索参数,尽量减少对表的访问行数,最小化结果集,从而减轻网络负担;能够分开的操作尽量分开处理,提高每次的响应速度;在数据窗口使用SQL时,尽量把使用的索引放在选择的首列;算法的结构尽量简单;在查询时,不要过多地使用通配符如 SELECT * FROM T1语句,要用到几列就选择几列如:SELECT COL1,COL2 FROM T1;在可能的情况下尽量限制尽量结果集行数如:SELECT TOP 300 COL1,COL2,COL3 FROM T1,因为某些情况下用户是不需要那么多的数据的。 (continue reading…)
/*
* displayContact
*@param type: agency or customers
*@param data: data uid
*@param pageid: contact page id
*/
protected function displayContact($type, $data, $pageid) {
// Get default configuration
$conf = $GLOBALS[‘TSFE’]->tmpl->setup[‘plugin.’][‘tx_demodata_pi4.’];
// Modify this configuration
$conf += array(‘type’ => $type,’data’ => $data,’pageid’ => $pageid);
// Get page
$cObj = t3lib_div::makeInstance(‘tslib_cObj’);
/* @var $cObj tslib_cObj */
$cObj->start(array(), ”);
return $cObj->cObjGetSingle(‘USER’, $conf);
}
PHP 过滤器用于验证和过滤来自非安全来源的数据,比如用户的输入。
PHP 过滤器用于验证和过滤来自非安全来源的数据。
验证和过滤用户输入或自定义数据是任何 Web 应用程序的重要组成部分。
设计 PHP 的过滤器扩展的目的是使数据过滤更轻松快捷。 (continue reading…)