Skip to content
Snippets Groups Projects
Select Git revision
  • 99cfa19760469bdab32e26fbc331f77825a0e009
  • master default protected
  • Legacy_Php7
3 results

plugins.class.php

Blame
  • index.php 9.19 KiB
    <?php
    /* ======================================================================
     * 
     * A P I   F O R   C I   S E R V E R
     * 
     * GET  /api/v1/projects/
     * GET  /api/v1/project/[ID]/build/[name-of-branch]
     * POST /api/v1/project/[ID]/build/[name-of-branch]
     * GET  /api/v1/project/[ID]/phases
     * 
     * ----------------------------------------------------------------------
     * 2020-06-16  v0.9  <axel.hahn@iml.unibe.ch>  
     * 2021-03-29  v1.2  <axel.hahn@iml.unibe.ch>  support slashes in branch names
     * 2024-09-02  v1.3  <axel.hahn@unibe.ch>      php8 only; added variable types; short array syntax
     * ======================================================================
     */
    
    $bDebug = false;
    ini_set('display_errors', 1);
    ini_set('display_startup_errors', 1);
    error_reporting(E_ALL);
    
    /**
     * Path to deployment classes
     * @var string
     */
     $sDirClasses = __DIR__ . '/../deployment/classes/';
    
     /**
     * Allowed time delta for client or server
     * @var integer
     */
    $iMaxAge = 60;
    
    require_once("../../config/inc_projects_config.php");
    
    require_once($sDirClasses . '/project.class.php');
    require_once($sDirClasses . 'logger.class.php');
    
    // ----------------------------------------------------------------------
    // FUNCTIONS
    // ----------------------------------------------------------------------
    /**
     * Write debug text (if enabled)
     * 
     * @global boolean $bDebug
     * 
     * @param string  $s       message
     * @param string  $sLevel  level; one of info|
     * @return boolean
     */
    function _wd(string $s, string $sLevel = 'info'): bool
    {
        global $bDebug;
        if ($bDebug) {
            echo "<div class=\"debug debug-$sLevel\">DEBUG: $s</div>";
        }
        return true;
    }
    
    /**
     * Abort execution of API request with error
     * 
     * @param string   $s        message
     * @param integer  $iStatus  http status code to send
     */
    function _quit(string $s, int $iStatus = 400): void
    {
        $aStatus = [
            400 => 'HTTP/1.0 400 Bad Request',