function ratings_shortcode($atts)
{
    $attributes = shortcode_atts(array('id' => 0, 'results' => false), $atts);
    if (!is_feed()) {
        $id = intval($attributes['id']);
        if ($attributes['results']) {
            return the_ratings_results($id);
        } else {
            return the_ratings('span', $id, false);
        }
    } else {
        return __('Note: There is a rating embedded within this post, please visit this post to rate it.', 'wp-postratings');
    }
}
 /**
  * Parses content tags
  *
  * @since	1.4.6
  * @param	string	HTML string with content tags
  * @param	array	Post data
  * @param	bool	Used to display post rating (if functionality is available)
  * @return	string
  */
 private function __format_content($string, $data = array(), $rating)
 {
     if (empty($string) || (empty($data) || !is_array($data))) {
         return false;
     }
     $params = array();
     $pattern = '/\\{(excerpt|summary|stats|title|image|thumb|thumb_img|rating|score|url|text_title|author|category|views|comments|date)\\}/i';
     preg_match_all($pattern, $string, $matches);
     array_map('strtolower', $matches[0]);
     if (in_array("{title}", $matches[0])) {
         $string = str_replace("{title}", $data['title'], $string);
     }
     if (in_array("{stats}", $matches[0])) {
         $string = str_replace("{stats}", $data['stats'], $string);
     }
     if (in_array("{excerpt}", $matches[0]) || in_array("{summary}", $matches[0])) {
         $string = str_replace(array("{excerpt}", "{summary}"), $data['summary'], $string);
     }
     if (in_array("{image}", $matches[0]) || in_array("{thumb}", $matches[0])) {
         $string = str_replace(array("{image}", "{thumb}"), $data['img'], $string);
     }
     if (in_array("{thumb_img}", $matches[0])) {
         $string = str_replace("{thumb_img}", $data['img_no_link'], $string);
     }
     // WP-PostRatings check
     if ($rating) {
         if (function_exists('the_ratings_results') && in_array("{rating}", $matches[0])) {
             $string = str_replace("{rating}", the_ratings_results($data['id']), $string);
         }
         if (function_exists('expand_ratings_template') && in_array("{score}", $matches[0])) {
             $string = str_replace("{score}", expand_ratings_template('%RATINGS_SCORE%', $data['id']), $string);
             // removing the redundant plus sign
             $string = str_replace('+', '', $string);
         }
     }
     if (in_array("{url}", $matches[0])) {
         $string = str_replace("{url}", $data['url'], $string);
     }
     if (in_array("{text_title}", $matches[0])) {
         $string = str_replace("{text_title}", $data['text_title'], $string);
     }
     if (in_array("{author}", $matches[0])) {
         $string = str_replace("{author}", $data['author'], $string);
     }
     if (in_array("{category}", $matches[0])) {
         $string = str_replace("{category}", $data['category'], $string);
     }
     if (in_array("{views}", $matches[0])) {
         $string = str_replace("{views}", $data['views'], $string);
     }
     if (in_array("{comments}", $matches[0])) {
         $string = str_replace("{comments}", $data['comments'], $string);
     }
     if (in_array("{date}", $matches[0])) {
         $string = str_replace("{date}", $data['date'], $string);
     }
     return $string;
 }
function get_most_rated_events($mode = '', $min_votes = 0, $limit = 10, $chars = 0, $display = true)
{
    global $wpdb;
    $ratings_max = intval(get_option('postratings_max'));
    $ratings_custom = intval(get_option('postratings_customrating'));
    $output = '';
    if (!empty($mode) && $mode != 'both') {
        $where = "{$wpdb->posts}.post_type = '{$mode}'";
    } else {
        $where = '1=1';
    }
    if ($ratings_custom && $ratings_max == 2) {
        $order_by = 'ratings_score';
    } else {
        $order_by = 'ratings_average';
    }
    $temp2 = $temp3 = $temp4 = '';
    $post_id = "%POST_URL%";
    $temp = '<li>';
    $temp3 .= '<div class="main_event_widget_container">
	<a href="%POST_URL%" title="%POST_TITLE%">%POST_TITLE%</a>';
    $temp2 .= '</div><div class="right_event_widget_container">
	<a href="%POST_URL%" class="icon-play-1" title="%POST_TITLE%">';
    $temp4 .= '</a>
	<a href="%POST_URL%' . '#tickets' . '" class="icon-ticket" title="%POST_TITLE%"></a></div>
	</li>';
    $most_rated = $wpdb->get_results("SELECT DISTINCT {$wpdb->posts}.*, (t1.meta_value+0.00) AS ratings_average, (t2.meta_value+0.00) AS ratings_users, (t3.meta_value+0.00) AS ratings_score FROM {$wpdb->posts} LEFT JOIN {$wpdb->postmeta} AS t1 ON t1.post_id = {$wpdb->posts}.ID LEFT JOIN {$wpdb->postmeta} As t2 ON t1.post_id = t2.post_id LEFT JOIN {$wpdb->postmeta} AS t3 ON t3.post_id = {$wpdb->posts}.ID WHERE t1.meta_key = 'ratings_average' AND t2.meta_key = 'ratings_users' AND t3.meta_key = 'ratings_score' AND {$wpdb->posts}.post_password = '' AND {$wpdb->posts}.post_date < '" . current_time('mysql') . "' AND {$wpdb->posts}.post_status = 'publish' AND t2.meta_value >= {$min_votes} AND {$where} ORDER BY ratings_users DESC, {$order_by} DESC LIMIT {$limit}");
    if ($most_rated) {
        $i = 1;
        foreach ($most_rated as $post) {
            $output .= expand_ratings_template($temp, $post, null, $chars, false);
            if ($i == 10) {
                $output .= '<span class="event_widget_number last">' . $i . '</span>';
            } else {
                $output .= '<span class="event_widget_number">' . $i . '</span>';
            }
            $post_id = url_to_postid(expand_ratings_template($post_id, $post, null, $chars, false));
            $output .= expand_ratings_template($temp3, $post, null, $chars, false);
            if (function_exists('the_ratings')) {
                $rating_images = substr_replace(the_ratings_results($post->ID), '', strlen(the_ratings_results($post->ID)) - 5);
                $rating_value = number_format(floatval(substr(the_ratings_results(get_the_ID()), strlen(the_ratings_results(get_the_ID())) - 5)), 1);
                if ($rating_value < 10) {
                    $rating_value = ' ' . $rating_value;
                }
                $output .= '<div class="event_list_rating">' . $rating_images . $rating_value . '</div>';
            }
            $output .= expand_ratings_template($temp2, $post, null, $chars, false);
            $youtube = explode('=', get_post_meta($post->ID, 'event_trailer', true));
            if ($youtube[0] != '') {
                $youtube_url = $youtube['1'];
            } else {
                $youtube_url = '';
            }
            $output .= '<input type="hidden" value="' . $youtube_url . '"></input>';
            $output .= expand_ratings_template($temp4, $post, null, $chars, false) . "\n";
            $i++;
        }
    } else {
        $output = '<li>' . __('N/A', 'vh') . '</li>' . "\n";
    }
    if ($display) {
        echo $output;
    } else {
        return $output;
    }
}
     }
     // ToDo: break, if rated comment
 }
 //echo "<br>-B-";
 $deact = '<span class="active">' . $txt_subscr_active . '</span>';
 if (strpos($a_subscription->status, "C") != false) {
     $deact = '<span class="warning">' . $txt_subscr_inactive . '</span>';
 }
 //echo "<li><label for='post_{$a_subscription->post_id}'><input type='checkbox' name='post_list[]' value='{$a_subscription->post_id}' id='post_{$a_subscription->post_id}'/> <span class='subscribe-column-1'>$a_subscription->dt</span> <span class='subscribe-separator subscribe-separator-1'>&mdash;</span> <span class='subscribe-column-2'>{$a_subscription->status}</span> <span class='subscribe-separator subscribe-separator-2'>&mdash;</span> <a class='subscribe-column-3' href='$permalink'>$title</a></label></li>\n";
 echo "<tr id=\"regcont\">\n\n\n                        <td id=\"col1\">&nbsp;";
 //                        <center><label id=\"registration\" for='post_{$a_subscription->post_id}'>
 //                        <input type='checkbox' name='post_list[]' value='{$a_subscription->post_id}' id='post_{$a_subscription->post_id}'/>
 //                        </center>
 echo "</td>";
 // list HW entry
 $rating = the_ratings_results($a_subscription->post_id, 0, 0, 0, 10);
 $commenttext = "";
 if ($comment_excerpt != "") {
     $commenttext = '<div class="hwprofile-cite"><i>"' . wp_strip_all_tags($comment_excerpt) . '"</i> (<a href="' . $permalink . '#comment-' . $CID . '">' . $txt_subscr_more . '</a>)</div>';
 }
 echo "\n                        <td id=\"col-hw\"> <a class='subscribe-column-3' href='{$permalink}'>{$art_image}</a>\n\n                        " . '<div class="subscribe-hwtext"><div class="subscribe-hwtext-span"><a href=' . $permalink . '>' . $title . '</a><br>' . $rating . '<br>' . $commenttext . '</div></div></label>
             
             </td>';
 /*
 echo "
                         <td id=\"col-hw\"> <a class='subscribe-column-3' href='$permalink'>$art_image</a>
 
                         ".'<div class="subscribe-hwtext"><span class="subscribe-hwtext-span"><a href='.$permalink.'>'.$title.'</a><br>'.$rating.'</span></div></label>
                         </td>';
 
                         //<td id=\"col4\">
示例#5
0
function process_ratings()
{
    global $wpdb, $user_identity, $user_ID;
    if (isset($_REQUEST['action']) && $_REQUEST['action'] == 'postratings') {
        $rate = intval($_REQUEST['rate']);
        $post_id = intval($_REQUEST['pid']);
        // Verify Referer
        if (!check_ajax_referer('postratings_' . $post_id . '-nonce', 'postratings_' . $post_id . '_nonce', false)) {
            _e('Failed To Verify Referrer', 'wp-postratings');
            exit;
        }
        if ($rate > 0 && $post_id > 0 && check_allowtorate()) {
            // Check For Bot
            $bots_useragent = array('googlebot', 'google', 'msnbot', 'ia_archiver', 'lycos', 'jeeves', 'scooter', 'fast-webcrawler', 'slurp@inktomi', 'turnitinbot', 'technorati', 'yahoo', 'findexa', 'findlinks', 'gaisbo', 'zyborg', 'surveybot', 'bloglines', 'blogsearch', 'ubsub', 'syndic8', 'userland', 'gigabot', 'become.com');
            $useragent = $_SERVER['HTTP_USER_AGENT'];
            foreach ($bots_useragent as $bot) {
                if (stristr($useragent, $bot) !== false) {
                    return;
                }
            }
            header('Content-Type: text/html; charset=' . get_option('blog_charset') . '');
            postratings_textdomain();
            $rated = check_rated($post_id);
            // Check Whether Post Has Been Rated By User
            if (!$rated) {
                // Check Whether Is There A Valid Post
                $post = get_post($post_id);
                // If Valid Post Then We Rate It
                if ($post && !wp_is_post_revision($post)) {
                    $ratings_max = intval(get_option('postratings_max'));
                    $ratings_custom = intval(get_option('postratings_customrating'));
                    $ratings_value = get_option('postratings_ratingsvalue');
                    $post_title = addslashes($post->post_title);
                    $post_ratings = get_post_custom($post_id);
                    $post_ratings_users = !empty($post_ratings['ratings_users']) ? intval($post_ratings['ratings_users'][0]) : 0;
                    $post_ratings_score = !empty($post_ratings['ratings_score']) ? intval($post_ratings['ratings_score'][0]) : 0;
                    // Check For Ratings Lesser Than 1 And Greater Than $ratings_max
                    if ($rate < 1 || $rate > $ratings_max) {
                        $rate = 0;
                    }
                    $post_ratings_users = $post_ratings_users + 1;
                    $post_ratings_score = $post_ratings_score + intval($ratings_value[$rate - 1]);
                    $post_ratings_average = round($post_ratings_score / $post_ratings_users, 2);
                    update_post_meta($post_id, 'ratings_users', $post_ratings_users);
                    update_post_meta($post_id, 'ratings_score', $post_ratings_score);
                    update_post_meta($post_id, 'ratings_average', $post_ratings_average);
                    // Add Log
                    if (!empty($user_identity)) {
                        $rate_user = addslashes($user_identity);
                    } elseif (!empty($_COOKIE['comment_author_' . COOKIEHASH])) {
                        $rate_user = addslashes($_COOKIE['comment_author_' . COOKIEHASH]);
                    } else {
                        $rate_user = __('Guest', 'wp-postratings');
                    }
                    $rate_user = apply_filters('wp_postratings_process_ratings_user', $rate_user);
                    $rate_userid = apply_filters('wp_postratings_process_ratings_userid', intval($user_ID));
                    // Only Create Cookie If User Choose Logging Method 1 Or 3
                    $postratings_logging_method = intval(get_option('postratings_logging_method'));
                    if ($postratings_logging_method == 1 || $postratings_logging_method == 3) {
                        $rate_cookie = setcookie("rated_" . $post_id, $ratings_value[$rate - 1], time() + 30000000, apply_filters('wp_postratings_cookiepath', SITECOOKIEPATH));
                    }
                    // Log Ratings No Matter What
                    $rate_log = $wpdb->query($wpdb->prepare("INSERT INTO {$wpdb->ratings} VALUES (%d, %d, %s, %d, %d, %s, %s, %s, %d )", 0, $post_id, $post_title, $ratings_value[$rate - 1], current_time('timestamp'), get_ipaddress(), @gethostbyaddr(get_ipaddress()), $rate_user, $rate_userid));
                    // Allow Other Plugins To Hook When A Post Is Rated
                    do_action('rate_post', $rate_userid, $post_id, $ratings_value[$rate - 1]);
                    // Output AJAX Result
                    echo the_ratings_results($post_id, $post_ratings_users, $post_ratings_score, $post_ratings_average);
                    exit;
                } else {
                    printf(__('Invalid Post ID. Post ID #%s.', 'wp-postratings'), $post_id);
                    exit;
                }
                // End if($post)
            } else {
                printf(__('You Had Already Rated This Post. Post ID #%s.', 'wp-postratings'), $post_id);
                exit;
            }
            // End if(!$rated)
        }
        // End if($rate && $post_id && check_allowtorate())
    }
    // End if(isset($_REQUEST['action']) && $_REQUEST['action'] == 'postratings')
}
示例#6
0
 }
 $comment = $a_identified_hw->usercomment;
 $url = $a_identified_hw->url;
 $id = $a_identified_hw->id;
 #$category_ids[1]->cat_name = ""; #overwrite old values
 $category_ids = get_the_category($postid);
 $category_name = $category_ids[0]->cat_name;
 #$category_name2 = "";
 $category_name2 = $category_ids[1]->cat_name;
 # --- Registered users
 global $wpdb;
 $usernum = $wpdb->get_var("SELECT COUNT(*) FROM {$wpdb->postmeta} WHERE meta_key LIKE '\\_stcr@\\_%' AND post_id = " . $postid);
 // list HW entry
 #$commenttext = "";
 #if ($comment_excerpt != "") $commenttext='<div class="hwprofile-cite"><i>"'.wp_strip_all_tags($comment_excerpt).'"</i> <br>(<a href="'.$permalink.'#comment-'.$CID.'">'.$txt_subscr_more.'</a> - <a href="/wp-admin/comment.php?action=editcomment&c='.$CID.'">'.$txt_subscr_edit_comment.'</a>)</div>';
 $rating = the_ratings_results($postid, 0, 0, 0, 10);
 if (count($postids) > $multilimit) {
     #small version, no image
     echo "\n        \t                <td id=\"col-hw\"> \n                        \t" . '<div class="subscribe-hwtext"><div class="subscribe-hwtext-span-scan-small"><a href=' . $permalink . ' target="_blank">' . $short_title . '</a></div></div>' . $title_part2 . '</label>' . "<span class='subscribe-column-23-small'>{$rating}</span>";
     print " </td>";
 } else {
     echo "\n                        <td id=\"col-hw\"> <a class='hwscan-found-image' href='{$permalink}' target='_blank' >{$art_image}</a>\n\n                        " . '<div class="subscribe-hwtext"><div class="subscribe-hwtext-span-scan"><a href=' . $permalink . ' target="_blank">' . $short_title . '</a></div></div>' . $title_part2 . '</label>' . "<span class='subscribe-column-23'>{$rating}</span>";
     print " </td>";
 }
 //<td id=\"col4\">
 //<span class='subscribe-column-2'>$deact<br>({$a_subscription->status})</span>
 //</td>
 // --- Add to HW profile
 if ($userknown == 1) {
     $hwbutton = lhg_add_hwbutton($email, $a_identified_hw->postid);
     #$hwbutton = "Test";
 function format_content($string, $data = array(), $rating)
 {
     if (empty($string) || (empty($data) || !is_array($data))) {
         return false;
     }
     $params = array();
     $pattern = '/\\{(summary|stats|title|image|rating)\\}/i';
     preg_match_all($pattern, $string, $matches);
     for ($i = 0; $i < count($matches[0]); $i++) {
         if (strtolower($matches[0][$i]) == "{title}") {
             $params[$matches[0][$i]] = $data['title'];
             continue;
         }
         if (strtolower($matches[0][$i]) == "{stats}") {
             $params[$matches[0][$i]] = $data['stats'];
             continue;
         }
         if (strtolower($matches[0][$i]) == "{summary}") {
             $params[$matches[0][$i]] = $data['summary'];
             continue;
         }
         if (strtolower($matches[0][$i]) == "{image}") {
             $params[$matches[0][$i]] = $data['img'];
             continue;
         }
         // WP-PostRatings check
         if ($rating) {
             if (strtolower($matches[0][$i]) == "{rating}") {
                 $params[$matches[0][$i]] = the_ratings_results($data['id']);
                 continue;
             }
         }
     }
     for ($i = 0; $i < count($params); $i++) {
         $string = str_replace($matches[0][$i], $params[$matches[0][$i]], $string);
     }
     return $string;
 }
function process_ratings()
{
    global $wpdb, $user_identity, $user_ID;
    $rate = intval($_GET['rate']);
    $post_id = intval($_GET['pid']);
    if ($rate > 0 && $post_id > 0 && check_allowtorate()) {
        // Check For Bot
        $bots_useragent = array('googlebot', 'google', 'msnbot', 'ia_archiver', 'lycos', 'jeeves', 'scooter', 'fast-webcrawler', 'slurp@inktomi', 'turnitinbot', 'technorati', 'yahoo', 'findexa', 'findlinks', 'gaisbo', 'zyborg', 'surveybot', 'bloglines', 'blogsearch', 'ubsub', 'syndic8', 'userland', 'gigabot', 'become.com');
        $useragent = $_SERVER['HTTP_USER_AGENT'];
        foreach ($bots_useragent as $bot) {
            if (stristr($useragent, $bot) !== false) {
                return;
            }
        }
        header('Content-Type: text/html; charset=' . get_option('blog_charset') . '');
        postratings_textdomain();
        $rated = check_rated($post_id);
        // Check Whether Post Has Been Rated By User
        if (!$rated) {
            // Check Whether Is There A Valid Post
            $post = get_post($post_id);
            // If Valid Post Then We Rate It
            if ($post && !wp_is_post_revision($post)) {
                $ratings_max = intval(get_option('postratings_max'));
                $ratings_custom = intval(get_option('postratings_customrating'));
                $ratings_value = get_option('postratings_ratingsvalue');
                $post_title = addslashes($post->post_title);
                $post_ratings = get_post_custom($post_id);
                $post_ratings_users = intval($post_ratings['ratings_users'][0]);
                $post_ratings_score = intval($post_ratings['ratings_score'][0]);
                // Check For Ratings Lesser Than 1 And Greater Than $ratings_max
                if ($rate < 1 || $rate > $ratings_max) {
                    $rate = 0;
                }
                $post_ratings_users = $post_ratings_users + 1;
                $post_ratings_score = $post_ratings_score + intval($ratings_value[$rate - 1]);
                $post_ratings_average = round($post_ratings_score / $post_ratings_users, 2);
                if (!update_post_meta($post_id, 'ratings_users', $post_ratings_users)) {
                    add_post_meta($post_id, 'ratings_users', $post_ratings_users, true);
                }
                if (!update_post_meta($post_id, 'ratings_score', $post_ratings_score)) {
                    add_post_meta($post_id, 'ratings_score', $post_ratings_score, true);
                }
                if (!update_post_meta($post_id, 'ratings_average', $post_ratings_average)) {
                    add_post_meta($post_id, 'ratings_average', $post_ratings_average, true);
                }
                // Add Log
                if (!empty($user_identity)) {
                    $rate_user = addslashes($user_identity);
                } elseif (!empty($_COOKIE['comment_author_' . COOKIEHASH])) {
                    $rate_user = addslashes($_COOKIE['comment_author_' . COOKIEHASH]);
                } else {
                    $rate_user = __('Guest', 'wp-postratings');
                }
                $rate_userid = intval($user_ID);
                // Only Create Cookie If User Choose Logging Method 1 Or 3
                $postratings_logging_method = intval(get_option('postratings_logging_method'));
                if ($postratings_logging_method == 1 || $postratings_logging_method == 3) {
                    $rate_cookie = setcookie("rated_" . $post_id, $ratings_value[$rate - 1], time() + 30000000, COOKIEPATH);
                }
                // Log Ratings No Matter What
                $rate_log = $wpdb->query("INSERT INTO {$wpdb->ratings} VALUES (0, {$post_id}, '{$post_title}', " . $ratings_value[$rate - 1] . ",'" . current_time('timestamp') . "', '" . get_ipaddress() . "', '" . esc_attr(@gethostbyaddr(get_ipaddress())) . "' ,'{$rate_user}', {$rate_userid})");
                # store into transver LHG database
                lhg_store_ratings($post_id, $post_ratings_users, $post_ratings_score, $ratings_value[$rate - 1]);
                // Output AJAX Result
                //echo the_ratings_results($post_id, $post_ratings_users, $post_ratings_score, $post_ratings_average);
                //show my rating, not the average
                echo the_ratings_results($post_id, $post_ratings_users, $post_ratings_score, $ratings_value[$rate - 1]);
                exit;
            } else {
                printf(__('Invalid Post ID. Post ID #%s.', 'wp-postratings'), $post_id);
                exit;
            }
            // End if($post)
        } else {
            printf(__('You Had Already Rated This Post. Post ID #%s.', 'wp-postratings'), $post_id);
            exit;
        }
        // End if(!$rated)
    }
    // End if($rate && $post_id && check_allowtorate())
}
示例#9
0
                $img = '<img src="' . get_stylesheet_directory_uri() . '/images/default.jpg" alt="' . get_the_title() . '" title="' . get_the_title() . '">';
            }
            // create json map
            $address = get_field('address');
            $dataLatLng = geocode($address);
            $news = '';
            if (get_field('new')) {
                $news = '<div class="news-icon"><span>New</span></div>';
            } else {
                if (get_field('page_hot')) {
                    $news = '<div class="news-icon hot"><span>Hot</span></div>';
                }
            }
            $url = $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI'];
            $total_comment = getFacebookDetails($url);
            $ratings = the_ratings_results(get_the_ID());
            $jsonData[] = array('title' => get_the_title(), 'lng' => $dataLatLng[0], 'lat' => $dataLatLng[1], 'address' => '', 'description' => '<p class="description">' . the_excerpt_max_charlength(18) . '</p>', 'vote' => '<div class="fs-comment"><span>Bình chọn:</span>' . $ratings . '</div>', 'img' => $img, 'baseurl' => get_the_permalink(), 'hot' => $news);
            ?>

              <?php 
        }
        ?>
            </ul>
            <?php 
        $defaultLng = 10.7596132;
        $defaultLat = 106.6644058;
        if ($jsonData) {
            foreach ($jsonData as $val) {
                if (!empty($val['lng']) || !empty($val['lat'])) {
                    $defaultLng = $val['lng'];
                    $defaultLat = $val['lat'];
function wp_one_post_widget($args, $vars = array())
{
    extract($args);
    $widget_number = (int) str_replace('wp-one-post-widget-', '', @$widget_id);
    $options = get_option('wp_one_post_widget');
    if (!empty($options[$widget_number])) {
        $vars = $options[$widget_number];
    }
    // ------ data used by several parts ----------
    $title = translate_title(get_the_title());
    $s = explode("(", $title);
    $short_title = trim($s[0]);
    global $post;
    global $wpdb;
    global $lhg_price_db;
    global $lang;
    global $txt_summary;
    global $txt_supplier;
    global $txt_cheapest_supplier;
    global $txt_rating;
    global $txt_select;
    global $txt_ratings;
    global $txt_sim_tags;
    global $txt_combine_tags;
    global $txt_wpop_register;
    global $txt_register_long;
    global $txt_send;
    global $txt_manage_subscr;
    global $txt_not_avail;
    global $txt_rate_yourself;
    global $txt_wpop_register;
    global $txt_button_string;
    //defined by amazon-product-in-a-post.php
    //echo "ID: $post->ID";
    if (is_single($post->ID)) {
        $querystr = "\r\n    SELECT {$wpdb->posts}.* \r\n    FROM {$wpdb->posts}\r\n    WHERE {$wpdb->posts}.post_title = '" . $vars['title'] . "'\r\n    AND {$wpdb->posts}.post_status = 'publish' \r\n    AND {$wpdb->posts}.post_type = 'post'\r\n  ";
        $pageposts = $wpdb->get_results($querystr, OBJECT);
        foreach ($pageposts as $post) {
            setup_postdata($post);
            $title = $post->post_title;
            $excerpt = $post->post_excerpt;
            if (!$excerpt) {
                $excerpt = substr($post->post_content, 0, 100);
            }
            if (!$vars['thumbnail_position']) {
                $vars['thumbnail_position'] = 'left';
            }
            $thumb = get_the_post_thumbnail($post->ID, 'thumbnail', array('class' => $vars['thumbnail_position']));
            $link = get_permalink($post->ID);
        }
        echo "\n{$before_widget}";
        echo '
    <div class="topright" style="border: 1px solid #2b8fc3; padding-left: 3px; padding-right:3px; padding-top: 1px; margin-bottom: 10px; background-color: #fff; padding-bottom: 17px;">';
        echo '
        <div class="wp-one-summary">' . $txt_summary . "</div>";
        //	if(empty($vars['custom_title'])): echo $before_title . "A".$vars['title'] . $after_title; else: echo "<h2>".$vars['custom_title'] . "</h2>"; endif;
        if ($vars['use_thumbnail'] == 'yes') {
            $content_widget = $thumb . '<p>' . $excerpt . ' <a href="' . $link . '">' . $vars['readmore'] . '</a></p>';
        } else {
            $content_widget = '<p>' . $excerpt . ' <a href="' . $link . '">' . $vars['readmore'] . '</a></p>';
        }
        //$thumb = get_the_post_thumbnail($post->ID);
        //echo "$thumb";
        //Rating Overview
        $post_id = $post->ID;
        // Check IP From IP Logging Database
        #$get_rates = $wpdb->get_results("SELECT rating_rating FROM $wpdb->ratings WHERE rating_postid = $post_id");
        //echo "Nr: ".sizeof($get_rates);
        $rating1 = 0;
        $rating2 = 0;
        $rating3 = 0;
        $rating4 = 0;
        $rating5 = 0;
        $rating_total = 0;
        #foreach($get_rates as $get_rate){
        #        $rating_total++;
        #
        #        if ($get_rate->rating_rating == 1 ) $rating1++;
        #        if ($get_rate->rating_rating == 2 ) $rating2++;
        #        if ($get_rate->rating_rating == 3 ) $rating3++;
        #        if ($get_rate->rating_rating == 4 ) $rating4++;
        #        if ($get_rate->rating_rating == 5 ) $rating5++;
        #
        #}
        if ($lang != "de") {
            $ratings = $lhg_price_db->get_results("SELECT * FROM  `lhgtransverse_posts` WHERE postid_com = {$post_id}");
        }
        if ($lang == "de") {
            $ratings = $lhg_price_db->get_results("SELECT * FROM  `lhgtransverse_posts` WHERE postid_de = {$post_id}");
        }
        #var_dump($ratings);
        $rating1 = $ratings[0]->post_ratings_1_com + $ratings[0]->post_ratings_1_de;
        $rating2 = $ratings[0]->post_ratings_2_com + $ratings[0]->post_ratings_2_de;
        $rating3 = $ratings[0]->post_ratings_3_com + $ratings[0]->post_ratings_3_de;
        $rating4 = $ratings[0]->post_ratings_4_com + $ratings[0]->post_ratings_4_de;
        $rating5 = $ratings[0]->post_ratings_5_com + $ratings[0]->post_ratings_5_de;
        $rating_total = $ratings[0]->post_ratings_users_com + $ratings[0]->post_ratings_users_de;
        #$rating1 + $rating2 + $rating3 + $rating4 + $rating5;
        //echo "<table cellspacing=0 cellpadding=0 border=1>
        //        <tr>
        //        <td width=90%>";
        //echo "</td></tr></table> ";
        global $vspacer;
        $vspacer = '<div class="spacer" style="border-top: 1px solid #2b8fc3; height: 0px; margin-top: 9px; margin-bottom: 9px;"></div>';
        // ---- Overview - cheapest supplier
        // get cheapest supplier
        $cheapest_supplier_id = lhg_db_get_cheapest_supplier_id($post->ID);
        #echo "CID: $cheapest_supplier_id <br>";
        if ($cheapest_supplier_id != "") {
            lhg_show_supplier_square($cheapest_supplier_id, $post->ID);
        }
        if ($cheapest_supplier_id == "") {
            lhg_show_supplier_square_default($post->ID);
        }
        //get price & url from DB
        $region = get_region();
        #        $meta="price-amazon.".$region;
        #        $aprice = get_post_meta($post->ID,$meta,true);
        #        $meta="url-amazon.".$region;
        #        $aurl=get_post_meta($post->ID,$meta,true); //amaz_url($post->ID);
        //still undefined?
        #	if ($aurl == ""){
        #	  $aid=get_id();
        #          $aurl = 'http://www.amazon.'.$region.'/?_encoding=UTF8&camp=15121&creative=390961&linkCode=ur2&tag='.$aid;
        #        }
        /*
        if ( ($region == "de") or ($region == "fr") or ($region == "it") or ($region == "es")) {
                $aprice=str_replace(".","",$aprice);
        }else{
        	        $aprice=str_replace(",","",$aprice);
        	        //$aprice=str_replace(",",".",$aprice);
        }
        */
        //echo "AP0: $aprice";
        #        $aprice = lhg_amazon_price_to_float ( $aprice , $region );
        //echo "AP1: $aprice";
        //
        // affilinet prices
        //
        if ($lang == "de debug") {
            //echo "A";
            $meta = "affilinet_PID";
            $aff_PID = get_post_meta($post->ID, $meta, true);
            //amaz_url($post->ID);
            if ($aff_PID == "") {
                //check for wrong entered PID
                $meta = "PID_affilinet";
                $aff_PID = get_post_meta($post->ID, $meta, true);
                //amaz_url($post->ID);
                //echo "affPID: $aff_PID";
            }
            if ($aff_PID != "") {
                // check for multiple PIDs
                $PIDlist = str_getcsv($aff_PID, ";");
                $num = count($PIDlist);
                //echo "Num: $num <br>PIDlist0: $PIDlist[0]<br>";
                //echo "PIDlist1: $PIDlist[1]<br>";
                if ($num == 1) {
                    list($aff_date, $aff_shop_id, $aff_price, $aff_shipping, $aff_url) = get_price_aff($aff_PID);
                    $cheapestURL = str_replace("+++++", ";", $aff_url);
                    //echo "Cheap: $cheapestURL<br>";
                    $tprice = $aff_price + $aff_shipping;
                    //echo "TP: $tprice <br>";
                    if ($aff_shop_id == 1739) {
                        $pcount++;
                        $pricetable[$pcount] = $tprice . '###  EUR ' . str_replace(".", ",", number_format($tprice, 2)) . ' &gt;  <a href="' . $aff_url . '" rel="nofollow">Redcoon.de</a>';
                        $pricetable_data[$pcount] = $tprice . '###' . str_replace(".", ",", number_format($tprice, 2)) . '###' . $aff_url . '###Redcoon.de' . '###' . str_replace(".", ",", number_format($aff_shipping, 2));
                    }
                    if ($aff_shop_id == 1752) {
                        $pcount++;
                        $pricetable[$pcount] = $tprice . '###  EUR ' . str_replace(".", ",", number_format($tprice, 2)) . ' &gt;  <a href="' . $aff_url . '" rel="nofollow">Reichelt.de</a>';
                        $pricetable_data[$pcount] = $tprice . '###' . str_replace(".", ",", number_format($tprice, 2)) . '###' . $aff_url . '###Reichelt.de' . '###' . str_replace(".", ",", number_format($aff_shipping, 2));
                    }
                }
                if ($num > 1) {
                    //cycle through IDs
                    //$ProductIDList = str_getcsv($ProductID,";");
                    //echo "multiple ids<br>";
                    list($aff_date, $aff_shop_id, $aff_price, $aff_shipping, $aff_url) = get_price_aff($aff_PID, $num);
                    //echo "ShopID: $aff_shop_id";
                    $ShopIDList = str_getcsv($aff_shop_id, ";");
                    $PriceList = str_getcsv($aff_price, ";");
                    $ShippingList = str_getcsv($aff_shipping, ";");
                    $URLList = str_getcsv($aff_url, ";");
                    $tpriceListCheapest = 9999999999;
                    for ($i = 0; $i < $num; $i++) {
                        $tpriceList[$i] = $PriceList[$i] + $ShippingList[$i];
                        //url of cheapest partner
                        if ($tpriceList[$i] < $tpriceListCheapest) {
                            $tpriceListCheapest = $tpriceList[$i];
                            $cheapestURL = str_replace("+++++", ";", $URLList[$i]);
                            //echo "Cheap: $cheapestURL<br>";
                        }
                        if ($ShopIDList[$i] == 1739) {
                            $pcount++;
                            $pricetable[$pcount] = $tpriceList[$i] . '###  EUR ' . str_replace(".", ",", number_format($tpriceList[$i], 2)) . ' &gt;  <a href="' . $URLList[$i] . '" rel="nofollow">Redcoon.de</a>';
                            $pricetable_data[$pcount] = $tpriceList[$i] . '###' . str_replace(".", ",", number_format($tpriceList[$i], 2)) . '###' . $URLList[$i] . '###Redcoon.de' . '###' . str_replace(".", ",", number_format($ShippingList[$i], 2));
                        }
                        if ($ShopIDList[$i] == 1752) {
                            $pcount++;
                            $pricetable[$pcount] = $tpriceList[$i] . '###  EUR ' . str_replace(".", ",", number_format($tpriceList[$i], 2)) . ' &gt;  <a href="' . $URLList[$i] . '" rel="nofollow">Reichelt.de</a>';
                            $pricetable_data[$pcount] = $tpriceList[$i] . '###' . str_replace(".", ",", number_format($tpriceList[$i], 2)) . '###' . $URLList[$i] . '###Reichelt.de' . '###' . str_replace(".", ",", number_format($ShippingList[$i], 2));
                        }
                    }
                }
            }
            //echo "ID: $aff_shop_id <br>Price: $aff_price + $aff_shipping";
        }
        //$nbprice=str_replace(",",".",NB_price($post->ID));
        //$nburl=NB_url($post->ID);
        //$region=get_region();
        //$aid=get_id();
        //print $aprice;
        //print "AURL: $aurl<br>";
        //if ($aurl == "") $aurl="http://www.amazon.$region/?_encoding=UTF8&camp=15121&creative=390961&linkCode=ur2&tag=$aid";
        //default: Euro
        //print "2: ".number_format($aprice,2);
        //$pricestring = number_format( str_replace("EUR","",str_replace(",",".",$aprice)),2,',','.');
        //pure price without currency
        //$pureprice   = str_replace("EUR","",$aprice);
        //$pureprice   = str_replace("CND","",$aprice);
        //$pureprice   = str_replace("$","",$aprice);
        #        $pricestring = $aprice;
        #
        #        if ( ($region == "de") or
        #             ($region == "es") or
        #             ($region == "fr") or
        #             ($region == "it") ){
        #		//$pricetable[0] =  str_replace(",",".",$pricestring).'###  EUR <span itemprop="price">'.$pricestring.'</span> &gt; <a href="'.$aurl.'" rel="nofollow">Amazon.'.$region.'</a>';
        #		//$pricetable[0] =  str_replace(",",".",$pricestring).'###  EUR <span itemprop="price">'.$pricestring.'</span> &gt; <a href="'.$aurl.'" rel="nofollow">Amazon.'.$region.'</a>';
        #		$pricetable_data[0] =  $pricestring.'###'.$pricestring.'###'.$aurl.'###Amazon.'.$region;
        #        }
        //float price to string
        #        $aprice_str = lhg_float_to_currency_string( $aprice , $region );
        #        $cs = lhg_get_currency_symbol( $region );
        //echo "REG: $region";
        /*
        if ($region == "com") $pricetable[0] =    '  $ <span itemprop="price">'.str_replace(".",".",number_format(str_replace("$","",$aprice),2)).'</span> &gt; <a href="'.$aurl.'" rel="nofollow">Amazon.'.$region.'</a>';
        if ($region == "in")  $pricetable[0] = '  '.str_replace("INR",'&#8377; <span itemprop="price">',$aprice).'</span> &gt; <a href="'.$aurl.'" rel="nofollow">Amazon.'.$region.'</a>';
        if ($region == "ca")  $pricetable[0] = '  CDN$ <span itemprop="price">'.str_replace(".",".",number_format(str_replace("CDN\$","",$aprice),2)).'</span> &gt; <a href="'.$aurl.'" rel="nofollow">Amazon.'.$region.'</a>';
        if ($region == "co.uk")  $pricetable[0] = '  '.$cs.' <span itemprop="price">'.$aprice_str.'</span> &gt; <a href="'.$aurl.'" rel="nofollow">Amazon.'.$region.'</a>';
        if ($region == "co.jp")  $pricetable[0] = '  &yen; <span itemprop="price">'.$aprice_str.'</span> &gt; <a href="'.$aurl.'" rel="nofollow">Amazon.'.$region.'</a>';
        */
        #        $pricetable[0] = '  '.$cs.' <span itemprop="price">'.$aprice_str.'</span> &gt; <a href="'.$aurl.'" rel="nofollow">Amazon.'.$region.'</a>';
        //echo "PT: $pricetable[0]";
        //print "APrice: $aprice<br>";
        #        if ($aprice=='out of stock')
        #                $pricetable[0] = '  '.$txt_not_avail.' &gt; <a href="'.$aurl.'" rel="nofollow">Amazon.'.$region.'</a>';
        //print "AP: >$aprice< <br>";
        #        if ( (strpos($aprice,'nicht vorr') !== false) or (strpos($aprice,'nicht liefer') !== false) or ($aprice=="") )
        #                $pricetable[0] = '  '.$txt_not_avail.' &gt; <a href="'.$aurl.'" rel="nofollow">Amazon.'.$region.'</a>';
        #        if ($lang == "de"){
        #          if ($nbprice != ""){
        #                $pcount++;
        #        	$pricetable[$pcount] = '  EUR <span itemprop="price">'.str_replace(".",",",number_format(str_replace("EUR","",$nbprice),2)).'</span> &gt;  <a href="'.$nburl.'" rel="nofollow">Notebooksbilliger.de</a>';
        #          }
        #          //sort($pricetable);
        #          array_multisort( $pricetable , SORT_NUMERIC, $pricetable_data );
        #	}
        //echo "PT0 ".$pricetable[0];
        //echo "POS: ".strpos($pricetable[0],"###");
        //get rid of sorting string, works only for "de"
        #        if ( strpos($pricetable[0],"###") >0 )
        #       foreach ($pricetable as &$value) {
        #           list( $null, $value) = explode("###",$value);
        #       }
        //echo "PT0 ".$pricetable[0];
        //echo "<br>PT1 ".$pricetable[1];
        //echo "PR: $aprice";
        // echo "\n".'<div itemscope itemtype="http://data-vocabulary.org/Product">';
        // echo "\n".'<span itemprop="category" content="Hardware" ></span>';
        // echo "\n".'<span itemprop="name" content="'.translate_title(get_the_title()).'" ></span>';
        //echo "PC: $pcount";
        #        if ($pcount > 0)
        #	        echo "\n".'<div style="text-align: center;"><b>'.$txt_cheapest_supplier.':</b></div>';
        //echo "aprice: $aprice<br>";
        //echo "PC: ",$pcount;
        #        if ($pcount == 0)
        #                if ($aprice!='out of stock')
        #                        	echo "\n".'<div style="text-align: center;"><b>'.$txt_supplier.'</b></div>';
        #        echo "\n".'<div class="rating" style="border: 0px solid #222; width: 70%; text-align: center; margin: 0 auto;">';
        #        echo $cheap_txt;
        /* single offer. to be changed for group of offers! */
        //echo "\n".'<span itemprop="offerDetails" itemscope itemtype="http://data-vocabulary.org/Offer">';
        #        $price_meta = "USD";
        #        if ($region == "de") $price_meta = "EUR";
        #        if ($region == "it") $price_meta = "EUR";
        #        if ($region == "fr") $price_meta = "EUR";
        #        if ($region == "es") $price_meta = "EUR";
        #        if ($region == "com") $price_meta = "USD";
        #        if ($region == "co.uk") $price_meta = "GBP";
        #        if ($region == "co.jp") $price_meta = "JPY";
        #        if ($region == "cn") $price_meta = "CNY";
        #        if ($region == "ca") $price_meta = "CAD";
        #        if ($region == "in") $price_meta = "INR";
        #
        #        echo "\n".'<meta itemprop="currency" content="'.$price_meta.'" />';
        //echo '<meta itemprop="price" content="'.str_replace(".",",",number_format(str_replace("EUR","",$nbprice),2)).'" />';
        //echo "Amazon.$region";
        //echo "PT: $pricetable[0]";
        #        if ( (strpos($pricetable[0],"Amazon.$region")) or ($pricetable[0] == "") ){
        #                //if ($aprice!='out of stock')
        #                echo "\n".'<div class="amazonbutton"><a href="'.$aurl.'" rel="nofollow"><img src="/wp-uploads/2012/10/Amazon_Logo1.png" border=0 width=125 height=125 alt="'.$txt_button_string.': '.$short_title.'" title="'.$txt_button_string.': '.$short_title.'"></a></div>';
        #        }elseif (strpos($pricetable[0],"Notebooksbilliger.de")){
        #        	echo "\n".'<div class="amazonbutton"><a href="'.$nburl.'" rel="nofollow"><img src="wp-uploads/2012/10/Logo_125-x-125_5_H.gif" border=0></a></div>';
        #        }elseif (strpos($pricetable[0],"Redcoon.de")){
        #        	echo "\n".'<div class="amazonbutton" style="border: 1px solid #2B8FC3; width: 140px; margin: 0 auto;"><a href="'.$cheapestURL.'" rel="nofollow"><img src="/wp-uploads/2014/03/redcoon-logo-125x125.jpg" border=0 width=140 height=140></a></div>';
        #        }elseif (strpos($pricetable[0],"Reichelt.de")){
        #        	echo "\n".'<div class="amazonbutton" style="border: 1px solid #2B8FC3; width: 140px; margin: 0 auto;"><a href="'.$cheapestURL.'" rel="nofollow"><img src="/wp-uploads/2014/03/reichelt_logo_125x125.gif" border=0 width=140 height=140></a></div>';
        #        }
        #
        #        $pricetable[0] = str_replace("+++++",";",$pricetable[0]);
        #        echo str_replace(" &gt; ", "<br>",$pricetable[0]);
        #        echo "\n"."</div>";
        #        if ($pcount == 0){
        #	        //echo "<b>Preis:</b>";
        #	}else{
        #	        //echo "<b>Amazon-Preis:</b><br>";
        #                //echo ' '.$aprice.' &gt; <a href="'.$aurl.'">Amazon.de</a>';
        #                echo $vspacer;
        #	        echo "<b>&Uuml;bersicht der Anbieter:</b>";
        #
        #	}
        //echo "<br>PT1 ".$pricetable[1];
        #	if ($pcount == 0){
        #		//echo $line;
        #	}else{
        #                echo "<br>
        #                <table>";
        #                //<tr><td><b>Preis</b></td><td><b>Anbieter</b></td><td></td></tr>
        #                //";
        #        	$i=0;
        #        	foreach($pricetable as $line){
        #                        list ($price1, $price2, $url , $shop, $shipping) = explode("###",$pricetable_data[$i]);
        #
        #                        //echo "$price2 .. $url .. $shop";
        #
        #		        if (strpos($pricetable[$i],"Redcoon.de")){
        #			      echo '<tr><td>EUR&nbsp;'.$price2.'<br><div class="portoline">inkl. Porto: '.$shipping.' EUR</div></td><td valign="middle"><a href="'.$url.'" rel="nofollow"><img src="wp-uploads/2014/03/redcoon-logo-110x033.jpg" style="border: 1px solid #2B8FC3;"></a></td><td><a href="'.$url.'" rel="nofollow">Redcoon.de</a></td></tr>';
        #
        #	    		}elseif (strpos($pricetable[$i],"Amazon.de")){
        #			      echo '<tr><td>EUR&nbsp;'.$price2.'<br><div class="portoline">exkl. Porto</div></td><td valign="middle"><a href="'.$url.'" rel="nofollow"><img src="wp-uploads/2014/03/amazon_de_logo_110_33.jpg" style="border: 1px solid #2B8FC3;"></a></td><td><a href="'.$url.'" rel="nofollow">Amazon.de</a></td></tr>';
        #			      //echo '<img src="wp-uploads/2014/03/amazon_de_logo_110_33.jpg">'.$pricetable[$i]."<br>";
        #  	    		}elseif (strpos($pricetable[$i],"Reichelt.de")){
        #                              $url = str_replace("+++++",";",$url);
        #                              echo '<tr><td>EUR&nbsp;'.$price2.'<br><div class="portoline">inkl. Porto: '.$shipping.' EUR</div></td><td valign="middle"><a href="'.$cheapestURL.'" rel="nofollow"><img src="wp-uploads/2014/03/reichelt_logo_110x33.jpeg" style="border: 1px solid #2B8FC3;"></a></td><td><a href="'.$url.'" rel="nofollow">Reichelt.de</a></td></tr>';
        #			      //echo '<img src="wp-uploads/2014/03/amazon_de_logo_110_33.jpg">'.$pricetable[$i]."<br>";
        #	    		}
        #                        else{
        #			      echo $pricetable[$i]."<br>";
        #                        }
        #
        #	              //if ($i == 0) echo '<div class="priceline" style="border: 0px solid #000; "><div class="pricetop" style="border: 1px solid #2b8fc3; background-color: #eee; margin: 3px 3px;">'.$line.'</div></div>';
        #	              //if ($i > 0)  echo '<div class="priceline" style="border: 0px solid #000; "><div class="price" style="border: 0px solid #333; background-color: #fff; margin: 3px 3px;">'.$line.'</div></div>';
        #  	              $i++;
        #    		}
        #                echo"</table>";
        #	}
        // echo get_affiliate_prices($post->ID);
        //
        // ---- New Supplier Overview
        //
        #if ($lang == "de")
        lhg_supplier_comparison($post->ID);
        //
        // ---- Rating Overview ==============================================================
        //
        global $txt_opw_num_ratings;
        //    = "Number of ratings";
        global $txt_opw_average_rating;
        // = "Average ratings";
        global $txt_opw_rating_overview;
        global $txt_out_of;
        global $txt_opw_hardware;
        global $txt_average;
        global $no_supplier_square;
        #$rating_avg = get_post_meta($post->ID,'ratings_average',true);
        $num_rates = $ratings[0]->post_ratings_users_com + $ratings[0]->post_ratings_users_de;
        if ($num_rates == 0) {
            $rating_avg = 0;
        }
        if ($num_rates != 0) {
            $rating_avg = ($ratings[0]->post_ratings_score_com + $ratings[0]->post_ratings_score_de) / $num_rates;
        }
        if ($no_supplier_square != 1) {
            echo $vspacer;
        }
        #echo '<div itemscope itemtype="http://schema.org/Product">';
        #echo '<div itemscope itemtype="http://data-vocabulary.org/Review-aggregate">';
        #echo '<div property="itemReviewed" typeof="Product">';
        #echo '  <div itemprop="rating" itemscope itemtype="http://data-vocabulary.org/Rating">';
        //echo '<div class="rating" style="border: 0px solid #222; width: 90%; margin: 0 auto;">';
        echo '

        <table class="ratingtable" border="0">
           <tr>
             <td><b>' . $txt_opw_hardware . ':</b></td>
             <td><span itemprop="name">' . $short_title . '</span></td>
           </tr>


           <tr>
             <td>
             ';
        //if ($rating_total>1) echo "<b>$txt_wpone_num_ratings:</b></td><td> <b>".'<span itemprop="votes">'."$rating_total</span></b><br>";
        //if ($rating_total<2)
        echo "       <b>{$txt_opw_num_ratings}:</b>\n             </td>\n\n\n\n             <td>\n                {$rating_total} <br />\n             </td>\n           </tr>\n\n\n           <tr>\n              <td><b>{$txt_opw_average_rating}: </b></td>\n\n              <td>";
        echo '<span itemprop="aggregateRating" itemscope itemtype="http://schema.org/AggregateRating">';
        echo the_ratings_results($post->ID, 0, 0, 0, 10) . '
                            (<span itemprop="ratingValue">' . round($rating_avg, 1) . '</span> ' . $txt_out_of . '
                             <span itemprop="bestRating">5</span>)

                            <span itemprop="ratingCount" content="' . $rating_total . '" />
                            <span itemprop="worstRating" content="0" />
                        </span>

              </td>
           </tr>


           ';
        echo '
           <tr>
              <td class="td-ratingoverview">' . "<b>{$txt_opw_rating_overview}:</b></td>\n\n              <td>";
        if ($rating_total == 0) {
            $ra5 = 0;
            $ra4 = 0;
            $ra3 = 0;
            $ra2 = 0;
            $ra1 = 0;
        } else {
            $ra5 = 100 * $rating5 / $rating_total;
            $ra4 = 100 * $rating4 / $rating_total;
            $ra3 = 100 * $rating3 / $rating_total;
            $ra2 = 100 * $rating2 / $rating_total;
            $ra1 = 100 * $rating1 / $rating_total;
        }
        echo '

        <div class="rateline" style="border: 0px solid #000;">
           <div style="float: left;">5:&nbsp; </div>
           <div class="outerbox" style="background-color: #eee; width: 80px; float: left; margin: 4px 0px;">
             <div class="box" style="border: 0px solid #088; background-color: #2b8fc3; height: 8px; width: ' . $ra5 . '%;" ></div>
           </div> &nbsp;(' . $rating5 . ')
        </div><br clear="all" />';
        echo '
        <div class="rateline" style="border: 0px solid #000; margin-top: -17px; ">
           <div style="float: left;">4:&nbsp; </div>
           <div class="outerbox" style="background-color: #eee; width: 80px; float: left; margin: 4px 0px;">
             <div class="box" style="border: 0px solid #088; background-color: #2b8fc3; height: 8px; width: ' . $ra4 . '%;" ></div>
           </div> &nbsp;(' . $rating4 . ')
        </div><br clear="all" />';
        echo '
        <div class="rateline" style="border: 0px solid #000; margin-top: -17px; ">
           <div style="float: left;">3:&nbsp; </div>
           <div class="outerbox" style="background-color: #eee; width: 80px; float: left; margin: 4px 0px;">
             <div class="box" style="border: 0px solid #088; background-color: #2b8fc3; height: 8px; width: ' . $ra3 . '%;" ></div>
           </div> &nbsp;(' . $rating3 . ')
        </div><br clear="all" />';
        echo '
        <div class="rateline" style="border: 0px solid #000; margin-top: -17px; ">
           <div style="float: left;">2:&nbsp; </div>
           <div class="outerbox" style="background-color: #eee; width: 80px; float: left; margin: 4px 0px;">
              <div class="box" style="border: 0px solid #088; background-color: #2b8fc3; height: 8px; width: ' . $ra2 . '%;" ></div>
           </div> &nbsp;(' . $rating2 . ')
        </div><br clear="all" />';
        echo '
        <div class="rateline" style="border: 0px solid #000; margin-top: -17px; ">
           <div style="float: left;">1:&nbsp; </div>
           <div class="outerbox" style="background-color: #eee; width: 80px; float: left; margin: 4px 0px;">
              <div class="box" style="border: 0px solid #2b8fc3; background-color: #2b8fc3; height: 8px; width: ' . $ra1 . '%;" ></div>
           </div> &nbsp;(' . $rating1 . ')
        </div>';
        #        echo '
        #     </div>';
        echo '      <a href="#comments">' . $txt_rate_yourself . '</a>';
        //echo "</td></tr><tr><td></td><td>";
        echo "\n                </td>\n              </tr>\n\n          </table>\n\n          ";
        #echo '</div>'; // itemreviewed
        # echo "  </div>"; //Rating
        #echo '</div>'; //Review-aggregate
        //echo $vspacer;
        //
        // -------- Subscriber =============================================================
        //
        //if ($lang == "de"){
        echo $vspacer;
        print "<b>" . '<i class="icon-user icon-add-hw-user"></i><i class="icon-plus icon-add-hw-plus"></i>' . "{$txt_wpop_register}</b><br />";
        print "{$txt_register_long}";
        if (is_user_logged_in()) {
            $current_user = wp_get_current_user();
            print '<form action="/hardware-profile?srp=' . $post->ID . '&#038;sra=s" method="post" onsubmit="if(this.sre.value==\'\' || this.sre.indexOf(\'@\')==0) return false">
  	                 <fieldset style="border:0">
  	                 <input type="hidden" class="subscribe-form-field" name="sre" value="' . $current_user->user_email . '" size="18">
  	                 <button type="submit" value="' . $txt_send . '" >' . $txt_send . '&nbsp;<i class="icon-arrow-right icon-button"></i></button>
  	                 </fieldset>
  	                 </form>';
        } else {
            print '<form action="/hardware-profile?srp=' . $post->ID . '&#038;sra=s" method="post" onsubmit="if(this.sre.value==\'\' || this.sre.indexOf(\'@\')==0) return false">
  	                 <fieldset style="border:0">
  	                 <input type="text" class="subscribe-form-field" name="sre" value="email" size="18" onfocus="if(this.value==this.defaultValue)this.value=\'\'" onblur="if(this.value==\'\')this.value=this.defaultValue"/>
  	                 <button type="submit" value="' . $txt_send . '" >' . $txt_send . '&nbsp;<i class="icon-arrow-right icon-button"></i></button>
  	                 </fieldset>
  	                 </form>';
        }
        $usernum = 0;
        //get number of registered users
        global $txt_opw_registered;
        global $wpdb;
        global $txt_not_avail;
        $usernum = $wpdb->get_var("SELECT COUNT(*) FROM {$wpdb->postmeta} WHERE meta_key LIKE '\\_stcr@\\_%' AND post_id = " . $post->ID);
        if ($usernum > 0) {
            print "(" . $txt_opw_registered . ": " . $usernum . ")";
        }
        //print do_shortcode('<a href="/manage-subscriptions">'.$txt_manage_subscr."</a>");
        //}
        //
        // ----------- Language Selector ============================================
        //
        #$selected    ='<div class="pricetop" style="border: 1px solid #2b8fc3; background-color: #eee; margin: 3px 3px 3px 3px; padding-top: 3px;">';
        #$selectedEnd ='</div>';
        # Debug:
        #lhg_store_comment_numbers_by_post_id( $post_id );
        echo $vspacer;
        echo "<b>{$txt_select}:</b><br />";
        //echo "PL:".get_permalink();
        //echo "<br>QPL:".qtrans_convertURL(get_permalink());
        list($null1, $null2, $null3, $posturl) = explode("/", get_permalink());
        list($null1, $null2, $null3, $null4, $posturl2) = explode("/", get_permalink());
        //echo "pu:".$posturl ."<br>";
        //echo "pu2".$posturl2."<br>";
        if ($posturl2 != "") {
            $posturl = $posturl2;
        }
        //we are in a qtranslate subfolder!
        $posturlde = $posturl;
        $posturlcom = $posturl;
        if (!is_search() and !($postID == "1821") and !is_archive()) {
            $comURL = get_post_meta($post->ID, 'COM_URL', true);
            $deURL = get_post_meta($post->ID, 'DE_URL', true);
            if ($comURL != "") {
                $posturlcom = $comURL;
            }
            if ($deURL != "") {
                $posturlde = $deURL;
            }
            if (substr($comURL, 0, 1) == "/") {
                $comURL = substr($comURL, 1);
            }
            if (substr($deURL, 0, 1) == "/") {
                $deURL = substr($deURL, 1);
            }
            //echo "LANG: $lang, PID: $postID, ";
            //translation still missing -> redirect to main page
            if ($comURL == "" and $post->ID > 2599 and $lang == "de") {
                $posturlcom = "";
            }
            if ($deURL == "" and $post->ID > 2599 and $lang == "en") {
                $posturlde = "";
            }
            # on de server get com link from priceDB
            if ($lang == "de") {
                $com = lhg_get_com_post_URL($postID);
                $comURL == $com;
            }
        }
        //remove language selection for .de
        $posturlde = str_replace("?lang=jp", "", $posturlde);
        $posturlde = str_replace("?lang=it", "", $posturlde);
        $posturlde = str_replace("?lang=es", "", $posturlde);
        $posturlde = str_replace("?lang=uk", "", $posturlde);
        $posturlde = str_replace("?lang=ca", "", $posturlde);
        $posturlde = str_replace("?lang=in", "", $posturlde);
        $posturlde = str_replace("?lang=fr", "", $posturlde);
        $posturlde = str_replace("?lang=cn", "", $posturlde);
        $posturlde = str_replace("?lang=en", "", $posturlde);
        $posturlcom = str_replace("?lang=jp", "", $posturlcom);
        $posturlcom = str_replace("?lang=it", "", $posturlcom);
        $posturlcom = str_replace("?lang=es", "", $posturlcom);
        $posturlcom = str_replace("?lang=uk", "", $posturlcom);
        $posturlcom = str_replace("?lang=ca", "", $posturlcom);
        $posturlcom = str_replace("?lang=in", "", $posturlcom);
        $posturlcom = str_replace("?lang=fr", "", $posturlcom);
        $posturlcom = str_replace("?lang=cn", "", $posturlcom);
        $posturlcom = str_replace("?lang=en", "", $posturlcom);
        if ($lang == "de") {
            $URLC = "http://www.linux-hardware-guide.com";
            $URLD = "";
        }
        if ($lang != "de") {
            $URLC = "";
            $URLD = "http://www.linux-hardware-guide.de";
        }
        //$URLC="http://192.168.3.113"; //Debug
        if (1 == 1) {
            echo '<div class="countrytable"><table border="0">
        	<tr class="countrytable_header">
                  <td class="cth_country">Country</td>
                  <td class="cth_price">Price</td>
                  <td class="cth_currency"></td>
                  <td class="cth_comment">Comments</td>
                </tr>';
            print lhg_country_row("de", $URLC, $URLD, $posturlcom, $posturlde);
            print lhg_country_row("com", $URLC, $URLD, $posturlcom, $posturlde);
            print lhg_country_row("ca", $URLC, $URLD, $posturlcom, $posturlde);
            print lhg_country_row("co.uk", $URLC, $URLD, $posturlcom, $posturlde);
            print lhg_country_row("fr", $URLC, $URLD, $posturlcom, $posturlde);
            print lhg_country_row("es", $URLC, $URLD, $posturlcom, $posturlde);
            print lhg_country_row("it", $URLC, $URLD, $posturlcom, $posturlde);
            print lhg_country_row("nl", $URLC, $URLD, $posturlcom, $posturlde);
            print lhg_country_row("in", $URLC, $URLD, $posturlcom, $posturlde);
            print lhg_country_row("co.jp", $URLC, $URLD, $posturlcom, $posturlde);
            print lhg_country_row("cn", $URLC, $URLD, $posturlcom, $posturlde);
            echo "</table></div>";
        } else {
            //if ($region == "de") print $selected;
            //echo '&nbsp;&nbsp;<a href="'.$URLD.'/'.$posturlde.'"><img src="/wp-content/plugins/qtranslate/flags/de.png" alt="Germany" /> Germany (&euro;)</a><br />';
            //if ($region == "de") print $selectedEnd;
            if ($region == "de") {
                print $selected;
            }
            echo '&nbsp;&nbsp;<a href="' . $URLC . '/' . $posturlcom . '"><img src="/wp-content/plugins/qtranslate/flags/us.png" alt="USA" /> USA (&euro;)</a><br />';
            if ($region == "de") {
                print $selectedEnd;
            }
            if ($region == "ca") {
                print $selected;
            }
            echo '&nbsp;&nbsp;<a href="' . $URLC . '/ca/' . $posturlcom . '"><img src="/wp-content/plugins/qtranslate/flags/ca.png" alt="Canada" /> Canada (CDN $)</a><br />';
            if ($region == "ca") {
                print $selectedEnd;
            }
            if ($region == "co.uk") {
                print $selected;
            }
            echo '&nbsp;&nbsp;<a href="' . $URLC . '/uk/' . $posturlcom . '"><img src="/wp-content/plugins/qtranslate/flags/uk.png" alt="UK" /> United Kingdom (&pound;)</a><br />';
            if ($region == "co.uk") {
                print $selectedEnd;
            }
            if ($region == "fr") {
                print $selected;
            }
            echo '&nbsp;&nbsp;<a href="' . $URLC . '/fr/' . $posturlcom . '"><img src="/wp-content/plugins/qtranslate/flags/fr.png" alt="France" /> France (&euro;)</a><br />';
            if ($region == "fr") {
                print $selectedEnd;
            }
            if ($region == "es") {
                print $selected;
            }
            echo '&nbsp;&nbsp;<a href="' . $URLC . '/es/' . $posturlcom . '"><img src="/wp-content/plugins/qtranslate/flags/es.png" alt="Espana" /> Espana (&euro;)</a><br />';
            if ($region == "es") {
                print $selectedEnd;
            }
            if ($region == "it") {
                print $selected;
            }
            echo '&nbsp;&nbsp;<a href="' . $URLC . '/it/' . $posturlcom . '"><img src="/wp-content/plugins/qtranslate/flags/it.png" alt="Italia" /> Italia (&euro;)</a><br />';
            if ($region == "it") {
                print $selectedEnd;
            }
            if ($region == "nl") {
                print $selected;
            }
            echo '&nbsp;&nbsp;<a href="' . $URLC . '/nl/' . $posturlcom . '"><img src="/wp-content/plugins/qtranslate/flags/nl.png" alt="Netherlands" /> Netherlands (&euro;)</a><br />';
            if ($region == "nl") {
                print $selectedEnd;
            }
            if ($region == "in") {
                print $selected;
            }
            echo '&nbsp;&nbsp;<a href="' . $URLC . '/in/' . $posturlcom . '"><img src="/wp-content/plugins/qtranslate/flags/in.png" alt="India" /> India (&#8377;)</a><br />';
            if ($region == "in") {
                print $selectedEnd;
            }
            if ($region == "co.jp") {
                print $selected;
            }
            echo '&nbsp;&nbsp;<a href="' . $URLC . '/ja/' . $posturlcom . '"><img src="/wp-content/plugins/qtranslate/flags/jp.png" alt="Japan" /> Japan (&yen;)</a><br />';
            if ($region == "co.jp") {
                print $selectedEnd;
            }
            if ($region == "cn") {
                print $selected;
            }
            echo '&nbsp;&nbsp;<a href="' . $URLC . '/zh/' . $posturlcom . '"><img src="/wp-content/plugins/qtranslate/flags/cn.png" alt="China" /> China (RMB)</a><br />';
            if ($region == "cn") {
                print $selectedEnd;
            }
        }
        //
        // Tag List Start
        //
        echo $vspacer;
        echo "\n\n" . "  <b>{$txt_sim_tags}:</b>\n  <br />";
        echo "\n" . '  <div style="margin-left: 18px;">';
        echo "\n\n" . '    <form method="get" action="/tagsearch/" class="combine_tags">' . "\n";
        foreach (get_the_category() as $category) {
            $counter++;
            $CID = $category->cat_ID;
            break;
            //stop at main category!
        }
        $args = array('category' => $CID);
        $catposts = get_posts($args);
        foreach ($catposts as $post) {
            setup_postdata($post);
            $posttags = get_the_tags(get_the_ID());
            if (is_array($posttags)) {
                foreach ($posttags as $tag) {
                    if ($tag->count > 1) {
                        // combination not useful in case of one result
                        if ($tag->term_id != 981) {
                            $count++;
                            $tagstrings[$count] = $tag->term_id . '; <a href="' . get_tag_link($tag->term_id) . '">' . $tag->name . '</a> (' . $tag->count . ')<br /> ';
                            if ($count > 15) {
                                break;
                            }
                        }
                    }
                }
            }
        }
        if (is_array($tagstrings)) {
            $unique_tagstrings = array_unique($tagstrings);
        }
        if (is_array($unique_tagstrings)) {
            sort($unique_tagstrings);
        }
        $countU = 0;
        if (is_array($unique_tagstrings)) {
            foreach ($unique_tagstrings as $tagstring) {
                $part = explode(";", $tagstring);
                $out .= "\n" . '      <input type="checkbox" name="tagid[' . $countU . ']" value="' . $part[0] . '" />' . $part[1];
                $countU++;
            }
        }
        echo $out;
        //
        // Tag List End
        //
        echo $content_widget;
        echo "\n" . '
      <div class="tagbutton">
        <button type="submit" value="' . $txt_combine_tags . '" >' . $txt_combine_tags . '&nbsp;
          <i class="icon-arrow-right icon-button"></i>
        </button>
      </div>

    </form>';
        echo "\n" . "\n  </div>\n  ";
        echo "\n" . "</div>";
        echo $after_widget;
        //close the blue widget
    }
}
function getSingleAmazonProduct($asin = '', $extratext = '', $extrabutton = 0)
{
    global $public_key, $private_key, $aws_partner_id, $aws_partner_locale, $amazonhiddenmsg, $amazonerrormsg, $apippopennewwindow, $apippnewwindowhtml;
    global $appip_text_lgimage;
    global $appip_text_listprice;
    global $appip_text_newfrom;
    global $appip_text_usedfrom;
    global $appip_text_instock;
    global $appip_text_outofstock;
    global $appip_text_author;
    global $appip_text_starring;
    global $appip_text_director;
    global $appip_text_reldate;
    global $appip_text_preorder;
    global $appip_text_releasedon;
    global $appip_text_notavalarea;
    global $buyamzonbutton;
    global $addestrabuybutton;
    global $encodemode;
    global $post;
    global $amazonRun;
    //text strings
    global $lang;
    global $txt_compat;
    global $txt_Compat;
    global $txt_with;
    global $txt_rating;
    global $txt_ratings;
    global $txt_price;
    global $txt_out_of_stock;
    global $txt_button;
    global $txt_button_width;
    global $siteurl;
    global $txt_pricetrend;
    global $txt_A_preis;
    global $txt_currency;
    global $txt_shipping;
    global $txt_on_stock;
    global $txt_updated;
    global $txt_buy_from;
    global $txt_search_at;
    global $txt_preorder;
    global $txt_not_avail_at;
    global $txt_never_avail;
    $region = get_region();
    $aws_partner_id = get_id();
    $aws_partner_locale = $region;
    //print "PL: $aws_partner_locale";
    //$apippOpenNewWindow = get_post_meta($post->ID,'amazon-product-newwindow',true);
    //if($apippOpenNewWindow!='3'){$apippnewwindowhtml=' target="amazonwin" ';}
    #print "A0: $asin<br>";
    $asinlist = get_post_meta($post->ID, 'amazon-product-asin-list', true);
    #print "CSV: ".str_getcsv($asin.",".$asinlist, ",");
    $data = str_getcsv($asin . "," . $asinlist, ",");
    #var_dump($data);
    #
    # check if DB entries for asins already exist -> create if necessary
    #
    $i = 0;
    while ($i < count($data)) {
        $asin_tmp = $data[$i];
        #print " A: $asin";
        if ($asin_tmp != "") {
            lhg_amazon_create_db_entry($region, $post->ID, $asin_tmp);
        }
        $i++;
    }
    //print "<br>Data0: $data[0] <br>";
    //print "Data1: $data[1] <br>";
    #print "Af: $asin<br>";
    if ($asin != '') {
        #print "count: ".count($data);
        #$i=0;
        #while ( $i< count($data) ){
        # one loop is enough. SQL request looks at all ASINs
        //print "I: $i <br>";
        global $amazonRun;
        $amazonRun = 0;
        // reset loop counter for new asin list element
        $asin = $data[$i];
        // $asin; //valid ASIN
        $ASIN = $asin;
        //valid ASIN
        //print "ASIN: $asin";
        $errors = '';
        #$appip_responsegroup 	= "ItemAttributes,Images,Offers,Reviews";
        #$appip_operation 		= "ItemLookup";
        #$appip_idtype	 		= "ASIN";
        #if ($region != "nl")
        #$pxml = aws_signed_request($aws_partner_locale, array("Operation"=>$appip_operation,"ItemId"=>$ASIN,"ResponseGroup" => $appip_responsegroup,"IdType"=>$appip_idtype,"AssociateTag"=>$aws_partner_id ), $public_key, $private_key);
        //print "<br>PXML: ";var_dump($pxml);
        #if(!is_array($pxml)){
        #	$pxml2=$pxml;
        #	$pxml = array();
        #	$pxml["itemlookuperrorresponse"]["error"]["code"]["message"] = $pxml2;
        #}
        #if(isset($pxml["itemlookuperrorresponse"]["error"]["code"])){
        #	$errors = $pxml["itemlookuperrorresponse"]["error"]["code"]["message"];
        #}
        //print "<br>Article found, checking";
        //Call 1
        $amazonRun += 1;
        //count loops to prevent multiple requests (will be reset for ASIN lists)
        //echo "<hr>Call 1<br>RUN: $amazonRun<br>";
        //if ($run == 2) break;
        #$result = FormatASINResult($pxml,$post->ID);
        $newPrice = lhg_db_get_lowest_amazon_price($post->ID, $region);
        #print "<br>New Price: $newPrice - $asin, $region";
        #if ($newPrice != "" and $newPrice != 0) break;
        #$i++;
        #}
        if ($lang != "de") {
            if ($newPrice == 0) {
                $newPrice = "out of stock";
            }
        }
        if ($lang == "de") {
            if ($newPrice == 0) {
                $newPrice = "nicht lieferbar";
            }
        }
        if ($errors == 'exceeded') {
            #	$hiddenerrors = "<"."!-- HIDDEN AMAZON PRODUCT IN A POST ERROR: Requests Exceeded -->";
            #	$errors = 'Requests Exceeded';
            #	if($extratext!=''){return $hiddenerrors.$extratext;}
            #	return $hiddenerrors;
            #}elseif($errors=='no signature match'){
            #        //echo "HERE A!";
            #	$hiddenerrors = "<"."!-- HIDDEN AMAZON PRODUCT IN A POST ERROR: Signature does not match AWS Signature. Check AWS Keys and Signature method. -->";
            #	$errors = 'Signature does not match';
            #	if($extratext!=''){return $hiddenerrors.$extratext;}
            #	return $hiddenerrors;
            //}elseif($errors=='not valid'){
            //        //echo "HERE B!";
            //	$hiddenerrors = "<"."!-- HIDDEN AMAZON PRODUCT IN A POST ERROR: Item Not Valid. Possibly not available in your locale or you did not enter a correct ASIN. -->";
            //	$errors = 'Not a valid item';
            //	if($extratext!=''){return $hiddenerrors.$extratext;}
            //	return $hiddenerrors;
            //}elseif($errors!=''){
            //	$hiddenerrors = "<"."!-- HIDDEN AMAZON PRODUCT IN A POST ERROR: ". $errors ."-->";
            //	if($extratext!=''){return $hiddenerrors.$extratext;}
            //	return $hiddenerrors;
        } else {
            //global $run;
            //$run += 1;
            //Call 2
            //echo "<hr>Call 2<br>";
            //$result = FormatASINResult($pxml,$post->ID);
            //print_r ($result);
            //echo "<br>WHAT: ".$result['URL'];
            //$returnval  = '	<br /><div class="amazon-box">';
            //$returnval = '                               ';
            //$returnval  .= ' 	 			<div class="amazon-box">';
            //<table cellpadding="0"class="amazon-product-table">'."\n";
            //$returnval .= '		<tr>'."\n";
            //$returnval .= '			<td valign="top">'."\n";
            $returnval .= '				<div class="amazon-image-wrapper">' . "\n";
            //$returnval .= '					<a href="' . $result["URL"] . '" '. $apippnewwindowhtml .'>' . awsImageGrabber($result['MediumImage'],'amazon-image') . '</a><br />'."\n";
            global $txt_cpl_noimage;
            // = "Kein Bild verf&uuml;gbar";
            #
            # ToDo: URL should be stored in DB and not fetched each time
            #
            #$amazon_image = awsImageGrabber($result['MediumImage'],'amazon-image');
            $attr = array('alt' => trim(strip_tags(translate_title(get_the_title($PID)))), 'title' => trim(strip_tags(translate_title(get_the_title($PID)))));
            $amazon_image = get_the_post_thumbnail($artid, array(130, 130), $attr);
            if (strpos($amazon_image, 'src=""')) {
                $amazon_image = '<img src="/wp-uploads/2013/03/noimage130.jpg" alt="' . $txt_cpl_noimage . '" title="' . $txt_cpl_noimage . '">';
            }
            if ($amazon_image == "") {
                $amazon_image = '<img src="/wp-uploads/2013/03/noimage130.jpg" alt="' . $txt_cpl_noimage . '" title="' . $txt_cpl_noimage . '">';
            }
            $returnval .= '					' . $amazon_image . '' . "\n";
            //$returnval .= '					'. awsImageGrabber($result['MediumImage'],'amazon-image') . ''."\n";
            //if($result['LargeImage']!=''){
            //$returnval .= '				<a target="amazon-image" href="javascript: void(0)" onclick="artwindow=window.open(\'' .$result['LargeImage'] .'\',\'art\',\'directories=no, location=no, menubar=no, resizable=no, scrollbars=no, status=no, toolbar=no, width=400,height=525\');artwindow.focus();return false;"><span class="amazon-tiny">'.$appip_text_lgimage.'</span></a>'."\n";
            //$returnval .= '					<a rel="appiplightbox" href="'.$result['LargeImage'] .'"><span class="amazon-tiny">'.$appip_text_lgimage.'</span></a>'."\n";
            //$returnval .= '					<span class="amazon-tiny">'.$appip_text_lgimage.'</span>'."\n";
            //}
            $returnval .= '				</div>' . "\n";
            $returnval .= '
<div class="amazon-buying">' . "\n";
            //$returnval .= '					<h2 class="amazon-asin-title"><a href="' . $result["URL"] . '" '. $apippnewwindowhtml .'><span class="asin-title">'.$result["Title"].'</span></a></h2>'."\n";
            //$returnval .= '					<h2 class="amazon-asin-title"><a href="' . $result["URL"] . '" '. $apippnewwindowhtml .'><span class="asin-title">'.$result["Title"].'</span></a></h2>'."\n";
            #if(isset($result["Author"])){
            #$returnval .= '					<span class="amazon-author">'.$appip_text_author.' '.$result["Author"].'</span><br />'."\n";
            #}
            #if(isset($result["Director"])){
            #$returnval .= '					<span class="amazon-director-label">'.$appip_text_director.': </span><span class="amazon-director">'.$result["Director"].'</span><br />'."\n";
            #}
            #if(isset($result["Actors"])){
            #$returnval .= '					<span class="amazon-starring-label">'.$appip_text_starring.': </span><span class="amazon-starring">'.$result["Actors"].'</span><br />'."\n";
            #}
            //if(isset($result["Rating"])){
            //$returnval .= '					<span class="amazon-rating-label">Rating: </span><span class="amazon-rating">'.$result["Rating"].'</span><br />'."\n";
            //}
            ob_start();
            if (function_exists('the_ratings')) {
                $returnval .= the_ratings();
            }
            $out1 = ob_get_contents();
            ob_end_clean();
            //get the correct! rating
            $post_id = $post->ID;
            global $wpdb;
            global $lhg_price_db;
            if ($lang != "de") {
                $ratings = $lhg_price_db->get_results("SELECT * FROM  `lhgtransverse_posts` WHERE postid_com = {$post_id}");
            }
            if ($lang == "de") {
                $ratings = $lhg_price_db->get_results("SELECT * FROM  `lhgtransverse_posts` WHERE postid_de = {$post_id}");
            }
            #$get_rates = $wpdb->get_results("SELECT rating_rating FROM $wpdb->ratings WHERE rating_postid = $post_id");
            $rating_total = 0;
            $rating_total = $ratings[0]->post_ratings_users_com + $ratings[0]->post_ratings_users_de;
            $rating = $ratings[0]->post_ratings_score_com + $ratings[0]->post_ratings_score_de;
            #foreach($get_rates as $get_rate){
            #        $rating += $get_rate->rating_rating;
            #        //print_r($get_rate);
            #        $rating_total++;
            #}
            //$returnval .= '<div class="hreview-aggregate">';
            //$returnval .= '<span class="item">';
            //$returnval .= '<span class="fn"><span class="value-title" title="'.get_the_title().'"/></span>';
            //$returnval .= '<span class="photo"><span class="value-title" title="'.wp_get_attachment_url( get_post_thumbnail_id($post->ID) ).'"/></span>';
            //$returnval .= '</span>';
            //$returnval .= '<span class="rating"><span class="value-title" title="'.($rating/$rating_total).'"/></span>';
            //$returnval .= '<span class="reviewer"><span class="value-title" title="linux-hardware-guide.de"/></span>';
            //$returnval .= '<span class="dtreviewed"><span class="value-title" title="'.get_the_date().'"/></span>';
            //$returnval .= '<span class="votes"><span class="value-title" title="'.$rating_total.'"/></span>';
            //$returnval .= '<span class="count"><span class="value-title" title="'.get_comments_number().'"/></span>';
            //$tooltip= 'Bewertet wird an dieser Stelle einzig die Linux-Kompatibilit&auml;t und nicht die Qualit&auml;t des Produktes.<div style="height: 3px;"></div>Sollten Sie dieses Produkt besitzen, dann helfen Sie bitte auch anderen Linux-Benutzern, indem Sie dessen
            //	   <a href="#comment-box">Linux-Kompatibilit&auml;t bewerten</a>.';
            //set tooltip depending on logged in or not (due to google rating)
            global $txt_tooltip;
            global $txt_amz_tooltip_loggedin;
            global $txt_amz_tooltip_not_loggedin;
            if (is_user_logged_in()) {
                $txt_tooltip = $txt_amz_tooltip_loggedin;
            }
            if (!is_user_logged_in()) {
                $txt_tooltip = $txt_amz_tooltip_not_loggedin;
            }
            $tooltip = $txt_tooltip;
            //'Bewertet wird an dieser Stelle einzig die Linux-Kompatibilit&auml;t und nicht die Qualit&auml;t des Produktes. Sollten Sie dieses Produkt besitzen, dann helfen Sie bitte auch anderen Linux-Benutzern, indem Sie dessen Linux-Kompatibilit&auml;t im Kommentar-Bereich dieser Seite bewerten.';
            $returnval .= "\n\t<b>{$txt_compat}:</b>";
            $returnval .= '
      <span class="tooltip">
        	' . tooltip($tooltip, -118, 380, -178) . '
      </span>';
            $returnval .= '

      <br />

  <div style="border: 0px solid #eee;">

    <div style="border: 0px solid #eee; width:80px; float: left;">
        ' . the_ratings_results($post->ID, 0, 0, 0, 10) . '
    </div>
    ';
            //Rich Snippet start
            //$returnval .= '<div itemscope itemtype="http://data-vocabulary.org/Review">';
            if ($rating_total == 1) {
                $returnval .= '
    <div style="border: 0px solid #eee; white-space: nowrap;">
        &nbsp;&nbsp;(<span class="rating">
          	<span class="value-title" title="' . round($rating / $rating_total, 1) . '">
                                ' . round($rating / $rating_total, 1) . '
                </span>
        </span> ' . $txt_with . '

        <span class="votes">
        	<span class="value-title" title="' . $rating_total . '">
                                ' . $rating_total . '
                </span>
        </span> ' . $txt_rating . ')
    </div>

  </div>' . "\n";
            }
            if ($rating_total == 0) {
                $rate_average_value = 0;
            } else {
                $rate_average_value = round($rating / $rating_total, 1);
            }
            if ($rating_total != 1) {
                $returnval .= '
    <div style="border: 0px solid #eee; white-space: nowrap;">
  	&nbsp;&nbsp;(<span class="rating">
        	<span class="value-title" title="' . $rate_average_value . '">
                                ' . $rate_average_value . '
                </span>
        </span> ' . $txt_with . '

        <span class="votes">
        	<span class="value-title" title="' . $rating_total . '">
                                ' . $rating_total . '
                </span>
        </span> ' . $txt_ratings . ')
    </div>
  </div>' . "\n";
            }
            //Rich Snippet end
            //$returnval .= '</div>';
            $returnval .= '
  <br />
';
            //also store cheapest price - not used. Use central price DB instead
            #$cheapest_price = lhg_db_get_cheapest_price($post->ID);
            #print "<br>Cheapest: $cheapest_price";
            #$meta="cheapest_price_".$region;
            #update_post_meta($post->ID,$meta,$cheapest_price);
            #                                $returnval .= '<div class="amaz-grey-box" style="border: 0px solid #eee; background-color: #eee;">';
            //if ($rating_total != 1) $returnval .= ' ('.$rating_total.' Bewertungen)</div></div><br>'."\n";
            //$returnval .= '				<hr noshade="noshade" size="1" />'."\n";
            //$returnval .= '				<div align="left">'."\n";
            //$returnval .= '					<table class="amazon-product-price" cellpadding="0">'."\n";
            //if($extratext!=''){
            //$returnval .= '						<tr>'."\n";
            //$returnval .= '							<td class="amazon-post-text" colspan="2">'.$extratext.'</td>'."\n";
            //$returnval .= '						</tr>'."\n";
            //}
            //If($result["PriceHidden"]==1 ){
            //	$returnval .= '						<tr>'."\n";
            //	$returnval .= '							<td class="amazon-list-price-label">'.$appip_text_listprice.':</td>'."\n";
            //	$returnval .= '							<td class="amazon-list-price-label">'.$amazonhiddenmsg.'</td>'."\n";
            //	$returnval .= '						</tr>'."\n";
            //}elseif($result["ListPrice"]!='0'){
            //	$returnval .= '						<tr>'."\n";
            //	$returnval .= '							<td class="amazon-list-price-label">Preis: '.$appip_text_listprice.':</td>'."\n";
            //$returnval .= '							Preis: '.$appip_text_listprice.':'."\n";
            //$returnval .= '							'.  mb_convert_encoding($result["ListPrice"], $encodemode, mb_detect_encoding( $result["ListPrice"], "auto" )) .' '."\n";
            //	$returnval .= '							<td class="amazon-list-price">'.  mb_convert_encoding($result["ListPrice"], $encodemode, mb_detect_encoding( $result["ListPrice"], "auto" )) .'</td>'."\n";
            //	$returnval .= '						</tr>'."\n";
            //}
            if (isset($newPrice)) {
                #print "AAH!";
                #$result["LowestNewPrice"])){
                #if($result["LowestNewPrice"]=='Too low to display'){
                #	$newPrice = 'Check Amazon For Pricing';
                #}else{
                #	#$newPrice = $result["LowestNewPrice"];
                #}
                //$returnval .= '						<tr>'."\n";
                //$returnval .= '							<td class="amazon-new-label">'.$appip_text_newfrom.':</td>'."\n";
                #					$returnval .= '							'.$txt_price.':'."\n";
                #if ($result["TotalNew"] == '') $returnval.="Warn \n";
                #if($result["TotalNew"]>0){
                //$ship=scrape($asin);
                //print_r($ship);
                //$returnval .= "Total: ".$SalePrice['FormattedPrice']."-".$result["ListPrice"]."+".$ship[1]."<br>";
                #not needed any longer. Stored in DB
                //$newPrice
                $myFile = "/home/wordpressftp/amazon-{$region}.txt";
                $fh = fopen($myFile, 'a') or die("can't open file");
                $stringData = $post->ID . ";" . $newPrice . "\n";
                fwrite($fh, $stringData);
                fwrite($fh, $stringData);
                fclose($fh);
                # store price - currently disabled
                #                //$newPrice with date
                $myFile = "/home/wordpressftp/amazon_date-{$region}.txt";
                $timeInf = time();
                $fh = fopen($myFile, 'a') or die("can't open file");
                $stringData = $post->ID . ";" . $newPrice . ";" . $timeInf . ";" . $result["URL"] . "\n";
                fwrite($fh, $stringData);
                fclose($fh);
                #lhg_amazon_price_to_db($region, $post->ID, $asin, $newPrice, $result["URL"], $timeInf);
                //remove Amazon string Symbol
                $newPrice = lhg_remove_amazon_currency_symbol($newPrice, $region);
                //add currency symbol
                #                                        $returnval .= lhg_get_currency_symbol ( $region );
                /*
                                                if ($region == "co.uk") $returnval .= "&pound;";
                                                if ($region == "co.jp") $returnval .= "&yen;";
                                                if ($region == "cn") {
                                                	$returnval .= "&yen;";
                                                        $newPrice  = substr($newPrice,2);
                                                }
                                                if ($region == "co.jp") $newPrice  = substr($newPrice,2);
                */
                #                                        $returnval .= '							'. mb_convert_encoding($newPrice , $encodemode, mb_detect_encoding( $newPrice, "auto" )).' <span itemprop="availability" content="in_stock" class="instock"> ('.$txt_on_stock.') </span>'."\n";
                #                                        $returnval .= '<br><div class="shipping"><font size="1">('.$txt_shipping.')';
                global $txt_tooltip2;
                $tooltip = $txt_tooltip2;
                //"Die von Amazon zur Verf&uuml;gung gestellten Preise sind exklusive m&ouml;glicherweise zus&auml;tzlich anfallender Versandkosten (abh&auml;ngig vom jeweiligen Anbieter des Amazon-Marketplace).";
                #                	                $returnval .= '<span class="tooltip">'.tooltip($tooltip).'<span>';
                #                                        $returnval .= '</font></div>';
                #
                #					}else{
                #//						$returnval .= '							'. mb_convert_encoding($newPrice , $encodemode, mb_detect_encoding( $newPrice, "auto" )).' <span class="outofstock">'.$appip_text_outofstock.'</span>'."\n";
                #						$returnval .= 'BB unbekannt							'; //. mb_convert_encoding($newPrice , $encodemode, mb_detect_encoding( $newPrice, "auto" )).' <span class="outofstock">'.$appip_text_outofstock.'</span>'."\n";
                #}
                //if($result["TotalNew"]>0){
                //	$returnval .= '							<td class="amazon-new">'. mb_convert_encoding($newPrice , $encodemode, mb_detect_encoding( $newPrice, "auto" )).' <span class="instock">'.$appip_text_instock.'</span></td>'."\n";
                //}else{
                //	$returnval .= '							<td class="amazon-new">'. mb_convert_encoding($newPrice , $encodemode, mb_detect_encoding( $newPrice, "auto" )).' <span class="outofstock">'.$appip_text_outofstock.'</span></td>'."\n";
                //}
                //$returnval .= '						</tr>'."\n";
                //				$returnval .= '								</div>'."\n";
                //store in DB
                $meta = "price-amazon." . $region;
                update_post_meta($post->ID, $meta, $newPrice);
                //$meta="url-amazon.".$region;
                //update_post_meta($post->ID,$meta,$result["URL"]);
            } elseif ($region != "pl") {
                #Price tag
                $aid = get_id();
                //if( ($errors!='') && ($region == "en")){
                //   $returnval .='Not available at <a target="_blank" href="http://www.amazon.'.$region.'/b/?_encoding=UTF8&camp=1789&creative=390957&linkCode=ur2&node=2956536011&tag=linuhardguid-20">Amazon.'.$region.'</a><img src="https://www.assoc-amazon.com/e/ir?t=linuhardguid-20&l=ur2&o=1" width="1" height="1" border="0" alt="" style="border:none !important; margin:0px !important;" />';
                //}else{
                //$returnval .= '							'.$txt_price.':'."\n";
                $ProductIsUnavailable = 1;
                if ($result["URL"] == "") {
                    $meta = "url-amazon." . $region;
                    $result["URL"] = get_post_meta($post->ID, $meta, true);
                }
                //still undefined?
                if ($result["URL"] == "") {
                    $region_tmp = $region;
                    if ($region == "nl") {
                        $region_tmp = "de";
                    }
                    $result["URL"] = 'http://www.amazon.' . $region_tmp . '/?_encoding=UTF8&amp;camp=15121&amp;creative=390961&amp;linkCode=ur2&amp;tag=' . $aid;
                    $NoUrlAvailable = 1;
                }
                #                                        $returnval .= '							'. mb_convert_encoding($newPrice , $encodemode, mb_detect_encoding( $newPrice, "auto" )).' <span class="outofstock">('.$txt_out_of_stock.')</span>'."\n";
                #     					if ($region !== "de") if ($NoUrlAvailable != 1) $returnval .='<br><div class="amazon-cr"></div>'.$txt_not_avail_at.' <a target="_blank" href="http://www.amazon.'.$region.'/?_encoding=UTF8&camp=15121&creative=390961&linkCode=ur2&tag='.$aid.'" rel="nofollow">Amazon.'.$region.'</a><div class="amazon-cr"></div>';
                #     					if ($region !== "de") if ($NoUrlAvailable == 1) $returnval .='<br><div class="amazon-cr"></div>'.$txt_never_avail.' <a target="_blank" href="http://www.amazon.'.$region.'/?_encoding=UTF8&camp=15121&creative=390961&linkCode=ur2&tag='.$aid.'" rel="nofollow">Amazon.'.$region.'</a><div class="amazon-cr"></div>';
                #     					if ($region == "de") $returnval .='<br>Nicht lieferbar von <a target="_blank" href="http://www.amazon.'.$region.'/?_encoding=UTF8&camp=15121&creative=390961&linkCode=ur2&tag='.$aid.'" rel="nofollow">Amazon.'.$region.'</a>';
                //<img src="https://www.assoc-amazon.com/e/ir?t=linuhardguid-20&l=ur2&o=1" width="1" height="1" border="0" alt="" style="border:none !important; margin:0px !important;" />';
                // $returnval .= '							'. mb_convert_encoding($newPrice , $encodemode, mb_detect_encoding( $newPrice, "auto" )).' <span class="instock"> (auf Lager) </span>'."\n";
                //}
                #Not needed any longer. Stored in DB
                $myFile = "/home/wordpressftp/amazon-{$region}.txt";
                $fh = fopen($myFile, 'a') or die("can't open file");
                $stringData = $post->ID . ";" . $txt_out_of_stock . "\n";
                fwrite($fh, $stringData);
                fclose($fh);
                # store price to file currently disabled
                #
                #              //print 'Res:'. $result["URL"];
                #               //$newPrice with date
                $myFile = "/home/wordpressftp/amazon_date-{$region}.txt";
                $timeInf = time();
                $fh = fopen($myFile, 'a') or die("can't open file");
                $stringData = $post->ID . ";" . $newPrice . ";" . $timeInf . ";" . $result["URL"] . "\n";
                fwrite($fh, $stringData);
                fclose($fh);
                //store in DB
                $newPrice = "out of stock";
                if ($region === "de") {
                    $newPrice = "nicht lieferbar";
                }
                $meta = "price-amazon." . $region;
                update_post_meta($post->ID, $meta, $newPrice);
                //$meta="url-amazon.".$region;
                //update_post_meta($post->ID,$meta,$result["URL"]);
                #print "BBB<br>";
                #lhg_amazon_price_to_db($region, $post->ID, $asin, $newPrice, $result["URL"], $timeInf);
                //                                $returnval.="Warn \n";
            }
            //if(isset($result["LowestUsedPrice"])){
            //	$returnval .= '						<tr>'."\n";
            //	$returnval .= '							<td class="amazon-used-label">'.$appip_text_usedfrom.':</td>'."\n";
            //	if($result["TotalUsed"]>0){
            //
            //		$returnval .= '						<td class="amazon-used">'. mb_convert_encoding($result["LowestUsedPrice"], $encodemode, mb_detect_encoding( $result["LowestUsedPrice"], "auto" )) .' <span class="instock">'.$appip_text_instock.'</span></td>'."\n";
            //	}else{
            //		$returnval .= '						<td class="amazon-new">'. mb_convert_encoding($result["LowestNewPrice"], $encodemode, mb_detect_encoding( $result["LowestUsedPrice"], "auto" )) . ' <span class="outofstock">'.$appip_text_outofstock.'</span></td>'."\n";
            //	}
            //	$returnval .= '						</tr>'."\n";
            //}
            //$returnval .= '						<tr>'."\n";
            //$returnval .= '							<td valign="top" colspan="2">'."\n";
            //$returnval .= '								<div class="amazon-dates">'."\n";
            //if(isset($result["ReleaseDate"])){
            //	if(strtotime($result["ReleaseDate"]) > strtotime(date("Y-m-d",time()))){
            //$returnval .= '									<span class="amazon-preorder"><br />'.$appip_text_releasedon.' '.date("F j, Y", strtotime($result["ReleaseDate"])).'.</span>'."\n";
            //	}else{
            //$returnval .= '									<span class="amazon-release-date">'.$appip_text_reldate.' '.date("F j, Y", strtotime($result["ReleaseDate"])).'.</span>'."\n";
            //	}
            //}
            //update amazon price first (see above), now show the button with updated price
            $returnval .= lhg_get_shop_button($post->ID);
            if ($errors == '') {
                //product not available at amazon
                if ($result["URL"] == "") {
                    $meta = "url-amazon." . $region;
                    $result["URL"] = get_post_meta($post->ID, $meta, true);
                }
                //still undefined?
                if ($result["URL"] == "") {
                    $result["URL"] = 'http://www.amazon.' . $region . '/?_encoding=UTF8&camp=15121&creative=390961&linkCode=ur2&tag=' . $aid;
                    $NoUrlAvailable = 1;
                }
                // href="http://www.amazon.'.$region.'/?_encoding=UTF8&camp=15121&creative=390961&linkCode=ur2&tag='.$aid.'">
                //gif for german page
                #                                if ($lang == "de") $returnval .= '<br><a href="' . $result["URL"] .'" rel="nofollow"><img src="'.$txt_button.'" border="0" '.$txt_button_width.'></a>';
                #
                #                                //dynamic button for everyone else
                #        			if ($lang != "de") {
                #
                #                                        global $txt_button_string;
                #
                #                                        if ($ProductIsUnavailable == 1) if ($NoUrlAvailable == 1) {
                ##                                        	$txt_button_string = $txt_search_at.' Amazon.'.$region;
                #                                       	$returnval .= '<br><a href="'. $result["URL"] .'" class="css_btn_class" rel="nofollow"><i class="icon-search icon-large3"></i>&nbsp;'.$txt_button_string.'</a>';
                #                                       }
                #
                #                                       if ($ProductIsUnavailable == 1) if ($NoUrlAvailable != 1) {
                #                                       	$txt_button_string = $txt_preorder.' Amazon.'.$region;
                #                                        	$returnval .= '<br><a href="'. $result["URL"] .'" class="css_btn_class" rel="nofollow"><i class="icon-shopping-cart icon-large3"></i>&nbsp;'.$txt_button_string.'</a>';
                #                                        }
                #
                #                                        if ($ProductIsUnavailable != 1) {
                #                                                $txt_button_string = $txt_buy_from.' Amazon.'.$region;
                #                                                $returnval .= '<br><a href="'. $result["URL"] .'" class="css_btn_class" rel="nofollow"><i class="icon-shopping-cart icon-large3"></i>&nbsp;'.$txt_button_string.'</a>';
                #	                        	}
                #	                        }
            }
            if ($extrabutton == 1 && $aws_partner_locale != '.com') {
                //$returnval .= '									<br /><div><a style="display:block;margin-top:8px;margin-bottom:5px;width:165px;" '. $apippnewwindowhtml .' href="' . $result["URL"] .'"><img src="'.WP_PLUGIN_URL.'/amazon-product-in-a-post-plugin/images/buyamzon-button.png" border="0" style="border:0 none !important;margin:0px !important;background:transparent !important;"/></a></div>'."\n";
            }
            //close amzbox
            $returnval .= '</div>';
            #                                $returnval .= '</div></div>'."\n";
            //$returnval .= '							</td>'."\n";
            //$returnval .= '						</tr>'."\n";
            //If(!isset($result["LowestUsedPrice"]) && !isset($result["LowestNewPrice"]) && !isset($result["ListPrice"])){
            //	$returnval .= '						<tr>'."\n";
            //	$returnval .= '							<td class="amazon-price-save-label" colspan="2">'.$appip_text_notavalarea.'</td>'."\n";
            //	$returnval .= '						</tr>'."\n";
            //}
            //$returnval .= '					</table>'."\n";
            //				$returnval .= '				</div>';
            // <br style="clear:left;">'."\n";
            //$returnval .= '				</div>'."\n";
            //$returnval .= '			</td>'."\n";
            //$returnval .= '		</tr>'."\n";
            //$returnval .= '	</table>'."\n";
            //$siteurl="linux-hardware-guide.com";
            $catlist = category_links();
            global $lhg_is_mobile_mode;
            if ($lhg_is_mobile_mode != 1) {
                $returnval = $returnval . '<div class="amazon-cat-list">' . $catlist . "</div>";
            }
            /*<table class=producttop border=0>
              #<tr class="producttop">
              #<td class="producttop" width=50%>'.
              $returnval
              .'</td>
              <td class="producttop" width=50%>'. $catlist .' </td></tr></table>';
              */
            if ($lhg_is_mobile_mode == 1) {
                $returnval = '<div class="amazon_product_top">' . $returnval . '</div>
                                <div class="amazon-cat-list">' . $catlist . ' </div>
                                <br style="clear:left;" /> ';
            }
            if (is_category()) {
                // is category, not chart output
                // echo "<h2>Cat</h2>";
            } else {
                if ($errors == '') {
                    # creation of chart should be performed on separate machine
                    # currently disabled
                    #
                    #     //echo "Here";
                    start_pricechart($post->ID);
                    //print "lang: $lang";
                    // Pricetrend image alt text:
                    $currency = lhg_get_currency_symbol($region);
                    $imgtext = $txt_pricetrend;
                    if (file_exists("/var/www/charts/" . $post->ID . "-" . $region . ".dat")) {
                        $myFile = "/var/www/charts/" . $post->ID . "-" . $region . ".dat";
                        $file = file($myFile);
                        list($min, $max, $chartdate) = split(";", $file[0]);
                        //echo "Min, Max: $min $max";
                        $title = get_the_title();
                        //echo "T: $title";
                        $sp = strpos($title, "(");
                        //echo "Pos: $sp";
                        if ($sp != "") {
                            $title = substr($title, 0, $sp);
                        }
                        //echo "T: $title";
                        $imgtext = $txt_pricetrend . "\n" . translate_title($title) . "\n-\nMinimum: {$currency} {$min} \nMaximum: {$currency} {$max}  \n{$txt_updated}: {$chartdate}";
                    }
                    if ($lang == "de") {
                        // en has no support for multiple affiliates a.t.m.
                        //if (file_exists("/var/www/charts/".$post->ID."m.png")){
                        if (false) {
                            $returnval .= '<br style="clear:left;" /><img src="http://' . $siteurl . '/wp-uploads/charts/' . $post->ID . 'm.png" alt="' . $imgtext . '" title="' . $imgtext . '" />';
                        } else {
                            if (file_exists("/var/www/charts/" . $post->ID . "-" . $region . ".png")) {
                                if ($charterror == 0) {
                                    $returnval .= '<br style="clear:left;" /><img src="/wp-uploads/charts/' . $post->ID . '-' . $region . '.png" alt="' . $imgtext . '" title="' . $imgtext . '" />';
                                }
                            }
                        }
                    } else {
                        if ($charterror == 0) {
                            if (file_exists("/var/www/charts/" . $post->ID . "-" . $region . ".png")) {
                                $returnval .= '<br style="clear:left;" /><img src="/wp-uploads/charts/' . $post->ID . "-" . $region . '.png" alt="' . $imgtext . '" title="' . $imgtext . '" />';
                            }
                        }
                    }
                    #list known prices
                    #if (file_exists("/var/www/charts/list".$post->ID.".txt")){
                    #$PriceList = file("/var/www/charts/list".$post->ID.".txt");
                    #
                    #$returnval .= '<ul>Preisvergleich
                    #               <li>Amazon.de: '.mb_convert_encoding($newPrice , $encodemode, mb_detect_encoding( $newPrice, "auto" )).' (<a href="' . $result["URL"] .'">bestellen</a>)';
                    #
                    #$returnval .= $PriceList[0];
                    #$returnval .="</ul>";
                    #}
                }
            }
            //List related categories
            //$returnval .= category_links();
            //show CPU table
            #if (in_category('CPU')) $returnval .= cpu_comparison();
            $googlecom = '<script async src="http://pagead2.googlesyndication.com/pagead/js/adsbygoogle.js"></script>
<ins class="adsbygoogle"
     style="display:inline-block;width:728px;height:90px"
     data-ad-client="ca-pub-5383503261197603"
     data-ad-slot="4611540473"></ins>
<script>
(adsbygoogle = window.adsbygoogle || []).push({});
</script>';
            $googlede = '<script async src="//pagead2.googlesyndication.com/pagead/js/adsbygoogle.js"></script>
<!-- Linux-Hardware-Guide.de -->
<ins class="adsbygoogle"
     style="display:inline-block;width:728px;height:90px"
     data-ad-client="ca-pub-5383503261197603"
     data-ad-slot="3000901678"></ins>
<script>
(adsbygoogle = window.adsbygoogle || []).push({});
</script>';
            $google_small_mobile = '
<center>
<script async src="//pagead2.googlesyndication.com/pagead/js/adsbygoogle.js"></script>
<!-- Mobile Banner -->
<ins class="adsbygoogle"
     style="display:inline-block;width:320px;height:50px"
     data-ad-client="ca-pub-5383503261197603"
     data-ad-slot="9621646075"></ins>
<script>
(adsbygoogle = window.adsbygoogle || []).push({});
</script>
</center>';
            global $lhg_is_mobile_mode;
            global $lhg_mobile_size;
            if ($lhg_is_mobile_mode != 1) {
                if ($lang == "en") {
                    if (!is_user_logged_in()) {
                        $returnval .= $googlecom;
                    }
                }
            }
            //
            if ($rating_total == 0) {
                $rate_average_value = 0;
            } else {
                $rate_average_value = round($rating / $rating_total, 1);
            }
            //only show in case of low rating
            if ($lhg_is_mobile_mode != 1) {
                if ($lang == "de") {
                    if ($rate_average_value < 5) {
                        if (!is_user_logged_in()) {
                            $returnval .= $googlede;
                        }
                    }
                }
            }
            if ($lhg_is_mobile_mode == 1) {
                if (!is_user_logged_in()) {
                    if ($lhg_mobile_size == "small") {
                        $returnval .= $google_small_mobile;
                    } elseif ($lhg_mobile_size == "large") {
                        $returnval .= $googlecom;
                    } else {
                        $returnval .= $google_small_mobile;
                    }
                }
            }
            //show article header
            //itemprop description is closed in related-post-thumbnails
            $returnval .= '<br /><h2>' . $txt_Compat . '</h2><div itemprop="description"><div class="description">';
            $returnval .= affilinet();
            //article_list();
            return $returnval;
        }
    }
}
 /**
  * Parses content tags
  * Since 1.4.6
  */
 function format_content($string, $data = array(), $rating)
 {
     if (empty($string) || (empty($data) || !is_array($data))) {
         return false;
     }
     $string = htmlentities($string);
     $params = array();
     $pattern = '/\\{(excerpt|summary|stats|title|image|thumb|rating|score|url|text_title|author|category|views|comments)\\}/i';
     preg_match_all($pattern, $string, $matches);
     array_map('strtolower', $matches[0]);
     if (in_array("{title}", $matches[0])) {
         $string = str_replace("{title}", $data['title'], $string);
     }
     if (in_array("{stats}", $matches[0])) {
         $string = str_replace("{stats}", $data['stats'], $string);
     }
     if (in_array("{excerpt}", $matches[0])) {
         $string = str_replace("{excerpt}", htmlentities($data['summary'], ENT_QUOTES), $string);
     }
     if (in_array("{summary}", $matches[0])) {
         $string = str_replace("{summary}", htmlentities($data['summary'], ENT_QUOTES), $string);
     }
     if (in_array("{image}", $matches[0])) {
         $string = str_replace("{image}", $data['img'], $string);
     }
     if (in_array("{thumb}", $matches[0])) {
         $string = str_replace("{thumb}", $data['img'], $string);
     }
     // WP-PostRatings check
     if ($rating && $this->postRating) {
         if (in_array("{rating}", $matches[0])) {
             $string = str_replace("{rating}", the_ratings_results($data['id']), $string);
         }
         if (in_array("{score}", $matches[0])) {
             $string = str_replace("{score}", expand_ratings_template('%RATINGS_SCORE%', $data['id']), $string);
             // removing the redundant plus sign
             $string = str_replace('+', '', $string);
         }
     }
     if (in_array("{url}", $matches[0])) {
         $string = str_replace("{url}", $data['url'], $string);
     }
     if (in_array("{text_title}", $matches[0])) {
         $string = str_replace("{text_title}", $data['text_title'], $string);
     }
     if (in_array("{author}", $matches[0])) {
         $string = str_replace("{author}", $data['author'], $string);
     }
     if (in_array("{category}", $matches[0])) {
         $string = str_replace("{category}", $data['category'], $string);
     }
     if (in_array("{views}", $matches[0])) {
         $string = str_replace("{views}", $data['views'], $string);
     }
     if (in_array("{comments}", $matches[0])) {
         $string = str_replace("{comments}", $data['comments'], $string);
     }
     return html_entity_decode($string);
 }
 /**
  *
  * @global type $wp_locale
  * @global type $wp_query
  * @param int $source SEARCH_ constant
  * @param type $wpQueryResults
  * @param type $displayPostMeta
  * @param string $maxResults 
  */
 private function populate($source, $wpQueryResults, $displayPostMeta, $maxResults)
 {
     global $wp_locale;
     global $wp_query;
     $dateFormat = get_option('date_format');
     // Some other plugin threw a fit once if I didn't instantiate
     // WP_Query once to initialize everything and then call it
     // for real. Might have been "Search Everything". I think there's
     // a comment about it in an old version of DWLS.
     $wp_query = $wpQueryResults = new WP_Query();
     $wp_query = $wpQueryResults = new WP_Query();
     if (function_exists('relevanssi_do_query')) {
         // Relevanssi isn't treating 0 as "unlimited" results
         // like WordPress's native search does. So we'll replace
         // $maxResults with a really big number, the biggest one
         // PHP knows how to represent, if $maxResults == -1
         // (unlimited)
         if (-1 == $maxResults) {
             $maxResults = PHP_INT_MAX;
         }
     }
     $wpQueryParams = $_GET;
     $wpQueryParams['showposts'] = $maxResults;
     if (self::SEARCH_WPCOMMERCE === $source) {
         $wpQueryParams['post_type'] = 'wpsc-product';
     } else {
         # LHG: was "any", but now limited to HW posts
         $wpQueryParams['post_type'] = 'post';
     }
     $wpQueryParams['post_status'] = 'publish';
     $queryString = http_build_query($wpQueryParams);
     $wpQueryResults->query($queryString);
     $this->searchTerms = $wpQueryResults->query_vars['s'];
     $wpQueryResults = apply_filters('dwls_alter_results', $wpQueryResults, $maxResults);
     foreach ($wpQueryResults->posts as $result) {
         // Add author names & permalinks
         if ($displayPostMeta) {
             $result->post_author_nicename = $this->authorName($result->post_author);
         }
         $result->permalink = lhg_translate_search_url(get_permalink($result->ID));
         if (function_exists('get_post_thumbnail_id')) {
             // Support for WP 2.9 post thumbnails
             $postImageID = get_post_thumbnail_id($result->ID);
             $postImageData = wp_get_attachment_image_src($postImageID, apply_filters('post_image_size', 'thumbnail'));
             $hasThumbnailSet = $postImageData !== false;
         } else {
             // No support for post thumbnails
             $hasThumbnailSet = false;
         }
         if ($hasThumbnailSet) {
             $result->attachment_thumbnail = $postImageData[0];
         } else {
             // If no post thumbnail, grab the first image from the post
             $applyContentFilter = get_option('daves-wordpress-live-search_apply_content_filter', false);
             $content = $result->post_content;
             if ($applyContentFilter) {
                 $content = apply_filters('the_content', $content);
             }
             $content = str_replace(']]>', ']]&gt;', $content);
             $result->attachment_thumbnail = $this->firstImg($content);
         }
         $result->attachment_thumbnail = apply_filters('dwls_attachment_thumbnail', $result->attachment_thumbnail);
         $result->post_excerpt = $this->excerpt($result);
         $result->post_date = date_i18n($dateFormat, strtotime($result->post_date));
         $result->post_date = apply_filters('dwls_post_date', $result->post_date);
         // We don't want to send all this content to the browser
         unset($result->post_content);
         // xLocalization
         $result->post_title = apply_filters("localization", $result->post_title);
         $result->post_title = apply_filters('dwls_post_title', $result->post_title);
         global $lang;
         if ($lang != "de") {
             $pt = qtrans_useCurrentLanguageIfNotFoundUseDefaultLanguage($result->post_title);
         }
         if ($lang == "de") {
             $pt = $result->post_title;
         }
         $result->post_title = $pt . "<br>" . the_ratings_results($result->ID, 0, 0, 0, 10);
         #."<br>".$pt;
         $result->show_more = true;
         $this->results[] = $result;
     }
 }
    public function widget($args, $lhg_instance)
    {
        //show only for english pages (missing translation of articles)
        // ToDo: Check if translation exists, otherwise hide
        global $region;
        if ($region == "fr" or $region == "es" or $region == "it" or $region == "nl" or $region == "co.jp" or $region == "cn") {
            return;
        }
        #echo "INS: ".$instance['title'];
        #var_dump($lhg_instance);
        $title = apply_filters('widget_title', $lhg_instance['title']);
        $artid = $lhg_instance['artid'];
        $default_image = "";
        $text = get_post_field('post_content', $artid);
        $text = lhg_clean_extract($text, 600);
        $more = "(more)";
        $posttitle = translate_title(get_the_title($artid));
        $s = explode("(", $posttitle);
        $short_title = trim($s[0]);
        $sub_title = trim($s[1]);
        $sub_title = str_replace(")", "", $sub_title);
        //get the latest date
        global $wpdb;
        $sql = "\n                SELECT post_modified\n                FROM {$wpdb->posts}\n                WHERE ID = " . $artid;
        $last_update = $wpdb->get_var($sql);
        $wpdf = get_option('date_format');
        $lupdate = date($wpdf, strtotime($last_update));
        // get comments
        $cn = lhg_get_comments_number($artid);
        if ($cn > 0) {
            //Comment tooltip
            $txt_comments = $txt_cpl_comments;
            //"Kommentare";
            //if ($lang == "en") $txt_comments="comments";
            if ($cn == 1) {
                $txt_comments = $txt_cpl_comment;
                //"Kommentar";
                //if ($lang == "en") $txt_comments="comment";
            }
            $coutInv = '';
            //<span class="comment-count-out-invisible"></span>';
            $cout = '<a href="' . $arturl . '#comments" alt="' . $cn . ' ' . $txt_comments . '" title="' . $cn . ' ' . $txt_comments . '">
                	        <div class="comment-count-out">
                        	  <span class="comment-bubble"></span>
	                           <span class="comment-count">' . $cn . '</span>
        	                </div>
                	       </a>';
        } else {
            $coutInv = "";
            $cout = "";
        }
        //ratings
        $ratings = the_ratings_results($artid, 0, 0, 0, 10);
        #var_dump($last_update);
        #var_dump($wpdf);
        #$sql = "SELECT post_modified
        #        FROM $wpdb->posts
        #        WHERE post_id ='".$artid."'";
        #$last_update = $wdpb->get_var( $sql );
        #echo( "Last updated $lupdate ." );
        #$date = get_the_modified_date($artid)
        $permalink = get_permalink($artid);
        $image = get_the_post_thumbnail($artid, array(130, 130));
        #echo "ARGS: $args";
        #var_dump($args);
        extract($args);
        #var_dump($instance);
        #echo "TIT: ".$instance['title'];
        echo "{$before_widget}";
        #$title = apply_filters ( 'widget_title', $instance['title'] );
        #$artid = empty( $instance['artid'] ) ? '&nbsp;' : $instance['artid'];
        #if ( !empty( $title ) ) {
        echo $before_title . $title . $after_title;
        #};
        echo '<div class="featured-hw">';
        #echo '<div class="featured-title-date">'.$lupdate.':</div>';
        echo '<div class="featured-title"><a href="' . $permalink . '">' . $short_title . '</a></div>
                <span class="featured-comments">' . $cout . '</span>
                <span class="featured-ratings">' . $ratings . '</span>

                <div class="featured-title-sub"><a href="' . $permalink . '">(' . $sub_title . ')</a></div>
                <div class="featured-image"><a href="' . $permalink . '">' . $image . '</a></div>
                ' . $text . '... <a href="' . $permalink . '">' . $more . '</a></p>';
        echo "</div>";
        echo $after_widget;
    }