fmsystem-commits
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Fmsystem-commits] [15829] configurable cookie domains for frontends


From: sigurdne
Subject: [Fmsystem-commits] [15829] configurable cookie domains for frontends
Date: Sun, 16 Oct 2016 10:21:08 +0000 (UTC)

Revision: 15829
          http://svn.sv.gnu.org/viewvc/?view=rev&root=fmsystem&revision=15829
Author:   sigurdne
Date:     2016-10-16 10:21:07 +0000 (Sun, 16 Oct 2016)
Log Message:
-----------
configurable cookie domains for frontends

Modified Paths:
--------------
    trunk/activitycalendarfrontend/setup/setup.inc.php
    trunk/activitycalendarfrontend/templates/base/config.tpl
    trunk/bookingfrontend/setup/setup.inc.php
    trunk/bookingfrontend/templates/base/config.tpl
    trunk/mobilefrontend/inc/class.hook_helper.inc.php
    trunk/mobilefrontend/setup/setup.inc.php
    trunk/mobilefrontend/templates/base/config.tpl
    trunk/phpgwapi/inc/class.sessions.inc.php

Added Paths:
-----------
    trunk/activitycalendarfrontend/inc/class.hook_helper.inc.php
    trunk/bookingfrontend/inc/class.hook_helper.inc.php

Added: trunk/activitycalendarfrontend/inc/class.hook_helper.inc.php
===================================================================
--- trunk/activitycalendarfrontend/inc/class.hook_helper.inc.php                
                (rev 0)
+++ trunk/activitycalendarfrontend/inc/class.hook_helper.inc.php        
2016-10-16 10:21:07 UTC (rev 15829)
@@ -0,0 +1,52 @@
+<?php
+       /**
+        * Activitycalendarfrontend - Hook helper
+        *
+        * @author Sigurd Nes <address@hidden>
+        * @copyright Copyright (C) 2013 Free Software Foundation, Inc. 
http://www.fsf.org/
+        * @license http://www.gnu.org/licenses/gpl.html GNU General Public 
License
+        * @package Property
+        * @version $Id: class.hook_helper.inc.php 14728 2016-02-11 22:28:46Z 
sigurdne $
+        */
+       /*
+         This program is free software: you can redistribute it and/or modify
+         it under the terms of the GNU General Public License as published by
+         the Free Software Foundation, either version 2 of the License, or
+         (at your option) any later version.
+
+         This program is distributed in the hope that it will be useful,
+         but WITHOUT ANY WARRANTY; without even the implied warranty of
+         MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+         GNU General Public License for more details.
+
+         You should have received a copy of the GNU General Public License
+         along with this program.  If not, see <http://www.gnu.org/licenses/>.
+        */
+
+       /**
+        * Hook helper
+        *
+        * @package Activitycalendar
+        */
+       class activitycalendarfrontend_hook_helper
+       {
+
+               public function set_cookie_domain()
+               {
+                       $script_path = 
dirname(phpgw::get_var('SCRIPT_FILENAME', 'string', 'SERVER'));
+                       
+                       if(preg_match('/activitycalendarfrontend/', 
$script_path))
+                       {
+                               //get from local config
+                               $config = CreateObject('phpgwapi.config', 
'activitycalendarfrontend');
+                               $config->read();
+
+                               
$GLOBALS['phpgw_info']['server']['cookie_domain'] = 
!empty($GLOBALS['phpgw_info']['server']['cookie_domain']) ? 
$GLOBALS['phpgw_info']['server']['cookie_domain'] : '';
+
+                               if 
(!empty($config->config_data['cookie_domain']))
+                               {
+                                       
$GLOBALS['phpgw_info']['server']['cookie_domain'] = 
$config->config_data['cookie_domain'];
+                               }
+                       }
+               }
+       }
\ No newline at end of file

Modified: trunk/activitycalendarfrontend/setup/setup.inc.php
===================================================================
--- trunk/activitycalendarfrontend/setup/setup.inc.php  2016-10-14 17:42:22 UTC 
(rev 15828)
+++ trunk/activitycalendarfrontend/setup/setup.inc.php  2016-10-16 10:21:07 UTC 
(rev 15829)
@@ -39,5 +39,6 @@
        $setup_info['activitycalendarfrontend']['hooks'] = array
                (
                'menu' => 'activitycalendarfrontend.menu.get_menu',
+               'set_cookie_domain' => 
'activitycalendarfrontend.hook_helper.set_cookie_domain',
                'config'
        );

Modified: trunk/activitycalendarfrontend/templates/base/config.tpl
===================================================================
--- trunk/activitycalendarfrontend/templates/base/config.tpl    2016-10-14 
17:42:22 UTC (rev 15828)
+++ trunk/activitycalendarfrontend/templates/base/config.tpl    2016-10-16 
10:21:07 UTC (rev 15829)
@@ -14,22 +14,26 @@
                <tr bgcolor="{row_off}">
                        <td colspan="2"><b>{Registration_settings}</b></td>
                </tr>
-               <tr bgcolor="{row_on}">
+               <tr class="row_on">
+                       
<td>{lang_cookie_domain_for_sessions_-_if_Same_as_framework_leave_empty}</td>
+                       <td><input name="newsettings[cookie_domain]" 
value="{value_cookie_domain}"></td>
+               </tr>
+               <tr bgcolor="{row_off}">
                        <td>{lang_ajaxURL}:</td>
                        <td><input name="newsettings[AJAXURL]" 
value="{value_AJAXURL}"></td>
                </tr>
-               <tr bgcolor="{row_off}">
+               <tr bgcolor="{row_on}">
                        <td colspan="2">&nbsp;</td>
                </tr>
-               <tr bgcolor="{row_on}">
+               <tr bgcolor="{row_off}">
                        <td>{lang_Anonymous_user}:</td>
                        <td><input name="newsettings[anonymous_user]" 
value="{value_anonymous_user}"></td>
                </tr>
-               <tr bgcolor="{row_off}">
+               <tr bgcolor="{row_on}">
                        <td>{lang_Anonymous_password}:</td>
                        <td><input type="password" 
name="newsettings[anonymous_passwd]" value="{value_anonymous_passwd}"></td>
                </tr>
-               <tr bgcolor="{row_on}">
+               <tr bgcolor="{row_off}">
                        <td>{lang_allow_test_for_sql_injection}:</td>
                        <td>
                                <select name="newsettings[allow_test]">

Added: trunk/bookingfrontend/inc/class.hook_helper.inc.php
===================================================================
--- trunk/bookingfrontend/inc/class.hook_helper.inc.php                         
(rev 0)
+++ trunk/bookingfrontend/inc/class.hook_helper.inc.php 2016-10-16 10:21:07 UTC 
(rev 15829)
@@ -0,0 +1,53 @@
+<?php
+       /**
+        * Bookingfrontend - Hook helper
+        *
+        * @author Sigurd Nes <address@hidden>
+        * @copyright Copyright (C) 2013 Free Software Foundation, Inc. 
http://www.fsf.org/
+        * @license http://www.gnu.org/licenses/gpl.html GNU General Public 
License
+        * @package Property
+        * @version $Id: class.hook_helper.inc.php 14728 2016-02-11 22:28:46Z 
sigurdne $
+        */
+       /*
+         This program is free software: you can redistribute it and/or modify
+         it under the terms of the GNU General Public License as published by
+         the Free Software Foundation, either version 2 of the License, or
+         (at your option) any later version.
+
+         This program is distributed in the hope that it will be useful,
+         but WITHOUT ANY WARRANTY; without even the implied warranty of
+         MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+         GNU General Public License for more details.
+
+         You should have received a copy of the GNU General Public License
+         along with this program.  If not, see <http://www.gnu.org/licenses/>.
+        */
+
+       /**
+        * Hook helper
+        *
+        * @package bookingfrontend
+        */
+       class bookingfrontend_hook_helper
+       {
+
+
+               public function set_cookie_domain()
+               {
+                       $script_path = 
dirname(phpgw::get_var('SCRIPT_FILENAME', 'string', 'SERVER'));
+                       
+                       if(preg_match('/bookingfrontend/', $script_path))
+                       {
+                               //get from local config
+                               $config = CreateObject('phpgwapi.config', 
'bookingfrontend');
+                               $config->read();
+
+                               
$GLOBALS['phpgw_info']['server']['cookie_domain'] = 
!empty($GLOBALS['phpgw_info']['server']['cookie_domain']) ? 
$GLOBALS['phpgw_info']['server']['cookie_domain'] : '';
+
+                               if 
(!empty($config->config_data['cookie_domain']))
+                               {
+                                       
$GLOBALS['phpgw_info']['server']['cookie_domain'] = 
$config->config_data['cookie_domain'];
+                               }
+                       }
+               }
+       }
\ No newline at end of file

Modified: trunk/bookingfrontend/setup/setup.inc.php
===================================================================
--- trunk/bookingfrontend/setup/setup.inc.php   2016-10-14 17:42:22 UTC (rev 
15828)
+++ trunk/bookingfrontend/setup/setup.inc.php   2016-10-16 10:21:07 UTC (rev 
15829)
@@ -34,5 +34,6 @@
        $setup_info['bookingfrontend']['hooks'] = array
                (
                'menu' => 'bookingfrontend.menu.get_menu',
+               'set_cookie_domain' => 
'bookingfrontend.hook_helper.set_cookie_domain',
                'config'
        );

Modified: trunk/bookingfrontend/templates/base/config.tpl
===================================================================
--- trunk/bookingfrontend/templates/base/config.tpl     2016-10-14 17:42:22 UTC 
(rev 15828)
+++ trunk/bookingfrontend/templates/base/config.tpl     2016-10-16 10:21:07 UTC 
(rev 15829)
@@ -20,6 +20,10 @@
                                </select>
                        </td>
                </tr>
+               <tr class="row_off">
+                       
<td>{lang_cookie_domain_for_sessions_-_if_Same_as_framework_leave_empty}</td>
+                       <td><input name="newsettings[cookie_domain]" 
value="{value_cookie_domain}"></td>
+               </tr>
                <tr class="row_on">
                        <td>{lang_Anonymous_user}:</td>
                        <td><input name="newsettings[anonymous_user]" 
value="{value_anonymous_user}"></td>

Modified: trunk/mobilefrontend/inc/class.hook_helper.inc.php
===================================================================
--- trunk/mobilefrontend/inc/class.hook_helper.inc.php  2016-10-14 17:42:22 UTC 
(rev 15828)
+++ trunk/mobilefrontend/inc/class.hook_helper.inc.php  2016-10-16 10:21:07 UTC 
(rev 15829)
@@ -5,7 +5,7 @@
         * @author Sigurd Nes <address@hidden>
         * @copyright Copyright (C) 2013 Free Software Foundation, Inc. 
http://www.fsf.org/
         * @license http://www.gnu.org/licenses/gpl.html GNU General Public 
License
-        * @package controller
+        * @package Property
         * @version $Id$
         */
        /*
@@ -43,11 +43,28 @@
                        $config = CreateObject('phpgwapi.config', 
'mobilefrontend');
                        $config->read();
 
-                       if (isset($config->config_data['auth_type']) && 
$config->config_data['auth_type'])
+                       if (!empty($config->config_data['auth_type']))
                        {
                                $GLOBALS['phpgw_info']['server']['auth_type'] = 
$config->config_data['auth_type'];
                        }
+               }
 
-//_debug_array($GLOBALS['phpgw_info']['server']);die();
+               public function set_cookie_domain()
+               {
+                       $script_path = 
dirname(phpgw::get_var('SCRIPT_FILENAME', 'string', 'SERVER'));
+                       
+                       if(preg_match('/mobilefrontend/', $script_path))
+                       {
+                               //get from local config
+                               $config = CreateObject('phpgwapi.config', 
'mobilefrontend');
+                               $config->read();
+
+                               
$GLOBALS['phpgw_info']['server']['cookie_domain'] = 
!empty($GLOBALS['phpgw_info']['server']['cookie_domain']) ? 
$GLOBALS['phpgw_info']['server']['cookie_domain'] : '';
+
+                               if 
(!empty($config->config_data['cookie_domain']))
+                               {
+                                       
$GLOBALS['phpgw_info']['server']['cookie_domain'] = 
$config->config_data['cookie_domain'];
+                               }
+                       }
                }
        }
\ No newline at end of file

Modified: trunk/mobilefrontend/setup/setup.inc.php
===================================================================
--- trunk/mobilefrontend/setup/setup.inc.php    2016-10-14 17:42:22 UTC (rev 
15828)
+++ trunk/mobilefrontend/setup/setup.inc.php    2016-10-16 10:21:07 UTC (rev 
15829)
@@ -50,6 +50,7 @@
                (
                'config',
                'home',
+               'set_cookie_domain' => 
'mobilefrontend.hook_helper.set_cookie_domain',
                'set_auth_type' => 'mobilefrontend.hook_helper.set_auth_type',
                'menu' => 'mobilefrontend.menu.get_menu'
        );

Modified: trunk/mobilefrontend/templates/base/config.tpl
===================================================================
--- trunk/mobilefrontend/templates/base/config.tpl      2016-10-14 17:42:22 UTC 
(rev 15828)
+++ trunk/mobilefrontend/templates/base/config.tpl      2016-10-16 10:21:07 UTC 
(rev 15829)
@@ -22,6 +22,10 @@
                                </select>
                        </td>
                </tr>
+               <tr class="row_off">
+                       
<td>{lang_cookie_domain_for_sessions_-_if_Same_as_framework_leave_empty}</td>
+                       <td><input name="newsettings[cookie_domain]" 
value="{value_cookie_domain}"></td>
+               </tr>
                <!-- END body -->
                <!-- BEGIN footer -->
                <tr class="th">

Modified: trunk/phpgwapi/inc/class.sessions.inc.php
===================================================================
--- trunk/phpgwapi/inc/class.sessions.inc.php   2016-10-14 17:42:22 UTC (rev 
15828)
+++ trunk/phpgwapi/inc/class.sessions.inc.php   2016-10-16 10:21:07 UTC (rev 
15829)
@@ -153,13 +153,14 @@
                        {
                                $use_cookies = true;
                                $this->_sessionid       = 
phpgw::get_var(session_name(), 'string', 'COOKIE');
+                               
$GLOBALS['phpgw']->hooks->process('set_cookie_domain', array('mobilefrontend', 
'bookingfrontend', 'activitycalendarfrontend'));
+                               $this->_phpgw_set_cookie_params();
                        }
                        else
                        {
                                $this->_sessionid       = 
phpgw::get_var(session_name()); // GET or POST
                        }
 
-                       $this->_phpgw_set_cookie_params();
 
                        //respect the config option for cookies
                        ini_set('session.use_cookies', $use_cookies);




reply via email to

[Prev in Thread] Current Thread [Next in Thread]