ini_set('post_max_size', '64M');
ini_set('upload_max_filesize', '64M');
require_once($_SERVER['DOCUMENT_ROOT'].'/dev/classes/c_library.php');
$c_library = new c_library;
// ADMIN - SAVE CHANGES
if ($_POST['admin'] == 1 and $user_info['admin_library']) {
if ($_POST['admin_function'] == 'newfile') {
// UPLOAD FILE
for ($i_areacheckbox=0; $i_areacheckbox<=20; $i_areacheckbox++) {
if ($_POST['newarea'.$i_areacheckbox]) {
$areatotal .= '-'.$_POST['newarea'.$i_areacheckbox].'-';
}
}
$parameters_newfile['area'] = $areatotal;
$parameters_newfile['title'] = $_POST['title'];
$parameters_newfile['author'] = $_POST['author'];
$parameters_newfile['language'] = $_POST['language'];
$parameters_newfile['file'] = $_FILES['file']['name'];
$parameters_newfile['kind'] = $_POST['kind'];
$parameters_newfile['url'] = $_POST['url'];
$parameters_newfile['url2'] = $_POST['url2'];
$parameters_newfile['url3'] = $_POST['url3'];
//print_r($_POST);
//print_r($_GET);
// UPLOADING
if ($_POST['kind'] == 1) {
// Configuration - Your Options
$allowed_filetypes = array('.pdf'); // These will be the types of file that will pass the validation.
$max_filesize = 524288*10*10*10; // Maximum filesize in BYTES (currently 0.5MB).
$upload_path = $_SERVER['DOCUMENT_ROOT'].'/upload/library/'; // The place the files will be uploaded to (currently a 'files' directory).
$filename = $_FILES['file']['name']; // Get the name of the file (including file extension).
$ext = substr($filename, strpos($filename,'.'), strlen($filename)-1); // Get the extension from the filename.
// Check if the filetype is allowed, if not DIE and inform the user.
if(!in_array($ext,$allowed_filetypes))
die('The file you attempted to upload is not allowed.');
// Now check the filesize, if it is too large then DIE and inform the user.
if(filesize($_FILES['file']['tmp_name']) > $max_filesize)
die('The file you attempted to upload is too large.');
// Check if we can upload to the specified path, if not DIE and inform the user.
if(!is_writable($upload_path))
die('You cannot upload to the specified directory, please CHMOD it to 777.');
// Upload the file to your specified path.
if (move_uploaded_file($_FILES['file']['tmp_name'], $upload_path.$filename)) {
echo 'Your file upload was successful, view the file here'; // It worked.
}
else {
echo 'There was an error during the file upload. Please try again.'; // It failed :(.
}
}
$c_library->admin_newfile($parameters_newfile);
}
else {
// EDIT AREAS
for ($i_areacheckbox=0; $i_areacheckbox<=20; $i_areacheckbox++) {
if ($_POST['newarea'.$i_areacheckbox]) {
$areatotal .= '-'.$_POST['newarea'.$i_areacheckbox].'-';
}
}
$parameters_savechanges['id'] = $_POST['idlib'];
$parameters_savechanges['area'] = $areatotal;
$c_library->admin_savechanges($parameters_savechanges);
$idlib = $_POST['idlib'];
$idlib_delete = 'delete'.$idlib;
if ($_POST[$idlib_delete] == 1) {
$c_library->admin_delete($idlib);
}
}
echo 'Saved