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 @@
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> */
if (empty($text)) {
......
......@@ -17,7 +17,7 @@
along with this program; if not, write to the Free Software
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');
$default_theme = 'breezy';
......
......@@ -17,7 +17,7 @@
along with this program; if not, write to the Free Software
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');
......
......@@ -18,7 +18,7 @@
along with this program; if not, write to the Free Software
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'])) {
$parameter = array();
......
......@@ -31,7 +31,7 @@ reset_errors();
/* Logged in? Simple security check */
if (!session::global_is_set('ui')) {
logging::log('security', 'unknown', '', array(), 'Error: autocomplete.php called without session');
header ('Location: index.php');
header('Location: index.php');
exit;
}
......
......@@ -24,7 +24,7 @@
@require_once('functions.inc');
@require_once('variables.inc');
error_reporting (0);
error_reporting(0);
session_cache_limiter('private');
session::start();
reset_errors();
......@@ -32,7 +32,7 @@ reset_errors();
/* Logged in? Simple security check */
if (!session::global_is_set('ui')) {
logging::log('security', 'unknown', '', array(), 'Error: getbin.php called without session');
header ('Location: index.php');
header('Location: index.php');
exit;
}
......@@ -54,5 +54,4 @@ if (session::is_set($key.'file')) {
}
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)) {
$config = new config(CONFIG_DIR.'/'.CONFIG_FILE, $BASE_DIR);
session::global_set('config', $config);
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 */
$smarty->compile_dir = $config->get_cfg_value('templateCompileDirectory', SPOOL_DIR);
......@@ -129,7 +129,7 @@ if (
/* If SSL is forced, just forward to the SSL enabled site */
if (($config->get_cfg_value('forcessl') == 'TRUE') && ($ssl != '')) {
header ("Location: $ssl");
header("Location: $ssl");
exit;
}
......@@ -150,4 +150,3 @@ if (isset($_REQUEST['message'])) {
}
LoginMethod::loginProcess();
?>
......@@ -40,14 +40,14 @@ session::start();
reset_errors();
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 */
if (!session::global_is_set('connected')) {
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;
}
......@@ -58,7 +58,7 @@ $config = session::global_get('config');
/* If SSL is forced, just forward to the SSL enabled site */
if (($config->get_cfg_value('forcessl') == 'TRUE') && ($ssl != '')) {
header ("Location: $ssl");
header("Location: $ssl");
exit;
}
......@@ -79,7 +79,7 @@ if (session::global_get('_LAST_PAGE_REQUEST') != '') {
if ($request_time > $max_life) {
session::destroy();
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;
}
}
......@@ -87,7 +87,7 @@ if (session::global_get('_LAST_PAGE_REQUEST') != '') {
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 */
$smarty->compile_dir = $config->get_cfg_value("templateCompileDirectory", SPOOL_DIR);
......@@ -111,14 +111,14 @@ $smarty->assign("hideMenus", FALSE);
if ($config->get_cfg_value("handleExpiredAccounts") == "TRUE") {
$expired = $ui->expired_status();
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.
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);
session::set('POSIX_WARN_ABOUT_EXPIRATION__DONE', TRUE);
} 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.
......@@ -178,11 +178,11 @@ if (isset($_GET['reset'])) {
}
/* 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');
$smarty->assign ('lang', preg_replace('/_.*$/', '', $lang));
$smarty->assign ('rtl', Language::isRTL($lang));
$smarty->assign ('must', '<span class="must">*</span>');
$smarty->assign('lang', preg_replace('/_.*$/', '', $lang));
$smarty->assign('rtl', Language::isRTL($lang));
$smarty->assign('must', '<span class="must">*</span>');
if (isset($plugin_index)) {
$plug = "?plug=$plugin_index";
} else {
......@@ -190,12 +190,12 @@ if (isset($plugin_index)) {
}
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 {
$smarty->assign ('username', $ui->uid);
$smarty->assign('username', $ui->uid);
}
$smarty->assign ("menu", $plist->menu);
$smarty->assign ("plug", "$plug");
$smarty->assign("menu", $plist->menu);
$smarty->assign("plug", "$plug");
$smarty->assign("usePrototype", "false");
......
......@@ -40,7 +40,7 @@ if ($p < 0) {
} elseif ($p > 100) {
$p = 100;
}
$p = intval ($p);
$p = intval($p);
/* Check dimensions */
if ($x < 3 || $x > 1000) {
......@@ -75,7 +75,7 @@ if (!function_exists("imagecreate")) {
}
/* Draw image in GD image stream */
$im = imagecreate ($x, $y);
$im = imagecreate($x, $y);
if (!$im) {
die ('Cannot Initialize new GD image stream');
}
......@@ -87,18 +87,16 @@ if (!function_exists("imagecreate")) {
$tx_color = imagecolorallocate($im, 240, 10, 90);
/* Draw progress bar */
imagerectangle ($im, 0, 0, $x - 1, $y - 1, $br_color);
imagefilledrectangle ($im, 1, 1, (($x - 2) * $p / 100),
$y - 2, $fi_color);
imagerectangle($im, 0, 0, $x - 1, $y - 1, $br_color);
imagefilledrectangle($im, 1, 1, (($x - 2) * $p / 100), $y - 2, $fi_color);
/* Is font to big for progress bar? */
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 */
header ("Content-type: image/png");
imagepng ($im);
imagedestroy ($im);
header("Content-type: image/png");
imagepng($im);
imagedestroy($im);
}
?>
......@@ -115,7 +115,7 @@ function parse_gettext_lang ($str)
}
}
function al2gt($gettextlangs)
function al2gt ($gettextlangs)
{
/* Check if ACCEPT_LANGUAGE isset */
if (empty($_SERVER["HTTP_ACCEPT_LANGUAGE"])) {
......
......@@ -20,7 +20,7 @@
class CSRFProtection
{
public static function check()
public static function check ()
{
if (empty($_POST)) {
return;
......@@ -36,7 +36,7 @@ class CSRFProtection
}
}
public static function getToken()
public static function getToken ()
{
if (!session::is_set('CSRFtoken')) {
session::set('CSRFtoken', standAlonePage::generateRandomHash());
......@@ -44,7 +44,7 @@ class CSRFProtection
return session::get('CSRFtoken');
}
public static function checkHeaders()
public static function checkHeaders ()
{
$origin = FALSE;
if (!empty($_SERVER['HTTP_ORIGIN'])) {
......
......@@ -28,7 +28,7 @@ class Combinations implements Iterator
protected $size = 0;
protected $pos = 0;
function __construct(array $input, $size)
function __construct (array $input, $size)
{
$this->input = array_values($input);
$this->n = count($this->input);
......@@ -36,12 +36,12 @@ class Combinations implements Iterator
$this->rewind();
}
function key()
function key ()
{
return $this->pos;
}
function current()
function current ()
{
$r = array();
for ($i = 0; $i < $this->size; $i++) {
......@@ -50,7 +50,7 @@ class Combinations implements Iterator
return $r;
}
function next()
function next ()
{
if ($this->_next()) {
$this->pos++;
......@@ -59,18 +59,18 @@ class Combinations implements Iterator
}
}
function rewind()
function rewind ()
{
$this->current = range(0, $this->size);
$this->pos = 0;
}
function valid()
function valid ()
{
return ($this->pos >= 0);
}
protected function _next()
protected function _next ()
{
$i = $this->size - 1;
while (($i >= 0) && ($this->current[$i] == $this->n - $this->size + $i)) {
......
......@@ -53,7 +53,7 @@ class CopyPasteHandler
/*!
* \brief Create CP handler
*/
function __construct()
function __construct ()
{
}
......@@ -70,9 +70,9 @@ class CopyPasteHandler
*
* \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'))) {
trigger_error(sprintf('Specified action "%s" does not exists for copy & paste.', $action));
......@@ -105,7 +105,7 @@ class CopyPasteHandler
* Remove hdd dumps of current entries too.
* Remove entries older than 24 hours.
*/
function cleanup_queue()
function cleanup_queue ()
{
$this->current = FALSE;
$this->require_update = TRUE;
......@@ -116,7 +116,7 @@ class CopyPasteHandler
/*!
* \brief This resets the queue to allow pasting again.
*/
function resetPaste()
function resetPaste ()
{
$this->current = FALSE;
$this->require_update = TRUE;
......@@ -126,7 +126,7 @@ class CopyPasteHandler
/*!
* \brief Check if there are still entries the object queue
*/
function entries_queued()
function entries_queued ()
{
return ((count($this->queue) > 0) || ($this->current !== FALSE));
}
......@@ -134,9 +134,9 @@ class CopyPasteHandler
/*!
* \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'])) {
return array();
}
......@@ -161,7 +161,7 @@ class CopyPasteHandler
* \brief Displays a dialog which allows the user to fix all dependencies of this object.
* Create unique names, ids, or what ever
*/
function execute($base)
function execute ($base)
{
$ui = get_userinfo();
......@@ -266,7 +266,7 @@ class CopyPasteHandler
return '';
}
private function current_saved()
private function current_saved ()
{
$this->lastdn = $this->current['object']->dn;
$this->handleReferences();
......@@ -278,7 +278,7 @@ class CopyPasteHandler
*
* \return the dn of the last edited entry
*/
function last_entry()
function last_entry ()
{
return $this->lastdn;
}
......@@ -287,7 +287,7 @@ class CopyPasteHandler
/*!
* \brief Save new values posted by copy & paste dialog
*/
function save_object()
function save_object ()
{
if (isset($_POST['abort_current_cut-copy_operation'])) {
$this->current = FALSE;
......@@ -299,7 +299,7 @@ class CopyPasteHandler
}
}
function handleReferences()
function handleReferences ()
{
$dst_dn = $this->current['object']->dn;
$src_dn = $this->current['dn'];
......@@ -316,7 +316,7 @@ class CopyPasteHandler
*
* \return the paste icon for headpages
*/
function generatePasteIcon()
function generatePasteIcon ()
{
$Copy_Paste = "&nbsp;<img class='center' src='images/lists/seperator.png' alt='' height='16' width='1'>&nbsp;";
if ($this->entries_queued()) {
......
......@@ -49,7 +49,7 @@ class IconThemeDir
* Defaults to 2 if not present. */
private $Threshold = 2;
function __construct($infos)
function __construct ($infos)
{
$this->Size = $infos['Size'];
$this->MinSize = $infos['Size'];
......@@ -66,7 +66,7 @@ class IconThemeDir
}
}
function MatchesSize($size)
function MatchesSize ($size)
{
switch ($this->Type) {
case 'Fixed':
......@@ -78,7 +78,7 @@ class IconThemeDir
}
}
function SizeDistance($size)
function SizeDistance ($size)
{
switch ($this->Type) {
case 'Fixed':
......@@ -106,7 +106,7 @@ class IconTheme
private $path;
private $parent;
function __construct($folder, $default_parent)
function __construct ($folder, $default_parent)
{
$this->path = $folder;
$datas = @parse_ini_file($folder.'/index.theme', TRUE, INI_SCANNER_RAW);
......@@ -127,13 +127,13 @@ class IconTheme
}
}
function FindIcon($context, $icon, $size)
function FindIcon ($context, $icon, $size)
{
$context = strtolower($context);
return $this->FindIconHelper($context, $icon, $size);
}
function FindIconHelper($context, $icon, $size)
function FindIconHelper ($context, $icon, $size)
{
$filename = $this->LookupIcon($context, $icon, $size);
if ($filename != NULL) {
......@@ -159,7 +159,7 @@ class IconTheme
return NULL;
}
function LookupIcon($context, $iconname, $size)
function LookupIcon ($context, $iconname, $size)
{
if (!isset($this->subdirs[$context])) {
return NULL;
......@@ -203,7 +203,7 @@ class IconTheme
/* We store themes in the session. To do otherwise, override these methods. */
static public $session_var = 'IconThemes';
static public function loadThemes($path)
static public function loadThemes ($path)
{
$themes = array();
if ($dir = opendir("$path")) {
......@@ -224,7 +224,7 @@ class IconTheme
$_SESSION[static::$session_var] = $themes;
}
static public function findThemeIcon($theme, $context, $icon, $size)
static public function findThemeIcon ($theme, $context, $icon, $size)
{
if (!isset($_SESSION[static::$session_var])) {
die('Error: no theme found in session');
......@@ -235,7 +235,7 @@ class IconTheme
return $_SESSION[static::$session_var][static::$default_theme]->FindIcon($context, $icon, $size);
}
public function findTheme($theme)
public function findTheme ($theme)
{
if (isset($_SESSION[static::$session_var][$theme])) {
return $_SESSION[static::$session_var][$theme];
......
......@@ -34,7 +34,7 @@ class Language
*
* \param string $lang Language locale to use, defaults to self::detect()
*/
public static function init($lang = NULL)
public static function init ($lang = NULL)
{
global $BASE_DIR;
......@@ -60,7 +60,7 @@ class Language
bindtextdomain($domain, LOCALE_DIR);
textdomain($domain);
if ($_SERVER['REQUEST_METHOD'] != 'POST') {
@DEBUG (DEBUG_TRACE, __LINE__, __FUNCTION__, __FILE__, $lang, 'Setting language to');
@DEBUG(DEBUG_TRACE, __LINE__, __FUNCTION__, __FILE__, $lang, 'Setting language to');
}
$ret = FALSE;
......@@ -70,7 +70,7 @@ class Language
$ret = TRUE;
if (session::global_is_set('plist')) {
if ($_SERVER['REQUEST_METHOD'] != 'POST') {
@DEBUG (DEBUG_TRACE, __LINE__, __FUNCTION__, __FILE__, session::global_get('lang'), 'Plist already loaded with language');
@DEBUG(DEBUG_TRACE, __LINE__, __FUNCTION__, __FILE__, session::global_get('lang'), 'Plist already loaded with language');
}
session::global_un_set('plist');
session::global_set('lang', $lang);
......@@ -95,7 +95,7 @@ class Language
*
* \return string gettext locale string
*/
public static function detect()
public static function detect ()
{
global $config;
......@@ -132,7 +132,7 @@ class Language
*
* \param boolean $ownLanguage Should language names be stated in their own language as well
*/
public static function getList($ownLanguage = FALSE)
public static function getList ($ownLanguage = FALSE)
{
/* locales in english */
$tmp_english = array(
......@@ -224,7 +224,7 @@ class Language
return preg_match('/^(fa_|ar_)/', $lang);
}
public static function setHeaders($language, $mime)
public static function setHeaders ($language, $mime)
{
list ($lang, $country, $char) = parse_gettext_lang($language);
......
......@@ -71,7 +71,7 @@ class SnapshotCreateDialog extends simplePlugin
*
* \param mixed $attr Attribute object or name (in this case it will be fetched from attributesAccess)
*/
function attrIsWriteable($attr): bool
function attrIsWriteable ($attr): bool
{
global $ui;
......@@ -85,7 +85,7 @@ class SnapshotCreateDialog extends simplePlugin
}
}
function renderAttributes($readOnly = FALSE)
function renderAttributes ($readOnly = FALSE)
{
global $ui;
$smarty = get_smarty();
......@@ -162,7 +162,7 @@ class SnapshotsAttribute extends OrderedArrayAttribute
}
}
protected function handleEdit($key)
protected function handleEdit ($key)
{
}
......@@ -170,7 +170,7 @@ class SnapshotsAttribute extends OrderedArrayAttribute
{
}
function addValue($value)
function addValue ($value)
{
$this->value[] = $value;
$this->reIndexValues();
......@@ -181,7 +181,7 @@ class SnapshotsAttribute extends OrderedArrayAttribute
return '';
}
protected function getAttributeArrayValue($key, $value)
protected function getAttributeArrayValue ($key, $value)
{
$values = array(
date(_('Y-m-d, H:i:s'), preg_replace('/\-.*$/', '', $value['gosaSnapshotTimestamp'][0])),
......@@ -193,7 +193,7 @@ class SnapshotsAttribute extends OrderedArrayAttribute
return $values;
}
protected function genRowIcons($key, $value)
protected function genRowIcons ($key, $value)
{
$id = $this->getHtmlId();
list ($img, $nbicons) = parent::genRowIcons($key, $value);
......@@ -211,7 +211,7 @@ class SnapshotsAttribute extends OrderedArrayAttribute
return array ($img, $nbicons);
}
protected