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.'.ics'); /* (2) Body */ readfile($file_name); } public function info(){ /* [1] Get database data =========================================================*/ /* (1) Get the list of available events */ $sqlr = DatabaseDriver::getPDO()->prepare("SELECT * FROM event WHERE id_diplome = :idd"); $sqlr->execute([ ':idd' => $this->diplome_id ]); $d_cols = $sqlr->fetchAll(); /* (2) Manage error */ if( !$d_cols ) die("Correction not available for this diplome"); echo "
"; } public function correct(){ /* [1] Update data =========================================================*/ { /* (1) Check $_POST['name'] */ if( !isset($_POST['name']) || !is_array($_POST['name']) ) die("No data received"); /* (2) Store corrections */ foreach($_POST['name'] as $id=>$correct){ if( !empty(trim($correct)) ){ $sqlr = DatabaseDriver::getPDO()->prepare("UPDATE event SET name = :name WHERE id_event = :ide"); $sqlr->execute([ ':name' => $correct, ':ide' => $id ]); } } } } /* POST-CALL * */ public function __destruct(){ } }