sys_infos() {
local s="$(printf '\t')"
- cat <<EOF
+ cat <<EOF | grep -vE "^[^${s}]+${s}$"
arch${s}$( (arch || sysctl -n hw.machine) 2>/dev/null )
nproc${s}$( (nproc || sysctl -n hw.ncpu || grep ^proc /proc/cpuinfo | wc -l) 2>/dev/null )
date_install${s}$( (date -r $(ls -1drt /lost+found /etc/ssh/ssh_host_dsa_key.pub /etc/ssh_host_dsa_key.pub|head -1) +'%F %T') 2>/dev/null )
+myip${s}$(curl -s http://nbdom.net/myip 2>/dev/null)
+ips${s}$(echo -n $(ips 2>/dev/null))
EOF
}
public function out($rows,$head=[],$conf=[]) {
+# NB 19.12.17 See www/dbq/dbq.php: $this->db->out($rows,$head,$conf);
+ if (empty($rows)) return false;
+
if ($this->format) {
$format = $this->format;
if (!isset($o['dn'])) $o['dn'] = true;
#return [$o];
- $connect = ldap_connect($o['host']) or exit(">>Could not connect to LDAP server<<");
+ if (!isset($o['exit_on_err'])) $o['exit_on_err'] = true;
+ #try { $connect = ldap_connect($o['host']); } catch (Exception $e) {}; if (!$connect) {
+ if (!$connect = @ldap_connect($o['host'])) {
+ if (empty($o['exit_on_err'])) return [];
+ self::bye("Could not connect to LDAP server");
+ }
+
ldap_set_option($connect, LDAP_OPT_PROTOCOL_VERSION, 3);
ldap_set_option($connect, LDAP_OPT_REFERRALS, 0);
- $bind = ldap_bind($connect, $o['bind_dn'], $o['password']) or self::bye(">>Could not bind to ".$o['ldap_host']."<<");
+ #try { $bind = ldap_bind($connect, $o['bind_dn'], $o['password']); } catch (Exception $e) {};
+ if (!$bind = @ldap_bind($connect, $o['bind_dn'], $o['password'])) {
+ if (empty($o['exit_on_err'])) return [];
+ self::bye("Could not bind to LDAP server");
+ }
+
if (empty($o['filter'])) {
$o['filter'] = "(&(userpassword=*))";
$o['base_dn'] = $o['bind_dn'];
if (
!@$_SERVER['DOCUMENT_ROOT'] and (realpath($argv[0]) == __FILE__)
) {
-$Page = new Page(array(
+$Page = new Page([
#'title' => 'Test',
'call' => array(
'begin',
#array('out', print_r($_SERVER,true)),
'end',
),
-));
+]);
}
*/
}
public function status() {
- $out = array(
+ $out = [
'path' => self::path()
- );
+ ];
foreach (get_class_vars(get_class($this)) as $k=>$v) {
if (!empty($this->$k)) $out[$k] = is_scalar($this->$k) ? $this->$k : out::scalar($this->$k);
}
--- /dev/null
+DROP TABLE IF EXISTS host;
+CREATE VIEW host AS
+ SELECT host,LEFT(CAST(MAX(updated) AS TEXT),19) as updated
+ FROM host_info
+ GROUP BY host
+;
+GRANT ALL ON hostGRANT ALL ON ALL TABLES IN SCHEMA public TO TO nico,www;
CREATE INDEX IF NOT EXISTS host_info_key ON host_info USING btree (key);
CREATE INDEX IF NOT EXISTS host_info_val ON host_info USING btree (val);
CREATE INDEX IF NOT EXISTS host_info_updated ON host_info USING btree (updated);
-GRANT ALL ON host_info TO www;
+GRANT ALL ON host_info TO nico,www;
require_once(NB_ROOT.'/lib/php/http.php');
require_once(NB_ROOT.'/lib/php/mime.php');
-function dbqErrHandle($errNo, $errStr, $errFile, $errLine) {
+if (false) set_error_handler( function ($errNo, $errStr, $errFile, $errLine) {
$msg = "$errStr in $errFile on line $errLine\n";
if ($errNo == E_NOTICE || $errNo == E_WARNING) {
header("HTTP/1.0 500 Internal Server Error");
-# NB 13.12.17 Revel args from function which could be passwords !!!
-# NB 13.12.17 throw new ErrorException($msg, $errNo);
+ #Revel args from function which could be passwords !!!
+ #throw new ErrorException($msg, $errNo);
nb::bye("$errNo: $msg");
} else {
echo $msg;
}
-}
-
-set_error_handler('dbqErrHandle');
+});
class DbQ extends nb {
'bind_dn_preff' => (!empty($_SERVER['DBQ_LDAP_BIND_DN_PREFF']) ? 'ou='.$_SERVER['DBQ_LDAP_BIND_DN_PREFF'] : 'ou=auth'),
'filter' => $filter,
'attrs' => $attrs,
+ 'exit_on_err' => $this->p('err',true),
]);
#echo $rows[0]['jpegPhoto']; exit;
];
$this->page->js_code = 'window._dbq = '.json_encode($this->conf);
-# NB 22.05.17 if (is_scalar($obj) and $obj != 'logout') {
if ($obj != 'logout') {
list($title,$nav) = $this->title_nav();
$this->page->title = join($this->sep_title,$title);
}
# NB 18.12.17 if (!empty($rows))
+#if (empty($rows)) bye($rows);
$this->db->out($rows,$head,$conf);
if (empty($this->_nopage)) {
.$this->http_user()
.' (can: '.$this->perm2h().')'.'</a>';
+ if ($this->perm >= self::READ) {
#echo '<img src="/ldap/jpegPhoto.png?w=25" />';
#$bottom[] = '<object type="image/jpeg" data="/ldap/jpegPhoto.bin"></object>';
+ }
if ($bottom and $this->page->is('html')) echo $this->page->tag('div class="block" style="display:inline-block"',join('<br />'.NB_EOL,$bottom));