<?php
/**
dichomety() a project by edward_sharp
http://www.edwardsharp.net/project/dichomety/
GoogleImages class thx to:
* GoogleImages - Google Image Scraper
*
* Scrapes images off Google image search based on a specified query term.
*
* @copyright 2008 The Dirty Frenchman
* @license http://www.gnu.org/licenses/gpl.html GNU General Public License
* @version 0.1
* @link http://www.thedirtyfrenchman.com
*/
/**
* getImages : Returns an array containing a thumbnail link, fullsize image link
* and ALT text link for specified keyword
*
*/
function getImages($keyword)
{
$pics = array();
$searchURL = 'http://images.google.com/images?svnum=10&um=1&hl=en&safe=off&q=';
$searchURL .= urlencode($keyword) . '&btnG=Search+Images"';
$results = file_get_contents($searchURL);
preg_match_all('/dyn.Img.*?;/', $results, $string, PREG_SET_ORDER );
$x=0;
foreach($string as $img)
{
$image = explode(',', str_replace("\"",'',$img[0]));
// Create array based on size
if (count($image)==16)
{
$pics[$x][thumb] = $image[13] . '?q=tbn:' . $image[2] . $image[3];
$pics[$x][alt] = str_replace('...','',str_replace('\x3cb\x3e','',(str_replace('\x3c/b\x3e','',$image[6]))));
$pics[$x][link] = $image[4];
}
if (count($image)==17)
{
$pics[$x][thumb] = $image[14] . '?q=tbn:' . $image[2] . $image[3];
$pics[$x][alt] = str_replace('...','',str_replace('\x3cb\x3e','',(str_replace('\x3c/b\x3e','',$image[6]))));
$pics[$x][link] = $image[3];
}
if (count($image)==18)
{
$pics[$x][thumb] = $image[15] . '?q=tbn:' . $image[2] . $image[3];
$pics[$x][alt] = str_replace('...','',str_replace('\x3cb\x3e','',(str_replace('\x3c/b\x3e','',$image[6]))));
$pics[$x][link] = $image[3];
}
$x++;
}
shuffle($pics);
return $pics;
}
function displayImages($x,$wID) {
$DonnaHaraway = array("a" =>
array (
0=> "Representation",
1=> "Bourgeois novel, realism",
2=> "Organism",
3=> "Depth, integrity",
4=> "Heat",
5=> "Biology as clinical practice",
6=> "Physiology",
7=> "Small group",
8=> "Perfection",
9=> "Eugenics",
10=> "Decadence, Magic Mountain",
11=> "Hygiene",
12=> "Microbiology, tuberculosis",
13=> "Organic division of labour",
14=> "Functional specialization",
15=> "Reproduction",
16=> "Organic sex role specialization",
17=> "Bioogical determinism",
18=> "Community ecology",
19=> "Racial chain of being",
20=> "Scientific management in home/factory",
21=> "Family/Market/Factory",
22=> "Family wage",
23=> "Public/Private",
24=> "Nature/Culture",
25=> "Co-operation",
26=> "Freud",
27=> "Sex",
28=> "labour",
29=> "Mind",
30=> "Second World War",
31=> "White Capitalist Patriarchy"),
"b" =>
array (
0=> "Simulation",
1=> "Science fiction, postmodernism",
2=> "Biotic Component",
3=> "Surface, boundary",
4=> "Noise",
5=> "Biology as inscription",
6=> "Communications engineering",
7=> "Subsystem",
8=> "Optimization",
9=> "Population Control",
10=> "Obsolescence, Future Shock",
11=> "Stress Management",
12=> "Immunology, AIDS",
13=> "Ergonomics/cybernetics of labour",
14=> "Modular construction",
15=> "Replication",
16=> "Optimal genetic strategies",
17=> "Evolutionary inertia, constraints",
18=> "Ecosystem",
19=> "Neo-imperialism, United Nations humanism",
20=> "Global factory/Electronid cottage",
21=> "Women in the Integrated Circuit",
22=> "Comparable worth",
23=> "Cyborg citizenship",
24=> "fields of difference",
25=> "Communicatins enhancemenet",
26=> "Lacan",
27=> "Genetic engineering",
28=> "Robotics",
29=> "Artificial Intelligence",
30=> "Star Wars",
31=> "Informatics of Domination",)
);
if($x=='a'){
global $keyword;
$keyword=$DonnaHaraway['a'][$wID];
} else if($x=='b'){
global $keyword;
$keyword=$DonnaHaraway['b'][$wID];
}
$img = getImages($keyword);
for ($i = 0; $i <= 15; $i++) {
$filenameinit = $img[$i][link];
//timeout stuff
$timeout = 3;
$old = ini_set('default_socket_timeout', $timeout);
@$file = fopen($filenameinit, 'r');
ini_set('default_socket_timeout', $old);
if (!$file){
}else {
$filename = $filenameinit;
break;
}
}
return "<img src=\"$filename\" alt=\"$keyword\" title=\"$keyword\" id=\"w\" height=\"90%\" width=\"100%\"/>";
}
?>
<?php
//init $wID and set it to something
if (isset($_GET[wID])&&$_GET[wID]<=30){
$wID=$_GET[wID]+1;
}
else {
$wID=0;
}
//refresh based on wID
if ($_GET[w1]==true) {
//echo '<meta http-equiv="refresh" content="1;url=index.php?w1=true&wID='.$wID.'" />';
print(displayImages('a',$wID));
}else if ($_GET[w2]==true) {
//echo '<meta http-equiv="refresh" content="1;url=index.php?w2=true&wID='.$wID.'" />';
print(displayImages('b',$wID));
}else {?>
var c=0
var t
function timedCount()
{
if (c<=31){
c=c+1;
} else {
c=0;
}
var xwin="index.php?w1=true&wID="+c;
var ywin="index.php?w2=true&wID="+c;
window.open(xwin,'a','width=500,height=600,top=50,left=0');
window.open(ywin,'b','width=500,height=600,top=50,left=500');
t=setTimeout("timedCount()",10000);
}
function stopCount()
{
clearTimeout(t);
}