Файл: adultscript-2.0.3-pro/files/templates/defboot/extend/ajax/video_upload.plugin.php
Строк: 59
<?php
defined('_VALID') or die('Restricted Access!');
function ajax_plugin_video_upload()
{
$data = array('error' => '', 'message' => '', 'status' => 0);
if (isset($_GET['id'])) {
$unique_id = VF::factory('filter')->get('id', 'STRING', 'GET');
if (!ctype_digit($unique_id)) {
$data['error'] = 100;
$data['msg'] = 'Invalid unique identifier!';
return json_encode($data);
}
if (empty($_FILES) or !isset($_FILES['file'])) {
$data['error'] = 101;
$data['msg'] = 'No file was uploaded!';
return json_encode($data);
}
if ($_FILES['file']['error']) {
$data['error'] = 102;
$data['msg'] = $_FILES['file']['error'];
return json_encode($data);
}
set_time_limit(2*3600);
$filename = VFile::safe($_FILES['file']['name']);
$ext = VFile::ext($filename);
if (!in_array($ext, VCfg::get('video.video_allowed_ext'))) {
$data['error'] = 103;
$data['msg'] = 'Invalid extension! Allowed extensions: '.implode(', ', VCfg::get('video.video_allowed_ext')).'.';
return json_encode($data);
}
if (!is_uploaded_file($_FILES['file']['tmp_name'])) {
$data['error'] = 104;
$data['msg'] = 'File is not a valid uploaded file!';
return json_encode($data);
}
$secret = substr(md5(VF::cfg_item('secret')), -5);
$dst = TMP_DIR.'/uploads/'.$unique_id.'_'.$secret.'.'.$ext;
if (!move_uploaded_file($_FILES['file']['tmp_name'], $dst)) {
$data['error'] = 105;
$data['msg'] = 'Failed to move uploaded file!';
return json_encode($data);
}
$info = TMP_DIR.'/uploads/'.$unique_id.'_'.$secret;
if (!file_put_contents($info, $filename."n".$ext)) {
$data['error'] = 106;
$data['msg'] = 'Failed to write data file!';
return json_encode($data);
}
$data['status'] = 1;
return json_encode($data);
} else {
$data['error'] = 110;
$data['msg'] = 'No unique identifier set!';
return json_encode($data);
}
}