Projekt

Obecné

Profil

« Předchozí | Další » 

Revize f95d4d7c

Přidáno uživatelem Tomáš Pašek před téměř 4 roky(ů)

Feature #8636 Zabezpečení metod

Zobrazit rozdíly:

application/controller/DeleteUserController.php
1 1
<?php
2 2
require "../model/DB.php";
3 3

  
4
$DB = new DB();
4
session_start();
5 5

  
6
$result = $DB->deleteUser($_POST['userId']);
6
if (array_key_exists("loggedIn", $_SESSION) && $_SESSION['loggedIn'] == "true" && array_key_exists("role", $_SESSION) && $_SESSION['role'] == "admin") {
7
    $DB = new DB();
8
    $result = $DB->deleteUser($_POST['userId']);
9
}
application/controller/GetChangeRequests.php
1 1
<?php
2 2
require "../model/DB.php";
3
$DB = new DB();
3
session_start();
4
if (array_key_exists("loggedIn", $_SESSION) && $_SESSION['loggedIn'] == "true") {
5
    $DB = new DB();
6
    $results = $DB->getChangeRequests();
4 7

  
5
$results = $DB->getChangeRequests();
6

  
7
echo json_encode(count($results)==0 ? null : $results);
8
    echo json_encode(count($results) == 0 ? null : $results);
9
}
application/controller/InsertController.php
1 1
<?php
2 2
require "../model/DB.php";
3

  
4
$DB = new DB();
5
$DB->insert();
3
session_start();
4
if (array_key_exists("loggedIn", $_SESSION) && $_SESSION['loggedIn'] == "true") {
5
    $DB = new DB();
6
    $DB->insert();
7
}
application/controller/RegistrationController.php
1 1
<?php
2 2
require "../model/DB.php";
3
$DB = new DB();
3
session_start();
4
if (array_key_exists("loggedIn", $_SESSION) && $_SESSION['loggedIn'] == "true" && array_key_exists("role", $_SESSION) && $_SESSION['role'] == "admin") {
5
    $DB = new DB();
4 6

  
5
$result = $DB->createUser($_POST);
7
    $result = $DB->createUser($_POST);
8
}
application/controller/RemoveChangeRequest.php
1 1
<?php
2 2
require "../model/DB.php";
3
$DB = new DB();
3
session_start();
4
if (array_key_exists("loggedIn", $_SESSION) && $_SESSION['loggedIn'] == "true") {
5
    $DB = new DB();
4 6

  
5
$DB->removeChangeRequest($_POST["requestId"]);
7
    $DB->removeChangeRequest($_POST["requestId"]);
8
}
application/controller/RemoveController.php
1 1
<?php
2 2
require "../model/DB.php";
3
$DB = new DB();
4
$DB->remove();
3
session_start();
4

  
5
if (array_key_exists("loggedIn", $_SESSION) && $_SESSION['loggedIn'] == "true") {
6
    $DB = new DB();
7
    $DB -> remove();
8
}
application/controller/UpdateController.php
1 1
<?php
2 2
require "../model/DB.php";
3
session_start();
3 4

  
4
$DB = new DB();
5
$DB->update();
5
if (array_key_exists("loggedIn", $_SESSION) && $_SESSION['loggedIn'] == "true") {
6
    $DB = new DB();
7
    $DB->update();
8
}
application/controller/UpdateUserRoleController.php
1 1
<?php
2 2
require "../model/DB.php";
3 3
session_start();
4
if ($_SESSION['role'] == "admin") {
4

  
5
if (array_key_exists("loggedIn", $_SESSION) && $_SESSION['loggedIn'] == "true" && array_key_exists("role", $_SESSION) && $_SESSION['role'] == "admin") {
5 6
    $DB = new DB();
6 7

  
7 8
    $results = $DB->updateUserRole($_POST["userId"], $_POST["role"]);
8 9

  
9 10
    echo json_encode(count($results) == 0 ? null : $results);
10 11
}
12

  
application/controller/UsersListController.php
2 2
require "../model/DB.php";
3 3
session_start();
4 4

  
5
if ($_SESSION['role'] == "admin") {
5
if (array_key_exists("loggedIn", $_SESSION) && $_SESSION['loggedIn'] == "true" && array_key_exists("role", $_SESSION) && $_SESSION['role'] == "admin") {
6 6
    $DB = new DB();
7 7

  
8 8
    $results = $DB->select("SELECT id, username, role from USERS", array());
application/model/DB.php
703 703

  
704 704
    }
705 705

  
706
    function remove(){
707
        // ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||| Tabulka dd_manuscript |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
708
        if (array_key_exists("id", $_POST) && $_POST['id'] != "") {
709
            $query = "DELETE FROM dd_manuscript WHERE";
710
            $query .= " wordform_id = :wordform_id ;";
711
            $this->stmt = $this->pdo->prepare($query);
712
            $this->stmt->bindParam(':wordform_id', $_POST['id'], PDO::PARAM_INT);
713
            $this->stmt->execute();
714
        }
706 715

  
707
}
708

  
709
function remove(){
710
    // ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||| Tabulka dd_manuscript |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
711
    if (array_key_exists("id", $_POST) && $_POST['id'] != "") {
712
        $query = "DELETE FROM dd_manuscript WHERE";
713
        $query .= " wordform_id = :wordform_id ;";
714
        $this->stmt = $this->pdo->prepare($query);
715
        $this->stmt->bindParam(':wordform_id', $_POST['id'], PDO::PARAM_INT);
716
        $this->stmt->execute();
717
    }
718

  
719
    // ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||| Tabulka dd_lemma |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
716
        // ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||| Tabulka dd_lemma |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
720 717

  
721 718
        /*if (array_key_exists("lemma", $_POST) && $_POST['lemma'] != "") {
722 719
            $query = "DELETE FROM dd_lemma WHERE";
......
725 722
            $this->stmt->bindParam(':lemma_id', $lemma["id"], PDO::PARAM_INT);
726 723
            $this->stmt->execute();
727 724
        } TODO: fix lemma*/
728
    // ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||| Tabulka dd_tag |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
725
        // ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||| Tabulka dd_tag |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
729 726

  
730 727
        /*if (array_key_exists("tag", $_POST) && $_POST['tag'] != "") {
731 728
            $query = "DELETE FROM dd_tag WHERE";
......
735 732
            $this->stmt->execute();
736 733
        } TODO: fix tag */
737 734

  
738
    // ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||| Tabulka dd_wordform |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
739
    if (array_key_exists("id", $_POST) && $_POST['id'] != "") {
740
        $query = "DELETE FROM dd_wordform WHERE";
741
        $query .= " id = :id ;";
742
        $this->stmt = $this->pdo->prepare($query);
743
        $this->stmt->bindParam(':id', $_POST['id'], PDO::PARAM_INT);
744
        $this->stmt->execute();
735
        // ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||| Tabulka dd_wordform |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
736
        if (array_key_exists("id", $_POST) && $_POST['id'] != "") {
737
            $query = "DELETE FROM dd_wordform WHERE";
738
            $query .= " id = :id ;";
739
            $this->stmt = $this->pdo->prepare($query);
740
            $this->stmt->bindParam(':id', $_POST['id'], PDO::PARAM_INT);
741
            $this->stmt->execute();
742
        }
745 743
    }
744

  
746 745
}
747 746

  
748 747
// (D) DATABASE SETTINGS - CHANGE TO YOUR OWN!
......
750 749
define('DB_NAME', 'dalimil2');
751 750
define('DB_CHARSET', 'utf8');
752 751
define('DB_USER', 'postgres');
753
define('DB_PASSWORD', 'x');
752
define('DB_PASSWORD', 'a');

Také k dispozici: Unified diff