Your IP : 216.73.216.170


Current Path : /var/www/iplanru/data/www/i-plan.ru/components/com_poll/views/poll/tmpl/
Upload File :
Current File : /var/www/iplanru/data/www/i-plan.ru/components/com_poll/views/poll/tmpl/page_nap_sel1.php

<?php
// No direct access
defined( '_JEXEC' ) or die;


$chash=pollHelper::setCookies();


$list=$db->setQuery("SELECT * FROM #__pollanswers where cookie=\"{$chash}\"")->loadAssocList();


// проверяем индентификатор
if (!JRequest::checkToken('REQUEST') or count($list)<>0) {
    JError::raiseError(403, JText::_('Страница недоступна без аутентификации.'));
    jexit('Invalid Token');
}




//save------------------------------------------------------------------
//code generated
$str1=strtoupper(md5(time().$_SERVER["REMOTE_ADDR"]));
$str2=strtoupper(md5(time().$str1));
$str3=strtoupper(md5(time().$str2));
$str4=strtoupper(md5(time().$str3));
$code= substr($str1,0,4).'-'.substr($str2,0,4).'-'.substr($str3,0,4).'-'.substr($str4,0,5);
unset($str1,$str2,$str3,$str4);


$b=$db->setQuery('INSERT INTO #__pollanswers (id,ip,cookie,date,code,discount,discount_time) 
				VALUES(NULL,"'.$_SERVER["REMOTE_ADDR"].'", 
							"'.$chash.'", 
							NOW(), 
							"'.$code.'", 
							"'.$componentParams->get('discount', '').'", 
							"'.$componentParams->get('discount_time', '').'" 
						);')->Execute();
$answer = $db->insertid();
if ($b and $answer<>'')
{
	$list=$db->setQuery("SELECT * FROM #__pollquestions where state=1 order by ordering")->loadAssocList();
	if (count($list)<>0)
	{
		foreach ($list as $item)
		{
			$p=true;
			$val=str_replace('"','\"',$jinput->getString( 'field_'.$item['id'], '' ));
			$b=$db->setQuery('INSERT INTO #__pollanswer (id,ans_id,que_id,value) VALUES(NULL,"'.$answer.'", '.$item['id'].', "'.$val.'");')->Execute();
			if (!$b)
			{
				$p=false;
			}
		}
	}
}


?>