| 12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333233423352336233723382339234023412342234323442345234623472348234923502351235223532354235523562357235823592360236123622363236423652366236723682369237023712372237323742375237623772378237923802381238223832384238523862387238823892390239123922393239423952396239723982399240024012402240324042405240624072408240924102411241224132414241524162417241824192420242124222423242424252426242724282429243024312432243324342435243624372438243924402441244224432444244524462447244824492450245124522453245424552456245724582459246024612462246324642465246624672468246924702471247224732474247524762477247824792480248124822483248424852486248724882489249024912492249324942495249624972498249925002501250225032504250525062507250825092510251125122513251425152516251725182519252025212522252325242525252625272528252925302531253225332534253525362537253825392540254125422543254425452546254725482549255025512552255325542555255625572558255925602561256225632564256525662567256825692570257125722573257425752576257725782579258025812582258325842585258625872588258925902591259225932594259525962597259825992600260126022603260426052606260726082609261026112612261326142615261626172618261926202621262226232624262526262627262826292630263126322633263426352636263726382639264026412642264326442645264626472648264926502651265226532654265526562657265826592660266126622663266426652666266726682669267026712672267326742675267626772678267926802681268226832684 |
- <?php
- @error_reporting(E_ALL ^ E_NOTICE);
- @extract($_GET);
- @extract($_POST);
- @extract($_SERVER);
- @extract($_ENV);
- // Basic Message Function //
- function err_msg($str="오류발생", $url='',$target='') {
- echo "
- <script>
- alert(\"$str\"); ";
- if(!$url) {
- echo "history.back();";
- } else {
- if( $target ) echo $target . ".";
- echo "location.href='$url';";
- }
- echo "</script>";
- 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 "<script>location.href='error.html?msg=$str&url=$url'</script>";
- die();
- }
- function move_page($path,$time = 0) {
- die("<META http-equiv='refresh' content='$time;URL=$path'>");
- }
- function js_msg($str) {
- $str = addslashes($str);
- echo "<script>alert(\"$str\");</script>";
- }
- 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 "<table width=300 align=center cellspacing=0><tr><td height=50></td></tr><tr bgcolor=#dedfde style='font-family:tahoma;font-size:8pt'><td class=eng heigh=20> <font face=webdings size=2>4</font> <b>ERROR</b></td><td align=right class=eng><a href=javascript:history.back() class=bd><font face=webdings size=2>7</font> <b>BACK</b></a> </td></tr><tr><td colspan=2 bgcolor=#f7f7f7 align=center height=80 style='font-family:돋음;font-size:9pt'><b>$msg</b></td></tr></table>";
- 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: <span style="width: expression(alert('Ping!'));"></span>
- $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('#</*\w+:\w[^>]*+>#i', '', $data);
- do
- {
- // Remove really unwanted tags
- $old_data = $data;
- $data = preg_replace('#</*(?:applet|b(?:ase|gsound|link)|embed|frame(?:set)?|i(?:frame|layer)|l(?:ayer|ink)|meta|object|s(?:cript|tyle)|title|xml)[^>]*+>#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),"<br>",$html);
- if($tags) {
- $html = preg_replace("/<($tags).*?>/i",'<\1>', $html);
- $html = preg_replace("/<\\/($tags)>/i",'</\1>', $html);
- }
- $html = preg_replace('/\0/', '&', $html);
- // $html = preg_replace("/>(http|https|ftp)(:\/\/\S+)<(.+?)");
- // $pattern = "(http://|ftp://)+([0-9a-zA-Z./@~?&=_]+)";
- // $html = ereg_replace($pattern, "<a href=\"\\1\\2\">\\1\\2</a>", $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 "<tr align=center><td height=40><b>등록된 글이 없습니다</b></td></tr>";
- }
- sql_free_result($result);
- }
- function printLatestList($db, $list) {
- $list[title] = preg_match("\"",""",$list[title]);
- $title = sprintf("<tr><td background='/mainimg/newgameback.gif'><table width='232' border='0' cellspacing='2' cellpadding='0' align='center'><tr><td><img src='/mainimg/arrow.gif' width='13' height='11' align='absmiddle'> <a href=\"javascript:openwin2('board/read.php?db=%s&no=%s')\">%s</a></td></tr></table></td></tr><tr><td background='/mainimg/newgameback.gif'><img src='/mainimg/newgamespotline.gif' width='260' height='7'></td></tr>", $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\(\)]+)","<a href=\"\\1://\\2\" target=\"_blank\" class=bd>\\1://\\2</a>",$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-]+)","<a href=\"mailto:\\1\" class=bd>\\1</a>",$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;$i<count($fil);$i++){
- if($i>0)$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;$i<count($fil);$i++){
- if($i>0)$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 "<script>window.status = '$str';</script>";
- }
- // 날짜를 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("
- <html><body>
- <meta charset='UTF-8' />
- <SCRIPT LANGUAGE=\"JavaScript\">
- <!--
- alert(\"$msg\");
- history.back();
- //-->
- </SCRIPT>
- </body></html>
- ");
- exit;
- }
- function Alert($msg){
- echo("
- <html><body>
- <meta charset='UTF-8' />
- <SCRIPT LANGUAGE=\"JavaScript\">
- <!--
- alert(\"$msg\");
- //-->
- </SCRIPT>
- </body></html>
- ");
- exit;
- }
- function AlertExit($msg){
- echo("
- <html><body>
- <meta charset='UTF-8' />
- <SCRIPT LANGUAGE=\"JavaScript\">
- <!--
- alert(\"$msg\");
- self.close();
- //-->
- </SCRIPT>
- </body></html>
- ");
- exit;
- }
- function AlertRedirect($msg,$url){
- echo("
- <html><body>
- <meta http-equiv='Refresh' content='0; URL=$url'>
- <meta charset='UTF-8' />
- <SCRIPT LANGUAGE=\"JavaScript\">
- <!--
- alert(\"$msg\");
- //-->
- </SCRIPT>
- </body></html>
- ");
- exit;
- }
- function AlertRedirectRefresh($msg,$url){
- echo("
- <html><body>
- <meta charset='UTF-8' />
- <SCRIPT LANGUAGE=\"JavaScript\">
- <!--
- opener.location.reload();alert(\"$msg\");
- self.close();
- //-->
- </SCRIPT>
- <meta http-equiv='Refresh' content='0; URL=$url'>
- </body></html>
- ");
- exit;
- }
- function AlertLogin($msg){
- echo("
- <html><body>
- <meta charset='UTF-8' />
- <SCRIPT LANGUAGE=\"JavaScript\">
- <!--
- alert(\"$msg\");
- top.location.href=\"/bkmode/index.html\";
- //-->
- </SCRIPT>
- </body></html>
- ");
- exit;
- }
- function Redirect($url){
- echo("
- <html><body>
- <SCRIPT LANGUAGE=\"JavaScript\">
- <!--
- location.replace('$url');
- //-->
- </SCRIPT>
- </body></html>
- ");
- exit;
- }
- function AlertExitRefresh($msg,$tourl){
- echo("
- <html><body>
- <meta charset='UTF-8' />
- <SCRIPT LANGUAGE=\"JavaScript\">
- <!--
- alert(\"$msg\");
- opener.location.replace('$tourl');
- self.close();
- //-->
- </SCRIPT>
- </body></html>
- ");
- exit;
- }
- function Replace($tourl){
- echo("
- <html><body>
- <SCRIPT LANGUAGE=\"JavaScript\">
- <!--
- location.replace('$tourl');
- //-->
- </SCRIPT>
- </body></html>
- ");
- exit;
- }
- function ExitRedirect($tourl){
- echo("
- <html><body>
- <SCRIPT LANGUAGE=\"JavaScript\">
- <!--
- opener.location.replace('$tourl');
- self.close();
- //-->
- </SCRIPT>
- </body></html>
- ");
- exit;
- }
- function ExitRefresh(){
- echo("
- <html><body>
- <SCRIPT LANGUAGE=\"JavaScript\">
- <!--
- opener.location.reload();
- self.close();
- //-->
- </SCRIPT>
- </body></html>
- ");
- exit;
- }
- function TopExit($tourl){
- echo("
- <html><body>
- <SCRIPT LANGUAGE=\"JavaScript\">
- <!--
- opener.top.location.replace('$tourl');
- self.close();
- //-->
- </SCRIPT>
- </body></html>
- ");
- exit;
- }
- function URL2($tourl,$url){
- echo("
- <html><body>
- <SCRIPT LANGUAGE=\"JavaScript\">
- <!--
- parent.left.location.href='$tourl';
- location.href='$url';
- //-->
- </SCRIPT>
- </body></html>
- ");
- 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 += "<a href=\"javascript:$url(1,$PageSize,'1','#car_list1')\" onFocus=\"this.blur();\" class=\"arr first\">맨 처음</a>";
- }
- //이전
- if($now_num > 1) {
- $html += "<a href=\"javascript:$url($prev_num,$PageSize,'1','#car_list1')\" onFocus=\"this.blur();\" class=\"arr prev\">이전</a>";
- }
- //블럭단위 페이징
- for ($i = $start_num + 1; $i <= $end_num && $i <= $lastpgno; $i++) {
- if ($i == $pageno) {
- $html += " <strong>$i</strong> ";
- }
- else {
- $html += "<a href=\"javascript:$url($i,$PageSize,'1','#car_list1')\" onFocus=\"this.blur();\">$i</a> ";
- }
- }
- //다음
- if($end_num < $lastpgno) {
- $html += " <a href=\"javascript:$url($next_num,$PageSize,'1','#car_list1')\" onFocus=\"this.blur();\" class=\"arr next\">다음</a>";
- }
- //마지막
- if($pageno<>$lastpgno && $lastpgno>0 ) {
- $html += "<a href=\"javascript:$url($lastpgno,$PageSize,'1','#car_list1')\" onFocus=\"this.blur();\" class=\"arr last\">맨 마지막</a>";
- }
- 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 '<div class="btn--right--wrap"></div>';
- // echo '<ul class="pagination">';
- // //이전
- // if($now_num > 1) {
- // // echo "<a href=\"$url&pageno=$prev_num\" onFocus=\"this.blur();\"><</a> <font color=\"#cccccc\">|</font>";
- // echo '<li class="page-item ">
- // <a class="page-link" href="#" aria-label="Previous">
- // <span aria-hidden="true">«</span>
- // </a>
- // </li>';
- // }
- // else{
- // echo "< <font color=\"#CCCCCC\">|</font>";
- // }
- //
- // //블럭단위 페이징
- // for ($i = $start_num + 1; $i <= $end_num && $i <= $lastpgno; $i++) {
- // if ($i == $pageno) {
- // // echo " <font color=\"#00adef\"><B>$i</B></font> <font color=\"#ccccc\">|</font>";
- // echo '<li class="page-item active"><a class="page-link" href="JavaScript">$i</a></li>';
- //
- // }
- // else {
- // // echo " <a href=\"$url&pageno=$i\" onFocus=\"this.blur();\">$i</a> <font color=\"#ccccc\">|</font>";
- // echo '<li class="page-item"><a class="page-link" href="{$url}&pageno={$i}">2</a></li>';
- // }
- // }
- //
- // //다음
- // if($end_num < $lastpgno) {
- // // echo " <a href=\"$url&pageno=$next_num\" onFocus=\"this.blur();\">>";
- // echo '<li class="page-item">
- // <a class="page-link" href="{$url}&pageno={$next_num}" aria-label="Next">
- // <span aria-hidden="true">»</span>
- // </a>
- // </li>';
- // }
- // else{
- // echo " >";
- // }
- // echo '</ul>';
- //
- // // echo '<div class="btn--left--wrap"></div>';
- // }
- //게시판페이징 - 사용자
- 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 "<div class='btn--right--wrap'></div>";
- echo "<ul class='pagination'>";
- if($pageno<>1 || $now_num > 1) {
- // echo "<span>";
- }
- //처음
- if($pageno<>1) {
- // echo "<a href=\"$url&pageno=1\" class=\"first\" onFocus=\"this.blur();\">맨앞</a>";
- }
- //이전
- if($now_num > 1) {
- // echo "<a href=\"$url&pageno=$prev_num\" class=\"prev\" onFocus=\"this.blur();\">이전</a>";
- echo "<li class='page-item '>
- <a class='page-link' href='{$url}&pageno={$prev_num}' aria-label='Previous'>
- <span aria-hidden='true'>«</span>
- </a>
- </li>";
- }
- if($pageno<>1 || $now_num > 1) {
- // echo "</span>";
- }
- //블럭단위 페이징
- for ($i = $start_num + 1; $i <= $end_num && $i <= $lastpgno; $i++) {
- if ($i == $pageno) {
- // echo "<strong>$i</strong>";
- echo "<li class='page-item active'><a class='page-link' href='javascript:;'>$i</a></li>";
- }
- else {
- // echo "<a href=\"$url&pageno=$i\" onFocus=\"this.blur();\">$i</a> ";
- echo "<li class='page-item'><a class='page-link' href='{$url}&pageno={$i}'>{$i}</a></li>";
- }
- }
- if( $end_num < $lastpgno || ($pageno<>$lastpgno && $lastpgno>0) ){
- // echo "<span>";
- }
- //다음
- if($end_num < $lastpgno) {
- // echo " <a href=\"$url&pageno=$next_num\" class=\"next\" onFocus=\"this.blur();\">다음</a>";
- echo "<li class='page-item'>
- <a class='page-link' href='{$url}&pageno={$next_num}' aria-label='Next'>
- <span aria-hidden='true'>»</span>
- </a>
- </li>";
- }
- //마지막
- if($pageno<>$lastpgno && $lastpgno>0 ) {
- // echo "<a href=\"$url&pageno=$lastpgno\" class=\"last\" onFocus=\"this.blur();\">맨뒤</a>";
- }
- if( $end_num < $lastpgno || ($pageno<>$lastpgno && $lastpgno>0) ){
- // echo "</span>";
- }
- echo "</ul>";
- echo "<div class='btn--left--wrap'></div>";
- }
- //게시판페이징 - 사용자
- 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 "<ul class='pagination'>";
- if($pageno<>1 || $now_num > 1) {
- // echo "<span>";
- }
- //처음
- if($pageno<>1) {
- // echo "<a href=\"$url&pageno=1\" class=\"first\" onFocus=\"this.blur();\">맨앞</a>";
- }
- //이전
- if($now_num > 1) {
- // echo "<a href=\"$url&pageno=$prev_num\" class=\"prev\" onFocus=\"this.blur();\">이전</a>";
- echo "<li class='page-item '>
- <a class='page-link' href='{$url}&pageno={$prev_num}' aria-label='Previous'>
- <span aria-hidden='true'>«</span>
- </a>
- </li>";
- }
- if($pageno<>1 || $now_num > 1) {
- // echo "</span>";
- }
- //블럭단위 페이징
- for ($i = $start_num + 1; $i <= $end_num && $i <= $lastpgno; $i++) {
- if ($i == $pageno) {
- // echo "<strong>$i</strong>";
- echo "<li class='page-item active'><a class='page-link' href='javascript:;'>$i</a></li>";
- }
- else {
- // echo "<a href=\"$url&pageno=$i\" onFocus=\"this.blur();\">$i</a> ";
- echo "<li class='page-item'><a class='page-link' href='{$url}&pageno={$i}'>{$i}</a></li>";
- }
- }
- if( $end_num < $lastpgno || ($pageno<>$lastpgno && $lastpgno>0) ){
- // echo "<span>";
- }
- //다음
- if($end_num < $lastpgno) {
- // echo " <a href=\"$url&pageno=$next_num\" class=\"next\" onFocus=\"this.blur();\">다음</a>";
- echo "<li class='page-item'>
- <a class='page-link' href='{$url}&pageno={$next_num}' aria-label='Next'>
- <span aria-hidden='true'>»</span>
- </a>
- </li>";
- }
- //마지막
- if($pageno<>$lastpgno && $lastpgno>0 ) {
- // echo "<a href=\"$url&pageno=$lastpgno\" class=\"last\" onFocus=\"this.blur();\">맨뒤</a>";
- }
- if( $end_num < $lastpgno || ($pageno<>$lastpgno && $lastpgno>0) ){
- // echo "</span>";
- }
- echo "</ul>";
- }
- //게시판페이징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 "<span>";
- }
- //처음
- if($pageno<>1) {
- echo "<a href=\"$url&pageno=1\" class=\"first\" onFocus=\"this.blur();\">맨앞</a>";
- }
- //이전
- if($now_num > 1) {
- echo "<a href=\"$url&pageno=$prev_num\" class=\"prev\" onFocus=\"this.blur();\">이전</a>";
- }
- if($pageno<>1 || $now_num > 1) {
- echo "</span>";
- }
- //블럭단위 페이징
- for ($i = $start_num + 1; $i <= $end_num && $i <= $lastpgno; $i++) {
- if ($i == $pageno) {
- echo "<strong>$i</strong>";
- }
- else {
- echo "<a href=\"$url&pageno=$i\" onFocus=\"this.blur();\">$i</a> ";
- }
- }
- if( $end_num < $lastpgno || ($pageno<>$lastpgno && $lastpgno>0) ){
- echo "<span>";
- }
- //다음
- if($end_num < $lastpgno) {
- echo " <a href=\"$url&pageno=$next_num\" class=\"next\" onFocus=\"this.blur();\">다음</a>";
- }
- //마지막
- if($pageno<>$lastpgno && $lastpgno>0 ) {
- echo "<a href=\"$url&pageno=$lastpgno\" class=\"last\" onFocus=\"this.blur();\">맨뒤</a>";
- }
- if( $end_num < $lastpgno || ($pageno<>$lastpgno && $lastpgno>0) ){
- echo "</span>";
- }
- }
- function ListPgFront($url,$pageno,$PageSize,$BlockPage,$totalrows)
- {
- /*
- <a href="#" class="arr first">맨 처음</a>
- <a href="#" class="arr prev">이전</a>
- <strong>1</strong>
- <a href="#">2</a>
- <a href="#">3</a>
- <a href="#">4</a>
- <a href="#">5</a>
- <a href="#" class="arr next">다음</a>
- <a href="#" class="arr last">맨 마지막</a>
- */
- $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 "<a href=\"$url&pageno=1\" onFocus=\"this.blur();\" class=\"arr first\">맨앞</a>";
- }
- //이전
- if($now_num > 1) {
- echo "<a href=\"$url&pageno=$prev_num\" onFocus=\"this.blur();\" class=\"arr prev\">이전</a>";
- }
- //블럭단위 페이징
- for ($i = $start_num + 1; $i <= $end_num && $i <= $lastpgno; $i++) {
- if ($i == $pageno) {
- echo " <strong>$i</strong> ";
- }
- else {
- echo "<a href=\"$url&pageno=$i\" onFocus=\"this.blur();\">$i</a> ";
- }
- }
- //다음
- if($end_num < $lastpgno) {
- echo " <a href=\"$url&pageno=$next_num\" onFocus=\"this.blur();\" class=\"arr nect\">다음</a>";
- }
- //마지막
- if($pageno<>$lastpgno && $lastpgno>0 ) {
- echo "<a href=\"$url&pageno=$lastpgno\" onFocus=\"this.blur();\" class=\"arr last\">맨뒤</a>";
- }
- }
- //원격지 아이피 얻기
- 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="<img src='$usercol' width='$width'><input type=hidden name=$userval value='$usercol'> <a href='$url' onclick=\"javascript:var msg='삭제하시겠습니까?';return confirm(msg);\"><font color=\"darkorange\"><B>Del</B></font></a>";
- return $Val_Array;
- }
- }
- function view_filepath($usercol,$userval) {
- if($usercol) {
- $Val_Array="<img src='$usercol' width=73 height=47><input type=hidden name='$userval' value='$usercol'> ";
- return $Val_Array;
- }
- }
- function view_file($usercol,$userval) {
- if($usercol) {
- $Val_Array=" <a href=\"javascript:imgwin('/board/preview.html','$usercol');\"><img src='/usedcar/images/icon_photo.gif' border=0 align=absmiddle></a><input type=hidden name=$userval value='$usercol'>";
- 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 = "<select name='syear$nm'$oc>\n";
- for($i = $sy; $i < date("Y")+2; $i++)
- {$rtn .= ($i != $year) ? "<option value='$i'>$i$ys</option>" : "<option value='$i' selected>$i$ys</option>";}
- $rtn .= "\n</select>\n\n";
- }
- if($mp) {
- $rtn .= "<select name='smonth$nm'$oc>\n";
- for($i = 1; $i < 13; $i++)
- {$o = ($i < 10) ? "0".$i : $i;
- $rtn .= ($i != $month) ? "<option value='$o'>$o$ms</option>" : "<option value='$o' selected>$o$ms</option>";}
- $rtn .= "\n</select>\n\n";
- }
- if($dp){
- $rtn .= "<select name='sday$nm'$oc>\n";
- for($i = 1; $i < 32; $i++)
- {$o = ($i < 10) ? "0".$i : $i;
- $rtn .= ($i != $day) ? "<option value='$o'>$o$ds</option>" : "<option value='$o' selected>$o$ds</option>";}
- $rtn .= "\n</select>\n\n";
- }
- return $rtn;
- }
- function get_excel_content($db,$table,$SQL)
- {
- $result = mysql_db_query($db, "SELECT * FROM $table $SQL");
- print "<TABLE BORDER=1 CELLSPACING=1 CELLPADDING=1 WIDTH=100%>\r\n";
- print "<TR BGCOLOR=GOLD ALIGN=CENTER>\r\n";
- for($j = 0; $j < mysql_num_fields($result); $j++) {
- print "<TD width=80 height=16><B>".mysql_field_name($result,$j)."</B></TD>\r\n";
- }
- print "</TR>\r\n";
- while ($row = mysql_fetch_row($result)) {
- print "<TR>\r\n";
- for($j = 0; $j < mysql_num_fields($result); $j++) {
- print "<TD width=80 height=16>".stripslashes($row[$j])."</TD>\r\n";
- }
- print "</TR>\r\n";
- }
- print "</TABLE>\r\n";
- print "</HTML>";
- }
- function FileView($file1_,$w,$h) {
- if($file1_) {
- if(eregi(".(gif|jpg|jpeg|bmp|ico|png)$",$file1_[0])) $viewfile = "<a href=\"javascript:imgwin('preview.html','./upload/$file1_[0]');\">".reSizeImg('/board/upload/'.$file1_[0],$w,$h)."</a>";
- 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 = "<embed src='/board/upload/$file1_[0]'>";
- }
- return $viewfile;
- }
- function DownFile($file1_,$url) {
- $downfile=" <a href='$url'><font color=\"000000\">$file1_[1]</font></a> ($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; $i<count($email); $i++){
- $mail->AddAddress($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","<br/>", $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 '<table><tr>';
- foreach($h as $key) {
- $key = ucwords($key);
- echo '<th>'.$key.'</th>';
- }
- echo '</tr>';
- foreach($array->result_array() as $row){
- echo '<tr>';
- foreach($row as $val){
- echo '<td>'.utf8_decode($val).'</td>';
- }
- }
- echo '</tr>';
- echo '</table>';
- }
- //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<count($d)-1;$i++) {
- if($dir_sub){
- $dir_sub .= "/".$d[$i];
- }else{
- $dir_sub = $d[$i];
- }
- @ftp_mkdir($conn_id, $dir_sub);
- }
- }
- $up = ftp_put($conn_id, $file, $source_dir."/".$file, FTP_BINARY);
- if($up){
- $result++;
- }
- }
- ftp_close($conn_id);
- return $result;
- }
- function random_string($length) {
- $key = '';
- $keys = array_merge(range(0, 9), range('a', 'z'));
- for ($i = 0; $i < $length; $i++) {
- $key .= $keys[array_rand($keys)];
- }
- return $key;
- }
- function getRequestType($type){
- if($type=="A0"){
- return "시승신청";
- }elseif($type=="B0"){
- return "브로셔신청";
- }else{
- return "견적요청";
- }
- }
- function fnGetBbsTitle($type){
- if($type=="01"){
- return "공지사항";
- }else if($type=="02"){
- return "1:1문의";
- }else if($type=="03"){
- return "자주묻는 질문";
- }else{
- return "게시판";
- }
- }
- function reArrayFiles(&$file_post) {
- $file_ary = array();
- $file_count = count($file_post['name']);
- $file_keys = array_keys($file_post);
- for ($i=0; $i<$file_count; $i++) {
- foreach ($file_keys as $key) {
- $file_ary[$i][$key] = $file_post[$key][$i];
- }
- }
- return $file_ary;
- }
- 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 _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.'<br/>';
- // echo $upload_ratio_path.$upload_file_name.'<br/>';
- // 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 = "<img src='".$img_thumb_src."' title='".$title."' $sumo_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 = "<img src='".$img_thumb_src."' title='".$title."' $sumo_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 = "<img src='".$img_thumb_src."' title='".$title."' $sumo_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 = "<img src='".$img_thumb_src."' title='".$title."' $sumo_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 = "<img src='".$img_thumb_src."' title='".$title."' $sumo_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 = "<img src='".$img_thumb_src."' title='".$title."' $sumo_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.'<br/>';
- // echo 'condition_index:'.$condition_index.'<br/>';
- // echo 'SA_AAP_SALE_CONDITION:'.$SA_AAP_SALE_CONDITION[$condition_index].'<br/>';
- // echo 'ds_tradein:'.$ds_tradein.'<br/>';
- // echo 'commission:'.$commission.'<br/>';
- // 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.'<br/>';
- // echo 'ds_tradein:'.$ds_tradein.'<br/>';
- // echo 'commission:'.$commission.'<br/>';
- // exit;
- }
- //관리자 금액이 만원 단위로 표현이 되므로
- // $commission = left($commission, 3);
- return $commission;
- }
- ?>
|