Skip to content

Instantly share code, notes, and snippets.

@taras taras/update.php
Created Aug 8, 2012

Embed
What would you like to do?
<?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
You can’t perform that action at this time.