1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140
|
<?php
include_once('ControllerAll.php');
include_once('getPersons.php');
class ControllerGetPersons extends ControllerAll{
public static function PostToHostSSL($host, $path, $data_to_send, $port=443, $methode)
{
$user="*********";
$passwd="*********";
#$user="**************";
#$passwd="*************";
$res = "";
$fp = fsockopen("ssl://".$host, $port, $errno, $errstr);
if (!$fp)
{
echo "<B>Error $errno</B>: $errstr";
}
else
{
fputs($fp, "$methode $path HTTPS/1.0\r\n");
fputs($fp, "Host: $host\r\n");
fputs($fp, "Content-type: application/x-www-form-urlencoded\r\n");
fputs($fp, "Content-length: ".strlen($data_to_send)."\r\n");
fputs($fp, "Accept: */*\r\n");
fputs($fp, "Authorization: Basic ".base64_encode($user.":".$passwd)."\r\n");
fputs($fp, "\r\n");
fputs($fp, $data_to_send."\r\n");
fputs($fp, "\r\n");
$headers = "";
while ($str = trim(fgets($fp, 4096))) {
$headers .= "$str\n";
}
echo $headers."\n";
$body = "";
while (!feof($fp)) {
$body .= fgets($fp, 4096);
$tableauRes=explode(";", $body);
}
$tailleTableau=count($tableauRes);
echo "test1bis";
$i=0;
$j=1;
$k=2;
$l=3;
$m=4;
$n=5;
$o=6;
$p=7;
$q=8;
$r=9;
$s=10;
$p=new getPersons();
$p->setAttr('uidper','');
$p->setAttr('pcod','');
$p->setAttr('pnam', '');
$p->setAttr('pfsn', '');
$p->setAttr('uidveh','');
$p->setAttr('vcod', '');
$p->setAttr('vdes', '');
$p->setAttr('vreg','');
$p->setAttr('vint', '');
$p->setAttr('elng', '');
$p->setAttr('esht','');
$p->insert();
echo "test2";
while($s<=$tailleTableau){
$pers = new getPersons();
$pers->setAttr('uidper',intval($tableauRes[$i]));
$pers->setAttr('pcod', $tableauRes[$j]);
$pers->setAttr('pnam', $tableauRes[$k]);
$pers->setAttr('pfsn', $tableauRes[$l]);
$pers->setAttr('uidveh',$tableauRes[$m]);
$pers->setAttr('vcod', $tableauRes[$n]);
$pers->setAttr('vdes', $tableauRes[$o]);
$pers->setAttr('vreg', $tableauRes[$p]);
$pers->setAttr('vint', $tableauRes[$q]);
$pers->setAttr('elng', $tableauRes[$r]);
$pers->setAttr('esht', $tableauRes[$s]);
$i+=11;
$j+=11;
$k+=11;
$l+=11;
$m+=11;
$n+=11;
$o+=11;
$p+=11;
$q+=11;
$r+=11;
$s+=11;
//print_r($pers);
echo "test3";
var_dump($pers);
exit('(debug)') ;
$pers->setAttr('idCentre',idCentre);
$pers->insert();
}
$res = $body;
fclose($fp);
}
}
public function execute(){
$data="ext=csv\n"; #html, csv, xml, txt
ControllerGetPersons::PostToHostSSL(****************',****************,$data, $port=443, "GET");
//header('Location:tpl_MajOk.php');
}
} |
Partager