:::::::::::::::::::::::::::::::::::::::::::::::::::::::::
::                                                     :: 
::     GPTEngine v 1.1.1 -- Windows Batch Installer    ::
::                                                     ::
::                 (©2005 by popux.com)                ::
::                                                     :: 
:::::::::::::::::::::::::::::::::::::::::::::::::::::::::

@ECHO OFF
TITLE GPTEngine Setup
GRAFTABL 850
COLOR 3B
CLS
ECHO.
SET Web_Domain=%1
SET Document_Root=%2
SET FTP_Username=%3
SET FTP_Password=%4
SET MySQL_Username=%5
SET MySQL_Password=%6
SET MySQL_Database=%7
SET Site_Name=%8
SET Site_URL=%9
FOR %%N IN (1,2,3,4,5,6,7,8,9) do SHIFT 
SET Site_EMail=%1
SET Site_Reply_EMail=%2
SET GPTE_Username=%3
SET GPTE_Password=%4
SET Admin_Title=%5
SET Admin_Name=%6
SET Admin_EMail=%7
SET Web_Server_OS=%8
SET Target_System=%9
SHIFT
SET Local_DocRoot=%9
gpteaux.exe %GPTE_Username% %GPTE_Password% %MySQL_Username% %MySQL_Password% %MySQL_Database% %Site_URL%
IF %Web_Server_OS%==windows MOVE /Y gpteaux.cgi ..\cgi_win32\
IF %Web_Server_OS%==linux MOVE /Y gpteaux.cgi ..\cgi_linux\
ECHO Creating SQL file...
ECHO DROP TABLE IF EXISTS `GPTE_Default_Config`;> gpte.sq2
ECHO CREATE TABLE `GPTE_Default_Config` (`Opt` varchar(32) NOT NULL default '''',`Val` text,PRIMARY KEY  (`Opt`),UNIQUE KEY `Opt` (`Opt`));>> gpte.sq2
ECHO /*!40000 ALTER TABLE `GPTE_Default_Config` DISABLE KEYS */;>> gpte.sq2
ECHO LOCK TABLES `GPTE_Default_Config` WRITE;>> gpte.sq2
ECHO INSERT INTO `GPTE_Default_Config` VALUES ('Administrator_EMail','%Admin_EMail%'),('Administrator_Name','%Admin_Name%'),('Administrator_Title','%Admin_Title%');>> gpte.sq2
ECHO INSERT INTO `GPTE_Default_Config` VALUES ('Site_Name','%Site_Name%'),('Site_URL','%Site_URL%'),('GPTEngine_Pages_URL','%Site_URL%/pages'),('GPTEngine_Docs_URL','%Site_URL%/docs');>> gpte.sq2
ECHO INSERT INTO `GPTE_Default_Config` VALUES ('PHP_Temp_URL','%Site_URL%/cgi-bin/tp');>> gpte.sq2
ECHO INSERT INTO `GPTE_Default_Config` VALUES ('Admin_Session_Time_Out','1800'),('Advertiser_Login_With_EMail','0'),('Delete_Suspended_Users','0');>> gpte.sq2
ECHO INSERT INTO `GPTE_Default_Config` VALUES ('Free_Referrals_Redistribution','95'),('gpte.cgi_Alias','gpte.cgi'),('gpteclick.cgi_Alias','gpteclick.cgi'),('Max_Clicking_Interval','30'),('Max_Login_Interval','30'),('Max_Mailer_Childs','5');>> gpte.sq2
ECHO INSERT INTO `GPTE_Default_Config` VALUES ('Max_Mailer_Running_Time','100'),('Max_Mails_to_Sent','100'),('Max_Mails_to_Sent_Interval','1'),('Max_Reading_Interval','30'),('Max_Surfing_Interval','30'),('Minimum_Payout','10.00'),('NavBar_Frame_Size','20');>> gpte.sq2
ECHO INSERT INTO `GPTE_Default_Config` VALUES ('Payout_ID_Info','PayPal_ID'),('PHP_Temp_Dir','tp'),('Point_Value','0.01'),('Same_IP_Blocking_Interval','720'),('Session_Time_Out','3600'),('Site_Copyright_Notice',CONCAT('©',CONCAT(YEAR(NOW()),' by %Site_Name%'))),('Site_EMail','%Site_EMail%');>> gpte.sq2
ECHO INSERT INTO `GPTE_Default_Config` VALUES ('Site_Reply_EMail','%Site_Reply_EMail%'),('Timer_Frame_Size','20'),('User_Login_With_EMail','0');>> gpte.sq2
IF %Web_Server_OS%==windows ECHO INSERT INTO `GPTE_Default_Config` VALUES ('SMTP_Need_Authentication','0'),('SMTP_Password',NULL),('SMTP_Server',NULL),('SMTP_Username',NULL);>> gpte.sq2
IF %Web_Server_OS%==linux ECHO INSERT INTO `GPTE_Default_Config` VALUES ('Sendmail_Path','/usr/sbin/sendmail'),('Sendmail_Queueing','0');>> gpte.sq2
ECHO UNLOCK TABLES;>> gpte.sq2
ECHO /*!40000 ALTER TABLE `GPTE_Default_Config` ENABLE KEYS */;>> gpte.sq2
TYPE gpte.sq1 > gpte.sql
TYPE gpte.sq2 >> gpte.sql
TYPE gpte.sq3 >> gpte.sql
DEL /Q gpte.sq2
IF %Web_Server_OS%==windows MOVE /Y gpte.sql ..\cgi_win32\ 
IF %Web_Server_OS%==linux MOVE /Y gpte.sql ..\cgi_linux\
IF %Target_System%==Local GOTO LocalSetup
ECHO Creating FTP script...
ECHO OPEN %Web_Domain%> gpte.ftp
ECHO %FTP_Username%>> gpte.ftp
ECHO %FTP_Password%>> gpte.ftp
ECHO CD %Document_Root%>> gpte.ftp
ECHO MKDIR page_pics>> gpte.ftp
ECHO CD page_pics>> gpte.ftp
ECHO LCD ../www/page_pics>> gpte.ftp
ECHO BINARY>> gpte.ftp
ECHO MPUT *>> gpte.ftp
ECHO CD ..>> gpte.ftp
ECHO LCD ..>> gpte.ftp
ECHO RENAME index.html old_index.html>> gpte.ftp
ECHO RENAME favicon.ico old_favicon.ico>> gpte.ftp
ECHO ASCII>> gpte.ftp
ECHO MPUT *.html>> gpte.ftp
ECHO BINARY>> gpte.ftp
ECHO PUT favicon.ico>> gpte.ftp
ECHO MKDIR pages>> gpte.ftp
ECHO CD pages>> gpte.ftp
ECHO MKDIR pics>> gpte.ftp
ECHO CD pics>> gpte.ftp
ECHO MKDIR flags>> gpte.ftp
ECHO CD flags>> gpte.ftp
ECHO LCD ../pages/pics/flags>> gpte.ftp
ECHO MPUT *>> gpte.ftp
ECHO CD ..>> gpte.ftp
ECHO LCD ..>> gpte.ftp
ECHO MPUT *.jpg>> gpte.ftp
ECHO CD ..>> gpte.ftp
ECHO MKDIR styles>> gpte.ftp
ECHO CD styles>> gpte.ftp
ECHO LCD ../styles>> gpte.ftp
ECHO ASCII>> gpte.ftp
ECHO MPUT *>> gpte.ftp
ECHO CD ..>> gpte.ftp
ECHO LCD ..>> gpte.ftp
ECHO MPUT *.gpte>> gpte.ftp
ECHO MPUT *.html>> gpte.ftp
ECHO CD ..>> gpte.ftp
ECHO MKDIR docs>> gpte.ftp
ECHO CD docs>> gpte.ftp
ECHO LCD ../docs>> gpte.ftp
ECHO MPUT *>> gpte.ftp
ECHO CD ..>> gpte.ftp
ECHO MKDIR cgi-bin>> gpte.ftp
ECHO CD cgi-bin>> gpte.ftp
IF %Web_Server_OS%==windows ECHO LCD ../cgi_win32>> gpte.ftp
IF %Web_Server_OS%==linux ECHO LCD ../cgi_linux>> gpte.ftp
ECHO MKDIR tp>> gpte.ftp
ECHO PUT gpte.css>> gpte.ftp
ECHO HASH>> gpte.ftp
ECHO PUT gpte.sql>> gpte.ftp
ECHO HASH>> gpte.ftp
ECHO BINARY>> gpte.ftp
ECHO PUT gptelogo.jpg>> gpte.ftp
ECHO MPUT *.cgi>> gpte.ftp
ECHO ASCII>> gpte.ftp
IF %Web_Server_OS%==linux ECHO DELETE gptelogo.cgi>> gpte.ftp
IF %Web_Server_OS%==linux ECHO DELETE gptestyle.cgi>> gpte.ftp
IF %Web_Server_OS%==linux ECHO PUT gptelogo.cgi>> gpte.ftp
IF %Web_Server_OS%==linux ECHO PUT gptestyle.cgi>> gpte.ftp
IF %Web_Server_OS%==windows MPUT *.bat>> gpte.ftp
IF %Web_Server_OS%==windows GOTO NEXT
ECHO LITERAL chmod 777 tp>> gpte.ftp
ECHO LITERAL chmod 666 gpte.sql>> gpte.ftp
ECHO LITERAL chmod 666 gpteaux.cgi>> gpte.ftp
ECHO LITERAL chmod 755 gpte00.cgi>> gpte.ftp
ECHO LITERAL chmod 755 gpte01.cgi>> gpte.ftp
ECHO LITERAL chmod 755 gpte02.cgi>> gpte.ftp
ECHO LITERAL chmod 755 gpte03.cgi>> gpte.ftp
ECHO LITERAL chmod 755 gpte04.cgi>> gpte.ftp
ECHO LITERAL chmod 755 gpte05.cgi>> gpte.ftp
ECHO LITERAL chmod 755 gpte06.cgi>> gpte.ftp
ECHO LITERAL chmod 755 gpte07.cgi>> gpte.ftp
ECHO LITERAL chmod 755 gpte08.cgi>> gpte.ftp
ECHO LITERAL chmod 755 gpte09.cgi>> gpte.ftp
ECHO LITERAL chmod 755 gpte10.cgi>> gpte.ftp
ECHO LITERAL chmod 755 gpte11.cgi>> gpte.ftp
ECHO LITERAL chmod 755 gpte12.cgi>> gpte.ftp
ECHO LITERAL chmod 755 gpte13.cgi>> gpte.ftp
ECHO LITERAL chmod 755 gpte14.cgi>> gpte.ftp
ECHO LITERAL chmod 755 gpte15.cgi>> gpte.ftp
ECHO LITERAL chmod 755 gpte16.cgi>> gpte.ftp
ECHO LITERAL chmod 755 gpte17.cgi>> gpte.ftp
ECHO LITERAL chmod 755 gpte18.cgi>> gpte.ftp
ECHO LITERAL chmod 755 gpte.cgi>> gpte.ftp
ECHO LITERAL chmod 755 gptebuyit.cgi>> gpte.ftp
ECHO LITERAL chmod 755 gpteclick.cgi>> gpte.ftp
ECHO LITERAL chmod 755 gptecntct.cgi>> gpte.ftp
ECHO LITERAL chmod 755 gptecrdt.cgi>> gpte.ftp
ECHO LITERAL chmod 755 gptecvtpnt.cgi>> gpte.ftp
ECHO LITERAL chmod 755 gptelogin.cgi>> gpte.ftp
ECHO LITERAL chmod 755 gptelogo.cgi>> gpte.ftp
ECHO LITERAL chmod 755 gptemailer.cgi>> gpte.ftp
ECHO LITERAL chmod 755 gptemsg.cgi>> gpte.ftp
ECHO LITERAL chmod 755 gptemsgbox.cgi>> gpte.ftp
ECHO LITERAL chmod 755 gptenav.cgi>> gpte.ftp
ECHO LITERAL chmod 755 gptengine.cgi>> gpte.ftp
ECHO LITERAL chmod 755 gptenvcrdt.cgi>> gpte.ftp
ECHO LITERAL chmod 755 gptepytreq.cgi>> gpte.ftp
ECHO LITERAL chmod 755 gptesetup.cgi>> gpte.ftp
ECHO LITERAL chmod 755 gptesignup.cgi>> gpte.ftp
ECHO LITERAL chmod 755 gptestyle.cgi>> gpte.ftp
ECHO LITERAL chmod 644 gptetndig.cgi>> gpte.ftp
ECHO LITERAL chmod 755 gpteturnbr.cgi>> gpte.ftp
ECHO LITERAL chmod 755 gpteuninst.cgi>> gpte.ftp
ECHO LITERAL chmod 755 gpteupgaff.cgi>> gpte.ftp
ECHO LITERAL chmod 755 gptevac.cgi>> gpte.ftp
:NEXT
ECHO BYE>> gpte.ftp 
ECHO Starting uploading...
TITLE GPTEngine Setup -- uploading files...
ftp -v -i -s:gpte.ftp
ECHO Cleaning temporary files...
DEL /Q gpte.ftp
IF %Web_Server_OS%==linux GOTO DEL1
IF %Web_Server_OS%==windows GOTO DEL2  
:DEL1
DEL /Q ..\cgi_linux\gpteaux.cgi
DEL /Q ..\cgi_linux\gpte.sql
GOTO END
:DEL2
DEL /Q ..\cgi_win32\gpteaux.cgi
DEL /Q ..\cgi_win32\gpte.sql
GOTO END
:END
TITLE GPTEngine Setup -- Done
START /MAX %Site_URL%/cgi-bin/gptesetup.cgi
CLS
:LocalSetup
ECHO Moving files to web server...
MOVE /Y ..\cgi_win32\gpteaux.cgi %Local_DocRoot%"\cgi-bin\"
MOVE /Y ..\cgi_win32\gpte.sql %Local_DocRoot%"\cgi-bin\"
RENAME %Local_DocRoot%\index.html %Local_DocRoot%\old_index.html
XCOPY /Y /C /I /K /E ..\www\* %Local_DocRoot%\
XCOPY /Y /C /I /K /E ..\docs %Local_DocRoot%\docs\
XCOPY /Y /C /I /K /E ..\pages %Local_DocRoot%\pages\
XCOPY /Y /C /I /K /E ..\cgi_win32\* %Local_DocRoot%\cgi-bin\
TITLE GPTEngine Setup -- Done
START /MAX http://localhost/cgi-bin/gptesetup.cgi
CLS