PageRenderTime 26ms CodeModel.GetById 12ms app.highlight 10ms RepoModel.GetById 1ms app.codeStats 1ms

/lib/post_form_options.inc.php

http://github.com/unpush/p2-php
PHP | 337 lines | 240 code | 45 blank | 52 comment | 68 complexity | bf1cab9eaa0752c578d9d23337589845 MD5 | raw file
  1<?php
  2/**
  3 * rep2 - ���X�������݃t�H�[���̋@�\�ǂݍ���
  4 */
  5
  6$js = array();
  7
  8$fake_time = -10; // time ��10���O�ɋU��
  9$time = time() - 9*60*60;
 10$time = $time + $fake_time * 60;
 11
 12$csrfid = P2Util::getCsrfId('post' . $host . $bbs . $key);
 13
 14$hd['FROM'] = '';
 15$hd['mail'] = '';
 16$hd['MESSAGE'] = '';
 17$hd['subject'] = '';
 18$hd['beres_checked'] = '';
 19$hd['p2res_checked'] = '';
 20
 21$htm['beres'] = '';
 22$htm['p2res'] = '';
 23$htm['sage_cb'] = '';
 24$htm['maru_post'] = '';
 25$htm['block_submit'] = '';
 26$htm['src_fix'] = '';
 27$htm['options'] = '';
 28$htm['options_k'] = '';
 29$htm['subject'] = '';
 30$htm['resform_ttitle'] = '';
 31
 32$htm['disable_js'] = <<<EOP
 33<script type="text/javascript">
 34//<![CDATA[
 35// Thanks naoya <http://d.hatena.ne.jp/naoya/20050804/1123152230>
 36
 37function isNetFront() {
 38  var ua = navigator.userAgent;
 39  if (ua.indexOf("NetFront") != -1 || ua.indexOf("AVEFront/") != -1 || ua.indexOf("AVE-Front/") != -1) {
 40    return true;
 41  } else {
 42    return false;
 43  }
 44}
 45
 46function disableSubmit(form) {
 47
 48  // 2006/02/15 NetFront�Ƃ͑����������ł܂��炵���̂Ŕ�����
 49  if (isNetFront()) {
 50    return;
 51  }
 52
 53  var elements = form.elements;
 54  for (var i = 0; i < elements.length; i++) {
 55    if (elements[i].type == 'submit') {
 56      elements[i].disabled = true;
 57    }
 58  }
 59}
 60
 61function setHiddenValue(button) {
 62
 63  // 2006/02/15 NetFront�Ƃ͑����������ł܂��炵���̂Ŕ�����
 64  if (isNetFront()) {
 65    return;
 66  }
 67
 68  if (button.name) {
 69    var q = document.createElement('input');
 70    q.type = 'hidden';
 71    q.name = button.name;
 72    q.value = button.value;
 73    button.form.appendChild(q);
 74  }
 75}
 76
 77//]]>
 78</script>\n
 79EOP;
 80
 81// {{{ key.idx���疼�O�ƃ��[�����Ǎ���
 82
 83if ($lines = FileCtl::file_read_lines($key_idx, FILE_IGNORE_NEW_LINES)) {
 84    $line = explode('<>', $lines[0]);
 85    $hd['FROM'] = htmlspecialchars($line[7], ENT_QUOTES);
 86    $hd['mail'] = htmlspecialchars($line[8], ENT_QUOTES);
 87}
 88
 89// }}}
 90// {{{ �f�[�^�x�[�X�����O����POST���s�f�[�^��beres/p2res�̐ݒ����Ǎ���
 91
 92$post_backup_key = PostDataStore::getKeyForBackup($host, $bbs, $key, !empty($_REQUEST['newthread']));
 93$post_config_key = PostDataStore::getKeyForConfig($host, $bbs);
 94
 95// �O����POST���s�f�[�^
 96if ($post_backup = PostDataStore::get($post_backup_key)) {
 97    $hd['FROM'] = htmlspecialchars($post_backup['FROM'], ENT_QUOTES, 'Shift_JIS');
 98    $hd['mail'] = htmlspecialchars($post_backup['mail'], ENT_QUOTES, 'Shift_JIS');
 99    $hd['MESSAGE'] = htmlspecialchars($post_backup['MESSAGE'], ENT_QUOTES, 'Shift_JIS');
100    $hd['subject'] = htmlspecialchars($post_backup['subject'], ENT_QUOTES, 'Shift_JIS');
101}
102
103// beres/p2res
104if ($post_config = PostDataStore::get($post_config_key)) {
105    if ($post_config['beres']) {
106        $hd['beres_checked'] = ' checked';
107    }
108    if ($post_config['p2res']) {
109        $hd['p2res_checked'] = ' checked';
110    }
111}
112
113// }}}
114// {{{ ���O�ƃ��[���̍ŏI����
115
116// �󔒂̓��[�U�ݒ��l�ɕϊ�
117if ($hd['FROM'] === '') {
118    $hd['FROM'] = htmlspecialchars($_conf['my_FROM'], ENT_QUOTES, 'Shift_JIS');
119}
120if ($hd['mail'] === '') {
121    $hd['mail'] = htmlspecialchars($_conf['my_mail'], ENT_QUOTES, 'Shift_JIS');
122}
123
124// P2NULL�͋󔒂ɕϊ�
125if ($hd['FROM'] === 'P2NULL') {
126    $hd['FROM'] = '';
127}
128if ($hd['mail'] === 'P2NULL') {
129    $hd['mail'] = '';
130}
131
132// }}}
133// {{{ textarea�̑���
134
135// �Q�l �N���V�b�N COLS='60' ROWS='8'
136$mobile = Net_UserAgent_Mobile::singleton();
137$wrap_at = ''; // wrap������W3C HTML 4.01�d�l�ɑ��݂��Ȃ�
138$name_size_at = '';
139$mail_size_at = '';
140$msg_cols_at = '';
141
142// PC
143if (!$_conf['ktai']) {
144    $name_size_at = ' size="19"';
145    $mail_size_at = ' size="19"';
146    $msg_cols_at = ' cols="' . $STYLE['post_msg_cols'] . '"';
147// willcom
148} elseif($mobile->isAirHPhone()) {
149    $msg_cols_at = ' cols="' . $STYLE['post_msg_cols'] . '"';
150// �g��
151} else {
152    $STYLE['post_msg_rows'] = 5;
153    $wrap_at = ' wrap="soft"';
154}
155
156// {{{ PC�p sage �`�F�b�N�{�b�N�X
157
158if (!$_conf['ktai']) {
159    $on_check_sage = ' onchange="checkSage();"';
160    $htm['sage_cb'] = <<<EOP
161<input id="sage" type="checkbox" onclick="mailSage()"><label for="sage">sage</label>
162EOP;
163} else {
164    $on_check_sage = '';
165}
166
167// }}}
168// {{{ ��/Be/����p2 �������� �`�F�b�N�{�b�N�X
169
170//  2ch����������
171if (P2Util::isHost2chs($host) and file_exists($_conf['sid2ch_php'])) {
172    $htm['maru_post'] = '<span title="2ch��ID�̎g�p"><input type="checkbox" id="maru" name="maru" value="1">'
173                      . '<label for="maru">��</label></span>';
174}
175
176// Be
177if (P2Util::isHost2chs($host) and $_conf['be_2ch_code'] && $_conf['be_2ch_mail']) {
178    $htm['beres'] = '<input type="checkbox" id="beres" name="beres" value="1"'. $hd['beres_checked'] . '>'
179                  . '<label for="beres">Be�ŏ�������</label>';
180}
181
182// ����p2
183if ((P2Util::isHost2chs($host) || P2Util::isHostMachiBbs($host)) &&
184    $_conf['p2_2ch_mail'] && $_conf['p2_2ch_pass'])
185{
186    $htm['p2res'] = '<input type="checkbox" id="p2res" name="p2res" value="1"'. $hd['p2res_checked'] . '>'
187                  . '<label for="p2res">����p2�ŏ�������</label>';
188}
189
190// }}}
191// {{{ �������݃u���b�N�p�`�F�b�N�{�b�N�X
192
193if (!$_conf['ktai']) {
194    $htm['block_submit'] = <<<EOP
195<input type="checkbox" id="block_submit" onclick="switchBlockSubmit(this.checked)"><label for="block_submit">block</label>
196EOP;
197}
198
199// }}}
200// {{{ �\�[�X�R�[�h�␳�p�`�F�b�N�{�b�N�X
201
202if (!$_conf['ktai']) {
203    if ($_conf['editor_srcfix'] == 1 || ($_conf['editor_srcfix'] == 2 && preg_match('/pc\\d+\\.2ch\\.net/', $host))) {
204        $htm['src_fix'] = <<<EOP
205<input type="checkbox" id="fix_source" name="fix_source" value="1"><label for="fix_source">src</label>
206EOP;
207    }
208}
209
210// }}}
211// {{{ �������݃v���r���[
212
213$htm['dpreview_onoff'] = '';
214$htm['dpreview_amona'] = '';
215$htm['dpreview']  = '';
216$htm['dpreview2'] = '';
217if (!$_conf['ktai'] && $_conf['expack.editor.dpreview']) {
218    $_dpreview_noname = 'null';
219    if (P2Util::isHost2chs($host)) {
220        $_dpreview_st = new SettingTxt($host, $bbs);
221        $_dpreview_st->setSettingArray();
222        if (!empty($_dpreview_st->setting_array['BBS_NONAME_NAME'])) {
223            $_dpreview_noname = $_dpreview_st->setting_array['BBS_NONAME_NAME'];
224            $_dpreview_noname = '"' . StrCtl::toJavaScript($_dpreview_noname) . '"';
225        }
226    }
227    $_dpreview_hide = 'false';
228    if ($_conf['expack.editor.dpreview'] == 2) {
229        if (P2Util::isBrowserSafariGroup() && basename($_SERVER['SCRIPT_NAME']) != 'post_form.php') {
230            $_dpreview_hide = 'true';
231        }
232        $_dpreview_pos = 'dpreview2';
233    } else {
234        $_dpreview_pos = 'dpreview';
235    }
236    $htm[$_dpreview_pos] = <<<EOP
237<script type="text/javascript" src="js/strutil.js?{$_conf['p2_version_id']}"></script>
238<script type="text/javascript" src="js/dpreview.js?{$_conf['p2_version_id']}"></script>
239<script type="text/javascript">
240//<![CDATA[
241var dpreview_use = true;
242var dpreview_on = false;
243var dpreview_hide = {$_dpreview_hide};
244var noname_name = {$_dpreview_noname};
245//]]>
246</script>
247<fieldset id="dpreview" style="display:none;">
248<legend>preview</legend>
249<div>
250    <span class="prvw_resnum">?</span>
251    �F<span class="prvw_name"><b id="dp_name"></b><span id="dp_trip"></span></span>
252    �F<span id="dp_mail" class="prvw_mail"></span>
253    �F<span class="prvw_dateid"><span id="dp_date"></span> ID:<span id="dp_id">???</span></span>
254</div>
255<div id="dp_msg" class="prvw_msg"></div>
256<!-- <div id="dp_empty" class="prvw_msg">(empty)</div> -->
257</fieldset>
258EOP;
259    $htm['dpreview_onoff'] = <<<EOP
260<input type="checkbox" id="dp_onoff" onclick="DPShowHide(this.checked)"><label for="dp_onoff">preview</label>
261EOP;
262    if ($_conf['expack.editor.dpreview_chkaa']) {
263        $htm['dpreview_amona'] = <<<EOP
264<input type="checkbox" id="dp_mona" disabled><label for="dp_mona">mona</label>
265EOP;
266    }
267}
268
269// }}}
270// {{{ �����Ƀ��X
271
272$htm['orig_msg'] = '';
273if ((basename($_SERVER['SCRIPT_NAME']) == 'post_form.php' || !empty($_GET['inyou'])) && !empty($_GET['resnum'])) {
274    $q_resnum = $_GET['resnum'];
275    $hd['MESSAGE'] = "&gt;&gt;" . $q_resnum . "\r\n";
276    if (!empty($_GET['inyou'])) {
277        $aThread = new ThreadRead;
278        $aThread->setThreadPathInfo($host, $bbs, $key);
279        $aThread->readDat($aThread->keydat);
280        $q_resar = $aThread->explodeDatLine($aThread->datlines[$q_resnum-1]);
281        $q_resar = array_map('trim', $q_resar);
282        $q_resar[3] = strip_tags($q_resar[3], '<br>');
283        if ($_GET['inyou'] == 1 || $_GET['inyou'] == 3) {
284            $hd['MESSAGE'] .= '&gt; ';
285            $hd['MESSAGE'] .= preg_replace('/\\s*<br>\\s*/',"\r\n&gt; ", $q_resar[3]);
286            $hd['MESSAGE'] .= "\r\n";
287        }
288        if ($_GET['inyou'] == 2 || $_GET['inyou'] == 3) {
289            if (!$_conf['ktai'] || $_conf['iphone']) {
290                $htm['orig_msg'] = <<<EOM
291<fieldset id="original_msg">
292<legend>Original Message:</legend>
293    <div>
294        <span class="prvw_resnum">{$q_resnum}</span>
295        �F<b class="prvw_name">{$q_resar[0]}</b>
296        �F<span class="prvw_mail">{$q_resar[1]}</span>
297        �F<span class="prvw_dateid">{$q_resar[2]}</span>
298    </div>
299    <div id="orig_msg" class="prvw_msg">{$q_resar[3]}</div>
300</fieldset>
301EOM;
302            } else {
303                $htm['orig_msg'] = <<<EOM
304<div><i>Original Message:</i>
305[{$q_resnum}]: <b>{$q_resar[0]}</b>: {$q_resar[1]}: {$q_resar[2]}<br>
306{$q_resar[3]}</div>
307EOM;
308            }
309        }
310    }
311}
312
313// }}}
314// {{{ �{�������̂Ƃ���sage�ĂȂ��Ƃ��ɑ��M���悤�Ƃ����ƒ��ӂ���
315
316$onsubmit_at = '';
317
318if (!$_conf['ktai']) {
319    if (!preg_match('{NetFront|AVE-?Front/}', $_SERVER['HTTP_USER_AGENT'])) {
320        $onsubmit_at = sprintf(' onsubmit="if (validateAll(%s,%s)) { switchBlockSubmit(true); return true; } else { return false }"',
321            (($_conf['expack.editor.check_message']) ? 'true' : 'false'),
322            (($_conf['expack.editor.check_sage'])    ? 'true' : 'false'));
323    }
324}
325
326// }}}
327
328/*
329 * Local Variables:
330 * mode: php
331 * coding: cp932
332 * tab-width: 4
333 * c-basic-offset: 4
334 * indent-tabs-mode: nil
335 * End:
336 */
337// vim: set syn=php fenc=cp932 ai et ts=4 sw=4 sts=4 fdm=marker: