| Line 11... |
Line 11... |
| 11 |
* @license http://www.gnu.org/licenses/gpl.html Licence GNU-GPL
|
11 |
* @license http://www.gnu.org/licenses/gpl.html Licence GNU-GPL
|
| 12 |
* @version SVN: $Id$
|
12 |
* @version SVN: $Id$
|
| 13 |
*/
|
13 |
*/
|
| 14 |
class Dao {
|
14 |
class Dao {
|
| 15 |
const HTTP_URL_REQUETE_SEPARATEUR = '&';
|
15 |
const HTTP_URL_REQUETE_SEPARATEUR = '&';
|
| - |
|
16 |
const HTTP_URL_REQUETE_CLE_VALEUR_SEPARATEUR = '=';
|
| 16 |
private $http_methodes = array('GET', 'POST', 'PUT', 'DELETE', 'HEAD', 'OPTIONS', 'CONNECT', 'TRACE');
|
17 |
private $http_methodes = array('GET', 'POST', 'PUT', 'DELETE', 'HEAD', 'OPTIONS', 'CONNECT', 'TRACE');
|
| 17 |
protected $parametres = null;
|
18 |
protected $parametres = null;
|
| 18 |
private $url = null;
|
19 |
private $url = null;
|
| 19 |
private $reponse_entetes = null;
|
20 |
private $reponse_entetes = null;
|
| Line 78... |
Line 79... |
| 78 |
$contexte = stream_context_create(array(
|
79 |
$contexte = stream_context_create(array(
|
| 79 |
'http' => array(
|
80 |
'http' => array(
|
| 80 |
'method' => $mode,
|
81 |
'method' => $mode,
|
| 81 |
'header' => "Content-type: application/x-www-form-urlencoded\r\n",
|
82 |
'header' => "Content-type: application/x-www-form-urlencoded\r\n",
|
| 82 |
'content' => http_build_query($donnees, null, self::HTTP_URL_REQUETE_SEPARATEUR))));
|
83 |
'content' => http_build_query($donnees, null, self::HTTP_URL_REQUETE_SEPARATEUR))));
|
| 83 |
$flux = @fopen($url, 'r', false, $contexte);
|
84 |
$flux = @fopen($this->url, 'r', false, $contexte);
|
| 84 |
if (!$flux) {
|
85 |
if (!$flux) {
|
| 85 |
$this->reponse_entetes = $http_response_header;
|
86 |
$this->reponse_entetes = $http_response_header;
|
| 86 |
$e = "L'ouverture de l'url '$url' par la méthode HTTP '$mode' a échoué!";
|
87 |
$e = "L'ouverture de l'url '{$this->url}' par la méthode HTTP '$mode' a échoué!";
|
| 87 |
trigger_error($e, E_USER_WARNING);
|
88 |
trigger_error($e, E_USER_WARNING);
|
| 88 |
} else {
|
89 |
} else {
|
| 89 |
// Informations sur les en-têtes et métadonnées du flux
|
90 |
// Informations sur les en-têtes et métadonnées du flux
|
| 90 |
$this->reponse_entetes = stream_get_meta_data($flux);
|
91 |
$this->reponse_entetes = stream_get_meta_data($flux);
|
| Line 102... |
Line 103... |
| 102 |
|
103 |
|
| 103 |
private function traiterUrlParametres() {
|
104 |
private function traiterUrlParametres() {
|
| 104 |
$parametres = array();
|
105 |
$parametres = array();
|
| 105 |
if (count($this->parametres) > 0) {
|
106 |
if (count($this->parametres) > 0) {
|
| - |
|
107 |
foreach ($this->parametres as $cle => $valeur) {
|
| - |
|
108 |
$cle = rawurlencode($cle);
|
| 106 |
foreach ($this->parametres as $cle => $valeur) {
|
109 |
$valeur = rawurlencode($valeur);
|
| 107 |
$parametres[] = $cle.self::HTTP_URL_REQUETE_CLE_VALEUR_SEPARATEUR.$valeur;
|
110 |
$parametres[] = $cle.self::HTTP_URL_REQUETE_CLE_VALEUR_SEPARATEUR.$valeur;
|
| 108 |
}
|
111 |
}
|
| 109 |
$url_parametres = implode(self::HTTP_URL_REQUETE_SEPARATEUR, $parametres);
|
112 |
$url_parametres = implode(self::HTTP_URL_REQUETE_SEPARATEUR, $parametres);
|
| 110 |
$this->url = $this->url.'?'.$url_parametres;
|
113 |
$this->url = $this->url.'?'.$url_parametres;
|