当前位置: 首页>>代码示例>>PHP>>正文


PHP GeSHi::load_from_file方法代码示例

本文整理汇总了PHP中GeSHi::load_from_file方法的典型用法代码示例。如果您正苦于以下问题:PHP GeSHi::load_from_file方法的具体用法?PHP GeSHi::load_from_file怎么用?PHP GeSHi::load_from_file使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在GeSHi的用法示例。


在下文中一共展示了GeSHi::load_from_file方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: jx_show_file

/**
 * Allows to view sourcecode (formatted by GeSHi or unformatted) and images
 *
 */
function jx_show_file($dir, $item)
{
    // show file contents
    show_header($GLOBALS["messages"]["actview"] . ": " . $item);
    $index2_edit_link = str_replace('/index3.php', '/index2.php', make_link('edit', $dir, $item));
    echo '<a name="top" class="componentheading" href="javascript:window.close();">[ ' . _PROMPT_CLOSE . ' ]</a>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;';
    $abs_item = get_abs_item($dir, $item);
    if (get_is_editable($abs_item) && $GLOBALS['jx_File']->is_writable($abs_item)) {
        // Edit the file in the PopUp
        echo '<a class="componentheading" href="' . make_link('edit', $dir, $item) . '&amp;return_to=' . urlencode($_SERVER['PHP_SELF'] . '?' . $_SERVER['QUERY_STRING']) . '">[ ' . $GLOBALS["messages"]["editlink"] . ' ]</a>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;';
        // Edit the file in the parent window
        //echo '<a class="componentheading" href="javascript:opener.location=\''.$index2_edit_link.'\'; window.close();">[ '.$GLOBALS["messages"]["editlink"].' ]</a>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;';
    }
    echo '<a class="componentheading" href="#bottom">[ ' . _CMN_BOTTOM . ' ]</a>';
    echo '<br /><br />';
    if (@eregi($GLOBALS["images_ext"], $item)) {
        echo '<img src="' . $GLOBALS['home_url'] . '/' . $dir . '/' . $item . '" alt="' . $GLOBALS["messages"]["actview"] . ": " . $item . '" /><br /><br />';
    } else {
        if (file_exists($GLOBALS['mosConfig_absolute_path'] . '/includes/domit/xml_saxy_shared.php')) {
            require_once $GLOBALS['mosConfig_absolute_path'] . '/includes/domit/xml_saxy_shared.php';
        } elseif (file_exists($GLOBALS['mosConfig_absolute_path'] . '/libraries/domit/xml_saxy_shared.php')) {
            require_once $GLOBALS['mosConfig_absolute_path'] . '/libraries/domit/xml_saxy_shared.php';
        } else {
            return;
        }
        if (file_exists($GLOBALS['mosConfig_absolute_path'] . '/mambots/content/geshi/geshi.php')) {
            $geshiFile = $GLOBALS['mosConfig_absolute_path'] . '/mambots/content/geshi/geshi.php';
        } elseif (file_exists($GLOBALS['mosConfig_absolute_path'] . '/libraries/geshi/geshi.php')) {
            $geshiFile = $GLOBALS['mosConfig_absolute_path'] . '/libraries/geshi/geshi.php';
        }
        if (file_exists($geshiFile)) {
            @ini_set('memory_limit', '32M');
            // GeSHi 1.0.7 is very memory-intensive
            include_once $geshiFile;
            // Create the GeSHi object that renders our source beautiful
            $geshi = new GeSHi('', '', dirname($geshiFile) . '/geshi');
            $file = get_abs_item($dir, $item);
            $pathinfo = pathinfo($file);
            if (jx_isFTPMode()) {
                $file = jx_ftp_make_local_copy($file);
            }
            if (is_callable(array($geshi, 'load_from_file'))) {
                $geshi->load_from_file($file);
            } else {
                $geshi->set_source(file_get_contents($file));
            }
            if (is_callable(array($geshi, 'getlanguagesuage_name_from_extension'))) {
                $lang = $geshi->getlanguage_name_from_extension($pathinfo['extension']);
            } else {
                $pathinfo = pathinfo($item);
                $lang = $pathinfo['extension'];
            }
            $geshi->set_language($lang);
            $geshi->enable_line_numbers(GESHI_NORMAL_LINE_NUMBERS);
            $text = $geshi->parse_code();
            if (jx_isFTPMode()) {
                unlink($file);
            }
            echo '<div style="text-align:left;">' . $text . '</div>';
            echo '<div style="line-height:25px;vertical-align:middle;text-align:center;" class="small">Rendering Time: <strong>' . $geshi->get_time() . ' Sec.</strong></div>';
        } else {
            // When GeSHi is not available, just display the plain file contents
            echo '<div class="quote" style="text-align:left;">' . nl2br(htmlentities($GLOBALS['jx_File']->file_get_contents(get_abs_item($dir, $item)))) . '</div>';
        }
    }
    echo '<a href="#top" name="bottom" class="componentheading">[ ' . _CMN_TOP . ' ]</a><br /><br />';
}
开发者ID:RangerWalt,项目名称:ecci,代码行数:71,代码来源:fun_view.php

示例2: strlen

// Get path info
$path = SOURCE_ROOT . $_SERVER['PATH_INFO'];
// Check for dickheads trying to use '../' to get to sensitive areas
$base_path_len = strlen(SOURCE_ROOT);
$real_path = realpath($path);
if (strncmp($real_path, SOURCE_ROOT, $base_path_len)) {
    exit("Access outside acceptable path.");
}
// Check file exists
if (!file_exists($path)) {
    exit("File not found ({$path}).");
}
// Prepare GeSHi instance
$geshi = new GeSHi();
$geshi->set_language('text');
$geshi->load_from_file($path);
$geshi->set_header_type(GESHI_HEADER_PRE);
$geshi->enable_classes();
$geshi->enable_line_numbers(GESHI_FANCY_LINE_NUMBERS, 10);
$geshi->set_overall_style('color: #000066; border: 1px solid #d0d0d0; background-color: #f0f0f0;', true);
$geshi->set_line_style('font: normal normal 95% \'Courier New\', Courier, monospace; color: #003030;', 'font-weight: bold; color: #006060;', true);
$geshi->set_code_style('color: #000020;', 'color: #000020;');
$geshi->set_link_styles(GESHI_LINK, 'color: #000060;');
$geshi->set_link_styles(GESHI_HOVER, 'background-color: #f0f000;');
$geshi->set_header_content('Source code viewer - ' . $path . ' - ' . $geshi->get_language_name());
$geshi->set_header_content_style('font-family: Verdana, Arial, sans-serif; color: #808080; font-size: 70%; font-weight: bold; background-color: #f0f0ff; border-bottom: 1px solid #d0d0d0; padding: 2px;');
$geshi->set_footer_content('Parsed in <TIME> seconds,  using GeSHi <VERSION>');
$geshi->set_footer_content_style('font-family: Verdana, Arial, sans-serif; color: #808080; font-size: 70%; font-weight: bold; background-color: #f0f0ff; border-top: 1px solid #d0d0d0; padding: 2px;');
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
     "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
开发者ID:LanceSandino,项目名称:Stikked,代码行数:31,代码来源:aliased.php

示例3: execAction

    function execAction($dir, $item)
    {
        // show file contents
        global $action;
        if (@eregi($GLOBALS["images_ext"], $item)) {
            $html = '<img src="' . make_link('get_image', $dir, rawurlencode($item)) . '" alt="' . $GLOBALS["messages"]["actview"] . ": " . $item . '" /><br /><br />';
        } elseif (@eregi($GLOBALS["editable_ext"], $item)) {
            $geshiFile = _EXT_PATH . '/libraries/geshi/geshi.php';
            ext_RaiseMemoryLimit('32M');
            // GeSHi 1.0.7 is very memory-intensive
            include_once $geshiFile;
            // Create the GeSHi object that renders our source beautiful
            $geshi = new GeSHi('', '', dirname($geshiFile) . '/geshi');
            $file = get_abs_item($dir, $item);
            $pathinfo = pathinfo($file);
            if (ext_isFTPMode()) {
                $file = ext_ftp_make_local_copy($file);
            }
            if (is_callable(array($geshi, 'load_from_file'))) {
                $geshi->load_from_file($file);
            } else {
                $geshi->set_source(file_get_contents($file));
            }
            if (is_callable(array($geshi, 'get_language_name_from_extension'))) {
                $lang = $geshi->get_language_name_from_extension($pathinfo['extension']);
            } else {
                $pathinfo = pathinfo($item);
                $lang = $pathinfo['extension'];
            }
            $geshi->set_language($lang);
            $geshi->enable_line_numbers(GESHI_NORMAL_LINE_NUMBERS);
            $langs = $GLOBALS["language"];
            if ($langs == "japanese") {
                $enc_list = array("ASCII", "ISO-2022-JP", "UTF-8", "EUCJP-WIN", "SJIS-WIN");
                $_e0 = strtoupper(mb_detect_encoding($geshi->source, $enc_list, true));
                if ($_e0 == "SJIS-WIN") {
                    $_encoding = "Shift_JIS";
                } elseif ($_e0 == "EUCJP-WIN") {
                    $_e0 = "EUC-JP";
                } elseif ($_e0 == "ASCII") {
                    $_e0 = "UTF-8";
                } else {
                    $_encoding = $_e0;
                }
                $geshi->set_encoding($_encoding);
            }
            $html = $geshi->parse_code();
            if ($langs == "japanese") {
                if (empty($lang) || strtoupper(mb_detect_encoding($html, $enc_list)) != "UTF-8") {
                    $html = mb_convert_encoding($html, "UTF-8", $_e0);
                }
            }
            if (ext_isFTPMode()) {
                unlink($file);
            }
            $html .= '<hr /><div style="line-height:25px;vertical-align:middle;text-align:center;" class="small">Rendering Time: <strong>' . $geshi->get_time() . ' Sec.</strong></div>';
        } else {
            $html = '
			<iframe src="' . make_link('download', $dir, $item, null, null, null, '&action2=view') . '" id="iframe1" width="100%" height="100%" frameborder="0"></iframe>';
        }
        $html = str_replace(array("\r", "\n"), array('\\r', '\\n'), addslashes($html));
        ?>
		{

	"dialogtitle": "<?php 
        echo $GLOBALS['messages']['actview'] . ": " . $item;
        ?>
",
	"height": 500,
	"autoScroll": true,
	"html": "<?php 
        echo $html;
        ?>
"

}
		<?php 
    }
开发者ID:elevenfox,项目名称:VTree,代码行数:78,代码来源:view.php

示例4: GeSHi

print "</td><td>";
print "<h2>" . $toelichting['titel'] . "</h2>";
print "<p>" . $toelichting['toelichting'] . "</p>";
print "</td></tr>";
print "</table>";
// einde buitenste tabel
// hier de verwerkende lus onderin....
print "</div>";
print "<hr>";
print "<table border=\"1\" width=\"100%\" cellpadding=\"25\"><tr><td bgcolor=\"#FFDC87\" >";
include_once '../../geshi.php';
$geshi = new GeSHi($source, $language);
if (isset($_POST['start'])) {
    $lijst = array_keys($_POST);
    $sleutel = $lijst[0];
    $bestand = "geenbestand.php";
    for ($i = 0; $i < $element; $i++) {
        if ($antwoorden[$i]['cnr'] == $sleutel) {
            $bestand = $antwoorden[$i]['sch'];
        }
    }
    unset($_POST);
    $geshi->enable_line_numbers(GESHI_NORMAL_LINE_NUMBERS);
    $geshi->load_from_file("{$bestand}");
    echo "<h2>Sourcecode {$bestand}</h2>";
    echo $geshi->parse_code();
}
print "</td></tr></table>";
print "<div align=\"center\">";
mysql_close($mysql);
include "voet.php";
开发者ID:googlecode-mirror,项目名称:timedanswers,代码行数:31,代码来源:index2.php


注:本文中的GeSHi::load_from_file方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。