/** * Shows the Time Information * @return */ function ShowTimeInfo() { $response = new ResponseManager(); $output = '<ul>'; $output .= '<li>' . __('Local Time') . ': ' . DateManager::getClock() . '</li>'; $output .= '<li>' . __('System Time') . ': ' . DateManager::getSystemClock() . '</li>'; $output .= '<li>' . __('Local Date') . ': ' . DateManager::getLocalDate() . '</li>'; $output .= '<li>' . __('System Date') . ': ' . DateManager::getSystemDate() . '</li>'; $output .= '</ul>'; $response->SetFormRequestResponse($output, __('Date / Time Information'), '480px', '240px'); $response->Respond(); }
public function EditForm() { // Create a form out of the config object. $displayProfile = new DisplayProfile(); $displayProfile->displayProfileId = Kit::GetParam('displayprofileid', _GET, _INT); if (!$displayProfile->Load()) { trigger_error($displayProfile->GetErrorMessage(), E_USER_ERROR); } if ($this->user->usertypeid != 1 && $this->user->userid != $displayProfile->userId) { trigger_error(__('You do not have permission to edit this profile'), E_USER_ERROR); } if (empty($displayProfile->type)) { trigger_error(__('Unknown Client Type'), E_USER_ERROR); } // Capture and validate the posted form parameters in accordance with the display config object. include 'config/client.config.php'; if (!isset($CLIENT_CONFIG[$displayProfile->type])) { trigger_error(__('CMS Config not supported for ' . $displayProfile->type . ' displays.'), E_USER_ERROR); } // Set some information about the form Theme::Set('form_id', 'DisplayConfigForm'); Theme::Set('form_action', 'index.php?p=displayprofile&q=Edit'); Theme::Set('form_meta', '<input type="hidden" name="displayprofileid" value="' . $displayProfile->displayProfileId . '" />'); $formFields = array(); $formTabs = array(); // Tabs? foreach ($CLIENT_CONFIG[$displayProfile->type]['tabs'] as $tab) { // Create an empty array of form fields for this tab. $formFields[$tab['id']] = array(); // Also add the tab $formTabs[] = FormManager::AddTab($tab['id'], $tab['name']); } // Go through each setting and output a form control to the theme. $formFields['general'][] = FormManager::AddText('name', __('Name'), $displayProfile->name, __('The Name of the Profile - (1 - 50 characters)'), 'n', 'maxlength="50" required'); $formFields['general'][] = FormManager::AddCheckbox('isdefault', __('Default Profile?'), $displayProfile->isDefault, __('Is this the default profile for all Displays of this type? Only 1 profile can be the default.'), 'd'); foreach ($CLIENT_CONFIG[$displayProfile->type]['settings'] as $setting) { // Check to see if we have a value for this setting as yet, if so we use that. // TODO: there must be a way to improve this? foreach ($displayProfile->config as $set) { if ($set['name'] == $setting['name']) { $setting['value'] = $set['value']; } } if ($setting['type'] == 'checkbox' && isset($setting['value'])) { $validated = $setting['value']; } else { if ($setting['fieldType'] == 'timePicker') { // Check if we are 0, if so then set to 00:00 if ($setting['value'] == 0) { $validated = '00:00'; } else { $validated = DateManager::getLocalDate($setting['value'] / 1000, 'H:i'); } } else { if (isset($setting['value'])) { $validated = Kit::ValidateParam($setting['value'], $setting['type']); } else { $validated = $setting['default']; } } } //Debug::LogEntry('audit', 'Validated ' . $setting['name'] . '. [' . $setting['value'] . '] as [' . $validated . ']. With type ' . $setting['type']); // Each field needs to have a type, a name and a default $formFields[$setting['tabId']][] = array('name' => $setting['name'], 'fieldType' => $setting['fieldType'], 'helpText' => $setting['helpText'], 'title' => $setting['title'], 'options' => isset($setting['options']) ? $setting['options'] : array(), 'optionId' => 'id', 'optionValue' => 'value', 'validation' => isset($setting['validation']) ? $setting['validation'] : '', 'value' => $validated, 'enabled' => $setting['enabled'], 'groupClass' => NULL, 'accesskey' => ''); } Theme::Set('form_tabs', $formTabs); foreach ($CLIENT_CONFIG[$displayProfile->type]['tabs'] as $tab) { Theme::Set('form_fields_' . $tab['id'], $formFields[$tab['id']]); } $response = new ResponseManager(); $response->SetFormRequestResponse(NULL, __('Edit Profile'), '650px', '350px'); $response->AddButton(__('Help'), 'XiboHelpRender("' . HelpManager::Link('DisplayProfile', 'Edit') . '")'); $response->AddButton(__('Cancel'), 'XiboDialogClose()'); $response->AddButton(__('Save'), '$("#DisplayConfigForm").submit()'); $response->Respond(); }
/** * Grid of Displays * @return */ function DisplayGrid() { // validate displays so we get a realistic view of the table Display::ValidateDisplays(); $db =& $this->db; $user =& $this->user; $response = new ResponseManager(); // Filter by Name $filter_display = Kit::GetParam('filter_display', _POST, _STRING); setSession('display', 'filter_display', $filter_display); // Filter by Name $filterMacAddress = Kit::GetParam('filterMacAddress', _POST, _STRING); setSession('display', 'filterMacAddress', $filterMacAddress); // Display Group $filter_displaygroupid = Kit::GetParam('filter_displaygroup', _POST, _INT); setSession('display', 'filter_displaygroup', $filter_displaygroupid); // Thumbnail? $filter_showView = Kit::GetParam('filter_showView', _REQUEST, _INT); setSession('display', 'filter_showView', $filter_showView); $filterVersion = Kit::GetParam('filterVersion', _REQUEST, _STRING); setSession('display', 'filterVersion', $filterVersion); // filter_autoRefresh? $filter_autoRefresh = Kit::GetParam('filter_autoRefresh', _REQUEST, _INT, 0); setSession('display', 'filter_autoRefresh', $filter_autoRefresh); // Pinned option? setSession('display', 'DisplayFilter', Kit::GetParam('XiboFilterPinned', _REQUEST, _CHECKBOX, 'off')); $displays = $user->DisplayList(array('displayid'), array('displaygroupid' => $filter_displaygroupid, 'display' => $filter_display, 'macAddress' => $filterMacAddress, 'clientVersion' => $filterVersion)); if (!is_array($displays)) { trigger_error($db->error()); trigger_error(__('Unable to get list of displays'), E_USER_ERROR); } // Do we want to make a VNC link out of the display name? $vncTemplate = Config::GetSetting('SHOW_DISPLAY_AS_VNCLINK'); $linkTarget = Kit::ValidateParam(Config::GetSetting('SHOW_DISPLAY_AS_VNC_TGT'), _STRING); $cols = array(array('name' => 'displayid', 'title' => __('ID')), array('name' => 'displayWithLink', 'title' => __('Display')), array('name' => 'status', 'title' => __('Status'), 'icons' => true, 'iconDescription' => 'statusDescription'), array('name' => 'licensed', 'title' => __('License'), 'icons' => true), array('name' => 'currentLayout', 'title' => __('Current Layout'), 'hidden' => $filter_showView != 3), array('name' => 'storageAvailableSpaceFormatted', 'title' => __('Storage Available'), 'hidden' => $filter_showView != 3), array('name' => 'storageTotalSpaceFormatted', 'title' => __('Storage Total'), 'hidden' => $filter_showView != 3), array('name' => 'storagePercentage', 'title' => __('Storage Free %'), 'hidden' => $filter_showView != 3), array('name' => 'description', 'title' => __('Description'), 'hidden' => $filter_showView != 4), array('name' => 'layout', 'title' => __('Default Layout'), 'hidden' => $filter_showView != 0), array('name' => 'inc_schedule', 'title' => __('Interleave Default'), 'icons' => true, 'hidden' => $filter_showView == 1 || $filter_showView == 2), array('name' => 'email_alert', 'title' => __('Email Alert'), 'icons' => true, 'hidden' => $filter_showView != 0), array('name' => 'loggedin', 'title' => __('Logged In'), 'icons' => true), array('name' => 'lastaccessed', 'title' => __('Last Accessed')), array('name' => 'clientVersionCombined', 'title' => __('Version'), 'hidden' => $filter_showView != 3), array('name' => 'clientaddress', 'title' => __('IP Address'), 'hidden' => $filter_showView == 1), array('name' => 'macaddress', 'title' => __('Mac Address'), 'hidden' => $filter_showView == 1), array('name' => 'screenShotRequested', 'title' => __('Screen shot?'), 'icons' => true, 'hidden' => $filter_showView != 1 && $filter_showView != 2), array('name' => 'thumbnail', 'title' => __('Thumbnail'), 'hidden' => $filter_showView != 1 && $filter_showView != 2)); Theme::Set('table_cols', $cols); Theme::Set('rowClass', 'rowColor'); $rows = array(); foreach ($displays as $row) { // VNC Template as display name? if ($vncTemplate != '' && $row['clientaddress'] != '') { if ($linkTarget == '') { $linkTarget = '_top'; } $row['displayWithLink'] = sprintf('<a href="' . $vncTemplate . '" title="VNC to ' . $row['display'] . '" target="' . $linkTarget . '">' . Theme::Prepare($row['display']) . '</a>', $row['clientaddress']); } else { $row['displayWithLink'] = $row['display']; } // Format last accessed $row['lastaccessed'] = DateManager::getLocalDate($row['lastaccessed']); // Create some login lights $row['rowColor'] = $row['mediainventorystatus'] == 1 ? 'success' : ($row['mediainventorystatus'] == 2 ? 'danger' : 'warning'); // Set some text for the display status switch ($row['mediainventorystatus']) { case 1: $row['statusDescription'] = __('Display is up to date'); break; case 2: $row['statusDescription'] = __('Display is downloading new files'); break; case 3: $row['statusDescription'] = __('Display is out of date but has not yet checked in with the server'); break; default: $row['statusDescription'] = __('Unknown Display Status'); } $row['status'] = $row['mediainventorystatus'] == 1 ? 1 : ($row['mediainventorystatus'] == 2 ? 0 : -1); // Thumbnail $row['thumbnail'] = ''; // If we aren't logged in, and we are showThumbnail == 2, then show a circle if ($filter_showView == 2 && $row['loggedin'] == 0) { $row['thumbnail'] = '<i class="fa fa-times-circle"></i>'; } else { if ($filter_showView != 0 && file_exists(Config::GetSetting('LIBRARY_LOCATION') . 'screenshots/' . $row['displayid'] . '_screenshot.jpg')) { $row['thumbnail'] = '<a data-toggle="lightbox" data-type="image" href="index.php?p=display&q=ScreenShot&DisplayId=' . $row['displayid'] . '"><img class="display-screenshot" src="index.php?p=display&q=ScreenShot&DisplayId=' . $row['displayid'] . '&' . Kit::uniqueId() . '" /></a>'; } } // Version $row['clientVersionCombined'] = $row['client_type'] . ' / ' . $row['client_version']; // Format the storage available / total space $row['storageAvailableSpaceFormatted'] = Kit::formatBytes($row['storageAvailableSpace']); $row['storageTotalSpaceFormatted'] = Kit::formatBytes($row['storageTotalSpace']); $row['storagePercentage'] = $row['storageTotalSpace'] == 0 ? 100 : round($row['storageAvailableSpace'] / $row['storageTotalSpace'] * 100.0, 2); // Edit and Delete buttons first if ($row['edit'] == 1) { // Edit $row['buttons'][] = array('id' => 'display_button_edit', 'url' => 'index.php?p=display&q=displayForm&displayid=' . $row['displayid'], 'text' => __('Edit')); } // Delete if ($row['del'] == 1) { $row['buttons'][] = array('id' => 'display_button_delete', 'url' => 'index.php?p=display&q=DeleteForm&displayid=' . $row['displayid'], 'text' => __('Delete')); } if ($row['edit'] == 1 || $row['del'] == 1) { $row['buttons'][] = array('linkType' => 'divider'); } // Schedule Now if ($row['edit'] == 1 || Config::GetSetting('SCHEDULE_WITH_VIEW_PERMISSION') == 'Yes') { $row['buttons'][] = array('id' => 'display_button_schedulenow', 'url' => 'index.php?p=schedule&q=ScheduleNowForm&displayGroupId=' . $row['displaygroupid'], 'text' => __('Schedule Now')); } if ($row['edit'] == 1) { // Default Layout $row['buttons'][] = array('id' => 'display_button_defaultlayout', 'url' => 'index.php?p=display&q=DefaultLayoutForm&DisplayId=' . $row['displayid'], 'text' => __('Default Layout')); // File Associations $row['buttons'][] = array('id' => 'displaygroup_button_fileassociations', 'url' => 'index.php?p=displaygroup&q=FileAssociations&DisplayGroupID=' . $row['displaygroupid'], 'text' => __('Assign Files')); // Screen Shot $row['buttons'][] = array('id' => 'display_button_requestScreenShot', 'url' => 'index.php?p=display&q=RequestScreenShotForm&displayId=' . $row['displayid'], 'text' => __('Request Screen Shot'), 'multi-select' => true, 'dataAttributes' => array(array('name' => 'multiselectlink', 'value' => 'index.php?p=display&q=RequestScreenShot'), array('name' => 'rowtitle', 'value' => $row['display']), array('name' => 'displayId', 'value' => $row['displayid']))); $row['buttons'][] = array('linkType' => 'divider'); } // Media Inventory $row['buttons'][] = array('id' => 'display_button_mediainventory', 'url' => 'index.php?p=display&q=MediaInventory&DisplayId=' . $row['displayid'], 'text' => __('Media Inventory')); if ($row['edit'] == 1) { // Logs $row['buttons'][] = array('id' => 'displaygroup_button_logs', 'url' => 'index.php?p=log&q=LastHundredForDisplay&displayid=' . $row['displayid'], 'text' => __('Recent Log')); $row['buttons'][] = array('linkType' => 'divider'); } if ($row['modifypermissions'] == 1) { // Display Groups $row['buttons'][] = array('id' => 'display_button_group_membership', 'url' => 'index.php?p=display&q=MemberOfForm&DisplayID=' . $row['displayid'], 'text' => __('Display Groups')); // Permissions $row['buttons'][] = array('id' => 'display_button_group_membership', 'url' => 'index.php?p=displaygroup&q=PermissionsForm&DisplayGroupID=' . $row['displaygroupid'], 'text' => __('Permissions')); // Version Information $row['buttons'][] = array('id' => 'display_button_version_instructions', 'url' => 'index.php?p=displaygroup&q=VersionInstructionsForm&displaygroupid=' . $row['displaygroupid'] . '&displayid=' . $row['displayid'], 'text' => __('Version Information')); $row['buttons'][] = array('linkType' => 'divider'); } if ($row['edit'] == 1) { // Wake On LAN $row['buttons'][] = array('id' => 'display_button_wol', 'url' => 'index.php?p=display&q=WakeOnLanForm&DisplayId=' . $row['displayid'], 'text' => __('Wake on LAN')); } // Assign this to the table row $rows[] = $row; } Theme::Set('table_rows', $rows); $output = Theme::RenderReturn('table_render'); $response->SetGridResponse($output); $response->refresh = Kit::GetParam('filter_autoRefresh', _REQUEST, _INT, 0); $response->Respond(); }
function Grid() { $db =& $this->db; $response = new ResponseManager(); $type = Kit::GetParam('filter_type', _POST, _WORD); $fromDt = Kit::GetParam('filter_fromdt', _POST, _STRING); setSession('sessions', 'Filter', Kit::GetParam('XiboFilterPinned', _REQUEST, _CHECKBOX, 'off')); setSession('sessions', 'filter_type', $type); setSession('sessions', 'filter_fromdt', $fromDt); $SQL = "SELECT session.userID, user.UserName, IsExpired, LastPage, session.LastAccessed, RemoteAddr, UserAgent "; $SQL .= "FROM `session` LEFT OUTER JOIN user ON user.userID = session.userID "; $SQL .= "WHERE 1 = 1 "; if ($fromDt != '') { // From Date is the Calendar Formatted DateTime in ISO format $SQL .= sprintf(" AND session.LastAccessed < '%s' ", DateManager::getMidnightSystemDate(DateManager::getTimestampFromString($fromDt))); } if ($type == "active") { $SQL .= " AND IsExpired = 0 "; } if ($type == "expired") { $SQL .= " AND IsExpired = 1 "; } if ($type == "guest") { $SQL .= " AND session.userID IS NULL "; } // Load results into an array $log = $db->GetArray($SQL); Debug::LogEntry('audit', $SQL); if (!is_array($log)) { trigger_error($db->error()); trigger_error(__('Error getting the log'), E_USER_ERROR); } $cols = array(array('name' => 'lastaccessed', 'title' => __('Last Accessed')), array('name' => 'isexpired', 'title' => __('Active'), 'icons' => true), array('name' => 'username', 'title' => __('User Name')), array('name' => 'lastpage', 'title' => __('Last Page')), array('name' => 'ip', 'title' => __('IP Address')), array('name' => 'browser', 'title' => __('Browser'))); Theme::Set('table_cols', $cols); $rows = array(); foreach ($log as $row) { $row['userid'] = Kit::ValidateParam($row['userID'], _INT); $row['username'] = Kit::ValidateParam($row['UserName'], _STRING); $row['isexpired'] = Kit::ValidateParam($row['IsExpired'], _INT) == 1 ? 0 : 1; $row['lastpage'] = Kit::ValidateParam($row['LastPage'], _STRING); $row['lastaccessed'] = DateManager::getLocalDate(strtotime(Kit::ValidateParam($row['LastAccessed'], _STRING))); $row['ip'] = Kit::ValidateParam($row['RemoteAddr'], _STRING); $row['browser'] = Kit::ValidateParam($row['UserAgent'], _STRING); // Edit $row['buttons'][] = array('id' => 'sessions_button_logout', 'url' => 'index.php?p=sessions&q=ConfirmLogout&userid=' . $row['userid'], 'text' => __('Logout')); $rows[] = $row; } Theme::Set('table_rows', $rows); $response->SetGridResponse(Theme::RenderReturn('table_render')); $response->Respond(); }
private function makeSubstitutions($data, $source) { // Replace all matches. $matches = ''; preg_match_all('/\\[.*?\\]/', $source, $matches); // Substitute foreach ($matches[0] as $sub) { $replace = str_replace('[', '', str_replace(']', '', $sub)); // Handling for date/time if (stripos($replace, 'time|') > -1) { $timeSplit = explode('|', $replace); $time = DateManager::getLocalDate($data['time'], $timeSplit[1]); // Pull time out of the array $source = str_replace($sub, $time, $source); } else { // Match that in the array if (isset($data[$replace])) { $source = str_replace($sub, $data[$replace], $source); } } } return $source; }
/** * Shows a form to add an event * will default to the current date if non is provided * @return */ function EditEventForm() { $db =& $this->db; $user =& $this->user; $response = new ResponseManager(); $eventID = Kit::GetParam('EventID', _GET, _INT, 0); if ($eventID == 0) { trigger_error(__('No event selected.'), E_USER_ERROR); } // Get the relevant details for this event $SQL = ""; $SQL .= "SELECT schedule.FromDT, "; $SQL .= " schedule.ToDT,"; $SQL .= " schedule.CampaignID, "; $SQL .= " schedule.userid, "; $SQL .= " schedule.is_priority, "; $SQL .= " schedule.DisplayGroupIDs, "; $SQL .= " schedule.recurrence_type, "; $SQL .= " schedule.recurrence_detail, "; $SQL .= " schedule.recurrence_range, "; $SQL .= " schedule.EventID, "; $SQL .= " schedule.DisplayOrder "; $SQL .= " FROM schedule "; $SQL .= " WHERE 1=1 "; $SQL .= sprintf(" AND schedule.EventID = %d", $eventID); Debug::LogEntry('audit', $SQL); if (!($result = $db->query($SQL))) { trigger_error($db->error()); trigger_error(__('Error getting details for this event.'), E_USER_ERROR); } $row = $db->get_assoc_row($result); $fromDT = Kit::ValidateParam($row['FromDT'], _INT); $toDT = Kit::ValidateParam($row['ToDT'], _INT); $displayGroupIds = explode(',', Kit::ValidateParam($row['DisplayGroupIDs'], _STRING)); $recType = Kit::ValidateParam($row['recurrence_type'], _STRING); $recDetail = Kit::ValidateParam($row['recurrence_detail'], _STRING); $recToDT = Kit::ValidateParam($row['recurrence_range'], _INT); $campaignId = Kit::ValidateParam($row['CampaignID'], _STRING); $isPriority = Kit::ValidateParam($row['is_priority'], _INT); $displayOrder = Kit::ValidateParam($row['DisplayOrder'], _INT); // Check that we have permission to edit this event. if (!$this->IsEventEditable($displayGroupIds)) { trigger_error(__('You do not have permission to edit this event.'), E_USER_ERROR); } $token_id = uniqid(); $token_field = '<input type="hidden" name="token_id" value="' . $token_id . '" />'; $token = Kit::Token($token_id); Theme::Set('form_id', 'EditEventForm'); Theme::Set('form_action', 'index.php?p=schedule&q=EditEvent'); Theme::Set('form_meta', $token_field . $token . '<input type="hidden" id="EventID" name="EventID" value="' . $eventID . '" />'); // Two tabs $tabs = array(); $tabs[] = FormManager::AddTab('general', __('General')); $tabs[] = FormManager::AddTab('repeats', __('Repeats')); Theme::Set('form_tabs', $tabs); $formFields = array(); // List of Display Groups $optionGroups = array(array('id' => 'group', 'label' => __('Groups')), array('id' => 'display', 'label' => __('Displays'))); $groups = array(); $displays = array(); $scheduleWithView = Config::GetSetting('SCHEDULE_WITH_VIEW_PERMISSION') == 'Yes'; foreach ($this->user->DisplayGroupList(-1) as $display) { // Can schedule with view, but no view permissions if ($scheduleWithView && $display['view'] != 1) { continue; } // Can't schedule with view, but no edit permissions if (!$scheduleWithView && $display['edit'] != 1) { continue; } $display['checked_text'] = in_array($display['displaygroupid'], $displayGroupIds) ? ' selected' : ''; if ($display['isdisplayspecific'] == 1) { $displays[] = $display; } else { $groups[] = $display; } } $formFields['general'][] = FormManager::AddMultiCombo('DisplayGroupIDs[]', __('Display'), $displayGroupIds, array('group' => $groups, 'display' => $displays), 'displaygroupid', 'displaygroup', __('Please select one or more displays / groups for this event to be shown on.'), 'd', '', true, '', '', '', $optionGroups, array(array('name' => 'data-live-search', 'value' => "true"), array('name' => 'data-selected-text-format', 'value' => "count > 4"))); // Time controls $formFields['general'][] = FormManager::AddText('starttimeControl', __('Start Time'), DateManager::getLocalDate($fromDT), __('Select the start time for this event'), 's', 'required'); $formFields['general'][] = FormManager::AddText('endtimeControl', __('End Time'), DateManager::getLocalDate($toDT), __('Select the end time for this event'), 'e', 'required'); // Add two hidden fields to always carry the ISO date $formFields['general'][] = FormManager::AddHidden('starttime', DateManager::getLocalDate($fromDT, "Y-m-d H:i", false)); $formFields['general'][] = FormManager::AddHidden('endtime', DateManager::getLocalDate($toDT, "Y-m-d H:i", false)); // Generate a list of layouts. $layouts = $user->CampaignList(NULL, false, false); $optionGroups = array(array('id' => 'campaign', 'label' => __('Campaigns')), array('id' => 'layout', 'label' => __('Layouts'))); $layoutOptions = array(); $campaignOptions = array(); foreach ($layouts as $layout) { if ($layout['islayoutspecific'] == 1) { $layoutOptions[] = array('id' => $layout['campaignid'], 'value' => $layout['campaign']); } else { $campaignOptions[] = array('id' => $layout['campaignid'], 'value' => $layout['campaign']); } } $formFields['general'][] = FormManager::AddCombo('CampaignID', __('Layout / Campaign'), $campaignId, array('campaign' => $campaignOptions, 'layout' => $layoutOptions), 'id', 'value', __('Please select a Layout or Campaign for this Event to show'), 'l', '', true, '', '', '', $optionGroups); $formFields['general'][] = FormManager::AddNumber('DisplayOrder', __('Display Order'), $displayOrder, __('Please select the order this event should appear in relation to others when there is more than one event scheduled'), 'o'); $formFields['general'][] = FormManager::AddCheckbox('is_priority', __('Priority'), $isPriority, __('Sets whether or not this event has priority. If set the event will be show in preference to other events.'), 'p'); $formFields['repeats'][] = FormManager::AddCombo('rec_type', __('Repeats'), $recType, array(array('id' => '', 'name' => __('None')), array('id' => 'Minute', 'name' => __('Per Minute')), array('id' => 'Hour', 'name' => __('Hourly')), array('id' => 'Day', 'name' => __('Daily')), array('id' => 'Week', 'name' => __('Weekly')), array('id' => 'Month', 'name' => __('Monthly')), array('id' => 'Year', 'name' => __('Yearly'))), 'id', 'name', __('What type of repeat is required?'), 'r'); $formFields['repeats'][] = FormManager::AddNumber('rec_detail', __('Repeat every'), $recDetail, __('How often does this event repeat?'), 'o', '', 'repeat-control-group'); $formFields['repeats'][] = FormManager::AddText('rec_rangeControl', __('Until'), $recToDT == 0 ? '' : DateManager::getLocalDate($recToDT), __('When should this event stop repeating?'), 'u', '', 'repeat-control-group'); $formFields['repeats'][] = FormManager::AddHidden('rec_range', DateManager::getLocalDate($recToDT, "Y-m-d H:i")); // Set some field dependencies $response->AddFieldAction('rec_type', 'init', '', array('.repeat-control-group' => array('display' => 'none'))); $response->AddFieldAction('rec_type', 'init', '', array('.repeat-control-group' => array('display' => 'block')), "not"); $response->AddFieldAction('rec_type', 'change', '', array('.repeat-control-group' => array('display' => 'none'))); $response->AddFieldAction('rec_type', 'change', '', array('.repeat-control-group' => array('display' => 'block')), "not"); Theme::Set('form_fields_general', $formFields['general']); Theme::Set('form_fields_repeats', $formFields['repeats']); $response->SetFormRequestResponse(NULL, __('Edit Event'), '800px', '600px'); $response->AddButton(__('Help'), "XiboHelpRender('index.php?p=help&q=Display&Topic=Schedule&Category=Edit')"); $response->AddButton(__('Delete'), 'XiboFormRender("index.php?p=schedule&q=DeleteForm&EventID=' . $eventID . '")'); $response->AddButton(__('Cancel'), 'XiboDialogClose()'); $response->AddButton(__('Save'), '$("#EditEventForm").attr("action", $("#EditEventForm").attr("action") + "&next=0").submit()'); $response->callBack = 'setupScheduleForm'; $response->Respond(); }
private function GetRssItems($isPreview, $text) { // Make sure we have the cache location configured $file = new File($this->db); File::EnsureLibraryExists(); // Make sure we have a $media/$layout object to use $media = new Media(); $layout = new Layout(); // Parse the text template $matches = ''; preg_match_all('/\\[.*?\\]/', $text, $matches); Debug::LogEntry('audit', 'Loading SimplePie to handle RSS parsing.' . urldecode($this->GetOption('uri'))); // Use SimplePie to get the feed include_once '3rdparty/simplepie/autoloader.php'; $feed = new SimplePie(); $feed->set_cache_location($file->GetLibraryCacheUri()); $feed->set_feed_url(urldecode($this->GetOption('uri'))); $feed->force_feed(true); $feed->set_cache_duration($this->GetOption('updateInterval', 3600) * 60); $feed->handle_content_type(); // Get a list of allowed attributes if ($this->GetOption('allowedAttributes') != '') { $attrsStrip = array_diff($feed->strip_attributes, explode(',', $this->GetOption('allowedAttributes'))); //Debug::Audit(var_export($attrsStrip, true)); $feed->strip_attributes($attrsStrip); } // Disable date sorting? if ($this->GetOption('disableDateSort') == 1) { $feed->enable_order_by_date(false); } // Init $feed->init(); $dateFormat = $this->GetOption('dateFormat'); if ($feed->error()) { Debug::LogEntry('audit', 'Feed Error: ' . $feed->error()); return array(); } // Set an expiry time for the media $expires = time() + $this->GetOption('updateInterval', 3600) * 60; // Store our formatted items $items = array(); foreach ($feed->get_items() as $item) { /* @var SimplePie_Item $item */ // Substitute for all matches in the template $rowString = $text; // Substitute foreach ($matches[0] as $sub) { $replace = ''; // Pick the appropriate column out if (strstr($sub, '|') !== false) { // Use the provided name space to extract a tag $attribs = NULL; if (substr_count($sub, '|') > 1) { list($tag, $namespace, $attribs) = explode('|', $sub); } else { list($tag, $namespace) = explode('|', $sub); } // What are we looking at Debug::Audit('Namespace: ' . str_replace(']', '', $namespace) . '. Tag: ' . str_replace('[', '', $tag) . '. '); // Are we an image place holder? if (strstr($namespace, 'image') != false) { // Try to get a link for the image $link = null; switch (str_replace('[', '', $tag)) { case 'Link': if ($enclosure = $item->get_enclosure()) { // Use the link to get the image $link = $enclosure->get_link(); } break; default: // Default behaviour just tries to get the content from the tag provided (without a name space). $tags = $item->get_item_tags('', str_replace('[', '', $tag)); if ($tags != null) { $link = is_array($tags) ? $tags[0]['data'] : ''; } } if ($link == NULL) { $dom = new DOMDocument(); $dom->loadHTML($item->get_content()); // Full $images = $dom->getElementsByTagName('img'); foreach ($images as $key => $value) { if ($key == 0) { $link = html_entity_decode($images->item($key)->getAttribute('src')); } } } if ($link == NULL) { $dom = new DOMDocument(); $dom->loadHTML($item->get_description()); //Summary $images = $dom->getElementsByTagName('img'); foreach ($images as $key => $value) { if ($key == 0) { $link = html_entity_decode($images->item($key)->getAttribute('src')); } } } // If we have managed to resolve a link, download it and replace the tag with the downloaded // image url if ($link != NULL) { // Grab the profile image $file = $media->addModuleFileFromUrl($link, 'ticker_' . md5($this->GetOption('url') . $link), $expires); // Tag this layout with this file $layout->AddLk($this->layoutid, 'module', $file['mediaId']); $replace = $isPreview ? '<img src="index.php?p=module&mod=image&q=Exec&method=GetResource&mediaid=' . $file['mediaId'] . '" ' . $attribs . '/>' : '<img src="' . $file['storedAs'] . '" ' . $attribs . ' />'; } } else { $tags = $item->get_item_tags(str_replace(']', '', $namespace), str_replace('[', '', $tag)); Debug::LogEntry('audit', 'Tags:' . var_export($tags, true)); // If we find some tags then do the business with them if ($tags != NULL) { if ($attribs != NULL) { $replace = is_array($tags) ? $tags[0]['attribs'][''][str_replace(']', '', $attribs)] : ''; } else { $replace = is_array($tags) ? $tags[0]['data'] : ''; } } } } else { // Use the pool of standard tags switch ($sub) { case '[Name]': $replace = $this->GetOption('name'); break; case '[Title]': $replace = $item->get_title(); break; case '[Description]': $replace = $item->get_description(); break; case '[Content]': $replace = $item->get_content(); break; case '[Copyright]': $replace = $item->get_copyright(); break; case '[Date]': $replace = DateManager::getLocalDate($item->get_date('U'), $dateFormat); break; case '[PermaLink]': $replace = $item->get_permalink(); break; case '[Link]': $replace = $item->get_link(); break; } if ($this->GetOption('stripTags') != '') { require_once '3rdparty/htmlpurifier/library/HTMLPurifier.auto.php'; $config = HTMLPurifier_Config::createDefault(); $config->set('HTML.ForbiddenElements', array_merge($feed->strip_htmltags, explode(',', $this->GetOption('stripTags')))); $purifier = new HTMLPurifier($config); $replace = $purifier->purify($replace); } } // Substitute the replacement we have found (it might be '') $rowString = str_replace($sub, $replace, $rowString); } $items[] = $rowString; } // Copyright information? if ($this->GetOption('copyright', '') != '') { $items[] = '<span id="copyright">' . $this->GetOption('copyright') . '</span>'; } // Return the formatted items return $items; }
public function OutputCsvForm() { $response = new ResponseManager(); Theme::Set('form_id', 'OutputCsvForm'); Theme::Set('form_action', 'index.php?p=stats&q=OutputCSV'); $formFields = array(); $formFields[] = FormManager::AddText('fromdt', __('From Date'), DateManager::getLocalDate(time() - 86400 * 35, 'Y-m-d'), NULL, 'f'); $formFields[] = FormManager::AddText('todt', __('To Date'), DateManager::getLocalDate(null, 'Y-m-d'), NULL, 't'); // List of Displays this user has permission for $displays = $this->user->DisplayGroupList(1); array_unshift($displays, array('displayid' => 0, 'displaygroup' => 'All')); $formFields[] = FormManager::AddCombo('displayid', __('Display'), NULL, $displays, 'displayid', 'displaygroup', NULL, 'd'); Theme::Set('header_text', __('Bandwidth')); Theme::Set('form_fields', $formFields); Theme::Set('form_class', 'XiboManualSubmit'); $response->SetFormRequestResponse(NULL, __('Export Statistics'), '550px', '275px'); $response->AddButton(__('Export'), '$("#OutputCsvForm").submit()'); $response->AddButton(__('Close'), 'XiboDialogClose()'); $response->Respond(); }
function Grid() { $db =& $this->db; $user =& $this->user; $response = new ResponseManager(); $type = Kit::GetParam('filter_type', _REQUEST, _INT, 0); $function = Kit::GetParam('filter_function', _REQUEST, _STRING); $page = Kit::GetParam('filter_page', _REQUEST, _STRING); $fromdt = Kit::GetParam('filter_fromdt', _REQUEST, _STRING); $displayid = Kit::GetParam('filter_display', _REQUEST, _INT); $seconds = Kit::GetParam('filter_seconds', _POST, _INT, 120); $filter_intervalTypeId = Kit::GetParam('filter_intervalTypeId', _POST, _INT, 1); setSession('log', 'Filter', Kit::GetParam('XiboFilterPinned', _REQUEST, _CHECKBOX, 'off')); setSession('log', 'filter_type', $type); setSession('log', 'filter_function', $function); setSession('log', 'filter_page', $page); setSession('log', 'filter_fromdt', $fromdt); setSession('log', 'filter_display', $displayid); setSession('log', 'filter_seconds', $seconds); setSession('log', 'filter_intervalTypeId', $filter_intervalTypeId); //get the dates and times if ($fromdt == '') { $starttime_timestamp = time(); } else { $start_date = DateManager::getTimestampFromString($fromdt); $starttime_timestamp = strtotime($start_date[1] . "/" . $start_date[0] . "/" . $start_date[2] . ' ' . date("H", time()) . ":" . date("i", time()) . ':59'); } $todt = date("Y-m-d H:i:s", $starttime_timestamp); $fromdt = date("Y-m-d H:i:s", $starttime_timestamp - $seconds * $filter_intervalTypeId); $SQL = ""; $SQL .= "SELECT logid, logdate, page, function, message, display.display FROM log LEFT OUTER JOIN display ON display.displayid = log.displayid "; $SQL .= sprintf(" WHERE logdate > '%s' AND logdate <= '%s' ", $fromdt, $todt); if ($type != 0) { $SQL .= sprintf("AND type = '%s' ", $type == 1 ? 'error' : 'audit'); } if ($page != "") { $SQL .= sprintf("AND page = '%s' ", $db->escape_string($page)); } if ($function != "") { $SQL .= sprintf("AND function = '%s' ", $db->escape_string($function)); } if ($displayid != 0) { $SQL .= sprintf("AND display.displayID = %d ", $displayid); } $SQL .= " ORDER BY logid "; // Load results into an array $log = $db->GetArray($SQL); if (!is_array($log)) { trigger_error($db->error()); trigger_error(__('Error getting the log'), E_USER_ERROR); } $cols = array(array('name' => 'logid', 'title' => __('ID')), array('name' => 'logdate', 'title' => __('Date')), array('name' => 'display', 'title' => __('Display')), array('name' => 'page', 'title' => __('Page')), array('name' => 'function', 'title' => __('Function')), array('name' => 'message', 'title' => __('Message'))); Theme::Set('table_cols', $cols); $rows = array(); foreach ($log as $row) { $row['logid'] = Kit::ValidateParam($row['logid'], _INT); $row['logdate'] = DateManager::getLocalDate(strtotime(Kit::ValidateParam($row['logdate'], _STRING)), 'y-m-d h:i:s'); $row['display'] = Kit::ValidateParam($row['display'], _STRING) == '' ? __('CMS') : Kit::ValidateParam($row['display'], _STRING); $row['page'] = Kit::ValidateParam($row['page'], _STRING); $row['function'] = Kit::ValidateParam($row['function'], _STRING); $row['message'] = nl2br(htmlspecialchars($row['message'])); $rows[] = $row; } Theme::Set('table_rows', $rows); $output = Theme::RenderReturn('table_render'); $response->initialSortOrder = 2; $response->initialSortColumn = 1; $response->pageSize = 20; $response->SetGridResponse($output); $response->Respond(); }
/** * Outputs a CSV of audit trail messages */ public function outputCSV() { // We are expecting some parameters $filterFromDt = Kit::GetParam('filterFromDt', _REQUEST, _STRING); $filterToDt = Kit::GetParam('filterToDt', _REQUEST, _STRING); $fromTimestamp = DateTime::createFromFormat('Y-m-d', $filterFromDt); $fromTimestamp->setTime(0, 0, 0); $toTimestamp = DateTime::createFromFormat('Y-m-d', $filterToDt); $toTimestamp->setTime(0, 0, 0); $search = array(array('fromTimeStamp', $fromTimestamp->format('U')), array('toTimeStamp', $toTimestamp->format('U'))); // Build the search string $search = implode(' ', array_map(function ($element) { return implode('|', $element); }, $search)); $rows = \Xibo\Factory\AuditLogFactory::query('logId', array('search' => $search)); // We want to output a load of stuff to the browser as a text file. header('Content-Type: text/csv'); header('Content-Disposition: attachment; filename="audittrail.csv"'); header("Content-Transfer-Encoding: binary"); header('Accept-Ranges: bytes'); $out = fopen('php://output', 'w'); fputcsv($out, array('ID', 'Date', 'User', 'Entity', 'Message', 'Object')); // Do some post processing foreach ($rows as $row) { /* @var \Xibo\Entity\AuditLog $row */ fputcsv($out, array($row->logId, DateManager::getLocalDate($row->logDate), $row->userName, $row->entity, $row->message, $row->objectAfter)); } fclose($out); exit; }
function displayPage() { // Set up some suffixes $suffixes = array('bytes', 'k', 'M', 'G', 'T'); // Get some data for a bandwidth chart try { $dbh = PDOConnect::init(); $sth = $dbh->prepare('SELECT FROM_UNIXTIME(month) AS month, IFNULL(SUM(Size), 0) AS size FROM `bandwidth` WHERE month > :month GROUP BY FROM_UNIXTIME(month) ORDER BY MIN(month);'); $sth->execute(array('month' => time() - 86400 * 365)); $results = $sth->fetchAll(); // Monthly bandwidth - optionally tested against limits $xmdsLimit = Config::GetSetting('MONTHLY_XMDS_TRANSFER_LIMIT_KB'); $maxSize = 0; foreach ($results as $row) { $maxSize = $row['size'] > $maxSize ? $row['size'] : $maxSize; } // Decide what our units are going to be, based on the size $base = $maxSize == 0 ? 0 : floor(log($maxSize) / log(1024)); if ($xmdsLimit > 0) { // Convert to appropriate size (xmds limit is in KB) $xmdsLimit = $xmdsLimit * 1024 / pow(1024, $base); Theme::Set('xmdsLimit', $xmdsLimit . ' ' . $suffixes[$base]); } $output = array(); foreach ($results as $row) { $size = (double) $row['size'] / pow(1024, $base); $remaining = $xmdsLimit - $size; $output[] = array('label' => DateManager::getLocalDate(DateManager::getDateFromGregorianString($row['month']), 'F'), 'value' => round($size, 2), 'limit' => round($remaining, 2)); } // What if we are empty? if (count($output) == 0) { $output[] = array('label' => DateManager::getLocalDate(null, 'F'), 'value' => 0, 'limit' => 0); } // Set the data Theme::Set('xmdsLimitSet', $xmdsLimit > 0); Theme::Set('bandwidthSuffix', $suffixes[$base]); Theme::Set('bandwidthWidget', json_encode($output)); // We would also like a library usage pie chart! $libraryLimit = Config::GetSetting('LIBRARY_SIZE_LIMIT_KB'); $libraryLimit = $libraryLimit * 1024; // Library Size in Bytes $sth = $dbh->prepare('SELECT IFNULL(SUM(FileSize), 0) AS SumSize, type FROM media GROUP BY type;'); $sth->execute(); $results = $sth->fetchAll(); // Do we base the units on the maximum size or the library limit $maxSize = 0; if ($libraryLimit > 0) { $maxSize = $libraryLimit; } else { // Find the maximum sized chunk of the items in the library foreach ($results as $library) { $maxSize = $library['SumSize'] > $maxSize ? $library['SumSize'] : $maxSize; } } // Decide what our units are going to be, based on the size $base = $maxSize == 0 ? 0 : floor(log($maxSize) / log(1024)); $output = array(); $totalSize = 0; foreach ($results as $library) { $output[] = array('value' => round((double) $library['SumSize'] / pow(1024, $base), 2), 'label' => ucfirst($library['type'])); $totalSize = $totalSize + $library['SumSize']; } // Do we need to add the library remaining? if ($libraryLimit > 0) { $remaining = round(($libraryLimit - $totalSize) / pow(1024, $base), 2); $output[] = array('value' => $remaining, 'label' => __('Free')); } // What if we are empty? if (count($output) == 0) { $output[] = array('label' => __('Empty'), 'value' => 0); } Theme::Set('libraryLimitSet', $libraryLimit); Theme::Set('libraryLimit', round((double) $libraryLimit / pow(1024, $base), 2) . ' ' . $suffixes[$base]); Theme::Set('librarySize', Kit::formatBytes($totalSize, 1)); Theme::Set('librarySuffix', $suffixes[$base]); Theme::Set('libraryWidget', json_encode($output)); // Also a display widget $sort_order = array('display'); $displays = $this->user->DisplayList($sort_order); $rows = array(); if (is_array($displays) && count($displays) > 0) { // Output a table showing the displays foreach ($displays as $row) { $row['mediainventorystatus'] = $row['mediainventorystatus'] == 1 ? 'success' : ($row['mediainventorystatus'] == 2 ? 'danger' : 'warning'); // Assign this to the table row $rows[] = $row; } } Theme::Set('display-widget-rows', $rows); // Get a count of users $sth = $dbh->prepare('SELECT IFNULL(COUNT(*), 0) AS count_users FROM `user`'); $sth->execute(); Theme::Set('countUsers', $sth->fetchColumn(0)); // Get a count of active layouts $sth = $dbh->prepare('SELECT IFNULL(COUNT(*), 0) AS count_scheduled FROM `schedule_detail` WHERE :now BETWEEN FromDT AND ToDT'); $sth->execute(array('now' => time())); Theme::Set('nowShowing', $sth->fetchColumn(0)); // Latest news if (Config::GetSetting('DASHBOARD_LATEST_NEWS_ENABLED') == 1) { // Make sure we have the cache location configured Kit::ClassLoader('file'); $file = new File($this->db); File::EnsureLibraryExists(); // Use SimplePie to get the feed include_once '3rdparty/simplepie/autoloader.php'; $feed = new SimplePie(); $feed->set_cache_location($file->GetLibraryCacheUri()); $feed->set_feed_url(Theme::GetConfig('latest_news_url')); $feed->set_cache_duration(86400); $feed->handle_content_type(); $feed->init(); $latestNews = array(); if ($feed->error()) { Debug::LogEntry('audit', 'Feed Error: ' . $feed->error(), get_class(), __FUNCTION__); } else { // Store our formatted items foreach ($feed->get_items() as $item) { $latestNews[] = array('title' => $item->get_title(), 'description' => $item->get_description(), 'link' => $item->get_link()); } } Theme::Set('latestNews', $latestNews); } else { Theme::Set('latestNews', array(array('title' => __('Latest news not enabled.'), 'description' => '', 'link' => ''))); } } catch (Exception $e) { Debug::LogEntry('error', $e->getMessage()); // Show the error in place of the bandwidth chart Theme::Set('widget-error', 'Unable to get widget details'); } // Do we have an embedded widget? Theme::Set('embedded-widget', html_entity_decode(Config::GetSetting('EMBEDDED_STATUS_WIDGET'))); // Render the Theme and output Theme::Render('status_dashboard'); }