Login | Join | OpenID | RSS Feed
개인 라이브러리 사용하기
최광용 Lv. 14 llllllllll 
378 hit since 2005/02/21 23:36

제로보드의 모든 페이지는 lib.php를 처음에 불러들인다. 즉 이 곳에 자신만의 함수들을 담은 라이브러리 파일을 인클루드 시켜놓으면 개인 라이브러리를 사용할 수 있다. 다음과 같이 적당한 위치에 include문을 써 넣는다.

if($_zb_lib_included) return;
$_zb_lib_included = true;

$_startTime=getmicrotime();

//cky
include "mylib.php";


mylib.php에는 자신이 사용할 적당한 변수들과 함수들을 정의해 두면 된다. 예를 들면 다음과 같다.

[secrice@athena bbs]$ head -n 20 mylib.php
<?
if ($_my_lib_included) return;
$_my_lib_included = true;

// cky definitions...
$cky_bgcolor="#aaaaaa";
$cky_linecolor="#eeeeee";
$cky_overcolor="#eeeeee";

$cky_mouseover = "onMouseOut=this.style.backgroundColor='' onMouseOver=this.style.backgroundColor='$cky_overcolor'";
$cky_line = "&lt;tr&gt;&lt;td colspan=10 height=1 bgcolor=$cky_linecolor&gt;&lt;/td&gt;&lt;/tr&gt;n";

// cky functions...

function print_ball($num, $total)
{
        $fontcolor= "#".dechex((int)(200 / $total * ($num + 1)) + 55)."3333";
        return "&lt;font color=$fontcolor&gt;$num&lt;/font&gt;";
}

위와 같이 정의해 두면 제로보드 스킨이나 php 코드 안에서 함수든 변수든 마음껏 불러서 사용할 수 있다.

Tags
PHP