added the webui to the tarball

This commit is contained in:
SJ
2012-02-08 23:14:28 +01:00
parent 79cdeed1b6
commit 1211e9a39c
272 changed files with 26456 additions and 11 deletions

View File

@ -0,0 +1,101 @@
<?php
class LDAP {
private $link;
private $bind;
public function __construct($ldaphost, $binddn, $bindpw) {
$this->link = ldap_connect($ldaphost) or exit('Error: ldap_connect()');
ldap_set_option($this->link, LDAP_OPT_PROTOCOL_VERSION, 3);
if(@ldap_bind($this->link, $binddn, $bindpw)) {
$this->bind = 1;
}
else {
$this->bind = 0;
}
return $this->link;
}
public function is_bind_ok() {
return $this->bind;
}
public function query($basedn, $filter, $justthese) {
$i = 0;
$data = array();
$sr = ldap_search($this->link, $basedn, $filter, $justthese);
$results = ldap_get_entries($this->link, $sr);
for($i=0; $i < $results['count']; $i++) {
for($k=0; $k < $results[$i]['count']; $k++) {
$attr = $results[$i][$k];
if($results[$i][$attr]['count'] == 1) {
$data[$i][$attr] = isset($results[$i][$attr][0]) ? $results[$i][$attr][0] : "";
}
else {
$data[$i][$attr] = isset($results[$i][$attr]) ? $results[$i][$attr] : "";
}
}
$data[$i]['dn'] = $results[$i]['dn'];
}
$query = new stdClass();
$query->row = isset($data[0]) ? $data[0] : array();
$query->dn = isset($results[0]['dn']) ? $results[0]['dn'] : "";
$query->rows = $data;
$query->num_rows = $results['count'];
unset($data);
return $query;
}
public function add($dn, $entry) {
return ldap_add($this->link, $dn, $entry);
}
public function modify($dn, $entry) {
return ldap_modify($this->link, $dn, $entry);
}
public function rename($dn, $newrdn, $newparent) {
return ldap_rename($this->link, $dn, $newrdn, $newparent, TRUE);
}
public function replace($dn, $entry) {
return ldap_mod_replace($this->link, $dn, $entry);
}
public function delete($dn) {
return ldap_delete($this->link, $dn);
}
public function __destruct() {
ldap_unbind($this->link);
}
}
?>

View File

@ -0,0 +1,88 @@
<?php
class MySQL {
private $link;
private $affected;
public function __construct($hostname, $username, $password, $database, $prefix = NULL) {
try {
$this->link = new PDO("mysql:host=$hostname;dbname=$database", $username, $password,
array(
PDO::MYSQL_ATTR_INIT_COMMAND => "SET NAMES utf8",
PDO::MYSQL_ATTR_INIT_COMMAND => "SET CHARACTER SET utf8"
)
);
}
catch(PDOException $exception) {
exit('Error: ' . $exception->getMessage() . " on database: $database<br />");
}
$this->affected = 0;
}
public function select_db($database) { }
public function query($sql, $arr = array()) {
$query = new stdClass();
$query->error = 1;
$query->errmsg = "Error";
$query->query = $sql;
$time_start = microtime(true);
$i = 0;
$data = array();
$s = $this->link->prepare($sql);
if(!$s) { return $query; }
$s->execute($arr);
$this->affected = $s->rowCount();
$R = $s->fetchAll();
while(list ($k, $v) = each($R)){
$data[$i] = $v;
$i++;
}
$query->row = isset($data[0]) ? $data[0] : array();
$query->rows = $data;
$query->num_rows = $i;
$query->error = 0;
$query->errmsg = "";
unset($data);
$time_end = microtime(true);
$query->exec_time = $time_end - $time_start;
return $query;
}
public function countAffected() {
return $this->affected;
}
public function getLastId() {
return $this->link->lastInsertId();
}
public function __destruct() { }
}
?>

View File

@ -0,0 +1,92 @@
<?php
class Sphinx {
private $link;
private $prefix;
public function __construct($hostname, $username, $password, $database, $prefix = NULL) {
if (!$this->link = mysql_connect($hostname, $username, $password)) {
exit('Error: Could not make a database connection using ' . $username . '@' . $hostname);
}
$this->prefix = $prefix;
mysql_query("SET NAMES 'utf8'", $this->link);
mysql_query("SET CHARACTER SET utf8", $this->link);
}
public function query($sql) {
$query = new stdClass();
$query->query = $sql;
$query->error = 0;
$query->errmsg = "";
$time_start = microtime(true);
$resource = mysql_query(str_replace('#__', $this->prefix, $sql), $this->link);
if($resource){
if(is_resource($resource)){
$i = 0;
$data = array();
while ($result = mysql_fetch_assoc($resource)) {
$data[$i] = $result;
$i++;
}
mysql_free_result($resource);
$query->row = isset($data[0]) ? $data[0] : array();
$query->rows = $data;
$query->num_rows = $i;
unset($data);
$time_end = microtime(true);
$query->exec_time = $time_end - $time_start;
return $query;
}
else {
return $query;
}
}
else {
$_SESSION['error'] = 'Error: ' . mysql_error() . '<br />Error No: ' . mysql_errno() . '<br />' . $sql;
$query->errmsg = 'Error: ' . mysql_error() . '<br />Error No: ' . mysql_errno() . '<br />' . $sql;
$query->error = 1;
return $query;
}
}
public function countAffected() {
return mysql_affected_rows($this->link);
}
public function getLastId() {
return mysql_insert_id($this->link);
}
public function __destruct() {
mysql_close($this->link);
}
}
?>

View File

@ -0,0 +1,93 @@
<?php
class SQLite {
private $link;
private $affected;
public function __construct($hostname, $username, $password, $database, $prefix = NULL) {
$fixperm = 0;
if(!file_exists($database)) { $fixperm = 1; }
try {
$this->link = new PDO("sqlite:$database", 'OPEN_CREATE');
}
catch(PDOException $exception) {
exit('Error: ' . $exception->getMessage() . " on $database<br />");
}
if($fixperm == 1) { chmod($database, 0660); }
$this->affected = 0;
}
public function select_db($database) { }
public function query($sql) {
$query = new stdClass();
$query->error = 1;
$query->errmsg = "Error";
$query->query = $sql;
$time_start = microtime(true);
$i = 0;
$data = array();
$s = $this->link->prepare($sql);
if(!$s) { return $query; }
$s->execute();
$this->affected = $s->rowCount();
$R = $s->fetchAll();
while(list ($k, $v) = each($R)){
$data[$i] = $v;
$i++;
}
$query->row = isset($data[0]) ? $data[0] : array();
$query->rows = $data;
$query->num_rows = $i;
$query->error = 0;
$query->errmsg = "";
unset($data);
$time_end = microtime(true);
$query->exec_time = $time_end - $time_start;
return $query;
}
public function escape($value) {
//return $this->link->quote($value);
return $value;
}
public function countAffected() {
return $this->affected;
}
public function getLastId() {
return $this->link->lastInsertId();
}
public function __destruct() { }
}
?>