Add New Option .. Inserts a Blank Vote

Find out what does your audience think

Add New Option .. Inserts a Blank Vote

New postby medialinx » Fri Oct 17, 2014 2:08 pm

Hi I Purchased the Vote system last night and all seems well except when I add a New Answer to the vote on the front end

It Inserts a Vote but doesn't record the name (Front or Back End)

Any Ideas

My Site is Offline at the minute as im still building it ... http://www.medialinx.tv/

But I can send log in details if you want ftp etc etc
Cheers Paul
medialinx
 
Posts: 3
Joined: Fri Oct 17, 2014 2:03 pm

Re: Add New Option .. Inserts a Blank Vote

New postby Edvard » Sun Oct 19, 2014 7:04 am

Hi,

Please send FTP and admin backend access to [email protected] and I'll fix it for you.

Thanks!
Regards,

Edvard Ananyan - 2GLux Team

Please post a review at the Joomla Extensions Directory. It is very important for us!
Edvard
Site Admin
 
Posts: 1836
Joined: Mon Jun 28, 2010 1:54 pm
Location: Yerevan, Armenia

Re: Add New Option .. Inserts a Blank Vote

New postby medialinx » Mon Oct 20, 2014 8:31 pm

Thank You ... Thats sorted out the Blank Add Answer ... Bit

Can you recommend a way to add a poll to an article without it all squashing up like the picture I sent

Thank You for your time
Paul
medialinx
 
Posts: 3
Joined: Fri Oct 17, 2014 2:03 pm

Re: Add New Option .. Inserts a Blank Vote

New postby poindusadmin » Tue Oct 21, 2014 11:59 am

I'm having the same issue with "Add Answer" inserting a Blank answer. Can you post the fix?
poindusadmin
 
Posts: 1
Joined: Tue Oct 21, 2014 11:55 am

Re: Add New Option .. Inserts a Blank Vote

New postby Edvard » Tue Oct 21, 2014 8:18 pm

Hi,

The fix is to use this file instead of components/com_sexypolling/addanswer.php

Code: Select all
<?php

/**

* Joomla! component sexypolling

*

* @version $Id: addanswer.php 2012-04-05 14:30:25 svn $

* @author 2GLux.com

* @package Sexy Polling

* @subpackage com_sexypolling

* @license GNU/GPL

*

*/



// no direct access

define('_JEXEC',true);

defined('_JEXEC') or die('Restircted access');



/*

* This is external PHP file and used on AJAX calls, so it has not "defined('_JEXEC') or die;" part.

*/

error_reporting(0);



define( 'DS', DIRECTORY_SEPARATOR );

define('JPATH_BASE', dirname(__FILE__).DS.'..'.DS.'..' );



session_start();



header('Content-type: application/json');



require_once ( JPATH_BASE .DS.'includes'.DS.'defines.php' );

require_once ( JPATH_BASE .DS.'includes'.DS.'framework.php' );



$app = JFactory::getApplication('site');

$app->initialise();



$db = JFactory::getDBO();



//get user groups

$levels = array();

$groups = array();



$user = JFactory::getUser();

$user_id = $user->get('id');

jimport( 'joomla.access.access' );

$groups = JAccess::getGroupsByUser($user_id);



$date_now = strtotime("now");

$datenow = date("Y-m-d H:i:s", $date_now);

$datenow_sql = date("Y-m-d", $date_now);



//get ip address
$REMOTE_ADDR = null;
if(isset($_SERVER['HTTP_X_FORWARDED_FOR'])) { list($REMOTE_ADDR) = explode(',', $_SERVER['HTTP_X_FORWARDED_FOR']); }
elseif(isset($_SERVER['HTTP_X_REAL_IP'])) { $REMOTE_ADDR = $_SERVER['HTTP_X_REAL_IP']; }
elseif(isset($_SERVER['REMOTE_ADDR'])) { $REMOTE_ADDR = $_SERVER['REMOTE_ADDR']; }
else { $REMOTE_ADDR = 'Unknown'; }
$ip = $REMOTE_ADDR;

//get post data

$polling_id = (int)$_POST['polling_id'];

$autopublish = (int)$_POST['autopublish'];

$writeinto = (int)$_POST['writeinto'];

$answer = $db->escape(strip_tags($_POST['answer']));

$answer = preg_replace('/sexydoublequestionmark/','??',$answer);


//get poll options

$query = "SELECT * FROM `#__sexy_polls` WHERE `id` = '$polling_id'";

$db->setQuery( $query );

$poll_options = $db->loadAssoc();

$ipcount = $poll_options["ipcount"];

$voting_period = $poll_options["voting_period"];



//check token

if (!JRequest::checkToken() && $poll_options["checktoken"] == 1) {

   echo '[{"invalid":"invalid_token"}]';

   exit();

}



$countryname = (!isset($_POST['country_name']) || $_POST['country_name'] == '' || $_POST['country_name'] == '-' ) ? 'Unknown' : JRequest::getVar('country_name', 'Unknown', 'POST');
$cityname = (!isset($_POST['city_name']) || $_POST['city_name'] == '' || $_POST['city_name'] == '-' ) ? 'Unknown' : JRequest::getVar('city_name', 'Unknown', 'POST');
$regionname = (!isset($_POST['region_name']) || $_POST['region_name'] == '' || $_POST['region_name'] == '-' ) ? 'Unknown' : JRequest::getVar('region_name', 'Unknown', 'POST');
$countrycode = (!isset($_POST['country_code']) || $_POST['country_code'] == '' || $_POST['country_code'] == '-' ) ? 'Unknown' : JRequest::getVar('country_code', 'Unknown', 'POST');

//check ipcount security

$query = "SELECT COUNT( sv.ip )

         FROM  `#__sexy_answers` sa

         JOIN  `#__sexy_votes` sv ON sv.id_answer = sa.id

         AND DATE_FORMAT(sv.date, '%Y-%m-%d') = '$datenow_sql'

         AND sv.ip = '$ip'

         WHERE sa.id_poll =  '$polling_id'

      ";

$db->setQuery($query);

$count_votes = $db->loadResult();

$ipcountchecked = true;

if($ipcount != 0 && $count_votes >= $ipcount)

   $ipcountchecked = false;



//make additional checkings

$voting_enabled = true;

if($poll_options["votechecks"] == 1) {

   //check ACL to vote

   function if_contain($array1,$array2) {

      if(is_array($array2))

         foreach($array1 as $val) {

         if(in_array($val,$array2))

            return true;

      }

      return false;

   }

   

   //check ACL to add answer

   $add_answer_permissions_id =$poll_options["answerpermission"];

   $query = "SELECT `rules` FROM #__viewlevels WHERE id = '$add_answer_permissions_id'";

   $db->setQuery($query);

   $db->query();

   $levels = explode(',',str_replace(array('[',']'),'',$db->loadResult()));

   if(!if_contain($levels,$groups) && $poll_options["checkacl"] == 1)

      $voting_enabled = false;



   $voting_permission_id = $poll_options["voting_permission"];

   $query = "SELECT `rules` FROM #__viewlevels WHERE id = '$voting_permission_id'";

   $db->setQuery($query);

   $db->query();

   $levels = explode(',',str_replace(array('[',']'),'',$db->loadResult()));

   if(!if_contain($levels,$groups) && $poll_options["checkacl"] == 1)

      $voting_enabled = false;



   $registration_to_vote_required = ( in_array(2,$levels) || in_array(3,$levels) || in_array(6,$levels) || in_array(8,$levels) ) ? true : false;



   //check start,end dates

   if($poll_options["date_start"] != '0000-00-00' &&  $date_now < strtotime($poll_options["date_start"]))

      $voting_enabled = false;

   if($poll_options["date_end"] != '0000-00-00' &&  $date_now > strtotime($poll_options["date_end"]))

      $voting_enabled = false;



   //check user_id

   if($registration_to_vote_required) {

      $query = "SELECT sv.`ip`,sv.`date` FROM #__sexy_votes sv JOIN #__sexy_answers sa ON sa.id_poll = '$polling_id' WHERE sv.id_answer = sa.id AND sv.id_user = '$user_id' ORDER BY sv.`date` DESC LIMIT 1";

      $db->setQuery($query);

      $db->query();

      $num_rows = $db->getNumRows();

      $row = $db->loadAssoc();

      if($num_rows > 0) {

         $datevoted = strtotime($row['date']);

         $hours_diff = ($date_now - $datevoted) / 3600;

         if($voting_period == 0 || ($hours_diff < $voting_period)) {

            $voting_enabled = false;

         }

      }

   }

   else {

      //check ip

      $query = "SELECT sv.`ip`,sv.`date` FROM #__sexy_votes sv JOIN #__sexy_answers sa ON sa.id_poll = '$polling_id' WHERE sv.id_answer = sa.id AND sv.ip = '$ip' ORDER BY sv.`date` DESC LIMIT 1";

      $db->setQuery($query);

      $db->query();

      $num_rows = $db->getNumRows();

      $row = $db->loadAssoc();

      if($num_rows > 0) {

         $datevoted = strtotime($row['date']);

         $hours_diff = ($date_now - $datevoted) / 3600;

         if($voting_period == 0 || ($hours_diff < $voting_period)) {

            $voting_enabled = false;

         }

      }

         

      //check cookie

      if (isset($_COOKIE["sexy_poll_$polling_id"])) {

         $voting_enabled = false;

      }

   }

}



if(($writeinto == 1 || $autopublish == 0) && $voting_enabled) {

   $published = $autopublish == 1 ? 1 : 0;

   $query = "INSERT INTO `#__sexy_answers` (`id_poll`,`name`,`published`,`created`) VALUES ('$polling_id','$answer','$published','$datenow')";

   $db->setQuery($query);

   $db->query();

   $insert_id = $db->insertid();

   

   if($ipcountchecked) {

      $query = "INSERT INTO `#__sexy_votes` (`id_answer`,`id_user`,`ip`,`date`,`country`,`city`,`region`,`countrycode`) VALUES ('$insert_id','$user_id','$ip','$datenow','$countryname','$cityname','$regionname','$countrycode')";

      $db->setQuery($query);

      $db->query();

      //set the cookie

      if($voting_period == 0) {

         $expire = time()+(60*60*24*365*2);//2 years

         setcookie("sexy_poll_$polling_id", $date_now, $expire, '/');

      }

      else {

         $expire_time = (float)$voting_period*60*60;

         $expire = (int)(time()+$expire_time);

         setcookie("sexy_poll_$polling_id", $date_now, $expire, '/');

      }

   }

}

else {

   $insert_id = 0;

}



echo json_encode(array(array('answer' => $answer, 'id' => $insert_id)));
jexit();
?>
Regards,

Edvard Ananyan - 2GLux Team

Please post a review at the Joomla Extensions Directory. It is very important for us!
Edvard
Site Admin
 
Posts: 1836
Joined: Mon Jun 28, 2010 1:54 pm
Location: Yerevan, Armenia

Re: Add New Option .. Inserts a Blank Vote

New postby Edvard » Tue Oct 21, 2014 8:20 pm

Hi Paul,

I need to see the poll inside your article to be able to suggest, can you send me a link?

Thank you!
Regards,

Edvard Ananyan - 2GLux Team

Please post a review at the Joomla Extensions Directory. It is very important for us!
Edvard
Site Admin
 
Posts: 1836
Joined: Mon Jun 28, 2010 1:54 pm
Location: Yerevan, Armenia

Re: Add New Option .. Inserts a Blank Vote

New postby medialinx » Wed Oct 22, 2014 1:50 pm

Hi Edvard

Thanks for getting back to me

I want to add it to a few articles in various places through Site at the minute it does this (See Image)
Image
its in a Article Here http://www.medialinx.tv/support/media-l ... gory&id=10

I tested the demo version and that all seemed to work but at the minute since purchasing .... Click View and it just loads and does nothing also Timeline doesn't appear .. I tried changing the template but same results

Site is offline .. but the log in details should be in the previous email I sent

Cheers Edvard ... im in no big hurry as im still building the site .. but it would be nice if everything worked

Cheers Again
Paul
medialinx
 
Posts: 3
Joined: Fri Oct 17, 2014 2:03 pm

Re: Add New Option .. Inserts a Blank Vote

New postby Edvard » Wed Oct 22, 2014 11:31 pm

Hi,

When I check http://www.medialinx.tv/support/media-linx-faqs it works fine and I'm able to see the results by clicking View, but when I use http://www.medialinx.tv/support/media-l ... gory&id=10 it doesn't work, it seems to be some conflict.

I was not able to see the narrow poll as in your image. It looks fine for me.

Let me know.

Thanks!
Regards,

Edvard Ananyan - 2GLux Team

Please post a review at the Joomla Extensions Directory. It is very important for us!
Edvard
Site Admin
 
Posts: 1836
Joined: Mon Jun 28, 2010 1:54 pm
Location: Yerevan, Armenia

Re: Add New Option .. Inserts a Blank Vote

New postby Larian » Thu Oct 30, 2014 2:40 pm

Hi,
had the same problem with the blank vote and replaced addanswers.php as described.

Now, i can add a new answer, but if i check it and vote for it the vote doesn't work. If i cancel it and refresh i have a new blank option.

http://www.ludothek.de/index.php/spiele ... che?poll=2
Larian
 
Posts: 1
Joined: Thu Oct 30, 2014 11:24 am

Re: Add New Option .. Inserts a Blank Vote

New postby Edvard » Fri Oct 31, 2014 4:05 am

Hi,

Can you send me FTP access to [email protected] I'll look into.

Thanks!
Regards,

Edvard Ananyan - 2GLux Team

Please post a review at the Joomla Extensions Directory. It is very important for us!
Edvard
Site Admin
 
Posts: 1836
Joined: Mon Jun 28, 2010 1:54 pm
Location: Yerevan, Armenia


Return to Sexy Polling

Who is online

Users browsing this forum: No registered users and 2 guests

cron