function lhg_db_get_cheapest_price_by_region($postid, $search_region) { global $region; #echo "RG: $region"; #print "PID: $postid<br>"; if ($search_region == "de" && $region != "de") { $postid = lhg_get_postid_de_from_com($postid); } if ($search_region != "de" && $region == "de") { $postid = lhg_get_postid_com_from_de($postid); } #print "PID2: $postid<br>"; $shopids = lhg_return_shop_ids($search_region); #print "SIDS<br>"; #var_dump($shopids); //which shop has this product? $products = lhg_get_sorted_products($shopids, $postid, $search_region); $price = $products[0]["price"] + $products[0]["shipping"]; //return first one = cheapest return $price; }
function lhg_article_scans_overview() { global $lang; global $lhg_price_db; global $txt_scan_distribution; global $txt_scan_kernel; global $txt_scan_scandate; global $txt_scan_result; global $txt_scan_results; global $txt_scan_title; global $txt_scan_text; global $txt_Rating; $pid = get_the_ID(); if ($lang == "de") { $pid = lhg_get_postid_com_from_de($pid); } $sql = "SELECT sid FROM `lhghwscans` WHERE postid = \"" . $pid . "\""; $ids = $lhg_price_db->get_results($sql); #print "ID List:"; #var_dump($ids); #print "<br>"; $findings = 0; $output_tmp = '<div class="article-scantable-outer"> <table class="article-scantable"> <tr> <td></td> <td><div class="article-scantable-header">' . $txt_scan_distribution . '</div></td> <td><div class="article-scantable-header">' . $txt_scan_kernel . '</div></td> <td><div class="article-scantable-header">' . $txt_Rating . '</div></td> <td><div class="article-scantable-header">' . $txt_scan_scandate . '</div></td> </tr> '; $idarray = array(); $counter = 0; foreach ($ids as $id) { $sid = $id->sid; #var_dump($sid); $sql = "SELECT id, distribution, kversion, pub_id, scandate FROM `lhgscansessions` WHERE sid = \"" . $sid . "\""; $result = $lhg_price_db->get_results($sql); $rating = lhg_get_rating_by_scan($sid, $pid); $ratingimage = lhg_create_rating_img($rating); #var_dump($result); #print "--<br>"; $result0 = $result[0]; #var_dump($result0); #print "-> Distr: ".$result0->distribution."<br>"; //]." - ".$results0["kversion"]." - $sid<br>"; #print "Res: -> Distr: ".$result0["distribution"]." - ".$results0["kversion"]." - $sid<br>"; #print "Res: $result -> Distr: ".$result["distribution"]." - ".$results["kversion"]." - $sid<br>"; # test if distri+kernel combination was already shown $uniquestring = $result0->distribution . "-" . $result0->kversion; $known = array_search($uniquestring, $idarray); #if ($pid == 21006) print "USTR: $uniquestring - "; #if ($pid == 21006) print "kn: ". $known ."<br>"; # ToDo: Scan overview currently only available on .com servers: $url_prefix = "./"; if ($lang == "de") { $url_prefix = ""; } #http://www.linux-hardware-guide.com"; if (!is_int($known)) { #if ($pid == 21006) print "AA<br>"; # Unique combination array_push($idarray, $uniquestring); if ($result0->distribution != "" && $result0->kversion != "" && $findings < 11) { $date = date_i18n(get_option('date_format'), $result0->scandate); $date_array[$counter] = $result0->scandate; $logo = get_distri_logo($result0->distribution); $tooltiptext = $txt_scan_distribution . ": " . preg_replace("/\r|\n/", "", $result0->distribution) . "\n" . $txt_scan_kernel . ": " . preg_replace("/\r|\n/", "", $result0->kversion); $output_tmp_array[$counter] .= '<tr> <td width="30">' . "\n <div class=\"scan-overview-distri-logo\"><img src=\"" . $logo . '" width="30" alt="' . $tooltiptext . '" title="' . $tooltiptext . '" ></div> </td><td>' . $result0->distribution . "</td>\n <td>" . $result0->kversion . "</td>\n <td>" . $ratingimage . "</td>\n <td><a href=\"" . $url_prefix . "/hardware-profile/system-" . $result0->pub_id . "\">" . $date . "</a></td>\n </tr>"; $findings++; $counter++; } } else { # had this result before. Skipping! #if ($pid == 21006) print "skipping: $uniquestring <br>"; } } if ($counter == 1) { $txt_results = "1 " . $txt_scan_result; } if ($counter > 1) { $txt_results = $counter . " " . $txt_scan_results; } $output = ""; $output .= "<h2>{$txt_scan_title} ({$txt_results}) </h2>"; $output .= $txt_scan_text; #'This hardware component was used by Linux users under the following system configurations. These results were collected by our <a href="./add-hardware">Scan Tool</a>:'; # Sort scan overview table by date if ($counter > 0) { array_multisort($date_array, SORT_DESC, $output_tmp_array); $output_tmp_string = implode(" ", $output_tmp_array); } $output_tmp .= $output_tmp_string . "</table></div>"; # we found something -> show table if ($findings > 0) { $output .= $output_tmp; } if ($findings == "" or $findings == 0) { $output = ""; } #print "FDG: $findings<br>"; return $output; }