Jump to content

jakebur01

Members
  • Posts

    885
  • Joined

  • Last visited

Everything posted by jakebur01

  1. That's exactly what I was looking for!! Thank you. That is awesome. @Barand Yes, for users to download. It's a lot cleaner to me than a php file name. And I'm using a variable as the filename.
  2. I don't know how to do exactly yet, but this is what I have in mind. Is this the right direction? $today = date("Y-m-d"); $originalstart = date("Y-m-d",strtotime('-24 months', strtotime($originalstart))); for( $i= 1 ; $i <= 24 ; $i++ ) { $start = date('Y-m-d',strtotime('+'."$i".' month', strtotime($originalstart))); //need to make day 01 somehow $firstday = new DateTime($start); $firstday->modify('first day of this month'); if(sunday){ //use sunday } elseif(tuesday thru thursday){ //use this past sunday } elseif(friday or saturday){ //use next Sunday } $lastday = new DateTime($start); $lastday->modify('+1 month'); $lastday->modify('last friday'); $lastday->modify('+1 day'); }
  3. I need to find the last Friday of each month and determine the start and end dates of each month based on the last Friday. So, for September, the last Friday was the 27th, that means Saturday the 28th will be the last day of September. September 29 will then start the first day of October.... October 25 is the last Friday in October, so Saturday October 26 will close out October..... Sun Oct 27 starts November, etc... 7/28 - 8/31 9/1 - 9/28 9/29 - 10/26 10/27 - 11/30 I can build a table and manually key in the start and end dates then query as needed, but if there is a way to do it on the fly, I'd rather do it in php to eliminate mistakes. Below is the code I'm currently using to find the first and last day of each calendar month, but I'll need to convert this to find the fiscal month based on the last Saturday of each month. And go back a few years in the option select. <select name="dateselect" id="dateselect"> <?php $today = date("Y-m-d"); $monthbegin = date("Y-m-d",strtotime('first day of this month', strtotime($today))); for( $i= 0 ; $i <= 52 ; $i++ ) { if($i == 0){ $monthselect = date('Y-m-d',strtotime($monthbegin)); $monthdisplay = date('F Y',strtotime($monthbegin)); echo '<option ' . ($i == 0 ? 'selected=\'selected\'' : '') . ' value="' . $monthselect . '" >' . $monthdisplay . '</option>'; } else{ $monthselect = date('Y-m-d',strtotime('-'."$i".' months',strtotime($monthbegin))); $monthdisplay = date('F Y',strtotime('-'."$i".' months',strtotime($monthbegin))); echo '<option ' . ($i == 0 ? 'selected=\'selected\'' : '') . ' value="' . $monthselect . '" >' . $monthdisplay . '</option>'; } } ?> </select> $begin_date = $_GET["dateselect"]; $end_date = date("Y-m-t", strtotime($begin_date));
  4. Is it possible to feed the browser a default save as name for the image when outputting to the browser, instead of it defaulting to the .php file name? So, instead of myimage.php I could use imagename.jpg or whatever I want.
  5. I was able to get the javascript working. $(document).ready(function(){ /* PREPARE THE SCRIPT */ $("#dateselect").bind('load change', function(){ /* WHEN YOU CHANGE AND SELECT FROM THE SELECT FIELD */ var my_js_date = $(this).val(); /* GET THE VALUE OF THE SELECTED DATA */ var dataString = "my_js_date="+my_js_date; /* STORE THAT TO A DATA STRING */ var imgurl = "myimage.php?date=" + my_js_date; $().ready( function() { $("#myimg").attr("src",imgurl); }) }).triggerHandler('change'); });
  6. I'm complicating things now. I have an option select to select the date. The image displays on the initial value. But, the image is not changing when I change the selection. <select name="dateselect" id="dateselect" oninput="document.getElementById('my_js_date').innerHTML = this.value"> function bodyOnLoad(){ var e = document.getElementById("dateselect"); document.getElementById('my_js_date').innerHTML = e.options[e.selectedIndex].value; }
  7. Do you know how to insert a javascript variable into the path? Javascript variable eventdate <img src='myimage.php?date=JAVASCRIPT eventdate VARIABLE HERE'> I've used javascript variables with php before but it's been several years.
  8. Wow. I'm using session_start() on my image page and querying data where user_id = session user id. That's pretty cool that the session still works through an image link and the user doesn't have to be directly on the page.
  9. That's what I was thinking! Thanks.
  10. I'm calling the image page via ajax. Depending on what date is selected will be written to the image. However I'm getting header error on my main page. What would be the proper way to display the generated image to the user? Can I do it without saving it? // FETCH IMAGE & WRITE TEXT $img = imagecreatefromjpeg('balloon.jpg'); $white = imagecolorallocate($img, 255, 255, 255); $txt = "Hello World"; $font = "C:\Windows\Fonts\arial.ttf"; imagettftext($img, 24, 0, 5, 24, $white, $font, $txt); // OUTPUT IMAGE header('Content-type: image/jpeg'); imagejpeg($img); imagedestroy($jpg_image); // OR SAVE TO A FILE // THE LAST PARAMETER IS THE QUALITY FROM 0 to 100 // imagejpeg($img, "test.jpg", 100);
  11. I also tried: // compose message printArray($_POST); function printArray($array){ foreach ($array as $key => $value){ $message .= "$key => $value<br />"; if(is_array($value)){ //If $value is an array, print it as well! printArray($value); } } } $message = wordwrap($message, 70); // send email mail($to, $subject, $message, $headers); But, it was blank. I know it is posting the custom field for sure as I have sent different values and received them back via post.
  12. Since I am not the one accessing the page, but Paypal, I've been trying to troubleshoot via mail(). I tried putting var_dump into my message but didn't work. $message = "<pre>"; $message .= var_dump($_POST); $message .= "</pre>"; $message = wordwrap($message, 70); // send email mail($to, $subject, $message, $headers); Ok... I used: // compose message $message = "<pre>"; $message .= print_r($_POST); $message .= "</pre>"; $message = wordwrap($message, 70); // send email mail($to, $subject, $message, $headers); But, all it returned was the number 1. "1".
  13. This is more of a Paypal question, but I'm using php on the listener and hopefully someone has run into this problem. I'm having trouble finding the correct POST name to use to get the OPTION SELECT for the item on my listener page. I tried: $option = $_POST['os0']; But, I'm not getting anything using that. I've also tried os0_x, on0, and on0_x. This is what I'm posting to Paypal: <input type="hidden" name="on0" value="Term"> <select name="os0"> <option value="1 Year">1 Year</option> <option value="3 Years">3 Years</option> <option value="5 Years">5 Years</option> </select>
  14. That's correct mac_gyver. There are not any missing images. I saw that after I used print_r ($images) like nik_jain suggested. How could I alter the code so that the first row will display two images?
  15. It's only image #2. If I have 29 images, #2 is the only one missing. I looked at the source and the image is missing all together. <img width = "200" src='PW-Files/10/images/1255967188.jpg'><br><img width = "200" src='PW-Files/10/images/1279977704.jpg'><img width = "200" src='PW-Files/10/images/1831679637.jpg'><br><img width = "200" src='PW-Files/10/images/2652035406.jpg'><img width = "200" src='PW-Files/10/images/3335979548.jpg'><br><img width = "200" src='PW-Files/10/images/4176309676.jpg'><img width = "200" src='PW-Files/10/images/428132950.jpg'><br><img width = "200" src='PW-Files/10/images/5397313372.jpg'><img width = "200" src='PW-Files/10/images/5406659459.jpg'><br><img width = "200" src='PW-Files/10/images/6463512950.jpg'><img width = "200" src='PW-Files/10/images/6660251971.jpg'><br><img width = "200" src='PW-Files/10/images/6978163793.jpg'><img width = "200" src='PW-Files/10/images/7276068595.jpg'><br><img width = "200" src='PW-Files/10/images/775470584.jpg'><img width = "200" src='PW-Files/10/images/871558021.jpg'><br><img width = "200" src='PW-Files/10/images/8794863931.jpg'><img width = "200" src='PW-Files/10/images/8799152527.jpg'><br><img width = "200" src='PW-Files/10/images/9769868608.jpg'><img width = "200" src='PW-Files/10/images/9896351471.jpg'><br>
  16. 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>' ; } }
  17. 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.
  18. 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'); }
  19. 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?
  20. 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.
  21. 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?
  22. 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;
  23. Thanks, Kevin. That was kinda my opinion too. I'll try out stack overflow and see how that goes.
  24. 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
  25. 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 [email protected] 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
×
×
  • 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.