IdentifiantMot de passe
Loading...
Mot de passe oublié ?Je m'inscris ! (gratuit)
Navigation

Inscrivez-vous gratuitement
pour pouvoir participer, suivre les réponses en temps réel, voter pour les messages, poser vos propres questions et recevoir la newsletter

EDI, CMS, Outils, Scripts et API PHP Discussion :

Téléchargement de fichier interrompu [PrestaShop]


Sujet :

EDI, CMS, Outils, Scripts et API PHP

Mode arborescent

Message précédent Message précédent   Message suivant Message suivant
  1. #1
    Candidat au Club
    Homme Profil pro
    Musicien
    Inscrit en
    Septembre 2011
    Messages
    2
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : France

    Informations professionnelles :
    Activité : Musicien
    Secteur : Arts - Culture

    Informations forums :
    Inscription : Septembre 2011
    Messages : 2
    Par défaut Téléchargement de fichier interrompu
    Bonjour,

    Musicien, je vends mes chansons au format .mp3, .wav sur Prestashop v1.4.4.0 par l'onglet "produit à télécharger".
    Mon hébergeur ovh mutualisé m'a confirmé qu'il bloque le temps d’exécution du téléchargement à 120 secondes lors d'une requête php, le fichier est donc amputé.
    Je n'ai évidemment pas accès au php.ini.Des modifications de get-file.php sont restées sans succès.
    Pour contourner ça, j'ai crée un produit à télécharger, un simple fichier .txt avec le lien en clair du type : http://www.monsite.fr/download/album-mp3.zip qui pointe vers le fichier du répertoire download.Ainsi, le téléchargement direct via ftp du type : http://www.monsite.fr/download/album-mp3.zip fonctionne correctement.
    Toutefois par cette méthode, le fichier n'est pas crypté et le répertoire download de mon site reste accessible pour peu que l'on connaisse le nom de chaque titre (chansons) avec l'extension appropriée .mp3 ou .wav.
    Par ailleurs, les options "nombre de téléchargement", "durée de vie" du lien de téléchargement cryptés disparaissent...
    Est-ce possible selon vous de modifier quelque chose pour pouvoir crypter l'adresse du lien de téléchargement via le download direct ftp / http et ce sans requête php qui est systématiquement bloquée par mon hébergeur ?

    N'étant pas développeur, je remercie par avance celles ou ceux qui voudront bien me donner un coup de pouce.
    Voici le code de get-file.php :
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    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
    141
    142
    143
    144
    145
    146
    147
    148
    149
    150
    151
    152
    153
    154
    155
    156
    157
    158
    159
    160
    161
    162
    163
    164
    165
    166
    167
    168
    169
    170
    171
    172
    173
    174
    175
    176
    177
    178
    179
    180
    181
    182
    183
    184
    185
    186
    187
    188
    189
    190
    191
    192
    193
    194
    195
    196
    197
    198
    199
    200
    201
    202
    203
    204
    205
    206
    207
    208
    209
    210
    211
    212
    213
    214
    215
    216
    217
    218
    219
    220
    221
    222
    223
    224
    225
    226
    227
    228
    229
    230
    231
    232
    233
    234
    235
    236
    237
    238
    239
    240
    241
    242
    243
    244
    245
    246
    247
    248
    249
    250
    251
    252
    253
    254
    255
    256
    257
    258
    259
    260
    261
    262
    263
    264
    265
    266
    267
    268
    269
    270
    271
    272
    273
    274
    275
    276
    277
    278
    279
    280
    281
    282
    283
    284
    285
    286
    287
    288
    289
    290
    291
    292
    293
    294
    295
    296
    297
    298
    299
    300
    <?php
    /*
    * 2007-2011 PrestaShop 
    *
    * NOTICE OF LICENSE
    *
    * This source file is subject to the Open Software License (OSL 3.0)
    * that is bundled with this package in the file LICENSE.txt.
    * It is also available through the world-wide-web at this URL:
    * http://opensource.org/licenses/osl-3.0.php
    * If you did not receive a copy of the license and are unable to
    * obtain it through the world-wide-web, please send an email
    * to license@prestashop.com so we can send you a copy immediately.
    *
    * DISCLAIMER
    *
    * Do not edit or add to this file if you wish to upgrade PrestaShop to newer
    * versions in the future. If you wish to customize PrestaShop for your
    * needs please refer to http://www.prestashop.com for more information.
    *
    *  @author PrestaShop SA <contact@prestashop.com>
    *  @copyright  2007-2011 PrestaShop SA
    *  @version  Release: $Revision: 6599 $
    *  @license    http://opensource.org/licenses/osl-3.0.php  Open Software License (OSL 3.0)
    *  International Registered Trademark & Property of PrestaShop SA
    */
     
    include(dirname(__FILE__).'/config/config.inc.php');
    include(dirname(__FILE__).'/init.php');
     
    function displayError($msg)
    {
    	$translations = array(
    	'Invalid key.' => Tools::displayError('Invalid key.'),
    	'This product does not exist in our store.' => Tools::displayError('This product does not exist in our store.'),
    	'This product has been deleted.' => Tools::displayError('This product has been deleted.'),
    	'This file no longer exists.'	=> Tools::displayError('This file no longer exists.'),
    	'The product deadline is in the past.' => Tools::displayError('The product deadline is in the past.'),
    	'Expiration date exceeded' => Tools::displayError('Expiration date exceeded'),
    	'You have reached the maximum number of allowed downloads.' => Tools::displayError('You have reached the maximum number of allowed downloads.'));
    ?>
    <script type="text/javascript">
    //<![CDATA[
    alert("<?php echo html_entity_decode($translations[$msg], ENT_QUOTES, 'utf-8'); ?>");
    window.location.href = '<?php echo __PS_BASE_URI__ ?>';
    //]]>
    </script>
    <?php
    	exit();
    }
     
    $cookie = new Cookie('psAdmin');
    if ($cookie->isLoggedBack() AND Tools::getValue('file'))
    {
    	/* Admin can directly access to file */
    	$filename = Tools::getValue('file');
    	if (!Validate::isSha1($filename))
    		die(Tools::displayError());
    	$file = _PS_DOWNLOAD_DIR_.strval(preg_replace('/\.{2,}/', '.',$filename));
    	$filename = ProductDownload::getFilenameFromFilename(Tools::getValue('file'));
    	if (empty($filename))
    	{
    		$newFileName = Tools::getValue('filename');
    		if (!empty($newFileName))
    			$filename = Tools::getValue('filename');
    		else
    			$filename = 'file';
    	}
     
    	if (!file_exists($file))
    		Tools::redirect('index.php');
    }
    else
    {
    	if (!($key = Tools::getValue('key')))
    		displayError('Invalid key.');
     
    	$cookie = new Cookie('ps');
    	Tools::setCookieLanguage();
    	if (!$cookie->isLogged() AND !Tools::getValue('secure_key') AND !Tools::getValue('id_order'))
    		Tools::redirect('authentication.php?back=get-file.php&key='.$key);
    	elseif (!$cookie->isLogged() AND Tools::getValue('secure_key') AND Tools::getValue('id_order'))
    	{
    		$order = new Order((int)Tools::getValue('id_order'));
    		if (!Validate::isLoadedObject($order))
    			displayError('Invalid key.');
    		if ($order->secure_key != Tools::getValue('secure_key'))
    			displayError('Invalid key.');
    	}
     
    	/* Key format: <sha1-filename>-<hashOrder> */
    	$tmp = explode('-', $key);
    	if (sizeof($tmp) != 2)
    		displayError('Invalid key.');
     
    	$filename = $tmp[0];
    	$hash = $tmp[1];
     
    	if (!($info = OrderDetail::getDownloadFromHash($hash)))
    		displayError('This product does not exist in our store.');
     
    	/* Product no more present in catalog */
    	if (!isset($info['id_product_download']) OR empty($info['id_product_download']))
    		displayError('This product has been deleted.');
     
    	if (!file_exists(_PS_DOWNLOAD_DIR_.$filename))
    		displayError('This file no longer exists.');
     
    	$now = time();
     
    	$product_deadline = strtotime($info['download_deadline']);
    	if ($now > $product_deadline AND $info['download_deadline'] != '0000-00-00 00:00:00')
    		displayError('The product deadline is in the past.');
     
    	$customer_deadline = strtotime($info['date_expiration']);
    	if ($now > $customer_deadline AND $info['date_expiration'] != '0000-00-00 00:00:00')
    		displayError('Expiration date exceeded');
     
    	if ($info['download_nb'] >= $info['nb_downloadable'] AND $info['nb_downloadable'])
    		displayError('You have reached the maximum number of allowed downloads.');
     
    	/* Access is authorized -> increment download value for the customer */
    	OrderDetail::incrementDownload($info['id_order_detail']);
     
    	$file = _PS_DOWNLOAD_DIR_.$info['physically_filename'];
    	$filename = $info['display_filename'];
    }
     
    /* Detect mime content type */
    $mimeType = false;
    if (function_exists('finfo_open'))
    {
    	$finfo = @finfo_open(FILEINFO_MIME);
    	$mimeType = @finfo_file($finfo, $file);
    	@finfo_close($finfo);
    }
    elseif (function_exists('mime_content_type'))
    	$mimeType = @mime_content_type($file);
    elseif (function_exists('exec'))
    {	
    	$mimeType = trim(@exec('file -b --mime-type '.escapeshellarg($file)));
    	if (!$mimeType)
    		$mimeType = trim(@exec('file --mime '.escapeshellarg($file)));
    	if (!$mimeType)
    		$mimeType = trim(@exec('file -bi '.escapeshellarg($file)));
    }
     
    if (empty($mimeType))
    {
    	$bName = basename($filename);
    	$bName = explode('.', $bName);
    	$bName = strtolower($bName[count($bName) - 1]);
     
    	$mimeTypes = array(
    	'ez' => 'application/andrew-inset',
    	'hqx' => 'application/mac-binhex40',
    	'cpt' => 'application/mac-compactpro',
    	'doc' => 'application/msword',
    	'oda' => 'application/oda',
    	'pdf' => 'application/pdf',
    	'ai' => 'application/postscript',
    	'eps' => 'application/postscript',
    	'ps' => 'application/postscript',
    	'smi' => 'application/smil',
    	'smil' => 'application/smil',
    	'wbxml' => 'application/vnd.wap.wbxml',
    	'wmlc' => 'application/vnd.wap.wmlc',
    	'wmlsc' => 'application/vnd.wap.wmlscriptc',
    	'bcpio' => 'application/x-bcpio',
    	'vcd' => 'application/x-cdlink',
    	'pgn' => 'application/x-chess-pgn',
    	'cpio' => 'application/x-cpio',
    	'csh' => 'application/x-csh',
    	'dcr' => 'application/x-director',
    	'dir' => 'application/x-director',
    	'dxr' => 'application/x-director',
    	'dvi' => 'application/x-dvi',
    	'spl' => 'application/x-futuresplash',
    	'gtar' => 'application/x-gtar',
    	'hdf' => 'application/x-hdf',
    	'js' => 'application/x-javascript',
    	'skp' => 'application/x-koan',
    	'skd' => 'application/x-koan',
    	'skt' => 'application/x-koan',
    	'skm' => 'application/x-koan',
    	'latex' => 'application/x-latex',
    	'nc' => 'application/x-netcdf',
    	'cdf' => 'application/x-netcdf',
    	'sh' => 'application/x-sh',
    	'shar' => 'application/x-shar',
    	'swf' => 'application/x-shockwave-flash',
    	'sit' => 'application/x-stuffit',
    	'sv4cpio' => 'application/x-sv4cpio',
    	'sv4crc' => 'application/x-sv4crc',
    	'tar' => 'application/x-tar',
    	'tcl' => 'application/x-tcl',
    	'tex' => 'application/x-tex',
    	'texinfo' => 'application/x-texinfo',
    	'texi' => 'application/x-texinfo',
    	't' => 'application/x-troff',
    	'tr' => 'application/x-troff',
    	'roff' => 'application/x-troff',
    	'man' => 'application/x-troff-man',
    	'me' => 'application/x-troff-me',
    	'ms' => 'application/x-troff-ms',
    	'ustar' => 'application/x-ustar',
    	'src' => 'application/x-wais-source',
    	'xhtml' => 'application/xhtml+xml',
    	'xht' => 'application/xhtml+xml',
    	'zip' => 'application/zip',
    	'au' => 'audio/basic',
    	'snd' => 'audio/basic',
    	'mid' => 'audio/midi',
    	'midi' => 'audio/midi',
    	'kar' => 'audio/midi',
    	'mpga' => 'audio/mpeg',
    	'mp2' => 'audio/mpeg',
    	'mp3' => 'audio/mpeg',
    	'aif' => 'audio/x-aiff',
    	'aiff' => 'audio/x-aiff',
    	'aifc' => 'audio/x-aiff',
    	'm3u' => 'audio/x-mpegurl',
    	'ram' => 'audio/x-pn-realaudio',
    	'rm' => 'audio/x-pn-realaudio',
    	'rpm' => 'audio/x-pn-realaudio-plugin',
    	'ra' => 'audio/x-realaudio',
    	'wav' => 'audio/x-wav',
    	'pdb' => 'chemical/x-pdb',
    	'xyz' => 'chemical/x-xyz',
    	'bmp' => 'image/bmp',
    	'gif' => 'image/gif',
    	'ief' => 'image/ief',
    	'jpeg' => 'image/jpeg',
    	'jpg' => 'image/jpeg',
    	'jpe' => 'image/jpeg',
    	'png' => 'image/png',
    	'tiff' => 'image/tiff',
    	'tif' => 'image/tif',
    	'djvu' => 'image/vnd.djvu',
    	'djv' => 'image/vnd.djvu',
    	'wbmp' => 'image/vnd.wap.wbmp',
    	'ras' => 'image/x-cmu-raster',
    	'pnm' => 'image/x-portable-anymap',
    	'pbm' => 'image/x-portable-bitmap',
    	'pgm' => 'image/x-portable-graymap',
    	'ppm' => 'image/x-portable-pixmap',
    	'rgb' => 'image/x-rgb',
    	'xbm' => 'image/x-xbitmap',
    	'xpm' => 'image/x-xpixmap',
    	'xwd' => 'image/x-windowdump',
    	'igs' => 'model/iges',
    	'iges' => 'model/iges',
    	'msh' => 'model/mesh',
    	'mesh' => 'model/mesh',
    	'silo' => 'model/mesh',
    	'wrl' => 'model/vrml',
    	'vrml' => 'model/vrml',
    	'css' => 'text/css',
    	'html' => 'text/html',
    	'htm' => 'text/html',
    	'asc' => 'text/plain',
    	'txt' => 'text/plain',
    	'rtx' => 'text/richtext',
    	'rtf' => 'text/rtf',
    	'sgml' => 'text/sgml',
    	'sgm' => 'text/sgml',
    	'tsv' => 'text/tab-seperated-values',
    	'wml' => 'text/vnd.wap.wml',
    	'wmls' => 'text/vnd.wap.wmlscript',
    	'etx' => 'text/x-setext',
    	'xml' => 'text/xml',
    	'xsl' => 'text/xml',
    	'mpeg' => 'video/mpeg',
    	'mpg' => 'video/mpeg',
    	'mpe' => 'video/mpeg',
    	'qt' => 'video/quicktime',
    	'mov' => 'video/quicktime',
    	'mxu' => 'video/vnd.mpegurl',
    	'avi' => 'video/x-msvideo',
    	'movie' => 'video/x-sgi-movie',
    	'ice' => 'x-conference-xcooltalk');
     
    	if (isset($mimeTypes[$bName]))
    		$mimeType = $mimeTypes[$bName];
    	else
    		$mimeType = 'application/octet-stream';
    }
     
     
    /* Set headers for download */
    header('Content-Transfer-Encoding: binary');
    header('Content-Type: '.$mimeType);
    header('Content-Length: '.filesize($file));
    header('Content-Disposition: attachment; filename="'.$filename.'"');
    ob_end_flush();
    $fp = fopen($file, 'rb');
    while (!feof($fp))
    	echo fgets($fp, 16384);
     
    exit;
    (En pièce jointe le fichier get-file.php)

    Patguitare
    Fichiers attachés Fichiers attachés

+ Répondre à la discussion
Cette discussion est résolue.

Discussions similaires

  1. Téléchargement gros fichier interrompu
    Par SurfingJeff dans le forum Langage
    Réponses: 11
    Dernier message: 03/12/2009, 10h22
  2. Téléchargement de fichier
    Par casafa dans le forum Web & réseau
    Réponses: 21
    Dernier message: 18/06/2009, 23h34
  3. Téléchargement de fichiers par HTTP / FTP
    Par Gladiator dans le forum Serveurs (Apache, IIS,...)
    Réponses: 2
    Dernier message: 07/12/2005, 11h28
  4. Réponses: 5
    Dernier message: 05/11/2005, 17h53
  5. [SOAP][XML][C#.NET] Téléchargement de fichiers XML
    Par juniorAl dans le forum XML/XSL et SOAP
    Réponses: 2
    Dernier message: 27/06/2005, 09h35

Partager

Partager
  • Envoyer la discussion sur Viadeo
  • Envoyer la discussion sur Twitter
  • Envoyer la discussion sur Google
  • Envoyer la discussion sur Facebook
  • Envoyer la discussion sur Digg
  • Envoyer la discussion sur Delicious
  • Envoyer la discussion sur MySpace
  • Envoyer la discussion sur Yahoo