function do_delete() { $class_id = $_REQUEST["class"]; if (!is_numeric($class_id)) { die("go away, loser"); } $class_obj = HardwareClass::load_from_id($class_id); $class_obj->remove(); }
public function find_from_mac($mac) { if (($mac = validate_mac($mac)) === 0) { die("invalid MAC address passed"); } $mac = mysql_escape_string($mac); $result = mysql_query("select class_id from class_map where mac='{$mac}'") or die("query to get class from MAC failed: " . mysql_error()); if ($row = mysql_fetch_row($result)) { return HardwareClass::load_from_id($row[0]); } else { return 0; } }
# hardware_class:$class - echoes the numeric class ID of the requestor # config_override:$path:$sig:$url - a configuration file override. # This is followed by a URL where the override can be retrieved, # and a base64-encoded RSA signature of the file. # kernel:$sig:$url - location and signature of the latest kernel image # image:$sig:$url - location and signature of the latest software image require_once "dbfuncs.php"; init_db(); if (!array_key_exists("mac", $_REQUEST)) { die("MAC address unspecified"); } $mac = $_REQUEST["mac"]; if (($mac = validate_mac($mac)) === 0) { die("invalid MAC address"); } if (($class = HardwareClass::find_from_mac($mac)) == 0) { print "system_mac:{$mac}\n"; print "system_unregistered\n"; die; } print "system_mac:{$mac}\n"; print "hardware_class:" . $class->get_id() . "\n"; foreach ($class->list_overrides() as $path) { print "config_override:{$path}"; print ":" . $class->get_override_sig($path) . ":"; print BASE_URL; print "/get_config.php?class=" . $class->get_id() . "&path="; print urlencode($path); print "\n"; } foreach ($class->list_files() as $file) {
*/ require_once "dbfuncs.php"; init_db(); $class_id = $_REQUEST["class"]; if (!is_numeric($class_id)) { die("go away, loser"); } function do_write($class_obj, $path) { if (!array_key_exists("text", $_REQUEST)) { die("text not specified for config write"); } $data = str_replace("\r\n", "\n", $_REQUEST["text"]); $class_obj->edit_override($path, $data); } $class_obj = HardwareClass::load_from_id($class_id); if (!array_key_exists("path", $_REQUEST)) { die("override path not specified"); } $path = $_REQUEST["path"]; if (array_key_exists("action", $_REQUEST)) { $action = $_REQUEST["action"]; switch ($action) { # handle different actions case "write": do_write($class_obj, $path); } } ?> <html> <head>
* @package Concerto * @author Web Technologies Group, $Author$ * @copyright Rensselaer Polytechnic Institute * @license GPLv2, see www.gnu.org/licenses/gpl-2.0.html * @version $Revision$ */ # This returns a file with multiple lines indicating the various # possibilities for individualized configuration. # These are documented below. # system_mac:$mac - echoes back the MAC of the requesting system # hardware_class:$class - echoes the numeric class ID of the requestor # config_override:$path:$sig:$url - a configuration file override. # This is followed by a URL where the override can be retrieved, # and a base64-encoded RSA signature of the file. # kernel:$sig:$url - location and signature of the latest kernel image # image:$sig:$url - location and signature of the latest software image require_once "dbfuncs.php"; init_db(); if (!array_key_exists("class", $_REQUEST)) { die("hardware class unspecified"); } if (($class = HardwareClass::load_from_id($_REQUEST["class"])) == 0) { die("hardware class invalid"); } if (!array_key_exists("path", $_REQUEST)) { die("config file unspecified"); } if (($override = $class->get_override($_REQUEST["path"])) === 0) { die("override does not exist"); } print $override;