|
|||||||||||
|
$default_file = "index.html"; //set default file $doc_path = "./"; //set parent path $cnc_doc_path = "/vhome/cvcwork/htdocs/mathacts02/"; //define cnc doc path. $docs=$HTTP_GET_VARS['content']; //get content //test url to find if it is remote or local $new_doc = split("\.\.\/",$docs); //parse by "../" //ceck if it is empty if ($new_doc[0] == "") { $new_doc[0] = $default_file; } //find to see if starts with a . $pos = strpos($new_doc[0], "."); // if posiition is at 0 need === not ==. if ($pos === 0){ // someon trying to access hidden files. $new_doc[0] = $default_file; } $new_file_path = "$doc_path"."$new_doc[0]"; //set the path to the file. //check to see if it exists. //If it is valid html file, the path will always in array cell 0 if(!file_exists($new_file_path)) { //check for remote URL within CNC (cnc.ucr.edu/) //cell 0 will contain "http://" or "http://www." //cell 1 will contain the content. $new_doc = split("cmdb.ucr.edu\/",$new_doc[0]); //find to see if starts with a . $pos = strpos($new_doc[1], "."); // if posiition is at 0 need === not ==. if ($pos === 0) { // someon trying to access hidden files. $new_doc[1] = $default_file; } $new_file_path = "$cnc_doc_path"."$new_doc[1]"; //set the path to the file. //test the path again if(!file_exists($new_file_path)) { //failed both test. set it to default file. else. include the new doc. $new_file_path = $default_file; } } //include content if(!@include ($new_file_path)){ echo "Default file not found."; } ?> |
||||||||||
|