Subversion Repositories oidplus

Rev

Rev 647 | Rev 650 | Go to most recent revision | Show entire file | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 647 Rev 648
Line 87... Line 87...
87
                                } else {
87
                                } else {
88
                                        $out['text'] .= '<p>'._L('You are using <b>method B</b> (Git working copy).').'</p>';
88
                                        $out['text'] .= '<p>'._L('You are using <b>method B</b> (Git working copy).').'</p>';
89
                                }
89
                                }
90
 
90
 
91
                                $local_installation = OIDplus::getVersion();
91
                                $local_installation = OIDplus::getVersion();
92
                                try {
-
 
93
                                        $svn = new phpsvnclient(parse_ini_file(__DIR__.'/consts.ini')['svn']);
-
 
94
                                        $newest_version = 'svn-'.$svn->getVersion();
92
                                $newest_version = $this->getLatestRevision();
95
                                } catch (Exception $e) {
-
 
96
                                        $newest_version = false;
-
 
97
                                }
-
 
98
 
93
 
99
                                $out['text'] .= _L('Local installation: %1',($local_installation ? $local_installation : _L('unknown'))).'<br>';
94
                                $out['text'] .= _L('Local installation: %1',($local_installation ? $local_installation : _L('unknown'))).'<br>';
100
                                $out['text'] .= _L('Latest published version: %1',($newest_version ? $newest_version : _L('unknown'))).'<br>';
95
                                $out['text'] .= _L('Latest published version: %1',($newest_version ? $newest_version : _L('unknown'))).'<br>';
101
 
96
 
102
                                $requireInfo = ($installType === 'svn-wc') ? _L('shell access with svn/svnversion tool, or PDO/SQLite3 PHP extension') : _L('shell access with Git client');
97
                                $requireInfo = ($installType === 'svn-wc') ? _L('shell access with svn/svnversion tool, or PDO/SQLite3 PHP extension') : _L('shell access with Git client');
Line 112... Line 107...
112
                                } else {
107
                                } else {
113
                                        $out['text'] .= '<p><font color="blue">'._L('Please enter %1 into the SSH shell to update OIDplus to the latest version.','<code>'.$updateCommand.'</code>').'</font></p>';
108
                                        $out['text'] .= '<p><font color="blue">'._L('Please enter %1 into the SSH shell to update OIDplus to the latest version.','<code>'.$updateCommand.'</code>').'</font></p>';
114
 
109
 
115
                                        $out['text'] .= '<h2 id="update_header">'._L('Preview of update %1 &rarr; %2',$local_installation,$newest_version).'</h2>';
110
                                        $out['text'] .= '<h2 id="update_header">'._L('Preview of update %1 &rarr; %2',$local_installation,$newest_version).'</h2>';
116
 
111
 
117
                                        // TODO: Completely remove PHP SVN client and instead get log files hard coded from VTS
-
 
118
                                        ob_start();
112
                                        ob_start();
119
                                        try {
113
                                        try {
120
                                                $svn = new phpsvnclient(parse_ini_file(__DIR__.'/consts.ini')['svn']);
-
 
121
                                                $svn->use_cache = true;
-
 
122
                                                $svn->updateWorkingCopy(str_replace('svn-', '', $local_installation), '/trunk', OIDplus::localpath(), true);
-
 
123
                                                $cont = ob_get_contents();
-
 
124
                                                $cont = str_replace(OIDplus::localpath(), '...', $cont);
114
                                                $cont = $this->showChangelog($local_installation);
125
                                        } catch (Exception $e) {
115
                                        } catch (Exception $e) {
126
                                                $cont = _L('Error: %1',$e->getMessage());
116
                                                $cont = _L('Error: %1',$e->getMessage());
127
                                        }
117
                                        }
128
                                        ob_end_clean();
118
                                        ob_end_clean();
129
 
119
 
Line 135... Line 125...
135
                                $out['text'] .= '<div id="update_versioninfo">';
125
                                $out['text'] .= '<div id="update_versioninfo">';
136
 
126
 
137
                                $out['text'] .= '<p>'._L('You are using <b>method C</b> (Snapshot TAR.GZ file with oidplus_version.txt file).').'</p>';
127
                                $out['text'] .= '<p>'._L('You are using <b>method C</b> (Snapshot TAR.GZ file with oidplus_version.txt file).').'</p>';
138
 
128
 
139
                                $local_installation = OIDplus::getVersion();
129
                                $local_installation = OIDplus::getVersion();
140
                                try {
-
 
141
                                        $svn = new phpsvnclient(parse_ini_file(__DIR__.'/consts.ini')['svn']);
-
 
142
                                        $newest_version = 'svn-'.$svn->getVersion();
130
                                $newest_version = $this->getLatestRevision();
143
                                } catch (Exception $e) {
-
 
144
                                        $newest_version = false;
-
 
145
                                }
-
 
146
 
131
 
147
                                $out['text'] .= _L('Local installation: %1',($local_installation ? $local_installation : _L('unknown'))).'<br>';
132
                                $out['text'] .= _L('Local installation: %1',($local_installation ? $local_installation : _L('unknown'))).'<br>';
148
                                $out['text'] .= _L('Latest published version: %1',($newest_version ? $newest_version : _L('unknown'))).'<br>';
133
                                $out['text'] .= _L('Latest published version: %1',($newest_version ? $newest_version : _L('unknown'))).'<br>';
149
 
134
 
150
                                if (!$newest_version) {
135
                                if (!$newest_version) {
Line 156... Line 141...
156
                                        $out['text'] .= '</div>';
141
                                        $out['text'] .= '</div>';
157
                                } else {
142
                                } else {
158
                                        $out['text'] .= '<p><font color="red">'.strtoupper(_L('Warning')).': '._L('Please make a backup of your files before updating. In case of an error, the OIDplus system (including this update-assistant) might become unavailable. Also, since the web-update does not contain collision-detection, changes you have applied (like adding, removing or modified files) might get reverted/lost! In case the update fails, you can download and extract the complete <a href="https://www.viathinksoft.com/projects/oidplus">SVN-Snapshot TAR.GZ file</a> again. Since all your data should lay inside the folder "userdata" and "userdata_pub", this should be safe.').'</font></p>';
143
                                        $out['text'] .= '<p><font color="red">'.strtoupper(_L('Warning')).': '._L('Please make a backup of your files before updating. In case of an error, the OIDplus system (including this update-assistant) might become unavailable. Also, since the web-update does not contain collision-detection, changes you have applied (like adding, removing or modified files) might get reverted/lost! In case the update fails, you can download and extract the complete <a href="https://www.viathinksoft.com/projects/oidplus">SVN-Snapshot TAR.GZ file</a> again. Since all your data should lay inside the folder "userdata" and "userdata_pub", this should be safe.').'</font></p>';
159
                                        $out['text'] .= '<form method="POST" action="index.php">';
144
                                        $out['text'] .= '<form method="POST" action="index.php">';
160
 
145
 
161
                                        $out['text'] .= '<p><input type="button" onclick="OIDplusPageAdminSoftwareUpdate.doUpdateOIDplus('.(substr($local_installation,4)+1).', '.substr($newest_version,4).')" value="'._L('Update NOW').'"></p>';
146
                                        $out['text'] .= '<p><input type="button" onclick="OIDplusPageAdminSoftwareUpdate.doUpdateOIDplus('.((int)substr($local_installation,4)+1).', '.substr($newest_version,4).')" value="'._L('Update NOW').'"></p>';
162
 
147
 
163
                                        $out['text'] .= '</div>';
148
                                        $out['text'] .= '</div>';
164
 
149
 
165
                                        $out['text'] .= '<h2 id="update_header">'._L('Preview of update %1 &rarr; %2',$local_installation,$newest_version).'</h2>';
150
                                        $out['text'] .= '<h2 id="update_header">'._L('Preview of update %1 &rarr; %2',$local_installation,$newest_version).'</h2>';
166
 
151
 
167
                                        ob_start();
152
                                        ob_start();
168
                                        try {
153
                                        try {
169
                                                $svn = new phpsvnclient(parse_ini_file(__DIR__.'/consts.ini')['svn']);
-
 
170
                                                $svn->use_cache = true;
-
 
171
                                                $svn->updateWorkingCopy(OIDplus::localpath().'/oidplus_version.txt', '/trunk', OIDplus::localpath(), true);
-
 
172
                                                $cont = ob_get_contents();
-
 
173
                                                $cont = str_replace(OIDplus::localpath(), '...', $cont);
154
                                                $cont = $this->showChangelog($local_installation);
174
                                        } catch (Exception $e) {
155
                                        } catch (Exception $e) {
175
                                                $cont = _L('Error: %1',$e->getMessage());
156
                                                $cont = _L('Error: %1',$e->getMessage());
176
                                        }
157
                                        }
177
                                        ob_end_clean();
158
                                        ob_end_clean();
178
 
159
 
Line 205... Line 186...
205
        }
186
        }
206
 
187
 
207
        public function tree_search($request) {
188
        public function tree_search($request) {
208
                return false;
189
                return false;
209
        }
190
        }
-
 
191
 
-
 
192
        private $releases_ser = null;
-
 
193
 
-
 
194
        private function showChangelog($local_ver) {
-
 
195
 
-
 
196
                try {
-
 
197
                        if (is_null($this->releases_ser)) {
-
 
198
                                $url = "https://www.oidplus.com/updates/releases.ser"; // TODO: in consts.ini
-
 
199
                                $cont = @file_get_contents($url);
-
 
200
                                if ($cont === false) return false;
-
 
201
                                $this->releases_ser = $cont;
-
 
202
                        } else {
-
 
203
                                $cont = $this->releases_ser;
-
 
204
                        }
-
 
205
                        $content = '';
-
 
206
                        $ary = @unserialize($cont);
-
 
207
                        if ($ary === false) return false;
-
 
208
                        krsort($ary);
-
 
209
                        foreach ($ary as $rev => $data) {
-
 
210
                                if ($rev <= substr($local_ver,4)) continue;
-
 
211
                                $comment = empty($data['msg']) ? _L('No comment') : $data['msg'];
-
 
212
                                $tex = _L("New revision %1 by %2",$rev,$data['author'])." (".$data['date'].") ";
-
 
213
                                $content .= trim($tex . str_replace("\n", "\n".str_repeat(' ', strlen($tex)), $comment));
-
 
214
                                $content .= "\n";
-
 
215
                        }
-
 
216
                        return $content;
-
 
217
                } catch (Exception $e) {
-
 
218
                        return false;
-
 
219
                }
-
 
220
 
-
 
221
        }
-
 
222
 
-
 
223
        private function getLatestRevision() {
-
 
224
                try {
-
 
225
                        if (is_null($this->releases_ser)) {
-
 
226
                                $url = "https://www.oidplus.com/updates/releases.ser"; // TODO: in consts.ini
-
 
227
                                $cont = @file_get_contents($url);
-
 
228
                                if ($cont === false) return false;
-
 
229
                                $this->releases_ser = $cont;
-
 
230
                        } else {
-
 
231
                                $cont = $this->releases_ser;
-
 
232
                        }
-
 
233
                        $ary = @unserialize($cont);
-
 
234
                        if ($ary === false) return false;
-
 
235
                        krsort($ary);
-
 
236
                        $max_rev = array_keys($ary)[0];
-
 
237
                        $newest_version = 'svn-' . $max_rev;
-
 
238
                        return $newest_version;
-
 
239
                } catch (Exception $e) {
-
 
240
                        return false;
-
 
241
                }
-
 
242
        }
210
}
243
}