/spb3/sinc/lib/class_phemplate.php
sitePHPbasic 디버그 모드 : WARNING
[2] file(http://spb3.staredong.com/spb3_diff_source.php?md5_path=%2Fspb3%2Fsinc%2Flib%2Fclass_phemplate.php): failed to open stream: HTTP request failed! HTTP/1.1 404 Not Found
Line : 89 (file:/wecan/cc/cc.sdong.kr/spb3/sadmin/util/svn/spb3_diff.php)
- 디버그 추적(debug_backtrace)
#0 spb_error_handler() 함수사용, line(),
#1 file() 함수사용, line(89), /wecan/cc/cc.sdong.kr/spb3/sadmin/util/svn/spb3_diff.php




사용변수들 ...
$_GET = Array ( [md5_path] => /spb3/sinc/lib/class_phemplate.php ) $_POST = Array ( ) $_COOKIE = Array ( ) Array ( [errno] => 2 [errstr] => file(http://spb3.staredong.com/spb3_diff_source.php?md5_path=%2Fspb3%2Fsinc%2Flib%2Fclass_phemplate.php): failed to open stream: HTTP request failed! HTTP/1.1 404 Not Found [errfile] => /wecan/cc/cc.sdong.kr/spb3/sadmin/util/svn/spb3_diff.php [errline] => 89 [arr] => Array ( [0] => Array ( [function] => spb_error_handler [args] => Array ( [0] => 2 [1] => file(http://spb3.staredong.com/spb3_diff_source.php?md5_path=%2Fspb3%2Fsinc%2Flib%2Fclass_phemplate.php): failed to open stream: HTTP request failed! HTTP/1.1 404 Not Found [2] => /wecan/cc/cc.sdong.kr/spb3/sadmin/util/svn/spb3_diff.php [3] => 89 [4] => Array ( [_GET] => Array ( [md5_path] => /spb3/sinc/lib/class_phemplate.php ) [_POST] => Array ( ) [_COOKIE] => Array ( ) [_FILES] => Array ( ) [_SERVER] => Array ( [HTTP_USER_AGENT] => CCBot/2.0 (https://commoncrawl.org/faq/) [HTTP_ACCEPT] => text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8 [HTTP_ACCEPT_LANGUAGE] => en-US,en;q=0.5 [HTTP_ACCEPT_ENCODING] => br,gzip [HTTP_HOST] => kamprs.or.kr [HTTP_CONNECTION] => Keep-Alive [PATH] => /sbin:/usr/sbin:/bin:/usr/bin [SERVER_SIGNATURE] =>
Apache/2.2.3 (CentOS) Server at kamprs.or.kr Port 80
[SERVER_SOFTWARE] => Apache/2.2.3 (CentOS) [SERVER_NAME] => kamprs.or.kr [SERVER_ADDR] => 61.14.208.190 [SERVER_PORT] => 80 [REMOTE_ADDR] => 18.204.2.231 [DOCUMENT_ROOT] => /wecan/cc/cc.sdong.kr [SERVER_ADMIN] => root@localhost [SCRIPT_FILENAME] => /wecan/cc/cc.sdong.kr/spb3/sadmin/util/svn/spb3_diff.php [REMOTE_PORT] => 48224 [GATEWAY_INTERFACE] => CGI/1.1 [SERVER_PROTOCOL] => HTTP/1.1 [REQUEST_METHOD] => GET [QUERY_STRING] => md5_path=%2Fspb3%2Fsinc%2Flib%2Fclass_phemplate.php [REQUEST_URI] => /spb3/sadmin/util/svn/spb3_diff.php?md5_path=%2Fspb3%2Fsinc%2Flib%2Fclass_phemplate.php [SCRIPT_NAME] => /spb3/sadmin/util/svn/spb3_diff.php [PHP_SELF] => /spb3/sadmin/util/svn/spb3_diff.php [REQUEST_TIME_FLOAT] => 1634528076.223 [REQUEST_TIME] => 1634528076 ) [GLOBALS] => Array *RECURSION* [SITE] => Array ( [database] => [th] => spb3_ [uh] => /spb3/ [home] => /spb3/ [name] => sitePHPbasic [company] => 뉴21커뮤니티(주) [webmaster] => spb@sdong.kr [hp] => 16449501 [version] => 3.2.0 [debug] => 2 [home_path] => /wecan/cc/cc.sdong.kr/ [spb3_path] => /wecan/cc/cc.sdong.kr/spb3/ [html_path] => /wecan/cc/cc.sdong.kr/spb3/sinc/skin/ [lib_path] => /wecan/cc/cc.sdong.kr/spb3/sinc/lib/ ) [_SESSION] => Array ( ) [spb_error_checktime_time] => class_spb_checktime Object ( [vars] => Array ( ) ) [thisPath] => /wecan/cc/cc.sdong.kr/spb3/sadmin/util/svn/ [file_source] => /wecan/cc/cc.sdong.kr/spb3/sinc/lib/class_phemplate.php [http_response_header] => Array ( [0] => HTTP/1.1 404 Not Found [1] => Date: Mon, 18 Oct 2021 03:34:36 GMT [2] => Server: Apache/2.2.3 (CentOS) [3] => Content-Length: 301 [4] => Connection: close [5] => Content-Type: text/html; charset=iso-8859-1 ) ) ) ) [1] => Array ( [file] => /wecan/cc/cc.sdong.kr/spb3/sadmin/util/svn/spb3_diff.php [line] => 89 [function] => file [args] => Array ( [0] => http://spb3.staredong.com/spb3_diff_source.php?md5_path=%2Fspb3%2Fsinc%2Flib%2Fclass_phemplate.php ) ) ) [key] => 1 [value] => Array ( [file] => /wecan/cc/cc.sdong.kr/spb3/sadmin/util/svn/spb3_diff.php [line] => 89 [function] => file [args] => Array ( [0] => http://spb3.staredong.com/spb3_diff_source.php?md5_path=%2Fspb3%2Fsinc%2Flib%2Fclass_phemplate.php ) ) )
sitePHPbasic 디버그 모드 : WARNING
[2] file(): Filename cannot be empty
Line : 119 (file:/wecan/cc/cc.sdong.kr/spb3/sadmin/util/svn/spb3_diff.php)
- 디버그 추적(debug_backtrace)
#0 spb_error_handler() 함수사용, line(),
#1 file() 함수사용, line(119), /wecan/cc/cc.sdong.kr/spb3/sadmin/util/svn/spb3_diff.php
#2 doDiff() 함수사용, line(142), /wecan/cc/cc.sdong.kr/spb3/sadmin/util/svn/spb3_diff.php
#3 diffWrap() 함수사용, line(197), /wecan/cc/cc.sdong.kr/spb3/sadmin/util/svn/spb3_diff.php
#4 inline() 함수사용, line(92), /wecan/cc/cc.sdong.kr/spb3/sadmin/util/svn/spb3_diff.php




사용변수들 ...
$_GET = Array ( [md5_path] => /spb3/sinc/lib/class_phemplate.php ) $_POST = Array ( ) $_COOKIE = Array ( ) Array ( [errno] => 2 [errstr] => file(): Filename cannot be empty [errfile] => /wecan/cc/cc.sdong.kr/spb3/sadmin/util/svn/spb3_diff.php [errline] => 119 [arr] => Array ( [0] => Array ( [function] => spb_error_handler [args] => Array ( [0] => 2 [1] => file(): Filename cannot be empty [2] => /wecan/cc/cc.sdong.kr/spb3/sadmin/util/svn/spb3_diff.php [3] => 119 [4] => Array ( [old] => Array ( [0] => // $Id: class_phemplate.php 13 2010-08-24 08:28:50Z sitehis $ [2] => // 04/05/17 박선민 340L get_var() chanage to same get_var_silent() [3] => // 04/05/17 박선민 696L optional() add and change etc.. [4] => // 05/01/25 박선민 828L drop_var() add recursion for array branches [5] => // 05/11/20 박선민 echoHtml()로 반복하는 sitePHPbasic 마무리 부분 함수로 [6] => // 07/03/18 박선민 {!e.abc} 인경우 urlencoding 등의 기능 추가 [7] => // 07/08/14 박선민 {#widget.???} 윗젯 include 기능 추가 [8] => // 07/09/16 박선민 {#content.keyword} spb3_content 테이블의 keyword에 대한 content가져와서 넣는 기능 추가 [9] => // 08/06/14 박선민 $_GET[html_return] 기능 추가 [10] => // 08/06/28 박선민 831L optional() change 값이 'N'이여도 false되게 [11] => // 08/07/13 박선민 716L // cut_string {#cut.50#0#….key} 기능 추가 [12] => // 08/07/29 박선민 546L // parse() ... IF문 기능 추가 [13] => // 08/10/06 박선민 {#sub.2.3.???} 기능 추가 [14] => // 08/11/08 박선민 #content.??? 기능 개선 [15] => // 08/11/29 박선민 bugfix - don't use &$this [16] => // 09/01/04 박선민 {#widget2.???} 윗젯2 기능 추가(php파일위치에 widget2_???.php를 읽어서 함수 실행 [17] => // 09/02/04 박선민 {!N.list.number} 기능 추가 [18] => // 09/02/06 박선민 GET_DEBUG_2 기능 추가 [19] => // 09/02/25 박선민 {#exp.0.-.key}, server.server.HTTP_REFERER 추가 [20] => // 09/03/11 박선민 {!A.str} javascript에서 변수넘길때 큰따옴표 오류 해결용 [21] => // 09/05/08 박선민 bugfix - GET_DEBUG_2 false였을 때 오류 [22] => // 09/05/31 박선민 {!B.str} table, excel등에서 빈값은  로 변환하여 리턴하도록 [23] => // 09/05/31 박선민 {!?.str} 링크에 ?가 없으면 ?를 붙여주도록 [24] => // 09/07/28 박선민 {!X.name} : xmlspecialchars 변환 기능 추가 [25] => //---------------------------------------------------------------------------// [26] => // author: pukomuko [27] => // date: 2001.03.15 [28] => // web: http://pukomuko.esu.lt [29] => // http://sourceforge.net/projects/phemplate [30] => // info: template engine [31] => //---------------------------------------------------------------------------// [32] => // copyleft license [33] => // [34] => // this software is provided 'as-is', without any express or implied [35] => // warranty. in no event will the authors be held liable for any damages [36] => // arising from the use of this software. [37] => // [38] => // permission is granted to anyone to use this software for any purpose, [39] => // including commercial applications, and to alter it and redistribute it [40] => // freely, subject to the following restrictions: [41] => // [42] => // 1. the origin of this software must not be misrepresented; [43] => // you must not claim that you wrote the original software. [44] => // if you use this software in a product, an acknowledgment [45] => // in the product documentation would be appreciated but is not required. [46] => // [47] => // 2. altered source versions must be plainly marked as such, [48] => // and must not be misrepresented as being the original software. [49] => // [50] => // 3. mail about the fact of using this class in production [51] => // would be very appreciated. [52] => // [53] => // 4. this notice may not be removed or altered from any source distribution. [54] => // [55] => //---------------------------------------------------------------------------// [56] => // changes: [57] => // [58] => // 2004.04.21 [59] => // - warining on empty file [60] => // * v1.10.1 [61] => [62] => /** [63] => */ [64] => define('TPL_LOOP', 1); [65] => define('TPL_NOLOOP', 2); [66] => define('TPL_INCLUDE', 4); [67] => define('TPL_APPEND', 8); [68] => define('TPL_FINISH', 16); [69] => define('TPL_OPTIONAL', 32); [70] => define('TPL_LOOP_INNER_PARSED',64); [71] => define('TPL_LOOP_INNER_OPTIONAL', 128); [72] => [73] => define('TPL_PARSEDLOOP', TPL_LOOP | TPL_LOOP_INNER_PARSED); [74] => define('TPL_OPTLOOP', TPL_PARSEDLOOP | TPL_LOOP_INNER_OPTIONAL); [75] => [76] => [77] => define('TPL_BLOCK', 1); [78] => define('TPL_BLOCKREC', 2); [79] => define('TPL_STRIP_UTF_HEADER', 4); [80] => [81] => class phemplate [82] => { [83] => /** [84] => * 현재 클래스가 있는 드렉토리 By Sunmin [85] => */ [86] => var $widgetPath =''; [87] => [88] => var $read_files = array(); [89] => [90] => /** [91] => * spb3_content에서 읽어온 것을 캐쉬 [92] => */ [93] => var $spb3_content = array(); [94] => [95] => [96] => /** [97] => * variables and blocks [98] => */ [99] => var $vars = array(); [100] => [101] => /** [102] => * loops container [103] => */ [104] => var $loops = array(); [105] => [106] => /** [107] => * dir of template files [108] => */ [109] => var $root = ''; [110] => [111] => /** [112] => * what to do with unknown variables in template? [113] => */ [114] => var $unknowns = 'keep'; [115] => [116] => /** [117] => * default parameters for process() loop, append, finish [118] => */ [119] => var $parameters = 0; [120] => [121] => [122] => /** [123] => * object having method report($level, $msg) [124] => * you can catch error messages from template. [125] => */ [126] => var $error_handler = null; [127] => [128] => [129] => [130] => /** [131] => * start tag for block [132] => */ [133] => var $block_start_string = ''; [134] => [135] => /** [136] => * end tag for block [137] => */ [138] => var $block_end_string = ''; [139] => [140] => /** [141] => * constructor [142] => * $unknows를 keep에서 remove_nonjs로 변경함 by Sunmin Park [143] => */ [144] => function phemplate( $root_dir = '', $unknowns = 'remove_nonjs', $params = 0) [145] => { [146] => // widget, widget2 path [147] => $this->widgetPath = dirname(dirname(__FILE__)).'/widget/'; // By Sunmin [148] => if($this->set_root($root_dir)) [149] => $this->widget2Path = dirname(dirname($this->root)).'/'; // By Sunmin [150] => $this->set_unknowns($unknowns); [151] => $this->set_params($params); [152] => [153] => [154] => [155] => // 기본 set_var by Sunmin [156] => $this->tie_var('SITE' ,$GLOBALS['SITE']); // $SITE 전역변수 [157] => $this->tie_var('get' ,$_GET); [158] => $this->set_var('braces' ,'{'); // 중괄호{braces} 표현 [159] => $this->set_var('nowtime',time()); [160] => [161] => $this->tie_var('session.seUid' ,$_SESSION['seUid']); // 로그인 uid [162] => $this->tie_var('session.seUserid' ,$_SESSION['seUserid']); // 로그인 userid [163] => $this->tie_var('session.seName' ,$_SESSION['seName']); // 로그인 이름 [164] => $this->tie_var('session.seNickname' ,$_SESSION['seNickname']); // 로그인 별명 [165] => $this->tie_var('session.seEmail' ,$_SESSION['seEmail']); [166] => $this->tie_var('session.sePoint' ,$_SESSION['sePoint']); [167] => $this->tie_var('session.seCoupon' ,$_SESSION['seCoupon']); [168] => $this->tie_var('session.sePriv' ,$_SESSION['sePriv']); [169] => [170] => $this->set_var('server.HTTP_HOST' ,$_SERVER['HTTP_HOST']); [171] => $this->set_var('server.HTTP_REFERER',$_SERVER['HTTP_REFERER']); [172] => $this->set_var('server.QUERY_STRING' ,$_SERVER['QUERY_STRING']); [173] => $this->set_var('server.REQUEST_URI' ,$_SERVER['REQUEST_URI']); [174] => $this->set_var('server.PHP_SELF' ,$_SERVER['PHP_SELF']); [175] => } [176] => [177] => /** [178] => substitute text and returns parsed string [179] => @author ZaZa (Sergej Kurakin) 2003.05.05 21:52 [180] => */ [181] => function parse($string) [182] => { [183] => $str = explode('{', $string); [184] => [185] => $res = ''; [186] => [187] => for ($i = 0; isset($str[$i]); $i++) [188] => { [189] => $line = explode('}', $str[$i]); [190] => if ($i === 0) [191] => { [192] => $res .= $line[0]; [193] => } [194] => else [195] => { [196] => $key = $line[0]; [197] => unset($line[0]); [198] => [199] => if ( $key && isset($this->vars[$key]) ) [200] => { [201] => $res .= $this->vars[$key].implode('}', $line); [202] => } [203] => else [204] => { [205] => // {!d.list.rdate} 등 By Sunmin [206] => if($key[0]=='!') { // and isset($this->vars[substr($key,3)])) { [207] => switch(substr($key,1,2)) { [208] => /** [209] => ** 대소문자 구분함 [210] => {!B.name} : 값이 없으면   [211] => {!b.name} : 문장에서 엔터를
로 변환함 [212] => {!S.name} : 문장에서 html 테그를 모두 제거하고, 엔터는
로 변환함 [213] => [214] => {!a.name} : '\' addslashes 삽입 [215] => {!A.name} : javascript에서 변수넘길때 funcname('{!A.str}') [216] => {!s.name} : addslashes된 것을 stripcslashes함 [217] => {!?.name} : 문자열 중간 혹은 끝에 ?가 없으면 맨뒤에 ?를 붙여줌 [218] => [219] => {!h.name} : HTML특수문자로 변환( 큰따옴표도 변환 ) [220] => {!H.name} : HTML특수문자로 변환( 큰따옴표는 그대로 나둠) [221] => {!x.name} : stripcslashes함 하고 HTML특수문자로 변환( 큰따옴표도 변환) [222] => {!X.name} : xmlspecialchars 변환 [223] => [224] => {!e.url} : URL ENCODE [225] => [226] => {!n.price} : 숫자에 콤마 추가(단, 값이 없으면 무조건 '0' 리턴) [227] => {!N.price} : 숫자에 콤마 추가(단, ''값이면 빈값으로 리턴 [228] => [229] => {!D.rdate} : 숫자날짜를 YYYY-MM-DD로 변환 (연도가 4자리) [230] => {!d.rdate} : 숫자날짜를 YY-MM-DD로 변환 (연도가 2자리) [231] => {!T.rdate} : 숫자날짜를 YY-MM-DD H:i:s로 변환 (ex, 2009-01-01 23:59:55) [232] => {!t.rdate} : 숫자날짜를 시간인 H:i:s로 변환 (ex, 23:59:55) [233] => {!g.rdate} : 숫자날짜를 국제표준 한국시간으로 'D, j M Y G:i:s +0900' [234] => **/ [235] => case 'B.': [236] => if(empty($this->vars[substr($key,3)]) and $this->vars[substr($key,3)]!="0") [237] => $res .= ' '.implode('}', $line); [238] => else $res .= $this->vars[substr($key,3)].implode('}', $line); [239] => continue 2; [240] => break; [241] => case 'b.': [242] => $res .= nl2br($this->vars[substr($key,3)]).implode('}', $line); [243] => continue 2; [244] => break; [245] => case 'S.': // strip_tags(),
tag취환 [246] => $res .= ereg_replace("(\r\n|\n|\r)", '
',strip_tags($this->vars[substr($key,3)])).implode('}', $line); [247] => continue 2; [248] => break; [249] => case 'a.': [250] => $res .= addslashes($this->vars[substr($key,3)]).implode('}', $line); [251] => continue 2; [252] => break; [253] => case 'A.': [254] => $res .= str_replace('\\"','"',addslashes($this->vars[substr($key,3)])).implode('}', $line); [255] => continue 2; [256] => break; [257] => case 's.': [258] => $res .= stripcslashes($this->vars[substr($key,3)]).implode('}', $line); [259] => continue 2; [260] => break; [261] => case '?.': [262] => if(false===strpos($this->vars[substr($key,3)],'?')) [263] => $res .= $this->vars[substr($key,3)].'?'.implode('}', $line); [264] => else [265] => $res .= $this->vars[substr($key,3)].implode('}', $line); [266] => continue 2; [267] => break; [268] => case 'h.': [269] => $res .= htmlspecialchars($this->vars[substr($key,3)],ENT_QUOTES).implode('}', $line); [270] => continue 2; [271] => break; [272] => case 'H.': [273] => $res .= htmlspecialchars($this->vars[substr($key,3)],ENT_NOQUOTES).implode('}', $line); [274] => continue 2; [275] => break; [276] => case 'x.': [277] => $res .= htmlspecialchars(stripcslashes($this->vars[substr($key,3)]),ENT_QUOTES).implode('}', $line); [278] => continue 2; [279] => break; [280] => case 'X.': [281] => $res .= str_replace(''', ''', htmlspecialchars($this->vars[substr($key,3)], ENT_QUOTES)).implode('}', $line); [282] => continue 2; [283] => break; [284] => case 'e.': [285] => $res .= urlencode($this->vars[substr($key,3)]).implode('}', $line); [286] => continue 2; [287] => break; [288] => case 'n.': [289] => $res .= number_format((int)$this->vars[substr($key,3)]).implode('}', $line); [290] => continue 2; [291] => break; [292] => case 'N.': [293] => if($this->vars[substr($key,3)] or $this->vars[substr($key,3)]==='0' or $this->vars[substr($key,3)]===0) [294] => $res .= number_format($this->vars[substr($key,3)]).implode('}', $line); [295] => else $res .= implode('}', $line); [296] => continue 2; [297] => break; [298] => case 'D.': [299] => if($this->vars[substr($key,3)]) [300] => $res .= date('Y-m-d',$this->vars[substr($key,3)]).implode('}', $line); [301] => else $res .= implode('}', $line); [302] => continue 2; [303] => break; [304] => case 'd.': [305] => if($this->vars[substr($key,3)]) [306] => $res .= date('y-m-d',$this->vars[substr($key,3)]).implode('}', $line); [307] => else $res .= implode('}', $line); [308] => continue 2; [309] => break; [310] => case 'T.': [311] => if($this->vars[substr($key,3)]) [312] => $res .= date('y-m-d H:i:s',$this->vars[substr($key,3)]).implode('}', $line); [313] => else $res .= implode('}', $line); [314] => continue 2; [315] => break; [316] => case 't.': [317] => if($this->vars[substr($key,3)]) [318] => $res .= date('H:i:s',$this->vars[substr($key,3)]).implode('}', $line); [319] => else $res .= implode('}', $line); [320] => continue 2; [321] => break; [322] => case 'g.': [323] => if($this->vars[substr($key,3)]) [324] => $res .= date('D, j M Y G:i:s +0900',$this->vars[substr($key,3)]).implode('}', $line); [325] => else $res .= implode('}', $line); [326] => continue 2; [327] => break; [328] => } [329] => } [330] => [331] => if($key[0]=='#') { [332] => // /spb3/sinc/widget/???.php By Sunmin [333] => if('widget.'==substr($key,1,7)) { [334] => $tmpWidget2 = substr($key,8); [335] => list($tmpWidget,$tmpKey) = explode('.',$tmpWidget2,2); [336] => if(eregi('^[-_a-z0-9]+$',$tmpWidget) and is_file($this->widgetPath . $tmpWidget . '/index.php')) { [337] => @include_once($this->widgetPath .$tmpWidget . '/index.php'); [338] => $func = 'widget_'.$tmpWidget; [339] => $res .= @$func($this,$tmpKey) . implode('}', $line); [340] => continue; [341] => } [342] => } [343] => elseif('widget2.'==substr($key,1,8)) { [344] => $tmpWidget2 = substr($key,9); [345] => list($tmpWidget,$tmpKey) = explode('.',$tmpWidget2,2); [346] => if(eregi('^[-_a-z0-9]+$',$tmpWidget) and is_file($this->widget2Path . 'widget2_'.$tmpWidget . '.php')) { [347] => @include_once($this->widget2Path . 'widget2_'.$tmpWidget . '.php'); [348] => $func = 'widget2_'.$tmpWidget; [349] => $res .= @$func($this,$tmpKey) . implode('}', $line); [350] => continue; [351] => } [352] => }elseif('include.'==substr($key,1,8)) { [353] => $tmpFilename = substr($key,9); [354] => if(is_file($this->root.'/include_'.$tmpFilename.'.html')) { [355] => $res .= @file_get_contents($this->root.'include_'.$tmpFilename.'.html') . implode('}', $line); [356] => } [357] => else $res .= implode('}', $line); [358] => continue; [359] => } [360] => // spb3_content읽어서 keyword에서 content 전송 [361] => elseif('content.'==substr($key,1,8)) { [362] => list($tmp,$tmpKeyword,$tmpContent) = explode('.',$key,3); [363] => if(!$tmpContent) $tmpContent = 'content'; [364] => if(!isset($this->spb3_content[$tmpContent])) { [365] => $this->spb3_content[$tmpContent] = db_resultdata($GLOBALS['SITE']['th'].'cate_content',$tmpContent,'keyword',$tmpKeyword); [366] => } [367] => $res .= $this->spb3_content[$tmpContent] . implode('}', $line); [368] => continue; [369] => } [370] => // cut_string {#cut.50#0#….key} [371] => elseif('cut.'==substr($key,1,4)) { [372] => list($tmp,$tmpCut,$tmpKey) = explode('.',$key,3); [373] => list($tmpCut1,$tmpCut2,$tmpCut3) = explode('#',$tmpCut,3); [374] => if($tmpCut1===NULL) $tmpCut1 = 50; [375] => if($tmpCut2===NULL) $tmpCut2 = 0; [376] => if($tmpCut3===NULL) $tmpCut3 = '…'; [377] => $res .= cut_string($this->vars[$tmpKey],$tmpCut1,$tmpCut2,$tmpCut3).implode('}', $line); [378] => continue; [379] => } [380] => // substr {#sub.2.3.key} [381] => elseif('sub.'==substr($key,1,4)) { [382] => list($tmp,$tmpSub1,$tmpSub2,$tmpKey) = explode('.',$key,4); [383] => $res .= substr($this->vars[$tmpKey],(int)$tmpSub1,(int)$tmpSub2).implode('}', $line); [384] => continue; [385] => } [386] => // explode(split) {#exp.0.-.key} 0번째, -으로 나누어서 [387] => elseif('exp.'==substr($key,1,4)) { [388] => $tmp = explode('.',$key,4); [389] => if(4==count($tmp)) { [390] => $tmp2 = explode($tmp[2],$this->vars[$tmp[3]]); [391] => $res .= $tmp2[$tmp[1]].implode('}', $line); [392] => } [393] => else $res .= implode('}', $line); [394] => continue; [395] => } [396] => } [397] => [398] => switch ($this->unknowns) [399] => { [400] => case "keep": [401] => $res .= '{'.$key; [402] => if (count ($line) > 0) [403] => { [404] => $res .= '}'; [405] => $res .= implode('}', $line); [406] => } [407] => break; [408] => [409] => case "remove": [410] => $res .= implode('', $line); [411] => break; [412] => [413] => case "remove_nonjs": [414] => if (!empty($key) && ((false === strpos($key, ' ')) && (false === strpos($key, "\n")) && (false === strpos($key, "\t")))) [415] => { [416] => $res .= implode('}', $line); [417] => } [418] => else [419] => { [420] => $res .= '{'.$key; [421] => if (count ($line) > 0) [422] => { [423] => $res .= '}'; [424] => $res .= implode('}', $line); [425] => } [426] => } [427] => break; [428] => [429] => case "comment": [430] => $res .= ''.implode('', $line); [431] => break; [432] => [433] => case "space": [434] => $res .= ' '.implode('', $line); [435] => break; [436] => [437] => } [438] => } [439] => } [440] => } [441] => [442] => return $res; [443] => } [444] => [445] => /** [446] => * check and set template root dir [447] => */ [448] => function set_root($root) [449] => { [450] => if (empty($root)) return; [451] => if (!is_dir($root)) [452] => { [453] => $this->error("phemplate::set_root(): 다음 드렉토리가 없습니다 : $root", 'warning'); [454] => return false; [455] => } [456] => [457] => $this->root = realpath($root).'/'; // By Sunmin 05/11/13 [458] => return true; [459] => } [460] => [461] => /** [462] => * what to do with unknown variables in template? [463] => * keep [464] => * remove [465] => * remove_nonjs [466] => * comment [467] => * space [468] => */ [469] => function set_unknowns($unk) [470] => { [471] => $this->unknowns = $unk; [472] => } [473] => [474] => /** [475] => * set default parameters for process() [476] => */ [477] => function set_params($params) [478] => { [479] => $this->parameters = $params; [480] => } [481] => [482] => /** [483] => * read file template into $vars [484] => * @param string $handle - name of handle for file contents [485] => * @param int $blocks - 1 for search, 2 for nested blocks [486] => * [487] => */ [488] => function set_file($handle, $filename = "", $blocks = false) [489] => { [490] => if ($filename == "") [491] => { [492] => $this->error("phemplate::set_file(): 파일이름이 빈값으로 넘어왔습니다 -$handle", 'fatal'); [493] => return false; [494] => } [495] => $this->vars[$handle] = $this->read_file($filename); [496] => if ($blocks & TPL_STRIP_UTF_HEADER) [497] => { [498] => $header = substr($this->vars[$handle], 0, 3); [499] => if ("\xEF\xBB\xBF" == $header) $this->vars[$handle] = substr($this->vars[$handle], 3); [500] => } [501] => if ($blocks) { $this->extract_blocks($handle, $blocks & TPL_BLOCKREC); } [502] => return true; [503] => [504] => } [505] => [506] => [507] => /** [508] => * set handle and value, [509] => * if value is array, all elements will be named: handle.key.subkey [510] => */ [511] => function set_var($var_name, $var_value) [512] => { [513] => if (is_array($var_value)) [514] => { [515] => foreach($var_value as $key=>$value) [516] => { [517] => $this->set_var($var_name . '.' . $key, $value); // recursion for array branches [518] => } [519] => } [520] => else // normal variable [521] => { [522] => $this->vars[$var_name] = $var_value; [523] => } [524] => } [525] => [526] => /** [527] => * tie value with variable [528] => * it's not possible to update array keys, just values [529] => */ [530] => function tie_var($var_name, &$var_value) [531] => { [532] => if (is_array($var_value)) [533] => { [534] => $list = array_keys($var_value); [535] => foreach($list as $key) [536] => { [537] => $this->tie_var($var_name . '.' . $key, $var_value[$key]); // recursion for array branches [538] => } [539] => } [540] => else // normal variable [541] => { [542] => $this->vars[$var_name] =& $var_value; [543] => } [544] => } [545] => [546] => /** [547] => * value of $handle [548] => * raises error if $handle undefined [549] => */ [550] => function get_var($handle) [551] => { [552] => if (!isset($this->vars[$handle])) { [553] => //$this->error("phemplate(): no such handle '$handle'", 'warning'); [554] => return null; // By Sunmin Park 04/05/17 [555] => } [556] => return $this->vars[$handle]; [557] => } [558] => [559] => /** [560] => * value of $handle, no error if no handle [561] => */ [562] => function get_var_silent($handle) [563] => { [564] => if (!isset($this->vars[$handle])) { $this->vars[$handle] = ''; return ''; } [565] => return $this->vars[$handle]; [566] => } [567] => [568] => /** [569] => * assign array to loop handle [570] => * @param string $loop_name - name for a loop [571] => * @param int $loop - loop data [572] => */ [573] => function set_loop($loop_name, $loop) [574] => { [575] => if (!$loop) $loop = 0; [576] => $this->loops[$loop_name] = $loop; [577] => } [578] => [579] => /** [580] => * tie array with loop [581] => */ [582] => function tie_loop($loop_name, &$loop) [583] => { [584] => if (!$loop) $loop = 0; [585] => $this->loops[$loop_name] =& $loop; [586] => } [587] => [588] => /** [589] => * extracts blocks from handle, and returns cleaned up version [590] => * [591] => * must be quite fast, because every found block is imediately taken out of string [592] => * [593] => * [594] => * @since 2001.10.31 works with nested blocks [js] [595] => * @since 2003.06.19 supports customized block syntax [js] [596] => * [597] => */ [598] => function extract_blocks($bl_handle, $recurse = false) [599] => { [600] => [601] => $str = $this->get_var($bl_handle); [602] => if (!$str) return $str; [603] => $bl_start = 0; [604] => [605] => list($bll, $blr) = explode('|', $this->block_start_string); [606] => $strlen = strlen($bll); [607] => [608] => [609] => // find them and clean from parent handle [610] => while(is_long($bl_start = strpos($str, $bll, $bl_start))) [611] => { [612] => $pos = $bl_start + $strlen; [613] => [614] => $endpos = strpos($str, $blr, $pos); [615] => $handle = substr($str, $pos, $endpos-$pos); [616] => [617] => $tag = $bll.$handle.$blr; [618] => $endtag = str_replace('|', $handle, $this->block_end_string); [619] => [620] => $start_pos = $bl_start + strlen($tag); [621] => $end_pos = strpos($str, $endtag, $bl_start); [622] => if (!$end_pos) { $this->error("스킨오류 : </block name=\"$handle\">이 없음", 'fatal'); } [623] => $bl_end = $end_pos + strlen($endtag); [624] => [625] => $block_code = substr($str, $start_pos, $end_pos-$start_pos); [626] => [627] => $this->set_var($handle, $block_code); [628] => [629] => $part1 = substr($str, 0, $bl_start); [630] => $part2 = substr($str, $bl_end, strlen($str)); [631] => [632] => $str = $part1 . $part2; [633] => [634] => if ($recurse) { $this->extract_blocks($handle, 1); } [635] => [636] => } [637] => [638] => $this->set_var($bl_handle, $str); [639] => [640] => } [641] => [642] => [643] => /** [644] => * search for tags in $handle [645] => * be carefull with paths [646] => */ [647] => function include_files($handle) [648] => { [649] => $str = $this->get_var($handle); [650] => [651] => while(is_long($pos = strpos($str, '', $pos); [655] => $filename = substr($str, $pos, $endpos-$pos); [656] => $tag = ''; [657] => [658] => [659] => $include = $this->read_file($filename); [660] => [661] => $str = str_replace($tag, $include, $str); [662] => } [663] => [664] => return $str; [665] => } [666] => [667] => [668] => /** [669] => * searches for all set loops in $handle, returns text of $handle with parsed loops [670] => * @param bool $noloop - must be true, if you want noloop statement [671] => * @return string [672] => */ [673] => function parse_loops($handle, $noloop = false) [674] => { [675] => $str = $this->get_var($handle); [676] => [677] => reset($this->loops); [678] => [679] => while ( list($loop_name, $loop_ar) = each($this->loops) ) [680] => { [681] => [682] => $start_tag = strpos($str, ''); [683] => [684] => $start_pos = $start_tag + strlen(''); [685] => if (!$start_pos) continue; [686] => $end_pos = strpos($str, ''); [687] => [688] => $loop_code = substr($str, $start_pos, $end_pos-$start_pos); [689] => $org_loop_code = $loop_code; [690] => [691] => $start_tag = substr($str, $start_tag, strlen('')); [692] => $end_tag = substr($str, $end_pos, strlen('')); [693] => [694] => if($loop_code != ''){ [695] => [696] => $new_code = ''; [697] => [698] => // clean if ($noloop & TPL_NOLOOP) [700] => { [701] => [702] => $nl_start_tag = strpos($loop_code, ''); [703] => $nl_start_pos = $nl_start_tag + strlen(''); [704] => [705] => [706] => if ($nl_start_pos) [707] => { [708] => [709] => $nl_end_pos = strpos($loop_code, ''); [710] => [711] => $noloop_code = substr($loop_code, $nl_start_pos, $nl_end_pos - $nl_start_pos); [712] => [713] => [714] => $nl_start_tag = substr($loop_code, $nl_start_tag, strlen('')); [715] => $nl_end_tag = substr($loop_code, $nl_end_pos, strlen('')); [716] => $loop_code = str_replace($nl_start_tag.$noloop_code.$nl_end_tag, '', $loop_code); [717] => } [718] => [719] => } [720] => [721] => if (is_array($loop_ar)) [722] => { [723] => [724] => if ($noloop & TPL_LOOP_INNER_PARSED) [725] => { [726] => for($i = 0; isset($loop_ar[$i]); $i++) [727] => [728] => { [729] => $temp_code = $loop_code; [730] => // rememeber loop variables [731] => [732] => $array_keys = array_keys($loop_ar[$i]); [733] => $this->set_var($loop_name, $loop_ar[$i]); [734] => if ($noloop & TPL_LOOP_INNER_OPTIONAL) $temp_code = $this->optional($loop_code); [735] => $temp_code = $this->parse($temp_code); [736] => $new_code .= $temp_code; [737] => [738] => // cleanup loop variables for next generation [739] => foreach ($array_keys as $key) unset($this->vars[$loop_name.'.'.$key]); [740] => [741] => } // for loop [742] => } [743] => else [744] => { [745] => // repeat for every row in array [746] => // for (reset($loop_ar); $row = current($loop_ar); next($loop_ar)) [747] => $ar_keys = array_keys($loop_ar); [748] => $ar_size = count($ar_keys); [749] => for($i = 0; ($i< $ar_size); $i++) [750] => { [751] => $temp_code = $loop_code; [752] => [753] => foreach( $loop_ar[$ar_keys[$i]] as $k=>$v) [754] => { [755] => $temp_code = str_replace( '{'. $loop_name. '.' .$k. '}', $v, $temp_code); [756] => } [757] => $new_code .= $temp_code; [758] => } [759] => } [760] => } elseif ($noloop & TPL_NOLOOP) [761] => { [762] => $new_code = $noloop_code; [763] => } [764] => [765] => [766] => $str = str_replace($start_tag.$org_loop_code.$end_tag, $new_code, $str); [767] => } // if loop code [768] => [769] => } // repeat for loop names [770] => [771] => return $str; [772] => } [773] => [774] => [775] => /** [776] => * process left variables [777] => * @deprecated parse() now handles unknown variables [778] => */ [779] => function finish($str) [780] => { [781] => switch ($this->unknowns) [782] => { [783] => case "keep": [784] => break; [785] => [786] => case "remove": [787] => $str = preg_replace('/{[^ \t\r\n}]+}/', "", $str); [788] => break; [789] => [790] => case "comment": [791] => $str = preg_replace('/{([^ \t\r\n}]+)}/', "", $str); [792] => break; [793] => [794] => case "space": [795] => $str = preg_replace('/{([^ \t\r\n}]+)}/', " ", $str); [796] => break; [797] => [798] => } [799] => [800] => return $str; [801] => } [802] => [803] => /** [804] => * search for optional tag [805] => * @param string $str text [806] => * @return string [807] => */ [808] => function optional($str) [809] => { [810] => $bl_start = 0; [811] => [812] => // extract and clean them from parent handle [813] => while(is_long($bl_start = strpos($str, '', $pos); [818] => $varname = substr($str, $pos, $endpos-$pos); [819] => [820] => $tag = ''; [821] => $endtag = ''; [822] => [823] => $end_pos = strpos($str, $endtag, $bl_start); [824] => if (!$end_pos) { $this->error("스킨오류 <opt name=\"$varname\">가 없음", 'fatal'); } [825] => [826] => $bl_end = $end_pos + strlen($endtag); [827] => [828] => [829] => $part1 = substr($str, 0, $bl_start); [830] => $part2 = substr($str, $bl_end, strlen($str)); [831] => [832] => // if .. by Sunmin Park [833] => if($varname[0]=="!") [834] => { [835] => $varname = substr($varname, 1); [836] => $flag = true; [837] => } [838] => else $flag = false; [839] => [840] => // .. By Sunmin Park [841] => if(strpos($varname,'=')) { [842] => list($varname,$varname_value) = explode('=',$varname,2); [843] => [844] => $value = $this->get_var_silent($varname); [845] => //echo " $value == $varname_value ";exit; [846] => if($value == $varname_value) { [847] => $flag = !$flag; [848] => } [849] => } [850] => else { [851] => $value = $this->get_var_silent($varname); [852] => [853] => //if ($value || $value === 0 || $value === '0') [854] => if ($value and $value !== 'N') [855] => { [856] => $flag = !$flag; [857] => } [858] => } [859] => [860] => if($flag) [861] => { [862] => $start_pos = $bl_start + strlen($tag); [863] => [864] => $block_code = substr($str, $start_pos, $end_pos-$start_pos); [865] => [866] => $str = $part1 . $this->parse($block_code) . $part2; [867] => } [868] => else [869] => { [870] => $str = $part1 . $part2; [871] => } [872] => } [873] => [874] => return $str; [875] => } [876] => [877] => /** [878] => * does everything: loops, includes, variables, concatenation [879] => * if $loop is 0 (not false, but 0) default parameters are used [880] => * thanks ShiVAs for idea to have $loop as parameters. [881] => * [882] => * @param $loop - loop, noloop or all parameters ored. [883] => * @param $append - append processed stuff to target, else $target is overwritten [884] => * @return string [885] => */ [886] => function process($target, $handle, $loop = false, $include = false, $append = false, $finish = false, $optional = false) [887] => { [888] => if ($loop === 0) $loop = $this->parameters; [889] => [890] => $noloop = false; [891] => $parsedloop = false; [892] => $loopopt = false; [893] => if ($loop > 2) [894] => { [895] => $noloop = $loop & TPL_NOLOOP; [896] => $include = $loop & TPL_INCLUDE; [897] => $append = $loop & TPL_APPEND; [898] => $finish = $loop & TPL_FINISH; [899] => $optional = $loop & TPL_OPTIONAL; [900] => $parsedloop = $loop & TPL_LOOP_INNER_PARSED; [901] => $loopopt = $loop & TPL_LOOP_INNER_OPTIONAL; [902] => } [903] => else [904] => { [905] => $noloop = $loop & TPL_NOLOOP; [906] => } [907] => [908] => if ($append) { [909] => if (isset($this->vars[$target])) { [910] => $app = $this->get_var($target); // preserve old info [911] => $this->set_var($target.'.count', $tmp=$this->get_var($target.'.count')+1); // by sunmin (append count) [912] => $this->set_var($target.'.countodd', $tmp%2 ); // by sunmin (append count) [913] => } [914] => else { [915] => $app = ''; [916] => $this->set_var($target.'.count', 1); // by sunmin (append count) [917] => $this->set_var($target.'.countodd', 1); // by sunmin (append count) [918] => } [919] => } [920] => [921] => $this->set_var($target, $this->get_var($handle)); // copy contents [922] => [923] => if ($include) { $this->set_var($target, $this->include_files($target)); } [924] => [925] => [926] => if ($noloop) { $this->set_var($target, $this->parse_loops($target, TPL_NOLOOP | $loopopt | $parsedloop)); } [927] => elseif ($loop) { $this->set_var($target, $this->parse_loops($target, $loopopt | $parsedloop)); } [928] => [929] => if ($optional) { $this->set_var($target, $this->optional($this->get_var_silent($target))); } [930] => [931] => if ($append) { $this->set_var($target, $app . $this->parse($this->get_var_silent($target))); } [932] => else { $this->set_var($target, $this->parse($this->get_var($target))); } [933] => [934] => if ($finish) { $this->set_var($target, $this->finish($this->get_var($target))); } [935] => [936] => return $this->get_var($target); [937] => } [938] => [939] => [940] => /** [941] => * spits out file contents [942] => * @access private [943] => */ [944] => function read_file($file) [945] => { [946] => $filename = $this->root . $file; [947] => [948] => if (!file_exists($filename)) [949] => { [950] => $this->error("phemplate::read_file(): 파일이 없음 - $filename", 'fatal'); [951] => return ''; [952] => } [953] => [954] => $tmp = false; [955] => [956] => $filesize = filesize($filename); [957] => if ($filesize) [958] => { [959] => $tmp = fread($fp = fopen($filename, 'r'), $filesize); [960] => fclose($fp); [961] => [962] => $this->read_files[]= $filename; [963] => } [964] => return $tmp; [965] => } [966] => [967] => /** [968] => * free mem used by loop [969] => */ [970] => function drop_loop($loop_handle) [971] => { [972] => if (isset($this->loops[$loop_handle])) unset($this->loops[$loop_handle]); [973] => } [974] => [975] => [976] => /** [977] => * free mem used by var [978] => */ [979] => function drop_var($handle,$var_value='') [980] => { [981] => if (is_array($var_value)) { // by Sunmin Park [982] => foreach($var_value as $key=>$value) [983] => $this->drop_var($handle.'.'.$key,$value); // recursion for array branches [984] => } [985] => elseif (isset($this->vars[$handle])) unset($this->vars[$handle]); [986] => } [987] => [988] => /** [989] => * set error handler [990] => */ [991] => function set_error_handler(&$eh) [992] => { [993] => $this->error_handler =& $eh; [994] => } [995] => [996] => /** [997] => * change block syntax [998] => */ [999] => function set_block_syntax($start, $end) [1000] => { [1001] => if (!strpos($start, '|')) $this->error("phemplate::set_block_syntax(): no '|' in start tag", 'fatal'); [1002] => if (!strpos($end, '|')) $this->error("phemplate::set_block_syntax(): no '|' in end tag", 'fatal'); [1003] => $this->block_start_string = $start; [1004] => $this->block_end_string = $end; [1005] => } [1006] => [1007] => /** [1008] => * error report [1009] => */ [1010] => function error( $msg, $level = '') [1011] => { [1012] => if (isset($this->error_handler)) [1013] => { [1014] => $lvl = E_USER_WARNING; [1015] => if ('fatal' == $level) $lvl = E_USER_ERROR; [1016] => $this->error_handler->report($lvl, $msg); [1017] => } [1018] => else [1019] => { [1020] => echo "\n
$level: $msg
\n"; [1021] => if ('fatal' == $level) { exit; } [1022] => } [1023] => } [1024] => [1025] => /** [1026] => * SitePHPbasic 반복하는 echoHtml [1027] => * By Sunmin Park 06/07/23 [1028] => */ [1029] => function echoHtml( &$dbinfo, &$SITE, $thisUrl='' ) { [1030] => $val='\\1'.$thisUrl.'skin/'.$dbinfo['skin'].'/images/'; [1031] => // - 사이트 템플릿 읽어오기 [1032] => if(ereg('^(ht|h|t)$',$dbinfo['html_type'])) { [1033] => $HEADER = array ('html_skin'=>$dbinfo['html_skin']); [1034] => @include($SITE['html_path'].'skin.php'); // retrun $aBody[0],$aBody[1] [1035] => } [1036] => [1037] => $html = ''; [1038] => switch($dbinfo['html_type']) { [1039] => case 'ht': [1040] => $html = $aBody[0]; [1041] => $html .= $dbinfo['html_head']; [1042] => $html .= ereg_replace('([="\'(])images/',$val,$this->process('', 'html',TPL_OPTIONAL)); [1043] => $html .= $dbinfo['html_tail']; [1044] => $html .= $aBody[1]; [1045] => break; [1046] => case 'h': [1047] => $html .= $aBody[0] ; [1048] => $html .= $dbinfo['html_head']; [1049] => $html .= ereg_replace('([="\'(])images/',$val,$this->process('', 'html',TPL_OPTIONAL)); [1050] => $html .= $dbinfo['html_tail']; [1051] => break; [1052] => case 't': [1053] => $html .= $dbinfo['html_head']; [1054] => $html .= ereg_replace('([="\'(])images/',$val,$this->process('', 'html',TPL_OPTIONAL)); [1055] => $html .= $dbinfo['html_tail'] ; [1056] => $html .= $aBody[1]; [1057] => break; [1058] => case 'no': [1059] => $html .= ereg_replace('([="\'(])images/',$val,$this->process('', 'html',TPL_OPTIONAL)); [1060] => break; [1061] => default: [1062] => $html .= $dbinfo['html_head']; [1063] => $html .= ereg_replace('([="\'(])images/',$val,$this->process('', 'html',TPL_OPTIONAL)); [1064] => $html .= $dbinfo['html_tail']; [1065] => } // end switch [1066] => [1067] => /* [1068] => if($_GET['utf8']=='euc-kr') { [1069] => // iconv 버그로 인해서 "\n"로 나눔 [1070] => $aA =explode("\n",$html); [1071] => $html =''; [1072] => foreach($aA as $v) $html .= iconv("euc-kr", "UTF-8",$v); [1073] => } [1074] => */ [1075] => [1076] => if($_GET['html_return']) $_GET['html']=$html; [1077] => else echo $html; [1078] => [1079] => // debug 출력 [1080] => if(defined('GET_DEBUG_2') and GET_DEBUG_2) { [1081] => echo "
"; [1082] => echo "skin : $dbinfo[skin], html_type: $dbinfo[html_type], html_skin: $dbinfo[html_skin]
thisUrl:$thisUrl "; [1083] => if('/spb3/sboard3/'==$thisUrl) { [1084] => echo " [게시판수정]"; [1085] => if($_GET['cateuid']) { [1086] => echo " [카테고리수정]"; [1087] => } [1088] => } [1089] => if($dbinfo['table']) { [1090] => echo " [$dbinfo[table]]"; [1091] => } [1092] => echo "
"; [1093] => if(count($this->read_files)) { [1094] => foreach($this->read_files as $filepath) { [1095] => if(strpos($filepath,$_SERVER['DOCUMENT_ROOT'])!==false) { [1096] => $url = substr($filepath,strlen($_SERVER['DOCUMENT_ROOT'])); [1097] => echo "skin file : $url
"; [1098] => } [1099] => else echo "skin file : $filepath
"; [1100] => } [1101] => } [1102] => //echo '
dbinfo ';var_export($dbinfo);

                                            [1103] => 			//echo '
'; [1104] => echo '
'; [1105] => } [1106] => } [1107] => } [1108] => ?> ) [new] => ) ) ) [1] => Array ( [file] => /wecan/cc/cc.sdong.kr/spb3/sadmin/util/svn/spb3_diff.php [line] => 119 [function] => file [args] => Array ( [0] => ) ) [2] => Array ( [file] => /wecan/cc/cc.sdong.kr/spb3/sadmin/util/svn/spb3_diff.php [line] => 142 [function] => doDiff [class] => diff [object] => diff Object ( [changes] => Array ( ) [diff] => Array ( ) [linepadding] => 2 ) [type] => -> [args] => Array ( [0] => /wecan/cc/cc.sdong.kr/spb3/sinc/lib/class_phemplate.php [1] => ) ) [3] => Array ( [file] => /wecan/cc/cc.sdong.kr/spb3/sadmin/util/svn/spb3_diff.php [line] => 197 [function] => diffWrap [class] => diff [object] => diff Object ( [changes] => Array ( ) [diff] => Array ( ) [linepadding] => 2 ) [type] => -> [args] => Array ( [0] => /wecan/cc/cc.sdong.kr/spb3/sinc/lib/class_phemplate.php [1] => ) ) [4] => Array ( [file] => /wecan/cc/cc.sdong.kr/spb3/sadmin/util/svn/spb3_diff.php [line] => 92 [function] => inline [class] => diff [object] => diff Object ( [changes] => Array ( ) [diff] => Array ( ) [linepadding] => 2 ) [type] => -> [args] => Array ( [0] => /wecan/cc/cc.sdong.kr/spb3/sinc/lib/class_phemplate.php [1] => [2] => 2 ) ) ) [key] => 4 [value] => Array ( [file] => /wecan/cc/cc.sdong.kr/spb3/sadmin/util/svn/spb3_diff.php [line] => 92 [function] => inline [class] => diff [object] => diff Object ( [changes] => Array ( ) [diff] => Array ( ) [linepadding] => 2 ) [type] => -> [args] => Array ( [0] => /wecan/cc/cc.sdong.kr/spb3/sinc/lib/class_phemplate.php [1] => [2] => 2 ) ) )
sitePHPbasic 디버그 모드 : WARNING
[2] array_keys() expects parameter 1 to be array, boolean given
Line : 122 (file:/wecan/cc/cc.sdong.kr/spb3/sadmin/util/svn/spb3_diff.php)
- 디버그 추적(debug_backtrace)
#0 spb_error_handler() 함수사용, line(),
#1 array_keys() 함수사용, line(122), /wecan/cc/cc.sdong.kr/spb3/sadmin/util/svn/spb3_diff.php
#2 doDiff() 함수사용, line(142), /wecan/cc/cc.sdong.kr/spb3/sadmin/util/svn/spb3_diff.php
#3 diffWrap() 함수사용, line(197), /wecan/cc/cc.sdong.kr/spb3/sadmin/util/svn/spb3_diff.php
#4 inline() 함수사용, line(92), /wecan/cc/cc.sdong.kr/spb3/sadmin/util/svn/spb3_diff.php




사용변수들 ...
$_GET = Array ( [md5_path] => /spb3/sinc/lib/class_phemplate.php ) $_POST = Array ( ) $_COOKIE = Array ( ) Array ( [errno] => 2 [errstr] => array_keys() expects parameter 1 to be array, boolean given [errfile] => /wecan/cc/cc.sdong.kr/spb3/sadmin/util/svn/spb3_diff.php [errline] => 122 [arr] => Array ( [0] => Array ( [function] => spb_error_handler [args] => Array ( [0] => 2 [1] => array_keys() expects parameter 1 to be array, boolean given [2] => /wecan/cc/cc.sdong.kr/spb3/sadmin/util/svn/spb3_diff.php [3] => 122 [4] => Array ( [old] => Array ( [0] => // $Id: class_phemplate.php 13 2010-08-24 08:28:50Z sitehis $ [2] => // 04/05/17 박선민 340L get_var() chanage to same get_var_silent() [3] => // 04/05/17 박선민 696L optional() add and change etc.. [4] => // 05/01/25 박선민 828L drop_var() add recursion for array branches [5] => // 05/11/20 박선민 echoHtml()로 반복하는 sitePHPbasic 마무리 부분 함수로 [6] => // 07/03/18 박선민 {!e.abc} 인경우 urlencoding 등의 기능 추가 [7] => // 07/08/14 박선민 {#widget.???} 윗젯 include 기능 추가 [8] => // 07/09/16 박선민 {#content.keyword} spb3_content 테이블의 keyword에 대한 content가져와서 넣는 기능 추가 [9] => // 08/06/14 박선민 $_GET[html_return] 기능 추가 [10] => // 08/06/28 박선민 831L optional() change 값이 'N'이여도 false되게 [11] => // 08/07/13 박선민 716L // cut_string {#cut.50#0#….key} 기능 추가 [12] => // 08/07/29 박선민 546L // parse() ... IF문 기능 추가 [13] => // 08/10/06 박선민 {#sub.2.3.???} 기능 추가 [14] => // 08/11/08 박선민 #content.??? 기능 개선 [15] => // 08/11/29 박선민 bugfix - don't use &$this [16] => // 09/01/04 박선민 {#widget2.???} 윗젯2 기능 추가(php파일위치에 widget2_???.php를 읽어서 함수 실행 [17] => // 09/02/04 박선민 {!N.list.number} 기능 추가 [18] => // 09/02/06 박선민 GET_DEBUG_2 기능 추가 [19] => // 09/02/25 박선민 {#exp.0.-.key}, server.server.HTTP_REFERER 추가 [20] => // 09/03/11 박선민 {!A.str} javascript에서 변수넘길때 큰따옴표 오류 해결용 [21] => // 09/05/08 박선민 bugfix - GET_DEBUG_2 false였을 때 오류 [22] => // 09/05/31 박선민 {!B.str} table, excel등에서 빈값은  로 변환하여 리턴하도록 [23] => // 09/05/31 박선민 {!?.str} 링크에 ?가 없으면 ?를 붙여주도록 [24] => // 09/07/28 박선민 {!X.name} : xmlspecialchars 변환 기능 추가 [25] => //---------------------------------------------------------------------------// [26] => // author: pukomuko [27] => // date: 2001.03.15 [28] => // web: http://pukomuko.esu.lt [29] => // http://sourceforge.net/projects/phemplate [30] => // info: template engine [31] => //---------------------------------------------------------------------------// [32] => // copyleft license [33] => // [34] => // this software is provided 'as-is', without any express or implied [35] => // warranty. in no event will the authors be held liable for any damages [36] => // arising from the use of this software. [37] => // [38] => // permission is granted to anyone to use this software for any purpose, [39] => // including commercial applications, and to alter it and redistribute it [40] => // freely, subject to the following restrictions: [41] => // [42] => // 1. the origin of this software must not be misrepresented; [43] => // you must not claim that you wrote the original software. [44] => // if you use this software in a product, an acknowledgment [45] => // in the product documentation would be appreciated but is not required. [46] => // [47] => // 2. altered source versions must be plainly marked as such, [48] => // and must not be misrepresented as being the original software. [49] => // [50] => // 3. mail about the fact of using this class in production [51] => // would be very appreciated. [52] => // [53] => // 4. this notice may not be removed or altered from any source distribution. [54] => // [55] => //---------------------------------------------------------------------------// [56] => // changes: [57] => // [58] => // 2004.04.21 [59] => // - warining on empty file [60] => // * v1.10.1 [61] => [62] => /** [63] => */ [64] => define('TPL_LOOP', 1); [65] => define('TPL_NOLOOP', 2); [66] => define('TPL_INCLUDE', 4); [67] => define('TPL_APPEND', 8); [68] => define('TPL_FINISH', 16); [69] => define('TPL_OPTIONAL', 32); [70] => define('TPL_LOOP_INNER_PARSED',64); [71] => define('TPL_LOOP_INNER_OPTIONAL', 128); [72] => [73] => define('TPL_PARSEDLOOP', TPL_LOOP | TPL_LOOP_INNER_PARSED); [74] => define('TPL_OPTLOOP', TPL_PARSEDLOOP | TPL_LOOP_INNER_OPTIONAL); [75] => [76] => [77] => define('TPL_BLOCK', 1); [78] => define('TPL_BLOCKREC', 2); [79] => define('TPL_STRIP_UTF_HEADER', 4); [80] => [81] => class phemplate [82] => { [83] => /** [84] => * 현재 클래스가 있는 드렉토리 By Sunmin [85] => */ [86] => var $widgetPath =''; [87] => [88] => var $read_files = array(); [89] => [90] => /** [91] => * spb3_content에서 읽어온 것을 캐쉬 [92] => */ [93] => var $spb3_content = array(); [94] => [95] => [96] => /** [97] => * variables and blocks [98] => */ [99] => var $vars = array(); [100] => [101] => /** [102] => * loops container [103] => */ [104] => var $loops = array(); [105] => [106] => /** [107] => * dir of template files [108] => */ [109] => var $root = ''; [110] => [111] => /** [112] => * what to do with unknown variables in template? [113] => */ [114] => var $unknowns = 'keep'; [115] => [116] => /** [117] => * default parameters for process() loop, append, finish [118] => */ [119] => var $parameters = 0; [120] => [121] => [122] => /** [123] => * object having method report($level, $msg) [124] => * you can catch error messages from template. [125] => */ [126] => var $error_handler = null; [127] => [128] => [129] => [130] => /** [131] => * start tag for block [132] => */ [133] => var $block_start_string = ''; [134] => [135] => /** [136] => * end tag for block [137] => */ [138] => var $block_end_string = ''; [139] => [140] => /** [141] => * constructor [142] => * $unknows를 keep에서 remove_nonjs로 변경함 by Sunmin Park [143] => */ [144] => function phemplate( $root_dir = '', $unknowns = 'remove_nonjs', $params = 0) [145] => { [146] => // widget, widget2 path [147] => $this->widgetPath = dirname(dirname(__FILE__)).'/widget/'; // By Sunmin [148] => if($this->set_root($root_dir)) [149] => $this->widget2Path = dirname(dirname($this->root)).'/'; // By Sunmin [150] => $this->set_unknowns($unknowns); [151] => $this->set_params($params); [152] => [153] => [154] => [155] => // 기본 set_var by Sunmin [156] => $this->tie_var('SITE' ,$GLOBALS['SITE']); // $SITE 전역변수 [157] => $this->tie_var('get' ,$_GET); [158] => $this->set_var('braces' ,'{'); // 중괄호{braces} 표현 [159] => $this->set_var('nowtime',time()); [160] => [161] => $this->tie_var('session.seUid' ,$_SESSION['seUid']); // 로그인 uid [162] => $this->tie_var('session.seUserid' ,$_SESSION['seUserid']); // 로그인 userid [163] => $this->tie_var('session.seName' ,$_SESSION['seName']); // 로그인 이름 [164] => $this->tie_var('session.seNickname' ,$_SESSION['seNickname']); // 로그인 별명 [165] => $this->tie_var('session.seEmail' ,$_SESSION['seEmail']); [166] => $this->tie_var('session.sePoint' ,$_SESSION['sePoint']); [167] => $this->tie_var('session.seCoupon' ,$_SESSION['seCoupon']); [168] => $this->tie_var('session.sePriv' ,$_SESSION['sePriv']); [169] => [170] => $this->set_var('server.HTTP_HOST' ,$_SERVER['HTTP_HOST']); [171] => $this->set_var('server.HTTP_REFERER',$_SERVER['HTTP_REFERER']); [172] => $this->set_var('server.QUERY_STRING' ,$_SERVER['QUERY_STRING']); [173] => $this->set_var('server.REQUEST_URI' ,$_SERVER['REQUEST_URI']); [174] => $this->set_var('server.PHP_SELF' ,$_SERVER['PHP_SELF']); [175] => } [176] => [177] => /** [178] => substitute text and returns parsed string [179] => @author ZaZa (Sergej Kurakin) 2003.05.05 21:52 [180] => */ [181] => function parse($string) [182] => { [183] => $str = explode('{', $string); [184] => [185] => $res = ''; [186] => [187] => for ($i = 0; isset($str[$i]); $i++) [188] => { [189] => $line = explode('}', $str[$i]); [190] => if ($i === 0) [191] => { [192] => $res .= $line[0]; [193] => } [194] => else [195] => { [196] => $key = $line[0]; [197] => unset($line[0]); [198] => [199] => if ( $key && isset($this->vars[$key]) ) [200] => { [201] => $res .= $this->vars[$key].implode('}', $line); [202] => } [203] => else [204] => { [205] => // {!d.list.rdate} 등 By Sunmin [206] => if($key[0]=='!') { // and isset($this->vars[substr($key,3)])) { [207] => switch(substr($key,1,2)) { [208] => /** [209] => ** 대소문자 구분함 [210] => {!B.name} : 값이 없으면   [211] => {!b.name} : 문장에서 엔터를
로 변환함 [212] => {!S.name} : 문장에서 html 테그를 모두 제거하고, 엔터는
로 변환함 [213] => [214] => {!a.name} : '\' addslashes 삽입 [215] => {!A.name} : javascript에서 변수넘길때 funcname('{!A.str}') [216] => {!s.name} : addslashes된 것을 stripcslashes함 [217] => {!?.name} : 문자열 중간 혹은 끝에 ?가 없으면 맨뒤에 ?를 붙여줌 [218] => [219] => {!h.name} : HTML특수문자로 변환( 큰따옴표도 변환 ) [220] => {!H.name} : HTML특수문자로 변환( 큰따옴표는 그대로 나둠) [221] => {!x.name} : stripcslashes함 하고 HTML특수문자로 변환( 큰따옴표도 변환) [222] => {!X.name} : xmlspecialchars 변환 [223] => [224] => {!e.url} : URL ENCODE [225] => [226] => {!n.price} : 숫자에 콤마 추가(단, 값이 없으면 무조건 '0' 리턴) [227] => {!N.price} : 숫자에 콤마 추가(단, ''값이면 빈값으로 리턴 [228] => [229] => {!D.rdate} : 숫자날짜를 YYYY-MM-DD로 변환 (연도가 4자리) [230] => {!d.rdate} : 숫자날짜를 YY-MM-DD로 변환 (연도가 2자리) [231] => {!T.rdate} : 숫자날짜를 YY-MM-DD H:i:s로 변환 (ex, 2009-01-01 23:59:55) [232] => {!t.rdate} : 숫자날짜를 시간인 H:i:s로 변환 (ex, 23:59:55) [233] => {!g.rdate} : 숫자날짜를 국제표준 한국시간으로 'D, j M Y G:i:s +0900' [234] => **/ [235] => case 'B.': [236] => if(empty($this->vars[substr($key,3)]) and $this->vars[substr($key,3)]!="0") [237] => $res .= ' '.implode('}', $line); [238] => else $res .= $this->vars[substr($key,3)].implode('}', $line); [239] => continue 2; [240] => break; [241] => case 'b.': [242] => $res .= nl2br($this->vars[substr($key,3)]).implode('}', $line); [243] => continue 2; [244] => break; [245] => case 'S.': // strip_tags(),
tag취환 [246] => $res .= ereg_replace("(\r\n|\n|\r)", '
',strip_tags($this->vars[substr($key,3)])).implode('}', $line); [247] => continue 2; [248] => break; [249] => case 'a.': [250] => $res .= addslashes($this->vars[substr($key,3)]).implode('}', $line); [251] => continue 2; [252] => break; [253] => case 'A.': [254] => $res .= str_replace('\\"','"',addslashes($this->vars[substr($key,3)])).implode('}', $line); [255] => continue 2; [256] => break; [257] => case 's.': [258] => $res .= stripcslashes($this->vars[substr($key,3)]).implode('}', $line); [259] => continue 2; [260] => break; [261] => case '?.': [262] => if(false===strpos($this->vars[substr($key,3)],'?')) [263] => $res .= $this->vars[substr($key,3)].'?'.implode('}', $line); [264] => else [265] => $res .= $this->vars[substr($key,3)].implode('}', $line); [266] => continue 2; [267] => break; [268] => case 'h.': [269] => $res .= htmlspecialchars($this->vars[substr($key,3)],ENT_QUOTES).implode('}', $line); [270] => continue 2; [271] => break; [272] => case 'H.': [273] => $res .= htmlspecialchars($this->vars[substr($key,3)],ENT_NOQUOTES).implode('}', $line); [274] => continue 2; [275] => break; [276] => case 'x.': [277] => $res .= htmlspecialchars(stripcslashes($this->vars[substr($key,3)]),ENT_QUOTES).implode('}', $line); [278] => continue 2; [279] => break; [280] => case 'X.': [281] => $res .= str_replace(''', ''', htmlspecialchars($this->vars[substr($key,3)], ENT_QUOTES)).implode('}', $line); [282] => continue 2; [283] => break; [284] => case 'e.': [285] => $res .= urlencode($this->vars[substr($key,3)]).implode('}', $line); [286] => continue 2; [287] => break; [288] => case 'n.': [289] => $res .= number_format((int)$this->vars[substr($key,3)]).implode('}', $line); [290] => continue 2; [291] => break; [292] => case 'N.': [293] => if($this->vars[substr($key,3)] or $this->vars[substr($key,3)]==='0' or $this->vars[substr($key,3)]===0) [294] => $res .= number_format($this->vars[substr($key,3)]).implode('}', $line); [295] => else $res .= implode('}', $line); [296] => continue 2; [297] => break; [298] => case 'D.': [299] => if($this->vars[substr($key,3)]) [300] => $res .= date('Y-m-d',$this->vars[substr($key,3)]).implode('}', $line); [301] => else $res .= implode('}', $line); [302] => continue 2; [303] => break; [304] => case 'd.': [305] => if($this->vars[substr($key,3)]) [306] => $res .= date('y-m-d',$this->vars[substr($key,3)]).implode('}', $line); [307] => else $res .= implode('}', $line); [308] => continue 2; [309] => break; [310] => case 'T.': [311] => if($this->vars[substr($key,3)]) [312] => $res .= date('y-m-d H:i:s',$this->vars[substr($key,3)]).implode('}', $line); [313] => else $res .= implode('}', $line); [314] => continue 2; [315] => break; [316] => case 't.': [317] => if($this->vars[substr($key,3)]) [318] => $res .= date('H:i:s',$this->vars[substr($key,3)]).implode('}', $line); [319] => else $res .= implode('}', $line); [320] => continue 2; [321] => break; [322] => case 'g.': [323] => if($this->vars[substr($key,3)]) [324] => $res .= date('D, j M Y G:i:s +0900',$this->vars[substr($key,3)]).implode('}', $line); [325] => else $res .= implode('}', $line); [326] => continue 2; [327] => break; [328] => } [329] => } [330] => [331] => if($key[0]=='#') { [332] => // /spb3/sinc/widget/???.php By Sunmin [333] => if('widget.'==substr($key,1,7)) { [334] => $tmpWidget2 = substr($key,8); [335] => list($tmpWidget,$tmpKey) = explode('.',$tmpWidget2,2); [336] => if(eregi('^[-_a-z0-9]+$',$tmpWidget) and is_file($this->widgetPath . $tmpWidget . '/index.php')) { [337] => @include_once($this->widgetPath .$tmpWidget . '/index.php'); [338] => $func = 'widget_'.$tmpWidget; [339] => $res .= @$func($this,$tmpKey) . implode('}', $line); [340] => continue; [341] => } [342] => } [343] => elseif('widget2.'==substr($key,1,8)) { [344] => $tmpWidget2 = substr($key,9); [345] => list($tmpWidget,$tmpKey) = explode('.',$tmpWidget2,2); [346] => if(eregi('^[-_a-z0-9]+$',$tmpWidget) and is_file($this->widget2Path . 'widget2_'.$tmpWidget . '.php')) { [347] => @include_once($this->widget2Path . 'widget2_'.$tmpWidget . '.php'); [348] => $func = 'widget2_'.$tmpWidget; [349] => $res .= @$func($this,$tmpKey) . implode('}', $line); [350] => continue; [351] => } [352] => }elseif('include.'==substr($key,1,8)) { [353] => $tmpFilename = substr($key,9); [354] => if(is_file($this->root.'/include_'.$tmpFilename.'.html')) { [355] => $res .= @file_get_contents($this->root.'include_'.$tmpFilename.'.html') . implode('}', $line); [356] => } [357] => else $res .= implode('}', $line); [358] => continue; [359] => } [360] => // spb3_content읽어서 keyword에서 content 전송 [361] => elseif('content.'==substr($key,1,8)) { [362] => list($tmp,$tmpKeyword,$tmpContent) = explode('.',$key,3); [363] => if(!$tmpContent) $tmpContent = 'content'; [364] => if(!isset($this->spb3_content[$tmpContent])) { [365] => $this->spb3_content[$tmpContent] = db_resultdata($GLOBALS['SITE']['th'].'cate_content',$tmpContent,'keyword',$tmpKeyword); [366] => } [367] => $res .= $this->spb3_content[$tmpContent] . implode('}', $line); [368] => continue; [369] => } [370] => // cut_string {#cut.50#0#….key} [371] => elseif('cut.'==substr($key,1,4)) { [372] => list($tmp,$tmpCut,$tmpKey) = explode('.',$key,3); [373] => list($tmpCut1,$tmpCut2,$tmpCut3) = explode('#',$tmpCut,3); [374] => if($tmpCut1===NULL) $tmpCut1 = 50; [375] => if($tmpCut2===NULL) $tmpCut2 = 0; [376] => if($tmpCut3===NULL) $tmpCut3 = '…'; [377] => $res .= cut_string($this->vars[$tmpKey],$tmpCut1,$tmpCut2,$tmpCut3).implode('}', $line); [378] => continue; [379] => } [380] => // substr {#sub.2.3.key} [381] => elseif('sub.'==substr($key,1,4)) { [382] => list($tmp,$tmpSub1,$tmpSub2,$tmpKey) = explode('.',$key,4); [383] => $res .= substr($this->vars[$tmpKey],(int)$tmpSub1,(int)$tmpSub2).implode('}', $line); [384] => continue; [385] => } [386] => // explode(split) {#exp.0.-.key} 0번째, -으로 나누어서 [387] => elseif('exp.'==substr($key,1,4)) { [388] => $tmp = explode('.',$key,4); [389] => if(4==count($tmp)) { [390] => $tmp2 = explode($tmp[2],$this->vars[$tmp[3]]); [391] => $res .= $tmp2[$tmp[1]].implode('}', $line); [392] => } [393] => else $res .= implode('}', $line); [394] => continue; [395] => } [396] => } [397] => [398] => switch ($this->unknowns) [399] => { [400] => case "keep": [401] => $res .= '{'.$key; [402] => if (count ($line) > 0) [403] => { [404] => $res .= '}'; [405] => $res .= implode('}', $line); [406] => } [407] => break; [408] => [409] => case "remove": [410] => $res .= implode('', $line); [411] => break; [412] => [413] => case "remove_nonjs": [414] => if (!empty($key) && ((false === strpos($key, ' ')) && (false === strpos($key, "\n")) && (false === strpos($key, "\t")))) [415] => { [416] => $res .= implode('}', $line); [417] => } [418] => else [419] => { [420] => $res .= '{'.$key; [421] => if (count ($line) > 0) [422] => { [423] => $res .= '}'; [424] => $res .= implode('}', $line); [425] => } [426] => } [427] => break; [428] => [429] => case "comment": [430] => $res .= ''.implode('', $line); [431] => break; [432] => [433] => case "space": [434] => $res .= ' '.implode('', $line); [435] => break; [436] => [437] => } [438] => } [439] => } [440] => } [441] => [442] => return $res; [443] => } [444] => [445] => /** [446] => * check and set template root dir [447] => */ [448] => function set_root($root) [449] => { [450] => if (empty($root)) return; [451] => if (!is_dir($root)) [452] => { [453] => $this->error("phemplate::set_root(): 다음 드렉토리가 없습니다 : $root", 'warning'); [454] => return false; [455] => } [456] => [457] => $this->root = realpath($root).'/'; // By Sunmin 05/11/13 [458] => return true; [459] => } [460] => [461] => /** [462] => * what to do with unknown variables in template? [463] => * keep [464] => * remove [465] => * remove_nonjs [466] => * comment [467] => * space [468] => */ [469] => function set_unknowns($unk) [470] => { [471] => $this->unknowns = $unk; [472] => } [473] => [474] => /** [475] => * set default parameters for process() [476] => */ [477] => function set_params($params) [478] => { [479] => $this->parameters = $params; [480] => } [481] => [482] => /** [483] => * read file template into $vars [484] => * @param string $handle - name of handle for file contents [485] => * @param int $blocks - 1 for search, 2 for nested blocks [486] => * [487] => */ [488] => function set_file($handle, $filename = "", $blocks = false) [489] => { [490] => if ($filename == "") [491] => { [492] => $this->error("phemplate::set_file(): 파일이름이 빈값으로 넘어왔습니다 -$handle", 'fatal'); [493] => return false; [494] => } [495] => $this->vars[$handle] = $this->read_file($filename); [496] => if ($blocks & TPL_STRIP_UTF_HEADER) [497] => { [498] => $header = substr($this->vars[$handle], 0, 3); [499] => if ("\xEF\xBB\xBF" == $header) $this->vars[$handle] = substr($this->vars[$handle], 3); [500] => } [501] => if ($blocks) { $this->extract_blocks($handle, $blocks & TPL_BLOCKREC); } [502] => return true; [503] => [504] => } [505] => [506] => [507] => /** [508] => * set handle and value, [509] => * if value is array, all elements will be named: handle.key.subkey [510] => */ [511] => function set_var($var_name, $var_value) [512] => { [513] => if (is_array($var_value)) [514] => { [515] => foreach($var_value as $key=>$value) [516] => { [517] => $this->set_var($var_name . '.' . $key, $value); // recursion for array branches [518] => } [519] => } [520] => else // normal variable [521] => { [522] => $this->vars[$var_name] = $var_value; [523] => } [524] => } [525] => [526] => /** [527] => * tie value with variable [528] => * it's not possible to update array keys, just values [529] => */ [530] => function tie_var($var_name, &$var_value) [531] => { [532] => if (is_array($var_value)) [533] => { [534] => $list = array_keys($var_value); [535] => foreach($list as $key) [536] => { [537] => $this->tie_var($var_name . '.' . $key, $var_value[$key]); // recursion for array branches [538] => } [539] => } [540] => else // normal variable [541] => { [542] => $this->vars[$var_name] =& $var_value; [543] => } [544] => } [545] => [546] => /** [547] => * value of $handle [548] => * raises error if $handle undefined [549] => */ [550] => function get_var($handle) [551] => { [552] => if (!isset($this->vars[$handle])) { [553] => //$this->error("phemplate(): no such handle '$handle'", 'warning'); [554] => return null; // By Sunmin Park 04/05/17 [555] => } [556] => return $this->vars[$handle]; [557] => } [558] => [559] => /** [560] => * value of $handle, no error if no handle [561] => */ [562] => function get_var_silent($handle) [563] => { [564] => if (!isset($this->vars[$handle])) { $this->vars[$handle] = ''; return ''; } [565] => return $this->vars[$handle]; [566] => } [567] => [568] => /** [569] => * assign array to loop handle [570] => * @param string $loop_name - name for a loop [571] => * @param int $loop - loop data [572] => */ [573] => function set_loop($loop_name, $loop) [574] => { [575] => if (!$loop) $loop = 0; [576] => $this->loops[$loop_name] = $loop; [577] => } [578] => [579] => /** [580] => * tie array with loop [581] => */ [582] => function tie_loop($loop_name, &$loop) [583] => { [584] => if (!$loop) $loop = 0; [585] => $this->loops[$loop_name] =& $loop; [586] => } [587] => [588] => /** [589] => * extracts blocks from handle, and returns cleaned up version [590] => * [591] => * must be quite fast, because every found block is imediately taken out of string [592] => * [593] => * [594] => * @since 2001.10.31 works with nested blocks [js] [595] => * @since 2003.06.19 supports customized block syntax [js] [596] => * [597] => */ [598] => function extract_blocks($bl_handle, $recurse = false) [599] => { [600] => [601] => $str = $this->get_var($bl_handle); [602] => if (!$str) return $str; [603] => $bl_start = 0; [604] => [605] => list($bll, $blr) = explode('|', $this->block_start_string); [606] => $strlen = strlen($bll); [607] => [608] => [609] => // find them and clean from parent handle [610] => while(is_long($bl_start = strpos($str, $bll, $bl_start))) [611] => { [612] => $pos = $bl_start + $strlen; [613] => [614] => $endpos = strpos($str, $blr, $pos); [615] => $handle = substr($str, $pos, $endpos-$pos); [616] => [617] => $tag = $bll.$handle.$blr; [618] => $endtag = str_replace('|', $handle, $this->block_end_string); [619] => [620] => $start_pos = $bl_start + strlen($tag); [621] => $end_pos = strpos($str, $endtag, $bl_start); [622] => if (!$end_pos) { $this->error("스킨오류 : </block name=\"$handle\">이 없음", 'fatal'); } [623] => $bl_end = $end_pos + strlen($endtag); [624] => [625] => $block_code = substr($str, $start_pos, $end_pos-$start_pos); [626] => [627] => $this->set_var($handle, $block_code); [628] => [629] => $part1 = substr($str, 0, $bl_start); [630] => $part2 = substr($str, $bl_end, strlen($str)); [631] => [632] => $str = $part1 . $part2; [633] => [634] => if ($recurse) { $this->extract_blocks($handle, 1); } [635] => [636] => } [637] => [638] => $this->set_var($bl_handle, $str); [639] => [640] => } [641] => [642] => [643] => /** [644] => * search for tags in $handle [645] => * be carefull with paths [646] => */ [647] => function include_files($handle) [648] => { [649] => $str = $this->get_var($handle); [650] => [651] => while(is_long($pos = strpos($str, '', $pos); [655] => $filename = substr($str, $pos, $endpos-$pos); [656] => $tag = ''; [657] => [658] => [659] => $include = $this->read_file($filename); [660] => [661] => $str = str_replace($tag, $include, $str); [662] => } [663] => [664] => return $str; [665] => } [666] => [667] => [668] => /** [669] => * searches for all set loops in $handle, returns text of $handle with parsed loops [670] => * @param bool $noloop - must be true, if you want noloop statement [671] => * @return string [672] => */ [673] => function parse_loops($handle, $noloop = false) [674] => { [675] => $str = $this->get_var($handle); [676] => [677] => reset($this->loops); [678] => [679] => while ( list($loop_name, $loop_ar) = each($this->loops) ) [680] => { [681] => [682] => $start_tag = strpos($str, ''); [683] => [684] => $start_pos = $start_tag + strlen(''); [685] => if (!$start_pos) continue; [686] => $end_pos = strpos($str, ''); [687] => [688] => $loop_code = substr($str, $start_pos, $end_pos-$start_pos); [689] => $org_loop_code = $loop_code; [690] => [691] => $start_tag = substr($str, $start_tag, strlen('')); [692] => $end_tag = substr($str, $end_pos, strlen('')); [693] => [694] => if($loop_code != ''){ [695] => [696] => $new_code = ''; [697] => [698] => // clean if ($noloop & TPL_NOLOOP) [700] => { [701] => [702] => $nl_start_tag = strpos($loop_code, ''); [703] => $nl_start_pos = $nl_start_tag + strlen(''); [704] => [705] => [706] => if ($nl_start_pos) [707] => { [708] => [709] => $nl_end_pos = strpos($loop_code, ''); [710] => [711] => $noloop_code = substr($loop_code, $nl_start_pos, $nl_end_pos - $nl_start_pos); [712] => [713] => [714] => $nl_start_tag = substr($loop_code, $nl_start_tag, strlen('')); [715] => $nl_end_tag = substr($loop_code, $nl_end_pos, strlen('')); [716] => $loop_code = str_replace($nl_start_tag.$noloop_code.$nl_end_tag, '', $loop_code); [717] => } [718] => [719] => } [720] => [721] => if (is_array($loop_ar)) [722] => { [723] => [724] => if ($noloop & TPL_LOOP_INNER_PARSED) [725] => { [726] => for($i = 0; isset($loop_ar[$i]); $i++) [727] => [728] => { [729] => $temp_code = $loop_code; [730] => // rememeber loop variables [731] => [732] => $array_keys = array_keys($loop_ar[$i]); [733] => $this->set_var($loop_name, $loop_ar[$i]); [734] => if ($noloop & TPL_LOOP_INNER_OPTIONAL) $temp_code = $this->optional($loop_code); [735] => $temp_code = $this->parse($temp_code); [736] => $new_code .= $temp_code; [737] => [738] => // cleanup loop variables for next generation [739] => foreach ($array_keys as $key) unset($this->vars[$loop_name.'.'.$key]); [740] => [741] => } // for loop [742] => } [743] => else [744] => { [745] => // repeat for every row in array [746] => // for (reset($loop_ar); $row = current($loop_ar); next($loop_ar)) [747] => $ar_keys = array_keys($loop_ar); [748] => $ar_size = count($ar_keys); [749] => for($i = 0; ($i< $ar_size); $i++) [750] => { [751] => $temp_code = $loop_code; [752] => [753] => foreach( $loop_ar[$ar_keys[$i]] as $k=>$v) [754] => { [755] => $temp_code = str_replace( '{'. $loop_name. '.' .$k. '}', $v, $temp_code); [756] => } [757] => $new_code .= $temp_code; [758] => } [759] => } [760] => } elseif ($noloop & TPL_NOLOOP) [761] => { [762] => $new_code = $noloop_code; [763] => } [764] => [765] => [766] => $str = str_replace($start_tag.$org_loop_code.$end_tag, $new_code, $str); [767] => } // if loop code [768] => [769] => } // repeat for loop names [770] => [771] => return $str; [772] => } [773] => [774] => [775] => /** [776] => * process left variables [777] => * @deprecated parse() now handles unknown variables [778] => */ [779] => function finish($str) [780] => { [781] => switch ($this->unknowns) [782] => { [783] => case "keep": [784] => break; [785] => [786] => case "remove": [787] => $str = preg_replace('/{[^ \t\r\n}]+}/', "", $str); [788] => break; [789] => [790] => case "comment": [791] => $str = preg_replace('/{([^ \t\r\n}]+)}/', "", $str); [792] => break; [793] => [794] => case "space": [795] => $str = preg_replace('/{([^ \t\r\n}]+)}/', " ", $str); [796] => break; [797] => [798] => } [799] => [800] => return $str; [801] => } [802] => [803] => /** [804] => * search for optional tag [805] => * @param string $str text [806] => * @return string [807] => */ [808] => function optional($str) [809] => { [810] => $bl_start = 0; [811] => [812] => // extract and clean them from parent handle [813] => while(is_long($bl_start = strpos($str, '', $pos); [818] => $varname = substr($str, $pos, $endpos-$pos); [819] => [820] => $tag = ''; [821] => $endtag = ''; [822] => [823] => $end_pos = strpos($str, $endtag, $bl_start); [824] => if (!$end_pos) { $this->error("스킨오류 <opt name=\"$varname\">가 없음", 'fatal'); } [825] => [826] => $bl_end = $end_pos + strlen($endtag); [827] => [828] => [829] => $part1 = substr($str, 0, $bl_start); [830] => $part2 = substr($str, $bl_end, strlen($str)); [831] => [832] => // if .. by Sunmin Park [833] => if($varname[0]=="!") [834] => { [835] => $varname = substr($varname, 1); [836] => $flag = true; [837] => } [838] => else $flag = false; [839] => [840] => // .. By Sunmin Park [841] => if(strpos($varname,'=')) { [842] => list($varname,$varname_value) = explode('=',$varname,2); [843] => [844] => $value = $this->get_var_silent($varname); [845] => //echo " $value == $varname_value ";exit; [846] => if($value == $varname_value) { [847] => $flag = !$flag; [848] => } [849] => } [850] => else { [851] => $value = $this->get_var_silent($varname); [852] => [853] => //if ($value || $value === 0 || $value === '0') [854] => if ($value and $value !== 'N') [855] => { [856] => $flag = !$flag; [857] => } [858] => } [859] => [860] => if($flag) [861] => { [862] => $start_pos = $bl_start + strlen($tag); [863] => [864] => $block_code = substr($str, $start_pos, $end_pos-$start_pos); [865] => [866] => $str = $part1 . $this->parse($block_code) . $part2; [867] => } [868] => else [869] => { [870] => $str = $part1 . $part2; [871] => } [872] => } [873] => [874] => return $str; [875] => } [876] => [877] => /** [878] => * does everything: loops, includes, variables, concatenation [879] => * if $loop is 0 (not false, but 0) default parameters are used [880] => * thanks ShiVAs for idea to have $loop as parameters. [881] => * [882] => * @param $loop - loop, noloop or all parameters ored. [883] => * @param $append - append processed stuff to target, else $target is overwritten [884] => * @return string [885] => */ [886] => function process($target, $handle, $loop = false, $include = false, $append = false, $finish = false, $optional = false) [887] => { [888] => if ($loop === 0) $loop = $this->parameters; [889] => [890] => $noloop = false; [891] => $parsedloop = false; [892] => $loopopt = false; [893] => if ($loop > 2) [894] => { [895] => $noloop = $loop & TPL_NOLOOP; [896] => $include = $loop & TPL_INCLUDE; [897] => $append = $loop & TPL_APPEND; [898] => $finish = $loop & TPL_FINISH; [899] => $optional = $loop & TPL_OPTIONAL; [900] => $parsedloop = $loop & TPL_LOOP_INNER_PARSED; [901] => $loopopt = $loop & TPL_LOOP_INNER_OPTIONAL; [902] => } [903] => else [904] => { [905] => $noloop = $loop & TPL_NOLOOP; [906] => } [907] => [908] => if ($append) { [909] => if (isset($this->vars[$target])) { [910] => $app = $this->get_var($target); // preserve old info [911] => $this->set_var($target.'.count', $tmp=$this->get_var($target.'.count')+1); // by sunmin (append count) [912] => $this->set_var($target.'.countodd', $tmp%2 ); // by sunmin (append count) [913] => } [914] => else { [915] => $app = ''; [916] => $this->set_var($target.'.count', 1); // by sunmin (append count) [917] => $this->set_var($target.'.countodd', 1); // by sunmin (append count) [918] => } [919] => } [920] => [921] => $this->set_var($target, $this->get_var($handle)); // copy contents [922] => [923] => if ($include) { $this->set_var($target, $this->include_files($target)); } [924] => [925] => [926] => if ($noloop) { $this->set_var($target, $this->parse_loops($target, TPL_NOLOOP | $loopopt | $parsedloop)); } [927] => elseif ($loop) { $this->set_var($target, $this->parse_loops($target, $loopopt | $parsedloop)); } [928] => [929] => if ($optional) { $this->set_var($target, $this->optional($this->get_var_silent($target))); } [930] => [931] => if ($append) { $this->set_var($target, $app . $this->parse($this->get_var_silent($target))); } [932] => else { $this->set_var($target, $this->parse($this->get_var($target))); } [933] => [934] => if ($finish) { $this->set_var($target, $this->finish($this->get_var($target))); } [935] => [936] => return $this->get_var($target); [937] => } [938] => [939] => [940] => /** [941] => * spits out file contents [942] => * @access private [943] => */ [944] => function read_file($file) [945] => { [946] => $filename = $this->root . $file; [947] => [948] => if (!file_exists($filename)) [949] => { [950] => $this->error("phemplate::read_file(): 파일이 없음 - $filename", 'fatal'); [951] => return ''; [952] => } [953] => [954] => $tmp = false; [955] => [956] => $filesize = filesize($filename); [957] => if ($filesize) [958] => { [959] => $tmp = fread($fp = fopen($filename, 'r'), $filesize); [960] => fclose($fp); [961] => [962] => $this->read_files[]= $filename; [963] => } [964] => return $tmp; [965] => } [966] => [967] => /** [968] => * free mem used by loop [969] => */ [970] => function drop_loop($loop_handle) [971] => { [972] => if (isset($this->loops[$loop_handle])) unset($this->loops[$loop_handle]); [973] => } [974] => [975] => [976] => /** [977] => * free mem used by var [978] => */ [979] => function drop_var($handle,$var_value='') [980] => { [981] => if (is_array($var_value)) { // by Sunmin Park [982] => foreach($var_value as $key=>$value) [983] => $this->drop_var($handle.'.'.$key,$value); // recursion for array branches [984] => } [985] => elseif (isset($this->vars[$handle])) unset($this->vars[$handle]); [986] => } [987] => [988] => /** [989] => * set error handler [990] => */ [991] => function set_error_handler(&$eh) [992] => { [993] => $this->error_handler =& $eh; [994] => } [995] => [996] => /** [997] => * change block syntax [998] => */ [999] => function set_block_syntax($start, $end) [1000] => { [1001] => if (!strpos($start, '|')) $this->error("phemplate::set_block_syntax(): no '|' in start tag", 'fatal'); [1002] => if (!strpos($end, '|')) $this->error("phemplate::set_block_syntax(): no '|' in end tag", 'fatal'); [1003] => $this->block_start_string = $start; [1004] => $this->block_end_string = $end; [1005] => } [1006] => [1007] => /** [1008] => * error report [1009] => */ [1010] => function error( $msg, $level = '') [1011] => { [1012] => if (isset($this->error_handler)) [1013] => { [1014] => $lvl = E_USER_WARNING; [1015] => if ('fatal' == $level) $lvl = E_USER_ERROR; [1016] => $this->error_handler->report($lvl, $msg); [1017] => } [1018] => else [1019] => { [1020] => echo "\n
$level: $msg
\n"; [1021] => if ('fatal' == $level) { exit; } [1022] => } [1023] => } [1024] => [1025] => /** [1026] => * SitePHPbasic 반복하는 echoHtml [1027] => * By Sunmin Park 06/07/23 [1028] => */ [1029] => function echoHtml( &$dbinfo, &$SITE, $thisUrl='' ) { [1030] => $val='\\1'.$thisUrl.'skin/'.$dbinfo['skin'].'/images/'; [1031] => // - 사이트 템플릿 읽어오기 [1032] => if(ereg('^(ht|h|t)$',$dbinfo['html_type'])) { [1033] => $HEADER = array ('html_skin'=>$dbinfo['html_skin']); [1034] => @include($SITE['html_path'].'skin.php'); // retrun $aBody[0],$aBody[1] [1035] => } [1036] => [1037] => $html = ''; [1038] => switch($dbinfo['html_type']) { [1039] => case 'ht': [1040] => $html = $aBody[0]; [1041] => $html .= $dbinfo['html_head']; [1042] => $html .= ereg_replace('([="\'(])images/',$val,$this->process('', 'html',TPL_OPTIONAL)); [1043] => $html .= $dbinfo['html_tail']; [1044] => $html .= $aBody[1]; [1045] => break; [1046] => case 'h': [1047] => $html .= $aBody[0] ; [1048] => $html .= $dbinfo['html_head']; [1049] => $html .= ereg_replace('([="\'(])images/',$val,$this->process('', 'html',TPL_OPTIONAL)); [1050] => $html .= $dbinfo['html_tail']; [1051] => break; [1052] => case 't': [1053] => $html .= $dbinfo['html_head']; [1054] => $html .= ereg_replace('([="\'(])images/',$val,$this->process('', 'html',TPL_OPTIONAL)); [1055] => $html .= $dbinfo['html_tail'] ; [1056] => $html .= $aBody[1]; [1057] => break; [1058] => case 'no': [1059] => $html .= ereg_replace('([="\'(])images/',$val,$this->process('', 'html',TPL_OPTIONAL)); [1060] => break; [1061] => default: [1062] => $html .= $dbinfo['html_head']; [1063] => $html .= ereg_replace('([="\'(])images/',$val,$this->process('', 'html',TPL_OPTIONAL)); [1064] => $html .= $dbinfo['html_tail']; [1065] => } // end switch [1066] => [1067] => /* [1068] => if($_GET['utf8']=='euc-kr') { [1069] => // iconv 버그로 인해서 "\n"로 나눔 [1070] => $aA =explode("\n",$html); [1071] => $html =''; [1072] => foreach($aA as $v) $html .= iconv("euc-kr", "UTF-8",$v); [1073] => } [1074] => */ [1075] => [1076] => if($_GET['html_return']) $_GET['html']=$html; [1077] => else echo $html; [1078] => [1079] => // debug 출력 [1080] => if(defined('GET_DEBUG_2') and GET_DEBUG_2) { [1081] => echo "
"; [1082] => echo "skin : $dbinfo[skin], html_type: $dbinfo[html_type], html_skin: $dbinfo[html_skin]
thisUrl:$thisUrl "; [1083] => if('/spb3/sboard3/'==$thisUrl) { [1084] => echo " [게시판수정]"; [1085] => if($_GET['cateuid']) { [1086] => echo " [카테고리수정]"; [1087] => } [1088] => } [1089] => if($dbinfo['table']) { [1090] => echo " [$dbinfo[table]]"; [1091] => } [1092] => echo "
"; [1093] => if(count($this->read_files)) { [1094] => foreach($this->read_files as $filepath) { [1095] => if(strpos($filepath,$_SERVER['DOCUMENT_ROOT'])!==false) { [1096] => $url = substr($filepath,strlen($_SERVER['DOCUMENT_ROOT'])); [1097] => echo "skin file : $url
"; [1098] => } [1099] => else echo "skin file : $filepath
"; [1100] => } [1101] => } [1102] => //echo '
dbinfo ';var_export($dbinfo);

                                            [1103] => 			//echo '
'; [1104] => echo '
'; [1105] => } [1106] => } [1107] => } [1108] => ?> ) [new] => [ovalue] => 0 ) ) ) [1] => Array ( [file] => /wecan/cc/cc.sdong.kr/spb3/sadmin/util/svn/spb3_diff.php [line] => 122 [function] => array_keys [args] => Array ( [0] => [1] => Array ( [file] => /wecan/cc/cc.sdong.kr/spb3/sadmin/util/svn/spb3_diff.php [line] => 142 [function] => doDiff [class] => diff [object] => diff Object ( [changes] => Array ( ) [diff] => Array ( ) [linepadding] => 2 ) [type] => -> [args] => Array ( [0] => /wecan/cc/cc.sdong.kr/spb3/sinc/lib/class_phemplate.php [1] => ) ) [3] => Array ( [file] => /wecan/cc/cc.sdong.kr/spb3/sadmin/util/svn/spb3_diff.php [line] => 197 [function] => diffWrap [class] => diff [object] => diff Object ( [changes] => Array ( ) [diff] => Array ( ) [linepadding] => 2 ) [type] => -> [args] => Array ( [0] => /wecan/cc/cc.sdong.kr/spb3/sinc/lib/class_phemplate.php [1] => ) ) [4] => Array ( [file] => /wecan/cc/cc.sdong.kr/spb3/sadmin/util/svn/spb3_diff.php [line] => 92 [function] => inline [class] => diff [object] => diff Object ( [changes] => Array ( ) [diff] => Array ( ) [linepadding] => 2 ) [type] => -> [args] => Array ( [0] => /wecan/cc/cc.sdong.kr/spb3/sinc/lib/class_phemplate.php [1] => [2] => 2 ) ) ) [key] => 4 [value] => Array ( [file] => /wecan/cc/cc.sdong.kr/spb3/sadmin/util/svn/spb3_diff.php [line] => 92 [function] => inline [class] => diff [object] => diff Object ( [changes] => Array ( ) [diff] => Array ( ) [linepadding] => 2 ) [type] => -> [args] => Array ( [0] => /wecan/cc/cc.sdong.kr/spb3/sinc/lib/class_phemplate.php [1] => [2] => 2 ) ) )
sitePHPbasic 디버그 모드 : WARNING
[2] Invalid argument supplied for foreach()
Line : 123 (file:/wecan/cc/cc.sdong.kr/spb3/sadmin/util/svn/spb3_diff.php)
- 디버그 추적(debug_backtrace)
#0 spb_error_handler() 함수사용, line(123), /wecan/cc/cc.sdong.kr/spb3/sadmin/util/svn/spb3_diff.php
#1 doDiff() 함수사용, line(142), /wecan/cc/cc.sdong.kr/spb3/sadmin/util/svn/spb3_diff.php
#2 diffWrap() 함수사용, line(197), /wecan/cc/cc.sdong.kr/spb3/sadmin/util/svn/spb3_diff.php
#3 inline() 함수사용, line(92), /wecan/cc/cc.sdong.kr/spb3/sadmin/util/svn/spb3_diff.php




사용변수들 ...
$_GET = Array ( [md5_path] => /spb3/sinc/lib/class_phemplate.php ) $_POST = Array ( ) $_COOKIE = Array ( ) Array ( [errno] => 2 [errstr] => Invalid argument supplied for foreach() [errfile] => /wecan/cc/cc.sdong.kr/spb3/sadmin/util/svn/spb3_diff.php [errline] => 123 [arr] => Array ( [0] => Array ( [file] => /wecan/cc/cc.sdong.kr/spb3/sadmin/util/svn/spb3_diff.php [line] => 123 [function] => spb_error_handler [args] => Array ( [0] => 2 [1] => Invalid argument supplied for foreach() [2] => /wecan/cc/cc.sdong.kr/spb3/sadmin/util/svn/spb3_diff.php [3] => 123 [4] => Array ( [old] => Array ( [0] => // $Id: class_phemplate.php 13 2010-08-24 08:28:50Z sitehis $ [2] => // 04/05/17 박선민 340L get_var() chanage to same get_var_silent() [3] => // 04/05/17 박선민 696L optional() add and change etc.. [4] => // 05/01/25 박선민 828L drop_var() add recursion for array branches [5] => // 05/11/20 박선민 echoHtml()로 반복하는 sitePHPbasic 마무리 부분 함수로 [6] => // 07/03/18 박선민 {!e.abc} 인경우 urlencoding 등의 기능 추가 [7] => // 07/08/14 박선민 {#widget.???} 윗젯 include 기능 추가 [8] => // 07/09/16 박선민 {#content.keyword} spb3_content 테이블의 keyword에 대한 content가져와서 넣는 기능 추가 [9] => // 08/06/14 박선민 $_GET[html_return] 기능 추가 [10] => // 08/06/28 박선민 831L optional() change 값이 'N'이여도 false되게 [11] => // 08/07/13 박선민 716L // cut_string {#cut.50#0#….key} 기능 추가 [12] => // 08/07/29 박선민 546L // parse() ... IF문 기능 추가 [13] => // 08/10/06 박선민 {#sub.2.3.???} 기능 추가 [14] => // 08/11/08 박선민 #content.??? 기능 개선 [15] => // 08/11/29 박선민 bugfix - don't use &$this [16] => // 09/01/04 박선민 {#widget2.???} 윗젯2 기능 추가(php파일위치에 widget2_???.php를 읽어서 함수 실행 [17] => // 09/02/04 박선민 {!N.list.number} 기능 추가 [18] => // 09/02/06 박선민 GET_DEBUG_2 기능 추가 [19] => // 09/02/25 박선민 {#exp.0.-.key}, server.server.HTTP_REFERER 추가 [20] => // 09/03/11 박선민 {!A.str} javascript에서 변수넘길때 큰따옴표 오류 해결용 [21] => // 09/05/08 박선민 bugfix - GET_DEBUG_2 false였을 때 오류 [22] => // 09/05/31 박선민 {!B.str} table, excel등에서 빈값은  로 변환하여 리턴하도록 [23] => // 09/05/31 박선민 {!?.str} 링크에 ?가 없으면 ?를 붙여주도록 [24] => // 09/07/28 박선민 {!X.name} : xmlspecialchars 변환 기능 추가 [25] => //---------------------------------------------------------------------------// [26] => // author: pukomuko [27] => // date: 2001.03.15 [28] => // web: http://pukomuko.esu.lt [29] => // http://sourceforge.net/projects/phemplate [30] => // info: template engine [31] => //---------------------------------------------------------------------------// [32] => // copyleft license [33] => // [34] => // this software is provided 'as-is', without any express or implied [35] => // warranty. in no event will the authors be held liable for any damages [36] => // arising from the use of this software. [37] => // [38] => // permission is granted to anyone to use this software for any purpose, [39] => // including commercial applications, and to alter it and redistribute it [40] => // freely, subject to the following restrictions: [41] => // [42] => // 1. the origin of this software must not be misrepresented; [43] => // you must not claim that you wrote the original software. [44] => // if you use this software in a product, an acknowledgment [45] => // in the product documentation would be appreciated but is not required. [46] => // [47] => // 2. altered source versions must be plainly marked as such, [48] => // and must not be misrepresented as being the original software. [49] => // [50] => // 3. mail about the fact of using this class in production [51] => // would be very appreciated. [52] => // [53] => // 4. this notice may not be removed or altered from any source distribution. [54] => // [55] => //---------------------------------------------------------------------------// [56] => // changes: [57] => // [58] => // 2004.04.21 [59] => // - warining on empty file [60] => // * v1.10.1 [61] => [62] => /** [63] => */ [64] => define('TPL_LOOP', 1); [65] => define('TPL_NOLOOP', 2); [66] => define('TPL_INCLUDE', 4); [67] => define('TPL_APPEND', 8); [68] => define('TPL_FINISH', 16); [69] => define('TPL_OPTIONAL', 32); [70] => define('TPL_LOOP_INNER_PARSED',64); [71] => define('TPL_LOOP_INNER_OPTIONAL', 128); [72] => [73] => define('TPL_PARSEDLOOP', TPL_LOOP | TPL_LOOP_INNER_PARSED); [74] => define('TPL_OPTLOOP', TPL_PARSEDLOOP | TPL_LOOP_INNER_OPTIONAL); [75] => [76] => [77] => define('TPL_BLOCK', 1); [78] => define('TPL_BLOCKREC', 2); [79] => define('TPL_STRIP_UTF_HEADER', 4); [80] => [81] => class phemplate [82] => { [83] => /** [84] => * 현재 클래스가 있는 드렉토리 By Sunmin [85] => */ [86] => var $widgetPath =''; [87] => [88] => var $read_files = array(); [89] => [90] => /** [91] => * spb3_content에서 읽어온 것을 캐쉬 [92] => */ [93] => var $spb3_content = array(); [94] => [95] => [96] => /** [97] => * variables and blocks [98] => */ [99] => var $vars = array(); [100] => [101] => /** [102] => * loops container [103] => */ [104] => var $loops = array(); [105] => [106] => /** [107] => * dir of template files [108] => */ [109] => var $root = ''; [110] => [111] => /** [112] => * what to do with unknown variables in template? [113] => */ [114] => var $unknowns = 'keep'; [115] => [116] => /** [117] => * default parameters for process() loop, append, finish [118] => */ [119] => var $parameters = 0; [120] => [121] => [122] => /** [123] => * object having method report($level, $msg) [124] => * you can catch error messages from template. [125] => */ [126] => var $error_handler = null; [127] => [128] => [129] => [130] => /** [131] => * start tag for block [132] => */ [133] => var $block_start_string = ''; [134] => [135] => /** [136] => * end tag for block [137] => */ [138] => var $block_end_string = ''; [139] => [140] => /** [141] => * constructor [142] => * $unknows를 keep에서 remove_nonjs로 변경함 by Sunmin Park [143] => */ [144] => function phemplate( $root_dir = '', $unknowns = 'remove_nonjs', $params = 0) [145] => { [146] => // widget, widget2 path [147] => $this->widgetPath = dirname(dirname(__FILE__)).'/widget/'; // By Sunmin [148] => if($this->set_root($root_dir)) [149] => $this->widget2Path = dirname(dirname($this->root)).'/'; // By Sunmin [150] => $this->set_unknowns($unknowns); [151] => $this->set_params($params); [152] => [153] => [154] => [155] => // 기본 set_var by Sunmin [156] => $this->tie_var('SITE' ,$GLOBALS['SITE']); // $SITE 전역변수 [157] => $this->tie_var('get' ,$_GET); [158] => $this->set_var('braces' ,'{'); // 중괄호{braces} 표현 [159] => $this->set_var('nowtime',time()); [160] => [161] => $this->tie_var('session.seUid' ,$_SESSION['seUid']); // 로그인 uid [162] => $this->tie_var('session.seUserid' ,$_SESSION['seUserid']); // 로그인 userid [163] => $this->tie_var('session.seName' ,$_SESSION['seName']); // 로그인 이름 [164] => $this->tie_var('session.seNickname' ,$_SESSION['seNickname']); // 로그인 별명 [165] => $this->tie_var('session.seEmail' ,$_SESSION['seEmail']); [166] => $this->tie_var('session.sePoint' ,$_SESSION['sePoint']); [167] => $this->tie_var('session.seCoupon' ,$_SESSION['seCoupon']); [168] => $this->tie_var('session.sePriv' ,$_SESSION['sePriv']); [169] => [170] => $this->set_var('server.HTTP_HOST' ,$_SERVER['HTTP_HOST']); [171] => $this->set_var('server.HTTP_REFERER',$_SERVER['HTTP_REFERER']); [172] => $this->set_var('server.QUERY_STRING' ,$_SERVER['QUERY_STRING']); [173] => $this->set_var('server.REQUEST_URI' ,$_SERVER['REQUEST_URI']); [174] => $this->set_var('server.PHP_SELF' ,$_SERVER['PHP_SELF']); [175] => } [176] => [177] => /** [178] => substitute text and returns parsed string [179] => @author ZaZa (Sergej Kurakin) 2003.05.05 21:52 [180] => */ [181] => function parse($string) [182] => { [183] => $str = explode('{', $string); [184] => [185] => $res = ''; [186] => [187] => for ($i = 0; isset($str[$i]); $i++) [188] => { [189] => $line = explode('}', $str[$i]); [190] => if ($i === 0) [191] => { [192] => $res .= $line[0]; [193] => } [194] => else [195] => { [196] => $key = $line[0]; [197] => unset($line[0]); [198] => [199] => if ( $key && isset($this->vars[$key]) ) [200] => { [201] => $res .= $this->vars[$key].implode('}', $line); [202] => } [203] => else [204] => { [205] => // {!d.list.rdate} 등 By Sunmin [206] => if($key[0]=='!') { // and isset($this->vars[substr($key,3)])) { [207] => switch(substr($key,1,2)) { [208] => /** [209] => ** 대소문자 구분함 [210] => {!B.name} : 값이 없으면   [211] => {!b.name} : 문장에서 엔터를
로 변환함 [212] => {!S.name} : 문장에서 html 테그를 모두 제거하고, 엔터는
로 변환함 [213] => [214] => {!a.name} : '\' addslashes 삽입 [215] => {!A.name} : javascript에서 변수넘길때 funcname('{!A.str}') [216] => {!s.name} : addslashes된 것을 stripcslashes함 [217] => {!?.name} : 문자열 중간 혹은 끝에 ?가 없으면 맨뒤에 ?를 붙여줌 [218] => [219] => {!h.name} : HTML특수문자로 변환( 큰따옴표도 변환 ) [220] => {!H.name} : HTML특수문자로 변환( 큰따옴표는 그대로 나둠) [221] => {!x.name} : stripcslashes함 하고 HTML특수문자로 변환( 큰따옴표도 변환) [222] => {!X.name} : xmlspecialchars 변환 [223] => [224] => {!e.url} : URL ENCODE [225] => [226] => {!n.price} : 숫자에 콤마 추가(단, 값이 없으면 무조건 '0' 리턴) [227] => {!N.price} : 숫자에 콤마 추가(단, ''값이면 빈값으로 리턴 [228] => [229] => {!D.rdate} : 숫자날짜를 YYYY-MM-DD로 변환 (연도가 4자리) [230] => {!d.rdate} : 숫자날짜를 YY-MM-DD로 변환 (연도가 2자리) [231] => {!T.rdate} : 숫자날짜를 YY-MM-DD H:i:s로 변환 (ex, 2009-01-01 23:59:55) [232] => {!t.rdate} : 숫자날짜를 시간인 H:i:s로 변환 (ex, 23:59:55) [233] => {!g.rdate} : 숫자날짜를 국제표준 한국시간으로 'D, j M Y G:i:s +0900' [234] => **/ [235] => case 'B.': [236] => if(empty($this->vars[substr($key,3)]) and $this->vars[substr($key,3)]!="0") [237] => $res .= ' '.implode('}', $line); [238] => else $res .= $this->vars[substr($key,3)].implode('}', $line); [239] => continue 2; [240] => break; [241] => case 'b.': [242] => $res .= nl2br($this->vars[substr($key,3)]).implode('}', $line); [243] => continue 2; [244] => break; [245] => case 'S.': // strip_tags(),
tag취환 [246] => $res .= ereg_replace("(\r\n|\n|\r)", '
',strip_tags($this->vars[substr($key,3)])).implode('}', $line); [247] => continue 2; [248] => break; [249] => case 'a.': [250] => $res .= addslashes($this->vars[substr($key,3)]).implode('}', $line); [251] => continue 2; [252] => break; [253] => case 'A.': [254] => $res .= str_replace('\\"','"',addslashes($this->vars[substr($key,3)])).implode('}', $line); [255] => continue 2; [256] => break; [257] => case 's.': [258] => $res .= stripcslashes($this->vars[substr($key,3)]).implode('}', $line); [259] => continue 2; [260] => break; [261] => case '?.': [262] => if(false===strpos($this->vars[substr($key,3)],'?')) [263] => $res .= $this->vars[substr($key,3)].'?'.implode('}', $line); [264] => else [265] => $res .= $this->vars[substr($key,3)].implode('}', $line); [266] => continue 2; [267] => break; [268] => case 'h.': [269] => $res .= htmlspecialchars($this->vars[substr($key,3)],ENT_QUOTES).implode('}', $line); [270] => continue 2; [271] => break; [272] => case 'H.': [273] => $res .= htmlspecialchars($this->vars[substr($key,3)],ENT_NOQUOTES).implode('}', $line); [274] => continue 2; [275] => break; [276] => case 'x.': [277] => $res .= htmlspecialchars(stripcslashes($this->vars[substr($key,3)]),ENT_QUOTES).implode('}', $line); [278] => continue 2; [279] => break; [280] => case 'X.': [281] => $res .= str_replace(''', ''', htmlspecialchars($this->vars[substr($key,3)], ENT_QUOTES)).implode('}', $line); [282] => continue 2; [283] => break; [284] => case 'e.': [285] => $res .= urlencode($this->vars[substr($key,3)]).implode('}', $line); [286] => continue 2; [287] => break; [288] => case 'n.': [289] => $res .= number_format((int)$this->vars[substr($key,3)]).implode('}', $line); [290] => continue 2; [291] => break; [292] => case 'N.': [293] => if($this->vars[substr($key,3)] or $this->vars[substr($key,3)]==='0' or $this->vars[substr($key,3)]===0) [294] => $res .= number_format($this->vars[substr($key,3)]).implode('}', $line); [295] => else $res .= implode('}', $line); [296] => continue 2; [297] => break; [298] => case 'D.': [299] => if($this->vars[substr($key,3)]) [300] => $res .= date('Y-m-d',$this->vars[substr($key,3)]).implode('}', $line); [301] => else $res .= implode('}', $line); [302] => continue 2; [303] => break; [304] => case 'd.': [305] => if($this->vars[substr($key,3)]) [306] => $res .= date('y-m-d',$this->vars[substr($key,3)]).implode('}', $line); [307] => else $res .= implode('}', $line); [308] => continue 2; [309] => break; [310] => case 'T.': [311] => if($this->vars[substr($key,3)]) [312] => $res .= date('y-m-d H:i:s',$this->vars[substr($key,3)]).implode('}', $line); [313] => else $res .= implode('}', $line); [314] => continue 2; [315] => break; [316] => case 't.': [317] => if($this->vars[substr($key,3)]) [318] => $res .= date('H:i:s',$this->vars[substr($key,3)]).implode('}', $line); [319] => else $res .= implode('}', $line); [320] => continue 2; [321] => break; [322] => case 'g.': [323] => if($this->vars[substr($key,3)]) [324] => $res .= date('D, j M Y G:i:s +0900',$this->vars[substr($key,3)]).implode('}', $line); [325] => else $res .= implode('}', $line); [326] => continue 2; [327] => break; [328] => } [329] => } [330] => [331] => if($key[0]=='#') { [332] => // /spb3/sinc/widget/???.php By Sunmin [333] => if('widget.'==substr($key,1,7)) { [334] => $tmpWidget2 = substr($key,8); [335] => list($tmpWidget,$tmpKey) = explode('.',$tmpWidget2,2); [336] => if(eregi('^[-_a-z0-9]+$',$tmpWidget) and is_file($this->widgetPath . $tmpWidget . '/index.php')) { [337] => @include_once($this->widgetPath .$tmpWidget . '/index.php'); [338] => $func = 'widget_'.$tmpWidget; [339] => $res .= @$func($this,$tmpKey) . implode('}', $line); [340] => continue; [341] => } [342] => } [343] => elseif('widget2.'==substr($key,1,8)) { [344] => $tmpWidget2 = substr($key,9); [345] => list($tmpWidget,$tmpKey) = explode('.',$tmpWidget2,2); [346] => if(eregi('^[-_a-z0-9]+$',$tmpWidget) and is_file($this->widget2Path . 'widget2_'.$tmpWidget . '.php')) { [347] => @include_once($this->widget2Path . 'widget2_'.$tmpWidget . '.php'); [348] => $func = 'widget2_'.$tmpWidget; [349] => $res .= @$func($this,$tmpKey) . implode('}', $line); [350] => continue; [351] => } [352] => }elseif('include.'==substr($key,1,8)) { [353] => $tmpFilename = substr($key,9); [354] => if(is_file($this->root.'/include_'.$tmpFilename.'.html')) { [355] => $res .= @file_get_contents($this->root.'include_'.$tmpFilename.'.html') . implode('}', $line); [356] => } [357] => else $res .= implode('}', $line); [358] => continue; [359] => } [360] => // spb3_content읽어서 keyword에서 content 전송 [361] => elseif('content.'==substr($key,1,8)) { [362] => list($tmp,$tmpKeyword,$tmpContent) = explode('.',$key,3); [363] => if(!$tmpContent) $tmpContent = 'content'; [364] => if(!isset($this->spb3_content[$tmpContent])) { [365] => $this->spb3_content[$tmpContent] = db_resultdata($GLOBALS['SITE']['th'].'cate_content',$tmpContent,'keyword',$tmpKeyword); [366] => } [367] => $res .= $this->spb3_content[$tmpContent] . implode('}', $line); [368] => continue; [369] => } [370] => // cut_string {#cut.50#0#….key} [371] => elseif('cut.'==substr($key,1,4)) { [372] => list($tmp,$tmpCut,$tmpKey) = explode('.',$key,3); [373] => list($tmpCut1,$tmpCut2,$tmpCut3) = explode('#',$tmpCut,3); [374] => if($tmpCut1===NULL) $tmpCut1 = 50; [375] => if($tmpCut2===NULL) $tmpCut2 = 0; [376] => if($tmpCut3===NULL) $tmpCut3 = '…'; [377] => $res .= cut_string($this->vars[$tmpKey],$tmpCut1,$tmpCut2,$tmpCut3).implode('}', $line); [378] => continue; [379] => } [380] => // substr {#sub.2.3.key} [381] => elseif('sub.'==substr($key,1,4)) { [382] => list($tmp,$tmpSub1,$tmpSub2,$tmpKey) = explode('.',$key,4); [383] => $res .= substr($this->vars[$tmpKey],(int)$tmpSub1,(int)$tmpSub2).implode('}', $line); [384] => continue; [385] => } [386] => // explode(split) {#exp.0.-.key} 0번째, -으로 나누어서 [387] => elseif('exp.'==substr($key,1,4)) { [388] => $tmp = explode('.',$key,4); [389] => if(4==count($tmp)) { [390] => $tmp2 = explode($tmp[2],$this->vars[$tmp[3]]); [391] => $res .= $tmp2[$tmp[1]].implode('}', $line); [392] => } [393] => else $res .= implode('}', $line); [394] => continue; [395] => } [396] => } [397] => [398] => switch ($this->unknowns) [399] => { [400] => case "keep": [401] => $res .= '{'.$key; [402] => if (count ($line) > 0) [403] => { [404] => $res .= '}'; [405] => $res .= implode('}', $line); [406] => } [407] => break; [408] => [409] => case "remove": [410] => $res .= implode('', $line); [411] => break; [412] => [413] => case "remove_nonjs": [414] => if (!empty($key) && ((false === strpos($key, ' ')) && (false === strpos($key, "\n")) && (false === strpos($key, "\t")))) [415] => { [416] => $res .= implode('}', $line); [417] => } [418] => else [419] => { [420] => $res .= '{'.$key; [421] => if (count ($line) > 0) [422] => { [423] => $res .= '}'; [424] => $res .= implode('}', $line); [425] => } [426] => } [427] => break; [428] => [429] => case "comment": [430] => $res .= ''.implode('', $line); [431] => break; [432] => [433] => case "space": [434] => $res .= ' '.implode('', $line); [435] => break; [436] => [437] => } [438] => } [439] => } [440] => } [441] => [442] => return $res; [443] => } [444] => [445] => /** [446] => * check and set template root dir [447] => */ [448] => function set_root($root) [449] => { [450] => if (empty($root)) return; [451] => if (!is_dir($root)) [452] => { [453] => $this->error("phemplate::set_root(): 다음 드렉토리가 없습니다 : $root", 'warning'); [454] => return false; [455] => } [456] => [457] => $this->root = realpath($root).'/'; // By Sunmin 05/11/13 [458] => return true; [459] => } [460] => [461] => /** [462] => * what to do with unknown variables in template? [463] => * keep [464] => * remove [465] => * remove_nonjs [466] => * comment [467] => * space [468] => */ [469] => function set_unknowns($unk) [470] => { [471] => $this->unknowns = $unk; [472] => } [473] => [474] => /** [475] => * set default parameters for process() [476] => */ [477] => function set_params($params) [478] => { [479] => $this->parameters = $params; [480] => } [481] => [482] => /** [483] => * read file template into $vars [484] => * @param string $handle - name of handle for file contents [485] => * @param int $blocks - 1 for search, 2 for nested blocks [486] => * [487] => */ [488] => function set_file($handle, $filename = "", $blocks = false) [489] => { [490] => if ($filename == "") [491] => { [492] => $this->error("phemplate::set_file(): 파일이름이 빈값으로 넘어왔습니다 -$handle", 'fatal'); [493] => return false; [494] => } [495] => $this->vars[$handle] = $this->read_file($filename); [496] => if ($blocks & TPL_STRIP_UTF_HEADER) [497] => { [498] => $header = substr($this->vars[$handle], 0, 3); [499] => if ("\xEF\xBB\xBF" == $header) $this->vars[$handle] = substr($this->vars[$handle], 3); [500] => } [501] => if ($blocks) { $this->extract_blocks($handle, $blocks & TPL_BLOCKREC); } [502] => return true; [503] => [504] => } [505] => [506] => [507] => /** [508] => * set handle and value, [509] => * if value is array, all elements will be named: handle.key.subkey [510] => */ [511] => function set_var($var_name, $var_value) [512] => { [513] => if (is_array($var_value)) [514] => { [515] => foreach($var_value as $key=>$value) [516] => { [517] => $this->set_var($var_name . '.' . $key, $value); // recursion for array branches [518] => } [519] => } [520] => else // normal variable [521] => { [522] => $this->vars[$var_name] = $var_value; [523] => } [524] => } [525] => [526] => /** [527] => * tie value with variable [528] => * it's not possible to update array keys, just values [529] => */ [530] => function tie_var($var_name, &$var_value) [531] => { [532] => if (is_array($var_value)) [533] => { [534] => $list = array_keys($var_value); [535] => foreach($list as $key) [536] => { [537] => $this->tie_var($var_name . '.' . $key, $var_value[$key]); // recursion for array branches [538] => } [539] => } [540] => else // normal variable [541] => { [542] => $this->vars[$var_name] =& $var_value; [543] => } [544] => } [545] => [546] => /** [547] => * value of $handle [548] => * raises error if $handle undefined [549] => */ [550] => function get_var($handle) [551] => { [552] => if (!isset($this->vars[$handle])) { [553] => //$this->error("phemplate(): no such handle '$handle'", 'warning'); [554] => return null; // By Sunmin Park 04/05/17 [555] => } [556] => return $this->vars[$handle]; [557] => } [558] => [559] => /** [560] => * value of $handle, no error if no handle [561] => */ [562] => function get_var_silent($handle) [563] => { [564] => if (!isset($this->vars[$handle])) { $this->vars[$handle] = ''; return ''; } [565] => return $this->vars[$handle]; [566] => } [567] => [568] => /** [569] => * assign array to loop handle [570] => * @param string $loop_name - name for a loop [571] => * @param int $loop - loop data [572] => */ [573] => function set_loop($loop_name, $loop) [574] => { [575] => if (!$loop) $loop = 0; [576] => $this->loops[$loop_name] = $loop; [577] => } [578] => [579] => /** [580] => * tie array with loop [581] => */ [582] => function tie_loop($loop_name, &$loop) [583] => { [584] => if (!$loop) $loop = 0; [585] => $this->loops[$loop_name] =& $loop; [586] => } [587] => [588] => /** [589] => * extracts blocks from handle, and returns cleaned up version [590] => * [591] => * must be quite fast, because every found block is imediately taken out of string [592] => * [593] => * [594] => * @since 2001.10.31 works with nested blocks [js] [595] => * @since 2003.06.19 supports customized block syntax [js] [596] => * [597] => */ [598] => function extract_blocks($bl_handle, $recurse = false) [599] => { [600] => [601] => $str = $this->get_var($bl_handle); [602] => if (!$str) return $str; [603] => $bl_start = 0; [604] => [605] => list($bll, $blr) = explode('|', $this->block_start_string); [606] => $strlen = strlen($bll); [607] => [608] => [609] => // find them and clean from parent handle [610] => while(is_long($bl_start = strpos($str, $bll, $bl_start))) [611] => { [612] => $pos = $bl_start + $strlen; [613] => [614] => $endpos = strpos($str, $blr, $pos); [615] => $handle = substr($str, $pos, $endpos-$pos); [616] => [617] => $tag = $bll.$handle.$blr; [618] => $endtag = str_replace('|', $handle, $this->block_end_string); [619] => [620] => $start_pos = $bl_start + strlen($tag); [621] => $end_pos = strpos($str, $endtag, $bl_start); [622] => if (!$end_pos) { $this->error("스킨오류 : </block name=\"$handle\">이 없음", 'fatal'); } [623] => $bl_end = $end_pos + strlen($endtag); [624] => [625] => $block_code = substr($str, $start_pos, $end_pos-$start_pos); [626] => [627] => $this->set_var($handle, $block_code); [628] => [629] => $part1 = substr($str, 0, $bl_start); [630] => $part2 = substr($str, $bl_end, strlen($str)); [631] => [632] => $str = $part1 . $part2; [633] => [634] => if ($recurse) { $this->extract_blocks($handle, 1); } [635] => [636] => } [637] => [638] => $this->set_var($bl_handle, $str); [639] => [640] => } [641] => [642] => [643] => /** [644] => * search for tags in $handle [645] => * be carefull with paths [646] => */ [647] => function include_files($handle) [648] => { [649] => $str = $this->get_var($handle); [650] => [651] => while(is_long($pos = strpos($str, '', $pos); [655] => $filename = substr($str, $pos, $endpos-$pos); [656] => $tag = ''; [657] => [658] => [659] => $include = $this->read_file($filename); [660] => [661] => $str = str_replace($tag, $include, $str); [662] => } [663] => [664] => return $str; [665] => } [666] => [667] => [668] => /** [669] => * searches for all set loops in $handle, returns text of $handle with parsed loops [670] => * @param bool $noloop - must be true, if you want noloop statement [671] => * @return string [672] => */ [673] => function parse_loops($handle, $noloop = false) [674] => { [675] => $str = $this->get_var($handle); [676] => [677] => reset($this->loops); [678] => [679] => while ( list($loop_name, $loop_ar) = each($this->loops) ) [680] => { [681] => [682] => $start_tag = strpos($str, ''); [683] => [684] => $start_pos = $start_tag + strlen(''); [685] => if (!$start_pos) continue; [686] => $end_pos = strpos($str, ''); [687] => [688] => $loop_code = substr($str, $start_pos, $end_pos-$start_pos); [689] => $org_loop_code = $loop_code; [690] => [691] => $start_tag = substr($str, $start_tag, strlen('')); [692] => $end_tag = substr($str, $end_pos, strlen('')); [693] => [694] => if($loop_code != ''){ [695] => [696] => $new_code = ''; [697] => [698] => // clean if ($noloop & TPL_NOLOOP) [700] => { [701] => [702] => $nl_start_tag = strpos($loop_code, ''); [703] => $nl_start_pos = $nl_start_tag + strlen(''); [704] => [705] => [706] => if ($nl_start_pos) [707] => { [708] => [709] => $nl_end_pos = strpos($loop_code, ''); [710] => [711] => $noloop_code = substr($loop_code, $nl_start_pos, $nl_end_pos - $nl_start_pos); [712] => [713] => [714] => $nl_start_tag = substr($loop_code, $nl_start_tag, strlen('')); [715] => $nl_end_tag = substr($loop_code, $nl_end_pos, strlen('')); [716] => $loop_code = str_replace($nl_start_tag.$noloop_code.$nl_end_tag, '', $loop_code); [717] => } [718] => [719] => } [720] => [721] => if (is_array($loop_ar)) [722] => { [723] => [724] => if ($noloop & TPL_LOOP_INNER_PARSED) [725] => { [726] => for($i = 0; isset($loop_ar[$i]); $i++) [727] => [728] => { [729] => $temp_code = $loop_code; [730] => // rememeber loop variables [731] => [732] => $array_keys = array_keys($loop_ar[$i]); [733] => $this->set_var($loop_name, $loop_ar[$i]); [734] => if ($noloop & TPL_LOOP_INNER_OPTIONAL) $temp_code = $this->optional($loop_code); [735] => $temp_code = $this->parse($temp_code); [736] => $new_code .= $temp_code; [737] => [738] => // cleanup loop variables for next generation [739] => foreach ($array_keys as $key) unset($this->vars[$loop_name.'.'.$key]); [740] => [741] => } // for loop [742] => } [743] => else [744] => { [745] => // repeat for every row in array [746] => // for (reset($loop_ar); $row = current($loop_ar); next($loop_ar)) [747] => $ar_keys = array_keys($loop_ar); [748] => $ar_size = count($ar_keys); [749] => for($i = 0; ($i< $ar_size); $i++) [750] => { [751] => $temp_code = $loop_code; [752] => [753] => foreach( $loop_ar[$ar_keys[$i]] as $k=>$v) [754] => { [755] => $temp_code = str_replace( '{'. $loop_name. '.' .$k. '}', $v, $temp_code); [756] => } [757] => $new_code .= $temp_code; [758] => } [759] => } [760] => } elseif ($noloop & TPL_NOLOOP) [761] => { [762] => $new_code = $noloop_code; [763] => } [764] => [765] => [766] => $str = str_replace($start_tag.$org_loop_code.$end_tag, $new_code, $str); [767] => } // if loop code [768] => [769] => } // repeat for loop names [770] => [771] => return $str; [772] => } [773] => [774] => [775] => /** [776] => * process left variables [777] => * @deprecated parse() now handles unknown variables [778] => */ [779] => function finish($str) [780] => { [781] => switch ($this->unknowns) [782] => { [783] => case "keep": [784] => break; [785] => [786] => case "remove": [787] => $str = preg_replace('/{[^ \t\r\n}]+}/', "", $str); [788] => break; [789] => [790] => case "comment": [791] => $str = preg_replace('/{([^ \t\r\n}]+)}/', "", $str); [792] => break; [793] => [794] => case "space": [795] => $str = preg_replace('/{([^ \t\r\n}]+)}/', " ", $str); [796] => break; [797] => [798] => } [799] => [800] => return $str; [801] => } [802] => [803] => /** [804] => * search for optional tag [805] => * @param string $str text [806] => * @return string [807] => */ [808] => function optional($str) [809] => { [810] => $bl_start = 0; [811] => [812] => // extract and clean them from parent handle [813] => while(is_long($bl_start = strpos($str, '', $pos); [818] => $varname = substr($str, $pos, $endpos-$pos); [819] => [820] => $tag = ''; [821] => $endtag = ''; [822] => [823] => $end_pos = strpos($str, $endtag, $bl_start); [824] => if (!$end_pos) { $this->error("스킨오류 <opt name=\"$varname\">가 없음", 'fatal'); } [825] => [826] => $bl_end = $end_pos + strlen($endtag); [827] => [828] => [829] => $part1 = substr($str, 0, $bl_start); [830] => $part2 = substr($str, $bl_end, strlen($str)); [831] => [832] => // if .. by Sunmin Park [833] => if($varname[0]=="!") [834] => { [835] => $varname = substr($varname, 1); [836] => $flag = true; [837] => } [838] => else $flag = false; [839] => [840] => // .. By Sunmin Park [841] => if(strpos($varname,'=')) { [842] => list($varname,$varname_value) = explode('=',$varname,2); [843] => [844] => $value = $this->get_var_silent($varname); [845] => //echo " $value == $varname_value ";exit; [846] => if($value == $varname_value) { [847] => $flag = !$flag; [848] => } [849] => } [850] => else { [851] => $value = $this->get_var_silent($varname); [852] => [853] => //if ($value || $value === 0 || $value === '0') [854] => if ($value and $value !== 'N') [855] => { [856] => $flag = !$flag; [857] => } [858] => } [859] => [860] => if($flag) [861] => { [862] => $start_pos = $bl_start + strlen($tag); [863] => [864] => $block_code = substr($str, $start_pos, $end_pos-$start_pos); [865] => [866] => $str = $part1 . $this->parse($block_code) . $part2; [867] => } [868] => else [869] => { [870] => $str = $part1 . $part2; [871] => } [872] => } [873] => [874] => return $str; [875] => } [876] => [877] => /** [878] => * does everything: loops, includes, variables, concatenation [879] => * if $loop is 0 (not false, but 0) default parameters are used [880] => * thanks ShiVAs for idea to have $loop as parameters. [881] => * [882] => * @param $loop - loop, noloop or all parameters ored. [883] => * @param $append - append processed stuff to target, else $target is overwritten [884] => * @return string [885] => */ [886] => function process($target, $handle, $loop = false, $include = false, $append = false, $finish = false, $optional = false) [887] => { [888] => if ($loop === 0) $loop = $this->parameters; [889] => [890] => $noloop = false; [891] => $parsedloop = false; [892] => $loopopt = false; [893] => if ($loop > 2) [894] => { [895] => $noloop = $loop & TPL_NOLOOP; [896] => $include = $loop & TPL_INCLUDE; [897] => $append = $loop & TPL_APPEND; [898] => $finish = $loop & TPL_FINISH; [899] => $optional = $loop & TPL_OPTIONAL; [900] => $parsedloop = $loop & TPL_LOOP_INNER_PARSED; [901] => $loopopt = $loop & TPL_LOOP_INNER_OPTIONAL; [902] => } [903] => else [904] => { [905] => $noloop = $loop & TPL_NOLOOP; [906] => } [907] => [908] => if ($append) { [909] => if (isset($this->vars[$target])) { [910] => $app = $this->get_var($target); // preserve old info [911] => $this->set_var($target.'.count', $tmp=$this->get_var($target.'.count')+1); // by sunmin (append count) [912] => $this->set_var($target.'.countodd', $tmp%2 ); // by sunmin (append count) [913] => } [914] => else { [915] => $app = ''; [916] => $this->set_var($target.'.count', 1); // by sunmin (append count) [917] => $this->set_var($target.'.countodd', 1); // by sunmin (append count) [918] => } [919] => } [920] => [921] => $this->set_var($target, $this->get_var($handle)); // copy contents [922] => [923] => if ($include) { $this->set_var($target, $this->include_files($target)); } [924] => [925] => [926] => if ($noloop) { $this->set_var($target, $this->parse_loops($target, TPL_NOLOOP | $loopopt | $parsedloop)); } [927] => elseif ($loop) { $this->set_var($target, $this->parse_loops($target, $loopopt | $parsedloop)); } [928] => [929] => if ($optional) { $this->set_var($target, $this->optional($this->get_var_silent($target))); } [930] => [931] => if ($append) { $this->set_var($target, $app . $this->parse($this->get_var_silent($target))); } [932] => else { $this->set_var($target, $this->parse($this->get_var($target))); } [933] => [934] => if ($finish) { $this->set_var($target, $this->finish($this->get_var($target))); } [935] => [936] => return $this->get_var($target); [937] => } [938] => [939] => [940] => /** [941] => * spits out file contents [942] => * @access private [943] => */ [944] => function read_file($file) [945] => { [946] => $filename = $this->root . $file; [947] => [948] => if (!file_exists($filename)) [949] => { [950] => $this->error("phemplate::read_file(): 파일이 없음 - $filename", 'fatal'); [951] => return ''; [952] => } [953] => [954] => $tmp = false; [955] => [956] => $filesize = filesize($filename); [957] => if ($filesize) [958] => { [959] => $tmp = fread($fp = fopen($filename, 'r'), $filesize); [960] => fclose($fp); [961] => [962] => $this->read_files[]= $filename; [963] => } [964] => return $tmp; [965] => } [966] => [967] => /** [968] => * free mem used by loop [969] => */ [970] => function drop_loop($loop_handle) [971] => { [972] => if (isset($this->loops[$loop_handle])) unset($this->loops[$loop_handle]); [973] => } [974] => [975] => [976] => /** [977] => * free mem used by var [978] => */ [979] => function drop_var($handle,$var_value='') [980] => { [981] => if (is_array($var_value)) { // by Sunmin Park [982] => foreach($var_value as $key=>$value) [983] => $this->drop_var($handle.'.'.$key,$value); // recursion for array branches [984] => } [985] => elseif (isset($this->vars[$handle])) unset($this->vars[$handle]); [986] => } [987] => [988] => /** [989] => * set error handler [990] => */ [991] => function set_error_handler(&$eh) [992] => { [993] => $this->error_handler =& $eh; [994] => } [995] => [996] => /** [997] => * change block syntax [998] => */ [999] => function set_block_syntax($start, $end) [1000] => { [1001] => if (!strpos($start, '|')) $this->error("phemplate::set_block_syntax(): no '|' in start tag", 'fatal'); [1002] => if (!strpos($end, '|')) $this->error("phemplate::set_block_syntax(): no '|' in end tag", 'fatal'); [1003] => $this->block_start_string = $start; [1004] => $this->block_end_string = $end; [1005] => } [1006] => [1007] => /** [1008] => * error report [1009] => */ [1010] => function error( $msg, $level = '') [1011] => { [1012] => if (isset($this->error_handler)) [1013] => { [1014] => $lvl = E_USER_WARNING; [1015] => if ('fatal' == $level) $lvl = E_USER_ERROR; [1016] => $this->error_handler->report($lvl, $msg); [1017] => } [1018] => else [1019] => { [1020] => echo "\n
$level: $msg
\n"; [1021] => if ('fatal' == $level) { exit; } [1022] => } [1023] => } [1024] => [1025] => /** [1026] => * SitePHPbasic 반복하는 echoHtml [1027] => * By Sunmin Park 06/07/23 [1028] => */ [1029] => function echoHtml( &$dbinfo, &$SITE, $thisUrl='' ) { [1030] => $val='\\1'.$thisUrl.'skin/'.$dbinfo['skin'].'/images/'; [1031] => // - 사이트 템플릿 읽어오기 [1032] => if(ereg('^(ht|h|t)$',$dbinfo['html_type'])) { [1033] => $HEADER = array ('html_skin'=>$dbinfo['html_skin']); [1034] => @include($SITE['html_path'].'skin.php'); // retrun $aBody[0],$aBody[1] [1035] => } [1036] => [1037] => $html = ''; [1038] => switch($dbinfo['html_type']) { [1039] => case 'ht': [1040] => $html = $aBody[0]; [1041] => $html .= $dbinfo['html_head']; [1042] => $html .= ereg_replace('([="\'(])images/',$val,$this->process('', 'html',TPL_OPTIONAL)); [1043] => $html .= $dbinfo['html_tail']; [1044] => $html .= $aBody[1]; [1045] => break; [1046] => case 'h': [1047] => $html .= $aBody[0] ; [1048] => $html .= $dbinfo['html_head']; [1049] => $html .= ereg_replace('([="\'(])images/',$val,$this->process('', 'html',TPL_OPTIONAL)); [1050] => $html .= $dbinfo['html_tail']; [1051] => break; [1052] => case 't': [1053] => $html .= $dbinfo['html_head']; [1054] => $html .= ereg_replace('([="\'(])images/',$val,$this->process('', 'html',TPL_OPTIONAL)); [1055] => $html .= $dbinfo['html_tail'] ; [1056] => $html .= $aBody[1]; [1057] => break; [1058] => case 'no': [1059] => $html .= ereg_replace('([="\'(])images/',$val,$this->process('', 'html',TPL_OPTIONAL)); [1060] => break; [1061] => default: [1062] => $html .= $dbinfo['html_head']; [1063] => $html .= ereg_replace('([="\'(])images/',$val,$this->process('', 'html',TPL_OPTIONAL)); [1064] => $html .= $dbinfo['html_tail']; [1065] => } // end switch [1066] => [1067] => /* [1068] => if($_GET['utf8']=='euc-kr') { [1069] => // iconv 버그로 인해서 "\n"로 나눔 [1070] => $aA =explode("\n",$html); [1071] => $html =''; [1072] => foreach($aA as $v) $html .= iconv("euc-kr", "UTF-8",$v); [1073] => } [1074] => */ [1075] => [1076] => if($_GET['html_return']) $_GET['html']=$html; [1077] => else echo $html; [1078] => [1079] => // debug 출력 [1080] => if(defined('GET_DEBUG_2') and GET_DEBUG_2) { [1081] => echo "
"; [1082] => echo "skin : $dbinfo[skin], html_type: $dbinfo[html_type], html_skin: $dbinfo[html_skin]
thisUrl:$thisUrl "; [1083] => if('/spb3/sboard3/'==$thisUrl) { [1084] => echo " [게시판수정]"; [1085] => if($_GET['cateuid']) { [1086] => echo " [카테고리수정]"; [1087] => } [1088] => } [1089] => if($dbinfo['table']) { [1090] => echo " [$dbinfo[table]]"; [1091] => } [1092] => echo "
"; [1093] => if(count($this->read_files)) { [1094] => foreach($this->read_files as $filepath) { [1095] => if(strpos($filepath,$_SERVER['DOCUMENT_ROOT'])!==false) { [1096] => $url = substr($filepath,strlen($_SERVER['DOCUMENT_ROOT'])); [1097] => echo "skin file : $url
"; [1098] => } [1099] => else echo "skin file : $filepath
"; [1100] => } [1101] => } [1102] => //echo '
dbinfo ';var_export($dbinfo);

                                            [1103] => 			//echo '
'; [1104] => echo '
'; [1105] => } [1106] => } [1107] => } [1108] => ?> ) [new] => [ovalue] => 0 [nkeys] => ) ) ) [1] => Array ( [file] => /wecan/cc/cc.sdong.kr/spb3/sadmin/util/svn/spb3_diff.php [line] => 142 [function] => doDiff [class] => diff [object] => diff Object ( [changes] => Array ( ) [diff] => Array ( ) [linepadding] => 2 ) [type] => -> [args] => Array ( [0] => /wecan/cc/cc.sdong.kr/spb3/sinc/lib/class_phemplate.php [1] => ) ) [2] => Array ( [file] => /wecan/cc/cc.sdong.kr/spb3/sadmin/util/svn/spb3_diff.php [line] => 197 [function] => diffWrap [class] => diff [object] => diff Object ( [changes] => Array ( ) [diff] => Array ( ) [linepadding] => 2 ) [type] => -> [args] => Array ( [0] => /wecan/cc/cc.sdong.kr/spb3/sinc/lib/class_phemplate.php [1] => ) ) [3] => Array ( [file] => /wecan/cc/cc.sdong.kr/spb3/sadmin/util/svn/spb3_diff.php [line] => 92 [function] => inline [class] => diff [object] => diff Object ( [changes] => Array ( ) [diff] => Array ( ) [linepadding] => 2 ) [type] => -> [args] => Array ( [0] => /wecan/cc/cc.sdong.kr/spb3/sinc/lib/class_phemplate.php [1] => [2] => 2 ) ) ) [key] => 3 [value] => Array ( [file] => /wecan/cc/cc.sdong.kr/spb3/sadmin/util/svn/spb3_diff.php [line] => 92 [function] => inline [class] => diff [object] => diff Object ( [changes] => Array ( ) [diff] => Array ( ) [linepadding] => 2 ) [type] => -> [args] => Array ( [0] => /wecan/cc/cc.sdong.kr/spb3/sinc/lib/class_phemplate.php [1] => [2] => 2 ) ) )
sitePHPbasic 디버그 모드 : WARNING
[2] array_keys() expects parameter 1 to be array, boolean given
Line : 122 (file:/wecan/cc/cc.sdong.kr/spb3/sadmin/util/svn/spb3_diff.php)
- 디버그 추적(debug_backtrace)
#0 spb_error_handler() 함수사용, line(),
#1 array_keys() 함수사용, line(122), /wecan/cc/cc.sdong.kr/spb3/sadmin/util/svn/spb3_diff.php
#2 doDiff() 함수사용, line(142), /wecan/cc/cc.sdong.kr/spb3/sadmin/util/svn/spb3_diff.php
#3 diffWrap() 함수사용, line(197), /wecan/cc/cc.sdong.kr/spb3/sadmin/util/svn/spb3_diff.php
#4 inline() 함수사용, line(92), /wecan/cc/cc.sdong.kr/spb3/sadmin/util/svn/spb3_diff.php




사용변수들 ...
$_GET = Array ( [md5_path] => /spb3/sinc/lib/class_phemplate.php ) $_POST = Array ( ) $_COOKIE = Array ( ) Array ( [errno] => 2 [errstr] => array_keys() expects parameter 1 to be array, boolean given [errfile] => /wecan/cc/cc.sdong.kr/spb3/sadmin/util/svn/spb3_diff.php [errline] => 122 [arr] => Array ( [0] => Array ( [function] => spb_error_handler [args] => Array ( [0] => 2 [1] => array_keys() expects parameter 1 to be array, boolean given [2] => /wecan/cc/cc.sdong.kr/spb3/sadmin/util/svn/spb3_diff.php [3] => 122 [4] => Array ( [old] => Array ( [0] => // $Id: class_phemplate.php 13 2010-08-24 08:28:50Z sitehis $ [2] => // 04/05/17 박선민 340L get_var() chanage to same get_var_silent() [3] => // 04/05/17 박선민 696L optional() add and change etc.. [4] => // 05/01/25 박선민 828L drop_var() add recursion for array branches [5] => // 05/11/20 박선민 echoHtml()로 반복하는 sitePHPbasic 마무리 부분 함수로 [6] => // 07/03/18 박선민 {!e.abc} 인경우 urlencoding 등의 기능 추가 [7] => // 07/08/14 박선민 {#widget.???} 윗젯 include 기능 추가 [8] => // 07/09/16 박선민 {#content.keyword} spb3_content 테이블의 keyword에 대한 content가져와서 넣는 기능 추가 [9] => // 08/06/14 박선민 $_GET[html_return] 기능 추가 [10] => // 08/06/28 박선민 831L optional() change 값이 'N'이여도 false되게 [11] => // 08/07/13 박선민 716L // cut_string {#cut.50#0#….key} 기능 추가 [12] => // 08/07/29 박선민 546L // parse() ... IF문 기능 추가 [13] => // 08/10/06 박선민 {#sub.2.3.???} 기능 추가 [14] => // 08/11/08 박선민 #content.??? 기능 개선 [15] => // 08/11/29 박선민 bugfix - don't use &$this [16] => // 09/01/04 박선민 {#widget2.???} 윗젯2 기능 추가(php파일위치에 widget2_???.php를 읽어서 함수 실행 [17] => // 09/02/04 박선민 {!N.list.number} 기능 추가 [18] => // 09/02/06 박선민 GET_DEBUG_2 기능 추가 [19] => // 09/02/25 박선민 {#exp.0.-.key}, server.server.HTTP_REFERER 추가 [20] => // 09/03/11 박선민 {!A.str} javascript에서 변수넘길때 큰따옴표 오류 해결용 [21] => // 09/05/08 박선민 bugfix - GET_DEBUG_2 false였을 때 오류 [22] => // 09/05/31 박선민 {!B.str} table, excel등에서 빈값은  로 변환하여 리턴하도록 [23] => // 09/05/31 박선민 {!?.str} 링크에 ?가 없으면 ?를 붙여주도록 [24] => // 09/07/28 박선민 {!X.name} : xmlspecialchars 변환 기능 추가 [25] => //---------------------------------------------------------------------------// [26] => // author: pukomuko [27] => // date: 2001.03.15 [28] => // web: http://pukomuko.esu.lt [29] => // http://sourceforge.net/projects/phemplate [30] => // info: template engine [31] => //---------------------------------------------------------------------------// [32] => // copyleft license [33] => // [34] => // this software is provided 'as-is', without any express or implied [35] => // warranty. in no event will the authors be held liable for any damages [36] => // arising from the use of this software. [37] => // [38] => // permission is granted to anyone to use this software for any purpose, [39] => // including commercial applications, and to alter it and redistribute it [40] => // freely, subject to the following restrictions: [41] => // [42] => // 1. the origin of this software must not be misrepresented; [43] => // you must not claim that you wrote the original software. [44] => // if you use this software in a product, an acknowledgment [45] => // in the product documentation would be appreciated but is not required. [46] => // [47] => // 2. altered source versions must be plainly marked as such, [48] => // and must not be misrepresented as being the original software. [49] => // [50] => // 3. mail about the fact of using this class in production [51] => // would be very appreciated. [52] => // [53] => // 4. this notice may not be removed or altered from any source distribution. [54] => // [55] => //---------------------------------------------------------------------------// [56] => // changes: [57] => // [58] => // 2004.04.21 [59] => // - warining on empty file [60] => // * v1.10.1 [61] => [62] => /** [63] => */ [64] => define('TPL_LOOP', 1); [65] => define('TPL_NOLOOP', 2); [66] => define('TPL_INCLUDE', 4); [67] => define('TPL_APPEND', 8); [68] => define('TPL_FINISH', 16); [69] => define('TPL_OPTIONAL', 32); [70] => define('TPL_LOOP_INNER_PARSED',64); [71] => define('TPL_LOOP_INNER_OPTIONAL', 128); [72] => [73] => define('TPL_PARSEDLOOP', TPL_LOOP | TPL_LOOP_INNER_PARSED); [74] => define('TPL_OPTLOOP', TPL_PARSEDLOOP | TPL_LOOP_INNER_OPTIONAL); [75] => [76] => [77] => define('TPL_BLOCK', 1); [78] => define('TPL_BLOCKREC', 2); [79] => define('TPL_STRIP_UTF_HEADER', 4); [80] => [81] => class phemplate [82] => { [83] => /** [84] => * 현재 클래스가 있는 드렉토리 By Sunmin [85] => */ [86] => var $widgetPath =''; [87] => [88] => var $read_files = array(); [89] => [90] => /** [91] => * spb3_content에서 읽어온 것을 캐쉬 [92] => */ [93] => var $spb3_content = array(); [94] => [95] => [96] => /** [97] => * variables and blocks [98] => */ [99] => var $vars = array(); [100] => [101] => /** [102] => * loops container [103] => */ [104] => var $loops = array(); [105] => [106] => /** [107] => * dir of template files [108] => */ [109] => var $root = ''; [110] => [111] => /** [112] => * what to do with unknown variables in template? [113] => */ [114] => var $unknowns = 'keep'; [115] => [116] => /** [117] => * default parameters for process() loop, append, finish [118] => */ [119] => var $parameters = 0; [120] => [121] => [122] => /** [123] => * object having method report($level, $msg) [124] => * you can catch error messages from template. [125] => */ [126] => var $error_handler = null; [127] => [128] => [129] => [130] => /** [131] => * start tag for block [132] => */ [133] => var $block_start_string = ''; [134] => [135] => /** [136] => * end tag for block [137] => */ [138] => var $block_end_string = ''; [139] => [140] => /** [141] => * constructor [142] => * $unknows를 keep에서 remove_nonjs로 변경함 by Sunmin Park [143] => */ [144] => function phemplate( $root_dir = '', $unknowns = 'remove_nonjs', $params = 0) [145] => { [146] => // widget, widget2 path [147] => $this->widgetPath = dirname(dirname(__FILE__)).'/widget/'; // By Sunmin [148] => if($this->set_root($root_dir)) [149] => $this->widget2Path = dirname(dirname($this->root)).'/'; // By Sunmin [150] => $this->set_unknowns($unknowns); [151] => $this->set_params($params); [152] => [153] => [154] => [155] => // 기본 set_var by Sunmin [156] => $this->tie_var('SITE' ,$GLOBALS['SITE']); // $SITE 전역변수 [157] => $this->tie_var('get' ,$_GET); [158] => $this->set_var('braces' ,'{'); // 중괄호{braces} 표현 [159] => $this->set_var('nowtime',time()); [160] => [161] => $this->tie_var('session.seUid' ,$_SESSION['seUid']); // 로그인 uid [162] => $this->tie_var('session.seUserid' ,$_SESSION['seUserid']); // 로그인 userid [163] => $this->tie_var('session.seName' ,$_SESSION['seName']); // 로그인 이름 [164] => $this->tie_var('session.seNickname' ,$_SESSION['seNickname']); // 로그인 별명 [165] => $this->tie_var('session.seEmail' ,$_SESSION['seEmail']); [166] => $this->tie_var('session.sePoint' ,$_SESSION['sePoint']); [167] => $this->tie_var('session.seCoupon' ,$_SESSION['seCoupon']); [168] => $this->tie_var('session.sePriv' ,$_SESSION['sePriv']); [169] => [170] => $this->set_var('server.HTTP_HOST' ,$_SERVER['HTTP_HOST']); [171] => $this->set_var('server.HTTP_REFERER',$_SERVER['HTTP_REFERER']); [172] => $this->set_var('server.QUERY_STRING' ,$_SERVER['QUERY_STRING']); [173] => $this->set_var('server.REQUEST_URI' ,$_SERVER['REQUEST_URI']); [174] => $this->set_var('server.PHP_SELF' ,$_SERVER['PHP_SELF']); [175] => } [176] => [177] => /** [178] => substitute text and returns parsed string [179] => @author ZaZa (Sergej Kurakin) 2003.05.05 21:52 [180] => */ [181] => function parse($string) [182] => { [183] => $str = explode('{', $string); [184] => [185] => $res = ''; [186] => [187] => for ($i = 0; isset($str[$i]); $i++) [188] => { [189] => $line = explode('}', $str[$i]); [190] => if ($i === 0) [191] => { [192] => $res .= $line[0]; [193] => } [194] => else [195] => { [196] => $key = $line[0]; [197] => unset($line[0]); [198] => [199] => if ( $key && isset($this->vars[$key]) ) [200] => { [201] => $res .= $this->vars[$key].implode('}', $line); [202] => } [203] => else [204] => { [205] => // {!d.list.rdate} 등 By Sunmin [206] => if($key[0]=='!') { // and isset($this->vars[substr($key,3)])) { [207] => switch(substr($key,1,2)) { [208] => /** [209] => ** 대소문자 구분함 [210] => {!B.name} : 값이 없으면   [211] => {!b.name} : 문장에서 엔터를
로 변환함 [212] => {!S.name} : 문장에서 html 테그를 모두 제거하고, 엔터는
로 변환함 [213] => [214] => {!a.name} : '\' addslashes 삽입 [215] => {!A.name} : javascript에서 변수넘길때 funcname('{!A.str}') [216] => {!s.name} : addslashes된 것을 stripcslashes함 [217] => {!?.name} : 문자열 중간 혹은 끝에 ?가 없으면 맨뒤에 ?를 붙여줌 [218] => [219] => {!h.name} : HTML특수문자로 변환( 큰따옴표도 변환 ) [220] => {!H.name} : HTML특수문자로 변환( 큰따옴표는 그대로 나둠) [221] => {!x.name} : stripcslashes함 하고 HTML특수문자로 변환( 큰따옴표도 변환) [222] => {!X.name} : xmlspecialchars 변환 [223] => [224] => {!e.url} : URL ENCODE [225] => [226] => {!n.price} : 숫자에 콤마 추가(단, 값이 없으면 무조건 '0' 리턴) [227] => {!N.price} : 숫자에 콤마 추가(단, ''값이면 빈값으로 리턴 [228] => [229] => {!D.rdate} : 숫자날짜를 YYYY-MM-DD로 변환 (연도가 4자리) [230] => {!d.rdate} : 숫자날짜를 YY-MM-DD로 변환 (연도가 2자리) [231] => {!T.rdate} : 숫자날짜를 YY-MM-DD H:i:s로 변환 (ex, 2009-01-01 23:59:55) [232] => {!t.rdate} : 숫자날짜를 시간인 H:i:s로 변환 (ex, 23:59:55) [233] => {!g.rdate} : 숫자날짜를 국제표준 한국시간으로 'D, j M Y G:i:s +0900' [234] => **/ [235] => case 'B.': [236] => if(empty($this->vars[substr($key,3)]) and $this->vars[substr($key,3)]!="0") [237] => $res .= ' '.implode('}', $line); [238] => else $res .= $this->vars[substr($key,3)].implode('}', $line); [239] => continue 2; [240] => break; [241] => case 'b.': [242] => $res .= nl2br($this->vars[substr($key,3)]).implode('}', $line); [243] => continue 2; [244] => break; [245] => case 'S.': // strip_tags(),
tag취환 [246] => $res .= ereg_replace("(\r\n|\n|\r)", '
',strip_tags($this->vars[substr($key,3)])).implode('}', $line); [247] => continue 2; [248] => break; [249] => case 'a.': [250] => $res .= addslashes($this->vars[substr($key,3)]).implode('}', $line); [251] => continue 2; [252] => break; [253] => case 'A.': [254] => $res .= str_replace('\\"','"',addslashes($this->vars[substr($key,3)])).implode('}', $line); [255] => continue 2; [256] => break; [257] => case 's.': [258] => $res .= stripcslashes($this->vars[substr($key,3)]).implode('}', $line); [259] => continue 2; [260] => break; [261] => case '?.': [262] => if(false===strpos($this->vars[substr($key,3)],'?')) [263] => $res .= $this->vars[substr($key,3)].'?'.implode('}', $line); [264] => else [265] => $res .= $this->vars[substr($key,3)].implode('}', $line); [266] => continue 2; [267] => break; [268] => case 'h.': [269] => $res .= htmlspecialchars($this->vars[substr($key,3)],ENT_QUOTES).implode('}', $line); [270] => continue 2; [271] => break; [272] => case 'H.': [273] => $res .= htmlspecialchars($this->vars[substr($key,3)],ENT_NOQUOTES).implode('}', $line); [274] => continue 2; [275] => break; [276] => case 'x.': [277] => $res .= htmlspecialchars(stripcslashes($this->vars[substr($key,3)]),ENT_QUOTES).implode('}', $line); [278] => continue 2; [279] => break; [280] => case 'X.': [281] => $res .= str_replace(''', ''', htmlspecialchars($this->vars[substr($key,3)], ENT_QUOTES)).implode('}', $line); [282] => continue 2; [283] => break; [284] => case 'e.': [285] => $res .= urlencode($this->vars[substr($key,3)]).implode('}', $line); [286] => continue 2; [287] => break; [288] => case 'n.': [289] => $res .= number_format((int)$this->vars[substr($key,3)]).implode('}', $line); [290] => continue 2; [291] => break; [292] => case 'N.': [293] => if($this->vars[substr($key,3)] or $this->vars[substr($key,3)]==='0' or $this->vars[substr($key,3)]===0) [294] => $res .= number_format($this->vars[substr($key,3)]).implode('}', $line); [295] => else $res .= implode('}', $line); [296] => continue 2; [297] => break; [298] => case 'D.': [299] => if($this->vars[substr($key,3)]) [300] => $res .= date('Y-m-d',$this->vars[substr($key,3)]).implode('}', $line); [301] => else $res .= implode('}', $line); [302] => continue 2; [303] => break; [304] => case 'd.': [305] => if($this->vars[substr($key,3)]) [306] => $res .= date('y-m-d',$this->vars[substr($key,3)]).implode('}', $line); [307] => else $res .= implode('}', $line); [308] => continue 2; [309] => break; [310] => case 'T.': [311] => if($this->vars[substr($key,3)]) [312] => $res .= date('y-m-d H:i:s',$this->vars[substr($key,3)]).implode('}', $line); [313] => else $res .= implode('}', $line); [314] => continue 2; [315] => break; [316] => case 't.': [317] => if($this->vars[substr($key,3)]) [318] => $res .= date('H:i:s',$this->vars[substr($key,3)]).implode('}', $line); [319] => else $res .= implode('}', $line); [320] => continue 2; [321] => break; [322] => case 'g.': [323] => if($this->vars[substr($key,3)]) [324] => $res .= date('D, j M Y G:i:s +0900',$this->vars[substr($key,3)]).implode('}', $line); [325] => else $res .= implode('}', $line); [326] => continue 2; [327] => break; [328] => } [329] => } [330] => [331] => if($key[0]=='#') { [332] => // /spb3/sinc/widget/???.php By Sunmin [333] => if('widget.'==substr($key,1,7)) { [334] => $tmpWidget2 = substr($key,8); [335] => list($tmpWidget,$tmpKey) = explode('.',$tmpWidget2,2); [336] => if(eregi('^[-_a-z0-9]+$',$tmpWidget) and is_file($this->widgetPath . $tmpWidget . '/index.php')) { [337] => @include_once($this->widgetPath .$tmpWidget . '/index.php'); [338] => $func = 'widget_'.$tmpWidget; [339] => $res .= @$func($this,$tmpKey) . implode('}', $line); [340] => continue; [341] => } [342] => } [343] => elseif('widget2.'==substr($key,1,8)) { [344] => $tmpWidget2 = substr($key,9); [345] => list($tmpWidget,$tmpKey) = explode('.',$tmpWidget2,2); [346] => if(eregi('^[-_a-z0-9]+$',$tmpWidget) and is_file($this->widget2Path . 'widget2_'.$tmpWidget . '.php')) { [347] => @include_once($this->widget2Path . 'widget2_'.$tmpWidget . '.php'); [348] => $func = 'widget2_'.$tmpWidget; [349] => $res .= @$func($this,$tmpKey) . implode('}', $line); [350] => continue; [351] => } [352] => }elseif('include.'==substr($key,1,8)) { [353] => $tmpFilename = substr($key,9); [354] => if(is_file($this->root.'/include_'.$tmpFilename.'.html')) { [355] => $res .= @file_get_contents($this->root.'include_'.$tmpFilename.'.html') . implode('}', $line); [356] => } [357] => else $res .= implode('}', $line); [358] => continue; [359] => } [360] => // spb3_content읽어서 keyword에서 content 전송 [361] => elseif('content.'==substr($key,1,8)) { [362] => list($tmp,$tmpKeyword,$tmpContent) = explode('.',$key,3); [363] => if(!$tmpContent) $tmpContent = 'content'; [364] => if(!isset($this->spb3_content[$tmpContent])) { [365] => $this->spb3_content[$tmpContent] = db_resultdata($GLOBALS['SITE']['th'].'cate_content',$tmpContent,'keyword',$tmpKeyword); [366] => } [367] => $res .= $this->spb3_content[$tmpContent] . implode('}', $line); [368] => continue; [369] => } [370] => // cut_string {#cut.50#0#….key} [371] => elseif('cut.'==substr($key,1,4)) { [372] => list($tmp,$tmpCut,$tmpKey) = explode('.',$key,3); [373] => list($tmpCut1,$tmpCut2,$tmpCut3) = explode('#',$tmpCut,3); [374] => if($tmpCut1===NULL) $tmpCut1 = 50; [375] => if($tmpCut2===NULL) $tmpCut2 = 0; [376] => if($tmpCut3===NULL) $tmpCut3 = '…'; [377] => $res .= cut_string($this->vars[$tmpKey],$tmpCut1,$tmpCut2,$tmpCut3).implode('}', $line); [378] => continue; [379] => } [380] => // substr {#sub.2.3.key} [381] => elseif('sub.'==substr($key,1,4)) { [382] => list($tmp,$tmpSub1,$tmpSub2,$tmpKey) = explode('.',$key,4); [383] => $res .= substr($this->vars[$tmpKey],(int)$tmpSub1,(int)$tmpSub2).implode('}', $line); [384] => continue; [385] => } [386] => // explode(split) {#exp.0.-.key} 0번째, -으로 나누어서 [387] => elseif('exp.'==substr($key,1,4)) { [388] => $tmp = explode('.',$key,4); [389] => if(4==count($tmp)) { [390] => $tmp2 = explode($tmp[2],$this->vars[$tmp[3]]); [391] => $res .= $tmp2[$tmp[1]].implode('}', $line); [392] => } [393] => else $res .= implode('}', $line); [394] => continue; [395] => } [396] => } [397] => [398] => switch ($this->unknowns) [399] => { [400] => case "keep": [401] => $res .= '{'.$key; [402] => if (count ($line) > 0) [403] => { [404] => $res .= '}'; [405] => $res .= implode('}', $line); [406] => } [407] => break; [408] => [409] => case "remove": [410] => $res .= implode('', $line); [411] => break; [412] => [413] => case "remove_nonjs": [414] => if (!empty($key) && ((false === strpos($key, ' ')) && (false === strpos($key, "\n")) && (false === strpos($key, "\t")))) [415] => { [416] => $res .= implode('}', $line); [417] => } [418] => else [419] => { [420] => $res .= '{'.$key; [421] => if (count ($line) > 0) [422] => { [423] => $res .= '}'; [424] => $res .= implode('}', $line); [425] => } [426] => } [427] => break; [428] => [429] => case "comment": [430] => $res .= ''.implode('', $line); [431] => break; [432] => [433] => case "space": [434] => $res .= ' '.implode('', $line); [435] => break; [436] => [437] => } [438] => } [439] => } [440] => } [441] => [442] => return $res; [443] => } [444] => [445] => /** [446] => * check and set template root dir [447] => */ [448] => function set_root($root) [449] => { [450] => if (empty($root)) return; [451] => if (!is_dir($root)) [452] => { [453] => $this->error("phemplate::set_root(): 다음 드렉토리가 없습니다 : $root", 'warning'); [454] => return false; [455] => } [456] => [457] => $this->root = realpath($root).'/'; // By Sunmin 05/11/13 [458] => return true; [459] => } [460] => [461] => /** [462] => * what to do with unknown variables in template? [463] => * keep [464] => * remove [465] => * remove_nonjs [466] => * comment [467] => * space [468] => */ [469] => function set_unknowns($unk) [470] => { [471] => $this->unknowns = $unk; [472] => } [473] => [474] => /** [475] => * set default parameters for process() [476] => */ [477] => function set_params($params) [478] => { [479] => $this->parameters = $params; [480] => } [481] => [482] => /** [483] => * read file template into $vars [484] => * @param string $handle - name of handle for file contents [485] => * @param int $blocks - 1 for search, 2 for nested blocks [486] => * [487] => */ [488] => function set_file($handle, $filename = "", $blocks = false) [489] => { [490] => if ($filename == "") [491] => { [492] => $this->error("phemplate::set_file(): 파일이름이 빈값으로 넘어왔습니다 -$handle", 'fatal'); [493] => return false; [494] => } [495] => $this->vars[$handle] = $this->read_file($filename); [496] => if ($blocks & TPL_STRIP_UTF_HEADER) [497] => { [498] => $header = substr($this->vars[$handle], 0, 3); [499] => if ("\xEF\xBB\xBF" == $header) $this->vars[$handle] = substr($this->vars[$handle], 3); [500] => } [501] => if ($blocks) { $this->extract_blocks($handle, $blocks & TPL_BLOCKREC); } [502] => return true; [503] => [504] => } [505] => [506] => [507] => /** [508] => * set handle and value, [509] => * if value is array, all elements will be named: handle.key.subkey [510] => */ [511] => function set_var($var_name, $var_value) [512] => { [513] => if (is_array($var_value)) [514] => { [515] => foreach($var_value as $key=>$value) [516] => { [517] => $this->set_var($var_name . '.' . $key, $value); // recursion for array branches [518] => } [519] => } [520] => else // normal variable [521] => { [522] => $this->vars[$var_name] = $var_value; [523] => } [524] => } [525] => [526] => /** [527] => * tie value with variable [528] => * it's not possible to update array keys, just values [529] => */ [530] => function tie_var($var_name, &$var_value) [531] => { [532] => if (is_array($var_value)) [533] => { [534] => $list = array_keys($var_value); [535] => foreach($list as $key) [536] => { [537] => $this->tie_var($var_name . '.' . $key, $var_value[$key]); // recursion for array branches [538] => } [539] => } [540] => else // normal variable [541] => { [542] => $this->vars[$var_name] =& $var_value; [543] => } [544] => } [545] => [546] => /** [547] => * value of $handle [548] => * raises error if $handle undefined [549] => */ [550] => function get_var($handle) [551] => { [552] => if (!isset($this->vars[$handle])) { [553] => //$this->error("phemplate(): no such handle '$handle'", 'warning'); [554] => return null; // By Sunmin Park 04/05/17 [555] => } [556] => return $this->vars[$handle]; [557] => } [558] => [559] => /** [560] => * value of $handle, no error if no handle [561] => */ [562] => function get_var_silent($handle) [563] => { [564] => if (!isset($this->vars[$handle])) { $this->vars[$handle] = ''; return ''; } [565] => return $this->vars[$handle]; [566] => } [567] => [568] => /** [569] => * assign array to loop handle [570] => * @param string $loop_name - name for a loop [571] => * @param int $loop - loop data [572] => */ [573] => function set_loop($loop_name, $loop) [574] => { [575] => if (!$loop) $loop = 0; [576] => $this->loops[$loop_name] = $loop; [577] => } [578] => [579] => /** [580] => * tie array with loop [581] => */ [582] => function tie_loop($loop_name, &$loop) [583] => { [584] => if (!$loop) $loop = 0; [585] => $this->loops[$loop_name] =& $loop; [586] => } [587] => [588] => /** [589] => * extracts blocks from handle, and returns cleaned up version [590] => * [591] => * must be quite fast, because every found block is imediately taken out of string [592] => * [593] => * [594] => * @since 2001.10.31 works with nested blocks [js] [595] => * @since 2003.06.19 supports customized block syntax [js] [596] => * [597] => */ [598] => function extract_blocks($bl_handle, $recurse = false) [599] => { [600] => [601] => $str = $this->get_var($bl_handle); [602] => if (!$str) return $str; [603] => $bl_start = 0; [604] => [605] => list($bll, $blr) = explode('|', $this->block_start_string); [606] => $strlen = strlen($bll); [607] => [608] => [609] => // find them and clean from parent handle [610] => while(is_long($bl_start = strpos($str, $bll, $bl_start))) [611] => { [612] => $pos = $bl_start + $strlen; [613] => [614] => $endpos = strpos($str, $blr, $pos); [615] => $handle = substr($str, $pos, $endpos-$pos); [616] => [617] => $tag = $bll.$handle.$blr; [618] => $endtag = str_replace('|', $handle, $this->block_end_string); [619] => [620] => $start_pos = $bl_start + strlen($tag); [621] => $end_pos = strpos($str, $endtag, $bl_start); [622] => if (!$end_pos) { $this->error("스킨오류 : </block name=\"$handle\">이 없음", 'fatal'); } [623] => $bl_end = $end_pos + strlen($endtag); [624] => [625] => $block_code = substr($str, $start_pos, $end_pos-$start_pos); [626] => [627] => $this->set_var($handle, $block_code); [628] => [629] => $part1 = substr($str, 0, $bl_start); [630] => $part2 = substr($str, $bl_end, strlen($str)); [631] => [632] => $str = $part1 . $part2; [633] => [634] => if ($recurse) { $this->extract_blocks($handle, 1); } [635] => [636] => } [637] => [638] => $this->set_var($bl_handle, $str); [639] => [640] => } [641] => [642] => [643] => /** [644] => * search for tags in $handle [645] => * be carefull with paths [646] => */ [647] => function include_files($handle) [648] => { [649] => $str = $this->get_var($handle); [650] => [651] => while(is_long($pos = strpos($str, '', $pos); [655] => $filename = substr($str, $pos, $endpos-$pos); [656] => $tag = ''; [657] => [658] => [659] => $include = $this->read_file($filename); [660] => [661] => $str = str_replace($tag, $include, $str); [662] => } [663] => [664] => return $str; [665] => } [666] => [667] => [668] => /** [669] => * searches for all set loops in $handle, returns text of $handle with parsed loops [670] => * @param bool $noloop - must be true, if you want noloop statement [671] => * @return string [672] => */ [673] => function parse_loops($handle, $noloop = false) [674] => { [675] => $str = $this->get_var($handle); [676] => [677] => reset($this->loops); [678] => [679] => while ( list($loop_name, $loop_ar) = each($this->loops) ) [680] => { [681] => [682] => $start_tag = strpos($str, ''); [683] => [684] => $start_pos = $start_tag + strlen(''); [685] => if (!$start_pos) continue; [686] => $end_pos = strpos($str, ''); [687] => [688] => $loop_code = substr($str, $start_pos, $end_pos-$start_pos); [689] => $org_loop_code = $loop_code; [690] => [691] => $start_tag = substr($str, $start_tag, strlen('')); [692] => $end_tag = substr($str, $end_pos, strlen('')); [693] => [694] => if($loop_code != ''){ [695] => [696] => $new_code = ''; [697] => [698] => // clean if ($noloop & TPL_NOLOOP) [700] => { [701] => [702] => $nl_start_tag = strpos($loop_code, ''); [703] => $nl_start_pos = $nl_start_tag + strlen(''); [704] => [705] => [706] => if ($nl_start_pos) [707] => { [708] => [709] => $nl_end_pos = strpos($loop_code, ''); [710] => [711] => $noloop_code = substr($loop_code, $nl_start_pos, $nl_end_pos - $nl_start_pos); [712] => [713] => [714] => $nl_start_tag = substr($loop_code, $nl_start_tag, strlen('')); [715] => $nl_end_tag = substr($loop_code, $nl_end_pos, strlen('')); [716] => $loop_code = str_replace($nl_start_tag.$noloop_code.$nl_end_tag, '', $loop_code); [717] => } [718] => [719] => } [720] => [721] => if (is_array($loop_ar)) [722] => { [723] => [724] => if ($noloop & TPL_LOOP_INNER_PARSED) [725] => { [726] => for($i = 0; isset($loop_ar[$i]); $i++) [727] => [728] => { [729] => $temp_code = $loop_code; [730] => // rememeber loop variables [731] => [732] => $array_keys = array_keys($loop_ar[$i]); [733] => $this->set_var($loop_name, $loop_ar[$i]); [734] => if ($noloop & TPL_LOOP_INNER_OPTIONAL) $temp_code = $this->optional($loop_code); [735] => $temp_code = $this->parse($temp_code); [736] => $new_code .= $temp_code; [737] => [738] => // cleanup loop variables for next generation [739] => foreach ($array_keys as $key) unset($this->vars[$loop_name.'.'.$key]); [740] => [741] => } // for loop [742] => } [743] => else [744] => { [745] => // repeat for every row in array [746] => // for (reset($loop_ar); $row = current($loop_ar); next($loop_ar)) [747] => $ar_keys = array_keys($loop_ar); [748] => $ar_size = count($ar_keys); [749] => for($i = 0; ($i< $ar_size); $i++) [750] => { [751] => $temp_code = $loop_code; [752] => [753] => foreach( $loop_ar[$ar_keys[$i]] as $k=>$v) [754] => { [755] => $temp_code = str_replace( '{'. $loop_name. '.' .$k. '}', $v, $temp_code); [756] => } [757] => $new_code .= $temp_code; [758] => } [759] => } [760] => } elseif ($noloop & TPL_NOLOOP) [761] => { [762] => $new_code = $noloop_code; [763] => } [764] => [765] => [766] => $str = str_replace($start_tag.$org_loop_code.$end_tag, $new_code, $str); [767] => } // if loop code [768] => [769] => } // repeat for loop names [770] => [771] => return $str; [772] => } [773] => [774] => [775] => /** [776] => * process left variables [777] => * @deprecated parse() now handles unknown variables [778] => */ [779] => function finish($str) [780] => { [781] => switch ($this->unknowns) [782] => { [783] => case "keep": [784] => break; [785] => [786] => case "remove": [787] => $str = preg_replace('/{[^ \t\r\n}]+}/', "", $str); [788] => break; [789] => [790] => case "comment": [791] => $str = preg_replace('/{([^ \t\r\n}]+)}/', "", $str); [792] => break; [793] => [794] => case "space": [795] => $str = preg_replace('/{([^ \t\r\n}]+)}/', " ", $str); [796] => break; [797] => [798] => } [799] => [800] => return $str; [801] => } [802] => [803] => /** [804] => * search for optional tag [805] => * @param string $str text [806] => * @return string [807] => */ [808] => function optional($str) [809] => { [810] => $bl_start = 0; [811] => [812] => // extract and clean them from parent handle [813] => while(is_long($bl_start = strpos($str, '', $pos); [818] => $varname = substr($str, $pos, $endpos-$pos); [819] => [820] => $tag = ''; [821] => $endtag = ''; [822] => [823] => $end_pos = strpos($str, $endtag, $bl_start); [824] => if (!$end_pos) { $this->error("스킨오류 <opt name=\"$varname\">가 없음", 'fatal'); } [825] => [826] => $bl_end = $end_pos + strlen($endtag); [827] => [828] => [829] => $part1 = substr($str, 0, $bl_start); [830] => $part2 = substr($str, $bl_end, strlen($str)); [831] => [832] => // if .. by Sunmin Park [833] => if($varname[0]=="!") [834] => { [835] => $varname = substr($varname, 1); [836] => $flag = true; [837] => } [838] => else $flag = false; [839] => [840] => // .. By Sunmin Park [841] => if(strpos($varname,'=')) { [842] => list($varname,$varname_value) = explode('=',$varname,2); [843] => [844] => $value = $this->get_var_silent($varname); [845] => //echo " $value == $varname_value ";exit; [846] => if($value == $varname_value) { [847] => $flag = !$flag; [848] => } [849] => } [850] => else { [851] => $value = $this->get_var_silent($varname); [852] => [853] => //if ($value || $value === 0 || $value === '0') [854] => if ($value and $value !== 'N') [855] => { [856] => $flag = !$flag; [857] => } [858] => } [859] => [860] => if($flag) [861] => { [862] => $start_pos = $bl_start + strlen($tag); [863] => [864] => $block_code = substr($str, $start_pos, $end_pos-$start_pos); [865] => [866] => $str = $part1 . $this->parse($block_code) . $part2; [867] => } [868] => else [869] => { [870] => $str = $part1 . $part2; [871] => } [872] => } [873] => [874] => return $str; [875] => } [876] => [877] => /** [878] => * does everything: loops, includes, variables, concatenation [879] => * if $loop is 0 (not false, but 0) default parameters are used [880] => * thanks ShiVAs for idea to have $loop as parameters. [881] => * [882] => * @param $loop - loop, noloop or all parameters ored. [883] => * @param $append - append processed stuff to target, else $target is overwritten [884] => * @return string [885] => */ [886] => function process($target, $handle, $loop = false, $include = false, $append = false, $finish = false, $optional = false) [887] => { [888] => if ($loop === 0) $loop = $this->parameters; [889] => [890] => $noloop = false; [891] => $parsedloop = false; [892] => $loopopt = false; [893] => if ($loop > 2) [894] => { [895] => $noloop = $loop & TPL_NOLOOP; [896] => $include = $loop & TPL_INCLUDE; [897] => $append = $loop & TPL_APPEND; [898] => $finish = $loop & TPL_FINISH; [899] => $optional = $loop & TPL_OPTIONAL; [900] => $parsedloop = $loop & TPL_LOOP_INNER_PARSED; [901] => $loopopt = $loop & TPL_LOOP_INNER_OPTIONAL; [902] => } [903] => else [904] => { [905] => $noloop = $loop & TPL_NOLOOP; [906] => } [907] => [908] => if ($append) { [909] => if (isset($this->vars[$target])) { [910] => $app = $this->get_var($target); // preserve old info [911] => $this->set_var($target.'.count', $tmp=$this->get_var($target.'.count')+1); // by sunmin (append count) [912] => $this->set_var($target.'.countodd', $tmp%2 ); // by sunmin (append count) [913] => } [914] => else { [915] => $app = ''; [916] => $this->set_var($target.'.count', 1); // by sunmin (append count) [917] => $this->set_var($target.'.countodd', 1); // by sunmin (append count) [918] => } [919] => } [920] => [921] => $this->set_var($target, $this->get_var($handle)); // copy contents [922] => [923] => if ($include) { $this->set_var($target, $this->include_files($target)); } [924] => [925] => [926] => if ($noloop) { $this->set_var($target, $this->parse_loops($target, TPL_NOLOOP | $loopopt | $parsedloop)); } [927] => elseif ($loop) { $this->set_var($target, $this->parse_loops($target, $loopopt | $parsedloop)); } [928] => [929] => if ($optional) { $this->set_var($target, $this->optional($this->get_var_silent($target))); } [930] => [931] => if ($append) { $this->set_var($target, $app . $this->parse($this->get_var_silent($target))); } [932] => else { $this->set_var($target, $this->parse($this->get_var($target))); } [933] => [934] => if ($finish) { $this->set_var($target, $this->finish($this->get_var($target))); } [935] => [936] => return $this->get_var($target); [937] => } [938] => [939] => [940] => /** [941] => * spits out file contents [942] => * @access private [943] => */ [944] => function read_file($file) [945] => { [946] => $filename = $this->root . $file; [947] => [948] => if (!file_exists($filename)) [949] => { [950] => $this->error("phemplate::read_file(): 파일이 없음 - $filename", 'fatal'); [951] => return ''; [952] => } [953] => [954] => $tmp = false; [955] => [956] => $filesize = filesize($filename); [957] => if ($filesize) [958] => { [959] => $tmp = fread($fp = fopen($filename, 'r'), $filesize); [960] => fclose($fp); [961] => [962] => $this->read_files[]= $filename; [963] => } [964] => return $tmp; [965] => } [966] => [967] => /** [968] => * free mem used by loop [969] => */ [970] => function drop_loop($loop_handle) [971] => { [972] => if (isset($this->loops[$loop_handle])) unset($this->loops[$loop_handle]); [973] => } [974] => [975] => [976] => /** [977] => * free mem used by var [978] => */ [979] => function drop_var($handle,$var_value='') [980] => { [981] => if (is_array($var_value)) { // by Sunmin Park [982] => foreach($var_value as $key=>$value) [983] => $this->drop_var($handle.'.'.$key,$value); // recursion for array branches [984] => } [985] => elseif (isset($this->vars[$handle])) unset($this->vars[$handle]); [986] => } [987] => [988] => /** [989] => * set error handler [990] => */ [991] => function set_error_handler(&$eh) [992] => { [993] => $this->error_handler =& $eh; [994] => } [995] => [996] => /** [997] => * change block syntax [998] => */ [999] => function set_block_syntax($start, $end) [1000] => { [1001] => if (!strpos($start, '|')) $this->error("phemplate::set_block_syntax(): no '|' in start tag", 'fatal'); [1002] => if (!strpos($end, '|')) $this->error("phemplate::set_block_syntax(): no '|' in end tag", 'fatal'); [1003] => $this->block_start_string = $start; [1004] => $this->block_end_string = $end; [1005] => } [1006] => [1007] => /** [1008] => * error report [1009] => */ [1010] => function error( $msg, $level = '') [1011] => { [1012] => if (isset($this->error_handler)) [1013] => { [1014] => $lvl = E_USER_WARNING; [1015] => if ('fatal' == $level) $lvl = E_USER_ERROR; [1016] => $this->error_handler->report($lvl, $msg); [1017] => } [1018] => else [1019] => { [1020] => echo "\n
$level: $msg
\n"; [1021] => if ('fatal' == $level) { exit; } [1022] => } [1023] => } [1024] => [1025] => /** [1026] => * SitePHPbasic 반복하는 echoHtml [1027] => * By Sunmin Park 06/07/23 [1028] => */ [1029] => function echoHtml( &$dbinfo, &$SITE, $thisUrl='' ) { [1030] => $val='\\1'.$thisUrl.'skin/'.$dbinfo['skin'].'/images/'; [1031] => // - 사이트 템플릿 읽어오기 [1032] => if(ereg('^(ht|h|t)$',$dbinfo['html_type'])) { [1033] => $HEADER = array ('html_skin'=>$dbinfo['html_skin']); [1034] => @include($SITE['html_path'].'skin.php'); // retrun $aBody[0],$aBody[1] [1035] => } [1036] => [1037] => $html = ''; [1038] => switch($dbinfo['html_type']) { [1039] => case 'ht': [1040] => $html = $aBody[0]; [1041] => $html .= $dbinfo['html_head']; [1042] => $html .= ereg_replace('([="\'(])images/',$val,$this->process('', 'html',TPL_OPTIONAL)); [1043] => $html .= $dbinfo['html_tail']; [1044] => $html .= $aBody[1]; [1045] => break; [1046] => case 'h': [1047] => $html .= $aBody[0] ; [1048] => $html .= $dbinfo['html_head']; [1049] => $html .= ereg_replace('([="\'(])images/',$val,$this->process('', 'html',TPL_OPTIONAL)); [1050] => $html .= $dbinfo['html_tail']; [1051] => break; [1052] => case 't': [1053] => $html .= $dbinfo['html_head']; [1054] => $html .= ereg_replace('([="\'(])images/',$val,$this->process('', 'html',TPL_OPTIONAL)); [1055] => $html .= $dbinfo['html_tail'] ; [1056] => $html .= $aBody[1]; [1057] => break; [1058] => case 'no': [1059] => $html .= ereg_replace('([="\'(])images/',$val,$this->process('', 'html',TPL_OPTIONAL)); [1060] => break; [1061] => default: [1062] => $html .= $dbinfo['html_head']; [1063] => $html .= ereg_replace('([="\'(])images/',$val,$this->process('', 'html',TPL_OPTIONAL)); [1064] => $html .= $dbinfo['html_tail']; [1065] => } // end switch [1066] => [1067] => /* [1068] => if($_GET['utf8']=='euc-kr') { [1069] => // iconv 버그로 인해서 "\n"로 나눔 [1070] => $aA =explode("\n",$html); [1071] => $html =''; [1072] => foreach($aA as $v) $html .= iconv("euc-kr", "UTF-8",$v); [1073] => } [1074] => */ [1075] => [1076] => if($_GET['html_return']) $_GET['html']=$html; [1077] => else echo $html; [1078] => [1079] => // debug 출력 [1080] => if(defined('GET_DEBUG_2') and GET_DEBUG_2) { [1081] => echo "
"; [1082] => echo "skin : $dbinfo[skin], html_type: $dbinfo[html_type], html_skin: $dbinfo[html_skin]
thisUrl:$thisUrl "; [1083] => if('/spb3/sboard3/'==$thisUrl) { [1084] => echo " [게시판수정]"; [1085] => if($_GET['cateuid']) { [1086] => echo " [카테고리수정]"; [1087] => } [1088] => } [1089] => if($dbinfo['table']) { [1090] => echo " [$dbinfo[table]]"; [1091] => } [1092] => echo "
"; [1093] => if(count($this->read_files)) { [1094] => foreach($this->read_files as $filepath) { [1095] => if(strpos($filepath,$_SERVER['DOCUMENT_ROOT'])!==false) { [1096] => $url = substr($filepath,strlen($_SERVER['DOCUMENT_ROOT'])); [1097] => echo "skin file : $url
"; [1098] => } [1099] => else echo "skin file : $filepath
"; [1100] => } [1101] => } [1102] => //echo '
dbinfo ';var_export($dbinfo);

                                            [1103] => 			//echo '
'; [1104] => echo '
'; [1105] => } [1106] => } [1107] => } [1108] => ?> ) [new] => [ovalue] => // $Id: class_phemplate.php 13 2010-08-24 08:28:50Z sitehis $ [oindex] => 1 [nkeys] => ) ) ) [1] => Array ( [file] => /wecan/cc/cc.sdong.kr/spb3/sadmin/util/svn/spb3_diff.php [line] => 122 [function] => array_keys [args] => Array ( [0] => [1] => // $Id: class_phemplate.php 13 2010-08-24 08:28:50Z sitehis $ ) ) [2] => Array ( [file] => /wecan/cc/cc.sdong.kr/spb3/sadmin/util/svn/spb3_diff.php [line] => 142 [function] => doDiff [class] => diff [object] => diff Object ( [changes] => Array ( ) [diff] => Array ( ) [linepadding] => 2 ) [type] => -> [args] => Array ( [0] => /wecan/cc/cc.sdong.kr/spb3/sinc/lib/class_phemplate.php [1] => ) ) [3] => Array ( [file] => /wecan/cc/cc.sdong.kr/spb3/sadmin/util/svn/spb3_diff.php [line] => 197 [function] => diffWrap [class] => diff [object] => diff Object ( [changes] => Array ( ) [diff] => Array ( ) [linepadding] => 2 ) [type] => -> [args] => Array ( [0] => /wecan/cc/cc.sdong.kr/spb3/sinc/lib/class_phemplate.php [1] => ) ) [4] => Array ( [file] => /wecan/cc/cc.sdong.kr/spb3/sadmin/util/svn/spb3_diff.php [line] => 92 [function] => inline [class] => diff [object] => diff Object ( [changes] => Array ( ) [diff] => Array ( ) [linepadding] => 2 ) [type] => -> [args] => Array ( [0] => /wecan/cc/cc.sdong.kr/spb3/sinc/lib/class_phemplate.php [1] => [2] => 2 ) ) ) [key] => 4 [value] => Array ( [file] => /wecan/cc/cc.sdong.kr/spb3/sadmin/util/svn/spb3_diff.php [line] => 92 [function] => inline [class] => diff [object] => diff Object ( [changes] => Array ( ) [diff] => Array ( ) [linepadding] => 2 ) [type] => -> [args] => Array ( [0] => /wecan/cc/cc.sdong.kr/spb3/sinc/lib/class_phemplate.php [1] => [2] => 2 ) ) )
sitePHPbasic 디버그 모드 : WARNING
[2] Invalid argument supplied for foreach()
Line : 123 (file:/wecan/cc/cc.sdong.kr/spb3/sadmin/util/svn/spb3_diff.php)
- 디버그 추적(debug_backtrace)
#0 spb_error_handler() 함수사용, line(123), /wecan/cc/cc.sdong.kr/spb3/sadmin/util/svn/spb3_diff.php
#1 doDiff() 함수사용, line(142), /wecan/cc/cc.sdong.kr/spb3/sadmin/util/svn/spb3_diff.php
#2 diffWrap() 함수사용, line(197), /wecan/cc/cc.sdong.kr/spb3/sadmin/util/svn/spb3_diff.php
#3 inline() 함수사용, line(92), /wecan/cc/cc.sdong.kr/spb3/sadmin/util/svn/spb3_diff.php




사용변수들 ...
$_GET = Array ( [md5_path] => /spb3/sinc/lib/class_phemplate.php ) $_POST = Array ( ) $_COOKIE = Array ( ) Array ( [errno] => 2 [errstr] => Invalid argument supplied for foreach() [errfile] => /wecan/cc/cc.sdong.kr/spb3/sadmin/util/svn/spb3_diff.php [errline] => 123 [arr] => Array ( [0] => Array ( [file] => /wecan/cc/cc.sdong.kr/spb3/sadmin/util/svn/spb3_diff.php [line] => 123 [function] => spb_error_handler [args] => Array ( [0] => 2 [1] => Invalid argument supplied for foreach() [2] => /wecan/cc/cc.sdong.kr/spb3/sadmin/util/svn/spb3_diff.php [3] => 123 [4] => Array ( [old] => Array ( [0] => // $Id: class_phemplate.php 13 2010-08-24 08:28:50Z sitehis $ [2] => // 04/05/17 박선민 340L get_var() chanage to same get_var_silent() [3] => // 04/05/17 박선민 696L optional() add and change etc.. [4] => // 05/01/25 박선민 828L drop_var() add recursion for array branches [5] => // 05/11/20 박선민 echoHtml()로 반복하는 sitePHPbasic 마무리 부분 함수로 [6] => // 07/03/18 박선민 {!e.abc} 인경우 urlencoding 등의 기능 추가 [7] => // 07/08/14 박선민 {#widget.???} 윗젯 include 기능 추가 [8] => // 07/09/16 박선민 {#content.keyword} spb3_content 테이블의 keyword에 대한 content가져와서 넣는 기능 추가 [9] => // 08/06/14 박선민 $_GET[html_return] 기능 추가 [10] => // 08/06/28 박선민 831L optional() change 값이 'N'이여도 false되게 [11] => // 08/07/13 박선민 716L // cut_string {#cut.50#0#….key} 기능 추가 [12] => // 08/07/29 박선민 546L // parse() ... IF문 기능 추가 [13] => // 08/10/06 박선민 {#sub.2.3.???} 기능 추가 [14] => // 08/11/08 박선민 #content.??? 기능 개선 [15] => // 08/11/29 박선민 bugfix - don't use &$this [16] => // 09/01/04 박선민 {#widget2.???} 윗젯2 기능 추가(php파일위치에 widget2_???.php를 읽어서 함수 실행 [17] => // 09/02/04 박선민 {!N.list.number} 기능 추가 [18] => // 09/02/06 박선민 GET_DEBUG_2 기능 추가 [19] => // 09/02/25 박선민 {#exp.0.-.key}, server.server.HTTP_REFERER 추가 [20] => // 09/03/11 박선민 {!A.str} javascript에서 변수넘길때 큰따옴표 오류 해결용 [21] => // 09/05/08 박선민 bugfix - GET_DEBUG_2 false였을 때 오류 [22] => // 09/05/31 박선민 {!B.str} table, excel등에서 빈값은  로 변환하여 리턴하도록 [23] => // 09/05/31 박선민 {!?.str} 링크에 ?가 없으면 ?를 붙여주도록 [24] => // 09/07/28 박선민 {!X.name} : xmlspecialchars 변환 기능 추가 [25] => //---------------------------------------------------------------------------// [26] => // author: pukomuko [27] => // date: 2001.03.15 [28] => // web: http://pukomuko.esu.lt [29] => // http://sourceforge.net/projects/phemplate [30] => // info: template engine [31] => //---------------------------------------------------------------------------// [32] => // copyleft license [33] => // [34] => // this software is provided 'as-is', without any express or implied [35] => // warranty. in no event will the authors be held liable for any damages [36] => // arising from the use of this software. [37] => // [38] => // permission is granted to anyone to use this software for any purpose, [39] => // including commercial applications, and to alter it and redistribute it [40] => // freely, subject to the following restrictions: [41] => // [42] => // 1. the origin of this software must not be misrepresented; [43] => // you must not claim that you wrote the original software. [44] => // if you use this software in a product, an acknowledgment [45] => // in the product documentation would be appreciated but is not required. [46] => // [47] => // 2. altered source versions must be plainly marked as such, [48] => // and must not be misrepresented as being the original software. [49] => // [50] => // 3. mail about the fact of using this class in production [51] => // would be very appreciated. [52] => // [53] => // 4. this notice may not be removed or altered from any source distribution. [54] => // [55] => //---------------------------------------------------------------------------// [56] => // changes: [57] => // [58] => // 2004.04.21 [59] => // - warining on empty file [60] => // * v1.10.1 [61] => [62] => /** [63] => */ [64] => define('TPL_LOOP', 1); [65] => define('TPL_NOLOOP', 2); [66] => define('TPL_INCLUDE', 4); [67] => define('TPL_APPEND', 8); [68] => define('TPL_FINISH', 16); [69] => define('TPL_OPTIONAL', 32); [70] => define('TPL_LOOP_INNER_PARSED',64); [71] => define('TPL_LOOP_INNER_OPTIONAL', 128); [72] => [73] => define('TPL_PARSEDLOOP', TPL_LOOP | TPL_LOOP_INNER_PARSED); [74] => define('TPL_OPTLOOP', TPL_PARSEDLOOP | TPL_LOOP_INNER_OPTIONAL); [75] => [76] => [77] => define('TPL_BLOCK', 1); [78] => define('TPL_BLOCKREC', 2); [79] => define('TPL_STRIP_UTF_HEADER', 4); [80] => [81] => class phemplate [82] => { [83] => /** [84] => * 현재 클래스가 있는 드렉토리 By Sunmin [85] => */ [86] => var $widgetPath =''; [87] => [88] => var $read_files = array(); [89] => [90] => /** [91] => * spb3_content에서 읽어온 것을 캐쉬 [92] => */ [93] => var $spb3_content = array(); [94] => [95] => [96] => /** [97] => * variables and blocks [98] => */ [99] => var $vars = array(); [100] => [101] => /** [102] => * loops container [103] => */ [104] => var $loops = array(); [105] => [106] => /** [107] => * dir of template files [108] => */ [109] => var $root = ''; [110] => [111] => /** [112] => * what to do with unknown variables in template? [113] => */ [114] => var $unknowns = 'keep'; [115] => [116] => /** [117] => * default parameters for process() loop, append, finish [118] => */ [119] => var $parameters = 0; [120] => [121] => [122] => /** [123] => * object having method report($level, $msg) [124] => * you can catch error messages from template. [125] => */ [126] => var $error_handler = null; [127] => [128] => [129] => [130] => /** [131] => * start tag for block [132] => */ [133] => var $block_start_string = ''; [134] => [135] => /** [136] => * end tag for block [137] => */ [138] => var $block_end_string = ''; [139] => [140] => /** [141] => * constructor [142] => * $unknows를 keep에서 remove_nonjs로 변경함 by Sunmin Park [143] => */ [144] => function phemplate( $root_dir = '', $unknowns = 'remove_nonjs', $params = 0) [145] => { [146] => // widget, widget2 path [147] => $this->widgetPath = dirname(dirname(__FILE__)).'/widget/'; // By Sunmin [148] => if($this->set_root($root_dir)) [149] => $this->widget2Path = dirname(dirname($this->root)).'/'; // By Sunmin [150] => $this->set_unknowns($unknowns); [151] => $this->set_params($params); [152] => [153] => [154] => [155] => // 기본 set_var by Sunmin [156] => $this->tie_var('SITE' ,$GLOBALS['SITE']); // $SITE 전역변수 [157] => $this->tie_var('get' ,$_GET); [158] => $this->set_var('braces' ,'{'); // 중괄호{braces} 표현 [159] => $this->set_var('nowtime',time()); [160] => [161] => $this->tie_var('session.seUid' ,$_SESSION['seUid']); // 로그인 uid [162] => $this->tie_var('session.seUserid' ,$_SESSION['seUserid']); // 로그인 userid [163] => $this->tie_var('session.seName' ,$_SESSION['seName']); // 로그인 이름 [164] => $this->tie_var('session.seNickname' ,$_SESSION['seNickname']); // 로그인 별명 [165] => $this->tie_var('session.seEmail' ,$_SESSION['seEmail']); [166] => $this->tie_var('session.sePoint' ,$_SESSION['sePoint']); [167] => $this->tie_var('session.seCoupon' ,$_SESSION['seCoupon']); [168] => $this->tie_var('session.sePriv' ,$_SESSION['sePriv']); [169] => [170] => $this->set_var('server.HTTP_HOST' ,$_SERVER['HTTP_HOST']); [171] => $this->set_var('server.HTTP_REFERER',$_SERVER['HTTP_REFERER']); [172] => $this->set_var('server.QUERY_STRING' ,$_SERVER['QUERY_STRING']); [173] => $this->set_var('server.REQUEST_URI' ,$_SERVER['REQUEST_URI']); [174] => $this->set_var('server.PHP_SELF' ,$_SERVER['PHP_SELF']); [175] => } [176] => [177] => /** [178] => substitute text and returns parsed string [179] => @author ZaZa (Sergej Kurakin) 2003.05.05 21:52 [180] => */ [181] => function parse($string) [182] => { [183] => $str = explode('{', $string); [184] => [185] => $res = ''; [186] => [187] => for ($i = 0; isset($str[$i]); $i++) [188] => { [189] => $line = explode('}', $str[$i]); [190] => if ($i === 0) [191] => { [192] => $res .= $line[0]; [193] => } [194] => else [195] => { [196] => $key = $line[0]; [197] => unset($line[0]); [198] => [199] => if ( $key && isset($this->vars[$key]) ) [200] => { [201] => $res .= $this->vars[$key].implode('}', $line); [202] => } [203] => else [204] => { [205] => // {!d.list.rdate} 등 By Sunmin [206] => if($key[0]=='!') { // and isset($this->vars[substr($key,3)])) { [207] => switch(substr($key,1,2)) { [208] => /** [209] => ** 대소문자 구분함 [210] => {!B.name} : 값이 없으면   [211] => {!b.name} : 문장에서 엔터를
로 변환함 [212] => {!S.name} : 문장에서 html 테그를 모두 제거하고, 엔터는
로 변환함 [213] => [214] => {!a.name} : '\' addslashes 삽입 [215] => {!A.name} : javascript에서 변수넘길때 funcname('{!A.str}') [216] => {!s.name} : addslashes된 것을 stripcslashes함 [217] => {!?.name} : 문자열 중간 혹은 끝에 ?가 없으면 맨뒤에 ?를 붙여줌 [218] => [219] => {!h.name} : HTML특수문자로 변환( 큰따옴표도 변환 ) [220] => {!H.name} : HTML특수문자로 변환( 큰따옴표는 그대로 나둠) [221] => {!x.name} : stripcslashes함 하고 HTML특수문자로 변환( 큰따옴표도 변환) [222] => {!X.name} : xmlspecialchars 변환 [223] => [224] => {!e.url} : URL ENCODE [225] => [226] => {!n.price} : 숫자에 콤마 추가(단, 값이 없으면 무조건 '0' 리턴) [227] => {!N.price} : 숫자에 콤마 추가(단, ''값이면 빈값으로 리턴 [228] => [229] => {!D.rdate} : 숫자날짜를 YYYY-MM-DD로 변환 (연도가 4자리) [230] => {!d.rdate} : 숫자날짜를 YY-MM-DD로 변환 (연도가 2자리) [231] => {!T.rdate} : 숫자날짜를 YY-MM-DD H:i:s로 변환 (ex, 2009-01-01 23:59:55) [232] => {!t.rdate} : 숫자날짜를 시간인 H:i:s로 변환 (ex, 23:59:55) [233] => {!g.rdate} : 숫자날짜를 국제표준 한국시간으로 'D, j M Y G:i:s +0900' [234] => **/ [235] => case 'B.': [236] => if(empty($this->vars[substr($key,3)]) and $this->vars[substr($key,3)]!="0") [237] => $res .= ' '.implode('}', $line); [238] => else $res .= $this->vars[substr($key,3)].implode('}', $line); [239] => continue 2; [240] => break; [241] => case 'b.': [242] => $res .= nl2br($this->vars[substr($key,3)]).implode('}', $line); [243] => continue 2; [244] => break; [245] => case 'S.': // strip_tags(),
tag취환 [246] => $res .= ereg_replace("(\r\n|\n|\r)", '
',strip_tags($this->vars[substr($key,3)])).implode('}', $line); [247] => continue 2; [248] => break; [249] => case 'a.': [250] => $res .= addslashes($this->vars[substr($key,3)]).implode('}', $line); [251] => continue 2; [252] => break; [253] => case 'A.': [254] => $res .= str_replace('\\"','"',addslashes($this->vars[substr($key,3)])).implode('}', $line); [255] => continue 2; [256] => break; [257] => case 's.': [258] => $res .= stripcslashes($this->vars[substr($key,3)]).implode('}', $line); [259] => continue 2; [260] => break; [261] => case '?.': [262] => if(false===strpos($this->vars[substr($key,3)],'?')) [263] => $res .= $this->vars[substr($key,3)].'?'.implode('}', $line); [264] => else [265] => $res .= $this->vars[substr($key,3)].implode('}', $line); [266] => continue 2; [267] => break; [268] => case 'h.': [269] => $res .= htmlspecialchars($this->vars[substr($key,3)],ENT_QUOTES).implode('}', $line); [270] => continue 2; [271] => break; [272] => case 'H.': [273] => $res .= htmlspecialchars($this->vars[substr($key,3)],ENT_NOQUOTES).implode('}', $line); [274] => continue 2; [275] => break; [276] => case 'x.': [277] => $res .= htmlspecialchars(stripcslashes($this->vars[substr($key,3)]),ENT_QUOTES).implode('}', $line); [278] => continue 2; [279] => break; [280] => case 'X.': [281] => $res .= str_replace(''', ''', htmlspecialchars($this->vars[substr($key,3)], ENT_QUOTES)).implode('}', $line); [282] => continue 2; [283] => break; [284] => case 'e.': [285] => $res .= urlencode($this->vars[substr($key,3)]).implode('}', $line); [286] => continue 2; [287] => break; [288] => case 'n.': [289] => $res .= number_format((int)$this->vars[substr($key,3)]).implode('}', $line); [290] => continue 2; [291] => break; [292] => case 'N.': [293] => if($this->vars[substr($key,3)] or $this->vars[substr($key,3)]==='0' or $this->vars[substr($key,3)]===0) [294] => $res .= number_format($this->vars[substr($key,3)]).implode('}', $line); [295] => else $res .= implode('}', $line); [296] => continue 2; [297] => break; [298] => case 'D.': [299] => if($this->vars[substr($key,3)]) [300] => $res .= date('Y-m-d',$this->vars[substr($key,3)]).implode('}', $line); [301] => else $res .= implode('}', $line); [302] => continue 2; [303] => break; [304] => case 'd.': [305] => if($this->vars[substr($key,3)]) [306] => $res .= date('y-m-d',$this->vars[substr($key,3)]).implode('}', $line); [307] => else $res .= implode('}', $line); [308] => continue 2; [309] => break; [310] => case 'T.': [311] => if($this->vars[substr($key,3)]) [312] => $res .= date('y-m-d H:i:s',$this->vars[substr($key,3)]).implode('}', $line); [313] => else $res .= implode('}', $line); [314] => continue 2; [315] => break; [316] => case 't.': [317] => if($this->vars[substr($key,3)]) [318] => $res .= date('H:i:s',$this->vars[substr($key,3)]).implode('}', $line); [319] => else $res .= implode('}', $line); [320] => continue 2; [321] => break; [322] => case 'g.': [323] => if($this->vars[substr($key,3)]) [324] => $res .= date('D, j M Y G:i:s +0900',$this->vars[substr($key,3)]).implode('}', $line); [325] => else $res .= implode('}', $line); [326] => continue 2; [327] => break; [328] => } [329] => } [330] => [331] => if($key[0]=='#') { [332] => // /spb3/sinc/widget/???.php By Sunmin [333] => if('widget.'==substr($key,1,7)) { [334] => $tmpWidget2 = substr($key,8); [335] => list($tmpWidget,$tmpKey) = explode('.',$tmpWidget2,2); [336] => if(eregi('^[-_a-z0-9]+$',$tmpWidget) and is_file($this->widgetPath . $tmpWidget . '/index.php')) { [337] => @include_once($this->widgetPath .$tmpWidget . '/index.php'); [338] => $func = 'widget_'.$tmpWidget; [339] => $res .= @$func($this,$tmpKey) . implode('}', $line); [340] => continue; [341] => } [342] => } [343] => elseif('widget2.'==substr($key,1,8)) { [344] => $tmpWidget2 = substr($key,9); [345] => list($tmpWidget,$tmpKey) = explode('.',$tmpWidget2,2); [346] => if(eregi('^[-_a-z0-9]+$',$tmpWidget) and is_file($this->widget2Path . 'widget2_'.$tmpWidget . '.php')) { [347] => @include_once($this->widget2Path . 'widget2_'.$tmpWidget . '.php'); [348] => $func = 'widget2_'.$tmpWidget; [349] => $res .= @$func($this,$tmpKey) . implode('}', $line); [350] => continue; [351] => } [352] => }elseif('include.'==substr($key,1,8)) { [353] => $tmpFilename = substr($key,9); [354] => if(is_file($this->root.'/include_'.$tmpFilename.'.html')) { [355] => $res .= @file_get_contents($this->root.'include_'.$tmpFilename.'.html') . implode('}', $line); [356] => } [357] => else $res .= implode('}', $line); [358] => continue; [359] => } [360] => // spb3_content읽어서 keyword에서 content 전송 [361] => elseif('content.'==substr($key,1,8)) { [362] => list($tmp,$tmpKeyword,$tmpContent) = explode('.',$key,3); [363] => if(!$tmpContent) $tmpContent = 'content'; [364] => if(!isset($this->spb3_content[$tmpContent])) { [365] => $this->spb3_content[$tmpContent] = db_resultdata($GLOBALS['SITE']['th'].'cate_content',$tmpContent,'keyword',$tmpKeyword); [366] => } [367] => $res .= $this->spb3_content[$tmpContent] . implode('}', $line); [368] => continue; [369] => } [370] => // cut_string {#cut.50#0#….key} [371] => elseif('cut.'==substr($key,1,4)) { [372] => list($tmp,$tmpCut,$tmpKey) = explode('.',$key,3); [373] => list($tmpCut1,$tmpCut2,$tmpCut3) = explode('#',$tmpCut,3); [374] => if($tmpCut1===NULL) $tmpCut1 = 50; [375] => if($tmpCut2===NULL) $tmpCut2 = 0; [376] => if($tmpCut3===NULL) $tmpCut3 = '…'; [377] => $res .= cut_string($this->vars[$tmpKey],$tmpCut1,$tmpCut2,$tmpCut3).implode('}', $line); [378] => continue; [379] => } [380] => // substr {#sub.2.3.key} [381] => elseif('sub.'==substr($key,1,4)) { [382] => list($tmp,$tmpSub1,$tmpSub2,$tmpKey) = explode('.',$key,4); [383] => $res .= substr($this->vars[$tmpKey],(int)$tmpSub1,(int)$tmpSub2).implode('}', $line); [384] => continue; [385] => } [386] => // explode(split) {#exp.0.-.key} 0번째, -으로 나누어서 [387] => elseif('exp.'==substr($key,1,4)) { [388] => $tmp = explode('.',$key,4); [389] => if(4==count($tmp)) { [390] => $tmp2 = explode($tmp[2],$this->vars[$tmp[3]]); [391] => $res .= $tmp2[$tmp[1]].implode('}', $line); [392] => } [393] => else $res .= implode('}', $line); [394] => continue; [395] => } [396] => } [397] => [398] => switch ($this->unknowns) [399] => { [400] => case "keep": [401] => $res .= '{'.$key; [402] => if (count ($line) > 0) [403] => { [404] => $res .= '}'; [405] => $res .= implode('}', $line); [406] => } [407] => break; [408] => [409] => case "remove": [410] => $res .= implode('', $line); [411] => break; [412] => [413] => case "remove_nonjs": [414] => if (!empty($key) && ((false === strpos($key, ' ')) && (false === strpos($key, "\n")) && (false === strpos($key, "\t")))) [415] => { [416] => $res .= implode('}', $line); [417] => } [418] => else [419] => { [420] => $res .= '{'.$key; [421] => if (count ($line) > 0) [422] => { [423] => $res .= '}'; [424] => $res .= implode('}', $line); [425] => } [426] => } [427] => break; [428] => [429] => case "comment": [430] => $res .= ''.implode('', $line); [431] => break; [432] => [433] => case "space": [434] => $res .= ' '.implode('', $line); [435] => break; [436] => [437] => } [438] => } [439] => } [440] => } [441] => [442] => return $res; [443] => } [444] => [445] => /** [446] => * check and set template root dir [447] => */ [448] => function set_root($root) [449] => { [450] => if (empty($root)) return; [451] => if (!is_dir($root)) [452] => { [453] => $this->error("phemplate::set_root(): 다음 드렉토리가 없습니다 : $root", 'warning'); [454] => return false; [455] => } [456] => [457] => $this->root = realpath($root).'/'; // By Sunmin 05/11/13 [458] => return true; [459] => } [460] => [461] => /** [462] => * what to do with unknown variables in template? [463] => * keep [464] => * remove [465] => * remove_nonjs [466] => * comment [467] => * space [468] => */ [469] => function set_unknowns($unk) [470] => { [471] => $this->unknowns = $unk; [472] => } [473] => [474] => /** [475] => * set default parameters for process() [476] => */ [477] => function set_params($params) [478] => { [479] => $this->parameters = $params; [480] => } [481] => [482] => /** [483] => * read file template into $vars [484] => * @param string $handle - name of handle for file contents [485] => * @param int $blocks - 1 for search, 2 for nested blocks [486] => * [487] => */ [488] => function set_file($handle, $filename = "", $blocks = false) [489] => { [490] => if ($filename == "") [491] => { [492] => $this->error("phemplate::set_file(): 파일이름이 빈값으로 넘어왔습니다 -$handle", 'fatal'); [493] => return false; [494] => } [495] => $this->vars[$handle] = $this->read_file($filename); [496] => if ($blocks & TPL_STRIP_UTF_HEADER) [497] => { [498] => $header = substr($this->vars[$handle], 0, 3); [499] => if ("\xEF\xBB\xBF" == $header) $this->vars[$handle] = substr($this->vars[$handle], 3); [500] => } [501] => if ($blocks) { $this->extract_blocks($handle, $blocks & TPL_BLOCKREC); } [502] => return true; [503] => [504] => } [505] => [506] => [507] => /** [508] => * set handle and value, [509] => * if value is array, all elements will be named: handle.key.subkey [510] => */ [511] => function set_var($var_name, $var_value) [512] => { [513] => if (is_array($var_value)) [514] => { [515] => foreach($var_value as $key=>$value) [516] => { [517] => $this->set_var($var_name . '.' . $key, $value); // recursion for array branches [518] => } [519] => } [520] => else // normal variable [521] => { [522] => $this->vars[$var_name] = $var_value; [523] => } [524] => } [525] => [526] => /** [527] => * tie value with variable [528] => * it's not possible to update array keys, just values [529] => */ [530] => function tie_var($var_name, &$var_value) [531] => { [532] => if (is_array($var_value)) [533] => { [534] => $list = array_keys($var_value); [535] => foreach($list as $key) [536] => { [537] => $this->tie_var($var_name . '.' . $key, $var_value[$key]); // recursion for array branches [538] => } [539] => } [540] => else // normal variable [541] => { [542] => $this->vars[$var_name] =& $var_value; [543] => } [544] => } [545] => [546] => /** [547] => * value of $handle [548] => * raises error if $handle undefined [549] => */ [550] => function get_var($handle) [551] => { [552] => if (!isset($this->vars[$handle])) { [553] => //$this->error("phemplate(): no such handle '$handle'", 'warning'); [554] => return null; // By Sunmin Park 04/05/17 [555] => } [556] => return $this->vars[$handle]; [557] => } [558] => [559] => /** [560] => * value of $handle, no error if no handle [561] => */ [562] => function get_var_silent($handle) [563] => { [564] => if (!isset($this->vars[$handle])) { $this->vars[$handle] = ''; return ''; } [565] => return $this->vars[$handle]; [566] => } [567] => [568] => /** [569] => * assign array to loop handle [570] => * @param string $loop_name - name for a loop [571] => * @param int $loop - loop data [572] => */ [573] => function set_loop($loop_name, $loop) [574] => { [575] => if (!$loop) $loop = 0; [576] => $this->loops[$loop_name] = $loop; [577] => } [578] => [579] => /** [580] => * tie array with loop [581] => */ [582] => function tie_loop($loop_name, &$loop) [583] => { [584] => if (!$loop) $loop = 0; [585] => $this->loops[$loop_name] =& $loop; [586] => } [587] => [588] => /** [589] => * extracts blocks from handle, and returns cleaned up version [590] => * [591] => * must be quite fast, because every found block is imediately taken out of string [592] => * [593] => * [594] => * @since 2001.10.31 works with nested blocks [js] [595] => * @since 2003.06.19 supports customized block syntax [js] [596] => * [597] => */ [598] => function extract_blocks($bl_handle, $recurse = false) [599] => { [600] => [601] => $str = $this->get_var($bl_handle); [602] => if (!$str) return $str; [603] => $bl_start = 0; [604] => [605] => list($bll, $blr) = explode('|', $this->block_start_string); [606] => $strlen = strlen($bll); [607] => [608] => [609] => // find them and clean from parent handle [610] => while(is_long($bl_start = strpos($str, $bll, $bl_start))) [611] => { [612] => $pos = $bl_start + $strlen; [613] => [614] => $endpos = strpos($str, $blr, $pos); [615] => $handle = substr($str, $pos, $endpos-$pos); [616] => [617] => $tag = $bll.$handle.$blr; [618] => $endtag = str_replace('|', $handle, $this->block_end_string); [619] => [620] => $start_pos = $bl_start + strlen($tag); [621] => $end_pos = strpos($str, $endtag, $bl_start); [622] => if (!$end_pos) { $this->error("스킨오류 : </block name=\"$handle\">이 없음", 'fatal'); } [623] => $bl_end = $end_pos + strlen($endtag); [624] => [625] => $block_code = substr($str, $start_pos, $end_pos-$start_pos); [626] => [627] => $this->set_var($handle, $block_code); [628] => [629] => $part1 = substr($str, 0, $bl_start); [630] => $part2 = substr($str, $bl_end, strlen($str)); [631] => [632] => $str = $part1 . $part2; [633] => [634] => if ($recurse) { $this->extract_blocks($handle, 1); } [635] => [636] => } [637] => [638] => $this->set_var($bl_handle, $str); [639] => [640] => } [641] => [642] => [643] => /** [644] => * search for tags in $handle [645] => * be carefull with paths [646] => */ [647] => function include_files($handle) [648] => { [649] => $str = $this->get_var($handle); [650] => [651] => while(is_long($pos = strpos($str, '', $pos); [655] => $filename = substr($str, $pos, $endpos-$pos); [656] => $tag = ''; [657] => [658] => [659] => $include = $this->read_file($filename); [660] => [661] => $str = str_replace($tag, $include, $str); [662] => } [663] => [664] => return $str; [665] => } [666] => [667] => [668] => /** [669] => * searches for all set loops in $handle, returns text of $handle with parsed loops [670] => * @param bool $noloop - must be true, if you want noloop statement [671] => * @return string [672] => */ [673] => function parse_loops($handle, $noloop = false) [674] => { [675] => $str = $this->get_var($handle); [676] => [677] => reset($this->loops); [678] => [679] => while ( list($loop_name, $loop_ar) = each($this->loops) ) [680] => { [681] => [682] => $start_tag = strpos($str, ''); [683] => [684] => $start_pos = $start_tag + strlen(''); [685] => if (!$start_pos) continue; [686] => $end_pos = strpos($str, ''); [687] => [688] => $loop_code = substr($str, $start_pos, $end_pos-$start_pos); [689] => $org_loop_code = $loop_code; [690] => [691] => $start_tag = substr($str, $start_tag, strlen('')); [692] => $end_tag = substr($str, $end_pos, strlen('')); [693] => [694] => if($loop_code != ''){ [695] => [696] => $new_code = ''; [697] => [698] => // clean if ($noloop & TPL_NOLOOP) [700] => { [701] => [702] => $nl_start_tag = strpos($loop_code, ''); [703] => $nl_start_pos = $nl_start_tag + strlen(''); [704] => [705] => [706] => if ($nl_start_pos) [707] => { [708] => [709] => $nl_end_pos = strpos($loop_code, ''); [710] => [711] => $noloop_code = substr($loop_code, $nl_start_pos, $nl_end_pos - $nl_start_pos); [712] => [713] => [714] => $nl_start_tag = substr($loop_code, $nl_start_tag, strlen('')); [715] => $nl_end_tag = substr($loop_code, $nl_end_pos, strlen('')); [716] => $loop_code = str_replace($nl_start_tag.$noloop_code.$nl_end_tag, '', $loop_code); [717] => } [718] => [719] => } [720] => [721] => if (is_array($loop_ar)) [722] => { [723] => [724] => if ($noloop & TPL_LOOP_INNER_PARSED) [725] => { [726] => for($i = 0; isset($loop_ar[$i]); $i++) [727] => [728] => { [729] => $temp_code = $loop_code; [730] => // rememeber loop variables [731] => [732] => $array_keys = array_keys($loop_ar[$i]); [733] => $this->set_var($loop_name, $loop_ar[$i]); [734] => if ($noloop & TPL_LOOP_INNER_OPTIONAL) $temp_code = $this->optional($loop_code); [735] => $temp_code = $this->parse($temp_code); [736] => $new_code .= $temp_code; [737] => [738] => // cleanup loop variables for next generation [739] => foreach ($array_keys as $key) unset($this->vars[$loop_name.'.'.$key]); [740] => [741] => } // for loop [742] => } [743] => else [744] => { [745] => // repeat for every row in array [746] => // for (reset($loop_ar); $row = current($loop_ar); next($loop_ar)) [747] => $ar_keys = array_keys($loop_ar); [748] => $ar_size = count($ar_keys); [749] => for($i = 0; ($i< $ar_size); $i++) [750] => { [751] => $temp_code = $loop_code; [752] => [753] => foreach( $loop_ar[$ar_keys[$i]] as $k=>$v) [754] => { [755] => $temp_code = str_replace( '{'. $loop_name. '.' .$k. '}', $v, $temp_code); [756] => } [757] => $new_code .= $temp_code; [758] => } [759] => } [760] => } elseif ($noloop & TPL_NOLOOP) [761] => { [762] => $new_code = $noloop_code; [763] => } [764] => [765] => [766] => $str = str_replace($start_tag.$org_loop_code.$end_tag, $new_code, $str); [767] => } // if loop code [768] => [769] => } // repeat for loop names [770] => [771] => return $str; [772] => } [773] => [774] => [775] => /** [776] => * process left variables [777] => * @deprecated parse() now handles unknown variables [778] => */ [779] => function finish($str) [780] => { [781] => switch ($this->unknowns) [782] => { [783] => case "keep": [784] => break; [785] => [786] => case "remove": [787] => $str = preg_replace('/{[^ \t\r\n}]+}/', "", $str); [788] => break; [789] => [790] => case "comment": [791] => $str = preg_replace('/{([^ \t\r\n}]+)}/', "", $str); [792] => break; [793] => [794] => case "space": [795] => $str = preg_replace('/{([^ \t\r\n}]+)}/', " ", $str); [796] => break; [797] => [798] => } [799] => [800] => return $str; [801] => } [802] => [803] => /** [804] => * search for optional tag [805] => * @param string $str text [806] => * @return string [807] => */ [808] => function optional($str) [809] => { [810] => $bl_start = 0; [811] => [812] => // extract and clean them from parent handle [813] => while(is_long($bl_start = strpos($str, '', $pos); [818] => $varname = substr($str, $pos, $endpos-$pos); [819] => [820] => $tag = ''; [821] => $endtag = ''; [822] => [823] => $end_pos = strpos($str, $endtag, $bl_start); [824] => if (!$end_pos) { $this->error("스킨오류 <opt name=\"$varname\">가 없음", 'fatal'); } [825] => [826] => $bl_end = $end_pos + strlen($endtag); [827] => [828] => [829] => $part1 = substr($str, 0, $bl_start); [830] => $part2 = substr($str, $bl_end, strlen($str)); [831] => [832] => // if .. by Sunmin Park [833] => if($varname[0]=="!") [834] => { [835] => $varname = substr($varname, 1); [836] => $flag = true; [837] => } [838] => else $flag = false; [839] => [840] => // .. By Sunmin Park [841] => if(strpos($varname,'=')) { [842] => list($varname,$varname_value) = explode('=',$varname,2); [843] => [844] => $value = $this->get_var_silent($varname); [845] => //echo " $value == $varname_value ";exit; [846] => if($value == $varname_value) { [847] => $flag = !$flag; [848] => } [849] => } [850] => else { [851] => $value = $this->get_var_silent($varname); [852] => [853] => //if ($value || $value === 0 || $value === '0') [854] => if ($value and $value !== 'N') [855] => { [856] => $flag = !$flag; [857] => } [858] => } [859] => [860] => if($flag) [861] => { [862] => $start_pos = $bl_start + strlen($tag); [863] => [864] => $block_code = substr($str, $start_pos, $end_pos-$start_pos); [865] => [866] => $str = $part1 . $this->parse($block_code) . $part2; [867] => } [868] => else [869] => { [870] => $str = $part1 . $part2; [871] => } [872] => } [873] => [874] => return $str; [875] => } [876] => [877] => /** [878] => * does everything: loops, includes, variables, concatenation [879] => * if $loop is 0 (not false, but 0) default parameters are used [880] => * thanks ShiVAs for idea to have $loop as parameters. [881] => * [882] => * @param $loop - loop, noloop or all parameters ored. [883] => * @param $append - append processed stuff to target, else $target is overwritten [884] => * @return string [885] => */ [886] => function process($target, $handle, $loop = false, $include = false, $append = false, $finish = false, $optional = false) [887] => { [888] => if ($loop === 0) $loop = $this->parameters; [889] => [890] => $noloop = false; [891] => $parsedloop = false; [892] => $loopopt = false; [893] => if ($loop > 2) [894] => { [895] => $noloop = $loop & TPL_NOLOOP; [896] => $include = $loop & TPL_INCLUDE; [897] => $append = $loop & TPL_APPEND; [898] => $finish = $loop & TPL_FINISH; [899] => $optional = $loop & TPL_OPTIONAL; [900] => $parsedloop = $loop & TPL_LOOP_INNER_PARSED; [901] => $loopopt = $loop & TPL_LOOP_INNER_OPTIONAL; [902] => } [903] => else [904] => { [905] => $noloop = $loop & TPL_NOLOOP; [906] => } [907] => [908] => if ($append) { [909] => if (isset($this->vars[$target])) { [910] => $app = $this->get_var($target); // preserve old info [911] => $this->set_var($target.'.count', $tmp=$this->get_var($target.'.count')+1); // by sunmin (append count) [912] => $this->set_var($target.'.countodd', $tmp%2 ); // by sunmin (append count) [913] => } [914] => else { [915] => $app = ''; [916] => $this->set_var($target.'.count', 1); // by sunmin (append count) [917] => $this->set_var($target.'.countodd', 1); // by sunmin (append count) [918] => } [919] => } [920] => [921] => $this->set_var($target, $this->get_var($handle)); // copy contents [922] => [923] => if ($include) { $this->set_var($target, $this->include_files($target)); } [924] => [925] => [926] => if ($noloop) { $this->set_var($target, $this->parse_loops($target, TPL_NOLOOP | $loopopt | $parsedloop)); } [927] => elseif ($loop) { $this->set_var($target, $this->parse_loops($target, $loopopt | $parsedloop)); } [928] => [929] => if ($optional) { $this->set_var($target, $this->optional($this->get_var_silent($target))); } [930] => [931] => if ($append) { $this->set_var($target, $app . $this->parse($this->get_var_silent($target))); } [932] => else { $this->set_var($target, $this->parse($this->get_var($target))); } [933] => [934] => if ($finish) { $this->set_var($target, $this->finish($this->get_var($target))); } [935] => [936] => return $this->get_var($target); [937] => } [938] => [939] => [940] => /** [941] => * spits out file contents [942] => * @access private [943] => */ [944] => function read_file($file) [945] => { [946] => $filename = $this->root . $file; [947] => [948] => if (!file_exists($filename)) [949] => { [950] => $this->error("phemplate::read_file(): 파일이 없음 - $filename", 'fatal'); [951] => return ''; [952] => } [953] => [954] => $tmp = false; [955] => [956] => $filesize = filesize($filename); [957] => if ($filesize) [958] => { [959] => $tmp = fread($fp = fopen($filename, 'r'), $filesize); [960] => fclose($fp); [961] => [962] => $this->read_files[]= $filename; [963] => } [964] => return $tmp; [965] => } [966] => [967] => /** [968] => * free mem used by loop [969] => */ [970] => function drop_loop($loop_handle) [971] => { [972] => if (isset($this->loops[$loop_handle])) unset($this->loops[$loop_handle]); [973] => } [974] => [975] => [976] => /** [977] => * free mem used by var [978] => */ [979] => function drop_var($handle,$var_value='') [980] => { [981] => if (is_array($var_value)) { // by Sunmin Park [982] => foreach($var_value as $key=>$value) [983] => $this->drop_var($handle.'.'.$key,$value); // recursion for array branches [984] => } [985] => elseif (isset($this->vars[$handle])) unset($this->vars[$handle]); [986] => } [987] => [988] => /** [989] => * set error handler [990] => */ [991] => function set_error_handler(&$eh) [992] => { [993] => $this->error_handler =& $eh; [994] => } [995] => [996] => /** [997] => * change block syntax [998] => */ [999] => function set_block_syntax($start, $end) [1000] => { [1001] => if (!strpos($start, '|')) $this->error("phemplate::set_block_syntax(): no '|' in start tag", 'fatal'); [1002] => if (!strpos($end, '|')) $this->error("phemplate::set_block_syntax(): no '|' in end tag", 'fatal'); [1003] => $this->block_start_string = $start; [1004] => $this->block_end_string = $end; [1005] => } [1006] => [1007] => /** [1008] => * error report [1009] => */ [1010] => function error( $msg, $level = '') [1011] => { [1012] => if (isset($this->error_handler)) [1013] => { [1014] => $lvl = E_USER_WARNING; [1015] => if ('fatal' == $level) $lvl = E_USER_ERROR; [1016] => $this->error_handler->report($lvl, $msg); [1017] => } [1018] => else [1019] => { [1020] => echo "\n
$level: $msg
\n"; [1021] => if ('fatal' == $level) { exit; } [1022] => } [1023] => } [1024] => [1025] => /** [1026] => * SitePHPbasic 반복하는 echoHtml [1027] => * By Sunmin Park 06/07/23 [1028] => */ [1029] => function echoHtml( &$dbinfo, &$SITE, $thisUrl='' ) { [1030] => $val='\\1'.$thisUrl.'skin/'.$dbinfo['skin'].'/images/'; [1031] => // - 사이트 템플릿 읽어오기 [1032] => if(ereg('^(ht|h|t)$',$dbinfo['html_type'])) { [1033] => $HEADER = array ('html_skin'=>$dbinfo['html_skin']); [1034] => @include($SITE['html_path'].'skin.php'); // retrun $aBody[0],$aBody[1] [1035] => } [1036] => [1037] => $html = ''; [1038] => switch($dbinfo['html_type']) { [1039] => case 'ht': [1040] => $html = $aBody[0]; [1041] => $html .= $dbinfo['html_head']; [1042] => $html .= ereg_replace('([="\'(])images/',$val,$this->process('', 'html',TPL_OPTIONAL)); [1043] => $html .= $dbinfo['html_tail']; [1044] => $html .= $aBody[1]; [1045] => break; [1046] => case 'h': [1047] => $html .= $aBody[0] ; [1048] => $html .= $dbinfo['html_head']; [1049] => $html .= ereg_replace('([="\'(])images/',$val,$this->process('', 'html',TPL_OPTIONAL)); [1050] => $html .= $dbinfo['html_tail']; [1051] => break; [1052] => case 't': [1053] => $html .= $dbinfo['html_head']; [1054] => $html .= ereg_replace('([="\'(])images/',$val,$this->process('', 'html',TPL_OPTIONAL)); [1055] => $html .= $dbinfo['html_tail'] ; [1056] => $html .= $aBody[1]; [1057] => break; [1058] => case 'no': [1059] => $html .= ereg_replace('([="\'(])images/',$val,$this->process('', 'html',TPL_OPTIONAL)); [1060] => break; [1061] => default: [1062] => $html .= $dbinfo['html_head']; [1063] => $html .= ereg_replace('([="\'(])images/',$val,$this->process('', 'html',TPL_OPTIONAL)); [1064] => $html .= $dbinfo['html_tail']; [1065] => } // end switch [1066] => [1067] => /* [1068] => if($_GET['utf8']=='euc-kr') { [1069] => // iconv 버그로 인해서 "\n"로 나눔 [1070] => $aA =explode("\n",$html); [1071] => $html =''; [1072] => foreach($aA as $v) $html .= iconv("euc-kr", "UTF-8",$v); [1073] => } [1074] => */ [1075] => [1076] => if($_GET['html_return']) $_GET['html']=$html; [1077] => else echo $html; [1078] => [1079] => // debug 출력 [1080] => if(defined('GET_DEBUG_2') and GET_DEBUG_2) { [1081] => echo "
"; [1082] => echo "skin : $dbinfo[skin], html_type: $dbinfo[html_type], html_skin: $dbinfo[html_skin]
thisUrl:$thisUrl "; [1083] => if('/spb3/sboard3/'==$thisUrl) { [1084] => echo " [게시판수정]"; [1085] => if($_GET['cateuid']) { [1086] => echo " [카테고리수정]"; [1087] => } [1088] => } [1089] => if($dbinfo['table']) { [1090] => echo " [$dbinfo[table]]"; [1091] => } [1092] => echo "
"; [1093] => if(count($this->read_files)) { [1094] => foreach($this->read_files as $filepath) { [1095] => if(strpos($filepath,$_SERVER['DOCUMENT_ROOT'])!==false) { [1096] => $url = substr($filepath,strlen($_SERVER['DOCUMENT_ROOT'])); [1097] => echo "skin file : $url
"; [1098] => } [1099] => else echo "skin file : $filepath
"; [1100] => } [1101] => } [1102] => //echo '
dbinfo ';var_export($dbinfo);

                                            [1103] => 			//echo '
'; [1104] => echo '
'; [1105] => } [1106] => } [1107] => } [1108] => ?> ) [new] => [ovalue] => // $Id: class_phemplate.php 13 2010-08-24 08:28:50Z sitehis $ [oindex] => 1 [nkeys] => ) ) ) [1] => Array ( [file] => /wecan/cc/cc.sdong.kr/spb3/sadmin/util/svn/spb3_diff.php [line] => 142 [function] => doDiff [class] => diff [object] => diff Object ( [changes] => Array ( ) [diff] => Array ( ) [linepadding] => 2 ) [type] => -> [args] => Array ( [0] => /wecan/cc/cc.sdong.kr/spb3/sinc/lib/class_phemplate.php [1] => ) ) [2] => Array ( [file] => /wecan/cc/cc.sdong.kr/spb3/sadmin/util/svn/spb3_diff.php [line] => 197 [function] => diffWrap [class] => diff [object] => diff Object ( [changes] => Array ( ) [diff] => Array ( ) [linepadding] => 2 ) [type] => -> [args] => Array ( [0] => /wecan/cc/cc.sdong.kr/spb3/sinc/lib/class_phemplate.php [1] => ) ) [3] => Array ( [file] => /wecan/cc/cc.sdong.kr/spb3/sadmin/util/svn/spb3_diff.php [line] => 92 [function] => inline [class] => diff [object] => diff Object ( [changes] => Array ( ) [diff] => Array ( ) [linepadding] => 2 ) [type] => -> [args] => Array ( [0] => /wecan/cc/cc.sdong.kr/spb3/sinc/lib/class_phemplate.php [1] => [2] => 2 ) ) ) [key] => 3 [value] => Array ( [file] => /wecan/cc/cc.sdong.kr/spb3/sadmin/util/svn/spb3_diff.php [line] => 92 [function] => inline [class] => diff [object] => diff Object ( [changes] => Array ( ) [diff] => Array ( ) [linepadding] => 2 ) [type] => -> [args] => Array ( [0] => /wecan/cc/cc.sdong.kr/spb3/sinc/lib/class_phemplate.php [1] => [2] => 2 ) ) )
sitePHPbasic 디버그 모드 : WARNING
[2] array_keys() expects parameter 1 to be array, boolean given
Line : 122 (file:/wecan/cc/cc.sdong.kr/spb3/sadmin/util/svn/spb3_diff.php)
- 디버그 추적(debug_backtrace)
#0 spb_error_handler() 함수사용, line(),
#1 array_keys() 함수사용, line(122), /wecan/cc/cc.sdong.kr/spb3/sadmin/util/svn/spb3_diff.php
#2 doDiff() 함수사용, line(142), /wecan/cc/cc.sdong.kr/spb3/sadmin/util/svn/spb3_diff.php
#3 diffWrap() 함수사용, line(197), /wecan/cc/cc.sdong.kr/spb3/sadmin/util/svn/spb3_diff.php
#4 inline() 함수사용, line(92), /wecan/cc/cc.sdong.kr/spb3/sadmin/util/svn/spb3_diff.php




사용변수들 ...
$_GET = Array ( [md5_path] => /spb3/sinc/lib/class_phemplate.php ) $_POST = Array ( ) $_COOKIE = Array ( ) Array ( [errno] => 2 [errstr] => array_keys() expects parameter 1 to be array, boolean given [errfile] => /wecan/cc/cc.sdong.kr/spb3/sadmin/util/svn/spb3_diff.php [errline] => 122 [arr] => Array ( [0] => Array ( [function] => spb_error_handler [args] => Array ( [0] => 2 [1] => array_keys() expects parameter 1 to be array, boolean given [2] => /wecan/cc/cc.sdong.kr/spb3/sadmin/util/svn/spb3_diff.php [3] => 122 [4] => Array ( [old] => Array ( [0] => // $Id: class_phemplate.php 13 2010-08-24 08:28:50Z sitehis $ [2] => // 04/05/17 박선민 340L get_var() chanage to same get_var_silent() [3] => // 04/05/17 박선민 696L optional() add and change etc.. [4] => // 05/01/25 박선민 828L drop_var() add recursion for array branches [5] => // 05/11/20 박선민 echoHtml()로 반복하는 sitePHPbasic 마무리 부분 함수로 [6] => // 07/03/18 박선민 {!e.abc} 인경우 urlencoding 등의 기능 추가 [7] => // 07/08/14 박선민 {#widget.???} 윗젯 include 기능 추가 [8] => // 07/09/16 박선민 {#content.keyword} spb3_content 테이블의 keyword에 대한 content가져와서 넣는 기능 추가 [9] => // 08/06/14 박선민 $_GET[html_return] 기능 추가 [10] => // 08/06/28 박선민 831L optional() change 값이 'N'이여도 false되게 [11] => // 08/07/13 박선민 716L // cut_string {#cut.50#0#….key} 기능 추가 [12] => // 08/07/29 박선민 546L // parse() ... IF문 기능 추가 [13] => // 08/10/06 박선민 {#sub.2.3.???} 기능 추가 [14] => // 08/11/08 박선민 #content.??? 기능 개선 [15] => // 08/11/29 박선민 bugfix - don't use &$this [16] => // 09/01/04 박선민 {#widget2.???} 윗젯2 기능 추가(php파일위치에 widget2_???.php를 읽어서 함수 실행 [17] => // 09/02/04 박선민 {!N.list.number} 기능 추가 [18] => // 09/02/06 박선민 GET_DEBUG_2 기능 추가 [19] => // 09/02/25 박선민 {#exp.0.-.key}, server.server.HTTP_REFERER 추가 [20] => // 09/03/11 박선민 {!A.str} javascript에서 변수넘길때 큰따옴표 오류 해결용 [21] => // 09/05/08 박선민 bugfix - GET_DEBUG_2 false였을 때 오류 [22] => // 09/05/31 박선민 {!B.str} table, excel등에서 빈값은  로 변환하여 리턴하도록 [23] => // 09/05/31 박선민 {!?.str} 링크에 ?가 없으면 ?를 붙여주도록 [24] => // 09/07/28 박선민 {!X.name} : xmlspecialchars 변환 기능 추가 [25] => //---------------------------------------------------------------------------// [26] => // author: pukomuko [27] => // date: 2001.03.15 [28] => // web: http://pukomuko.esu.lt [29] => // http://sourceforge.net/projects/phemplate [30] => // info: template engine [31] => //---------------------------------------------------------------------------// [32] => // copyleft license [33] => // [34] => // this software is provided 'as-is', without any express or implied [35] => // warranty. in no event will the authors be held liable for any damages [36] => // arising from the use of this software. [37] => // [38] => // permission is granted to anyone to use this software for any purpose, [39] => // including commercial applications, and to alter it and redistribute it [40] => // freely, subject to the following restrictions: [41] => // [42] => // 1. the origin of this software must not be misrepresented; [43] => // you must not claim that you wrote the original software. [44] => // if you use this software in a product, an acknowledgment [45] => // in the product documentation would be appreciated but is not required. [46] => // [47] => // 2. altered source versions must be plainly marked as such, [48] => // and must not be misrepresented as being the original software. [49] => // [50] => // 3. mail about the fact of using this class in production [51] => // would be very appreciated. [52] => // [53] => // 4. this notice may not be removed or altered from any source distribution. [54] => // [55] => //---------------------------------------------------------------------------// [56] => // changes: [57] => // [58] => // 2004.04.21 [59] => // - warining on empty file [60] => // * v1.10.1 [61] => [62] => /** [63] => */ [64] => define('TPL_LOOP', 1); [65] => define('TPL_NOLOOP', 2); [66] => define('TPL_INCLUDE', 4); [67] => define('TPL_APPEND', 8); [68] => define('TPL_FINISH', 16); [69] => define('TPL_OPTIONAL', 32); [70] => define('TPL_LOOP_INNER_PARSED',64); [71] => define('TPL_LOOP_INNER_OPTIONAL', 128); [72] => [73] => define('TPL_PARSEDLOOP', TPL_LOOP | TPL_LOOP_INNER_PARSED); [74] => define('TPL_OPTLOOP', TPL_PARSEDLOOP | TPL_LOOP_INNER_OPTIONAL); [75] => [76] => [77] => define('TPL_BLOCK', 1); [78] => define('TPL_BLOCKREC', 2); [79] => define('TPL_STRIP_UTF_HEADER', 4); [80] => [81] => class phemplate [82] => { [83] => /** [84] => * 현재 클래스가 있는 드렉토리 By Sunmin [85] => */ [86] => var $widgetPath =''; [87] => [88] => var $read_files = array(); [89] => [90] => /** [91] => * spb3_content에서 읽어온 것을 캐쉬 [92] => */ [93] => var $spb3_content = array(); [94] => [95] => [96] => /** [97] => * variables and blocks [98] => */ [99] => var $vars = array(); [100] => [101] => /** [102] => * loops container [103] => */ [104] => var $loops = array(); [105] => [106] => /** [107] => * dir of template files [108] => */ [109] => var $root = ''; [110] => [111] => /** [112] => * what to do with unknown variables in template? [113] => */ [114] => var $unknowns = 'keep'; [115] => [116] => /** [117] => * default parameters for process() loop, append, finish [118] => */ [119] => var $parameters = 0; [120] => [121] => [122] => /** [123] => * object having method report($level, $msg) [124] => * you can catch error messages from template. [125] => */ [126] => var $error_handler = null; [127] => [128] => [129] => [130] => /** [131] => * start tag for block [132] => */ [133] => var $block_start_string = ''; [134] => [135] => /** [136] => * end tag for block [137] => */ [138] => var $block_end_string = ''; [139] => [140] => /** [141] => * constructor [142] => * $unknows를 keep에서 remove_nonjs로 변경함 by Sunmin Park [143] => */ [144] => function phemplate( $root_dir = '', $unknowns = 'remove_nonjs', $params = 0) [145] => { [146] => // widget, widget2 path [147] => $this->widgetPath = dirname(dirname(__FILE__)).'/widget/'; // By Sunmin [148] => if($this->set_root($root_dir)) [149] => $this->widget2Path = dirname(dirname($this->root)).'/'; // By Sunmin [150] => $this->set_unknowns($unknowns); [151] => $this->set_params($params); [152] => [153] => [154] => [155] => // 기본 set_var by Sunmin [156] => $this->tie_var('SITE' ,$GLOBALS['SITE']); // $SITE 전역변수 [157] => $this->tie_var('get' ,$_GET); [158] => $this->set_var('braces' ,'{'); // 중괄호{braces} 표현 [159] => $this->set_var('nowtime',time()); [160] => [161] => $this->tie_var('session.seUid' ,$_SESSION['seUid']); // 로그인 uid [162] => $this->tie_var('session.seUserid' ,$_SESSION['seUserid']); // 로그인 userid [163] => $this->tie_var('session.seName' ,$_SESSION['seName']); // 로그인 이름 [164] => $this->tie_var('session.seNickname' ,$_SESSION['seNickname']); // 로그인 별명 [165] => $this->tie_var('session.seEmail' ,$_SESSION['seEmail']); [166] => $this->tie_var('session.sePoint' ,$_SESSION['sePoint']); [167] => $this->tie_var('session.seCoupon' ,$_SESSION['seCoupon']); [168] => $this->tie_var('session.sePriv' ,$_SESSION['sePriv']); [169] => [170] => $this->set_var('server.HTTP_HOST' ,$_SERVER['HTTP_HOST']); [171] => $this->set_var('server.HTTP_REFERER',$_SERVER['HTTP_REFERER']); [172] => $this->set_var('server.QUERY_STRING' ,$_SERVER['QUERY_STRING']); [173] => $this->set_var('server.REQUEST_URI' ,$_SERVER['REQUEST_URI']); [174] => $this->set_var('server.PHP_SELF' ,$_SERVER['PHP_SELF']); [175] => } [176] => [177] => /** [178] => substitute text and returns parsed string [179] => @author ZaZa (Sergej Kurakin) 2003.05.05 21:52 [180] => */ [181] => function parse($string) [182] => { [183] => $str = explode('{', $string); [184] => [185] => $res = ''; [186] => [187] => for ($i = 0; isset($str[$i]); $i++) [188] => { [189] => $line = explode('}', $str[$i]); [190] => if ($i === 0) [191] => { [192] => $res .= $line[0]; [193] => } [194] => else [195] => { [196] => $key = $line[0]; [197] => unset($line[0]); [198] => [199] => if ( $key && isset($this->vars[$key]) ) [200] => { [201] => $res .= $this->vars[$key].implode('}', $line); [202] => } [203] => else [204] => { [205] => // {!d.list.rdate} 등 By Sunmin [206] => if($key[0]=='!') { // and isset($this->vars[substr($key,3)])) { [207] => switch(substr($key,1,2)) { [208] => /** [209] => ** 대소문자 구분함 [210] => {!B.name} : 값이 없으면   [211] => {!b.name} : 문장에서 엔터를
로 변환함 [212] => {!S.name} : 문장에서 html 테그를 모두 제거하고, 엔터는
로 변환함 [213] => [214] => {!a.name} : '\' addslashes 삽입 [215] => {!A.name} : javascript에서 변수넘길때 funcname('{!A.str}') [216] => {!s.name} : addslashes된 것을 stripcslashes함 [217] => {!?.name} : 문자열 중간 혹은 끝에 ?가 없으면 맨뒤에 ?를 붙여줌 [218] => [219] => {!h.name} : HTML특수문자로 변환( 큰따옴표도 변환 ) [220] => {!H.name} : HTML특수문자로 변환( 큰따옴표는 그대로 나둠) [221] => {!x.name} : stripcslashes함 하고 HTML특수문자로 변환( 큰따옴표도 변환) [222] => {!X.name} : xmlspecialchars 변환 [223] => [224] => {!e.url} : URL ENCODE [225] => [226] => {!n.price} : 숫자에 콤마 추가(단, 값이 없으면 무조건 '0' 리턴) [227] => {!N.price} : 숫자에 콤마 추가(단, ''값이면 빈값으로 리턴 [228] => [229] => {!D.rdate} : 숫자날짜를 YYYY-MM-DD로 변환 (연도가 4자리) [230] => {!d.rdate} : 숫자날짜를 YY-MM-DD로 변환 (연도가 2자리) [231] => {!T.rdate} : 숫자날짜를 YY-MM-DD H:i:s로 변환 (ex, 2009-01-01 23:59:55) [232] => {!t.rdate} : 숫자날짜를 시간인 H:i:s로 변환 (ex, 23:59:55) [233] => {!g.rdate} : 숫자날짜를 국제표준 한국시간으로 'D, j M Y G:i:s +0900' [234] => **/ [235] => case 'B.': [236] => if(empty($this->vars[substr($key,3)]) and $this->vars[substr($key,3)]!="0") [237] => $res .= ' '.implode('}', $line); [238] => else $res .= $this->vars[substr($key,3)].implode('}', $line); [239] => continue 2; [240] => break; [241] => case 'b.': [242] => $res .= nl2br($this->vars[substr($key,3)]).implode('}', $line); [243] => continue 2; [244] => break; [245] => case 'S.': // strip_tags(),
tag취환 [246] => $res .= ereg_replace("(\r\n|\n|\r)", '
',strip_tags($this->vars[substr($key,3)])).implode('}', $line); [247] => continue 2; [248] => break; [249] => case 'a.': [250] => $res .= addslashes($this->vars[substr($key,3)]).implode('}', $line); [251] => continue 2; [252] => break; [253] => case 'A.': [254] => $res .= str_replace('\\"','"',addslashes($this->vars[substr($key,3)])).implode('}', $line); [255] => continue 2; [256] => break; [257] => case 's.': [258] => $res .= stripcslashes($this->vars[substr($key,3)]).implode('}', $line); [259] => continue 2; [260] => break; [261] => case '?.': [262] => if(false===strpos($this->vars[substr($key,3)],'?')) [263] => $res .= $this->vars[substr($key,3)].'?'.implode('}', $line); [264] => else [265] => $res .= $this->vars[substr($key,3)].implode('}', $line); [266] => continue 2; [267] => break; [268] => case 'h.': [269] => $res .= htmlspecialchars($this->vars[substr($key,3)],ENT_QUOTES).implode('}', $line); [270] => continue 2; [271] => break; [272] => case 'H.': [273] => $res .= htmlspecialchars($this->vars[substr($key,3)],ENT_NOQUOTES).implode('}', $line); [274] => continue 2; [275] => break; [276] => case 'x.': [277] => $res .= htmlspecialchars(stripcslashes($this->vars[substr($key,3)]),ENT_QUOTES).implode('}', $line); [278] => continue 2; [279] => break; [280] => case 'X.': [281] => $res .= str_replace(''', ''', htmlspecialchars($this->vars[substr($key,3)], ENT_QUOTES)).implode('}', $line); [282] => continue 2; [283] => break; [284] => case 'e.': [285] => $res .= urlencode($this->vars[substr($key,3)]).implode('}', $line); [286] => continue 2; [287] => break; [288] => case 'n.': [289] => $res .= number_format((int)$this->vars[substr($key,3)]).implode('}', $line); [290] => continue 2; [291] => break; [292] => case 'N.': [293] => if($this->vars[substr($key,3)] or $this->vars[substr($key,3)]==='0' or $this->vars[substr($key,3)]===0) [294] => $res .= number_format($this->vars[substr($key,3)]).implode('}', $line); [295] => else $res .= implode('}', $line); [296] => continue 2; [297] => break; [298] => case 'D.': [299] => if($this->vars[substr($key,3)]) [300] => $res .= date('Y-m-d',$this->vars[substr($key,3)]).implode('}', $line); [301] => else $res .= implode('}', $line); [302] => continue 2; [303] => break; [304] => case 'd.': [305] => if($this->vars[substr($key,3)]) [306] => $res .= date('y-m-d',$this->vars[substr($key,3)]).implode('}', $line); [307] => else $res .= implode('}', $line); [308] => continue 2; [309] => break; [310] => case 'T.': [311] => if($this->vars[substr($key,3)]) [312] => $res .= date('y-m-d H:i:s',$this->vars[substr($key,3)]).implode('}', $line); [313] => else $res .= implode('}', $line); [314] => continue 2; [315] => break; [316] => case 't.': [317] => if($this->vars[substr($key,3)]) [318] => $res .= date('H:i:s',$this->vars[substr($key,3)]).implode('}', $line); [319] => else $res .= implode('}', $line); [320] => continue 2; [321] => break; [322] => case 'g.': [323] => if($this->vars[substr($key,3)]) [324] => $res .= date('D, j M Y G:i:s +0900',$this->vars[substr($key,3)]).implode('}', $line); [325] => else $res .= implode('}', $line); [326] => continue 2; [327] => break; [328] => } [329] => } [330] => [331] => if($key[0]=='#') { [332] => // /spb3/sinc/widget/???.php By Sunmin [333] => if('widget.'==substr($key,1,7)) { [334] => $tmpWidget2 = substr($key,8); [335] => list($tmpWidget,$tmpKey) = explode('.',$tmpWidget2,2); [336] => if(eregi('^[-_a-z0-9]+$',$tmpWidget) and is_file($this->widgetPath . $tmpWidget . '/index.php')) { [337] => @include_once($this->widgetPath .$tmpWidget . '/index.php'); [338] => $func = 'widget_'.$tmpWidget; [339] => $res .= @$func($this,$tmpKey) . implode('}', $line); [340] => continue; [341] => } [342] => } [343] => elseif('widget2.'==substr($key,1,8)) { [344] => $tmpWidget2 = substr($key,9); [345] => list($tmpWidget,$tmpKey) = explode('.',$tmpWidget2,2); [346] => if(eregi('^[-_a-z0-9]+$',$tmpWidget) and is_file($this->widget2Path . 'widget2_'.$tmpWidget . '.php')) { [347] => @include_once($this->widget2Path . 'widget2_'.$tmpWidget . '.php'); [348] => $func = 'widget2_'.$tmpWidget; [349] => $res .= @$func($this,$tmpKey) . implode('}', $line); [350] => continue; [351] => } [352] => }elseif('include.'==substr($key,1,8)) { [353] => $tmpFilename = substr($key,9); [354] => if(is_file($this->root.'/include_'.$tmpFilename.'.html')) { [355] => $res .= @file_get_contents($this->root.'include_'.$tmpFilename.'.html') . implode('}', $line); [356] => } [357] => else $res .= implode('}', $line); [358] => continue; [359] => } [360] => // spb3_content읽어서 keyword에서 content 전송 [361] => elseif('content.'==substr($key,1,8)) { [362] => list($tmp,$tmpKeyword,$tmpContent) = explode('.',$key,3); [363] => if(!$tmpContent) $tmpContent = 'content'; [364] => if(!isset($this->spb3_content[$tmpContent])) { [365] => $this->spb3_content[$tmpContent] = db_resultdata($GLOBALS['SITE']['th'].'cate_content',$tmpContent,'keyword',$tmpKeyword); [366] => } [367] => $res .= $this->spb3_content[$tmpContent] . implode('}', $line); [368] => continue; [369] => } [370] => // cut_string {#cut.50#0#….key} [371] => elseif('cut.'==substr($key,1,4)) { [372] => list($tmp,$tmpCut,$tmpKey) = explode('.',$key,3); [373] => list($tmpCut1,$tmpCut2,$tmpCut3) = explode('#',$tmpCut,3); [374] => if($tmpCut1===NULL) $tmpCut1 = 50; [375] => if($tmpCut2===NULL) $tmpCut2 = 0; [376] => if($tmpCut3===NULL) $tmpCut3 = '…'; [377] => $res .= cut_string($this->vars[$tmpKey],$tmpCut1,$tmpCut2,$tmpCut3).implode('}', $line); [378] => continue; [379] => } [380] => // substr {#sub.2.3.key} [381] => elseif('sub.'==substr($key,1,4)) { [382] => list($tmp,$tmpSub1,$tmpSub2,$tmpKey) = explode('.',$key,4); [383] => $res .= substr($this->vars[$tmpKey],(int)$tmpSub1,(int)$tmpSub2).implode('}', $line); [384] => continue; [385] => } [386] => // explode(split) {#exp.0.-.key} 0번째, -으로 나누어서 [387] => elseif('exp.'==substr($key,1,4)) { [388] => $tmp = explode('.',$key,4); [389] => if(4==count($tmp)) { [390] => $tmp2 = explode($tmp[2],$this->vars[$tmp[3]]); [391] => $res .= $tmp2[$tmp[1]].implode('}', $line); [392] => } [393] => else $res .= implode('}', $line); [394] => continue; [395] => } [396] => } [397] => [398] => switch ($this->unknowns) [399] => { [400] => case "keep": [401] => $res .= '{'.$key; [402] => if (count ($line) > 0) [403] => { [404] => $res .= '}'; [405] => $res .= implode('}', $line); [406] => } [407] => break; [408] => [409] => case "remove": [410] => $res .= implode('', $line); [411] => break; [412] => [413] => case "remove_nonjs": [414] => if (!empty($key) && ((false === strpos($key, ' ')) && (false === strpos($key, "\n")) && (false === strpos($key, "\t")))) [415] => { [416] => $res .= implode('}', $line); [417] => } [418] => else [419] => { [420] => $res .= '{'.$key; [421] => if (count ($line) > 0) [422] => { [423] => $res .= '}'; [424] => $res .= implode('}', $line); [425] => } [426] => } [427] => break; [428] => [429] => case "comment": [430] => $res .= ''.implode('', $line); [431] => break; [432] => [433] => case "space": [434] => $res .= ' '.implode('', $line); [435] => break; [436] => [437] => } [438] => } [439] => } [440] => } [441] => [442] => return $res; [443] => } [444] => [445] => /** [446] => * check and set template root dir [447] => */ [448] => function set_root($root) [449] => { [450] => if (empty($root)) return; [451] => if (!is_dir($root)) [452] => { [453] => $this->error("phemplate::set_root(): 다음 드렉토리가 없습니다 : $root", 'warning'); [454] => return false; [455] => } [456] => [457] => $this->root = realpath($root).'/'; // By Sunmin 05/11/13 [458] => return true; [459] => } [460] => [461] => /** [462] => * what to do with unknown variables in template? [463] => * keep [464] => * remove [465] => * remove_nonjs [466] => * comment [467] => * space [468] => */ [469] => function set_unknowns($unk) [470] => { [471] => $this->unknowns = $unk; [472] => } [473] => [474] => /** [475] => * set default parameters for process() [476] => */ [477] => function set_params($params) [478] => { [479] => $this->parameters = $params; [480] => } [481] => [482] => /** [483] => * read file template into $vars [484] => * @param string $handle - name of handle for file contents [485] => * @param int $blocks - 1 for search, 2 for nested blocks [486] => * [487] => */ [488] => function set_file($handle, $filename = "", $blocks = false) [489] => { [490] => if ($filename == "") [491] => { [492] => $this->error("phemplate::set_file(): 파일이름이 빈값으로 넘어왔습니다 -$handle", 'fatal'); [493] => return false; [494] => } [495] => $this->vars[$handle] = $this->read_file($filename); [496] => if ($blocks & TPL_STRIP_UTF_HEADER) [497] => { [498] => $header = substr($this->vars[$handle], 0, 3); [499] => if ("\xEF\xBB\xBF" == $header) $this->vars[$handle] = substr($this->vars[$handle], 3); [500] => } [501] => if ($blocks) { $this->extract_blocks($handle, $blocks & TPL_BLOCKREC); } [502] => return true; [503] => [504] => } [505] => [506] => [507] => /** [508] => * set handle and value, [509] => * if value is array, all elements will be named: handle.key.subkey [510] => */ [511] => function set_var($var_name, $var_value) [512] => { [513] => if (is_array($var_value)) [514] => { [515] => foreach($var_value as $key=>$value) [516] => { [517] => $this->set_var($var_name . '.' . $key, $value); // recursion for array branches [518] => } [519] => } [520] => else // normal variable [521] => { [522] => $this->vars[$var_name] = $var_value; [523] => } [524] => } [525] => [526] => /** [527] => * tie value with variable [528] => * it's not possible to update array keys, just values [529] => */ [530] => function tie_var($var_name, &$var_value) [531] => { [532] => if (is_array($var_value)) [533] => { [534] => $list = array_keys($var_value); [535] => foreach($list as $key) [536] => { [537] => $this->tie_var($var_name . '.' . $key, $var_value[$key]); // recursion for array branches [538] => } [539] => } [540] => else // normal variable [541] => { [542] => $this->vars[$var_name] =& $var_value; [543] => } [544] => } [545] => [546] => /** [547] => * value of $handle [548] => * raises error if $handle undefined [549] => */ [550] => function get_var($handle) [551] => { [552] => if (!isset($this->vars[$handle])) { [553] => //$this->error("phemplate(): no such handle '$handle'", 'warning'); [554] => return null; // By Sunmin Park 04/05/17 [555] => } [556] => return $this->vars[$handle]; [557] => } [558] => [559] => /** [560] => * value of $handle, no error if no handle [561] => */ [562] => function get_var_silent($handle) [563] => { [564] => if (!isset($this->vars[$handle])) { $this->vars[$handle] = ''; return ''; } [565] => return $this->vars[$handle]; [566] => } [567] => [568] => /** [569] => * assign array to loop handle [570] => * @param string $loop_name - name for a loop [571] => * @param int $loop - loop data [572] => */ [573] => function set_loop($loop_name, $loop) [574] => { [575] => if (!$loop) $loop = 0; [576] => $this->loops[$loop_name] = $loop; [577] => } [578] => [579] => /** [580] => * tie array with loop [581] => */ [582] => function tie_loop($loop_name, &$loop) [583] => { [584] => if (!$loop) $loop = 0; [585] => $this->loops[$loop_name] =& $loop; [586] => } [587] => [588] => /** [589] => * extracts blocks from handle, and returns cleaned up version [590] => * [591] => * must be quite fast, because every found block is imediately taken out of string [592] => * [593] => * [594] => * @since 2001.10.31 works with nested blocks [js] [595] => * @since 2003.06.19 supports customized block syntax [js] [596] => * [597] => */ [598] => function extract_blocks($bl_handle, $recurse = false) [599] => { [600] => [601] => $str = $this->get_var($bl_handle); [602] => if (!$str) return $str; [603] => $bl_start = 0; [604] => [605] => list($bll, $blr) = explode('|', $this->block_start_string); [606] => $strlen = strlen($bll); [607] => [608] => [609] => // find them and clean from parent handle [610] => while(is_long($bl_start = strpos($str, $bll, $bl_start))) [611] => { [612] => $pos = $bl_start + $strlen; [613] => [614] => $endpos = strpos($str, $blr, $pos); [615] => $handle = substr($str, $pos, $endpos-$pos); [616] => [617] => $tag = $bll.$handle.$blr; [618] => $endtag = str_replace('|', $handle, $this->block_end_string); [619] => [620] => $start_pos = $bl_start + strlen($tag); [621] => $end_pos = strpos($str, $endtag, $bl_start); [622] => if (!$end_pos) { $this->error("스킨오류 : </block name=\"$handle\">이 없음", 'fatal'); } [623] => $bl_end = $end_pos + strlen($endtag); [624] => [625] => $block_code = substr($str, $start_pos, $end_pos-$start_pos); [626] => [627] => $this->set_var($handle, $block_code); [628] => [629] => $part1 = substr($str, 0, $bl_start); [630] => $part2 = substr($str, $bl_end, strlen($str)); [631] => [632] => $str = $part1 . $part2; [633] => [634] => if ($recurse) { $this->extract_blocks($handle, 1); } [635] => [636] => } [637] => [638] => $this->set_var($bl_handle, $str); [639] => [640] => } [641] => [642] => [643] => /** [644] => * search for tags in $handle [645] => * be carefull with paths [646] => */ [647] => function include_files($handle) [648] => { [649] => $str = $this->get_var($handle); [650] => [651] => while(is_long($pos = strpos($str, '', $pos); [655] => $filename = substr($str, $pos, $endpos-$pos); [656] => $tag = ''; [657] => [658] => [659] => $include = $this->read_file($filename); [660] => [661] => $str = str_replace($tag, $include, $str); [662] => } [663] => [664] => return $str; [665] => } [666] => [667] => [668] => /** [669] => * searches for all set loops in $handle, returns text of $handle with parsed loops [670] => * @param bool $noloop - must be true, if you want noloop statement [671] => * @return string [672] => */ [673] => function parse_loops($handle, $noloop = false) [674] => { [675] => $str = $this->get_var($handle); [676] => [677] => reset($this->loops); [678] => [679] => while ( list($loop_name, $loop_ar) = each($this->loops) ) [680] => { [681] => [682] => $start_tag = strpos($str, ''); [683] => [684] => $start_pos = $start_tag + strlen(''); [685] => if (!$start_pos) continue; [686] => $end_pos = strpos($str, ''); [687] => [688] => $loop_code = substr($str, $start_pos, $end_pos-$start_pos); [689] => $org_loop_code = $loop_code; [690] => [691] => $start_tag = substr($str, $start_tag, strlen('')); [692] => $end_tag = substr($str, $end_pos, strlen('')); [693] => [694] => if($loop_code != ''){ [695] => [696] => $new_code = ''; [697] => [698] => // clean if ($noloop & TPL_NOLOOP) [700] => { [701] => [702] => $nl_start_tag = strpos($loop_code, ''); [703] => $nl_start_pos = $nl_start_tag + strlen(''); [704] => [705] => [706] => if ($nl_start_pos) [707] => { [708] => [709] => $nl_end_pos = strpos($loop_code, ''); [710] => [711] => $noloop_code = substr($loop_code, $nl_start_pos, $nl_end_pos - $nl_start_pos); [712] => [713] => [714] => $nl_start_tag = substr($loop_code, $nl_start_tag, strlen('')); [715] => $nl_end_tag = substr($loop_code, $nl_end_pos, strlen('')); [716] => $loop_code = str_replace($nl_start_tag.$noloop_code.$nl_end_tag, '', $loop_code); [717] => } [718] => [719] => } [720] => [721] => if (is_array($loop_ar)) [722] => { [723] => [724] => if ($noloop & TPL_LOOP_INNER_PARSED) [725] => { [726] => for($i = 0; isset($loop_ar[$i]); $i++) [727] => [728] => { [729] => $temp_code = $loop_code; [730] => // rememeber loop variables [731] => [732] => $array_keys = array_keys($loop_ar[$i]); [733] => $this->set_var($loop_name, $loop_ar[$i]); [734] => if ($noloop & TPL_LOOP_INNER_OPTIONAL) $temp_code = $this->optional($loop_code); [735] => $temp_code = $this->parse($temp_code); [736] => $new_code .= $temp_code; [737] => [738] => // cleanup loop variables for next generation [739] => foreach ($array_keys as $key) unset($this->vars[$loop_name.'.'.$key]); [740] => [741] => } // for loop [742] => } [743] => else [744] => { [745] => // repeat for every row in array [746] => // for (reset($loop_ar); $row = current($loop_ar); next($loop_ar)) [747] => $ar_keys = array_keys($loop_ar); [748] => $ar_size = count($ar_keys); [749] => for($i = 0; ($i< $ar_size); $i++) [750] => { [751] => $temp_code = $loop_code; [752] => [753] => foreach( $loop_ar[$ar_keys[$i]] as $k=>$v) [754] => { [755] => $temp_code = str_replace( '{'. $loop_name. '.' .$k. '}', $v, $temp_code); [756] => } [757] => $new_code .= $temp_code; [758] => } [759] => } [760] => } elseif ($noloop & TPL_NOLOOP) [761] => { [762] => $new_code = $noloop_code; [763] => } [764] => [765] => [766] => $str = str_replace($start_tag.$org_loop_code.$end_tag, $new_code, $str); [767] => } // if loop code [768] => [769] => } // repeat for loop names [770] => [771] => return $str; [772] => } [773] => [774] => [775] => /** [776] => * process left variables [777] => * @deprecated parse() now handles unknown variables [778] => */ [779] => function finish($str) [780] => { [781] => switch ($this->unknowns) [782] => { [783] => case "keep": [784] => break; [785] => [786] => case "remove": [787] => $str = preg_replace('/{[^ \t\r\n}]+}/', "", $str); [788] => break; [789] => [790] => case "comment": [791] => $str = preg_replace('/{([^ \t\r\n}]+)}/', "", $str); [792] => break; [793] => [794] => case "space": [795] => $str = preg_replace('/{([^ \t\r\n}]+)}/', " ", $str); [796] => break; [797] => [798] => } [799] => [800] => return $str; [801] => } [802] => [803] => /** [804] => * search for optional tag [805] => * @param string $str text [806] => * @return string [807] => */ [808] => function optional($str) [809] => { [810] => $bl_start = 0; [811] => [812] => // extract and clean them from parent handle [813] => while(is_long($bl_start = strpos($str, '', $pos); [818] => $varname = substr($str, $pos, $endpos-$pos); [819] => [820] => $tag = ''; [821] => $endtag = ''; [822] => [823] => $end_pos = strpos($str, $endtag, $bl_start); [824] => if (!$end_pos) { $this->error("스킨오류 <opt name=\"$varname\">가 없음", 'fatal'); } [825] => [826] => $bl_end = $end_pos + strlen($endtag); [827] => [828] => [829] => $part1 = substr($str, 0, $bl_start); [830] => $part2 = substr($str, $bl_end, strlen($str)); [831] => [832] => // if .. by Sunmin Park [833] => if($varname[0]=="!") [834] => { [835] => $varname = substr($varname, 1); [836] => $flag = true; [837] => } [838] => else $flag = false; [839] => [840] => // .. By Sunmin Park [841] => if(strpos($varname,'=')) { [842] => list($varname,$varname_value) = explode('=',$varname,2); [843] => [844] => $value = $this->get_var_silent($varname); [845] => //echo " $value == $varname_value ";exit; [846] => if($value == $varname_value) { [847] => $flag = !$flag; [848] => } [849] => } [850] => else { [851] => $value = $this->get_var_silent($varname); [852] => [853] => //if ($value || $value === 0 || $value === '0') [854] => if ($value and $value !== 'N') [855] => { [856] => $flag = !$flag; [857] => } [858] => } [859] => [860] => if($flag) [861] => { [862] => $start_pos = $bl_start + strlen($tag); [863] => [864] => $block_code = substr($str, $start_pos, $end_pos-$start_pos); [865] => [866] => $str = $part1 . $this->parse($block_code) . $part2; [867] => } [868] => else [869] => { [870] => $str = $part1 . $part2; [871] => } [872] => } [873] => [874] => return $str; [875] => } [876] => [877] => /** [878] => * does everything: loops, includes, variables, concatenation [879] => * if $loop is 0 (not false, but 0) default parameters are used [880] => * thanks ShiVAs for idea to have $loop as parameters. [881] => * [882] => * @param $loop - loop, noloop or all parameters ored. [883] => * @param $append - append processed stuff to target, else $target is overwritten [884] => * @return string [885] => */ [886] => function process($target, $handle, $loop = false, $include = false, $append = false, $finish = false, $optional = false) [887] => { [888] => if ($loop === 0) $loop = $this->parameters; [889] => [890] => $noloop = false; [891] => $parsedloop = false; [892] => $loopopt = false; [893] => if ($loop > 2) [894] => { [895] => $noloop = $loop & TPL_NOLOOP; [896] => $include = $loop & TPL_INCLUDE; [897] => $append = $loop & TPL_APPEND; [898] => $finish = $loop & TPL_FINISH; [899] => $optional = $loop & TPL_OPTIONAL; [900] => $parsedloop = $loop & TPL_LOOP_INNER_PARSED; [901] => $loopopt = $loop & TPL_LOOP_INNER_OPTIONAL; [902] => } [903] => else [904] => { [905] => $noloop = $loop & TPL_NOLOOP; [906] => } [907] => [908] => if ($append) { [909] => if (isset($this->vars[$target])) { [910] => $app = $this->get_var($target); // preserve old info [911] => $this->set_var($target.'.count', $tmp=$this->get_var($target.'.count')+1); // by sunmin (append count) [912] => $this->set_var($target.'.countodd', $tmp%2 ); // by sunmin (append count) [913] => } [914] => else { [915] => $app = ''; [916] => $this->set_var($target.'.count', 1); // by sunmin (append count) [917] => $this->set_var($target.'.countodd', 1); // by sunmin (append count) [918] => } [919] => } [920] => [921] => $this->set_var($target, $this->get_var($handle)); // copy contents [922] => [923] => if ($include) { $this->set_var($target, $this->include_files($target)); } [924] => [925] => [926] => if ($noloop) { $this->set_var($target, $this->parse_loops($target, TPL_NOLOOP | $loopopt | $parsedloop)); } [927] => elseif ($loop) { $this->set_var($target, $this->parse_loops($target, $loopopt | $parsedloop)); } [928] => [929] => if ($optional) { $this->set_var($target, $this->optional($this->get_var_silent($target))); } [930] => [931] => if ($append) { $this->set_var($target, $app . $this->parse($this->get_var_silent($target))); } [932] => else { $this->set_var($target, $this->parse($this->get_var($target))); } [933] => [934] => if ($finish) { $this->set_var($target, $this->finish($this->get_var($target))); } [935] => [936] => return $this->get_var($target); [937] => } [938] => [939] => [940] => /** [941] => * spits out file contents [942] => * @access private [943] => */ [944] => function read_file($file) [945] => { [946] => $filename = $this->root . $file; [947] => [948] => if (!file_exists($filename)) [949] => { [950] => $this->error("phemplate::read_file(): 파일이 없음 - $filename", 'fatal'); [951] => return ''; [952] => } [953] => [954] => $tmp = false; [955] => [956] => $filesize = filesize($filename); [957] => if ($filesize) [958] => { [959] => $tmp = fread($fp = fopen($filename, 'r'), $filesize); [960] => fclose($fp); [961] => [962] => $this->read_files[]= $filename; [963] => } [964] => return $tmp; [965] => } [966] => [967] => /** [968] => * free mem used by loop [969] => */ [970] => function drop_loop($loop_handle) [971] => { [972] => if (isset($this->loops[$loop_handle])) unset($this->loops[$loop_handle]); [973] => } [974] => [975] => [976] => /** [977] => * free mem used by var [978] => */ [979] => function drop_var($handle,$var_value='') [980] => { [981] => if (is_array($var_value)) { // by Sunmin Park [982] => foreach($var_value as $key=>$value) [983] => $this->drop_var($handle.'.'.$key,$value); // recursion for array branches [984] => } [985] => elseif (isset($this->vars[$handle])) unset($this->vars[$handle]); [986] => } [987] => [988] => /** [989] => * set error handler [990] => */ [991] => function set_error_handler(&$eh) [992] => { [993] => $this->error_handler =& $eh; [994] => } [995] => [996] => /** [997] => * change block syntax [998] => */ [999] => function set_block_syntax($start, $end) [1000] => { [1001] => if (!strpos($start, '|')) $this->error("phemplate::set_block_syntax(): no '|' in start tag", 'fatal'); [1002] => if (!strpos($end, '|')) $this->error("phemplate::set_block_syntax(): no '|' in end tag", 'fatal'); [1003] => $this->block_start_string = $start; [1004] => $this->block_end_string = $end; [1005] => } [1006] => [1007] => /** [1008] => * error report [1009] => */ [1010] => function error( $msg, $level = '') [1011] => { [1012] => if (isset($this->error_handler)) [1013] => { [1014] => $lvl = E_USER_WARNING; [1015] => if ('fatal' == $level) $lvl = E_USER_ERROR; [1016] => $this->error_handler->report($lvl, $msg); [1017] => } [1018] => else [1019] => { [1020] => echo "\n
$level: $msg
\n"; [1021] => if ('fatal' == $level) { exit; } [1022] => } [1023] => } [1024] => [1025] => /** [1026] => * SitePHPbasic 반복하는 echoHtml [1027] => * By Sunmin Park 06/07/23 [1028] => */ [1029] => function echoHtml( &$dbinfo, &$SITE, $thisUrl='' ) { [1030] => $val='\\1'.$thisUrl.'skin/'.$dbinfo['skin'].'/images/'; [1031] => // - 사이트 템플릿 읽어오기 [1032] => if(ereg('^(ht|h|t)$',$dbinfo['html_type'])) { [1033] => $HEADER = array ('html_skin'=>$dbinfo['html_skin']); [1034] => @include($SITE['html_path'].'skin.php'); // retrun $aBody[0],$aBody[1] [1035] => } [1036] => [1037] => $html = ''; [1038] => switch($dbinfo['html_type']) { [1039] => case 'ht': [1040] => $html = $aBody[0]; [1041] => $html .= $dbinfo['html_head']; [1042] => $html .= ereg_replace('([="\'(])images/',$val,$this->process('', 'html',TPL_OPTIONAL)); [1043] => $html .= $dbinfo['html_tail']; [1044] => $html .= $aBody[1]; [1045] => break; [1046] => case 'h': [1047] => $html .= $aBody[0] ; [1048] => $html .= $dbinfo['html_head']; [1049] => $html .= ereg_replace('([="\'(])images/',$val,$this->process('', 'html',TPL_OPTIONAL)); [1050] => $html .= $dbinfo['html_tail']; [1051] => break; [1052] => case 't': [1053] => $html .= $dbinfo['html_head']; [1054] => $html .= ereg_replace('([="\'(])images/',$val,$this->process('', 'html',TPL_OPTIONAL)); [1055] => $html .= $dbinfo['html_tail'] ; [1056] => $html .= $aBody[1]; [1057] => break; [1058] => case 'no': [1059] => $html .= ereg_replace('([="\'(])images/',$val,$this->process('', 'html',TPL_OPTIONAL)); [1060] => break; [1061] => default: [1062] => $html .= $dbinfo['html_head']; [1063] => $html .= ereg_replace('([="\'(])images/',$val,$this->process('', 'html',TPL_OPTIONAL)); [1064] => $html .= $dbinfo['html_tail']; [1065] => } // end switch [1066] => [1067] => /* [1068] => if($_GET['utf8']=='euc-kr') { [1069] => // iconv 버그로 인해서 "\n"로 나눔 [1070] => $aA =explode("\n",$html); [1071] => $html =''; [1072] => foreach($aA as $v) $html .= iconv("euc-kr", "UTF-8",$v); [1073] => } [1074] => */ [1075] => [1076] => if($_GET['html_return']) $_GET['html']=$html; [1077] => else echo $html; [1078] => [1079] => // debug 출력 [1080] => if(defined('GET_DEBUG_2') and GET_DEBUG_2) { [1081] => echo "
"; [1082] => echo "skin : $dbinfo[skin], html_type: $dbinfo[html_type], html_skin: $dbinfo[html_skin]
thisUrl:$thisUrl "; [1083] => if('/spb3/sboard3/'==$thisUrl) { [1084] => echo " [게시판수정]"; [1085] => if($_GET['cateuid']) { [1086] => echo " [카테고리수정]"; [1087] => } [1088] => } [1089] => if($dbinfo['table']) { [1090] => echo " [$dbinfo[table]]"; [1091] => } [1092] => echo "
"; [1093] => if(count($this->read_files)) { [1094] => foreach($this->read_files as $filepath) { [1095] => if(strpos($filepath,$_SERVER['DOCUMENT_ROOT'])!==false) { [1096] => $url = substr($filepath,strlen($_SERVER['DOCUMENT_ROOT'])); [1097] => echo "skin file : $url
"; [1098] => } [1099] => else echo "skin file : $filepath
"; [1100] => } [1101] => } [1102] => //echo '
dbinfo ';var_export($dbinfo);

                                            [1103] => 			//echo '
'; [1104] => echo '
'; [1105] => } [1106] => } [1107] => } [1108] => ?> ) [new] => [ovalue] => // 04/05/17 박선민 340L get_var() chanage to same get_var_silent() [oindex] => 2 [nkeys] => ) ) ) [1] => Array ( [file] => /wecan/cc/cc.sdong.kr/spb3/sadmin/util/svn/spb3_diff.php [line] => 122 [function] => array_keys [args] => Array ( [0] => [1] => // 04/05/17 박선민 340L get_var() chanage to same get_var_silent() ) ) [2] => Array ( [file] => /wecan/cc/cc.sdong.kr/spb3/sadmin/util/svn/spb3_diff.php [line] => 142 [function] => doDiff [class] => diff [object] => diff Object ( [changes] => Array ( ) [diff] => Array ( ) [linepadding] => 2 ) [type] => -> [args] => Array ( [0] => /wecan/cc/cc.sdong.kr/spb3/sinc/lib/class_phemplate.php [1] => ) ) [3] => Array ( [file] => /wecan/cc/cc.sdong.kr/spb3/sadmin/util/svn/spb3_diff.php [line] => 197 [function] => diffWrap [class] => diff [object] => diff Object ( [changes] => Array ( ) [diff] => Array ( ) [linepadding] => 2 ) [type] => -> [args] => Array ( [0] => /wecan/cc/cc.sdong.kr/spb3/sinc/lib/class_phemplate.php [1] => ) ) [4] => Array ( [file] => /wecan/cc/cc.sdong.kr/spb3/sadmin/util/svn/spb3_diff.php [line] => 92 [function] => inline [class] => diff [object] => diff Object ( [changes] => Array ( ) [diff] => Array ( ) [linepadding] => 2 ) [type] => -> [args] => Array ( [0] => /wecan/cc/cc.sdong.kr/spb3/sinc/lib/class_phemplate.php [1] => [2] => 2 ) ) ) [key] => 4 [value] => Array ( [file] => /wecan/cc/cc.sdong.kr/spb3/sadmin/util/svn/spb3_diff.php [line] => 92 [function] => inline [class] => diff [object] => diff Object ( [changes] => Array ( ) [diff] => Array ( ) [linepadding] => 2 ) [type] => -> [args] => Array ( [0] => /wecan/cc/cc.sdong.kr/spb3/sinc/lib/class_phemplate.php [1] => [2] => 2 ) ) )
sitePHPbasic 디버그 모드 : WARNING
[2] Invalid argument supplied for foreach()
Line : 123 (file:/wecan/cc/cc.sdong.kr/spb3/sadmin/util/svn/spb3_diff.php)
- 디버그 추적(debug_backtrace)
#0 spb_error_handler() 함수사용, line(123), /wecan/cc/cc.sdong.kr/spb3/sadmin/util/svn/spb3_diff.php
#1 doDiff() 함수사용, line(142), /wecan/cc/cc.sdong.kr/spb3/sadmin/util/svn/spb3_diff.php
#2 diffWrap() 함수사용, line(197), /wecan/cc/cc.sdong.kr/spb3/sadmin/util/svn/spb3_diff.php
#3 inline() 함수사용, line(92), /wecan/cc/cc.sdong.kr/spb3/sadmin/util/svn/spb3_diff.php




사용변수들 ...
$_GET = Array ( [md5_path] => /spb3/sinc/lib/class_phemplate.php ) $_POST = Array ( ) $_COOKIE = Array ( ) Array ( [errno] => 2 [errstr] => Invalid argument supplied for foreach() [errfile] => /wecan/cc/cc.sdong.kr/spb3/sadmin/util/svn/spb3_diff.php [errline] => 123 [arr] => Array ( [0] => Array ( [file] => /wecan/cc/cc.sdong.kr/spb3/sadmin/util/svn/spb3_diff.php [line] => 123 [function] => spb_error_handler [args] => Array ( [0] => 2 [1] => Invalid argument supplied for foreach() [2] => /wecan/cc/cc.sdong.kr/spb3/sadmin/util/svn/spb3_diff.php [3] => 123 [4] => Array ( [old] => Array ( [0] => // $Id: class_phemplate.php 13 2010-08-24 08:28:50Z sitehis $ [2] => // 04/05/17 박선민 340L get_var() chanage to same get_var_silent() [3] => // 04/05/17 박선민 696L optional() add and change etc.. [4] => // 05/01/25 박선민 828L drop_var() add recursion for array branches [5] => // 05/11/20 박선민 echoHtml()로 반복하는 sitePHPbasic 마무리 부분 함수로 [6] => // 07/03/18 박선민 {!e.abc} 인경우 urlencoding 등의 기능 추가 [7] => // 07/08/14 박선민 {#widget.???} 윗젯 include 기능 추가 [8] => // 07/09/16 박선민 {#content.keyword} spb3_content 테이블의 keyword에 대한 content가져와서 넣는 기능 추가 [9] => // 08/06/14 박선민 $_GET[html_return] 기능 추가 [10] => // 08/06/28 박선민 831L optional() change 값이 'N'이여도 false되게 [11] => // 08/07/13 박선민 716L // cut_string {#cut.50#0#….key} 기능 추가 [12] => // 08/07/29 박선민 546L // parse() ... IF문 기능 추가 [13] => // 08/10/06 박선민 {#sub.2.3.???} 기능 추가 [14] => // 08/11/08 박선민 #content.??? 기능 개선 [15] => // 08/11/29 박선민 bugfix - don't use &$this [16] => // 09/01/04 박선민 {#widget2.???} 윗젯2 기능 추가(php파일위치에 widget2_???.php를 읽어서 함수 실행 [17] => // 09/02/04 박선민 {!N.list.number} 기능 추가 [18] => // 09/02/06 박선민 GET_DEBUG_2 기능 추가 [19] => // 09/02/25 박선민 {#exp.0.-.key}, server.server.HTTP_REFERER 추가 [20] => // 09/03/11 박선민 {!A.str} javascript에서 변수넘길때 큰따옴표 오류 해결용 [21] => // 09/05/08 박선민 bugfix - GET_DEBUG_2 false였을 때 오류 [22] => // 09/05/31 박선민 {!B.str} table, excel등에서 빈값은  로 변환하여 리턴하도록 [23] => // 09/05/31 박선민 {!?.str} 링크에 ?가 없으면 ?를 붙여주도록 [24] => // 09/07/28 박선민 {!X.name} : xmlspecialchars 변환 기능 추가 [25] => //---------------------------------------------------------------------------// [26] => // author: pukomuko [27] => // date: 2001.03.15 [28] => // web: http://pukomuko.esu.lt [29] => // http://sourceforge.net/projects/phemplate [30] => // info: template engine [31] => //---------------------------------------------------------------------------// [32] => // copyleft license [33] => // [34] => // this software is provided 'as-is', without any express or implied [35] => // warranty. in no event will the authors be held liable for any damages [36] => // arising from the use of this software. [37] => // [38] => // permission is granted to anyone to use this software for any purpose, [39] => // including commercial applications, and to alter it and redistribute it [40] => // freely, subject to the following restrictions: [41] => // [42] => // 1. the origin of this software must not be misrepresented; [43] => // you must not claim that you wrote the original software. [44] => // if you use this software in a product, an acknowledgment [45] => // in the product documentation would be appreciated but is not required. [46] => // [47] => // 2. altered source versions must be plainly marked as such, [48] => // and must not be misrepresented as being the original software. [49] => // [50] => // 3. mail about the fact of using this class in production [51] => // would be very appreciated. [52] => // [53] => // 4. this notice may not be removed or altered from any source distribution. [54] => // [55] => //---------------------------------------------------------------------------// [56] => // changes: [57] => // [58] => // 2004.04.21 [59] => // - warining on empty file [60] => // * v1.10.1 [61] => [62] => /** [63] => */ [64] => define('TPL_LOOP', 1); [65] => define('TPL_NOLOOP', 2); [66] => define('TPL_INCLUDE', 4); [67] => define('TPL_APPEND', 8); [68] => define('TPL_FINISH', 16); [69] => define('TPL_OPTIONAL', 32); [70] => define('TPL_LOOP_INNER_PARSED',64); [71] => define('TPL_LOOP_INNER_OPTIONAL', 128); [72] => [73] => define('TPL_PARSEDLOOP', TPL_LOOP | TPL_LOOP_INNER_PARSED); [74] => define('TPL_OPTLOOP', TPL_PARSEDLOOP | TPL_LOOP_INNER_OPTIONAL); [75] => [76] => [77] => define('TPL_BLOCK', 1); [78] => define('TPL_BLOCKREC', 2); [79] => define('TPL_STRIP_UTF_HEADER', 4); [80] => [81] => class phemplate [82] => { [83] => /** [84] => * 현재 클래스가 있는 드렉토리 By Sunmin [85] => */ [86] => var $widgetPath =''; [87] => [88] => var $read_files = array(); [89] => [90] => /** [91] => * spb3_content에서 읽어온 것을 캐쉬 [92] => */ [93] => var $spb3_content = array(); [94] => [95] => [96] => /** [97] => * variables and blocks [98] => */ [99] => var $vars = array(); [100] => [101] => /** [102] => * loops container [103] => */ [104] => var $loops = array(); [105] => [106] => /** [107] => * dir of template files [108] => */ [109] => var $root = ''; [110] => [111] => /** [112] => * what to do with unknown variables in template? [113] => */ [114] => var $unknowns = 'keep'; [115] => [116] => /** [117] => * default parameters for process() loop, append, finish [118] => */ [119] => var $parameters = 0; [120] => [121] => [122] => /** [123] => * object having method report($level, $msg) [124] => * you can catch error messages from template. [125] => */ [126] => var $error_handler = null; [127] => [128] => [129] => [130] => /** [131] => * start tag for block [132] => */ [133] => var $block_start_string = ''; [134] => [135] => /** [136] => * end tag for block [137] => */ [138] => var $block_end_string = ''; [139] => [140] => /** [141] => * constructor [142] => * $unknows를 keep에서 remove_nonjs로 변경함 by Sunmin Park [143] => */ [144] => function phemplate( $root_dir = '', $unknowns = 'remove_nonjs', $params = 0) [145] => { [146] => // widget, widget2 path [147] => $this->widgetPath = dirname(dirname(__FILE__)).'/widget/'; // By Sunmin [148] => if($this->set_root($root_dir)) [149] => $this->widget2Path = dirname(dirname($this->root)).'/'; // By Sunmin [150] => $this->set_unknowns($unknowns); [151] => $this->set_params($params); [152] => [153] => [154] => [155] => // 기본 set_var by Sunmin [156] => $this->tie_var('SITE' ,$GLOBALS['SITE']); // $SITE 전역변수 [157] => $this->tie_var('get' ,$_GET); [158] => $this->set_var('braces' ,'{'); // 중괄호{braces} 표현 [159] => $this->set_var('nowtime',time()); [160] => [161] => $this->tie_var('session.seUid' ,$_SESSION['seUid']); // 로그인 uid [162] => $this->tie_var('session.seUserid' ,$_SESSION['seUserid']); // 로그인 userid [163] => $this->tie_var('session.seName' ,$_SESSION['seName']); // 로그인 이름 [164] => $this->tie_var('session.seNickname' ,$_SESSION['seNickname']); // 로그인 별명 [165] => $this->tie_var('session.seEmail' ,$_SESSION['seEmail']); [166] => $this->tie_var('session.sePoint' ,$_SESSION['sePoint']); [167] => $this->tie_var('session.seCoupon' ,$_SESSION['seCoupon']); [168] => $this->tie_var('session.sePriv' ,$_SESSION['sePriv']); [169] => [170] => $this->set_var('server.HTTP_HOST' ,$_SERVER['HTTP_HOST']); [171] => $this->set_var('server.HTTP_REFERER',$_SERVER['HTTP_REFERER']); [172] => $this->set_var('server.QUERY_STRING' ,$_SERVER['QUERY_STRING']); [173] => $this->set_var('server.REQUEST_URI' ,$_SERVER['REQUEST_URI']); [174] => $this->set_var('server.PHP_SELF' ,$_SERVER['PHP_SELF']); [175] => } [176] => [177] => /** [178] => substitute text and returns parsed string [179] => @author ZaZa (Sergej Kurakin) 2003.05.05 21:52 [180] => */ [181] => function parse($string) [182] => { [183] => $str = explode('{', $string); [184] => [185] => $res = ''; [186] => [187] => for ($i = 0; isset($str[$i]); $i++) [188] => { [189] => $line = explode('}', $str[$i]); [190] => if ($i === 0) [191] => { [192] => $res .= $line[0]; [193] => } [194] => else [195] => { [196] => $key = $line[0]; [197] => unset($line[0]); [198] => [199] => if ( $key && isset($this->vars[$key]) ) [200] => { [201] => $res .= $this->vars[$key].implode('}', $line); [202] => } [203] => else [204] => { [205] => // {!d.list.rdate} 등 By Sunmin [206] => if($key[0]=='!') { // and isset($this->vars[substr($key,3)])) { [207] => switch(substr($key,1,2)) { [208] => /** [209] => ** 대소문자 구분함 [210] => {!B.name} : 값이 없으면   [211] => {!b.name} : 문장에서 엔터를
로 변환함 [212] => {!S.name} : 문장에서 html 테그를 모두 제거하고, 엔터는
로 변환함 [213] => [214] => {!a.name} : '\' addslashes 삽입 [215] => {!A.name} : javascript에서 변수넘길때 funcname('{!A.str}') [216] => {!s.name} : addslashes된 것을 stripcslashes함 [217] => {!?.name} : 문자열 중간 혹은 끝에 ?가 없으면 맨뒤에 ?를 붙여줌 [218] => [219] => {!h.name} : HTML특수문자로 변환( 큰따옴표도 변환 ) [220] => {!H.name} : HTML특수문자로 변환( 큰따옴표는 그대로 나둠) [221] => {!x.name} : stripcslashes함 하고 HTML특수문자로 변환( 큰따옴표도 변환) [222] => {!X.name} : xmlspecialchars 변환 [223] => [224] => {!e.url} : URL ENCODE [225] => [226] => {!n.price} : 숫자에 콤마 추가(단, 값이 없으면 무조건 '0' 리턴) [227] => {!N.price} : 숫자에 콤마 추가(단, ''값이면 빈값으로 리턴 [228] => [229] => {!D.rdate} : 숫자날짜를 YYYY-MM-DD로 변환 (연도가 4자리) [230] => {!d.rdate} : 숫자날짜를 YY-MM-DD로 변환 (연도가 2자리) [231] => {!T.rdate} : 숫자날짜를 YY-MM-DD H:i:s로 변환 (ex, 2009-01-01 23:59:55) [232] => {!t.rdate} : 숫자날짜를 시간인 H:i:s로 변환 (ex, 23:59:55) [233] => {!g.rdate} : 숫자날짜를 국제표준 한국시간으로 'D, j M Y G:i:s +0900' [234] => **/ [235] => case 'B.': [236] => if(empty($this->vars[substr($key,3)]) and $this->vars[substr($key,3)]!="0") [237] => $res .= ' '.implode('}', $line); [238] => else $res .= $this->vars[substr($key,3)].implode('}', $line); [239] => continue 2; [240] => break; [241] => case 'b.': [242] => $res .= nl2br($this->vars[substr($key,3)]).implode('}', $line); [243] => continue 2; [244] => break; [245] => case 'S.': // strip_tags(),
tag취환 [246] => $res .= ereg_replace("(\r\n|\n|\r)", '
',strip_tags($this->vars[substr($key,3)])).implode('}', $line); [247] => continue 2; [248] => break; [249] => case 'a.': [250] => $res .= addslashes($this->vars[substr($key,3)]).implode('}', $line); [251] => continue 2; [252] => break; [253] => case 'A.': [254] => $res .= str_replace('\\"','"',addslashes($this->vars[substr($key,3)])).implode('}', $line); [255] => continue 2; [256] => break; [257] => case 's.': [258] => $res .= stripcslashes($this->vars[substr($key,3)]).implode('}', $line); [259] => continue 2; [260] => break; [261] => case '?.': [262] => if(false===strpos($this->vars[substr($key,3)],'?')) [263] => $res .= $this->vars[substr($key,3)].'?'.implode('}', $line); [264] => else [265] => $res .= $this->vars[substr($key,3)].implode('}', $line); [266] => continue 2; [267] => break; [268] => case 'h.': [269] => $res .= htmlspecialchars($this->vars[substr($key,3)],ENT_QUOTES).implode('}', $line); [270] => continue 2; [271] => break; [272] => case 'H.': [273] => $res .= htmlspecialchars($this->vars[substr($key,3)],ENT_NOQUOTES).implode('}', $line); [274] => continue 2; [275] => break; [276] => case 'x.': [277] => $res .= htmlspecialchars(stripcslashes($this->vars[substr($key,3)]),ENT_QUOTES).implode('}', $line); [278] => continue 2; [279] => break; [280] => case 'X.': [281] => $res .= str_replace(''', ''', htmlspecialchars($this->vars[substr($key,3)], ENT_QUOTES)).implode('}', $line); [282] => continue 2; [283] => break; [284] => case 'e.': [285] => $res .= urlencode($this->vars[substr($key,3)]).implode('}', $line); [286] => continue 2; [287] => break; [288] => case 'n.': [289] => $res .= number_format((int)$this->vars[substr($key,3)]).implode('}', $line); [290] => continue 2; [291] => break; [292] => case 'N.': [293] => if($this->vars[substr($key,3)] or $this->vars[substr($key,3)]==='0' or $this->vars[substr($key,3)]===0) [294] => $res .= number_format($this->vars[substr($key,3)]).implode('}', $line); [295] => else $res .= implode('}', $line); [296] => continue 2; [297] => break; [298] => case 'D.': [299] => if($this->vars[substr($key,3)]) [300] => $res .= date('Y-m-d',$this->vars[substr($key,3)]).implode('}', $line); [301] => else $res .= implode('}', $line); [302] => continue 2; [303] => break; [304] => case 'd.': [305] => if($this->vars[substr($key,3)]) [306] => $res .= date('y-m-d',$this->vars[substr($key,3)]).implode('}', $line); [307] => else $res .= implode('}', $line); [308] => continue 2; [309] => break; [310] => case 'T.': [311] => if($this->vars[substr($key,3)]) [312] => $res .= date('y-m-d H:i:s',$this->vars[substr($key,3)]).implode('}', $line); [313] => else $res .= implode('}', $line); [314] => continue 2; [315] => break; [316] => case 't.': [317] => if($this->vars[substr($key,3)]) [318] => $res .= date('H:i:s',$this->vars[substr($key,3)]).implode('}', $line); [319] => else $res .= implode('}', $line); [320] => continue 2; [321] => break; [322] => case 'g.': [323] => if($this->vars[substr($key,3)]) [324] => $res .= date('D, j M Y G:i:s +0900',$this->vars[substr($key,3)]).implode('}', $line); [325] => else $res .= implode('}', $line); [326] => continue 2; [327] => break; [328] => } [329] => } [330] => [331] => if($key[0]=='#') { [332] => // /spb3/sinc/widget/???.php By Sunmin [333] => if('widget.'==substr($key,1,7)) { [334] => $tmpWidget2 = substr($key,8); [335] => list($tmpWidget,$tmpKey) = explode('.',$tmpWidget2,2); [336] => if(eregi('^[-_a-z0-9]+$',$tmpWidget) and is_file($this->widgetPath . $tmpWidget . '/index.php')) { [337] => @include_once($this->widgetPath .$tmpWidget . '/index.php'); [338] => $func = 'widget_'.$tmpWidget; [339] => $res .= @$func($this,$tmpKey) . implode('}', $line); [340] => continue; [341] => } [342] => } [343] => elseif('widget2.'==substr($key,1,8)) { [344] => $tmpWidget2 = substr($key,9); [345] => list($tmpWidget,$tmpKey) = explode('.',$tmpWidget2,2); [346] => if(eregi('^[-_a-z0-9]+$',$tmpWidget) and is_file($this->widget2Path . 'widget2_'.$tmpWidget . '.php')) { [347] => @include_once($this->widget2Path . 'widget2_'.$tmpWidget . '.php'); [348] => $func = 'widget2_'.$tmpWidget; [349] => $res .= @$func($this,$tmpKey) . implode('}', $line); [350] => continue; [351] => } [352] => }elseif('include.'==substr($key,1,8)) { [353] => $tmpFilename = substr($key,9); [354] => if(is_file($this->root.'/include_'.$tmpFilename.'.html')) { [355] => $res .= @file_get_contents($this->root.'include_'.$tmpFilename.'.html') . implode('}', $line); [356] => } [357] => else $res .= implode('}', $line); [358] => continue; [359] => } [360] => // spb3_content읽어서 keyword에서 content 전송 [361] => elseif('content.'==substr($key,1,8)) { [362] => list($tmp,$tmpKeyword,$tmpContent) = explode('.',$key,3); [363] => if(!$tmpContent) $tmpContent = 'content'; [364] => if(!isset($this->spb3_content[$tmpContent])) { [365] => $this->spb3_content[$tmpContent] = db_resultdata($GLOBALS['SITE']['th'].'cate_content',$tmpContent,'keyword',$tmpKeyword); [366] => } [367] => $res .= $this->spb3_content[$tmpContent] . implode('}', $line); [368] => continue; [369] => } [370] => // cut_string {#cut.50#0#….key} [371] => elseif('cut.'==substr($key,1,4)) { [372] => list($tmp,$tmpCut,$tmpKey) = explode('.',$key,3); [373] => list($tmpCut1,$tmpCut2,$tmpCut3) = explode('#',$tmpCut,3); [374] => if($tmpCut1===NULL) $tmpCut1 = 50; [375] => if($tmpCut2===NULL) $tmpCut2 = 0; [376] => if($tmpCut3===NULL) $tmpCut3 = '…'; [377] => $res .= cut_string($this->vars[$tmpKey],$tmpCut1,$tmpCut2,$tmpCut3).implode('}', $line); [378] => continue; [379] => } [380] => // substr {#sub.2.3.key} [381] => elseif('sub.'==substr($key,1,4)) { [382] => list($tmp,$tmpSub1,$tmpSub2,$tmpKey) = explode('.',$key,4); [383] => $res .= substr($this->vars[$tmpKey],(int)$tmpSub1,(int)$tmpSub2).implode('}', $line); [384] => continue; [385] => } [386] => // explode(split) {#exp.0.-.key} 0번째, -으로 나누어서 [387] => elseif('exp.'==substr($key,1,4)) { [388] => $tmp = explode('.',$key,4); [389] => if(4==count($tmp)) { [390] => $tmp2 = explode($tmp[2],$this->vars[$tmp[3]]); [391] => $res .= $tmp2[$tmp[1]].implode('}', $line); [392] => } [393] => else $res .= implode('}', $line); [394] => continue; [395] => } [396] => } [397] => [398] => switch ($this->unknowns) [399] => { [400] => case "keep": [401] => $res .= '{'.$key; [402] => if (count ($line) > 0) [403] => { [404] => $res .= '}'; [405] => $res .= implode('}', $line); [406] => } [407] => break; [408] => [409] => case "remove": [410] => $res .= implode('', $line); [411] => break; [412] => [413] => case "remove_nonjs": [414] => if (!empty($key) && ((false === strpos($key, ' ')) && (false === strpos($key, "\n")) && (false === strpos($key, "\t")))) [415] => { [416] => $res .= implode('}', $line); [417] => } [418] => else [419] => { [420] => $res .= '{'.$key; [421] => if (count ($line) > 0) [422] => { [423] => $res .= '}'; [424] => $res .= implode('}', $line); [425] => } [426] => } [427] => break; [428] => [429] => case "comment": [430] => $res .= ''.implode('', $line); [431] => break; [432] => [433] => case "space": [434] => $res .= ' '.implode('', $line); [435] => break; [436] => [437] => } [438] => } [439] => } [440] => } [441] => [442] => return $res; [443] => } [444] => [445] => /** [446] => * check and set template root dir [447] => */ [448] => function set_root($root) [449] => { [450] => if (empty($root)) return; [451] => if (!is_dir($root)) [452] => { [453] => $this->error("phemplate::set_root(): 다음 드렉토리가 없습니다 : $root", 'warning'); [454] => return false; [455] => } [456] => [457] => $this->root = realpath($root).'/'; // By Sunmin 05/11/13 [458] => return true; [459] => } [460] => [461] => /** [462] => * what to do with unknown variables in template? [463] => * keep [464] => * remove [465] => * remove_nonjs [466] => * comment [467] => * space [468] => */ [469] => function set_unknowns($unk) [470] => { [471] => $this->unknowns = $unk; [472] => } [473] => [474] => /** [475] => * set default parameters for process() [476] => */ [477] => function set_params($params) [478] => { [479] => $this->parameters = $params; [480] => } [481] => [482] => /** [483] => * read file template into $vars [484] => * @param string $handle - name of handle for file contents [485] => * @param int $blocks - 1 for search, 2 for nested blocks [486] => * [487] => */ [488] => function set_file($handle, $filename = "", $blocks = false) [489] => { [490] => if ($filename == "") [491] => { [492] => $this->error("phemplate::set_file(): 파일이름이 빈값으로 넘어왔습니다 -$handle", 'fatal'); [493] => return false; [494] => } [495] => $this->vars[$handle] = $this->read_file($filename); [496] => if ($blocks & TPL_STRIP_UTF_HEADER) [497] => { [498] => $header = substr($this->vars[$handle], 0, 3); [499] => if ("\xEF\xBB\xBF" == $header) $this->vars[$handle] = substr($this->vars[$handle], 3); [500] => } [501] => if ($blocks) { $this->extract_blocks($handle, $blocks & TPL_BLOCKREC); } [502] => return true; [503] => [504] => } [505] => [506] => [507] => /** [508] => * set handle and value, [509] => * if value is array, all elements will be named: handle.key.subkey [510] => */ [511] => function set_var($var_name, $var_value) [512] => { [513] => if (is_array($var_value)) [514] => { [515] => foreach($var_value as $key=>$value) [516] => { [517] => $this->set_var($var_name . '.' . $key, $value); // recursion for array branches [518] => } [519] => } [520] => else // normal variable [521] => { [522] => $this->vars[$var_name] = $var_value; [523] => } [524] => } [525] => [526] => /** [527] => * tie value with variable [528] => * it's not possible to update array keys, just values [529] => */ [530] => function tie_var($var_name, &$var_value) [531] => { [532] => if (is_array($var_value)) [533] => { [534] => $list = array_keys($var_value); [535] => foreach($list as $key) [536] => { [537] => $this->tie_var($var_name . '.' . $key, $var_value[$key]); // recursion for array branches [538] => } [539] => } [540] => else // normal variable [541] => { [542] => $this->vars[$var_name] =& $var_value; [543] => } [544] => } [545] => [546] => /** [547] => * value of $handle [548] => * raises error if $handle undefined [549] => */ [550] => function get_var($handle) [551] => { [552] => if (!isset($this->vars[$handle])) { [553] => //$this->error("phemplate(): no such handle '$handle'", 'warning'); [554] => return null; // By Sunmin Park 04/05/17 [555] => } [556] => return $this->vars[$handle]; [557] => } [558] => [559] => /** [560] => * value of $handle, no error if no handle [561] => */ [562] => function get_var_silent($handle) [563] => { [564] => if (!isset($this->vars[$handle])) { $this->vars[$handle] = ''; return ''; } [565] => return $this->vars[$handle]; [566] => } [567] => [568] => /** [569] => * assign array to loop handle [570] => * @param string $loop_name - name for a loop [571] => * @param int $loop - loop data [572] => */ [573] => function set_loop($loop_name, $loop) [574] => { [575] => if (!$loop) $loop = 0; [576] => $this->loops[$loop_name] = $loop; [577] => } [578] => [579] => /** [580] => * tie array with loop [581] => */ [582] => function tie_loop($loop_name, &$loop) [583] => { [584] => if (!$loop) $loop = 0; [585] => $this->loops[$loop_name] =& $loop; [586] => } [587] => [588] => /** [589] => * extracts blocks from handle, and returns cleaned up version [590] => * [591] => * must be quite fast, because every found block is imediately taken out of string [592] => * [593] => * [594] => * @since 2001.10.31 works with nested blocks [js] [595] => * @since 2003.06.19 supports customized block syntax [js] [596] => * [597] => */ [598] => function extract_blocks($bl_handle, $recurse = false) [599] => { [600] => [601] => $str = $this->get_var($bl_handle); [602] => if (!$str) return $str; [603] => $bl_start = 0; [604] => [605] => list($bll, $blr) = explode('|', $this->block_start_string); [606] => $strlen = strlen($bll); [607] => [608] => [609] => // find them and clean from parent handle [610] => while(is_long($bl_start = strpos($str, $bll, $bl_start))) [611] => { [612] => $pos = $bl_start + $strlen; [613] => [614] => $endpos = strpos($str, $blr, $pos); [615] => $handle = substr($str, $pos, $endpos-$pos); [616] => [617] => $tag = $bll.$handle.$blr; [618] => $endtag = str_replace('|', $handle, $this->block_end_string); [619] => [620] => $start_pos = $bl_start + strlen($tag); [621] => $end_pos = strpos($str, $endtag, $bl_start); [622] => if (!$end_pos) { $this->error("스킨오류 : </block name=\"$handle\">이 없음", 'fatal'); } [623] => $bl_end = $end_pos + strlen($endtag); [624] => [625] => $block_code = substr($str, $start_pos, $end_pos-$start_pos); [626] => [627] => $this->set_var($handle, $block_code); [628] => [629] => $part1 = substr($str, 0, $bl_start); [630] => $part2 = substr($str, $bl_end, strlen($str)); [631] => [632] => $str = $part1 . $part2; [633] => [634] => if ($recurse) { $this->extract_blocks($handle, 1); } [635] => [636] => } [637] => [638] => $this->set_var($bl_handle, $str); [639] => [640] => } [641] => [642] => [643] => /** [644] => * search for tags in $handle [645] => * be carefull with paths [646] => */ [647] => function include_files($handle) [648] => { [649] => $str = $this->get_var($handle); [650] => [651] => while(is_long($pos = strpos($str, '', $pos); [655] => $filename = substr($str, $pos, $endpos-$pos); [656] => $tag = ''; [657] => [658] => [659] => $include = $this->read_file($filename); [660] => [661] => $str = str_replace($tag, $include, $str); [662] => } [663] => [664] => return $str; [665] => } [666] => [667] => [668] => /** [669] => * searches for all set loops in $handle, returns text of $handle with parsed loops [670] => * @param bool $noloop - must be true, if you want noloop statement [671] => * @return string [672] => */ [673] => function parse_loops($handle, $noloop = false) [674] => { [675] => $str = $this->get_var($handle); [676] => [677] => reset($this->loops); [678] => [679] => while ( list($loop_name, $loop_ar) = each($this->loops) ) [680] => { [681] => [682] => $start_tag = strpos($str, ''); [683] => [684] => $start_pos = $start_tag + strlen(''); [685] => if (!$start_pos) continue; [686] => $end_pos = strpos($str, ''); [687] => [688] => $loop_code = substr($str, $start_pos, $end_pos-$start_pos); [689] => $org_loop_code = $loop_code; [690] => [691] => $start_tag = substr($str, $start_tag, strlen('')); [692] => $end_tag = substr($str, $end_pos, strlen('')); [693] => [694] => if($loop_code != ''){ [695] => [696] => $new_code = ''; [697] => [698] => // clean if ($noloop & TPL_NOLOOP) [700] => { [701] => [702] => $nl_start_tag = strpos($loop_code, ''); [703] => $nl_start_pos = $nl_start_tag + strlen(''); [704] => [705] => [706] => if ($nl_start_pos) [707] => { [708] => [709] => $nl_end_pos = strpos($loop_code, ''); [710] => [711] => $noloop_code = substr($loop_code, $nl_start_pos, $nl_end_pos - $nl_start_pos); [712] => [713] => [714] => $nl_start_tag = substr($loop_code, $nl_start_tag, strlen('')); [715] => $nl_end_tag = substr($loop_code, $nl_end_pos, strlen('')); [716] => $loop_code = str_replace($nl_start_tag.$noloop_code.$nl_end_tag, '', $loop_code); [717] => } [718] => [719] => } [720] => [721] => if (is_array($loop_ar)) [722] => { [723] => [724] => if ($noloop & TPL_LOOP_INNER_PARSED) [725] => { [726] => for($i = 0; isset($loop_ar[$i]); $i++) [727] => [728] => { [729] => $temp_code = $loop_code; [730] => // rememeber loop variables [731] => [732] => $array_keys = array_keys($loop_ar[$i]); [733] => $this->set_var($loop_name, $loop_ar[$i]); [734] => if ($noloop & TPL_LOOP_INNER_OPTIONAL) $temp_code = $this->optional($loop_code); [735] => $temp_code = $this->parse($temp_code); [736] => $new_code .= $temp_code; [737] => [738] => // cleanup loop variables for next generation [739] => foreach ($array_keys as $key) unset($this->vars[$loop_name.'.'.$key]); [740] => [741] => } // for loop [742] => } [743] => else [744] => { [745] => // repeat for every row in array [746] => // for (reset($loop_ar); $row = current($loop_ar); next($loop_ar)) [747] => $ar_keys = array_keys($loop_ar); [748] => $ar_size = count($ar_keys); [749] => for($i = 0; ($i< $ar_size); $i++) [750] => { [751] => $temp_code = $loop_code; [752] => [753] => foreach( $loop_ar[$ar_keys[$i]] as $k=>$v) [754] => { [755] => $temp_code = str_replace( '{'. $loop_name. '.' .$k. '}', $v, $temp_code); [756] => } [757] => $new_code .= $temp_code; [758] => } [759] => } [760] => } elseif ($noloop & TPL_NOLOOP) [761] => { [762] => $new_code = $noloop_code; [763] => } [764] => [765] => [766] => $str = str_replace($start_tag.$org_loop_code.$end_tag, $new_code, $str); [767] => } // if loop code [768] => [769] => } // repeat for loop names [770] => [771] => return $str; [772] => } [773] => [774] => [775] => /** [776] => * process left variables [777] => * @deprecated parse() now handles unknown variables [778] => */ [779] => function finish($str) [780] => { [781] => switch ($this->unknowns) [782] => { [783] => case "keep": [784] => break; [785] => [786] => case "remove": [787] => $str = preg_replace('/{[^ \t\r\n}]+}/', "", $str); [788] => break; [789] => [790] => case "comment": [791] => $str = preg_replace('/{([^ \t\r\n}]+)}/', "", $str); [792] => break; [793] => [794] => case "space": [795] => $str = preg_replace('/{([^ \t\r\n}]+)}/', " ", $str); [796] => break; [797] => [798] => } [799] => [800] => return $str; [801] => } [802] => [803] => /** [804] => * search for optional tag [805] => * @param string $str text [806] => * @return string [807] => */ [808] => function optional($str) [809] => { [810] => $bl_start = 0; [811] => [812] => // extract and clean them from parent handle [813] => while(is_long($bl_start = strpos($str, '', $pos); [818] => $varname = substr($str, $pos, $endpos-$pos); [819] => [820] => $tag = ''; [821] => $endtag = ''; [822] => [823] => $end_pos = strpos($str, $endtag, $bl_start); [824] => if (!$end_pos) { $this->error("스킨오류 <opt name=\"$varname\">가 없음", 'fatal'); } [825] => [826] => $bl_end = $end_pos + strlen($endtag); [827] => [828] => [829] => $part1 = substr($str, 0, $bl_start); [830] => $part2 = substr($str, $bl_end, strlen($str)); [831] => [832] => // if .. by Sunmin Park [833] => if($varname[0]=="!") [834] => { [835] => $varname = substr($varname, 1); [836] => $flag = true; [837] => } [838] => else $flag = false; [839] => [840] => // .. By Sunmin Park [841] => if(strpos($varname,'=')) { [842] => list($varname,$varname_value) = explode('=',$varname,2); [843] => [844] => $value = $this->get_var_silent($varname); [845] => //echo " $value == $varname_value ";exit; [846] => if($value == $varname_value) { [847] => $flag = !$flag; [848] => } [849] => } [850] => else { [851] => $value = $this->get_var_silent($varname); [852] => [853] => //if ($value || $value === 0 || $value === '0') [854] => if ($value and $value !== 'N') [855] => { [856] => $flag = !$flag; [857] => } [858] => } [859] => [860] => if($flag) [861] => { [862] => $start_pos = $bl_start + strlen($tag); [863] => [864] => $block_code = substr($str, $start_pos, $end_pos-$start_pos); [865] => [866] => $str = $part1 . $this->parse($block_code) . $part2; [867] => } [868] => else [869] => { [870] => $str = $part1 . $part2; [871] => } [872] => } [873] => [874] => return $str; [875] => } [876] => [877] => /** [878] => * does everything: loops, includes, variables, concatenation [879] => * if $loop is 0 (not false, but 0) default parameters are used [880] => * thanks ShiVAs for idea to have $loop as parameters. [881] => * [882] => * @param $loop - loop, noloop or all parameters ored. [883] => * @param $append - append processed stuff to target, else $target is overwritten [884] => * @return string [885] => */ [886] => function process($target, $handle, $loop = false, $include = false, $append = false, $finish = false, $optional = false) [887] => { [888] => if ($loop === 0) $loop = $this->parameters; [889] => [890] => $noloop = false; [891] => $parsedloop = false; [892] => $loopopt = false; [893] => if ($loop > 2) [894] => { [895] => $noloop = $loop & TPL_NOLOOP; [896] => $include = $loop & TPL_INCLUDE; [897] => $append = $loop & TPL_APPEND; [898] => $finish = $loop & TPL_FINISH; [899] => $optional = $loop & TPL_OPTIONAL; [900] => $parsedloop = $loop & TPL_LOOP_INNER_PARSED; [901] => $loopopt = $loop & TPL_LOOP_INNER_OPTIONAL; [902] => } [903] => else [904] => { [905] => $noloop = $loop & TPL_NOLOOP; [906] => } [907] => [908] => if ($append) { [909] => if (isset($this->vars[$target])) { [910] => $app = $this->get_var($target); // preserve old info [911] => $this->set_var($target.'.count', $tmp=$this->get_var($target.'.count')+1); // by sunmin (append count) [912] => $this->set_var($target.'.countodd', $tmp%2 ); // by sunmin (append count) [913] => } [914] => else { [915] => $app = ''; [916] => $this->set_var($target.'.count', 1); // by sunmin (append count) [917] => $this->set_var($target.'.countodd', 1); // by sunmin (append count) [918] => } [919] => } [920] => [921] => $this->set_var($target, $this->get_var($handle)); // copy contents [922] => [923] => if ($include) { $this->set_var($target, $this->include_files($target)); } [924] => [925] => [926] => if ($noloop) { $this->set_var($target, $this->parse_loops($target, TPL_NOLOOP | $loopopt | $parsedloop)); } [927] => elseif ($loop) { $this->set_var($target, $this->parse_loops($target, $loopopt | $parsedloop)); } [928] => [929] => if ($optional) { $this->set_var($target, $this->optional($this->get_var_silent($target))); } [930] => [931] => if ($append) { $this->set_var($target, $app . $this->parse($this->get_var_silent($target))); } [932] => else { $this->set_var($target, $this->parse($this->get_var($target))); } [933] => [934] => if ($finish) { $this->set_var($target, $this->finish($this->get_var($target))); } [935] => [936] => return $this->get_var($target); [937] => } [938] => [939] => [940] => /** [941] => * spits out file contents [942] => * @access private [943] => */ [944] => function read_file($file) [945] => { [946] => $filename = $this->root . $file; [947] => [948] => if (!file_exists($filename)) [949] => { [950] => $this->error("phemplate::read_file(): 파일이 없음 - $filename", 'fatal'); [951] => return ''; [952] => } [953] => [954] => $tmp = false; [955] => [956] => $filesize = filesize($filename); [957] => if ($filesize) [958] => { [959] => $tmp = fread($fp = fopen($filename, 'r'), $filesize); [960] => fclose($fp); [961] => [962] => $this->read_files[]= $filename; [963] => } [964] => return $tmp; [965] => } [966] => [967] => /** [968] => * free mem used by loop [969] => */ [970] => function drop_loop($loop_handle) [971] => { [972] => if (isset($this->loops[$loop_handle])) unset($this->loops[$loop_handle]); [973] => } [974] => [975] => [976] => /** [977] => * free mem used by var [978] => */ [979] => function drop_var($handle,$var_value='') [980] => { [981] => if (is_array($var_value)) { // by Sunmin Park [982] => foreach($var_value as $key=>$value) [983] => $this->drop_var($handle.'.'.$key,$value); // recursion for array branches [984] => } [985] => elseif (isset($this->vars[$handle])) unset($this->vars[$handle]); [986] => } [987] => [988] => /** [989] => * set error handler [990] => */ [991] => function set_error_handler(&$eh) [992] => { [993] => $this->error_handler =& $eh; [994] => } [995] => [996] => /** [997] => * change block syntax [998] => */ [999] => function set_block_syntax($start, $end) [1000] => { [1001] => if (!strpos($start, '|')) $this->error("phemplate::set_block_syntax(): no '|' in start tag", 'fatal'); [1002] => if (!strpos($end, '|')) $this->error("phemplate::set_block_syntax(): no '|' in end tag", 'fatal'); [1003] => $this->block_start_string = $start; [1004] => $this->block_end_string = $end; [1005] => } [1006] => [1007] => /** [1008] => * error report [1009] => */ [1010] => function error( $msg, $level = '') [1011] => { [1012] => if (isset($this->error_handler)) [1013] => { [1014] => $lvl = E_USER_WARNING; [1015] => if ('fatal' == $level) $lvl = E_USER_ERROR; [1016] => $this->error_handler->report($lvl, $msg); [1017] => } [1018] => else [1019] => { [1020] => echo "\n
$level: $msg
\n"; [1021] => if ('fatal' == $level) { exit; } [1022] => } [1023] => } [1024] => [1025] => /** [1026] => * SitePHPbasic 반복하는 echoHtml [1027] => * By Sunmin Park 06/07/23 [1028] => */ [1029] => function echoHtml( &$dbinfo, &$SITE, $thisUrl='' ) { [1030] => $val='\\1'.$thisUrl.'skin/'.$dbinfo['skin'].'/images/'; [1031] => // - 사이트 템플릿 읽어오기 [1032] => if(ereg('^(ht|h|t)$',$dbinfo['html_type'])) { [1033] => $HEADER = array ('html_skin'=>$dbinfo['html_skin']); [1034] => @include($SITE['html_path'].'skin.php'); // retrun $aBody[0],$aBody[1] [1035] => } [1036] => [1037] => $html = ''; [1038] => switch($dbinfo['html_type']) { [1039] => case 'ht': [1040] => $html = $aBody[0]; [1041] => $html .= $dbinfo['html_head']; [1042] => $html .= ereg_replace('([="\'(])images/',$val,$this->process('', 'html',TPL_OPTIONAL)); [1043] => $html .= $dbinfo['html_tail']; [1044] => $html .= $aBody[1]; [1045] => break; [1046] => case 'h': [1047] => $html .= $aBody[0] ; [1048] => $html .= $dbinfo['html_head']; [1049] => $html .= ereg_replace('([="\'(])images/',$val,$this->process('', 'html',TPL_OPTIONAL)); [1050] => $html .= $dbinfo['html_tail']; [1051] => break; [1052] => case 't': [1053] => $html .= $dbinfo['html_head']; [1054] => $html .= ereg_replace('([="\'(])images/',$val,$this->process('', 'html',TPL_OPTIONAL)); [1055] => $html .= $dbinfo['html_tail'] ; [1056] => $html .= $aBody[1]; [1057] => break; [1058] => case 'no': [1059] => $html .= ereg_replace('([="\'(])images/',$val,$this->process('', 'html',TPL_OPTIONAL)); [1060] => break; [1061] => default: [1062] => $html .= $dbinfo['html_head']; [1063] => $html .= ereg_replace('([="\'(])images/',$val,$this->process('', 'html',TPL_OPTIONAL)); [1064] => $html .= $dbinfo['html_tail']; [1065] => } // end switch [1066] => [1067] => /* [1068] => if($_GET['utf8']=='euc-kr') { [1069] => // iconv 버그로 인해서 "\n"로 나눔 [1070] => $aA =explode("\n",$html); [1071] => $html =''; [1072] => foreach($aA as $v) $html .= iconv("euc-kr", "UTF-8",$v); [1073] => } [1074] => */ [1075] => [1076] => if($_GET['html_return']) $_GET['html']=$html; [1077] => else echo $html; [1078] => [1079] => // debug 출력 [1080] => if(defined('GET_DEBUG_2') and GET_DEBUG_2) { [1081] => echo "
"; [1082] => echo "skin : $dbinfo[skin], html_type: $dbinfo[html_type], html_skin: $dbinfo[html_skin]
thisUrl:$thisUrl "; [1083] => if('/spb3/sboard3/'==$thisUrl) { [1084] => echo " [게시판수정]"; [1085] => if($_GET['cateuid']) { [1086] => echo " [카테고리수정]"; [1087] => } [1088] => } [1089] => if($dbinfo['table']) { [1090] => echo " [$dbinfo[table]]"; [1091] => } [1092] => echo "
"; [1093] => if(count($this->read_files)) { [1094] => foreach($this->read_files as $filepath) { [1095] => if(strpos($filepath,$_SERVER['DOCUMENT_ROOT'])!==false) { [1096] => $url = substr($filepath,strlen($_SERVER['DOCUMENT_ROOT'])); [1097] => echo "skin file : $url
"; [1098] => } [1099] => else echo "skin file : $filepath
"; [1100] => } [1101] => } [1102] => //echo '
dbinfo ';var_export($dbinfo);

                                            [1103] => 			//echo '
'; [1104] => echo '
'; [1105] => } [1106] => } [1107] => } [1108] => ?> ) [new] => [ovalue] => // 04/05/17 박선민 340L get_var() chanage to same get_var_silent() [oindex] => 2 [nkeys] => ) ) ) [1] => Array ( [file] => /wecan/cc/cc.sdong.kr/spb3/sadmin/util/svn/spb3_diff.php [line] => 142 [function] => doDiff [class] => diff [object] => diff Object ( [changes] => Array ( ) [diff] => Array ( ) [linepadding] => 2 ) [type] => -> [args] => Array ( [0] => /wecan/cc/cc.sdong.kr/spb3/sinc/lib/class_phemplate.php [1] => ) ) [2] => Array ( [file] => /wecan/cc/cc.sdong.kr/spb3/sadmin/util/svn/spb3_diff.php [line] => 197 [function] => diffWrap [class] => diff [object] => diff Object ( [changes] => Array ( ) [diff] => Array ( ) [linepadding] => 2 ) [type] => -> [args] => Array ( [0] => /wecan/cc/cc.sdong.kr/spb3/sinc/lib/class_phemplate.php [1] => ) ) [3] => Array ( [file] => /wecan/cc/cc.sdong.kr/spb3/sadmin/util/svn/spb3_diff.php [line] => 92 [function] => inline [class] => diff [object] => diff Object ( [changes] => Array ( ) [diff] => Array ( ) [linepadding] => 2 ) [type] => -> [args] => Array ( [0] => /wecan/cc/cc.sdong.kr/spb3/sinc/lib/class_phemplate.php [1] => [2] => 2 ) ) ) [key] => 3 [value] => Array ( [file] => /wecan/cc/cc.sdong.kr/spb3/sadmin/util/svn/spb3_diff.php [line] => 92 [function] => inline [class] => diff [object] => diff Object ( [changes] => Array ( ) [diff] => Array ( ) [linepadding] => 2 ) [type] => -> [args] => Array ( [0] => /wecan/cc/cc.sdong.kr/spb3/sinc/lib/class_phemplate.php [1] => [2] => 2 ) ) )
sitePHPbasic 디버그 모드 : WARNING
[2] array_keys() expects parameter 1 to be array, boolean given
Line : 122 (file:/wecan/cc/cc.sdong.kr/spb3/sadmin/util/svn/spb3_diff.php)
- 디버그 추적(debug_backtrace)
#0 spb_error_handler() 함수사용, line(),
#1 array_keys() 함수사용, line(122), /wecan/cc/cc.sdong.kr/spb3/sadmin/util/svn/spb3_diff.php
#2 doDiff() 함수사용, line(142), /wecan/cc/cc.sdong.kr/spb3/sadmin/util/svn/spb3_diff.php
#3 diffWrap() 함수사용, line(197), /wecan/cc/cc.sdong.kr/spb3/sadmin/util/svn/spb3_diff.php
#4 inline() 함수사용, line(92), /wecan/cc/cc.sdong.kr/spb3/sadmin/util/svn/spb3_diff.php




사용변수들 ...
$_GET = Array ( [md5_path] => /spb3/sinc/lib/class_phemplate.php ) $_POST = Array ( ) $_COOKIE = Array ( ) Array ( [errno] => 2 [errstr] => array_keys() expects parameter 1 to be array, boolean given [errfile] => /wecan/cc/cc.sdong.kr/spb3/sadmin/util/svn/spb3_diff.php [errline] => 122 [arr] => Array ( [0] => Array ( [function] => spb_error_handler [args] => Array ( [0] => 2 [1] => array_keys() expects parameter 1 to be array, boolean given [2] => /wecan/cc/cc.sdong.kr/spb3/sadmin/util/svn/spb3_diff.php [3] => 122 [4] => Array ( [old] => Array ( [0] => // $Id: class_phemplate.php 13 2010-08-24 08:28:50Z sitehis $ [2] => // 04/05/17 박선민 340L get_var() chanage to same get_var_silent() [3] => // 04/05/17 박선민 696L optional() add and change etc.. [4] => // 05/01/25 박선민 828L drop_var() add recursion for array branches [5] => // 05/11/20 박선민 echoHtml()로 반복하는 sitePHPbasic 마무리 부분 함수로 [6] => // 07/03/18 박선민 {!e.abc} 인경우 urlencoding 등의 기능 추가 [7] => // 07/08/14 박선민 {#widget.???} 윗젯 include 기능 추가 [8] => // 07/09/16 박선민 {#content.keyword} spb3_content 테이블의 keyword에 대한 content가져와서 넣는 기능 추가 [9] => // 08/06/14 박선민 $_GET[html_return] 기능 추가 [10] => // 08/06/28 박선민 831L optional() change 값이 'N'이여도 false되게 [11] => // 08/07/13 박선민 716L // cut_string {#cut.50#0#….key} 기능 추가 [12] => // 08/07/29 박선민 546L // parse() ... IF문 기능 추가 [13] => // 08/10/06 박선민 {#sub.2.3.???} 기능 추가 [14] => // 08/11/08 박선민 #content.??? 기능 개선 [15] => // 08/11/29 박선민 bugfix - don't use &$this [16] => // 09/01/04 박선민 {#widget2.???} 윗젯2 기능 추가(php파일위치에 widget2_???.php를 읽어서 함수 실행 [17] => // 09/02/04 박선민 {!N.list.number} 기능 추가 [18] => // 09/02/06 박선민 GET_DEBUG_2 기능 추가 [19] => // 09/02/25 박선민 {#exp.0.-.key}, server.server.HTTP_REFERER 추가 [20] => // 09/03/11 박선민 {!A.str} javascript에서 변수넘길때 큰따옴표 오류 해결용 [21] => // 09/05/08 박선민 bugfix - GET_DEBUG_2 false였을 때 오류 [22] => // 09/05/31 박선민 {!B.str} table, excel등에서 빈값은  로 변환하여 리턴하도록 [23] => // 09/05/31 박선민 {!?.str} 링크에 ?가 없으면 ?를 붙여주도록 [24] => // 09/07/28 박선민 {!X.name} : xmlspecialchars 변환 기능 추가 [25] => //---------------------------------------------------------------------------// [26] => // author: pukomuko [27] => // date: 2001.03.15 [28] => // web: http://pukomuko.esu.lt [29] => // http://sourceforge.net/projects/phemplate [30] => // info: template engine [31] => //---------------------------------------------------------------------------// [32] => // copyleft license [33] => // [34] => // this software is provided 'as-is', without any express or implied [35] => // warranty. in no event will the authors be held liable for any damages [36] => // arising from the use of this software. [37] => // [38] => // permission is granted to anyone to use this software for any purpose, [39] => // including commercial applications, and to alter it and redistribute it [40] => // freely, subject to the following restrictions: [41] => // [42] => // 1. the origin of this software must not be misrepresented; [43] => // you must not claim that you wrote the original software. [44] => // if you use this software in a product, an acknowledgment [45] => // in the product documentation would be appreciated but is not required. [46] => // [47] => // 2. altered source versions must be plainly marked as such, [48] => // and must not be misrepresented as being the original software. [49] => // [50] => // 3. mail about the fact of using this class in production [51] => // would be very appreciated. [52] => // [53] => // 4. this notice may not be removed or altered from any source distribution. [54] => // [55] => //---------------------------------------------------------------------------// [56] => // changes: [57] => // [58] => // 2004.04.21 [59] => // - warining on empty file [60] => // * v1.10.1 [61] => [62] => /** [63] => */ [64] => define('TPL_LOOP', 1); [65] => define('TPL_NOLOOP', 2); [66] => define('TPL_INCLUDE', 4); [67] => define('TPL_APPEND', 8); [68] => define('TPL_FINISH', 16); [69] => define('TPL_OPTIONAL', 32); [70] => define('TPL_LOOP_INNER_PARSED',64); [71] => define('TPL_LOOP_INNER_OPTIONAL', 128); [72] => [73] => define('TPL_PARSEDLOOP', TPL_LOOP | TPL_LOOP_INNER_PARSED); [74] => define('TPL_OPTLOOP', TPL_PARSEDLOOP | TPL_LOOP_INNER_OPTIONAL); [75] => [76] => [77] => define('TPL_BLOCK', 1); [78] => define('TPL_BLOCKREC', 2); [79] => define('TPL_STRIP_UTF_HEADER', 4); [80] => [81] => class phemplate [82] => { [83] => /** [84] => * 현재 클래스가 있는 드렉토리 By Sunmin [85] => */ [86] => var $widgetPath =''; [87] => [88] => var $read_files = array(); [89] => [90] => /** [91] => * spb3_content에서 읽어온 것을 캐쉬 [92] => */ [93] => var $spb3_content = array(); [94] => [95] => [96] => /** [97] => * variables and blocks [98] => */ [99] => var $vars = array(); [100] => [101] => /** [102] => * loops container [103] => */ [104] => var $loops = array(); [105] => [106] => /** [107] => * dir of template files [108] => */ [109] => var $root = ''; [110] => [111] => /** [112] => * what to do with unknown variables in template? [113] => */ [114] => var $unknowns = 'keep'; [115] => [116] => /** [117] => * default parameters for process() loop, append, finish [118] => */ [119] => var $parameters = 0; [120] => [121] => [122] => /** [123] => * object having method report($level, $msg) [124] => * you can catch error messages from template. [125] => */ [126] => var $error_handler = null; [127] => [128] => [129] => [130] => /** [131] => * start tag for block [132] => */ [133] => var $block_start_string = ''; [134] => [135] => /** [136] => * end tag for block [137] => */ [138] => var $block_end_string = ''; [139] => [140] => /** [141] => * constructor [142] => * $unknows를 keep에서 remove_nonjs로 변경함 by Sunmin Park [143] => */ [144] => function phemplate( $root_dir = '', $unknowns = 'remove_nonjs', $params = 0) [145] => { [146] => // widget, widget2 path [147] => $this->widgetPath = dirname(dirname(__FILE__)).'/widget/'; // By Sunmin [148] => if($this->set_root($root_dir)) [149] => $this->widget2Path = dirname(dirname($this->root)).'/'; // By Sunmin [150] => $this->set_unknowns($unknowns); [151] => $this->set_params($params); [152] => [153] => [154] => [155] => // 기본 set_var by Sunmin [156] => $this->tie_var('SITE' ,$GLOBALS['SITE']); // $SITE 전역변수 [157] => $this->tie_var('get' ,$_GET); [158] => $this->set_var('braces' ,'{'); // 중괄호{braces} 표현 [159] => $this->set_var('nowtime',time()); [160] => [161] => $this->tie_var('session.seUid' ,$_SESSION['seUid']); // 로그인 uid [162] => $this->tie_var('session.seUserid' ,$_SESSION['seUserid']); // 로그인 userid [163] => $this->tie_var('session.seName' ,$_SESSION['seName']); // 로그인 이름 [164] => $this->tie_var('session.seNickname' ,$_SESSION['seNickname']); // 로그인 별명 [165] => $this->tie_var('session.seEmail' ,$_SESSION['seEmail']); [166] => $this->tie_var('session.sePoint' ,$_SESSION['sePoint']); [167] => $this->tie_var('session.seCoupon' ,$_SESSION['seCoupon']); [168] => $this->tie_var('session.sePriv' ,$_SESSION['sePriv']); [169] => [170] => $this->set_var('server.HTTP_HOST' ,$_SERVER['HTTP_HOST']); [171] => $this->set_var('server.HTTP_REFERER',$_SERVER['HTTP_REFERER']); [172] => $this->set_var('server.QUERY_STRING' ,$_SERVER['QUERY_STRING']); [173] => $this->set_var('server.REQUEST_URI' ,$_SERVER['REQUEST_URI']); [174] => $this->set_var('server.PHP_SELF' ,$_SERVER['PHP_SELF']); [175] => } [176] => [177] => /** [178] => substitute text and returns parsed string [179] => @author ZaZa (Sergej Kurakin) 2003.05.05 21:52 [180] => */ [181] => function parse($string) [182] => { [183] => $str = explode('{', $string); [184] => [185] => $res = ''; [186] => [187] => for ($i = 0; isset($str[$i]); $i++) [188] => { [189] => $line = explode('}', $str[$i]); [190] => if ($i === 0) [191] => { [192] => $res .= $line[0]; [193] => } [194] => else [195] => { [196] => $key = $line[0]; [197] => unset($line[0]); [198] => [199] => if ( $key && isset($this->vars[$key]) ) [200] => { [201] => $res .= $this->vars[$key].implode('}', $line); [202] => } [203] => else [204] => { [205] => // {!d.list.rdate} 등 By Sunmin [206] => if($key[0]=='!') { // and isset($this->vars[substr($key,3)])) { [207] => switch(substr($key,1,2)) { [208] => /** [209] => ** 대소문자 구분함 [210] => {!B.name} : 값이 없으면   [211] => {!b.name} : 문장에서 엔터를
로 변환함 [212] => {!S.name} : 문장에서 html 테그를 모두 제거하고, 엔터는
로 변환함 [213] => [214] => {!a.name} : '\' addslashes 삽입 [215] => {!A.name} : javascript에서 변수넘길때 funcname('{!A.str}') [216] => {!s.name} : addslashes된 것을 stripcslashes함 [217] => {!?.name} : 문자열 중간 혹은 끝에 ?가 없으면 맨뒤에 ?를 붙여줌 [218] => [219] => {!h.name} : HTML특수문자로 변환( 큰따옴표도 변환 ) [220] => {!H.name} : HTML특수문자로 변환( 큰따옴표는 그대로 나둠) [221] => {!x.name} : stripcslashes함 하고 HTML특수문자로 변환( 큰따옴표도 변환) [222] => {!X.name} : xmlspecialchars 변환 [223] => [224] => {!e.url} : URL ENCODE [225] => [226] => {!n.price} : 숫자에 콤마 추가(단, 값이 없으면 무조건 '0' 리턴) [227] => {!N.price} : 숫자에 콤마 추가(단, ''값이면 빈값으로 리턴 [228] => [229] => {!D.rdate} : 숫자날짜를 YYYY-MM-DD로 변환 (연도가 4자리) [230] => {!d.rdate} : 숫자날짜를 YY-MM-DD로 변환 (연도가 2자리) [231] => {!T.rdate} : 숫자날짜를 YY-MM-DD H:i:s로 변환 (ex, 2009-01-01 23:59:55) [232] => {!t.rdate} : 숫자날짜를 시간인 H:i:s로 변환 (ex, 23:59:55) [233] => {!g.rdate} : 숫자날짜를 국제표준 한국시간으로 'D, j M Y G:i:s +0900' [234] => **/ [235] => case 'B.': [236] => if(empty($this->vars[substr($key,3)]) and $this->vars[substr($key,3)]!="0") [237] => $res .= ' '.implode('}', $line); [238] => else $res .= $this->vars[substr($key,3)].implode('}', $line); [239] => continue 2; [240] => break; [241] => case 'b.': [242] => $res .= nl2br($this->vars[substr($key,3)]).implode('}', $line); [243] => continue 2; [244] => break; [245] => case 'S.': // strip_tags(),
tag취환 [246] => $res .= ereg_replace("(\r\n|\n|\r)", '
',strip_tags($this->vars[substr($key,3)])).implode('}', $line); [247] => continue 2; [248] => break; [249] => case 'a.': [250] => $res .= addslashes($this->vars[substr($key,3)]).implode('}', $line); [251] => continue 2; [252] => break; [253] => case 'A.': [254] => $res .= str_replace('\\"','"',addslashes($this->vars[substr($key,3)])).implode('}', $line); [255] => continue 2; [256] => break; [257] => case 's.': [258] => $res .= stripcslashes($this->vars[substr($key,3)]).implode('}', $line); [259] => continue 2; [260] => break; [261] => case '?.': [262] => if(false===strpos($this->vars[substr($key,3)],'?')) [263] => $res .= $this->vars[substr($key,3)].'?'.implode('}', $line); [264] => else [265] => $res .= $this->vars[substr($key,3)].implode('}', $line); [266] => continue 2; [267] => break; [268] => case 'h.': [269] => $res .= htmlspecialchars($this->vars[substr($key,3)],ENT_QUOTES).implode('}', $line); [270] => continue 2; [271] => break; [272] => case 'H.': [273] => $res .= htmlspecialchars($this->vars[substr($key,3)],ENT_NOQUOTES).implode('}', $line); [274] => continue 2; [275] => break; [276] => case 'x.': [277] => $res .= htmlspecialchars(stripcslashes($this->vars[substr($key,3)]),ENT_QUOTES).implode('}', $line); [278] => continue 2; [279] => break; [280] => case 'X.': [281] => $res .= str_replace(''', ''', htmlspecialchars($this->vars[substr($key,3)], ENT_QUOTES)).implode('}', $line); [282] => continue 2; [283] => break; [284] => case 'e.': [285] => $res .= urlencode($this->vars[substr($key,3)]).implode('}', $line); [286] => continue 2; [287] => break; [288] => case 'n.': [289] => $res .= number_format((int)$this->vars[substr($key,3)]).implode('}', $line); [290] => continue 2; [291] => break; [292] => case 'N.': [293] => if($this->vars[substr($key,3)] or $this->vars[substr($key,3)]==='0' or $this->vars[substr($key,3)]===0) [294] => $res .= number_format($this->vars[substr($key,3)]).implode('}', $line); [295] => else $res .= implode('}', $line); [296] => continue 2; [297] => break; [298] => case 'D.': [299] => if($this->vars[substr($key,3)]) [300] => $res .= date('Y-m-d',$this->vars[substr($key,3)]).implode('}', $line); [301] => else $res .= implode('}', $line); [302] => continue 2; [303] => break; [304] => case 'd.': [305] => if($this->vars[substr($key,3)]) [306] => $res .= date('y-m-d',$this->vars[substr($key,3)]).implode('}', $line); [307] => else $res .= implode('}', $line); [308] => continue 2; [309] => break; [310] => case 'T.': [311] => if($this->vars[substr($key,3)]) [312] => $res .= date('y-m-d H:i:s',$this->vars[substr($key,3)]).implode('}', $line); [313] => else $res .= implode('}', $line); [314] => continue 2; [315] => break; [316] => case 't.': [317] => if($this->vars[substr($key,3)]) [318] => $res .= date('H:i:s',$this->vars[substr($key,3)]).implode('}', $line); [319] => else $res .= implode('}', $line); [320] => continue 2; [321] => break; [322] => case 'g.': [323] => if($this->vars[substr($key,3)]) [324] => $res .= date('D, j M Y G:i:s +0900',$this->vars[substr($key,3)]).implode('}', $line); [325] => else $res .= implode('}', $line); [326] => continue 2; [327] => break; [328] => } [329] => } [330] => [331] => if($key[0]=='#') { [332] => // /spb3/sinc/widget/???.php By Sunmin [333] => if('widget.'==substr($key,1,7)) { [334] => $tmpWidget2 = substr($key,8); [335] => list($tmpWidget,$tmpKey) = explode('.',$tmpWidget2,2); [336] => if(eregi('^[-_a-z0-9]+$',$tmpWidget) and is_file($this->widgetPath . $tmpWidget . '/index.php')) { [337] => @include_once($this->widgetPath .$tmpWidget . '/index.php'); [338] => $func = 'widget_'.$tmpWidget; [339] => $res .= @$func($this,$tmpKey) . implode('}', $line); [340] => continue; [341] => } [342] => } [343] => elseif('widget2.'==substr($key,1,8)) { [344] => $tmpWidget2 = substr($key,9); [345] => list($tmpWidget,$tmpKey) = explode('.',$tmpWidget2,2); [346] => if(eregi('^[-_a-z0-9]+$',$tmpWidget) and is_file($this->widget2Path . 'widget2_'.$tmpWidget . '.php')) { [347] => @include_once($this->widget2Path . 'widget2_'.$tmpWidget . '.php'); [348] => $func = 'widget2_'.$tmpWidget; [349] => $res .= @$func($this,$tmpKey) . implode('}', $line); [350] => continue; [351] => } [352] => }elseif('include.'==substr($key,1,8)) { [353] => $tmpFilename = substr($key,9); [354] => if(is_file($this->root.'/include_'.$tmpFilename.'.html')) { [355] => $res .= @file_get_contents($this->root.'include_'.$tmpFilename.'.html') . implode('}', $line); [356] => } [357] => else $res .= implode('}', $line); [358] => continue; [359] => } [360] => // spb3_content읽어서 keyword에서 content 전송 [361] => elseif('content.'==substr($key,1,8)) { [362] => list($tmp,$tmpKeyword,$tmpContent) = explode('.',$key,3); [363] => if(!$tmpContent) $tmpContent = 'content'; [364] => if(!isset($this->spb3_content[$tmpContent])) { [365] => $this->spb3_content[$tmpContent] = db_resultdata($GLOBALS['SITE']['th'].'cate_content',$tmpContent,'keyword',$tmpKeyword); [366] => } [367] => $res .= $this->spb3_content[$tmpContent] . implode('}', $line); [368] => continue; [369] => } [370] => // cut_string {#cut.50#0#….key} [371] => elseif('cut.'==substr($key,1,4)) { [372] => list($tmp,$tmpCut,$tmpKey) = explode('.',$key,3); [373] => list($tmpCut1,$tmpCut2,$tmpCut3) = explode('#',$tmpCut,3); [374] => if($tmpCut1===NULL) $tmpCut1 = 50; [375] => if($tmpCut2===NULL) $tmpCut2 = 0; [376] => if($tmpCut3===NULL) $tmpCut3 = '…'; [377] => $res .= cut_string($this->vars[$tmpKey],$tmpCut1,$tmpCut2,$tmpCut3).implode('}', $line); [378] => continue; [379] => } [380] => // substr {#sub.2.3.key} [381] => elseif('sub.'==substr($key,1,4)) { [382] => list($tmp,$tmpSub1,$tmpSub2,$tmpKey) = explode('.',$key,4); [383] => $res .= substr($this->vars[$tmpKey],(int)$tmpSub1,(int)$tmpSub2).implode('}', $line); [384] => continue; [385] => } [386] => // explode(split) {#exp.0.-.key} 0번째, -으로 나누어서 [387] => elseif('exp.'==substr($key,1,4)) { [388] => $tmp = explode('.',$key,4); [389] => if(4==count($tmp)) { [390] => $tmp2 = explode($tmp[2],$this->vars[$tmp[3]]); [391] => $res .= $tmp2[$tmp[1]].implode('}', $line); [392] => } [393] => else $res .= implode('}', $line); [394] => continue; [395] => } [396] => } [397] => [398] => switch ($this->unknowns) [399] => { [400] => case "keep": [401] => $res .= '{'.$key; [402] => if (count ($line) > 0) [403] => { [404] => $res .= '}'; [405] => $res .= implode('}', $line); [406] => } [407] => break; [408] => [409] => case "remove": [410] => $res .= implode('', $line); [411] => break; [412] => [413] => case "remove_nonjs": [414] => if (!empty($key) && ((false === strpos($key, ' ')) && (false === strpos($key, "\n")) && (false === strpos($key, "\t")))) [415] => { [416] => $res .= implode('}', $line); [417] => } [418] => else [419] => { [420] => $res .= '{'.$key; [421] => if (count ($line) > 0) [422] => { [423] => $res .= '}'; [424] => $res .= implode('}', $line); [425] => } [426] => } [427] => break; [428] => [429] => case "comment": [430] => $res .= ''.implode('', $line); [431] => break; [432] => [433] => case "space": [434] => $res .= ' '.implode('', $line); [435] => break; [436] => [437] => } [438] => } [439] => } [440] => } [441] => [442] => return $res; [443] => } [444] => [445] => /** [446] => * check and set template root dir [447] => */ [448] => function set_root($root) [449] => { [450] => if (empty($root)) return; [451] => if (!is_dir($root)) [452] => { [453] => $this->error("phemplate::set_root(): 다음 드렉토리가 없습니다 : $root", 'warning'); [454] => return false; [455] => } [456] => [457] => $this->root = realpath($root).'/'; // By Sunmin 05/11/13 [458] => return true; [459] => } [460] => [461] => /** [462] => * what to do with unknown variables in template? [463] => * keep [464] => * remove [465] => * remove_nonjs [466] => * comment [467] => * space [468] => */ [469] => function set_unknowns($unk) [470] => { [471] => $this->unknowns = $unk; [472] => } [473] => [474] => /** [475] => * set default parameters for process() [476] => */ [477] => function set_params($params) [478] => { [479] => $this->parameters = $params; [480] => } [481] => [482] => /** [483] => * read file template into $vars [484] => * @param string $handle - name of handle for file contents [485] => * @param int $blocks - 1 for search, 2 for nested blocks [486] => * [487] => */ [488] => function set_file($handle, $filename = "", $blocks = false) [489] => { [490] => if ($filename == "") [491] => { [492] => $this->error("phemplate::set_file(): 파일이름이 빈값으로 넘어왔습니다 -$handle", 'fatal'); [493] => return false; [494] => } [495] => $this->vars[$handle] = $this->read_file($filename); [496] => if ($blocks & TPL_STRIP_UTF_HEADER) [497] => { [498] => $header = substr($this->vars[$handle], 0, 3); [499] => if ("\xEF\xBB\xBF" == $header) $this->vars[$handle] = substr($this->vars[$handle], 3); [500] => } [501] => if ($blocks) { $this->extract_blocks($handle, $blocks & TPL_BLOCKREC); } [502] => return true; [503] => [504] => } [505] => [506] => [507] => /** [508] => * set handle and value, [509] => * if value is array, all elements will be named: handle.key.subkey [510] => */ [511] => function set_var($var_name, $var_value) [512] => { [513] => if (is_array($var_value)) [514] => { [515] => foreach($var_value as $key=>$value) [516] => { [517] => $this->set_var($var_name . '.' . $key, $value); // recursion for array branches [518] => } [519] => } [520] => else // normal variable [521] => { [522] => $this->vars[$var_name] = $var_value; [523] => } [524] => } [525] => [526] => /** [527] => * tie value with variable [528] => * it's not possible to update array keys, just values [529] => */ [530] => function tie_var($var_name, &$var_value) [531] => { [532] => if (is_array($var_value)) [533] => { [534] => $list = array_keys($var_value); [535] => foreach($list as $key) [536] => { [537] => $this->tie_var($var_name . '.' . $key, $var_value[$key]); // recursion for array branches [538] => } [539] => } [540] => else // normal variable [541] => { [542] => $this->vars[$var_name] =& $var_value; [543] => } [544] => } [545] => [546] => /** [547] => * value of $handle [548] => * raises error if $handle undefined [549] => */ [550] => function get_var($handle) [551] => { [552] => if (!isset($this->vars[$handle])) { [553] => //$this->error("phemplate(): no such handle '$handle'", 'warning'); [554] => return null; // By Sunmin Park 04/05/17 [555] => } [556] => return $this->vars[$handle]; [557] => } [558] => [559] => /** [560] => * value of $handle, no error if no handle [561] => */ [562] => function get_var_silent($handle) [563] => { [564] => if (!isset($this->vars[$handle])) { $this->vars[$handle] = ''; return ''; } [565] => return $this->vars[$handle]; [566] => } [567] => [568] => /** [569] => * assign array to loop handle [570] => * @param string $loop_name - name for a loop [571] => * @param int $loop - loop data [572] => */ [573] => function set_loop($loop_name, $loop) [574] => { [575] => if (!$loop) $loop = 0; [576] => $this->loops[$loop_name] = $loop; [577] => } [578] => [579] => /** [580] => * tie array with loop [581] => */ [582] => function tie_loop($loop_name, &$loop) [583] => { [584] => if (!$loop) $loop = 0; [585] => $this->loops[$loop_name] =& $loop; [586] => } [587] => [588] => /** [589] => * extracts blocks from handle, and returns cleaned up version [590] => * [591] => * must be quite fast, because every found block is imediately taken out of string [592] => * [593] => * [594] => * @since 2001.10.31 works with nested blocks [js] [595] => * @since 2003.06.19 supports customized block syntax [js] [596] => * [597] => */ [598] => function extract_blocks($bl_handle, $recurse = false) [599] => { [600] => [601] => $str = $this->get_var($bl_handle); [602] => if (!$str) return $str; [603] => $bl_start = 0; [604] => [605] => list($bll, $blr) = explode('|', $this->block_start_string); [606] => $strlen = strlen($bll); [607] => [608] => [609] => // find them and clean from parent handle [610] => while(is_long($bl_start = strpos($str, $bll, $bl_start))) [611] => { [612] => $pos = $bl_start + $strlen; [613] => [614] => $endpos = strpos($str, $blr, $pos); [615] => $handle = substr($str, $pos, $endpos-$pos); [616] => [617] => $tag = $bll.$handle.$blr; [618] => $endtag = str_replace('|', $handle, $this->block_end_string); [619] => [620] => $start_pos = $bl_start + strlen($tag); [621] => $end_pos = strpos($str, $endtag, $bl_start); [622] => if (!$end_pos) { $this->error("스킨오류 : </block name=\"$handle\">이 없음", 'fatal'); } [623] => $bl_end = $end_pos + strlen($endtag); [624] => [625] => $block_code = substr($str, $start_pos, $end_pos-$start_pos); [626] => [627] => $this->set_var($handle, $block_code); [628] => [629] => $part1 = substr($str, 0, $bl_start); [630] => $part2 = substr($str, $bl_end, strlen($str)); [631] => [632] => $str = $part1 . $part2; [633] => [634] => if ($recurse) { $this->extract_blocks($handle, 1); } [635] => [636] => } [637] => [638] => $this->set_var($bl_handle, $str); [639] => [640] => } [641] => [642] => [643] => /** [644] => * search for tags in $handle [645] => * be carefull with paths [646] => */ [647] => function include_files($handle) [648] => { [649] => $str = $this->get_var($handle); [650] => [651] => while(is_long($pos = strpos($str, '', $pos); [655] => $filename = substr($str, $pos, $endpos-$pos); [656] => $tag = ''; [657] => [658] => [659] => $include = $this->read_file($filename); [660] => [661] => $str = str_replace($tag, $include, $str); [662] => } [663] => [664] => return $str; [665] => } [666] => [667] => [668] => /** [669] => * searches for all set loops in $handle, returns text of $handle with parsed loops [670] => * @param bool $noloop - must be true, if you want noloop statement [671] => * @return string [672] => */ [673] => function parse_loops($handle, $noloop = false) [674] => { [675] => $str = $this->get_var($handle); [676] => [677] => reset($this->loops); [678] => [679] => while ( list($loop_name, $loop_ar) = each($this->loops) ) [680] => { [681] => [682] => $start_tag = strpos($str, ''); [683] => [684] => $start_pos = $start_tag + strlen(''); [685] => if (!$start_pos) continue; [686] => $end_pos = strpos($str, ''); [687] => [688] => $loop_code = substr($str, $start_pos, $end_pos-$start_pos); [689] => $org_loop_code = $loop_code; [690] => [691] => $start_tag = substr($str, $start_tag, strlen('')); [692] => $end_tag = substr($str, $end_pos, strlen('')); [693] => [694] => if($loop_code != ''){ [695] => [696] => $new_code = ''; [697] => [698] => // clean if ($noloop & TPL_NOLOOP) [700] => { [701] => [702] => $nl_start_tag = strpos($loop_code, ''); [703] => $nl_start_pos = $nl_start_tag + strlen(''); [704] => [705] => [706] => if ($nl_start_pos) [707] => { [708] => [709] => $nl_end_pos = strpos($loop_code, ''); [710] => [711] => $noloop_code = substr($loop_code, $nl_start_pos, $nl_end_pos - $nl_start_pos); [712] => [713] => [714] => $nl_start_tag = substr($loop_code, $nl_start_tag, strlen('')); [715] => $nl_end_tag = substr($loop_code, $nl_end_pos, strlen('')); [716] => $loop_code = str_replace($nl_start_tag.$noloop_code.$nl_end_tag, '', $loop_code); [717] => } [718] => [719] => } [720] => [721] => if (is_array($loop_ar)) [722] => { [723] => [724] => if ($noloop & TPL_LOOP_INNER_PARSED) [725] => { [726] => for($i = 0; isset($loop_ar[$i]); $i++) [727] => [728] => { [729] => $temp_code = $loop_code; [730] => // rememeber loop variables [731] => [732] => $array_keys = array_keys($loop_ar[$i]); [733] => $this->set_var($loop_name, $loop_ar[$i]); [734] => if ($noloop & TPL_LOOP_INNER_OPTIONAL) $temp_code = $this->optional($loop_code); [735] => $temp_code = $this->parse($temp_code); [736] => $new_code .= $temp_code; [737] => [738] => // cleanup loop variables for next generation [739] => foreach ($array_keys as $key) unset($this->vars[$loop_name.'.'.$key]); [740] => [741] => } // for loop [742] => } [743] => else [744] => { [745] => // repeat for every row in array [746] => // for (reset($loop_ar); $row = current($loop_ar); next($loop_ar)) [747] => $ar_keys = array_keys($loop_ar); [748] => $ar_size = count($ar_keys); [749] => for($i = 0; ($i< $ar_size); $i++) [750] => { [751] => $temp_code = $loop_code; [752] => [753] => foreach( $loop_ar[$ar_keys[$i]] as $k=>$v) [754] => { [755] => $temp_code = str_replace( '{'. $loop_name. '.' .$k. '}', $v, $temp_code); [756] => } [757] => $new_code .= $temp_code; [758] => } [759] => } [760] => } elseif ($noloop & TPL_NOLOOP) [761] => { [762] => $new_code = $noloop_code; [763] => } [764] => [765] => [766] => $str = str_replace($start_tag.$org_loop_code.$end_tag, $new_code, $str); [767] => } // if loop code [768] => [769] => } // repeat for loop names [770] => [771] => return $str; [772] => } [773] => [774] => [775] => /** [776] => * process left variables [777] => * @deprecated parse() now handles unknown variables [778] => */ [779] => function finish($str) [780] => { [781] => switch ($this->unknowns) [782] => { [783] => case "keep": [784] => break; [785] => [786] => case "remove": [787] => $str = preg_replace('/{[^ \t\r\n}]+}/', "", $str); [788] => break; [789] => [790] => case "comment": [791] => $str = preg_replace('/{([^ \t\r\n}]+)}/', "", $str); [792] => break; [793] => [794] => case "space": [795] => $str = preg_replace('/{([^ \t\r\n}]+)}/', " ", $str); [796] => break; [797] => [798] => } [799] => [800] => return $str; [801] => } [802] => [803] => /** [804] => * search for optional tag [805] => * @param string $str text [806] => * @return string [807] => */ [808] => function optional($str) [809] => { [810] => $bl_start = 0; [811] => [812] => // extract and clean them from parent handle [813] => while(is_long($bl_start = strpos($str, '', $pos); [818] => $varname = substr($str, $pos, $endpos-$pos); [819] => [820] => $tag = ''; [821] => $endtag = ''; [822] => [823] => $end_pos = strpos($str, $endtag, $bl_start); [824] => if (!$end_pos) { $this->error("스킨오류 <opt name=\"$varname\">가 없음", 'fatal'); } [825] => [826] => $bl_end = $end_pos + strlen($endtag); [827] => [828] => [829] => $part1 = substr($str, 0, $bl_start); [830] => $part2 = substr($str, $bl_end, strlen($str)); [831] => [832] => // if .. by Sunmin Park [833] => if($varname[0]=="!") [834] => { [835] => $varname = substr($varname, 1); [836] => $flag = true; [837] => } [838] => else $flag = false; [839] => [840] => // .. By Sunmin Park [841] => if(strpos($varname,'=')) { [842] => list($varname,$varname_value) = explode('=',$varname,2); [843] => [844] => $value = $this->get_var_silent($varname); [845] => //echo " $value == $varname_value ";exit; [846] => if($value == $varname_value) { [847] => $flag = !$flag; [848] => } [849] => } [850] => else { [851] => $value = $this->get_var_silent($varname); [852] => [853] => //if ($value || $value === 0 || $value === '0') [854] => if ($value and $value !== 'N') [855] => { [856] => $flag = !$flag; [857] => } [858] => } [859] => [860] => if($flag) [861] => { [862] => $start_pos = $bl_start + strlen($tag); [863] => [864] => $block_code = substr($str, $start_pos, $end_pos-$start_pos); [865] => [866] => $str = $part1 . $this->parse($block_code) . $part2; [867] => } [868] => else [869] => { [870] => $str = $part1 . $part2; [871] => } [872] => } [873] => [874] => return $str; [875] => } [876] => [877] => /** [878] => * does everything: loops, includes, variables, concatenation [879] => * if $loop is 0 (not false, but 0) default parameters are used [880] => * thanks ShiVAs for idea to have $loop as parameters. [881] => * [882] => * @param $loop - loop, noloop or all parameters ored. [883] => * @param $append - append processed stuff to target, else $target is overwritten [884] => * @return string [885] => */ [886] => function process($target, $handle, $loop = false, $include = false, $append = false, $finish = false, $optional = false) [887] => { [888] => if ($loop === 0) $loop = $this->parameters; [889] => [890] => $noloop = false; [891] => $parsedloop = false; [892] => $loopopt = false; [893] => if ($loop > 2) [894] => { [895] => $noloop = $loop & TPL_NOLOOP; [896] => $include = $loop & TPL_INCLUDE; [897] => $append = $loop & TPL_APPEND; [898] => $finish = $loop & TPL_FINISH; [899] => $optional = $loop & TPL_OPTIONAL; [900] => $parsedloop = $loop & TPL_LOOP_INNER_PARSED; [901] => $loopopt = $loop & TPL_LOOP_INNER_OPTIONAL; [902] => } [903] => else [904] => { [905] => $noloop = $loop & TPL_NOLOOP; [906] => } [907] => [908] => if ($append) { [909] => if (isset($this->vars[$target])) { [910] => $app = $this->get_var($target); // preserve old info [911] => $this->set_var($target.'.count', $tmp=$this->get_var($target.'.count')+1); // by sunmin (append count) [912] => $this->set_var($target.'.countodd', $tmp%2 ); // by sunmin (append count) [913] => } [914] => else { [915] => $app = ''; [916] => $this->set_var($target.'.count', 1); // by sunmin (append count) [917] => $this->set_var($target.'.countodd', 1); // by sunmin (append count) [918] => } [919] => } [920] => [921] => $this->set_var($target, $this->get_var($handle)); // copy contents [922] => [923] => if ($include) { $this->set_var($target, $this->include_files($target)); } [924] => [925] => [926] => if ($noloop) { $this->set_var($target, $this->parse_loops($target, TPL_NOLOOP | $loopopt | $parsedloop)); } [927] => elseif ($loop) { $this->set_var($target, $this->parse_loops($target, $loopopt | $parsedloop)); } [928] => [929] => if ($optional) { $this->set_var($target, $this->optional($this->get_var_silent($target))); } [930] => [931] => if ($append) { $this->set_var($target, $app . $this->parse($this->get_var_silent($target))); } [932] => else { $this->set_var($target, $this->parse($this->get_var($target))); } [933] => [934] => if ($finish) { $this->set_var($target, $this->finish($this->get_var($target))); } [935] => [936] => return $this->get_var($target); [937] => } [938] => [939] => [940] => /** [941] => * spits out file contents [942] => * @access private [943] => */ [944] => function read_file($file) [945] => { [946] => $filename = $this->root . $file; [947] => [948] => if (!file_exists($filename)) [949] => { [950] => $this->error("phemplate::read_file(): 파일이 없음 - $filename", 'fatal'); [951] => return ''; [952] => } [953] => [954] => $tmp = false; [955] => [956] => $filesize = filesize($filename); [957] => if ($filesize) [958] => { [959] => $tmp = fread($fp = fopen($filename, 'r'), $filesize); [960] => fclose($fp); [961] => [962] => $this->read_files[]= $filename; [963] => } [964] => return $tmp; [965] => } [966] => [967] => /** [968] => * free mem used by loop [969] => */ [970] => function drop_loop($loop_handle) [971] => { [972] => if (isset($this->loops[$loop_handle])) unset($this->loops[$loop_handle]); [973] => } [974] => [975] => [976] => /** [977] => * free mem used by var [978] => */ [979] => function drop_var($handle,$var_value='') [980] => { [981] => if (is_array($var_value)) { // by Sunmin Park [982] => foreach($var_value as $key=>$value) [983] => $this->drop_var($handle.'.'.$key,$value); // recursion for array branches [984] => } [985] => elseif (isset($this->vars[$handle])) unset($this->vars[$handle]); [986] => } [987] => [988] => /** [989] => * set error handler [990] => */ [991] => function set_error_handler(&$eh) [992] => { [993] => $this->error_handler =& $eh; [994] => } [995] => [996] => /** [997] => * change block syntax [998] => */ [999] => function set_block_syntax($start, $end) [1000] => { [1001] => if (!strpos($start, '|')) $this->error("phemplate::set_block_syntax(): no '|' in start tag", 'fatal'); [1002] => if (!strpos($end, '|')) $this->error("phemplate::set_block_syntax(): no '|' in end tag", 'fatal'); [1003] => $this->block_start_string = $start; [1004] => $this->block_end_string = $end; [1005] => } [1006] => [1007] => /** [1008] => * error report [1009] => */ [1010] => function error( $msg, $level = '') [1011] => { [1012] => if (isset($this->error_handler)) [1013] => { [1014] => $lvl = E_USER_WARNING; [1015] => if ('fatal' == $level) $lvl = E_USER_ERROR; [1016] => $this->error_handler->report($lvl, $msg); [1017] => } [1018] => else [1019] => { [1020] => echo "\n
$level: $msg
\n"; [1021] => if ('fatal' == $level) { exit; } [1022] => } [1023] => } [1024] => [1025] => /** [1026] => * SitePHPbasic 반복하는 echoHtml [1027] => * By Sunmin Park 06/07/23 [1028] => */ [1029] => function echoHtml( &$dbinfo, &$SITE, $thisUrl='' ) { [1030] => $val='\\1'.$thisUrl.'skin/'.$dbinfo['skin'].'/images/'; [1031] => // - 사이트 템플릿 읽어오기 [1032] => if(ereg('^(ht|h|t)$',$dbinfo['html_type'])) { [1033] => $HEADER = array ('html_skin'=>$dbinfo['html_skin']); [1034] => @include($SITE['html_path'].'skin.php'); // retrun $aBody[0],$aBody[1] [1035] => } [1036] => [1037] => $html = ''; [1038] => switch($dbinfo['html_type']) { [1039] => case 'ht': [1040] => $html = $aBody[0]; [1041] => $html .= $dbinfo['html_head']; [1042] => $html .= ereg_replace('([="\'(])images/',$val,$this->process('', 'html',TPL_OPTIONAL)); [1043] => $html .= $dbinfo['html_tail']; [1044] => $html .= $aBody[1]; [1045] => break; [1046] => case 'h': [1047] => $html .= $aBody[0] ; [1048] => $html .= $dbinfo['html_head']; [1049] => $html .= ereg_replace('([="\'(])images/',$val,$this->process('', 'html',TPL_OPTIONAL)); [1050] => $html .= $dbinfo['html_tail']; [1051] => break; [1052] => case 't': [1053] => $html .= $dbinfo['html_head']; [1054] => $html .= ereg_replace('([="\'(])images/',$val,$this->process('', 'html',TPL_OPTIONAL)); [1055] => $html .= $dbinfo['html_tail'] ; [1056] => $html .= $aBody[1]; [1057] => break; [1058] => case 'no': [1059] => $html .= ereg_replace('([="\'(])images/',$val,$this->process('', 'html',TPL_OPTIONAL)); [1060] => break; [1061] => default: [1062] => $html .= $dbinfo['html_head']; [1063] => $html .= ereg_replace('([="\'(])images/',$val,$this->process('', 'html',TPL_OPTIONAL)); [1064] => $html .= $dbinfo['html_tail']; [1065] => } // end switch [1066] => [1067] => /* [1068] => if($_GET['utf8']=='euc-kr') { [1069] => // iconv 버그로 인해서 "\n"로 나눔 [1070] => $aA =explode("\n",$html); [1071] => $html =''; [1072] => foreach($aA as $v) $html .= iconv("euc-kr", "UTF-8",$v); [1073] => } [1074] => */ [1075] => [1076] => if($_GET['html_return']) $_GET['html']=$html; [1077] => else echo $html; [1078] => [1079] => // debug 출력 [1080] => if(defined('GET_DEBUG_2') and GET_DEBUG_2) { [1081] => echo "
"; [1082] => echo "skin : $dbinfo[skin], html_type: $dbinfo[html_type], html_skin: $dbinfo[html_skin]
thisUrl:$thisUrl "; [1083] => if('/spb3/sboard3/'==$thisUrl) { [1084] => echo " [게시판수정]"; [1085] => if($_GET['cateuid']) { [1086] => echo " [카테고리수정]"; [1087] => } [1088] => } [1089] => if($dbinfo['table']) { [1090] => echo " [$dbinfo[table]]"; [1091] => } [1092] => echo "
"; [1093] => if(count($this->read_files)) { [1094] => foreach($this->read_files as $filepath) { [1095] => if(strpos($filepath,$_SERVER['DOCUMENT_ROOT'])!==false) { [1096] => $url = substr($filepath,strlen($_SERVER['DOCUMENT_ROOT'])); [1097] => echo "skin file : $url
"; [1098] => } [1099] => else echo "skin file : $filepath
"; [1100] => } [1101] => } [1102] => //echo '
dbinfo ';var_export($dbinfo);

                                            [1103] => 			//echo '
'; [1104] => echo '
'; [1105] => } [1106] => } [1107] => } [1108] => ?> ) [new] => [ovalue] => // 04/05/17 박선민 696L optional() add and change etc.. [oindex] => 3 [nkeys] => ) ) ) [1] => Array ( [file] => /wecan/cc/cc.sdong.kr/spb3/sadmin/util/svn/spb3_diff.php [line] => 122 [function] => array_keys [args] => Array ( [0] => [1] => // 04/05/17 박선민 696L optional() add and change etc.. ) ) [2] => Array ( [file] => /wecan/cc/cc.sdong.kr/spb3/sadmin/util/svn/spb3_diff.php [line] => 142 [function] => doDiff [class] => diff [object] => diff Object ( [changes] => Array ( ) [diff] => Array ( ) [linepadding] => 2 ) [type] => -> [args] => Array ( [0] => /wecan/cc/cc.sdong.kr/spb3/sinc/lib/class_phemplate.php [1] => ) ) [3] => Array ( [file] => /wecan/cc/cc.sdong.kr/spb3/sadmin/util/svn/spb3_diff.php [line] => 197 [function] => diffWrap [class] => diff [object] => diff Object ( [changes] => Array ( ) [diff] => Array ( ) [linepadding] => 2 ) [type] => -> [args] => Array ( [0] => /wecan/cc/cc.sdong.kr/spb3/sinc/lib/class_phemplate.php [1] => ) ) [4] => Array ( [file] => /wecan/cc/cc.sdong.kr/spb3/sadmin/util/svn/spb3_diff.php [line] => 92 [function] => inline [class] => diff [object] => diff Object ( [changes] => Array ( ) [diff] => Array ( ) [linepadding] => 2 ) [type] => -> [args] => Array ( [0] => /wecan/cc/cc.sdong.kr/spb3/sinc/lib/class_phemplate.php [1] => [2] => 2 ) ) ) [key] => 4 [value] => Array ( [file] => /wecan/cc/cc.sdong.kr/spb3/sadmin/util/svn/spb3_diff.php [line] => 92 [function] => inline [class] => diff [object] => diff Object ( [changes] => Array ( ) [diff] => Array ( ) [linepadding] => 2 ) [type] => -> [args] => Array ( [0] => /wecan/cc/cc.sdong.kr/spb3/sinc/lib/class_phemplate.php [1] => [2] => 2 ) ) )
sitePHPbasic 디버그 모드 : WARNING
[2] Invalid argument supplied for foreach()
Line : 123 (file:/wecan/cc/cc.sdong.kr/spb3/sadmin/util/svn/spb3_diff.php)
- 디버그 추적(debug_backtrace)
#0 spb_error_handler() 함수사용, line(123), /wecan/cc/cc.sdong.kr/spb3/sadmin/util/svn/spb3_diff.php
#1 doDiff() 함수사용, line(142), /wecan/cc/cc.sdong.kr/spb3/sadmin/util/svn/spb3_diff.php
#2 diffWrap() 함수사용, line(197), /wecan/cc/cc.sdong.kr/spb3/sadmin/util/svn/spb3_diff.php
#3 inline() 함수사용, line(92), /wecan/cc/cc.sdong.kr/spb3/sadmin/util/svn/spb3_diff.php




사용변수들 ...
$_GET = Array ( [md5_path] => /spb3/sinc/lib/class_phemplate.php ) $_POST = Array ( ) $_COOKIE = Array ( ) Array ( [errno] => 2 [errstr] => Invalid argument supplied for foreach() [errfile] => /wecan/cc/cc.sdong.kr/spb3/sadmin/util/svn/spb3_diff.php [errline] => 123 [arr] => Array ( [0] => Array ( [file] => /wecan/cc/cc.sdong.kr/spb3/sadmin/util/svn/spb3_diff.php [line] => 123 [function] => spb_error_handler [args] => Array ( [0] => 2 [1] => Invalid argument supplied for foreach() [2] => /wecan/cc/cc.sdong.kr/spb3/sadmin/util/svn/spb3_diff.php [3] => 123 [4] => Array ( [old] => Array ( [0] => // $Id: class_phemplate.php 13 2010-08-24 08:28:50Z sitehis $ [2] => // 04/05/17 박선민 340L get_var() chanage to same get_var_silent() [3] => // 04/05/17 박선민 696L optional() add and change etc.. [4] => // 05/01/25 박선민 828L drop_var() add recursion for array branches [5] => // 05/11/20 박선민 echoHtml()로 반복하는 sitePHPbasic 마무리 부분 함수로 [6] => // 07/03/18 박선민 {!e.abc} 인경우 urlencoding 등의 기능 추가 [7] => // 07/08/14 박선민 {#widget.???} 윗젯 include 기능 추가 [8] => // 07/09/16 박선민 {#content.keyword} spb3_content 테이블의 keyword에 대한 content가져와서 넣는 기능 추가 [9] => // 08/06/14 박선민 $_GET[html_return] 기능 추가 [10] => // 08/06/28 박선민 831L optional() change 값이 'N'이여도 false되게 [11] => // 08/07/13 박선민 716L // cut_string {#cut.50#0#….key} 기능 추가 [12] => // 08/07/29 박선민 546L // parse() ... IF문 기능 추가 [13] => // 08/10/06 박선민 {#sub.2.3.???} 기능 추가 [14] => // 08/11/08 박선민 #content.??? 기능 개선 [15] => // 08/11/29 박선민 bugfix - don't use &$this [16] => // 09/01/04 박선민 {#widget2.???} 윗젯2 기능 추가(php파일위치에 widget2_???.php를 읽어서 함수 실행 [17] => // 09/02/04 박선민 {!N.list.number} 기능 추가 [18] => // 09/02/06 박선민 GET_DEBUG_2 기능 추가 [19] => // 09/02/25 박선민 {#exp.0.-.key}, server.server.HTTP_REFERER 추가 [20] => // 09/03/11 박선민 {!A.str} javascript에서 변수넘길때 큰따옴표 오류 해결용 [21] => // 09/05/08 박선민 bugfix - GET_DEBUG_2 false였을 때 오류 [22] => // 09/05/31 박선민 {!B.str} table, excel등에서 빈값은  로 변환하여 리턴하도록 [23] => // 09/05/31 박선민 {!?.str} 링크에 ?가 없으면 ?를 붙여주도록 [24] => // 09/07/28 박선민 {!X.name} : xmlspecialchars 변환 기능 추가 [25] => //---------------------------------------------------------------------------// [26] => // author: pukomuko [27] => // date: 2001.03.15 [28] => // web: http://pukomuko.esu.lt [29] => // http://sourceforge.net/projects/phemplate [30] => // info: template engine [31] => //---------------------------------------------------------------------------// [32] => // copyleft license [33] => // [34] => // this software is provided 'as-is', without any express or implied [35] => // warranty. in no event will the authors be held liable for any damages [36] => // arising from the use of this software. [37] => // [38] => // permission is granted to anyone to use this software for any purpose, [39] => // including commercial applications, and to alter it and redistribute it [40] => // freely, subject to the following restrictions: [41] => // [42] => // 1. the origin of this software must not be misrepresented; [43] => // you must not claim that you wrote the original software. [44] => // if you use this software in a product, an acknowledgment [45] => // in the product documentation would be appreciated but is not required. [46] => // [47] => // 2. altered source versions must be plainly marked as such, [48] => // and must not be misrepresented as being the original software. [49] => // [50] => // 3. mail about the fact of using this class in production [51] => // would be very appreciated. [52] => // [53] => // 4. this notice may not be removed or altered from any source distribution. [54] => // [55] => //---------------------------------------------------------------------------// [56] => // changes: [57] => // [58] => // 2004.04.21 [59] => // - warining on empty file [60] => // * v1.10.1 [61] => [62] => /** [63] => */ [64] => define('TPL_LOOP', 1); [65] => define('TPL_NOLOOP', 2); [66] => define('TPL_INCLUDE', 4); [67] => define('TPL_APPEND', 8); [68] => define('TPL_FINISH', 16); [69] => define('TPL_OPTIONAL', 32); [70] => define('TPL_LOOP_INNER_PARSED',64); [71] => define('TPL_LOOP_INNER_OPTIONAL', 128); [72] => [73] => define('TPL_PARSEDLOOP', TPL_LOOP | TPL_LOOP_INNER_PARSED); [74] => define('TPL_OPTLOOP', TPL_PARSEDLOOP | TPL_LOOP_INNER_OPTIONAL); [75] => [76] => [77] => define('TPL_BLOCK', 1); [78] => define('TPL_BLOCKREC', 2); [79] => define('TPL_STRIP_UTF_HEADER', 4); [80] => [81] => class phemplate [82] => { [83] => /** [84] => * 현재 클래스가 있는 드렉토리 By Sunmin [85] => */ [86] => var $widgetPath =''; [87] => [88] => var $read_files = array(); [89] => [90] => /** [91] => * spb3_content에서 읽어온 것을 캐쉬 [92] => */ [93] => var $spb3_content = array(); [94] => [95] => [96] => /** [97] => * variables and blocks [98] => */ [99] => var $vars = array(); [100] => [101] => /** [102] => * loops container [103] => */ [104] => var $loops = array(); [105] => [106] => /** [107] => * dir of template files [108] => */ [109] => var $root = ''; [110] => [111] => /** [112] => * what to do with unknown variables in template? [113] => */ [114] => var $unknowns = 'keep'; [115] => [116] => /** [117] => * default parameters for process() loop, append, finish [118] => */ [119] => var $parameters = 0; [120] => [121] => [122] => /** [123] => * object having method report($level, $msg) [124] => * you can catch error messages from template. [125] => */ [126] => var $error_handler = null; [127] => [128] => [129] => [130] => /** [131] => * start tag for block [132] => */ [133] => var $block_start_string = ''; [134] => [135] => /** [136] => * end tag for block [137] => */ [138] => var $block_end_string = ''; [139] => [140] => /** [141] => * constructor [142] => * $unknows를 keep에서 remove_nonjs로 변경함 by Sunmin Park [143] => */ [144] => function phemplate( $root_dir = '', $unknowns = 'remove_nonjs', $params = 0) [145] => { [146] => // widget, widget2 path [147] => $this->widgetPath = dirname(dirname(__FILE__)).'/widget/'; // By Sunmin [148] => if($this->set_root($root_dir)) [149] => $this->widget2Path = dirname(dirname($this->root)).'/'; // By Sunmin [150] => $this->set_unknowns($unknowns); [151] => $this->set_params($params); [152] => [153] => [154] => [155] => // 기본 set_var by Sunmin [156] => $this->tie_var('SITE' ,$GLOBALS['SITE']); // $SITE 전역변수 [157] => $this->tie_var('get' ,$_GET); [158] => $this->set_var('braces' ,'{'); // 중괄호{braces} 표현 [159] => $this->set_var('nowtime',time()); [160] => [161] => $this->tie_var('session.seUid' ,$_SESSION['seUid']); // 로그인 uid [162] => $this->tie_var('session.seUserid' ,$_SESSION['seUserid']); // 로그인 userid [163] => $this->tie_var('session.seName' ,$_SESSION['seName']); // 로그인 이름 [164] => $this->tie_var('session.seNickname' ,$_SESSION['seNickname']); // 로그인 별명 [165] => $this->tie_var('session.seEmail' ,$_SESSION['seEmail']); [166] => $this->tie_var('session.sePoint' ,$_SESSION['sePoint']); [167] => $this->tie_var('session.seCoupon' ,$_SESSION['seCoupon']); [168] => $this->tie_var('session.sePriv' ,$_SESSION['sePriv']); [169] => [170] => $this->set_var('server.HTTP_HOST' ,$_SERVER['HTTP_HOST']); [171] => $this->set_var('server.HTTP_REFERER',$_SERVER['HTTP_REFERER']); [172] => $this->set_var('server.QUERY_STRING' ,$_SERVER['QUERY_STRING']); [173] => $this->set_var('server.REQUEST_URI' ,$_SERVER['REQUEST_URI']); [174] => $this->set_var('server.PHP_SELF' ,$_SERVER['PHP_SELF']); [175] => } [176] => [177] => /** [178] => substitute text and returns parsed string [179] => @author ZaZa (Sergej Kurakin) 2003.05.05 21:52 [180] => */ [181] => function parse($string) [182] => { [183] => $str = explode('{', $string); [184] => [185] => $res = ''; [186] => [187] => for ($i = 0; isset($str[$i]); $i++) [188] => { [189] => $line = explode('}', $str[$i]); [190] => if ($i === 0) [191] => { [192] => $res .= $line[0]; [193] => } [194] => else [195] => { [196] => $key = $line[0]; [197] => unset($line[0]); [198] => [199] => if ( $key && isset($this->vars[$key]) ) [200] => { [201] => $res .= $this->vars[$key].implode('}', $line); [202] => } [203] => else [204] => { [205] => // {!d.list.rdate} 등 By Sunmin [206] => if($key[0]=='!') { // and isset($this->vars[substr($key,3)])) { [207] => switch(substr($key,1,2)) { [208] => /** [209] => ** 대소문자 구분함 [210] => {!B.name} : 값이 없으면   [211] => {!b.name} : 문장에서 엔터를
로 변환함 [212] => {!S.name} : 문장에서 html 테그를 모두 제거하고, 엔터는
로 변환함 [213] => [214] => {!a.name} : '\' addslashes 삽입 [215] => {!A.name} : javascript에서 변수넘길때 funcname('{!A.str}') [216] => {!s.name} : addslashes된 것을 stripcslashes함 [217] => {!?.name} : 문자열 중간 혹은 끝에 ?가 없으면 맨뒤에 ?를 붙여줌 [218] => [219] => {!h.name} : HTML특수문자로 변환( 큰따옴표도 변환 ) [220] => {!H.name} : HTML특수문자로 변환( 큰따옴표는 그대로 나둠) [221] => {!x.name} : stripcslashes함 하고 HTML특수문자로 변환( 큰따옴표도 변환) [222] => {!X.name} : xmlspecialchars 변환 [223] => [224] => {!e.url} : URL ENCODE [225] => [226] => {!n.price} : 숫자에 콤마 추가(단, 값이 없으면 무조건 '0' 리턴) [227] => {!N.price} : 숫자에 콤마 추가(단, ''값이면 빈값으로 리턴 [228] => [229] => {!D.rdate} : 숫자날짜를 YYYY-MM-DD로 변환 (연도가 4자리) [230] => {!d.rdate} : 숫자날짜를 YY-MM-DD로 변환 (연도가 2자리) [231] => {!T.rdate} : 숫자날짜를 YY-MM-DD H:i:s로 변환 (ex, 2009-01-01 23:59:55) [232] => {!t.rdate} : 숫자날짜를 시간인 H:i:s로 변환 (ex, 23:59:55) [233] => {!g.rdate} : 숫자날짜를 국제표준 한국시간으로 'D, j M Y G:i:s +0900' [234] => **/ [235] => case 'B.': [236] => if(empty($this->vars[substr($key,3)]) and $this->vars[substr($key,3)]!="0") [237] => $res .= ' '.implode('}', $line); [238] => else $res .= $this->vars[substr($key,3)].implode('}', $line); [239] => continue 2; [240] => break; [241] => case 'b.': [242] => $res .= nl2br($this->vars[substr($key,3)]).implode('}', $line); [243] => continue 2; [244] => break; [245] => case 'S.': // strip_tags(),
tag취환 [246] => $res .= ereg_replace("(\r\n|\n|\r)", '
',strip_tags($this->vars[substr($key,3)])).implode('}', $line); [247] => continue 2; [248] => break; [249] => case 'a.': [250] => $res .= addslashes($this->vars[substr($key,3)]).implode('}', $line); [251] => continue 2; [252] => break; [253] => case 'A.': [254] => $res .= str_replace('\\"','"',addslashes($this->vars[substr($key,3)])).implode('}', $line); [255] => continue 2; [256] => break; [257] => case 's.': [258] => $res .= stripcslashes($this->vars[substr($key,3)]).implode('}', $line); [259] => continue 2; [260] => break; [261] => case '?.': [262] => if(false===strpos($this->vars[substr($key,3)],'?')) [263] => $res .= $this->vars[substr($key,3)].'?'.implode('}', $line); [264] => else [265] => $res .= $this->vars[substr($key,3)].implode('}', $line); [266] => continue 2; [267] => break; [268] => case 'h.': [269] => $res .= htmlspecialchars($this->vars[substr($key,3)],ENT_QUOTES).implode('}', $line); [270] => continue 2; [271] => break; [272] => case 'H.': [273] => $res .= htmlspecialchars($this->vars[substr($key,3)],ENT_NOQUOTES).implode('}', $line); [274] => continue 2; [275] => break; [276] => case 'x.': [277] => $res .= htmlspecialchars(stripcslashes($this->vars[substr($key,3)]),ENT_QUOTES).implode('}', $line); [278] => continue 2; [279] => break; [280] => case 'X.': [281] => $res .= str_replace(''', ''', htmlspecialchars($this->vars[substr($key,3)], ENT_QUOTES)).implode('}', $line); [282] => continue 2; [283] => break; [284] => case 'e.': [285] => $res .= urlencode($this->vars[substr($key,3)]).implode('}', $line); [286] => continue 2; [287] => break; [288] => case 'n.': [289] => $res .= number_format((int)$this->vars[substr($key,3)]).implode('}', $line); [290] => continue 2; [291] => break; [292] => case 'N.': [293] => if($this->vars[substr($key,3)] or $this->vars[substr($key,3)]==='0' or $this->vars[substr($key,3)]===0) [294] => $res .= number_format($this->vars[substr($key,3)]).implode('}', $line); [295] => else $res .= implode('}', $line); [296] => continue 2; [297] => break; [298] => case 'D.': [299] => if($this->vars[substr($key,3)]) [300] => $res .= date('Y-m-d',$this->vars[substr($key,3)]).implode('}', $line); [301] => else $res .= implode('}', $line); [302] => continue 2; [303] => break; [304] => case 'd.': [305] => if($this->vars[substr($key,3)]) [306] => $res .= date('y-m-d',$this->vars[substr($key,3)]).implode('}', $line); [307] => else $res .= implode('}', $line); [308] => continue 2; [309] => break; [310] => case 'T.': [311] => if($this->vars[substr($key,3)]) [312] => $res .= date('y-m-d H:i:s',$this->vars[substr($key,3)]).implode('}', $line); [313] => else $res .= implode('}', $line); [314] => continue 2; [315] => break; [316] => case 't.': [317] => if($this->vars[substr($key,3)]) [318] => $res .= date('H:i:s',$this->vars[substr($key,3)]).implode('}', $line); [319] => else $res .= implode('}', $line); [320] => continue 2; [321] => break; [322] => case 'g.': [323] => if($this->vars[substr($key,3)]) [324] => $res .= date('D, j M Y G:i:s +0900',$this->vars[substr($key,3)]).implode('}', $line); [325] => else $res .= implode('}', $line); [326] => continue 2; [327] => break; [328] => } [329] => } [330] => [331] => if($key[0]=='#') { [332] => // /spb3/sinc/widget/???.php By Sunmin [333] => if('widget.'==substr($key,1,7)) { [334] => $tmpWidget2 = substr($key,8); [335] => list($tmpWidget,$tmpKey) = explode('.',$tmpWidget2,2); [336] => if(eregi('^[-_a-z0-9]+$',$tmpWidget) and is_file($this->widgetPath . $tmpWidget . '/index.php')) { [337] => @include_once($this->widgetPath .$tmpWidget . '/index.php'); [338] => $func = 'widget_'.$tmpWidget; [339] => $res .= @$func($this,$tmpKey) . implode('}', $line); [340] => continue; [341] => } [342] => } [343] => elseif('widget2.'==substr($key,1,8)) { [344] => $tmpWidget2 = substr($key,9); [345] => list($tmpWidget,$tmpKey) = explode('.',$tmpWidget2,2); [346] => if(eregi('^[-_a-z0-9]+$',$tmpWidget) and is_file($this->widget2Path . 'widget2_'.$tmpWidget . '.php')) { [347] => @include_once($this->widget2Path . 'widget2_'.$tmpWidget . '.php'); [348] => $func = 'widget2_'.$tmpWidget; [349] => $res .= @$func($this,$tmpKey) . implode('}', $line); [350] => continue; [351] => } [352] => }elseif('include.'==substr($key,1,8)) { [353] => $tmpFilename = substr($key,9); [354] => if(is_file($this->root.'/include_'.$tmpFilename.'.html')) { [355] => $res .= @file_get_contents($this->root.'include_'.$tmpFilename.'.html') . implode('}', $line); [356] => } [357] => else $res .= implode('}', $line); [358] => continue; [359] => } [360] => // spb3_content읽어서 keyword에서 content 전송 [361] => elseif('content.'==substr($key,1,8)) { [362] => list($tmp,$tmpKeyword,$tmpContent) = explode('.',$key,3); [363] => if(!$tmpContent) $tmpContent = 'content'; [364] => if(!isset($this->spb3_content[$tmpContent])) { [365] => $this->spb3_content[$tmpContent] = db_resultdata($GLOBALS['SITE']['th'].'cate_content',$tmpContent,'keyword',$tmpKeyword); [366] => } [367] => $res .= $this->spb3_content[$tmpContent] . implode('}', $line); [368] => continue; [369] => } [370] => // cut_string {#cut.50#0#….key} [371] => elseif('cut.'==substr($key,1,4)) { [372] => list($tmp,$tmpCut,$tmpKey) = explode('.',$key,3); [373] => list($tmpCut1,$tmpCut2,$tmpCut3) = explode('#',$tmpCut,3); [374] => if($tmpCut1===NULL) $tmpCut1 = 50; [375] => if($tmpCut2===NULL) $tmpCut2 = 0; [376] => if($tmpCut3===NULL) $tmpCut3 = '…'; [377] => $res .= cut_string($this->vars[$tmpKey],$tmpCut1,$tmpCut2,$tmpCut3).implode('}', $line); [378] => continue; [379] => } [380] => // substr {#sub.2.3.key} [381] => elseif('sub.'==substr($key,1,4)) { [382] => list($tmp,$tmpSub1,$tmpSub2,$tmpKey) = explode('.',$key,4); [383] => $res .= substr($this->vars[$tmpKey],(int)$tmpSub1,(int)$tmpSub2).implode('}', $line); [384] => continue; [385] => } [386] => // explode(split) {#exp.0.-.key} 0번째, -으로 나누어서 [387] => elseif('exp.'==substr($key,1,4)) { [388] => $tmp = explode('.',$key,4); [389] => if(4==count($tmp)) { [390] => $tmp2 = explode($tmp[2],$this->vars[$tmp[3]]); [391] => $res .= $tmp2[$tmp[1]].implode('}', $line); [392] => } [393] => else $res .= implode('}', $line); [394] => continue; [395] => } [396] => } [397] => [398] => switch ($this->unknowns) [399] => { [400] => case "keep": [401] => $res .= '{'.$key; [402] => if (count ($line) > 0) [403] => { [404] => $res .= '}'; [405] => $res .= implode('}', $line); [406] => } [407] => break; [408] => [409] => case "remove": [410] => $res .= implode('', $line); [411] => break; [412] => [413] => case "remove_nonjs": [414] => if (!empty($key) && ((false === strpos($key, ' ')) && (false === strpos($key, "\n")) && (false === strpos($key, "\t")))) [415] => { [416] => $res .= implode('}', $line); [417] => } [418] => else [419] => { [420] => $res .= '{'.$key; [421] => if (count ($line) > 0) [422] => { [423] => $res .= '}'; [424] => $res .= implode('}', $line); [425] => } [426] => } [427] => break; [428] => [429] => case "comment": [430] => $res .= ''.implode('', $line); [431] => break; [432] => [433] => case "space": [434] => $res .= ' '.implode('', $line); [435] => break; [436] => [437] => } [438] => } [439] => } [440] => } [441] => [442] => return $res; [443] => } [444] => [445] => /** [446] => * check and set template root dir [447] => */ [448] => function set_root($root) [449] => { [450] => if (empty($root)) return; [451] => if (!is_dir($root)) [452] => { [453] => $this->error("phemplate::set_root(): 다음 드렉토리가 없습니다 : $root", 'warning'); [454] => return false; [455] => } [456] => [457] => $this->root = realpath($root).'/'; // By Sunmin 05/11/13 [458] => return true; [459] => } [460] => [461] => /** [462] => * what to do with unknown variables in template? [463] => * keep [464] => * remove [465] => * remove_nonjs [466] => * comment [467] => * space [468] => */ [469] => function set_unknowns($unk) [470] => { [471] => $this->unknowns = $unk; [472] => } [473] => [474] => /** [475] => * set default parameters for process() [476] => */ [477] => function set_params($params) [478] => { [479] => $this->parameters = $params; [480] => } [481] => [482] => /** [483] => * read file template into $vars [484] => * @param string $handle - name of handle for file contents [485] => * @param int $blocks - 1 for search, 2 for nested blocks [486] => * [487] => */ [488] => function set_file($handle, $filename = "", $blocks = false) [489] => { [490] => if ($filename == "") [491] => { [492] => $this->error("phemplate::set_file(): 파일이름이 빈값으로 넘어왔습니다 -$handle", 'fatal'); [493] => return false; [494] => } [495] => $this->vars[$handle] = $this->read_file($filename); [496] => if ($blocks & TPL_STRIP_UTF_HEADER) [497] => { [498] => $header = substr($this->vars[$handle], 0, 3); [499] => if ("\xEF\xBB\xBF" == $header) $this->vars[$handle] = substr($this->vars[$handle], 3); [500] => } [501] => if ($blocks) { $this->extract_blocks($handle, $blocks & TPL_BLOCKREC); } [502] => return true; [503] => [504] => } [505] => [506] => [507] => /** [508] => * set handle and value, [509] => * if value is array, all elements will be named: handle.key.subkey [510] => */ [511] => function set_var($var_name, $var_value) [512] => { [513] => if (is_array($var_value)) [514] => { [515] => foreach($var_value as $key=>$value) [516] => { [517] => $this->set_var($var_name . '.' . $key, $value); // recursion for array branches [518] => } [519] => } [520] => else // normal variable [521] => { [522] => $this->vars[$var_name] = $var_value; [523] => } [524] => } [525] => [526] => /** [527] => * tie value with variable [528] => * it's not possible to update array keys, just values [529] => */ [530] => function tie_var($var_name, &$var_value) [531] => { [532] => if (is_array($var_value)) [533] => { [534] => $list = array_keys($var_value); [535] => foreach($list as $key) [536] => { [537] => $this->tie_var($var_name . '.' . $key, $var_value[$key]); // recursion for array branches [538] => } [539] => } [540] => else // normal variable [541] => { [542] => $this->vars[$var_name] =& $var_value; [543] => } [544] => } [545] => [546] => /** [547] => * value of $handle [548] => * raises error if $handle undefined [549] => */ [550] => function get_var($handle) [551] => { [552] => if (!isset($this->vars[$handle])) { [553] => //$this->error("phemplate(): no such handle '$handle'", 'warning'); [554] => return null; // By Sunmin Park 04/05/17 [555] => } [556] => return $this->vars[$handle]; [557] => } [558] => [559] => /** [560] => * value of $handle, no error if no handle [561] => */ [562] => function get_var_silent($handle) [563] => { [564] => if (!isset($this->vars[$handle])) { $this->vars[$handle] = ''; return ''; } [565] => return $this->vars[$handle]; [566] => } [567] => [568] => /** [569] => * assign array to loop handle [570] => * @param string $loop_name - name for a loop [571] => * @param int $loop - loop data [572] => */ [573] => function set_loop($loop_name, $loop) [574] => { [575] => if (!$loop) $loop = 0; [576] => $this->loops[$loop_name] = $loop; [577] => } [578] => [579] => /** [580] => * tie array with loop [581] => */ [582] => function tie_loop($loop_name, &$loop) [583] => { [584] => if (!$loop) $loop = 0; [585] => $this->loops[$loop_name] =& $loop; [586] => } [587] => [588] => /** [589] => * extracts blocks from handle, and returns cleaned up version [590] => * [591] => * must be quite fast, because every found block is imediately taken out of string [592] => * [593] => * [594] => * @since 2001.10.31 works with nested blocks [js] [595] => * @since 2003.06.19 supports customized block syntax [js] [596] => * [597] => */ [598] => function extract_blocks($bl_handle, $recurse = false) [599] => { [600] => [601] => $str = $this->get_var($bl_handle); [602] => if (!$str) return $str; [603] => $bl_start = 0; [604] => [605] => list($bll, $blr) = explode('|', $this->block_start_string); [606] => $strlen = strlen($bll); [607] => [608] => [609] => // find them and clean from parent handle [610] => while(is_long($bl_start = strpos($str, $bll, $bl_start))) [611] => { [612] => $pos = $bl_start + $strlen; [613] => [614] => $endpos = strpos($str, $blr, $pos); [615] => $handle = substr($str, $pos, $endpos-$pos); [616] => [617] => $tag = $bll.$handle.$blr; [618] => $endtag = str_replace('|', $handle, $this->block_end_string); [619] => [620] => $start_pos = $bl_start + strlen($tag); [621] => $end_pos = strpos($str, $endtag, $bl_start); [622] => if (!$end_pos) { $this->error("스킨오류 : </block name=\"$handle\">이 없음", 'fatal'); } [623] => $bl_end = $end_pos + strlen($endtag); [624] => [625] => $block_code = substr($str, $start_pos, $end_pos-$start_pos); [626] => [627] => $this->set_var($handle, $block_code); [628] => [629] => $part1 = substr($str, 0, $bl_start); [630] => $part2 = substr($str, $bl_end, strlen($str)); [631] => [632] => $str = $part1 . $part2; [633] => [634] => if ($recurse) { $this->extract_blocks($handle, 1); } [635] => [636] => } [637] => [638] => $this->set_var($bl_handle, $str); [639] => [640] => } [641] => [642] => [643] => /** [644] => * search for tags in $handle [645] => * be carefull with paths [646] => */ [647] => function include_files($handle) [648] => { [649] => $str = $this->get_var($handle); [650] => [651] => while(is_long($pos = strpos($str, '', $pos); [655] => $filename = substr($str, $pos, $endpos-$pos); [656] => $tag = ''; [657] => [658] => [659] => $include = $this->read_file($filename); [660] => [661] => $str = str_replace($tag, $include, $str); [662] => } [663] => [664] => return $str; [665] => } [666] => [667] => [668] => /** [669] => * searches for all set loops in $handle, returns text of $handle with parsed loops [670] => * @param bool $noloop - must be true, if you want noloop statement [671] => * @return string [672] => */ [673] => function parse_loops($handle, $noloop = false) [674] => { [675] => $str = $this->get_var($handle); [676] => [677] => reset($this->loops); [678] => [679] => while ( list($loop_name, $loop_ar) = each($this->loops) ) [680] => { [681] => [682] => $start_tag = strpos($str, ''); [683] => [684] => $start_pos = $start_tag + strlen(''); [685] => if (!$start_pos) continue; [686] => $end_pos = strpos($str, ''); [687] => [688] => $loop_code = substr($str, $start_pos, $end_pos-$start_pos); [689] => $org_loop_code = $loop_code; [690] => [691] => $start_tag = substr($str, $start_tag, strlen('')); [692] => $end_tag = substr($str, $end_pos, strlen('')); [693] => [694] => if($loop_code != ''){ [695] => [696] => $new_code = ''; [697] => [698] => // clean if ($noloop & TPL_NOLOOP) [700] => { [701] => [702] => $nl_start_tag = strpos($loop_code, ''); [703] => $nl_start_pos = $nl_start_tag + strlen(''); [704] => [705] => [706] => if ($nl_start_pos) [707] => { [708] => [709] => $nl_end_pos = strpos($loop_code, ''); [710] => [711] => $noloop_code = substr($loop_code, $nl_start_pos, $nl_end_pos - $nl_start_pos); [712] => [713] => [714] => $nl_start_tag = substr($loop_code, $nl_start_tag, strlen('')); [715] => $nl_end_tag = substr($loop_code, $nl_end_pos, strlen('')); [716] => $loop_code = str_replace($nl_start_tag.$noloop_code.$nl_end_tag, '', $loop_code); [717] => } [718] => [719] => } [720] => [721] => if (is_array($loop_ar)) [722] => { [723] => [724] => if ($noloop & TPL_LOOP_INNER_PARSED) [725] => { [726] => for($i = 0; isset($loop_ar[$i]); $i++) [727] => [728] => { [729] => $temp_code = $loop_code; [730] => // rememeber loop variables [731] => [732] => $array_keys = array_keys($loop_ar[$i]); [733] => $this->set_var($loop_name, $loop_ar[$i]); [734] => if ($noloop & TPL_LOOP_INNER_OPTIONAL) $temp_code = $this->optional($loop_code); [735] => $temp_code = $this->parse($temp_code); [736] => $new_code .= $temp_code; [737] => [738] => // cleanup loop variables for next generation [739] => foreach ($array_keys as $key) unset($this->vars[$loop_name.'.'.$key]); [740] => [741] => } // for loop [742] => } [743] => else [744] => { [745] => // repeat for every row in array [746] => // for (reset($loop_ar); $row = current($loop_ar); next($loop_ar)) [747] => $ar_keys = array_keys($loop_ar); [748] => $ar_size = count($ar_keys); [749] => for($i = 0; ($i< $ar_size); $i++) [750] => { [751] => $temp_code = $loop_code; [752] => [753] => foreach( $loop_ar[$ar_keys[$i]] as $k=>$v) [754] => { [755] => $temp_code = str_replace( '{'. $loop_name. '.' .$k. '}', $v, $temp_code); [756] => } [757] => $new_code .= $temp_code; [758] => } [759] => } [760] => } elseif ($noloop & TPL_NOLOOP) [761] => { [762] => $new_code = $noloop_code; [763] => } [764] => [765] => [766] => $str = str_replace($start_tag.$org_loop_code.$end_tag, $new_code, $str); [767] => } // if loop code [768] => [769] => } // repeat for loop names [770] => [771] => return $str; [772] => } [773] => [774] => [775] => /** [776] => * process left variables [777] => * @deprecated parse() now handles unknown variables [778] => */ [779] => function finish($str) [780] => { [781] => switch ($this->unknowns) [782] => { [783] => case "keep": [784] => break; [785] => [786] => case "remove": [787] => $str = preg_replace('/{[^ \t\r\n}]+}/', "", $str); [788] => break; [789] => [790] => case "comment": [791] => $str = preg_replace('/{([^ \t\r\n}]+)}/', "", $str); [792] => break; [793] => [794] => case "space": [795] => $str = preg_replace('/{([^ \t\r\n}]+)}/', " ", $str); [796] => break; [797] => [798] => } [799] => [800] => return $str; [801] => } [802] => [803] => /** [804] => * search for optional tag [805] => * @param string $str text [806] => * @return string [807] => */ [808] => function optional($str) [809] => { [810] => $bl_start = 0; [811] => [812] => // extract and clean them from parent handle [813] => while(is_long($bl_start = strpos($str, '', $pos); [818] => $varname = substr($str, $pos, $endpos-$pos); [819] => [820] => $tag = ''; [821] => $endtag = ''; [822] => [823] => $end_pos = strpos($str, $endtag, $bl_start); [824] => if (!$end_pos) { $this->error("스킨오류 <opt name=\"$varname\">가 없음", 'fatal'); } [825] => [826] => $bl_end = $end_pos + strlen($endtag); [827] => [828] => [829] => $part1 = substr($str, 0, $bl_start); [830] => $part2 = substr($str, $bl_end, strlen($str)); [831] => [832] => // if .. by Sunmin Park [833] => if($varname[0]=="!") [834] => { [835] => $varname = substr($varname, 1); [836] => $flag = true; [837] => } [838] => else $flag = false; [839] => [840] => // .. By Sunmin Park [841] => if(strpos($varname,'=')) { [842] => list($varname,$varname_value) = explode('=',$varname,2); [843] => [844] => $value = $this->get_var_silent($varname); [845] => //echo " $value == $varname_value ";exit; [846] => if($value == $varname_value) { [847] => $flag = !$flag; [848] => } [849] => } [850] => else { [851] => $value = $this->get_var_silent($varname); [852] => [853] => //if ($value || $value === 0 || $value === '0') [854] => if ($value and $value !== 'N') [855] => { [856] => $flag = !$flag; [857] => } [858] => } [859] => [860] => if($flag) [861] => { [862] => $start_pos = $bl_start + strlen($tag); [863] => [864] => $block_code = substr($str, $start_pos, $end_pos-$start_pos); [865] => [866] => $str = $part1 . $this->parse($block_code) . $part2; [867] => } [868] => else [869] => { [870] => $str = $part1 . $part2; [871] => } [872] => } [873] => [874] => return $str; [875] => } [876] => [877] => /** [878] => * does everything: loops, includes, variables, concatenation [879] => * if $loop is 0 (not false, but 0) default parameters are used [880] => * thanks ShiVAs for idea to have $loop as parameters. [881] => * [882] => * @param $loop - loop, noloop or all parameters ored. [883] => * @param $append - append processed stuff to target, else $target is overwritten [884] => * @return string [885] => */ [886] => function process($target, $handle, $loop = false, $include = false, $append = false, $finish = false, $optional = false) [887] => { [888] => if ($loop === 0) $loop = $this->parameters; [889] => [890] => $noloop = false; [891] => $parsedloop = false; [892] => $loopopt = false; [893] => if ($loop > 2) [894] => { [895] => $noloop = $loop & TPL_NOLOOP; [896] => $include = $loop & TPL_INCLUDE; [897] => $append = $loop & TPL_APPEND; [898] => $finish = $loop & TPL_FINISH; [899] => $optional = $loop & TPL_OPTIONAL; [900] => $parsedloop = $loop & TPL_LOOP_INNER_PARSED; [901] => $loopopt = $loop & TPL_LOOP_INNER_OPTIONAL; [902] => } [903] => else [904] => { [905] => $noloop = $loop & TPL_NOLOOP; [906] => } [907] => [908] => if ($append) { [909] => if (isset($this->vars[$target])) { [910] => $app = $this->get_var($target); // preserve old info [911] => $this->set_var($target.'.count', $tmp=$this->get_var($target.'.count')+1); // by sunmin (append count) [912] => $this->set_var($target.'.countodd', $tmp%2 ); // by sunmin (append count) [913] => } [914] => else { [915] => $app = ''; [916] => $this->set_var($target.'.count', 1); // by sunmin (append count) [917] => $this->set_var($target.'.countodd', 1); // by sunmin (append count) [918] => } [919] => } [920] => [921] => $this->set_var($target, $this->get_var($handle)); // copy contents [922] => [923] => if ($include) { $this->set_var($target, $this->include_files($target)); } [924] => [925] => [926] => if ($noloop) { $this->set_var($target, $this->parse_loops($target, TPL_NOLOOP | $loopopt | $parsedloop)); } [927] => elseif ($loop) { $this->set_var($target, $this->parse_loops($target, $loopopt | $parsedloop)); } [928] => [929] => if ($optional) { $this->set_var($target, $this->optional($this->get_var_silent($target))); } [930] => [931] => if ($append) { $this->set_var($target, $app . $this->parse($this->get_var_silent($target))); } [932] => else { $this->set_var($target, $this->parse($this->get_var($target))); } [933] => [934] => if ($finish) { $this->set_var($target, $this->finish($this->get_var($target))); } [935] => [936] => return $this->get_var($target); [937] => } [938] => [939] => [940] => /** [941] => * spits out file contents [942] => * @access private [943] => */ [944] => function read_file($file) [945] => { [946] => $filename = $this->root . $file; [947] => [948] => if (!file_exists($filename)) [949] => { [950] => $this->error("phemplate::read_file(): 파일이 없음 - $filename", 'fatal'); [951] => return ''; [952] => } [953] => [954] => $tmp = false; [955] => [956] => $filesize = filesize($filename); [957] => if ($filesize) [958] => { [959] => $tmp = fread($fp = fopen($filename, 'r'), $filesize); [960] => fclose($fp); [961] => [962] => $this->read_files[]= $filename; [963] => } [964] => return $tmp; [965] => } [966] => [967] => /** [968] => * free mem used by loop [969] => */ [970] => function drop_loop($loop_handle) [971] => { [972] => if (isset($this->loops[$loop_handle])) unset($this->loops[$loop_handle]); [973] => } [974] => [975] => [976] => /** [977] => * free mem used by var [978] => */ [979] => function drop_var($handle,$var_value='') [980] => { [981] => if (is_array($var_value)) { // by Sunmin Park [982] => foreach($var_value as $key=>$value) [983] => $this->drop_var($handle.'.'.$key,$value); // recursion for array branches [984] => } [985] => elseif (isset($this->vars[$handle])) unset($this->vars[$handle]); [986] => } [987] => [988] => /** [989] => * set error handler [990] => */ [991] => function set_error_handler(&$eh) [992] => { [993] => $this->error_handler =& $eh; [994] => } [995] => [996] => /** [997] => * change block syntax [998] => */ [999] => function set_block_syntax($start, $end) [1000] => { [1001] => if (!strpos($start, '|')) $this->error("phemplate::set_block_syntax(): no '|' in start tag", 'fatal'); [1002] => if (!strpos($end, '|')) $this->error("phemplate::set_block_syntax(): no '|' in end tag", 'fatal'); [1003] => $this->block_start_string = $start; [1004] => $this->block_end_string = $end; [1005] => } [1006] => [1007] => /** [1008] => * error report [1009] => */ [1010] => function error( $msg, $level = '') [1011] => { [1012] => if (isset($this->error_handler)) [1013] => { [1014] => $lvl = E_USER_WARNING; [1015] => if ('fatal' == $level) $lvl = E_USER_ERROR; [1016] => $this->error_handler->report($lvl, $msg); [1017] => } [1018] => else [1019] => { [1020] => echo "\n
$level: $msg
\n"; [1021] => if ('fatal' == $level) { exit; } [1022] => } [1023] => } [1024] => [1025] => /** [1026] => * SitePHPbasic 반복하는 echoHtml [1027] => * By Sunmin Park 06/07/23 [1028] => */ [1029] => function echoHtml( &$dbinfo, &$SITE, $thisUrl='' ) { [1030] => $val='\\1'.$thisUrl.'skin/'.$dbinfo['skin'].'/images/'; [1031] => // - 사이트 템플릿 읽어오기 [1032] => if(ereg('^(ht|h|t)$',$dbinfo['html_type'])) { [1033] => $HEADER = array ('html_skin'=>$dbinfo['html_skin']); [1034] => @include($SITE['html_path'].'skin.php'); // retrun $aBody[0],$aBody[1] [1035] => } [1036] => [1037] => $html = ''; [1038] => switch($dbinfo['html_type']) { [1039] => case 'ht': [1040] => $html = $aBody[0]; [1041] => $html .= $dbinfo['html_head']; [1042] => $html .= ereg_replace('([="\'(])images/',$val,$this->process('', 'html',TPL_OPTIONAL)); [1043] => $html .= $dbinfo['html_tail']; [1044] => $html .= $aBody[1]; [1045] => break; [1046] => case 'h': [1047] => $html .= $aBody[0] ; [1048] => $html .= $dbinfo['html_head']; [1049] => $html .= ereg_replace('([="\'(])images/',$val,$this->process('', 'html',TPL_OPTIONAL)); [1050] => $html .= $dbinfo['html_tail']; [1051] => break; [1052] => case 't': [1053] => $html .= $dbinfo['html_head']; [1054] => $html .= ereg_replace('([="\'(])images/',$val,$this->process('', 'html',TPL_OPTIONAL)); [1055] => $html .= $dbinfo['html_tail'] ; [1056] => $html .= $aBody[1]; [1057] => break; [1058] => case 'no': [1059] => $html .= ereg_replace('([="\'(])images/',$val,$this->process('', 'html',TPL_OPTIONAL)); [1060] => break; [1061] => default: [1062] => $html .= $dbinfo['html_head']; [1063] => $html .= ereg_replace('([="\'(])images/',$val,$this->process('', 'html',TPL_OPTIONAL)); [1064] => $html .= $dbinfo['html_tail']; [1065] => } // end switch [1066] => [1067] => /* [1068] => if($_GET['utf8']=='euc-kr') { [1069] => // iconv 버그로 인해서 "\n"로 나눔 [1070] => $aA =explode("\n",$html); [1071] => $html =''; [1072] => foreach($aA as $v) $html .= iconv("euc-kr", "UTF-8",$v); [1073] => } [1074] => */ [1075] => [1076] => if($_GET['html_return']) $_GET['html']=$html; [1077] => else echo $html; [1078] => [1079] => // debug 출력 [1080] => if(defined('GET_DEBUG_2') and GET_DEBUG_2) { [1081] => echo "
"; [1082] => echo "skin : $dbinfo[skin], html_type: $dbinfo[html_type], html_skin: $dbinfo[html_skin]
thisUrl:$thisUrl "; [1083] => if('/spb3/sboard3/'==$thisUrl) { [1084] => echo " [게시판수정]"; [1085] => if($_GET['cateuid']) { [1086] => echo " [카테고리수정]"; [1087] => } [1088] => } [1089] => if($dbinfo['table']) { [1090] => echo " [$dbinfo[table]]"; [1091] => } [1092] => echo "
"; [1093] => if(count($this->read_files)) { [1094] => foreach($this->read_files as $filepath) { [1095] => if(strpos($filepath,$_SERVER['DOCUMENT_ROOT'])!==false) { [1096] => $url = substr($filepath,strlen($_SERVER['DOCUMENT_ROOT'])); [1097] => echo "skin file : $url
"; [1098] => } [1099] => else echo "skin file : $filepath
"; [1100] => } [1101] => } [1102] => //echo '
dbinfo ';var_export($dbinfo);

                                            [1103] => 			//echo '
'; [1104] => echo '
'; [1105] => } [1106] => } [1107] => } [1108] => ?> ) [new] => [ovalue] => // 04/05/17 박선민 696L optional() add and change etc.. [oindex] => 3 [nkeys] => ) ) ) [1] => Array ( [file] => /wecan/cc/cc.sdong.kr/spb3/sadmin/util/svn/spb3_diff.php [line] => 142 [function] => doDiff [class] => diff [object] => diff Object ( [changes] => Array ( ) [diff] => Array ( ) [linepadding] => 2 ) [type] => -> [args] => Array ( [0] => /wecan/cc/cc.sdong.kr/spb3/sinc/lib/class_phemplate.php [1] => ) ) [2] => Array ( [file] => /wecan/cc/cc.sdong.kr/spb3/sadmin/util/svn/spb3_diff.php [line] => 197 [function] => diffWrap [class] => diff [object] => diff Object ( [changes] => Array ( ) [diff] => Array ( ) [linepadding] => 2 ) [type] => -> [args] => Array ( [0] => /wecan/cc/cc.sdong.kr/spb3/sinc/lib/class_phemplate.php [1] => ) ) [3] => Array ( [file] => /wecan/cc/cc.sdong.kr/spb3/sadmin/util/svn/spb3_diff.php [line] => 92 [function] => inline [class] => diff [object] => diff Object ( [changes] => Array ( ) [diff] => Array ( ) [linepadding] => 2 ) [type] => -> [args] => Array ( [0] => /wecan/cc/cc.sdong.kr/spb3/sinc/lib/class_phemplate.php [1] => [2] => 2 ) ) ) [key] => 3 [value] => Array ( [file] => /wecan/cc/cc.sdong.kr/spb3/sadmin/util/svn/spb3_diff.php [line] => 92 [function] => inline [class] => diff [object] => diff Object ( [changes] => Array ( ) [diff] => Array ( ) [linepadding] => 2 ) [type] => -> [args] => Array ( [0] => /wecan/cc/cc.sdong.kr/spb3/sinc/lib/class_phemplate.php [1] => [2] => 2 ) ) )
sitePHPbasic 디버그 모드 : WARNING
[2] array_keys() expects parameter 1 to be array, boolean given
Line : 122 (file:/wecan/cc/cc.sdong.kr/spb3/sadmin/util/svn/spb3_diff.php)
- 디버그 추적(debug_backtrace)
#0 spb_error_handler() 함수사용, line(),
#1 array_keys() 함수사용, line(122), /wecan/cc/cc.sdong.kr/spb3/sadmin/util/svn/spb3_diff.php
#2 doDiff() 함수사용, line(142), /wecan/cc/cc.sdong.kr/spb3/sadmin/util/svn/spb3_diff.php
#3 diffWrap() 함수사용, line(197), /wecan/cc/cc.sdong.kr/spb3/sadmin/util/svn/spb3_diff.php
#4 inline() 함수사용, line(92), /wecan/cc/cc.sdong.kr/spb3/sadmin/util/svn/spb3_diff.php




사용변수들 ...
$_GET = Array ( [md5_path] => /spb3/sinc/lib/class_phemplate.php ) $_POST = Array ( ) $_COOKIE = Array ( ) Array ( [errno] => 2 [errstr] => array_keys() expects parameter 1 to be array, boolean given [errfile] => /wecan/cc/cc.sdong.kr/spb3/sadmin/util/svn/spb3_diff.php [errline] => 122 [arr] => Array ( [0] => Array ( [function] => spb_error_handler [args] => Array ( [0] => 2 [1] => array_keys() expects parameter 1 to be array, boolean given [2] => /wecan/cc/cc.sdong.kr/spb3/sadmin/util/svn/spb3_diff.php [3] => 122 [4] => Array ( [old] => Array ( [0] => // $Id: class_phemplate.php 13 2010-08-24 08:28:50Z sitehis $ [2] => // 04/05/17 박선민 340L get_var() chanage to same get_var_silent() [3] => // 04/05/17 박선민 696L optional() add and change etc.. [4] => // 05/01/25 박선민 828L drop_var() add recursion for array branches [5] => // 05/11/20 박선민 echoHtml()로 반복하는 sitePHPbasic 마무리 부분 함수로 [6] => // 07/03/18 박선민 {!e.abc} 인경우 urlencoding 등의 기능 추가 [7] => // 07/08/14 박선민 {#widget.???} 윗젯 include 기능 추가 [8] => // 07/09/16 박선민 {#content.keyword} spb3_content 테이블의 keyword에 대한 content가져와서 넣는 기능 추가 [9] => // 08/06/14 박선민 $_GET[html_return] 기능 추가 [10] => // 08/06/28 박선민 831L optional() change 값이 'N'이여도 false되게 [11] => // 08/07/13 박선민 716L // cut_string {#cut.50#0#….key} 기능 추가 [12] => // 08/07/29 박선민 546L // parse() ... IF문 기능 추가 [13] => // 08/10/06 박선민 {#sub.2.3.???} 기능 추가 [14] => // 08/11/08 박선민 #content.??? 기능 개선 [15] => // 08/11/29 박선민 bugfix - don't use &$this [16] => // 09/01/04 박선민 {#widget2.???} 윗젯2 기능 추가(php파일위치에 widget2_???.php를 읽어서 함수 실행 [17] => // 09/02/04 박선민 {!N.list.number} 기능 추가 [18] => // 09/02/06 박선민 GET_DEBUG_2 기능 추가 [19] => // 09/02/25 박선민 {#exp.0.-.key}, server.server.HTTP_REFERER 추가 [20] => // 09/03/11 박선민 {!A.str} javascript에서 변수넘길때 큰따옴표 오류 해결용 [21] => // 09/05/08 박선민 bugfix - GET_DEBUG_2 false였을 때 오류 [22] => // 09/05/31 박선민 {!B.str} table, excel등에서 빈값은  로 변환하여 리턴하도록 [23] => // 09/05/31 박선민 {!?.str} 링크에 ?가 없으면 ?를 붙여주도록 [24] => // 09/07/28 박선민 {!X.name} : xmlspecialchars 변환 기능 추가 [25] => //---------------------------------------------------------------------------// [26] => // author: pukomuko [27] => // date: 2001.03.15 [28] => // web: http://pukomuko.esu.lt [29] => // http://sourceforge.net/projects/phemplate [30] => // info: template engine [31] => //---------------------------------------------------------------------------// [32] => // copyleft license [33] => // [34] => // this software is provided 'as-is', without any express or implied [35] => // warranty. in no event will the authors be held liable for any damages [36] => // arising from the use of this software. [37] => // [38] => // permission is granted to anyone to use this software for any purpose, [39] => // including commercial applications, and to alter it and redistribute it [40] => // freely, subject to the following restrictions: [41] => // [42] => // 1. the origin of this software must not be misrepresented; [43] => // you must not claim that you wrote the original software. [44] => // if you use this software in a product, an acknowledgment [45] => // in the product documentation would be appreciated but is not required. [46] => // [47] => // 2. altered source versions must be plainly marked as such, [48] => // and must not be misrepresented as being the original software. [49] => // [50] => // 3. mail about the fact of using this class in production [51] => // would be very appreciated. [52] => // [53] => // 4. this notice may not be removed or altered from any source distribution. [54] => // [55] => //---------------------------------------------------------------------------// [56] => // changes: [57] => // [58] => // 2004.04.21 [59] => // - warining on empty file [60] => // * v1.10.1 [61] => [62] => /** [63] => */ [64] => define('TPL_LOOP', 1); [65] => define('TPL_NOLOOP', 2); [66] => define('TPL_INCLUDE', 4); [67] => define('TPL_APPEND', 8); [68] => define('TPL_FINISH', 16); [69] => define('TPL_OPTIONAL', 32); [70] => define('TPL_LOOP_INNER_PARSED',64); [71] => define('TPL_LOOP_INNER_OPTIONAL', 128); [72] => [73] => define('TPL_PARSEDLOOP', TPL_LOOP | TPL_LOOP_INNER_PARSED); [74] => define('TPL_OPTLOOP', TPL_PARSEDLOOP | TPL_LOOP_INNER_OPTIONAL); [75] => [76] => [77] => define('TPL_BLOCK', 1); [78] => define('TPL_BLOCKREC', 2); [79] => define('TPL_STRIP_UTF_HEADER', 4); [80] => [81] => class phemplate [82] => { [83] => /** [84] => * 현재 클래스가 있는 드렉토리 By Sunmin [85] => */ [86] => var $widgetPath =''; [87] => [88] => var $read_files = array(); [89] => [90] => /** [91] => * spb3_content에서 읽어온 것을 캐쉬 [92] => */ [93] => var $spb3_content = array(); [94] => [95] => [96] => /** [97] => * variables and blocks [98] => */ [99] => var $vars = array(); [100] => [101] => /** [102] => * loops container [103] => */ [104] => var $loops = array(); [105] => [106] => /** [107] => * dir of template files [108] => */ [109] => var $root = ''; [110] => [111] => /** [112] => * what to do with unknown variables in template? [113] => */ [114] => var $unknowns = 'keep'; [115] => [116] => /** [117] => * default parameters for process() loop, append, finish [118] => */ [119] => var $parameters = 0; [120] => [121] => [122] => /** [123] => * object having method report($level, $msg) [124] => * you can catch error messages from template. [125] => */ [126] => var $error_handler = null; [127] => [128] => [129] => [130] => /** [131] => * start tag for block [132] => */ [133] => var $block_start_string = ''; [134] => [135] => /** [136] => * end tag for block [137] => */ [138] => var $block_end_string = ''; [139] => [140] => /** [141] => * constructor [142] => * $unknows를 keep에서 remove_nonjs로 변경함 by Sunmin Park [143] => */ [144] => function phemplate( $root_dir = '', $unknowns = 'remove_nonjs', $params = 0) [145] => { [146] => // widget, widget2 path [147] => $this->widgetPath = dirname(dirname(__FILE__)).'/widget/'; // By Sunmin [148] => if($this->set_root($root_dir)) [149] => $this->widget2Path = dirname(dirname($this->root)).'/'; // By Sunmin [150] => $this->set_unknowns($unknowns); [151] => $this->set_params($params); [152] => [153] => [154] => [155] => // 기본 set_var by Sunmin [156] => $this->tie_var('SITE' ,$GLOBALS['SITE']); // $SITE 전역변수 [157] => $this->tie_var('get' ,$_GET); [158] => $this->set_var('braces' ,'{'); // 중괄호{braces} 표현 [159] => $this->set_var('nowtime',time()); [160] => [161] => $this->tie_var('session.seUid' ,$_SESSION['seUid']); // 로그인 uid [162] => $this->tie_var('session.seUserid' ,$_SESSION['seUserid']); // 로그인 userid [163] => $this->tie_var('session.seName' ,$_SESSION['seName']); // 로그인 이름 [164] => $this->tie_var('session.seNickname' ,$_SESSION['seNickname']); // 로그인 별명 [165] => $this->tie_var('session.seEmail' ,$_SESSION['seEmail']); [166] => $this->tie_var('session.sePoint' ,$_SESSION['sePoint']); [167] => $this->tie_var('session.seCoupon' ,$_SESSION['seCoupon']); [168] => $this->tie_var('session.sePriv' ,$_SESSION['sePriv']); [169] => [170] => $this->set_var('server.HTTP_HOST' ,$_SERVER['HTTP_HOST']); [171] => $this->set_var('server.HTTP_REFERER',$_SERVER['HTTP_REFERER']); [172] => $this->set_var('server.QUERY_STRING' ,$_SERVER['QUERY_STRING']); [173] => $this->set_var('server.REQUEST_URI' ,$_SERVER['REQUEST_URI']); [174] => $this->set_var('server.PHP_SELF' ,$_SERVER['PHP_SELF']); [175] => } [176] => [177] => /** [178] => substitute text and returns parsed string [179] => @author ZaZa (Sergej Kurakin) 2003.05.05 21:52 [180] => */ [181] => function parse($string) [182] => { [183] => $str = explode('{', $string); [184] => [185] => $res = ''; [186] => [187] => for ($i = 0; isset($str[$i]); $i++) [188] => { [189] => $line = explode('}', $str[$i]); [190] => if ($i === 0) [191] => { [192] => $res .= $line[0]; [193] => } [194] => else [195] => { [196] => $key = $line[0]; [197] => unset($line[0]); [198] => [199] => if ( $key && isset($this->vars[$key]) ) [200] => { [201] => $res .= $this->vars[$key].implode('}', $line); [202] => } [203] => else [204] => { [205] => // {!d.list.rdate} 등 By Sunmin [206] => if($key[0]=='!') { // and isset($this->vars[substr($key,3)])) { [207] => switch(substr($key,1,2)) { [208] => /** [209] => ** 대소문자 구분함 [210] => {!B.name} : 값이 없으면   [211] => {!b.name} : 문장에서 엔터를
로 변환함 [212] => {!S.name} : 문장에서 html 테그를 모두 제거하고, 엔터는
로 변환함 [213] => [214] => {!a.name} : '\' addslashes 삽입 [215] => {!A.name} : javascript에서 변수넘길때 funcname('{!A.str}') [216] => {!s.name} : addslashes된 것을 stripcslashes함 [217] => {!?.name} : 문자열 중간 혹은 끝에 ?가 없으면 맨뒤에 ?를 붙여줌 [218] => [219] => {!h.name} : HTML특수문자로 변환( 큰따옴표도 변환 ) [220] => {!H.name} : HTML특수문자로 변환( 큰따옴표는 그대로 나둠) [221] => {!x.name} : stripcslashes함 하고 HTML특수문자로 변환( 큰따옴표도 변환) [222] => {!X.name} : xmlspecialchars 변환 [223] => [224] => {!e.url} : URL ENCODE [225] => [226] => {!n.price} : 숫자에 콤마 추가(단, 값이 없으면 무조건 '0' 리턴) [227] => {!N.price} : 숫자에 콤마 추가(단, ''값이면 빈값으로 리턴 [228] => [229] => {!D.rdate} : 숫자날짜를 YYYY-MM-DD로 변환 (연도가 4자리) [230] => {!d.rdate} : 숫자날짜를 YY-MM-DD로 변환 (연도가 2자리) [231] => {!T.rdate} : 숫자날짜를 YY-MM-DD H:i:s로 변환 (ex, 2009-01-01 23:59:55) [232] => {!t.rdate} : 숫자날짜를 시간인 H:i:s로 변환 (ex, 23:59:55) [233] => {!g.rdate} : 숫자날짜를 국제표준 한국시간으로 'D, j M Y G:i:s +0900' [234] => **/ [235] => case 'B.': [236] => if(empty($this->vars[substr($key,3)]) and $this->vars[substr($key,3)]!="0") [237] => $res .= ' '.implode('}', $line); [238] => else $res .= $this->vars[substr($key,3)].implode('}', $line); [239] => continue 2; [240] => break; [241] => case 'b.': [242] => $res .= nl2br($this->vars[substr($key,3)]).implode('}', $line); [243] => continue 2; [244] => break; [245] => case 'S.': // strip_tags(),
tag취환 [246] => $res .= ereg_replace("(\r\n|\n|\r)", '
',strip_tags($this->vars[substr($key,3)])).implode('}', $line); [247] => continue 2; [248] => break; [249] => case 'a.': [250] => $res .= addslashes($this->vars[substr($key,3)]).implode('}', $line); [251] => continue 2; [252] => break; [253] => case 'A.': [254] => $res .= str_replace('\\"','"',addslashes($this->vars[substr($key,3)])).implode('}', $line); [255] => continue 2; [256] => break; [257] => case 's.': [258] => $res .= stripcslashes($this->vars[substr($key,3)]).implode('}', $line); [259] => continue 2; [260] => break; [261] => case '?.': [262] => if(false===strpos($this->vars[substr($key,3)],'?')) [263] => $res .= $this->vars[substr($key,3)].'?'.implode('}', $line); [264] => else [265] => $res .= $this->vars[substr($key,3)].implode('}', $line); [266] => continue 2; [267] => break; [268] => case 'h.': [269] => $res .= htmlspecialchars($this->vars[substr($key,3)],ENT_QUOTES).implode('}', $line); [270] => continue 2; [271] => break; [272] => case 'H.': [273] => $res .= htmlspecialchars($this->vars[substr($key,3)],ENT_NOQUOTES).implode('}', $line); [274] => continue 2; [275] => break; [276] => case 'x.': [277] => $res .= htmlspecialchars(stripcslashes($this->vars[substr($key,3)]),ENT_QUOTES).implode('}', $line); [278] => continue 2; [279] => break; [280] => case 'X.': [281] => $res .= str_replace(''', ''', htmlspecialchars($this->vars[substr($key,3)], ENT_QUOTES)).implode('}', $line); [282] => continue 2; [283] => break; [284] => case 'e.': [285] => $res .= urlencode($this->vars[substr($key,3)]).implode('}', $line); [286] => continue 2; [287] => break; [288] => case 'n.': [289] => $res .= number_format((int)$this->vars[substr($key,3)]).implode('}', $line); [290] => continue 2; [291] => break; [292] => case 'N.': [293] => if($this->vars[substr($key,3)] or $this->vars[substr($key,3)]==='0' or $this->vars[substr($key,3)]===0) [294] => $res .= number_format($this->vars[substr($key,3)]).implode('}', $line); [295] => else $res .= implode('}', $line); [296] => continue 2; [297] => break; [298] => case 'D.': [299] => if($this->vars[substr($key,3)]) [300] => $res .= date('Y-m-d',$this->vars[substr($key,3)]).implode('}', $line); [301] => else $res .= implode('}', $line); [302] => continue 2; [303] => break; [304] => case 'd.': [305] => if($this->vars[substr($key,3)]) [306] => $res .= date('y-m-d',$this->vars[substr($key,3)]).implode('}', $line); [307] => else $res .= implode('}', $line); [308] => continue 2; [309] => break; [310] => case 'T.': [311] => if($this->vars[substr($key,3)]) [312] => $res .= date('y-m-d H:i:s',$this->vars[substr($key,3)]).implode('}', $line); [313] => else $res .= implode('}', $line); [314] => continue 2; [315] => break; [316] => case 't.': [317] => if($this->vars[substr($key,3)]) [318] => $res .= date('H:i:s',$this->vars[substr($key,3)]).implode('}', $line); [319] => else $res .= implode('}', $line); [320] => continue 2; [321] => break; [322] => case 'g.': [323] => if($this->vars[substr($key,3)]) [324] => $res .= date('D, j M Y G:i:s +0900',$this->vars[substr($key,3)]).implode('}', $line); [325] => else $res .= implode('}', $line); [326] => continue 2; [327] => break; [328] => } [329] => } [330] => [331] => if($key[0]=='#') { [332] => // /spb3/sinc/widget/???.php By Sunmin [333] => if('widget.'==substr($key,1,7)) { [334] => $tmpWidget2 = substr($key,8); [335] => list($tmpWidget,$tmpKey) = explode('.',$tmpWidget2,2); [336] => if(eregi('^[-_a-z0-9]+$',$tmpWidget) and is_file($this->widgetPath . $tmpWidget . '/index.php')) { [337] => @include_once($this->widgetPath .$tmpWidget . '/index.php'); [338] => $func = 'widget_'.$tmpWidget; [339] => $res .= @$func($this,$tmpKey) . implode('}', $line); [340] => continue; [341] => } [342] => } [343] => elseif('widget2.'==substr($key,1,8)) { [344] => $tmpWidget2 = substr($key,9); [345] => list($tmpWidget,$tmpKey) = explode('.',$tmpWidget2,2); [346] => if(eregi('^[-_a-z0-9]+$',$tmpWidget) and is_file($this->widget2Path . 'widget2_'.$tmpWidget . '.php')) { [347] => @include_once($this->widget2Path . 'widget2_'.$tmpWidget . '.php'); [348] => $func = 'widget2_'.$tmpWidget; [349] => $res .= @$func($this,$tmpKey) . implode('}', $line); [350] => continue; [351] => } [352] => }elseif('include.'==substr($key,1,8)) { [353] => $tmpFilename = substr($key,9); [354] => if(is_file($this->root.'/include_'.$tmpFilename.'.html')) { [355] => $res .= @file_get_contents($this->root.'include_'.$tmpFilename.'.html') . implode('}', $line); [356] => } [357] => else $res .= implode('}', $line); [358] => continue; [359] => } [360] => // spb3_content읽어서 keyword에서 content 전송 [361] => elseif('content.'==substr($key,1,8)) { [362] => list($tmp,$tmpKeyword,$tmpContent) = explode('.',$key,3); [363] => if(!$tmpContent) $tmpContent = 'content'; [364] => if(!isset($this->spb3_content[$tmpContent])) { [365] => $this->spb3_content[$tmpContent] = db_resultdata($GLOBALS['SITE']['th'].'cate_content',$tmpContent,'keyword',$tmpKeyword); [366] => } [367] => $res .= $this->spb3_content[$tmpContent] . implode('}', $line); [368] => continue; [369] => } [370] => // cut_string {#cut.50#0#….key} [371] => elseif('cut.'==substr($key,1,4)) { [372] => list($tmp,$tmpCut,$tmpKey) = explode('.',$key,3); [373] => list($tmpCut1,$tmpCut2,$tmpCut3) = explode('#',$tmpCut,3); [374] => if($tmpCut1===NULL) $tmpCut1 = 50; [375] => if($tmpCut2===NULL) $tmpCut2 = 0; [376] => if($tmpCut3===NULL) $tmpCut3 = '…'; [377] => $res .= cut_string($this->vars[$tmpKey],$tmpCut1,$tmpCut2,$tmpCut3).implode('}', $line); [378] => continue; [379] => } [380] => // substr {#sub.2.3.key} [381] => elseif('sub.'==substr($key,1,4)) { [382] => list($tmp,$tmpSub1,$tmpSub2,$tmpKey) = explode('.',$key,4); [383] => $res .= substr($this->vars[$tmpKey],(int)$tmpSub1,(int)$tmpSub2).implode('}', $line); [384] => continue; [385] => } [386] => // explode(split) {#exp.0.-.key} 0번째, -으로 나누어서 [387] => elseif('exp.'==substr($key,1,4)) { [388] => $tmp = explode('.',$key,4); [389] => if(4==count($tmp)) { [390] => $tmp2 = explode($tmp[2],$this->vars[$tmp[3]]); [391] => $res .= $tmp2[$tmp[1]].implode('}', $line); [392] => } [393] => else $res .= implode('}', $line); [394] => continue; [395] => } [396] => } [397] => [398] => switch ($this->unknowns) [399] => { [400] => case "keep": [401] => $res .= '{'.$key; [402] => if (count ($line) > 0) [403] => { [404] => $res .= '}'; [405] => $res .= implode('}', $line); [406] => } [407] => break; [408] => [409] => case "remove": [410] => $res .= implode('', $line); [411] => break; [412] => [413] => case "remove_nonjs": [414] => if (!empty($key) && ((false === strpos($key, ' ')) && (false === strpos($key, "\n")) && (false === strpos($key, "\t")))) [415] => { [416] => $res .= implode('}', $line); [417] => } [418] => else [419] => { [420] => $res .= '{'.$key; [421] => if (count ($line) > 0) [422] => { [423] => $res .= '}'; [424] => $res .= implode('}', $line); [425] => } [426] => } [427] => break; [428] => [429] => case "comment": [430] => $res .= ''.implode('', $line); [431] => break; [432] => [433] => case "space": [434] => $res .= ' '.implode('', $line); [435] => break; [436] => [437] => } [438] => } [439] => } [440] => } [441] => [442] => return $res; [443] => } [444] => [445] => /** [446] => * check and set template root dir [447] => */ [448] => function set_root($root) [449] => { [450] => if (empty($root)) return; [451] => if (!is_dir($root)) [452] => { [453] => $this->error("phemplate::set_root(): 다음 드렉토리가 없습니다 : $root", 'warning'); [454] => return false; [455] => } [456] => [457] => $this->root = realpath($root).'/'; // By Sunmin 05/11/13 [458] => return true; [459] => } [460] => [461] => /** [462] => * what to do with unknown variables in template? [463] => * keep [464] => * remove [465] => * remove_nonjs [466] => * comment [467] => * space [468] => */ [469] => function set_unknowns($unk) [470] => { [471] => $this->unknowns = $unk; [472] => } [473] => [474] => /** [475] => * set default parameters for process() [476] => */ [477] => function set_params($params) [478] => { [479] => $this->parameters = $params; [480] => } [481] => [482] => /** [483] => * read file template into $vars [484] => * @param string $handle - name of handle for file contents [485] => * @param int $blocks - 1 for search, 2 for nested blocks [486] => * [487] => */ [488] => function set_file($handle, $filename = "", $blocks = false) [489] => { [490] => if ($filename == "") [491] => { [492] => $this->error("phemplate::set_file(): 파일이름이 빈값으로 넘어왔습니다 -$handle", 'fatal'); [493] => return false; [494] => } [495] => $this->vars[$handle] = $this->read_file($filename); [496] => if ($blocks & TPL_STRIP_UTF_HEADER) [497] => { [498] => $header = substr($this->vars[$handle], 0, 3); [499] => if ("\xEF\xBB\xBF" == $header) $this->vars[$handle] = substr($this->vars[$handle], 3); [500] => } [501] => if ($blocks) { $this->extract_blocks($handle, $blocks & TPL_BLOCKREC); } [502] => return true; [503] => [504] => } [505] => [506] => [507] => /** [508] => * set handle and value, [509] => * if value is array, all elements will be named: handle.key.subkey [510] => */ [511] => function set_var($var_name, $var_value) [512] => { [513] => if (is_array($var_value)) [514] => { [515] => foreach($var_value as $key=>$value) [516] => { [517] => $this->set_var($var_name . '.' . $key, $value); // recursion for array branches [518] => } [519] => } [520] => else // normal variable [521] => { [522] => $this->vars[$var_name] = $var_value; [523] => } [524] => } [525] => [526] => /** [527] => * tie value with variable [528] => * it's not possible to update array keys, just values [529] => */ [530] => function tie_var($var_name, &$var_value) [531] => { [532] => if (is_array($var_value)) [533] => { [534] => $list = array_keys($var_value); [535] => foreach($list as $key) [536] => { [537] => $this->tie_var($var_name . '.' . $key, $var_value[$key]); // recursion for array branches [538] => } [539] => } [540] => else // normal variable [541] => { [542] => $this->vars[$var_name] =& $var_value; [543] => } [544] => } [545] => [546] => /** [547] => * value of $handle [548] => * raises error if $handle undefined [549] => */ [550] => function get_var($handle) [551] => { [552] => if (!isset($this->vars[$handle])) { [553] => //$this->error("phemplate(): no such handle '$handle'", 'warning'); [554] => return null; // By Sunmin Park 04/05/17 [555] => } [556] => return $this->vars[$handle]; [557] => } [558] => [559] => /** [560] => * value of $handle, no error if no handle [561] => */ [562] => function get_var_silent($handle) [563] => { [564] => if (!isset($this->vars[$handle])) { $this->vars[$handle] = ''; return ''; } [565] => return $this->vars[$handle]; [566] => } [567] => [568] => /** [569] => * assign array to loop handle [570] => * @param string $loop_name - name for a loop [571] => * @param int $loop - loop data [572] => */ [573] => function set_loop($loop_name, $loop) [574] => { [575] => if (!$loop) $loop = 0; [576] => $this->loops[$loop_name] = $loop; [577] => } [578] => [579] => /** [580] => * tie array with loop [581] => */ [582] => function tie_loop($loop_name, &$loop) [583] => { [584] => if (!$loop) $loop = 0; [585] => $this->loops[$loop_name] =& $loop; [586] => } [587] => [588] => /** [589] => * extracts blocks from handle, and returns cleaned up version [590] => * [591] => * must be quite fast, because every found block is imediately taken out of string [592] => * [593] => * [594] => * @since 2001.10.31 works with nested blocks [js] [595] => * @since 2003.06.19 supports customized block syntax [js] [596] => * [597] => */ [598] => function extract_blocks($bl_handle, $recurse = false) [599] => { [600] => [601] => $str = $this->get_var($bl_handle); [602] => if (!$str) return $str; [603] => $bl_start = 0; [604] => [605] => list($bll, $blr) = explode('|', $this->block_start_string); [606] => $strlen = strlen($bll); [607] => [608] => [609] => // find them and clean from parent handle [610] => while(is_long($bl_start = strpos($str, $bll, $bl_start))) [611] => { [612] => $pos = $bl_start + $strlen; [613] => [614] => $endpos = strpos($str, $blr, $pos); [615] => $handle = substr($str, $pos, $endpos-$pos); [616] => [617] => $tag = $bll.$handle.$blr; [618] => $endtag = str_replace('|', $handle, $this->block_end_string); [619] => [620] => $start_pos = $bl_start + strlen($tag); [621] => $end_pos = strpos($str, $endtag, $bl_start); [622] => if (!$end_pos) { $this->error("스킨오류 : </block name=\"$handle\">이 없음", 'fatal'); } [623] => $bl_end = $end_pos + strlen($endtag); [624] => [625] => $block_code = substr($str, $start_pos, $end_pos-$start_pos); [626] => [627] => $this->set_var($handle, $block_code); [628] => [629] => $part1 = substr($str, 0, $bl_start); [630] => $part2 = substr($str, $bl_end, strlen($str)); [631] => [632] => $str = $part1 . $part2; [633] => [634] => if ($recurse) { $this->extract_blocks($handle, 1); } [635] => [636] => } [637] => [638] => $this->set_var($bl_handle, $str); [639] => [640] => } [641] => [642] => [643] => /** [644] => * search for tags in $handle [645] => * be carefull with paths [646] => */ [647] => function include_files($handle) [648] => { [649] => $str = $this->get_var($handle); [650] => [651] => while(is_long($pos = strpos($str, '', $pos); [655] => $filename = substr($str, $pos, $endpos-$pos); [656] => $tag = ''; [657] => [658] => [659] => $include = $this->read_file($filename); [660] => [661] => $str = str_replace($tag, $include, $str); [662] => } [663] => [664] => return $str; [665] => } [666] => [667] => [668] => /** [669] => * searches for all set loops in $handle, returns text of $handle with parsed loops [670] => * @param bool $noloop - must be true, if you want noloop statement [671] => * @return string [672] => */ [673] => function parse_loops($handle, $noloop = false) [674] => { [675] => $str = $this->get_var($handle); [676] => [677] => reset($this->loops); [678] => [679] => while ( list($loop_name, $loop_ar) = each($this->loops) ) [680] => { [681] => [682] => $start_tag = strpos($str, ''); [683] => [684] => $start_pos = $start_tag + strlen(''); [685] => if (!$start_pos) continue; [686] => $end_pos = strpos($str, ''); [687] => [688] => $loop_code = substr($str, $start_pos, $end_pos-$start_pos); [689] => $org_loop_code = $loop_code; [690] => [691] => $start_tag = substr($str, $start_tag, strlen('')); [692] => $end_tag = substr($str, $end_pos, strlen('')); [693] => [694] => if($loop_code != ''){ [695] => [696] => $new_code = ''; [697] => [698] => // clean if ($noloop & TPL_NOLOOP) [700] => { [701] => [702] => $nl_start_tag = strpos($loop_code, ''); [703] => $nl_start_pos = $nl_start_tag + strlen(''); [704] => [705] => [706] => if ($nl_start_pos) [707] => { [708] => [709] => $nl_end_pos = strpos($loop_code, ''); [710] => [711] => $noloop_code = substr($loop_code, $nl_start_pos, $nl_end_pos - $nl_start_pos); [712] => [713] => [714] => $nl_start_tag = substr($loop_code, $nl_start_tag, strlen('')); [715] => $nl_end_tag = substr($loop_code, $nl_end_pos, strlen('')); [716] => $loop_code = str_replace($nl_start_tag.$noloop_code.$nl_end_tag, '', $loop_code); [717] => } [718] => [719] => } [720] => [721] => if (is_array($loop_ar)) [722] => { [723] => [724] => if ($noloop & TPL_LOOP_INNER_PARSED) [725] => { [726] => for($i = 0; isset($loop_ar[$i]); $i++) [727] => [728] => { [729] => $temp_code = $loop_code; [730] => // rememeber loop variables [731] => [732] => $array_keys = array_keys($loop_ar[$i]); [733] => $this->set_var($loop_name, $loop_ar[$i]); [734] => if ($noloop & TPL_LOOP_INNER_OPTIONAL) $temp_code = $this->optional($loop_code); [735] => $temp_code = $this->parse($temp_code); [736] => $new_code .= $temp_code; [737] => [738] => // cleanup loop variables for next generation [739] => foreach ($array_keys as $key) unset($this->vars[$loop_name.'.'.$key]); [740] => [741] => } // for loop [742] => } [743] => else [744] => { [745] => // repeat for every row in array [746] => // for (reset($loop_ar); $row = current($loop_ar); next($loop_ar)) [747] => $ar_keys = array_keys($loop_ar); [748] => $ar_size = count($ar_keys); [749] => for($i = 0; ($i< $ar_size); $i++) [750] => { [751] => $temp_code = $loop_code; [752] => [753] => foreach( $loop_ar[$ar_keys[$i]] as $k=>$v) [754] => { [755] => $temp_code = str_replace( '{'. $loop_name. '.' .$k. '}', $v, $temp_code); [756] => } [757] => $new_code .= $temp_code; [758] => } [759] => } [760] => } elseif ($noloop & TPL_NOLOOP) [761] => { [762] => $new_code = $noloop_code; [763] => } [764] => [765] => [766] => $str = str_replace($start_tag.$org_loop_code.$end_tag, $new_code, $str); [767] => } // if loop code [768] => [769] => } // repeat for loop names [770] => [771] => return $str; [772] => } [773] => [774] => [775] => /** [776] => * process left variables [777] => * @deprecated parse() now handles unknown variables [778] => */ [779] => function finish($str) [780] => { [781] => switch ($this->unknowns) [782] => { [783] => case "keep": [784] => break; [785] => [786] => case "remove": [787] => $str = preg_replace('/{[^ \t\r\n}]+}/', "", $str); [788] => break; [789] => [790] => case "comment": [791] => $str = preg_replace('/{([^ \t\r\n}]+)}/', "", $str); [792] => break; [793] => [794] => case "space": [795] => $str = preg_replace('/{([^ \t\r\n}]+)}/', " ", $str); [796] => break; [797] => [798] => } [799] => [800] => return $str; [801] => } [802] => [803] => /** [804] => * search for optional tag [805] => * @param string $str text [806] => * @return string [807] => */ [808] => function optional($str) [809] => { [810] => $bl_start = 0; [811] => [812] => // extract and clean them from parent handle [813] => while(is_long($bl_start = strpos($str, '', $pos); [818] => $varname = substr($str, $pos, $endpos-$pos); [819] => [820] => $tag = ''; [821] => $endtag = ''; [822] => [823] => $end_pos = strpos($str, $endtag, $bl_start); [824] => if (!$end_pos) { $this->error("스킨오류 <opt name=\"$varname\">가 없음", 'fatal'); } [825] => [826] => $bl_end = $end_pos + strlen($endtag); [827] => [828] => [829] => $part1 = substr($str, 0, $bl_start); [830] => $part2 = substr($str, $bl_end, strlen($str)); [831] => [832] => // if .. by Sunmin Park [833] => if($varname[0]=="!") [834] => { [835] => $varname = substr($varname, 1); [836] => $flag = true; [837] => } [838] => else $flag = false; [839] => [840] => // .. By Sunmin Park [841] => if(strpos($varname,'=')) { [842] => list($varname,$varname_value) = explode('=',$varname,2); [843] => [844] => $value = $this->get_var_silent($varname); [845] => //echo " $value == $varname_value ";exit; [846] => if($value == $varname_value) { [847] => $flag = !$flag; [848] => } [849] => } [850] => else { [851] => $value = $this->get_var_silent($varname); [852] => [853] => //if ($value || $value === 0 || $value === '0') [854] => if ($value and $value !== 'N') [855] => { [856] => $flag = !$flag; [857] => } [858] => } [859] => [860] => if($flag) [861] => { [862] => $start_pos = $bl_start + strlen($tag); [863] => [864] => $block_code = substr($str, $start_pos, $end_pos-$start_pos); [865] => [866] => $str = $part1 . $this->parse($block_code) . $part2; [867] => } [868] => else [869] => { [870] => $str = $part1 . $part2; [871] => } [872] => } [873] => [874] => return $str; [875] => } [876] => [877] => /** [878] => * does everything: loops, includes, variables, concatenation [879] => * if $loop is 0 (not false, but 0) default parameters are used [880] => * thanks ShiVAs for idea to have $loop as parameters. [881] => * [882] => * @param $loop - loop, noloop or all parameters ored. [883] => * @param $append - append processed stuff to target, else $target is overwritten [884] => * @return string [885] => */ [886] => function process($target, $handle, $loop = false, $include = false, $append = false, $finish = false, $optional = false) [887] => { [888] => if ($loop === 0) $loop = $this->parameters; [889] => [890] => $noloop = false; [891] => $parsedloop = false; [892] => $loopopt = false; [893] => if ($loop > 2) [894] => { [895] => $noloop = $loop & TPL_NOLOOP; [896] => $include = $loop & TPL_INCLUDE; [897] => $append = $loop & TPL_APPEND; [898] => $finish = $loop & TPL_FINISH; [899] => $optional = $loop & TPL_OPTIONAL; [900] => $parsedloop = $loop & TPL_LOOP_INNER_PARSED; [901] => $loopopt = $loop & TPL_LOOP_INNER_OPTIONAL; [902] => } [903] => else [904] => { [905] => $noloop = $loop & TPL_NOLOOP; [906] => } [907] => [908] => if ($append) { [909] => if (isset($this->vars[$target])) { [910] => $app = $this->get_var($target); // preserve old info [911] => $this->set_var($target.'.count', $tmp=$this->get_var($target.'.count')+1); // by sunmin (append count) [912] => $this->set_var($target.'.countodd', $tmp%2 ); // by sunmin (append count) [913] => } [914] => else { [915] => $app = ''; [916] => $this->set_var($target.'.count', 1); // by sunmin (append count) [917] => $this->set_var($target.'.countodd', 1); // by sunmin (append count) [918] => } [919] => } [920] => [921] => $this->set_var($target, $this->get_var($handle)); // copy contents [922] => [923] => if ($include) { $this->set_var($target, $this->include_files($target)); } [924] => [925] => [926] => if ($noloop) { $this->set_var($target, $this->parse_loops($target, TPL_NOLOOP | $loopopt | $parsedloop)); } [927] => elseif ($loop) { $this->set_var($target, $this->parse_loops($target, $loopopt | $parsedloop)); } [928] => [929] => if ($optional) { $this->set_var($target, $this->optional($this->get_var_silent($target))); } [930] => [931] => if ($append) { $this->set_var($target, $app . $this->parse($this->get_var_silent($target))); } [932] => else { $this->set_var($target, $this->parse($this->get_var($target))); } [933] => [934] => if ($finish) { $this->set_var($target, $this->finish($this->get_var($target))); } [935] => [936] => return $this->get_var($target); [937] => } [938] => [939] => [940] => /** [941] => * spits out file contents [942] => * @access private [943] => */ [944] => function read_file($file) [945] => { [946] => $filename = $this->root . $file; [947] => [948] => if (!file_exists($filename)) [949] => { [950] => $this->error("phemplate::read_file(): 파일이 없음 - $filename", 'fatal'); [951] => return ''; [952] => } [953] => [954] => $tmp = false; [955] => [956] => $filesize = filesize($filename); [957] => if ($filesize) [958] => { [959] => $tmp = fread($fp = fopen($filename, 'r'), $filesize); [960] => fclose($fp); [961] => [962] => $this->read_files[]= $filename; [963] => } [964] => return $tmp; [965] => } [966] => [967] => /** [968] => * free mem used by loop [969] => */ [970] => function drop_loop($loop_handle) [971] => { [972] => if (isset($this->loops[$loop_handle])) unset($this->loops[$loop_handle]); [973] => } [974] => [975] => [976] => /** [977] => * free mem used by var [978] => */ [979] => function drop_var($handle,$var_value='') [980] => { [981] => if (is_array($var_value)) { // by Sunmin Park [982] => foreach($var_value as $key=>$value) [983] => $this->drop_var($handle.'.'.$key,$value); // recursion for array branches [984] => } [985] => elseif (isset($this->vars[$handle])) unset($this->vars[$handle]); [986] => } [987] => [988] => /** [989] => * set error handler [990] => */ [991] => function set_error_handler(&$eh) [992] => { [993] => $this->error_handler =& $eh; [994] => } [995] => [996] => /** [997] => * change block syntax [998] => */ [999] => function set_block_syntax($start, $end) [1000] => { [1001] => if (!strpos($start, '|')) $this->error("phemplate::set_block_syntax(): no '|' in start tag", 'fatal'); [1002] => if (!strpos($end, '|')) $this->error("phemplate::set_block_syntax(): no '|' in end tag", 'fatal'); [1003] => $this->block_start_string = $start; [1004] => $this->block_end_string = $end; [1005] => } [1006] => [1007] => /** [1008] => * error report [1009] => */ [1010] => function error( $msg, $level = '') [1011] => { [1012] => if (isset($this->error_handler)) [1013] => { [1014] => $lvl = E_USER_WARNING; [1015] => if ('fatal' == $level) $lvl = E_USER_ERROR; [1016] => $this->error_handler->report($lvl, $msg); [1017] => } [1018] => else [1019] => { [1020] => echo "\n
$level: $msg
\n"; [1021] => if ('fatal' == $level) { exit; } [1022] => } [1023] => } [1024] => [1025] => /** [1026] => * SitePHPbasic 반복하는 echoHtml [1027] => * By Sunmin Park 06/07/23 [1028] => */ [1029] => function echoHtml( &$dbinfo, &$SITE, $thisUrl='' ) { [1030] => $val='\\1'.$thisUrl.'skin/'.$dbinfo['skin'].'/images/'; [1031] => // - 사이트 템플릿 읽어오기 [1032] => if(ereg('^(ht|h|t)$',$dbinfo['html_type'])) { [1033] => $HEADER = array ('html_skin'=>$dbinfo['html_skin']); [1034] => @include($SITE['html_path'].'skin.php'); // retrun $aBody[0],$aBody[1] [1035] => } [1036] => [1037] => $html = ''; [1038] => switch($dbinfo['html_type']) { [1039] => case 'ht': [1040] => $html = $aBody[0]; [1041] => $html .= $dbinfo['html_head']; [1042] => $html .= ereg_replace('([="\'(])images/',$val,$this->process('', 'html',TPL_OPTIONAL)); [1043] => $html .= $dbinfo['html_tail']; [1044] => $html .= $aBody[1]; [1045] => break; [1046] => case 'h': [1047] => $html .= $aBody[0] ; [1048] => $html .= $dbinfo['html_head']; [1049] => $html .= ereg_replace('([="\'(])images/',$val,$this->process('', 'html',TPL_OPTIONAL)); [1050] => $html .= $dbinfo['html_tail']; [1051] => break; [1052] => case 't': [1053] => $html .= $dbinfo['html_head']; [1054] => $html .= ereg_replace('([="\'(])images/',$val,$this->process('', 'html',TPL_OPTIONAL)); [1055] => $html .= $dbinfo['html_tail'] ; [1056] => $html .= $aBody[1]; [1057] => break; [1058] => case 'no': [1059] => $html .= ereg_replace('([="\'(])images/',$val,$this->process('', 'html',TPL_OPTIONAL)); [1060] => break; [1061] => default: [1062] => $html .= $dbinfo['html_head']; [1063] => $html .= ereg_replace('([="\'(])images/',$val,$this->process('', 'html',TPL_OPTIONAL)); [1064] => $html .= $dbinfo['html_tail']; [1065] => } // end switch [1066] => [1067] => /* [1068] => if($_GET['utf8']=='euc-kr') { [1069] => // iconv 버그로 인해서 "\n"로 나눔 [1070] => $aA =explode("\n",$html); [1071] => $html =''; [1072] => foreach($aA as $v) $html .= iconv("euc-kr", "UTF-8",$v); [1073] => } [1074] => */ [1075] => [1076] => if($_GET['html_return']) $_GET['html']=$html; [1077] => else echo $html; [1078] => [1079] => // debug 출력 [1080] => if(defined('GET_DEBUG_2') and GET_DEBUG_2) { [1081] => echo "
"; [1082] => echo "skin : $dbinfo[skin], html_type: $dbinfo[html_type], html_skin: $dbinfo[html_skin]
thisUrl:$thisUrl "; [1083] => if('/spb3/sboard3/'==$thisUrl) { [1084] => echo " [게시판수정]"; [1085] => if($_GET['cateuid']) { [1086] => echo " [카테고리수정]"; [1087] => } [1088] => } [1089] => if($dbinfo['table']) { [1090] => echo " [$dbinfo[table]]"; [1091] => } [1092] => echo "
"; [1093] => if(count($this->read_files)) { [1094] => foreach($this->read_files as $filepath) { [1095] => if(strpos($filepath,$_SERVER['DOCUMENT_ROOT'])!==false) { [1096] => $url = substr($filepath,strlen($_SERVER['DOCUMENT_ROOT'])); [1097] => echo "skin file : $url
"; [1098] => } [1099] => else echo "skin file : $filepath
"; [1100] => } [1101] => } [1102] => //echo '
dbinfo ';var_export($dbinfo);

                                            [1103] => 			//echo '
'; [1104] => echo '
'; [1105] => } [1106] => } [1107] => } [1108] => ?> ) [new] => [ovalue] => // 05/01/25 박선민 828L drop_var() add recursion for array branches [oindex] => 4 [nkeys] => ) ) ) [1] => Array ( [file] => /wecan/cc/cc.sdong.kr/spb3/sadmin/util/svn/spb3_diff.php [line] => 122 [function] => array_keys [args] => Array ( [0] => [1] => // 05/01/25 박선민 828L drop_var() add recursion for array branches ) ) [2] => Array ( [file] => /wecan/cc/cc.sdong.kr/spb3/sadmin/util/svn/spb3_diff.php [line] => 142 [function] => doDiff [class] => diff [object] => diff Object ( [changes] => Array ( ) [diff] => Array ( ) [linepadding] => 2 ) [type] => -> [args] => Array ( [0] => /wecan/cc/cc.sdong.kr/spb3/sinc/lib/class_phemplate.php [1] => ) ) [3] => Array ( [file] => /wecan/cc/cc.sdong.kr/spb3/sadmin/util/svn/spb3_diff.php [line] => 197 [function] => diffWrap [class] => diff [object] => diff Object ( [changes] => Array ( ) [diff] => Array ( ) [linepadding] => 2 ) [type] => -> [args] => Array ( [0] => /wecan/cc/cc.sdong.kr/spb3/sinc/lib/class_phemplate.php [1] => ) ) [4] => Array ( [file] => /wecan/cc/cc.sdong.kr/spb3/sadmin/util/svn/spb3_diff.php [line] => 92 [function] => inline [class] => diff [object] => diff Object ( [changes] => Array ( ) [diff] => Array ( ) [linepadding] => 2 ) [type] => -> [args] => Array ( [0] => /wecan/cc/cc.sdong.kr/spb3/sinc/lib/class_phemplate.php [1] => [2] => 2 ) ) ) [key] => 4 [value] => Array ( [file] => /wecan/cc/cc.sdong.kr/spb3/sadmin/util/svn/spb3_diff.php [line] => 92 [function] => inline [class] => diff [object] => diff Object ( [changes] => Array ( ) [diff] => Array ( ) [linepadding] => 2 ) [type] => -> [args] => Array ( [0] => /wecan/cc/cc.sdong.kr/spb3/sinc/lib/class_phemplate.php [1] => [2] => 2 ) ) )
sitePHPbasic 디버그 모드 : WARNING
[2] Invalid argument supplied for foreach()
Line : 123 (file:/wecan/cc/cc.sdong.kr/spb3/sadmin/util/svn/spb3_diff.php)
- 디버그 추적(debug_backtrace)
#0 spb_error_handler() 함수사용, line(123), /wecan/cc/cc.sdong.kr/spb3/sadmin/util/svn/spb3_diff.php
#1 doDiff() 함수사용, line(142), /wecan/cc/cc.sdong.kr/spb3/sadmin/util/svn/spb3_diff.php
#2 diffWrap() 함수사용, line(197), /wecan/cc/cc.sdong.kr/spb3/sadmin/util/svn/spb3_diff.php
#3 inline() 함수사용, line(92), /wecan/cc/cc.sdong.kr/spb3/sadmin/util/svn/spb3_diff.php




사용변수들 ...
$_GET = Array ( [md5_path] => /spb3/sinc/lib/class_phemplate.php ) $_POST = Array ( ) $_COOKIE = Array ( ) Array ( [errno] => 2 [errstr] => Invalid argument supplied for foreach() [errfile] => /wecan/cc/cc.sdong.kr/spb3/sadmin/util/svn/spb3_diff.php [errline] => 123 [arr] => Array ( [0] => Array ( [file] => /wecan/cc/cc.sdong.kr/spb3/sadmin/util/svn/spb3_diff.php [line] => 123 [function] => spb_error_handler [args] => Array ( [0] => 2 [1] => Invalid argument supplied for foreach() [2] => /wecan/cc/cc.sdong.kr/spb3/sadmin/util/svn/spb3_diff.php [3] => 123 [4] => Array ( [old] => Array ( [0] => // $Id: class_phemplate.php 13 2010-08-24 08:28:50Z sitehis $ [2] => // 04/05/17 박선민 340L get_var() chanage to same get_var_silent() [3] => // 04/05/17 박선민 696L optional() add and change etc.. [4] => // 05/01/25 박선민 828L drop_var() add recursion for array branches [5] => // 05/11/20 박선민 echoHtml()로 반복하는 sitePHPbasic 마무리 부분 함수로 [6] => // 07/03/18 박선민 {!e.abc} 인경우 urlencoding 등의 기능 추가 [7] => // 07/08/14 박선민 {#widget.???} 윗젯 include 기능 추가 [8] => // 07/09/16 박선민 {#content.keyword} spb3_content 테이블의 keyword에 대한 content가져와서 넣는 기능 추가 [9] => // 08/06/14 박선민 $_GET[html_return] 기능 추가 [10] => // 08/06/28 박선민 831L optional() change 값이 'N'이여도 false되게 [11] => // 08/07/13 박선민 716L // cut_string {#cut.50#0#….key} 기능 추가 [12] => // 08/07/29 박선민 546L // parse() ... IF문 기능 추가 [13] => // 08/10/06 박선민 {#sub.2.3.???} 기능 추가 [14] => // 08/11/08 박선민 #content.??? 기능 개선 [15] => // 08/11/29 박선민 bugfix - don't use &$this [16] => // 09/01/04 박선민 {#widget2.???} 윗젯2 기능 추가(php파일위치에 widget2_???.php를 읽어서 함수 실행 [17] => // 09/02/04 박선민 {!N.list.number} 기능 추가 [18] => // 09/02/06 박선민 GET_DEBUG_2 기능 추가 [19] => // 09/02/25 박선민 {#exp.0.-.key}, server.server.HTTP_REFERER 추가 [20] => // 09/03/11 박선민 {!A.str} javascript에서 변수넘길때 큰따옴표 오류 해결용 [21] => // 09/05/08 박선민 bugfix - GET_DEBUG_2 false였을 때 오류 [22] => // 09/05/31 박선민 {!B.str} table, excel등에서 빈값은  로 변환하여 리턴하도록 [23] => // 09/05/31 박선민 {!?.str} 링크에 ?가 없으면 ?를 붙여주도록 [24] => // 09/07/28 박선민 {!X.name} : xmlspecialchars 변환 기능 추가 [25] => //---------------------------------------------------------------------------// [26] => // author: pukomuko [27] => // date: 2001.03.15 [28] => // web: http://pukomuko.esu.lt [29] => // http://sourceforge.net/projects/phemplate [30] => // info: template engine [31] => //---------------------------------------------------------------------------// [32] => // copyleft license [33] => // [34] => // this software is provided 'as-is', without any express or implied [35] => // warranty. in no event will the authors be held liable for any damages [36] => // arising from the use of this software. [37] => // [38] => // permission is granted to anyone to use this software for any purpose, [39] => // including commercial applications, and to alter it and redistribute it [40] => // freely, subject to the following restrictions: [41] => // [42] => // 1. the origin of this software must not be misrepresented; [43] => // you must not claim that you wrote the original software. [44] => // if you use this software in a product, an acknowledgment [45] => // in the product documentation would be appreciated but is not required. [46] => // [47] => // 2. altered source versions must be plainly marked as such, [48] => // and must not be misrepresented as being the original software. [49] => // [50] => // 3. mail about the fact of using this class in production [51] => // would be very appreciated. [52] => // [53] => // 4. this notice may not be removed or altered from any source distribution. [54] => // [55] => //---------------------------------------------------------------------------// [56] => // changes: [57] => // [58] => // 2004.04.21 [59] => // - warining on empty file [60] => // * v1.10.1 [61] => [62] => /** [63] => */ [64] => define('TPL_LOOP', 1); [65] => define('TPL_NOLOOP', 2); [66] => define('TPL_INCLUDE', 4); [67] => define('TPL_APPEND', 8); [68] => define('TPL_FINISH', 16); [69] => define('TPL_OPTIONAL', 32); [70] => define('TPL_LOOP_INNER_PARSED',64); [71] => define('TPL_LOOP_INNER_OPTIONAL', 128); [72] => [73] => define('TPL_PARSEDLOOP', TPL_LOOP | TPL_LOOP_INNER_PARSED); [74] => define('TPL_OPTLOOP', TPL_PARSEDLOOP | TPL_LOOP_INNER_OPTIONAL); [75] => [76] => [77] => define('TPL_BLOCK', 1); [78] => define('TPL_BLOCKREC', 2); [79] => define('TPL_STRIP_UTF_HEADER', 4); [80] => [81] => class phemplate [82] => { [83] => /** [84] => * 현재 클래스가 있는 드렉토리 By Sunmin [85] => */ [86] => var $widgetPath =''; [87] => [88] => var $read_files = array(); [89] => [90] => /** [91] => * spb3_content에서 읽어온 것을 캐쉬 [92] => */ [93] => var $spb3_content = array(); [94] => [95] => [96] => /** [97] => * variables and blocks [98] => */ [99] => var $vars = array(); [100] => [101] => /** [102] => * loops container [103] => */ [104] => var $loops = array(); [105] => [106] => /** [107] => * dir of template files [108] => */ [109] => var $root = ''; [110] => [111] => /** [112] => * what to do with unknown variables in template? [113] => */ [114] => var $unknowns = 'keep'; [115] => [116] => /** [117] => * default parameters for process() loop, append, finish [118] => */ [119] => var $parameters = 0; [120] => [121] => [122] => /** [123] => * object having method report($level, $msg) [124] => * you can catch error messages from template. [125] => */ [126] => var $error_handler = null; [127] => [128] => [129] => [130] => /** [131] => * start tag for block [132] => */ [133] => var $block_start_string = ''; [134] => [135] => /** [136] => * end tag for block [137] => */ [138] => var $block_end_string = ''; [139] => [140] => /** [141] => * constructor [142] => * $unknows를 keep에서 remove_nonjs로 변경함 by Sunmin Park [143] => */ [144] => function phemplate( $root_dir = '', $unknowns = 'remove_nonjs', $params = 0) [145] => { [146] => // widget, widget2 path [147] => $this->widgetPath = dirname(dirname(__FILE__)).'/widget/'; // By Sunmin [148] => if($this->set_root($root_dir)) [149] => $this->widget2Path = dirname(dirname($this->root)).'/'; // By Sunmin [150] => $this->set_unknowns($unknowns); [151] => $this->set_params($params); [152] => [153] => [154] => [155] => // 기본 set_var by Sunmin [156] => $this->tie_var('SITE' ,$GLOBALS['SITE']); // $SITE 전역변수 [157] => $this->tie_var('get' ,$_GET); [158] => $this->set_var('braces' ,'{'); // 중괄호{braces} 표현 [159] => $this->set_var('nowtime',time()); [160] => [161] => $this->tie_var('session.seUid' ,$_SESSION['seUid']); // 로그인 uid [162] => $this->tie_var('session.seUserid' ,$_SESSION['seUserid']); // 로그인 userid [163] => $this->tie_var('session.seName' ,$_SESSION['seName']); // 로그인 이름 [164] => $this->tie_var('session.seNickname' ,$_SESSION['seNickname']); // 로그인 별명 [165] => $this->tie_var('session.seEmail' ,$_SESSION['seEmail']); [166] => $this->tie_var('session.sePoint' ,$_SESSION['sePoint']); [167] => $this->tie_var('session.seCoupon' ,$_SESSION['seCoupon']); [168] => $this->tie_var('session.sePriv' ,$_SESSION['sePriv']); [169] => [170] => $this->set_var('server.HTTP_HOST' ,$_SERVER['HTTP_HOST']); [171] => $this->set_var('server.HTTP_REFERER',$_SERVER['HTTP_REFERER']); [172] => $this->set_var('server.QUERY_STRING' ,$_SERVER['QUERY_STRING']); [173] => $this->set_var('server.REQUEST_URI' ,$_SERVER['REQUEST_URI']); [174] => $this->set_var('server.PHP_SELF' ,$_SERVER['PHP_SELF']); [175] => } [176] => [177] => /** [178] => substitute text and returns parsed string [179] => @author ZaZa (Sergej Kurakin) 2003.05.05 21:52 [180] => */ [181] => function parse($string) [182] => { [183] => $str = explode('{', $string); [184] => [185] => $res = ''; [186] => [187] => for ($i = 0; isset($str[$i]); $i++) [188] => { [189] => $line = explode('}', $str[$i]); [190] => if ($i === 0) [191] => { [192] => $res .= $line[0]; [193] => } [194] => else [195] => { [196] => $key = $line[0]; [197] => unset($line[0]); [198] => [199] => if ( $key && isset($this->vars[$key]) ) [200] => { [201] => $res .= $this->vars[$key].implode('}', $line); [202] => } [203] => else [204] => { [205] => // {!d.list.rdate} 등 By Sunmin [206] => if($key[0]=='!') { // and isset($this->vars[substr($key,3)])) { [207] => switch(substr($key,1,2)) { [208] => /** [209] => ** 대소문자 구분함 [210] => {!B.name} : 값이 없으면   [211] => {!b.name} : 문장에서 엔터를
로 변환함 [212] => {!S.name} : 문장에서 html 테그를 모두 제거하고, 엔터는
로 변환함 [213] => [214] => {!a.name} : '\' addslashes 삽입 [215] => {!A.name} : javascript에서 변수넘길때 funcname('{!A.str}') [216] => {!s.name} : addslashes된 것을 stripcslashes함 [217] => {!?.name} : 문자열 중간 혹은 끝에 ?가 없으면 맨뒤에 ?를 붙여줌 [218] => [219] => {!h.name} : HTML특수문자로 변환( 큰따옴표도 변환 ) [220] => {!H.name} : HTML특수문자로 변환( 큰따옴표는 그대로 나둠) [221] => {!x.name} : stripcslashes함 하고 HTML특수문자로 변환( 큰따옴표도 변환) [222] => {!X.name} : xmlspecialchars 변환 [223] => [224] => {!e.url} : URL ENCODE [225] => [226] => {!n.price} : 숫자에 콤마 추가(단, 값이 없으면 무조건 '0' 리턴) [227] => {!N.price} : 숫자에 콤마 추가(단, ''값이면 빈값으로 리턴 [228] => [229] => {!D.rdate} : 숫자날짜를 YYYY-MM-DD로 변환 (연도가 4자리) [230] => {!d.rdate} : 숫자날짜를 YY-MM-DD로 변환 (연도가 2자리) [231] => {!T.rdate} : 숫자날짜를 YY-MM-DD H:i:s로 변환 (ex, 2009-01-01 23:59:55) [232] => {!t.rdate} : 숫자날짜를 시간인 H:i:s로 변환 (ex, 23:59:55) [233] => {!g.rdate} : 숫자날짜를 국제표준 한국시간으로 'D, j M Y G:i:s +0900' [234] => **/ [235] => case 'B.': [236] => if(empty($this->vars[substr($key,3)]) and $this->vars[substr($key,3)]!="0") [237] => $res .= ' '.implode('}', $line); [238] => else $res .= $this->vars[substr($key,3)].implode('}', $line); [239] => continue 2; [240] => break; [241] => case 'b.': [242] => $res .= nl2br($this->vars[substr($key,3)]).implode('}', $line); [243] => continue 2; [244] => break; [245] => case 'S.': // strip_tags(),
tag취환 [246] => $res .= ereg_replace("(\r\n|\n|\r)", '
',strip_tags($this->vars[substr($key,3)])).implode('}', $line); [247] => continue 2; [248] => break; [249] => case 'a.': [250] => $res .= addslashes($this->vars[substr($key,3)]).implode('}', $line); [251] => continue 2; [252] => break; [253] => case 'A.': [254] => $res .= str_replace('\\"','"',addslashes($this->vars[substr($key,3)])).implode('}', $line); [255] => continue 2; [256] => break; [257] => case 's.': [258] => $res .= stripcslashes($this->vars[substr($key,3)]).implode('}', $line); [259] => continue 2; [260] => break; [261] => case '?.': [262] => if(false===strpos($this->vars[substr($key,3)],'?')) [263] => $res .= $this->vars[substr($key,3)].'?'.implode('}', $line); [264] => else [265] => $res .= $this->vars[substr($key,3)].implode('}', $line); [266] => continue 2; [267] => break; [268] => case 'h.': [269] => $res .= htmlspecialchars($this->vars[substr($key,3)],ENT_QUOTES).implode('}', $line); [270] => continue 2; [271] => break; [272] => case 'H.': [273] => $res .= htmlspecialchars($this->vars[substr($key,3)],ENT_NOQUOTES).implode('}', $line); [274] => continue 2; [275] => break; [276] => case 'x.': [277] => $res .= htmlspecialchars(stripcslashes($this->vars[substr($key,3)]),ENT_QUOTES).implode('}', $line); [278] => continue 2; [279] => break; [280] => case 'X.': [281] => $res .= str_replace(''', ''', htmlspecialchars($this->vars[substr($key,3)], ENT_QUOTES)).implode('}', $line); [282] => continue 2; [283] => break; [284] => case 'e.': [285] => $res .= urlencode($this->vars[substr($key,3)]).implode('}', $line); [286] => continue 2; [287] => break; [288] => case 'n.': [289] => $res .= number_format((int)$this->vars[substr($key,3)]).implode('}', $line); [290] => continue 2; [291] => break; [292] => case 'N.': [293] => if($this->vars[substr($key,3)] or $this->vars[substr($key,3)]==='0' or $this->vars[substr($key,3)]===0) [294] => $res .= number_format($this->vars[substr($key,3)]).implode('}', $line); [295] => else $res .= implode('}', $line); [296] => continue 2; [297] => break; [298] => case 'D.': [299] => if($this->vars[substr($key,3)]) [300] => $res .= date('Y-m-d',$this->vars[substr($key,3)]).implode('}', $line); [301] => else $res .= implode('}', $line); [302] => continue 2; [303] => break; [304] => case 'd.': [305] => if($this->vars[substr($key,3)]) [306] => $res .= date('y-m-d',$this->vars[substr($key,3)]).implode('}', $line); [307] => else $res .= implode('}', $line); [308] => continue 2; [309] => break; [310] => case 'T.': [311] => if($this->vars[substr($key,3)]) [312] => $res .= date('y-m-d H:i:s',$this->vars[substr($key,3)]).implode('}', $line); [313] => else $res .= implode('}', $line); [314] => continue 2; [315] => break; [316] => case 't.': [317] => if($this->vars[substr($key,3)]) [318] => $res .= date('H:i:s',$this->vars[substr($key,3)]).implode('}', $line); [319] => else $res .= implode('}', $line); [320] => continue 2; [321] => break; [322] => case 'g.': [323] => if($this->vars[substr($key,3)]) [324] => $res .= date('D, j M Y G:i:s +0900',$this->vars[substr($key,3)]).implode('}', $line); [325] => else $res .= implode('}', $line); [326] => continue 2; [327] => break; [328] => } [329] => } [330] => [331] => if($key[0]=='#') { [332] => // /spb3/sinc/widget/???.php By Sunmin [333] => if('widget.'==substr($key,1,7)) { [334] => $tmpWidget2 = substr($key,8); [335] => list($tmpWidget,$tmpKey) = explode('.',$tmpWidget2,2); [336] => if(eregi('^[-_a-z0-9]+$',$tmpWidget) and is_file($this->widgetPath . $tmpWidget . '/index.php')) { [337] => @include_once($this->widgetPath .$tmpWidget . '/index.php'); [338] => $func = 'widget_'.$tmpWidget; [339] => $res .= @$func($this,$tmpKey) . implode('}', $line); [340] => continue; [341] => } [342] => } [343] => elseif('widget2.'==substr($key,1,8)) { [344] => $tmpWidget2 = substr($key,9); [345] => list($tmpWidget,$tmpKey) = explode('.',$tmpWidget2,2); [346] => if(eregi('^[-_a-z0-9]+$',$tmpWidget) and is_file($this->widget2Path . 'widget2_'.$tmpWidget . '.php')) { [347] => @include_once($this->widget2Path . 'widget2_'.$tmpWidget . '.php'); [348] => $func = 'widget2_'.$tmpWidget; [349] => $res .= @$func($this,$tmpKey) . implode('}', $line); [350] => continue; [351] => } [352] => }elseif('include.'==substr($key,1,8)) { [353] => $tmpFilename = substr($key,9); [354] => if(is_file($this->root.'/include_'.$tmpFilename.'.html')) { [355] => $res .= @file_get_contents($this->root.'include_'.$tmpFilename.'.html') . implode('}', $line); [356] => } [357] => else $res .= implode('}', $line); [358] => continue; [359] => } [360] => // spb3_content읽어서 keyword에서 content 전송 [361] => elseif('content.'==substr($key,1,8)) { [362] => list($tmp,$tmpKeyword,$tmpContent) = explode('.',$key,3); [363] => if(!$tmpContent) $tmpContent = 'content'; [364] => if(!isset($this->spb3_content[$tmpContent])) { [365] => $this->spb3_content[$tmpContent] = db_resultdata($GLOBALS['SITE']['th'].'cate_content',$tmpContent,'keyword',$tmpKeyword); [366] => } [367] => $res .= $this->spb3_content[$tmpContent] . implode('}', $line); [368] => continue; [369] => } [370] => // cut_string {#cut.50#0#….key} [371] => elseif('cut.'==substr($key,1,4)) { [372] => list($tmp,$tmpCut,$tmpKey) = explode('.',$key,3); [373] => list($tmpCut1,$tmpCut2,$tmpCut3) = explode('#',$tmpCut,3); [374] => if($tmpCut1===NULL) $tmpCut1 = 50; [375] => if($tmpCut2===NULL) $tmpCut2 = 0; [376] => if($tmpCut3===NULL) $tmpCut3 = '…'; [377] => $res .= cut_string($this->vars[$tmpKey],$tmpCut1,$tmpCut2,$tmpCut3).implode('}', $line); [378] => continue; [379] => } [380] => // substr {#sub.2.3.key} [381] => elseif('sub.'==substr($key,1,4)) { [382] => list($tmp,$tmpSub1,$tmpSub2,$tmpKey) = explode('.',$key,4); [383] => $res .= substr($this->vars[$tmpKey],(int)$tmpSub1,(int)$tmpSub2).implode('}', $line); [384] => continue; [385] => } [386] => // explode(split) {#exp.0.-.key} 0번째, -으로 나누어서 [387] => elseif('exp.'==substr($key,1,4)) { [388] => $tmp = explode('.',$key,4); [389] => if(4==count($tmp)) { [390] => $tmp2 = explode($tmp[2],$this->vars[$tmp[3]]); [391] => $res .= $tmp2[$tmp[1]].implode('}', $line); [392] => } [393] => else $res .= implode('}', $line); [394] => continue; [395] => } [396] => } [397] => [398] => switch ($this->unknowns) [399] => { [400] => case "keep": [401] => $res .= '{'.$key; [402] => if (count ($line) > 0) [403] => { [404] => $res .= '}'; [405] => $res .= implode('}', $line); [406] => } [407] => break; [408] => [409] => case "remove": [410] => $res .= implode('', $line); [411] => break; [412] => [413] => case "remove_nonjs": [414] => if (!empty($key) && ((false === strpos($key, ' ')) && (false === strpos($key, "\n")) && (false === strpos($key, "\t")))) [415] => { [416] => $res .= implode('}', $line); [417] => } [418] => else [419] => { [420] => $res .= '{'.$key; [421] => if (count ($line) > 0) [422] => { [423] => $res .= '}'; [424] => $res .= implode('}', $line); [425] => } [426] => } [427] => break; [428] => [429] => case "comment": [430] => $res .= ''.implode('', $line); [431] => break; [432] => [433] => case "space": [434] => $res .= ' '.implode('', $line); [435] => break; [436] => [437] => } [438] => } [439] => } [440] => } [441] => [442] => return $res; [443] => } [444] => [445] => /** [446] => * check and set template root dir [447] => */ [448] => function set_root($root) [449] => { [450] => if (empty($root)) return; [451] => if (!is_dir($root)) [452] => { [453] => $this->error("phemplate::set_root(): 다음 드렉토리가 없습니다 : $root", 'warning'); [454] => return false; [455] => } [456] => [457] => $this->root = realpath($root).'/'; // By Sunmin 05/11/13 [458] => return true; [459] => } [460] => [461] => /** [462] => * what to do with unknown variables in template? [463] => * keep [464] => * remove [465] => * remove_nonjs [466] => * comment [467] => * space [468] => */ [469] => function set_unknowns($unk) [470] => { [471] => $this->unknowns = $unk; [472] => } [473] => [474] => /** [475] => * set default parameters for process() [476] => */ [477] => function set_params($params) [478] => { [479] => $this->parameters = $params; [480] => } [481] => [482] => /** [483] => * read file template into $vars [484] => * @param string $handle - name of handle for file contents [485] => * @param int $blocks - 1 for search, 2 for nested blocks [486] => * [487] => */ [488] => function set_file($handle, $filename = "", $blocks = false) [489] => { [490] => if ($filename == "") [491] => { [492] => $this->error("phemplate::set_file(): 파일이름이 빈값으로 넘어왔습니다 -$handle", 'fatal'); [493] => return false; [494] => } [495] => $this->vars[$handle] = $this->read_file($filename); [496] => if ($blocks & TPL_STRIP_UTF_HEADER) [497] => { [498] => $header = substr($this->vars[$handle], 0, 3); [499] => if ("\xEF\xBB\xBF" == $header) $this->vars[$handle] = substr($this->vars[$handle], 3); [500] => } [501] => if ($blocks) { $this->extract_blocks($handle, $blocks & TPL_BLOCKREC); } [502] => return true; [503] => [504] => } [505] => [506] => [507] => /** [508] => * set handle and value, [509] => * if value is array, all elements will be named: handle.key.subkey [510] => */ [511] => function set_var($var_name, $var_value) [512] => { [513] => if (is_array($var_value)) [514] => { [515] => foreach($var_value as $key=>$value)