PHP如何forword url?
| 2011,3月 18 | Posted by yaozer under PHP |
| 2011,3月 18 | Posted by yaozer under PHP |
| 2010,5月 26 | Posted by yaozer under PHP, ubuntu server |
ubuntu10.04 的php版本是 php5.3, 很多程序可能不支持, 降级到php5.2 的方法如下:
01 |
sudo aptitude purge `dpkg -l | grep php| awk '{print $2}' |tr"\n" " "` |
02 |
echo -e "Package: php5\nPin: release a=karmic\nPin-Priority: 991\n" | sudo tee /etc/apt/preferences.d/php > /dev/null |
03 |
apt-cache search php5-|grep php5-|awk '{print "Package:", $1,"\nPin: release a=karmic\nPin-Priority: 991\n"}'|sudo tee -a /etc/apt/preferences.d/php > /dev/null |
04 |
apt-cache search -n libapache2-mod-php5 |awk '{print "Package:", $1,"\nPin: release a=karmic\nPin-Priority: 991\n"}'| sudo tee -a /etc/apt/preferences.d/php > /dev/null |
05 |
echo -e "Package: php-pear\nPin: release a=karmic\nPin-Priority: 991\n" | sudo tee -a /etc/apt/preferences.d/php > /dev/null |
| 06 | grep 'main restricted' /etc/apt/sources.list|grep -v "#"| seds/lucid/karmic/g | sudo tee/etc/apt/sources.list.d/karmic.list > /dev/null |
07 |
sudo apt-get update |
08 |
sudo aptitude install -t karmic php5-cli php5-cgi |
09 |
sudo aptitude hold `dpkg -l | grep php5| awk '{print $2}' |tr"\n" " "` |
| 2010,5月 14 | Posted by yaozer under PHP |
UPC-A 是条形码的一种格式, 用php 可以生成 订单, sku等的条形码, 供打印。 具体php代码如下:
function UPCAbarcode($code)
{
$lw = 2; $hi = 100;
$Lencode = array('0001101','0011001','0010011','0111101','0100011',
'0110001','0101111','0111011','0110111','0001011');
$Rencode = array('1110010','1100110','1101100','1000010','1011100',
'1001110','1010000','1000100','1001000','1110100');
$ends = '101'; $center = '01010';
/* UPC-A Must be 11 digits, we compute the checksum. */
if ( strlen($code) != 11 ) { die("UPC-A Must be 11 digits."); }
/* Compute the EAN-13 Checksum digit */
$ncode = '0'.$code;
$even = 0; $odd = 0;
for ($x=0;$x<12;$x++)
{
if ($x % 2) { $odd += $ncode[$x]; } else { $even += $ncode[$x]; }
}
$code.=(10 - (($odd * 3 + $even) % 10)) % 10;
/* Create the bar encoding using a binary string */
$bars=$ends;
$bars.=$Lencode[$code[0]];
for($x=1;$x<6;$x++)
{
$bars.=$Lencode[$code[$x]];
}
$bars.=$center;
for($x=6;$x<12;$x++)
{
$bars.=$Rencode[$code[$x]];
}
$bars.=$ends;
/* Generate the Barcode Image */
$img = ImageCreate($lw*95+30,$hi+30);
$fg = ImageColorAllocate($img, 0, 0, 0);
$bg = ImageColorAllocate($img, 255, 255, 255);
ImageFilledRectangle($img, 0, 0, $lw*95+30, $hi+30, $bg);
$shift=10;
for ($x=0;$x
if (($x<10) || ($x>=45 && $x<50) || ($x >=85)) { $sh=10; } else { $sh=0; }
if ($bars[$x] == ’1′) { $color = $fg; } else { $color = $bg; }
ImageFilledRectangle($img, ($x*$lw)+15,5,($x+1)*$lw+14,$hi+5+$sh,$color);
}
/* Add the Human Readable Label */
ImageString($img,4,5,$hi-5,$code[0],$fg);
for ($x=0;$x<5;$x++)
{
ImageString($img,5,$lw*(13+$x*6)+15,$hi+5,$code[$x+1],$fg);
ImageString($img,5,$lw*(53+$x*6)+15,$hi+5,$code[$x+6],$fg);
}
ImageString($img,4,$lw*95+17,$hi-5,$code[11],$fg);
/* Output the Header and Content. */
header("Content-Type: image/png");
ImagePNG($img);
}
UPCAbarcode('13322483157');
?>
| 2009,7月 5 | Posted by yaozer under Apache, MySQL, PHP, ubuntu server, 其他 |
ubuntu 如何搭建 lamp ?那还不容易, apache2, php5, mysql-server 之类的装一下不就可以了吗? 但是有时候也会遇到一些问题, 比如ubuntu 9.04上面安装mysql-server5.1是有些问题的。
怎么安装最简单呢? 答案是这样的:
sudo apt-get install lamp-server^
别忘了最后面那个 ^ , 这条命令和一般命令不一样哦, 原理见此处:https://help.ubuntu.com/community/Tasksel
| 2009,7月 2 | Posted by yaozer under PHP |
综合了网上的一些资料, 改写了一下。
function tree($directory)
{
echo date(“Y-m-d H:i:s”);
$i=0;
$mydir=dir($directory);
echo “<ul>\n”;
while($file=$mydir->read() AND $i<5)
{
if((is_dir(“$directory”)) AND ($file!=”.”) AND ($file!=”..”))
{
$filetime=date(“Y-m-d H:i:s”,filectime($file));
//encode spaces
$file = rawurlencode($file);
// convert the + (this is one result from the function rawurlencode) in %20
$url = str_replace(‘+’ , ‘%20′ , $file);
echo “<li><font color=\”#ff00cc\”><a href=’”.$url.”‘>”.$url.”</a></font> $filetime<br/></li>\n”;
$i+=1;
}
}
echo “</ul>\n”;
$mydir->close();
}
tree(“.”); // 列出当前目录
| 2009,5月 24 | Posted by yaozer under Centos, PHP |
来源 :开源ISPCP社区 http://www.ispcpcn.com/article/13/
CentOS5.3的php版本默认为5.1.6,然后在5.2.9版本之前的的php都存在一个漏洞,但是目前网上很多地方都无法使用yum update php*升级到5.2.9,比较常见的是升级到5.2.6版本的,经过搜索国外资料,现在终于找到一种升级CentOS的php到5.2.9的方法。
注意,此方法只能在官方的php版本上升级,如果你使用网上的升级到5.2.6版本的升级方法已经升级了,将无法使用本方法升级php。
运行下面命令:
wget http://download.fedora.redhat.com/pub/epel/5/i386/epel-release-5-3.noarch.rpm
wget http://rpms.famillecollet.com/enterprise/5/remi/i386/remi-release-5-7.el5.remi.noarch.rpm
rpm -Uvh remi-release-5*.rpm epel-release-5*.rpm
然后编辑/etc/yum.repos.d/remi.repo
#vi /etc/yum.repos.d/remi.repo
在这个文件的最后增加一行:
priority=1
保存退出。
/etc/yum.repos.d/epel.repo和/etc/yum.repos.d/epel-testing.repo这两个文件也按照上面的方法进行编辑!
使用下面的命令进行升级,但是经过测试,如果单独升级php将提示失败,只有联通mysql一起升级才可以,所以我们必须执行以下命令才能升级php到5.2.9版本:
yum –enablerepo=remi update php* mysql*
| 2008,7月 8 | Posted by yaozer under PHP |
由于oscommerce 和 zen-cart 都需要cURL 支持,故尝试在Ubuntu上安装cURL for PHP5。
准备先在笔记本上测试通过后再安装到51kaiyuan.com服务器. 笔记本运行的是Ubuntu Destop 8.04, 服务器上跑的是Ubuntu Server 8.04,估计应该出入不大。
安装命令: sudo apt-get install curl libcurl3 libcurl3-dev php5-curl
在Ubuntu Destop 8.04上安装时由于存在依赖关系错误,始终无法安装。曾强行安装,貌似成功,但实际没有。
不得已,只能冒险在服务器上直接安装了。在Ubuntu Server 8.04 安装出人意料的顺利,很快就安装成功了,暗自庆幸rp不错。计划晚上装一下zen-cart, oscommerce进行验证。
最新评论