1
0
mirror of https://git.FreeBSD.org/ports.git synced 2025-01-20 08:27:15 +00:00

net/phpldapadmin: Fix runtime with php80

- Pet portclippy/portfmt

PR:		261990
Reported by:	ohartmann@walstatt.org
Approved by:	ports@bsdserwis.com (maintainer)
Sponsored by:	Bounce Experts
This commit is contained in:
Muhammad Moinur Rahman 2022-03-06 22:40:55 -06:00
parent 31ff8eccc3
commit a9c2430bd9
25 changed files with 374 additions and 3 deletions

View File

@ -2,6 +2,7 @@
PORTNAME= phpldapadmin
PORTVERSION= 1.2.6.3
PORTREVISION= 1
CATEGORIES= net www
PKGNAMESUFFIX= ${PHP_PKGNAMESUFFIX}
@ -44,14 +45,17 @@ SUB_FILES+= pkg-message
post-patch:
cd ${WRKSRC} ; \
cp lib/Attribute.php lib/PLAAttribute.php; \
${FIND} . ! -type d ! -name ${CFGFILE}.example ! -name .cvsignore \
! -name .gitignore ! -name *.orig | ${SORT} | \
! -name .gitignore ! -name *.orig \
! -name Attribute.php | ${SORT} | \
${SED} -e "s!^\.!${WWWDIR_REL}!" >${PLIST} ;
do-install:
cd ${WRKSRC} ; \
for src in $$( ${FIND} . ! -name .cvsignore \
! -name .gitignore ! -name *.orig ) ; do \
! -name .gitignore ! -name *.orig \
! -name Attribute.php) ; do \
dst=${STAGEDIR}${WWWDIR}$${src#.} ; \
if ${TEST} -d $$src ; then \
${MKDIR} $$dst ; \

View File

@ -0,0 +1,11 @@
--- htdocs/collapse.php.orig 2021-12-12 02:35:51 UTC
+++ htdocs/collapse.php
@@ -19,7 +19,7 @@ $dn = get_request('dn','GET',true);
$tree = get_cached_item($app['server']->getIndex(),'tree');
$entry = $tree->getEntry($dn);
$entry->close();
-set_cached_item($app['server']->getIndex(),'tree','null',$tree);
+set_cached_item($app['server']->getIndex(),$tree,'tree','null');
header(sprintf('Location:index.php?server_id=%s&junk=%s#%s%s',
$app['server']->getIndex(),random_junk(),htmlid($app['server']->getIndex(),$dn),app_session_param()));

View File

@ -0,0 +1,11 @@
--- htdocs/draw_tree_node.php.orig 2021-12-12 02:35:51 UTC
+++ htdocs/draw_tree_node.php
@@ -50,7 +50,7 @@ if ($request['dn']) {
}
if ($treesave)
- set_cached_item($app['server']->getIndex(),'tree','null',$tree);
+ set_cached_item($app['server']->getIndex(),$tree,'tree','null');
if ($request['dn'])
echo $tree->draw_children($dnentry,$request['code']);

View File

@ -0,0 +1,11 @@
--- htdocs/expand.php.orig 2021-12-12 02:35:51 UTC
+++ htdocs/expand.php
@@ -19,7 +19,7 @@ $dn = get_request('dn','GET',true);
$tree = get_cached_item($app['server']->getIndex(),'tree');
$entry = $tree->getEntry($dn);
$entry->open();
-set_cached_item($app['server']->getIndex(),'tree','null',$tree);
+set_cached_item($app['server']->getIndex(),$tree,'tree','null');
header(sprintf('Location:index.php?server_id=%s&junk=%s#%s%s',
$app['server']->getIndex(),random_junk(),htmlid($app['server']->getIndex(),$dn),app_session_param()));

View File

@ -0,0 +1,11 @@
--- htdocs/refresh.php.orig 2021-12-12 02:35:51 UTC
+++ htdocs/refresh.php
@@ -34,7 +34,7 @@ if (get_request('purge','REQUEST')) {
$entry->open();
}
- set_cached_item($app['server']->getIndex(),'tree','null',$tree);
+ set_cached_item($app['server']->getIndex(),$tree,'tree','null');
}
if (get_request('meth','REQUEST') == 'ajax')

View File

@ -0,0 +1,11 @@
--- lib/Attribute.php.orig 2021-12-12 02:35:51 UTC
+++ lib/Attribute.php
@@ -12,7 +12,7 @@
* @package phpLDAPadmin
* @subpackage Templates
*/
-class Attribute {
+class PLAAttribute {
# Attribute Name
public $name;
# Source of this attribute definition

View File

@ -0,0 +1,11 @@
--- lib/AttributeFactory.php.orig 2021-12-12 02:35:51 UTC
+++ lib/AttributeFactory.php
@@ -133,7 +133,7 @@ class AttributeFactory {
return $this->newGidAttribute($name,$values,$server_id,$source);
} else {
- return new Attribute($name,$values,$server_id,$source);
+ return new PLAAttribute($name,$values,$server_id,$source);
}
}

View File

@ -0,0 +1,11 @@
--- lib/BinaryAttribute.php.orig 2021-12-12 02:35:51 UTC
+++ lib/BinaryAttribute.php
@@ -12,7 +12,7 @@
* @package phpLDAPadmin
* @subpackage Templates
*/
-class BinaryAttribute extends Attribute {
+class BinaryAttribute extends PLAAttribute {
protected $filepaths;
protected $filenames;

View File

@ -0,0 +1,10 @@
--- lib/DateAttribute.php.orig 2021-12-12 02:35:51 UTC
+++ lib/DateAttribute.php
@@ -12,6 +12,6 @@
* @package phpLDAPadmin
* @subpackage Templates
*/
-class DateAttribute extends Attribute {
+class DateAttribute extends PLAAttribute {
}
?>

View File

@ -0,0 +1,10 @@
--- lib/DnAttribute.php.orig 2021-12-12 02:35:51 UTC
+++ lib/DnAttribute.php
@@ -12,6 +12,6 @@
* @package phpLDAPadmin
* @subpackage Templates
*/
-class DnAttribute extends Attribute {
+class DnAttribute extends PLAAttribute {
}
?>

View File

@ -0,0 +1,10 @@
--- lib/GidAttribute.php.orig 2021-12-12 02:35:51 UTC
+++ lib/GidAttribute.php
@@ -12,6 +12,6 @@
* @package phpLDAPadmin
* @subpackage Templates
*/
-class GidAttribute extends Attribute {
+class GidAttribute extends PLAAttribute {
}
?>

View File

@ -0,0 +1,11 @@
--- lib/MultiLineAttribute.php.orig 2021-12-12 02:35:51 UTC
+++ lib/MultiLineAttribute.php
@@ -12,7 +12,7 @@
* @package phpLDAPadmin
* @subpackage Templates
*/
-class MultiLineAttribute extends Attribute {
+class MultiLineAttribute extends PLAAttribute {
protected $rows = 0;
protected $cols = 0;

View File

@ -0,0 +1,10 @@
--- lib/ObjectClassAttribute.php.orig 2021-12-12 02:35:51 UTC
+++ lib/ObjectClassAttribute.php
@@ -12,6 +12,6 @@
* @package phpLDAPadmin
* @subpackage Templates
*/
-class ObjectClassAttribute extends Attribute {
+class ObjectClassAttribute extends PLAAttribute {
}
?>

View File

@ -0,0 +1,31 @@
--- lib/PageRender.php.orig 2021-12-12 02:35:51 UTC
+++ lib/PageRender.php
@@ -827,7 +827,7 @@ class PageRender extends Visitor {
if (! $attribute->getOldValue($i))
return;
- draw_jpeg_photo($this->getServer(),$this->template->getDN(),$attribute->getName(),$i,false,false);
+ draw_jpeg_photo($this->getServer(),$this->template->getDN(),$i,$attribute->getName(),false,false);
}
/**
@@ -844,16 +844,16 @@ class PageRender extends Visitor {
# If the attribute is modified, the new value needs to be stored in a session variable for the draw_jpeg_photo callback.
if ($attribute->hasBeenModified()) {
$_SESSION['tmp'][$attribute->getName()][$i] = $attribute->getValue($i);
- draw_jpeg_photo(null,$this->template->getDN(),$attribute->getName(),$i,false,false);
+ draw_jpeg_photo(null,$this->template->getDN(),$i,$attribute->getName(),false,false);
} else
- draw_jpeg_photo($this->getServer(),$this->template->getDN(),$attribute->getName(),$i,false,false);
+ draw_jpeg_photo($this->getServer(),$this->template->getDN(),$i,$attribute->getName(),false,false);
}
protected function drawFormReadOnlyValueJpegAttribute($attribute,$i) {
$this->draw('HiddenValue',$attribute,$i);
$_SESSION['tmp'][$attribute->getName()][$i] = $attribute->getValue($i);
- draw_jpeg_photo(null,$this->template->getDN(),$attribute->getName(),$i,false,false);
+ draw_jpeg_photo(null,$this->template->getDN(),$i,$attribute->getName(),false,false);
}
protected function drawFormReadOnlyValueMultiLineAttribute($attribute,$i) {

View File

@ -0,0 +1,10 @@
--- lib/PasswordAttribute.php.orig 2021-12-12 02:35:51 UTC
+++ lib/PasswordAttribute.php
@@ -12,6 +12,6 @@
* @package phpLDAPadmin
* @subpackage Templates
*/
-class PasswordAttribute extends Attribute {
+class PasswordAttribute extends PLAAttribute {
}
?>

View File

@ -0,0 +1,11 @@
--- lib/SelectionAttribute.php.orig 2021-12-12 02:35:51 UTC
+++ lib/SelectionAttribute.php
@@ -12,7 +12,7 @@
* @package phpLDAPadmin
* @subpackage Templates
*/
-class SelectionAttribute extends Attribute {
+class SelectionAttribute extends PLAAttribute {
protected $selection = array();
protected $multiple;
protected $default;

View File

@ -0,0 +1,11 @@
--- lib/ShadowAttribute.php.orig 2021-12-12 02:35:51 UTC
+++ lib/ShadowAttribute.php
@@ -12,7 +12,7 @@
* @package phpLDAPadmin
* @subpackage Templates
*/
-class ShadowAttribute extends Attribute {
+class ShadowAttribute extends PLAAttribute {
public $shadow_before_today_attrs = array('shadowLastChange','shadowMin');
public $shadow_after_today_attrs = array('shadowMax','shadowExpire','shadowWarning','shadowInactive');
}

View File

@ -0,0 +1,11 @@
--- lib/Tree.php.orig 2021-12-12 02:35:51 UTC
+++ lib/Tree.php
@@ -68,7 +68,7 @@ abstract class Tree {
}
}
- set_cached_item($server_id,'tree','null',$tree);
+ set_cached_item($server_id,$tree,'tree','null');
}
return $tree;

View File

@ -0,0 +1,43 @@
--- lib/Visitor.php.orig 2021-12-12 02:35:51 UTC
+++ lib/Visitor.php
@@ -22,6 +22,15 @@ abstract class Visitor {
protected $server_id;
public function __call($method,$args) {
+ # This mapping array allows to map effective class names to
+ # function name suffixes.
+ # It has been introduced when class Attribute has been renamed
+ # to PLAAttribute to avoid a name clash with the built-in
+ # class of PHP 8.
+ # Entering a class name mapping here allows to rename the
+ # class without having to rename the methods too.
+ static $classmap = array('PLAAttribute' => 'Attribute');
+
if (DEBUG_ENABLED && (($fargs=func_get_args())||$fargs='NOARGS'))
debug_log('Entered (%%)',129,0,__FILE__,__LINE__,__METHOD__,$fargs);
@@ -33,19 +42,14 @@ abstract class Visitor {
$fnct = array_shift($args);
$object = $args[0];
- $class = get_class($object);
- $call = "$method$fnct$class";
-
- array_push($methods,$call);
-
- while ($class && ! method_exists($this,$call)) {
+ for ($class = get_class($object); $class; $class = get_parent_class($class)) {
+ $call = isset($classmap[$class])? "$method$fnct$classmap[$class]": "$method$fnct$class";
+ array_push($methods,$call);
+ if (method_exists($this,$call))
+ break;
if (defined('DEBUGTMP') && DEBUGTMP)
printf('<font size=-2><i>Class (%s): Method doesnt exist (%s,%s)</i></font><br />',$class,get_class($this),$call);
-
- $class = get_parent_class($class);
- $call = "$method$fnct$class";
- array_push($methods,$call);
}
if (defined('DEBUGTMP') && DEBUGTMP)

View File

@ -0,0 +1,13 @@
--- lib/common.php.orig 2021-12-12 02:35:51 UTC
+++ lib/common.php
@@ -296,7 +296,9 @@ if ($app['language'] == 'auto') {
* Strip slashes from GET, POST, and COOKIE variables if this
* PHP install is configured to automatically addslashes()
*/
-if (@get_magic_quotes_gpc() && (! isset($slashes_stripped) || ! $slashes_stripped)) {
+if (@version_compare(phpversion(), '5.4.0', '<') &&
+ @get_magic_quotes_gpc() &&
+ (!isset($slashes_stripped) || !$slashes_stripped)) {
array_stripslashes($_REQUEST);
array_stripslashes($_GET);
array_stripslashes($_POST);

View File

@ -0,0 +1,38 @@
--- lib/ds_ldap.php.orig 2021-12-12 02:35:51 UTC
+++ lib/ds_ldap.php
@@ -1768,7 +1768,7 @@ class ldap extends DS {
ksort($return);
# cache the schema to prevent multiple schema fetches from LDAP server
- set_cached_item($this->index,'schema','objectclasses',$return);
+ set_cached_item($this->index,$return,'schema','objectclasses');
}
if (DEBUG_ENABLED)
@@ -1953,7 +1953,7 @@ class ldap extends DS {
$return = $attrs;
# cache the schema to prevent multiple schema fetches from LDAP server
- set_cached_item($this->index,'schema','attributes',$return);
+ set_cached_item($this->index,$return,'schema','attributes');
}
if (DEBUG_ENABLED)
@@ -2029,7 +2029,7 @@ class ldap extends DS {
$return = $rules;
# cache the schema to prevent multiple schema fetches from LDAP server
- set_cached_item($this->index,'schema','matchingrules',$return);
+ set_cached_item($this->index,$return,'schema','matchingrules');
}
if (DEBUG_ENABLED)
@@ -2078,7 +2078,7 @@ class ldap extends DS {
ksort($return);
# cache the schema to prevent multiple schema fetches from LDAP server
- set_cached_item($this->index,'schema','syntaxes',$return);
+ set_cached_item($this->index,$return,'schema','syntaxes');
}
if (DEBUG_ENABLED)

View File

@ -0,0 +1,29 @@
--- lib/ds_ldap_pla.php.orig 2021-12-12 02:35:51 UTC
+++ lib/ds_ldap_pla.php
@@ -371,7 +371,7 @@ class ldap_pla extends ldap {
$tree->addEntry($dn);
- set_cached_item($this->index,'tree','null',$tree);
+ set_cached_item($this->index,$tree,'tree','null');
run_hook('post_entry_create',array('server_id'=>$this->index,'method'=>$method,'dn'=>$dn,'attrs'=>$entry_array));
@@ -403,7 +403,7 @@ class ldap_pla extends ldap {
$tree = get_cached_item($this->index,'tree');
$tree->delEntry($dn);
- set_cached_item($this->index,'tree','null',$tree);
+ set_cached_item($this->index,$tree,'tree','null');
run_hook('post_entry_delete',array('server_id'=>$this->index,'method'=>$method,'dn'=>$dn));
}
@@ -430,7 +430,7 @@ class ldap_pla extends ldap {
$newdn = sprintf('%s,%s',$new_rdn,$container);
$tree->renameEntry($dn,$newdn);
- set_cached_item($this->index,'tree','null',$tree);
+ set_cached_item($this->index,$tree,'tree','null');
run_hook('post_entry_rename',array('server_id'=>$this->index,'method'=>$method,'dn'=>$dn,'rdn'=>$new_rdn,'container'=>$container));
}

View File

@ -0,0 +1,31 @@
--- lib/functions.php.orig 2021-12-12 02:35:51 UTC
+++ lib/functions.php
@@ -928,7 +928,7 @@ function get_cached_item($index,$item,$subitem='null')
*
* Returns true on success of false on failure.
*/
-function set_cached_item($index,$item,$subitem='null',$data) {
+function set_cached_item($index,$data,$item,$subitem='null') {
if (DEBUG_ENABLED && (($fargs=func_get_args())||$fargs='NOARGS'))
debug_log('Entered (%%)',1,0,__FILE__,__LINE__,__METHOD__,$fargs);
@@ -2032,8 +2032,8 @@ function ldap_error_msg($msg,$errnum) {
*
* Usage Examples:
* <code>
- * draw_jpeg_photo(0,'cn=Bob,ou=People,dc=example,dc=com',"jpegPhoto",0,true,array('img_opts'=>"border: 1px; width: 150px"));
- * draw_jpeg_photo(1,'cn=Fred,ou=People,dc=example,dc=com',null,1);
+ * draw_jpeg_photo(0,'cn=Bob,ou=People,dc=example,dc=com',0,"jpegPhoto",true,array('img_opts'=>"border: 1px; width: 150px"));
+ * draw_jpeg_photo(1,'cn=Fred,ou=People,dc=example,dc=com',1,null);
* </code>
*
* @param object The Server to get the image from.
@@ -2046,7 +2046,7 @@ function ldap_error_msg($msg,$errnum) {
* @param array Specifies optional image and CSS style attributes for the table tag. Supported keys are
* fixed_width, fixed_height, img_opts.
*/
-function draw_jpeg_photo($server,$dn,$attr_name='jpegphoto',$index,$draw_delete_buttons=false,$options=array()) {
+function draw_jpeg_photo($server,$dn,$index,$attr_name='jpegphoto',$draw_delete_buttons=false,$options=array()) {
if (DEBUG_ENABLED && (($fargs=func_get_args())||$fargs='NOARGS'))
debug_log('Entered (%%)',1,0,__FILE__,__LINE__,__METHOD__,$fargs);

View File

@ -0,0 +1,11 @@
--- lib/xmlTemplates.php.orig 2021-12-12 02:35:51 UTC
+++ lib/xmlTemplates.php
@@ -140,7 +140,7 @@ abstract class xmlTemplates {
if ($changed) {
masort($this->templates,'title');
- set_cached_item($server_id,$class['item'],'null',$this->templates);
+ set_cached_item($server_id,$this->templates,$class['item'],'null');
}
}

View File

@ -1,4 +1,4 @@
--- tools/po/Makefile.orig 2012-10-01 06:54:14 UTC
--- tools/po/Makefile.orig 2021-12-12 02:35:51 UTC
+++ tools/po/Makefile
@@ -1,4 +1,3 @@
-#!/bin/bash