Esempio n. 1
0
/**
 * Process recovering username
 */
// Init ALL smarty SWITCH values
$smarty->assign('sectionTOOLCONTENT', false);
$smarty->assign('sectionMAINCONTENT', false);
// Init ALL smarty values
$smarty->assign('message', "");
$smarty->assign('error', "");
$smarty->assign('auth_sources', "");
$smarty->assign('selected_auth_source', "");
$smarty->assign('SelectNetworkUI', "");
$smarty->assign('username', "");
$smarty->assign('email', "");
if (isset($_REQUEST['form_request'])) {
    $account_origin = Network::getObject($_REQUEST['auth_source']);
    try {
        /*
         * Tool content
         */
        // Set section of Smarty template
        $smarty->assign('sectionTOOLCONTENT', true);
        // Compile HTML code
        $html = $smarty->fetch("templates/sites/lost_password.tpl");
        /*
         * Main content
         */
        // Reset ALL smarty SWITCH values
        $smarty->assign('sectionTOOLCONTENT', false);
        $smarty->assign('sectionMAINCONTENT', false);
        // Set section of Smarty template
Esempio n. 2
0
$info = null;
$token = null;
if (!empty($_REQUEST['token'])) {
    $token = $db->escapeString($_REQUEST['token']);
    $dbRetval = $db->execSqlUniqueRes("SELECT CURRENT_TIMESTAMP, *, CASE WHEN ((CURRENT_TIMESTAMP - reg_date) > networks.validation_grace_time) THEN true ELSE false END AS validation_grace_time_expired FROM connections JOIN tokens USING (token_id) JOIN users ON (users.user_id=connections.user_id) JOIN networks ON (users.account_origin = networks.network_id) WHERE connections.token_id='{$token}'", $info, false);
    if ($dbRetval == false) {
        $auth_message .= "| Error: couldn't retrieve the requested token: {$token} because of a SQL error. ";
        $auth_response = ACCOUNT_STATUS_ERROR;
    }
} else {
    $auth_message .= "| Error: no connection token provided. ";
    $auth_response = ACCOUNT_STATUS_DENIED;
}
if ($info != null) {
    // Retrieve the associated authenticator
    $network = Network::getObject($info['account_origin']);
    $authenticator = $network->getAuthenticator();
    if (!$authenticator) {
        $auth_message .= "| Error: Unable to instantiate authenticator. ";
        $auth_response = ACCOUNT_STATUS_ERROR;
    } else {
        if ($_REQUEST['stage'] == STAGE_LOGIN) {
            if ($info['token_status'] == TOKEN_UNUSED) {
                /* This is for the 15 minutes validation period, the exact same code is also present in when the stage is counters.  If you update this one don't forget to update the other one! */
                if ($info['account_status'] == ACCOUNT_STATUS_VALIDATION && $info['validation_grace_time_expired'] == 't') {
                    $auth_response = ACCOUNT_STATUS_VALIDATION_FAILED;
                    $auth_message .= "| The validation grace period which began at " . $info['reg_date'] . " has now expired. ";
                } else {
                    // Start accounting
                    if ($authenticator->acctStart($info['conn_id'], $auth_message)) {
                        $auth_response = ACCOUNT_STATUS_ALLOWED;
Esempio n. 3
0
    }
}
/*
 * Tool content
 */
// Set section of Smarty template
$smarty->assign('sectionTOOLCONTENT', true);
$smarty->assign('sectionMAINCONTENT', false);
// Compile HTML code
$htmlToolContent = $smarty->fetch("templates/sites/signup.tpl");
/*
 * Main content
 */
// Use the account_origin along, if it was set (it may be set in case there was an error processing the form).
if (isset($_REQUEST["auth_source"])) {
    $selectedNetwork = Network::getObject($_REQUEST['auth_source']);
} else {
    $selectedNetwork = Network::getDefaultNetwork();
}
if (Server::getServer()->getUseGlobalUserAccounts()) {
    $smarty->assign('SelectNetworkUI', "<input type=\"hidden\" name=\"auth_source\" value='" . $selectedNetwork->getId() . "' />");
} else {
    //Make sure to only list networks whose authenticator allows user self-signup
    $smarty->assign('SelectNetworkUI', Network::getSelectUI('auth_source', array('preSelectedObject' => $selectedNetwork, 'onlyNetwoksAllowingSignup' => true)));
}
// Set section of Smarty template
$smarty->assign('sectionTOOLCONTENT', false);
$smarty->assign('sectionMAINCONTENT', true);
// Compile HTML code
$htmlMainContent = $smarty->fetch("templates/sites/signup.tpl");
/*
Esempio n. 4
0
    // Check if ordering should ignore uppper and lower case
    if ($sort_by_param == "name" || $sort_by_param == "node_id") {
        $sort_by_param_sql = "lower(" . $sort_by_param . ")";
    } else {
        $sort_by_param_sql = $sort_by_param;
    }
} else {
    $sort_by_param_sql = DEFAULT_SORT_BY_PARAM;
}
if (isset($_REQUEST["network_id"])) {
    $network_id = $_REQUEST["network_id"];
    if ($network_id == "") {
        $network = null;
    } else {
        try {
            $network = Network::getObject($network_id);
        } catch (Exception $e) {
            $network = Network::getDefaultNetwork();
        }
    }
} else {
    $network = Network::getDefaultNetwork();
}
$network_id_sql = $network === null ? "" : "AND network_id = '{$network->getId()}'";
$sql = "SELECT node_id, gw_id, name, last_heartbeat_user_agent, (CURRENT_TIMESTAMP-last_heartbeat_timestamp) AS since_last_heartbeat, last_heartbeat_ip, CASE WHEN ((CURRENT_TIMESTAMP-last_heartbeat_timestamp) < interval '5 minutes') THEN true ELSE false END AS online, creation_date, node_deployment_status, last_heartbeat_wifidog_uptime, last_heartbeat_sys_uptime FROM nodes WHERE node_deployment_status != 'PERMANENTLY_CLOSED' {$network_id_sql} ORDER BY {$sort_by_param_sql}";
$nodes_results = null;
$db->execSql($sql, $nodes_results, false);
//Possible to select empty networks, not an error
if ($nodes_results === null) {
    $nodes_results = array();
}
Esempio n. 5
0
 /** Gets the Network to which the user belongs
  * @return Network object (never returns null)
  */
 public function getNetwork()
 {
     return Network::getObject($this->_row['account_origin']);
 }
Esempio n. 6
0
 /** Gets the Network to which the node belongs
  * @return Network object (never returns null)
  */
 public function getNetwork()
 {
     return Network::getObject($this->_row['network_id']);
 }
Esempio n. 7
0
 */
// Set section of Smarty template
$smarty->assign('sectionMAINCONTENT', true);
// Set network selector
$preSelectedObject = !empty($_REQUEST['network_map']) ? Network::getObject($_REQUEST['network_map']) : Network::getCurrentNetwork();
//$selectNetworkUI = Network::getSelectUI('network_map', array('preSelectedObject' => $preSelectedObject, 'onChange' => "javascript: document.lang_form.submit();"));
$selectNetworkUI = Network::getSelectUI('network_map', array('preSelectedObject' => $preSelectedObject, 'onChange' => "submit.click();"));
$smarty->assign('selectNetworkUI', $selectNetworkUI . (count(Network::getAllNetworks()) > 1 ? '<input class="submit" type="submit" name="submit" value="' . _("Change network") . '">' : ""));
// Compile HTML code
$html_body = $smarty->fetch("templates/sites/hotspots_map.tpl");
/*
 * Footer JavaScripts
 */
// Get GIS data to set
if (!empty($_REQUEST['network_map'])) {
    $network = Network::getObject($_REQUEST['network_map']);
} else {
    $network = Network::getCurrentNetwork();
}
$gis_data = $network->getGisLocation();
// The onLoad code should only be called once all DIV are created.
$script = "<script type=\"text/javascript\">//<![CDATA[\n";
$script .= "    function toggleOverlay(name)\n";
$script .= "    {\n";
$script .= "        o = document.getElementById('map_postalcode_overlay');\n";
$script .= "        if (o != undefined) {\n";
$script .= "            if (o.style.display == 'block') {\n";
$script .= "                o.style.display = 'none';\n";
$script .= "            } else {\n";
$script .= "                o.style.display = 'block';\n";
$script .= "            }\n";
Esempio n. 8
0
 /**
  * Start accounting traffic for the user
  *
  * @param string $conn_id The connection id for the connection to work on
  *
  * @return void
  */
 public function acctStart($conn_id)
 {
     $db = AbstractDb::getObject();
     $conn_id = $db->escapeString($conn_id);
     $db->execSqlUniqueRes("SELECT CURRENT_TIMESTAMP, *, CASE WHEN ((CURRENT_TIMESTAMP - reg_date) > networks.validation_grace_time) THEN true ELSE false END AS validation_grace_time_expired FROM connections JOIN users ON (users.user_id=connections.user_id) JOIN networks ON (users.account_origin = networks.network_id) WHERE connections.conn_id='{$conn_id}'", $info, false);
     $network = Network::getObject($info['network_id']);
     $splash_user_id = $network->getSplashOnlyUser()->getId();
     $auth_response = $info['account_status'];
     // Login the user
     $mac = $db->escapeString($_REQUEST['mac']);
     $ip = $db->escapeString($_REQUEST['ip']);
     $sql = "BEGIN;\n";
     $sql .= "UPDATE connections SET user_mac='{$mac}',user_ip='{$ip}',last_updated=CURRENT_TIMESTAMP WHERE conn_id='{$conn_id}';";
     $sql .= "UPDATE tokens SET token_status='" . TOKEN_INUSE . "' FROM connections WHERE connections.token_id=tokens.token_id AND conn_id='{$conn_id}';";
     $sql .= "COMMIT;\n";
     $db->execSqlUpdate($sql, false);
     if ($splash_user_id != $info['user_id'] && $network->getMultipleLoginAllowed() === false) {
         /*
          * The user isn't the splash_only user and the network config does
          * not allow multiple logins. Logging in with a new token implies
          * that all other active tokens should expire
          */
         $token = $db->escapeString($_REQUEST['token']);
         $sql = "SELECT * FROM connections JOIN tokens USING (token_id) WHERE user_id = '{$info['user_id']}' AND token_status='" . TOKEN_INUSE . "' AND token_id!='{$token}';";
         $conn_rows = array();
         $db->execSql($sql, $conn_rows, false);
         if (isset($conn_rows)) {
             foreach ($conn_rows as $conn_row) {
                 $this->acctStop($conn_row['conn_id']);
             }
         }
     }
 }
Esempio n. 9
0
 /**
  * Process the new object interface.
  *
  * Will return the new object if the user has the credentials and the form was fully filled.
  * @return the node object or null if no new node was created.
  */
 public static function processCreateNewObjectUI()
 {
     // Init values
     $retval = null;
     $name = "new_node_group_name";
     if (!empty($_REQUEST[$name])) {
         $ng_name = $_REQUEST[$name];
     } else {
         $ng_name = null;
     }
     $name = "new_node_group_network_id";
     if (!empty($_REQUEST[$name])) {
         $network = Network::getObject($_REQUEST[$name]);
     } else {
         $network = Network::processSelectUI('new_node_group');
     }
     if ($network) {
         Security::requirePermission(Permission::P('NETWORK_PERM_ADD_NODEGROUP'), $network);
         $retval = self::createNewObject($ng_name, $network);
     }
     return $retval;
 }
Esempio n. 10
0
 /**
  * Get this vhost's default network
  *
  * @return object A Network object, NEVER returns null.
  */
 public function &getDefaultNetwork()
 {
     return Network::getObject($this->__row['default_network']);
 }