You are here

public function OAuthStorePostgreSQL::addLog in Lingotek Translation 7.3

Same name and namespace in other branches
  1. 7.7 lib/oauth-php/library/store/OAuthStorePostgreSQL.php \OAuthStorePostgreSQL::addLog()
  2. 7.2 lib/oauth-php/library/store/OAuthStorePostgreSQL.php \OAuthStorePostgreSQL::addLog()
  3. 7.4 lib/oauth-php/library/store/OAuthStorePostgreSQL.php \OAuthStorePostgreSQL::addLog()
  4. 7.5 lib/oauth-php/library/store/OAuthStorePostgreSQL.php \OAuthStorePostgreSQL::addLog()
  5. 7.6 lib/oauth-php/library/store/OAuthStorePostgreSQL.php \OAuthStorePostgreSQL::addLog()

Add an entry to the log table

Parameters

array keys (osr_consumer_key, ost_token, ocr_consumer_key, oct_token):

string received:

string sent:

string base_string:

string notes:

int (optional) user_id:

Overrides OAuthStoreAbstract::addLog

File

lib/oauth-php/library/store/OAuthStorePostgreSQL.php, line 1650

Class

OAuthStorePostgreSQL

Code

public function addLog($keys, $received, $sent, $base_string, $notes, $user_id = null) {
  $args = array();
  $ps = array();
  foreach ($keys as $key => $value) {
    $args[] = $value;
    $ps[] = "olg_{$key} = '%s'";
  }
  if (!empty($_SERVER['REMOTE_ADDR'])) {
    $remote_ip = $_SERVER['REMOTE_ADDR'];
  }
  else {
    if (!empty($_SERVER['REMOTE_IP'])) {
      $remote_ip = $_SERVER['REMOTE_IP'];
    }
    else {
      $remote_ip = '0.0.0.0';
    }
  }

  // Build the SQL
  $ps['olg_received'] = "'%s'";
  $args[] = $this
    ->makeUTF8($received);
  $ps['olg_sent'] = "'%s'";
  $args[] = $this
    ->makeUTF8($sent);
  $ps['olg_base_string'] = "'%s'";
  $args[] = $base_string;
  $ps['olg_notes'] = "'%s'";
  $args[] = $this
    ->makeUTF8($notes);
  $ps['olg_usa_id_ref'] = "NULLIF('%d', '0')";
  $args[] = $user_id;
  $ps['olg_remote_ip'] = "NULLIF('%s','0.0.0.0')";
  $args[] = $remote_ip;
  $this
    ->query('
            INSERT INTO oauth_log (' . implode(',', array_keys($ps)) . ')
            VALUES(' . implode(',', $ps) . ')', $args);
}