<commit_before><?php
require_once "../common.php";
require_once "../g-settings.php";

$cal_id = "<EMAIL>";

if(isset($_POST['action'])){
    switch($_POST['action']){
    case "get":
        echo json_encode(processEvents());
        break;
    case "getNew": //TODO: Js handling & inf scroll
        if(isset($_POST['eid']) && isset($_POST['timeMin'])){
            echo json_encode(processEvents("",$_POST['timeMin'],0,$_POST['eid']));
        }else echo "Insufficient data was supplied for the request.";
        break;
    case "getOld": //TODO: Js handling & inf scroll
        if(isset($_POST['timeMax']) && isset($_POST['eid'])){
            echo json_encode(processEvents($_POST['timeMax'],"",0,$_POST['eid']));
        }else echo "Insufficient data was supplied for the request.";
        break;
    default:
        echo "Invalid action.";
    }
}else echo "No action defined.";

function processEvents($time_min = "-7 days", $time_max = "", $max_results = 0, $eidL = -1){
    
    global $cal_id, $service, $timeOverrideEnd, $timeOverrideStart;
        
    $lDate = new DateTime();
    $lDate->modify($time_min);

    $cal = $service->calendars->get($cal_id);

    $optParams = array(
      'orderBy' => 'startTime',
      'singleEvents' => true,
      'timeMin' => $lDate->format('c')
    );
    
    if ($max_results != 0) $optParams['maxResults'] = $max_results;
    if ($time_max != "") $optParams['timeMax'] = $time_max;

    $events = $service->events->listEvents($cal->id, $optParams);

    $event_arr = array(array());
    $page_html = "";
    $eid = $eidL + 1;
    
    $pull_arr = $events->getItems();
    array_reverse($pull_arr);
    
    foreach ($pull_arr as $event) {    

        $event_arr[$eid]['title'] = $event->getSummary();
        $event_arr[$eid]['desc'] = $event->getDescription();
        $event_arr[$eid]['location'] = $event->getLocation();
        $event_arr[$eid]['date'] = processEventDate($event->getStart(),$event->getEnd());
        $event_arr[$eid]['start'] = $event->getStart();
        $event_arr[$eid]['end'] = $event->getEnd();
        $event_arr[$eid]['color'] = $event->getColorId();
        $event_arr[$eid]['attachments'] = $event->getAttachments();

        switch($event_arr[$eid]['color']){
            case "10": $color_class = "sci-gr"; break;
            case "9": $color_class = "tch-bl"; break;
            case "11": $color_class = "egr-or"; break;
            case "5": $color_class = "mth-ye"; break;<commit_msg>Forgot how to variable<commit_after><?php
require_once "../common.php";
require_once "../g-settings.php";

$cal_id = "<EMAIL>";

if(isset($_POST['action'])){
    switch($_POST['action']){
    case "get":
        echo json_encode(processEvents());
        break;
    case "getNew": //TODO: Js handling & inf scroll
        if(isset($_POST['eid']) && isset($_POST['timeMin'])){
            echo json_encode(processEvents("",$_POST['timeMin'],0,$_POST['eid']));
        }else echo "Insufficient data was supplied for the request.";
        break;
    case "getOld": //TODO: Js handling & inf scroll
        if(isset($_POST['timeMax']) && isset($_POST['eid'])){
            echo json_encode(processEvents($_POST['timeMax'],"",0,$_POST['eid']));
        }else echo "Insufficient data was supplied for the request.";
        break;
    default:
        echo "Invalid action.";
    }
}else echo "No action defined.";

function processEvents($time_min = "-7 days", $time_max = "", $max_results = 0, $eidL = -1){
    
    global $cal_id, $service, $timeOverrideEnd, $timeOverrideStart;
        
    $lDate = new DateTime();
    $lDate->modify($time_min);

    $cal = $service->calendars->get($cal_id);

    $optParams = array(
      'orderBy' => 'startTime',
      'singleEvents' => true,
      'timeMin' => $lDate->format('c')
    );
    
    if ($max_results != 0) $optParams['maxResults'] = $max_results;
    if ($time_max != "") $optParams['timeMax'] = $time_max;

    $events = $service->events->listEvents($cal->id, $optParams);

    $event_arr = array(array());
    $page_html = "";
    $eid = $eidL + 1;
    
    $pull_arr = $events->getItems();
    $pull_arr = array_reverse($pull_arr);
    
    foreach ($pull_arr as $event) {    

        $event_arr[$eid]['title'] = $event->getSummary();
        $event_arr[$eid]['desc'] = $event->getDescription();
        $event_arr[$eid]['location'] = $event->getLocation();
        $event_arr[$eid]['date'] = processEventDate($event->getStart(),$event->getEnd());
        $event_arr[$eid]['start'] = $event->getStart();
        $event_arr[$eid]['end'] = $event->getEnd();
        $event_arr[$eid]['color'] = $event->getColorId();
        $event_arr[$eid]['attachments'] = $event->getAttachments();

        switch($event_arr[$eid]['color']){
            case "10": $color_class = "sci-gr"; break;
            case "9": $color_class = "tch-bl"; break;
            case "11": $color_class = "egr-or"; break;
            case "5": $color_class = "mth-ye"; break;
{'fraction_non_alphanumeric': 0.2029334940727346, 'fraction_numerical': 0.005224030540486237, 'mean_word_length': 3.1483333333333334, 'pattern_counts': {'":': 14, '<': 7, '<?xml version=': 0, '>': 45, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1513425', 'n_tokens_mistral': 1647, 'n_tokens_neox': 1628, 'n_words': 313}