コード例 #1
0
/**
 * check witch rating plugin exist in wp and rate post
 * @param int $postId
 * @param int $rating
 * @param int $user_id
 * @return bool
 */
function wiziapp_do_actual_rating($postId, $rating = 0, $user_id = 0)
{
    $GLOBALS['WiziappLog']->write('info', "Got a rating request with {$postId}::{$rating}::{$user_id}", "wiziapp_do_rating");
    $postId = intval($postId);
    $rating = intval($rating);
    if (filter_var($user_id, FILTER_VALIDATE_IP)) {
        $ip = $user_id;
        $user_id = 0;
    } else {
        $ip = $_SERVER['REMOTE_ADDR'];
        $user_id = intval($user_id);
    }
    if ($rating < 1 && $rating > 5) {
        return false;
    }
    //polldaddy rating
    $id = get_option('pd-rating-posts-id');
    if (function_exists('polldaddy_show_rating_comments') && $id > 0) {
        $url = 'http://polldaddy.com/ratings/rate.php?';
        $url_query = array();
        $url_query['cmd'] = 'get';
        $url_query['id'] = get_option('pd-rating-posts-id');
        $url_query['uid'] = 'wp-post-' . $postId;
        $url_query['item_id'] = '_post_' . $postId;
        $link = $url . http_build_query($url_query);
        $matches = array();
        $get_content = wiziapp_general_http_request('', $link, 'GET');
        $get_content = $get_content['body'];
        preg_match("/\\.token='([a-z0-9]*)/", $get_content, $matches);
        $url_query['token'] = $matches[1];
        preg_match("/\\.avg_rating = ([a-z0-9]*)/", $get_content, $matches);
        $url_query['avg'] = $matches[1];
        preg_match("/\\.votes = ([a-z0-9]*)/", $get_content, $matches);
        $url_query['votes'] = $matches[1];
        $post = get_post($postId);
        $url_query['title'] = str_replace('&amp;', '&', $post->post_title);
        $url_query['permalink'] = $post->guid;
        $url_query['type'] = 'stars';
        $url_query['cmd'] = 'rate';
        $url_query['r'] = $rating;
        $link = $url . http_build_query($url_query);
        wiziapp_general_http_request('', $link, 'GET');
        return true;
    }
    //GD Star rating
    global $gdsr;
    if (is_object($gdsr) && get_class($gdsr) == 'GDStarRating') {
        $ua = $_SERVER["HTTP_USER_AGENT"];
        gdsrBlgDB::save_vote($postId, $user_id, $ip, $ua, $rating);
        gdsrFrontHelp::save_cookie($postId);
        do_action("gdsr_vote_rating_article", $postId, $user_id, $rating);
        return true;
    }
    //WP-PostRatings
    if (function_exists('process_ratings') && $postId > 0 && $user_id > 0) {
        $_GET['rate'] = $rating;
        $_GET['pid'] = $postId;
        global $user_ID;
        $user_ID = $user_id;
        process_ratings();
        return true;
    }
    return false;
}
コード例 #2
0
 function render_multi_rating_actual($settings)
 {
     if ($this->g->is_bot && $this->g->o["bot_message"] != "normal") {
         return GDSRRender::render_locked_response($this->g->o["bot_message"]);
     }
     $rd_post_id = intval($settings[1]);
     $rd_is_page = intval($settings[2]);
     $post_author = intval($settings[3]);
     $post_date = intval($settings[4]);
     $override["id"] = intval($settings[11]);
     $override["tpl"] = intval($settings[5]);
     $override["read_only"] = intval($settings[6]);
     $override["size"] = intval($settings[7]);
     $override["style"] = $this->g->g->stars[$settings[8]]->folder;
     $override["style_ie6"] = $this->g->g->stars[$settings[9]]->folder;
     $rd_user_id = intval($settings[10]);
     $override["average_size"] = intval($settings[12]);
     $override["average_stars"] = $this->g->g->stars[$settings[13]]->folder;
     $override["average_stars_ie6"] = $this->g->g->stars[$settings[14]]->folder;
     $set = gd_get_multi_set($override["id"]);
     if ($set == null) {
         return "";
     }
     $rd_unit_width = $override["size"];
     $rd_unit_style = $this->g->is_ie6 ? $override["style_ie6"] : $override["style"];
     $rd_unit_width_avg = $override["average_size"];
     $rd_unit_style_avg = $this->g->is_ie6 ? $override["average_stars_ie6"] : $override["average_stars"];
     $dbg_allow = "F";
     $already_voted = false;
     $allow_vote = $override["read_only"] == 0;
     $allow_vote = apply_filters("gdsr_allow_vote_stars_article", $allow_vote, $rd_post_id, $override["id"]);
     if ($this->g->override_readonly_multis) {
         $allow_vote = false;
         $dbg_allow = "RTO";
     }
     if ($this->g->is_ban && $this->g->o["ip_filtering"] == 1) {
         if ($this->g->o["ip_filtering_restrictive"] == 1) {
             return "";
         } else {
             $allow_vote = false;
         }
         $dbg_allow = "B";
     }
     if ($override["read_only"] == 1) {
         $dbg_allow = "RO";
     }
     $remaining = 0;
     $deadline = "";
     $post_data = wp_gdget_post($rd_post_id);
     if (!is_object($post_data)) {
         GDSRDatabase::add_default_vote($rd_post_id, $rd_is_page);
         $post_data = wp_gdget_post($rd_post_id);
         $this->g->c[$rd_post_id] = 1;
     }
     $rules_articles = $post_data->rules_articles != "I" ? $post_data->rules_articles : $this->g->get_post_rule_value($rd_post_id, "rules_articles", "default_voterules_articles");
     if ($rules_articles == "H") {
         return "";
     }
     if ($allow_vote) {
         if ($this->g->o["author_vote"] == 1 && $rd_user_id == $post_author) {
             $allow_vote = false;
             $dbg_allow = "A";
         }
     }
     if ($allow_vote) {
         if ($rules_articles == "" || $rules_articles == "A" || $rules_articles == "U" && $rd_user_id > 0 || $rules_articles == "V" && $rd_user_id == 0) {
             $allow_vote = true;
         } else {
             $allow_vote = false;
             $dbg_allow = "R_" . $rules_articles;
         }
     }
     $remaining = 0;
     $deadline = '';
     $expiry_type = 'N';
     if ($allow_vote && ($post_data->expiry_type == 'D' || $post_data->expiry_type == 'T' || $post_data->expiry_type == 'I')) {
         $expiry_type = $post_data->expiry_type != 'I' ? $post_data->expiry_type : $this->g->get_post_rule_value($rd_post_id, "expiry_type", "default_timer_type");
         $expiry_value = $post_data->expiry_type != 'I' ? $post_data->expiry_value : $this->g->get_post_rule_value($rd_post_id, "expiry_value", "default_timer_value");
         switch ($expiry_type) {
             case "D":
                 $remaining = gdsrFrontHelp::expiration_date($expiry_value);
                 $deadline = $expiry_value;
                 break;
             case "T":
                 $remaining = gdsrFrontHelp::expiration_countdown($post_date, $expiry_value);
                 $deadline = gdsrFrontHelp::calculate_deadline($remaining);
                 break;
         }
         if ($remaining < 1) {
             gdsrBlgDB::lock_post($rd_post_id);
             $allow_vote = false;
             $dbg_allow = "T";
         }
     }
     $already_voted = !GDSRDBMulti::check_vote($rd_post_id, $rd_user_id, $set->multi_id, 'multis', $_SERVER["REMOTE_ADDR"], $this->g->o["logged"] != 1, $this->g->o["mur_allow_mixed_ip_votes"] == 1);
     if ($allow_vote) {
         $allow_vote = !$already_voted;
         if (!$allow_vote) {
             $dbg_allow = "D";
         }
     }
     if ($allow_vote) {
         $allow_vote = gdsrFrontHelp::check_cookie($rd_post_id . "#" . $set->multi_id, "multis");
         if (!$allow_vote) {
             $dbg_allow = "C";
         }
     }
     $multi_record_id = GDSRDBMulti::get_vote($rd_post_id, $set->multi_id, count($set->object));
     $multi_data = GDSRDBMulti::get_values($multi_record_id);
     $votes = array();
     foreach ($multi_data as $md) {
         $single_vote = array();
         $single_vote["votes"] = 0;
         $single_vote["score"] = 0;
         if ($rules_articles == "A" || $rules_articles == "N") {
             $single_vote["votes"] = $md->user_voters + $md->visitor_voters;
             $single_vote["score"] = $md->user_votes + $md->visitor_votes;
         } else {
             if ($rules_articles == "V") {
                 $single_vote["votes"] = $md->visitor_voters;
                 $single_vote["score"] = $md->visitor_votes;
             } else {
                 $single_vote["votes"] = $md->user_voters;
                 $single_vote["score"] = $md->user_votes;
             }
         }
         $rating = $single_vote["votes"] > 0 ? $single_vote["score"] / $single_vote["votes"] : 0;
         if ($rating > $set->stars) {
             $rating = $set->stars;
         }
         $single_vote["rating"] = @number_format($rating, 1);
         $votes[] = $single_vote;
     }
     $debug = $rd_user_id == 0 ? "V" : "U";
     $debug .= $rd_user_id == $post_author ? "A" : "N";
     $debug .= ":" . $dbg_allow . " [" . STARRATING_VERSION . "]";
     $tags_css = array("MUR_CSS_BUTTON" => $this->g->o["mur_class_button"], "MUR_CSS_BLOCK" => $this->g->o["mur_class_block"], "MUR_CSS_HEADER" => $this->g->o["mur_class_header"], "MUR_CSS_STARS" => $this->g->o["mur_class_stars"], "MUR_CSS_TEXT" => $this->g->o["mur_class_text"]);
     $mur_button = $this->g->o["mur_button_active"] == 1;
     if (!$allow_vote) {
         $mur_button = false;
     }
     $template_id = $override["tpl"];
     return GDSRRenderT2::render_mrb($template_id, array("already_voted" => $already_voted, "style" => $rd_unit_style, "allow_vote" => $allow_vote, "votes" => $votes, "post_id" => $rd_post_id, "set" => $set, "height" => $rd_unit_width, "header_text" => $this->g->o["mur_header_text"], "tags_css" => $tags_css, "avg_style" => $rd_unit_style_avg, "avg_size" => $rd_unit_width_avg, "star_factor" => 1, "time_restirctions" => $expiry_type, "time_remaining" => $remaining, "time_date" => $deadline, "button_active" => $mur_button, "button_text" => $this->g->o["mur_button_text"], "debug" => $debug, "wait_msg" => $this->loader_multis));
 }
コード例 #3
0
ファイル: votes.php プロジェクト: hewu/blogwp
 function vote_comment($votes, $id, $tpl_id, $unit_width)
 {
     global $userdata;
     $user = is_object($userdata) ? $userdata->ID : 0;
     $ip = $_SERVER["REMOTE_ADDR"];
     if ($this->g->o["save_user_agent"] == 1) {
         $ua = $_SERVER["HTTP_USER_AGENT"];
     } else {
         $ua = "";
     }
     $vote_value = $votes;
     wp_gdsr_dump("VOTE_CMM", "[CMM: " . $id . "] --" . $votes . "-- [" . $user . "] " . $unit_width . "px");
     $allow_vote = intval($votes) <= $this->g->o["cmm_stars"] && intval($votes) > 0;
     if ($allow_vote) {
         $allow_vote = gdsrFrontHelp::check_cookie($id, 'comment');
     }
     if ($allow_vote) {
         $allow_vote = gdsrBlgDB::check_vote($id, $user, 'comment', $ip, $this->g->o["cmm_logged"] != 1, $this->g->o["cmm_allow_mixed_ip_votes"] == 1);
     }
     if ($allow_vote) {
         gdsrBlgDB::save_vote_comment($id, $user, $ip, $ua, $votes);
         gdsrFrontHelp::save_cookie($id, 'comment');
         do_action("gdsr_vote_rating_comment", $id, $user, $votes);
     }
     $data = GDSRDatabase::get_comment_data($id);
     $post_data = GDSRDatabase::get_post_data($data->post_id);
     $unit_count = $this->g->o["cmm_stars"];
     $votes = $score = 0;
     if ($post_data->rules_comments == "A" || $post_data->rules_comments == "N") {
         $votes = $data->user_voters + $data->visitor_voters;
         $score = $data->user_votes + $data->visitor_votes;
     } else {
         if ($post_data->rules_comments == "V") {
             $votes = $data->visitor_voters;
             $score = $data->visitor_votes;
         } else {
             $votes = $data->user_voters;
             $score = $data->user_votes;
         }
     }
     if ($votes > 0) {
         $rating2 = $score / $votes;
     } else {
         $rating2 = 0;
     }
     $rating1 = @number_format($rating2, 1);
     $rating_width = number_format($rating2 * $unit_width, 0);
     include STARRATING_PATH . 'code/t2/templates.php';
     $template = new gdTemplateRender($tpl_id, "CRB");
     $rt = GDSRRenderT2::render_crt($template->dep["CRT"], array("rating" => $rating1, "unit_count" => $unit_count, "votes" => $votes, "vote_value" => $vote_value));
     $rating_width = apply_filters("gdsr_vote_rating_comment_return", $rating_width, $unit_width, $rating1, $vote_value);
     return '{ "status": "ok", "value": "' . $rating_width . '", "rater": "' . str_replace('"', '\\"', $rt) . '" }';
 }
コード例 #4
0
ファイル: class.php プロジェクト: TheReaCompany/pooplog
 /**
  * WordPress action for adding blog header contents
  */
 function wp_head()
 {
     if (is_feed()) {
         return;
     }
     $this->wp_head_javascript();
     $include_cmm_review = $this->o["comments_review_active"] == 1;
     $include_mur_rating = $this->o["multis_active"] == 1;
     if ($this->o["external_rating_css"] == 0) {
         $this->include_rating_css(false);
     }
     if ($this->o["debug_wpquery"] == 1) {
         global $wp_query;
         wp_gdsr_dump("WP_QUERY", $wp_query->request);
     }
     $this->custom_actions('wp_head');
     if ($this->o["ie_opacity_fix"] == 1) {
         gdsrFrontHelp::ie_opacity_fix();
     }
 }
コード例 #5
0
ファイル: render.php プロジェクト: TheReaCompany/pooplog
 function render_srt($template, $rpar = array())
 {
     $rdef = array("rating" => 0, "unit_count" => 0, "votes" => 0, "id" => 0, "time_restirctions" => "N", "time_remaining" => 0, "time_date" => "");
     $rpar = wp_parse_args($rpar, $rdef);
     $rpar = apply_filters('gdsr_t2parameters_srt', $rpar);
     extract($rpar, EXTR_SKIP);
     if (($time_restirctions == 'D' || $time_restirctions == 'T') && $time_remaining > 0) {
         $time_parts = gdsrFrontHelp::remaining_time_parts($time_remaining);
         $time_total = gdsrFrontHelp::remaining_time_total($time_remaining);
         $tpl = $template->elm["time_active"];
         $rt = html_entity_decode($tpl);
         $rt = str_replace('%TR_DATE%', $time_date, $rt);
         $rt = str_replace('%TR_YEARS%', $time_parts["year"], $rt);
         $rt = str_replace('%TR_MONTHS%', $time_parts["month"], $rt);
         $rt = str_replace('%TR_DAYS%', $time_parts["day"], $rt);
         $rt = str_replace('%TR_HOURS%', $time_parts["hour"], $rt);
         $rt = str_replace('%TR_MINUTES%', $time_parts["minute"], $rt);
         $rt = str_replace('%TR_SECONDS%', $time_parts["second"], $rt);
         $rt = str_replace('%TOT_DAYS%', $time_total["day"], $rt);
         $rt = str_replace('%TOT_HOURS%', $time_total["hour"], $rt);
         $rt = str_replace('%TOT_MINUTES%', $time_total["minute"], $rt);
     } else {
         if ($time_restirctions == 'D' || $time_restirctions == 'T') {
             $tpl = $template->elm["time_closed"];
         } else {
             $tpl = $template->elm["normal"];
         }
         $rt = html_entity_decode($tpl);
     }
     $rt = str_replace('%RATING%', apply_filters('gdsr_t2_tag_value', $rating, "SRT", "%RATING%"), $rt);
     $rt = str_replace('%VOTES%', apply_filters('gdsr_t2_tag_value', $votes, "SRT", "%VOTES%"), $rt);
     $rt = str_replace('%MAX_RATING%', $unit_count, $rt);
     $rt = str_replace('%ID%', $id, $rt);
     $word_votes = $template->dep["EWV"];
     $tense = $votes == 1 ? $word_votes->elm["singular"] : $word_votes->elm["plural"];
     $rt = str_replace('%WORD_VOTES%', __($tense), $rt);
     return $rt;
 }
コード例 #6
0
ファイル: render.php プロジェクト: sangpena/appflex.mobi
 function render_srt($template, $rpar = array())
 {
     $rdef = array('rating' => 0, 'unit_count' => 0, 'votes' => 0, 'id' => 0, 'time_restirctions' => 'N', 'time_remaining' => 0, 'time_date' => '');
     $rpar = wp_parse_args($rpar, $rdef);
     $rpar = apply_filters('gdsr_t2parameters_srt', $rpar);
     extract($rpar, EXTR_SKIP);
     if (($time_restirctions == 'D' || $time_restirctions == 'T') && $time_remaining > 0) {
         $time_parts = gdsrFrontHelp::remaining_time_parts($time_remaining);
         $time_total = gdsrFrontHelp::remaining_time_total($time_remaining);
         $tpl = $template->elm['time_active'];
         $rt = html_entity_decode($tpl);
         $rt = str_replace('%TR_DATE%', $time_date, $rt);
         $rt = str_replace('%TR_YEARS%', $time_parts['year'], $rt);
         $rt = str_replace('%TR_MONTHS%', $time_parts['month'], $rt);
         $rt = str_replace('%TR_DAYS%', $time_parts['day'], $rt);
         $rt = str_replace('%TR_HOURS%', $time_parts['hour'], $rt);
         $rt = str_replace('%TR_MINUTES%', $time_parts['minute'], $rt);
         $rt = str_replace('%TR_SECONDS%', $time_parts['second'], $rt);
         $rt = str_replace('%TOT_DAYS%', $time_total['day'], $rt);
         $rt = str_replace('%TOT_HOURS%', $time_total['hour'], $rt);
         $rt = str_replace('%TOT_MINUTES%', $time_total['minute'], $rt);
     } else {
         if ($time_restirctions == 'D' || $time_restirctions == 'T') {
             $tpl = $template->elm['time_closed'];
         } else {
             $tpl = $template->elm['normal'];
         }
         $rt = html_entity_decode($tpl);
     }
     $rt = str_replace('%RATING%', apply_filters('gdsr_t2_tag_value', $rating, 'SRT', '%RATING%'), $rt);
     $rt = str_replace('%VOTES%', apply_filters('gdsr_t2_tag_value', $votes, 'SRT', '%VOTES%'), $rt);
     $rt = str_replace('%ID%', $id, $rt);
     $rt = str_replace('%MAX_RATING%', $unit_count, $rt);
     $word_votes = $template->dep['EWV'];
     $tense = $votes == 1 ? $word_votes->elm['singular'] : $word_votes->elm['plural'];
     $rt = str_replace('%WORD_VOTES%', __($tense), $rt);
     return $rt;
 }