metanohi-misc-subsites/old-projects/x/gimg.php

176 lines
3.4 KiB
PHP

<?php
$qo=$_GET["q"];
if ($qo=="") {
$filename="words.txt";
$handle=fopen($filename,"r");
$w=fread($handle,filesize($filename));
fclose($handle);
$w=explode(",",$w);
$rn=sizeof($w);
$rn=mt_rand(0,$rn-1);
$qo=$w[$rn];
//$sf="An automated search has been made for the word";
}
/*else {
$sf="You have searched for";
}*/
$q=str_replace(" ","+",$qo);
$gimgs=fopen("http://images.google.dk/images?q=".$q,"rb");
$gimg=stream_get_contents($gimgs);
fclose($gimgs);
$img=explode("\");dyn.Img(\"",$gimg);
$img=$img[1];
$img=explode("\"http://",$img);
$img=$img[1];
$img=explode("\"",$img);
$img=str_replace("25","","http://".$img[0]);
//$sf=$sf." ".$q;
$ts="\"".$qo."\" search result :: ";
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3c.org/1999/xhtml" xml:lang="da">
<head>
<title><?php echo $ts; ?>ImageLoad Google</title>
<style type='text/css'>
body {
overflow:hidden;
}
#ibg {
position:absolute;
display:none;
}
#top {
position:absolute;
top:0;
left:8px;
right:8px;
height:8px;
background:transparent url('img/fade-top.png') repeat-x;
}
#right {
position:absolute;
right:0;
top:8px;
bottom:8px;
width:8px;
background:transparent url('img/fade-right.png') repeat-y;
}
#bottom {
position:absolute;
bottom:0;
left:8px;
right:8px;
height:8px;
background:transparent url('img/fade-bottom.png') repeat-x;
}
#left {
position:absolute;
left:0;
top:8px;
bottom:8px;
width:8px;
background:transparent url('img/fade-left.png') repeat-y;
}
#ca {
position:absolute;
top:0;
left:0;
width:8px;
height:8px;
background:transparent url('img/ca.png') no-repeat;
}
#cb {
position:absolute;
top:0;
right:0;
width:8px;
height:8px;
background:transparent url('img/cb.png') no-repeat;
}
#cc {
position:absolute;
bottom:0;
right:0;
width:8px;
height:8px;
background:transparent url('img/cc.png') no-repeat;
}
#cd {
position:absolute;
bottom:0;
left:0;
width:8px;
height:8px;
background:transparent url('img/cd.png') no-repeat;
}
#lifg {
position:absolute;
visibility:hidden;
}
</style>
<script type='text/javascript'>
pic=new Image()
pic.src="<?php echo $img; ?>"
function load() {
lifg=document.getElementById("lifg")
ibg=document.getElementById("ibg")
lifg.src="<?php echo $img; ?>"
if (lifg.scrollWidth>784 || lifg.scrollHeight>584) {
if (lifg.scrollWidth>lifg.scrollHeight) {
lifg.style.width="784px"
if (lifg.scrollHeight>584) {
lifg.style.height="584px"
lifg.style.width="auto"
}
}
else
lifg.style.height="584px"
}
lifg.style.marginLeft="-"+lifg.scrollWidth/2+"px"
lifg.style.marginTop="-"+lifg.scrollHeight/2+"px"
lifg.style.left="50%"
lifg.style.top="50%"
ibg.style.marginLeft="-"+(lifg.scrollWidth+16)/2+"px"
ibg.style.marginTop="-"+(lifg.scrollHeight+16)/2+"px"
ibg.style.left="50%"
ibg.style.top="50%"
ibg.style.width=lifg.scrollWidth+16+"px"
ibg.style.height=lifg.scrollHeight+16+"px"
ibg.style.display="block"
lifg.style.visibility="visible"
}
</script>
</head>
<body onload='load()'>
<div id='ibg'>
<div id='top'></div>
<div id='right'></div>
<div id='bottom'></div>
<div id='left'></div>
<div id='ca'></div>
<div id='cb'></div>
<div id='cc'></div>
<div id='cd'></div>
</div>
<img id='lifg' src='<?php echo $img; ?>' alt='' />
</body>
</html>