function LoadState() { global $state_path; if (empty($state_path)) { die("ERROR: state.ini path not yet set in server_state.php<br/>"); } // if the state ini exists, parse it $state = new ServerState(); if (file_exists($state_path)) { $state_file = parse_ini_file($state_path, true); $state->ReadBlock($state_file); } // if the update datetime is set, use it reset the bandwidth count if applicable if (!empty($state->state_time->updated_datetime)) { // get the current date and update date $current_datetime = getdate(); $updated_datetime = getdate($state->state_time->updated_datetime); // if if a day has elapsed, reset the bandwidth usage counter to 0 if ($current_datetime['year'] > $updated_datetime['year'] || $current_datetime['month'] > $updated_datetime['month'] || $current_datetime['mday'] > $updated_datetime['mday']) { // reset bandwidth usage for the day $state->server_bandwidth->bandwidth_used = 0; } } else { $state->server_bandwidth->bandwidth_used = 0; } return $state; }