Jump to content

IanArcher

Members
  • Content Count

    115
  • Joined

  • Last visited

Everything posted by IanArcher

  1. Ok, using this setup or building off of it (because i've never used AJAX before) how would I implement that? If possible, can you provide some coding snippets?
  2. I'm writing an application using PHP and MySQL that is a TV Guide/TV Listings to pull the results of the following fields: id – int(11) name – varchar(255) chan_position – int(3) src_image – varchar(255) time – varchar(255) title – varchar(255) date – varchar(25) This is the code I've tried so far that basically displays all results as a table: <?php require('db.php'); ?> <div class="container"> <? //Start table echo "<table id='guide'>"; echo "<th>Channel</th>"; echo "<th>Title</th>"; echo "<th>Time</th>"; echo "<th>Date</th>"; echo "</tr>"; // Loop through database for ($i = 1; $i < $rowcount; $i++) { $row = mysqli_fetch_assoc($result); $chan_name = $row['name']; $chan_num = $row['chan_position']; $chan_logo = $row['src_image']; $time = date("g:i a", strtotime($row['time'])); $title = $row['title']; $date = $row['date']; // Show entries echo "<tr> <td style='text-align: center;'>"."<img src='".$chan_logo."'><br>".$chan_name."</td> <td>".$title."</td> <td>".$time."</td> <td>".$date."</td> </tr>"; } echo "</table>" ?> The ultimate goal is to have it display closely (but not exactly) to how its done here: http://www.zap2it.com/tvlistings 1. Getting the pagination to be horizontal and the loop through the results based on the time that is stored in the `time` column from 00:00 to 23:00 (use of AJAX necessary?) **Additional details** This is what is currently being output and the link above is what is needed to be output in terms of scrolling and pagination functionality. The output of the table at the moment is how the data is currently stored in the table as well.
  3. You're right, It's pretty tricky, but I managed to achieve what i wanted with this: <script type="text/javascript" language="javascript"> window.onload = function() { $('.form_input_select[name="Country[]"]').attr("value","PSC"); /*$('.form_input_select[name="REGION[]"]').html('');*/ /*$('.form_input_select option[value=""]').attr("selected","selected");*/ $('.form_input_select[name="Country[]"]').live('change', function(e) { var pay = $(this).val(); $.get('/m/events/home/?ajax=state&country='+pay, {}, function(r) { //$('.form_input_select[name="REGION[]"]').html(r); }); }); //$('.form_input_select[name="REGION[0]"]').html(''); /*$('.form_input_select option[value=""]').attr("selected","selected");*/ $('.form_input_select[name="Country[0]"]').live('change', function(e) { var pay = $(this).val(); $.get('/m/events/home/?ajax=state&country='+pay, {}, function(r) { $('.form_input_select[name="REGION[0]"]').html(r); }); }); };</script> It still doesn't filter if you select the Region dropdown itself, but it comes with the the user's chosen Region, and the Country change event still works.
  4. I commented out those lines of code: /*$('.form_input_select[name="REGION[]"]').html('');*/ /*$('.form_input_select option[value=""]').attr("selected","selected");*/ $('.form_input_select[name="Country[]"]').live('change', function(e) { var pay = $(this).val(); $.get('/m/events/home/?ajax=state&country='+pay, {}, function(r) { $('.form_input_select[name="REGION[]"]').html(r); }); }); $('.form_input_select[name="REGION[0]"]').html(''); /*$('.form_input_select option[value=""]').attr("selected","selected");*/ $('.form_input_select[name="Country[0]"]').live('change', function(e) { var pay = $(this).val(); $.get('/m/events/home/?ajax=state&country='+pay, {}, function(r) { $('.form_input_select[name="REGION[0]"]').html(r); }); }); And it prepopulates the entire list of Regions/Provinces for the world and when i change the Country drop-down it filters the Regions/Provinces by Country, which is fine, but when i am editing a user's profile with those two fields, by default the Region field still is blank with no options below it until you change the Country, instead of showing the user's chosen region that's stored in the MySQL database. Any ideas?
  5. In essence, PHP is putting out the list of options to the dropdown, but the person before used this javascript code to work with the Country dropdown. Before the Region dropdown was a standalone field filled with options from the database using PHP. And on a slower connection, you can see the pre-populated value that the user has chosen for their region, until the page is finished loading and the Javascript overwrites it to be blank. I only want the javascript to stop doing that until the Country menu is changed. Does that look possible in the code?
  6. Thanks for the response, there is an existing code for this on the site i'm doing it for, i was just thinking of reinventing it. Here it is, i've highlighted the part i'm referring to: <script type="text/javascript"> var oBxUserStatus = new BxUserStatus(); oBxUserStatus.userStatusInit('<bx_url_root />', __is_profile_page__); /** * Zehair : */ $(document).ready(function() { /*** Region Code Starts Here ***/ $('.form_input_select[name="REGION[]"]').html(''); $('.form_input_select option[value=""]').attr("selected","selected"); $('.form_input_select[name="Country[]"]').live('change', function(e) { var pay = $(this).val(); $.get('/m/events/home/?ajax=state&country='+pay, {}, function(r) { $('.form_input_select[name="REGION[]"]').html(r); }); }); $('.form_input_select[name="REGION[0]"]').html(''); $('.form_input_select option[value=""]').attr("selected","selected"); $('.form_input_select[name="Country[0]"]').live('change', function(e) { var pay = $(this).val(); $.get('/m/events/home/?ajax=state&country='+pay, {}, function(r) { $('.form_input_select[name="REGION[0]"]').html(r); }); }); /*** Region Code Ends Here ***/ if(window.location.pathname == '/index.php' || window.location.pathname == '/' ) { $('.mainLogo').css("margin-left","-3px"); } $('.topMenu td:last-child').remove(); $('input[name=copy_to_profile_photos]').attr('checked', false); // $('input[name=copy_to_profile_photos]').hide(); // $('label[for=copy_to_profile_photos]').hide(); $(".form_input_submit img").each(function (i) { $(this).filter(function() { return (($(this).attr('alt') == 'Personnaliser ' ) ? true : false ); }).parent().parent().parent().parent().hide(); }); $(".form_input_submit img").each(function (i) { $(this).filter(function() { return (($(this).attr('alt') == 'Ajouter son' ) ? true : false ); }).parent().parent().parent().parent().hide(); }); $(".form_input_submit img").each(function (i) { $(this).filter(function() { return (($(this).attr('alt') == 'Ajouter des vidéos' ) ? true : false ); }).parent().parent().parent().parent().hide(); }); $(".form_input_submit img").each(function (i) { $(this).filter(function() { return (($(this).attr('alt') == "Demander une info" ) ? true : false ); }).parent().parent().parent().parent().hide(); }); $('.subMenuInfoKeeper .thumbnail_block').hide() }); </script> By default there is a field called Region, and it's populating from a table in the database. The issue is whatever value is stored for that user for this field is being cloaked by a blank option value. I still want the code to be intact for when the Country is changed, but to populate with the user's region by default. Like uncloacking it, until it's changed. I attempted to comment out the lines of code where the option[value=""], but it did nothing. Any ideas?
  7. Hello,I need a some assistance with this javascript/jquery script.I have a page where Every Region/Province/State is a MySQL table called `States`Organization: There is a dropdown menu called Province, that has all these Regions in it. I'm trying to make it so that when a user selects a country from the Country dropdown menu: <select add_other="" multiplyable="true" class="form_input_select" name="Country[]"> The Province drop-down menu below it runs a query to show all States/Provinces that belong to the Country selected and filters/strips out the others that don't. <select add_other="" multiplyable="true" class="form_input_select" name="Province[]"><option value="204">Alsace</option><option value="239">Aquitaine</option><option value="271">Auvergne</option> The SQL Query that could work for this SELECT * FROM `States` WHERE (Selected Country) LIKE 'Country` I've read and looked around and apparently the only effective way to do this with Javascript/JSON to use it with PHP as you can only use node.js to connect to a MySQL database.I'm fairly new to Javascript and really need some pointing in the right direction to put this together as most of the scripts I've found around are really specific to their needs for their site.I'm doing this on Boonex Dolphin so not much modifying the hardcoded HTML itself, which is why I have to take the Javascript/Jquery route with this. Thanks in advance
  8. Agreed, also Apple iPhone Mail doesn't use text/html Content, it uses text/plain. No matter where you add a photo into the body as well, no image tag will show up. Just the photo's Content headers. The most logical thing to do would be just to extract the plain text from the body. I considered writing a script to create img tags where those photo insertions should be, but that would require appending the parts together somehow, set a default image size say 400x350 (But that presents even more complications), and changing the header to text/html. But that literally seems near impossible to do and definitely not logical.
  9. I managed to get around this and successfully deal with this image looping & image naming process by using a recently published class found here:http://www.electrict...ge-attachments/ and followed up that class by using it as an include in the script that creates variables such as $text_part, $html_part, and wrote the following: /**** The below sequence manages IMAGE Tags in E-mail are supplied by direct URL links ****/ if (preg_match_all('/<img\s+([^>]*)src="http(s)?:\/\/(.*)"/i', $emailMessage->bodyHTML, $matches)) { echo '<br />Detected E-mail Client uses URL links for image tags...continuing News from Mail session<br />'; } /**** The below sequence manages IMAGE Tags in E-mail are supplied by attachments ****/ if (preg_match_all('/src="cid:(.*)"/Uims', $emailMessage->bodyHTML, $matches)) { if(count($matches)) { $search = array(); $replace = array(); $num_img = sizeof($emailMessage->attachments); for($i = 1; $i <= $num_img; $i++){ foreach($matches[1] as $match) { $matchExt = $emailMessage->attachments[$match]['subtype']; $fnameExt = (string)$matchExt; $fnameExt = strtolower($fnameExt); $uniqueFilename = "image$i.$fnameExt"; $i++; file_put_contents("$dirname/$uniqueFilename", $emailMessage->attachments[$match]['data']); $search[] = "src=\"cid:$match\""; $replace[] = "src=\"$dirname/$uniqueFilename\""; } $emailMessage->bodyHTML = str_ireplace($search, $replace, $emailMessage->bodyHTML); } } } /**** The below sequence manages IMAGE Tags in E-mail are supplied by inline image data ****/ if(preg_match_all('/src="data:(image\/(.*);.*,(.*))"/Uims', $emailMessage->bodyHTML, $basematches)) { $img_num = sizeof($basematches[2]); if(count($basematches[3])) { $search = array(); $replace = array(); for($i = 1; $i <= $img_num; $i++) { foreach($basematches[3] as $base64data) { $uniqueFilename = "$dirname/image".$i.".png"; $i++; $base64data_decoded = base64_decode($base64data); $imCreate = imagecreatefromstring($base64data_decoded); if ($imCreate !== false) { imagepng($imCreate, $uniqueFilename); imagedestroy($imCreate); } $search[] = "$base64data\""; $replace[] = "$uniqueFilename\""; } $emailMessage->bodyHTML = str_ireplace($search, $replace, $emailMessage->bodyHTML); $emailMessage->bodyHTML = preg_replace("/data:image\/(jpeg|png|bmp|gif);base64,/i", "", $emailMessage->bodyHTML); } }} I am kind of worried about using all that regex to parse this HTML as opposed to finding a DOMDocument solution, but through my research i haven't seen anything that DOMDocuments can do to that length as opposed to PCRE functions. The best one can do is include as many 'possible modifiers' as you can. I'm just trying to get around another bug where Apple iPhone's standard Mail app splits messages in different parts because of inline attachments, i proved this with some testing.An example: --Apple-Mail-1-577088534Content-Transfer-Encoding: quoted-printableContent-Type: text/plain; charset="us-ascii" Title: iPhone Email=0A=Snippet: iPhone Test=0A=Tags: iphone=2Cemail=2Cpictures=0A=Category: Member=0A=Message:=0A=Brothers and sisters have I none but this man's father is my father's son.==0A==0A= --Apple-Mail-1-577088534Content-Disposition: inline; filename="image.png"Content-Type: image/png; name="image.png"Content-Transfer-Encoding: base64 iVBORw0KGgoAAAANSUhEUgAAAUAAAAHgCAYAAADUjLREAAAgAElEQVR4AeydB3xUVfbHTzpJCITemwgIWEBRFARBV117WxVde11X176WXeuuZdUt6t+1u4oFe8MK9opiQRAUadJ7S0hIz/zP94YbXh5v --Apple-Mail-1-577088534Content-Transfer-Encoding: quoted-printableContent-Type: text/plain; charset="us-ascii" =0A==0A=Brothers and sisters have I none but this man's father is my father's son.==0A= --Apple-Mail-1-577088534Content-Disposition: inline; filename="image.jpeg"Content-Type: image/jpeg; name="image.jpeg"Content-Transfer-Encoding: base64 /9j/4AAQSkZJRgABAQAAAQABAAD/4gxYSUNDX1BST0ZJTEUAAQEAAAxITGlubwIQAABtbnRyUkdCIFhZWiAHzgACAAkABgAxAABhY3NwTVNGVAAAAABJRUMgc1JHQgAAAAAAAAAAAAAAAQAA9tYAAQAA --Apple-Mail-1-577088534Content-Transfer-Encoding: quoted-printableContent-Type: text/plain; charset="us-ascii" Brothers and sisters have I none but this man's father is my father's son.==0A= --Apple-Mail-1-577088534Content-Disposition: inline; filename="image.jpeg"Content-Type: image/jpeg; name="image.jpeg"Content-Transfer-Encoding: base64 /9j/4AAQSkZJRgABAQEAYABgAAD/4gxYSUNDX1BST0ZJTEUAAQEAAAxITGlubwIQAABtbnRyUkdCIFhZWiAHzgACAAkABgAxAABhY3NwTVNGVAAAAABJRUMgc1JHQgAAAAAAAAAAAAAAAQAA9tYAAQAA --Apple-Mail-1-577088534Content-Transfer-Encoding: quoted-printableContent-Type: text/plain; charset="us-ascii" Brothers and sisters have I none but this man's father is my father's son.==0A= --Apple-Mail-1-577088534Content-Disposition: inline; filename="image.jpeg"Content-Type: image/jpeg; name="image.jpeg"Content-Transfer-Encoding: base64 /9j/4AAQSkZJRgABAQEASABIAAD/4QI2RXhpZgAATU0AKgAAAAgACgEPAAIAAAAGAAAAhgEQAAIAAAALAAAAjAESAAMAAAABAAYAAAEaAAUAAAABAAAAmAEbAAUAAAABAAAAoAEoAAMAAAABAAIAAAEx --Apple-Mail-1-577088534Content-Transfer-Encoding: quoted-printableContent-Type: text/plain; charset="us-ascii" Brothers and sisters have I none but this man's father is my father's son.==0A==0A=Brothers and sisters have I none Inline image:= --Apple-Mail-1-577088534Content-Disposition: inline; filename="image.jpeg"Content-Type: image/jpeg; name="image.jpeg"Content-Transfer-Encoding: base64 /9j/4AAQSkZJRgABAQEASABIAAD/4QI2RXhpZgAATU0AKgAAAAgACgEPAAIAAAAGAAAAhgEQAAIAAAALAAAAjAESAAMAAAABAAYAAAEaAAUAAAABAAAAmAEbAAUAAAABAAAAoAEoAAMAAAABAAIAAAEx --Apple-Mail-1-577088534Content-Transfer-Encoding: quoted-printableContent-Type: text/plain; charset="us-ascii" but this man's father is my father's son.= --Apple-Mail-1-577088534-- The email contained multiple lines of the same words where as i just inserted pictures amongst them, and also concluded that the client doesn't use <img> tags, (EXCEPT for when forwarding process, then the client uses <img> tags).
  10. Wow to be honest, i really have no idea where to start off writing something for that. Again, not asking to be spoonfed, but maybe some example code please?
  11. How could i start to write something like that? Any specific functions>? Because this sounds similar to the example code you gave for the $fname = ''; $cid = '';
  12. I wrote something to deal with filenames in the MIME headers that causeuse individual names like that, which can cause overwriting, no where i need to save the attachment with that filename that has been modified is the issue. This is somehwere earlier in the script where attachments and filenames for them are processed: // DECODE DATA $data = ($partno)? imap_qprint(imap_fetchbody($mbox,$mid,$partno)): // multipart imap_body($mbox,$mid); // not multipart // Any part may be encoded, even plain text messages, so check everything. if ($p->encoding==4) $data = quoted_printable_decode($data); elseif ($p->encoding==3) $data = base64_decode($data); // no need to decode 7-bit, 8-bit, or binary // PARAMETERS // get all parameters, like charset, filenames of attachments, etc. $params = array(); if ($p->ifparameters) foreach ($p->parameters as $x) $params[ strtolower( $x->attribute ) ] = $x->value; if ($p->ifdparameters) foreach ($p->dparameters as $x) $params[ strtolower( $x->attribute ) ] = $x->value; // ATTACHMENT // Any part with a filename is an attachment, // so an attached text file (type 0) is not mistaken as the message. if (!empty($params['filename']) || !empty($params['name'])) { // filename may be given as 'Filename' or 'Name' or both $filename = (!empty($params['filename']))? $params['filename'] : $params['name']; // filename may be encoded, so see imap_mime_header_decode() $attachments[$filename] = $data; // this is a problem if two files have same name This is where i change the filename if it is just image.jpg|png|bmp or whatever popular extension if ($fname != '' && $cid != '') $images[$cid] = $fname; // map the $cid to the $image to produce the image filename $ifname = $fname; //while(){ if($f = preg_match('/(filename|name)="(image.(png|jpg|jpeg|gif|bmp))"/i', $mimeheaders, $plainfile)){ echo '<br>This is a dangerous filename match that could result in file overwriting and must be numbered sequentially<br />'; if( $ifname === $plainfile[2] ) { echo 'This is the right filename<br>'; echo $plainfile[2] . "<br>"; if ($pos = strrpos($ifname, '.')) { $n = substr($ifname, 0, $pos); $ext = substr($ifname, $pos); echo $ifname = $n . "_" . $i . $ext."<br />"; echo "<a style='font-size:18px; font-weight: bold'>$ifname</a><br />"; } } } But this is where it gets sort of tricky, the below code is in an include file that will save the attachments/images and create a directory to hold them but will only be included only based upon certain validation criterion. // searches the plain text portion of the email for the Title: and its corresponding text.$aSubject = preg_match('/Title:\s+(.*)/i', $text_part, $matches) ? $matches[1] : '';// trim Title: string from the subject, and keeps the group matched corresponding text$aSubject = str_replace("Title: ", "" ,$aSubject);// removes special characters from article/directory name and makes all characters lowercase$stripped = trim(strtolower(preg_replace("/[^A-Za-z0-9 ]/", "", $aSubject)));$aSubject = str_replace(" ", "_", $stripped); // the directory will be created here in the /newsfrommail/ application folder$dirname = "../newsfrommail/$aSubject/";// creates the directory$dir = mkdir($dirname, 0777);// process attachmentsforeach ($attachments as $filename => $data){ // places all attachments in the directory defined by $aSubject file_put_contents("$aSubject/".$filename, $data);} I must change the filename somehow to that of $ifname so the attachment data gets saved to the modified filename and it isn't as simple as changing $filename to $ifname. Any ideas?
  13. Another realization i had is that, because the script i'm using to replace the src attribute's value of an image tag with that of the filename for the CID element in the MIME headers, once a filename is renamed, the replace will be useless if the file that has been saved has been renamed. So the image tag's src won't be pointing to an actual file anymore
  14. Images are saved using: // process attachments foreach ($attachments as $imageFilename => $data) { // places all attachments in the directory defined by $aSubject file_put_contents("$aSubject/" . $imageFilename, $data); } Will that be an issue or just follow what you suggested?
  15. I know it exists somewhere along that lines of using the function, but i mean, during testing, i had an email with 3 .jpeg images sent from Gmail and in the MIME Headers they are all named image.jpeg, and when it came down to saving them only one got saved, so renaming must take place before saving.
  16. coutning the parts in the email was pretty simple: $struct = imap_fetchstructure($mbox,$no); $num_parts = sizeof($struct->parts); It's just the issue where some email clients give their attachments with the same extension the same filename, for e.g. image.jpegBecause when i test with an email with multiple attachments and have them saved to a directory, only one file gets saved.If been researching a way to possibly modify the MIME header if the value of a name of filename attribute is already present in the email, but that's an issue because the attachment part on the script is in an incrementing for loop that looks through each part one at a time. I simply want to rename name/filename value with a _number if it already exists in the email mime headers, any ideas? // PARAMETERS // get all parameters, like charset, filenames of attachments, etc. $params = array(); if ($p->ifparameters) foreach ($p->parameters as $x) $params[ strtolower( $x->attribute ) ] = $x->value; if ($p->ifdparameters) foreach ($p->dparameters as $x) $params[ strtolower( $x->attribute ) ] = $x->value; // ATTACHMENT // Any part with a filename is an attachment, // so an attached text file (type 0) is not mistaken as the message. if (!empty($params['filename']) || !empty($params['name'])) { // filename may be given as 'Filename' or 'Name' or both $filename = (!empty($params['filename']))? $params['filename'] : $params['name']; // filename may be encoded, so see imap_mime_header_decode()
  17. That's true, i see what your getting at. I'll work on that counting the parts in the email returned from imap_fetchstructure, then i'll have a clearer view of replacing multiple cid: images with the actual file.
  18. I hard-coded $num_parts like that only for a short time, I intend of getting the exact number for it after i had completed this part of the testing actually. I moved the $images array out of the for loop for $num_parts, yet still only one image is being properly replaced, the other still remains a cid: entity.
  19. So i made my edits to the code you gave, and it does the replacement, yet the test email i'm working with has two image tags in the body, and it only replaces on. I've been working for a while now trying to get it to jump to other image tags in the body to do replacements with the proper filenames for all of them, but no luck. Used preg_match_all, if statements, even tried putting the code in a function called imageConvert. Forgive me if this is simple to you, I'm still unclear on how i should arrange it to properly replace all the image tag's sources with the filenames even after re-reading through your advice. //The Situation: // Once the replace has occured, you will move onto the next image tag for ($no = 1; $no <= $box->Nmsgs; $no++) // loop through the messages{ preg_match('/<img\s+([^>]*)src="(([^"]*))"\s+([^>]*)(.*?)>/i', $html_part, $srcMatch); // if an image tag is found, start the process for that $cidPos = strpos($srcMatch[2], 'cid:'); // find cid: in html body if($cidPos !== false) { $srcMatch[2] = str_ireplace('cid:', '', $srcMatch[2], $occurance); } // slice off cid: elseif($occurance===0) { echo 'No occurence'; } //count the amount of parts there are in the email $num_parts = 2; for($i = 1; $i <= $num_parts; $i++){ $mimeheaders = imap_fetchmime($mbox, $no, $i); $fname = ''; //empty string $cid = ''; //empty string $matches = array(); //empty array $images = array(); //empy array preg_match('/Content-Type:(.*);\s+name="(.*)"/i', $mimeheaders, $matches); if (count($matches) >= 3) $fname = $matches[2]; preg_match('/Content-ID:(.*)<(.*)>/i', $mimeheaders, $matches); if (count($matches) >= 3) $cid = $matches[2]; if ($fname != '' && $cid != '') $images[$cid] = $fname; // map the $cid to the $image, producing the image filename if($srcMatch[2] == $cid){ // if the match out of the image tag is equiv to the cid $html_part = str_ireplace('cid:', '', $html_part, $returnstring); //slice off cid: (again), **fix this** echo '<b><a style="color:orange"><br />Success</a></b><br />'; $srcMatch[2] = '/'.$srcMatch[2].'/'; //needs delimiters echo $srcMatch[2]; $html_part = preg_replace($srcMatch[2], $image, $html_part); } else { echo '<b><a style="color:orange"><br />Cannot continue replace procedure</a></b>'; } } //end of $num_parts loop } //end of Nmsgs loop
  20. I was looking at it in the actual for loop and saw the $num_parts variable and trying to figure if something was being done with it, because i never actually used a for loop, only foreach loops before and it should've occured to me anyhow, but what should it be actually? I'm not to sure myself.$num_parts = ''; or $num_parts = array();
  21. So if i have: for($i = 1; $i <= $num_parts; $i++){ $fp = fopen('mimeheaders.txt', 'w'); $mimepart = imap_fetchmime($mbox, $no, $i); //1st part fwrite($fp, $mimepart); fclose($fp); $mimeSave = file_get_contents('mimeheaders.txt'); //save a copy of the headers $images = array();} Is that what you're referring to when you say Using a regex right? I'm not that sure about how to go about beginning to write something like that. Could this be an example of what you are referring to? $attachments = array(); // PARAMETERS // get all parameters, like charset, filenames of attachments, etc. $params = array(); if ($p->ifparameters) foreach ($p->parameters as $x) $params[ strtolower( $x->attribute ) ] = $x->value; if ($p->ifdparameters) foreach ($p->dparameters as $x) $params[ strtolower( $x->attribute ) ] = $x->value; // ATTACHMENT // Any part with a filename is an attachment, // so an attached text file (type 0) is not mistaken as the message. if (!empty($params['filename']) || !empty($params['name'])) { // filename may be given as 'Filename' or 'Name' or both $filename = (!empty($params['filename']))? $params['filename'] : $params['name']; // filename may be encoded, so see imap_mime_header_decode() $attachments[$filename] = $data; // this is a problem if two files have same name
  22. Ok so following your guide justsomeguy, i have happed the CID to the names using: echo '<br />Array Joins<br/>';$mergeArr = array_combine($nameArr, $cidArr);echo '<pre>';print_r($mergeArr);echo '</pre>'; Which prints Array JoinsArray( [Image1[2].gif] => 813DEC0642E941F0845447B680DA566A@BrinardHP [Image2[2].gif] => 6829CB8F2D5D43AAB115DE06572E770A@BrinardHP [] =>) Just to be sure, is this the kind of mapping process you were referring to? If so i was trying to search the array using regexp to test it but it kept throwing the expects parameter to be a string, array given Error, as before, but i have no other knowledge, either in the manual as far as i can see that does this: //preg_match_all('/[(.*)]\s+=>\s+(.*)\n/i');if(preg_match_all('/[(.*)]\s=>\s(.*)/', $mergeArr, $mergeMatch)){echo 'Matches<br />';} else {echo 'No matches<br />';} Prints 'No matches'If the above were successfull i would use somewhere along the lines of the following code to do a replace: echo 'Is $srcArr[0] equal to $cidArr[0]?<br />Answer:';if($srcArr[0] == $cidArr[0]){ //prints 'Yes'echo '<h1>Yes</h1>';} else {echo '<h1>No</h1>'; }preg_replace($srcArr[0], $mergeMatch[2], $html_part); Where am I going wrong with the regexp and the replace?
  23. Also, i am using the below code to strip off the 'cid:' string from the CID match, but it keeps throwing the else message: if(array_search('cid:', $srcArr)){str_replace('cid:', '', $srcArr);} else {echo 'No cid affix found<br />';} echo '<hr>'; I used,in_array and preg_replace to no avail. Any ideas? It's how i am going to match up the content-id values with the cid matches.
×
×
  • Create New...