| Server IP : 195.130.67.5 / Your IP : 216.73.216.231 Web Server : Microsoft-IIS/10.0 System : Windows NT WEBSERVER1 10.0 build 17763 (Windows Server 2016) i586 User : IUSR ( 0) PHP Version : 7.4.19 Disable Function : NONE MySQL : OFF | cURL : ON | WGET : OFF | Perl : OFF | Python : OFF | Sudo : OFF | Pkexec : OFF Directory : C:/inetpub/wwwroot/includes/ |
Upload File : |
<?
////////////////////////////////////////////////////////////////////////////////////////
// Class: Attachments
// Purpose: Κλάση διαχείρισης συννημμένων
///////////////////////////////////////////////////////////////////////////////////////
class Attachments
{
private $connector;
public function __construct($db)
{
$this->connector = $db;
}
// Επιστρέφει πίνακα με όλα τα συννημμένα του άρθρου με το δεδομένο id
public function getAttachmentsByParentId($id)
{
$at_array = array();
$result = $this->connector->query("SELECT * FROM attachments WHERE parent_id=$id ORDER BY id");
while ($myrow = $this->connector->fetchArray($result))
{
$at_array[] = $myrow;
}
return $at_array;
}
// Επιστρέφει το μέγεθος του συννημμένου αρχείου με το δοσμένο $at_url path. Αν το αρχείο δεν υπάρχει επιστρέφει 0, ενώ αν το συννημμένο είναι link σε άλλο server επιστρέφει "NULL"
public function getAttachmentSize($at_url)
{
if (stristr($at_url,"http://"))
{
$at_filesize = "NULL";
}
else if (file_exists("../".iconv("utf-8", "iso-8859-7", $at_url)))
{
$at_filesize = @filesize("../".iconv("utf-8", "iso-8859-7", $at_url));
}
else
{
$at_filesize = 0;
}
return $at_filesize;
}
// Προσθέτει νέο συννημμενο
public function insertAttachment($at_filename, $at_filetype, $at_filesize, $at_url, $at_display_filename, $at_description, $at_parent_id)
{
$result = $this->connector->query("INSERT INTO attachments (filename, file_type, file_size, url, display_name, description, parent_id) VALUES ('".$at_filename."','".$at_filetype."',".$at_filesize.",'".$at_url."','".$at_display_filename."','".$at_description."',".$at_parent_id.")");
return $result;
}
// Ενημερώνει υπάρχον συννημμενο
public function updateAttachment($attachment_id, $at_display_filename, $at_description)
{
$result = $this->connector->query("UPDATE attachments SET display_name='".$at_display_filename."', description='".$at_description."' WHERE id=".$attachment_id);
return $result;
}
// Διαγράφει το συννημμένο με συγκεκριμένο id
public function deleteAttachment($id)
{
$result = $this->connector->query("DELETE FROM attachments WHERE id=".$id);
return $result;
}
// Διαγράφει όλα τα συννημμένα που ανοίκουν στο άρθρο με το δεδομένο id
public function deleteAllAttachmentsByParentId($id)
{
$result = $this->connector->query("DELETE FROM attachments WHERE parent_id=".$id);
return $result;
}
}