File name: addrbook/setup/setup (5,456 bytes) Text file viewer v1.2
    1 : #!/bin/wel
    2 : 
    3 : /* file: setup
    4 : 
    5 :    주소록 설치 프로그램 (author: 서광현)
    6 : 
    7 :    Copyright (c) 2001/02/22 by Wesoft
    8 :    All Rights Reserved.
    9 : */
   10 : 
   11 : timeout(0);
   12 : if(right(getcwd(), 5)=="setup") chdir("..");
   13 : 
   14 : default_host= "localhost";
   15 : default_db= "weladdr";
   16 : default_decoder= "@cgipasswd";
   17 : default_zipcode_url= "/cgi-pub/zipcode";
   18 : default_cookie_expire= 30;
   19 : default_register= "Auto register";
   20 : 
   21 : print("\n\n>>>> addrbook.wel V0.1 installer\n");
   22 : print("\n1. Enter MySQL database user id: ");
   23 : myuser= lrtrim(input());
   24 : print("\n2. Enter MySQL database passwd: ");
   25 : mypass= lrtrim(input());
   26 : print("\n3. Enter MySQL host (", default_host, "): ");
   27 : myhost= lrtrim(input());
   28 : print("\n4. Enter database name (", default_db, "): ");
   29 : mydb= lrtrim(input());
   30 : print("\n5. Enter decode variable (", default_decoder, "): ");
   31 : decoder= lrtrim(input());
   32 : print("\n6. Enter URL [zipcode.wel] (", default_zipcode_url, "): ");
   33 : zipcode_url= lrtrim(input());
   34 : print("\n7. Enter cookie expire time (", default_cookie_expire, "min): ");
   35 : cookie_expire= val(input());
   36 : print("\n8. Enter online register (", default_register, "): ");
   37 : register= ltrim(input());
   38 : 
   39 : while(1)
   40 :  {
   41 :     print("\n9. Administrator user id: ");
   42 :     admuser= lrtrim(input());
   43 :     if(admuser!="") break;
   44 :  }
   45 : while(1)
   46 :  {
   47 :     print("\n10. Administrator user password: ");
   48 :     admpass= tolower(left(lrtrim(input()),12));
   49 :     if(admpass!="") break;
   50 :  }
   51 : print("\n11. Administrator name: "); admname= lrtrim(input());
   52 : print("\n12. Administrator phone: "); admphone= lrtrim(input());
   53 : print("\n13. Administrator handphone: "); admhdphone= lrtrim(input());
   54 : while(1)
   55 :  {
   56 :     print("\n14. Administrator email: ");
   57 :     admemail= lrtrim(input());
   58 :     if(admemail!="") break;
   59 :  }
   60 : 
   61 : if(myhost=="") myhost= default_host;
   62 : if(mydb=="") mydb= default_db;
   63 : if(decoder=="") decoder= default_decoder;
   64 : if(zipcode_url=="") zipcode_url= default_zipcode_url;
   65 : len= len(zipcode_url);
   66 : if(right(zipcode_url, 1)=="/") zipcode_url= left(zipcode_url, len-1);
   67 : if(cookie_expire=="") cookie_expire= default_cookie_expire;
   68 : ch= toupper(left(register, 1));
   69 : if(ch=="Y") register= "Yes";
   70 :  else if(ch=="N") register= "No";
   71 :  else register= default_register;
   72 : 
   73 : enpass= encode(mypass, encodekey(), "", decoder);
   74 : enadmpass= encode(admpass, encodekey(), "", decoder);
   75 : 
   76 : print("\n\n-------------------------------------\n");
   77 : print("  MySQL database      user: ", myuser, "\n");
   78 : print("  MySQL database    passwd: ", mypass, "\n");
   79 : print("  MySQL database      host: ", myhost, "\n");
   80 : print("  Database name / addrbook: ", mydb, "\n");
   81 : print("  password decode variable: ", decoder, "\n");
   82 : print("  zipcode.wel          URL: ", zipcode_url, "\n");
   83 : print("  Cookie    expire    time: ", cookie_expire, " min\n");
   84 : print("  Online register         : ", register, "\n");
   85 : print("  -------------------------\n");
   86 : print("  Administrator user     id: ", admuser, "\n");
   87 : print("  Administrator user passwd: ", admpass, "\n");
   88 : print("  Administrator        name: ", admname, "\n");
   89 : print("  Administrator       phone: ", admphone, "\n");
   90 : print("  Administrator   handphone: ", admhdphone, "\n");
   91 : print("  Administrator       Email: ", admemail, "\n");
   92 : print("-------------------------------------\n\n");
   93 : 
   94 : sel= choice(" Do you want to install?(Y/n) ", "Yy\nNn");
   95 : if(sel==3) print("Y");
   96 : print("\n\n");
   97 : cancel= "Installation is cancelled.\n\n";
   98 : if(sel>3)
   99 :  {
  100 :     print(cancel);
  101 :     return;
  102 :  }
  103 : ch= toupper(left(register, 1));
  104 : if(ch=="Y") register= 1;
  105 :  else if(ch=="N") register= 0;
  106 :  else register= 2;
  107 : 
  108 : mysql= mysql_connect(myhost, myuser, mypass); // MySQL 서버 연결
  109 : if(mysql==MYSQL_ERR)
  110 :  {
  111 :     print("MySQL connect error!\n", cancel);
  112 :     return;
  113 :  }
  114 : 
  115 : print("1. Creating database: mysqladmin create ", mydb, "\n");
  116 : if(mypass=="") passoption= ""; else passoption= " -p" ~ mypass;
  117 : mysqladmin= "mysqladmin create " ~ mydb ~ " -u" ~ myuser ~ passoption;
  118 : system(mysqladmin);
  119 : if(mysql_select_db(mysql, mydb)==MYSQL_ERR)
  120 :  {
  121 :     print("database creation error!\n", cancel);
  122 :     return;
  123 :  }
  124 : 
  125 : print("2. Creating user table: DB=", mydb, " TABLE=user");
  126 : 
  127 : include("setup/setup.sub");
  128 : if(mysql_query(mysql, ADDRBOOK_USER_TABLE)==MYSQL_ERR)
  129 :  {
  130 :     print("\ntable 'user' creating error!\n", cancel);
  131 :     return;
  132 :  }
  133 : print(" --> OK\n");
  134 : print("3. Creating memo table: DB=", mydb, " TABLE=umemo");
  135 : if(mysql_query(mysql, ADDRBOOK_MEMO_TABLE)==MYSQL_ERR)
  136 :  {
  137 :     print("\ntable 'umemo' creating error!\n", cancel);
  138 :     return;
  139 :  }
  140 : print(" --> OK\n");
  141 : print("4. Insert Administrator");
  142 : wdtime= date(1) ~ " " ~ left(time(1),5);
  143 : qstr= "insert into user (wdtime,id,pass,title,class,kind,useflag,"
  144 :     ~ "name,phone,hdphone,email,pagerec)"
  145 :     ~ strform("values ('{$wdtime}','{$admuser}','{$enadmpass}',",
  146 :               "'Administrator','A','C','Y','{$admname}','{$admphone}',",
  147 :               "'{$admhdphone}','{$admemail}','10')");
  148 : 
  149 : if(mysql_query(mysql, qstr)==MYSQL_ERR)
  150 :  {
  151 :     print("\nadministrator insert error!\n", cancel);
  152 :     return;
  153 :  }
  154 : mysql_close(mysql);
  155 : print(" --> OK\n");
  156 : print("5. setup 'common.inc'");
  157 : fp= fopen("common.inc", "w");
  158 : if(fp==FILE_OPEN_ERR)
  159 :  {
  160 :     print("\ncommon.inc open error!\n", cancel);
  161 :     return;
  162 :  }
  163 : formredir(fp);
  164 : btname= "{$btname}";
  165 : action= "{$action}";
  166 : style= "{$style}";
  167 : randomize();
  168 : cookie_garbage= fix(rand(40))+1;
  169 : formdump("setup/common.def");
  170 : fclose(fp);
  171 : print(" --> OK\n");
  172 : print("6. Testing:  http://your-site/install-dir/addrbook/login.wel\n\n");
  173 : print(" Successfuly installed, Thanks for using.\n\n");
  174 : print(" http://wesoft.co.kr                          Tel: (054) 433-4554\n");
  175 : return;
File name: addrbook/setup/setup (5,456 bytes) Wesoft Corp. ⓒ 2001 All rights reserved.