Skip to content

Instantly share code, notes, and snippets.

@taras
Created August 8, 2012 04:04
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save taras/3291949 to your computer and use it in GitHub Desktop.
Save taras/3291949 to your computer and use it in GitHub Desktop.
<?php
/**
* This script allows to update any directory from its repository if one exists.
*
* Setup:
* 1. Upload update.php file into wp-content directory
* 2. Make update.php executable
* 3. Add the following rewrite rule to your .htaccess at the top
* RewriteRule ^(.*)update$ /wp-content/update.php?path=$1 [QSA,PT]
*
*/
require_once( '../wp-load.php' );
if ( !is_user_logged_in() ) auth_redirect();
if ( !current_user_can('update_core') ) {
echo "You do not have permissions to perform this action";
die();
}
$target = dirname(WP_CONTENT_DIR) .'/'. $_GET['path'];
if ( !is_dir($target.'/.hg') ) {
echo 'This directory does not have a repository';
die();
}
chdir($target);
printf('<pre>%s</pre>', shell_exec('/usr/local/bin/hg pull -u'));
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment