Location: PHPKode > projects > YW-GuestBook > YW Guestbook 1.45/YW Guestbook/ywgb/install.php
<?php
  //-------------------------------------------------------------------------
  //                             YW Guestbook
  //                               install.php
  //
  //-------------------------------------------------------------------------
  //                   Copyright (c) Vortex Solutions
  //                        http://www.yahoowebs.tk
  //-------------------------------------------------------------------------
  //  This program is free software. You can redistribute it and/or modify
  //  it under the terms of the License that was distributed with this file!
  //-------------------------------------------------------------------------

  define ( "MAXLEN_NAME"     , "40" );
  define ( "MAXLEN_EMAIL"    , "40" );
  define ( "MAXLEN_HOMEPAGE" , "40" );
  define ( "MAXLEN_AIM"      , "40" );
  define ( "MAXLEN_MSN"      , "40" );
  define ( "MAXLEN_YAHOO"    , "40" );

  global $ENCODING;
  
  if (!function_exists('mysqli_connect') && !function_exists('mysql_connect')) 
    die("<center><b>Fatal error</b>: The MySQL(i) extension cannot be loaded - please check your PHP configuration !");

  if (!file_exists("lang/langinstall.inc"))
    die("<center>Missing file: <b>lang/langinstall.inc</b> !");
  @include("lang/langinstall.inc");

  $ENCODING = (isset($lang['encoding'])) ? strtolower($lang['encoding']) : "";
  if ($ENCODING != "")
    header("Content-Type: text/html; charset=".$ENCODING);
?>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
  <head>
    <title>YW Guestbook- Installation</title>
    <link rel="stylesheet" type="text/css" href="admin.css">
  </head>

  <body><br />
<?php
  //*********************************************************************
  //                          main-routine
  //*********************************************************************

  // include the language-package
    
  include("functions.php");

  // is the install-lock active ?
  if (file_exists("ht_lock.".EXT))
    Error($lang['alreadyInstalled']);

  $x = ($ENCODING == "utf-8") ? "_utf8" : "";
  include("libs/string".$x.".php"); 

  vgb_getParameters();

  // if no parameters are given show the guestbook-entries
  if (!empty($arg)) {
    // are all needed parameters set ?
    setParameters(array("HOSTNAME","USERNAME","PASSWORD","DATABASE",
                        "EMAIL","ADMINPASS","ADMINPASS2","PREFIX"));

    // preset the inputfields
    $preHOSTNAME   = trim($arg['HOSTNAME']);
    $preUSERNAME   = trim($arg['USERNAME']);
    $prePASSWORD   = trim($arg['PASSWORD']);
    $preDATABASE   = trim($arg['DATABASE']);
    $preEMAIL      = trim($arg['EMAIL']);
    $preADMINPASS  = trim($arg['ADMINPASS']);
    $preADMINPASS2 = trim($arg['ADMINPASS2']);
    $prePREFIX    = trim($arg['PREFIX']);
    $preEUROPE = (isset($arg['EUROPE'])) ? 1 : 0;
    $preNORTH = (isset($arg['NORTH'])) ? 1 : 0;
    $preSOUTH = (isset($arg['SOUTH'])) ? 1 : 0;
    $preASIA = (isset($arg['ASIA'])) ? 1 : 0;
    $preAFRICA = (isset($arg['AFRICA'])) ? 1 : 0;
    $preOCEANIA = (isset($arg['OCEANIA'])) ? 1 : 0;
    $preDEPENDENCY = (isset($arg['DEPENDENCY'])) ? 1 : 0;

    // check the parameters
    if ($preHOSTNAME == "")
      $errorMSG = $lang['noHostname'];
    elseif ($preUSERNAME == "")
      $errorMSG = $lang['noUsername'];
    elseif ($preDATABASE == "")
      $errorMSG = $lang['noDatabase'];
    elseif ($prePREFIX == "")
      $errorMSG = $lang['noPrefix'];
    elseif ($preADMINPASS == "")
      $errorMSG = $lang['noPassword'];
    elseif (($x = vgb_noASCII(array($lang['adminPass'] => $preADMINPASS, $lang['email'] => $preEMAIL))) != "")
      $errorMSG = "Only ASCII characters are allowed in the field: ".$x; 
    elseif (strtoupper($preADMINPASS) != strtoupper($preADMINPASS2))
      $errorMSG = $lang['wrongPassword'];
    else {
      $est = false;
      if (function_exists('mysqli_connect')) {
        $mySQL = @mysqli_connect($preHOSTNAME,$preUSERNAME,$prePASSWORD,$preDATABASE);
        if ($mySQL) {
          $est = true;
          include("libs/db_mysqli.php");
        }
      }  
      if (!$est) {
        if (!function_exists('mysql_connect')) 
          $errorMSG = $lang['noDB'];
        else {
          $mySQL = @mysql_connect($preHOSTNAME,$preUSERNAME,$prePASSWORD)
            or $errorMSG = $lang['noDB'];
      
          if (!isset($errorMSG) && (!@mysql_select_db($preDATABASE)))
            $errorMSG = $lang['noDBAccess'];
          if (!isset($errorMSG))
            include("libs/db_mysql.php");
        }
      }
    }
      
    $Prefix = $prePREFIX;

    if (!isset($errorMSG)) {
      // inputs are okay => start installation
      installDB();
      // create ht_lock
      $filetext = "<?php global \$mySQL_Host,\$mySQL_User,\$mySQL_Password,\$mySQL_Database,\$Prefix; \$mySQL_Host = '".
                   AddSlashes($preHOSTNAME)."';".
                   "\$mySQL_User = '".
                   AddSlashes($preUSERNAME)."';".
                   "\$mySQL_Password = '".
                   AddSlashes($prePASSWORD)."';".
                   "\$mySQL_Database = '".
                   AddSlashes($preDATABASE)."';".
                   "\$Prefix = '".
                   AddSlashes($prePREFIX)."'?>";
      $file = @fopen("ht_lock.".EXT,"a+")
        or Error($lang['noFile'].htmlspecialchars($filetext,ENT_QUOTES).
                 $lang['noFile2']);
      fputs($file,$filetext);
      fclose($file);
      $screen = 1;
    }
    else
      $screen = 0;
  }
  else {
    $preHOSTNAME = "localhost";
    $preUSERNAME = "";
    $prePASSWORD = "";
    $preDATABASE = "";
    $prePREFIX = "VGB";
    $preEMAIL = "";
    $preADMINPASS = "";
    $preADMINPASS2 = "";
    $screen = 0;
    $preEUROPE = 1;
    $preNORTH = 1;
    $preSOUTH = 1;
    $preASIA = 1;
    $preAFRICA = 1;
    $preOCEANIA = 1;
    $preDEPENDENCY = 0;
  }

  switch ($screen) {
    case 0: // print the install-mask
            echo "<form action='install.".EXT."' method='post'>".
                 "<table width=550 align=center><tr>".
                 "<td class='bgright' align=left>".
                 "<center>".
                 "<span class='title'>YW Guestbook - ".$lang['install'].
                 "</span>".
                 "<p>".
                 "<span class='option'>".$lang['welcome']."</span><p>";
            printMSG();
            echo "<span class='info'>".$lang['required']."</span><p></center>";
            echo "<ul type=square class='menu'><li>".$lang['mysqlSetup'].
                 "</li></ul>";
            InputField("HOSTNAME",$preHOSTNAME,25,127,
              $lang['hostname'],$lang['hostnameInfo']);
            InputField("USERNAME",$preUSERNAME,25,127,
              $lang['username'],$lang['usernameInfo']);
            InputField("PASSWORD",$prePASSWORD,25,127,
              $lang['password'],$lang['passwordInfo']);
            InputField("DATABASE",$preDATABASE,25,127,
              $lang['database'],$lang['databaseInfo']);
            InputField("PREFIX",$prePREFIX,25,127,
              $lang['prefix'],$lang['prefixInfo']);
            echo "<p><ul type=square class='menu'><li>".$lang['adminSetup'].
                 "</li></ul>";
            InputField("EMAIL",$preEMAIL,25,127,
              $lang['email'],$lang['emailInfo']);
            Password("ADMINPASS",$preADMINPASS,$lang['adminPass'],
              $lang['adminPassInfo']);
            Password("ADMINPASS2",$preADMINPASS2,$lang['adminPass2'],
              $lang['adminPass2Info']);
            echo "<p><ul type=square class='menu'><li>".$lang['countrySetup'].
                 "</li></ul>";
            Checkbox("EUROPE",$preEUROPE,$lang['europe']);
            Checkbox("NORTH",$preNORTH,$lang['north']);
            Checkbox("SOUTH",$preSOUTH,$lang['south']);
            Checkbox("ASIA",$preASIA,$lang['asia']);
            Checkbox("AFRICA",$preAFRICA,$lang['africa']);
            Checkbox("OCEANIA",$preOCEANIA,$lang['oceania']);
            Checkbox("DEPENDENCY",$preDEPENDENCY,$lang['dependency']);
            echo "<center><p><input type=submit class='button' ".
                 "value='".$lang['startInstall'].
                 "' name='install'><br>&nbsp;</center>".
                 "</td></tr></table>".
                 "</form><br />";
            break;
    case 1: // print the installation-success screen
            echo "<table width=100% height=100%><tr>".
                 "<td align=center valign=middle>".
                 "<table width=400><tr><td class='bgright' align=center>".
                 "<span class='title'>YW Guestbook<span><p>".
                 "<span class='info'>".$lang['success']."</span><p>".
                 "<a href='admin.".EXT."'>&raquo; ".$lang['click'].
                 "</a><br>&nbsp;".
                 "</td></tr></table></td></tr></table>";
  }
  //*********************************************************************
  //                          sub-routines
  //*********************************************************************

  function setParameters ( $inParameters ) {
    // returns if all of the given parameters are set or exit with an error
    global $arg,$lang;

    foreach ($inParameters as $_parameter) {
      if (!isset($arg[$_parameter]))
        error($lang['missingParameter'].$_parameter);
    }
  }

  function printMSG() {
    // prints an error- or statusmessage if defined
    global $lang,$errorMSG,$statusMSG;

    if (isset($errorMSG))
      echo "<center><span class='show'>".$lang['errorOccured'].
           "</span><br><span class='error'>".$errorMSG.
           "</b></span><p></center>";
    elseif (isset($statusMSG))
      echo "<center><br><span class='status'><b>".$statusMSG.
           "</b></span><p></center>";
  }

  function password ( $inName, $inValue, $inText, $inInfo = null ) {
    // prints a password-input-field
    echo "<table width=450 align=center cellpadding=2>".
         "<tr><td align=left class='bgoption'>".
         "<table width=100% cellspacing=0>".
         "<tr><td>".
         "<span class='option'>".
         " &nbsp; $inText </span>".
         "</td><td align=right>".
         "<input class='input' name='$inName' value='".vgb_formdata($inValue)."' maxlength=127".
         " size=25 type=password> &nbsp; ".
         "</td></tr></table></td></tr>";
    if (!is_null($inInfo))
      echo "<tr><td colspan=2 class='bginfo'><blockquote><span class='info'>".
      vgb_removeHTML($inInfo)."</span>".
           "</blockquote></td></tr>";
    echo "</table>";
  }

  function inputfield ( $inName, $inValue, $inLen, $inMaxlen,
                        $inText, $inInfo = null ) {
    // prints an inputfield for text
    echo "<table width=450 align=center cellpadding=2>".
         "<tr><td class='bgoption'>".
         "<table cellspacing=0 width=100%>".
         "<tr><td align=left><span class='option'> &nbsp; $inText </span>".
         "</td><td align=right>".
         "<input class='input' name='$inName' value='".
         vgb_formdata($inValue)."' maxlength=$inMaxlen".
         " size=$inLen type=text> &nbsp; ".
         "</td></tr></table></td></tr>";
    if (!is_null($inInfo))
      echo "<tr><td colspan=2 class='bginfo'><blockquote><span class='info'>".
           vgb_removeHTML($inInfo)."</span>".
           "</blockquote></td></tr>";
    echo "</table>";
  }

  function checkbox ( $inName, $inValue, $inText, $inInfo = null ) {
    // prints a checkbox
    echo "<table width=450 align=center>".
         "<tr><td align=left class='bgoption'><span class='option'>".
         "<input name='$inName' value='1'";
    if ($inValue)
      echo " checked";
    echo " type=checkbox>".
         " $inText</span></td></tr>";
    if (!is_null($inInfo))
      echo "<tr><td class='bginfo'><blockquote><span class='info'>$inInfo".
           "</span></blockquote></td></tr>";
    echo "</table>";
  }

  function addC ( $inName, $inIcon = null ) {
    // adds a country to database

    if (is_Null($inIcon))
      $inIcon = $inName;
    $inIcon = strtolower($inIcon).".gif";
    $inName = strtoupper($inName);
    vgb_query("insert into VGB_COUNTRY values(NULL,'$inName','$inIcon',1)");
  }

  function installDB() {
  // creates the database for the guestbook
    global $lang,$preEMAIL,$preADMINPASS,$ENCODING,
           $preEUROPE,$preNORTH,$preSOUTH,$preASIA,
           $preAFRICA,$preOCEANIA,$preDEPENDENCY;

    // set the first available skin as default skin
    $_skins = array();
    $_dir = @opendir("skins/")
      or error($lang['noSkinDir']);
    while ($_name = readdir($_dir)) {
      if (($_name != ".") && ($_name != ".."))
        $_skins[] = $_name;
    }
    closedir($_dir);
    // if the skindir is empty set an empty string
    $_skin = (sizeof($_skins) == 0) ? "" : $_skins[0];

    $queries = array(
      // build up structure
      "create table if not exists VGB_SETTINGS (
         VERSION           varchar(127) not null,
         ONLINEDATE        date not null,
         ADMINPASSWORD     varchar(127) not null,
         ADMINEMAIL        varchar(127),
         LASTSENDMAIL      date not null,
         ACTIVESKIN        varchar(255) not null,
         SENDNOTICE        bool not null,
         USEFRAMES         bool not null,
         USEJAVASCRIPT     bool not null,
         USEUSDATE         bool not null,
         USEEMOTICONS      bool not null,
         PASTENTRIES       int not null,
         MAXSPAMTIME       int not null,
         MAXENTRIES        int not null,
         MAXENTRIESPERPAGE int not null,
         MAXLENENTRY       int not null,
         MAXLENNAME        tinyint unsigned not null,
         MAXLENEMAIL       tinyint unsigned not null,
         MAXLENHOMEPAGE    tinyint unsigned not null,
         MAXLENAIM         tinyint unsigned not null,
         MAXLENMSN         tinyint unsigned not null,
         MAXLENYAHOO       tinyint unsigned not null,
         FORCEBREAK        tinyint unsigned not null,
         ACTIVATELINKS     bool not null,
         ASKEMAIL          bool not null,
         ASKHOMEPAGE       bool not null,
         ASKICQ            bool not null,
         ASKAIM            bool not null,
         ASKMSN            bool not null,
         ASKYAHOO          bool not null,
         ASKCOUNTRY        bool not null,
         FORCECOUNTRY      bool not null,
         HIDEIP            bool not null,
         HIDEHOST          bool not null,
         USEBROWSCAP       bool not null,
         HIDESTATS         bool not null,
         LIMITBROWSER      int not null,
         LIMITOS           int not null,
         LIMITCOUNTRY      int not null,
         USEFILTER         int not null,
         BADWORDSTRING     varchar(".(vgb_maxlen()*vgb_lenfactor()).") not null,
         ASKPICTURE        bool not null,
         MINX              int not null,
         MAXX              int not null,
         MINY              int not null,
         MAXY              int not null,
         VISITORS          int not null,
         VISITORSSINCE     date not null,
         INDEXURL          varchar(127),
         VGBID1            varchar(255),
         VGBID2            varchar(255),
         FORCEEMAIL        bool not null,
         USEBBCODE         bool not null,
         STRIPCODE         bool not null,
         USECSS            bool not null,
         USEBOLD           bool not null,
         USEITALIC         bool not null,
         USEUNDERLINE      bool not null,
         USELINK           bool not null,
         USELEFT           bool not null,
         USECENTER         bool not null,
         USERIGHT          bool not null,
         USECODE           bool not null,
         USELIST           bool not null,
         USEIMAGE          bool not null,
         USESIZE           bool not null,
         USECOLORHEX       bool not null,
         USECOLORPRE       bool not null,
         USEFONT           bool not null,
         SIZEMIN           tinyint unsigned not null,
         SIZEMAX           tinyint unsigned not null,
         USERCOLORS        text not null,
         USERFONTS         text not null,
         ASKPICTEXT        bool not null,
         FILTERNAME        bool not null,
         FILTEREMAIL       bool not null,
         FILTERHOMEPAGE    bool not null,
         FILTERAIM         bool not null,
         FILTERMSN         bool not null,
         FILTERYAHOO       bool not null,
         FILTERPICTEXT     bool not null,
         ASKPRIVATE        bool not null,
         PRIVPARAMETER     varchar(30),
         ASKHIDEEMAIL      bool not null,
         USEMAILER         bool not null,
         USEADMINEMO       bool not null,
         USEIFRAME         bool not null,
         PRECOUNTRY        int,
         ALLOWCOMMENTS     bool not null,
         ADDHOURS          int not null,
         ADDMINUTES        int not null,
         ADDSECONDS        int not null,
         COMMENTNAME       varchar(".(MAXLEN_NAME*vgb_lenfactor()).") not null,
         COMMENTEMAIL      varchar(".MAXLEN_EMAIL.") not null,
         MODERATEDMODE     bool not null,
         DEACTIVATED       bool not null,
         USEWBR            bool not null,
         BACKURL           varchar(127),
         ALLOWSEARCH       bool not null,
         USEQUOTE          bool not null,
         BANLIST           text not null,
         BANROBOTS         bool not null,
         MAXEMPTYLINES     int not null,
         EMAILTOOLTIP      varchar(".(vgb_maxlen()*vgb_lenfactor()).") not null,
         EMAILFROM         varchar(127) not null,
         HTMLEMAIL         bool not null,
         FIRSTENTRY        bool not null,
         FIRSTCOMMENT      bool not null,
         ENTRYSENT         bool not null,
         COMMENTSENT       bool not null,
         PASSPREFIX        varchar(20) not null,
         THUMBNAILX        int not null,
         THUMBNAILY        int not null,
         ENCODING          varchar(30) not null
       )",
      "create table if not exists VGB_ENTRY (
         ID                int primary key auto_increment,
         DATE              date not null,
         NAME              varchar(".(MAXLEN_NAME*vgb_lenfactor())."),
         ENTRY             text not null,
         COMMENT           text,
         COUNTRY           int,
         EMAIL             varchar(".MAXLEN_EMAIL."),
         HOMEPAGE          varchar(".MAXLEN_HOMEPAGE."),
         ICQ               int unsigned,
         AIM               varchar(".MAXLEN_AIM."),
         MSN               varchar(".MAXLEN_MSN."),
         YAHOO             varchar(".MAXLEN_YAHOO."),
         IP                varchar(16) not null,
         BROWSER           varchar(255) not null,
         HOSTNAME          varchar(128) not null,
         SIGNTIME          time,
         PICTURE           varchar(32),
         PICTEXT           varchar(".(vgb_maxlen()*vgb_lenfactor())."),
         PRIVATE           varchar(20),
         HIDEEMAIL         bool not null,
         UNMODERATED       bool not null
       )",
      "create table if not exists VGB_CUSTOMFIELD (
         ID                tinyint unsigned primary key auto_increment,
         NAME              varchar(255) not null,
         TYPE              tinyint not null,
         RULES             text not null,
         PRIORITY          tinyint unsigned not null,
         FRCE              bool not null,
         STATS             bool not null,
         LIMITSTATS        int not null,
         FORMTEXT          varchar(255) not null,
         FILTER            bool not null,
         PREALLOCATE       varchar(255)
       )",
      "create table if not exists VGB_CUSTOMENTRY (
         ENTRY_ID          int not null,
         FIELD_ID          tinyint unsigned not null,
         CONTENT           varchar(255),
         primary key(ENTRY_ID,FIELD_ID)
       )",
      "create table if not exists VGB_RATINGBOX (
         ID                tinyint unsigned primary key auto_increment,
         NAME              varchar(255) not null,
         PRIORITY          tinyint unsigned not null,
         FRCE              bool not null,
         STATS             bool not null,
         FORMTEXT          varchar(255) not null
       )",
      "create table if not exists VGB_RATING (
         ENTRY_ID          int not null,
         BOX_ID            tinyint unsigned not null,
         RATING            tinyint not null,
         primary key(ENTRY_ID,BOX_ID)
       )",
      "create table if not exists VGB_SPAM (
         IP                varchar(16) not null,
         TIMESTAMP         datetime not null,
         TRIES             tinyint,
         primary key(IP,TIMESTAMP)
       )",
      "create table if not exists VGB_VISITOR (
         IP                varchar(16) not null,
         TIMESTAMP         datetime not null,
         primary key(IP,TIMESTAMP)
       )",
      "create table if not exists VGB_EMOTICON (
         ID                int primary key auto_increment,
         CODE              varchar(32) not null,
         FILENAME          varchar(127) not null,
         PRIORITY          tinyint unsigned not null
      )",
      "create table if not exists VGB_COUNTRY (
         ID                int primary key auto_increment,
         NAME              varchar(255) not null,
         FLAGICON          varchar(127) not null,
         TRANSLATE         bool not null
      )",
      "create table if not exists VGB_SESSION (
         IP                varchar(16) not null,
         TIMESTAMP         datetime not null,
         SESSIONID         varchar(20) not null,
         TRY               tinyint ,
         primary key(IP,TIMESTAMP)
      )",
      "create table if not exists VGB_MAILSPAM (
         IP                varchar(16) not null,
         TIMESTAMP         datetime not null,
         EMAIL             varchar(127) not null,
         primary key(IP,TIMESTAMP,EMAIL)
      )",
      "create table if not exists VGB_LOGIN (
         IP                varchar(16) not null,
         TIMESTAMP         datetime not null,
         ENTRYID           int not null,
         TRY               tinyint ,
         SESSIONID         varchar(20),
         primary key(IP,TIMESTAMP,ENTRYID)
      )",
      "create table if not exists VGB_COMMENT (
         ID                int primary key auto_increment,
         ENTRYID           int not null,
         NAME              varchar(".(MAXLEN_NAME*vgb_lenfactor()).") not null,
         EMAIL             varchar(".MAXLEN_EMAIL."),
         TEXT              text not null,
         IP                varchar(16) not null,
         HOSTNAME          varchar(128) not null,
         DATE              date not null,
         SIGNTIME          time not null,
         ADMIN             bool not null,
         UNMODERATED       bool not null
      )",
      "create table if not exists VGB_COMMENTSPAM (
         IP                varchar(16) not null,
         TIMESTAMP         datetime not null,
         ENTRYID           int not null,
         primary key(IP,TIMESTAMP,ENTRYID)
      )",
      "create table if not exists VGB_EMAIL (
         ID                int primary key,
         ACTIVE            bool not null,
         SUBJECT           varchar(127),
         MESSAGE           text
      )",
      "create table if not exists VGB_USER (
         ID                int primary key auto_increment,
         NAME              varchar(".(MAXLEN_NAME*vgb_lenfactor()).") not null,
         RESERVED          bool not null,
         PASSWORD          varchar(30) not null,
         SIGNATURE         text not null,
         EMAIL             varchar(".MAXLEN_EMAIL.") not null,
         HIDEEMAIL         bool not null,
         HOMEPAGE          varchar(".MAXLEN_HOMEPAGE.") not null,
         ICQ               int unsigned not null,
         AIM               varchar(".MAXLEN_AIM.") not null,
         MSN               varchar(".MAXLEN_MSN.") not null,
         YAHOO             varchar(".MAXLEN_YAHOO.") not null,
         COUNTRY           int not null,
         PICTEXT           varchar(".(vgb_lenfactor()*vgb_maxlen()).") not null,
         PICTURE           varchar(32) not null
      )",
      "create table if not exists VGB_CUSTOMUSER (
         USER_ID           int not null,
         FIELD_ID          tinyint unsigned not null,
         CONTENT           varchar(255) not null,
         primary key(USER_ID,FIELD_ID)
      )",
      // clear all existing datas
      "delete from VGB_SETTINGS",
      "delete from VGB_ENTRY",
      "delete from VGB_CUSTOMFIELD",
      "delete from VGB_CUSTOMENTRY",
      "delete from VGB_RATINGBOX",
      "delete from VGB_RATING",
      "delete from VGB_COUNTRY",
      "delete from VGB_EMOTICON",
      "delete from VGB_SPAM",
      "delete from VGB_VISITOR",
      "delete from VGB_SESSION",
      "delete from VGB_MAILSPAM",
      "delete from VGB_LOGIN",
      "delete from VGB_COMMENT",
      "delete from VGB_COMMENTSPAM",
      "delete from VGB_EMAIL",
      "delete from VGB_USER",
      "delete from VGB_CUSTOMUSER",

      // initialize default mails
      "insert into VGB_EMAIL values(1,0,null,null)",
      "insert into VGB_EMAIL values(2,0,null,null)",
      "insert into VGB_EMAIL values(3,0,null,null)",
      "insert into VGB_EMAIL values(4,0,null,null)",
      "insert into VGB_EMAIL values(5,0,null,null)",
      "insert into VGB_EMAIL values (6,0,null,null)",
      "insert into VGB_EMAIL values (7,0,null,null)",
      "insert into VGB_EMAIL values (8,0,null,null)",
      "insert into VGB_EMAIL values (9,0,null,null)",

      // create default emoticons
      "insert into VGB_EMOTICON values(null,':-)','smile.gif',20)",
      "insert into VGB_EMOTICON values(null,':-D','laugh.gif',25)",
      "insert into VGB_EMOTICON values(null,';-)','wink.gif',30)",
      "insert into VGB_EMOTICON values(null,':-(','sad.gif',35)",
      "insert into VGB_EMOTICON values(null,':-/','angry.gif',40)",
      "insert into VGB_EMOTICON values(null,':-*','sick.gif',45)",
      "insert into VGB_EMOTICON values(null,'8-)','cool.gif',50)",
      "insert into VGB_EMOTICON values(null,':-0','ohmy.gif',55)",
      "insert into VGB_EMOTICON values(null,'8-0','love.gif',60)",
      "insert into VGB_EMOTICON values(null,':-|','unsure.gif',65)",
      "insert into VGB_EMOTICON values(null,':-!','important.gif',70)",
      "insert into VGB_EMOTICON values(null,':-?','question.gif',75)",
      "insert into VGB_EMOTICON values(null,'#-)','crazy.gif',80)",
      "insert into VGB_EMOTICON values(null,':-U','special1.gif',85)",
      "insert into VGB_EMOTICON values(null,':-B','special2.gif',90)",
      "insert into VGB_EMOTICON values(null,':-}','tongue.gif',95)"
    );
    foreach ($queries as $q) {
      vgb_query($q);
    }
    // save the selected countries into database
    addC("0","empty");
    if ($preEUROPE) {
      addC("al");
      addC("ad");
      addC("am");
      addC("at");
      addC("by");
      addC("be");
      addC("ba");
      addC("bg");
      addC("cv");
      addC("hr");
      addC("cz");
      addC("dk");
      addC("ee");
      addC("fi");
      addC("fr");
      addC("ge");
      addC("de");
      addC("gr");
      addC("hu");
      addC("is");
      addC("ie");
      addC("it");
      addC("lv");
      addC("li");
      addC("lt");
      addC("lu");
      addC("mk");
      addC("mt");
      addC("md");
      addC("mc");
      addC("nl");
      addC("no");
      addC("pl");
      addC("pt");
      addC("ro");
      addC("sm");
      addC("sk");
      addC("si");
      addC("es");
      addC("se");
      addC("ch");
      addC("ua");
      addC("uk");
      addC("va");
      addC("yu");
    }
    if ($preNORTH) {
      addC("ag");
      addC("bs");
      addC("bb");
      addC("bz");
      addC("ca");
      addC("cr");
      addC("cu");
      addC("dm");
      addC("do");
      addC("sv");
      addC("gd");
      addC("gt");
      addC("ht","hi");
      addC("hn");
      addC("jm");
      addC("mx");
      addC("ni");
      addC("pa");
      addC("kn");
      addC("lc");
      addC("vc");
      addC("tt");
      addC("us");
    }
    if ($preSOUTH) {
      addC("ar");
      addC("bo");
      addC("br");
      addC("cl");
      addC("co");
      addC("ec");
      addC("gy");
      addC("py");
      addC("pe");
      addC("sr");
      addC("uy");
      addC("ve");
    }
    if ($preASIA || $preEUROPE) {
      addC("cy");
      addC("ru");
      addC("tr");
    }
    if ($preASIA) {
      addC("af");
      addC("az");
      addC("bh");
      addC("bd");
      addC("bt");
      addC("bn");
      addC("mm");
      addC("kh");
      addC("cn");
      addC("tp");
      addC("in");
      addC("id");
      addC("ir");
      addC("iq");
      addC("il");
      addC("jp");
      addC("jo");
      addC("kz");
      addC("kp");
      addC("kr");
      addC("kw");
      addC("kg");
      addC("la");
      addC("lb");
      addC("my");
      addC("mv");
      addC("mn");
      addC("np");
      addC("om");
      addC("pk");
      addC("ph");
      addC("qr");
      addC("sa");
      addC("sg");
      addC("lk");
      addC("sy");
      addC("tw");
      addC("tj");
      addC("th");
      addC("tm");
      addC("ae");
      addC("uz");
      addC("vn");
      addC("ye");
    }
    if ($preAFRICA) {
      addC("dz");
      addC("ao");
      addC("bj");
      addC("bw");
      addC("bf");
      addC("bi");
      addC("cm");
      addC("cf");
      addC("td");
      addC("km");
      addC("cg");
      addC("cd");
      addC("ci");
      addC("dj");
      addC("eg");
      addC("gq");
      addC("er");
      addC("et");
      addC("ga");
      addC("gm");
      addC("gh");
      addC("gn");
      addC("gw");
      addC("ke");
      addC("ls");
      addC("lr");
      addC("ly");
      addC("mg");
      addC("mw");
      addC("ml");
      addC("mr");
      addC("mu");
      addC("ma");
      addC("mz");
      addC("na");
      addC("ne");
      addC("ng");
      addC("rw");
      addC("st");
      addC("sn");
      addC("sc");
      addC("sl");
      addC("so");
      addC("za");
      addC("sd");
      addC("sz");
      addC("tz");
      addC("tg");
      addC("tn");
      addC("ug");
      addC("zm");
      addC("zw");
    }
    if ($preOCEANIA) {
      addC("au");
      addC("fj");
      addC("ki");
      addC("mh");
      addC("fm");
      addC("nr");
      addC("nz");
      addC("pw");
      addC("pg");
      addC("ws");
      addC("sb");
      addC("to");
      addC("tv");
      addC("vu");
    }
    if ($preDEPENDENCY) {
      addC("as");
      addC("ai");
      addC("aw");
      addC("bm");
      addC("bv","no");
      addC("io");
      addC("vg");
      addC("ky");
      addC("cx","au");
      addC("cc","au");
      addC("ck");
      addC("fo");
      addC("fk");
      addC("gf","fr");
      addC("pf");
      addC("gi");
      addC("gl");
      addC("gp","fr");
      addC("gu");
      addC("gg");
      addC("hm","au");
      addC("hk");
      addC("im");
      addC("je");
      addC("mo");
      addC("mq");
      addC("yt","fr");
      addC("ms");
      addC("an");
      addC("nc","fr");
      addC("nu");
      addC("nf");
      addC("mp");
      addC("pr");
      addC("pn");
      addC("re","fr");
      addC("sh");
      addC("pm");
      addC("gs");
      addC("sj","no");
      addC("tk","nz");
      addC("tc");
      addC("vi");
      addC("wf");
    }

    // save default values into database
    $_today = getdate(time());
    $_onlineDate = $_today['year']."-".$_today['mon']."-".
                     $_today['mday'];
    $q = "insert into VGB_SETTINGS values('1.2 FINAL','$_onlineDate',".
         "'".strtoupper(AddSlashes($preADMINPASS))."',";
    $q .= ($preEMAIL == "") ? "null" : "'".AddSlashes($preEMAIL)."'";
    $q .= ",'2000-1-1','".AddSlashes($_skin)."',0,0,1,0,1,0,5,0,10,10000,".
          MAXLEN_NAME.",".MAXLEN_EMAIL.",".MAXLEN_HOMEPAGE.",".MAXLEN_AIM.
          ",".MAXLEN_MSN.",".MAXLEN_YAHOO.",28,1,1,1,0,0,0,0,1,1,0,0,0,0,0,0,0,0,'-BADWORD-',
          0,10,200,10,200,0,'".$_onlineDate."',null,
          'bG9hZFNraW4oIm5vRnJhbWVzLnBocCIpO2lmKCRjbCE9MyllcnJvcigkbGFuZ1snb".
          "m9Db3B5J10pOw==|ZWNobyI8Yj5WaVBFUiBHdWVzdGJvb2sgViIuJHNldHRpbmdzW".
          "ydWRVJTSU9OJ10uIjwvYj4gLSA','mY29weTsgMjAwNCBieSBNYXJjIFN0ZWluIjs".
          "kY2x8PSAxOw==|b3V0KCI8YSBocmVmPSdodHRwOi8vd3d3LnZpcGVyZ2IuZGUudnU".
          "nIHRhcmdldD0nX2JsYW5rJyIuIiAkaW5UYWc+d3d3LnZpcGVyZ2IuZGUudnU8L2E+".
          "Iik7JGNsfD0yOw==',0, 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,3,'black=#000000\ngray=#808080\nred=#FF0000\nlime=#00FF00\nyellow=#FFFF00\nblue=#0000FF\nfuchsia=#FF00FF\naqua=#00FFFF\nwhite=#FFFFFF\nmaroon=#800000\ngreen=#008000\nolive=#808000\nnavy=#000080\npurple=#800080\nteal=#008080\nsilver=#C0C0C0','',0,0,0,".
          "0,0,0,0,0,0,null,0,1,0,0,null,0,0,0,0,'','',0,0,0,null,0,0,'',0,3,'::user::(a+)::domain::','',0,0,0,0,0,'pass=',100,0,'".$ENCODING."')";
    vgb_query($q);
  }
?>
  </body>
</html>
Return current item: YW-GuestBook