= strlen($s) ? $s : ($s{$n+$x} == " " ? substr($s,0,$n+$x) . "..." : "")); if ( $o != "" ) { return $o; } } } function bbcode($s) { $string = nl2br($s); // // [b]...[/b] //$string = preg_replace("~\[b\](.*)\[/b\]~Uis","[b]\\1[/b]",$string); // // [i]...[/i] //$string = preg_replace("~\[i\](.*)\[/i\]~Uis","[i]\\1[/i]",$string); // // [u]...[/u] // $string = preg_replace("~\[u\](.*)\[/u\]~Uis","\\1",$string); return $string; } function linkss($s) { $p[] = '"(( |^)((ftp|http|https){1}://)[-a-zA-Z0-9@:%_\+.~#?&//=]+)"i'; $r[] = '\\1'; $p[] = '"( |^)(www.[-a-zA-Z0-9@:%_\+.~#?&//=]+)"i'; $r[] = '\\1\\2'; $p[] = '"([_\.0-9a-z-]+@([0-9a-z][0-9a-z-]+\.)+[a-z]{2,3})"i'; $r[] = '\\1'; $s = preg_replace($p, $r, $s); return $s; } function bcode($s) { $string = $s; // [b]...[/b] $string = preg_replace("~\[b\](.*)\[/b\]~Uis","\\1",$string); // [i]...[/i] $string = preg_replace("~\[i\](.*)\[/i\]~Uis","\\1",$string); // [u]...[/u] $string = preg_replace("~\[u\](.*)\[/u\]~Uis","\\1",$string); return nl2br($string); } function wordsubstr200($s) { $n = 200; for ( $x = 0; $x < strlen($s); $x++ ) { $o = ($n+$x >= strlen($s) ? $s : ($s{$n+$x} == " " ? substr($s,0,$n+$x) . "..." : "")); if ( $o != "" ) { return $o; } } } function map25link($name, $steet, $pcode, $city, $desc){ return "http://link2.map24.com/?lid=b8e0e7f6&maptype=JAVA&width0=2000&street0=".urlencode ($steet)."&zip0=".urlencode ($pcode)."&city0=".urlencode ($city)."&state0=&country0=DE&logo_url0=&name0=".urlencode ($name)."&description0=".urlencode ($desc); } function match_email ($input){ return preg_match("#^[a-z0-9.!\#$%&\'*+-/=?^_`{|}~]+@([0-9.]+|([^\s]+\.+[a-z]{2,4}))$#si", $input); } function optimise_html($tpl_source, &$smarty) { $tpl_source = preg_replace("/\n/"," ",$tpl_source); $tpl_source = preg_replace("/\f/"," ",$tpl_source); $tpl_source = preg_replace("/\r/"," ",$tpl_source); $tpl_source = preg_replace("/\t+/"," ",$tpl_source); $tpl_source = preg_replace("/ +/"," ",$tpl_source); $tpl_source = preg_replace("/-->/","\x1B",$tpl_source); $tpl_source = preg_replace("/ $src_size[1]) { $xScale = floor($yScale * $src_size[0] / $src_size[1]); }else if($src_size[1] > $src_size[0]) { $yScale = floor($xScale * $src_size[1] / $src_size[0]); } $src_x=$src_size[0]; $src_y=$src_size[1]; $dst_img = imagecreatetruecolor($xScale, $yScale); imagecopyresampled($dst_img, $src_img, 0, 0, 0, 0, $xScale, $yScale, imagesx($src_img), imagesy($src_img)); imagejpeg($dst_img, $target, $compression); chmod($target, 644); } ?> * @package heidekreis */ class Calendar { var $time; var $date; var $daytime; /* The start day of the week. This is the day that appears in the first column of the calendar. Sunday = 0. */ var $startDay = 1; /* The start month of the year. This is the month that appears in the first slot of the calendar in the year view. January = 1. */ var $startMonth = 1; /* The labels to display for the days of the week. The first entry in this array represents Sunday. */ var $dayNames = array("so", "mo", "di", "mi", "do", "fr", "sa"); /* The labels to display for the months of the year. The first entry in this array represents January. */ var $monthNames = array("Januar", "Februar", "März", "April", "Mai", "Juni", "Juli", "August", "September", "Oktober", "November", "Dezember"); /* The number of days in each month. You're unlikely to want to change this... The first entry in this array represents January. */ var $daysInMonth = array(31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31); function Calendar () { $this->time = time(); $this->date = date("d.m.Y"); $this->daytime = date("H:i:s"); } /* * Gibt die angegebene Monat in Deustch zurück * @param integer $month 1 - 12 Monat * @return string den Monat */ function get_monthname ($month){ $demonth = array(); $demonth[1] = "Januar"; $demonth[2] = "Februar"; $demonth[3] = "März"; $demonth[4] = "April"; $demonth[5] = "Mai"; $demonth[6] = "Juni"; $demonth[7] = "Juli"; $demonth[8] = "August"; $demonth[9] = "September"; $demonth[10] = "Oktober"; $demonth[11] = "November"; $demonth[12] = "Dezember"; return $demonth[$month]; } /* Get the array of strings used to label the days of the week. This array contains seven elements, one for each day of the week. The first entry in this array represents Sunday. */ function getDayNames() { return $this->dayNames; } /* Set the array of strings used to label the days of the week. This array must contain seven elements, one for each day of the week. The first entry in this array represents Sunday. */ function setDayNames($names) { $this->dayNames = $names; } /* Get the array of strings used to label the months of the year. This array contains twelve elements, one for each month of the year. The first entry in this array represents January. */ function getMonthNames() { return $this->monthNames; } /* Set the array of strings used to label the months of the year. This array must contain twelve elements, one for each month of the year. The first entry in this array represents January. */ function setMonthNames($names) { $this->monthNames = $names; } /* Gets the start day of the week. This is the day that appears in the first column of the calendar. Sunday = 0. */ function getStartDay() { return $this->startDay; } /* Sets the start day of the week. This is the day that appears in the first column of the calendar. Sunday = 0. */ function setStartDay($day) { $this->startDay = $day; } /* Gets the start month of the year. This is the month that appears first in the year view. January = 1. */ function getStartMonth() { return $this->startMonth; } /* Sets the start month of the year. This is the month that appears first in the year view. January = 1. */ function setStartMonth($month) { $this->startMonth = $month; } /* Return the URL to link to in order to display a calendar for a given month/year. You must override this method if you want to activate the "forward" and "back" feature of the calendar. Note: If you return an empty string from this function, no navigation link will be displayed. This is the default behaviour. If the calendar is being displayed in "year" view, $month will be set to zero. */ function getCalendarLink($month, $year) { global $s; return "/index.php?s=monthview&calmonth=$month&calyear=$year&category=".$_GET['category']; } /* Return the URL to link to for a given date. You must override this method if you want to activate the date linking feature of the calendar. Note: If you return an empty string from this function, no navigation link will be displayed. This is the default behaviour. */ function getDateLink($day, $month, $year) { global $s; return "/index.php?s=dayview&calday=$day&calmonth=$month&calyear=$year&category=".$_GET['category']; } function getWeekLink($day, $month, $year, $week) { global $s; return "/index.php?s=weekview&calday=$day&calmonth=$month&calyear=$year&calweek=$week&category=".$_GET['category']; } /* Return the HTML for the current month */ function getCurrentMonthView() { $d = getdate(time()); return $this->getMonthView($d["mon"], $d["year"]); } /* Return the HTML for the current year */ function getCurrentYearView() { $d = getdate(time()); return $this->getYearView($d["year"]); } /* Return the HTML for a specified month */ function getMonthView($month, $year) { return $this->getMonthHTML($month, $year); } /* Return the HTML for a specified year */ function getYearView($year) { return $this->getYearHTML($year); } /******************************************************************************** The rest are private methods. No user-servicable parts inside. You shouldn't need to call any of these functions directly. *********************************************************************************/ /* Calculate the number of days in a month, taking into account leap years. */ function getDaysInMonth($month, $year) { if ($month < 1 || $month > 12) { return 0; } $d = $this->daysInMonth[$month - 1]; if ($month == 2) { // Check for leap year // Forget the 4000 rule, I doubt I'll be around then... if ($year%4 == 0) { if ($year%100 == 0) { if ($year%400 == 0) { $d = 29; } } else { $d = 29; } } } return $d; } /* Generate the HTML for a given month */ function getMonthHTML($m, $y, $showYear = 1) { global $mysql; $s = ""; $a = $this->adjustDate($m, $y); $month = $a[0]; $year = $a[1]; // calculate Weeks in year $firstDay = getdate(mktime(12, 0, 0, 1, 1, $year)); if($firstDay['wday'] < 4 ){ // monday $WeeksInYear = 52; }else{ $WeeksInYear = 53; } $daysInMonth = $this->getDaysInMonth($month, $year); $date = getdate(mktime(12, 0, 0, $month, 1, $year)); $first = $date["wday"]; $monthName = $this->monthNames[$month - 1]; $prev = $this->adjustDate($month - 1, $year); $next = $this->adjustDate($month + 1, $year); if ($showYear == 1) { $prevMonth = $this->getCalendarLink($prev[0], $prev[1]); $nextMonth = $this->getCalendarLink($next[0], $next[1]); } else { $prevMonth = ""; $nextMonth = ""; } $header = "".$monthName . (($showYear > 0) ? " " . $year . "" : ""); $s .= "
\n"; $s .= "\n"; $s .= "\n"; $s .= "\n"; $s .= "\n"; $s .= "\n"; $s .= "\n"; $s .= "\n"; $s .= "\n"; $s .= "\n"; $s .= "\n"; $s .= "\n"; $s .= "\n"; $s .= "\n"; $s .= "\n"; $s .= "\n"; // We need to work out what date to start at so that the first appears in the correct column $d = $this->startDay + 1 - $first; $day = 1; while ($d > 1) { $d -= 7; } // Make sure we know when today is, so that we can use a different CSS style $today = getdate(time()); while ($d <= $daysInMonth) { $week = date("W", gmmktime(12, 0, 0, $month, $day, $year)); $s .= "\n"; for ($i = 0; $i < 7; $i++) { $sqleventcat = "select *, date_format(event_date_start, 'Beginn am %d.%m.%Y um %H:%i Uhr') as startdate,date_format(event_date_end, 'Ende am %d.%m.%Y um %H:%i Uhr') as enddate from he_event, he_association left join he_evant_area on event_area_id = he_evant_area.event_area_id where he_event.association_id = he_association.association_id and he_event.event_type_id = '".$r['event_type_id']."'"; if(strlen($today["mon"])==1) { $today["mon"]="0".$today["mon"]; } $sqleventcat .= " and YEAR(event_date_start) <= '".$today["year"]."' and '".$today["year"]."' <= YEAR(event_date_end)"; $sqleventcat .= " and MONTH(event_date_start) <= '".$today["mon"]."' and '".$today["mon"]."' <= MONTH(event_date_end)"; $datumss = $today['year']."-".$today['mon']."-".$today["mday"]; $sqleventcat .= " and DAYOFYEAR(event_date_start) <= DAYOFYEAR('".$datumss."') and DAYOFYEAR('".$datumss."') <= DAYOFYEAR(event_date_end)"; $sqleventcat .= " order by event_date_start ASC "; $idevent = $mysql->query($sqleventcat); $re = $mysql->fassoc($idevent); $class = ($year == $today["year"] && $month == $today["mon"] && $d == $today["mday"]) ? "calendarToday" : "calendar"; if($re) { $class="calenderYes";} $s .= "\n"; $d++; // real monthdays for Week if($d > 1){ $day++; } } $s .= "\n"; $s .= "\n"; } $s .= "
" . (($prevMonth == "") ? " " : "<<") . "$header" . (($nextMonth == "") ? " " : ">>") . "
" . $this->dayNames[($this->startDay)%7] . "" . $this->dayNames[($this->startDay+1)%7] . "" . $this->dayNames[($this->startDay+2)%7] . "" . $this->dayNames[($this->startDay+3)%7] . "" . $this->dayNames[($this->startDay+4)%7] . "" . $this->dayNames[($this->startDay+5)%7] . "" . $this->dayNames[($this->startDay+6)%7] . "kw
"; if ($d > 0 && $d <= $daysInMonth) { $link = $this->getDateLink($d, $month, $year); $s .=(($link == "") ? $d : "$d"); } else { $s .= " "; } $s .= "getWeekLink($d, $month, $year, $week)."\">$week
\n"; return $s; } /* Generate the HTML for a given year */ function getYearHTML($year) { $s = ""; $prev = $this->getCalendarLink(0, $year - 1); $next = $this->getCalendarLink(0, $year + 1); $s .= "\n"; $s .= ""; $s .= "\n"; $s .= "\n"; $s .= "\n"; $s .= "\n"; $s .= ""; $s .= "\n"; $s .= "\n"; $s .= "\n"; $s .= "\n"; $s .= "\n"; $s .= "\n"; $s .= "\n"; $s .= "\n"; $s .= "\n"; $s .= "\n"; $s .= "\n"; $s .= "\n"; $s .= "\n"; $s .= "\n"; $s .= "\n"; $s .= "\n"; $s .= "\n"; $s .= "\n"; $s .= "\n"; $s .= "
" . (($prev == "") ? " " : "<< vorheriges Jahr") . "" . (($this->startMonth > 1) ? $year . " - " . ($year + 1) : $year) ."" . (($next == "") ? " " : "nächstes Jahr >>") . "
" . $this->getMonthHTML(0 + $this->startMonth, $year, 0) ."" . $this->getMonthHTML(1 + $this->startMonth, $year, 0) ."" . $this->getMonthHTML(2 + $this->startMonth, $year, 0) ."
" . $this->getMonthHTML(3 + $this->startMonth, $year, 0) ."" . $this->getMonthHTML(4 + $this->startMonth, $year, 0) ."" . $this->getMonthHTML(5 + $this->startMonth, $year, 0) ."
" . $this->getMonthHTML(6 + $this->startMonth, $year, 0) ."" . $this->getMonthHTML(7 + $this->startMonth, $year, 0) ."" . $this->getMonthHTML(8 + $this->startMonth, $year, 0) ."
" . $this->getMonthHTML(9 + $this->startMonth, $year, 0) ."" . $this->getMonthHTML(10 + $this->startMonth, $year, 0) ."" . $this->getMonthHTML(11 + $this->startMonth, $year, 0) ."
\n"; return $s; } /* Adjust dates to allow months > 12 and < 0. Just adjust the years appropriately. e.g. Month 14 of the year 2001 is actually month 2 of year 2002. */ function adjustDate($month, $year) { $a = array(); $a[0] = $month; $a[1] = $year; while ($a[0] > 12) { $a[0] -= 12; $a[1]++; } while ($a[0] <= 0) { $a[0] += 12; $a[1]--; } return $a; } } ?>mysql = $mysql; if($id){ $this->id = $id; } } function add ($asc, $logo = NULL, $logo_filename = NULL) { if(file_exists($logo)){ $filename = $this->new_logo($logo, $logo_filename); } $sql = "insert into he_association (association_name, association_kontact, association_desc, association_url, association_logo, association_public, association_nonprofit, association_pdf) values ('".$asc['association_name']."', '".$asc['association_kontact']."', '".$asc['association_desc']."', '".$asc['association_url']."', '".$filename."', '".$asc['association_public']."', '".$asc['association_nonprofit']."', '".$asc['association_pdf']."')"; $this->mysql->query($sql); $this->id = $this->mysql->insert_id(); return $this->id; } function new_logo($logo, $userfilename){ global $conf; $ex = explode(".", $userfilename); mt_srand((double)microtime()*1000000); $randval = mt_rand(); $logo_filename = "association_".$randval.".".$ex[1]; if($this->id){ $id = $this->mysql->query("select * from he_association where association_id = '".$this->id."'"); $rf = $this->mysql->fassoc($id); if(file_exists($conf['association_logo_path']."/".$rf['association_logo'])){ @unlink($conf['association_logo_path']."/".$rf['association_logo']); } } move_uploaded_file($logo, $conf['association_logo_path']."/".$logo_filename); chmod($conf['association_logo_path']."/".$logo_filename, 0644); return $logo_filename; } function new_pdf($pdf, $userfilename){ global $conf; $ex = explode(".", $userfilename); mt_srand((double)microtime()*1000000); $randval = mt_rand(); $pdf_filename = "association_".$randval.".".$ex[1]; if($this->id){ $id = $this->mysql->query("select * from he_association where association_id = '".$this->id."'"); $rf = $this->mysql->fassoc($id); if(file_exists($conf['association_pdf_path']."/".$rf['association_pdf'])){ @unlink($conf['association_pdf_path']."/".$rf['association_pdf']); } } move_uploaded_file($pdf, $conf['association_pdf_path']."/".$pdf_filename); chmod($conf['association_pdf_path']."/".$pdf_filename, 0644); return $pdf_filename; } function drop () { if($this->id){ // eventslöschen $id = $this->mysql->query("select * from he_event where association_id = '".$this->id."'"); while($re = $this->mysql->fassoc( $id )){ $this->mysql->query("delete from he_event_file where event_id = '".$re['event_id']."'"); $this->mysql->query("delete from he_event_stats where event_id = '".$re['event_id']."'"); } $this->mysql->query("delete from he_event where association_id = '".$this->id."'"); // eventslöschen $idu = $this->mysql->query("select user_id from he_user_association where association_id = '".$this->id."'"); $this->mysql->query("delete from he_user_association where association_id = '".$this->id."'"); $sql = "delete from he_association where association_id = '".$this->id."'"; $this->mysql->query($sql); if($this->mysql->affected() >= 1){ return true; }else{ return false; } }else{ return false; } } function update ($asc, $logo = NULL, $logo_filename = NULL, $pdf = NULL, $pdf_filename = NULL) { if($this->id){ if(file_exists($logo)){ $filename = $this->new_logo($logo, $logo_filename); } if(file_exists($pdf)){ $pdffilename = $this->new_pdf($pdf, $pdf_filename); } $sql = "update he_association set association_name='".$asc['association_name']."', association_kontact='".$asc['association_kontact']."', association_desc='".$asc['association_desc']."', association_url = '".$asc['association_url']."'"; if($filename){ $sql .= " , association_logo = '".$filename."' "; } if($pdffilename){ $sql .= " , association_pdf = '".$pdffilename."' "; } $sql .= " where association_id = '".$this->id."'"; $this->mysql->query($sql); if($this->mysql->affected() >= 1){ return true; }else{ return false; } }else{ return false; } } function update_admin ($asc, $logo = NULL, $logo_filename = NULL, $pdf = NULL, $pdf_filename = NULL) { if($this->id){ if(file_exists($logo)){ $filename = $this->new_logo($logo, $logo_filename); } if(file_exists($pdf)){ $pdffilename = $this->new_pdf($pdf, $pdf_filename); } $sql = "update he_association set association_nonprofit='".$asc['association_nonprofit']."', association_public='".$asc['association_public']."' ,association_name='".$asc['association_name']."', association_kontact='".$asc['association_kontact']."', association_desc='".$asc['association_desc']."', association_url = '".$asc['association_url']."'"; if($filename){ $sql .= " , association_logo = '".$filename."' "; } if($pdffilename){ $sql .= " , association_pdf = '".$pdffilename."' "; } $sql .= " where association_id = '".$this->id."'"; $this->mysql->query($sql); if($this->mysql->affected() >= 1){ return true; }else{ return false; } }else{ return false; } } } ?>mysql = $mysql; } function auth ($login, $passwd) { $sql = "select *, he_user.user_id as user_id from he_user left join he_user_association on he_user.user_id = he_user_association.user_id where he_user.user_login = '".$login."' and he_user.user_passwd = password('".$passwd."') group by he_user_association.user_association_id"; $id = $this->mysql->query($sql); if($this->mysql->num_rows($id) >=1){ while($r = $this->mysql->fassoc($id)) { // userinformations $this->login = $r['user_login']; $this->passwd = $r['user_passwd']; $this->email = $r['user_email']; $this->fname = $r['user_fname']; if(!$this->id)$this->id = $r['user_id']; $this->isadmin = $r['user_isadmin']; // rechte if($r['association_auth_add'] >= 1){ $this->auth_add[] = $r['association_id']; } if($r['association_auth_edit'] >= 1){ $this->auth_edit[] = $r['association_id']; } if($r['association_auth_user'] >= 1){ $this->auth_user[] = $r['association_id']; } } return true; }else{ return false; } } // 20130624: MiK function auth_umstellung ($login, $passwd) { $sql = "select *, he_user.user_id as user_id from he_user left join he_user_association on he_user.user_id = he_user_association.user_id where he_user.user_login = '".$login."' and he_user.user_passwd = '1234567890ABC' group by he_user_association.user_association_id"; $id = $this->mysql->query($sql); if($this->mysql->num_rows($id) >=1){ return true; }else{ return false; } } // legt einen user an function add ($usd, $admin = NULL) { $sql = "insert into he_user (user_login, user_passwd, user_fname, user_email, user_isadmin) values ('".$usd['user_login']."', password('".$usd['user_passwd']."'), '".$usd['user_fname']."', '".$usd['user_email']."', '".$usd['user_isadmin']."')"; $this->mysql->query($sql); $userid = $this->mysql->insert_id(); if($admin){ foreach($usd['member'] as $key => $ass){ if($ass == 1){ $sql2 = "insert into he_user_association (user_id, association_id, association_auth_add, association_auth_edit, association_auth_user) values ('".$userid."', '".$key."', '".$usd['auth_add'][$key]."', '".$usd['auth_edit'][$key]."', '".$usd['auth_user'][$key]."')"; $this->mysql->query($sql2); } } return true; }else{ $sql2 = "insert into he_user_association (user_id, association_id, association_auth_add, association_auth_edit, association_auth_user) values ('".$userid."', '".$usd['association_id']."','".$usd['auth_add']."', '".$usd['auth_edit']."', '".$usd['auth_user']."')"; $this->mysql->query($sql2); return true; } } function has_event_access($eventid){ foreach($this->auth_edit as $as){ $id = $this->mysql->query("select * from he_event where event_id = '".$eventid."' and association_id = '".$as."'"); if($r = $this->mysql->num_rows($id) >= 1){ return true; break; } } } function has_location_access($location){ foreach($this->auth_edit as $as){ $id = $this->mysql->query("select * from he_location where location_id = '".$eventid."' and association_id = '".$as."'"); if($r = $this->mysql->num_rows($id) >= 1){ return true; break; } } } // ändert einen user function update ($usd, $user_id, $admin = NULL) { $sql = "update he_user set " . " user_login='".$usd['user_login']."',"; if(!empty($usd['user_passwd'])){ $sql .= " user_passwd=password('".$usd['user_passwd']."'),"; } $sql .= " user_fname='".$usd['user_fname']."', user_email='".$usd['user_email']."', user_isadmin='".$usd['user_isadmin']."' where user_id = '".$user_id."'"; $this->mysql->query($sql); if($admin){ $this->mysql->query("delete from he_user_association where user_id = '".$user_id."'"); foreach($usd['member'] as $key => $ass){ if($ass == 1){ $sql2 = "insert into he_user_association (user_id, association_id, association_auth_add, association_auth_edit, association_auth_user) values ('".$user_id."', '".$key."', '".$usd['auth_add'][$key]."', '".$usd['auth_edit'][$key]."', '".$usd['auth_user'][$key]."')"; $this->mysql->query($sql2); } } return true; }else{ $this->mysql->query("update he_user_association set association_auth_add='".$usd['auth_add']."', association_auth_edit='".$usd['auth_edit']."', association_auth_user='".$usd['auth_user']."' where user_id = '".$user_id."' and association_id = '".$usd['association_id']."'"); } return true; } // löscht einen Benutzer function drop($userid) { $this->mysql->query("delete from he_user_association where user_id = '".$userid."'"); $this->mysql->query("delete from he_session where user_id = '".$userid."'"); $this->mysql->query("delete from he_user where user_id = '".$userid."'"); if($this->mysql->affected() >= 1){ return true; }else{ return false; } } } ?>