Rev 61 | Go to most recent revision | Show entire file | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 61 | Rev 91 | ||
---|---|---|---|
Line 13... | Line 13... | ||
13 | 13 | ||
14 | type |
14 | type |
15 | TForm2 = class(TForm) |
15 | TForm2 = class(TForm) |
16 | WebBrowser1: TWebBrowser; |
16 | WebBrowser1: TWebBrowser; |
17 | Timer1: TTimer; |
17 | Timer1: TTimer; |
- | 18 | OpenDialog3: TOpenDialog; |
|
18 | procedure Timer1Timer(Sender: TObject); |
19 | procedure Timer1Timer(Sender: TObject); |
19 | procedure WebBrowser1BeforeNavigate2(ASender: TObject; |
20 | procedure WebBrowser1BeforeNavigate2(ASender: TObject; |
20 | const pDisp: IDispatch; const URL, Flags, TargetFrameName, PostData, |
21 | const pDisp: IDispatch; const URL, Flags, TargetFrameName, PostData, |
21 | Headers: OleVariant; var Cancel: WordBool); |
22 | Headers: OleVariant; var Cancel: WordBool); |
22 | procedure WebBrowser1WindowClosing(ASender: TObject; |
23 | procedure WebBrowser1WindowClosing(ASender: TObject; |
Line 127... | Line 128... | ||
127 | 128 | ||
128 | procedure TForm2.Timer1Timer(Sender: TObject); |
129 | procedure TForm2.Timer1Timer(Sender: TObject); |
129 | var |
130 | var |
130 | phpScript: string; |
131 | phpScript: string; |
131 | sl: TStringList; |
132 | sl: TStringList; |
- | 133 | resourcestring |
|
- | 134 | SRunningScriptPleaseWait = 'Running script... please wait...'; |
|
- | 135 | SPleaseEnterPHPScript = 'Please enter a PHP file to execute.'; |
|
- | 136 | SFileDoesNotExist = 'File %s does not exist.'; |
|
- | 137 | SFastPHP = 'ViaThinkSoft FastPHP'; |
|
132 | begin |
138 | begin |
133 | Timer1.Enabled := false; |
139 | Timer1.Enabled := false; |
134 | phpScript := ParamStr(1); |
140 | phpScript := ParamStr(1); |
135 | 141 | ||
136 | // Remove Security |
142 | // Remove Security |
137 | WebBrowser1.ServiceQuery := EmbeddedWBQueryService; |
143 | WebBrowser1.ServiceQuery := EmbeddedWBQueryService; |
138 | 144 | ||
139 | WebBrowser1.LoadHTML('<h1>FastPHP</h1>Running script... please wait...'); |
145 | WebBrowser1.LoadHTML('<h1>'+SFastPHP+'</h1>'+SRunningScriptPleaseWait); |
140 | 146 | ||
141 | // TODO: nice HTML error/intro pages (as resource?) |
147 | // TODO: nice HTML error/intro pages (as resource?) |
142 | if phpScript = '' then |
148 | if phpScript = '' then |
143 | begin |
149 | begin |
144 | WebBrowser1.LoadHTML('<h1>FastPHP</h1>Please enter a PHP file to execute.'); |
150 | WebBrowser1.LoadHTML('<h1>'+SFastPHP+'</h1>'+SPleaseEnterPHPScript); |
- | 151 | if not OpenDialog3.Execute then |
|
- | 152 | begin |
|
145 | Abort; |
153 | Abort; |
146 | end; |
154 | end; |
- | 155 | phpScript := OpenDialog3.FileName; |
|
- | 156 | end; |
|
147 | 157 | ||
148 | if not FileExists(phpScript) then |
158 | if not FileExists(phpScript) then |
149 | begin |
159 | begin |
150 | WebBrowser1.LoadHTML(Format('<h1>FastPHP</h1>File %s does not exist.', [phpScript])); |
160 | WebBrowser1.LoadHTML(Format('<h1>'+SFastPHP+'</h1>'+SFileDoesNotExist, [phpScript])); |
151 | Abort; |
161 | Abort; |
152 | end; |
162 | end; |
153 | 163 | ||
154 | WebBrowser1.LoadHTML(RunPHPScript(phpScript), phpScript); |
164 | WebBrowser1.LoadHTML(RunPHPScript(phpScript), phpScript); |
155 | 165 | ||
Line 175... | Line 185... | ||
175 | var |
185 | var |
176 | myURL, myUrl2, getData: string; |
186 | myURL, myUrl2, getData: string; |
177 | p: integer; |
187 | p: integer; |
178 | background: boolean; |
188 | background: boolean; |
179 | ArgGet, ArgPost, ArgHeader: string; |
189 | ArgGet, ArgPost, ArgHeader: string; |
- | 190 | resourcestring |
|
- | 191 | SOnlyWorksInEditor = 'This action only works in FastPHP editor.'; |
|
180 | begin |
192 | begin |
181 | background := Pos('background|', URL) >= 1; |
193 | background := Pos('background|', URL) >= 1; // do not translate |
182 | 194 | ||
183 | {$REGION 'Line number references (PHP errors and warnings)'} |
195 | {$REGION 'Line number references (PHP errors and warnings)'} |
184 | if Copy(URL, 1, length(FASTPHP_GOTO_URI_PREFIX)) = FASTPHP_GOTO_URI_PREFIX then |
196 | if Copy(URL, 1, length(FASTPHP_GOTO_URI_PREFIX)) = FASTPHP_GOTO_URI_PREFIX then |
185 | begin |
197 | begin |
186 | // TODO: maybe we could even open that file in the editor! |
198 | // TODO: maybe we could even open that file in the editor! |
187 | ShowMessage('This action only works in FastPHP editor.'); |
199 | ShowMessage(SOnlyWorksInEditor); |
188 | Cancel := true; |
200 | Cancel := true; |
189 | Exit; |
201 | Exit; |
190 | end; |
202 | end; |
191 | {$ENDREGION} |
203 | {$ENDREGION} |
192 | 204 | ||
193 | {$REGION 'Intelligent browser (executes PHP scripts)'} |
205 | {$REGION 'Intelligent browser (executes PHP scripts)'} |
194 | if URL <> 'about:blank' then |
206 | if URL <> 'about:blank' then |
195 | begin |
207 | begin |
196 | myUrl := URL; |
208 | myUrl := URL; |
197 | 209 | ||
198 | myurl := StringReplace(myurl, 'background|', '', []); |
210 | myurl := StringReplace(myurl, 'background|', '', []); // do not translate |
199 | 211 | ||
200 | p := Pos('?', myUrl); |
212 | p := Pos('?', myUrl); |
201 | if p >= 1 then |
213 | if p >= 1 then |
202 | begin |
214 | begin |
203 | getData := copy(myURL, p+1, Length(myURL)-p); |
215 | getData := copy(myURL, p+1, Length(myURL)-p); |