Esempio n. 1
0
function searchGoogle($query, $numResults)
{
    $googleResultArray = array();
    $googleAcctKey = 'hc+TUI3f03XThqcHJk4auJCOdaVHJ0FSSCAZFc8tvAc=';
    $googleRootUri = 'http://www.google.com/custom';
    $googlecounter = 0;
    //using url encode here causes weirdness
    $html = file_get_html($googleRootUri . '?start=0&num=' . $numResults . '&q=' . $query . '&client=google-csbe&cx=' . $googleAcctKey);
    foreach ($html->find('a.l') as $e) {
        ++$googlecounter;
    }
    for ($i = 0; $i < $googlecounter; $i++) {
        $googleurl = $html->find('a.l');
        $googletitle = $html->find('a.l');
        $googlesnippet = $html->find('div.std');
        $tmpStr = remove_leading($googleurl[$i]->href);
        $tmpStr = remove_trailing_backslash($tmpStr);
        $googleResultArray[$i][0] = trim($tmpStr);
        $tempStr = substr($googlesnippet[$i]->innertext, 0, strpos($googlesnippet[$i]->innertext, "<br><span class=\"a\">"));
        $googleResultArray[$i][1] = strip_tags($tempStr);
        $googleResultArray[$i][2] = $i + 1;
        $googleResultArray[$i][3] = 0.0;
        $googleResultArray[$i][4] = 0;
        $googleResultArray[$i][5] = "Google";
        $googleResultArray[$i][6] = 1;
        $googleResultArray[$i][7] = strip_tags($googletitle[$i]->innertext);
    }
    //clear dom to deal with the memory leak issue
    $html->clear();
    unset($html);
    $googleResultArray = check_duplicates($googleResultArray);
    return $googleResultArray;
}
Esempio n. 2
0
    }
}
if ($total_marks != 0) {
    if ($row_no > 0 and $properties->get_paper_type() != '3' and $properties->get_paper_type() != '4') {
        echo "<tr><td colspan=\"4\"></td><td id=\"marks_total\" style=\"border-top:1px solid black; padding-right:4px\" align=\"right\">";
        if ($marks_incorrect_error == true) {
            echo '<img src="../artwork/small_yellow_warning_icon.gif" width="12" height="11" alt="' . $string['variablenomarks'] . '" />';
        } else {
            echo $total_marks;
        }
        echo "</td><td><nobr>&nbsp;&nbsp;" . $string['passmark'] . ":&nbsp;" . $properties->get_pass_mark() . "%&nbsp;</nobr></td></tr>\n";
        echo "<tr><td colspan=\"4\"></td><td style=\"color:#808080; text-align:right\">" . round($total_random_mark, 2) . "&nbsp;</td><td style=\"color:#808080\">(" . round(round($total_random_mark, 2) / $total_marks * 100, 0) . "%) " . $string['randommark'] . "</td></tr>\n";
    }
}
if ($properties->get_paper_type() != '3') {
    check_duplicates($q_screen, $string);
}
// Final paper warnings.
if ($properties->get_paper_type() == '2') {
    if (isset($paper_warnings['status']) and count($paper_warnings['status']) > 0) {
        $first = true;
        echo "<tr><td colspan=\"2\" class=\"warnicon\"><img src=\"../artwork/small_yellow_warning_icon.gif\" width=\"12\" height=\"11\" alt=\"" . $string['warning'] . "\" /></td><td colspan=\"4\" class=\"warn\"><strong>" . $string['following_questions'] . ":</strong> ";
        foreach ($paper_warnings['status'] as $name => $warn_qs) {
            if (!$first) {
                echo ', ';
            }
            echo "<strong>'{$name}'</strong> Q" . implode(', Q', $warn_qs);
            $first = false;
        }
        echo "</td></tr>\n";
    }