Exemplo n.º 1
0
 public function remove()
 {
     $result = false;
     $hook = new Hook($this->ampdb, 'ampoliros', 'site.remove');
     if ($hook->CallHooks('calltime', $this, '') == HOOK_RESULT_OK) {
         $query = $this->ampdb->Execute('SELECT * ' . 'FROM sites ' . 'WHERE id=' . (int) $this->siteserial);
         $data = $query->Fields();
         // Disables all modules
         //
         $this->DisableAllModules($this->siteserial);
         $args['dbname'] = $data['sitedbname'];
         $args['dbhost'] = $data['sitedbhost'];
         $args['dbport'] = $data['sitedbport'];
         $args['dbuser'] = $data['sitedbuser'];
         $args['dbpass'] = $data['sitedbpass'];
         $args['dbtype'] = $data['sitedbtype'];
         $args['dblog'] = $data['sitedblog'];
         $this->sitedb->Close();
         $this->sitedb->DropDB($args);
         // Remove cached items
         //
         Carthag::import('com.solarix.ampoliros.datatransfer.cache.CacheGarbageCollector');
         $cache_gc = new CacheGarbageCollector();
         $cache_gc->RemoveSiteItems((int) $data['id']);
         // Removes site users
         //
         $this->RemoveAllUsers();
         // Removes site from amp database
         //
         $this->ampdb->Execute('DELETE FROM sites ' . 'WHERE id=' . (int) $data['id']);
         $this->ampdb->Execute('DELETE FROM disabledsubmodules ' . 'WHERE siteid=' . $this->siteserial);
         import('com.solarix.ampoliros.io.log.Logger');
         $log = new Logger(AMP_LOG);
         $log->LogEvent($data['siteid'], 'Removed site ' . $data['siteid'], LOGGER_NOTICE);
         if (!empty($data['siteid'])) {
             RecRemoveDir(SITESTUFF_PATH . $data['siteid']);
         }
         if ($hook->CallHooks('siteremoved', $this, '') == HOOK_RESULT_OK) {
             $result = true;
         }
         global $gEnv;
         if ($gEnv['core']['config']->Value('ALERT_ON_SITE_OPERATION') == '1') {
             Carthag::import('com.solarix.ampoliros.security.SecurityLayer');
             $amp_security = new SecurityLayer();
             $amp_security->SendAlert('Site ' . $data['siteid'] . ' has been removed');
             unset($amp_security);
         }
     }
     return $result;
 }