Jump to content

imekul

Members
  • Posts

    17
  • Joined

  • Last visited

    Never

Everything posted by imekul

  1. Are you aware of any samples or examples that show how to do something like this? I found a sample script at http://www.nicholassolutions.com/tutorials/php/index.php#MimeDecode, but it doesn't seem to work fully.
  2. I have piping set up, where when I send an e-mail to a certain address, a script executes. This script will parse the e-mail and will post the body of the e-mails (along with a picture, if attached) to a blog. This all works okay, except the problem I keep running into is when I send from different devices (desktop, Android phone, BlackBerry), the e-mails have different character sets or encoding. So one e-mail will show up just fine, and then the body of another will look something like this: So what I'm wondering is if there is any way to detect the charset/encoding and automatically decode it properly? The only solution I have so far -- and I'm not very good with PHP, I'll admit -- is to just "hack" my way through, by using stristr() to see if the body contains certain characters (like "ISO-8859-1"), and then extracting the text that is in between, say, "ISO-8859-1" and "--". Of course, this is very crude, and has many problems on its own. So what I am looking for is if there is some sort of way to automatically get the body of an e-mail in plain text, regardless of whether the e-mail has an attachment, how it's encoded, or what mail client was used. Thanks for your time!
  3. I have a WordPress blog, and I set up a custom PHP script where I can pipe an e-mail sent to a certain address, having it execute this PHP script that parses the e-mail and then posts the WordPress post. This works just fine. As soon as the post is entered (or if another author makes a post), I receive an e-mail with the text of the post. The subject of the e-mail contains the WordPress post ID. The reason I do that is because I have the script set up where I can quote a given post by simply replying to the corresponding e-mail. Since each subject has its own ID, which is tied to the WP post, this works fine. What I'm trying to do is figure out a more elegant way to include a unique identifier -- that is, the post ID -- in some place OTHER than the subject. For instance, if there was a meta tag or something where I can include a unique identifier, yet it doesn't have to show up in the subject. So an ideal solution would be to take the post ID (say 12345) that would normally show up in the subject, and instead put it in some hidden variable or parameter that is part of the e-mail's headers or meta data. That way, that data would still be accessible by the PHP script, and could be linked to the correct post, but it also frees up the subject line. Any ideas on how I could accomplish this? Basically, I'm looking for a way to assign a unique message ID to each e-mail -- some way to track which e-mail is being replied to. It would be ideal if it was something that was hidden and not shown in the subject or body of the e-mail. Thanks for reading!
  4. Thanks for the lead. I'll try to figure that out. You're not aware of any working examples or tutorials, by chance?
  5. I'm trying to think of a way to, if possible, automate an upload to YouTube using a PHP script. I'll be e-mailing a small 3GP video file to an e-mail address, which then pipes to a PHP script. I can easily parse the e-mail and extract the 3GP video, saving it on my server. So now I would like a way to automatically upload that 3GP to YouTube. Would you say this is possible? In a way, it seems pretty simple... yet I'm just not sure where to go from here, once I have the 3GP file saved on my server. Any ideas? Thanks for reading!
  6. I have a blog that displays the entries with a pretty simple query: SELECT * FROM blog ORDER BY entrynumber DESC LIMIT 50 This works fine, and it sorts by the entry number, and thus, is in chronological order (latest post is shown first). I'm wanting to add a sticky / announcement switch to each entry that will put that entry on top of all of the other ones, so it will basically stay on top, regardless of what its date or entrynumber is. I'm thinking of adding a sticky field to the table, and then switching it to 1 on any post that I want stickified. I can then access the stickies by using this: SELECT * FROM blog WHERE sticky = 1 But I would like to essentially merge the two queries. I'm not too familiar with SQL, but I understand that I should be able to have a query that will first select any post where sticky = 1 (and sort those by entrynumber, should there happen to be more than one sticky at a time). After that, I would like it to simply sort the next 50 results by entrynumber. Does anybody know how I can sort like this? The idea seems pretty simple, but I'm not sure what the SQL would be. Thanks!
  7. Hi guys, I have a WordPress database that has 751 blog entries that I have imported. The problem is that the dates are incorrect, and I want to fix them. Instead of manually updating each row (which, obviously, would take quite some time), I'd like to be able to import data straight into the post_date column of my table. The "correct" dates are just stored like this: 2008-07-04 02:26:00 2008-07-04 11:20:00 2008-07-05 12:44:00 2008-07-05 02:19:00 2008-07-06 01:59:00 2008-07-08 02:31:00 2008-07-09 01:32:00 ...and so on, up to 751. I would love to find an easy way to just be able to import this into the post_date column, but I can't find a way to replace the existing data. Another option that I can think of is to make a long MySQL UPDATE query, but the only problem with this is that the unique ID in my WP table is unfortunately not completely unbroken. It starts at 6 and goes all the way up to 802, which means there are about 50 rows missing along the way. So I guess I have two questions. One, if it's possible to "re-seat" the existing 751 rows, where they will be ID'd as 0-750, that would make it much easier to do some sort of a batch update, I would think. The second option would be to just find a way to merge these 751 lines into the post_date column of the 751 rows in my table. Any ideas on how this could be done? I'm not incredibly proficient at MySQL, but I can get around in phpMyAdmin. The main goal is simply to update the post_date field of the 751 preexisting rows, and put in the data from the 751 lines from the "corrected" file. Thanks for reading this. Any help would be appreciated! Luke
  8. Terrific! I guess this thing is solved. Thanks for all the help, laffin! I love having working examples like this, because then I can dissect them, break them, and learn a little bit about the code.
  9. Terrific! Thanks for the lead, buddy. By the way, any idea how I could make that change on the quirk with the keywords being followed by certain punctuation marks (like , and . and !) always being linked instead of just the first instance? Thanks again. I'm going to check out Expresso right now.
  10. Wow, that works great! Everything seems to be perfect, with a small exception. It seems like when there is a keyword with punctuation after it (i.e., Luke, or Luke. or Luke!), then each and every instance of that word is linked. Honestly, it's not a huge deal, because it's rarer for a word like that to come up. Out of curiosity, though, I'm wondering why that is, if you happen to know. Either way, thanks a million for all of the help. It's been great! I'm going to try to dissect the $pm="/((?<=\s|^)(?:" . implode('|',$wl) .")(?=\.|\!|\?|\,|\'|\s|$))/im"; line and try to make some sense of it.
  11. Also, while I'm at it, is it simple to make the names case-insensitive? So LUKE, Luke, luKe, and luke would all be linked?
  12. That seems to work great! The only problem I can see is that when a person's name (a keyword) is the first word in a post (that is, when the sentence would start out "Luke, are you going to..."), then that keyword is skipped over, is not autolinked. So as a simple example, if the post contained "Luke Luke," the end result would be "Luke Luke." And, as far as I can tell, this only applies to words at the beginning of a post. I think it's something to do with the regular expressions and the delimiters, but, honestly, $pm="/((?<=[\s^])(?:" . implode('|',$wl) .")(?=[\.\!\?\,\'\s$]?))/m"; doesn't make a whole lot of sense to me. Methinks it's time to learn regular expressions.
  13. Hey, I think that works! Wow -- thanks. Now, how would I add more posts to the array? Of course, when it's in use, I'll use a while loop, and each time, the body of the post (the text to be searched) will be $mainbody. So can I just replace $posts with $mainbody? Or do I need to do something else in order to have it work with each individual post, or...? Also, just to experiment, I tried adding a third value, a third sentence, to the $posts array, but that one didn't seem to be searched like the other two were. I could very well be missing something obvious, and, to be honest, I don't understand most of the code you posted. I understand the basics of the preg_replace, but I'm afraid trying to read through your function is just making my head swim a little bit... I'd love to learn this better, though; it looks like there's a tremendous amount of potential with this type of thing. Thanks for taking the time to write it out, though! It looks like it's very close to what I'm looking for.
  14. Ah, good idea. Basically, say I have these two following sentences (each being pulled from a MySQL table): #1 - Well, Mark's Super Bowl picks were definitely closer than Luke's. #2 - Sorry, Mark, I can't go along with you on that one. I'm going to have to side with Luke. Nathan, on the other hand, has a really interesting prediction Imagine each is a separate post in a blog (to see what I'm talking about, go to www.famteam.com/today/). Anyway, when it's all said and done, I want those to be formatted to look like: #1 - Well, Mark's Super Bowl picks were definitely closer than Luke's. #2 - Sorry, Mark, I can't go along with you on that one. I'm going to have to side with Luke. Nathan, on the other hand, has a really interesting prediction. The first instance of each keyword would get a link, and then the rest of the times it comes up, it's just plain text. Hope this makes it a little clearer as to what I'm trying to accomplish!
  15. Hi all! Here's what I'm trying to do. I have a blog (www.famteam.com/today/), and I want to add automatic hyperlinks to different names. Say I mention the name "Luke" in the blog. I want that to be automatically changed to [iurl=#]Luke[/iurl]. But I only want this to happen for the first instance of the keywords, regardless of where in the page the keyword first pops up. Now, here's my current setup: $look_for is an array with the words to search for (names, such as Luke, Mark, et cetera) $replace_with is another array, with the corresponding replacement names (that is, a hyperlinked "Luke," hyperlinked "Mark," etc) $mainbody is the text of each post in the blog. Then I use this: $mainbody = preg_replace($look_for, $replace_with, $mainbody, 1); This works perfectly. The problem is, I pull 50 posts from the database, and so the preg_replace function is getting run 50 times. As a result of that, obviously, it's re-replacing the keywords in each post. Basically, what I would like to happen is for the autolinks to only occur once per keyword for the entire page. The method I have now has them occur once per post. Does this make sense? Basically, I just want each keyword to only be linked one time, in its first instance, throughout the entire page. Thanks for any help you can provide!
×
×
  • 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.