read()) { if($entry <> ".." && $entry <> ".") { $extension = explode(".",strtolower($entry)); if(count($extension) == 1) $extension = ""; else $extension = array_pop($extension); if(in_array($extension,$extension_list) || $filter == '') { $result[$i]['filename'] = $entry; $result[$i]['used'] = 0; $i++; } } } sort ($result); $d->close(); return $result; } /** * @autor Stefan Nebenführ | Matoma Internet Consulting GmbH * @copyright Matoma Internet Consulting GmbH * @access public * @desc Liefert alle dynamischen Marker als Array */ function getDynMarkers() { include("main.inc.php"); $result = array(); $i = 0; // dynamische Marker $dyn_markers = $_DB->query("SELECT Id, name, description, category_Id FROM dynamic_markers ORDER BY category_Id, name"); if (!$dyn_markers) { die('Ungültige Abfrage: ' . $_DB->_db->error); } while($row = $_DB->fetch_array($dyn_markers)) { $result[$i]['id'] = $row[0]; $result[$i]['title'] = $row[1]; $result[$i]['description'] = $row[2]; $result[$i]['category'] = $row[3]; $i++; } //arsort($result, SORT_NUMERIC); return $result; } /** * @autor Stefan Nebenführ | Matoma Internet Consulting GmbH * @copyright Matoma Internet Consulting GmbH * @access public * @desc Liefert alle dynamischen Marker als Array */ function getListMarkers() { global $_DB; $result = array(); $i = 0; // dynamische Marker $dyn_markers = $_DB->query("SELECT Id, name, description, category_Id FROM dynamic_markers WHERE t3id IS NULL ORDER BY category_Id, name"); if (!$dyn_markers) { die('Ungültige Abfrage: ' . $_DB->_db->error); } while($row = $_DB->fetch_array($dyn_markers)) { $result[$i]['id'] = $row[0]; $result[$i]['title'] = $row[1]; $result[$i]['description'] = $row[2]; $result[$i]['category'] = $row[3]; $i++; } //arsort($result, SORT_NUMERIC); return $result; } /** * @autor Stefan Nebenführ | Matoma Internet Consulting GmbH * @copyright Matoma Internet Consulting GmbH * @access public * @desc Liefert einen bestimmten Marker als assoziatives Array zurück */ function getMarker($mid) { include("main.inc.php"); $result = array(); // dynamischer Marker $marker = $_DB->query("SELECT * FROM dynamic_markers WHERE Id= $mid AND t3id IS NULL"); if (!$marker) { die('Ungültige Abfrage: ' . $_DB->_db->error); } $row = $_DB->fetch_array($marker); $result['id'] = $row[0]; $result['name'] = $row[1]; $result['cat_id'] = $row[2]; $result['description'] = $row[3]; $result['pic'] = $row[4]; $result['file'] = $row[5]; $result['hyper'] = $row[6]; $result['lat'] = $row[7]; $result['lng'] = $row[8]; return $result; } /** * @autor Stefan Nebenführ | Matoma Internet Consulting GmbH * @copyright Matoma Internet Consulting GmbH * @access public * @desc Loescht eine bestimmten Marker */ function deleteMarker($mid) { include("main.inc.php"); $result = FALSE; // dynamischen Marker löschen $marker = $_DB->query("DELETE FROM dynamic_markers WHERE Id = $mid"); if (!$marker) { die('Ungültige Abfrage: ' . $_DB->_db->error); } return $result; } /** * @autor Stefan Nebenführ | Matoma Internet Consulting GmbH * @copyright Matoma Internet Consulting GmbH * @access public * @desc Liefert alle Wurzelkategorien als Array */ function getCategories() { include("main.inc.php"); $result = array(); $_DB1 = new db_mysql($connect_profile); $_DB1->connect(); $i = 0; // Kategorien $categories = $_DB->query("SELECT Id, name, level, parent, REPLACE(REPLACE( REPLACE( REPLACE( REPLACE( REPLACE( REPLACE( REPLACE(name, 'Ä', 'A'), 'Ö', 'O'), 'Ãœ', 'U'), 'Ü', 'U'), 'ä', 'a'), 'ö', 'o'), 'ü','u'), 'ß', 's') AS sortiert FROM kategorien WHERE level = 0 ORDER BY sortiert"); if (!$categories) { die('Ungültige Abfrage: ' . $_DB->_db->error); } while($row = $_DB->fetch_array($categories)) { $markers = $_DB1->query("SELECT path FROM marker_types WHERE category_Id =" . $row[0]); if(!$markers) { die('Ungültige Abfrage: ' . $_DB->_db->error); } else { $row1 = $_DB1->fetch_array($markers); } $result[$i]['id'] = $row[0]; $result[$i]['title'] = $row[1]; $result[$i]['level'] = $row[2]; $result[$i]['parent'] = $row[3]; $result[$i]['marker'] = $row1[0]; $i++; } //arsort($result, SORT_NUMERIC); return $result; } /** * @autor Stefan Nebenführ | Matoma Internet Consulting GmbH * @copyright Matoma Internet Consulting GmbH * @access public * @desc Liefert alle Unterkategorien als Array einer bestimmten Kategorie */ function getSubCategories($catid) { include("main.inc.php"); $result = array(); $i = 0; // Kategorien $categories = $_DB->query("SELECT Id, name, level, parent, REPLACE(REPLACE( REPLACE( REPLACE( REPLACE( REPLACE( REPLACE( REPLACE(name, 'Ä', 'A'), 'Ö', 'O'), 'Ãœ', 'U'), 'Ü', 'U'), 'ä', 'a'), 'ö', 'o'), 'ü','u'), 'ß', 's') AS sortiert FROM kategorien WHERE level = 1 AND parent = $catid ORDER BY sortiert"); if (!$categories) { die('Ungültige Abfrage: ' . $_DB->_db->error); } while($row = $_DB->fetch_array($categories)) { $result[$i]['id'] = $row[0]; $result[$i]['title'] = $row[1]; $result[$i]['level'] = $row[2]; $result[$i]['parent'] = $row[3]; $i++; } //arsort($result, SORT_NUMERIC); return $result; } /** * @autor Stefan Nebenführ | Matoma Internet Consulting GmbH * @copyright Matoma Internet Consulting GmbH * @access public * @desc Liefert alle Kategorien als Array */ function getAllCategories() { include("main.inc.php"); $result = array(); $_DB1 = new db_mysql($connect_profile); $_DB1->connect(); $i = 0; // Kategorien $categories = $_DB->query("SELECT Id, name, level, parent, REPLACE(REPLACE( REPLACE( REPLACE( REPLACE( REPLACE( REPLACE( REPLACE(name, 'Ä', 'A'), 'Ö', 'O'), 'Ãœ', 'U'), 'Ü', 'U'), 'ä', 'a'), 'ö', 'o'), 'ü','u'), 'ß', 's') AS sortiert FROM kategorien WHERE t3cat=0 ORDER BY sortiert"); if (!$categories) { die('Ungültige Abfrage: ' . $_DB->_db->error); } while($row = $_DB->fetch_array($categories)) { $markers = $_DB1->query("SELECT path FROM marker_types WHERE category_Id =" . $row[0]); if(!$markers) { die('Ungültige Abfrage: ' . $_DB->_db->error); } else { $row1 = $_DB1->fetch_array($markers); } $result[$i]['id'] = $row[0]; $result[$i]['title'] = $row[1]; $i++; } //arsort($result, SORT_NUMERIC); return $result; } /** * @autor Stefan Nebenführ | Matoma Internet Consulting GmbH * @copyright Matoma Internet Consulting GmbH * @access public * @desc Liefert eine bestimmte Kategorie zurück */ function getCategory($cid) { include("main.inc.php"); $result = array(); // Kategorie $category = $_DB->query("SELECT Id, name, level, parent FROM kategorien WHERE Id = $cid"); if (!$category) { die('Ungültige Abfrage Kategorie: ' . $_DB->_db->error); } $row = $_DB->fetch_array($category); $result['id'] = $row[0]; $result['name'] = $row[1]; $result['level'] = $row[2]; $result['parent'] = $row[3]; return $result; } /** * @autor Stefan Nebenführ | Matoma Internet Consulting GmbH * @copyright Matoma Internet Consulting GmbH * @access public * @desc Liefert eine bestimmte Markertyp zurück */ function getMarkerType($cid) { include("main.inc.php"); $_DB1 = new db_mysql($connect_profile); $_DB1->connect(); $result = array(); $mt = ""; // Marker_Type $mtype = $_DB->query("SELECT Id, path FROM marker_types WHERE category_Id = $cid"); if (!$mtype) { die('Ungültige Abfrage mt: ' . $_DB->_db->error); } $row = $_DB->fetch_array($mtype); if(is_null($row)){ $par_cat_sql = $_DB->query("SELECT parent FROM kategorien WHERE Id = $cid"); if (!$par_cat_sql) { die('Ungültige Abfrage mt: ' . $_DB->_db->error); } $row = $_DB->fetch_array($par_cat_sql); $result = getMarkerType($row[0]); } else { $mt = "
"; $result['mt'] = $mt; $result['id'] = $row[0]; $result['path'] = $row[1]; } return $result; } /** * @autor Stefan Nebenführ | Matoma Internet Consulting GmbH * @copyright Matoma Internet Consulting GmbH * @access public * @desc Liefert alle freien Markertypen zurück */ function getFreeMarkerTypes($cid) { include("main.inc.php"); // Marker_Types $mtype = $_DB->query("SELECT Id, path FROM marker_types WHERE category_Id = $cid"); if (!$mtype) { die('Ungültige Abfrage mts: ' . $_DB->_db->error); } $mt = ""; while($row = $_DB->fetch_array($mtype)){ $mt .= "
"; } return $mt; } /** * @autor Stefan Nebenführ | Matoma Internet Consulting GmbH * @copyright Matoma Internet Consulting GmbH * @access public * @desc Loescht eine bestimmte Kategorie und ihre Unterkategorien */ function deleteCategory($cat_id) { include("main.inc.php"); $result = FALSE; // Kategorie löschen $categories = $_DB->query("DELETE FROM kategorien WHERE Id=$cat_id"); if (!$categories) { die('Ungültige Abfrage: ' . $_DB->_db->error); } else { // Unterkategorien ermitteln $subcategories = $_DB->query("Select Id FROM kategorien WHERE parent=$cat_id"); if(!$subcategories){ die('Ungültige Abfrage: ' . $_DB->_db->error); } else{ while($row = $_DB->fetch_array($subcategories)){ // Unterkategorie löschen $subc = $_DB->query("DELETE FROM kategorien WHERE Id=$row[0]"); if(!$subc){ die('Ungültige Abfrage: ' . $_DB->_db->error); } else{ // dynamische Marker der Unterkategorie löschen $dyn_markers_sub = $_DB->query("DELETE FROM dynamic_markers WHERE category_Id=$row[0]"); if (!$dyn_markers_sub) { die('Ungültige Abfrage: ' . $_DB->_db->error); } } } } // dynamische Marker löschen $dyn_markers = $_DB->query("DELETE FROM dynamic_markers WHERE category_Id=$cat_id"); if (!$dyn_markers) { die('Ungültige Abfrage: ' . $_DB->_db->error); } else { // dynamische Marker löschen $dyn_markers = $_DB->query("UPDATE marker_types SET category_Id=0 WHERE category_Id=$cat_id"); if (!$dyn_markers) { die('Ungültige Abfrage: ' . $_DB->_db->error); } } } return $result; } /** * @autor Wladimir Golwich | Matoma Internet Consulting GmbH * @copyright Matoma Internet Consulting GmbH * @access public * @desc Loescht eine hochgeladene Ressource wieder * @param string $file Name der Datei, die geloescht werden soll * @return bool Ergenbis Loesch-Operation */ function deleteFile($file) { $result = FALSE; if(file_exists($file)) { exec('chmod 777 '.$file); $result = unlink($file); } return $result; } /** * @autor Wladimir Golwich | Matoma Internet Consulting GmbH * @copyright Matoma Internet Consulting GmbH * @access public * @desc Laedt eine hochgeladene Datei in Ressourcen-Ordner * @return bool Ergenbis Upload-Operation */ function uploadFile() { global $_CONST; /** * * @var string Pfad zum Default-Uploadverzeichnis + Tempname der Datei */ $userfile = $_FILES["userfile"]["tmp_name"]; /** * * @var string Ursprunglicher Name der Datei */ $userfile_name = $_FILES["userfile"]["name"]; /** * * @var string Mime-Typ der Datei */ $userfile_type = $_FILES["userfile"]["type"]; /** * * @var integer Groesse der Datei */ $userfile_size = $_FILES["userfile"]["size"]; $result = FALSE; // locale setzen um Umlaute zu erkennen. //setlocale(LC_CTYPE,"de_DE"); $umlaute = array( "ä" => "ae", "ö" => "oe", "ü" => "ue" ); if($userfile != "none" && !empty($userfile)) { $userfile_name = strtolower($userfile_name); // ALLE Umlaute umwandeln (auch doppelte): while(strpos($userfile_name,"ä") OR strpos($userfile_name,"ö") OR strpos($userfile_name,"ü")) { $userfile_name = strtr($userfile_name,$umlaute); } if(file_exists($_CONST['PATH']['ressources_files'] . "/" . $userfile_name)) { $userfile_name = date("d-m-Y_H-i") . "_" . $userfile_name; } $result = copy($userfile, $_CONST['PATH']['ressources_files'] . "/" . $userfile_name); } return $result; } /** * @autor Wladimir Golwich | Matoma Internet Consulting GmbH * @copyright Matoma Internet Consulting GmbH * @access public * @desc Laedt eine hochgeladene Datei in Ressourcen-Ordner * @return bool Ergenbis Upload-Operation */ function uploadImage() { global $_CONST; /** * * @var string Pfad zum Default-Uploadverzeichnis + Tempname der Datei */ $userfile = $_FILES["userfile"]["tmp_name"]; /** * * @var string Ursprunglicher Name der Datei */ $userfile_name = $_FILES["userfile"]["name"]; /** * * @var string Mime-Typ der Datei */ $userfile_type = $_FILES["userfile"]["type"]; /** * * @var integer Groesse der Datei */ $userfile_size = $_FILES["userfile"]["size"]; $result = FALSE; // locale setzen um Umlaute zu erkennen. //setlocale(LC_CTYPE,"de_DE"); $umlaute = array( "ä" => "ae", "ö" => "oe", "ü" => "ue" ); if($userfile != "none" && !empty($userfile)) { $userfile_name = strtolower($userfile_name); // ALLE Umlaute umwandeln (auch doppelte): while(strpos($userfile_name,"ä") OR strpos($userfile_name,"ö") OR strpos($userfile_name,"ü")) { $userfile_name = strtr($userfile_name,$umlaute); } if(file_exists($_CONST['PATH']['ressources_physical'] . "/" . $userfile_name)) { $userfile_name = date("d-m-Y_H-i") . "_" . $userfile_name; } $result = copy($userfile, $_CONST['PATH']['ressources_physical'] . "/" . $userfile_name); } return $result; } /** * @autor Stefan Nebenführ | Matoma Internet Consulting GmbH * @copyright Matoma Internet Consulting GmbH * @access public * @desc Liefert alle angelegten Strecken als Array */ function getAllLines() { include("main.inc.php"); $result = array(); $i = 0; // Strecken $lines = $_DB->query("SELECT `Id`, `title`, `desc`, `pic_path`, `hyperlink`, `content_url`, REPLACE(REPLACE( REPLACE( REPLACE( REPLACE( REPLACE( REPLACE( REPLACE(`title`, 'Ä', 'A'), 'Ö', 'O'), 'Ãœ', 'U'), 'Ü', 'U'), 'ä', 'a'), 'ö', 'o'), 'ü','u'), 'ß', 's') AS sortiert FROM strecken ORDER BY sortiert"); if (!$lines) { die('Ungültige Abfrage: ' . $_DB->_db->error); } while($row = $_DB->fetch_array($lines)) { $result[$i]['id'] = $row[0]; $result[$i]['title'] = $row[1]; $result[$i]['description'] = $row[2]; $result[$i]['pic'] = $row[3]; $result[$i]['hyper'] = $row[4]; $result[$i]['content_url'] = $row[5]; $i++; } return $result; } /** * @autor Stefan Nebenführ | Matoma Internet Consulting GmbH * @copyright Matoma Internet Consulting GmbH * @access public * @desc Liefert eine bestimmte Strecke als assoziatives Array zurück */ function getLine($lid) { include("main.inc.php"); $result = array(); // Strecke $line = $_DB->query("SELECT * FROM strecken WHERE `Id`= $lid"); if (!$line) { die('Ungültige Abfrage: ' . $_DB->_db->error); } $row = $_DB->fetch_array($line); $result['id'] = $row[0]; $result['title'] = $row[1]; $result['description'] = $row[2]; $result['pic'] = $row[3]; $result['hyper'] = $row[4]; $result['content_url'] = $row[5]; $result['elevation_up'] = $row[6]; $result['elevation_down'] = $row[7]; $result['distance'] = $row[8]; return $result; } /** * @autor Stefan Nebenführ | Matoma Internet Consulting GmbH * @copyright Matoma Internet Consulting GmbH * @access public * @desc Liefert die Streckenpunkte einer bestimmten Strecke als String zurück */ function getLinePointsString($lid) { include("main.inc.php"); $result = ""; // Strecke $line = $_DB->query("SELECT `lat`, `lng` FROM streckenpunkte WHERE `strecken_id`= $lid ORDER BY `point_number` ASC"); if (!$line) { die('Ungültige Abfrage: ' . $_DB->_db->error); } while($row = $_DB->fetch_array($line)) { $result .= $row[0] . ", " . $row[1] . ";"; } $laenge = strlen($result)-1; $result = substr($result, 0, $laenge); return $result; } /** * @autor Stefan Nebenführ | Matoma Internet Consulting GmbH * @copyright Matoma Internet Consulting GmbH * @access public * @desc Loescht eine bestimmte Strecke sowie deren Streckenpunkte */ function deleteLine($lid) { include("main.inc.php"); $_DB1 = new db_mysql($connect_profile); $_DB1->connect(); $result = FALSE; // Strecke löschen $line = $_DB->query("DELETE FROM strecken WHERE `Id`=$lid"); if (!$line) { die('Fehler beim Löschen der Strecke: ' . $_DB->_db->error); } else { // Streckenpunkte ermitteln $line_points = $_DB->query("Select Id FROM streckenpunkte WHERE strecken_id=$lid"); if(!$line_points){ die('Ungültige Abfrage: ' . $_DB->_db->error); } else{ while($row = $_DB->fetch_array($line_points)){ // Streckenpunkt löschen $lp = $_DB1->query("DELETE FROM streckenpunkte WHERE `Id`=$row[0]"); if(!$lp){ die('Fehler beim Löschen des Streckenpunktes: ' . $_DB->_db->error); } } } } return $result; } /** * @autor Stefan Nebenführ | Matoma Internet Consulting GmbH * @copyright Matoma Internet Consulting GmbH * @access public * @desc Erstellt eine GPX-Datei aus den übergebenen Streckenpunkten */ function createGPX($title, $line_points) { include("main.inc.php"); $filename = $_CONST['PATH']['ressources_gpx'] . $title . ".gpx"; $content = ''; $content .= 'Etappe ' . $title . ''; for($i=0;$i < count($line_points); $i++){ $newLinepoint = array(); $newLinepoint = explode(",", str_replace(' ', '', $line_points[$i])); $lat = (double)$newLinepoint[0]; $lng = (double)$newLinepoint[1]; $content .= ''; } $content .= ''; $file_handle = fopen($filename,'wb'); fwrite($file_handle,$content,strlen($content)); fclose($file_handle); } // Funktionen zum Erstellen des Höhenprofils /** * @autor Stefan Nebenführ | Matoma Internet Consulting GmbH * @copyright Matoma Internet Consulting GmbH * @access public * @desc Erzeugt einen Graphen aus den übergebenen Arrays */ function createGraph($xdata, $ydata, $lid){ include ("jpgraph/src/jpgraph.php"); include ("jpgraph/src/jpgraph_line.php"); $picpath = "../graph_files/" . $lid . ".png"; //if(!file_exists($picpath)){ // Grafik generieren und Grafiktyp festlegen $graph = new Graph(620,200,"auto"); $graph->SetScale("linlin"); $lineplot=new LinePlot($ydata, $xdata); // Die Linien zu der Grafik hinzufügen $graph->Add($lineplot); // Grafik Formatieren $graph->img->SetMargin(60,20,20,50); $graph->xaxis->title->Set("Strecke in km"); $graph->yaxis->title->Set("Höhenmeter"); $graph->yaxis->title->SetFont(FF_VERA,FS_BOLD); $graph->yaxis->title->SetMargin(20); $graph->xaxis->title->SetFont(FF_VERA,FS_BOLD); $graph->xaxis->title->SetMargin(15); $graph->SetFrame(false); $lineplot->SetColor("red"); $lineplot->SetWeight(2); // Grafik anzeigen $graph->Stroke($picpath); //} $picpath = substr($picpath, 3); return $picpath; } /** * @autor Stefan Nebenführ | Matoma Internet Consulting GmbH * @copyright Matoma Internet Consulting GmbH * @access public * @desc - Sammelt nötige Daten aus der Datenbank * - Berechnet Höhenmeter (up, down) * - Berechnet die Gesamtdistanz */ function getGraphData($lid){ include("main.inc.php"); $alti = array(); $dist_array = array(); $result = array(); $max_alti = 0; $min_alti = 0; $count = 0; $htemp = 0; $hup = 0; $hdown = 0; $xtemp = 0; $ytemp = 0; $i = 0; $sp_sql = "SELECT `lat`, `lng`, `altitude` FROM streckenpunkte WHERE `strecken_id`=$lid ORDER BY `strecken_id`, `point_number` ASC"; $sp_handle = $_DB->query($sp_sql); if($sp_handle != true){ die("Fehler: " . $_DB->_db->error); } //echo '
';
                                
        while($row = $_DB->fetch_array($sp_handle))
        {       
                if($i == 0){                
                    $count = 0; 
                    $min_alti = $row[2];
                    $htemp = $row[2];       
                }else{
                    $count += getDistance($xtemp, $ytemp, $row[0], $row[1]);                
                }
                                                
                $dist_array[$i] = round($count / 1000, 2);  
                        
                $xtemp = $row[0];
                $ytemp = $row[1];   
                                                                        
                $alti[$i] = $row[2];
                                
                // Ermittlung der maximalen Höhe
                if($row[2] > $max_alti)
                    $max_alti = $row[2];
                    
                // Ermittlung der minimalen Höhe
                if($row[2] < $min_alti)
                    $min_alti = $row[2];    
                                
                // Berechnung der zurückgelegten Höhenmeter 
                if($htemp < $row[2]){
                    $hup += ($row[2] - $htemp);
                }else if($htemp > $row[2]){
                    $hdown += ($htemp - $row[2]);
                }
                            
                $htemp = $row[2];                           
                    
                //print_r($row[2] . ' : ' . $hup . ' : ' . $hdown . ' : ' . $max_alti . '
'); $i++; } //exit; $result['path'] = createGraph($dist_array, $alti, $lid); $result['up'] = $hup; $result['down'] = $hdown; $result['distance'] = $dist_array[count($dist_array)-1]; $result['max_altitude'] = $max_alti; $result['min_altitude'] = $min_alti; return $result; } /** * @autor Stefan Nebenführ | Matoma Internet Consulting GmbH * @copyright Matoma Internet Consulting GmbH * @access public * @desc Liefert die Entfernung zwischen zwei Punkten */ function getDistance($x1, $y1, $x2, $y2){ if(($x1 == $x2) && ($y1 == $y2)){ return 0.00; }else{ // Umrechnung ins Bogenmaß $x1=($x1 / 180) * pi(); $x2=($x2 / 180) * pi(); $y1=($y1 / 180) * pi(); $y2=($y2 / 180) * pi(); // Berechnung der Entfernung in km $entfernung = acos(sin($x1) * sin($x2) + cos($x1) * cos($x2) * cos($y1 - $y2)) * 6370; // Entfernung in m zurückgeben return round($entfernung * 1000, 2); } } /** * @autor Stefan Nebenführ | Matoma Internet Consulting GmbH * @copyright Matoma Internet Consulting GmbH * @access public * @desc Liefert die Höhenmeter */ function getAltitude($lat, $lng) { usleep(500000); $data = file_get_contents("http://maps.google.com/maps/api/elevation/xml?locations=" . $lat . "," . $lng . "&sensor=false"); $data = trim(strip_tags($data)); $data = explode(" ", $data); $result = floatval(substr($data[13], 0 , stripos($data[13], '.')+3)); return $result; } /** * @autor Stefan Nebenführ | Matoma Internet Consulting GmbH * @copyright Matoma Internet Consulting GmbH * @access public * @desc inserts a new chronik marker * @return bool Ergenbis Insert-Operation */ function insertChronikMarker($data) { global $_DB; $sql = 'INSERT INTO chronik_marker (Id, name, period_id, lat, lng, image, email) VALUES(NULL,"' . $data["title"] . '",' . $data["period"] . ', ' . $data["lat"] . ',' . $data["lng"] . ', "' . $data["image"] . '","' . $data["email"] . '")'; $cmarker = $_DB->query($sql); if (!$cmarker) { die('Ungültige Abfrage mts: ' . $_DB->_db->error); }else { return true; } return false; } /** * @autor Stefan Nebenführ | Matoma Internet Consulting GmbH * @copyright Matoma Internet Consulting GmbH * @access public * @desc Liefert die Epoche */ function getEpoche($epid) { global $_EPOCHE; $result = ""; $result = $_EPOCHE[$epid]; return $result; } /** * @autor Stefan Nebenführ | Matoma Internet Consulting GmbH * @copyright Matoma Internet Consulting GmbH * @access public * @desc Liefert den Marker mit der uebergebenen ID */ function getChronikMarker($cmid) { global $_DB; $result = array(); $sql = 'SELECT * FROM chronik_marker WHERE Id = ' . $cmid; if(!is_null($period_id)) $sql .= ' and period_Id =' . $period_id; $cmarker = $_DB->query($sql); if (!$cmarker) { die('Ungültige Abfrage mts: ' . $_DB->_db->error); } $row = $_DB->fetch_array($cmarker); $result['id'] = $row[0]; $result['name'] = $row[1]; $result['epoche'] = getEpoche($row[2]); $result['lat'] = $row[3]; $result['lng'] = $row[4]; $result['image'] = $row[5]; return $result; } /** * @autor Stefan Nebenführ | Matoma Internet Consulting GmbH * @copyright Matoma Internet Consulting GmbH * @access public * @desc Liefert die Marker zu einer bestimmten Chronik Periode */ function getChronikMarkers($validated, $period_id = null) { global $_DB; $valid = $validated ? 1 : 0; $result = array(); $i = 0; $sql = 'SELECT * FROM chronik_marker WHERE validated = ' . $valid; if(!is_null($period_id)) $sql .= ' and period_Id =' . $period_id; $cmarker = $_DB->query($sql); if (!$cmarker) { die('Ungültige Abfrage mts: ' . $_DB->_db->error); } while($row = $_DB->fetch_array($cmarker)){ $result[$i]['id'] = $row[0]; $result[$i]['name'] = $row[1]; $result[$i]['epoche'] = getEpoche($row[2]); $result[$i]['lat'] = $row[3]; $result[$i]['lng'] = $row[4]; $result[$i]['image'] = $row[5]; $result[$i]['email'] = $row[6]; $i++; } return $result; } /** * @autor Stefan Nebenführ | Matoma Internet Consulting GmbH * @copyright Matoma Internet Consulting GmbH * @access public * @desc Gibt eine bestimmten Marker frei * @param $cmid Marker-ID */ function approveChronikMarker($cmid) { global $_DB; $result = false; $sql = 'UPDATE chronik_marker SET validated=1 WHERE Id=' . $cmid; // approve chronik marker $chronik_marker = $_DB->query($sql); if (!$chronik_marker) { die('Ungültige Abfrage: ' . $_DB->_db->error); } else { $result = true; } return $result; } /** * @autor Stefan Nebenführ | Matoma Internet Consulting GmbH * @copyright Matoma Internet Consulting GmbH * @access public * @desc Loescht eine bestimmten Marker */ function deleteChronikMarker($cmid) { global $_DB; global $_CONST; $result = false; // get chronik marker $cmarker = getChronikMarker($cmid); // delete images deleteFile($_CONST['PATH']['ressources_chronik_images_physical'] . "/" . $cmarker["image"]); deleteFile($_CONST['PATH']['ressources_chronik_thumbs_physical'] . "/" . $cmarker["image"]); // delete chronik marker $chronik_marker = $_DB->query("DELETE FROM chronik_marker WHERE Id = $cmid"); if (!$chronik_marker) { die('Ungültige Abfrage: ' . $_DB->_db->error); } else { $result = true; } return $result; } /** * @autor Stefan Nebenführ | Matoma Internet Consulting GmbH * @copyright Matoma Internet Consulting GmbH * @access public * @desc Laedt eine hochgeladene Datei in Ressourcen-Ordner * @param Files array * @return bool Ergenbis Upload-Operation */ function uploadChronikImage($files) { global $_CONST; /** * * @var string Pfad zum Default-Uploadverzeichnis + Tempname der Datei */ $userfile = $files["upload"]["tmp_name"]; /** * * @var string Ursprunglicher Name der Datei */ $userfile_name = $files["upload"]["name"]; /** * * @var string Mime-Typ der Datei */ $userfile_type = $files["upload"]["type"]; /** * * @var integer Groesse der Datei */ $userfile_size = $files["upload"]["size"]; $result = FALSE; // locale setzen um Umlaute zu erkennen. //setlocale(LC_CTYPE,"de_DE"); $umlaute = array( "ä" => "ae", "ö" => "oe", "ü" => "ue" ); if($userfile != "none" && !empty($userfile) && substr($userfile_type,0,5) === 'image') { $userfile_name = strtolower($userfile_name); // ALLE Umlaute umwandeln (auch doppelte): while(strpos($userfile_name,"ä") OR strpos($userfile_name,"ö") OR strpos($userfile_name,"ü")) { $userfile_name = strtr($userfile_name,$umlaute); } if(file_exists($_CONST['PATH']['ressources_chronik_images_physical'] . "/" . $userfile_name)) { $userfile_name = date("d-m-Y_H-i") . "_" . $userfile_name; } $result = copy($userfile, $_CONST['PATH']['ressources_chronik_images_physical'] . "/" . $userfile_name); // generate thumb param array $params = array('sid' => 5, 'spath' => $_CONST['PATH']['ressources_chronik_images_physical'], 'sfile' => $userfile_name); generateChronikThumb($params); return $userfile_name; } else { header('Status: 415 Unsupported Media Type'); die('Die hochgeladene Datei ist kein Bild!'); } } /** * @autor Stefan Nebenführ | Matoma Internet Consulting GmbH * @copyright Matoma Internet Consulting GmbH * @access public * @desc Erzeugt ein Thumbnail * @param Files array * @return thumbnail */ function generateChronikThumb($params) { global $_CONST; // Array mit Größen-Konstanten. $size_constants = array(0 => array('width' => $picinfos[0], 'height' => $picinfos[1]), 1 => array('width' => 100, 'height' => 100), 2 => array('width' => 125, 'height' => 125), 3 => array('width' => 170, 'height' => 170), 4 => array('width' => 75, 'height' => 75), 5 => array('width' => 50, 'height' => 50), 6 => array('width' => 400, 'height' => 400)); // Größen ID $sID = (isset($params['sid'])) ? (int)$params['sid'] : 0; $origimg = $params['spath'] . '/' . $params['sfile']; // Ermitteln des Dateinamens. $base_name = basename($origimg); if($base_name != $params['sfile']) $base_name = $params['sfile']; // Ermitteln des Dateipfads $dir_name = dirname($origimg); //First of all..grab some image infos $picinfos = getimagesize($origimg); //Imagetype ermitteln $imageType = @exif_imagetype($origimg); $imageType = !empty($imageType) ? $imageType : null; if(!file_exists($_CONST['PATH']['ressources_chronik_thumbs_physical'] . '/' . $base_name)){ //Create an new image from the old one if($imageType == IMAGETYPE_PNG) $oldpic = ImageCreateFromPNG($origimg); else if($imageType == IMAGETYPE_JPEG) $oldpic = ImageCreateFromJPEG($origimg); else if($imageType == IMAGETYPE_GIF) $oldpic = ImageCreateFromGIF($origimg); //Check which site is bigger, and calculate the factor to resize if($picinfos[0] > $picinfos[1]){ $factor = $size_constants[$sID]['width'] / $picinfos[0]; } else{ $factor = $size_constants[$sID]['height'] / $picinfos[1]; } //calculate new sizes $new_width= round($picinfos[0] * $factor); $new_height= round($picinfos[1] * $factor); //Create an new blank image with new sizes $newpic = imagecreatetruecolor($new_width, $new_height); $weiss = imagecolorallocate($newpic, 255, 255, 255); imagefill($newpic, 0, 0, $weiss); //Copy resized old pic into new pic imagecopyresampled($newpic,$oldpic,0,0,0,0,$new_width,$new_height,$picinfos[0],$picinfos[1]); //Create an new blank frame image $frame_image=imagecreatetruecolor($size_constants[$sID]['width'], $size_constants[$sID]['height']); imagefill($frame_image, 0, 0, $weiss); // Berechnung der exakten Position zur Zentrierung des skalierten Bildes innerhalb des frame images. if($picinfos[0] > $picinfos[1]){ $x_pos = 0; $y_pos = round(($size_constants[$sID]['height'] - $new_height) / 2); } else{ $x_pos = round(($size_constants[$sID]['width'] - $new_width) / 2); $y_pos = 0; } // Copy and merge imagecopymerge($frame_image, $newpic, $x_pos, $y_pos, 0, 0, $new_width, $new_height, 100); // Image-Datei erzeugen. imagejpeg($frame_image, $_CONST['PATH']['ressources_chronik_thumbs_physical'] . '/' . $base_name); imagedestroy($newpic); imagedestroy($frame_image); return $_CONST['PATH']['ressources_chronik_thumbs_physical'] . '/' . $base_name; }else{ return $_CONST['PATH']['ressources_chronik_thumbs_physical'] . '/' . $base_name; } } /** * @autor Stefan Nebenführ | Matoma Internet Consulting GmbH * @copyright Matoma Internet Consulting GmbH * @access public * @desc Verschickt eine Benachrichtigungsmail */ function sendMail() { global $_CONST; global $_SMARTY; $OB = '----=_OuterBoundary_000'; $IB = '----=_InnerBoundery_001'; $eol = "\n"; $tab = "\t"; $subject = "Chronikbild freigeben"; $email = $_CONST['MAIL']['to']; $message = $_SMARTY->fetch("mail.tpl"); // Header $headers = 'MIME-Version: 1.0' . $eol; $headers .= 'From: ' . $_CONST['MAIL']['from'] . $eol; $headers .= 'Reply-To: ' . $_CONST['MAIL']['reply_to'] . $eol; $headers .= 'Content-Type: multipart/mixed;' . $eol . $tab . 'boundary="' . $OB . '"' . $eol; // Standartnachricht an alte ARPA mail programme $msg = 'This is a multi-part message in MIME format.' . $eol; $msg .= $eol . '--' . $OB . $eol; $msg .= 'Content-Type: multipart/alternative;' . $eol . $tab . 'boundary="' . $IB . '"' . $eol . $eol; // plaintext section $msg .= $eol . '--' . $IB . $eol; $msg .= 'Content-Type: text/html;' . $eol . $tab . 'charset="utf-8"' . $eol; $msg .= 'Content-Transfer-Encoding: quoted-printable' . $eol . $eol; $msg .= $message . $eol . $eol; // Hier endet die Nachrichtentextsektion, unten dran befindet sich das Attachment. $msg .= $eol . '--' . $IB . '--' . $eol; // Jede E-Mail hat irgendwo mal ein Ende. $msg .= $eol . '--' . $OB . '--' . $eol; mail($email, $subject, $msg, $headers); } ?>_db = NULL; $this->_rs = NULL; $this->_server = $connect_profile['server']; $this->_uid = $connect_profile['uid']; $this->_pwd = $connect_profile['pwd']; $this->_db_name = $connect_profile['db']; } ################ Public-Methodes ################## /******************************************************************* * Method: connect() * Description: connect to DB * Arguments: string with connection-argumets * Returns: bool *******************************************************************/ public function connect() { $this->_db = new mysqli($this->_server, $this->_uid, $this->_pwd, $this->_db_name); if($this->_db->errno) { echo $this->_db->error; return false; } $this->_db->set_charset('utf8'); return true; } /** * @return bool * @param $sql string SQL-Query * @desc Execute the sql-query */ public function query($sql) { if(!is_resource($this->_db)) { $this->connect(); } if($this->_rs = $this->_db->query($sql)) { return true; } echo $this->_db->error; return false; } /******************************************************************* * Method: num_rows() * Description: number of affected rows by last sql-query * Arguments: sql-statement as string * Returns: int/FALSE *******************************************************************/ public function num_rows() { if($this->_rs) { return($this->_rs->num_rows); } echo $this->_db->error; return false; } /******************************************************************* * Method: fetch_array() * Description: return one record * Arguments: - * Returns: array/FALSE *******************************************************************/ public function fetch_array() { if($this->_rs && ($row = $this->_rs->fetch_array())) { return $row; }; return NULL; } /******************************************************************* * Method: fetch_assoc() * Description: return one record * Arguments: - * Returns: array/FALSE *******************************************************************/ public function fetch_assoc() { if($this->_rs && ($row = $this->_rs->fetch_assoc())) { return $row; }; return NULL; } /** * @return mixed * @desc Returns all rows of SQL-statment as array */ public function records_array() { $return_value = array(); if($this->_rs) { while($row = $this->_rs->fetch_assoc()) { $return_value[] = $row; } } return $return_value; } /******************************************************************* * Method: close() * Description: close the connection to DB * Arguments: - * Returns: bool *******************************************************************/ public function close() { if($this->_db->close()) { return true; } echo $this->_db->error; return false; } /******************************************************************* * Method: get_insert_id() * Description: close the connection to DB * Arguments: - * Returns: ressource *******************************************************************/ public function get_insert_id() { return $this->_db->insert_id; } ################ Private-Methodes ################## }