All pastes #582011 Raw Edit

tonkkis

public php v1 · immutable
·published 2007-06-21 20:22 UTC
rendered paste body
<?phpsession_start();		if ($_SESSION['auth'] === "ok")					{$iimagedir='ku/';$ithumbdir='ku/';$ithumb_maxx=810;$ithumb_maxy=410;function isompi($ifile) {    global $iimagedir,$ithumbdir,$ithumb_maxx,$ithumb_maxy;    $iattr=getimagesize($iimagedir.$ifile);    $iorigx=$iattr[0];    $iorigy=$iattr[1];    if ($iorigx>$iorigy) {      if ($iorigx > $ithumb_maxx) {           $isizex=$ithumb_maxx;           $isizey=($iorigy/$iorigx)*$ithumb_maxx;      }else{           $isizex=$iorigx;           $isizey=($iorigy/$iorigx)*$iorigx;      }    }	 else {      if ($iorigy > $ithumb_maxy) {           $isizex=($iorigx/$iorigy)*$ithumb_maxy;           $isizey=$ithumb_maxy;      }else{           $isizex=($iorigx/$iorigy)*$iorigy;           $isizey=$iorigy;      }    }    switch ($iattr[2]) {        case 1:        $iorig=imagecreatefromgif($iimagedir.$ifile);        break;        case 2:        $iorig=imagecreatefromjpeg($iimagedir.$ifile);        break;        case 3:        $iorig=imagecreatefrompng($iimagedir.$ifile);        break;        default:        return false;        break;    }    if ($iorig) {        $ipikku=imagecreatetruecolor($isizex,$isizey);        imagecopyresampled($ipikku,$iorig,0,0,0,0,$isizex,$isizey,$iorigx,$iorigy);        $istatus=imagejpeg($ipikku,$ithumbdir.$ifile,75);	@chmod($ithumbdir.$ifile, 0755);        imagedestroy($iorig);        imagedestroy($ipikku);    }}		$tempPath = "temp/";	$savedPath = "ku/";		if  (substr($_FILES['thefile']['name'], - 3, 3) == "jpg" || substr($_FILES['thefile']['name'], - 3, 3) == "gif"	|| substr($_FILES['thefile']['name'], - 3, 3) == "png") {	if ($_FILES['thefile']['error'] === 0)	{		$c = opendir("ku/");	$b = readdir($c);			while($b){				$b = readdir($c);					if($a = fnmatch("10*",$b)){					unlink("ku/".$b);				}				elseif($a = fnmatch("9*",$b)) {					rename("ku/".$b,"ku/10.".substr($b,-3,3));				}				elseif($a = fnmatch("8*",$b)){					rename("ku/".$b,"ku/9.".substr($b,-3,3));				}				elseif($a = fnmatch("7*",$b)){					rename("ku/".$b,"ku/8.".substr($b,-3,3));				}				elseif($a = fnmatch("6*",$b)){					rename("ku/".$b,"ku/7.".substr($b,-3,3));				}				elseif($a = fnmatch("5*",$b)){					rename("ku/".$b,"ku/6.".substr($b,-3,3));				}				elseif($a = fnmatch("4*",$b)){					rename("ku/".$b,"ku/5.".substr($b,-3,3));				}				elseif($a = fnmatch("3*",$b)){					rename("ku/".$b,"ku/6.".substr($b,-3,3));				}				elseif($a = fnmatch("2*",$b)){					rename("ku/".$b,"ku/3.".substr($b,-3,3));				}				elseif($a = fnmatch("1*",$b)){					rename("ku/".$b,"ku/2.".substr($b,-3,3));				}			}        $tempFile = $tempPath . $_FILES['thefile']['name'];        $savedFile = $savedPath . $_FILES['thefile']['name'];        $movedOk = move_uploaded_file($_FILES['thefile']['tmp_name'], $tempFile);        $doit = `cat $tempFile > $savedFile && rm $tempFile`;	$handle = fopen("sanat/kuvat.txt","a");				}		isompi($_FILES['thefile']['name']);		if(substr($_FILES['thefile']['name'], -4,4) == "JPEG" || substr($_FILES['thefile']['name'], -4,4) == "jpeg"){			rename("ku/".$_FILES['thefile']['name'],"ku/1.jpeg");		}		else{			$vanhuliini = "ku/".$_FILES['thefile']['name'];			$uusio = "ku/1.".substr($_FILES['thefile']['name'],-3,3);					rename($vanhuliini,$uusio);			}		}	}?>	<form action="<?php $_SERVER[PHP_SELF]; ?>" method="post" enctype="multipart/form-data">		<h1>uploadattava tiedosto</h1>        <input type = "file" name = "thefile" value = "Selaa" size="30"><br>	<input type = "submit" value = "upload">		</p>	</form><?php		if ($movedOk)        {		echo "<p>".$_FILES['thefile']['name']."</p>";		echo "<p>onnistu</p>";        }		else {			echo "<p>Upload: kesken tai epäonnistunut.</p>";		}?>