按月份归档:7 月 2013

以前做的采集QQ号码程序

<?php
header("Content-type: text/html; charset=utf-8");
require_once 'database.php';
//set_time_limit(0);
//ignore_user_abort();
function writelog($log){
	$log_file="rizhi.txt";
	$fp = fopen($log_file,'a');
	fwrite($fp,date("Y-m-d H:i:s",time())."		".$log."\r\n");
	fclose($fp);
}
function writelog2($log){
	$log_file="QQMAIL.txt";
	$fp = fopen($log_file,'a');
	fwrite($fp,$log."\r\n");
	fclose($fp);
}
ignore_user_abort();           // 即使Client断开(如关掉浏览器),PHP脚本也可以继续执行.
set_time_limit(0);             // 执行时间为无限制,php默认的执行时间是30秒,通过set_time_limit(0)可以让程序无限制的执行下去

$bb = 0 ;
writelog('开始采集!');
echo '开始采集!<br><hr>';

for($nl=24;$nl<=30;$nl++){//年龄
	$nl++;
	$nl2=$nl +1;
	for($yue=1;$yue<=12;$yue++){//月
		for($ri=1;$ri<=31;$ri++){//日
			for($i=0;$i<100;$i++){//页数
				$jishu =$i+1;
				echo "<font color = red>最低年龄:".$nl."最高年龄:".$nl2."     ".$yue."月".$ri."日  ".$jishu."%</font>";
				echo "<br>";
				writelog("最低年龄:".$nl."最高年龄:".$nl2."     ".$yue."月".$ri."日  第".$i."页");
				$url="http://soren.qzone.qq.com/cgi-bin/soren/cgi_userinfo_search?sex=-1&a1=".$nl."&a2=".$nl2."&pv=11&ct=1100&hp=0&hc=0&at=-1&month=".$yue."&day=".$ri."&mr=-1&bt=-1&cr=&cn=&cap=0&cac=0&idol=&game=&it=&sport=&book=&tv=&cloth=&cosm=&place=&interest=&begin=".$i."&bSimple=0";
				$ch = curl_init();
				curl_setopt ($ch, CURLOPT_URL, $url);
				curl_setopt ($ch, CURLOPT_RETURNTRANSFER, 1);
				curl_setopt ($ch, CURLOPT_CONNECTTIMEOUT,10);
				$content = curl_exec($ch);
				preg_match_all('/id=\"portrait_(.*?)\" onclick/is',$content,$qq);
				foreach($qq[1] as $value){

					$coolaj = trim($value)."@qq.com";
					$sql = "select * from mail where mails = '".$coolaj."'";
					$rs2 = mysql_query($sql, $connect) or die("Invalid query: " . mysql_error());
					$cool =  mysql_fetch_row ($rs2);
					if(is_array($cool)){
						writelog("插入失败->".$coolaj."已经存在!");
					}else{
						$rs = mysql_query("insert into mail VALUES('','".$coolaj."','".$i."','QQ采集')", $connect) or die("Invalid query: " . mysql_error());
						if($rs){
							$bb++;
							echo $showtime=date("Y-m-d H:i:s");
							echo "插入<font color=red>第".$bb."个</font><font color=blue>".$coolaj."</font>成功!<br>";
							writelog("插入第".$bb."个".$coolaj."成功!");
							writelog2($coolaj);
						}else{
							writelog("插入".$coolaj."失败!");
						}
					}

				}
			}
		}
	}
}
echo "<script>alert('采集完成!')</script>";

 

<?php
$_POST=sql_injection($_POST);
$_GET=sql_injection($_GET);
function sql_injection($content)
{
 if (get_magic_quotes_gpc())
 {
  if (is_array($content))
  {
   foreach ($content as $key=>$value)
   {
    $content[$key] = str_replace("'","\"",stripslashes($value));
   }
  }
  else
  {
    $content[$key] = str_replace("'","\"",stripslashes($content));
  }
 }
 return $content;
}

$hostname_conn = "localhost";
$database_conn = "test";
$username_conn = "root";
$password_conn = "";
$connect = mysql_pconnect($hostname_conn, $username_conn, $password_conn,true) or trigger_error(mysql_error(),E_USER_ERROR);
mysql_select_db($database_conn, $connect);
mysql_query("set NAMES 'UTF8'");
date_default_timezone_set('PRC');
?>

 

Nginx负载均衡[转]

最近迷上了Nginx,真实麻雀虽小,五脏俱全..功能实在强大..

nginx不单可以作为强大的web服务器,也可以作为一个反向代理服务器,而且nginx还可以按照调度规则实现动态、静态页面的分离,可以按照轮询、ip哈希、URL哈希、权重等多种方式对后端服务器做负载均衡,同时还支持后端服务器的健康检查。

如果只有一台服务器时,这个服务器挂了,那么对于网站来说是个灾难.因此,这时候的负载均衡就会大显身手了,它会自动剔除挂掉的服务器.

下面简单的介绍下我使用Nginx做负载的体会

下载—安装Nginx这些不介绍了,前篇有介绍.

windows和Linux下配置Nginx负载的写法一样,故不分开介绍.

阅读全文 ……