<?php /* # Copyright 2012 NodeSocket, LLC # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. */ require_once dirname(__DIR__) . "/classes/Requires.php"; $result = MySQLQueries::get_settings(); $settings = null; $result = MySQLQueries::get_settings(); $row = MySQLConnection::fetch_object($result); if (isset($row->data)) { $row->data = json_decode($row->data); } $settings = $row; Functions::format_dates($settings); echo json_encode($settings);
# you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. */ $_SERVER['SCRIPT_NAME'] !== "/controller.php" ? require_once __DIR__ . "/classes/Requires.php" : (Links::$pretty = true); Functions::check_required_parameters(array($_GET['param1'])); //Get recipe $result = MySQLQueries::get_recipe($_GET['param1']); $recipe = MySQLConnection::fetch_object($result); $recipe = Functions::format_dates($recipe); $interpreters = array("shell", "bash", "perl", "python", "node.js"); Header::set_title("Commando.io - Edit Recipe"); Header::render(array("chosen", "codemirror")); Navigation::render("recipes"); ?> <div class="container"> <div class="row"> <div class="span12"> <h1 class="header" style="float: left;"><?php echo $recipe->name; ?> </h1>
if (!CSRF::is_valid()) { Error::halt(400, 'bad request', 'Missing required security token.'); } $result = MySQLQueries::get_recipe($_POST['recipe']); $recipe = MySQLConnection::fetch_object($result); if (empty($recipe)) { //Output error details Error::halt(400, 'bad request', 'The recipe \'' . $_POST['recipe'] . '\' does not exist.'); } //Default group handling if (count($_POST['groups']) === 1 && empty($_POST['groups'][0])) { $_POST['groups'] = array(); } $servers = array(); $results = MySQLQueries::get_servers_by_groups($_POST['groups']); while ($row = MySQLConnection::fetch_object($results)) { $servers[] = $row; } $returned_results = array(); foreach ($servers as $server) { try { $ssh = new SSH($server->address, $server->ssh_port, THROW_ERROR); } catch (Exception $ex) { $ex = json_decode($ex->getMessage()); $returned_results[] = array("server" => $server->id, "server_label" => $server->label, "stream" => "error", "result" => $ex->error->message); continue; } try { $ssh_auth = $ssh->auth($server->ssh_username, SSH_PUBLIC_KEY_PATH, SSH_PRIVATE_KEY_PATH, THROW_ERROR); } catch (Exception $ex) { $ex = json_decode($ex->getMessage());
public static function get_db_version() { $result = MySQLQueries::get_db_version(); if ($result !== false) { $row = MySQLConnection::fetch_object($result); return $row->current; } return null; }
public static function get_timezone_offset() { if (defined("TIMEZONE_OFFSET")) { return TIMEZONE_OFFSET; } //Get settings $settings = null; $result = MySQLQueries::get_settings(false); $row = MySQLConnection::fetch_object($result); if (isset($row->data)) { $row->data = json_decode($row->data); } $settings = $row; if (isset($settings->data->timezone_offset)) { if (isset($settings->data->timezone_daylight_savings) && $settings->data->timezone_daylight_savings) { $hours = substr($settings->data->timezone_offset, 0, 3); $offsetted_hours = $hours + 1; if ($offsetted_hours < 0 && substr($offsetted_hours, 0, 1) == "-") { $offsetted_hours = "-" . str_pad(str_replace("-", "", $offsetted_hours), 2, "0", STR_PAD_LEFT); } else { $offsetted_hours = "+" . str_pad($offsetted_hours, 2, "0", STR_PAD_LEFT); } define("TIMEZONE_OFFSET", str_replace($hours, $offsetted_hours, $settings->data->timezone_offset)); } else { define("TIMEZONE_OFFSET", $settings->data->timezone_offset); } } else { define("TIMEZONE_OFFSET", "+00:00"); } return TIMEZONE_OFFSET; }