=3){ if(file_exists('./data/room-cache/'.md5($room))){ $room=file_get_contents('./data/room-cache/'.md5($room)); if($room!=''){ $room=dbSingle('SELECT * FROM palvelu_p WHERE TYYPPI="'.mysql_real_escape_string($room).'";'); if($room){ $date=date('ymd',$time); $rawbookings=dbMatrix('SELECT * FROM kokousvaraus_p WHERE TYYPPI="'.mysql_real_escape_string($room['TYYPPI']).'" AND PVM="'.mysql_real_escape_string($date).'" ORDER BY AKLO;'); $bookings=array(); if($rawbookings){ foreach($rawbookings as $raw){ $stamp=strtotime(date('Y-m-d',$time).' '.$raw['LKLO'][0].$raw['LKLO'][1].':'.$raw['LKLO'][2].$raw['LKLO'][3]); $new=array(); $new['group']=array(); $new['course']=array(); if(isset($bookings[$stamp])){ $new=$bookings[$stamp]; if(trim($raw['LUOKKATUN'])!=''){ $new['group'][]=$raw['LUOKKATUN']; } if(trim($raw['KURSSITUN'])!=''){ $new['course'][]=$raw['KURSSITUN']; } } else { $new['room']=$raw['TYYPPI']; $new['title']=$raw['TILAISUUS']; if(trim($raw['LUOKKATUN'])!=''){ $new['group'][]=$raw['LUOKKATUN']; } if(trim($raw['KURSSITUN'])!=''){ $new['course'][]=$raw['KURSSITUN']; } $new['teacher']=$raw['OPETTAJANIMI']; $new['starttime']=strtotime(date('Y-m-d',$time).' '.$raw['AKLO'][0].$raw['AKLO'][1].':'.$raw['AKLO'][2].$raw['AKLO'][3]); $new['endtime']=strtotime(date('Y-m-d',$time).' '.$raw['LKLO'][0].$raw['LKLO'][1].':'.$raw['LKLO'][2].$raw['LKLO'][3]); $new['duration']=($new['endtime'] - $new['starttime'] )/60; $new['starttime']=date('H:i',$new['starttime']); $new['endtime']=date('H:i',$new['endtime']); } $new['course']=array_unique($new['course']); $new['group']=array_unique($new['group']); $bookings[$stamp]=$new; } } } else { echo 'Cannot find room ('.$room.') information!'; die(); } } else { echo 'Room information link!'; die(); } } else { echo 'Cannot find room information!'; die(); } } else { echo 'Invalid room number!'; die(); } } else { echo 'Room number not defined!'; die(); } ?>