Webbserverprogrammering 1

Show sourcecode

The following files exists in this folder. Click to view.

webbsrvprg/exercises/projekt/incl/

addfilters.php
dbconnection.php
default.php
footer.php
header.php
playertable.php
protected.php
sort.php
stylesheet.css

addfilters.php

67 lines ASCII Windows (CRLF)
<?php
$filters 
= [];
$ownedfilters = [];
if (isset(
$owned)) {
    
$ownedfilters = [];
    
$filters = [];
    if (isset(
$_POST["submit"])) {
        if (!empty(
$_POST["agemax"]) & $_POST["agemin"] <= $_POST["agemax"] & $_POST["agemax"] != 0) {
            
$ownedfilters['maxage'] = htmlspecialchars($_POST["agemax"], ENT_QUOTES'UTF-8');
            
$ownedfilters['minage'] = htmlspecialchars($_POST["agemin"], ENT_QUOTES'UTF-8');
            if (empty(
$ownedfilters['minage'])) {
                
$ownedfilters['minage'] = 0;
            }
        }
        if (!empty(
$_POST["ratingmax"]) & $_POST["ratingmin"] <= $_POST["ratingmax"] & $_POST["ratingmax"] != 0) {
            
$ownedfilters['minrating'] = htmlspecialchars($_POST["ratingmin"], ENT_QUOTES'UTF-8');
            
$ownedfilters['maxrating'] = htmlspecialchars($_POST["ratingmax"], ENT_QUOTES'UTF-8');
            if (empty(
$ownedfilters['minrating'])) {
                
$ownedfilters['minrating'] = 0;
            }
        }
        if (!empty(
$_POST["nation"])) {
            
$ownedfilters['nation'] = htmlspecialchars($_POST["nation"], ENT_QUOTES'UTF-8');
        }
        foreach ([
"position1""position2""position3""position4"] as $pos) {
            if (!empty(
$_POST[$pos])) {
                
$ownedfilters['position'][] = htmlspecialchars($_POST[$pos], ENT_QUOTES'UTF-8');;
            }
        }
        if (!empty(
$_POST["name"])) {
            
$ownedfilters['name'] = htmlspecialchars($_POST["name"], ENT_QUOTES'UTF-8');
        }
    }
    echo 
'<script> const ownedfilters = ' json_encode($ownedfilters) . ';
const filters = 0; </script>'
;
} else {
    if (isset(
$_POST["submit"])) {
        if (!empty(
$_POST["agemax"]) & $_POST["agemin"] <= $_POST["agemax"] & $_POST["agemax"] != 0) {
            
$filters['maxage'] = htmlspecialchars($_POST["agemax"], ENT_QUOTES'UTF-8');
            
$filters['minage'] = htmlspecialchars($_POST["agemin"], ENT_QUOTES'UTF-8');
            if (empty(
$filters['minage'])) {
                
$filters['minage'] = 0;
            }
        }
        if (!empty(
$_POST["ratingmax"]) & $_POST["ratingmin"] <= $_POST["ratingmax"] & $_POST["ratingmax"] != 0) {
            
$filters['minrating'] = htmlspecialchars($_POST["ratingmin"], ENT_QUOTES'UTF-8');
            
$filters['maxrating'] = htmlspecialchars($_POST["ratingmax"], ENT_QUOTES'UTF-8');
            if (empty(
$filters['minrating'])) {
                
$filters['minrating'] = 0;
            }
        }
        if (!empty(
$_POST["nation"])) {
            
$filters['nation'] = htmlspecialchars($_POST["nation"], ENT_QUOTES'UTF-8');
        }
        foreach ([
"position1""position2""position3""position4"] as $pos) {
            if (!empty(
$_POST[$pos])) {
                
$filters['position'][] = htmlspecialchars($_POST[$pos], ENT_QUOTES'UTF-8');;
            }
        }
        if (!empty(
$_POST["name"])) {
            
$filters['name'] = htmlspecialchars($_POST["name"], ENT_QUOTES'UTF-8');
        }
    }
    echo 
'<script> const filters = ' json_encode($filters) . ';
    const ownedfilters = 0 </script>'
;
}