-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
81 changed files
with
12,042 additions
and
448 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
<?php | ||
|
||
return array( | ||
/** | ||
* SID - Your Twilio Account SID # | ||
*/ | ||
"sid" => "AC3b8cd1e12a5b6ff4e4ea25f431833a97", | ||
|
||
/** | ||
* token - Access token that can be found in your Twilio dashboard | ||
*/ | ||
"token" => "22964db1d502e5069c2d44c9a49c8b6c", | ||
|
||
/** | ||
* from - The Phone number registered with Twilio that your SMS & Calls will come from | ||
*/ | ||
"from" => "+441332402803" | ||
); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,6 @@ | ||
<?php | ||
|
||
return array( | ||
|
||
'publish_key' => 'pub-c-18bc7bd1-2981-4cc4-9c4e-234d25519d36', | ||
'subscribe_key' => 'sub-c-5782df52-d147-11e3-93dd-02ee2ddab7fe', | ||
|
||
); | ||
); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
<?php | ||
class AuthenticationController extends BaseController{ | ||
|
||
public function getAll() | ||
{ | ||
|
||
|
||
} | ||
|
||
public function store() | ||
{ | ||
|
||
} | ||
|
||
public function auth() | ||
{ | ||
if (!isset($_SERVER['HTTP_AUTHORIZATION']) || $_SERVER['HTTP_AUTHORIZATION'] == '') | ||
{ | ||
return Response::json(array("success" => "test")); | ||
} | ||
else{ | ||
list($email, $password) = explode(':', base64_decode(substr($_SERVER['HTTP_AUTHORIZATION'], 6))); | ||
} | ||
if (Auth::attempt(array('email' => $email, 'password' => $password))) | ||
{ | ||
return Response::json(Auth::user()); | ||
} | ||
|
||
return Response::json(array("id" => 0)); | ||
} | ||
} | ||
?> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
<?php | ||
class PrivilegeController extends BaseController { | ||
|
||
public function getAll() | ||
{ | ||
return Response::json(Privilege::all()); | ||
} | ||
|
||
public function store() | ||
{ | ||
$privilege = new Privilege; | ||
$privilege->name = Input::get('name'); | ||
|
||
$privilege->save(); | ||
|
||
return Response::json($privilege); | ||
} | ||
|
||
public function deletePrivilege($id) | ||
{ | ||
$privilege = Privilege::find($id); | ||
$privilege->delete(); | ||
|
||
return Response::json(array("success" => true)); | ||
} | ||
} | ||
?> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,150 @@ | ||
<?php | ||
class ServerController extends BaseController { | ||
|
||
public function getAll() | ||
{ | ||
return Response::json(Server::all()); | ||
} | ||
|
||
public function getServer($id) | ||
{ | ||
$server = Server::find($id); | ||
//return Response::json(array('server' => json_decode($server), 'pulses' => json_decode($server->pulse))); | ||
return Response::json($server); | ||
} | ||
|
||
public function store() | ||
{ | ||
$server = new Server; | ||
|
||
$server->servergroup_id = Input::get("servergroup_id"); | ||
$server->name = Input::get("name"); | ||
$server->available_disk = Input::get("available_disk"); | ||
$server->available_ram = Input::get("available_ram"); | ||
$server->cpu_speed = Input::get("cpu_speed"); | ||
$server->os_name = Input::get("os_name"); | ||
$server->os_version = Input::get("os_version"); | ||
$server->guid = Input::get("guid"); | ||
|
||
$server->save(); | ||
|
||
$pubnub = App::make('pubnub'); | ||
$pubnub->publish(array( | ||
'channel' => 'Cadence', | ||
'message' => json_decode($server) | ||
)); | ||
|
||
return Response::json($server); | ||
} | ||
|
||
public function getPulses($id) | ||
{ | ||
$server = Server::find($id); | ||
return Response::json($server->pulse); | ||
} | ||
|
||
public function getPulsesForDays($id, $days) | ||
{ | ||
$server = Server::find($id); | ||
$pulses = Pulse::ofServerID($id)->ofDays($days)->get(); | ||
return Response::json($pulses); | ||
} | ||
|
||
public function getLatestPulse($id) | ||
{ | ||
$pulse = Pulse::ofServerID($id)->orderby('timestamp', 'asc')->first(); | ||
return Response::json($pulse); | ||
} | ||
|
||
public function changeStatus($guid) | ||
{ | ||
Server::where('guid', '=', $guid)->update(array('online' => Input::get("status"))); | ||
$server = Server::where('guid', '=', $guid)->get(); | ||
|
||
if($server->isEmpty()) | ||
{ | ||
return Response::make("Server with this GUID not found"); | ||
} | ||
|
||
$subscriptionsForServer = Subscription::ofServerID($server->first()->servergroup_id)->get(); | ||
foreach ($subscriptionsForServer as $subscription) | ||
{ | ||
if (Input::get("status") == 0) | ||
{ | ||
if($subscription->text == 1) | ||
{ | ||
Twilio::message($subscription->user->mobile_number, "CADENCE STATUS ALERT: Server '" . $server->first()->name . "' has gone offline. Urgent attention needed."); | ||
} | ||
if($subscription->phonecall == 1) | ||
{ | ||
Twilio::call($subscription->user->mobile_number, 'http://cadence-bu.cloudapp.net/voicealert.xml'); | ||
} | ||
} | ||
else | ||
{ | ||
if($subscription->text == 1) | ||
{ | ||
Twilio::message($subscription->user->mobile_number, "CADENCE STATUS UPDATE: Server '" . $server->first()->name . "' has come back online. Have a great day."); | ||
} | ||
} | ||
} | ||
|
||
$pubnub = App::make('pubnub'); | ||
$pubnub->publish(array( | ||
'channel' => 'pulses-' . $server->first()->id . '-online', | ||
'message' => json_encode(array("online" => Input::get("status"))) | ||
)); | ||
|
||
return Response::json($server->first()); | ||
} | ||
|
||
public function updateServerDetails($guid) | ||
{ | ||
$server = Server::where('guid', '=', $guid)->first()->update(array( | ||
"available_disk" => Input::get("available_disk"), | ||
"available_ram" => Input::get("available_ram"), | ||
"cpu_speed" => Input::get("cpu_speed"), | ||
"os_name" => Input::get("os_name"), | ||
"os_version" => Input::get("os_version") | ||
)); | ||
return Response::json(Server::where('guid', '=', $guid)->get()); | ||
} | ||
|
||
public function updateServerGroup($id) | ||
{ | ||
$server = Server::find($id); | ||
|
||
$server->servergroup_id = Input::get('servergroup_id'); | ||
$server->save(); | ||
} | ||
|
||
public function getStatus($guid) | ||
{ | ||
$server = Server::where('guid', '=', $guid)->get(); | ||
return Response::json($server); | ||
} | ||
|
||
public function deleteServer($id) | ||
{ | ||
$server = Server::find($id); | ||
$server->delete(); | ||
|
||
return Response::json(array("success" => true)); | ||
} | ||
|
||
public function getUnassignedServers() | ||
{ | ||
return Response::json(Server::ofUnassigned(0)->get()); | ||
} | ||
|
||
public function getAssignedServers() | ||
{ | ||
return Response::json(Server::ofAssigned(0)->get()); | ||
} | ||
|
||
public function getServersForStatus($status) | ||
{ | ||
return Response::json(Server::ofStatus($status)->get()); | ||
} | ||
} | ||
?> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,72 @@ | ||
<?php | ||
class ServerGroupController extends BaseController { | ||
|
||
public function getAll() | ||
{ | ||
return Response::json(ServerGroup::all()); | ||
} | ||
|
||
public function getServers($id) | ||
{ | ||
$serverGroup = ServerGroup::find($id); | ||
return Response::json($serverGroup->server); | ||
} | ||
|
||
public function store() | ||
{ | ||
if (ServerGroup::where('name','=', Input::get("name"))->count() > 0) { | ||
//$user = User::where('email','=', Input::get("email"))->get()->first(); | ||
return Response::json(array('success' => false , 'error' => 'Server Group already exists')); | ||
} | ||
|
||
$serverGroup = new ServerGroup; | ||
$serverGroup->name = Input::get("name"); | ||
$serverGroup->save(); | ||
|
||
return Response::json($serverGroup); | ||
} | ||
|
||
public function deleteServerGroup($id) | ||
{ | ||
$serverGroup = ServerGroup::find($id); | ||
$serverGroup->delete(); | ||
|
||
$servers = Server::where("servergroup_id", "=", $id)->get(); | ||
|
||
foreach($servers as $server) | ||
{ | ||
$server->servergroup_id = 0; | ||
$server->save(); | ||
} | ||
|
||
$subscriptions = Subscription::where("servergroup_id", "=", $id)->get(); | ||
|
||
foreach($subscriptions as $Subscription) | ||
{ | ||
$Subscription->delete(); | ||
} | ||
|
||
return Response::json(array("success" => true)); | ||
} | ||
|
||
public function getServerGroup($id) | ||
{ | ||
return Response::json(ServerGroup::find($id)); | ||
} | ||
|
||
public function editServerGroup($id) | ||
{ | ||
if (ServerGroup::find($id)->count() > 0) { | ||
//$user = User::where('email','=', Input::get("email"))->get()->first(); | ||
return Response::json(array('success' => false , 'error' => 'Server Group already exists')); | ||
} | ||
|
||
$serverGroup = ServerGroup::find($id); | ||
$serverGroup->name = Input::get("name"); | ||
|
||
$serverGroup->save(); | ||
|
||
return Response::json($serverGroup); | ||
} | ||
} | ||
?> |
Oops, something went wrong.