Skip to content

Commit

Permalink
Merge branch 'test_config' into dev
Browse files Browse the repository at this point in the history
  • Loading branch information
MathieuNls committed Feb 2, 2016
2 parents 70318dc + e617fba commit 87f9f98
Show file tree
Hide file tree
Showing 3 changed files with 63 additions and 2 deletions.
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,5 @@ application/logs/*
application/tests/build/*
vendor/
.env
.phpintel/*
.phpintel/*
application/config/google-api.p12
23 changes: 23 additions & 0 deletions application/config/config.php
Original file line number Diff line number Diff line change
Expand Up @@ -502,3 +502,26 @@
| Array: array('10.0.1.200', '192.168.5.0/24')
*/
$config['proxy_ips'] = '';

/*
|--------------------------------------------------------------------------
| Google API Config
|--------------------------------------------------------------------------
|
| Google API requires a P12 enrypted key. The key is downloaded
| from a secure location if not already present on the disk
*/
if(!file_exists(APPPATH.'config/google-api.p12')){
$out = fopen(APPPATH.'config/google-api.p12', "wb");
$ch = curl_init();
curl_setopt($ch, CURLOPT_FILE, $out);
curl_setopt($ch, CURLOPT_HEADER, 0);
curl_setopt($ch, CURLOPT_URL, getenv("GOOGLE_API_LINK"));
curl_setopt($ch, CURLOPT_USERPWD, getenv("GOOGLE_API_KEY"));
curl_exec($ch);

curl_close($ch);
fclose($out);
}
$config['google_api_key'] = APPPATH.'config/google-api.p12';
$config['google_api_account'] = getenv("GOOGLE_API_ACCOUNT");
39 changes: 38 additions & 1 deletion application/controllers/Measures.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,29 @@ public function __construct() {
parent::__construct();
$this->load->model('watch');
$this->load->model('measure');
$this->load->library('auto_email');
}

function test()
{
$out = fopen(APPPATH."config/google-api.p12", "wb");
$ch = curl_init();

curl_setopt($ch, CURLOPT_FILE, $out);
curl_setopt($ch, CURLOPT_HEADER, 0);
curl_setopt($ch, CURLOPT_URL, "https://toolwatch.io");

curl_exec($ch);
echo "<br>Error is : ".curl_error ( $ch);

curl_close($ch);

fclose($out);

var_dump(file_get_contents(APPPATH."config/google-api.p12"));
}


/**
* Loads the dashboard of an user.
*/
Expand Down Expand Up @@ -340,11 +361,27 @@ function accuracyMeasure() {
//We store the computed accuracy & percentile
$result['accuracy'] = $watchMeasure->accuracy;
$result['percentile'] = $watchMeasure->percentile;


log_message('info', 'OUT OF HERE');

$this->output->_display("");
ob_end_flush();
echo json_encode($result);

// Ignore connection-closing by the client/user
ignore_user_abort(true);

$this->auto_email->updateObserver($this, NEW_ACCURACY,
array('measure' => $watchMeasure));


} else {
$result['success'] = false;
echo json_encode($result);
}

echo json_encode($result);

}
}
}

0 comments on commit 87f9f98

Please sign in to comment.