URI: 
       game.cgi - brcon2024-hackathons - Bitreichcon 2024 Hackathons
  HTML git clone git://bitreich.org/brcon2024-hackathons git://enlrupgkhuxnvlhsf6lc3fziv5h2hhfrinws65d7roiv6bfj7d652fid.onion/brcon2024-hackathons
   DIR Log
   DIR Files
   DIR Refs
   DIR Tags
   DIR Submodules
       ---
       game.cgi (2865B)
       ---
            1 #!/bin/sh
            2 if [ -z "${QUERY_STRING}" ];
            3 then
            4         printf "3Invalid Request\tErr\t%s\t%s\r\n" "${SERVER_NAME}" "${SERVER_PORT}"
            5         exit
            6 fi
            7 
            8 id="${QUERY_STRING#*:}"
            9 type="${QUERY_STRING%%:*}"
           10 
           11 {
           12         case "${type}" in 
           13         tuid )
           14                 curl -sgG \
           15                         --data-urlencode "id=${id}" \
           16                         --url "https://ifdb.org/viewgame?ifiction"
           17                 ;;
           18         ifid )
           19                 curl -sgG \
           20                         --data-urlencode "ifid=${id}" \
           21                         --url "https://ifdb.org/viewgame?ifiction"
           22                 ;;
           23         * )
           24                 printf "3Invalid Request\tErr\t%s\t%s\r\n" "${SERVER_NAME}" "${SERVER_PORT}"
           25                 exit 1
           26                 ;;
           27         esac
           28 } | \
           29 xml2tsv | \
           30 awk '
           31 function fold(s) {
           32         cmd = "fmt -w80"
           33         printf("%s", s) | cmd
           34         close(cmd);
           35 }
           36 BEGIN {
           37         FS = "\t";
           38 }
           39 $1 == "/viewgame/errorCode" {
           40         exit
           41 }
           42 $1 == "/ifindex/story/bibliographic/description/br" {
           43         bibliographic["description"] = bibliographic["description"] "\n\n";
           44 }
           45 index($1, "/ifindex/story/bibliographic/description") == 1 {
           46         bibliographic["description"] = bibliographic["description"] $2;
           47         next;
           48 }
           49 index($1, "/ifindex/story/bibliographic/") == 1 {
           50         bibliographic[substr($1, length("/ifindex/story/bibliographic/") + 1)] = $2;
           51         next;
           52 }
           53 index($1, "/ifindex/story/contact/") == 1 {
           54         contact[substr($1, length("/ifindex/story/contact/") + 1)] = $2;
           55         next;
           56 }
           57 $1 == "/ifindex/story/ifdb/downloads/links/link" {
           58         links["length"]++;
           59         next;
           60 }
           61 index($1, "/ifindex/story/ifdb/downloads/links/link/") == 1 {
           62         links[links["length"], substr($1, length("/ifindex/story/ifdb/downloads/links/link/") + 1)] = $2;
           63         next;
           64 }
           65 index($1, "/ifindex/story/ifdb/") == 1 {
           66         ifdb[substr($1, length("/ifindex/story/ifdb/") + 1)] = $2;
           67         next;
           68 }
           69 END {
           70         printf("%s\n", bibliographic["title"])
           71         printf("--------------------------------------------------------------------------------\n")
           72         fold(sprintf("Author(s): %s", bibliographic["author"]));
           73         if (bibliographic["genre"])
           74                 printf("Genre: %s\n", bibliographic["genre"]);
           75         if (bibliographic["language"])
           76                 printf("Language: %s\n", bibliographic["language"]);
           77         if (bibliographic["firstpublished"])
           78                 printf("First Publication Date: %s\n", bibliographic["firstpublished"]);
           79         if (bibliographic["forgiveness"])
           80                 printf("Forgiveness Rating: %s\n", bibliographic["forgiveness"]);
           81         if (contact["url"])
           82                 printf("Website: %s\n", contact["url"]);
           83 
           84         if (ifdb["ratingCountAvg"])
           85                 printf("Rating: %s stars (based on %s rating%s)\n", ifdb["starRating"], ifdb["ratingCountAvg"], ifdb["ratingCountAvg"] > 1 ? "s" : "");
           86 
           87         if (bibliographic["description"]) {
           88                 printf("\nDescription:\n");
           89                 fold(bibliographic["description"])
           90         }
           91 
           92         if (links["length"]) {
           93                 printf("\nDownloads:\n");
           94                 for (i = 1; i <= links["length"]; i++) {
           95                         printf("%s\n", links[i, "title"]);
           96                         printf("\t%s\n", links[i, "url"]);
           97                         if (match(links[i, "url"], /^https?:\/\/(www\.)?ifarchive\.org\/if-archive\//))
           98                                 printf("\t%s\n", "gopher://gopher.661.org/9/if-archive/" substr(links[i, "url"], RSTART + RLENGTH));
           99                         printf("\n");
          100                 }
          101         }
          102 }'