server/php/basic/public_html/renkan_del.php
changeset 442 adb907bba956
child 444 19f0b7803aed
equal deleted inserted replaced
441:4732f078d0fe 442:adb907bba956
       
     1 <?php
       
     2 
       
     3     require_once(realpath(dirname(__FILE__) . "/../resources/config.php"));
       
     4 
       
     5     require_once(LIBRARY_PATH . "/templateFunctions.php");
       
     6     require_once(LIBRARY_PATH . "/utilsFunctions.php");
       
     7     require_once(LIBRARY_PATH . "/renkanFunctions.php");
       
     8     require_once(LIBRARY_PATH . "/dbFunctions.php");
       
     9 
       
    10     $self_url = selfURL();
       
    11     $index_url = selfBaseURL().'/index.php';
       
    12 
       
    13     if ($_SERVER['REQUEST_METHOD'] === 'PUT' || $_SERVER['REQUEST_METHOD'] === 'POST') {
       
    14 
       
    15         //TODO implement CSRF with https://github.com/BKcore/NoCSRF for example
       
    16         $renkanId = isset($_POST['renkanId']) ? $_POST['renkanId'] : false;
       
    17 
       
    18         if(!empty($renkanId)) {
       
    19             deleteProject($renkanId);
       
    20         }
       
    21         header("Location: $index_url");
       
    22         die();
       
    23     }
       
    24 
       
    25     if(!isset($_GET['renkanId'])) {
       
    26         header("Location: $index_url");
       
    27         die();
       
    28     }
       
    29     $renkanId = $_GET['renkanId'];
       
    30     $resRenkan = selectProject($renkanId);
       
    31 
       
    32     if(count($resRenkan) === 0) {
       
    33         header("Location: $index_url");
       
    34         die();
       
    35     }
       
    36 
       
    37     $variables = [ 'renkan' => $resRenkan[0], 'self_url' => selfURL(), 'self_base_url' => selfBaseURL()];
       
    38     $css = [];
       
    39 
       
    40     renderLayoutWithContentFile("renkan_del.php", $variables, $css);