Location: PHPKode > projects > phpMakeUpdate > phpMakeUpdate/includes/init.php
<?php
/**
 * phpMakeUpdate - web tool for make the updates from Subversion repository
 * Copyright (C) 2006  Arthur Harder
 *
 * web: http://www.easyWebSolutions.biz or http://www.easyWebSolutions.de
 *
 * 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, write to the Free Software
 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
 *
 */
define('ID_CMDLINE',1);
define('ID_STDOUT',2);
define('ID_ERROUT',3);
define('ID_CMD_RC',4);

define('ID_AUTHOR',1);
define('ID_DATE',2);
define('ID_MESSAGE_SIZE',3);
define('ID_MESSAGE',4);

define('SVN','/usr/local/bin/svn');
define('SVNLOOK','/usr/local/bin/svnlook');
define('TAR','/bin/tar');

define('DEPT_TREE',2);

define('REP_LIST','config/replist.txt');

define('REC_PER_PAGE',20);
define('FILES_LIST_SIZE',40);

define('BGCOLOR_HELL','#fff');
define('BGCOLOR_DARK','#eaf0f0');

require('includes/makeupdate.class.php');
require('includes/update.common.php');
require('template_lite/class.template.php');

if (empty($_SESSION['lang']))
{
    $languages = orderedLanguages();
    $setlang = false;

    foreach ($languages as $lang)
    {
        if (is_file('lang/'.$lang.'.php'))
        {
            $setlang = true;
            require_once('lang/'.$lang.'.php');
            break;
        }
    }

    if (!$setlang)
    {
        $_SESSION['lang'] = 'en';
        require_once('lang/en.php');
    }

    $_SESSION['lang'] = $lang;
}
else
{
    require_once('lang/'.$_SESSION['lang'].'.php');
}

switch ($_SESSION['lang'])
{
    case 'ru':
        setlocale (LC_ALL, 'ru_RU', 'hide@address.com', 'ru', 'russian');
    break;

    case 'de':
        setlocale (LC_ALL, 'hide@address.com', 'de_DE', 'de', 'ge');
    break;

    default:
        setlocale (LC_ALL, 'en_US.utf8', 'en_GB.utf8','en_US', 'en', 'gb');
}

session_start();
ob_start();

function clearvar($string)
{
    $string = strip_tags($string);
    $string = htmlentities($string,ENT_QUOTES);
    return $string;
}

function orderedLanguages()
{
   $http_accept_language = isset($_SERVER['HTTP_ACCEPT_LANGUAGE']) ? $_SERVER['HTTP_ACCEPT_LANGUAGE'] : 'de;q=1';
   $languages = split(",", $http_accept_language );
   $lang_q = Array();
   foreach( $languages as $aLang ) {
       $lang_array = split(";q=", trim( $aLang ) );
       $lang = trim( $lang_array[0] );
       if( !isset( $lang_array[1] ) )
           $q = 1;
       else
           $q = trim($lang_array[1]);
       $lang_q["$lang"] = (float)$q;
   }
   arsort($lang_q);
   //extra code for making the languages key indexed
   $i = 0;
   $lang_index = Array();
   foreach($lang_q as $lang => $q) {
   //    $lang_q[$i] = $lang; //add to the same array the index key/language
       $lang_index[$i] = $lang; //add to a new array the index key/language
       $i++;
   }

   //return $lang_index; // uncomment for returning array with keys={0..n-1}, values={most..least preferred}
   return $lang_index;
}
?>
Return current item: phpMakeUpdate