2 /////////////////////////////////////////////////
3 // PukiWiki - Yet another WikiWikiWeb clone.
5 // $Id: vote.inc.php,v 1.16 2004/07/31 03:09:20 henoheno Exp $
8 function plugin_vote_action()
10 global $vars, $script, $cols,$rows;
11 global $_title_collided, $_msg_collided, $_title_updated;
12 global $_vote_plugin_choice, $_vote_plugin_votes;
14 $postdata_old = get_source($vars['refer']);
16 $title = $body = $postdata = '';
18 foreach($postdata_old as $line)
20 if (! preg_match("/^#vote\((.*)\)\s*$/", $line, $arg))
26 if ($vote_no++ != $vars['vote_no'])
31 $args = explode(',', $arg[1]);
34 foreach($args as $arg)
37 if (preg_match("/^(.+)\[(\d+)\]$/", $arg, $match))
42 $e_arg = encode($arg);
43 if (! empty($vars["vote_$e_arg"]) and $vars["vote_$e_arg"] == $_vote_plugin_votes)
48 $votes[] = $arg . '[' . $cnt . ']';
51 $vote_str = '#vote(' . @join(',', $votes) . ")\n";
53 $postdata_input = $vote_str;
54 $postdata .= $vote_str;
57 if (md5(@join('', get_source($vars['refer']))) != $vars['digest'])
59 $title = $_title_collided;
61 $s_refer = htmlspecialchars($vars['refer']);
62 $s_digest = htmlspecialchars($vars['digest']);
63 $s_postdata_input = htmlspecialchars($postdata_input);
66 <form action="$script?cmd=preview" method="post">
68 <input type="hidden" name="refer" value="$s_refer" />
69 <input type="hidden" name="digest" value="$s_digest" />
70 <textarea name="msg" rows="$rows" cols="$cols" id="textarea">$s_postdata_input</textarea><br />
78 page_write($vars['refer'], $postdata);
80 $title = $_title_updated;
83 $retvars['msg'] = $title;
84 $retvars['body'] = $body;
86 $vars['page'] = $vars['refer'];
91 function plugin_vote_convert()
93 global $script, $vars, $digest;
94 global $_vote_plugin_choice, $_vote_plugin_votes;
95 static $numbers = array();
97 if (! isset($numbers[$vars['page']]))
99 $numbers[$vars['page']] = 0;
101 $vote_no = $numbers[$vars['page']]++;
103 if (!func_num_args())
108 $args = func_get_args();
109 $s_page = htmlspecialchars($vars['page']);
110 $s_digest = htmlspecialchars($digest);
113 <form action="$script" method="post">
114 <table cellspacing="0" cellpadding="2" class="style_table" summary="vote">
116 <td align="left" class="vote_label" style="padding-left:1em;padding-right:1em"><strong>$_vote_plugin_choice</strong>
117 <input type="hidden" name="plugin" value="vote" />
118 <input type="hidden" name="refer" value="$s_page" />
119 <input type="hidden" name="vote_no" value="$vote_no" />
120 <input type="hidden" name="digest" value="$s_digest" />
122 <td align="center" class="vote_label"><strong>$_vote_plugin_votes</strong></td>
129 foreach($args as $arg)
133 if (preg_match("/^(.+)\[(\d+)\]$/", $arg, $match))
138 $e_arg = encode($arg);
140 $link = make_link($arg);
142 $cls = ($tdcnt++ % 2) ? 'vote_td1' : 'vote_td2';
146 <td align="left" class="$cls" style="padding-left:1em;padding-right:1em;">$link</td>
147 <td align="right" class="$cls">$cnt
148 <input type="submit" name="vote_$e_arg" value="$_vote_plugin_votes" class="submit" />