Jeffrey Cannon
Forum Replies Created
-
Forum: Hacks
In reply to: New Post via Email PipingI did resolve this issue.
#!/usr/bin/php -q <?php /**/ //setup global $_SERVER variables to keep WP from trying to redirect $_SERVER = array( "HTTP_HOST" => "domain.com", "SERVER_NAME" => "domain.com", "REQUEST_URI" => "/email_pipe/reader.php", // location of this file "REQUEST_METHOD" => "GET" ); //require the WP bootstrap require_once('/home/user/public_html/wp-load.php'); switch_to_blog(70); //include email parser require_once('/home/user/public_html/email_pipe/include/rfc822_addresses.php'); require_once('/home/user/public_html/email_pipe/include/mime_parser.php'); // read from stdin $fd = fopen("php://stdin", "r"); $email = ""; while (!feof($fd)) { $email .= fread($fd, 1024); } fclose($fd); //create the email parser class $mime=new mime_parser_class; $mime->ignore_syntax_errors = 1; $parameters=array( 'Data'=>$email, ); $mime->Decode($parameters, $decoded); //---------------------- GET EMAIL HEADER INFO -----------------------// //get the name and email of the sender $fromName = $decoded[0]['ExtractedAddresses']['from:'][0]['name']; $fromEmail = $decoded[0]['ExtractedAddresses']['from:'][0]['address']; //get the name and email of the recipient $toEmail = $decoded[0]['ExtractedAddresses']['to:'][0]['address']; $toName = $decoded[0]['ExtractedAddresses']['to:'][0]['name']; //get the subject $subject = $decoded[0]['Headers']['subject:']; if (!$subject) {$subject = "(no subject)";} $removeChars = array('<','>'); //get the message id $messageID = str_replace($removeChars,'',$decoded[0]['Headers']['message-id:']); //get the reply id $replyToID = str_replace($removeChars,'',$decoded[0]['Headers']['in-reply-to:']); //---------------------- FIND THE BODY -----------------------// //get the message body if(substr($decoded[0]['Headers']['content-type:'],0,strlen('text/plain')) == 'text/plain' && isset($decoded[0]['Body'])){ $body = $decoded[0]['Body']; } elseif(substr($decoded[0]['Parts'][0]['Headers']['content-type:'],0,strlen('text/plain')) == 'text/plain' && isset($decoded[0]['Parts'][0]['Body'])) { $body = $decoded[0]['Parts'][0]['Body']; } elseif(substr($decoded[0]['Parts'][0]['Parts'][0]['Headers']['content-type:'],0,strlen('text/plain')) == 'text/plain' && isset($decoded[0]['Parts'][0]['Parts'][0]['Body'])) { $body = $decoded[0]['Parts'][0]['Parts'][0]['Body']; } //create email message $email = " Message ID: $messageID Reply ID: $replyToID Subject: $subject To: $toName $toEmail From: $fromName $fromEmail Body: $body "; $email_post = " To: $toName $toEmail From: $fromName $fromEmail Subject: $subject $body "; // Create post object $my_post = array( 'post_title' => $subject, 'post_content' => $email_post, 'post_status' => 'publish', 'post_author' => 52, 'post_type' => 'ticket' ); // Insert the post into the database $new_post = wp_insert_post( $my_post ); // Update status to: New $wpdb->insert( 'blog_70_term_relationships', array( 'object_id' => $new_post, 'term_taxonomy_id' => 5 ), array( '%d', '%d' ) ); // Update priority to: High $wpdb->insert( 'blog_70_term_relationships', array( 'object_id' => $new_post, 'term_taxonomy_id' => 3 ), array( '%d', '%d' ) ); // Update type to: Start $wpdb->insert( 'blog_70_term_relationships', array( 'object_id' => $new_post, 'term_taxonomy_id' => 17 ), array( '%d', '%d' ) ); // Send email //mail('[email protected]',$subject, $email); ?>
Things I discovered through trial and error…
The EOL (end of line) Conversion for the file had to be Unix and not Windows format. I think it also had to be created in UTF-8 and not ANSI.
I had to specify the server variables at the beginning or the switch_to_blog() function wouldn’t work at all.
After the new post was created I had to use MySQL queries to update the post’s taxonomy because it wouldn’t work using the WordPress functions. I think this was because they didn’t recognize the switch_to_blog() function.
Forum: Fixing WordPress
In reply to: Slow WP versions on Hostgator (WP guru assistance)Anyone?
Forum: Fixing WordPress
In reply to: Slowness Hostgator Fresh InstallSomething to note…
I’ve noticed when I type in the URL, hit enter, click the url and hit enter again (basically refresh the page before it loads), it loads faster.
Not sure if that gives any clue as to why it loads slow on the first time and not on the second time, but it’s a trick I’ve found to view the site faster.
Still doesn’t help everyone else who waits for it to load the first time.
Forum: Fixing WordPress
In reply to: Slowness Hostgator Fresh InstallNo, it’s still running slow.
WordPress is slow and SilverStripe is fast.
I assume that means MySQL is doing fine.
Is there anything else to rule out or try?
Forum: Fixing WordPress
In reply to: Slowness Hostgator Fresh InstallI installed SilverStripe and it seems to be doing just fine.
Should I try another one?
Forum: Fixing WordPress
In reply to: Slowness Hostgator Fresh InstallThere’s not one.
It usually shows up if I change the settings for the permalinks, but since it’s a fresh install I didn’t.
Forum: Fixing WordPress
In reply to: Slowness Hostgator Fresh InstallDone.
Still 16 seconds.
Forum: Fixing WordPress
In reply to: Slowness Hostgator Fresh InstallWhat would be something that I could set up with MySQL that would give us the information we need?
I’ve never really done anything from scratch. I’ve always used pre-packaged setups for my websites.
Forum: Fixing WordPress
In reply to: Slowness Hostgator Fresh InstallDone.
Same load time.
Forum: Fixing WordPress
In reply to: Slowness Hostgator Fresh InstallLoaded in 1 second…
Forum: Plugins
In reply to: How to customize RSS feed in WP 2.7 ?I discovered the feeds are created by these files within the wp-includes folder:
– feed-atom.php
– feed-rdf.php
– feed-rss.php
– feed-rss2.php
– feed.phpOf course any changes to these files will be overwritten on an update, but that’s where they are (for the curious).
Forum: Themes and Templates
In reply to: header.php not updatingI was having the same problem and with mine I figured out that it was reading the theme files from my test directory that I had previously been using before I moved the WordPress install to my root directory.
Something to look in to.
Forum: Fixing WordPress
In reply to: [How To] Show Posts Related To Category Only?Here’s the code tweaked with some code found in the query_posts page you provided from the WordPress Codex:
<?php $categoryvariable=$cat; // assign the variable as current category $query= 'cat=' . $categoryvariable. '&orderby=date&order=ASC'; // concatenate the query query_posts($query); // run the query ?> <h2>Recent Posts</h2> <ul> <?php if (have_posts()) : ?> <?php while (have_posts()) : the_post(); ?> <li> <a href="<?php the_permalink() ?>" rel="bookmark" title="Permanent Link to <?php the_title_attribute(); ?>"> <?php the_title(); ?> </a> </li> <?php endwhile; ?> </ul>
Is this closer to what you’re talking about?
Forum: Fixing WordPress
In reply to: “showposts” not working in WP_QueryJust checking to see if anyone knows what’s going on?
Forum: Fixing WordPress
In reply to: [How To] Show Posts Related To Category Only?This should work for you…
<?php if (is_category('Loans')) { query_posts("category_name=Loans&showposts=3"); ?> <h2>Recent Posts</h2> <ul> <?php if (have_posts()) : ?> <?php while (have_posts()) : the_post(); ?> <li><a href="<?php the_permalink() ?>" rel="bookmark" title="Permanent Link to <?php the_title_attribute(); ?>"><?php the_title(); ?></a></li> <?php endwhile; ?> </ul> <?php } ?>