2 // $Id: vote.inc.php,v 1.12 2003/04/13 06:28:52 arino Exp $
4 function plugin_vote_init()
8 '_vote_plugin_choice' => 'ÁªÂò»è',
9 '_vote_plugin_votes' => 'Åêɼ',
13 '_vote_plugin_choice' => 'Selection',
14 '_vote_plugin_votes' => 'Vote',
16 set_plugin_messages($messages);
19 function plugin_vote_action()
21 global $post,$vars,$script,$cols,$rows;
22 global $_title_collided,$_msg_collided,$_title_updated;
23 global $_vote_plugin_choice, $_vote_plugin_votes;
25 $postdata_old = get_source($post['refer']);
27 $title = $body = $postdata = '';
29 foreach($postdata_old as $line) {
30 if (!preg_match("/^#vote\((.*)\)\s*$/",$line,$arg)) {
35 if ($vote_no++ != $post['vote_no']) {
39 $args = explode(',',$arg[1]);
41 foreach($args as $arg) {
43 if (preg_match("/^(.+)\[(\d+)\]$/",$arg,$match)) {
47 $e_arg = encode($arg);
48 if (!empty($post["vote_$e_arg"]) and $post["vote_$e_arg"] == $_vote_plugin_votes) {
52 $votes[] = $arg.'['.$cnt.']';
55 $vote_str = '#vote('.@join(',',$votes).")\n";
57 $postdata_input = $vote_str;
58 $postdata .= $vote_str;
61 if (md5(@join('',get_source($post['refer']))) != $post['digest']) {
62 $title = $_title_collided;
64 $s_refer = htmlspecialchars($post['refer']);
65 $s_digest = htmlspecialchars($post['digest']);
66 $s_postdata_input = htmlspecialchars($postdata_input);
69 <form action="$script?cmd=preview" method="post">
71 <input type="hidden" name="refer" value="$s_refer" />
72 <input type="hidden" name="digest" value="$s_digest" />
73 <textarea name="msg" rows="$rows" cols="$cols" id="textarea">$s_postdata_input</textarea><br />
81 page_write($post['refer'],$postdata);
83 $title = $_title_updated;
86 $retvars['msg'] = $title;
87 $retvars['body'] = $body;
89 $post['page'] = $post['refer'];
90 $vars['page'] = $post['refer'];
94 function plugin_vote_convert()
96 global $script,$vars,$digest;
97 global $_vote_plugin_choice, $_vote_plugin_votes;
98 static $numbers = array();
100 if (!array_key_exists($vars['page'],$numbers))
102 $numbers[$vars['page']] = 0;
104 $vote_no = $numbers[$vars['page']]++;
106 if (!func_num_args()) {
110 $args = func_get_args();
111 $s_page = htmlspecialchars($vars['page']);
112 $s_digest = htmlspecialchars($digest);
115 <form action="$script" method="post">
116 <table cellspacing="0" cellpadding="2" class="style_table" summary="vote">
118 <td align="left" class="vote_label" style="padding-left:1em;padding-right:1em"><strong>$_vote_plugin_choice</strong>
119 <input type="hidden" name="plugin" value="vote" />
120 <input type="hidden" name="refer" value="$s_page" />
121 <input type="hidden" name="vote_no" value="$vote_no" />
122 <input type="hidden" name="digest" value="$s_digest" />
124 <td align="center" class="vote_label"><strong>$_vote_plugin_votes</strong></td>
130 foreach($args as $arg) {
133 if (preg_match("/^(.+)\[(\d+)\]$/",$arg,$match)) {
137 $e_arg = encode($arg);
139 $link = make_link($arg);
141 $cls = ($tdcnt++ % 2) ? 'vote_td1' : 'vote_td2';
145 <td align="left" class="$cls" style="padding-left:1em;padding-right:1em;">$link</td>
146 <td align="right" class="$cls">$cnt
147 <input type="submit" name="vote_$e_arg" value="$_vote_plugin_votes" class="submit" />