Jump to content

meomike2000

Members
  • Posts

    171
  • Joined

  • Last visited

    Never

Everything posted by meomike2000

  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
  16. here is code that will do just that, post to this file and you can resize image before saving, you will have to make it work for you, and it will handle one upload at a time.... hope it helps... the function createthumbnail() is the resizer play with it <?php session_start(); if(!session_is_registered(username)){ header("location: ../../login2/app_login.php"); } $result = null; //includes. include '../../login/dirconf.php'; // create the users folder in not yet created. if (!is_dir("../users/$username")) { mkdir("../users/$username", 0751); } Function createthumbnail($src=null) { $srcimg = imagecreatefromjpeg($src); $srcsize = getimagesize($src); $dest_y = 900; $dest_x = (900 / $srcsize[1]) * $srcsize[0]; $thumbimg = imagecreatetruecolor($dest_x, $dest_y); imagecopyresampled($thumbimg,$srcimg,0,0,0,0,$dest_x,$dest_y, $srcsize[0], $srcsize[1]); imagejpeg($thumbimg,$src); } //form data. $pinf = $_POST['pinf']; $tag = $_POST['tag']; $disp = $_POST['disp']; //test remove whitespace and replace with _ $rawname = ($_FILES['imagefile']['name']); $newname = str_replace(" ", "_", $rawname); $location = "../users/$username/"; $location = $location . basename($newname); $target = "users/$username/"; $target = $target . basename($newname); $img = $target; $filesize = ($_FILES['imagefile']['size']); $filename = $newname; $filetype = ($_FILES['imagefile']['type']); //open connection to database server. $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!'); //test filename exist $query = "select phname from uphotos where fk_uid = '" . $userid . "' and phname = '" . $filename . "'"; $result = mysql_query($query); //test if file exist. if(mysql_num_rows($result) > 0) { //close database mysql_close($connection); $_SESSION['error'] = "file name exist already!"; header("location: get_manager_images.php?up=true"); exit(); } //requery to get all rows for a user. $query = "select phname from uphotos where fk_uid = '" .$userid. "'"; $result = mysql_query($query); //should allow 8 files. if(mysql_num_rows($result) > 7) { //close database mysql_close($connection); $_SESSION['error'] = "you have reached your upload limit!"; header("location: get_manager_images.php?up=true"); exit(); } //test file. elseif ($filetype = 'image/jpeg') { if($filesize > 0) { if($filesize > 600000) { createthumbnail($_FILES['imagefile']['tmp_name']); } if (move_uploaded_file($_FILES['imagefile']['tmp_name'], $location)) { if(!get_magic_quotes_gpc()) { $fileName = addslashes($fileName); } $query = "INSERT INTO uphotos (fk_uid, phtag, phname, size, content, inf, disp) VALUES ('".$userid."', '".$tag ."', '".$filename."', '".$filesize."', '".$img."', '".$pinf."', '".$disp."')"; $result = mysql_query($query) or die ('error3 in query: $query. ' . mysql_error()); $updatetime = time(); $update = "added photo"; //$query = "update friendupdates set friendupdate = 'added a new photo', time = '".$updatetime."' where userid = '".$userid."'"; $query = "insert into updates (uid,value,time) values ('".$userid."','".$update."','".$updatetime."')"; $result = mysql_query($query); //close database mysql_close($connection); //redirect header("location: get_manager_images.php");//?up=true"); exit(); } } else { $_SESSION['error'] = "there was an error with your upload, please check file size 3mb max size."; header("location: get_manager_images.php?up=true"); exit(); } } else { $_SESSION['error'] = "there was an error with your upload, please check file type, only jpeg images."; header("location: get_manager_images.php?up=true"); exit(); } ?>
  17. the issues i c are near the end of the code were u add in the else clauses and with the last if statement, check you bracket layout } } } } }
  18. here is a link to same xml without the parser... http://www.meo2000.net/web/updatexmltest.php
  19. here is a link if it will help http://www.meo2000.net/web/updateFriendsOrder.php
  20. strip_tags() didnt seem to work, the <br /> or junk is still there. 2 question: 1 why is it there, i didnt add it to the xml anywhere, 2 how do i get rid of it....... also if dont try to parse it, it just prints the xml out on the screen with a warning that the xml has no style, dont need style, and this does not show the <br /> tag. the tag is there only when i try to parse it...... help, never parsed xml with php, only js.....
  21. i have created a test script that generates xml, then i try to parse it farther in the script, the purpose is to learn to parse xml in php... i get an error that says there is junk at the end of my xml document. it is a <br /> tag. but i did not include this tag in the xml doc. so how do i remove this junk.... thanks in advance mike.....
  22. is it possible to send xml back to the server ( script would be php ), and if so can one prove some direction or simple example thanks, mike....
  23. seemed to work fine for me, what browser u using......
  24. so did you figure it out or still need help......
×
×
  • 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.