Example #1
0
/**
 * @brief Get hash of the last git commit (on remote "origin"!)
 *
 * @note    If this method does not work, try to make a "git pull" first!
 *
 * @param integer $length       if this is smaller than 40, only the first $length characters will be returned
 *
 * @retval string       The hash of the last commit
 * @retval NULL         If this is no Git installation
 *
 * @throws Exception if there was an error
 */
function get_git_commit_hash($length = 40)
{
    $filename = BASE . '/.git/refs/remotes/origin/' . get_git_branch_name();
    if (file_exists($filename)) {
        $head = File($filename);
        $hash = $head[0];
        return substr($hash, 0, $length);
    }
    return NULL;
    // this is not a Git installation
}
Example #2
0
    }
    $html->set_loop('rss_feed_loop', $rss_loop);
}
/********************************************************************************
 *
 *   Set the rest of the HTML variables
 *
 *********************************************************************************/
$html->set_loop('authors', $authors);
if (!$fatal_error) {
    $html->set_variable('banner', $config['startup']['custom_banner'], 'string');
    try {
        $system_version = $system->get_installed_version();
        $html->set_variable('system_version', $system_version->as_string(false, true, true, false), 'string');
        $html->set_variable('system_version_full', $system_version->as_string(false, false, false, true), 'string');
        $html->set_variable('git_branch', get_git_branch_name(), 'string');
        $html->set_variable('git_commit', get_git_commit_hash(10), 'string');
    } catch (Exception $e) {
        $messages[] = array('text' => nl2br($e->getMessage()), 'strong' => true, 'color' => 'red');
    }
}
/********************************************************************************
 *
 *   Generate HTML Output
 *
 *********************************************************************************/
$reload_link = $fatal_error ? 'startup.php' : '';
// an empty string means that the...
$html->print_header($messages, $reload_link);
// ...reload-button won't be visible
if (!$fatal_error) {