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
| <?php
define('FOLDER_ROOT', '../..');
$load_param = array('session','template','cnty_tools_main','cnty_tools_action','cnty_conf','error','xss');
require_once('head.php');
include PATH_TEMPLATES_CONFIG."/_config_account.php";
$aTemplates['Account_Form'] = file_get_contents($cfg['path_tmpl_list'].'tmpl_trace_new.html');
function DoOutput ()
{
global $rt;
echo TemplateProcess($rt['output']);
}
$addr = $cfg['this_url'];
//$sub_name = substr($_SESSION['sess_key_plateform'], 0, 10);
/* Send file
@param string $url Url
@param array $file File array
@param array $var Var array
@param string $boundary Separator
@return array with header and content client response
*/
function header_build($url, $file, $var = null, $boundary = '---------------------------9633331271588363780939124723') {
$response = null;
$tab = parse_url($url);
echo ($tab);
$fp = fsockopen($tab['host'], 80, $errno, $errstr, 30);
$parsingfile = fopen('parsingfile.txt', 'r+');
fseek($parsingfile, 0);
fputs($parsingfile, $tab);
fclose($parsingfile);
//$parsingresult = file_get_contents($parsingfile);
echo ($parsingresult);
if ($fp) {
// Build the header
$header = "POST ".$tab['path']." HTTP/1.0\r\n";
$header .= "Host: ".$tab['host']."\r\n";
$header .= "Content-type: multipart/form-data, boundary=$boundary\r\n";
$data = null;
// Add post var
foreach ($var as $k => $v) {
$data .="--$boundary\r\n";
$data .= "Content-Disposition: form-data; name=\"".$k."\"\r\n";
$data .= "\r\n".$v."\r\n";
}
// Attach files
foreach ($file as $f) {
$data .= "--$boundary\r\n";
$data .="Content-Disposition: form-data; name=\"ul_files[]\"; filename=\"".basename($f)."\"\r\n";
$data .= "Content-Type: unknow/unknow\r\n\r\n";
$data .= file_get_contents($f)."\r\n";
$data .= "--$boundary\r\n";
}
$header .= "Content-length: ".strlen($data)."\r\n\r\n";
// Write !
fwrite($fp, $header.$data);
$data = null;
// Read response
while (!feof($fp)) {
$data .= fread($fp, 32);
}
// Extract header and content
$data = explode("\n", $data);
$header = true;
$tab = null;
foreach ($data as $k => $v) {
$v = trim($v);
if (empty($v)) {
$header = false;
}
$tab[(($header) ? 'header' : 'content')] .= $v;
}
fclose($fp);
}
return $tab;
}
/*
*/
$error = 0;
//define('MY_DISPLAY_KEY', '7b9e07cae6d80eb026fc5614fa7641b7');
//$_SESSION['sess_key_plateform'] = '6ee357286d2e135480c8f83a21f6b2e4';
if (isset($_FILES) && !empty($_FILES)) {
$out = header_build($addr,
array($_FILES['trackfile']['tmp_name']),
array('sk' => $_SESSION['sess_key_platform'], 'dk' => MY_DISPLAY_KEY, 'type' => 'track')
);
$content = unserialize($out['content']);
if (is_array($content)) {
$msg = 'Erreur durant l\'importation de la trace !';
} else {
$msg = 'La trace à bien été importée !';
}
SetTemplateVar(false, 'MESSAGE_TRACK', $msg);
} else {
SetTemplateVar(false, 'MESSAGE_TRACK', null);
}
$rt['output'] = GetTemplate('Account_Form');
DoOutput();
unset($rt);
?> |
Partager