Jump to content

antonyfal

Members
  • Posts

    172
  • Joined

  • Last visited

Profile Information

  • Gender
    Male

antonyfal's Achievements

Regular Member

Regular Member (3/5)

0

Reputation

  1. PRogress: It was always downloading the attachments. This morning i opened my download folder and viewed about 100 files that were downloaded through my testing. The download dialog never appeared and the downloads were so small it barely showed up on mozilla.. Anyway this is solved.. All the attempts above work.
  2. I have tried everything even force download and and and ... ive just finished downloading the file to my server and downloading it from there but nothing is working.. I have discovered that i do have the filename fixed though... how can i download a txt file from the server? all my headers are correct.. even if i add the url to the browser the file is displayed on the page and the browser download dialog does not appear.. any ideas? i would like to download the file via jquery ajax..
  3. Hi.. I tried many things to download the files with a .txt extension and spaces in the name, i did manage to get the fix for the spaces in the name of a .txt file name by adding colons.. However now when i try to download files with an .txt file extension, it simply opens the file and does not download it,, regardless whether the name is one word or multiple words... What modification would i have to make to the following code to download .txt files: here is my newly adjusted attempt at downloading the files from server: // this is just the php that i changed $message = base64_decode(imap_fetchbody($imap, $msgnum, $partNum)); $ext = substr($filename, strrpos($filename, '.') + 1); $next = strtolower($ext); $type = "application/octet-stream"; if($next =='asf'){ $type = "video/x-ms-asf"; } if($next =='avi'){ $type = "video/avi"; } if($next =='flv'){ $type = "video/x-flv"; } if($next =='fla'){ $type = "application/octet-stream"; } if($next =='swf'){ $type = "application/x-shockwave-flash"; } if($next =='doc'){ $type = "application/msword"; } if($next =='docx'){ $type = "application/msword"; } if($next =='zip'){ $type = "application/zip"; } if($next =='xls'){ $type = "application/vnd.ms-excel"; } if($next =='gif'){ $type = "image/gif"; } if($next =='jpg'){ $type = "image/jpg"; } if($next =='jpeg'){ $type = "image/jpg"; } if($next =='png'){ $type = "image/png"; } if($next =='wav'){ $type = "audio/wav"; } if($next =='mp3'){ $type = "audio/mpeg3"; } if($next =='mpg'){ $type = "video/mpeg"; } if($next =='mpeg'){ $type = "video/mpeg"; } if($next =='rtf'){ $type = "application/rtf"; } if($next =='html'){ $type = "text/html"; } if($next =='htm'){ $type = "text/html"; } if($next =='xml'){ $type = "text/xml"; } if($next =='xsl'){ $type = "text/xsl"; } if($next =='css'){ $type = "text/css"; } if($next =='php'){ $type = "text/php"; } if($next =='txt'){ $type = "text/plain"; } if($next =='asp'){ $type = "text/asp"; } if($next =='pdf'){ $type = "application/pdf"; } if($next =='psd'){ $type = "application/octet-stream"; } header("Content-Description: File Transfer"); header("Content-Type: $type; name=\"$filename\""); header("Content-Disposition: attachment; filename=\"$filename\""); header("Content-Transfer-Encoding: binary"); header("Expires: 0"); header("Cache-Control: must-revalidate, post-check=0, pre-check=0"); header("Pragma: public"); header("Content-Length: ".filesize($message)); ob_clean(); flush(); echo $message;
  4. Thanks jairathnem.. if i try to put the $filename in quotes and also encode the $filename.. it does not download, only an image downloads, the text files open for display.. heres what i have tried since posting: header("Content-Description: File Transfer"); header("Content-Type: application/octet-stream"); if(strpos( $_SERVER['HTTP_USER_AGENT'],"MSIE" )>0) { header('Content-Disposition: attachment; filename=" '.urlencode($fileName).' " '); } else { header('Content-Disposition: attachment; filename*=UTF-8\' \' '.urlencode($fileName));// there is something wrong with this part.. } header('Content-Transfer-Encoding: binary'); header('Expires: 0'); header('Cache-Control: must-revalidate'); header('Pragma: public'); echo $message;
  5. Hi.. I trying to select an attachment from a dropdown select and then i want it to save to the desktop. Everything works perfectly the files all save, however if a file has a name with spaces, the file that saves only take the first word of the name, and the extension is not saved. IE: $filename = amy numbers.txt the file name of the downloaded file is amy and saves without an extension. here is my code: both php and jquery javascript: // here is javascript call <script> jQuery('ul.ligtatchment > li >a.att_dwn').live('click', function (){ jQuery('#loadingdiv').show(); var msg = jQuery(this).attr('rel').split('_'); jQuery.get(globalVar +'&task=em_attachment&msgnum='+msg[0]+'&part='+msg[1]+'&encoding='+msg[2], function(data) { if(data){ jQuery('#atdiv_'+msg[0]).remove(); jQuery('#loadingdiv').hide(); jQuery('<div class="attdiv" id="atdiv_'+msg[0]+'"><iframe id="dnframe_'+msg[0]+'" name="dnframe_'+msg[0]+'" class="dnframe" src="'+globalVar +'&task=em_attachment&msgnum='+msg[0]+'&part='+msg[1]+'&encoding='+msg[2]+'" style="display: none;"></iframe></div>').prependTo('div#chkmldivs'); } else { jQuery('#loadingdiv').hide(); jAlert('ERROR', 'There is no file for download'); } }); }); </script> // here is php code.. $msgnum = $_GET['msgnum']; $partNum =$_GET['part']; $encoding = $_GET['encoding']; $partStruct = imap_bodystruct($imap, $msgnum, $partNum); $filename = $partStruct->dparameters[0]->value; // if i echo the name here it is correct IE: amy numbers.txt //$nfilename = str_replace(' ',' ',$filename); here i tried to replace the blanks with but did not work.. $message = imap_fetchbody($imap, $msgnum, $partNum); switch ($encoding) { case 0: case 1: $message = imap_8bit($message); break; case 2: $message = imap_binary($message); break; case 3: $message = imap_base64($message); break; case 4: $message = quoted_printable_decode($message); break; } header("Content-Description: File Transfer"); header("Content-Type: application/octet-stream"); header("Content-Disposition: attachment; filename=".$filename); header("Content-Transfer-Encoding: binary"); header("Expires: 0"); header("Cache-Control: must-revalidate"); header("Pragma: public"); echo $message;
  6. RESOLVED IT: if anybody want a function to retrieve all images in a imap html message and convert them to embedded images before they display, so as to avoid Mozilla's warnings regarding http pages on a https domain, here is the code. This code will retrieve any image src, even if the src does not contain a mime type.. IE: http://hi5.taggedmail.com/imgsrv.php?sz=1&uid=5458308947 // here is the curl function to collect the info on the image src url: function get_web_page($url) { $options = array( CURLOPT_RETURNTRANSFER => true, // return web page CURLOPT_HEADER => false, // don't return headers CURLOPT_FOLLOWLOCATION => true, // follow redirects CURLOPT_ENCODING => "", // handle all encodings CURLOPT_USERAGENT => $_SERVER["HTTP_USER_AGENT"], // who am i CURLOPT_AUTOREFERER => true, // set referer on redirect CURLOPT_CONNECTTIMEOUT => 120, // timeout on connect CURLOPT_TIMEOUT => 120, // timeout on response CURLOPT_MAXREDIRS => 10, // stop after 10 redirects ); $ch = curl_init( $url ); curl_setopt_array( $ch, $options ); $content = curl_exec( $ch ); $err = curl_errno( $ch ); $errmsg = curl_error( $ch ); $header = curl_getinfo( $ch ); curl_close( $ch ); $header['errno'] = $err; $header['errmsg'] = $errmsg; $header['content'] = $content; return $header; } // here is the complete use of the function that will take all the src of the images regardless weather the image has a basename or is a php or html link, it will get the file source and convert it to a base64 embedded image and put it back in its original place.. NOTE: i use output not echo you can change that to your needs.. if(preg_match_all('/<img[^>]+>/i', $msgBody, $matches)){ $i = 1; $imageinfo = array(); foreach ($matches[0] as $img) { $id = 'img_'.($i++); preg_match('/src="(.*?)"/', $img, $m); $src1 = str_replace('src=','',$m[0]); $src = str_replace('"','',$src1); if (preg_match('/(\.jpg|\.png|\.bmp|\.gif|\.jpeg)$/', $src)) { // style and height width attributes are only necessary //for already displayed inline images with correct or direct url's preg_match_all('/(style)=("[^"]*")/i',$img, $imageinfo[$img]); $style = str_replace('"', '', $imageinfo[$img][2][0]); if($Style !='') $nstyle =' style="border: none;'.$style.'"'; else $nstyle=' style="border: none;"'; if(strpos($nstyle,'width')===0 ){ preg_match('/(width)=("[^"]*")/i',$img, $imageinfo[$img]); $width= str_replace('"', '', $imageinfo[$img][2][0]); if($width !='') $nwidth = ' width="'.$width.'"'; } if(strpos($nstyle,'height')===0 ){ preg_match('/(height)=("[^"]*")/i',$img, $imageinfo[$img]); $height= str_replace('"', '', $imageinfo[$img][2][0]); if($height !='') $nheight = ' height="'.$height.'"'; } $type = pathinfo($src, PATHINFO_EXTENSION); $imgData = base64_encode(file_get_contents($src)); $fname = basename($src); $msgBody = str_replace($img, '<img id="'.$id.'" src="data:image/' . $type . ';base64,'.$imgData.'"'.$nwidth.$nheight.$nstyle.'/>', $msgBody); } else { $pic = get_web_page($src); if(!preg_match('/(\.jpg|\.png|\.bmp|\.gif|\.jpeg)$/', $pic['url'])) { $pic = get_web_page($pic['url']); } $type = pathinfo($pic['url'], PATHINFO_EXTENSION); $imgData = base64_encode(file_get_contents($pic['url'])); $fname = basename($pic['url']); $msgBody = str_replace($img, '<img id="'.$id.'" src="data:image/' . $type . ';base64,'.$imgData.'"/>', $msgBody); } } $_SESSION['MessageHTML'] = $msgBody; } else { $_SESSION['MessageHTML'] = $msgBody; }
  7. UPDATE: i have this little function that works on any type of link... the only problem im having now is that is only changes the first image it finds, and doesnt itterate through all the images and changes them.. Can someone see the error with my code? if(preg_match('/<img[^>]+>/i', $msgBody)){ preg_match_all('/<img[^>]+>/i', $msgBody, $matches); $i = 1; $imageinfo = array(); foreach ($matches[0] as $img) { $id = 'img_'.($i++); preg_match_all('/(src|style)=("[^"]*")/i',$img, $imageinfo[$img]); $src= str_replace('"', '', $imageinfo[$img][2][0]); if (preg_match('/(\.jpg|\.png|\.bmp|\.gif|\.jpeg)$/', $src)) { preg_match_all('/(style)=("[^"]*")/i',$img, $imageinfo[$img]); $style = str_replace('"', '', $imageinfo[$img][2][0]); if($Style !=''){ $nstyle =' style="border: none;'.$style.'"'; } else { $nstyle=' style="border: none;"'; } if(!preg_match('/width/i', $nstyle, $iswidth)){ preg_match_all('/(width)=("[^"]*")/i',$img, $imageinfo[$img]); $width= str_replace('"', '', $imageinfo[$img][2][0]); if($width !=''){ $nwidth = ' width="'.$width.'"'; } } if(!preg_match('/height/i', $nstyle, $isheight)){ preg_match_all('/(height)=("[^"]*")/i',$img, $imageinfo[$img]); $height= str_replace('"', '', $imageinfo[$img][2][0]); if($height !=''){ $nheight = ' height="'.$height.'"'; } } $type = pathinfo($src, PATHINFO_EXTENSION); $imgData = base64_encode(file_get_contents($src)); $fname =basename($src); //$msgBody = str_replace($img, '<img id="'.$id.'" src="data:image/' . $type . ';base64,'.$imgData.'"'.$nwidth.$nheight.$nstyle.'/>', $msgBody); } else { $pic = get_web_page($src); //this function returns an array of the image from this type of url: //http://hi5.taggedmail.com/imgsrv.php?sz=1&uid=5458308947 foreach($pic as $k =>$v){ //so here its suposed to run throught the $msgBody and find all images that have this type of link.. and then replace the images in the //image body.. however it does not work, and when it does it only changes the first one it comes accross.. $type = pathinfo($pic['url'], PATHINFO_EXTENSION); $imgData = base64_encode(file_get_contents($pic['url'])); $fname =basename($pic['url']); $nwidth =''; $nheight =''; $nstyle=''; } } $msgBody = str_replace($img, '<img id="'.$id.'" src="data:image/' . $type . ';base64,'.$imgData.'"'.$nwidth.$nheight.$nstyle.'/>', $msgBody); } $_SESSION['MessageHTML'] = $msgBody; } else { $_SESSION['MessageHTML'] = $msgBody; } Regards Antony..
  8. OK! so the code above didn't work for my needs, its only to display the image. I now know that what i have to use is Curl. I have this function which returns the above link as an array of the page at the end of the link.. For the email containing the link above this works fine, however i am looking for a more universal solution to my issue.. function get_web_page( $url ) { $options = array( CURLOPT_RETURNTRANSFER => true, // return web page CURLOPT_HEADER => false, // don't return headers CURLOPT_FOLLOWLOCATION => true, // follow redirects CURLOPT_ENCODING => "", // handle all encodings CURLOPT_USERAGENT => "spider", // who am i CURLOPT_AUTOREFERER => true, // set referer on redirect CURLOPT_CONNECTTIMEOUT => 120, // timeout on connect CURLOPT_TIMEOUT => 120, // timeout on response CURLOPT_MAXREDIRS => 10, // stop after 10 redirects ); $ch = curl_init( $url ); curl_setopt_array( $ch, $options ); $content = curl_exec( $ch ); $err = curl_errno( $ch ); $errmsg = curl_error( $ch ); $header = curl_getinfo( $ch ); curl_close( $ch ); $header['errno'] = $err; $header['errmsg'] = $errmsg; $header['content'] = $content; return $header; } $filename = 'http://hi5.taggedmail.com/imgsrv.php?sz=1&uid=5458308947'; $pic = get_web_page($filename); $srcs = array(); foreach($pic as $k =>$v){ if($k == 'url') $newsrc = $v; print_r($newsrc); } return;
  9. Hi jazzman1. if you google this: "Loading mixed (insecure) display content on a secure page" you can see the changes mozilla made. can you please give an example of how to handle this type of link with my code above? regards Antony
  10. UPDATE: if i use file get_contents on this link: http://hi5.taggedmail.com/imgsrv.php?sz=1&uid=5458308947 i get this output when i echo it: JFIFOcad$Rev: 14797 $ %# , #&')*)-0-(0%()( @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@xx" !"1AQa#q3r2BR$&Db1A2Qa! ?kEP6@ZC@ͻV'Iy,s"n!W]*yspo;V(6 6wsnn0̓r7nPѝ$t Dkr^8.jvMPD.0B N[$}7<ppzzF8R^)~폰~[W`RU!qďXَ`wE <eöVz+F;\ۇL]ܗe975;sP@IIfcTscx#)˧9WxvDfϏWqi/,Jc ُ̃z5g*#ҙM_NZ/wkZ\[W[pr:(6=[ n`QȍM pHM&n2=X17w_4=l qQ5:&.wR1ֹbx$4ؾ7SDxh:Q}/ᚓN8lg !flw8~zCqRs#ilQ9q!a&9kFM]G?htUuc8itR>%kaWu 7',,ƨ U4ƨUrMZjȴ[v:vB:Y(FbdƢ9š+3 pcp月=$/j:H?@\Ny-@Er ߲:.G67jtm1>9RUd]*O77)7/W6BB HzZjWd-Nr\9st ԑԐoM`P,D69!\[$t՘5$]^.-cH1PX|MO c_<V%pgsMTbQvDo` J:|\8"ː:/0QO(6{Yz!nnSyy-6Kޮ-fWӞM~:tFosͥG7?"P-r4nD>`joqR;Whˣ>I $fG5UDsk]X_ԅd~S0$aI-^ I>GBZ86F*p$ƅn@Fd{oq̑ȩC0üV睎^f(bP9t j9Ezk9T_)Kٺ%mJ":`cf8|rX*uMc~__ZV֖T05wUA,ek3,@Å~o7q)g4f<8nA[a`G#N@:M ߞS sSKuF(o;Н1$)M(GqJgFJIx?d{ u-laICqH2S2lLF+Œmssnnܪap9*ߖ6Y(9>Fj٭+f\(xs\;o?IcE0vNc`&hȠqȊN Ay޽B{fO۔a1vo 4ԭQt*ӷ}®F<Ыdu-nۼ`ԿP994 #Y i just want to get this info <img height="" width="" style="" src=""> anyone have any ideas?
  11. Hi there. I am busy creating a php imap app for my site. It was working untill Mozilla changed its policies. No i get this error: Loading mixed (insecure) display content on a secure page "http://hi5.taggedmail.com/imgsrv.php?sz=1&uid=5458308947" div.innerHTML = wrap[1] + elem + wrap[2]; What i am doing now is to fetch the image info such as its height width style, then convert the image to a embedded image and return it to its original spot with its original dimensions and style. However i am having problems with image src's that look like the following example: <img src ="http://hi5.taggedmail.com/imgsrv.php?sz=1&uid=5458308947" />// my regex either //doesn't pick it up, or cannot pull the image from this link.. where as a src link example like the following i have no problems, however it only does the first link <img src ="http://x.tagstat.com/im/headers/default/hi5_logo_small_01.png" /> here is my code: if(preg_match('/<img[^>]+>/i', $msgBody)){ preg_match_all('/<img[^>]+>/i', $msgBody, $matches); $i = 1; $nbody =''; $imageinfo = array(); foreach ($matches[0] as $img) { $id = 'img_'.($i++); preg_match_all('/(src|style)=("[^"]*")/i',$img, $imageinfo[$img]); $src= str_replace('"', '', $imageinfo[$img][2][0]); $style = str_replace('"', '', $imageinfo[$img][2][1]); if($Style !='') $nstyle =' style="border: none;'.$style.'"'; else $nstyle=' style="border: none;"'; if(!preg_match('/width/i', $nstyle, $iswidth)){ preg_match_all('/(width)=("[^"]*")/i',$img, $imageinfo[$img]); $width= str_replace('"', '', $imageinfo[$img][2][0]); if($width !='') $nwidth = ' width="'.$width.'"'; } if(!preg_match('/height/i', $nstyle, $isheight)){ preg_match_all('/(height)=("[^"]*")/i',$img, $imageinfo[$img]); $height= str_replace('"', '', $imageinfo[$img][2][0]); if($height !='') $nheight = ' height="'.$height.'"'; } $type = pathinfo($src, PATHINFO_EXTENSION); $imgData = base64_encode(file_get_contents($src)); $nnsrc = 'data:image/' . $type . ';base64,'.$imgData; $nbody .= str_replace($img, '<img id="'.$id.'" src="'.$nnsrc.'"'.$nwidth.$nheight.$nstyle.'/>', $msgBody); } } else { $nbody = $msgBody; } $_SESSION['MessageHTML'] = $nbody;
  12. Thanks jairathnem and cyberRobot for your reply's. I will look into what you gave me and get back as soon as i have something. regards Antony
  13. Hi.. Im working on a script to invite some one to a live chat/video session.. The people involved are global, from all parts of the world.. How it works: profile "A" stipulates his/her available times, as IE: 13:00pm , 12:00pm, 16:00pm, 19:00pm. (lets say this is a GMT +4 timezone); profile "B" wants to chat to profile "A" and sees the available times to book the appointment to chat.. If profile "B" is in the GMT -4 timezone.. How can i display Profile "A"'s times in profile "B"'s timezone.. if it's 13:00pm in +4 GMT its (totally out of my thumb) 04:00am in profile "B"'s time.. also is php the best way to achieve this? or jquery javascript? i have no code..
  14. Thanks a stack Barand.. This is very helpful and I now know how to use the UNION function.. Awesome..
×
×
  • 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.