浏览模式: 标准 | 列表 全部文章

显示网站目录下所有文件的PHP程序

一个简单的脚本,运行在PHP环境下,方便列出目录下的所有文件(以下代码为列出当前与脚本同目录的文件,可以自行修改opendir("./"))这个相对路径达到显示其他路径下文件的效果)

  • <?php
  •    echo "<li>download files list<li>";
  •    if ($handle = opendir("./"))
  •    {
  •       while (1)
  •       {
  •             $ufile = readdir($handle);
  •             if ($ufile == "") break;
  •             if (($ufile!=".")&($ufile!= ".."))
  •             {
  •                   $tfile=iconv('GB2312', 'UTF-8', $ufile);
  •                   echo "<li><a href='".$config_basedir_file.$tfile."'>URL+".$tfile."</a></li>";
  •             }
  •       }
  • }
  • ?>

抛开体力劳动Linux下bash双重循环下载文件

需求:有一个网站,提供视频在线播放,视频格式为flv,视频路径直接写在网页源代码中,而视频路径每一次的请求都不一样,比如某个视频在网页源代码中的地址为:http://url/dl/88bd09b075a2033d8b515fae13398253/4f0fa279/1.flv,每一次刷新页面查看源代码,代码中dl后和1.flv之间的代码就会改变,系统这样生成的随机地址就是防盗链,而经测试,如果所生成的视频flv地址在经过三五分钟未经引用(播放),那么该地址就会失效,需要重新刷新页面获得地址,正因为如此,所以用不了迅雷,只能自己写个程序多线程一个个视频下载,每次下载前都是获得新请求到的视频地址。

基于此,在Linux下写一个bash程序,构造双重循环下载视频文件,考虑到系统自带的wget下载工具单线程太不给力,正冰简单写的这个就直接用了《Linux下多线程下载工具推荐:myget》。

程序功能如下(程序命名为zb,以下同):

  1. 先判断程序是否将下载列表跟到程序后面
  2. 将下载列表里的下载网址取出
  3. 使用curl获取页面源代码并将flv一行的数据单独导出到tmp文件,这里填出该行数据:so.addVariable('file','http://url/dl/88bd09b075a2033d8b515fae13398253/4f0fa279/1.flv');
  4. 然后将视频完整地址通过sed命令提取出来并输出到tmp2文件
  5. 调用mytget工具将tmp2中的视频地址进行多线程下载

程序使用方法:

  1. 先使用vi编辑器将待下载的网页地址写入到一个文本中(建立待下载的下载列表),一行一个目标网址(这些网址可以使用类似火车采集器这类软件先批量抓取下来),保存为list文件名
  2. 使用$./zb list 命令下载(多线程下载工具采用10线程进行下载,速度不错)
  3. 等待程序完成下载

程序代码:

  • if [ "$1" == "" ]; then
  •     printf "need url list"
  •     exit 1
  • fi
  •  
  • for x in $(cat $1)
  • do
  •     curl $x | grep flv>tmp
  •     cat tmp  | sed "s/\(.*\),'\(.*\)'\(.*\)/\2/g">tmp2
  •         for y in $(cat tmp2)
  •         do
  •         mytget -n 10 $y
  •         done
  • done
  •  
  • rm -rf tmp*
  • rm -rf $1

     

Linux下使用wget工具下载整站

有时候为了方便模仿某些网站,需要使用下载整站工具把模板网站所有可索引(访问)的资源下载下来,并保存成与服务器相同的目录结构。

正冰给大家介绍一种简便的工具,那就是linux下的wget工具,使用方法: 

wget -r -p -np -k  URL

  • -r:在本机建立服务器端目录结构;
  • -p: 下载显示HTML文件的所有图片;
  • -np:只下载目标站点指定目录及其子目录的内容;
  • -k: 转换非相对链接为相对链接。

比如需要下载本站某篇文章的所有资源,网址为http://blog.is36.com/linux_wget_tool_download_website/

那么命令就是:wget -r -p -np -k http://blog.is36.com/linux_wget_tool_download_website/

也就是从当前页面开始镜像整个网站到本地,使用这个工具下载整站的好处是:下载的资源纯净(某些商业软件在未注册情况下会在网页里加版权)、方便;坏处就是单线程比较慢,只适合下载简单的网站。

当然,windows下也有wget工具,去搜索下载吧,下载后的使用方法跟linux下一样。

Tags: linux, wget

Linux VPS快速搭建magento环境与迁移magento网站

手头管理的某台vps因为特殊原因不能继续使用了,挂在其上基于LAMP环境的magento网站需要迁移到新的VPS上,本文就magento程序的特殊性,记录一下新环境的快速搭建以及迁移magento网站。新VPS系统是centos 5 32bit,以下操作都是基于此。

首先为新VPS快速搭建运行magento程序必须的LAMP环境,首先安装:

# wget -c http://dl.wdlinux.cn:5180/lanmp_v20.tar.gz

# tar zxvf lanmp_v20.tar.gz

#sh in.sh (选择1回车:apache + php + mysql + zend + eAccelerator + pureftpd + phpmyadmin)

安装pdo_mysql扩展(magento必须)

# wget http://pecl.php.net/get/PDO_MYSQL-1.0.2.tgz

tar zxvf PDO_MYSQL-1.0.2.tgz

cd PDO_MYSQL-1.0.2

/www/wdlinux/php/bin/phpize

./configure --with-php-config=/www/wdlinux/php/bin/php-config --with-pdo-mysql=/www/wdlinux/mysql

make && make install

#echo "extension=pdo_mysql.so">>/www/wdlinux/etc/php.ini

#service httpd restart (重启apache使扩展生效)

# /www/wdlinux/php/bin/php -m (通过此命令可以看到php所加载的扩展,包括pdo_mysql,有问题可以根据提示进行修改,比如路径错误导致找不到,则建立正确的扩展路径,错误修改后再次执行上一条命令使扩展生效。

lanmp_v20.tar.gz已经配置集成了rewrite规则与innodb存储引擎的配置信息,方便了部署,所以快速完成环境搭建之后就可以开始迁移magento网站:

  1. 在新的VPS上建立与旧VPS一样的网站配置(网站、数据库、配置文件)
  2. 将旧VPS与新VPS的mysql数据库停用,在旧VPS上打包mysql数据库:mysqldump -h localhost -uroot -p magento > /root/magento_db.sql
  3. 采用最直接省事的scp工具进行迁移,因为旧VPS的ssh默认端口被我修改为2222,所以命令有所改变,先迁移网站:scp -r  -P 2222 root@8.8.8.8:/www/web/magento/public_html/ /www/web/magento/public_html/
  4. 再迁移数据库:scp -r  -P 2222 root@8.8.8.8:/root/magento_db.sql /root/
  5. 将数据库导入:mysql -h localhost -uroot -p magento < /root/magento_db.sql (之前测试过直接打包数据库迁移过来解压缩到数据库存储目录不成功,只能如此)
  6. 启动新VPS上的mysql服务,将域名解析到新VPS,解析生效后测试网站是否正常

迁移后的提醒:

  • 迁移网站后如果无法正常访问,而是跳转到默认模板之类的情况发生,将网站的errors目录下的local.xml.sample修改为local.xml,刷新后就可以看到出错提示。
  • 网站使用了rewrite,但是打开产品页面却跳转404页面,那么就手动将magento的.htaccess传到网站根目录。

Tags: linux, vps, magento, pdo_mysql

linux mysql密码遗忘丢失找回来的方法

以下命令需要在root权限下执行:

首先要停止mysql服务,看一下mysql使用说明(启动、停止、重启、重启、重载、强制重载、状态),如下: 

# /etc/init.d/mysql

Usage: /etc/init.d/mysql  {start|stop|restart|reload|force-reload|status}  [ MySQL server options ]

停止mysql服务:

# /etc/init.d/mysql stop

执行mysql下的mysqld_safe,跳过权限与网络设置启动(以便下一步无须权限就可以进入数据库操作)

# /usr/local/mysql/bin/mysqld_safe --user=mysql --skip-grant-tables --skip-networking &

使用mysql命令直接进入mysql数据库进行操作: 

# mysql -u root mysql

mysql> UPDATE user SET Password=PASSWORD('NewPassword') where USER='root';

mysql> FLUSH PRIVILEGES;

mysql> quit 

重启mysql服务使得mysql恢复正常运行:

# /etc/init.d/mysql restart

尝试用新密码登陆操作:

# mysql -uroot -p

Enter password: <输入重置的密码NewPassword>

简单几步,重置mysql密码。

Tags: mysql

在京东商城(360buy)买飞机票有惊喜

以前一直在淘宝旅行(jipiao.trip.taobao.com)买飞机票,方便、安全、快捷,这次综合对比下来发现一直网购的B2C网站京东商城的机票业务(jipiao.360buy.com)也非常给力,买机票直减现金(最高6%),还赠送最高50万航空意外伤害保障,活动时间2011.12.20-2011.12.31

简单对比了下,热门路线都是在票面价基础上都是直减6%,比如杭州至昆明、上海至昆明均是如此。而本次正冰购买的路线却因为非热门,只减了2.5%,1360元票面价,再减34元。

凭电子票号到www.travelsky.com查了下,发现京东代理了芒果网(www.mangocity.com)的机票。 

  • 机票销售单位名称:芒果网有限公司北京分公司
  • 地址:北京市朝阳区朝外雅宝路12号华声国际大厦18层02房间
  • 联系电话:010-85639918
  • 代理编号(Office号):PEK408
  • 国际航协代码(IATA):08316840

Tags: 京东商城, 360buy

为为网好不好?又似买特网第二!

买特网(www.360mart.com)是出了名的慢,一直在模仿京东,包括域名,但是却从未能超越它……

以前在买特网买过硬盘一个,拖了一周才给发货,伤不起,有木有?!

现在好了,出来一个为为网(www.homevv.com)与淘宝合作,还在Google Adwords上砸了蛮多钱做广告的(甚至包括正冰这个博客都显示它的广告,当然这个跟我最近不断访问它网站也有关系)。

好啦,接下来说下在这家网站的购物经历,真够悲剧的。


6号晚上(2011-12-06 23:54)单子买了个路由器(TP-LINK TL-WR941N 300M 无线宽带路由器),显示价格229元,用了公用券weiwei减22,再用去一张叠加券减20(淘宝5.4元购入),最终消费192.4元(这个价格相比较别的商家而且开发票已经非常给力

想着快递运输里说明浙江用户当天17点前下单可以发货(预计7号会发出),结果到了8号仍未发出,找在线客服,居然还是个用拼音输入法,不断打错别字的,被告知“长时间未发货为缺货,需要下午联系采购”,心里觉着遇到了第二个买特网了!马上搜索了下,在EGOU上发现有很多人遇到发货延迟情况。

我明了:发大额抵价券,占用用户资金,长时间不发货……(典型的“买特网”兄弟)

8号当日,我致电为为网4006-698-698,被告知会询问过采购后给予答复,当天下午,接到02196806电话告知该商品将在9号(周五)入库,尽快发出。

10号晚上查询该商品未发出,11号早上该商品送至中通快递,12号中午收到(产品拣货是10号,开票时间为10号)。

经过这次在为为网的购物,我想说的是:

  1. 这是我第一次在为为网购物,体验非常差,很难让我再来进行第二次购物。
  2. 又一家典型的“买特网”(不了解买特网的童鞋百度一下)
  3. 不专业客服说出的不专业的话:“采购现在不在 下午可能会在”,尼玛什么叫“可能”,上班都这么随意涣散?难道不能直接电话联系一下?
  4. 你们QQ客服的签名是“为您所想,为您所求”,我只能说:靠!
  5. 没有货的产品,请礼貌地显示缺货,不要在那里让大家下单了却没及时收货,然后等客户联系了才说没有货,自己做大爷。(我只能说艹你大爷)
  6. 无论这次购物最终如何,为为网将同买特网一样,至少进入我的购物“黑名单”,其他童鞋请参考!

以上可能为个例,请勿对号入座,个人实际案例仅供参考。因为该商家优惠额度较大,如果有童鞋要买不急于用的东西可以考虑尝试下……

Tags: 为为网, 买特网

正冰提醒:天上不掉馅饼,谨防国际诈骗!

以前有收到邮件,一般都是说有一笔巨额遗产免费赠送给你,让你与他取得联系,这种骗术已经有点老掉牙了。类似案例见《男子收到国际诈骗信 邀其接受400万美元遗产

而最近正冰居然收到了新式诈骗邮件(其实也不新,都在变而已),类似案例见《从非洲来的邮件--女大学生收到国际诈骗信

下面开始简单叙述正冰收到诈骗信的整个过程:

  • 11月4日收到来自lindyKumikombeh@yahoo.com的邮件(主题为:HELLO)说想与我交个朋友,我看邮件写得像模像样,也不像robot发送的,就顺手回了一个。
  • 11月23日无意间发现她在11月6日已经回复了我的邮件,洋洋洒洒一大片文字,主题为:about me,内容就是介绍她现在的情况,附带3张照片。具体内容见附1。根据她的邮件我也回了个mail,扯淡一番。
  • 11月25日在想那人是不是又那么积极地回邮件了,就去看了下邮箱,果不其然,她已经在11月24日就回复了邮件,这次更加夸张,直接让我在一个约定的时间里给她打电话(+221777512477),还说会把一笔多达750万美元的25%赠送给我。邮件主题:please help me。具体内容见附2。我心里想,750W*.25*6.4=1200W人民币,还有比中500W的概率还高的事情?顺手Google了一下这个号码,显然已经被登记在骗子列表中了,此刻我已经确信这是骗子无疑了,然后我便回了一个邮件给她:“我通过google搜索+221777512477是一个骗子电话,你做何解释?”你懂得,估计不会有下文了,难道她还会积极地回复我说这不是骗局?哈哈!

整个过程讲完了,下面讲讲这次亲身体验的案例中需要注意的地方:

  • 骗子已经从原来直接说给你遗产转变成先以交朋友的想法跟你套近乎,继而告诉你她的近况然后直接一刀切说让你帮助她,她会把巨额财富给你。
  • 这类骗子一般邮件里常用的词语就是death certificate(死亡证明书)、+221777512477 (Senegal, probably a prepaid mobile phone)

遇到类似正冰这种情况请直接不要理会,有兴趣的可以做以下2点操作:

  • 去google搜索关键词,比如发送者邮箱(一般来说对方会骗一次换一次)、对方提供的号码、对方所说的地方。
  • 去http://www.scamomatic.com/把邮件粘贴进去,检查是不是诈骗邮件,另外你所提交的信息还能够帮助到更多的人。

我把附2的内容放到scamomatic检测,结果如下:

This email looks like an orphan scam.

The following phrases should put you on alert:

"i will like you to ":

a common phrase found in 419 scams

"death certificate":

this phrase is often used in inheritance scams such as next of kin or orphan scams.

This email lists mobile phone numbers. Use of such numbers is typical for scams because they allow criminals to conceal their true location. They can receive calls in an Internet cafe from where they send you emails, while pretending to be in some office.

+221777512477 (Senegal, probably a prepaid mobile phone)

Thank you for using Scam-O-Matic. If you found the results from this check useful then please mention www.scamomatic.com to your friends, family and co-workers, so they can also use it to check out and report suspicious emails that may have been sent to them by criminals.

Once you have received any scam emails, it means the scammers know your email address. You will probably receive further scam emails. Therefore we recommend that you bookmark www.scamomatic.com (Ctrl+D) in your web browser for when you may need it again.

DISCLAIMER: While we try to give appropriate advice in the greatest number of cases, we must decline responsibilty for any mistakes that may occur. We encourage you to do your own research on the internet (for example, search on Google) and using other information sources. Get informed, talk to people you trust (your family, friends, your bank, local police) and then act accordingly.

翻译成中文:

这封电子邮件看起来像一个孤儿的骗局。

以下短语应该放在提醒您:

“我会想你”:

419诈骗发现一个共同的短语

“死亡证明书”:

这句话经常被用来在继承诈骗,如近亲或孤儿诈骗。

此电子邮件列出了手机号码。使用这样的数字是典型的为诈骗,因为它们允许犯罪分子隐瞒自己的真实位置。他们可以从网吧,在那里他们会给您发电子邮件接收呼叫,同时假装在一些办公室。

221777512477(塞内加尔,可能是预付费手机)

感谢您使用诈骗- O - MATIC。如果您发现从这个检查非常有用的结果,然后请注明www.scamomatic.com给你的朋友,家人和同事,让他们也可以使用它来检查和报告可疑的电子邮件可能已被犯罪分子发送给他们。

一旦你收到任何诈骗邮件,这意味着诈骗者知道您的电子邮件地址。你可能会得到进一步的诈骗电子邮件。因此,我们建议您在您的网页浏览器的书签时,您可能需要再次www.scamomatic.com(按Ctrl + D)。

免责声明:虽然我们竭尽所能给予适当的意见数量最多的案件,我们必须拒绝任何可能发生的错误responsibilty。我们鼓励你在互联网上做自己的研究(例如,在Google上搜索)和使用其他来源的信息。了解详情,与人交谈,你信任你的家人,朋友,您的银行,当地警方,然后采取相应的行动。

附1:

Dear,

How are you today?,i hope fine. Mine is not very good due to my suffering condition here in Dakar Senegal. I'm Miss lindy Kumikombeh,am from a famiy of three and am the eldest,I am 24years old, single girl and never married, 5 feet tall, 60 kg weight, black hair and brown eyes, I am from libya but presently i am residing in Church  Camp here in Senegal, as a result of civil war that was fought in my country which made me to lost my both parents during this mortal Political War that kills thousands of innocent souls in Libya. my family was among the first target of the rebels, because my late father Dr Robert Kumikombeh has a successful company, he was the Chairman and the managing director Kumikombeh Agricultural Industrial Company Ltd in tripole the capital city of my country,,and also a politician supporting the current government,so when the mortal political crisis were about to start due to my father was a politician who was supporting the current government during that time in my country all members of my family was murdered in cold blood and our family home was set ablaze. I was lucky to escaped death.

Is just me and my junior brother that is alive now and we managed to make our way to Senegal where we are staying now and never pray or think about our legs to step in that bloody country again.

I would like to know more about you, tell me your hobbies and what are you doing presently? I will tell you more about me in my next email. i attach my picture for you,and i will be looking forward to hear from you soon.send to me yours picture as well

Yours

lindy

附2:

Hello my dear

How are you today? i hope fine thanks for your mail and i am glad to know you. Dear like you know, i am living in the Church camp here in Dakar-Senegal. In this camp, it's just like one staying in a lonely zone like prison and i hope by God's grace, I will come out here soon since i met some one like you because i don't have any relatives now whom i can go to . so i am living in the refugee camp female's hostel as the camp has two hostels one for boys the other for women. Please try to call me by 2.pm GMT time in the afternoon tomorrow.The Church camp telephone number is: (+221777512477) when you call tell Rev Patric Kotor  that you want to speak with Mis lindy so that he will send for me in the hostel. Please call me tomorrow i will love to hear your voice.

As a refugee here, I don't have any right or privileged to have an account here because it is against the law of this country and also i don't like this country for anything that's why i contact you. I will like to continue with my studies in Medical department in a good university in your country because i only attended my first year in University of Libya before the tragic incident that led to the death of my parents took place. Please listen to this, I have my late father's statement of account and death certificate here with me which i will send to you later, because when my father was alive he deposited some amount of money in a leading bank in Dakar Senegal, which he used my name as the next of kin and the amount is 7.5Million USD seven Million five Hundred Thousand Dollars). So i will like you to help me transfer this money to your account and from it you can send me some money for me to get my travelling documents and air ticket to come over and meet you in your country after the transfer of the money to your account. I keep this secret to people in the camp here and no one knows about it, except you now. So in the light of above i will like you to keep it to yourself and don't tell it to anyone, I will like you to send me your below information for me to know you more and know whom the bank is going to transfer my inheritance to his account.

Below here is what i need from you so that I will give you the bank contact information:

(1) Your Full name

(2) Phone Numbers

(3) Occupation

(4) House or office address.

I will give you 25% percent of my total inheritance for assisting me in this transfer and you will also help me in the area of investing the remaining fund in any good business you know that will be giving us profit,i will like to continue with my studies in my carrier in health sector as i was in the university of Libya as a medical student before the war incident that made me to be in this situation

of life after the death of my beloved parents.

I will love to meet you very soon and thanks for your regards,I will like you to call me,call around 2.00pm GMT time in the afternoon. I want to hear your voice. Have a nice day and think about me. Awaiting to hear from you soonest.

Yours

lindy

Tags: scam