Created
August 8, 2012 04:04
-
-
Save taras/3291949 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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