From dbc0d9614421e064cc62aacf116ebb783c83f2f3 Mon Sep 17 00:00:00 2001 From: Jonathan Bauer Date: Fri, 1 Apr 2016 16:50:13 +0200 Subject: [merge] merging c3sl / fr - initial commit --- modules/imgmanagement/module.inc.php | 76 ++++++++++++++++++++++++++++++++++++ 1 file changed, 76 insertions(+) create mode 100644 modules/imgmanagement/module.inc.php (limited to 'modules/imgmanagement/module.inc.php') diff --git a/modules/imgmanagement/module.inc.php b/modules/imgmanagement/module.inc.php new file mode 100644 index 00000000..27844e23 --- /dev/null +++ b/modules/imgmanagement/module.inc.php @@ -0,0 +1,76 @@ +baselocation = '/var/images/'; + $this->images = array(); + + error_reporting(E_ALL); + ini_set('display_errors','on'); + + Session::get('token'); + + } + + protected function doRender() + { + /*get city of user !!!!NOT TESTED!!!! + + $data=array( 'id'= User.getId()); + $res = Database::exec("SELECT cityid FROM user WHERE userid=:id",$data); + $cityid = $res->fetch(PDO::FETCH_ASSOC); + $res = Database::exec("SELECT name FROM cities WHERE cityid=:cityid",$cityid); + $city = $res->fetch(PDO::FETCH_ASSOC); + $location = $baselocation . $city; + + + verify type of vars (string concatenation and more) + !!!!NOT TESTED!!!! + */ + + error_reporting(E_ALL); + ini_set('display_errors','on'); + //Search images on location specified + $location = $this->baselocation . 'curitiba/*'; + //Gets the configuration of each image + $config = substr($location,0,-1).'config.json'; + $imgsactive = json_decode(file_get_contents($config),true); + $images = glob($location, GLOB_ONLYDIR); + $actives = array(); + $deactives= array(); + foreach($images as &$imgname){ + $imgname= substr($imgname, strlen($location)-1); + //fill associative array (img->active[true/false]) + $this->images[$imgname] = isset($imgsactive[$imgname])?$imgsactive[$imgname] : false; + if($this->images[$imgname]){ + array_push($actives, array('name' => $imgname)); + }else{ + array_push($deactives, array('name'=>$imgname)); + } + } + + //Save eventually new images to config.json + $fp = fopen($config,'w'); + fwrite($fp,json_encode($this->images)); + fclose($fp); + Render::addTemplate('page-imgmanagement', array( + 'deactives' => $deactives, + 'actives' => $actives)); + } +} -- cgit v1.2.3-55-g7522