Example #1
0
 public static function getInstance()
 {
     if (empty(self::$instance)) {
         self::$instance = parent::db_factory(_HISTORY_DBUSER, _HISTORY_DBPASS, _HISTORY_DBUSE, _HISTORY_DBSERVER, _HISTORY_DBPORT);
     }
     return self::$instance;
 }
Example #2
0
 /**
  * Save a historic copy of the scan results
  *
  * Due to a partial request/oh my god what were we thinking,
  * we decided to add a historic scan results database so that
  * if needed in the future, we can reference copies of any and
  * all scans run by users even if the user deleted the scan
  * results. This method will insert the historic copies of the
  * scan data.
  *
  * @param array $params Array of parameters sent to the function
  *	0 - Client key of the scanner
  *	1 - Profile ID to save the results under
  *	2 - The date, in MySQL datetime format, that the
  *	    results were saved to the database
  *	3 - The full scan results to save
  * @return True on successful progress update. IXR_Error
  *	on failure
  */
 public function jobs_saveHistoricReport($params)
 {
     $db = historyDB::getInstance();
     $client_key = $params[0];
     $profile_id = $params[1];
     $saved_on = $params[2];
     $results = $params[3];
     $username = $this->username_from_profile($profile_id);
     $sql = "INSERT INTO historic_saved_scan_results (\n\t\t\t\t`profile_id`,\n\t\t\t\t`username`,\n\t\t\t\t`saved_on`,\n\t\t\t\t`scan_results`) \n\t\t\tVALUES (':1',':2',':3',\":4\");";
     if (!$this->client_key_ok($client_key)) {
         return $this->error;
     }
     if (!$this->client_key_can_scan_profile($client_key, $profile_id)) {
         return $this->error;
     }
     $stmt = $db->prepare($sql);
     $stmt->execute($profile_id, $username, $saved_on, $results);
     return true;
 }