Exemple #1
0
                <script type="text/javascript">
                /* <![CDATA[ */

                jQuery(document).ready( function($) {

		      $("#my_popup").hide();
                      $("[id^=details-hw-]").hide();

                });

                /*]]> */
                </script>

';
}
$uploader_guid = lhg_get_scan_uploader_guid($sid);
if ($show_public_profile == 1 or $uploader_guid > 0 or $editmode == 1) {
    # do not show link box in public profile
    # do not show if scan was already linked to registered user (e.g. by personified upload)
    # hide email from other uses
} else {
    print '
<br>&nbsp;<br>
<h2>Contact information</h2>
<form action="?" method="post">
       Please leave us your email address in order to contact you in case of questions regarding your hardware scan results:<br>
       <b>Email</b>: <input name="email" id="email-input" type="text" size="30" maxlength="50" value="' . $email . '">
       <input type="submit" id="email-submit" name="email-login" value="' . $buttontext . '" class="hwscan-email-button-' . $buttontext . '" />
</form>
<br>
';
function lhg_menu_hw_scans()
{
    global $lhg_price_db;
    if ($_POST != "") {
        lhg_db_update_scaninfo();
    }
    $res = lhg_db_get_scan_sids();
    print "<h1>Hardware Scans</h1>";
    print "<br>";
    #print "POST:";
    #var_dump ( $_POST );
    #var_dump( $res );
    print '<form action="admin.php?page=lhg_menu_hw_scans" method="post">';
    $user = wp_get_current_user();
    $userid = $user->ID;
    #defaults
    $show_new = true;
    $show_ongoing = true;
    $show_complete = false;
    $show_feedback = false;
    $show_new = get_user_meta($userid, 'lhg_scan_show_new', true);
    $show_ongoing = get_user_meta($userid, 'lhg_scan_show_ongoing', true);
    $show_complete = get_user_meta($userid, 'lhg_scan_show_complete', true);
    $show_feedback = get_user_meta($userid, 'lhg_scan_show_feedback', true);
    #not defined -> set defaults
    #if ($show_new      == "") {add_user_meta( $userid, 'lhg_scan_show_new',      true , true); $show_new      = true;}
    #if ($show_ongoing  == "") {add_user_meta( $userid, 'lhg_scan_show_ongoing',  true , true); $show_ongoing  = true;}
    #if ($show_complete == "") {add_user_meta( $userid, 'lhg_scan_show_complete', false, true); $show_complete = false;}
    print "Show: ";
    # $userid: $show_new - $show_ongoing - $show_complete";
    $show_new == true ? print '<input name="filter_show_new" type="checkbox" value="1" checked /> New ' : (print '<input name="filter_show_new" type="checkbox" value="1" /> New ');
    $show_ongoing == true ? print '<input name="filter_show_ongoing" type="checkbox" value="true" checked /> Ongoing ' : (print '<input name="filter_show_ongoing" type="checkbox" value="false" /> Ongoing ');
    $show_complete == true ? print '<input name="filter_show_complete" type="checkbox" value="true" checked /> Complete ' : (print '<input name="filter_show_complete" type="checkbox" value="false" /> Complete ');
    $show_feedback == true ? print '<input name="filter_show_feedback" type="checkbox" value="true" checked /> Feedback needed ' : (print '<input name="filter_show_feedback" type="checkbox" value="false" /> Feedback needed ');
    print "<table border=1><tr>";
    print "<td><b>Date</b></td><td><b>Link</b></td><td><b>Comment User</b></td> <td><b>Comment Admins</b></td> <td><b>Status</b></td> </tr>";
    foreach ($res as $resN) {
        $sid = $resN->sid;
        $status = $resN->status;
        if ($status == "" or $status == "duplicate" or $status == "new" && $show_new == true or $status == "ongoing" && $show_ongoing == true or $status == "feedback" && $show_feedback == true or $status == "complete" && $show_complete == true) {
            $pub_id = $resN->pub_id;
            if ($result->pub_id == "") {
                $pub_id = lhg_create_pub_id($sid);
            }
            $time = $resN->scandate;
            $date = gmdate("m/d/Y g:i:s A", $time);
            $acomment = $resN->admincomment;
            $ucomment = $resN->usercomment;
            #
            # check for comments on articles, i.e. cycle through all postids
            $myquery = $lhg_price_db->prepare("SELECT usercomment FROM `lhghwscans` WHERE sid = %s", $sid);
            $commentlist = $lhg_price_db->get_results($myquery);
            foreach ($commentlist as $usercomment) {
                if ($usercomment->usercomment != "") {
                    if ($ucomment == "") {
                        $ucomment .= $usercomment->usercomment;
                    } else {
                        $ucomment .= "; " . $usercomment->usercomment;
                    }
                }
            }
            $email = $resN->email;
            $ucomment_short = $ucomment;
            if (strlen($ucomment) > 50) {
                $ucomment_short = substr(sanitize_text_field($ucomment), 0, 50) . "...";
            }
            $distribution = $resN->distribution;
            $status = $resN->status;
            #$sid2 = $res[1]->sid;
            #var_dump ($sid ."--".$sid2);
            #print "SID: $sid<br>";
            #extract userdata
            $uploader_guid = lhg_get_scan_uploader_guid($sid);
            $usertxt = "";
            $duplicate_txt = "";
            if ($status == "duplicate") {
                $duplicate_txt = "dup";
            }
            if ($uploader_guid > 0) {
                $user_tmp = lhg_get_userdata_guid($uploader_guid);
                $user = $user_tmp[0];
                $user_nicename = $user->user_nicename;
                $avatar = $user->avatar;
                $wpuid_de = $user->wpuid_de;
                $wpuid_com = $user->wpuid;
                #Gravatar stored avatar image
                if (strpos($avatar, "gravatar") > 1) {
                    $start = strpos($avatar, "src='");
                    $imgurl = substr($avatar, $start + 5);
                    $tmp = explode("' class", $imgurl);
                    $imgurl = $tmp[0];
                    $usertxt = '<img src="' . $imgurl . '" width="20px" heigth="20px" title="User: '******'" alt="User: '******'">';
                } else {
                    if (strpos($avatar, "http://")) {
                        #local avatar .com
                        $start = strpos($avatar, 'src="');
                        $imgurl = substr($avatar, $start + 5);
                        $tmp = explode('" class', $imgurl);
                        $imgurl = $tmp[0];
                        $usertxt = '<img src="' . $imgurl . '" width="20px" heigth="20px" title="User: '******'" alt="User: '******'">';
                    } else {
                        #local avatar .de
                        $start = strpos($avatar, "src='");
                        $imgurl = substr($avatar, $start + 5);
                        $tmp = explode("' class", $imgurl);
                        $imgurl = $tmp[0];
                        $usertxt = '<img src="http://www.linux-hardware-guide.de' . $imgurl . '" width="20px" heigth="20px" title="User: '******'" alt="User: '******'">';
                    }
                }
            }
            $statusSelector = '
				<select name="status-' . $sid . '">';
            $statusSelector .= ($status == "new" or $status == "duplicate") ? '<option value="new" selected>New</option>' : '<option value="new">New</option>';
            $statusSelector .= $status == "ongoing" ? '<option value="ongoing" selected>Ongoing</option>' : '<option value="ongoing">Ongoing</option>';
            $statusSelector .= $status == "complete" ? '<option value="complete" selected>Complete</option>' : '<option value="complete">Complete</option>';
            $statusSelector .= $status == "feedback" ? '<option value="feedback" selected>Feedback needed</option>' : '<option value="feedback">Feedback needed</option>';
            $statusSelector .= '</select>';
            $distrilogo = get_distri_logo($distribution);
            if ($email == "") {
                $maillogo = '<span class="emailgrey" style="color: grey; font-weight: bold; font-size: 1.4em; position: relative; top: -3px;"> @</span>';
            }
            #<i class="icon-envelope icon-large2"></i>';
            if ($email != "") {
                $maillogo = '<span class="emailgreen" style="color: green; font-weight: bold; font-size: 1.4em; position: relative; top: -3px;">@</span>';
            }
            #<i class="icon-envelope icon-large2"></i>';
            $commentavail = '<span class="emailgrey" style="color: grey; font-weight: bold; font-size: 1.4em; position: relative; top: -3px;">C</span>';
            if ($ucomment != "") {
                $commentavail = '<span class="emailgreen" style="color: green; font-weight: bold; font-size: 1.4em; position: relative; top: -3px;">C</span>';
            }
            #<i class="icon-envelope icon-large2"></i>';
            $ratingavail = '<img src="/wp-content/plugins/wp-postratings/images/stars_crystal/rating_off.gif">';
            if ($rated != "") {
                $ratingavail = '<img src="/wp-content/plugins/wp-postratings/images/stars_crystal/rating_on.gif">';
            }
            print "<tr>";
            print "<td>{$date} </td>";
            print '<td><a href="/hardware-profile/editscan-' . $sid . '">' . $sid . '</a> (<a href="/hardware-profile/system-' . $pub_id . '">pub</a>)</td>';
            $tooltiptext = "Distribution: " . preg_replace("/\r|\n/", "", $resN->distribution) . "\nKernel: " . preg_replace("/\r|\n/", "", $resN->kversion);
            print '<td>
                          <img src="' . $distrilogo . '" alt="' . $tooltiptext . '" title="' . $tooltiptext . '" width=20>
                          ' . $maillogo . " " . $commentavail . " " . $ratingavail . " " . $usertxt . " " . $duplicate_txt . " " . $ucomment_short . "</td>";
            print '<td>
	        	        <input name="hwscan_acomment_' . $sid . '" type="text" size="20" value="' . $acomment . '">
	                       </td>';
            print "<td>{$statusSelector}</td>";
            print "</tr>";
        }
    }
    print "</tr></table>";
    print '<input type="submit" value="update">';
    print "</form>";
}