<?php
session_start();
require_once("../common/init.php");

if ($_GET[lang]=="")
{

$sqllanginfo = "select * from ch_lang  where AutoDo='1'   ";
}
else
{
	

$lang=$_GET[lang];
$sqllanginfo = "select * from ch_lang  where ProductName='$lang'  ";
}
$langInfo  = $DB->getdata($sqllanginfo);
$lang_agentname=$langInfo[ProductIntro];

$lang=$langInfo[ProductName];

$smarty->assign('lang_sj',$langInfo[sj]);
$smarty->assign('lang_zc',$langInfo[zc]);
$smarty->assign('lang_wjmm',$langInfo[wjmm]);
$smarty->assign('lang_sjb',$langInfo[sjb]);

$smarty->assign('lang_dl',$langInfo[dl]);
$smarty->assign('lang_jrsc',$langInfo[jrsc]);
$smarty->assign('lang_jg',$langInfo[jg]);
$smarty->assign('lang_ckxq',$langInfo[ckxq]);

$smarty->assign('lang_rmb',$langInfo[rmb]);
$smarty->assign('lang_yuan',$langInfo[yuan]);
$smarty->assign('lang_sjtime',$langInfo[sjtime]);
$smarty->assign('lang_zz',$langInfo[zz]);
$smarty->assign('lang_sl',$langInfo[sl]);
$smarty->assign('lang_cpjs',$langInfo[cpjs]);
$smarty->assign('lang_cply',$langInfo[cply]);
$smarty->assign('lang_dqwz',$langInfo[dqwz]);
$smarty->assign('lang_syindex',$langInfo[syindex]);

$smarty->assign('lang_soshuo',$langInfo[soshuo]);
$smarty->assign('lang_cpsoshuo',$langInfo[cpsoshuo]);
$smarty->assign('lang_wzsoshuo',$langInfo[wzsoshuo]);

$smarty->assign('lang_tjwt',$langInfo[tjwt]);
$smarty->assign('lang_wtlx',$langInfo[wtlx]);

$smarty->assign('lang_lxr',$langInfo[lxr]);
$smarty->assign('lang_lybt',$langInfo[lybt]);
$smarty->assign('lang_lylr',$langInfo[lylr]);
$smarty->assign('lang_yzm',$langInfo[yzm]);
$smarty->assign('lang_yzmzq',$langInfo[yzmzq]);
$smarty->assign('lang_yzmcw',$langInfo[yzmcw]);
$smarty->assign('lang_wtlb',$langInfo[wtlb]);
$smarty->assign('lang_gong',$langInfo[gong]);
$smarty->assign('lang_gong1',$langInfo[gong1]);
$smarty->assign('lang_gong2',$langInfo[gong2]);
$smarty->assign('lang_gong3',$langInfo[gong3]);
$smarty->assign('lang_oprice',$langInfo[oprice]);
$smarty->assign('lang_nprice',$langInfo[nprice]);

$smarty->assign('lang_welcome',$langInfo[welcome]);
$smarty->assign('lang_logout',$langInfo[logout]);
$smarty->assign('lang_gl',$langInfo[gl]);
$smarty->assign('lang_qhmm',$langInfo[qhmm]);
$smarty->assign('lang_lb',$langInfo[lb]);
$smarty->assign('lang_ljgm',$langInfo[ljgm]);
$smarty->assign('lang_cz',$langInfo[cz]);
$smarty->assign('lang_more',$langInfo[more]);
$smarty->assign('lang_fh',$langInfo[fh]);
$smarty->assign('lang_wdl',$langInfo[wdl]);
$smarty->assign('lang_ydl',$langInfo[ydl]);
$smarty->assign('lang_yhm',$langInfo[yhm]);
$smarty->assign('lang_mm',$langInfo[mm]);
$smarty->assign('lang_qrmm',$langInfo[qrmm]);
$smarty->assign('lang_lxrz',$langInfo[lxrz]);
$smarty->assign('lang_lxry',$langInfo[lxry]);
$smarty->assign('lang_gsmz',$langInfo[gsmz]);
$smarty->assign('lang_gsmy',$langInfo[gsmy]);
$smarty->assign('lang_gj',$langInfo[gj]);
$smarty->assign('lang_sf',$langInfo[sf]);
$smarty->assign('lang_cs',$langInfo[cs]);
$smarty->assign('lang_txdzz',$langInfo[txdzz]);
$smarty->assign('lang_txdzy',$langInfo[txdzy]);
$smarty->assign('lang_yb',$langInfo[yb]);
$smarty->assign('lang_czh',$langInfo[czh]);
$smarty->assign('lang_email',$langInfo[email]);

if($lang==""){
$lang="Chinese";
}
$UserName = $_POST['UserName'];
$UserMail = $_POST['UserMail'];

if($UserName!='' && $UserMail != ''){
    $sql="select * from users where UserName='$UserName'";
	$rs=$db->query($sql);
	$UserInfo=$db->fetch_array($rs);
	if(!$UserInfo || $UserInfo['Email'] != $UserMail) {
	    $message.= "<font color='red'>".$langInfo[yhbz]."</font>";
	} else {
		$UserName = $UserInfo['UserName'];
	   	$Password = $UserInfo['Password'];
		$num = md5($UserName.$Password.rand());
		
		$sql = 'INSERT INTO `getpwd` (`id`, `user`, `key`, `istart`, `time`) VALUES (NULL, \''.$UserName.'\', \''.$num.'\', \'0\', UNIX_TIMESTAMP());';
		$db->query($sql);
		$ID=$db->insert_id();
		$mailvars['UserName'] = $UserInfo['UserName'];
		$mailvars['url'] = $parentpath.'/user/get_pwd.php?id='.$ID.'&key='.md5($num).'&sj='.time(); 
	  
	 $sent = SendTemplateMail("user_pass.htm",$mailvars,$UserInfo['Email'],$langInfo[qhmm]);
	   if($sent) {
		   $message = '<font color=#009900>Send mail successfull: '.$UserInfo[Email].' </font>';
	    echo '<script>alert(Send mail successfull'.$UserInfo[Email].');</script>';
	   }
	   else $message = "SMTP server does not exist or SMTP authentication failed<br>SMTP服务器不存在 或 SMTP认证失败";
	      echo "<script>alert('SMTP server does not exist or SMTP authentication failed<br>SMTP服务器不存在 或 SMTP认证失败');</script>";
	}
} elseif($submit) {
	$message = $langInfo[yhbz];
}
$smarty->assign("lang",$lang);
$smarty->assign("message",$message);
$smarty->display('user_getpwd.html');
$db->close();
?>