LSN 소스에서 테마관련 기능이 작동하질 않습니다
글쓴이: meanitt / 작성시간: 월, 2005/04/04 - 10:03오후
http://linux.sarang.net 에서 예전에 배포했던 홈페이지소스를 가지고 이것저것 만져보다가 테마기능이 작동을 하지 않아서 이렇게 글 남깁니다
themes.php 내용입니다</thmes.php>
<?
if(!file_exists("conf/themes/$theme.theme") && $theme != "random")
$theme = "200004";
Setcookie("themes_cookie", "$theme", time() + (60*60*24*30));
Header("Location: $uri");
?>
func.ph 내용입니다</func/func.ph>
<?
//
// 랜덤값 생성 함수
//
function LSN_random($max = 99)
{
static $startseed = 0;
if(!$startseed) {
$startseed = (double)microtime()*getrandmax();
mt_srand($startseed);
}
$rand = mt_rand() % $max;
return $rand;
}
function LSN_nImg($x, $y, $alt = "")
{
$nImg = "<IMG SRC=\"/images/n.gif\" WIDTH=\"$x\" HEIGHT=\"$y\" ALT=\"$alt\">";
return $nImg;
}
//
// 파일을 읽어옴
// ($explode를 구분자로 사용하여 파일 내용을 잘라서 돌려줌)
//
function LSN_getFile($file, $explode = 0)
{
$filepointer = fopen($file, "r");
$filecontent = fread($filepointer, filesize($file));
fclose($filepointer);
if($explode)
$filecontent = explode($explode, $filecontent);
return $filecontent;
}
//
// motd.php 파일이 있을 경우 현재 접속 중인 모든 사람에게
// 공지창을 띄움. (헤더폼에서 사용하고 있음)
//
function LSN_getMotd()
{
global $dir;
if(file_exists("$dir[root]/motd.php")) {
$motd = "remoteWindow('/motd.php', 'LSN_motd', 300, 200)\n";
return $motd;
}
}
function LSN_getTitle($title)
{
$title = " - ".$title;
return $title;
}
//
//// 테마 함수
//
Function LSN_getThemes()
{
global $dir;
$themes_dat = LSN_getFile("$dir[theme]/themes.dat", "\n");
for($i = 0; $i < count($themes_dat); $i++) {
list($theme[$i][group], $theme[$i][name], $theme[$i][file]) = explode("|", $themes_dat[$i]);
}
return $theme;
}
//
// 테마 무작위로 가져오기 함수
//
function LSN_themesRandom()
{
global $dir;
$themes = LSN_getThemes();
$theme = "random";
while($theme == "random") {
$random = LSN_random(count($themes));
$theme = $themes[$random][file];
}
return $themes[$random][file];
}
//
// 현재 사용하고 있는 테마를 SELECT 폼에서 사용하기 위해
// 출력하는 함수
//
function LSN_printThemes()
{
global $use;
$themes = LSN_getThemes();
$theme .= "<FORM ACTION=\"themes.php\" METHOD=\"post\">\n".
"<SELECT NAME=\"theme\">\n".
"<OPTION>테마선택\n";
for($i = 0; $i < count($themes); $i++) {
if($themes[$i][group] != $old) {
$theme .= "<OPTION>------\n";
}
if($themes[$i][file] == $use[theme]) {
$select = " SELECTED";
} else {
unset($select);
}
$theme .= "<OPTION VALUE=\"".$themes[$i][file]."\"$select>".$themes[$i][name]."\n";
$old = $themes[$i][group];
}
$theme .= "</SELECT>\n".
"<INPUT TYPE=\"hidden\" NAME=\"uri\" VALUE=\"".getenv("REQUEST_URI")."\">\n".
"<INPUT TYPE=\"submit\" VALUE=\"적용\">\n" .
"</FORM>\n";
return $theme;
}
//
//// 메뉴 함수
//
function LSN_getMenu()
{
global $dir;
$dirpointer = opendir($dir[form]);
while($list = readdir($dirpointer)) {
if(ereg("^menu[0-9].ph$", $list))
$menus[] = $list;
}
closedir($dirpointer);
sort($menus);
return $menus;
}
function LSN_printMenu()
{
$numargs = func_num_args();
$arglist = func_get_args();
// 메뉴 제목
$menu = $arglist[0];
$menu .= "<TR><TD>\n";
for($i = 1; $i < count($arglist); $i++) {
$menu .= $arglist[$i];
}
$menu .= LSN_nImg(1, 7, "+---+")."<BR>\n";
$menu .= "</TD></TR>\n";
return $menu;
}
function LSN_printMenuItem($url, $description, $accesskey = "")
{
global $dir, $layout, $getcho;
$uri = getenv("REQUEST_URI");
if(ereg("/board", $url)) {
$page[0] = "/board";
$page[1] = eregi_replace(".*table=(.*)", "\\1", $url);
} else if(ereg("/", $url)) {
$page[0] = "/";
$page[1] = eregi_replace(".*p=(.*)", "\\1", $url);
}
$ac = $accesskey ? "accesskey=\"$accesskey\"" : "";
if(ereg("^(http|ftp|news|https)://", $url)) {
$menu = "<IMG SRC=\"$dir[image]/dot.gif\" WIDTH=\"12\" HEIGHT=\"12\" ALT=\"|\"> ".
"<A $ac TARGET=\"_blink\" HREF=\"$url\"><FONT COLOR=\"".$layout[menu][tmp][fg]."\">".
$description."</FONT></A><BR>\n";
} else if(strstr($uri, $page[0]) && strstr($uri, $page[1])) {
$menu = "<IMG SRC=\"$dir[image]/box.gif\" WIDTH=\"12\" HEIGHT=\"12\" ALT=\"|\"> ".
"<A $ac HREF=\"$url\"><FONT COLOR=\"".$layout[menu][tmp][fg]."\">".
$description."</FONT></A><BR>\n";
} else {
$menu = "<IMG SRC=\"$dir[image]/dot.gif\" WIDTH=\"12\" HEIGHT=\"12\" ALT=\"|\"> ".
"<A $ac HREF=\"$url\"><FONT COLOR=\"".$layout[menu][tmp][fg]."\">".
$description."</FONT></A><BR>\n";
}
return $menu;
}
function LSN_printMenuTitle($title, $url = "")
{
global $layout;
$title = "<FONT COLOR=\"".$layout[menu][tmp][tt]."\">$title</FONT>";
if($url)
$title = "<A HREF=\"$url\">$title</A>";
$title = "<TR><TD><B>$title</B></TD></TR>\n".
"<TR><TD BGCOLOR=\"".$layout[menu][tmp][sp]."\">".LSN_nImg(0, 1, "+")."</TD></TR>\n";
return $title;
}
function LSN_printTitle($title, $top = 0) {
global $layout, $dir;
$title =
" <IMG SRC=\"/images/n.gif\" ALT=\"------------------------------------------------------------\" WIDTH=\"0\" HEIGHT=\"4\"><BR>\n".
" <FONT COLOR=\"".$layout[titl][fg]."\">$title</FONT><BR>\n".
" <IMG SRC=\"/images/n.gif\" ALT=\"------------------------------------------------------------\" WIDTH=\"0\" HEIGHT=\"4\"><BR>\n";
$str =
"<TABLE WIDTH=\"100%\" BORDER=\"0\" CELLSPACING=\"0\" CELLPADDING=\"0\">\n".
"<TR>\n".
$str .= $top ?
" <TD ALIGN=\"center\" BGCOLOR=\"".$layout[titl][bg]."\" VALIGN=\"bottom\">\n".$title."</TD>" :
" <TD COLSPAN=\"2\" BGCOLOR=\"".$layout[titl][ct]."\"><IMG SRC=\"/images/n.gif\" ALT=\"\" WIDTH=\"0\" HEIGHT=\"".$layout[titl][yt]."\"></TD>\n".
"</TR><TR>\n".
" <TD ALIGN=\"center\" BGCOLOR=\"".$layout[titl][bg]."\" VALIGN=\"bottom\">\n".$title.
" </TD><TD ALIGN=\"center\" BGCOLOR=\"".$layout[titl][bg]."\" WIDTH=\"5%\">\n".
" <A HREF=\"#\"><IMG SRC=\"$dir[image]/top.gif\" WIDTH=\"11\" HEIGHT=\"11\" ALT=\"[TOP]\" BORDER=\"0\"></A>\n".
" </TD>\n";
$str .=
"</TR><TR>\n".
" <TD COLSPAN=\"2\" BGCOLOR=\"".$layout[titl][cb]."\"><IMG SRC=\"/images/n.gif\" ALT=\"\" WIDTH=\"0\" HEIGHT=\"".$layout[titl][yb]."\"></TD>\n".
"</TR>\n".
"</TABLE><P>\n";
return $str;
}
function LSN_getLogo()
{
global $dir;
if(file_exists("$dir[root]$dir[image]/logo.gif") &&
file_exists("$dir[root]$dir[image]/logo.size")) {
$image = $dir[image];
} else {
$image = "/images/color";
}
include("$dir[root]$image/logo.size");
$logo = "<IMG SRC=\"$image/logo.gif\" WIDTH=\"$lsize[x]\" HEIGHT=\"$lsize[y]\" ".
"ALT=\"[ 리눅스와 함께 무한 자유의 여행을 ]\">\n";
return $logo;
}
function LSN_getDir($dir, $recursive = 0, $include = "")
{
$dirs = LSN_getSubDir($dir, $recursive, $include);
$dirs[] = $dir;
sort($dirs);
return $dirs;
}
function LSN_getSubDir($dir, $recursive = 0, $include = "")
{
$dirpointer = opendir($dir);
while($list = readdir($dirpointer)) {
if(is_readable("$dir/$list") &&
(is_dir("$dir/$list") && !is_link("$dir/$list")) && !eregi("^\.", $list)) {
if(!$include || eregi(".*($include).*", "$dir/$list")) {
$dirs[] = "$dir/$list";
if($recursive)
$dirs = array_merge($dirs, LSN_getSubDir("$dir/$list", $recursive, $include));
}
}
}
closedir($dirpointer);
return $dirs;
}
function LSN_printSrc($dirs, $root = "") {
global $layout;
echo("<UL>\n");
for($i = 0; $i < count($dirs); $i++) {
$dirpointer = opendir($dirs[$i]);
unset($lists);
while($list = readdir($dirpointer)) {
$lists[] = $list;
}
closedir($dirpointer);
sort($lists);
unset($str);
for($j = 0; $j < count($lists); $j++) {
if(is_file("$dirs[$i]/$lists[$j]") &&
ereg("\.(php|ph|theme|dat|txt|po|pot|sql)$", $lists[$j])) {
$str .= "<LI TYPE=\"square\"><A HREF=\"/src.php?src=".
urlencode(ereg_replace($root, "", $dirs[$i])."/$lists[$j]").
"\">$lists[$j]</A>\n";
}
}
if($str) {
$d = ereg_replace($root, "", $dirs[$i]);
$d = $d ? $d : "/";
echo("<LI><B>$d</B><P>\n<UL>\n$str</UL><P>\n");
}
}
echo("</UL>\n");
}
function LSN_new($date = 0, $return = 0)
{
global $dir;
$week = 7*24*60*60;
$time = time();
if(($time - $week) < $date) {
$str = " <IMG SRC=\"$dir[image]/new.gif\" WIDTH=\"21\" HEIGHT=\"12\"" .
"BORDER=\"0\" ALT=\"[NEW]\">";
}
if($return)
return $str;
echo $str;
}
/////////////////////////////////////////////////////////////////////////
function _new($date = 0)
{
global $SCRIPT_FILENAME, $p, $dir;
if($date) {
$ctime = $date;
} else {
if($p) {
$ctime = filectime("$dir[root]/page/$p.php");
} else {
$ctime = filectime("$SCRIPT_FILENAME");
}
}
$time = time();
$week = 7*24*60*60;
if(($time - $week) < $ctime) {
echo(" <IMG SRC=\"$dir[image]/new.gif\" WIDTH=\"21\" HEIGHT=\"12\"" .
"BORDER=\"0\" ALT=\"[NEW]\">");
}
}
// 접속한 사람이 사용하는 브라우져를 알기 위해 사용되는 함수, 현재는 FORM
// 입력창의 크기가 브라우져마다 틀리게 설정되는 것을 보정하기 위해 사용됨
//
// getenv - 환경 변수값을 가져옴
// http://www.php.net/manual/function.getenv.php
function gagent()
{
$agent_env = getenv("HTTP_USER_AGENT");
// $agent 배열 정보 [br] 브라우져 종류
// [os] 운영체제
// [ln] 언어 (넷스케이프)
if(ereg("MSIE", $agent_env)) {
$agent[br] = "MSIE";
$agent[os] = "WIN";
} else if(ereg("^Mozilla", $agent_env)) {
$agent[br] = "MOZL";
if(ereg("Win", $agent_env)) {
$agent[os] = "WIN";
if(ereg("\[ko\]", $agent_env)) {
$agent[ln] = "KO";
}
if(ereg("/5.0", $agent_env)) {
$agent[ve] = "50";
}
} else {
$agent[os] = "OTHER";
}
} else {
$agent[br] = "OTHER";
}
return $agent;
}
// 넷스케이프와 익스간의 FORM 입력창의 크기 차이를 보정하기 위한 함 수
// intval - 변수를 정수형으로 변환함
// http://www.php.net/manual/function.intval.php
function sform($size)
{
// 클라이언트 브라우져 종류를 가져오는 함수 (include/get_info.ph)
$agent = gagent();
// 윈도우용 네스케이프
if($agent[br] == "MOZL" && $agent[os] == "WIN") {
if($agent[ve] == "50") {
$size *= 2.2;
} else {
$size *= 1.5;
}
}
// 인터넷 익스플로러
if($agent[br] == "MSIE") {
$size *= 2.3;
}
$size = intval($size);
echo $size;
}
?>
global.ph 내용입니다</conf/global.ph>
<?
$dir[root] = "/home/httpd/html";
$dir[form] = "$dir[root]/form";
$dir[theme] = "$dir[root]/conf/themes";
// 기본 테마 불러옴
if(file_exists("$dir[theme]/default.theme")) {
include("$dir[theme]/default.theme");
}
// 테마 변수 (쿠키, GET)
$use[theme] = $theme ? $theme : $themes_cookie;
// 무작위인 경우
if($use[theme] == "random") {
$use[theme] = LSN_themesRandom();
}
// 지정된 변수에 맞게 테마 불러옴
if(file_exists("$dir[theme]/$use[theme].theme")) {
include("$dir[theme]/$use[theme].theme");
}
// 이미지 디렉토리
$dir[image] = "/images/color/$use[theme]";
// 배경 이미지
if(file_exists("$dir[root]$dir[image]/back.gif")) {
$use[bgImg] = "BACKGROUND=\"$dir[image]/back.gif\"";
} else if(file_exists("$dir[root]$dir[image]/back.jpg")) {
$use[bgImg] = "BACKGROUND=\"$dir[image]/back.jpg\"";
}
?>
테마 관련 파일들은 /conf/themes 안에 들어있습니다
위엣것들을 가지고 폼에서 테마를 선택하고 바꿔보면 쿠키가 구워지지 않는지 테마변경이 이루어지질 않네요
뭐가 잘못된거죠??
Forums:


HINT : register_globals우선 /conf/glob
HINT : register_globals
우선 /conf/global.ph파일 맨 앞에 보면 $dir[root]라는 부분이 있습니다. 기본값은 LSN 시스템에 맞추어져 있기 때문에 반드시 수정해야 할 부분입니다.
이 값을 실제 웹 루트 디렉토리와 맞춰주세요.
그리고 아래의 내용을 포함하고 있는 파일을 하나 만들어서 register_globals 를 찾아보세요.
<?php
echo phpinfo();
?>
저 값이 On으로 되어 있으면 그대로 사용할 수 있고 Off로 되어 있다면 전체 소스를 이에 맞춰서 변경해야 합니다.
댓글 달기