View file index.php

File size: 2.99Kb
<?php
include ("header.php");  $to=$_REQUEST["to"]; if ($to == "view") { $foto=$_GET["cat"]; if ($foto == "girl") { $cat = "./girl/"; } if ($foto == "men") { $cat = "./men/"; } if ($foto == "folk") { $cat = "./folk/"; } $dir = opendir($cat); while ($file = readdir($dir)) { if (($file != ".") && ($file != "..")) { $sz=filesize("$cat/{$file}"); $sz = $sz / 1024; $size = round($sz); $old=imagecreatefromjpeg("$cat/{$file}"); $w = imageSX($old); $h = imageSY($old); echo "<img src='preview.php?dir={$cat}/{$file}' alt='preview'/><br/><small>разрешение: $w X $h <br/> размер: $size kb</small><br/>скачать:<br/>&gt;&gt;<a href='$cat/{$file}'>{$file}</a><br/>+ - + - +<br/>"; } } echo "<br/>"; closedir($dir); }
if ($to == "input")
{ if (empty($_REQUEST["user"])) { print "<form action=\"index.php\" method=\"post\" enctype=\"multipart/form-data\"> файл:<br/> <input type=\"hidden\" name=\"user\" value = \"input\"> <input type=\"hidden\" name=\"to\" value = \"input\">";  $agent = strtok($_SERVER['HTTP_USER_AGENT'],'/'); if ($agent == "Opera") { print "<input type=\"hidden\" name=\"agent\" value = \"Opera\"> <input name=\"user\" value = \"\">&nbsp;<a href=\"op:fileselect\">[обзор системы]</a> <br/> Имя:<input type=\"text\" name=\"f\" value = \"foto\">.jpg"; } else { print "<input type=\"file\" size=\"32\" name=\"att[]\">"; } print "<br/> Категория:<small><br/><input type=\"radio\" name=\"cat\" value =\"girl\">&nbsp;девушки <br/><input type=\"radio\" name=\"cat\" value =\"men\">&nbsp;парни <br/><input type=\"radio\" name=\"cat\" value =\"folk\">&nbsp;другие</small> <input type='submit' value='[закинуть файл]'> </form> <br/>"; } else  {   $user = $_POST["user"];  $dir=$_REQUEST["cat"];  $agent=$_REQUEST["agent"]; if ($agent == "Opera") {
$uploadedfile = $_POST['user']; $array = explode('file=', $uploadedfile);
$filebase64 = $array[1];   $filedata = base64_decode($filebase64); $dir=$_REQUEST["cat"]; $f=$_REQUEST["f"]; $id=htmlspecialchars($f); $t=date("s"); $f="$id$t"; $file = fopen("{$dir}/{$f}.jpg", "x+"); fclose($file); $file = @fopen("${dir}/{$f}.jpg", "wb");

fwrite($file, $filedata);
fclose($file); } else { for($i = 0; $i < count($_FILES['att']['name']); $i++) { if (copy($_FILES['att']['tmp_name'][$i], "{$dir}/".$_FILES['att']['name'][$i])) {
unlink($_FILES['att']['tmp_name'][$i]);
chmod("{$dir}/".$_FILES['att']['name'][$i], 0777); }} }
print "ваше фото добавлено ";}} if (empty($_REQUEST["to"])) { print 'Категории: <br/> - - - <br/> <a href="?to=view&cat=girl"> девушки</a> <br/> - - - <br/> <a href="?to=view&cat=men"> парни</a> <br/> - - - <br/> <a href="?to=view&cat=folk"> другие</a> </small>'; $ref=$site; print "<hr/><b><a href=\"http://$ref\">$ref</a></b>"; } if ($to == "set") { $flag = mkdir 
("girl", 
0777); $flag = mkdir 
("men", 
0777); $flag = mkdir 
("folk", 
0777); print "ok"; } print '<hr/> <a href="?to=input"> добавить</a> | <a href="./">начало</a></p>'; print $zzz;?>