nginx - php header <!-- Core Error --> and file currupted -
i'm having issue since update php version 5.4.41.
i'm running on nginx server php 5.4.41.
i've made php code allow me retrieve file , download it. since updated php code file i'm trying download corrupted. upload txt file , see happening.
ex: if upload text file test inside after download it, become
<!--core error-->test
here complete code
<?php require_once("include.php"); if(!xml2php("customer")) { $smarty->assign('error_msg',"error in language file"); } //grab key url $key = $var['key']; if ($var['escape'] == 1) { if (isset($key)) { $q = "select * ".prfx."table_customer_backup customer_backup_key=".$db->qstr($key); if(!$rs = $db->execute($q)) { force_page('core', 'error&error_msg=mysql error: '.$db- >errormsg().'&menu=1&type=database'); exit; } else { $customer_backup_filename = $rs->fields['customer_backup_filename']; $customer_backup_ext = $rs->fields['customer_backup_ext']; $customer_backup_file_link = $rs->fields['customer_backup_file_link']; $customer_backup_filetype = $rs->fields['customer_backup_filetype']; } if(empty($customer_backup_file_link)){ force_page('core', 'error&error_msg=this key not valid'); exit; } } else { force_page('core', 'error&error_msg=this key not valid'); exit; } $fakefilename= $customer_backup_filename.".".$customer_backup_ext; $file = $customer_backup_file_link; if (isset($customer_backup_file_link, $customer_backup_ext, $customer_backup_filename, $customer_backup_filetype) && file_exists($customer_backup_file_link)){ ignore_user_abort(true); set_time_limit(0); // disable time limit script header("cache-control: public"); header("content-description: file transfer"); header("content-type: ".$customer_backup_filetype); header("content-disposition: attachment; filename=".$fakefilename); header("content-length: ".filesize($file)); header("content-transfer-encoding: binary"); readfile($file); } else { force_page('core', 'error&error_msg=there problem downloading file. please contact administrator.'); exit; } } else { force_page('core', 'error&error_msg=there problem downloading file. please contact administrator.'); exit; } $smarty->display('customer'.sep.'download.tpl'); //exit; ?>
i discover if put // in front of
header("content-type: ".$customer_backup_filetype); header("content-disposition: attachment; filename=".$fakefilename);
to ignore file display browser without issue
i need i've been working on issue 2 days , haven't found nothing.
update :
i discover if try escape smarty template engine not work same issue. if load smarty template engine text display without error.
http://www.exemple.com/index.php?page=customer:download&key=1414830421&escape=1 //escaping smarty template engine
the <!--core error-->
has originate place before:
readfile($file);
since line content 'test' written, displays after it.
my guesses be, source either 1 of:
- include.php
- xml2php()
- $db->execute()
maybe add additional output code, narrow down line, <!--core error-->
gets written.
Comments
Post a Comment