📄 servercontroller.pas
字号:
P:real;
n,n1,n2,P1,P2:integer;
S:String;
begin
P:=RecNo/RowLimit;
P1:=Trunc(P);
if Frac(P)>0 then Inc(P1);
P:=RecordCount/RowLimit;
P2:=Trunc(P);
if Frac(P)>0 then Inc(P2);
Result:=' ';
if P1>1 then
begin
Result:=Result+
GetLinkStringEx(GridID,'0_1','<font face="Webdings" title="首页">9</font>','',Grid)+
GetLinkStringEx(GridID,'0_2','<font face="Webdings" title="上一页">7</font>','',Grid)+'%S';
end else
begin
Result:=Result+'<font face="Webdings" color=gray title="首页">9</font>'+
'<font face="Webdings" color=gray title="上一页">7</font>%S';
end;
if P1<>P2 then
begin
Result:=Result+
GetLinkStringEx(GridID,'0_3','<font face="Webdings" title="下一页">8</font>','',Grid)+
GetLinkStringEx(GridID,'0_4','<font face="Webdings" title="尾页">:</font>','',Grid);
end else
begin
Result:=Result+'<font face="Webdings" color=gray title="下一页">8</font>'+
'<font face="Webdings" color=gray title="尾页">:</font>';
end;
n1:=P1-5;
if n1<1 then n1:=1;
n2:=P1+5+ABS(P1-5-n1)-1;
if n2>P2 then n2:=P2;
s:=' ';
for n:=n1 to n2 do
begin
if n=p1 then
s:=s+format('<font color=red><b>%D</b></font> ',[n]) else
s:=S+GetLinkStringEx(GridID,'1_'+IntToStr(n),inttostr(n),'',Grid)+' ';
end;
Result:=format(Result,[s]);
Result:=Result+ format(' 共<b>%D</b>部电影 每页<b>%D</b>部电影 共<b>%D</b>页 ',
[RecordCount,RowLimit,P2]);
end;
function PictureString(IPath,ISize:string):string;
begin
Result:='';
if ISize='small' then
begin
Result:='<IMG height=85 src="'+IPath+'" width=85 border=0>';
exit;
end;
if ISize='med' then
Result:='<IMG height=150 src="'+IPath+'" width=110 border=0>'
else
Result:='<IMG height=500 src="'+IPath+'" width=520 border=0>';
end;
function ShowForm(AFormName:String):boolean;
type
TIWFormClass = class of TIWForm;
var
LForm : TIWForm;
begin
Result:=True;
if WebApplication.FindComponent(AFormName) <> nil then
begin
WebApplication.SetActiveForm(WebApplication.FindComponent(AFormName) as TIWContainer);
//(WebApplication.FindComponent(AFormName) as TIWContainer).Show;
end else begin
try
LForm := TIWFormClass(FindClass('T' + AFormName)).Create(WebApplication);
WebApplication.SetActiveForm(LForm);
//LForm.Show;
except
Result := false;
end;
end;
end;
function GetLinkString(Row,ID:string;Link:String;Cof:String='';GridName:String='ComGrid'):String;
begin
Result:=Format('<a href="#none" onclick="return SubmitClickConfirm(''%S'',''%s_%s'', true, ''%S'');">%S</a>',
[GridName,Row,ID,Cof,Link
]); //GetLinkString('0',t,temp) temp超级连接的内容
end; // 0
// t,传送到数据表格处理的数据
function GetLinkStringEx(Row:integer;ID,Link:String;Cof:String='';GridName:String='ComGrid'):String;
begin
Result:=Format('<a href="#none" onclick="return SubmitClickConfirm(''%S'',''%D_%S'', true, ''%S'');">%S</a>',
[GridName,Row,ID,Cof,Link
]);
end;
function GetSpace(Count:integer):String;
var
n:integer;
begin
Result:='';
for n:=0 to Count do Result:=Result+' ';
end;
function HotFilms(IQuery:TADOQuery;ICount:Integer=14):string;
var
Temp:TStringList;
i:Integer;
begin
Result:='';
temp:=TStringList.Create;
IQuery.Close;
IQuery.SQL.Clear;
IQuery.SQL.Add('select articleid,title from Movie ORDER BY Movie.hits DESC');
IQuery.Open;
if IQuery.RecordCount<ICount then ICount:=IQuery.RecordCount;
try
for i:=1 to Icount do begin
Temp.Clear;
temp.LoadFromFile(WebApplication.ApplicationPath+'\files\Skin\'+GSkin+'\HotFilm.Html');
temp.Text:=StringReplace(temp.Text,'Film',GetLinkString('0',IQuery.fieldByname('title').AsString,GetSpace(2)+IQuery.fieldByname('title').AsString),[rfReplaceAll]);
IQuery.Next;
Result:=Result+Temp.text;
end;
except
Result:=Temp.text;
end;
Temp.Free;
end;
function NewFilms(IQuery:TADOQuery;ICount:Integer=6):string;
var
Temp:TStringList;
i:Integer;
Pic:string;
begin
Result:='';
temp:=TStringList.Create;
IQuery.Close;
IQuery.SQL.Clear;
IQuery.SQL.Add('select * from Movie where IsDate(Movie.dateandtime) ORDER BY datevalue(Movie.dateandtime) DESC');
IQuery.Open;
try
if IQuery.RecordCount<ICount then ICount:=IQuery.RecordCount;
for i:=1 to Icount do begin
Temp.Clear;
temp.LoadFromFile(WebApplication.ApplicationPath+'\files\Skin\'+GSkin+'\NewFilm.Html');
Pic:=pictureString(IQuery.fieldbyname('url').AsString,'small');
temp.Text:=StringReplace(temp.Text,'Picture',GetLinkString('0',IQuery.FieldByname('title').AsString,pic),[rfReplaceAll]);
temp.Text:=StringReplace(temp.Text,'Film',GetLinkString('0',IQuery.fieldByname('title').AsString,IQuery.fieldByname('title').AsString),[rfReplaceAll]);
temp.Text:=StringReplace(temp.Text,'Author',IQuery.fieldByname('name').AsString,[rfReplaceAll]);
temp.Text:=StringReplace(temp.Text,'Type',IQuery.FieldByname('TypeID').AsString,[rfReplaceAll]);
temp.Text:=StringReplace(temp.Text,'Search',GetLinkString('0',IQuery.FieldByname('title').AsString,'查看详情->>'),[rfReplaceAll]);
IQuery.Next;
Result:=Result+Temp.text;
end;
except
Result:=Temp.text;
end;
Temp.Free;
end;
function PlayFilms(IQuery:TADOQuery;Search:string;PlayFilmNum:Integer=0):string;
var
Temp:TStringList;
i,j:Integer;
PlayFilm,Download,FilmNumLink,PlayNumUrl:string;
MovieList:TADOQuery;
begin
Result:='';
temp:=TStringList.Create;
IQuery.Close;
IQuery.SQL.Clear;
IQuery.SQL.Add('select * from Movie where title ='+QuotedStr(Search));
IQuery.Open;
IQuery.Edit; //添加单击次数
IQuery.FieldByName('hits').AsInteger:= IQuery.FieldByName('hits').AsInteger+1;
IQuery.Post;
try
begin
Temp.Clear;
temp.LoadFromFile(WebApplication.ApplicationPath+'\files\Skin\'+GSkin+'\PlayFilm.Html');
///////////////////////////////////////////////////////////////////////////////
if IQuery.FieldByName('IsFilmNum').AsBoolean = True then begin //生成播放集数
MovieList:=TADOQuery.Create(WebApplication);
MovieList.Connection:=con1;
MovieList.SQL.Add('select * from MovieList where title='+QuotedStr(IQuery.fieldByname('title').AsString)+' ORDER BY FilmNum');
MovieList.Open;
i:=-1;
j:=2;
while not MovieList.Eof do begin
Inc(i);
if (i= 6) or (i=12) or(i=18) or(i=24) or(i=30) or(i=36) or(i=42) then
FilmNumLink:=FilmNumLink+'<p></p>'+GetSpace(2)+GetLinkString('0',MovieList.fieldByname('FilmNum').AsString,'第'+MovieList.fieldByname('FilmNum').AsString+'集')+GetSpace(2)
else begin
if i=10 then j:=1;
FilmNumLink:=FilmNumLink+GetSpace(2)+GetLinkString('0',MovieList.fieldByname('FilmNum').AsString,'第'+MovieList.fieldByname('FilmNum').AsString+'集')+GetSpace(j);
end;
MovieList.Next;
end;
FilmNumLink:=FilmNumLink+'<p></p>';
/////////////////////////////////////////////////////////////////////////////////
with MovieList do begin //得到用户传来的播放集数.并获取超连接
Locate('title;FilmNum',VarArrayOf([IQuery.fieldByname('title').AsString,PlayFilmNum]),[]);
{Close;
SQL.Clear;
SQL.Add('select * from MovieList where title='+QuotedStr(IQuery.fieldByname('title').AsString)+' and FilmNum='+inttostr(PlayFilmNum));
Open; }
PlayNumUrl:= FieldByName('playurl').AsString; //是播放连续剧
end;
end;//if
if Trim(UpperCase(IQuery.fieldbyname('movietype').AsString)) ='AVI' then begin
if PlayNumUrl<>'' then begin
PlayFilm:=PlayAvi(PlayNumUrl);// 是播放连续剧 //电影类型判断以区分以何种播放器播放电影
PlayFilm:=PlayFilm+'<p>'+FilmNumLink+'</p>';
end
else begin
PlayFilm:=PlayAvi(IQuery.fieldbyname('domurl').AsString);
PlayFilm:=PlayFilm+'<p>'+FilmNumLink+'</p>';
end;
end
else
begin
if PlayNumUrl<>'' then begin //RM
PlayFilm:=PlayRM(PlayNumUrl);// 是播放连续剧
PlayFilm:=PlayFilm+GetSpace(28)+'<a href="javascript:setFull()" >【全屏】</a>';
PlayFilm:=PlayFilm+'<p>'+FilmNumLink+'</p>';
end
else begin
PlayFilm:=PlayRM(IQuery.fieldbyname('domurl').AsString);
PlayFilm:=PlayFilm+GetSpace(28)+'<a href="javascript:setFull()" >【全屏】</a>';
PlayFilm:=PlayFilm+'<p>'+FilmNumLink+'</p>';
end;
end;
temp.Text:=StringReplace(temp.Text,'PlayFilm',PlayFilm,[rfReplaceAll]);
temp.Text:=StringReplace(temp.Text,'title',IQuery.fieldByname('title').AsString,[rfReplaceAll]);
temp.Text:=StringReplace(temp.Text,'author',IQuery.fieldByname('name').AsString,[rfReplaceAll]);
temp.Text:=StringReplace(temp.Text,'type',IQuery.fieldByname('TypeId').AsString,[rfReplaceAll]);
temp.Text:=StringReplace(temp.Text,'where',IQuery.FieldByname('where').AsString,[rfReplaceAll]);
temp.Text:=StringReplace(temp.Text,'howlong',IQuery.FieldByname('howlong').AsString,[rfReplaceAll]);
temp.Text:=StringReplace(temp.Text,'hit',IQuery.FieldByname('hits').AsString,[rfReplaceAll]);
temp.Text:=StringReplace(temp.Text,'datetime',IQuery.FieldByname('dateandtime').AsString,[rfReplaceAll]);
temp.Text:=StringReplace(temp.Text,'memo',IQuery.FieldByname('content').AsString,[rfReplaceAll]);
// if IQuery.FieldByname('candown').AsString ='1' then
Download:='本站暂不提供下载!';
temp.Text:=StringReplace(temp.Text,'download',Download,[rfReplaceAll]);
Result:=Temp.text;
end;
except
Result:=Temp.text;
end;
movielist.free;
Temp.Free;
end;
function IWServerController: TIWServerController;
begin
Result := TIWServerController(GServerController);
end;
function UserSession: TIWUserSession;
begin
Result := TIWUserSession(WebApplication.Data);
end;
procedure TIWServerController.IWServerControllerBaseNewSession(
ASession: TIWApplication; var VMainForm: TIWBaseForm);
begin
ASession.Data := TIWUserSession.Create(nil);
with UserSession do begin
SKIN:=ASession.Request.CookieFields.Values['Skin']; //载入旧风格
if (SKIN='') or (not DirectoryExists(ASession.ApplicationPath+'Files\Skin\'+Skin)) then SKIN:='1'; //设置默认风格
GSkin:=Skin;
end;
end;
procedure TIWServerController.IWServerControllerBaseBackButton(
ASubmittedSequence, ACurrentSequence: Integer; AFormName: String;
var VHandled, VExecute: Boolean);
const
DefaultFormName = 'MainForm';
type
TIWFormClass = class of TIWForm;
var
LForm : TIWForm;
begin
VHandled := True;
VExecute := true;
if AFormName = '' then
AFormName := DefaultFormName;
if WebApplication.FindComponent(AFormName) <> nil then
begin
WebApplication.SetActiveForm(WebApplication.FindComponent(AFormName) as
TIWContainer);
end else begin
try
LForm := TIWFormClass(FindClass('T' + AFormName)).Create(WebApplication);
WebApplication.SetActiveForm(LForm);
except
VHandled := false;
end;
end;
end;
procedure TIWServerController.IWServerControllerBaseCreate(
Sender: TObject);
var
VLIst:TStringList;
begin
if not FileExists(GServerController.AppPath+'files\FilmSystem.ini') then
begin
VLIst:=TStringList.Create;
with VList do begin
Values['Port']:= '8080';
Values['New']:= '4';
Values['Hot']:= '14';
Values['effect']:='false';
end;
VLIst.SaveToFile(GServerController.AppPath+'files\FilmSystem.ini');
VLIst.Free;
end;
VLIst:=TStringList.Create;
VLIst.LoadFromFile(GServerController.AppPath+'files\FilmSystem.ini');
Self.Port:=StrToInt(iif(VLIst.ValueFromIndex[0],'8080'));
VLIst.Free;
//全局数据连接
con1:=TADOConnection.Create(Self);
con1.ConnectionString:= 'Provider=Microsoft.Jet.OLEDB.4.0;Data Source='+GServerController.AppPath+'\database\imovie.mdb;Persist Security Info=False';
con1.Open;
end;
procedure TIWServerController.IWServerControllerBaseDestroy(
Sender: TObject);
begin
con1.Free;
end;
initialization
TIWServerController.SetServerControllerClass;
end.
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -