Skip to content

Commit

Permalink
! Removed access logging, version 1.0 code
Browse files Browse the repository at this point in the history
Signed-off-by: Jason Clemons <realjblaze@gmail.com>
  • Loading branch information
Jason Clemons committed Dec 15, 2013
1 parent 758f7a9 commit ab12f1e
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 73 deletions.
23 changes: 6 additions & 17 deletions api/includes/bootloader.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,19 +26,9 @@
*/
$accounts = array(
array(
'email' => '',
'password' => '',
'gamertag' => ''
),
array(
'email' => '',
'password' => '',
'gamertag' => ''
),
array(
'email' => '',
'password' => '',
'gamertag' => ''
'email' => 'john@example.com',
'password' => 'Password123',
'gamertag' => 'Major Nelson'
)
);

Expand All @@ -61,10 +51,9 @@
/*!
* Define some log file locations.
*/
define('COOKIE_FILE', '../includes/cookies/' . XBOX_EMAIL . '.jar'); // path to cookie file
define('DEBUG_FILE', '../includes/logs/debug.log'); // path to debug log
define('STACK_TRACE_FILE', '../includes/logs/stack_trace.log'); // path to stack trace
define('ACCESS_FILE', '../includes/logs/access.log'); // path to access log
define('COOKIE_FILE', '../includes/cookies/' . XBOX_EMAIL . '.jar');
define('DEBUG_FILE', '../includes/logs/debug.log');
define('STACK_TRACE_FILE', '../includes/logs/stack_trace.log');

/*!
* Initiate the caching engine.
Expand Down
71 changes: 16 additions & 55 deletions api/includes/classes/base.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@ class Base
public $cookie_file = ''; // cookie jar path
public $debug_file = ''; // debug file path
public $stack_trace_file = ''; // stack trace file path
public $access_file = ''; // access log file path
public $runtime = null; // current runtime
public $ip = null; // ip address to use for session, generated in __construct()
public $format = 'xml'; // default response format
Expand Down Expand Up @@ -106,23 +105,12 @@ public function output_headers()
*/
public function output_payload($data)
{
//!!! Version 1.0 being deprecated soon!
if ($this->version == '1.0') {
$payload = array(
'Data' => $data,
'In' => round(microtime(true) - $this->runtime, 3),
'Stat' => 'ok',
'Authed' => 'false',
'AuthedAs' => null
);
} else {
$payload = array(
'status' => 'success',
'version' => $this->version,
'data' => $data,
'runtime' => round(microtime(true) - $this->runtime, 3)
);
}
$payload = array(
'status' => 'success',
'version' => $this->version,
'data' => $data,
'runtime' => round(microtime(true) - $this->runtime, 3)
);

// Output the data in the desired format.
switch ($this->format) {
Expand All @@ -147,26 +135,15 @@ public function output_error($code)
http_response_code((int) $code);
}

//!!! Version 1.0 being deprecated soon!
if ($this->version == '1.0') {
$payload = array(
'Error' => $this->errors[$code],
'In' => round(microtime(true) - $this->runtime, 3),
'Stat' => 'fail',
'Authed' => 'false',
'AuthedAs' => null
);
} else {
$payload = array(
'status' => 'error',
'version' => $this->version,
'data' => array(
'code' => $code,
'message' => $this->errors[$code]
),
'runtime' => round(microtime(true) - $this->runtime, 3)
);
}
$payload = array(
'status' => 'error',
'version' => $this->version,
'data' => array(
'code' => $code,
'message' => $this->errors[$code]
),
'runtime' => round(microtime(true) - $this->runtime, 3)
);

// Output the data in the desired format.
switch ($this->format) {
Expand Down Expand Up @@ -490,22 +467,6 @@ protected function empty_cookie_file()
}
}

/*!
* Saves access data to access log, if enabled
*/
public function save_to_access($string)
{
if ($this->debug) {
$file = fopen($this->access_file, 'a+');
if (!$file) {
$this->error = 608;
} else {
fwrite($file, '[' . date('Y-m-d H:i:s') . '] (' . $this->version . ') ' . $string . "\n");
fclose($file);
}
}
}

/*!
* Save items to the debug log
*/
Expand Down Expand Up @@ -578,7 +539,7 @@ function output_pretty_jsonp($json, $callback)
function output_pretty_xml($mixed, $xml = false)
{
if ($xml === false) {
$xml = new SimpleXMLElement('<?xml version="1.0" encoding="utf-8"?><xbox status="' . (empty($mixed['status']) ? $mixed['Stat'] : $mixed['status']) . '" version="' . (empty($mixed['version']) ? '1.0' : $mixed['version']) . '" />');
$xml = new SimpleXMLElement('<?xml version="1.0" encoding="utf-8"?><xbox status="' . $mixed['status'] . '" version="' . $mixed['version'] . '" />');
}

foreach ($mixed as $key => $value) {
Expand Down
1 change: 0 additions & 1 deletion api/includes/kernel.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,5 +26,4 @@
$api->debug_file = DEBUG_FILE;
$api->stack_trace_file = STACK_TRACE_FILE;
$api->access_file = ACCESS_FILE;
$api->save_to_access($_SERVER['REMOTE_ADDR'] . ' ' . $_SERVER['REQUEST_URI']);
$api->init(XBOX_EMAIL, XBOX_PASSWORD);

0 comments on commit ab12f1e

Please sign in to comment.