function git_commitdiff_plain($projectroot, $project, $hash, $hash_parent) { global $tpl; $cachekey = sha1($project) . "|" . $hash . "|" . $hash_parent; header("Content-type: text/plain; charset=UTF-8"); header("Content-disposition: inline; filename=\"git-" . $hash . ".patch\""); if (!$tpl->is_cached('diff_plaintext.tpl', $cachekey)) { $ret = prep_tmpdir(); if ($ret !== TRUE) { echo $ret; return; } $co = git_read_commit($projectroot . $project, $hash); if (!isset($hash_parent)) { $hash_parent = $co['parent']; } $diffout = git_diff_tree($projectroot . $project, $hash_parent . " " . $hash); $difftree = explode("\n", $diffout); $refs = read_info_ref($projectroot . $project, "tags"); $listout = git_read_revlist($projectroot . $project, "HEAD"); foreach ($listout as $i => $rev) { if (isset($refs[$rev])) { $tagname = $refs[$rev]; } if ($rev == $hash) { break; } } $ad = date_str($co['author_epoch'], $co['author_tz']); $tpl->assign("from", $co['author']); $tpl->assign("date", $ad['rfc2822']); $tpl->assign("subject", $co['title']); if (isset($tagname)) { $tpl->assign("tagname", $tagname); } $tpl->assign("url", script_url() . "?p=" . $project . "&a=commitdiff&h=" . $hash); $tpl->assign("comment", $co['comment']); $diffs = array(); foreach ($difftree as $i => $line) { if (preg_match("/^:([0-7]{6}) ([0-7]{6}) ([0-9a-fA-F]{40}) ([0-9a-fA-F]{40}) (.)\t(.*)\$/", $line, $regs)) { if ($regs[5] == "A") { $diffs[] = git_diff($projectroot . $project, null, "/dev/null", $regs[4], "b/" . $regs[6]); } else { if ($regs[5] == "D") { $diffs[] = git_diff($projectroot . $project, $regs[3], "a/" . $regs[6], null, "/dev/null"); } else { if ($regs[5] == "M") { $diffs[] = git_diff($projectroot . $project, $regs[3], "a/" . $regs[6], $regs[4], "b/" . $regs[6]); } } } } } $tpl->assign("diffs", $diffs); } $tpl->display('diff_plaintext.tpl', $cachekey); }
function git_commitdiff_plain($projectroot, $project, $hash, $hash_parent) { global $tpl; $cachekey = sha1($project) . "|" . $hash . "|" . $hash_parent; header("Content-type: text/plain; charset=UTF-8"); header("Content-disposition: inline; filename=\"git-" . $hash . ".patch\""); $git = new Git($projectroot . $project); $hash = sha1_bin($hash); if (isset($hash_parent)) { $hash_parent = sha1_bin($hash_parent); } if (!$tpl->is_cached('diff_plaintext.tpl', $cachekey)) { $co = git_read_commit($git, $hash); if (!isset($hash_parent) && isset($co['parent'])) { $hash_parent = sha1_bin($co['parent']); } $a_tree = isset($hash_parent) ? $git->getObject($hash_parent)->getTree() : array(); $b_tree = $git->getObject(sha1_bin($co['tree'])); $difftree = GitTree::diffTree($a_tree, $b_tree); // FIXME: simplified tagname search is not implemented yet /*$refs = read_info_ref($git,"tags"); $listout = git_read_revlist($git, "HEAD"); foreach ($listout as $i => $rev) { if (isset($refs[$rev])) $tagname = $refs[$rev]; if ($rev == $hash) break; }*/ $ad = date_str($co['author_epoch'], $co['author_tz']); $tpl->assign("from", $co['author']); $tpl->assign("date", $ad['rfc2822']); $tpl->assign("subject", $co['title']); if (isset($tagname)) { $tpl->assign("tagname", $tagname); } $tpl->assign("url", script_url() . "?p=" . $project . "&a=commitdiff&h=" . sha1_hex($hash)); $tpl->assign("comment", $co['comment']); $diffs = array(); foreach ($difftree as $file => $diff) { if ($diff->status == GitTree::TREEDIFF_ADDED) { $diffs[] = git_diff($git, null, "/dev/null", $diff->new_obj, "b/" . $file); } else { if ($diff->status == GitTree::TREEDIFF_REMOVED) { $diffs[] = git_diff($git, $diff->old_obj, "a/" . $file, null, "/dev/null"); } else { if ($diff->status == GitTree::TREEDIFF_CHANGED) { $diffs[] = git_diff($git, $diff->old_obj, "a/" . $file, $diff->new_obj, "b/" . $file); } } } } $tpl->assign("diffs", $diffs); } $tpl->display('diff_plaintext.tpl', $cachekey); }
/** * 弹出层 * @author pwstrick */ public function layer() { if ($this->controller->is_post()) { $tree = $this->p('tree_hidden'); $data = array('ids' => $tree, 'names' => array('随机3', '随机二')); $this->ajaxSuccessOutput('获取成功!', $data); } $css_tree = form_css(script_url('libs/ztree/zTreeStyle/zTreeStyle.css')); $other_link = $this->formatMetaLink(array(), array($css_tree)); $this->layerTemplate('树形结构', $other_link); $this->view->display('user/layer'); }
/** * 百度编辑器初始化以及上传 */ public function ueditor() { $action = $this->p('action'); $path = script_url('libs/ueditor/php/config.json'); $CONFIG = json_decode(preg_replace("/\\/\\*[\\s\\S]+?\\*\\//", "", file_get_contents($path)), true); switch ($action) { case 'config': echo json_encode($CONFIG); break; default: $this->_uploadImage('upfile'); break; } //$this->_upload('upfile'); }
function git_rss($projectroot, $project) { global $tpl; header("Content-type: text/xml; charset=UTF-8"); $cachekey = sha1($project); if (!$tpl->is_cached('rss.tpl', $cachekey)) { $head = git_read_head($projectroot . $project); $revlist = git_read_revlist($projectroot . $project, $head, GITPHP_RSS_ITEMS); $tpl->assign("self", script_url()); $commitlines = array(); $revlistcount = count($revlist); for ($i = 0; $i < $revlistcount; ++$i) { $commit = $revlist[$i]; $co = git_read_commit($projectroot . $project, $commit); if ($i >= 20 && time() - $co['committer_epoch'] > 48 * 60 * 60) { break; } $cd = date_str($co['committer_epoch']); $difftree = array(); $parent = ''; if (!empty($co['parent'])) { $parent = $co['parent']; } $diffout = git_diff_tree($projectroot . $project, $parent . " " . $co['id']); $tok = strtok($diffout, "\n"); while ($tok !== false) { if (preg_match("/^:([0-7]{6}) ([0-7]{6}) ([0-9a-fA-F]{40}) ([0-9a-fA-F]{40}) (.)([0-9]{0,3})\t(.*)\$/", $tok, $regs)) { $difftree[] = $regs[7]; } $tok = strtok("\n"); } $commitline = array(); $commitline["cdmday"] = $cd['mday']; $commitline["cdmonth"] = $cd['month']; $commitline["cdhour"] = $cd['hour']; $commitline["cdminute"] = $cd['minute']; $commitline["title"] = $co['title']; $commitline["author"] = $co['author']; $commitline["cdrfc2822"] = $cd['rfc2822']; $commitline["commit"] = $commit; $commitline["comment"] = $co['comment']; $commitline["difftree"] = $difftree; $commitlines[] = $commitline; } $tpl->assign("commitlines", $commitlines); } $tpl->display('rss.tpl', $cachekey); }
function git_rss($projectroot, $project) { global $tpl; header("Content-type: text/xml; charset=UTF-8"); $cachekey = sha1($project); $git = new Git($projectroot . $project); if (!$tpl->is_cached('rss.tpl', $cachekey)) { $head = git_read_head($git); $revlist = git_read_revlist($git, $head, GITPHP_RSS_ITEMS); $tpl->assign("self", script_url()); $commitlines = array(); $revlistcount = count($revlist); for ($i = 0; $i < $revlistcount; ++$i) { $commit = $revlist[$i]; $co = git_read_commit($git, $commit->getName()); if ($i >= 20 && time() - $co['committer_epoch'] > 48 * 60 * 60) { break; } $cd = date_str($co['committer_epoch']); $difftree = array(); $diffout = GitTree::diffTree(isset($commit->parent[0]) ? $commit->parent[0]->getTree() : null, $commit->getTree()); foreach ($diffout as $file => $diff) { $difftree[] = $file; } $commitline = array(); $commitline["cdmday"] = $cd['mday']; $commitline["cdmonth"] = $cd['month']; $commitline["cdhour"] = $cd['hour']; $commitline["cdminute"] = $cd['minute']; $commitline["title"] = $co['title']; $commitline["author"] = $co['author']; $commitline["cdrfc2822"] = $cd['rfc2822']; $commitline["commit"] = $commit; $commitline["comment"] = $co['comment']; $commitline["difftree"] = $difftree; $commitlines[] = $commitline; } $tpl->assign("commitlines", $commitlines); } $tpl->display('rss.tpl', $cachekey); }
function git_opml($projectroot, $projectlist) { global $tpl, $gitphp_conf; $cachekey = sha1(serialize($projectlist)); if (!$tpl->is_cached('opml.tpl', $cachekey)) { header("Content-type: text/xml; charset=UTF-8"); $projlist = git_read_projects($projectroot, $projectlist); $tpl->assign("title", $gitphp_conf['title']); $tpl->assign("self", script_url()); $opmllist = array(); foreach ($projlist as $cat => $plist) { if (is_array($plist)) { foreach ($plist as $i => $proj) { $opmllist[] = $proj; } } else { $opmllist[] = $plist; } } $tpl->assign("opmllist", $opmllist); } $tpl->display('opml.tpl', $cachekey); }
return sprintf("%s://%s%s/", $scheme, $_SERVER["HTTP_HOST"], $_SERVER["SCRIPT_NAME"]); } /////////////////////////////////////////////////////////////////////////// // !! 他のスクリプトからインクルードされている場合はここでこのスクリプトを終了して処理を戻す !! if (__FILE__ != $_SERVER["SCRIPT_FILENAME"]) { return; } /////////////////////////////////////////////////////////////////////////// // リクエストの処理を開始。メソッドとパスから適切な処理に分岐する $method = $_SERVER["REQUEST_METHOD"]; $path = isset($_SERVER["PATH_INFO"]) ? $_SERVER["PATH_INFO"] : "/"; $params = array(); // preg_match_allの結果を受け取るArray if (preg_match_all("/^\\/hello\$/", $path, $params)) { if ($method == "GET") { response_json(array("Hello, わーるど!" . script_url())); exit; } else { if ($method == "POST") { response_json(array("Hello, わーるど!POST!")); exit; } else { throw new HttpErrorStatus("Method Not Allowed", 405); } } } if (preg_match_all("/^\\/hello\\/([0-9]+)\$/", $path, $params) && $method == "POST") { $path_variable1 = (int) $params[1][0]; $path_variable2 = (int) $params[2][0]; response_json(array($path_variable1, $path_variable2)); exit;
<?php if (!defined("IS_INITPHP")) { exit("Access Denied!"); } /* INITPHP Version 1.0 ,Create on 2015-10-07 16:36:04, compiled from D:\htdocs\grape/app/admin/template/layout/layer_footer.htm */ ?> <script src="<?php echo script_url('libs/require/require.js'); ?> " type="text/javascript" data-main="<?php echo script_url('app/' . $script . '/main'); ?> "></script> </body> </html>
public static function enqueue_script($script) { if (!empty($script->deps)) { foreach ($script->deps as $key => $src) { echo "<script id='{$key}' type='text/javascript' src='" . script_url() . $src . "'></script>"; } } echo "\t\n"; if (isset($script->script)) { echo $script->script; } }
/** * 添加时间控件标记 */ function form_my97_script() { return form_script(script_url('libs/My97DatePicker/WdatePicker.js')); }
<!--<script src="http://cdn.oesmith.co.uk/morris-0.4.3.min.js"></script>--> <!--<script src="<?php echo script_url('morris/chart-data-morris.js'); ?> "></script>--> <script src="<?php echo script_url('tablesorter/jquery.tablesorter.js'); ?> "></script> <script src="<?php echo script_url('visualize.js'); ?> "></script> <script src="<?php echo script_url('autoload.js'); ?> "></script> <script type="text/javascript"> var SITE_URL = '<?php echo site_url(); ?> '; </script> </head> <body> <div id="wrapper">
echo css_url('bootstrap-responsive.css'); ?> " type="text/css" rel="stylesheet"/> <link href="<?php echo css_url('matrix-style.css'); ?> " type="text/css" rel="stylesheet"/> <link href="<?php echo css_url('matrix-login.css'); ?> " type="text/css" rel="stylesheet"/> <link href="<?php echo base_url('font-awesome/css/font-awesome.css'); ?> " type="text/css" rel="stylesheet"/> <script type="text/javascript" src="<?php echo script_url('libs/modernizr/modernizr.js'); ?> "></script> <!--[if lte IE 8]> <script src="<?php echo script_url('libs/respond/respond.js'); ?> " type="text/javascript"></script> <![endif]--> <script type="text/javascript" src="<?php echo script_url('config.js'); ?> "></script> </head> <body>
} ?> <?php } ?> <!-- 检测CSS3属性支持的插件,让IE8等浏览器支持HTML5的标签--> <script type="text/javascript" src="<?php echo script_url('libs/modernizr/modernizr.js'); ?> "></script> <script type="text/javascript" src="<?php echo script_url('config.js'); ?> "></script> <script type="text/javascript" src="<?php echo script_url('libs/jquery/jquery.js'); ?> "></script> <?php if (!empty($page_scripts)) { ?> <?php foreach ($page_scripts as $key => $value) { ?> <?php echo $value; ?> <?php } ?> <?php