96 echo PageUtils::checkusername($_GET['name']); |
96 echo PageUtils::checkusername($_GET['name']); |
97 break; |
97 break; |
98 case "getsource": |
98 case "getsource": |
99 header('Content-type: application/json'); |
99 header('Content-type: application/json'); |
100 $password = ( isset($_GET['pagepass']) ) ? $_GET['pagepass'] : false; |
100 $password = ( isset($_GET['pagepass']) ) ? $_GET['pagepass'] : false; |
101 $page = new PageProcessor($paths->page_id, $paths->namespace); |
101 $revid = ( isset($_GET['revid']) ) ? intval($_GET['revid']) : 0; |
|
102 $page = new PageProcessor($paths->page_id, $paths->namespace, $revid); |
102 $page->password = $password; |
103 $page->password = $password; |
103 if ( $src = $page->fetch_source() ) |
104 if ( $src = $page->fetch_source() ) |
104 { |
105 { |
105 $allowed = true; |
106 $allowed = true; |
106 } |
107 } |
123 'src' => $src, |
124 'src' => $src, |
124 'auth_view_source' => $allowed, |
125 'auth_view_source' => $allowed, |
125 'auth_edit' => $auth_edit, |
126 'auth_edit' => $auth_edit, |
126 'time' => time(), |
127 'time' => time(), |
127 'require_captcha' => false, |
128 'require_captcha' => false, |
128 'allow_wysiwyg' => $auth_wysiwyg |
129 'allow_wysiwyg' => $auth_wysiwyg, |
|
130 'revid' => $revid |
129 ); |
131 ); |
|
132 |
|
133 if ( $revid > 0 ) |
|
134 { |
|
135 // Retrieve information about this revision and the current one |
|
136 $q = $db->sql_query('SELECT l1.author AS currentrev_author, l2.author AS oldrev_author FROM ' . table_prefix . 'logs AS l1 |
|
137 LEFT JOIN ' . table_prefix . 'logs AS l2 |
|
138 ON ( l2.time_id = ' . $revid . ' |
|
139 AND l2.log_type = \'page\' |
|
140 AND l2.action = \'edit\' |
|
141 AND l2.page_id = \'ACL_Tests\' |
|
142 AND l2.namespace = \'Article\' |
|
143 ) |
|
144 WHERE l1.log_type = \'page\' |
|
145 AND l1.action = \'edit\' |
|
146 AND l1.page_id = \'ACL_Tests\' |
|
147 AND l1.namespace = \'Article\' |
|
148 AND l1.time_id >= ' . $revid . ' |
|
149 ORDER BY l1.time_id DESC;'); |
|
150 if ( !$q ) |
|
151 $db->die_json(); |
|
152 |
|
153 $rev_count = $db->numrows() - 1; |
|
154 $row = $db->fetchrow(); |
|
155 $return['undo_info'] = array( |
|
156 'old_author' => $row['oldrev_author'], |
|
157 'current_author' => $row['currentrev_author'], |
|
158 'undo_count' => $rev_count |
|
159 ); |
|
160 } |
130 |
161 |
131 if ( $auth_edit && !$session->user_logged_in && getConfig('guest_edit_require_captcha') == '1' ) |
162 if ( $auth_edit && !$session->user_logged_in && getConfig('guest_edit_require_captcha') == '1' ) |
132 { |
163 { |
133 $return['require_captcha'] = true; |
164 $return['require_captcha'] = true; |
134 $return['captcha_id'] = $session->make_captcha(); |
165 $return['captcha_id'] = $session->make_captcha(); |