I've created a file directory system. here there is a function to make the directories and I want to prevent users making directories in ../ ie up one folder therefore I've created an if statement with strpos to search for it. Here's the code:
<div class="FormElement">
<form method="post">
<input type="text" name="newFolder" id="newFolder" class="newFolder"/>
<input type="submit" value="Create">
</form>
<?php
$uniqueUserPath = $_SESSION['userPath'];
$folderName = $_POST['newFolder'];
$makeFolder = $uniqueUserPath . "/" . $folderName;
// mkdir($uniqueUserPath . "/" . $folderName);
if (strpos($folderName, "../") == true) {
echo 'there is a slash.';
} else {
mkdir($uniqueUserPath . "/" . $folderName);
echo 'there isnt a slash';
}
?>
</div>
And if you type in there "../" it stil echo's there isn't a slash and more importantly it will start making the directories in a folder outside of the users folder.
Any help would be appreciated kind regards,