Файл: adultscript-2.0.3-pro/files/mobile/templates/default/extend/ajax/photo_upload.plugin.php
Строк: 30
<?php
defined('_VALID') or die('Restricted Access!');
function ajax_plugin_photo_upload()
{
// needs more security here
$unique = (isset($_GET['unique']) && ctype_digit($_GET['unique'])) ? trim($_GET['unique']) : null;
$count = 1;
if ($_FILES) {
$dir = TMP_DIR.'/uploads/'.$unique;
VFolder::delete($dir);
VFolder::create($dir, 0777);
foreach ($_FILES as $index => $file) {
echo VF::debug($file);
if ($file['error'] != '0') {
continue;
}
if (!file_exists($file['tmp_name']) or !is_uploaded_file($file['tmp_name'])) {
continue;
}
$ext = VFile::ext($file['name']);
$exts = VF::cfg_item('module.photo.photo_allowed_ext');
if (!in_array($ext, $exts)) {
continue;
}
$max_size = VF::cfg_item('module.photo.photo_max_size')*1024*1024;
if (filesize($file['tmp_name']) > $max_size) {
return;
}
$image = VF::factory('image');
if ($image->load($file['tmp_name'])) {
$dst = $dir.'/'.$count.'.'.$image->src['ext'];
move_uploaded_file($file['tmp_name'], $dst);
}
++$count;
}
echo 'success';
}
}