adminSettings.js 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264
  1. /* $Id: adminSettings.js 3169 2007-08-05 12:58:59Z danez $ */
  2. /**
  3. * validateSettings
  4. */
  5. function validateSettings(section) {
  6. var msg = "";
  7. switch (section) {
  8. case 'dir':
  9. break;
  10. case 'fluxd':
  11. if (isUnsignedNumber(document.theForm.fluxd_Qmgr_interval.value) == false ) {
  12. msg = msg + "* Qmgr Interval must be a valid number.\n";
  13. document.theForm.fluxd_Qmgr_interval.focus();
  14. }
  15. if (isUnsignedNumber(document.theForm.fluxd_Qmgr_maxTotalTransfers.value) == false) {
  16. msg = msg + "* Max Total Transfers must be a valid number.\n";
  17. document.theForm.fluxd_Qmgr_maxTotalTransfers.focus();
  18. }
  19. if (isUnsignedNumber(document.theForm.fluxd_Qmgr_maxUserTransfers.value) == false) {
  20. msg = msg + "* Max User Transfers must be a valid number.\n";
  21. document.theForm.fluxd_Qmgr_maxUserTransfers.focus();
  22. }
  23. if (isUnsignedNumber(document.theForm.fluxd_Fluxinet_port.value) == false ) {
  24. msg = msg + "* Fluxinet port must be a valid number.\n";
  25. document.theForm.fluxd_Fluxinet_port.focus();
  26. }
  27. if (isUnsignedNumber(document.theForm.fluxd_Watch_interval.value) == false ) {
  28. msg = msg + "* Watch Interval must be a valid number.\n";
  29. document.theForm.fluxd_Watch_interval.focus();
  30. }
  31. if (isUnsignedNumber(document.theForm.fluxd_Maintenance_interval.value) == false) {
  32. msg = msg + "* Maintenance Interval must be a valid number.\n";
  33. document.theForm.fluxd_Maintenance_interval.focus();
  34. }
  35. if (isUnsignedNumber(document.theForm.fluxd_Trigger_interval.value) == false ) {
  36. msg = msg + "* Trigger Interval must be a valid number.\n";
  37. document.theForm.fluxd_Trigger_interval.focus();
  38. }
  39. break;
  40. case 'fluxd_Rssad_filter_new':
  41. if (document.theForm.filtername.value.length < 1) {
  42. msg = msg + "* Enter a Filtername.\n";
  43. document.theForm.filtername.focus();
  44. }
  45. break;
  46. case 'fluxd_Rssad_filter_add':
  47. if (document.theForm.filtername.value.length < 1) {
  48. msg = msg + "* Enter a Filtername.\n";
  49. document.theForm.filtername.focus();
  50. }
  51. case 'fluxd_Rssad_filter_edit':
  52. if (document.theForm.rssad_filters.options.length < 1) {
  53. msg = msg + "* Enter at least one Filter.\n";
  54. document.theForm.rssad_filter_entry.focus();
  55. }
  56. break;
  57. case 'fluxd_Rssad_job':
  58. if (document.theForm.savedir.value.length < 1) {
  59. msg = msg + "* Enter a savedir.\n";
  60. document.theForm.savedir.focus();
  61. } else {
  62. if (document.theForm.savedir.value.indexOf('/') != 0) {
  63. msg = msg + "* savedir must be an absolute path.\n";
  64. }
  65. }
  66. if (document.theForm.url.value.length < 1) {
  67. msg = msg + "* Enter a URL.\n";
  68. document.theForm.url.focus();
  69. }
  70. break;
  71. case 'fluxd_Watch_job':
  72. if (document.theForm.watchdir.value.length < 1) {
  73. msg = msg + "* Enter a watchdir.\n";
  74. document.theForm.watchdir.focus();
  75. } else {
  76. if (document.theForm.watchdir.value.indexOf('/') != 0) {
  77. msg = msg + "* watchdir must be an absolute path.\n";
  78. }
  79. }
  80. break;
  81. case 'index':
  82. if (isUnsignedNumber(document.theForm.page_refresh.value) == false ) {
  83. msg = msg + "* Page Refresh Interval must be a valid number.\n";
  84. document.theForm.page_refresh.focus();
  85. }
  86. if (isUnsignedNumber(document.theForm.index_ajax_update.value) == false ) {
  87. msg = msg + "* AJAX Update Interval must be a valid number.\n";
  88. document.theForm.index_ajax_update.focus();
  89. }
  90. if (isUnsignedNumber(document.theForm.hack_multiupload_rows.value) == false ) {
  91. msg = msg + "* multi-upload rows must be a valid number.\n";
  92. document.theForm.hack_multiupload_rows.focus();
  93. }
  94. if (isUnsignedNumber(document.theForm.bandwidth_up.value) == false ) {
  95. msg = msg + "* Bandwidth Up must be a valid number.\n";
  96. document.theForm.bandwidth_up.focus();
  97. }
  98. if (isUnsignedNumber(document.theForm.bandwidth_down.value) == false ) {
  99. msg = msg + "* Bandwidth Down must be a valid number.\n";
  100. document.theForm.bandwidth_down.focus();
  101. }
  102. break;
  103. case 'server':
  104. bwd = document.theForm.path_incoming.value.Trim();
  105. //if (bwd.indexOf('/') == 0) {
  106. // msg = msg + "* Incoming-PATH cannot be a absolute path. Incoming is a sub-dir of PATH.\n";
  107. if (bwd.indexOf('/') == 0 || bwd.indexOf('../') != -1) {
  108. msg = msg + "* Incoming-dir can only be a subdir of PATH. (specify relative Path).\n";
  109. document.theForm.path_incoming.focus();
  110. }
  111. break;
  112. case 'control':
  113. if (isUnsignedNumber(document.theForm.maxdepth.value) == false) {
  114. msg = msg + "* Max Depth must be a valid number.\n" ;
  115. }
  116. break;
  117. case 'stats':
  118. break;
  119. case 'transfer':
  120. if (isNumber(document.theForm.max_upload_rate.value) == false) {
  121. msg = msg + "* Max Upload Rate must be a valid number.\n";
  122. document.theForm.max_upload_rate.focus();
  123. }
  124. if (isNumber(document.theForm.max_download_rate.value) == false) {
  125. msg = msg + "* Max Download Rate must be a valid number.\n";
  126. document.theForm.max_download_rate.focus();
  127. }
  128. if (isNumber(document.theForm.max_uploads.value) == false) {
  129. msg = msg + "* Max # Uploads must be a valid number.\n";
  130. document.theForm.max_uploads.focus();
  131. }
  132. if (isNumber(document.theForm.maxcons.value) == false) {
  133. msg = msg + "* Max Cons must be a valid number.\n" ;
  134. }
  135. if ((isNumber(document.theForm.minport.value) == false) || (isNumber(document.theForm.maxport.value) == false)) {
  136. msg = msg + "* Port Range must have valid numbers.\n";
  137. document.theForm.minport.focus();
  138. }
  139. if ((document.theForm.maxport.value > 65535) || (document.theForm.minport.value > 65535)) {
  140. msg = msg + "* Port can not be higher than 65535.\n";
  141. document.theForm.minport.focus();
  142. }
  143. if ((document.theForm.maxport.value < 0) || (document.theForm.minport.value < 0)) {
  144. msg = msg + "* Can not have a negative number for port value.\n";
  145. document.theForm.minport.focus();
  146. }
  147. if (document.theForm.maxport.value < document.theForm.minport.value) {
  148. msg = msg + "* Port Range is not valid.\n";
  149. document.theForm.minport.focus();
  150. }
  151. if (isNumber(document.theForm.rerequest_interval.value) == false) {
  152. msg = msg + "* Rerequest Interval must have a valid number.\n";
  153. document.theForm.rerequest_interval.focus();
  154. }
  155. if (document.theForm.rerequest_interval.value < 10) {
  156. msg = msg + "* Rerequest Interval must be 10 or greater.\n";
  157. document.theForm.rerequest_interval.focus();
  158. }
  159. if (isNumber(document.theForm.sharekill.value) == false) {
  160. msg = msg + "* Keep seeding until Sharing % must be a valid number.\n";
  161. document.theForm.sharekill.focus();
  162. }
  163. if (isNumber(document.theForm.wget_limit_rate.value) == false) {
  164. msg = msg + "* wget Download Rate must be a valid number.\n";
  165. document.theForm.wget_limit_rate.focus();
  166. }
  167. if (isNumber(document.theForm.wget_limit_retries.value) == false) {
  168. msg = msg + "* wget Limit Number of Retries must be a valid number.\n";
  169. document.theForm.wget_limit_retries.focus();
  170. }
  171. if (isNumber(document.theForm.nzbperl_rate.value) == false) {
  172. msg = msg + "* nzbperl Download Rate must be a valid number.\n";
  173. document.theForm.nzbperl_rate.focus();
  174. }
  175. if (isNumber(document.theForm.nzbperl_conn.value) == false) {
  176. msg = msg + "* nzbperl Connections must be a valid number.\n";
  177. document.theForm.nzbperl_conn.focus();
  178. }
  179. if (isNumber(document.theForm.nzbperl_threads.value) == false) {
  180. msg = msg + "* nzbperl Threads must be a valid number.\n";
  181. document.theForm.nzbperl_threads.focus();
  182. }
  183. break;
  184. case 'fluazu':
  185. if (document.theForm.fluazu_host.value.length < 1) {
  186. msg = msg + "* Host cannot be empty.\n";
  187. document.theForm.fluazu_host.focus();
  188. }
  189. if (isUnsignedNumber(document.theForm.fluazu_port.value) == false) {
  190. msg = msg + "* Port must be a valid number.\n";
  191. document.theForm.fluazu_port.focus();
  192. }
  193. break;
  194. case 'azureus':
  195. if (isUnsignedNumber(document.azuForm.CORE_PARAM_INT_MAX_DOWNLOAD_SPEED_KBYTES_PER_SEC.value) == false) {
  196. msg = msg + "* Max Download Speed KBs must be a valid number.\n";
  197. document.azuForm.CORE_PARAM_INT_MAX_DOWNLOAD_SPEED_KBYTES_PER_SEC.focus();
  198. }
  199. if (isUnsignedNumber(document.azuForm.CORE_PARAM_INT_MAX_UPLOAD_SPEED_KBYTES_PER_SEC.value) == false) {
  200. msg = msg + "* Max Upload Speed KBs must be a valid number.\n";
  201. document.azuForm.CORE_PARAM_INT_MAX_UPLOAD_SPEED_KBYTES_PER_SEC.focus();
  202. }
  203. break;
  204. case 'webapp':
  205. if (isUnsignedNumber(document.theForm.transferStatsUpdate.value) == false) {
  206. msg = msg + "* Download-Details Update Interval must be a valid number.\n";
  207. document.theForm.transferStatsUpdate.focus();
  208. }
  209. if (isUnsignedNumber(document.theForm.servermon_update.value) == false) {
  210. msg = msg + "* Server Monitor Update Interval must be a valid number.\n";
  211. document.theForm.servermon_update.focus();
  212. }
  213. if (isUnsignedNumber(document.theForm.days_to_keep.value) == false) {
  214. msg = msg + "* Days to keep Audit Actions must be a valid number.\n";
  215. document.theForm.days_to_keep.focus();
  216. }
  217. if (isUnsignedNumber(document.theForm.minutes_to_keep.value) == false) {
  218. msg = msg + "* Minutes to keep user online must be a valid number.\n";
  219. document.theForm.minutes_to_keep.focus();
  220. }
  221. if (isUnsignedNumber(document.theForm.rss_cache_min.value) == false) {
  222. msg = msg + "* Minutes to Cache RSS Feeds must be a valid number.\n";
  223. document.theForm.rss_cache_min.focus();
  224. }
  225. break;
  226. case 'xfer':
  227. if (isUnsignedNumber(document.theForm.xfer_total.value) == false) {
  228. msg = msg + "* xfer total must be a valid number.\n";
  229. document.theForm.xfer_total.focus();
  230. }
  231. if (isUnsignedNumber(document.theForm.xfer_month.value) == false) {
  232. msg = msg + "* xfer month must be a valid number.\n";
  233. document.theForm.xfer_month.focus();
  234. }
  235. if (isUnsignedNumber(document.theForm.xfer_week.value) == false) {
  236. msg = msg + "* xfer week must be a valid number.\n";
  237. document.theForm.xfer_week.focus();
  238. }
  239. if (isUnsignedNumber(document.theForm.xfer_day.value) == false) {
  240. msg = msg + "* xfer day must be a valid number.\n";
  241. document.theForm.xfer_day.focus();
  242. }
  243. break;
  244. }
  245. if (msg != "") {
  246. alert("Please check the following:\n\n" + msg);
  247. return false;
  248. } else {
  249. return true;
  250. }
  251. }
  252. /**
  253. * performRefresh
  254. *
  255. * Refresh theForm without executing its onsubmit code (used when a select
  256. * has changed and the form must be reloaded to show new values).
  257. */
  258. function performRefresh() {
  259. var f = document.theForm;
  260. f.refresh.value = '1';
  261. f.submit();
  262. }