'); function oc_statusTime($h, $m) { $time = ''; $ampm = ''; if ($h > 12) { $time = ($h - 12) . ':' . $m; $ampm = 'pm'; } elseif ($h == 0) { if ($m == 0) { $time = 'midnight'; } else { $time = '12:30'; $ampm = 'am'; } } elseif ($h == 12) { if ($m == 0) { $time = 'noon'; } else { $time = '12:30'; $ampm = 'pm'; } } else { $time = ltrim($h, '0') . ':' . $m; $ampm = 'am'; } return($h . ':' . $m . ' || ' . $time . $ampm); } function oc_statusEvent(&$l) { $ret = ''; if (!empty($l['open'])) { $opendate = new DateTime($l['open']); $ret .= '
» will open on ' . safeHTMLstr($opendate->format('j F Y, H:i / g:ia')) . ' ' . safeHTMLstr($GLOBALS['OC_configAR']['OC_timeZone']) . '
'; } if (!empty($l['close'])) { $closedate = new DateTime($l['close']); $ret .= '
» will close on ' . safeHTMLstr($closedate->format('j F Y, H:i / g:ia')) . ' ' . safeHTMLstr($GLOBALS['OC_configAR']['OC_timeZone']) . '
'; } return($ret); } if (isset($_REQUEST['install']) && ($_REQUEST['install'] == 1)) { require_once "install-include.php"; $token = ''; } else { beginChairSession(); printHeader("Open/Close Status",1); $token = $_SESSION[OCC_SESSION_VAR_NAME]['chairtoken']; } if (isset($_POST['ocsubmit']) && !empty($_POST['ocsubmit'])) { // Check for valid submission if (OCC_INSTALL_COMPLETE && !validToken('chair')) { warn('Invalid submission'); } if ($_POST['ocsubmit'] == "Set Status") { if (preg_match("/deleteevent,((?:open|close)),(\w+),(\w+),_x/", implode("|", array_keys($_POST)), $matches)) { // delete scheduled event if (ocsql_query("UPDATE `" . OCC_TABLE_STATUS . "` SET `" . safeSQLstr($matches[1]) . "`=NULL WHERE `module`='" . safeSQLstr($matches[2]) . "' AND `setting`='" . safeSQLstr($matches[3]) . "' LIMIT 1")) { print '

Event deleted

'; } else { print '

unable to delete event

'; } } else { // regular Set Status // Update form's OC_ fields - w/exceptions below requiring special handling if ((!isset($_REQUEST['install'])) && isset($_POST['OC_submissions_open']) && ($_POST['OC_submissions_open'] == 1) && ($OC_statusAR['OC_submissions_open'] == 0) && (defined('OCC_LICENSE_EXPIRES')) && (strtotime(OCC_LICENSE_EXPIRES) < time())) { unset($_POST['OC_submissions_open']); print '

' . base64_decode('TmV3IFN1Ym1pc3Npb25zIG1heSBub3QgYmUgb3BlbmVkIGFzIHRoZSBsaWNlbnNlIGhhcyBleHBpcmVkLiAgRXh0ZW5kIHRoZSBzdXBwb3J0IHBlcmlvZCBvciBwdXJjaGFzZSBhIG5ldyBsaWNlbnNlIGlmIHRoaXMgaXMgYSBuZXcgZXZlbnQu') . '

'; } foreach (array_keys($_POST) as $p) { if (preg_match("/^[\w-]+/",$p) && isset($OC_statusAR[$p]) && preg_match("/^[01]$/i",$_POST[$p]) && ($OC_statusAR[$p] != $_POST[$p])) { updateStatusSetting($p, $_POST[$p]); $OC_statusAR[$p] = $_POST[$p]; } } // Success - if install, redirect, else let user know if (isset($_REQUEST['install']) && ($_REQUEST['install'] == 1)) { header("Location: install-complete.php"); exit; } else { print '

Status saved

'; } } } elseif ($_POST['ocsubmit'] == "Schedule") { // add an event if ( isset($_POST['status']) && preg_match("/^([a-z0-9_]+)\:([a-z0-9_]+)$/i", $_POST['status'], $matches) && isset($_POST['openclose']) && preg_match("/^(?:open|close)$/", $_POST['openclose']) && isset($_POST['day']) && preg_match("/^\d\d$/", $_POST['day']) && isset($_POST['month']) && preg_match("/^\d\d$/", $_POST['month']) && isset($_POST['year']) && preg_match("/^\d{4}$/", $_POST['year']) && isset($_POST['time']) && preg_match("/^\d\d\:\d\d$/", $_POST['time']) ) { $module = $matches[1]; $setting = $matches[2]; if (($module != 'OC') && !oc_moduleActive($module)) { print '

module inactive

'; } elseif (!isset($OC_statusAR[$setting])) { print '

status not found

'; } else { $date = $_POST['year'] . '-' . $_POST['month'] . '-' . $_POST['day']; $todayDT = new DateTime(date('Y-m-d')); // date() used otherwise in case same day which would cause todayDT > dateDT $dateDT = new DateTime($date); if ($dateDT < $todayDT) { print '

event date must be in the future

'; } else { if (ocsql_query("UPDATE `" . OCC_TABLE_STATUS . "` SET `" . (($_POST['openclose'] == 'open') ? 'open' : 'close') . "`='" . safeSQLstr($date . ' ' . $_POST['time'] . ':00') . "' WHERE `module`='" . safeSQLstr($module) . "' AND `setting`='" . safeSQLstr($setting) . "' LIMIT 1")) { print '

Event scheduled

'; } else { print '

unable to schedule event

'; } } } } else { print '

invalid event field(s)

'; } } else { warn('Unknown action'); } } if (isset($_REQUEST['install']) && ($_REQUEST['install'] == 1)) { printHeader($hdr,$hdrfn); print '

Step 5 of 5: Open Submissions & Sign-Up/In

'; $installFields = ''; } else { $installFields = ''; } $ocq = "SELECT * FROM `" . OCC_TABLE_STATUS . "` WHERE `module`='OC' ORDER BY `order`, `setting`"; $ocr = ocsql_query($ocq) or err('Unable to retrieve status settings'); $nonocq = "SELECT * FROM `" . OCC_TABLE_STATUS . "` WHERE `module`!='OC' ORDER BY `module`, `order`, `setting`"; $nonocr = ocsql_query($nonocq) or err('Unable to retrieve additional status settings'); $divnum = 1; if (empty($installFields)) { // not installing OC if (!isset($_POST['ocsubmit'])) { print '

Make desired changes then click any Set Status button, or schedule an event below:

'; } print '
Set to
on
at ' . safeHTMLstr($OC_configAR['OC_timeZone']) . '

'; } print '
' . $installFields; print '
General (collapse)
'; while ($l = ocsql_fetch_assoc($ocr)) { if (!isset($l['dependency']) || empty($l['dependency']) || $OC_configAR[$l['dependency']]) { print '
' . generateRadioOptions($l['setting'], $OC_statusValueAR, $l['status']) . '
' . oc_statusEvent($l); if (!empty($l['description'])) { print '
' . safeHTMLstr($l['description']) . '
'; } } } $module = ''; while ($l = ocsql_fetch_assoc($nonocr)) { // skip inactive modules if (!oc_moduleActive($l['module'])) { continue; } // show module heading if ($module != $l['module']) { $module = $l['module']; print '
' . safeHTMLstr($OC_modulesAR[$module]['name']) . ' Module (collapse)
'; } if (!isset($l['dependency']) || empty($l['dependency']) || $OC_configAR[$l['dependency']]) { print '
' . generateRadioOptions($l['setting'], $OC_statusValueAR, $l['status']) . '
' . oc_statusEvent($l); if (!empty($l['description'])) { print '
' . safeHTMLstr($l['description']) . '
'; } print '
'; } } print '

'; printFooter(); ?>