<?php require_once 'D:\\self\\trainings\\Dropbox\\szkolenie\\v 2.0\\code\\Eagles\\includePathSetter.php'; require_once 'TrainingFive/Database/DbHandle.php'; require_once 'TrainingFive/Database/DbInsert.php'; $dbHandle = new DbHandle(); $result = array(); if (isset($_GET['resType']) && $_GET['resType'] == 'auth') { $result = $dbHandle->GetData('select * from authors;'); } if (isset($_GET['resType']) && $_GET['resType'] == 'tests') { $result = $dbHandle->GetData('select * from testsresultsview;'); } header('Content-type: application/json'); echo json_encode($result);
// xsrf //session cookie // perla -> localhost, zal, przeg cookie sesyjne ADMIN //$salt = 'hewuoghwdpfweighweipghrgweighwerigri'; // dhsafgad sghdafgdhif/ // $token = md5( $_COOKIE['PHPSESSID'] . $salt); // rozne // E&A // bartek -> alamakota localhost/zapytania.php facebook.com, formularz $_POST method post name ? input ? x.php zapytanie.php POST name = user id privileges = 128 USER token = $token // zapytanie.php if ($_SESSION['uzy_prawa'] == xyz) { } if (post [tok] === md5($_COOKIE['PHPSESSID'] . $salt)) //echo '55'; if (isset($_POST['zatwierdz'])) { require_once 'D:\\self\\trainings\\Dropbox\\szkolenie\\v 2.0\\code\\Eagles\\includePathSetter.php'; require_once 'TrainingFive/Database/DbHandle.php'; require_once 'TrainingFive/Database/DbUpdate.php'; $dbUpdate = new DbUpdate(); $dbHandle = new DbHandle(); $dbHandle->Connect(); $update = $dbUpdate->RenderQuery('applicationtests', array('codesnipet' => $_POST['yourcode'], 'rightanswers' => pg_escape_string($dbHandle->connectionHandle, $_POST['youranswer']))); $dbHandle->SetData($update); } ?> <form method="post" action="/"> <input type="text" name="yourcode" placeholder="type your code" /> <input type="text" name="youranswer" placeholder="type your answer" /> <input type="submit" name="zatwierdz" /> </form>