Refactor input validation
This commit is contained in:
parent
048bf2d0aa
commit
e075714d12
@ -1,13 +1,9 @@
|
|||||||
<?php
|
<?php
|
||||||
require_once '../../includes/connect_endpoint.php';
|
require_once '../../includes/connect_endpoint.php';
|
||||||
|
require_once '../../includes/inputvalidation.php';
|
||||||
|
|
||||||
session_start();
|
session_start();
|
||||||
function validate($value) {
|
|
||||||
$value = trim($value);
|
|
||||||
$value = stripslashes($value);
|
|
||||||
$value = htmlspecialchars($value);
|
|
||||||
$value = htmlentities($value);
|
|
||||||
return $value;
|
|
||||||
}
|
|
||||||
if (isset($_SESSION['loggedin']) && $_SESSION['loggedin'] === true) {
|
if (isset($_SESSION['loggedin']) && $_SESSION['loggedin'] === true) {
|
||||||
if (isset($_GET['action']) && $_GET['action'] == "add") {
|
if (isset($_GET['action']) && $_GET['action'] == "add") {
|
||||||
$categoryName = "Category";
|
$categoryName = "Category";
|
||||||
|
|||||||
@ -1,13 +1,9 @@
|
|||||||
<?php
|
<?php
|
||||||
require_once '../../includes/connect_endpoint.php';
|
require_once '../../includes/connect_endpoint.php';
|
||||||
|
require_once '../../includes/inputvalidation.php';
|
||||||
|
|
||||||
session_start();
|
session_start();
|
||||||
function validate($value) {
|
|
||||||
$value = trim($value);
|
|
||||||
$value = stripslashes($value);
|
|
||||||
$value = htmlspecialchars($value);
|
|
||||||
$value = htmlentities($value);
|
|
||||||
return $value;
|
|
||||||
}
|
|
||||||
if (isset($_SESSION['loggedin']) && $_SESSION['loggedin'] === true) {
|
if (isset($_SESSION['loggedin']) && $_SESSION['loggedin'] === true) {
|
||||||
if (isset($_GET['action']) && $_GET['action'] == "add") {
|
if (isset($_GET['action']) && $_GET['action'] == "add") {
|
||||||
$currencyName = "Currency";
|
$currencyName = "Currency";
|
||||||
|
|||||||
@ -1,13 +1,9 @@
|
|||||||
<?php
|
<?php
|
||||||
require_once '../../includes/connect_endpoint.php';
|
require_once '../../includes/connect_endpoint.php';
|
||||||
|
require_once '../../includes/inputvalidation.php';
|
||||||
|
|
||||||
session_start();
|
session_start();
|
||||||
function validate($value) {
|
|
||||||
$value = trim($value);
|
|
||||||
$value = stripslashes($value);
|
|
||||||
$value = htmlspecialchars($value);
|
|
||||||
$value = htmlentities($value);
|
|
||||||
return $value;
|
|
||||||
}
|
|
||||||
if (isset($_SESSION['loggedin']) && $_SESSION['loggedin'] === true) {
|
if (isset($_SESSION['loggedin']) && $_SESSION['loggedin'] === true) {
|
||||||
if (isset($_GET['action']) && $_GET['action'] == "add") {
|
if (isset($_GET['action']) && $_GET['action'] == "add") {
|
||||||
$householdName = "Member";
|
$householdName = "Member";
|
||||||
|
|||||||
@ -1,6 +1,8 @@
|
|||||||
<?php
|
<?php
|
||||||
error_reporting(E_ERROR | E_PARSE);
|
error_reporting(E_ERROR | E_PARSE);
|
||||||
require_once '../../includes/connect_endpoint.php';
|
require_once '../../includes/connect_endpoint.php';
|
||||||
|
require_once '../../includes/inputvalidation.php';
|
||||||
|
|
||||||
session_start();
|
session_start();
|
||||||
|
|
||||||
function sanitizeFilename($filename) {
|
function sanitizeFilename($filename) {
|
||||||
@ -9,13 +11,6 @@
|
|||||||
return $filename;
|
return $filename;
|
||||||
}
|
}
|
||||||
|
|
||||||
function validate($value) {
|
|
||||||
$value = trim($value);
|
|
||||||
$value = stripslashes($value);
|
|
||||||
$value = htmlspecialchars($value);
|
|
||||||
$value = htmlentities($value);
|
|
||||||
return $value;
|
|
||||||
}
|
|
||||||
function getLogoFromUrl($url, $uploadDir, $name) {
|
function getLogoFromUrl($url, $uploadDir, $name) {
|
||||||
|
|
||||||
$ch = curl_init($url);
|
$ch = curl_init($url);
|
||||||
|
|||||||
@ -1,14 +1,8 @@
|
|||||||
<?php
|
<?php
|
||||||
require_once '../../includes/connect_endpoint.php';
|
require_once '../../includes/connect_endpoint.php';
|
||||||
session_start();
|
require_once '../../includes/inputvalidation.php';
|
||||||
|
|
||||||
function validate($value) {
|
session_start();
|
||||||
$value = trim($value);
|
|
||||||
$value = stripslashes($value);
|
|
||||||
$value = htmlspecialchars($value);
|
|
||||||
$value = htmlentities($value);
|
|
||||||
return $value;
|
|
||||||
}
|
|
||||||
|
|
||||||
function update_exchange_rate($db) {
|
function update_exchange_rate($db) {
|
||||||
$query = "SELECT api_key FROM fixer";
|
$query = "SELECT api_key FROM fixer";
|
||||||
|
|||||||
11
includes/inputvalidation.php
Normal file
11
includes/inputvalidation.php
Normal file
@ -0,0 +1,11 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
function validate($value) {
|
||||||
|
$value = trim($value);
|
||||||
|
$value = stripslashes($value);
|
||||||
|
$value = htmlspecialchars($value);
|
||||||
|
$value = htmlentities($value);
|
||||||
|
return $value;
|
||||||
|
}
|
||||||
|
|
||||||
|
?>
|
||||||
Loading…
Reference in New Issue
Block a user