Quoted
Warning: Cannot modify header information - headers already sent by (output started at /var/www/virtual/xxxxxxx/htdocs/theme/cache/%%FA^FA4^FA44DF90%%page_header.htm.php:9) in /var/www/virtual/xxx/htdocs/class/pdf/pdf_inc/fpdf.php on line 998
FPDF error: Some data has already been output to browser, can't send PDF file
|
|
PHP Quellcode |
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 |
<?PHP include('./include/init.php'); global $Core, $Smarty, $lang; define('FPDF_FONTPATH', './class/pdf/pdf_inc/font/'); include_once('./class/pdf/pdf_inc/fpdf.php'); include_once('./class/pdf/pdf_inc/class_calculation_pdf.php'); require('./class/mail/class.phpmailer.php'); $pakage = trim(htmlspecialchars($_GET['pakage'])); // Header laden $Core->page_header($lang['BUY'] . ' • ' . $pakage); $message = ''; // Absenden if (isset($_POST['send'])) { $buy_date = $Core->userdate(time()); $message = false; // Alle felder ausgefüllt? if ( !$_POST['name'] or !$_POST['adresse'] or !$_POST['plz'] or !$_POST['ort'] or !$_POST['phone'] or !$_POST['email'] ) { $message .= 'Du hast nicht alle Felder ausgefült <br />'; $fehler = true; } // Email gültig if ( !$Core->check_email($_POST['email']) ) { $message .= 'Du hast eine Falsche Email Adresse angegeben <br />'; $fehler = true; } // AGB Akzeptiert if ( !@$_POST['acept'] ) { $message .= 'Sie müssen die AGBs akzeptieren. <br />'; $fehler = true; } //Kein Fehler aufgetaucht? if ( !isset($fehler) ) { // EIntragen der Kunden Daten $pdoparams = array( ':paket' => $_GET['pakage'], ':anrede' => $_POST['anrede'], ':name' => $_POST['name'], ':adresse' => $_POST['adresse'], ':ort' => $_POST['plz'] . ' ' . $_POST['ort'], ':phone' => $_POST['phone'], ':email' => $_POST['email'], ); $sql = 'INSERT INTO ' . KUNDEN . ' (paket, anrede, name, adresse, ort, phone, email) VALUES (:paket, :anrede, :name, :adresse, :ort, :phone, :email)'; $stmt = MyDB::getInstance()->prepare($sql); $stmt->execute($pdoparams); // AUsgabe der letzten Kunden ID $Kunden_ID = MyDB::getInstance()->lastInsertId(); $bodytext = $lang['BUY_EMAIL_TEXT']; $bodyhtml = $lang['BUY_EMAIL_TEXT']; /* -------------------------- */ $pdf = new Calculation(); // INI-Datei laden $pdf->global = parse_ini_file('./class/pdf/pdf_inc/pdf_config.ini',TRUE); // Grundeinstellungen $pdf->customer['adress'] = $_POST['name'].'\n'.$_POST['adresse'].'\n\n'.$_POST['plz'] . ' ' . $_POST['ort']; $pdf->calculation['date'] = $buy_date; $pdf->calculation['number'] = $Kunden_ID['id']; $pdf->calculation['subject'] = "Produkt Bestellung"; $pdf->calculation['subject_info'] = "Produkt Bestellung"; // Grundeinstellungen,Layout setzen $pdf->CalculationInitRender(); // Project-Daten einlesen include('./class/pdf/pdf_inc/project.inc'); // Zahlungsziel, AGB, Endsumme etc. setzen $pdf->CalculationEnd(); $pdf_doc = $pdf->Output('', 'S'); // Email senden $mail = new PHPMailer(); $mail->From = $Core->config['email']; $mail->FromName = 'xxxx'; $mail->Subject = 'xxxx Bestellung des Paketes ' . $_GET['pakage']; $mail->AltBody = $bodytext; $mail->MsgHTML($bodyhtml); $mail->AddAddress( $_POST['email'] ); // PDF Anhang mitsenden $mail->AddStringAttachment($pdf_doc, 'pdf_doc.pdf', '', 'application/pdf'); $mail->Send(); $message = 'Danke für ihre Bestellungen. In wenigen Minuten sollten sie eine Email mit weiteren Informationen verhalten.'; } } $agb_link = '<a href="agb.php">'.$lang['AGB'].'</a>'; $Smarty->assign(array( 'PAKAGE_VERSION_BUY' => $lang['PAKAGE'] . ' ' . $pakage . ' ' . $lang['BUY'], 'PAKAGE' => $pakage, 'RP-M' => (@$_GET['pakage'] == 'rp-m')? true : false, 'RP-L' => (@$_GET['pakage'] == 'rp-l')? true : false, 'AGB_ACEPT' => sprintf($lang['AGB_ACEPT'], $agb_link), 'MESSAGE' => $message, )); $Smarty->display('buy.htm'); // Footer laden $Core->page_footer(); ?> |
|
|
PHP Quellcode |
1 2 |
$pdf_doc = $pdf->Output('', 'S'); $mail->AddStringAttachment($pdf_doc, 'pdf_doc.pdf', '', 'application/pdf'); |
|
|
PHP Quellcode |
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 |
<?PHP // Fehlerreport von E_NOTICE deaktivieren error_reporting(E_ALL); $time = round(microtime(), 3); // UTF8 erzwingen @setlocale(LC_CTYPE, 'de_DE.utf8', 'de_DE.UTF-8', 'en_US.utf8', 'en_US.UTF-8', 'en_GB.utf8', 'en_GB.UTF-8', 'de_AT.utf8', 'de_AT.UTF-8', 'de_CH.utf8', 'de_CH.UTF-8'); if( function_exists('mb_internal_encoding') ) { mb_internal_encoding('utf-8'); } header('Content-type: text/html; charset=utf-8'); foreach ($_POST as $key => $value) { $value = strip_tags ($value); $value = htmlspecialchars ($value); $_POST[$key] = $value; } foreach ($_GET as $key => $value) { $value = strip_tags ($value); $value = htmlspecialchars ($value); $_GET[$key] = $value; } require('./class/engine/Smarty.class.php'); require('./include/config.php'); require('./include/constants.php'); require('./class/core_class.php'); require('./class/db_class.php'); require('./class/mail_class.php'); require('./class/kunde_class.php'); $Smarty = new Smarty(); $Core = new Core(); $Kunde = new KUNDE(); global $Core, $Smarty, $Kunde; // Prüfen ob Online oder Offline // und ausgabe des Nicks if ($Kunde->chkonline() == false ) { } else { $user_cookie = $_COOKIE['rootpoint']; $pdoparams = array( ':cookie_key' => $user_cookie, ); $sql = "SELECT * FROM " . KUNDEN . " WHERE cookie_key = :cookie_key"; $stmt = MyDB::getInstance()->prepare($sql); $stmt->execute($pdoparams); $userdata = $stmt->fetch(); } ?> |
|
|
PHP Quellcode |
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 |
<?PHP class Core { public $config = array(); // Laden aller Einstellungen die immer verfügbar sind public function __construct() { global $Core, $Smarty, $lang; $sql = "SELECT * FROM " . CONFIG; $stmt = MyDB::getInstance()->prepare($sql); $stmt->execute(); while ($row = $stmt->fetch()) { $this->config[$row['name']] = $row['value']; } require('./lang/de/lang_global.php'); } /** * Email Adresse prüfen * * @param $email String Email Adresse * @access public */ public function check_email($email) { global $Core, $Smarty; if (!preg_match('/^[^0-9][a-zA-Z0-9_]+([.][a-zA-Z0-9_]+)*[@][a-zA-Z0-9_]+([.][a-zA-Z0-9_]+)*[.][a-zA-Z]{2,4}$/', $email)) { return false; } else { return true; } } /** * Timestamp umwandeln * * @param $date int timestamp * @access public */ public function userdate($date) { $date = date("d.m.Y",$date); return $date; } /** * time() Umwandeln * * @param $var Wers aus der Datenbank bzw Formular * @access public */ public function usertime($var) { @$var = date("d.m.Y - H:i",$var); return $var; } /** * GetICQStatus() ICQ Status ermitteln * * @param $uin INT ICQ ID * @access public */ public function GetICQStatus($uin) { if(!is_numeric($uin)) return false; $fp = @fsockopen('status.icq.com', 80, $errno, $errstr, 5); if(is_resource($fp)) { stream_set_timeout($fp,3); $request = "HEAD /online.gif?icq=".$uin."&img=5 HTTP/1.1\r\n"."Host: status.icq.com\r\n"."Connection: close\r\n\r\n"; fputs($fp, $request); do { $response = fgets($fp, 25); } while(!feof($fp) && !stristr($response, 'Location')); fclose($fp); if(strstr($response, 'online1')) return 'online'; if(strstr($response, 'online0')) return 'offline'; if(strstr($response, 'online2')) return 'offline'; } else { return 'offline'; } } /** * Ausgabe des Headers * * @param $title String Titel der aufgerufenen Seite * @access public */ public function page_header($title) { global $Core, $Smarty, $lang, $Kunde; // Cache aktiv? $Smarty->caching = $this->config['cache']; $Smarty->assign(array( 'PAGE_HEADER' => $this->config['sitename'] . ' • ' . $this->config['description'] . ' • ' . $title, 'LANG' => $lang, 'YESNO' => array('1' => $lang['YES'], '0' => $lang['NO']), 'EMAIL' => $this->config['email'], 'USER_LOGGED_IN' => !$Kunde->chkonline(), )); $Smarty->display('page_header.htm'); } /** * Ausgabe des Footers * * @access public */ public function page_footer() { global $Core, $Smarty; $sql = "SELECT * FROM " . NEWS; $stmt = MyDB::getInstance()->prepare($sql); $stmt->execute(); while ($row = $stmt->fetch()) { $row['date'] = $this->userdate($row['date']); $news[] = $row; } $time2 = round(microtime(), 3); $Smarty->assign(array( 'GEN_TIME' => $time2 - @$time, 'NEWS' => $news, 'ICQ_STATUS' => $this->GetICQStatus(), 'ICQ_NR' => $this->config['icq'], )); $Smarty->display('page_footer.htm'); } } ?> |
|
|
PHP Quellcode |
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 |
function Output($file='',$download=false) { //Output PDF to file or browser global $HTTP_ENV_VARS; if($this->state<3) $this->Close(); if($file=='') { //Send to browser Header('Content-Type: application/pdf'); if(headers_sent()) $this->Error('Some data has already been output to browser, can\'t send PDF file'); Header('Content-Length: '.strlen($this->buffer)); Header('Content-disposition: inline; filename=doc.pdf'); echo $this->buffer; } else { if($download) { //Download file if(isset($HTTP_ENV_VARS['HTTP_USER_AGENT']) and strpos($HTTP_ENV_VARS['HTTP_USER_AGENT'],'MSIE 5.5')) Header('Content-Type: application/dummy'); else Header('Content-Type: application/octet-stream'); if(headers_sent()) $this->Error('Some data has already been output to browser, can\'t send PDF file'); Header('Content-Length: '.strlen($this->buffer)); Header('Content-disposition: attachment; filename='.$file); echo $this->buffer; } else { //Save file locally $f=fopen($file,'wb'); if(!$f) $this->Error('Unable to create output file: '.$file); fwrite($f,$this->buffer,strlen($this->buffer)); fclose($f); } } } |
|
|
PHP Quellcode |
1 |
$pdf_doc = $pdf->Output('', 'S'); |
|
|
PHP Quellcode |
1 |
$pdf_doc = $pdf->Output('irgendwas', 'S'); |
|
|
PHP Quellcode |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 |
function Output($name='', $dest='') { //Output PDF to some destination if($this->state<3) $this->Close(); $dest=strtoupper($dest); if($dest=='') { if($name=='') { $name='doc.pdf'; $dest='I'; } else $dest='F'; } switch($dest) usw... |
This post has been edited 1 times, last edit by "Rondrer" (Jul 22nd 2010, 5:44pm)