소스 파일 : /open_src/view_src.php (2021-01-19)     소스 설명 : (소스개방) 소스 파일을 웹페이지로 보기   (Run)
001
002
003
004
005
006
007
008
009
010
011
012
013
014
015
016
017
018
019
020
021
022
023
024
025
026
027
028
029
030
031
032
033
034
035
036
037
038
039
040
041
042
043
044
045
046
047
048
049
050
051
052
053
054
055
056
057
058
059
060
061
062
063
064
065
066
067
068
069
070
071
072
073
074
075
076
077
078
079
080
081
082
083
084
085
086
087
088
089
090
091
092
093
094
095
096
097
098
099
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
<?php // (2022.9.7, 차재복, Cha Jae Bok, cjbword@gmailcom)
//** 소스 파일을 웹페이지로 보기 **
// (호출 : testing.html, ...)

# 세션 스타트 (매 웹페이지 마다 필요)
    session_start();

# 전달 파라미터
    $dir = preg_replace("/[^a-zA-Z0-9_\.]/","",$_GET['dir']); // 해킹 방어 : 영문자(소,대),_,숫자 이외 모든 문자 제거
    $file = preg_replace("/[^a-zA-Z0-9_(,)\.]/","",$_GET['file']); // 해킹 방어 : 영문자(소,대),_,숫자,(,콤마,) 이외 모든 문자 제거
    $find = $_GET['find'];
        if (empty($find)) $find = false;

	if (empty($dir) and empty($file)) {
		$dir = "open_src";
		$file = "view_src.php";
	}

	// 머리글,바닥글 표출 유무
	$bare = $_REQUEST['bare'];


# 함수 include : src_view(), src_desc(), src_lang_keyword()
	include "../open_src/view_src_utils.php";

# db 설정 (db 접속 성공의 결과로써, $dbi 변수가 넘어옴)
	include_once "../base_utils/db_conn.php";

# html 선언부
    echo "<!DOCTYPE html>";
    echo "<html>";

# html head
    if (empty($bare)) {
	    echo "<head>";
		    echo "<meta http-equiv='content-type' content='text/html; charset=utf-8'>";  // 
   			echo "<title>정보통신기술용어해설</title>";

	    	// mobile 확인
		    require_once '../../mobiledetect/Mobile_Detect.php';
   			$detect = new Mobile_Detect;
	    	if ( $detect->isMobile() and !($detect->isTablet()) ) { // 순수 모바일 기기 (not tablet)
		    	echo "<meta name='viewport' content='user-scalable=yes, width=device-width, initial-scale=1.0' />";
   			}

	    echo "</head>";
	}

# html body
    echo "<body>";

# style
    echo "<style type='text/css'>
	    	body, div, pre {
		    	font-size : 13px;
			    line-height: 150%;

   				tab-size: 4;
    			-moz-tab-size: 4;
	    		-o-tab-size: 4;
		    	-webkit-tab-size: 4;
   			}
    		</style>
	    ";

# 소스 설명을 가져오기 위한 db 검색
    $file_desc = src_desc($dir, $file, $dbi);

# 상단 표제부
	echo "<div>";
    if (empty($file_desc)) {
        exit ("해당 파일 ' {$_GET['dir']}/{$_GET['file']} '을 찾을 수 없습니다 !!!");
    } else {
		    echo "소스 파일 : /{$file_desc['dir']}/{$file_desc['filename']}";
			echo " (".substr($file_desc['date'],0,10).") &nbsp;&nbsp;&nbsp; ";
	        echo "소스 설명 : {$file_desc['expr']}";
			if (!empty($file_desc['run'])) {
				echo " &nbsp; (";
				echo "<a href='../{$file_desc['dir']}/{$file_desc['filename']}' style='font-style:italic;font-size:12px;'>Run</a>";
				echo ")";
			}
    }
	echo "<div>";


# 소스 보기 실행
	$file_alias = '../' . $file_desc['dir'] .'/'. $file_desc['filename'] ;
	$line_no = src_view ($file_alias, $find);
		// find 할 경우에, 해당 라인 번호가 리턴 됨

# 소스 내용 중 언어 키워드 포함된 것을 보여줌
	echo src_lang_keyword($file_desc, $dbi);

# 하단 
	echo "<br style='clear:both;'>";
    if (empty($bare)) {
		// 구분선
		echo "<hr style='clear:both;'>";

		// 저작권
		include_once "../base_utils/copyright.php";

		// 구분선
		echo "<hr style='margin-top:0px; border-top:1px gray solid;'>";

		// 소스 개방 메뉴
//		include "../open_src/open.php"; // (소스이력 폴더별소스 ... )

		// 구분선
		echo "<hr>";
	}

# 접속 통계 처리
	include_once "../base_utils/stat_utils.php";
	html_access("view_src", $dbi);

# 자바스크립트 (find할 경우에, 찾은 라인번호로써 스크롤)
	if (!empty($line_no)) {
	    echo "<script type='text/javascript'>
                document.getElementById('l'+'". $line_no ."').scrollIntoView();
		        </script>";
	}
?>


Copyrightⓒ written by 차재복 (Cha Jae Bok)               기술용어해설 후원
"본 웹사이트 내 모든 저작물은 원출처를 밝히는 한 자유롭게 사용(상업화포함) 가능합니다"