diff --git a/htdocs/cmd.php b/htdocs/cmd.php index 39b5dbe..dabdb23 100644 --- a/htdocs/cmd.php +++ b/htdocs/cmd.php @@ -39,7 +39,7 @@ switch ($www['cmd']) { } if (DEBUG_ENABLED) - debug_log('Ready to render page for command [%s,%s].',128,__FILE__,__LINE__,__METHOD__,$www['cmd'],$app['script_cmd']); + debug_log('Ready to render page for command [%s,%s].',128,0,__FILE__,__LINE__,__METHOD__,$www['cmd'],$app['script_cmd']); # Create page. # Set the index so that we render the right server tree. diff --git a/htdocs/copy.php b/htdocs/copy.php index 2769908..7b21c8b 100644 --- a/htdocs/copy.php +++ b/htdocs/copy.php @@ -89,9 +89,8 @@ if ($copy_result) { } function r_copy_dn($serverSRC,$serverDST,$snapshottree,$dnSRC,$dnDST,$remove) { - if (DEBUG_ENABLED) - debug_log('Entered with (%s,%s,%s,%s,%s)',1,__FILE__,__LINE__,__METHOD__, - $serverSRC->getIndex(),$serverDST->getIndex(),$snapshottree,$dnSRC,$dnDST); + if (DEBUG_ENABLED && (($fargs=func_get_args())||$fargs='NOARGS')) + debug_log('Entered (%%)',1,0,__FILE__,__LINE__,__METHOD__,$fargs); $copy_message = array(); @@ -141,9 +140,8 @@ function r_copy_dn($serverSRC,$serverDST,$snapshottree,$dnSRC,$dnDST,$remove) { } function copy_dn($serverSRC,$serverDST,$dnSRC,$dnDST,$remove) { - if (DEBUG_ENABLED) - debug_log('Entered with (%s,%s,%s,%s)',17,__FILE__,__LINE__,__METHOD__, - $serverSRC->getIndex(),$serverDST->getIndex(),$dnSRC,$dnDST); + if (DEBUG_ENABLED && (($fargs=func_get_args())||$fargs='NOARGS')) + debug_log('Entered (%%)',1,0,__FILE__,__LINE__,__METHOD__,$fargs); $request = array(); $request['pageSRC'] = new PageRender($serverSRC->getIndex(),get_request('template','REQUEST',false,'none')); @@ -166,9 +164,8 @@ function copy_dn($serverSRC,$serverDST,$dnSRC,$dnDST,$remove) { } function build_tree($server,$dn,$buildtree) { - if (DEBUG_ENABLED) - debug_log('Entered with (%s,%s,%s)',1,__FILE__,__LINE__,__METHOD__, - $server->getIndex(),$dn,$buildtree); + if (DEBUG_ENABLED && (($fargs=func_get_args())||$fargs='NOARGS')) + debug_log('Entered (%%)',1,0,__FILE__,__LINE__,__METHOD__,$fargs); # We search all children, not only the visible children in the tree $children = $server->getContainerContents($dn,null,0); @@ -180,7 +177,7 @@ function build_tree($server,$dn,$buildtree) { } if (DEBUG_ENABLED) - debug_log('Returning (%s)',1,__FILE__,__LINE__,__METHOD__,$buildtree); + debug_log('Returning (%s)',1,0,__FILE__,__LINE__,__METHOD__,$buildtree); return $buildtree; } diff --git a/htdocs/entry_chooser.php b/htdocs/entry_chooser.php index 1eecdaf..573e199 100644 --- a/htdocs/entry_chooser.php +++ b/htdocs/entry_chooser.php @@ -45,7 +45,7 @@ if (isset($app['server']) && ! is_null($request['container'])) { foreach ($app['server']->getBaseDN() as $base) { if (DEBUG_ENABLED) - debug_log('Comparing BaseDN [%s] with container [%s]',64,__FILE__,__LINE__,__METHOD__,$base,$request['container']); + debug_log('Comparing BaseDN [%s] with container [%s]',64,0,__FILE__,__LINE__,__METHOD__,$base,$request['container']); if (! pla_compare_dns($request['container'],$base)) { $parent_container = false; diff --git a/htdocs/export_form.php b/htdocs/export_form.php index 4db878b..49d7fbf 100755 --- a/htdocs/export_form.php +++ b/htdocs/export_form.php @@ -165,14 +165,9 @@ function get_line_end_format() { */ function get_user_agent_string() { if (isset($_SERVER['HTTP_USER_AGENT'])) - $return = strtolower($_SERVER['HTTP_USER_AGENT']); + return strtolower($_SERVER['HTTP_USER_AGENT']); else - $return = ''; - - if (DEBUG_ENABLED) - debug_log('Entered with (), Returning (%s)',1,__FILE__,__LINE__,__METHOD__,$return); - - return $return; + return ''; } /** diff --git a/lib/AJAXTree.php b/lib/AJAXTree.php index 1bc9f14..e94d869 100644 --- a/lib/AJAXTree.php +++ b/lib/AJAXTree.php @@ -25,8 +25,8 @@ class AJAXTree extends HTMLTree { * @param boolean $last_child is the last child entry, which is normally the "Create New Entry" option */ protected function draw_item($item,$level,$first_child=true,$last_child=true) { - if (DEBUG_ENABLED) - debug_log('Entered with (%s,%s,%s,%s)',33,__FILE__,__LINE__,__METHOD__,$item,$level,$first_child,$last_child); + if (DEBUG_ENABLED && (($fargs=func_get_args())||$fargs='NOARGS')) + debug_log('Entered (%%)',33,0,__FILE__,__LINE__,__METHOD__,$fargs); $server = $this->getServer(); @@ -145,8 +145,8 @@ class AJAXTree extends HTMLTree { * Expand and draw a child entry, when it is clicked on. This is using AJAX just to render this section of the tree. */ public function draw_children($parent_entry,$code) { - if (DEBUG_ENABLED) - debug_log('Entered with (%s,%s)',33,__FILE__,__LINE__,__METHOD__,$parent_entry,$code); + if (DEBUG_ENABLED && (($fargs=func_get_args())||$fargs='NOARGS')) + debug_log('Entered (%%)',33,0,__FILE__,__LINE__,__METHOD__,$fargs); $children = array(); foreach ($parent_entry->getChildren() as $child) { @@ -192,6 +192,9 @@ class AJAXTree extends HTMLTree { * @param $code a string of 0 and 1 ; $code == "000101" will return " | |" */ protected function get_indentation($code) { + if (DEBUG_ENABLED && (($fargs=func_get_args())||$fargs='NOARGS')) + debug_log('Entered (%%)',33,0,__FILE__,__LINE__,__METHOD__,$fargs); + $indent = ''; for ($i=0; $i',JSDIR); printf('',JSDIR); } @@ -221,6 +227,9 @@ class AJAXTree extends HTMLTree { * Draw the "Create New Entry" item before the children. */ private function create_before_child($entry,$level) { + if (DEBUG_ENABLED && (($fargs=func_get_args())||$fargs='NOARGS')) + debug_log('Entered (%%)',33,0,__FILE__,__LINE__,__METHOD__,$fargs); + if (strlen($level) == 0) return ''; @@ -238,6 +247,9 @@ class AJAXTree extends HTMLTree { * Draw the "Create New Entry" item after the children. */ private function create_after_child($entry,$level) { + if (DEBUG_ENABLED && (($fargs=func_get_args())||$fargs='NOARGS')) + debug_log('Entered (%%)',33,0,__FILE__,__LINE__,__METHOD__,$fargs); + if (strlen($level) == 0) return ''; @@ -254,6 +266,9 @@ class AJAXTree extends HTMLTree { * Draw the "Create New Entry" item. */ private function draw_create_new_entry($entry,$level,$img) { + if (DEBUG_ENABLED && (($fargs=func_get_args())||$fargs='NOARGS')) + debug_log('Entered (%%)',33,0,__FILE__,__LINE__,__METHOD__,$fargs); + $output = ''; $href = sprintf('cmd=template_engine&server_id=%s&container=%s',$this->getServerID(),rawurlencode($entry->getDN())); @@ -284,6 +299,9 @@ class AJAXTree extends HTMLTree { * @return array List of open nodes */ public function listOpenItems() { + if (DEBUG_ENABLED && (($fargs=func_get_args())||$fargs='NOARGS')) + debug_log('Entered (%%)',33,0,__FILE__,__LINE__,__METHOD__,$fargs); + $result = array(); foreach ($this->entries as $dn => $value) diff --git a/lib/Attribute.php b/lib/Attribute.php index 292087d..d3fb103 100644 --- a/lib/Attribute.php +++ b/lib/Attribute.php @@ -81,6 +81,9 @@ class Attribute { protected $postvalue = array(); public function __construct($name,$values,$server_id,$source=null) { + if (DEBUG_ENABLED && (($fargs=func_get_args())||$fargs='NOARGS')) + debug_log('Entered (%%)',5,0,__FILE__,__LINE__,__METHOD__,$fargs); + $server = $_SESSION[APPCONFIG]->getServer($server_id); $sattr = $server->getSchemaAttribute($name); @@ -128,6 +131,9 @@ class Attribute { * @return string Attribute name */ public function getName($lower=true,$real=false) { + if (DEBUG_ENABLED && (($fargs=func_get_args())||$fargs='NOARGS')) + debug_log('Entered (%%)',5,0,__FILE__,__LINE__,__METHOD__,$fargs,$this->name); + if ($real) return $lower ? strtolower($this->name) : $this->name; else @@ -135,18 +141,30 @@ class Attribute { } public function getValues() { + if (DEBUG_ENABLED && (($fargs=func_get_args())||$fargs='NOARGS')) + debug_log('Entered (%%)',5,1,__FILE__,__LINE__,__METHOD__,$fargs,$this->values); + return $this->values; } public function getOldValues() { + if (DEBUG_ENABLED && (($fargs=func_get_args())||$fargs='NOARGS')) + debug_log('Entered (%%)',5,1,__FILE__,__LINE__,__METHOD__,$fargs,$this->oldvalues); + return $this->oldvalues; } public function getValueCount() { + if (DEBUG_ENABLED && (($fargs=func_get_args())||$fargs='NOARGS')) + debug_log('Entered (%%)',5,0,__FILE__,__LINE__,__METHOD__,$fargs,$this->values); + return count($this->values); } public function getSource() { + if (DEBUG_ENABLED && (($fargs=func_get_args())||$fargs='NOARGS')) + debug_log('Entered (%%)',5,1,__FILE__,__LINE__,__METHOD__,$fargs,$this->source); + return $this->source; } @@ -154,6 +172,9 @@ class Attribute { * Autovalue is called after the attribute is initialised, and thus the values from the ldap server will be set. */ public function autoValue($new_val) { + if (DEBUG_ENABLED && (($fargs=func_get_args())||$fargs='NOARGS')) + debug_log('Entered (%%)',5,0,__FILE__,__LINE__,__METHOD__,$fargs); + if ($this->values) return; @@ -161,6 +182,9 @@ class Attribute { } public function initValue($new_val) { + if (DEBUG_ENABLED && (($fargs=func_get_args())||$fargs='NOARGS')) + debug_log('Entered (%%)',5,0,__FILE__,__LINE__,__METHOD__,$fargs); + if ($this->values || $this->oldvalues) { debug_dump(array('new_val'=>$new_val,'this'=>$this)); debug_dump_backtrace('new and/or old values are set',1); @@ -170,14 +194,23 @@ class Attribute { } public function clearValue() { + if (DEBUG_ENABLED && (($fargs=func_get_args())||$fargs='NOARGS')) + debug_log('Entered (%%)',5,0,__FILE__,__LINE__,__METHOD__,$fargs); + $this->values = array(); } public function setOldValue($val) { + if (DEBUG_ENABLED && (($fargs=func_get_args())||$fargs='NOARGS')) + debug_log('Entered (%%)',5,1,__FILE__,__LINE__,__METHOD__,$fargs); + $this->oldvalues = $val; } public function setValue($new_val) { + if (DEBUG_ENABLED && (($fargs=func_get_args())||$fargs='NOARGS')) + debug_log('Entered (%%)',5,0,__FILE__,__LINE__,__METHOD__,$fargs); + if ($this->values) { if ($this->values == $new_val) return; @@ -197,6 +230,9 @@ class Attribute { } public function addValue($new_val,$i=-1) { + if (DEBUG_ENABLED && (($fargs=func_get_args())||$fargs='NOARGS')) + debug_log('Entered (%%)',5,0,__FILE__,__LINE__,__METHOD__,$fargs); + if ($i < 0) $i = $this->getValueCount(); @@ -208,6 +244,9 @@ class Attribute { } public function delValue($i=-1) { + if (DEBUG_ENABLED && (($fargs=func_get_args())||$fargs='NOARGS')) + debug_log('Entered (%%)',5,0,__FILE__,__LINE__,__METHOD__,$fargs); + if ($i < 0) $this->setValue(array()); @@ -222,6 +261,9 @@ class Attribute { } public function getValue($i) { + if (DEBUG_ENABLED && (($fargs=func_get_args())||$fargs='NOARGS')) + debug_log('Entered (%%)',5,0,__FILE__,__LINE__,__METHOD__,$fargs); + if (isset($this->values[$i])) return $this->values[$i]; else @@ -229,6 +271,9 @@ class Attribute { } public function getOldValue($i) { + if (DEBUG_ENABLED && (($fargs=func_get_args())||$fargs='NOARGS')) + debug_log('Entered (%%)',5,0,__FILE__,__LINE__,__METHOD__,$fargs); + if (isset($this->oldvalues[$i])) return $this->oldvalues[$i]; else @@ -236,22 +281,37 @@ class Attribute { } public function getMinValueCount() { + if (DEBUG_ENABLED && (($fargs=func_get_args())||$fargs='NOARGS')) + debug_log('Entered (%%)',5,1,__FILE__,__LINE__,__METHOD__,$fargs,$this->min_value_count); + return $this->min_value_count; } public function setMinValueCount($min) { + if (DEBUG_ENABLED && (($fargs=func_get_args())||$fargs='NOARGS')) + debug_log('Entered (%%)',5,1,__FILE__,__LINE__,__METHOD__,$fargs); + $this->min_value_count = $min; } public function getMaxValueCount() { + if (DEBUG_ENABLED && (($fargs=func_get_args())||$fargs='NOARGS')) + debug_log('Entered (%%)',5,1,__FILE__,__LINE__,__METHOD__,$fargs,$this->max_value_count); + return $this->max_value_count; } public function setMaxValueCount($max) { + if (DEBUG_ENABLED && (($fargs=func_get_args())||$fargs='NOARGS')) + debug_log('Entered (%%)',5,1,__FILE__,__LINE__,__METHOD__,$fargs); + $this->max_value_count = $max; } public function haveMoreValues() { + if (DEBUG_ENABLED && (($fargs=func_get_args())||$fargs='NOARGS')) + debug_log('Entered (%%)',5,0,__FILE__,__LINE__,__METHOD__,$fargs); + if ($this->getMaxValueCount() < 0 || ($this->getValueCount() < $this->getMaxValueCount())) return true; else @@ -259,18 +319,30 @@ class Attribute { } public function justModified() { + if (DEBUG_ENABLED && (($fargs=func_get_args())||$fargs='NOARGS')) + debug_log('Entered (%%)',5,0,__FILE__,__LINE__,__METHOD__,$fargs); + $this->modified = true; } public function hasBeenModified() { + if (DEBUG_ENABLED && (($fargs=func_get_args())||$fargs='NOARGS')) + debug_log('Entered (%%)',5,1,__FILE__,__LINE__,__METHOD__,$fargs,$this->modified); + return $this->modified; } public function isForceDelete() { + if (DEBUG_ENABLED && (($fargs=func_get_args())||$fargs='NOARGS')) + debug_log('Entered (%%)',5,1,__FILE__,__LINE__,__METHOD__,$fargs,$this->forcedelete); + return $this->forcedelete; } public function setForceDelete() { + if (DEBUG_ENABLED && (($fargs=func_get_args())||$fargs='NOARGS')) + debug_log('Entered (%%)',5,0,__FILE__,__LINE__,__METHOD__,$fargs); + $this->forcedelete = true; $this->oldvalues = $this->values; $this->values = array(); @@ -278,14 +350,23 @@ class Attribute { } public function isInternal() { + if (DEBUG_ENABLED && (($fargs=func_get_args())||$fargs='NOARGS')) + debug_log('Entered (%%)',5,1,__FILE__,__LINE__,__METHOD__,$fargs,$this->internal); + return $this->internal; } public function setInternal() { + if (DEBUG_ENABLED && (($fargs=func_get_args())||$fargs='NOARGS')) + debug_log('Entered (%%)',5,1,__FILE__,__LINE__,__METHOD__,$fargs); + $this->internal = true; } public function isRequired() { + if (DEBUG_ENABLED && (($fargs=func_get_args())||$fargs='NOARGS')) + debug_log('Entered (%%)',5,0,__FILE__,__LINE__,__METHOD__,$fargs); + if ($this->getMinValueCount() > 0) return true; elseif ($this->ldaptype == 'must') @@ -297,6 +378,9 @@ class Attribute { } public function isMay() { + if (DEBUG_ENABLED && (($fargs=func_get_args())||$fargs='NOARGS')) + debug_log('Entered (%%)',5,0,__FILE__,__LINE__,__METHOD__,$fargs); + if (($this->ldaptype == 'may') && ! $this->isRequired()) return true; else @@ -304,22 +388,37 @@ class Attribute { } public function setType($type) { + if (DEBUG_ENABLED && (($fargs=func_get_args())||$fargs='NOARGS')) + debug_log('Entered (%%)',5,1,__FILE__,__LINE__,__METHOD__,$fargs); + $this->type = strtolower($type); } public function getType() { + if (DEBUG_ENABLED && (($fargs=func_get_args())||$fargs='NOARGS')) + debug_log('Entered (%%)',5,1,__FILE__,__LINE__,__METHOD__,$fargs,$this->type); + return $this->type; } public function setLDAPtype($type) { + if (DEBUG_ENABLED && (($fargs=func_get_args())||$fargs='NOARGS')) + debug_log('Entered (%%)',5,1,__FILE__,__LINE__,__METHOD__,$fargs); + $this->ldaptype = strtolower($type); } public function getLDAPtype() { + if (DEBUG_ENABLED && (($fargs=func_get_args())||$fargs='NOARGS')) + debug_log('Entered (%%)',5,1,__FILE__,__LINE__,__METHOD__,$fargs,$this->ldaptype); + return $this->ldaptype; } public function setProperties($properties) { + if (DEBUG_ENABLED && (($fargs=func_get_args())||$fargs='NOARGS')) + debug_log('Entered (%%)',5,0,__FILE__,__LINE__,__METHOD__,$fargs); + foreach ($properties as $index => $value) { if ($index == 'maxvalnb') { $this->setMaxValueCount($value); @@ -352,39 +451,66 @@ class Attribute { } public function setRequired() { + if (DEBUG_ENABLED && (($fargs=func_get_args())||$fargs='NOARGS')) + debug_log('Entered (%%)',5,0,__FILE__,__LINE__,__METHOD__,$fargs); + if ($this->getMinValueCount() <= 0) $this->setMinValueCount(1); } public function setOptional() { + if (DEBUG_ENABLED && (($fargs=func_get_args())||$fargs='NOARGS')) + debug_log('Entered (%%)',5,1,__FILE__,__LINE__,__METHOD__,$fargs); + $this->setMinValueCount(0); } public function isReadOnly() { + if (DEBUG_ENABLED && (($fargs=func_get_args())||$fargs='NOARGS')) + debug_log('Entered (%%)',5,1,__FILE__,__LINE__,__METHOD__,$fargs,$this->readonly); + return $this->readonly; } public function setReadOnly() { + if (DEBUG_ENABLED && (($fargs=func_get_args())||$fargs='NOARGS')) + debug_log('Entered (%%)',5,0,__FILE__,__LINE__,__METHOD__,$fargs); + $this->readonly = true; } public function isVisible() { + if (DEBUG_ENABLED && (($fargs=func_get_args())||$fargs='NOARGS')) + debug_log('Entered (%%)',5,0,__FILE__,__LINE__,__METHOD__,$fargs); + return $this->visible && (! $this->forcehide); } public function hide() { + if (DEBUG_ENABLED && (($fargs=func_get_args())||$fargs='NOARGS')) + debug_log('Entered (%%)',5,0,__FILE__,__LINE__,__METHOD__,$fargs); + $this->visible = false; } public function show() { + if (DEBUG_ENABLED && (($fargs=func_get_args())||$fargs='NOARGS')) + debug_log('Entered (%%)',5,0,__FILE__,__LINE__,__METHOD__,$fargs); + $this->visible = true; } public function haveFriendlyName() { + if (DEBUG_ENABLED && (($fargs=func_get_args())||$fargs='NOARGS')) + debug_log('Entered (%%)',5,0,__FILE__,__LINE__,__METHOD__,$fargs); + return $_SESSION[APPCONFIG]->haveFriendlyName($this); } public function getFriendlyName() { + if (DEBUG_ENABLED && (($fargs=func_get_args())||$fargs='NOARGS')) + debug_log('Entered (%%)',5,1,__FILE__,__LINE__,__METHOD__,$fargs,$this->display); + if ($this->display) return $this->display; else @@ -392,73 +518,127 @@ class Attribute { } public function setDescription($description) { + if (DEBUG_ENABLED && (($fargs=func_get_args())||$fargs='NOARGS')) + debug_log('Entered (%%)',5,1,__FILE__,__LINE__,__METHOD__,$fargs); + $this->description = $description; } public function getDescription() { + if (DEBUG_ENABLED && (($fargs=func_get_args())||$fargs='NOARGS')) + debug_log('Entered (%%)',5,1,__FILE__,__LINE__,__METHOD__,$fargs,$this->description); + return $this->description; } public function setIcon($icon) { + if (DEBUG_ENABLED && (($fargs=func_get_args())||$fargs='NOARGS')) + debug_log('Entered (%%)',5,1,__FILE__,__LINE__,__METHOD__,$fargs); + $this->icon = $icon; } public function getIcon() { + if (DEBUG_ENABLED && (($fargs=func_get_args())||$fargs='NOARGS')) + debug_log('Entered (%%)',5,1,__FILE__,__LINE__,__METHOD__,$fargs,$this->icon); + return $this->icon ? sprintf('%s/%s',IMGDIR,$this->icon) : ''; } public function getHint() { + if (DEBUG_ENABLED && (($fargs=func_get_args())||$fargs='NOARGS')) + debug_log('Entered (%%)',5,1,__FILE__,__LINE__,__METHOD__,$fargs,$this->hint); + return $this->hint; } public function setHint($hint) { + if (DEBUG_ENABLED && (($fargs=func_get_args())||$fargs='NOARGS')) + debug_log('Entered (%%)',5,1,__FILE__,__LINE__,__METHOD__,$fargs); + $this->hint = $hint; } public function getMaxLength() { + if (DEBUG_ENABLED && (($fargs=func_get_args())||$fargs='NOARGS')) + debug_log('Entered (%%)',5,1,__FILE__,__LINE__,__METHOD__,$fargs,$this->maxlength); + return $this->maxlength; } public function setMaxLength($maxlength) { + if (DEBUG_ENABLED && (($fargs=func_get_args())||$fargs='NOARGS')) + debug_log('Entered (%%)',5,1,__FILE__,__LINE__,__METHOD__,$fargs); + $this->maxlength = $maxlength; } public function getSize() { + if (DEBUG_ENABLED && (($fargs=func_get_args())||$fargs='NOARGS')) + debug_log('Entered (%%)',5,1,__FILE__,__LINE__,__METHOD__,$fargs,$this->size); + return $this->size; } public function setSize($size) { + if (DEBUG_ENABLED && (($fargs=func_get_args())||$fargs='NOARGS')) + debug_log('Entered (%%)',5,1,__FILE__,__LINE__,__METHOD__,$fargs); + $this->size = $size; } public function getSpacer() { + if (DEBUG_ENABLED && (($fargs=func_get_args())||$fargs='NOARGS')) + debug_log('Entered (%%)',5,1,__FILE__,__LINE__,__METHOD__,$fargs,$this->spacer); + return $this->spacer; } public function getPage() { + if (DEBUG_ENABLED && (($fargs=func_get_args())||$fargs='NOARGS')) + debug_log('Entered (%%)',5,1,__FILE__,__LINE__,__METHOD__,$fargs,$this->page); + return $this->page; } public function setPage($page) { + if (DEBUG_ENABLED && (($fargs=func_get_args())||$fargs='NOARGS')) + debug_log('Entered (%%)',5,1,__FILE__,__LINE__,__METHOD__,$fargs); + $this->page = $page; } public function getOnChange() { + if (DEBUG_ENABLED && (($fargs=func_get_args())||$fargs='NOARGS')) + debug_log('Entered (%%)',5,1,__FILE__,__LINE__,__METHOD__,$fargs,$this->onchange); + return $this->onchange; } public function getHelper() { + if (DEBUG_ENABLED && (($fargs=func_get_args())||$fargs='NOARGS')) + debug_log('Entered (%%)',5,1,__FILE__,__LINE__,__METHOD__,$fargs,$this->helper); + return $this->helper; } public function getHelperValue() { + if (DEBUG_ENABLED && (($fargs=func_get_args())||$fargs='NOARGS')) + debug_log('Entered (%%)',5,1,__FILE__,__LINE__,__METHOD__,$fargs,$this->helpervalue); + return $this->helpervalue; } public function getVerify() { + if (DEBUG_ENABLED && (($fargs=func_get_args())||$fargs='NOARGS')) + debug_log('Entered (%%)',5,1,__FILE__,__LINE__,__METHOD__,$fargs,$this->verify); + return $this->verify; } public function setRDN($rdn) { + if (DEBUG_ENABLED && (($fargs=func_get_args())||$fargs='NOARGS')) + debug_log('Entered (%%)',5,1,__FILE__,__LINE__,__METHOD__,$fargs); + $this->rdn = $rdn; } @@ -468,6 +648,9 @@ class Attribute { * @return boolean */ public function isRDN() { + if (DEBUG_ENABLED && (($fargs=func_get_args())||$fargs='NOARGS')) + debug_log('Entered (%%)',5,0,__FILE__,__LINE__,__METHOD__,$fargs,$this->rdn); + return $this->rdn; } @@ -477,6 +660,9 @@ class Attribute { * @param sattr Schema Attribute */ private function setLDAPdetails($sattr) { + if (DEBUG_ENABLED && (($fargs=func_get_args())||$fargs='NOARGS')) + debug_log('Entered (%%)',5,0,__FILE__,__LINE__,__METHOD__,$fargs); + # By default, set this as a MAY attribute, later processing should make it a MUST attribute if it is. if (! $this->ldaptype) $this->ldaptype = 'may'; @@ -494,22 +680,37 @@ class Attribute { * This list will be lowercase. */ public function getAliases() { + if (DEBUG_ENABLED && (($fargs=func_get_args())||$fargs='NOARGS')) + debug_log('Entered (%%)',5,1,__FILE__,__LINE__,__METHOD__,$fargs,$this->aliases); + return $this->aliases; } public function getAutoValue() { + if (DEBUG_ENABLED && (($fargs=func_get_args())||$fargs='NOARGS')) + debug_log('Entered (%%)',5,1,__FILE__,__LINE__,__METHOD__,$fargs,$this->autovalue); + return $this->autovalue; } public function getPostValue() { + if (DEBUG_ENABLED && (($fargs=func_get_args())||$fargs='NOARGS')) + debug_log('Entered (%%)',5,1,__FILE__,__LINE__,__METHOD__,$fargs,$this->postvalue); + return $this->postvalue; } public function setPostValue($postvalue) { + if (DEBUG_ENABLED && (($fargs=func_get_args())||$fargs='NOARGS')) + debug_log('Entered (%%)',5,1,__FILE__,__LINE__,__METHOD__,$fargs); + $this->postvalue = $postvalue; } public function setXML($values) { + if (DEBUG_ENABLED && (($fargs=func_get_args())||$fargs='NOARGS')) + debug_log('Entered (%%)',5,0,__FILE__,__LINE__,__METHOD__,$fargs); + # Mostly all the time, this should be an array if (is_array($values)) foreach ($values as $index => $value) @@ -625,6 +826,9 @@ class Attribute { * Display the values removed in an attribute. */ public function getRemovedValues() { + if (DEBUG_ENABLED && (($fargs=func_get_args())||$fargs='NOARGS')) + debug_log('Entered (%%)',5,0,__FILE__,__LINE__,__METHOD__,$fargs); + $return = array(); foreach ($this->getOldValues() as $value) @@ -638,6 +842,9 @@ class Attribute { * Display the values removed in an attribute. */ public function getAddedValues() { + if (DEBUG_ENABLED && (($fargs=func_get_args())||$fargs='NOARGS')) + debug_log('Entered (%%)',5,0,__FILE__,__LINE__,__METHOD__,$fargs); + $return = array(); foreach ($this->getValues() as $value) @@ -657,8 +864,8 @@ class Attribute { * @return string */ private function real_attr_name() { - if (DEBUG_ENABLED) - debug_log('Entered with (%s)',1,__FILE__,__LINE__,__METHOD__,$attr_name); + if (DEBUG_ENABLED && (($fargs=func_get_args())||$fargs='NOARGS')) + debug_log('Entered (%%)',5,1,__FILE__,__LINE__,__METHOD__,$fargs,$this->name); return preg_replace('/;.*$/U','',$this->name); } @@ -667,6 +874,9 @@ class Attribute { * Does this attribute need supporting JS */ public function needJS($type=null) { + if (DEBUG_ENABLED && (($fargs=func_get_args())||$fargs='NOARGS')) + debug_log('Entered (%%)',5,0,__FILE__,__LINE__,__METHOD__,$fargs); + if (is_null($type)) { foreach (array('focus','blur','validate') as $type) if ($this->needJS($type)) diff --git a/lib/HTMLTree.php b/lib/HTMLTree.php index c2d394a..eebeac0 100644 --- a/lib/HTMLTree.php +++ b/lib/HTMLTree.php @@ -27,8 +27,8 @@ class HTMLTree extends Tree { * @param boolean Only display the tree, or include the server name and menu items */ public function draw($onlytree=false) { - if (DEBUG_ENABLED) - debug_log('Entered with ()',33,__FILE__,__LINE__,__METHOD__); + if (DEBUG_ENABLED && (($fargs=func_get_args())||$fargs='NOARGS')) + debug_log('Entered (%%)',33,0,__FILE__,__LINE__,__METHOD__,$fargs); $server = $this->getServer(); @@ -152,6 +152,9 @@ class HTMLTree extends Tree { * Draw the server name */ protected function draw_server_name() { + if (DEBUG_ENABLED && (($fargs=func_get_args())||$fargs='NOARGS')) + debug_log('Entered (%%)',33,0,__FILE__,__LINE__,__METHOD__,$fargs); + $server = $this->getServer(); echo ''; @@ -171,6 +174,9 @@ class HTMLTree extends Tree { * Draw the tree menu options */ protected function draw_menu() { + if (DEBUG_ENABLED && (($fargs=func_get_args())||$fargs='NOARGS')) + debug_log('Entered (%%)',33,0,__FILE__,__LINE__,__METHOD__,$fargs); + $links = ''; if (is_array($_SESSION[APPCONFIG]->getValue('menu','session'))) @@ -194,6 +200,9 @@ class HTMLTree extends Tree { * Get the HTML for each tree menu option */ protected function get_menu_item($item) { + if (DEBUG_ENABLED && (($fargs=func_get_args())||$fargs='NOARGS')) + debug_log('Entered (%%)',33,0,__FILE__,__LINE__,__METHOD__,$fargs); + $server = $this->getServer(); $menu = array(); @@ -309,6 +318,9 @@ class HTMLTree extends Tree { } protected function get_logout_menu_item() { + if (DEBUG_ENABLED && (($fargs=func_get_args())||$fargs='NOARGS')) + debug_log('Entered (%%)',33,0,__FILE__,__LINE__,__METHOD__,$fargs); + $server = $this->getServer(); $href = sprintf('cmd.php?cmd=logout&server_id=%s',$server->getIndex()); @@ -323,6 +335,9 @@ class HTMLTree extends Tree { * Draw the Logged in User */ protected function draw_logged_in_user() { + if (DEBUG_ENABLED && (($fargs=func_get_args())||$fargs='NOARGS')) + debug_log('Entered (%%)',33,0,__FILE__,__LINE__,__METHOD__,$fargs); + $server = $this->getServer(); $logged_in_dn = $server->getLogin(null); @@ -379,8 +394,8 @@ class HTMLTree extends Tree { * @param int $level Level to start drawing (start to -1) */ protected function draw_item($item,$level) { - if (DEBUG_ENABLED) - debug_log('Entered with (%s,%s)',33,__FILE__,__LINE__,__METHOD__,$item,$level); + if (DEBUG_ENABLED && (($fargs=func_get_args())||$fargs='NOARGS')) + debug_log('Entered (%%)',33,0,__FILE__,__LINE__,__METHOD__,$fargs); $server = $this->getServer(); @@ -452,10 +467,13 @@ class HTMLTree extends Tree { } if (DEBUG_ENABLED) - debug_log('Leaving (%s,%s)',33,__FILE__,__LINE__,__METHOD__,$item,$level); + debug_log('Leaving (%s,%s)',33,0,__FILE__,__LINE__,__METHOD__,$item,$level); } protected function get_formatted_dn($entry,$level) { + if (DEBUG_ENABLED && (($fargs=func_get_args())||$fargs='NOARGS')) + debug_log('Entered (%%)',33,0,__FILE__,__LINE__,__METHOD__,$fargs); + if ($level < 0) return pretty_print_dn($entry->getDN()); else @@ -470,6 +488,9 @@ class HTMLTree extends Tree { * @param dn $encoded_dn */ protected function draw_create_link($rdn,$level,$encoded_dn) { + if (DEBUG_ENABLED && (($fargs=func_get_args())||$fargs='NOARGS')) + debug_log('Entered (%%)',33,0,__FILE__,__LINE__,__METHOD__,$fargs); + # print the "Create New object" link. $href = htmlspecialchars(sprintf('cmd.php?cmd=template_engine&server_id=%s&container=%s',$this->getServerID(),$encoded_dn)); @@ -485,6 +506,9 @@ class HTMLTree extends Tree { * Draw login link */ protected function draw_login_link() { + if (DEBUG_ENABLED && (($fargs=func_get_args())||$fargs='NOARGS')) + debug_log('Entered (%%)',33,0,__FILE__,__LINE__,__METHOD__,$fargs); + $server = $this->getServer(); $href_parm = htmlspecialchars(sprintf('cmd=%s&server_id=%s',get_custom_file($server->getIndex(),'login_form',''),$server->getIndex())); @@ -511,6 +535,9 @@ class HTMLTree extends Tree { * If there is javascript, draw it */ protected function draw_javascript() { + if (DEBUG_ENABLED && (($fargs=func_get_args())||$fargs='NOARGS')) + debug_log('Entered (%%)',33,0,__FILE__,__LINE__,__METHOD__,$fargs); + if ($this->javascript) { echo "\n"; echo $this->javascript; @@ -522,6 +549,9 @@ class HTMLTree extends Tree { * Work out how deep the "opened" tree is. */ public function getDepth() { + if (DEBUG_ENABLED && (($fargs=func_get_args())||$fargs='NOARGS')) + debug_log('Entered (%%)',33,0,__FILE__,__LINE__,__METHOD__,$fargs); + $server = $this->getServer(); # If we are not logged in diff --git a/lib/PageRender.php b/lib/PageRender.php index eec83bf..e60cf7e 100644 --- a/lib/PageRender.php +++ b/lib/PageRender.php @@ -23,6 +23,9 @@ class PageRender extends Visitor { protected $page; public function __construct($server_id,$template_id) { + if (DEBUG_ENABLED && (($fargs=func_get_args())||$fargs='NOARGS')) + debug_log('Entered (%%)',129,0,__FILE__,__LINE__,__METHOD__,$fargs); + $this->server_id = $server_id; $this->template_id = $template_id; } @@ -36,14 +39,23 @@ class PageRender extends Visitor { * Get our templates applicable for this object */ protected function getTemplates() { + if (DEBUG_ENABLED && (($fargs=func_get_args())||$fargs='NOARGS')) + debug_log('Entered (%%)',129,0,__FILE__,__LINE__,__METHOD__,$fargs); + return new Templates($this->server_id); } public function getTemplate() { + if (DEBUG_ENABLED && (($fargs=func_get_args())||$fargs='NOARGS')) + debug_log('Entered (%%)',129,0,__FILE__,__LINE__,__METHOD__,$fargs); + return $this->template; } public function getTemplateID() { + if (DEBUG_ENABLED && (($fargs=func_get_args())||$fargs='NOARGS')) + debug_log('Entered (%%)',129,0,__FILE__,__LINE__,__METHOD__,$fargs); + return $this->template->getID(); } @@ -51,6 +63,9 @@ class PageRender extends Visitor { * Initialise the PageRender */ public function accept() { + if (DEBUG_ENABLED && (($fargs=func_get_args())||$fargs='NOARGS')) + debug_log('Entered (%%)',129,0,__FILE__,__LINE__,__METHOD__,$fargs); + if (DEBUGTMP) printf('%s:%s
',time(),__METHOD__); if ($this->template_id) { @@ -100,6 +115,9 @@ class PageRender extends Visitor { } public function setDN($dn) { + if (DEBUG_ENABLED && (($fargs=func_get_args())||$fargs='NOARGS')) + debug_log('Entered (%%)',129,0,__FILE__,__LINE__,__METHOD__,$fargs); + if ($this->container) system_message(array( 'title'=>__METHOD__, @@ -110,6 +128,9 @@ class PageRender extends Visitor { } public function setContainer($dn) { + if (DEBUG_ENABLED && (($fargs=func_get_args())||$fargs='NOARGS')) + debug_log('Entered (%%)',129,0,__FILE__,__LINE__,__METHOD__,$fargs); + if ($this->dn) system_message(array( 'title'=>__METHOD__, @@ -129,6 +150,9 @@ class PageRender extends Visitor { * Process our arguments from the templates */ protected function getPostAttribute($attribute,$i) { + if (DEBUG_ENABLED && (($fargs=func_get_args())||$fargs='NOARGS')) + debug_log('Entered (%%)',129,0,__FILE__,__LINE__,__METHOD__,$fargs); + $autovalue = $attribute->getPostValue(); $args = explode(';',$autovalue['args']); $server = $this->getServer(); @@ -283,9 +307,10 @@ class PageRender extends Visitor { * @return string Template ID to be used or null if the user was presented with a list. */ protected function getTemplateChoice() { + if (DEBUG_ENABLED && (($fargs=func_get_args())||$fargs='NOARGS')) + debug_log('Entered (%%)',129,0,__FILE__,__LINE__,__METHOD__,$fargs); + if (DEBUGTMP) printf('%s
',__METHOD__); - if (DEBUG_ENABLED) - debug_log('Entered with (%s)',1,__FILE__,__LINE__,__METHOD__,$this->template ? $this->template->getDN() : ''); # First work out our template $templates = $this->getTemplates(); @@ -372,6 +397,9 @@ class PageRender extends Visitor { } protected function getNoteAliasAttribute($attribute) { + if (DEBUG_ENABLED && (($fargs=func_get_args())||$fargs='NOARGS')) + debug_log('Entered (%%)',129,0,__FILE__,__LINE__,__METHOD__,$fargs); + if (DEBUGTMP) printf('%s
',__METHOD__); # Is there a user-friendly translation available for this attribute? @@ -386,6 +414,9 @@ class PageRender extends Visitor { #@todo this function shouldnt re-calculate requiredness, it should be known in the template already - need to set the ldaptype when initiating the attribute. protected function getNoteRequiredAttribute($attribute) { + if (DEBUG_ENABLED && (($fargs=func_get_args())||$fargs='NOARGS')) + debug_log('Entered (%%)',129,0,__FILE__,__LINE__,__METHOD__,$fargs); + if (DEBUGTMP) printf('%s
',__METHOD__); $required_by = ''; @@ -425,6 +456,9 @@ class PageRender extends Visitor { } protected function getNoteRDNAttribute($attribute) { + if (DEBUG_ENABLED && (($fargs=func_get_args())||$fargs='NOARGS')) + debug_log('Entered (%%)',129,0,__FILE__,__LINE__,__METHOD__,$fargs); + if (DEBUGTMP) printf('%s
',__METHOD__); # Is this attribute required because its the RDN @@ -435,6 +469,9 @@ class PageRender extends Visitor { } protected function getNoteHintAttribute($attribute) { + if (DEBUG_ENABLED && (($fargs=func_get_args())||$fargs='NOARGS')) + debug_log('Entered (%%)',129,0,__FILE__,__LINE__,__METHOD__,$fargs); + if (DEBUGTMP) printf('%s
',__METHOD__); # Is there a hint for this attribute @@ -445,6 +482,9 @@ class PageRender extends Visitor { } protected function getNoteROAttribute($attribute) { + if (DEBUG_ENABLED && (($fargs=func_get_args())||$fargs='NOARGS')) + debug_log('Entered (%%)',129,0,__FILE__,__LINE__,__METHOD__,$fargs); + if (DEBUGTMP) printf('%s
',__METHOD__); # Is this attribute is readonly @@ -459,6 +499,9 @@ class PageRender extends Visitor { * Draw all hidden attributes */ final public function drawHiddenAttributes() { + if (DEBUG_ENABLED && (($fargs=func_get_args())||$fargs='NOARGS')) + debug_log('Entered (%%)',129,0,__FILE__,__LINE__,__METHOD__,$fargs); + foreach ($this->template->getAttributes(true) as $attribute) if ($attribute->hasbeenModified()) if ($attribute->getValues()) @@ -1091,9 +1134,8 @@ class PageRender extends Visitor { * @param string A shadow attribute name */ private function shadow_date($attribute) { - if (DEBUG_ENABLED) - debug_log('Entered with (%s)',1,__FILE__,__LINE__,__METHOD__, - $attr); + if (DEBUG_ENABLED && (($fargs=func_get_args())||$fargs='NOARGS')) + debug_log('Entered (%%)',129,0,__FILE__,__LINE__,__METHOD__,$fargs); $shadowattr = array(); $shadowattr['lastchange'] = $this->template->getAttribute('shadowlastchange'); diff --git a/lib/Query.php b/lib/Query.php index 69c44d8..18b02bf 100644 --- a/lib/Query.php +++ b/lib/Query.php @@ -24,28 +24,28 @@ class Query extends xmlTemplate { * @param xmldata Parsed xmldata from xml2array object */ protected function storeTemplate($xmldata) { - if (DEBUG_ENABLED) - debug_log('Entered with (%s)',5,__FILE__,__LINE__,__METHOD__,$xmldata); + if (DEBUG_ENABLED && (($fargs=func_get_args())||$fargs='NOARGS')) + debug_log('Entered (%%)',5,0,__FILE__,__LINE__,__METHOD__,$fargs); $server = $this->getServer(); foreach ($xmldata['query'] as $xml_key => $xml_value) { if (DEBUG_ENABLED) - debug_log('Foreach loop Key [%s] Value [%s]',4,__FILE__,__LINE__,__METHOD__,$xml_key,is_array($xml_value)); + debug_log('Foreach loop Key [%s] Value [%s]',4,0,__FILE__,__LINE__,__METHOD__,$xml_key,is_array($xml_value)); switch ($xml_key) { # Build our attribute list from the DN and Template. case ('attributes'): if (DEBUG_ENABLED) - debug_log('Case [%s]',4,__FILE__,__LINE__,__METHOD__,$xml_key); + debug_log('Case [%s]',4,0,__FILE__,__LINE__,__METHOD__,$xml_key); if (is_array($xmldata['query'][$xml_key])) { foreach ($xmldata['query'][$xml_key] as $tattrs) { foreach ($tattrs as $index => $details) { if (DEBUG_ENABLED) - debug_log('Foreach tattrs Key [%s] Value [%s]',4,__FILE__,__LINE__,__METHOD__, + debug_log('Foreach tattrs Key [%s] Value [%s]',4,0,__FILE__,__LINE__,__METHOD__, $index,$details); # If there is no schema definition for the attribute, it will be ignored. @@ -78,7 +78,7 @@ class Query extends xmlTemplate { default: if (DEBUG_ENABLED) - debug_log('Case [%s]',4,__FILE__,__LINE__,__METHOD__,$xml_key); + debug_log('Case [%s]',4,0,__FILE__,__LINE__,__METHOD__,$xml_key); # Some key definitions need to be an array, some must not be: $allowed_arrays = array(''); @@ -123,6 +123,9 @@ class Query extends xmlTemplate { * Accept will run the query and store the results in results() */ public function accept() { + if (DEBUG_ENABLED && (($fargs=func_get_args())||$fargs='NOARGS')) + debug_log('Entered (%%)',5,0,__FILE__,__LINE__,__METHOD__,$fargs); + $server = $this->getServer(); $query = array(); @@ -173,6 +176,9 @@ class Query extends xmlTemplate { * This is temporary to get around objects that use a DN for rendering, for example jpegPhoto */ public function setDN($dn) { + if (DEBUG_ENABLED && (($fargs=func_get_args())||$fargs='NOARGS')) + debug_log('Entered (%%)',5,1,__FILE__,__LINE__,__METHOD__,$fargs); + $this->dn = $dn; } @@ -180,10 +186,16 @@ class Query extends xmlTemplate { * This is temporary to get around objects that use a DN for rendering, for example jpegPhoto */ public function getDN() { + if (DEBUG_ENABLED && (($fargs=func_get_args())||$fargs='NOARGS')) + debug_log('Entered (%%)',5,1,__FILE__,__LINE__,__METHOD__,$fargs,$this->dn); + return $this->dn; } public function getAttrSortOrder() { + if (DEBUG_ENABLED && (($fargs=func_get_args())||$fargs='NOARGS')) + debug_log('Entered (%%)',5,0,__FILE__,__LINE__,__METHOD__,$fargs); + $result = array(); if (count($this->attributes)) { @@ -203,6 +215,9 @@ class Query extends xmlTemplate { } public function getAttrDisplayOrder() { + if (DEBUG_ENABLED && (($fargs=func_get_args())||$fargs='NOARGS')) + debug_log('Entered (%%)',5,0,__FILE__,__LINE__,__METHOD__,$fargs); + $result = array(); if (count($this->attributes)) { @@ -241,10 +256,16 @@ class Query extends xmlTemplate { * @return boolean */ public function isVisible() { + if (DEBUG_ENABLED && (($fargs=func_get_args())||$fargs='NOARGS')) + debug_log('Entered (%%)',5,1,__FILE__,__LINE__,__METHOD__,$fargs,$this->visible); + return $this->visible; } public function getDescription() { + if (DEBUG_ENABLED && (($fargs=func_get_args())||$fargs='NOARGS')) + debug_log('Entered (%%)',5,1,__FILE__,__LINE__,__METHOD__,$fargs,$this->description); + return $this->description; } } diff --git a/lib/QueryRender.php b/lib/QueryRender.php index f8d66f5..8b7096d 100644 --- a/lib/QueryRender.php +++ b/lib/QueryRender.php @@ -20,8 +20,8 @@ class QueryRender extends PageRender { * Intialise and Render the QueryRender */ public function accept() { - if (DEBUG_ENABLED) - debug_log('Entered with ()',1,__FILE__,__LINE__,__METHOD__); + if (DEBUG_ENABLED && (($fargs=func_get_args())||$fargs='NOARGS')) + debug_log('Entered (%%)',129,0,__FILE__,__LINE__,__METHOD__,$fargs); if (DEBUGTMP) printf('%s
',__METHOD__); if (DEBUGTMP||DEBUGTMPSUB) printf('* %s [GETquery:%s]
',__METHOD__,get_request('query','REQUEST')); @@ -44,6 +44,9 @@ class QueryRender extends PageRender { * Get our templates applicable for this object */ protected function getTemplates() { + if (DEBUG_ENABLED && (($fargs=func_get_args())||$fargs='NOARGS')) + debug_log('Entered (%%)',129,0,__FILE__,__LINE__,__METHOD__,$fargs); + return new Queries($this->server_id); } @@ -51,6 +54,9 @@ class QueryRender extends PageRender { * Are default queries enabled? */ protected function haveDefaultTemplate() { + if (DEBUG_ENABLED && (($fargs=func_get_args())||$fargs='NOARGS')) + debug_log('Entered (%%)',129,0,__FILE__,__LINE__,__METHOD__,$fargs); + $server = $this->getServer(); if ($server->getValue('query','disable_default')) @@ -195,12 +201,18 @@ class QueryRender extends PageRender { } private function visitStart() { + if (DEBUG_ENABLED && (($fargs=func_get_args())||$fargs='NOARGS')) + debug_log('Entered (%%)',129,0,__FILE__,__LINE__,__METHOD__,$fargs); + $this->drawTitle(_('Search Results')); $this->drawSubTitle(); echo '
'; } private function visitEnd() { + if (DEBUG_ENABLED && (($fargs=func_get_args())||$fargs='NOARGS')) + debug_log('Entered (%%)',129,0,__FILE__,__LINE__,__METHOD__,$fargs); + $server = $this->getServer(); $afattrs = $this->getAFAttrs(); @@ -509,6 +521,9 @@ var deon=0; } private function getAFattrs() { + if (DEBUG_ENABLED && (($fargs=func_get_args())||$fargs='NOARGS')) + debug_log('Entered (%%)',129,0,__FILE__,__LINE__,__METHOD__,$fargs); + $attribute_factory = new AttributeFactory(); $results = array(); @@ -519,6 +534,9 @@ var deon=0; } private function getAjaxRef($dn) { + if (DEBUG_ENABLED && (($fargs=func_get_args())||$fargs='NOARGS')) + debug_log('Entered (%%)',129,0,__FILE__,__LINE__,__METHOD__,$fargs); + return preg_replace('/=/','.',base64_encode($dn)); } diff --git a/lib/Template.php b/lib/Template.php index b334866..75e4701 100644 --- a/lib/Template.php +++ b/lib/Template.php @@ -57,6 +57,9 @@ class Template extends xmlTemplate { private $rdn; public function __clone() { + if (DEBUG_ENABLED && (($fargs=func_get_args())||$fargs='NOARGS')) + debug_log('Entered (%%)',5,0,__FILE__,__LINE__,__METHOD__,$fargs); + # We need to clone our attributes, when passing back a template with getTemplate foreach ($this->attributes as $key => $value) $this->attributes[$key] = clone $value; @@ -68,21 +71,21 @@ class Template extends xmlTemplate { * @param xmldata Parsed xmldata from xml2array object */ protected function storeTemplate($xmldata) { - if (DEBUG_ENABLED) - debug_log('Entered with (%s)',5,__FILE__,__LINE__,__METHOD__,$xmldata); + if (DEBUG_ENABLED && (($fargs=func_get_args())||$fargs='NOARGS')) + debug_log('Entered (%%)',5,0,__FILE__,__LINE__,__METHOD__,$fargs); $server = $this->getServer(); $objectclasses = array(); foreach ($xmldata['template'] as $xml_key => $xml_value) { if (DEBUG_ENABLED) - debug_log('Foreach loop Key [%s] Value [%s]',4,__FILE__,__LINE__,__METHOD__,$xml_key,is_array($xml_value)); + debug_log('Foreach loop Key [%s] Value [%s]',4,0,__FILE__,__LINE__,__METHOD__,$xml_key,is_array($xml_value)); switch ($xml_key) { # Build our object Classes from the DN and Template. case ('objectclasses'): if (DEBUG_ENABLED) - debug_log('Case [%s]',4,__FILE__,__LINE__,__METHOD__,$xml_key); + debug_log('Case [%s]',4,0,__FILE__,__LINE__,__METHOD__,$xml_key); if (isset($xmldata['template'][$xml_key]['objectclass'])) if (is_array($xmldata['template'][$xml_key]['objectclass'])) { @@ -116,13 +119,13 @@ class Template extends xmlTemplate { # Build our attribute list from the DN and Template. case ('attributes'): if (DEBUG_ENABLED) - debug_log('Case [%s]',4,__FILE__,__LINE__,__METHOD__,$xml_key); + debug_log('Case [%s]',4,0,__FILE__,__LINE__,__METHOD__,$xml_key); if (is_array($xmldata['template'][$xml_key])) { foreach ($xmldata['template'][$xml_key] as $tattrs) foreach ($tattrs as $index => $details) { if (DEBUG_ENABLED) - debug_log('Foreach tattrs Key [%s] Value [%s]',4,__FILE__,__LINE__,__METHOD__, + debug_log('Foreach tattrs Key [%s] Value [%s]',4,0,__FILE__,__LINE__,__METHOD__, $index,$details); # If there is no schema definition for the attribute, it will be ignored. @@ -138,7 +141,7 @@ class Template extends xmlTemplate { default: if (DEBUG_ENABLED) - debug_log('Case [%s]',4,__FILE__,__LINE__,__METHOD__,$xml_key); + debug_log('Case [%s]',4,0,__FILE__,__LINE__,__METHOD__,$xml_key); # Some key definitions need to be an array, some must not be: $allowed_arrays = array('rdn'); @@ -216,6 +219,9 @@ class Template extends xmlTemplate { * @return boolean */ protected function hasDefaultTemplate() { + if (DEBUG_ENABLED && (($fargs=func_get_args())||$fargs='NOARGS')) + debug_log('Entered (%%)',5,0,__FILE__,__LINE__,__METHOD__,$fargs); + if ($_SESSION[APPCONFIG]->getValue('appearance','disable_default_template')) return false; else @@ -229,8 +235,8 @@ class Template extends xmlTemplate { * @return array - Array of templates of that type */ protected function readTemplates($type) { - if (DEBUG_ENABLED) - debug_log('Entered with ()',1,__FILE__,__LINE__,__METHOD__); + if (DEBUG_ENABLED && (($fargs=func_get_args())||$fargs='NOARGS')) + debug_log('Entered (%%)',5,0,__FILE__,__LINE__,__METHOD__,$fargs); $template_xml = new Templates($this->server_id); return $template_xml->getTemplates($type); @@ -245,6 +251,9 @@ class Template extends xmlTemplate { * (OLD values are IGNORED, we will have got them when we build this object from the LDAP server DN.) */ public function accept($makeVisible=false) { + if (DEBUG_ENABLED && (($fargs=func_get_args())||$fargs='NOARGS')) + debug_log('Entered (%%)',5,0,__FILE__,__LINE__,__METHOD__,$fargs); + $server = $this->getServer(); # If a DN is set, then query the LDAP server for the details. @@ -546,6 +555,9 @@ class Template extends xmlTemplate { * @param dn The DN of the entry */ public function setDN($dn) { + if (DEBUG_ENABLED && (($fargs=func_get_args())||$fargs='NOARGS')) + debug_log('Entered (%%)',5,0,__FILE__,__LINE__,__METHOD__,$fargs); + if (isset($this->container)) system_message(array( 'title'=>__METHOD__, @@ -564,6 +576,9 @@ class Template extends xmlTemplate { * @return RDN attributes not processed */ public function setRDNAttributes($rdn) { + if (DEBUG_ENABLED && (($fargs=func_get_args())||$fargs='NOARGS')) + debug_log('Entered (%%)',5,0,__FILE__,__LINE__,__METHOD__,$fargs); + # Setup to work out our RDN. $rdnarray = rdn_explode($rdn); @@ -588,6 +603,9 @@ class Template extends xmlTemplate { * @return dn */ public function getDN() { + if (DEBUG_ENABLED && (($fargs=func_get_args())||$fargs='NOARGS')) + debug_log('Entered (%%)',5,0,__FILE__,__LINE__,__METHOD__,$fargs,$this->dn); + if ($this->dn) return $this->dn; @@ -603,6 +621,9 @@ class Template extends xmlTemplate { * @todo Trigger a query to the LDAP server and generate an error if the container doesnt exist */ public function setContainer($container) { + if (DEBUG_ENABLED && (($fargs=func_get_args())||$fargs='NOARGS')) + debug_log('Entered (%%)',5,0,__FILE__,__LINE__,__METHOD__,$fargs); + if (isset($this->dn)) system_message(array( 'title'=>__METHOD__, @@ -618,6 +639,9 @@ class Template extends xmlTemplate { * @return dn DN of the container */ public function getContainer() { + if (DEBUG_ENABLED && (($fargs=func_get_args())||$fargs='NOARGS')) + debug_log('Entered (%%)',5,1,__FILE__,__LINE__,__METHOD__,$fargs,$this->container); + return $this->container; } @@ -625,6 +649,9 @@ class Template extends xmlTemplate { * Copy a DN */ public function copy($template,$rdn) { + if (DEBUG_ENABLED && (($fargs=func_get_args())||$fargs='NOARGS')) + debug_log('Entered (%%)',5,0,__FILE__,__LINE__,__METHOD__,$fargs); + $rdnarray = rdn_explode($rdn); $counter = 1; @@ -683,6 +710,9 @@ class Template extends xmlTemplate { * @return array Array of attributes. */ function getAttrbyLdapType($type) { + if (DEBUG_ENABLED && (($fargs=func_get_args())||$fargs='NOARGS')) + debug_log('Entered (%%)',5,0,__FILE__,__LINE__,__METHOD__,$fargs); + $result = array(); foreach ($this->attributes as $index => $attribute) { @@ -697,6 +727,9 @@ class Template extends xmlTemplate { * Return true if this is a MUST,MAY attribute */ function isAttrType($attr,$type) { + if (DEBUG_ENABLED && (($fargs=func_get_args())||$fargs='NOARGS')) + debug_log('Entered (%%)',5,0,__FILE__,__LINE__,__METHOD__,$fargs); + if (in_array(strtolower($attr),$this->getAttrbyLdapType($type))) return true; else @@ -709,6 +742,9 @@ class Template extends xmlTemplate { * @return array Array of RDN objects */ private function getRDNObjects() { + if (DEBUG_ENABLED && (($fargs=func_get_args())||$fargs='NOARGS')) + debug_log('Entered (%%)',5,0,__FILE__,__LINE__,__METHOD__,$fargs); + $return = array(); foreach ($this->attributes as $attribute) @@ -725,6 +761,9 @@ class Template extends xmlTemplate { * @return array RDNs in order. */ public function getRDNAttrs() { + if (DEBUG_ENABLED && (($fargs=func_get_args())||$fargs='NOARGS')) + debug_log('Entered (%%)',5,0,__FILE__,__LINE__,__METHOD__,$fargs); + $return = array(); foreach ($this->getRDNObjects() as $attribute) { @@ -751,6 +790,9 @@ class Template extends xmlTemplate { * @return rdn RDN for this template */ public function getRDN() { + if (DEBUG_ENABLED && (($fargs=func_get_args())||$fargs='NOARGS')) + debug_log('Entered (%%)',5,0,__FILE__,__LINE__,__METHOD__,$fargs); + # If the DN is set, then the RDN will be calculated from it. if ($this->dn) return get_rdn($this->dn); @@ -776,6 +818,9 @@ class Template extends xmlTemplate { * Return the attribute name part of the RDN */ public function getRDNAttributeName() { + if (DEBUG_ENABLED && (($fargs=func_get_args())||$fargs='NOARGS')) + debug_log('Entered (%%)',5,0,__FILE__,__LINE__,__METHOD__,$fargs); + $attr = array(); if ($this->getDN()) { @@ -798,6 +843,9 @@ class Template extends xmlTemplate { * Determine the type of template this is */ public function getContext() { + if (DEBUG_ENABLED && (($fargs=func_get_args())||$fargs='NOARGS')) + debug_log('Entered (%%)',5,0,__FILE__,__LINE__,__METHOD__,$fargs); + if ($this->getContainer()) return 'create'; elseif ($this->getDN()) @@ -812,10 +860,16 @@ class Template extends xmlTemplate { * @return boolean */ public function isVisible() { + if (DEBUG_ENABLED && (($fargs=func_get_args())||$fargs='NOARGS')) + debug_log('Entered (%%)',5,1,__FILE__,__LINE__,__METHOD__,$fargs,$this->visible); + return $this->visible; } public function getRegExp() { + if (DEBUG_ENABLED && (($fargs=func_get_args())||$fargs='NOARGS')) + debug_log('Entered (%%)',5,1,__FILE__,__LINE__,__METHOD__,$fargs,$this->regexp); + return $this->regexp; } @@ -823,6 +877,9 @@ class Template extends xmlTemplate { * Test if this template has been marked as a read-only template */ public function isReadOnly() { + if (DEBUG_ENABLED && (($fargs=func_get_args())||$fargs='NOARGS')) + debug_log('Entered (%%)',5,0,__FILE__,__LINE__,__METHOD__,$fargs); + if ((($this->getContext() == 'edit') && $this->readonly) || $this->getServer()->isReadOnly()) return true; else @@ -836,6 +893,9 @@ class Template extends xmlTemplate { * @return array Array of attributes */ public function getAttributes($optional=false) { + if (DEBUG_ENABLED && (($fargs=func_get_args())||$fargs='NOARGS')) + debug_log('Entered (%%)',5,0,__FILE__,__LINE__,__METHOD__,$fargs); + if ($optional) return $this->attributes; @@ -854,6 +914,9 @@ class Template extends xmlTemplate { * Return a list of attributes that should be shown */ public function getAttributesShown() { + if (DEBUG_ENABLED && (($fargs=func_get_args())||$fargs='NOARGS')) + debug_log('Entered (%%)',5,0,__FILE__,__LINE__,__METHOD__,$fargs); + $result = array(); foreach ($this->attributes as $attribute) @@ -867,6 +930,9 @@ class Template extends xmlTemplate { * Return a list of the internal attributes */ public function getAttributesInternal() { + if (DEBUG_ENABLED && (($fargs=func_get_args())||$fargs='NOARGS')) + debug_log('Entered (%%)',5,0,__FILE__,__LINE__,__METHOD__,$fargs); + $result = array(); foreach ($this->attributes as $attribute) @@ -882,6 +948,9 @@ class Template extends xmlTemplate { * @return array Array of Objects */ public function getObjectClasses() { + if (DEBUG_ENABLED && (($fargs=func_get_args())||$fargs='NOARGS')) + debug_log('Entered (%%)',5,0,__FILE__,__LINE__,__METHOD__,$fargs); + $attribute = $this->getAttribute('objectclass'); if ($attribute) return $attribute->getValues(); @@ -893,6 +962,9 @@ class Template extends xmlTemplate { * Get template icon */ public function getIcon() { + if (DEBUG_ENABLED && (($fargs=func_get_args())||$fargs='NOARGS')) + debug_log('Entered (%%)',5,1,__FILE__,__LINE__,__METHOD__,$fargs,$this->icon); + return isset($this->icon) ? sprintf('%s/%s',IMGDIR,$this->icon) : ''; } @@ -902,6 +974,9 @@ class Template extends xmlTemplate { * @return string Description */ public function getDescription() { + if (DEBUG_ENABLED && (($fargs=func_get_args())||$fargs='NOARGS')) + debug_log('Entered (%%)',5,1,__FILE__,__LINE__,__METHOD__,$fargs,$this->description); + return $this->description; } @@ -911,6 +986,9 @@ class Template extends xmlTemplate { * @param string Message indicating the reason the template has been invalidated */ public function setInvalid($msg,$admin=false) { + if (DEBUG_ENABLED && (($fargs=func_get_args())||$fargs='NOARGS')) + debug_log('Entered (%%)',5,0,__FILE__,__LINE__,__METHOD__,$fargs); + $this->invalid = true; $this->invalid_reason = $msg; $this->invalid_admin = $admin; @@ -922,6 +1000,9 @@ class Template extends xmlTemplate { * @return string Invalid reason, or false if not invalid */ public function isInValid() { + if (DEBUG_ENABLED && (($fargs=func_get_args())||$fargs='NOARGS')) + debug_log('Entered (%%)',5,0,__FILE__,__LINE__,__METHOD__,$fargs); + if ($this->invalid) return $this->invalid_reason; else @@ -929,6 +1010,9 @@ class Template extends xmlTemplate { } public function isAdminDisabled() { + if (DEBUG_ENABLED && (($fargs=func_get_args())||$fargs='NOARGS')) + debug_log('Entered (%%)',5,1,__FILE__,__LINE__,__METHOD__,$fargs,$this->invalid_admin); + return $this->invalid_admin; } @@ -939,6 +1023,9 @@ class Template extends xmlTemplate { * @param int */ private function setMinValueCount($attr,$value) { + if (DEBUG_ENABLED && (($fargs=func_get_args())||$fargs='NOARGS')) + debug_log('Entered (%%)',5,0,__FILE__,__LINE__,__METHOD__,$fargs); + $attribute = $this->getAttribute($attr); if (! is_null($attribute)) @@ -952,6 +1039,9 @@ class Template extends xmlTemplate { * @param string (MUST,MAY,OPTIONAL) */ private function setAttrLDAPtype($attr,$value) { + if (DEBUG_ENABLED && (($fargs=func_get_args())||$fargs='NOARGS')) + debug_log('Entered (%%)',5,0,__FILE__,__LINE__,__METHOD__,$fargs); + $attribute = $this->getAttribute($attr); if (is_null($attribute)) @@ -964,8 +1054,8 @@ class Template extends xmlTemplate { * OnChangeAdd javascript processing */ public function OnChangeAdd($origin,$value) { - if (DEBUG_ENABLED) - debug_log('Entered with (%s,%s)',5,__FILE__,__LINE__,__METHOD__,$origin,$value); + if (DEBUG_ENABLED && (($fargs=func_get_args())||$fargs='NOARGS')) + debug_log('Entered (%%)',5,0,__FILE__,__LINE__,__METHOD__,$fargs); $attribute = $this->getAttribute($origin); @@ -1130,6 +1220,9 @@ class Template extends xmlTemplate { * STRUCTURAL - without one, creating an entry will just product an LDAP error. */ private function rebuildTemplateAttrs() { + if (DEBUG_ENABLED && (($fargs=func_get_args())||$fargs='NOARGS')) + debug_log('Entered (%%)',5,0,__FILE__,__LINE__,__METHOD__,$fargs); + $server = $this->getServer(); # Collect our structural, MUST & MAY attributes. @@ -1241,6 +1334,9 @@ class Template extends xmlTemplate { * Attributes with empty values will be excluded. */ public function getLDAPadd($attrsOnly=false) { + if (DEBUG_ENABLED && (($fargs=func_get_args())||$fargs='NOARGS')) + debug_log('Entered (%%)',5,0,__FILE__,__LINE__,__METHOD__,$fargs); + $return = array(); $returnattrs = array(); @@ -1273,6 +1369,9 @@ class Template extends xmlTemplate { * @param boolean Return the attribute objects (useful for a confirmation process), or the modification array for ldap_modify() */ public function getLDAPmodify($attrsOnly=false,$index=0) { + if (DEBUG_ENABLED && (($fargs=func_get_args())||$fargs='NOARGS')) + debug_log('Entered (%%)',5,0,__FILE__,__LINE__,__METHOD__,$fargs); + static $return = array(); static $returnattrs = array(); @@ -1351,6 +1450,9 @@ class Template extends xmlTemplate { * We'll cache this result in the event of multiple calls. */ public function getForceDeleteAttrs() { + if (DEBUG_ENABLED && (($fargs=func_get_args())||$fargs='NOARGS')) + debug_log('Entered (%%)',5,0,__FILE__,__LINE__,__METHOD__,$fargs); + static $result = array(); if (count($result)) @@ -1367,6 +1469,9 @@ class Template extends xmlTemplate { * Get available attributes */ public function getAvailAttrs() { + if (DEBUG_ENABLED && (($fargs=func_get_args())||$fargs='NOARGS')) + debug_log('Entered (%%)',5,0,__FILE__,__LINE__,__METHOD__,$fargs); + $attributes = array(); $server = $this->getServer(); diff --git a/lib/TemplateRender.php b/lib/TemplateRender.php index 559141c..65144f2 100644 --- a/lib/TemplateRender.php +++ b/lib/TemplateRender.php @@ -24,6 +24,9 @@ class TemplateRender extends PageRender { * Initialise and Render the TemplateRender */ public function accept($norender=false) { + if (DEBUG_ENABLED && (($fargs=func_get_args())||$fargs='NOARGS')) + debug_log('Entered (%%)',129,0,__FILE__,__LINE__,__METHOD__,$fargs); + if (DEBUGTMP) printf('%s:%s
',time(),__METHOD__); if (DEBUGTMP||DEBUGTMPSUB) printf('* %s [Visit-Start:%s]
',__METHOD__,get_class($this)); @@ -84,6 +87,9 @@ class TemplateRender extends PageRender { } protected function getDefaultAttribute($attribute,$container,$type) { + if (DEBUG_ENABLED && (($fargs=func_get_args())||$fargs='NOARGS')) + debug_log('Entered (%%)',129,0,__FILE__,__LINE__,__METHOD__,$fargs); + switch ($type) { case 'autovalue': $autovalue = $attribute->getAutoValue(); @@ -545,6 +551,9 @@ class TemplateRender extends PageRender { * Applicable modes are "create" or "edit" */ protected function getMode() { + if (DEBUG_ENABLED && (($fargs=func_get_args())||$fargs='NOARGS')) + debug_log('Entered (%%)',129,0,__FILE__,__LINE__,__METHOD__,$fargs); + if ($this->dn) return 'modification'; elseif ($this->container) @@ -557,6 +566,9 @@ class TemplateRender extends PageRender { * Return the container for this mode */ protected function getModeContainer() { + if (DEBUG_ENABLED && (($fargs=func_get_args())||$fargs='NOARGS')) + debug_log('Entered (%%)',129,0,__FILE__,__LINE__,__METHOD__,$fargs); + switch ($this->getMode()) { case 'creation': return $this->container; @@ -575,6 +587,9 @@ class TemplateRender extends PageRender { * Is the default template enabled? */ protected function haveDefaultTemplate() { + if (DEBUG_ENABLED && (($fargs=func_get_args())||$fargs='NOARGS')) + debug_log('Entered (%%)',129,0,__FILE__,__LINE__,__METHOD__,$fargs); + if ($_SESSION[APPCONFIG]->getValue('appearance','disable_default_template')) return false; else @@ -705,9 +720,10 @@ class TemplateRender extends PageRender { * so that it can be rendered. */ private function visitStart() { + if (DEBUG_ENABLED && (($fargs=func_get_args())||$fargs='NOARGS')) + debug_log('Entered (%%)',129,0,__FILE__,__LINE__,__METHOD__,$fargs); + if (DEBUGTMP) printf('%s
',__METHOD__); - if (DEBUG_ENABLED) - debug_log('Entered',1,__FILE__,__LINE__,__METHOD__); # If we have a DN, then we are an editing template if ($this->dn) @@ -725,9 +741,10 @@ class TemplateRender extends PageRender { } private function visitEnd() { + if (DEBUG_ENABLED && (($fargs=func_get_args())||$fargs='NOARGS')) + debug_log('Entered (%%)',129,0,__FILE__,__LINE__,__METHOD__,$fargs); + if (DEBUGTMP) printf('%s
',__METHOD__); - if (DEBUG_ENABLED) - debug_log('Entered with (%s)',1,__FILE__,__LINE__,__METHOD__,$this->template->getDN()); foreach ($this->template->getAttributesShown() as $attribute) if ($attribute->getPage() > $this->pagelast) @@ -927,6 +944,9 @@ class TemplateRender extends PageRender { /** PAGE ENTRY MENU ITEMS **/ private function getMenuItem($i) { + if (DEBUG_ENABLED && (($fargs=func_get_args())||$fargs='NOARGS')) + debug_log('Entered (%%)',129,0,__FILE__,__LINE__,__METHOD__,$fargs); + if (DEBUGTMP) printf('%s (%s)
',__METHOD__,$i); switch ($i) { @@ -1086,6 +1106,9 @@ class TemplateRender extends PageRender { } protected function getDeleteAttributeMessage() { + if (DEBUG_ENABLED && (($fargs=func_get_args())||$fargs='NOARGS')) + debug_log('Entered (%%)',129,0,__FILE__,__LINE__,__METHOD__,$fargs); + if (DEBUGTMP) printf('%s
',__METHOD__); if ($_SESSION[APPCONFIG]->isCommandAvailable('script','delete_attr') && ! $this->template->isReadOnly()) @@ -1095,6 +1118,9 @@ class TemplateRender extends PageRender { } protected function getModifiedAttributesMessage(&$modified_attributes) { + if (DEBUG_ENABLED && (($fargs=func_get_args())||$fargs='NOARGS')) + debug_log('Entered (%%)',129,0,__FILE__,__LINE__,__METHOD__,$fargs); + if (DEBUGTMP) printf('%s
',__METHOD__); return sprintf($this->layout['hint'], @@ -1104,12 +1130,18 @@ class TemplateRender extends PageRender { } protected function getReadOnlyMessage() { + if (DEBUG_ENABLED && (($fargs=func_get_args())||$fargs='NOARGS')) + debug_log('Entered (%%)',129,0,__FILE__,__LINE__,__METHOD__,$fargs); + if (DEBUGTMP) printf('%s
',__METHOD__); return sprintf($this->layout['hint'],_('Viewing entry in read-only mode.')); } protected function getViewSchemaMessage() { + if (DEBUG_ENABLED && (($fargs=func_get_args())||$fargs='NOARGS')) + debug_log('Entered (%%)',129,0,__FILE__,__LINE__,__METHOD__,$fargs); + if (DEBUGTMP) printf('%s
',__METHOD__); return sprintf($this->layout['hint'],_('Hint: To view the schema for an attribute, click the attribute name.')); @@ -1118,6 +1150,9 @@ class TemplateRender extends PageRender { /** PAGE ENTRY MENU ITEMS DETAILS **/ private function getMenuItemRefresh() { + if (DEBUG_ENABLED && (($fargs=func_get_args())||$fargs='NOARGS')) + debug_log('Entered (%%)',129,0,__FILE__,__LINE__,__METHOD__,$fargs); + if (DEBUGTMP) printf('%s
',__METHOD__); $href = sprintf('cmd=template_engine&%s&junk=%s',$this->url_base,random_junk()); @@ -1131,6 +1166,9 @@ class TemplateRender extends PageRender { } protected function getMenuItemSwitchTemplate() { + if (DEBUG_ENABLED && (($fargs=func_get_args())||$fargs='NOARGS')) + debug_log('Entered (%%)',129,0,__FILE__,__LINE__,__METHOD__,$fargs); + $href = sprintf('cmd=template_engine&%s&template=',$this->url_base); if (isAjaxEnabled()) @@ -1142,6 +1180,9 @@ class TemplateRender extends PageRender { } protected function getMenuItemExportBase() { + if (DEBUG_ENABLED && (($fargs=func_get_args())||$fargs='NOARGS')) + debug_log('Entered (%%)',129,0,__FILE__,__LINE__,__METHOD__,$fargs); + if (DEBUGTMP) printf('%s
',__METHOD__); $href = sprintf('cmd=export_form&%s&scope=base',$this->url_base); @@ -1155,6 +1196,9 @@ class TemplateRender extends PageRender { } private function getMenuItemMove() { + if (DEBUG_ENABLED && (($fargs=func_get_args())||$fargs='NOARGS')) + debug_log('Entered (%%)',129,0,__FILE__,__LINE__,__METHOD__,$fargs); + if (DEBUGTMP) printf('%s
',__METHOD__); $href = sprintf('cmd=copy_form&%s',$this->url_base); @@ -1170,6 +1214,9 @@ class TemplateRender extends PageRender { } protected function getMenuItemInternalAttributes() { + if (DEBUG_ENABLED && (($fargs=func_get_args())||$fargs='NOARGS')) + debug_log('Entered (%%)',129,0,__FILE__,__LINE__,__METHOD__,$fargs); + if (DEBUGTMP) printf('%s
',__METHOD__); if (get_request('show_internal_attrs','REQUEST')) { @@ -1187,6 +1234,9 @@ class TemplateRender extends PageRender { } private function getMenuItemDelete() { + if (DEBUG_ENABLED && (($fargs=func_get_args())||$fargs='NOARGS')) + debug_log('Entered (%%)',129,0,__FILE__,__LINE__,__METHOD__,$fargs); + if (DEBUGTMP) printf('%s
',__METHOD__); $href = sprintf('cmd=delete_form&%s',$this->url_base); @@ -1201,6 +1251,9 @@ class TemplateRender extends PageRender { } protected function getMenuItemRename() { + if (DEBUG_ENABLED && (($fargs=func_get_args())||$fargs='NOARGS')) + debug_log('Entered (%%)',129,0,__FILE__,__LINE__,__METHOD__,$fargs); + if (DEBUGTMP) printf('%s
',__METHOD__); $href = sprintf('cmd=rename_form&%s&template=%s',$this->url_base,$this->template->getID()); @@ -1214,6 +1267,9 @@ class TemplateRender extends PageRender { } protected function getMenuItemCompare() { + if (DEBUG_ENABLED && (($fargs=func_get_args())||$fargs='NOARGS')) + debug_log('Entered (%%)',129,0,__FILE__,__LINE__,__METHOD__,$fargs); + if (DEBUGTMP) printf('%s
',__METHOD__); $href = sprintf('cmd=compare_form&%s',$this->url_base); @@ -1228,6 +1284,9 @@ class TemplateRender extends PageRender { } protected function getMenuItemCreate() { + if (DEBUG_ENABLED && (($fargs=func_get_args())||$fargs='NOARGS')) + debug_log('Entered (%%)',129,0,__FILE__,__LINE__,__METHOD__,$fargs); + if (DEBUGTMP) printf('%s
',__METHOD__); $href = sprintf('cmd=template_engine&server_id=%s&container=%s',$this->getServerID(),rawurlencode($this->template->getDN())); @@ -1242,6 +1301,9 @@ class TemplateRender extends PageRender { } protected function getMenuItemAddAttribute() { + if (DEBUG_ENABLED && (($fargs=func_get_args())||$fargs='NOARGS')) + debug_log('Entered (%%)',129,0,__FILE__,__LINE__,__METHOD__,$fargs); + if (DEBUGTMP) printf('%s
',__METHOD__); if (! $this->template->getAvailAttrs()) @@ -1260,6 +1322,9 @@ class TemplateRender extends PageRender { } protected function getMenuItemShowChildren($children_count) { + if (DEBUG_ENABLED && (($fargs=func_get_args())||$fargs='NOARGS')) + debug_log('Entered (%%)',129,0,__FILE__,__LINE__,__METHOD__,$fargs); + if (DEBUGTMP) printf('%s
',__METHOD__); $href = sprintf('cmd=query_engine&server_id=%s&filter=%s&base=%s&scope=one&query=none', @@ -1277,6 +1342,9 @@ class TemplateRender extends PageRender { } protected function getMenuItemExportSub() { + if (DEBUG_ENABLED && (($fargs=func_get_args())||$fargs='NOARGS')) + debug_log('Entered (%%)',129,0,__FILE__,__LINE__,__METHOD__,$fargs); + if (DEBUGTMP) printf('%s
',__METHOD__); $href = sprintf('cmd=export_form&%s&scope=%s',$this->url_base,'sub'); @@ -1935,12 +2003,18 @@ function fillRec(id,value) { } protected function getFocusJavascriptAttribute($attribute,$component) { + if (DEBUG_ENABLED && (($fargs=func_get_args())||$fargs='NOARGS')) + debug_log('Entered (%%)',129,0,__FILE__,__LINE__,__METHOD__,$fargs); + if (DEBUGTMP) printf('%s
',__METHOD__); return ''; } protected function getBlurJavascriptAttribute($attribute,$component) { + if (DEBUG_ENABLED && (($fargs=func_get_args())||$fargs='NOARGS')) + debug_log('Entered (%%)',129,0,__FILE__,__LINE__,__METHOD__,$fargs); + if (DEBUGTMP) printf('%s
',__METHOD__); $j = "\t".'fill('.$component.'.id,pla_getComponentValue('.$component.'));'."\n"; @@ -1993,6 +2067,9 @@ function fillRec(id,value) { } protected function getMenuItemAttribute($attribute,$action) { + if (DEBUG_ENABLED && (($fargs=func_get_args())||$fargs='NOARGS')) + debug_log('Entered (%%)',129,0,__FILE__,__LINE__,__METHOD__,$fargs); + if (DEBUGTMP) printf('%s
',__METHOD__); # If there is no DN, then this is a creating entry. @@ -2033,6 +2110,9 @@ function fillRec(id,value) { } protected function getAddValueMenuItemAttribute($attribute) { + if (DEBUG_ENABLED && (($fargs=func_get_args())||$fargs='NOARGS')) + debug_log('Entered (%%)',129,0,__FILE__,__LINE__,__METHOD__,$fargs); + if (DEBUGTMP) printf('%s
',__METHOD__); $href_parm = htmlspecialchars(sprintf('cmd=add_value_form&server_id=%s&dn=%s&attr=%s', @@ -2048,6 +2128,9 @@ function fillRec(id,value) { } protected function getModifyMemberMenuItemAttribute($attribute) { + if (DEBUG_ENABLED && (($fargs=func_get_args())||$fargs='NOARGS')) + debug_log('Entered (%%)',129,0,__FILE__,__LINE__,__METHOD__,$fargs); + if (DEBUGTMP) printf('%s
',__METHOD__); $href = sprintf('cmd=modify_member_form&server_id=%s&dn=%s&attr=%s', @@ -2064,6 +2147,9 @@ function fillRec(id,value) { } protected function getRenameMenuItemAttribute($attribute) { + if (DEBUG_ENABLED && (($fargs=func_get_args())||$fargs='NOARGS')) + debug_log('Entered (%%)',129,0,__FILE__,__LINE__,__METHOD__,$fargs); + if (DEBUGTMP) printf('%s
',__METHOD__); $href = sprintf('cmd.php?cmd=rename_form&server_id=%s&dn=%s&template=%s', @@ -2076,8 +2162,6 @@ function fillRec(id,value) { protected function drawValueAttribute($attribute,$i) { if (DEBUGTMP) printf('%s
',__METHOD__); - if (DEBUG_ENABLED) - debug_log('Entered with (%s,%d)',1,__FILE__,__LINE__,__METHOD__,$attribute->getName(),$i); $val = $attribute->getValue($i); @@ -2443,6 +2527,9 @@ function deleteAttribute(attrName,friendlyName,i) } protected function getMenuItemSelectionAttribute($attribute,$i) { + if (DEBUG_ENABLED && (($fargs=func_get_args())||$fargs='NOARGS')) + debug_log('Entered (%%)',129,0,__FILE__,__LINE__,__METHOD__,$fargs); + if (DEBUGTMP) printf('%s
',__METHOD__); switch ($i) { diff --git a/lib/Tree.php b/lib/Tree.php index a332147..81097ae 100644 --- a/lib/Tree.php +++ b/lib/Tree.php @@ -28,6 +28,9 @@ abstract class Tree { abstract public function draw(); protected function __construct($server_id) { + if (DEBUG_ENABLED && (($fargs=func_get_args())||$fargs='NOARGS')) + debug_log('Entered (%%)',33,0,__FILE__,__LINE__,__METHOD__,$fargs); + $this->server_id = $server_id; } @@ -38,6 +41,9 @@ abstract class Tree { * @return object Tree */ static public function getInstance($server_id) { + if (DEBUG_ENABLED && (($fargs=func_get_args())||$fargs='NOARGS')) + debug_log('Entered (%%)',33,0,__FILE__,__LINE__,__METHOD__,$fargs); + $tree = get_cached_item($server_id,'tree'); if (! $tree) { @@ -69,6 +75,9 @@ abstract class Tree { * @return int Server ID that this tree is for */ protected function getServerID() { + if (DEBUG_ENABLED && (($fargs=func_get_args())||$fargs='NOARGS')) + debug_log('Entered (%%)',33,1,__FILE__,__LINE__,__METHOD__,$fargs,$this->server_id); + return $this->server_id; } @@ -78,6 +87,9 @@ abstract class Tree { * @return object Server Object for this tree */ protected function getServer() { + if (DEBUG_ENABLED && (($fargs=func_get_args())||$fargs='NOARGS')) + debug_log('Entered (%%)',33,0,__FILE__,__LINE__,__METHOD__,$fargs); + return $_SESSION[APPCONFIG]->getServer($this->server_id); } @@ -87,6 +99,9 @@ abstract class Tree { * @return array Base DN entries */ public function getBaseEntries() { + if (DEBUG_ENABLED && (($fargs=func_get_args())||$fargs='NOARGS')) + debug_log('Entered (%%)',33,0,__FILE__,__LINE__,__METHOD__,$fargs); + $return = array(); foreach ($this->entries as $details) @@ -109,10 +124,13 @@ abstract class Tree { * @return dn Lowercase clean DN */ private function indexDN($dn) { + if (DEBUG_ENABLED && (($fargs=func_get_args())||$fargs='NOARGS')) + debug_log('Entered (%%)',33,0,__FILE__,__LINE__,__METHOD__,$fargs); + $index = strtolower(implode(',',pla_explode_dn($dn))); if (DEBUG_ENABLED) - debug_log('Entered with (%s), Result (%s)',1,__FILE__,__LINE__,__METHOD__,$dn,$index); + debug_log('Result (%s)',1,0,__FILE__,__LINE__,__METHOD__,$index); return $index; } @@ -124,6 +142,9 @@ abstract class Tree { * @return object Tree DN object */ public function getEntry($dn) { + if (DEBUG_ENABLED && (($fargs=func_get_args())||$fargs='NOARGS')) + debug_log('Entered (%%)',33,0,__FILE__,__LINE__,__METHOD__,$fargs); + $dnlower = $this->indexDN($dn); if (isset($this->entries[$dnlower])) @@ -140,8 +161,8 @@ abstract class Tree { * @param string $dn the dn of the entry to create */ public function addEntry($dn) { - if (DEBUG_ENABLED) - debug_log('Entered with (%s)',1,__FILE__,__LINE__,__METHOD__,$dn); + if (DEBUG_ENABLED && (($fargs=func_get_args())||$fargs='NOARGS')) + debug_log('Entered (%%)',33,0,__FILE__,__LINE__,__METHOD__,$fargs); $server = $this->getServer(); $dnlower = $this->indexDN($dn); @@ -153,7 +174,7 @@ abstract class Tree { debug_dump_backtrace('Calling add entry to an entry that ALREADY exists?',1); if (DEBUG_ENABLED) - debug_log('New ENTRY (%s).',64,__FILE__,__LINE__,__METHOD__,$dn); + debug_log('New ENTRY (%s).',64,0,__FILE__,__LINE__,__METHOD__,$dn); $tree_factory = new TreeItem($server->getIndex(),$dn); $tree_factory->setObjectClasses($server->getDNAttrValue($dn,'objectClass')); @@ -170,7 +191,7 @@ abstract class Tree { $parent_dn = $server->getContainer($dn); if (DEBUG_ENABLED) - debug_log('Parent DNs (%s)',64,__FILE__,__LINE__,__METHOD__,$parent_dn); + debug_log('Parent DNs (%s)',64,0,__FILE__,__LINE__,__METHOD__,$parent_dn); if ($parent_dn) { $parent_entry = $this->getEntry($parent_dn); @@ -193,8 +214,8 @@ abstract class Tree { * @param dn DN to remote */ public function delEntry($dn) { - if (DEBUG_ENABLED) - debug_log('Entered with (%s)',1,__FILE__,__LINE__,__METHOD__,$dn); + if (DEBUG_ENABLED && (($fargs=func_get_args())||$fargs='NOARGS')) + debug_log('Entered (%%)',33,0,__FILE__,__LINE__,__METHOD__,$fargs); $server = $this->getServer(); $dnlower = $this->indexDN($dn); @@ -217,8 +238,8 @@ abstract class Tree { * @param dn New DN */ public function renameEntry($dnOLD,$dnNEW) { - if (DEBUG_ENABLED) - debug_log('Entered with (%s,%s)',1,__FILE__,__LINE__,__METHOD__,$dnOLD,$dnNEW); + if (DEBUG_ENABLED && (($fargs=func_get_args())||$fargs='NOARGS')) + debug_log('Entered (%%)',33,0,__FILE__,__LINE__,__METHOD__,$fargs); $server = $this->getServer(); $dnlowerOLD = $this->indexDN($dnOLD); @@ -249,8 +270,8 @@ abstract class Tree { * @param boolean LDAP Size Limit */ public function readChildren($dn,$nolimit=false) { - if (DEBUG_ENABLED) - debug_log('Entered with (%s,%s)',1,__FILE__,__LINE__,__METHOD__,$dn,$nolimit); + if (DEBUG_ENABLED && (($fargs=func_get_args())||$fargs='NOARGS')) + debug_log('Entered (%%)',33,0,__FILE__,__LINE__,__METHOD__,$fargs); $server = $this->getServer(); $dnlower = $this->indexDN($dn); @@ -272,7 +293,7 @@ abstract class Tree { } if (DEBUG_ENABLED) - debug_log('Children of (%s) are (%s)',64,__FILE__,__LINE__,__METHOD__,$dn,$ldap['children']); + debug_log('Children of (%s) are (%s)',64,0,__FILE__,__LINE__,__METHOD__,$dn,$ldap['children']); # Relax our execution time, it might take some time to load this if ($nolimit) @@ -280,7 +301,7 @@ abstract class Tree { foreach ($ldap['children'] as $child) { if (DEBUG_ENABLED) - debug_log('Adding (%s)',64,__FILE__,__LINE__,__METHOD__,$child); + debug_log('Adding (%s)',64,0,__FILE__,__LINE__,__METHOD__,$child); if (! in_array($child,$this->entries[$dnlower]->getChildren())) $this->entries[$dnlower]->addChild($child); @@ -290,9 +311,6 @@ abstract class Tree { $this->entries[$dnlower]->setSizeLimited(); else $this->entries[$dnlower]->unsetSizeLimited(); - - if (DEBUG_ENABLED) - debug_log('Entered with (%s,%s), Returning ()',1,__FILE__,__LINE__,__METHOD__,$dn,$nolimit); } /** @@ -302,8 +320,8 @@ abstract class Tree { * @param boolean LDAP Size Limit */ protected function readChildrenNumber($dn,$nolimit=false) { - if (DEBUG_ENABLED) - debug_log('Entered with (%s,%s)',1,__FILE__,__LINE__,__METHOD__,$dn,$nolimit); + if (DEBUG_ENABLED && (($fargs=func_get_args())||$fargs='NOARGS')) + debug_log('Entered (%%)',33,0,__FILE__,__LINE__,__METHOD__,$fargs); $dnlower = $this->indexDN($dn); diff --git a/lib/TreeItem.php b/lib/TreeItem.php index 68d608b..d4b1b6d 100644 --- a/lib/TreeItem.php +++ b/lib/TreeItem.php @@ -37,6 +37,9 @@ class TreeItem { private $template = null; public function __construct($server_id,$dn) { + if (DEBUG_ENABLED && (($fargs=func_get_args())||$fargs='NOARGS')) + debug_log('Entered (%%)',33,0,__FILE__,__LINE__,__METHOD__,$fargs); + $this->server_id = $server_id; $this->dn = $dn; } @@ -47,6 +50,9 @@ class TreeItem { * @return DN The DN of this item. */ public function getDN() { + if (DEBUG_ENABLED && (($fargs=func_get_args())||$fargs='NOARGS')) + debug_log('Entered (%%)',33,1,__FILE__,__LINE__,__METHOD__,$fargs,$this->dn); + return $this->dn; } @@ -56,6 +62,9 @@ class TreeItem { * @return RDN The RDN of this items DN. */ public function getRDN() { + if (DEBUG_ENABLED && (($fargs=func_get_args())||$fargs='NOARGS')) + debug_log('Entered (%%)',33,0,__FILE__,__LINE__,__METHOD__,$fargs); + return get_rdn($this->getDn(),0,true); } @@ -63,6 +72,9 @@ class TreeItem { * Set this item as a LDAP base DN item. */ public function setBase() { + if (DEBUG_ENABLED && (($fargs=func_get_args())||$fargs='NOARGS')) + debug_log('Entered (%%)',33,1,__FILE__,__LINE__,__METHOD__,$fargs); + $this->base_entry = true; } @@ -70,18 +82,30 @@ class TreeItem { * Return if this item is a base DN item. */ public function isBaseDN() { + if (DEBUG_ENABLED && (($fargs=func_get_args())||$fargs='NOARGS')) + debug_log('Entered (%%)',33,1,__FILE__,__LINE__,__METHOD__,$fargs,$this->base_entry); + return $this->base_entry; } public function setObjectClasses($oc) { + if (DEBUG_ENABLED && (($fargs=func_get_args())||$fargs='NOARGS')) + debug_log('Entered (%%)',33,1,__FILE__,__LINE__,__METHOD__,$fargs); + $this->objectclasses = $oc; } public function getObjectClasses() { + if (DEBUG_ENABLED && (($fargs=func_get_args())||$fargs='NOARGS')) + debug_log('Entered (%%)',33,1,__FILE__,__LINE__,__METHOD__,$fargs,$this->objectclasses); + return $this->objectclasses; } public function isInLDAP() { + if (DEBUG_ENABLED && (($fargs=func_get_args())||$fargs='NOARGS')) + debug_log('Entered (%%)',33,0,__FILE__,__LINE__,__METHOD__,$fargs); + return count($this->objectclasses) ? true : false; } @@ -90,6 +114,9 @@ class TreeItem { * or an array of the dn of the children */ public function getChildren() { + if (DEBUG_ENABLED && (($fargs=func_get_args())||$fargs='NOARGS')) + debug_log('Entered (%%)',33,1,__FILE__,__LINE__,__METHOD__,$fargs,$this->children); + return $this->children; } @@ -99,17 +126,14 @@ class TreeItem { * @param DN The DN to add. */ public function addChild($dn) { - if (DEBUG_ENABLED) - debug_log('Entered with (%s)',1,__FILE__,__LINE__,__METHOD__,$dn); + if (DEBUG_ENABLED && (($fargs=func_get_args())||$fargs='NOARGS')) + debug_log('Entered (%%)',33,0,__FILE__,__LINE__,__METHOD__,$fargs); if (in_array($dn,$this->children)) return; array_push($this->children,$dn); usort($this->children,'pla_compare_dns'); - - if (DEBUG_ENABLED) - debug_log('Entered with (%s), Leaving ()',1,__FILE__,__LINE__,__METHOD__,$dn); } /** @@ -118,8 +142,8 @@ class TreeItem { * @param DN The DN to add. */ public function delChild($dn) { - if (DEBUG_ENABLED) - debug_log('Entered with (%s)',1,__FILE__,__LINE__,__METHOD__,$dn); + if (DEBUG_ENABLED && (($fargs=func_get_args())||$fargs='NOARGS')) + debug_log('Entered (%%)',33,0,__FILE__,__LINE__,__METHOD__,$fargs); if ($this->children) { # If the parent hasnt been opened in the tree, then there wont be any children. @@ -136,6 +160,9 @@ class TreeItem { * @param DN The DN to rename to. */ public function rename($dn) { + if (DEBUG_ENABLED && (($fargs=func_get_args())||$fargs='NOARGS')) + debug_log('Entered (%%)',33,0,__FILE__,__LINE__,__METHOD__,$fargs); + $this->dn = $dn; } @@ -143,6 +170,9 @@ class TreeItem { * Return if this item has been opened. */ public function isOpened() { + if (DEBUG_ENABLED && (($fargs=func_get_args())||$fargs='NOARGS')) + debug_log('Entered (%%)',33,1,__FILE__,__LINE__,__METHOD__,$fargs,$this->open); + return $this->open; } @@ -150,6 +180,9 @@ class TreeItem { * Mark this node as closed. */ public function close() { + if (DEBUG_ENABLED && (($fargs=func_get_args())||$fargs='NOARGS')) + debug_log('Entered (%%)',33,0,__FILE__,__LINE__,__METHOD__,$fargs); + $this->open = false; } @@ -157,6 +190,9 @@ class TreeItem { * Opens the node ; the children of the node must have been defined */ public function open() { + if (DEBUG_ENABLED && (($fargs=func_get_args())||$fargs='NOARGS')) + debug_log('Entered (%%)',33,0,__FILE__,__LINE__,__METHOD__,$fargs); + $this->open = true; } @@ -164,6 +200,9 @@ class TreeItem { * Mark this node as a leaf. */ public function setLeaf() { + if (DEBUG_ENABLED && (($fargs=func_get_args())||$fargs='NOARGS')) + debug_log('Entered (%%)',33,1,__FILE__,__LINE__,__METHOD__,$fargs); + $this->leaf = true; } @@ -171,6 +210,9 @@ class TreeItem { * Return if this node is a leaf. */ public function isLeaf() { + if (DEBUG_ENABLED && (($fargs=func_get_args())||$fargs='NOARGS')) + debug_log('Entered (%%)',33,1,__FILE__,__LINE__,__METHOD__,$fargs,$this->leaf); + return $this->leaf; } @@ -179,6 +221,9 @@ class TreeItem { * If the icon hasnt been set, it will call get_icon() */ public function getIcon() { + if (DEBUG_ENABLED && (($fargs=func_get_args())||$fargs='NOARGS')) + debug_log('Entered (%%)',33,1,__FILE__,__LINE__,__METHOD__,$fargs,$this->icon); + if (! $this->icon) $this->icon = get_icon($this->server_id,$this->dn,$this->objectclasses); @@ -189,6 +234,9 @@ class TreeItem { * Mark this node as a size limited (it wont have all its children). */ public function setSizeLimited() { + if (DEBUG_ENABLED && (($fargs=func_get_args())||$fargs='NOARGS')) + debug_log('Entered (%%)',33,1,__FILE__,__LINE__,__METHOD__,$fargs); + $this->size_limited = true; } @@ -196,6 +244,9 @@ class TreeItem { * Clear the size limited flag. */ public function unsetSizeLimited() { + if (DEBUG_ENABLED && (($fargs=func_get_args())||$fargs='NOARGS')) + debug_log('Entered (%%)',33,0,__FILE__,__LINE__,__METHOD__,$fargs); + $this->size_limited = false; } @@ -203,14 +254,23 @@ class TreeItem { * Return if this node has hit an LDAP size limit (and thus doesnt have all its children). */ public function isSizeLimited() { + if (DEBUG_ENABLED && (($fargs=func_get_args())||$fargs='NOARGS')) + debug_log('Entered (%%)',33,0,__FILE__,__LINE__,__METHOD__,$fargs); + return $this->size_limited; } public function setTemplate($template) { + if (DEBUG_ENABLED && (($fargs=func_get_args())||$fargs='NOARGS')) + debug_log('Entered (%%)',33,1,__FILE__,__LINE__,__METHOD__,$fargs); + $this->template = $template; } public function getTemplate() { + if (DEBUG_ENABLED && (($fargs=func_get_args())||$fargs='NOARGS')) + debug_log('Entered (%%)',33,0,__FILE__,__LINE__,__METHOD__,$fargs); + return $this->template; } } diff --git a/lib/Visitor.php b/lib/Visitor.php index 806ba92..137f8e4 100644 --- a/lib/Visitor.php +++ b/lib/Visitor.php @@ -24,6 +24,9 @@ abstract class Visitor { protected $server_id; public function __call($method,$args) { + if (DEBUG_ENABLED && (($fargs=func_get_args())||$fargs='NOARGS')) + debug_log('Entered (%%)',129,0,__FILE__,__LINE__,__METHOD__,$fargs); + if (! in_array($method,array('get','visit','draw'))) debug_dump_backtrace(sprintf('Incorrect use of method loading [%s]',$method),1); @@ -75,7 +78,7 @@ abstract class Visitor { return; } elseif (DEBUG_ENABLED) { - debug_log('Doesnt exist param (%s,%s)',1,__FILE__,__LINE__,__METHOD__,$method,$fnct); + debug_log('Doesnt exist param (%s,%s)',1,0,__FILE__,__LINE__,__METHOD__,$method,$fnct); } printf('NO Methods: %s
',implode('|',$methods)); @@ -87,6 +90,9 @@ abstract class Visitor { * @return int Server ID */ public function getServerID() { + if (DEBUG_ENABLED && (($fargs=func_get_args())||$fargs='NOARGS')) + debug_log('Entered (%%)',129,1,__FILE__,__LINE__,__METHOD__,$fargs,$this->server_id); + if (isset($this->server_id)) return $this->server_id; else @@ -99,6 +105,9 @@ abstract class Visitor { * @return object DataStore Server */ protected function getServer() { + if (DEBUG_ENABLED && (($fargs=func_get_args())||$fargs='NOARGS')) + debug_log('Entered (%%)',129,0,__FILE__,__LINE__,__METHOD__,$fargs); + return $_SESSION[APPCONFIG]->getServer($this->getServerID()); } } diff --git a/lib/common.php b/lib/common.php index 6c22d00..08c4424 100644 --- a/lib/common.php +++ b/lib/common.php @@ -213,7 +213,7 @@ else define('DEBUG_ENABLED',0); if (DEBUG_ENABLED) - debug_log('Application (%s) initialised and starting with (%s).',1,__FILE__,__LINE__,__METHOD__, + debug_log('Application (%s) initialised and starting with (%s).',1,0,__FILE__,__LINE__,__METHOD__, app_version(),$_REQUEST); # Set our PHP timelimit. diff --git a/lib/config_default.php b/lib/config_default.php index a4df4a2..3607717 100644 --- a/lib/config_default.php +++ b/lib/config_default.php @@ -616,6 +616,9 @@ class Config { * Function to check and warn about any unusual defined variables. */ public function CheckCustom() { + if (defined('DEBUG_ENABLED') && DEBUG_ENABLED && (($fargs=func_get_args())||$fargs='NOARGS')) + debug_log('Entered (%%)',3,0,__FILE__,__LINE__,__METHOD__,$fargs); + if (isset($this->custom)) { foreach ($this->custom as $masterkey => $masterdetails) { @@ -648,6 +651,9 @@ class Config { * Get a list of available commands. */ public function getCommandList() { + if (DEBUG_ENABLED && (($fargs=func_get_args())||$fargs='NOARGS')) + debug_log('Entered (%%)',3,0,__FILE__,__LINE__,__METHOD__,$fargs); + $config = $this->getConfigArray(false); masort($config['command'],'summary'); @@ -662,6 +668,9 @@ class Config { * Simple ACL to see if commands can be run */ public function isCommandAvailable($index='cmd') { + if (DEBUG_ENABLED && (($fargs=func_get_args())||$fargs='NOARGS')) + debug_log('Entered (%%)',3,0,__FILE__,__LINE__,__METHOD__,$fargs); + $a = func_get_args(); array_shift($a); $a = $a[0]; @@ -676,6 +685,9 @@ class Config { } public function configDefinition($key,$index,$config) { + if (DEBUG_ENABLED && (($fargs=func_get_args())||$fargs='NOARGS')) + debug_log('Entered (%%)',3,0,__FILE__,__LINE__,__METHOD__,$fargs); + if (! is_array($config) || ! array_key_exists('desc',$config) || ! array_key_exists('default',$config)) return; @@ -690,8 +702,8 @@ class Config { * Return the friendly attributes names */ private function getFriendlyAttrs() { - if (defined('DEBUG_ENABLED') && DEBUG_ENABLED) - debug_log('Entered with ()',1,__FILE__,__LINE__,__METHOD__); + if (DEBUG_ENABLED && (($fargs=func_get_args())||$fargs='NOARGS')) + debug_log('Entered (%%)',3,0,__FILE__,__LINE__,__METHOD__,$fargs); return array_change_key_case($this->getValue('appearance','friendly_attrs')); } @@ -704,6 +716,9 @@ class Config { * @return string friendly name|attribute */ public function getFriendlyName($attr) { + if (DEBUG_ENABLED && (($fargs=func_get_args())||$fargs='NOARGS')) + debug_log('Entered (%%)',3,0,__FILE__,__LINE__,__METHOD__,$fargs); + static $friendly_attrs; if (! $friendly_attrs) @@ -729,6 +744,9 @@ class Config { * @return boolean true|false */ public function haveFriendlyName($attr) { + if (DEBUG_ENABLED && (($fargs=func_get_args())||$fargs='NOARGS')) + debug_log('Entered (%%)',3,0,__FILE__,__LINE__,__METHOD__,$fargs); + return $attr->getName(false) != $this->getFriendlyName($attr); } @@ -739,6 +757,9 @@ class Config { * @return string html for the friendly name. */ public function getFriendlyHTML($attr) { + if (DEBUG_ENABLED && (($fargs=func_get_args())||$fargs='NOARGS')) + debug_log('Entered (%%)',3,0,__FILE__,__LINE__,__METHOD__,$fargs); + if ($this->haveFriendlyName($attr)) return sprintf('%s', _('Alias for'),$attr->getName(false),$this->getFriendlyName($attr)); @@ -759,6 +780,9 @@ class Config { * @param boolean $visible - Only return visible servers */ public function getServerList($visible=true) { + if (DEBUG_ENABLED && (($fargs=func_get_args())||$fargs='NOARGS')) + debug_log('Entered (%%)',3,0,__FILE__,__LINE__,__METHOD__,$fargs); + return $this->servers->getServerList($visible); } } diff --git a/lib/ds.php b/lib/ds.php index 66f0e9e..2cb3206 100644 --- a/lib/ds.php +++ b/lib/ds.php @@ -70,6 +70,9 @@ abstract class DS { * Return a configuration value */ public function getValue($key,$setting,$fatal=true) { + if (defined('DEBUG_ENABLED') && DEBUG_ENABLED && (($fargs=func_get_args())||$fargs='NOARGS')) + debug_log('Entered (%%)',17,1,__FILE__,__LINE__,__METHOD__,$fargs); + if (isset($this->custom->{$key}[$setting])) return $this->custom->{$key}[$setting]; @@ -115,6 +118,9 @@ abstract class DS { * Get the name of this datastore */ public function getName() { + if (DEBUG_ENABLED && (($fargs=func_get_args())||$fargs='NOARGS')) + debug_log('Entered (%%)',17,0,__FILE__,__LINE__,__METHOD__,$fargs); + return $this->getValue('server','name'); } @@ -125,6 +131,9 @@ abstract class DS { * Return the authentication type for this object */ public function getAuthType() { + if (DEBUG_ENABLED && (($fargs=func_get_args())||$fargs='NOARGS')) + debug_log('Entered (%%)',17,0,__FILE__,__LINE__,__METHOD__,$fargs); + switch ($this->getValue('login','auth_type')) { case 'config': case 'http': @@ -144,6 +153,9 @@ abstract class DS { * If this returns '', we are logged in with anonymous */ public function getLogin($method=null) { + if (DEBUG_ENABLED && (($fargs=func_get_args())||$fargs='NOARGS')) + debug_log('Entered (%%)',17,0,__FILE__,__LINE__,__METHOD__,$fargs); + $method = $this->getMethod($method); # For anonymous binds @@ -182,6 +194,9 @@ abstract class DS { * Set the login details of the user logged into this datastore's connection method */ protected function setLogin($user,$pass,$method=null) { + if (DEBUG_ENABLED && (($fargs=func_get_args())||$fargs='NOARGS')) + debug_log('Entered (%%)',17,0,__FILE__,__LINE__,__METHOD__,$fargs); + $method = $this->getMethod($method); switch ($this->getAuthType()) { @@ -208,6 +223,9 @@ abstract class DS { * Get the login password of the user logged into this datastore's connection method */ protected function getPassword($method=null) { + if (DEBUG_ENABLED && (($fargs=func_get_args())||$fargs='NOARGS')) + debug_log('Entered (%%)',17,0,__FILE__,__LINE__,__METHOD__,$fargs); + $method = $this->getMethod($method); # For anonymous binds @@ -241,6 +259,9 @@ abstract class DS { * Return if this datastore's connection method has been logged into */ public function isLoggedIn($method=null) { + if (DEBUG_ENABLED && (($fargs=func_get_args())||$fargs='NOARGS')) + debug_log('Entered (%%)',17,0,__FILE__,__LINE__,__METHOD__,$fargs); + static $CACHE = array(); $method = $this->getMethod($method); @@ -319,6 +340,9 @@ abstract class DS { * Logout of this datastore's connection method */ public function logout($method=null) { + if (DEBUG_ENABLED && (($fargs=func_get_args())||$fargs='NOARGS')) + debug_log('Entered (%%)',17,0,__FILE__,__LINE__,__METHOD__,$fargs); + $method = $this->getMethod($method); unset ($_SESSION['cache'][$this->index]); @@ -344,10 +368,16 @@ abstract class DS { * Functions that return the condition of the datasource */ public function isVisible() { + if (DEBUG_ENABLED && (($fargs=func_get_args())||$fargs='NOARGS')) + debug_log('Entered (%%)',17,0,__FILE__,__LINE__,__METHOD__,$fargs); + return $this->getValue('server','visible'); } public function isReadOnly() { + if (DEBUG_ENABLED && (($fargs=func_get_args())||$fargs='NOARGS')) + debug_log('Entered (%%)',17,0,__FILE__,__LINE__,__METHOD__,$fargs); + if (! trim($this->getLogin(null)) && $_SESSION[APPCONFIG]->getValue('appearance','anonymous_bind_implies_read_only')) return true; else @@ -355,6 +385,9 @@ abstract class DS { } public function getIndex() { + if (defined('DEBUG_ENABLED') && DEBUG_ENABLED && (($fargs=func_get_args())||$fargs='NOARGS')) + debug_log('Entered (%%)',17,1,__FILE__,__LINE__,__METHOD__,$fargs,$this->index); + return $this->index; } @@ -368,6 +401,9 @@ abstract class DS { * @return string Connection Method */ protected function getMethod($method=null) { + if (DEBUG_ENABLED && (($fargs=func_get_args())||$fargs='NOARGS')) + debug_log('Entered (%%)',17,0,__FILE__,__LINE__,__METHOD__,$fargs); + static $CACHE = array(); # Immediately return if method is set. @@ -390,6 +426,9 @@ abstract class DS { * This method should be overridden in application specific ds files */ public function isSessionValid() { + if (DEBUG_ENABLED && (($fargs=func_get_args())||$fargs='NOARGS')) + debug_log('Entered (%%)',17,0,__FILE__,__LINE__,__METHOD__,$fargs,true); + return true; } @@ -398,6 +437,9 @@ abstract class DS { * this function will return null. */ public function inactivityTime() { + if (DEBUG_ENABLED && (($fargs=func_get_args())||$fargs='NOARGS')) + debug_log('Entered (%%)',17,0,__FILE__,__LINE__,__METHOD__,$fargs); + if ($this->isLoggedIn() && ! in_array($this->getAuthType(),array('config','http'))) return time()+($this->getValue('login','timeout')*60); else @@ -511,10 +553,6 @@ class Datastore { * Set values for a database object. */ public function setValue($key,$setting,$value) { - if (defined('DEBUG_ENABLED') && (DEBUG_ENABLED)) - debug_log('Entered with (%s,%s,%s)',3,__FILE__,__LINE__,__METHOD__, - $key,$setting,$value); - if (! $this->objects[$this->index]->isDefaultKey($key)) error("ERROR: Setting a key [$key] that isnt predefined.",'error',true); @@ -539,14 +577,14 @@ class Datastore { * @return array list of all configured servers. */ public function getServerList($isVisible=true) { + if (defined('DEBUG_ENABLED') && DEBUG_ENABLED && (($fargs=func_get_args())||$fargs='NOARGS')) + debug_log('Entered (%%)',17,0,__FILE__,__LINE__,__METHOD__,$fargs); + static $CACHE; if (isset($CACHE[$isVisible])) return $CACHE[$isVisible]; - if (defined('DEBUG_ENABLED') && DEBUG_ENABLED) - debug_log('Entered with (%s)',3,__FILE__,__LINE__,__METHOD__,$isVisible); - $CACHE[$isVisible] = array(); # Debugging incase objects is not set. @@ -560,10 +598,6 @@ class Datastore { if (! $isVisible || ($isVisible && $server->getValue('server','visible'))) $CACHE[$isVisible][$id] = $server; - if (defined('DEBUG_ENABLED') && DEBUG_ENABLED) - debug_log('Entered with (%s), Returning (%s)',3,__FILE__,__LINE__,__METHOD__, - $isVisible,$CACHE); - return $CACHE[$isVisible]; } @@ -574,8 +608,8 @@ class Datastore { * @return object Datastore instance object. */ public function Instance($index=null) { - if (defined('DEBUG_ENABLED') && DEBUG_ENABLED) - debug_log('Entered with (%s)',3,__FILE__,__LINE__,__METHOD__,$index); + if (defined('DEBUG_ENABLED') && DEBUG_ENABLED && (($fargs=func_get_args())||$fargs='NOARGS')) + debug_log('Entered (%%)',17,0,__FILE__,__LINE__,__METHOD__,$fargs); # If no index defined, then pick the lowest one. if (is_null($index)) @@ -585,7 +619,7 @@ class Datastore { debug_dump_backtrace("Error: Datastore instance [$index] doesnt exist?",1); if (defined('DEBUG_ENABLED') && DEBUG_ENABLED) - debug_log('Returning instance of database (%s)',3,__FILE__,__LINE__,__METHOD__,$index); + debug_log('Returning instance of database (%s)',3,0,__FILE__,__LINE__,__METHOD__,$index); return $this->objects[$index]; } @@ -597,8 +631,8 @@ class Datastore { * @return object Datastore instance object. */ public function InstanceName($name=null) { - if (DEBUG_ENABLED) - debug_log('Entered with (%s)',3,__FILE__,__LINE__,__METHOD__,$name); + if (DEBUG_ENABLED && (($fargs=func_get_args())||$fargs='NOARGS')) + debug_log('Entered (%%)',17,0,__FILE__,__LINE__,__METHOD__,$fargs); foreach ($this->getServerList(false) as $index) if ($this->objects[$index]->getName() == $name) @@ -615,8 +649,8 @@ class Datastore { * @return object Datastore instance object. */ public function InstanceId($id=null) { - if (DEBUG_ENABLED) - debug_log('Entered with (%s)',3,__FILE__,__LINE__,__METHOD__,$id); + if (DEBUG_ENABLED && (($fargs=func_get_args())||$fargs='NOARGS')) + debug_log('Entered (%%)',17,0,__FILE__,__LINE__,__METHOD__,$fargs); foreach ($this->getServerList(false) as $index) if ($this->objects[$index->getIndex()]->getValue('server','id') == $id) diff --git a/lib/ds_ldap.php b/lib/ds_ldap.php index adaef61..e649025 100644 --- a/lib/ds_ldap.php +++ b/lib/ds_ldap.php @@ -25,6 +25,9 @@ class ldap extends DS { private $force_may = array(); public function __construct($index) { + if (defined('DEBUG_ENABLED') && DEBUG_ENABLED && (($fargs=func_get_args())||$fargs='NOARGS')) + debug_log('Entered (%%)',17,0,__FILE__,__LINE__,__METHOD__,$fargs); + $this->index = $index; $this->type = 'ldap'; @@ -129,8 +132,8 @@ class ldap extends DS { * @return resource|null Connection resource if successful, null if not. */ protected function connect($method,$debug=false,$new=false) { - if (DEBUG_ENABLED) - debug_log('Entered with (%s)',17,__FILE__,__LINE__,__METHOD__,$method); + if (DEBUG_ENABLED && (($fargs=func_get_args())||$fargs='NOARGS')) + debug_log('Entered (%%)',17,0,__FILE__,__LINE__,__METHOD__,$fargs); static $CACHE = array(); @@ -162,7 +165,7 @@ class ldap extends DS { # No identifiable connection exists, lets create a new one. if (DEBUG_ENABLED) - debug_log('Creating NEW connection [%s] for index [%s]',16,__FILE__,__LINE__,__METHOD__, + debug_log('Creating NEW connection [%s] for index [%s]',16,0,__FILE__,__LINE__,__METHOD__, $method,$this->index); if (function_exists('run_hook')) @@ -176,7 +179,7 @@ class ldap extends DS { $CACHE[$this->index][$method] = $resource; if (DEBUG_ENABLED) - debug_log('LDAP Resource [%s], Host [%s], Port [%s]',16,__FILE__,__LINE__,__METHOD__, + debug_log('LDAP Resource [%s], Host [%s], Port [%s]',16,0,__FILE__,__LINE__,__METHOD__, $resource,$this->getValue('server','host'),$this->getValue('server','port')); if (! is_resource($resource)) @@ -206,11 +209,11 @@ class ldap extends DS { debug_dump(array('method'=>$method,'bind'=>$bind,'USER'=>$_SESSION['USER'])); if (DEBUG_ENABLED) - debug_log('Resource [%s], Bind Result [%s]',16,__FILE__,__LINE__,__METHOD__,$resource,$bind); + debug_log('Resource [%s], Bind Result [%s]',16,0,__FILE__,__LINE__,__METHOD__,$resource,$bind); if (! $bind['result']) { if (DEBUG_ENABLED) - debug_log('Leaving with FALSE, bind FAILed',16,__FILE__,__LINE__,__METHOD__); + debug_log('Leaving with FALSE, bind FAILed',16,0,__FILE__,__LINE__,__METHOD__); $this->noconnect = true; @@ -248,6 +251,9 @@ class ldap extends DS { * @todo isLoginStringEnabled() based logins */ public function login($user=null,$pass=null,$method=null,$new=false) { + if (DEBUG_ENABLED && (($fargs=func_get_args())||$fargs='NOARGS')) + debug_log('Entered (%%)',17,0,__FILE__,__LINE__,__METHOD__,$fargs); + $userDN = null; # Get the userDN from the username. @@ -306,6 +312,9 @@ class ldap extends DS { * @return array|null Results of query. */ public function query($query,$method,$index=null,$debug=false) { + if (DEBUG_ENABLED && (($fargs=func_get_args())||$fargs='NOARGS')) + debug_log('Entered (%%)',17,0,__FILE__,__LINE__,__METHOD__,$fargs); + $size_limit = 500; $time_limit = 0; $attrs_only = 0; @@ -347,11 +356,7 @@ class ldap extends DS { } if (DEBUG_ENABLED) - debug_log('Entered with (%s,%s,%s)',17,__FILE__,__LINE__,__METHOD__, - $query,$index,$debug); - - if (DEBUG_ENABLED) - debug_log('%s search PREPARE.',16,__FILE__,__LINE__,__METHOD__,$query['scope']); + debug_log('%s search PREPARE.',16,0,__FILE__,__LINE__,__METHOD__,$query['scope']); if ($debug) debug_dump(array('query'=>$query,'server'=>$this->getIndex(),'con'=>$this->connect($method))); @@ -377,7 +382,7 @@ class ldap extends DS { debug_dump(array('method'=>$method,'search'=>$search,'error'=>$this->getErrorMessage())); if (DEBUG_ENABLED) - debug_log('Search scope [%s] base [%s] filter [%s] attrs [%s] COMPLETE (%s).',16,__FILE__,__LINE__,__METHOD__, + debug_log('Search scope [%s] base [%s] filter [%s] attrs [%s] COMPLETE (%s).',16,0,__FILE__,__LINE__,__METHOD__, $query['scope'],$query['base'],$query['filter'],$query['attrs'],is_null($search)); if (! $search) @@ -429,7 +434,7 @@ class ldap extends DS { } if (DEBUG_ENABLED) - debug_log('Returning (%s)',17,__FILE__,__LINE__,__METHOD__,$return); + debug_log('Returning (%s)',17,0,__FILE__,__LINE__,__METHOD__,$return); return $return; } @@ -440,6 +445,9 @@ class ldap extends DS { * @param string Which connection method resource to use */ public function getErrorMessage($method=null) { + if (DEBUG_ENABLED && (($fargs=func_get_args())||$fargs='NOARGS')) + debug_log('Entered (%%)',17,0,__FILE__,__LINE__,__METHOD__,$fargs); + return ldap_error($this->connect($method)); } @@ -449,6 +457,9 @@ class ldap extends DS { * @param string Which connection method resource to use */ public function getErrorNum($method=null) { + if (DEBUG_ENABLED && (($fargs=func_get_args())||$fargs='NOARGS')) + debug_log('Entered (%%)',17,0,__FILE__,__LINE__,__METHOD__,$fargs); + return ldap_errno($this->connect($method)); } @@ -461,6 +472,9 @@ class ldap extends DS { * @param string Which connection method resource to use */ public function getLoginID($user,$method=null) { + if (DEBUG_ENABLED && (($fargs=func_get_args())||$fargs='NOARGS')) + debug_log('Entered (%%)',17,0,__FILE__,__LINE__,__METHOD__,$fargs); + $query['filter'] = sprintf('(&(uid=%s))',$user); $query['attrs'] = array('dn'); $result = $this->query($query,$method); @@ -479,6 +493,9 @@ class ldap extends DS { * Return if anonymous bind is allowed in the configuration */ public function isAnonBindAllowed() { + if (DEBUG_ENABLED && (($fargs=func_get_args())||$fargs='NOARGS')) + debug_log('Entered (%%)',17,0,__FILE__,__LINE__,__METHOD__,$fargs); + return $this->getValue('login','anon_bind'); } @@ -493,6 +510,9 @@ class ldap extends DS { * @return boolean */ private function isTLSEnabled() { + if (DEBUG_ENABLED && (($fargs=func_get_args())||$fargs='NOARGS')) + debug_log('Entered (%%)',17,0,__FILE__,__LINE__,__METHOD__,$fargs); + if ($this->getValue('server','tls') && ! function_exists('ldap_start_tls')) { error(_('TLS has been enabled in your config, but your PHP install does not support TLS. TLS will be disabled.'),'warn'); return false; @@ -505,6 +525,9 @@ class ldap extends DS { * If TLS is configured, then start it */ private function startTLS($resource) { + if (DEBUG_ENABLED && (($fargs=func_get_args())||$fargs='NOARGS')) + debug_log('Entered (%%)',17,0,__FILE__,__LINE__,__METHOD__,$fargs); + if (! $this->getValue('server','tls') || (function_exists('ldap_start_tls') && ! ldap_start_tls($resource))) error(_('Could not start TLS. Please check your LDAP server configuration.'),'error',null,true); } @@ -520,6 +543,9 @@ class ldap extends DS { * @return boolean */ private function isSASLEnabled() { + if (DEBUG_ENABLED && (($fargs=func_get_args())||$fargs='NOARGS')) + debug_log('Entered (%%)',17,0,__FILE__,__LINE__,__METHOD__,$fargs); + if ($this->getValue('server','sasl') && ! function_exists('ldap_sasl_bind')) { error(_('SASL has been enabled in your config, but your PHP install does not support SASL. SASL will be disabled.'),'warn'); return false; @@ -535,6 +561,9 @@ class ldap extends DS { * @todo This has not been tested, please let the developers know if this function works as expected. */ private function startSASL($resource,$method) { + if (DEBUG_ENABLED && (($fargs=func_get_args())||$fargs='NOARGS')) + debug_log('Entered (%%)',17,0,__FILE__,__LINE__,__METHOD__,$fargs); + error(__METHOD__.' has NOT been tested, please let us know if it works and which version of PHP you are using.','info'); static $CACHE = array(); @@ -551,7 +580,7 @@ class ldap extends DS { if (! trim($this->getValue('sasl','authz_id'))) { if (DEBUG_ENABLED) - debug_log('Rewriting bind DN [%s] -> authz_id with regex [%s] and replacement [%s].',9,__FILE__,__LINE__,__METHOD__, + debug_log('Rewriting bind DN [%s] -> authz_id with regex [%s] and replacement [%s].',9,0,__FILE__,__LINE__,__METHOD__, $CACHE['login_dn'], $this->getValue('sasl','authz_id_regex'), $this->getValue('sasl','authz_id_replacement')); @@ -566,7 +595,7 @@ class ldap extends DS { 'error','index.php'); if (DEBUG_ENABLED) - debug_log('Resource [%s], SASL OPTIONS: mech [%s], realm [%s], authz_id [%s], props [%s]',9,__FILE__,__LINE__,__METHOD__, + debug_log('Resource [%s], SASL OPTIONS: mech [%s], realm [%s], authz_id [%s], props [%s]',9,0,__FILE__,__LINE__,__METHOD__, $resource, $this->getValue('sasl','mech'), $this->getValue('sasl','realm'), @@ -595,6 +624,9 @@ class ldap extends DS { * @return boolean */ private function isProxyEnabled() { + if (DEBUG_ENABLED && (($fargs=func_get_args())||$fargs='NOARGS')) + debug_log('Entered (%%)',17,0,__FILE__,__LINE__,__METHOD__,$fargs); + return $this->getValue('login','auth_type') == 'proxy' ? true : false; } @@ -602,6 +634,9 @@ class ldap extends DS { * If PROXY AUTH is configured, then start it */ private function startProxy($resource,$method) { + if (DEBUG_ENABLED && (($fargs=func_get_args())||$fargs='NOARGS')) + debug_log('Entered (%%)',17,0,__FILE__,__LINE__,__METHOD__,$fargs); + $rootdse = $this->getRootDSE(); if (! (isset($rootdse['supportedcontrol']) && in_array('2.16.840.1.113730.3.4.18',$rootdse['supportedcontrol']))) { @@ -688,6 +723,9 @@ class ldap extends DS { * Modify attributes of a DN */ public function modify($dn,$attrs,$method=null) { + if (DEBUG_ENABLED && (($fargs=func_get_args())||$fargs='NOARGS')) + debug_log('Entered (%%)',17,0,__FILE__,__LINE__,__METHOD__,$fargs); + # We need to supress the error here - programming should detect and report it. return @ldap_mod_replace($this->connect($method),$dn,$attrs); } @@ -708,8 +746,8 @@ class ldap extends DS { * @todo Sort the entries, so that they are in the correct DN order. */ public function getBaseDN($method=null) { - if (DEBUG_ENABLED) - debug_log('Entered with (%s)',17,__FILE__,__LINE__,__METHOD__,$method); + if (DEBUG_ENABLED && (($fargs=func_get_args())||$fargs='NOARGS')) + debug_log('Entered (%%)',17,0,__FILE__,__LINE__,__METHOD__,$fargs); static $CACHE; @@ -722,14 +760,14 @@ class ldap extends DS { # If the base is set in the configuration file, then just return that. if (count($this->getValue('server','base'))) { if (DEBUG_ENABLED) - debug_log('Return BaseDN from Config [%s]',17,__FILE__,__LINE__,__METHOD__,implode('|',$this->getValue('server','base'))); + debug_log('Return BaseDN from Config [%s]',17,0,__FILE__,__LINE__,__METHOD__,implode('|',$this->getValue('server','base'))); $CACHE[$this->index][$method] = $this->getValue('server','base'); # We need to figure it out. } else { if (DEBUG_ENABLED) - debug_log('Connect to LDAP to find BaseDN',80,__FILE__,__LINE__,__METHOD__); + debug_log('Connect to LDAP to find BaseDN',80,0,__FILE__,__LINE__,__METHOD__); # Set this to empty, in case we loop back here looking for the baseDNs $CACHE[$this->index][$method] = array(); @@ -738,7 +776,7 @@ class ldap extends DS { if (isset($results['namingcontexts'])) { if (DEBUG_ENABLED) - debug_log('LDAP Entries:%s',80,__FILE__,__LINE__,__METHOD__,implode('|',$results['namingcontexts'])); + debug_log('LDAP Entries:%s',80,0,__FILE__,__LINE__,__METHOD__,implode('|',$results['namingcontexts'])); $result = $results['namingcontexts']; } @@ -758,8 +796,8 @@ class ldap extends DS { * @return boolean */ public function dnExists($dn,$method=null) { - if (DEBUG_ENABLED) - debug_log('Search for (%s)',16,__FILE__,__LINE__,__METHOD__,$dn); + if (DEBUG_ENABLED && (($fargs=func_get_args())||$fargs='NOARGS')) + debug_log('Entered (%%)',17,0,__FILE__,__LINE__,__METHOD__,$fargs); $results = $this->getDNAttrValues($dn,$method); @@ -776,6 +814,9 @@ class ldap extends DS { * @return string The container */ public function getContainerTop($dn) { + if (DEBUG_ENABLED && (($fargs=func_get_args())||$fargs='NOARGS')) + debug_log('Entered (%%)',17,0,__FILE__,__LINE__,__METHOD__,$fargs); + $return = $dn; foreach ($this->getBaseDN() as $base) { @@ -786,7 +827,7 @@ class ldap extends DS { } if (DEBUG_ENABLED) - debug_log('Entered with (%s), Returning (%s)',17,__FILE__,__LINE__,__METHOD__,$dn,$return); + debug_log('Returning (%s)',17,0,__FILE__,__LINE__,__METHOD__,$return); return $return; } @@ -799,8 +840,8 @@ class ldap extends DS { * @return string The container */ public function getContainerPath($dn,$path='..') { - if (DEBUG_ENABLED) - debug_log('Entered with (%s,%s)',17,__FILE__,__LINE__,__METHOD__,$dn,$path); + if (DEBUG_ENABLED && (($fargs=func_get_args())||$fargs='NOARGS')) + debug_log('Entered (%%)',17,0,__FILE__,__LINE__,__METHOD__,$fargs); $top = $this->getContainerTop($dn); @@ -846,23 +887,25 @@ class ldap extends DS { * @return string The container */ public function getContainer($dn) { + if (DEBUG_ENABLED && (($fargs=func_get_args())||$fargs='NOARGS')) + debug_log('Entered (%%)',17,0,__FILE__,__LINE__,__METHOD__,$fargs); + $parts = $this->explodeDN($dn); if (count($parts) <= 1) - $container = null; + $return = null; else { - $container = $parts[1]; + $return = $parts[1]; for ($i=2;$iescapeDN($dn),1); if (! $result[$with_attributes]) { if (DEBUG_ENABLED) - debug_log('Returning NULL - NO result.',1,__FILE__,__LINE__,__METHOD__); + debug_log('Returning NULL - NO result.',1,0,__FILE__,__LINE__,__METHOD__); return array(); } @@ -988,8 +1031,7 @@ class ldap extends DS { } if (DEBUG_ENABLED) - debug_log('Entered with (%s,%s), Returning (%s)',1,__FILE__,__LINE__,__METHOD__, - $dn,$with_attributes,$result[$with_attributes]); + debug_log('Returning (%s)',17,0,__FILE__,__LINE__,__METHOD__,$result[$with_attributes]); return $result[$with_attributes]; } @@ -998,11 +1040,12 @@ class ldap extends DS { * Parse a DN and escape any special characters */ protected function escapeDN($dn) { + if (DEBUG_ENABLED && (($fargs=func_get_args())||$fargs='NOARGS')) + debug_log('Entered (%%)',17,0,__FILE__,__LINE__,__METHOD__,$fargs); + if (! trim($dn)) return $dn; - $olddn = $dn; - # Check if the RDN has a comma and escape it. while (preg_match('/([^\\\\]),(\s*[^=]*\s*),/',$dn)) $dn = preg_replace('/([^\\\\]),(\s*[^=]*\s*),/','$1\\\\2C$2,',$dn); @@ -1010,8 +1053,7 @@ class ldap extends DS { $dn = preg_replace('/([^\\\\]),(\s*[^=]*\s*)([^,])$/','$1\\\\2C$2$3',$dn); if (DEBUG_ENABLED) - debug_log('Entered with (%s), Returning (%s)',1,__FILE__,__LINE__,__METHOD__, - $olddn,$dn); + debug_log('Returning (%s)',17,0,__FILE__,__LINE__,__METHOD__,$dn); return $dn; } @@ -1020,6 +1062,9 @@ class ldap extends DS { * Parse a DN and unescape any special characters */ private function unescapeDN($dn) { + if (DEBUG_ENABLED && (($fargs=func_get_args())||$fargs='NOARGS')) + debug_log('Entered (%%)',17,0,__FILE__,__LINE__,__METHOD__,$fargs); + if (is_array($dn)) { $a = array(); foreach ($dn as $key => $rdn) @@ -1032,6 +1077,9 @@ class ldap extends DS { } public function getRootDSE($method=null) { + if (DEBUG_ENABLED && (($fargs=func_get_args())||$fargs='NOARGS')) + debug_log('Entered (%%)',17,0,__FILE__,__LINE__,__METHOD__,$fargs); + $query = array(); $query['base'] = ''; $query['scope'] = 'base'; @@ -1057,8 +1105,8 @@ class ldap extends DS { * @return array|false Schema if available, null if its not or false if we cant connect. */ private function getSchemaDN($method=null,$dn='') { - if (DEBUG_ENABLED) - debug_log('Entered with (%s)',25,__FILE__,__LINE__,__METHOD__,$dn); + if (DEBUG_ENABLED && (($fargs=func_get_args())||$fargs='NOARGS')) + debug_log('Entered (%%)',25,0,__FILE__,__LINE__,__METHOD__,$fargs); # If we already got the SchemaDN, then return it. if ($this->_schemaDN) @@ -1070,19 +1118,19 @@ class ldap extends DS { $search = @ldap_read($this->connect($method),$dn,'objectClass=*',array('subschemaSubentry')); if (DEBUG_ENABLED) - debug_log('Search returned (%s)',24,__FILE__,__LINE__,__METHOD__,is_resource($search)); + debug_log('Search returned (%s)',24,0,__FILE__,__LINE__,__METHOD__,is_resource($search)); # Fix for broken ldap.conf configuration. if (! $search && ! $dn) { if (DEBUG_ENABLED) - debug_log('Trying to find the DN for "broken" ldap.conf',80,__FILE__,__LINE__,__METHOD__); + debug_log('Trying to find the DN for "broken" ldap.conf',80,0,__FILE__,__LINE__,__METHOD__); if (isset($this->_baseDN)) { foreach ($this->_baseDN as $base) { $search = @ldap_read($this->connect($method),$base,'objectClass=*',array('subschemaSubentry')); if (DEBUG_ENABLED) - debug_log('Search returned (%s) for base (%s)',24,__FILE__,__LINE__,__METHOD__, + debug_log('Search returned (%s) for base (%s)',24,0,__FILE__,__LINE__,__METHOD__, is_resource($search),$base); if ($search) @@ -1096,7 +1144,7 @@ class ldap extends DS { if (! @ldap_count_entries($this->connect($method),$search)) { if (DEBUG_ENABLED) - debug_log('Search returned 0 entries. Returning NULL',25,__FILE__,__LINE__,__METHOD__); + debug_log('Search returned 0 entries. Returning NULL',25,0,__FILE__,__LINE__,__METHOD__); return null; } @@ -1104,7 +1152,7 @@ class ldap extends DS { $entries = @ldap_get_entries($this->connect($method),$search); if (DEBUG_ENABLED) - debug_log('Search returned [%s]',24,__FILE__,__LINE__,__METHOD__,$entries); + debug_log('Search returned [%s]',24,0,__FILE__,__LINE__,__METHOD__,$entries); if (! $entries || ! is_array($entries)) return null; @@ -1112,7 +1160,7 @@ class ldap extends DS { $entry = isset($entries[0]) ? $entries[0] : false; if (! $entry) { if (DEBUG_ENABLED) - debug_log('Entry is false, Returning NULL',80,__FILE__,__LINE__,__METHOD__); + debug_log('Entry is false, Returning NULL',80,0,__FILE__,__LINE__,__METHOD__); return null; } @@ -1120,7 +1168,7 @@ class ldap extends DS { $sub_schema_sub_entry = isset($entry[0]) ? $entry[0] : false; if (! $sub_schema_sub_entry) { if (DEBUG_ENABLED) - debug_log('Sub Entry is false, Returning NULL',80,__FILE__,__LINE__,__METHOD__); + debug_log('Sub Entry is false, Returning NULL',80,0,__FILE__,__LINE__,__METHOD__); return null; } @@ -1128,7 +1176,7 @@ class ldap extends DS { $this->_schemaDN = isset($entry[$sub_schema_sub_entry][0]) ? $entry[$sub_schema_sub_entry][0] : false; if (DEBUG_ENABLED) - debug_log('Returning (%s)',25,__FILE__,__LINE__,__METHOD__,$this->_schemaDN); + debug_log('Returning (%s)',25,0,__FILE__,__LINE__,__METHOD__,$this->_schemaDN); return $this->_schemaDN; } @@ -1161,8 +1209,8 @@ class ldap extends DS { * etc. */ private function getRawSchema($method,$schema_to_fetch,$dn='') { - if (DEBUG_ENABLED) - debug_log('Entered with (%s,%s)',25,__FILE__,__LINE__,__METHOD__,$schema_to_fetch,$dn); + if (DEBUG_ENABLED && (($fargs=func_get_args())||$fargs='NOARGS')) + debug_log('Entered (%%)',25,0,__FILE__,__LINE__,__METHOD__,$fargs); $valid_schema_to_fetch = array('objectclasses','attributetypes','ldapsyntaxes','matchingrules','matchingruleuse'); @@ -1176,7 +1224,7 @@ class ldap extends DS { $schema = $this->_schema_entries[$schema_to_fetch]; if (DEBUG_ENABLED) - debug_log('Returning CACHED (%s)',25,__FILE__,__LINE__,__METHOD__,$schema); + debug_log('Returning CACHED (%s)',25,0,__FILE__,__LINE__,__METHOD__,$schema); return $schema; } @@ -1198,11 +1246,11 @@ class ldap extends DS { if ($schema_dn) { if (DEBUG_ENABLED) - debug_log('Using Schema DN (%s)',24,__FILE__,__LINE__,__METHOD__,$schema_dn); + debug_log('Using Schema DN (%s)',24,0,__FILE__,__LINE__,__METHOD__,$schema_dn); foreach (array('(objectClass=*)','(objectClass=subschema)') as $schema_filter) { if (DEBUG_ENABLED) - debug_log('Looking for schema with Filter (%s)',24,__FILE__,__LINE__,__METHOD__,$schema_filter); + debug_log('Looking for schema with Filter (%s)',24,0,__FILE__,__LINE__,__METHOD__,$schema_filter); $schema_search = @ldap_read($this->connect($method),$schema_dn,$schema_filter,array($schema_to_fetch),0,0,0,LDAP_DEREF_NEVER); @@ -1212,18 +1260,18 @@ class ldap extends DS { $schema_entries = @ldap_get_entries($this->connect($method),$schema_search); if (DEBUG_ENABLED) - debug_log('Search returned [%s]',24,__FILE__,__LINE__,__METHOD__,$schema_entries); + debug_log('Search returned [%s]',24,0,__FILE__,__LINE__,__METHOD__,$schema_entries); if (is_array($schema_entries) && isset($schema_entries['count']) && $schema_entries['count']) { if (DEBUG_ENABLED) - debug_log('Found schema with (DN:%s) (FILTER:%s) (ATTR:%s)',24,__FILE__,__LINE__,__METHOD__, + debug_log('Found schema with (DN:%s) (FILTER:%s) (ATTR:%s)',24,0,__FILE__,__LINE__,__METHOD__, $schema_dn,$schema_filter,$schema_to_fetch); break; } if (DEBUG_ENABLED) - debug_log('Didnt find schema with filter (%s)',24,__FILE__,__LINE__,__METHOD__,$schema_filter); + debug_log('Didnt find schema with filter (%s)',24,0,__FILE__,__LINE__,__METHOD__,$schema_filter); unset($schema_entries); $schema_search = null; @@ -1234,7 +1282,7 @@ class ldap extends DS { * is still null, use some common subSchemaSubentry DNs as a work-around. */ if (is_null($schema_search)) { if (DEBUG_ENABLED) - debug_log('Attempting work-arounds for "broken" LDAP servers...',24,__FILE__,__LINE__,__METHOD__); + debug_log('Attempting work-arounds for "broken" LDAP servers...',24,0,__FILE__,__LINE__,__METHOD__); foreach ($this->getBaseDN() as $base) { $ldap['W2K3 AD'][expand_dn_with_base($base,'cn=Aggregate,cn=Schema,cn=configuration,')] = '(objectClass=*)'; @@ -1248,7 +1296,7 @@ class ldap extends DS { foreach ($ldap as $ldap_server_name => $ldap_options) { foreach ($ldap_options as $ldap_dn => $ldap_filter) { if (DEBUG_ENABLED) - debug_log('Attempting [%s] (%s) (%s)
',24,__FILE__,__LINE__,__METHOD__, + debug_log('Attempting [%s] (%s) (%s)
',24,0,__FILE__,__LINE__,__METHOD__, $ldap_server_name,$ldap_dn,$ldap_filter); $schema_search = @ldap_read($this->connect($method),$ldap_dn,$ldap_filter, @@ -1259,17 +1307,17 @@ class ldap extends DS { $schema_entries = @ldap_get_entries($this->connect($method),$schema_search); if (DEBUG_ENABLED) - debug_log('Search returned [%s]',24,__FILE__,__LINE__,__METHOD__,$schema_entries); + debug_log('Search returned [%s]',24,0,__FILE__,__LINE__,__METHOD__,$schema_entries); if ($schema_entries && isset($schema_entries[0][$schema_to_fetch])) { if (DEBUG_ENABLED) - debug_log('Found schema with filter of (%s)',24,__FILE__,__LINE__,__METHOD__,$ldap_filter); + debug_log('Found schema with filter of (%s)',24,0,__FILE__,__LINE__,__METHOD__,$ldap_filter); break; } if (DEBUG_ENABLED) - debug_log('Didnt find schema with filter (%s)',24,__FILE__,__LINE__,__METHOD__,$ldap_filter); + debug_log('Didnt find schema with filter (%s)',24,0,__FILE__,__LINE__,__METHOD__,$ldap_filter); unset($schema_entries); $schema_search = null; @@ -1285,7 +1333,7 @@ class ldap extends DS { * Attempt to pull schema from Root DSE with scope "one" (work-around for Isode M-Vault X.500/LDAP) */ foreach (array('base','one') as $ldap_scope) { if (DEBUG_ENABLED) - debug_log('Attempting to find schema with scope (%s), filter (objectClass=*) and a blank base.',24,__FILE__,__LINE__,__METHOD__, + debug_log('Attempting to find schema with scope (%s), filter (objectClass=*) and a blank base.',24,0,__FILE__,__LINE__,__METHOD__, $ldap_scope); switch ($ldap_scope) { @@ -1303,17 +1351,17 @@ class ldap extends DS { $schema_entries = @ldap_get_entries($this->connect($method),$schema_search); if (DEBUG_ENABLED) - debug_log('Search returned [%s]',24,__FILE__,__LINE__,__METHOD__,$schema_entries); + debug_log('Search returned [%s]',24,0,__FILE__,__LINE__,__METHOD__,$schema_entries); if ($schema_entries && isset($schema_entries[0][$schema_to_fetch])) { if (DEBUG_ENABLED) - debug_log('Found schema with filter of (%s)',24,__FILE__,__LINE__,__METHOD__,'(objectClass=*)'); + debug_log('Found schema with filter of (%s)',24,0,__FILE__,__LINE__,__METHOD__,'(objectClass=*)'); break; } if (DEBUG_ENABLED) - debug_log('Didnt find schema with filter (%s)',24,__FILE__,__LINE__,__METHOD__,'(objectClass=*)'); + debug_log('Didnt find schema with filter (%s)',24,0,__FILE__,__LINE__,__METHOD__,'(objectClass=*)'); unset($schema_entries); $schema_search = null; @@ -1333,7 +1381,7 @@ class ldap extends DS { 'type'=>'error')); else if (DEBUG_ENABLED) - debug_log('Returning because schema_search is NULL ()',25,__FILE__,__LINE__,__METHOD__); + debug_log('Returning because schema_search is NULL ()',25,0,__FILE__,__LINE__,__METHOD__); # We'll set this, so if we return here our cache will return the known false. $this->_schema_entries[$schema_to_fetch] = false; @@ -1343,7 +1391,7 @@ class ldap extends DS { if (! $schema_entries) { $return = false; if (DEBUG_ENABLED) - debug_log('Returning false since ldap_get_entries() returned false.',25,__FILE__,__LINE__,__METHOD__,$return); + debug_log('Returning false since ldap_get_entries() returned false.',25,0,__FILE__,__LINE__,__METHOD__,$return); return $return; } @@ -1357,7 +1405,7 @@ class ldap extends DS { $return = false; if (DEBUG_ENABLED) - debug_log('Returning because (%s) isnt in the schema array. (%s)',25,__FILE__,__LINE__,__METHOD__,$schema_to_fetch,$return); + debug_log('Returning because (%s) isnt in the schema array. (%s)',25,0,__FILE__,__LINE__,__METHOD__,$schema_to_fetch,$return); return $return; } @@ -1374,7 +1422,7 @@ class ldap extends DS { $this->_schema_entries[$schema_to_fetch] = $schema; if (DEBUG_ENABLED) - debug_log('Returning (%s)',25,__FILE__,__LINE__,__METHOD__,$schema); + debug_log('Returning (%s)',25,0,__FILE__,__LINE__,__METHOD__,$schema); return $schema; } @@ -1392,6 +1440,9 @@ class ldap extends DS { * @see SchemaObjectClasses */ public function getSchemaObjectClass($oclass_name,$method=null,$dn='') { + if (DEBUG_ENABLED && (($fargs=func_get_args())||$fargs='NOARGS')) + debug_log('Entered (%%)',25,0,__FILE__,__LINE__,__METHOD__,$fargs); + $oclass_name = strtolower($oclass_name); $socs = $this->SchemaObjectClasses($method,$dn); @@ -1402,8 +1453,7 @@ class ldap extends DS { $return = $socs[$oclass_name]; if (DEBUG_ENABLED) - debug_log('Entered with (%s,%s), Returning (%s).',25,__FILE__,__LINE__,__METHOD__, - $oclass_name,$dn,$return); + debug_log('Returning (%s)',25,0,__FILE__,__LINE__,__METHOD__,$return); return $return; } @@ -1421,6 +1471,9 @@ class ldap extends DS { * @see SchemaAttributes */ public function getSchemaAttribute($attr_name,$method=null,$dn='') { + if (DEBUG_ENABLED && (($fargs=func_get_args())||$fargs='NOARGS')) + debug_log('Entered (%%)',25,0,__FILE__,__LINE__,__METHOD__,$fargs); + $attr_name = strtolower($attr_name); $sattrs = $this->SchemaAttributes($method,$dn); @@ -1431,8 +1484,7 @@ class ldap extends DS { $return = $sattrs[$attr_name]; if (DEBUG_ENABLED) - debug_log('Entered with (%s,%s), Returning (%s).',25,__FILE__,__LINE__,__METHOD__, - $attr_name,$dn,$return); + debug_log('Returning (%s)',25,0,__FILE__,__LINE__,__METHOD__,$return); return $return; } @@ -1451,15 +1503,15 @@ class ldap extends DS { * @see getSchemaObjectClass */ public function SchemaObjectClasses($method=null,$dn='') { - if (DEBUG_ENABLED) - debug_log('Entered with (%s)',25,__FILE__,__LINE__,__METHOD__,$dn); + if (DEBUG_ENABLED && (($fargs=func_get_args())||$fargs='NOARGS')) + debug_log('Entered (%%)',25,0,__FILE__,__LINE__,__METHOD__,$fargs); # Set default return $return = null; if ($return = get_cached_item($this->index,'schema','objectclasses')) { if (DEBUG_ENABLED) - debug_log('Returning CACHED [%s] (%s)',25,__FILE__,__LINE__,__METHOD__,$this->index,'objectclasses'); + debug_log('Returning CACHED [%s] (%s)',25,0,__FILE__,__LINE__,__METHOD__,$this->index,'objectclasses'); return $return; } @@ -1491,7 +1543,7 @@ class ldap extends DS { } if (DEBUG_ENABLED) - debug_log('Returning (%s)',25,__FILE__,__LINE__,__METHOD__,$return); + debug_log('Returning (%s)',25,0,__FILE__,__LINE__,__METHOD__,$return); return $return; } @@ -1507,15 +1559,15 @@ class ldap extends DS { * @return array An array of AttributeType objects. */ public function SchemaAttributes($method=null,$dn='') { - if (DEBUG_ENABLED) - debug_log('Entered with (%s)',25,__FILE__,__LINE__,__METHOD__,$dn); + if (DEBUG_ENABLED && (($fargs=func_get_args())||$fargs='NOARGS')) + debug_log('Entered (%%)',25,0,__FILE__,__LINE__,__METHOD__,$fargs); # Set default return $return = null; if ($return = get_cached_item($this->index,'schema','attributes')) { if (DEBUG_ENABLED) - debug_log('(): Returning CACHED [%s] (%s)',25,__FILE__,__LINE__,__METHOD__,$this->index,'attributes'); + debug_log('(): Returning CACHED [%s] (%s)',25,0,__FILE__,__LINE__,__METHOD__,$this->index,'attributes'); return $return; } @@ -1676,7 +1728,7 @@ class ldap extends DS { } if (DEBUG_ENABLED) - debug_log('Returning (%s)',25,__FILE__,__LINE__,__METHOD__,$return); + debug_log('Returning (%s)',25,0,__FILE__,__LINE__,__METHOD__,$return); return $return; } @@ -1686,12 +1738,15 @@ class ldap extends DS { * The key of each entry is the OID of the matching rule. */ public function MatchingRules($method=null,$dn='') { + if (DEBUG_ENABLED && (($fargs=func_get_args())||$fargs='NOARGS')) + debug_log('Entered (%%)',25,0,__FILE__,__LINE__,__METHOD__,$fargs); + # Set default return $return = null; if ($return = get_cached_item($this->index,'schema','matchingrules')) { if (DEBUG_ENABLED) - debug_log('Returning CACHED [%s] (%s).',25,__FILE__,__LINE__,__METHOD__,$this->index,'matchingrules'); + debug_log('Returning CACHED [%s] (%s).',25,0,__FILE__,__LINE__,__METHOD__,$this->index,'matchingrules'); return $return; } @@ -1749,7 +1804,7 @@ class ldap extends DS { } if (DEBUG_ENABLED) - debug_log('Entered with (%s), Returning (%s).',25,__FILE__,__LINE__,__METHOD__,$dn,$return); + debug_log('Returning (%s)',25,0,__FILE__,__LINE__,__METHOD__,$return); return $return; } @@ -1759,12 +1814,15 @@ class ldap extends DS { * their descriptions. The key of each entry is the OID of the Syntax. */ public function SchemaSyntaxes($method=null,$dn='') { + if (DEBUG_ENABLED && (($fargs=func_get_args())||$fargs='NOARGS')) + debug_log('Entered (%%)',25,0,__FILE__,__LINE__,__METHOD__,$fargs); + # Set default return $return = null; if ($return = get_cached_item($this->index,'schema','syntaxes')) { if (DEBUG_ENABLED) - debug_log('Returning CACHED [%s] (%s).',25,__FILE__,__LINE__,__METHOD__,$this->index,'syntaxes'); + debug_log('Returning CACHED [%s] (%s).',25,0,__FILE__,__LINE__,__METHOD__,$this->index,'syntaxes'); return $return; } @@ -1795,7 +1853,7 @@ class ldap extends DS { } if (DEBUG_ENABLED) - debug_log('Entered with (%s), Returning (%s).',25,__FILE__,__LINE__,__METHOD__,$dn,$return); + debug_log('Returning (%s)',25,0,__FILE__,__LINE__,__METHOD__,$return); return $return; } @@ -1808,8 +1866,8 @@ class ldap extends DS { * otherwise. */ function isForceMay($attr_name) { - if (DEBUG_ENABLED) - debug_log('Entered with (%s)',17,__FILE__,__LINE__,__METHOD__,$attr_name); + if (DEBUG_ENABLED && (($fargs=func_get_args())||$fargs='NOARGS')) + debug_log('Entered (%%)',17,0,__FILE__,__LINE__,__METHOD__,$fargs); return in_array($attr_name,$this->force_may); } @@ -1843,9 +1901,8 @@ class ldap extends DS { * @todo Caching these values may be problematic with multiple calls and different deref values. */ public function getDNAttrValue($dn,$attr,$method=null,$deref=LDAP_DEREF_NEVER) { - if (DEBUG_ENABLED) - debug_log('Entered with (%s,%s,%s,%s)',17,__FILE__,__LINE__,__METHOD__, - $dn,$attr,$method,$deref); + if (DEBUG_ENABLED && (($fargs=func_get_args())||$fargs='NOARGS')) + debug_log('Entered (%%)',17,0,__FILE__,__LINE__,__METHOD__,$fargs); # Ensure our attr is in lowercase $attr = strtolower($attr); @@ -1898,8 +1955,8 @@ class ldap extends DS { * @see getDNAttrValue */ public function getDNAttrValues($dn,$method=null,$deref=LDAP_DEREF_NEVER,$attrs=array('*','+')) { - if (DEBUG_ENABLED) - debug_log('Entered with (%s,%s,%s,%s)',17,__FILE__,__LINE__,__METHOD__,$dn,$method,$deref,$attrs); + if (DEBUG_ENABLED && (($fargs=func_get_args())||$fargs='NOARGS')) + debug_log('Entered (%%)',17,0,__FILE__,__LINE__,__METHOD__,$fargs); static $CACHE; @@ -1914,12 +1971,11 @@ class ldap extends DS { $cacheindex = '*'; if (! is_null($cacheindex) && isset($CACHE[$this->index][$method][$dn][$cacheindex])) { - if (DEBUG_ENABLED) - debug_log('Entered with (%s,%s,%s,%s), Returning CACHED (%s)',17,__FILE__,__LINE__,__METHOD__, - $dn,$method,$deref,$attrs,$CACHE[$this->index][$method][$dn][$cacheindex]); - $results = $CACHE[$this->index][$method][$dn][$cacheindex]; + if (DEBUG_ENABLED) + debug_log('Returning (%s)',17,0,__FILE__,__LINE__,__METHOD__,$results); + } else { $query = array(); $query['base'] = $this->escapeDN($dn); @@ -1957,8 +2013,8 @@ class ldap extends DS { * @return boolean */ function isDNAttr($attr_name,$method=null) { - if (DEBUG_ENABLED) - debug_log('Entered with (%s)',17,__FILE__,__LINE__,__METHOD__,$attr_name); + if (DEBUG_ENABLED && (($fargs=func_get_args())||$fargs='NOARGS')) + debug_log('Entered (%%)',17,0,__FILE__,__LINE__,__METHOD__,$fargs); # Simple test first $dn_attrs = array('aliasedObjectName'); @@ -1998,8 +2054,8 @@ class ldap extends DS { * @see draw_jpeg_photo */ function isJpegPhoto($attr_name) { - if (DEBUG_ENABLED) - debug_log('Entered with (%s)',17,__FILE__,__LINE__,__METHOD__,$attr_name); + if (DEBUG_ENABLED && (($fargs=func_get_args())||$fargs='NOARGS')) + debug_log('Entered (%%)',17,0,__FILE__,__LINE__,__METHOD__,$fargs); # easy quick check if (! strcasecmp($attr_name,'jpegPhoto') || ! strcasecmp($attr_name,'photo')) @@ -2029,8 +2085,8 @@ class ldap extends DS { * @return boolean */ function isAttrBoolean($attr_name) { - if (DEBUG_ENABLED) - debug_log('Entered with (%s)',17,__FILE__,__LINE__,__METHOD__,$attr_name); + if (DEBUG_ENABLED && (($fargs=func_get_args())||$fargs='NOARGS')) + debug_log('Entered (%%)',17,0,__FILE__,__LINE__,__METHOD__,$fargs); $type = ($sattr = $this->getSchemaAttribute($attr_name)) ? $sattr->getType() : null; @@ -2055,8 +2111,8 @@ class ldap extends DS { * @see isJpegPhoto */ function isAttrBinary($attr_name) { - if (DEBUG_ENABLED) - debug_log('Entered with (%s)',17,__FILE__,__LINE__,__METHOD__,$attr_name); + if (DEBUG_ENABLED && (($fargs=func_get_args())||$fargs='NOARGS')) + debug_log('Entered (%%)',17,0,__FILE__,__LINE__,__METHOD__,$fargs); /** * Determining if an attribute is binary can be an expensive operation. @@ -2139,8 +2195,8 @@ class ldap extends DS { * @return bool true|false */ function userIsMember($user,$group) { - if (DEBUG_ENABLED) - debug_log('Entered with (%s,%s)',17,__FILE__,__LINE__,__METHOD__,$user,$group); + if (DEBUG_ENABLED && (($fargs=func_get_args())||$fargs='NOARGS')) + debug_log('Entered (%%)',17,0,__FILE__,__LINE__,__METHOD__,$fargs); $user = strtolower($user); $group = $this->getDNAttrValues($group); @@ -2170,8 +2226,8 @@ class ldap extends DS { * This function will determine if the user is allowed to login based on a filter */ protected function userIsAllowedLogin($dn) { - if (DEBUG_ENABLED) - debug_log('Entered with (%s)',17,__FILE__,__LINE__,__METHOD__,$dn); + if (DEBUG_ENABLED && (($fargs=func_get_args())||$fargs='NOARGS')) + debug_log('Entered (%%)',17,0,__FILE__,__LINE__,__METHOD__,$fargs); $dn = trim(strtolower($dn)); @@ -2180,7 +2236,7 @@ class ldap extends DS { foreach ($this->getValue('login','allowed_dns') as $login_allowed_dn) { if (DEBUG_ENABLED) - debug_log('Working through (%s)',80,__FILE__,__LINE__,__METHOD__,$login_allowed_dn); + debug_log('Working through (%s)',80,0,__FILE__,__LINE__,__METHOD__,$login_allowed_dn); /* Check if $login_allowed_dn is an ldap search filter * Is first occurence of 'filter=' (case ensitive) at position 0 ? */ @@ -2195,7 +2251,7 @@ class ldap extends DS { $results = $this->query($query,null); if (DEBUG_ENABLED) - debug_log('Search, Filter [%s], BaseDN [%s] Results [%s]',16,__FILE__,__LINE__,__METHOD__, + debug_log('Search, Filter [%s], BaseDN [%s] Results [%s]',16,0,__FILE__,__LINE__,__METHOD__, $query['filter'],$query['base'],$results); if ($results) { @@ -2209,7 +2265,7 @@ class ldap extends DS { if (count($dn_array)) foreach ($dn_array as $result_dn) { if (DEBUG_ENABLED) - debug_log('Comparing with [%s]',80,__FILE__,__LINE__,__METHOD__,$result_dn); + debug_log('Comparing with [%s]',80,0,__FILE__,__LINE__,__METHOD__,$result_dn); # Check if $result_dn is a user DN if (strcasecmp($dn,trim(strtolower($result_dn))) == 0) diff --git a/lib/ds_ldap_pla.php b/lib/ds_ldap_pla.php index afcbbc7..ea0eee8 100644 --- a/lib/ds_ldap_pla.php +++ b/lib/ds_ldap_pla.php @@ -138,8 +138,8 @@ class ldap_pla extends ldap { * @return boolean True if the feature is enabled and false otherwise. */ function isShowCreateEnabled() { - if (DEBUG_ENABLED) - debug_log('Entered with ()',17,__FILE__,__LINE__,__METHOD__); + if (DEBUG_ENABLED && (($fargs=func_get_args())||$fargs='NOARGS')) + debug_log('Entered (%%)',17,0,__FILE__,__LINE__,__METHOD__,$fargs); if (! $_SESSION[APPCONFIG]->isCommandAvailable('script','create')) return false; @@ -161,13 +161,16 @@ class ldap_pla extends ldap { * @return boolean */ function isLoginAttrEnabled() { + if (DEBUG_ENABLED && (($fargs=func_get_args())||$fargs='NOARGS')) + debug_log('Entered (%%)',17,0,__FILE__,__LINE__,__METHOD__,$fargs); + if ((strcasecmp($this->getLoginAttr(),'dn') != 0) && trim($this->getLoginAttr())) $return = true; else $return = false; if (DEBUG_ENABLED) - debug_log('Entered with (), Returning (%s)',17,__FILE__,__LINE__,__METHOD__,$return); + debug_log('Returning (%s)',17,0,__FILE__,__LINE__,__METHOD__,$return); return $return; } @@ -183,8 +186,8 @@ class ldap_pla extends ldap { * @return boolean */ function isLoginStringEnabled() { - if (DEBUG_ENABLED) - debug_log('login_attr is [%s]',80,__FILE__,__LINE__,__METHOD__,$this->getLoginAttr()); + if (DEBUG_ENABLED && (($fargs=func_get_args())||$fargs='NOARGS')) + debug_log('Entered (%%)',17,0,__FILE__,__LINE__,__METHOD__,$fargs); if (! strcasecmp($this->getLoginAttr(),'string')) $return = true; @@ -192,7 +195,7 @@ class ldap_pla extends ldap { $return = false; if (DEBUG_ENABLED) - debug_log('Entered with (), Returning (%s)',17,__FILE__,__LINE__,__METHOD__,$return); + debug_log('Returning (%s)',17,0,__FILE__,__LINE__,__METHOD__,$return); return $return; } @@ -208,8 +211,8 @@ class ldap_pla extends ldap { * @return string|false */ function getLoginString() { - if (DEBUG_ENABLED) - debug_log('Entered with ()',17,__FILE__,__LINE__,__METHOD__,__FILE__,__LINE__,__METHOD__); + if (DEBUG_ENABLED && (($fargs=func_get_args())||$fargs='NOARGS')) + debug_log('Entered (%%)',17,0,__FILE__,__LINE__,__METHOD__,$fargs); return $this->login_string; } @@ -224,6 +227,9 @@ class ldap_pla extends ldap { * @return boolean */ public function isAnonBindAllowed() { + if (DEBUG_ENABLED && (($fargs=func_get_args())||$fargs='NOARGS')) + debug_log('Entered (%%)',17,0,__FILE__,__LINE__,__METHOD__,$fargs); + # If only_login_allowed_dns is set, then we cant have anonymous. if (count($this->getValue('login','allowed_dns')) > 0) $return = false; @@ -231,7 +237,7 @@ class ldap_pla extends ldap { $return = $this->getValue('login','anon_bind'); if (DEBUG_ENABLED) - debug_log('Entered with (), Returning (%s)',17,__FILE__,__LINE__,__METHOD__,$return); + debug_log('Returning (%s)',17,0,__FILE__,__LINE__,__METHOD__,$return); return $return; } @@ -247,7 +253,8 @@ class ldap_pla extends ldap { * @return boolean */ function isBranchRenameEnabled() { - debug_log('Entered with (), Returning (%s).',17,__FILE__,__LINE__,__METHOD__,$this->getValue('server','branch_rename')); + if (DEBUG_ENABLED && (($fargs=func_get_args())||$fargs='NOARGS')) + debug_log('Entered (%%)',17,0,__FILE__,__LINE__,__METHOD__,$fargs); return $this->getValue('server','branch_rename'); } @@ -271,6 +278,9 @@ class ldap_pla extends ldap { * @return boolean */ function isMultiLineAttr($attr_name,$val=null) { + if (DEBUG_ENABLED && (($fargs=func_get_args())||$fargs='NOARGS')) + debug_log('Entered (%%)',17,0,__FILE__,__LINE__,__METHOD__,$fargs); + # Set default return $return = false; @@ -303,7 +313,7 @@ class ldap_pla extends ldap { } if (DEBUG_ENABLED) - debug_log('Entered with (%s,%s), Returning (%s)',17,__FILE__,__LINE__,__METHOD__,$attr_name,$val,$return); + debug_log('Returning (%s)',17,0,__FILE__,__LINE__,__METHOD__,$return); return $return; } @@ -320,8 +330,8 @@ class ldap_pla extends ldap { * @return boolean */ public function isAttrReadOnly($attr) { - if (DEBUG_ENABLED) - debug_log('Entered with (%s)',17,__FILE__,__LINE__,__METHOD__,$attr); + if (DEBUG_ENABLED && (($fargs=func_get_args())||$fargs='NOARGS')) + debug_log('Entered (%%)',17,0,__FILE__,__LINE__,__METHOD__,$fargs); $attrs = $_SESSION[APPCONFIG]->getValue('appearance','readonly_attrs'); $except_dn = $_SESSION[APPCONFIG]->getValue('appearance','readonly_attrs_exempt'); @@ -353,8 +363,8 @@ class ldap_pla extends ldap { * @return boolean */ public function isAttrHidden($attr) { - if (DEBUG_ENABLED) - debug_log('Entered with (%s)',17,__FILE__,__LINE__,__METHOD__,$attr); + if (DEBUG_ENABLED && (($fargs=func_get_args())||$fargs='NOARGS')) + debug_log('Entered (%%)',17,0,__FILE__,__LINE__,__METHOD__,$fargs); $attrs = $_SESSION[APPCONFIG]->getValue('appearance','hide_attrs'); $except_dn = $_SESSION[APPCONFIG]->getValue('appearance','hide_attrs_exempt'); @@ -378,8 +388,8 @@ class ldap_pla extends ldap { * Add objects */ public function add($dn,$entry_array,$method=null) { - if (DEBUG_ENABLED) - debug_log('Entered with (%s,%s,%s)',17,__FILE__,__LINE__,__METHOD__,$dn,$entry_array,$method); + if (DEBUG_ENABLED && (($fargs=func_get_args())||$fargs='NOARGS')) + debug_log('Entered (%%)',17,0,__FILE__,__LINE__,__METHOD__,$fargs); foreach ($entry_array as $attr => $val) $entry_array[$attr] = dn_unescape($val); @@ -417,8 +427,8 @@ class ldap_pla extends ldap { * Delete objects */ public function delete($dn,$method=null) { - if (DEBUG_ENABLED) - debug_log('Entered with (%s,%s)',17,__FILE__,__LINE__,__METHOD__,$dn,$method); + if (DEBUG_ENABLED && (($fargs=func_get_args())||$fargs='NOARGS')) + debug_log('Entered (%%)',17,0,__FILE__,__LINE__,__METHOD__,$fargs); $result = false; @@ -443,8 +453,8 @@ class ldap_pla extends ldap { * Rename objects */ public function rename($dn,$new_rdn,$container,$deleteoldrdn,$method=null) { - if (DEBUG_ENABLED) - debug_log('Entered with (%s,%s,%s,%s,%s)',17,__FILE__,__LINE__,__METHOD__,$dn,$new_rdn,$container,$deleteoldrdn,$method); + if (DEBUG_ENABLED && (($fargs=func_get_args())||$fargs='NOARGS')) + debug_log('Entered (%%)',17,0,__FILE__,__LINE__,__METHOD__,$fargs); $result = false; @@ -470,8 +480,8 @@ class ldap_pla extends ldap { * Modify objects */ public function modify($dn,$attrs,$method=null) { - if (DEBUG_ENABLED) - debug_log('Entered with (%s,%s,%s)',17,__FILE__,__LINE__,__METHOD__,$dn,$attrs,$method); + if (DEBUG_ENABLED && (($fargs=func_get_args())||$fargs='NOARGS')) + debug_log('Entered (%%)',17,0,__FILE__,__LINE__,__METHOD__,$fargs); # Check our unique attributes. if (! $this->checkUniqueAttrs($dn,$attrs)) @@ -583,8 +593,8 @@ class ldap_pla extends ldap { * @return boolean */ public function isAttrUnique($attr) { - if (DEBUG_ENABLED) - debug_log('Entered with (%s)',17,__FILE__,__LINE__,__METHOD__,$attr); + if (DEBUG_ENABLED && (($fargs=func_get_args())||$fargs='NOARGS')) + debug_log('Entered (%%)',17,0,__FILE__,__LINE__,__METHOD__,$fargs); # Should this attribute value be unique if (in_array_ignore_case($attr,$this->getValue('unique','attrs'))) @@ -604,9 +614,8 @@ class ldap_pla extends ldap { * @param string|array New values for the attribute */ public function checkUniqueAttrs($dn,$attrs) { - if (DEBUG_ENABLED) - debug_log('Entered with (%s,%s,%s)',17,__FILE__,__LINE__,__METHOD__, - $dn,$attrs); + if (DEBUG_ENABLED && (($fargs=func_get_args())||$fargs='NOARGS')) + debug_log('Entered (%%)',17,0,__FILE__,__LINE__,__METHOD__,$fargs); # If none of the attributes are defined unique, we'll return immediately; if (! $checkattrs = array_intersect(arrayLower($this->getValue('unique','attrs')),array_keys(array_change_key_case($attrs)))) @@ -669,6 +678,9 @@ class ldap_pla extends ldap { * Check if the session timeout has occured for this LDAP server. */ public function isSessionValid() { + if (DEBUG_ENABLED && (($fargs=func_get_args())||$fargs='NOARGS')) + debug_log('Entered (%%)',17,0,__FILE__,__LINE__,__METHOD__,$fargs); + # If inactiveTime() returns a value, we need to check that it has not expired. if (is_null($this->inactivityTime()) || ! $this->isLoggedIn()) return true; diff --git a/lib/functions.php b/lib/functions.php index 3e98174..9c9de02 100644 --- a/lib/functions.php +++ b/lib/functions.php @@ -54,9 +54,6 @@ if (file_exists(LIBDIR.'functions.custom.php')) * Loads class definition */ function __autoload($className) { - if (defined('DEBUG_ENABLED') && DEBUG_ENABLED) - debug_log('Call to autoload (%s)',1,__FILE__,__LINE__,__METHOD__,$className); - if (file_exists(HOOKSDIR."classes/$className.php")) require_once(HOOKSDIR."classes/$className.php"); elseif (file_exists(LIBDIR."$className.php")) @@ -77,8 +74,8 @@ function __autoload($className) { * $_GET, $_POST, or $_COOKIE. */ function array_stripslashes(&$array) { - if (DEBUG_ENABLED) - debug_log('Entered with (%s)',1,__FILE__,__LINE__,__METHOD__,$array); + if (DEBUG_ENABLED && (($fargs=func_get_args())||$fargs='NOARGS')) + debug_log('Entered (%%)',1,0,__FILE__,__LINE__,__METHOD__,$fargs); if (is_array($array)) while (list($key) = each($array)) @@ -125,9 +122,8 @@ if (! function_exists('_')) { * @see set_error_handler */ function app_error_handler($errno,$errstr,$file,$lineno) { - if (defined('DEBUG_ENABLED') && DEBUG_ENABLED) - debug_log('Entered with (%s,%s,%s,%s)',1,__FILE__,__LINE__,__METHOD__, - $errno,$errstr,$file,$lineno); + if (defined('DEBUG_ENABLED') && DEBUG_ENABLED && (($fargs=func_get_args())||$fargs='NOARGS')) + debug_log('Entered (%%)',1,0,__FILE__,__LINE__,__METHOD__,$fargs); /** * error_reporting will be 0 if the error context occurred @@ -233,9 +229,6 @@ function app_version() { $CACHE = 'UNKNOWN'; } - if (defined('DEBUG_ENABLED') && DEBUG_ENABLED) - debug_log('Entered with (), Returning (%s)',1,__FILE__,__LINE__,__METHOD__,$CACHE); - return $CACHE; } @@ -353,6 +346,9 @@ function check_config($config_file) { * @return array */ function cmd_control_pane($type) { + if (DEBUG_ENABLED && (($fargs=func_get_args())||$fargs='NOARGS')) + debug_log('Entered (%%)',1,0,__FILE__,__LINE__,__METHOD__,$fargs); + switch ($type) { case 'main' : return array( @@ -491,29 +487,25 @@ function debug_sysmsg($msg) { * @param int Log bit number for this message. * @see syslog.php */ -function debug_log($msg,$level=0) { - global $debug_file; - - # Temporary, to catch when these are not set in the function arguments. - $file = __FILE__; - $line = __LINE__; - $method = __METHOD__; +function debug_log($msg,$level,$indent) { + static $debug_file; # In case we are called before we are fully initialised or if debugging is not set. - if (! isset($_SESSION[APPCONFIG]) || ! ($_SESSION[APPCONFIG]->getValue('debug','file') - || $_SESSION[APPCONFIG]->getValue('debug','syslog'))) - return false; + if (! isset($_SESSION[APPCONFIG]) || + ! ($_SESSION[APPCONFIG]->getValue('debug','file') || $_SESSION[APPCONFIG]->getValue('debug','syslog'))) + return; $debug_level = $_SESSION[APPCONFIG]->getValue('debug','level'); if (! $debug_level || (! ($level & $debug_level))) return; - $debugaddr = false; if ($_SESSION[APPCONFIG]->getValue('debug','addr')) if (isset($_SERVER['HTTP_X_FORWARDED_FOR']) && $_SERVER['HTTP_X_FORWARDED_FOR'] == $_SESSION[APPCONFIG]->getValue('debug','addr')) $debugaddr = true; elseif ($_SERVER['REMOTE_ADDR'] == $_SESSION[APPCONFIG]->getValue('debug','addr')) $debugaddr = true; + else + $debugaddr = false; else $debugaddr = true; @@ -522,36 +514,51 @@ function debug_log($msg,$level=0) { return; # If we are limiting debug to a browser, then check that - $caller = basename( $_SERVER['PHP_SELF'] ); + $caller = basename($_SERVER['PHP_SELF']); - if (func_num_args() > 2) { - $args = func_get_args(); - array_shift($args); - array_shift($args); + $args = func_get_args(); + # Discard our first three arguments. + array_shift($args); + array_shift($args); + array_shift($args); - # This is temporary, until we change all the debug_log statements. - if (is_string($args[0]) && preg_match('/.php$/',$args[0])) { - $file = array_shift($args); - $line = array_shift($args); - $method = array_shift($args); - } + # Pull the file/line/method + if (is_string($args[0]) && preg_match('/.php$/',$args[0])) { + $file = preg_replace('/.php$/','',array_shift($args)); + $line = array_shift($args); + $method = array_shift($args); - $fargs = array(); - foreach ($args as $key) { - if (is_array($key) || is_object($key)) - array_push($fargs,serialize($key)); - else - array_push($fargs,$key); - } - $msg = vsprintf($msg, array_values($fargs)); + } else { + $file = 'UNKNOWN'; + $line = 'UNKNOWN'; + $method = 'UNKNOWN'; } + # TEMP: New debuglog format + if (preg_match('/%%/',$msg) && $args[0] != 'NOARGS') + $args = array_shift($args); + + $fargs = array(); + foreach ($args as $key) { + if (is_array($key)) + array_push($fargs,serialize($key)); + elseif (is_object($key)) + array_push($fargs,sprintf('OBJECT:%s',get_class($key))); + else + array_push($fargs,$key); + } + + if (preg_match('/%%/',$msg)) + $msg = preg_replace('/%%/',join('|',$fargs),$msg); + else + $msg = vsprintf($msg,array_values($fargs)); + if (function_exists('stopwatch')) $timer = stopwatch(); else $timer = null; - $debug_message = sprintf('[%2.3f] %3s-%s(%04s): %s: %s',$timer,$level,basename($file),$line,$method,substr($msg,0,200)); + $debug_message = sprintf('[%2.3f] %15s(%04s-%03s): %s%s: %s',$timer,basename($file),$line,$level,str_repeat('.',$indent),$method,substr($msg,0,200)); if ($debug_file || $_SESSION[APPCONFIG]->getValue('debug','file')) { if (! $debug_file) @@ -732,9 +739,8 @@ function system_message($msg,$redirect=null) { * @author lem9 (taken from the phpMyAdmin source) */ function blowfish_encrypt($data,$secret=null) { - if (DEBUG_ENABLED) - debug_log('Entered with (%s,%s)',1,__FILE__,__LINE__,__METHOD__, - $data,$secret); + if (DEBUG_ENABLED && (($fargs=func_get_args())||$fargs='NOARGS')) + debug_log('Entered (%%)',1,0,__FILE__,__LINE__,__METHOD__,$fargs); # If our secret is null or blank, get the default. if ($secret === null || ! trim($secret)) @@ -772,9 +778,8 @@ function blowfish_encrypt($data,$secret=null) { * @author lem9 (taken from the phpMyAdmin source) */ function blowfish_decrypt($encdata,$secret=null) { - if (DEBUG_ENABLED) - debug_log('Entered with (%s,%s)',1,__FILE__,__LINE__,__METHOD__, - $encdata,$secret); + if (DEBUG_ENABLED && (($fargs=func_get_args())||$fargs='NOARGS')) + debug_log('Entered (%%)',1,0,__FILE__,__LINE__,__METHOD__,$fargs); # This cache gives major speed up for stupid callers :) static $CACHE = array(); @@ -817,9 +822,8 @@ function blowfish_decrypt($encdata,$secret=null) { * @return string The padded string */ function full_str_pad($input,$pad_length,$pad_string='',$pad_type=0) { - if (DEBUG_ENABLED) - debug_log('Entered with (%s,%s,%s,%s)',1,__FILE__,__LINE__,__METHOD__, - $input,$pad_length,$pad_string,$pad_type); + if (DEBUG_ENABLED && (($fargs=func_get_args())||$fargs='NOARGS')) + debug_log('Entered (%%)',1,0,__FILE__,__LINE__,__METHOD__,$fargs); $str = ''; $length = $pad_length - strlen($input); @@ -853,22 +857,18 @@ function full_str_pad($input,$pad_length,$pad_string='',$pad_type=0) { * or null if there is nothing cached.. */ function get_cached_item($index,$item,$subitem='null') { + if (DEBUG_ENABLED && (($fargs=func_get_args())||$fargs='NOARGS')) + debug_log('Entered (%%)',1,0,__FILE__,__LINE__,__METHOD__,$fargs); + # Set default return $return = null; # Check config to make sure session-based caching is enabled. - if ($_SESSION[APPCONFIG]->getValue('cache',$item)) - if (isset($_SESSION['cache'][$index][$item][$subitem])) { - if (DEBUG_ENABLED) - debug_log('Returning SESSION cached [%s] (%s)',1,__FILE__,__LINE__,__METHOD__, - $item,$subitem); - - $return = $_SESSION['cache'][$index][$item][$subitem]; - } + if ($_SESSION[APPCONFIG]->getValue('cache',$item) && isset($_SESSION['cache'][$index][$item][$subitem])) + $return = $_SESSION['cache'][$index][$item][$subitem]; if (DEBUG_ENABLED) - debug_log('Entered with (%s,%s,%s), Returning (%s)',1,__FILE__,__LINE__,__METHOD__, - $index,$item,$subitem,$return); + debug_log('Returning (%s)',1,0,__FILE__,__LINE__,__METHOD__,$return); return $return; } @@ -879,9 +879,8 @@ 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) { - if (DEBUG_ENABLED) - debug_log('Entered with (%s,%s,%s,%s)',1,__FILE__,__LINE__,__METHOD__, - $index,$item,$subitem,$data); + if (DEBUG_ENABLED && (($fargs=func_get_args())||$fargs='NOARGS')) + debug_log('Entered (%%)',1,0,__FILE__,__LINE__,__METHOD__,$fargs); # Check config to make sure session-based caching is enabled. if ($_SESSION[APPCONFIG]->getValue('cache',$item)) { @@ -889,6 +888,7 @@ function set_cached_item($index,$item,$subitem='null',$data) { $CACHE[$index][$item][$subitem] = $data; $_SESSION['cache'][$index][$item][$subitem] = $data; + return true; } else @@ -899,11 +899,10 @@ function set_cached_item($index,$item,$subitem='null',$data) { * Deletes the cache for a specified $item for the specified $index */ function del_cached_item($index,$item,$subitem='null') { - global $CACHE; + if (DEBUG_ENABLED && (($fargs=func_get_args())||$fargs='NOARGS')) + debug_log('Entered (%%)',1,0,__FILE__,__LINE__,__METHOD__,$fargs); - if (DEBUG_ENABLED) - debug_log('Entered with (%s,%s,%s)',1,__FILE__,__LINE__,__METHOD__, - $index,$item,$subitem); + global $CACHE; # Check config to make sure session-based caching is enabled. if (isset($_SESSION['cache'][$index][$item][$subitem])) @@ -925,6 +924,9 @@ function del_cached_item($index,$item,$subitem='null') { * @return boolean */ function set_cookie($name,$val,$expire=null,$dir=null) { + if (DEBUG_ENABLED && (($fargs=func_get_args())||$fargs='NOARGS')) + debug_log('Entered (%%)',1,0,__FILE__,__LINE__,__METHOD__,$fargs); + # Set default return $return = false; @@ -942,8 +944,7 @@ function set_cookie($name,$val,$expire=null,$dir=null) { } if (DEBUG_ENABLED) - debug_log('Entered with (%s,%s,%s,%s), Returning (%s)',1,__FILE__,__LINE__,__METHOD__, - $name,$val,$expire,$dir,$return); + debug_log('Returning (%s)',1,0,__FILE__,__LINE__,__METHOD__,$return); return $return; } @@ -958,6 +959,9 @@ function set_cookie($name,$val,$expire=null,$dir=null) { * @return string The customized filename, if exists, or the standard one */ function get_custom_file($index,$filename,$path) { + if (DEBUG_ENABLED && (($fargs=func_get_args())||$fargs='NOARGS')) + debug_log('Entered (%%)',1,0,__FILE__,__LINE__,__METHOD__,$fargs); + # Set default return $return = $path.$filename; $server = $_SESSION[APPCONFIG]->getServer($index); @@ -967,8 +971,7 @@ function get_custom_file($index,$filename,$path) { $return = $path.$custom.$filename; if (DEBUG_ENABLED) - debug_log('Entered with (%s,%s,%s), Returning (%s)',1,__FILE__,__LINE__,__METHOD__, - $index,$filename,$path,$return); + debug_log('Returning (%s)',1,0,__FILE__,__LINE__,__METHOD__,$return); return $return; } @@ -982,9 +985,8 @@ function get_custom_file($index,$filename,$path) { * @return array Sorted multi demension array. */ function masort(&$data,$sortby,$rev=0) { - if (DEBUG_ENABLED) - debug_log('Entered with (%s,%s,%s)',1,__FILE__,__LINE__,__METHOD__, - $data,$sortby,$rev); + if (DEBUG_ENABLED && (($fargs=func_get_args())||$fargs='NOARGS')) + debug_log('Entered (%%)',1,0,__FILE__,__LINE__,__METHOD__,$fargs); # if the array to sort is null or empty if (! $data) return; @@ -1097,6 +1099,9 @@ function isCompress() { * @return boolean */ function obfuscate_password_display($enc=null) { + if (DEBUG_ENABLED && (($fargs=func_get_args())||$fargs='NOARGS')) + debug_log('Entered (%%)',1,0,__FILE__,__LINE__,__METHOD__,$fargs); + if ($_SESSION[APPCONFIG]->getValue('appearance','obfuscate_password_display')) $return = true; @@ -1107,8 +1112,7 @@ function obfuscate_password_display($enc=null) { $return = false; if (DEBUG_ENABLED) - debug_log('Entered with (%s), Returning (%s)',1,__FILE__,__LINE__,__METHOD__, - $enc,$return); + debug_log('Returning (%s)',1,0,__FILE__,__LINE__,__METHOD__,$return); return $return; } @@ -1124,8 +1128,8 @@ function obfuscate_password_display($enc=null) { * @return string */ function pretty_print_dn($dn) { - if (DEBUG_ENABLED) - debug_log('Entered with (%s)',1,__FILE__,__LINE__,__METHOD__,$dn); + if (DEBUG_ENABLED && (($fargs=func_get_args())||$fargs='NOARGS')) + debug_log('Entered (%%)',1,0,__FILE__,__LINE__,__METHOD__,$fargs); $dn_save = $dn; $dn = pla_explode_dn($dn); @@ -1157,8 +1161,8 @@ function pretty_print_dn($dn) { * @return boolean */ function is_dn_string($str) { - if (DEBUG_ENABLED) - debug_log('Entered with (%s)',1,__FILE__,__LINE__,__METHOD__,$str); + if (DEBUG_ENABLED && (($fargs=func_get_args())||$fargs='NOARGS')) + debug_log('Entered (%%)',1,0,__FILE__,__LINE__,__METHOD__,$fargs); /* Try to break the string into its component parts if it can be done ie, "uid=Manager" "dc=example" and "dc=com" */ @@ -1194,8 +1198,8 @@ function is_dn_string($str) { * @return boolean Returns true if the specified string looks like an email address or false otherwise. */ function is_mail_string($str) { - if (DEBUG_ENABLED) - debug_log('Entered with (%s)',1,__FILE__,__LINE__,__METHOD__,$str); + if (DEBUG_ENABLED && (($fargs=func_get_args())||$fargs='NOARGS')) + debug_log('Entered (%%)',1,0,__FILE__,__LINE__,__METHOD__,$fargs); $mail_regex = "/^[_A-Za-z0-9-]+(\\.[_A-Za-z0-9-]+)*@[A-Za-z0-9-]+(\\.[A-Za-z0-9-]+)*$/"; @@ -1212,8 +1216,8 @@ function is_mail_string($str) { * @return boolean Returns true if the specified string looks like a web URL or false otherwise. */ function is_url_string($str) { - if (DEBUG_ENABLED) - debug_log('Entered with (%s)',1,__FILE__,__LINE__,__METHOD__,$str); + if (DEBUG_ENABLED && (($fargs=func_get_args())||$fargs='NOARGS')) + debug_log('Entered (%%)',1,0,__FILE__,__LINE__,__METHOD__,$fargs); $url_regex = '/^(ftp|https?):\/\/+[\w\.\-\/\?\=\&]*\w+/'; @@ -1255,8 +1259,8 @@ function is_url_string($str) { * @return int */ function pla_compare_dns($dn1,$dn2) { - if (DEBUG_ENABLED) - debug_log('Entered with (%s,%s)',1,__FILE__,__LINE__,__METHOD__,$dn1,$dn2); + if (DEBUG_ENABLED && (($fargs=func_get_args())||$fargs='NOARGS')) + debug_log('Entered (%%)',1,0,__FILE__,__LINE__,__METHOD__,$fargs); # If pla_compare_dns is passed via a tree, then we'll just get the DN part. if (is_array($dn1)) @@ -1354,9 +1358,8 @@ function pla_compare_dns($dn1,$dn2) { * @return int */ function get_next_number($base,$attr,$increment=false,$filter=false,$startmin=null) { - if (DEBUG_ENABLED) - debug_log('Entered with (%s,%s,%s,%s)',1,__FILE__,__LINE__,__METHOD__, - $base,$attr,$increment,$filter); + if (DEBUG_ENABLED && (($fargs=func_get_args())||$fargs='NOARGS')) + debug_log('Entered (%%)',1,0,__FILE__,__LINE__,__METHOD__,$fargs); $server = $_SESSION[APPCONFIG]->getServer(get_request('server_id','REQUEST')); $attr = strtolower($attr); @@ -1550,8 +1553,8 @@ function get_next_number($base,$attr,$increment=false,$filter=false,$startmin=nu * @return string */ function get_icon($server_id,$dn,$object_classes=array()) { - if (DEBUG_ENABLED) - debug_log('Entered with (%s)',1,__FILE__,__LINE__,__METHOD__,$dn); + if (DEBUG_ENABLED && (($fargs=func_get_args())||$fargs='NOARGS')) + debug_log('Entered (%%)',1,0,__FILE__,__LINE__,__METHOD__,$fargs); $server = $_SESSION[APPCONFIG]->getServer($server_id); @@ -1731,9 +1734,8 @@ function get_icon($server_id,$dn,$object_classes=array()) { * @return string|null Returns null if both base is null and sub_dn is null or empty */ function expand_dn_with_base($base,$sub_dn) { - if (DEBUG_ENABLED) - debug_log('Entered with (%s,%s)',1,__FILE__,__LINE__,__METHOD__, - $base,$sub_dn); + if (DEBUG_ENABLED && (($fargs=func_get_args())||$fargs='NOARGS')) + debug_log('Entered (%%)',1,0,__FILE__,__LINE__,__METHOD__,$fargs); $empty_str = (is_null($sub_dn) || (($len=strlen(trim($sub_dn))) == 0)); @@ -1758,8 +1760,8 @@ function expand_dn_with_base($base,$sub_dn) { * @return string The generated salt string. */ function random_salt($length) { - if (DEBUG_ENABLED) - debug_log('Entered with (%s)',1,__FILE__,__LINE__,__METHOD__,$length); + if (DEBUG_ENABLED && (($fargs=func_get_args())||$fargs='NOARGS')) + debug_log('Entered (%%)',1,0,__FILE__,__LINE__,__METHOD__,$fargs); $possible = '0123456789'. 'abcdefghijklmnopqrstuvwxyz'. @@ -1784,8 +1786,8 @@ function random_salt($length) { * @return string The RDN */ function get_rdn($dn,$include_attrs=0,$decode=false) { - if (DEBUG_ENABLED) - debug_log('Entered with (%s,%s,%s)',1,__FILE__,__LINE__,__METHOD__,$dn,$include_attrs,$decode); + if (DEBUG_ENABLED && (($fargs=func_get_args())||$fargs='NOARGS')) + debug_log('Entered (%%)',1,0,__FILE__,__LINE__,__METHOD__,$fargs); if (is_null($dn)) return null; @@ -1806,6 +1808,9 @@ function get_rdn($dn,$include_attrs=0,$decode=false) { * Split an RDN into its attributes */ function rdn_explode($rdn) { + if (DEBUG_ENABLED && (($fargs=func_get_args())||$fargs='NOARGS')) + debug_log('Entered (%%)',1,0,__FILE__,__LINE__,__METHOD__,$fargs); + # Setup to work out our RDN. $rdnarray = explode('\+',$rdn); @@ -1839,8 +1844,8 @@ function rdn_explode($rdn) { * @return array An associative array contianing the error title and description like so: */ function pla_verbose_error($key) { - if (DEBUG_ENABLED) - debug_log('Entered with (%s)',1,__FILE__,__LINE__,__METHOD__,$key); + if (DEBUG_ENABLED && (($fargs=func_get_args())||$fargs='NOARGS')) + debug_log('Entered (%%)',1,0,__FILE__,__LINE__,__METHOD__,$fargs); static $CACHE = array(); @@ -1891,10 +1896,11 @@ function pla_verbose_error($key) { * @return array An associative array contianing the OID title and description like so: */ function support_oid_to_text($key) { - if (DEBUG_ENABLED) - debug_log('Entered with (%s)',1,__FILE__,__LINE__,__METHOD__,$key); + if (DEBUG_ENABLED && (($fargs=func_get_args())||$fargs='NOARGS')) + debug_log('Entered (%%)',1,0,__FILE__,__LINE__,__METHOD__,$fargs); static $CACHE = array(); + $unknown = array(); $unknown['desc'] = 'We have no description for this OID, if you know what this OID provides, please let us know. Please also include an RFC reference if it is available.'; $unknown['title'] = 'Can you help with this OID info?'; @@ -1937,6 +1943,9 @@ function support_oid_to_text($key) { * Print an LDAP error message */ function ldap_error_msg($msg,$errnum) { + if (DEBUG_ENABLED && (($fargs=func_get_args())||$fargs='NOARGS')) + debug_log('Entered (%%)',1,0,__FILE__,__LINE__,__METHOD__,$fargs); + $body = ''; $errnum = ('0x'.str_pad(dechex($errnum),2,0,STR_PAD_LEFT)); @@ -1979,9 +1988,8 @@ function ldap_error_msg($msg,$errnum) { * fixed_width, fixed_height, img_opts. */ function draw_jpeg_photo($server,$dn,$attr_name='jpegphoto',$index,$draw_delete_buttons=false,$options=array()) { - if (DEBUG_ENABLED) - debug_log('Entered with (%s,%s,%s,%s,%s,%s)',1,__FILE__,__LINE__,__METHOD__, - is_object($server),$dn,$attr_name,$index,$draw_delete_buttons,$img_html_attrs); + if (DEBUG_ENABLED && (($fargs=func_get_args())||$fargs='NOARGS')) + debug_log('Entered (%%)',1,0,__FILE__,__LINE__,__METHOD__,$fargs); $fixed = array(); $fixed['width'] = isset($options['fixed_width']) ? $options['fixed_width'] : false; @@ -2078,6 +2086,9 @@ function draw_jpeg_photo($server,$dn,$attr_name='jpegphoto',$index,$draw_delete_ * @todo Dynamically work this list out so we only present hashes that we can encrypt */ function password_types() { + if (DEBUG_ENABLED && (($fargs=func_get_args())||$fargs='NOARGS')) + debug_log('Entered (%%)',1,0,__FILE__,__LINE__,__METHOD__,$fargs); + return array( 'blowfish', 'clear', @@ -2100,9 +2111,8 @@ function password_types() { * @return string The hashed password. */ function password_hash($password_clear,$enc_type) { - if (DEBUG_ENABLED) - debug_log('Entered with (%s,%s)',1,__FILE__,__LINE__,__METHOD__, - $password_clear,$enc_type); + if (DEBUG_ENABLED && (($fargs=func_get_args())||$fargs='NOARGS')) + debug_log('Entered (%%)',1,0,__FILE__,__LINE__,__METHOD__,$fargs); $enc_type = strtolower($enc_type); @@ -2197,9 +2207,8 @@ function password_hash($password_clear,$enc_type) { * @return Boolean True if the clear password matches the hash, and false otherwise. */ function password_check($cryptedpassword,$plainpassword) { - if (DEBUG_ENABLED) - debug_log('Entered with (%s,%s)',1,__FILE__,__LINE__,__METHOD__, - $cryptedpassword,$plainpassword); + if (DEBUG_ENABLED && (($fargs=func_get_args())||$fargs='NOARGS')) + debug_log('Entered (%%)',1,0,__FILE__,__LINE__,__METHOD__,$fargs); if (preg_match('/{([^}]+)}(.*)/',$cryptedpassword,$matches)) { $cryptedpassword = $matches[2]; @@ -2344,8 +2353,8 @@ function password_check($cryptedpassword,$plainpassword) { * @return string */ function get_enc_type($user_password) { - if (DEBUG_ENABLED) - debug_log('Entered with (%s)',1,__FILE__,__LINE__,__METHOD__,$user_password); + if (DEBUG_ENABLED && (($fargs=func_get_args())||$fargs='NOARGS')) + debug_log('Entered (%%)',1,0,__FILE__,__LINE__,__METHOD__,$fargs); # Capture the stuff in the { } to determine if this is crypt, md5, etc. $enc_type = null; @@ -2383,9 +2392,8 @@ function get_enc_type($user_password) { * @param boolean (optional) If true, the function draws the localized text "choose" to the right of the button. */ function draw_chooser_link($form_element,$include_choose_text=true,$rdn='none') { - if (DEBUG_ENABLED) - debug_log('Entered with (%s,%s,%s)',1,__FILE__,__LINE__,__METHOD__, - $form_element,$include_choose_text,$rdn); + if (DEBUG_ENABLED && (($fargs=func_get_args())||$fargs='NOARGS')) + debug_log('Entered (%%)',1,0,__FILE__,__LINE__,__METHOD__,$fargs); if ($rdn == 'none') $href = sprintf("javascript:dnChooserPopup('%s','');",$form_element); @@ -2419,14 +2427,14 @@ function draw_chooser_link($form_element,$include_choose_text=true,$rdn='none') * @return array An array of RDN parts of this format: */ function pla_explode_dn($dn,$with_attributes=0) { - global $CACHE; + if (DEBUG_ENABLED && (($fargs=func_get_args())||$fargs='NOARGS')) + debug_log('Entered (%%)',1,0,__FILE__,__LINE__,__METHOD__,$fargs); - if (DEBUG_ENABLED) - debug_log('Entered with (%s,%s)',1,__FILE__,__LINE__,__METHOD__,$dn,$with_attributes); + global $CACHE; if (isset($CACHE['explode'][$dn][$with_attributes])) { if (DEBUG_ENABLED) - debug_log('Return CACHED result (%s) for (%s)',1,__FILE__,__LINE__,__METHOD__, + debug_log('Return CACHED result (%s) for (%s)',1,0,__FILE__,__LINE__,__METHOD__, $CACHE['explode'][$dn][$with_attributes],$dn); return $CACHE['explode'][$dn][$with_attributes]; @@ -2439,7 +2447,7 @@ function pla_explode_dn($dn,$with_attributes=0) { $result[1] = ldap_explode_dn(dn_escape($dn),1); if (! $result[$with_attributes]) { if (DEBUG_ENABLED) - debug_log('Returning NULL - NO result.',1,__FILE__,__LINE__,__METHOD__); + debug_log('Returning NULL - NO result.',1,0,__FILE__,__LINE__,__METHOD__); return array(); } @@ -2458,8 +2466,7 @@ function pla_explode_dn($dn,$with_attributes=0) { } if (DEBUG_ENABLED) - debug_log('Entered with (%s,%s), Returning (%s)',1,__FILE__,__LINE__,__METHOD__, - $dn,$with_attributes,$result[$with_attributes]); + debug_log('Returning (%s)',1,0,__FILE__,__LINE__,__METHOD__,$result[$with_attributes]); return $result[$with_attributes]; } @@ -2468,6 +2475,9 @@ function pla_explode_dn($dn,$with_attributes=0) { * Parse a DN and escape any special characters */ function dn_escape($dn) { + if (DEBUG_ENABLED && (($fargs=func_get_args())||$fargs='NOARGS')) + debug_log('Entered (%%)',1,0,__FILE__,__LINE__,__METHOD__,$fargs); + $olddn = $dn; # Check if the RDN has a comma and escape it. @@ -2477,7 +2487,7 @@ function dn_escape($dn) { $dn = preg_replace('/([^\\\\]),(\s*[^=]*\s*)([^,])$/','$1\\\\2C$2$3',$dn); if (DEBUG_ENABLED) - debug_log('Entered with (%s), Returning (%s)',1,__FILE__,__LINE__,__METHOD__,$olddn,$dn); + debug_log('Returning (%s)',1,0,__FILE__,__LINE__,__METHOD__,$dn); return $dn; } @@ -2486,12 +2496,17 @@ function dn_escape($dn) { * Parse a DN and unescape any special characters */ function dn_unescape($dn) { + if (DEBUG_ENABLED && (($fargs=func_get_args())||$fargs='NOARGS')) + debug_log('Entered (%%)',1,0,__FILE__,__LINE__,__METHOD__,$fargs); + if (is_array($dn)) { $a = array(); - foreach ($dn as $key => $rdn) { + + foreach ($dn as $key => $rdn) $a[$key] = preg_replace('/\\\([0-9A-Fa-f]{2})/e',"''.chr(hexdec('\\1')).''",$rdn); - } + return $a; + } else { return preg_replace('/\\\([0-9A-Fa-f]{2})/e',"''.chr(hexdec('\\1')).''",$dn); } @@ -2569,9 +2584,8 @@ function utime() { * @return string The string created from the array. */ function array_to_query_string($array,$exclude_vars=array()) { - if (DEBUG_ENABLED) - debug_log('Entered with (%s,%s,%s)',1,__FILE__,__LINE__,__METHOD__, - $array,$exclude_vars,$url_encode_ampersands); + if (DEBUG_ENABLED && (($fargs=func_get_args())||$fargs='NOARGS')) + debug_log('Entered (%%)',1,0,__FILE__,__LINE__,__METHOD__,$fargs); if (! is_array($array) || ! count($array)) return ''; @@ -2617,8 +2631,8 @@ function array_to_query_string($array,$exclude_vars=array()) { * @see pla_explode_dns */ function pla_reverse_dn($dn) { - if (DEBUG_ENABLED) - debug_log('Entered with (%s)',1,__FILE__,__LINE__,__METHOD__,$dn); + if (DEBUG_ENABLED && (($fargs=func_get_args())||$fargs='NOARGS')) + debug_log('Entered (%%)',1,0,__FILE__,__LINE__,__METHOD__,$fargs); return (implode(',',array_reverse(pla_explode_dn($dn)))); } @@ -2627,8 +2641,8 @@ function pla_reverse_dn($dn) { * Attribute sorting */ function sortAttrs($a,$b) { - if (DEBUG_ENABLED) - debug_log('Entered with (%s,%s)',1,__FILE__,__LINE__,__METHOD__,$a,$b); + if (DEBUG_ENABLED && (($fargs=func_get_args())||$fargs='NOARGS')) + debug_log('Entered (%%)',1,0,__FILE__,__LINE__,__METHOD__,$fargs); if ($a == $b) return 0; @@ -2665,8 +2679,8 @@ function sortAttrs($a,$b) { * @returns array Array with values converted to lowercase. */ function arrayLower($array) { - if (DEBUG_ENABLED) - debug_log('Entered with (%s)',1,__FILE__,__LINE__,__METHOD__,$array); + if (DEBUG_ENABLED && (($fargs=func_get_args())||$fargs='NOARGS')) + debug_log('Entered (%%)',1,0,__FILE__,__LINE__,__METHOD__,$fargs); if (! is_array($array)) return $array; @@ -2686,8 +2700,8 @@ function arrayLower($array) { * @return boolean True if its there, false if its not. */ function in_array_ignore_case($needle,$haystack) { - if (DEBUG_ENABLED) - debug_log('Entered with (%s,%s)',1,__FILE__,__LINE__,__METHOD__,$needle,$haystack); + if (DEBUG_ENABLED && (($fargs=func_get_args())||$fargs='NOARGS')) + debug_log('Entered (%%)',1,0,__FILE__,__LINE__,__METHOD__,$fargs); if (! is_array($haystack)) return false; @@ -2705,7 +2719,7 @@ function in_array_ignore_case($needle,$haystack) { } if (DEBUG_ENABLED) - debug_log('Entered with (%s,%s), Returning (%s)',1,__FILE__,__LINE__,__METHOD__,$needle,$haystack,$return); + debug_log('Returning (%s)',1,0,__FILE__,__LINE__,__METHOD__,$return); return $return; } @@ -2714,11 +2728,10 @@ function in_array_ignore_case($needle,$haystack) { * Gets a DN string using the user-configured tree_display_format string to format it. */ function draw_formatted_dn($server,$entry) { - $dn = $entry->getDn(); + if (DEBUG_ENABLED && (($fargs=func_get_args())||$fargs='NOARGS')) + debug_log('Entered (%%)',1,0,__FILE__,__LINE__,__METHOD__,$fargs); - if (DEBUG_ENABLED) - debug_log('Entered with (%s,%s)',1,__FILE__,__LINE__,__METHOD__, - $server->getIndex(),$dn); + $dn = $entry->getDn(); $formats = $_SESSION[APPCONFIG]->getValue('appearance','tree_display_format'); @@ -2728,7 +2741,7 @@ function draw_formatted_dn($server,$entry) { $tokens = $tokens[0]; if (DEBUG_ENABLED) - debug_log('The tokens are (%s)',1,__FILE__,__LINE__,__METHOD__,$tokens); + debug_log('The tokens are (%s)',1,0,__FILE__,__LINE__,__METHOD__,$tokens); foreach ($tokens as $token) { if (strcasecmp($token,'%dn') == 0) @@ -2773,9 +2786,8 @@ function draw_formatted_dn($server,$entry) { * Server html select list */ function server_select_list($selected=null,$logged_on=false,$name='index',$isVisible=true,$js=null) { - if (DEBUG_ENABLED) - debug_log('Entered with (%s,%s,%s,%s)',1,__FILE__,__LINE__,__METHOD__, - $selected,$logged_on,$name,$js); + if (DEBUG_ENABLED && (($fargs=func_get_args())||$fargs='NOARGS')) + debug_log('Entered (%%)',1,0,__FILE__,__LINE__,__METHOD__,$fargs); $count = 0; $server_menu_html = sprintf('
'; echo '', isCompress() ? '[C]' : ' ', @@ -326,8 +332,8 @@ class page { * Only show a particular page frame - used by an AJAX call */ public function show($frame,$compress=false,$raw=false) { - if (defined('DEBUG_ENABLED') && DEBUG_ENABLED) - debug_log('Entered with (%s)',129,__FILE__,__LINE__,__METHOD__,$compress); + if (DEBUG_ENABLED && (($fargs=func_get_args())||$fargs='NOARGS')) + debug_log('Entered (%%)',129,0,__FILE__,__LINE__,__METHOD__,$fargs); # If the body is called via AJAX, and compression is enable, we need to compress the output if ($compress && ob_get_level() && isCompress()) { @@ -353,7 +359,7 @@ class page { ob_end_clean(); if (DEBUG_ENABLED) - debug_log('Sending COMPRESSED output to browser[(%s),%s]',129,__FILE__,__LINE__,__METHOD__, + debug_log('Sending COMPRESSED output to browser[(%s),%s]',129,0,__FILE__,__LINE__,__METHOD__, strlen($output),$output); print gzencode($output); @@ -361,8 +367,8 @@ class page { } public function display($filter=array()) { - if (defined('DEBUG_ENABLED') && DEBUG_ENABLED) - debug_log('Entered with [%s]',129,__FILE__,__LINE__,__METHOD__,$filter); + if (DEBUG_ENABLED && (($fargs=func_get_args())||$fargs='NOARGS')) + debug_log('Entered (%%)',129,0,__FILE__,__LINE__,__METHOD__,$fargs); # Control what is displayed. $display = array( @@ -431,7 +437,7 @@ class page { ob_end_clean(); if (DEBUG_ENABLED) - debug_log('Sending COMPRESSED output to browser[(%s),%s]',129,__FILE__,__LINE__,__METHOD__, + debug_log('Sending COMPRESSED output to browser[(%s),%s]',129,0,__FILE__,__LINE__,__METHOD__, strlen($output),$output); print gzencode($output); @@ -439,8 +445,8 @@ class page { } public function setsysmsg($data) { - if (defined('DEBUG_ENABLED') && DEBUG_ENABLED) - debug_log('Entered with [%s]',129,__FILE__,__LINE__,__METHOD__,$data); + if (DEBUG_ENABLED && (($fargs=func_get_args())||$fargs='NOARGS')) + debug_log('Entered (%%)',129,0,__FILE__,__LINE__,__METHOD__,$fargs); if (! is_array($data)) return; @@ -467,9 +473,6 @@ class block { private $body; private $foot; - public function __construct() { - } - public function setTitle($html) { $this->title = $html; } diff --git a/lib/schema_functions.php b/lib/schema_functions.php index dab5e35..4971c45 100644 --- a/lib/schema_functions.php +++ b/lib/schema_functions.php @@ -29,18 +29,30 @@ abstract class SchemaItem { private $is_obsolete = false; public function setOID($oid) { + if (DEBUG_ENABLED && (($fargs=func_get_args())||$fargs='NOARGS')) + debug_log('Entered (%%)',9,1,__FILE__,__LINE__,__METHOD__,$fargs); + $this->oid = $oid; } public function setDescription($desc) { + if (DEBUG_ENABLED && (($fargs=func_get_args())||$fargs='NOARGS')) + debug_log('Entered (%%)',9,1,__FILE__,__LINE__,__METHOD__,$fargs); + $this->description = $desc; } public function getOID() { + if (DEBUG_ENABLED && (($fargs=func_get_args())||$fargs='NOARGS')) + debug_log('Entered (%%)',9,0,__FILE__,__LINE__,__METHOD__,$fargs); + return $this->oid; } public function getDescription() { + if (DEBUG_ENABLED && (($fargs=func_get_args())||$fargs='NOARGS')) + debug_log('Entered (%%)',9,1,__FILE__,__LINE__,__METHOD__,$fargs,$this->description); + return $this->description; } @@ -48,6 +60,9 @@ abstract class SchemaItem { * Gets whether this objectClass is flagged as obsolete by the LDAP server. */ public function getIsObsolete() { + if (DEBUG_ENABLED && (($fargs=func_get_args())||$fargs='NOARGS')) + debug_log('Entered (%%)',9,1,__FILE__,__LINE__,__METHOD__,$fargs,$this->is_obsolete); + return $this->is_obsolete; } @@ -58,6 +73,9 @@ abstract class SchemaItem { * @return string The name */ public function getName($lower=true) { + if (DEBUG_ENABLED && (($fargs=func_get_args())||$fargs='NOARGS')) + debug_log('Entered (%%)',9,1,__FILE__,__LINE__,__METHOD__,$fargs,$this->name); + return $lower ? strtolower($this->name) : $this->name; } } @@ -90,8 +108,8 @@ class ObjectClass extends SchemaItem { * Creates a new ObjectClass object given a raw LDAP objectClass string. */ public function __construct($class,$server) { - if (DEBUG_ENABLED) - debug_log('Entered with (%s)',9,__FILE__,__LINE__,__METHOD__,$class); + if (DEBUG_ENABLED && (($fargs=func_get_args())||$fargs='NOARGS')) + debug_log('Entered (%%)',9,0,__FILE__,__LINE__,__METHOD__,$fargs); $this->server_id = $server->getIndex(); $this->type = $server->getValue('server','schema_oclass_default'); @@ -136,7 +154,7 @@ class ObjectClass extends SchemaItem { $this->name = preg_replace('/\'$/','',$this->name); if (DEBUG_ENABLED) - debug_log('Case NAME returned (%s)',8,__FILE__,__LINE__,__METHOD__,$this->name); + debug_log('Case NAME returned (%s)',8,0,__FILE__,__LINE__,__METHOD__,$this->name); break; case 'DESC': @@ -150,14 +168,14 @@ class ObjectClass extends SchemaItem { } while (! preg_match('/\'$/s',$strings[$i])); if (DEBUG_ENABLED) - debug_log('Case DESC returned (%s)',8,__FILE__,__LINE__,__METHOD__,$this->description); + debug_log('Case DESC returned (%s)',8,0,__FILE__,__LINE__,__METHOD__,$this->description); break; case 'OBSOLETE': $this->is_obsolete = TRUE; if (DEBUG_ENABLED) - debug_log('Case OBSOLETE returned (%s)',8,__FILE__,__LINE__,__METHOD__,$this->is_obsolete); + debug_log('Case OBSOLETE returned (%s)',8,0,__FILE__,__LINE__,__METHOD__,$this->is_obsolete); break; case 'SUP': @@ -176,28 +194,28 @@ class ObjectClass extends SchemaItem { } if (DEBUG_ENABLED) - debug_log('Case SUP returned (%s)',8,__FILE__,__LINE__,__METHOD__,$this->sup_classes); + debug_log('Case SUP returned (%s)',8,0,__FILE__,__LINE__,__METHOD__,$this->sup_classes); break; case 'ABSTRACT': $this->type = 'abstract'; if (DEBUG_ENABLED) - debug_log('Case ABSTRACT returned (%s)',8,__FILE__,__LINE__,__METHOD__,$this->type); + debug_log('Case ABSTRACT returned (%s)',8,0,__FILE__,__LINE__,__METHOD__,$this->type); break; case 'STRUCTURAL': $this->type = 'structural'; if (DEBUG_ENABLED) - debug_log('Case STRUCTURAL returned (%s)',8,__FILE__,__LINE__,__METHOD__,$this->type); + debug_log('Case STRUCTURAL returned (%s)',8,0,__FILE__,__LINE__,__METHOD__,$this->type); break; case 'AUXILIARY': $this->type = 'auxiliary'; if (DEBUG_ENABLED) - debug_log('Case AUXILIARY returned (%s)',8,__FILE__,__LINE__,__METHOD__,$this->type); + debug_log('Case AUXILIARY returned (%s)',8,0,__FILE__,__LINE__,__METHOD__,$this->type); break; case 'MUST': @@ -206,7 +224,7 @@ class ObjectClass extends SchemaItem { $i = $this->parseList(++$i,$strings,$attrs); if (DEBUG_ENABLED) - debug_log('parseList returned %d (%s)',8,__FILE__,__LINE__,__METHOD__,$i,$attrs); + debug_log('parseList returned %d (%s)',8,0,__FILE__,__LINE__,__METHOD__,$i,$attrs); foreach ($attrs as $string) { $attr = new ObjectClass_ObjectClassAttribute($string,$this->name); @@ -220,7 +238,7 @@ class ObjectClass extends SchemaItem { } if (DEBUG_ENABLED) - debug_log('Case MUST returned (%s) (%s)',8,__FILE__,__LINE__,__METHOD__,$this->must_attrs,$this->force_may); + debug_log('Case MUST returned (%s) (%s)',8,0,__FILE__,__LINE__,__METHOD__,$this->must_attrs,$this->force_may); break; case 'MAY': @@ -229,7 +247,7 @@ class ObjectClass extends SchemaItem { $i = $this->parseList(++$i,$strings,$attrs); if (DEBUG_ENABLED) - debug_log('parseList returned %d (%s)',8,__FILE__,__LINE__,__METHOD__,$i,$attrs); + debug_log('parseList returned %d (%s)',8,0,__FILE__,__LINE__,__METHOD__,$i,$attrs); foreach ($attrs as $string) { $attr = new ObjectClass_ObjectClassAttribute($string,$this->name); @@ -237,7 +255,7 @@ class ObjectClass extends SchemaItem { } if (DEBUG_ENABLED) - debug_log('Case MAY returned (%s)',8,__FILE__,__LINE__,__METHOD__,$this->may_attrs); + debug_log('Case MAY returned (%s)',8,0,__FILE__,__LINE__,__METHOD__,$this->may_attrs); break; default: @@ -245,7 +263,7 @@ class ObjectClass extends SchemaItem { $this->setOID($strings[$i]); if (DEBUG_ENABLED) - debug_log('Case default returned (%s)',8,__FILE__,__LINE__,__METHOD__,$this->getOID()); + debug_log('Case default returned (%s)',8,0,__FILE__,__LINE__,__METHOD__,$this->getOID()); } break; } @@ -255,7 +273,7 @@ class ObjectClass extends SchemaItem { $this->description = preg_replace("/\'$/",'',$this->description); if (DEBUG_ENABLED) - debug_log('Returning () - NAME (%s), DESCRIPTION (%s), MUST (%s), MAY (%s), FORCE MAY (%s)',9,__FILE__,__LINE__,__METHOD__, + debug_log('Returning () - NAME (%s), DESCRIPTION (%s), MUST (%s), MAY (%s), FORCE MAY (%s)',9,0,__FILE__,__LINE__,__METHOD__, $this->name,$this->description,$this->must_attrs,$this->may_attrs,$this->force_may); } @@ -263,14 +281,15 @@ class ObjectClass extends SchemaItem { * Parse an LDAP schema list */ private function parseList($i,$strings,&$attrs) { + if (DEBUG_ENABLED && (($fargs=func_get_args())||$fargs='NOARGS')) + debug_log('Entered (%%)',9,0,__FILE__,__LINE__,__METHOD__,$fargs); + /* * A list starts with a ( followed by a list of attributes separated by $ terminated by ) * The first token can therefore be a ( or a (NAME or a (NAME) * The last token can therefore be a ) or NAME) * The last token may be terminate by more than one bracket */ - if (DEBUG_ENABLED) - debug_log('Entered with (%d,%s,%s)',9,__FILE__,__LINE__,__METHOD__,$i,$strings,$attrs); $string = $strings[$i]; if (! preg_match('/^\(/',$string)) { @@ -317,7 +336,7 @@ class ObjectClass extends SchemaItem { sort($attrs); if (DEBUG_ENABLED) - debug_log('Returning (%d,[%s],[%s])',9,__FILE__,__LINE__,__METHOD__,$i,$strings,$attrs); + debug_log('Returning (%d,[%s],[%s])',9,0,__FILE__,__LINE__,__METHOD__,$i,$strings,$attrs); return $i; } @@ -326,6 +345,9 @@ class ObjectClass extends SchemaItem { * This will return all our parent ObjectClass Objects */ public function getParents() { + if (DEBUG_ENABLED && (($fargs=func_get_args())||$fargs='NOARGS')) + debug_log('Entered (%%)',9,0,__FILE__,__LINE__,__METHOD__,$fargs); + if ((count($this->sup_classes) == 1) && ($this->sup_classes[0] == 'top')) return array(); @@ -359,8 +381,8 @@ class ObjectClass extends SchemaItem { * @see getMayAttrNames */ public function getMustAttrs($parents=false) { - if (DEBUG_ENABLED) - debug_log('Entered with (%s)',9,__FILE__,__LINE__,__METHOD__,$parents); + if (DEBUG_ENABLED && (($fargs=func_get_args())||$fargs='NOARGS')) + debug_log('Entered (%%)',9,0,__FILE__,__LINE__,__METHOD__,$fargs); if (! $parents) return $this->must_attrs; @@ -401,8 +423,8 @@ class ObjectClass extends SchemaItem { * @see AttributeType */ public function getMayAttrs($parents=false) { - if (DEBUG_ENABLED) - debug_log('Entered with (%s)',9,__FILE__,__LINE__,__METHOD__,$parents); + if (DEBUG_ENABLED && (($fargs=func_get_args())||$fargs='NOARGS')) + debug_log('Entered (%%)',9,0,__FILE__,__LINE__,__METHOD__,$fargs); if (! $parents) return $this->may_attrs; @@ -428,6 +450,9 @@ class ObjectClass extends SchemaItem { } public function getForceMayAttrs() { + if (DEBUG_ENABLED && (($fargs=func_get_args())||$fargs='NOARGS')) + debug_log('Entered (%%)',9,0,__FILE__,__LINE__,__METHOD__,$fargs); + return $this->force_may; } @@ -447,8 +472,8 @@ class ObjectClass extends SchemaItem { * @see getMayAttrNames */ public function getMustAttrNames($parents=false) { - if (DEBUG_ENABLED) - debug_log('Entered with (%s)',9,__FILE__,__LINE__,__METHOD__,$parents); + if (DEBUG_ENABLED && (($fargs=func_get_args())||$fargs='NOARGS')) + debug_log('Entered (%%)',9,0,__FILE__,__LINE__,__METHOD__,$fargs); $attr_names = array(); @@ -474,8 +499,8 @@ class ObjectClass extends SchemaItem { * @see getMustAttrNames */ public function getMayAttrNames($parents=false) { - if (DEBUG_ENABLED) - debug_log('Entered with (%s)',9,__FILE__,__LINE__,__METHOD__,$parents); + if (DEBUG_ENABLED && (($fargs=func_get_args())||$fargs='NOARGS')) + debug_log('Entered (%%)',9,0,__FILE__,__LINE__,__METHOD__,$fargs); $attr_names = array(); @@ -493,8 +518,8 @@ class ObjectClass extends SchemaItem { * @return boolean Returns true on success or false on failure (objectclass already existed for example) */ public function addChildObjectClass($name) { - if (DEBUG_ENABLED) - debug_log('Entered with (%s)',9,__FILE__,__LINE__,__METHOD__,$name); + if (DEBUG_ENABLED && (($fargs=func_get_args())||$fargs='NOARGS')) + debug_log('Entered (%%)',9,0,__FILE__,__LINE__,__METHOD__,$fargs); $name = trim($name); @@ -511,6 +536,9 @@ class ObjectClass extends SchemaItem { * @return Array Names of objectClasses which inherit from this objectClass. */ public function getChildObjectClasses() { + if (DEBUG_ENABLED && (($fargs=func_get_args())||$fargs='NOARGS')) + debug_log('Entered (%%)',9,0,__FILE__,__LINE__,__METHOD__,$fargs); + return $this->children_objectclasses; } @@ -520,6 +548,9 @@ class ObjectClass extends SchemaItem { * @return array An array of objectClass names (strings) */ public function getSupClasses() { + if (DEBUG_ENABLED && (($fargs=func_get_args())||$fargs='NOARGS')) + debug_log('Entered (%%)',9,0,__FILE__,__LINE__,__METHOD__,$fargs); + return $this->sup_classes; } @@ -529,6 +560,9 @@ class ObjectClass extends SchemaItem { * @param array ObjectClasses that this attribute may be related to */ public function isRelated($oclass) { + if (DEBUG_ENABLED && (($fargs=func_get_args())||$fargs='NOARGS')) + debug_log('Entered (%%)',9,0,__FILE__,__LINE__,__METHOD__,$fargs); + # If I am in the array, we'll just return false if (in_array_ignore_case($this->name,$oclass)) return false; @@ -549,6 +583,9 @@ class ObjectClass extends SchemaItem { * Gets the type of this objectClass: STRUCTURAL, ABSTRACT, or AUXILIARY. */ public function getType() { + if (DEBUG_ENABLED && (($fargs=func_get_args())||$fargs='NOARGS')) + debug_log('Entered (%%)',9,1,__FILE__,__LINE__,__METHOD__,$fargs,$this->type); + return $this->type; } @@ -560,8 +597,8 @@ class ObjectClass extends SchemaItem { * @param array $attr An array of attribute names (strings) to add. */ private function addMustAttrs($attr) { - if (DEBUG_ENABLED) - debug_log('Entered with (%s)',9,__FILE__,__LINE__,__METHOD__,$attr); + if (DEBUG_ENABLED && (($fargs=func_get_args())||$fargs='NOARGS')) + debug_log('Entered (%%)',9,0,__FILE__,__LINE__,__METHOD__,$fargs); if (! is_array($attr) || ! count($attr)) return; @@ -576,8 +613,8 @@ class ObjectClass extends SchemaItem { * @param array $attr An array of attribute names (strings) to add. */ private function addMayAttrs($attr) { - if (DEBUG_ENABLED) - debug_log('Entered with (%s)',9,__FILE__,__LINE__,__METHOD__,$attr); + if (DEBUG_ENABLED && (($fargs=func_get_args())||$fargs='NOARGS')) + debug_log('Entered (%%)',9,0,__FILE__,__LINE__,__METHOD__,$fargs); if (! is_array($attr) || ! count($attr)) return; @@ -589,6 +626,9 @@ class ObjectClass extends SchemaItem { * Determine if an array is listed in the force_may attrs */ public function isForceMay($attr) { + if (DEBUG_ENABLED && (($fargs=func_get_args())||$fargs='NOARGS')) + debug_log('Entered (%%)',9,0,__FILE__,__LINE__,__METHOD__,$fargs); + foreach ($this->force_may as $forcemay) if ($forcemay->getName() == $attr) return true; @@ -597,6 +637,9 @@ class ObjectClass extends SchemaItem { } public function isStructural() { + if (DEBUG_ENABLED && (($fargs=func_get_args())||$fargs='NOARGS')) + debug_log('Entered (%%)',9,0,__FILE__,__LINE__,__METHOD__,$fargs); + if ($this->type == 'structural') return true; else @@ -630,8 +673,8 @@ class ObjectClass_ObjectClassAttribute { * @param string $source the name of the ObjectClass which specifies this attribute. */ public function __construct($name,$source) { - if (DEBUG_ENABLED) - debug_log('Entered with name (%s), source (%s)',9,__FILE__,__LINE__,__METHOD__,$name,$source); + if (DEBUG_ENABLED && (($fargs=func_get_args())||$fargs='NOARGS')) + debug_log('Entered (%%)',9,0,__FILE__,__LINE__,__METHOD__,$fargs); $this->name = $name; $this->source = $source; @@ -639,11 +682,17 @@ class ObjectClass_ObjectClassAttribute { # Gets this attribute's name public function getName($lower=true) { + if (DEBUG_ENABLED && (($fargs=func_get_args())||$fargs='NOARGS')) + debug_log('Entered (%%)',9,1,__FILE__,__LINE__,__METHOD__,$fargs,$this->name); + return $lower ? strtolower($this->name) : $this->name; } # Gets the name of the ObjectClass which originally specified this attribute. public function getSource() { + if (DEBUG_ENABLED && (($fargs=func_get_args())||$fargs='NOARGS')) + debug_log('Entered (%%)',9,1,__FILE__,__LINE__,__METHOD__,$fargs,$this->source); + return $this->source; } } @@ -691,8 +740,8 @@ class AttributeType extends SchemaItem { * Creates a new AttributeType object from a raw LDAP AttributeType string. */ public function __construct($attr) { - if (DEBUG_ENABLED) - debug_log('Entered with (%s)',9,__FILE__,__LINE__,__METHOD__,$attr); + if (DEBUG_ENABLED && (($fargs=func_get_args())||$fargs='NOARGS')) + debug_log('Entered (%%)',9,0,__FILE__,__LINE__,__METHOD__,$fargs); $strings = preg_split('/[\s,]+/',$attr,-1,PREG_SPLIT_DELIM_CAPTURE); @@ -743,7 +792,7 @@ class AttributeType extends SchemaItem { } if (DEBUG_ENABLED) - debug_log('Case NAME returned (%s) (%s)',8,__FILE__,__LINE__,__METHOD__,$this->name,$this->aliases); + debug_log('Case NAME returned (%s) (%s)',8,0,__FILE__,__LINE__,__METHOD__,$this->name,$this->aliases); break; case 'DESC': @@ -756,14 +805,14 @@ class AttributeType extends SchemaItem { } while (! preg_match("/\'$/s",$strings[$i])); if (DEBUG_ENABLED) - debug_log('Case DESC returned (%s)',8,__FILE__,__LINE__,__METHOD__,$this->description); + debug_log('Case DESC returned (%s)',8,0,__FILE__,__LINE__,__METHOD__,$this->description); break; case 'OBSOLETE': $this->is_obsolete = TRUE; if (DEBUG_ENABLED) - debug_log('Case OBSOLETE returned (%s)',8,__FILE__,__LINE__,__METHOD__,$this->is_obsolete); + debug_log('Case OBSOLETE returned (%s)',8,0,__FILE__,__LINE__,__METHOD__,$this->is_obsolete); break; case 'SUP': @@ -771,7 +820,7 @@ class AttributeType extends SchemaItem { $this->sup_attribute = $strings[$i]; if (DEBUG_ENABLED) - debug_log('Case SUP returned (%s)',8,__FILE__,__LINE__,__METHOD__,$this->sup_attribute); + debug_log('Case SUP returned (%s)',8,0,__FILE__,__LINE__,__METHOD__,$this->sup_attribute); break; case 'EQUALITY': @@ -779,7 +828,7 @@ class AttributeType extends SchemaItem { $this->equality = $strings[$i]; if (DEBUG_ENABLED) - debug_log('Case EQUALITY returned (%s)',8,__FILE__,__LINE__,__METHOD__,$this->equality); + debug_log('Case EQUALITY returned (%s)',8,0,__FILE__,__LINE__,__METHOD__,$this->equality); break; case 'ORDERING': @@ -787,7 +836,7 @@ class AttributeType extends SchemaItem { $this->ordering = $strings[$i]; if (DEBUG_ENABLED) - debug_log('Case ORDERING returned (%s)',8,__FILE__,__LINE__,__METHOD__,$this->ordering); + debug_log('Case ORDERING returned (%s)',8,0,__FILE__,__LINE__,__METHOD__,$this->ordering); break; case 'SUBSTR': @@ -795,7 +844,7 @@ class AttributeType extends SchemaItem { $this->sub_str = $strings[$i]; if (DEBUG_ENABLED) - debug_log('Case SUBSTR returned (%s)',8,__FILE__,__LINE__,__METHOD__,$this->sub_str); + debug_log('Case SUBSTR returned (%s)',8,0,__FILE__,__LINE__,__METHOD__,$this->sub_str); break; case 'SYNTAX': @@ -817,28 +866,28 @@ class AttributeType extends SchemaItem { } if (DEBUG_ENABLED) - debug_log('Case SYNTAX returned (%s) (%s) (%s)',8,__FILE__,__LINE__,__METHOD__, + debug_log('Case SYNTAX returned (%s) (%s) (%s)',8,0,__FILE__,__LINE__,__METHOD__, $this->syntax,$this->syntax_oid,$this->max_length); break; case 'SINGLE-VALUE': $this->is_single_value = TRUE; if (DEBUG_ENABLED) - debug_log('Case SINGLE-VALUE returned (%s)',8,__FILE__,__LINE__,__METHOD__,$this->is_single_value); + debug_log('Case SINGLE-VALUE returned (%s)',8,0,__FILE__,__LINE__,__METHOD__,$this->is_single_value); break; case 'COLLECTIVE': $this->is_collective = TRUE; if (DEBUG_ENABLED) - debug_log('Case COLLECTIVE returned (%s)',8,__FILE__,__LINE__,__METHOD__,$this->is_collective); + debug_log('Case COLLECTIVE returned (%s)',8,0,__FILE__,__LINE__,__METHOD__,$this->is_collective); break; case 'NO-USER-MODIFICATION': $this->is_no_user_modification = TRUE; if (DEBUG_ENABLED) - debug_log('Case NO-USER-MODIFICATION returned (%s)',8,__FILE__,__LINE__,__METHOD__,$this->is_no_user_modification); + debug_log('Case NO-USER-MODIFICATION returned (%s)',8,0,__FILE__,__LINE__,__METHOD__,$this->is_no_user_modification); break; case 'USAGE': @@ -846,7 +895,7 @@ class AttributeType extends SchemaItem { $this->usage = $strings[$i]; if (DEBUG_ENABLED) - debug_log('Case USAGE returned (%s)',8,__FILE__,__LINE__,__METHOD__,$this->usage); + debug_log('Case USAGE returned (%s)',8,0,__FILE__,__LINE__,__METHOD__,$this->usage); break; default: @@ -854,7 +903,7 @@ class AttributeType extends SchemaItem { $this->setOID($strings[$i]); if (DEBUG_ENABLED) - debug_log('Case default returned (%s)',8,__FILE__,__LINE__,__METHOD__,$this->getOID()); + debug_log('Case default returned (%s)',8,0,__FILE__,__LINE__,__METHOD__,$this->getOID()); } } } @@ -871,7 +920,7 @@ class AttributeType extends SchemaItem { $this->sup_attribute = preg_replace("/\'$/",'',$this->sup_attribute); if (DEBUG_ENABLED) - debug_log('Returning ()',9,__FILE__,__LINE__,__METHOD__); + debug_log('Returning ()',9,0,__FILE__,__LINE__,__METHOD__); } /** @@ -880,6 +929,9 @@ class AttributeType extends SchemaItem { * @return string */ public function getUsage() { + if (DEBUG_ENABLED && (($fargs=func_get_args())||$fargs='NOARGS')) + debug_log('Entered (%%)',9,1,__FILE__,__LINE__,__METHOD__,$fargs,$this->usage); + return $this->usage; } @@ -890,10 +942,10 @@ class AttributeType extends SchemaItem { * @return string */ public function getSupAttribute() { - if ($this->sup_attribute) - return $this->sup_attribute; - else - return null; + if (DEBUG_ENABLED && (($fargs=func_get_args())||$fargs='NOARGS')) + debug_log('Entered (%%)',9,1,__FILE__,__LINE__,__METHOD__,$fargs,$this->sup_attribute); + + return $this->sup_attribute; } /** @@ -902,6 +954,9 @@ class AttributeType extends SchemaItem { * @return string */ public function getEquality() { + if (DEBUG_ENABLED && (($fargs=func_get_args())||$fargs='NOARGS')) + debug_log('Entered (%%)',9,1,__FILE__,__LINE__,__METHOD__,$fargs,$this->equality); + return $this->equality; } @@ -911,6 +966,9 @@ class AttributeType extends SchemaItem { * @return string */ public function getOrdering() { + if (DEBUG_ENABLED && (($fargs=func_get_args())||$fargs='NOARGS')) + debug_log('Entered (%%)',9,1,__FILE__,__LINE__,__METHOD__,$fargs,$this->ordering); + return $this->ordering; } @@ -920,6 +978,9 @@ class AttributeType extends SchemaItem { * @return string */ public function getSubstr() { + if (DEBUG_ENABLED && (($fargs=func_get_args())||$fargs='NOARGS')) + debug_log('Entered (%%)',9,1,__FILE__,__LINE__,__METHOD__,$fargs,$this->sub_str); + return $this->sub_str; } @@ -930,6 +991,9 @@ class AttributeType extends SchemaItem { * an empty array if no attribute aliases this object. */ public function getAliases() { + if (DEBUG_ENABLED && (($fargs=func_get_args())||$fargs='NOARGS')) + debug_log('Entered (%%)',9,1,__FILE__,__LINE__,__METHOD__,$fargs,$this->aliases); + return $this->aliases; } @@ -940,8 +1004,8 @@ class AttributeType extends SchemaItem { * @return boolean True if the specified attribute is an alias for this one, or false otherwise. */ public function isAliasFor($attr_name) { - if (DEBUG_ENABLED) - debug_log('Entered with (%s)',9,__FILE__,__LINE__,__METHOD__,$attr_name); + if (DEBUG_ENABLED && (($fargs=func_get_args())||$fargs='NOARGS')) + debug_log('Entered (%%)',9,0,__FILE__,__LINE__,__METHOD__,$fargs); foreach ($this->aliases as $alias_attr_name) if (strcasecmp($alias_attr_name,$attr_name) == 0) @@ -956,6 +1020,9 @@ class AttributeType extends SchemaItem { * @return string The raw syntax string */ public function getSyntaxString() { + if (DEBUG_ENABLED && (($fargs=func_get_args())||$fargs='NOARGS')) + debug_log('Entered (%%)',9,1,__FILE__,__LINE__,__METHOD__,$fargs,$this->syntax); + return $this->syntax; } @@ -968,6 +1035,9 @@ class AttributeType extends SchemaItem { * @return string The syntax OID string. */ public function getSyntaxOID() { + if (DEBUG_ENABLED && (($fargs=func_get_args())||$fargs='NOARGS')) + debug_log('Entered (%%)',9,1,__FILE__,__LINE__,__METHOD__,$fargs,$this->syntax_oid); + return $this->syntax_oid; } @@ -977,6 +1047,9 @@ class AttributeType extends SchemaItem { * @return int The maximum length (in characters) of this attribute or null if no maximum is specified. */ public function getMaxLength() { + if (DEBUG_ENABLED && (($fargs=func_get_args())||$fargs='NOARGS')) + debug_log('Entered (%%)',9,1,__FILE__,__LINE__,__METHOD__,$fargs,$this->max_length); + return $this->max_length; } @@ -987,6 +1060,9 @@ class AttributeType extends SchemaItem { * @return boolean Returns true if this attribute is single-valued or false otherwise. */ public function getIsSingleValue() { + if (DEBUG_ENABLED && (($fargs=func_get_args())||$fargs='NOARGS')) + debug_log('Entered (%%)',9,1,__FILE__,__LINE__,__METHOD__,$fargs,$this->is_single_value); + return $this->is_single_value; } @@ -996,6 +1072,9 @@ class AttributeType extends SchemaItem { * @param boolean $is */ public function setIsSingleValue($is) { + if (DEBUG_ENABLED && (($fargs=func_get_args())||$fargs='NOARGS')) + debug_log('Entered (%%)',9,1,__FILE__,__LINE__,__METHOD__,$fargs); + $this->is_single_value = $is; } @@ -1005,6 +1084,9 @@ class AttributeType extends SchemaItem { * @return boolean Returns true if this attribute is collective and false otherwise. */ public function getIsCollective() { + if (DEBUG_ENABLED && (($fargs=func_get_args())||$fargs='NOARGS')) + debug_log('Entered (%%)',9,1,__FILE__,__LINE__,__METHOD__,$fargs,$this->is_collective); + return $this->is_collective; } @@ -1014,6 +1096,9 @@ class AttributeType extends SchemaItem { * @return boolean Returns true if this attribute is not modifiable by users. */ public function getIsNoUserModification() { + if (DEBUG_ENABLED && (($fargs=func_get_args())||$fargs='NOARGS')) + debug_log('Entered (%%)',9,1,__FILE__,__LINE__,__METHOD__,$fargs,$this->is_no_user_modification); + return $this->is_no_user_modification; } @@ -1023,6 +1108,9 @@ class AttributeType extends SchemaItem { * @return string The attribute's type. */ public function getType() { + if (DEBUG_ENABLED && (($fargs=func_get_args())||$fargs='NOARGS')) + debug_log('Entered (%%)',9,1,__FILE__,__LINE__,__METHOD__,$fargs,$this->type); + return $this->type; } @@ -1034,8 +1122,8 @@ class AttributeType extends SchemaItem { * attribute name is not found in this attribute's list of aliases) */ public function removeAlias($remove_alias_name) { - if (DEBUG_ENABLED) - debug_log('Entered with (%s)',9,__FILE__,__LINE__,__METHOD__,$remove_alias_name); + if (DEBUG_ENABLED && (($fargs=func_get_args())||$fargs='NOARGS')) + debug_log('Entered (%%)',9,0,__FILE__,__LINE__,__METHOD__,$fargs); foreach ($this->aliases as $i => $alias_name) { @@ -1055,6 +1143,9 @@ class AttributeType extends SchemaItem { * @param string $alias The name of a new attribute to add to this attribute's list of aliases. */ public function addAlias($alias) { + if (DEBUG_ENABLED && (($fargs=func_get_args())||$fargs='NOARGS')) + debug_log('Entered (%%)',9,0,__FILE__,__LINE__,__METHOD__,$fargs); + array_push($this->aliases,$alias); } @@ -1064,6 +1155,9 @@ class AttributeType extends SchemaItem { * @param string $name The new name to give this attribute. */ public function setName($name) { + if (DEBUG_ENABLED && (($fargs=func_get_args())||$fargs='NOARGS')) + debug_log('Entered (%%)',9,1,__FILE__,__LINE__,__METHOD__,$fargs); + $this->name = $name; } @@ -1073,6 +1167,9 @@ class AttributeType extends SchemaItem { * @param string $attr The name of the new parent (SUP) attribute */ public function setSupAttribute($attr) { + if (DEBUG_ENABLED && (($fargs=func_get_args())||$fargs='NOARGS')) + debug_log('Entered (%%)',9,1,__FILE__,__LINE__,__METHOD__,$fargs); + $this->sup_attribute = $attr; } @@ -1082,6 +1179,9 @@ class AttributeType extends SchemaItem { * @param array $aliases The array of alias names (strings) */ public function setAliases($aliases) { + if (DEBUG_ENABLED && (($fargs=func_get_args())||$fargs='NOARGS')) + debug_log('Entered (%%)',9,1,__FILE__,__LINE__,__METHOD__,$fargs); + $this->aliases = $aliases; } @@ -1091,6 +1191,9 @@ class AttributeType extends SchemaItem { * @param string $type The new type. */ public function setType($type) { + if (DEBUG_ENABLED && (($fargs=func_get_args())||$fargs='NOARGS')) + debug_log('Entered (%%)',9,1,__FILE__,__LINE__,__METHOD__,$fargs); + $this->type = $type; } @@ -1101,12 +1204,12 @@ class AttributeType extends SchemaItem { * @param string $name The name of the objectClass to add. */ public function addUsedInObjectClass($name) { - if (DEBUG_ENABLED) - debug_log('Entered with (%s)',9,__FILE__,__LINE__,__METHOD__,$name); + if (DEBUG_ENABLED && (($fargs=func_get_args())||$fargs='NOARGS')) + debug_log('Entered (%%)',9,0,__FILE__,__LINE__,__METHOD__,$fargs); foreach ($this->used_in_object_classes as $used_in_object_class) { if (DEBUG_ENABLED) - debug_log('Checking (%s) with (%s)',8,__FILE__,__LINE__,__METHOD__,$used_in_object_class,$name); + debug_log('Checking (%s) with (%s)',8,0,__FILE__,__LINE__,__METHOD__,$used_in_object_class,$name); if (strcasecmp($used_in_object_class,$name) == 0) return false; @@ -1122,6 +1225,9 @@ class AttributeType extends SchemaItem { * @return array An array of names of objectclasses (strings) which provide this attribute */ public function getUsedInObjectClasses() { + if (DEBUG_ENABLED && (($fargs=func_get_args())||$fargs='NOARGS')) + debug_log('Entered (%%)',9,1,__FILE__,__LINE__,__METHOD__,$fargs,$this->used_in_object_classes); + return $this->used_in_object_classes; } @@ -1132,8 +1238,8 @@ class AttributeType extends SchemaItem { * @param string $name The name of the objectClass to add. */ public function addRequiredByObjectClass($name) { - if (DEBUG_ENABLED) - debug_log('Entered with (%s)',9,__FILE__,__LINE__,__METHOD__,$name); + if (DEBUG_ENABLED && (($fargs=func_get_args())||$fargs='NOARGS')) + debug_log('Entered (%%)',9,0,__FILE__,__LINE__,__METHOD__,$fargs); foreach ($this->required_by_object_classes as $required_by_object_class) if (strcasecmp($required_by_object_class,$name) == 0) @@ -1149,6 +1255,9 @@ class AttributeType extends SchemaItem { * @return array An array of names of objectclasses (strings) which provide this attribute */ public function getRequiredByObjectClasses() { + if (DEBUG_ENABLED && (($fargs=func_get_args())||$fargs='NOARGS')) + debug_log('Entered (%%)',9,1,__FILE__,__LINE__,__METHOD__,$fargs,$this->required_by_object_classes); + return $this->required_by_object_classes; } @@ -1156,10 +1265,16 @@ class AttributeType extends SchemaItem { * This function will mark this attribute as a forced MAY attribute */ public function setForceMay() { + if (DEBUG_ENABLED && (($fargs=func_get_args())||$fargs='NOARGS')) + debug_log('Entered (%%)',9,1,__FILE__,__LINE__,__METHOD__,$fargs); + $this->forced_as_may = true; } public function isForceMay() { + if (DEBUG_ENABLED && (($fargs=func_get_args())||$fargs='NOARGS')) + debug_log('Entered (%%)',9,1,__FILE__,__LINE__,__METHOD__,$fargs,$this->forced_as_may); + return $this->forced_as_may; } } @@ -1175,8 +1290,8 @@ class Syntax extends SchemaItem { * Creates a new Syntax object from a raw LDAP syntax string. */ public function __construct($class) { - if (DEBUG_ENABLED) - debug_log('Entered with (%s)',9,__FILE__,__LINE__,__METHOD__,$class); + if (DEBUG_ENABLED && (($fargs=func_get_args())||$fargs='NOARGS')) + debug_log('Entered (%%)',9,0,__FILE__,__LINE__,__METHOD__,$fargs); $strings = preg_split('/[\s,]+/',$class,-1,PREG_SPLIT_DELIM_CAPTURE); @@ -1222,8 +1337,8 @@ class MatchingRule extends SchemaItem { * Creates a new MatchingRule object from a raw LDAP MatchingRule string. */ function __construct($strings) { - if (DEBUG_ENABLED) - debug_log('Entered with (%s)',9,__FILE__,__LINE__,__METHOD__,$strings); + if (DEBUG_ENABLED && (($fargs=func_get_args())||$fargs='NOARGS')) + debug_log('Entered (%%)',9,0,__FILE__,__LINE__,__METHOD__,$fargs); $strings = preg_split('/[\s,]+/',$strings,-1,PREG_SPLIT_DELIM_CAPTURE); @@ -1294,6 +1409,9 @@ class MatchingRule extends SchemaItem { * @param array $attrs The array of attribute names (strings) which use this MatchingRule */ public function setUsedByAttrs($attrs) { + if (DEBUG_ENABLED && (($fargs=func_get_args())||$fargs='NOARGS')) + debug_log('Entered (%%)',9,1,__FILE__,__LINE__,__METHOD__,$fargs); + $this->used_by_attrs = $attrs; } @@ -1303,8 +1421,8 @@ class MatchingRule extends SchemaItem { * @return true if the attribute was added and false otherwise (already in the list) */ public function addUsedByAttr($attr) { - if (DEBUG_ENABLED) - debug_log('Entered with (%s)',9,__FILE__,__LINE__,__METHOD__,$attr); + if (DEBUG_ENABLED && (($fargs=func_get_args())||$fargs='NOARGS')) + debug_log('Entered (%%)',9,0,__FILE__,__LINE__,__METHOD__,$fargs); foreach ($this->used_by_attrs as $attr_name) if (strcasecmp($attr_name,$attr) == 0) @@ -1321,6 +1439,9 @@ class MatchingRule extends SchemaItem { * @return array The array of attribute names (strings). */ public function getUsedByAttrs() { + if (DEBUG_ENABLED && (($fargs=func_get_args())||$fargs='NOARGS')) + debug_log('Entered (%%)',9,1,__FILE__,__LINE__,__METHOD__,$fargs,$this->used_by_attrs); + return $this->used_by_attrs; } } @@ -1336,8 +1457,8 @@ class MatchingRuleUse extends SchemaItem { private $used_by_attrs = array(); function __construct($strings) { - if (DEBUG_ENABLED) - debug_log('Entered with (%s)',9,__FILE__,__LINE__,__METHOD__,$strings); + if (DEBUG_ENABLED && (($fargs=func_get_args())||$fargs='NOARGS')) + debug_log('Entered (%%)',9,0,__FILE__,__LINE__,__METHOD__,$fargs); $strings = preg_split('/[\s,]+/',$strings,-1,PREG_SPLIT_DELIM_CAPTURE); @@ -1411,6 +1532,9 @@ class MatchingRuleUse extends SchemaItem { * @return array The array of attribute names (strings). */ public function getUsedByAttrs() { + if (DEBUG_ENABLED && (($fargs=func_get_args())||$fargs='NOARGS')) + debug_log('Entered (%%)',9,1,__FILE__,__LINE__,__METHOD__,$fargs,$this->used_by_attrs); + return $this->used_by_attrs; } } diff --git a/lib/session_functions.php b/lib/session_functions.php index a02d964..ee666d8 100644 --- a/lib/session_functions.php +++ b/lib/session_functions.php @@ -26,9 +26,6 @@ define('app_session_id_ses_max', 36); * @return string the new session ID string */ function app_session_get_id() { - if (DEBUG_ENABLED) - debug_log('Entered with ()',1,__FILE__,__LINE__,__METHOD__); - $id_md5 = md5(rand(1,1000000)); $ip_md5 = md5($_SERVER['REMOTE_ADDR']); $id_hex = hexdec($id_md5[0]) + 1; @@ -51,9 +48,6 @@ function app_session_get_id() { * @return boolean True, if the session is valid */ function app_session_verify_id() { - if (DEBUG_ENABLED) - debug_log('Entered with ()',1,__FILE__,__LINE__,__METHOD__); - $check_id = session_id(); $ip_md5 = md5($_SERVER['REMOTE_ADDR']); $id_hex = hexdec($check_id[0]) + 1; diff --git a/lib/xmlTemplates.php b/lib/xmlTemplates.php index 4352ee3..dd9da57 100644 --- a/lib/xmlTemplates.php +++ b/lib/xmlTemplates.php @@ -21,8 +21,8 @@ abstract class xmlTemplates { protected $templates = array(); function __construct($server_id) { - if (DEBUG_ENABLED) - debug_log('Entered with (%s)',5,__FILE__,__LINE__,__METHOD__,$server_id); + if (DEBUG_ENABLED && (($fargs=func_get_args())||$fargs='NOARGS')) + debug_log('Entered (%%)',5,0,__FILE__,__LINE__,__METHOD__,$fargs); $this->server_id = $server_id; $server = $_SESSION[APPCONFIG]->getServer($this->server_id); @@ -33,7 +33,7 @@ abstract class xmlTemplates { # Try to get the templates from our CACHE. if ($this->templates = get_cached_item($server_id,$class['item'])) { if (DEBUG_ENABLED) - debug_log('Using CACHED templates',5,__FILE__,__LINE__,__METHOD__); + debug_log('Using CACHED templates',4,0,__FILE__,__LINE__,__METHOD__); # See if the template_time has expired to see if we should reload the templates. foreach ($this->templates as $index => $template) { @@ -63,6 +63,9 @@ abstract class xmlTemplates { } } + if (DEBUG_ENABLED) + debug_log('Templates refreshed',4,0,__FILE__,__LINE__,__METHOD__); + # See if there are any new template files $index = max(array_keys($this->templates))+1; foreach ($class['types'] as $type) { @@ -101,7 +104,7 @@ abstract class xmlTemplates { } else { if (DEBUG_ENABLED) - debug_log('Parsing templates',5,__FILE__,__LINE__,__METHOD__); + debug_log('Parsing templates',4,0,__FILE__,__LINE__,__METHOD__); # Need to reset this, as get_cached_item() returns null if nothing cached. $this->templates = array(); @@ -134,6 +137,9 @@ abstract class xmlTemplates { } } + if (DEBUG_ENABLED) + debug_log('Templates loaded',4,0,__FILE__,__LINE__,__METHOD__); + if ($changed) { masort($this->templates,'title'); set_cached_item($server_id,$class['item'],'null',$this->templates); @@ -144,6 +150,9 @@ abstract class xmlTemplates { * This will return our custom class variables, used by the parent to create objects. */ private function getClassVars() { + if (DEBUG_ENABLED && (($fargs=func_get_args())||$fargs='NOARGS')) + debug_log('Entered (%%)',5,0,__FILE__,__LINE__,__METHOD__,$fargs); + $class = array(); switch (get_class($this)) { @@ -181,6 +190,9 @@ abstract class xmlTemplates { * @return array List of templates of the type */ public function getTemplates($type=null,$container=null,$disabled=false) { + if (DEBUG_ENABLED && (($fargs=func_get_args())||$fargs='NOARGS')) + debug_log('Entered (%%)',5,0,__FILE__,__LINE__,__METHOD__,$fargs); + $result = array(); if (is_array($this->templates)) @@ -206,6 +218,9 @@ abstract class xmlTemplates { * @return object Template (or default template if the ID doesnt exist) */ function getTemplate($templateid) { + if (DEBUG_ENABLED && (($fargs=func_get_args())||$fargs='NOARGS')) + debug_log('Entered (%%)',5,0,__FILE__,__LINE__,__METHOD__,$fargs); + $class = $this->getClassVars(); foreach ($this->templates as $template) @@ -221,6 +236,9 @@ abstract class xmlTemplates { * Get a list of template filenames. */ private function getTemplateFiles() { + if (DEBUG_ENABLED && (($fargs=func_get_args())||$fargs='NOARGS')) + debug_log('Entered (%%)',5,0,__FILE__,__LINE__,__METHOD__,$fargs); + $result = array(); foreach ($this->templates as $template) @@ -253,6 +271,9 @@ abstract class xmlTemplate { protected $attributes = array(); public function __construct($server_id,$name=null,$filename=null,$type=null,$id=null) { + if (DEBUG_ENABLED && (($fargs=func_get_args())||$fargs='NOARGS')) + debug_log('Entered (%%)',5,0,__FILE__,__LINE__,__METHOD__,$fargs); + $this->server_id = $server_id; $this->name = $name; $this->type = $type; @@ -277,6 +298,9 @@ abstract class xmlTemplate { * @return int Attribute ID in the array */ protected function getAttrID($attr) { + if (DEBUG_ENABLED && (($fargs=func_get_args())||$fargs='NOARGS')) + debug_log('Entered (%%)',5,0,__FILE__,__LINE__,__METHOD__,$fargs); + foreach ($this->attributes as $index => $attribute) if (strtolower($attr) == $attribute->getName() || in_array(strtolower($attr),$attribute->getAliases())) return $index; @@ -288,6 +312,9 @@ abstract class xmlTemplate { * Get the Template filename. */ public function getFileName() { + if (DEBUG_ENABLED && (($fargs=func_get_args())||$fargs='NOARGS')) + debug_log('Entered (%%)',5,1,__FILE__,__LINE__,__METHOD__,$fargs,$this->filename); + return $this->filename; } @@ -295,6 +322,9 @@ abstract class xmlTemplate { * Return the template by ID */ public function getID() { + if (DEBUG_ENABLED && (($fargs=func_get_args())||$fargs='NOARGS')) + debug_log('Entered (%%)',5,0,__FILE__,__LINE__,__METHOD__,$fargs,$this->id); + if ($this->name) return sprintf('%s:%s',$this->getName(false),$this->id); else @@ -307,6 +337,9 @@ abstract class xmlTemplate { * @param boolean Force the name to be lowercase (default) */ public function getName($lower=true) { + if (DEBUG_ENABLED && (($fargs=func_get_args())||$fargs='NOARGS')) + debug_log('Entered (%%)',5,1,__FILE__,__LINE__,__METHOD__,$fargs,$this->name); + if ($lower) return strtolower($this->name); else @@ -317,6 +350,9 @@ abstract class xmlTemplate { * Get the Template read time. */ public function getReadTime() { + if (DEBUG_ENABLED && (($fargs=func_get_args())||$fargs='NOARGS')) + debug_log('Entered (%%)',5,1,__FILE__,__LINE__,__METHOD__,$fargs,$this->readtime); + return $this->readtime; } @@ -326,6 +362,9 @@ abstract class xmlTemplate { * @return object DataStore Server */ protected function getServer() { + if (DEBUG_ENABLED && (($fargs=func_get_args())||$fargs='NOARGS')) + debug_log('Entered (%%)',5,1,__FILE__,__LINE__,__METHOD__,$fargs); + return $_SESSION[APPCONFIG]->getServer($this->getServerID()); } @@ -335,6 +374,9 @@ abstract class xmlTemplate { * @return int Server ID */ protected function getServerID() { + if (DEBUG_ENABLED && (($fargs=func_get_args())||$fargs='NOARGS')) + debug_log('Entered (%%)',5,1,__FILE__,__LINE__,__METHOD__,$fargs,$this->server_id); + return $this->server_id; } @@ -344,6 +386,9 @@ abstract class xmlTemplate { * @return boolean */ public function isType($type) { + if (DEBUG_ENABLED && (($fargs=func_get_args())||$fargs='NOARGS')) + debug_log('Entered (%%)',5,0,__FILE__,__LINE__,__METHOD__,$fargs,$this->type); + if ($this->type == $type) return true; else @@ -354,6 +399,9 @@ abstract class xmlTemplate { * Return the template type */ public function getType() { + if (DEBUG_ENABLED && (($fargs=func_get_args())||$fargs='NOARGS')) + debug_log('Entered (%%)',5,1,__FILE__,__LINE__,__METHOD__,$fargs,$this->type); + return $this->type; } @@ -361,6 +409,9 @@ abstract class xmlTemplate { * Get template title */ public function getTitle() { + if (DEBUG_ENABLED && (($fargs=func_get_args())||$fargs='NOARGS')) + debug_log('Entered (%%)',5,0,__FILE__,__LINE__,__METHOD__,$fargs); + if (! isset($this->title) && ! isset($this->description)) return ''; @@ -373,6 +424,9 @@ abstract class xmlTemplate { * @return int Attribute ID */ public function addAttribute($name,$value,$source=null) { + if (DEBUG_ENABLED && (($fargs=func_get_args())||$fargs='NOARGS')) + debug_log('Entered (%%)',5,0,__FILE__,__LINE__,__METHOD__,$fargs); + if (! is_array($value)) debug_dump_backtrace('Value should be an array()',1); @@ -403,6 +457,9 @@ abstract class xmlTemplate { * @return array Array of attributes Names */ public function getAttributeNames() { + if (DEBUG_ENABLED && (($fargs=func_get_args())||$fargs='NOARGS')) + debug_log('Entered (%%)',5,0,__FILE__,__LINE__,__METHOD__,$fargs); + $result = array(); foreach ($this->attributes as $attribute) @@ -418,6 +475,9 @@ abstract class xmlTemplate { * @return object Attribute */ public function getAttribute($name) { + if (DEBUG_ENABLED && (($fargs=func_get_args())||$fargs='NOARGS')) + debug_log('Entered (%%)',5,0,__FILE__,__LINE__,__METHOD__,$fargs); + foreach ($this->attributes as $attribute) if (($attribute->getName() == strtolower($name)) || in_array(strtolower($name),$attribute->getAliases())) return $attribute;
'; @@ -202,8 +205,8 @@ class page { } protected function tree() { - if (defined('DEBUG_ENABLED') && DEBUG_ENABLED) - debug_log('Entered with ()',129,__FILE__,__LINE__,__METHOD__); + if (DEBUG_ENABLED && (($fargs=func_get_args())||$fargs='NOARGS')) + debug_log('Entered (%%)',129,0,__FILE__,__LINE__,__METHOD__,$fargs); if (! isset($_SESSION[APPCONFIG])) return; @@ -231,6 +234,9 @@ class page { } public function block_add($side,$object) { + if (DEBUG_ENABLED && (($fargs=func_get_args())||$fargs='NOARGS')) + debug_log('Entered (%%)',129,0,__FILE__,__LINE__,__METHOD__,$fargs); + if (! is_object($object)) error(sprintf('block_add called with [%s], but it is not an object',serialize($object))); @@ -238,8 +244,8 @@ class page { } private function block_print($side) { - if (defined('DEBUG_ENABLED') && DEBUG_ENABLED) - debug_log('Entered with ()',129,__FILE__,__LINE__,__METHOD__); + if (DEBUG_ENABLED && (($fargs=func_get_args())||$fargs='NOARGS')) + debug_log('Entered (%%)',129,0,__FILE__,__LINE__,__METHOD__,$fargs); if (! isset($this->_block[$side])) return; @@ -251,8 +257,8 @@ class page { } private function sysmsg() { - if (defined('DEBUG_ENABLED') && DEBUG_ENABLED) - debug_log('Entered with ()',129,__FILE__,__LINE__,__METHOD__); + if (DEBUG_ENABLED && (($fargs=func_get_args())||$fargs='NOARGS')) + debug_log('Entered (%%)',129,0,__FILE__,__LINE__,__METHOD__,$fargs); if (isset($this->sysmsg)) { foreach ($this->sysmsg as $index => $details) { @@ -289,8 +295,8 @@ class page { } private function body($raw=false) { - if (defined('DEBUG_ENABLED') && DEBUG_ENABLED) - debug_log('Entered with ()',129,__FILE__,__LINE__,__METHOD__); + if (DEBUG_ENABLED && (($fargs=func_get_args())||$fargs='NOARGS')) + debug_log('Entered (%%)',129,0,__FILE__,__LINE__,__METHOD__,$fargs); # Add the Session System Messages if (isset($_SESSION['sysmsg']) && is_array($_SESSION['sysmsg'])) { @@ -313,8 +319,8 @@ class page { } private function footer_print() { - if (defined('DEBUG_ENABLED') && DEBUG_ENABLED) - debug_log('Entered with ()',129,__FILE__,__LINE__,__METHOD__); + if (DEBUG_ENABLED && (($fargs=func_get_args())||$fargs='NOARGS')) + debug_log('Entered (%%)',129,0,__FILE__,__LINE__,__METHOD__,$fargs); printf('
%s
%s
%s