view dbdefs.inc.php @ 1120:b2bca5f6d0ff default tip

Cosmetic cleanup: remove trailing whitespace.
author Matti Hamalainen <ccr@tnsp.org>
date Sun, 13 Dec 2020 13:47:13 +0200
parents 24e6915fc0fb
children
line wrap: on
line source

<?php

$dbVersion = 31;

//
// Define sizes of database fields, see createdb.php
// and also the places where input is validated.
//
define("SQL_LEN_USERNAME", 32);
define("SQL_LEN_GROUPS", 64);
define("SQL_LEN_ONELINER", 64);
define("SQL_LEN_EMAIL", 80);
define("SQL_LEN_REGHOST", 128);

define("SQL_LEN_NEWS_TITLE", 128);
define("SQL_LEN_NEWS_TEXT", 4096);
define("SQL_LEN_NEWS_AUTHOR", 64);

define("SQL_LEN_COMPO_NAME", 128);
define("SQL_LEN_COMPO_DESC", 4096);
define("SQL_LEN_COMPO_NOTES", 4096);
define("SQL_LEN_COMPO_PATH", 128);

define("SQL_LEN_ENTRY_NAME", 64);
define("SQL_LEN_ENTRY_AUTHOR", 64);
define("SQL_LEN_ENTRY_FILENAME", 128);
define("SQL_LEN_ENTRY_INFO", 50*4);
define("SQL_LEN_ENTRY_NOTES", 1024);
define("SQL_LEN_ENTRY_PREVIEW_FILE", 128);

define("SQL_LEN_DISP_SLIDE_TITLE", 64);
define("SQL_LEN_DISP_SLIDE_TEXT", 4096);
define("SQL_LEN_ROT_LIST_NAME", 128);

define("SQL_LEN_USERKEY", 64);


//
// Site settings and defaults we put in
//
$siteSettingsGroups = [
  "general"   => ["General", "General settings"],
  "news"      => ["News", "News related settings"],
  "event"     => ["Event / Schedule", "Event and schedule related settings"],
  "compos"    => ["Compos", "Compo related settings"],
];


$siteDefaultSettings = [

  //
  // General site settings
  //
  "general" => [
    "maxAttendeesHard" => [VT_INT, 60, "Maximum attendees (HARD limit, <= 0 means no limit)"],
    "maxAttendeesSoft" => [VT_INT, 50, "Maximum attendees (soft limit, <= 0 means no limit)"],

    "userTimeout"      => [VT_INT, 120, "User pages (voting) timeout in minutes"],
    "admTimeout"       => [VT_INT, 15, "Administration interface timeout in minutes"],

    "showAdmin"        => [VT_BOOL, FALSE, "Always show administration interface link on the menu"],
    "showAttendees"    => [VT_BOOL, TRUE, "Show attendees list"],

    "showResults"      => [VT_BOOL, FALSE, "Enable results page"],

    "showInfoTextOnAbout" => [VT_BOOL, FALSE, "Show site info HTML on About page"],

    "requireEMail"     => [VT_BOOL, FALSE, "Require e-mail address in registrations"],
    "allowRegister"    => [VT_BOOL, FALSE, "Enable event registration"],

    "allowVoting"      => [VT_BOOL, FALSE, "Enable voting (individual compos must be enabled as well)"],
  ],

  //
  // News related
  //
  "news" => [
    "showNews"         => [VT_BOOL, TRUE, "Enable News link on main menu + News page"],
    "showNewsOnAbout"  => [VT_BOOL, TRUE, "Show latest news item on About page"],

    "msgNewsHeader"    => [VT_TEXT, "
<h1>The FAPper's news outlet</h1>
", "News page header blob"],
  ],

  //
  // Event / schedule information
  //
  "event" => [
    "showSchedule"     => [VT_BOOL, TRUE, "Enable Schedule link on main menu + Schedule page"],

    "msgEventDescription" => [VT_TEXT, "
<h1>Event program &amp; schedule</h1>
<ul>
 <li><b>Aegis</b> of DSS and FAG will be performing a DJ gig.</li>
 <li>.. and possible additional live acts. More info to come.</li>
</ul>

<h2>Friday 30.11.</h2>
<ul>
 <li><b>18:00</b> - <i>Doors open</i>.</li>
 <li><b>22:00</b> - DJ set by Aegis.</li>
</ul>

<h2>Saturday 1.12.</h2>
<ul>
 <li><b>14:00</b> - Deadline for remote entries.</li>
 <li><b>18:00</b> - Deadline for the entries delivered on location.</li>
 <li><b>20:00</b> - Competitions start.</li>
</ul>

Competition schedule and voting deadline will depend on number of entries.

<h2>Sunday 2.12.</h2>
<ul>
 <li><b>12:00</b> - Party over?</li>
</ul>
", "Event general description / timetables etc."],

  ],

  //
  // Competitions
  //
  "compos" => [
    "showCompos"       => [VT_BOOL, TRUE, "Enable Compos link on main menu + Compos page"],

    "msgCompoDescription" => [VT_TEXT, "
<h1>General</h1>
<p class=\"notice\">
YOU <b>MUST</b> HAVE AT LEAST ONE ENTRY TO COMPETITIONS IF YOU COME TO THE PARTY.
</p>

<p class=\"note\">
If there are enough entries, then AGA/OCS/ECS demos will be run in separate compos.
<br />
Remote entries are welcome!
</p>

<p>
The compo machine will be an <b>A1200 with an 060/50 and lots of
RAM</b>. An <b>A500 1.3 512k/512k</b> will also be available if your
prod is not AGA compatible.
</p>

<h1>Compos</h1>
", "Compo general description"],
  ],

];


//
// Database table definitions
//
$sqlTables = [
  // Site settings
  "settings_groups" => [
    ["id"           , "INTEGER", "PRIMARY KEY", "AUTOINCREMENT"],
    ["name"         , "VARCHAR(64)"],
    ["description"  , "VARCHAR(128)"],
  ],

  "settings" => [
    ["key"          , "VARCHAR(32)", "PRIMARY KEY"],
    ["vtype"        , "INT"],
    ["vstr"         , "VARCHAR(128)"],
    ["vtext"        , "TEXT"],
    ["vint"         , "INT"],
    ["sdesc"        , "VARCHAR(128)"],
    ["vgroup"       , "INT"],
  ],

  "news" => [
    ["id"           , "INTEGER", "PRIMARY KEY", "AUTOINCREMENT"],
    ["utime"        , "INT"],
    ["title"        , "VARCHAR(".SQL_LEN_NEWS_TITLE.")"],
    ["text"         , "VARCHAR(".SQL_LEN_NEWS_TEXT.")"],
    ["author"       , "VARCHAR(".SQL_LEN_NEWS_AUTHOR.")"],
    ["persist"      , "INT", "DEFAULT 0"],
  ],

  "compos" => [
    ["id"           , "INTEGER", "PRIMARY KEY", "AUTOINCREMENT"],
    ["name"         , "VARCHAR(".SQL_LEN_COMPO_NAME.")"],
    ["description"  , "VARCHAR(".SQL_LEN_COMPO_DESC.")"],
    ["notes"        , "VARCHAR(".SQL_LEN_COMPO_NOTES.")"],
    ["visible"      , "INT", "DEFAULT 0"],
    ["voting"       , "INT", "DEFAULT 0"],

    // Default preview type (see EFILE_* in msite.inc.php) for this compo.
    // Global for the compo (entry-specific overrides if it is != EFILE_NONE)
    ["preview_type" , "INT", "DEFAULT 0"],

    ["show_authors" , "INT", "DEFAULT 0"],
    // Show author(s) on compo main screen/voting page for COMPO_NORMAL compos
    // For COMPO_POINTS and COMPO_ASSIGN, show on results page or not

    ["ctype"        , "INT", "DEFAULT 0"],
    ["cpath"        , "VARCHAR(".SQL_LEN_COMPO_PATH.")"],
  ],

  "entries" => [
    ["id"           , "INTEGER", "PRIMARY KEY", "AUTOINCREMENT"],
    ["show_id"      , "INT", "DEFAULT 0"],
    ["name"         , "VARCHAR(".SQL_LEN_ENTRY_NAME.")"],
    ["author"       , "VARCHAR(".SQL_LEN_ENTRY_AUTHOR.")"],
    ["compo_id"     , "INT", "DEFAULT 0"],
    ["info"         , "VARCHAR(".SQL_LEN_ENTRY_INFO.")", "DEFAULT NULL"],
    ["notes"        , "VARCHAR(".SQL_LEN_ENTRY_NOTES.")", "DEFAULT NULL"],
    ["flags"        , "INT", "DEFAULT 0"],
    ["evalue"       , "INT", "DEFAULT 0"],
    ["file_id"      , "INT", "DEFAULT 0"], // uploaded file id from "files" table
    ["preview_id"   , "INT", "DEFAULT 0"], // uploaded preview file id from "files" table
    ["preview_type" , "INT", "DEFAULT 0"], // see EFILE_*, overrides compo's general type if != 0
    ["utime"        , "INT", "DEFAULT 0"],
    ["owner_id"     , "INT", "DEFAULT 0"], // 0 = admin, otherwise userkey id
  ],

  "files" => [
    ["id"           , "INTEGER", "PRIMARY KEY", "AUTOINCREMENT"],
    ["filename"     , "VARCHAR(".SQL_LEN_ENTRY_FILENAME.")", "DEFAULT NULL"], // stored filename
    ["origname"     , "VARCHAR(".SQL_LEN_ENTRY_FILENAME.")", "DEFAULT NULL"], // original uploaded filename
    ["filetype"     , "VARCHAR(32)", "DEFAULT NULL"], // type of the file, if any, as key from $fileTypeData
    ["uploadtype"   , "VARCHAR(32)", "DEFAULT NULL"], // "preview", "entry"
    ["filesize"     , "INT", "DEFAULT 0"], // uploaded size
    ["entry_id"     , "INT", "DEFAULT 0"], // belongs to this entry (0 = none)
    ["uploader_id"  , "INT", "DEFAULT 0"], // 0 = admin, otherwise userkey id
    ["deleted"      , "INT", "DEFAULT 0"], // 1 = to be deleted
    ["utime"        , "INT", "DEFAULT 0"],
  ],

  "attendees" => [
    ["id"           , "INTEGER", "PRIMARY KEY", "AUTOINCREMENT"],
    ["regtime"      , "INT"],
    ["name"         , "VARCHAR(".SQL_LEN_USERNAME.")"],
    ["groups"       , "VARCHAR(".SQL_LEN_GROUPS.")"],
    ["oneliner"     , "VARCHAR(".SQL_LEN_ONELINER.")"],
    ["email"        , "VARCHAR(".SQL_LEN_EMAIL.")"],
    ["reghost"      , "VARCHAR(".SQL_LEN_REGHOST.")", "DEFAULT NULL"],
    ["key_id"       , "INT", "DEFAULT NULL"],
    ["usr_flags"    , "INT", "DEFAULT 0"],
    ["adm_flags"    , "INT", "DEFAULT 0"],
  ],

  "userkeys" => [
    ["id"           , "INTEGER", "PRIMARY KEY", "AUTOINCREMENT"],
    ["key"          , "VARCHAR(".SQL_LEN_USERKEY.")"],
    ["active"       , "INT", "DEFAULT 0"],
  ],

  "votes" => [
    ["id"           , "INTEGER", "PRIMARY KEY", "AUTOINCREMENT"],
    ["entry_id"     , "INT", "DEFAULT NULL"],
    ["key_id"       , "INT", "DEFAULT 0"],
    ["value"        , "INT", "DEFAULT 0"],
    ["utime"        , "INT", "DEFAULT 0"],
  ],


  // Party information system tables
  "display_vars" => [
    ["key"          , "VARCHAR(32)", "PRIMARY KEY"],
    ["vtype"        , "INT"],
    ["vstr"         , "VARCHAR(128)"],
    ["vtext"        , "TEXT"],
    ["vint"         , "INT"],
    ["sdesc"        , "VARCHAR(128)"],
  ],

  "display_slides" => [
    ["id"           , "INTEGER", "PRIMARY KEY", "AUTOINCREMENT"],
    ["title"        , "VARCHAR(".SQL_LEN_DISP_SLIDE_TITLE.")"],
    ["text"         , "VARCHAR(".SQL_LEN_DISP_SLIDE_TEXT.")"],
  ],

  "rot_list_data" => [
    ["id"           , "INTEGER", "PRIMARY KEY", "AUTOINCREMENT"],
    ["name"         , "VARCHAR(".SQL_LEN_ROT_LIST_NAME.")"],
  ],

  "rot_list_slides" => [
    ["id"           , "INTEGER", "PRIMARY KEY", "AUTOINCREMENT"],
    ["list_id"      , "INT", "DEFAULT 0"],
    ["slide_id"     , "INT", "DEFAULT 0"],
    ["order_num"    , "INT", "DEFAULT 0"],
  ],
];


//
// Party information system settings / data
//
$siteDisplayVars = [
  "showMode"          => [VT_INT, 0, "Currently active display mode"],
  "rotateDuration"    => [VT_INT, 15, "Slide rotation time per slide (seconds)"],

  "tempDuration"      => [VT_INT, 5, "Temporary slide display time (minutes)"],
  "tempSlide"         => [VT_INT, 0, "Temporary slide ID"],

  "compoID"           => [VT_INT, 0, "Compo ID of current compo"],
  "compoPrevEntry"    => [VT_INT, 0, "Previously shown compo entry"],
  "compoCurrEntry"    => [VT_INT, 0, "Current / next compo entry to be shown"],

  // Not user-manageable
  "tempSlideSet"      => [VT_BOOL, FALSE, "Temporary slide set"],

  "activeSlideMode"   => [VT_INT, 0, "Current active slide display mode"],
  "activeSlide"       => [VT_INT, 0, "Current active slide"],
  "activeSlideExpire" => [VT_INT, 0, "Expiration timestamp of current slide"],

  "rotateList"        => [VT_INT, 0, "Current rotation list ID"],
  "rotateListIndex"   => [VT_INT, 0, "Current index in rotation list"],

  "lastUpdate"        => [VT_INT, 0, "Timestamp of last slide update"],

  "screenCmd"         => [VT_STR, "", "Off-channel showscreen command"],
  "screenCmdSet"      => [VT_BOOL, FALSE, "Off-channel showscreen command has been set"],
];


//
// Some premade test data
//
$siteTestData = [
  "news" => [
    "utime,title,text,author",
    time().",%s,%s,%s",
    ["Today's news", "We. Are. Back.", "orgaz"],
    ["Good news, everybody!", "...", "The Professor"],
  ],

  "userkeys" => [
    "key",
    "%s",
    ["test1"],
    ["test2"],
    ["test1"],
    ["test2"],
  ],

  "attendees" => [
    "regtime,name,groups,oneliner,email",
    "%d,%s,%s,%s,%s",
    [time()-0, "man with no alias", "supergroup", "foo-bar", "c@supergroup.com"],
    [time()-15, "man with alias", "supergroup", "hi!", "c@supergroup.com"],
    [time()-30, "alias with a man", "supergroup", "mega super kewl rulets", "x@microsoft.com"],
  ],

  "compos" => [
    "name,description,visible,voting",
    "%s,%s,1,1",
    ["Graphics", "Anything in standard resolutions."],
    ["Protracker music", "Standard 4-channel Protracker MOD music."],
    ["4k intro", "4k intro competition"],
  ],

  "entries" => [
    "name,author,compo_id,filename,info",
    "%s,%s,%d,%s,%s",
    ["Donkey Dong", "electric/extend", 1, "donkey.lbm", "amigaaaah!"],
    ["Your kondom", "ccr/TNSP", 1, "kondom.lbm", "oh my god, it's full of cocks!"],
    ["Penis song", "reed/flt", 2, "penis.mod", "laulu rakkaudelle"],
    ["jenkka", "aegis", 2, "jenkka.mod", ""],
    ["Fungiform 2", "mfx", 3, "mfx-fungiform2.lzh", "OCS-only"],
  ],

  "display_slides" => [
    "title,text",
    "%s,%s",
    ["Next Up 4k", "<h1>Next up: 4k intro</h1><h2>4k intro compo is about to begin</h2>... in about 10 minutes."],
    ["Astu to infodesk", "<b>Astu</b> - please come to info desk!"],
    ["Gentle Eye mainos", "<b>Buy Amiga stuff!</b><br />Gentle Eye Oy is selling Amiga-related stuff near organizer desk!"],
  ],

  "rot_list_data" => [
    "name",
    "%s",
    ["Main rotation"],
    ["Next Up"],
  ],

  "rot_list_slides" => [
    "list_id,slide_id",
    "%d,%d",
    [1,2],
    [1,3],
    [2,1],
  ],
];


$upgradeMappings = [
//  "" => ["key" => "", value => ""],
  12 => [
    "show_authors" => ["key" => "showAuthors"],
    "display_vars" => ["table" => "displayVars"],
    "display_slides" => ["table" => "displaySlides"],
    "rot_list_data" => ["table" => "rotationListData"],
    "rot_list_slides" => ["table" => "rotationListSlides"],
  ],

  14 => [
    "settings_groups" => ["table" => FALSE],
  ],

  17 => [
    "ctype" => ["key" => "type"],
    "cpath" => ["key" => "path"],
  ],

  31 => [
    "userkeys" => ["table" => "votekeys"],
    "msgEventDescription" => ["key" => "eventDescription"],
    "msgCompoDescription" => ["key" => "compoDescription"],
  ],
];

?>