58 lines
938 B
PHP
58 lines
938 B
PHP
|
<?php
|
||
|
|
||
|
namespace router\controller;
|
||
|
|
||
|
|
||
|
class ics{
|
||
|
|
||
|
|
||
|
private $diplome_id;
|
||
|
|
||
|
/* PRE-CALL
|
||
|
*
|
||
|
* @url<String> Calling URI
|
||
|
*
|
||
|
*/
|
||
|
public function __construct($url){
|
||
|
$this->diplome_id = $url['diplome_id'];
|
||
|
}
|
||
|
|
||
|
|
||
|
/* CALL
|
||
|
*
|
||
|
*/
|
||
|
public function download(){
|
||
|
|
||
|
/* [1] Check .ics file
|
||
|
=========================================================*/
|
||
|
/* (1) Set file name */
|
||
|
$file_name = __ROOT__."/tmp/".$this->diplome_id.".ics";
|
||
|
|
||
|
/* (2) Check if exists */
|
||
|
if( !file_exists($file_name) )
|
||
|
die("An error occured. Please contact the developers.\n");
|
||
|
|
||
|
|
||
|
/* [2] Display file
|
||
|
=========================================================*/
|
||
|
/* (1) Headers */
|
||
|
header('Content-Type: text/calendar; charset=utf-8');
|
||
|
header('Content-Disposition: attachment; filename='.$this->diplome_id);
|
||
|
|
||
|
/* (2) Body */
|
||
|
readfile($file_name);
|
||
|
|
||
|
|
||
|
}
|
||
|
|
||
|
/* POST-CALL
|
||
|
*
|
||
|
*/
|
||
|
public function __destruct(){
|
||
|
|
||
|
}
|
||
|
|
||
|
|
||
|
|
||
|
}
|