You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

GetUrlScript.txt 1.8 KiB

4 年之前
4 年之前
4 年之前
4 年之前
4 年之前
12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576
  1. function dec2bin(x:integer):string;
  2. var s:string;
  3. begin
  4. s:='';
  5. repeat
  6. s:=chr($30 + x and 1) + s;
  7. x:=x shr 1;
  8. until x=0;
  9. result:=s;
  10. end;
  11. var binX,binY:string;
  12. i,posSRC,posDATE,posTYPE,posFirstAND,lenbinXY:integer;
  13. begin
  14. posFirstAND:=pos('&',GetUrlBase)-1;
  15. if posFirstAND<=0 then begin
  16. posFirstAND:=length(GetUrlBase);
  17. end;
  18. posSRC:=pos('&src=',GetUrlBase);
  19. posDATE:=pos('&date=',GetUrlBase);
  20. posTYPE:=pos('&type=',GetUrlBase);
  21. ResultURL:=copy(GetUrlBase,1,posFirstAND);
  22. if posSRC>0 then begin
  23. i:=posSRC+5;
  24. while (GetUrlBase[i]<>'&') do begin
  25. inc(i);
  26. if (i>length(GetUrlBase)) then break;
  27. end;
  28. ResultURL:=ResultURL+copy(GetUrlBase,posSRC+5,i-(posSRC+5));
  29. end;
  30. ResultURL:=ResultURL+'/'+inttostr(GetZ-1)+'/';
  31. if posDATE>0 then begin
  32. i:=posDATE+6;
  33. while (GetUrlBase[i]<>'&') do begin
  34. inc(i);
  35. if (i>length(GetUrlBase)) then break;
  36. end;
  37. if (i-(posDATE+6))>0 then begin
  38. ResultURL:=ResultURL+copy(GetUrlBase,posDATE+6,i-(posDATE+6))+'/';
  39. end;
  40. end;
  41. binX:=dec2bin(GetX);
  42. binY:=dec2bin(GetY);
  43. lenbinXY:=length(binX);
  44. for i:=1 to ((GetZ-1)-lenbinXY) do begin
  45. binX:='0'+binX;
  46. end;
  47. lenbinXY:=length(binY);
  48. for i:=1 to ((GetZ-1)-lenbinXY) do begin
  49. binY:='0'+binY;
  50. end;
  51. for i:=7 to GetZ-1 do begin
  52. ResultURL:=ResultURL+copy(binY,1,i-6)+'-'+copy(binX,1,i-6)+'/';
  53. end;
  54. ResultURL:=ResultURL+binY+'-'+binX;
  55. if posTYPE>0 then begin
  56. i:=posTYPE+6;
  57. while (GetUrlBase[i]<>'&') do begin
  58. inc(i);
  59. if (i>length(GetUrlBase)) then break;
  60. end;
  61. if (i-(posTYPE+6))>0 then begin
  62. ResultURL:=ResultURL+'.'+copy(GetUrlBase,posTYPE+6,i-(posTYPE+6));
  63. end;
  64. end else begin
  65. ResultURL:=ResultURL+'.jpg';
  66. end;
  67. end.