;Koriss - 19/01/2015 - V001 - script to copy file into folder and propose installation option ; -- CodeClasses.iss -- ; This script shows how to use the WizardForm object and the various VCL classes. [Setup] AppName=SPS AppVersion=14.01 ;CreateAppDir=no DefaultDirName={sd}\sps DisableProgramGroupPage=yes DefaultGroupName=SPS UninstallDisplayIcon={app}\sps.exe WindowVisible=no WizardSmallImageFile=logo.bmp WizardImageFile = bg.bmp OutputDir=C:\Users\IT\Desktop\sps setup\salihin [Files] Source: "package\*"; DestDir: "{app}\"; Flags: Createallsubdirs Recursesubdirs; Source: "ioncube\*"; DestDir: "{app}\..\..\php\ioncube"; Check:getOptionValue(); Flags: Createallsubdirs Recursesubdirs; [Icons] Name: "{commondesktop}\ xampp for sps"; Filename: "{app}\..\..\xampp-control.exe"; [Run] ;Filename: "{cmd}"; Parameters: "sc create MySQL start= auto DisplayName= MySQL binPath= ""{app}\..\..\mysql\bin\mysqld defaults-file={app}\..\..\mysql\bin\my.ini"""; Flags: runhidden ; ;Filename: "{cmd}"; Parameters: "sc create apatche start= auto DisplayName= Apatche binPath=""{app}\..\..\apache\bin\httpd"""; Flags: runhidden ; ;Filename: "{cmd}"; Parameters: Parameters: {code:getParammysql}; Flags: runhidden runascurrentuser; ;Filename: "{cmd}"; Parameters: Parameters: {code:getParamapache}; Flags: runhidden; ;Filename: {code:getmysqlPath}; Flags: runhidden runascurrentuser; ;Filename: {code:getApachtePath}; Flags: runhidden runascurrentuser ; Filename: "http://localhost/{code:MyURL}/installation"; Description: "open in browser localhost/{code:MyURL}/installation"; Flags: shellexec postinstall runasoriginaluser [Code] var optionValue1 : Boolean; obj : TNewCheckListBox; procedure installXampp(Sender: TObject); var ResultCode: integer; begin if Exec(ExpandConstant('{src}\resources\xampp.exe'), '', '', SW_SHOW, ewWaitUntilTerminated, ResultCode) then begin // MsgBox('About to install xampp.exe as ', mbInformation, MB_OK); end else begin MsgBox('Fail to install MyProg.exe as ' + IntToStr(ResultCode), mbInformation, MB_OK); end; end; function MyURL(Param: String): String; var dir: String; OptionsPage: TInputOptionWizardPage; strArray: TArrayOfString; url : String; len, p : Integer; begin dir := ExpandConstant('{app}'); p := Pos('htdocs', dir); if p > 0 then begin url := Copy(dir, p+7, Length(dir)-p+8); end; // getURL(url,dir,'\'); Result := url; end; function parentDir(dir: String) : String; begin Result := Copy(dir, 1, Pos('htdocs',dir)-1); end; function getParammysql(va:string):String; var myparentDir:String; dir:String; begin dir := ExpandConstant('{app}'); myparentDir := Copy(dir, 1, Pos('htdocs',dir)-1); Result := 'sc create MySQL start= auto DisplayName= MySQL binPath= "' + myparentDir + 'mysql\bin\mysqld --install'; end; function getmysqlPath(va:string):String; var myparentDir:String; dir:String; begin dir := ExpandConstant('{app}'); Result := Copy(dir, 1, Pos('htdocs',dir)-1) + 'mysql\bin\mysqld.exe'; end; function getApachtePath(va:string):String; var myparentDir:String; dir:String; begin dir := ExpandConstant('{app}'); Result := Copy(dir, 1, Pos('htdocs',dir)-1) + 'apache\bin\httpd.exe'; end; function getParamapache(va:string): String; var apparentDir:String; dir:String; begin dir := ExpandConstant('{app}'); apparentDir := Copy(dir, 1, Pos('htdocs',dir)-1); Result := 'sc create apatche start= auto DisplayName= Apatche binPath="' + apparentDir + 'apache\bin\httpd"'; end; function getOptionValue(): Boolean ; var FormButton: TNewButton; ANSIStr, UnicodeStr,UnicodeStr1, appP : String; begin appP := parentDir (ExpandConstant('{app}')); //MsgBox(appP , mbInformation, MB_OK); // IF (obj.State[0]) then if LoadStringFromFile(appP+'php\php.ini', ANSIStr) then begin StringChangeEx(ANSIStr, 'zend_extension = "'+ appP +'php\ioncube\ioncube_loader_win_5.5.dll"' + #13#10, '', True); StringChangeEx(ANSIStr, 'zend_extension = "'+ appP +'php\ioncube\ioncube_loader_win_5.6.dll"' + #13#10, '', True); UnicodeStr1 := 'zend_extension = "'+ appP +'php\ioncube\ioncube_loader_win_5.5.dll"' + #13#10 + String(ANSIStr); UnicodeStr := 'zend_extension = "'+ appP +'php\ioncube\ioncube_loader_win_5.6.dll"' + #13#10 + UnicodeStr1; SaveStringToFile(appP+'php\php.ini', AnsiString(UnicodeStr), False); end; Result := obj.State[0]; end; var Pagewithdir: TInputDirWizardPage; procedure GetApatchePath; var DataRootDir: String; Button, FormButton: TNewButton; CheckListBox : TNewCheckListBox; begin // Create the page Pagewithdir := CreateInputDirPage(wpWelcome, 'Apache Server Setting', 'Where is the apache document root?', 'if using xammp, the document root is the htdocs folder whithin the installation, for wamp it is www folder.'#13#10#13#10 + 'click on next to select the folder, if there is no apache istalled, click on the install apache before', False, 'sps'); Button := TNewButton.Create(Pagewithdir); Button.Width := ScaleY(80); Button.Height := ScaleY(25); Button.Top := 120; Button.Caption := 'Install Xampp'; Button.OnClick := @installXampp; Button.Parent :=Pagewithdir.Surface; end; procedure setIoncub; var DataRootDir: String; Button, FormButton: TNewButton; CheckListBox : TNewCheckListBox; PageOpt: TInputDirWizardPage; begin // Create the page PageOpt := CreateInputDirPage(Pagewithdir.ID, 'Apache Server Setting', 'Ioncube loader', 'Ioncube is third party appplication that allowed sps code to be run.'#13#10#13#10 + 'In case you have no idea about ioncube, do not change the default value. '#13#10#13#10 + 'Do restart your server after the installation before setting sps on the browser. For more information visit https://www.ioncube.com/', False, 'sps'); CheckListBox := TNewCheckListBox.Create(PageOpt); CheckListBox.Top := ScaleY(80); CheckListBox.Width :=PageOpt.SurfaceWidth; CheckListBox.Height := ScaleY(100); CheckListBox.Flat := True; CheckListBox.Parent := PageOpt.Surface; CheckListBox.AddRadioButton('Install ioncube', '', 0, True, True, nil); CheckListBox.AddRadioButton('Do not Install Ioncube', '', 0, False, True, nil); obj := CheckListBox; optionValue1 := CheckListBox.State[0]; end; procedure AboutButtonOnClick(Sender: TObject); begin MsgBox('This installer will copy the sps application into your web server', mbInformation, mb_Ok); end; procedure URLLabelOnClick(Sender: TObject); var ErrorCode: Integer; begin ShellExecAsOriginalUser('open', 'http://salihinpremier.com/', '', '', SW_SHOWNORMAL, ewNoWait, ErrorCode); end; procedure CreateAboutButtonAndURLLabel(ParentForm: TSetupForm; CancelButton: TNewButton); var AboutButton: TNewButton; URLLabel: TNewStaticText; begin AboutButton := TNewButton.Create(ParentForm); AboutButton.Left := ParentForm.ClientWidth - CancelButton.Left - CancelButton.Width; AboutButton.Top := CancelButton.Top; AboutButton.Width := CancelButton.Width; AboutButton.Height := CancelButton.Height; AboutButton.Caption := '&About...'; AboutButton.OnClick := @AboutButtonOnClick; AboutButton.Parent := ParentForm; URLLabel := TNewStaticText.Create(ParentForm); URLLabel.Caption := 'http://salihinpremier.com/'; URLLabel.Cursor := crHand; URLLabel.OnClick := @URLLabelOnClick; URLLabel.Parent := ParentForm; { Alter Font *after* setting Parent so the correct defaults are inherited first } URLLabel.Font.Style := URLLabel.Font.Style + [fsUnderline]; if GetWindowsVersion >= $040A0000 then { Windows 98 or later? } URLLabel.Font.Color := clHotLight else URLLabel.Font.Color := clBlue; URLLabel.Top := AboutButton.Top + AboutButton.Height - URLLabel.Height - 2; URLLabel.Left := AboutButton.Left + AboutButton.Width + ScaleX(20); end; procedure InitializeWizard(); var BackgroundBitmapImage: TBitmapImage; BackgroundBitmapText: TNewStaticText; begin { Custom wizard pages } GetApatchePath; setIoncub; { Custom controls } CreateAboutButtonAndURLLabel(WizardForm, WizardForm.CancelButton); BackgroundBitmapImage := TBitmapImage.Create(MainForm); BackgroundBitmapImage.Left := 50; BackgroundBitmapImage.Top := 90; BackgroundBitmapImage.AutoSize := True; BackgroundBitmapImage.Bitmap := WizardForm.WizardBitmapImage.Bitmap; BackgroundBitmapImage.Parent := MainForm; BackgroundBitmapText := TNewStaticText.Create(MainForm); BackgroundBitmapText.Left := BackgroundBitmapImage.Left; BackgroundBitmapText.Top := BackgroundBitmapImage.Top + BackgroundBitmapImage.Height + ScaleY(8); BackgroundBitmapText.Caption := 'TBitmapImage'; BackgroundBitmapText.Font.Color := clWhite; BackgroundBitmapText.Parent := MainForm; { Custom beveled label } WizardForm.BeveledLabel.Caption := ' BeveledLabel '; end; procedure InitializeUninstallProgressForm(); begin { Custom controls } CreateAboutButtonAndURLLabel(UninstallProgressForm, UninstallProgressForm.CancelButton); end;