Changeset 54 for branches/ajax_post_edit
- Timestamp:
- 02/16/09 21:00:11 (3 years ago)
- Location:
- branches/ajax_post_edit
- Files:
-
- 3 modified
-
ajax_post_edit.js (modified) (6 diffs)
-
edit.php (modified) (5 diffs)
-
manifest.xml (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
branches/ajax_post_edit/ajax_post_edit.js
r45 r54 37 37 ape_show_loading_info(); 38 38 39 sendRequest('action=get&id=' + ape_id + '& utf=1&csrf_token=' + ape['crsf_token'], function() {ape_on_ready_get_post()});39 sendRequest('action=get&id=' + ape_id + '&csrf_token=' + ape['crsf_token'], function() {ape_on_ready_get_post()}); 40 40 } 41 41 } … … 50 50 var parsed_message = match(http.responseText, 'parsed_message'); 51 51 52 if (parsed_message == '') 53 { 54 // if it's a security token error 55 error = match(http.responseText.substring(http.responseText.indexOf('<div class="frm-info">')), 'p'); 56 if (error != '') 57 alert(error.substring(0, error.indexOf('.'))); 58 else 59 alert(http.responseText); 60 61 $('post' + ape_id).innerHTML = ape_temp_post; 62 id = -1; 63 return false; 64 } 65 66 var entry_content_html = http.responseText.substring(0, http.responseText.indexOf('<!-- END FORM -->')); 67 $('post' + ape_id).innerHTML = entry_content_html; 68 69 $('postedit').style.height = textAreaHeight + 'px'; 70 $('postedit').focus(); 52 // If there aren't any errors 53 if (parsed_message != '') 54 { 55 var entry_content_html = http.responseText.substring(0, http.responseText.indexOf('<!-- END FORM -->')); 56 $('post' + ape_id).innerHTML = entry_content_html; 57 58 $('postedit').style.height = textAreaHeight + 'px'; 59 $('postedit').focus(); 60 return 1; 61 } 62 63 if (http.responseText.substring(0, 12) == 'csrf_confirm') 64 { 65 response = http.responseText.split(':'); 66 if (confirm(response[1])) 67 { 68 ape['crsf_token'] = response[2]; 69 sendRequest('action=get&id=' + ape_id + '&csrf_token=' + response[2], function() {ape_on_ready_get_post()}); 70 } 71 } 72 else 73 alert(http.responseText); 74 75 $('post' + ape_id).innerHTML = ape_temp_post; 76 id = -1; 71 77 } 72 78 … … 79 85 ape_enable(false); 80 86 81 var silent = '';87 ape_update_url = 'action=update&id=' + ape_id + '&req_message=' + encodeURIComponent($('postedit').value) + '&utf=1'; 82 88 if ($('fldsilent')) 83 silent = '&silent=' + ($('fldsilent').checked ? 1 : 0); 84 85 var subject = ''; 89 ape_update_url += '&silent=' + ($('fldsilent').checked ? 1 : 0); 90 86 91 if ($('req_subject')) 87 subject = '&req_subject=' + encodeURIComponent($('req_subject').value); 88 89 sendRequest('action=update&id=' + ape_id + '&req_message=' + encodeURIComponent($('postedit').value) + subject + silent + '&utf=1&csrf_token=' + ape['crsf_token'], function() {ape_on_ready_update_post()}); 92 ape_update_url += '&req_subject=' + encodeURIComponent($('req_subject').value); 93 94 ape_update_url += '&csrf_token=' + ape['crsf_token']; 95 96 sendRequest(ape_update_url, function() {ape_on_ready_update_post()}); 90 97 ape_show_saving_info(); 91 98 } … … 97 104 function ape_on_ready_update_post() 98 105 { 99 100 106 var message = match(http.responseText, 'message'); 101 107 if (message != '') 102 108 { 109 // Update post message for pun_quote extension 110 try 111 { 112 pun_quote_posts[ape_id] = $('postedit').value; 113 } 114 catch (e) {} 115 103 116 var last_edit = match(http.responseText, 'last_edit'); 104 117 … … 146 159 } 147 160 else 148 alert(http.responseText); 161 { 162 if (http.responseText.substring(0, 12) == 'csrf_confirm') 163 { 164 response = http.responseText.split(':'); 165 if (confirm(response[1])) 166 { 167 ape['crsf_token'] = response[2]; 168 sendRequest(ape_update_url.substring(0, ape_update_url.indexOf('&csrf_token=') + 12) + response[2], function() {ape_on_ready_update_post()}); 169 } 170 else 171 { 172 ape_enable(true); 173 ape_hide_saving_info(); 174 } 175 } 176 else 177 alert(http.responseText); 178 } 149 179 } 150 180 … … 360 390 var ape_menu_hovered = false; // if menu is hovered 361 391 var ape; 392 var ape_update_url = ''; -
branches/ajax_post_edit/edit.php
r45 r54 7 7 8 8 if ($forum_user['g_read_board'] == '0') 9 exit('<error>'.$lang_common['No view'].'</error>'); 10 9 message($lang_common['No view']); 11 10 12 11 require_once FORUM_ROOT.'include/parser.php'; … … 25 24 26 25 if (!isset($id)) 27 exit('<error>'.$lang_common['Bad request'].'</error>'); 28 26 message($lang_common['Bad request']); 29 27 30 28 $query = array( … … 51 49 $result = $forum_db->query_build($query) or error(__FILE__, __LINE__); 52 50 if (!$forum_db->num_rows($result)) 53 exit('<error>'.$lang_common['Bad request'].'</error>');51 message($lang_common['Bad request']); 54 52 55 53 $cur_post = $forum_db->fetch_assoc($result); … … 64 62 $cur_post['closed'] == '1') && 65 63 !$forum_page['is_admmod']) 66 exit('<error>'.$lang_common['No permission'].'</error>'); 67 64 message($lang_common['No permission']); 68 65 69 66 $can_edit_subject = $id == $cur_post['first_post_id']; 70 67 71 72 68 // it's a request for get post message 73 if ($action == "get")69 if ($action == 'get') 74 70 { 75 71 ($hook = get_hook('ape_pre_message_box')) ? eval($hook) : null; … … 117 113 118 114 // it's a request for update post in database 119 elseif ($action == "update")115 elseif ($action == 'update') 120 116 { 121 117 // If it is a topic it must contain a subject -
branches/ajax_post_edit/manifest.xml
r37 r54 4 4 <id>ajax_post_edit</id> 5 5 <title>Ajax Post Edit</title> 6 <version>1.7 </version>6 <version>1.7.1</version> 7 7 <description>This extension allows quickly edit post</description> 8 8 <author>Daris</author> … … 56 56 } 57 57 ]]></hook> 58 59 <hook id="fn_message_start"><![CDATA[ 60 61 if (strpos($_SERVER['SCRIPT_FILENAME'], 'extensions/ajax_post_edit/edit.php') !== false) 62 exit($message); 63 64 ]]></hook> 65 66 <hook id="fn_csrf_confirm_form_start"><![CDATA[ 67 68 if (strpos($_SERVER['SCRIPT_FILENAME'], 'extensions/ajax_post_edit/edit.php') !== false) 69 exit('csrf_confirm:'.$lang_common['CSRF token mismatch'].':'.generate_form_token($ext_info['url'].'/edit.php')); 70 ]]></hook> 71 58 72 </hooks> 59 73 </extension>