/http-wrapper/ojn_admin/plugins/bunnies/wizzflux.plugin.php

https://github.com/soif/OpenJabNab · PHP · 139 lines · 129 code · 10 blank · 0 comment · 32 complexity · 7e7d9494657aec49a3447f18410aa564 MD5 · raw file

  1. <?php
  2. $Ztamps = $ojnAPI->GetListofZtamps(false);
  3. $FList = $ojnAPI->getApiList("bunny/".$_SESSION['bunny']."/wizzflux/listflux?".$ojnAPI->getToken());
  4. if(!empty($_POST['a'])) {
  5. if($_POST['a']=="webcast") {
  6. if(!empty($_POST['webcastT']) && !empty($_POST['webcastP'])) {
  7. $retour = $ojnAPI->getApiString("bunny/".$_SESSION['bunny']."/wizzflux/addwebcast?name=".urlencode($_POST['webcastP'])."&time=".$_POST['webcastT']."&".$ojnAPI->getToken());
  8. $_SESSION['message'] = isset($retour['ok']) ? $retour['ok'] : "Error : ".$retour['error'];
  9. }
  10. }
  11. else if($_POST['a']=="play") {
  12. if(!empty($_POST['playN'])) {
  13. $retour = $ojnAPI->getApiString("bunny/".$_SESSION['bunny']."/wizzflux/play?name=".urlencode($_POST['playN'])."&".$ojnAPI->getToken());
  14. $_SESSION['message'] = isset($retour['ok']) ? $retour['ok'] : "Error : ".$retour['error'];
  15. }
  16. }
  17. else if($_POST['a'] == "rfidplay") {
  18. if(!empty($_POST['PresetN_Rfp']) && !empty($_POST['Tag_Rfp']) && isset($Ztamps[$_POST['Tag_Rfp']])) {
  19. $retour = $ojnAPI->getApiString("bunny/".$_SESSION['bunny']."/wizzflux/addrfid?tag=".$_POST['Tag_Rfp']."&name=".urlencode($_POST['PresetN_Rfp'])."&".$ojnAPI->getToken());
  20. $_SESSION['message'] = isset($retour['ok']) ? $retour['ok'] : "Error : ".$retour['error'];
  21. }
  22. } else if($_POST['a'] == "rfidd") {
  23. if(!empty($_POST['Tag_Rfd']) && isset($Ztamps[$_POST['Tag_Rfd']])) {
  24. $retour = $ojnAPI->getApiString("bunny/".$_SESSION['bunny']."/wizzflux/removerfid?tag=".$_POST['Tag_Rfd']."&".$ojnAPI->getToken());
  25. $_SESSION['message'] = isset($retour['ok']) ? $retour['ok'] : "Error : ".$retour['error'];
  26. }
  27. } else if($_POST['a'] == "default") {
  28. if(!empty($_POST['d'])) {
  29. $retour = $ojnAPI->getApiString("bunny/".$_SESSION['bunny']."/wizzflux/setdefault?name=".urlencode($_POST['d'])."&".$ojnAPI->getToken());
  30. $_SESSION['message'] = isset($retour['ok']) ? $retour['ok'] : "Error : ".$retour['error'];
  31. }
  32. }
  33. header("Location: bunny_plugin.php?p=wizzflux");
  34. }
  35. else if(!empty($_GET['rw'])) {
  36. $retour = $ojnAPI->getApiString("bunny/".$_SESSION['bunny']."/wizzflux/removewebcast?time=".$_GET['rw']."&".$ojnAPI->getToken());
  37. $_SESSION['message'] = isset($retour['ok']) ? $retour['ok'] : "Error : ".$retour['error'];
  38. header("Location: bunny_plugin.php?p=wizzflux");
  39. }
  40. $default = $ojnAPI->getApiString("bunny/".$_SESSION['bunny']."/wizzflux/getdefault?".$ojnAPI->getToken());
  41. $default = isset($default['value']) ? (string)($default['value']) : '';
  42. $wList = $ojnAPI->getApiString("bunny/".$_SESSION['bunny']."/wizzflux/listwebcast?".$ojnAPI->getToken());
  43. ?>
  44. <form method="post">
  45. <fieldset>
  46. <legend>Actions</legend>
  47. <span class="fieldName">Play <input type="radio" name="a" value="play" /></span>Flux:
  48. <select name="playN">
  49. <option value=""></option>
  50. <?php if(!empty($FList))
  51. foreach($FList as $item) { ?>
  52. <option value="<?php echo $item; ?>"><?php echo ucfirst($item); ?></option>
  53. <?php } ?>
  54. </select><br />
  55. <hr />
  56. <span class="fieldName">Set default flux <input type="radio" name="a" value="default" /></span>Flux:
  57. <select name="d">
  58. <?php if(!empty($FList))
  59. foreach($FList as $item) { ?>
  60. <option value="<?php echo $item; ?>" <?php echo $default == $item ? 'selected="selected"' : ''; ?>><?php echo ucfirst($item); ?></option>
  61. <?php } ?>
  62. </select><br />
  63. <hr />
  64. <span class="fieldName">Add a webcast <input type="radio" name="a" value="webcast" /></span>at: <input type="text" name="webcastT" maxlength="5" style="width:50px" /> <i>(hh:mm)</i> &nbsp;&nbsp;&nbsp; for flux <select name="webcastP">
  65. <option value=""></option>
  66. <?php if(!empty($FList))
  67. foreach($FList as $item) { ?>
  68. <option value="<?php echo $item; ?>"><?php echo ucfirst($item); ?></option>
  69. <?php } ?>
  70. </select><br />
  71. <hr />
  72. <span class="fieldName">Play flux <input type="radio" name="a" value="rfidplay" /></span>Flux:
  73. <select name="PresetN_Rfp">
  74. <option value=""></option>
  75. <?php if(!empty($FList))
  76. foreach($FList as $item) { ?>
  77. <option value="<?php echo $item; ?>"><?php echo ucfirst($item); ?></option>
  78. <?php } ?>
  79. </select>
  80. &nbsp;&nbsp;&nbsp;<br />
  81. <span class="fieldName"></span>on Ztamp:
  82. <select name="Tag_Rfp">
  83. <option value=""></option>
  84. <?php foreach($Ztamps as $k=>$v): ?>
  85. <option value="<?php echo $k; ?>"><?php echo $v; ?> (<?php echo $k; ?>)</option>
  86. <?php endforeach; ?>
  87. </select><br />
  88. <hr />
  89. <span class="fieldName">Delete Ztamp association <input type="radio" name="a" value="rfidd" /></span>Ztamp:
  90. <select name="Tag_Rfd">
  91. <option value=""></option>
  92. <?php foreach($Ztamps as $k=>$v): ?>
  93. <option value="<?php echo $k; ?>"><?php echo $v; ?> (<?php echo $k; ?>)</option>
  94. <?php endforeach; ?>
  95. </select><br />
  96. <hr />
  97. <input type="submit" value="Enregister">
  98. </fieldset>
  99. </form>
  100. <?php
  101. if(isset($pList['list']->item)) {
  102. ?>
  103. <hr />
  104. <?php
  105. }
  106. if(isset($wList['list']->item)){
  107. ?>
  108. <hr />
  109. <table class="tablePlugins" cellspacing=0>
  110. <tr>
  111. <th colspan="3">Webcast</th>
  112. </tr>
  113. <tr>
  114. <th>Time</th>
  115. <th>Name</th>
  116. <th>Actions</th>
  117. </tr>
  118. <?php
  119. $i = 0;
  120. foreach($wList['list']->item as $item) {
  121. ?>
  122. <tr<?php echo $i++ % 2 ? " class='l2'" : "" ?>>
  123. <td><?php echo urldecode($item->key) ?></td>
  124. <td><?php echo $item->value ?></td>
  125. <td width="15%" class="remove"><a href="bunny_plugin.php?p=wizzflux&rw=<?php echo $item->key ?>">Remove</a></td>
  126. </tr>
  127. <?php } ?>
  128. </table>
  129. <?php } ?>