|
|
@@ -4688,14 +4688,14 @@ jQuery(document).ready(function(){
|
|
|
$db = DB::getDB();
|
|
|
$record = $db->get_by_id($tblName, $id);
|
|
|
if (!$this->_acl->canWriteRecord($record) && !$this->_acl->hasPermSuperWrite()) {
|
|
|
- header('HTTP/1.0 403.3 - Write access forbidden');
|
|
|
+ header('HTTP/1.0 403 Forbidden');
|
|
|
echo "Brak dostępu do rekordu";
|
|
|
exit;
|
|
|
}
|
|
|
|
|
|
$theGeomFieldId = $this->_acl->getFieldIdByName($geomFieldName);
|
|
|
if (!$this->_acl->isAllowed($theGeomFieldId, 'W', $record)) {
|
|
|
- header('HTTP/1.0 403.3 - Write access forbidden');
|
|
|
+ header('HTTP/1.0 403 Forbidden');
|
|
|
echo "Brak dostępu do zapisu dla pola {$geomFieldName}";
|
|
|
exit;
|
|
|
}
|
|
|
@@ -4733,6 +4733,14 @@ jQuery(document).ready(function(){
|
|
|
try {
|
|
|
$response = $this->{$method}($args);
|
|
|
}
|
|
|
+ catch (HttpException $e) {
|
|
|
+ $response = new stdClass();
|
|
|
+ $response->type = 'error';
|
|
|
+ $response->msg = $e->getMessage();
|
|
|
+ $response->errorCode = $e->getCode();
|
|
|
+
|
|
|
+ Http::sendHeaderByCode($e->getCode());
|
|
|
+ }
|
|
|
catch (Exception $e) {
|
|
|
$response = new stdClass();
|
|
|
$response->type = 'error';
|
|
|
@@ -4740,12 +4748,6 @@ jQuery(document).ready(function(){
|
|
|
$response->errorCode = $e->getCode();
|
|
|
}
|
|
|
|
|
|
- switch ($response->errorCode) {
|
|
|
- case 404: header('HTTP/1.0 404 Not Found'); break;
|
|
|
- case 403: header('HTTP/1.0 403 Forbidden'); break;
|
|
|
- case 4033: header('HTTP/1.0 403.3 - Write access forbidden'); break;
|
|
|
- default:
|
|
|
- }
|
|
|
header('Content-type: application/json');
|
|
|
echo json_encode($response);
|
|
|
exit;
|
|
|
@@ -4757,22 +4759,22 @@ jQuery(document).ready(function(){
|
|
|
$response = new stdClass();
|
|
|
|
|
|
if ($id <= 0) {
|
|
|
- throw new Exception("Wrong param ID", 404);
|
|
|
+ throw new HttpException("Wrong param ID", 404);
|
|
|
}
|
|
|
|
|
|
$tblName = $this->_acl->getName();
|
|
|
|
|
|
$record = $this->_dataSource->getItem($id);
|
|
|
if (!$record) {
|
|
|
- throw new Exception("Nie odnaleziono rekordu nr {$id}", 404);
|
|
|
+ throw new HttpException("Nie odnaleziono rekordu nr {$id}", 404);
|
|
|
}
|
|
|
if (!$this->_acl->canWriteRecord($record) && !$this->_acl->hasPermSuperWrite()) {
|
|
|
- throw new Exception("Brak dostępu do rekordu nr {$id}", 403);
|
|
|
+ throw new HttpException("Brak dostępu do rekordu nr {$id}", 403);
|
|
|
}
|
|
|
|
|
|
$theGeomFieldId = $this->_acl->getFieldIdByName($geomFieldName);
|
|
|
if (!$this->_acl->isAllowed($theGeomFieldId, 'W', $record)) {
|
|
|
- throw new Exception("Brak dostępu do zapisu dla pola {$geomFieldName}", 403);
|
|
|
+ throw new HttpException("Brak dostępu do zapisu dla pola {$geomFieldName}", 403);
|
|
|
}
|
|
|
|
|
|
if (empty($record->{$geomFieldName})) {
|
|
|
@@ -4804,23 +4806,22 @@ jQuery(document).ready(function(){
|
|
|
return $response;
|
|
|
}
|
|
|
|
|
|
- // TODO: check read access
|
|
|
public function sendFileContent($id, $fileName) {
|
|
|
$DBG = ('1' == V::get('DBG', '', $_REQUEST));
|
|
|
|
|
|
$dbID = $this->_acl->getDB();
|
|
|
$db = DB::getDB($dbID);
|
|
|
if (!$db) {
|
|
|
- throw new Exception('No DB', 406);
|
|
|
+ throw new HttpException('No DB', 406);
|
|
|
}
|
|
|
|
|
|
$record = $this->_dataSource->getItem($id);
|
|
|
if (!$record) {
|
|
|
- throw new Exception("No item ID({$rowID})", 404);
|
|
|
+ throw new HttpException("No item ID({$rowID})", 404);
|
|
|
}
|
|
|
|
|
|
- if (!$this->_acl->canReadRecord($record)) {
|
|
|
- throw new Exception("Brak dostępu do rekordu", 406);
|
|
|
+ if (!$this->_acl->canReadRecord($record)) {// TODO: Write, Super Write?
|
|
|
+ throw new HttpException("Brak dostępu do rekordu", 406);
|
|
|
}
|
|
|
|
|
|
$tblName = $this->_acl->getName();
|
|
|
@@ -4828,7 +4829,7 @@ jQuery(document).ready(function(){
|
|
|
Lib::loadClass('FoldersConfig');
|
|
|
$folderConfAll = FoldersConfig::getRawData();
|
|
|
if (!FoldersConfig::hasConfig($confTblName)) {
|
|
|
- throw new Exception("Brak danych konfiguracyjnych", 404);
|
|
|
+ throw new HttpException("Brak danych konfiguracyjnych", 404);
|
|
|
}
|
|
|
|
|
|
$folderConf = FoldersConfig::getAll($confTblName);
|
|
|
@@ -4838,7 +4839,7 @@ jQuery(document).ready(function(){
|
|
|
$uploader = new FileUploader($confTblName, $record);
|
|
|
$errMsg = '';
|
|
|
if (!$uploader->setConfig($folderConf, $errMsg)) {
|
|
|
- throw new Exception("Błąd danych konfiguracyjnych ({$tblName})\n". $errMsg, 404);
|
|
|
+ throw new HttpException("Błąd danych konfiguracyjnych ({$tblName})\n". $errMsg, 404);
|
|
|
}
|
|
|
$uploader->findFolder();
|
|
|
if($DBG){ echo'<pre style="max-height:200px;overflow:auto;border:1px solid red;text-align:left;">uploader (F.' . __FUNCTION__ . ':' . __LINE__ . '): ';print_r($uploader);echo'</pre>'; }
|
|
|
@@ -4849,7 +4850,7 @@ jQuery(document).ready(function(){
|
|
|
$localPath = $uploader->getLocalPath();
|
|
|
$filePath = "{$localPath}/{$mainFolder}/{$fileName}";
|
|
|
if (!file_exists($filePath)) {
|
|
|
- throw new Exception("Plik nie istnieje", 404);
|
|
|
+ throw new HttpException("Plik nie istnieje", 404);
|
|
|
}
|
|
|
|
|
|
if (function_exists('http_send_file')) {
|
|
|
@@ -4865,12 +4866,16 @@ jQuery(document).ready(function(){
|
|
|
header('Content-Length: ' . filesize($filePath));
|
|
|
|
|
|
set_time_limit(0);
|
|
|
- $file = @fopen($filePath, "rb");
|
|
|
- while (!feof($file)) {
|
|
|
- print(@fread($file, 1024*8));
|
|
|
+ $filePointer = @fopen($filePath, "rb");
|
|
|
+ if (!$filePointer) {
|
|
|
+ throw new HttpException('Problem z odczytem pliku', 500);
|
|
|
+ }
|
|
|
+ while (!feof($filePointer)) {
|
|
|
+ print(@fread($filePointer, 1024*8));
|
|
|
ob_flush();
|
|
|
flush();
|
|
|
}
|
|
|
+ fclose($filePointer);
|
|
|
}
|
|
|
}
|
|
|
|