Check Path and Create Directories

	function check_dir($dir){
		//Linux: "/home/wsdc/public_html/uploads/members/28/register/"
		//Windows: "D:\web_wsdc\uploads\members\34\register\"
		$dir_parts = explode(DIRECTORY_SEPARATOR, $dir);

		if(DIRECTORY_SEPARATOR == '/'){//Linux
			$path = '/';
		}else{//windows
			$path = '';
		}
		//log_g($dir);

		foreach ($dir_parts as $key => $value) {
			if($value == '') continue;

			$path .= $value . DIRECTORY_SEPARATOR;
			//log_g($path);
			if(file_exists($path) == false){
				$old = umask(0);
				mkdir($path, 0777);
				umask($old);
			}
		}

		//log_g($path);
	}