define WEBROOT http _SERVER HTTP_HOST define DOCROOT _SERVER DOCUMENT_

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
<?
define('WEBROOT', 'http://'.$_SERVER['HTTP_HOST'].'/');
define('DOCROOT', $_SERVER['DOCUMENT_ROOT'].'/');
require(DOCROOT.'config.php');
require(DOCROOT.'source/db.php');
$db = new DB;
### Image Propeties ###
$config['max_image_size'] = 6000*1024; // Maximum Image Size (6Mb)
$config['upload_images_dir'] = DOCROOT.'images/'; // Upload dir
$config['upload_thumbs_dir'] = DOCROOT.'thumbs/'; // Upload dir
$config['valid_types'] = array('rar', 'zip', 'pdf', 'tif', 'tiff', 'ai', 'cdr', 'eps', 'jpg', 'jpeg', 'gif', 'png', 'psd','PNG','JPG','JPEG'); // Upload Images Types
### End Image Propeties ###
$useragent = $_SERVER['HTTP_USER_AGENT'];
$filename = $_FILES['file']['name'];
$filename_tmp = $_FILES['file']['tmp_name'];
$comment = $_POST['comment'];
$ip = $_SERVER['REMOTE_ADDR'];
$unixtime = time();
$md5 = md5($unixtime . "_" . $_FILES['file']['name']);
$ext = substr($_FILES['file']['name'], 1 + strrpos($_FILES['file']['name'], "."));
$file = DOCROOT.'images/'.$unixtime.$md5.'.'.$ext;
if(filesize($filename_tmp) > $config['max_image_size'])
{
$body = 'Рамзер файла больше 2000кб';
} else {
if(!in_array($ext, $config['valid_types'])){
$body = "неправильный тип файла";
} else {
if(move_uploaded_file($_FILES['file']['tmp_name'], $config['upload_images_dir'] .$unixtime.$md5.'.'.$ext)) {
include ("thumbnail.php");
$obj_img = new thumbnail_images();
$obj_img->PathImgOld = $file ;
$obj_img->PathImgNew = $config['upload_thumbs_dir']. $unixtime.$md5.'.'.$ext;
$obj_img->NewWidth = 120;
$obj_img->NewHeight = 100;
$obj_img->create_thumbnail_images();
$filenametosql = $unixtime.$md5.'.'.$ext;
$db->query("insert into images( comment, time, ip, filename, md5, views, email, public, useragent)
values('@$comment','$unixtime','$ip','$filenametosql','$md5', 0, '@$email', '@$public', '$useragent') ") or die(mysql_error());
header('Location: '.WEBROOT.$_POST['loc'].'/view/'.$md5.'/');
$content .= "<center>Фотко добавлено<br/><a href=\"/view/".$md5."/\">Посмотреть</a></center>";
if($_POST['doemail'] == 1) {
mail($_POST['email'], "Pic.co.ua", $body_mail, $headers);
}
} else {
$body = 'ошибко загрузко файло';
}
}
}
?>