Validate parameters
This commit is contained in:
parent
60affcdb64
commit
cba9bd2a7d
10
php/api.php
10
php/api.php
@ -55,12 +55,16 @@ if (!empty($_POST['function'])||!empty($_GET['function'])) {
|
||||
// Get Settings
|
||||
$settings = getSettings();
|
||||
|
||||
// Security
|
||||
if (isset($_POST['albumID'])&&($_POST['albumID']==''||$_POST['albumID']<0||$_POST['albumID']>10000)) exit('Error: Wrong parameter type for albumID!');
|
||||
if (isset($_POST['photoID'])&&$_POST['photoID']=='') exit('Error: Wrong parameter type for photoID!');
|
||||
// Escape
|
||||
foreach(array_keys($_POST) as $key) $_POST[$key] = mysqli_real_escape_string($database, urldecode($_POST[$key]));
|
||||
foreach(array_keys($_GET) as $key) $_GET[$key] = mysqli_real_escape_string($database, urldecode($_GET[$key]));
|
||||
|
||||
// Validate parameters
|
||||
if (isset($_POST['albumIDs'])&&preg_match('/^[0-9\,]{1,}$/', $_POST['albumIDs'])!==1) exit('Error: Wrong parameter type for albumIDs!');
|
||||
if (isset($_POST['photoIDs'])&&preg_match('/^[0-9\,]{1,}$/', $_POST['photoIDs'])!==1) exit('Error: Wrong parameter type for photoIDs!');
|
||||
if (isset($_POST['albumID'])&&preg_match('/^[0-9sf]{1,}$/', $_POST['albumID'])!==1) exit('Error: Wrong parameter type for albumID!');
|
||||
if (isset($_POST['photoID'])&&preg_match('/^[0-9]{14}$/', $_POST['photoID'])!==1) exit('Error: Wrong parameter type for photoID!');
|
||||
|
||||
if (isset($_SESSION['login'])&&$_SESSION['login']==true) {
|
||||
|
||||
/**
|
||||
|
Loading…
Reference in New Issue
Block a user