Commit be957d07 authored by Côme Chilliet's avatar Côme Chilliet
Browse files

🚑 fix(code) Fix code to follow new codesniffer profile

issue #5956
parent 9364ce61
...@@ -19,7 +19,7 @@ ...@@ -19,7 +19,7 @@
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA. Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA.
*/ */
function smarty_block_render($params, $text) function smarty_block_render ($params, $text)
{ {
/* Skip closing tag </render> */ /* Skip closing tag </render> */
if (empty($text)) { if (empty($text)) {
......
...@@ -17,7 +17,7 @@ ...@@ -17,7 +17,7 @@
along with this program; if not, write to the Free Software along with this program; if not, write to the Free Software
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA. Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA.
*/ */
function smarty_function_filePath($params, Smarty_Internal_Template $smarty) function smarty_function_filePath ($params, Smarty_Internal_Template $smarty)
{ {
$config = session::global_get('config'); $config = session::global_get('config');
$default_theme = 'breezy'; $default_theme = 'breezy';
......
...@@ -17,7 +17,7 @@ ...@@ -17,7 +17,7 @@
along with this program; if not, write to the Free Software along with this program; if not, write to the Free Software
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA. Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA.
*/ */
function smarty_function_iconPath($params) function smarty_function_iconPath ($params)
{ {
$config = session::global_get('config'); $config = session::global_get('config');
......
...@@ -18,7 +18,7 @@ ...@@ -18,7 +18,7 @@
along with this program; if not, write to the Free Software along with this program; if not, write to the Free Software
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA. Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA.
*/ */
function smarty_function_msgPool($params) function smarty_function_msgPool ($params)
{ {
if (class_available('msgPool') && isset($params['type'])) { if (class_available('msgPool') && isset($params['type'])) {
$parameter = array(); $parameter = array();
......
...@@ -31,7 +31,7 @@ reset_errors(); ...@@ -31,7 +31,7 @@ reset_errors();
/* Logged in? Simple security check */ /* Logged in? Simple security check */
if (!session::global_is_set('ui')) { if (!session::global_is_set('ui')) {
logging::log('security', 'unknown', '', array(), 'Error: autocomplete.php called without session'); logging::log('security', 'unknown', '', array(), 'Error: autocomplete.php called without session');
header ('Location: index.php'); header('Location: index.php');
exit; exit;
} }
......
...@@ -24,7 +24,7 @@ ...@@ -24,7 +24,7 @@
@require_once('functions.inc'); @require_once('functions.inc');
@require_once('variables.inc'); @require_once('variables.inc');
error_reporting (0); error_reporting(0);
session_cache_limiter('private'); session_cache_limiter('private');
session::start(); session::start();
reset_errors(); reset_errors();
...@@ -32,7 +32,7 @@ reset_errors(); ...@@ -32,7 +32,7 @@ reset_errors();
/* Logged in? Simple security check */ /* Logged in? Simple security check */
if (!session::global_is_set('ui')) { if (!session::global_is_set('ui')) {
logging::log('security', 'unknown', '', array(), 'Error: getbin.php called without session'); logging::log('security', 'unknown', '', array(), 'Error: getbin.php called without session');
header ('Location: index.php'); header('Location: index.php');
exit; exit;
} }
...@@ -54,5 +54,4 @@ if (session::is_set($key.'file')) { ...@@ -54,5 +54,4 @@ if (session::is_set($key.'file')) {
} }
echo session::get($key); echo session::get($key);
error_reporting (E_ALL | E_STRICT); error_reporting(E_ALL | E_STRICT);
?>
...@@ -89,7 +89,7 @@ if (!is_readable(CONFIG_DIR.'/'.CONFIG_FILE)) { ...@@ -89,7 +89,7 @@ if (!is_readable(CONFIG_DIR.'/'.CONFIG_FILE)) {
$config = new config(CONFIG_DIR.'/'.CONFIG_FILE, $BASE_DIR); $config = new config(CONFIG_DIR.'/'.CONFIG_FILE, $BASE_DIR);
session::global_set('config', $config); session::global_set('config', $config);
session::global_set('DEBUGLEVEL', $config->get_cfg_value('DEBUGLEVEL')); session::global_set('DEBUGLEVEL', $config->get_cfg_value('DEBUGLEVEL'));
@DEBUG (DEBUG_CONFIG, __LINE__, __FUNCTION__, __FILE__, $config->data, 'config'); @DEBUG(DEBUG_CONFIG, __LINE__, __FUNCTION__, __FILE__, $config->data, 'config');
/* Set template compile directory */ /* Set template compile directory */
$smarty->compile_dir = $config->get_cfg_value('templateCompileDirectory', SPOOL_DIR); $smarty->compile_dir = $config->get_cfg_value('templateCompileDirectory', SPOOL_DIR);
...@@ -129,7 +129,7 @@ if ( ...@@ -129,7 +129,7 @@ if (
/* If SSL is forced, just forward to the SSL enabled site */ /* If SSL is forced, just forward to the SSL enabled site */
if (($config->get_cfg_value('forcessl') == 'TRUE') && ($ssl != '')) { if (($config->get_cfg_value('forcessl') == 'TRUE') && ($ssl != '')) {
header ("Location: $ssl"); header("Location: $ssl");
exit; exit;
} }
...@@ -150,4 +150,3 @@ if (isset($_REQUEST['message'])) { ...@@ -150,4 +150,3 @@ if (isset($_REQUEST['message'])) {
} }
LoginMethod::loginProcess(); LoginMethod::loginProcess();
?>
...@@ -40,14 +40,14 @@ session::start(); ...@@ -40,14 +40,14 @@ session::start();
reset_errors(); reset_errors();
if ($_SERVER['REQUEST_METHOD'] == 'POST') { if ($_SERVER['REQUEST_METHOD'] == 'POST') {
@DEBUG (DEBUG_POST, __LINE__, __FUNCTION__, __FILE__, $_POST, '_POST'); @DEBUG(DEBUG_POST, __LINE__, __FUNCTION__, __FILE__, $_POST, '_POST');
} }
@DEBUG (DEBUG_SESSION, __LINE__, __FUNCTION__, __FILE__, $_SESSION, '_SESSION'); @DEBUG(DEBUG_SESSION, __LINE__, __FUNCTION__, __FILE__, $_SESSION, '_SESSION');
/* Logged in? Simple security check */ /* Logged in? Simple security check */
if (!session::global_is_set('connected')) { if (!session::global_is_set('connected')) {
logging::log('security', 'login', '', array(), 'main.php called without session - logging out'); logging::log('security', 'login', '', array(), 'main.php called without session - logging out');
header ('Location: index.php?message=nosession'); header('Location: index.php?message=nosession');
exit; exit;
} }
...@@ -58,7 +58,7 @@ $config = session::global_get('config'); ...@@ -58,7 +58,7 @@ $config = session::global_get('config');
/* If SSL is forced, just forward to the SSL enabled site */ /* If SSL is forced, just forward to the SSL enabled site */
if (($config->get_cfg_value('forcessl') == 'TRUE') && ($ssl != '')) { if (($config->get_cfg_value('forcessl') == 'TRUE') && ($ssl != '')) {
header ("Location: $ssl"); header("Location: $ssl");
exit; exit;
} }
...@@ -79,7 +79,7 @@ if (session::global_get('_LAST_PAGE_REQUEST') != '') { ...@@ -79,7 +79,7 @@ if (session::global_get('_LAST_PAGE_REQUEST') != '') {
if ($request_time > $max_life) { if ($request_time > $max_life) {
session::destroy(); session::destroy();
logging::log('security', 'login', '', array(), 'main.php called with expired session - logging out'); logging::log('security', 'login', '', array(), 'main.php called with expired session - logging out');
header ('Location: index.php?signout=1&message=expired'); header('Location: index.php?signout=1&message=expired');
exit; exit;
} }
} }
...@@ -87,7 +87,7 @@ if (session::global_get('_LAST_PAGE_REQUEST') != '') { ...@@ -87,7 +87,7 @@ if (session::global_get('_LAST_PAGE_REQUEST') != '') {
session::global_set('_LAST_PAGE_REQUEST', time()); session::global_set('_LAST_PAGE_REQUEST', time());
@DEBUG (DEBUG_CONFIG, __LINE__, __FUNCTION__, __FILE__, $config->data, "config"); @DEBUG(DEBUG_CONFIG, __LINE__, __FUNCTION__, __FILE__, $config->data, "config");
/* Set template compile directory */ /* Set template compile directory */
$smarty->compile_dir = $config->get_cfg_value("templateCompileDirectory", SPOOL_DIR); $smarty->compile_dir = $config->get_cfg_value("templateCompileDirectory", SPOOL_DIR);
...@@ -111,14 +111,14 @@ $smarty->assign("hideMenus", FALSE); ...@@ -111,14 +111,14 @@ $smarty->assign("hideMenus", FALSE);
if ($config->get_cfg_value("handleExpiredAccounts") == "TRUE") { if ($config->get_cfg_value("handleExpiredAccounts") == "TRUE") {
$expired = $ui->expired_status(); $expired = $ui->expired_status();
if (($expired == POSIX_WARN_ABOUT_EXPIRATION) && !session::is_set('POSIX_WARN_ABOUT_EXPIRATION__DONE')) { if (($expired == POSIX_WARN_ABOUT_EXPIRATION) && !session::is_set('POSIX_WARN_ABOUT_EXPIRATION__DONE')) {
@DEBUG (DEBUG_TRACE, __LINE__, __FUNCTION__, __FILE__, $expired, 'This user account ('.$ui->uid.') is about to expire'); @DEBUG(DEBUG_TRACE, __LINE__, __FUNCTION__, __FILE__, $expired, 'This user account ('.$ui->uid.') is about to expire');
// The users password is about to xpire soon, display a warning message. // The users password is about to xpire soon, display a warning message.
logging::log('security', 'fusiondirectory', '', array(), 'password for user "'.$ui->uid.'" is about to expire'); logging::log('security', 'fusiondirectory', '', array(), 'password for user "'.$ui->uid.'" is about to expire');
msg_dialog::display(_('Password change'), _('Your password is about to expire, please change your password!'), INFO_DIALOG); msg_dialog::display(_('Password change'), _('Your password is about to expire, please change your password!'), INFO_DIALOG);
session::set('POSIX_WARN_ABOUT_EXPIRATION__DONE', TRUE); session::set('POSIX_WARN_ABOUT_EXPIRATION__DONE', TRUE);
} elseif ($expired == POSIX_FORCE_PASSWORD_CHANGE) { } elseif ($expired == POSIX_FORCE_PASSWORD_CHANGE) {
@DEBUG (DEBUG_TRACE, __LINE__, __FUNCTION__, __FILE__, $expired, "This user account expired"); @DEBUG(DEBUG_TRACE, __LINE__, __FUNCTION__, __FILE__, $expired, "This user account expired");
// The password is expired, we are now going to enforce a new one from the user. // The password is expired, we are now going to enforce a new one from the user.
...@@ -178,11 +178,11 @@ if (isset($_GET['reset'])) { ...@@ -178,11 +178,11 @@ if (isset($_GET['reset'])) {
} }
/* show web frontend */ /* show web frontend */
$smarty->assign ("date", date("l, dS F Y H:i:s O")); $smarty->assign("date", date("l, dS F Y H:i:s O"));
$lang = session::global_get('lang'); $lang = session::global_get('lang');
$smarty->assign ('lang', preg_replace('/_.*$/', '', $lang)); $smarty->assign('lang', preg_replace('/_.*$/', '', $lang));
$smarty->assign ('rtl', Language::isRTL($lang)); $smarty->assign('rtl', Language::isRTL($lang));
$smarty->assign ('must', '<span class="must">*</span>'); $smarty->assign('must', '<span class="must">*</span>');
if (isset($plugin_index)) { if (isset($plugin_index)) {
$plug = "?plug=$plugin_index"; $plug = "?plug=$plugin_index";
} else { } else {
...@@ -190,12 +190,12 @@ if (isset($plugin_index)) { ...@@ -190,12 +190,12 @@ if (isset($plugin_index)) {
} }
if ($ui->ignore_acl_for_current_user()) { if ($ui->ignore_acl_for_current_user()) {
$smarty->assign ('username', '<div style="color:#FF0000;">'._('User ACL checks disabled').'</div>&nbsp;'.$ui->uid); $smarty->assign('username', '<div style="color:#FF0000;">'._('User ACL checks disabled').'</div>&nbsp;'.$ui->uid);
} else { } else {
$smarty->assign ('username', $ui->uid); $smarty->assign('username', $ui->uid);
} }
$smarty->assign ("menu", $plist->menu); $smarty->assign("menu", $plist->menu);
$smarty->assign ("plug", "$plug"); $smarty->assign("plug", "$plug");
$smarty->assign("usePrototype", "false"); $smarty->assign("usePrototype", "false");
......
...@@ -40,7 +40,7 @@ if ($p < 0) { ...@@ -40,7 +40,7 @@ if ($p < 0) {
} elseif ($p > 100) { } elseif ($p > 100) {
$p = 100; $p = 100;
} }
$p = intval ($p); $p = intval($p);
/* Check dimensions */ /* Check dimensions */
if ($x < 3 || $x > 1000) { if ($x < 3 || $x > 1000) {
...@@ -75,7 +75,7 @@ if (!function_exists("imagecreate")) { ...@@ -75,7 +75,7 @@ if (!function_exists("imagecreate")) {
} }
/* Draw image in GD image stream */ /* Draw image in GD image stream */
$im = imagecreate ($x, $y); $im = imagecreate($x, $y);
if (!$im) { if (!$im) {
die ('Cannot Initialize new GD image stream'); die ('Cannot Initialize new GD image stream');
} }
...@@ -87,18 +87,16 @@ if (!function_exists("imagecreate")) { ...@@ -87,18 +87,16 @@ if (!function_exists("imagecreate")) {
$tx_color = imagecolorallocate($im, 240, 10, 90); $tx_color = imagecolorallocate($im, 240, 10, 90);
/* Draw progress bar */ /* Draw progress bar */
imagerectangle ($im, 0, 0, $x - 1, $y - 1, $br_color); imagerectangle($im, 0, 0, $x - 1, $y - 1, $br_color);
imagefilledrectangle ($im, 1, 1, (($x - 2) * $p / 100), imagefilledrectangle($im, 1, 1, (($x - 2) * $p / 100), $y - 2, $fi_color);
$y - 2, $fi_color);
/* Is font to big for progress bar? */ /* Is font to big for progress bar? */
if ($font != 0) { if ($font != 0) {
imagestring ($im, $font, ($x - $fx) / 2, ($y - $fy) / 2, "$p%", $tx_color); imagestring($im, $font, ($x - $fx) / 2, ($y - $fy) / 2, "$p%", $tx_color);
} }
/* Finally draw the image and remove context */ /* Finally draw the image and remove context */
header ("Content-type: image/png"); header("Content-type: image/png");
imagepng ($im); imagepng($im);
imagedestroy ($im); imagedestroy($im);
} }
?>
...@@ -115,7 +115,7 @@ function parse_gettext_lang ($str) ...@@ -115,7 +115,7 @@ function parse_gettext_lang ($str)
} }
} }
function al2gt($gettextlangs) function al2gt ($gettextlangs)
{ {
/* Check if ACCEPT_LANGUAGE isset */ /* Check if ACCEPT_LANGUAGE isset */
if (empty($_SERVER["HTTP_ACCEPT_LANGUAGE"])) { if (empty($_SERVER["HTTP_ACCEPT_LANGUAGE"])) {
......
...@@ -20,7 +20,7 @@ ...@@ -20,7 +20,7 @@
class CSRFProtection class CSRFProtection
{ {
public static function check() public static function check ()
{ {
if (empty($_POST)) { if (empty($_POST)) {
return; return;
...@@ -36,7 +36,7 @@ class CSRFProtection ...@@ -36,7 +36,7 @@ class CSRFProtection
} }
} }
public static function getToken() public static function getToken ()
{ {
if (!session::is_set('CSRFtoken')) { if (!session::is_set('CSRFtoken')) {
session::set('CSRFtoken', standAlonePage::generateRandomHash()); session::set('CSRFtoken', standAlonePage::generateRandomHash());
...@@ -44,7 +44,7 @@ class CSRFProtection ...@@ -44,7 +44,7 @@ class CSRFProtection
return session::get('CSRFtoken'); return session::get('CSRFtoken');
} }
public static function checkHeaders() public static function checkHeaders ()
{ {
$origin = FALSE; $origin = FALSE;
if (!empty($_SERVER['HTTP_ORIGIN'])) { if (!empty($_SERVER['HTTP_ORIGIN'])) {
......
...@@ -28,7 +28,7 @@ class Combinations implements Iterator ...@@ -28,7 +28,7 @@ class Combinations implements Iterator
protected $size = 0; protected $size = 0;
protected $pos = 0; protected $pos = 0;
function __construct(array $input, $size) function __construct (array $input, $size)
{ {
$this->input = array_values($input); $this->input = array_values($input);
$this->n = count($this->input); $this->n = count($this->input);
...@@ -36,12 +36,12 @@ class Combinations implements Iterator ...@@ -36,12 +36,12 @@ class Combinations implements Iterator
$this->rewind(); $this->rewind();
} }
function key() function key ()
{ {
return $this->pos; return $this->pos;
} }
function current() function current ()
{ {
$r = array(); $r = array();
for ($i = 0; $i < $this->size; $i++) { for ($i = 0; $i < $this->size; $i++) {
...@@ -50,7 +50,7 @@ class Combinations implements Iterator ...@@ -50,7 +50,7 @@ class Combinations implements Iterator
return $r; return $r;
} }
function next() function next ()
{ {
if ($this->_next()) { if ($this->_next()) {
$this->pos++; $this->pos++;
...@@ -59,18 +59,18 @@ class Combinations implements Iterator ...@@ -59,18 +59,18 @@ class Combinations implements Iterator
} }
} }
function rewind() function rewind ()
{ {
$this->current = range(0, $this->size); $this->current = range(0, $this->size);
$this->pos = 0; $this->pos = 0;
} }
function valid() function valid ()
{ {
return ($this->pos >= 0); return ($this->pos >= 0);
} }
protected function _next() protected function _next ()
{ {
$i = $this->size - 1; $i = $this->size - 1;
while (($i >= 0) && ($this->current[$i] == $this->n - $this->size + $i)) { while (($i >= 0) && ($this->current[$i] == $this->n - $this->size + $i)) {
......
...@@ -53,7 +53,7 @@ class CopyPasteHandler ...@@ -53,7 +53,7 @@ class CopyPasteHandler
/*! /*!
* \brief Create CP handler * \brief Create CP handler
*/ */
function __construct() function __construct ()
{ {
} }
...@@ -70,9 +70,9 @@ class CopyPasteHandler ...@@ -70,9 +70,9 @@ class CopyPasteHandler
* *
* \param String $type the type of the object * \param String $type the type of the object
*/ */
function add_to_queue($dn, $action, $type) function add_to_queue ($dn, $action, $type)
{ {
@DEBUG (DEBUG_TRACE, __LINE__, __FUNCTION__, __FILE__, $dn, 'add_to_queue'); @DEBUG(DEBUG_TRACE, __LINE__, __FUNCTION__, __FILE__, $dn, 'add_to_queue');
if (!in_array($action, array('cut','copy'))) { if (!in_array($action, array('cut','copy'))) {
trigger_error(sprintf('Specified action "%s" does not exists for copy & paste.', $action)); trigger_error(sprintf('Specified action "%s" does not exists for copy & paste.', $action));
...@@ -105,7 +105,7 @@ class CopyPasteHandler ...@@ -105,7 +105,7 @@ class CopyPasteHandler
* Remove hdd dumps of current entries too. * Remove hdd dumps of current entries too.
* Remove entries older than 24 hours. * Remove entries older than 24 hours.
*/ */
function cleanup_queue() function cleanup_queue ()
{ {
$this->current = FALSE; $this->current = FALSE;
$this->require_update = TRUE; $this->require_update = TRUE;
...@@ -116,7 +116,7 @@ class CopyPasteHandler ...@@ -116,7 +116,7 @@ class CopyPasteHandler
/*! /*!
* \brief This resets the queue to allow pasting again. * \brief This resets the queue to allow pasting again.
*/ */
function resetPaste() function resetPaste ()
{ {
$this->current = FALSE; $this->current = FALSE;
$this->require_update = TRUE; $this->require_update = TRUE;
...@@ -126,7 +126,7 @@ class CopyPasteHandler ...@@ -126,7 +126,7 @@ class CopyPasteHandler
/*! /*!
* \brief Check if there are still entries the object queue * \brief Check if there are still entries the object queue
*/ */
function entries_queued() function entries_queued ()
{ {
return ((count($this->queue) > 0) || ($this->current !== FALSE)); return ((count($this->queue) > 0) || ($this->current !== FALSE));
} }
...@@ -134,9 +134,9 @@ class CopyPasteHandler ...@@ -134,9 +134,9 @@ class CopyPasteHandler
/*! /*!
* \brief Paste one entry from LDAP * \brief Paste one entry from LDAP
*/ */
protected function load_entry_from_ldap($entry, $base) protected function load_entry_from_ldap ($entry, $base)
{ {
@DEBUG (DEBUG_TRACE, __LINE__, __FUNCTION__, __FILE__, $entry['dn'], 'load_entry_from_ldap'); @DEBUG(DEBUG_TRACE, __LINE__, __FUNCTION__, __FILE__, $entry['dn'], 'load_entry_from_ldap');
if (!isset($entry['tab_class']) && !isset($entry['type'])) { if (!isset($entry['tab_class']) && !isset($entry['type'])) {
return array(); return array();
} }
...@@ -161,7 +161,7 @@ class CopyPasteHandler ...@@ -161,7 +161,7 @@ class CopyPasteHandler
* \brief Displays a dialog which allows the user to fix all dependencies of this object. * \brief Displays a dialog which allows the user to fix all dependencies of this object.
* Create unique names, ids, or what ever * Create unique names, ids, or what ever
*/ */
function execute($base) function execute ($base)
{ {
$ui = get_userinfo(); $ui = get_userinfo();
...@@ -266,7 +266,7 @@ class CopyPasteHandler ...@@ -266,7 +266,7 @@ class CopyPasteHandler
return ''; return '';
} }
private function current_saved() private function current_saved ()
{ {
$this->lastdn = $this->current['object']->dn; $this->lastdn = $this->current['object']->dn;
$this->handleReferences(); $this->handleReferences();
...@@ -278,7 +278,7 @@ class CopyPasteHandler ...@@ -278,7 +278,7 @@ class CopyPasteHandler
* *
* \return the dn of the last edited entry * \return the dn of the last edited entry
*/ */
function last_entry() function last_entry ()
{ {
return $this->lastdn; return $this->lastdn;
} }
...@@ -287,7 +287,7 @@ class CopyPasteHandler ...@@ -287,7 +287,7 @@ class CopyPasteHandler
/*! /*!
* \brief Save new values posted by copy & paste dialog * \brief Save new values posted by copy & paste dialog
*/ */
function save_object() function save_object ()
{ {
if (isset($_POST['abort_current_cut-copy_operation'])) { if (isset($_POST['abort_current_cut-copy_operation'])) {
$this->current = FALSE;