Jump to content

meomike2000

Members
  • Posts

    171
  • Joined

  • Last visited

    Never

About meomike2000

  • Birthday 07/08/1974

Profile Information

  • Gender
    Male
  • Location
    texas

meomike2000's Achievements

Member

Member (2/5)

0

Reputation

  1. i use this sample: $structure = imap_fetchstructure($this->mail,$this->messId); if (!$structure->parts) { // not multipart $body = $this->getPart($s,0); }else { // multipart: iterate through each part $plainmsg = false; $htmlmsg = false; $attachment = Array(); foreach ($structure->parts as $partno0 => $p) { $piece = $this->getPart($p,$partno0+1); if ($piece['type'] == 'attachment') { $attachment[] = $piece['fileName']; //$body['attachment'] = $piece['fileName'];//$this->getPart($p,$partno0+1); }else{ if ($piece['type'] == 'plain') { $plainmsg = $this->formatMessage($piece['body']); } if ($piece['type'] == 'html') { $htmlmsg = $this->formatMessage($piece['body']); } } } if ($attachment) {$body['attachment'] = $attachment;} if ($plainmsg && $htmlmsg) { $body['body'] = ($this->userChoice == 'html') ? $htmlmsg : $plainmsg; //$body['body'] = $piece['type']; }else{ $body['body'] = ($htmlmsg) ? $htmlmsg : $plainmsg; //$data = ($partno > 0) ? imap_fetchbody($mbox,$mid,$partno) : imap_body($mbox,$mid); } } and the piece from $this->getPart($p,$partno0+1); that handles attachment...... // ATTACHMENT // Any part with a filename is an attachment, // so an attached text file (type 0) is not mistaken as the message. if ($params['filename'] || $params['name']) { // filename may be given as 'Filename' or 'Name' or both $filename = ($params['filename'] || $params['name']) ? $params['filename'] : $params['name']; $body['type'] = 'attachment';//$data; $body['fileName'] = $filename; $body['fileData'] = $data; } hope this helps
  2. workin on an email program and i need help with the attachments. were r the stored or how do i make a link to them for downloading, i have searched my email directory and can not find them..... any help would be great. thanks mike
  3. well my solution was to add the row id to the xml then after changes where made i loop through the xml and add the rowid to the changed value with a seperator and then add that to my post array and then i send that to the php script where i loop through my $_POST[] array and then split the value to get the rowid to update with the new value.... while this works i still would like to find a way to post xml back to a php script....... here is the changes to my ajax that adds the post array. and then sends it to php.... also i still get my response back from the php script after processing as xml.... this.setPost = function() { var self = friendspage; var res = []; res = self.xml.getElementsByTagName("friend"); var form = document.createElement('form'); //var inputs = []; for (var a = 0; a < res.length; a++) { self.xmlfriend[a] = res[a]; var rowid = res[a].getElementsByTagName("rowid")[0].childNodes[0].nodeValue; var input = document.createElement('input'); input.type = 'hidden'; input.name = 'input[' + a + ']'; input.value = rowid; form.appendChild(input); } self.doSave(form); }; this.doSave = function(form) { var self = friendspage; var uid = self.uid; var date = new Date(); var ajax = new Ajax(); var postData = formData2QueryString(form); ajax.doPost('../scripts/friends/updateFriendsOrder.php?uid=' + uid + '&date=' + date, postData, self.handleSavexml, 'xml'); }; here is the php file that does the updateing... <?php include '../../conf.php'; $userid = $_GET['uid']; $query = null; //open connection to db. $connection = mysql_connect($host, $user, $pass) or die ('unable to connect!'); //select database to use. mysql_select_db($db) or die ('unable to select database!'); $a = 0; foreach ($_POST['input'] as $fid) { //$fid = $_POST["input[$a]"]; $query = "update friends set orderid = '".$a."' where fid = '".$fid."'"; $updateorder = mysql_query($query); $query = null; $a++; } header("Content-Type: text/xml"); print '<?xml version="1.0" encoding="utf-8" ?> <response>'; if ($a == 0) { print '<type>order</type> <status>fail</status> <a>'.$a.'</a>'; }else{ print '<type>order</type> <status>success</status> <a>'.$a.'</a>'; } print '</response>'; ?> hope this may help anybody that is trying to do something similar.... mike
  4. self.xml is an array that stores the xml...... i tried to store it as a string as u suggest that this is not xml and the script fails.......
  5. i have tried to just post it and pick it up, no luck. here is the complete php file that generates the xml... done to standards..... here i parsed it and printed the results for u. in the real file i dont i send it with the xml header and print the saved xml. those are commented out for the view, i will change that so it is xml for u to see..... look now same file but changed to display with header xml http://www.meo2000.net/web/getallfriends.php also, in my real life scripts i have set the header to xml so yes it is true xml.... <?php include 'conf.php'; $userid = 1; $query = null; //open connection to db. $connection = mysql_connect($host, $user, $pass) or die ('unable to connect!'); //select database to use. mysql_select_db($db) or die ('unable to select database!'); //$query = "select friendid from friends where myid = '" . $userid . "' and status = 'accepted'"; $query = "select users.scrname, users.lastlog, upage.inf, upage.logtime, friends.friendid from users, upage, friends where users.uid = friends.friendid and upage.fk_uid = friends.friendid and friends.myid = '".$userid."' and friends.status = 'accepted'"; $result = mysql_query($query); $query = null; $dom = new DOMDocument('1.0', 'iso-8859-1'); $friends = $dom->createElement('friends'); $dom->appendChild($friends); while ($row = mysql_fetch_row($result)) { $id = $row[4]; if ($row[0] == "double click to set name") { $query = "select uname from users where uid = '".$row[4]."'"; $results = mysql_query($query); $rows = mysql_fetch_row($results); mysql_free_result($results); $uname = $rows[0]; }else { $uname = $row[0]; } $date = get_time($row[1]); //createthumbnail($row[2]); $pic = $row[2]; $uname = htmlentities($uname); $friend = $dom->createElement('friend'); $friends->appendChild($friend); $fid = $friend->appendChild($dom->createElement('id')); $fid->appendChild($dom->createTextNode("id: $id")); $fname = $friend->appendChild($dom->createElement('name')); $fname->appendChild($dom->createTextNode("name: $id")); $fpic = $friend->appendChild($dom->createElement('pic')); $fpic->appendChild($dom->createTextNode("pic: $id")); } $xmldoc = $dom->saveXML(); mysql_free_result($result); //close database mysql_close($connection); $query = null; //echo $xmldoc; //$xml = new DOMDocument(); //$xml->loadXML($xmldoc); // statement block to get at the elements of the xml document //$friendxml = $xml->getElementsByTagName('friend'); //foreach ($friendxml AS $f) { // foreach ($f->childNodes AS $item) { // print $item->nodeValue . "<br />"; // } // print "<br />"; //} header("Content-Type: text/xml") echo $xmldoc; ?>
  6. the xml is generated from a php script, here is a example of the xml with out info filled in, http://www.meo2000.net/web/getallfriends.php the entire user page is generated with js/ajax and i use the AJAX doGET(); to get the xml, then it is parsed and displayed to the user from js/ajax. the user can make changes to the information, some or all, and then the user can save the changes. when the user makes the changes it changes the xml that is stored in a js/ajax global array this/self.xml. i need to send that xml back to the server to be parsed and saved. look at the example xml, that is just part of the info, how else could i send the xml back...... is this possible, and if so, how do i send xml back to the server from my ajax script to my php script...... sorry if it seams confusing.... mike..
  7. i have found that i needed to add/make some changes/ to my ajax script..... not sure if this is correct or not but seems correct.... made this change to this.doReq = function() if (this.method == "POST") { //here is the change..... if (this.responseFormat == "xml") { this.req.setRequestHeader("Content-Type", "text/xml"); }else{ //sending plain text this.req.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded'); } }
  8. here is a sample of my idea, in this example php file, the info is gotten out the database and formated into xml then it is loaded into a domdocument and parsed..... this is much the same idea as to what i am trying to do except the xml is requested by ajax, this lets the user make changes, then i need to be able to send this xml back to the server/php so the changes can be saved... http://www.meo2000.net/web/getallfriends.php
  9. the original file is created with php and then sent to the ajax script, there a user can update the things and then save. on save i need to send the modified xml back to php for processing/saving. i do not use actual xml files. all the info comes from database, so i need to send it back to be saved in database. i need this to be returned as xml, as some users may only need to send back one or two things to be updated while others may need to send back 10 20 or more items to be updated.....
  10. here is the complete ajax script.... function Ajax() { this.req = null; this.url = null; this.method = 'GET'; this.async = true; this.status = null; this.statusText = ''; this.postData = null; this.readyState = null; this.responseText = null; this.responseXML = null; this.handleResp = null; this.responseFormat = 'text'; // 'text', 'xml', or 'object' this.mimeType = null; this.init = function() { if (!this.req) { try { //Try to create object for Firefox, Safari, IE7, etc. this.req = new XMLHttpRequest(); //alert("Your browser is firefox!"); } catch (e) { try { // Try to create object for later versions of IE. this.req = new ActiveXObject("Msxml2.XMLHTTP"); //alert("Your browser is a later version"); } catch (e) { try { //Try to create object for early versions of IE. this.req = new AxtiveXObject("Microsoft.XMLHTTP"); //alert("Your browser is a older version!"); } catch (e) { //could not create an xmlhttprequest object. alert("Your browser broke!"); return false; } } } } return this.req; }; this.doReq = function() { if (!this.init()) { alert('could not create XMLHttpRequest object.'); return; } this.req.open(this.method, this.url, this.async); if (this.method == "POST") { this.req.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded'); } if (this.mimeType) { try { req.overrideMimeType(this.mimeType); } catch (e) { // couldn't override MIME type -- IE6 or Opera? } } var self = this; // Fix loss-of-scope in inner function this.req.onreadystatechange = function() { var resp = null; if (self.req.readyState == 4) { switch (self.responseFormat) { case 'text': resp = self.req.responseText; break; case 'xml': resp = self.req.responseXML; break; case 'object': resp = req; break; } if (self.req.status >= 200 && self.req.status <= 299) { self.handleResp(resp); } else{ self.handleErr(resp); } } }; this.req.send(this.postData); }; this.setMimeType = function(mimeType) { this.mimeType = mimeType; }; this.handleErr = function() { var errorWin; try { errorWin = window.open('', 'errorWin'); errorWin.document.body.innerHTML = this.responseText; } catch (e) { alert('An error occurred, but the error message cannot be ' + 'displayed. This is probably because of your browser\'s ' + 'pop-up blocker.\n' + 'Please allow pop-ups from this web site if you want to ' + 'see the full error message.\n' + '\n' + 'Status Code: ' + this.req.status + '\n' + 'Status Description: ' + this.req.statusText + ' ' + this.url); } }; this.abort = function() { if (this.req) { this.req.onreadystatechange = function() { }; this.req.abort(); this.req = null; } }; this.doPost = function(url, postData, hand, format) { this.url = url; this.handleResp = hand; this.responseFormat = format || 'text'; this.method = 'POST'; this.postData = postData; this.doReq(); }; this.doGet = function(url, hand, format) { this.url = url; this.handleResp = hand; this.responseFormat = format || 'text'; this.doReq(); }; }
  11. may need to move this to the ajax board, not sure..... i tried this $xmldoc=$_GET['ajax_request']; $xml = new DOMDocument(); $xml->loadXML($xmldoc); but that dont seem to work, i will play with it some, maybe i am doing something wrong in the posting part. here is the segment that does the posting..... var ajax = new Ajax(); var postData = self.xml; ajax.doPost('../scripts/friends/updateFriendsOrder.php?uid=' + uid + '&date=' + date, postData, self.handleSave, 'xml');
  12. so what you are saying is that you enter html into a form, save that in a database and then from another page you get the html from the database and display it?????? is my thinking correct
  13. if i were to post an xml document from an ajax script to my php script for processing how do i get/catch the xml in my php script. i have learned how to parse the xml in php by creating it then pasing the results all in same php script. so i can handle that part with this code, but how do i get the value of $xmldoc, see line 3&4 of code below for what $xmldoc is suppost to be , that is the problem i got. //create new dom document $xml = new DOMDocument(); //get sent xml $xmldoc = ?????; //load xmldoc $xml->loadXML($xmldoc); // statement block to get at the elements of the xml document $friendxml = $xml->getElementsByTagName('friend'); foreach ($friendxml AS $f) { foreach ($f->childNodes AS $item) { // print $item->nodeName . " = " . $item->nodeValue . "<br />"; } //print "<br />"; } hope this makes sense, hope you can help, thanks in advance mike.
  14. not sure, check the manual they have examples.... they always use a while() loop,..... http://us2.php.net/manual/en/function.mysql-fetch-array.php
  15. post the code that has problems please
×
×
  • 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.