update.php (11382B)
1 <?php 2 ############################### 3 # include files from root dir # 4 ############################### 5 $root_1 = realpath($_SERVER["DOCUMENT_ROOT"]); 6 $currentdir = getcwd(); 7 $root_2 = str_replace($root_1, '', $currentdir); 8 $root_3 = explode("/", $root_2); 9 if ($root_3[1] == 'core') { 10 echo $root_3[1]; 11 $root = realpath($_SERVER["DOCUMENT_ROOT"]); 12 }else{ 13 $root = $root_1 . '/' . $root_3[1]; 14 } 15 16 require($root . '/core/config/variables.config.php'); 17 require($root . '/core/update/update/vendor/autoload.php'); 18 require($root . '/core/update/update/update.php'); 19 use \VisualAppeal\AutoUpdate; 20 ####################### 21 # flush browser cache # 22 ####################### 23 header("Cache-Control: no-cache, must-revalidate, no-store"); 24 25 if(isset($_GET['update']) && function_exists($_GET['update'])){ 26 call_user_func($_GET['update']); 27 }else{ 28 echo "Function not found or wrong input"; 29 } 30 31 function update(){ 32 global $root, $root_1, $root_2, $root_3; 33 $update = new AutoUpdate($root . '/temp/', $root . '/', 60); 34 $update->setCurrentVersion('1.0.0'); 35 $update->setUpdateUrl('http://media.nordgedanken.de/rpicms/server'); 36 $update->setUpdateFile('update.json'); 37 $update->setBranch('stable'); 38 39 // Optional: 40 $update->addLogHandler(new Monolog\Handler\StreamHandler($root . '/core/update/update.log')); 41 42 43 include($root . '/core/config/variables.config.php'); 44 include($root . '/core/config/connect.db.inc.php'); 45 46 if (mysqli_connect_errno()) { 47 printf("Verbindung fehlgeschlagen: %s\n", mysqli_connect_error()); 48 exit(); 49 } 50 $user = "test"; 51 if ($resultat = $connection->query("SELECT * FROM allowed_user WHERE email LIKE '$user'")) { 52 while($daten = $resultat->fetch_object() ){ 53 $allowed_user = $daten->email; 54 } 55 } 56 #if (empty($allowed_user)) { 57 # echo "You not logged in!"; 58 #}else{ 59 if($allowed_user == $user){ 60 61 ################ 62 # lang support # 63 ################ 64 function getBrowserLangs() { 65 $langs[0] = $langs[1] = substr($_SERVER['HTTP_ACCEPT_LANGUAGE'], 0, 2); 66 $langs[0] = explode(',', $_SERVER['HTTP_ACCEPT_LANGUAGE']); 67 foreach($langs[0] as $l) { 68 $q = explode(';', $l); 69 $lang = substr($q[0], 0, 2); 70 $q = (isset($q[1])) ? (float)substr($q[1], 2) : 1; 71 $result[$lang] = $q; 72 } 73 if(isset($result) && is_array($result)) { 74 arsort($result, SORT_NUMERIC); 75 return $result; 76 } 77 return $result[$langs[1]] = 1; 78 } 79 $langs = getBrowserLangs(); 80 foreach($langs as $prio => $lang) { 81 if($lang = 'de') { 82 include('lang/de-DE.php'); 83 break; 84 } elseif($lang = 'en') { 85 include('lang/en-US.php'); 86 break; 87 } 88 // AND SO ON ................. 89 } 90 ?> 91 <!DOCTYPE html> 92 <html> 93 <head> 94 <meta charset="utf-8"> 95 <meta http-equiv="X-UA-Compatible" content="IE=edge"> 96 <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no"> 97 <meta name="description" content=""> 98 <meta name="author" content=""> 99 100 <link rel="icon" href="../../core/libs/theme_engine/BootStrap/favicon.ico"> 101 <?php 102 echo "<title>$blog_name | Admin</title>"; 103 ?> 104 105 <!-- Bootstrap core CSS --> 106 <link href="../../core/libs/theme_engine/BootStrap/css/bootstrap.min.css" rel="stylesheet"> 107 <!-- Custom styles for this template --> 108 <link href="jumbotron.min.css" rel="stylesheet"> 109 <link rel="stylesheet" href="../../core/libs/theme_engine/font-awesome/css/font-awesome.min.css"> 110 <link rel="stylesheet" href="../../core/libs/theme_engine/bootstrap-social/bootstrap-social.min.css"> 111 <link href="../../core/libs/theme_engine/BootStrap/css/bootstrap-combined.no-icons.min.css" rel="stylesheet"> 112 <!--<script src="../../core/libs/theme_engine/jquery/jquery-1.11.2.min.js"></script>--> 113 114 <?php include($root . '/core/backend/admin/modules/html_header.php'); ?> 115 <!-- Just for debugging purposes. Don't actually copy these 2 lines! --> 116 117 <!--[if lt IE 9]><script src="../../core/libs/theme_engine/BootStrap/js/ie8-responsive-file-warning.js"></script><![endif]--> 118 119 <!-- HTML5 shim and Respond.js for IE8 support of HTML5 elements and media queries --> 120 <!--[if lt IE 9]> 121 <script src="https://oss.maxcdn.com/html5shiv/3.7.2/html5shiv.min.js"></script> 122 <script src="https://oss.maxcdn.com/respond/1.4.2/respond.min.js"></script> 123 <![endif]--> 124 125 <script type="text/javascript"> 126 function Go (select) { 127 var wert = select.options[select.options.selectedIndex].value; 128 if (wert == "leer") { 129 select.form.reset(); 130 parent.frames["unten"].focus(); 131 return; 132 } else { 133 if (wert == "ende") { 134 top.location.href = location.href; 135 } else { 136 location.href = wert; 137 138 } 139 } 140 } 141 </script> 142 <script type="text/javascript"> 143 function showhide(id) { 144 if (document.getElementById) { 145 var divid = document.getElementById(id); 146 var divs = document.getElementsByClassName("hide_"); 147 for (var i = 0; i < divs.length; i++) { 148 divs[i].style.display = "none"; 149 } 150 divid.style.display = "block"; 151 } 152 return false; 153 } 154 function foo() { 155 if(window.location.hash) { 156 var hash = window.location.hash.substring(1); //Puts hash in variable, and removes the # character 157 var divid1 = document.getElementById(hash); 158 divid1.style.display = "block"; 159 } else { 160 var divid1 = document.getElementById("update"); 161 divid1.style.display = "block"; 162 } 163 } 164 onload = foo; 165 </script> 166 <script type="text/javascript" src="../../core/libs/theme_engine/tinymce/tinymce.min.js"></script> 167 </head> 168 <body> 169 <nav class="navbar navbar-inverse navbar-fixed-top" role="navigation"> 170 <div class="container"> 171 <div class="navbar-header"> 172 <button type="button" class="navbar-toggle collapsed" data-toggle="collapse" data-target="#navbar" aria-expanded="false" aria-controls="navbar"> 173 <span class="sr-only">Toggle navigation</span> 174 <span class="icon-bar"></span> 175 <span class="icon-bar"></span> 176 <span class="icon-bar"></span> 177 </button> 178 <?php 179 echo '<a class="navbar-brand" href="index.php">'.$blog_name.'</a>'; 180 ?> 181 </div> 182 <div id="navbar" class="navbar-collapse collapse"> 183 <ul class="nav navbar-nav"> 184 <li class="dropdown"> 185 <a href="admin.php#settings" class="dropdown-toggle disabled" data-toggle="dropdown" role="button" aria-expanded="false">Settings <span class="caret"></span></a> 186 <ul class="dropdown-menu" role="menu"> 187 <li><a href="admin.php#update" class="active">Update <span class="sr-only">(current)</span></a></li> 188 </ul> 189 </li> 190 <li class="dropdown"> 191 <a href="admin.php#posts" class="dropdown-toggle disabled" data-toggle="dropdown" role="button" aria-expanded="false">Posts <span class="caret"></span></a> 192 <ul class="dropdown-menu" role="menu"> 193 <li><a href="admin.php#newpost">New Post</a></li> 194 </ul> 195 </li> 196 </ul> 197 </div><!--/.navbar-collapse --> 198 </div> 199 </nav> 200 201 <!-- Main jumbotron for a primary marketing message or call to action --> 202 <div class="jumbotron"> 203 <div class="container"> 204 <h1>Administration</h1> 205 <hr class="one"> 206 <!-- Tab panes --> 207 <div class="tab-content"> 208 209 <div class="hide_" id="update"> 210 <h2>Updates</h2> 211 <?php 212 //Check for a new update 213 if ($update->checkUpdate() === false) 214 die('Could not check for updates! See log file for details.'); 215 if ($update->newVersionAvailable()) { 216 //Install new update 217 echo 'New Version: ' . $update->getLatestVersion() . '<br>'; 218 echo 'Installing Updates: <br>'; 219 echo '<pre>'; 220 var_dump(array_map(function($version) { 221 return (string) $version; 222 }, $update->getVersionsToUpdate())); 223 echo '</pre>'; 224 $result = $update->update(); 225 if ($result === true) { 226 echo 'Update successful<br>'; 227 } else { 228 echo 'Update failed: ' . $result . '!<br>'; 229 if ($result = AutoUpdate::ERROR_SIMULATE) { 230 echo '<pre>'; 231 var_dump($update->getSimulationResults()); 232 echo '</pre>'; 233 } 234 } 235 } else { 236 echo 'Current Version is up to date<br>'; 237 } 238 ?> 239 <form action="admin.php"> 240 <button type="submit" value="Zurück" class="btn btn-danger">Zurück</button> 241 </form> 242 243 </div> 244 </div> 245 </div> 246 </div> 247 <div class="container"> 248 <!-- Example row of columns --> 249 <div class="row"> 250 <?php 251 echo ' 252 <div class="col-md-4"> 253 <h2>'.$name_themes.'</h2> 254 <form action="."> 255 <p><select size="1" name="Auswahl" onchange="Go(this);" width="100%" class="form-control"> 256 <option value="leer" selected="selected">[ bitte auswählen! ]</option> 257 <option value="leer">------------------------</option> 258 <option value="../jumbotron">Jumbotron</option> 259 <option value="../accentbox">Accentbox</option> 260 <option value="../parkzone">ParkZone</option> 261 <option value="../zResponsiv">zResponsiv</option> 262 <option value="ende">Beenden</option> 263 </select></p> 264 </form> 265 <p><a class="btn btn-default" href="#" role="button">'.$name_details.' »</a></p> 266 </div> 267 <div class="col-md-4"> 268 <h2>'.$name_archiv.'</h2> 269 <p>Donec id elit non mi porta gravida at eget metus. Fusce dapibus, tellus ac cursus commodo, tortor mauris condimentum nibh, ut fermentum massa justo sit amet risus. Etiam porta sem malesuada magna mollis euismod. Donec sed odio dui. </p> 270 <p><a class="btn btn-default" href="#" role="button">'.$name_details.' »</a></p> 271 </div> 272 <div class="col-md-4"> 273 <h2>'.$name_meta.'</h2> 274 <p>Donec sed odio dui. Cras justo odio, dapibus ac facilisis in, egestas eget quam. Vestibulum id ligula porta felis euismod semper. Fusce dapibus, tellus ac cursus commodo, tortor mauris condimentum nibh, ut fermentum massa justo sit amet risus.</p> 275 <p><a class="btn btn-default" href="#" role="button">'.$name_details.' »</a></p> 276 '; 277 ?> 278 </div> 279 </div> 280 281 <hr> 282 283 <footer> 284 <p>© RpicmsTeam 2014 & 2015</p> 285 <?php include($root . '/core/backend/admin/modules/footer.php'); ?> 286 </footer> 287 </div> <!-- /container --> 288 289 290 <!-- Bootstrap core JavaScript 291 ================================================== --> 292 <!-- Placed at the end of the document so the pages load faster --> 293 <script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.3/jquery.min.js"></script> 294 <script src="../../core/libs/theme_engine/BootStrap/js/bootstrap.min.js"></script> 295 <?php include($root . '/core/backend/admin/modules/script_footer.php'); ?> 296 </body> 297 </html> 298 <?php 299 }else{ 300 echo "You not logged in!"; 301 header('HTTP/1.1 401 Unauthorized', true, 401); 302 } 303 304 } 305 ?>