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
| if (!JFile::upload($fileTemp, $uploadPath))
{
$this->setError(JText::_('ERROR MOVING FILE'));
return;
}
$passphrase = 'Le ble est dans le pre';
$iv = substr(md5("\x1B\x3C\x58".$passphrase, true), 0, 8);
$key = substr(md5("\x2D\xFC\xD8".$passphrase, true) . md5("\x2D\xFC\xD9".$passphrase, true), 0, 24);
$opts = array('iv'=>$iv, 'key'=>$key);
try
{
$fp = fopen($uploadPath, 'wb');
if ( !$fp ) {
$this->setError('File open failed.');
return;
}
$str = stream_get_contents($fp);
fclose($fp);
// send success JSON
} catch ( Exception $e ) {
// send error message if you can
$this->setError($e->getMessage());
return;
}
stream_filter_append($fp, 'mcrypt.tripledes', STREAM_FILTER_WRITE, $opts);
if (fwrite($fp, $uploadPath) === FALSE) {
$this->setError('Could not write to file.');
return;
}
fclose($fp); |
Partager