alert(\"$str\"); "; if(!$url) { echo "history.back();"; } else { if( $target ) echo $target . "."; echo "location.href='$url';"; } echo ""; die(); } function nvl($str, $replacestr="") { if(!$str){ return $replacestr; }else{ return $str; } } function fnGetDocExt($param){ $allfile = strtolower($param); $fileinfo = pathinfo($allfile); $ext = $fileinfo['extension']; if($ext=="doc" || $ext=="hwp" || $ext=="ppt" || $ext=="pptx" || $ext=="docx" || $ext=="pdf"){ return "doc"; }else{ return "img"; } } FUNCTION error_page($str="오류발생",$url="") { $str = addslashes($str); if(!$url) $url = $PHP_SELF; echo ""; die(); } function move_page($path,$time = 0) { die(""); } function js_msg($str) { $str = addslashes($str); echo ""; } FUNCTION login_please($url) { $url = urlencode($url); if(!session_is_registered(MEM_SESS)) { js_msg('로그인이 필요합니다'); move_page("/login/login.html?url=$url"); } } function message($msg){ global $head_url,$foot_url,$head_html,$foot_html; if ($head_url) include $head_url; echo stripslashes($head_html); echo "
4 ERROR7 BACK  
$msg
"; echo stripslashes($foot_html); if ($foot_url) include $foot_url; exit; } function avoid_crack($data) { // Fix &entity\n; $data = str_replace(array('&','<','>'), array('&amp;','&lt;','&gt;'), $data); $data = preg_replace('/(&#*\w+)[\x00-\x20]+;/u', '$1;', $data); $data = preg_replace('/(&#x*[0-9A-F]+);*/iu', '$1;', $data); $data = html_entity_decode($data, ENT_COMPAT, 'UTF-8'); // Remove any attribute starting with "on" or xmlns $data = preg_replace('#(<[^>]+?[\x00-\x20"\'])(?:on|xmlns)[^>]*+>#iu', '$1>', $data); // Remove javascript: and vbscript: protocols $data = preg_replace('#([a-z]*)[\x00-\x20]*=[\x00-\x20]*([`\'"]*)[\x00-\x20]*j[\x00-\x20]*a[\x00-\x20]*v[\x00-\x20]*a[\x00-\x20]*s[\x00-\x20]*c[\x00-\x20]*r[\x00-\x20]*i[\x00-\x20]*p[\x00-\x20]*t[\x00-\x20]*:#iu', '$1=$2nojavascript...', $data); $data = preg_replace('#([a-z]*)[\x00-\x20]*=([\'"]*)[\x00-\x20]*v[\x00-\x20]*b[\x00-\x20]*s[\x00-\x20]*c[\x00-\x20]*r[\x00-\x20]*i[\x00-\x20]*p[\x00-\x20]*t[\x00-\x20]*:#iu', '$1=$2novbscript...', $data); $data = preg_replace('#([a-z]*)[\x00-\x20]*=([\'"]*)[\x00-\x20]*-moz-binding[\x00-\x20]*:#u', '$1=$2nomozbinding...', $data); // Only works in IE: $data = preg_replace('#(<[^>]+?)style[\x00-\x20]*=[\x00-\x20]*[`\'"]*.*?expression[\x00-\x20]*\([^>]*+>#i', '$1>', $data); $data = preg_replace('#(<[^>]+?)style[\x00-\x20]*=[\x00-\x20]*[`\'"]*.*?behaviour[\x00-\x20]*\([^>]*+>#i', '$1>', $data); $data = preg_replace('#(<[^>]+?)style[\x00-\x20]*=[\x00-\x20]*[`\'"]*.*?s[\x00-\x20]*c[\x00-\x20]*r[\x00-\x20]*i[\x00-\x20]*p[\x00-\x20]*t[\x00-\x20]*:*[^>]*+>#iu', '$1>', $data); // Remove namespaced elements (we do not need them) $data = preg_replace('#]*+>#i', '', $data); do { // Remove really unwanted tags $old_data = $data; $data = preg_replace('#]*+>#i', '', $data); } while ($old_data !== $data); $data = preg_replace("/[\"\']/i", '\"', $data); //쌍따옴표 치환 $data = preg_replace("/[\"\']/i", "\'", $data); //따옴표 치환 // we are done... return $data; } function text_cut($str, $len){ if(strlen($str) > $len){ if(ord($str[$len - 1]) <= 127) $pos = $len; else{ for($pos = $len - 1; $pos >= 0; $pos--){ if (ord($str[$pos]) > 127) $h++; else break; } if ($h%2==0) $pos += $h + 1; else $pos += $h; } $str = mb_substr($str, 0, $pos, 'UTF-8'); $str .=".."; } return $str; } function validateAuth($dbpwd, $userpwd) { global $admin, $uadmin; if(session_is_registered("administrator")) { return true; } else { if($userpwd == $admin[passwd]) { // js_msg("유저가 입력한 패스워드와 전체관리자 패스워드가 동일"); return true; } else if($uadmin[passwd] == crypt($userpwd, $uadmin[passwd])) { // js_msg("유저가 입력한 패스워드가 로컬관리자 패스워드와 동일"); return true; }else if(!$dbpwd || !$userpwd) { // js_msg("db패스워드가 없거나 유저가 패스워드를 입력하지 않음"); return false; } else if($dbpwd != $userpwd) { // js_msg("DB패스워드와 유저가 입력한 패스워드는 일치하지 않음"); return false; } else return true; } // end outer if } function setLocalAdminSession($db, $pwd) { global $uadmin; if(!$db || !$pwd) return false; if($uadmin[passwd] == crypt($pwd, $uadmin[passwd])) { session_register($db); return true; } else { return false; } } function safeHTML($html, $tags = "b|br|i|u|ul|ol|li") { $html = preg_replace('/\0/', '', $html); $html = preg_replace('/\&/', '\0', $html); $html = htmlspecialchars($html); $html = str_replace(chr(13).chr(10),"
",$html); if($tags) { $html = preg_replace("/<($tags).*?>/i",'<\1>', $html); $html = preg_replace("/<\\/($tags)>/i",'', $html); } $html = preg_replace('/\0/', '&', $html); // $html = preg_replace("/>(http|https|ftp)(:\/\/\S+)<(.+?)"); // $pattern = "(http://|ftp://)+([0-9a-zA-Z./@~?&=_]+)"; // $html = ereg_replace($pattern, "\\1\\2", $html); return $html; } function utf8_length($str) { $len = strlen($str); for ($i = $length = 0; $i < $len; $length++) { $high = ord($str[$i]); if ($high < 0x80)//0<= code <128 범위의 문자(ASCII 문자)는 인덱스 1칸이동 $i += 1; else if ($high < 0xE0)//128 <= code < 224 범위의 문자(확장 ASCII 문자)는 인덱스 2칸이동 $i += 2; else if ($high < 0xF0)//224 <= code < 240 범위의 문자(유니코드 확장문자)는 인덱스 3칸이동 $i += 3; else//그외 4칸이동 (미래에 나올문자) $i += 4; } return $length; } function cutstring($str, $chars, $tail = '..') { if (utf8_length($str) <= $chars)//전체 길이를 불러올 수 있으면 tail을 제거한다. $tail = ''; else $chars -= utf8_length($tail);//글자가 잘리게 생겼다면 tail 문자열의 길이만큼 본문을 빼준다. $len = strlen($str); for ($i = $adapted = 0; $i < $len; $adapted = $i) { $high = ord($str[$i]); if ($high < 0x80) $i += 1; else if ($high < 0xE0) $i += 2; else if ($high < 0xF0) $i += 3; else $i += 4; if (--$chars < 0) break; } return trim(substr($str, 0, $adapted)) . $tail; } function getFileType($filename) { $ext = substr($filename, strpos($filename, ".")); } // 문자열에 한글이 포함되어 있는지 검사하는 함수 // ord - 문자의 ASCII 값을 가져옴 function is_hangul($str) { // 특정 문자가 한글의 범위내(0xA1A1 - 0xFEFE)에 있는지 검사 for($i = 0; $i < strlen($str); $i++) { $char = ord($str[$i]); if($char >= 0xa1 && $char <= 0xfe) return 1; } } // 알파벳인지 그리고 대문자(0x41 - 0x5a)인지 소문자(0x61 - 0x7a)인지 // 검사하는 함수 // // ord - 문자의 ASCII 값을 가져옴 function is_alpha($char) { $char = ord($char); if($char >= 0x61 && $char <= 0x7a) return 1; if($char >= 0x41 && $char <= 0x5a) return 2; } // URL이 정확한 것인지 검사하는 함수 // // eregi - 정규 표현식을 이용한 검사 (대소문자 무시) // eregi_replace - 정규 표현식을 이용한 치환 (대소문자 무시) function check_url($url) { $url = trim($url); if(is_hangul($url)) return; // 프로토콜(http://, ftp://...)을 나타내는 부분이 없을 때 기본값으로 // http://를 붙임 if(!eregi("^(http://|https://|ftp://|telnet://|news://)", $url)) $url = preg_match("^", "http://", $url); if(!eregi("(http|https|ftp|telnet|news):\/\/[a-z0-9-]+\.[][a-zA-Z0-9:&#@=_~%;\?\/\.\+-]+", $url)) return; return $url; } // E-MAIL 주소가 정확한 것인지 검사하는 함수 // // eregi - 정규 표현식을 이용한 검사 (대소문자 무시) function check_email($email) { $email = trim($email); if(is_hangul($email)) return; if(!eregi("^[a-z0-9_-]+@[a-z0-9-]+\.[a-z0-9\.-]+", $email)) return; return $email; } function getLatestList($db, $num=5) { global $PHP_SELF; $query = "select * from $db order by no desc limit 0, $num"; $result = sql_query($query); if(sql_num_rows($result)) { while($list = sql_fetch_array($result)) { printLatestList($db,$list); } } else { echo "등록된 글이 없습니다"; } sql_free_result($result); } function printLatestList($db, $list) { $list[title] = preg_match("\"",""",$list[title]); $title = sprintf("
 %s
", $db, $list[no], $list[title]); echo "$title\n"; } function getExt($filename) { $filename = trim($filename); $right = strrchr($filename, "."); return strtolower(substr($right,1)); } /// 게시물 자동링크 /// function autolink($str){ // URL $str=preg_match("(http|https|ftp|telnet|news)://([-/.a-zA-Z0-9_~#%$?&=:\200-\377\(\)]+)"," \\1://\\2",$str); $str=str_replace("=","=",$str); $str=str_replace("=\" ","=\"",$str); $str=str_replace("='","='",$str); $str=preg_match(" (http|https|ftp|telnet|news)://([-/.a-zA-Z0-9_~#%$?&=:\200-\377\(\)]+)","\\1://\\2",$str); // MAIL $str=preg_match("([\xA1-\xFEa-z0-9_-]+@[\xA1-\xFEa-z0-9-]+\.[a-z0-9-]+)"," \\1",$str); $str=str_replace("mailto:","mailto:",$str); $str=preg_match(" ([\xA1-\xFEa-z0-9_-]+@[\xA1-\xFEa-z0-9-]+\.[a-z0-9-]+)","\\1",$str); return $str; } //아스키 문자열을 헥사 코드로.. function asc_hex($char){ $j = 0; $word_length=strlen($char); for($i = 0;$i<$word_length;$i++) { if($j == 0){ if(ord(substr($char,$i,1)) > 0xa1 && ord(substr($char,$i,1)) <= 0xfe) { if($i>0)$str .= ' '; $j = 1; $str = $str.bin2hex(substr($char,$i,1)); }else{ if($i>0)$str .= ' '; $str = $str.'00'.bin2hex(substr($char,$i,1)); } }else{ $str = $str.bin2hex(substr($char,$i,1)); $j = 0; } } return $str; } //헥사 코드 문자열을 아스키 코드 문자열로 function hex_asc($str){ $word_length=strlen($str); for($i = 0;$i<$word_length;$i+=5){ $tmp1=HexDec(substr($str,$i,2)); if($tmp1==0){ $tmp2=HexDec(substr($str,$i+2,2)); $str2.=chr($tmp2); }else{ $tmp2=HexDec(substr($str,$i+2,2)); $str2.=chr($tmp1).chr($tmp2); } } return $str2; } // 사용법 // $str=fuck2xxx($str,$fil,'XX'); function fuck2xxx($str,$fil,$replace_str){ $fil=explode(',',$fil); $replace_str=asc_hex($replace_str); $filter_str='/('; for($i=0;$i0)$filter_str.='|'; $filter_str.=asc_hex($fil[$i]); } $filter_str.=')+/'; $str=preg_replace($filter_str,$replace_str,asc_hex($str)); return hex_asc($str); } // 쓰기금지할 단어들을 검색해서 있으면 true function is_fuck($str,$fil){ $fil=explode(',',$fil); $filter_str='/('; for($i=0;$i0)$filter_str.='|'; $filter_str.= $fil[$i]; } $filter_str.=')+/'; if( preg_match($filter_str,$str) ) { return true; } else { return false; } } function get_microtime($old, $new) { $old = explode(" ", $old); $new = explode(" ", $new); $time[msec] = $new[0] - $old[0]; $time[sec] = $new[1] - $old[1]; if($time[msec] < 0) { $time[msec] = 1.0 + $time[msec]; $time[sec]--; } $time = sprintf("%.2f", $time[sec] + $time[msec]); return $time; } function print_microtime($old, $new) { $old = explode(" ", $old); $new = explode(" ", $new); $time[msec] = $new[0] - $old[0]; $time[sec] = $new[1] - $old[1]; if($time[msec] < 0) { $time[msec] = 1.0 + $time[msec]; $time[sec]--; } $time = sprintf("%.2f", $time[sec] + $time[msec]); $str = "PageLoding Time : " . $time ." sec"; echo ""; } // 날짜를 date 형식으로 받아서 그날시작되는 UNIX TIMESTAMP 를 반환해준다 function str2date($in){ $t = split("/",$in); if (count($t)!=3) $t = split("-",$in); if (count($t)!=3) $t = split(" ",$in); if (count($t)!=3) return -1; if (!is_numeric($t[0])) return -1; if (!is_numeric($t[1])) return -2; if (!is_numeric($t[2])) return -3; if ($t[2]<1902 || $t[2]>2037) return -3; return mktime (0,0,0, $t[1], $t[0], $t[2]); } /* ============================================================================ Return : Comment: 화일이 이미지인지 체크 Usage : ------------------------------------------------------------------------------*/ function img_type( $srcimg ) { if(is_file($srcimg)) { $image_info = @getimagesize($srcimg); switch ($image_info['mime']) { case 'image/gif': return true; break; case 'image/jpeg': return true; break; case 'image/png': return true; break; case 'image/bmp': return true; break; default : return false; break; } } else { return false; } } //기타이동함수 function AlertBack($msg){ echo(" "); exit; } function Alert($msg){ echo(" "); exit; } function AlertExit($msg){ echo(" "); exit; } function AlertRedirect($msg,$url){ echo(" "); exit; } function AlertRedirectRefresh($msg,$url){ echo(" "); exit; } function AlertLogin($msg){ echo(" "); exit; } function Redirect($url){ echo(" "); exit; } function AlertExitRefresh($msg,$tourl){ echo(" "); exit; } function Replace($tourl){ echo(" "); exit; } function ExitRedirect($tourl){ echo(" "); exit; } function ExitRefresh(){ echo(" "); exit; } function TopExit($tourl){ echo(" "); exit; } function URL2($tourl,$url){ echo(" "); exit; } /* //Ajax페이징 function ListPgAjax($url,$pageno,$PageSize,$BlockPage,$totalrows) { $lastpgno=(int)@ceil($totalrows/$PageSize); //마지막 페이지 $now_num = (int) @ceil($pageno/$BlockPage); $start_num = (int) ($now_num - 1) * $BlockPage; $end_num = (int) $now_num * $BlockPage; $next_num = (int) $end_num + 1;//마지막 페이지 값 구함 $prev_num = (int) $start_num;//시작 페이지 값 구함 $html = ""; //처음 if($pageno<>1) { $html += "맨 처음"; } //이전 if($now_num > 1) { $html += "이전"; } //블럭단위 페이징 for ($i = $start_num + 1; $i <= $end_num && $i <= $lastpgno; $i++) { if ($i == $pageno) { $html += " $i "; } else { $html += "$i "; } } //다음 if($end_num < $lastpgno) { $html += " 다음"; } //마지막 if($pageno<>$lastpgno && $lastpgno>0 ) { $html += "맨 마지막"; } return $html; } */ //게시판페이징 // function ListPg($url,$pageno,$PageSize,$BlockPage,$totalrows) // { // // $lastpgno=(int)@ceil($totalrows/$PageSize); //마지막 페이지 // $now_num = (int) @ceil($pageno/$BlockPage); // $start_num = (int) ($now_num - 1) * $BlockPage; // $end_num = (int) $now_num * $BlockPage; // $next_num = (int) $end_num + 1;//마지막 페이지 값 구함 // $prev_num = (int) $start_num;//시작 페이지 값 구함 // // // echo '
'; // echo ''; // // // echo '
'; // } //게시판페이징 - 사용자 function ListPg($url,$pageno,$PageSize,$BlockPage,$totalrows) { $lastpgno=(int)@ceil($totalrows/$PageSize); //마지막 페이지 $now_num = (int) @ceil($pageno/$BlockPage); $start_num = (int) ($now_num - 1) * $BlockPage; $end_num = (int) $now_num * $BlockPage; $next_num = (int) $end_num + 1;//마지막 페이지 값 구함 $prev_num = (int) $start_num;//시작 페이지 값 구함 echo "
"; echo ""; echo "
"; } //게시판페이징 - 사용자 function ListMobilePg($url,$pageno,$PageSize,$BlockPage,$totalrows) { $lastpgno=(int)@ceil($totalrows/$PageSize); //마지막 페이지 $now_num = (int) @ceil($pageno/$BlockPage); $start_num = (int) ($now_num - 1) * $BlockPage; $end_num = (int) $now_num * $BlockPage; $next_num = (int) $end_num + 1;//마지막 페이지 값 구함 $prev_num = (int) $start_num;//시작 페이지 값 구함 echo ""; } //게시판페이징1 function ListPg1($url,$pageno,$PageSize,$BlockPage,$totalrows) { $lastpgno=(int)@ceil($totalrows/$PageSize); //마지막 페이지 $now_num = (int) @ceil($pageno/$BlockPage); $start_num = (int) ($now_num - 1) * $BlockPage; $end_num = (int) $now_num * $BlockPage; $next_num = (int) $end_num + 1;//마지막 페이지 값 구함 $prev_num = (int) $start_num;//시작 페이지 값 구함 if($pageno<>1 || $now_num > 1) { echo ""; } //처음 if($pageno<>1) { echo "맨앞"; } //이전 if($now_num > 1) { echo "이전"; } if($pageno<>1 || $now_num > 1) { echo ""; } //블럭단위 페이징 for ($i = $start_num + 1; $i <= $end_num && $i <= $lastpgno; $i++) { if ($i == $pageno) { echo "$i"; } else { echo "$i "; } } if( $end_num < $lastpgno || ($pageno<>$lastpgno && $lastpgno>0) ){ echo ""; } //다음 if($end_num < $lastpgno) { echo " 다음"; } //마지막 if($pageno<>$lastpgno && $lastpgno>0 ) { echo "맨뒤"; } if( $end_num < $lastpgno || ($pageno<>$lastpgno && $lastpgno>0) ){ echo ""; } } function ListPgFront($url,$pageno,$PageSize,$BlockPage,$totalrows) { /* 맨 처음 1 2 3 4 5 맨 마지막 */ $lastpgno=(int)@ceil($totalrows/$PageSize); //마지막 페이지 $now_num = (int) @ceil($pageno/$BlockPage); $start_num = (int) ($now_num - 1) * $BlockPage; $end_num = (int) $now_num * $BlockPage; $next_num = (int) $end_num + 1;//마지막 페이지 값 구함 $prev_num = (int) $start_num;//시작 페이지 값 구함 //처음 if($pageno<>1) { echo "맨앞"; } //이전 if($now_num > 1) { echo "이전"; } //블럭단위 페이징 for ($i = $start_num + 1; $i <= $end_num && $i <= $lastpgno; $i++) { if ($i == $pageno) { echo " $i "; } else { echo "$i "; } } //다음 if($end_num < $lastpgno) { echo " 다음"; } //마지막 if($pageno<>$lastpgno && $lastpgno>0 ) { echo "맨뒤"; } } //원격지 아이피 얻기 function getIp() { return $_SERVER["REMOTE_ADDR"]; } /* 파일을 다운로드 받고자 할때 사용하는 함수이다. 사용법은 자기 자신의 페이지를 리플래쉬 하면서 함수를 호출하는 방식으로 하면된다. downloadname : 다운로드 받을때의 이름 filepath : 화일의 서버경로(시스템 경로나 상대경로) */ function fileDownload($downloadname, $filepath) { $HTTP_USER_AGENT=$_SERVER["HTTP_USER_AGENT"]; Header("Cache-Control: must-revalidate, post-check=0, pre-check=0"); $filesize=@filesize($filepath); if(strstr($HTTP_USER_AGENT, "MSIE 6.")) { Header("Content-type: application/x-msdownload"); Header("Content-Length: $filesize"); Header("Content-Disposition: attachment; filename=$downloadname"); Header("Content-Transfer-Encoding: binary"); Header("Pragma: no-cache"); Header("Expires: 0"); } else if(strstr($HTTP_USER_AGENT, "MSIE 5.5")) { header("Content-Type: doesn/matter"); header("Content-disposition: filename=$downloadname"); header("Content-Transfer-Encoding: binary"); header("Pragma: no-cache"); header("Expires: 0"); } else if(strstr($HTTP_USER_AGENT, "MSIE 5.0")) { Header("Content-type: file/unknown"); header("Content-Disposition: attachment; filename=$downloadname"); Header("Content-Description: PHP3 Generated Data"); header("Pragma: no-cache"); header("Expires: 0"); } else { if (eregi('(htm|php|txt|gif|jpg|jpeg|png)',$tmp1)) { $filename .='.file'; } Header("Content-type: file/unknown"); header("Content-Disposition: attachment; filename=$downloadname"); Header("Content-Description: PHP3 Generated Data"); header("Pragma: no-cache"); header("Expires: 0"); } header("Content-Description: File Transfert"); @readfile($filepath); exit; } //파일사이즈 function getFileSize($userfile_size) { if($userfile_size < 1024) $userfile_size=$userfile_size." B"; else if ($userfile_size >1024 && $userfile_size < 1024 *1024) $userfile_size=sprintf("%0.1f K",$userfile_size / 1024); else $userfile_size=sprintf("%0.1f M",$userfile_size / (1024*1024)); return $userfile_size; } function total_size($USER_PATH){ $quota = exec("du -sk $USER_PATH"); $Total = explode("$USER_PATH", $quota); $Total = trim($Total[0]); $Total=getFileSize(($Total*1024)); return $Total; } function val_array($userval,$keyval) { while(list($key,$val) = each($userval)) { if($keyval==$key) $Val_Array=$val; } return $Val_Array; } function mod_checked($usercol,$userval) { if($usercol==$userval) $Val_Array= "checked"; return $Val_Array; } function mod_selected($usercol,$userval) { if($usercol==$userval) $Val_Array= "selected"; return $Val_Array; } function mod_filepath($usercol,$userval,$url,$width='35') { if(file_exists($usercol)) { $Val_Array=" Del"; return $Val_Array; } } function view_filepath($usercol,$userval) { if($usercol) { $Val_Array=" "; return $Val_Array; } } function view_file($usercol,$userval) { if($usercol) { $Val_Array=" "; echo $Val_Array; } } function getDatePlus($plus_y,$plus_m,$plus_d,$type) { return date($type,mktime(0,0,0,date("m")+$plus_m,date("d")+$plus_d,date("Y")+$plus_y)); } function getDateDay($y,$m,$d,$type) { return date($type,mktime(0,0,0,$m,$d,$y)); } function getDaySearchForm($yp,$mp,$dp,$ys,$ms,$ds,$yg,$mg,$dg,$oc,$nm,$el,$sy) { //getDaySearchForm(출력(년,월,일),삽입(년,월,일),초기값(년,월,일),event,name,기본셋팅,시작년도) $year = (!$yg) ? (!$el) ? date("Y") : substr($el,0,4) : $yg; $month = (!$mg) ? (!$el) ? date("m") : substr($el,4,2) : $mg; $day = (!$dg) ? (!$el) ? date("d") : substr($el,6,2) : $dg; if($yp) { $rtn = "\n\n"; } if($mp) { $rtn .= "\n\n"; } if($dp){ $rtn .= "\n\n"; } return $rtn; } function get_excel_content($db,$table,$SQL) { $result = mysql_db_query($db, "SELECT * FROM $table $SQL"); print "\r\n"; print "\r\n"; for($j = 0; $j < mysql_num_fields($result); $j++) { print "\r\n"; } print "\r\n"; while ($row = mysql_fetch_row($result)) { print "\r\n"; for($j = 0; $j < mysql_num_fields($result); $j++) { print "\r\n"; } print "\r\n"; } print "
".mysql_field_name($result,$j)."
".stripslashes($row[$j])."
\r\n"; print ""; } function FileView($file1_,$w,$h) { if($file1_) { if(eregi(".(gif|jpg|jpeg|bmp|ico|png)$",$file1_[0])) $viewfile = "".reSizeImg('/board/upload/'.$file1_[0],$w,$h).""; if(eregi(".(asf|mp3|mp2|mp4|avi|wm|wmx|wmp|wax|dat|wvx|mpe|m1v|mpv2|mp2v|mpa|m3u|midi|rmi|ivf|aif|aifc|aiff|au|snd|cda|mpg|mpeg|wma|wmv|asx|wav|mid)$",$file1_[0])) $viewfile = ""; } return $viewfile; } function DownFile($file1_,$url) { $downfile=" $file1_[1] ($file1_[2])"; return $downfile; } function generatePassword($length) { $lowercase = "qwertyuiopasdfghjklzxcvbnm"; $numbers = "1234567890"; $randomCode = ""; mt_srand(crc32(microtime())); $max = strlen($lowercase) - 1; for ($x = 0; $x < abs($length/2); $x++) { $randomCode .= $lowercase[mt_rand(0, $max)]; } $max = strlen($numbers) - 1; for ($x = 0; $x < abs($length/2); $x++) { $randomCode .= $numbers[mt_rand(0, $max)]; } return str_shuffle($randomCode); } function upload($filearray, $targetdir, $max_size, $allowext){ $max_size = $max_size * 2048 * 2048; // 바이트로 계산한다. 1MB = 1024KB = 1048576Byte if(!is_dir($targetdir)){ @mkdir($targetdir, 0777); } //차량이미지 등록시 ratio도 같이 생성 if(strpos($targetdir, 'uploadfile/car/') !== false) { if(!is_dir($targetdir.'ratio/')){ @mkdir($targetdir.'ratio/', 0777); } } if($filearray['size'] > $max_size){ return false; }else { $file_ext = strtolower(end(explode('.', $filearray['name']))); if($allowext!=null){ if(in_array($file_ext, array_change_key_case($allowext,CASE_LOWER))){ $file_name = rand(10000,99999)."_".$filearray['name']; $file_name = preg_replace ("/[ #\&\+\-%@=\/\\\:;,\'\"\^`~\|\!\?\*$#<>()\[\]\{\}]/i", "", $file_name); $path = $targetdir . '/' . $file_name; if(copy($filearray['tmp_name'], $path)){ return $file_name; }else{ return false; // 실패 했을 경우에는 false를 출력합니다. } }else{ return false; } }else{ $file_name = $file_ext."_".time().".".$file_ext; $file_name = preg_replace ("/[ #\&\+\-%@=\/\\\:;,\'\"\^`~\|\!\?\*$#<>()\[\]\{\}]/i", "", $file_name); $path = $targetdir . '/' . $file_name; if(copy($filearray['tmp_name'], $path)){ return $file_name; }else{ return false; } } } } function sendMail($to, $to_name, $from, $from_name, $subject, $comment, $type="1", $cc="", $bcc="") { $recipient = "=?utf-8?B?".base64_encode($to_name)."?= <$to>"; // 글내용이 text타입 if($type == 2) $comment = nl2br(htmlspecialchars($comment)); $fmail = 'design@interscope.co.kr';//후이즈 정책으로 fmail고정 $headers = "From: =?utf-8?B?".base64_encode($from_name)."?= <{$from}>\r\n"; $headers .= "X-Sender: <$from>\n"; $headers .= "X-Mailer: PHP ".phpversion()."\n"; $headers .= "X-Priority: 1\n"; $headers .= "Return-Path: <$from>\n"; $headers .= "Content-Type: text/html; "; $headers .= "charset=utf-8\n"; $headers .= "Content-Transfer-Encoding: base64\n"; if($cc) $headers .= "cc: $cc\n"; if($bcc) $headers .= "bcc: $bcc"; $comment = stripslashes($comment); $comment = str_replace("\n\r","\n", $comment); //return mail($recipient , '=?utf-8?B?'.base64_encode($subject).'?=' , base64_encode($comment) , $headers); return mail($recipient , '=?utf-8?B?'.base64_encode($subject).'?=' , base64_encode($comment) , $headers, '-f'.$fmail);//후이즈 정책으로 변경 } function chk_file($tmpfile, $file) { if (!is_uploaded_file($tmpfile)) { return false; } $ext = strtolower(pathinfo($file, PATHINFO_EXTENSION)); if (!in_array($ext, array('png','jpeg','jpg'))) { echo '확장자가png,jpeg,jpg인 것만 올려주세요'; return false; } // 여기서 에러가 나면 // PHP.ini 파일에서 extension=fileinfo.so, // 혹은extension=php_fileinfo.dll 코멘트 제거 해주시고 재기동 $finfo = finfo_open(FILEINFO_MIME_TYPE); $mime_type = finfo_file($finfo, $tmpfile); if (!in_array($mime_type, array('image/png', 'image/jpeg'))) { echo '이미지 파일이 아니에요'; return false; } return true; } if (!function_exists('json_encode')) { function json_encode($data) { $json = new Services_JSON(); return( $json->encode($data) ); } } if( !function_exists('json_decode') ) { function json_decode($data) { $json = new Services_JSON(); return( $json->decode($data) ); } } function mail_send($mail_title, $mail_content, $arr_email, $arr_name){ try { $mail = new PHPMailer(true); $mail->IsSMTP(); // send via SMTP $mail->Host = MAILHOST; $mail->Port = MAILPORT; $mail->Mailer = "smtp"; $mail->CharSet = "euc-kr"; $mail->Encoding = "base64"; $mail->Username = GUSER; //SMTP 사용자 이름 $mail->Password = GPWD; //SMTP 비밀번호 $mail->SMTPAuth = true; // turn on SMTP authentication $mail->SMTPSecure = 'ssl'; $webmaster_email = GUSER; // 답변을 받을 이메일 $mail->From = GUSER; $mail->FromName = "WEBMASTER"; // 보내는 사람 이름 $email = explode("|", $arr_email); $name = explode("|", $arr_name); for($i=0; $iAddAddress($email[$i], iconv("UTF-8","EUC-KR",$name[$i])); } $mail->AddReplyTo($webmaster_email,"Webmaster"); $mail->WordWrap = 50; // set word wrap $mail->IsHTML(true); // HTML의 형식으로 보냄 $mail->Subject = iconv("UTF-8","EUC-KR",$mail_title); // 메일 이름 $mail_fileName = $_SERVER['DOCUMENT_ROOT'].'/common/templet/admin_mail.html'; $fp = fopen($mail_fileName, "r"); $fr = fread($fp, filesize($mail_fileName)); fclose($fp); $fr = str_replace("[[nm_title]]",$mail_title, $fr); // 제목 $fr = str_replace("[[nm_cont]]",$mail_content, $fr); // 내용 $mail->Body = iconv("UTF-8","EUC-KR",$fr); // 내용 $mail->AltBody = $mail_content; $mail->IsSMTP(); $mail->Send(); return true; } catch (phpmailerException $e) { //echo $e->errorMessage(); //Pretty error messages from PHPMailer //die(); return false; } catch (Exception $e) { //echo $e->getMessage(); //Boring error messages from anything else! //die(); return false; } } function getCode($table, $column , $code){ $code=@mysql_result(mysql_query("select nm_name from code_master where nm_table='".$table."' and nm_column='".$column."' and nm_code='".$code."' and ds_delind='N'"),0,0); return $code; } //단순형 웹연동 개요 : SMS를 발송할때 POST 방식으로 메시지를 날려줍니다. //웹모듈은 등록된 사용자만 메시지 전송이 가능하며, 특정 아이피에서만 발송을 원하시는 경우 웹연동 사용자 등록후 "회원정보 수정" 에서 아이피를 등록해주시면 됩니다. //단순형 모듈은 한번에 관리자1명에게만 문자가 통보가 되는 형태이며, 다중의 관리자가 있는경우 각각의 관리자 수만큼 루프를 돌린후 1명단위로 get_url_fsockopen을 호출하시면 됩니다. function get_url_fsockopen($url,$vars){ $result = array(); $URL_parsed = parse_url($url); $host = $URL_parsed["host"]; $port = ($URL_parsed["port"]) ? $URL_parsed["port"] : 80; $path = $URL_parsed["path"]; $request.="POST ".$path." HTTP/1.1\r\n"; $request.="Host: ".$host.":".$port."\r\n"; $request.="Referer: $referer\r\n"; $request.="Content-type: application/x-www-form-urlencoded\r\n"; $request.="Content-length: ".strlen($vars)."\r\n"; $request.="Connection: close\r\n"; $request.="\r\n"; $request.=$vars."\r\n"; $fp = fsockopen($host, $port, $errno, $errstr, 30); fputs($fp, $request); while(!feof($fp)) { $result[] .= fgets($fp, 128); } fclose($fp); return $result[10]; } //오늘 반환 function now(){ return date ("Y-m-d H:i:s"); } function getymd(){ return date ("Ymd"); } function nowDate(){ $week = array("일", "월", "화", "수", "목", "금", "토"); $s = $week[date("w")]; return date ("Y"."년 "."m"."월 "."d"."일 "). "(".$s.")"; } function tag($str,$len){ return cutstring(stripslashes(strip_tags($str)),$len); } function databr($str){ return str_replace("\n","
", $str); } /*ExcelPrint*/ function to_excel($array, $filename) { header('Content-type: application/vnd.ms-excel'); header('Content-Disposition: attachment; filename='.$filename.'.xls'); $h = array(); foreach($array->result_array() as $row){ foreach($row as $key=>$val){ if(!in_array($key, $h)){ $h[] = $key; } } } //echo the entire table headers echo ''; foreach($h as $key) { $key = ucwords($key); echo ''; } echo ''; foreach($array->result_array() as $row){ echo ''; foreach($row as $val){ echo ''; } } echo ''; echo '
'.$key.'
'.utf8_decode($val).'
'; } //FTP 파일전송(타서버전송됨) function ftp_upload($files, $source_dir, $target_dir){ $ftp_host = "alis2.news.naver.com"; $ftp_user = "ktnews_s"; $ftp_pass = "ktnews_sb4UYdxD=jn"; $result = 0; $conn_id = ftp_connect($ftp_host); $login_result = ftp_login($conn_id, $ftp_user, $ftp_pass); if(!$conn_id || !$login_result) { $result = 999; return; } $dir = ftp_chdir($conn_id, $target_dir); $files = explode(',',$files); foreach($files as $file){ $file = trim($file); $d = explode('/',$file); if(count($d)>1){ $dir_sub = ""; for($i=0;$i= 1) ? "Mobile" : "Computer"; } //이미지 파일 업로드 function _upload_car_image($upload_path, $upload_ratio_path, $param_filename, $max_size, $thumb = false) { $res = array("result" => true, "msg"=> "", "filename"=> "", "thumb_info" => array()); //이미지 첨부파일 등록 여부 체크 if (is_uploaded_file($_FILES[$param_filename]['tmp_name'])) { if($_FILES[$param_filename]['size'] > 0 ){ $upload_file_name = upload($_FILES[$param_filename],$upload_path, $max_size, array('gif', 'jpeg', 'jpg','png','bmp' ,'ttif')); //첨부파일 업로드 실패 if($upload_file_name==false){ $res["result"] = false; $res["msg"] = "첨부파일 업로드 실패 하였습니다"; } //업로드 성공 else { $res["filename"] = $upload_file_name; // create_watermark($upload_path.$upload_file_name); if($thumb == true) { // echo $upload_path.$upload_file_name.'
'; // echo $upload_ratio_path.$upload_file_name.'
'; // exit; $thumb = array( 'o_path' => $upload_path.$upload_file_name, 'n_path' => $upload_ratio_path.$upload_file_name, 'mode' => 'ratio', 'width' => CAR_THUM2_WIDTH, 'height' => CAR_THUM2_HEIGHT, 'preview_yn' => 'N','o_name' =>$upload_file_name ); $thumb_info = getThumb($thumb); if($_SERVER['REMOTE_ADDR'] == '220.86.24.199') { // print_r($thumb_info); // exit; } $res["thumb_info"] = $thumb_info; } } } } return $res; } //차량 이미지를 가져옴 function getCarBasicImage($cd_car, $img, $title = "이미지", $bsumogallery = false, $sumogallery_group='basic') { $sumo_tag = ""; $no_image = "/img/car_basic_no_image_1000x600.png"; $no_thumb_image = "/img/car_basic_no_image_90x70.png"; $img_src = UPLOAD_PATH_CAR.$cd_car."_main/".$img;//."nm_file_main/".$img; $img_thumb_src = UPLOAD_PATH_CAR.$cd_car."_main/ratio/".$img; $img_thumb_src = UPLOAD_PATH_CAR.$cd_car."_main/".$img; //해당 파일이 없다면 no이미지로 대체 if(!is_file($_SERVER['DOCUMENT_ROOT'].$img_src)) { $img_src = $no_image; $img_thumb_src = $no_thumb_image; } //존재하면 파일타임을 파라미터로 사용 else { $img_filemtime = filemtime($_SERVER['DOCUMENT_ROOT'].$img_src); $img_src.= '?time='.$img_filemtime; $img_thumb_src.= '?time='.$img_filemtime; } //sumo gallery 용 if($bsumogallery == true) { $sumo_tag = " data-sgallery='".$sumogallery_group."' data-full='".$img_src."' data-thumb='".$img_thumb_src."' "; } $img_tag = ""; return $img_tag; } //차량 이미지를 가져옴 function getCarBasicImageString($cd_car, $img, $title = "이미지") { $sumo_tag = ""; $no_image = "/img/car_basic_no_image_1000x600.png"; $no_thumb_image = "/img/car_basic_no_image_90x70.png"; $img_src = UPLOAD_PATH_CAR.$cd_car."_main/".$img;//."nm_file_main/".$img; $img_thumb_src = UPLOAD_PATH_CAR.$cd_car."_main/ratio/".$img; $img_thumb_src = UPLOAD_PATH_CAR.$cd_car."_main/".$img; //해당 파일이 없다면 no이미지로 대체 if(!is_file($_SERVER['DOCUMENT_ROOT'].$img_src)) { $img_src = $no_image; $img_thumb_src = $no_thumb_image; } //sumo gallery 용 // if($bsumogallery == true) { // $sumo_tag = " data-sgallery='".$sumogallery_group."' data-full='".$img_src."' data-thumb='".$img_thumb_src."' "; // } // // $img_tag = ""; return $img_thumb_src; } //차량 이미지를 가져옴 function getCarBasicThumbImage($cd_car, $img, $title = "이미지", $bsumogallery = false, $sumogallery_group='basic') { $sumo_tag = ""; $no_image = "/img/car_basic_no_image_1000x600.png"; $no_thumb_image = "/img/car_basic_no_image_90x70.png"; $img_src = UPLOAD_PATH_CAR.$cd_car."_main/".$img;//."nm_file_main/".$img; $img_thumb_src = UPLOAD_PATH_CAR.$cd_car."_main/ratio/".$img; //해당 파일이 없다면 no이미지로 대체 if(!is_file($_SERVER['DOCUMENT_ROOT'].$img_src)) { $img_src = $no_image; $img_thumb_src = $no_thumb_image; } //존재하면 파일타임을 파라미터로 사용 else { // echo $img_src; // exit; $img_filemtime = filemtime($_SERVER['DOCUMENT_ROOT'].$img_src); $img_src.= '?time='.$img_filemtime; $img_thumb_src.= '?time='.$img_filemtime; } // echo $_SERVER['DOCUMENT_ROOT'].$img_src; // exit; //sumo gallery 용 if($bsumogallery == true) { $sumo_tag = " data-sgallery='".$sumogallery_group."' data-full='".$img_src."' data-thumb='".$img_thumb_src."' "; } $img_tag = ""; return $img_tag; } //차량 이미지를 가져옴 function getCarAddtionalImage($cd_car, $img, $title = "이미지", $bsumogallery = false, $sumogallery_group='basic') { $sumo_tag = ""; $no_image = "/img/car_basic_no_image_1000x600.png"; $no_thumb_image = "/img/car_basic_no_image_90x70.png"; $img_src = UPLOAD_PATH_CAR.$cd_car."_detail/".$img; $img_thumb_src = UPLOAD_PATH_CAR.$cd_car."_detail/".$img; //해당 파일이 없다면 no이미지로 대체 if(!is_file($_SERVER['DOCUMENT_ROOT'].$img_src)) { $img_src = $no_image; $img_thumb_src = $no_thumb_image; } //존재하면 파일타임을 파라미터로 사용 else { // echo $img_src; // exit; $img_filemtime = filemtime($_SERVER['DOCUMENT_ROOT'].$img_src); $img_src.= '?time='.$img_filemtime; $img_thumb_src.= '?time='.$img_filemtime; } //sumo gallery 용 if($bsumogallery == true) { $sumo_tag = " data-sgallery='".$sumogallery_group."' data-full='".$img_src."' data-thumb='".$img_thumb_src."' "; } $img_tag = ""; return $img_tag; } //차량 이미지를 가져옴 function getCarAddtionalThumbImage($cd_car, $img, $title = "이미지", $bsumogallery = false, $sumogallery_group='basic') { $sumo_tag = ""; $no_image = "/img/car_basic_no_image_1000x600.png"; $no_thumb_image = "/img/car_basic_no_image_90x70.png"; $img_src = UPLOAD_PATH_CAR.$cd_car."_detail/".$img; $img_thumb_src = UPLOAD_PATH_CAR.$cd_car."_detail/".$img; //해당 파일이 없다면 no이미지로 대체 if(!is_file($_SERVER['DOCUMENT_ROOT'].$img_src)) { $img_src = $no_image; $img_thumb_src = $no_thumb_image; } //존재하면 파일타임을 파라미터로 사용 else { // echo $img_src; // exit; $img_filemtime = filemtime($_SERVER['DOCUMENT_ROOT'].$img_src); $img_src.= '?time='.$img_filemtime; $img_thumb_src.= '?time='.$img_filemtime; } //sumo gallery 용 if($bsumogallery == true) { $sumo_tag = " data-sgallery='".$sumogallery_group."' data-full='".$img_src."' data-thumb='".$img_thumb_src."' "; } $img_tag = ""; return $img_tag; } //차량 낙찰 이후 이미지를 가져옴 function getCarContractImage($cd_sale, $img, $title = "이미지", $bsumogallery = false, $sumogallery_group='basic') { $sumo_tag = ""; $no_image = "/img/car_basic_no_image_1000x600.png"; $no_thumb_image = "/img/car_basic_no_image_90x70.png"; $img_src = UPLOAD_PATH.'aap/contract_step/'.$cd_sale.'_detail/'.$img; $img_thumb_src = UPLOAD_PATH.'aap/contract_step/'.$cd_sale.'_detail/'.$img; // echo $img_src; //해당 파일이 없다면 no이미지로 대체 if(!is_file($_SERVER['DOCUMENT_ROOT'].$img_src)) { $img_src = $no_image; $img_thumb_src = $no_thumb_image; } //존재하면 파일타임을 파라미터로 사용 else { // echo $img_src; // exit; $img_filemtime = filemtime($_SERVER['DOCUMENT_ROOT'].$img_src); $img_src.= '?time='.$img_filemtime; $img_thumb_src.= '?time='.$img_filemtime; } //sumo gallery 용 if($bsumogallery == true) { $sumo_tag = " data-sgallery='".$sumogallery_group."' data-full='".$img_src."' data-thumb='".$img_thumb_src."' "; } $img_tag = ""; return $img_tag; } function getThumb($param){ if(empty($param['o_path'])) return array('bool' => false, 'msg' => '원본 파일 경로가 없습니다.'); if(empty($param['n_path'])) return array('bool' => false, 'msg' => '원본 파일 경로가 없습니다.'); if(!in_array($param['mode'], array('ratio', 'fixed'))) $param['mode'] = 'ratio'; if(empty($param['width'])) $param['width'] = 300; if(empty($param['height'])) $param['height'] = 300; if(!in_array($param['fill_yn'], array('Y', 'N'))) $param['fill_yn'] = 'N'; if(!in_array($param['preview_yn'], array('Y', 'N'))) $param['preview_yn'] = 'Y'; if(empty($param['o_name'])) $param['o_name'] = ''; // 미리보기 방지 이미지 url //if($param['preview_yn'] == 'N') $param['o_path'] = './hidden.png'; $src = array(); $dst = array(); $src['path'] = $param['o_path']; $dst['path'] = $param['n_path']; // 썸네일 이미지 갱신 기간 (1주일) if(file_exists($dst['path'])){ // if(mktime() - filemtime($dst['path']) < 60 * 60 * 24 * 7) return array('bool' => true, 'src' => $dst['path']); } $imginfo = getimagesize($src['path']); $src['mime'] = $imginfo['mime']; // if($_SERVER['REMOTE_ADDR'] == '220.86.24.199') { // print_r($imginfo); // exit; // } // 원본 이미지 리소스 호출 switch($src['mime']){ case 'image/jpeg' : $src['img'] = imagecreatefromjpeg($src['path']); break; case 'image/gif' : $src['img'] = imagecreatefromgif($src['path']); break; case 'image/png' : $src['img'] = @imagecreatefrompng($src['path']); break; case 'image/bmp' : $src['img'] = imagecreatefrombmp($src['path']); break; case 'image/webp' : $src['img'] = imagecreatefromwebp($src['path']); break; // mime 타입이 해당되지 않으면 return false default : return array('bool' => false, 'msg' => '이미지 파일이 아닙니다.'); break; } // 원본 이미지 크기 / 좌표 초기값 $src['w'] = $imginfo[0]; $src['h'] = $imginfo[1]; $src['x'] = 0; $src['y'] = 0; // 썸네일 이미지 좌표 초기값 설정 $dst['x'] = 0; $dst['y'] = 0; // 썸네일 이미지 가로, 세로 비율 계산 $dst['ratio']['w'] = $src['w'] / $param['width']; $dst['ratio']['h'] = $src['h'] / $param['height']; switch($param['mode']){ case 'ratio' : // 썸네일 이미지의 비율계산 (가로 == 세로) if($dst['ratio']['w'] == $dst['ratio']['h']){ $dst['w'] = $param['width']; $dst['h'] = $param['height']; } // 썸네일 이미지의 비율계산 (가로 > 세로) elseif($dst['ratio']['w'] > $dst['ratio']['h']){ $dst['w'] = $param['width']; $dst['h'] = round(($param['width'] * $src['h']) / $src['w']); } // 썸네일 이미지의 비율계산 (가로 < 세로) elseif($dst['ratio']['w'] < $dst['ratio']['h']){ $dst['w'] = round(($param['height'] * $src['w']) / $src['h']); $dst['h'] = $param['height']; } if($param['fill_yn'] == 'Y'){ $dst['canvas']['w'] = $param['width']; $dst['canvas']['h'] = $param['height']; $dst['x'] = $param['width'] > $dst['w'] ? ($param['width'] - $dst['w']) / 2 : 0; $dst['y'] = $param['height'] > $dst['h'] ? ($param['height'] - $dst['h']) / 2 : 0; } else{ $dst['canvas']['w'] = $dst['w']; $dst['canvas']['h'] = $dst['h']; } break; case 'fixed' : // 썸네일 이미지의 비율계산 (가로 == 세로) if($dst['ratio']['w'] == $dst['ratio']['h']){ $dst['w'] = $param['width']; $dst['h'] = $param['height']; } // 썸네일 이미지의 비율계산 (가로 > 세로) elseif($dst['ratio']['w'] > $dst['ratio']['h']){ $dst['w'] = $src['w'] / $dst['ratio']['h']; $dst['h'] = $param['height']; $src['x'] = ($dst['w'] - $param['width']) / 2; } // 썸네일 이미지의 비율계산 (가로 < 세로) elseif($dst['ratio']['w'] < $dst['ratio']['h']){ $dst['w'] = $param['width']; $dst['h'] = $src['h'] / $dst['ratio']['w']; $dst['y'] = 0; } $dst['canvas']['w'] = $param['width']; $dst['canvas']['h'] = $param['height']; break; } // 썸네일 이미지 리소스 생성 $dst['img'] = imagecreatetruecolor($dst['canvas']['w'], $dst['canvas']['h']); // 배경색 처리 //배경색 기능 없앰 2020-05-28 // if(in_array($src['mime'], array('image/png', 'image/gif'))){ // // 배경 투명 처리 // imagetruecolortopalette($dst['img'], false, 255); // $bgcolor = imagecolorallocatealpha($dst['img'], 255, 255, 255, 127); // imagefilledrectangle($dst['img'], 0, 0, $dst['canvas']['w'],$dst['canvas']['h'], $bgcolor); // } // else{ // // 배경 흰색 처리 // $bgclear = imagecolorallocate($dst['img'],255,255,255); // imagefill($dst['img'],0,0,$bgclear); // } // 원본 이미지 썸네일 이미지 크기에 맞게 복사 imagecopyresampled($dst['img'],$src['img'],$dst['x'],$dst['y'],$src['x'],$src['y'],$dst['w'],$dst['h'],$src['w'],$src['h']); // imagecopyresampled 함수 사용 불가시 사용 //imagecopyresized($dst['img'],$src['img'],$dst['x'],$dst['y'],$src['x'],$src['y'],$dst['w'],$dst['h'],$src['w'],$src['h']); ImageInterlace($dst['img']); // 썸네일 이미지 리소스를 기반으로 실제 이미지 생성 switch($src['mime']){ case 'image/jpeg' : imagejpeg($dst['img'], $dst['path']); break; case 'image/gif' : imagegif($dst['img'], $dst['path']); break; case 'image/png' : imagepng($dst['img'], $dst['path']); break; case 'image/bmp' : imagebmp($dst['img'], $dst['path']); break; case 'image/webp' : imagewebp($dst['img'], $dst['path']); break; } // 원본 이미지 리소스 종료 imagedestroy($src['img']); // 썸네일 이미지 리소스 종료 imagedestroy($dst['img']); // 썸네일 파일경로 존재 여부 확인후 리턴 return file_exists($dst['path']) ? array('bool' => true, 'src' => $dst['path'],'fileName'=>$param['o_name']) : array('bool' => false, 'msg' => '파일 생성에 실패하였습니다.'); } function date_diff_d($str1, $str2) { $frdt = strtotime($str1); $todt = strtotime($str2); $diff = ($todt - $frdt)/(60*60*24); return $diff; } if(!function_exists('right')) { function right($value, $count){ $value = mb_substr($value, (mb_strlen($value) - $count), mb_strlen($value)); return $value; } } if(!function_exists('left')) { function left($string, $count){ return mb_substr($string, 0, $count); } } if(!function_exists('conv_date')) { function conv_date($date, $format){ $datetime = date_create($date); return date_format($datetime, $format); } } if(!function_exists('add_birth_hyphen')) { // 전화번호의 숫자만 취한 후 중간에 하이픈(-)을 넣는다. function add_birth_hyphen($birth) { return preg_replace("/([0-9]{4})([0-9]{2})([0-9]{2})$/", "\\1-\\2-\\3", $birth); } } if(!function_exists('add_hyphen')) { // 전화번호의 숫자만 취한 후 중간에 하이픈(-)을 넣는다. function add_hyphen($tel) { $tel = preg_replace("/[^0-9]/", "", $tel); // 숫자 이외 제거 if (substr($tel,0,2)=='02') return preg_replace("/([0-9]{2})([0-9]{3,4})([0-9]{4})$/", "\\1-\\2-\\3", $tel); // else if (is_numeric(substr($tel,0,1))) // return preg_replace("/([0-9]{2})([0-9]{3})([0-9]{3,4})([0-9]{4})$/", "\\1-\\2-\\3\\4", $tel); else if (strlen($tel)=='8' && (substr($tel,0,2)=='15' || substr($tel,0,2)=='16' || substr($tel,0,2)=='18')) // 지능망 번호이면 return preg_replace("/([0-9]{4})([0-9]{4})$/", "\\1-\\2", $tel); else return preg_replace("/([0-9]{3})([0-9]{3,4})([0-9]{4})$/", "\\1-\\2-\\3", $tel); } } //기존 회원에서 일반회원, 유프로 직원으로 분류됨에 따라 생성 //구분은 회원정보에 관계사(ds_company_bp)가 있을 경우 유프로 직원이라 함 //return true 시 유프로 직원, false : 일반회원 function getUproMember($cd_user) { $ret = false; $sql=mysql_query("select ds_company_bp from member_master mm where cd_user = '$cd_user' and ds_delind='N' limit 1"); $row = mysql_fetch_array($sql); if(!empty($row[ds_company_bp])) { $ret = true; } return $ret; } //발송취소 시킴 function cancel_tender_sms($connect, $cd_tender_sms) { $sms_sql = "update tender_sms_master set ds_send_status = 'B0' where cd_tender_sms = '$cd_tender_sms' "; // echo $sms_sql; mysql_query($sms_sql, $connect); } //해당 매물을 lock 상태로 업데이트 시킴 function lock_status_tender_sms($connect, $cd_tender_sms) { $sms_sql = "update tender_sms_master set ds_lock_status = 'B0' where cd_tender_sms = '$cd_tender_sms' "; mysql_query($sms_sql, $connect); } //SMS 등록 function insert_tender_sms($connect, $DATA) { //ds_send_status = 발송상태 발송완료 //ds_lock_status = 락처리 필요없음 $sql = "insert into tender_sms_master set cd_sale = '$DATA[cd_sale]' , cd_tender = '$DATA[cd_tender]' , depth = '$DATA[depth]' , nm_hp = '$DATA[tender_nm_hp]' , nm_content = '$DATA[nm_content]' , ds_status = '$DATA[ds_status]' , ds_send_status = '$DATA[ds_send_status]' , ds_lock_status = 'A0' , dt_send = '$DATA[dt_send]' , nm_send = '$DATA[cd_userid]' , dt_insert = now() , nm_insert = '$DATA[cd_userid]' "; $result = mysql_query($sql,$connect); return $result; } //락 필요치 않음으로 업데이트 function no_lock_tender_sms($connect, $cd_tender_sms) { $sms_sql = "update tender_sms_master set ds_lock_status = 'A0' where cd_tender_sms = '$cd_tender_sms' "; // echo $sms_sql; mysql_query($sms_sql, $connect); } //락 설정 function lock_tender_sms($connect, $cd_tender, $cd_tender_sms) { //tender master update $tender_sql = "update tender_master set ds_lock_status = 'A0' , dt_lock = now() where cd_tender = '$cd_tender' "; // echo $tender_sql; mysql_query($tender_sql, $connect); //tender sms master update $sms_sql = "update tender_sms_master set ds_lock_status = 'Z0' where cd_tender_sms = '$cd_tender_sms' "; // echo $sms_sql; mysql_query($sms_sql); } function tender_sms_msg() { $sms_msg = array( 'Z0' => "낙찰중 페이지 {CAR_INFO} 거래 진행처리 진행 부탁드립니다. {PERIOD}일이내 미처리시 입찰이 정지 됩니다.", 'Z1' => "진행중 페이지 {CAR_INFO} 거래 진행처리 진행 부탁드립니다. {PERIOD}일이내 미처리시 입찰이 정지 됩니다.", ); return $sms_msg; } function tender_sms_period() { //1차 5일, 2차 3일, 3차 2일 $sms_period = array(1 => 5, 2 => 3, 3 => 2); return $sms_period; } //파일의 수정일을 기준으로 파일 버전을 가져옴 //현재는 이미지의 갱신을 위해 사용 function get_file_mtime($file_web_path) { $file_path = $_SERVER['DOCUMENT_ROOT'].'/'.$file_web_path; if(file_exists($file_path) && is_file($file_path)) { $file_mtime = filemtime($file_path); }else { $file_mtime = "1"; } return $file_mtime; } if(!function_exists('string_to_asterisk')) { function string_to_asterisk($mode, $str) { $ret = ""; switch($mode) { case 'id': case 'name': $str = trim($str); $length = mb_strlen($str, 'utf-8'); $string_changed = $str; if ($length <= 2) { // 한두 글자면 그냥 뒤에 별표 붙여서 내보낸다. $ret = mb_substr($str, 0, 1, 'utf-8') . '*'; } if ($length >= 3) { // 3으로 나눠서 앞뒤. $leave_length = floor($length/3); // 남겨 둘 길이. 반올림하니 너무 많이 남기게 돼, 내림으로 해서 남기는 걸 줄였다. $asterisk_length = $length - ($leave_length * 2); $offset = $leave_length + $asterisk_length; $head = mb_substr($str, 0, $leave_length, 'utf-8'); $tail = mb_substr($str, $offset, $leave_length, 'utf-8'); $ret = $head . implode('', array_fill(0, $asterisk_length, '*')) . $tail; } break; case 'phone': $str = trim($str); $length = mb_strlen($str, 'utf-8'); $string_changed = $str; if ($length <= 2) { // 한두 글자면 그냥 뒤에 별표 붙여서 내보낸다. $ret = mb_substr($str, 0, 1, 'utf-8') . '*'; } if ($length >= 3) { // 3으로 나눠서 앞뒤. $leave_length = floor($length/3); // 남겨 둘 길이. 반올림하니 너무 많이 남기게 돼, 내림으로 해서 남기는 걸 줄였다. $asterisk_length = $length - ($leave_length * 2); $offset = $leave_length + $asterisk_length; $head = mb_substr($str, 0, $leave_length, 'utf-8'); $tail = mb_substr($str, $offset, $leave_length, 'utf-8'); $ret = $head . implode('', array_fill(0, $asterisk_length, '*')) . $tail; } break; } return $ret; } } function create_watermark($image_path, $watermark_path = "") { if(empty($watermark_path)) { $watermark_path = $_SERVER['DOCUMENT_ROOT'].'/img/logo_watermark.png'; } // $img_path = "/image.jpg"; // 원본 이미지 절대경로 // $watermark_img_path = "/watermark.png"; // 워터마크 이미지 절대경로 // $image_path, $watermark_path 는 반드시 절대경로로 지정해야함 (url이 아닌 path) $array_img_chk = array("jpg", "jpeg", "png", "gif", "bmp"); // 이미지 확장자 $img_ext = explode(".", strrev($image_path)); $img_ext = strrev($img_ext[0]); $img_ext = strtolower($img_ext); $opacity = 0.5; $quality = 90; // 이미지 파일인 경우에만 진행 if(in_array($img_ext, $array_img_chk)) { $img_info = getimagesize($image_path); //확장자는 jpg인데 mime은 image/webp일 경우 에러가 남 //방법이 없음 // print_r($img_info); // exit; if($img_ext == 'jpg' || $img_ext == 'jpeg') $create_img = imagecreatefromjpeg($image_path); if($img_ext == 'png') $create_img = imagecreatefrompng($image_path); if($img_ext == 'gif') $create_img = imagecreatefromgif($image_path); if($img_ext == 'bmp') $create_img = imagecreatefromwbmp($image_path); if($create_img) { // 워터마크 이미지 확장자 $watermark_img_ext = explode(".", strrev($watermark_path)); $watermark_img_ext = strrev($watermark_img_ext[0]); $watermark_img_ext = strtolower($watermark_img_ext); if($watermark_img_ext == 'jpg' || $watermark_img_ext == 'jpeg') $create_watermark_img = imagecreatefromjpeg($watermark_path); if($watermark_img_ext == 'png') $create_watermark_img = imagecreatefrompng($watermark_path); if($watermark_img_ext == 'gif') $create_watermark_img = imagecreatefromgif($watermark_path); if($watermark_img_ext == 'bmp') $create_watermark_img = imagecreatefromwbmp($watermark_path); if($create_watermark_img) { list($img_w, $img_h) = getimagesize($image_path); list($watermark_img_w, $watermark_img_h) = getimagesize($watermark_path); imagealphablending($create_img, true); $create_watermark_opacity_img = imagesetopacity($create_watermark_img, $opacity); // 워터마크 위치 지정 // $pos_x = 50; // $pos_y = 50; // (예시) 워터마크를 정중앙으로 $pos_x = ceil(($img_w - $watermark_img_w) / 2); $pos_y = ceil(($img_h - $watermark_img_h) / 2); imagecopy($create_img, $create_watermark_opacity_img, $pos_x, $pos_y, 0, 0, $watermark_img_w, $watermark_img_h); // imagecopymerge($create_img, $create_watermark_opacity_img, $pos_x, $pos_y, 0, 0, $watermark_img_w, $watermark_img_h, $opacity); /* imagecopy 설명 */ // 원본 이미지 리소스 : $create_img // 워터마크 이미지 리소스 : $create_watermark_img // 워터마크 이미지 x 좌표 : $pos_x // 워터마크 이미지 y 좌표 : $pos_y // 원본 이미지 x 좌표 : 0 // 원본 이미지 y 좌표 : 0 // 워터마크 이미지 가로크기 : $watermark_img_w // 워터마크 이미지 세로크기 : $watermark_img_h //테스트용 // header("Content-type: image/jpeg"); //실제 이미지 생성 imagejpeg($create_img, $image_path, $quality); imagedestroy($create_img); imagedestroy($create_watermark_opacity_img); } } } } function imagesetopacity( $imageSrc, $opacity ) { $width = imagesx( $imageSrc ); $height = imagesy( $imageSrc ); // Duplicate image and convert to TrueColor $imageDst = imagecreatetruecolor( $width, $height ); imagealphablending( $imageDst, false ); imagefill( $imageDst, 0, 0, imagecolortransparent( $imageDst )); imagecopy( $imageDst, $imageSrc, 0, 0, 0, 0, $width, $height ); // Set new opacity to each pixel for ( $x = 0; $x < $width; ++$x ) for ( $y = 0; $y < $height; ++$y ) { $pixelColor = imagecolorat( $imageDst, $x, $y ); $pixelOpacity = 127 - (( $pixelColor >> 24 ) & 0xFF ); if ( $pixelOpacity > 0 ) { $pixelOpacity = $pixelOpacity * $opacity; $pixelColor = ( $pixelColor & 0xFFFFFF ) | ( (int)round( 127 - $pixelOpacity ) << 24 ); imagesetpixel( $imageDst, $x, $y, $pixelColor ); } } return $imageDst; } function emailCheck($_str) { if (preg_match("/^[_\.0-9a-zA-Z-]+@([0-9a-zA-Z][0-9a-zA-Z-]+\.)+[a-zA-Z]{2,6}$/i", $_str) == false) { return false; // array(false, "올바른 이메일 주소를 입력해주세요."); } else { return true; // return array(true); } } //common.js 에서 동일한 함수명으로 스크립용이 존재하도록 설계 했으나 백단에서 처리해도 될 것 같아 스크립트 안만듬 //이차 조아 수수료 정책 SA가 올린 매물에 AAP가 입찰을 하게 될 경우에 반영됨 //2023-04-03 수수료 정책 // function get_sa_aap_commission($price, $ds_tradein, $nm_brand, $is_staff = "N") { // // $commission = ""; // // $price = preg_replace("/[^0-9]*/s", "", $price); // // if(empty($price)) { // return $commission; // } // // $price = (int)$price; // // if($price < 1) { // return $commission; // } // // //SA가 올린 매물만 수수료가 존재 // if($is_staff != 'Y') { // return $commission; // } // // $SA_AAP_SALE_CONDITION = array(); // //트레이드인 아우디 차량 // $SA_AAP_SALE_CONDITION['A0']['AUDI'] = array( // "0" => 255000, // "1" => 310000, // "2" => 365000, // "3" => 520000, // "4" => 675000, // ); // //트레이드인 아우이 이외 // $SA_AAP_SALE_CONDITION['A0']['ETC'] = array( // "0" => 155000, // "1" => 210000, // "2" => 315000, // "3" => 420000, // "4" => 575000, // ); // // $SA_AAP_SALE_CONDITION['B0']['AUDI'] = array( // "0" => 155000, // "1" => 210000, // "2" => 315000, // "3" => 420000, // "4" => 575000, // ); // $SA_AAP_SALE_CONDITION['B0']['ETC'] = array( // "0" => 55000, // "1" => 110000, // "2" => 165000, // "3" => 220000, // "4" => 275000, // ); // // // $brand = ""; // if(strtoupper($nm_brand) == "AUDI" || $nm_brand == "아무디") { // $brand = "AUDI"; // }else { // $brand = "ETC"; // } // // // $condition_index = 0; // // // //100만원 미만 // if($price < 100) { // $condition_index = 0; // } // //100만원 이상 1000만원 미만 // else if($price >= 100 && $price < 1000) { // $condition_index = 1; // } // //1000만원 이상 2000만원 미만 // else if($price >= 1000 && $price < 2000) { // $condition_index = 2; // } // else if($price >= 2000 && $price < 2850) { // $condition_index = 3; // } // else if($price >= 2850) { // $condition_index = 4; // } // // // if($_SERVER['REMOTE_ADDR'] == '220.86.24.199') { // // echo 'price:'.$price; // // echo 'condition_index:'.$condition_index; // // echo 'ds_tradein:'.$ds_tradein; // // print_r($SA_AAP_SALE_CONDITION); // // exit; // // } // // $commission = $SA_AAP_SALE_CONDITION[$ds_tradein][$brand][$condition_index]; // // //관리자 금액이 만원 단위로 표현이 되므로 // // $commission = left($commission, 3); // return $commission; // // } //이차 조아 수수료 정책 SA가 올린 매물에 AAP가 입찰을 하게 될 경우에 반영됨, AAP 수수료를 정의함 //2023-11-08 수수료 정책 function get_sa_aap_commission($price, $ds_tradein, $nm_brand, $is_staff = "N") { $commission = ""; $price = preg_replace("/[^0-9]*/s", "", $price); if(empty($price)) { return $commission; } $price = (int)$price; if($price < 1) { return $commission; } //SA가 올린 매물만 수수료가 존재 if($is_staff != 'Y') { return $commission; } $SA_AAP_SALE_CONDITION = array(); //구간별 수수료는 특정 조건없이 동일 $SA_AAP_SALE_CONDITION = array( "0" => 100000, "1" => 150000, "2" => 200000, "3" => 250000, "4" => 300000, "5" => 350000, ); $brand = ""; if(strtoupper($nm_brand) == "AUDI" || $nm_brand == "아무디") { $brand = "AUDI"; }else { $brand = "ETC"; } //AAP 금액별 구간별 수수료 $condition_index = 0; //100만원 이하 if($price <= 100) { $condition_index = 0; } //101만원 이상 500만원 이하 else if($price >= 101 && $price <= 500) { $condition_index = 1; } //501만원 이상 1000만원 이하 else if($price >= 501 && $price <= 1000) { $condition_index = 2; } //1,001만원 ~ 2,000만원 이하 else if($price >= 1001 && $price <= 2000) { $condition_index = 3; } //2,001만원 ~ 3,000만원 이하 else if($price >= 2001 && $price <= 3000) { $condition_index = 4; } //3001만원 이상 else if($price >= 3001) { $condition_index = 5; } $commission = 0; $commission = $SA_AAP_SALE_CONDITION[$condition_index]; $commission = $commission / 10000; // if($_SERVER['REMOTE_ADDR'] == '220.86.24.199') { // echo 'price:'.$price.'
'; // echo 'condition_index:'.$condition_index.'
'; // echo 'SA_AAP_SALE_CONDITION:'.$SA_AAP_SALE_CONDITION[$condition_index].'
'; // echo 'ds_tradein:'.$ds_tradein.'
'; // echo 'commission:'.$commission.'
'; // print_r($SA_AAP_SALE_CONDITION); // // exit; // } //관리자 금액이 만원 단위로 표현이 되므로 // $commission = left($commission, 3); return $commission; } //이차 조아 수수료 정책 SA가 올린 매물에 AAP가 입찰을 하게 될 경우에 반영됨, 사용자 or SA의 수수료를 정의함 //2023-11-08 수수료 정책 function get_sa_user_commission($price, $ds_tradein, $nm_brand, $is_staff = "N") { $commission = ""; $price = preg_replace("/[^0-9]*/s", "", $price); if(empty($price)) { return $commission; } $price = (int)$price; if($price < 1) { return $commission; } //SA가 올린 매물만 수수료가 존재 if($is_staff != 'Y') { return $commission; } $brand = ""; if(strtoupper($nm_brand) == "AUDI" || $nm_brand == "아무디") { $brand = "AUDI"; }else { $brand = "ETC"; } $commission = 0; //사용자 수수료 적용 체크 // 1. 2850만원 초과 Trade-in 예 차량 중 AUDI, 일반 차량 (AUDI, 일반차량 = 차량 종류가 2개라 굳이 조건식에는 안들어감) // 2. 2850만원 초과 Trade-in 아니오 차량 중 AUDI 차량 if(($price > 2850 && $ds_tradein == 'A0') || ($price > 2850 && $ds_tradein == 'B0' && $brand == 'AUDI')) { //금액을 10만 단위로 변환 $commission = ($price * 0.0105) * 10000; //천단위 올림 $commission = ceil($commission / 1000) * 1000; } if($_SERVER['REMOTE_ADDR'] == '220.86.24.199') { // echo 'price:'.$price.'
'; // echo 'ds_tradein:'.$ds_tradein.'
'; // echo 'commission:'.$commission.'
'; // exit; } //관리자 금액이 만원 단위로 표현이 되므로 // $commission = left($commission, 3); return $commission; } ?>