Пример #1
0
 case "uploadPostImages":
     require_once "../framework/BinaryHandler.php";
     $bh = new BinaryHandler();
     $binImage = $_FILES['image'];
     $iteration = $_POST['iteration'];
     $identifier = $_POST["identifier"];
     $school = $bh->cookieCheck("sPref");
     if ($bh->getSchoolName($school) == null) {
         ### Prevent from inserting into nonexisting directory ###
         return "501: Request malformed";
     }
     echo $bh->uploadPostImages($binImage, $iteration, $identifier, $school);
     break;
 case "editPost":
     require_once "../framework2/PostQuery.php";
     $pq = new PostQuery();
     $school = filter_var($_POST["school"], FILTER_SANITIZE_STRING);
     if ($pq->getSchoolName($school) == null) {
         ### Prevent from inserting into nonexisting db ###
         return $pq->statusDump(500, "nonexisting school ID", null);
     }
     $title = $_POST["title"];
     $details = $_POST["details"];
     $price = filter_var($_POST["price"], FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION);
     $tags = $_POST["tags"];
     $identifier = $_POST["identifier"];
     $pq->editPost($title, $details, $price, $tags, $identifier, $school);
     break;
 case "addUser":
     require_once "../framework2/UserMgmt.php";
     $um = new UserMgmt();
 public function testCreateEntity()
 {
     $entity = new Post();
     $query = PostQuery::create();
     $this->assertEquals($entity, $query->createEntity());
 }
Пример #3
0
 case "uploadPostImages":
     require_once "../framework/BinaryHandler.php";
     $bh = new BinaryHandler();
     $binImage = $_FILES['image'];
     $iteration = $_POST['iteration'];
     $identifier = $_POST["identifier"];
     $school = $bh->cookieCheck("sPref");
     if ($bh->getSchoolName($school) == null) {
         ### Prevent from inserting into nonexisting directory ###
         return "501: Request malformed";
     }
     echo $bh->uploadPostImages($binImage, $iteration, $identifier, $school);
     break;
 case "editPost":
     require_once "../framework/PostQuery.php";
     $pq = new PostQuery();
     $school = filter_var($_POST["school"], FILTER_SANITIZE_STRING);
     if ($pq->getSchoolName($school) == null) {
         ### Prevent from inserting into nonexisting db ###
         return "500: Request malformed";
     }
     $title = $_POST["title"];
     $details = $_POST["details"];
     $price = filter_var($_POST["price"], FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION);
     $tags = $_POST["tags"];
     $identifier = $_POST["identifier"];
     $result = $pq->editPost($title, $details, $price, $tags, $identifier, $school);
     switch ($result) {
         case 401:
             echo "You are not authorized to do this!";
             break;
Пример #4
0
require_once 'vendor/autoload.php';
require_once 'config.php';
?>

<?php 
if (isset($_POST['submit'])) {
    $post = new Post();
    $post->setUserId($_POST['user-id']);
    $post->setPost($_POST['post']);
    $post->save();
}
?>

<?php 
//Get Posts
$posts = PostQuery::create()->orderById('desc')->find();
//Get Users
$users = UserQuery::create()->find();
?>

<!doctype html>

<html>
    <head>
        <link rel="stylesheet" href="css/bootstrap.css">
        <script src="js/jquery1.11.3.js"></script>
        <script src="js/bootstrap.js"></script>
    </head>

    <body>