<?php
function str_post($rows){
	foreach($rows as $k=>$row){
		$data.="$k=".urlencode($row)."&";
	}
	return rtrim($data,'&');
}

function send_mail($to, $sub, $msg, $config) {
	include_once 'smtp.class.php';
	$From = $config['mail_email'];
	$Host = $config['mail_host'];
	$Port = $config['mail_port'];
	$SMTPAuth = 1;
	$Username = $config['mail_email'];
	$Password = $config['mail_pwd'];
	$Nickname = $config['web_name'];
	$SSL = false;
	$mail = new SMTP($Host , $Port , $SMTPAuth , $Username , $Password , $SSL);
	$mail->att = array();
	if($mail->send($to , $From , $sub , $msg, $Nickname)) {
		return true;
	} else {
		return $mail->log;
	}
}

function send_active_mail($user,$mail,$do='SID',$qq,$config){
	$currtime=date("Y-m-d H:i:s");
	$sub="秒赞网{$do}过期提醒";//邮件标题
	$msg="<div style='width:700px; background-color:#FFF; border:1px solid #CCC; margin:20px auto; color:#333; font-family:Microsoft YaHei,微软雅黑; letter-spacing:0.04em; min-height:400px; overflow:hidden;'><div style='background-color:#03a5e8; height:70px;color:#FFF;'><img src='http://".$_SERVER['SERVER_NAME']."/logo.png' width='188' height='50' style='margin:10px auto 10px 10px; float:left;'/><div style='float:right; width:260px; height:50px; margin:10px; font-size:14px; overflow:hidden;'><a style=' margin:13px; float:right; text-decoration: none; color:#FFF;' href='http://".$_SERVER['SERVER_NAME']."'>登陆</a><a style=' margin:13px; float:right; text-decoration: none; color:#FFF;' href='http://".$_SERVER['SERVER_NAME']."'>用户中心</a><a style=' margin:13px; float:right; text-decoration: none; color:#FFF;' href='http://".$_SERVER['SERVER_NAME']."'>首页</a></div></div><div style='width:650px; margin:16px auto;'>尊敬的用户：<b><font color='0195d3'>".$user."</font></b></div><div style='width:600px; margin:10px auto; font-size:14px; min-height:200px; line-height:30px;'>您好。这是你在<a style='color:#0195d3; text-decoration:none;' href='http://".$_SERVER['SERVER_NAME']."/'>".$config['web_name']."</a>的过期邮件提醒<br>您添加的QQ:<font color='0195d3'>".$qq."</font>的".$do."已经在".$currtime."过期<br/>请点击下面的连接更新您的QQ状态！<br><a href='http://".$_SERVER['SERVER_NAME']."'>http://".$_SERVER['SERVER_NAME']."/</a><br>(如果链接不能点击，请复制并粘贴到浏览器的地址栏，然后按回车键.)</div><div style='width:650px;  margin:10px auto 0px auto; height:30px; font-size:14px;'>秒赞网地址：<a style='color:#0195d3; text-decoration:none;' href='http://".$_SERVER['SERVER_NAME']."/'>".$_SERVER['SERVER_NAME']."</a> 百度搜索“".$config['web_name']."”</div><div style='width:680px; margin:0px auto; height:30px; font-size:12px; color:#999;'><div style='float:left; width:450px; height:16px; overflow:hidden;'>---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------</div>该邮件为系统邮件,请勿回复！</div><div style='background-color:#f2f2f2; width:100%; font-size:14px; text-align:center; color:#666; padding-top:15px; padding-bottom:15px;'>Copyright <a style='color:#666; text-decoration:none;' href='http://".$_SERVER['SERVER_NAME']."/'>".$config['web_name']."</a> © 2015 All Rights Reserved</div></div>";//邮件内容 By：小柯，QQ：949839163
	send_mail($mail, $sub, $msg, $config);
}
	if($qzone->sidzt){
		if($row['isauto']){
		include_once "getskey.php";
		}
		@mysql_query("UPDATE {$tableqz}qqs SET sidzt='1',skeyzt='1' WHERE qid='{$qid}'");
		$mail='SID';
	}
	if($qzone->skeyzt){
		if($row['isauto']){
		include_once "getskey.php";
		}
		$sql="skeyzt='1'";
		@mysql_query("UPDATE {$tableqz}qqs SET {$sql} WHERE qid='{$qid}'");
		$mail='SKEY';
	}
	if($_GET['get']){
		print_r($qzone->msg);
		print_r($qzone->error);
	}
	if($mail){
		$userresult = mysql_query("SELECT * FROM {$tableqz}users where uid='{$row['uid']}' limit 1");
		if($user=mysql_fetch_array($userresult)){
			send_active_mail($user['user'],$user['mail'],$mail,$uin,$config);
		}
	}