Export WordPress post URLs

I’m making some Apache redirects from an old domain to a new domain. I need the old domains blog posts to redirect to the new domain. So I need the WordPress permalinks.

In MySQL, you can say the following to get your permalinks.

SELECT wpp.post_title, wpp.guid,wpp.post_date,
CONCAT(wpo_su.option_value,
REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(
    wpo.option_value,'%year%', date_format(wpp.post_date,'%Y'))
    ,'%monthnum%',date_format(wpp.post_date,'%m'))
    ,'%day%',date_format(wpp.post_date,'%d'))
    ,'%postname%',wpp.post_name )
    ,'%category%',wpc.slug )
    ,'%post_id%', wpp.id)
) as permalink
FROM wp_posts wpp
INNER JOIN wp_options wpo ON wpo.option_name='permalink_structure'
INNER JOIN wp_options wpo_su ON wpo_su.option_name='siteurl'
INNER JOIN (
    SELECT wtr.object_id ID, max(wpt.slug) slug
    FROM wp_term_relationships wtr
    INNER JOIN wp_term_taxonomy wtt ON wtt.term_taxonomy_id=wtr.term_taxonomy_id AND wtt.taxonomy='category'
    INNER JOIN wp_terms wpt on wpt.term_id=wtt.term_id
    GROUP BY  wtr.object_id
) wpc ON wpc.ID=wpp.ID
WHERE wpp.post_type = 'post'
AND wpp.post_status = 'publish'
ORDER BY wpp.post_date DESC
Advertisements

Redirecting all mail from Sendmail on PHP

Making websites, eh? Trying to write something for use on your testing server without bombarding your database victims with development spam? You need.. slurp mail! (ahem)

Here’s how to write your own sendmail client that’ll redirect all emails to the address of your choice. Create /usr/sbin/slurpmail and stick this in it!

formail -R cc X-original-cc \
-R to X-original-to \
-R bcc X-original-bcc \
-f -A"To: whoeveryouare@gmail.com" \
| /usr/sbin/sendmail -t -i

Chmod it to make it -rwxr-xr-x. Then in php.ini find the sendmail path line that reads /usr/sbin/sendmail -t -i and change it to slurpmail!

Rock and/or Roll! We are now getting all the mails that would have went to god knows who! yay! Mind and restart Apache now first!