rpicms

A CMS for the Raspberry Pi
git clone git://archive.git.mtrnord.blog/RpicmsTeam/rpicms.git
Log | Files | Refs | README | LICENSE

commit 78f35d134f24d5f8572d7e90c0778af9616ffd8f
parent 0ad800fb26a137703ccc18a6aa630351b6449604
Author: MTRNord <mtrnord1@gmail.com>
Date:   Sat, 20 Dec 2014 22:11:16 +0100

rework admin.php

Diffstat:
Mthemes/jumbotron/admin.php | 32+++-----------------------------
Athemes/jumbotron/update.php | 63+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
2 files changed, 66 insertions(+), 29 deletions(-)

diff --git a/themes/jumbotron/admin.php b/themes/jumbotron/admin.php @@ -179,36 +179,10 @@ foreach($langs as $prio => $lang) { <div class="hide_" id="update"> <h2>Updates</h2> - <?php - require($root . '/core/update/update/update.php'); + <from action="update.php?update=1" method="get"> + <button type="submit" value="update">Update</button> + </from> - $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"> diff --git a/themes/jumbotron/update.php b/themes/jumbotron/update.php @@ -0,0 +1,62 @@ +<?php + +if(isset($_GET['update']) && function_exists($_GET['update'])) +call_user_func($_GET['update']); +else +echo "Function not found or wrong input"; + +####################### +# flush browser cache # +####################### +header("Cache-Control: no-cache, must-revalidate, no-store"); + +############################### +# 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]; +} +function update(){ +require($root . '/core/update/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(); +} +} +// dauerhafte PHP-Weiterleitung (Statuscode 301) +header("HTTP/1.1 301 Moved Permanently"); +// Weiterleitungsziel. Wohin soll eine permanente Weiterleitung erfolgen? +header("Location:admin.php"); +// zur Sicherheit ein exit-Aufruf, falls Probleme aufgetreten sind +exit; +?> +\ No newline at end of file