<?php
include("postget.php");
include_once("common.php");
checklevel(2,$_REQUEST['clientid']);
$thisclient=1;
if($_POST['enviar']==""._YES."") {

	$query="SELECT email, preflang, password FROM hd_clients WHERE clientid='".$_SESSION['hd_clientid']."'";
	$one=mysql_query($query,$db_link);
	$row=mysql_fetch_array($one);
	
	$pass=decrypt($row['password']);
	$subject=_INFORMATION_OF_ACCESS;

	$body="<table border='0' cellspacing='1'>";

	$body.="<TR class='row1'>";
	$body.="<td>";
	$body.="<font size=2>";

	$body.=nl2br(texto('DATA_ACCESS_TO_THE_ACCOUNT',$row[preflang]));

	$body.="</font>";
	$body.="</td>";
	$body.="</tr>";
	$body.="</table>";

	$body=stripslashes($body);

	$body=str_replace('%URL%','<a href="'.$config[1][1].'">'.$config[1][1].'</a>',$body);
	$body=str_replace('%USER%',$_SESSION['hd_clientid'],$body);
	$body=str_replace('%PASS%',$pass,$body);

	if(mail2client($subject,$body,'admin',$row[email],1)) {
			logevent(""._PASSWORD_SENT."",$_SESSION['hd_clientid'],$_SESSION['hd_idc']);
			messagetop(_PASSWORD_SENT,"","tickets.php?clientid=".$_SESSION['hd_clientid'],1);
	}else{
		messagetop(_ERROR,_PASSWORD_NOT_SENT,"tickets.php?clientid=".$_SESSION['hd_clientid'],0);
	}
}else if($_POST['enviar']==""._NO."") {
	messagetop(_PASSWORD_NOT_SENT,"","tickets.php?clientid=".$_SESSION['hd_clientid'],2);
}else{
	if(!is_numeric($_SESSION['hd_clientid'])){print("No client id specified.<BR>");exit();}
	include("head_template.php");
	echo '
<div class="container">
	<div class="row">


<table width="98%" class="table table-bordered">
		<tr>
		<td align="center" width="100%">
';
echo '
		</td>
		</tr>
';	$imagenAmostrar = "pass_.png";
	
echo '
			<tr valign="top">
				<td>

';

	print("<h2>".lang('_SEND_AN_EMAIL_WITH_THE_NEW_PASSWORD')."?</h2><br>");
	print("<form method='POST'>
	<input type=hidden name=clientid value=".$_SESSION['hd_clientid'].">
	<input type=submit name=enviar value="._YES.">
	&nbsp;&nbsp;&nbsp;&nbsp;
	<input type=submit class='btnformyellow' name=enviar value="._NO."></form>");

echo '
		</td>
		</tr>
		</table>
</div>
</div>
';

	include("foot_template.php");
}
?>