Skip to content

Commit

Permalink
net/phpldapadmin: additional fix to support for php81+
Browse files Browse the repository at this point in the history
PR:	266678 268135 264672
Approved by: rene (mentor)
Differential Revision: https://reviews.freebsd.org/D37633
  • Loading branch information
Krzysztof authored and Ronald Klop committed Dec 12, 2022
1 parent ecdc544 commit 05adb0b
Show file tree
Hide file tree
Showing 9 changed files with 154 additions and 4 deletions.
2 changes: 1 addition & 1 deletion net/phpldapadmin/Makefile
@@ -1,6 +1,6 @@
PORTNAME= phpldapadmin
PORTVERSION= 1.2.6.3
PORTREVISION= 2
PORTREVISION= 3
CATEGORIES= net www
PKGNAMESUFFIX= ${PHP_PKGNAMESUFFIX}

Expand Down
7 changes: 6 additions & 1 deletion net/phpldapadmin/files/patch-lib_AttributeFactory.php
Expand Up @@ -39,7 +39,7 @@
return $this->newShadowAttribute($name,$values,$server_id,$source);

} elseif ($app['server']->isAttrBoolean($name)) {
@@ -129,7 +129,7 @@ class AttributeFactory {
@@ -129,11 +129,11 @@ class AttributeFactory {
} elseif ($app['server']->isMultiLineAttr($name)) {
return $this->newMultiLineAttribute($name,$values,$server_id,$source);

Expand All @@ -48,3 +48,8 @@
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);
}
}

29 changes: 29 additions & 0 deletions net/phpldapadmin/files/patch-lib_PageRender.php
Expand Up @@ -59,6 +59,35 @@
return sprintf('<acronym title="%s: \'%s\' %s \'%s\'">%s</acronym>',
_('Note'),$friendly_name,_('is an alias for'),$attribute->getName(false),_('alias'));
else
@@ -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) {
@@ -954,7 +954,7 @@ class PageRender extends Visitor {
$server = $this->getServer();
$val = $attribute->getValue($i);
Expand Down
9 changes: 9 additions & 0 deletions net/phpldapadmin/files/patch-lib_Tree.php
@@ -1,5 +1,14 @@
--- 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;
@@ -132,7 +132,7 @@ abstract class Tree {
if (DEBUG_ENABLED && (($fargs=func_get_args())||$fargs='NOARGS'))
debug_log('Entered (%%)',33,0,__FILE__,__LINE__,__METHOD__,$fargs);
Expand Down
11 changes: 11 additions & 0 deletions net/phpldapadmin/files/patch-lib_common.php
Expand Up @@ -12,3 +12,14 @@
}

$app['lang_http'] = array_unique($app['lang_http']);
@@ -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);
35 changes: 33 additions & 2 deletions net/phpldapadmin/files/patch-lib_ds__ldap.php
Expand Up @@ -182,7 +182,7 @@ private function fillDNTemplate($user) {
continue;

$object_class = new ObjectClass($line,$this);
@@ -1762,8 +1765,8 @@ class ldap extends DS {
@@ -1762,13 +1765,13 @@ class ldap extends DS {
# Now go through and reference the parent/child relationships
foreach ($return as $oclass)
foreach ($oclass->getSupClasses() as $parent_name)
Expand All @@ -193,6 +193,12 @@ private function fillDNTemplate($user) {

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)
@@ -1816,7 +1819,7 @@ class ldap extends DS {
*/
$attrs_oid = array();
Expand Down Expand Up @@ -241,7 +247,7 @@ private function fillDNTemplate($user) {

/* Since this attribute's superior attribute does not have another superior
* attribute, clone its properties for this attribute. Then, replace
@@ -1936,18 +1939,18 @@ class ldap extends DS {
@@ -1936,24 +1939,24 @@ class ldap extends DS {

# Add Used In.
foreach ($oclass_attrs as $attr_name)
Expand All @@ -266,6 +272,13 @@ private function fillDNTemplate($user) {
}

$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)
@@ -1987,7 +1990,7 @@ class ldap extends DS {
$rules = array();

Expand Down Expand Up @@ -293,6 +306,15 @@ private function fillDNTemplate($user) {

if (isset($rules[$rule_key]))
$rules[$rule_key]->addUsedByAttr($attr->getName(false));
@@ -2029,7 +2032,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)
@@ -2063,11 +2066,11 @@ class ldap extends DS {
$return = array();

Expand All @@ -307,6 +329,15 @@ private function fillDNTemplate($user) {

if (! $key)
continue;
@@ -2078,7 +2081,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)
@@ -2097,7 +2100,7 @@ class ldap extends DS {
if (DEBUG_ENABLED && (($fargs=func_get_args())||$fargs='NOARGS'))
debug_log('Entered (%%)',17,0,__FILE__,__LINE__,__METHOD__,$fargs);
Expand Down
27 changes: 27 additions & 0 deletions net/phpldapadmin/files/patch-lib_ds__ldap__pla.php
Expand Up @@ -29,6 +29,33 @@ private function isAttrTest($attr,$attrs,$except_dn) {
return true;

return false;
@@ -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));
}
@@ -674,7 +674,7 @@ class ldap_pla extends ldap {
if ($this->getValue('appearance', 'show_authz') && function_exists('ldap_exop_whoami')) {
$result = @ldap_exop_whoami($this->connect($method));
Expand Down
29 changes: 29 additions & 0 deletions net/phpldapadmin/files/patch-lib_functions.php
Expand Up @@ -113,6 +113,15 @@

if ($length > 0) { // str_repeat doesn't like negatives
if ($pad_type == STR_PAD_RIGHT) { // STR_PAD_RIGHT == 1
@@ -928,7 +929,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);

@@ -1090,7 +1091,7 @@ function masort(&$data,$sortby,$rev=0) {
$code .= " \$a = array_change_key_case(\$a);\n";
$code .= " \$b = array_change_key_case(\$b);\n";
Expand Down Expand Up @@ -254,6 +263,26 @@
}
}
}
@@ -2032,8 +2033,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 +2047,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);

@@ -2164,7 +2165,7 @@ function pla_password_hash($password_clear,$enc_type)
if (DEBUG_ENABLED && (($fargs=func_get_args())||$fargs='NOARGS'))
debug_log('Entered (%%)',1,0,__FILE__,__LINE__,__METHOD__,$fargs);
Expand Down
9 changes: 9 additions & 0 deletions net/phpldapadmin/files/patch-lib_xmlTemplates.php
Expand Up @@ -18,6 +18,15 @@
$this->templates[$counter] = new $class['name']($this->server_id,$templatename,$filename,$type,$counter);
$counter++;
}
@@ -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');
}
}

@@ -304,7 +304,7 @@ abstract class xmlTemplate {
debug_log('Entered (%%)',5,0,__FILE__,__LINE__,__METHOD__,$fargs);

Expand Down

0 comments on commit 05adb0b

Please sign in to comment.