分享、学习、提高
国际流行建站组合,学习中。。。
2008/08/18 20:52
Tags: , ,
从朋友那拿到一份代码,用CURL模拟用户登录并采集需要用户登录的页面的。
<?php
$cookie_jar = tempnam('./tmp','cookie');
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL,'登陆地址');
curl_setopt($ch, CURLOPT_POST, 1);
$request = 'username=xxx&pwd=xxx';
curl_setopt($ch, CURLOPT_POSTFIELDS, $request);//传递数据
curl_setopt($ch, CURLOPT_COOKIEJAR, $cookie_jar);//把返回来的cookie信息保存在$cookie_jar文件中
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);//设定返回的数据是否自动显示
curl_setopt($ch, CURLOPT_HEADER, false);//设定是否显示头信息
curl_setopt($ch, CURLOPT_NOBODY, false);//设定是否输出页面内容
curl_exec($ch);
curl_close($ch); //get data after login

$ch2 = curl_init();
curl_setopt($ch2, CURLOPT_URL, '查看地址');
curl_setopt($ch2, CURLOPT_HEADER, false);
curl_setopt($ch2, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch2, CURLOPT_COOKIEFILE, $cookie_jar);
$orders = curl_exec($ch2);

echo $orders;
curl_close($ch2);// 实践证明很稳定:)
?>


先在本机测试,在php.ini中去掉了extension=php_curl.dll前面的;,查看一下phpinfo(),并没有curl。
查了下文档,
引用
Note to Win32 Users: In order to enable this module on a Windows environment, libeay32.dll and ssleay32.dll must be present in your PATH.

将libeay32.dll 和ssleay32.dll复制到system32下,重启apache,刷新phpinfo(),看到了curl。
引用
cURL support  enabled  
cURL Information  libcurl/7.16.0 OpenSSL/0.9.8d zlib/1.2.3

本机测试顺利通过,再去服务器上测试。原没装curl,只好重新编译php。
在原编译参数后面加了--with-curl=/usr/local/curl。
我这次的配置是:
./configure '--prefix=/usr/local/php5' '--with-apxs2=/usr/local/apache2/bin/apxs' '--with-mysql=/usr/local/mysql' '--with-gd=/usr/local/gd' '--with-zlib' '--with-png' '--with-jpeg-dir=/usr/local/jpeg' '--with-freetype-dir=/usr/local/freetype' '--enable-sockets' '--with-iconv' '--enable-mbstring' '--enable-track-vars' '--enable-force-cgi-redirect' '--with-config-file-path=/usr/local/php5/etc' --with-curl=/usr/local/curl
很快OK。phpinfo显示
引用
CURL support  enabled  
CURL Information  libcurl/7.12.1 OpenSSL/0.9.7a zlib/1.2.3 libidn/0.5.6


感觉挺好用的:)
2008/08/14 22:30
Tags:
因为一些原因,对数据库进行了迁移,可能是在操作时由于使用了kill来结束mysqld,导致了一些数据损坏。

迁到新数据库后,以下是是些错误信息。

Warning: mysql_query(): Unable to save result set in /www/hx/include/db_mysql.class.php on line 58

SQL: select count(0) from hx_subject where isdel=0 and classid=9
Error: Got error 134 from storage engine
Errno.: 1030

最后,用myisamchk和optimize table tablename等方法,全部修复完成。

一般优化表后的提示是OK,如下表:

mysql> OPTIMIZE TABLE `hx_focus`;
+----------------+----------+----------+----------+
| Table          | Op       | Msg_type | Msg_text |
+----------------+----------+----------+----------+
| dashi.hx_focus | optimize | status   | OK       |
+----------------+----------+----------+----------+

但这个表发现提示:Table is already up to date 。
mysql> OPTIMIZE TABLE `hx_key`;
+--------------+----------+----------+-----------------------------+
| Table        | Op       | Msg_type | Msg_text                    |
+--------------+----------+----------+-----------------------------+
| dashi.hx_key | optimize | status   | Table is already up to date |
+--------------+----------+----------+-----------------------------+

查了下:Table is already up to date means that the storage engine for the table indicated that there was no need to check the table.
原来是不需要检查,挺好:)

另外,关闭数据库最好不要用kill,很容易造成数据损坏。建议使用:
bin/mysqladmin -u root shutdown

/usr/local/mysql/support-files/mysql.server stop


----------------------------------------------------------------------------------------
web在厦门,mysql数据库在北京后,这几天经常出现连接数据库 Too many connections。
经分析,怀疑是远程连接容易造成Too many connections。

用show processlist查看,发现大量的unauthenticated user,可能占了99%。。。

查了一下,解决办法有二:
1、启动时带参数  --skip-name-resolve
2、访问的主机授权时用IP,最好把该主机的IP及主机名写到/etc/hosts文件中
可参阅:http://www.itlearner.com/article/2008/4184.shtml

原启动方式:
/usr/local/mysql/bin/mysqld_safe --max_connections=500 --max_connect_errors=50000 --user=mysql --maximum-wait-timeout=100 --maximum-interactive_timeout=100 &

更新后启动方式:
/usr/local/mysql/bin/mysqld_safe --max_connections=500 --max_connect_errors=50000 --user=mysql --maximum-wait-timeout=100 --maximum-interactive_timeout=100 --skip-name-resolve &

重启后问题解决:)

---------------------------------------------------------------------------------------

删除一个用户的权限
revoke all on *.* from hxtest@localhost;
delete from mysql.user where user='hxtest' and host='localhost';
可以用show grants for hxtest,来查看hxtest已有的权限。
2008/07/12 18:59
Tags:
帮朋友linux服务器配置点东西,差点忘了怎么装FTP了。这次把安装配置的流程记录了下来,以供以后参考。

第一步:安装
proftpd是国外软件,官方主页为http://www.proftpd.org,但直接在其网站上下载非常慢。因此我整理到了我的下载站上,地址:http://down.itlearner.com/soft/2363.shtml。目前稳定版本是proftpd-1.3.1。我这次是用proftpd-1.3.0来安装的。
解压
tar zxvf proftpd-1.3.0.tar.gz
切换目录
cd proftpd-1.3.0/
配置,其它Web软件机房的人都装到了webserver目录下,因此这个也装到此目录下。
./configure --prefix=/usr/local/webserver/proftpd --enable-shadow
编译
make;make install
装好,开始配置

第二步:配置
由于上一步将proftpd安装在了/usr/local/webserver/proftpd下,因此,配置文件为:/usr/local/webserver/proftpd/etc/proftpd.conf。将修改FTP的设置的话,一般就是修改这个文件。

Group nogroup 改为Group nobody
#DefaultRoot ~前面的#去掉
下面加上三条
DelayEngine off
IdentLookups off
UseReverseDNS off
起加速作用,具体作用请参见我以前的文章:加速proftpd http://www.9enjoy.com/post/59/

在AllowOverwrite on下加
AllowRetrieveRestart    on
AllowStoreRestart       on
允许断点续传用的。

将要成为ftp根目录的目录设置为允许,我的是/data0。
<Directory /data0/>
        AllowAll
</Directory>

好了,配置就基本完成了。
启动它:/usr/local/webserver/proftpd/sbin/proftpd
一般要在开机时让它自动启动,在/etc/rc.local加上这句即可。

创建一个FTP用户(我这偷懒,一个FTP用户搞定服务器上所有站点,所以直接指向web根目录)
创建用户
useradd ftphx -s /sbin/nologin -d /data0/
设置密码
passwd ftphx
将这个目录下的文件属性改为ftphx所有,以便其有所有读、改、删的权限。
chown -R ftphx:ftphx /data0/
具体可参见我以前的文章:开设站点流程 http://www.9enjoy.com/post/158/

好了,完成了:)

说明一下,不管是什么系统什么软件搭建的FTP,使用的客户端软件是一样的,比如我都用cuteFtp。
2008/07/10 10:25
Tags: ,
默认在linux下是没rar的解压软件的,因此一般本地压缩使用winrar,选择压成ZIP后上传,使用unzip来解压。
但昨天下了一个大文件rar文件,没办法,只好去找来linux下的rar解压软件,来完成解压。

还找了一段时间,才找到。发到软件下载那边共享,rarlinux下载

这个是3.6.0的版本
tar -zxf rarlinux-3.6.0.tar.gz
cd rarlinux-3.6.0
make
没看到configure,所以就直接make了。

解压hx.rar文件:
rar x hx.rar

具体参数可以rar -h查看,下面例出一些。
RAR 3.60   Copyright (c) 1993-2006 Alexander Roshal   5 Aug 2006
Shareware version         Type RAR -? for help

Usage:     rar <command> -<switch 1> -<switch N> <archive> <files...>
               <@listfiles...> <path_to_extract\>

<Commands>
  a             Add files to archive
  c             Add archive comment
  cf            Add files comment
  ch            Change archive parameters
  cw            Write archive comment to file
  d             Delete files from archive
  e             Extract files to current directory
  f             Freshen files in archive
  i[par]=<str>  Find string in archives
  k             Lock archive
  l[t,b]        List archive [technical, bare]
  m[f]          Move to archive [files only]
  p             Print file to stdout
  r             Repair archive
  rc            Reconstruct missing volumes
  rn            Rename archived files
  rr[N]         Add data recovery record
  rv[N]         Create recovery volumes
  s[name|-]     Convert archive to or from SFX
  t             Test archive files
  u             Update files in archive
  v[t,b]        Verbosely list archive [technical,bare]
  x             Extract files with full path

最新的版本可以去官方获取,官方主页是:http://www.rarlab.com

2008/07/04 13:03
Tags: ,
今天又有人问我怎么重置DEDE的管理员密码,我说那我写一个。
dedecms v5的密码,之前就有看过,是MD5后的前24位,而之前的版本可能不是。
于是,很快写了一个简单的小程序,上传上来,应该也有人用得到::)



解压后放在根目录,运行后密码即重置为123456。重置完后,请立刻删除这个文件,并登录后台修改密码!一定要删除这个文件,以防被他人运行再次重置密码。
分页: 1/14 第一页 1 2 3 4 5 6 7 8 9 10 下页 最后页 [ 显示模式: 摘要 | 列表 ]