function getScheduleBoinx()
 {
     $nDay = 0;
     $ret = array();
     foreach ($this->GetSchedule() as $Date => $Times) {
         $nDay++;
         $nGroup = 0;
         $n = 0;
         $OldTitle = '';
         $OldSubTitle = '';
         $OldType = '';
         $OldStart = '';
         $OldEnd = '';
         $IsTitle = false;
         $OldComment = '';
         ksort($Times);
         foreach ($Times as $Time => $Sessions) {
             foreach ($Sessions as $Session => $Distances) {
                 foreach ($Distances as $Distance => $Items) {
                     foreach ($Items as $k => $Item) {
                         $key = $Item->Day . '|' . $Time . '|' . $Session . '|' . $Distance . '|' . $Item->Order;
                         $ActiveSession = in_array($key, $this->ActiveSessions);
                         $LinTim = $Item->Start . ($Item->Duration ? '-' . addMinutes($Item->Start, $Item->Duration) : '');
                         $LinTit = '';
                         $LinSub = '';
                         $LinTxt = '';
                         if ($Item->Type == 'Z') {
                             // free text
                             $OldComment = '';
                             if ($OldTitle != $Item->Title and $Item->Title) {
                                 if (!$IsTitle) {
                                     $LinTit = $Item->Title;
                                 }
                                 $OldTitle = $Item->Title;
                                 $OldSubTitle = '';
                                 $IsTitle = true;
                             }
                             if ($OldSubTitle != $Item->SubTitle and $Item->SubTitle) {
                                 $LinSub = $Item->SubTitle;
                                 $OldSubTitle = $Item->SubTitle;
                                 $IsTitle = false;
                             }
                             if ($Item->Text) {
                                 $LinTxt = $Item->Text;
                                 $IsTitle = false;
                             }
                             $OldStart = $Item->Start;
                             $OldEnd = $Item->Duration;
                             $ret[$nDay][] = array($Item->Day, $LinTim, $LinTit, $LinSub, $LinTxt, $ActiveSession);
                         } else {
                             // all other kind of texts have a title and the items
                             if ($OldTitle != $Item->Title) {
                                 // Title
                                 if (!$IsTitle) {
                                     $LinTit = $Item->Title;
                                 }
                                 $OldTitle = $Item->Title;
                                 $OldSubTitle = '';
                                 $IsTitle = true;
                             }
                             if ($OldSubTitle != $Item->SubTitle) {
                                 // SubTitle
                                 $LinSub = $Item->SubTitle;
                                 $OldSubTitle = $Item->SubTitle;
                                 $IsTitle = false;
                             }
                             // 								$timing='';
                             // 								if($OldStart != $Item->Start or $OldEnd != $Item->Duration) {
                             // 									$timing=$Item->Start.($Item->Duration ? '-'.addMinutes($Item->Start, $Item->Duration) : '');
                             // 									$OldStart=$Item->Start;
                             // 									$OldEnd=$Item->Duration;
                             // 								}
                             $lnk = $Item->Text;
                             if (!$Item->Warmup) {
                                 // not warmup!
                                 $OldComment = '';
                                 switch ($Item->Type) {
                                     case 'Q':
                                     case 'E':
                                         $lnk = '';
                                         if ($Item->Comments) {
                                             $ret[$nDay][] = array($Item->Day, $LinTim, $LinTit, $LinSub, $Item->Comments, $ActiveSession);
                                         }
                                         if (count($this->Groups[$Item->Type][$Session]) == 1) {
                                             $txt = $Item->Text . $lnk;
                                         } elseif ($Item == @end(end(end(end($this->Groups[$Item->Type][$Session]))))) {
                                             $txt = get_text('Distance', 'Tournament') . ' ' . $Distance . $lnk;
                                         } else {
                                             $txt = get_text('Distance', 'Tournament') . ' ' . $Distance;
                                             // more distances defined so format is different...
                                         }
                                         $ret[$nDay][] = array($Item->Day, $LinTim, $LinTit, $LinSub, $txt, $ActiveSession);
                                         $IsTitle = false;
                                         break;
                                     case 'I':
                                     case 'T':
                                         $lnk = $Item->Text . ': ' . $Item->Events;
                                         $ret[$nDay][] = array($Item->Day, $LinTim, $LinTit, $LinSub, $lnk, $ActiveSession);
                                         $IsTitle = false;
                                         // 											debug_svela($Item);
                                         break;
                                     default:
                                         debug_svela($Item);
                                 }
                             } else {
                                 if ($Item->Comments) {
                                     $lnk = $Item->Comments;
                                 } else {
                                     switch ($Item->Type) {
                                         case 'I':
                                         case 'T':
                                             $lnk = $Item->Text . ': ' . $Item->Events . ' ' . 'warmup';
                                             break;
                                         default:
                                             $lnk .= ' Warmup';
                                     }
                                 }
                                 if ($OldComment == $lnk) {
                                     continue;
                                 }
                                 $OldComment = $lnk;
                                 $ret[$nDay][] = array($Item->Day, $LinTim, $LinTit, $LinSub, $lnk, $ActiveSession);
                                 $IsTitle = false;
                             }
                         }
                     }
                 }
             }
         }
     }
     // 		debug_svela($ret);
     $XmlDoc = new DOMDocument('1.0', 'UTF-8');
     $XmlRoot = $XmlDoc->createElement('schedule');
     $XmlDoc->appendChild($XmlRoot);
     foreach ($ret as $nDay => $events) {
         $Day = $XmlDoc->createElement('day' . $nDay);
         $XmlRoot->AppendChild($Day);
         $nGroup = 0;
         foreach ($events as $n => $Item) {
             if ($n % 8 == 0) {
                 $Group = $XmlDoc->createElement('groupevent' . ++$nGroup);
                 $Day->AppendChild($Group);
             }
             $Line = $XmlDoc->createElement('event' . ($n % 8 + 1));
             $Group->AppendChild($Line);
             $a = $XmlDoc->createElement('day');
             $a->AppendChild($XmlDoc->createCDATASection($Item[0]));
             $Line->AppendChild($a);
             $a = $XmlDoc->createElement('time');
             $a->AppendChild($XmlDoc->createCDATASection($Item[1]));
             $Line->AppendChild($a);
             $a = $XmlDoc->createElement('name');
             $a->AppendChild($XmlDoc->createCDATASection($Item[2]));
             $Line->AppendChild($a);
             $a = $XmlDoc->createElement('sub');
             $a->AppendChild($XmlDoc->createCDATASection($Item[3]));
             $Line->AppendChild($a);
             $a = $XmlDoc->createElement('details');
             $a->AppendChild($XmlDoc->createCDATASection($Item[4]));
             $Line->AppendChild($a);
             $a = $XmlDoc->createElement('on', $Item[5] ? 1 : 0);
             $Line->AppendChild($a);
         }
     }
     return $XmlDoc;
 }
 /**
  * Get the date slider's where
  * @return string
  */
 static function getDateSliderWhere($fName, $pSet, $cipherer, $table, $SearchFor, $SearchFor2, $strSearchOption, $fullFieldName)
 {
     $firstDelimPos = strpos($SearchFor, "-");
     $lastDelimPos = strrpos($SearchFor, "-");
     if ($firstDelimPos === FALSE || $firstDelimPos == $lastDelimPos) {
         return "";
     }
     $stepType = $pSet->getFilterStepType($fName);
     $timeValueEnvolved = false;
     if ($stepType == FSST_SECONDS || $stepType == FSST_MINUTES || $stepType == FSST_HOURS) {
         $timeValueEnvolved = true;
     }
     $value1 = $cipherer->MakeDBValue($fName, $SearchFor, "", true);
     switch ($strSearchOption) {
         case "slider":
             $firstDelimPos = strpos($SearchFor2, "-");
             $lastDelimPos = strrpos($SearchFor2, "-");
             if ($firstDelimPos === FALSE || $firstDelimPos == $lastDelimPos) {
                 return "";
             }
             $cleanvalue2 = prepare_for_db($fName, $SearchFor2, "");
             $timeArr = db2time($cleanvalue2);
             if (!$timeValueEnvolved) {
                 // for dates without time, add one day
                 $timeArr = adddays($timeArr, 1);
                 $value2 = $timeArr[0] . "-" . $timeArr[1] . "-" . $timeArr[2];
             } else {
                 if ($stepType == FSST_SECONDS) {
                     $timeArr = addSeconds($timeArr, 1);
                 } else {
                     $timeArr = addMinutes($timeArr, 1);
                 }
                 $dateString = $timeArr[0] . "-" . $timeArr[1] . "-" . $timeArr[2];
                 $hours = $timeArr[3] < 10 ? '0' . $timeArr[3] : $timeArr[3];
                 $minutes = $timeArr[4] < 10 ? '0' . $timeArr[4] : $timeArr[4];
                 $seconds = $timeArr[5] < 10 ? '0' . $timeArr[5] : $timeArr[5];
                 $timeString = $hours . ":" . $minutes . ":" . $seconds;
                 $value2 = $dateString . " " . $timeString;
             }
             $value2 = add_db_quotes($fName, $value2, $table);
             return $fullFieldName . ">=" . $value1 . " and " . $fullFieldName . "<" . $value2;
         case 'moreequal':
             return $fullFieldName . ">=" . $value1;
         case 'lessequal':
             return $fullFieldName . "<=" . $value1;
         default:
             return "";
     }
 }
/**
* Get the date-time array with particular number of seconds added
* @param {number} seconds
* @param {array} dateArray		Date-time array
* @return {array}
*/
function addSeconds($dateArray, $seconds)
{
    $minutes = floor($seconds / 60);
    if ($minutes) {
        $dateArray = addMinutes($dateArray, $minutes);
        $seconds = $seconds - $minutes * 60;
    }
    if ($dateArray[5] + $seconds < 60) {
        $dateArray[5] = $dateArray[5] + $seconds;
    } else {
        $dateArray = addMinutes($dateArray, 1);
        $dateArray[5] = $dateArray[5] + $seconds - 60;
    }
    return $dateArray;
}
$cur_user = new User();
$user = $cur_user->getUserId();
if ($user > 0) {
    session_start();
    $start = $_SESSION['start'];
    $te1 = $start->format('Y-m-d H:i:s');
    session_write_close();
    $end = new DateTime();
    $last_access = $end->format('Y-m-d H:i:s');
    $interval = $start->diff($end);
    $min = $interval->format('%i.%S');
    $min = floatval($min) + $interval->format('%h') * 60;
    $query = "select time from time where user = "******" AND prod = " . $prod . " ";
    $rslt = mysqli_query($con, $query);
    $update = 0;
    if (!$rslt) {
        die('Could not get data: ' . mysql_error());
    }
    while ($row = mysqli_fetch_row($rslt)) {
        $update = 1;
        $prv_time = $row[0];
        $min = addMinutes($min, $prv_time);
    }
    if ($update == 0) {
        $query = "INSERT INTO time(user,prod,time,last_access) VALUES (\n\t\t\t{$user},\n\t\t\t{$prod},\n\t\t\t{$min},\n\t\t\t'{$last_access}')\n\t\t\t";
    } else {
        $query = "UPDATE time \n\t\t\tSET time=" . $min . ", last_access='" . $last_access . "' \n\t\t\tWHERE user="******" AND prod=" . $prod . " ";
    }
    $rslt = mysqli_query($con, $query);
    mysqli_close($con);
}