// load our config data if (file_exists("scripts/inc.config.php")) { require 'scripts/inc.config.php'; // ensure we are being called from our configured host if ($defined['hostname'] === $_SERVER['SERVER_NAME']) { // Initialize classes $db = new dbConn(); $err = new GenerateErrors(); $tpl = new Template(); $skin = new PageSkinner(); $val = new ValidateStrings(); $menu = new GenerateNavMenu(); $auth = new Authenticate(); $encrypt = new Encryption(); $level = new AccessLevels(); $misc = new MiscFunctions(); $debug = new DebugData(); $enc = new Encryption(); // initialize a db connection handle $dbconn = $db->dbConnect($defined['dbhost'], $defined['username'], $defined['password'], $defined['dbname']); // ensure our sessions are present if (empty($_SESSION['token'])) { $sessions = new dbSession(); } //define the template and cache directories $tpl->strTemplateDir = $defined['virpath'] . 'templates'; $tpl->strCacheDir = '/tmp'; if (!empty($_GET) || !empty($_POST)) { $flag = "TRUE"; } else { $flag = "FALSE";
// load our config data if (file_exists("scripts/inc.config.php")) { require 'scripts/inc.config.php'; // ensure we are being called from our configured host if ($defined['hostname'] === $_SERVER['SERVER_NAME']) { // Initialize classes $db = new dbConn(); $err = new GenerateErrors(); $tpl = new Template(); $skin = new PageSkinner(); $val = new ValidateStrings(); $menu = new GenerateNavMenu(); $auth = new Authenticate(); $encrypt = new Encryption(); $level = new AccessLevels(); $misc = new MiscFunctions(); $debug = new DebugData(); // initialize a db connection handle $dbconn = $db->dbConnect($defined['dbhost'], $defined['username'], $defined['password'], $defined['dbname']); // ensure our sessions are present if (empty($_SESSION['token'])) { $sessions = new dbSession(); } //define the template and cache directories $tpl->strTemplateDir = $defined['virpath'] . 'templates'; $tpl->strCacheDir = '/tmp'; if (!empty($_GET) || !empty($_POST)) { $flag = "TRUE"; } else { $flag = "FALSE"; }
*/ // load our config data if (file_exists("scripts/inc.config.php")) { require 'scripts/inc.config.php'; // ensure we are being called from our configured host if ($defined['hostname'] === $_SERVER['SERVER_NAME']) { // Initialize classes $db = new dbConn(); $err = new GenerateErrors(); $tpl = new Template(); $skin = new PageSkinner(); $val = new ValidateStrings(); $menu = new GenerateNavMenu(); $auth = new Authenticate(); $level = new AccessLevels(); $misc = new MiscFunctions(); $debug = new DebugData(); // initialize a db connection handle $dbconn = $db->dbConnect($defined['dbhost'], $defined['username'], $defined['password'], $defined['dbname']); // ensure our sessions are present if (empty($_SESSION['token'])) { $sessions = new dbSession(); } //define the template and cache directories $tpl->strTemplateDir = $defined['virpath'] . 'templates'; $tpl->strCacheDir = '/tmp'; if (!empty($_GET) || !empty($_POST)) { $flag = "TRUE"; } else { $flag = "FALSE"; }
function AuthUser($user, $pass, $token) { // our global config opts global $defined; // initialize classes $db = new dbConn(); $val = new ValidateStrings(); $lib = new Authenticate(); $auth = new Encryption(); $sess = new Sessions(); $misc = new MiscFunctions(); $exit = new ExitApp(); // check our authentication requirements if (empty($user) && empty($pass) && empty($token)) { return -1; } // we have an existing authentication token present if (!empty($token) && empty($user) && empty($pass)) { $array = $auth->DecodeAuthToken($token); $user = base64_decode($array[0]); $pass = base64_decode($array[1]); $time = $array[4]; $current = $misc->GenTime(); if ($lib->AuthTimeOut($defined['timeout'], $time, $current) === -1) { return -2; } } // perform validation on username and password if ($val->ValidateAlphaChar($user) === -1 || $val->ValidateParagraph($pass) === -1) { return -3; } // see if the user exists for authenticaiton $data = $db->dbConnect($defined['dbhost'], $defined['username'], $defined['password'], $defined['dbname']); $query = "SELECT * FROM `auth_users` WHERE `username` = \"{$user}\" AND `password` = sha1( \"{$pass}\" )"; $query = $val->ValidateSQL($query, $data); // database problem if (($value = $db->dbQuery($query, $data)) === -1) { return -5; } // check user match if ($db->dbNumRows($value) === -1 || $db->dbNumRows($value) === 0) { return -4; } else { $return = 0; } // create our authentication session token if (empty($token)) { $array = $db->dbArrayResults($value); $x = $auth->GeneratePrivateKey($defined['enckeygen']); $access_date = $misc->GenDate(); $access_time = $misc->GenTimeRead(); $query = "UPDATE `auth_users` SET `access_date` = \"" . $access_date . "\", `access_time` = \"" . $access_time . "\", `session` = \"{$x}\" WHERE `id` = \"" . $array[0]['id'] . "\""; $value = $val->ValidateSQL($query, $data); if (($value = $db->dbQuery($value, $data)) === -1) { return -5; } $x = $auth->EncodePrivToHex($x); if (($token = $auth->EncodeAuthToken($array[0]['username'], $pass, $array[0]['level'], $array[0]['group'], $misc->GenTime(), $x)) !== -1) { $sess->RegisterSession("token", $token); $return = 0; } } $db->dbFreeData($query); $db->dbCloseConn($data); return $return; }
// just some defs $LIBERROR = NULL; $CONFIGERRORS = NULL; // ensure we are being called from our configured host if ($defined['hostname'] === $_SERVER['SERVER_NAME']) { // Initialize classes $db = new dbConn(); $err = new GenerateErrors(); $tpl = new Template(); $skin = new PageSkinner(); $val = new ValidateStrings(); $menu = new GenerateNavMenu(); $auth = new Authenticate(); $encrypt = new Encryption(); $level = new AccessLevels(); $misc = new MiscFunctions(); $debug = new DebugData(); // initialize a db connection handle $dbconn = $db->dbConnect($defined['dbhost'], $defined['username'], $defined['password'], $defined['dbname']); // ensure our sessions are present if (empty($_SESSION['token'])) { $sessions = new dbSession(); } //define the template and cache directories $tpl->strTemplateDir = $defined['virpath'] . 'templates'; $tpl->strCacheDir = '/tmp'; if (!empty($_GET) || !empty($_POST)) { $flag = "TRUE"; } else { $flag = "FALSE"; }
// load our config data if (file_exists("../../../scripts/inc.config.php")) { require '../../../scripts/inc.config.php'; // ensure we are being called from our configured host if ($defined['hostname'] === $_SERVER['SERVER_NAME']) { // Initialize classes $db = new dbConn(); $err = new GenerateErrors(); $tpl = new Template(); $skin = new PageSkinner(); $val = new ValidateStrings(); $menu = new GenerateNavMenu(); $auth = new Authenticate(); $encrypt = new Encryption(); $level = new AccessLevels(); $misc = new MiscFunctions(); $debug = new DebugData(); // initialize a db connection handle $dbconn = $db->dbConnect($defined['dbhost'], $defined['username'], $defined['password'], $defined['dbname']); // ensure our sessions are present if (empty($_SESSION['token'])) { $sessions = new dbSession(); } //define the template and cache directories $tpl->strTemplateDir = '../../../../templates'; $tpl->strCacheDir = '/tmp'; if (!empty($_GET) || !empty($_POST)) { $flag = "TRUE"; } else { $flag = "FALSE"; }
<?php /* * phpDHCPAdmin * Jason Gerfen [jason.gerfen@gmail.com] * * cron.restart.dhcpd.php - Handle crontab restarting of the ISC DHCPD service */ // load our config data if (file_exists('../scripts/inc.config.php')) { require '../scripts/inc.config.php'; global $defined; // open up some handles $db = new dbConn(); $val = new ValidateStrings(); $misc = new MiscFunctions(); // attempt to get a list of networks the net adapter(s) are listening on $misc->GetAdapters(); // process lease data $misc->GetCurrentLeases($defined['leases']); // look to see if we need to recreate the leases file $dbconn = $db->dbConnect($defined['dbhost'], $defined['username'], $defined['password'], $defined['dbname']); $query = "SELECT `recreate` FROM `conf_leases_properties` WHERE `id` = \"1\""; if (($value = $db->dbQuery($val->ValidateSQL($query, $dbconn), $dbconn)) === 0) { $data = $db->dbArrayResults($value); } // do we recreate? if ($data[0]['recreate'] === "TRUE") { echo "LEASES: We are going to recreate the current " . $defined['leases'] . "file. Please wait...\n"; } // Check for file that flags a restart
/* * phpDHCPAdmin * Jason Gerfen [jason.gerfen@gmail.com] * * setup.php - Setup script */ // get our libraries require '../scripts/classes/class.dbase.php'; require '../scripts/classes/class.errors.php'; require '../scripts/classes/class.validation.php'; require '../scripts/classes/class.libraries.php'; // init our libraries $db = new dbConn(); $err = new GenerateErrors(); $val = new ValidateStrings(); $misc = new MiscFunctions(); // Assign some defaults since nothing is configured $TITLE = "phpDHCPAdmin-0.9.5-beta Setup Wizard"; $STYLE = "../templates/black"; $DESCRIPTION = "I am here to help you import the database structure and setup the application defaults"; $DISCLAIMER = "All rights reserved 2009 ® Jason Gerfen"; $TABLES = array('admin_backup_conf', 'admin_config_algorithm', 'admin_logs', 'admin_sessions', 'auth_groups', 'auth_levels', 'auth_users', 'conf_adapters', 'conf_classes', 'conf_classes_options', 'conf_classes_opts', 'conf_dnssec_opts', 'conf_dns_opts', 'conf_failover', 'conf_global_opts', 'conf_hosts', 'conf_leases', 'conf_leases_properties', 'conf_pools', 'conf_pxe_groups', 'conf_pxe_opts', 'conf_shared_networks', 'conf_subnets', 'conf_traffic'); $REGEX = array('/\\$defined[\'hostname\']\\s\\s\\s\\s=\\s\\"\\";/', '/\\$defined[\'dbhost\']\\s\\s\\s\\s\\s\\s=\\s\\"localhost\\";/', '/\\$defined[\'username\']\\s\\s\\s\\s=\\s\\"\\";/', '/\\$defined[\'password\']\\s\\s\\s\\s=\\s\\"\\";/', '/\\$defined[\'mail\']\\s\\s\\s\\s\\s\\s\\s\\s=\\s\\"\\";/', '/\\$defined[\'virpath\']\\s\\s\\s\\s\\s=\\s\\"\\";/'); // lets process the form if (!empty($_POST)) { // make sure we have a complete form submission if (!empty($_POST['mysql_root_user']) && !empty($_POST['mysql_root_passwd']) && !empty($_POST['defined_hostname']) && !empty($_POST['mysql_server_address']) && !empty($_POST['mysql_server_username']) && !empty($_POST['mysql_server_password']) && !empty($_POST['configuration_path']) && !empty($_POST['admin_email'])) { // ensure nothing screwy is going on in regards to input if ($val->ValidateString($_POST['mysql_root_user']) !== -1 && $val->ValidateParagraph($_POST['mysql_root_passwd']) !== -1 && $val->ValidateDomain($_POST['defined_hostname']) !== -1 && $val->ValidateDomain($_POST['mysql_server_address']) !== -1 && $val->ValidateParagraph($_POST['mysql_server_username']) !== -1 && $val->ValidateParagraph($_POST['mysql_server_password']) !== -1 && $val->ValidateParagraph($_POST['configuration_path']) !== -1 && $val->ValidateEmail($_POST['admin_email']) !== -1) { // ensure our root username & password is correct $dbconn = $db->dbConnectOnly($_POST['mysql_server_address'], $_POST['mysql_root_user'], $_POST['mysql_root_passwd']);