Example #1
0
 public function __construct($source = null, Kommun $kommun)
 {
     $this->setKommun($kommun);
     if ($source) {
         Security::demand(EDITOR);
         parent::__construct($source);
         if ($this->getStorlek() > self::MAX_SIZE) {
             throw new KommunkartaException("Filen är för stor", -1);
         }
         $this->approve(KOMMUN_IMAGES_PATH . "/temp");
         $this->setNamn($this->kommunToNamn());
     } else {
         try {
             parent::__construct(null, $this->kommunToPath());
         } catch (FilException $e) {
             if ($e->getCode() == -1) {
                 throw new KommunkartaException("Kommunen har ingen karta", -2);
             }
         }
     }
 }
Example #2
0
 public function delete()
 {
     Security::demand(USER, $this->getMedlem());
     parent::delete();
 }
Example #3
0
 public static function refreshCache()
 {
     Misc::logMotiomera("Start RSSHandler::refreshCache() ", 'info');
     $rss = new lastRSS();
     $rss->cache_dir = '';
     $rss->cache_time = 0;
     $rss->CDATA = "content";
     /*
     		if (file_exists(ROOT . self::CACHE_PATH . "/rss.php")) {
     			include (ROOT . self::CACHE_PATH . "/rss.php");
     		}
     */
     //krillo
     echo "************* refreshCache lastRSS: ";
     print_r($rss);
     if ($rs = $rss->get(self::RSS_URL)) {
         //krillo
         echo "************* refreshCache : inne i loopen   if (rs = rss->get(self::RSS_URL) \n";
         $cache = "<?php \n\n // Skapad " . date("Y-m-d H:i:s") . "\n\n" . '$rss_cache = array();' . "\n";
         $i = 0;
         //krillo
         echo "************* refreshCache : param rs \n";
         print_r($rs);
         foreach ($rs["items"] as $row) {
             if ($i < self::MAX_ARTICLES) {
                 //krillo
                 echo "****************** refreshCache item {$i} loopen ****************\n";
                 print_r($row);
                 $tmp = split("<br>", $row["description"]);
                 $tmp2 = split('"', $tmp[1]);
                 $img = $tmp2[1];
                 $tmpsource = array(" ", "å", "ä", "ö", "Å", "Ä", "Ö");
                 $tmpreplace = array("%20", "%E5", "%E4", "%F6", "%C5", "%C4", "%D6");
                 $img = str_replace($tmpsource, $tmpreplace, $img);
                 $cache .= '$rss_cache[' . $i . ']["title"] = "' . htmlspecialchars($row["title"]) . '";' . "\n";
                 //remove &nbsp;
                 $tmp[0] = str_replace("&nbsp;", "", $tmp[0]);
                 $cache .= '$rss_cache[' . $i . ']["description"] = "' . htmlspecialchars(strip_tags($tmp[0])) . '";' . "\n";
                 $cache .= '$rss_cache[' . $i . ']["img"] = "' . addslashes($img) . '";' . "\n";
                 $cache .= '$rss_cache[' . $i . ']["link"] = "' . (isset($row["link"]) ? $row["link"] : 'default.html') . '";' . "\n";
                 //krillo
                 echo "rawurlencode(img): " . rawurlencode($img) . '<br>';
                 if (!isset($rss_cache) || $img != $rss_cache[$i]["img"]) {
                     // hämta bild
                     //krillo
                     echo "hämta bild";
                     if ($f = curl_init($img)) {
                         curl_setopt($f, CURLOPT_RETURNTRANSFER, true);
                         curl_setopt($f, CURLOPT_HEADER, 0);
                         $bild = curl_exec($f);
                     }
                     $fil = fopen(ROOT . self::CACHE_PATH . "/{$i}.jpg", 'w');
                     fwrite($fil, $bild);
                     fclose($fil);
                     $bild = new Bild(null, ROOT . self::CACHE_PATH . "/{$i}.jpg");
                     $bild->resize(self::IMG_WIDTH, self::IMG_HEIGHT);
                     $image = imagecreatetruecolor(126, 95);
                     $bg = imagecreatefromjpeg(ROOT . self::CACHE_PATH . "/{$i}.jpg");
                     $overlay = imagecreatefrompng(ROOT . self::CACHE_PATH . "/mask.png");
                     imagecopy($image, $bg, 0, 0, 0, 0, 126, 95);
                     imagecopy($image, $overlay, 0, 0, 0, 0, 126, 95);
                     imagejpeg($image, ROOT . self::CACHE_PATH . "/{$i}.jpg", 90);
                 }
             }
             $i++;
         }
         $cache .= "?>";
         if (!($file = @fopen(ROOT . self::CACHE_PATH . "/rss.php", 'w'))) {
             Misc::logMotiomera("Cache-filen is not writable ", 'error');
             throw new RSSHandlerException("Cache-filen är inte skrivbar", -3);
         }
         fwrite($file, $cache);
         fclose($file);
     } else {
         Misc::logMotiomera("Could not get the RSS from " . self::RSS_URL, 'error');
     }
     Misc::logMotiomera("End RSSHandler::refreshCache() ", 'info');
 }
Example #4
0
 public function setBild(Bild $bild)
 {
     Security::demand(KOMMUN, $this->getKommun());
     $this->bild = $bild;
     $bild->approve($this->getImgPath());
 }
Example #5
0
 }
 if (isset($_POST['googlename'])) {
     $googlename = $_POST['googlename'];
 }
 if (isset($_POST['abroad'])) {
     $abroad = 'true';
 } else {
     $abroad = 'false';
 }
 if (empty($_GET["id"])) {
     if (isset($_POST["sameort"])) {
         $_POST["ort"] = $_POST["namn"];
     }
     $kommun = new Kommun($_POST["namn"], $_POST["ort"], $_POST["areal"], $_POST["folkmangd"], $_POST["webb"], $_POST["info"], $framsidebildAuto, $abroad, $googlename);
     if (isset($_FILES["some_name"]) && $_FILES["some_name"]["tmp_name"]) {
         $bild = new Bild($_FILES["some_name"]);
         $bild->approve(ROOT . "/staticroute/abroad_" . $kommun->getId() . "jpg");
     }
 } else {
     $kommun = Kommun::loadById($_GET["id"]);
     if ($ADMIN->getTyp() != "kommun") {
         $kommun->setNamn($_POST["namn"]);
         $kommun->setOrt($_POST["ort"]);
         $kommun->setKod($kod);
         $kommun->setLan($_POST["lan"]);
     }
     $kommun->setAreal($_POST["areal"]);
     $kommun->setFolkmangd($_POST["folkmangd"]);
     $kommun->setWebb($_POST["webb"]);
     $kommun->setInfo($_POST["info"]);
     $kommun->setGoogleName($googlename);
Example #6
0
 public function getThumb()
 {
     parent::getThumb();
     if (@(!file($this->kommunToThumbPath()))) {
         $this->resizeNyFil($this->kommunToThumbPath(), self::THUMB_WIDTH, self::THUMB_HEIGHT);
     }
     return $this->kommunToThumbNamn();
 }
Example #7
0
 public function setBild(Bild $bild)
 {
     $this->bildUrl = $bild->getNamn();
 }
Example #8
0
 public function delete()
 {
     Security::demand(ADMIN);
     parent::delete();
 }
Example #9
0
 public static function listByMedlem(Medlem $medlem)
 {
     return parent::lister(get_class(), "medlem_id", $medlem->getId());
 }