کلاس نمایش نظرسنجی (بخاطر قولی که داده بودم) :
<?php
class Poll
{
function __construct()
{
$this->db = getDataBaseConnect( __ROOT_INC__ , 'qartal' );
$this->setLanguage(0);
}
function setParam( $id , $page , $style )
{
$this->id = $id;
$this->page = $page;
$this->styleType = $style;
}
function getAds()
{
$this->_ads = '';
}
function selectQuery()
{
$Query = 'SELECT * FROM tools_polls LEFT JOIN tools_pollanswers ON (tools_polls.PollID=tools_pollanswers.PollID) WHERE tools_polls.PollID='.$this->id.' ORDER By PollAnswerListing ASC';
$pollQuery = $this->db->prepare( $Query );
$pollQuery->execute();
$this->pRows = $pollQuery->rowCount();
$this->pInfo = $pollQuery->fetchAll( PDO::FETCH_ASSOC );
}
function getExist()
{
if( isset( $this->pInfo ) && $this->pRows > 1 )
{
$this->_showStatus = array( 1 );
}
else
{
$this->_showStatus = array( 0 , 'نظرسنجی پیدا نشد!' );
}
}
function setLanguage( $default = 0 )
{
if( isset( $this->pInfo[0]['Language'] ) )
{
$_language = $this->pInfo[0]['Language'] ;
}
else
{
$_language = $default ;
}
if( $_language == 0 )
{
$this->__lan__msg_deny = 'دسترسی غیر مجاز!' ;
$this->__lan__msg_unactive = 'نظرسنجی غیر فعال است!' ;
$this->__lan__msg_block = 'نظرسنجی مسدود شده است!' ;
$this->__lan__msg_errorStartTime = 'رای گیری شروع نشده است!' ;
$this->__lan__msg_errorEndTime = 'مدت زمان رای گیری به پایان رسیده است!' ;
$this->__lan__pollTitle = 'نظرسنجی' ;
$this->__lan__resultLinkTitle = 'نمایش کامل نتیجه' ;
$this->__lan__question = 'سوال' ;
$this->__lan__msg_submitVote = 'در حال ثبت رای ...' ;
$this->__lan__msg_voted = 'شما قبلاً در رای گیری شرکت کرده اید.' ;
$this->__lan__msg_thankYou = 'با تشکر از اینکه در رای گیری شرکت نمودید.' ;
$this->__lan__msg_totalVote = 'مجموع آرا' ;
$this->__lan__msg_vote = 'رای' ;
$this->__lan__msg_chooseAnswer = 'لطفاً گزینه ای را انتخاب نمایید.' ;
$this->__lan__direction = 'rtl' ;
$this->__lan__direction_r = 'ltr' ;
$this->__lan__align = 'right' ;
$this->__lan__align_r = 'left' ;
$this->__lan__pageTitle = 'قارتال آنلاین - ' ;
$this->__lan__qartalonline = 'قارتال آنلاین' ;
$this->__lan__creatPollTitle = 'نظرسنجی جدید بسازید' ;
$this->__lan__msg_privateResult = 'نتیجه رای گیری خصوصی است!' ;
$this->__lan__pollResult = 'نتیجه نظرسنجی' ;
$this->__lan__createdDate = 'تاریخ ایجاد' ;
$this->__lan__startDate = 'تاریخ شروع' ;
$this->__lan__endDate = 'تاریخ پایان' ;
$this->__lan__url = 'آدرس' ;
$this->__lan__msg_error = 'خطا' ;
$this->__lan__msg_checkError = 'لطفاً به صفحه قبل بازگشته و گزینه ای را انتخاب نمایید.' ;
}
elseif( $_language == 1 )
{
$this->__lan__msg_deny = 'Access is denied!' ;
$this->__lan__msg_unactive = 'The poll is inactive!' ;
$this->__lan__msg_block = 'The poll is blocked!' ;
$this->__lan__msg_errorStartTime = 'Voting has not started!' ;
$this->__lan__msg_errorEndTime = 'Voting has ended!' ;
$this->__lan__pollTitle = 'Poll' ;
$this->__lan__resultLinkTitle = 'View result' ;
$this->__lan__question = 'Question' ;
$this->__lan__msg_submitVote = 'vote ...' ;
$this->__lan__msg_voted = 'Duplicate vote.' ;
$this->__lan__msg_thankYou = 'Thank you for voting.' ;
$this->__lan__msg_totalVote = 'Total Votes' ;
$this->__lan__msg_vote = 'votes' ;
$this->__lan__msg_chooseAnswer = 'Please choose one option in order to vote.' ;
$this->__lan__direction = 'ltr' ;
$this->__lan__direction_r = 'rtl' ;
$this->__lan__align = 'left' ;
$this->__lan__align_r = 'right' ;
$this->__lan__pageTitle = 'QartalOnline - ' ;
$this->__lan__qartalonline = 'QartalOnline' ;
$this->__lan__creatPollTitle = 'Create poll' ;
$this->__lan__msg_privateResult = 'The poll result is private.' ;
$this->__lan__pollResult = 'Poll result' ;
$this->__lan__createdDate = 'Creation date' ;
$this->__lan__startDate = 'Start date' ;
$this->__lan__endDate = 'end date' ;
$this->__lan__url = 'Url' ;
$this->__lan__msg_error = 'error' ;
$this->__lan__msg_checkError = 'Please choose one option in order to vote.' ;
}
}
function getIpCheck()
{
if( $this->pInfo[0]['IPAllow'] != '' )
{
$this->getIpAllow();
}
elseif( $this->pInfo[0]['IPDeny'] != '' )
{
$this->getIpDeny();
}
}
function getIpDeny()
{
$_userIp = ip2long( getIp() ) ;
$_denyStatus = 0 ;
foreach( explode( '|' , $this->pInfo[0]['IPDeny'] ) as $_ipDeny )
{
if( strpos( $_ipDeny , '-' ) )
{
list( $_ipDeny_start , $_ipDeny_end ) = explode( '-' , $_ipDeny ) ;
if( $_userIp > ip2long( $_ipDeny_start ) && $_userIp < ip2long( $_ipDeny_end ) )
{
$_denyStatus = 1 ;
break ;
}
}
else
{
if( $_userIp == ip2long( $_ipDeny ) )
{
$_denyStatus = 1 ;
break ;
}
}
}
if( $_denyStatus == 1 )
{
$this->_showStatus = array( 0 , $this->__lan__msg_deny );
}
}
function getIpAllow()
{
$_userIp = ip2long( getIp() ) ;
$_allowStatus = 0 ;
foreach( explode( '|' , $this->pInfo[0]['IPDeny'] ) as $_ipAllow )
{
if( strpos( $_ipAllow , '-' ) )
{
list( $_ipAllow_start , $_ipAllow_end ) = explode( '-' , $_ipAllow ) ;
if( $_userIp < ip2long( $_ipAllow_start ) || $_userIp > ip2long( $_ipAllow_end ) )
{
$_allowStatus = 1 ;
break ;
}
}
else
{
if( $_userIp != ip2long( $_ipAllow ) )
{
$_allowStatus = 1 ;
break ;
}
}
}
if( $_allowStatus == 1 )
{
$this->_showStatus = array( 0 , $this->__lan__msg_deny );
}
}
function getStatusCheck()
{
if( $this->pInfo[0]['Status'] == 0 )
{
$this->_showStatus = array( 0 , $this->__lan__msg_unactive );
}
elseif( $this->pInfo[0]['Status'] == 2 )
{
$this->_showStatus = array( 0 , $this->__lan__msg_block );
}
}
function getDateCheck()
{
if( $this->pInfo[0]['StartDate'] == 0 || $this->pInfo[0]['StartDate'] <= date('Ymd') )
{
if( $this->pInfo[0]['EndDate'] != 0 && $this->pInfo[0]['EndDate'] <= date('Ymd') )
{
$this->_showStatus = array( 0 , $this->__lan__msg_errorEndTime );
}
}
else
{
$this->_showStatus = array( 0 , $this->__lan__msg_errorStartTime );
}
}
function getPoll()
{
if( isset( $this->pInfo[0]['Title'] ) && $this->pInfo[0]['Title'] != '' )
{
$_title = getCleanOut( $this->pInfo[0]['Title'] , '11000000' );
}
else
{
$_title = $this->__lan__pollTitle ;
}
$_submit = '<div id="submit"><input type="submit" name="submit" id="pollsubmit" value="'.getCleanOut( $this->pInfo[0]['ButtonText'] , '11000000' ).'"></div>';
if( isset( $this->pInfo[0]['Results'] ) && $this->pInfo[0]['Results'] == '1' )
{
$_result = '<div id="result"><a href="/poll/result/'.$this->id.'/" target="_blank">['.$this->__lan__resultLinkTitle.']</a></div>';
}
else
{
$_result = '';
}
$_status='<div id="status"></div>';
if( $this->styleType == 0 )
{
$_question = '<div id="question"><span>'.$this->__lan__question.' : </span>'.getCleanOut( $this->pInfo[0]['Question'] , '11000000' ).'</div>';
}
else
{
$_question = '<div id="question">'.getCleanOut( $this->pInfo[0]['Question'] , '11000000' ).'</div>';
}
$_answer = '';
$keywords = '';
foreach($this->pInfo as $PI)
{
if($PI['PollAnswerValue']!='')
{
$_answer .= '<div id="answer'.$PI['PollAnswerListing'].'" class="answer"><div class="atop"><input type="radio" name="pa" id="pa'.$PI['PollAnswerListing'].'" value="'.$PI['PollAnswerID'].'"><label for="pa'.$PI['PollAnswerListing'].'">'.getCleanOut( $PI['PollAnswerValue'] , '11000000' ).'</label><span></span></div><div class="abottom"><div id="chart'.$PI['PollAnswerListing'].'" class="chart"></div></div></div>';
$keywords .= ','.str_replace( ' ' , ',' , $PI['PollAnswerValue'] );
}
}
$_answer = '<div id="answer">'.$_answer.'</div>';
$this->_keywords = $keywords .','.str_replace( ' ' , ',' , $this->pInfo[0]['Question'] ) ;
$this->_description = $this->pInfo[0]['Question'] ;
$_postParam='<input type="hidden" name="id" value="'.$this->id.'"><input type="hidden" name="type" value="'.$this->styleType.'"><input type="hidden" name="lan" value="'.$this->pInfo[0]['Language'].'">';
$this->_htmlCode = '<form onSubmit="return getResult();" action="/poll/post" method="post" target="_blank">'.$_question.$_answer.$_postParam. $_status.$_submit.$_result.'</form>';
$this->setTemp($_title);
}
function setStyle()
{
if( $this->styleType == 0 )
{
if( isset( $this->__lan__direction ) && $this->__lan__direction == 'ltr' )
{
$this->style = '<link href="/poll/file/css/style_ltr.css" rel="stylesheet" type="text/css" media="all">';
}
else
{
$this->style = '<link href="/poll/file/css/style.css" rel="stylesheet" type="text/css" media="all">';
}
}
else
{
if( isset( $this->pInfo[0]['CSS'] ) && $this->pInfo[0]['CSS'] != '' )
{
$symbol=array( '@<style[^>]*?>.*?</style>@siU' ,
'@<script[^>]*?>.*?</script>@si' ,
'@<\?php.*?\?>@siU' ,
'@<[\/\!]*?[^<>]*?>@si' ,
'@<![\s\S]*?--[ \t\n\r]*>@' ,
'/<.*?>/' );
$css = getCleanOut( getClean( preg_replace( $symbol , '' , $this->pInfo[0]['CSS'] ) , '1110000000' , '' ) , '1000110000' , "\t" );
$this->style = '<style type="text/css">'.$css.'</style>';
}
else
{
list( $background , $question , $answer ) = explode( '-' , $this->pInfo[0]['Style'] ) ;
$this->style = '<style type="text/css">@charset "utf-8";*{margin:0;padding:0;outline:0;font-family:Tahoma;}div{margin:auto;}a{text-decoration:none;cursor:pointer;direction:'.$this->__lan__direction.';}body{background:#'.$backgroun d.';font-size:12px;margin:0 auto;padding:1px;}.clear{float:none;clear:both;}#e rror{text-align:center;margin:50px auto;}#poll{text-align:'.$this->__lan__align.';direction:'.$this->__lan__direction.';}#question{color:#'.$question. ';font-weight:bold;}#question span{color:#F00;}#answer{padding:10px 0;color:#'.$answer.';text-align:'.$this->__lan__align.';}.answer{display:block;padding:1px ;text-align:'.$this->__lan__align.';}.answer input{vertical-align:middle;}.answer label{padding-'.$this->__lan__align.':3px;vertical-align:middle;direction:'.$this->__lan__direction.';}.answer span{font-size:10px;color:#888;}.atop{display:block;}.abotto m{width:100%;display:block;height:7px;float:none;c lear:both;}.chart{float:'.$this->__lan__align.';overflow:hidden;background-color:#039;height:4px;margin:3px;margin-bottom:0;-webkit-border-radius:4px;-moz-border-radius:4px;border-radius:4px;}#status{height:20px;font-size:11px;}.loader{background:url(/poll/file/image/loader.gif) no-repeat '.$this->__lan__align.';height:16px;padding-'.$this->__lan__align.':18px;color:#666;}.accept{color:#09 4;}.error{color:#F00;}#result{text-align:center;padding-bottom:5px;}#result a{color:#555;font-size:11px;}#submit{padding:5px 0;color:#000;text-align:center;}input[type=\'submit\']{color:#333;padding:4px 8px;margin:auto 5px;cursor:pointer;border:#CCC solid 1px;-webkit-border-radius:2px;-moz-border-radius:2px;border-radius:2px;background:#F3F3F3;}input[type=\'submit\']:hover,input[type=\'submit\']:focus{border-color:#999;-webkit-box-shadow:0 0 1px 0 #999;-moz-box-shadow:0 0 1px 0 #999;box-shadow:0 0 1px 0 #999;}input[type="submit"][disabled]{color:#999;border-color:#CCC;-webkit-box-shadow:none;-moz-box-shadow:none;box-shadow:none;}input[type="submit"][disabled]:hover{cursor:default;}</style>';
}
}
}
function setJS()
{
if( $this->page == 'poll' )
{
$this->js = '<script src="http://file.qartalonline.com/js/jquery/jquery-1.3.2.min.js"></script><script>function getResult(){var av=$(\'input:radio[name=pa]:checked\').val();var pi=$(\'input:hidden[name=id]\').val();if ($(\'input:radio[name=pa]:checked\').length){$(\'#status\').html(\'<div class="loader">'.$this->__lan__msg_submitVote.'</div>\');$.ajax({type:\'POST\',url:\'/poll/post\',data:{pa:av,id:pi,type:\'1\',lan:\''.$this->pInfo[0]['Language'].'\'},success:function(m){for(i=1;i<=15;i++){$(\'# pa\'+i).attr(\'disabled\',\'disabled\');}$(\'#poll submit\').attr(\'disabled\',\'disabled\');if(m==\' voted\'){$(\'#status\').html(\'<div class="error">'.$this->__lan__msg_voted.'</div>\').fadeIn(\'slow\');}else if(m==\'VoteWereRecorded\'){$(\'#status\').html(\' <div class="accept">'.$this->__lan__msg_thankYou.'</div>\').fadeIn(\'slow\');}else{var sr=(m).split(\'-\');var na=sr.length;var tp=sr[0];for(i=1;i<na;i++){var sa=(sr[i]).split(\'|\');var ai=(sa[0]);var ap=(sa[1]);var ac=(sa[2]);var pp=(100*ap/tp);$(\'#chart\'+ai).css(\'background-color\',ac);$(\'#chart\'+ai).animate({width:pp+\'% \'});$(\'#answer\'+ai).children(\'div\').children( \'span\').html(\'[\'+ap+\' '.$this->__lan__msg_vote.' - \'+Math.round(pp)+\'%]\');}$(\'#status\').html(\'<div class="accept">'.$this->__lan__msg_thankYou.'</div>\').fadeIn(\'slow\');$(\'#submit\').html(\''.$ this->__lan__msg_totalVote.' : \'+tp+\' '.$this->__lan__msg_vote.'\').fadeIn(\'slow\');}}});}else{ $(\'#status\').html(\'<div class="error">'.$this->__lan__msg_chooseAnswer.'</div>\').fadeTo(\'slow\',1,function(){setTimeout(fu nction(){$(\'.error\').fadeOut(\'slow\');},1000);} );}return false;}</script>';
}
else
{
$this->js = '';
}
}
function getKeywords()
{
if( !isset( $this->_keywords ) )
{
$this->_keywords = 'قارتال,آنلاین,نظرسنجی';
}
if( !isset( $this->_description ) )
{
$this->_description = 'نظرسنجی';
}
$this->_key_dec = '<meta name="keywords" content="'.$this->_keywords.'" ><meta name="description" content="'.$this->_description.'">' ;
}
function setTemp( $_title , $_jsEnable = 1 )
{
$this->setStyle();
$this->getAds();
$this->getKeywords();
if( $_jsEnable == 1 )
{
$this->setJS();
}
else
{
$this->js = '';
}
if( $this->styleType == 0 )
{
$_StartHtmlCode = '<!DOCTYPE HTML><html><head><meta charset="utf-8"><title>'.$this->__lan__pageTitle.$_title.'</title>'.$this->_key_dec.$this->style.$this->js.'</head><body><div id="bbody"><div id="top">'.$_title.'</div><div id="body"><div id="right"><div id="poll">';
$_EndHtmlCode = '</div></div><div id="left"><div>'.$this->_ads.'</div></div><div class="clear"></div></div><div id="bottom"><a href="http://www.qartalonline.com" target="_blank">'.$this->__lan__qartalonline.'</a><span> - </span><a href="http://www.qartalonline.com/poll/" target="_blank">'.$this->__lan__creatPollTitle.'</a></div></div></body></html>';
}
else
{
$_StartHtmlCode = '<!DOCTYPE HTML><html><head><meta charset="utf-8">'.$this->_key_dec.$this->style.$this->js.'</head><body><div id="poll">';
$_EndHtmlCode = '</div></body></html>';
}
$this->printOutputCode( $_StartHtmlCode.$this->_htmlCode.$_EndHtmlCode );
}
function setMsg()
{
if( $this->pInfo[0]['MsgDVoted'] != '' )
{
$this->__lan__msg_voted = $this->pInfo[0]['MsgDVoted'];
}
if( $this->pInfo[0]['MsgSubmitvote'] != '' )
{
$this->__lan__msg_thankYou = $this->pInfo[0]['MsgSubmitvote'];
}
}
function startPoll()
{
$this->selectQuery();
$this->getExist();
if( $this->_showStatus[0] == 1 )
{
$this->setLanguage();
$this->getIpCheck();
if( $this->_showStatus[0] == 1 )
{
$this->getStatusCheck();
if( $this->_showStatus[0] == 1 )
{
$this->getDateCheck();
if( $this->_showStatus[0] == 1 )
{
$this->setMsg();
$this->getPoll();
}
else
{
$this->printErrorMessage();
}
}
else
{
$this->printErrorMessage();
}
}
else
{
$this->printErrorMessage();
}
}
else
{
$this->printErrorMessage();
}
}
function getAjaxResult()
{
$cArray = array( '#0078ff' , '#e46666' , '#f0a400' , '#a507d3' , '#44ae16' , '#127b91' , '#bb1bbd' , '#996e6b' , '#83a625' , '#cb4f78' , '#3386c0' , '#00d299' , '#e0a21e' , '#ff0000' , '#599c88' );
$cCounter = 0;
$SumAnswerPoints = 0;
foreach( $this->pInfo as $PI ){
if( !isset( $_result ) )
{
$_result = $PI['PollAnswerListing'].'|'.$PI['PollAnswerPoints'].'|'.$cArray[$cCounter] ;
}
else
{
$_result = $_result.'-'.$PI['PollAnswerListing'].'|'.$PI['PollAnswerPoints'].'|'.$cArray[$cCounter] ;
}
$cCounter++;
$SumAnswerPoints = $SumAnswerPoints + $PI['PollAnswerPoints'] ;
}
$_result = $SumAnswerPoints.'-'.$_result ;
$this->printOutputCode( $_result );
}
function getNormalResult()
{
$SumAnswerPoints=0;
$i=1;
$PollPercentage=0;
$CharStyle='';
$_chart='';
$_startDate='';
$_endDate='';
$_url='';
if( isset( $this->pInfo[0]['Title'] ) && $this->pInfo[0]['Title'] != '' )
{
$_title = $this->__lan__pollResult.' : '.getCleanOut( $this->pInfo[0]['Title'] , '11000000' );
}
else
{
$_title = $this->__lan__pollResult;
}
foreach( $this->pInfo as $PI )
{
$SumAnswerPoints = $SumAnswerPoints + $PI['PollAnswerPoints'] ;
}
$keywords = '';
foreach( $this->pInfo as $PI )
{
if( $SumAnswerPoints > 0 )
{
$PollPercentage = round( ( ( 100 * $PI['PollAnswerPoints'] ) / $SumAnswerPoints ) , 2 ) ;
}
$_chart .= '<div class="results"><div class="resultsAnswer">'.$i.'. '.getCleanOut( $PI['PollAnswerValue'] , '1100110000' , '--' ).'</div><div class="resultChart"><div class="chart'.$i.'" style="width:'.$PollPercentage.'%;"></div><div class="background"></div></div><div class="points"><span>'.$PI['PollAnswerPoints'].'</span> '.$this->__lan__msg_vote.'</div><div class="percentage">'.$PollPercentage.' %</div><div class="clear"></div></div>';
$keywords .= ','.str_replace( ' ' , ',' , $PI['PollAnswerValue'] );
$i++;
}
$_chart = '<div id="results">'.$_chart.'</div>';
$this->_keywords = $keywords .','.str_replace( ' ' , ',' , $this->pInfo[0]['Question'] ) ;
$this->_description = $this->pInfo[0]['Question'] ;
$_question = '<div id="question"><span>'.$this->__lan__question.' : </span>'.getCleanOut( $this->pInfo[0]['Question'] , '11000000' ).'</div>';
$_totalPoints = '<div id="totalPoints">'.$this->__lan__msg_totalVote.' : <span>'.$SumAnswerPoints.'</span> '.$this->__lan__msg_vote.'</div>';
if( $this->pInfo[0]['Language'] == 0 )
{
$_createdDate = '<div id="createdDate">'.$this->__lan__createdDate.' : <span>'.Date_m2sh( $this->pInfo[0]['Created'] , '2' ).'</span></div>';
}
else
{
$data = substr( $this->pInfo[0]['Created'] , 0 , 4 ).'-'.substr( $this->pInfo[0]['Created'] , 4 , 2 ).'-'.substr( $this->pInfo[0]['Created'] , 6 , 2 );
$_createdDate = '<div id="createdDate">'.$this->__lan__createdDate.' : <span>'.$data.'</span></div>';
}
if( isset( $this->pInfo[0]['StartDate'] ) && mb_strlen( $this->pInfo[0]['StartDate'] , 'utf-8' ) == '8' )
{
if( $this->pInfo[0]['Language'] == 0 )
{
$_startDate = '<div id="startDate">'.$this->__lan__startDate.' : <span>'.Date_m2sh($this->pInfo[0]['StartDate'],'2').'</span></div>';
}
else
{
$data = substr( $this->pInfo[0]['StartDate'] , 0 , 4 ).'-'.substr( $this->pInfo[0]['StartDate'] , 4 , 2 ).'-'.substr( $this->pInfo[0]['StartDate'] , 6 , 2 );
$_startDate = '<div id="startDate">'.$this->__lan__startDate.' : <span>'.$data.'</span></div>';
}
}
if( isset( $this->pInfo[0]['EndDate'] ) && mb_strlen( $this->pInfo[0]['EndDate'] , 'utf-8' ) == '8' )
{
if( $this->pInfo[0]['Language'] == 0 )
{
$_endDate = '<div id="endDate">'.$this->__lan__endDate.' : <span>'.Date_m2sh($this->pInfo[0]['EndDate'],'2').'</span></div>';
}
else
{
$data = substr( $this->pInfo[0]['EndDate'] , 0 , 4 ).'-'.substr( $this->pInfo[0]['EndDate'] , 4 , 2 ).'-'.substr( $this->pInfo[0]['EndDate'] , 6 , 2 );
$_endDate = '<div id="endDate">'.$this->__lan__endDate.' : <span>'.$data.'</span></div>';
}
}
if( isset( $this->pInfo[0]['Url'] ) && $this->pInfo[0]['Url'] != '' && $this->pInfo[0]['Url'] != 'http://' )
{
$_url = '<div id="url">'.$this->__lan__url.' : <a href="'.getCleanOut( $this->pInfo[0]['Url'] , '11000000' ).'" target="_blank">'.getCleanOut( $this->pInfo[0]['Url'] , '11000000' ).'</a></div>';
}
$this->_htmlCode = $_question.$_chart.$_totalPoints.$_createdDate.$_s tartDate.$_endDate.$_url;
$this->setTemp( $_title );
}
function showResult()
{
$this->getExist();
if( $this->_showStatus[0] == 1 )
{
$this->setLanguage();
$this->getIpCheck();
if( $this->_showStatus[0] == 1 )
{
$status=$this->getStatusCheck();
if( $this->_showStatus[0] == 1 )
{
if( $this->pInfo[0]['Results'] == '1' )
{
if( $this->styleType == 1 )
{
$this->getAjaxResult();
}
else
{
$this->getNormalResult();
}
}
else
{
$this->printErrorMessage( $this->__lan__msg_privateResult );
}
}
else
{
$this->printErrorMessage();
}
}
else
{
$this->printErrorMessage();
}
}
else
{
$this->printErrorMessage();
}
}
function vote($answerId)
{
$status = 'error';
for( $i=0 ; $i<15 ; $i++ )
{
if( $answerId == $this->pInfo[$i]['PollAnswerID'] )
{
$status = 'accept';
$this->pInfo[$i]['PollAnswerPoints']++;
break;
}
}
if( $status == 'accept' )
{
$query = 'UPDATE tools_pollanswers SET PollAnswerPoints=PollAnswerPoints+1 WHERE PollAnswerID='.$answerId ;
$this->db->exec( $query );
if( $this->pInfo[0]['Results'] == 1 )
{
if( $this->styleType == 1 )
{
$this->getAjaxResult();
}
else
{
$this->getNormalResult();
}
}
else
{
if( $this->styleType == 0 )
{
$this->printErrorMessage( $this->__lan__msg_thankYou );
}
else
{
$this->printOutputCode( 'VoteWereRecorded' );
}
}
}
else
{
$this->printOutputCode( $this->__lan__msg_error );
}
}
function getVote($answerId)
{
$this->selectQuery();
$this->getExist();
if( $this->_showStatus[0] == 1 )
{
$this->setLanguage();
$this->getIpCheck();
if( $this->_showStatus[0] == 1 )
{
$this->getStatusCheck();
if( $this->_showStatus[0] == 1 )
{
$cookieName = 'QO__Poll'.$this->id ;
$this->setMsg();
// check kardane cooki
if( isset( $_COOKIE[$cookieName] ) && $_COOKIE[$cookieName] == 1 && $this->pInfo[0]['CookieTime'] != 0 )
{
if( $this->styleType == 0 )
{
$this->printErrorMessage( $this->__lan__msg_voted );
}
else
{
$this->printOutputCode( 'voted' );
}
}
else
{
$cookieTime = $this->pInfo[0]['CookieTime'] ;
$cookieTime = $cookieTime * 86400 ;
setcookie( $cookieName , 1 , time()+$cookieTime , '/' ) ;
$this->vote( $answerId );
}
}
else
{
$this->printErrorMessage();
}
}
else
{
$this->printErrorMessage();
}
}
else
{
$this->printErrorMessage();
}
}
function printErrorMessage( $msg = '' )
{
if( $msg == '' )
{
$msg = $this->_showStatus[1];
}
$this->_htmlCode='<div id="error">'.$msg.'</div>';
$this->setTemp( $this->__lan__pollTitle , 0 );
}
function printOutputCode( $output )
{
echo $output;
}
function __destruct()
{
unset($this->db);
}
}
?>