[ create a new paste ] login | about

Link: http://codepad.org/XLXsBHh7    [ raw code | output | fork ]

PHP, pasted on Sep 4:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
<?php
$userPath = "../../../../";

$storagePath = "/var/www/mysite/uploads";
$path = $storagePath . $userPath;

$path = realpath($path);
if(strpos($path, $storagePath) === 0){
   //Path is okay
   echo "Okay";
}
else {
   //User wants to gain access into a forbidden area.
   echo "Danger";
}


Output:
1
Danger


Create a new paste based on this one


Comments: