GeezerVison is showing github.com — マージ調整(cd70565) · unpush/p2-php@6777eba
File treeExpand file treeCollapse file tree Open diff view settings Expand file treeCollapse file tree Open diff view settings Collapse file Copy file name to clipboardExpand all lines: js/post_draft.js +3-3Lines changed: 3 additions & 3 deletions | Original file line number | Diff line number | Diff line change |
|---|
@@ -11,7 +11,7 @@ var autosave_interval_id = null; | 11 | 11 | var saveDraftForm = function(form) { | 12 | 12 | document.getElementById('post_draft_msg').innerHTML = | 13 | 13 | (autosave_interval_id !== null ? '自動' : '') + '保存中...'; | 14 | | - post_draft(form.host.value, form.bbs.value, form.key.value, take_kakiko_data(form), | | 14 | + post_draft(form.host.value, form.bbs.value, form.key.value, form.csrfid.value, take_kakiko_data(form), | 15 | 15 | function(st) { | 16 | 16 | setTimeout(function() { | 17 | 17 | if (st == '1') { | @@ -32,7 +32,7 @@ var saveDraftForm = function(form) { | 32 | 32 | }); | 33 | 33 | }; | 34 | 34 |
| 35 | | -var post_draft = function(host, bbs, key, data, fin, err) { | | 35 | +var post_draft = function(host, bbs, key, csrfid, data, fin, err) { | 36 | 36 | var req = (typeof getXmlHttp === 'undefined') ? new XMLHttpRequest() : getXmlHttp(); | 37 | 37 | if (!req) return; | 38 | 38 |
| @@ -54,7 +54,7 @@ var post_draft = function(host, bbs, key, data, fin, err) { | 54 | 54 | }, | 55 | 55 | (function() { | 56 | 56 | var ret = []; | 57 | | - var h = {'host' : host, 'bbs' : bbs, 'key' : key}; | | 57 | + var h = {'host' : host, 'bbs' : bbs, 'key' : key, 'csrfid' : csrfid}; | 58 | 58 | for (var i in h) | 59 | 59 | ret.push(i + '=' + encodeURIComponent(h[i])); | 60 | 60 | return ret; | |
Collapse file Copy file name to clipboardExpand all lines: post.php +3-3Lines changed: 3 additions & 3 deletions | Original file line number | Diff line number | Diff line change |
|---|
| 128 | 128 |
| 129 | 129 | if ($_POST['savedraft']) { | 130 | 130 | // 書き込みを一時的に保存 | 131 | | - $failed_post_file = P2Util::getFailedPostFilePath($host, $bbs, $key); | 132 | | - $cont = serialize($post_cache); | 133 | | - DataPhp::writeDataPhp($failed_post_file, $cont, $_conf['res_write_perm']); | | 131 | + $post_backup_key = PostDataStore::getKeyForBackup($host, $bbs, $key, !empty($_REQUEST['newthread'])); | | 132 | + PostDataStore::set($post_backup_key, $post_cache); | | 133 | + $reload = empty($_POST['from_read_new']); | 134 | 134 | showPostMsg(false, '下書きを保存しました', $reload); | 135 | 135 | exit; | 136 | 136 | } | |
Collapse file Copy file name to clipboardExpand all lines: post_draft.php +42-15Lines changed: 42 additions & 15 deletions | Original file line number | Diff line number | Diff line change |
|---|
| 9 | 9 |
| 10 | 10 | $_login->authorize(); | 11 | 11 |
| | 12 | +// 引数エラー | | 13 | +if (empty($_POST['host'])) { | | 14 | + // 引数の指定が変です | | 15 | + echo 'null'; | | 16 | + exit; | | 17 | +} | | 18 | + | | 19 | +$el = error_reporting(E_ALL & ~E_NOTICE); | | 20 | +$salt = 'post' . $_POST['host'] . $_POST['bbs'] . $_POST['key']; | | 21 | +error_reporting($el); | | 22 | + | | 23 | +if (!isset($_POST['csrfid']) or $_POST['csrfid'] != P2Util::getCsrfId($salt)) { | | 24 | + // 不正なポストです | | 25 | + echo 'null'; | | 26 | + exit; | | 27 | +} | | 28 | + | 12 | 29 | // }}} | 13 | 30 | // {{{ HTTPヘッダ | 14 | 31 |
| | 17 | 34 |
| 18 | 35 | // }}} | 19 | 36 | // {{{ 初期化 | 20 | | -$host = $_POST['host']; | 21 | | -$bbs = $_POST['bbs']; | 22 | | -$key = $_POST['key']; | 23 | | -$message = $_POST['MESSAGE']; | 24 | | -$from = $_POST['FROM']; | 25 | | -$mail = $_POST['mail']; | 26 | | -$subject = $_POST['subject']; | 27 | | - | 28 | | -// パラメータを検証 | 29 | | -if (!($host && $bbs && ($message || $from || $mail || $subject))) { | 30 | | - echo 'null'; | 31 | | - exit; | | 37 | +$post_param_keys = array('bbs', 'key', 'time', 'FROM', 'mail', 'MESSAGE', 'subject', 'submit'); | | 38 | +$post_internal_keys = array('host', 'sub', 'popup', 'rescount', 'ttitle_en'); | | 39 | +foreach ($post_param_keys as $pk) { | | 40 | + ${$pk} = (isset($_POST[$pk])) ? mb_convert_encoding($_POST[$pk], 'CP932', 'UTF-8') : ''; | | 41 | +} | | 42 | +foreach ($post_internal_keys as $pk) { | | 43 | + ${$pk} = (isset($_POST[$pk])) ? $_POST[$pk] : ''; | | 44 | +} | | 45 | + | | 46 | +// したらばのlivedoor移転に対応。post先をlivedoorとする。 | | 47 | +$host = P2Util::adjustHostJbbs($host); | | 48 | + | | 49 | +// machibbs、JBBS@したらば なら | | 50 | +if (P2Util::isHostMachiBbs($host) or P2Util::isHostJbbsShitaraba($host)) { | | 51 | + /* compact() と array_combine() でPOSTする値の配列を作るので、 | | 52 | + $post_param_keys と $post_send_keys の値の順序は揃える! */ | | 53 | + //$post_param_keys = array('bbs', 'key', 'time', 'FROM', 'mail', 'MESSAGE', 'subject', 'submit'); | | 54 | + $post_send_keys = array('BBS', 'KEY', 'TIME', 'NAME', 'MAIL', 'MESSAGE', 'SUBJECT', 'submit'); | | 55 | +// 2ch | | 56 | +} else { | | 57 | + $post_send_keys = $post_param_keys; | 32 | 58 | } | | 59 | +$post = array_combine($post_send_keys, compact($post_param_keys)); | | 60 | +unset($post['submit']); | 33 | 61 |
| 34 | 62 | // }}} | 35 | 63 | // {{{ execute | 36 | | -DataPhp::writeDataPhp(P2Util::getFailedPostFilePath($host, $bbs, $key), | 37 | | - serialize(array('host'=>$host, 'bbs'=>$bbs, 'key'=>$key, 'FROM'=>$from, 'mail'=>$mail, 'subject'=>$subject, 'MESSAGE'=>$message)), | 38 | | - $_conf['res_write_perm']); | | 64 | +$post_backup_key = PostDataStore::getKeyForBackup($host, $bbs, $key, !empty($_REQUEST['newthread'])); | | 65 | +PostDataStore::set($post_backup_key, $post); | 39 | 66 |
| 40 | 67 | echo '1'; | 41 | 68 | exit; | |
|