events.php error template forest

MichaelxD

New Member
Feb 18, 2019
2
0
1
27
hola, desde hace un tiempo compre el template forest últimamente me lanza siguiente error

[30-Jun-2020 23:38:19 UTC] PHP Notice: Undefined index: time in /hoxxxx/WebEngine/api/events.php on line 189
[30-Jun-2020 23:38:19 UTC] PHP Notice: Undefined index: time in /hoxxxx/WebEngine/api/events.php on line 190

abajo el código, alguno me puede iluminar a ver porque da error?

PHP:
<?php
/**
 * WebEngine CMS
 * https://webenginecms.org/
 *
 * @version 1.2.0
 * @author Lautaro Angelico <http://lautaroangelico.com/>
 * @copyright (c) 2013-2019 Lautaro Angelico, All Rights Reserved
 *
 * Licensed under the MIT license
 * http://opensource.org/licenses/MIT
 */

// PHP Timezone
// http://php.net/manual/en/timezones.php
date_default_timezone_set('UTC');

$eventTimes = array(
    'bloodcastle' => array(
        'name' => 'Blood Castle',
        'opentime' => 300,
        'duration' => 0,
        'schedule' => array(
            '00:00','02:00','04:00','06:00','08:00','10:00','12:00','14:00','16:00','18:00','20:00','22:00',
        ),
    ),
    'devilsquare' => array(
        'name' => 'Devil Square',
        'opentime' => 300,
        'duration' => 0,
        'schedule' => array(
            '00:25','02:25','04:25','06:25','08:25','10:25','12:25','14:25','16:25','18:25','20:25','22:25',
        ),
    ),
    'chaoscastle' => array(
        'name' => 'Chaos Castle',
        'opentime' => 300,
        'duration' => 0,
        'schedule' => array(
            '01:00','05:00','09:00','13:00','17:00','21:00',
        ),
    ),
    'goldeninvasion' => array(
        'name' => 'Golden Invasion',
        'opentime' => 0,
        'duration' => 900,
        'schedule' => array(
            '00:25','04:25','08:25','12:25','16:25','20:25',
        ),
    
    ),
'crywolf' => array(
        'name' => 'Estatua Sagrada de CryWolf',
        'opentime' => 300,
        'duration' => 0,
        'day' => 'Thursday','Sunday',
        'schedule' => array(
            '20:30',
        ),
    ),
    'dg' => array(
        'name' => 'DoubleGoer',
        'opentime' => 300,
        'duration' => 0,
        'schedule' => array(
            '00:25','04:25','08:25','12:25','16:25','20:25',
        ),
            ),
    'ww' => array(
        'name' => 'Mago Blanco',
        'opentime' => 300,
        'duration' => 0,
        'schedule' => array(
            '00:50','04:50','08:50','12:50','16:50','20:50',
        ),
                    ),
    'Medusa' => array(
        'name' => 'Medusa',
        'opentime' => 300,
        'duration' => 0,
        'schedule' => array(
            '01:00','13:00',
        ),
                            ),
    'Summon' => array(
        'name' => 'Summon',
        'opentime' => 300,
        'duration' => 0,
        'schedule' => array(
            '01:25','05:25','09:25','13:25','17:25','21:25',
        ),
                            ),
    'Egg' => array(
        'name' => 'Evento Muun',
        'opentime' => 300,
        'duration' => 0,
        'schedule' => array(
            '01:50','05:50','09:50','13:50','17:50','21:50',
        ),
            ),
            'CL' => array(
        'name' => 'Conejo Lunar',
        'opentime' => 300,
        'duration' => 0,
        'schedule' => array(
            '02:15','06:15','10:15','14:15','18:15','22:15',
        ),
        ),
            'mm' => array(
        'name' => 'Moss Merchant',
        'opentime' => 300,
        'duration' => 0,
                'day' => 'Sunday',
        'schedule' => array(
            '02:0','04:00','14:00','20:00',
        ),
                ),
            'cd' => array(
        'name' => 'Castle Deep',
        'opentime' => 300,
        'duration' => 0,
        'schedule' => array(
            '04:0','12:00','20:00',
        ),
        
    ),
);

// DO NOT EDIT BELOW THIS LINE
// DO NOT EDIT BELOW THIS LINE
// DO NOT EDIT BELOW THIS LINE

function getEventNextTime($eventSchedule) {
    $currentTime = date("H:i");
    foreach($eventSchedule as $time) {
        if($time > $currentTime) {
            return date("Y-m-d ") . $time;
        }
    }
    $tomorrow = date('d', strtotime('tomorrow'));
    return date("Y-m-$tomorrow ") . $eventSchedule[0];
}

function getEventPreviousTime($eventSchedule) {
    $currentTime = date("H:i");
    foreach($eventSchedule as $key => $time) {       
        if($time > $currentTime) {
            $last = $key-1;
            if($last < 0) {
                $yesterday = date('d', strtotime('yesterday'));
                return date("Y-m-$yesterday ") . end($eventSchedule);
            }
            return date("Y-m-d ") . $eventSchedule[$last];
            return;
        }
    }
    return date("Y-m-d ") . end($eventSchedule);
}

function getWeeklyEventNextTime($day, $time) {
    $currentDay = strtolower(date("l"));
    $currentTime = date("H:i");
    if($currentDay == strtolower($day)) {
        if($currentTime < $time) {
            return date("Y-m-d H:i", strtotime('today '.$time.''));
        }
    }
    return date("Y-m-d H:i", strtotime('next '.$day.' '.$time.''));
}

function getWeeklyEventPreviousTime($day, $time) {
    $currentDay = strtolower(date("l"));
    $currentTime = date("H:i");
    if($currentDay == strtolower($day)) {
        if($currentTime > $time) {
            return date("Y-m-d H:i", strtotime('today '.$time.''));
        }
    }
    return date("Y-m-d H:i", strtotime('last '.$day.' '.$time.''));
}

foreach($eventTimes as $eventId => $event) {
    $active = 0;
    $open = 0;
    if(!array_key_exists('day', $event)) {
        $lastTime = getEventPreviousTime($event['schedule']);
        $nextTime = getEventNextTime($event['schedule']);
    } else {
        $lastTime = getWeeklyEventPreviousTime($event['day'], $event['time']); <______________Linea de error
        $nextTime = getWeeklyEventNextTime($event['day'], $event['time']);     <______________Linea de error
    }
    $nextTimeF = date("D g:i A", strtotime($nextTime));
    $offset = strtotime($nextTime)-strtotime($lastTime);
    $timeLeft = strtotime($nextTime)-time();
    
    $result[$eventId] = array(
        'event' => $event['name'],
        'opentime' => $event['opentime'],
        'duration' => $event['duration'],
        'last' => $lastTime,
        'next' => $nextTime,
        'nextF' => $nextTimeF,
        'offset' => $offset,
        'timeleft' => $timeLeft,
    );
}

if(isset($_GET['event'])) {
    if(array_key_exists($_GET['event'], $result)) {
        $result = $result[$_GET['event']];
    }
}

http_response_code(200);
header('Content-Type: application/json');
echo json_encode($result, JSON_PRETTY_PRINT);