<?php session_start();
include './core.php';

$svaTool = new svaTool(); 


$errorCode = 0;

$password = NULL;
$confPasswd = NULL;
// Ajout de nouvel utilisateur 
/*
if (isset($_REQUEST['oldPassword']) && strlen($_REQUEST['oldPassword']) > 0 )
    $oldPassword = addslashes($_REQUEST['oldPassword']);
else
    $errorCode = 1;
	*/
	
if (isset($_REQUEST['newPassword']) && strlen($_REQUEST['newPassword']) > 0)
    $newPassword = addslashes($_REQUEST['newPassword']);
else
    $errorCode = 2;
	
if (isset($_REQUEST['confPassword']) && strlen($_REQUEST['confPassword']) > 0)
    $confPassword = addslashes($_REQUEST['confPassword']);
else
    $errorCode = 3;
	
	if (strcmp($confPassword, $newPassword) != 0) {

    $errorCode = 4;
}
	

$id = $_REQUEST['sccUserId'];
$username = $_REQUEST['accountName'];
	
	/*
	if (isset($_REQUEST['password']) && strlen($_REQUEST['password']) > 0)
    $password = md5($_REQUEST['password']);
else
    $errorCode = 7;

if (isset($_REQUEST['confPasswd']) && strlen($_REQUEST['confPasswd']) > 0)
    $confPasswd = md5($_REQUEST['confPasswd']);
else
    $errorCode = 8;

if (strcmp($password, $confPasswd) != 0) {

    $errorCode = 9;
}
*/
//if (isset($_REQUEST['tariffId']) &&  $_REQUEST['tariffId'] !=-1) $tariffId = $_REQUEST['tariffId'] ;else $errorCode = 14;
$tariffId=13;


if ($errorCode == 0) {
$password = 0;

$res = $dba->updateMyAccountPassword($id,md5($newPassword)) ;


}




switch ($errorCode) {

    case 0 : $msg = "{ \"errorCode\": $errorCode,\"errorMessage\" :\"MOT DE PASSE RE-INITIALISE AVEC SUCCES ! \"  }"; 
        break;
    case 1 : $msg = "{ \"errorCode\": $errorCode,\"errorMessage\" :\"ERREUR ! VEUILLEZ SAISIR L'ANCIEN MOT DE PASSE !\"  }";
        break;
    case 2 : $msg = "{ \"errorCode\": $errorCode,\"errorMessage\" :\"ERREUR ! LE NOUVEAU MOT DE PASSE EST INVALIDE !\"  }"; 
        break;
    case 3 : $msg = "{ \"errorCode\": $errorCode,\"errorMessage\" :\"ERREUR ! LE MOT DE PASSE DE CONFIRMATION EST INVALIDE .!\"  }"; 
        break;
    case 4 : $msg = "{ \"errorCode\": $errorCode,\"errorMessage\" :\"ERREUR ! LES MOTS DE PASSE NE CONCORDENT PAS ! \"  }";
        break;
  
    /*case 7 : $msg =  "ERREUR ! LE MOT DE PASSE EST INVALIDE.";
        break;*/
  
   
	 
}


echo $msg ;


?>