155 $return['src'] = $row['page_text']; |
155 $return['src'] = $row['page_text']; |
156 $return['edit_summary'] = $row['edit_summary']; |
156 $return['edit_summary'] = $row['edit_summary']; |
157 } |
157 } |
158 } |
158 } |
159 |
159 |
|
160 $return['undo_info'] = array(); |
|
161 |
160 if ( $revid > 0 ) |
162 if ( $revid > 0 ) |
161 { |
163 { |
162 // Retrieve information about this revision and the current one |
164 // Retrieve information about this revision and the current one |
163 $q = $db->sql_query('SELECT l1.author AS currentrev_author, l2.author AS oldrev_author FROM ' . table_prefix . 'logs AS l1 |
165 $q = $db->sql_query('SELECT l1.author AS currentrev_author, l2.author AS oldrev_author FROM ' . table_prefix . 'logs AS l1 |
164 LEFT JOIN ' . table_prefix . 'logs AS l2 |
166 LEFT JOIN ' . table_prefix . 'logs AS l2 |
165 ON ( l2.time_id = ' . $revid . ' |
167 ON ( l2.log_id = ' . $revid . ' |
166 AND l2.log_type = \'page\' |
168 AND l2.log_type = \'page\' |
167 AND l2.action = \'edit\' |
169 AND l2.action = \'edit\' |
168 AND l2.page_id = \'' . $db->escape($paths->page_id) . '\' |
170 AND l2.page_id = \'' . $db->escape($paths->page_id) . '\' |
169 AND l2.namespace = \'' . $db->escape($paths->namespace) . '\' |
171 AND l2.namespace = \'' . $db->escape($paths->namespace) . '\' |
|
172 AND l2.is_draft != 1 |
170 ) |
173 ) |
171 WHERE l1.log_type = \'page\' |
174 WHERE l1.log_type = \'page\' |
172 AND l1.action = \'edit\' |
175 AND l1.action = \'edit\' |
173 AND l1.page_id = \'' . $db->escape($paths->page_id) . '\' |
176 AND l1.page_id = \'' . $db->escape($paths->page_id) . '\' |
174 AND l1.namespace = \'' . $db->escape($paths->namespace) . '\' |
177 AND l1.namespace = \'' . $db->escape($paths->namespace) . '\' |
175 AND l1.time_id >= ' . $revid . ' |
178 AND l1.time_id > ' . $page->revision_time . ' |
|
179 AND l1.is_draft != 1 |
176 ORDER BY l1.time_id DESC;'); |
180 ORDER BY l1.time_id DESC;'); |
177 if ( !$q ) |
181 if ( !$q ) |
178 $db->die_json(); |
182 $db->die_json(); |
179 |
183 |
180 $rev_count = $db->numrows() - 1; |
184 if ( $db->numrows() > 0 ) |
181 if ( $rev_count == -1 ) |
185 { |
182 { |
186 $rev_count = $db->numrows() - 1; |
183 $return = array( |
187 if ( $rev_count == -1 ) |
184 'mode' => 'error', |
188 { |
185 'error' => '[Internal] No rows returned by revision info query. SQL:<pre>' . $db->latest_query . '</pre>' |
189 $return = array( |
|
190 'mode' => 'error', |
|
191 'error' => '[Internal] No rows returned by revision info query. SQL:<pre>' . $db->latest_query . '</pre>' |
|
192 ); |
|
193 } |
|
194 else |
|
195 { |
|
196 $row = $db->fetchrow(); |
|
197 $return['undo_info'] = array( |
|
198 'old_author' => $row['oldrev_author'], |
|
199 'current_author' => $row['currentrev_author'], |
|
200 'undo_count' => $rev_count |
186 ); |
201 ); |
|
202 } |
187 } |
203 } |
188 else |
204 else |
189 { |
205 { |
190 $row = $db->fetchrow(); |
206 $return['revid'] = $revid = 0; |
191 $return['undo_info'] = array( |
|
192 'old_author' => $row['oldrev_author'], |
|
193 'current_author' => $row['currentrev_author'], |
|
194 'undo_count' => $rev_count |
|
195 ); |
|
196 } |
207 } |
197 } |
208 } |
198 |
209 |
199 if ( $auth_edit && !$session->user_logged_in && getConfig('guest_edit_require_captcha') == '1' ) |
210 if ( $auth_edit && !$session->user_logged_in && getConfig('guest_edit_require_captcha') == '1' ) |
200 { |
211 { |
216 $page->password = $pagepass; |
227 $page->password = $pagepass; |
217 |
228 |
218 $page->send(); |
229 $page->send(); |
219 break; |
230 break; |
220 case "savepage": |
231 case "savepage": |
|
232 /* **** OBSOLETE **** */ |
221 $summ = ( isset($_POST['summary']) ) ? $_POST['summary'] : ''; |
233 $summ = ( isset($_POST['summary']) ) ? $_POST['summary'] : ''; |
222 $minor = isset($_POST['minor']); |
234 $minor = isset($_POST['minor']); |
223 $e = PageUtils::savepage($paths->page_id, $paths->namespace, $_POST['text'], $summ, $minor); |
235 $e = PageUtils::savepage($paths->page_id, $paths->namespace, $_POST['text'], $summ, $minor); |
224 if ( $e == 'good' ) |
236 if ( $e == 'good' ) |
225 { |
237 { |
344 if ( !$session->user_logged_in && getConfig('guest_edit_require_captcha') == '1' ) |
356 if ( !$session->user_logged_in && getConfig('guest_edit_require_captcha') == '1' ) |
345 { |
357 { |
346 $return['new_captcha'] = $session->make_captcha(); |
358 $return['new_captcha'] = $session->make_captcha(); |
347 } |
359 } |
348 } |
360 } |
349 |
361 } |
350 // If this is based on a draft version, delete the draft - we no longer need it. |
362 |
351 if ( @$request['used_draft'] ) |
363 // If this is based on a draft version, delete the draft - we no longer need it. |
352 { |
364 if ( @$request['used_draft'] ) |
353 $q = $db->sql_query('DELETE FROM ' . table_prefix . 'logs WHERE log_type = \'page\' AND action = \'edit\' |
365 { |
354 AND page_id = \'' . $db->escape($paths->page_id) . '\' |
366 $q = $db->sql_query('DELETE FROM ' . table_prefix . 'logs WHERE log_type = \'page\' AND action = \'edit\' |
355 AND namespace = \'' . $db->escape($paths->namespace) . '\' |
367 AND page_id = \'' . $db->escape($paths->page_id) . '\' |
356 AND is_draft = 1;'); |
368 AND namespace = \'' . $db->escape($paths->namespace) . '\' |
357 } |
369 AND is_draft = 1;'); |
358 } |
370 } |
359 |
371 |
360 echo enano_json_encode($return); |
372 echo enano_json_encode($return); |
361 |
373 |
362 break; |
374 break; |
383 echo '<div class="info-box">' . $lang->get('editor_msg_diff') . '</div>'; |
395 echo '<div class="info-box">' . $lang->get('editor_msg_diff') . '</div>'; |
384 echo $diff; |
396 echo $diff; |
385 |
397 |
386 break; |
398 break; |
387 case "protect": |
399 case "protect": |
388 echo PageUtils::protect($paths->page_id, $paths->namespace, (int)$_POST['level'], $_POST['reason']); |
400 // echo PageUtils::protect($paths->page_id, $paths->namespace, (int)$_POST['level'], $_POST['reason']); |
|
401 $page = new PageProcessor($paths->page_id, $paths->namespace); |
|
402 header('Content-type: application/json'); |
|
403 |
|
404 $result = $page->protect_page(intval($_POST['level']), $_POST['reason']); |
|
405 echo enano_json_encode($result); |
389 break; |
406 break; |
390 case "histlist": |
407 case "histlist": |
391 echo PageUtils::histlist($paths->page_id, $paths->namespace); |
408 echo PageUtils::histlist($paths->page_id, $paths->namespace); |
392 break; |
409 break; |
393 case "rollback": |
410 case "rollback": |
394 echo PageUtils::rollback( (int)$_GET['id'] ); |
411 $id = intval(@$_GET['id']); |
|
412 $page = new PageProcessor($paths->page_id, $paths->namespace); |
|
413 header('Content-type: application/json'); |
|
414 |
|
415 $result = $page->rollback_log_entry($id); |
|
416 echo enano_json_encode($result); |
395 break; |
417 break; |
396 case "comments": |
418 case "comments": |
397 $comments = new Comments($paths->page_id, $paths->namespace); |
419 $comments = new Comments($paths->page_id, $paths->namespace); |
398 if ( isset($_POST['data']) ) |
420 if ( isset($_POST['data']) ) |
399 { |
421 { |
403 { |
425 { |
404 die('{ "mode" : "error", "error" : "No input" }'); |
426 die('{ "mode" : "error", "error" : "No input" }'); |
405 } |
427 } |
406 break; |
428 break; |
407 case "rename": |
429 case "rename": |
408 echo PageUtils::rename($paths->page_id, $paths->namespace, $_POST['newtitle']); |
430 $page = new PageProcessor($paths->page_id, $paths->namespace); |
|
431 header('Content-type: application/json'); |
|
432 |
|
433 $result = $page->rename_page($_POST['newtitle']); |
|
434 echo enano_json_encode($result); |
409 break; |
435 break; |
410 case "flushlogs": |
436 case "flushlogs": |
411 echo PageUtils::flushlogs($paths->page_id, $paths->namespace); |
437 echo PageUtils::flushlogs($paths->page_id, $paths->namespace); |
412 break; |
438 break; |
413 case "deletepage": |
439 case "deletepage": |