Beispiel #1
0
 public static function getInstance()
 {
     if (!self::$instance) {
         self::$instance = self::createAdapterInstance();
     }
     return self::$instance;
 }
Beispiel #2
0
 public static function getAll()
 {
     $sgdb = SGDatabase::getInstance();
     $configs = $sgdb->query('SELECT * FROM ' . SG_CONFIG_TABLE_NAME);
     if (!$configs) {
         return null;
     }
     $currentConfigs = array();
     foreach ($configs as $config) {
         self::$values[$config['ckey']] = $config['cvalue'];
         $currentConfigs[$config['ckey']] = $config['cvalue'];
     }
     return $currentConfigs;
 }
Beispiel #3
0
 public static function uninstall($deleteBackups = false)
 {
     try {
         $sgdb = SGDatabase::getInstance();
         //drop config table
         $res = $sgdb->query('DROP TABLE IF EXISTS `' . SG_CONFIG_TABLE_NAME . '`;');
         if ($res === false) {
             throw new SGExceptionDatabaseError('Could not execute query');
         }
         //drop action table
         $res = $sgdb->query('DROP TABLE IF EXISTS `' . SG_ACTION_TABLE_NAME . '`;');
         if ($res === false) {
             throw new SGExceptionDatabaseError('Could not execute query');
         }
         //delete directory of backups
         if ($deleteBackups) {
             $backupPath = SGConfig::get('SG_BACKUP_DIRECTORY');
             deleteDirectory($backupPath);
         }
     } catch (SGException $exception) {
         die($exception);
     }
 }
Beispiel #4
0
 public function __construct()
 {
     $this->sgdb = SGDatabase::getInstance();
 }
Beispiel #5
0
 public function __construct()
 {
     $this->sgdb = SGDatabase::getInstance();
     $notificationCenter = SGNotificationCenter::getInstance();
     $notificationCenter->addObserver(SG_NOTIFICATION_SAVE_DB_ACTION_STATE, $this, 'saveActionState', true);
 }
Beispiel #6
0
 public static function deleteBackup($backupName, $deleteAction = true)
 {
     deleteDirectory(SG_BACKUP_DIRECTORY . $backupName);
     if ($deleteAction) {
         $sgdb = SGDatabase::getInstance();
         $sgdb->query('DELETE FROM ' . SG_ACTION_TABLE_NAME . ' WHERE name=%s', array($backupName));
     }
 }
Beispiel #7
0
function getReport()
{
    $jsonArray = array();
    $headerArray = array();
    $jsonArray['ptype'] = '1';
    $jsonArray['token'] = '28016ffb35b451291bfed7c5905474d6';
    $lastReportTime = SGConfig::get('SG_LAST_REPORT_DATE');
    if (!$lastReportTime) {
        SGConfig::set('SG_LAST_REPORT_DATE', time());
    }
    SGBackup::getLogFileHeader($headerArray);
    $jsonArray['header'] = $headerArray;
    $jsonArray['header']['uid'] = sha1("http://" . @$_SERVER[HTTP_HOST] . @$_SERVER[REQUEST_URI]);
    $sgdb = SGDatabase::getInstance();
    $res = $sgdb->query('SELECT type, subtype, status, count(*) AS scount FROM ' . SG_ACTION_TABLE_NAME . ' WHERE update_date > FROM_UNIXTIME(%d) GROUP BY type, subtype, status', array($lastReportTime));
    if (count($res)) {
        foreach ($res as $item) {
            $jsonArray['log'][] = $item;
        }
    }
    return json_encode($jsonArray);
}