Merge branch 'master' of github.com:gnuboard/g4s
This commit is contained in:
@ -1441,44 +1441,44 @@ function check_string($str, $options)
|
||||
// 한글
|
||||
if ($oc >= 0xA0 && $oc <= 0xFF) {
|
||||
if (strtoupper($g4['charset']) == 'UTF-8') {
|
||||
if ($options & _G4_HANGUL_) {
|
||||
if ($options & G4_HANGUL) {
|
||||
$s .= $c . $str[$i+1] . $str[$i+2];
|
||||
}
|
||||
$i+=2;
|
||||
} else {
|
||||
// 한글은 2바이트 이므로 문자하나를 건너뜀
|
||||
$i++;
|
||||
if ($options & _G4_HANGUL_) {
|
||||
if ($options & G4_HANGUL) {
|
||||
$s .= $c . $str[$i];
|
||||
}
|
||||
}
|
||||
}
|
||||
// 숫자
|
||||
else if ($oc >= 0x30 && $oc <= 0x39) {
|
||||
if ($options & _G4_NUMERIC_) {
|
||||
if ($options & G4_NUMERIC) {
|
||||
$s .= $c;
|
||||
}
|
||||
}
|
||||
// 영대문자
|
||||
else if ($oc >= 0x41 && $oc <= 0x5A) {
|
||||
if (($options & _G4_ALPHABETIC_) || ($options & _G4_ALPHAUPPER_)) {
|
||||
if (($options & G4_ALPHABETIC) || ($options & G4_ALPHAUPPER)) {
|
||||
$s .= $c;
|
||||
}
|
||||
}
|
||||
// 영소문자
|
||||
else if ($oc >= 0x61 && $oc <= 0x7A) {
|
||||
if (($options & _G4_ALPHABETIC_) || ($options & _G4_ALPHALOWER_)) {
|
||||
if (($options & G4_ALPHABETIC) || ($options & G4_ALPHALOWER)) {
|
||||
$s .= $c;
|
||||
}
|
||||
}
|
||||
// 공백
|
||||
else if ($oc == 0x20) {
|
||||
if ($options & _G4_SPACE_) {
|
||||
if ($options & G4_SPACE) {
|
||||
$s .= $c;
|
||||
}
|
||||
}
|
||||
else {
|
||||
if ($options & _G4_SPECIAL_) {
|
||||
if ($options & G4_SPECIAL) {
|
||||
$s .= $c;
|
||||
}
|
||||
}
|
||||
@ -1659,4 +1659,20 @@ function get_selected($field, $value, $first=false)
|
||||
$selected = ($field=="") ? ' selected="selected"' : '';
|
||||
return $selected;
|
||||
}
|
||||
|
||||
|
||||
function skin_path()
|
||||
{
|
||||
global $g4;
|
||||
$skin_dir = 'skin';
|
||||
$skin_path = $g4['path'].'/'.$skin_dir;
|
||||
if (G4_IS_MOBILE) $skin_path = $g4['mobile_path'].'/'.$skin_dir;
|
||||
return $skin_path;
|
||||
}
|
||||
|
||||
|
||||
function is_mobile()
|
||||
{
|
||||
return preg_match('/'.G4_MOBILE_AGENT.'/i', $_SERVER['HTTP_USER_AGENT']);
|
||||
}
|
||||
?>
|
||||
@ -10,10 +10,9 @@ function connect($skin_dir='')
|
||||
$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 = skin_path().'/connect/'.$skin_dir;
|
||||
|
||||
ob_start();
|
||||
include_once ($connect_skin_path.'/connect.skin.php');
|
||||
|
||||
@ -1,12 +0,0 @@
|
||||
<?
|
||||
// 상수 정의
|
||||
|
||||
// 입력값 검사 상수
|
||||
define('_G4_ALPHAUPPER_', 1); // 영대문자
|
||||
define('_G4_ALPHALOWER_', 2); // 영소문자
|
||||
define('_G4_ALPHABETIC_', 4); // 영대,소문자
|
||||
define('_G4_NUMERIC_', 8); // 숫자
|
||||
define('_G4_HANGUL_', 16); // 한글
|
||||
define('_G4_SPACE_', 32); // 공백
|
||||
define('_G4_SPECIAL_', 64); // 특수문자
|
||||
?>
|
||||
@ -6,10 +6,9 @@ function latest($skin_dir='', $bo_table, $rows=10, $subject_len=40, $options='')
|
||||
{
|
||||
global $g4;
|
||||
|
||||
if ($skin_dir)
|
||||
$latest_skin_path = $g4['path'].'/skin/latest/'.$skin_dir;
|
||||
else
|
||||
$latest_skin_path = $g4['path'].'/skin/latest/basic';
|
||||
if (!$skin_dir)
|
||||
$skin_dir = 'basic';
|
||||
$latest_skin_path = skin_path().'/latest/'.$skin_dir;
|
||||
|
||||
$list = array();
|
||||
|
||||
|
||||
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, 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[path]/data/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)) {
|
||||
// 상대경로(..)로 시작되면 sir.co.kr 도메인으로 여긴다.
|
||||
$src = preg_replace("/^\.\.\//", "http://sir.co.kr/", $src);
|
||||
|
||||
// 유일한 파일명을 만든다.
|
||||
$src_md5 = md5($src.$width);
|
||||
$thumb = "$g4[path]/data/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;
|
||||
}
|
||||
}
|
||||
?>
|
||||
@ -13,7 +13,7 @@ function outlogin($skin_dir='basic')
|
||||
$point = number_format($member['mb_point']);
|
||||
}
|
||||
|
||||
$outlogin_skin_path = $g4['path'].'/skin/outlogin/'.$skin_dir;
|
||||
$outlogin_skin_path = skin_path().'/outlogin/'.$skin_dir;
|
||||
|
||||
// 읽지 않은 쪽지가 있다면
|
||||
if ($is_member) {
|
||||
|
||||
@ -14,7 +14,7 @@ function poll($skin_dir='basic', $po_id=false)
|
||||
}
|
||||
|
||||
ob_start();
|
||||
$poll_skin_path = $g4['path'].'/skin/poll/'.$skin_dir;
|
||||
$poll_skin_path = skin_path().'/poll/'.$skin_dir;
|
||||
include_once ($poll_skin_path.'/poll.skin.php');
|
||||
$content = ob_get_contents();
|
||||
ob_end_clean();
|
||||
|
||||
@ -26,7 +26,7 @@ function popular($skin_dir='basic', $pop_cnt=7, $date_cnt=3)
|
||||
}
|
||||
|
||||
ob_start();
|
||||
$popular_skin_path = $g4['path'].'/skin/popular/'.$skin_dir;
|
||||
$popular_skin_path = skin_path().'/popular/'.$skin_dir;
|
||||
include_once ($popular_skin_path.'/popular.skin.php');
|
||||
$content = ob_get_contents();
|
||||
ob_end_clean();
|
||||
|
||||
@ -19,7 +19,7 @@ function visit($skin_dir='basic')
|
||||
settype($visit[3], "integer");
|
||||
|
||||
ob_start();
|
||||
$visit_skin_path = $g4['path'].'/skin/visit/'.$skin_dir;
|
||||
$visit_skin_path = skin_path().'/visit/'.$skin_dir;
|
||||
include_once ($visit_skin_path.'/visit.skin.php');
|
||||
$content = ob_get_contents();
|
||||
ob_end_clean();
|
||||
|
||||
Reference in New Issue
Block a user