Plagiarism Check Using the Google Search API

This project was inspired by an incident were somebody tired to pass off material from a public document found in the Internet as his own. Fortunately, a Google search was done on a random paragraph to yield surprising results.

< ?php require_once("include/nusoap/nusoap.php"); ?>
Send this file:
< ?php if ($_POST['upload'] == "true") { ?> < ?php if ($_FILES['userfile']['size'] > 500000) { ?> File Size (< ?php echo $_FILES['userfile']['size']; ?>) Not Supported. < ?php } else if ($_FILES['userfile']['type'] != 'text/plain') { ?> File Type (< ?php echo $_FILES['userfile']['type']; ?>) Not Supported. < ?php } else { /* grab string */ $fh = fopen (trim(stripslashes($_FILES['userfile']['tmp_name'])), "r"); if ($_FILES['userfile']['size'] > 10240) { fseek ($fh, rand (20, 100) * 10); } if ($_FILES['userfile']['size'] > 1024) { fseek ($fh, rand (10, 90) * 10); } else { fseek ($fh, rand (5, 10) * 10); } $text = fread ($fh, 512); $haystack = preg_replace("/\s+/", " ", $text); $bquery = strstr ($haystack, ' '); fclose ($fh); $end = strpos ($bquery, ' ', rand (5, 10) * 10); $query = trim (substr ($bquery, 0, $end)); echo "Validation String: " . $query . "
\n"; /* do query */ $params = array( 'key' => 'use your own google key here', 'q' => $query, 'start' => 0, 'maxResults' => 10, 'filter' => false, 'restrict' => '', 'safeSearch' => false, 'lr' => '', 'ie' => '', 'oe' => '' ); $soapoptions = array( 'namespace' => 'urn:GoogleSearch', 'trace' => 0); $sc = new soapclient('http://api.google.com/GoogleSearch.wsdl', 'wsdl'); $results = $sc->call ("doGoogleSearch", $params); print "Printing Results (Displaying " . $results['endIndex']; print "/" . $results['estimatedTotalResultsCount'] . ")

\n"; foreach ( $results['resultElements'] as $result ) { print ""; print $result['title'] . "
"; print "" . $result['snippet'] . ""; print "

\n"; } }} ?>