비표준 그누보드4 첫커밋

This commit is contained in:
whitedot
2012-10-05 15:12:27 +09:00
parent 8751c57ffc
commit a4b2e70e4d
899 changed files with 89562 additions and 0 deletions

56
lib/cheditor4.lib.php Normal file
View File

@ -0,0 +1,56 @@
<?
if (!defined('_GNUBOARD_')) exit;
if ($g4['is_cheditor5'])
{
$g4['cheditor4'] = "cheditor5";
$g4['cheditor4_path'] = $g4['path'] . "/" . $g4['cheditor4'];
function cheditor1($id, $width='100%', $height='250')
{
global $g4;
return "
<script type='text/javascript'>
var ed_{$id} = new cheditor('ed_{$id}');
ed_{$id}.config.editorHeight = '{$height}';
ed_{$id}.config.editorWidth = '{$width}';
ed_{$id}.inputForm = 'tx_{$id}';
</script>";
}
}
else
{
function cheditor1($id, $width='100%', $height='250')
{
global $g4;
return "
<script type='text/javascript'>
var ed_{$id} = new cheditor('ed_{$id}');
ed_{$id}.config.editorHeight = '{$height}';
ed_{$id}.config.editorWidth = '{$width}';
ed_{$id}.config.imgReSize = false;
ed_{$id}.config.fullHTMLSource = false;
ed_{$id}.config.editorPath = '{$g4[cheditor4_path]}';
ed_{$id}.inputForm = 'tx_{$id}';
</script>";
}
}
function cheditor2($id, $content='')
{
global $g4;
return "
<textarea name='{$id}' id='tx_{$id}' style='display:none;'>{$content}</textarea>
<script type='text/javascript'>
ed_{$id}.run();
</script>";
}
function cheditor3($id)
{
return "document.getElementById('tx_{$id}').value = ed_{$id}.outputBodyHTML();";
}
?>

1518
lib/common.lib.php Normal file

File diff suppressed because it is too large Load Diff

25
lib/connect.lib.php Normal file
View File

@ -0,0 +1,25 @@
<?
if (!defined('_GNUBOARD_')) exit;
// 현재 접속자수 출력
function connect($skin_dir="")
{
global $config, $g4;
// 회원, 방문객 카운트
$sql = " select sum(IF(mb_id<>'',1,0)) as mb_cnt, count(*) as total_cnt from $g4[login_table] where mb_id <> '$config[cf_admin]' ";
$row = sql_fetch($sql);
if ($skin_dir)
$connect_skin_path = "$g4[path]/skin/connect/$skin_dir";
else
$connect_skin_path = "$g4[path]/skin/connect/$config[cf_connect_skin]";
ob_start();
include_once ("$connect_skin_path/connect.skin.php");
$content = ob_get_contents();
ob_end_clean();
return $content;
}
?>

12
lib/constant.php Normal file
View File

@ -0,0 +1,12 @@
<?
// 상수 정의
// 입력값 검사 상수
define('_G4_ALPHAUPPER_', 1); // 영대문자
define('_G4_ALPHALOWER_', 2); // 영소문자
define('_G4_ALPHABETIC_', 4); // 영대,소문자
define('_G4_NUMERIC_', 8); // 숫자
define('_G4_HANGUL_', 16); // 한글
define('_G4_SPACE_', 32); // 공백
define('_G4_SPECIAL_', 64); // 특수문자
?>

12
lib/etc.lib.php Normal file
View File

@ -0,0 +1,12 @@
<?
// 로그를 파일에 쓴다
function write_log($file, $log) {
$fp = fopen($file, "a+");
ob_start();
print_r($log);
$msg = ob_get_contents();
ob_end_clean();
fwrite($fp, $msg);
fclose($fp);
}
?>

35
lib/latest.lib.php Normal file
View File

@ -0,0 +1,35 @@
<?
if (!defined('_GNUBOARD_')) exit;
// 최신글 추출
function latest($skin_dir="", $bo_table, $rows=10, $subject_len=40, $options="")
{
global $g4;
if ($skin_dir)
$latest_skin_path = "$g4[path]/skin/latest/$skin_dir";
else
$latest_skin_path = "$g4[path]/skin/latest/basic";
$list = array();
$sql = " select * from $g4[board_table] where bo_table = '$bo_table'";
$board = sql_fetch($sql);
$tmp_write_table = $g4['write_prefix'] . $bo_table; // 게시판 테이블 전체이름
//$sql = " select * from $tmp_write_table where wr_is_comment = 0 order by wr_id desc limit 0, $rows ";
// 위의 코드 보다 속도가 빠름
$sql = " select * from $tmp_write_table where wr_is_comment = 0 order by wr_num limit 0, $rows ";
//explain($sql);
$result = sql_query($sql);
for ($i=0; $row = sql_fetch_array($result); $i++)
$list[$i] = get_list($row, $board, $latest_skin_path, $subject_len);
ob_start();
include "$latest_skin_path/latest.skin.php";
$content = ob_get_contents();
ob_end_clean();
return $content;
}
?>

173
lib/mailer.lib.php Normal file
View File

@ -0,0 +1,173 @@
<?
if (!defined("_GNUBOARD_")) exit;
// 메일 보내기 (파일 여러개 첨부 가능)
// type : text=0, html=1, text+html=2
function mailer($fname, $fmail, $to, $subject, $content, $type=0, $file="", $cc="", $bcc="")
{
global $config;
global $g4;
// 메일발송 사용을 하지 않는다면
if (!$config[cf_email_use]) return;
$fname = "=?$g4[charset]?B?" . base64_encode($fname) . "?=";
$subject = "=?$g4[charset]?B?" . base64_encode($subject) . "?=";
//$g4[charset] = ($g4[charset] != "") ? "charset=$g4[charset]" : "";
$header = "Return-Path: <$fmail>\n";
$header .= "From: $fname <$fmail>\n";
$header .= "Reply-To: <$fmail>\n";
if ($cc) $header .= "Cc: $cc\n";
if ($bcc) $header .= "Bcc: $bcc\n";
$header .= "MIME-Version: 1.0\n";
//$header .= "X-Mailer: SIR Mailer 0.91 (sir.co.kr) : $_SERVER[SERVER_ADDR] : $_SERVER[REMOTE_ADDR] : $g4[url] : $_SERVER[PHP_SELF] : $_SERVER[HTTP_REFERER] \n";
// UTF-8 관련 수정
$header .= "X-Mailer: SIR Mailer 0.92 (sir.co.kr) : $_SERVER[SERVER_ADDR] : $_SERVER[REMOTE_ADDR] : $g4[url] : $_SERVER[PHP_SELF] : $_SERVER[HTTP_REFERER] \n";
if ($file != "") {
$boundary = uniqid("http://sir.co.kr/");
$header .= "Content-type: MULTIPART/MIXED; BOUNDARY=\"$boundary\"\n\n";
$header .= "--$boundary\n";
}
if ($type) {
$header .= "Content-Type: TEXT/HTML; charset=$g4[charset]\n";
if ($type == 2)
$content = nl2br($content);
} else {
$header .= "Content-Type: TEXT/PLAIN; charset=$g4[charset]\n";
$content = stripslashes($content);
}
$header .= "Content-Transfer-Encoding: BASE64\n\n";
$header .= chunk_split(base64_encode($content)) . "\n";
if ($file != "") {
foreach ($file as $f) {
$header .= "\n--$boundary\n";
$header .= "Content-Type: APPLICATION/OCTET-STREAM; name=\"$f[name]\"\n";
$header .= "Content-Transfer-Encoding: BASE64\n";
$header .= "Content-Disposition: inline; filename=\"$f[name]\"\n";
$header .= "\n";
$header .= chunk_split(base64_encode($f[data]));
$header .= "\n";
}
$header .= "--$boundary--\n";
}
@mail($to, $subject, "", $header);
}
// 파일 첨부시
/*
$fp = fopen(__FILE__, "r");
$file[] = array(
"name"=>basename(__FILE__),
"data"=>fread($fp, filesize(__FILE__)));
fclose($fp);
*/
// 파일을 첨부함
function attach_file($filename, $file)
{
$fp = fopen($file, "r");
$tmpfile = array(
"name" => $filename,
"data" => fread($fp, filesize($file)));
fclose($fp);
return $tmpfile;
}
// 메일 유효성 검사
// core PHP Programming 책 참고
// hanmail.net , hotmail.com , kebi.com 등이 정상적이지 않음으로 사용 불가
function verify_email($address, &$error)
{
global $g4;
$WAIT_SECOND = 3; // ?초 기다림
list($user, $domain) = explode("@", $address);
// 도메인에 메일 교환기가 존재하는지 검사
if (checkdnsrr($domain, "MX")) {
// 메일 교환기 레코드들을 얻는다
if (!getmxrr($domain, $mxhost, $mxweight)) {
$error = "메일 교환기를 회수할 수 없음";
return false;
}
} else {
// 메일 교환기가 없으면, 도메인 자체가 편지를 받는 것으로 간주
$mxhost[] = $domain;
$mxweight[] = 1;
}
// 메일 교환기 호스트의 배열을 만든다.
for ($i=0; $i<count($mxhost); $i++)
$weighted_host[($mxweight[$i])] = $mxhost[$i];
ksort($weighted_host);
// 각 호스트를 검사
foreach($weighted_host as $host) {
// 호스트의 SMTP 포트에 연결
if (!($fp = @fsockopen($host, 25))) continue;
// 220 메세지들은 건너뜀
// 3초가 지나도 응답이 없으면 포기
socket_set_blocking($fp, false);
$stoptime = $g4[server_time] + $WAIT_SECOND;
$gotresponse = false;
while (true) {
// 메일서버로부터 한줄 얻음
$line = fgets($fp, 1024);
if (substr($line, 0, 3) == "220") {
// 타이머를 초기화
$stoptime = $g4[server_time] + $WAIT_SECOND;
$gotresponse = true;
} else if ($line == "" && $gotresponse)
break;
else if ($g4[server_time] > $stoptime)
break;
}
// 이 호스트는 응답이 없음. 다음 호스트로 넘어간다
if (!$gotresponse) continue;
socket_set_blocking($fp, true);
// SMTP 서버와의 대화를 시작
fputs($fp, "HELO $_SERVER[SERVER_NAME]\r\n");
echo "HELO $_SERVER[SERVER_NAME]\r\n";
fgets($fp, 1024);
// From을 설정
fputs($fp, "MAIL FROM: <info@$domain>\r\n");
echo "MAIL FROM: <info@$domain>\r\n";
fgets($fp, 1024);
// 주소를 시도
fputs($fp, "RCPT TO: <$address>\r\n");
echo "RCPT TO: <$address>\r\n";
$line = fgets($fp, 1024);
// 연결을 닫음
fputs($fp, "QUIT\r\n");
fclose($fp);
if (substr($line, 0, 3) != "250") {
// SMTP 서버가 이 주소를 인식하지 못하므로 잘못된 주소임
$error = $line;
return false;
} else
// 주소를 인식했음
return true;
}
$error = "메일 교환기에 도달하지 못하였습니다.";
return false;
}
?>

37
lib/outlogin.lib.php Normal file
View File

@ -0,0 +1,37 @@
<?
if (!defined('_GNUBOARD_')) exit;
// 외부로그인
function outlogin($skin_dir="basic")
{
global $config, $member, $g4, $urlencode, $is_admin;
$nick = cut_str($member['mb_nick'], $config['cf_cut_name']);
$point = number_format($member['mb_point']);
$outlogin_skin_path = "$g4[path]/skin/outlogin/$skin_dir";
// 읽지 않은 쪽지가 있다면
if ($member['mb_id']) {
$sql = " select count(*) as cnt from {$g4['memo_table']} where me_recv_mb_id = '{$member['mb_id']}' and me_read_datetime = '0000-00-00 00:00:00' ";
$row = sql_fetch($sql);
$memo_not_read = $row['cnt'];
$is_auth = false;
$sql = " select count(*) as cnt from $g4[auth_table] where mb_id = '$member[mb_id]' ";
$row = sql_fetch($sql);
if ($row['cnt'])
$is_auth = true;
}
ob_start();
if ($member['mb_id'])
include_once ("$outlogin_skin_path/outlogin.skin.2.php");
else // 로그인 전이라면
include_once ("$outlogin_skin_path/outlogin.skin.1.php");
$content = ob_get_contents();
ob_end_clean();
return $content;
}
?>

25
lib/poll.lib.php Normal file
View File

@ -0,0 +1,25 @@
<?
if (!defined('_GNUBOARD_')) exit;
// 설문조사
function poll($skin_dir="basic", $po_id=false)
{
global $config, $member, $g4;
// 투표번호가 넘어오지 않았다면 가장 큰(최근에 등록한) 투표번호를 얻는다
if (empty($po_id))
{
$po_id = $config['cf_max_po_id'];
if (empty($po_id))
return "<!-- po_id를 찾을 수 없습니다. -->";
}
ob_start();
$poll_skin_path = "$g4[path]/skin/poll/$skin_dir";
include_once ("$poll_skin_path/poll.skin.php");
$content = ob_get_contents();
ob_end_clean();
return $content;
}
?>

36
lib/popular.lib.php Normal file
View File

@ -0,0 +1,36 @@
<?
if (!defined('_GNUBOARD_')) exit;
// 인기검색어 출력
// $skin_dir : 스킨 디렉토리
// $pop_cnt : 검색어 몇개
// $date_cnt : 몇일 동안
function popular($skin_dir='basic', $pop_cnt=7, $date_cnt=3)
{
global $config, $g4;
if (!$skin_dir) $skin_dir = 'basic';
$date_gap = date("Y-m-d", $g4[server_time] - ($date_cnt * 86400));
$sql = " select pp_word, count(*) as cnt from $g4[popular_table]
where pp_date between '$date_gap' and '$g4[time_ymd]'
group by pp_word
order by cnt desc, pp_word
limit 0, $pop_cnt ";
$result = sql_query($sql);
for ($i=0; $row=sql_fetch_array($result); $i++)
{
$list[$i] = $row;
// 스크립트등의 실행금지
$list[$i][pp_word] = get_text($list[$i][pp_word]);
}
ob_start();
$popular_skin_path = "$g4[path]/skin/popular/$skin_dir";
include_once ("$popular_skin_path/popular.skin.php");
$content = ob_get_contents();
ob_end_clean();
return $content;
}
?>

77
lib/trackback.lib.php Normal file
View File

@ -0,0 +1,77 @@
<?
if (!defined('_GNUBOARD_')) exit;
/////////////////////////////////////////
// //
// mics'php - Trackback Sender //
// //
// COPYLEFT (c) by micsland.com //
// //
// MODIFIED (c) by sir.co.kr //
// //
/////////////////////////////////////////
// return 값이 있으면 오류, 없으면 정상
function send_trackback($tb_url, $url, $title, $blog_name, $excerpt)
{
/*
// allow_url_fopen = Off 일 경우 트랙백 사용할 수 없었던 오류를 수정
// allow_url_fopen = On 일 경우에만 사용 가능
//주소가 유효한지 검사
$p_fp = fopen($tb_url,"r");
if($p_fp)
@fclose($p_fp);
else
return "트랙백 URL이 존재하지 않습니다.";
*/
//내용 정리
$title = strip_tags($title);
$excerpt = strip_tags($excerpt);
$tmp_data = "url=".rawurlencode($url)."&title=".rawurlencode($title)."&blog_name=".rawurlencode($blog_name)."&excerpt=".rawurlencode($excerpt);
//주소 처리
$uinfo = parse_url($tb_url);
if($uinfo[query]) $tmp_data .= "&".$uinfo[query];
if(!$uinfo[port]) $uinfo[port] = "80";
//최종 전송 자료
$send_str = "POST ".$uinfo[path]." HTTP/1.1\r\n".
"Host: ".$uinfo[host]."\r\n".
"User-Agent: GNUBOARD\r\n".
"Content-Type: application/x-www-form-urlencoded\r\n".
"Content-length: ".strlen($tmp_data)."\r\n".
"Connection: close\r\n\r\n".
$tmp_data;
$fp = @fsockopen($uinfo[host],$uinfo[port]);
if(!$fp)
return "트랙백 URL이 존재하지 않습니다.";
//전송
//$fp = fsockopen($uinfo[host],$uinfo[port]);
fputs($fp,$send_str);
//응답 받음
while(!feof($fp)) $response .= fgets($fp,128);
fclose($fp);
//트랙백 URL인지 확인
if(!strstr($response,"<response>"))
return "올바른 트랙백 URL이 아닙니다.";
//XML 부분만 뽑음
$response = strchr($response,"<?");
$response = substr($response,0,strpos($response,"</response>"));
//에러 검사
if(strstr($response,"<error>0</error>"))
return "";
else {
$tb_error_str = strchr($response,"<message>");
$tb_error_str = substr($tb_error_str,0,strpos($tb_error_str,"</message>"));
$tb_error_str = str_replace("<message>","",$tb_error_str);
return "트랙백 전송중 오류가 발생했습니다: $tb_error_str";
}
}
?>

84
lib/visit.lib.php Normal file
View File

@ -0,0 +1,84 @@
<?
if (!defined('_GNUBOARD_')) exit;
// 방문자수 출력
function visit($skin_dir="basic")
{
global $config, $g4;
// visit 배열변수에
// $visit[1] = 오늘
// $visit[2] = 어제
// $visit[3] = 최대
// $visit[4] = 전체
// 숫자가 들어감
preg_match("/오늘:(.*),어제:(.*),최대:(.*),전체:(.*)/", $config['cf_visit'], $visit);
settype($visit[0], "integer");
settype($visit[1], "integer");
settype($visit[2], "integer");
settype($visit[3], "integer");
ob_start();
$visit_skin_path = "$g4[path]/skin/visit/$skin_dir";
include_once ("$visit_skin_path/visit.skin.php");
$content = ob_get_contents();
ob_end_clean();
return $content;
}
// get_browser() 함수는 이미 있음
function get_brow($agent)
{
$agent = strtolower($agent);
//echo $agent; echo "<br/>";
if (preg_match("/msie 5.0[0-9]*/", $agent)) { $s = "MSIE 5.0"; }
else if(preg_match("/msie 5.5[0-9]*/", $agent)) { $s = "MSIE 5.5"; }
else if(preg_match("/msie 6.0[0-9]*/", $agent)) { $s = "MSIE 6.0"; }
else if(preg_match("/msie 7.0[0-9]*/", $agent)) { $s = "MSIE 7.0"; }
else if(preg_match("/msie 8.0[0-9]*/", $agent)) { $s = "MSIE 8.0"; }
else if(preg_match("/msie 4.[0-9]*/", $agent)) { $s = "MSIE 4.x"; }
else if(preg_match("/firefox/", $agent)) { $s = "FireFox"; }
else if(preg_match("/chrome/", $agent)) { $s = "Chrome"; }
else if(preg_match("/x11/", $agent)) { $s = "Netscape"; }
else if(preg_match("/opera/", $agent)) { $s = "Opera"; }
else if(preg_match("/gec/", $agent)) { $s = "Gecko"; }
else if(preg_match("/bot|slurp/", $agent)) { $s = "Robot"; }
else if(preg_match("/internet explorer/", $agent)) { $s = "IE"; }
else if(preg_match("/mozilla/", $agent)) { $s = "Mozilla"; }
else { $s = "기타"; }
return $s;
}
function get_os($agent)
{
$agent = strtolower($agent);
//echo $agent; echo "<br/>";
if (preg_match("/windows 98/", $agent)) { $s = "98"; }
else if(preg_match("/windows 95/", $agent)) { $s = "95"; }
else if(preg_match("/windows nt 4\.[0-9]*/", $agent)) { $s = "NT"; }
else if(preg_match("/windows nt 5\.0/", $agent)) { $s = "2000"; }
else if(preg_match("/windows nt 5\.1/", $agent)) { $s = "XP"; }
else if(preg_match("/windows nt 5\.2/", $agent)) { $s = "2003"; }
else if(preg_match("/windows nt 6\.0/", $agent)) { $s = "Vista"; }
else if(preg_match("/windows nt 6\.1/", $agent)) { $s = "Windows7"; }
else if(preg_match("/windows 9x/", $agent)) { $s = "ME"; }
else if(preg_match("/windows ce/", $agent)) { $s = "CE"; }
else if(preg_match("/mac/", $agent)) { $s = "MAC"; }
else if(preg_match("/linux/", $agent)) { $s = "Linux"; }
else if(preg_match("/sunos/", $agent)) { $s = "sunOS"; }
else if(preg_match("/irix/", $agent)) { $s = "IRIX"; }
else if(preg_match("/phone/", $agent)) { $s = "Phone"; }
else if(preg_match("/bot|slurp/", $agent)) { $s = "Robot"; }
else if(preg_match("/internet explorer/", $agent)) { $s = "IE"; }
else if(preg_match("/mozilla/", $agent)) { $s = "Mozilla"; }
else { $s = "기타"; }
return $s;
}
?>