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

간단하지만 유용한 배너관리 시스템입니다.

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

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>
<?
}

?>

이올린에 북마크하기(0) 이올린에 추천하기(0)

Posted by 바람부는데로

, , ,
Response
No Trackback , No Comment
RSS :
http://apmusers.com/tt/dbckdghk/rss/response/20

Trackback URL : 이 글에는 트랙백을 보낼 수 없습니다

« Previous : 1 : ... 81 : 82 : 83 : 84 : 85 : 86 : 87 : 88 : 89 : ... 95 : Next »

블로그 이미지

유창화의 블로그(사진은 10년전 모습)

- 바람부는데로

Archives

Calendar

«   2012/02   »
      1 2 3 4
5 6 7 8 9 10 11
12 13 14 15 16 17 18
19 20 21 22 23 24 25
26 27 28 29      

이올린 추천글

Site Stats

Total hits:
235018
Today:
59
Yesterday:
87