웹마스터 팁
page_full_width" class="col-xs-12" |cond="$__Context->page_full_width">
[추천 강의] NZEO.COM 에서 쓰는 북마크 구현하기
2002.12.28 23:39
http://seokeen.zio.tocheck.php //제로보드 회원과 연동시키는 부분
SelectBox.js //Say Club 셀렉트박스
include.php //북마크 출력
bookmark.php //북마크 입력
bookmark_ok.php //입력;;
bookmark_del.php //북마크 삭제
설치하시려면 bookmark 라는 테이블을 생성해 주셔야 합니다.
이상있는 부분이 발견되거나;;; 하면 댓글 달아주세요;;;
CREATE TABLE bookmark (
id int(11) NOT NULL auto_increment,
member_id varchar(20) NOT NULL default '',
url varchar(255) NOT NULL default '',
url_name varchar(50) NOT NULL default '',
PRIMARY KEY (id)
) TYPE=MyISAM;
check.php ─────────────────────────────────────
<?
ob_start();
$connect = mysql_connect("localhost" ,"아이디", "패스워드") or die(mysql_error());
mysql_select_db("DB네임");
$user_id = $HTTP_COOKIE_VARS[zetyxboard_userid];
$password = $HTTP_COOKIE_VARS[zetyxboard_password];
$result = @mysql_query("select * from zetyx_member_table where user_id='$user_id' and password='$password'",$connect) or die(mysql_error());
$check = mysql_fetch_array($result);
?>
SelectBox.js ─────────────────────────────────────
function printZSelectBox(selectBox,option) {
var tmp, name, value, outString, action;
var id = selectBox["id"];
var width = selectBox["width"];
var height = selectBox["height"];
var bordercolor = selectBox["bordercolor"];
var bgcolor = selectBox["bgcolor"];
var fontcolor = selectBox["fontcolor"];
var focusbgcolor = selectBox["focusbgcolor"];
var fontsize = selectBox["fontsize"];
var padding = selectBox["padding"];
var bullet = selectBox["bullet"];
var onChange = selectBox["onChange"];
var select = option["select"];
if(bordercolor==null) bordercolor = "#888888";
if(bgcolor==null) bgcolor= "#ffffff";
if(fontcolor==null) fontcolor="#333333";
if(focusbgcolor==null) focusbgcolor= "#ededed";
if(width==null) width=100;
if(height!=null) height="height="+height; else height = "";
if(fontsize==null) fontsize="9";
if(padding==null) padding="1";
if(bullet==null) bullet="▽";
outString = "<input type=hidden name='"+id+"'>";
outString += "<table width="+width+" "+height+" border=0 cellspacing=1 cellpadding=0 bgcolor="+bordercolor+" style='table-layout:fixed;cursor:hand' onClick="showZSelectBox('layer_"+id+"')">n";
outString += "<tr bgcolor="+bgcolor+">n";
outString += "<td>n";
outString += "<table border=0 width=100% height=100% cellspacing=0 cellpadding="+padding+" style='table-layout:fixed;'>n";
outString += "<col width=></col><col width=15></col>n";
outString += "<tr>n";
outString += "<td style='line-height:100%;padding-top:3px;padding-left:3px;' onMouseOver=this.style.backgroundColor='"+focusbgcolor+"' onMouseOut=this.style.backgroundColor='+ ''><div id="+id+"_value style=color:"+fontcolor+";font-size:"+fontsize+"pt;>Select</div></td>n";
outString += "<td style='font-size:"+fontsize+"pt;padding:0px;color:"+fontcolor+";' align=center>"+bullet+"</td>n";
outString += "</tr>n";
outString += "</table>n";
outString += "</td>n";
outString += "</tr>n";
outString += "</table>n";
outString += "<div id='layer_"+id+"' style='z-index:100; position:absolute; visibility:hidden' onMouseOver=showZSelectBox('layer_"+id+"') onMouseOut=hideZSelectBox('layer_"+id+"')>n";
outString += "<table border=0 cellspacing=0 cellpadding=0 height=2><tr><td></td></tr></table><table border=0 cellspacing=1 cellpadding=0 bgcolor="+bordercolor+" width="+width+">n";
outString += "<tr bgcolor="+bgcolor+">n";
outString += "<td>n";
outString += "<table border=0 cellspacing=0 cellpadding=0 width=100% style=table-layout:fixed>n";
outString += "<col style=padding-left:3px;font-size:"+fontsize+"pt;color:"+fontcolor+" width=></col>n";
for(i=0;i<option.length;i++) {
tmp = option[i].split(",");
name = tmp[0];
value = tmp[1];
if(value==null) value = "";
if(onChange!=null&&value) action= "location.href=""+value+""";
else action = ""selectZSelectBox('"+name+"','"+value+"'+ ','"+id+"')"";
outString += "<tr onMouseOver=this.style.backgroundColor='"+focusbgcolor+"' onMouseOut=this.style.backgroundColor='' style=cursor:hand><td onClick="+action+" style='padding-top:1px;font-size:"+fontsize+"pt;color:"+fontcolor+"'>"+name+"</td></tr>n";
}
outString += "</table>n";
outString += "</td>n";
outString += "</tr>n";
outString += "</table>n";
outString += "</div>n";
document.writeln(outString);
if(select!=null) {
tmp = option[select].split(",");
name = tmp[0];
value = tmp[1];
if(value==null) value = "";
document.all[id+"_value"].innerHTML = name;
document.all[id].value = value;
}
}
function showZSelectBox(id) {
document.all[id].style.visibility = '';
}
function hideZSelectBox(id) {
document.all[id].style.visibility = 'hidden';
}
function selectZSelectBox(name,value,id) {
document.all[id+"_value"].innerHTML = name;
document.all[id].value=value;
document.all["layer_"+id].style.visibility = 'hidden';
}
include.php ────────────────────────────────
include.php 을 원하는 부분에 include 하시면 됩니다.;;;;
<script src="SelectBox.js"></script>
<script>
var selectBox = new Array();
var option = new Array();
selectBox["id"] = "BookMark";
selectBox["fontsize"] = "9";
selectBox["width"] = "148";
selectBox["height"] = "19";
selectBox["fontcolor"] = "#333333";
selectBox["bordercolor"] = "#666666";
selectBox["focusbgcolor"] = "#f0f0f0";
selectBox["bullet"] = "<img src=select_bul.gif width=10 height=6 border=0>";
selectBox["padding"] = "0";
selectBox["onChange"] = true;
option[0] = "북마크";
<?
include ("check.php");
@$temp = "select * from bookmark where member_id='$check[user_id]'";
@$result = mysql_query($temp,$connect);
$total = mysql_affected_rows();
for ($i=0; $i<$total; $i++)
{
$m = $i+1;
$data = mysql_fetch_array($result);
echo "option[$m] = "$data[url_name],$data[url]";rn";
}
?>
option["select"] = 0;
printZSelectBox(selectBox,option);
</script>
<?
if($check[level]) $a_link = "<a href='bookmark.php' title='현재 페이지 북마크하기'>";
else $a_link = "<a href='#' onclick='alert(" 로그인된 회원에 한해 이용하실 수 있습니다. ")' title='현재 페이지 북마크하기'>";
echo $a_link;
?>
북마크추가</a>
</form>
bookmark.php ────────────────────────────────
<?
//$HTTP_REFERER 변수를 받아온다.
include ("check.php");
if(!$check[level]||$check[level]==10) error ("사용권한이 없습니다. 로그인해주세요");
$temp = mysql_query("select * from bookmark where member_id='$check[user_id]'");
<form name='bookMark' action='bookmark_ok.php' method='post' enctype='multipart/form-data'>
북마크 이름 : <input type='text' name='url_name' value=''>
URL : <input type='text' name='url' value='<?=$HTTP_REFERER?>'>
<input type=submit value=' SUBMIT '>
</form>
<table>
<tr align='center'>
<td><b>Name</b></td><td><b>URL</b></td><td><b>Del</b></td>
</tr>
<?
while ($data=mysql_fetch_array($temp))
{
echo "<tr>
<td>$data[url_name]</td>
<td><a href='$data[url]' target='_blank'>$data[url]</td>
<td><a href='bookmark_del.php?id=$data[id]'>삭제</a></td>
</tr>";
}
?>
</table>
bookmark_ok.php ────────────────────────────────
<?
include ("check.php");
mysql_query("insert into bookmark (member_id,url,url_name) values ('$check[user_id]','$url','$url_name')");
echo "<meta http-equiv='refresh' content='0;URL=bookmark.php'>";
?>
bookmark_del.php ────────────────────────────────
<?
include ("check.php");
mysql_query("delete from bookmark where id ='$id'");
echo "<meta http-equiv='refresh' content='0;URL=bookmark.php'>";
?>
SelectBox.js //Say Club 셀렉트박스
include.php //북마크 출력
bookmark.php //북마크 입력
bookmark_ok.php //입력;;
bookmark_del.php //북마크 삭제
설치하시려면 bookmark 라는 테이블을 생성해 주셔야 합니다.
이상있는 부분이 발견되거나;;; 하면 댓글 달아주세요;;;
CREATE TABLE bookmark (
id int(11) NOT NULL auto_increment,
member_id varchar(20) NOT NULL default '',
url varchar(255) NOT NULL default '',
url_name varchar(50) NOT NULL default '',
PRIMARY KEY (id)
) TYPE=MyISAM;
check.php ─────────────────────────────────────
<?
ob_start();
$connect = mysql_connect("localhost" ,"아이디", "패스워드") or die(mysql_error());
mysql_select_db("DB네임");
$user_id = $HTTP_COOKIE_VARS[zetyxboard_userid];
$password = $HTTP_COOKIE_VARS[zetyxboard_password];
$result = @mysql_query("select * from zetyx_member_table where user_id='$user_id' and password='$password'",$connect) or die(mysql_error());
$check = mysql_fetch_array($result);
?>
SelectBox.js ─────────────────────────────────────
function printZSelectBox(selectBox,option) {
var tmp, name, value, outString, action;
var id = selectBox["id"];
var width = selectBox["width"];
var height = selectBox["height"];
var bordercolor = selectBox["bordercolor"];
var bgcolor = selectBox["bgcolor"];
var fontcolor = selectBox["fontcolor"];
var focusbgcolor = selectBox["focusbgcolor"];
var fontsize = selectBox["fontsize"];
var padding = selectBox["padding"];
var bullet = selectBox["bullet"];
var onChange = selectBox["onChange"];
var select = option["select"];
if(bordercolor==null) bordercolor = "#888888";
if(bgcolor==null) bgcolor= "#ffffff";
if(fontcolor==null) fontcolor="#333333";
if(focusbgcolor==null) focusbgcolor= "#ededed";
if(width==null) width=100;
if(height!=null) height="height="+height; else height = "";
if(fontsize==null) fontsize="9";
if(padding==null) padding="1";
if(bullet==null) bullet="▽";
outString = "<input type=hidden name='"+id+"'>";
outString += "<table width="+width+" "+height+" border=0 cellspacing=1 cellpadding=0 bgcolor="+bordercolor+" style='table-layout:fixed;cursor:hand' onClick="showZSelectBox('layer_"+id+"')">n";
outString += "<tr bgcolor="+bgcolor+">n";
outString += "<td>n";
outString += "<table border=0 width=100% height=100% cellspacing=0 cellpadding="+padding+" style='table-layout:fixed;'>n";
outString += "<col width=></col><col width=15></col>n";
outString += "<tr>n";
outString += "<td style='line-height:100%;padding-top:3px;padding-left:3px;' onMouseOver=this.style.backgroundColor='"+focusbgcolor+"' onMouseOut=this.style.backgroundColor='+ ''><div id="+id+"_value style=color:"+fontcolor+";font-size:"+fontsize+"pt;>Select</div></td>n";
outString += "<td style='font-size:"+fontsize+"pt;padding:0px;color:"+fontcolor+";' align=center>"+bullet+"</td>n";
outString += "</tr>n";
outString += "</table>n";
outString += "</td>n";
outString += "</tr>n";
outString += "</table>n";
outString += "<div id='layer_"+id+"' style='z-index:100; position:absolute; visibility:hidden' onMouseOver=showZSelectBox('layer_"+id+"') onMouseOut=hideZSelectBox('layer_"+id+"')>n";
outString += "<table border=0 cellspacing=0 cellpadding=0 height=2><tr><td></td></tr></table><table border=0 cellspacing=1 cellpadding=0 bgcolor="+bordercolor+" width="+width+">n";
outString += "<tr bgcolor="+bgcolor+">n";
outString += "<td>n";
outString += "<table border=0 cellspacing=0 cellpadding=0 width=100% style=table-layout:fixed>n";
outString += "<col style=padding-left:3px;font-size:"+fontsize+"pt;color:"+fontcolor+" width=></col>n";
for(i=0;i<option.length;i++) {
tmp = option[i].split(",");
name = tmp[0];
value = tmp[1];
if(value==null) value = "";
if(onChange!=null&&value) action= "location.href=""+value+""";
else action = ""selectZSelectBox('"+name+"','"+value+"'+ ','"+id+"')"";
outString += "<tr onMouseOver=this.style.backgroundColor='"+focusbgcolor+"' onMouseOut=this.style.backgroundColor='' style=cursor:hand><td onClick="+action+" style='padding-top:1px;font-size:"+fontsize+"pt;color:"+fontcolor+"'>"+name+"</td></tr>n";
}
outString += "</table>n";
outString += "</td>n";
outString += "</tr>n";
outString += "</table>n";
outString += "</div>n";
document.writeln(outString);
if(select!=null) {
tmp = option[select].split(",");
name = tmp[0];
value = tmp[1];
if(value==null) value = "";
document.all[id+"_value"].innerHTML = name;
document.all[id].value = value;
}
}
function showZSelectBox(id) {
document.all[id].style.visibility = '';
}
function hideZSelectBox(id) {
document.all[id].style.visibility = 'hidden';
}
function selectZSelectBox(name,value,id) {
document.all[id+"_value"].innerHTML = name;
document.all[id].value=value;
document.all["layer_"+id].style.visibility = 'hidden';
}
include.php ────────────────────────────────
include.php 을 원하는 부분에 include 하시면 됩니다.;;;;
<script src="SelectBox.js"></script>
<script>
var selectBox = new Array();
var option = new Array();
selectBox["id"] = "BookMark";
selectBox["fontsize"] = "9";
selectBox["width"] = "148";
selectBox["height"] = "19";
selectBox["fontcolor"] = "#333333";
selectBox["bordercolor"] = "#666666";
selectBox["focusbgcolor"] = "#f0f0f0";
selectBox["bullet"] = "<img src=select_bul.gif width=10 height=6 border=0>";
selectBox["padding"] = "0";
selectBox["onChange"] = true;
option[0] = "북마크";
<?
include ("check.php");
@$temp = "select * from bookmark where member_id='$check[user_id]'";
@$result = mysql_query($temp,$connect);
$total = mysql_affected_rows();
for ($i=0; $i<$total; $i++)
{
$m = $i+1;
$data = mysql_fetch_array($result);
echo "option[$m] = "$data[url_name],$data[url]";rn";
}
?>
option["select"] = 0;
printZSelectBox(selectBox,option);
</script>
<?
if($check[level]) $a_link = "<a href='bookmark.php' title='현재 페이지 북마크하기'>";
else $a_link = "<a href='#' onclick='alert(" 로그인된 회원에 한해 이용하실 수 있습니다. ")' title='현재 페이지 북마크하기'>";
echo $a_link;
?>
북마크추가</a>
</form>
bookmark.php ────────────────────────────────
<?
//$HTTP_REFERER 변수를 받아온다.
include ("check.php");
if(!$check[level]||$check[level]==10) error ("사용권한이 없습니다. 로그인해주세요");
$temp = mysql_query("select * from bookmark where member_id='$check[user_id]'");
<form name='bookMark' action='bookmark_ok.php' method='post' enctype='multipart/form-data'>
북마크 이름 : <input type='text' name='url_name' value=''>
URL : <input type='text' name='url' value='<?=$HTTP_REFERER?>'>
<input type=submit value=' SUBMIT '>
</form>
<table>
<tr align='center'>
<td><b>Name</b></td><td><b>URL</b></td><td><b>Del</b></td>
</tr>
<?
while ($data=mysql_fetch_array($temp))
{
echo "<tr>
<td>$data[url_name]</td>
<td><a href='$data[url]' target='_blank'>$data[url]</td>
<td><a href='bookmark_del.php?id=$data[id]'>삭제</a></td>
</tr>";
}
?>
</table>
bookmark_ok.php ────────────────────────────────
<?
include ("check.php");
mysql_query("insert into bookmark (member_id,url,url_name) values ('$check[user_id]','$url','$url_name')");
echo "<meta http-equiv='refresh' content='0;URL=bookmark.php'>";
?>
bookmark_del.php ────────────────────────────────
<?
include ("check.php");
mysql_query("delete from bookmark where id ='$id'");
echo "<meta http-equiv='refresh' content='0;URL=bookmark.php'>";
?>
댓글 5
-
lyx
2002.12.29 10:24
쿠키로 체크하는 방식은.. 4.0 버전대에서 쓰이던건데... -
と두기
2002.12.29 12:33
bookmark.php 부분에서 에러나는것은..
?>를 안써서인것 같네요;; -
jeje
2002.12.29 13:54
두기님 말슴이 맞는 듯 싶네요..
그런데..
checking.php 쪽에서 자꾸 에러가 나는데..
그걸 .4.1pl2버젼에서
<?
$_zb_url = "제로보드가 설치된 url";
$_zb_path = "제로보드가 설치된 절대경로";
include $_zb_path."outlogin.php";
?>
이걸 넣어주고 $member[level]로 대체할 수 있는 방법은 없을까요? -
jeje
2002.12.29 01:52
일단....로긴이 된 상태에서도 로그인을 하라고 나옵니다.
그 부분은...
include.php에서...
$check[level] 대신...$member[level]를 넣어 줌으로써 해결된 것 같습니다.
그런데...
Parse error: parse error in /경로/bookmark.php on line 8
이런 에러가 뜨네요...
실제로 거긴...
<form name='bookMark' action='bookmark_ok.php' method='post' enctype='multipart/form-data'>
이것이 있는 곳이고 이 문장은 짧은 제 실력에는 에러가 없는 듯한데요...
마지막으로..
이건 인크루드해서 사용하는 것이기 때문에..
각 화일마다 경로를 절대경로나 주소로 바꾸어 줘야 모든 화일이 서로 연결이 되리라 생각됩니다. -
앗싸~~ 곰세마리
2003.01.11 14:58
저두 이거 대로 하니깐 계속 error가 나는뎅..
어떻게 수정해서 새로 ?? 올려주시면 안될까요?