public static function show_debug($LEVEL = '', $IN_CONTENT = FALSE, $BACK_BUTTON = FALSE) { if (self::status($LEVEL)) { $output = ''; $after_titel = TRUE; $group_open = FALSE; $group_level = 0; foreach (self::$debug as $entry) { if (empty($LEVEL) || $LEVEL == $entry["LEVEL"]) { //if ( !empty($entry["GROUP"]) ){ if (is_int($entry["GROUP"]) and $entry["GROUP"] > 0) { # Handle groups if ($entry["GROUP"] == $group_level and $group_open) { $output .= '</fieldset><fieldset'; } elseif ($entry["GROUP"] == $group_level and !$group_open) { $output .= '<fieldset'; } elseif ($entry["GROUP"] > $group_level) { $output .= '<fieldset'; $group_level++; $group_open = TRUE; } elseif ($entry["GROUP"] < $group_level) { for ($level = $group_level; $level >= $entry["GROUP"]; $level--) { $output .= '</fieldset>'; } $output .= '<fieldset'; $group_level = $entry["GROUP"]; } # define the background if ((1 & $entry["GROUP"]) == 1) { $bgcolor = "even"; } else { $bgcolor = "odd"; } $output .= ' class="' . $bgcolor . '">'; // put title in FIELDSET - LEGEND if (!empty($entry["TITLE"])) { $output .= '<legend><b>' . $entry["TITLE"] . '</b></legend>'; } } elseif ($entry["GROUP"] === FALSE) { for ($level = $group_level; $level > 0; $level--) { $output .= '</fieldset>'; } $group_open = FALSE; } elseif (is_int($entry["GROUP"]) and $entry["GROUP"] < 0) { for ($level = (int) -$group_level; $level <= $entry["GROUP"]; $level++) { $output .= '</fieldset>'; } $group_open = FALSE; } elseif (is_array($entry["MESSAGE"])) { if ($after_titel) { $output .= NConf_HTML::swap_content($entry["MESSAGE"], $entry["TITLE"]); } else { $output .= NConf_HTML::swap_content($entry["MESSAGE"], $entry["TITLE"], FALSE, FALSE); } } else { if ($IN_CONTENT) { if (!empty($entry["TITLE"])) { if (!empty($entry["MESSAGE"])) { if ($after_titel) { $output .= NConf_HTML::text('<b>' . $entry["TITLE"] . '</b>: ' . $entry["MESSAGE"], FALSE); } else { $output .= NConf_HTML::text('<b>' . $entry["TITLE"] . '</b>: ' . $entry["MESSAGE"]); } // info about new line for next message $after_titel = FALSE; } else { $output .= NConf_HTML::title($entry["TITLE"]); // info about new line for next message $after_titel = TRUE; } } else { if ($after_titel) { $output .= NConf_HTML::text($entry["MESSAGE"], FALSE); $after_titel = FALSE; } else { $output .= NConf_HTML::text($entry["MESSAGE"]); } } } else { if (!empty($entry["TITLE"])) { $output .= NConf_HTML::text('<b>' . $entry["TITLE"] . '</b>: ' . $entry["MESSAGE"]); } else { // mostly for fieldset not making a first line //if ($after_titel){ // $output .= NConf_HTML::text($entry["MESSAGE"], FALSE); // $after_titel = FALSE; //}else{ $output .= NConf_HTML::text($entry["MESSAGE"]); //} } } } } } # print back button if wanted if ($BACK_BUTTON) { $output .= '<br><br>'; $output .= '<div id=buttons>'; $output .= '<input type=button onClick="window.location.href=\'' . $BACK_BUTTON . '\'" value="Back">'; $output .= '</div>'; } return $output; } else { return ''; } }
function db_handler($query, $output = "result", $debug_title = "query") { # Remove beginning spaces $query = trim($query); if (DB_NO_WRITES == 1 and !preg_match("/^SELECT/i", $query)) { message('INFO', "DB_NO_WRITES activated, no deletions or modifications will be performed"); } else { $result = mysql_query($query); // new DEBUG output $debug_query = NConf_HTML::text_converter("sql_uppercase", $query); $debug_query_output = NConf_HTML::swap_content($debug_query, 'Query', FALSE, FALSE); $debug_data_result = '<br>(Result output not yet defined)'; if ($result) { # Output related stuff # not already implemented, or replaced functions: //if ($output == "getOne") $output = "1st_field_data"; switch ($output) { case "affected": case "insert": case "update": case "delete": $affected = mysql_affected_rows(); if ($affected > 0) { //message('DEBUG', "# affected rows: $affected", "ok"); $return = $affected; } else { // needed for inserts ??: //message('DEBUG', "# affected rows: $affected", "nomatch"); $return = "yes"; } # DEBUG output with new API module: $debug_data_result = NConf_HTML::swap_content($return, 'Result: affected rows: ' . $affected . ')', FALSE, TRUE); break; case "getOne": $first_row = mysql_fetch_row($result); $return = $first_row[0]; # DEBUG output with new API module: $debug_data_result = NConf_HTML::text('<b>Result: getOne:</b>' . $return); break; case "result": $return = $result; # DEBUG output with new API module: $debug_data_result = NConf_HTML::text('<b>Result:</b>' . $return); break; case "query": $return = $query; # DEBUG output with new API module: $debug_data_result = NConf_HTML::text('<b>Result: see query above</b>'); break; case "insert_id": $new_id = mysql_insert_id(); $return = $new_id; # DEBUG output with new API module: $debug_data_result = NConf_HTML::text('<b>Result: last query generated ID:</b>' . $return); break; case "num_rows": $result = mysql_num_rows($result); $return = $result; # DEBUG output with new API module: $debug_data_result = NConf_HTML::text('<b>Result: number of rows:</b>' . $return); break; case "assoc": $result = mysql_fetch_assoc($result); $return = $result; # DEBUG output with new API module: $debug_data_result = NConf_HTML::swap_content($return, 'Result: assoc array:', FALSE, TRUE); break; case "array": $i = 0; $rows = array(); while ($row = mysql_fetch_assoc($result)) { $rows[$i] = $row; $i++; } $count = count($rows); $return = $rows; # DEBUG output with new API module: $debug_data_result = NConf_HTML::swap_content($return, 'Result array (rows: ' . $count . ')', FALSE, TRUE); break; case "array_direct": $i = 0; $rows = array(); while ($row = mysql_fetch_row($result)) { $rows[$i] = $row[0]; $i++; } $count = count($rows); $return = $rows; # DEBUG output with new API module: $debug_data_result = NConf_HTML::swap_content($return, 'Result array_direct (rows: ' . $count . ')', FALSE, TRUE); break; case "array_2fieldsTOassoc": $rows = array(); while ($row = mysql_fetch_row($result)) { $rows[$row[0]] = $row[1]; } $count = count($rows); $return = $rows; # DEBUG output with new API module: $debug_data_result = NConf_HTML::swap_content($return, 'Result array_2fieldsTOassoc (rows: ' . $count . ')', FALSE, TRUE); break; # Failed on output case # Failed on output case default: message('ERROR', "db_handler failed on output case"); return FALSE; } // Debug and result return $debug_entry = NConf_HTML::swap_content($debug_query_output . $debug_data_result, "<b>SQL</b> " . $debug_title, FALSE, FALSE, 'debbug_query'); message('DEBUG', $debug_entry); return $return; } else { // makes an open debug entry with mysql_error info $debug_entry = NConf_HTML::swap_content($debug_query_output . '<br><b>mysql error:</b>' . mysql_error(), '<b class="attention" >SQL</b> ' . $debug_title, TRUE, FALSE, 'debbug_query color_warning'); NConf_DEBUG::set($debug_entry, 'DEBUG'); } } }
echo NConf_HTML::title("Info:", 2); echo NConf_DEBUG::show_debug("INFO"); echo NConf_HTML::line(); } // Display jQuery/ajax errors echo '<div id="jquery_error" class="ui-state-error" style="display: none">'; echo '<span style="float: left; margin-right: 0.3em;" class="ui-icon ui-icon-alert"> </span>'; echo NConf_HTML::title("Error:", 2); echo '</div>'; if (NConf_DEBUG::status("ERROR")) { echo NConf_HTML::title("Error:", 2); echo '<font color="red">'; echo NConf_DEBUG::show_debug("ERROR"); echo '</font>'; echo NConf_HTML::line(); } if (DEBUG_MODE == 1) { echo '<div id="jquery_console_parent" style="padding: 0; display: none">'; echo NConf_HTML::swap_content('<div id="jquery_console"></div>', "<b>jQuery debugging</b>", FALSE, FALSE); echo '</div>'; NConf_DEBUG::display(); } ?> </div> </div> <!-- END OF DIV "footer" --> </body> </html>
# Try to logon user to ldap $ldap_user_dn = str_replace(USER_REPLACEMENT, $user_loginname, BASE_DN); NConf_DEBUG::set($ldap_user_dn, 'DEBUG', 'ldap user dn'); $user_pwd = $_POST["password"]; $ldap_response = @ldap_bind($ldapconnection, $ldap_user_dn, $user_pwd); if ($ldap_response and $user_loginname and $user_pwd) { NConf_DEBUG::set("success", 'DEBUG', 'ldap bind'); # If user login was successfull, look for group # admins are in group : ADMIN_GROUP # normal nconf user are in group : USER_GROUP # all other do not have access # AdminUsers $sr = ldap_search($ldapconnection, GROUP_DN, ADMIN_GROUP); $results = ldap_get_entries($ldapconnection, $sr); # debug $debug_entry = NConf_HTML::swap_content($results, "<b>LDAP</b> ldap_get_entries:", FALSE, FALSE); message($debug, $debug_entry); $Admin_user_array = $results[0]["memberuid"]; # remove field count unset($Admin_user_array["count"]); # BasicUsers $sr = ldap_search($ldapconnection, GROUP_DN, USER_GROUP); $results = ldap_get_entries($ldapconnection, $sr); $Basic_user_array = $results[0]["memberuid"]; # remove field count unset($Basic_user_array["count"]); # Users Infos $justthese = array("cn"); //$justthese = array("cn", "description", "uid"); $sr = ldap_read($ldapconnection, $ldap_user_dn, "(objectclass=*)", $justthese); $results = ldap_get_entries($ldapconnection, $sr);
public function setURL($URL, $REGEX_OPEN_END = TRUE, $GROUPS = array(), $REQUEST = array()) { # do not check if already allowed if ($this->url_check_status == TRUE) { return; } # check URL for passed attributes (should only be the scriptname) # the navigation links will need this handler # search for query part in URL # TODO: check if ampersand can be optimized on xmode views: # Array( # [class] => contact # [amp;xmode] => pikett # ) # perhaps using $_SERVER['QUERY_STRING'] ? if (strpos($URL, "?") !== FALSE) { $url_parsed = parse_url($URL); $this->debug .= NConf_HTML::swap_content($url_parsed, "ACL - Found query in URL : Parsing URL", FALSE, TRUE); # get request items parse_str($url_parsed["query"], $REQUEST); $this->debug .= NConf_HTML::swap_content($REQUEST, "ACL - fetched query and converted to REQUEST array", FALSE, TRUE); # override URL with correct scriptname $URL = $url_parsed["path"]; } # check group permission if (empty($GROUPS) or in_array($this->group, $GROUPS)) { if ($REGEX_OPEN_END) { if (!preg_match('/^' . preg_quote($URL) . '\\w*/', $this->current_script)) { return; } } else { if (!preg_match('/^' . preg_quote($URL) . '$/', $this->current_script)) { return; } } $this->debug .= NConf_HTML::text("URL matched: {$URL}", TRUE); # check for request limitations if (!empty($REQUEST)) { # check if needed request items match $diff = array_diff($REQUEST, $_REQUEST); if (!empty($diff)) { # for debugging these could be grouped together $this->debug .= NConf_HTML::swap_content($REQUEST, "REQUEST items do not match", FALSE, TRUE); return; } else { $this->debug .= NConf_HTML::swap_content($REQUEST, "REQUEST items matched", FALSE, TRUE); } //NConf_DEBUG::set($REQUEST, 'DEBUG', "REQUEST matched"); } # all checks passed, URL is fine $this->url_check_status = TRUE; return; } }
} } } # get also the debug informations if ($debug == 'yes' and $json == 'no') { $title = 'Load file "' . $file_path . '" @ ' . date("H:i:s"); // set ERROR if (NConf_DEBUG::status('ERROR')) { echo '<div id="ajax_error">'; echo NConf_DEBUG::show_debug('ERROR', TRUE); echo '</div>'; } // set DEBUG if (NConf_DEBUG::status('DEBUG')) { echo '<div id="ajax_debug">'; echo NConf_HTML::swap_content(NConf_DEBUG::show_debug('DEBUG', TRUE), $title, FALSE, FALSE, 'color_list3'); echo '</div>'; } if (!empty($ajax) and $ajax == 'yes') { ?> <!-- jQuery part --> <script type="text/javascript"> $(document).ready(function(){ // fetch ERROR part and give to footer and display it $("#jquery_error").append( $("#ajax_error") ); $("#ajax_error").parent("#jquery_error").show("blind"); // fetch DEBUG part and give to footer (will be displayed if debug is enabled) $("#ajax_debug").prependTo( $("#jquery_console") ); $("#jquery_console_parent").fadeIn("slow"); });