Example #1
0
<?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";
Functions::check_required_parameters(array($_POST['id'], $_POST['name']));
MySQLQueries::edit_group($_POST['id'], $_POST['name']);
Functions::redirect(Links::render("groups"));
Example #2
0
<?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";
Functions::check_required_parameters(array($_POST['label']));
if (MySQLQueries::is_server_label_unique($_POST['label'])) {
    echo '{"unique":true}';
} else {
    echo '{"unique":false}';
}
Example #3
0
$_SERVER['SCRIPT_NAME'] !== "/controller.php" ? require_once __DIR__ . "/classes/Requires.php" : (Links::$pretty = true);
require_once __DIR__ . "/markdown/markdown.php";
Functions::check_required_parameters(array($_GET['param1']));
$result = MySQLQueries::get_recipe_head_version($_GET['param1']);
$head = MySQLConnection::fetch_object($result);
if (isset($_GET['param2']) && !empty($_GET['param2'])) {
    $recipe_version = $_GET['param2'];
} else {
    $recipe_version = $head->recipe_version;
}
$result = MySQLQueries::get_recipe_by_version($_GET['param1'], $recipe_version);
$recipe = MySQLConnection::fetch_object($result);
$recipe = Functions::format_dates($recipe);
//Get recipe versions
$recipe_versions = array();
$result = MySQLQueries::get_recipe_versions($_GET['param1']);
while ($row = MySQLConnection::fetch_object($result)) {
    ////
    // Move head to the top of the array
    ////
    if ($row->id === $head->recipe_version) {
        array_unshift($recipe_versions, $row);
    } else {
        $recipe_versions[] = $row;
    }
}
//Calculate Statistics
$recipe->lines = substr_count($recipe->content, "\n") + 1;
$recipe->length = Functions::formatBytes(strlen($recipe->content));
//Get the correct language for code-pretty
switch ($recipe->interpreter) {
Example #4
0
 public static function get_db_version()
 {
     $result = MySQLQueries::get_db_version();
     if ($result !== false) {
         $row = MySQLConnection::fetch_object($result);
         return $row->current;
     }
     return null;
 }
Example #5
0
<?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";
Functions::check_required_parameters(array($_GET['id'], $_GET['version']));
if (!CSRF::is_valid(1, METHOD_GET)) {
    Error::halt(400, 'bad request', 'Missing required security token.');
}
MySQLQueries::edit_recipe_head($_GET['id'], $_GET['version']);
Functions::redirect(Links::render("view-recipe", array($_GET['id'])));
Example #6
0
MongoConnection::selectCollection("executions");
//Get groups
$groups = array();
$result = MySQLQueries::get_groups();
while ($row = MySQLConnection::fetch_object($result)) {
    $groups[] = $row;
}
//Get the servers in the default group
$servers_in_default_group = array();
$result = MySQLQueries::get_servers_by_groups(array());
while ($row = MySQLConnection::fetch_object($result)) {
    $servers_in_default_group[] = $row;
}
//Get recipes
$recipes = array();
$result = MySQLQueries::get_recipes();
while ($row = MySQLConnection::fetch_object($result)) {
    $recipes[] = $row;
}
Header::set_title("Commando.io - Execute");
Header::render(array("chosen", "codemirror"));
?>
	<div id="execute-working" class="progress progress-striped active">
  		<div class="bar" style="width: 100%;"></div>
	</div>
<?php 
Navigation::right('<li id="execute-results-jump" class="dropdown" style="display: none;">
	    			   		<a href="#" class="dropdown-toggle" data-toggle="dropdown">
	          					Jump To Results…
	          					<b class="caret"></b>
	    					</a>
Example #7
0
<?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";
Functions::check_required_parameters(array($_POST['id'], $_POST['name'], $_POST['interpreter'], $_POST['content']));
MySQLQueries::edit_recipe($_POST['id'], $_POST['name'], $_POST['interpreter'], $_POST['notes'], $_POST['content']);
Functions::redirect(Links::render("view-recipe", array($_POST['id'])));
Example #8
0
Functions::check_required_parameters(array($_POST['groups'], $_POST['recipe']));
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) {
Example #9
0
# limitations under the License.
*/
require_once dirname(__DIR__) . "/classes/Requires.php";
//Get settings
$result = MySQLQueries::get_settings();
$row = MySQLConnection::fetch_object($result);
$instance_key = null;
if (isset($row->data)) {
    $row->data = json_decode($row->data);
    if (isset($row->data->instance_key) && !empty($row->data->instance_key)) {
        $instance_key = $row->data->instance_key;
    } else {
        $instance_key = Functions::generate_random(9) . uniqid() . Functions::generate_random(8);
        $data = array("instance_key" => $instance_key, "default_ssh_username" => $row->data->default_ssh_username, "default_ssh_port" => $row->data->default_ssh_port, "default_interpreter" => $row->data->default_interpreter, "timezone_offset" => $row->data->timezone_offset, "timezone_daylight_savings" => $row->data->timezone_daylight_savings);
        MySQLQueries::edit_settings(json_encode((object) $data));
    }
} else {
    $instance_key = Functions::generate_random(9) . uniqid() . Functions::generate_random(8);
    $data = array("instance_key" => $instance_key);
    MySQLQueries::edit_settings(json_encode((object) $data));
}
$servers = array();
$result = MySQLQueries::get_servers();
while ($row = MySQLConnection::fetch_object($result)) {
    $servers[] = $row;
}
$payload = '{"event":"' . $instance_key . '","properties":{"token":"678f0669ff58d890eeb50633c91a633d","distinct_id":"' . $instance_key . '","ip":"' . Functions::get_remote_ip() . '","servers":"' . count($servers) . '","version":"' . Version::app . '","ip-address":"' . Functions::get_remote_ip() . '","mp_name_tag":"' . $instance_key . '","time":"' . time() . '"}}';
$curl = new Curl();
$curl->get_request("https://api.mixpanel.com/track/?data=" . base64_encode($payload));
$curl->close();
echo '{"instance_key":"' . $instance_key . '"}';
Example #10
0
Functions::check_required_parameters(array($_GET['param1']));
if (isset($_GET['param2']) && !empty($_GET['param2'])) {
    $recipe_version = $_GET['param2'];
} else {
    $result = MySQLQueries::get_recipe_head_version($_GET['param1']);
    $head = MySQLConnection::fetch_object($result);
    ////
    // Invalid recipe id
    ////
    if (empty($head)) {
        Error::halt(404, 'not found', 'Recipe \'' . $_GET['param1'] . '\' does not exist.');
    } else {
        $recipe_version = $head->recipe_version;
    }
}
$result = MySQLQueries::get_recipe_by_version($_GET['param1'], $recipe_version);
$recipe = MySQLConnection::fetch_object($result);
////
// Invalid recipe version
////
if (empty($recipe)) {
    Error::halt(404, 'not found', 'Recipe version \'' . $_GET['param1'] . '\' does not exist.');
}
$file_extension = null;
switch ($recipe->interpreter) {
    case 'shell':
        $file_extension = ".sh";
        break;
    case 'bash':
        $file_extension = ".sh";
        break;
Example #11
0
<?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";
Functions::check_required_parameters(array($_POST['id']));
MySQLQueries::delete_group($_POST['id']);
echo '{"deleted":true}';
Example #12
0
 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;
 }
Example #13
0
<?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";
Functions::check_required_parameters(array($_POST['ids']));
//$ids 'should' be an array
$ids = json_decode($_POST['ids']);
if ($ids == null) {
    //Output error details
    Error::halt(400, 'bad request', 'Parameter \'ids\' is invalid JSON.');
}
MySQLQueries::delete_recipes($ids);
echo '{"deleted":' . count($ids) . '}';
Example #14
0
<?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";
Functions::check_required_parameters(array($_POST['id']));
$result = MySQLQueries::get_server($_POST['id']);
$row = MySQLConnection::fetch_object($result);
$row = Functions::format_dates($row);
echo json_encode($row);
Example #15
0
# limitations under the License.
*/
$_SERVER['SCRIPT_NAME'] !== "/controller.php" ? header("Location: /") : null;
//Get servers
$servers = array();
$result = MySQLQueries::get_servers();
while ($row = MySQLConnection::fetch_object($result)) {
    if (isset($servers[$row->group_name])) {
        array_push($servers[$row->group_name], $row);
    } else {
        $servers[$row->group_name] = array($row);
    }
}
//Get groups
$groups = array();
$result = MySQLQueries::get_groups();
while ($row = MySQLConnection::fetch_object($result)) {
    $groups[] = $row;
}
Header::set_title("Commando.io - Servers");
Header::render(array("chosen", "code-pretty", "tagsinput"));
Navigation::render("servers");
?>
	<!-- add server modal -->
	<div class="modal fade" id="add-server" style="display: none;">
	  <div class="modal-header">
	    <a class="close" data-dismiss="modal">×</a>
	    <h3>Add Server</h3>
	  </div>
	  <div class="modal-body">
	    <form id="form-add-server" class="well form-horizontal" method="post" action="/actions/add_server.php">
Example #16
0
<?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";
Functions::check_required_parameters(array($_POST['label'], $_POST['address'], $_POST['ssh_username'], $_POST['ssh_port']));
MySQLQueries::add_server($_POST['label'], $_POST['group'], $_POST['tags'], $_POST['address'], $_POST['ssh_username'], $_POST['ssh_port']);
Functions::redirect(Links::render("servers"));
Example #17
0
<?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";
Functions::check_required_parameters(array($_POST['id']));
MySQLQueries::delete_server($_POST['id']);
echo '{"deleted":true}';
Example #18
0
<?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";
$data = array("default_ssh_username" => $_POST['default_ssh_username'], "default_ssh_port" => $_POST['default_ssh_port'], "default_interpreter" => $_POST['default_interpreter'], "timezone_offset" => $_POST['timezone_offset'], "timezone_daylight_savings" => $_POST['timezone_daylight_savings']);
$result = MySQLQueries::edit_settings(json_encode((object) $data));
Functions::redirect("/settings/saved");
Example #19
0
<?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";
Functions::check_required_parameters(array($_GET['id']));
if (!CSRF::is_valid(METHOD_GET)) {
    Error::halt(400, 'bad request', 'Missing required security token.');
}
MySQLQueries::delete_recipes(array($_GET['id']));
Functions::redirect(Links::render("recipes"));
Example #20
0
<?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";
Functions::check_required_parameters(array($_POST['id']));
$result = MySQLQueries::get_group($_POST['id']);
$row = MySQLConnection::fetch_object($result);
$row = Functions::format_dates($row);
echo json_encode($row);
Example #21
0
<?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";
Functions::check_required_parameters(array($_POST['name']));
MySQLQueries::add_group($_POST['name']);
Functions::redirect(Links::render("groups"));
Example #22
0
# 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);
//Get recipes
$recipes = array();
$result = MySQLQueries::get_recipes();
while ($row = MySQLConnection::fetch_object($result)) {
    //Calculate Statistics
    $row->lines = substr_count($row->content, "\n") + 1;
    $row->length = Functions::format_bytes(strlen($row->content));
    $recipes[$row->id] = $row;
}
//Get number of versions for all recipes
$result = MySQLQueries::get_number_of_recipe_versions();
while ($row = MySQLConnection::fetch_object($result)) {
    $recipes[$row->id]->number_of_versions = $row->count;
}
$recipes = Functions::format_dates($recipes);
Header::set_title("Commando.io - Recipes");
Header::render();
Navigation::render("recipes");
?>
    
    <div class="container">
           
      <h1 class="header">Recipes</h1> 
      
	  <div class="row">
   	  	<div class="span12">
Example #23
0
# 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.
*/
$_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;
?>
Example #24
0
<?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";
Functions::check_required_parameters(array($_POST['name']));
if (MySQLQueries::is_recipe_name_unique($_POST['name'])) {
    echo '{"unique":true}';
} else {
    echo '{"unique":false}';
}
Example #25
0
<?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);
Example #26
0
<?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";
Functions::check_required_parameters(array($_POST['name']));
if (MySQLQueries::is_group_name_unique($_POST['name'])) {
    echo '{"unique":true}';
} else {
    echo '{"unique":false}';
}