- 01
- 02
- 03
- 04
- 05
- 06
- 07
- 08
- 09
- 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
- 53
- 54
- 55
- 56
- 57
- 58
- 59
- 60
- 61
- 62
- 63
- 64
- 65
- 66
- 67
insert_image.php:
<?php
require_once('../config.inc.php');
if ((!isset($_SESSION['user_type'])) || ($_SESSION['user_type'] != 0)) {
header('Location: /');
die;
}
require('admin_image.inc.php');
settitle.php:
<?php
require_once('../config.inc.php');
if ((!isset($_SESSION['user_type'])) || ($_SESSION['user_type'] != 0)) {
header('Location: /');
die;
}
$id = intval($_POST['image']);
$title = $_POST['imgtitle'];
mysql_query("UPDATE images SET title='$title' WHERE id=$id");
require('admin_image.inc.php');
upload_image.php:
<?php
require_once('../config.inc.php');
if ((!isset($_SESSION['user_type'])) || ($_SESSION['user_type'] != 0)) {
header('Location: /');
die;
}
if ((isset($_POST['upload'])) && (isset($_FILES['newimage']))) {
$title = (isset($_POST['title'])) ? $_POST['title'] : '';
$file = $_FILES['newimage'];
if ($file['error'] != 0) {
$msg = 'An error occured during uploading file. (Error code:' . $file['error'] . ')';
} else {
$type = $file['type'];
$tmp_name = $file['tmp_name'];
//check if we are uploading image or not
if (!(((preg_match('/\.gif/i', $file['name'])) || (preg_match('/\.jpg/i', $file['name'])) ||
(preg_match('/\.jpeg/i', $file['name'])) || (preg_match('/\.bmp/i', $file['name'])) ||
(preg_match('/\.png/i', $file['name'])))
&& ((preg_match('/gif/i', $file['type'])) || (preg_match('/jpg/i', $file['type'])) ||
(preg_match('/jpeg/i', $file['type'])) || (preg_match('/bmp/i', $file['type'])) ||
(preg_match('/png/i', $file['type']))))) {
$msg = 'You are trying to upload a non-image file.';
} elseif (filesize($tmp_name) <= 0) {
$msg = 'You are trying to upload file which size is 0 bytes.';
} else {
$img_data = fread(fopen($tmp_name, 'r'), filesize($tmp_name));
if (mysql_query("INSERT INTO images (id, image, type, title)"
. " VALUES ('',"
. " '" . mysql_escape_string($img_data) . "',"
. " '" . mysql_escape_string($type) . "',"
. " '" . mysql_escape_string($title) . "')"))
$msg = 'Image uploaded.';
else
$msg = 'An error occured during inserting image in DB.';
}
}
}
if (isset($msg))
$MyPage->assign('msg', $msg);
require('admin_image.inc.php');
Какая экспрессия, какое необычное именование файлов... lower_case_with_underscores + просто текст
А главное какое необычное представление о модульности: 2 файла по 10 строк, и один на 40, в каждом из которых прописана авторизация и которые инклюдят главный файл