| 1 |
<?php |
| 2 |
namespace LAM\UPLOAD; |
| 3 |
/* |
| 4 |
|
| 5 |
This code is part of LDAP Account Manager (http://www.ldap-account-manager.org/) |
| 6 |
Copyright (C) 2004 - 2025 Roland Gruber |
| 7 |
|
| 8 |
This program is free software; you can redistribute it and/or modify |
| 9 |
it under the terms of the GNU General Public License as published by |
| 10 |
the Free Software Foundation; either version 2 of the License, or |
| 11 |
(at your option) any later version. |
| 12 |
|
| 13 |
This program is distributed in the hope that it will be useful, |
| 14 |
but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 15 |
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 16 |
GNU General Public License for more details. |
| 17 |
|
| 18 |
You should have received a copy of the GNU General Public License |
| 19 |
along with this program; if not, write to the Free Software |
| 20 |
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
| 21 |
|
| 22 |
*/ |
| 23 |
|
| 24 |
use htmlDiv; |
| 25 |
use htmlJavaScript; |
| 26 |
use htmlResponsiveRow; |
| 27 |
use LAM\TYPES\TypeManager; |
| 28 |
|
| 29 |
/** |
| 30 |
* Creates LDAP accounts for file upload. |
| 31 |
* |
| 32 |
* @author Roland Gruber |
| 33 |
* @package tools |
| 34 |
*/ |
| 35 |
|
| 36 |
/** security functions */ |
| 37 |
include_once(__DIR__ . "/../../lib/security.inc"); |
| 38 |
/** access to configuration */ |
| 39 |
include_once(__DIR__ . '/../../lib/config.inc'); |
| 40 |
/** LDAP handle */ |
| 41 |
include_once(__DIR__ . '/../../lib/ldap.inc'); |
| 42 |
/** status messages */ |
| 43 |
include_once(__DIR__ . '/../../lib/status.inc'); |
| 44 |
/** account modules */ |
| 45 |
include_once(__DIR__ . '/../../lib/modules.inc'); |
| 46 |
/** PDF */ |
| 47 |
include_once(__DIR__ . '/../../lib/pdf.inc'); |
| 48 |
|
| 49 |
|
| 50 |
// Start session |
| 51 |
startSecureSession(); |
| 52 |
enforceUserIsLoggedIn(); |
| 53 |
|
| 54 |
// check if this tool may be run |
| 55 |
checkIfToolIsActive('toolFileUpload'); |
| 56 |
|
| 57 |
// die if no write access |
| 58 |
if (!checkIfWriteAccessIsAllowed()) { |
| 59 |
die(); |
| 60 |
} |
| 61 |
|
| 62 |
// Redirect to startpage if user is not logged in |
| 63 |
if (!isLoggedIn()) { |
| 64 |
metaRefresh("../login.php"); |
| 65 |
exit; |
| 66 |
} |
| 67 |
|
| 68 |
// Set correct language, codepages, .... |
| 69 |
setlanguage(); |
| 70 |
|
| 71 |
include __DIR__ . '/../../lib/adminHeader.inc'; |
| 72 |
$typeId = htmlspecialchars($_SESSION['mass_typeId']); |
| 73 |
$typeManager = new TypeManager(); |
| 74 |
$type = $typeManager->getConfiguredType($typeId); |
| 75 |
if ($type === null) { |
| 76 |
logNewMessage(LOG_ERR, 'User tried to access invalid upload type: ' . $typeId); |
| 77 |
die(); |
| 78 |
} |
| 79 |
|
| 80 |
// check if account type is ok |
| 81 |
if ($type->isHidden()) { |
| 82 |
logNewMessage(LOG_ERR, 'User tried to access hidden upload: ' . $type->getId()); |
| 83 |
die(); |
| 84 |
} |
| 85 |
if (!checkIfNewEntriesAreAllowed($type->getId()) || !checkIfWriteAccessIsAllowed($type->getId())) { |
| 86 |
logNewMessage(LOG_ERR, 'User tried to access forbidden upload: ' . $type->getId()); |
| 87 |
die(); |
| 88 |
} |
| 89 |
|
| 90 |
$container = new htmlResponsiveRow(); |
| 91 |
$javaScript = new htmlJavaScript('window.lam.upload.continueUpload(\'../misc/ajax.php?function=upload&typeId=' . $type->getId() . '\', \'' . getSecurityTokenName() . '\', \'' . getSecurityTokenValue() . '\');'); |
| 92 |
$contentDiv = new htmlDiv('uploadContent', $javaScript, ['smallPaddingContent']); |
| 93 |
$container->add($contentDiv); |
| 94 |
parseHtml(null, $container, [], false, null); |
| 95 |
|
| 96 |
include __DIR__ . '/../../lib/adminFooter.inc'; |