'%supplier% %event%', 'description' => '', 'choices' => [], 'start' => 'now 00:00:00', 'end' => '+1 year', 'frequency' => '1 day', ], $config[$supplier] ); $action = isset($_REQUEST['action']) ? $_REQUEST['action'] : null; $hasEvent = isset($_REQUEST['event']); if (!$hasEvent) { $now = new \DateTime('now'); $current = new \DateTime($config[$supplier]['start']); $frequency = \DateInterval::createFromDateString($config[$supplier]['frequency']); $maxIterations = 1000; while ( ($current->getTimestamp() < $now->getTimestamp()) and ($maxIterations-- > 0) ) $current->add($frequency); $nextEvent = $current->format('Y-m-d'); header(sprintf('Location: %s?supplier=%s&event=%s', $requestUrl, $supplier, $nextEvent)); die(); } $event = $_REQUEST['event']; switch ($action) { case 'insert' : case 'delete' : $isBeginning = (!file_exists(DATA_FILE) or in_array(filesize(DATA_FILE), [ false, 0 ])); $output = fopen(DATA_FILE, 'a+'); if (!$output) break; if (!flock($output, LOCK_EX)) break; if ($isBeginning) fwrite($output, ' $prevItem) if ($prevItem['hash'] === $item['hash']) unset($items[$index]); } } while (preg_match('/%([^%]+)%/i', $config[$supplier]['title'], $match)) $config[$supplier]['title'] = str_replace( $match[0], ${$match[1]}, $config[$supplier]['title'] ); ?>