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

vcs.git.class.php

Blame
  • index.php 9.43 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
     * ======================================================================
     */
    
        $bDebug=false;
        ini_set('display_errors', 1);
        ini_set('display_startup_errors', 1);
        error_reporting(E_ALL);
    
        require_once("../../config/inc_projects_config.php");
        
        $sDirClasses=__DIR__.'/../deployment/classes/';
        require_once($sDirClasses.'/project.class.php');
        require_once($sDirClasses.'logger.class.php');
    
        $iMaxAge=60;
        
        // ----------------------------------------------------------------------
        // FUNCTIONS
        // ----------------------------------------------------------------------
        /**
         * write debug text (if enabled)
         * @global boolean $bDebug
         * @param string  $s       message
         * @param string  $sLevel  level; one of info|
         * @return boolean
         */
        function _wd($s, $sLevel='info'){
            global $bDebug;
            if ($bDebug){
                echo '<div class="debug debug-'.$sLevel.'">DEBUG: '.$s.'</div>';
            }
            return true;
        }
        
        /**
         * abort execution with error
         * @param string   $s        message
         * @param integer  $iStatus  http status code to send
         */
        function _quit($s, $iStatus=400){
            $aStatus=array(
               400=>'HTTP/1.0 400 Bad Request', 
               403=>'HTTP/1.0 403 Access denied', 
               404=>'HTTP/1.0 404 Not found', 
            );
            header($aStatus[$iStatus]);
            _done(array('status'=>$iStatus, 'info'=>$aStatus[$iStatus], 'message'=>$s));
        }
        /**
         * end with OK output
         * @param type $Data
         */
        function _done($Data){
            echo is_array($Data) 
                ? json_encode($Data, JSON_PRETTY_PRINT)
                : $Data
                ;