listing.inc.php 1.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  1. <?php include 'header.inc.php'; ?>
  2. <div style="float:right;"><input type="button" value="Log out" onclick="location.href='./?logout'"></div>
  3. <p>Welcome to Netsim! If this is your first time playing, we recommend you start from the first level below, and work your way forward.<p>
  4. <p>Please note that this project is still in <strong>beta</strong>. If you find any bugs, you can report them to <a href="https://twitter.com/errorinn">@errorinn</a> or open an issue on <a href="https://github.com/errorinn/netsim/issues">Github</a>.</p>
  5. <?php
  6. $res = $db->query("SELECT * FROM category ORDER BY orderby");
  7. while ($row = $res->fetchArray()) {
  8. echo "<h3 style=\"clear:both;;\">".$row['name']."</h3>\n";
  9. $res2 = $db->query("SELECT * FROM level WHERE category_id = ".$row['id']." ORDER BY orderby");
  10. while ($row2 = $res2->fetchArray()) {
  11. $complete = levelComplete($row2['id']);
  12. echo "<div style=\"float:left;position:relative;border-radius:0 0 10px 10px;border:solid 1px #AAA;margin:10px;padding:5px\">";
  13. echo "<a href=\"./?level=".$row2['id']."\">\n";
  14. echo "\t<img".($complete ? " style=\"opacity:0.3\"" : "")." src=\"includes/thumbs/".(file_exists("includes/thumbs/".$row2['id'].".png") ? $row2['id'] : 0).".png\">\n";
  15. if ($complete) echo "\t<img src=\"includes/thumbs/check.png\" style=\"position:absolute;top:80px;left:70px;\">\n";
  16. echo "</a><br>\n";
  17. echo "<a href=\"./?levels=".$row2['id']."\" style=\"color:#000;text-decoration:none;\">".$row2['name']."</a>\n";
  18. echo "</div>\n";
  19. //echo "[";
  20. //echo levelComplete($row2['id']) ? "X" : "&nbsp;";
  21. //echo "] <a href=\"./?level=".$row2['id']."\">".$row2['name']."</a><br>\n";
  22. }
  23. echo "<div style=\"clear:both;margin-bottom:30px;\"></div>";
  24. }
  25. function levelComplete($l) {
  26. global $db;
  27. $q = $db->query("SELECT * FROM solns WHERE user_id = ".$_SESSION['cs4g_user_id']." AND level_id = $l");
  28. $row = $q->fetchArray();
  29. return $row !== false && $row['completed'] == 1;
  30. }
  31. include 'footer.inc.php';
  32. ?>