| 24 | | /** |
| 25 | | * If we are already at the version we want to upgrade to this means that the |
| 26 | | * upgrade script did already do its job. |
| 27 | | */ |
| 28 | | if(version_compare(JLOG_SOFTWARE_VERSION, JLOG_INSTALLED_VERSION, '==')) { |
| 29 | | $c['main'] .= '<p class="error">Version '.JLOG_INSTALLED_VERSION.' ist bereits komplett installiert.</p>'; |
| 30 | | } else { |
| 31 | | |
| 32 | | // get list of available languages |
| 33 | | $dir = opendir(JLOG_BASEPATH.'lang'); |
| 34 | | $languages = array(); |
| 35 | | while(($file = readdir($dir)) !== false) { |
| 36 | | if($file == '.' OR $file == '..') continue; |
| 37 | | if(!preg_match('/lang\.([a-zA-z0-9]+)\.inc\.php/', $file, $matches)) continue; |
| 38 | | $languages[] = $matches[1]; |
| 39 | | } |
| 40 | | // detect current language |
| 41 | | include(JLOG_BASEPATH."lang".DIRECTORY_SEPARATOR."lang.inc.php"); |
| 42 | | list($old_language) = explode("-", $l["language"]); |
| 43 | | include(JLOG_BASEPATH.'lang'.DIRECTORY_SEPARATOR.'lang.'.JLOG_LANGUAGE.'.inc.php'); |
| 44 | | |
| 45 | | if(!isset($_POST['update'])) { |
| 46 | | $c['main'] .= "<form action='".$_SERVER['SCRIPT_NAME']."' method='post' accept-charset='UTF-8'> |
| 47 | | <p><label for='password'>Bitte geben Sie Ihr aktuelles Administrator-Passwort ein (zum Schutz gegen unbefugtes Aufrufen dieses Scriptes):</label><br /> |
| 48 | | <input type='password' name='password' id='password' value='' /></p> |
| 49 | | <p><label for='language'>Bitte wÀhlen Sie die gewÌnschte Sprache fÌr Ihr Weblog:</label><br /> |
| 50 | | <select class='userdata' id='language' name='jlog_language'>"; |
| 51 | | foreach($languages as $lang) { |
| 52 | | $c['main'] .= "<option"; |
| 53 | | if((isset($_POST['jlog_language']) AND $_POST['jlog_language'] == $lang) OR $old_language == $lang) $c['main'] .= " selected='selected'"; |
| 54 | | $c['main'] .= ">$lang</option>"; |
| 55 | | } |
| 56 | | $c['main'] .= "</select> |
| 57 | | </p> |
| 58 | | <p>Die Zeichenkodierung ihrer Template-Datei <code>personal/template.tpl</code> muss nach UTF-8 umgewandelt werden. Wenn diese Datei |
| 59 | | beschreibbar ist (z.B.: chmod 777), wird dies vom Updatescript automatisch fÃŒr sie erledigt. |
| 60 | | Andernfalls mÌssen Sie die Konvertierung nachtrÀglich manuell vornehmen.</p> |
| 61 | | <p><input type='submit' name='update' value='Update starten' /></p> |
| 62 | | </form>"; |
| 63 | | } |
| 64 | | else { |
| 65 | | /** |
| 66 | | * The hash of the administrator password is the hash of an ISO-encoded |
| 67 | | * password, which is different from the hash of the same password encoded |
| 68 | | * in UTF-8. Therefore, we have to convert the received password to ISO first, |
| 69 | | * before we can run md5(). |
| 70 | | */ |
| 71 | | $pass1 = md5($_POST['password']); # This is how it should look in |
| 72 | | # Jlog 1.1.0 |
| 73 | | $pass2 = md5(utf8_decode($_POST['password'])); # This is what we need to do for |
| 74 | | # Jlog 1.0.2 password |
| 75 | | $pass3 = md5(utf8_encode($_POST['password'])); # actually this should not happen, |
| 76 | | # but better try this as well, as we |
| 77 | | # don't know how the end-user's |
| 78 | | # system looks like |
| 79 | | |
| 80 | | /** |
| 81 | | * validate form data |
| 82 | | */ |
| 83 | | if(JLOG_ADMIN_PASSWORD != $pass1 AND JLOG_ADMIN_PASSWORD != $pass2 AND JLOG_ADMIN_PASSWORD != $pass3) { |
| 84 | | $update_errors[] = 'Administrator-Passwort fehlerhaft!'; |
| 85 | | } |
| 86 | | |
| 87 | | if(empty($update_errors)) { |
| 88 | | require(JLOG_BASEPATH."scripts".DIRECTORY_SEPARATOR."settings.class.php"); |
| 89 | | |
| 90 | | // read current settings from environment and POSTed data |
| 91 | | $update = new Settings($l); |
| 92 | | $update->get_data(); |
| 93 | | $update->get_userdata(); |
| 94 | | |
| 95 | | // convert all settings to utf8 |
| 96 | | foreach($update->d as $key => $value) { |
| 97 | | $update->d[$key] = utf8_encode($value); |
| 98 | | } |
| 99 | | |
| 100 | | // reset hash of the administrator password (reasons, see above) |
| 101 | | $update->d['jlog_admin_password'] = $pass1; |
| 102 | | |
| 103 | | // store chosen language |
| 104 | | $update->d['jlog_language'] = $_POST['jlog_language']; |
| 105 | | |
| 106 | | // rewrite settings.inc.php |
| 107 | | $update_errors = $update->do_settings(); |
| 108 | | |
| 109 | | /** |
| 110 | | * On a correct Jlog 1.0.2 installation, the template is saved with an ISO |
| 111 | | * encoding, so we're going to try to convert this to UTF-8 |
| 112 | | */ |
| 113 | | $template = JLOG_BASEPATH."personal".DIRECTORY_SEPARATOR."template.tpl"; |
| 114 | | if(@file_put_contents($template, utf8_encode(@file_get_contents($template))) == false) { |
| 115 | | $update_errors[] = 'Die Datei <code>personal/template.tpl</code> konnte nicht in UTF-8 Kodierung konvertiert werden.'; |
| 116 | | } |
| 117 | | |
| 118 | | // Ready :-) |
| 119 | | require(JLOG_BASEPATH."scripts".DIRECTORY_SEPARATOR."update.php"); |
| 120 | | |
| 121 | | if(empty($update_errors)) { |
| 122 | | $c['main'] .= "<p>Update erfolgreich, <a href='../'>Viel SpaÃ</a>!</p>"; |
| 123 | | } |
| 124 | | else { |
| 125 | | $c['main'] .= error_output($update_errors, "", "Das Update wurde durchgefÃŒhrt, allerdings sind folgende Probleme aufgetreten"); |
| 126 | | $c['main'] .= '<p>Sie können versuchen diese Schritte von Hand nachzuvollziehen. <a href="../">Zur Startseite</a></p>'; |
| 127 | | } |
| 128 | | } |
| 129 | | else { |
| 130 | | $c['main'] .= error_output($update_errors, "", "Fehler beim Update"); |
| 131 | | $c['main'] .= '<p><a href="">Erneut versuchen</a></p>'; |
| 132 | | } |
| 133 | | } |
| | 21 | require_once(JLOG_BASEPATH.'scripts'.DIRECTORY_SEPARATOR.'JlogUpdater.php'); |
| | 22 | $updater = new JlogUpdater(); |
| | 23 | |
| | 24 | if ($updater->isUp2Date()) { |
| | 25 | $c['main'] = '<p>Das Update auf ' . JLOG_INSTALLED_VERSION . ' wurde bereits erfolgreich durchgefÃŒhrt.</p>'; |
| | 26 | } |
| | 27 | else if (!isset($_POST['update'])) { |
| | 28 | $c['main'] = $updater->prepareForm($l); |
| | 29 | } |
| | 30 | else { |
| | 31 | $c['main'] = $updater->performUpdate($l); |
| | 32 | |
| | 33 | // Ready :-) |
| | 34 | require(JLOG_BASEPATH."scripts".DIRECTORY_SEPARATOR."update.php"); |