protected function execute(InputInterface $input, OutputInterface $output)
 {
     $output->writeln('<head><style>' . file_get_contents(dirname(dirname(dirname(__DIR__))) . '/res/css/diff.css') . '</style></head>');
     $sourceFile = $input->getArgument('pathSource');
     $targetFile = $input->getArgument('pathCompare');
     $sourceCode = explode("\n", file_get_contents($sourceFile));
     $targetCode = explode("\n", file_get_contents($targetFile));
     array_shift($sourceCode);
     array_shift($targetCode);
     $output->write(html_diff(join("\n", $sourceCode), join("\n", $targetCode)));
 }
 function _tpl_act_changes(&$event, $param)
 {
     global $TEXT;
     global $PRE;
     global $SUF;
     if ('changes' != $event->data) {
         return;
     }
     html_edit($TEXT);
     echo '<br id="scroll__here" />';
     html_diff(con($PRE, $TEXT, $SUF));
     $event->preventDefault();
     return;
 }
Exemple #3
0
 public function diff()
 {
     // dump($sourceDocument);
     // Source = 3 ; target = 2
     $sourceData = json_decode($source->content);
     $targetData = json_decode($target->content);
     $diff = array();
     $diff['title'] = html_diff($sourceData->title, $targetData->title, true);
     $diff['permalink'] = html_diff($sourceData->permalink, $targetData->permalink, true);
     $diff['intro'] = html_diff($sourceData->intro, $targetData->intro);
     // $diff['state']	=	html_diff($sourceData->state,$targetData->state, true);
     // TODO: get category title
     $sourceCategory = EB::table('Category');
     $sourceCategory->load($sourceData->category_id);
     $diff['source_category_title'] = $sourceCategory->title;
     $targetCategory = EB::table('Category');
     $targetCategory->load($targetData->category_id);
     $diff['diff_category_title'] = $targetCategory->title;
     return $diff;
 }
Exemple #4
0
/**
 * Default Action of TPL_ACT_RENDER
 *
 * @return bool
 */
function tpl_content_core()
{
    global $ACT;
    global $TEXT;
    global $PRE;
    global $SUF;
    global $SUM;
    global $IDX;
    global $INPUT;
    switch ($ACT) {
        case 'show':
            html_show();
            break;
            /** @noinspection PhpMissingBreakStatementInspection */
        /** @noinspection PhpMissingBreakStatementInspection */
        case 'locked':
            html_locked();
        case 'edit':
        case 'recover':
            html_edit();
            break;
        case 'preview':
            html_edit();
            html_show($TEXT);
            break;
        case 'draft':
            html_draft();
            break;
        case 'search':
            html_search();
            break;
        case 'revisions':
            html_revisions($INPUT->int('first'));
            break;
        case 'diff':
            html_diff();
            break;
        case 'recent':
            html_recent($INPUT->extract('first')->int('first'), $INPUT->str('show_changes'));
            break;
        case 'index':
            html_index($IDX);
            #FIXME can this be pulled from globals? is it sanitized correctly?
            break;
        case 'backlink':
            html_backlinks();
            break;
        case 'conflict':
            html_conflict(con($PRE, $TEXT, $SUF), $SUM);
            html_diff(con($PRE, $TEXT, $SUF), false);
            break;
        case 'login':
            html_login();
            break;
        case 'register':
            html_register();
            break;
        case 'resendpwd':
            html_resendpwd();
            break;
        case 'denied':
            print p_locale_xhtml('denied');
            break;
        case 'profile':
            html_updateprofile();
            break;
        case 'admin':
            tpl_admin();
            break;
        case 'subscribe':
            tpl_subscribe();
            break;
        case 'media':
            tpl_media();
            break;
        default:
            $evt = new Doku_Event('TPL_ACT_UNKNOWN', $ACT);
            if ($evt->advise_before()) {
                msg("Failed to handle command: " . hsc($ACT), -1);
            }
            $evt->advise_after();
            unset($evt);
            return false;
    }
    return true;
}
Exemple #5
0
function tpl_content_core()
{
    global $ACT;
    global $TEXT;
    global $PRE;
    global $SUF;
    global $SUM;
    global $IDX;
    switch ($ACT) {
        case 'show':
            html_show();
            break;
        case 'locked':
            html_locked();
        case 'edit':
        case 'recover':
            html_edit();
            break;
        case 'preview':
            html_edit();
            html_show($TEXT);
            break;
        case 'draft':
            html_draft();
            break;
        case 'search':
            html_search();
            break;
        case 'revisions':
            $first = isset($_REQUEST['first']) ? intval($_REQUEST['first']) : 0;
            html_revisions($first);
            break;
        case 'diff':
            html_diff();
            break;
        case 'recent':
            if (is_array($_REQUEST['first'])) {
                $_REQUEST['first'] = array_keys($_REQUEST['first']);
                $_REQUEST['first'] = $_REQUEST['first'][0];
            }
            $first = is_numeric($_REQUEST['first']) ? intval($_REQUEST['first']) : 0;
            html_recent($first);
            break;
        case 'index':
            html_index($IDX);
            #FIXME can this be pulled from globals? is it sanitized correctly?
            break;
        case 'backlink':
            html_backlinks();
            break;
        case 'conflict':
            html_conflict(con($PRE, $TEXT, $SUF), $SUM);
            html_diff(con($PRE, $TEXT, $SUF), false);
            break;
        case 'login':
            html_login();
            break;
        case 'register':
            html_register();
            break;
        case 'resendpwd':
            html_resendpwd();
            break;
        case 'denied':
            print p_locale_xhtml('denied');
            break;
        case 'profile':
            html_updateprofile();
            break;
        case 'admin':
            tpl_admin();
            break;
        case 'subscribe':
            tpl_subscribe();
            break;
        default:
            $evt = new Doku_Event('TPL_ACT_UNKNOWN', $ACT);
            if ($evt->advise_before()) {
                msg("Failed to handle command: " . hsc($ACT), -1);
            }
            $evt->advise_after();
            unset($evt);
            return false;
    }
    return true;
}
Exemple #6
0
be added after it.

This paragraph contains
important new additions
to this document.';
echo '
<style type="text/css">
.ins { background: #cfc; }
.del { background: #fcc; }
ins { background: #9f9; }
del { background: #f99; }
hr { background: none; border: none; border-top: 2px dotted #000; color: #fff; }
</style>
<pre>
';
echo html_diff($original, $updated);
function html_diff($old, $new)
{
    $diff = simpleDiff::diff_to_array(false, $old, $new, 1);
    $out = '<table class="diff">';
    $prev = key($diff);
    foreach ($diff as $i => $line) {
        if ($i > $prev + 1) {
            $out .= '<tr><td colspan="5" class="separator"><hr /></td></tr>';
        }
        list($type, $old, $new) = $line;
        $class1 = $class2 = '';
        $t1 = $t2 = '';
        if ($type == simpleDiff::INS) {
            $class2 = 'ins';
            $t2 = '+';
function ws_display($window_name, $form = '')
{
    global $conf, $self, $onadb, $baseURL;
    global $images, $color, $style;
    $html = '';
    $js = '';
    $debug_val = 3;
    // used in the auth() calls to supress logging
    // Dont display this if they dont have access
    if (!auth('host_config_admin', $debug_val)) {
        array_pop($_SESSION['ona']['work_space']['history']);
        $html .= "<br><center><font color=\"red\"><b>You don't have access to this page</b></font></center>";
        $response = new xajaxResponse();
        $response->addAssign("work_space_content", "innerHTML", $html);
        return $response->getXML();
    }
    // If the user supplied an array in a string, build the array and store it in $form
    $form = parse_options_string($form);
    if ($form['type_id']) {
        list($status, $rows, $rec) = ona_get_config_type_record(array('id' => $form['type_id']));
        $default_type = $rec['name'];
    }
    // Load the host record
    list($status, $rows, $host) = ona_find_host($form['host_id']);
    if (!$host['id']) {
        array_pop($_SESSION['ona']['work_space']['history']);
        $html .= "<br><center><font color=\"red\"><b>Host doesn't exist!</b></font></center>";
        $response = new xajaxResponse();
        $response->addAssign("work_space_content", "innerHTML", $html);
        return $response->getXML();
    }
    // Get configurations info
    list($status, $rows, $configs) = db_get_records($onadb, 'configurations', array('host_id' => $host['id']), 'ctime DESC');
    // Update History Title (and tell the browser to re-draw the history div)
    $history = array_pop($_SESSION['ona']['work_space']['history']);
    $js .= "xajax_window_submit('work_space', ' ', 'rewrite_history');";
    if ($history['title'] == $window_name) {
        $history['title'] = "Configs: {$host['name']}";
        array_push($_SESSION['ona']['work_space']['history'], $history);
    }
    // Create some javascript to refresh the current page
    $refresh = htmlentities(str_replace(array("'", '"'), array("\\'", '\\"'), $history['url']), ENT_QUOTES, $conf['php_charset']);
    $refresh = "xajax_window_submit('work_space', '{$refresh}');";
    $style['content_box'] = <<<EOL
        margin: 10px 20px;
        padding: 2px 4px;
        background-color: #FFFFFF;
        vertical-align: top;
EOL;
    $style['label_box'] = <<<EOL
        font-weight: bold;
        padding: 2px 4px;
        border: solid 1px {$color['border']};
        background-color: {$color['window_content_bg']};
EOL;
    // Escape data for display in html
    foreach (array_keys((array) $record) as $key) {
        $record[$key] = htmlentities($record[$key], ENT_QUOTES, $conf['php_charset']);
    }
    $html .= <<<EOL
    <!-- FORMATTING TABLE -->
    <div style="{$style['content_box']}">
    <table cellspacing="0" border="0" cellpadding="0"><tr>

        <!-- START OF FIRST COLUMN OF SMALL BOXES -->
        <td nowrap="true" valign="top" style="padding-right: 15px;">
EOL;
    // Config archive INFORMATION
    $html .= <<<EOL
            <table width=100% cellspacing="0" border="0" cellpadding="0" style="margin-bottom: 8px;">

                <tr><td colspan="99" nowrap="true" style="{$style['label_box']}">
                    <!-- LABEL -->

                    <b>Configuration archives for:</b>
                    <a title="View host. ID: {$host['id']}"
                       class="nav"
                       onClick="xajax_window_submit('work_space', 'xajax_window_submit(\\'display_host\\', \\'host_id=>{$host['id']}\\', \\'display\\')');"
                    >{$host['name']}</a
                    >.<a title="View domain. ID: {$host['domain_id']}"
                         class="domain"
                         onClick="xajax_window_submit('work_space', 'xajax_window_submit(\\'display_domain\\', \\'domain_id=>{$host['domain_id']}\\', \\'display\\')');"
                    >{$host['domain_fqdn']}</a>

EOL;
    // TODO: fix this so it actually looks for a report list item like other reports do
    $html .= <<<EOL
                </td></tr>

                <tr>
                    <td class="padding" align="left">
                        <b>Cisco Config report:</b>&nbsp;
                        <a title="View report"
                        class="act"
                        onClick="xajax_window_submit('work_space', 'xajax_window_submit(\\'display_report\\', \\'report=>cisco_cfg_audit,config=>{$host['fqdn']}\\', \\'display\\')');"
                        >View Report</a></td>
                </tr>

            </table>
EOL;
    // END CONFIG INFORMATION
    $html .= <<<EOL
        <!-- END OF FIRST COLUMN OF SMALL BOXES -->
        </td>

    </tr></table>
    </div>
    <!-- END OF TOP SECTION -->
EOL;
    // Config archive LIST
    $tab = 'configs';
    $submit_window = "list_{$tab}";
    $form_id = "{$submit_window}_filter_form";
    $_SESSION['ona'][$form_id]['tab'] = $tab;
    $content_id = "{$window_name}_{$submit_window}";
    $html .= <<<EOL
    <!-- Archive LIST -->
    <div style="border: 1px solid {$color['border']}; margin: 10px 20px;">

        <!-- Tab & Quick Filter -->
        <table id="{$form_id}_table" cellspacing="0" border="0" cellpadding="0">
            <tr>
                <td id="{$form_id}_{$tab}_tab" class="table-tab-active">
                    Associated {$tab} <span id="{$form_id}_{$tab}_count"></span>
                </td>

                <td id="{$form_id}_quick_filter" class="padding" align="right" width="100%">
                    <form id="{$form_id}" onSubmit="return false;">
                    <input id="{$form_id}_page" name="page" value="1" type="hidden">
                    <input name="content_id" value="{$content_id}" type="hidden">
                    <input name="form_id" value="{$form_id}" type="hidden">
                    <input name="host_id" value="{$host['id']}" type="hidden">
                    <div id="{$form_id}_filter_overlay"
                         title="Filter"
                         style="position: relative;
                                display: inline;
                                color: #CACACA;
                                cursor: text;"
                         onClick="this.style.display = 'none'; el('{$form_id}_filter').focus();"
                    ></div>
                    <input
                        id="{$form_id}_filter"
                        name="filter"
                        class="filter"
                        type="text"
                        value="{$default_type}"
                        size="15"
                        maxlength="20"
                        alt="Quick Filter"
                        onFocus="el('{$form_id}_filter_overlay').style.display = 'none';"
                        onBlur="if (this.value == '') el('{$form_id}_filter_overlay').style.display = 'inline';"
                        onKeyUp="
                            if (typeof(timer) != 'undefined') clearTimeout(timer);
                            code = 'if ({$form_id}_last_search != el(\\'{$form_id}_filter\\').value) {' +
                                   '    {$form_id}_last_search = el(\\'{$form_id}_filter\\').value;' +
                                   '    document.getElementById(\\'{$form_id}_page\\').value = 1;' +
                                   '    xajax_window_submit(\\'{$submit_window}\\', xajax.getFormValues(\\'{$form_id}\\'), \\'display_list\\');' +
                                   '}';
                            timer = setTimeout(code, 700);"
                    >
                    </form>
                </td>

            </tr>
        </table>

        <div id='{$content_id}'>
            {$conf['loading_icon']}
        </div>

        <!-- Tool LINKS -->
        <div class="act-box" style="padding: 2px 4px; border-top: 1px solid {$color['border']}">

            <input type="button"
                name="compare"
                value="Compare selected configs"
                class="button"
                onClick="
                  var tmp = 1; var OLD = el('old' + tmp);
                  while (OLD) {
                    if (OLD.checked) break;
                      OLD = el('old' + tmp++);
                    }
                    var tmp = 1; var NEW = el('new' + tmp);
                    while (NEW) {
                      if (NEW.checked) break;
                        NEW = el('new' + tmp++);
                    }
                    if ((!OLD) || (!NEW))
                      alert('ERROR => You must select and old and new config to compare them!');
                    else
                      xajax_window_submit('work_space', 'xajax_window_submit(\\'{$window_name}\\', \\'host_id=>{$form['host_id']}, old_id=>' + OLD.value + ',new_id=>' + NEW.value + '\\', \\'display\\')');
            ">
        </div>

    </div>

EOL;
    $js .= <<<EOL
        /* Setup the quick filter */
        el('{$form_id}_filter_overlay').style.left = (el('{$form_id}_filter_overlay').offsetWidth + 10) + 'px';
        {$form_id}_last_search = '';

        /* Tell the browser to load/display the list */
        xajax_window_submit('{$submit_window}', xajax.getFormValues('{$form_id}'), 'display_list');
EOL;
    // If they have selected to display the config, show it
    if ($form['displayconf']) {
        list($status, $rows, $config) = ona_get_config_record(array('id' => $form['displayconf']));
        // Remove characters that will not display properly in a browser.. specifically CTRL-C and CTRL-G chars
        $config['config_body'] = htmlentities(str_replace(array(chr(03), chr(07)), '', $config['config_body']), ENT_QUOTES, $conf['php_charset']);
        $html .= <<<EOL
        <div style="margin: 10px 20px; background-color: {$color['bar_bg']}; border: 1px solid; height: 60px;">
            <table cellspacing="0" border="0" cellpadding="2" align="left" style="font-size:small;">
                <tr>
                    <td style="font-weight: bold;">Insert date:</td>
                    <td>{$config['ctime']}</td>
                </tr>
                <tr>
                    <td style="font-weight: bold;">Config type:</td>
                    <td>{$config['config_type_name']}</td>
                </tr>
                <tr>
                    <td style="font-weight: bold;">MD5:</td>
                    <td>{$config['md5_checksum']}</td>
                </tr>
            </table>
        </div>
        <div style="clear: both;"></div>
        <div id="confoutputdiv" style="border: 1px solid rgb(26, 26, 26); margin: 10px 20px;padding-left: 8px;overflow-y: auto;">
            <pre style='font-family: monospace;width: 50px;' id="confoutput">{$config['config_body']}</pre>
        </div>
EOL;
    }
    // If they have selected to display the diff mode
    if ($form['old_id'] && $form['new_id']) {
        // Load the old config text record
        list($status, $rows, $old) = ona_get_config_record(array('id' => $form['old_id']));
        if (!$old['id']) {
            $html .= "<br><center><font color=\"red\"><b>Configuration text record doesn't exist!</b></font></center>";
        }
        // Load the new config text record
        list($status, $rows, $new) = ona_get_config_record(array('id' => $form['new_id']));
        if (!$new['id']) {
            $html .= "<br><center><font color=\"red\"><b>Configuration text record doesn't exist!</b></font></center>";
        }
        // Load the asscoiated old host record
        list($status, $rows, $old_host) = ona_find_host($old['host_id']);
        if (!$old_host['id']) {
            $html .= "<br><center><font color=\"red\"><b>Host doesn't exist!</b></font></center>";
        }
        // Load the asscoiated new host record
        list($status, $rows, $new_host) = ona_find_host($new['host_id']);
        if (!$new_host['id']) {
            $html .= "<br><center><font color=\"red\"><b>Host doesn't exist!</b></font></center>";
        }
        // Update History Title
        $history = array_pop($_SESSION['ona']['work_space']['history']);
        $history['title'] = "Config diff ({$form['old_id']} / {$form['new_id']})";
        array_push($_SESSION['ona']['work_space']['history'], $history);
        // Remove characters that will not display properly in a browser.. specifically CTRL-C chars
        $old['config_body'] = htmlentities(str_replace(chr(03), "", $old['config_body']), ENT_QUOTES, $conf['php_charset']);
        $new['config_body'] = htmlentities(str_replace(chr(03), "", $new['config_body']), ENT_QUOTES, $conf['php_charset']);
        // Display the config text diff
        $html .= <<<EOL
        <div style="margin: 10px 20px;">

            <!-- Diff Headers -->
            <table width="100%" cellspacing="0" border="0" cellpadding="2" align="left" style="font-size:small;">
            <tr>
            <td align="left" style="background-color: {$color['bar_bg']};">
                <table cellspacing="0" border="0" cellpadding="2" align="left" style="font-size:small;">
                    <tr>
                        <td style="font-weight: bold;">Host:</td>
                        <td>
                            <a title="View host. ID: {$old_host['id']}"
                               class="nav"
                               onClick="xajax_window_submit('work_space', 'xajax_window_submit(\\'display_host\\', \\'host_id=>{$old_host['id']}\\', \\'display\\')');"
                            >{$old_host['name']}</a
                            >.<a title="View domain. ID: {$old_host['domain_id']}"
                                 class="domain"
                                 onClick="xajax_window_submit('work_space', 'xajax_window_submit(\\'display_domain\\', \\'domain_id=>{$old_host['domain_id']}\\', \\'display\\')');"
                            >{$old_host['domain_fqdn']}</a>
                        </td>
                    </tr>
                    <tr>
                        <td style="font-weight: bold;">Insert date:</td>
                        <td>{$old['ctime']}</td>
                    </tr>
                    <tr>
                        <td style="font-weight: bold;">Config type:</td>
                        <td>{$old['config_type_name']}</td>
                    </tr>
                    <tr>
                        <td style="font-weight: bold;">MD5:</td>
                        <td>{$old['md5_checksum']}</td>
                    </tr>
                    <tr>
                        <td style="font-weight: bold;">Actions:</td>
                        <td>
                            <a title="View config"
                               class="nav"
                               onClick="xajax_window_submit('work_space', 'xajax_window_submit(\\'{$window_name}\\', \\'host_id=>{$old_host['id']},displayconf=>{$old['id']}\\', \\'display\\')');"
                            ><img src="{$images}/silk/zoom.png" alt="View config" border="0"></a>&nbsp;

                            <a title="Download config" class="act" target="null" href="{$baseURL}/config_dnld.php?config_id={$old['id']}&download=1"
                            ><img src="{$images}/silk/disk.png" alt="Download config" border="0"></a>&nbsp;
                        </td>
                    </tr>
                </table>
            </td>
            <td align="left" style="background-color: {$color['bar_bg']};">
                <table cellspacing="0" border="0" cellpadding="2" align="left" style="font-size:small;">
                    <tr>
                        <td style="font-weight: bold;">Host:</td>
                        <td>
                            <a title="View host. ID: {$new_host['id']}"
                               class="nav"
                               onClick="xajax_window_submit('work_space', 'xajax_window_submit(\\'display_host\\', \\'host_id=>{$new_host['id']}\\', \\'display\\')');"
                            >{$new_host['name']}</a
                            >.<a title="View domain. ID: {$new_host['domain_id']}"
                                 class="domain"
                                 onClick="xajax_window_submit('work_space', 'xajax_window_submit(\\'display_domain\\', \\'domain_id=>{$new_host['domain_id']}\\', \\'display\\')');"
                            >{$new_host['domain_fqdn']}</a>
                        </td>
                    </tr>
                    <tr>
                        <td style="font-weight: bold;">Insert date:</td>
                        <td>{$new['ctime']}</td>
                    </tr>
                    <tr>
                        <td style="font-weight: bold;">Config type:</td>
                        <td>{$new['config_type_name']}</td>
                    </tr>
                    <tr>
                        <td style="font-weight: bold;">MD5:</td>
                        <td>{$new['md5_checksum']}</td>
                    </tr>
                    <tr>
                        <td style="font-weight: bold;">Actions:</td>
                        <td>
                            <a title="View config"
                               class="nav"
                               onClick="xajax_window_submit('work_space', 'xajax_window_submit(\\'{$window_name}\\', \\'host_id=>{$new_host['id']},displayconf=>{$new['id']}\\', \\'display\\')');"
                            ><img src="{$images}/silk/zoom.png" alt="View config" border="0"></a>&nbsp;

                            <a title="Download config" class="act" target="null" href="{$baseURL}/config_dnld.php?config_id={$new['id']}&download=1"
                            ><img src="{$images}/silk/disk.png" alt="Download config" border="0"></a>&nbsp;
                        </td>
                    </tr>
                </table>
            </td>
            </tr>
            <tr>
            <td colspan="2">
EOL;
        // Display the diff
        $html .= html_diff(html_entity_decode($old['config_body'], ENT_QUOTES, $conf['php_charset']), html_entity_decode($new['config_body'], ENT_QUOTES, $conf['php_charset']), "Config A", "Config B", 0);
        $html .= <<<EOL
            </td>
            </tr>
            </table>
        </div>
EOL;
    }
    // Insert the new html into the window
    // Instantiate the xajaxResponse object
    $response = new xajaxResponse();
    $response->addAssign("work_space_content", "innerHTML", $html);
    if ($js) {
        $response->addScript($js);
    }
    return $response->getXML();
}
Exemple #8
0
 /**
  * Displays a comparison of two versions for the blog post
  *
  * @since	4.0
  * @access	public
  * @param	string
  * @return
  */
 public function diff()
 {
     require JPATH_ADMINISTRATOR . '/components/com_easyblog/includes/htmldiff/html_diff.php';
     // Only allow logged in users on this page
     EB::requireLogin();
     //Get revision table
     $Revision = EB::table('Revision');
     // get blogid
     $versionId = JRequest::getVar('id', '');
     $postId = JRequest::getVar('post_id', '');
     //Load the version for the blog post
     $currentBlog = $Revision->getCurrentBlog($postId);
     $compareBlog = $Revision->getCompareBlog($versionId);
     $currentData = json_decode($currentBlog->params);
     $compareData = json_decode($compareBlog->params);
     $diff = html_diff($currentData->intro, $compareData->intro, true);
     // Get category title
     $category = EB::table('Category');
     $category->load($currentData->category_id);
     $dataArr = array();
     $dataArr['catOld'] = $category->title;
     $category->load($compareData->category_id);
     $dataArr['catNew'] = $category->title;
     $this->set('currentData', $currentData);
     $this->set('compareData', $compareData);
     $this->set('dataArr', $dataArr);
     $this->set('diff', $diff);
     $this->set('blogId', $postId);
     $this->set('versionId', $versionId);
     echo parent::display('dashboard/version/compare');
 }
Exemple #9
0
        write_rss2();
    } elseif (in_array($_GET['dl'], $arrowdesc, true)) {
        draw_arrow($_GET['dl']);
    }
}
html_header();
html_style();
html_breadcrumbs();
html_pages();
if (isset($_GET['p'])) {
    html_spacer();
    html_summary($_GET['p']);
    html_spacer();
    if ($_GET['a'] == "commitdiff") {
        html_title("diff --git {$_GET['p']} {$_GET['h']}");
        html_diff($_GET['p'], $_GET['h']);
    } elseif (isset($_GET['tr'])) {
        html_title("Files");
        html_browse($_GET['p']);
    }
} else {
    html_spacer();
    html_home();
}
html_title("Help");
if (isset($_GET['p'])) {
    html_help($_GET['p']);
} else {
    html_help("projectname.git ");
}
html_footer();
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;
}
Exemple #11
0
                    $curRev = $index;
                    break;
                }
            }
        }
        // Get the source for the active revision
        foreach ($revisions[$curRev]['files'] as $file => $url) {
            $gistSource[$file]['cur'] = curl($url);
            // Get the source for the previous revision (for diffing)
            $gistSource[$file]['prev'] = '';
            if ($curRev < count($revisions) - 1) {
                $gistSource[$file]['prev'] = curl($revisions[$curRev + 1]['files'][$file]);
            }
            // Diff the two
            $diff = simpleDiff::diff($gistSource[$file]['prev'], $gistSource[$file]['cur']);
            $gistSource[$file]['diff'] = html_diff($gistSource[$file]['prev'], $gistSource[$file]['cur']);
        }
        //print_r($gistSource);
        //echo '<pre>' . print_r($gistSource, true) . '</pre>';
    }
}
// Make sure there is no whitespace before first HTML code
// so we don't trigger Quirks mode
?>
<!DOCTYPE html>
<html>
  <head>
    <title>GistPad</title>
    
    <!--
    Copyright (c) 2010 Brandon Williams