Skip to content

Commit

Permalink
net/phpldapadmin: fix support for php81+
Browse files Browse the repository at this point in the history
PR:	266678
Reported by:	Gerard Seibert
Approved by: rene (mentor)
Differential Revision: https://reviews.freebsd.org/D37513
  • Loading branch information
Krzysztof authored and Ronald Klop committed Dec 1, 2022
1 parent d008ed9 commit fee2b33
Show file tree
Hide file tree
Showing 36 changed files with 2,698 additions and 135 deletions.
2 changes: 1 addition & 1 deletion net/phpldapadmin/Makefile
@@ -1,6 +1,6 @@
PORTNAME= phpldapadmin
PORTVERSION= 1.2.6.3
PORTREVISION= 1
PORTREVISION= 2
CATEGORIES= net www
PKGNAMESUFFIX= ${PHP_PKGNAMESUFFIX}

Expand Down
11 changes: 11 additions & 0 deletions net/phpldapadmin/files/patch-htdocs_add__oclass__form.php
@@ -0,0 +1,11 @@
--- htdocs/add_oclass_form.php.orig 2021-12-12 02:35:51 UTC
+++ htdocs/add_oclass_form.php
@@ -36,7 +36,7 @@ $ldap['attrs']['must'] = array();

foreach ($request['template']->getAttribute('objectclass')->getValues() as $oclass_name) {
# Exclude "top" if its there.
- if (! strcasecmp('top',$oclass_name))
+ if (! strcasecmp('top',(string) $oclass_name))
continue;

if ($soc = $app['server']->getSchemaObjectClass($oclass_name))
32 changes: 32 additions & 0 deletions net/phpldapadmin/files/patch-htdocs_add__value__form.php
@@ -0,0 +1,32 @@
--- htdocs/add_value_form.php.orig 2021-12-12 02:35:51 UTC
+++ htdocs/add_value_form.php
@@ -32,12 +32,12 @@ if ($request['attribute']->isReadOnly())
*/

# Render the form
-if (! strcasecmp($request['attr'],'objectclass') || get_request('meth','REQUEST') != 'ajax') {
+if (! strcasecmp((string) $request['attr'],'objectclass') || get_request('meth','REQUEST') != 'ajax') {
# Render the form.
$request['page']->drawTitle(sprintf('%s <b>%s</b> %s <b>%s</b>',_('Add new'),htmlspecialchars($request['attr']),_('value to'),htmlspecialchars(get_rdn($request['dn']))));
$request['page']->drawSubTitle();

- if (! strcasecmp($request['attr'],'objectclass')) {
+ if (! strcasecmp((string) $request['attr'],'objectclass')) {
echo '<form action="cmd.php" method="post" class="new_value" id="entry_form">';
echo '<div>';
echo '<input type="hidden" name="cmd" value="add_oclass_form" />';
@@ -91,12 +91,12 @@ if (! strcasecmp($request['attr'],'objectclass') || ge
printf('<td class="top">%s</td>',_('Enter the value(s) you would like to add:'));
echo '<td>';

- if (! strcasecmp($request['attr'],'objectclass')) {
+ if (! strcasecmp((string) $request['attr'],'objectclass')) {
# If our attr is an objectClass, fetch all available objectClasses and remove those from the list that are already defined in the entry
$socs = $app['server']->SchemaObjectClasses();

foreach ($request['attribute']->getValues() as $oclass)
- unset($socs[strtolower($oclass)]);
+ unset($socs[strtolower((string) $oclass)]);

# Draw objectClass selection
echo '<table border="0">';
11 changes: 11 additions & 0 deletions net/phpldapadmin/files/patch-htdocs_cmd.php
@@ -0,0 +1,11 @@
--- htdocs/cmd.php.orig 2021-12-12 02:35:51 UTC
+++ htdocs/cmd.php
@@ -41,7 +41,7 @@ if (DEBUG_ENABLED)
$www['page'] = new page($app['server']->getIndex());

# See if we can render the command
-if (trim($www['cmd'])) {
+if (trim((string) $www['cmd'])) {
# If this is a READ-WRITE operation, the LDAP server must not be in READ-ONLY mode.
if ($app['server']->isReadOnly() && ! in_array(get_request('cmd','REQUEST'),$app['readwrite_cmds']))
error(_('You cannot perform updates while server is in read-only mode'),'error','index.php');
11 changes: 11 additions & 0 deletions net/phpldapadmin/files/patch-htdocs_copy.php
@@ -0,0 +1,11 @@
--- htdocs/copy.php.orig 2021-12-12 02:35:51 UTC
+++ htdocs/copy.php
@@ -21,7 +21,7 @@ $ldap['SRC'] = $_SESSION[APPCONFIG]->getServer(get_req
$ldap['DST'] = $_SESSION[APPCONFIG]->getServer(get_request('server_id_dst'));

# Error checking
-if (! trim($request['dnDST']))
+if (! trim((string) $request['dnDST']))
error(_('You left the destination DN blank.'),'error','index.php');

if ($ldap['DST']->isReadOnly())
11 changes: 11 additions & 0 deletions net/phpldapadmin/files/patch-htdocs_download__binary__attr.php
@@ -0,0 +1,11 @@
--- htdocs/download_binary_attr.php.orig 2021-12-12 02:35:51 UTC
+++ htdocs/download_binary_attr.php
@@ -15,7 +15,7 @@ require './common.php';

$request = array();
$request['dn'] = get_request('dn','GET');
-$request['attr'] = strtolower(get_request('attr','GET',true));
+$request['attr'] = strtolower((string) get_request('attr','GET',true));
$request['index'] = get_request('index','GET',false,0);
$request['type'] = get_request('type','GET',false,'octet-stream');
$request['filename'] = get_request('filename','GET',false,sprintf('%s:%s.bin',get_rdn($request['dn'],true),$request['attr']));
11 changes: 11 additions & 0 deletions net/phpldapadmin/files/patch-htdocs_export__form.php
@@ -0,0 +1,11 @@
--- htdocs/export_form.php.orig 2021-12-12 02:35:51 UTC
+++ htdocs/export_form.php
@@ -166,7 +166,7 @@ function get_line_end_format() {
*/
function get_user_agent_string() {
if (isset($_SERVER['HTTP_USER_AGENT']))
- return strtolower($_SERVER['HTTP_USER_AGENT']);
+ return strtolower((string) $_SERVER['HTTP_USER_AGENT']);
else
return '';
}
11 changes: 11 additions & 0 deletions net/phpldapadmin/files/patch-htdocs_login.php
@@ -0,0 +1,11 @@
--- htdocs/login.php.orig 2021-12-12 02:35:51 UTC
+++ htdocs/login.php
@@ -22,7 +22,7 @@ if ($pass) {
$user['password'] = get_request('login_pass');
$user['password'] = html_entity_decode($user['password'], ENT_QUOTES);

- if ($user['login'] && !strlen($user['password'])) {
+ if ($user['login'] && empty($user['password'])) {
system_message(array(
'title' => _('Authenticate to server'),
'body' => _('You left the password blank.'),
16 changes: 16 additions & 0 deletions net/phpldapadmin/files/patch-htdocs_login__form.php
@@ -0,0 +1,16 @@
--- htdocs/login_form.php.orig 2021-12-12 02:35:51 UTC
+++ htdocs/login_form.php
@@ -19,11 +19,11 @@ echo '<br />';
$isHTTPS = false;

# Check if the current connection is encrypted
-if (isset($_SERVER['HTTPS']) && strtolower($_SERVER['HTTPS']) == 'on') {
+if (isset($_SERVER['HTTPS']) && strtolower((string) $_SERVER['HTTPS']) == 'on') {
$isHTTPS = true;
}
# Check if a proxy server downstream does encryption for us
-elseif (!empty($_SERVER['HTTP_X_FORWARDED_PROTO']) && strtolower($_SERVER['HTTP_X_FORWARDED_PROTO']) == 'https' || !empty($_SERVER['HTTP_X_FORWARDED_SSL']) && strtolower($_SERVER['HTTP_X_FORWARDED_SSL'])
+elseif (!empty($_SERVER['HTTP_X_FORWARDED_PROTO']) && strtolower((string) $_SERVER['HTTP_X_FORWARDED_PROTO']) == 'https' || !empty($_SERVER['HTTP_X_FORWARDED_SSL']) && strtolower($_SERVER['HTTP_X_FORWARDED_SSL'])
== 'on') {
$isHTTPS = true;
}
29 changes: 29 additions & 0 deletions net/phpldapadmin/files/patch-htdocs_monitor.php
@@ -0,0 +1,29 @@
--- htdocs/monitor.php.orig 2021-12-12 02:35:51 UTC
+++ htdocs/monitor.php
@@ -48,7 +48,7 @@ foreach (array(
if (isset($results[$dn]['description'])) {
$description = implode(' ',$results[$dn]['description']);

- $description = preg_replace('/"/','\'',$description);
+ $description = preg_replace('/"/','\'',is_null($description)? "":$description);
} else {
$description = '';
}
@@ -103,7 +103,7 @@ foreach (array(
else
$sc = $results[$key][$attr];

- if (strcasecmp('supportedcontrol',$attr) == 0)
+ if (strcasecmp('supportedcontrol',(string) $attr) == 0)
foreach ($sc as $control) {
$oidtotext = support_oid_to_text($control);

@@ -199,7 +199,7 @@ foreach (array(
) as $dn ) {

$description = implode(' ',$results[$dn]['description']);
- $description = preg_replace('/"/','\'',$description);
+ $description = preg_replace('/"/','\'',is_null($description)? "":$description);

printf('<tr class="list_item"><td class="heading" rowspan="2"><acronym title="%s">%s</acronym></td></tr>',$description,$dn);
echo '<tr class="list_item"><td class="value">';
11 changes: 11 additions & 0 deletions net/phpldapadmin/files/patch-htdocs_purge__cache.php
@@ -0,0 +1,11 @@
--- htdocs/purge_cache.php.orig 2021-12-12 02:35:51 UTC
+++ htdocs/purge_cache.php
@@ -16,7 +16,7 @@ $purge_session_keys = array('app_initialized','backtra
$size = 0;
foreach ($purge_session_keys as $key)
if (isset($_SESSION[$key])) {
- $size += strlen(serialize($_SESSION[$key]));
+ $size += strlen((string) serialize($_SESSION[$key]));
unset($_SESSION[$key]);
}

165 changes: 165 additions & 0 deletions net/phpldapadmin/files/patch-htdocs_schema.php
@@ -0,0 +1,165 @@
--- htdocs/schema.php.orig 2021-12-12 02:35:51 UTC
+++ htdocs/schema.php
@@ -25,7 +25,7 @@ $entry['value'] = get_request('viewvalue','GET');

if (! is_null($entry['value'])) {
$entry['viewed'] = false;
- $entry['value'] = strtolower($entry['value']);
+ $entry['value'] = strtolower((string) $entry['value']);
}

$schema_error_str = sprintf('%s <b>%s</b>.<br /><br /></div>%s<ul><li>%s</li><li>%s</li><li>%s</li><li>%s</li></ul>',
@@ -149,12 +149,12 @@ switch($entry['view']) {
echo '<br />';

foreach ($sattrs as $attr) {
- if (isAjaxEnabled() || (is_null($entry['value']) || ! trim($entry['value']) || $entry['value']==$attr->getName())) {
- if ((! is_null($entry['value']) && $entry['value']==$attr->getName()) || ! trim($entry['value']))
+ if (isAjaxEnabled() || (is_null($entry['value']) || ! trim((string) $entry['value']) || $entry['value']==$attr->getName())) {
+ if ((! is_null($entry['value']) && $entry['value']==$attr->getName()) || ! trim((string) $entry['value']))
$entry['viewed'] = true;

if (isAjaxEnabled() && $entry['value'])
- printf('<div id="at%s" style="display: %s">',$attr->getName(),strcasecmp($entry['value'],$attr->getName()) ? 'none' : 'block');
+ printf('<div id="at%s" style="display: %s">',(string) $attr->getName(),strcasecmp((string) $entry['value'],(string) $attr->getName()) ? 'none' : 'block');
else
printf('<div id="at%s">',$attr->getName());

@@ -193,10 +193,10 @@ switch($entry['view']) {
printf('(%s)',_('none'));

else {
- $href = htmlspecialchars(sprintf('%s&viewvalue=%s',$entry['href']['attributes'],strtolower($attr->getSupAttribute())));
+ $href = htmlspecialchars(sprintf('%s&viewvalue=%s',$entry['href']['attributes'],strtolower((string) $attr->getSupAttribute())));
if (isAjaxEnabled())
printf('<a href="cmd.php?%s" onclick="return ajSHOWSCHEMA(\'attributes\',\'at\',\'%s\');">%s</a>',
- $href,strtolower($attr->getSupAttribute()),$attr->getSupAttribute());
+ $href,strtolower((string) $attr->getSupAttribute()),$attr->getSupAttribute());
else
printf('<a href="cmd.php?%s">%s</a>',$href,$attr->getSupAttribute());
}
@@ -287,10 +287,10 @@ switch($entry['view']) {

else
foreach ($attr->getAliases() as $alias) {
- $href = htmlspecialchars(sprintf('%s&viewvalue=%s',$entry['href']['attributes'],strtolower($alias)));
+ $href = htmlspecialchars(sprintf('%s&viewvalue=%s',$entry['href']['attributes'],strtolower((string) $alias)));
if (isAjaxEnabled())
printf('<a href="cmd.php?%s" onclick="return ajSHOWSCHEMA(\'attributes\',\'at\',\'%s\');">%s</a>',
- $href,strtolower($alias),$alias);
+ $href,strtolower((string) $alias),$alias);
else
printf('<a href="cmd.php?%s">%s</a>',$href,$alias);
}
@@ -306,10 +306,10 @@ switch($entry['view']) {

else
foreach ($attr->getUsedInObjectClasses() as $objectclass) {
- $href = htmlspecialchars(sprintf('%s&viewvalue=%s',$entry['href']['objectclasses'],strtolower($objectclass)));
+ $href = htmlspecialchars(sprintf('%s&viewvalue=%s',$entry['href']['objectclasses'],strtolower((string) $objectclass)));
if (isAjaxEnabled())
printf('<a href="cmd.php?%s" onclick="return ajJUMP(\'%s\',\'%s\',\'%s\');">%s</a> ',
- $href,$href,_('ObjectClasses'),strtolower($objectclass),$objectclass);
+ $href,$href,_('ObjectClasses'),strtolower((string) $objectclass),$objectclass);
else
printf('<a href="cmd.php?%s">%s</a> ',$href,$objectclass);
}
@@ -379,8 +379,8 @@ switch($entry['view']) {
$oid = $rule->getOID();
$desc = $rule->getName(false);

- if (isAjaxEnabled() || (is_null($entry['value']) || ! trim($entry['value']) || $entry['value']==$rule->getName())) {
- if ((! is_null($entry['value']) && $entry['value']==$rule->getName()) || ! trim($entry['value']))
+ if (isAjaxEnabled() || (is_null($entry['value']) || ! trim((string) $entry['value']) || $entry['value']==$rule->getName())) {
+ if ((! is_null($entry['value']) && $entry['value']==$rule->getName()) || ! trim((string) $entry['value']))
$entry['viewed'] = true;

if (null != $rule->getDescription())
@@ -391,7 +391,7 @@ switch($entry['view']) {

if (isAjaxEnabled() && $entry['value'])
printf('<tr class="%s" id="mr%s" style="display: %s">',$counter%2 ? 'odd' : 'even',$rule->getName(),
- strcasecmp($entry['value'],$rule->getName()) ? 'none' : '');
+ strcasecmp((string) $entry['value'],(string) $rule->getName()) ? 'none' : '');
else
printf('<tr class="%s" id="mr%s">',$counter%2 ? 'odd' : 'even',$rule->getName());
printf('<td>%s</td>',$oid);
@@ -467,12 +467,12 @@ switch($entry['view']) {
echo '<br />';

foreach ($socs as $name => $oclass) {
- if (isAjaxEnabled() || (is_null($entry['value']) || ! trim($entry['value']) || $entry['value']==$oclass->getName())) {
- if ((! is_null($entry['value']) && $entry['value']==$oclass->getName()) || ! trim($entry['value']))
+ if (isAjaxEnabled() || (is_null($entry['value']) || ! trim((string) $entry['value']) || $entry['value']==$oclass->getName())) {
+ if ((! is_null($entry['value']) && $entry['value']==$oclass->getName()) || ! trim((string) $entry['value']))
$entry['viewed'] = true;

if (isAjaxEnabled() && $entry['value'])
- printf('<div id="oc%s" style="display: %s">',$oclass->getName(),strcasecmp($entry['value'],$oclass->getName()) ? 'none' : '');
+ printf('<div id="oc%s" style="display: %s">',(string) $oclass->getName(),strcasecmp((string) $entry['value'],(string) $oclass->getName()) ? 'none' : '');
else
printf('<div id="oc%s">',$oclass->getName());

@@ -494,10 +494,10 @@ switch($entry['view']) {

else
foreach ($oclass->getSupClasses() as $i => $object_class) {
- $href = htmlspecialchars(sprintf('%s&viewvalue=%s',$entry['href']['objectclasses'],strtolower($object_class)));
+ $href = htmlspecialchars(sprintf('%s&viewvalue=%s',$entry['href']['objectclasses'],strtolower((string) $object_class)));
if (isAjaxEnabled())
printf('<a href="cmd.php?%s" onclick="return ajSHOWSCHEMA(\'objectclasses\',\'oc\',\'%s\');">%s</a>',
- $href,strtolower($object_class),$object_class);
+ $href,strtolower((string) $object_class),$object_class);
else
printf('<a href="cmd.php?%s&viewvalue=%s" title="%s">%s</a>',
$href,$object_class,_('Jump to this objectClass definition'),$object_class);
@@ -508,7 +508,7 @@ switch($entry['view']) {
echo '</b></td></tr>';

printf('<tr class="odd"><td colspan="4">%s: <b>',_('Parent to'));
- if (strcasecmp($oclass->getName(),'top') == 0) {
+ if (strcasecmp((string) $oclass->getName(),'top') == 0) {
$href = htmlspecialchars($entry['href']['objectclasses']);
if (isAjaxEnabled())
printf('<a href="cmd.php?%s" onclick="return ajSHOWSCHEMA(\'objectclasses\',\'oc\',\'\');">all</a>',
@@ -521,10 +521,10 @@ switch($entry['view']) {

else
foreach ($oclass->getChildObjectClasses() as $i => $object_class) {
- $href = htmlspecialchars(sprintf('%s&viewvalue=%s',$entry['href']['objectclasses'],strtolower($object_class)));
+ $href = htmlspecialchars(sprintf('%s&viewvalue=%s',$entry['href']['objectclasses'],strtolower((string) $object_class)));
if (isAjaxEnabled())
printf('<a href="cmd.php?%s" title="%s" onclick="return ajSHOWSCHEMA(\'objectclasses\',\'oc\',\'%s\');">%s</a>',
- $href,_('Jump to this objectClass definition'),strtolower($object_class),$object_class);
+ $href,_('Jump to this objectClass definition'),strtolower((string) $object_class),$object_class);
else
printf('<a href="cmd.php?%s" title="%s">%s</a>',$href,_('Jump to this objectClass definition'),$object_class);

@@ -553,11 +553,11 @@ switch($entry['view']) {

if ($attr->getSource() != $oclass->getName(false)) {
echo '<br />';
- $href = htmlspecialchars(sprintf('%s&viewvalue=%s',$entry['href']['objectclasses'],strtolower($attr->getSource())));
+ $href = htmlspecialchars(sprintf('%s&viewvalue=%s',$entry['href']['objectclasses'],strtolower((string) $attr->getSource())));
printf('<small>(%s ',_('Inherited from'));
if (isAjaxEnabled())
printf('<a href="cmd.php?%s" title="%s" onclick="return ajSHOWSCHEMA(\'objectclasses\',\'oc\',\'%s\');">%s</a>',
- $href,_('Jump to this objectClass definition'),strtolower($attr->getSource()),$attr->getSource());
+ $href,_('Jump to this objectClass definition'),strtolower((string) $attr->getSource()),$attr->getSource());
else
printf('<a href="cmd.php?%s">%s</a>',$href,$attr->getSource());
echo ')</small>';
@@ -586,11 +586,11 @@ switch($entry['view']) {

if ($attr->getSource() != $oclass->getName(false)) {
echo '<br />';
- $href = htmlspecialchars(sprintf('%s&viewvalue=%s',$entry['href']['objectclasses'],strtolower($attr->getSource())));
+ $href = htmlspecialchars(sprintf('%s&viewvalue=%s',$entry['href']['objectclasses'],strtolower((string) $attr->getSource())));
printf('<small>(%s ',_('Inherited from'));
if (isAjaxEnabled())
printf('<a href="cmd.php?%s" title="%s" onclick="return ajSHOWSCHEMA(\'objectclasses\',\'oc\',\'%s\');">%s</a>',
- $href,_('Jump to this objectClass definition'),strtolower($attr->getSource()),$attr->getSource());
+ $href,_('Jump to this objectClass definition'),strtolower((string) $attr->getSource()),$attr->getSource());
else
printf('<a href="cmd.php?%s">%s</a>',$href,$attr->getSource());
echo ')</small>';
20 changes: 20 additions & 0 deletions net/phpldapadmin/files/patch-htdocs_server__info.php
@@ -0,0 +1,20 @@
--- htdocs/server_info.php.orig 2021-12-12 02:35:51 UTC
+++ htdocs/server_info.php
@@ -60,7 +60,7 @@ foreach ($attrs as $key => $values) {
printf('<td>%s</td>',$oidtext['title']);

else
- if (strlen($value) > 0)
+ if (strlen((string) $value) > 0)
printf('<td><small>%s</small></td>',$value);

} else {
@@ -69,7 +69,7 @@ foreach ($attrs as $key => $values) {

print '</tr>';

- if (isset($oidtext['desc']) && trim($oidtext['desc']))
+ if (isset($oidtext['desc']) && trim((string) $oidtext['desc']))
printf('<tr><td><small>%s</small></td></tr>',$oidtext['desc']);
else
echo '<tr><td>&nbsp;</td></tr>';
11 changes: 11 additions & 0 deletions net/phpldapadmin/files/patch-htdocs_view__jpeg__photo.php
@@ -0,0 +1,11 @@
--- htdocs/view_jpeg_photo.php.orig 2021-12-12 02:35:51 UTC
+++ htdocs/view_jpeg_photo.php
@@ -15,7 +15,7 @@ require './common.php';

$request = array();
$request['dn'] = get_request('dn','GET');
-$request['attr'] = strtolower(get_request('attr','GET',false,'jpegphoto'));
+$request['attr'] = strtolower((string) get_request('attr','GET',false,'jpegphoto'));
$request['index'] = get_request('index','GET',false,0);
$request['type'] = get_request('type','GET',false,'image/jpeg');
$request['filename'] = get_request('filename','GET',false,sprintf('%s.jpg',get_rdn($request['dn'],true)));

0 comments on commit fee2b33

Please sign in to comment.