function get_upload_directory() {
//variables...
$upload_dir = trim($this->upload_dir);
//Yeah!
if($upload_dir) {
$ud_len = strlen($upload_dir);
$last_slash = substr($upload_dir,$ud_len-1,1);
if($last_slash <> "/") {
$upload_dir = $upload_dir ."/";
} else {
$upload_dir = $upload_dir;
}
//Handle...
$handle = @opendir($upload_dir);
if($handle) {
$upload_dir = $upload_dir;
closedir($handle);
} else {
$upload_dir = "ERROR";
}
} else {
$upload_dir = "ERROR";
}
return $upload_dir;
}
function get_upload_log_directory() {
$upload_log_dir = trim($this->upload_log_dir);
if($upload_log_dir) {
$ud_len = strlen($upload_log_dir);
$last_slash = substr($upload_log_dir,$ud_len-1,1);
if($last_slash <> "/"){
$upload_log_dir = $upload_log_dir."/";
} else {
$upload_log_dir = $upload_log_dir;
}
$handle = @opendir($upload_log_dir);
if($handle) {
$upload_log_dir = $upload_log_dir;
closedir($handle);
} else {
$upload_log_dir = "ERROR";
}
} else {
$upload_log_dir = "ERROR";
}
return $upload_log_dir;
}
function upload_file_no_validation() {
//Variables
$temp_file_name = trim($this->temp_file_name);
$file_name = trim(strtolower($this->file_name));
$upload_dir = $this->get_upload_directory();
$upload_log_dir = $this->get_upload_log_directory();
$file_size = $this->get_file_size();
$ip = trim($_SErver['REMOTE_ADDR']);
$cpu = gethostbyaddr($ip);
$m = date("m");
$d = date("d");
$y = date("Y");
$date = date("m/d/Y");
$time = date("h:i:s A");
//Let's go...
if(($upload_dir == "ERROR") OR ($upload_log_dir == "ERROR")){
return false;
} else {
if(is_upload_file($temp_file_name)) {
if (move_uploaded_file($temp_file_name,$upload_dir . $file_name)) {
$log = $upload_log_dir.$y."_".$m."_".$d.".txt";
$fp = fopen($log,"a+");
fwrite($fp,"$ip-$cpu | $file_name | $file_size | $date | $time");
fclose($fp);
return true;
} else {
return false;
}
} else {
return false;
}
}
}
function upload_file_with_validation() {
//SECTION #1
$temp_file_name = trim($this->temp_file_name);
$file_name =
$upload_dir = $this->get_upload_directory();
$upload_log_dir = $this->get_upload_log_directory();
$file_size = $this->get_file_size();
$ip = trim($_SERVER['REMOTE_ADDR']);
$cpu = gethostbyaddr($ip);
$m = date("m");
$d = date("d");
$y = date("Y");
$date = date("m/d/Y");
$time = date("h:i:s A");
$existing_file = $this->existing_file(); //<-Add On
$valid_user = $this->validate_user(); //<-Add On
$valid_size = $this->validate_size(); //<-Add On
$valid_ext = $this->validate_extension(); //<-Add On
//SECTION #2
if (($upload_dir == "ERROR") OR ($upload_log_dir == "ERROR")) {
return false;
}
elseif ((((!$valid_user) OR (!$valid_size) OR (!$valid_ext) OR ($existing_file)))) {
return false;
} else {
if (is_uploaded_file($temp_file_name)) {
if (move_uploaded_file($temp_file_name,$upload_dir . $file_name)) {
$log = $upload_log_dir.$y."_".$m."_".$d.".txt";
$fp = fopen($log,"a+");
fwrite($fp,"
$ip-$cpu | $file_name | $file_size | $date | $time");
fclose($fp);
return true;
} else {
return false;
}
} else {
return false;
}
}
#### Function Include ####
//Start the function
function includefile ($area) {
$id = $_GET['id'];
//Quick pattern check, for security :D
if ( !eregi("^[-?_?a-z0-9]+$",$area) ) { //Only allow a-z, 0-9, -, _ :)
//Let's stop them, and record the problem...
echo'Sorry, but the file you are trying to access is not allowed, and your
ip will be recorded';
$ip = $_SERVER['REMOTE_ADDR'];
$problem_body = "User trying to access the file: " . $area . ", and their
ip is: " . $ip;
$date = date("M, Y, D");
$time = time();
$insert = new site;
$connect = $this->connect();
$insert->query = "INSERT INTO " . $g_db_pre . "problems
VAULES('$problem_body','$date','$time')";
$insert->query();
//Close if( !eregi("") ...
}
elseif ( file_exists("./includes/" . $area . ".incphp") ) {
//Check if the file exists
include_once("./includes/" . $area . ".inc.php");
//Close elseif( file_ex ...
}
elseif ( !isset($id) ) {
include ( "./includes/index.inc.php" );
//No id, close function
}
else { //File didn't exist, record problem again...
echo'Sorry, but the file you are trying to access is not allowed, and your
ip recorded';
$ip = $_SERVER['REMOTE_ADDR'];
$problem_body = "User trying to access the file: " . $area . ", and their
ip is: " . $ip;
$date = date ( "M, Y, D" );
$time = time ( );
$insert = new site;
$connect = $this->connect ( );
$insert->query = "INSERT INTO " . $g_db_pre . "problems
VAULES('$problem_body','$date','$time')";
$insert->query ( );
//Close else
}
//Close the function include();
}
#### Function Add ####
//Start function
function add( $addit ) { //Add slashes
$val = $addit;
$addit = addslashes( $val );
//done with function add();
}
#### Function strip ####
//Initiate function
function strip( $stripit ) { //Strip slashes
$val = $stripit;
$stripit = stripslashes( $val );
//done with function strip();
}
#### Function BB ####
//Initiate function
function bb( $body ) {
//Let's make 2 arrays, $patterns and $replacements
//$patterns
$patterns[0] = "|\[p\](.*?)[/p\]|s";
$patterns[1] = "|\[b\](.*?)\[/b\]|s";
$patterns[2] = "|\[i\](.*?)\[/i\]|s";
$patterns[3] = "|\[u\](.*?)\[/u\]|s";
$patterns[4] = "|\[center\](.*?)\[/center\]|s";
$patterns[5] = "|\[hr\](.*?),(.*?)\[/hr\]|s";
$patterns[6] = "|\[code\](.*?)\[/code\]|s";
$patterns[7] = "|\[url\](.*?)\[/url\]|s";
$patterns[8] = "|\[url=(.*?)\](.*?)\[/url\]|s";
$patterns[9] = "|\[img\]([url]http://.*?[/url])\[/img\]|s";
$patterns[10] = "|\[right\](.*?)[/right\]|s";
$patterns[11] = "|\[left\](.*?)[/left\]|s";
//$replacements
$replacements[0] = "<p>\$1</p>";
$replacements[1] = "<b>\$1</b>";
$replacements[2] = "<i>\$1</i>";
$replacements[3] = "<u>\$1</u>";
$replacements[4] = "<p align=\"center\">\$1</p>";
$replacements[5] = "<hr size=\"\$1\" width=\"\$2\" />";
$replacements[6] = "<div class=\"code\">\$1</div>";
$replacements[7] = "<a href=\"\$1\" target=\"_blank\">\$1</a>";
$replacements[8] = "<a href=\"\$2\" target=\"_blank\">\$2</a>";
$replacements[9] = "<img src=\"\$1\" /><br />";
$replacements[10] = "<p align=\"right\">\$1</p>";
$replacements[11] = "<p align=\"left\">\$1</p>";
//Let's do the annoying list function...
preg_match_all("|\[list\](.*?)\[/list\]|s", $body, $matches);
$g = 12;
//Let's do some changing
foreach($matches[2] as $key => $value) {
//# of *'s.
$itemsu = count(explode("*", $matches[2][$key]));
//# of #'s.
$itemso = count(explode("#", $matches[2][$key]));
//Chop it up.
$chop = chop($matches[2][$key]);
//last one...
$listregpat[$g] = $chop[0];
//Okay structure part...
if($itemsu > 1) {
$listregrep = "<ol>";
for($i = 1; $i < $itemsu; $i++) {
if($i == 1) $firstlet = $chop[0];
else $firstlet = "";
$listregpat[$g] = "(.*?)\*";
$listregrep .= "<li>" . $firstlet . "\$" . $i . "</li>";
}
$listregpat[$g] .= "(.*?)";
$listregrep .= "<li>\$" . $itemso . "</li></ol>";
$patterns[$g] = "|\[list\]" . $listregpat[$g] . "|\[/list\]|s";
$replacements[$g] = $listregrep;
} else {
$patterns[$g] = "|\[list\](" . $chop[0] . ")(.*?)\[/list\]|s";
$replacements[$g] = "<ul><li>\$1\$2</li></ul>";
}
$g++;
}
ksort($patterns);
ksort($replacements);
$replaced = preg_replace($patterns, $replacements, $body);
//done with bb code :-)
}
?>
also there is an error...
on a line that doesn't exist it says unexpected $ or something like that...anyone see that?