|
Server : Apache/2.2.17 (Unix) mod_ssl/2.2.17 OpenSSL/0.9.8e-fips-rhel5 DAV/2 PHP/5.2.17 System : Linux localhost 2.6.18-419.el5 #1 SMP Fri Feb 24 22:47:42 UTC 2017 x86_64 User : nobody ( 99) PHP Version : 5.2.17 Disable Function : NONE Directory : /home/queenjbs/yuchun/conf/ |
Upload File : |
<?
/*****
신규 파일 업로드
img_file_upload
*****/
/*이미지 파일 업로드
$ImageTmp, 이미지파일
$BigImageMaxSize, 이미지 최대 사이즈
$ResizePrefix, 이미지 리픽스네임
$DIR_PATH, 파일 경로
$idx , 디렉토리 명
//디렉토리 생성
$mydir = "dir";
if(@mkdir($mydir, 0777)) {
if(is_dir($mydir)) {
@chmod($mydir, 0777);
echo "${mydir} 디렉토리를 생성하였습니다.";
}
}
else {
echo "${mydir} 디렉토리를 생성하지 못했습니다.";
}
*/
function img_file_upload($ImageTmp,$BigImageMaxSize,$ResizePrefix,$DIR_PATH) {
//파일 디렉토리 체크
if (is_dir($DIR_PATH) === false) {
mkdir($DIR_PATH, 0777,true);
}
// some information about image we need later.
unset($ImageName,$ImageSize,$TempSrc,$ImageType,$CurWidth,$CurHeight);
$ImageName =$ImageTmp["name"];
$ImageSize =$ImageTmp['size'];
$TempSrc =$ImageTmp['tmp_name'];
$ImageType =$ImageTmp['type'];
if( $ImageSize<15520000){
//Some Settings
$BigImageMaxSize = 800; //Image Maximum height or width
$ResizePrefix = time()."_800_"; //Normal resize Prefix
$Quality = 100;
$processImage = true;
//Validate file + create image from uploaded file.
switch(strtolower($ImageType))
{ case 'image/png':
$CreatedImage = imagecreatefrompng($TempSrc);
break;
case 'image/gif':
$CreatedImage = imagecreatefromgif($TempSrc);
break;
case 'image/jpeg':
case 'image/pjpeg':
$CreatedImage = imagecreatefromjpeg($TempSrc);
break;
default:
$processImage = false; //image format is not supported!
}
//get Image Size
list($CurWidth,$CurHeight) = getimagesize($TempSrc);
//Alert_msg($CurWidth." >".$BigImageMaxSize);
if($CurWidth >$BigImageMaxSize) {
//Set the Destination Image path
$DestRandImageName = $DIR_PATH.$ResizePrefix.$ImageName; //Name for Big Image
Alert_back($CurWidth." >".$BigImageMaxSize);
if($processImage && resizeImage($CurWidth,$CurHeight,$BigImageMaxSize,$DestRandImageName,$CreatedImage,$Quality,$ImageType))
{
return $vName = $ResizePrefix.$ImageName;
echo "img success";
}else{
Alert_back("이미지 파일이 아닙니다. 다시 확인해 주세요.");
}
}else{
/*
if (!file_exists($DIR_PATH.$ImageName)) {
$OriginalImageName = $DIR_PATH.$ImageName; // Original Image Name
$moveImage = move_uploaded_file($TempSrc, $OriginalImageName);
} else {
*/
// 이미지 이름 수정.
$ImageName = date("YmdHis")."_".$ImageName;
$OriginalImageName = $DIR_PATH.$ImageName; // Original Image Name
$moveImage = move_uploaded_file($TempSrc, $OriginalImageName);
//}
//imagedestroy($TempSrc);
return $vName = $ImageName;
}
}else{
Alert_back("이미지 파일 크기가 큽니다. 15MB 이하로 넣어주세요.");
}
}
/*이미지 리사이즈 저장*/
function resizeImage($CurWidth,$CurHeight,$MaxSize,$DestFolder,$SrcImage,$Quality,$ImageType)
{
//Check Image size is not 0
if($CurWidth <= 0 || $CurHeight <= 0)
{ return false;
}
//Construct a proportional size of new image
$ImageScale = min($MaxSize/$CurWidth, $MaxSize/$CurHeight);
$NewWidth = ceil($ImageScale*$CurWidth);
$NewHeight = ceil($ImageScale*$CurHeight);
if($CurWidth < $NewWidth || $CurHeight < $NewHeight)
{ $NewWidth = $CurWidth;
$NewHeight = $CurHeight;
}
$NewCanves = imagecreatetruecolor($NewWidth, $NewHeight);
// Resize Image
if(imagecopyresampled($NewCanves, $SrcImage,0, 0, 0, 0, $NewWidth, $NewHeight, $CurWidth, $CurHeight))
{ switch(strtolower($ImageType))
{ case 'image/png':
imagepng($NewCanves,$DestFolder);
break;
case 'image/gif':
imagegif($NewCanves,$DestFolder);
break;
case 'image/jpeg':
case 'image/pjpeg':
imagejpeg($NewCanves,$DestFolder,$Quality);
break;
default:
return false;
}
if(is_resource($NewCanves))
{ imagedestroy($NewCanves);
}
return true;
}
}
//글자자르기 함수.
function utf8_cutstr($str,$len,$tail='') {
//$str=strip_tags($str,'<br />'); //tag 없앰
$c = substr(str_pad(decbin(ord($str{$len})),8,'0',STR_PAD_LEFT),0,2);
if ($c == '10')
for (;$c != '11' && $c{0} == 1;$c = substr(str_pad(decbin(ord($str{--$len})),8,'0',STR_PAD_LEFT),0,2));
return substr($str,0,$len) . (strlen($str)-strlen($tail) >= $len ? $tail : '');
}
function Alert_back($msg) { // 메시지를 보이고 뒤로
echo "<script>alert('$msg');history.back()</script>";
exit;
}
function Alert_msg($msg) { // 메시지를 보인다.
echo "<script>alert('$msg');</script>";
// exit; <-- 중단 하지 않도록 한다.
}
function Alert_go($msg,$url) { // 메시지를 보이고 해당 url 로 이동
echo "<script>alert('$msg');location.href='$url';</script>";
exit;
}
function Opener_close($msg) { // 메시지를 보이고 자식창을 닫는다.
echo "<script>alert('$msg');opener.document.location.reload();self.close();</script>";
exit;
}
function Gogo($url,$sec=0) { // 해당 주소로 간다.
echo "<META http-equiv='refresh' content='$sec; url=$url'>";
exit;
}
function Opener_reload_close() { // 부모창 다시읽고 자식창을 닫는다.
echo "
<script>
opener.document.location.reload();
self.close();
</script>
";
exit;
}
function Confirm_go($msg,$url,$url2) { // 사용자의 동의를 받고 해당 url 로 이동
echo "
<script>
if ( confirm('$msg') ) {
location.href='$url';
} else {
location.href='$url2';
}
</script>";
exit;
}
function Parent_go($msg,$url) { // 사용자의 동의를 받고 해당 url 로 이동
echo "
<script>
alert('$msg');
parent.location.href='$url'
</script>";
exit;
}
//브라우져 버젼체크
function getBrowser()
{
$u_agent = $_SERVER['HTTP_USER_AGENT'];
$bname = 'Unknown';
$platform = 'Unknown';
$version= "";
//First get the platform?
if (preg_match('/linux/i', $u_agent)) { $platform = 'linux'; }
elseif (preg_match('/macintosh|mac os x/i', $u_agent)) { $platform = 'mac'; }
elseif (preg_match('/windows|win32/i', $u_agent)) { $platform = 'windows'; }
// Next get the name of the useragent yes seperately and for good reason
if(preg_match('/MSIE/i',$u_agent) && !preg_match('/Opera/i',$u_agent)) { $bname = 'Internet Explorer'; $ub = "MSIE"; }
elseif(preg_match('/Firefox/i',$u_agent)) { $bname = 'Mozilla Firefox'; $ub = "Firefox"; }
elseif(preg_match('/Chrome/i',$u_agent)) { $bname = 'Google Chrome'; $ub = "Chrome"; }
elseif(preg_match('/Safari/i',$u_agent)) { $bname = 'Apple Safari'; $ub = "Safari"; }
elseif(preg_match('/Opera/i',$u_agent)) { $bname = 'Opera'; $ub = "Opera"; }
elseif(preg_match('/Netscape/i',$u_agent)) { $bname = 'Netscape'; $ub = "Netscape"; }
// finally get the correct version number
$known = array('Version', $ub, 'other');
$pattern = '#(?<browser>' . join('|', $known) .
')[/ ]+(?<version>[0-9.|a-zA-Z.]*)#';
if (!preg_match_all($pattern, $u_agent, $matches)) {
// we have no matching number just continue
}
// see how many we have
$i = count($matches['browser']);
if ($i != 1) {
//we will have two since we are not using 'other' argument yet
//see if version is before or after the name
if (strripos($u_agent,"Version") < strripos($u_agent,$ub)){ $version= $matches['version'][0]; }
else { $version= $matches['version'][1]; }
}
else { $version= $matches['version'][0]; }
// check if we have a number
if ($version==null || $version=="") {$version="?";}
return array('userAgent'=>$u_agent, 'name'=>$bname, 'version'=>$version, 'platform'=>$platform, 'pattern'=>$pattern);
}
//모바일 체크
function MobileCheck() {
global $HTTP_USER_AGENT;
$MobileArray = array("iphone","lgtelecom","skt","mobile","samsung","nokia","blackberry","android","android","sony","phone");
$checkCount = 0;
for($i=0; $i<sizeof($MobileArray); $i++){
if(preg_match("/$MobileArray[$i]/", strtolower($HTTP_USER_AGENT))){ $checkCount++; break; }
}
return ($checkCount >= 1) ? "Mobile" : "Computer";
}
//로그인체크
function LoginCheck() {
Alert_go("ログインが必要です。","login.php");
exit;
}
?>