function get_running_pmb_userid($source_id) { global $wsdl; $get_wsdl = isset($wsdl); //Si on ne souhaite que le wsdl, alors on laisse passer if ($get_wsdl) { return 1; } if (!isset($_SERVER['PHP_AUTH_USER'])) { //Si on ne nous fourni pas de credentials, alors on teste l'utilisateur anonyme $user_id = connector_out_check_credentials('', '', $source_id); if ($user_id === false) { header('WWW-Authenticate: Basic realm="PMB SOAP"'); header('HTTP/1.0 401 Unauthorized'); exit; } } else { //Sinon on teste les credentiels fournis $rawusername = $_SERVER['PHP_AUTH_USER']; $password = $_SERVER['PHP_AUTH_PW']; $user_id = connector_out_check_credentials($rawusername, $password, $source_id); if ($user_id === false) { header('WWW-Authenticate: Basic realm="PMB SOAP"'); header('HTTP/1.0 401 Unauthorized'); exit; } } return $user_id; }
function get_running_pmb_userid($source_id) { $user_id = 1; $this->json_input = json_decode(file_get_contents('php://input'), true); if (!$this->json_input) { return 1; } $credentials_user = ''; $credentials_password = ''; if (isset($this->json_input["auth_user"])) { $credentials_user = $this->json_input["auth_user"]; if (isset($this->json_input["auth_pw"])) { //Vérification du hash salé double $requete = "select esuser_password from es_esusers where esuser_username='******'"; $resultat = mysql_query($requete); if ($resultat) { $pwd = mysql_result($resultat, 0, 0); $sc = $this->instantiate_source_class($source_id); $salt = md5($credentials_user . md5($pwd) . $sc->comment . $this->json_input["id"] . $this->json_input["method"]); if ($salt == $this->json_input["auth_pw"]) { $credentials_password = $pwd; } } } //$credentials_password = isset($this->json_input["auth_pw"]) ? $this->json_input["auth_pw"] : ''; } if (isset($_SERVER['PHP_AUTH_USER'])) { $credentials_user = $_SERVER['PHP_AUTH_USER']; $credentials_password = $_SERVER['PHP_AUTH_PW']; } if (!$credentials_user) { //Si on ne nous fourni pas de credentials, alors on teste l'utilisateur anonyme $user_id = connector_out_check_credentials('', '', $source_id); if ($user_id === false) { $this->return_json_error('Access with no credentials is forbidden.', $this->json_input); } } else { $user_id = connector_out_check_credentials($credentials_user, $credentials_password, $source_id); if ($user_id === false) { $this->return_json_error('Bad credentials.', $this->json_input); } } return $user_id; }