PluginProbe
Poll Maker by AYS – Versus Polls, Anonymous Polls, Image Polls / 6.5.1
Poll Maker by AYS – Versus Polls, Anonymous Polls, Image Polls v6.5.1
6.5.1 6.5.0 6.4.9 6.4.8 6.4.7 6.4.6 6.4.5 6.4.4 6.4.3 6.4.2 6.4.1 6.4.0 6.3.9 6.3.8 6.3.7 6.3.6 6.3.5 6.3.4 6.3.3 5.6.0 5.6.1 5.6.2 5.6.3 5.6.4 5.6.5 All 154 releases
← All changes | public/class-poll-maker-ays-public.php +56 -51 6.4.9 → 6.5.1 View file →
@@ -206,13 +206,9 @@
206 206 }
207 207
208 208 public function show_chart_js() {
209 209 wp_enqueue_script( $this->plugin_name . '-charts-google', plugin_dir_url(__FILE__) . 'js/google-chart.js', array('jquery'), $this->version, true);
210 - }
211 - // public function show_column_chart_js() {
212 - // // wp_enqueue_script( $this->plugin_name . '-column-chart', 'https://www.gstatic.com/charts/loader.js', array('jquery'), $this->version, true);
213 - // wp_enqueue_script( $this->plugin_name . '-column-chart', plugin_dir_url(__FILE__) . 'js/poll-maker-chart-loader.js', array('jquery'), $this->version, true);
214 - // }
210 + }
215 211
216 212 // Categories shortcode
217 213 public function ays_poll_generate_categories_method($attr) {
218 214 ob_start();
@@ -370,9 +366,8 @@
370 366
371 367 $chart_style = false;
372 368 if (isset( $result_option_res['show_result_view']) && ( $result_option_res['show_result_view'] == 'pie_chart' || $result_option_res['show_result_view'] == 'column_chart' )) {
373 369 $this->show_chart_js();
374 - // $this->show_column_chart_js();
375 370 $chart_style = true;
376 371 }
377 372
378 373 if ($polls == null) {
@@ -919,14 +914,9 @@
919 914 );
920 915
921 916 $bg_color = $options['bg_color'];
922 917 $bg_image = isset($options['bg_image']) && $options['bg_image'] != '' ? esc_url($options['bg_image']): '';
923 - // if ($bg_image != '') {
924 - // if ( !(filter_var($bg_image, FILTER_VALIDATE_URL) && wp_http_validate_url($bg_image)) ) {
925 - // // invalid URL, handle accordingly
926 - // $bg_image = '';
927 - // }
928 - // }
918 +
929 919 if( $bg_image != "" ){
930 920 $check_if_current_image_exists = Poll_Maker_Ays_Admin::ays_poll_check_if_current_image_exists($bg_image);
931 921
932 922 if( !$check_if_current_image_exists ){
@@ -2477,19 +2467,10 @@
2477 2467
2478 2468 $poll_answer_percentages = array();
2479 2469 $poll_answer_votes = array();
2480 2470 foreach ( $poll['answers'] as $index => $answer ) {
2481 - // if($fake_votes){
2482 - // if(intval( $answer['votes'] ) + intval( $answer['fake_votes'] ) < 0){
2483 - // $poll_answer_votes[$answer['id']] = intval( $answer['votes'] );
2484 - // }
2485 - // else{
2486 - // $poll_answer_votes[$answer['id']] = intval( $answer['votes'] ) + intval( $answer['fake_votes'] );
2487 - // }
2488 - // }
2489 - // else{
2490 - $poll_answer_votes[$answer['id']] = intval( $answer['votes'] );
2491 - // }
2471 +
2472 + $poll_answer_votes[$answer['id']] = intval( $answer['votes'] );
2492 2473 }
2493 2474
2494 2475 $poll_answer_votes_sum = array_sum( $poll_answer_votes );
2495 2476 $poll_answer_percentages = array();
@@ -2498,13 +2479,10 @@
2498 2479 $poll_answer_percentages[$index] = round( ( $answer_vote_count * 100 ) / $poll_answer_votes_sum, 1);
2499 2480 }else{
2500 2481 $poll_answer_percentages[$index] = 0;
2501 2482 }
2502 - }
2483 + }
2503 2484
2504 - // $show_votes_count = isset($options['show_votes_count']) && $options['show_votes_count'] == 1 ? true : false;
2505 - // $show_answer_percent = isset($options['show_res_percent']) && $options['show_res_percent'] == 1 ? true : false;
2506 -
2507 2485 if($poll_allow_multivote){
2508 2486 $content .= "<input type='hidden' id='multivot_answer_count' value='".$multivote_answer_count."'/>";
2509 2487 $content .= $poll_multivote_min_count_content;
2510 2488 }
@@ -2580,29 +2558,14 @@
2580 2558 $answer_votes_count_before_voting = "";
2581 2559 switch ( $show_votes_before_voting_by ) {
2582 2560 case 'by_percentage':
2583 2561 $answer_votes_count_before_voting = $poll_answer_percentages[$answer['id']] . "%";
2584 - // if( $show_votes_count ){
2585 - // $answer_votes_count_before_voting .= " (". intval( $answer['votes'] ) .")";
2586 - // }
2587 2562 break;
2588 2563 default:
2589 2564 $real_votes = isset($answer['votes']) && $answer['votes'] != "" ? intval( $answer['votes'] ) : 0;
2590 - // $fake_votes_all = isset($answer['fake_votes']) && $answer['fake_votes'] != "0" ? intval( $answer['fake_votes'] ) : 0;
2591 - // if($fake_votes){
2592 - // if($real_votes + $fake_votes_all < 0){
2593 - // $answer_votes_count_before_voting = $real_votes;
2594 - // }
2595 - // else{
2596 - // $answer_votes_count_before_voting = $real_votes + $fake_votes_all;
2597 - // }
2598 - // }
2599 - // else{
2600 - $answer_votes_count_before_voting = $real_votes;
2601 - // }
2602 - // if( $show_answer_percent ){
2603 - // $answer_votes_count_before_voting .= " (". $poll_answer_percentages[$answer['id']] . "%" .")";
2604 - // }
2565 +
2566 + $answer_votes_count_before_voting = $real_votes;
2567 +
2605 2568 break;
2606 2569 }
2607 2570
2608 2571 $content .= "
@@ -3071,9 +3034,11 @@
3071 3034 return $poll;
3072 3035 }
3073 3036
3074 3037 private static function get_user_ip() {
3075 - $ipaddress = '';
3038 +
3039 + $ipaddress = false;
3040 +
3076 3041 if (getenv('HTTP_CLIENT_IP')) {
3077 3042 $ipaddress = getenv('HTTP_CLIENT_IP');
3078 3043 } else if (getenv('HTTP_X_FORWARDED_FOR')) {
3079 3044 $ipaddress = getenv('HTTP_X_FORWARDED_FOR');
@@ -3082,15 +3047,20 @@
3082 3047 } else if (getenv('HTTP_FORWARDED_FOR')) {
3083 3048 $ipaddress = getenv('HTTP_FORWARDED_FOR');
3084 3049 } else if (getenv('HTTP_FORWARDED')) {
3085 3050 $ipaddress = getenv('HTTP_FORWARDED');
3086 - } else if (getenv('REMOTE_ADDR')) {
3087 - $ipaddress = getenv('REMOTE_ADDR');
3088 - } else {
3089 - $ipaddress = 'UNKNOWN';
3090 3051 }
3091 3052
3092 - return $ipaddress;
3053 + if ( $ipaddress !== false && filter_var( $ipaddress, FILTER_VALIDATE_IP ) !== false ) {
3054 + return $ipaddress;
3055 + }
3056 +
3057 + $remote_address = getenv('REMOTE_ADDR');
3058 + if ( $remote_address !== false && filter_var( $remote_address, FILTER_VALIDATE_IP ) !== false ) {
3059 + return $remote_address;
3060 + }
3061 +
3062 + return 'UNKNOWN';
3093 3063 }
3094 3064
3095 3065 public static function get_user_ip_validated(){
3096 3066 $headers_to_check = array(
@@ -3174,8 +3144,28 @@
3174 3144
3175 3145 return $result;
3176 3146 }
3177 3147
3148 + public static function get_poll_category_by_ids($ids){
3149 + global $wpdb;
3150 +
3151 + $ids = array_map('intval', explode(',', $ids));
3152 + $ids = array_filter($ids);
3153 +
3154 + if (empty($ids)) {
3155 + return [];
3156 + }
3157 +
3158 + $ids_sql = implode(',', $ids);
3159 +
3160 + $sql = "SELECT *
3161 + FROM {$wpdb->prefix}ayspoll_categories
3162 + WHERE id IN ($ids_sql)
3163 + ORDER BY FIELD(id, $ids_sql)";
3164 +
3165 + return $wpdb->get_results($sql, ARRAY_A);
3166 + }
3167 +
3178 3168 public function get_poll_status($id) {
3179 3169 global $wpdb;
3180 3170 $poll_id = absint(intval($id));
3181 3171 $poll_table = $wpdb->prefix . 'ayspoll_polls';
@@ -3284,8 +3274,22 @@
3284 3274 $poll_answers_count = isset($poll['answers']) ? count($poll['answers']) : 0;
3285 3275 $added_answer_id = array();
3286 3276
3287 3277 $poll_title = (isset($poll['title']) && $poll['title'] != '') ? stripslashes( sanitize_text_field( $poll['title'] ) ) : '';
3278 +
3279 + // Poll category title
3280 + $poll_category_title = "";
3281 +
3282 + $poll_cats = isset( $poll['categories'] ) ? trim( $poll['categories'], ',' ) : '';
3283 + $poll_category_ids = $poll_cats !== '' ? sanitize_text_field( $poll_cats ) : '';
3284 +
3285 + if ( $poll_category_ids != '' ) {
3286 + $categories = self::get_poll_category_by_ids( $poll_category_ids );
3287 + $category_names = wp_list_pluck( $categories, 'title' );
3288 +
3289 + $poll_category_title = implode( ', ', $category_names );
3290 + }
3291 +
3288 3292 $poll_vote_reason_text = "";
3289 3293 $poll_vote_reason = false;
3290 3294 $show_answers_numbering = (isset($options['show_answers_numbering']) && sanitize_text_field( $options['show_answers_numbering'] ) != '') ? sanitize_text_field( $options['show_answers_numbering'] ) : 'none';
3291 3295 if (isset($options['poll_vote_reason']) && $options['poll_vote_reason'] == "on" && isset($_POST['ays-poll-reason-text'])) {
@@ -3642,8 +3646,9 @@
3642 3646 'user_name' => $form_apm_name,
3643 3647 'user_email' => $form_apm_email,
3644 3648 'user_phone' => $form_apm_phone,
3645 3649 'poll_title' => $poll_title,
3650 + 'poll_category_title' => $poll_category_title,
3646 3651 'poll_id' => $poll_id,
3647 3652 'users_first_name' => $user_first_name,
3648 3653 'users_last_name' => $user_last_name,
3649 3654 'creation_date' => $creation_date,