<? 
if($_POST["email"]){ $email = $_POST["email"] ; 
        $explode = explode("@", $email) ; 
		$dominio = $explode[1];
		$emaild = $explode[0];
} 
$cota ="5"; //Cota do email
$url="http://www.$dominio:2082/frontend/x2/mail/dopasswdpop.html"; 
?>
<? if($vai=="modifique"){ 
?><title>Modificando senha de email no Cpanel</title>
<table width = "550" cellspacing = "0" cellpadding = "0" border = "0">
  <tr>
    <td valign = "bottom">&nbsp;</td>
    <td valign = "middle" width = "522"><font class="big">Toque a senha de seu email </font><br>
        <br></td>
    <td valign = "bottom">&nbsp;</td>
  </tr>
  <tr>
    <td></td>
    <td>
      <form method="POST" action="<? echo $url; ?>">
        <table>
          <tr>
            <td width="80"> <font class="med"> Email </font></td>
            <td width="212"> <? echo $emaild; ?>@<? echo $dominio; ?>
                <input type="hidden" name="email" value="<? echo $emaild; ?>">
                <input type="hidden" name="domain" value="<? echo $dominio; ?>">
            </td>
          </tr>
          <tr>
            <td> <font class="med"> Nova senha: </font> </td>
            <td><input name="password" type="password" id="password"></td>
          </tr>
          <input type="hidden" name="quota" value="5">
          <tr>
            <td>&nbsp;</td>
            <td>&nbsp;</td>
          </tr>
          <tr>
            <td><input name="submit" type="submit" value="Vai"></td>
            <td><input name="reset" type="reset" value="Cancelar"></td>
          </tr>
        </table>
    </form></td>
    <td></td>
  </tr>
  <td valign = "bottom">&nbsp;</td>
      <td valign = "middle" width = "522">
        <center>
                </center></td>
      <td valign = "bottom">&nbsp;</td>
</table>
<? } if($vai=="dados"){?>
<table width = "550" cellspacing = "0" cellpadding = "0" border = "0">
  <tr>
    <td valign = "bottom">&nbsp;</td>
    <td valign = "middle" width = "522">Insira o email:<br>
        <br></td>
    <td valign = "bottom">&nbsp;</td>
  </tr>
  <tr>
    <td></td>
    <td>
      <form method="POST" action="?vai=modifique">
        <table>
          <tr>
            <td width="80"> <font class="med"> Email </font></td>
            <td width="212"> <input name="email" type="text" id="email"></td>
          </tr>
          <input type="hidden" name="quota" value="<? echo $cota; ?>">
          <tr>
            <td><input name="submit2" type="submit" value="Vai"></td>
            <td><input name="reset2" type="reset" value="Cancelar"></td>
          </tr>
        </table>
    </form></td>
    <td></td>
  </tr>
  <td valign = "bottom">&nbsp;</td>
      <td valign = "middle" width = "522">
        <center>
      </center></td>
      <td valign = "bottom">&nbsp;</td>
</table>
<? } ?>
<?
function login_cpanel ($username, $password) { 
    $cpanel_file_location = "/frontend/x2/mail/"; 
    $cpanel_domain = "nardoimoveis.com.br"; //Dominio
    $cpanel_port = 2082; 

    $header = "POST " . $cpanel_file_location . " HTTP/1.0\r\nAuthorization: Basic "; 
    $header .= base64_encode($username . ":" . $password) .  "\r\n"; 
    $header .= "Content-type: application/x-www-form-urlencoded\r\n"; 
    $header .= "Content-length: " . strlen($request) . "\r\n"; 
    $header .= "Connection: close\r\n\r\n"; 

    $fp = fsockopen($cpanel_domain, $cpanel_port, $errno, $errstr); 
    if ($fp) { 
        fputs($fp, $header); 
        while (!feof($fp)) { $cpanel_response .= fgets($fp, 128); } 
    } 
     
    if ((strpos($cpanel_response, "200 OK") < 1) && (strpos($cpanel_response, "WWW-Authenticate") > 0)) { 
        return false; 
    } else { 
        return true; 
    } 
    $fp = fclose($fp); 
} 
if ((strlen($_POST["username"]) > 0) && (strlen($_POST["password"]) > 0)) { 
    if (login_cpanel ($_POST["username"], $_POST["password"]) == true) { 
        echo "<meta http-equiv='refresh' content='4;URL=login.php?vai=dados'>Aguarde..."; 
        $oculta = 1; 
    } else { 
        echo "Usuario ou senha incorretos."; 
    } 
} 

if ($oculta != 1)if($vai=='') { 
?><BR> 
            <form method=post> 
              <BR> 
            <table>
              <tr>
                <td width="80"> <font class="med">Usuario: </font></td>
                <td width="212"><input type=text name=username size=30></td>
              </tr>
              <input type="hidden" name="quota2" value="<? echo $cota; ?>">
              <tr>
                <td>senha:</td>
                <td><input name=password type=password id="password" size=30></td>
              </tr>
            </table>
            <BR> 
            <input type=submit value=Logar> 
            </form> <? } ?>