| Server IP : 37.9.174.138 / Your IP : 216.73.216.117 Web Server : Apache System : Linux vps6.backend.sk 6.12.100+deb13-amd64 #1 SMP PREEMPT_DYNAMIC Debian 6.12.100-1 (2026-07-30) x86_64 User : ftpuser ( 1001) PHP Version : 8.4.24 Disable Function : NONE MySQL : OFF | cURL : ON | WGET : ON | Perl : ON | Python : OFF | Sudo : ON | Pkexec : ON Directory : /var/www/html/ttjs.cz/dev/modules/ttjs/code/ |
Upload File : |
<?php
/*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
namespace modules\ttjs\code;
/**
* Description of PDSO
*
* @author pegas
*/
class PDSO extends \app\classes\PDOElement {
CONST UPLOAD_DIR = "uploads/private/uploads/pdso/";
private $items;
public function __construct($id) {
parent::__construct($id, "pdso", array("id" => $id), "id", false, false, true);
$this->items = new \app\classes\PDOCollection("pdso_items", "id", "SELECT * FROM pdso_items WHERE pdso_id=:pdso_id AND state=:ACTIVE", array(
"pdso_id" => $this->_get("id"),
"ACTIVE" => \app\constants\State::ACTIVE
));
}
public function getItems() {
return $this->items;
}
public static function getNewPDSO($users_id) {
$db = \app\classes\PDODatabase::getInstance();
$path = getUniqueId() . time();
mkdir(DOCUMENT_ROOT . self::UPLOAD_DIR . $path);
mkdir(str_replace("/private/uploads/", "/private/thumbs/", DOCUMENT_ROOT . self::UPLOAD_DIR . $path));
$db->addRecord("pdso", array(
"path" => $path,
"users_id" => $users_id
));
return new PDSO($db->getLastInsertId());
}
public static function getEmptyPDSO($users_id) {
$db = \app\classes\PDODatabase::getInstance();
$id = $db->getValue("SELECT MAX(id) FROM pdso WHERE users_id=:users_id AND state=:ACTIVE", array(
"users_id" => $users_id,
"ACTIVE" => \app\constants\State::ACTIVE
));
try {
$pdso = new PDSO($id);
if ($pdso->getItems()->getElementsCount() === 0) {
$pdso->update(array("created" => date("Y-m-d H:i:s")));
return $pdso;
}
} catch (\Exception $ex) {
}
$pdso = self::getNewPDSO($users_id);
return $pdso;
}
public function verifyUserAccessibility($userId) {
if (intval($this->_get("users_id")) !== intval($userId)) {
throw new \Exception("pdso id: " . $this->_get("id"), \app\constants\ResponseCodes::ACCESS_DENIED);
}
}
public function getUploadPath($www = false) {
$nonwww = DOCUMENT_ROOT . self::UPLOAD_DIR . $this->_get("path") . "/";
if (!file_exists($nonwww)) {
mkdir($nonwww);
}
return $www ? "/" . self::UPLOAD_DIR . $this->_get("path") . "/" : $nonwww;
}
public function delete() {
$db = \app\classes\PDODatabase::getInstance();
$db->sqlCommand("UPDATE pdso_items SET state=:DELETED WHERE pdso_id=:pdso_id", array(
"DELETED" => \app\constants\State::DELETED,
"pdso_id" => $this->_get("id")
));
deleteFile(DOCUMENT_ROOT . self::UPLOAD_DIR . $this->_get("path"));
deleteFile(str_replace("/private/uploads/", "/private/thumbs/", DOCUMENT_ROOT . self::UPLOAD_DIR . $this->_get("path")));
parent::delete();
}
}