v_php_service_edit.php 19 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556
  1. <?php
  2. /*
  3. FusionPBX
  4. Version: MPL 1.1
  5. The contents of this file are subject to the Mozilla Public License Version
  6. 1.1 (the "License"); you may not use this file except in compliance with
  7. the License. You may obtain a copy of the License at
  8. http://www.mozilla.org/MPL/
  9. Software distributed under the License is distributed on an "AS IS" basis,
  10. WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
  11. for the specific language governing rights and limitations under the
  12. License.
  13. The Original Code is FusionPBX
  14. The Initial Developer of the Original Code is
  15. Mark J Crane <[email protected]>
  16. Portions created by the Initial Developer are Copyright (C) 2008-2012
  17. the Initial Developer. All Rights Reserved.
  18. Contributor(s):
  19. Mark J Crane <[email protected]>
  20. */
  21. require_once "root.php";
  22. require_once "resources/require.php";
  23. require_once "resources/check_auth.php";
  24. if (permission_exists('php_service_add') || permission_exists('php_service_edit')) {
  25. //access granted
  26. }
  27. else {
  28. echo "access denied";
  29. exit;
  30. }
  31. /*
  32. function pkg_is_service_running($servicename) {
  33. exec("/bin/ps ax | awk '{ print $5 }'", $psout);
  34. array_shift($psout);
  35. foreach($psout as $line) {
  36. $ps[] = trim(array_pop(explode(' ', array_pop(explode('/', $line)))));
  37. }
  38. if(is_service_running($servicename, $ps) or is_process_running($servicename) ) {
  39. return true;
  40. }
  41. else {
  42. return false;
  43. }
  44. }
  45. function byte_convert( $bytes ) {
  46. if ($bytes<=0)
  47. return '0 Byte';
  48. $convention=1000; //[1000->10^x|1024->2^x]
  49. $s=array('B', 'kB', 'MB', 'GB', 'TB', 'PB', 'EB', 'ZB');
  50. $e=floor(log($bytes,$convention));
  51. return round($bytes/pow($convention,$e),2).' '.$s[$e];
  52. }
  53. */
  54. function php_services_sync_package_php() {
  55. global $db, $domain_uuid, $startup_script_dir, $tmp_dir;
  56. $sql = "";
  57. $sql .= "select * from v_php_services ";
  58. $sql .= "where domain_uuid = '$domain_uuid' ";
  59. $tmp_prep_statement = $db->prepare(check_sql($sql));
  60. $tmp_prep_statement->execute();
  61. $tmp_result = $tmp_prep_statement->fetchAll(PDO::FETCH_NAMED);
  62. foreach ($tmp_result as &$row) {
  63. $service_name = $row["service_name"];
  64. $tmp_service_name = str_replace(" ", "_", $service_name);
  65. $service_script = base64_decode($row["service_script"]);
  66. //$service_enabled = $row["service_enabled"];
  67. $service_description = $row["service_description"];
  68. $php_service_file = "php_service_".$tmp_service_name.".php";
  69. if ($row['service_enabled'] == "false") {
  70. //delete the php service file
  71. unlink($_SERVER["DOCUMENT_ROOT"].PROJECT_PATH.'/secure/php_service_'.$tmp_service_name.'.php');
  72. //delete the start up script
  73. unlink($startup_script_dir.'/php_service_'.$tmp_service_name.'.sh');
  74. //delete the pid file
  75. unlink($tmp_dir.'/php_service_'.$tmp_service_name.'.pid');
  76. }
  77. else {
  78. //write the php service
  79. $tmp = "<?php\n";
  80. $tmp .= "// name: ".$service_name." \n";
  81. $tmp .= "// description: ".$service_description." \n";
  82. $tmp .= "\n";
  83. $tmp .= "// set time limit to indefinite execution\n";
  84. $tmp .= "set_time_limit (0);\n";
  85. $tmp .= "\n";
  86. $tmp .= "//run this program as long as the pid file exists\n";
  87. $tmp .= "\$filename = '".$tmp_dir."/php_service_".$tmp_service_name.".pid';\n";
  88. $tmp .= "\$fp = fopen(\$filename, 'w');\n";
  89. $tmp .= "fwrite(\$fp, getmypid());\n";
  90. $tmp .= "fclose(\$fp);\n";
  91. $tmp .= "chmod(\"".$tmp_dir."/php_service_".$tmp_service_name.".pid\", 0776);\n";
  92. $tmp .= "unset(\$filename);\n";
  93. $tmp .= "\n";
  94. //$tmp .= "//require_once(\"config.inc\");\n";
  95. //$tmp .= "//global \$config;\n";
  96. //$tmp .= "//\$sys_log_address = \$config['syslog']['remoteserver'];\n";
  97. //$tmp .= "\$sys_log_address = \"127.0.0.1\";\n";
  98. //$tmp .= "\$syslogport = 514;\n";
  99. //$tmp .= "echo \"syslog server: \".\$sys_log_address.\"\\n\";\n";
  100. //$tmp .= "\n";
  101. //$tmp .= "\n";
  102. //$tmp .= "\n";
  103. //$tmp .= "function send_to_syslog(\$sys_log_address, \$syslogport, \$syslogmsg) {\n";
  104. //$tmp .= "\n";
  105. //$tmp .= " \$fp = fsockopen(\"udp://\".\$sys_log_address, \$syslogport, \$errno, \$errstr);\n";
  106. //$tmp .= " if (!\$fp) {\n";
  107. //$tmp .= " //echo \"ERROR: \$errno - \$errstr<br />\\n\";\n";
  108. //$tmp .= " } else {\n";
  109. //$tmp .= " fwrite(\$fp, \$syslogmsg);\n";
  110. //$tmp .= " fclose(\$fp);\n";
  111. //$tmp .= " }\n";
  112. //$tmp .= "\n";
  113. //$tmp .= "}\n";
  114. //$tmp .= "\n";
  115. //$tmp .= "\n";
  116. //$tmp .= "//\$msg = \"1.begin loop. \".date('r').\"\\n\";\n";
  117. //$tmp .= "//\$fp = fopen('/tmp/".$tmp_service_name.".txt', 'a');\n";
  118. //$tmp .= "//fwrite(\$fp, \$msg.\"\\n\");\n";
  119. //$tmp .= "//fclose(\$fp);\n";
  120. //$tmp .= "\n";
  121. $tmp .= $service_script;
  122. $tmp .= "\n";
  123. $tmp .= "?>";
  124. $fout = fopen($_SERVER["DOCUMENT_ROOT"].PROJECT_PATH.'/secure/'.$php_service_file,"w");
  125. fwrite($fout, $tmp);
  126. unset($tmp);
  127. fclose($fout);
  128. //add execute permissions to the php service script
  129. chmod($_SERVER["DOCUMENT_ROOT"].PROJECT_PATH.'/secure/'.$php_service_file, 0776);
  130. //write the start up script
  131. // CYGWIN_NT-5.1
  132. // Darwin
  133. // FreeBSD
  134. // HP-UX
  135. // IRIX64
  136. // Linux
  137. // NetBSD
  138. // OpenBSD
  139. // SunOS
  140. // Unix
  141. // WIN32
  142. // WINNT
  143. // Windows
  144. switch (PHP_OS) {
  145. case "FreeBSD":
  146. // make sure the start up directory i set
  147. if (strlen($startup_script_dir) > 0) {
  148. $startup_script_dir = "/usr/local/etc/rc.d";
  149. }
  150. $tmp = "";
  151. $tmp = "#!/bin/sh\n";
  152. $tmp .= "# This file was automatically generated\n";
  153. $tmp .= "# by the PHP Service handler.\n";
  154. $tmp .= "# \n";
  155. $tmp .= "# Copy this script to the startup directory.\n";
  156. $tmp .= "# cp -a ".$_SERVER["DOCUMENT_ROOT"].PROJECT_PATH."/secure/php_service_".$tmp_service_name.".sh ".$startup_script_dir."/php_service_".$tmp_service_name.".sh";
  157. $tmp .= "# \n";
  158. $tmp .= "# Usage: ./php_service_".$tmp_service_name.".sh {start|stop|restart}\n";
  159. $tmp .= "# ".$startup_script_dir."/./php_service_".$tmp_service_name.".sh start";
  160. $tmp .= "\n";
  161. $tmp .= "\n";
  162. $tmp .= "rc_start() {\n";
  163. $tmp .= " ".PHP_BINDIR."/php ".$_SERVER["DOCUMENT_ROOT"].PROJECT_PATH."/secure/".$php_service_file." >> /var/log/php_service_".$tmp_service_name.".log &\n";
  164. $tmp .= "}\n";
  165. $tmp .= "\n";
  166. $tmp .= "rc_stop() {\n";
  167. $tmp .= " rm ".$tmp_dir."/php_service_".$tmp_service_name.".pid\n";
  168. $tmp .= "}\n";
  169. $tmp .= "\n";
  170. $tmp .= "case \"\$1\" in\n";
  171. $tmp .= " start)\n";
  172. $tmp .= " echo \"Starting the service. \"\n";
  173. $tmp .= " rc_start\n";
  174. $tmp .= " ;;\n";
  175. $tmp .= " stop)\n";
  176. $tmp .= " echo \"Stopping the service. \"\n";
  177. $tmp .= " rc_stop\n";
  178. $tmp .= " ;;\n";
  179. $tmp .= " restart)\n";
  180. $tmp .= " echo \"Restarting the service. \"\n";
  181. $tmp .= " rc_stop\n";
  182. $tmp .= " rc_start\n";
  183. $tmp .= " ;;\n";
  184. $tmp .= " *)\n";
  185. $tmp .= " echo \"Usage: ".$startup_script_dir."/php_service_".$tmp_service_name.".sh {start|stop|restart}\"\n";
  186. $tmp .= " exit 1\n";
  187. $tmp .= " ;;\n";
  188. $tmp .= "esac\n";
  189. $fout = fopen($_SERVER["DOCUMENT_ROOT"].PROJECT_PATH."/secure/php_service_".$tmp_service_name.".sh","w");
  190. fwrite($fout, $tmp);
  191. unset($tmp);
  192. fclose($fout);
  193. //add execute permissions to the start script
  194. chmod($_SERVER["DOCUMENT_ROOT"].PROJECT_PATH."/secure/php_service_".$tmp_service_name.".sh", 0755);
  195. break;
  196. default:
  197. // make sure the start up directory i set
  198. if (strlen($startup_script_dir) > 0) {
  199. $startup_script_dir = "/etc/init.d";
  200. }
  201. $tmp = "";
  202. $tmp .= "#!/bin/sh\n";
  203. $tmp .= "# /etc/init.d/".$tmp_service_name."\n";
  204. $tmp .= "# This file was automatically generated\n";
  205. $tmp .= "# by the PHP Service handler.\n";
  206. $tmp .= "# \n";
  207. $tmp .= "# Copy this script to the startup directory.\n";
  208. $tmp .= "# cp -a ".$_SERVER["DOCUMENT_ROOT"].PROJECT_PATH."/secure/php_service_".$tmp_service_name.".sh ".$startup_script_dir."/php_service_".$tmp_service_name.".sh";
  209. $tmp .= "# \n";
  210. $tmp .= "# Usage: ./php_service_".$tmp_service_name.".sh {start|stop|restart}\n";
  211. $tmp .= "# ".$startup_script_dir."/./php_service_".$tmp_service_name.".sh start";
  212. $tmp .= "\n";
  213. $tmp .= "\n";
  214. $tmp .= "rc_start() {\n";
  215. $tmp .= " ".PHP_BINDIR."/php ".$_SERVER["DOCUMENT_ROOT"].PROJECT_PATH."/secure/".$php_service_file." >> /var/log/".tmp_service_name.".log &\n";
  216. $tmp .= "}\n";
  217. $tmp .= "\n";
  218. $tmp .= "rc_stop() {\n";
  219. $tmp .= " rm ".$tmp_dir."/php_service_".$tmp_service_name.".pid\n";
  220. $tmp .= "}\n";
  221. $tmp .= "\n";
  222. $tmp .= "case \"\$1\" in\n";
  223. $tmp .= " start)\n";
  224. $tmp .= " echo \"Starting the service. \"\n";
  225. $tmp .= " rc_start\n";
  226. $tmp .= " ;;\n";
  227. $tmp .= " stop)\n";
  228. $tmp .= " echo \"Stopping the service. \"\n";
  229. $tmp .= " rc_stop\n";
  230. $tmp .= " ;;\n";
  231. $tmp .= " restart)\n";
  232. $tmp .= " echo \"Restarting the service. \"\n";
  233. $tmp .= " rc_stop\n";
  234. $tmp .= " rc_start\n";
  235. $tmp .= " ;;\n";
  236. $tmp .= " *)\n";
  237. $tmp .= " echo \"Usage: ".$startup_script_dir."/".$tmp_service_name.".sh {start|stop|restart}\"\n";
  238. $tmp .= " exit 1\n";
  239. $tmp .= " ;;\n";
  240. $tmp .= "esac\n";
  241. $tmp .= "\n";
  242. $tmp .= "exit 0";
  243. $fout = fopen($_SERVER["DOCUMENT_ROOT"].PROJECT_PATH."/secure/php_service_".$tmp_service_name.".sh","w");
  244. fwrite($fout, $tmp);
  245. unset($tmp);
  246. fclose($fout);
  247. //add execute permissions to the start script
  248. chmod($_SERVER["DOCUMENT_ROOT"].PROJECT_PATH."/secure/php_service_".$tmp_service_name.".sh", 0755);
  249. }
  250. } //end if enabled
  251. }
  252. }
  253. //set the action as an add or an update
  254. if (isset($_REQUEST["id"])) {
  255. $action = "update";
  256. $php_service_uuid = check_str($_REQUEST["id"]);
  257. }
  258. else {
  259. $action = "add";
  260. }
  261. //set the http values to variabless
  262. if (count($_POST)>0) {
  263. $service_name = check_str($_POST["service_name"]);
  264. $service_script = $_POST["service_script"];
  265. $service_enabled = check_str($_POST["service_enabled"]);
  266. $service_description = check_str($_POST["service_description"]);
  267. //set defaults
  268. $service_type = "php";
  269. //setup the default script
  270. $tmp_service_name = str_replace(" ", "_", $service_name);
  271. if (strlen($service_script) == 0) {
  272. $tmp = "\n";
  273. $tmp .= "\n";
  274. $tmp .= "\$x = 0;\n";
  275. $tmp .= "while(\$x == 0) {\n";
  276. $tmp .= "\n";
  277. $tmp .= "\n";
  278. $tmp .= "\n";
  279. $tmp .= "\n";
  280. $tmp .= "\n";
  281. $tmp .= "\n";
  282. $tmp .= "\n";
  283. $tmp .= "\n";
  284. $tmp .= "\n";
  285. $tmp .= " if(!file_exists('".$tmp_dir."/php_service_".$tmp_service_name.".pid')) { return; }\n";
  286. $tmp .= " usleep(1000000); //1 000 000 microseconds = 1 second\n";
  287. //$tmp .= " //if (\$x > 60){ exit; } //exit after 60 loops for testing\n";
  288. $tmp .= "} //end while\n";
  289. $service_script = $tmp;
  290. }
  291. }
  292. if (count($_POST)>0 && strlen($_POST["persistformvar"]) == 0) {
  293. $msg = '';
  294. if ($action == "update") {
  295. $php_service_uuid = check_str($_POST["php_service_uuid"]);
  296. }
  297. //check for all required data
  298. if (strlen($service_name) == 0) { $msg .= "Please provide: Name<br>\n"; }
  299. //if (strlen($service_script) == 0) { $msg .= "Please provide: Script<br>\n"; }
  300. if (strlen($service_enabled) == 0) { $msg .= "Please provide: Enabled<br>\n"; }
  301. //if (strlen($service_description) == 0) { $msg .= "Please provide: Description<br>\n"; }
  302. if (strlen($msg) > 0 && strlen($_POST["persistformvar"]) == 0) {
  303. require_once "resources/header.php";
  304. require_once "resources/persist_form_var.php";
  305. echo "<div align='center'>\n";
  306. echo "<table><tr><td>\n";
  307. echo $msg."<br />";
  308. echo "</td></tr></table>\n";
  309. persistformvar($_POST);
  310. echo "</div>\n";
  311. require_once "resources/footer.php";
  312. return;
  313. }
  314. //add or update the database
  315. if ($_POST["persistformvar"] != "true") {
  316. if ($action == "add" && permission_exists('php_service_add')) {
  317. $php_service_uuid = uuid();
  318. $sql = "insert into v_php_services ";
  319. $sql .= "(";
  320. $sql .= "domain_uuid, ";
  321. $sql .= "php_service_uuid, ";
  322. $sql .= "service_name, ";
  323. $sql .= "service_script, ";
  324. $sql .= "service_enabled, ";
  325. $sql .= "service_description ";
  326. $sql .= ")";
  327. $sql .= "values ";
  328. $sql .= "(";
  329. $sql .= "'$domain_uuid', ";
  330. $sql .= "'$php_service_uuid', ";
  331. $sql .= "'$service_name', ";
  332. $sql .= "'".base64_encode($service_script)."', ";
  333. $sql .= "'$service_enabled', ";
  334. $sql .= "'$service_description' ";
  335. $sql .= ")";
  336. $db->exec(check_sql($sql));
  337. unset($sql);
  338. //create the php service files
  339. php_services_sync_package_php();
  340. require_once "resources/header.php";
  341. echo "<meta http-equiv=\"refresh\" content=\"2;url=v_php_service.php\">\n";
  342. echo "<div align='center'>\n";
  343. echo "Add Complete\n";
  344. echo "</div>\n";
  345. require_once "resources/footer.php";
  346. return;
  347. } //if ($action == "add")
  348. if ($action == "update" && permission_exists('php_service_edit')) {
  349. $sql = "update v_php_services set ";
  350. $sql .= "service_name = '$service_name', ";
  351. $sql .= "service_script = '".base64_encode($service_script)."', ";
  352. $sql .= "service_enabled = '$service_enabled', ";
  353. $sql .= "service_description = '$service_description' ";
  354. $sql .= "where domain_uuid = '$domain_uuid' ";
  355. $sql .= "and php_service_uuid = '$php_service_uuid' ";
  356. $db->exec(check_sql($sql));
  357. unset($sql);
  358. //create the php service files
  359. php_services_sync_package_php();
  360. require_once "resources/header.php";
  361. echo "<meta http-equiv=\"refresh\" content=\"2;url=v_php_service.php\">\n";
  362. echo "<div align='center'>\n";
  363. echo "Update Complete\n";
  364. echo "</div>\n";
  365. require_once "resources/footer.php";
  366. return;
  367. } //if ($action == "update")
  368. } //if ($_POST["persistformvar"] != "true")
  369. } //(count($_POST)>0 && strlen($_POST["persistformvar"]) == 0)
  370. //pre-populate the form
  371. if (count($_GET)>0 && $_POST["persistformvar"] != "true") {
  372. $php_service_uuid = $_GET["id"];
  373. $sql = "";
  374. $sql .= "select * from v_php_services ";
  375. $sql .= "where domain_uuid = '$domain_uuid' ";
  376. $sql .= "and php_service_uuid = '$php_service_uuid' ";
  377. $prep_statement = $db->prepare(check_sql($sql));
  378. $prep_statement->execute();
  379. $result = $prep_statement->fetchAll(PDO::FETCH_NAMED);
  380. foreach ($result as &$row) {
  381. $service_name = $row["service_name"];
  382. $tmp_service_name = str_replace(" ", "_", $service_name);
  383. $service_script = base64_decode($row["service_script"]);
  384. $service_enabled = $row["service_enabled"];
  385. $service_description = $row["service_description"];
  386. break; //limit to 1 row
  387. }
  388. unset ($prep_statement);
  389. }
  390. //include the header
  391. require_once "resources/header.php";
  392. // edit area
  393. echo " <script language=\"javascript\" type=\"text/javascript\" src=\"".PROJECT_PATH."/includes/edit_area/edit_area_full.js\"></script>\n";
  394. echo " <!-- -->\n";
  395. echo " <script language=\"Javascript\" type=\"text/javascript\">\n";
  396. echo " // initialisation //load,\n";
  397. echo " editAreaLoader.init({\n";
  398. echo " id: \"service_script\" // id of the textarea to transform //, |, help\n";
  399. if (strlen($service_script) < 3000) {
  400. echo " ,start_highlight: true\n";
  401. }
  402. else {
  403. echo " ,start_highlight: false\n";
  404. echo " ,display: \"later\"\n";
  405. }
  406. echo " ,font_size: \"8\"\n";
  407. echo " ,allow_toggle: true\n";
  408. echo " ,language: \"en\"\n";
  409. echo " ,syntax: \"html\"\n";
  410. echo " ,toolbar: \"search, go_to_line,|, fullscreen, |, undo, redo, |, select_font, |, syntax_selection, |, change_smooth_selection, highlight, reset_highlight, |, help\" //new_document,\n";
  411. echo " ,plugins: \"charmap\"\n";
  412. echo " ,charmap_default: \"arrows\"\n";
  413. echo "\n";
  414. echo " });\n";
  415. echo "\n";
  416. echo " </script>";
  417. //show the form
  418. echo "<div align='center'>";
  419. echo "<table width='100%' border='0' cellpadding='0' cellspacing=''>\n";
  420. echo "<tr class='border'>\n";
  421. echo " <td align=\"left\">\n";
  422. echo " <br>";
  423. echo "<form method='post' name='frm' action=''>\n";
  424. echo "<div align='center'>\n";
  425. echo "<table width='100%' border='0' cellpadding='6' cellspacing='0'>\n";
  426. echo "<tr>\n";
  427. if ($action == "add") {
  428. echo "<td align='left' width='30%' nowrap><b>PHP Service Add</b></td>\n";
  429. }
  430. if ($action == "update") {
  431. echo "<td align='left' width='30%' nowrap><b>PHP Service Edit</b></td>\n";
  432. }
  433. echo "<td width='70%' align='right'><input type='button' class='btn' name='' alt='back' onclick=\"window.location='v_php_service.php'\" value='Back'></td>\n";
  434. echo "</tr>\n";
  435. echo "<tr>\n";
  436. echo "<td colspan='2'>\n";
  437. echo "Manages multiple dynamic and customizable services. There are many possible uses including alerts, ssh access control, scheduling commands to run, and many others uses that are yet to be discovered.<br /><br />\n";
  438. echo "</td>\n";
  439. echo "</tr>\n";
  440. echo "<tr>\n";
  441. echo "<td class='vncellreq' valign='top' align='left' nowrap>\n";
  442. echo " Name:\n";
  443. echo "</td>\n";
  444. echo "<td class='vtable' align='left'>\n";
  445. echo " <input class='formfld' type='text' name='service_name' maxlength='255' value=\"$service_name\">\n";
  446. echo "<br />\n";
  447. echo "Enter a name.\n";
  448. echo "</td>\n";
  449. echo "</tr>\n";
  450. echo "<tr>\n";
  451. echo "<td class='vncellreq' valign='top' align='left' nowrap>\n";
  452. echo " Script:\n";
  453. echo "</td>\n";
  454. echo "<td class='vtable' align='left'>\n";
  455. echo " <textarea class='formfld' style='width: 90%;' wrap='off' rows='17' name='service_script' id='service_script' rows='4'>$service_script</textarea>\n";
  456. echo "<br />\n";
  457. echo "Enter the PHP script here.\n";
  458. echo "</td>\n";
  459. echo "</tr>\n";
  460. echo "<tr>\n";
  461. echo "<td class='vncellreq' valign='top' align='left' nowrap>\n";
  462. echo " Enabled:\n";
  463. echo "</td>\n";
  464. echo "<td class='vtable' align='left'>\n";
  465. echo " <select class='formfld' name='service_enabled'>\n";
  466. echo " <option value=''></option>\n";
  467. if ($service_enabled == "true") {
  468. echo " <option value='true' selected >true</option>\n";
  469. }
  470. else {
  471. echo " <option value='true'>true</option>\n";
  472. }
  473. if ($service_enabled == "false") {
  474. echo " <option value='false' selected >false</option>\n";
  475. }
  476. else {
  477. echo " <option value='false'>false</option>\n";
  478. }
  479. echo " </select>\n";
  480. echo "<br />\n";
  481. echo "\n";
  482. echo "</td>\n";
  483. echo "</tr>\n";
  484. echo "<tr>\n";
  485. echo "<td class='vncell' valign='top' align='left' nowrap>\n";
  486. echo " Description:\n";
  487. echo "</td>\n";
  488. echo "<td class='vtable' align='left'>\n";
  489. echo " <input class='formfld' type='text' name='service_description' maxlength='255' value=\"$service_description\">\n";
  490. echo "<br />\n";
  491. echo "\n";
  492. echo "</td>\n";
  493. echo "</tr>\n";
  494. echo " <tr>\n";
  495. echo " <td colspan='2' align='right'>\n";
  496. if ($action == "update") {
  497. echo " <input type='hidden' name='php_service_uuid' value='$php_service_uuid'>\n";
  498. }
  499. echo " <input type='submit' name='submit' class='btn' value='Save'>\n";
  500. echo " </td>\n";
  501. echo " </tr>";
  502. echo "</table>";
  503. echo "</form>";
  504. echo " </td>";
  505. echo " </tr>";
  506. echo "</table>";
  507. echo "</div>";
  508. //include the footer
  509. require_once "resources/footer.php";
  510. ?>