Add ability to update via Git from the management panel (Administrators only)

This commit is contained in:
Trevor Slocum 2013-04-15 18:53:16 -07:00
parent 02290cc3d1
commit a5a93dd639
2 changed files with 36 additions and 3 deletions

View File

@ -237,6 +237,19 @@ if (isset($_POST['message']) || isset($_POST['file'])) {
$onload = manageOnLoad('bans');
$text .= manageBanForm();
$text .= manageBansTable();
} else if (isset($_GET['update'])) {
if (is_dir('.git')) {
$git_output = shell_exec('git pull 2>&1');
$text .= '<blockquote class="reply" style="padding: 7px;font-size: 1.25em;">
<pre>Attempting update...' . "\n\n" . $git_output . '</pre>
</blockquote>
<p><b>Note:</b> If TinyIB updates and you have made custom modifications, <a href="https://github.com/tslocum/TinyIB/commits/master">review the changes</a> which have been merged into your installation.
Ensure that your modifications do not interfere with any new/modified files.
See the <a href="https://github.com/tslocum/TinyIB#readme">README</a> for more information.</p>';
} else {
$text .= '<p><b>TinyIB was not installed via Git.</b></p>
<p>If you installed TinyIB without Git, you must <a href="https://github.com/tslocum/TinyIB">update manually</a>. If you did install with Git, ensure the script has read and write access to the <b>.git</b> folder.</p>';
}
}
}

View File

@ -561,7 +561,7 @@ function manageStatus() {
$i = 0;
foreach ($posts as $post) {
if ($post_html != '') { $post_html .= '<tr><td colspan="2"><hr></td></tr>'; }
$post_html .= '<tr><td>' . buildPost($post, TINYIB_INDEXPAGE) . '</td><td valign="top"><form method="get" action="?"><input type="hidden" name="manage" value=""><input type="hidden" name="moderate" value="' . $post['id'] . '"><input type="submit" value="Moderate" class="managebutton"></form></td></tr>';
$post_html .= '<tr><td>' . buildPost($post, TINYIB_INDEXPAGE) . '</td><td valign="top" align="right"><form method="get" action="?"><input type="hidden" name="manage" value=""><input type="hidden" name="moderate" value="' . $post['id'] . '"><input type="submit" value="Moderate" class="managebutton"></form></td></tr>';
}
return <<<EOF
@ -570,7 +570,27 @@ function manageStatus() {
<fieldset>
<legend>Info</legend>
$info
<table border="0" cellspacing="0" cellpadding="0" width="100%">
<tbody>
<tr><td>
$info
</td>
EOF;
if ($isadmin) {
$output .= <<<EOF
<td valign="top" align="right">
<form method="get" action="?">
<input type="hidden" name="manage">
<input type="hidden" name="update">
<input type="submit" value="Update TinyIB" class="managebutton">
</form>
</td>
EOF;
}
$output .= <<<EOF
</tr>
</tbody>
</table>
</fieldset>
<fieldset>
@ -588,4 +608,4 @@ EOF;
function manageInfo($text) {
return '<div class="manageinfo">' . $text . '</div>';
}
?>
?>