Skip to content

Commit

Permalink
Removed userid from /measurement_container
Browse files Browse the repository at this point in the history
  • Loading branch information
Jesse Blum committed Dec 6, 2012
1 parent 46a3a81 commit 9d04a54
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 12 deletions.
26 changes: 15 additions & 11 deletions 2/index.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
define('HN_TS_DEBUG', false);
define('HN_TS_VERSION', "v. 2.0.0-Alpha-0.2");
$app = new Slim();
$hn_tsuserid=NULL;
if(HN_TS_DEBUG){
$app->getLog()->setEnabled(true);
}
Expand Down Expand Up @@ -56,11 +57,12 @@
}

// Select private key for given public key
$sql = "SELECT privatekey FROM wp_ts_apikeys WHERE publickey =
$sql = "SELECT privatekey,userid FROM wp_ts_apikeys WHERE publickey =
'$pub' AND revoked='0'";
$pri = querySql($sql);
if(count($pri)){
$pri = $pri[0]->privatekey;
$rows = querySql($sql);
$pri='';
if(count($rows)){
$pri = $rows[0]->privatekey;
//echo "pri: $pri<br/>";
}else{
hn_ts_error_msg("Invalid parameter: pubkey", 400);
Expand Down Expand Up @@ -105,7 +107,9 @@
//echo "hmac: $hmac<br/>";
//echo "hash: $hash<br/>";
hn_ts_error_msg("Invalid parameter: hmac", 400);
}
}
global $hn_tsuserid;
$hn_tsuserid=$rows[0]->userid;
};

/**
Expand Down Expand Up @@ -161,11 +165,10 @@ function hn_ts_withinTime($ts){
$missingDataValue = $app->request()->post('missingdatavalue');
$siteId = $app->request()->post('siteid');
$blogid = $app->request()->post('blogid');
$userid = $app->request()->post('userid');
hn_ts_create_measurement_containerForBlog(
$measuretype, $minimumvalue, $maximumvalue, $unit,
$unitSymbol, $device, $otherInformation, $datatype,
$missingDataValue, $siteId, $blogid, $userid, $friendlyName);
$missingDataValue, $siteId, $blogid, $friendlyName);
});
$app->get('/measurement_container/:name', $hn_ts_authenticate, function($name) use ($app) {
if(!isset($name)){
Expand Down Expand Up @@ -434,7 +437,7 @@ function hn_ts_list_mc_names(){
*/
function hn_ts_create_measurement_containerForBlog($measurementType,
$minimumvalue, $maximumvalue, $unit, $unitSymbol, $deviceDetails, $otherInformation,
$dataType,$missingDataValue, $siteId, $blogId, $userid, $friendlyName){
$dataType,$missingDataValue, $siteId, $blogId, $friendlyName){
/* Ensure that the parameters are valid **********/

// Ensure friendly name is unique
Expand Down Expand Up @@ -465,8 +468,9 @@ function hn_ts_create_measurement_containerForBlog($measurementType,
if(!$blogId || $blogId < 1){
$blogId = 1;
}
if(!$userid || $userid < 1){
$userid = 1;
global $hn_tsuserid;
if(NULL==$hn_tsuserid || $hn_tsuserid < 1){
$hn_tsuserid = 1;
}

//Ensure that arguments have legal characters.
Expand All @@ -481,7 +485,7 @@ function hn_ts_create_measurement_containerForBlog($measurementType,
$missingDataValue = hn_ts_sanitise($missingDataValue);
$siteId = hn_ts_sanitise($siteId);
$blogId = hn_ts_sanitise($blogId);
$userid = hn_ts_sanitise($userid);
$userid = hn_ts_sanitise($hn_tsuserid);

try {
/** Insert record into metadata, create table, and add friendly name record */
Expand Down
15 changes: 14 additions & 1 deletion admin/settings.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,25 @@ function hn_ts_init(){
function hn_ts_add_page() {
add_options_page('Timestreams', 'Timestreams', 'manage_options', 'hn_ts_options', 'hn_ts_options_do_page');
}

class SingleSite{
public $site_id =1;
public $blog_id =1;
}

// Draw the menu page itself
function hn_ts_options_do_page() {
function hn_ts_options_do_page() {
if(is_multisite()){
global $current_blog;
}else{
$current_blog = new SingleSite;
}

?>
<div class="wrap">
<h2><?php _e('Timestreams Options',HN_TS_NAME); ?></h2>
<p><?php _e('Site Id: ',HN_TS_NAME); echo $current_blog->site_id;?></p>
<p><?php _e('Blog Id: ',HN_TS_NAME); echo $current_blog->blog_id;?></p>
<p><?php _e('Please enter the following values if you are replicating your data through a proxy server.',HN_TS_NAME); ?></p>
<form method="post" action="options.php">
<?php settings_fields('hn_ts_options'); ?>
Expand Down

0 comments on commit 9d04a54

Please sign in to comment.