Show
Ignore:
Timestamp:
10/02/08 09:44:42 (2 months ago)
Author:
networkfusion
Message:

* Support for redirecting to the users original URL instead of portal

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/wifidog-auth/CHANGELOG

    r1366 r1384  
    11# $Id$ 
     22008-10-02 Robin Jones 
     3        * Support for redirecting to the users original URL instead of portal 
     4 
    252008-09-23 Robin Jones 
    36        * Oops, forgot to include new style sheet into the previous commit. 
    4  
    5 2008-09-23 Robin Jones 
    67        * Made Login template easier to edit using CSS and added example to NetworkFusion theme pack, This closes #343 . 
    78 
  • trunk/wifidog-auth/wifidog/classes/Network.php

    r1362 r1384  
    14051405    } 
    14061406 
     1407      /**  
     1408      * Are nodes allowed to redirect users to the original requested web page instead of  
     1409      * the portal?  
     1410      *  
     1411      * @return bool True or false  
     1412      *  
     1413      * @access public  
     1414      */  
     1415     public function getPortalOriginalUrlAllowed()  
     1416     {  
     1417         return (($this->_row['allow_original_url_redirect'] == 't') ? true : false);  
     1418     }  
     1419   
     1420     /**  
     1421      * Set if nodes are allowed to redirect users to the original requested web page  
     1422      * instead of the portal?  
     1423      *  
     1424      * @param bool $value The new value, true or false  
     1425      *  
     1426      * @return bool True on success, false on failure  
     1427      *  
     1428      * @access public  
     1429      */  
     1430     public function setPortalOriginalUrlAllowed($value)  
     1431     {  
     1432         // Init values  
     1433         $retval = true;  
     1434   
     1435         if ($value != $this->getPortalOriginalUrlAllowed()) {  
     1436             $db = AbstractDb::getObject();  
     1437             $value ? $value = 'TRUE' : $value = 'FALSE';  
     1438             $retval = $db->execSqlUpdate("UPDATE networks SET allow_original_url_redirect = {$value} WHERE network_id = '{$this->getId()}'", false);  
     1439             $this->refresh();  
     1440         }  
     1441   
     1442         return $retval;  
     1443     }  
     1444 
     1445 
    14071446    /** The length of the window during which the user must not have exceeded the limits below. 
    14081447     * 
     
    16651704        $data = InterfaceElements::generateInputCheckbox("network_" . $this->getId() . "_allow_custom_portal_redirect", "", _("Yes"), $this->getCustomPortalRedirectAllowed(), "network_allow_custom_portal_redirect_radio"); 
    16661705        $html_network_node_properties[] = InterfaceElements::generateAdminSectionContainer("network_allow_custom_portal_redirect", $title, $data, $help); 
     1706 
     1707        //  allow_original_URL_redirect 
     1708        $title = _("Original URL redirection"); 
     1709        $help = _("Are nodes allowed to redirect users to the web page they originally requested instead of the portal?"); 
     1710        $data = InterfaceElements::generateInputCheckbox("network_" . $this->getId() . "_allow_original_URL_redirect", "", _("Yes"), $this->getPortalOriginalUrlAllowed(), "network_allow_original_URL_redirect_radio"); 
     1711        $html_network_node_properties[] = InterfaceElements::generateAdminSectionContainer("network_allow_original_URL_redirect", $title, $data, $help); 
    16671712 
    16681713        // Build section 
     
    18751920        $this->setCustomPortalRedirectAllowed(empty ($_REQUEST[$name]) ? false : true); 
    18761921 
     1922        //  'allow_original_URL_redirect 
     1923        $name = "network_".$this->getId()."_allow_original_URL_redirect"; 
     1924        $this->setPortalOriginalUrlAllowed(empty ($_REQUEST[$name]) ? false : true); 
     1925 
    18771926        /* 
    18781927         * Dynamic abuse control 
  • trunk/wifidog-auth/wifidog/classes/Node.php

    r1351 r1384  
    10201020    } 
    10211021 
     1022   /** redirect users to the original requested web page instead of portal  
     1023      Must be enabled in the Network configuration to have any effect  
     1024      @return a string */  
     1025     function getPortalOriginalUrlAllowed()  
     1026     {  
     1027         return (($this->_row['allow_original_url_redirect'] == 't') ? true : false);  
     1028     }  
     1029   
     1030     /** redirect users to the original requested web page instead of portal  
     1031      Must be enabled in the Network configuration to have any effect  
     1032      @return true on success, false on failure */  
     1033     function setPortalOriginalUrlAllowed($value)  
     1034     {  
     1035         $retval = true;  
     1036         if ($value != $this->getPortalOriginalUrlAllowed())  
     1037         {  
     1038             $db = AbstractDb::getObject();  
     1039             $value ? $value = 'TRUE' : $value = 'FALSE'; 
     1040             $retval = $db->execSqlUpdate("UPDATE nodes SET allow_original_url_redirect = '{$value}' WHERE node_id = '{$this->getId()}'", false);  
     1041             $this->refresh();  
     1042         }  
     1043         return $retval;  
     1044     }  
     1045 
     1046 
     1047 
    10221048    /** 
    10231049     * Retrieves the admin interface of this object 
     
    12401266            $_html_node_config[] = InterfaceElements::generateAdminSectionContainer("node_custom_portal_redirect_url", $_title, $_data); 
    12411267        } 
     1268 
     1269        //  allow_original_URL_redirect 
     1270        $title = _("Original URL redirection"); 
     1271        $help = _("Are nodes allowed to redirect users to the web page they originally requested instead of the portal? this will overide the custom portal URL"); 
     1272        $data = InterfaceElements::generateInputCheckbox("node_" . $node_id . "_allow_original_URL_redirect", "", _("Yes"), $this->getPortalOriginalUrlAllowed(), "node_allow_original_URL_redirect_radio"); 
     1273        $_html_node_config[] = InterfaceElements::generateAdminSectionContainer("node_allow_original_URL_redirect", $title, $data, $help); 
    12421274 
    12431275        // Build section 
     
    14251457        } 
    14261458 
     1459        // allow_original_URL_redirect 
     1460        if ($network->getPortalOriginalUrlAllowed()) 
     1461        { 
     1462            $name = "node_" . $node_id . "_allow_original_URL_redirect"; 
     1463            $this->setPortalOriginalUrlAllowed(empty ($_REQUEST[$name]) ? false : true); 
     1464        } 
     1465 
    14271466        // End Node configuration section 
    14281467 
  • trunk/wifidog-auth/wifidog/include/schema_validate.php

    r1352 r1384  
    4848 * Define current database schema version 
    4949 */ 
    50 define('REQUIRED_SCHEMA_VERSION', 62); 
     50define('REQUIRED_SCHEMA_VERSION', 63); 
    5151/** Used to test a new shecma version before modyfying the database */ 
    5252define('SCHEMA_UPDATE_TEST_MODE', false); 
     
    14161416         
    14171417    } 
     1418    $new_schema_version = 63; 
     1419    if ($schema_version < $new_schema_version && $new_schema_version <= $targetSchema) { 
     1420        printUpdateVersion($new_schema_version); 
     1421     $sql .= "\n\nUPDATE schema_info SET value='$new_schema_version' WHERE tag='schema_version';\n"; 
     1422 
     1423        $sql .= "ALTER TABLE networks ADD column allow_original_url_redirect bool; \n"; 
     1424        $sql .= "ALTER TABLE networks ALTER COLUMN allow_original_url_redirect SET DEFAULT FALSE;\n"; 
     1425 
     1426        $sql .= "ALTER TABLE nodes ADD column allow_original_URL_redirect bool; \n"; 
     1427        $sql .= "ALTER TABLE nodes ALTER COLUMN allow_original_URL_redirect SET DEFAULT FALSE;\n"; 
     1428    } 
    14181429    /* 
    14191430     $new_schema_version = ; 
  • trunk/wifidog-auth/wifidog/portal/index.php

    r1295 r1384  
    107107    } 
    108108} 
     109 
     110/* 
     111 * If this node allows redirection to original URL, and the network config allows it, 
     112 * redirect to original URL 
     113 */ 
     114$session_original_url = $session->get(SESS_ORIGINAL_URL_VAR); 
     115 
     116if ($node->getPortalOriginalUrlAllowed() && $network->getPortalOriginalUrlAllowed() && !empty ($session_original_url)) 
     117    /** 
     118     * If the database doesn't get cleaned up by a cron job, we'll do now (normally this is done in ManiUI, but for custom URLs, MainUI may never be instanciated 
     119     */ 
     120    if (CONF_USE_CRON_FOR_DB_CLEANUP == false) { 
     121        garbage_collect(); 
     122    } 
     123    header("Location: {$session_original_url}"); 
     124    exit; 
     125} 
     126 
    109127 
    110128/*