* This software is a derived product, based on: * * Simple Machines Forum (SMF) * copyright: 2011 Simple Machines (http://www.simplemachines.org) * license: BSD, See included LICENSE.TXT for terms and conditions. * * @version 1.0 */ // We need the Settings.php info for database stuff. if (file_exists(dirname(__FILE__) . '/Settings.php')) { require_once dirname(__FILE__) . '/Settings.php'; } // Initialize everything initialize_inputs(); // Load the language files. load_language_data(); // Any actions we need to take care of this pass? $result = false; if (isset($_POST['submit'])) { $result = action_set_settings(); } if (isset($_POST['remove_hooks'])) { $result = action_remove_hooks(); } if (isset($_GET['delete'])) { $result = action_deleteScript(); } // Off to the template template_initialize($result); action_show_settings(); template_show_footer();
function get_languages($feature, $spare = '') { // initialize variables $a_languages = load_language_data(); $index = ''; $complete = ''; $b_found = false; // set to default value //prepare user language array $a_user_languages = array(); // debuggers, set to true to trigger action: $b_debugger_1 = false; // print out return array $b_debugger_2 = false; // set fake data values //check to see if language is set if (isset($_SERVER["HTTP_ACCEPT_LANGUAGE"])) { $languages = strtolower($_SERVER["HTTP_ACCEPT_LANGUAGE"]); if ($b_debugger_2 === true) { $languages = ' fr-ch;q=0.3, da, en-us;q=0.8, en;q=0.5, fr;q=0.3'; } // need to remove spaces from strings to avoid error $languages = str_replace(' ', '', $languages); $a_languages_working = explode(',', $languages); //$a_languages_working = explode( ",", $test);// this is for testing purposes only foreach ($a_languages_working as $language_list) { // pull out the language, place languages into array of full and primary // string structure: $a_temp = array(); // slice out the part before ; on first step, the part before - on second, place into array $a_temp[0] = substr($language_list, 0, strcspn($language_list, ';')); //full language $a_temp[1] = substr($language_list, 0, 2); // cut out primary language // then we'll see if that array key exists in the language array, and pack the rest of the values if (array_key_exists($a_temp[0], $a_languages) === true) { // complete language, like english (canada) $a_temp[2] = $a_languages[$a_temp[0]]; // extract working language, like english $a_temp[3] = substr($a_temp[2], 0, strcspn($a_temp[2], ' (')); } else { $a_temp[2] = ''; $a_temp[3] = ''; } //place this array into main $a_user_languages language array $a_user_languages[] = $a_temp; } } else { $a_user_languages[0] = array('', '', '', ''); //return array with empty values. } if ($b_debugger_1 === true) { echo '<pre>'; print_r($a_user_languages); echo '</pre>'; } // return parameters if ($feature == 'data') { return $a_user_languages; } elseif ($feature == 'header') { // get default primary language, the first one in array that is switch ($a_user_languages[0][1]) { case 'en': $location = 'english.php'; $b_found = true; break; case 'sp': $location = 'spanish.php'; $b_found = true; break; default: break; } if ($b_found === true) { header("Location: {$location}"); } else { header("Location: default.php"); } } }