* @copyright 2004 by http://wombat.exit0.net * @package wombatSite * @subpackage install */ /** * make tool: cache folder * * creates necessary cache folders and sets correct permissions * * @version 1.0.0 * @package wombatSite * @subpackage install */ class wbMaker_VarDir extends wbMaker { /** * information * * @access private * @var array $_info */ var $_info = array( 'maker' => 'VarDir', 'state' => 'new', 'brief' => 'Build var directory structure and sets file permissions.', 'msg' => '' ); /** * location of var dir * * relative to baseDir * * @access private * @var string $_varDir */ var $_varDir = 'var'; /** * location of cache files * * @access private * @var string $_baseDir */ var $_baseDir; /** * sub directories * * @access private * @var array $_dirs */ var $_dirs = array( 'admin' => 0777, 'admin/menu' => 0777, 'cache' => 0777, 'cache/forms' => 0777, 'cache/lang' => 0777, 'cache/lang/system' => 0777, 'cache/lang/site' => 0777, 'content' => 0777, 'content/html' => 0777, 'content/html/draft' => 0777, 'log' => 0777, 'tmp' => 0777, 'upload' => 0777, 'upload/image' => 0777, 'lang' => 0777, ); /** * bring birth! * * @access public * @return boolean $result true on success */ function __construct() { umask( 0000 ); $this->_baseDir = wbFactory::getParam( 'baseDir' ); $this->_varDir = wbFactory::getParam( 'varDir' ); } /** * php4 constructor wrapper * * @access public * @see __construct() */ function wbMaker_VarDir() { $this->__construct(); } /** * run... * * @access public * @return boolean true on success, false if any target has failed (or patError object on error!) */ function make() { $base = $this->_baseDir . '/' . $this->_varDir; // create base folder if( !is_dir( $base ) ) { $res = @mkdir( $base, 0777 ); if( !$res ) { $this->_info['state'] = 'failed'; $this->_info['msg'] = 'Could not create var directory at "'. $base .'"!'; return false; } } foreach( $this->_dirs as $dir => $mode ) { // does not even exists if( !file_exists( $base . '/' . $dir ) ) { $res = @mkdir( $base . '/' . $dir, $mode ); if( !$res ) { $this->_info['state'] = 'failed'; $this->_info['msg'] = 'Could not create directory at "'. $dir .'"!'; return false; } wbDebugger::addMsg( 'Make', 'Create directory: "'. $dir .'"', 'VarDir' ); continue; } // exists but is not a directory if( !is_dir( $base . '/' . $dir ) ) { $this->_info['state'] = 'failed'; $this->_info['msg'] = '"'. $dir .'" is not a directory!'; return false; } $res = @chmod( $base . '/' . $dir, $mode ); if( !$res ) { $this->_info['state'] = 'failed'; $this->_info['msg'] = 'Could not change permissions of "'. $dir .'"!'; return false; } wbDebugger::addMsg( 'Make', 'Changed permission: "'. $dir .'"', 'VarDir' ); } $this->_info['msg'] = 'Checked '. count( $this->_dirs ) .' folders.'; return true; } } ?>