경로 수정 작업 중

This commit is contained in:
chicpro
2013-03-14 17:56:20 +09:00
parent 8ba59fe9b0
commit 1a60978568
1212 changed files with 39023 additions and 33180 deletions

File diff suppressed because it is too large Load Diff

View File

@ -2,21 +2,20 @@
if (!defined('_GNUBOARD_')) exit;
// 현재 접속자수 출력
function connect($skin_dir="")
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]' ";
$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]";
if (!$skin_dir)
$skin_dir = $config['cf_connect_skin'];
$connect_skin_path = G4_SKIN_PATH.'/connect/'.$skin_dir;
ob_start();
include_once ("$connect_skin_path/connect.skin.php");
include_once ($connect_skin_path.'/connect.skin.php');
$content = ob_get_contents();
ob_end_clean();

View File

@ -1,4 +1,6 @@
<?
if (!defined('_GNUBOARD_')) exit;
// 로그를 파일에 쓴다
function write_log($file, $log) {
$fp = fopen($file, "a+");

View File

@ -564,7 +564,7 @@ function create_table_item_info()
{
global $g4;
return sql_query("
CREATE TABLE IF NOT EXISTS `{$g4['yc4_item_info_table']}` (
CREATE TABLE IF NOT EXISTS `{$g4['shop_item_info_table']}` (
`ii_id` int(11) NOT NULL AUTO_INCREMENT,
`it_id` varchar(10) NOT NULL,
`ii_gubun` varchar(50) NOT NULL,

View File

@ -1,35 +1,48 @@
<?
<?php
if (!defined('_GNUBOARD_')) exit;
// 최신글 추출
function latest($skin_dir="", $bo_table, $rows=10, $subject_len=40, $options="")
function latest($skin_dir='', $bo_table, $rows=10, $subject_len=40)
{
global $g4;
if ($skin_dir)
$latest_skin_path = "$g4[path]/skin/latest/$skin_dir";
else
$latest_skin_path = "$g4[path]/skin/latest/basic";
if (!$skin_dir) $skin_dir = 'basic';
$list = array();
if(G4_IS_MOBILE) {
$latest_skin_path = G4_MOBILE_PATH.'/'.G4_SKIN_DIR.'/latest/'.$skin_dir;
$latest_skin_url = G4_MOBILE_URL.'/'.G4_SKIN_DIR.'/latest/'.$skin_dir;
} else {
$latest_skin_path = G4_SKIN_PATH.'/latest/'.$skin_dir;
$latest_skin_url = G4_SKIN_URL.'/latest/'.$skin_dir;
}
$sql = " select * from $g4[board_table] where bo_table = '$bo_table'";
$board = sql_fetch($sql);
$cache_file = G4_DATA_PATH."/cache/latest-{$bo_table}-{$skin_dir}-{$rows}-{$subject_len}.php";
if (!G4_USE_CACHE || !file_exists($cache_file)) {
$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_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);
$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";
include $latest_skin_path.'/latest.skin.php';
$content = ob_get_contents();
ob_end_clean();
return $content;
}
?>
}
?>

View File

@ -1,15 +1,15 @@
<?
if (!defined("_GNUBOARD_")) exit;
if (!defined('_GNUBOARD_')) exit;
// 메일 보내기 (파일 여러개 첨부 가능)
// type : text=0, html=1, text+html=2
function mailer($fname, $fmail, $to, $subject, $content, $type=0, $file="", $cc="", $bcc="")
function mailer($fname, $fmail, $to, $subject, $content, $type=0, $file='', $cc='', $bcc='')
{
global $config;
global $g4;
// 메일발송 사용을 하지 않는다면
if (!$config[cf_email_use]) return;
if (!$config['cf_email_use']) return;
$fname = "=?$g4[charset]?B?" . base64_encode($fname) . "?=";
$subject = "=?$g4[charset]?B?" . base64_encode($subject) . "?=";
@ -21,12 +21,10 @@ function mailer($fname, $fmail, $to, $subject, $content, $type=0, $file="", $cc=
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";
$header .= "X-Mailer: {$_SERVER['SERVER_ADDR']} : {$_SERVER['REMOTE_ADDR']} : ".G4_URL." : {$_SERVER['PHP_SELF']} : {$_SERVER['HTTP_REFERER']} \n";
if ($file != "") {
$boundary = uniqid("http://sir.co.kr/");
if ($file != '') {
$boundary = uniqid('http://sir.co.kr/');
$header .= "Content-type: MULTIPART/MIXED; BOUNDARY=\"$boundary\"\n\n";
$header .= "--$boundary\n";
@ -43,15 +41,15 @@ function mailer($fname, $fmail, $to, $subject, $content, $type=0, $file="", $cc=
$header .= "Content-Transfer-Encoding: BASE64\n\n";
$header .= chunk_split(base64_encode($content)) . "\n";
if ($file != "") {
if ($file != '') {
foreach ($file as $f) {
$header .= "\n--$boundary\n";
$header .= "Content-Type: APPLICATION/OCTET-STREAM; name=\"$f[name]\"\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 .= "Content-Disposition: inline; filename=\"{$f['name']}\"\n";
$header .= "\n";
$header .= chunk_split(base64_encode($f[data]));
$header .= chunk_split(base64_encode($f['data']));
$header .= "\n";
}
$header .= "--$boundary--\n";
@ -94,7 +92,7 @@ function verify_email($address, &$error)
if (checkdnsrr($domain, "MX")) {
// 메일 교환기 레코드들을 얻는다
if (!getmxrr($domain, $mxhost, $mxweight)) {
$error = "메일 교환기를 회수할 수 없음";
$error = '메일 교환기를 회수할 수 없음';
return false;
}
} else {
@ -116,20 +114,20 @@ function verify_email($address, &$error)
// 220 메세지들은 건너뜀
// 3초가 지나도 응답이 없으면 포기
socket_set_blocking($fp, false);
$stoptime = $g4[server_time] + $WAIT_SECOND;
$stoptime = G4_SERVER_TIME + $WAIT_SECOND;
$gotresponse = false;
while (true) {
// 메일서버로부터 한줄 얻음
$line = fgets($fp, 1024);
if (substr($line, 0, 3) == "220") {
if (substr($line, 0, 3) == '220') {
// 타이머를 초기화
$stoptime = $g4[server_time] + $WAIT_SECOND;
$stoptime = G4_SERVER_TIME + $WAIT_SECOND;
$gotresponse = true;
} else if ($line == "" && $gotresponse)
} else if ($line == '' && $gotresponse)
break;
else if ($g4[server_time] > $stoptime)
else if (G4_SERVER_TIME > $stoptime)
break;
}
@ -139,8 +137,8 @@ function verify_email($address, &$error)
socket_set_blocking($fp, true);
// SMTP 서버와의 대화를 시작
fputs($fp, "HELO $_SERVER[SERVER_NAME]\r\n");
echo "HELO $_SERVER[SERVER_NAME]\r\n";
fputs($fp, "HELO {$_SERVER['SERVER_NAME']}\r\n");
echo "HELO {$_SERVER['SERVER_NAME']}\r\n";
fgets($fp, 1024);
// From을 설정
@ -157,7 +155,7 @@ function verify_email($address, &$error)
fputs($fp, "QUIT\r\n");
fclose($fp);
if (substr($line, 0, 3) != "250") {
if (substr($line, 0, 3) != '250') {
// SMTP 서버가 이 주소를 인식하지 못하므로 잘못된 주소임
$error = $line;
return false;
@ -166,8 +164,8 @@ function verify_email($address, &$error)
return true;
}
$error = "메일 교환기에 도달하지 못하였습니다.";
$error = '메일 교환기에 도달하지 못하였습니다.';
return false;
}
?>

145
lib/mobile.lib.php Normal file
View 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, 0606); // 추후 삭제를 위하여 파일모드 변경
return $thumb;
}
function mobile_thumb($matches)
{
global $is_admin;
global $g4, $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 = G4_DATA_PATH.'/thumb/'.$bo_table;
if (!is_dir($thumb_dir)) {
@mkdir($thumb_dir, 0707);
@chmod($thumb_dir, 0707);
}
$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 = G4_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;
}
}
?>

View File

@ -2,33 +2,68 @@
if (!defined('_GNUBOARD_')) exit;
// 외부로그인
function outlogin($skin_dir="basic")
function outlogin($skin_dir='basic')
{
global $config, $member, $g4, $urlencode, $is_admin;
global $config, $member, $g4, $urlencode, $is_admin, $is_member;
$nick = cut_str($member['mb_nick'], $config['cf_cut_name']);
$point = number_format($member['mb_point']);
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']);
}
$outlogin_skin_path = "$g4[path]/skin/outlogin/$skin_dir";
if (G4_IS_MOBILE) {
$outlogin_skin_path = G4_MOBILE_PATH.'/'.G4_SKIN_DIR.'/outlogin/'.$skin_dir;
$outlogin_skin_url = G4_MOBILE_URL.'/'.G4_SKIN_DIR.'/outlogin/'.$skin_dir;
} else {
$outlogin_skin_path = G4_SKIN_PATH.'/outlogin/'.$skin_dir;
$outlogin_skin_url = G4_SKIN_URL.'/outlogin/'.$skin_dir;
}
// 읽지 않은 쪽지가 있다면
if ($member['mb_id']) {
if ($is_member) {
$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]' ";
$sql = " select count(*) as cnt from {$g4['auth_table']} where mb_id = '{$member['mb_id']}' ";
$row = sql_fetch($sql);
if ($row['cnt'])
if ($row['cnt'])
$is_auth = true;
}
if (G4_HTTPS_DOMAIN) {
$outlogin_url = $_GET['url'];
if ($outlogin_url) {
if (preg_match("/^\.\.\//", $outlogin_url)) {
$outlogin_url = urlencode(G4_URL."/".preg_replace("/^\.\.\//", "", $outlogin_url));
}
else {
$purl = parse_url(G4_URL);
if ($purl['path']) {
$path = urlencode($purl['path']);
$urlencode = preg_replace("/".$path."/", "", $urlencode);
}
$outlogin_url = $urlencode;
}
}
else {
$outlogin_url = G4_URL;
}
}
else {
$outlogin_url = $urlencode;
}
$outlogin_action_url = G4_HTTPS_BBS_URL.'/login_check.php';
ob_start();
if ($member['mb_id'])
include_once ("$outlogin_skin_path/outlogin.skin.2.php");
if ($is_member)
include_once ($outlogin_skin_path.'/outlogin.skin.2.php');
else // 로그인 전이라면
include_once ("$outlogin_skin_path/outlogin.skin.1.php");
include_once ($outlogin_skin_path.'/outlogin.skin.1.php');
$content = ob_get_contents();
ob_end_clean();

View File

@ -2,21 +2,24 @@
if (!defined('_GNUBOARD_')) exit;
// 설문조사
function poll($skin_dir="basic", $po_id=false)
function poll($skin_dir='basic', $po_id=false)
{
global $config, $member, $g4;
// 투표번호가 넘어오지 않았다면 가장 큰(최근에 등록한) 투표번호를 얻는다
if (empty($po_id))
{
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");
if (G4_IS_MOBILE) {
$poll_skin_path = G4_MOBILE_PATH.'/'.G4_SKIN_DIR.'/poll/'.$skin_dir;
} else {
$poll_skin_path = G4_SKIN_PATH.'/poll/'.$skin_dir;
}
include_once ($poll_skin_path.'/poll.skin.php');
$content = ob_get_contents();
ob_end_clean();

View File

@ -11,23 +11,24 @@ function popular($skin_dir='basic', $pop_cnt=7, $date_cnt=3)
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 ";
$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++)
{
for ($i=0; $row=sql_fetch_array($result); $i++) {
$list[$i] = $row;
// 스크립트등의 실행금지
$list[$i][pp_word] = get_text($list[$i][pp_word]);
$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");
if(G4_IS_MOBILE) {
$popular_skin_path = G4_MOBILE_PATH.'/'.G4_SKIN_DIR.'/popular/'.$skin_dir;
$popular_skin_url = G4_MOBILE_URL.'/'.G4_SKIN_DIR.'/popular/'.$skin_dir;
} else {
$popular_skin_path = G4_SKIN_PATH.'/popular/'.$skin_dir;
$popular_skin_url = G4_SKIN_URL.'/popular/'.$skin_dir;
}
include_once ($popular_skin_path.'/popular.skin.php');
$content = ob_get_contents();
ob_end_clean();

181
lib/register.lib.php Normal file
View File

@ -0,0 +1,181 @@
<?
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 $g4;
$sql = " select count(*) as cnt from `{$g4['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, G4_HANGUL + G4_ALPHABETIC + G4_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 $g4;
$row = sql_fetch(" select count(*) as cnt from {$g4['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 $g4;
$row = sql_fetch(" select count(*) as cnt from `{$g4['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, G4_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 $g4;
$reg_mb_hp = preg_replace("/[^0-9]/", "", $reg_mb_hp);
$len = strlen($reg_mb_hp);
if($len == 10)
$reg_mb_hp = preg_replace("/([0-9]{3})([0-9]{3})([0-9]{4})/", "\\1-\\2-\\3", $reg_mb_hp);
else if($len == 11)
$reg_mb_hp = preg_replace("/([0-9]{3})([0-9]{4})([0-9]{4})/", "\\1-\\2-\\3", $reg_mb_hp);
else
return "핸드폰번호를 올바르게 입력해 주십시오.";
$sql = "select count(*) as cnt from {$g4['member_table']} where mb_hp = '$reg_mb_hp' and mb_id <> '$reg_mb_id' ";
$row = sql_fetch($sql);
if($row['cnt'])
return "이미 사용 중인 핸드폰번호입니다.";
else
return "";
}
return;
?>

View File

@ -7,7 +7,7 @@ function get_cart_count($on_uid)
{
global $g4;
$sql = " select count(ct_id) as cnt from $g4[yc4_cart_table] where on_uid = '$on_uid' ";
$sql = " select count(ct_id) as cnt from {$g4['yc4_cart_table']} where on_uid = '$on_uid' ";
$row = sql_fetch($sql);
$cnt = (int)$row[cnt];
return $cnt;
@ -18,25 +18,25 @@ function get_image($img, $width=0, $height=0)
{
global $g4, $default;
$full_img = "$g4[path]/data/item/$img";
$full_img = G4_DATA_PATH."/item/$img";
if (file_exists($full_img) && $img)
if (file_exists($full_img) && $img)
{
if (!$width)
if (!$width)
{
$size = getimagesize($full_img);
$width = $size[0];
$height = $size[1];
}
$str = "<img id='$img' src='$g4[url]/data/item/$img' width='$width' height='$height' border='0'>";
}
else
$str = "<img id=\"$img\" src=\"".G4_DATA_URL."/item/$img\" width=\"$width\" height=\"$height\" border=\"0\">";
}
else
{
$str = "<img id='$img' src='$g4[shop_img_url]/no_image.gif' border='0' ";
$str = "<img id=\"$img\" src='\"".G4_SHOP_URL."/img/no_image.gif\" border=\"0\" ";
if ($width)
$str .= "width='$width' height='$height'";
$str .= "width=\"$width\" height=\"$height\"";
else
$str .= "width='$default[de_mimg_width]' height='$default[de_mimg_height]'";
$str .= "width=\"{$default['de_mimg_width']}\" height=\"{$default['de_mimg_height']}\"";
$str .= ">";
}
@ -47,11 +47,9 @@ function get_image($img, $width=0, $height=0)
// 상품 이미지를 얻는다
function get_it_image($img, $width=0, $height=0, $id="")
{
global $g4;
$str = get_image($img, $width, $height);
if ($id) {
$str = "<a href='$g4[shop_url]/item.php?it_id=$id'>$str</a>";
$str = "<a href=\"".G4_SHOP_URL."/item.php?it_id=$id'>$str</a>";
}
return $str;
}
@ -61,14 +59,14 @@ function get_it_stock_qty($it_id)
{
global $g4;
$sql = " select it_stock_qty from $g4[yc4_item_table] where it_id = '$it_id' ";
$sql = " select it_stock_qty from {$g4['yc4_item_table']} where it_id = '$it_id' ";
$row = sql_fetch($sql);
$jaego = (int)$row['it_stock_qty'];
// 재고에서 빼지 않았고 주문인것만
$sql = " select SUM(ct_qty) as sum_qty
from $g4[yc4_cart_table]
where it_id = '$it_id'
from {$g4['yc4_cart_table']}
where it_id = '$it_id'
and ct_stock_use = 0
and ct_status in ('주문', '준비') ";
$row = sql_fetch($sql);
@ -82,14 +80,14 @@ function get_large_image($img, $it_id, $btn_image=true)
{
global $g4;
if (file_exists("$g4[path]/data/item/$img") && $img != "")
if (file_exists(G4_DATA_PATH."/item/$img") && $img != "")
{
$size = getimagesize("$g4[path]/data/item/$img");
$size = getimagesize(G4_DATA_PATH."/item/$img");
$width = $size[0];
$height = $size[1];
$str = "<a href=\"javascript:popup_large_image('$it_id', '$img', $width, $height, '$g4[shop_path]')\">";
$str = "<a href=\"javascript:popup_large_image('$it_id', '$img', $width, $height, '".G4_SHOP_URL."')\">";
if ($btn_image)
$str .= "<img src='$g4[shop_img_path]/btn_zoom.gif' border='0'></a>";
$str .= "<img src=\"".G4_SHOP_URL."/img/btn_zoom.gif\" border=\"0\"></a>";
}
else
$str = "";
@ -97,7 +95,7 @@ function get_large_image($img, $it_id, $btn_image=true)
}
// 금액 표시
function display_amount($amount, $tel_inq=false)
function display_amount($amount, $tel_inq=false)
{
if ($tel_inq)
$amount = "전화문의";
@ -115,21 +113,21 @@ function get_amount($it)
if ($it['it_tel_inq']) return '전화문의';
if ($member[mb_level] > 2) // 특별회원
$amount = $it[it_amount3];
if ($member[mb_level] == 2 || $amount == 0) // 회원가격
$amount = $it[it_amount2];
if ($member['mb_level'] > 2) // 특별회원
$amount = $it['it_amount3'];
if ($member[mb_level] == 1 || $amount == 0) // 회원가격
$amount = $it[it_amount];
if ($member['mb_level'] == 2 || $amount == 0) // 회원가격
$amount = $it['it_amount2'];
if ($member['mb_level'] == 1 || $amount == 0) // 비회원가격
$amount = $it['it_amount'];
return (int)$amount;
}
// 포인트 표시
function display_point($point)
function display_point($point)
{
return number_format($point, 0) . "";
}
@ -141,7 +139,7 @@ function get_point($amount, $point)
}
// HTML 특수문자 변환 htmlspecialchars
function htmlspecialchars2($str)
function htmlspecialchars2($str)
{
$trans = array("\"" => "&#034;", "'" => "&#039;", "<"=>"&#060;", ">"=>"&#062;");
$str = strtr($str, $trans);
@ -158,98 +156,25 @@ function upload_file($srcfile, $destfile, $dir)
return true;
}
// 유일키를 생성
function get_unique_id($len=32)
{
global $g4;
$result = @mysql_query(" LOCK TABLES $g4[yc4_on_uid_table] WRITE, $g4[yc4_cart_table] READ, $g4[yc4_order_table] READ ");
if (!$result) {
$sql = " CREATE TABLE `$g4[yc4_on_uid_table]` (
`on_id` int(11) NOT NULL auto_increment,
`on_uid` varchar(32) NOT NULL default '',
`on_datetime` datetime NOT NULL default '0000-00-00 00:00:00',
`session_id` varchar(32) NOT NULL default '',
PRIMARY KEY (`on_id`),
UNIQUE KEY `on_uid` (`on_uid`) ) ";
sql_query($sql, false);
}
// 이틀전 자료는 모두 삭제함
$ytime = date("Y-m-d", $g4['server_time'] - 86400 * 1);
$sql = " delete from $g4[yc4_on_uid_table] where on_datetime < '$ytime' ";
sql_query($sql);
$unique = false;
do {
sql_query(" INSERT INTO $g4[yc4_on_uid_table] set on_uid = NOW(), on_datetime = NOW(), session_id = '".session_id()."' ", false);
$id = @mysql_insert_id();
$uid = md5($id);
sql_query(" UPDATE $g4[yc4_on_uid_table] set on_uid = '$uid' where on_id = '$id' ");
// 장바구니에도 겹치는게 있을 수 있으므로 ...
$sql = "select COUNT(*) as cnt from $g4[yc4_cart_table] where on_uid = '$uid' ";
$row = sql_fetch($sql);
if (!$row[cnt]) {
// 주문서에도 겹치는게 있을 수 있으므로 ...
$sql = "select COUNT(*) as cnt from $g4[yc4_order_table] where on_uid = '$uid' ";
$row = sql_fetch($sql);
if (!$row[cnt])
$unique = true;
}
} while (!$unique); // $unique 가 거짓인동안 실행
@mysql_query(" UNLOCK TABLES ");
return $uid;
}
// 주문서 번호를 얻는다.
function get_new_od_id()
{
global $g4;
// 주문서 테이블 Lock 걸고
sql_query(" LOCK TABLES $g4[yc4_order_table] READ, $g4[yc4_order_table] WRITE ", FALSE);
// 주문서 번호를 만든다.
$date = date("ymd", time()); // 2002년 3월 7일 일경우 020307
$sql = " select max(od_id) as max_od_id from $g4[yc4_order_table] where SUBSTRING(od_id, 1, 6) = '$date' ";
$row = sql_fetch($sql);
$od_id = $row[max_od_id];
if ($od_id == 0)
$od_id = 1;
else
{
$od_id = (int)substr($od_id, -4);
$od_id++;
}
$od_id = $date . substr("0000" . $od_id, -4);
// 주문서 테이블 Lock 풀고
sql_query(" UNLOCK TABLES ", FALSE);
return $od_id;
}
function message($subject, $content, $align="left", $width="450")
{
$str = "
<table width=$width cellpadding=4 align=center>
<tr><td class=line height=1></td></tr>
<table width=\"$width\" cellpadding=\"4\" align=\"center\">
<tr><td class=\"line\" height=\"1\"></td></tr>
<tr>
<td align=center>$subject</td>
<td align=\"center\">$subject</td>
</tr>
<tr><td class=line height=1></td></tr>
<tr><td class=\"line\" height=\"1\"></td></tr>
<tr>
<td>
<table width=100% cellpadding=8 cellspacing=0>
<table width=\"100%\" cellpadding=\"8\" cellspacing=\"0\">
<tr>
<td class=leading align=$align>$content</td>
<td class=\"leading\" align=\"$align\">$content</td>
</tr>
</table>
</td>
</tr>
<tr><td class=line height=1></td></tr>
<tr><td class=\"line\" height=\"1\"></td></tr>
</table>
<br>
";
@ -277,30 +202,30 @@ function display_type($type, $skin_file, $list_mod, $list_row, $img_width, $img_
// 상품의 갯수
$items = $list_mod * $list_row;
// 1.02.00
// 1.02.00
// it_order 추가
$sql = " select *
from $g4[yc4_item_table]
from {$g4['yc4_item_table']}
where it_use = '1'
and it_type{$type} = '1' ";
if ($ca_id) $sql .= " and ca_id like '$ca_id%' ";
$sql .= " order by it_order, it_id desc
$sql .= " order by it_order, it_id desc
limit $items ";
$result = sql_query($sql);
if (!mysql_num_rows($result)) {
return false;
}
$file = "$g4[shop_path]/$skin_file";
$file = G4_SHOP_PATH."/$skin_file";
if (!file_exists($file)) {
echo "<span class=point>{$file} 파일을 찾을 수 없습니다.</span>";
echo "<span class=\"point\">{$file} 파일을 찾을 수 없습니다.</span>";
} else {
$td_width = (int)(100 / $list_mod);
include $file;
}
}
// 분류별 출력
// 분류별 출력
// 스킨파일번호, 1라인이미지수, 총라인수, 이미지폭, 이미지높이 , 분류번호
function display_category($no, $list_mod, $list_row, $img_width, $img_height, $ca_id="")
{
@ -309,8 +234,8 @@ function display_category($no, $list_mod, $list_row, $img_width, $img_height, $c
// 상품의 갯수
$items = $list_mod * $list_row;
$sql = " select * from $g4[yc4_item_table] where it_use = '1'";
if ($ca_id)
$sql = " select * from {$g4['yc4_item_table']} where it_use = '1'";
if ($ca_id)
$sql .= " and ca_id LIKE '{$ca_id}%' ";
$sql .= " order by it_order, it_id desc limit $items ";
$result = sql_query($sql);
@ -318,9 +243,9 @@ function display_category($no, $list_mod, $list_row, $img_width, $img_height, $c
return false;
}
$file = "$g4[shop_path]/maintype{$no}.inc.php";
$file = G4_SHOP_PATH."/maintype{$no}.inc.php";
if (!file_exists($file)) {
echo "<span class=point>{$file} 파일을 찾을 수 없습니다.</span>";
echo "<span class=\"point\">{$file} 파일을 찾을 수 없습니다.</span>";
} else {
$td_width = (int)(100 / $list_mod);
include $file;
@ -345,10 +270,10 @@ function get_star_image($it_id)
{
global $g4;
$sql = "select (SUM(is_score) / COUNT(*)) as score from $g4[yc4_item_ps_table] where it_id = '$it_id' ";
$sql = "select (SUM(is_score) / COUNT(*)) as score from {$g4['yc4_item_ps_table']} where it_id = '$it_id' ";
$row = sql_fetch($sql);
return (int)get_star($row[score]);
return (int)get_star($row['score']);
}
// 메일 보내는 내용을 HTML 형식으로 만든다.
@ -357,7 +282,7 @@ function email_content($str)
global $g4;
$s = "";
$s .= "<html><head><meta http-equiv='content-type' content='text/html; charset={$g4['charset']}'><title>메일</title>\n";
$s .= "<html><head><meta http-equiv=\"content-type\" content=\"text/html; charset={$g4['charset']}\"><title>메일</title>\n";
$s .= "<body>\n";
$s .= $str;
$s .= "</body>\n";
@ -371,10 +296,10 @@ function email_content($str)
function gap_time($begin_time, $end_time)
{
$gap = $end_time - $begin_time;
$time[days] = (int)($gap / 86400);
$time[hours] = (int)(($gap - ($time[days] * 86400)) / 3600);
$time[minutes] = (int)(($gap - ($time[days] * 86400 + $time[hours] * 3600)) / 60);
$time[seconds] = (int)($gap - ($time[days] * 86400 + $time[hours] * 3600 + $time[minutes] * 60));
$time['days'] = (int)($gap / 86400);
$time['hours'] = (int)(($gap - ($time['days'] * 86400)) / 3600);
$time['minutes'] = (int)(($gap - ($time['days'] * 86400 + $time['hours'] * 3600)) / 60);
$time['seconds'] = (int)($gap - ($time['days'] * 86400 + $time['hours'] * 3600 + $time['minutes'] * 60));
return $time;
}
@ -416,7 +341,7 @@ function title_sort($col, $type=0)
}
}
#return "$_SERVER[PHP_SELF]?$q1&$q2&page=$page";
return "$_SERVER[PHP_SELF]?$q1&$q2&page=$page";
return "{$_SERVER['PHP_SELF']}?$q1&$q2&page=$page";
}
@ -425,8 +350,8 @@ function session_check()
{
global $g4;
if (!trim(get_session('ss_on_uid')))
gotourl("$g4[path]/");
if (!trim(get_session('ss_uniqid')))
gotourl(G4_SHOP_URL);
}
// 상품 옵션
@ -438,34 +363,34 @@ function get_item_options($subject, $option, $index)
if (!$subject || !$option) return "";
$str = "";
$arr = explode("\n", $option);
// 옵션이 하나일 경우
if (count($arr) == 1)
if (count($arr) == 1)
{
$str = $option;
}
else
}
else
{
$str = "<select name=it_opt{$index} onchange='amount_change()'>\n";
for ($k=0; $k<count($arr); $k++)
$str = "<select name=\"it_opt{$index}\" onchange=\"amount_change()\">\n";
for ($k=0; $k<count($arr); $k++)
{
$arr[$k] = str_replace("\r", "", $arr[$k]);
$opt = explode(";", trim($arr[$k]));
$str .= "<option value='$arr[$k]'>{$opt[0]}";
$str .= "<option value=\"$arr[$k]\">{$opt[0]}";
// 옵션에 금액이 있다면
if ($opt[1] != 0)
if ($opt[1] != 0)
{
$str .= " (";
// - 금액이 아니라면 모두 + 금액으로
//if (!ereg("[-]", $opt[1]))
if (!preg_match("/[-]/", $opt[1]))
//if (!ereg("[-]", $opt[1]))
if (!preg_match("/[-]/", $opt[1]))
$str .= "+";
$str .= display_amount($opt[1]) . ")";
}
$str .= "</option>\n";
}
$str .= "</select>\n<input type=hidden name=it_opt{$index}_subject value='$subject'>\n";
$str .= "</select>\n<input type=\"hidden\" name=\"it_opt{$index}_subject\" value=\"$subject\">\n";
}
return $str;
@ -483,12 +408,12 @@ function print_item_options()
it_opt4_subject,
it_opt5_subject,
it_opt6_subject
from $g4[yc4_item_table]
from {$g4['yc4_item_table']}
where it_id = '$it_id' ";
$it = sql_fetch($sql);
$it_name = $str_split = "";
for ($i=1; $i<=6; $i++)
for ($i=1; $i<=6; $i++)
{
$it_opt = trim(func_get_arg($i));
// 상품옵션에서 0은 제외되는 현상을 수정
@ -499,7 +424,7 @@ function print_item_options()
$opt = explode( ";", $it_opt );
$it_name .= "&nbsp; $it_opt_subject = $opt[0]";
if ($opt[1] != 0)
if ($opt[1] != 0)
{
$it_name .= " (";
//if (ereg("[+]", $opt[1]) == true)
@ -518,24 +443,24 @@ function it_name_icon($it, $it_name="", $url=1)
global $g4;
$str = "";
if ($it_name)
if ($it_name)
$str = $it_name;
else
$str = stripslashes($it[it_name]);
$str = stripslashes($it['it_name']);
if ($url)
$str = "<a href='$g4[shop_path]/item.php?it_id=$it[it_id]'>$str</a>";
$str = "<a href=\"".G4_SHOP_URL."/item.php?it_id={$it['it_id']}\">$str</a>";
if ($it[it_type1]) $str .= " <img src='$g4[shop_img_path]/icon_type1.gif' border='0' align='absmiddle' />";
if ($it[it_type2]) $str .= " <img src='$g4[shop_img_path]/icon_type2.gif' border='0' align='absmiddle' />";
if ($it[it_type3]) $str .= " <img src='$g4[shop_img_path]/icon_type3.gif' border='0' align='absmiddle' />";
if ($it[it_type4]) $str .= " <img src='$g4[shop_img_path]/icon_type4.gif' border='0' align='absmiddle' />";
if ($it[it_type5]) $str .= " <img src='$g4[shop_img_path]/icon_type5.gif' border='0' align='absmiddle' />";
if ($it['it_type1']) $str .= " <img src=\"".G4_SHOP_URL."/img/icon_type1.gif\" border=\"0\" align=\"absmiddle\" />";
if ($it['it_type2']) $str .= " <img src=\"".G4_SHOP_URL."/img/icon_type2.gif\" border=\"0\" align=\"absmiddle\" />";
if ($it['it_type3']) $str .= " <img src=\"".G4_SHOP_URL."/img/icon_type3.gif\" border=\"0\" align=\"absmiddle\" />";
if ($it['it_type4']) $str .= " <img src=\"".G4_SHOP_URL."/img/icon_type4.gif\" border=\"0\" align=\"absmiddle\" />";
if ($it['it_type5']) $str .= " <img src=\"".G4_SHOP_URL."/img/icon_type5.gif\" border=\"0\" align=\"absmiddle\" />";
// 품절
$stock = get_it_stock_qty($it[it_id]);
$stock = get_it_stock_qty($it['it_id']);
if ($stock <= 0)
$str .= " <img src='$g4[shop_img_path]/icon_pumjul.gif' border='0' align='absmiddle' /> ";
$str .= " <img src=\"".G4_SHOP_URL."/img/icon_pumjul.gif\" border=\"0\" align=\"absmiddle\" /> ";
return $str;
}
@ -559,7 +484,7 @@ function display_banner($position, $num="")
if (!$position) $position = "왼쪽";
include "$g4[shop_path]/boxbanner{$num}.inc.php";
include G4_SHOP_PATH.'/boxbanner'.$num.'.inc.php';
}
// 1.00.02
@ -572,11 +497,11 @@ function display_event($no, $event, $list_mod, $list_row, $img_width, $img_heigh
// 상품의 갯수
$items = $list_mod * $list_row;
// 1.02.00
// 1.02.00
// b.it_order 추가
$sql = " select b.*
from $g4[yc4_event_item_table] a,
$g4[yc4_item_table] b
from {$g4['yc4_event_item_table']} a,
{$g4['yc4_item_table']} b
where a.it_id = b.it_id
and b.it_use = '1'
and a.ev_id = '$event' ";
@ -588,9 +513,9 @@ function display_event($no, $event, $list_mod, $list_row, $img_width, $img_heigh
return false;
}
$file = "$g4[shop_path]/maintype{$no}.inc.php";
$file = G4_SHOP_PATH."/maintype{$no}.inc.php";
if (!file_exists($file)) {
echo "<span class=point>{$file} 파일을 찾을 수 없습니다.</span>";
echo "<span class=\"point\">{$file} 파일을 찾을 수 없습니다.</span>";
} else {
$td_width = (int)(100 / $list_mod);
include $file;
@ -612,26 +537,26 @@ function get_goods($on_uid)
global $g4;
// 상품명만들기
$row = sql_fetch(" select a.it_id, b.it_name from $g4[yc4_cart_table] a, $g4[yc4_item_table] b where a.it_id = b.it_id and a.on_uid = '$on_uid' order by ct_id limit 1 ");
$row = sql_fetch(" select a.it_id, b.it_name from {$g4['yc4_cart_table']} a, {$g4['yc4_item_table']} b where a.it_id = b.it_id and a.on_uid = '$on_uid' order by ct_id limit 1 ");
// 상품명에 "(쌍따옴표)가 들어가면 오류 발생함
$goods[it_id] = $row[it_id];
$goods[full_name]= $goods[name] = addslashes($row[it_name]);
$goods['it_id'] = $row['it_id'];
$goods['full_name']= $goods['name'] = addslashes($row['it_name']);
// 특수문자제거
$goods[full_name] = preg_replace ("/[ #\&\+\-%@=\/\\\:;,\.'\"\^`~\_|\!\?\*$#<>()\[\]\{\}]/i", "", $goods[full_name]);
$goods['full_name'] = preg_replace ("/[ #\&\+\-%@=\/\\\:;,\.'\"\^`~\_|\!\?\*$#<>()\[\]\{\}]/i", "", $goods['full_name']);
// 상품건수
$row = sql_fetch(" select count(*) as cnt from $g4[yc4_cart_table] where on_uid = '$on_uid' ");
$cnt = $row[cnt] - 1;
$row = sql_fetch(" select count(*) as cnt from {$g4['yc4_cart_table']} where on_uid = '$on_uid' ");
$cnt = $row['cnt'] - 1;
if ($cnt)
$goods[full_name] .= "{$cnt}";
$goods[count] = $row[cnt];
$goods['full_name'] .= "{$cnt}";
$goods['count'] = $row['cnt'];
return $goods;
}
// 패턴의 내용대로 해당 디렉토리에서 정렬하여 <select> 태그에 적용할 수 있게 반환
function get_list_skin_options($pattern, $dirname="./")
function get_list_skin_options($pattern, $dirname="./")
{
$str = "";
@ -646,7 +571,7 @@ function get_list_skin_options($pattern, $dirname="./")
sort($arr);
foreach($arr as $key=>$value) {
$str .= "<option value='$arr[$key]'>$arr[$key]</option>\n";
$str .= "<option value=\"$arr[$key]\">$arr[$key]</option>\n";
}
return $str;
@ -682,10 +607,10 @@ function alert_opener($msg='', $url='')
if (!$msg) $msg = '올바른 방법으로 이용해 주십시오.';
echo "<meta http-equiv=\"content-type\" content=\"text/html; charset=$g4[charset]\">";
echo "<meta http-equiv=\"content-type\" content=\"text/html; charset={$g4['charset']}\">";
echo "<script type='text/javascript'>";
echo "alert('$msg');";
echo "opener.location.href='$url';";
echo "alert(\"$msg\");";
echo "opener.location.href=\"$url\";";
echo "self.close();";
echo "</script>";
exit;

View File

@ -4,8 +4,8 @@ if (!defined('_GNUBOARD_')) exit;
/*******************************************************************************
썸네일 Class
사용법 :
사용법 :
$thumb = new g4_thumbnail(경로, 썸네일이미지폭);
$thumb->run(이미지 경로가 포함된 컨텐츠);
@ -57,11 +57,11 @@ class g4_thumb {
$width = $this->get_width();
$source = null;
$size = @getimagesize($srcimg);
if ($size[2] == 1)
if ($size[2] == 1)
$source = @imagecreatefromgif($srcimg);
else if ($size[2] == 2)
$source = @imagecreatefromjpeg($srcimg);
else if ($size[2] == 3)
else if ($size[2] == 3)
$source = @imagecreatefrompng($srcimg);
if ($source == null)
@ -111,7 +111,7 @@ class g4_thumb {
if ($size[0] < $this->width) {
return "<img src='$thumb' width='$size[0]' />";
} else {
return "<a href='$src' target='_blank' title='클릭하시면 이미지가 크게 보입니다.'><img src='$thumb' width='{$this->width}' border='0' /></a>";
return "<a href='$src' target='_blank' title='새창으로 크게 보'><img src='$thumb' width='{$this->width}' border='0' /></a>";
}
}
}

218
lib/thumbnail.lib.php Normal file
View File

@ -0,0 +1,218 @@
<?php
if (!defined('_GNUBOARD_')) exit;
@ini_set('memory_limit', '512M');
function it_img_thumb($filename, $filepath, $thumb_width, $thumb_height, $is_create=false)
{
return thumbnail($filename, $filepath, $filepath, $thumb_width, $thumb_height, $is_create);
}
// 게시글리스트 썸네일 생성
function get_list_thumbnail($filename, $filepath, $thumb_width, $thumb_height, $is_create=false, $is_crop=true)
{
return thumbnail($filename, $filepath, $filepath, $thumb_width, $thumb_height, $is_create, $is_crop);
}
// 게시글보기 썸네일 생성
function get_view_thumbnail($contents)
{
global $board, $config;
$dvc_width = intval($_COOKIE['device_width']);
if(G4_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(!$matchs)
return $contents;
for($i=0; $i<count($matchs[1]); $i++) {
// 이미지 path 구함
$imgurl = parse_url($matchs[1][$i]);
$srcfile = $_SERVER['DOCUMENT_ROOT'].$imgurl['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];
$thumb_tag = str_replace($filename, $thumb_file, $img_tag);
// img 태그에 width 값이 있을 경우 width 값 바꿔줌
preg_match("/width=[\'\"]?([0-9]+)[\'\"]?/", $img_tag, $mw);
if(!empty($mw[1])) {
$thumb_tag = str_replace($mw[0], str_replace($mw[1], $thumb_width, $mw[0]), $thumb_tag);
}
// img 태그에 height 값이 있을 경우 height 값 바꿔줌
preg_match("/height=[\'\"]?([0-9]+)[\'\"]?/", $img_tag, $mh);
if(!empty($mh[1])) {
$thumb_tag = str_replace($mh[0], str_replace($mh[1], $thumb_height, $mh[0]), $thumb_tag);
}
// $img_tag에 editor 경로가 있으면 원본보기 링크 추가
if(strpos($matchs[1][$i], 'data/editor') && preg_match("/\.({$config['cf_image_extension']})$/i", $filename)) {
$thumb_tag = '<a href="'.G4_BBS_URL.'/view_image.php?fn='.urlencode($imgurl['path']).'" target="_blank" class="view_image">'.$thumb_tag.'</a>';
}
$contents = str_replace($img_tag, $thumb_tag, $contents);
}
}
return $contents;
}
//function thumbnail($bo_table, $file, $width, $height, $is_create=false)
function thumbnail($filename, $source_path, $target_path, $thumb_width, $thumb_height, $is_create, $is_crop=false)
{
global $g4;
$thumb_filename = preg_replace("/\.[^\.]+$/i", "", $filename); // 확장자제거
if (!is_dir($target_path)) {
@mkdir($target_path, 0707);
@chmod($target_path, 0707);
}
$thumb_file = "$target_path/thumb-{$thumb_filename}_{$thumb_width}x{$thumb_height}.jpg";
$thumb_time = @filemtime($thumb_file);
$source_file = "$source_path/$filename";
$source_time = @filemtime($source_file);
if (file_exists($thumb_file)) {
if ($is_create == false && $source_time < $thumb_time) {
return basename($thumb_file);
}
}
$size = @getimagesize($source_file);
// 이미지 파일이 없거나 아님
if (!$size[0]) {
if (!$thumb_height) $thumb_height = $thumb_width;
$thumb_file = "$target_path/thumb-noimg_{$thumb_width}x{$thumb_height}.jpg";
if (!file_exists($thumb_file)) {
$target = imagecreate($thumb_width, $thumb_height);
imagecolorallocate($target, 250, 250, 250);
imagecopy($target, $target, 0, 0, 0, 0, $thumb_width, $thumb_height);
imagejpeg($target, $thumb_file, 90);
@chmod($thumb_file, 0606); // 추후 삭제를 위하여 파일모드 변경
}
return basename($thumb_file);
}
// Animated GIF 체크
if($size[2] == 1) {
if(is_animated_gif($source_file))
return basename($source_file);
}
$is_imagecopyresampled = false;
$is_large = false;
$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);
}
$src_width = $size[0];
$src_height = $size[1];
if($is_crop && $thumb_width && $thumb_height) {
$ratio = $thumb_height / $thumb_width;
if($src_height / $src_width >= $ratio) {
$src_height = ceil(($thumb_height * $src_width) / $thumb_width);
} else {
$src_width = ceil(($thumb_width * $src_height) / $thumb_height);
}
}
if ($thumb_width) {
if ($thumb_height) {
$rate = $thumb_width / $src_width;
$tmp_height = (int)($src_height * $rate);
if ($tmp_height < $thumb_height) {
$dst = imagecreatetruecolor($thumb_width, $thumb_height);
$bgcolor = imagecolorallocate($dst, 250, 250, 250); // 배경색 여기야!!!
imagefill($dst, 0, 0, $bgcolor);
imagecopyresampled($dst, $src, 0, 0, 0, 0, $thumb_width, $thumb_height, $src_width, $src_height);
} else {
$dst = imagecreatetruecolor($thumb_width, $thumb_height);
imagecopyresampled($dst, $src, 0, 0, 0, 0, $thumb_width, $thumb_height, $src_width, $src_height);
}
} else {
$rate = $thumb_width / $src_width;
$tmp_height = (int)($src_height * $rate);
$dst = imagecreatetruecolor($thumb_width, $tmp_height);
imagecopyresampled($dst, $src, 0, 0, 0, 0, $thumb_width, $tmp_height, $src_width, $src_height);
}
}
//imagepng($dst, $thumb_file, 9); // 0 (no compression) ~ 9
imagejpeg($dst, $thumb_file, 90);
chmod($thumb_file, 0606); // 추후 삭제를 위하여 파일모드 변경
return basename($thumb_file);
}
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;
}
?>

View File

@ -2,11 +2,11 @@
if (!defined('_GNUBOARD_')) exit;
// 방문자수 출력
function visit($skin_dir="basic")
function visit($skin_dir='basic')
{
global $config, $g4;
// visit 배열변수에
// visit 배열변수에
// $visit[1] = 오늘
// $visit[2] = 어제
// $visit[3] = 최대
@ -19,8 +19,14 @@ function visit($skin_dir="basic")
settype($visit[3], "integer");
ob_start();
$visit_skin_path = "$g4[path]/skin/visit/$skin_dir";
include_once ("$visit_skin_path/visit.skin.php");
if(G4_IS_MOBILE) {
$visit_skin_path = G4_MOBILE_PATH.'/'.G4_SKIN_DIR.'/visit/'.$skin_dir;
$visit_skin_url = G4_MOBILE_URL.'/'.G4_SKIN_DIR.'/visit/'.$skin_dir;
} else {
$visit_skin_path = G4_SKIN_PATH.'/visit/'.$skin_dir;
$visit_skin_url = G4_SKIN_URL.'/visit/'.$skin_dir;
}
include_once ($visit_skin_path.'/visit.skin.php');
$content = ob_get_contents();
ob_end_clean();