Well.... THANK YOU TO EVERYONE WHO HELPED ME
Got my 1st LAZ App built.
And I can run it from a USB drive - NO .NET (AWESOME!!!)
What this Utility does is simply send a CSS file to my webserver based on the checkbox "Show Notification" selection.
Below is a screen shot of all the files used.
The noticeblock.txt and noticenone.txt files contain the CSS code.
Only difference is that the css "display" tag is different. (display:block or display:none)
What happens after I upload is if I checked the "Show Notification" checkbox... a yellow notice appears on the top of my website.
So, basically this utility just shows or hides an html DIV
As you will see in the code... very simple.
1) var is set when checkbox is selected
2) Clicking the upload button simply evaluates the var
3) We then delete the notice.css file
4) Copy and rename one of the TXT files (based on var) to notice.css
5) Then we upload the CSS file using Synapse FTPSend.pas
Only requirement is that you have to have Synapse and "uses" will be FTPSend
That's it!
HERE IS THE ENTIRE CODE:unit main;
{$mode objfpc}{$H+}
interface
uses
Classes, SysUtils, FileUtil, Forms, Controls, Graphics, Dialogs, StdCtrls,
ExtCtrls, FTPSend;
type
{ TForm1 }
TForm1 = class(TForm)
Button1: TButton;
CheckBox1: TCheckBox;
Image1: TImage;
Label1: TLabel;
procedure Button1Click(Sender: TObject);
procedure CheckBox1Change(Sender: TObject);
private
{ private declarations }
public
{ public declarations }
end;
var
Form1: TForm1;
//var for FTP
IPHost: String = '**********';
Port: String = '21';
User: String = '*********';
Pass: String = '********';
PassMd: Boolean = True;
BinaryMd: Boolean = True;
DirectF: Boolean = True;
//var for file handling
DisplayType: String = 'NONE';
defaultFile: String = 'notice.css';
newFile: String = 'noticenone.txt';
PutFile: String = '/public_html/technipixel/notice.css';
implementation
{$R *.lfm}
{ TForm1 }
//=======================================================
// UPLOAD BUTTON
procedure TForm1.Button1Click(Sender: TObject);
begin
//remove CSS file
DeleteFile('notice.css');
//set txt file based on checkbox
If DisplayType = 'BLOCK' Then
newFile := 'noticeblock.txt';
If DisplayType = 'NONE' Then
newFile := 'noticenone.txt';
//copy file and rename to CSS
CopyFile(newFile,defaultFILE);
//send to webserver vis FTP
with TFTPSend.Create do
try
if User <> '' then
begin
Username := User;
Password := Pass;
end;
TargetHost := IPHost;
TargetPort := Port;
BinaryMode := BinaryMd;
PassiveMode:= PassMd;
if not Login then
Exit;
DirectFileName := defaultFile;
DirectFile := DirectF;
StoreFile(PutFile, False);
Logout;
finally
Free;
MessageDlg('Upload Complete', 'CSS File Has Been Uploaded!', mtInformation, [mbOK], 0);
end;
end;
procedure TForm1.CheckBox1Change(Sender: TObject);
begin
//check for checkbox
If Checkbox1.Checked = False Then
DisplayType:='NONE';
If Checkbox1.Checked = True Then
DisplayType:='BLOCK';
end;
end.
WHY I MADE THISOften times I need to display a notice that I am out of my office (I work from home) or closed for a period of time.
Instead of opening Dreamweaver and editing the CSS every time, then open FileZilla and upload takes about 5 minutes.
This utility does it all for me in 10 seconds!
Again... THANKS
Now that my first small app is out of the way and I understand the code structure in the edior... on to a bigger project!!!
