xx 0) { continue; } //skip day marker events
$time = makeHovT($evt);
$chBox = '';
if ($evt['cbx']) {
$chBox .= cMark($evt,$date) ? $evt['cmk'] : '☐';
$chBox = "{$chBox}";
}
if (strlen($evtBody) > 0) {
$popText = "
";
if ($evtBody == '0') {
$popText .= "".($chBox.$time ? "{$chBox}{$time}
" : '')."{$evt['tit']}";
} else {
$popText .= "{$chBox}{$time} {$evt['tit']}
".makeE($evt,$evtBody,'br',"
");
}
$popText = htmlspecialchars(addslashes($popText),ENT_QUOTES).'
';
$popClass = ($evt['mde'] or $evt['r_t']) ? 'repeat' : 'normal';
$popAttr = " onmouseover='pop(this,`{$popText}`,`{$popClass}`,30)'";
} else {
$popAttr = '';
}
$bgColor = $evt['cbg'] ? " style='background-color:{$evt['cbg']};'" : '';
if ($ef2Jump and preg_match('%https?://[^"\'\s]+%i',$evt['tx3'],$match)) {
$onClick = " onclick='newWindow(`{$match[0]}`); event.stopPropagation();'"; //jump to URL in extra field 2
} elseif ($evtWin) {
$onClick = " onclick='".($evt['mayE'] ? 'editE' : 'showE')."({$evt['eid']},`{$date}`,`{$calID}`); event.stopPropagation();'"; //view or post/edit
} else {
$onClick = '';
}
$class = $evt['sym'] ? 'symbol' : 'square';
echo "{$evt['sym']}\n";
}
}
function intersect($str1,$str2) {
if ($str1 == '0') { return $str2; }
return implode(',',array_intersect(explode(',',$str1),explode(',',$str2)));
}
/***** MAIN PROGRAM *****/
//sanity check
if (isset($_GET['oM']) and !preg_match('%^(-\d{1,2}|\d{0,2})$%', $_GET['oM'])) { exit('not permitted ('.substr(basename(__FILE__),0,-4).')'); } //invalid argument
//error_reporting(E_ERROR); //errors only
error_reporting(E_ALL); //errors, warnings and notices - test line
require './lcconfig.php'; //calendar config data
require './common/toolbox.php'; //load tools
require './common/toolboxd.php'; //database tools
require './common/retrieve.php'; //get retrieve function
//init
$calPath = rtrim(dirname($_SERVER["PHP_SELF"]),'/').'/';
session_set_cookie_params(1440,$calPath); //set cookie path
//load display configuration
if (isset($_GET['cnf'])) { //sanitize GET params
$cnf = sanitize($_GET['cnf']);
}
if (!empty($cnf) and file_exists("./configs/{$cnf}.cnf")) { //specified
include "./configs/{$cnf}.cnf";
} elseif (file_exists("./configs/".basename(__FILE__,'.php').".cnf")) { //default
include "./configs/".basename(__FILE__,'.php').".cnf";
}
if (empty($calID)) { $calID = $dbDef; } //select calendar
$dbH = dbConnect($calID); //connect to database
$set = getSettings(); //get settings from db
date_default_timezone_set($set['timeZone']); //set time zone
header("Cache-control: private"); //proxies: don't cache
require './lang/ai-'.strtolower($set['language']).'.php'; //get ai texts
session_name('PHPSESSID'); //session cookie name
session_start(); //for security when going to full calendar
//get user ID
$opt = loadLastSel(); //load uID, if saved - default: public user
$uID = substr($opt['uI'],1);
$msg = $un_em = ''; //init
if (!empty($_POST['logX'])) { //log-in mode
$logX = $_POST['logX'][0];
$un_em = sanitize($_POST['un_em'] ?? '');
$pword = sanitize($_POST['pword'] ?? '');
if ($logX == 'w') { //login form
$msg = $logMsg;
} elseif ($logX == 'o') { //log out button pressed
$uID = 1; //public user
$opt['uI'] = '01';
saveLastSel($opt);
} elseif ($logX == 'i') { //logging in: validate form
if (!$un_em) { $msg = $ax['log_no_un_em']; goto end; }
if (!$pword) { $msg = $ax['log_no_pw']; goto end; }
$md5Pw = md5($pword);
$stH = stPrep("SELECT `ID` FROM `users` WHERE (`name` = ? OR `email` = ?) AND (`password` = ? OR `tPassword` = ?) AND `status` >= 0");
stExec($stH,[$un_em,$un_em,$md5Pw,$md5Pw]);
$row = $stH->fetch(PDO::FETCH_ASSOC); //fetch user details
$stH = null;
if (!$row) { $msg = $ax['log_un_em_pw_invalid']; goto end; }
$uID = $row['ID'];
$opt['uI'] = $opt['uI'][0].strval($uID); //preserve bake/eat digit
saveLastSel($opt);
end: //watch out for the T-rex
}
}
//get user credentials
$stH = dbQuery("SELECT u.`ID`, u.`name`, u.`language`, g.`ID` as gID, g.`privs`, g.`vCatIDs` as vCats, g.`eCatIDs` as eCats FROM `users` AS u INNER JOIN `groups` AS g ON g.`ID` = u.`groupID` WHERE u.`ID` = {$uID}");
$usr = $stH->fetch(PDO::FETCH_ASSOC); //user & group data
$stH = null;
require './lang/ui-'.strtolower($usr['language'] ?: $set['language']).'.php'; //get ui texts
if (!$msg and !$usr['privs']) {
$msg = $logMsg; //login form
}
$evtList = []; //init
if (!$msg) { //read access: get events
if ($usr['privs'] > 1) { $_SESSION[$calID]['uid'] = $uID; } //uid for index.php when editE
//compute dates
$offM = $_GET['oM'] ?? 0; //offset Month
$timeD1 = mktime(12,0,0,date('n')+$offM,1,date('Y')); //time 1st day
$dateD1 = date("Y-m-d", $timeD1); //date 1st day
$curM = date("n",$timeD1);
$curY = date("Y",$timeD1);
$sOffset = ($set['weekStart']) ? date("N", $timeD1) - 1 : date("w", $timeD1); //offset first day
$eOffset = date("t", $timeD1) + $sOffset; //offset last day
$daysToShow = ($eOffset == 28) ? 28 : (($eOffset > 35) ? 42 : 35); //4, 5 or 6 weeks
$fDate = date("Y-m-d", $timeD1 - ($sOffset * 86400)); //start date in 1st week
$tDate = date("Y-m-d", $timeD1 + ($daysToShow - $sOffset - 1) * 86400); //end date in last week
//set filter and retrieve events
$cats = str_replace(' ','',$cats); //remove spaces
if (isset($_GET['cats'])) {
$getCats = sanitize($_GET['cats']);
}
if (!empty($getCats)) {
$urlCats = preg_replace_callback('~(,?)([^,]+)(,?)~', function ($m) { return $m[1].intval($m[2]).$m[3]; }, $getCats); //sanitize
$cats = intersect($cats,$urlCats); //intersection of $cats and URL cats
}
$usr['vCats'] = intersect($usr['vCats'],$cats);
$filter = ($users == 'own') ? " AND e.`userID` = {$uID}" : ($users ? " AND e.`userID` IN ({$users})" : '');
$filter .= ($groups == 'own') ? " AND g.`ID` = {$usr['gID']}" : ($groups ? " AND g.`ID` IN ({$groups})" : '');
if ($venue) { $filter .= " AND e.`venue` LIKE '%{$venue}%'"; }
if ($filter) { $filter = substr($filter,5); }
retrieve($fDate,$tDate,'',$filter,'*');
}
?>
\n";
$calH = (5 * (int)$HDCEL) + (2 * (int)$HWDAY) + 20;
echo "\n";
echo "
\n";
echo "{$msg}
\n";
echo "\n\n";
} else { //calendar
//display header
if ($fullCal) {
echo "{$xx['vws_click_for_full']}
\n";
}
echo "\n";
if ($pdfBut) { //load PDF dialog
$pdfJson = json_encode(['calID' => $calID, 'uID' => $uID, 'users' => $users, 'groups' => $groups, 'cats' => $cats, 'venue' => $venue, 'pdfCnf' => $pdfCnf]); //json encode object
echo "
";
}
//display month
$days = $wkDays ? '1234567' : $set['workWeekDays']; //set days to show
$cWidth = round(98 / strlen($days),1).'%';
echo "
\n";
for ($i = 0; $i < 7; $i++) {
$cTime = mktime(12,0,0,$curM,$i-$sOffset+1,$curY ); //current time
if (strpos($days,date("N",$cTime)) !== false) { echo "| {$wkDays_s[$set['weekStart'] + $i]} | "; } //week days
}
echo "
\n";
for ($i = 0; $i < $daysToShow; $i++) {
$cTime = mktime(12,0,0,$curM,$i-$sOffset+1,$curY ); //current time
$cDate = date("Y-m-d", $cTime);
if ($i%7 == 0) { //new week
echo "\n";
}
$dayNr = date("N", $cTime);
if (strpos($days,$dayNr) !== false) {
$dow = ($i < $sOffset or $i >= $eOffset) ? 'out' : (($dayNr > 5) ? 'we0' : 'wd0');
if ($cDate == date("Y-m-d")) { $dow .= ' today'; }
$day = ltrim(substr($cDate, 8, 2),"0");
$dayBg = $hdrCol = $hdrTxt = '';
$curSeq = 0;
if (!empty($evtList[$cDate])) {
foreach ($evtList[$cDate] as $evt) { //check if day background should be set
if (($evt['dbg'] & 1) and $evt['seq'] > $curSeq) {
$dayBg = " style='background:{$evt['cbg']}'";
$curSeq = $evt['seq'];
}
if ($evt['typ'] == 1) {
$hdrTxt = strip_tags($evt['tit']);
$hdrCol = " style='background:{$evt['tx3']};'";
}
}
}
$title = $hdrTxt ? " title='{$hdrTxt}'" : '';
$tdAttrib = ($evtWin and $usr['privs'] > 1) ? "class='{$dow}' onclick='newE(`{$cDate}`); event.stopPropagation();'" : "class='{$dow}'";
echo "| \n {$day} \n";
if (!empty($evtList[$cDate])) { showEvents($cDate); }
echo " | \n";
}
if ($i%7 == 6) { echo "
\n"; } //if last day of week, wrap to left
}
echo "\n|
RSS
\n";
if ($offM != 0) { echo "{$xx['vws_today']}\n"; }
echo " | \n
\n
\n";
}
?>