Run shell_exec in WordPress and Drupal

March 5, 2007 by gregg Leave a reply »

I found this out on accident – use nested includes to use shell_exec in WordPress and Drupal posts without any issues – I am using the Exec-PHP plugin.

* Tested with WordPress 2.1.2
* WordPress: Only works in Blog posts – not in a “page” – the PHP will not work.
* WordPress: Must use file path, not HTTP URL – see example below. URL’s will not work for the post.
* Drupal, tested as pages – works fine.

WordPress / Drupal Post text – use includes only:

<?php
include "/home/user/domain.com/ScriptDir/index.php";
?>

Contents of /home/user/domain.com/ScriptDir/index.php

<?php
include "/home/user/domain.com/ScriptDir/foo.php";
?>

Finally, the contents of /home/user/domain.com/ScriptDir/foo.php

<?php
shell_exec ( unix commands );
.. more verboten commands
?>
  • del.icio.us
  • Digg
  • Slashdot
  • Technorati
  • MisterWong
  • Reddit
Advertisement:

Leave a Reply


Mochabomb is Digg proof thanks to caching by WP Super Cache