File name: zipcode/zipcode.wel (3,326 bytes) Text file viewer v1.2
    1 : #!/bin/wel
    2 : 
    3 : /*  zipcode.wel
    4 : 
    5 :     주소 입력 부프로그램
    6 : 
    7 :     Copyright (c) 2001/01/27 by Wesoft
    8 :     All Rights Reserved.
    9 : 
   10 : */
   11 : 
   12 : host= "localhost";
   13 : htmlquery("GET");
   14 : htmlquery("POST");
   15 : htmlquery(decode(mysqlupass, "", "@mysqlupass")); // MySQL(myuser, mypass)
   16 : 
   17 : dbname= "zipcode";
   18 : tablename= "zipcode";
   19 : cpright= "<font color=#5c5c5c face=Verdana size=1>"
   20 :        ~ "<b>Wesoft Corp.</b> ⓒ 2001 All rights reserved.</font>";
   21 : 
   22 : PROGRAM_NAME= "zipcode.wel";
   23 : PROGRAM_VERSION= "v0.1.2";
   24 : 
   25 : if(background!="") bground= " background='" ~ background ~ "'";
   26 :   else if(bgcolor!="") bground= " bgcolor='#" ~ bgcolor ~ "'";
   27 : 
   28 : if(onlylist!=1)
   29 :  {
   30 :    if(fn=="" || z1=="" || z2=="" || a1=="" || a2=="")
   31 :     {
   32 :        formdump("form/usage.fom");
   33 :        return;
   34 :     }
   35 :  }
   36 : if(dong=="") { formdump("form/zipcode.fom"); return; }
   37 : 
   38 : dong= strchange(lrtrim(dong), "'|\\", "\"|/");
   39 : pos= strfind(dong, " ");
   40 : if(pos==0) sido_cond= "", keyword= dong;
   41 :  else
   42 :   {
   43 :      fch= "경남|경북|전남|전북|충남|충북";
   44 :      rch= "경상남도|경상북도|전라남도|전라북도|충청남도|충청북도";
   45 :      sido= strchange(left(dong, pos-1), fch, rch);
   46 :      dong= ltrim(mid(dong, pos+1));
   47 :      keyword= sido ~ " " ~ dong;
   48 :      sido_cond= "(sido like '%" ~ sido
   49 :               ~ "%' or gugun like '%" ~ sido ~ "%') and ";
   50 :   }
   51 : 
   52 : mysql= mysql_connect(host, myuser, mypass);
   53 : if(mysql==MYSQL_ERR)
   54 :  {
   55 :     MSG1= "MySQL 서버 접속 오류";
   56 :     MSG2= host ~ " 서버에 접속할 수 없습니다! 서버 관리자에게 문의하세요!";
   57 :     formdump("form/error.fom");
   58 :     return;
   59 :  }
   60 : 
   61 : if(mysql_select_db(mysql, dbname)==MYSQL_ERR)
   62 :  {
   63 :     MSG1= "Database 선택 오류";
   64 :     MSG2= dbname
   65 :         ~ " 데이터베이스를 선택할 수 없습니다! 서버 관리자에게 문의하세요!";
   66 :     formdump("form/error.fom");
   67 :     return;
   68 :  }
   69 : 
   70 : qstr= "select zipcode,sido,gugun,dong,bunji,ho from " ~ tablename
   71 :     ~ " where " ~ sido_cond ~ "dong like '%" ~ dong ~ "%'";
   72 : 
   73 : if(mysql_query(mysql, qstr)==MYSQL_ERR)
   74 :  {
   75 :     MSG1= "Database Query 오류";
   76 :     MSG2= "데이터베이스 쿼리가 잘못되었습니다! 서버 관리자에게 문의하세요!"
   77 :         ~ "<br>Query: " ~ qstr;
   78 :     formdump("form/error.fom");
   79 :     return;
   80 :  }
   81 : 
   82 : result= mysql_store_result(mysql);
   83 : if(result==MYSQL_ERR)
   84 :  {
   85 :     MSG1= "mysql_store_result() 오류";
   86 :     MSG2= "mysql_store_result() 오류입니다! 서버 관리자에게 문의하세요!";
   87 :     formdump("form/error.fom");
   88 :     return;
   89 :  }
   90 : 
   91 : formopen("form/zipcode.fom");
   92 : DATA_TABLE= 1;
   93 : rows_count= mysql_num_rows(result);
   94 : if(rows_count==0)
   95 :   {
   96 :      NO_DATA= 1;
   97 :      MSG_COLOR= "#f00000";
   98 :      MSG= "'" ~ keyword ~ "'에 대한 자료가 없습니다.";
   99 :   }
  100 :  else if(rows_count<=256)
  101 :   {
  102 :      MSG_COLOR= "#000000";
  103 :      MSG= "총 " ~ rows_count ~ "개의 '" ~ keyword ~ "'이(가) 검색되었습니다.";
  104 :   }
  105 :  else
  106 :   {
  107 :     MSG_COLOR= "#f00000";
  108 :     MSG= "총 " ~ rows_count ~ "개의 '"
  109 :        ~ keyword ~ "'이(가) 검색되어 256개만 처리했습니다.";
  110 :     rows_count= 256;
  111 :   }
  112 : for (i=1; i<=rows_count; i++)
  113 :  {
  114 :     row= mysql_fetch_row(result);
  115 :     if(isarray(row))
  116 :      {
  117 :         zip1= mid(row[0], 1, 3);
  118 :         zip2= mid(row[0], 5, 3);
  119 :         address2= row[1];
  120 :         if(row[2]!="") address2~= " "~row[2];
  121 :         if(row[3]!="") address2~= " "~row[3];
  122 :         address= address2; // 호와 번지가 제외된 주소
  123 :         if(row[4]!="") address2~= " "~row[4];
  124 :         if(row[5]!="") address2~= " "~row[5];
  125 :         formmerge(0);
  126 :      }
  127 :  }
  128 : formdump();
  129 : formclose();
  130 : mysql_free_result(result);
  131 : mysql_close(mysql);
  132 : return;
File name: zipcode/zipcode.wel (3,326 bytes) Wesoft Corp. ⓒ 2001 All rights reserved.