Skip to content
Snippets Groups Projects
Commit 1c35c577 authored by Hahn Axel (hahn)'s avatar Hahn Axel (hahn)
Browse files

Initial commit

parents
No related branches found
No related tags found
No related merge requests found
# ldap.class.php
A PHP class that I use
* for authentication of user logins
* CRUD actions on ldap nodes
Institute for Medical Education; University of Bern
License: GNU GPL 3
see [docs](docs/)
\ No newline at end of file
{
"title": "__PRODUCT__",
"author": "Axel Hahn",
"tagline": "__DESCRIPTION__",
"ignore": {
"files": ["30_PHP-client/Plugins/Checks/_skeleton.md"],
"folders": ["99_Not_Ready"]
},
"html": {
"auto_toc": true,
"auto_landing": false,
"date_modified": false,
"jump_buttons": true,
"edit_on_github_": "iml-it/__PROJECT__/tree/master/docs",
"edit_on_": {
"name": "Gitlab",
"basepath": "https://git-repo.iml.unibe.ch/iml-open-source/__PROJECT__/tree/master/docs"
},
"links": {
"Git Repo": "__GITURL__"
},
"theme": "daux-blue",
"search": true
}
}
\ No newline at end of file
/*
patch css elements of daux.io blue theme
version 2022-05-13
*/
/* ---------- vars ---------- */
:root{
/* background colors */
--bg:none;
--bg-body: #fff;
--bg-navlinkactive:#f4f4f4;
--bg-navlinkactive: linear-gradient(-90deg,rgba(0,0,0,0), rgba(40,60,80,0.05) 30%);
--bg-pre:#f8f8f8;
--bg-toc: #fff;
/* foreground colors */
--color: #234;
--navlinkactive:#f33;
--title: #aaa;
--link:#12a;
--toclink:rgba(40,60,80,0.8);
--h1: rgba(40,60,80,0.8);
--h1-bottom: 1px solid rgba(40,60,80,0.1);
--h2: #468;
--h3: #579;
}
/* ---------- tags ---------- */
a.Brand::before {
background: rgb(255,0,51);
color: #fff;
font-family: arial;
font-weight: bold;
padding: 0.5em 0.3em;
content: 'IML';
margin-right: 0.4em;
}
body, *{color: var(--color);}
body{background: var(--bg-body);}
a{color: var(--link);}
a:hover{opacity: 0.7;}
h1>a{ color:var(--title);}
_h1:nth-child(1){position: fixed; background: var(--bg); box-shadow: 0 0 1em #ccc; padding: 0 1em}
h1:nth-child(1)>a{ color:var(--navlinkactive); }
.s-content h1{color: var(--h1); font-size: 200%; font-weight:bold; margin-top: 2em; border-bottom: var(--h1-bottom);}
.s-content h2{color: var(--h2); font-size: 160%; }
.s-content h3{color: var(--h3); font-size: 140%; }
.s-content h4{margin: 0; font-size: 100%; text-align: center; background-color: rgba(0,0,0,0.05);padding: 0.3em;}
.s-content pre{
background: var(--bg-pre);
}
/* ---------- classes ---------- */
.required{color:#a42;}
.optional{color:#888;}
/* ----- top left */
.Brand,
.Columns__left {
background: var(--bg);
border-right: 0px solid #e7e7e9;
color: var(--color);
}
.Brand{font-size: 200%;
background_: linear-gradient(-10deg,#fff 50%, #ddd);
background: var(--bg);
}
.Columns__right__content {
background: var(--bg);
}
/* ----- Navi left */
.Nav a:hover{
background: none;
color: var(--navlinkactive) !important;
}
.Nav__item--active {
border-right_: 0.3em solid var(--navlinkactive);
}
.Nav__item--active > a{
background: var(--bg-navlinkactive);
color: var(--navlinkactive);
}
.Nav .Nav .Nav__item--active a {
color: var(--navlinkactive);
}
.Nav .Nav .Nav__item a {
opacity: 1;
}
.Nav__item--open > a {
background-color: var(--bg);
}
.Nav a[href*="__Welcome"]{
background: url("/icons/house.png") no-repeat 10px 4px ;
padding-left: 40px;
}
.Nav a[href*="__How_does_it_work"]{
background: url("/icons/light-bulb.png") no-repeat 10px 4px ;
padding-left: 40px;
}
/* ---------- classes ---------- */
/* FIX smaller fnt size in tables */
.s-content table {
font-size: 1em;
}
/* TOC */
@media(min-width:1700px){
.TableOfContentsContainer{
position: fixed;
right: 2em;
top: 1em;
}
}
.TableOfContentsContainer{
border-top-left-radius: 1em;
background-color: var(--bg-toc);
border-left: 2px solid rgba(0,0,0,0.05);
padding: 0em;
}
.TableOfContentsContainer__content {
border: none;
font-size: 0.5em;
}
ul.TableOfContents ul{
list-style-type: none;
padding-left: 1em;
}
.TableOfContentsContainer a{ color:var(--toclink);}
.TableOfContentsContainer__content > .TableOfContents > li + li {
border-top: none;
}
.TableOfContentsContainer__content > .TableOfContents > li {
border-bottom: 1px dashed #ddd;
}
/* pager - prev .. next */
.s-content{
margin-bottom: 6em;
}
.Pager{
border-top: 1px dashed #aaa; margin: 0; padding: 1em;
}
.Pager a{
color:var(--navlinkactive);
}
<?php
/**
*
* Axels first router
*
* --------------------------------------------------------------------------------<br>
* <br>
* THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE <br>
* LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR <br>
* OTHER PARTIES PROVIDE THE PROGRAM ?AS IS? WITHOUT WARRANTY OF ANY KIND, <br>
* EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED <br>
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE <br>
* ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. <br>
* SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY <br>
* SERVICING, REPAIR OR CORRECTION.<br>
* <br>
* --------------------------------------------------------------------------------<br>
* @version 1.0
* @author Axel Hahn
* @link https://github.com/iml-it/appmonitor
* @license GPL
* @license http://www.gnu.org/licenses/gpl-3.0.html GPL 3.0
* @package -
*
**/
class tinyrouter{
public $sUrl = '';
public $aRoutes = [];
public $aMatch = false;
/**
* constructor
* @param $aRoutes array array of routings
* @param $sUrl string incoming url
*/
public function __construct($aRoutes=[], $sUrl=false){
$this->setRoutes($aRoutes);
$this->setUrl($sUrl);
}
/**
* detect last matching route item
* if no route matches then it returns false
*/
protected function _getRoute(){
$aReturn=[];
$this->aMatch=[];
if(!$this->sUrl || !count($this->aRoutes)){
return false;
}
$aReqParts=$this->getUrlParts();
foreach($this->aRoutes as $aRoutecfg){
$sRoute=$aRoutecfg[0];
$aParts=$this->getUrlParts($sRoute);
if (count($aParts) == count($aReqParts)){
$iPart=0;
$aVars=[];
$bFoundRoute=false;
foreach($aParts as $sPart){
// detect @varname or @varname:regex in a routing
if($sPart[0]=="@"){
$sValue=$aReqParts[$iPart];
preg_match('/\@([a-z]*):(.*)/', $sPart, $match);
if(isset($match[2])){
// if a given regex does not match the value then abort
if(!preg_match("/^$match[2]$/", $sValue)){
$bFoundRoute=false;
break;
}
}
// store a variable without starting @
$aVars[$match[1]]=$sValue;
} else {
// no @ ... if string of url parts in url and route
// do not match then we abort
if($aParts[$iPart]!==$aReqParts[$iPart]){
$bFoundRoute=false;
break;
}
}
$bFoundRoute=true;
// $aVars[$iPart]=$sValue;
$iPart++;
}
if($bFoundRoute){
$aReturn=[
"route"=>$aRoutecfg[0],
"callback"=>$aRoutecfg[1],
"vars"=>$aVars
];
}
}
}
$this->aMatch=count($aReturn) ? $aReturn : false;
return $this->aMatch;
}
/**
* set routes
*/
public function setRoutes($aRoutes=[]){
if(is_array($aRoutes) && count($aRoutes)){
$this->aRoutes=$aRoutes;
$this->_getRoute();
}
return true;
}
/**
* set incoming url
*/
public function setUrl($sUrl){
$this->sUrl=$sUrl;
$this->_getRoute();
}
/**
* helper function: get url parts as array
* @returns array
*/
public function getUrlParts($sUrl=false){
if(!$sUrl){
$sUrl=$this->sUrl;
}
$aReqParts=explode('/', $sUrl);
if ($sUrl[0]=='/'){
array_shift($aReqParts);
}
return $aReqParts;
}
/**
* detect last matching route item
* if no route matches then it returns false
* @return array|bool
*/
public function getRoute(){
return $this->aMatch;
}
/**
* return the callback of matching route
* @return string
*/
public function getCallback(){
return isset($this->aMatch['callback']) ? $this->aMatch['callback'] : false;
}
/**
* return the variables as keys in route parts with starting @ character
* @return array
*/
public function getVars(){
return isset($this->aMatch['vars']) ? $this->aMatch['vars'] : false;
}
/**
* return the variables as keys in route parts with starting @ character
* @return string
*/
public function getVar($sVarname){
return isset($this->aMatch['vars'][$sVarname]) ? $this->aMatch['vars'][$sVarname] : false;
}
/**
* get an array with next level route entries releative to the current route
* @return array
*/
public function getSubitems(){
$sKey='allowed_subkeys';
$aReturn=[$sKey=>[]];
$iCurrent=count($this->getUrlParts());
foreach($this->aRoutes as $aRoutecfg){
$sRoute=$aRoutecfg[0];
if(count($this->getUrlParts($sRoute))-1 == $iCurrent && strstr($sRoute, $this->aMatch['route']) ){
$aReturn[$sKey][]=basename($sRoute);
}
}
return $aReturn;
}
}
\ No newline at end of file
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment