> ------------------------------------------------------------------------------ See main.inc.php for release information EStat_Install : classe to manage plugin install --------------------------------------------------------------------------- */ include_once('estat_version.inc.php'); // => Don't forget to update this file !! include_once('estat_root.class.inc.php'); /* EStat class for install process */ class EStat_Install extends EStat_root { /* function for installation process return true if install process is ok, otherwise false */ public function install() { $this->checkDirectories(); $this->initConfig(); $this->loadConfig(); // create Global Stat File $gStatFile=new StatDBGlobal($this->fileStatDir, self::FILE_GLOBAL); $gStatFile->open(ASDF_OPEN_WRITE); $gStatFile->close(); $this->config['installed']=ESTAT_VERSION2; $this->config['plugin.newInstall']='y'; $this->saveConfig(); GPCCore::register($this->getPluginName(), ESTAT_VERSION, ESTAT_GPC_NEEDED); return(true); } /* function for uninstall process */ public function uninstall() { //GPCCore::rmDir(dirname($this->fileStatDir)); $this->deleteConfig(); GPCCore::unregister($this->getPluginName()); return(''); } public function activate() { $this->checkDirectories(); $this->initConfig(); $this->loadConfig(); // check if ip database need to be updated $this->checkIpCountryFile(); /* * migration code */ switch($this->config['installed']) { case '00.01.00b': //$this->updateFrom_000100b(); default: // nothing to do... break; } $this->config['installed']=ESTAT_VERSION2; $this->saveConfig(); GPCCore::register($this->getPluginName(), ESTAT_VERSION, ESTAT_GPC_NEEDED); return(''); } public function deactivate() { } /** * update from release 0.1.0b * * -- dummy -- * */ private function updateFrom_000100b() { return(false); } /** * check version of the ipCountry.bin file * * if database need an update, the config value 'plugin.newInstall' is set to "u" */ private function checkIpCountryFile() { if($this->config['plugin.newInstall']=='y') return(false); $dbCountry=new StatDBCountry($this->fileStatDir, self::FILE_COUNTRY); $ipFileInfo=$dbCountry->getIpFileInfo(ESTAT_PATH.'data/ipCountry.bin'); $ipDBVersion=$dbCountry->getInfoProperty('nfo', 'ipFileVersion'); if($ipFileInfo['fileVersion']>$ipDBVersion) { $this->config['plugin.newInstall']=='u'; return(true); } return(false); } /** * create the local directories & copy index.php files * */ private function checkDirectories() { if(!file_exists($this->fileStatDir)) mkdir($this->fileStatDir, 0755, true); if(!file_exists($this->fileExportDir)) mkdir($this->fileExportDir, 0755, true); if(!file_exists($this->fileStatDir.'/index.php')) copy(ESTAT_PATH.'index.php', $this->fileStatDir.'/index.php'); if(!file_exists(dirname($this->fileStatDir).'/index.php')) copy(ESTAT_PATH.'index.php', dirname($this->fileStatDir).'/index.php'); if(!file_exists($this->fileExportDir.'/index.php')) copy(ESTAT_PATH.'index.php', $this->fileExportDir.'/index.php'); if(!file_exists(dirname($this->fileExportDir).'/index.php')) copy(ESTAT_PATH.'index.php', dirname($this->fileExportDir).'/index.php'); } } //class ?>