<?php

//Hak Cipta dilindungi Undang-undang. Hak Cipta : Khamdi Rahmani, Reg. Kemenkum HAM No : 000121327. Dilarang merubah isi File tanpa ijin tertulis dari pemegang Hak Cipta. 

class csrf
{
    public function token()
    {
        $token = md5(uniqid(rand(), true));
        $_SESSION['csrf'] = $token;
        $token = "<input type='hidden' name='csrf' value='$token' hidden />";
        echo $token;
        return true;
        exit();
    }
    public function cek()
    {
        $csrf = isset($_POST['csrf']) ? $_POST['csrf'] : '';
        if (isset($_POST['csrf']) ? $_POST['csrf'] : '') {
        } else {
            $redirect = new form;
            echo $redirect->redirect('csrf', '0', '../');
            session_destroy();
            exit();
        }
        return true;
    }

    public function cekToken()
    {
        //$token = new csrf;
        $csrf = $this->cek();
        echo $csrf;
        return true;
    }
}
