'"'); # $add = strtr($post['tvote_add'],$trans_tbl); $hash=sprintf('%08x',crc32($add)); if (is_null($items[$add])) { $items[$add] = array(1,$add); $votedlist[$hash]=1; } else { if (!$votedlist[$hash]) { if ($items[$add][0]<0x7FFFFFFF) $items[$add][0]++; $votedlist[$hash]=1; } } } if (count($votedlist)>$votedlist_max) array_shift($votedlist); $new_value=@join(C_DELIM,array_keys($votedlist)); $_COOKIE['tvote_'.$post['refer'].'_'.$post['tvote_no']]=$new_value; if (_TVOTE_SORT) { // スコア降順ソート&キー昇順ソート //$cmpfunc = create_function('$a, $b', 'return ($a[0]==$b[0]?strcasecmp($a[1],$b[1]):$b[0]-$a[0]);'); $cmpfunc = function($a, $b) {return ($a[0]==$b[0]?strcasecmp($a[1],$b[1]):$b[0]-$a[0]);}; uasort($items,$cmpfunc); } foreach ($items as $key => $value) { $votes[] = '"'.$key.'['.$value[0].']"'; } // オプション($opt[$arg]) を $votesのあとに追加; $tvote_str = '#tvote('.@join(',',$votes).")\n"; $postdata_input = $tvote_str; $postdata .= $tvote_str; } if (_TVOTE_MD5_CHECK && (md5(@join('',get_source($post['refer']))) != $post['digest'])) { $title = $_title_collided; $s_refer = htmlsc($post['refer']); $s_digest = htmlsc($post['digest']); $s_postdata_input = htmlsc($postdata_input); $body = <<

EOD; } else { page_write($post['refer'],$postdata,$timestamp); $title = $_title_updated; } $retvars['msg'] = $title; $retvars['body'] = $body; $post['page'] = $post['refer']; $vars['page'] = $post['refer']; return $retvars; } function plugin_tvote_convert() { global $script,$vars,$digest; global $_vote_plugin_choice, $_vote_plugin_votes; static $numbers = array(); $style = 'padding-left:0.5em;padding-right:0.5em'; // $vars['tvote_info_'.$tvote_no] .= "debug"; // PukiWikiのバグ?対策 action時にページ名でなしで呼ばれる。 if (empty($vars['page'])) return ''; if (!array_key_exists($vars['page'],$numbers)) $numbers[$vars['page']] = 0; $tvote_no = $numbers[$vars['page']]++; $args = func_get_args(); $s_page = htmlsc($vars['page']); $s_digest = htmlsc($digest); $_votedlist=explode(C_DELIM, $_COOKIE['tvote_'.$s_page.'_'.$tvote_no]); foreach( $_votedlist as $key ) { if (preg_match("/^([\da-f]{8})$/i",$key,$match)) $votedlist[$match[1]]=1; } $view_count=_TVOTE_OPENCOUNT || ($votedlist) || (is_freeze($vars['page']) && _TVOTE_FREEZE_SYNC); if($view_count) { $votecount_head='得票数'; $votepercent_head='得票率'; } $body = <<
'; $tdcnt = 0; $pollcnt = 0; $itemlist=array(); foreach($args as $arg) { $cnt = 0; if (preg_match("/^(.+)\[([^\[]*)\]$/",$arg,$match)) { $arg = $match[1]; $cnt = intval($match[2]); if (!is_int($cnt) || $cnt<0) $cnt=0; $polltotal+=$cnt; //引数の先頭文字が+ならはオプションとして $opt[$arg]=$cnt; } $itemlist[$arg]=$cnt; } foreach($itemlist as $key => $cnt) { $e_arg = encode($key); # $trans_tbl = array ('"' => '"'); # $item = strtr($key,$trans_tbl); $trans_tbl = array_flip(get_html_translation_table(HTML_ENTITIES)); $item = strtr($key, $trans_tbl); $html = make_link($item); if ($polltotal != 0) $cntp=sprintf("%.1f",$cnt*100/$polltotal).'%'; else $cntp = 0 . "%"; if(!$view_count) { unset($cnt); unset($cntp); } $cls = ($tdcnt++ % 2) ? 'vote_td1' : 'vote_td2'; $body .= << '; } # 凍結判定 if(!(is_freeze($vars['page']) && _TVOTE_FREEZE_SYNC) && _TVOTE_ADD) { $cls = ($tdcnt++ % 2) ? 'vote_td1' : 'vote_td2'; $body .= << EOD; } if($view_count) { $cls = ($tdcnt++ % 2) ? 'vote_td1' : 'vote_td2'; $body .= << EOD; } $body .= '
$_vote_plugin_choice $votecount_head $votepercent_head EOD; if(!(is_freeze($vars['page']) && _TVOTE_FREEZE_SYNC)) $body .= $_vote_plugin_votes; $body .= '
$html $cnt $cntp EOD; $hash=sprintf('%08x',crc32($key)); $itemshash[$hash] = 1; // 凍結判定 if(!(is_freeze($vars['page']) && _TVOTE_FREEZE_SYNC)) { if (!$votedlist[$hash]) //投票してないならボタン表示 $body .= ""; else //投票済なら表示しない $body .= '投票済'; } //else $body .= '締切'; $body .= '
その他
投票総数 $polltotal
'; # クッキー掃除 if (!empty($votedlist)) { foreach( array_keys($votedlist) as $key ) if (!$itemshash[$key]) unset($votedlist[$key]); } # クッキーセット if (!empty($votedlist)) { $new_value=@join(C_DELIM,array_keys($votedlist)); setcookie('tvote_'.$s_page.'_'.$tvote_no,$new_value,time()+3600*24*_TVOTE_VALIDDAYS); } return $vars['tvote_info_'.$tvote_no].$body; } ?>