Archive for August, 2008

Removing Images from a WordPress Post

Today I ran across a unique need to remove images from a WordPress post in a specific post loop.  Because there is no way to do a “read more” excerpt while taking strict control of the raw content from the_content() I was limited to capturing and manipulating the content from PHP’s output buffer.  My solution: obtain the output from the_content() and remove the image tags from the post using preg_replace().

Here is the solution:

.
.
.
<?php
   ob_start();
   the_content('Read the full post',true);
   $postOutput = preg_replace('/<img[^>]+./','', ob_get_contents());
   ob_end_clean();
   echo $postOutput;
?>
.
.
.



Removing the Password on an Apache SSL Certificate

Every once in a while I run across an SSL Cert with an included password. Although the security is great automating an environment or an Apache restart with required interaction is problematic.

Here is an example of the interaction with a password included SSL Cert:

[root@w2 conf.d]# /etc/init.d/httpd restart
Stopping httpd:                                            [  OK  ]
Starting httpd: Apache/2.2.8 mod_ssl/2.2.8 (Pass Phrase Dialog)
Some of your private key files are encrypted for security reasons.
In order to read them you have to provide the pass phrases.
 
Server chrisschuld.com:443 (RSA)
Enter pass phrase:
 
OK: Pass Phrase Dialog successful.

And here is how you remove the password:

[root@w2 conf]# openssl rsa -in chrisschuld.com.key -out chrisschuld.com.key.nopass