Skip to content
Snippets Groups Projects

Compare revisions

Changes are shown as if the source revision was being merged into the target revision. Learn more about comparing revisions.

Source

Select target project
No results found
Select Git revision
  • Legacy_Php7
  • master
2 results

Target

Select target project
No results found
Select Git revision
  • Legacy_Php7
  • master
2 results
Show changes

Commits on Source 25

20 files
+ 771
265
Compare changes
  • Side-by-side
  • Inline

Files

+1 −1
Original line number Original line Diff line number Diff line
# ======================================================================
# ======================================================================
#
#
# GENERATED BY docker/init.sh - template: ./templates/dot_env - e2cde05722688ff85d3a93e9cd55787e
# GENERATED BY init.sh - template: ./templates/dot_env - e2cde05722688ff85d3a93e9cd55787e
# values to be used in docker-composer.yml
# values to be used in docker-composer.yml
#
#
# ======================================================================
# ======================================================================
Original line number Original line Diff line number Diff line
#
#
# GENERATED BY docker/init.sh - template: ./templates/web-server-Dockerfile - 42dce773c83597a7d05af398bdd66d15
# GENERATED BY init.sh - template: ./templates/web-server-Dockerfile - 42dce773c83597a7d05af398bdd66d15
#
#
FROM php:8.1-apache
FROM php:8.1-apache


Original line number Original line Diff line number Diff line
#
#
# GENERATED BY docker/init.sh - template: ./templates/vhost_app.conf - 9a9cf79de5a3584c0cef6cb79c339c25
# GENERATED BY init.sh - template: ./templates/vhost_app.conf - 9a9cf79de5a3584c0cef6cb79c339c25
#
#




Original line number Original line Diff line number Diff line
;
;
; GENERATED BY docker/init.sh - template: ./templates/extra-php-config.ini - 80c23edaf568e2c36b9926fe2339e481
; GENERATED BY init.sh - template: ./templates/extra-php-config.ini - 80c23edaf568e2c36b9926fe2339e481
;
;
[PHP]
[PHP]


Original line number Original line Diff line number Diff line
#
#
# GENERATED BY docker/init.sh - template: ./templates/docker-compose.yml - 97c88229bd2b5099544c013052b8d9c3
# GENERATED BY init.sh - template: ./templates/docker-compose.yml - 97c88229bd2b5099544c013052b8d9c3
#
#
# ======================================================================
# ======================================================================
#
#
+22 −12
Original line number Original line Diff line number Diff line
@@ -4,8 +4,12 @@
# DOCKER PHP DEV ENVIRONMENT :: INIT
# DOCKER PHP DEV ENVIRONMENT :: INIT
#
#
# ----------------------------------------------------------------------
# ----------------------------------------------------------------------
# 2021-11-nn  <axel.hahn@iml.unibe.ch>
# 2021-11-nn  v1.0 <axel.hahn@iml.unibe.ch>
# 2022-07-19  <axel.hahn@iml.unibe.ch>  support multiple dirs for setfacl
# 2022-07-19  v1.1 <axel.hahn@iml.unibe.ch>  support multiple dirs for setfacl
# 2022-11-16  v1.2 <www.axel-hahn.de>        use docker-compose -p "$APP_NAME"
# 2022-12-18  v1.3 <www.axel-hahn.de>        add -p "$APP_NAME" in other docker commands
# 2022-12-20  v1.4 <axel.hahn@unibe.ch>      replace fgrep with grep -F
# 2023-03-06  v1.5 <www.axel-hahn.de>        up with and without --build
# ======================================================================
# ======================================================================


cd $( dirname $0 )
cd $( dirname $0 )
@@ -14,6 +18,8 @@ cd $( dirname $0 )
# git@git-repo.iml.unibe.ch:iml-open-source/docker-php-starterkit.git
# git@git-repo.iml.unibe.ch:iml-open-source/docker-php-starterkit.git
selfgitrepo="docker-php-starterkit.git"
selfgitrepo="docker-php-starterkit.git"


_version="1.5"

# ----------------------------------------------------------------------
# ----------------------------------------------------------------------
# FUNCTIONS
# FUNCTIONS
# ----------------------------------------------------------------------
# ----------------------------------------------------------------------
@@ -86,7 +92,7 @@ function _removeGitdata(){
function _fix_no-db(){
function _fix_no-db(){
    local _file=$1
    local _file=$1
    if [ $DB_ADD = false ]; then
    if [ $DB_ADD = false ]; then
        typeset -i local iStart=$( cat ${_file} | fgrep -n "$CUTTER_NO_DATABASE" | cut -f 1 -d ':' )-1
        typeset -i local iStart=$( cat ${_file} | grep -Fn "$CUTTER_NO_DATABASE" | cut -f 1 -d ':' )-1
        if [ $iStart -gt 0 ]; then
        if [ $iStart -gt 0 ]; then
            sed -ni "1,${iStart}p" ${_file}
            sed -ni "1,${iStart}p" ${_file}
        fi
        fi
@@ -186,7 +192,7 @@ function _showContainers(){
    local bLong=$1
    local bLong=$1
    h2 CONTAINERS
    h2 CONTAINERS
    if [ -z "$bLong" ]; then
    if [ -z "$bLong" ]; then
        docker-compose ps
        docker-compose -p "$APP_NAME" ps
    else
    else
        docker ps | grep $APP_NAME
        docker ps | grep $APP_NAME
    fi
    fi
@@ -233,7 +239,7 @@ action=$1


while true; do
while true; do
    echo
    echo
    echo -e "\e[32m===== INITIALIZER FOR APP [$APP_NAME] ===== \e[0m"
    echo -e "\e[32m===== INITIALIZER FOR DOCKER APP [$APP_NAME] v$_version ===== \e[0m\n\r"


    if [ -z "$action" ]; then
    if [ -z "$action" ]; then


@@ -246,7 +252,8 @@ while true; do
        echo "  t - generate files from templates"
        echo "  t - generate files from templates"
        echo "  T - remove generated files"
        echo "  T - remove generated files"
        echo
        echo
        echo "  u - startup containers    docker-compose up -d"
        echo "  u - startup containers    docker-compose ... up -d"
        echo "  U - startup containers    docker-compose ... up -d --build"
        echo "  s - shutdown containers   docker-compose stop"
        echo "  s - shutdown containers   docker-compose stop"
        echo "  r - remove containers     docker-compose rm -f"
        echo "  r - remove containers     docker-compose rm -f"
        echo
        echo
@@ -281,24 +288,27 @@ while true; do
            _showInfos
            _showInfos
            _wait
            _wait
            ;;
            ;;
        u)
        u|U)
            if docker-compose --verbose up -d --remove-orphans --build; then
            dockerUp="docker-compose -p "$APP_NAME" --verbose up -d --remove-orphans"
                # test ! -z "${APP_ONSTARTUP}" && sleep 2 && docker exec -it appmonitor-server /bin/bash -c "${APP_ONSTARTUP}" 
            if [ "$action" = "U" ]; then
                dockerUp+=" --build"
            fi
            if $dockerUp; then
                echo "In a web browser:"
                echo "In a web browser:"
                echo "  $frontendurl"
                echo "  $frontendurl"
            else
            else
                echo "ERROR: docker-compose up failed :-/"
                echo "ERROR: docker-compose up failed :-/"
                docker-compose logs | tail
                docker-compose -p "$APP_NAME" logs | tail
            fi
            fi
            echo
            echo


            _wait
            _wait
            ;;
            ;;
        s)
        s)
            docker-compose stop
            docker-compose -p "$APP_NAME" stop
            ;;
            ;;
        r)
        r)
            docker-compose rm -f
            docker-compose -p "$APP_NAME" rm -f
            ;;
            ;;
        c)
        c)
            docker ps
            docker ps
Original line number Original line Diff line number Diff line
@@ -14,7 +14,8 @@
            "basepath": "https://git-repo.iml.unibe.ch/iml-open-source/imldeployment/tree/master/docs"
            "basepath": "https://git-repo.iml.unibe.ch/iml-open-source/imldeployment/tree/master/docs"
        },
        },
        "links": {
        "links": {
            "GitHub Repo": "https://git-repo.iml.unibe.ch/iml-open-source/imldeployment/"
            "GitHub Repo": "https://git-repo.iml.unibe.ch/iml-open-source/imldeployment/",
            "IML Opensource": "https://os-docs.iml.unibe.ch/"
        },
        },
        "theme": "daux-blue",
        "theme": "daux-blue",
        "search": true
        "search": true
+212 −121
Original line number Original line Diff line number Diff line
/*
/*

    override css elements of daux.io blue theme
    patch css elements of daux.io blue theme
    version 2022-11-30
    version 2022-05-13

*/
*/


/* ---------- vars ---------- */ 

:root {
:root {

    /* Axels Overrides */
    /* background colors */
    --color-text: #222;
    --bg:none;
    --link-color: #822;
    --bg-body: #fff;
    --brand-color: var(--color-secondary);
    --bg-navlinkactive:#f4f4f4;
    --brand-background: var(--body-background);
    --bg-navlinkactive: linear-gradient(-90deg,rgba(0,0,0,0), rgba(40,60,80,0.05) 30%);
    --hr-color: none;
    --bg-pre:#f8f8f8;
    --search-field-background: none;
    --bg-toc: #fff;
    --search-field-border-color: none;

    --sidebar-background: var(--body-background);
    /* foreground colors */
    --sidebar-border-color: none;
    --color: #234;
    --sidebar-link-active-background: #e8f4f6;
    --navlinkactive:#f33;
    --sidebar-link-active-background: #eee;
    --title: #aaa;
    /* Axels custom values */

    --axel_bg-toc: var(--body-background);
    --link:#12a;
    --axel_bg-toc-head: #f8f8f8;
    --toclink:rgba(40,60,80,0.8);
    --axel_brand-background: none;

    --axel_brand-pre-background: rgb(255, 0, 51);
    --h1: rgba(40,60,80,0.8);
    ;
    --h1-bottom: 1px solid rgba(40,60,80,0.1);
    --axel_brand-pre-background-hover: rgb(255, 0, 51);
    --h2: #468;
    ;
    --h3: #579;
    --axel_h1_header: none;

    --axel_h1: #345;
    --axel_h1-bg: none;
    --axel_h1-bottom: 3px solid none;
    --axel_h2: #156;
    --axel_h2-bg: #f8fafb;
    --axel_h2-bottom: 2px solid #467;
    --axel_h2-hero-bottom: 2px solid #912;
    --axel_h3: #278;
    --axel_h3-bottom: 1px solid #ddd;
    --axel_hero_bg: #f8f8f8;
    --axel_nav-bg: #fcfcfc;
    --axel_nav-buttomborder: #ddd;
    --axel_pre-background: #f8f8f8;
    --axel-th-background: #d0e0e8;
    --axel-article-nav-border-top: 0px dotted #ddd;
}
}


/* ---------- tags ---------- */
.dark {
    /* Axels Overrides */
    --color-text: #c0c0c0;
    --link-color: #b44;
    --brand-color: var(--color-text);
    --brand-background: var(--body-background);
    --hr-color: none;
    --code-tag-background-color_: #bcc;
    --search-field-background: none;
    --search-field-border-color: none;
    --sidebar-background: var(--body-background);
    --sidebar-border-color: none;
    --sidebar-link-active-background: #333;
    /* Axels custom values */
    --axel_bg-toc: var(--body-background);
    --axel_bg-toc-head: #333;
    --axel_brand-background: none;
    --axel_brand-pre-background: rgb(255, 0, 51);
    ;
    --axel_brand-pre-background-hover: rgb(255, 0, 51);
    ;
    --axel_h1_header: none;
    --axel_h1: #777;
    --axel_h1-bg: none;
    --axel_h1-bottom: none;
    --axel_h2: #467;
    --axel_h2-bg: #202020;
    --axel_h2-bottom: 2px solid #256;
    --axel_h2-hero-bottom: 2px solid #712;
    --axel_h3: #589;
    --axel_h3-bottom: 1px solid #333;
    --axel_hero_bg: #242424;
    --axel_nav-bg: #242424;
    --axel_nav-buttomborder: #555;
    --axel_pre-background: #bcc;
    --axel-th-background: #203038;
    --axel-article-nav-border-top: 0px dotted #234;
}


/* ---------- left side ---------- */
a.Brand::before {
a.Brand::before {
	background: rgb(255,0,51);
    background: var(--axel_brand-pre-background);
    color: #fff;
    color: #fff;
    font-family: arial;
    font-family: arial;
    font-weight: bold;
    font-weight: bold;
    padding: 0.5em 0.3em;
    padding: 0.5em 0.3em;
    content: 'IML';
    content: 'IML';
    margin-right: 0.4em;
    margin-right: 0.4em;
    float: left;
}
}


body, *{color: var(--color);}
a.Brand:hover::before {
body{background: var(--bg-body);}
    background: var(--axel_brand-pre-background-hover);


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 ---------- */
a.Brand {

    background: var(--axel_brand-background);
.required{color:#a42;}
    font-size: 200%;
.optional{color:#888;}
    height: 4em;
}


/* ---------- page header: breadcrumb ---------- */
.Page__header {
    border: none;
}


/* ----- top left */
.Page__header a {
.Brand,
    color: var(--axel_h1_header);
.Columns__left {
	background: var(--bg);
	border-right: 0px solid #e7e7e9;
    color: var(--color);
}
}
.Brand{font-size: 200%;

    background_: linear-gradient(-10deg,#fff 50%, #ddd);
.Page__header h1 {
    background: var(--bg);
    font-size: 1.3em;
}
}
.Columns__right__content {

	background: var(--bg);
/* ---------- page content ---------- */
.s-content {
    padding-top: 1em;
}
}


/* ----- Navi left */
.s-content h1 {
    background: var(--axel_h1-bg);
    color: var(--axel_h1);
    font-size: 200%;
    font-weight: bold;
    margin-bottom: 2em;
    margin-top: 2em;
    border-bottom: var(--axel_h1-bottom);
}


.Nav a:hover{
.s-content h2 {
    background: none;
    background: var(--axel_h2-bg);
    color: var(--navlinkactive) !important;
    color: var(--axel_h2);
    font-size: 180%;
    font-weight: bold;
    margin-top: 4em;
    border-bottom: var(--axel_h2-bottom);
}
}


.Nav__item--active {
h1:first-of-type {
    border-right_: 0.3em solid var(--navlinkactive);
    margin-top: 0em;
}
}
.Nav__item--active > a{

	background: var(--bg-navlinkactive);
h2:first-of-type {
    color: var(--navlinkactive);
    margin-top: 0em;
}
}
.Nav .Nav .Nav__item--active a {

    color: var(--navlinkactive);
.s-content h3 {
    background: var(--axel_h3-bg);
    color: var(--axel_h3);
    font-size: 150%;
    font-weight: bold;
    margin-top: 3em;
    border-bottom: var(--axel_h3-bottom);
}
}
.Nav .Nav .Nav__item a {

	opacity: 1;
.s-content h4 {
    margin: 0;
    font-size: 100%;
    text-align: center;
    background-color: rgba(0, 0, 0, 0.05);
    padding: 0.3em;
}
}
.Nav__item--open > a {

	background-color: var(--bg);
.s-content pre {
    background: var(--axel_pre-background);
}
}


.Nav a[href*="__Welcome"]{
/* FIX smaller fnt size in tables */
    background: url("/icons/house.png") no-repeat 10px 4px ;
.s-content table {
    padding-left: 40px;
    font-size: 1em;
}
}
.Nav a[href*="__How_does_it_work"]{

    background: url("/icons/light-bulb.png") no-repeat 10px 4px ;
.s-content table th {
    padding-left: 40px;
    background: var(--axel-th-background);
}
}


.s-content h3 code {
    border: none;
    background: none;
}


article nav {
    border-top: var(--axel-article-nav-border-top);
    margin: 8em 0 5em;
}


.Pager li>a {
    padding: 1em 2em;
}


/* ---------- classes ---------- */
/* ---------- classes ---------- */
.required {
    color: #a42;
}


/* FIX smaller fnt size in tables */
.optional {
.s-content table {
    color: #888;
	font-size: 1em;
}
}


div.hero {
    background: var(--axel_hero_bg);
    border-radius: 2em;
    padding: 5em 2em;
    text-align: center;
    margin-bottom: 1.5em;
}

div.hero h2 {
    color: var(--color-text);
    background: none;
    border-bottom: var(--axel_h2-hero-bottom);
    font-size: 300%;
    margin: 0 0 2em;
}


/* TOC */
/* ---------- TOC ---------- */
@media(min-width:1700px) {
@media(min-width:1700px) {
    .TableOfContentsContainer {
    .TableOfContentsContainer {
        position: fixed;
        position: fixed;
@@ -140,37 +226,42 @@ h1:nth-child(1)>a{ color:var(--navlinkactive); }
}
}


.TableOfContentsContainer {
.TableOfContentsContainer {
    background-color: var(--axel_bg-toc);
    padding: 0.5em;
}

.s-content .TableOfContentsContainer h4 {
    background-color: var(--axel_bg-toc-head);
    border-top-left-radius: 1em;
    border-top-left-radius: 1em;
    background-color: var(--bg-toc);
    font-size: 1.1em;
	border-left: 2px solid rgba(0,0,0,0.05);
    margin: 0;
    padding: 0em;
    padding: 0;
}
}
.TableOfContentsContainer__content {


	border: none;
.TableOfContentsContainer__content {
    border-width: 1px;
    font-size: 0.5em;
    font-size: 0.5em;

}
}

ul.TableOfContents ul {
ul.TableOfContents ul {
    list-style-type: none;
    list-style-type: none;
    padding-left: 1em;
    padding-left: 1em;
}
}
.TableOfContentsContainer a{ color:var(--toclink);}


.TableOfContentsContainer__content > .TableOfContents > li + li {
/* ----- Icons on links --- */
	border-top: none;

}
.EditOn a::before{
.TableOfContentsContainer__content > .TableOfContents > li {
    content: '✏️ ';
	border-bottom: 1px dashed #ddd;
}
}


/* pager - prev .. next */
.Links a[href^="https://github.com/"]::before {
.s-content{
    content: '🌐 ';
    margin-bottom: 6em;
}
}
.Pager{

    border-top: 1px dashed #aaa; margin: 0; padding: 1em;
.Links a[href^="https://git-repo.iml.unibe.ch/"]::before {
    content: '🌐 ';
}
}
.Pager a{

    color:var(--navlinkactive);
.Links a[href^="https://os-docs.iml.unibe.ch"]::before {
    content: '📗 ';
}
}
 No newline at end of file
Original line number Original line Diff line number Diff line
@@ -98,7 +98,7 @@ return [
            'presets'=>[<%= @replace["messenger-slack-presets"] %>],
            'presets'=>[<%= @replace["messenger-slack-presets"] %>],
        ],
        ],
        'email'=>[
        'email'=>[
            'from'=>[<%= @replace["messenger-email-from"] %>],
            'from'=><%= @replace["messenger-email-from"] %>,
        ],
        ],
    ],
    ],


Original line number Original line Diff line number Diff line
@@ -112,7 +112,7 @@ foreach(array('server/config', 'server/tmp') as $sMyDir){
// ----------------------------------------------------------------------
// ----------------------------------------------------------------------
require_once($sApproot.'/server/classes/appmonitor-server.class.php');
require_once($sApproot.'/server/classes/appmonitor-server.class.php');
$oServer=new appmonitorserver();
$oServer=new appmonitorserver();
$iCount=count($oServer->apiGetAppIds());
$iCount=count($oServer->getAppIds());
$oMonitor->addCheck(
$oMonitor->addCheck(
    array(
    array(
        "name" => "appcounter",
        "name" => "appcounter",
Original line number Original line Diff line number Diff line
<?php
/**
 * ____________________________________________________________________________
 * 
 *  _____ _____ __                   _____         _ _           
 * |     |     |  |      ___ ___ ___|     |___ ___|_| |_ ___ ___ 
 * |-   -| | | |  |__   | .'| . | . | | | | . |   | |  _| . |  _|
 * |_____|_|_|_|_____|  |__,|  _|  _|_|_|_|___|_|_|_|_| |___|_|  
 *                          |_| |_|                              
 *                           _ _         _                                            
 *                       ___| |_|___ ___| |_                                          
 *                      |  _| | | -_|   |  _|                                         
 *                      |___|_|_|___|_|_|_|   
 *                                                               
 * ____________________________________________________________________________
 * 
 * CUSTOM CHECK BASED ON SHELL COMMANDS
 * 
 * Execute a shell command.
 * ____________________________________________________________________________
 * 
 * 2022-09-19  <axel.hahn@iml.unibe.ch>
 * 
 */
class checkExec extends appmonitorcheck{
    /**
     * get default group of this check
     * @param array   $aParams - see run() method
     * @return array
     */
    public function getGroup($aParams){
        return 'service';
    }

    /**
     * check execution of a command
     * @param array $aParams
     * array(
     *     "command"        {string} command to execute
     *     "output"         {bool}   flag: show output; default: true
     *
     *     "exitOK"         {array}  array of integegers for ok exitcodes
     *     "exitWarn"       {array}  array of integegers for exitcodes with warning
     *     "exitCritical"   {array}  array of integegers for exitcodes that result in an error
     *
     *     // TODO ... MAYBE
     *     "searchOK"       {string} search string that must be found in output
     *     "searchWarn"     {string} if search string is found check returns with warning
     *     "searchCritical" {string} if search string is found check returns with critical
     * )
     * @return boolean
     */
    public function run($aParams) {
        $this->_checkArrayKeys($aParams, "command");
        $_sCmd=$aParams['command'];
        $_bShowOutput=isset($aParams['output'])        ? !!$aParams['output']       : true;

        $_aRcOK=isset($aParams['exitOK'])              ? $aParams['exitOK']       : [];
        $_aRcWarning=isset($aParams['exitWarn'])       ? $aParams['exitWarn']     : [];
        $_aRcCritical=isset($aParams['exitCritical'])  ? $aParams['exitCritical'] : [];

        $_sMode='default';
        if(count($_aRcOK) + count($_aRcWarning) + count($_aRcCritical)){
            $_sMode='exitcode';
        }

        exec($_sCmd,$aOutput, $iRc);
        $_sOut=$_bShowOutput ? '<br>'.implode("<br>", $aOutput) : '';

        switch($_sMode){
            // non-zero exitcode is an error
            case "default":
                if ($iRc) {
                    return [
                        RESULT_ERROR, 
                        'command failed with exitcode '.$iRc.': [' . $_sCmd . ']'.$_sOut
                    ];
                } else {
                    return[
                        RESULT_OK, 
                        'OK [' . $_sCmd . '] ' .$_sOut
                    ];
                };
                break;;

            // handle given custom exitcodes
            case "exitcode":
                if (in_array($iRc, $_aRcCritical)){
                    return [
                        RESULT_ERROR, 
                        'Critical exitcode '.$iRc.' detected: [' . $_sCmd . ']'.$_sOut
                    ];
                }
                if (in_array($iRc, $_aRcWarning)){
                    return [
                        RESULT_WARNING, 
                        'Warning exitcode '.$iRc.' detected: [' . $_sCmd . ']'.$_sOut
                    ];
                }
                if ($iRc == 0 || in_array($iRc, $_aRcOK)){
                    return [
                        RESULT_OK, 
                        'OK exitcode '.$iRc.' detected: [' . $_sCmd . ']'.$_sOut
                    ];
                }
                return [
                    RESULT_UNKNOWN, 
                    'UNKNOWN - unhandled exitcode '.$iRc.' detected: [' . $_sCmd . ']'.$_sOut
                ];
            case "search":
                return[
                    RESULT_UNKNOWN, 
                    'UNKNOWN method [' . $_sMode . '] - is not implemented yet.'
                ];
                break;;
            default:
                return[
                    RESULT_UNKNOWN, 
                    'UNKNOWN mode [' . htmlentities($_sMode) . '].'
                ];
        } // switch($_sMode)
    }

}
Original line number Original line Diff line number Diff line
<?php
/**
 * ____________________________________________________________________________
 * 
 *  _____ _____ __                   _____         _ _           
 * |     |     |  |      ___ ___ ___|     |___ ___|_| |_ ___ ___ 
 * |-   -| | | |  |__   | .'| . | . | | | | . |   | |  _| . |  _|
 * |_____|_|_|_|_____|  |__,|  _|  _|_|_|_|___|_|_|_|_| |___|_|  
 *                          |_| |_|                              
 *                           _ _         _                                            
 *                       ___| |_|___ ___| |_                                          
 *                      |  _| | | -_|   |  _|                                         
 *                      |___|_|_|___|_|_|_|   
 *                                                               
 * ____________________________________________________________________________
 * 
 * CHECK PING RESPONSE TIME VIA ICMP
 * ____________________________________________________________________________
 * 
 * 2022-07-05  <axel.hahn@iml.unibe.ch>
 * 2022-09-16  <axel.hahn@iml.unibe.ch>  read error before closing socket.
 * 2022-11-22  <axel.hahn@iml.unibe.ch>  Use exec with detecting MS Win for the ping parameter for count of pings
 */
class checkPing extends appmonitorcheck{
    /**
     * get default group of this check
     * @param array   $aParams
     * @return array
     */
    public function getGroup(){
        return 'network';
    }

    /**
     * check ping to a target
     * @param array $aParams
     * array(
     *     host                string   optional hostname to connect; default: 127.0.0.1
     *     timeout             integer  OBSOLET (because using exec): optional timeout in sec; default: 5
     * )
     * @return boolean
     */
    public function run($aParams) {
        $sHost = array_key_exists('host', $aParams) ? $aParams['host'] : '127.0.0.1';

        $sParamCount=strtoupper(substr(PHP_OS, 0, 3)) === 'WIN' ? "n" : "c";
        $iRepeat=1;
        
        $sCommand="ping -$sParamCount $iRepeat $sHost 2>&1";
        exec($sCommand, $aOut, $iRc);
        $sOut=implode("\n", $aOut);

        if ($iRc>0){
            return [RESULT_ERROR, "ERROR: ping to $sHost failed.\n".$sOut];
        }
        return [RESULT_OK, "OK: ping to $sHost\n".$sOut];

        /*
            Socket functions require root :-/

        if (!function_exists('socket_create')){
            return [RESULT_UNKNOWN, "UNKNOWN: Unable to perform ping test. The socket module is not enabled in the php installation."];
        }

        // ICMP ping packet with a pre-calculated checksum
        $package = "\x08\x00\x7d\x4b\x00\x00\x00\x00PingHost";
        $socket  = socket_create(AF_INET, SOCK_RAW, getprotobyname('icmp'));
        // TODO
        if(!$socket){
                die("ERROR: unable to create socket");
        }
        socket_set_option(
            $socket, 
            SOL_SOCKET, 
            SO_RCVTIMEO, 
            array(
                "sec"=>(isset($aParams["timeout"]) && (int)$aParams["timeout"]) ? (int)$aParams["timeout"] : $this->_iTimeoutTcp, // timeout in seconds
                "usec"=>0
              )
        );

        $start = microtime(true);
        socket_connect($socket, $sHost, 0);
        $connect = socket_send($socket, $package, strLen($package), 0);
        if($connect){
            if (socket_read($socket, 255)){
                $result = microtime(true) - $start;
                socket_close($socket);
                return [RESULT_OK, 
                    "OK: ping to $sHost",
                    array(
                        'type'=>'counter',
                        'count'=>$result,
                        'visual'=>'line',
                    )

                ];
            } else {
                $aResult=[RESULT_ERROR, "ERROR: ping to $sHost failed after connect." . socket_strerror(socket_last_error($socket))];
                socket_close($socket);
                return $aResult;
            }
        } else {
            return [RESULT_ERROR, "ERROR: ping to $sHost failed. " . socket_strerror(socket_last_error($socket))];
        }

        */
    }

}
Original line number Original line Diff line number Diff line
@@ -14,10 +14,13 @@
 *                                                               
 *                                                               
 * ____________________________________________________________________________
 * ____________________________________________________________________________
 * 
 * 
 * CHECK SWLITE CONNECTION USING PDO
 * CHECK TCP CONNECTION TO A GIVEN PORT
 * ____________________________________________________________________________
 * ____________________________________________________________________________
 * 
 * 
 * 2021-10-27  <axel.hahn@iml.unibe.ch>
 * 2021-10-27  <axel.hahn@iml.unibe.ch>
 * 2022-07-05  <axel.hahn@iml.unibe.ch>  send unknown if socket module is not activated.
 * 2022-09-16  <axel.hahn@iml.unibe.ch>  read error before closing socket.
 * 2022-12-05  <axel.hahn@unibe.ch>      add @ sign at socket functions to prevent warning
 * 
 * 
 */
 */
class checkPortTcp extends appmonitorcheck{
class checkPortTcp extends appmonitorcheck{
@@ -46,9 +49,13 @@ class checkPortTcp extends appmonitorcheck{
        $sHost = array_key_exists('host', $aParams) ? $aParams['host'] : '127.0.0.1';
        $sHost = array_key_exists('host', $aParams) ? $aParams['host'] : '127.0.0.1';
        $iPort = (int) $aParams['port'];
        $iPort = (int) $aParams['port'];


        if (!function_exists('socket_create')){
            return [RESULT_UNKNOWN, "UNKNOWN: Unable to perform tcp test. The socket module is not enabled in the php installation."];
        }

        // from http://php.net/manual/de/sockets.examples.php
        // from http://php.net/manual/de/sockets.examples.php


        $socket = socket_create(AF_INET, SOCK_STREAM, SOL_TCP);
        $socket = @socket_create(AF_INET, SOCK_STREAM, SOL_TCP);
        if ($socket === false) {
        if ($socket === false) {
            return [RESULT_UNKNOWN, "ERROR: $sHost:$iPort was not checked. socket_create() failed: " . socket_strerror(socket_last_error())];
            return [RESULT_UNKNOWN, "ERROR: $sHost:$iPort was not checked. socket_create() failed: " . socket_strerror(socket_last_error())];
        }
        }
@@ -63,10 +70,11 @@ class checkPortTcp extends appmonitorcheck{
              )
              )
            );
            );


        $result = socket_connect($socket, $sHost, $iPort);
        $result = @socket_connect($socket, $sHost, $iPort);
        if ($result === false) {
        if ($result === false) {
            $aResult=[RESULT_ERROR, "ERROR: $sHost:$iPort failed. " . socket_strerror(socket_last_error($socket))];
            socket_close($socket);
            socket_close($socket);
            return [RESULT_ERROR, "ERROR: $sHost:$iPort failed. " . socket_strerror(socket_last_error($socket))];
            return $aResult;
        } else {
        } else {
            socket_close($socket);
            socket_close($socket);
            return [RESULT_OK, "OK: $sHost:$iPort was connected."];
            return [RESULT_OK, "OK: $sHost:$iPort was connected."];
Original line number Original line Diff line number Diff line
@@ -12,6 +12,9 @@ class build_base implements iBuildplugin{
    protected $_sBuildDir = false;
    protected $_sBuildDir = false;
    protected $_sOutfile = false;
    protected $_sOutfile = false;
    
    
    protected $_sPluginId = false;
    protected $_aPlugininfos = false;

    protected $_sLang = "en-en";
    protected $_sLang = "en-en";
    protected $_aLang = [];
    protected $_aLang = [];


Original line number Original line Diff line number Diff line
<?php
<?php


/**
/**
 * ----------------------------------------------------------------------
 * 
 * Debug logging during a client request.
 * Debug logging during a client request.
 * So you can measure any action find bottlenecks in your code.
 * 
 * Licence: GNU GPL 3.0
 * Source:  https://github.com/axelhahn/ahlogger
 * Docs:    https://www.axel-hahn.de/docs/ahlogger/
 * 
 * USAGE:<br>
 * (1) Trigger a message with add() to add a marker<br>
 * (2) The render() method lists all items in a table with time since start
 *     and the delta to the last message. <br>
 * 
 * @author www.axel-hahn.de
 * 
 * 
 * @author hahn
 * ----------------------------------------------------------------------
 * 2016-02-26  init
 * 2016-11-19  add memory usage
 * (...)
 * 2022-09-25  add memory tracking, add cli renderer 
 * 2022-09-27  css updates
 * 2022-10-02  add emoji chars 
 * 2022-10-16  mark longest action with an icon 
 * 2022-12-15  make it compatible to PHP 8.2; add doc + comments
 * ----------------------------------------------------------------------
 */
 */
class logger {
class logger {
    protected $aMessages=array();

    protected $bShowDebug=true;
    /**
     * @var {array} array of added messages
     */
    protected $aMessages = [];
    
    /**
     * @var {bool} flag: show debug infos? default: false
     */
    protected $bShowDebug = false;

    /**
     * @var {int} memory usage on start
     */
    protected $_iMemStart = false;
    protected $_iMemStart = false;


    /**
     * @var {string} dynamic prefix for used css - it is set in the cronstructor
     */
    protected $sCssPrefix = '';

    // ----------------------------------------------------------------------
    // CONSTRUCTOR
    // ----------------------------------------------------------------------


    /**
    /**
     * constuctor
     * constuctor
@@ -18,33 +61,15 @@ class logger {
     */
     */
    public function __construct($sInitMessage = "Logger was initialized.") {
    public function __construct($sInitMessage = "Logger was initialized.") {
        $this->_iMemStart=memory_get_usage();
        $this->_iMemStart=memory_get_usage();
        $this->enableDebug(true);
        $this->add($sInitMessage);
        $this->add($sInitMessage);
        $this->sCssPrefix='debug-'.md5(microtime(true));
        return true;
        return true;
    }
    }


    /**
    // ----------------------------------------------------------------------
     * enable / disable debugging
    // PUBLIC METHODS
     * @param type $bEnable
    // ----------------------------------------------------------------------
     * @return type
     */
    public function enableDebug($bEnable=false){
        return $this->bShowDebug=$bEnable;
    }

    /**
     * enable client debugging by a given array of allowed ip addresses
     * @param array $aIpArray
     * @return boolean
     */
    public function enableDebugByIp($aIpArray){
        $this->enableDebug(false);
        if (!$_SERVER || !is_array($_SERVER) || !array_key_exists("REMOTE_ADDR", $_SERVER)){
            return false;
        }
        if (array_search($_SERVER['REMOTE_ADDR'], $aIpArray)!==false){
            $this->enableDebug(true);
        }
    }


    /**
    /**
     * add a logging message
     * add a logging message
@@ -56,94 +81,238 @@ class logger {
        if (!$this->bShowDebug){
        if (!$this->bShowDebug){
            return false;
            return false;
        }        
        }        
        global $aCfg;
        $this->aMessages[] = array(
        $this->aMessages[] = array(
            'time' => microtime(true),
            'time' => microtime(true),
            'message' => $sMessage,
            'message' => $sMessage,
            'level'=>$sLevel
            'level' => preg_replace('/[^a-z0-9\-\_]/', '', $sLevel),
            'memory' => memory_get_usage()
        );
        );
        if ($sLevel=="MAIL"){
            mail($aCfg["emailDeveloper"], "studmed - booking tool - Logmessage", $sMessage);
        }


        return true;
        return true;
    }
    }


    /**
    /**
     * render output of all logging messages
     * enable / disable debugging
     * @param type $bEnable
     * @return type
     */
     */
    public function render(){
    public function enableDebug($bEnable=true){
        if (!$this->bShowDebug){
        return $this->bShowDebug=!!$bEnable;
    }

    /**
     * enable client debugging by a given array of allowed ip addresses
     * @param array $aIpArray list of ip addresses in a flat array
     * @return boolean
     */
    public function enableDebugByIp($aIpArray){
        $this->enableDebug(false);
        if (!$_SERVER || !is_array($_SERVER) || !array_key_exists("REMOTE_ADDR", $_SERVER)){
            return false;
            return false;
        }
        }
        $sOut='';
        if (array_search($_SERVER['REMOTE_ADDR'], $aIpArray)!==false){
            $this->enableDebug(true);
        }
    }

    /**
     * helper function: prepare array of added massages before output
     * - detect warnings and errors
     * - detect needed time for each action
     * - detect longest action
     * - detect maximum of memory usage
     * - calculate total time
     * 
     * @return array
     */
    protected function _prepareRendering(){
        $iMem=memory_get_usage();
        $iMem=memory_get_usage();
        $this->add('<hr>');
        $this->add('<hr>');
        $this->add('Memory on start: ' . number_format($this->_iMemStart, 0, '.', ',') . " bytes");
        $this->add('Memory on start: ' . number_format($this->_iMemStart, 0, '.', ',') . " bytes");
        $this->add('Memory on end: '   . number_format($iMem, 0, '.', ',') . " bytes");
        $this->add('Memory on end: '   . number_format($iMem, 0, '.', ',') . " bytes");
        $this->add('Memory peak: '  . number_format(memory_get_peak_usage(), 0, '.', ',') . " bytes");
        $this->add('Memory peak: '  . number_format(memory_get_peak_usage(), 0, '.', ',') . " bytes");


        $aReturn=[
            'totaltime' => false,
            'level' => false,
            'warnings' => '',
            'errors' => '',
            'maxrowid' => false,
            'maxtime' => false,
            'result' => []
        ];
        $sStarttime = $this->aMessages[0]["time"];
        $sStarttime = $this->aMessages[0]["time"];
        
        $iLasttime = $sStarttime;
        $iCounter = 0;
        $iCounter = 0;
        $sMaxRowId = false;
        $sMaxRowId = false;
        $iMaxtime = -1;
        $iMaxtime = -1;
        $sWarnings=false;
        $iMaxmem = -1;
        
        $bHasWarning = false;
        $iLasttime=$sStarttime;
        $bHasError = false;


        foreach ($this->aMessages as $aLogentry) {
        foreach ($this->aMessages as $aLogentry) {
            $iCounter++;
            $iCounter++;
            $sTrId='debugTableRow'.$iCounter;

            if($aLogentry["level"]=="warning"){
                $bHasWarning=true;
            }
            if($aLogentry["level"]=="error"){
                $bHasError=true;
            }

            $sTrId = $this->sCssPrefix.'debugTableRow' . $iCounter;
            $iDelta = $aLogentry["time"] - $iLasttime;
            $iDelta = $aLogentry["time"] - $iLasttime;
            if ($iDelta > $iMaxtime) {
            if ($iDelta > $iMaxtime) {
                $iMaxtime = $iDelta;
                $iMaxtime = $iDelta;
                $sMaxRowId = $sTrId;
                $sMaxRowId = $sTrId;
            }
            }
            $iMaxmem=max($aLogentry["memory"], $iMaxmem);




            $sStyle=($iDelta > 1)?'color: #f82;':'';
            if (($iDelta > 1) || $aLogentry["level"] == "warning") {
            if (($iDelta > 1)){
                $aReturn['warnings'].='<a href="#' . $sTrId . '" title="' . sprintf("%01.4f", $iDelta) . ' s">' . $iCounter . '</a>&nbsp;';
                $sWarnings.='<a href="#'.$sTrId.'" title="'.sprintf("%01.4f", $iDelta).' s">'.$iCounter.'</a>&nbsp;';
            }
            }
            $sOut.='<tr class="'.$aLogentry["level"].'" id="'.$sTrId.'" style="'.$sStyle.'">'.
            if ($aLogentry["level"] == "error") {
                   '<td>'.$iCounter.'</td>'.
                $aReturn['errors'].='<a href="#' . $sTrId . '" title="' . sprintf("%01.4f", $iDelta) . ' s">' . $iCounter . '</a>&nbsp;';
                   '<td>'.sprintf("%01.3f", $aLogentry["time"]-$sStarttime).'</td>'.
            }
                   '<td>'.sprintf("%01.3f", $iDelta).'</td>'.
            $aReturn['entries'][]=[
                   '<td>'.$aLogentry["level"].'</td>'.
                'time'=>$aLogentry["time"],
                   '<td>'.$aLogentry["message"].'</td>'.
                'level'=>$aLogentry["level"],
                   '</tr>';
                'message'=>$aLogentry["message"],
                'memory'=>sprintf("%01.2f", $aLogentry["memory"]/1024/1024), // MB

                'trid'=>$sTrId,
                'trclass'=>$aLogentry["level"],
                'counter'=>$iCounter,
                'timer'=>sprintf("%01.3f", $aLogentry["time"] - $sStarttime),
                'delta'=>sprintf("%01.0f", $iDelta*1000),
            ];
            $iLasttime = $aLogentry["time"];
            $iLasttime = $aLogentry["time"];
        }
        $aReturn['level']=($bHasWarning
            ? ($bHasError ? 'error' : 'warning')
            : ''
        );
        $aReturn['maxrowid']=$sMaxRowId;
        $aReturn['maxtime']=sprintf("%01.3f", $iMaxtime);
        $aReturn['maxmem']=sprintf("%01.2f", $iMaxmem/1024/1024);
        $aReturn['totaltime']=sprintf("%01.3f", $aLogentry['time']-$aReturn['entries'][0]['time']);
        return $aReturn;
    }

    /**
     * get html code for a progressbar with divs
     * @param  {int|float}  $iVal  value between 0..max value
     * @param  {int|float}  $iMax  max value
     * @return {string}
     */
    protected function _getBar($iVal, $iMax){
        $iWidth=$iVal/$iMax*100;
        return '<div class="bar"><div class="progress" style="width: '.$iWidth.'%;">&nbsp;</div></div>';
    }


    /**
     * render output of all logging messages
     */
    public function render() {
        if (!$this->bShowDebug){
            return false;
        }
        }
        $iTotal=$iLasttime-$sStarttime;
        $aData=$this->_prepareRendering();
        if ($sWarnings){

            $sWarnings='<br>warnings:&nbsp;'.$sWarnings;
        /*
        Array
        (
            [totaltime] => 0.006
            [errors] =>  
            [warnings] => 3 
            [maxrowid] => debugTableRow3
            [maxtime] => 0.005
            [result] => Array
                (
                )

            [entries] => Array
                mit Elementen
                Array
                    (
                        [time] => 1663959608.2566
                        [level] => info
                        [message] => Logger was initialized.
                        [memory] => 538056
                        [trid] => debugTableRow1
                        [trclass] => info
                        [trstyle] => 
                        [counter] => 1
                        [timer] => 0.000
                        [delta] => 0.000
                    )
        */

        $sOut='';
        // echo '<pre>'; print_r($aData); die();
        foreach ($aData['entries'] as $aLogentry){
            $sOut.='<tr class="'.$this->sCssPrefix.'-level-' . $aLogentry["level"] . ''.($aLogentry["trid"]==$aData["maxrowid"] ? ' '.$this->sCssPrefix.'-maxrow' : '').'" '
                .'id="' . $aLogentry["trid"] . '">' .
                    '<td>' . $aLogentry["counter"] . '</td>' .
                    '<td>' . $aLogentry["level"] . '</td>' .
                    '<td>' . $aLogentry["timer"] . '</td>' .
                    '<td>' . $this->_getBar($aLogentry["delta"], $aData["maxtime"]*1000). $aLogentry["delta"] .' ms'.($aLogentry["delta"]==$aData['maxtime']*1000 ? ' ⏱️' : '').'</td>' .
                    '<td>' . $this->_getBar($aLogentry["memory"], $aData["maxmem"]) . $aLogentry["memory"] .' MB'. '</td>' .
                    '<td>' . $aLogentry["message"] . '</td>' .
                    '</tr>';
        }
        }
        if ($sOut){
            $sOut = '
            <style>
                .'.$this->sCssPrefix.'-info          {position: fixed; top: 6em; right: 1em; background: rgba(200,228,255, 0.8); border: 1px solid; z-index: 99999;}
                .'.$this->sCssPrefix.'-info .head    {background: rgba(0,0,0,0.4); color: #fff;padding: 0em 0.5em 0.2em; }
                .'.$this->sCssPrefix.'-info .content {padding: 0.5em; }
                .'.$this->sCssPrefix.'-info .content .total {font-size: 160%; color: rgba(0,0,0,0.5); margin: 0.3em 0; display: inline-block;}

                .'.$this->sCssPrefix.'-messages {margin: 5em 2em 2em;}
                .'.$this->sCssPrefix.'-messages .bar      {background: rgba(0,0,0,0.03); height: 1.4em; position: absolute; width: 6em; border-right: 1px solid rgba(0,0,0,0.2);}
                .'.$this->sCssPrefix.'-messages .progress {background: rgba(100,140,180,0.2); height: 1.4em; padding: 0;}
                .'.$this->sCssPrefix.'-messages table{background: #fff; color: #222;table-layout:fixed; }
                .'.$this->sCssPrefix.'-messages table th{background: none;}
                .'.$this->sCssPrefix.'-messages table th.barcol{min-width: 7em; position: relative;}
                .'.$this->sCssPrefix.'-messages table td{padding: 3px; vertical-align: top;}
                .'.$this->sCssPrefix.'-messages table th:hover{background:#aaa !important;}


        if ($sOut) $sOut='
                .'.$this->sCssPrefix.'-level-info{background: #e0e8f8; color:#124}
            <div style="position: fixed; right: 1em; top: 6em; background: rgba(255,80,80, 0.1); padding: 0.5em;">
                .'.$this->sCssPrefix.'-level-warning{background: #fcf8e3; color: #980;}
                <span style="font-size: 130%;">total:&nbsp;'.sprintf("%01.3f", $iTotal).'&nbsp;s</span><br>
                .'.$this->sCssPrefix.'-level-error{background: #fce0e0; color: #944;}
                <span>longest&nbsp;action:&nbsp;<a href="#'.$sMaxRowId.'">'.sprintf("%01.3f", $iMaxtime).'&nbsp;s</a></span>
                .'.$this->sCssPrefix.'-maxrow{color:#f33; font-weight: bold;}
                <span>'.$sWarnings.'</span>
            </style>
            <div class="'.$this->sCssPrefix.' '.$this->sCssPrefix.'-info '.$this->sCssPrefix.'-level-'.$aData['level'].'">
                <div class="head">ahLogger</div>
                <div class="content">
                    <span class="total">⏱️ ' . $aData['totaltime'] . '&nbsp;s</span><br>
                    🪲 <a href="#'.$this->sCssPrefix.'-messages">Debug infos</a> | 🔺 <a href="#">top</a><br>
                    <span>longest&nbsp;action: ⏱️&nbsp;<a href="#' . $aData['maxrowid'] . '">' . ($aData['maxtime']*1000) . '&nbsp;ms</a></span>
                    ' . ($aData['errors'] ? '<br><span>‼️ Errors: '.$aData['errors'] . '</span>' : '').'
                    ' . ($aData['warnings'] ? '<br><span>⚠️ Warnings: '.$aData['warnings'] . '</span>' : '').'
                </div>
                </div>
            <br>
            </div>
            <br>

            <br>
            <div id="'.$this->sCssPrefix.'-messages" class="'.$this->sCssPrefix.' '.$this->sCssPrefix.'-messages">
            <br>
            DEBUG :: LOG MESSAGES<br>'
            <br>
            . ($aData['errors']   ? '<span>Errors: '.$aData['errors'] . '</span><br>' : '')
            <h3>DEBUG</h3><br>
            . ($aData['warnings'] ? '<span>Warnings: '.$aData['warnings'] . '</span><br>' : '')
            <table class="datatable table table-striped debugtable">
            .'<br>
            <table >
            <thead>
            <thead>
            <tr>
            <tr>
                <th>#</th>
                <th>#</th>
                <th>delta to start time</th>
                <th>delta to previuos</th>
                <th>level</th>
                <th>level</th>
                <th>time [s]</th>
                <th class="barcol">delta</th>
                <th class="barcol">memory</th>
                <th>message</th>
                <th>message</th>
            </tr></thead><tbody>
            </tr></thead><tbody>
            ' . $sOut . '</tbody></table>'
            ' . $sOut . '</tbody></table>'
                . '<script>$(\'#'.$sMaxRowId.'\').css(\'color\', \'#f00\');</script>';
            ;
		}
        return $sOut;
        return $sOut;
    }
    }
   /**
   /**
@@ -154,32 +323,19 @@ class logger {
        if (!$this->bShowDebug){
        if (!$this->bShowDebug){
            return false;
            return false;
        }
        }
        $sOut='';
        $aData=$this->_prepareRendering();
        $sStarttime=$this->aMessages[0]["time"];
        
        $iCounter=0;
        $sMaxRowId=false;
        $iMaxtime=-1;
        $sWarnings=false;
        
        $iLasttime=$sStarttime;


        foreach ($this->aMessages as $aLogentry){
        $sOut='';
            $iCounter++;
        foreach ($aData['entries'] as $aLogentry){
            $iDelta=$aLogentry["time"]-$iLasttime;
            $sOut.=$aLogentry["timer"].' | '
            $sOut.=$aLogentry["level"].' '
                    .$aLogentry["delta"].' ms | '
                   . $iCounter.' '
                    .$aLogentry["level"].' | '
                   .sprintf("%01.3f", $aLogentry["time"]-$sStarttime).' '
                    .(sprintf("%01.3f", $aLogentry["memory"]/1024/1024)).' MB | '
                   .sprintf("%01.3f", $iDelta).' '
                   .$aLogentry["level"].' '
                   .$aLogentry["message"].' '
                   .$aLogentry["message"].' '
                   . "\n"
                   . "\n"
                   ;
                   ;
            $iLasttime=$aLogentry["time"];

        }
        }
        // $iTotal=$iLasttime-$sStarttime;
        $sOut.="\nTotal time: ".$aData['totaltime'] . "\n";
        return $sOut;
        return $sOut;
    }
    }
}
}
Original line number Original line Diff line number Diff line
@@ -42,14 +42,16 @@ class messenger {
    }
    }


    /**
    /**
     * send an email if _aCfg['email'] exists
     * send an email if _aCfg['email']['to'] exists
     */
     */
    private function _sendEmail(){
    private function _sendEmail(){
        if (array_key_exists('email', $this->_aCfg) && array_key_exists('to', $this->_aCfg['email'])
        if (isset($this->_aCfg['email']['to']) && $this->_aCfg['email']['to']) {
        ) {
            preg_match('/^(.*)\n/', $this->_sMessage, $aTmp);
            preg_match('/^(.*)\n/', $this->_sMessage, $aTmp);
            $sSubject = $aTmp[0];
            $sSubject = $aTmp[0];
            return mail($this->_aCfg['email']['to'], $sSubject, $this->_sMessage, "From: " . $this->_aCfg['email']['from'] . "\r\n" .
            return mail(
                $this->_aCfg['email']['to'], 
                $sSubject, $this->_sMessage, 
                "From: " . $this->_aCfg['email']['from'] . "\r\n" .
                "Reply-To: " . $this->_aCfg['email']['from'] . "\r\n"
                "Reply-To: " . $this->_aCfg['email']['from'] . "\r\n"
            );
            );
        }
        }
@@ -57,15 +59,15 @@ class messenger {
    }
    }
    
    
    /**
    /**
     * send a message to slack if _aCfg['slack'] exists
     * send a message to slack if _aCfg['slack']['incomingurl'] exists
     */
     */
    private function _sendToSlack(){
    private function _sendToSlack(){
        if (array_key_exists('slack', $this->_aCfg)) {
        if (isset($this->_aCfg['slack']['incomingurl']) && $this->_aCfg['slack']['incomingurl']) {
            require_once(__DIR__ . '/../../vendor/shooker/shooker.php');
            require_once(__DIR__ . '/../../vendor/shooker/shooker.php');
            $shkr = new Shooker();
            $shkr = new Shooker();
            $shkr->setupIncoming($this->_aCfg['slack']['incomingurl']);
            $shkr->setupIncoming($this->_aCfg['slack']['incomingurl']);
            $sUser=(array_key_exists('user', $this->_aCfg['slack'])? $this->_aCfg['slack']['user']: false);
            $sUser=(isset($this->_aCfg['slack']['user'])? $this->_aCfg['slack']['user']: false);
            $sIcon=(array_key_exists('icon', $this->_aCfg['slack'])? $this->_aCfg['slack']['icon']: false);
            $sIcon=(isset($this->_aCfg['slack']['icon'])? $this->_aCfg['slack']['icon']: false);
            return $shkr->sendMessage($this->_sMessage, $sUser, $sIcon);
            return $shkr->sendMessage($this->_sMessage, $sUser, $sIcon);
        }
        }
        return false;
        return false;
Original line number Original line Diff line number Diff line
@@ -647,7 +647,7 @@ class project extends base {
        $this->getAllPhaseInfos();
        $this->getAllPhaseInfos();
        foreach ($this->_aData["phases"] as $sPhase => $aData) {
        foreach ($this->_aData["phases"] as $sPhase => $aData) {
            foreach (array_keys($this->_aPlaces) as $sPlace) {
            foreach (array_keys($this->_aPlaces) as $sPlace) {
                if (array_key_exists($sPlace, $aData) && array_key_exists("version", $aData[$sPlace])) {
                if (isset($aData[$sPlace]["version"])) {
                    $this->_aVersions[$aData[$sPlace]["version"]][] = array('phase' => $sPhase, 'place' => $sPlace);
                    $this->_aVersions[$aData[$sPlace]["version"]][] = array('phase' => $sPhase, 'place' => $sPlace);
                }
                }
            }
            }
Original line number Original line Diff line number Diff line
@@ -176,7 +176,7 @@ class rollout_awx extends rollout_base {
        
        
        // ----- Checks:
        // ----- Checks:
        $sCmdChecks='';
        $sCmdChecks='';
        if($aConfig['extravars']){
        if(isset($aConfig['extravars']) && $aConfig['extravars']){
            $aTmp=json_decode($aConfig['extravars'], 1);
            $aTmp=json_decode($aConfig['extravars'], 1);
            if (!$aTmp || !is_array($aTmp) || !count($aTmp) ){
            if (!$aTmp || !is_array($aTmp) || !count($aTmp) ){
                $sCmdChecks.='echo "ERROR: Value in extravars has wrong Syntax - this is no JSON: '.$aConfig['extravars'].'"; exit 1; ';                
                $sCmdChecks.='echo "ERROR: Value in extravars has wrong Syntax - this is no JSON: '.$aConfig['extravars'].'"; exit 1; ';                
@@ -184,14 +184,14 @@ class rollout_awx extends rollout_base {
            $aConfig['extravars']=json_encode($aTmp);
            $aConfig['extravars']=json_encode($aTmp);
        }
        }
        
        
        if(!(int)$aConfig['inventory']){
        if(!isset($aConfig['inventory']) || !(int)$aConfig['inventory']){
            $sCmdChecks.='echo "ERROR: no inventory was given."; exit 1; ';
            $sCmdChecks.='echo "ERROR: no inventory was given."; exit 1; ';
        }
        }
        
        
        // ----- Send variables having values only
        // ----- Send variables having values only
        $aBodyvars=array();
        $aBodyvars=array();
        foreach(['inventory'=>'inventory', 'limit'=>'limit', 'job_tags'=>'tags', 'extra_vars'=>'extravars'] as $sParam=>$sVarkey){
        foreach(['inventory'=>'inventory', 'limit'=>'limit', 'job_tags'=>'tags', 'extra_vars'=>'extravars'] as $sParam=>$sVarkey){
            if ($aConfig[$sVarkey]) {
            if (isset($aConfig[$sVarkey]) && $aConfig[$sVarkey]) {
                $aBodyvars[$sParam]=$aConfig[$sVarkey];
                $aBodyvars[$sParam]=$aConfig[$sVarkey];
            }
            }
        }
        }
Original line number Original line Diff line number Diff line
@@ -120,6 +120,7 @@ if(is_array($aData) && count($aData)){
        // $sTable.='<tr>';
        // $sTable.='<tr>';
        foreach ($aRow as $sKey=>$sValue){
        foreach ($aRow as $sKey=>$sValue){
            // $sTable.='<td class="'.$sKey.'"><a href="'.$sUrl.'">'.$sValue.'</a></td>';
            // $sTable.='<td class="'.$sKey.'"><a href="'.$sUrl.'">'.$sValue.'</a></td>';
            $sOnclick='';
            $sLabel=strstr($sValue, '"')
            $sLabel=strstr($sValue, '"')
                    ? htmlentities($sValue)
                    ? htmlentities($sValue)
                    : '<a href="#" onclick="$(\'#eFilter\').val(\''.$sValue.'\');filterTable();" title="click to filter by ['.$sValue.']">'.htmlentities($sValue).'</a>'
                    : '<a href="#" onclick="$(\'#eFilter\').val(\''.$sValue.'\');filterTable();" title="click to filter by ['.$sValue.']">'.htmlentities($sValue).'</a>'
Original line number Original line Diff line number Diff line
@@ -143,7 +143,7 @@ switch ($sAction) {
            // case 'other-varname':
            // case 'other-varname':
            case 'version':
            case 'version':
                if ($oVersion->updateVar($sVarname, $sValue)) {
                if ($oVersion->updateVar($sVarname, $sValue)) {
                    echo "OK: $sVarname was updated.";
                    echo "OK: $sVarname was updated.".PHP_EOL."new value: $sValue".PHP_EOL;
                } else {
                } else {
                    echo "ERROR: update for $sVarname failed.";
                    echo "ERROR: update for $sVarname failed.";
                }
                }