PageRenderTime 51ms CodeModel.GetById 23ms RepoModel.GetById 1ms app.codeStats 0ms

/src/boinc/boinc/html/ops/manage_apps.php

http://decs.googlecode.com/
PHP | 250 lines | 165 code | 51 blank | 34 comment | 21 complexity | 7aaf4a08b5c63a282c05950060269ae4 MD5 | raw file
Possible License(s): GPL-2.0, LGPL-2.1, LGPL-2.0
  1. <?php
  2. /***********************************************************************\
  3. * Display and Manage BOINC Application Versions
  4. *
  5. * This page presents a form with information about application versions.
  6. * Some of the fields can be changed. An appllication version can be deleted
  7. * by entering the word "DELETE" (all caps required) in the provided field.
  8. * It is better to deprecate a version first than to delete it, but it is also
  9. * good to remove old versions after they have been unused for a while,
  10. * lest you over-fill the feeder (which results in new versions not being
  11. * used by clients).
  12. *
  13. * Eric Myers <myers@spy-hill.net> - 4 June 2006
  14. * @(#) $Id: manage_apps.php 11547 2006-11-17 19:52:09Z rytiss $
  15. \***********************************************************************/
  16. require_once('../inc/util_ops.inc');
  17. db_init();
  18. // Platform and application labels (are better than numbers)
  19. $result = mysql_query("SELECT * FROM platform");
  20. $Nplatform = mysql_num_rows($result);
  21. for($i=0;$i<=$Nplatform;$i++){
  22. $item=mysql_fetch_object($result);
  23. $id=$item->id;
  24. $plat_off[$id]=$item->deprecated;
  25. $platform[$id]=$item->user_friendly_name;
  26. }
  27. mysql_free_result($result);
  28. /***************************************************\
  29. * Action: process form input for changes
  30. \***************************************************/
  31. if( !empty($_POST) ) {
  32. /* Changing properties of existing applications */
  33. $result = mysql_query("SELECT * FROM app");
  34. $Nrow=mysql_num_rows($result);
  35. for($j=1;$j<=$Nrow;$j++){ // test/update each row in DB
  36. $item=mysql_fetch_object($result);
  37. $id=$item->id;
  38. /* Delete this entry? */
  39. $field="delete_".$id;
  40. if( $_POST[$field]=='DELETE' ) {
  41. $cmd = "DELETE FROM app WHERE id=$id";
  42. $commands .= "<P><pre>$cmd</pre>\n";
  43. mysql_query($cmd);
  44. continue; // next row, this one is gone
  45. }
  46. /* Change deprecated status? */
  47. $field="deprecated_".$id;
  48. $new_v= ($_POST[$field]=='on') ? 1 : 0;
  49. $old_v=$item->deprecated;
  50. if($new_v != $old_v ) {
  51. $cmd = "UPDATE app SET deprecated=$new_v WHERE id=$id";
  52. $commands .= "<P><pre>$cmd</pre>\n";
  53. mysql_query($cmd);
  54. }
  55. /* Minimum version limit */
  56. $field="min_version_".$id;
  57. $new_v= $_POST[$field] + 0;
  58. $old_v=$item->min_version;
  59. if( $new_v != $old_v ) {
  60. $cmd = "UPDATE app SET min_version=$new_v WHERE id=$id";
  61. $commands .= "<P><pre>$cmd</pre>\n";
  62. mysql_query($cmd);
  63. }
  64. /* Minimum version limit */
  65. $field="weight_".$id;
  66. $new_v= $_POST[$field] + 0;
  67. $old_v=$item->weight;
  68. if( $new_v != $old_v ) {
  69. $cmd = "UPDATE app SET weight=$new_v WHERE id=$id";
  70. $commands .= "<P><pre>$cmd</pre>\n";
  71. mysql_query($cmd);
  72. }
  73. /* Homogendous redundancy restriction (same platform for all WU's) */
  74. $field="homogeneous_redundancy_".$id;
  75. $new_v= ($_POST[$field]=='on') ? 1 : 0;
  76. $old_v=$item->homogeneous_redundancy;
  77. if( $new_v != $old_v ) {
  78. $cmd = "UPDATE app SET homogeneous_redundancy=$new_v WHERE id=$id";
  79. $commands .= "<P><pre>$cmd</pre>\n";
  80. mysql_query($cmd);
  81. }
  82. }
  83. /* Adding a new application */
  84. if( $_POST['add_app'] ) {
  85. $name= mysql_real_escape_string($_POST['add_name']);
  86. $user_friendly_name=mysql_real_escape_string($_POST['add_user_friendly_name']);
  87. if( empty($name) || empty($user_friendly_name) ) {
  88. $commands .= "<p><font color='red'>
  89. To add a new application please supply both a brief name and a
  90. longer 'user-friendly' name.</font></p>\n";
  91. }
  92. else {
  93. $now=time();
  94. $cmd = "INSERT INTO app (name,user_friendly_name,create_time) ".
  95. "VALUES ('$name', '$user_friendly_name',$now)";
  96. $commands .= "<P><pre>$cmd</pre>\n";
  97. mysql_query($cmd);
  98. }
  99. }
  100. }//$_POST
  101. /***************************************************\
  102. * Display the DB contents in a form
  103. \***************************************************/
  104. admin_page_head("Manage Project Applications");
  105. if($commands) echo $commands;
  106. $self=$_SERVER['PHP_SELF'];
  107. echo "<form action='$self' method='POST'>\n";
  108. // Application Table:
  109. echo"<P>
  110. <h2>". PROJECT . " Applications</h2>\n";
  111. start_table("align='center'");
  112. echo "<TR><TH>ID #</TH>
  113. <TH>Name<br>(description)</TH>
  114. <TH>Creation<br>Time</TH>
  115. <TH>minimum<br>version</TH>
  116. <TH>weight</TH>
  117. <TH>Homogeneous<br>Redundancy</TH>
  118. <TH>deprecated?</TH>
  119. <TH>DELETE?<sup>*</sup>
  120. </TH>
  121. </TR>\n";
  122. $q="SELECT * FROM app ORDER BY id";
  123. $result = mysql_query($q);
  124. $Nrow=mysql_num_rows($result);
  125. for($j=1;$j<=$Nrow;$j++){
  126. $item=mysql_fetch_object($result);
  127. $id=$item->id;
  128. // grey-out deprecated versions
  129. $f1=$f2='';
  130. if($item->deprecated==1) {
  131. $f1="<font color='GREY'>";
  132. $f2="</font>";
  133. }
  134. echo "<tr> ";
  135. echo " <TD align='center'>$f1 $id $f2</TD>\n";
  136. $name=$item->name;
  137. $full_name=$item->user_friendly_name;
  138. echo " <TD align='left'>$f1<tt>$name</tt><br>
  139. <em>$full_name</em> $f2</TD>\n";
  140. $time=$item->create_time;
  141. echo " <TD align='center'>$f1 " .time_str($time)."$f2</TD>\n";
  142. $field="min_version_".$id;
  143. $v=$item->min_version;
  144. echo " <TD align='center'>
  145. <input type='text' size='4' name='$field' value='$v'></TD>\n";
  146. $field="weight_".$id;
  147. $v=$item->weight;
  148. echo " <TD align='center'>
  149. <input type='text' size='4' name='$field' value='$v'></TD>\n";
  150. $field="homogeneous_redundancy_".$id;
  151. $v='';
  152. if( $item->homogeneous_redundancy ) $v=' CHECKED ';
  153. echo " <TD align='center'>
  154. <input name='$field' type='checkbox' $v></TD>\n";
  155. $field="deprecated_".$id;
  156. $v='';
  157. if($item->deprecated) $v=' CHECKED ';
  158. echo " <TD align='center'>
  159. <input name='$field' type='checkbox' $v></TD>\n";
  160. $field="delete_app_".$id;
  161. echo " <TD align='center'>
  162. <input type='text' size='6' name='$field' value=''></TD>\n";
  163. echo "</tr> ";
  164. }
  165. mysql_free_result($result);
  166. echo "<tr><td colspan=6>
  167. <sup>*</sup>To delete an entry you must enter the word 'DELETE' in this field,
  168. in all capital letters..
  169. <td align='center' colspan=2 bgcolor='#FFFF88'>
  170. <input type='submit' name='update' value='Update'></td>
  171. </tr>\n";
  172. end_table();
  173. /**
  174. * Entry form to create a new application
  175. */
  176. echo"<P>
  177. <h2>Add an Application</h2>
  178. To add an application to the project enter the short name and description
  179. ('user friendly name') below. You can then control the version limits and
  180. turn on homogeneous redundancy (if desired) when the application appears
  181. in the table above.
  182. </p>\n";
  183. start_table("align='center' ");
  184. echo "<TR><TH>Name</TH>
  185. <TH>Description</TH>
  186. <TH> &nbsp; </TH>
  187. </TR>\n";
  188. echo "<TR>
  189. <TD> <input type='text' size='12' name='add_name' value=''></TD>
  190. <TD> <input type='text' size='35' name='add_user_friendly_name' value=''></TD>
  191. <TD align='center' bgcolor='#FFFF88'>
  192. <input type='submit' name='add_app' value='Add Application'></TD>
  193. </TR>\n";
  194. end_table();
  195. echo "</form><p>\n";
  196. admin_page_tail();
  197. //Generated automatically - do not edit
  198. $cvs_version_tracker[]="\$Id: manage_apps.php 11547 2006-11-17 19:52:09Z rytiss $";
  199. ?>