Example #1
0
 function save_vote_comment_thumb($id, $user, $ip, $ua, $vote)
 {
     global $wpdb, $table_prefix;
     $ua = str_replace("'", "''", $ua);
     $ua = substr($ua, 0, 250);
     $post = $wpdb->get_row("select comment_post_ID from {$wpdb->comments} where comment_ID = " . $id);
     $post_id = $post->comment_post_ID;
     $sql = sprintf("SELECT * FROM %sgdsr_data_article WHERE post_id = %s", $table_prefix, $post_id);
     $post_data = $wpdb->get_row($sql);
     if ($post_data->moderate_comments == "" || $post_data->moderate_comments == "N" || $post_data->moderate_comments == "V" && $user > 0 || $post_data->moderate_comments == "U" && $user == 0) {
         gdsrBlgDB::add_vote_comment_thumb($id, $user, $ip, $ua, $vote);
     } else {
         $modsql = sprintf("INSERT INTO %sgdsr_moderate (id, vote_type, user_id, vote, voted, ip, user_agent) VALUES (%s, 'cmmthumb', %s, %s, '%s', '%s', '%s')", $table_prefix, $id, $user, $vote, str_replace("'", "''", current_time('mysql')), $ip, $ua);
         $wpdb->query($modsql);
     }
 }