⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 filesystem.php

📁 一款基于PHP的网络日记程序。WikyBlog支持:多用户的 BLOG
💻 PHP
字号:
<?phpdefined('WikyBlog') or die("Not an entry point...");//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////		functions that are not the same between FileSystemFTP.php and FileSystem.php//		//Attemps to save a file..	//	if the file does not exist it attempts to create it	//		function saveFile(&$fileLocation,&$contents){		if( !file_exists($fileLocation) ){			if( !(makeFile($fileLocation)) ){				return false;			}		}				if( !is_writable($fileLocation) ){			if( !chmod($fileLocation,0666) ){				trigger_error('Could not change mode:'.$fileLocation);				return false;			}		}				if ( !($handle = fopen($fileLocation, 'w')) ) {			trigger_error('Could not open file:'.$fileLocation);			return false;		}						if( fwrite($handle, $contents) === FALSE ) {			trigger_error('Could not save file:'.$fileLocation);			return false;		}				fclose($handle);		return true;	}	//Attempts to create a file for writing	//	- calls makeDir to create directory	//	- new directories must be within subdirectories of $rootDir.. ie $rootDir/userfiles/<new dir>	function makeFile($fileLocation,$how='w'){		$dir = dirname($fileLocation);				if( !makeDir($dir) ){			return false;		}				if ( !($handle = fopen($fileLocation, $how)) ) {			trigger_error('Could not open file:'.$fileLocation);			return false;		}				return true;	}	//Attempts to create a directory	//accepts paths that include filenames, it will just remove the filename	function makeDir($relPath){		global $rootDir;				if( is_dir($relPath)){			//message('already exists');						if( !is_writable($relPath)){				if( !chmod($relPath,0777) ){					trigger_error('Could not change mode:'.$relPath);					return false;				}			}			return true;		}				//Must be a subdir of $rootDir		if( wbStrpos($relPath,$rootDir) === false){			trigger_error('Tried to create an illegal directory for: '.$fileLocation);			return false;		}				$relPath = wbStr_replace($rootDir.'/','',$relPath);		$newParts = explode('/',$relPath);		$newDir = $rootDir.'/'.array_shift($newParts);				//The immediate subdir of $rootDir must already exist		if( !is_dir($newDir) ){			trigger_error('The subdirectory to the rootdir must already exist: '.$fileLocation);			return false;		}		//maybe not?		if( !is_writable($newDir) ){			trigger_error('The subdirectory to the rootdir must be writable: '.$fileLocation);			return false;		}				foreach($newParts as $piece){			$newDir.='/'.$piece;			//message($newDir);			if( is_dir($newDir) ){				continue;			}						if( mkdir($newDir,0777) ){				continue;			}			trigger_error('Could not create directory: '.$newDir);			return false;		}		return true;	}		function renameFile($from,$to){		$toDir = dirname($to);		if( !makeDir($toDir) ){			return false;		}				if( !rename($from,$to) ){			trigger_error('Couldn\'t rename '.$from. ' to '. $to);			return false;		}		return true;	}	function wbMove_uploaded_file($from,$to){		return move_uploaded_file($from,$to);	}	function wbUnlink($path){		return unlink($path);	}	function wbRmdir($path){		return rmdir($path);	}	function wbChmod($file,$mode){		return chmod($file,$mode); //true on success, false on failure	}	////		functions that are not the same between FileSystemFTP.php and FileSystem.php//	//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////		These funcitons are the same for FileSystemFTP.php and FileSystem.php//		// check to make sure a supplied path is a subdirectory of $rootdir	function checkPath($dir,$subDir='',$trigger=true){		global $rootDir;		$check = $rootDir.'/'.$subDir;				//try to get rid of ../		$dir = wbStr_replace('\\','/',$dir);		$dir = wbStr_replace('../','/',$dir);		$dir = wbStr_replace('./','/',$dir);						//check for more ./		if( wbStrpos($dir,'./') !== false ){			if($trigger){				trigger_error('Illegal path supplied to checkPath() (1): '.$dir);			}			return false;		}				//should be in $check		if( wbStrpos($dir,$check) === false){			if($trigger){				trigger_error('Illegal path supplied to checkPath() (2): '.$dir);			}			return false;		}				return true;	}	//	//		saveAsPHP	//		function saveAsPHP(&$location,$varName,&$mixed,$global=false){				$text = '<'.'?'."php\n";		$text .= "//\n";		$text .= "//\t\tWikyBlog Generated File\n";		$text .= "//\t\t*****************************************************\n";		$text .= "//\t\tThis file contains data used by the wikyblog software\n";		$text .= "//\n\n";		$text .= 'defined(\'WikyBlog\') or die(\'Not an entry point...\');';		$text .= "\n\n";				if( $global ){			$text .= 'global $'.$varName.";\n";		}		$text .= '$'.$varName." = \n";		$text .= var_export($mixed,true);		$text .= ';';			return saveFile($location,$text);	}	

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -