Exemple #1
0
 /**
  * Assigns values about network to be processed by the Smarty engine.
  *
  * @param object $smarty Smarty object
  * @param object $net    Network object
  *
  * @return void
  */
 public static function assignSmartyValues($smarty, $net = null)
 {
     if (!$net) {
         $net = Network::getCurrentNetwork();
     }
     // Set network details
     $smarty->assign('networkName', $net ? $net->getName() : '');
     $smarty->assign('networkWebSiteURL', $net ? $net->getWebSiteURL() : '');
     // Set networks usage information
     $smarty->assign('networkNumOnlineUsers', $net ? $net->getNumOnlineUsers() : 0);
     // Set networks node information
     $smarty->assign('networkNumDeployedNodes', $net ? $net->getNumDeployedNodes() : 0);
     $smarty->assign('networkNumOnlineNodes', $net ? $net->getNumOnlineNodes() : 0);
     $smarty->assign('networkNumNonMonitoredNodes', $net ? $net->getNumOnlineNodes(true) : 0);
 }
Exemple #2
0
 /** Menu hook function */
 public static function hookMenu()
 {
     $items = array();
     $network = Network::getCurrentNetwork();
     $server = Server::getServer();
     if (Security::hasAnyPermission(array(array(Permission::P('NETWORK_PERM_VIEW_ONLINE_USERS'), $network)))) {
         $items[] = array('path' => 'users/online_users', 'title' => _("Online Users"), 'url' => BASE_URL_PATH . "admin/online_users.php");
     }
     if (Security::hasPermission(Permission::P('SERVER_PERM_EDIT_SERVER_CONFIG'), $server)) {
         $items[] = array('path' => 'users/import_nocat', 'title' => _("Import NoCat user database"), 'url' => BASE_URL_PATH . "admin/import_user_database.php");
     }
     if (Security::getObjectsWithPermission(Permission::P('NETWORK_PERM_EDIT_ANY_USER'))) {
         $items[] = array('path' => 'users/user_manager', 'title' => _("User manager"), 'url' => BASE_URL_PATH . "admin/user_log.php");
     }
     if (Security::getObjectsWithPermission(Permission::P('NETWORK_PERM_VIEW_STATISTICS'))) {
         $items[] = array('path' => 'users/statistics', 'title' => _("Statistics"), 'url' => BASE_URL_PATH . "admin/stats.php");
     }
     $items[] = array('path' => 'users', 'title' => _('User administration'), 'type' => MENU_ITEM_GROUPING);
     return $items;
 }
Exemple #3
0
 */
// Set section of Smarty template
$smarty->assign('sectionMAINCONTENT', true);
// Set Google maps information
$smarty->assign('googleMapsEnabled', defined('GMAPS_HOTSPOTS_MAP_ENABLED') && GMAPS_HOTSPOTS_MAP_ENABLED);
if (Server::getServer()->getUseGlobalUserAccounts()) {
    $server = Server::getServer();
    $smarty->assign('serverNumValidUsers', $server ? $server->getTotalNumValidUsers() : 0);
    $smarty->assign('serverNumOnlineUsers', $server ? $server->getTotalNumOnlineUsers() : 0);
    $smarty->assign('serverNumDeployedNodes', $server ? $server->getTotalNumDeployedNodes() : 0);
    $smarty->assign('serverNumOnlineNodes', $server ? $server->getNumOnlineNodes() : 0);
    $smarty->assign('serverNumNonMonitoredNodes', $server ? $server->getNumOnlineNodes(true) : 0);
    // Compile HTML code
    $html_body = $smarty->fetch("templates/sites/indexglobaluser.tpl");
} else {
    $net = Network::getCurrentNetwork();
    $smarty->assign('networkNumValidUsers', $net ? $net->getNumValidUsers() : 0);
    // Compile HTML code
    $html_body = $smarty->fetch("templates/sites/index.tpl");
}
/*
 * Don't redirect on the index page
 *
$currentNode = Node::getCurrentRealNode();
if($currentNode){
    header("Location: ".BASE_URL_PATH."portal/?node_id=".$currentNode->getId());
    exit();
}
*/
/*
 * Render output
Exemple #4
0
 public static function redirect($redirect_url, $redirect_to_title = null, $timeout = 60)
 {
     if (!$redirect_to_title) {
         $network = Network::getCurrentNetwork();
         $redirect_to_title = $network ? sprintf(_("%s Login"), $network->getName()) : _("Login");
     }
     header("Location: {$redirect_url}");
     echo "<html>\n" . "<head><meta http-equiv='Refresh' content='{$timeout}; URL={$redirect_url}'/></head>\n" . "<body>\n" . "<noscript>\n" . "<span style='display:none;'>\n" . "<h1>" . $redirect_to_title . "</h1>\n" . sprintf(_("Click <a href='%s'>here</a> to continue"), $redirect_url) . "<br/>\n" . _("The transfer from secure login back to regular http may cause a warning.") . "\n" . "</span>\n" . "</noscript>\n" . "</body>\n" . "</html>\n";
     exit;
 }
// |                                                                   |
// +-------------------------------------------------------------------+
/**
 * @package    WiFiDogAuthServer
 * @author     Philippe April
 * @copyright  2004-2006 Philippe April
 * @version    Subversion $Id$
 * @link       http://www.wifidog.org/
 */
/**
 * Load common include file
 */
require_once 'admin_common.php';
require_once 'classes/Node.php';
require_once 'classes/MainUI.php';
Security::requirePermission(Permission::P('NETWORK_PERM_VIEW_ONLINE_USERS'), Network::getCurrentNetwork());
$db = AbstractDb::getObject();
$smarty = SmartyWifidog::getObject();
$online_users = null;
$db->execSql("SELECT connections.user_id, name, username, account_origin, timestamp_in, incoming, outgoing FROM users,nodes,connections JOIN tokens USING (token_id) WHERE token_status='" . TOKEN_INUSE . "' AND users.user_id=connections.user_id AND nodes.node_id=connections.node_id ORDER BY account_origin, timestamp_in DESC", $online_users);
$smarty->assign("users_array", $online_users);
$ui = MainUI::getObject();
$ui->addContent('main_area_middle', $smarty->fetch("admin/templates/online_users.html"));
$ui->display();
/*
 * Local variables:
 * tab-width: 4
 * c-basic-offset: 4
 * c-hanging-comment-ender-p: nil
 * End:
 */
Exemple #6
0
 /**
  * Create a new Node in the database
  *
  * @param string $gw_id The Id of the gatewqay to be associated with
  * thisnode. If not present, a dummy value will be assigned.
  * @param object $network Network object.  The node's network.  If not
  *                        present, the current Network will be assigned
  *
  * @return mixed The newly created Node object, or null if there was
  *               an error
  *
  * @static
  * @access public
  */
 public static function createNewObject($gw_id = null, $network = null)
 {
     $db = AbstractDb::getObject();
     if (empty($gw_id)) {
         $gw_id = $db->escapeString(_('PUT_GATEWAY_ID_HERE'));
     } else {
         $gw_id = $db->escapeString($gw_id);
     }
     $node_id = get_guid();
     if (empty($network)) {
         $network = Network::getCurrentNetwork();
     }
     $network_id = $db->escapeString($network->getId());
     $node_deployment_status = $db->escapeString("IN_PLANNING");
     $node_name = _("New node");
     $duplicate = null;
     try {
         $duplicate = Node::getObjectByGatewayId($gw_id);
     } catch (Exception $e) {
     }
     if ($duplicate) {
         throw new Exception(sprintf(_('Sorry, a node for the gateway %s already exists.'), $gw_id));
     }
     $sql = "INSERT INTO nodes (node_id, gw_id, network_id, creation_date, node_deployment_status, name) VALUES ('{$node_id}', '{$gw_id}', '{$network_id}', CURRENT_TIMESTAMP,'{$node_deployment_status}', '{$node_name}')";
     if (!$db->execSqlUpdate($sql, false)) {
         throw new Exception(_('Unable to insert new node into database!'));
     }
     HotspotGraphElement::createNewObject($node_id, 'Node', $network);
     $object = self::getObject($node_id);
     return $object;
 }
Exemple #7
0
 /**
  * Create a new Node group in the database
  *
  * @param string $ng_name The name of the new node group to create.  If empty a dummy value will be set
  * @param object $network Network object.  The node's network.  If not
  *                        present, the current Network will be assigned
  *
  * @return mixed The newly created Node Group object, or null if there was
  *               an error
  *
  * @static
  * @access public
  */
 public static function createNewObject($ng_name = null, $network = null)
 {
     $db = AbstractDb::getObject();
     if (empty($ng_name)) {
         $ng_name = $db->escapeString(_('New node group name'));
     } else {
         $ng_name = $db->escapeString($ng_name);
     }
     $node_group_id = get_guid();
     if (empty($network)) {
         $network = Network::getCurrentNetwork();
     }
     $network_id = $db->escapeString($network->getId());
     $duplicate = null;
     try {
         $duplicate = NodeGroup::getObjectByName($ng_name);
     } catch (Exception $e) {
     }
     if ($duplicate) {
         throw new Exception(sprintf(_('Sorry, a node group with the name %s already exists.'), $ng_name));
     }
     $sql = "INSERT INTO node_groups (node_group_id, name) VALUES ('{$node_group_id}', '{$ng_name}')";
     if (!$db->execSqlUpdate($sql, false)) {
         throw new Exception(_('Unable to insert new node group into database!'));
     }
     HotspotGraphElement::createNewObject($node_group_id, 'NodeGroup', $network);
     $object = self::getObject($node_group_id);
     return $object;
 }
 /**
  * Create a new Content object in the database
  *
  * @param string $server_id The server id of the new server. If absent,
  *                           will be assigned a guid.
  *
  * @return mixed The newly created object, or null if there was an error
  *
  * @see GenericObject
  *
  * @static
  * @access public
  */
 public static function createNewObject($hostname)
 {
     $db = AbstractDb::getObject();
     if (empty($id)) {
         $id = get_guid();
     }
     $id = $db->escapeString($id);
     $hostname = $db->escapeString($hostname);
     $networkId = Network::getCurrentNetwork()->getId();
     $sql = "INSERT INTO virtual_hosts (virtual_host_id, hostname, default_network) VALUES ('{$id}', '{$hostname}', '{$networkId}')";
     if (!$db->execSqlUpdate($sql, false)) {
         throw new Exception(_('Unable to insert the new server in the database!'));
     }
     $_object = self::getObject($id);
     return $_object;
 }
Exemple #9
0
 public function formatEvent($event, $info = null)
 {
     $dt = date("Y-m-d H:i:s (T)", $event->getTimestamp());
     $myFilename = $event->getFilename();
     $myLinenum = $event->getLinenum();
     // Get information about node
     $myCurrentNode = Node::getCurrentNode();
     if (empty($myCurrentNode)) {
         $myNodeName = '*nonode*';
     } else {
         $myNodeName = $myCurrentNode->getName();
     }
     // Get information about network
     $myNetwork = Network::getCurrentNetwork();
     if (empty($myNetwork)) {
         $myNetworkName = '*nonetwork*';
     } else {
         $myNetworkName = $myNetwork->getName();
     }
     // Get information about user
     $myCurrentUser = User::getCurrentUser();
     if (empty($myCurrentUser)) {
         $myUserName = '******';
     } else {
         $myUserName = $myCurrentUser->getUsername();
     }
     $string = "{$dt} " . EventObject::PrettyErrorType($event->getLayoutType()) . " >{$myNetworkName} >{$myUserName}@{$myNodeName} [" . $_SERVER['REQUEST_URI'] . "]" . ": " . $event->getMessage() . (!empty($myFilename) ? " in {$myFilename}" . (!empty($myLinenum) ? " on line {$myLinenum}" : "") : "") . "\n";
     if ($event->classifyErrorType() == 'error') {
         $string .= "   Stack Backtrace\n" . self::FormatBacktrace($event->getContext()) . "\n";
     }
     return $string;
 }
Exemple #10
0
 /**
  * Verify the given user credentials against the wifidog database 
  * @param $username   The username to authenticate
  * @param $pwdhash    The password hash
  * @param $gw_id      The gateway id
  * @param $gw_ip   	  The gateway's ip addresss
  * @param $mac			  The mac address of the user
  * @param $gw_port	  The port of the gateway's http server
  * @param $from 			The ip address of the user on the node
  * @param $logout			Whether the user wants to logout
  * @return unknown_type
  */
 protected function executeAuth($username = null, $password = null, $gw_id = null, $gw_ip = null, $mac = null, $gw_port = null, $from = null, $logout = false)
 {
     $this->_outputArr['auth'] = 0;
     require_once 'classes/Node.php';
     require_once 'classes/User.php';
     require_once 'classes/Network.php';
     require_once 'classes/Authenticator.php';
     if (!is_null($gw_id)) {
         if (is_null($gw_ip) || is_null($gw_port) || is_null($from)) {
             throw new WSException("Missing information on the gateway.  You must specify parameter 'gw_address' AND 'gw_port' AND 'from_ip' if the parameter 'gw_id' is specified.", WSException::INVALID_PARAMETER);
         }
         $node = Node::getObjectByGatewayId($gw_id);
         if ($node) {
             $network = $node->getNetwork();
         } else {
             throw new WSException("Node identified by {$gw_id} cannot be found", WSException::PROCESS_ERROR);
         }
     } else {
         // Gateway ID is not set ... virtual login
         $network = Network::getCurrentNetwork();
         $node = null;
     }
     /*
      * If this is a splash-only node, then the user is automatically authenticated
      */
     $token = null;
     if (!empty($node) && $node->isSplashOnly()) {
         $this->_outputArr['auth'] = 1;
         $user = $network->getSplashOnlyUser();
         $token = $user->generateConnectionTokenNoSession($node, $from, $mac);
         if (!$token) {
             throw new WSException("User authenticated but cannot generate connection token.", WSException::PROCESS_ERROR);
         }
     } else {
         if (!$logout) {
             // Authenticate the user on the requested network
             $user = $network->getAuthenticator()->login($username, $password, $errMsg, $errNo);
             if (!$user) {
                 $this->_outputArr['auth'] = 0;
                 $this->_outputArr['explanation'] = $errMsg;
                 $this->_outputArr['errorcode'] = $errNo;
             } else {
                 $this->_outputArr['auth'] = 1;
                 if (!is_null($node)) {
                     $token = $user->generateConnectionTokenNoSession($node, $from, $mac);
                     if (!$token) {
                         throw new WSException("User authenticated but cannot generate connection token.", WSException::PROCESS_ERROR);
                     }
                 }
             }
         } else {
             $user = User::getUserByUsernameOrEmail($username);
             User::setCurrentUser($user);
             $network->getAuthenticator()->logout();
             $this->_outputArr['auth'] = 1;
         }
     }
     if ($this->_outputArr['auth'] == 1 && !is_null($token)) {
         $this->_outputArr['forwardTo'] = "http://" . $gw_ip . ":" . $gw_port . "/wifidog/auth?token=" . $token;
     }
 }