1. Email Traffics
2. Form Data
3. Form Generator
|
Form Admin Panel | Main Menu ' ; echo 'Logout' ; }; ?> |
" . join( " | ", $this->columns ) . " | |
{$i} | " . join( " | ", $r ) . " |
\n"; echo join("",file($file) ); echo "\n"; }else{ $man = new phpfmgDataManager(); $man->displayRecords(); }; }else{ echo "No form data found."; }; phpfmg_admin_footer(); } function phpfmg_log_download(){ $n = isset($_REQUEST['file']) ? $_REQUEST['file'] : ''; $files = array( 1 => PHPFMG_EMAILS_LOGFILE, 2 => PHPFMG_SAVE_FILE, ); $file = $files[$n]; if( is_file($file) ){ phpfmg_util_download( $file, PHPFMG_SAVE_FILE == $file ? 'form-data.csv' : 'email-traffics.txt', true, 1 ); // skip the first line }else{ phpfmg_admin_header(); echo "No email traffic log found."; phpfmg_admin_footer(); }; } function phpfmg_log_delete(){ $n = isset($_REQUEST['file']) ? $_REQUEST['file'] : ''; $files = array( 1 => PHPFMG_EMAILS_LOGFILE, 2 => PHPFMG_SAVE_FILE, ); phpfmg_admin_header(); $file = $files[$n]; if( is_file($file) ){ echo unlink($file) ? "It has been deleted!" : "Failed to delete!" ; }; phpfmg_admin_footer(); } function phpfmg_util_download($file, $filename='', $toCSV = false, $skipN = 0 ){ if (!is_file($file)) return false ; set_time_limit(0); $buffer = ""; $i = 0 ; $fp = @fopen($file, 'rb'); while( !feof($fp)) { $i ++ ; $line = fgets($fp); if($i > $skipN){ // skip lines if( $toCSV ){ $line = str_replace( chr(0x09), ',', $line ); $buffer .= phpfmg_data2record( $line, false ); }else{ $buffer .= $line; }; }; }; fclose ($fp); /* If the Content-Length is NOT THE SAME SIZE as the real conent output, Windows+IIS might be hung!! */ $len = strlen($buffer); $filename = basename( '' == $filename ? $file : $filename ); $file_extension = strtolower(substr(strrchr($filename,"."),1)); switch( $file_extension ) { case "pdf": $ctype="application/pdf"; break; case "exe": $ctype="application/octet-stream"; break; case "zip": $ctype="application/zip"; break; case "doc": $ctype="application/msword"; break; case "xls": $ctype="application/vnd.ms-excel"; break; case "ppt": $ctype="application/vnd.ms-powerpoint"; break; case "gif": $ctype="image/gif"; break; case "png": $ctype="image/png"; break; case "jpeg": case "jpg": $ctype="image/jpg"; break; case "mp3": $ctype="audio/mpeg"; break; case "wav": $ctype="audio/x-wav"; break; case "mpeg": case "mpg": case "mpe": $ctype="video/mpeg"; break; case "mov": $ctype="video/quicktime"; break; case "avi": $ctype="video/x-msvideo"; break; //The following are for extensions that shouldn't be downloaded (sensitive stuff, like php files) case "php": case "htm": case "html": $ctype="text/plain"; break; default: $ctype="application/x-download"; } //Begin writing headers header("Pragma: public"); header("Expires: 0"); header("Cache-Control: must-revalidate, post-check=0, pre-check=0"); header("Cache-Control: public"); header("Content-Description: File Transfer"); //Use the switch-generated Content-Type header("Content-Type: $ctype"); //Force the download header("Content-Disposition: attachment; filename=".$filename.";" ); header("Content-Transfer-Encoding: binary"); header("Content-Length: ".$len); while (@ob_end_clean()); // no output buffering ! flush(); echo $buffer ; return true; } ?>