Changeset 858 in ExiteCMS for trunk/includes/core_functions.php


Ignore:
Timestamp:
09/29/07 21:51:40 (5 years ago)
Author:
hverton
Message:

Added language selection and language detection
When adding a new member as sponsor, the member will be added to the 'Sponsors' user_group
Added missing index.php to the new cache directories

Location:
trunk
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk

    • Property svn:ignore
      •  

        old new  
        11Copy of config.php 
         2config.backup.php 
        23config.php 
  • trunk/includes/core_functions.php

    r845 r858  
    107107define ("BASEDIR", strstr(substr(strstr($settings['siteurl'], '://'),3), '/')); 
    108108 
     109// locale detection - step 1 - check if there's a locale cookie set 
     110if (isset($_COOKIE['locale'])) { 
     111    // check if we (still) support this language. If so, update the locale setting 
     112    $result = dbquery("SELECT * FROM ".$db_prefix."locale WHERE locale_code = '".$_COOKIE['locale']."' AND locale_active = '1'"); 
     113    if ($data = dbarray($result)) { 
     114        $settings['locale'] = $data['locale_name']; 
     115        define("LOCALESET", $settings['locale']."/"); 
     116    } 
     117} 
     118 
     119// locale detection - step 2 - check the browsers accepted languages 
     120if (!defined('LOCALESET') && isset($_SERVER['HTTP_ACCEPT_LANGUAGE']) && !empty($_SERVER['HTTP_ACCEPT_LANGUAGE'])) { 
     121    // check which languages are supported by the users browser 
     122    $temp = explode(",", $_SERVER['HTTP_ACCEPT_LANGUAGE']); 
     123    foreach($temp as $lng) { 
     124        $thislng = explode(";", $lng); 
     125        // check if we support this language 
     126        $result = dbquery("SELECT * FROM ".$db_prefix."locale WHERE locale_code = '".$thislng[0]."' AND locale_active = '1'"); 
     127        if ($data = dbarray($result)) { 
     128            // if so, set the locale 
     129            $settings['locale'] = $data['locale_name']; 
     130            define("LOCALESET", $settings['locale']."/"); 
     131            break; 
     132        } 
     133    } 
     134    // if not found, loop again on languages only 
     135    if (!defined('LOCALESET')) { 
     136        foreach($temp as $lng) { 
     137            $thislng = explode(";", $lng); 
     138            $thislng = explode("-", $thislng); 
     139            // check if we support this language 
     140            $result = dbquery("SELECT * FROM ".$db_prefix."locale WHERE locale_code = '".$thislng[0]."' AND locale_active = '1'"); 
     141            if ($data = dbarray($result)) { 
     142                // if so, set the locale 
     143                $settings['locale'] = $data['locale_name']; 
     144                define("LOCALESET", $settings['locale']."/"); 
     145                break; 
     146            } 
     147        } 
     148    } 
     149} 
     150 
     151// locale detection - step 3 - use the website's default 
     152if (!defined('LOCALESET')) { 
     153    define("LOCALESET", $settings['locale']."/"); 
     154} 
     155 
    109156// URL path definitions relative to BASEDIR 
    110 define("LOCALESET", $settings['locale']."/"); 
    111157define("ADMIN", BASEDIR."administration/"); 
    112158define("IMAGES", BASEDIR."images/"); 
     
    144190 
    145191// Browser window dimensions (assume 1024x768 if no cookies found) 
    146 define("BROWSER_WIDTH", isset($_COOKIE['width'])?$_COOKIE['width']:1024); 
    147 define("BROWSER_HEIGHT", isset($_COOKIE['height'])?$_COOKIE['height']:768); 
     192define("BROWSER_WIDTH", isset($_COOKIE['width']) ? $_COOKIE['width'] : 1024); 
     193define("BROWSER_HEIGHT", isset($_COOKIE['height']) ? $_COOKIE['height'] : 768); 
    148194 
    149195// Initialise the $locale array 
     
    172218 
    173219// image types we support 
    174 $imagetypes = array( 
    175     ".bmp", 
    176     ".gif", 
    177     ".iff", 
    178     ".jpg", 
    179     ".jpeg", 
    180     ".png", 
    181     ".psd", 
    182     ".tiff", 
    183     ".wbmp" 
    184 ); 
     220$imagetypes = array(".bmp",".gif",".iff",".jpg",".jpeg",".png",".psd",".tiff",".wbmp"); 
    185221 
    186222// image types we can generate a thumbnail from 
    187 $thumbtypes = array( 
    188     ".gif", 
    189     ".jpg", 
    190     ".jpeg", 
    191     ".png", 
    192 ); 
     223$thumbtypes = array(".gif",".jpg",".jpeg",".png",); 
    193224 
    194225// debug function, handy to print a standard debug text 
     
    761792        } 
    762793        if ($data['user_status'] == 0) {     
    763             if (isset($_POST['remember_me'])) { 
    764                 setcookie("remember_me", "yes", time() + 31536000, "/", "", "0"); 
    765                 $cookie_exp = time() + 3600*24*30; 
    766             } else { 
    767                 setcookie("remember_me", "yes", time() - 7200, "/", "", "0"); 
    768                 $cookie_exp = time() + 60*30; 
    769             } 
     794            $cookie_exp = time() + 60*30; 
    770795            header("P3P: CP='NOI ADM DEV PSAi COM NAV OUR OTRo STP IND DEM'"); 
    771796            setcookie("userinfo", $cookie_value, $cookie_exp, "/", "", "0"); 
Note: See TracChangeset for help on using the changeset viewer.