그누보드5
This commit is contained in:
2361
lib/common.lib.php
Normal file
2361
lib/common.lib.php
Normal file
File diff suppressed because it is too large
Load Diff
30
lib/connect.lib.php
Normal file
30
lib/connect.lib.php
Normal file
@ -0,0 +1,30 @@
|
||||
<?php
|
||||
if (!defined('_GNUBOARD_')) exit;
|
||||
|
||||
// 현재 접속자수 출력
|
||||
function connect($skin_dir='')
|
||||
{
|
||||
global $config, $g5;
|
||||
|
||||
// 회원, 방문객 카운트
|
||||
$sql = " select sum(IF(mb_id<>'',1,0)) as mb_cnt, count(*) as total_cnt from {$g5['login_table']} where mb_id <> '{$config['cf_admin']}' ";
|
||||
$row = sql_fetch($sql);
|
||||
|
||||
if (!$skin_dir)
|
||||
$skin_dir = $config['cf_connect_skin'];
|
||||
if(G5_IS_MOBILE) {
|
||||
$connect_skin_path = G5_MOBILE_PATH.'/'.G5_SKIN_DIR.'/connect/'.$skin_dir;
|
||||
$connect_skin_url = G5_MOBILE_URL.'/'.G5_SKIN_DIR.'/connect/'.$skin_dir;
|
||||
} else {
|
||||
$connect_skin_path = G5_SKIN_PATH.'/connect/'.$skin_dir;
|
||||
$connect_skin_url = G5_SKIN_URL.'/connect/'.$skin_dir;
|
||||
}
|
||||
|
||||
ob_start();
|
||||
include_once ($connect_skin_path.'/connect.skin.php');
|
||||
$content = ob_get_contents();
|
||||
ob_end_clean();
|
||||
|
||||
return $content;
|
||||
}
|
||||
?>
|
||||
27
lib/editor.lib.php
Normal file
27
lib/editor.lib.php
Normal file
@ -0,0 +1,27 @@
|
||||
<?php
|
||||
if (!defined('_GNUBOARD_')) exit; // 개별 페이지 접근 불가
|
||||
|
||||
/*
|
||||
환경설정에서 에디터 선택이 없는 경우에 사용하는 라이브러리 입니다.
|
||||
에디터 선택시 "선택없음"이 아닌 경우 plugin/editor 하위 디렉토리의 각 에디터이름/editor.lib.php 를 수정하시기 바랍니다.
|
||||
*/
|
||||
|
||||
function editor_html($id, $content)
|
||||
{
|
||||
return "<textarea id=\"$id\" name=\"$id\" style=\"width:100%;\" maxlength=\"65536\">$content</textarea>";
|
||||
}
|
||||
|
||||
|
||||
// textarea 로 값을 넘긴다. javascript 반드시 필요
|
||||
function get_editor_js($id)
|
||||
{
|
||||
return "var {$id}_editor = document.getElementById('{$id}');\n";
|
||||
}
|
||||
|
||||
|
||||
// textarea 의 값이 비어 있는지 검사
|
||||
function chk_editor_js($id)
|
||||
{
|
||||
return "if (!{$id}_editor.value) { alert(\"내용을 입력해 주십시오.\"); {$id}_editor.focus(); return false; }\n";
|
||||
}
|
||||
?>
|
||||
57
lib/latest.lib.php
Normal file
57
lib/latest.lib.php
Normal file
@ -0,0 +1,57 @@
|
||||
<?php
|
||||
if (!defined('_GNUBOARD_')) exit;
|
||||
|
||||
// 최신글 추출
|
||||
function latest($skin_dir='', $bo_table, $rows=10, $subject_len=40)
|
||||
{
|
||||
global $g5;
|
||||
static $css = array();
|
||||
|
||||
if (!$skin_dir) $skin_dir = 'basic';
|
||||
|
||||
if(G5_IS_MOBILE) {
|
||||
$latest_skin_path = G5_MOBILE_PATH.'/'.G5_SKIN_DIR.'/latest/'.$skin_dir;
|
||||
$latest_skin_url = G5_MOBILE_URL.'/'.G5_SKIN_DIR.'/latest/'.$skin_dir;
|
||||
} else {
|
||||
$latest_skin_path = G5_SKIN_PATH.'/latest/'.$skin_dir;
|
||||
$latest_skin_url = G5_SKIN_URL.'/latest/'.$skin_dir;
|
||||
}
|
||||
|
||||
$cache_file = G5_DATA_PATH."/cache/latest-{$bo_table}-{$skin_dir}-{$rows}-{$subject_len}.php";
|
||||
if (!G5_USE_CACHE || !file_exists($cache_file)) {
|
||||
$list = array();
|
||||
|
||||
$sql = " select * from {$g5['board_table']} where bo_table = '{$bo_table}' ";
|
||||
$board = sql_fetch($sql);
|
||||
|
||||
$tmp_write_table = $g5['write_prefix'] . $bo_table; // 게시판 테이블 전체이름
|
||||
$sql = " select * from {$tmp_write_table} where wr_is_comment = 0 order by wr_num limit 0, {$rows} ";
|
||||
$result = sql_query($sql);
|
||||
for ($i=0; $row = sql_fetch_array($result); $i++) {
|
||||
$list[$i] = get_list($row, $board, $latest_skin_url, $subject_len);
|
||||
}
|
||||
|
||||
$handle = fopen($cache_file, 'w');
|
||||
$cache_content = "<?php\nif (!defined('_GNUBOARD_')) exit;\n\$bo_subject=\"".get_text($board['bo_subject'])."\";\n\$list=".var_export($list, true)."?>";
|
||||
fwrite($handle, $cache_content);
|
||||
fclose($handle);
|
||||
}
|
||||
|
||||
include_once($cache_file);
|
||||
|
||||
/*
|
||||
// 같은 스킨은 .css 를 한번만 호출한다.
|
||||
if (!in_array($skin_dir, $css) && is_file($latest_skin_path.'/style.css')) {
|
||||
echo '<link rel="stylesheet" href="'.$latest_skin_url.'/style.css">';
|
||||
$css[] = $skin_dir;
|
||||
}
|
||||
*/
|
||||
|
||||
ob_start();
|
||||
include $latest_skin_path.'/latest.skin.php';
|
||||
$content = ob_get_contents();
|
||||
ob_end_clean();
|
||||
|
||||
return $content;
|
||||
}
|
||||
?>
|
||||
409
lib/mailer.lib.php
Normal file
409
lib/mailer.lib.php
Normal file
@ -0,0 +1,409 @@
|
||||
<?php
|
||||
if (!defined('_GNUBOARD_')) exit;
|
||||
|
||||
include_once(G5_PHPMAILER_PATH.'/class.phpmailer.php');
|
||||
|
||||
// 메일 보내기 (파일 여러개 첨부 가능)
|
||||
// type : text=0, html=1, text+html=2
|
||||
function mailer($fname, $fmail, $to, $subject, $content, $type=0, $file="", $cc="", $bcc="")
|
||||
{
|
||||
global $config;
|
||||
global $g5;
|
||||
|
||||
// 메일발송 사용을 하지 않는다면
|
||||
if (!$config['cf_email_use']) return;
|
||||
|
||||
if ($type != 1)
|
||||
$content = nl2br($content);
|
||||
|
||||
$mail = new PHPMailer(); // defaults to using php "mail()"
|
||||
if (defined('G5_SMTP')) {
|
||||
$mail->IsSMTP(); // telling the class to use SMTP
|
||||
$mail->Host = G5_SMTP; // SMTP server
|
||||
}
|
||||
$mail->From = $fmail;
|
||||
$mail->FromName = $fname;
|
||||
$mail->Subject = $subject;
|
||||
$mail->AltBody = ""; // optional, comment out and test
|
||||
$mail->MsgHTML($content);
|
||||
$mail->AddAddress($to);
|
||||
if ($cc)
|
||||
$mail->AddCC($cc);
|
||||
if ($bcc)
|
||||
$mail->AddBCC($bcc);
|
||||
//print_r2($file); exit;
|
||||
if ($file != "") {
|
||||
foreach ($file as $f) {
|
||||
$mail->AddAttachment($f['path'], $f['name']);
|
||||
}
|
||||
}
|
||||
return $mail->Send();
|
||||
}
|
||||
|
||||
// 파일을 첨부함
|
||||
function attach_file($filename, $tmp_name)
|
||||
{
|
||||
// 서버에 업로드 되는 파일은 확장자를 주지 않는다. (보안 취약점)
|
||||
$dest_file = G5_DATA_PATH.'/tmp/'.str_replace('/', '_', $tmp_name);
|
||||
move_uploaded_file($tmp_name, $dest_file);
|
||||
/*
|
||||
$fp = fopen($tmp_name, "r");
|
||||
$tmpfile = array(
|
||||
"name" => $filename,
|
||||
"tmp_name" => $tmp_name,
|
||||
"data" => fread($fp, filesize($tmp_name)));
|
||||
fclose($fp);
|
||||
*/
|
||||
$tmpfile = array("name" => $filename, "path" => $dest_file);
|
||||
return $tmpfile;
|
||||
}
|
||||
|
||||
/*
|
||||
// 메일 보내기 (파일 여러개 첨부 가능)
|
||||
// type : text=0, html=1, text+html=2
|
||||
function mailer($fname, $fmail, $to, $subject, $content, $type=0, $file="", $cc="", $bcc="")
|
||||
{
|
||||
global $config;
|
||||
global $g5;
|
||||
|
||||
// 메일발송 사용을 하지 않는다면
|
||||
if (!$config['cf_email_use']) return;
|
||||
|
||||
$boundary = uniqid(time());
|
||||
|
||||
$header = "Message-ID: <".generate_mail_id(preg_replace("/@.+$/i","",$to)).">\r\n".
|
||||
"From:=?utf-8?B?".base64_encode($fname)."?=<$fmail>\r\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.94 : {$_SERVER['SERVER_ADDR']} : {$_SERVER['REMOTE_ADDR']} : ".G5_URL." : {$_SERVER['PHP_SELF']} : {$_SERVER['HTTP_REFERER']} \n";
|
||||
$header .= "Date: ".date ("D, j M Y H:i:s T",time())."\r\n".
|
||||
"To: $to\r\n".
|
||||
"Subject: =?utf-8?B?".base64_encode($subject)."?=\r\n";
|
||||
|
||||
if ($file == "") {
|
||||
$header .= "Content-Type: MULTIPART/ALTERNATIVE;\n".
|
||||
" BOUNDARY=\"$boundary\"\n\n";
|
||||
} else {
|
||||
$header .= "Content-Type: MULTIPART/MIXED;\n".
|
||||
" BOUNDARY=\"$boundary\"\n\n";
|
||||
}
|
||||
|
||||
if ($type == 2)
|
||||
$content = nl2br($content);
|
||||
|
||||
$strip_content = stripslashes(trim($content));
|
||||
$encode_content = chunk_split(base64_encode($strip_content));
|
||||
|
||||
$body = "";
|
||||
$body .= "\n--$boundary\n";
|
||||
$body .= "Content-Type: TEXT/PLAIN; charset=utf-8\n";
|
||||
$body .= "Content-Transfer-Encoding: BASE64\n\n";
|
||||
$body .= $encode_content;
|
||||
$body .= "\n--$boundary\n";
|
||||
|
||||
if ($type) {
|
||||
$body .= "Content-Type: TEXT/HTML; charset=utf-8\n";
|
||||
$body .= "Content-Transfer-Encoding: BASE64\n\n";
|
||||
$body .= $encode_content;
|
||||
$body .= "\n--$boundary\n";
|
||||
}
|
||||
|
||||
if ($file != "") {
|
||||
foreach ($file as $f) {
|
||||
$body .= "n--$boundary\n";
|
||||
$body .= "Content-Type: APPLICATION/OCTET-STREAM; name=$fname\n";
|
||||
$body .= "Content-Transfer-Encoding: BASE64\n";
|
||||
$body .= "Content-Disposition: inline; filename=$fname\n";
|
||||
|
||||
$body .= "\n";
|
||||
$body .= chunk_split(base64_encode($f['data']));
|
||||
$body .= "\n";
|
||||
}
|
||||
$body .= "--$boundary--\n";
|
||||
}
|
||||
|
||||
$mails['to'] = $to;
|
||||
$mails['from'] = $fmail;
|
||||
$mails['text'] = $header.$body;
|
||||
|
||||
if (defined(G5_SMTP)) {
|
||||
ini_set('SMTP', G5_SMTP);
|
||||
@mail($to, $subject, $body, $header, "-f $fmail");
|
||||
} else {
|
||||
new maildaemon($mails);
|
||||
}
|
||||
}
|
||||
|
||||
// 파일 첨부시
|
||||
$fp = fopen(__FILE__, "r");
|
||||
$file[] = array(
|
||||
"name"=>basename(__FILE__),
|
||||
"data"=>fread($fp, filesize(__FILE__)));
|
||||
fclose($fp);
|
||||
|
||||
// 메일 유효성 검사
|
||||
// core PHP Programming 책 참고
|
||||
// hanmail.net , hotmail.com , kebi.com 등이 정상적이지 않음으로 사용 불가
|
||||
function verify_email($address, &$error)
|
||||
{
|
||||
global $g5;
|
||||
|
||||
$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 = G5_SERVER_TIME + $WAIT_SECOND;
|
||||
$gotresponse = false;
|
||||
|
||||
while (true) {
|
||||
// 메일서버로부터 한줄 얻음
|
||||
$line = fgets($fp, 1024);
|
||||
|
||||
if (substr($line, 0, 3) == '220') {
|
||||
// 타이머를 초기화
|
||||
$stoptime = G5_SERVER_TIME + $WAIT_SECOND;
|
||||
$gotresponse = true;
|
||||
} else if ($line == '' && $gotresponse)
|
||||
break;
|
||||
else if (G5_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;
|
||||
}
|
||||
|
||||
|
||||
# jsboard 의 메일보내기 class를 추가합니다. 130808
|
||||
# http://kldp.net/projects/jsboard/
|
||||
|
||||
# mail 보내기 함수 2001.11.30 김정균
|
||||
# $Id: include/sendmail.php,v 1.4 2009/11/19 05:29:51 oops Exp $
|
||||
|
||||
# 서버상의 smtp daemon 에 의존하지 않고 직접 발송하는 smtp class
|
||||
#
|
||||
# 특정 배열로 class 에 전달을 하여 메일을 발송한다. 배열은 아래을 참조한다.
|
||||
#
|
||||
# debug -> debug 를 할지 안할지를 결정한다.
|
||||
# ofhtml -> 웹상에서 사용할지 쉘상에서 사용할지를 결정한다.
|
||||
# from -> 메일을 발송하는 사람의 메일주소
|
||||
# to -> 메일을 받을 사람의 메일 주소
|
||||
# text -> 헤더 내용을 포함한 메일 본문
|
||||
#
|
||||
class maildaemon {
|
||||
var $failed = 0;
|
||||
|
||||
function __construct($v) {
|
||||
$this->debug = $v['debug'];
|
||||
$this->ofhtml = $v['ofhtml'];
|
||||
if($_SERVER['SERVER_NAME']) $this->helo = $_SERVER['SERVER_NAME'];
|
||||
if(!$this->helo || preg_match("/^[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}$/i",$this->helo))
|
||||
$this->helo = "JSBoardMessage";
|
||||
|
||||
$this->from = $v['from'];
|
||||
$this->to = $v['to'];
|
||||
$this->body = $v['text']."\r\n.";
|
||||
|
||||
//die($v['text']);
|
||||
$this->newline = $this->ofhtml ? "<br>\n" : "\n";
|
||||
|
||||
$this->mx = $this->getMX($this->to);
|
||||
|
||||
if($this->debug) {
|
||||
echo "DEBUG: ".$this->mx." start".$this->newline;
|
||||
echo "################################################################".$this->newline;
|
||||
}
|
||||
$this->sockets("open");
|
||||
$this->send("HELO ".$this->helo);
|
||||
$this->send("MAIL FROM: <".$this->from.">");
|
||||
$this->send("RCPT TO: <".$this->to.">");
|
||||
$this->send("data");
|
||||
$this->send($this->body);
|
||||
$this->send("quit");
|
||||
$this->sockets("close");
|
||||
}
|
||||
|
||||
function getMX($email) {
|
||||
$dev = explode("@",$email);
|
||||
$account = $dev[0];
|
||||
$host = $dev[1];
|
||||
|
||||
if(checkdnsrr($host,"MX") && getmxrr($host,$mx,$weight)) {
|
||||
$idx = 0;
|
||||
for($i=0;$i<sizeof($mx);$i++) {
|
||||
$dest = $dest ? $dest : $weight[$i];
|
||||
if($dest > $weight[$i]) {
|
||||
$dest = $weight[$i];
|
||||
$idx = $i;
|
||||
}
|
||||
}
|
||||
} else return $host;
|
||||
return $mx[$idx];
|
||||
}
|
||||
|
||||
# 디버그 함수
|
||||
# $t -> 1 (debug of socket open,close)
|
||||
# 0 (regular smtp message)
|
||||
# $p -> 1 (print detail debug)
|
||||
#
|
||||
# return 1 -> success
|
||||
# return 0 -> failed
|
||||
#
|
||||
function debug($str,$t=0,$p=0) {
|
||||
if($t) {
|
||||
if(!$str) $this->failed = 1;
|
||||
if($this->sock) $returnmsg = trim(fgets($this->sock,1024));
|
||||
} else {
|
||||
if(!preg_match("/^(220|221|250|251|354)$/",substr(trim($str),0,3)))
|
||||
$this->failed = 1;
|
||||
}
|
||||
|
||||
# DEBUG mode -> 모든 메세지 출력
|
||||
if($p) {
|
||||
if($t) {
|
||||
$str = "Conncet ".$this->mx;
|
||||
$str .= $this->failed ? " Failed" : " Success";
|
||||
$str .= $this->newline."DEBUG: $returnmsg";
|
||||
}
|
||||
echo "DEBUG: $str".$this->newline;
|
||||
}
|
||||
|
||||
# DEBUG 모드가 아닐때, 에러 메세지 출력
|
||||
if(!$p && $this->failed) {
|
||||
if($this->ofhtml) echo "<SCRIPT>\nalert('$str')\n</SCRIPT>\n";
|
||||
else "ERROR: $str\n";
|
||||
}
|
||||
}
|
||||
|
||||
function sockets($option=0) {
|
||||
switch($option) {
|
||||
case "open" :
|
||||
$this->sock = @fsockopen($this->mx,25,$this->errno,$this->errstr,30);
|
||||
$this->debug($this->sock,1,$this->debug);
|
||||
break;
|
||||
default :
|
||||
if($this->sock) fclose($this->sock);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
function send($str,$chk=0) {
|
||||
if(!$this->failed) {
|
||||
if($this->debug) {
|
||||
if(preg_match("/\r\n/",trim($str)))
|
||||
$str_debug = trim(str_replace("\r\n","\r\n ",$str));
|
||||
else $str_debug = $str;
|
||||
}
|
||||
fputs($this->sock,"$str\r\n");
|
||||
$recv = trim(fgets($this->sock,1024));
|
||||
$recvchk = $recv;
|
||||
$this->debug($recv,0,$this->debug);
|
||||
|
||||
if(preg_match("/Mail From:/i",$str) && preg_match("/exist|require|error/i",$recvchk) && !$chk) {
|
||||
$this->failed = 0;
|
||||
$this->send("MAIL FROM: <".$this->to.">",1);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
function generate_mail_id($uid) {
|
||||
$id = date("YmdHis",time());
|
||||
mt_srand((float) microtime() * 1000000);
|
||||
$randval = mt_rand();
|
||||
$id .= $randval."@$uid";
|
||||
return $id;
|
||||
}
|
||||
|
||||
|
||||
function mail_header($to,$from,$title,$mta=0) {
|
||||
global $langs,$boundary;
|
||||
|
||||
# mail header 를 작성
|
||||
$boundary = get_boundary_msg();
|
||||
$header = "Message-ID: <".generate_mail_id(preg_replace("/@.+$/i","",$to)).">\r\n".
|
||||
"From:=?utf-8?B?".base64_encode('보내는사람')."?=<$from>\r\n".
|
||||
"MIME-Version: 1.0\r\n";
|
||||
|
||||
if(!$mta) $header .= "Date: ".date ("D, j M Y H:i:s T",time())."\r\n".
|
||||
"To: $to\r\n".
|
||||
"Subject: $title\r\n";
|
||||
|
||||
$header .= "Content-Type: multipart/alternative;\r\n".
|
||||
" boundary=\"$boundary\"\r\n\r\n";
|
||||
|
||||
return $header;
|
||||
}
|
||||
|
||||
|
||||
function get_boundary_msg() {
|
||||
$uniqchr = uniqid("");
|
||||
$one = strtoupper($uniqchr[0]);
|
||||
$two = strtoupper(substr($uniqchr,0,8));
|
||||
$three = strtoupper(substr(strrev($uniqchr),0,8));
|
||||
return "----=_NextPart_000_000${one}_${two}.${three}";
|
||||
}
|
||||
*/
|
||||
?>
|
||||
145
lib/mobile.lib.php
Normal file
145
lib/mobile.lib.php
Normal file
@ -0,0 +1,145 @@
|
||||
<?php
|
||||
if (!defined('_GNUBOARD_')) exit;
|
||||
|
||||
// 원본 이미지를 넘기면 비율에 따라 썸네일 이미지를 생성함
|
||||
function mobile_create_thumb($srcImg, $width, $thumb)
|
||||
{
|
||||
$size = @getimagesize($srcImg);
|
||||
if ($size[2] == 1)
|
||||
$source = @imagecreatefromgif($srcImg);
|
||||
else if ($size[2] == 2)
|
||||
$source = @imagecreatefromjpeg($srcImg);
|
||||
else if ($size[2] == 3)
|
||||
$source = @imagecreatefrompng($srcImg);
|
||||
else
|
||||
return "";
|
||||
|
||||
if (!$source)
|
||||
return "";
|
||||
|
||||
if ($size[0] < $width) {
|
||||
$width = $size[0];
|
||||
$height = $size[1];
|
||||
}
|
||||
else {
|
||||
$rate = $width / $size[0];
|
||||
$height = (int)($size[1] * $rate);
|
||||
}
|
||||
|
||||
$target = @imagecreatetruecolor($width, $height);
|
||||
$bgcolor = @imagecolorallocate($target, 255, 255, 255); // 썸네일 배경
|
||||
imagefilledrectangle($target, 0, 0, $width, $height, $bgcolor);
|
||||
imagecopyresampled($source, $source, 0, 0, 0, 0, $width, $height, $size[0], $size[1]);
|
||||
imagecopy($target, $source, 0, 0, 0, 0, $size[0], $size[1]);
|
||||
|
||||
imagejpeg($target, $thumb, 100);
|
||||
chmod($thumb, G5_FILE_PERMISSION); // 추후 삭제를 위하여 파일모드 변경
|
||||
|
||||
return $thumb;
|
||||
}
|
||||
|
||||
|
||||
function mobile_thumb($matches)
|
||||
{
|
||||
global $is_admin;
|
||||
global $g5, $bo_table, $wr_id;
|
||||
|
||||
$width = 300; // (소스이미지 width pixel)
|
||||
|
||||
//if ($is_admin) print_r2($matches);
|
||||
|
||||
if ($is_admin) {
|
||||
foreach ($matches as $img) {
|
||||
echo "<p>";
|
||||
|
||||
preg_match("/src=[\"\']?([^\"\'\s>]+)/i", $img, $m);
|
||||
$src = trim($m[1]);
|
||||
//echo $src;
|
||||
|
||||
// 상대경로(..)로 시작되면 sir.co.kr 도메인으로 여긴다.
|
||||
$src = preg_replace("/^\.\.\//", "http://m.sir.co.kr/", $src);
|
||||
$absolute = preg_replace("/^http\:\/\/(www\.)?sir\.co\.kr\/(.*)$/", "/home/sir/$2", $src);
|
||||
|
||||
$thumb_dir = G5_DATA_PATH.'/thumb/'.$bo_table;
|
||||
if (!is_dir($thumb_dir)) {
|
||||
@mkdir($thumb_dir, G5_DIR_PERMISSION);
|
||||
@chmod($thumb_dir, G5_DIR_PERMISSION);
|
||||
}
|
||||
|
||||
$result = true;
|
||||
|
||||
if (preg_match("/\.(jpe?g|png)$/i", $src)) {
|
||||
// 유일한 파일명을 만든다.
|
||||
$src_md5 = md5($src.$width);
|
||||
$thumb = "$thumb_dir/{$wr_id}-{$src_md5}";
|
||||
|
||||
if (!file_exists($thumb)) {
|
||||
$result = mobile_create_thumb($src, $width, $thumb);
|
||||
}
|
||||
}
|
||||
else {
|
||||
$thumb = $src;
|
||||
}
|
||||
|
||||
if ($result) {
|
||||
$size = @getimagesize($absolute);
|
||||
if ($size[2] == IMAGETYPE_GIF)
|
||||
$w = ($size[0] < $width) ? $size[0] : $width;
|
||||
else
|
||||
$w = ($size[0] < $width) ? $size[0] : "100%";
|
||||
return "<img src='$thumb' width='$w' />";
|
||||
}
|
||||
}
|
||||
} else {
|
||||
|
||||
foreach ($matches as $img) {
|
||||
preg_match("/src=[\"\']?([^\"\'\s>]+)/i", $img, $m);
|
||||
|
||||
$result = true;
|
||||
|
||||
$src = trim($m[1]);
|
||||
//if ($is_admin) echo $src."<br>";
|
||||
if (preg_match("/\.(jpe?g|png)$/i", $src)) {
|
||||
// 상대경로(..)로 시작되면 도메인으로 여긴다.
|
||||
$src = preg_replace("/^\.\.\//", 'http://'.$_SERVER['SERVER_NAME'].'/', $src);
|
||||
|
||||
// 유일한 파일명을 만든다.
|
||||
$src_md5 = md5($src.$width);
|
||||
$thumb = G5_DATA_PATH.'/thumb/'.$bo_table.'-'.$wr_id.'-'.$src_md5;
|
||||
|
||||
if (!file_exists($thumb)) {
|
||||
$result = mobile_create_thumb($src, $width, $thumb);
|
||||
}
|
||||
}
|
||||
else {
|
||||
$thumb = $src;
|
||||
}
|
||||
|
||||
if ($result) {
|
||||
//if ($is_admin) { $begin_time = get_microtime(); }
|
||||
//echo $thumb;
|
||||
$size = @getimagesize($thumb);
|
||||
//if ($is_admin) print_r2($size);
|
||||
if ($size[2] == IMAGETYPE_GIF)
|
||||
$w = ($size[0] < $width) ? $size[0] : $width;
|
||||
else
|
||||
$w = ($size[0] < $width) ? $size[0] : "100%";
|
||||
//if ($is_admin) { echo "<p>time : "; echo get_microtime() - $begin_time; }
|
||||
return "<img src='$thumb' width='$w' />";
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
function mobile_embed($matches)
|
||||
{
|
||||
foreach ($matches as $embed) {
|
||||
//$embed = preg_replace("#height\=\d+#i", "", $embed);
|
||||
//$embed = preg_replace("#width\=\d+#i", "", $embed);
|
||||
|
||||
return $embed;
|
||||
}
|
||||
}
|
||||
?>
|
||||
50
lib/outlogin.lib.php
Normal file
50
lib/outlogin.lib.php
Normal file
@ -0,0 +1,50 @@
|
||||
<?php
|
||||
if (!defined('_GNUBOARD_')) exit;
|
||||
|
||||
// 외부로그인
|
||||
function outlogin($skin_dir='basic')
|
||||
{
|
||||
global $config, $member, $g5, $urlencode, $is_admin, $is_member;
|
||||
|
||||
if (array_key_exists('mb_nick', $member)) {
|
||||
$nick = cut_str($member['mb_nick'], $config['cf_cut_name']);
|
||||
}
|
||||
if (array_key_exists('mb_point', $member)) {
|
||||
$point = number_format($member['mb_point']);
|
||||
}
|
||||
|
||||
if (G5_IS_MOBILE) {
|
||||
$outlogin_skin_path = G5_MOBILE_PATH.'/'.G5_SKIN_DIR.'/outlogin/'.$skin_dir;
|
||||
$outlogin_skin_url = G5_MOBILE_URL.'/'.G5_SKIN_DIR.'/outlogin/'.$skin_dir;
|
||||
} else {
|
||||
$outlogin_skin_path = G5_SKIN_PATH.'/outlogin/'.$skin_dir;
|
||||
$outlogin_skin_url = G5_SKIN_URL.'/outlogin/'.$skin_dir;
|
||||
}
|
||||
|
||||
// 읽지 않은 쪽지가 있다면
|
||||
if ($is_member) {
|
||||
$sql = " select count(*) as cnt from {$g5['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 {$g5['auth_table']} where mb_id = '{$member['mb_id']}' ";
|
||||
$row = sql_fetch($sql);
|
||||
if ($row['cnt'])
|
||||
$is_auth = true;
|
||||
}
|
||||
|
||||
$outlogin_url = login_url();
|
||||
$outlogin_action_url = G5_HTTPS_BBS_URL.'/login_check.php';
|
||||
|
||||
ob_start();
|
||||
if ($is_member)
|
||||
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;
|
||||
}
|
||||
?>
|
||||
34
lib/poll.lib.php
Normal file
34
lib/poll.lib.php
Normal file
@ -0,0 +1,34 @@
|
||||
<?php
|
||||
if (!defined('_GNUBOARD_')) exit;
|
||||
|
||||
// 설문조사
|
||||
function poll($skin_dir='basic', $po_id=false)
|
||||
{
|
||||
global $config, $member, $g5, $is_admin;
|
||||
|
||||
// 투표번호가 넘어오지 않았다면 가장 큰(최근에 등록한) 투표번호를 얻는다
|
||||
if (!$po_id) {
|
||||
$row = sql_fetch(" select MAX(po_id) as max_po_id from {$g5['poll_table']} ");
|
||||
$po_id = $row['max_po_id'];
|
||||
}
|
||||
|
||||
if(!$po_id)
|
||||
return;
|
||||
|
||||
$po = sql_fetch(" select * from {$g5['poll_table']} where po_id = '$po_id' ");
|
||||
|
||||
ob_start();
|
||||
if (G5_IS_MOBILE) {
|
||||
$poll_skin_path = G5_MOBILE_PATH.'/'.G5_SKIN_DIR.'/poll/'.$skin_dir;
|
||||
$poll_skin_url = G5_MOBILE_URL.'/'.G5_SKIN_DIR.'/poll/'.$skin_dir;
|
||||
} else {
|
||||
$poll_skin_path = G5_SKIN_PATH.'/poll/'.$skin_dir;
|
||||
$poll_skin_url = G5_SKIN_URL.'/poll/'.$skin_dir;
|
||||
}
|
||||
include_once ($poll_skin_path.'/poll.skin.php');
|
||||
$content = ob_get_contents();
|
||||
ob_end_clean();
|
||||
|
||||
return $content;
|
||||
}
|
||||
?>
|
||||
37
lib/popular.lib.php
Normal file
37
lib/popular.lib.php
Normal file
@ -0,0 +1,37 @@
|
||||
<?php
|
||||
if (!defined('_GNUBOARD_')) exit;
|
||||
|
||||
// 인기검색어 출력
|
||||
// $skin_dir : 스킨 디렉토리
|
||||
// $pop_cnt : 검색어 몇개
|
||||
// $date_cnt : 몇일 동안
|
||||
function popular($skin_dir='basic', $pop_cnt=7, $date_cnt=3)
|
||||
{
|
||||
global $config, $g5;
|
||||
|
||||
if (!$skin_dir) $skin_dir = 'basic';
|
||||
|
||||
$date_gap = date("Y-m-d", G5_SERVER_TIME - ($date_cnt * 86400));
|
||||
$sql = " select pp_word, count(*) as cnt from {$g5['popular_table']} where pp_date between '$date_gap' and '".G5_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();
|
||||
if(G5_IS_MOBILE) {
|
||||
$popular_skin_path = G5_MOBILE_PATH.'/'.G5_SKIN_DIR.'/popular/'.$skin_dir;
|
||||
$popular_skin_url = G5_MOBILE_URL.'/'.G5_SKIN_DIR.'/popular/'.$skin_dir;
|
||||
} else {
|
||||
$popular_skin_path = G5_SKIN_PATH.'/popular/'.$skin_dir;
|
||||
$popular_skin_url = G5_SKIN_URL.'/popular/'.$skin_dir;
|
||||
}
|
||||
include_once ($popular_skin_path.'/popular.skin.php');
|
||||
$content = ob_get_contents();
|
||||
ob_end_clean();
|
||||
|
||||
return $content;
|
||||
}
|
||||
?>
|
||||
181
lib/register.lib.php
Normal file
181
lib/register.lib.php
Normal file
@ -0,0 +1,181 @@
|
||||
<?php
|
||||
if (!defined('_GNUBOARD_')) exit;
|
||||
|
||||
function empty_mb_id($reg_mb_id)
|
||||
{
|
||||
if (trim($reg_mb_id)=='')
|
||||
return "회원아이디를 입력해 주십시오.";
|
||||
else
|
||||
return "";
|
||||
}
|
||||
|
||||
function valid_mb_id($reg_mb_id)
|
||||
{
|
||||
if (preg_match("/[^0-9a-z_]+/i", $reg_mb_id))
|
||||
return "회원아이디는 영문자, 숫자, _ 만 입력하세요.";
|
||||
else
|
||||
return "";
|
||||
}
|
||||
|
||||
function count_mb_id($reg_mb_id)
|
||||
{
|
||||
if (strlen($reg_mb_id) < 3)
|
||||
return "회원아이디는 최소 3글자 이상 입력하세요.";
|
||||
else
|
||||
return "";
|
||||
}
|
||||
|
||||
function exist_mb_id($reg_mb_id)
|
||||
{
|
||||
global $g5;
|
||||
|
||||
$reg_mb_id = trim($reg_mb_id);
|
||||
if ($reg_mb_id == "") return "";
|
||||
|
||||
$sql = " select count(*) as cnt from `{$g5['member_table']}` where mb_id = '$reg_mb_id' ";
|
||||
$row = sql_fetch($sql);
|
||||
if ($row['cnt'])
|
||||
return "이미 사용중인 회원아이디 입니다.";
|
||||
else
|
||||
return "";
|
||||
}
|
||||
|
||||
function reserve_mb_id($reg_mb_id)
|
||||
{
|
||||
global $config;
|
||||
if (preg_match("/[\,]?{$reg_mb_id}/i", $config['cf_prohibit_id']))
|
||||
return "이미 예약된 단어로 사용할 수 없는 회원아이디 입니다.";
|
||||
else
|
||||
return "";
|
||||
}
|
||||
|
||||
function empty_mb_nick($reg_mb_nick)
|
||||
{
|
||||
if (!trim($reg_mb_nick))
|
||||
return "별명을 입력해 주십시오.";
|
||||
else
|
||||
return "";
|
||||
}
|
||||
|
||||
function valid_mb_nick($reg_mb_nick)
|
||||
{
|
||||
if (!check_string($reg_mb_nick, G5_HANGUL + G5_ALPHABETIC + G5_NUMERIC))
|
||||
return "별명은 공백없이 한글, 영문, 숫자만 입력 가능합니다.";
|
||||
else
|
||||
return "";
|
||||
}
|
||||
|
||||
function count_mb_nick($reg_mb_nick)
|
||||
{
|
||||
if (strlen($reg_mb_nick) < 4)
|
||||
return "별명은 한글 2글자, 영문 4글자 이상 입력 가능합니다.";
|
||||
else
|
||||
return "";
|
||||
}
|
||||
|
||||
function exist_mb_nick($reg_mb_nick, $reg_mb_id)
|
||||
{
|
||||
global $g5;
|
||||
$row = sql_fetch(" select count(*) as cnt from {$g5['member_table']} where mb_nick = '$reg_mb_nick' and mb_id <> '$reg_mb_id' ");
|
||||
if ($row['cnt'])
|
||||
return "이미 존재하는 별명입니다.";
|
||||
else
|
||||
return "";
|
||||
}
|
||||
|
||||
function reserve_mb_nick($reg_mb_nick)
|
||||
{
|
||||
global $config;
|
||||
if (preg_match("/[\,]?{$reg_mb_nick}/i", $config['cf_prohibit_id']))
|
||||
return "이미 예약된 단어로 사용할 수 없는 별명 입니다.";
|
||||
else
|
||||
return "";
|
||||
}
|
||||
|
||||
function empty_mb_email($reg_mb_email)
|
||||
{
|
||||
if (!trim($reg_mb_email))
|
||||
return "E-mail 주소를 입력해 주십시오.";
|
||||
else
|
||||
return "";
|
||||
}
|
||||
|
||||
function valid_mb_email($reg_mb_email)
|
||||
{
|
||||
if (!preg_match("/([0-9a-zA-Z_-]+)@([0-9a-zA-Z_-]+)\.([0-9a-zA-Z_-]+)/", $reg_mb_email))
|
||||
return "E-mail 주소가 형식에 맞지 않습니다.";
|
||||
else
|
||||
return "";
|
||||
}
|
||||
|
||||
// 금지 메일 도메인 검사
|
||||
function prohibit_mb_email($reg_mb_email)
|
||||
{
|
||||
global $config;
|
||||
list($id, $domain) = explode("@", $reg_mb_email);
|
||||
$email_domains = explode("\n", trim($config['cf_prohibit_email']));
|
||||
for ($i=0; $i<count($email_domains); $i++) {
|
||||
if (strtolower($domain) == strtolower($email_domains[$i]))
|
||||
return "$domain 메일은 사용할 수 없습니다.";
|
||||
}
|
||||
return "";
|
||||
}
|
||||
|
||||
function exist_mb_email($reg_mb_email, $reg_mb_id)
|
||||
{
|
||||
global $g5;
|
||||
$row = sql_fetch(" select count(*) as cnt from `{$g5['member_table']}` where mb_email = '$reg_mb_email' and mb_id <> '$reg_mb_id' ");
|
||||
if ($row['cnt'])
|
||||
return "이미 사용중인 E-mail 주소입니다.";
|
||||
else
|
||||
return "";
|
||||
}
|
||||
|
||||
function empty_mb_name($reg_mb_name)
|
||||
{
|
||||
if (!trim($reg_mb_name))
|
||||
return "이름을 입력해 주십시오.";
|
||||
else
|
||||
return "";
|
||||
}
|
||||
|
||||
function valid_mb_name($mb_name)
|
||||
{
|
||||
if (!check_string($mb_name, G5_HANGUL))
|
||||
return "이름은 공백없이 한글만 입력 가능합니다.";
|
||||
else
|
||||
return "";
|
||||
}
|
||||
|
||||
function valid_mb_hp($reg_mb_hp)
|
||||
{
|
||||
$reg_mb_hp = preg_replace("/[^0-9]/", "", $reg_mb_hp);
|
||||
if(!$reg_mb_hp)
|
||||
return "휴대폰번호를 입력해 주십시오.";
|
||||
else {
|
||||
if(preg_match("/^01[0-9]{8,9}$/", $reg_mb_hp))
|
||||
return "";
|
||||
else
|
||||
return "휴대폰번호를 올바르게 입력해 주십시오.";
|
||||
}
|
||||
}
|
||||
|
||||
function exist_mb_hp($reg_mb_hp, $reg_mb_id)
|
||||
{
|
||||
global $g5;
|
||||
|
||||
if (!trim($reg_mb_hp)) return "";
|
||||
|
||||
$reg_mb_hp = hyphen_hp_number($reg_mb_hp);
|
||||
|
||||
$sql = "select count(*) as cnt from {$g5['member_table']} where mb_hp = '$reg_mb_hp' and mb_id <> '$reg_mb_id' ";
|
||||
$row = sql_fetch($sql);
|
||||
|
||||
if($row['cnt'])
|
||||
return " 이미 사용 중인 휴대폰번호입니다. ".$reg_mb_hp;
|
||||
else
|
||||
return "";
|
||||
}
|
||||
|
||||
return;
|
||||
?>
|
||||
498
lib/thumbnail.lib.php
Normal file
498
lib/thumbnail.lib.php
Normal file
@ -0,0 +1,498 @@
|
||||
<?php
|
||||
if (!defined('_GNUBOARD_')) exit;
|
||||
|
||||
@ini_set('memory_limit', '512M');
|
||||
|
||||
// 게시글리스트 썸네일 생성
|
||||
function get_list_thumbnail($bo_table, $wr_id, $thumb_width, $thumb_height, $is_create=false, $is_crop=true, $crop_mode='center', $is_sharpen=true, $um_value='80/0.5/3')
|
||||
{
|
||||
global $g5, $config;
|
||||
$filename = $alt = "";
|
||||
$edt = false;
|
||||
|
||||
$sql = " select bf_file, bf_content from {$g5['board_file_table']}
|
||||
where bo_table = '$bo_table' and wr_id = '$wr_id' and bf_type between '1' and '3' order by bf_no limit 0, 1 ";
|
||||
$row = sql_fetch($sql);
|
||||
|
||||
if($row['bf_file']) {
|
||||
$filename = $row['bf_file'];
|
||||
$filepath = G5_DATA_PATH.'/file/'.$bo_table;
|
||||
$alt = get_text($row['bf_content']);
|
||||
} else {
|
||||
$write_table = $g5['write_prefix'].$bo_table;
|
||||
$sql = " select wr_content from $write_table where wr_id = '$wr_id' ";
|
||||
$write = sql_fetch($sql);
|
||||
$matchs = get_editor_image($write['wr_content']);
|
||||
$edt = true;
|
||||
|
||||
for($i=0; $i<count($matchs[1]); $i++)
|
||||
{
|
||||
// 이미지 path 구함
|
||||
$p = parse_url($matchs[1][$i]);
|
||||
if(strpos($p['path'], "/data/") != 0)
|
||||
$data_path = preg_replace("/^\/.*\/data/", "/data", $p['path']);
|
||||
else
|
||||
$data_path = $p['path'];
|
||||
|
||||
if(!preg_match('/^\/'.G5_DATA_DIR.'/', $data_path))
|
||||
continue;
|
||||
|
||||
$srcfile = G5_PATH.$data_path;
|
||||
|
||||
if(preg_match("/\.({$config['cf_image_extension']})$/i", $srcfile) && is_file($srcfile)) {
|
||||
$size = @getimagesize($srcfile);
|
||||
if(empty($size))
|
||||
continue;
|
||||
|
||||
$filename = basename($srcfile);
|
||||
$filepath = dirname($srcfile);
|
||||
|
||||
preg_match("/alt=[\"\']?([^\"\']*)[\"\']?/", $matchs[0][$i], $malt);
|
||||
$alt = get_text($malt[1]);
|
||||
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if(!$filename)
|
||||
return false;
|
||||
|
||||
$tname = thumbnail($filename, $filepath, $filepath, $thumb_width, $thumb_height, $is_create, $is_crop, $crop_mode, $is_sharpen, $um_value);
|
||||
|
||||
if($tname) {
|
||||
if($edt) {
|
||||
$src = G5_URL.str_replace($filename, $tname, $data_path);
|
||||
} else {
|
||||
$src = G5_DATA_URL.'/file/'.$bo_table.'/'.$tname;
|
||||
}
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
|
||||
$thumb = array("src"=>$src, "alt"=>$alt);
|
||||
|
||||
return $thumb;
|
||||
}
|
||||
|
||||
// 게시글보기 썸네일 생성
|
||||
function get_view_thumbnail($contents, $thumb_width=0)
|
||||
{
|
||||
global $board, $config;
|
||||
|
||||
if (!$thumb_width) {
|
||||
$dvc_width = intval($_COOKIE['device_width']);
|
||||
if(G5_IS_MOBILE && $dvc_width) {
|
||||
// 썸네일 width 설정
|
||||
$thumb_width = 320;
|
||||
|
||||
if($dvc_width >= 1000) {
|
||||
return $contents;
|
||||
} else if($dvc_width >= 760 && $dvc_width < 1000) {
|
||||
$thumb_width = 760;
|
||||
} else if($dvc_width >= 480 && $dvc_width < 760) {
|
||||
$thumb_width = 480;
|
||||
}
|
||||
} else {
|
||||
$thumb_width = $board['bo_image_width'];
|
||||
}
|
||||
}
|
||||
|
||||
// $contents 중 img 태그 추출
|
||||
$matchs = get_editor_image($contents);
|
||||
|
||||
if(empty($matchs))
|
||||
return $contents;
|
||||
|
||||
for($i=0; $i<count($matchs[1]); $i++) {
|
||||
// 이미지 path 구함
|
||||
$p = parse_url($matchs[1][$i]);
|
||||
if(strpos($p['path'], "/data/") != 0)
|
||||
$data_path = preg_replace("/^\/.*\/data/", "/data", $p['path']);
|
||||
else
|
||||
$data_path = $p['path'];
|
||||
|
||||
if(!preg_match('/^\/'.G5_DATA_DIR.'/', $data_path))
|
||||
continue;
|
||||
|
||||
$srcfile = G5_PATH.$data_path;
|
||||
|
||||
if(is_file($srcfile)) {
|
||||
// 썸네일 높이
|
||||
$size = @getimagesize($srcfile);
|
||||
if(empty($size))
|
||||
continue;
|
||||
|
||||
// 원본 width가 thumb_width보다 작다면
|
||||
if($size[0] <= $thumb_width)
|
||||
continue;
|
||||
|
||||
// Animated GIF 체크
|
||||
$is_animated = false;
|
||||
if($size[2] == 1) {
|
||||
$is_animated = is_animated_gif($srcfile);
|
||||
}
|
||||
|
||||
$thumb_height = round(($thumb_width * $size[1]) / $size[0]);
|
||||
$filename = basename($srcfile);
|
||||
$filepath = dirname($srcfile);
|
||||
|
||||
// 썸네일 생성
|
||||
if(!$is_animated)
|
||||
$thumb_file = thumbnail($filename, $filepath, $filepath, $thumb_width, $thumb_height, false);
|
||||
else
|
||||
$thumb_file = $filename;
|
||||
|
||||
$img_tag = $matchs[0][$i];
|
||||
preg_match("/alt=[\"\']?([^\"\']*)[\"\']?/", $img_tag, $malt);
|
||||
$alt = get_text($malt[1]);
|
||||
$thumb_tag = '<img src="'.G5_URL.str_replace($filename, $thumb_file, $data_path).'" alt="'.$alt.'"/>';
|
||||
|
||||
// $img_tag에 editor 경로가 있으면 원본보기 링크 추가
|
||||
if(strpos($matchs[1][$i], 'data/editor') && preg_match("/\.({$config['cf_image_extension']})$/i", $filename)) {
|
||||
$imgurl = str_replace(G5_URL, "", $matchs[1][$i]);
|
||||
$thumb_tag = '<a href="'.G5_BBS_URL.'/view_image.php?fn='.urlencode($imgurl).'" target="_blank" class="view_image">'.$thumb_tag.'</a>';
|
||||
}
|
||||
|
||||
$contents = str_replace($img_tag, $thumb_tag, $contents);
|
||||
}
|
||||
}
|
||||
|
||||
return $contents;
|
||||
}
|
||||
|
||||
function thumbnail($filename, $source_path, $target_path, $thumb_width, $thumb_height, $is_create, $is_crop=false, $crop_mode='center', $is_sharpen=true, $um_value='80/0.5/3')
|
||||
{
|
||||
global $g5;
|
||||
|
||||
if(!$thumb_width && !$thumb_height)
|
||||
return;
|
||||
|
||||
$thumb_filename = preg_replace("/\.[^\.]+$/i", "", $filename); // 확장자제거
|
||||
$thumb_file = "$target_path/thumb-{$thumb_filename}_{$thumb_width}x{$thumb_height}.jpg";
|
||||
$source_file = "$source_path/$filename";
|
||||
|
||||
if(!is_file($source_file)) // 원본 파일이 없다면
|
||||
return;
|
||||
|
||||
$size = @getimagesize($source_file);
|
||||
if($size[2] < 1 || $size[2] > 3) // gif, jpg, png 에 대해서만 적용
|
||||
return;
|
||||
|
||||
if (!is_dir($target_path)) {
|
||||
@mkdir($target_path, G5_DIR_PERMISSION);
|
||||
@chmod($target_path, G5_DIR_PERMISSION);
|
||||
}
|
||||
|
||||
// Animated GIF는 썸네일 생성하지 않음
|
||||
if($size[2] == 1) {
|
||||
if(is_animated_gif($source_file))
|
||||
return basename($source_file);
|
||||
}
|
||||
|
||||
$thumb_time = @filemtime($thumb_file);
|
||||
$source_time = @filemtime($source_file);
|
||||
|
||||
if (file_exists($thumb_file)) {
|
||||
if ($is_create == false && $source_time < $thumb_time) {
|
||||
return basename($thumb_file);
|
||||
}
|
||||
}
|
||||
|
||||
// 원본파일의 GD 이미지 생성
|
||||
$src = null;
|
||||
if ($size[2] == 1) {
|
||||
$src = imagecreatefromgif($source_file);
|
||||
} else if ($size[2] == 2) {
|
||||
$src = imagecreatefromjpeg($source_file);
|
||||
} else if ($size[2] == 3) {
|
||||
$src = imagecreatefrompng($source_file);
|
||||
} else {
|
||||
return;
|
||||
}
|
||||
|
||||
if(!$src)
|
||||
return;
|
||||
|
||||
$is_large = true;
|
||||
// width, height 설정
|
||||
if($thumb_width) {
|
||||
if(!$thumb_height) {
|
||||
$thumb_height = round(($thumb_width * $size[1]) / $size[0]);
|
||||
} else {
|
||||
if($size[0] < $thumb_width || $size[1] < $thumb_height)
|
||||
$is_large = false;
|
||||
}
|
||||
} else {
|
||||
if($thumb_height) {
|
||||
$thumb_width = round(($thumb_height * $size[0]) / $size[1]);
|
||||
}
|
||||
}
|
||||
|
||||
$dst_x = 0;
|
||||
$dst_y = 0;
|
||||
$src_x = 0;
|
||||
$src_y = 0;
|
||||
$dst_w = $thumb_width;
|
||||
$dst_h = $thumb_height;
|
||||
$src_w = $size[0];
|
||||
$src_h = $size[1];
|
||||
|
||||
$ratio = $dst_h / $dst_w;
|
||||
|
||||
if($is_large) {
|
||||
// 크롭처리
|
||||
if($is_crop) {
|
||||
switch($crop_mode)
|
||||
{
|
||||
case 'center':
|
||||
if($size[1] / $size[0] >= $ratio) {
|
||||
$src_h = round($src_w * $ratio);
|
||||
$src_y = round(($size[1] - $src_h) / 2);
|
||||
} else {
|
||||
$src_w = round($size[1] / $ratio);
|
||||
$src_x = round(($size[0] - $src_w) / 2);
|
||||
}
|
||||
break;
|
||||
default:
|
||||
if($size[1] / $size[0] >= $ratio) {
|
||||
$src_h = round($src_w * $ratio);
|
||||
} else {
|
||||
$src_w = round($size[1] / $ratio);
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
$dst = imagecreatetruecolor($dst_w, $dst_h);
|
||||
} else {
|
||||
$dst = imagecreatetruecolor($dst_w, $dst_h);
|
||||
|
||||
if($src_w < $dst_w) {
|
||||
if($src_h >= $dst_h) {
|
||||
$dst_x = round(($dst_w - $src_w) / 2);
|
||||
$src_h = $dst_h;
|
||||
} else {
|
||||
$dst_x = round(($dst_w - $src_w) / 2);
|
||||
$dst_y = round(($dst_h - $src_h) / 2);
|
||||
$dst_w = $src_w;
|
||||
$dst_h = $src_h;
|
||||
}
|
||||
} else {
|
||||
if($src_h < $dst_h) {
|
||||
$dst_y = round(($dst_h - $src_h) / 2);
|
||||
$dst_h = $src_h;
|
||||
$src_w = $dst_w;
|
||||
}
|
||||
}
|
||||
|
||||
$bgcolor = imagecolorallocate($dst, 255, 255, 255); // 배경색
|
||||
imagefill($dst, 0, 0, $bgcolor);
|
||||
}
|
||||
|
||||
imagecopyresampled($dst, $src, $dst_x, $dst_y, $src_x, $src_y, $dst_w, $dst_h, $src_w, $src_h);
|
||||
|
||||
// sharpen 적용
|
||||
if($is_sharpen && $is_large) {
|
||||
$val = explode('/', $um_value);
|
||||
UnsharpMask($dst, $val[0], $val[1], $val[2]);
|
||||
}
|
||||
|
||||
imagejpeg($dst, $thumb_file, 90);
|
||||
chmod($thumb_file, G5_FILE_PERMISSION); // 추후 삭제를 위하여 파일모드 변경
|
||||
|
||||
imagedestroy($src);
|
||||
imagedestroy($dst);
|
||||
|
||||
return basename($thumb_file);
|
||||
}
|
||||
|
||||
function UnsharpMask($img, $amount, $radius, $threshold) {
|
||||
|
||||
/*
|
||||
출처 : http://vikjavev.no/computing/ump.php
|
||||
New:
|
||||
- In version 2.1 (February 26 2007) Tom Bishop has done some important speed enhancements.
|
||||
- From version 2 (July 17 2006) the script uses the imageconvolution function in PHP
|
||||
version >= 5.1, which improves the performance considerably.
|
||||
|
||||
|
||||
Unsharp masking is a traditional darkroom technique that has proven very suitable for
|
||||
digital imaging. The principle of unsharp masking is to create a blurred copy of the image
|
||||
and compare it to the underlying original. The difference in colour values
|
||||
between the two images is greatest for the pixels near sharp edges. When this
|
||||
difference is subtracted from the original image, the edges will be
|
||||
accentuated.
|
||||
|
||||
The Amount parameter simply says how much of the effect you want. 100 is 'normal'.
|
||||
Radius is the radius of the blurring circle of the mask. 'Threshold' is the least
|
||||
difference in colour values that is allowed between the original and the mask. In practice
|
||||
this means that low-contrast areas of the picture are left unrendered whereas edges
|
||||
are treated normally. This is good for pictures of e.g. skin or blue skies.
|
||||
|
||||
Any suggenstions for improvement of the algorithm, expecially regarding the speed
|
||||
and the roundoff errors in the Gaussian blur process, are welcome.
|
||||
|
||||
*/
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
////
|
||||
//// Unsharp Mask for PHP - version 2.1.1
|
||||
////
|
||||
//// Unsharp mask algorithm by Torstein Hønsi 2003-07.
|
||||
//// thoensi_at_netcom_dot_no.
|
||||
//// Please leave this notice.
|
||||
////
|
||||
///////////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
|
||||
|
||||
// $img is an image that is already created within php using
|
||||
// imgcreatetruecolor. No url! $img must be a truecolor image.
|
||||
|
||||
// Attempt to calibrate the parameters to Photoshop:
|
||||
if ($amount > 500) $amount = 500;
|
||||
$amount = $amount * 0.016;
|
||||
if ($radius > 50) $radius = 50;
|
||||
$radius = $radius * 2;
|
||||
if ($threshold > 255) $threshold = 255;
|
||||
|
||||
$radius = abs(round($radius)); // Only integers make sense.
|
||||
if ($radius == 0) {
|
||||
return $img; imagedestroy($img); break; }
|
||||
$w = imagesx($img); $h = imagesy($img);
|
||||
$imgCanvas = imagecreatetruecolor($w, $h);
|
||||
$imgBlur = imagecreatetruecolor($w, $h);
|
||||
|
||||
|
||||
// Gaussian blur matrix:
|
||||
//
|
||||
// 1 2 1
|
||||
// 2 4 2
|
||||
// 1 2 1
|
||||
//
|
||||
//////////////////////////////////////////////////
|
||||
|
||||
|
||||
if (function_exists('imageconvolution')) { // PHP >= 5.1
|
||||
$matrix = array(
|
||||
array( 1, 2, 1 ),
|
||||
array( 2, 4, 2 ),
|
||||
array( 1, 2, 1 )
|
||||
);
|
||||
$divisor = array_sum(array_map('array_sum', $matrix));
|
||||
$offset = 0;
|
||||
|
||||
imagecopy ($imgBlur, $img, 0, 0, 0, 0, $w, $h);
|
||||
imageconvolution($imgBlur, $matrix, $divisor, $offset);
|
||||
}
|
||||
else {
|
||||
|
||||
// Move copies of the image around one pixel at the time and merge them with weight
|
||||
// according to the matrix. The same matrix is simply repeated for higher radii.
|
||||
for ($i = 0; $i < $radius; $i++) {
|
||||
imagecopy ($imgBlur, $img, 0, 0, 1, 0, $w - 1, $h); // left
|
||||
imagecopymerge ($imgBlur, $img, 1, 0, 0, 0, $w, $h, 50); // right
|
||||
imagecopymerge ($imgBlur, $img, 0, 0, 0, 0, $w, $h, 50); // center
|
||||
imagecopy ($imgCanvas, $imgBlur, 0, 0, 0, 0, $w, $h);
|
||||
|
||||
imagecopymerge ($imgBlur, $imgCanvas, 0, 0, 0, 1, $w, $h - 1, 33.33333 ); // up
|
||||
imagecopymerge ($imgBlur, $imgCanvas, 0, 1, 0, 0, $w, $h, 25); // down
|
||||
}
|
||||
}
|
||||
|
||||
if($threshold>0){
|
||||
// Calculate the difference between the blurred pixels and the original
|
||||
// and set the pixels
|
||||
for ($x = 0; $x < $w-1; $x++) { // each row
|
||||
for ($y = 0; $y < $h; $y++) { // each pixel
|
||||
|
||||
$rgbOrig = ImageColorAt($img, $x, $y);
|
||||
$rOrig = (($rgbOrig >> 16) & 0xFF);
|
||||
$gOrig = (($rgbOrig >> 8) & 0xFF);
|
||||
$bOrig = ($rgbOrig & 0xFF);
|
||||
|
||||
$rgbBlur = ImageColorAt($imgBlur, $x, $y);
|
||||
|
||||
$rBlur = (($rgbBlur >> 16) & 0xFF);
|
||||
$gBlur = (($rgbBlur >> 8) & 0xFF);
|
||||
$bBlur = ($rgbBlur & 0xFF);
|
||||
|
||||
// When the masked pixels differ less from the original
|
||||
// than the threshold specifies, they are set to their original value.
|
||||
$rNew = (abs($rOrig - $rBlur) >= $threshold)
|
||||
? max(0, min(255, ($amount * ($rOrig - $rBlur)) + $rOrig))
|
||||
: $rOrig;
|
||||
$gNew = (abs($gOrig - $gBlur) >= $threshold)
|
||||
? max(0, min(255, ($amount * ($gOrig - $gBlur)) + $gOrig))
|
||||
: $gOrig;
|
||||
$bNew = (abs($bOrig - $bBlur) >= $threshold)
|
||||
? max(0, min(255, ($amount * ($bOrig - $bBlur)) + $bOrig))
|
||||
: $bOrig;
|
||||
|
||||
|
||||
|
||||
if (($rOrig != $rNew) || ($gOrig != $gNew) || ($bOrig != $bNew)) {
|
||||
$pixCol = ImageColorAllocate($img, $rNew, $gNew, $bNew);
|
||||
ImageSetPixel($img, $x, $y, $pixCol);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
else{
|
||||
for ($x = 0; $x < $w; $x++) { // each row
|
||||
for ($y = 0; $y < $h; $y++) { // each pixel
|
||||
$rgbOrig = ImageColorAt($img, $x, $y);
|
||||
$rOrig = (($rgbOrig >> 16) & 0xFF);
|
||||
$gOrig = (($rgbOrig >> 8) & 0xFF);
|
||||
$bOrig = ($rgbOrig & 0xFF);
|
||||
|
||||
$rgbBlur = ImageColorAt($imgBlur, $x, $y);
|
||||
|
||||
$rBlur = (($rgbBlur >> 16) & 0xFF);
|
||||
$gBlur = (($rgbBlur >> 8) & 0xFF);
|
||||
$bBlur = ($rgbBlur & 0xFF);
|
||||
|
||||
$rNew = ($amount * ($rOrig - $rBlur)) + $rOrig;
|
||||
if($rNew>255){$rNew=255;}
|
||||
elseif($rNew<0){$rNew=0;}
|
||||
$gNew = ($amount * ($gOrig - $gBlur)) + $gOrig;
|
||||
if($gNew>255){$gNew=255;}
|
||||
elseif($gNew<0){$gNew=0;}
|
||||
$bNew = ($amount * ($bOrig - $bBlur)) + $bOrig;
|
||||
if($bNew>255){$bNew=255;}
|
||||
elseif($bNew<0){$bNew=0;}
|
||||
$rgbNew = ($rNew << 16) + ($gNew <<8) + $bNew;
|
||||
ImageSetPixel($img, $x, $y, $rgbNew);
|
||||
}
|
||||
}
|
||||
}
|
||||
imagedestroy($imgCanvas);
|
||||
imagedestroy($imgBlur);
|
||||
|
||||
return true;
|
||||
|
||||
}
|
||||
|
||||
function is_animated_gif($filename) {
|
||||
if(!($fh = @fopen($filename, 'rb')))
|
||||
return false;
|
||||
$count = 0;
|
||||
// 출처 : http://www.php.net/manual/en/function.imagecreatefromgif.php#104473
|
||||
// an animated gif contains multiple "frames", with each frame having a
|
||||
// header made up of:
|
||||
// * a static 4-byte sequence (\x00\x21\xF9\x04)
|
||||
// * 4 variable bytes
|
||||
// * a static 2-byte sequence (\x00\x2C) (some variants may use \x00\x21 ?)
|
||||
|
||||
// We read through the file til we reach the end of the file, or we've found
|
||||
// at least 2 frame headers
|
||||
while(!feof($fh) && $count < 2) {
|
||||
$chunk = fread($fh, 1024 * 100); //read 100kb at a time
|
||||
$count += preg_match_all('#\x00\x21\xF9\x04.{4}\x00(\x2C|\x21)#s', $chunk, $matches);
|
||||
}
|
||||
|
||||
fclose($fh);
|
||||
return $count > 1;
|
||||
}
|
||||
?>
|
||||
86
lib/visit.lib.php
Normal file
86
lib/visit.lib.php
Normal file
@ -0,0 +1,86 @@
|
||||
<?php
|
||||
if (!defined('_GNUBOARD_')) exit;
|
||||
|
||||
// 방문자수 출력
|
||||
function visit($skin_dir='basic')
|
||||
{
|
||||
global $config, $g5;
|
||||
|
||||
// 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();
|
||||
if(G5_IS_MOBILE) {
|
||||
$visit_skin_path = G5_MOBILE_PATH.'/'.G5_SKIN_DIR.'/visit/'.$skin_dir;
|
||||
$visit_skin_url = G5_MOBILE_URL.'/'.G5_SKIN_DIR.'/visit/'.$skin_dir;
|
||||
} else {
|
||||
$visit_skin_path = G5_SKIN_PATH.'/visit/'.$skin_dir;
|
||||
$visit_skin_url = G5_SKIN_URL.'/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 ([1-9][0-9]\.[0-9]+)/", $agent, $m)) { $s = 'MSIE '.$m[1]; }
|
||||
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 nt 6\.2/", $agent)) { $s = "Windows8"; }
|
||||
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;
|
||||
}
|
||||
?>
|
||||
Reference in New Issue
Block a user