public function __construct() { if (empty($_GET['article_id']) && empty($_POST['article_id'])) { $this->disable(); return; } $this->initialize(); if (empty($this->article)) { $this->disable(); return; } $this->enable(); if (!$this->article['zobrazit']) { if ($this->accessRights->approved('ADD')) { $this->setFunction("edit", "edit_article"); $this->setForm("edit", "Zmeň názov článku", "edit_name", "edit_article_form"); $this->setFunction("change_topic", "change_topic"); $this->setForm("change_topic", "Zmeň rubriku", "change_topic", "change_topic_form"); } } if ($this->accessRights->approved('RELEASE')) { $this->setFunction("release", "release_article"); } if ($this->accessRights->approved('ASSIGN')) { $this->setFunction("add_user", "add_user"); $this->setForm("add_user", "Pridaj užívateľa", "add_user", "add_user_form"); $this->setFunction("rem_user", "remove_user"); $this->setForm("rem_user", "Odstráň užívateľa", "rem_user", "remove_user_form"); } $this->path = ProgramManager::getHomeDir() . "/../articles/" . $this->article['id']; }
protected function remove_article() { if (empty($_POST['id'])) { $this->setMsg(false, "Zadajte článok"); return; } $data = new DBQuery(CDatabaza::getInstance()); $data->setTable("Clanok_uzivatel"); $data->setRecord("clanok_id", $_POST['id']); if (!$data->queryDB("delete")) { $this->setMsg(false, "Nepodarilo sa vymazať prepojenia"); return; } $data->setTable("Clanok"); $data->setRecord("clanok_id", $_POST['id']); if (!$data->queryDB("delete")) { $this->setMsg(false, "Nepodarilo sa vymazať článok"); return; } //odstrani adresar a vsetko co sa v nom nachadza $dir = ProgramManager::getHomeDir() . "/../articles/" . $_POST['id']; $this->removeDir($dir); $this->setMsg(true, "Článok vymazaný"); }
private function createThumbFile($url, $width, $height) { $path = ProgramManager::getHomeDir() . "/../" . $url; if (!file_exists(dirname($path) . "/thumbs")) { mkdir(dirname($path) . "/thumbs"); chmod(dirname($path) . "/thumbs", 0777); } else { chmod(dirname($path) . "/thumbs", 0777); } if (!file_exists($path)) { return null; } //get extention index $filename = basename($url); $extIndex = strrpos($filename, "."); //creates path to thumb file $thumbUrl = dirname($url) . "/thumbs/" . substr($filename, 0, $extIndex) . "_thumb.png"; $thumbPath = ProgramManager::getHomeDir() . "/../" . $thumbUrl; if (file_exists($thumbPath)) { chmod($thumbPath, 0777); return $thumbUrl; } //create source image $src_image = $this->getImage($path); if ($src_image == null) { return null; } //get size of source image $srcSize = getimagesize($path); //create thumb image $dest_image = $this->getThumb($src_image, $srcSize[0], $srcSize[1], $width, $height); //save thumb image as png file $file = fopen($thumbPath, "w"); fclose($file); chmod($thumbPath, 0777); imagepng($dest_image, $thumbPath); imagedestroy($src_image); imagedestroy($dest_image); //return path to new thumb file return $thumbUrl; }
private function display_show() { echo ""; $path = ProgramManager::getHomeDir() . "/../articles/" . $this->article['id'] . "/" . $this->article['id'] . ".art"; $article = fopen($path, "r"); echo "<div style='text-align:left'>"; if (!$article) { echo "Prazdy clanok"; } else { while (!feof($article)) { echo fgets($article); } fclose($article); } echo "</div>"; }