<td id="col1"></td>

                <td id="title-colhw">' . $txt_subscr_article . '</td>';
        //                <td id="col4">'.$txt_modus.'</td>
        echo '
                <td id="col2">' . $txt_subscr_regist_date . '</td>




                </tr>';
        foreach ($subscriptions as $a_subscription) {
            $comment_excerpt = "";
            $permalink = get_permalink($a_subscription->post_id);
            $title = translate_title(get_the_title($a_subscription->post_id));
            $art_image = get_the_post_thumbnail($a_subscription->post_id, array(55, 55));
            $PID = $a_subscription->post_id;
            $UID = get_current_user_id();
            $searchargs = array('status' => 'approve', 'user_id' => $UID, 'post_id' => $PID);
            $comments = get_comments($searchargs);
            foreach ($comments as $comment) {
                //$comment_excerpt = $comment->comment_content;
                //echo "CID: $comment->comment_ID";
                $CID = $comment->comment_ID;
                $comment_found = get_comment($CID);
                //shorten comment
                if (strlen($comment_found->comment_content) > 310) {
                    $comment_excerpt = substr($comment_found->comment_content, 0, 300) . "...";
                } else {
                    $comment_excerpt = $comment_found->comment_content;
Beispiel #2
0
        echo '<a href="' . $URLC . '/ja/' . $posturlcom . '"><img src="/wp-content/plugins/qtranslate/flags/jp.png"
title="Region: Japan
Currency: &yen;"  alt="Japan" /></a>';
        echo '<a href="' . $URLC . '/zh/' . $posturlcom . '"><img src="/wp-content/plugins/qtranslate/flags/cn.png"
title="Region: China
Currency: RMB"  alt="China" /></a>

<br clear="all"/>';
        echo '</span>';
    }
}
ob_start();
wp_title('|', true, 'right');
$s = ob_get_contents();
ob_end_clean();
echo translate_title($s);
// Add the blog name.
bloginfo('name');
// Add the blog description for the home/front page.
$site_description = get_bloginfo('description', 'display');
if ($site_description && (is_home() || is_front_page())) {
    echo " | {$site_description}";
}
// Add a page number if necessary:
if ($paged >= 2 || $page >= 2) {
    echo ' | ' . sprintf(__('Page %s'), max($paged, $page));
}
global $region;
//get_lang();
if ($region == "fr") {
    $loc = "France";
Beispiel #3
0
        the_post();
        ?>


		<div <?php 
        post_class();
        ?>
 id="post-<?php 
        the_ID();
        ?>
">
			<h1 class="content-title">
			<span style="font-family: PTSansBold;">
                        <?php 
        if ($region != "de") {
            $title = translate_title(qtrans_use('en', get_the_title(), false));
        } else {
            $title = get_the_title();
        }
        $s = explode("(", $title);
        $short_title1 = trim($s[0]);
        $short_title2 = "(" . trim($s[1]);
        //check for empty part2
        if ($short_title2 == "(") {
            $short_title2 = "";
        }
        echo $short_title1;
        ?>
                        </span><?php 
        echo $short_title2;
        ?>
Beispiel #4
0
     }
     echo '</td></tr>';
 }
 # get the rating field
 ob_start();
 $returnval .= the_ratings("div", $postid);
 $out1 = ob_get_contents();
 ob_end_clean();
 if (!strpos($out1, "onmouseout") > 0) {
     $out1 = "already rated";
 }
 echo "<tr id=\"regcont\">";
 #List identified hw components
 $comment_excerpt = "";
 $permalink = get_permalink($postid);
 $title = translate_title(get_the_title($postid));
 $s = explode("(", $title);
 $short_title = trim($s[0]);
 $title_part2 = str_replace(")", "", trim($s[1]));
 if (strlen($title_part2) > 1) {
     $title_part2 .= "<br>";
 }
 $img_attr = array('class' => "hwscan-image image55");
 $art_image = get_the_post_thumbnail($postid, array(55, 55), $img_attr);
 if ($art_image == "") {
     #print "No Image";
     $art_image = '<img width="55" height="55" src="/wp-uploads/2013/03/noimage130.jpg" class="hwscan-image wp-post-image" alt="no-image" title="no-image"/>';
 }
 $comment = $a_identified_hw->usercomment;
 $url = $a_identified_hw->url;
 $id = $a_identified_hw->id;
    function widget($args, $instance)
    {
        global $comments, $comment;
        $cache = wp_cache_get('widget_recent_comments', 'widget');
        if (!is_array($cache)) {
            $cache = array();
        }
        if (!isset($args['widget_id'])) {
            $args['widget_id'] = $this->id;
        }
        if (isset($cache[$args['widget_id']])) {
            echo $cache[$args['widget_id']];
            return;
        }
        extract($args, EXTR_SKIP);
        $output = '';
        $title = apply_filters('widget_title', empty($instance['title']) ? __('Recent Comments') : $instance['title'], $instance, $this->id_base);
        if (empty($instance['number']) || !($number = absint($instance['number']))) {
            $number = 5;
        }
        $comments = get_comments(array('number' => $number, 'status' => 'approve', 'post_status' => 'publish'));
        $output .= $before_widget;
        if ($title) {
            $output .= $before_title . '<i class="icon-comments"></i> ' . $title . $after_title;
        }
        $output .= "\n\n" . '<ul id="recentcomments1">' . "\n\n";
        if ($comments) {
            foreach ((array) $comments as $comment) {
                //$output .= "Test";
                global $region;
                $lang_url = lhg_get_lang_url_from_region($region);
                if ($lang_url != "") {
                    $lang_url = "/" . $lang_url;
                }
                $cid = $comment->comment_ID;
                //echo "CID:".$cid;
                $clang = get_comment_meta($cid, 'language', true);
                //echo "Lang: $clang"."<br>";
                $check = lhg_show_language($clang, $region);
                //echo "CHK: $check";
                //author ID
                $uid = 0;
                //reset
                $output_tmp_1 = "";
                $output_tmp_2 = "";
                $uid = get_comment($cid)->user_id;
                //echo "UID: $uid";
                //$CAID    = get_comment_author ($comment->comment_ID);
                //echo "CID: $CAID";
                $avatar = get_avatar($comment, 24);
                preg_match('#src=["|\'](.+)["|\']#Uuis', $avatar, $avatarurla);
                //echo "URL: $avatarurl[1]";
                $avatarurl = $avatarurla[1];
                if ($lang_url == "/de") {
                    $lang_url = "";
                }
                $user_link = '<a href="' . $lang_url . '/hardware-profile/user' . $uid . '">';
                $user_link_end = '</a>';
                if ($uid != 0) {
                    $output_tmp_1 = $user_link;
                }
                if ($uid != 0) {
                    $output_tmp_2 = $user_link_end;
                }
                $output_tmp = '
        <li class="recentcomments">
          <div class="widgetimg_all">
            <div class="widgetimg_avatar">';
                $output_tmp .= $output_tmp_1 . '
              <img src="' . $avatarurl . '" height="24" width="24" alt="Avatar" />' . $output_tmp_2;
                $output_tmp .= '
             </div>


            <div class="widgetimg_text">
              ' . sprintf(_x('%1$s on %2$s', 'widgets'), $output_tmp_1 . str_replace("admin", "LHG Team", get_comment_author()) . $output_tmp_2, '<a href="' . esc_url(get_comment_link($comment->comment_ID)) . '">' . translate_title(get_the_title($comment->comment_post_ID)) . '</a> ' . get_comment_date("", $coment->comment_ID) . " ") . '
            </div>
          </div>
        </li>
        ';
                if ($comment_found < 5) {
                    if ($check != 0) {
                        //echo "A";
                        $output_lang .= $output_tmp;
                        $comment_found++;
                    } else {
                        //echo "B";
                        if ($comment_default_found < 5) {
                            $output_default .= $output_tmp;
                        }
                        $comment_default_found++;
                    }
                }
            }
            if ($output_lang == "") {
                $output .= $output_default;
            }
            if ($output_lang != "") {
                $output .= $output_lang;
            }
        }
        $output .= '</ul>';
        $output .= $after_widget;
        echo $output;
        $cache[$args['widget_id']] = $output;
        wp_cache_set('widget_recent_comments', $cache, 'widget');
    }
function lhg_check_transverse_postid($postid)
{
    //ToDo: remove comment. only disregarded due to transition phase
    #if ( !current_user_can( 'administrator' ) ) return;
    //if (is_single() ) echo "Post: continue";
    if (is_page()) {
        return;
    }
    //do not store pages in this DB
    if (is_attachment()) {
        return;
    }
    //do not stroe attachment pages in DB
    //check if postid was already added to DB, otherwise create entry
    global $lang;
    $title = translate_title(get_the_title());
    $s = explode("(", $title);
    $short_title = trim($s[0]);
    #echo "PID: $postid";
    if ($lang == "en") {
        //check if postid is in DB
        $postid_com = $postid;
        $permalink_com = get_permalink($postid_com);
        $permalink_com = str_replace("/uk/", "/", $permalink_com);
        $permalink_com = str_replace("/zh/", "/", $permalink_com);
        $permalink_com = str_replace("/nl/", "/", $permalink_com);
        $permalink_com = str_replace("/fr/", "/", $permalink_com);
        $permalink_com = str_replace("/es/", "/", $permalink_com);
        $permalink_com = str_replace("/it/", "/", $permalink_com);
        $permalink_com = str_replace("/in/", "/", $permalink_com);
        $permalink_com = str_replace("/ja/", "/", $permalink_com);
        $permalink_com = str_replace("/ca/", "/", $permalink_com);
        global $lhg_price_db;
        $sql = "SELECT postid_com FROM `lhgtransverse_posts` WHERE postid_com = " . $postid_com;
        $result = $lhg_price_db->get_var($sql);
        #echo "<br>RESULT: $result<br>";
        if ($result != "") {
            //already in DB
            #echo "found<br>";
        } elseif ($result == "0") {
            #echo "found 2<br>";
        } else {
            #echo "Update needed<br>";
            #echo "Inser pid: $postid_com";
            //write permalink to DB
            if ($short_title != "") {
                global $lhg_price_db;
                $sqlinsert = "INSERT INTO lhgtransverse_posts (product, postid_com, permalink_com) VALUES ('{$short_title}', '{$postid_com}','{$permalink_com}')";
                $resultB = $lhg_price_db->query($sqlinsert);
            }
        }
    }
    if ($lang == "de") {
        //check if postid is in DB
        $postid_de = $postid;
        $permalink_de = get_permalink($postid_de);
        global $lhg_price_db;
        $sql = "SELECT postid_de FROM `lhgtransverse_posts` WHERE postid_de = " . $postid_de;
        $result = $lhg_price_db->get_var($sql);
        #echo "<br>RESULT: $result<br>";
        if ($result != "") {
            //already in DB
            #echo "found<br>";
        } elseif ($result == "0") {
            #echo "found 2<br>";
        } else {
            #echo "Update needed<br>";
            #echo "Inser pid: $postid_com";
            //write permalink to DB
            if ($short_title != "") {
                global $lhg_price_db;
                $sqlinsert = "INSERT INTO lhgtransverse_posts (product, postid_de, permalink_de) VALUES ('{$short_title}', '{$postid_de}','{$permalink_de}')";
                $resultB = $lhg_price_db->query($sqlinsert);
            }
        }
    }
}
function awsImageGrabber($imgurl, $class = "")
{
    #takes too long. Should be prevented
    return;
    global $asin;
    $base_url0 = '<' . 'img itemprop="photo" alt="' . translate_title(get_the_title($post->ID)) . '" title="' . translate_title(get_the_title($post->ID)) . '" src="';
    $base_url = $imgurl;
    $base_url1 = '"';
    $base_url1 = $base_url1 . ' class="amazon-image ' . $class . '"';
    $base_url1 = $base_url1 . ' />';
    if ($base_url != '') {
        return $base_url0 . $base_url . $base_url1;
    } else {
        //$base_url = WP_PLUGIN_URL .'/amazon-product-in-a-post-plugin/images/noimage.jpg';
        //$post_thumbnail_id = get_post_thumbnail_id( $post->ID );
        //$base_url = wp_get_attachment_image_src( $post_thumbnail_id, $poststhname );
        $base_url = wp_get_attachment_url(get_post_thumbnail_id($post->ID));
        //echo "URL=".$base_url;
        //$base_url = WP_PLUGIN_URL .'/amazon-product-in-a-post-plugin/images/noimage.jpg';
        return $base_url0 . $base_url . $base_url1;
    }
}
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 lhg_show_supplier_square_default($postid)
{
    global $region;
    global $txt_not_avail;
    $region_tmp = $region;
    if ($region == "nl") {
        $region_tmp = "de";
    }
    $txt_button_string = $txt_not_avail . "\nAmazon." . $region_tmp;
    $img = "/wp-uploads/2012/10/Amazon_Logo1.png";
    $meta = "url-amazon." . $region;
    $url = get_post_meta($postid, $meta, true);
    //amaz_url($post->ID);
    // see if we have "Check Amazon for pricing"
    $meta = "price-amazon." . $region;
    $aprice = get_post_meta($postid, $meta, true);
    $title = translate_title(get_the_title());
    $s = explode("(", $title);
    $short_title = trim($s[0]);
    #if ($postid == 40247 ) print "DEBUG";
    #echo "AP: $aprice";
    if ($aprice != "Check Amazon For Pricing" and $region != "nl") {
        //URL still undefined?
        if ($url == "") {
            $aid = get_id();
            $url = 'http://www.amazon.' . $region_tmp . '/?_encoding=UTF8&camp=15121&creative=390961&linkCode=ur2&tag=' . $aid;
        }
        #print_r($url);
        /*
        //not available - reduce number of outgoing links
        
                echo "\n".'<div class="rating" style="border: 0px solid #222; width: 70%; text-align: center; margin: 0 auto;">';
        
                echo "\n".'<div class="amazonbutton">
                 	      <a href="'.$url.'" rel="nofollow"><img src="'.$img.'" border="0" width="125" height="125" alt="'.$short_title.'
        '.$txt_button_string.'" title="'.$short_title.'
        '.$txt_button_string.'" /></a>
                           </div>';
                echo $txt_not_avail."<br />";
                echo '<a href="'.$url.'" rel="nofollow">Amazon.'.$region_tmp.'</a>';
        
                echo "\n"."</div>";
        */
        global $no_supplier_square;
        $no_supplier_square = 1;
        #echo $txt_not_avail.' &gt; <a href="'.$aurl.'" rel="nofollow"></a>';
        //$shopids = lhg_return_shop_ids($region);
        //which shop has this product?
        //$products = lhg_get_sorted_products($shopids,$postid);
        //return first one = cheapest
        //echo "Show default";
    } elseif ($region == "nl") {
        //do not show anything, if nothing found
    } else {
        echo "\n" . '<div class="rating" style="border: 0px solid #222; width: 70%; text-align: center; margin: 0 auto;">';
        echo "\n" . '<div class="amazonbutton">
         	      <a href="' . $url . '" rel="nofollow"><img src="' . $img . '" border="0" width="125" height="125" alt="Available at Amazon.com: ' . $short_title . '" title="Available at Amazon.com: ' . $short_title . '" /></a>
                   </div>';
        echo "Check Amazon for pricing<br />";
        echo '<a href="' . $url . '" rel="nofollow">Amazon.' . $region . '</a>';
        echo "\n" . "</div>";
        #echo $txt_not_avail.' &gt; <a href="'.$aurl.'" rel="nofollow"></a>';
        //$shopids = lhg_return_shop_ids($region);
        //which shop has this product?
        //$products = lhg_get_sorted_products($shopids,$postid);
    }
}
 /**
  * Builds popular posts list
  * Since 1.4.0
  */
 function get_popular_posts($instance, $return = false)
 {
     // update instance's settings
     /*echo "<pre>"; print_r($instance); echo "</pre>";*/
     $instance = $this->array_merge_recursive_distinct($this->defaults, $instance);
     /*echo "<pre>"; print_r($instance); echo "</pre>";*/
     global $wpdb;
     $table = $wpdb->prefix . "popularpostsdata";
     $fields = "";
     $from = "";
     $where = "";
     $post_types = "";
     $pids = "";
     $cats = "";
     $authors = "";
     $content = "";
     // post filters
     // * post types - based on code seen at https://github.com/williamsba/WordPress-Popular-Posts-with-Custom-Post-Type-Support
     $types = explode(",", $instance['post_type']);
     $i = 0;
     $len = count($types);
     $sql_post_types = "";
     $join_cats = true;
     if ($len > 1) {
         // we are getting posts from more that one ctp
         foreach ($types as $post_type) {
             $sql_post_types .= "'" . $post_type . "'";
             if ($i != $len - 1) {
                 $sql_post_types .= ",";
             }
             $i++;
         }
         $post_types = " p.post_type IN({$sql_post_types}) ";
     } else {
         if ($len == 1) {
             // post from one ctp only
             $post_types = " p.post_type = '" . $instance['post_type'] . "' ";
             // if we're getting just pages, why join the categories table?
             if (strtolower($instance['post_type']) == 'page') {
                 $join_cats = false;
             }
         }
     }
     // * posts exclusion
     if (!empty($instance['pid'])) {
         $ath = explode(",", $instance['pid']);
         $len = count($ath);
         if ($len > 1) {
             // we are excluding more than one post
             $pids = " AND p.ID NOT IN(" . $instance['pid'] . ") ";
         } else {
             if ($len == 1) {
                 // exclude one post only
                 $pids = " AND p.ID <> '" . $instance['pid'] . "' ";
             }
         }
     }
     // * categories
     if (!empty($instance['cat']) && $join_cats) {
         $cat_ids = explode(",", $instance['cat']);
         $in = array();
         $out = array();
         $not_in = "";
         usort($cat_ids, array(&$this, 'sorter'));
         for ($i = 0; $i < count($cat_ids); $i++) {
             if ($cat_ids[$i] >= 0) {
                 $in[] = $cat_ids[$i];
             }
             if ($cat_ids[$i] < 0) {
                 $out[] = $cat_ids[$i];
             }
         }
         $in_cats = implode(",", $in);
         $out_cats = implode(",", $out);
         $out_cats = preg_replace('|[^0-9,]|', '', $out_cats);
         if ($in_cats != "" && $out_cats == "") {
             // get posts from from given cats only
             $cats = " AND p.ID IN (\r\n\t\t\t\t\t\tSELECT object_id\r\n\t\t\t\t\t\tFROM {$wpdb->term_relationships} AS r\r\n\t\t\t\t\t\t\t JOIN {$wpdb->term_taxonomy} AS x ON x.term_taxonomy_id = r.term_taxonomy_id\r\n\t\t\t\t\t\t\t JOIN {$wpdb->terms} AS t ON t.term_id = x.term_id\r\n\t\t\t\t\t\tWHERE x.taxonomy = 'category' AND t.term_id IN({$in_cats})\r\n\t\t\t\t\t\t) ";
         } else {
             if ($in_cats == "" && $out_cats != "") {
                 // exclude posts from given cats only
                 $cats = " AND p.ID NOT IN (\r\n\t\t\t\t\t\tSELECT object_id\r\n\t\t\t\t\t\tFROM {$wpdb->term_relationships} AS r\r\n\t\t\t\t\t\t\t JOIN {$wpdb->term_taxonomy} AS x ON x.term_taxonomy_id = r.term_taxonomy_id\r\n\t\t\t\t\t\t\t JOIN {$wpdb->terms} AS t ON t.term_id = x.term_id\r\n\t\t\t\t\t\tWHERE x.taxonomy = 'category' AND t.term_id IN({$out_cats})\r\n\t\t\t\t\t\t) ";
             } else {
                 // mixed, and possibly a heavy load on the DB
                 $cats = " AND p.ID IN (\r\n\t\t\t\t\t\tSELECT object_id\r\n\t\t\t\t\t\tFROM {$wpdb->term_relationships} AS r\r\n\t\t\t\t\t\t\t JOIN {$wpdb->term_taxonomy} AS x ON x.term_taxonomy_id = r.term_taxonomy_id\r\n\t\t\t\t\t\t\t JOIN {$wpdb->terms} AS t ON t.term_id = x.term_id\r\n\t\t\t\t\t\tWHERE x.taxonomy = 'category' AND t.term_id IN({$in_cats})\r\n\t\t\t\t\t\t) AND p.ID NOT IN (\r\n\t\t\t\t\t\tSELECT object_id\r\n\t\t\t\t\t\tFROM {$wpdb->term_relationships} AS r\r\n\t\t\t\t\t\t\t JOIN {$wpdb->term_taxonomy} AS x ON x.term_taxonomy_id = r.term_taxonomy_id\r\n\t\t\t\t\t\t\t JOIN {$wpdb->terms} AS t ON t.term_id = x.term_id\r\n\t\t\t\t\t\tWHERE x.taxonomy = 'category' AND t.term_id IN({$out_cats})\r\n\t\t\t\t\t\t) ";
             }
         }
     }
     // * authors
     if (!empty($instance['author'])) {
         $ath = explode(",", $instance['author']);
         $len = count($ath);
         if ($len > 1) {
             // we are getting posts from more that one author
             $authors = " AND p.post_author IN(" . $instance['author'] . ") ";
         } else {
             if ($len == 1) {
                 // post from one author only
                 $authors = " AND p.post_author = '" . $instance['author'] . "' ";
             }
         }
     }
     $fields = "p.ID AS 'id', p.post_title AS 'title', p.post_date AS 'date', p.post_author AS 'uid' ";
     if ($instance['range'] == "all") {
         // ALL TIME
         $fields .= ", p.comment_count AS 'comment_count' ";
         if ($instance['order_by'] == "comments") {
             // ordered by comments
             if ($instance['stats_tag']['views']) {
                 // get views, too
                 $fields .= ", IFNULL(v.pageviews, 0) AS 'pageviews' ";
                 $from = " {$wpdb->posts} p LEFT JOIN {$table} v ON p.ID = v.postid WHERE {$post_types} {$pids} {$authors} {$cats} AND p.comment_count > 0 AND p.post_password = '' AND p.post_status = 'publish' ORDER BY p.comment_count DESC LIMIT {$instance['limit']} ";
             } else {
                 // get data from wp_posts only
                 $from = " {$wpdb->posts} p WHERE {$post_types} {$pids} {$authors} {$cats} AND p.comment_count > 0 AND p.post_password = '' AND p.post_status = 'publish' ORDER BY p.comment_count DESC LIMIT {$instance['limit']} ";
             }
         } else {
             // ordered by views / avg
             if ($instance['order_by'] == "views") {
                 $fields .= ", v.pageviews AS 'pageviews' ";
                 $from = " {$table} v LEFT JOIN {$wpdb->posts} p ON v.postid = p.ID WHERE {$post_types} {$pids} {$authors} {$cats} AND p.post_password = '' AND p.post_status = 'publish' ORDER BY pageviews DESC LIMIT {$instance['limit']} ";
             } else {
                 if ($instance['order_by'] == "avg") {
                     $fields .= ", ( v.pageviews/(IF ( DATEDIFF('{$this->now()}', MIN(v.day)) > 0, DATEDIFF('{$this->now()}', MIN(v.day)), 1) ) ) AS 'avg_views' ";
                     $from = " {$table} v LEFT JOIN {$wpdb->posts} p ON v.postid = p.ID WHERE {$post_types} {$pids} {$authors} {$cats} AND p.post_password = '' AND p.post_status = 'publish' GROUP BY p.ID ORDER BY avg_views DESC LIMIT {$instance['limit']} ";
                 }
             }
         }
     } else {
         // CUSTOM RANGE
         $interval = "";
         switch ($instance['range']) {
             case "yesterday":
                 $interval = "1 DAY";
                 break;
             case "daily":
                 $interval = "1 DAY";
                 break;
             case "weekly":
                 $interval = "1 WEEK";
                 break;
             case "monthly":
                 $interval = "1 MONTH";
                 break;
             default:
                 $interval = "1 DAY";
                 break;
         }
         if ($instance['order_by'] == "comments") {
             // ordered by comments
             $fields .= ", c.comment_count AS 'comment_count' ";
             $from = " (SELECT comment_post_ID AS 'id', COUNT(comment_post_ID) AS 'comment_count', MAX(comment_date) AS comment_date FROM {$wpdb->comments} WHERE comment_date > DATE_SUB('{$this->now()}', INTERVAL {$interval}) AND comment_approved = 1 GROUP BY id ORDER BY comment_count DESC, comment_date DESC) c LEFT JOIN {$wpdb->posts} p ON p.ID = c.id ";
             if ($instance['stats_tag']['views']) {
                 // get views, too
                 $fields .= ", IFNULL(v.pageviews, 0) AS 'pageviews' ";
                 $from .= " LEFT JOIN (SELECT id, SUM(pageviews) AS pageviews, MAX(day) AS day FROM {$table}cache WHERE day > DATE_SUB('{$this->now()}', INTERVAL {$interval}) GROUP BY id ORDER BY pageviews DESC, day DESC) v ON p.ID = v.id ";
             }
             $from .= " WHERE {$post_types} {$pids} {$authors} {$cats} AND p.post_password = '' AND p.post_status = 'publish' LIMIT {$instance['limit']} ";
         } else {
             // ordered by views / avg
             if ($instance['order_by'] == "views") {
                 $fields .= ", v.pageviews AS 'pageviews' ";
                 $from = " (SELECT id, SUM(pageviews) AS pageviews, MAX(day) AS day FROM {$table}cache WHERE day > DATE_SUB('{$this->now()}', INTERVAL {$interval}) GROUP BY id ORDER BY pageviews DESC, day DESC) v LEFT JOIN {$wpdb->posts} p ON v.id = p.ID ";
             } else {
                 if ($instance['order_by'] == "avg") {
                     $fields .= ", ( v.pageviews/(IF ( DATEDIFF('{$this->now()}', DATE_SUB('{$this->now()}', INTERVAL {$interval})) > 0, DATEDIFF('{$this->now()}', DATE_SUB('{$this->now()}', INTERVAL {$interval})), 1) ) ) AS 'avg_views' ";
                     $from = " (SELECT id, SUM(pageviews) AS pageviews, MAX(day) AS day FROM {$table}cache WHERE day > DATE_SUB('{$this->now()}', INTERVAL {$interval}) GROUP BY id ORDER BY pageviews DESC, day DESC) v LEFT JOIN {$wpdb->posts} p ON v.id = p.ID ";
                 }
             }
             if ($instance['stats_tag']['comment_count']) {
                 // get comments, too
                 $fields .= ", IFNULL(c.comment_count, 0) AS 'comment_count' ";
                 $from .= " LEFT JOIN (SELECT comment_post_ID AS 'id', COUNT(comment_post_ID) AS 'comment_count', MAX(comment_date) AS comment_date FROM {$wpdb->comments} WHERE comment_date > DATE_SUB('{$this->now()}', INTERVAL {$interval}) AND comment_approved = 1 GROUP BY id ORDER BY comment_count DESC, comment_date DESC) c ON p.ID = c.id ";
             }
             $from .= " WHERE {$post_types} {$pids} {$authors} {$cats} AND p.post_password = '' AND p.post_status = 'publish' ";
             if ($instance['order_by'] == "avg") {
                 $from .= " GROUP BY v.id ORDER BY avg_views DESC ";
             }
             $from .= " LIMIT {$instance['limit']} ";
         }
     }
     $query = "SELECT {$fields} FROM {$from}";
     //echo $query;
     $mostpopular = $wpdb->get_results($query);
     /*echo "<pre>"; print_r($mostpopular); echo "</pre>";*/
     // posts array
     $posts_data = array();
     if (!is_array($mostpopular) || empty($mostpopular)) {
         // no posts to show
         $content .= "<p>" . __('Sorry. No data so far.', 'wordpress-popular-posts') . "</p>" . "\n";
     } else {
         // list posts
         // HTML wrapper
         if ($instance['markup']['custom_html']) {
             $content .= htmlspecialchars_decode($instance['markup']['wpp-start'], ENT_QUOTES) . "\n";
         } else {
             $content .= "<ul class=\"wpp-list\">" . "\n";
         }
         foreach ($mostpopular as $p) {
             $stats = "";
             $thumb = "";
             $title = "";
             $title_sub = "";
             $permalink = get_permalink($p->id);
             $author = $instance['stats_tag']['author'] ? get_the_author_meta('display_name', $p->uid) : "";
             $date = date_i18n($instance['stats_tag']['date']['format'], strtotime($p->date));
             $pageviews = $instance['order_by'] == "views" || $instance['order_by'] == "avg" || $instance['stats_tag']['views'] ? $instance['order_by'] == "views" || $instance['order_by'] == "comments" ? $p->pageviews : $p->avg_views : 0;
             $comments = $instance['order_by'] == "comments" || $instance['stats_tag']['comment_count'] ? $p->comment_count : 0;
             $post_cat = "";
             $excerpt = "";
             $rating = "";
             $data = array();
             // TITLE
             $title = $this->qTrans ? qtrans_useCurrentLanguageIfNotFoundUseDefaultLanguage($p->title) : $p->title;
             $title = strip_tags($title);
             $title_sub = strip_tags($title);
             // truncate title
             if ($instance['shorten_title']['active']) {
                 if (isset($instance['shorten_title']['words']) && $instance['shorten_title']['words']) {
                     // by words
                     $words = explode(" ", $title, $instance['shorten_title']['length'] + 1);
                     if (count($words) > $instance['shorten_title']['length']) {
                         array_pop($words);
                         $title_sub = implode(" ", $words) . "...";
                     }
                 } else {
                     // by characters
                     if (strlen($title) > $instance['shorten_title']['length']) {
                         $title_sub = mb_substr($title, 0, $instance['shorten_title']['length'], $this->charset) . "...";
                     }
                 }
             }
             $title = htmlspecialchars($title, ENT_QUOTES, $this->charset);
             $title_sub = htmlspecialchars($title_sub, ENT_QUOTES, $this->charset);
             $title = apply_filters('the_title', $title, $p->id);
             $title_sub = apply_filters('the_title', $title_sub, $p->id);
             // EXCERPT
             if ($instance['post-excerpt']['active']) {
                 $excerpt = trim($this->get_summary($p->id, $instance));
                 if (!empty($excerpt)) {
                     if (!$instance['markup']['custom_html']) {
                         $excerpt = ": <span class=\"wpp-excerpt\">" . $excerpt . "</span>";
                     }
                 }
             }
             // STATS
             // comments
             if ($instance['stats_tag']['comment_count']) {
                 $comments_text = sprintf(_n('1 new comment', '%s new comments', $comments, 'wordpress-popular-posts'), number_format_i18n($comments));
                 $stats .= "<span class=\"wpp-comments\">" . $comments_text . "</span>";
             } else {
             }
             // views
             if ($instance['stats_tag']['views']) {
                 if ($instance['order_by'] == 'avg') {
                     $views_text = sprintf(_n('1 view per day', '%s views per day', intval($pageviews), 'wordpress-popular-posts'), number_format_i18n($pageviews, 2));
                 } else {
                     $views_text = sprintf(_n('1 view', '%s views', intval($pageviews), 'wordpress-popular-posts'), number_format_i18n($pageviews));
                 }
                 $stats .= $stats == "" ? "<span class=\"wpp-views\">" . $views_text . "</span>" : " | <span class=\"wpp-views\">" . $views_text . "</span>";
             }
             //author
             if ($instance['stats_tag']['author']) {
                 $display_name = "<a href=\"" . get_author_posts_url($p->uid) . "\">{$author}</a>";
                 $stats .= $stats == "" ? "<span class=\"wpp-author\">" . __('by', 'wordpress-popular-posts') . " {$display_name}</span>" : " | <span class=\"wpp-author\">" . __('by', 'wordpress-popular-posts') . " {$display_name}</span>";
             }
             // date
             if ($instance['stats_tag']['date']['active']) {
                 $stats .= $stats == "" ? "<span class=\"wpp-date\">" . __('posted on', 'wordpress-popular-posts') . " {$date}</span>" : " | <span class=\"wpp-date\">" . __('posted on', 'wordpress-popular-posts') . " {$date}</span>";
             }
             // category
             if ($instance['stats_tag']['category']) {
                 $post_cat = get_the_category($p->id);
                 $post_cat = isset($post_cat[0]) ? '<a href="' . get_category_link($post_cat[0]->term_id) . '">' . $post_cat[0]->cat_name . '</a>' : '';
                 if ($post_cat != '') {
                     $stats .= $stats == "" ? "<span class=\"wpp-category\">" . __('under', 'wordpress-popular-posts') . " {$post_cat}</span>" : " | <span class=\"wpp-category\">" . __('under', 'wordpress-popular-posts') . " {$post_cat}</span>";
                 }
             }
             // RATING
             if ($instance['rating'] && $this->postRating && function_exists('the_ratings')) {
                 $rating = '<span class="wpp-rating">' . the_ratings('span', $p->id, false) . '</span>';
             }
             // POST THUMBNAIL
             //if ($instance['thumbnail']['active'] && $this->thumb) {
             if (1 == 1) {
                 $tbWidth = 40;
                 //$instance['thumbnail']['width'];
                 $tbHeight = 40;
                 //$instance['thumbnail']['height'];
                 //$thumb = "<a href=\"". $permalink ."\" title=\"{$title}\" target=\"".$this->user_ops['tools']['link']['target']."\">";
                 $thumb = "";
                 /*
                 if ( $this->user_ops['tools']['thumbnail']['source'] == "custom_field" ) { // get image from custom field
                 
                 							$path = get_post_meta($p->id, $this->user_ops['tools']['thumbnail']['field'], true);
                 
                 							if ( $path != "" ) {
                 								
                 								if ( $this->user_ops['tools']['thumbnail']['resize'] ) {
                 									
                 									$thumb .= $this->get_img( $p->id, array($tbWidth, $tbHeight), $this->user_ops['tools']['thumbnail']['source'] );
                 																		
                 								} else {
                 									$thumb .= "<img src=\"{$path}\" width=\"{$tbWidth}\" height=\"{$tbHeight}\" alt=\"{$title}\" border=\"0\" class=\"wpp-thumbnail wpp_cf\" />";
                 								}
                 								
                 							} else {
                 								$thumb .= "<img src=\"". $this->default_thumbnail ."\" alt=\"{$title}\" border=\"0\" width=\"{$tbWidth}\" height=\"{$tbHeight}\" class=\"wpp-thumbnail wpp_cf_def\" />";
                 							}
                 
                 						} else { // get image from post / Featured Image
                 							$thumb .= $this->get_img( $p->id, array($tbWidth, $tbHeight), $this->user_ops['tools']['thumbnail']['source'] );
                 						}
                 */
                 $thumb .= get_the_post_thumbnail($p->id, array(40, 40), array('class' => 'wp-cpl-sc-thumb', 'alt' => translate_title(get_the_title($p->id)), 'title' => translate_title(get_the_title($p->id))));
                 //$thumb .= "</a>";
             }
             $data = array('id' => $p->id, 'title' => '<a href="' . $permalink . '" title="' . $title . '">' . $title_sub . '</a>', 'summary' => $excerpt, 'stats' => $stats, 'img' => $thumb, 'url' => $permalink, 'text_title' => $title, 'category' => $post_cat, 'author' => "<a href=\"" . get_author_posts_url($p->uid) . "\">{$author}</a>", 'views' => $pageviews, 'comments' => $comments);
             $posts_data[] = (object) $data;
             // PUTTING IT ALL TOGETHER
             if ($instance['markup']['custom_html']) {
                 // build custom layout
                 $content .= htmlspecialchars_decode($this->format_content($instance['markup']['post-html'], $data, $instance['rating']), ENT_QUOTES) . "\n";
             } else {
                 // build regular layout
                 $content .= "<li><a href=\"" . $permalink . "\" title=\"{$title}\">" . '<div class="popular-post">' . "\n                                                {$thumb}<span class=\"post-stats\">{$stats}</span><br><b>{$title_sub}</b>{$excerpt}</div></a>\n                                                </li>" . "\n";
                 /* $content .= "<li><a href=\"". $permalink ."\" title=\"{$title}\">".'<div class="popular-post">'."
                    {$thumb}<a href=\"{$permalink}\" title=\"{$title}\" class=\"wpp-post-title\" target=\"".$this->user_ops['tools']['link']['target']."\">{$title_sub}</a> {$excerpt}<span class=\"post-stats\">{$stats}</span>{$rating}</div></a></li>" . "\n";
                    */
             }
         }
         // END HTML wrapper
         if ($instance['markup']['custom_html']) {
             $content .= htmlspecialchars_decode($instance['markup']['wpp-end'], ENT_QUOTES) . "\n";
         } else {
             $content .= "\n" . "</ul>" . "\n";
         }
     }
     //return $content;
     return apply_filters('wpp_html', $content2 . $content, $posts_data);
     die;
 }
function lhg_hplip_shortcode($attr)
{
    global $lang;
    global $region;
    # Printer name = $printer_name
    $title = translate_title(get_the_title());
    $s = explode("(", $title);
    $printer_name = trim($s[0]);
    # Printer type
    $printer_type = "";
    $printer_type_de = " ";
    if (strpos($title, "aser") > 0) {
        $printer_type = "laser";
    }
    if (strpos($title, "nkjet") > 0) {
        $printer_type = "inkjet";
    }
    if (strpos($title, "inten") > 0) {
        $printer_type_de = "Tintenstrahl-";
    }
    if (strpos($title, "encre") > 0) {
        $printer_type_fr = "imprimante &agrave; jet d'encre";
    }
    if (strpos($title, "Tinta") > 0) {
        $printer_type_es = "impresora de inyección de tinta";
    }
    if (strpos($title, "tampante") > 0) {
        $printer_type_it = "inkjet stampante";
    }
    # With scanner?
    $scanner_available = 0;
    if (strpos($title, "canner") > 0) {
        $scanner_available = 1;
    }
    if (strpos($title, "canneur") > 0) {
        $scanner_available = 1;
    }
    if (strpos($title, "Esc") > 0) {
        $scanner_available = 1;
    }
    #print "T: $title<br> - SA: $scanner_available <br>";
    $output = 'The ' . $printer_name . ' is an ';
    $output_de = 'Der ' . $printer_name . ' ist ein ';
    $output_fr = 'La ' . $printer_name . ' est une ';
    $output_es = 'El ' . $printer_name . ' es ';
    $output_it = 'La ' . $printer_name . ' è ';
    if ($scanner_available == 0) {
        $output .= $printer_type . ' printer.';
    }
    if ($scanner_available == 0) {
        $output_de .= $printer_type_de . 'Drucker.';
    }
    if ($scanner_available == 0) {
        $output_fr .= $printer_type_fr;
    }
    if ($scanner_available == 0) {
        $output_es .= "una " . $printer_type_fr;
    }
    if ($scanner_available == 0) {
        $output_it .= "una " . $printer_type_it;
    }
    if ($scanner_available > 0) {
        $output .= 'all-in-one device with ' . $printer_type . ' printer and scanner. ';
    }
    if ($scanner_available > 0) {
        $output_de .= 'Multifunktionsdruckert mit ' . $printer_type . 'Drucker und Scanner. ';
    }
    if ($scanner_available > 0) {
        $output_fr .= 'tout-en-un ' . $printer_type_fr . ' avec une scanner. ';
    }
    if ($scanner_available > 0) {
        $output_es .= 'un dispositivo todo-en-uno con la ' . $printer_type_es . '. ';
    }
    if ($scanner_available > 0) {
        $output_it .= 'una multifunction ' . $printer_type_es . '. ';
    }
    if (isset($attr['usb'])) {
        $output .= 'The device is connected via USB and has the USB ID
<pre class="brush: plain; title: lsusb; notranslate" title="lsusb">
' . $attr['usb'] . '
</pre>
';
    }
    if (isset($attr['usb'])) {
        $output_de .= 'Das Ger�t kann per USB angeschlossen werden und besitzt die USB ID
<pre class="brush: plain; title: lsusb; notranslate" title="lsusb">
' . $attr['usb'] . '
</pre>
';
    }
    if (isset($attr['usb'])) {
        $output_fr .= 'L\'appareil est connecté via USB et possède l\'ID USB
<pre class="brush: plain; title: lsusb; notranslate" title="lsusb">
' . $attr['usb'] . '
</pre>
';
    }
    if (isset($attr['usb'])) {
        $output_es .= 'El dispositivo está conectado a través de USB y cuenta con el ID USB
<pre class="brush: plain; title: lsusb; notranslate" title="lsusb">
' . $attr['usb'] . '
</pre>
';
    }
    if (isset($attr['usb'])) {
        $output_it .= 'Il dispositivo è collegato via USB e ha la ID USB
<pre class="brush: plain; title: lsusb; notranslate" title="lsusb">
' . $attr['usb'] . '
</pre>
';
    }
    $output .= ' The ' . $printer_name . ' is fully supported under Linux thanks to the
<a href="' . $attr['url'] . '">HPLIP drivers provided by HP</a>. At least the version ' . $attr['version'] . ' of the  HPLIP
drivers is necessary in order to fully support the ' . $printer_name . '.
Under Ubuntu the needed drivers can be installed via the apt-get package manager:
<pre class="brush: plain; notranslate" >
sudo apt-get install hplip hpijs hplip-gui
</pre>
Otherwise, the drivers can be downloaded from <a href="http://hplipopensource.com/hplip-web/downloads.html">HPLIP web site</a>. The downloaded files (eventually after unpacking them) can be installed (as root):
<pre class="brush: plain; notranslate" >
sh hplip-' . $attr['version'] . '.run
</pre>
Under Ubuntu this step is not necessary (because installation is done by the package management system) and one can immediately skip to the configuration step:
<pre class="brush: plain; notranslate" >
sudo hp-setup
</pre>
';
    $output_de .= ' Der ' . $printer_name . ' wird vollst&auml;ndig unter Linux unterst&uuml;tzt dank der
<a href="' . $attr['url'] . '">HPLIP Treiber</a> welche von HP zur Verf&uuml;gung gestellt werden. Es wird mindestens die Version ' . $attr['version'] . ' des HPLIP
Treibers ben&ouml;tigt, um den ' . $printer_name . ' anzusprechen.
Unter Ubuntu kann der Treiber mittels Paket-Manager und apt-get installiert werden:
<pre class="brush: plain; notranslate" >
sudo apt-get install hplip hpijs hplip-gui
</pre>
Bei anderen Linux-Distributionen kann der Treiber auch von der <a href="http://hplipopensource.com/hplip-web/downloads.html">HPLIP Webseite</a> heruntergeladen werden. Die heruntergeladenen
Dateien k&ouml;nnen (nach dem Entpacken) als Benuter "root" installiert werden mittels:
<pre class="brush: plain; notranslate" >
sh hplip-' . $attr['version'] . '.run
</pre>
Die Konfiguration des Treibers erfolgt mittels des Programms hp-setup:
<pre class="brush: plain; notranslate" >
sudo hp-setup
</pre>
';
    $output_fr .= 'La ' . $printer_name . ' est entièrement pris en charge sous Linux grâce aux pilotes
<a href="' . $attr['url'] . '">pilotes HPLIP</a> fournies par HP. Au moins la version ' . $attr['version'] . ' des pilotes hplip
est nécessaire afin de soutenir pleinement la ' . $printer_name . '.
Sous Ubuntu les pilotes nécessaires peuvent être installés via apt-get gestionnaire de paquets:
<pre class="brush: plain; notranslate" >
sudo apt-get install hplip hpijs hplip-gui
</pre>
Sinon, les pilotes peuvent être téléchargés à partir
<a href="http://hplipopensource.com/hplip-web/downloads.html">HPLIP site web</a>. Les fichiers
téléchargés (éventuellement après déballage) peuvent être installés (en tant que root):
<pre class="brush: plain; notranslate" >
sh hplip-' . $attr['version'] . '.run
</pre>
Sous Ubuntu cette étape est pas nécessaire (car l\'installation se fait par le système de gestion des paquets) et on peut immédiatement
passer à l\'étape de configuration:
<pre class="brush: plain; notranslate" >
sudo hp-setup
</pre>
';
    $output_es .= 'La ' . $printer_name . ' es totalmente compatible con Linux gracias a los
<a href="' . $attr['url'] . '">controladores HPLIP</a> proporcionadas por HP.
Por lo menos la versión ' . $attr['version'] . '
de los conductores HPLIP es necesario con el fin de apoyar plenamente la ' . $printer_name . '.
Bajo Ubuntu los controladores necesarios se pueden instalar a través de apt-get gestor de paquetes:
<pre class="brush: plain; notranslate" >
sudo apt-get install hplip hpijs hplip-gui
</pre>
De lo contrario, los controladores se pueden descargar desde el
<a href="http://hplipopensource.com/hplip-web/downloads.html">sitio web HPLIP</a>. Los archivos descargados (finalmente
después de desempaquetar ellos) se pueden instalar (como root):
<pre class="brush: plain; notranslate" >
sh hplip-' . $attr['version'] . '.run
</pre>
Bajo Ubuntu este paso no es necesario (ya que la instalación se realiza por el sistema de gestión de paquetes) y
uno puede saltar inmediatamente al paso de configuración:
<pre class="brush: plain; notranslate" >
sudo hp-setup
</pre>
';
    $output_it .= 'La ' . $printer_name . ' è pienamente supportato in Linux grazie ai
<a href="' . $attr['url'] . '">driver HPLIP</a> forniti da HP.
Almeno la versione ' . $attr['version'] . ' dei driver HPLIP è necessaria al fine di sostenere pienamente la
 ' . $printer_name . '.
Sotto Ubuntu i driver necessari possono essere installati tramite apt-get gestore di pacchetti:
<pre class="brush: plain; notranslate" >
sudo apt-get install hplip hpijs hplip-gui
</pre>
In caso contrario, i driver possono essere scaricati dal 
<a href="http://hplipopensource.com/hplip-web/downloads.html">sito web HPLIP</a>. I file scaricati
(eventualmente dopo estrarli) possono essere installate (come root):
<pre class="brush: plain; notranslate" >
sh hplip-' . $attr['version'] . '.run
</pre>
Sotto Ubuntu questo passaggio non è necessario (perché l\'installazione viene eseguita dal sistema
di gestione dei pacchetti) e si può passare immediatamente alla fase di configurazione:
<pre class="brush: plain; notranslate" >
sudo hp-setup
</pre>
';
    if ($scanner_available > 0) {
        $output .= '
<h3>Scanner:</h3>
The scanner can be used together with <a href="http://www.xsane.org/">XSane</a>, which can
be installed under Ubuntu by:
<pre class="brush: plain; notranslate" >
sudo apt-get install xsane
</pre>

If the scanner is found, one can also scan with the console program
<pre class="brush: plain; notranslate" >
hp-scan
</pre>' . '
After placing a sheet of paper on the scan unit and presses the scan button on the printer, a file “hpscan001.png” is created in the home directory.
';
    }
    if ($scanner_available > 0) {
        $output_de .= '
<h3>Scanner:</h3>
Der Scanner kann unter Linux z.B. mittels des Programms <a href="http://www.xsane.org/">XSane</a> angesprochen werden, welches unter Ubuntu installiert wird mittels
<pre class="brush: plain; notranslate" >
sudo apt-get install xsane
</pre>

Au&szlig;erdem ist es m&ouml;glich, unter der Konsole einen Scan auszuf&uuml;hren mittels des Programms
<pre class="brush: plain; notranslate" >
hp-scan
</pre>' . '
Nachdem das zu scannende Papier auf der Scanner-Einheit plaziert wurde und der "Scan"-Knopf am Drucker gedr&uuml;ckt wurde, wird die "hpscan001.png"
im Home-Verzeichnis erstellt.
';
    }
    if ($scanner_available > 0) {
        $output_fr .= '
<h3>Scanner:</h3>
Le scanner peut être utilisé conjointement ave <a href="http://www.xsane.org/">XSane</a> ce qui peut
être installé sous Ubuntu par:
<pre class="brush: plain; notranslate" >
sudo apt-get install xsane
</pre>

Si le scanner se trouve, on peut également numériser avec le programme de la console
<pre class="brush: plain; notranslate" >
hp-scan
</pre>' . '

Après avoir placé une feuille de papier sur l\'unité de balayage et appuie sur le bouton de numérisation sur l\'imprimante, un fichier "hpscan001.png"
est créé dans le répertoire de la maison.
';
    }
    if ($scanner_available > 0) {
        $output_es .= '
<h3> Escáner: </h3>
El escáner se puede utilizar junto con <a href="http://www.xsane.org/"> XSane </a>, lo que puede
se instalará bajo Ubuntu por:
<pre class="brush: plain; notranslate">
sudo apt-get install xsane
</pre>

Si se encuentra el escáner, también se puede escanear con el programa de consola
<pre class = "brush: plain; notranslate">
hp-scan
</pre> ' . '
Después de colocar una hoja de papel en la unidad de exploración y presiona el botón de escaneo de la impresora, un "hpscan001.png"
archivo se crea en el directorio principal.
';
    }
    if ($scanner_available > 0) {
        $output_it .= '
<h3> Scanner: </h3>
Lo scanner può essere utilizzato insieme a <a href="http://www.xsane.org/"> XSane </a>, che può
essere installati con Ubuntu da:
<pre class = "brush: plain; notranslate">
sudo apt-get install xsane
</pre>

Se viene trovato lo scanner, si può anche eseguire la scansione con il programma di console
<pre class = "brush: plain; notranslate">
hp-scan
</pre> ' . '
Dopo aver posizionato un foglio di carta sulla unità di scansione e preme il pulsante di scansione sulla stampante, un file "hpscan001.png" viene creata nella directory home.
';
    }
    #$output = do_shortcode($output, false);
    if ($lang == "de") {
        $output = $output_de;
    }
    if ($region == "fr") {
        $output = $output_fr;
    }
    if ($region == "es") {
        $output = $output_es;
    }
    if ($region == "it") {
        $output = $output_it;
    }
    if (!isset($attr['url'])) {
        $output = '<h1>ERROR: URL missing</h1><br>' . $output;
    }
    return $output;
}
    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;
    }
function lhg_store_product_in_db()
{
    global $lhg_price_db;
    $postid = $_POST['post_ID'];
    $title = translate_title(get_the_title($postid));
    $s = explode("(", $title);
    $short_title = trim($s[0]);
    if ($short_title != "") {
        # write taglist to lhgtransverse_posts
        $sql = "UPDATE lhgtransverse_posts SET `product` = \"%s\" WHERE postid_com = %s";
        $safe_sql = $lhg_price_db->prepare($sql, $short_title, $postid);
        $result = $lhg_price_db->query($safe_sql);
    }
}