home *** CD-ROM | disk | FTP | other *** search
/ rtsi.com / 2014.01.www.rtsi.com.tar / www.rtsi.com / OS9 / FAQ / cgi-bin / discus4_00 / source / database.tmpl < prev    next >
Text File  |  2009-11-06  |  19KB  |  491 lines

  1. # FILE: database.tmpl
  2. # DESCRIPTION: Database Interface screen
  3. # Copyright (c) 2002, DiscusWare, LLC, all rights reserved
  4. # -------------------------------------------------------------------------------------------
  5.  
  6. <!--BEGIN-->
  7. <#define array @menubar(number,name)#>
  8. 0    Setup
  9. <#if $connect->{status} == 1#>    1    Initialize
  10. <#if $connect->{status} == 1#>    2    Import
  11. <#if $connect->{status} == 1#>    3    Export
  12. 4    Toggle
  13. <#if $connect->{status} == 1#>    5    Stats
  14. <#/define#>
  15.  
  16. <#define array @tables (name,description,file)#>
  17. counters    Internal counters    data.txt/postindex.txt
  18. locks    File locking    (All file locks)
  19. <#if pro#>    log    Posting log    *-log.txt
  20. <#if pro#>    passwd    Moderator database    passwd.txt<#if pro#>/md-accts.txt<#endif#>
  21. <#if pro#>    search    Search engine index    *-search.txt
  22. <#if pro#>    users    User database    users.txt<#if pro#>/us-accts.txt<#endif#>
  23. <#if pro && $DCONF->{tree_as_sql}#>    tree    Tree data    tree.txt
  24. <#/define#>
  25.  
  26. <#define array @skin_alt (_index, color)#>
  27. 1    #c0c0c0
  28. 2    #d0d0d0
  29. <#/define#>
  30.  
  31.  
  32. <html><head><title>Database Interface Manager</title>
  33. <script language="JavaScript">
  34. function impexp (what) {
  35.     if (what == true) {
  36.         var m = confirm('This operation cannot be undone! Are you sure you want to overwrite all of the selected data in your database with the data from the chosen text file?');
  37.     } else {
  38.         var m = confirm('This operation cannot be undone! Are you sure you want to overwrite all of the selected data in your text file with the data from the database?');
  39.     }
  40.     if (m == true) {
  41.         document.forms[0].submit();
  42.     }
  43. }
  44. </script>
  45. <style>
  46. td.unselected {font: bold 9pt verdana,arial,helvetica; background-color: #d0d0d0}
  47. td.selected {font: bold 9pt verdana,arial,helvetica; background-color: #f7f757}
  48. td.ub {font: bold 8pt verdana,arial,helvetica}
  49. a.bar {text-decoration: none}
  50. p { margin-left: 2pt; }
  51. p.blbar {margin-left: 0pt; font: 11pt verdana,arial,helvetica; color: #ffff00; background-color: #000000; width: 100% }
  52. .surround {border: thin black inset; width: 100%; font: 10pt verdana,arial,helvetica }
  53. .normal {font: 10pt verdana,arial,helvetica}
  54. .comment {font: 9pt verdana,arial,helvetica; margin-left: 20pt; }
  55. td.eb {font: bold 9pt verdana,arial,helvetica}
  56. td.enb {font: 9pt verdana,arial,helvetica}
  57. td.s {font: 8pt arial,helvetica}
  58. td.sb {font: 8pt arial,helvetica; font-weight: bold}
  59. </style>
  60. </head>
  61. <body bgcolor=#ffffff text=#000000 link=#0000ff vlink=#0000ff>$fs
  62. <center><font size=3><b>Database Interface Manager</b></font></center>
  63. <hr>
  64. <table cellpadding=0 cellspacing=0 border=0 width=100%><tr><td bgcolor=#d0d0d0>
  65. <table cellpadding=5 cellspacing=0><tr>
  66. <#foreach $barid (@menubar)#>
  67.     <#if $general->{menu} == $barid->{number}#>
  68.         <td class="selected">
  69.     <#else#>
  70.         <td class="unselected">
  71.     <#endif#>
  72.     <a class="bar" href="$general->{url}&menu=$barid->{number}">$barid->{name}</a>
  73.     </td>
  74. <#endloop#>
  75. </tr></table>
  76. </td></tr></table>
  77. <hr>
  78.  
  79. <form action="$cgiurl" method=post>
  80. <input type=hidden name=username value="$general->{username}">
  81.  
  82. <#if $stuff->{what} > 0#>
  83. <#define array @actions (_index, what)#>
  84. 1    saved database parameters
  85. 2    imported selected text files into database
  86. 3    initialized database tables
  87. 4    exported selected database tables into text files
  88. 5    toggled database usage
  89. <#/define#>
  90. <table width=100% bgcolor=#ccffcc border=0><tr><td>$fs
  91. <b>Note:</b> Successfully <#pick what $stuff->{what} from @actions(1,2,3,4,5)#>
  92. </font></td></tr></table>
  93. <p>
  94. <#endif#>
  95.  
  96. <#if $stuff->{toggle} == 1#>
  97.     <div class="surround">
  98.         {#if $browser->{ieX}#}<p class="blbar">Data Source Saved</p>{#else#}<table width=100% bgcolor=#000000><tr><td>$fs<font color=#ffff00>Data Source Saved</font></font></td></tr></table>{#endif#}
  99.         <p>
  100.         Your setting of data source has been saved.  If you recently synchronized your
  101.         database and text files by importing or exporting your data, you may continue
  102.         working.  If you receive a "Bad Login" message, you must log in again with the
  103.         password from your selected data source.
  104.         </p>
  105.         <br>
  106.     </div>
  107.     </body></html>
  108.     <#exit#>
  109. <#endif#>
  110.  
  111. <#if $general->{menu} == 0#>
  112.  
  113.     <#if pro && $GLOBAL_OPTIONS{database} == 1#>
  114.         <p>WARNING:  You are currently using the database to supply your user and
  115.         moderator data.  Changing the setup at this time could cause you to lose your
  116.         access to the administration program.
  117.         </p>
  118.     <#endif#>
  119.  
  120.  
  121. <input type=hidden name=action value="database-setup">
  122. <div class="surround">
  123.     {#if $browser->{ieX}#}<p class="blbar">Database Setup</p>{#else#}<table width=100% bgcolor=#000000><tr><td>$fs<font color=#ffff00>Database Setup</font></font></td></tr></table>{#endif#}
  124.     <p>
  125.     $text
  126.     </p>
  127.     <#if $connect->{status} == 1#>
  128.         <table bgcolor="#119911" border=0 cellpadding=1 style="margin: 10pt;"><tr>
  129.         <td bgcolor="#ffffff" class="eb">
  130.         <b>With the parameters shown here, a connection was successfully
  131.         initiated to database!</b>
  132.         </td></tr></table>
  133.     <#else#>
  134.         <#if $connect->{status} == 2#>
  135.             <p>
  136.             <b><font color=#ff0000>NOTE:  Database name must be supplied in order to connect.</font></b>
  137.             </p>
  138.         <#else#>
  139.             <table bgcolor="#ff0000" border=0 cellpadding=1 style="margin: 10pt;"><tr>
  140.             <td bgcolor="#ffffff" class="eb">
  141.             <p>
  142.             <b>Warning!  With the parameters shown here, the program could not
  143.             connect to database! Error was: 
  144.             <font color="#119911">$connect->{message}</font></b>
  145.             </p>
  146.             <p>
  147.             This error is a problem with your database setup and is not a problem with
  148.             the Discus software itself.  Please consult the administration
  149.             instructions for Database Manager for tips you can try.
  150.             </p>
  151.             </td></tr></table>
  152.         <#endif#>
  153.     <#endif#>
  154.     <p>
  155.     Specify the name of the database and the username and (optional) password that you use
  156.     to connect to this database.  You can also specify a prefix that all tables used by
  157.     this discussion board will use, and you can specify the full path to the MySQL socket
  158.     on your server (consult the administration instructions for details).
  159.     </p>
  160.     <ul>
  161.         <table>
  162.         <tr><td class=eb nowrap>Database Name:</td><td><input type=text size=15 name=database value="$db_param->{database}"></td></tr>
  163.         <tr><td class=eb nowrap>Username:</td><td><input type=text size=15 name=dbusername value="$db_param->{username}"></td></tr>
  164.         <#if $GLOBAL_OPTIONS->{hide_database_password} == 0#>
  165.             <tr><td class=eb nowrap>Password:</td><td><input type=text size=15 name=dbpassword value="$db_param->{password}"></td></tr>
  166.         <#else#>
  167.             <tr><td class=eb nowrap>Password:</td><td><input type=password size=15 name=dbpassword value="$db_param->{password}"></td></tr>
  168.         <#endif#>
  169.         <tr><td class=eb nowrap>Optional Prefix:</td><td><input type=text size=15 name=dbprefix value="$db_param->{prefix}"></td></tr>
  170.         <tr><td class=eb nowrap>Optional Socket:</td><td><input type=text size=30 name=dbsocket value="$db_param->{force_socket}"></td></tr>
  171.         </table>
  172.         <p>
  173.         <input type=submit value="Save Parameters">
  174.         </p>
  175.     </ul>
  176. </div>
  177. <#endif#>
  178.  
  179. <#if $general->{menu} >= 1 && $general->{menu} <= 3 && $connect->{status} != 1#>
  180.     <p>
  181.     <font color=#ff0000><b>"<#pick name $general->{menu} from @menubar (2,3,4)#>" Unavailable!</b></font>
  182.     </p>
  183.     <p>
  184.     This screen may be used only when a connection has successfully been established to
  185.     the database.  Please use <a href="$general->{url}&menu=0">this interface</a> to
  186.     set up a connection.
  187.     </p>
  188.     </font></body></html>
  189.     <#exit#>
  190. <#endif#>
  191.  
  192. <#if $general->{menu} == 1#>
  193. <div class="surround">
  194.     {#if $browser->{ieX}#}<p class="blbar">Initialize Database Tables</p>{#else#}<table width=100% bgcolor=#000000><tr><td>$fs<font color=#ffff00>Initialize Database Tables</font></font></td></tr></table>{#endif#}
  195.     <#if $GLOBAL_OPTIONS{database} == 0#>
  196.         <p>
  197.         This section allows you to initialize the database so it can accept input.  Be
  198.         careful, because when you initialize a table, you <b>delete all existing
  199.         information</b> in that table!
  200.         </p>
  201.     <#else#>
  202.         <p>
  203.         This screen allows you to initialize database tables.  Since you are currently
  204.         using the database to store your data, you cannot initialize the tables at this
  205.         time.
  206.         </p>
  207.     <#endif#>
  208.  
  209.     <p>
  210.     <table border=0 cellpadding=0 cellspacing=0><tr><td bgcolor="#000000">
  211.     <table border=0 cellpadding=2 cellspacing=1 width=100%>
  212.     <tr bgcolor=#ffffcc>
  213.     <td class=eb>Table</td>
  214.     <td class=eb>Purpose</td>
  215.     <td class=eb>Status</td>
  216.     <td class=eb>Rows</td>
  217.     <#if $GLOBAL_OPTIONS{database} == 0#><td class=eb>Initialize</td>
  218.     </tr>
  219.     <#foreach $table (@tables)#>
  220.         <#define $name = $table->{name}#>
  221.         <tr bgcolor="<#pick color $table->{_iteration} from @skin_alt (1,2)#>">
  222.         <td class=enb>\u$table->{name}</td>
  223.         <td class=enb>$table->{description}</td>
  224.         <td align=center class=enb><#if $exists->{$name} == 1#><font color=#119911>Ready</font><#else#><font color=#ff0000>Not Initialized</font><#endif#></td>
  225.         <td align=right  class=enb><#if $count->{$name} == 0#>0<#else#>$count->{$name}<#endif#> </td>
  226.         <#if $GLOBAL_OPTIONS{database} == 0#>
  227.             <td align=center class=enb><input type=checkbox name=init value="$table->{name}"{#if $exists->{$table->{name}} == 0#} CHECKED{#endif#}></td>
  228.         <#endif#>
  229.         </tr>
  230.     <#endloop#>
  231.     </table>
  232.     </td></tr></table>
  233.     </p>
  234.     
  235.     <#if $GLOBAL_OPTIONS{database} == 0#>
  236.         <p>
  237.         <input type=button value="Initialize Selected Tables" onclick="if (confirm('Warning: Initializing a table will permanently delete all data contained in that table!  This data will not be backed up and cannot be recovered later.  Are you absolutely sure that you want to initialize the selected table(s)?')) { document.forms[0].submit(); }">
  238.         </p>
  239.     <#endif#>
  240.     <input type=hidden name=action value="database-init">
  241. </div>
  242. <#endif#>
  243.  
  244. <#if $general->{menu} == 2#>
  245. <div class="surround">
  246.     {#if $browser->{ieX}#}<p class="blbar">Import Data</p>{#else#}<table width=100% bgcolor=#000000><tr><td>$fs<font color=#ffff00>Import Data</font></font></td></tr></table>{#endif#}
  247.     <#if $GLOBAL_OPTIONS{database} == 1#>
  248.         <p>
  249.         You cannot import information from text files into the database at this time.
  250.         This is because you are currently using the data in the database to power your board.
  251.         If you want to import information from text files, first toggle the database OFF.
  252.         </p>
  253.         <br>
  254.     <#else#>    
  255.         <p>
  256.         This section allows you to take your existing data from the text files and import it
  257.         into your database.  For safety, you can import data only into a freshly initialized
  258.         table.  You can <a href="$general->{url}&menu=1">initialize tables</a> if needed.
  259.         </p>
  260.         <p>
  261.         <table border=0 cellpadding=0 cellspacing=0><tr><td bgcolor="#000000">
  262.         <table border=0 cellpadding=2 cellspacing=1 width=100%>
  263.         <tr bgcolor=#ffffcc>
  264.         <td class=eb>Table</td>
  265.         <td class=eb>Corresponding File</td>
  266.         <td class=eb align=center>Status</td>
  267.         <td class=eb align=right>Rows</td>
  268.         <td class=eb>Import</td>
  269.         </tr>
  270.         <#foreach $table (@tables)#>
  271.             <#define $name = $table->{name}#>
  272.             <tr bgcolor="<#pick color $table->{_iteration} from @skin_alt (1,2)#>">
  273.             <td class=enb>\u$table->{name}</td>
  274.             <td class=enb>$table->{file}</td>
  275.             <#if $table->{name} eq "counters"#>
  276.                 <td align=center class=enb>
  277.                     <#if $exists->{$name} == 1#>
  278.                         <font color=#119911>Ready</font>
  279.                     <#else#>
  280.                         <font color=#ff0000>Not Initialized</font>
  281.                     <#endif#>
  282.                 </td>
  283.             <#else#>
  284.                 <td align=center class=enb>
  285.                     <#if $exists->{$name} == 1#>
  286.                         <#if $count->{$name} > 0#>
  287.                             <font color=#ff0000>Data Exists</font>
  288.                         <#else#>
  289.                             <font color=#119911>Ready</font>
  290.                         <#endif#>
  291.                     <#else#>
  292.                         <font color=#ff0000>Not Initialized</font>
  293.                     <#endif#>
  294.                 </td>
  295.             <#endif#>
  296.             <td align=right  class=enb><#if $count->{$name} == 0#>0<#else#>$count->{$name}<#endif#> </td>
  297.             <#if $table->{name} eq "counters"#>
  298.                 <td align=center class=enb><#if $exists->{$name} == 0#><input type=checkbox disabled><#else#><input type=checkbox name=imports value="$table->{name}" CHECKED><#endif#></td>
  299.             <#else#>
  300.                 <#if $table->{name} eq "locks"#>
  301.                     <td align=center><input type=checkbox disabled></td>
  302.                 <#else#>
  303.                     <td align=center class=enb><#if $count->{$name} > 0 || $exists->{$name} == 0#><input type=checkbox disabled><#else#><input type=checkbox name=imports value="$table->{name}" CHECKED><#endif#></td>
  304.                 <#endif#>
  305.             <#endif#>            
  306.             </tr>
  307.         <#endloop#>
  308.         </table>
  309.         </td></tr></table>
  310.         </p>
  311.         <p>
  312.         <input type=submit value="Import Selected Data">
  313.         </p>
  314.         <input type=hidden name="action" value="database-import">
  315.     <#endif#>
  316. </div>
  317. <#endif#>
  318.  
  319. <#if $general->{menu} == 3#>
  320.     <div class="surround">
  321.         {#if $browser->{ieX}#}<p class="blbar">Export Data</p>{#else#}<table width=100% bgcolor=#000000><tr><td>$fs<font color=#ffff00>Export Data</font></font></td></tr></table>{#endif#}
  322.         <#if $GLOBAL_OPTIONS{database} == 0#>
  323.             <p>
  324.             You cannot export information from the database into text files at this time.
  325.             This is because you are currently using the data in the text files to power your board.
  326.             If you want to export information to text files, first toggle the database ON.
  327.             </p>
  328.             <br>
  329.         <#else#>
  330.             <p>
  331.             This section allows you to take your existing data from database and place it into plain
  332.             text files.  These text files can then be easily backed up or transferred to another
  333.             server.
  334.             </p>
  335.  
  336.         <p>
  337.         <table border=0 cellpadding=0 cellspacing=0><tr><td bgcolor="#000000">
  338.         <table border=0 cellpadding=2 cellspacing=1 width=100%>
  339.         <tr bgcolor=#ffffcc>
  340.         <td class=eb>Table</td>
  341.         <td class=eb>Corresponding File</td>
  342.         <td class=eb align=center>Status</td>
  343.         <td class=eb align=right>Rows</td>
  344.         <td class=eb>Export</td>
  345.         </tr>
  346.         <#foreach $table (@tables)#>
  347.             <#define $name = $table->{name}#>
  348.             <tr bgcolor="<#pick color $table->{_iteration} from @skin_alt (1,2)#>">
  349.             <td class=enb>\u$table->{name}</td>
  350.             <td class=enb>$table->{file}</td>
  351.             <td align=center class=enb>
  352.                 <#if $exists->{$name} == 1#>
  353.                     <#if $count->{$name} == 0#>
  354.                         <font color=#ff0000>No Data</font>
  355.                     <#else#>
  356.                         <font color=#119911>Ready</font>
  357.                     <#endif#>
  358.                 <#else#>
  359.                     <font color=#ff0000>Not Initialized</font>
  360.                 <#endif#>
  361.             </td>
  362.             <td align=right  class=enb><#if $count->{$name} == 0#>0<#else#>$count->{$name}<#endif#> </td>
  363.             <#if $table->{name} eq "locks" || $count->{$name} == 0 || $exists->{$name} == 0#>
  364.                 <td align=center><input type=checkbox disabled></td>
  365.             <#else#>
  366.                 <td align=center class=enb><input type=checkbox name=exports value="$table->{name}" CHECKED></td>
  367.             <#endif#>
  368.             </tr>
  369.         <#endloop#>
  370.         </table>
  371.         </td></tr></table>
  372.         </p>
  373.         <p>
  374.         <input type=submit value="Export Selected Data">
  375.         </p>
  376.         <input type=hidden name="action" value="database-export">
  377.         <#endif#>
  378.     </div>
  379. <#endif#>
  380.  
  381. <#if $general->{menu} == 4#>
  382.     <input type=hidden name="action" value="database-toggle">
  383.     <div class="surround">
  384.         {#if $browser->{ieX}#}<p class="blbar">Toggle Database On/Off</p>{#else#}<table width=100% bgcolor=#000000><tr><td>$fs<font color=#ffff00>Toggle Database On/Off</font></font></td></tr></table>{#endif#}
  385.         <p>
  386.         This controls whether the program stores its primary data in text files or in the
  387.         database.  You should turn on the database only after you have imported all data
  388.         from the text files into the database.
  389.         </p>
  390.         <ul>
  391.             <table><tr><td>$fs<b>Data Source:</b></font></td>
  392.             <td>
  393.             <select name="source" size=1>
  394.             <option value="0"{#if $GLOBAL_OPTIONS{database} == 0#} selected{#endif#}>Text files (Database OFF)
  395.             <#if $general->{ok_to_toggle_on} == 1#>
  396.                 <option value="1"{#if $GLOBAL_OPTIONS{database} == 1#} selected{#endif#}>Database (Database ON)
  397.                 </select></td></tr></table>
  398.             <#else#>
  399.                 </select></td></tr></table>
  400.                 <#if $general->{ok_to_toggle_on} == 0#>
  401.                     <p>
  402.                     <font color=#ff0000>You cannot turn the database on at this time.</font>  One or more
  403.                     tables is not yet initialized, or a connection could not be made to the
  404.                     database.  Please click "Setup" or "Initialize" above to remedy the situation before
  405.                     enabling the database.
  406.                     </p>
  407.                 <#else#>
  408.                     <p>
  409.                     <font color=#ff0000>You cannot turn the database on at this time.</font>
  410.                     You have not yet imported the data from your text files into your
  411.                     database.  Do this by clicking the "Import" tab.
  412.                     </p>
  413.                 <#endif#>
  414.             <#endif#>
  415.             <p>
  416.             <input type="submit" value="Save Database Setting">
  417.             </p>
  418.         </ul>
  419.     </div>
  420. <#endif#>
  421.  
  422. <#if $general->{menu} == 5#>
  423.     <div class="surround">
  424.         {#if $browser->{ieX}#}<p class="blbar">Database Statistics</p>{#else#}<table width=100% bgcolor=#000000><tr><td>$fs<font color=#ffff00>Database Statistics</font></font></td></tr></table>{#endif#}
  425.         <#if $general->{mysql_version} ne ""#>
  426.             <p>Your MySQL version is: <b>$general->{mysql_version}</b>.</p>
  427.         <#endif#>        
  428.         <#if $#stables >= 1#>
  429.             <ul>
  430.                 <table width="80%" bgcolor="#000000" cellpadding=0 cellspacing=0 border=0>
  431.                 <tr>
  432.                 <td>
  433.                     <table width="100%" border=0 cellpadding=3 cellspacing=1>
  434.                     <tr bgcolor="#ccccff">
  435.                     <td class="sb">Table Name</td>
  436.                     <td class="sb" align=right>Rows</td>
  437.                     <td class="sb" align=right>Data Size</td>
  438.                     <td class="sb" align=right>Max. Size</td>
  439.                     <td class="sb" align=right>% Used</td>
  440.                     </tr>
  441.                     <#foreach $tab (@stables)#>
  442.                         <tr bgcolor="#ffffff" align=right>
  443.                         <td class="s" align=left>$tab->{Name}</td>
  444.                         <td class="s">$tab->{Rows}</td>
  445.                         <td class="s">$tab->{Data_length}</td>
  446.                         <td class="s">$tab->{Max_data_length}</td>
  447.                         <td class="s">$tab->{percent}%</td>
  448.                         </tr>                
  449.                     <#endloop#>
  450.                     </table>        
  451.                 </td>
  452.                 </tr>
  453.                 </table>
  454.             </ul>
  455.             <input type=hidden name="foo">
  456.         <#else#>
  457.             <p>
  458.             <b>Statistics Error</b>: No tables were found in the database.  This could
  459.             occur for one of the following two reasons:
  460.             </p>
  461.             
  462.             <p>
  463.             <b>1. Not Initialized</b>: You have not initialized this database.  You
  464.             can do so through the <a href="$cgiurl?action=database&username=$general->{username}&menu=1">Initialize</a>
  465.             tab.
  466.             </p>
  467.             
  468.             <p>
  469.             <b>2. Statistics Not Supported</b>: In rare cases, your database may be
  470.             set up so that it does not respond to the
  471.             <span style="font: 10pt courier new">SHOW TABLE STATUS</span>
  472.             command, which is a SQL command used to list the tables and statistics about
  473.             the tables in your database.  Please contact your web host
  474.             (<u>not DiscusWare</u>) if you are concerned that your database does not
  475.             support <span style="font: 10pt courier new">SHOW TABLE STATUS</span>. 
  476.             </p>
  477.             <p>
  478.             Note every aspect of the Discus database functionality, except this
  479.             statistics screen, will still work properly, even if your database does
  480.             not support <span style="font: 10pt courier new">SHOW TABLE STATUS</span>.
  481.             </p>
  482.             <br />    
  483.         <#endif#>
  484.     </div>
  485. <#endif#>
  486.  
  487. </body>
  488. </html>
  489.  
  490. <!--END-->
  491.