Submitted by admin on 2011, April 7, 9:05 PM
和Spreadsheet_Excel_Writer类似,Spreadsheet_Excel_Reader是用来读取Excel内容的工具。
可以方便的将Excel数据导入到数据或者其他用途。
如下代码:
<?php
//调用Reader
require_once 'Spreadsheet/Excel/Reader/reader.php';
//创建 Reader
$data = new Spreadsheet_Excel_Reader();
//设置文本输出编码
$data->setOutputEncoding('GB2312');
//读取Excel文件
$data->read("c:\test.xls");
//$data->sheets[0]['numRows']为Excel行数
for ($i = 1; $i <= $data->sheets[0]['numRows']; $i++) {
//$data->sheets[0]['numCols']为Excel列数
for ($j = 1; $j <= $data->sheets[0]['numCols']; $j++) {
//显示每个单元格内容
echo $data->sheets[0]['cells'][$i][$j];
}
}
?>
另,由于日期型的特殊性,在取值时可能会产生错误,可将Excel单元格类型设为Text,
将日期以文本形式读取,如需日期型字符再通过PHP对其进行处理即可(strtotime()结合date())。
php | 评论:0
| Trackbacks:0
| 阅读:907
Submitted by admin on 2011, April 7, 8:49 PM
aria2 是 Linux 下一个不错的高速下载工具。由于它具有分段下载引擎,所以支持从多个地址或者从一个地址的多个连接来下载同一个文件。这样自然就大大加快了文件的下载速 度。aria2 也具有断点续传功能,这使你随时能够恢复已经中断的文件下载。除了支持一般的 http(s) 和 ftp 协议外,aria2 还支持 BitTorrent 协议。这意味着,你也可以使用 aria2 来下载 torrent 文件。
安装 aria2
aria2 目前已被包含到许多 Linux 发行版中,因此你可以通过所用的系统直接加以安装。例如,在 Debian/Ubuntu 中,你可以在终端执行如下指令来安装 aria2:
sudo apt-get install aria2
如果你使用 Fedora Core,那么可以使用下列命令:
sudo yum install aria2
你也可以获取 aria2 的源代码,自行编译安装。当前 aria2 的最新版本为aria2-1.10.8.tar.gz,可从这里下载。
aria2 的使用方法
aria2 是命令行程序,使用非常简单。
- 一般使用 使用 aria2 下载文件,只需在命令后附加地址即可。如:
aria2c http://www.kernel.org/pub/linux/kernel/v2.6/linux-2.6.22.6.tar.bz2
- 分段下载 利用 aria2 的分段下载功能可以加快文件的下载速度,对于下载大文件时特别有用。为了使用 aria2 的分段下载功能,你需要在命令中指定 s 选项。如:
aria2c -s 2 http://www.kernel.org/pub/linux/kernel/v2.6/linux-2.6.22.6.tar.bz2
这将使用 2 个连接来下载该文件。s 后面的参数值介于 1~5 之间,你可以根据实际情况选择。
- 断点续传 在命令中使用 c 选项可以断点续传文件。如:
aria2c -c http://www.kernel.org/pub/linux/kernel/v2.6/linux-2.6.22.6.tar.bz2
- 下载 torrent 文件 你也可以使用 aria2 下载 BitTorrent 文件。如:
aria2c -o gutsy.torrent http://cdimage.ubuntu.com/daily-live/current/gutsy-desktop-i386.iso.torrent
关于 aria2 的更多用法,可以通过 man aria2c 查阅。
linux | 评论:0
| Trackbacks:0
| 阅读:937
Submitted by admin on 2011, April 7, 8:48 PM
1)Linux下有许多软件可以从终端进行BT下载。rtorrent 可能是其中最使用简单而且使用范围广的。下载时,你只需要向他提供简单的种子文件地址而不需要下载整个种子文件。比如:rtorrent <torrent文件地址>
rtorrent是高度自定义化的。默认情况下,你可以编辑位于~.rtorrent.rc的配置文件来对它进行设置。你也可以用这样的命令:rtorrent -n -o import=~/自定义.rc来为rtorrent指定你自己的自定义设置文件。
一些特殊情况下你可以使用自己的设置文件,而默认情况下rtorrent不加载设置文件。
在线程中暂停和恢复下载:session = ~/Download/session
为新的下载监视目录:schedule = watch_directory,10,10,load_start=~/Download/watch/*.torrent
在下载结束后移动文件:on_finished = move_complete,”execute=mv,-u,$d,get_base_path=,~/Download/ ;d.set_directory=~/Download/”
到达上传限额后停止上传:schedule = ratio,60,60,”stop_on_ratio=200,50M,300”
完整的选项和下载请看下面的网站:http://libtorrent.rakshasa.no/
2)另一个重要的BT下载工具Transmission也有命令行版本。使用transmission下载文件,你需要提供已下载的种子文件,而不像rtorrent那样只提供一个链接。比如:transmissioncli /home/pays/Desktop/test.torrent
此外,你可以使用-d和-u选项自定义下载和上传的速度限制。Transmission为Debian准备的命令行版本可以从这里下载:http://packages.debian.org/unstable/net/transmission-cli
3)命令行下载BT的的三个选择是ctorrent。虽然它在2006年就停止研发了,不过在多数时候仍然可以正常工作。它使用和transmission的命令行版本类似的命令格式,比如:ctorrent /home/pays/Desktop/test.torrent你可以从ctorrent的网站来了解它的更多信息:http://ctorrent.sourceforge.net/
linux | 评论:0
| Trackbacks:0
| 阅读:843
Submitted by admin on 2011, April 7, 5:53 PM
修改方法:
/etc/sysctl.conf文件中加入
kernel.panic = 30 #panic错误中自动重启,等待时间为30秒
kernel.sysrq = 1 #激活Magic SysRq! 否则,键盘鼠标没有响应
linux | 评论:0
| Trackbacks:0
| 阅读:1416
Submitted by admin on 2011, April 3, 9:35 PM
if [[ "$1" =~ "^[0-9]+$" ]] ;then
TEST=`echo $num|sed 's/[0-9]//g'`
if [ "$TEST" != "" ]
shell | 评论:0
| Trackbacks:0
| 阅读:905
Submitted by admin on 2011, April 3, 2:08 AM
在使用PHP过程中发现,自己编写的php代码因为都是源代码方式放在服务器上的所以很容易就被别人拿走随便修改(变成自己开发的)使用了。
为了保住自己的劳动成果,我一直寻找一种可以加密php代码的软件。
最著名的就是Zend公司的Zendencoder了,但是不是开源软件(要价很高,也没有找到破解版)。
既然收费的用不起,我们就用开源的。我找到了php_screw这个开源软件,目前最新版本是1.3
网址
http://sourceforge.net/projects/php-screw/
我的安装环境
系统:Slackware 10
软件:Apache 1.3.31
PHP 4.3.7
以上环境全部是slackware 10默认安装后自带的。具体的Apache+php+mysql安装方法参照如下
支持php的Apache环境安装
获得软件
下载php_screw-1.3 (http://prdownloads.sourceforge.net/php-screw/php_screw-1.3.tgz?download)
安装
1.将获得的php_screw-1.3.tgz文件放到/usr/local目录下,然后用tar解压缩
tar zxvf php_screw-1.3.tgz
2.进入/usr/local/php_screw-1.3目录开始安装
cd /usr/local/php_screw-1.3
phpize
./confiugre
3.设置自己用来加密的密码
vi my_screw.h
-- Please change the encryption SEED key (pm9screw_mycryptkey) into the
values according to what you like.
The encryption will be harder to break, if you add more values to the
encryption SEED array. However, the size of the SEED is unrelated to
the time of the decrypt processing.
* If you can read and understand the source code, to modify an original
encryption logic will be possible. But in general, this should not
be necessary.
OPTIONAL: Encrypted scripts get a stamp added to the beginning of the
file. If you like, you may change this stamp defined by
PM9SCREW and PM9SCREW_LEN in php_screw.h. PM9SCREW_LEN must
be less than or equal to the size of PM9SCREW.
4.编译
make
5.拷贝modules目录下的php_screw.so文件到/usr/lib/php/extension目录下
cp modules/php_screw.so /usr/lib/php/extension/
6.编辑php.ini文件
在php.ini文件里,加入如下语句
extension=php_screw.so
7.重新启动Apache
/etc/rc.d/rc.httpd restart
8.编译加密工具
cd tools
make
9.将tools目录下加密用的工具screw拷贝到适当目录
cp screw /usr/bin/
经过以上的10步,就已经把php_screw-1.3全部安装完成了。并且现在的php也已经支持解释加密过的php文件了
使用
1.现写一个要加密的php文件。
我写了如下的一个用来测试php速度的compute.php文件
<?
$a=0;
$t=time();
for($i=0;$i<5000000;$i++)
{$a=$a*$i;}
$t1=time();
echo "<p>";
echo "It used:";
echo $t1-$t;
echo "seconds";
?>
将上面的compute.php文件放到/var/www/htdocs目录下。通过浏览器访问,将显示出php在大量计算时的速度(只能粗略估计一下)
2.将我们写的php文件加密
cd /var/www/htdocs/
screw compute.php
我们加密后,现在目录下的compute.php文件就是我们已经加密的了。而源文件被改名为compute.php.screw存放了。
我们现在再测试一下compute.php,看看能否正常使用?速度如何?
我比较了一下,加密前后的速度大概一样,基本没有太多的损失。
php | 评论:0
| Trackbacks:0
| 阅读:879