<?php
##########################################################################
# @author: elmar eigner #
# @contact: eigner@open-eye.de #
# @revision: 1.0 #
# @release-date: 2002/06/27 #
# @classname: picgrab #
##########################################################################
class picgrab {
var $result = false;
var $orgfile;
var $newfile;
var $priverror;
var $showresult;
function picgrab($domain,$pfad,$neuername,$out) {
$this->orgfile = $domain.$pfad;
$this->showresult = $out;
$fp = fopen ("http://".$this->orgfile,"rb");
if (!$fp) {
$this->$priverror = "couln't open $this->orgfile";
return false;
} else {
$data = fread($fp,6000000);
fclose($fp);
}
if(preg_match("/\.([a-z]*)$/i",$this->orgfile,$filetypes)) {
$imgtype = $filetypes[1];
$this->newfile = $neuername.".".$imgtype;
$myNewImage = fopen($this->newfile,"wb");
if($myNewImage) {
fputs($myNewImage,$data);
fclose($myNewImage);
$this->result = true;
}
else {
$this->$priverror = "couln't save $this->orgfile as $this->newfile!";
return false;
}
}
if($this->result) {
if($this->showresult==1) echo "succesfully saved $this->orgfile as <a href='$this->newfile' target='_blank'>$this->newfile</a>!";
}
else {
if($this->showresult==1) echo $this->$priverror;
}
}
} // end class picgrab
##########################################################################
# @Usage-Sample of class picgrab #
# @PARAMS: #
# domain (without leading http!) #
# path to picture #
# name (path+name) to save as #
# result flag (0=don't show, 1=show) #
##########################################################################
$p1 = new picgrab("www.nichtohne.de","/oe/pix/head_3.jpg","open-eye",1);
?> |