{$ax['no_way']}
\n"; exit; } function buttonsValid($buttons,$range) { global $pSet; if (empty($buttons)) { return true; } foreach (explode(',',$buttons) as $buttonNr) { if (substr_count($buttons.',',$buttonNr.',') > 1 or strpos($range.',',$buttonNr.',') === false) { return false; } } return true; } function fieldsValid($fields,$range) { if (empty($fields)) { return false; } foreach (str_split($fields) as $fieldNr) { if (substr_count($range,$fieldNr) != 1) { return false; } } return true; } //set lcconfig params $calMenu = isset($_POST['calMenu']) ? $_POST['calMenu'] : 0; //calendar menu in Opt panel $cronHost = isset($_POST['cronHost']) ? $_POST['cronHost'] : $crHost; //cron service host $cronIpAd = isset($_POST['cronIpAd']) ? $_POST['cronIpAd'] : $crIpAd; //cron service Ip address if (isset($_POST["save"])) { //get posted settings foreach ($defSet as $key => $void) { if (!isset($_POST['pSet'][$key])) { $pSet[$key] = 0; //set unchecked check box to unchecked } else { $pSet[$key] = is_int($defSet[$key][0]) ? intval($_POST['pSet'][$key]) : trim($_POST['pSet'][$key]); //make int-strings integers } } } else { //get current settings foreach ($defSet as $key => $value) { $pSet[$key] = isset($set[$key]) ? $set[$key] : $value[0]; } } if (isset($_POST["mail"])) { //send test mail $msgBody = "{$ax['set_mail_sent_from']}.
"; $recipient = sendEml($ax['set_test_mail'],$msgBody,$pSet['calendarEmail'],1,0,0); $msg .= $ax['set_mail_sent_to'].' '.$recipient; } //preprocessing - comma separate $pSet['viewsPublic'] = trim(preg_replace('%(\d)(?!0|,|$)%',"$1,",$pSet['viewsPublic']),' ,'); $pSet['viewsLogged'] = trim(preg_replace('%(\d)(?!0|,|$)%',"$1,",$pSet['viewsLogged']),' ,'); $pSet['viewButsPub'] = trim(preg_replace('%(\d)(?!0|,|$)%',"$1,",$pSet['viewButsPub']),' ,'); $pSet['viewButsLog'] = trim(preg_replace('%(\d)(?!0|,|$)%',"$1,",$pSet['viewButsLog']),' ,'); $pSet['recipList'] = trim(preg_replace("%[\s\\\\<>]%",'',$pSet['recipList']),' ,;.'); $pSet['smsCountry'] = ltrim($pSet['smsCountry'],'+0'); $eClass = 'warning'; $errors = array_fill(0, 51, ''); $e = 0; //init if (isset($_POST["save"])) { //validate settings if (!$pSet['calendarTitle']) { $errors[$e] = ' class="inputError"'; } $e++; if (!$pSet['calendarUrl'] or !preg_match($rxCalURL,$pSet['calendarUrl'])) { $errors[$e] = " class='inputError'"; } $e++; if (substr($pSet['calendarUrl'],0,4) != 'http') { $pSet['calendarUrl'] = 'http://'.$pSet['calendarUrl']; } if (!$pSet['calendarEmail'] or !preg_match($rxEmailX, $pSet['calendarEmail'])) { $errors[$e] = " class='inputError'"; } $e++; //xxx if ($pSet['backLinkUrl'] and substr($pSet['backLinkUrl'],0,4) != 'http') { $pSet['backLinkUrl'] = 'http://'.$pSet['backLinkUrl']; } if (!$pSet['timeZone'] or !@date_default_timezone_set($pSet['timeZone'])) { $errors[$e] = " class='inputError'"; } $e++; if ($pSet['notifChange'] and !preg_match ('%^([^@;]+@[^@;]+?\.\w+;|\d{8,14};|\w+;)+$%',$pSet['recipList'].';')) { $errors[$e] = " class='inputError'"; } $e++; if (!preg_match ('%^(([1-9]|10),\s*)*([1-9]|10)$%',$pSet['viewsPublic'])) { $errors[$e] = " class='inputError'"; } $e++; if (!preg_match ('%^(([1-9]|10),\s*)*([1-9]|10)$%',$pSet['viewsLogged'])) { $errors[$e] = " class='inputError'"; } $e++; if (!buttonsValid($pSet['viewButsPub'],$pSet['viewsPublic'])) { $errors[$e] = " class='inputError'"; } $e++; if (!buttonsValid($pSet['viewButsLog'],$pSet['viewsLogged'])) { $errors[$e] = " class='inputError'"; } $e++; if (strpos($pSet['viewsPublic'].',',strval($pSet['defViewPub']).',') === false) { $errors[$e] = " class='inputError'"; } $e++; if (strpos($pSet['viewsLogged'].',',strval($pSet['defViewLog']).',') === false) { $errors[$e] = " class='inputError'"; } $e++; if ($pSet['cookieExp'] < 1 or $pSet['cookieExp'] > 365) { $errors[$e] = " class='inputError'"; } $e++; if (!fieldsValid($pSet['evtTemplGen'],' 12345678')) { $errors[$e] = " class='inputError'"; } $e++; if (!fieldsValid($pSet['evtTemplUpc'],' 12345678')) { $errors[$e] = " class='inputError'"; } $e++; if (!fieldsValid($pSet['evtTemplPop'],' 12345678')) { $errors[$e] = " class='inputError'"; } $e++; if ($pSet['yearStart'] < 0 or $pSet['yearStart'] > 12) { $errors[$e] = " class='inputError'"; } $e++; if ($pSet['YvRowsToShow'] < 1 or $pSet['YvRowsToShow'] > 10) { $errors[$e] = " class='inputError'"; } $e++; if ($pSet['YvColsToShow'] < 1 or $pSet['YvColsToShow'] > 6) { $errors[$e] = " class='inputError'"; } $e++; if ($pSet['MvWeeksToShow'] < 0 or $pSet['MvWeeksToShow'] > 20) { $errors[$e] = " class='inputError'"; } $e++; if (!preg_match("/^[0-6]{1,7}$/", $pSet['workWeekDays'])) { $errors[$e] = " class='inputError'"; } $e++; if ($pSet['weekStart'] < 0 or $pSet['weekStart'] > 6) { $errors[$e] = " class='inputError'"; } $e++; if ($pSet['XvWeeksToShow'] < 4 or $pSet['XvWeeksToShow'] > 20) { $errors[$e] = " class='inputError'"; } $e++; if ($pSet['lookaheadDays'] < 1 or $pSet['lookaheadDays'] > 365) { $errors[$e] = " class='inputError'"; } $e++; if ($pSet['dwStartHour'] < 0 or $pSet['dwStartHour'] > 18 or $pSet['dwStartHour'] > ($pSet['dwEndHour'] - 4)) { $errors[$e] = " class='inputError'"; } $e++; if ($pSet['dwEndHour'] > 24 or $pSet['dwEndHour'] < 6 or $pSet['dwStartHour'] > ($pSet['dwEndHour'] - 4)) { $errors[$e] = " class='inputError'"; } $e++; if ($pSet['dwTsHeight'] < 10 or $pSet['dwTsHeight'] > 60) { $errors[$e] = " class='inputError'"; } $e++; //the following regexs use lookahead assertion if (!preg_match ('%^([ymd])([^\da-zA-Z])(?!\1)([ymd])\2(?!(\1|\3))[ymd]$%',$pSet['dateFormat'])) { $errors[$e] = " class='inputError'"; } $e++; if (!preg_match ('%^([Md])[^\da-zA-Z]+(?!\1)[Md]$%',$pSet['MdFormat'])) { $errors[$e] = " class='inputError'"; } $e++; if (!preg_match ('%^([Myd])[^\da-zA-Z]+(?!\1)([Myd])[^\da-zA-Z]+(?!(\1|\2))[Myd]$%',$pSet['MdyFormat'])) { $errors[$e] = " class='inputError'"; } $e++; if (!preg_match ('%^([My])[^\da-zA-Z]+(?!\1)[My]$%',$pSet['MyFormat'])) { $errors[$e] = " class='inputError'"; } $e++; if (!preg_match ('%^(WD|[Md])[^\da-zA-Z]+(?!\1)(WD|[Md])[^\da-zA-Z]+(?!(\1|\2))(WD|[Md])$%',$pSet['DMdFormat'])) { $errors[$e] = " class='inputError'"; } $e++; if (!preg_match ('%^(WD|[Mdy])[^\da-zA-Z]+(?!\1)(WD|[Mdy])[^\da-zA-Z]+(?!(\1|\2))(WD|[Mdy])[^\da-zA-Z]+(?!(\1|\2\3))(WD|[Mdy])$%',$pSet['DMdyFormat'])) { $errors[$e] = " class='inputError'"; } $e++; if (!preg_match ('%^([Hhm])[^\da-zA-Z](?!\1)[Hhm](\s?[aA])?$%',$pSet['timeFormat'])) { $errors[$e] = " class='inputError'"; } $e++; if ($pSet['maxUplSize'] < 1 or $pSet['maxUplSize'] > 6) { $errors[$e] = " class='inputError'"; } $e++; if ($pSet['tnlMaxW'] < 10 or $pSet['tnlMaxW'] > 800) { $errors[$e] = " class='inputError'"; } $e++; if ($pSet['tnlMaxH'] < 10 or $pSet['tnlMaxH'] > 800) { $errors[$e] = " class='inputError'"; } $e++; if ($pSet['tnlDelDays'] < 0 or $pSet['tnlDelDays'] > 99) { $errors[$e] = " class='inputError'"; } $e++; if (!$pSet['smtpServer'] and $pSet['mailServer'] == 2) { $errors[$e] = " class='inputError'"; } $e++; if ($pSet['smtpPort'] < 0 or $pSet['smtpPort'] > 10025) { $errors[$e] = " class='inputError'"; } $e++; //10025 max port nr for SMTP if (!$pSet['smtpUser'] and $pSet['smtpAuth'] and $pSet['mailServer'] == 2) { $errors[$e] = " class='inputError'"; } $e++; if (!$pSet['smtpPass'] and $pSet['smtpAuth'] and $pSet['mailServer'] == 2) { $errors[$e] = " class='inputError'"; } $e++; if ($pSet['smsService'] and $pSet['smsSubject'] and !$pSet['calendarPhone'] and !$pSet['notSenderSms']) { $errors[$e] = " class='inputError'"; } $e++; //xxx if ($pSet['smsService'] and !preg_match ('%^[^#@]*#[^#@]*?@([^@\.]+?\.)+[\w]+$%',$pSet['smsCarrier'])) { $errors[$e] = " class='inputError'"; } $e++; if ($pSet['smsService'] and $pSet['smsCountry'] and !is_numeric($pSet['smsCountry'])) { $errors[$e] = " class='inputError'"; } $e++; if ($pSet['maxLenSms'] < 70 or $pSet['maxLenSms'] > 500) { $errors[$e] = " class='inputError'"; } $e++; if ($cronHost == 2 and !preg_match('%(?:(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.){4}%',$cronIpAd.'.')) { $errors[$e] = " class='inputError'"; } $e++; if ($pSet['chgNofDays'] < 0 or $pSet['chgNofDays'] > 30) { $errors[$e] = " class='inputError'"; } $e++; if ($pSet['eventExp'] < 0 or $pSet['eventExp'] > 999) { $errors[$e] = " class='inputError'"; } $e++; if ($pSet['maxNoLogin'] < 0 or $pSet['maxNoLogin'] > 365) { $errors[$e] = " class='inputError'"; } $e++; if (!empty($pSet['popFieldsSbar']) and !fieldsValid($pSet['popFieldsSbar'],' 1234567')) { $errors[$e] = " class='inputError'"; } $e++; if ($pSet['sideBarDays'] < 1 or $pSet['sideBarDays'] > 365) { $errors[$e] = " class='inputError'"; } $e++; //no errors, save settings in database if (!in_array(" class='inputError'",$errors)) { if ($dbSel != $calMenu or $crHost != $cronHost or $crIpAd != $cronIpAd) { $dbSel = $calMenu; $crHost = $cronHost; $crIpAd = $cronIpAd; saveConfig(); //save config data } saveSettings($pSet); $msg = $ax['set_settings_saved']; } else { //errors found $msg .= $ax['set_missing_invalid']; $eClass = 'error'; } } echo "".(($msg) ? $msg : $ax['hover_for_details'])."
\n