function do_action() { if(front::post('submit') &&front::post('vote') &&front::post('aid')) { front::check_type(front::post('aid')); if(!isset($this->view->user)) front::flash(lang('请登陆!')); $vote=new vote(); $_vote=$vote->getrow('aid='.front::post('aid')); if(eregi($this->view->user['username'].',',$_vote['users'])) { front::flash(lang('不能重复投票!')); front::redirect(front::$from); } $_votes=$_vote['votes']; if(!$_votes) $_votes=array(); else $_votes=unserialize($_votes); $_votes[front::post('vote')]=$_votes[front::post('vote')]+1; $votes=serialize($_votes); $vote_data=array_merge($_vote,array('votes'=>$votes,'aid'=>front::post('aid'),'users'=>$_vote['users'].$this->view->user['username'].',')); $vote->rec_replace($vote_data,front::post('aid')); front::flash(lang('投票成功!')); }else { front::flash(lang('投票失败!')); } front::redirect(front::$from); }
<?php /** * 投票接口 * @param $question_id int 投票ID * @param $single_total string 3,4,5 * @param $verify_code string 验证码 * @param $other_title string 用户提交过来的其他选项 * */ define('M2O_ROOT_PATH', './'); require M2O_ROOT_PATH . 'global.php'; include M2O_ROOT_PATH . 'lib/class/vote.class.php'; $obj = new vote(); //投票选项处理 投票接口需要索引下标的数组 $_REQUEST['single_total'] = is_array($_REQUEST['single_total']) ? $_REQUEST['single_total'] : explode(',', $_REQUEST['single_total']); if (is_array($_REQUEST['single_total']) && count($_REQUEST['single_total']) > 0 && $_REQUEST['single_total'][0]) { $tmp_array = array(); foreach ($_REQUEST['single_total'] as $k => $v) { $tmp_array[$v] = $v; } $_REQUEST['single_total'] = $tmp_array; } else { $_REQUEST['single_total'] = array(); } $ret = $obj->submitVote(); $ret = is_array($ret) ? $ret[0] : array(); //echo json_encode($ret);exit; if ($ret) { $message = '投票成功'; $success = 1;
<?php if (!defined("B_PROLOG_INCLUDED") || B_PROLOG_INCLUDED !== true) { die; } if (!CModule::IncludeModule("vote")) { return; } include_once $_SERVER["DOCUMENT_ROOT"] . "/bitrix/modules/vote/install/index.php"; $vote = new vote(); $vote->InstallUserFields();
public static function ajaxVoterTweet($request, $context) { try { // On cherche le tweet $tweet = tweetTable::getTweetById($request["id"]); if (is_null($tweet)) { throw new Exception("Erreur pour voter un tweet. Le tweet n'existe pas."); } // On ajoute la relation avant de continuer $dataVote = array("message" => $tweet->id, "utilisateur" => context::getSessionAttribute("utilisateur")->id); $vote = new vote($dataVote); if (is_null($vote->save())) { throw new Exception("Il y a eu une erreur pour enregistrer le vote."); } // S'il ny a pas de soucis, on actualise le tweet $tweet->nbvotes++; if (is_null($tweet->save())) { throw new Exception("Il y a eu une erreur pour actualiser le nombre de votes."); } // On affiche la nouvelle quantité de votes context::setSessionAttribute("tweetTemplate", $tweet); context::setSessionAttribute("succes", "On a bien enregistré ton vote"); return context::SUCCESS; } catch (Exception $e) { context::setSessionAttribute("erreur", $e); return context::ERROR; } }
public static function vote($request, $context) { //print_r($request); if (!empty($request['idtweet']) && $context->getSessionAttribute('is_logged') == 1) { $voteInfo['message'] = $request['idtweet']; $voteInfo['utilisateur'] = $_SESSION['id']; $vote = new vote($voteInfo); $vote->save(); $tweetInfo['id'] = $request['idtweet']; $nbVotes = vote::getVote($request['idtweet']); //print_r($nbVotes); $tweetInfo['nbVotes'] = $nbVotes[0]['count']; $tweet = new tweet($tweetInfo); $tweet->save(); context::redirect(history . back()); return context::SUCCESS; } return context::ERROR; }
<?php $ip = router::ip(); $ipvote = new vote($ip); if ($ipvote->found()) { $msg = '[previousvote] ' . $ipvote->country->name . ' (' . gmdate('H:i', cron::timeUntil('clearvotes')) . ' [timetovote])'; } else { if (isset($uri[0])) { $votecountry = new country(intval($uri[0])); if ($votecountry->found() && $votecountry->state == country::voteable()->state) { new vote(['ip' => $ip, 'country#' => $votecountry->id]); $votecountry->add('votes', 1); $votecountry->update(); $msg = '[newvote] ' . $votecountry->name; } else { $msg = '[invalidvote]'; } } } ?> <script src="http://code.jquery.com/jquery-1.10.2.min.js" type="text/javascript"></script> <?php $state = null; $country = country::voteable(); $imgs = []; while ($country->found()) { $state = $country->state; $img = '/style/images/bg' . $country->id . '.jpg'; if (file_exists(root . $img)) { $imgs[] = "'" . $img . "'"; }
<?php require_once 'voteClass.php'; if ($spell_checked == "vote") { $vote = new vote(); $output = $vote->getQues(); var_dump($output); $total_return = $output['ques']; $id = $output['id']; for ($i = 1; $i < 5; $i++) { if ($output['opt' . $i] != "") { $options_list[] = $output['opt' . $i]; $list[] = array("content" => "__vote__" . $id . "__" . $output['opt' . $i] . "__"); } } var_dump($options); var_dump($list); } elseif (preg_match("~__vote__(.+)__(.+)__~", $req, $match)) { $id = $match[1]; $optname = $match[2]; $vote = new Vote(); $out = $vote->getCount($id); $out = $out['count']; $out = json_decode($out, TRUE); foreach ($out as $opt->{$count}) { if ($optname == $opt) { $count++; break; } } var_dump($out);
<?php defined('IN_DESTOON') or exit('Access Denied'); require DT_ROOT . '/module/' . $module . '/common.inc.php'; $MOD['vote_enable'] or dheader(DT_PATH); $TYPE = get_type('vote', 1); require MD_ROOT . '/vote.class.php'; $do = new vote(); $typeid = isset($typeid) ? intval($typeid) : 0; if ($itemid) { $do->itemid = $itemid; $item = $do->get_one(); $item or dheader(DT_PATH); extract($item); if ($submit) { $could_vote = true; $condition = $_username ? "AND username='******'" : "AND ip='{$DT_IP}'"; $r = $db->get_one("SELECT rid FROM {$DT_PRE}vote_record WHERE itemid={$itemid} {$condition}"); if ($r) { $could_vote = false; } if ($fromtime && $DT_TIME < $fromtime) { $could_vote = false; } if ($totime && $DT_TIME > $totime) { $could_vote = false; } if (!check_group($_groupid, $MOD['vote_group'])) { $could_vote = false; } if ($could_vote) {
if (vote::img($aid, $i)) { ?> <img src="<?php echo vote::img($aid, $i); ?> " /> <?php } ?> <div class=optionbar><div style="width: <?php echo vote::get($aid, $i) * 3 + 5; ?> px;"></div></div> <?php echo vote::get($aid, $i); ?> <div class="clear"> </div> </li> <?php $i++; } unset($i); ?> </ul> <?php } ?>
<?php defined('IN_DESTOON') or exit('Access Denied'); $TYPE = get_type('vote', 1); require MD_ROOT . '/vote.class.php'; $do = new vote(); $menus = array(array('添加投票', '?moduleid=' . $moduleid . '&file=' . $file . '&action=add'), array('投票列表', '?moduleid=' . $moduleid . '&file=' . $file), array('更新地址', '?moduleid=' . $moduleid . '&file=' . $file . '&action=update'), array('生成投票', '?moduleid=' . $moduleid . '&file=' . $file . '&action=html'), array('投票分类', 'javascript:Dwidget(\'?file=type&item=' . $file . '\', \'投票分类\');'), array('模块设置', '?moduleid=' . $moduleid . '&file=setting#' . $file)); if ($_catids || $_areaids) { require DT_ROOT . '/admin/admin_check.inc.php'; } switch ($action) { case 'add': if ($submit) { if ($do->pass($post)) { $do->add($post); dmsg('添加成功', $forward); } else { msg($do->errmsg); } } else { foreach ($do->fields as $v) { isset(${$v}) or ${$v} = ''; } $vote_min = 1; $vote_max = 3; $addtime = timetodate($DT_TIME); $menuid = 0; include tpl('vote_edit', $module); } break; case 'edit':
<?php /** * 根据投票id取投票内容; * */ define('M2O_ROOT_PATH', './'); require M2O_ROOT_PATH . 'global.php'; $id = intval($_REQUEST['id']); $dReturn = intval($_REQUEST['d_return']); if ($id) { include M2O_ROOT_PATH . 'lib/class/vote.class.php'; $obj = new vote(); $vote = $obj->singleQuestionConti($id); // echo "<pre>"; // print_r($vote); // echo "</pre>";exit; if ($dReturn) { echo json_encode($vote); exit; } $options = $vote['option_title']; //投票结果 $html = '<ul class="vt_ul">'; $i = 0; if (is_array($options) && count($options) > 0) { foreach ($options as $kk => $vv) { $i++; $precent = @round($vv['ini_single'] / $vote['question_total_ini'] * 100, 1); $rand = rand(1, 10); $html .= '<li class="vote-item-' . $vv['id'] . '"><div class="vote-option-li">' . $vv['title'] . ':</div> <div class="vote-option-outer-box"><div class="vote-option-inner-box vote-option-color' . $rand . '" style="width:' . $precent . '%;"></div></div> <div class="vote-option-text-box">(' . $precent . '%)<span>' . $vv['ini_single'] . ' 票</span></div></li>'; }
<?php /* * To change this license header, choose License Headers in Project Properties. * To change this template file, choose Tools | Templates * and open the template in the editor. */ $v = new vote(); $v->vote('', 1, 'asd'); /** * Description of vote * * @author changdi */ class vote { //put your code here const ONE_WEEK_IN_SECONDS = 7 * 86400; const VOTE_SCORE = 432; public function vote($conn, $user, $item) { $cutoff = time() - self::ONE_WEEK_IN_SECONDS; } }
@extends('layouts.master') @section('content') <div class="col-md-6"> <?php $index = 1; $redo = $data[3]; $vote_id = Session::get('vote_id'); $vote = vote::where('id', '=', $vote_id)->get(); ?> @if ($redo == 1) 以下為舊的籤票內容 <a href="{{ url('/account_redo_true', array($vote_id), false) }}"><strong>確定重做籤票共{{$vote[0]->vote_amount}}張</strong></a><br> @endif 籤票共 {{count($data[0])}} 張 <table class="table table-bordered col-md-12"> <tr> @foreach ($data[0] as $index =>$account) <td class="col-md-4"> <h4>
private function vote_column($id, $column_id) { include_once ROOT_PATH . 'lib/class/vote.class.php'; $voteApi = new vote(); return $voteApi->update_column($id, $column_id); }
图片url </td> <td width="1%"> </td> <td width="70%"> <?php echo form::input("vote[{$i}]", vote::title(@$data['aid'], $i), 'class="input" '); ?> <span class="hotspot" onmouseover="tooltip.show('填写内容中投票内容名称!');" onmouseout="tooltip.hide();"> <img src="<?php echo $skin_path; ?> /images/remind.gif" alt="" width="14" height="20" style="margin-left:10px; margin-right:5px;"> </span> <div class="blank5"></div> <?php echo form::input("vote_image[{$i}]", vote::img(@$data['aid'], $i), 'class="input" '); ?> <span class="hotspot" onmouseover="tooltip.show('填写内容中投票内容图片地址!');" onmouseout="tooltip.hide();"> <img src="<?php echo $skin_path; ?> /images/remind.gif" alt="" width="14" height="20" style="margin-left:10px; margin-right:5px;"> </span> </td> </tr> <tr><td colspan="4" height="10"> </td></tr> <?php } ?> </table> </td>
function clearvotes($time) { vote::clear(); }
public static function getInstance() { if (!self::$me) { $class=new vote(); self::$me=$class; } return self::$me; }
} private function special_detail($id) { include_once ROOT_PATH . 'lib/class/special.class.php'; $specialApi = new special(); $special_info = $specialApi->detail($id); if (!$special_info['id']) { return false; } return $special_info; } /** * * @Description 获取投票详情 * @author Kin * @date 2014-2-26 上午11:15:00
function save_after($aid) { //$tag=preg_replace('/\s+/',' ',trim(front::$post['tag'])); $tags=explode(',',trim(front::$post['tag'])); //var_dump($tags); $tag_table=new tag(); $arctag_table=new arctag(); foreach($tags as $tag) { if($tag) if(!$tag_table->getrow('tagname="'.$tag.'"')) $tag_table->rec_insert(array('tagname'=>$tag)); $tag=$tag_table->getrow('tagname="'.$tag.'"'); $arctag_table->rec_replace(array('aid'=>$aid,'tagid'=>$tag['tagid'])); } //exit; $doit = false; if(session::get('attachment_id') ||front::post('attachment_id')) { $attachment_id=session::get('attachment_id')?session::get('attachment_id'):front::post('attachment_id'); $attachment=new attachment(); $attachment->rec_update(array('aid'=>$aid,'intro'=>front::post('attachment_intro')),$attachment_id); $doit = true; if(session::get('attachment_id')) session::del('attachment_id'); } if(front::post('attachment_path') != '' && $doit == false) { $attachment=new attachment(); $attachment->rec_insert(array('aid'=>$aid,'path'=>front::post('attachment_path'),'intro'=>front::post('attachment_intro'),'adddate'=>date('Y-m-d H:i:s'))); $doit = false; } if(front::post('_ranks')) { $_ranks=serialize(front::post('_ranks')); $rank=new rank(); if(is_array($rank->getrow(array('aid'=>$aid)))) $rank->rec_update(array('ranks'=>$_ranks),'aid='.$aid); else $rank->rec_insert(array('aid'=>$aid,'ranks'=>$_ranks)); } else { $rank=new rank(); $rank->rec_delete('aid='.$aid); } if(front::post('vote')) { $votes=front::$post['vote']; $images=front::$post['vote_image']; $vote=new vote(); $_vote=$vote->getrow('aid='.$aid); if(!$_vote) $_vote=array('aid'=>$aid); $_vote['titles']=serialize($votes); $_vote['images']=serialize($images); $vote->rec_replace($_vote,$aid); } }
<?php require 'LikeClass.php'; require '../core/Database/Database.php'; if ($_SERVER['REQUEST_METHOD'] != 'POST') { $http_response_code(403); die; } $pdo = new PDO("mysql:dbname=marmiton;host=localhost", 'root', ''); $pdo->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION); $vote = new vote($pdo); if ($_GET['vote'] == 1) { $vote->like($_GET['recette_id'], $_SERVER["REMOTE_ADDR"]); } else { $vote->dislike($_GET['recette_id'], $_SERVER["REMOTE_ADDR"]); } $vote->updateCount($_GET['recette_id']); header('Location: index.php?page=recipe&id=' . $_GET['recette_id']);