diff --git a/.travis.yml b/.travis.yml index e61e7330..371faa51 100644 --- a/.travis.yml +++ b/.travis.yml @@ -13,5 +13,5 @@ before_script: - composer install script: - - composer check + - composer check-format diff --git a/ADDITIONS/squirrelmail-plugin/common.php b/ADDITIONS/squirrelmail-plugin/common.php index 7e76b3bb..6a80e54e 100644 --- a/ADDITIONS/squirrelmail-plugin/common.php +++ b/ADDITIONS/squirrelmail-plugin/common.php @@ -3,35 +3,30 @@ ini_set('include_path', get_include_path() . ':' . dirname(__FILE__)); @include_once('Zend/Version.php'); -if(!class_exists('Zend_Version', false)) { - die("Zend Framework not found. Please check the INSTALL File."); +if (!class_exists('Zend_Version', false)) { + die("Zend Framework not found. Please check the INSTALL File."); } chdir(".."); -if (!defined('SM_PATH')) -{ - define('SM_PATH','../'); +if (!defined('SM_PATH')) { + define('SM_PATH', '../'); } include_once(dirname(__FILE__) . '/config.php'); include_once(dirname(__FILE__) . '/functions.inc.php'); include_if_exists(dirname(__FILE__) . '/../include/validate.php'); -if (file_exists(dirname(__FILE__) . '/../include/validate.php')) -{ +if (file_exists(dirname(__FILE__) . '/../include/validate.php')) { include_once(dirname(__FILE__) . '/include/validate.php'); -} -else { +} else { include_if_exists(SM_PATH . 'src/validate.php'); } include_once(SM_PATH . 'functions/page_header.php'); include_once(SM_PATH . 'functions/display_messages.php'); include_once(SM_PATH . 'functions/imap.php'); include_if_exists(SM_PATH . 'functions/array.php'); -if (file_exists(SM_PATH . 'src/load_prefs.php')) -{ +if (file_exists(SM_PATH . 'src/load_prefs.php')) { include_once(SM_PATH . 'src/load_prefs.php'); -} -else { +} else { include_if_exists(SM_PATH . 'include/load_prefs.php'); } // overwrite squirrelmail's content type to utf8... @@ -41,4 +36,3 @@ header("Content-Type: text/html; charset=utf8"); //global $VACCONFMESSAGE; bindtextdomain('postfixadmin', dirname(__FILE__) . '/postfixadmin/locale'); textdomain('postfixadmin'); - diff --git a/ADDITIONS/squirrelmail-plugin/functions.inc.php b/ADDITIONS/squirrelmail-plugin/functions.inc.php index cf25ff72..c15ff33b 100644 --- a/ADDITIONS/squirrelmail-plugin/functions.inc.php +++ b/ADDITIONS/squirrelmail-plugin/functions.inc.php @@ -22,7 +22,7 @@ function _display_password_form() { echo _('The PostfixAdmin plugin needs your current mailbox password'); echo "
"; echo _('Password for'); - echo " " . $_SESSION['username'] . " :"; + echo " " . $_SESSION['username'] . " :"; echo ""; echo "
"; do_footer(); @@ -40,37 +40,33 @@ function get_xmlrpc() { $login_object = $client->getProxy('login'); - if(empty($_SESSION['password'])) { - if(empty($_POST['password'])) { + if (empty($_SESSION['password'])) { + if (empty($_POST['password'])) { _display_password_form(); exit(0); - } - else { + } else { try { $success = $login_object->login($_SESSION['username'], $_POST['password']); - } - catch(Exception $e) { + } catch (Exception $e) { //var_dump($client->getHttpClient()->getLastResponse()->getBody()); error_log("Failed to login to xmlrpc instance - " . $e->getMessage()); die('Failed to login to xmlrpc instance'); } - if($success) { + if ($success) { $_SESSION['password'] = $_POST['password']; // reload the current page as a GET request. header("Location: {$_SERVER['REQUEST_URI']}"); exit(0); - } - else { + } else { _display_password_form(); exit(0); } } - } - else { + } else { $success = $login_object->login($_SESSION['username'], $_SESSION['password']); } - if(!$success) { + if (!$success) { unset($_SESSION['password']); die("Invalid details cached... refresh this page and re-enter your mailbox password"); } @@ -78,7 +74,7 @@ function get_xmlrpc() { } function include_if_exists($filename) { - if(file_exists($filename)) { + if (file_exists($filename)) { include_once($filename); } return; @@ -93,10 +89,8 @@ $optmode = 'display'; // function check_email($email) { $return = filter_var($email, FILTER_VALIDATE_EMAIL); - if($return === false) { + if ($return === false) { return false; } return true; } - - diff --git a/ADDITIONS/squirrelmail-plugin/index.php b/ADDITIONS/squirrelmail-plugin/index.php index 01d4d112..da17d499 100644 --- a/ADDITIONS/squirrelmail-plugin/index.php +++ b/ADDITIONS/squirrelmail-plugin/index.php @@ -23,5 +23,3 @@ ****************************************************************************************/ header("Location: ../../index.php"); - -?> \ No newline at end of file diff --git a/ADDITIONS/squirrelmail-plugin/postfixadmin_changepass.php b/ADDITIONS/squirrelmail-plugin/postfixadmin_changepass.php index 4d262f04..25c1f8b4 100644 --- a/ADDITIONS/squirrelmail-plugin/postfixadmin_changepass.php +++ b/ADDITIONS/squirrelmail-plugin/postfixadmin_changepass.php @@ -9,7 +9,7 @@ global $username; do_header(); $USERID_USERNAME = $username; -$tmp = preg_split ('/@/', $USERID_USERNAME); +$tmp = preg_split('/@/', $USERID_USERNAME); $USERID_DOMAIN = $tmp[1]; @@ -20,15 +20,14 @@ $pPassword_password_current_text = ''; $pPassword_password_text = ''; $error = 0; -if ($_SERVER['REQUEST_METHOD'] == "POST") -{ +if ($_SERVER['REQUEST_METHOD'] == "POST") { //$pPassword_password_text = _("pPassword_password_text"); $fPassword_current = $_POST['fPassword_current']; $fPassword = $_POST['fPassword']; $fPassword2 = $_POST['fPassword2']; $username = $USERID_USERNAME; - if(!$user->login($_SESSION['username'], $_POST['fPassword_current'])) { + if (!$user->login($_SESSION['username'], $_POST['fPassword_current'])) { $error = 1; bindtextdomain('postfixadmin', SM_PATH . 'plugins/postfixadmin/locale'); textdomain('postfixadmin'); @@ -37,20 +36,20 @@ if ($_SERVER['REQUEST_METHOD'] == "POST") textdomain('squirrelmail'); } $min_length = 0; - if(isset($CONF['min_password_length'])) { + if (isset($CONF['min_password_length'])) { $min_length = $CONF['min_password_length']; } - if (empty ($fPassword) or ($fPassword != $fPassword2) or ($min_length > 0 && strlen($fPassword) < $min_length)) { + if (empty($fPassword) or ($fPassword != $fPassword2) or ($min_length > 0 && strlen($fPassword) < $min_length)) { $error = 1; bindtextdomain('postfixadmin', SM_PATH . 'plugins/postfixadmin/locale'); textdomain('postfixadmin'); - if(empty($fPassword)) { + if (empty($fPassword)) { $pPassword_password_text .= _("The passwords that you supplied are empty!"); } - if($fPassword != $fPassword2) { + if ($fPassword != $fPassword2) { $pPassword_password_text .= _("The passwords that you supplied don't match!"); } - if($min_length > 0 && strlen($fPassword) < $min_length) { + if ($min_length > 0 && strlen($fPassword) < $min_length) { $pPassword_password_text .= _("The password you supplied is too short!"); } bindtextdomain('squirrelmail', SM_PATH . 'locale'); @@ -67,8 +66,7 @@ if ($_SERVER['REQUEST_METHOD'] == "POST") $stMessage = _("Please sign out and log back again with your new password!"); bindtextdomain('squirrelmail', SM_PATH . 'locale'); textdomain('squirrelmail'); - } - else { + } else { bindtextdomain('postfixadmin', SM_PATH . 'plugins/postfixadmin/locale'); textdomain('postfixadmin'); $tMessage = _("Unable to change your password!"); @@ -125,4 +123,3 @@ echo "
"; bindtextdomain('squirrelmail', SM_PATH . 'locale'); textdomain('squirrelmail'); -?> diff --git a/ADDITIONS/squirrelmail-plugin/postfixadmin_forward.php b/ADDITIONS/squirrelmail-plugin/postfixadmin_forward.php index 74080680..d713017b 100644 --- a/ADDITIONS/squirrelmail-plugin/postfixadmin_forward.php +++ b/ADDITIONS/squirrelmail-plugin/postfixadmin_forward.php @@ -5,7 +5,7 @@ require_once(dirname(__FILE__) . '/common.php'); $USERID_USERNAME = $username; -$tmp = preg_split ('/@/', $USERID_USERNAME); +$tmp = preg_split('/@/', $USERID_USERNAME); $USERID_LOCALPART = $tmp[0]; $USERID_DOMAIN = $tmp[1]; @@ -13,10 +13,9 @@ $xmlrpc = get_xmlrpc(); $alias = $xmlrpc->getProxy('alias'); do_header(); // Normal page request (GET) -if ($_SERVER['REQUEST_METHOD'] == "GET") -{ +if ($_SERVER['REQUEST_METHOD'] == "GET") { $row = $alias->get(); - if($row === false) { + if ($row === false) { bindtextdomain('postfixadmin', SM_PATH . 'plugins/postfixadmin/locale'); textdomain('postfixadmin'); $tMessage = _("Unable to locate alias!"); @@ -26,29 +25,25 @@ if ($_SERVER['REQUEST_METHOD'] == "GET") } } -if ($_SERVER['REQUEST_METHOD'] == "POST") -{ +if ($_SERVER['REQUEST_METHOD'] == "POST") { $pEdit_alias_goto = _("To"); $fGoto = $_POST['fGoto']; // reform string into a list... - $goto = preg_replace ('/\r\n/', ',', $fGoto); - $goto = preg_replace ('/[\s]+/i', '', $goto); - $goto = preg_replace ('/\,*$/', '', $goto); - $array = preg_split ('/,/', $goto); + $goto = preg_replace('/\r\n/', ',', $fGoto); + $goto = preg_replace('/[\s]+/i', '', $goto); + $goto = preg_replace('/\,*$/', '', $goto); + $array = preg_split('/,/', $goto); $error = 0; // check that we have valid addresses in the list - foreach($array as $key => $email_address) - { - if (empty($email_address)) - { - unset($array[$key]); + foreach ($array as $key => $email_address) { + if (empty($email_address)) { + unset($array[$key]); continue; } - if (!check_email($email_address)) - { + if (!check_email($email_address)) { $error = 1; $tGoto = $goto; bindtextdomain('postfixadmin', SM_PATH . 'plugins/postfixadmin/locale'); @@ -61,15 +56,13 @@ if ($_SERVER['REQUEST_METHOD'] == "POST") if ($error != 1) { $flag = 'forward_and_store'; // goto = $USERID_USERNAME; $success = $alias->update($array, $flag); - if(!$success) { + if (!$success) { bindtextdomain('postfixadmin', SM_PATH . 'plugins/postfixadmin/locale'); textdomain('postfixadmin'); $tMessage = _("Unable to modify the alias!"); bindtextdomain('squirrelmail', SM_PATH . 'locale'); textdomain('squirrelmail'); - } - else { - + } else { bindtextdomain('postfixadmin', SM_PATH . 'plugins/postfixadmin/locale'); textdomain('postfixadmin'); echo "

". _("Alias successfully changed!"). "\n

"; @@ -83,7 +76,7 @@ if ($_SERVER['REQUEST_METHOD'] == "POST") bindtextdomain('postfixadmin', SM_PATH . 'plugins/postfixadmin/locale'); textdomain('postfixadmin'); -if(!isset($tMessage)) { +if (!isset($tMessage)) { $tMessage = ''; } echo " @@ -129,8 +122,10 @@ echo "
get(); -foreach($aliases as $address) { - if ($address == "" || $address == NULL) { continue; } +foreach ($aliases as $address) { + if ($address == "" || $address == null) { + continue; + } print "$address\n"; } bindtextdomain('postfixadmin', SM_PATH . 'plugins/postfixadmin/locale'); @@ -162,4 +157,3 @@ echo " "; bindtextdomain('squirrelmail', SM_PATH . 'locale'); textdomain('squirrelmail'); -?> diff --git a/ADDITIONS/squirrelmail-plugin/postfixadmin_vacation.php b/ADDITIONS/squirrelmail-plugin/postfixadmin_vacation.php index 69aa5cd6..91187b8e 100644 --- a/ADDITIONS/squirrelmail-plugin/postfixadmin_vacation.php +++ b/ADDITIONS/squirrelmail-plugin/postfixadmin_vacation.php @@ -15,14 +15,12 @@ EOM; do_header(); $USERID_USERNAME = $username; -$tmp = preg_split ('/@/', $USERID_USERNAME); +$tmp = preg_split('/@/', $USERID_USERNAME); $USERID_DOMAIN = $tmp[1]; -if ($_SERVER['REQUEST_METHOD'] == "GET") -{ +if ($_SERVER['REQUEST_METHOD'] == "GET") { $details = $vacation->getDetails(); - if($vacation->checkVacation()) { - + if ($vacation->checkVacation()) { bindtextdomain('postfixadmin', SM_PATH . 'plugins/postfixadmin/locale'); textdomain('postfixadmin'); $tMessage = _("You already have an auto response configured!"); @@ -54,9 +52,7 @@ if ($_SERVER['REQUEST_METHOD'] == "GET")

"; bindtextdomain('squirrelmail', SM_PATH . 'locale'); textdomain('squirrelmail'); - } - else - { + } else { $tSubject = "Out of Office"; $tSubject = $details['subject']; $VACCONF = $details['body']; @@ -94,64 +90,52 @@ if ($_SERVER['REQUEST_METHOD'] == "GET") } } -if ($_SERVER['REQUEST_METHOD'] == "POST") -{ +if ($_SERVER['REQUEST_METHOD'] == "POST") { $fBack = null; $fAway = null; - foreach(array('fBack', 'fAway', 'fSubject', 'fBody') as $key) { + foreach (array('fBack', 'fAway', 'fSubject', 'fBody') as $key) { $$key = null; - if(isset($_POST[$key])) { + if (isset($_POST[$key])) { $$key = $_POST[$key]; } } - if (!empty($fBack)) - { + if (!empty($fBack)) { $success = $vacation->remove(); - if(!$success) - { + if (!$success) { bindtextdomain('postfixadmin', SM_PATH . 'plugins/postfixadmin/locale'); textdomain('postfixadmin'); $tMessage = _("Unable to update your auto response settings!"); echo "

This may signify an error; please contact support (1)

"; bindtextdomain('squirrelmail', SM_PATH . 'locale'); textdomain('squirrelmail'); - } - else - { + } else { bindtextdomain('postfixadmin', SM_PATH . 'plugins/postfixadmin/locale'); textdomain('postfixadmin'); echo "

". _("Your auto response has been removed!") ."

"; bindtextdomain('squirrelmail', SM_PATH . 'locale'); textdomain('squirrelmail'); - } } - if (!empty ($fAway)) - { + if (!empty($fAway)) { // add record into vacation $success = $vacation->setAway($fSubject, $fBody); - if(!$success) { + if (!$success) { $error = 1; bindtextdomain('postfixadmin', SM_PATH . 'plugins/postfixadmin/locale'); textdomain('postfixadmin'); $tMessage = _("Unable to update your auto response settings!"); bindtextdomain('squirrelmail', SM_PATH . 'locale'); textdomain('squirrelmail'); - } - else - { + } else { bindtextdomain('postfixadmin', SM_PATH . 'plugins/postfixadmin/locale'); textdomain('postfixadmin'); echo "

". _("Your auto response has been set!") ."

"; bindtextdomain('squirrelmail', SM_PATH . 'locale'); textdomain('squirrelmail'); - } } } - -?> diff --git a/ADDITIONS/squirrelmail-plugin/setup.php b/ADDITIONS/squirrelmail-plugin/setup.php index f817411e..41c4b361 100644 --- a/ADDITIONS/squirrelmail-plugin/setup.php +++ b/ADDITIONS/squirrelmail-plugin/setup.php @@ -7,14 +7,13 @@ function squirrelmail_plugin_init_postfixadmin() { global $squirrelmail_plugin_hooks; $squirrelmail_plugin_hooks['optpage_register_block']['postfixadmin'] = 'postfixadmin_optpage_register_block'; - } -function postfixadmin_version(){ +function postfixadmin_version() { return '2.3.0'; } -function postfixadmin_optpage_register_block () { +function postfixadmin_optpage_register_block() { // Gets added to the user's OPTIONS page. global $optpage_blocks; global $AllowVacation; @@ -24,18 +23,18 @@ function postfixadmin_optpage_register_block () { bindtextdomain('postfixadmin', SM_PATH . 'plugins/postfixadmin/locale'); textdomain('postfixadmin'); - $optpage_blocks[] = array ( + $optpage_blocks[] = array( 'name' => _("Forwarding"), 'url' => '../plugins/postfixadmin/postfixadmin_forward.php', 'desc' => _("Here you can create and edit E-Mail forwards."), - 'js' => FALSE + 'js' => false ); bindtextdomain('squirrelmail', SM_PATH . 'locale'); textdomain('squirrelmail'); bindtextdomain('postfixadmin', SM_PATH . 'plugins/postfixadmin/locale'); textdomain('postfixadmin'); - if($AllowVacation) { + if ($AllowVacation) { $optpage_blocks[] = array( 'name' => _("Auto Response"), 'url' => '../plugins/postfixadmin/postfixadmin_vacation.php', @@ -47,7 +46,7 @@ function postfixadmin_optpage_register_block () { } bindtextdomain('postfixadmin', SM_PATH . 'plugins/postfixadmin/locale'); textdomain('postfixadmin'); - if($AllowChangePass) { + if ($AllowChangePass) { $optpage_blocks[] = array( 'name' => _("Change Password"), 'url' => '../plugins/postfixadmin/postfixadmin_changepass.php', @@ -58,4 +57,3 @@ function postfixadmin_optpage_register_block () { textdomain('squirrelmail'); } } -?> diff --git a/ADDITIONS/virtualmaildel.php b/ADDITIONS/virtualmaildel.php index 4282ff50..66954067 100644 --- a/ADDITIONS/virtualmaildel.php +++ b/ADDITIONS/virtualmaildel.php @@ -8,14 +8,14 @@ 0 4 * * * * vmail php -q virtualmaildel.php >/dev/null Changes: - 2017.08.31 updated to use PHP mysqli extension. + 2017.08.31 updated to use PHP mysqli extension. Tadas Ustinavičius ( https://github.com/postfixadmin/postfixadmin/pull/70 ) */ $CONF = []; -// Either, uncomment this (and change to work) +// Either, uncomment this (and change to work) //require_once('/path/to/postfixadmin/config.inc.php'); // OR uncomment this. @@ -31,31 +31,26 @@ $CONF = [ $MAKE_CHANGES = false; // change to true when you're happy this isn't going to trash your server. -if(empty($CONF)) { +if (empty($CONF)) { die("\nPlease configure me\n\n"); } // Where's the homedir accounts stored. (GET THIS RIGHT OTHERWISE IT THINK NONE EXIST AND DELETES ALL) -$homedir = '/home/virtual'; +$homedir = '/home/virtual'; -if ( ! is_dir( $homedir ) ) { - die( "Cannot find home directory for virtual mailboxes in $homedir\n" ); +if (! is_dir($homedir)) { + die("Cannot find home directory for virtual mailboxes in $homedir\n"); } // // Recursive Delete Function // -function deldir($dir) -{ +function deldir($dir) { $current_dir = opendir($dir); - while($entryname = readdir($current_dir)) - { - if(is_dir("$dir/$entryname") and ($entryname != "." and $entryname!="..")) - { + while ($entryname = readdir($current_dir)) { + if (is_dir("$dir/$entryname") and ($entryname != "." and $entryname!="..")) { deldir("${dir}/${entryname}"); - } - elseif($entryname != "." and $entryname!="..") - { + } elseif ($entryname != "." and $entryname!="..") { unlink("${dir}/${entryname}"); } } @@ -70,54 +65,47 @@ $dir = []; // // Get list of directories // -$fr = opendir( $homedir ); +$fr = opendir($homedir); // TODO: Would glob($homedir . '/**/*/new') be somewhat quicker/shorter/less effort? -while ( ($domain = readdir($fr)) !== false) -{ +while (($domain = readdir($fr)) !== false) { // // Check if it's a dir // - if ( $domain != "." and $domain != ".." and filetype($homedir .'/'. $domain) == "dir" ) - { + if ($domain != "." and $domain != ".." and filetype($homedir .'/'. $domain) == "dir") { // // Open the (assumed) DOMAIN directory // - $ff = opendir( $homedir .'/'. $domain ); - while ( ($user = readdir($ff)) !== false) - { + $ff = opendir($homedir .'/'. $domain); + while (($user = readdir($ff)) !== false) { // // Check for directories assuming it's a user account // - if ( $user!="." and $user!=".." and filetype($homedir .'/'. $domain .'/'. $user) == "dir" ) - { + if ($user!="." and $user!=".." and filetype($homedir .'/'. $domain .'/'. $user) == "dir") { // // if the dir 'new' exists inside then it's an account // - if ( file_exists($homedir .'/'. $domain .'/'. $user .'/'. "new") ) - { + if (file_exists($homedir .'/'. $domain .'/'. $user .'/'. "new")) { $dir[$domain][$user] = ""; - } - else - { + } else { // // Alert that the dir doesn't have a 'new' dir, possibly not an account. Leave it. // echo "UNKNOWN : " . $homedir ."/". $domain ."/". $user ."/new NOT FOUND. Possibly not an account. Leaving untouched\n"; } } - } + } } -} +} // // OK, got an array of accounts from the dir, Now connect to the DB and check them // -$conx = mysqli_connect( $CONF['database_host'],$CONF['database_user'],$CONF['database_password'], $CONF['database_name'] ); +$conx = mysqli_connect($CONF['database_host'], $CONF['database_user'], $CONF['database_password'], $CONF['database_name']); // // Is there a problem connecting? // -if ( ! $conx || mysqli_connect_errno() ) { +if (! $conx || mysqli_connect_errno()) { var_dump("DB connection failed." . mysqli_connect_error()); die("Problem connecting to the database. "); } @@ -126,34 +114,33 @@ if ( ! $conx || mysqli_connect_errno() ) { // Select all mailboxes to verify against dirs listed in array // $query = "SELECT * FROM mailbox"; -$result = mysqli_query( $conx, $query ); +$result = mysqli_query($conx, $query); // // Query the mailbox table // -if ( ! $result ) { +if (! $result) { die("Failed to query mailbox table."); } // // Fetch the list of results // -while ( $row = mysqli_fetch_assoc( $result ) ) -{ +while ($row = mysqli_fetch_assoc($result)) { // // Pull apart the maildir field, needed to figure out the directory structure to compare // - $strip = explode("/",$row['maildir']); + $strip = explode("/", $row['maildir']); // // Unset the array if it exists. This stops it being erased later. // - unset( $dir[ $strip[0] ][ $strip[1] ] ); + unset($dir[ $strip[0] ][ $strip[1] ]); } // // If there are results. unset the domain too. // -if ( count($dir[$strip[0]])==0 and mysqli_num_rows($result)>0 ) { - unset( $dir[$strip[0]] ); +if (count($dir[$strip[0]])==0 and mysqli_num_rows($result)>0) { + unset($dir[$strip[0]]); } // @@ -163,29 +150,24 @@ if ( count($dir[$strip[0]])==0 and mysqli_num_rows($result)>0 ) { // // If the array still exists (incase nothing there) // -if ( is_array($dir) ) -{ +if (is_array($dir)) { // // Go through each dir // - foreach ( $dir as $key => $value ) - { + foreach ($dir as $key => $value) { // // Is this a user array? // - if ( is_array( $value) ) - { + if (is_array($value)) { // // Go through and nuke the folders // - foreach ( $value as $user => $value2 ) - { + foreach ($value as $user => $value2) { // Nuke.. need any more explanations? $path = $homedir . '/' . $key . '/' . $user; - if($MAKE_CHANGES) { - deldir( $path ); - } - else { + if ($MAKE_CHANGES) { + deldir($path); + } else { echo " - Would recursively delete : $path \n"; } } diff --git a/common.php b/common.php index 28adf0a8..f092731b 100644 --- a/common.php +++ b/common.php @@ -1,27 +1,27 @@ diff --git a/functions.inc.php b/functions.inc.php index 18cc4b0a..2ec29858 100644 --- a/functions.inc.php +++ b/functions.inc.php @@ -34,7 +34,7 @@ function authentication_get_username() { } if (!isset($_SESSION['sessid'])) { - header ("Location: login.php"); + header("Location: login.php"); exit(0); } $SESSID_USERNAME = $_SESSION['sessid']['username']; @@ -47,8 +47,8 @@ function authentication_get_username() { * @return String admin or user or (boolean) false. */ function authentication_get_usertype() { - if(isset($_SESSION['sessid'])) { - if(isset($_SESSION['sessid']['type'])) { + if (isset($_SESSION['sessid'])) { + if (isset($_SESSION['sessid']['type'])) { return $_SESSION['sessid']['type']; } } @@ -62,9 +62,9 @@ function authentication_get_usertype() { * Note, user < admin < global-admin */ function authentication_has_role($role) { - if(isset($_SESSION['sessid'])) { - if(isset($_SESSION['sessid']['roles'])) { - if(in_array($role, $_SESSION['sessid']['roles'])) { + if (isset($_SESSION['sessid'])) { + if (isset($_SESSION['sessid']['roles'])) { + if (in_array($role, $_SESSION['sessid']['roles'])) { return true; } } @@ -81,8 +81,8 @@ function authentication_has_role($role) { */ function authentication_require_role($role) { // redirect to appropriate page? - if(authentication_has_role($role)) { - return True; + if (authentication_has_role($role)) { + return true; } header("Location: login.php"); @@ -138,10 +138,10 @@ function _flash_string($type, $string) { return; } - if(!isset($_SESSION['flash'])) { + if (!isset($_SESSION['flash'])) { $_SESSION['flash'] = array(); } - if(!isset($_SESSION['flash'][$type])) { + if (!isset($_SESSION['flash'][$type])) { $_SESSION['flash'][$type] = array(); } $_SESSION['flash'][$type][] = $string; @@ -153,25 +153,25 @@ function _flash_string($type, $string) { // Call: check_language // Parameter: $use_post - set to 0 if $_POST should NOT be read // -function check_language ($use_post = 1) { +function check_language($use_post = 1) { global $supported_languages; # from languages/languages.php $lang = Config::read('default_language'); - if(isset($_SERVER['HTTP_ACCEPT_LANGUAGE'])) { - $lang_array = preg_split ('/(\s*,\s*)/', $_SERVER['HTTP_ACCEPT_LANGUAGE']); + if (isset($_SERVER['HTTP_ACCEPT_LANGUAGE'])) { + $lang_array = preg_split('/(\s*,\s*)/', $_SERVER['HTTP_ACCEPT_LANGUAGE']); if (safecookie('lang')) { array_unshift($lang_array, safecookie('lang')); # prefer language from cookie } - if ( $use_post && safepost('lang')) { + if ($use_post && safepost('lang')) { array_unshift($lang_array, safepost('lang')); # but prefer $_POST['lang'] even more } - for($i = 0; $i < count($lang_array); $i++) { + for ($i = 0; $i < count($lang_array); $i++) { $lang_next = $lang_array[$i]; $lang_next = strtolower(trim($lang_next)); $lang_next = preg_replace('/;.*$/', '', $lang_next); # remove things like ";q=0.8" - if(array_key_exists($lang_next, $supported_languages)) { + if (array_key_exists($lang_next, $supported_languages)) { $lang = $lang_next; break; } @@ -192,7 +192,7 @@ function language_selector() { $selector = '