WP-Polls - Version 2.73.2

Version Description

N/A

Download this release

Release Info

Developer GamerZ
Plugin Icon WP-Polls
Version 2.73.2
Comparing to
See all releases

Code changes from version 2.73.1 to 2.73.2

Files changed (2) hide show
  1. readme.txt +7 -3
  2. wp-polls.php +74 -68
readme.txt CHANGED
@@ -1,10 +1,10 @@
1
  === WP-Polls ===
2
  Contributors: GamerZ
3
- Donate link: http://lesterchan.net/site/donation/
4
  Tags: poll, polls, polling, vote, booth, democracy, ajax, survey, post, widget
5
  Requires at least: 4.0
6
- Tested up to: 4.5
7
- Stable tag: 2.73.1
8
 
9
  Adds an AJAX poll system to your WordPress blog. You can also easily add a poll into your WordPress's blog post/page.
10
 
@@ -27,6 +27,10 @@ WP-Polls is extremely customizable via templates and css styles and there are to
27
  I spent most of my free time creating, updating, maintaining and supporting these plugins, if you really love my plugins and could spare me a couple of bucks, I will really appreciate it. If not feel free to use it without any obligations.
28
 
29
  == Changelog ==
 
 
 
 
30
  = Version 2.73.1 =
31
  * FIXED: Allow local IP
32
  * FIXED: XSS on Poll bar option. Props [Netsparker Web Application Security Scanner](https://www.netsparker.com/)
1
  === WP-Polls ===
2
  Contributors: GamerZ
3
+ Donate link: https://lesterchan.net/site/donation/
4
  Tags: poll, polls, polling, vote, booth, democracy, ajax, survey, post, widget
5
  Requires at least: 4.0
6
+ Tested up to: 4.7
7
+ Stable tag: 2.73.2
8
 
9
  Adds an AJAX poll system to your WordPress blog. You can also easily add a poll into your WordPress's blog post/page.
10
 
27
  I spent most of my free time creating, updating, maintaining and supporting these plugins, if you really love my plugins and could spare me a couple of bucks, I will really appreciate it. If not feel free to use it without any obligations.
28
 
29
  == Changelog ==
30
+ = Version 2.73.2 =
31
+ * NEW: Bump WordPress 4.7
32
+ * FIXED: Change cron to hourly instead of twice daily.
33
+
34
  = Version 2.73.1 =
35
  * FIXED: Allow local IP
36
  * FIXED: XSS on Poll bar option. Props [Netsparker Web Application Security Scanner](https://www.netsparker.com/)
wp-polls.php CHANGED
@@ -3,7 +3,7 @@
3
  Plugin Name: WP-Polls
4
  Plugin URI: https://lesterchan.net/portfolio/programming/php/
5
  Description: Adds an AJAX poll system to your WordPress blog. You can easily include a poll into your WordPress's blog post/page. WP-Polls is extremely customizable via templates and css styles and there are tons of options for you to choose to ensure that WP-Polls runs the way you wanted. It now supports multiple selection of answers.
6
- Version: 2.73.1
7
  Author: Lester 'GaMerZ' Chan
8
  Author URI: https://lesterchan.net
9
  Text Domain: wp-polls
@@ -30,7 +30,7 @@ Text Domain: wp-polls
30
 
31
 
32
  ### Version
33
- define( 'WP_POLLS_VERSION', '2.73.1' );
34
 
35
 
36
  ### Create Text Domain For Translations
@@ -1233,11 +1233,10 @@ function poll_timestamp($poll_timestamp, $fieldname = 'pollq_timestamp', $displa
1233
  function cron_polls_place() {
1234
  wp_clear_scheduled_hook('polls_cron');
1235
  if (!wp_next_scheduled('polls_cron')) {
1236
- wp_schedule_event(time(), 'twicedaily', 'polls_cron');
1237
  }
1238
  }
1239
 
1240
-
1241
  ### Funcion: Check All Polls Status To Check If It Expires
1242
  add_action('polls_cron', 'cron_polls_status');
1243
  function cron_polls_status() {
@@ -1316,78 +1315,85 @@ function vote_poll() {
1316
  do_action('wp_polls_vote_poll');
1317
  $poll_aid = $_POST["poll_$poll_id"];
1318
  $poll_aid_array = array_unique(array_map('intval', explode(',', $poll_aid)));
1319
- if($poll_id > 0 && !empty($poll_aid_array) && check_allowtovote()) {
1320
- $is_poll_open = intval( $wpdb->get_var( $wpdb->prepare( "SELECT COUNT(*) FROM $wpdb->pollsq WHERE pollq_id = %d AND pollq_active = 1", $poll_id ) ) );
1321
- if ( $is_poll_open > 0 ) {
1322
- $check_voted = check_voted($poll_id);
1323
- if ($check_voted == 0) {
1324
- if (!empty($user_identity)) {
1325
- $pollip_user = htmlspecialchars(addslashes($user_identity));
1326
- } elseif (!empty($_COOKIE['comment_author_' . COOKIEHASH])) {
1327
- $pollip_user = htmlspecialchars(addslashes($_COOKIE['comment_author_' . COOKIEHASH]));
1328
- } else {
1329
- $pollip_user = __('Guest', 'wp-polls');
1330
- }
1331
- $pollip_userid = intval($user_ID);
1332
- $pollip_ip = get_ipaddress();
1333
- $pollip_host = @gethostbyaddr($pollip_ip);
1334
- $pollip_timestamp = current_time('timestamp');
1335
- // Only Create Cookie If User Choose Logging Method 1 Or 2
1336
- $poll_logging_method = intval(get_option('poll_logging_method'));
1337
- if ($poll_logging_method == 1 || $poll_logging_method == 3) {
1338
- $cookie_expiry = intval(get_option('poll_cookielog_expiry'));
1339
- if ($cookie_expiry == 0) {
1340
- $cookie_expiry = 30000000;
1341
  }
1342
- $vote_cookie = setcookie('voted_' . $poll_id, $poll_aid, ($pollip_timestamp + $cookie_expiry), apply_filters('wp_polls_cookiepath', SITECOOKIEPATH));
1343
- }
1344
- $i = 0;
1345
- foreach ($poll_aid_array as $polla_aid) {
1346
- $update_polla_votes = $wpdb->query( "UPDATE $wpdb->pollsa SET polla_votes = (polla_votes + 1) WHERE polla_qid = $poll_id AND polla_aid = $polla_aid" );
1347
- if (!$update_polla_votes) {
1348
- unset($poll_aid_array[$i]);
 
 
 
 
 
1349
  }
1350
- $i++;
1351
- }
1352
- $vote_q = $wpdb->query("UPDATE $wpdb->pollsq SET pollq_totalvotes = (pollq_totalvotes+" . sizeof( $poll_aid_array ) . "), pollq_totalvoters = (pollq_totalvoters + 1) WHERE pollq_id = $poll_id AND pollq_active = 1");
1353
- if ($vote_q) {
1354
  foreach ($poll_aid_array as $polla_aid) {
1355
- $wpdb->insert(
1356
- $wpdb->pollsip,
1357
- array(
1358
- 'pollip_qid' => $poll_id,
1359
- 'pollip_aid' => $polla_aid,
1360
- 'pollip_ip' => $pollip_ip,
1361
- 'pollip_host' => $pollip_host,
1362
- 'pollip_timestamp' => $pollip_timestamp,
1363
- 'pollip_user' => $pollip_user,
1364
- 'pollip_userid' => $pollip_userid
1365
- ),
1366
- array(
1367
- '%s',
1368
- '%s',
1369
- '%s',
1370
- '%s',
1371
- '%s',
1372
- '%s',
1373
- '%d'
1374
- )
1375
- );
1376
  }
1377
- echo display_pollresult($poll_id, $poll_aid_array, false);
1378
- do_action( 'wp_polls_vote_poll_success' );
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1379
  } else {
1380
- printf(__('Unable To Update Poll Total Votes And Poll Total Voters. Poll ID #%s', 'wp-polls'), $poll_id);
1381
- } // End if($vote_a)
1382
  } else {
1383
- printf(__('You Had Already Voted For This Poll. Poll ID #%s', 'wp-polls'), $poll_id);
1384
- } // End if($check_voted)
1385
  } else {
1386
- printf( __( 'Poll ID #%s is closed', 'wp-polls' ), $poll_id );
1387
- } // End if($is_poll_open > 0)
1388
  } else {
1389
- printf(__('Invalid Poll ID. Poll ID #%s', 'wp-polls'), $poll_id);
1390
- } // End if($poll_id > 0 && !empty($poll_aid_array) && check_allowtovote())
1391
  break;
1392
  // Poll Result
1393
  case 'result':
3
  Plugin Name: WP-Polls
4
  Plugin URI: https://lesterchan.net/portfolio/programming/php/
5
  Description: Adds an AJAX poll system to your WordPress blog. You can easily include a poll into your WordPress's blog post/page. WP-Polls is extremely customizable via templates and css styles and there are tons of options for you to choose to ensure that WP-Polls runs the way you wanted. It now supports multiple selection of answers.
6
+ Version: 2.73.2
7
  Author: Lester 'GaMerZ' Chan
8
  Author URI: https://lesterchan.net
9
  Text Domain: wp-polls
30
 
31
 
32
  ### Version
33
+ define( 'WP_POLLS_VERSION', '2.73.2' );
34
 
35
 
36
  ### Create Text Domain For Translations
1233
  function cron_polls_place() {
1234
  wp_clear_scheduled_hook('polls_cron');
1235
  if (!wp_next_scheduled('polls_cron')) {
1236
+ wp_schedule_event(time(), 'hourly', 'polls_cron');
1237
  }
1238
  }
1239
 
 
1240
  ### Funcion: Check All Polls Status To Check If It Expires
1241
  add_action('polls_cron', 'cron_polls_status');
1242
  function cron_polls_status() {
1315
  do_action('wp_polls_vote_poll');
1316
  $poll_aid = $_POST["poll_$poll_id"];
1317
  $poll_aid_array = array_unique(array_map('intval', explode(',', $poll_aid)));
1318
+ $is_real = intval( $wpdb->get_var( $wpdb->prepare( "SELECT COUNT(*) FROM $wpdb->pollsa WHERE polla_aid = %d AND polla_qid = %d", array( $poll_aid, $poll_id ) ) ) );
1319
+
1320
+ // The multiple ifs is ugly, I know it. Feel free to send a PR to fix it
1321
+ if( $is_real > 0 ) {
1322
+ if($poll_id > 0 && !empty($poll_aid_array) && check_allowtovote()) {
1323
+ $is_poll_open = intval( $wpdb->get_var( $wpdb->prepare( "SELECT COUNT(*) FROM $wpdb->pollsq WHERE pollq_id = %d AND pollq_active = 1", $poll_id ) ) );
1324
+ if ( $is_poll_open > 0 ) {
1325
+ $check_voted = check_voted($poll_id);
1326
+ if ($check_voted == 0) {
1327
+ if (!empty($user_identity)) {
1328
+ $pollip_user = htmlspecialchars(addslashes($user_identity));
1329
+ } elseif (!empty($_COOKIE['comment_author_' . COOKIEHASH])) {
1330
+ $pollip_user = htmlspecialchars(addslashes($_COOKIE['comment_author_' . COOKIEHASH]));
1331
+ } else {
1332
+ $pollip_user = __('Guest', 'wp-polls');
 
 
 
 
 
 
 
1333
  }
1334
+ $pollip_userid = intval($user_ID);
1335
+ $pollip_ip = get_ipaddress();
1336
+ $pollip_host = @gethostbyaddr($pollip_ip);
1337
+ $pollip_timestamp = current_time('timestamp');
1338
+ // Only Create Cookie If User Choose Logging Method 1 Or 2
1339
+ $poll_logging_method = intval(get_option('poll_logging_method'));
1340
+ if ($poll_logging_method == 1 || $poll_logging_method == 3) {
1341
+ $cookie_expiry = intval(get_option('poll_cookielog_expiry'));
1342
+ if ($cookie_expiry == 0) {
1343
+ $cookie_expiry = 30000000;
1344
+ }
1345
+ setcookie('voted_' . $poll_id, $poll_aid, ($pollip_timestamp + $cookie_expiry), apply_filters('wp_polls_cookiepath', SITECOOKIEPATH));
1346
  }
1347
+ $i = 0;
 
 
 
1348
  foreach ($poll_aid_array as $polla_aid) {
1349
+ $update_polla_votes = $wpdb->query( "UPDATE $wpdb->pollsa SET polla_votes = (polla_votes + 1) WHERE polla_qid = $poll_id AND polla_aid = $polla_aid" );
1350
+ if (!$update_polla_votes) {
1351
+ unset($poll_aid_array[$i]);
1352
+ }
1353
+ $i++;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1354
  }
1355
+ $vote_q = $wpdb->query("UPDATE $wpdb->pollsq SET pollq_totalvotes = (pollq_totalvotes+" . sizeof( $poll_aid_array ) . "), pollq_totalvoters = (pollq_totalvoters + 1) WHERE pollq_id = $poll_id AND pollq_active = 1");
1356
+ if ($vote_q) {
1357
+ foreach ($poll_aid_array as $polla_aid) {
1358
+ $wpdb->insert(
1359
+ $wpdb->pollsip,
1360
+ array(
1361
+ 'pollip_qid' => $poll_id,
1362
+ 'pollip_aid' => $polla_aid,
1363
+ 'pollip_ip' => $pollip_ip,
1364
+ 'pollip_host' => $pollip_host,
1365
+ 'pollip_timestamp' => $pollip_timestamp,
1366
+ 'pollip_user' => $pollip_user,
1367
+ 'pollip_userid' => $pollip_userid
1368
+ ),
1369
+ array(
1370
+ '%s',
1371
+ '%s',
1372
+ '%s',
1373
+ '%s',
1374
+ '%s',
1375
+ '%s',
1376
+ '%d'
1377
+ )
1378
+ );
1379
+ }
1380
+ echo display_pollresult($poll_id, $poll_aid_array, false);
1381
+ do_action( 'wp_polls_vote_poll_success' );
1382
+ } else {
1383
+ printf(__('Unable To Update Poll Total Votes And Poll Total Voters. Poll ID #%s', 'wp-polls'), $poll_id);
1384
+ } // End if($vote_a)
1385
  } else {
1386
+ printf(__('You Had Already Voted For This Poll. Poll ID #%s', 'wp-polls'), $poll_id);
1387
+ } // End if($check_voted)
1388
  } else {
1389
+ printf( __( 'Poll ID #%s is closed', 'wp-polls' ), $poll_id );
1390
+ } // End if($is_poll_open > 0)
1391
  } else {
1392
+ printf(__('Invalid Poll ID. Poll ID #%s', 'wp-polls'), $poll_id);
1393
+ } // End if($poll_id > 0 && !empty($poll_aid_array) && check_allowtovote())
1394
  } else {
1395
+ printf(__('Invalid Answer to Poll ID #%s', 'wp-polls'), $poll_id);
1396
+ } //End if(!isRealAnswer($poll_id,$poll_aid))
1397
  break;
1398
  // Poll Result
1399
  case 'result':