htmlgen.pm 54 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239
  1. #######################################################################
  2. # htmlgen.pm
  3. #
  4. # These routines generate the HTML for the GnuDIP
  5. # Web interface.
  6. #
  7. # See COPYING for licensing information.
  8. #
  9. #######################################################################
  10. # Perl modules
  11. use strict;
  12. # global variables
  13. use vars qw($conf);
  14. use vars qw($pref $userinfo $remote_ip);
  15. use vars qw($reqparm $thiscgi $thishost $thisurl);
  16. use vars qw($htmlgen_header $htmlgen_trailer);
  17. # GnuDIP common subroutines
  18. use gdiplib;
  19. use gdipcgi_cmn;
  20. use gdipmailchk;
  21. # variables global to this file
  22. # - may be included in all pages
  23. my ($title, $head, $headtxt, $topline, $trailerline, $bodytxt, $body, $bodyend, $html_dir);
  24. #######################################################################
  25. # initialise global variables
  26. #######################################################################
  27. sub htmlgen_init {
  28. # title
  29. $title = "GnuDIP Web Interface";
  30. $headtxt = tst(qq*
  31. <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
  32. <title>$title</title>*);
  33. $head = tst(qq*
  34. <head>
  35. $headtxt
  36. </head>*);
  37. # HTML to insert after <body>
  38. if (! defined $htmlgen_header or
  39. ! defined $$conf{'persistance'} or
  40. $$conf{'persistance'} ne 'YES') {
  41. my $headerfile = $$conf{'header_file'};
  42. $headerfile = '' if !defined($headerfile);
  43. $htmlgen_header = '';
  44. if ($headerfile and open(HEADER,"$headerfile")) {
  45. while (my $line = <HEADER>) {
  46. $htmlgen_header .= $line;
  47. };
  48. close HEADER;
  49. }
  50. }
  51. # HTML to insert before </body>
  52. if (! defined $htmlgen_trailer or
  53. ! defined $$conf{'persistance'} or
  54. $$conf{'persistance'} ne 'YES') {
  55. my $trailerfile = $$conf{'trailer_file'};
  56. $trailerfile = '' if !defined($trailerfile);
  57. $htmlgen_trailer = '';
  58. if ($trailerfile and open(TRAILER,"$trailerfile")) {
  59. while (my $line = <TRAILER>) {
  60. $htmlgen_trailer .= $line;
  61. };
  62. close TRAILER;
  63. }
  64. }
  65. # offset to HTML directory
  66. $html_dir = $$conf{'html_dir'};
  67. $html_dir = '../html' if !$html_dir;
  68. # stuff for top of each page
  69. $topline = $htmlgen_header . tst(qq*
  70. <center><table><tr>
  71. <td>
  72. <img align=middle src="$html_dir/gnudip.jpg" alt="GnuDIP Logo"
  73. border=0 height=60 width=113>
  74. </td>
  75. <td><table>
  76. <tr><td><center><h1>$title</h1></center></td></tr>
  77. <tr><td width="100%"><table width="100%" border=1><tr>
  78. <td><center>
  79. <a href="$html_dir/help.html" target=_blank>Help</a>
  80. </center></td>
  81. </tr></table></td></tr>
  82. </table></td>
  83. </tr></table></center>*);
  84. # for starting and ending HTML body
  85. $bodytxt = "body bgcolor=\"FFFFFF\"";
  86. $body = "<$bodytxt>";
  87. $bodyend = $htmlgen_trailer . '</body>';
  88. }
  89. #######################################################################
  90. # login
  91. #######################################################################
  92. sub pg_login {
  93. header();
  94. tpr(qq*
  95. <html>
  96. <head>
  97. $headtxt
  98. <script type="text/javascript">
  99. function sethidden() {
  100. document.forms["login"].localaddr.value="nojava";
  101. document.forms["login"].localaddr.value=document.IPdetect.getLocal();
  102. document.forms["login"].errormsg.value=document.IPdetect.getMsg();
  103. }
  104. </script>
  105. </head>
  106. <$bodytxt onload="sethidden()">
  107. $topline
  108. <center><h2>Login</h2></center>
  109. <form action="$thiscgi" method="post" name="login">
  110. <input type=hidden name="page" value="login">
  111. <input name="localaddr" type=hidden value="nojavascript">
  112. <input name="errormsg" type=hidden value="">
  113. <center>
  114. <table>
  115. <tr>
  116. <td>Username/Hostname</td>
  117. <td><input type="text" name="username"></td>
  118. </tr>
  119. *);
  120. if ($$pref{'SHOW_DOMAINLIST'} eq 'YES') {
  121. html_domain('','domain');
  122. } else {
  123. tpr(qq*
  124. <tr>
  125. <td>Domain</td>
  126. <td><input type="text" name="domain"></td></tr>
  127. *);
  128. }
  129. tpr(qq*
  130. <tr>
  131. <td>Password</td>
  132. <td><input type="password" name="password"></td>
  133. </tr>
  134. </table>
  135. <table><tr>
  136. <td>
  137. <input type="submit" name="login" value="Login">
  138. </td>
  139. *);
  140. if ($$pref{'SEND_URL'} eq 'YES') {
  141. if (!$$conf{'URL_sendURL'}) {
  142. tpr(qq*
  143. <td>
  144. <input type="submit" name="sendURL" value="Forgotten Password">
  145. </td>
  146. *);
  147. } else {
  148. tpr(qq*
  149. <td>
  150. <table border=1><tr><td>
  151. <a href="$$conf{'URL_sendURL'}">Forgotten Password</a>
  152. </td></tr></table>
  153. </td>
  154. *);
  155. }
  156. }
  157. if ($$pref{'ADD_SELF'} eq 'YES') {
  158. if (!$$conf{'URL_self_signup'}) {
  159. tpr(qq*
  160. <td>
  161. <input type="submit" name="self_signup" value="Self Register">
  162. </td>
  163. *);
  164. } else {
  165. tpr(qq*
  166. <td>
  167. <table border=1><tr><td>
  168. <a href="$$conf{'URL_self_signup'}">Self Register</a>
  169. </td></tr></table>
  170. </td>
  171. *);
  172. }
  173. }
  174. tpr(qq*
  175. </tr></table>
  176. </center>
  177. </form>
  178. $htmlgen_trailer<applet codebase="$html_dir/" code="IPdetect.class" name="IPdetect"
  179. height=0 width=0>
  180. </applet>
  181. </body>
  182. </html>
  183. *);
  184. exit;
  185. }
  186. #######################################################################
  187. # forgotten password
  188. #######################################################################
  189. sub pg_sendURL {
  190. # ensure initialized
  191. default_empty('sendURL_username');
  192. header();
  193. tpr(qq*
  194. <html>
  195. <head>
  196. $headtxt
  197. </head>
  198. $body
  199. $topline
  200. <center><h2>Forgotten Password</h2>
  201. <font color="red" size="+1">
  202. Enter your username and domain
  203. <br>
  204. A Quick Login URL will be sent to the E-mail address on record
  205. </font></center>
  206. <form action="$thiscgi" method="post">
  207. <input type=hidden name="page" value="sendURL">
  208. <center>
  209. <table>
  210. <tr>
  211. <td>Username/Hostname</td>
  212. <td><input type="text" name="sendURL_username" value="$$reqparm{'sendURL_username'}"></td>
  213. </tr>
  214. *);
  215. if ($$pref{'SHOW_DOMAINLIST'} eq 'YES') {
  216. html_domain('','domain');
  217. } else {
  218. tpr(qq*
  219. <tr>
  220. <td>Domain</td>
  221. <td><input type="text" name="domain"></td></tr>
  222. *);
  223. }
  224. tpr(qq*
  225. </table>
  226. *);
  227. # ensure not a robot
  228. mchk_html();
  229. tpr(qq*
  230. <br>
  231. <input type="submit" name="do_sendURL" value="Send E-mail">
  232. </center>
  233. </form>
  234. $bodyend
  235. </html>
  236. *);
  237. exit;
  238. }
  239. #######################################################################
  240. # Quick Login URL E-mail sent
  241. #######################################################################
  242. sub pg_sentURL {
  243. my $email = shift;
  244. pg_msg(qq*
  245. Quick Login URL E-mail Sent
  246. *,qq*
  247. An E-mail has been sent to the E-mail address on record for this host,
  248. containing a Quick Login URL (i.e., www address).<br>
  249. When you receive the E-mail, connect to the URL in your browser to
  250. login.
  251. *);
  252. }
  253. #######################################################################
  254. # self signup
  255. #######################################################################
  256. sub pg_self {
  257. pg_error("no_addself") if $$pref{'ADD_SELF'} ne 'YES';
  258. header();
  259. tpr(qq*
  260. <html>
  261. $head
  262. $body
  263. $topline
  264. <center><h2>Self Registration</h2></center>
  265. <form action="$thiscgi" method="post">
  266. <input type=hidden name="page" value="doself">
  267. <center>
  268. <table>
  269. <tr><td>Username/Hostname</td>
  270. <td><input type="text" name="new_username"></td>
  271. </tr>
  272. *);
  273. tpr(qq*
  274. <tr><td>Domain</td>
  275. <td>
  276. <select name="new_domain">
  277. *);
  278. my $domains = getdomains();
  279. foreach my $domain (@$domains) {
  280. if ($$domain{'addself'} eq 'YES') {
  281. tpr(qq*
  282. <option value="$$domain{'domain'}">$$domain{'domain'}</option>
  283. *);
  284. }
  285. }
  286. tpr(qq*
  287. </select>
  288. </td></tr>
  289. *);
  290. tpr(qq*
  291. <tr><td>E-Mail Address</td>
  292. <td><input type="text" name="new_email"></td>
  293. </tr>
  294. <tr><td>Password</td>
  295. <td><input type="password" name="new_password" value=""></td>
  296. </tr>
  297. <tr><td>Password Again</td>
  298. <td><input type="password" name="new_password1" value=""></td>
  299. </tr>
  300. </table>
  301. </center>
  302. *);
  303. # ensure not a robot
  304. mchk_html();
  305. tpr(qq*
  306. <br>
  307. <center><input type="submit" name="do_signup" value="Register">&nbsp;
  308. <input type="reset" value="Clear Form">
  309. </center>
  310. </form>
  311. $bodyend
  312. </html>
  313. *);
  314. exit;
  315. }
  316. #######################################################################
  317. # self signup E-mail sent
  318. #######################################################################
  319. sub pg_selfemail {
  320. my $email = shift;
  321. pg_msg(qq*
  322. Self Registration E-mail Sent
  323. *,qq*
  324. An E-mail has been sent to $email, containing a URL (i.e., www address).<br>
  325. When you receive the E-mail, connect to the URL in your browser to
  326. complete the self registration process.
  327. *);
  328. }
  329. #######################################################################
  330. # self signup done
  331. #######################################################################
  332. sub pg_didself {
  333. pg_msg(qq*
  334. Registration Successful
  335. *,qq*
  336. Your registration was successful.<br>
  337. Please return to the login page.
  338. *);
  339. }
  340. #######################################################################
  341. # E-mail update E-mail sent
  342. #######################################################################
  343. sub pg_newemail {
  344. my $email = shift;
  345. pg_msg(qq*
  346. E-mail Update E-mail Sent
  347. *,qq*
  348. An E-mail has been sent to $email, containing a URL (i.e., www address).<br>
  349. When you receive the E-mail, connect to the URL in your browser to
  350. complete the E-mail address update process.
  351. *);
  352. }
  353. #######################################################################
  354. # E-mail update done
  355. #######################################################################
  356. sub pg_didemail {
  357. pg_msg(qq*
  358. E-mail Address Update Successful
  359. *,qq*
  360. Your E-mail address update was successful.
  361. *);
  362. }
  363. #######################################################################
  364. # no forward URL set
  365. #######################################################################
  366. sub pg_noforwardurl {
  367. pg_msg(qq*
  368. Auto Update Successful but Forward URL Not Set
  369. *,qq*
  370. Your username and password were verified and your hostname now points
  371. to your new IP <i>$remote_ip</i>.
  372. <p>
  373. However you have not set a URL to forward to.
  374. <br>
  375. Please set a Forward URL in your GnuDIP settings.
  376. *);
  377. }
  378. #######################################################################
  379. # AutoURL test succeeded
  380. #######################################################################
  381. sub pg_goodautourl {
  382. pg_msg(qq*
  383. AutoURL Test Succeeded
  384. *,qq*
  385. Your username and password were verified and your hostname
  386. now points to your new IP <i>$remote_ip</i>.
  387. <p>
  388. Set this page as your default page and from now on it will
  389. automatically forward you to your Forward URL under the
  390. settings menu.
  391. *);
  392. }
  393. #######################################################################
  394. # user options
  395. #######################################################################
  396. sub pg_options {
  397. # ensure initialized
  398. default_empty('localaddr');
  399. default_empty('user_pattern');
  400. default_empty('errormsg');
  401. header();
  402. tpr(qq*
  403. <html>
  404. $head
  405. $body
  406. *);
  407. if ($$pref{'DELETE_SELF'} eq 'YES' and !$$conf{'URL_delthisuser'}) {
  408. tpr(qq*
  409. <script type="text/javascript">
  410. function test() {
  411. message=("Delete Current User?")
  412. if(confirm(message)) {
  413. return true
  414. } else {
  415. return false
  416. }
  417. }
  418. </script>
  419. *);
  420. }
  421. tpr(qq*
  422. $topline
  423. *);
  424. my $updateaddr = $remote_ip;
  425. if ($$userinfo{'level'} eq 'USER') {
  426. tpr(qq*
  427. <center>
  428. <font color="red" size="+1">
  429. Hostname $$userinfo{'username'}.$$userinfo{'domain'}
  430. Currently Points to $$userinfo{'currentip'}
  431. <br>
  432. <i>(Updated at $$userinfo{'updated'})</i>
  433. </font>
  434. <p>
  435. <font color="red" size="+1">
  436. The computer that connected to GnuDIP has IP address $remote_ip
  437. </font>
  438. <p>
  439. <font color="red" size="+1">
  440. *);
  441. if ($$reqparm{'localaddr'} eq 'nojavascript') {
  442. tpr(qq*
  443. GnuDIP cannot determine if $remote_ip is the IP address of your
  444. computer.
  445. <br>
  446. Javascript is not enabled in your browser.
  447. *);
  448. } elsif ($$reqparm{'localaddr'} eq 'nojava') {
  449. tpr(qq*
  450. GnuDIP cannot determine if $remote_ip is the IP address of your
  451. computer.
  452. <br>
  453. Java is not enabled in your browser.
  454. *);
  455. } elsif ($$reqparm{'localaddr'} eq 'javaerror') {
  456. writelog('Error occured in Java applet:');
  457. writelog(" message: $$reqparm{'errormsg'}");
  458. tpr(qq*
  459. GnuDIP cannot determine if $remote_ip is the IP address of your
  460. computer.
  461. <br>
  462. The Java applet for doing this has failed with the following message:
  463. <blockquote>
  464. $$reqparm{'errormsg'}
  465. </blockquote>
  466. *);
  467. } elsif (validdotquad($$reqparm{'localaddr'})) {
  468. $updateaddr = $$reqparm{'localaddr'};
  469. tpr(qq*
  470. The computer your browser is running on has IP address $updateaddr
  471. *);
  472. } elsif ($$reqparm{'localaddr'}) {
  473. writelog('Error occured in Java applet:');
  474. writelog(" invalid IP address: $$reqparm{'localaddr'}");
  475. tpr(qq*
  476. GnuDIP cannot determine if $remote_ip is the IP address of your
  477. computer.
  478. <br>
  479. The Java applet for doing this has failed. It returned an invalid IP
  480. address.
  481. *);
  482. } else {
  483. tpr(qq*
  484. Browser based IP address detection was not done
  485. *);
  486. }
  487. tpr(qq*
  488. </font>
  489. </center>
  490. *);
  491. }
  492. tpr(qq*
  493. <center><h2>User Options</h2></center>
  494. *);
  495. if ($$reqparm{'updatehost'}) {
  496. tpr(qq*
  497. <center><font size="+1"><b>
  498. Update done for $$userinfo{'username'}.$$userinfo{'domain'}
  499. </b></font></center>
  500. <p>
  501. *);
  502. } elsif ($$reqparm{'offline'}) {
  503. tpr(qq*
  504. <center><font size="+1"><b>
  505. Offline done for $$userinfo{'username'}.$$userinfo{'domain'}
  506. </b></font></center>
  507. <p>
  508. *);
  509. }
  510. tpr(qq*
  511. <form action="$thiscgi" method="post">
  512. <input type=hidden name="page" value="options">
  513. *);
  514. html_user();
  515. $$reqparm{'updateaddr'} = $updateaddr if ! defined $$reqparm{'updateaddr'};
  516. tpr(qq*
  517. <input type=hidden name="localaddr" value="$$reqparm{'localaddr'}">
  518. <input type=hidden name="errormsg" value="$$reqparm{'errormsg'}">
  519. <center>
  520. <table>
  521. *);
  522. if ($$userinfo{'level'} eq "USER") {
  523. tpr(qq*
  524. <tr><td>Update <b>$$userinfo{'username'}.$$userinfo{'domain'}</b></td>
  525. <td><input type=submit name="updatehost" value="Go"></td>
  526. </tr>
  527. <tr><td align="center">to</td>
  528. <td><input type=text name="updateaddr" value="$$reqparm{'updateaddr'}"></td>
  529. </tr>
  530. <tr><td>Offline <b>$$userinfo{'username'}.$$userinfo{'domain'}</b></td>
  531. <td><input type=submit name="offline" value="Go"></td>
  532. </tr>
  533. *);
  534. }
  535. tpr(qq*
  536. <tr><td>Change Settings</td>
  537. <td><input type=submit name="changesettings" value="Go"></td>
  538. </tr>
  539. *);
  540. if ($$userinfo{'level'} eq 'USER' and
  541. $$pref{'REQUIRE_EMAIL'} eq 'YES') {
  542. tpr(qq*
  543. <tr><td>Change E-mail Address</td>
  544. <td><input type=submit name="changemail" value="Go"></td>
  545. </tr>
  546. *);
  547. }
  548. if ($$userinfo{'level'} eq 'USER' and
  549. $$pref{'ALLOW_AUTO_URL'} eq 'YES') {
  550. tpr(qq*
  551. <tr><td>Set Auto URL</td>
  552. <td><input type=submit name="setautourl" value="Go"></td>
  553. </tr>
  554. *);
  555. }
  556. if ($$userinfo{'level'} eq 'ADMIN') {
  557. tpr(qq*
  558. <tr><td>Add User</td>
  559. <td><input type=submit name="manageusers_adduser" value="Go"></td>
  560. </tr>
  561. <tr><td>Manage Users</td>
  562. <td><input type=submit name="manageusers_main" value="Go"></td>
  563. </tr>
  564. <tr><td>&nbsp;</td>
  565. <td>User Pattern:</td>
  566. <td><input type=text name="user_pattern"
  567. value="$$reqparm{'user_pattern'}"></td>
  568. </tr>
  569. <tr><td>&nbsp;</td>
  570. <td>&nbsp;</td>
  571. <td><table>
  572. <tr><td>\*</td><td>-</td><td>zero or more characters</td></tr>
  573. <tr><td>?</td><td>-</td><td>one character</td></tr>
  574. </table></td>
  575. <tr><td>Add Domain</td>
  576. <td><input type=submit name="managedomains_add" value="Go"></td>
  577. </tr>
  578. <tr><td>Manage Domains</td>
  579. <td><input type=submit name="managedomains_main" value="Go"></td>
  580. </tr>
  581. <tr><td>Administrative Settings</td>
  582. <td><input type=submit name="system_settings" value="Go"></td>
  583. </tr>
  584. *);
  585. }
  586. if ($$pref{'DELETE_SELF'} eq 'YES') {
  587. tpr(qq*
  588. <tr><td>&nbsp;</td></tr>
  589. <tr><td>Delete Current User</td><td>
  590. *);
  591. if (!$$conf{'URL_delthisuser'}) {
  592. tpr(qq*
  593. <input type=submit name="do_delthisuser" value="Delete"
  594. onclick="return test()">
  595. *);
  596. } else {
  597. # sign the self delete information
  598. my $checkval = md5_base64(
  599. $$userinfo{'username'} . '.' .
  600. $$userinfo{'domain'} . '.' .
  601. $$pref{'SERVER_KEY'}
  602. );
  603. # the URL must have a question mark and any other
  604. # parameters already in it
  605. my $url = $$conf{'URL_delthisuser'};
  606. $url .= 'user=' . $$userinfo{'username'};
  607. $url .= '&amp;domn=' . $$userinfo{'domain'};
  608. $url .= '&amp;sign=' . uri_escape($checkval);
  609. tpr(qq*
  610. <table border=1><tr><td>
  611. <a href="$url">Delete</a>
  612. </td></tr></table>
  613. *);
  614. }
  615. tpr(qq*
  616. </td></tr>
  617. *);
  618. }
  619. tpr(qq*
  620. </table>
  621. </center>
  622. </form>
  623. *);
  624. # button for setting Quick Login
  625. my $detect;
  626. my $quick = "$thisurl?";
  627. if ($updateaddr eq $$reqparm{'localaddr'}) {
  628. $quick .= 'login=ipdetect';
  629. $detect = 'yes';
  630. } else {
  631. $quick .= 'login=enc';
  632. $detect = 'no';
  633. }
  634. $quick .=
  635. "&amp;username=$$userinfo{'username'}" .
  636. "&amp;password=$$userinfo{'password'}";
  637. if ($$userinfo{'level'} eq 'USER') {
  638. $quick .= "&amp;domain=$$userinfo{'domain'}";
  639. }
  640. tpr(qq*
  641. <form action="$quick" method="post">
  642. <input type=hidden name="page" value="options">
  643. *);
  644. html_user();
  645. tpr(qq*
  646. <input type=hidden name="detect" value="$detect">
  647. <input type=hidden name="quick" value="$quick">
  648. <center>
  649. <input type=submit name="setquick" value="Set Quick Login URL">
  650. </center>
  651. </form>
  652. $bodyend
  653. </html>
  654. *);
  655. exit;
  656. }
  657. #######################################################################
  658. # user settings
  659. #######################################################################
  660. sub pg_usersettings {
  661. pg_cmn_edituser($userinfo);
  662. }
  663. #######################################################################
  664. # current user deleted
  665. #######################################################################
  666. sub pg_usergone {
  667. pg_msg(qq*
  668. Current User Deleted
  669. *,qq*
  670. The current user has been deleted.
  671. <br>
  672. Please go back to the previous Login page.
  673. *);
  674. }
  675. #######################################################################
  676. # set quick login
  677. #######################################################################
  678. sub pg_setquick {
  679. # "&" has to become "&amp;" in HTML
  680. my $quick = $$reqparm{'quick'};
  681. $quick =~ s/\&/\&amp;/g;
  682. header();
  683. tpr(qq*
  684. <html>
  685. $head
  686. $body
  687. $topline
  688. <center>
  689. <h2>Set Quick Login URL</h2>
  690. <h3>Create a new Favorite or Bookmark now</h3>
  691. <p>
  692. <h3>Or in Windows create a Shortcut<br>Right click on this link:</h3>
  693. <p>
  694. <table border=2><tr><td>
  695. <a href="$quick">GnuDIP Quick Login</a>
  696. </td></tr></table>
  697. <p>
  698. The Favorite, Bookmark or Shortcut will do Quick Login.
  699. *);
  700. if ($$reqparm{'detect'} eq 'no') {
  701. tpr(q*
  702. <p>
  703. <font color=red>
  704. This URL will not do IP address detection.
  705. <br>
  706. Either Javascript or Java is not enabled in your browser.
  707. </font>
  708. *);
  709. }
  710. tpr(qq*
  711. </center>
  712. $bodyend
  713. </html>
  714. *);
  715. exit;
  716. }
  717. #######################################################################
  718. # Quick Login IP detection
  719. #######################################################################
  720. sub pg_ipdetect {
  721. header();
  722. tpr(qq*
  723. <html>
  724. <head>
  725. $headtxt
  726. <script type="text/javascript">
  727. function winload() {
  728. var newurl;
  729. newurl = "$thisurl?" +
  730. "login=enc&username=$$reqparm{'username'}&" +
  731. "domain=$$reqparm{'domain'}&password=$$reqparm{'password'}";
  732. newurl += "&localaddr=" + document.IPdetect.getLocal();
  733. if (document.IPdetect.getLocal() == "javaerror")
  734. newurl += "&errormsg=" + document.IPdetect.getMsg();
  735. window.location.replace(newurl);
  736. }
  737. </script>
  738. </head>
  739. <$bodytxt onload=\"winload()\">
  740. <noscript>
  741. <p>
  742. <font color=red>
  743. Javascript support is not enabled in this browser.
  744. </font>
  745. Javascript support is required for IP address detection.
  746. </noscript>
  747. <applet codebase="$html_dir/" code="IPdetect.class"
  748. name="IPdetect" height=0 width=0>
  749. <p>
  750. <font color=red>
  751. Java support is not enabled in this browser.
  752. </font>
  753. Java support is required for IP address detection.
  754. </applet>
  755. </body>
  756. </html>
  757. *);
  758. exit;
  759. }
  760. #######################################################################
  761. # add domain
  762. #######################################################################
  763. sub pg_adddomain {
  764. # must be admin
  765. pg_error('not_admin') if $$userinfo{'level'} ne 'ADMIN';
  766. header();
  767. tpr(qq*
  768. <html>
  769. $head
  770. $body
  771. $topline
  772. <center>
  773. <h2>Add Domain</h2>
  774. <font color="red">
  775. New domains are added at the end of the list
  776. </font>
  777. <p>
  778. <font color="red">
  779. You may delete and re-add a domain
  780. <br>
  781. Updates using the client will not be affected
  782. <br>
  783. Web Tool users for that domain cannot login until the domain is re-added
  784. </font>
  785. </center>
  786. <form action="$thiscgi" method="post">
  787. <input type=hidden name="page" value="adddomain">
  788. *);
  789. html_user();
  790. default_empty('adddomain_new_domain');
  791. default_empty('ALLOW_CHANGEPASS');
  792. default_empty('ADDSELF');
  793. my $check_pass = setcheck($$reqparm{'ALLOW_CHANGEPASS'});
  794. my $check_self = setcheck($$reqparm{'ADDSELF'});
  795. tpr(qq*
  796. <center>
  797. <table>
  798. <tr><td>Domain Name</td>
  799. <td><input type="text" name="adddomain_new_domain" value="$$reqparm{'adddomain_new_domain'}"></td></tr>
  800. <tr><td>Allow Password Changes</td>
  801. <td><input type="checkbox" name="ALLOW_CHANGEPASS" value="YES" $check_pass></td></tr>
  802. <tr><td>Self Registration</td>
  803. <td><input type="checkbox" name="ADDSELF" value="YES" $check_self></td></tr>
  804. </table>
  805. <br>
  806. <input type="submit" name="do_adddomain" value="Add Domain">
  807. </center>
  808. </form>
  809. $bodyend
  810. </html>
  811. *);
  812. exit;
  813. }
  814. #######################################################################
  815. # manage domains
  816. #######################################################################
  817. sub pg_managedomains {
  818. # must be admin
  819. pg_error('not_admin') if $$userinfo{'level'} ne 'ADMIN';
  820. # get domains from database
  821. my $domains = getdomains();
  822. header();
  823. tpr(qq*
  824. <html>
  825. $head
  826. $body
  827. <script type="text/javascript">
  828. function test() {
  829. message=("Delete Selected Domains?")
  830. if(confirm(message)) {
  831. return true
  832. } else {
  833. return false
  834. }
  835. }
  836. </script>
  837. $topline
  838. <center><h2>Manage Domains</h2></center>
  839. <form action="$thiscgi" method="post">
  840. <input type=hidden name="page" value="managedomains">
  841. *);
  842. html_user();
  843. tpr(qq*
  844. <center>
  845. <table border=1>
  846. <tr>
  847. <th>Domain</th>
  848. <th>Allow Password Changes</th>
  849. <th>Allow Add Self</th>
  850. <th>Edit Domain</th>
  851. <th>Delete Domain</th></tr>
  852. *);
  853. foreach my $dominfo (@$domains) {
  854. tpr(qq*
  855. <tr align="center">
  856. <td>$$dominfo{'domain'}</td>
  857. <td>$$dominfo{'changepass'}</td>
  858. <td>$$dominfo{'addself'}</td>
  859. <td><input type=radio name="editdom" value="$$dominfo{'domain'}"></td>
  860. <td><input type=checkbox name="deldom" value="$$dominfo{'domain'}"></td></tr>
  861. *);
  862. }
  863. tpr(qq*
  864. </table>
  865. <br>
  866. <br>
  867. <input type=submit name="managedomains_edit" value="Edit Selected Domain">
  868. &nbsp;
  869. <input type=submit name="do_deldomain" value="Delete Selected Domains"
  870. onclick="return test()">
  871. </center>
  872. </form>
  873. $bodyend
  874. </html>
  875. *);
  876. exit;
  877. }
  878. #######################################################################
  879. # edit domain
  880. #######################################################################
  881. sub pg_editdomain {
  882. my $dinfo = shift;
  883. # must be admin
  884. pg_error('not_admin') if $$userinfo{'level'} ne 'ADMIN';
  885. # domain not passed but domain name available?
  886. if (!$dinfo and $$reqparm{'editdom'}) {
  887. $dinfo = getdomain($$reqparm{'editdom'});
  888. pg_error('bad_sel_domain') if !$dinfo;
  889. }
  890. header();
  891. tpr(qq*
  892. <html>
  893. $head
  894. $body
  895. $topline
  896. <center><h2>Edit Domain</font></h2></center>
  897. *);
  898. # do we have a domain to edit?
  899. if (!$dinfo) {
  900. tpr(qq*
  901. <center>
  902. <h3>
  903. No domain has been selected
  904. <br>
  905. Please go back and select a domain
  906. </h3>
  907. </center>
  908. $bodyend
  909. </html>
  910. *);
  911. exit;
  912. }
  913. # reshowing this page?
  914. if ($$reqparm{'do_editdomain'}) {
  915. tpr(qq*
  916. <center><font size="+1"><b>
  917. Previous changes saved
  918. </b></font></center>
  919. <p>
  920. *);
  921. }
  922. my $cpcheck = setcheck($$dinfo{'changepass'});
  923. my $ascheck = setcheck($$dinfo{'addself'});
  924. tpr(qq*
  925. <form action="$thiscgi" method="post">
  926. <input type=hidden name="page" value="editdomain">
  927. *);
  928. html_user();
  929. tpr(qq*
  930. <input type=hidden name="editdom" value="$$dinfo{'domain'}">
  931. <center>
  932. <table>
  933. <tr><td>Domain</td>
  934. <td><input type="text" name="new_domain" value="$$dinfo{'domain'}"></td>
  935. </tr>
  936. <tr><td>Allow Password Changes</td>
  937. <td><input type="checkbox" name="ALLOW_CHANGEPASS"
  938. value="YES"$cpcheck></td></tr>
  939. <tr><td>Self Registration</td>
  940. <td><input type="checkbox" name="ADDSELF"
  941. value="YES"$ascheck></td></tr>
  942. </table>
  943. <br>
  944. <input type="submit" name="do_editdomain" value="Save Changes">
  945. </center>
  946. </form>
  947. $bodyend
  948. </html>
  949. *);
  950. exit;
  951. }
  952. #######################################################################
  953. # add user (by admin)
  954. #######################################################################
  955. sub pg_adduser {
  956. # must be admin
  957. pg_error('not_admin') if $$userinfo{'level'} ne 'ADMIN';
  958. header();
  959. tpr(qq*
  960. <html>
  961. $head
  962. $body
  963. $topline
  964. <center><h2>Add User</h2></center>
  965. <form action="$thiscgi" method="post">
  966. <input type=hidden name="page" value="adduser">
  967. *);
  968. html_user();
  969. tpr(qq*
  970. <center>
  971. <table>
  972. <tr><td>Username/Hostname</td>
  973. <td><input type="text" name="new_username"></td></tr>
  974. *);
  975. html_domain();
  976. tpr(qq*
  977. <tr><td>E-Mail Address</td>
  978. <td><input type="text" name="new_email"></td></tr>
  979. <tr><td>Disable Password</td>
  980. <td><input type="checkbox" name="disable" value="YES"></td></tr>
  981. <tr><td>New Password</td>
  982. <td><input type="password" name="new_password" value=""></td></tr>
  983. <tr><td>New Password Again</td>
  984. <td><input type="password" name="new_password1" value=""></td></tr>
  985. <tr><td>Admin</td>
  986. <td><input type="checkbox" name="user_level" value="ADMIN"></td></tr>
  987. </table>
  988. <br>
  989. <input type="submit" name="do_adduser" value="Add User">
  990. </center>
  991. </form>
  992. $bodyend
  993. </html>
  994. *);
  995. exit;
  996. }
  997. #######################################################################
  998. # manage users
  999. #######################################################################
  1000. sub pg_manageusers {
  1001. # must be admin
  1002. pg_error('not_admin') if $$userinfo{'level'} ne 'ADMIN';
  1003. # ensure initialized
  1004. default_empty('orderby');
  1005. default_empty('sortby');
  1006. default_empty('user_pattern');
  1007. # local title
  1008. my $ltitle = 'Manage Users';
  1009. $ltitle .= " - $$reqparm{'user_pattern'}"
  1010. if $$reqparm{'user_pattern'};
  1011. # the red up/down mark
  1012. my $mark = '&lt;';
  1013. $mark = '&gt;' if $$reqparm{'orderby'} eq 'desc';
  1014. $mark = qq*<font size="+2" color="red">$mark</font>*;
  1015. my $byip = '';
  1016. my $bydomain = '';
  1017. my $byupdated = '';
  1018. my $bylevel = '';
  1019. my $byemail = '';
  1020. my $byuser = '';
  1021. if ($$reqparm{'manage_users_sortby_currentip'}) {
  1022. $byip = $mark;
  1023. } elsif ($$reqparm{'manage_users_sortby_domain'}) {
  1024. $bydomain = $mark;
  1025. } elsif ($$reqparm{'manage_users_sortby_updated'}) {
  1026. $byupdated = $mark;
  1027. } elsif ($$reqparm{'manage_users_sortby_level'}) {
  1028. $bylevel = $mark;
  1029. } elsif ($$reqparm{'manage_users_sortby_email'}) {
  1030. $byemail = $mark;
  1031. } else {
  1032. $byuser = $mark;
  1033. }
  1034. header();
  1035. tpr(qq*
  1036. <html>
  1037. $head
  1038. $body
  1039. <script type="text/javascript">
  1040. function test() {
  1041. message=("Delete Selected Users?")
  1042. if(confirm(message)) {
  1043. return true
  1044. } else {
  1045. return false
  1046. }
  1047. }
  1048. </script>
  1049. $topline
  1050. <center><h2>$ltitle</h2></center>
  1051. <form action="$thiscgi" method="post">
  1052. <input type=hidden name="page" value="manageusers">
  1053. *);
  1054. html_user();
  1055. tpr(qq*
  1056. <input type=hidden name="user_pattern" value="$$reqparm{'user_pattern'}">
  1057. <input type=hidden name="sortby" value=$$reqparm{'sortby'}>
  1058. <input type=hidden name="orderby" value=$$reqparm{'orderby'}>
  1059. <center>
  1060. <table border=1>
  1061. <tr align="center">
  1062. <td><input type=submit name="manage_users_sortby_username"
  1063. value="Sort">$byuser</td>
  1064. <td><input type=submit name="manage_users_sortby_currentip"
  1065. value="Sort">$byip</td>
  1066. <td><input type=submit name="manage_users_sortby_email"
  1067. value="Sort">$byemail</td>
  1068. <td><input type=submit name="manage_users_sortby_domain"
  1069. value="Sort">$bydomain</td>
  1070. <td><input type=submit name="manage_users_sortby_updated"
  1071. value="Sort">$byupdated</td>
  1072. <td><input type=submit name="manage_users_sortby_level"
  1073. value="Sort">$bylevel</td>
  1074. <td>&nbsp;</td>
  1075. <td>&nbsp;</td></tr>
  1076. <tr align="center">
  1077. <th>Username</th>
  1078. <th>Current IP</th>
  1079. <th>E-Mail</th>
  1080. <th>Domain</th>
  1081. <th>Last Updated</th>
  1082. <th>Level</th>
  1083. <th>Edit User</th>
  1084. <th>Delete User</th></tr>
  1085. *);
  1086. # one row for each user
  1087. my $sth =
  1088. getuserspattern(
  1089. $$reqparm{'user_pattern'},
  1090. $$reqparm{'sortby'},
  1091. $$reqparm{'orderby'}
  1092. );
  1093. while (my $uinfo = getuserseach($sth)) {
  1094. $$uinfo{'email'} = '&nbsp;' if !$$uinfo{'email'};
  1095. $$uinfo{'domain'} = '&nbsp;' if !$$uinfo{'domain'};
  1096. tpr(qq*
  1097. <tr align="center">
  1098. <td>$$uinfo{'username'}</td>
  1099. <td>$$uinfo{'currentip'}</td>
  1100. <td>$$uinfo{'email'}</td>
  1101. <td>$$uinfo{'domain'}</td>
  1102. <td>$$uinfo{'updated'}</td>
  1103. <td>$$uinfo{'level'}</td>
  1104. <td><input type=radio name="edituser" value="$$uinfo{'id'}"></td>
  1105. <td><input type=checkbox name="deluser" value="$$uinfo{'id'}"></td></tr>
  1106. *);
  1107. }
  1108. tpr(qq*
  1109. </table>
  1110. <br>
  1111. <br>
  1112. <input type=submit name="manageusers_edituser" value="Edit Selected User">
  1113. &nbsp;
  1114. <input type=submit name="do_deluser" value="Delete Selected Users"
  1115. onclick="return test()">
  1116. </center>
  1117. </form>
  1118. $bodyend
  1119. </html>
  1120. *);
  1121. exit;
  1122. }
  1123. #######################################################################
  1124. # edit user
  1125. #######################################################################
  1126. sub pg_edituser {
  1127. my $uinfo = shift;
  1128. # must be admin
  1129. pg_error('not_admin') if $$userinfo{'level'} ne 'ADMIN';
  1130. # user not passed but one ID-ed?
  1131. if (!$uinfo and $$reqparm{'edituser'}) {
  1132. # user exists?
  1133. $uinfo = getuserbyid($$reqparm{'edituser'});
  1134. pg_error('bad_sel_user') if !$uinfo;
  1135. }
  1136. # show common page
  1137. pg_cmn_edituser($uinfo);
  1138. }
  1139. ########################################################################
  1140. # common user edit page
  1141. # - cases distinguished by:
  1142. # $$reqparm{'do_edituser'} or $$reqparm{'manageusers_edituser'}
  1143. ########################################################################
  1144. sub pg_cmn_edituser {
  1145. my $uinfo = shift;
  1146. # differences for each case
  1147. my $ltitle = '';
  1148. my $submit = '';
  1149. my $page = '';
  1150. if ($$reqparm{'do_edituser'} or $$reqparm{'manageusers_edituser'}) {
  1151. $ltitle = 'Edit User';
  1152. $submit = 'do_edituser';
  1153. $page = 'edituser';
  1154. } else {
  1155. $ltitle = 'Current Settings';
  1156. $submit = 'do_updatesettings';
  1157. $page = 'updatesettings';
  1158. }
  1159. header();
  1160. tpr(qq*
  1161. <html>
  1162. $head
  1163. $body
  1164. $topline
  1165. <center><h2>$ltitle</h2></center>
  1166. *);
  1167. # do we have a user to edit?
  1168. if (!$uinfo) {
  1169. tpr(qq*
  1170. <center>
  1171. <h3>
  1172. No user has been selected
  1173. <br>
  1174. Please go back and select a user
  1175. </h3>
  1176. </center>
  1177. $bodyend
  1178. </html>
  1179. *);
  1180. exit;
  1181. }
  1182. # reshowing this page?
  1183. if ($$reqparm{'do_updatesettings'} or
  1184. $$reqparm{'do_edituser'}) {
  1185. tpr(qq*
  1186. <center><font size="+1"><b>
  1187. Previous changes saved
  1188. </b></font></center>
  1189. <p>
  1190. *);
  1191. }
  1192. tpr(qq*
  1193. <center><font color="red">
  1194. Note: Leave Password Fields Blank to Remain the Same
  1195. </font></center>
  1196. <p>
  1197. <form action="$thiscgi" method="post">
  1198. <input type=hidden name="page" value="$page">
  1199. *);
  1200. html_user();
  1201. # save ID of user if not editing self
  1202. if ($$reqparm{'edituser'}) {
  1203. tpr(qq*
  1204. <input type=hidden name="edituser" value="$$reqparm{'edituser'}">
  1205. *);
  1206. }
  1207. tpr(qq*
  1208. <center>
  1209. <table>
  1210. <tr><td>Username/Hostname</td>
  1211. <td><input type="text" name="new_username"
  1212. value="$$uinfo{'username'}"></td>
  1213. </tr>
  1214. <tr><td>E-Mail Address</td><td>
  1215. *);
  1216. if ($$userinfo{'level'} eq 'USER' and
  1217. $$pref{'REQUIRE_EMAIL'} eq 'YES') {
  1218. tpr(qq*
  1219. <table border=1><tr><td>$$uinfo{'email'}</td></tr></table>
  1220. *);
  1221. } else {
  1222. tpr(qq*
  1223. <input type="text" name="new_email" value="$$uinfo{'email'}" size="40">
  1224. *);
  1225. }
  1226. tpr(qq*
  1227. </td></tr>
  1228. *);
  1229. # user being edited not admin?
  1230. if ($$uinfo{'level'} ne 'ADMIN') {
  1231. # domain list
  1232. html_domain($$uinfo{'domain'});
  1233. # autoURL
  1234. if ($$pref{'ALLOW_AUTO_URL'} eq 'YES') {
  1235. tpr(qq*
  1236. <tr><td>Forward URL
  1237. <font color="red">(Do not forget <b>http://</b>)</font></td>
  1238. <td><input type="text" size=40 name="forwardurl"
  1239. value="$$uinfo{'forwardurl'}"></td>
  1240. </tr>
  1241. *);
  1242. }
  1243. # not editing self?
  1244. if ($$reqparm{'do_edituser'} or $$reqparm{'manageusers_edituser'}) {
  1245. # wildcards user by user?
  1246. if ($$pref{'ALLOW_WILD'} eq 'USER') {
  1247. my $checked = setcheck($$uinfo{'allowwild'});
  1248. tpr(qq*
  1249. <tr><td>Allow Wild Card</td>
  1250. <td><input type="checkbox" name="allow_wildcard"
  1251. value="YES" $checked></td></tr>
  1252. *);
  1253. }
  1254. # MX values user by user?
  1255. if ($$pref{'ALLOW_MX'} eq 'USER') {
  1256. my $checked = setcheck($$uinfo{'allowmx'});
  1257. tpr(qq*
  1258. <tr><td>Allow Mail Exchanger</td>
  1259. <td><input type="checkbox" name="allow_mx" value="YES"$checked></td></tr>
  1260. *);
  1261. }
  1262. my $currentip = $$uinfo{'currentip'};
  1263. $currentip = '' if $currentip eq '0.0.0.0';
  1264. tpr(qq*
  1265. <tr><td>IP Address</td>
  1266. <td><input type="text" name="new_IPaddress" value="$currentip"></td>
  1267. </tr>
  1268. *);
  1269. }
  1270. # show wildcard option?
  1271. if ($$pref{'ALLOW_WILD'} eq 'YES' or
  1272. $$pref{'ALLOW_WILD'} eq 'USER' and $$uinfo{'allowwild'} eq 'YES') {
  1273. my $checked = setcheck($$uinfo{'wildcard'});
  1274. tpr(qq*
  1275. <tr><td>Wild Card</td>
  1276. <td><input type="checkbox" name="wildcard" value="YES"$checked></td>
  1277. </tr>
  1278. *);
  1279. }
  1280. # show MX value option?
  1281. if ($$pref{'ALLOW_MX'} eq 'YES' or
  1282. $$pref{'ALLOW_MX'} eq 'USER' and $$uinfo{'allowmx'} eq 'YES') {
  1283. my $checked = setcheck($$uinfo{'MXbackup'});
  1284. tpr(qq*
  1285. <tr><td>Mail Exchanger</td>
  1286. <td><input type="text" name="new_MXvalue"
  1287. value="$$uinfo{'MXvalue'}" size=35></td>
  1288. </tr>
  1289. <tr><td>Backup Mail Exchanger</td>
  1290. <td><input type="checkbox" name="MXbackup" value="YES"$checked></td>
  1291. </tr>
  1292. *);
  1293. }
  1294. }
  1295. # not editing self?
  1296. if ($$reqparm{'do_edituser'} or $$reqparm{'manageusers_edituser'}) {
  1297. # show disable password option?
  1298. if ($$uinfo{'password'} eq '') {
  1299. tpr(qq*
  1300. <tr><td>&nbsp;</td>
  1301. <td><b>Password is Disabled</b></td>
  1302. </tr>
  1303. *);
  1304. } else {
  1305. tpr(qq*
  1306. <tr><td>Disable Password</td>
  1307. <td><input type="checkbox" name="disable" value="YES"></td>
  1308. </tr>
  1309. *);
  1310. }
  1311. }
  1312. tpr(qq*
  1313. <tr><td>New Password</td>
  1314. <td><input type="password" name="new_password" value=""></td>
  1315. </tr>
  1316. <tr><td>New Password Again</td>
  1317. <td><input type="password" name="new_password1" value=""></td>
  1318. </tr>
  1319. </table>
  1320. </center>
  1321. <br>
  1322. <center><input type="submit" name="$submit" value="Save Changes"></center>
  1323. </form>
  1324. $bodyend
  1325. </html>
  1326. *);
  1327. exit;
  1328. }
  1329. ########################################################################
  1330. # need E-mail before proceeding
  1331. ########################################################################
  1332. sub pg_needemail {
  1333. # ensure initialized
  1334. $$reqparm{'new_needemail'} = $$userinfo{'email'}
  1335. if !defined $$reqparm{'new_needemail'};
  1336. header();
  1337. tpr(qq*
  1338. <html>
  1339. $head
  1340. $body
  1341. $topline
  1342. <center><h2>E-mail Address Entry</h2></center>
  1343. <center><font color="red">
  1344. You must provide a valid E-mail address.
  1345. </font></center>
  1346. <p>
  1347. <form action="$thiscgi" method="post">
  1348. <input type=hidden name="page" value="needemail">
  1349. *);
  1350. html_user();
  1351. tpr(qq*
  1352. <center>
  1353. <table>
  1354. <tr><td>Username/Hostname</td>
  1355. <td><table width="100%" border=1><tr><td>
  1356. <b><font size="+1">$$userinfo{'username'}</font></b>
  1357. </td></tr></table></td>
  1358. </tr>
  1359. <tr><td>Domain</td>
  1360. <td><table width="100%" border=1><tr><td>
  1361. <b><font size="+1">$$userinfo{'domain'}</font></b>
  1362. </td></tr></table></td>
  1363. </tr>
  1364. <tr><td>E-Mail Address</td>
  1365. <td><input type="text" name="new_needemail"
  1366. value="$$reqparm{'new_needemail'}" size="40"></td>
  1367. </tr>
  1368. </table>
  1369. </center>
  1370. *);
  1371. # ensure not a robot
  1372. mchk_html();
  1373. tpr(qq*
  1374. <br>
  1375. <center><input type="submit" name="do_needemail" value="Save Changes"></center>
  1376. </form>
  1377. $bodyend
  1378. </html>
  1379. *);
  1380. exit;
  1381. }
  1382. #######################################################################
  1383. # system settings
  1384. #######################################################################
  1385. sub pg_syssettings {
  1386. # must be admin
  1387. pg_error('not_admin') if $$userinfo{'level'} ne 'ADMIN';
  1388. my $ADD_SELF_check =
  1389. setcheck($$pref{'ADD_SELF'});
  1390. my $DELETE_SELF_check =
  1391. setcheck($$pref{'DELETE_SELF'});
  1392. my $SEND_URL_check =
  1393. setcheck($$pref{'SEND_URL'});
  1394. my $REQUIRE_EMAIL_check =
  1395. setcheck($$pref{'REQUIRE_EMAIL'});
  1396. my $NO_ROBOTS_check =
  1397. setcheck($$pref{'NO_ROBOTS'});
  1398. my $ALLOW_CHANGE_HOSTNAME_check =
  1399. setcheck($$pref{'ALLOW_CHANGE_HOSTNAME'});
  1400. my $ALLOW_CHANGE_DOMAIN_check =
  1401. setcheck($$pref{'ALLOW_CHANGE_DOMAIN'});
  1402. my $ALLOW_AUTO_URL_check =
  1403. setcheck($$pref{'ALLOW_AUTO_URL'});
  1404. my $ALLOW_WILD_check =
  1405. setcheck($$pref{'ALLOW_WILD'});
  1406. my $ALLOW_MX_check =
  1407. setcheck($$pref{'ALLOW_MX'});
  1408. my $SHOW_DOMAINLIST_check =
  1409. setcheck($$pref{'SHOW_DOMAINLIST'});
  1410. my $ALLOW_WILD_USER_check =
  1411. $ALLOW_WILD_check;
  1412. $ALLOW_WILD_USER_check = ' checked'
  1413. if $$pref{'ALLOW_WILD'} eq 'USER';
  1414. my $ALLOW_MX_USER_check =
  1415. $ALLOW_MX_check;
  1416. $ALLOW_MX_USER_check = ' checked'
  1417. if $$pref{'ALLOW_MX'} eq 'USER';
  1418. header();
  1419. tpr(qq*
  1420. <html>
  1421. $head
  1422. $body
  1423. $topline
  1424. <br>
  1425. <center><h2>System Settings</h2></center>
  1426. *);
  1427. if ($$reqparm{'save_settings'}) {
  1428. tpr(qq*
  1429. <center><font size="+1"><b>
  1430. Previous settings saved
  1431. </b></font></center>
  1432. <p>
  1433. *);
  1434. }
  1435. tpr(qq*
  1436. <form action="$thiscgi" method="post">
  1437. <input type=hidden name="page" value="syssettings">
  1438. *);
  1439. html_user();
  1440. tpr(qq@
  1441. <br>
  1442. <center>
  1443. <table border=1>
  1444. <tr>
  1445. <td>Allow self registration</td>
  1446. <td align="center">
  1447. <input type=checkbox name="ADD_SELF"
  1448. value="YES" $ADD_SELF_check></td></tr>
  1449. <tr>
  1450. <td>Allow self deletion</td>
  1451. <td align="center">
  1452. <input type=checkbox name="DELETE_SELF"
  1453. value="YES" $DELETE_SELF_check></td></tr>
  1454. <tr>
  1455. <td>Allow sending of quick login URL-s for forgotten passwords</td>
  1456. <td align="center">
  1457. <input type=checkbox name="SEND_URL"
  1458. value="YES" $SEND_URL_check></td></tr>
  1459. <tr>
  1460. <td>Require and validate E-mail addresses<br>
  1461. <blockquote><i>
  1462. This option requires that a user provide an E-mail address during
  1463. self registration. Also, whenever a non-administrative user provides
  1464. an E-mail address, they must use a URL sent to that E-mail
  1465. address to complete the change.
  1466. </i></blockquote></td>
  1467. <td align ="center">
  1468. <input type=checkbox name="REQUIRE_EMAIL"
  1469. value="YES" $REQUIRE_EMAIL_check></td></tr>
  1470. <tr>
  1471. <td>Check for robot before sending E-mail<br>
  1472. <blockquote><i>
  1473. This option requires that a user examine an image for a character
  1474. string encoded in it and enter the string on any page that sends
  1475. E-mail.
  1476. </i></blockquote></td>
  1477. <td align ="center">
  1478. <input type=checkbox name="NO_ROBOTS"
  1479. value="YES" $NO_ROBOTS_check></td></tr>
  1480. <tr>
  1481. <td>Show domain list on login page<br>
  1482. <blockquote><i>
  1483. Users will have to enter their domain name into a text box
  1484. during login unless this option is on.
  1485. </i></blockquote></td>
  1486. <td align="center">
  1487. <input type=checkbox name="SHOW_DOMAINLIST"
  1488. value="YES" $SHOW_DOMAINLIST_check></td></tr>
  1489. <tr>
  1490. <td>Allow users to change their hostname/username</td>
  1491. <td align="center">
  1492. <input type=checkbox name="ALLOW_CHANGE_HOSTNAME"
  1493. value="YES" $ALLOW_CHANGE_HOSTNAME_check></td></tr>
  1494. <tr>
  1495. <td>Allow users to switch their domain</td>
  1496. <td align="center">
  1497. <input type=checkbox name="ALLOW_CHANGE_DOMAIN"
  1498. value="YES" $ALLOW_CHANGE_DOMAIN_check></td></tr>
  1499. <tr>
  1500. <td>Enable automatic login using "Auto URL"<br>
  1501. <blockquote><i>
  1502. This allows users to set the GnuDIP Auto URL as their browser's
  1503. default page to update their IP address and be redirected to their
  1504. specified "Forward URL".
  1505. </i></blockquote></td>
  1506. <td align ="center">
  1507. <input type=checkbox name="ALLOW_AUTO_URL"
  1508. value="YES" $ALLOW_AUTO_URL_check></td></tr>
  1509. <tr>
  1510. <td>Allow all users to set a wildcard DNS RR entry
  1511. <blockquote><i>
  1512. The wildcard entry will match any full hostname ending
  1513. in the users full hostname. So not just "user.gnudipdomain" will
  1514. map to the current address but so will "www.user.gnudipdomain"
  1515. and so on.
  1516. </i></blockquote></td>
  1517. <td align="center">
  1518. <input type=checkbox name="ALLOW_WILD"
  1519. value="YES" $ALLOW_WILD_check></td></tr>
  1520. <tr>
  1521. <td>Allow enabled users to set a wildcard DNS RR entry</td>
  1522. <td align="center">
  1523. <input type=checkbox name="ALLOW_WILD_USER"
  1524. value="YES" $ALLOW_WILD_USER_check></td></tr>
  1525. <tr>
  1526. <td>Allow all users to set mail exchanger RR entries<br>
  1527. <blockquote><i>
  1528. This allows users to specify a (primary or backup) mail exchanger.
  1529. </i></blockquote></td>
  1530. <td align="center">
  1531. <input type=checkbox name="ALLOW_MX"
  1532. value="YES" $ALLOW_MX_check></td></tr>
  1533. <tr>
  1534. <td>Allow enabled users to set mail exchanger RR entries</td>
  1535. <td align="center">
  1536. <input type=checkbox name="ALLOW_MX_USER"
  1537. value="YES" $ALLOW_MX_USER_check></td></tr>
  1538. <tr>
  1539. <td>Restricted usernames<br>
  1540. <blockquote><i>
  1541. This is a comma seperated list of usernames you do not want to
  1542. be allowed as GnuDIP usernames.
  1543. It can protect common hostnames from being used.
  1544. An * can be used as a wild card to match a string of characters,
  1545. and a ? can be used to match a single character.
  1546. Common entries include www, ftp, ns?, mail*, etc...
  1547. </i></blockquote></td>
  1548. <td align="center">
  1549. <input type=text name="RESTRICTED_USERS" size=25
  1550. value="$$pref{'RESTRICTED_USERS'}"></td></tr>
  1551. <tr>
  1552. <td>Page Timeout<br>
  1553. <blockquote><i>
  1554. If a number is provided here, browser pages will expire
  1555. after that number of seconds.
  1556. This will not apply to administrative users.
  1557. A good value for this might be 1800 - 30 minutes.
  1558. </i></blockquote></td>
  1559. <td align="center">
  1560. <input type=text name="PAGE_TIMEOUT" size=25
  1561. value="$$pref{'PAGE_TIMEOUT'}"></td></tr>
  1562. <tr>
  1563. <td>Server Signature Key<br>
  1564. <blockquote><i>
  1565. This value is generated automatically upon the first login to
  1566. GnuDIP.
  1567. It is used to "sign" the login information placed in each page.
  1568. This signature is tested each time a page internal to GnuDIP is
  1569. requested.
  1570. </i></blockquote></td>
  1571. <td align="center">
  1572. <table border=1><tr><td align="center">
  1573. $$pref{'SERVER_KEY'}
  1574. </table></td></tr>
  1575. </table>
  1576. <br>
  1577. <input type=submit name="save_settings" value="Save Settings\">
  1578. </center>
  1579. </form>
  1580. $bodyend
  1581. </html>
  1582. @);
  1583. exit;
  1584. }
  1585. ########################################################################
  1586. # set auto URL
  1587. ########################################################################
  1588. sub pg_setautourl {
  1589. # generate cookies
  1590. printcookie('gnudipuser', $$userinfo{'username'}, '+1M');
  1591. printcookie('gnudipdomain', $$userinfo{'domain'}, '+1M');
  1592. printcookie('gnudippass', $$userinfo{'password'}, '+1M');
  1593. header();
  1594. tpr(qq*
  1595. <html>
  1596. $head
  1597. $body
  1598. $topline
  1599. <center>
  1600. <h2>Auto URL Cookie Set</h2>
  1601. Auto URL is a feature of GnuDIP that allows a user to set cookies in
  1602. their browser with their username, domain and (hashed) password.
  1603. <p>
  1604. When GnuDIP is contacted using the "Auto URL", it reads this information
  1605. from the cookies passed from the browser to GnuDIP. After verifying
  1606. this information it updates the hostname to point to the IP address
  1607. of the computer that connected to GnuDIP, and then "redirects" the
  1608. browser to the value the user has provided for "Forward URL". If
  1609. "Forward URL" is not set a mesage page will be displayed instead
  1610. of redirecting the browser.
  1611. <p>
  1612. <font color="red">
  1613. Note that the IP address of the computer that connects to GnuDIP is used.
  1614. Browser based IP address detection is not supported for Auto URL.
  1615. </font>
  1616. <p>
  1617. Now that the cookie has been set, you can test it by clicking the link below.
  1618. After it succesfully updates your hostname set that page as your
  1619. browsers default page.
  1620. </center>
  1621. <form action="$thisurl?action=getautourlinfo" method="post">
  1622. <input type=hidden name="page" value="setautourl">
  1623. *);
  1624. html_user();
  1625. tpr(qq*
  1626. <br>
  1627. <center>
  1628. <input type=submit name="testautourl"
  1629. value="Click Here To Test AUTO URL Cookie">
  1630. </center>
  1631. </form>
  1632. <form action="$thiscgi" method="post">
  1633. <input type=hidden name="page" value="setautourl">
  1634. *);
  1635. html_user();
  1636. tpr(qq*
  1637. <br>
  1638. <center>
  1639. <input type="submit" name="removeautourl" value="Remove Auto URL">
  1640. </center>
  1641. </form>
  1642. $bodyend
  1643. </html>
  1644. *);
  1645. exit;
  1646. }
  1647. #######################################################################
  1648. # display title and message
  1649. #######################################################################
  1650. sub pg_msg {
  1651. my $msgtitle = shift;
  1652. my $msg = shift;
  1653. # ensure initialized
  1654. $msgtitle = '' if !defined($msgtitle);
  1655. $msg = '' if !defined($msg);
  1656. # remove leading and trailing new lines
  1657. $msgtitle =~ s /^\n//;
  1658. $msgtitle =~ s /\n$//;
  1659. $msg =~ s /^\n//;
  1660. $msg =~ s /\n$//;
  1661. header();
  1662. tpr(qq*
  1663. <html>
  1664. $head
  1665. $body
  1666. $topline
  1667. <center>
  1668. <h2>$msgtitle</h2>
  1669. $msg
  1670. </center>
  1671. $bodyend
  1672. </html>
  1673. *);
  1674. exit;
  1675. }
  1676. #######################################################################
  1677. # display error message
  1678. #######################################################################
  1679. sub pg_error {
  1680. my $error = shift;
  1681. if ($error eq 'page_timeout') {
  1682. pg_msg(qq*
  1683. Error: Browser Page Has Expired
  1684. *,qq*
  1685. The current GnuDIP page has expired.
  1686. <br>
  1687. Please go back to the login page.
  1688. *);
  1689. } elsif ($error eq 'nouser') {
  1690. pg_msg(qq*
  1691. Error: Unknown User
  1692. *,qq*
  1693. You entered a username/domain combination which was unknown.
  1694. <br>
  1695. Please go back and check for typos.
  1696. *);
  1697. } elsif ($error eq 'bad_sel_user') {
  1698. pg_msg(qq*
  1699. Error: Selected User Does Not Exist
  1700. *,qq*
  1701. Please go back and refresh the list.
  1702. *);
  1703. } elsif ($error eq 'bad_edit_user') {
  1704. pg_msg(qq*
  1705. Error: User Being Edited Does Not Exist
  1706. *,qq*
  1707. Please go back and refresh the list.
  1708. *);
  1709. } elsif ($error eq 'bad_user_domain') {
  1710. pg_msg(qq*
  1711. Error: Domain For User Being Edited Does Not Exist
  1712. *,qq*
  1713. Please either restore the domain, or delete the user.
  1714. Or use the "gdipdbfix.pl" script to remove all invalid users.
  1715. *);
  1716. } elsif ($error eq 'bad_sel_domain') {
  1717. pg_msg(qq*
  1718. Error: Selected Domain Does Not Exist
  1719. *,qq*
  1720. Please go back and refresh the list.
  1721. *);
  1722. } elsif ($error eq 'bad_edit_domain') {
  1723. pg_msg(qq*
  1724. Error: Domain Being Edited Does Not Exist
  1725. *,qq*
  1726. Please go back and refresh the list.
  1727. *);
  1728. } elsif ($error eq 'bad_request') {
  1729. pg_msg(qq*
  1730. Error: Invalid HTTP Request
  1731. *,qq*
  1732. The HTTP request was not valid.
  1733. *);
  1734. } elsif ($error eq 'badpass') {
  1735. pg_msg(qq*
  1736. Error: Invalid Password
  1737. *,qq*
  1738. The password you entered was invalid.
  1739. <br>
  1740. Please go back and check for typos.
  1741. *);
  1742. } elsif ($error eq 'dispass') {
  1743. pg_msg(qq*
  1744. Error: Password Disabled
  1745. *,qq*
  1746. The password for this user has been disabled.
  1747. *);
  1748. } elsif ($error eq 'not_same') {
  1749. pg_msg(qq*
  1750. Error: Password Error
  1751. *,qq*
  1752. You must enter the same password twice.
  1753. <br>
  1754. Please go back and enter the same password twice.
  1755. *);
  1756. } elsif ($error eq 'bad_username') {
  1757. pg_msg(qq*
  1758. Error: Invalid User Name
  1759. *,qq*
  1760. You entered a user name which is not a valid domain name component.
  1761. <br>
  1762. Please go back and check this entry.
  1763. *);
  1764. } elsif ($error eq 'user_exists') {
  1765. pg_msg(qq*
  1766. Error: User Exists
  1767. *,qq*
  1768. Please go back and choose a username that is not already in use.
  1769. *);
  1770. } elsif ($error eq 'no_username') {
  1771. pg_msg(qq*
  1772. Error: No User Name
  1773. *,qq*
  1774. You did not provide a user name.
  1775. <br>
  1776. Please go back and choose a username.
  1777. *);
  1778. } elsif ($error eq 'no_password') {
  1779. pg_msg(qq*
  1780. Error: No Password
  1781. *,qq*
  1782. You did not provide a password.
  1783. <br>
  1784. Please go back and choose a password.
  1785. *);
  1786. } elsif ($error eq 'no_email') {
  1787. pg_msg(qq*
  1788. Error: No E-mail Address
  1789. *,qq*
  1790. You did not provide an E-mail address.
  1791. <br>
  1792. Please go back and enter a valid E-mail address.
  1793. *);
  1794. } elsif ($error eq 'no_domain') {
  1795. pg_msg(qq*
  1796. Error: No Domain Name
  1797. *,qq*
  1798. You did not provide a domain name.
  1799. <br>
  1800. Please go back and choose a username.
  1801. *);
  1802. } elsif ($error eq 'domain_exists') {
  1803. pg_msg(qq*
  1804. Error: Domain Exists
  1805. *,qq*
  1806. Please go back and choose a domain that is not already in use.
  1807. *);
  1808. } elsif ($error eq 'no_cookie') {
  1809. pg_msg(qq*
  1810. Error: Missing AutoURL Cookie
  1811. *,qq*
  1812. One or more Auto URL cookies were not sent.
  1813. <br>
  1814. Please go to the main menu and choose 'Set Auto URL'.
  1815. *);
  1816. } elsif ($error eq 'no_autourl') {
  1817. pg_msg(qq*
  1818. Error: Auto URL Not Allowed
  1819. *,qq*
  1820. This server has the Auto URL option turned off.
  1821. <br>
  1822. Any Auto URL cookie that may have been in your browser has been removed.
  1823. *);
  1824. } elsif ($error eq 'bad_cookie') {
  1825. pg_msg(qq*
  1826. Error: Invalid AutoURL Login
  1827. *,qq*
  1828. The cookies passed by your browser contained an invalid username and/or
  1829. password.
  1830. <br>
  1831. Perhaps you did not reset your cookie after you changed your password.
  1832. *);
  1833. } elsif ($error eq 'no_changepass') {
  1834. pg_msg(qq*
  1835. Error: Password Changes Not Allowed
  1836. *,qq*
  1837. Your administrator has chosen not to allow users to change their own password.
  1838. <br>
  1839. Please contact your administrator and ask them to change your password for you.
  1840. *);
  1841. } elsif ($error eq 'not_admin') {
  1842. pg_msg(qq*
  1843. Error: Not Administrator
  1844. *,qq*
  1845. You are not marked as an administrator.
  1846. <br>
  1847. Please log in again if you feel this is an error.
  1848. *);
  1849. } elsif ($error eq 'restricted_user') {
  1850. pg_msg(qq*
  1851. Error: Restricted Username
  1852. *,qq*
  1853. The username you have chosen has been marked as restricted.
  1854. <br>
  1855. Please contact your administrator if you feel this is an error.
  1856. *);
  1857. } elsif ($error eq 'no_changehostname') {
  1858. pg_msg(qq*
  1859. Error: Hostname changes not allowed
  1860. *,qq*
  1861. Your administrator has chosen not to allow users to change their hostnames.
  1862. <br>
  1863. Please contact your administrator if you feel this is an error.
  1864. *);
  1865. } elsif ($error eq 'no_domain_change') {
  1866. pg_msg(qq*
  1867. Error: Subdomain changes not allowed
  1868. *,qq*
  1869. Your administrator has chosen not to allow users to change their subdomain
  1870. names.
  1871. <br>
  1872. Please contact your administrator if you feel this is an error.
  1873. *);
  1874. } elsif ($error eq 'no_dom_domain_change') {
  1875. pg_msg(qq*
  1876. Error: Change to this subdomain not allowed
  1877. *,qq*
  1878. Your administrator has chosen not to allow users to change their subdomain
  1879. to this name.
  1880. <br>
  1881. Please contact your administrator if you feel this is an error.
  1882. *);
  1883. } elsif ($error eq 'no_spaces') {
  1884. pg_msg(qq*
  1885. Error: No Spaces or Blanks Allowed
  1886. *,qq*
  1887. You entered a string which contained spaces or was left blank.
  1888. <br>
  1889. Please go back and check your username.
  1890. *);
  1891. } elsif ($error eq 'no_addself') {
  1892. pg_msg(qq*
  1893. Error: Self registration not allowed
  1894. *,qq*
  1895. Your administrator has chosen not to allow self registration.
  1896. <br>
  1897. Please contact your administrator for an account.
  1898. *);
  1899. } elsif ($error eq 'no_sendURL') {
  1900. pg_msg(qq*
  1901. Error: Sending login URL not allowed
  1902. *,qq*
  1903. Your administrator has chosen not to allow mailing a login URL.
  1904. <br>
  1905. Please contact your administrator for a new password.
  1906. *);
  1907. } elsif ($error eq 'no_delself') {
  1908. pg_msg(qq*
  1909. Error: Self deletion not allowed
  1910. *,qq*
  1911. Your administrator has chosen not to allow self deletion.
  1912. *);
  1913. } elsif ($error eq 'no_domaddself') {
  1914. pg_msg(qq*
  1915. Error: Self registration for this domain not allowed
  1916. *,qq*
  1917. Your administrator has chosen not to allow self registration
  1918. for this domain.
  1919. *);
  1920. } elsif ($error eq 'unknown_dom') {
  1921. pg_msg(qq*
  1922. Error: Unknown Domain
  1923. *,qq*
  1924. An invalid domain name was specified.
  1925. *);
  1926. } elsif ($error eq 'bad_domain') {
  1927. pg_msg(qq*
  1928. Error: Invalid Domain Name Syntax
  1929. *,qq*
  1930. The domain name you entered has invalid syntax.
  1931. <br>
  1932. Please go back and check what you entered.
  1933. *);
  1934. } elsif ($error eq 'bad_email') {
  1935. pg_msg(qq*
  1936. Error: Invalid E-mail Address Syntax
  1937. *,qq*
  1938. The E-mail address you entered has invalid syntax.
  1939. <br>
  1940. Please go back and check what you entered.
  1941. *);
  1942. } elsif ($error eq 'bad_MX_dom') {
  1943. pg_msg(qq*
  1944. Error: Invalid Mail Exchanger Domain Name
  1945. *,qq*
  1946. The domain name you provided for a mail exchanger is not valid.
  1947. <br>
  1948. Please go back and check what you entered.
  1949. *);
  1950. } elsif ($error eq 'bad_MX_IP') {
  1951. pg_msg(qq*
  1952. Error: Invalid Mail Exchanger IP
  1953. *,qq*
  1954. The IP address you provided for a mail exchanger is not valid.
  1955. <br><b>Note:</b> This domain requires the <b>IP address</b> of the mail
  1956. exchanger.<br>
  1957. Please go back and check what you entered.
  1958. *);
  1959. } elsif ($error eq 'bad_IP') {
  1960. pg_msg(qq*
  1961. Error: Unservicable IP Address
  1962. *,qq*
  1963. The requested IP address is not one that this GnuDIP installation will serve.
  1964. *);
  1965. } elsif ($error eq 'bad_IP_syntax') {
  1966. pg_msg(qq*
  1967. Error: Invalid IP Address Syntax
  1968. *,qq*
  1969. The requested IP address does not have valid syntax.
  1970. *);
  1971. } elsif ($error eq 'no_useremail') {
  1972. pg_msg(qq*
  1973. Error: No E-mail Address on Record
  1974. *,qq*
  1975. There is no E-mail address on record for the user you selected.
  1976. <br>
  1977. A Quick Login URL canot be sent.
  1978. *);
  1979. } elsif ($error eq 'config') {
  1980. pg_msg(qq*
  1981. Error: GnuDIP Configuration or Interface Problem
  1982. *,qq*
  1983. An internal GnuDIP operation has failed, due to a configuration error, or
  1984. the failure of a system service required by GnuDIP.
  1985. <p>
  1986. Please report this problem to your administrator if it persists.
  1987. *);
  1988. } else {
  1989. pg_msg(qq*
  1990. Error: Internal Error
  1991. *,qq*
  1992. An internal error has occurred.
  1993. *);
  1994. }
  1995. }
  1996. #######################################################################
  1997. # subroutines
  1998. #######################################################################
  1999. # generate html for user information
  2000. sub html_user {
  2001. # ensure people come through login page
  2002. # sign the login information
  2003. my $pagetime = time;
  2004. my $checkval =
  2005. md5_hex(
  2006. "$$userinfo{'username'}.".
  2007. "$$userinfo{'domain'}." .
  2008. "$$userinfo{'password'}." .
  2009. "$$reqparm{'logonid'}." .
  2010. "$pagetime." .
  2011. $$pref{'SERVER_KEY'}
  2012. );
  2013. tpr(qq*
  2014. <input type=hidden name="username" value="$$userinfo{'username'}">
  2015. <input type=hidden name="domain" value="$$userinfo{'domain'}">
  2016. <input type=hidden name="password" value="$$userinfo{'password'}">
  2017. <input type=hidden name="logonid" value="$$reqparm{'logonid'}">
  2018. <input type=hidden name="pagetime" value="$pagetime">
  2019. <input type=hidden name="checkval" value="$checkval">
  2020. *);
  2021. }
  2022. # generate html for the domain list
  2023. # may specify the one at the top
  2024. sub html_domain {
  2025. my $top = shift;
  2026. my $dname = shift;
  2027. # default name for <select>
  2028. $dname = 'new_domain' if !$dname;
  2029. tpr(qq*
  2030. <tr><td>Domain</td>
  2031. <td>
  2032. <select name="$dname">
  2033. *);
  2034. if ($top) {
  2035. tpr(qq*
  2036. <option value="$top">$top</option>
  2037. *);
  2038. }
  2039. my $domains = getdomains();
  2040. foreach my $domain (@$domains) {
  2041. if (!$top or $$domain{'domain'} ne $top) {
  2042. tpr(qq*
  2043. <option value="$$domain{'domain'}">$$domain{'domain'}</option>
  2044. *);
  2045. }
  2046. }
  2047. tpr(qq*
  2048. </select>
  2049. </td></tr>
  2050. *);
  2051. }
  2052. # return ' checked' if the value is 'YES'
  2053. sub setcheck {
  2054. my $value = shift;
  2055. my $checked = '';
  2056. $checked = ' checked'
  2057. if $value and $value eq 'YES';
  2058. return $checked;
  2059. }
  2060. # print content and document type
  2061. sub header {
  2062. tpr(qq*
  2063. Content-Type: text/html; charset=iso-8859-1
  2064. <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
  2065. "http://www.w3.org/TR/html4/loose.dtd\">
  2066. *);
  2067. }
  2068. #######################################################################
  2069. # must return 1
  2070. #######################################################################
  2071. 1;