Skip to content

Instantly share code, notes, and snippets.

@Phelms215
Created July 14, 2014 12:30
Show Gist options
  • Save Phelms215/4f98889fadb69d7afde0 to your computer and use it in GitHub Desktop.
Save Phelms215/4f98889fadb69d7afde0 to your computer and use it in GitHub Desktop.
<?PHP
//
// Function Name: index
// Description: Display the system's dashboard
//
public function JSON() {
$key = $this->input->get("key");
$this->control->load_custom("Chef", array($this->config->item('chef_server'),
$this->config->item('chef_port'),
$this->config->item('chef_user'),
$this->config->item('chef_key')));
$r = $this->control->fetchNode_fromChef_byName("PhelmsUtil");
// $r['PANEL_KEY'] = 'Real Test';
print_r($this->Chef->put("/nodes/PhelmsUtil", $key, json_encode($r)));
exit;
}
// Get Function
public function get($uri, $params = ''){
if(!empty($params)){
$params = urlencode($params);
$this->prepare($uri . "?" . $params, "GET", '');
}
else{
$this->prepare($uri, 'GET', '');
}
$headers = $this->getHeaders('GET', $uri);
return $this->execute($headers);
}
// Put Function
public function put($uri, $id, $data){
$encodedData = json_encode($data);
$this->prepare($uri, 'PUT', $data);
$headers = $this->getHeaders('PUT', $uri, $data);
var_dump(json_decode($this->execute($headers)));
exit;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment