\82Ì\8fê\8d\87 stRef = 32, endRes = 50 \82É\82È\82é
}
procedure TGikoSys.GetPopupResNumber(URL : string; var stRes, endRes : Int64);
+const
+ START_NAME : array[0..1] of String = ('st=', 'start=');
+ END_NAME : array[0..1] of String = ('to=', 'end=');
+ RES_NAME : array[0..0] of String = ('res=');
var
buf : String;
convBuf : String;
ps : Int64;
pch : PChar;
+ bufList : TStringList;
+ i, j, idx : Integer;
begin
URL := Trim(LowerCase(URL));
- if (AnsiPos('&st=', URL ) <> 0) and ( AnsiPos( '&to=',URL) <> 0 ) then begin
- stRes := 0;
- endRes := 0;
- try
- buf := Copy( URL, AnsiPos('&st=', URL ) + 4, AnsiPos( '&to=',URL) - AnsiPos('&st=', URL ) - 4 );
- if buf <> '' then
- stRes := StrToInt64( buf );
- if AnsiPos( '&nofirst=',URL) <> 0 then begin
- buf := Copy( URL, AnsiPos('&to=', URL ) + 4, AnsiPos( '&nofirst=',URL) - AnsiPos('&to=', URL ) - 4);
- end else begin
- buf := Copy( URL, AnsiPos('&to=', URL ) + 4, Length( URL ) - AnsiPos('&to=', URL ) - 4 + 1 );
- ps := 0;
- pch := PChar(buf);
- while ( ps < Length(buf) )and ( pch[ps] >= '0' ) and ( pch[ps] <= '9' ) do Inc(ps);
- buf := Copy( buf, 1, ps );
- end;
- try
- if buf <> '' then
- endRes := StrToInt64(buf)
- except
- endRes := 0;
- end;
- except
- stRes := 0;
- end;
- if (stRes <> 0) and (endRes = 0) then
- endRes := stRes + MAX_POPUP_RES
- else if (stRes = 0) and (endRes <> 0) then begin
- stRes := endRes - MAX_POPUP_RES;
- if stRes < 1 then
- stRes := 1;
- end;
- GikoSys.GetBrowsableThreadURL( URL );
- end else if( AnsiPos('&res=', URL ) <> 0 ) then begin
- endRes := 0;
- buf := Copy( URL, AnsiPos('&res=', URL ) + 5, Length( URL ) - AnsiPos('&res=', URL ) - 5 + 1 );
- ps := 0;
- pch := PChar(buf);
- while ( ps < Length(buf) )and ( pch[ps] >= '0' ) and ( pch[ps] <= '9' ) do Inc(ps);
- buf := Copy( buf, 1, ps );
- try
- if buf <> '' then
- stRes := StrToInt(buf)
- else begin
- stRes := 0;
- end;
- except
- stRes := 0;
- end;
- end else if (AnsiPos('&start=', URL ) <> 0) and ( AnsiPos( '&end=',URL) <> 0 ) then begin
- try
- stRes := StrToInt64( Copy( URL, AnsiPos('&start=', URL ) + 7, AnsiPos( '&end=',URL) - AnsiPos('&start=', URL ) - 7 ) );
- if AnsiPos( '&nofirst=',URL) <> 0 then begin
- buf := Copy( URL, AnsiPos('&end=', URL ) + 5, AnsiPos( '&nofirst=',URL) - AnsiPos('&end=', URL ) - 5);
- end else begin
- buf := Copy( URL, AnsiPos('&end=', URL ) + 5, Length( URL ) - AnsiPos('&to=', URL ) - 5 + 1 );
- ps := 0;
- pch := PChar(buf);
- while ( ps < Length(buf) )and ( pch[ps] >= '0' ) and ( pch[ps] <= '9' ) do Inc(ps);
- buf := Copy( buf, 1, ps );
- end;
- try
- if buf <> '' then
- endRes := StrToInt64(buf);
- except
- endRes := 0;
- end;
- except
- stRes := 0;
- end;
- end else if ( AnsiPos('.html',URL) <> Length(URL) -4 ) and ( AnsiPos('.htm',URL) <> Length(URL) -3 ) then begin
+ idx := AnsiPos('?', URL);
+ if (idx <> 0) then begin
+ stRes := 0;
+ endRes := 0;
+ bufList := TStringList.Create();
+ try
+ bufList.Delimiter := '&';
+ bufList.DelimitedText := Copy(URL, idx + 1, Length(URL));
+ for i := 0 to bufList.Count - 1 do begin
+ convBuf := '';
+ // \8aJ\8en\83\8c\83X\94Ô\82Ì\8c\9f\8dõ
+ for j := 0 to Length(START_NAME) - 1 do begin
+ idx := AnsiPos(START_NAME[j], bufList[i]);
+ if (idx <> 0) then begin
+ convBuf := Copy(bufList[i], idx + Length(START_NAME[j]), Length(bufList[i]));
+ stRes := StrToInt64Def( convBuf, 0 );
+ break;
+ end;
+ end;
+ // \8fI\97¹\83\8c\83X\94Ô\82Ì\8c\9f\8dõ
+ if (convBuf = '') then begin
+ for j := 0 to Length(END_NAME) - 1 do begin
+ idx := AnsiPos(END_NAME[j], bufList[i]);
+ if (idx <> 0) then begin
+ convBuf := Copy(bufList[i], idx + Length(END_NAME[j]), Length(bufList[i]));
+ endRes := StrToInt64Def( convBuf, 0 );
+ break;
+ end;
+ end;
+ end;
+ // \83\8c\83X\94Ô\82Ì\8c\9f\8dõ
+ if ((stRes = 0) and (endRes = 0) and (convBuf = '')) then begin
+ for j := 0 to Length(RES_NAME) - 1 do begin
+ idx := AnsiPos(RES_NAME[j], bufList[i]);
+ if (idx <> 0) then begin
+ convBuf := Copy(bufList[i], idx + Length(RES_NAME[j]), Length(bufList[i]));
+ stRes := StrToInt64Def( convBuf, 0 );
+ endRes := stRes;
+ break;
+ end;
+ end;
+ end;
+ end;
+
+ if (stRes <> 0) and (endRes = 0) then begin
+ endRes := stRes + MAX_POPUP_RES;
+ end else if (stRes = 0) and (endRes <> 0) then begin
+ stRes := endRes - MAX_POPUP_RES;
+ if stRes < 1 then begin
+ stRes := 1;
+ end;
+ end;
+ finally
+ bufList.clear;
+ bufList.free;
+ end;
+ end else if ( AnsiPos('.html',URL) <> Length(URL) -4 ) and ( AnsiPos('.htm',URL) <> Length(URL) -3 ) then begin
buf := Copy(URL, LastDelimiter('/',URL)+1,Length(URL)-LastDelimiter('/',URL)+1);
if Length(buf) > 0 then begin
if AnsiPos('-', buf) = 1 then begin
ps := 0;
pch := PChar(buf);
while ( ps < Length(buf) )and ( pch[ps] >= '0' ) and ( pch[ps] <= '9' ) do Inc(ps);
- try
- convBuf := Copy( buf, 1, ps );
- if convBuf <> '' then
- endRes := StrToInt64(convBuf)
- else
- endRes := 0;
- except
- endRes := 0;
- end;
+ convBuf := Copy( buf, 1, ps );
+ if convBuf <> '' then begin
+ endRes := StrToInt64Def(convBuf, 0);
+ end;
if endRes <> 0 then begin
stRes := endRes - MAX_POPUP_RES;
if stRes < 1 then
ps := 0;
pch := PChar(buf);
while ( ps < Length(buf) )and ( pch[ps] >= '0' ) and ( pch[ps] <= '9' ) do Inc(ps);
- try
- convBuf := Copy( buf, 1, ps );
- if convBuf <> '' then
- endRes := StrToInt64(convBuf)
- else
- endRes := 0;
- except
- endRes := 0;
- end;
+ convBuf := Copy( buf, 1, ps );
+ if convBuf <> '' then begin
+ endRes := StrToInt64Def(convBuf, 0);
+ end;
end else begin
stRes := 0;
end;
end;
end;
end;
- end else begin
- //stRes := 0;
- //endRes := 0;
end;
end;