소셜로그인 중단 안내

계정으로 로그인 기능이 2023년 11월 16일 중단되었습니다.

아이보스 계정이 사라지는 것은 절대 아니며, 계정의 이메일 주소를 이용해 로그인 하실 수 있습니다.

▶️ 자세한 공지사항 확인

파일로 만든 배너관리 시스템

2006.08.24 22:55

유창화

조회수 3,321

댓글 3

아주 간단하지만 사이트에 적용하기 쉬운 유용한 배너관리 시스템입니다.

응용하시면 괜찬은것도 만들수 있으리라고 봅니다.

서버가 리눅스 / 유닉스 계열에 php가 가능한 환경이어야 합니다.
윈도우 환경에서는 테스트 해보지 않았습니다.


http://82da.com/Ybbs/sample/Ybanner.php

http://sir.co.kr/bbs/board.php?bo_table=g4_tiptech&wr_id=7070

<?php

/*제작자 : 유창화
사용제한 : 사용은 자유롭습니다. 단, 강의나 책의 내용으로서 사용될 경우 허락을 받으셔야 합니다.*/

//모든 에러를 출력하도록 설정한다.
error_reporting(E_ALL);

//기본 함수 모음을 인클루드

include_once 'source/Yfunction.php';
//처리시간 측정시작
$Ystarttime = Yget_microtime();



//정보가 저장될 디렉토리를 지정하세요, 퍼미션은 웹서버가 읽고 쓸수 있어야 합니다.
$Ypath_array_files = './temp/banner_arrays';


//해당 디렉토리가 없으면 생성
if (!is_dir($Ypath_array_files)) {

mkdir($Ypath_array_files);
chmod ($Ypath_array_files, 0777);
}



//사용된 함수
function Yget_array_from_file($path_file, $array_name){

$$array_name = Array();

if (is_file($path_file)){

@include $path_file;
}

return $$array_name;
}

function Yecho_banner($pos){

global $Ypath_array_files;

$Ypath_file = $Ypath_array_files . '/' . $pos . '.php';
$Ybanner = Yget_array_from_file($Ypath_file, 'Ybanner');

//등록된 배너일 경우에만
if (is_array($Ybanner)){

$rand_key = array_rand ($Ybanner);
echo base64_decode($Ybanner[$rand_key]);
}
}



if (empty($_GET['Ymode'])) {//전체보기

echo "
[배너 등록]
<br><br>
<form method='GET'><input type=hidden name='Ymode' value='view'>배너위치 <input type='text' name='Ypos'> 공백없이 영문과 특수문자만 사용하세요.<br><br>
<input type='submit' value='배너 등록 및 수정하기'></form>

<br><br>
[등록된 배너 리스트]
<br>
";

$d = dir($Ypath_array_files);
while (false !== ($entry = $d->read())) {

if (is_file($Ypath_array_files . '/' . $entry) && preg_match("`\.php$`i", $entry)) {

$temp_Ypos = preg_replace("`\.php`", "", $entry);
echo "<a href='" . $_SERVER['PHP_SELF'] . "?Ymode=view&Ypos=" . $temp_Ypos . "'>" . $temp_Ypos . "</a><br>";
}
else{

continue;
}
}
$d->close();

echo "
<br><br>
[배너 출력 방법 소개]
<br>
자신의 페이지에서 원하는 부분에 다음 함수를 호출 하면 됩니다
<br>
&lt;?=Yecho_banner('자기가 등록한 배너 포스');?&gt;

<br><br>
[예제]
<br>
main_right 출력
<br>
";

Yecho_banner('main_right');
}
else if (!empty($_POST['Ymode']) && $_POST['Ymode'] == 'update' ){//배너 처리

$Ypos = $_POST['Ypos'];
$Ypath_file = $Ypath_array_files . '/' . $Ypos . '.php';
$temp_text = '';

if (isset($Ybanner) && is_array($Ybanner)){

$loop = count($Ybanner);
for($i = 0; $i <= $loop; $i++){

if (empty($Ybanner[$i])) continue;
$temp_text .= "\$Ybanner[] = \"" . base64_encode(stripslashes($Ybanner[$i])) . "\";\n";
}
}

$temp_text = "<?\n\n\n\n" . $temp_text . "\n\n\n?>";


if (is_file($Ypath_file)) @copy($Ypath_file, $Ypath_file . '.' . date('Ymd'));

$fp = @fopen ($Ypath_file, "w");
@fwrite($fp, $temp_text);//유일한 파일이므로 파일에 락을 걸지 않는다.
@fclose($fp);
@chmod ($save_file, 0777);

echo "<script>alert('\\n\\n성공적으로 수정\\n\\n');location.href='" . $_SERVER['PHP_SELF'] . "?Ymode=view&Ypos=$Ypos';</script>";
exit;
}
else if ($_GET['Ymode'] == 'view' && !empty($_GET['Ypos'])){//배너 등록 수정 폼

$Ypos = $_GET['Ypos'];
$Ypath_file = $Ypath_array_files . '/' . $Ypos . '.php';
$Ybanner = Yget_array_from_file($Ypath_file, 'Ybanner');
$temp_list = '';
$temp_text = '';
if (isset($Ybanner) && is_array($Ybanner)){

$loop = count($Ybanner);
for($i = 0; $i <= $loop; $i++){

$temp = (empty($Ybanner[$i])) ? '' : base64_decode($Ybanner[$i]);
$temp_list .= "
<tr height=34 bgcolor=white>
<td align=left width=150 bgcolor=#FFC9AC> &nbsp;&nbsp;&nbsp;&nbsp;태그 </td>
<td>
<br>
&nbsp;
&nbsp;<textarea name=\"Ybanner[" . $i . "]\" cols=72 rows=4>" . $temp . "</textarea><br><br>
</td>
</tr>
";
$temp_text .= (empty($Ybanner[$i])) ? '' : base64_decode($Ybanner[$i]) . '<br>';
}
}
else{

$i = 0;
$temp_list = "
<tr height=34 bgcolor=white>
<td align=left width=150 bgcolor=#FFC9AC> &nbsp;&nbsp;&nbsp;&nbsp;태그 </td>
<td>
<br>
&nbsp;
&nbsp;<textarea name=\"" . Ybanner . "[" . $i . "]\" cols=72 rows=4></textarea><br><br>
</td>
</tr>
";
$temp_text = '등록된 배너가 없습니다.';
}

?>

<BR>
<table border=0 cellpadding=0 cellspacing=1 width=700 align=center bgcolor=black>
<form name=registform method=POST>
<tr height=30>
<td colspan=2 align=cente bgcolor=#C6E3F2>
:::::: 배너관리 - <?=$Ypos?> :::::::
</td>
</tr>
<?=$temp_list?>
<tr height=40>
<td align=center colspan=2 bgcolor=white>
<input type=button value=수정 onfocus=this.blur() onclick="con_input()">
<input type=button value=목록 onfocus=this.blur() onclick="location.href='<?=$_SERVER['PHP_SELF']?>'">
<input type=hidden name=Ymode value=update>
<input type=hidden name=Ypos value=<?=$Ypos?>>
<input type=hidden name=name value=<?=$Ybanner?>>
</td>
</tr>
</form>
</table>
<script language=javascript>

function init(){

window.document.title += " : <?=$Ypos?>";
}

window.onload = init;

function con_input() {

var form = document.registform;

if (confirm('\n\n정말로 수정하시겠습니까?\n\n')) {

form.submit();
}
return;
}

</script>
<br>
현재 랜덤 배너 내용
<br>
---------------------
<br>

<?php

echo $temp_text;

?>

<br>
<br>
---------------------
<br>
<?
}

?>
목록글쓰기
댓글 3
댓글 새로고침
로그인 후 더욱 많은 기능을 이용하세요!아이보스 로그인