Collection of themes/skins for the Fossil SCM

⌈⌋ ⎇ branch:  Fossil Skins Extra


Hex Artifact Content

Artifact e6bf384ff3ee6e029dd5e88b690be582cfec9cd1:

  • Executable file extroot/cat — part of check-in [0e67fdb36b] at 2021-10-20 05:59:00 on branch trunk — support for #access: flag (user: mario size: 1005)

0000: 23 21 2f 75 73 72 2f 62 69 6e 2f 70 68 70 2d 63  #!/usr/bin/php-c
0010: 67 69 20 2d 64 63 67 69 2e 66 6f 72 63 65 5f 72  gi -dcgi.force_r
0020: 65 64 69 72 65 63 74 3d 30 0a 3c 3f 70 68 70 0a  edirect=0.<?php.
0030: 23 20 65 6e 63 6f 64 69 6e 67 3a 20 75 74 66 2d  # encoding: utf-
0040: 38 0a 23 20 61 70 69 3a 20 63 67 69 0a 23 20 74  8.# api: cgi.# t
0050: 79 70 65 3a 20 6f 75 74 70 75 74 0a 23 20 63 61  ype: output.# ca
0060: 74 65 67 6f 72 79 3a 20 61 63 63 65 73 73 0a 23  tegory: access.#
0070: 20 74 69 74 6c 65 3a 20 43 61 74 20 66 69 6c 65   title: Cat file
0080: 0a 23 20 64 65 73 63 72 69 70 74 69 6f 6e 3a 20  .# description: 
0090: 4c 6f 6f 6b 20 75 70 20 66 69 6c 65 6e 61 6d 65  Look up filename
00a0: 20 61 6e 64 20 72 65 64 69 72 65 63 74 20 74 6f   and redirect to
00b0: 20 2f 72 61 77 2f 55 55 49 44 0a 23 20 76 65 72   /raw/UUID.# ver
00c0: 73 69 6f 6e 3a 20 30 2e 31 0a 23 20 73 74 61 74  sion: 0.1.# stat
00d0: 65 3a 20 62 65 74 61 0a 23 20 64 65 70 65 6e 64  e: beta.# depend
00e0: 73 3a 20 70 68 70 3a 73 71 6c 69 74 65 0a 23 20  s: php:sqlite.# 
00f0: 63 6f 6e 66 69 67 3a 20 2d 0a 23 20 61 63 63 65  config: -.# acce
0100: 73 73 3a 20 70 75 62 6c 69 63 0a 23 0a 23 20 44  ss: public.#.# D
0110: 6f 65 73 20 61 6e 20 69 6e 64 69 72 65 63 74 20  oes an indirect 
0120: 6c 6f 6f 6b 75 70 20 62 79 20 66 69 6c 65 6e 61  lookup by filena
0130: 6d 65 2c 0a 23 20 74 68 65 6e 20 72 65 64 69 72  me,.# then redir
0140: 65 63 74 73 20 74 6f 20 74 68 65 20 2f 72 61 77  ects to the /raw
0150: 2f 55 55 49 44 20 64 6f 77 6e 6c 6f 61 64 2e 0a  /UUID download..
0160: 23 0a 23 20 65 2e 67 2e 0a 23 20 20 20 20 68 74  #.# e.g..#    ht
0170: 74 70 3a 2f 2f 66 6f 73 73 69 6c 2f 65 78 74 2f  tp://fossil/ext/
0180: 72 61 77 2f 52 45 41 44 4d 45 2e 6d 64 0a 23 0a  raw/README.md.#.
0190: 23 20 57 69 6c 6c 20 61 6c 77 61 79 73 20 6c 6f  # Will always lo
01a0: 6f 6b 75 70 20 74 68 65 20 74 72 75 6e 6b 2f 74  okup the trunk/t
01b0: 69 70 20 75 75 69 64 2e 0a 23 0a 0a 0a 23 2d 2d  ip uuid..#...#--
01c0: 20 69 6e 69 74 0a 69 6e 63 6c 75 64 65 28 22 2e   init.include(".
01d0: 2f 66 6f 73 73 69 6c 5f 63 6f 6d 6d 6f 6e 2e 70  /fossil_common.p
01e0: 68 70 22 29 3b 0a 24 66 6e 20 3d 20 6c 74 72 69  hp");.$fn = ltri
01f0: 6d 28 24 5f 53 45 52 56 45 52 5b 22 50 41 54 48  m($_SERVER["PATH
0200: 5f 49 4e 46 4f 22 5d 2c 20 22 2f 22 29 3b 0a 23  _INFO"], "/");.#
0210: 70 72 69 6e 74 5f 72 28 24 5f 53 45 52 56 45 52  print_r($_SERVER
0220: 29 3b 0a 0a 0a 23 2d 2d 20 66 69 6e 64 20 75 75  );...#-- find uu
0230: 69 64 0a 69 66 20 28 65 6d 70 74 79 28 24 66 6e  id.if (empty($fn
0240: 29 29 20 7b 0a 20 20 20 20 64 69 65 28 22 41 63  )) {.    die("Ac
0250: 63 65 73 73 20 61 73 20 2f 65 78 74 2f 63 61 74  cess as /ext/cat
0260: 2f 66 6e 2e 74 78 74 22 29 3b 0a 7d 0a 24 72 20  /fn.txt");.}.$r 
0270: 3d 20 64 62 28 0a 20 20 20 20 22 53 45 4c 45 43  = db(.    "SELEC
0280: 54 20 75 75 69 64 0a 20 20 20 20 20 46 52 4f 4d  T uuid.     FROM
0290: 20 62 6c 6f 62 20 4c 45 46 54 20 4a 4f 49 4e 20   blob LEFT JOIN 
02a0: 6d 6c 69 6e 6b 20 4f 4e 20 62 6c 6f 62 2e 72 69  mlink ON blob.ri
02b0: 64 3d 6d 6c 69 6e 6b 2e 66 69 64 0a 20 20 20 20  d=mlink.fid.    
02c0: 20 20 20 20 20 20 20 20 20 20 20 4c 45 46 54 20             LEFT 
02d0: 4a 4f 49 4e 20 66 69 6c 65 6e 61 6d 65 20 4f 4e  JOIN filename ON
02e0: 20 6d 6c 69 6e 6b 2e 66 6e 69 64 3d 66 69 6c 65   mlink.fnid=file
02f0: 6e 61 6d 65 2e 66 6e 69 64 0a 20 20 20 20 20 57  name.fnid.     W
0300: 48 45 52 45 20 6e 61 6d 65 20 3d 20 3f 0a 20 20  HERE name = ?.  
0310: 20 20 20 4f 52 44 45 52 20 42 59 20 72 69 64 20     ORDER BY rid 
0320: 44 45 53 43 20 4c 49 4d 49 54 20 31 22 2c 0a 20  DESC LIMIT 1",. 
0330: 20 20 20 5b 24 66 6e 5d 0a 29 3b 0a 69 66 20 28     [$fn].);.if (
0340: 24 72 20 61 6e 64 20 24 75 75 69 64 20 3d 20 24  $r and $uuid = $
0350: 72 5b 30 5d 5b 22 75 75 69 64 22 5d 29 20 7b 0a  r[0]["uuid"]) {.
0360: 20 20 20 20 24 66 6e 20 3d 20 62 61 73 65 6e 61      $fn = basena
0370: 6d 65 28 24 66 6e 29 3b 0a 20 20 20 20 68 65 61  me($fn);.    hea
0380: 64 65 72 28 22 4c 6f 63 61 74 69 6f 6e 3a 20 24  der("Location: $
0390: 5f 53 45 52 56 45 52 5b 46 4f 53 53 49 4c 5f 55  _SERVER[FOSSIL_U
03a0: 52 49 5d 2f 72 61 77 2f 24 75 75 69 64 3f 61 74  RI]/raw/$uuid?at
03b0: 3d 24 66 6e 22 29 3b 0a 7d 0a 65 6c 73 65 20 7b  =$fn");.}.else {
03c0: 0a 20 20 20 20 68 65 61 64 65 72 28 22 53 74 61  .    header("Sta
03d0: 74 75 73 3a 20 34 30 34 20 4e 6f 74 20 66 6f 75  tus: 404 Not fou
03e0: 6e 64 22 29 3b 0a 7d 0a 0a 20 20 20 20           nd");.}..