68 lines
1.6 KiB
PHP
Executable File
68 lines
1.6 KiB
PHP
Executable File
<?php
|
|
|
|
use Vn\Lib;
|
|
use Vn\Lib\UserException;
|
|
|
|
/**
|
|
* Uploads a access module.
|
|
*/
|
|
class AccessVersion extends Vn\Web\JsonRequest
|
|
{
|
|
function run ($db)
|
|
{
|
|
if (empty ($_REQUEST['moduleName']))
|
|
throw new UserException (s('Module name not specified'));
|
|
|
|
$module = $_REQUEST['moduleName'];
|
|
|
|
// Checks for file errors.
|
|
|
|
if (empty ($_FILES['moduleFile']['name']))
|
|
throw new UserException (s('File not choosed'));
|
|
|
|
if ($_FILES['moduleFile']['error'] != 0)
|
|
{
|
|
switch ($_FILES['image']['error'])
|
|
{
|
|
case UPLOAD_ERR_INI_SIZE:
|
|
$message = 'ErrIniSize';
|
|
break;
|
|
case UPLOAD_ERR_FORM_SIZE:
|
|
$message = 'ErrFormSize';
|
|
break;
|
|
case UPLOAD_ERR_PARTIAL:
|
|
$message = 'ErrPartial';
|
|
break;
|
|
case UPLOAD_ERR_NO_FILE:
|
|
$message = 'ErrNoFile';
|
|
break;
|
|
case UPLOAD_ERR_NO_TMP_DIR:
|
|
$message = 'ErrNoTmpDir';
|
|
break;
|
|
case UPLOAD_ERR_CANT_WRITE:
|
|
$message = 'ErrCantWrite';
|
|
break;
|
|
case UPLOAD_ERR_EXTENSION:
|
|
$message = 'ErrExtension';
|
|
break;
|
|
default:
|
|
$message = 'ErrDefault';
|
|
break;
|
|
}
|
|
|
|
throw new Lib\Exception (s($message));
|
|
}
|
|
|
|
error_log ($module);
|
|
error_log ($_FILES['moduleFile']['tmp_name']);
|
|
error_log ("/tmp/$module.png");
|
|
|
|
// Saves the module.
|
|
|
|
rename ($_FILES['moduleFile']['tmp_name'], "/tmp/$module.png");
|
|
//unlink ($_FILES['moduleFile']['tmp_name']);
|
|
return TRUE;
|
|
}
|
|
}
|
|
|