| [ Indice ] |
Riferimento incrociato di Joomla! 1.5.14 - VM 1.1.4Servizio fornito da VMItalia |
[Vedi sommario] [Stampa] [Vedi testo]
1 <?php 2 if( !defined( '_VALID_MOS' ) && !defined( '_JEXEC' ) ) die( 'Direct Access to '.basename(__FILE__).' is not allowed.' ); 3 /** 4 * 5 * @version $Id: shop.pdf_output.php 1821 2009-06-24 12:18:48Z soeren_nb $ 6 * @package VirtueMart 7 * @subpackage html 8 * @copyright Copyright (C) 2004-2007 soeren - All rights reserved. 9 * @license http://www.gnu.org/copyleft/gpl.html GNU/GPL, see LICENSE.php 10 * VirtueMart is free software. This version may have been modified pursuant 11 * to the GNU General Public License, and as distributed it includes or 12 * is derivative of works licensed under the GNU General Public License or 13 * other free or open source software licenses. 14 * See /administrator/components/com_virtuemart/COPYRIGHT.php for copyright notices and details. 15 * 16 * http://virtuemart.net 17 */ 18 mm_showMyFileName( __FILE__ ); 19 20 $showpage = vmGet( $_REQUEST, 'showpage'); 21 $flypage = vmGet( $_REQUEST, 'flypage'); 22 $product_id = vmGet( $_REQUEST, 'product_id'); 23 $category_id = vmGet( $_REQUEST, 'category_id'); 24 // Page Navigation Parameters 25 $my_page= explode ( '.', $showpage ); 26 27 $pagename = $my_page[1]; 28 $limit = intval( $vm_mainframe->getUserStateFromRequest( "viewlistlimit{$showpage}", 'limit', $mosConfig_list_limit ) ); 29 $limitstart = intval( $vm_mainframe->getUserStateFromRequest( "view{$keyword}{$category_id}{$pagename}limitstart", 'limitstart', 0 )) ; 30 31 32 /* Who cares for Safe Mode ? Not me! */ 33 if (@file_exists( "/usr/bin/htmldoc" )) { 34 35 $allowed_pdf_pages = array('shop.product_details', 'shop.browse'); 36 if( in_array( $showpage, $allowed_pdf_pages )) exit; 37 38 $load_page = escapeshellarg($mosConfig_live_site . "/index2.php?option=com_virtuemart&page=$showpage&flypage=$flypage&product_id=$product_id&category_id=$category_id&pop=1&hide_js=1&output=pdf"); 39 header( "Content-Type: application/pdf" ); 40 header( "Content-Disposition: inline; filename=\"pdf-store.pdf\"" ); 41 flush(); 42 //following line for Linux only - windows may need the path as well... 43 passthru( "/usr/bin/htmldoc --no-localfiles --quiet -t pdf14 --jpeg --webpage --header t.D --footer ./. --size letter --left 0.5in $load_page" ); 44 exit; 45 } 46 else { 47 freePDF( $showpage, $flypage, $product_id, $category_id, $limitstart, $limit ); 48 } 49 function repairImageLinks( $html ) { 50 51 if( PSHOP_IMG_RESIZE_ENABLE == '1' ) { 52 $images = array(); 53 if (preg_match_all("/<img[^>]*>/", $html, $images) > 0) { 54 $i = 0; 55 foreach ($images as $image) { 56 if ( is_array( $image ) ) { 57 foreach( $image as $src) { 58 preg_match("'src=\"[^\"]*\"'si", $src, $matches); 59 $source = str_replace ("src=\"", "", $matches[0]); 60 $source = str_replace ("\"", "", $source); 61 $fileNamePos = strpos($source, "filename="); 62 if ( $fileNamePos > 0 ) { 63 $firstAmpersand = strpos( $source, "&" ); 64 $fileName = substr( $source, $fileNamePos+9, $firstAmpersand - $fileNamePos-9 ); 65 $extension = strrchr( $fileName, "." ); 66 $fileNameNoExt = str_replace( $extension, "", $fileName ); 67 // $newSource = IMAGEURL . "product/resized/".$fileNameNoExt."_".PSHOP_IMG_WIDTH."x".PSHOP_IMG_HEIGHT.$extension; 68 $newSource = IMAGEURL . "product/resized/".$fileNameNoExt.$extension; 69 } 70 else 71 $newSource= $source; 72 $html = str_replace( $source, $newSource, $html ); 73 } 74 } 75 } 76 } 77 } 78 return $html; 79 80 } 81 function freePDF( $showpage, $flypage, $product_id, $category_id, $limitstart, $limit ) { 82 global $db, $sess, $auth, $my, $perm, $VM_LANG, $mosConfig_live_site, $mosConfig_sitename, $mosConfig_offset, $mosConfig_hideCreateDate, $mosConfig_hideAuthor, 83 $mosConfig_hideModifyDate,$mm_action_url, $database, $mainframe, $mosConfig_absolute_path, $vendor_full_image, $vendor_name, $limitstart, $limit, 84 $vm_mainframe, $keyword, $cur_template; 85 86 while( @ob_end_clean() ); 87 error_reporting( 0 ); 88 ini_set( "allow_url_fopen", "1" ); 89 90 switch( $showpage ) { 91 case "shop.product_details": 92 $_REQUEST['flypage'] = "shop.flypage_lite_pdf"; 93 $_REQUEST['product_id'] = $product_id; 94 95 ob_start(); 96 include( PAGEPATH . $showpage . '.php' ); 97 $html .= ob_get_contents(); 98 ob_end_clean(); 99 100 $html = repairImageLinks( $html ); 101 break; 102 103 case "shop.browse": 104 // vmInputFilter is needed for the browse page 105 if( !isset( $vmInputFilter ) || !isset( $GLOBALS['vmInputFilter'] ) ) { 106 $GLOBALS['vmInputFilter'] = $vmInputFilter = vmInputFilter::getInstance(); 107 } 108 109 $_REQUEST['category_id'] = $category_id; 110 111 ob_start(); 112 include( PAGEPATH . $showpage . '.php' ); 113 $html .= ob_get_contents(); 114 ob_end_clean(); 115 116 $html = repairImageLinks( $html ); 117 break; 118 } 119 120 $logo = IMAGEPATH . "vendor/$vendor_full_image"; 121 $logourl = IMAGEURL . "vendor/$vendor_full_image"; 122 123 if (version_compare( phpversion(), '5.0' ) < 0 || extension_loaded('domxml') || !file_exists(CLASSPATH."pdf/dompdf/dompdf_config.inc.php")) { 124 125 define('FPDF_FONTPATH', CLASSPATH.'pdf/font/'); 126 define( 'RELATIVE_PATH', CLASSPATH.'pdf/' ); 127 require ( CLASSPATH.'pdf/html2fpdf.php'); 128 require ( CLASSPATH.'pdf/html2fpdf_site.php'); 129 130 $pdf = new PDF(); 131 132 $pdf->AddPage(); 133 $pdf->SetFont('Arial','',11); 134 $pdf->InitLogo($logo); 135 $pdf->PutTitle($mosConfig_sitename); 136 $pdf->PutAuthor( $vendor_name ); 137 $html = str_replace ("&", "&", $html); 138 $pdf->WriteHTML($html); 139 140 $pdf->Output(); 141 } elseif( file_exists(CLASSPATH."pdf/dompdf/dompdf_config.inc.php")) { 142 // In this part you can use the dompdf library (http://www.digitaljunkies.ca/dompdf/) 143 // Just extract the dompdf archive to /classes/pdf/dompdf 144 //require_once( CLASSPATH . "pdf/dompdf/dompdf_config.inc.php" ); 145 //require_once( CLASSPATH . "pdf/dompdf/load_font.php" ); 146 147 //require_once( CLASSPATH . "pdf/dompdf/dompdf.php" ); 148 //define('DOMPDF_FONTPATH', CLASSPATH.'pdf/dompdf/lib/fonts/'); 149 //define( 'RELATIVE_PATH', CLASSPATH.'pdf/dompdf/' ); 150 $image_details = getimagesize($logo); 151 $footer = '<script type="text/php"> 152 153 if ( isset($pdf) ) { 154 155 // Open the object: all drawing commands will 156 // go to the object instead of the current page 157 $footer = $pdf->open_object(); 158 159 $w = $pdf->get_width(); 160 $h = $pdf->get_height(); 161 162 // Draw a line along the bottom 163 $y = $h - 2 * 12 - 24; 164 $pdf->line(16, $y, $w - 16, $y, "grey", 1); 165 166 // Add a logo 167 $img_w = 2 * 72; // 2 inches, in points 168 $img_h = 1 * 72; // 1 inch, in points -- change these as required 169 $pdf->image("'.$logourl.'", "'.$image_details[2].'", ($w - $img_w) / 2.0, $y - $img_h, $img_w, $img_h); 170 171 // Close the object (stop capture) 172 $pdf->close_object(); 173 // Add the object to every page. You can 174 // also specify "odd" or "even" 175 $pdf->add_object($footer, "all"); 176 177 } 178 </script>'; 179 180 $website = '<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> 181 <html xmlns="http://www.w3.org/1999/xhtml"> 182 <head>'. $mainframe->getHead().' 183 <link rel="stylesheet" href="templates/'. $cur_template .'/css/template_css.css" type="text/css" /> 184 <link rel="stylesheet" href="'. VM_THEMEURL .'theme.css" type="text/css" /> 185 <link rel="shortcut icon" href="'. $mosConfig_live_site .'/images/favicon.ico" /> 186 <meta http-equiv="Content-Type" content="text/html; '. _ISO.'" /> 187 <meta name="robots" content="noindex, nofollow" /> 188 </head> 189 <body class="contentpane"> 190 ' . $html .' 191 ' . $footer .' 192 </body> 193 </html>'; 194 195 196 $website = str_replace ("resized%2F", "", $website); 197 $website = str_replace ("&", "&", $website); 198 $website = str_replace ("#", "", $website); 199 200 require_once( CLASSPATH."pdf/dompdf/dompdf_config.inc.php"); 201 $dompdf = new DOMPDF(); 202 203 $dompdf->load_html($website); 204 $dompdf->render(); 205 // die( htmlspecialchars($website)); 206 //YOU CAN EITHER UNCOMMENT THE FOLLOWING LINES AND COMMENT THIS LINE --> // $dompdf->stream( "virtue".$limitstart.".pdf", array('Attachment' => 1)); 207 // OR LEAVE THE FOLLOWING LINES COMMENTED WITH // AND THE $dompdf->stream( "virtue".$limitstart.".pdf", array('Attachment' => 1)); UNCOMMENTED, BOTH WORK AT LAST !! 208 // $file = "virtutest1.pdf"; 209 // file_put_contents($file, $website); 210 // $url = "dompdf.php?input_file=". $mosConfig_live_site."/".rawurlencode($file) . 211 // "&paper=letter&output_file=" . rawurlencode("virtue".$limitstart.".pdf"); 212 //$url = str_replace ("%3A", ":", $url ); 213 //$url = str_replace ("%5C", "/", $url ); 214 //$url = str_replace ("&", "&", $url); 215 //header("Location: ".$mosConfig_live_site . "/administrator/components/com_virtuemart/classes/pdf/dompdf/$url"); 216 217 218 $dompdf->stream( "virtue".$limitstart.".pdf", array('Attachment' => 1)); 219 220 } 221 222 223 }
titolo
Descrizione
Corpo
titolo
Descrizione
Corpo
titolo
Descrizione
Corpo
titolo
Corpo
| Generato il: Mon Oct 19 20:29:27 2009 | Generato con PHPXref 0.7 |