function generateTimeperiodsCfg($file=0) { PluginMonitoringToolbox::logIfExtradebug( 'pm-shinken', "Starting generateTimeperiodsCfg ...\n" ); $calendar = new Calendar(); $calendarSegment = new CalendarSegment(); $calendar_Holiday = new Calendar_Holiday(); $holiday = new Holiday(); $a_timeperiods = array(); $i=0; $a_listcalendar = $calendar->find(); foreach ($a_listcalendar as $datacalendar) { $a_timeperiods[$i]['timeperiod_name'] = $datacalendar['name']; $a_timeperiods[$i]['alias'] = $datacalendar['name']; $a_listsegment = $calendarSegment->find("`calendars_id`='".$datacalendar['id']."'"); $a_cal = array(); foreach ($a_listsegment as $datasegment) { $begin = preg_replace("/:00$/", "", $datasegment['begin']); $end = preg_replace("/:00$/", "", $datasegment['end']); $day = ""; switch ($datasegment['day']) { case "0": $day = "sunday"; break; case "1": $day = "monday"; break; case "2": $day = "tuesday"; break; case "3": $day = "wednesday"; break; case "4": $day = "thursday"; break; case "5": $day = "friday"; break; case "6": $day = "saturday"; break; } $a_cal[$day][] = $begin."-".$end; } foreach ($a_cal as $day=>$a_times) { $a_timeperiods[$i][$day] = implode(',', $a_times); } $a_cholidays = $calendar_Holiday->find("`calendars_id`='".$datacalendar['id']."'"); foreach ($a_cholidays as $a_choliday) { $holiday->getFromDB($a_choliday['holidays_id']); if ($holiday->fields['is_perpetual'] == 1 && $holiday->fields['begin_date'] == $holiday->fields['end_date']) { $datetime = strtotime($holiday->fields['begin_date']); $a_timeperiods[$i][strtolower(date('F', $datetime)). ' '.date('j', $datetime)] = '00:00-00:00'; } } $i++; } PluginMonitoringToolbox::logIfExtradebug( 'pm-shinken', "End generateTimeperiodsCfg\n" ); if ($file == "1") { $config = "# Generated by plugin monitoring for GLPI\n# on ".date("Y-m-d H:i:s")."\n\n"; foreach ($a_timeperiods as $data) { $config .= $this->writeFile("timeperiod", $data); } return array('timeperiods.cfg', $config); } else { return $a_timeperiods; } }
/** * Actions done before the DELETE of the item in the database / * Maybe used to add another check for deletion * * @return bool : true if item need to be deleted else false **/ function pre_deleteItem() { PluginMonitoringToolbox::logIfExtradebug('pm-ack', "acknowledge, pre_deleteItem : " . $this->fields['id'] . "\n"); $user = new User(); $user->getFromDB($this->fields['users_id']); $item = new $this->fields['itemtype'](); $item->getFromDB($this->fields['items_id']); $host_id = -1; $service_id = -1; if ($this->fields['itemtype'] == 'PluginMonitoringHost') { $host_id = $this->fields['items_id']; } else { $service_id = $this->fields['items_id']; } if ($host_id != -1) { // Acknowledge is to be deleted ... // ... send information to shinken via webservice $pmShinkenwebservice = new PluginMonitoringShinkenwebservice(); if ($pmShinkenwebservice->sendAcknowledge($host_id, -1, $user->getName(1), '', '', '', '', 'delete')) { // Set host as acknowledged // $pmHost = new PluginMonitoringHost(); // $pmHost->getFromDB($this->fields['plugin_monitoring_hosts_id']); // $item->setAcknowledged($this->fields['comment']); $a_services = $item->getServicesID(); if (is_array($a_services)) { foreach ($a_services as $service_id) { // Send acknowledge command for a service to shinken via webservice $pmShinkenwebservice = new PluginMonitoringShinkenwebservice(); if ($pmShinkenwebservice->sendAcknowledge(-1, $service_id, $user->getName(1), '', '', '', '', 'delete')) { // Set service as acknowledged // $pmService = new PluginMonitoringService(); // $pmService->getFromDB($service_id); // $pmService->setAcknowledged($this->fields['comment']); } } } Session::addMessageAfterRedirect(__('Acknowledge deletion notified to the monitoring application:', 'monitoring')); $this->fields['notified'] = 1; } else { Session::addMessageAfterRedirect(__('Acknowledge deletion has not been accepted by the monitoring application:', 'monitoring'), false, ERROR); // return false; } } else { // Send acknowledge command for a service to shinken via webservice $pmShinkenwebservice = new PluginMonitoringShinkenwebservice(); if ($pmShinkenwebservice->sendAcknowledge(-1, $service_id, $user->getName(1), '', '', '', '', 'delete')) { // Set service as acknowledged // $pmService = new PluginMonitoringService(); // $pmService->getFromDB($service_id); // $pmService->setAcknowledged($this->fields['comment']); Session::addMessageAfterRedirect(__('Acknowledge deletion notified to the monitoring application:', 'monitoring')); $this->fields['notified'] = 1; } else { Session::addMessageAfterRedirect(__('Acknowledge deletion has not been accepted by the monitoring application:', 'monitoring'), false, ERROR); // return false; } } return true; }
function showTabs($options = array()) { global $CFG_GLPI; PluginMonitoringToolbox::logIfExtradebug('pm', "showTabs ... no more use function ?\n"); // for objects not in table like central $ID = 0; if (isset($this->fields['id'])) { $ID = $this->fields['id']; } $target = $_SERVER['PHP_SELF']; $extraparamhtml = ""; $extraparam = ""; $withtemplate = ""; if (is_array($options) && count($options)) { if (isset($options['withtemplate'])) { $withtemplate = $options['withtemplate']; } foreach ($options as $key => $val) { $extraparamhtml .= "&{$key}={$val}"; $extraparam .= "&{$key}={$val}"; } } if (empty($withtemplate) && $ID && $this->getType() && $this->displaylist) { $glpilistitems =& $_SESSION['glpilistitems'][$this->getType()]; $glpilisttitle =& $_SESSION['glpilisttitle'][$this->getType()]; $glpilisturl =& $_SESSION['glpilisturl'][$this->getType()]; if (empty($glpilisturl)) { $glpilisturl = $this->getSearchURL(); } echo "<div id='menu_navigate'>"; $next = $prev = $first = $last = -1; $current = false; if (is_array($glpilistitems)) { $current = array_search($ID, $glpilistitems); if ($current !== false) { if (isset($glpilistitems[$current + 1])) { $next = $glpilistitems[$current + 1]; } if (isset($glpilistitems[$current - 1])) { $prev = $glpilistitems[$current - 1]; } $first = $glpilistitems[0]; if ($first == $ID) { $first = -1; } $last = $glpilistitems[count($glpilistitems) - 1]; if ($last == $ID) { $last = -1; } } } $cleantarget = Html::cleanParametersURL($target); echo "<ul>"; echo "<li><a href=\"javascript:showHideDiv('tabsbody','tabsbodyimg','" . $CFG_GLPI["root_doc"] . "/pics/deplier_down.png','" . $CFG_GLPI["root_doc"] . "/pics/deplier_up.png')\">"; echo "<img alt='' name='tabsbodyimg' src=\"" . $CFG_GLPI["root_doc"] . "/pics/deplier_up.png\">"; echo "</a></li>"; echo "<li><a href=\"" . $glpilisturl . "\">"; if ($glpilisttitle) { if (Toolbox::strlen($glpilisttitle) > $_SESSION['glpidropdown_chars_limit']) { $glpilisttitle = Toolbox::substr($glpilisttitle, 0, $_SESSION['glpidropdown_chars_limit']) . "…"; } echo $glpilisttitle; } else { echo __('List'); } echo "</a> : </li>"; if ($first > 0) { echo "<li><a href='{$cleantarget}?id={$first}{$extraparamhtml}'><img src='" . $CFG_GLPI["root_doc"] . "/pics/first.png' alt=\"" . __('First') . "\" title=\"" . __('First') . "\"></a></li>"; } else { echo "<li><img src='" . $CFG_GLPI["root_doc"] . "/pics/first_off.png' alt=\"" . __('First') . "\" title=\"" . __('First') . "\"></li>"; } if ($prev > 0) { echo "<li><a href='{$cleantarget}?id={$prev}{$extraparamhtml}'><img src='" . $CFG_GLPI["root_doc"] . "/pics/left.png' alt=\"" . __('Previous') . "\" title=\"" . __('Previous') . "\"></a></li>"; } else { echo "<li><img src='" . $CFG_GLPI["root_doc"] . "/pics/left_off.png' alt=\"" . __('Previous') . "\" title=\"" . __('Previous') . "\"></li>"; } if ($current !== false) { echo "<li>" . ($current + 1) . "/" . count($glpilistitems) . "</li>"; } if ($next > 0) { echo "<li><a href='{$cleantarget}?id={$next}{$extraparamhtml}'><img src='" . $CFG_GLPI["root_doc"] . "/pics/right.png' alt=\"" . __('Next') . "\" title=\"" . __('Next') . "\"></a></li>"; } else { echo "<li><img src='" . $CFG_GLPI["root_doc"] . "/pics/right_off.png' alt=\"" . __('Next') . "\" title=\"" . __('Next') . "\"></li>"; } if ($last > 0) { echo "<li><a href='{$cleantarget}?id={$last}{$extraparamhtml}'><img src=\"" . $CFG_GLPI["root_doc"] . "/pics/last.png\" alt=\"" . __('Last') . "\" title=\"" . __('Last') . "\"></a></li>"; } else { echo "<li><img src='" . $CFG_GLPI["root_doc"] . "/pics/last_off.png' alt=\"" . __('Last') . "\" title=\"" . __('Last') . "\"></li>"; } echo "</ul></div>"; echo "<div class='sep'></div>"; } echo "<div id='tabspanel' class='center-h'></div>"; $onglets = $this->defineTabs($options); $display_all = true; if (isset($onglets['no_all_tab'])) { $display_all = false; unset($onglets['no_all_tab']); } $class = $this->getType(); if ($_SESSION['glpi_use_mode'] == Session::DEBUG_MODE && ($ID > 0 || $this->showdebug) && (method_exists($class, 'showDebug') || in_array($class, $CFG_GLPI["infocom_types"]) || in_array($class, $CFG_GLPI["reservation_types"]))) { $onglets[-2] = __('Debug'); } if (count($onglets)) { $tabpage = $this->getTabsURL(); $tabs = array(); foreach ($onglets as $key => $val) { $tabs[$key] = array('title' => $val, 'url' => $tabpage, 'params' => "target={$target}&itemtype=" . $this->getType() . "&glpi_tab={$key}&id={$ID}{$extraparam}"); } $plug_tabs = Plugin::getTabs($target, $this, $withtemplate); $tabs += $plug_tabs; // Not all tab for templates and if only 1 tab if ($display_all && empty($withtemplate) && count($tabs) > 1) { $tabs[-1] = array('title' => __('All'), 'url' => $tabpage, 'params' => "target={$target}&itemtype=" . $this->getType() . "&glpi_tab=-1&id={$ID}{$extraparam}"); } Ajax::createTabs('tabspanel', 'tabcontent', $tabs, $this->getType(), "'100%'"); } }
static function methodShinkenGetConffiles($params, $protocol) { PluginMonitoringToolbox::logIfExtradebug( 'pm-shinken', "Starting methodShinkenGetConffiles ...\n" ); if (isset ($params['help'])) { return array('file' => 'config filename to get : commands.cfg, hosts.cfg, ... use all to get all files.', 'help' => 'bool,optional'); } if (!isset($params['tag'])) { $params['tag'] = ''; } ini_set("max_execution_time", "0"); ini_set("memory_limit", "-1"); $pmShinken = new PluginMonitoringShinken(); switch ($params['file']) { case 'commands.cfg': $array = $pmShinken->generateCommandsCfg(1); return array($array[0]=>$array[1]); break; case 'hosts.cfg': $array = $pmShinken->generateHostsCfg(1, $params['tag']); return array($array[0]=>$array[1]); break; case 'hostgroups.cfg': $array = $pmShinken->generateHostgroupsCfg(1, $params['tag']); return array($array[0]=>$array[1]); break; case 'contacts.cfg': $array = $pmShinken->generateContactsCfg(1, $params['tag']); return array($array[0]=>$array[1]); break; case 'timeperiods.cfg': $array = $pmShinken->generateTimeperiodsCfg(1, $params['tag']); return array($array[0]=>$array[1]); break; case 'services.cfg': $array = $pmShinken->generateServicesCfg(1, $params['tag']); return array($array[0]=>$array[1]); break; case 'templates.cfg': $array = $pmShinken->generateTemplatesCfg(1, $params['tag']); return array($array[0]=>$array[1]); break; case 'all': $output = array(); $array = $pmShinken->generateCommandsCfg(1); $output[$array[0]] = $array[1]; $array = $pmShinken->generateHostsCfg(1, $params['tag']); $output[$array[0]] = $array[1]; $array = $pmShinken->generateHostgroupsCfg(1, $params['tag']); $output[$array[0]] = $array[1]; $array = $pmShinken->generateContactsCfg(1, $params['tag']); $output[$array[0]] = $array[1]; $array = $pmShinken->generateTimeperiodsCfg(1, $params['tag']); $output[$array[0]] = $array[1]; $array = $pmShinken->generateTemplatesCfg(1, $params['tag']); $output[$array[0]] = $array[1]; $array = $pmShinken->generateServicesCfg(1, $params['tag']); $output[$array[0]] = $array[1]; return $output; break; } }
function plugin_monitoring_searchOptionsValues($item) { global $CFG_GLPI; // Fred : Add a log to check whether this function is still called ... PluginMonitoringToolbox::logIfExtradebug('pm', "plugin_monitoring_searchOptionsValues is called ..\n"); // Search options for services if ($item['searchoption']['table'] == 'glpi_plugin_monitoring_services' and $item['searchoption']['field'] == 'state') { $input = array(); $input['CRITICAL'] = 'CRITICAL'; $input['DOWNTIME'] = 'DOWNTIME'; $input['FLAPPING'] = 'FLAPPING'; $input['OK'] = 'OK'; $input['RECOVERY'] = 'RECOVERY'; $input['UNKNOWN'] = 'UNKNOWN'; $input['WARNING'] = 'WARNING'; Dropdown::showFromArray($item['name'], $input, array('value' => $item['value'])); return true; } else { if ($item['searchoption']['table'] == 'glpi_plugin_monitoring_services' and $item['searchoption']['field'] == 'state_type') { $input = array(); $input['HARD'] = 'HARD'; $input['SOFT'] = 'SOFT'; Dropdown::showFromArray($item['name'], $input, array('value' => $item['value'])); return true; } else { if ($item['searchoption']['table'] == 'glpi_plugin_monitoring_services' and ($item['searchoption']['field'] == 'Computer' or $item['searchoption']['field'] == 'Printer' or $item['searchoption']['field'] == 'NetworkEquipment')) { $itemtype = $item['searchoption']['field']; $use_ajax = false; if ($CFG_GLPI["use_ajax"]) { $nb = countElementsInTable("glpi_plugin_monitoring_componentscatalogs_hosts", "`itemtype`='Computer'"); if ($nb > $CFG_GLPI["ajax_limit_count"]) { $use_ajax = true; } } $params = array(); $params['itemtype'] = $itemtype; $params['searchText'] = ''; $params['myname'] = $item['name']; $params['rand'] = ''; $params['value'] = $item['value']; $default = "<select name='" . $item['name'] . "' id='dropdown_" . $item['name'] . "0'>"; if (isset($item['value']) and !empty($item['value'])) { $itemm = new $itemtype(); $itemm->getFromDB($item['value']); $default .= "<option value='" . $item['value'] . "'>" . $itemm->getName() . "</option></select>"; } Ajax::dropdown($use_ajax, "/plugins/monitoring/ajax/dropdownDevices.php", $params, $default); return true; } } } // Search options for hosts if ($item['searchoption']['table'] == 'glpi_plugin_monitoring_hosts' and $item['searchoption']['field'] == 'state') { $input = array(); $input['DOWN'] = 'DOWN'; $input['DOWNTIME'] = 'DOWNTIME'; $input['FLAPPING'] = 'FLAPPING'; $input['RECOVERY'] = 'RECOVERY'; $input['UNKNOWN'] = 'UNKNOWN'; $input['UNREACHABLE'] = 'UNREACHABLE'; $input['UP'] = 'UP'; Dropdown::showFromArray($item['name'], $input, array('value' => $item['value'])); return true; } else { if ($item['searchoption']['table'] == 'glpi_plugin_monitoring_hosts' and $item['searchoption']['field'] == 'state_type') { $input = array(); $input['HARD'] = 'HARD'; $input['SOFT'] = 'SOFT'; Dropdown::showFromArray($item['name'], $input, array('value' => $item['value'])); return true; } } }
function generateTimeperiodsCfg($file = 0, $tag = '') { global $DB; PluginMonitoringToolbox::logIfExtradebug('pm-shinken', "Starting generateTimeperiodsCfg ...\n"); $calendar = new Calendar(); $calendarSegment = new CalendarSegment(); $calendar_Holiday = new Calendar_Holiday(); $holiday = new Holiday(); $hostconfig = new PluginMonitoringHostconfig(); $pmEntity = new PluginMonitoringEntity(); // Get list of entities $a_entities_allowed = $pmEntity->getEntitiesByTag($tag); $a_entities_list = array(); foreach ($a_entities_allowed as $entity) { $a_entities_list = getSonsOf("glpi_entities", $entity); } $where = ''; if (!isset($a_entities_allowed['-1'])) { $where = getEntitiesRestrictRequest("WHERE", "glpi_entities", '', $a_entities_list); } foreach ($a_entities_list as $entities_id) { $jetlag = $hostconfig->getValueAncestor('jetlag', $entities_id); $a_entities_list[$entities_id] = $jetlag; } // Get all calendars of components $cals_entities = array(); $query = "SELECT `entities_id`, `calendars_id`\n FROM `glpi_plugin_monitoring_services`\n LEFT JOIN `glpi_plugin_monitoring_components`\n ON `plugin_monitoring_components_id` = `glpi_plugin_monitoring_components`.`id` "; if ($where == '') { $query .= "WHERE `glpi_plugin_monitoring_components`.`id` IS NOT NULL"; } else { $query .= $where . " AND `glpi_plugin_monitoring_components`.`id` IS NOT NULL"; } $result = $DB->query($query); while ($data = $DB->fetch_array($result)) { if (!isset($cals_entities[$data['entities_id']])) { $cals_entities[$data['entities_id']] = array(); } $cals_entities[$data['entities_id']][$data['calendars_id']] = $data['calendars_id']; } // get all calendars of servciescatalog $query = "SELECT `entities_id`, `calendars_id`\n FROM `glpi_plugin_monitoring_servicescatalogs` " . $where; $result = $DB->query($query); while ($data = $DB->fetch_array($result)) { if (!isset($cals_entities[$data['entities_id']])) { $cals_entities[$data['entities_id']] = array(); } $cals_entities[$data['entities_id']][$data['calendars_id']] = $data['calendars_id']; } // Get all calendars of contacts TODO $calendars_added = array(); $a_timeperiods = array(); $i = 0; foreach ($cals_entities as $entities_id => $calendars) { foreach ($calendars as $calendars_id) { $jetlag = $a_entities_list[$entities_id]; if (!isset($calendars_added[$calendars_id . "-" . $jetlag])) { $calendars_added[$calendars_id . "-" . $jetlag] = 1; $calendar->getFromDB($calendars_id); $tmp = array(); $tmp['timeperiod_name'] = $calendar->fields['name']; $tmp['alias'] = $calendar->fields['name']; $a_listsegment = $calendarSegment->find("`calendars_id`='" . $calendar->fields['id'] . "'"); $a_cal = array(); foreach ($a_listsegment as $datasegment) { $begin = preg_replace("/:00\$/", "", $datasegment['begin']); $end = preg_replace("/:00\$/", "", $datasegment['end']); $day = ""; switch ($datasegment['day']) { case "0": $day = "sunday"; break; case "1": $day = "monday"; break; case "2": $day = "tuesday"; break; case "3": $day = "wednesday"; break; case "4": $day = "thursday"; break; case "5": $day = "friday"; break; case "6": $day = "saturday"; break; } $a_cal[$day][] = $begin . "-" . $end; } foreach ($a_cal as $day => $a_times) { $tmp[$day] = implode(',', $a_times); } $a_cholidays = $calendar_Holiday->find("`calendars_id`='" . $calendar->fields['id'] . "'"); foreach ($a_cholidays as $a_choliday) { $holiday->getFromDB($a_choliday['holidays_id']); if ($holiday->fields['is_perpetual'] == 1 && $holiday->fields['begin_date'] == $holiday->fields['end_date']) { $datetime = strtotime($holiday->fields['begin_date']); $tmp[strtolower(date('F', $datetime)) . ' ' . date('j', $datetime)] = '00:00-00:00'; } } if ($jetlag == 0) { $tmp['timeperiod_name'] = $tmp['timeperiod_name']; $tmp['alias'] = $tmp['alias']; } else { $tmp['timeperiod_name'] = $tmp['timeperiod_name'] . "-" . $jetlag; $tmp['alias'] = $tmp['alias'] . "-" . $jetlag; } $days = array('sunday', 'monday', 'tuesday', 'wednesday', 'thursday', 'friday', 'saturday'); $saturday = ''; $reportHours = 0; $beforeday = 'saturday'; foreach ($days as $numday => $day) { if (isset($tmp[$day])) { $splitDay = explode(',', $tmp[$day]); $toAdd = ''; if ($reportHours > 0) { $toAdd = '00:00-' . sprintf("%02s", $reportHours) . ':00'; $reportHours = 0; } foreach ($splitDay as $num => $hourMinute) { $previous_begin = 0; $beginEnd = explode('-', $hourMinute); // ** Begin ** $split = explode(':', $beginEnd[0]); $split[0] += $jetlag; if ($split[0] > 24) { //$reportHours = $split[0] - 24; unset($splitDay[$num]); } else { if ($split[0] < 0) { $reportHours = $split[0]; $previous_begin = 24 + $split[0]; $split[0] = '00'; } $beginEnd[0] = sprintf("%02s", $split[0]) . ':' . $split[1]; // ** End ** $split = explode(':', $beginEnd[1]); $split[0] += $jetlag; if ($split[0] < 0) { if ($numday - 1 == -1) { $saturday .= "," . sprintf("%02s", $previous_begin) . ":00-" . sprintf("%02s", 24 + $split[0]) . ":00"; } else { $tmp[$days[$numday - 1]] .= "," . sprintf("%02s", $previous_begin) . ":00-" . sprintf("%02s", 24 + $split[0]) . ":00"; } unset($splitDay[$num]); } else { if ($split[0] > 24) { $reportHours = $split[0] - 24; $split[0] = 24; } $beginEnd[1] = sprintf("%02s", $split[0]) . ':' . $split[1]; $hourMinute = implode('-', $beginEnd); $splitDay[$num] = $hourMinute; } } } if ($reportHours < 0) { // if (!isset($tmp[$beforeday])) { // $tmp[$beforeday] = array(); // } // $splitBeforeDay = explode(',', $tmp[$beforeday]); // $splitBeforeDay[] = sprintf("%02s", (24 + $reportHours)).':00-24:00'; // $tmp[$beforeday] = implode(',', $splitBeforeDay); $reportHours = 0; } if (!empty($toAdd)) { array_unshift($splitDay, $toAdd); } $tmp[$day] = implode(',', $splitDay); } else { if ($reportHours > 0) { //$tmp[$day] = '00:00-'.$reportHours.':00'; $reportHours = 0; } } $beforeday = $day; } // Manage for report hours from saturday to sunday if ($reportHours > 0) { $splitDay = explode(',', $tmp['sunday']); array_unshift($splitDay, '00:00-' . sprintf("%02s", $reportHours) . ':00'); $tmp['sunday'] = implode(',', $splitDay); } if ($saturday != '') { if (isset($tmp['saturday'])) { $tmp['saturday'] .= $saturday; } else { $tmp['saturday'] = $saturday; } } // concatain if need foreach ($days as $day) { if (isset($tmp[$day])) { $splitDay = explode(',', $tmp[$day]); $beforeHour = ''; $beforeNum = 0; foreach ($splitDay as $num => $data) { if (substr($data, 0, 2) == $beforeHour) { $splitDay[$beforeNum] = substr($splitDay[$beforeNum], 0, 6) . substr($data, 6, 5); $beforeHour = substr($data, 6, 2); unset($splitDay[$num]); } else { $beforeHour = substr($data, 6, 2); $beforeNum = $num; } } $tmp[$day] = implode(',', $splitDay); } } $a_timeperiods[$i] = $tmp; $i++; } } } PluginMonitoringToolbox::logIfExtradebug('pm-shinken', "End generateTimeperiodsCfg\n"); if ($file == "1") { $config = "# Generated by plugin monitoring for GLPI\n# on " . date("Y-m-d H:i:s") . "\n\n"; foreach ($a_timeperiods as $data) { $config .= $this->writeFile("timeperiod", $data); } return array('timeperiods.cfg', $config); } else { return $a_timeperiods; } }