コード例 #1
0
ファイル: git.php プロジェクト: rwaldron/git-php
    setcookie('nr_of_shortlog_lines', "{$nr_of_shortlog_lines}", time() + 3600 * 24 * 360);
} elseif (isset($_COOKIE['nr_of_shortlog_lines'])) {
    $nr_of_shortlog_lines = $_COOKIE['nr_of_shortlog_lines'];
} else {
    $nr_of_shortlog_lines = 20;
}
if ($nr_of_shortlog_lines > 512 || $nr_of_shortlog_lines < 0 || !is_numeric($nr_of_shortlog_lines)) {
    $nr_of_shortlog_lines = 20;
}
$extEnscript = array('.ada' => 'ada', '.adb' => 'ada', '.ads' => 'ada', '.awk' => 'awk', '.c' => 'c', '.c++' => 'cpp', '.cc' => 'cpp', '.cpp' => 'cpp', '.csh' => 'csh', '.cxx' => 'cpp', '.diff' => 'diffu', '.dpr' => 'delphi', '.e' => 'eiffel', '.el' => 'elisp', '.eps' => 'postscript', '.f' => 'fortran', '.for' => 'fortran', '.gs' => 'haskell', '.h' => 'c', '.hpp' => 'cpp', '.hs' => 'haskell', '.htm' => 'html', '.html' => 'html', '.idl' => 'idl', '.java' => 'java', '.js' => 'javascript', '.lgs' => 'haskell', '.lhs' => 'haskell', '.m' => 'objc', '.m4' => 'm4', '.man' => 'nroff', '.nr' => 'nroff', '.p' => 'pascal', '.pas' => 'delphi', '.patch' => 'diffu', '.pkg' => 'sql', '.pl' => 'perl', '.pm' => 'perl', '.pp' => 'pascal', '.ps' => 'postscript', '.s' => 'asm', '.scheme' => 'scheme', '.scm' => 'scheme', '.scr' => 'synopsys', '.sh' => 'sh', '.shtml' => 'html', '.sql' => 'sql', '.st' => 'states', '.syn' => 'synopsys', '.synth' => 'synopsys', '.tcl' => 'tcl', '.tex' => 'tex', '.texi' => 'tex', '.texinfo' => 'tex', '.v' => 'verilog', '.vba' => 'vba', '.vh' => 'verilog', '.vhd' => 'vhdl', '.vhdl' => 'vhdl', '.py' => 'python', '.php' => 'php', '.phtml' => 'php', '.php3' => 'php', '.php' => 'php');
if (!isset($git_embed) && $git_embed != true) {
    $git_embed = false;
}
if (isset($_GET['dl'])) {
    if ($_GET['dl'] == 'targz') {
        write_targz(get_repo_path($_GET['p']));
    } elseif ($_GET['dl'] == 'zip') {
        write_zip(get_repo_path($_GET['p']));
    } elseif ($_GET['dl'] == 'plain') {
        write_plain();
    } elseif (in_array($_GET['dl'], $icondesc, true)) {
        write_img_png($_GET['dl']);
    } elseif ($_GET['dl'] == 'dlfile') {
        write_dlfile();
    } elseif ($_GET['dl'] == 'rss2') {
        write_rss2();
    } elseif (in_array($_GET['dl'], $arrowdesc, true)) {
        draw_arrow($_GET['dl']);
    }
}
html_header();
コード例 #2
0
function git_render_page()
{
    global $git_embed, $repos;
    $git_embed = true;
    /* Add the default css */
    $git_css = true;
    /* Add the git logo in the footer */
    $git_logo = true;
    $title = "git";
    $repo_index = "index.aux";
    $repo_directory = '/home/david/git/';
    $geshi_directory = '/home/david/src/mediawiki/extensions/SyntaxHighlight_GeSHi/geshi';
    //if git is not installed into standard path, we need to set the path
    $mypath = getenv("PATH");
    $addpath = "/usr/lib/git-core";
    if (isset($mypath)) {
        $mypath .= ":{$addpath}";
    } else {
        $mypath = $addpath;
    }
    putenv("PATH={$mypath}");
    //repos could be made by an embeder script
    if (!is_array($repos)) {
        $repos = array();
    }
    if (file_exists($repo_index)) {
        $r = file($repo_index);
        foreach ($r as $repo) {
            $repos[] = trim($repo);
        }
    } else {
        if (file_exists($repo_directory) && is_dir($repo_directory)) {
            if ($handle = opendir($repo_directory)) {
                while (false !== ($file = readdir($handle))) {
                    if ($file != "." && $file != "..") {
                        /* TODO: Check for valid git repos */
                        $repos[] = trim($repo_directory . $file);
                    }
                }
                closedir($handle);
            }
        }
    }
    sort($repos);
    if ($geshi_directory != '') {
        require "{$geshi_directory}/geshi.php";
    }
    if (!isset($git_embed) && $git_embed != true) {
        $git_embed = false;
    }
    foreach ($_GET as $var => $val) {
        $_GET[$var] = str_replace(";", "", $_GET[$var]);
    }
    $str = '';
    if (isset($_GET['dl'])) {
        if ($_GET['dl'] == 'targz') {
            write_targz(get_repo_path($_GET['p']));
        } else {
            if ($_GET['dl'] == 'zip') {
                write_zip(get_repo_path($_GET['p']));
            } else {
                if ($_GET['dl'] == 'git_logo') {
                    write_git_logo();
                } else {
                    if ($_GET['dl'] == 'plain') {
                        write_plain();
                    } else {
                        if ($_GET['dl'] == 'rss2') {
                            write_rss2();
                        }
                    }
                }
            }
        }
    }
    $str .= html_header($title);
    $str .= html_style($git_css);
    $str .= html_breadcrumbs();
    if (isset($_GET['p'])) {
        $str .= html_spacer();
        $str .= html_desc($_GET['p']);
        $str .= html_spacer();
        $str .= html_summary($_GET['p']);
        $str .= html_spacer();
        if ($_GET['a'] == "commitdiff") {
            $str .= html_diff($_GET['p'], $_GET['c'], $_GET['cp']);
        } else {
            $str .= html_browse($_GET['p']);
        }
    } else {
        $str .= html_spacer();
        $str .= html_home($repos);
    }
    $str .= html_footer($git_logo);
    return $str;
}