commit 6783c6b368f1dffbdc92e8cfa12f734ce3f2e64d
parent dde96cd039432b2b5b7142bc8331cb3468324e12
Author: MTRNord <mtrnord1@gmail.com>
Date: Sat, 20 Dec 2014 20:51:43 +0100
add update script to jumbotron
Diffstat:
2 files changed, 45 insertions(+), 1 deletion(-)
diff --git a/core/update/update/update.php b/core/update/update/update.php
@@ -1,12 +1,26 @@
<?php
+###############################
+# include files from root dir #
+###############################
+$root_1 = realpath($_SERVER["DOCUMENT_ROOT"]);
+$currentdir = getcwd();
+$root_2 = str_replace($root_1, '', $currentdir);
+$root_3 = explode("/", $root_2);
+if ($root_3[1] == 'core') {
+ echo $root_3[1];
+ $root = realpath($_SERVER["DOCUMENT_ROOT"]);
+}else{
+ $root = $root_1 . '/' . $root_3[1];
+}
+
/*
* Set the script max execution time
*/
ini_set('max_execution_time', 60);
define('UPDATE_DIR_TEMP', dirname(__FILE__).'/temp/');
-define('UPDATE_DIR_INSTALL', dirname(__FILE__).'/../');
+define('UPDATE_DIR_INSTALL', $root);
class AutoUpdate {
/*
diff --git a/themes/jumbotron/admin.php b/themes/jumbotron/admin.php
@@ -179,6 +179,36 @@ foreach($langs as $prio => $lang) {
<div class="hide_" id="update">
<h2>Updates</h2>
+ <?php
+ require($root . '/core/update/update.php');
+
+ $update = new AutoUpdate(true);
+ $update->currentVersion = 1; //Must be an integer - you can't compare strings
+ $update->updateUrl = 'http://media.nordgedanken.de/rpicms/server'; //Replace with your server update directory
+
+ //Check for a new update
+ $latest = $update->checkUpdate();
+ if ($latest !== false) {
+ if ($latest > $update->currentVersion) {
+ //Install new update
+ echo "New Version: ".$update->latestVersionName."<br>";
+ echo "Installing Update...<br>";
+ if ($update->update()) {
+ echo "Update successful!";
+ }
+ else {
+ echo "Update failed!";
+ }
+
+ }
+ else {
+ echo "Current Version is up to date";
+ }
+ }
+ else {
+ echo $update->getLastError();
+ }
+ ?>
</div>
<div class="hide_" id="posts">