func.20231111.php 71 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332233323342335233623372338233923402341234223432344234523462347234823492350235123522353235423552356235723582359236023612362236323642365236623672368236923702371237223732374237523762377237823792380238123822383238423852386238723882389239023912392239323942395239623972398239924002401240224032404240524062407240824092410241124122413241424152416241724182419242024212422242324242425242624272428242924302431243224332434243524362437243824392440244124422443244424452446244724482449245024512452245324542455245624572458245924602461246224632464246524662467246824692470247124722473247424752476247724782479248024812482248324842485248624872488248924902491249224932494249524962497249824992500250125022503250425052506250725082509251025112512251325142515251625172518251925202521252225232524252525262527252825292530253125322533253425352536
  1. <?php
  2. @error_reporting(E_ALL ^ E_NOTICE);
  3. @extract($_GET);
  4. @extract($_POST);
  5. @extract($_SERVER);
  6. @extract($_ENV);
  7. // Basic Message Function //
  8. function err_msg($str="오류발생", $url='',$target='') {
  9. echo "
  10. <script>
  11. alert(\"$str\"); ";
  12. if(!$url) {
  13. echo "history.back();";
  14. } else {
  15. if( $target ) echo $target . ".";
  16. echo "location.href='$url';";
  17. }
  18. echo "</script>";
  19. die();
  20. }
  21. function nvl($str, $replacestr="") {
  22. if(!$str){
  23. return $replacestr;
  24. }else{
  25. return $str;
  26. }
  27. }
  28. function fnGetDocExt($param){
  29. $allfile = strtolower($param);
  30. $fileinfo = pathinfo($allfile);
  31. $ext = $fileinfo['extension'];
  32. if($ext=="doc" || $ext=="hwp" || $ext=="ppt" || $ext=="pptx" || $ext=="docx" || $ext=="pdf"){
  33. return "doc";
  34. }else{
  35. return "img";
  36. }
  37. }
  38. FUNCTION error_page($str="오류발생",$url="") {
  39. $str = addslashes($str);
  40. if(!$url) $url = $PHP_SELF;
  41. echo "<script>location.href='error.html?msg=$str&url=$url'</script>";
  42. die();
  43. }
  44. function move_page($path,$time = 0) {
  45. die("<META http-equiv='refresh' content='$time;URL=$path'>");
  46. }
  47. function js_msg($str) {
  48. $str = addslashes($str);
  49. echo "<script>alert(\"$str\");</script>";
  50. }
  51. FUNCTION login_please($url) {
  52. $url = urlencode($url);
  53. if(!session_is_registered(MEM_SESS)) {
  54. js_msg('로그인이 필요합니다');
  55. move_page("/login/login.html?url=$url");
  56. }
  57. }
  58. function message($msg){
  59. global $head_url,$foot_url,$head_html,$foot_html;
  60. if ($head_url) include $head_url;
  61. echo stripslashes($head_html);
  62. 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> &nbsp;</td></tr><tr><td colspan=2 bgcolor=#f7f7f7 align=center height=80 style='font-family:돋음;font-size:9pt'><b>$msg</b></td></tr></table>";
  63. echo stripslashes($foot_html);
  64. if ($foot_url) include $foot_url;
  65. exit;
  66. }
  67. function avoid_crack($data)
  68. {
  69. // Fix &entity\n;
  70. $data = str_replace(array('&amp;','&lt;','&gt;'), array('&amp;amp;','&amp;lt;','&amp;gt;'), $data);
  71. $data = preg_replace('/(&#*\w+)[\x00-\x20]+;/u', '$1;', $data);
  72. $data = preg_replace('/(&#x*[0-9A-F]+);*/iu', '$1;', $data);
  73. $data = html_entity_decode($data, ENT_COMPAT, 'UTF-8');
  74. // Remove any attribute starting with "on" or xmlns
  75. $data = preg_replace('#(<[^>]+?[\x00-\x20"\'])(?:on|xmlns)[^>]*+>#iu', '$1>', $data);
  76. // Remove javascript: and vbscript: protocols
  77. $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);
  78. $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);
  79. $data = preg_replace('#([a-z]*)[\x00-\x20]*=([\'"]*)[\x00-\x20]*-moz-binding[\x00-\x20]*:#u', '$1=$2nomozbinding...', $data);
  80. // Only works in IE: <span style="width: expression(alert('Ping!'));"></span>
  81. $data = preg_replace('#(<[^>]+?)style[\x00-\x20]*=[\x00-\x20]*[`\'"]*.*?expression[\x00-\x20]*\([^>]*+>#i', '$1>', $data);
  82. $data = preg_replace('#(<[^>]+?)style[\x00-\x20]*=[\x00-\x20]*[`\'"]*.*?behaviour[\x00-\x20]*\([^>]*+>#i', '$1>', $data);
  83. $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);
  84. // Remove namespaced elements (we do not need them)
  85. $data = preg_replace('#</*\w+:\w[^>]*+>#i', '', $data);
  86. do
  87. {
  88. // Remove really unwanted tags
  89. $old_data = $data;
  90. $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);
  91. }
  92. while ($old_data !== $data);
  93. $data = preg_replace("/[\"\']/i", '\"', $data); //쌍따옴표 치환
  94. $data = preg_replace("/[\"\']/i", "\'", $data); //따옴표 치환
  95. // we are done...
  96. return $data;
  97. }
  98. function text_cut($str, $len){
  99. if(strlen($str) > $len){
  100. if(ord($str[$len - 1]) <= 127) $pos = $len;
  101. else{
  102. for($pos = $len - 1; $pos >= 0; $pos--){
  103. if (ord($str[$pos]) > 127) $h++;
  104. else break;
  105. }
  106. if ($h%2==0) $pos += $h + 1;
  107. else $pos += $h;
  108. }
  109. $str = mb_substr($str, 0, $pos, 'UTF-8');
  110. $str .="..";
  111. }
  112. return $str;
  113. }
  114. function validateAuth($dbpwd, $userpwd) {
  115. global $admin, $uadmin;
  116. if(session_is_registered("administrator")) {
  117. return true;
  118. } else {
  119. if($userpwd == $admin[passwd]) {
  120. // js_msg("유저가 입력한 패스워드와 전체관리자 패스워드가 동일");
  121. return true;
  122. } else if($uadmin[passwd] == crypt($userpwd, $uadmin[passwd])) {
  123. // js_msg("유저가 입력한 패스워드가 로컬관리자 패스워드와 동일");
  124. return true;
  125. }else if(!$dbpwd || !$userpwd) {
  126. // js_msg("db패스워드가 없거나 유저가 패스워드를 입력하지 않음");
  127. return false;
  128. } else if($dbpwd != $userpwd) {
  129. // js_msg("DB패스워드와 유저가 입력한 패스워드는 일치하지 않음");
  130. return false;
  131. } else return true;
  132. } // end outer if
  133. }
  134. function setLocalAdminSession($db, $pwd) {
  135. global $uadmin;
  136. if(!$db || !$pwd) return false;
  137. if($uadmin[passwd] == crypt($pwd, $uadmin[passwd])) {
  138. session_register($db);
  139. return true;
  140. } else {
  141. return false;
  142. }
  143. }
  144. function safeHTML($html, $tags = "b|br|i|u|ul|ol|li") {
  145. $html = preg_replace('/\0/', '', $html);
  146. $html = preg_replace('/\&/', '\0', $html);
  147. $html = htmlspecialchars($html);
  148. $html = str_replace(chr(13).chr(10),"<br>",$html);
  149. if($tags) {
  150. $html = preg_replace("/&lt;($tags).*?&gt;/i",'<\1>', $html);
  151. $html = preg_replace("/&lt;\\/($tags)&gt;/i",'</\1>', $html);
  152. }
  153. $html = preg_replace('/\0/', '&', $html);
  154. // $html = preg_replace("/&gt;(http|https|ftp)(:\/\/\S+)&lt;(.+?)");
  155. // $pattern = "(http://|ftp://)+([0-9a-zA-Z./@~?&=_]+)";
  156. // $html = ereg_replace($pattern, "<a href=\"\\1\\2\">\\1\\2</a>", $html);
  157. return $html;
  158. }
  159. function utf8_length($str) {
  160. $len = strlen($str);
  161. for ($i = $length = 0; $i < $len; $length++) {
  162. $high = ord($str[$i]);
  163. if ($high < 0x80)//0<= code <128 범위의 문자(ASCII 문자)는 인덱스 1칸이동
  164. $i += 1;
  165. else if ($high < 0xE0)//128 <= code < 224 범위의 문자(확장 ASCII 문자)는 인덱스 2칸이동
  166. $i += 2;
  167. else if ($high < 0xF0)//224 <= code < 240 범위의 문자(유니코드 확장문자)는 인덱스 3칸이동
  168. $i += 3;
  169. else//그외 4칸이동 (미래에 나올문자)
  170. $i += 4;
  171. }
  172. return $length;
  173. }
  174. function cutstring($str, $chars, $tail = '..') {
  175. if (utf8_length($str) <= $chars)//전체 길이를 불러올 수 있으면 tail을 제거한다.
  176. $tail = '';
  177. else
  178. $chars -= utf8_length($tail);//글자가 잘리게 생겼다면 tail 문자열의 길이만큼 본문을 빼준다.
  179. $len = strlen($str);
  180. for ($i = $adapted = 0; $i < $len; $adapted = $i) {
  181. $high = ord($str[$i]);
  182. if ($high < 0x80)
  183. $i += 1;
  184. else if ($high < 0xE0)
  185. $i += 2;
  186. else if ($high < 0xF0)
  187. $i += 3;
  188. else
  189. $i += 4;
  190. if (--$chars < 0)
  191. break;
  192. }
  193. return trim(substr($str, 0, $adapted)) . $tail;
  194. }
  195. function getFileType($filename) {
  196. $ext = substr($filename, strpos($filename, "."));
  197. }
  198. // 문자열에 한글이 포함되어 있는지 검사하는 함수
  199. // ord - 문자의 ASCII 값을 가져옴
  200. function is_hangul($str) {
  201. // 특정 문자가 한글의 범위내(0xA1A1 - 0xFEFE)에 있는지 검사
  202. for($i = 0; $i < strlen($str); $i++) {
  203. $char = ord($str[$i]);
  204. if($char >= 0xa1 && $char <= 0xfe)
  205. return 1;
  206. }
  207. }
  208. // 알파벳인지 그리고 대문자(0x41 - 0x5a)인지 소문자(0x61 - 0x7a)인지
  209. // 검사하는 함수
  210. //
  211. // ord - 문자의 ASCII 값을 가져옴
  212. function is_alpha($char) {
  213. $char = ord($char);
  214. if($char >= 0x61 && $char <= 0x7a)
  215. return 1;
  216. if($char >= 0x41 && $char <= 0x5a)
  217. return 2;
  218. }
  219. // URL이 정확한 것인지 검사하는 함수
  220. //
  221. // eregi - 정규 표현식을 이용한 검사 (대소문자 무시)
  222. // eregi_replace - 정규 표현식을 이용한 치환 (대소문자 무시)
  223. function check_url($url) {
  224. $url = trim($url);
  225. if(is_hangul($url))
  226. return;
  227. // 프로토콜(http://, ftp://...)을 나타내는 부분이 없을 때 기본값으로
  228. // http://를 붙임
  229. if(!eregi("^(http://|https://|ftp://|telnet://|news://)", $url))
  230. $url = preg_match("^", "http://", $url);
  231. if(!eregi("(http|https|ftp|telnet|news):\/\/[a-z0-9-]+\.[][a-zA-Z0-9:&#@=_~%;\?\/\.\+-]+", $url))
  232. return;
  233. return $url;
  234. }
  235. // E-MAIL 주소가 정확한 것인지 검사하는 함수
  236. //
  237. // eregi - 정규 표현식을 이용한 검사 (대소문자 무시)
  238. function check_email($email) {
  239. $email = trim($email);
  240. if(is_hangul($email))
  241. return;
  242. if(!eregi("^[a-z0-9_-]+@[a-z0-9-]+\.[a-z0-9\.-]+", $email))
  243. return;
  244. return $email;
  245. }
  246. function getLatestList($db, $num=5) {
  247. global $PHP_SELF;
  248. $query = "select * from $db order by no desc limit 0, $num";
  249. $result = sql_query($query);
  250. if(sql_num_rows($result)) {
  251. while($list = sql_fetch_array($result)) {
  252. printLatestList($db,$list);
  253. }
  254. } else {
  255. echo "<tr align=center><td height=40><b>등록된 글이 없습니다</b></td></tr>";
  256. }
  257. sql_free_result($result);
  258. }
  259. function printLatestList($db, $list) {
  260. $list[title] = preg_match("\"","&quot;",$list[title]);
  261. $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'> &nbsp;<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]);
  262. echo "$title\n";
  263. }
  264. function getExt($filename) {
  265. $filename = trim($filename);
  266. $right = strrchr($filename, ".");
  267. return strtolower(substr($right,1));
  268. }
  269. /// 게시물 자동링크 ///
  270. function autolink($str){
  271. // URL
  272. $str=preg_match("(http|https|ftp|telnet|news)://([-/.a-zA-Z0-9_~#%$?&=:\200-\377\(\)]+)"," \\1://\\2",$str);
  273. $str=str_replace("=","=",$str);
  274. $str=str_replace("=\" ","=\"",$str);
  275. $str=str_replace("='","='",$str);
  276. $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);
  277. // MAIL
  278. $str=preg_match("([\xA1-\xFEa-z0-9_-]+@[\xA1-\xFEa-z0-9-]+\.[a-z0-9-]+)"," \\1",$str);
  279. $str=str_replace("mailto:","mailto:",$str);
  280. $str=preg_match(" ([\xA1-\xFEa-z0-9_-]+@[\xA1-\xFEa-z0-9-]+\.[a-z0-9-]+)","<a href=\"mailto:\\1\" class=bd>\\1</a>",$str);
  281. return $str;
  282. }
  283. //아스키 문자열을 헥사 코드로..
  284. function asc_hex($char){
  285. $j = 0;
  286. $word_length=strlen($char);
  287. for($i = 0;$i<$word_length;$i++) {
  288. if($j == 0){
  289. if(ord(substr($char,$i,1)) > 0xa1 && ord(substr($char,$i,1)) <= 0xfe) {
  290. if($i>0)$str .= ' ';
  291. $j = 1; $str = $str.bin2hex(substr($char,$i,1));
  292. }else{
  293. if($i>0)$str .= ' ';
  294. $str = $str.'00'.bin2hex(substr($char,$i,1));
  295. }
  296. }else{
  297. $str = $str.bin2hex(substr($char,$i,1));
  298. $j = 0;
  299. }
  300. }
  301. return $str;
  302. }
  303. //헥사 코드 문자열을 아스키 코드 문자열로
  304. function hex_asc($str){
  305. $word_length=strlen($str);
  306. for($i = 0;$i<$word_length;$i+=5){
  307. $tmp1=HexDec(substr($str,$i,2));
  308. if($tmp1==0){
  309. $tmp2=HexDec(substr($str,$i+2,2));
  310. $str2.=chr($tmp2);
  311. }else{
  312. $tmp2=HexDec(substr($str,$i+2,2));
  313. $str2.=chr($tmp1).chr($tmp2);
  314. }
  315. }
  316. return $str2;
  317. }
  318. // 사용법
  319. // $str=fuck2xxx($str,$fil,'XX');
  320. function fuck2xxx($str,$fil,$replace_str){
  321. $fil=explode(',',$fil);
  322. $replace_str=asc_hex($replace_str);
  323. $filter_str='/(';
  324. for($i=0;$i<count($fil);$i++){
  325. if($i>0)$filter_str.='|';
  326. $filter_str.=asc_hex($fil[$i]);
  327. }
  328. $filter_str.=')+/';
  329. $str=preg_replace($filter_str,$replace_str,asc_hex($str));
  330. return hex_asc($str);
  331. }
  332. // 쓰기금지할 단어들을 검색해서 있으면 true
  333. function is_fuck($str,$fil){
  334. $fil=explode(',',$fil);
  335. $filter_str='/(';
  336. for($i=0;$i<count($fil);$i++){
  337. if($i>0)$filter_str.='|';
  338. $filter_str.= $fil[$i];
  339. }
  340. $filter_str.=')+/';
  341. if( preg_match($filter_str,$str) ) {
  342. return true;
  343. } else {
  344. return false;
  345. }
  346. }
  347. function get_microtime($old, $new) {
  348. $old = explode(" ", $old);
  349. $new = explode(" ", $new);
  350. $time[msec] = $new[0] - $old[0];
  351. $time[sec] = $new[1] - $old[1];
  352. if($time[msec] < 0) {
  353. $time[msec] = 1.0 + $time[msec];
  354. $time[sec]--;
  355. }
  356. $time = sprintf("%.2f", $time[sec] + $time[msec]);
  357. return $time;
  358. }
  359. function print_microtime($old, $new) {
  360. $old = explode(" ", $old);
  361. $new = explode(" ", $new);
  362. $time[msec] = $new[0] - $old[0];
  363. $time[sec] = $new[1] - $old[1];
  364. if($time[msec] < 0) {
  365. $time[msec] = 1.0 + $time[msec];
  366. $time[sec]--;
  367. }
  368. $time = sprintf("%.2f", $time[sec] + $time[msec]);
  369. $str = "PageLoding Time : " . $time ." sec";
  370. echo "<script>window.status = '$str';</script>";
  371. }
  372. // 날짜를 date 형식으로 받아서 그날시작되는 UNIX TIMESTAMP 를 반환해준다
  373. function str2date($in){
  374. $t = split("/",$in);
  375. if (count($t)!=3) $t = split("-",$in);
  376. if (count($t)!=3) $t = split(" ",$in);
  377. if (count($t)!=3) return -1;
  378. if (!is_numeric($t[0])) return -1;
  379. if (!is_numeric($t[1])) return -2;
  380. if (!is_numeric($t[2])) return -3;
  381. if ($t[2]<1902 || $t[2]>2037) return -3;
  382. return mktime (0,0,0, $t[1], $t[0], $t[2]);
  383. }
  384. /* ============================================================================
  385. Return :
  386. Comment: 화일이 이미지인지 체크
  387. Usage :
  388. ------------------------------------------------------------------------------*/
  389. function img_type( $srcimg )
  390. {
  391. if(is_file($srcimg)) {
  392. $image_info = @getimagesize($srcimg);
  393. switch ($image_info['mime']) {
  394. case 'image/gif': return true; break;
  395. case 'image/jpeg': return true; break;
  396. case 'image/png': return true; break;
  397. case 'image/bmp': return true; break;
  398. default : return false; break;
  399. }
  400. } else {
  401. return false;
  402. }
  403. }
  404. //기타이동함수
  405. function AlertBack($msg){
  406. echo("
  407. <html><body>
  408. <meta charset='UTF-8' />
  409. <SCRIPT LANGUAGE=\"JavaScript\">
  410. <!--
  411. alert(\"$msg\");
  412. history.back();
  413. //-->
  414. </SCRIPT>
  415. </body></html>
  416. ");
  417. exit;
  418. }
  419. function Alert($msg){
  420. echo("
  421. <html><body>
  422. <meta charset='UTF-8' />
  423. <SCRIPT LANGUAGE=\"JavaScript\">
  424. <!--
  425. alert(\"$msg\");
  426. //-->
  427. </SCRIPT>
  428. </body></html>
  429. ");
  430. exit;
  431. }
  432. function AlertExit($msg){
  433. echo("
  434. <html><body>
  435. <meta charset='UTF-8' />
  436. <SCRIPT LANGUAGE=\"JavaScript\">
  437. <!--
  438. alert(\"$msg\");
  439. self.close();
  440. //-->
  441. </SCRIPT>
  442. </body></html>
  443. ");
  444. exit;
  445. }
  446. function AlertRedirect($msg,$url){
  447. echo("
  448. <html><body>
  449. <meta http-equiv='Refresh' content='0; URL=$url'>
  450. <meta charset='UTF-8' />
  451. <SCRIPT LANGUAGE=\"JavaScript\">
  452. <!--
  453. alert(\"$msg\");
  454. //-->
  455. </SCRIPT>
  456. </body></html>
  457. ");
  458. exit;
  459. }
  460. function AlertRedirectRefresh($msg,$url){
  461. echo("
  462. <html><body>
  463. <meta charset='UTF-8' />
  464. <SCRIPT LANGUAGE=\"JavaScript\">
  465. <!--
  466. opener.location.reload();alert(\"$msg\");
  467. self.close();
  468. //-->
  469. </SCRIPT>
  470. <meta http-equiv='Refresh' content='0; URL=$url'>
  471. </body></html>
  472. ");
  473. exit;
  474. }
  475. function AlertLogin($msg){
  476. echo("
  477. <html><body>
  478. <meta charset='UTF-8' />
  479. <SCRIPT LANGUAGE=\"JavaScript\">
  480. <!--
  481. alert(\"$msg\");
  482. top.location.href=\"/bkmode/index.html\";
  483. //-->
  484. </SCRIPT>
  485. </body></html>
  486. ");
  487. exit;
  488. }
  489. function Redirect($url){
  490. echo("
  491. <html><body>
  492. <SCRIPT LANGUAGE=\"JavaScript\">
  493. <!--
  494. location.replace('$url');
  495. //-->
  496. </SCRIPT>
  497. </body></html>
  498. ");
  499. exit;
  500. }
  501. function AlertExitRefresh($msg,$tourl){
  502. echo("
  503. <html><body>
  504. <meta charset='UTF-8' />
  505. <SCRIPT LANGUAGE=\"JavaScript\">
  506. <!--
  507. alert(\"$msg\");
  508. opener.location.replace('$tourl');
  509. self.close();
  510. //-->
  511. </SCRIPT>
  512. </body></html>
  513. ");
  514. exit;
  515. }
  516. function Replace($tourl){
  517. echo("
  518. <html><body>
  519. <SCRIPT LANGUAGE=\"JavaScript\">
  520. <!--
  521. location.replace('$tourl');
  522. //-->
  523. </SCRIPT>
  524. </body></html>
  525. ");
  526. exit;
  527. }
  528. function ExitRedirect($tourl){
  529. echo("
  530. <html><body>
  531. <SCRIPT LANGUAGE=\"JavaScript\">
  532. <!--
  533. opener.location.replace('$tourl');
  534. self.close();
  535. //-->
  536. </SCRIPT>
  537. </body></html>
  538. ");
  539. exit;
  540. }
  541. function ExitRefresh(){
  542. echo("
  543. <html><body>
  544. <SCRIPT LANGUAGE=\"JavaScript\">
  545. <!--
  546. opener.location.reload();
  547. self.close();
  548. //-->
  549. </SCRIPT>
  550. </body></html>
  551. ");
  552. exit;
  553. }
  554. function TopExit($tourl){
  555. echo("
  556. <html><body>
  557. <SCRIPT LANGUAGE=\"JavaScript\">
  558. <!--
  559. opener.top.location.replace('$tourl');
  560. self.close();
  561. //-->
  562. </SCRIPT>
  563. </body></html>
  564. ");
  565. exit;
  566. }
  567. function URL2($tourl,$url){
  568. echo("
  569. <html><body>
  570. <SCRIPT LANGUAGE=\"JavaScript\">
  571. <!--
  572. parent.left.location.href='$tourl';
  573. location.href='$url';
  574. //-->
  575. </SCRIPT>
  576. </body></html>
  577. ");
  578. exit;
  579. }
  580. /*
  581. //Ajax페이징
  582. function ListPgAjax($url,$pageno,$PageSize,$BlockPage,$totalrows)
  583. {
  584. $lastpgno=(int)@ceil($totalrows/$PageSize); //마지막 페이지
  585. $now_num = (int) @ceil($pageno/$BlockPage);
  586. $start_num = (int) ($now_num - 1) * $BlockPage;
  587. $end_num = (int) $now_num * $BlockPage;
  588. $next_num = (int) $end_num + 1;//마지막 페이지 값 구함
  589. $prev_num = (int) $start_num;//시작 페이지 값 구함
  590. $html = "";
  591. //처음
  592. if($pageno<>1) {
  593. $html += "<a href=\"javascript:$url(1,$PageSize,'1','#car_list1')\" onFocus=\"this.blur();\" class=\"arr first\">맨 처음</a>";
  594. }
  595. //이전
  596. if($now_num > 1) {
  597. $html += "<a href=\"javascript:$url($prev_num,$PageSize,'1','#car_list1')\" onFocus=\"this.blur();\" class=\"arr prev\">이전</a>";
  598. }
  599. //블럭단위 페이징
  600. for ($i = $start_num + 1; $i <= $end_num && $i <= $lastpgno; $i++) {
  601. if ($i == $pageno) {
  602. $html += " <strong>$i</strong> ";
  603. }
  604. else {
  605. $html += "<a href=\"javascript:$url($i,$PageSize,'1','#car_list1')\" onFocus=\"this.blur();\">$i</a> ";
  606. }
  607. }
  608. //다음
  609. if($end_num < $lastpgno) {
  610. $html += " <a href=\"javascript:$url($next_num,$PageSize,'1','#car_list1')\" onFocus=\"this.blur();\" class=\"arr next\">다음</a>";
  611. }
  612. //마지막
  613. if($pageno<>$lastpgno && $lastpgno>0 ) {
  614. $html += "<a href=\"javascript:$url($lastpgno,$PageSize,'1','#car_list1')\" onFocus=\"this.blur();\" class=\"arr last\">맨 마지막</a>";
  615. }
  616. return $html;
  617. }
  618. */
  619. //게시판페이징
  620. // function ListPg($url,$pageno,$PageSize,$BlockPage,$totalrows)
  621. // {
  622. //
  623. // $lastpgno=(int)@ceil($totalrows/$PageSize); //마지막 페이지
  624. // $now_num = (int) @ceil($pageno/$BlockPage);
  625. // $start_num = (int) ($now_num - 1) * $BlockPage;
  626. // $end_num = (int) $now_num * $BlockPage;
  627. // $next_num = (int) $end_num + 1;//마지막 페이지 값 구함
  628. // $prev_num = (int) $start_num;//시작 페이지 값 구함
  629. //
  630. // // echo '<div class="btn--right--wrap"></div>';
  631. // echo '<ul class="pagination">';
  632. // //이전
  633. // if($now_num > 1) {
  634. // // echo "<a href=\"$url&pageno=$prev_num\" onFocus=\"this.blur();\"><</a> <font color=\"#cccccc\">|</font>";
  635. // echo '<li class="page-item ">
  636. // <a class="page-link" href="#" aria-label="Previous">
  637. // <span aria-hidden="true">&laquo;</span>
  638. // </a>
  639. // </li>';
  640. // }
  641. // else{
  642. // echo "< <font color=\"#CCCCCC\">|</font>";
  643. // }
  644. //
  645. // //블럭단위 페이징
  646. // for ($i = $start_num + 1; $i <= $end_num && $i <= $lastpgno; $i++) {
  647. // if ($i == $pageno) {
  648. // // echo " <font color=\"#00adef\"><B>$i</B></font> <font color=\"#ccccc\">|</font>";
  649. // echo '<li class="page-item active"><a class="page-link" href="JavaScript">$i</a></li>';
  650. //
  651. // }
  652. // else {
  653. // // echo " <a href=\"$url&pageno=$i\" onFocus=\"this.blur();\">$i</a> <font color=\"#ccccc\">|</font>";
  654. // echo '<li class="page-item"><a class="page-link" href="{$url}&pageno={$i}">2</a></li>';
  655. // }
  656. // }
  657. //
  658. // //다음
  659. // if($end_num < $lastpgno) {
  660. // // echo " <a href=\"$url&pageno=$next_num\" onFocus=\"this.blur();\">>";
  661. // echo '<li class="page-item">
  662. // <a class="page-link" href="{$url}&pageno={$next_num}" aria-label="Next">
  663. // <span aria-hidden="true">&raquo;</span>
  664. // </a>
  665. // </li>';
  666. // }
  667. // else{
  668. // echo " >";
  669. // }
  670. // echo '</ul>';
  671. //
  672. // // echo '<div class="btn--left--wrap"></div>';
  673. // }
  674. //게시판페이징 - 사용자
  675. function ListPg($url,$pageno,$PageSize,$BlockPage,$totalrows)
  676. {
  677. $lastpgno=(int)@ceil($totalrows/$PageSize); //마지막 페이지
  678. $now_num = (int) @ceil($pageno/$BlockPage);
  679. $start_num = (int) ($now_num - 1) * $BlockPage;
  680. $end_num = (int) $now_num * $BlockPage;
  681. $next_num = (int) $end_num + 1;//마지막 페이지 값 구함
  682. $prev_num = (int) $start_num;//시작 페이지 값 구함
  683. echo "<div class='btn--right--wrap'></div>";
  684. echo "<ul class='pagination'>";
  685. if($pageno<>1 || $now_num > 1) {
  686. // echo "<span>";
  687. }
  688. //처음
  689. if($pageno<>1) {
  690. // echo "<a href=\"$url&pageno=1\" class=\"first\" onFocus=\"this.blur();\">맨앞</a>";
  691. }
  692. //이전
  693. if($now_num > 1) {
  694. // echo "<a href=\"$url&pageno=$prev_num\" class=\"prev\" onFocus=\"this.blur();\">이전</a>";
  695. echo "<li class='page-item '>
  696. <a class='page-link' href='{$url}&pageno={$prev_num}' aria-label='Previous'>
  697. <span aria-hidden='true'>&laquo;</span>
  698. </a>
  699. </li>";
  700. }
  701. if($pageno<>1 || $now_num > 1) {
  702. // echo "</span>";
  703. }
  704. //블럭단위 페이징
  705. for ($i = $start_num + 1; $i <= $end_num && $i <= $lastpgno; $i++) {
  706. if ($i == $pageno) {
  707. // echo "<strong>$i</strong>";
  708. echo "<li class='page-item active'><a class='page-link' href='javascript:;'>$i</a></li>";
  709. }
  710. else {
  711. // echo "<a href=\"$url&pageno=$i\" onFocus=\"this.blur();\">$i</a> ";
  712. echo "<li class='page-item'><a class='page-link' href='{$url}&pageno={$i}'>{$i}</a></li>";
  713. }
  714. }
  715. if( $end_num < $lastpgno || ($pageno<>$lastpgno && $lastpgno>0) ){
  716. // echo "<span>";
  717. }
  718. //다음
  719. if($end_num < $lastpgno) {
  720. // echo " <a href=\"$url&pageno=$next_num\" class=\"next\" onFocus=\"this.blur();\">다음</a>";
  721. echo "<li class='page-item'>
  722. <a class='page-link' href='{$url}&pageno={$next_num}' aria-label='Next'>
  723. <span aria-hidden='true'>&raquo;</span>
  724. </a>
  725. </li>";
  726. }
  727. //마지막
  728. if($pageno<>$lastpgno && $lastpgno>0 ) {
  729. // echo "<a href=\"$url&pageno=$lastpgno\" class=\"last\" onFocus=\"this.blur();\">맨뒤</a>";
  730. }
  731. if( $end_num < $lastpgno || ($pageno<>$lastpgno && $lastpgno>0) ){
  732. // echo "</span>";
  733. }
  734. echo "</ul>";
  735. echo "<div class='btn--left--wrap'></div>";
  736. }
  737. //게시판페이징 - 사용자
  738. function ListMobilePg($url,$pageno,$PageSize,$BlockPage,$totalrows)
  739. {
  740. $lastpgno=(int)@ceil($totalrows/$PageSize); //마지막 페이지
  741. $now_num = (int) @ceil($pageno/$BlockPage);
  742. $start_num = (int) ($now_num - 1) * $BlockPage;
  743. $end_num = (int) $now_num * $BlockPage;
  744. $next_num = (int) $end_num + 1;//마지막 페이지 값 구함
  745. $prev_num = (int) $start_num;//시작 페이지 값 구함
  746. echo "<ul class='pagination'>";
  747. if($pageno<>1 || $now_num > 1) {
  748. // echo "<span>";
  749. }
  750. //처음
  751. if($pageno<>1) {
  752. // echo "<a href=\"$url&pageno=1\" class=\"first\" onFocus=\"this.blur();\">맨앞</a>";
  753. }
  754. //이전
  755. if($now_num > 1) {
  756. // echo "<a href=\"$url&pageno=$prev_num\" class=\"prev\" onFocus=\"this.blur();\">이전</a>";
  757. echo "<li class='page-item '>
  758. <a class='page-link' href='{$url}&pageno={$prev_num}' aria-label='Previous'>
  759. <span aria-hidden='true'>&laquo;</span>
  760. </a>
  761. </li>";
  762. }
  763. if($pageno<>1 || $now_num > 1) {
  764. // echo "</span>";
  765. }
  766. //블럭단위 페이징
  767. for ($i = $start_num + 1; $i <= $end_num && $i <= $lastpgno; $i++) {
  768. if ($i == $pageno) {
  769. // echo "<strong>$i</strong>";
  770. echo "<li class='page-item active'><a class='page-link' href='javascript:;'>$i</a></li>";
  771. }
  772. else {
  773. // echo "<a href=\"$url&pageno=$i\" onFocus=\"this.blur();\">$i</a> ";
  774. echo "<li class='page-item'><a class='page-link' href='{$url}&pageno={$i}'>{$i}</a></li>";
  775. }
  776. }
  777. if( $end_num < $lastpgno || ($pageno<>$lastpgno && $lastpgno>0) ){
  778. // echo "<span>";
  779. }
  780. //다음
  781. if($end_num < $lastpgno) {
  782. // echo " <a href=\"$url&pageno=$next_num\" class=\"next\" onFocus=\"this.blur();\">다음</a>";
  783. echo "<li class='page-item'>
  784. <a class='page-link' href='{$url}&pageno={$next_num}' aria-label='Next'>
  785. <span aria-hidden='true'>&raquo;</span>
  786. </a>
  787. </li>";
  788. }
  789. //마지막
  790. if($pageno<>$lastpgno && $lastpgno>0 ) {
  791. // echo "<a href=\"$url&pageno=$lastpgno\" class=\"last\" onFocus=\"this.blur();\">맨뒤</a>";
  792. }
  793. if( $end_num < $lastpgno || ($pageno<>$lastpgno && $lastpgno>0) ){
  794. // echo "</span>";
  795. }
  796. echo "</ul>";
  797. }
  798. //게시판페이징1
  799. function ListPg1($url,$pageno,$PageSize,$BlockPage,$totalrows)
  800. {
  801. $lastpgno=(int)@ceil($totalrows/$PageSize); //마지막 페이지
  802. $now_num = (int) @ceil($pageno/$BlockPage);
  803. $start_num = (int) ($now_num - 1) * $BlockPage;
  804. $end_num = (int) $now_num * $BlockPage;
  805. $next_num = (int) $end_num + 1;//마지막 페이지 값 구함
  806. $prev_num = (int) $start_num;//시작 페이지 값 구함
  807. if($pageno<>1 || $now_num > 1) {
  808. echo "<span>";
  809. }
  810. //처음
  811. if($pageno<>1) {
  812. echo "<a href=\"$url&pageno=1\" class=\"first\" onFocus=\"this.blur();\">맨앞</a>";
  813. }
  814. //이전
  815. if($now_num > 1) {
  816. echo "<a href=\"$url&pageno=$prev_num\" class=\"prev\" onFocus=\"this.blur();\">이전</a>";
  817. }
  818. if($pageno<>1 || $now_num > 1) {
  819. echo "</span>";
  820. }
  821. //블럭단위 페이징
  822. for ($i = $start_num + 1; $i <= $end_num && $i <= $lastpgno; $i++) {
  823. if ($i == $pageno) {
  824. echo "<strong>$i</strong>";
  825. }
  826. else {
  827. echo "<a href=\"$url&pageno=$i\" onFocus=\"this.blur();\">$i</a> ";
  828. }
  829. }
  830. if( $end_num < $lastpgno || ($pageno<>$lastpgno && $lastpgno>0) ){
  831. echo "<span>";
  832. }
  833. //다음
  834. if($end_num < $lastpgno) {
  835. echo " <a href=\"$url&pageno=$next_num\" class=\"next\" onFocus=\"this.blur();\">다음</a>";
  836. }
  837. //마지막
  838. if($pageno<>$lastpgno && $lastpgno>0 ) {
  839. echo "<a href=\"$url&pageno=$lastpgno\" class=\"last\" onFocus=\"this.blur();\">맨뒤</a>";
  840. }
  841. if( $end_num < $lastpgno || ($pageno<>$lastpgno && $lastpgno>0) ){
  842. echo "</span>";
  843. }
  844. }
  845. function ListPgFront($url,$pageno,$PageSize,$BlockPage,$totalrows)
  846. {
  847. /*
  848. <a href="#" class="arr first">맨 처음</a>
  849. <a href="#" class="arr prev">이전</a>
  850. <strong>1</strong>
  851. <a href="#">2</a>
  852. <a href="#">3</a>
  853. <a href="#">4</a>
  854. <a href="#">5</a>
  855. <a href="#" class="arr next">다음</a>
  856. <a href="#" class="arr last">맨 마지막</a>
  857. */
  858. $lastpgno=(int)@ceil($totalrows/$PageSize); //마지막 페이지
  859. $now_num = (int) @ceil($pageno/$BlockPage);
  860. $start_num = (int) ($now_num - 1) * $BlockPage;
  861. $end_num = (int) $now_num * $BlockPage;
  862. $next_num = (int) $end_num + 1;//마지막 페이지 값 구함
  863. $prev_num = (int) $start_num;//시작 페이지 값 구함
  864. //처음
  865. if($pageno<>1) {
  866. echo "<a href=\"$url&pageno=1\" onFocus=\"this.blur();\" class=\"arr first\">맨앞</a>";
  867. }
  868. //이전
  869. if($now_num > 1) {
  870. echo "<a href=\"$url&pageno=$prev_num\" onFocus=\"this.blur();\" class=\"arr prev\">이전</a>";
  871. }
  872. //블럭단위 페이징
  873. for ($i = $start_num + 1; $i <= $end_num && $i <= $lastpgno; $i++) {
  874. if ($i == $pageno) {
  875. echo " <strong>$i</strong> ";
  876. }
  877. else {
  878. echo "<a href=\"$url&pageno=$i\" onFocus=\"this.blur();\">$i</a> ";
  879. }
  880. }
  881. //다음
  882. if($end_num < $lastpgno) {
  883. echo " <a href=\"$url&pageno=$next_num\" onFocus=\"this.blur();\" class=\"arr nect\">다음</a>";
  884. }
  885. //마지막
  886. if($pageno<>$lastpgno && $lastpgno>0 ) {
  887. echo "<a href=\"$url&pageno=$lastpgno\" onFocus=\"this.blur();\" class=\"arr last\">맨뒤</a>";
  888. }
  889. }
  890. //원격지 아이피 얻기
  891. function getIp() {
  892. return $_SERVER["REMOTE_ADDR"];
  893. }
  894. /*
  895. 파일을 다운로드 받고자 할때 사용하는 함수이다.
  896. 사용법은 자기 자신의 페이지를 리플래쉬 하면서
  897. 함수를 호출하는 방식으로 하면된다.
  898. downloadname : 다운로드 받을때의 이름
  899. filepath : 화일의 서버경로(시스템 경로나 상대경로)
  900. */
  901. function fileDownload($downloadname, $filepath) {
  902. $HTTP_USER_AGENT=$_SERVER["HTTP_USER_AGENT"];
  903. Header("Cache-Control: must-revalidate, post-check=0, pre-check=0");
  904. $filesize=@filesize($filepath);
  905. if(strstr($HTTP_USER_AGENT, "MSIE 6.")) {
  906. Header("Content-type: application/x-msdownload");
  907. Header("Content-Length: $filesize");
  908. Header("Content-Disposition: attachment; filename=$downloadname");
  909. Header("Content-Transfer-Encoding: binary");
  910. Header("Pragma: no-cache");
  911. Header("Expires: 0");
  912. }
  913. else if(strstr($HTTP_USER_AGENT, "MSIE 5.5")) {
  914. header("Content-Type: doesn/matter");
  915. header("Content-disposition: filename=$downloadname");
  916. header("Content-Transfer-Encoding: binary");
  917. header("Pragma: no-cache");
  918. header("Expires: 0");
  919. }
  920. else if(strstr($HTTP_USER_AGENT, "MSIE 5.0")) {
  921. Header("Content-type: file/unknown");
  922. header("Content-Disposition: attachment; filename=$downloadname");
  923. Header("Content-Description: PHP3 Generated Data");
  924. header("Pragma: no-cache");
  925. header("Expires: 0");
  926. }
  927. else {
  928. if (eregi('(htm|php|txt|gif|jpg|jpeg|png)',$tmp1)) {
  929. $filename .='.file';
  930. }
  931. Header("Content-type: file/unknown");
  932. header("Content-Disposition: attachment; filename=$downloadname");
  933. Header("Content-Description: PHP3 Generated Data");
  934. header("Pragma: no-cache");
  935. header("Expires: 0");
  936. }
  937. header("Content-Description: File Transfert");
  938. @readfile($filepath);
  939. exit;
  940. }
  941. //파일사이즈
  942. function getFileSize($userfile_size) {
  943. if($userfile_size < 1024) $userfile_size=$userfile_size." B";
  944. else if ($userfile_size >1024 && $userfile_size < 1024 *1024) $userfile_size=sprintf("%0.1f K",$userfile_size / 1024);
  945. else $userfile_size=sprintf("%0.1f M",$userfile_size / (1024*1024));
  946. return $userfile_size;
  947. }
  948. function total_size($USER_PATH){
  949. $quota = exec("du -sk $USER_PATH");
  950. $Total = explode("$USER_PATH", $quota);
  951. $Total = trim($Total[0]);
  952. $Total=getFileSize(($Total*1024));
  953. return $Total;
  954. }
  955. function val_array($userval,$keyval) {
  956. while(list($key,$val) = each($userval)) {
  957. if($keyval==$key) $Val_Array=$val;
  958. }
  959. return $Val_Array;
  960. }
  961. function mod_checked($usercol,$userval) {
  962. if($usercol==$userval) $Val_Array= "checked"; return $Val_Array;
  963. }
  964. function mod_selected($usercol,$userval) {
  965. if($usercol==$userval) $Val_Array= "selected"; return $Val_Array;
  966. }
  967. function mod_filepath($usercol,$userval,$url,$width='35') {
  968. if(file_exists($usercol)) {
  969. $Val_Array="<img src='$usercol' width='$width'><input type=hidden name=$userval value='$usercol'>&nbsp;<a href='$url' onclick=\"javascript:var msg='삭제하시겠습니까?';return confirm(msg);\"><font color=\"darkorange\"><B>Del</B></font></a>";
  970. return $Val_Array;
  971. }
  972. }
  973. function view_filepath($usercol,$userval) {
  974. if($usercol) {
  975. $Val_Array="<img src='$usercol' width=73 height=47><input type=hidden name='$userval' value='$usercol'>&nbsp;";
  976. return $Val_Array;
  977. }
  978. }
  979. function view_file($usercol,$userval) {
  980. if($usercol) {
  981. $Val_Array="&nbsp;<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'>";
  982. echo $Val_Array;
  983. }
  984. }
  985. function getDatePlus($plus_y,$plus_m,$plus_d,$type)
  986. {
  987. return date($type,mktime(0,0,0,date("m")+$plus_m,date("d")+$plus_d,date("Y")+$plus_y));
  988. }
  989. function getDateDay($y,$m,$d,$type)
  990. {
  991. return date($type,mktime(0,0,0,$m,$d,$y));
  992. }
  993. function getDaySearchForm($yp,$mp,$dp,$ys,$ms,$ds,$yg,$mg,$dg,$oc,$nm,$el,$sy)
  994. {
  995. //getDaySearchForm(출력(년,월,일),삽입(년,월,일),초기값(년,월,일),event,name,기본셋팅,시작년도)
  996. $year = (!$yg) ? (!$el) ? date("Y") : substr($el,0,4) : $yg;
  997. $month = (!$mg) ? (!$el) ? date("m") : substr($el,4,2) : $mg;
  998. $day = (!$dg) ? (!$el) ? date("d") : substr($el,6,2) : $dg;
  999. if($yp) {
  1000. $rtn = "<select name='syear$nm'$oc>\n";
  1001. for($i = $sy; $i < date("Y")+2; $i++)
  1002. {$rtn .= ($i != $year) ? "<option value='$i'>$i$ys</option>" : "<option value='$i' selected>$i$ys</option>";}
  1003. $rtn .= "\n</select>\n\n";
  1004. }
  1005. if($mp) {
  1006. $rtn .= "<select name='smonth$nm'$oc>\n";
  1007. for($i = 1; $i < 13; $i++)
  1008. {$o = ($i < 10) ? "0".$i : $i;
  1009. $rtn .= ($i != $month) ? "<option value='$o'>$o$ms</option>" : "<option value='$o' selected>$o$ms</option>";}
  1010. $rtn .= "\n</select>\n\n";
  1011. }
  1012. if($dp){
  1013. $rtn .= "<select name='sday$nm'$oc>\n";
  1014. for($i = 1; $i < 32; $i++)
  1015. {$o = ($i < 10) ? "0".$i : $i;
  1016. $rtn .= ($i != $day) ? "<option value='$o'>$o$ds</option>" : "<option value='$o' selected>$o$ds</option>";}
  1017. $rtn .= "\n</select>\n\n";
  1018. }
  1019. return $rtn;
  1020. }
  1021. function get_excel_content($db,$table,$SQL)
  1022. {
  1023. $result = mysql_db_query($db, "SELECT * FROM $table $SQL");
  1024. print "<TABLE BORDER=1 CELLSPACING=1 CELLPADDING=1 WIDTH=100%>\r\n";
  1025. print "<TR BGCOLOR=GOLD ALIGN=CENTER>\r\n";
  1026. for($j = 0; $j < mysql_num_fields($result); $j++) {
  1027. print "<TD width=80 height=16><B>".mysql_field_name($result,$j)."</B></TD>\r\n";
  1028. }
  1029. print "</TR>\r\n";
  1030. while ($row = mysql_fetch_row($result)) {
  1031. print "<TR>\r\n";
  1032. for($j = 0; $j < mysql_num_fields($result); $j++) {
  1033. print "<TD width=80 height=16>".stripslashes($row[$j])."</TD>\r\n";
  1034. }
  1035. print "</TR>\r\n";
  1036. }
  1037. print "</TABLE>\r\n";
  1038. print "</HTML>";
  1039. }
  1040. function FileView($file1_,$w,$h) {
  1041. if($file1_) {
  1042. 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>";
  1043. 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]'>";
  1044. }
  1045. return $viewfile;
  1046. }
  1047. function DownFile($file1_,$url) {
  1048. $downfile=" <a href='$url'><font color=\"000000\">$file1_[1]</font></a> ($file1_[2])";
  1049. return $downfile;
  1050. }
  1051. function generatePassword($length) {
  1052. $lowercase = "qwertyuiopasdfghjklzxcvbnm";
  1053. $numbers = "1234567890";
  1054. $randomCode = "";
  1055. mt_srand(crc32(microtime()));
  1056. $max = strlen($lowercase) - 1;
  1057. for ($x = 0; $x < abs($length/2); $x++) {
  1058. $randomCode .= $lowercase[mt_rand(0, $max)];
  1059. }
  1060. $max = strlen($numbers) - 1;
  1061. for ($x = 0; $x < abs($length/2); $x++) {
  1062. $randomCode .= $numbers[mt_rand(0, $max)];
  1063. }
  1064. return str_shuffle($randomCode);
  1065. }
  1066. function upload($filearray, $targetdir, $max_size, $allowext){
  1067. $max_size = $max_size * 2048 * 2048; // 바이트로 계산한다. 1MB = 1024KB = 1048576Byte
  1068. if(!is_dir($targetdir)){
  1069. @mkdir($targetdir, 0777);
  1070. }
  1071. //차량이미지 등록시 ratio도 같이 생성
  1072. if(strpos($targetdir, 'uploadfile/car/') !== false) {
  1073. if(!is_dir($targetdir.'ratio/')){
  1074. @mkdir($targetdir.'ratio/', 0777);
  1075. }
  1076. }
  1077. if($filearray['size'] > $max_size){
  1078. return false;
  1079. }else {
  1080. $file_ext = strtolower(end(explode('.', $filearray['name'])));
  1081. if($allowext!=null){
  1082. if(in_array($file_ext, array_change_key_case($allowext,CASE_LOWER))){
  1083. $file_name = rand(10000,99999)."_".$filearray['name'];
  1084. $file_name = preg_replace ("/[ #\&\+\-%@=\/\\\:;,\'\"\^`~\|\!\?\*$#<>()\[\]\{\}]/i", "", $file_name);
  1085. $path = $targetdir . '/' . $file_name;
  1086. if(copy($filearray['tmp_name'], $path)){
  1087. return $file_name;
  1088. }else{
  1089. return false;
  1090. // 실패 했을 경우에는 false를 출력합니다.
  1091. }
  1092. }else{
  1093. return false;
  1094. }
  1095. }else{
  1096. $file_name = $file_ext."_".time().".".$file_ext;
  1097. $file_name = preg_replace ("/[ #\&\+\-%@=\/\\\:;,\'\"\^`~\|\!\?\*$#<>()\[\]\{\}]/i", "", $file_name);
  1098. $path = $targetdir . '/' . $file_name;
  1099. if(copy($filearray['tmp_name'], $path)){
  1100. return $file_name;
  1101. }else{
  1102. return false;
  1103. }
  1104. }
  1105. }
  1106. }
  1107. function sendMail($to, $to_name, $from, $from_name, $subject, $comment, $type="1", $cc="", $bcc="") {
  1108. $recipient = "=?utf-8?B?".base64_encode($to_name)."?= <$to>";
  1109. // 글내용이 text타입
  1110. if($type == 2) $comment = nl2br(htmlspecialchars($comment));
  1111. $fmail = 'design@interscope.co.kr';//후이즈 정책으로 fmail고정
  1112. $headers = "From: =?utf-8?B?".base64_encode($from_name)."?= <{$from}>\r\n";
  1113. $headers .= "X-Sender: <$from>\n";
  1114. $headers .= "X-Mailer: PHP ".phpversion()."\n";
  1115. $headers .= "X-Priority: 1\n";
  1116. $headers .= "Return-Path: <$from>\n";
  1117. $headers .= "Content-Type: text/html; ";
  1118. $headers .= "charset=utf-8\n";
  1119. $headers .= "Content-Transfer-Encoding: base64\n";
  1120. if($cc) $headers .= "cc: $cc\n";
  1121. if($bcc) $headers .= "bcc: $bcc";
  1122. $comment = stripslashes($comment);
  1123. $comment = str_replace("\n\r","\n", $comment);
  1124. //return mail($recipient , '=?utf-8?B?'.base64_encode($subject).'?=' , base64_encode($comment) , $headers);
  1125. return mail($recipient , '=?utf-8?B?'.base64_encode($subject).'?=' , base64_encode($comment) , $headers, '-f'.$fmail);//후이즈 정책으로 변경
  1126. }
  1127. function chk_file($tmpfile, $file) {
  1128. if (!is_uploaded_file($tmpfile)) {
  1129. return false;
  1130. }
  1131. $ext = strtolower(pathinfo($file, PATHINFO_EXTENSION));
  1132. if (!in_array($ext, array('png','jpeg','jpg'))) {
  1133. echo '확장자가png,jpeg,jpg인 것만 올려주세요';
  1134. return false;
  1135. }
  1136. // 여기서 에러가 나면
  1137. // PHP.ini 파일에서 extension=fileinfo.so,
  1138. // 혹은extension=php_fileinfo.dll 코멘트 제거 해주시고 재기동
  1139. $finfo = finfo_open(FILEINFO_MIME_TYPE);
  1140. $mime_type = finfo_file($finfo, $tmpfile);
  1141. if (!in_array($mime_type, array('image/png', 'image/jpeg'))) {
  1142. echo '이미지 파일이 아니에요';
  1143. return false;
  1144. }
  1145. return true;
  1146. }
  1147. if (!function_exists('json_encode')) {
  1148. function json_encode($data) {
  1149. $json = new Services_JSON();
  1150. return( $json->encode($data) );
  1151. }
  1152. }
  1153. if( !function_exists('json_decode') ) {
  1154. function json_decode($data) {
  1155. $json = new Services_JSON();
  1156. return( $json->decode($data) );
  1157. }
  1158. }
  1159. function mail_send($mail_title, $mail_content, $arr_email, $arr_name){
  1160. try {
  1161. $mail = new PHPMailer(true);
  1162. $mail->IsSMTP(); // send via SMTP
  1163. $mail->Host = MAILHOST;
  1164. $mail->Port = MAILPORT;
  1165. $mail->Mailer = "smtp";
  1166. $mail->CharSet = "euc-kr";
  1167. $mail->Encoding = "base64";
  1168. $mail->Username = GUSER; //SMTP 사용자 이름
  1169. $mail->Password = GPWD; //SMTP 비밀번호
  1170. $mail->SMTPAuth = true; // turn on SMTP authentication
  1171. $mail->SMTPSecure = 'ssl';
  1172. $webmaster_email = GUSER; // 답변을 받을 이메일
  1173. $mail->From = GUSER;
  1174. $mail->FromName = "WEBMASTER"; // 보내는 사람 이름
  1175. $email = explode("|", $arr_email);
  1176. $name = explode("|", $arr_name);
  1177. for($i=0; $i<count($email); $i++){
  1178. $mail->AddAddress($email[$i], iconv("UTF-8","EUC-KR",$name[$i]));
  1179. }
  1180. $mail->AddReplyTo($webmaster_email,"Webmaster");
  1181. $mail->WordWrap = 50; // set word wrap
  1182. $mail->IsHTML(true); // HTML의 형식으로 보냄
  1183. $mail->Subject = iconv("UTF-8","EUC-KR",$mail_title); // 메일 이름
  1184. $mail_fileName = $_SERVER['DOCUMENT_ROOT'].'/common/templet/admin_mail.html';
  1185. $fp = fopen($mail_fileName, "r");
  1186. $fr = fread($fp, filesize($mail_fileName));
  1187. fclose($fp);
  1188. $fr = str_replace("[[nm_title]]",$mail_title, $fr); // 제목
  1189. $fr = str_replace("[[nm_cont]]",$mail_content, $fr); // 내용
  1190. $mail->Body = iconv("UTF-8","EUC-KR",$fr); // 내용
  1191. $mail->AltBody = $mail_content;
  1192. $mail->IsSMTP();
  1193. $mail->Send();
  1194. return true;
  1195. } catch (phpmailerException $e) {
  1196. //echo $e->errorMessage(); //Pretty error messages from PHPMailer
  1197. //die();
  1198. return false;
  1199. } catch (Exception $e) {
  1200. //echo $e->getMessage(); //Boring error messages from anything else!
  1201. //die();
  1202. return false;
  1203. }
  1204. }
  1205. function getCode($table, $column , $code){
  1206. $code=@mysql_result(mysql_query("select nm_name
  1207. from code_master
  1208. where nm_table='".$table."'
  1209. and nm_column='".$column."'
  1210. and nm_code='".$code."'
  1211. and ds_delind='N'"),0,0);
  1212. return $code;
  1213. }
  1214. //단순형 웹연동 개요 : SMS를 발송할때 POST 방식으로 메시지를 날려줍니다.
  1215. //웹모듈은 등록된 사용자만 메시지 전송이 가능하며, 특정 아이피에서만 발송을 원하시는 경우 웹연동 사용자 등록후 "회원정보 수정" 에서 아이피를 등록해주시면 됩니다.
  1216. //단순형 모듈은 한번에 관리자1명에게만 문자가 통보가 되는 형태이며, 다중의 관리자가 있는경우 각각의 관리자 수만큼 루프를 돌린후 1명단위로 get_url_fsockopen을 호출하시면 됩니다.
  1217. function get_url_fsockopen($url,$vars){
  1218. $result = array();
  1219. $URL_parsed = parse_url($url);
  1220. $host = $URL_parsed["host"];
  1221. $port = ($URL_parsed["port"]) ? $URL_parsed["port"] : 80;
  1222. $path = $URL_parsed["path"];
  1223. $request.="POST ".$path." HTTP/1.1\r\n";
  1224. $request.="Host: ".$host.":".$port."\r\n";
  1225. $request.="Referer: $referer\r\n";
  1226. $request.="Content-type: application/x-www-form-urlencoded\r\n";
  1227. $request.="Content-length: ".strlen($vars)."\r\n";
  1228. $request.="Connection: close\r\n";
  1229. $request.="\r\n";
  1230. $request.=$vars."\r\n";
  1231. $fp = fsockopen($host, $port, $errno, $errstr, 30);
  1232. fputs($fp, $request);
  1233. while(!feof($fp)) {
  1234. $result[] .= fgets($fp, 128);
  1235. }
  1236. fclose($fp);
  1237. return $result[10];
  1238. }
  1239. //오늘 반환
  1240. function now(){
  1241. return date ("Y-m-d H:i:s");
  1242. }
  1243. function getymd(){
  1244. return date ("Ymd");
  1245. }
  1246. function nowDate(){
  1247. $week = array("일", "월", "화", "수", "목", "금", "토");
  1248. $s = $week[date("w")];
  1249. return date ("Y"."년 "."m"."월 "."d"."일 "). "(".$s.")";
  1250. }
  1251. function tag($str,$len){
  1252. return cutstring(stripslashes(strip_tags($str)),$len);
  1253. }
  1254. function databr($str){
  1255. return str_replace("\n","<br/>", $str);
  1256. }
  1257. /*ExcelPrint*/
  1258. function to_excel($array, $filename) {
  1259. header('Content-type: application/vnd.ms-excel');
  1260. header('Content-Disposition: attachment; filename='.$filename.'.xls');
  1261. $h = array();
  1262. foreach($array->result_array() as $row){
  1263. foreach($row as $key=>$val){
  1264. if(!in_array($key, $h)){
  1265. $h[] = $key;
  1266. }
  1267. }
  1268. }
  1269. //echo the entire table headers
  1270. echo '<table><tr>';
  1271. foreach($h as $key) {
  1272. $key = ucwords($key);
  1273. echo '<th>'.$key.'</th>';
  1274. }
  1275. echo '</tr>';
  1276. foreach($array->result_array() as $row){
  1277. echo '<tr>';
  1278. foreach($row as $val){
  1279. echo '<td>'.utf8_decode($val).'</td>';
  1280. }
  1281. }
  1282. echo '</tr>';
  1283. echo '</table>';
  1284. }
  1285. //FTP 파일전송(타서버전송됨)
  1286. function ftp_upload($files, $source_dir, $target_dir){
  1287. $ftp_host = "alis2.news.naver.com";
  1288. $ftp_user = "ktnews_s";
  1289. $ftp_pass = "ktnews_sb4UYdxD=jn";
  1290. $result = 0;
  1291. $conn_id = ftp_connect($ftp_host);
  1292. $login_result = ftp_login($conn_id, $ftp_user, $ftp_pass);
  1293. if(!$conn_id || !$login_result) {
  1294. $result = 999;
  1295. return;
  1296. }
  1297. $dir = ftp_chdir($conn_id, $target_dir);
  1298. $files = explode(',',$files);
  1299. foreach($files as $file){
  1300. $file = trim($file);
  1301. $d = explode('/',$file);
  1302. if(count($d)>1){
  1303. $dir_sub = "";
  1304. for($i=0;$i<count($d)-1;$i++) {
  1305. if($dir_sub){
  1306. $dir_sub .= "/".$d[$i];
  1307. }else{
  1308. $dir_sub = $d[$i];
  1309. }
  1310. @ftp_mkdir($conn_id, $dir_sub);
  1311. }
  1312. }
  1313. $up = ftp_put($conn_id, $file, $source_dir."/".$file, FTP_BINARY);
  1314. if($up){
  1315. $result++;
  1316. }
  1317. }
  1318. ftp_close($conn_id);
  1319. return $result;
  1320. }
  1321. function random_string($length) {
  1322. $key = '';
  1323. $keys = array_merge(range(0, 9), range('a', 'z'));
  1324. for ($i = 0; $i < $length; $i++) {
  1325. $key .= $keys[array_rand($keys)];
  1326. }
  1327. return $key;
  1328. }
  1329. function getRequestType($type){
  1330. if($type=="A0"){
  1331. return "시승신청";
  1332. }elseif($type=="B0"){
  1333. return "브로셔신청";
  1334. }else{
  1335. return "견적요청";
  1336. }
  1337. }
  1338. function fnGetBbsTitle($type){
  1339. if($type=="01"){
  1340. return "공지사항";
  1341. }else if($type=="02"){
  1342. return "1:1문의";
  1343. }else if($type=="03"){
  1344. return "자주묻는 질문";
  1345. }else{
  1346. return "게시판";
  1347. }
  1348. }
  1349. function reArrayFiles(&$file_post) {
  1350. $file_ary = array();
  1351. $file_count = count($file_post['name']);
  1352. $file_keys = array_keys($file_post);
  1353. for ($i=0; $i<$file_count; $i++) {
  1354. foreach ($file_keys as $key) {
  1355. $file_ary[$i][$key] = $file_post[$key][$i];
  1356. }
  1357. }
  1358. return $file_ary;
  1359. }
  1360. function MobileCheck() {
  1361. global $HTTP_USER_AGENT;
  1362. $MobileArray = array("iphone","lgtelecom","skt","mobile","samsung","nokia","blackberry","android","android","sony","phone");
  1363. $checkCount = 0;
  1364. for($i=0; $i<sizeof($MobileArray); $i++){
  1365. if(preg_match("/$MobileArray[$i]/", strtolower($HTTP_USER_AGENT))){ $checkCount++; break; }
  1366. }
  1367. return ($checkCount >= 1) ? "Mobile" : "Computer";
  1368. }
  1369. //이미지 파일 업로드
  1370. function _upload_car_image($upload_path, $upload_ratio_path, $param_filename, $max_size, $thumb = false) {
  1371. $res = array("result" => true, "msg"=> "", "filename"=> "", "thumb_info" => array());
  1372. //이미지 첨부파일 등록 여부 체크
  1373. if (is_uploaded_file($_FILES[$param_filename]['tmp_name'])) {
  1374. if($_FILES[$param_filename]['size'] > 0 ){
  1375. $upload_file_name = upload($_FILES[$param_filename],$upload_path, $max_size, array('gif', 'jpeg', 'jpg','png','bmp' ,'ttif'));
  1376. //첨부파일 업로드 실패
  1377. if($upload_file_name==false){
  1378. $res["result"] = false;
  1379. $res["msg"] = "첨부파일 업로드 실패 하였습니다";
  1380. }
  1381. //업로드 성공
  1382. else {
  1383. $res["filename"] = $upload_file_name;
  1384. // create_watermark($upload_path.$upload_file_name);
  1385. if($thumb == true) {
  1386. // echo $upload_path.$upload_file_name.'<br/>';
  1387. // echo $upload_ratio_path.$upload_file_name.'<br/>';
  1388. // exit;
  1389. $thumb = array(
  1390. 'o_path' => $upload_path.$upload_file_name, 'n_path' => $upload_ratio_path.$upload_file_name,
  1391. 'mode' => 'ratio', 'width' => CAR_THUM2_WIDTH, 'height' => CAR_THUM2_HEIGHT, 'preview_yn' => 'N','o_name' =>$upload_file_name
  1392. );
  1393. $thumb_info = getThumb($thumb);
  1394. if($_SERVER['REMOTE_ADDR'] == '220.86.24.199') {
  1395. // print_r($thumb_info);
  1396. // exit;
  1397. }
  1398. $res["thumb_info"] = $thumb_info;
  1399. }
  1400. }
  1401. }
  1402. }
  1403. return $res;
  1404. }
  1405. //차량 이미지를 가져옴
  1406. function getCarBasicImage($cd_car, $img, $title = "이미지", $bsumogallery = false, $sumogallery_group='basic') {
  1407. $sumo_tag = "";
  1408. $no_image = "/img/car_basic_no_image_1000x600.png";
  1409. $no_thumb_image = "/img/car_basic_no_image_90x70.png";
  1410. $img_src = UPLOAD_PATH_CAR.$cd_car."_main/".$img;//."nm_file_main/".$img;
  1411. $img_thumb_src = UPLOAD_PATH_CAR.$cd_car."_main/ratio/".$img;
  1412. $img_thumb_src = UPLOAD_PATH_CAR.$cd_car."_main/".$img;
  1413. //해당 파일이 없다면 no이미지로 대체
  1414. if(!is_file($_SERVER['DOCUMENT_ROOT'].$img_src)) {
  1415. $img_src = $no_image;
  1416. $img_thumb_src = $no_thumb_image;
  1417. }
  1418. //존재하면 파일타임을 파라미터로 사용
  1419. else {
  1420. $img_filemtime = filemtime($_SERVER['DOCUMENT_ROOT'].$img_src);
  1421. $img_src.= '?time='.$img_filemtime;
  1422. $img_thumb_src.= '?time='.$img_filemtime;
  1423. }
  1424. //sumo gallery 용
  1425. if($bsumogallery == true) {
  1426. $sumo_tag = " data-sgallery='".$sumogallery_group."' data-full='".$img_src."' data-thumb='".$img_thumb_src."' ";
  1427. }
  1428. $img_tag = "<img src='".$img_thumb_src."' title='".$title."' $sumo_tag />";
  1429. return $img_tag;
  1430. }
  1431. //차량 이미지를 가져옴
  1432. function getCarBasicImageString($cd_car, $img, $title = "이미지") {
  1433. $sumo_tag = "";
  1434. $no_image = "/img/car_basic_no_image_1000x600.png";
  1435. $no_thumb_image = "/img/car_basic_no_image_90x70.png";
  1436. $img_src = UPLOAD_PATH_CAR.$cd_car."_main/".$img;//."nm_file_main/".$img;
  1437. $img_thumb_src = UPLOAD_PATH_CAR.$cd_car."_main/ratio/".$img;
  1438. $img_thumb_src = UPLOAD_PATH_CAR.$cd_car."_main/".$img;
  1439. //해당 파일이 없다면 no이미지로 대체
  1440. if(!is_file($_SERVER['DOCUMENT_ROOT'].$img_src)) {
  1441. $img_src = $no_image;
  1442. $img_thumb_src = $no_thumb_image;
  1443. }
  1444. //sumo gallery 용
  1445. // if($bsumogallery == true) {
  1446. // $sumo_tag = " data-sgallery='".$sumogallery_group."' data-full='".$img_src."' data-thumb='".$img_thumb_src."' ";
  1447. // }
  1448. //
  1449. // $img_tag = "<img src='".$img_thumb_src."' title='".$title."' $sumo_tag />";
  1450. return $img_thumb_src;
  1451. }
  1452. //차량 이미지를 가져옴
  1453. function getCarBasicThumbImage($cd_car, $img, $title = "이미지", $bsumogallery = false, $sumogallery_group='basic') {
  1454. $sumo_tag = "";
  1455. $no_image = "/img/car_basic_no_image_1000x600.png";
  1456. $no_thumb_image = "/img/car_basic_no_image_90x70.png";
  1457. $img_src = UPLOAD_PATH_CAR.$cd_car."_main/".$img;//."nm_file_main/".$img;
  1458. $img_thumb_src = UPLOAD_PATH_CAR.$cd_car."_main/ratio/".$img;
  1459. //해당 파일이 없다면 no이미지로 대체
  1460. if(!is_file($_SERVER['DOCUMENT_ROOT'].$img_src)) {
  1461. $img_src = $no_image;
  1462. $img_thumb_src = $no_thumb_image;
  1463. }
  1464. //존재하면 파일타임을 파라미터로 사용
  1465. else {
  1466. // echo $img_src;
  1467. // exit;
  1468. $img_filemtime = filemtime($_SERVER['DOCUMENT_ROOT'].$img_src);
  1469. $img_src.= '?time='.$img_filemtime;
  1470. $img_thumb_src.= '?time='.$img_filemtime;
  1471. }
  1472. // echo $_SERVER['DOCUMENT_ROOT'].$img_src;
  1473. // exit;
  1474. //sumo gallery 용
  1475. if($bsumogallery == true) {
  1476. $sumo_tag = " data-sgallery='".$sumogallery_group."' data-full='".$img_src."' data-thumb='".$img_thumb_src."' ";
  1477. }
  1478. $img_tag = "<img src='".$img_thumb_src."' title='".$title."' $sumo_tag />";
  1479. return $img_tag;
  1480. }
  1481. //차량 이미지를 가져옴
  1482. function getCarAddtionalImage($cd_car, $img, $title = "이미지", $bsumogallery = false, $sumogallery_group='basic') {
  1483. $sumo_tag = "";
  1484. $no_image = "/img/car_basic_no_image_1000x600.png";
  1485. $no_thumb_image = "/img/car_basic_no_image_90x70.png";
  1486. $img_src = UPLOAD_PATH_CAR.$cd_car."_detail/".$img;
  1487. $img_thumb_src = UPLOAD_PATH_CAR.$cd_car."_detail/".$img;
  1488. //해당 파일이 없다면 no이미지로 대체
  1489. if(!is_file($_SERVER['DOCUMENT_ROOT'].$img_src)) {
  1490. $img_src = $no_image;
  1491. $img_thumb_src = $no_thumb_image;
  1492. }
  1493. //존재하면 파일타임을 파라미터로 사용
  1494. else {
  1495. // echo $img_src;
  1496. // exit;
  1497. $img_filemtime = filemtime($_SERVER['DOCUMENT_ROOT'].$img_src);
  1498. $img_src.= '?time='.$img_filemtime;
  1499. $img_thumb_src.= '?time='.$img_filemtime;
  1500. }
  1501. //sumo gallery 용
  1502. if($bsumogallery == true) {
  1503. $sumo_tag = " data-sgallery='".$sumogallery_group."' data-full='".$img_src."' data-thumb='".$img_thumb_src."' ";
  1504. }
  1505. $img_tag = "<img src='".$img_thumb_src."' title='".$title."' $sumo_tag />";
  1506. return $img_tag;
  1507. }
  1508. //차량 이미지를 가져옴
  1509. function getCarAddtionalThumbImage($cd_car, $img, $title = "이미지", $bsumogallery = false, $sumogallery_group='basic') {
  1510. $sumo_tag = "";
  1511. $no_image = "/img/car_basic_no_image_1000x600.png";
  1512. $no_thumb_image = "/img/car_basic_no_image_90x70.png";
  1513. $img_src = UPLOAD_PATH_CAR.$cd_car."_detail/".$img;
  1514. $img_thumb_src = UPLOAD_PATH_CAR.$cd_car."_detail/".$img;
  1515. //해당 파일이 없다면 no이미지로 대체
  1516. if(!is_file($_SERVER['DOCUMENT_ROOT'].$img_src)) {
  1517. $img_src = $no_image;
  1518. $img_thumb_src = $no_thumb_image;
  1519. }
  1520. //존재하면 파일타임을 파라미터로 사용
  1521. else {
  1522. // echo $img_src;
  1523. // exit;
  1524. $img_filemtime = filemtime($_SERVER['DOCUMENT_ROOT'].$img_src);
  1525. $img_src.= '?time='.$img_filemtime;
  1526. $img_thumb_src.= '?time='.$img_filemtime;
  1527. }
  1528. //sumo gallery 용
  1529. if($bsumogallery == true) {
  1530. $sumo_tag = " data-sgallery='".$sumogallery_group."' data-full='".$img_src."' data-thumb='".$img_thumb_src."' ";
  1531. }
  1532. $img_tag = "<img src='".$img_thumb_src."' title='".$title."' $sumo_tag />";
  1533. return $img_tag;
  1534. }
  1535. //차량 낙찰 이후 이미지를 가져옴
  1536. function getCarContractImage($cd_sale, $img, $title = "이미지", $bsumogallery = false, $sumogallery_group='basic') {
  1537. $sumo_tag = "";
  1538. $no_image = "/img/car_basic_no_image_1000x600.png";
  1539. $no_thumb_image = "/img/car_basic_no_image_90x70.png";
  1540. $img_src = UPLOAD_PATH.'aap/contract_step/'.$cd_sale.'_detail/'.$img;
  1541. $img_thumb_src = UPLOAD_PATH.'aap/contract_step/'.$cd_sale.'_detail/'.$img;
  1542. // echo $img_src;
  1543. //해당 파일이 없다면 no이미지로 대체
  1544. if(!is_file($_SERVER['DOCUMENT_ROOT'].$img_src)) {
  1545. $img_src = $no_image;
  1546. $img_thumb_src = $no_thumb_image;
  1547. }
  1548. //존재하면 파일타임을 파라미터로 사용
  1549. else {
  1550. // echo $img_src;
  1551. // exit;
  1552. $img_filemtime = filemtime($_SERVER['DOCUMENT_ROOT'].$img_src);
  1553. $img_src.= '?time='.$img_filemtime;
  1554. $img_thumb_src.= '?time='.$img_filemtime;
  1555. }
  1556. //sumo gallery 용
  1557. if($bsumogallery == true) {
  1558. $sumo_tag = " data-sgallery='".$sumogallery_group."' data-full='".$img_src."' data-thumb='".$img_thumb_src."' ";
  1559. }
  1560. $img_tag = "<img src='".$img_thumb_src."' title='".$title."' $sumo_tag />";
  1561. return $img_tag;
  1562. }
  1563. function getThumb($param){
  1564. if(empty($param['o_path'])) return array('bool' => false, 'msg' => '원본 파일 경로가 없습니다.');
  1565. if(empty($param['n_path'])) return array('bool' => false, 'msg' => '원본 파일 경로가 없습니다.');
  1566. if(!in_array($param['mode'], array('ratio', 'fixed'))) $param['mode'] = 'ratio';
  1567. if(empty($param['width'])) $param['width'] = 300;
  1568. if(empty($param['height'])) $param['height'] = 300;
  1569. if(!in_array($param['fill_yn'], array('Y', 'N'))) $param['fill_yn'] = 'N';
  1570. if(!in_array($param['preview_yn'], array('Y', 'N'))) $param['preview_yn'] = 'Y';
  1571. if(empty($param['o_name'])) $param['o_name'] = '';
  1572. // 미리보기 방지 이미지 url
  1573. //if($param['preview_yn'] == 'N') $param['o_path'] = './hidden.png';
  1574. $src = array();
  1575. $dst = array();
  1576. $src['path'] = $param['o_path'];
  1577. $dst['path'] = $param['n_path'];
  1578. // 썸네일 이미지 갱신 기간 (1주일)
  1579. if(file_exists($dst['path'])){
  1580. // if(mktime() - filemtime($dst['path']) < 60 * 60 * 24 * 7)
  1581. return array('bool' => true, 'src' => $dst['path']);
  1582. }
  1583. $imginfo = getimagesize($src['path']);
  1584. $src['mime'] = $imginfo['mime'];
  1585. // if($_SERVER['REMOTE_ADDR'] == '220.86.24.199') {
  1586. // print_r($imginfo);
  1587. // exit;
  1588. // }
  1589. // 원본 이미지 리소스 호출
  1590. switch($src['mime']){
  1591. case 'image/jpeg' : $src['img'] = imagecreatefromjpeg($src['path']); break;
  1592. case 'image/gif' : $src['img'] = imagecreatefromgif($src['path']); break;
  1593. case 'image/png' : $src['img'] = @imagecreatefrompng($src['path']); break;
  1594. case 'image/bmp' : $src['img'] = imagecreatefrombmp($src['path']); break;
  1595. case 'image/webp' : $src['img'] = imagecreatefromwebp($src['path']); break;
  1596. // mime 타입이 해당되지 않으면 return false
  1597. default : return array('bool' => false, 'msg' => '이미지 파일이 아닙니다.'); break;
  1598. }
  1599. // 원본 이미지 크기 / 좌표 초기값
  1600. $src['w'] = $imginfo[0];
  1601. $src['h'] = $imginfo[1];
  1602. $src['x'] = 0;
  1603. $src['y'] = 0;
  1604. // 썸네일 이미지 좌표 초기값 설정
  1605. $dst['x'] = 0;
  1606. $dst['y'] = 0;
  1607. // 썸네일 이미지 가로, 세로 비율 계산
  1608. $dst['ratio']['w'] = $src['w'] / $param['width'];
  1609. $dst['ratio']['h'] = $src['h'] / $param['height'];
  1610. switch($param['mode']){
  1611. case 'ratio' :
  1612. // 썸네일 이미지의 비율계산 (가로 == 세로)
  1613. if($dst['ratio']['w'] == $dst['ratio']['h']){
  1614. $dst['w'] = $param['width'];
  1615. $dst['h'] = $param['height'];
  1616. }
  1617. // 썸네일 이미지의 비율계산 (가로 > 세로)
  1618. elseif($dst['ratio']['w'] > $dst['ratio']['h']){
  1619. $dst['w'] = $param['width'];
  1620. $dst['h'] = round(($param['width'] * $src['h']) / $src['w']);
  1621. }
  1622. // 썸네일 이미지의 비율계산 (가로 < 세로)
  1623. elseif($dst['ratio']['w'] < $dst['ratio']['h']){
  1624. $dst['w'] = round(($param['height'] * $src['w']) / $src['h']);
  1625. $dst['h'] = $param['height'];
  1626. }
  1627. if($param['fill_yn'] == 'Y'){
  1628. $dst['canvas']['w'] = $param['width'];
  1629. $dst['canvas']['h'] = $param['height'];
  1630. $dst['x'] = $param['width'] > $dst['w'] ? ($param['width'] - $dst['w']) / 2 : 0;
  1631. $dst['y'] = $param['height'] > $dst['h'] ? ($param['height'] - $dst['h']) / 2 : 0;
  1632. }
  1633. else{
  1634. $dst['canvas']['w'] = $dst['w'];
  1635. $dst['canvas']['h'] = $dst['h'];
  1636. }
  1637. break;
  1638. case 'fixed' :
  1639. // 썸네일 이미지의 비율계산 (가로 == 세로)
  1640. if($dst['ratio']['w'] == $dst['ratio']['h']){
  1641. $dst['w'] = $param['width'];
  1642. $dst['h'] = $param['height'];
  1643. }
  1644. // 썸네일 이미지의 비율계산 (가로 > 세로)
  1645. elseif($dst['ratio']['w'] > $dst['ratio']['h']){
  1646. $dst['w'] = $src['w'] / $dst['ratio']['h'];
  1647. $dst['h'] = $param['height'];
  1648. $src['x'] = ($dst['w'] - $param['width']) / 2;
  1649. }
  1650. // 썸네일 이미지의 비율계산 (가로 < 세로)
  1651. elseif($dst['ratio']['w'] < $dst['ratio']['h']){
  1652. $dst['w'] = $param['width'];
  1653. $dst['h'] = $src['h'] / $dst['ratio']['w'];
  1654. $dst['y'] = 0;
  1655. }
  1656. $dst['canvas']['w'] = $param['width'];
  1657. $dst['canvas']['h'] = $param['height'];
  1658. break;
  1659. }
  1660. // 썸네일 이미지 리소스 생성
  1661. $dst['img'] = imagecreatetruecolor($dst['canvas']['w'], $dst['canvas']['h']);
  1662. // 배경색 처리
  1663. //배경색 기능 없앰 2020-05-28
  1664. // if(in_array($src['mime'], array('image/png', 'image/gif'))){
  1665. // // 배경 투명 처리
  1666. // imagetruecolortopalette($dst['img'], false, 255);
  1667. // $bgcolor = imagecolorallocatealpha($dst['img'], 255, 255, 255, 127);
  1668. // imagefilledrectangle($dst['img'], 0, 0, $dst['canvas']['w'],$dst['canvas']['h'], $bgcolor);
  1669. // }
  1670. // else{
  1671. // // 배경 흰색 처리
  1672. // $bgclear = imagecolorallocate($dst['img'],255,255,255);
  1673. // imagefill($dst['img'],0,0,$bgclear);
  1674. // }
  1675. // 원본 이미지 썸네일 이미지 크기에 맞게 복사
  1676. imagecopyresampled($dst['img'],$src['img'],$dst['x'],$dst['y'],$src['x'],$src['y'],$dst['w'],$dst['h'],$src['w'],$src['h']);
  1677. // imagecopyresampled 함수 사용 불가시 사용
  1678. //imagecopyresized($dst['img'],$src['img'],$dst['x'],$dst['y'],$src['x'],$src['y'],$dst['w'],$dst['h'],$src['w'],$src['h']);
  1679. ImageInterlace($dst['img']);
  1680. // 썸네일 이미지 리소스를 기반으로 실제 이미지 생성
  1681. switch($src['mime']){
  1682. case 'image/jpeg' : imagejpeg($dst['img'], $dst['path']); break;
  1683. case 'image/gif' : imagegif($dst['img'], $dst['path']); break;
  1684. case 'image/png' : imagepng($dst['img'], $dst['path']); break;
  1685. case 'image/bmp' : imagebmp($dst['img'], $dst['path']); break;
  1686. case 'image/webp' : imagewebp($dst['img'], $dst['path']); break;
  1687. }
  1688. // 원본 이미지 리소스 종료
  1689. imagedestroy($src['img']);
  1690. // 썸네일 이미지 리소스 종료
  1691. imagedestroy($dst['img']);
  1692. // 썸네일 파일경로 존재 여부 확인후 리턴
  1693. return file_exists($dst['path']) ? array('bool' => true, 'src' => $dst['path'],'fileName'=>$param['o_name']) : array('bool' => false, 'msg' => '파일 생성에 실패하였습니다.');
  1694. }
  1695. function date_diff_d($str1, $str2) {
  1696. $frdt = strtotime($str1);
  1697. $todt = strtotime($str2);
  1698. $diff = ($todt - $frdt)/(60*60*24);
  1699. return $diff;
  1700. }
  1701. if(!function_exists('right')) {
  1702. function right($value, $count){
  1703. $value = mb_substr($value, (mb_strlen($value) - $count), mb_strlen($value));
  1704. return $value;
  1705. }
  1706. }
  1707. if(!function_exists('left')) {
  1708. function left($string, $count){
  1709. return mb_substr($string, 0, $count);
  1710. }
  1711. }
  1712. if(!function_exists('conv_date')) {
  1713. function conv_date($date, $format){
  1714. $datetime = date_create($date);
  1715. return date_format($datetime, $format);
  1716. }
  1717. }
  1718. if(!function_exists('add_birth_hyphen')) {
  1719. // 전화번호의 숫자만 취한 후 중간에 하이픈(-)을 넣는다.
  1720. function add_birth_hyphen($birth)
  1721. {
  1722. return preg_replace("/([0-9]{4})([0-9]{2})([0-9]{2})$/", "\\1-\\2-\\3", $birth);
  1723. }
  1724. }
  1725. if(!function_exists('add_hyphen')) {
  1726. // 전화번호의 숫자만 취한 후 중간에 하이픈(-)을 넣는다.
  1727. function add_hyphen($tel)
  1728. {
  1729. $tel = preg_replace("/[^0-9]/", "", $tel); // 숫자 이외 제거
  1730. if (substr($tel,0,2)=='02')
  1731. return preg_replace("/([0-9]{2})([0-9]{3,4})([0-9]{4})$/", "\\1-\\2-\\3", $tel);
  1732. // else if (is_numeric(substr($tel,0,1)))
  1733. // return preg_replace("/([0-9]{2})([0-9]{3})([0-9]{3,4})([0-9]{4})$/", "\\1-\\2-\\3\\4", $tel);
  1734. else if (strlen($tel)=='8' && (substr($tel,0,2)=='15' || substr($tel,0,2)=='16' || substr($tel,0,2)=='18'))
  1735. // 지능망 번호이면
  1736. return preg_replace("/([0-9]{4})([0-9]{4})$/", "\\1-\\2", $tel);
  1737. else
  1738. return preg_replace("/([0-9]{3})([0-9]{3,4})([0-9]{4})$/", "\\1-\\2-\\3", $tel);
  1739. }
  1740. }
  1741. //기존 회원에서 일반회원, 유프로 직원으로 분류됨에 따라 생성
  1742. //구분은 회원정보에 관계사(ds_company_bp)가 있을 경우 유프로 직원이라 함
  1743. //return true 시 유프로 직원, false : 일반회원
  1744. function getUproMember($cd_user) {
  1745. $ret = false;
  1746. $sql=mysql_query("select ds_company_bp from member_master mm where cd_user = '$cd_user' and ds_delind='N' limit 1");
  1747. $row = mysql_fetch_array($sql);
  1748. if(!empty($row[ds_company_bp])) {
  1749. $ret = true;
  1750. }
  1751. return $ret;
  1752. }
  1753. //발송취소 시킴
  1754. function cancel_tender_sms($connect, $cd_tender_sms) {
  1755. $sms_sql = "update tender_sms_master set ds_send_status = 'B0' where cd_tender_sms = '$cd_tender_sms' ";
  1756. // echo $sms_sql;
  1757. mysql_query($sms_sql, $connect);
  1758. }
  1759. //해당 매물을 lock 상태로 업데이트 시킴
  1760. function lock_status_tender_sms($connect, $cd_tender_sms) {
  1761. $sms_sql = "update tender_sms_master set ds_lock_status = 'B0' where cd_tender_sms = '$cd_tender_sms' ";
  1762. mysql_query($sms_sql, $connect);
  1763. }
  1764. //SMS 등록
  1765. function insert_tender_sms($connect, $DATA) {
  1766. //ds_send_status = 발송상태 발송완료
  1767. //ds_lock_status = 락처리 필요없음
  1768. $sql = "insert into tender_sms_master set
  1769. cd_sale = '$DATA[cd_sale]'
  1770. , cd_tender = '$DATA[cd_tender]'
  1771. , depth = '$DATA[depth]'
  1772. , nm_hp = '$DATA[tender_nm_hp]'
  1773. , nm_content = '$DATA[nm_content]'
  1774. , ds_status = '$DATA[ds_status]'
  1775. , ds_send_status = '$DATA[ds_send_status]'
  1776. , ds_lock_status = 'A0'
  1777. , dt_send = '$DATA[dt_send]'
  1778. , nm_send = '$DATA[cd_userid]'
  1779. , dt_insert = now()
  1780. , nm_insert = '$DATA[cd_userid]'
  1781. ";
  1782. $result = mysql_query($sql,$connect);
  1783. return $result;
  1784. }
  1785. //락 필요치 않음으로 업데이트
  1786. function no_lock_tender_sms($connect, $cd_tender_sms) {
  1787. $sms_sql = "update tender_sms_master set ds_lock_status = 'A0' where cd_tender_sms = '$cd_tender_sms' ";
  1788. // echo $sms_sql;
  1789. mysql_query($sms_sql, $connect);
  1790. }
  1791. //락 설정
  1792. function lock_tender_sms($connect, $cd_tender, $cd_tender_sms) {
  1793. //tender master update
  1794. $tender_sql = "update tender_master set
  1795. ds_lock_status = 'A0'
  1796. , dt_lock = now()
  1797. where cd_tender = '$cd_tender'
  1798. ";
  1799. // echo $tender_sql;
  1800. mysql_query($tender_sql, $connect);
  1801. //tender sms master update
  1802. $sms_sql = "update tender_sms_master set ds_lock_status = 'Z0' where cd_tender_sms = '$cd_tender_sms' ";
  1803. // echo $sms_sql;
  1804. mysql_query($sms_sql);
  1805. }
  1806. function tender_sms_msg() {
  1807. $sms_msg = array(
  1808. 'Z0' => "낙찰중 페이지 {CAR_INFO} 거래 진행처리 진행 부탁드립니다. {PERIOD}일이내 미처리시 입찰이 정지 됩니다.",
  1809. 'Z1' => "진행중 페이지 {CAR_INFO} 거래 진행처리 진행 부탁드립니다. {PERIOD}일이내 미처리시 입찰이 정지 됩니다.",
  1810. );
  1811. return $sms_msg;
  1812. }
  1813. function tender_sms_period() {
  1814. //1차 5일, 2차 3일, 3차 2일
  1815. $sms_period = array(1 => 5, 2 => 3, 3 => 2);
  1816. return $sms_period;
  1817. }
  1818. //파일의 수정일을 기준으로 파일 버전을 가져옴
  1819. //현재는 이미지의 갱신을 위해 사용
  1820. function get_file_mtime($file_web_path) {
  1821. $file_path = $_SERVER['DOCUMENT_ROOT'].'/'.$file_web_path;
  1822. if(file_exists($file_path) && is_file($file_path)) {
  1823. $file_mtime = filemtime($file_path);
  1824. }else {
  1825. $file_mtime = "1";
  1826. }
  1827. return $file_mtime;
  1828. }
  1829. if(!function_exists('string_to_asterisk')) {
  1830. function string_to_asterisk($mode, $str) {
  1831. $ret = "";
  1832. switch($mode) {
  1833. case 'id':
  1834. case 'name':
  1835. $str = trim($str);
  1836. $length = mb_strlen($str, 'utf-8');
  1837. $string_changed = $str;
  1838. if ($length <= 2) {
  1839. // 한두 글자면 그냥 뒤에 별표 붙여서 내보낸다.
  1840. $ret = mb_substr($str, 0, 1, 'utf-8') . '*';
  1841. }
  1842. if ($length >= 3) {
  1843. // 3으로 나눠서 앞뒤.
  1844. $leave_length = floor($length/3); // 남겨 둘 길이. 반올림하니 너무 많이 남기게 돼, 내림으로 해서 남기는 걸 줄였다.
  1845. $asterisk_length = $length - ($leave_length * 2);
  1846. $offset = $leave_length + $asterisk_length;
  1847. $head = mb_substr($str, 0, $leave_length, 'utf-8');
  1848. $tail = mb_substr($str, $offset, $leave_length, 'utf-8');
  1849. $ret = $head . implode('', array_fill(0, $asterisk_length, '*')) . $tail;
  1850. }
  1851. break;
  1852. case 'phone':
  1853. $str = trim($str);
  1854. $length = mb_strlen($str, 'utf-8');
  1855. $string_changed = $str;
  1856. if ($length <= 2) {
  1857. // 한두 글자면 그냥 뒤에 별표 붙여서 내보낸다.
  1858. $ret = mb_substr($str, 0, 1, 'utf-8') . '*';
  1859. }
  1860. if ($length >= 3) {
  1861. // 3으로 나눠서 앞뒤.
  1862. $leave_length = floor($length/3); // 남겨 둘 길이. 반올림하니 너무 많이 남기게 돼, 내림으로 해서 남기는 걸 줄였다.
  1863. $asterisk_length = $length - ($leave_length * 2);
  1864. $offset = $leave_length + $asterisk_length;
  1865. $head = mb_substr($str, 0, $leave_length, 'utf-8');
  1866. $tail = mb_substr($str, $offset, $leave_length, 'utf-8');
  1867. $ret = $head . implode('', array_fill(0, $asterisk_length, '*')) . $tail;
  1868. }
  1869. break;
  1870. }
  1871. return $ret;
  1872. }
  1873. }
  1874. function create_watermark($image_path, $watermark_path = "") {
  1875. if(empty($watermark_path)) {
  1876. $watermark_path = $_SERVER['DOCUMENT_ROOT'].'/img/logo_watermark.png';
  1877. }
  1878. // $img_path = "/image.jpg"; // 원본 이미지 절대경로
  1879. // $watermark_img_path = "/watermark.png"; // 워터마크 이미지 절대경로
  1880. // $image_path, $watermark_path 는 반드시 절대경로로 지정해야함 (url이 아닌 path)
  1881. $array_img_chk = array("jpg", "jpeg", "png", "gif", "bmp");
  1882. // 이미지 확장자
  1883. $img_ext = explode(".", strrev($image_path));
  1884. $img_ext = strrev($img_ext[0]);
  1885. $img_ext = strtolower($img_ext);
  1886. $opacity = 0.5;
  1887. $quality = 90;
  1888. // 이미지 파일인 경우에만 진행
  1889. if(in_array($img_ext, $array_img_chk)) {
  1890. $img_info = getimagesize($image_path);
  1891. //확장자는 jpg인데 mime은 image/webp일 경우 에러가 남
  1892. //방법이 없음
  1893. // print_r($img_info);
  1894. // exit;
  1895. if($img_ext == 'jpg' || $img_ext == 'jpeg')
  1896. $create_img = imagecreatefromjpeg($image_path);
  1897. if($img_ext == 'png')
  1898. $create_img = imagecreatefrompng($image_path);
  1899. if($img_ext == 'gif')
  1900. $create_img = imagecreatefromgif($image_path);
  1901. if($img_ext == 'bmp')
  1902. $create_img = imagecreatefromwbmp($image_path);
  1903. if($create_img) {
  1904. // 워터마크 이미지 확장자
  1905. $watermark_img_ext = explode(".", strrev($watermark_path));
  1906. $watermark_img_ext = strrev($watermark_img_ext[0]);
  1907. $watermark_img_ext = strtolower($watermark_img_ext);
  1908. if($watermark_img_ext == 'jpg' || $watermark_img_ext == 'jpeg')
  1909. $create_watermark_img = imagecreatefromjpeg($watermark_path);
  1910. if($watermark_img_ext == 'png')
  1911. $create_watermark_img = imagecreatefrompng($watermark_path);
  1912. if($watermark_img_ext == 'gif')
  1913. $create_watermark_img = imagecreatefromgif($watermark_path);
  1914. if($watermark_img_ext == 'bmp')
  1915. $create_watermark_img = imagecreatefromwbmp($watermark_path);
  1916. if($create_watermark_img) {
  1917. list($img_w, $img_h) = getimagesize($image_path);
  1918. list($watermark_img_w, $watermark_img_h) = getimagesize($watermark_path);
  1919. imagealphablending($create_img, true);
  1920. $create_watermark_opacity_img = imagesetopacity($create_watermark_img, $opacity);
  1921. // 워터마크 위치 지정
  1922. // $pos_x = 50;
  1923. // $pos_y = 50;
  1924. // (예시) 워터마크를 정중앙으로
  1925. $pos_x = ceil(($img_w - $watermark_img_w) / 2);
  1926. $pos_y = ceil(($img_h - $watermark_img_h) / 2);
  1927. imagecopy($create_img, $create_watermark_opacity_img, $pos_x, $pos_y, 0, 0, $watermark_img_w, $watermark_img_h);
  1928. // imagecopymerge($create_img, $create_watermark_opacity_img, $pos_x, $pos_y, 0, 0, $watermark_img_w, $watermark_img_h, $opacity);
  1929. /* imagecopy 설명 */
  1930. // 원본 이미지 리소스 : $create_img
  1931. // 워터마크 이미지 리소스 : $create_watermark_img
  1932. // 워터마크 이미지 x 좌표 : $pos_x
  1933. // 워터마크 이미지 y 좌표 : $pos_y
  1934. // 원본 이미지 x 좌표 : 0
  1935. // 원본 이미지 y 좌표 : 0
  1936. // 워터마크 이미지 가로크기 : $watermark_img_w
  1937. // 워터마크 이미지 세로크기 : $watermark_img_h
  1938. //테스트용
  1939. // header("Content-type: image/jpeg");
  1940. //실제 이미지 생성
  1941. imagejpeg($create_img, $image_path, $quality);
  1942. imagedestroy($create_img);
  1943. imagedestroy($create_watermark_opacity_img);
  1944. }
  1945. }
  1946. }
  1947. }
  1948. function imagesetopacity( $imageSrc, $opacity )
  1949. {
  1950. $width = imagesx( $imageSrc );
  1951. $height = imagesy( $imageSrc );
  1952. // Duplicate image and convert to TrueColor
  1953. $imageDst = imagecreatetruecolor( $width, $height );
  1954. imagealphablending( $imageDst, false );
  1955. imagefill( $imageDst, 0, 0, imagecolortransparent( $imageDst ));
  1956. imagecopy( $imageDst, $imageSrc, 0, 0, 0, 0, $width, $height );
  1957. // Set new opacity to each pixel
  1958. for ( $x = 0; $x < $width; ++$x )
  1959. for ( $y = 0; $y < $height; ++$y ) {
  1960. $pixelColor = imagecolorat( $imageDst, $x, $y );
  1961. $pixelOpacity = 127 - (( $pixelColor >> 24 ) & 0xFF );
  1962. if ( $pixelOpacity > 0 ) {
  1963. $pixelOpacity = $pixelOpacity * $opacity;
  1964. $pixelColor = ( $pixelColor & 0xFFFFFF ) | ( (int)round( 127 - $pixelOpacity ) << 24 );
  1965. imagesetpixel( $imageDst, $x, $y, $pixelColor );
  1966. }
  1967. }
  1968. return $imageDst;
  1969. }
  1970. function emailCheck($_str)
  1971. {
  1972. if (preg_match("/^[_\.0-9a-zA-Z-]+@([0-9a-zA-Z][0-9a-zA-Z-]+\.)+[a-zA-Z]{2,6}$/i", $_str) == false)
  1973. {
  1974. return false;
  1975. // array(false, "올바른 이메일 주소를 입력해주세요.");
  1976. }
  1977. else
  1978. {
  1979. return true;
  1980. // return array(true);
  1981. }
  1982. }
  1983. //common.js 에서 동일한 함수명으로 스크립용이 존재하도록 설계 했으나 백단에서 처리해도 될 것 같아 스크립트 안만듬
  1984. function get_sa_aap_commission($price, $ds_tradein, $nm_brand, $is_staff = "N") {
  1985. $commission = "";
  1986. $price = preg_replace("/[^0-9]*/s", "", $price);
  1987. if(empty($price)) {
  1988. return $commission;
  1989. }
  1990. $price = (int)$price;
  1991. if($price < 1) {
  1992. return $commission;
  1993. }
  1994. //SA가 올린 매물만 수수료가 존재
  1995. if($is_staff != 'Y') {
  1996. return $commission;
  1997. }
  1998. $SA_AAP_SALE_CONDITION = array();
  1999. //트레이드인 아우디 차량
  2000. $SA_AAP_SALE_CONDITION['A0']['AUDI'] = array(
  2001. "0" => 255000,
  2002. "1" => 310000,
  2003. "2" => 365000,
  2004. "3" => 520000,
  2005. "4" => 675000,
  2006. );
  2007. //트레이드인 아우이 이외
  2008. $SA_AAP_SALE_CONDITION['A0']['ETC'] = array(
  2009. "0" => 155000,
  2010. "1" => 210000,
  2011. "2" => 315000,
  2012. "3" => 420000,
  2013. "4" => 575000,
  2014. );
  2015. $SA_AAP_SALE_CONDITION['B0']['AUDI'] = array(
  2016. "0" => 155000,
  2017. "1" => 210000,
  2018. "2" => 315000,
  2019. "3" => 420000,
  2020. "4" => 575000,
  2021. );
  2022. $SA_AAP_SALE_CONDITION['B0']['ETC'] = array(
  2023. "0" => 55000,
  2024. "1" => 110000,
  2025. "2" => 165000,
  2026. "3" => 220000,
  2027. "4" => 275000,
  2028. );
  2029. $brand = "";
  2030. if(strtoupper($nm_brand) == "AUDI" || $nm_brand == "아무디") {
  2031. $brand = "AUDI";
  2032. }else {
  2033. $brand = "ETC";
  2034. }
  2035. $condition_index = 0;
  2036. //100만원 미만
  2037. if($price < 100) {
  2038. $condition_index = 0;
  2039. }
  2040. //100만원 이상 1000만원 미만
  2041. else if($price >= 100 && $price < 1000) {
  2042. $condition_index = 1;
  2043. }
  2044. //1000만원 이상 2000만원 미만
  2045. else if($price >= 1000 && $price < 2000) {
  2046. $condition_index = 2;
  2047. }
  2048. else if($price >= 2000 && $price < 2850) {
  2049. $condition_index = 3;
  2050. }
  2051. else if($price >= 2850) {
  2052. $condition_index = 4;
  2053. }
  2054. // if($_SERVER['REMOTE_ADDR'] == '220.86.24.199') {
  2055. // echo 'price:'.$price;
  2056. // echo 'condition_index:'.$condition_index;
  2057. // echo 'ds_tradein:'.$ds_tradein;
  2058. // print_r($SA_AAP_SALE_CONDITION);
  2059. // exit;
  2060. // }
  2061. $commission = $SA_AAP_SALE_CONDITION[$ds_tradein][$brand][$condition_index];
  2062. //관리자 금액이 만원 단위로 표현이 되므로
  2063. // $commission = left($commission, 3);
  2064. return $commission;
  2065. }
  2066. ?>