Collection of themes/skins for the Fossil SCM

⌈⌋ ⎇ branch:  Fossil Skins Extra


Hex Artifact Content

Artifact 9973677f508d218eef397b10f0664c0ca1dde937:

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

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 61 70 69 0a 23 20 63 61 74 65 67  ype: api.# categ
0060: 6f 72 79 3a 20 74 69 63 6b 65 74 73 0a 23 20 74  ory: tickets.# t
0070: 69 74 6c 65 3a 20 43 72 61 73 68 72 65 70 6f 72  itle: Crashrepor
0080: 74 0a 23 20 64 65 73 63 72 69 70 74 69 6f 6e 3a  t.# description:
0090: 20 52 65 63 65 69 76 65 73 20 65 72 72 6f 72 73   Receives errors
00a0: 20 28 4a 53 4f 4e 20 50 4f 53 54 29 20 61 6e 64   (JSON POST) and
00b0: 20 66 69 6c 65 73 20 74 68 65 6d 20 61 73 20 74   files them as t
00c0: 69 63 6b 65 74 73 0a 23 20 76 65 72 73 69 6f 6e  ickets.# version
00d0: 3a 20 30 2e 31 0a 23 20 73 74 61 74 65 3a 20 61  : 0.1.# state: a
00e0: 6c 70 68 61 0a 23 20 63 6f 6e 66 69 67 3a 20 2d  lpha.# config: -
00f0: 0a 23 20 61 63 63 65 73 73 3a 20 70 75 62 6c 69  .# access: publi
0100: 63 0a 23 0a 23 20 43 72 65 61 74 65 73 20 61 20  c.#.# Creates a 
0110: 74 69 63 6b 65 74 20 66 6f 72 20 61 6e 79 20 50  ticket for any P
0120: 4f 53 54 20 69 74 20 72 65 63 65 69 76 65 73 20  OST it receives 
0130: 74 68 61 74 20 63 6f 6e 74 61 69 6e 73 20 76 61  that contains va
0140: 6c 69 64 20 4a 53 4f 4e 2e 0a 23 20 55 6e 70 61  lid JSON..# Unpa
0150: 63 6b 73 20 73 6f 6d 65 20 66 69 65 6c 64 73 20  cks some fields 
0160: 69 6e 74 6f 20 74 69 63 6b 65 74 20 70 72 6f 70  into ticket prop
0170: 65 72 74 69 65 73 2c 20 61 6e 64 20 70 6f 73 74  erties, and post
0180: 73 20 74 68 65 20 77 68 6f 6c 65 20 62 6c 6f 62  s the whole blob
0190: 0a 23 20 61 73 20 74 69 63 6b 65 74 20 63 6f 6d  .# as ticket com
01a0: 6d 65 6e 74 2e 20 54 68 69 73 20 69 73 20 70 72  ment. This is pr
01b0: 6f 62 61 62 6c 79 20 6d 6f 72 65 20 73 75 69 74  obably more suit
01c0: 61 62 6c 65 20 66 6f 72 20 47 55 49 20 61 70 70  able for GUI app
01d0: 73 20 74 68 61 6e 0a 23 20 73 6d 61 6c 6c 65 72  s than.# smaller
01e0: 20 63 6f 6e 73 6f 6c 65 20 74 6f 6f 6c 73 20 6f   console tools o
01f0: 72 20 6c 69 62 72 61 72 69 6b 65 73 2e 0a 23 20  r librarikes..# 
0200: 41 6e 64 20 69 74 20 63 6f 75 6c 64 20 70 72 6f  And it could pro
0210: 62 61 62 6c 79 20 61 6c 73 6f 20 62 65 20 72 65  bably also be re
0220: 75 73 65 64 20 66 6f 72 20 73 74 6f 72 69 6e 67  used for storing
0230: 20 66 65 61 74 75 72 65 20 72 65 71 75 65 73 74   feature request
0240: 73 2e 0a 23 0a 23 20 4e 6f 77 20 74 68 69 73 20  s..#.# Now this 
0250: 68 61 73 20 73 6f 6d 65 20 70 72 69 76 61 63 79  has some privacy
0260: 20 69 6d 70 6c 69 63 61 74 69 6f 6e 73 2e 20 53   implications. S
0270: 6f 20 63 61 72 65 20 73 68 6f 75 6c 64 20 62 65  o care should be
0280: 20 74 61 6b 65 6e 20 77 68 69 63 68 0a 23 20 69   taken which.# i
0290: 6e 66 6f 72 6d 61 74 69 6f 6e 20 69 73 20 69 6e  nformation is in
02a0: 63 6c 75 64 65 64 2c 20 74 68 65 20 66 69 6c 74  cluded, the filt
02b0: 65 72 20 6f 70 74 69 6f 6e 73 20 65 78 70 61 6e  er options expan
02c0: 64 65 64 2c 20 6f 72 20 70 65 72 68 61 70 73 20  ded, or perhaps 
02d0: 65 76 65 6e 0a 23 20 74 68 65 20 74 69 63 6b 65  even.# the ticke
02e0: 74 20 62 61 63 6b 65 6e 64 20 74 61 6b 65 6e 20  t backend taken 
02f0: 6e 6f 6e 2d 70 75 62 6c 69 63 2e 0a 23 0a 23 20  non-public..#.# 
0300: 42 61 73 69 63 20 75 73 61 67 65 20 63 6f 75 6c  Basic usage coul
0310: 64 20 62 65 20 73 6f 6d 65 74 68 69 6e 67 20 6c  d be something l
0320: 69 6b 65 3a 0a 23 0a 23 20 20 20 20 63 61 74 63  ike:.#.#    catc
0330: 68 20 45 78 63 65 70 74 69 6f 6e 20 61 73 20 65  h Exception as e
0340: 3a 0a 23 20 20 20 20 20 20 20 20 69 6d 70 6f 72  :.#        impor
0350: 74 20 72 65 71 75 65 73 74 73 2c 20 74 72 61 63  t requests, trac
0360: 65 62 61 63 6b 2c 20 6a 73 6f 6e 0a 23 20 20 20  eback, json.#   
0370: 20 20 20 20 20 72 65 71 75 65 73 74 73 2e 70 6f       requests.po
0380: 73 74 28 22 68 74 74 70 3a 2f 2f 66 6f 73 73 69  st("http://fossi
0390: 6c 2e 65 78 61 6d 70 6c 65 2e 63 6f 6d 2f 72 65  l.example.com/re
03a0: 70 6f 2f 65 78 74 2f 63 72 61 73 68 72 65 70 6f  po/ext/crashrepo
03b0: 72 74 22 2c 20 64 61 74 61 3d 6a 73 6f 6e 2e 64  rt", data=json.d
03c0: 75 6d 70 73 28 7b 0a 23 20 20 20 20 20 20 20 20  umps({.#        
03d0: 20 20 20 20 22 76 65 72 73 69 6f 6e 22 3a 20 22      "version": "
03e0: 30 2e 30 2e 31 22 2c 0a 23 20 20 20 20 20 20 20  0.0.1",.#       
03f0: 20 20 20 20 20 22 66 69 6c 65 22 3a 20 5f 5f 66       "file": __f
0400: 69 6c 65 5f 5f 2c 0a 23 20 20 20 20 20 20 20 20  ile__,.#        
0410: 20 20 20 20 22 65 72 72 6f 72 22 3a 20 73 74 72      "error": str
0420: 28 65 29 2c 0a 23 20 20 20 20 20 20 20 20 20 20  (e),.#          
0430: 20 20 22 65 78 63 65 70 74 69 6f 6e 22 3a 20 72    "exception": r
0440: 65 70 72 28 65 29 2c 0a 23 20 20 20 20 20 20 20  epr(e),.#       
0450: 20 20 20 20 20 22 62 61 63 6b 74 72 61 63 65 22       "backtrace"
0460: 3a 20 74 72 61 63 65 62 61 63 6b 2e 65 78 74 72  : traceback.extr
0470: 61 63 74 5f 74 62 2c 0a 23 20 20 20 20 20 20 20  act_tb,.#       
0480: 20 20 20 20 20 22 6c 6f 63 61 6c 73 22 3a 20 6c       "locals": l
0490: 6f 63 61 6c 73 28 29 2c 0a 23 20 20 20 20 20 20  ocals(),.#      
04a0: 20 20 7d 2c 20 64 65 66 61 75 6c 74 3d 6c 61 6d    }, default=lam
04b0: 62 64 61 20 76 3a 20 72 65 70 72 28 76 29 29 29  bda v: repr(v)))
04c0: 0a 23 0a 23 20 4f 62 76 69 6f 75 73 6c 79 20 79  .#.# Obviously y
04d0: 6f 75 20 6d 69 67 68 74 20 77 61 6e 74 20 74 6f  ou might want to
04e0: 20 77 72 61 70 20 74 68 69 73 20 69 6e 20 73 6f   wrap this in so
04f0: 6d 65 20 67 65 6e 65 72 61 6c 20 72 65 70 6f 72  me general repor
0500: 74 69 6e 67 20 63 61 6c 6c 2e 0a 23 20 41 6e 64  ting call..# And
0510: 20 63 65 72 74 61 69 6e 6c 79 20 63 75 73 74 6f   certainly custo
0520: 6d 69 7a 65 20 74 68 65 20 6d 61 70 70 69 6e 67  mize the mapping
0530: 20 66 6f 72 20 61 63 74 75 61 6c 6c 79 20 75 73   for actually us
0540: 65 64 20 66 69 65 6c 64 73 2e 0a 0a 0a 23 2d 2d  ed fields....#--
0550: 20 63 6f 6e 66 69 67 0a 0a 23 20 72 65 71 75 69   config..# requi
0560: 72 65 20 74 68 61 74 20 50 4f 53 54 20 70 61 79  re that POST pay
0570: 6c 6f 61 64 20 63 6f 6e 74 61 69 6e 73 20 61 74  load contains at
0580: 20 6c 65 61 73 74 20 6f 6e 65 20 6f 66 20 74 68   least one of th
0590: 6f 73 65 20 66 69 65 6c 64 73 20 28 74 6f 20 61  ose fields (to a
05a0: 76 65 72 74 20 61 72 62 69 74 72 61 72 79 20 73  vert arbitrary s
05b0: 70 61 6d 62 6f 74 73 20 66 69 6c 69 6e 67 20 74  pambots filing t
05c0: 69 63 6b 65 74 73 29 0a 24 72 65 71 75 69 72 65  ickets).$require
05d0: 64 5f 66 69 65 6c 64 73 20 3d 20 5b 0a 20 20 20  d_fields = [.   
05e0: 20 22 76 65 72 73 69 6f 6e 22 2c 0a 20 20 20 20   "version",.    
05f0: 22 65 72 72 6f 72 22 2c 0a 20 20 20 20 22 65 78  "error",.    "ex
0600: 63 65 70 74 69 6f 6e 22 2c 0a 5d 3b 0a 23 20 63  ception",.];.# c
0610: 6f 6e 74 61 69 6e 65 64 20 66 69 65 6c 64 73 20  ontained fields 
0620: 6f 6e 74 6f 20 74 69 63 6b 65 74 20 70 72 6f 70  onto ticket prop
0630: 65 72 74 69 65 73 0a 24 6d 61 70 5f 66 69 65 6c  erties.$map_fiel
0640: 64 73 20 3d 20 5b 0a 20 20 20 20 22 65 72 72 6f  ds = [.    "erro
0650: 72 22 20 3d 3e 20 22 74 69 74 6c 65 22 2c 0a 20  r" => "title",. 
0660: 20 20 20 22 76 65 72 73 69 6f 6e 22 20 3d 3e 20     "version" => 
0670: 22 66 6f 75 6e 64 69 6e 22 2c 0a 20 20 20 20 22  "foundin",.    "
0680: 6d 6f 64 75 6c 65 22 20 3d 3e 20 22 73 75 62 73  module" => "subs
0690: 79 73 74 65 6d 22 2c 0a 5d 3b 0a 23 20 74 69 63  ystem",.];.# tic
06a0: 6b 65 74 20 64 65 66 61 75 6c 74 73 0a 24 64 65  ket defaults.$de
06b0: 66 61 75 6c 74 5f 66 69 65 6c 64 73 20 3d 20 5b  fault_fields = [
06c0: 0a 20 20 20 23 22 63 6f 6d 6d 65 6e 74 22 20 3d  .   #"comment" =
06d0: 3e 20 22 4a 53 4f 4e 22 2c 0a 20 20 20 23 22 66  > "JSON",.   #"f
06e0: 6f 75 6e 64 69 6e 22 20 3d 3e 20 22 30 2e 30 2e  oundin" => "0.0.
06f0: 31 22 2c 0a 20 20 20 23 22 69 63 6f 6d 6d 65 6e  1",.   #"icommen
0700: 74 22 20 3d 3e 20 22 22 2e 0a 20 20 20 23 22 6c  t" => ""..   #"l
0710: 6f 67 69 6e 22 20 3d 3e 20 22 65 78 74 72 6f 6f  ogin" => "extroo
0720: 74 22 2c 0a 20 20 20 22 6d 69 6d 65 74 79 70 65  t",.   "mimetype
0730: 22 20 3d 3e 20 22 74 65 78 74 2f 6a 73 6f 6e 22  " => "text/json"
0740: 2c 0a 20 20 20 22 70 72 69 76 61 74 65 5f 63 6f  ,.   "private_co
0750: 6e 74 61 63 74 22 20 3d 3e 20 22 22 2c 0a 20 20  ntact" => "",.  
0760: 20 22 74 79 70 65 22 20 3d 3e 20 22 49 6e 63 69   "type" => "Inci
0770: 64 65 6e 74 22 2c 0a 20 20 20 22 73 74 61 74 75  dent",.   "statu
0780: 73 22 20 3d 3e 20 22 4f 70 65 6e 22 2c 0a 20 20  s" => "Open",.  
0790: 20 22 73 65 76 65 72 69 74 79 22 20 3d 3e 20 22   "severity" => "
07a0: 4d 65 64 69 75 6d 22 2c 0a 20 20 20 22 70 72 69  Medium",.   "pri
07b0: 6f 72 69 74 79 22 20 3d 3e 20 22 4d 65 64 69 75  ority" => "Mediu
07c0: 6d 22 2c 0a 20 20 20 23 22 72 65 73 6f 6c 75 74  m",.   #"resolut
07d0: 69 6f 6e 22 20 3d 3e 20 22 22 2c 0a 20 20 20 22  ion" => "",.   "
07e0: 73 75 62 73 79 73 74 65 6d 22 20 3d 3e 20 22 63  subsystem" => "c
07f0: 6f 72 65 22 2c 0a 20 20 20 22 74 69 74 6c 65 22  ore",.   "title"
0800: 20 3d 3e 20 22 43 72 61 73 68 72 65 70 6f 72 74   => "Crashreport
0810: 22 2c 0a 20 20 20 22 75 73 65 72 6e 61 6d 65 22  ",.   "username"
0820: 20 3d 3e 20 22 63 72 61 73 68 72 65 70 6f 72 74   => "crashreport
0830: 22 2c 0a 5d 3b 0a 23 20 72 65 77 72 69 74 65 20  ",.];.# rewrite 
0840: 74 65 78 74 20 63 6f 6e 74 65 6e 74 73 20 69 6e  text contents in
0850: 20 61 6e 79 20 66 69 65 6c 64 20 28 73 6f 6d 65   any field (some
0860: 20 70 72 69 76 61 63 79 20 66 69 6c 74 65 72 69   privacy filteri
0870: 6e 67 29 0a 24 66 69 6c 74 65 72 5f 63 6f 6e 74  ng).$filter_cont
0880: 65 6e 74 20 3d 20 5b 0a 20 20 20 20 22 7e 2f 68  ent = [.    "~/h
0890: 6f 6d 65 2f 5b 5c 77 5c 2d 5c 2e 5d 2b 2f 7e 22  ome/[\w\-\.]+/~"
08a0: 20 3d 3e 20 22 2f 68 6f 6d 65 2f 75 73 65 72 2f   => "/home/user/
08b0: 22 2c 20 23 20 61 76 6f 69 64 20 75 73 65 72 20  ", # avoid user 
08c0: 6e 61 6d 65 73 0a 20 20 20 20 22 7e 5b 5e 5c 5c  names.    "~[^\\
08d0: 74 5c 5c 72 5c 5c 6e 5c 5c 78 32 30 2d 5c 5c 78  t\\r\\n\\x20-\\x
08e0: 46 46 5d 2f 7e 22 20 3d 3e 20 22 23 22 2c 20 20  FF]/~" => "#",  
08f0: 20 23 20 6e 6f 20 63 6f 6e 74 72 6f 6c 20 63 68   # no control ch
0900: 61 72 73 0a 5d 3b 0a 0a 0a 23 2d 2d 20 69 6e 69  ars.];...#-- ini
0910: 74 0a 69 66 20 28 24 5f 53 45 52 56 45 52 5b 22  t.if ($_SERVER["
0920: 43 4f 4e 54 45 4e 54 5f 4c 45 4e 47 54 48 22 5d  CONTENT_LENGTH"]
0930: 20 3e 3d 20 31 30 29 20 7b 0a 20 20 20 20 24 6a   >= 10) {.    $j
0940: 73 6f 6e 20 3d 20 66 72 6f 6d 5f 69 6e 70 75 74  son = from_input
0950: 28 29 3b 0a 20 20 20 20 69 66 20 28 21 61 72 72  ();.    if (!arr
0960: 61 79 5f 69 6e 74 65 72 73 65 63 74 28 61 72 72  ay_intersect(arr
0970: 61 79 5f 6b 65 79 73 28 24 6a 73 6f 6e 29 2c 20  ay_keys($json), 
0980: 24 72 65 71 75 69 72 65 64 5f 66 69 65 6c 64 73  $required_fields
0990: 29 29 20 7b 0a 20 20 20 20 20 20 20 20 64 69 65  )) {.        die
09a0: 28 6a 73 6f 6e 5f 65 6e 63 6f 64 65 28 5b 22 65  (json_encode(["e
09b0: 72 72 6f 72 22 20 3d 3e 20 22 72 65 71 75 69 72  rror" => "requir
09c0: 65 64 20 66 69 65 6c 64 73 20 6d 69 73 73 69 6e  ed fields missin
09d0: 67 22 5d 29 29 3b 0a 20 20 20 20 7d 0a 20 20 20  g"]));.    }.   
09e0: 20 73 74 6f 72 65 28 24 6a 73 6f 6e 29 3b 0a 7d   store($json);.}
09f0: 0a 65 6c 73 65 20 7b 0a 20 20 20 20 68 65 61 64  .else {.    head
0a00: 65 72 28 22 43 6f 6e 74 65 6e 74 2d 54 79 70 65  er("Content-Type
0a10: 3a 20 74 65 78 74 2f 78 2d 6d 61 72 6b 64 6f 77  : text/x-markdow
0a20: 6e 22 29 3b 0a 20 20 20 20 64 69 65 28 22 53 61  n");.    die("Sa
0a30: 76 65 20 61 6e 79 20 73 74 61 63 6b 74 72 61 63  ve any stacktrac
0a40: 65 73 2f 65 72 72 6f 72 73 2f 65 74 63 2e 20 61  es/errors/etc. a
0a50: 73 20 74 69 63 6b 65 74 73 2c 20 69 66 20 73 65  s tickets, if se
0a60: 6e 74 20 61 73 20 4a 53 4f 4e 20 62 6c 6f 62 20  nt as JSON blob 
0a70: 70 65 72 20 50 4f 53 54 2e 22 29 3b 0a 7d 0a 0a  per POST.");.}..
0a80: 0a 23 20 61 73 73 75 6d 65 20 69 6e 70 75 74 20  .# assume input 
0a90: 69 73 20 4a 53 4f 4e 0a 66 75 6e 63 74 69 6f 6e  is JSON.function
0aa0: 20 66 72 6f 6d 5f 69 6e 70 75 74 28 29 20 7b 0a   from_input() {.
0ab0: 20 20 20 20 72 65 74 75 72 6e 20 6a 73 6f 6e 5f      return json_
0ac0: 64 65 63 6f 64 65 28 66 69 6c 65 5f 67 65 74 5f  decode(file_get_
0ad0: 63 6f 6e 74 65 6e 74 73 28 22 70 68 70 3a 2f 2f  contents("php://
0ae0: 69 6e 70 75 74 22 29 2c 20 54 72 75 65 29 3b 0a  input"), True);.
0af0: 7d 0a 0a 23 20 73 74 6f 72 65 20 61 73 20 74 69  }..# store as ti
0b00: 63 6b 65 74 0a 66 75 6e 63 74 69 6f 6e 20 73 74  cket.function st
0b10: 6f 72 65 28 24 64 61 74 61 29 20 7b 0a 20 20 20  ore($data) {.   
0b20: 20 67 6c 6f 62 61 6c 20 24 6d 61 70 5f 66 69 65   global $map_fie
0b30: 6c 64 73 2c 20 24 64 65 66 61 75 6c 74 5f 66 69  lds, $default_fi
0b40: 65 6c 64 73 2c 20 24 66 69 6c 74 65 72 5f 63 6f  elds, $filter_co
0b50: 6e 74 65 6e 74 3b 0a 0a 20 20 20 20 23 2d 2d 20  ntent;..    #-- 
0b60: 70 72 65 70 61 72 65 20 66 69 65 6c 64 73 0a 20  prepare fields. 
0b70: 20 20 20 24 66 69 65 6c 64 73 20 3d 20 24 64 65     $fields = $de
0b80: 66 61 75 6c 74 5f 66 69 65 6c 64 73 3b 0a 20 20  fault_fields;.  
0b90: 20 20 24 66 69 65 6c 64 73 5b 22 63 6f 6d 6d 65    $fields["comme
0ba0: 6e 74 22 5d 20 3d 20 6a 73 6f 6e 5f 65 6e 63 6f  nt"] = json_enco
0bb0: 64 65 28 24 64 61 74 61 2c 20 4a 53 4f 4e 5f 50  de($data, JSON_P
0bc0: 52 45 54 54 59 5f 50 52 49 4e 54 7c 4a 53 4f 4e  RETTY_PRINT|JSON
0bd0: 5f 55 4e 45 53 43 41 50 45 44 5f 53 4c 41 53 48  _UNESCAPED_SLASH
0be0: 45 53 7c 4a 53 4f 4e 5f 55 4e 45 53 43 41 50 45  ES|JSON_UNESCAPE
0bf0: 44 5f 55 4e 49 43 4f 44 45 29 3b 0a 20 20 20 20  D_UNICODE);.    
0c00: 23 2d 2d 20 65 78 74 72 61 20 66 69 65 6c 64 73  #-- extra fields
0c10: 0a 20 20 20 20 66 6f 72 65 61 63 68 20 28 24 6d  .    foreach ($m
0c20: 61 70 5f 66 69 65 6c 64 73 20 61 73 20 24 66 72  ap_fields as $fr
0c30: 6f 6d 3d 3e 24 74 6f 29 20 7b 0a 20 20 20 20 20  om=>$to) {.     
0c40: 20 20 20 69 66 20 28 69 73 73 65 74 28 24 64 61     if (isset($da
0c50: 74 61 5b 24 66 72 6f 6d 5d 29 29 20 7b 0a 20 20  ta[$from])) {.  
0c60: 20 20 20 20 20 20 20 20 20 20 24 66 69 65 6c 64            $field
0c70: 73 5b 24 74 6f 5d 20 3d 20 73 75 62 73 74 72 28  s[$to] = substr(
0c80: 24 64 61 74 61 5b 24 66 72 6f 6d 5d 2c 20 30 2c  $data[$from], 0,
0c90: 20 31 30 30 29 3b 0a 20 20 20 20 20 20 20 20 7d   100);.        }
0ca0: 0a 20 20 20 20 7d 0a 0a 20 20 20 20 23 2d 2d 20  .    }..    #-- 
0cb0: 61 73 73 65 6d 62 6c 65 20 63 6d 64 0a 20 20 20  assemble cmd.   
0cc0: 20 24 63 6d 64 20 3d 20 22 66 6f 73 73 69 6c 20   $cmd = "fossil 
0cd0: 2d 2d 6e 6f 63 67 69 20 2d 52 20 7b 24 71 28 24  --nocgi -R {$q($
0ce0: 5f 53 45 52 56 45 52 5b 27 46 4f 53 53 49 4c 5f  _SERVER['FOSSIL_
0cf0: 52 45 50 4f 53 49 54 4f 52 59 27 5d 29 7d 20 74  REPOSITORY'])} t
0d00: 69 63 6b 65 74 20 61 64 64 22 3b 0a 20 20 20 20  icket add";.    
0d10: 24 71 20 3d 20 27 65 73 63 61 70 65 73 68 65 6c  $q = 'escapeshel
0d20: 6c 61 72 67 27 3b 0a 20 20 20 20 66 6f 72 65 61  larg';.    forea
0d30: 63 68 20 28 24 66 69 65 6c 64 73 20 61 73 20 24  ch ($fields as $
0d40: 6e 61 6d 65 3d 3e 24 76 61 6c 75 65 29 20 7b 0a  name=>$value) {.
0d50: 20 20 20 20 20 20 20 20 66 6f 72 65 61 63 68 20          foreach 
0d60: 28 24 66 69 6c 74 65 72 5f 63 6f 6e 74 65 6e 74  ($filter_content
0d70: 20 61 73 20 24 72 78 3d 3e 24 74 6f 29 20 7b 0a   as $rx=>$to) {.
0d80: 20 20 20 20 20 20 20 20 20 20 20 20 24 76 61 6c              $val
0d90: 75 65 20 3d 20 70 72 65 67 5f 72 65 70 6c 61 63  ue = preg_replac
0da0: 65 28 24 72 78 2c 20 24 74 6f 2c 20 24 76 61 6c  e($rx, $to, $val
0db0: 75 65 29 3b 0a 20 20 20 20 20 20 20 20 7d 0a 20  ue);.        }. 
0dc0: 20 20 20 20 20 20 20 24 63 6d 64 20 2e 3d 20 22         $cmd .= "
0dd0: 20 7b 24 71 28 24 6e 61 6d 65 29 7d 20 7b 24 71   {$q($name)} {$q
0de0: 28 24 76 61 6c 75 65 29 7d 22 3b 0a 20 20 20 20  ($value)}";.    
0df0: 7d 0a 0a 20 20 20 20 23 2d 2d 20 72 75 6e 0a 20  }..    #-- run. 
0e00: 20 20 20 65 78 65 63 28 24 63 6d 64 2c 20 24 73     exec($cmd, $s
0e10: 74 64 6f 75 74 2c 20 24 65 72 72 6e 6f 29 3b 0a  tdout, $errno);.
0e20: 0a 20 20 20 20 23 2d 2d 20 4a 53 4f 4e 20 72 65  .    #-- JSON re
0e30: 73 70 6f 6e 73 65 0a 20 20 20 20 69 66 20 28 21  sponse.    if (!
0e40: 24 65 72 72 6e 6f 29 20 7b 0a 20 20 20 20 20 20  $errno) {.      
0e50: 20 20 64 69 65 28 6a 73 6f 6e 5f 65 6e 63 6f 64    die(json_encod
0e60: 65 28 5b 22 65 72 72 6f 72 22 20 3d 3e 20 24 73  e(["error" => $s
0e70: 74 64 6f 75 74 2c 20 22 65 72 72 6e 6f 22 20 3d  tdout, "errno" =
0e80: 3e 20 24 65 72 72 6e 6f 5d 29 29 3b 0a 20 20 20  > $errno]));.   
0e90: 20 7d 0a 20 20 20 20 65 6c 73 65 20 7b 0a 20 20   }.    else {.  
0ea0: 20 20 20 20 20 20 64 69 65 28 6a 73 6f 6e 5f 65        die(json_e
0eb0: 6e 63 6f 64 65 28 5b 22 73 75 63 63 65 73 73 22  ncode(["success"
0ec0: 20 3d 3e 20 24 73 74 64 6f 75 74 2c 20 22 65 72   => $stdout, "er
0ed0: 72 6e 6f 22 20 3d 3e 20 24 65 72 72 6e 6f 5d 29  rno" => $errno])
0ee0: 29 3b 0a 20 20 20 20 7d 0a 7d 0a 0a              );.    }.}..