Mercurial > hg > fapweb
view showajax.php @ 1074:48e16e856646
Use long tags.
author | Matti Hamalainen <ccr@tnsp.org> |
---|---|
date | Tue, 24 Jan 2017 17:57:38 +0200 |
parents | 7da8bde9b7be |
children | 0a2117349f46 |
line wrap: on
line source
<?php // // FAPWeb - Simple Web-based Demoparty Management System // Party information display system AJAX backend module // (C) Copyright 2012-2017 Tecnic Software productions (TNSP) // require_once "mconfig.inc.php"; require_once "msite.inc.php"; function stPrintCompoEntry($entry, $class, $compo, $title = false) { echo " <div class=\"".$class."\">\n"; if ($title !== false) echo " <div class=\"entryTitle\">".$title."</div>\n"; echo " <div class=\"entryIndex\">#".$entry["show_id"]."</div>\n". " <div class=\"entryName\">".chentities($entry["name"])."</div>\n"; if ($compo["show_authors"]) { if ($title === false) echo " <div class=\"entryBy\">by</div>\n"; echo " <div class=\"entryAuthor\">".chentities($entry["author"])."</div>\n"; } if ($title === false) echo " <div class=\"entryInfo\">".stConvertCommonDesc($entry["info"], TRUE)."</div>\n"; echo " </div>\n"; } function stPrintCompoSlide($compo, $entry, $prev) { echo " <div class=\"compoHeader\">\n". " <div class=\"compoHeaderDiv\"></div>\n". " <div class=\"compoTitle\">".chentities($compo["name"])." competition</div>\n". " </div>\n"; if ($entry === false && $prev === false) echo "<div class=\"compoStarting\">... Is about to start ...</div>"; if ($entry !== false) stPrintCompoEntry($entry, "compoNext", $compo, false); if ($prev !== false) stPrintCompoEntry($prev, "compoPrev", $compo, "Previous entry"); } function stPrintRotationSlide($data) { echo " <div class=\"slideHeader\">\n". " <div class=\"slideHeaderDiv\"></div>\n". " </div>\n". " <div class=\"slideText\">\n". $data. " </div>\n"; } function stGuruMeditation() { stPrintRotationSlide( "<div class=\"guru\">". "Software Failure. Press left mouse button to continue.<br />". "Guru Meditation #00000004.0000AAC0". "</div>\n"); } // // Initialize // stSetupCacheControl(); if (!stConnectSQLDB()) die("Could not connect to SQL database."); stReloadDisplayVars(); // // Check if the slide needs updating? // $updated = FALSE; // Temporary slides are handled globally if (stGetDisplayVar("tempDuration") > 0 && stGetDisplayVar("tempSlide") > 0 && stGetDisplayVar("tempSlideSet")) { $sql = stPrepareSQL("SELECT * FROM display_slides WHERE id=%d", stGetDisplayVar("tempSlide")); if (($res = stFetchSQL($sql)) !== false) { stSetDisplayVar("tempSlideSet", FALSE); stSetDisplayVar("activeSlideMode", SMODE_ROTATE); stSetDisplayVar("activeSlide", stGetDisplayVar("tempSlide")); stSetDisplayVar("activeSlideExpire", time() + (stGetDisplayVar("tempDuration") * 60)); $updated = TRUE; } } else // Otherwise we act according to global show mode switch (stGetDisplayVar("showMode")) { case SMODE_ROTATE: // // Rotation / normal slide show mode // stSetDisplayVar("activeSlideMode", SMODE_ROTATE); if (stGetDisplayVar("rotateList") == 0) { stSetDisplayVar("rotateList", 1); stSetDisplayVar("activeSlideExpire", 0); $updated = TRUE; } if (time() >= stGetDisplayVar("activeSlideExpire") && stGetDisplayVar("rotateList") > 0) { // Get list of slides from active rotation list $list = stGetDisplayVar("rotateList"); $sql = stPrepareSQL( "SELECT * FROM rot_list_slides WHERE list_id=%d ORDER BY order_num,id", $list); if (($slideList = stExecSQL($sql)) !== false) { // Get slide at current index $slides = array(); foreach ($slideList as $slide) $slides[] = $slide; $index = stGetDisplayVar("rotateListIndex"); if (count($slides) > $index) { $slide_id = $slides[$index]["slide_id"]; if ($slide_id != stGetDisplayVar("activeSlide")) { stSetDisplayVar("activeSlide", $slide_id); stSetDisplayVar("activeSlideExpire", time() + stGetDisplayVar("rotateDuration")); $updated = TRUE; } } // Rotate to next slide if (++$index >= count($slides)) $index = 0; stSetDisplayVar("rotateListIndex", $index); } } break; case SMODE_COMPO: // // Competition mode, is controlled from admin UI, so we donẗ // actually do anything here. // if (time() >= stGetDisplayVar("activeSlideExpire")) { stSetDisplayVar("activeSlideMode", SMODE_COMPO); $updated = TRUE; } break; case SMODE_DISABLED: if (stGetDisplayVar("activeSlideMode") != SMODE_DISABLED) { stSetDisplayVar("activeSlideMode", SMODE_DISABLED); $updated = TRUE; } break; } // Check if we need to update the "last updated" timestamp if ($updated) stDisplayUpdated(); // // Serve the request // $type = stGetRequestItem("type"); switch (stGetRequestItem("action")) { case "check": // Check if there has been any change $changed = stGetRequestItem("lastUpdate") != stGetDisplayVar("lastUpdate"); if (stGetDisplayVar("screenCmdSet")) { echo stGetDisplayVar("screenCmd"); stSetDisplayVar("screenCmdSet", FALSE); } else echo $changed ? "changed" : "nochange"; break; case "get": switch ($type) { case "update": echo stGetDisplayVar("lastUpdate"); break; case "slide": // Based on the currently active mode ... switch (stGetDisplayVar("activeSlideMode")) { case SMODE_ROTATE: // Slide rotation mode, display currently active slide if (stGetDisplayVar("activeSlide") > 0) { $sql = stPrepareSQL("SELECT * FROM display_slides WHERE id=%d", stGetDisplayVar("activeSlide")); if (($slide = stFetchSQL($sql)) !== false) stPrintRotationSlide($slide["text"]); } else stGuruMeditation(); break; case SMODE_COMPO: // Competition mode, show entry data $compo_id = stGetDisplayVar("compoID"); $compo = stFetchSQL(stPrepareSQL( "SELECT * FROM compos WHERE id=%d", $compo_id)); if ($compo !== false) { $prev = stFetchSQL(stPrepareSQL( "SELECT * FROM entries WHERE compo_id=%d AND show_id=%d AND show_id<>0", $compo_id, stGetDisplayVar("compoPrevEntry"))); $entry = stFetchSQL(stPrepareSQL( "SELECT * FROM entries WHERE compo_id=%d AND show_id=%d AND show_id<>0", $compo_id, stGetDisplayVar("compoCurrEntry"))); stPrintCompoSlide($compo, $entry, $prev); } break; default: stGuruMeditation(); break; } break; default: stGuruMeditation(); break; } break; default: stGuruMeditation(); break; } // Save changed variables stSaveDisplayVars(); //stDumpAJAXStatusErrors(); ?>