Jump to content

jakebur01

Members
  • Posts

    885
  • Joined

  • Last visited

Posts posted by jakebur01

  1. I am trying to display two images per row.  Will add in table tags later so it will look nicer.  Anyway, it is leaving off the second image.  So, I have 6 images and image number two is blank.

    $dirname = "Files/$listingid/images/";
    
    $images = glob($dirname."*");
       /*
       $html .= '<table width="100%">';
    
    foreach($images as $image){
        
    $html .= "<tr><td><center>";
    
    $html .="<img src=\"$image\" width=\"300\">";
    
    $html .= "</a></center></td>";
    
    $html .= "</td></tr>";
    }
      $html .= "</table>";
       */
    
    $countImages = count($images) ;
    
    $imagesPerRow = 2;
    
    
    for ($i = 0 ; $i < $countImages; $i++) {
        //display image here
        $image = $images[$i] ;
        $html .= "<img width = \"200\" src='$image'>" ;
    
        
    	if ($i % $imagesPerRow == 0) {
            //have displayed an entire row
            $html .= '<br>' ;
        }
    
    	
    }
    
  2. CroNiX I have a license.  Besides that doesn't make any sense to me.  Google Earth Pro lets you export images and pdf's. 

     

    Right now they can print a picture of the map off of the webpage, my only problem is that I have my content ( details, images, etc.) in tabs.  So, If you print the page you are only going to get whats displayed in the active tab.  By putting everything on pages in a pdf that will allow them to print everything they need on individual pages.  Or I could e-mail them a copy to print.  I'm not doing anything illegal, they would print the map anyway.

  3. There has to be a way to alter the code so that it will see it as a .jpg.  I am using jpg-baseline as the static image format.  Could the code be altered to where it doesn't look for an extension but would bypass and parse all images as .jpg's?

    http://maps.googleapis.com/maps/api/staticmap?format=jpg-baseline&zoom=15&size=500x300&maptype=hybrid&path=color:0xff0000ff%7Cweight:3%7C33.00246877112488,-92.93866290403291%7C%2033.00644261225979,-92.93867958613085%7C%2033.00645557858705,-92.94401937409705%7C%2033.00247812848498,-92.94400274254195%7C%2033.00246877112488,-92.93866290403291
    function _getImage(&$file, $firsttime=true, $allowvector=true, $orig_srcpath=false) { 
    	// firsttime i.e. whether to add to this->images - use false when calling iteratively
    	// Image Data passed directly as var:varname
    	if (preg_match('/var:\s*(.*)/',$file, $v)) { 
    		$data = $this->$v[1];
    		$file = md5($data);
    	}
    	// mPDF 5.5.13
    	if (preg_match('/data:image\/(gif|jpeg|png);base64,(.*)/',$file, $v)) { 
    		$type = $v[1];
    		$data = base64_decode($v[2]);
    		$file = md5($data);
    	}
    
    	// mPDF 5.6.02
    	if ($firsttime && $file && substr($file,0,5)!='data:') { $file = urlencode_part($file); }
    	if ($firsttime && $orig_srcpath && substr($orig_srcpath,0,5)!='data:') { $orig_srcpath = urlencode_part($orig_srcpath); }
    
    	$ppUx = 0;
    	if ($orig_srcpath && isset($this->images[$orig_srcpath])) { $file=$orig_srcpath; return $this->images[$orig_srcpath]; }
    	if (isset($this->images[$file])) { return $this->images[$file]; }
    	else if ($orig_srcpath && isset($this->formobjects[$orig_srcpath])) { $file=$orig_srcpath; return $this->formobjects[$file]; }
    	else if (isset($this->formobjects[$file])) { return $this->formobjects[$file]; }
    	// Save re-trying image URL's which have already failed
    	else if ($firsttime && isset($this->failedimages[$file])) { return $this->_imageError($file, $firsttime, ''); } 
    	if (empty($data)) {
    		$type = '';
    		$data = '';
    
     		if ($orig_srcpath && $this->basepathIsLocal && $check = @fopen($orig_srcpath,"rb")) {
    			fclose($check); 
    			$file=$orig_srcpath;
    			$data = file_get_contents($file);
    			$type = $this->_imageTypeFromString($data);
    		}
    		if (!$data && $check = @fopen($file,"rb")) {
    			fclose($check); 
    			$data = file_get_contents($file);
    			$type = $this->_imageTypeFromString($data);
    		}
    		if ((!$data || !$type) && !ini_get('allow_url_fopen') ) {	// only worth trying if remote file and !ini_get('allow_url_fopen')
    			$this->file_get_contents_by_socket($file, $data);	// needs full url?? even on local (never needed for local)
    			if ($data) { $type = $this->_imageTypeFromString($data); }
    		}
    		if ((!$data || !$type) && !ini_get('allow_url_fopen') && function_exists("curl_init")) {
    			$this->file_get_contents_by_curl($file, $data);		// needs full url?? even on local (never needed for local)
    			if ($data) { $type = $this->_imageTypeFromString($data); }
    		}
    
    	}
    	if (!$data) { return $this->_imageError($file, $firsttime, 'Could not find image file'); }
    	if (empty($type)) { $type = $this->_imageTypeFromString($data); }	
    	if (($type == 'wmf' || $type == 'svg') && !$allowvector) { return $this->_imageError($file, $firsttime, 'WMF or SVG image file not supported in this context'); }
    
    	// SVG
    	if ($type == 'svg') {
    		if (!class_exists('SVG', false)) { include(_MPDF_PATH .'classes/svg.php'); }
    		$svg = new SVG($this);
    		$family=$this->FontFamily;
    		$style=$this->FontStyle;
    		$size=$this->FontSizePt;
    		$info = $svg->ImageSVG($data);
    		//Restore font
    		if($family) $this->SetFont($family,$style,$size,false);
    		if (!$info) { return $this->_imageError($file, $firsttime, 'Error parsing SVG file'); }
    		$info['type']='svg';
    		$info['i']=count($this->formobjects)+1;
    		$this->formobjects[$file]=$info;
    		return $info;
    	}
    
    	// JPEG
    	if ($type == 'jpeg' || $type == 'jpg') {
    		$hdr = $this->_jpgHeaderFromString($data);
    		if (!$hdr) { return $this->_imageError($file, $firsttime, 'Error parsing JPG header'); }
    		$a = $this->_jpgDataFromHeader($hdr);
    		$j = strpos($data,'JFIF');
    		if ($j) { 
    			//Read resolution
    			$unitSp=ord(substr($data,($j+7),1));
    			if ($unitSp > 0) {
    				$ppUx=$this->_twobytes2int(substr($data,($j+,2));	// horizontal pixels per meter, usually set to zero
    				if ($unitSp == 2) {	// = dots per cm (if == 1 set as dpi)
    					$ppUx=round($ppUx/10 *25.4);
    				}
    			}
    		}
    		if ($a[2] == 'DeviceCMYK' && (($this->PDFA && $this->restrictColorSpace!=3) || $this->restrictColorSpace==2)) {
    			// convert to RGB image
    			if (!function_exists("gd_info")) { $this->Error("JPG image may not use CMYK color space (".$file.")."); }
    			if ($this->PDFA && !$this->PDFAauto) { $this->PDFAXwarnings[] = "JPG image may not use CMYK color space - ".$file." - (Image converted to RGB. NB This will alter the colour profile of the image.)"; }
    			$im = @imagecreatefromstring($data);
    			if ($im) {
    				$tempfile = _MPDF_TEMP_PATH.'_tempImgPNG'.md5($file).RAND(1,10000).'.png';
    				imageinterlace($im, false);
    				$check = @imagepng($im, $tempfile);
    				if (!$check) { return $this->_imageError($file, $firsttime, 'Error creating temporary file ('.$tempfile.') whilst using GD library to parse JPG(CMYK) image'); }
    				$info = $this->_getImage($tempfile, false);
    				if (!$info) { return $this->_imageError($file, $firsttime, 'Error parsing temporary file ('.$tempfile.') created with GD library to parse JPG(CMYK) image'); }
    				imagedestroy($im);
    				unlink($tempfile);
    				$info['type']='jpg';
    				if ($firsttime) {
    					$info['i']=count($this->images)+1;
    					$this->images[$file]=$info;
    				}
    				return $info;
    			}
    			else { return $this->_imageError($file, $firsttime, 'Error creating GD image file from JPG(CMYK) image'); }
    		}
    		else if ($a[2] == 'DeviceRGB' && ($this->PDFX || $this->restrictColorSpace==3)) {
    			// Convert to CMYK image stream - nominally returned as type='png'
    			$info = $this->_convImage($data, $a[2], 'DeviceCMYK', $a[0], $a[1], $ppUx, false);
    			if (($this->PDFA && !$this->PDFAauto) || ($this->PDFX && !$this->PDFXauto)) { $this->PDFAXwarnings[] = "JPG image may not use RGB color space - ".$file." - (Image converted to CMYK. NB This will alter the colour profile of the image.)"; }
    		}
    		else if (($a[2] == 'DeviceRGB' || $a[2] == 'DeviceCMYK') && $this->restrictColorSpace==1) {
    			// Convert to Grayscale image stream - nominally returned as type='png'
    			$info = $this->_convImage($data, $a[2], 'DeviceGray', $a[0], $a[1], $ppUx, false);
    		}
    		else {
    			$info = array('w'=>$a[0],'h'=>$a[1],'cs'=>$a[2],'bpc'=>$a[3],'f'=>'DCTDecode','data'=>$data, 'type'=>'jpg');
    			if ($ppUx) { $info['set-dpi'] = $ppUx; }
    		}
    		if (!$info) { return $this->_imageError($file, $firsttime, 'Error parsing or converting JPG image'); }
    
    		if ($firsttime) {
    			$info['i']=count($this->images)+1;
    			$this->images[$file]=$info;
    		}
    		return $info;
    	}
    
    	// PNG
    	else if ($type == 'png') {
    		//Check signature
    		if(substr($data,0,!=chr(137).'PNG'.chr(13).chr(10).chr(26).chr(10)) { 
    			return $this->_imageError($file, $firsttime, 'Error parsing PNG identifier'); 
    		}
    		//Read header chunk
    		if(substr($data,12,4)!='IHDR') { 
    			return $this->_imageError($file, $firsttime, 'Incorrect PNG file (no IHDR block found)'); 
    		}
    
    		$w=$this->_fourbytes2int(substr($data,16,4));
    		$h=$this->_fourbytes2int(substr($data,20,4));
    		$bpc=ord(substr($data,24,1));
    		$errpng = false;
    		$pngalpha = false; 
    		if($bpc> { $errpng = 'not 8-bit depth'; }
    		$ct=ord(substr($data,25,1));
    		if($ct==0) { $colspace='DeviceGray'; }
    		elseif($ct==2) { $colspace='DeviceRGB'; }
    		elseif($ct==3) { $colspace='Indexed'; }
    		elseif($ct==4) { $colspace='DeviceGray';  $errpng = 'alpha channel'; $pngalpha = true; }
    		else { $colspace='DeviceRGB'; $errpng = 'alpha channel'; $pngalpha = true; } 
    		if(ord(substr($data,26,1))!=0) { $errpng = 'compression method'; }
    		if(ord(substr($data,27,1))!=0) { $errpng = 'filter method'; }
    		if(ord(substr($data,28,1))!=0) { $errpng = 'interlaced file'; }
    		$j = strpos($data,'pHYs');
    		if ($j) { 
    			//Read resolution
    			$unitSp=ord(substr($data,($j+12),1));
    			if ($unitSp == 1) {
    				$ppUx=$this->_fourbytes2int(substr($data,($j+4),4));	// horizontal pixels per meter, usually set to zero
    				$ppUx=round($ppUx/1000 *25.4);
    			}
    		}
    		if (($colspace == 'DeviceRGB' || $colspace == 'Indexed') && ($this->PDFX || $this->restrictColorSpace==3)) {
    			// Convert to CMYK image stream - nominally returned as type='png'
    			$info = $this->_convImage($data, $colspace, 'DeviceCMYK', $w, $h, $ppUx, $pngalpha);
    			if (($this->PDFA && !$this->PDFAauto) || ($this->PDFX && !$this->PDFXauto)) { $this->PDFAXwarnings[] = "PNG image may not use RGB color space - ".$file." - (Image converted to CMYK. NB This will alter the colour profile of the image.)"; }
    		}
    		else if (($colspace == 'DeviceRGB' || $colspace == 'Indexed') && $this->restrictColorSpace==1) {
    			// Convert to Grayscale image stream - nominally returned as type='png'
    			$info = $this->_convImage($data, $colspace, 'DeviceGray', $w, $h, $ppUx, $pngalpha);
    		}
    		else if (($this->PDFA || $this->PDFX) && $pngalpha) {
    			// Remove alpha channel
    			if ($this->restrictColorSpace==1) {	// Grayscale
    				$info = $this->_convImage($data, $colspace, 'DeviceGray', $w, $h, $ppUx, $pngalpha);
    			}
    			else if ($this->restrictColorSpace==3) {	// CMYK
    				$info = $this->_convImage($data, $colspace, 'DeviceCMYK', $w, $h, $ppUx, $pngalpha);
    			}
    			else if ($this->PDFA ) {	// RGB
    				$info = $this->_convImage($data, $colspace, 'DeviceRGB', $w, $h, $ppUx, $pngalpha);
    			}
    			if (($this->PDFA && !$this->PDFAauto) || ($this->PDFX && !$this->PDFXauto)) { $this->PDFAXwarnings[] = "Transparency (alpha channel) not permitted in PDFA or PDFX files - ".$file." - (Image converted to one without transparency.)"; }
    		}
    		else if ($errpng || $pngalpha) {
    			if (function_exists('gd_info')) { $gd = gd_info(); }
    			else {$gd = array(); }
    			if (!isset($gd['PNG Support'])) { return $this->_imageError($file, $firsttime, 'GD library required for PNG image ('.$errpng.')'); }
    			$im = imagecreatefromstring($data);
    			if (!$im) { return $this->_imageError($file, $firsttime, 'Error creating GD image from PNG file ('.$errpng.')'); }
    			$w = imagesx($im);
    			$h = imagesy($im);
    			if ($im) {
    			   $tempfile = _MPDF_TEMP_PATH.'_tempImgPNG'.md5($file).RAND(1,10000).'.png';
    			   // Alpha channel set
    			   if ($pngalpha) {
    				if ($this->PDFA) { $this->Error("PDFA1-b does not permit images with alpha channel transparency (".$file.")."); }
    				$imgalpha = imagecreate($w, $h);
    				// generate gray scale pallete
    				for ($c = 0; $c < 256; ++$c) { ImageColorAllocate($imgalpha, $c, $c, $c); }
    				// extract alpha channel
    				for ($xpx = 0; $xpx < $w; ++$xpx) {
    					for ($ypx = 0; $ypx < $h; ++$ypx) {
    						$alpha = (imagecolorat($im, $xpx, $ypx) & 0x7F000000) >> 24;
    						// mPDF 5.7.2
    						if ($alpha < 127) {
    							imagesetpixel($imgalpha, $xpx, $ypx, (255-($alpha * 2)));
    						}
    					}
    				}
    				// create temp alpha file
    	 		 	$tempfile_alpha = _MPDF_TEMP_PATH.'_tempMskPNG'.md5($file).RAND(1,10000).'.png';
    				if (!is_writable(_MPDF_TEMP_PATH)) { 	// mPDF 5.7.2
    					ob_start(); 
    					$check = @imagepng($imgalpha);
    					if (!$check) { return $this->_imageError($file, $firsttime, 'Error creating temporary image object whilst using GD library to parse PNG image'); }
    					imagedestroy($imgalpha);
    					$this->_tempimg = ob_get_contents();
    					$this->_tempimglnk = 'var:_tempimg';
    					ob_end_clean();
    					// extract image without alpha channel
    					$imgplain = imagecreatetruecolor($w, $h);
    					imagealphablending( $imgplain, false );	// mPDF 5.7.2
    					imagecopy($imgplain, $im, 0, 0, 0, 0, $w, $h);
    					// create temp image file
    					$minfo = $this->_getImage($this->_tempimglnk, false);
    					if (!$minfo) { return $this->_imageError($file, $firsttime, 'Error parsing temporary file image object created with GD library to parse PNG image'); }
    					ob_start(); 
    					$check = @imagepng($imgplain);
    					if (!$check) { return $this->_imageError($file, $firsttime, 'Error creating temporary image object whilst using GD library to parse PNG image'); }
    					$this->_tempimg = ob_get_contents();
    					$this->_tempimglnk = 'var:_tempimg';
    					ob_end_clean();
    					$info = $this->_getImage($this->_tempimglnk, false);
    					if (!$info) { return $this->_imageError($file, $firsttime, 'Error parsing temporary file image object created with GD library to parse PNG image'); }
    					imagedestroy($imgplain);
    					$imgmask = count($this->images)+1;
    					$minfo['cs'] = 'DeviceGray';
    					$minfo['i']=$imgmask ;
    					$this->images[$tempfile_alpha] = $minfo;
    
    				}
    				else {
    					$check = @imagepng($imgalpha, $tempfile_alpha);
    					if (!$check) { return $this->_imageError($file, $firsttime, 'Failed to create temporary image file ('.$tempfile_alpha.') parsing PNG image with alpha channel ('.$errpng.')'); }
    					imagedestroy($imgalpha);
    
    					// extract image without alpha channel
    					$imgplain = imagecreatetruecolor($w, $h);
    					imagealphablending( $imgplain, false );	// mPDF 5.7.2
    					imagecopy($imgplain, $im, 0, 0, 0, 0, $w, $h);
    
    					// create temp image file
    					$check = @imagepng($imgplain, $tempfile);
    					if (!$check) { return $this->_imageError($file, $firsttime, 'Failed to create temporary image file ('.$tempfile.') parsing PNG image with alpha channel ('.$errpng.')'); }
    					imagedestroy($imgplain);
    					// embed mask image
    					$minfo = $this->_getImage($tempfile_alpha, false);
    					unlink($tempfile_alpha);
    					if (!$minfo) { return $this->_imageError($file, $firsttime, 'Error parsing temporary file ('.$tempfile_alpha.') created with GD library to parse PNG image'); }
    					$imgmask = count($this->images)+1;
    					$minfo['cs'] = 'DeviceGray';
    					$minfo['i']=$imgmask ;
    					$this->images[$tempfile_alpha] = $minfo;
    					// embed image, masked with previously embedded mask
    					$info = $this->_getImage($tempfile, false);
    					unlink($tempfile);
    					if (!$info) { return $this->_imageError($file, $firsttime, 'Error parsing temporary file ('.$tempfile.') created with GD library to parse PNG image'); }
    
    				}
    				$info['masked'] = $imgmask;
    				if ($ppUx) { $info['set-dpi'] = $ppUx; }
    				$info['type']='png';
    				if ($firsttime) {
    					$info['i']=count($this->images)+1;
    					$this->images[$file]=$info;
    				}
    				return $info;
    			   }
    			   else { 	// No alpha/transparency set
    				imagealphablending($im, false);
    				imagesavealpha($im, false); 
    				imageinterlace($im, false);
    				if (!is_writable($tempfile)) { 
    					ob_start(); 
    					$check = @imagepng($im);
    					if (!$check) { return $this->_imageError($file, $firsttime, 'Error creating temporary image object whilst using GD library to parse PNG image'); }
    					$this->_tempimg = ob_get_contents();
    					$this->_tempimglnk = 'var:_tempimg';
    					ob_end_clean();
    					$info = $this->_getImage($this->_tempimglnk, false);
    					if (!$info) { return $this->_imageError($file, $firsttime, 'Error parsing temporary file image object created with GD library to parse PNG image'); }
    					imagedestroy($im);
    				}
    				else {
    					$check = @imagepng($im, $tempfile );
    					if (!$check) { return $this->_imageError($file, $firsttime, 'Failed to create temporary image file ('.$tempfile.') parsing PNG image ('.$errpng.')'); }
    					imagedestroy($im);
    					$info = $this->_getImage($tempfile, false) ;
    					unlink($tempfile ); 
    					if (!$info) { return $this->_imageError($file, $firsttime, 'Error parsing temporary file ('.$tempfile.') created with GD library to parse PNG image'); }
    				}
    				if ($ppUx) { $info['set-dpi'] = $ppUx; }
    				$info['type']='png';
    				if ($firsttime) {
    					$info['i']=count($this->images)+1;
    					$this->images[$file]=$info;
    				}
    				return $info;
    			   }
    			}
    		}
    
    		else {
    			$parms='/DecodeParms <</Predictor 15 /Colors '.($ct==2 ? 3 : 1).' /BitsPerComponent '.$bpc.' /Columns '.$w.'>>';
    			//Scan chunks looking for palette, transparency and image data
    			$pal='';
    			$trns='';
    			$pngdata='';
    			$p = 33;
    			do {
    				$n=$this->_fourbytes2int(substr($data,$p,4));	$p += 4;
    				$type=substr($data,$p,4);	$p += 4;
    				if($type=='PLTE') {
    					//Read palette
    					$pal=substr($data,$p,$n);	$p += $n;
    					$p += 4;
    				}
    				elseif($type=='tRNS') {
    					//Read transparency info
    					$t=substr($data,$p,$n);	$p += $n;
    					if($ct==0) $trns=array(ord(substr($t,1,1)));
    					elseif($ct==2) $trns=array(ord(substr($t,1,1)),ord(substr($t,3,1)),ord(substr($t,5,1)));
    					else
    					{
    						$pos=strpos($t,chr(0));
    						if(is_int($pos)) $trns=array($pos);
    					}
    					$p += 4;
    				}
    				elseif($type=='IDAT') {
    					$pngdata.=substr($data,$p,$n);	$p += $n;
    					$p += 4;
    				}
    				elseif($type=='IEND') { break; }
    				else if (preg_match('/[a-zA-Z]{4}/',$type)) { $p += $n+4; }
    				else { return $this->_imageError($file, $firsttime, 'Error parsing PNG image data'); }
    			}
    			while($n);
    			if (!$pngdata) { return $this->_imageError($file, $firsttime, 'Error parsing PNG image data - no IDAT data found'); }
    			if($colspace=='Indexed' and empty($pal)) { return $this->_imageError($file, $firsttime, 'Error parsing PNG image data - missing colour palette'); }
    			$info = array('w'=>$w,'h'=>$h,'cs'=>$colspace,'bpc'=>$bpc,'f'=>'FlateDecode','parms'=>$parms,'pal'=>$pal,'trns'=>$trns,'data'=>$pngdata);
    			$info['type']='png';
    			if ($ppUx) { $info['set-dpi'] = $ppUx; }
    		}
    
    		if (!$info) { return $this->_imageError($file, $firsttime, 'Error parsing or converting PNG image'); }
    
    		if ($firsttime) {
    			$info['i']=count($this->images)+1;
    			$this->images[$file]=$info;
    		}
    		return $info;
    	}
    
    	// GIF
    	else if ($type == 'gif') {
    	if (function_exists('gd_info')) { $gd = gd_info(); }
    		else {$gd = array(); }
    		if (isset($gd['GIF Read Support']) && $gd['GIF Read Support']) {
    			$im = @imagecreatefromstring($data);
    			if ($im) {
    				$tempfile = _MPDF_TEMP_PATH.'_tempImgPNG'.md5($file).RAND(1,10000).'.png';
    				imagealphablending($im, false);
    				imagesavealpha($im, false); 
    				imageinterlace($im, false);
    				if (!is_writable($tempfile)) { 
    					ob_start(); 
    					$check = @imagepng($im);
    					if (!$check) { return $this->_imageError($file, $firsttime, 'Error creating temporary image object whilst using GD library to parse GIF image'); }
    					$this->_tempimg = ob_get_contents();
    					$this->_tempimglnk = 'var:_tempimg';
    					ob_end_clean();
    					$info = $this->_getImage($this->_tempimglnk, false);
    					if (!$info) { return $this->_imageError($file, $firsttime, 'Error parsing temporary file image object created with GD library to parse GIF image'); }
    					imagedestroy($im);
    				}
    				else {
    					$check = @imagepng($im, $tempfile);
    					if (!$check) { return $this->_imageError($file, $firsttime, 'Error creating temporary file ('.$tempfile.') whilst using GD library to parse GIF image'); }
    					$info = $this->_getImage($tempfile, false);
    					if (!$info) { return $this->_imageError($file, $firsttime, 'Error parsing temporary file ('.$tempfile.') created with GD library to parse GIF image'); }
    					imagedestroy($im);
    					unlink($tempfile);
    				}
    				$info['type']='gif';
    				if ($firsttime) {
    					$info['i']=count($this->images)+1;
    					$this->images[$file]=$info;
    				}
    				return $info;
    			}
    			else { return $this->_imageError($file, $firsttime, 'Error creating GD image file from GIF image'); }
    		}
    
    		if (!class_exists('gif', false)) { 
    			include_once(_MPDF_PATH.'classes/gif.php'); 
    		}
    		$gif=new CGIF();
    
    		$h=0;
    		$w=0;
    		$gif->loadFile($data, 0);
    
    		if(isset($gif->m_img->m_gih->m_bLocalClr) && $gif->m_img->m_gih->m_bLocalClr) {
    			$nColors = $gif->m_img->m_gih->m_nTableSize;
    			$pal = $gif->m_img->m_gih->m_colorTable->toString();
    			if($bgColor != -1) {
    				$bgColor = $gif->m_img->m_gih->m_colorTable->colorIndex($bgColor);
    			}
    			$colspace='Indexed';
    		} elseif(isset($gif->m_gfh->m_bGlobalClr) && $gif->m_gfh->m_bGlobalClr) {
    			$nColors = $gif->m_gfh->m_nTableSize;
    			$pal = $gif->m_gfh->m_colorTable->toString();
    			if((isset($bgColor)) and $bgColor != -1) {
    				$bgColor = $gif->m_gfh->m_colorTable->colorIndex($bgColor);
    			}
    			$colspace='Indexed';
    		} else {
    			$nColors = 0;
    			$bgColor = -1;
    			$colspace='DeviceGray';
    			$pal='';
    		}
    
    		$trns='';
    		if(isset($gif->m_img->m_bTrans) && $gif->m_img->m_bTrans && ($nColors > 0)) {
    			$trns=array($gif->m_img->m_nTrans);
    		}
    		$gifdata=$gif->m_img->m_data;
    		$w=$gif->m_gfh->m_nWidth;
    		$h=$gif->m_gfh->m_nHeight;
    		$gif->ClearData();
    
    		if($colspace=='Indexed' and empty($pal)) {
    			return $this->_imageError($file, $firsttime, 'Error parsing GIF image - missing colour palette'); 
    		}
    		if ($this->compress) {
    			$gifdata=gzcompress($gifdata);
    			$info = array( 'w'=>$w, 'h'=>$h, 'cs'=>$colspace, 'bpc'=>8, 'f'=>'FlateDecode', 'pal'=>$pal, 'trns'=>$trns, 'data'=>$gifdata);
    		} 
    		else {
    			$info = array( 'w'=>$w, 'h'=>$h, 'cs'=>$colspace, 'bpc'=>8, 'pal'=>$pal, 'trns'=>$trns, 'data'=>$gifdata);
    		} 
    		$info['type']='gif';
    		if ($firsttime) {
    			$info['i']=count($this->images)+1;
    			$this->images[$file]=$info;
    		}
    		return $info;
    	}
    
    /*-- IMAGES-BMP --*/
    	// BMP (Windows Bitmap)
    	else if ($type == 'bmp') {
    		if (!class_exists('bmp', false)) { include(_MPDF_PATH.'classes/bmp.php'); }
    		if (empty($this->bmp)) { $this->bmp = new bmp($this); }
    		$info = $this->bmp->_getBMPimage($data, $file);
    		if (isset($info['error'])) {
    			return $this->_imageError($file, $firsttime, $info['error']); 
    		}
    		if ($firsttime) {
    			$info['i']=count($this->images)+1;
    			$this->images[$file]=$info;
    		}
    		return $info;
    	}
    /*-- END IMAGES-BMP --*/
    /*-- IMAGES-WMF --*/
    	// WMF
    	else if ($type == 'wmf') {
    		if (!class_exists('wmf', false)) { include(_MPDF_PATH.'classes/wmf.php'); }
    		if (empty($this->wmf)) { $this->wmf = new wmf($this); }
    		$wmfres = $this->wmf->_getWMFimage($data);
    	  if ($wmfres[0]==0) { 
    		if ($wmfres[1]) { return $this->_imageError($file, $firsttime, $wmfres[1]); }
    		return $this->_imageError($file, $firsttime, 'Error parsing WMF image'); 
    	  }
    	  $info = array('x'=>$wmfres[2][0],'y'=>$wmfres[2][1],'w'=>$wmfres[3][0],'h'=>$wmfres[3][1],'data'=>$wmfres[1]);
    	  $info['i']=count($this->formobjects)+1;
    	  $info['type']='wmf';
    	  $this->formobjects[$file]=$info;
    	  return $info;
    	}
    /*-- END IMAGES-WMF --*/
    
    	// UNKNOWN TYPE - try GD imagecreatefromstring
    	else {
    		if (function_exists('gd_info')) { $gd = gd_info(); }
    		else {$gd = array(); }
    		if (isset($gd['PNG Support']) && $gd['PNG Support']) {
    			$im = @imagecreatefromstring($data);
    			if (!$im) { return $this->_imageError($file, $firsttime, 'Error parsing image file - image type not recognised, and not supported by GD imagecreate'); }
    			$tempfile = _MPDF_TEMP_PATH.'_tempImgPNG'.md5($file).RAND(1,10000).'.png';
    			imagealphablending($im, false);
    			imagesavealpha($im, false); 
    			imageinterlace($im, false);
    			$check = @imagepng($im, $tempfile);
    			if (!$check) { return $this->_imageError($file, $firsttime, 'Error creating temporary file ('.$tempfile.') whilst using GD library to parse unknown image type'); }
    			$info = $this->_getImage($tempfile, false);
    			imagedestroy($im);
    			unlink($tempfile);
    			if (!$info) { return $this->_imageError($file, $firsttime, 'Error parsing temporary file ('.$tempfile.') created with GD library to parse unknown image type'); }
    			$info['type']='png';
    			if ($firsttime) {
    				$info['i']=count($this->images)+1;
    				$this->images[$file]=$info;
    			}
    			return $info;
    		}
    	}
    
    	return $this->_imageError($file, $firsttime, 'Error parsing image file - image type not recognised'); 
    }
    
  4. I finally got my kml to display through the static maps api thinking I could then display my map on the pdf I'm generating using mpdf.  But,  it is not displaying the image in the pdf.  It works fine on a blank test page.

    $kmlMap = "<img src=\"http://maps.googleapis.com/maps/api/staticmap?zoom=15&size=500x300&maptype=hybrid&path=color:0xff0000ff|weight:3|$correctedCoords \" /><br />";
    

    Any ideas on how I could make this work with mpdf?

  5. I have a string I am pulling out of a kml file to be used in google's static map image.  The problem is that the longitude and latitude are in the wrong order.

    $xml=simplexml_load_file($kml);
    //print_r($xml);
    $coordinates= $xml->Document->Placemark->Polygon->outerBoundaryIs->LinearRing->coordinates;
    $coordinates = str_replace(",0","|",$coordinates);
    echo $coordinates;
    
    

    $coordinates returns

     

    -93.93740385636626,32.5298698657008| -93.94147866742821,32.52989552832681| -93.94144945527509,32.53330102162547| -93.94975589137293,32.53335196474311| -93.94983123242544,32.52989370087431| -93.94493319136991,32.52989645540433| -93.9443121915328,32.52861950574362| -93.94419758821717,32.52736388060429| -93.94302907878635,32.52652644904565| -93.94229993303671,32.5257441308524| -93.94147580320451,32.52521094897828| -93.94137978713827,32.52261795379491| -93.93742258613195,32.5225916055261| -93.93740385636626,32.5298698657008|

     

    I need them as they are above separated by pipes to be used as a parameter in a url only I need the longitude and latitude swapped.

     

    So instead of "-93.93740385636626,32.5298698657008", I need it to read "32.5298698657008,-93.93740385636626".  All of the coordinates I will be using in the future will be in the same general area as the locations above.

     

  6. Be that as it may, you have to be logged in to access this page and the only people accessing this site will be my family, which i'm not worried about.  I realize that this is bad practice for security reasons, but I am still not having any success returning any images.  I commented out the trigger_error, not sure how it got in the success section.   Any ideas on how I could get the images to appear?

  7. I last used this code about 5 years ago on another website.  I copied it into the current site i'm working on to list the images in a directory.  As far as I can tell the path is correct.  I printed $image_path out and everything looks ok, however it is triggering the error Notice: error, path not found in.  I have commented out this error and it still does not run.  For some reason the path is not returning anything.  I checked the permissions and they look ok.

     

    Here is the code:

    if(strlen($_GET['delete'])) {
    		$delete_image = dirname(__FILE__) . "/PW-Files/$listingid/images/".urldecode($_GET['delete']);
    		unlink($delete_image);
    	}
    
        $image_path = dirname(__FILE__) . "/PW-Files/$listingid/images";
        $dir_handle = null;
       
        if (($dir_handle = opendir($image_path)))
        {
            trigger_error('error, path not found');
            return;
        }
        $html = '<table width="500" border="1">';
        $file = readdir($dir_handle);
        $image_types = array("jpg","jpeg","gif","png");
       while (false !== ($file=readdir($dir_handle))) {
        
    		
    		if(in_array(strtolower(substr($file,strpos($file,".")+1)),$image_types)){
            $html .= "<tr><td><center><IMG SRC='/PW-Files/$listingid/images/{$file}' width='100' align='top' vspace='2' alt='{$file}' /></center></td><td>{$file}<br /><a href=\" PW-Image_Upload.php?delete=".urlencode($file)."\">delete image</a></td></tr>";
    
    		}
        }
        closedir($dir_handle);
        
    
       $html .= "</table>";
        echo $html;
    
  8. Hi,

     

    I have been a member of phpfreaks for a few years now.  I now have a situation where I am learning C# so I can send out faxes through a modem.  I have figured most everything out and I have it working so far, but I would like to join a good C# forum for help.

     

    I appreciate and enjoy phpfreaks.  I have learned a lot through this site and group.

     

    Does anyone have any recommendations for a C# forum similar to php freaks?

     

    Thanks,

     

    Jake

  9. I would really like to build an application in C# that will send out faxes and e-mails.  I have been going through some C# tutorials learning the language.  I have experience with php.

     

    On the client side (I could do this in C# or php) I would have a few customer groups setup to select from.  Each group is pulling data from our customer data file through odbc.  So, with this client application you would select a group and attach a pdf.  Hit send and the client application would then rename the pdf to a unique id and ftp it to a directory on the server.  Then, all of the faxes and e-mails that need to go out would be written to a mysql database on the server.

    Example ftp file: 20111112112938.pdf

    Example data fields: id  company  fax  email  file  email_status  fax_status  fax_tries

    Example insert: 0  Jan's Restaurant  Y  Y 19995555834.pdf  jan@jansrestaurant.com  20111112119238  pending  pending  0

     

    On the server side the C# program would look at the mysql database to see what e-mails and faxes need to be sent based on their status.  The faxes would go out through a zoom serial fax modem.  And the e-mails would send out 5 every 15 seconds or whatever I set it to.

     

    Getting the server to send out the e-mails should not be hard http://stackoverflow.com/questions/449887/sending-e-mail-using-c-sharp.  But, sending a fax through a serial modem could be a challenge for me.  I do not know anything about this.  Does anyone have any experience sending faxes through a serial fax modem using C#?

     

    Thanks,

     

    Jake

     

     

  10. hmm..  I tried mapping a drive under M:\ pointing it to the sharename, but I got the same error.

     

    Warning: fopen(M:\resource.pdf) [function.fopen]: failed to open stream: No such file or directory in C:\Inetpub\wwwroot\date.php on line 69

     

    $filename = "M:\\resource.pdf";

  11. Is there a way to write a file to a directory on my network?

     

    I tried creating a shortcut called automated and pointed it to the network path.  I also set up a virtual directory called automated in IIS and still could not make it work. I gave it read and write permissions.

     

    error

    Warning: fopen(C:\Inetpub\wwwroot\dompdf\automated\resource.pdf) [function.fopen]: failed to open stream: No such file or directory in C:\Inetpub\wwwroot\date.php on line 69

     

    Warning: fwrite() expects parameter 1 to be resource, boolean given in C:\Inetpub\wwwroot\date.php on line 70

     

    Warning: fclose() expects parameter 1 to be resource, boolean given in C:\Inetpub\wwwroot\date.php on line 71

     

    code

    require_once("dompdf/dompdf_config.inc.php");
    
    $html =
      '<html><body>'.
      '<p>Put your html here, or generate it with your favourite '.
      'templating system.</p>'.
      '</body></html>';
    
    $dompdf = new DOMPDF();
    $dompdf->load_html($html);
    $dompdf->render(); 
    $pdfoutput = $dompdf->output(); 
    $filename = "C:\\Inetpub\\wwwroot\\dompdf\\automated\\resource.pdf"; 
    $fp = fopen($filename, "a"); 
    fwrite($fp, $pdfoutput); 
    fclose($fp); 
    

  12. PHP Version 5.3.6

    Windows NT WAVELINK 5.1 build 2600 (Windows XP Professional Service Pack 3) i586

    Mar 17 2011 10:46:06

     

    code

    $sunday = date('Y-m-d', strtotime('last Sunday', strtotime('last Saturday')));
    $saturday = date('Y-m-d', strtotime('last Saturday'));
    
    $firstday = date('Y-m-d', strtotime('next Sunday', strtotime('last Friday', strtotime('first day of last month'))));
    $lastday = date('Y-m-d', strtotime('next Saturday', strtotime('last Friday', strtotime('first day of this month'))));
    
    $thisfirstday = date('Y-m-d', strtotime('next Sunday', strtotime('last Friday', strtotime('first day of this month'))));
    $thislastday = date('Y-m-d', strtotime('next Saturday', strtotime('last Friday', strtotime('first day of next month'))));
    
    
    if($firstday<=$sunday && $sunday<=$lastday)
    {
    $month = date('m', strtotime('-10 days', strtotime('next Saturday', strtotime('last Friday', strtotime('first day of this month')))));
    $year = date('Y', strtotime('-10 days', strtotime('next Saturday', strtotime('last Friday', strtotime('first day of this month')))));
    echo"1<br />$month|$year";
    }
    
    elseif($firstday<=$saturday && $saturday<=$lastday)
    {
    $month = date('m', strtotime('-10 days', strtotime('next Saturday', strtotime('last Friday', strtotime('first day of this month')))));
    $year = date('Y', strtotime('-10 days', strtotime('next Saturday', strtotime('last Friday', strtotime('first day of this month')))));
    echo"2<br />$month|$year";
    }
    
    elseif($thisfirstday<=$sunday && $sunday<=$thislastday)
    {
    $month = date('m', strtotime('-10 days', strtotime('next Saturday', strtotime('last Friday', strtotime('first day of next month')))));
    $year = date('Y', strtotime('-10 days', strtotime('next Saturday', strtotime('last Friday', strtotime('first day of next month')))));
    echo"3<br />$month|$year";
    }
    
    elseif($thisfirstday<=$saturday && $saturday<=$thislastday)
    {
    $month = date('m', strtotime('-10 days', strtotime('next Saturday', strtotime('last Friday', strtotime('first day of next month')))));
    $year = date('Y', strtotime('-10 days', strtotime('next Saturday', strtotime('last Friday', strtotime('first day of next month')))));
    echo"4<br />$month|$year";
    }
    
    else
    {
    $month="00";
    $year="0000";
    }echo "<hr />Firstday: $firstday<br>\n"; // Firstday: 1969-12-28
    echo "Sunday: $sunday<br>\n"; // Sunday: 2011-10-02
    echo "Lastday: $lastday<br>\n"; // Lastday: 1969-12-27

     

    output

    3

    10|2011

    Firstday: 2011-08-28

    Sunday: 2011-10-02

    Lastday: 2011-10-01

  13. I did echo them out, and it works.  There is no problem now as far as I know.  I just wanted a second eye on the code.  Basically, what ever day the last Friday of the month lands on...  the Saturday following will make up the last day of the months period.

     

    I am running a scheduled task ever Thursday morning.  I am using this code to determine which month period the previous week falls into.

  14. I suspect you are trying to find if $today is still part of the previous month range or if it is part of the current month range. If so, your comparisons would need to test for those conditions (if today is greater-than or equal to the start value and less-than or equal to the end value) -

     

    <?php
    if($firstday<=$today && $today<=$lastday)
    {
    
    $month = date('m', strtotime('-10 days', strtotime('next Saturday', strtotime('last Friday', strtotime('first day of this month')))));
    $year = date('Y', strtotime('-10 days', strtotime('next Saturday', strtotime('last Friday', strtotime('first day of this month')))));
    
    echo"1<br />$month|$year";
    }
    
    elseif($thisfirstday<=$today && $today<=$thislastday)
    {
    $month = date('m', strtotime('-10 days', strtotime('next Saturday', strtotime('last Friday', strtotime('first day of next month')))));
    $year = date('Y', strtotime('-10 days', strtotime('next Saturday', strtotime('last Friday', strtotime('first day of next month')))));
    echo"3<br />$month|$year";
    
    }

     

    That is exactly what i'm trying to do!

     

    Does this code look ok for finding that out?

    $sunday = date('Y-m-d', strtotime('last Sunday', strtotime('last Saturday')));
    $saturday = date('Y-m-d', strtotime('last Saturday'));
    
    $firstday = date('Y-m-d', strtotime('next Sunday', strtotime('last Friday', strtotime('first day of last month'))));
    $lastday = date('Y-m-d', strtotime('next Saturday', strtotime('last Friday', strtotime('first day of this month'))));
    
    $thisfirstday = date('Y-m-d', strtotime('next Sunday', strtotime('last Friday', strtotime('first day of this month'))));
    $thislastday = date('Y-m-d', strtotime('next Saturday', strtotime('last Friday', strtotime('first day of next month'))));
    
    
    if($firstday<=$sunday && $sunday<=$lastday)
    {
    $month = date('m', strtotime('-10 days', strtotime('next Saturday', strtotime('last Friday', strtotime('first day of this month')))));
    $year = date('Y', strtotime('-10 days', strtotime('next Saturday', strtotime('last Friday', strtotime('first day of this month')))));
    }
    
    elseif($firstday<=$saturday && $saturday<=$lastday)
    {
    $month = date('m', strtotime('-10 days', strtotime('next Saturday', strtotime('last Friday', strtotime('first day of this month')))));
    $year = date('Y', strtotime('-10 days', strtotime('next Saturday', strtotime('last Friday', strtotime('first day of this month')))));
    }
    
    elseif($thisfirstday<=$sunday && $sunday<=$thislastday)
    {
    $month = date('m', strtotime('-10 days', strtotime('next Saturday', strtotime('last Friday', strtotime('first day of next month')))));
    $year = date('Y', strtotime('-10 days', strtotime('next Saturday', strtotime('last Friday', strtotime('first day of next month')))));
    }
    
    elseif($thisfirstday<=$saturday && $saturday<=$thislastday)
    {
    $month = date('m', strtotime('-10 days', strtotime('next Saturday', strtotime('last Friday', strtotime('first day of next month')))));
    $year = date('Y', strtotime('-10 days', strtotime('next Saturday', strtotime('last Friday', strtotime('first day of next month')))));
    }
    
    else
    {
    $month="00";
    $year="0000";
    }

  15. This didn't work either:

     

    <?PHP
    
    $today = strtotime("now");
    
    $sunday = strtotime('last Sunday', strtotime('last Saturday'));
    $saturday = strtotime('last Saturday');
    
    $firstday = strtotime('next Sunday', strtotime('last Friday', strtotime('first day of last month')));
    $lastday = strtotime('next Saturday', strtotime('last Friday', strtotime('first day of this month')));
    
    $thisfirstday = strtotime('next Sunday', strtotime('last Friday', strtotime('first day of this month')));
    $thislastday = strtotime('next Saturday', strtotime('last Friday', strtotime('first day of next month')));
    
    echo"$today<hr />$firstday<br />$lastday<hr />$thisfirstday<br />$thislastday";
    
    if($firstday>="$today" && $lastday<="$today")
    {
    $month = date('m', strtotime('-10 days', strtotime('next Saturday', strtotime('last Friday', strtotime('first day of this month')))));
    $year = date('Y', strtotime('-10 days', strtotime('next Saturday', strtotime('last Friday', strtotime('first day of this month')))));
    
    echo"1<br />$month|$year";
    }
    
    
    
    
    
    
    elseif($thisfirstday>="$today" && $thislastday<="$today")
    {
    $month = date('m', strtotime('-10 days', strtotime('next Saturday', strtotime('last Friday', strtotime('first day of next month')))));
    $year = date('Y', strtotime('-10 days', strtotime('next Saturday', strtotime('last Friday', strtotime('first day of next month')))));
    echo"3<br />$month|$year";
    
    }
    
    
    ?>

  16. Todays date is between the criteria in if else, but it is not catching it.

     

    <?PHP
    
    $today = date('Y-m-d');
    
    $sunday = date('Y-m-d', strtotime('last Sunday', strtotime('last Saturday')));
    $saturday = date('Y-m-d', strtotime('last Saturday'));
    
    $firstday = date('Y-m-d', strtotime('next Sunday', strtotime('last Friday', strtotime('first day of last month'))));
    $lastday = date('Y-m-d', strtotime('next Saturday', strtotime('last Friday', strtotime('first day of this month'))));
    
    $thisfirstday = date('Y-m-d', strtotime('next Sunday', strtotime('last Friday', strtotime('first day of this month'))));
    $thislastday = date('Y-m-d', strtotime('next Saturday', strtotime('last Friday', strtotime('first day of next month'))));
    
    echo"$today<hr />$firstday<br />$lastday<hr />$thisfirstday<br />$thislastday";
    
    if($firstday>="$today" && $lastday<="$today")
    {
    $month = date('m', strtotime('-10 days', strtotime('next Saturday', strtotime('last Friday', strtotime('first day of this month')))));
    $year = date('Y', strtotime('-10 days', strtotime('next Saturday', strtotime('last Friday', strtotime('first day of this month')))));
    
    echo"1<br />$month|$year";
    }
    
    
    
    
    
    
    elseif($thisfirstday>="$today" && $thislastday<="$today")
    {
    $month = date('m', strtotime('-10 days', strtotime('next Saturday', strtotime('last Friday', strtotime('first day of next month')))));
    $year = date('Y', strtotime('-10 days', strtotime('next Saturday', strtotime('last Friday', strtotime('first day of next month')))));
    echo"3<br />$month|$year";
    
    }
    
    
    ?>

     

    output:

    2011-10-10<hr />2011-08-28<br />2011-10-01<hr />2011-10-02<br />2011-10-29

  17. I would like to store weekly reports into documents.  I am familiar with storing data to a regular text document, but it does not keep bold text, tables and so forth.  Are there any other documents that would not be to hard to output to such as .pdf, .rtf, .doc, etc.?

     

    I've attached the current format we are using in excel.  Now that I have things automated in php, I would like to output to a document with almost identical formatting.  And how can I keep it on 8 1/2" x 11" pages without it splitting data or tables between two pages?

     

    Thanks,

     

    Jake

     

     

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.