<%Links::Tools::sql_monitor%>
<html>

<head>
<title>Gossamer Links - Tools - SQL Monitor</title>
<base target="_self">
</head>

<body bgcolor="#FFFFFF">

<%Links::header('SQL Monitor', 'This lets you send queries directly to your SQL server. If you are using MySQL as your database, you can use MySQLMan for more robust SQL management.')%>

<br>
<form action="admin.cgi" method="POST" onsubmit="if (document.getElementById('query').value == '') { alert('No query entered!'); return false }">
<input type="hidden" name="do" value="page">
<input type="hidden" name="page" value="tools_sql_monitor.html">

<table border="1" cellpadding="0" cellspacing="0"><tr><td>
  <table bgColor="#ffffff" border="0" cellPadding="3" cellSpacing="3" width="500" valign="top">
    <tr><td>
      <font size="2" face="Tahoma,Arial,Helvetica">
	Please enter your query (Gossamer Links tables are <%if db_prefix%>prefixed with '<%db_prefix%>'<%else%>not prefixed<%endif%>):
	<br><br>
	<textarea name="query" rows="4" cols="50" id="query" style="width: 100%"><%if query and error%><%escape_html query%><%endif%></textarea><br>
	<%if query and not error%>
	  <script type="text/javascript">
	    function setLastQuery () {
	      document.getElementById('query').value = "<%escape_js unescape_html query%>";
	    }
	  </script>
	  Last query: <a href="javascript:setLastQuery()" title="Click to set query box"><pre style="margin: 0px"><%escape_html query%></pre></a><br>
	<%endif%>
	Save output to file: <input type=text name="saveto" value="<%if saveto%><%saveto%><%endif%>" size=10> (leave blank to output to screen)<br>
	Output format: <input type="radio" name="style" value="tabs"<%if style eq 'tabs'%> checked<%endif%>> Tab-separated values <input type="radio" name="style" value="text"<%if style eq 'text'%> checked<%endif%>> Text <input type="radio" name="style" value="html"<%if style eq 'html' or not style%> checked<%endif%>> HTML<br>
	<br>
	<input type="submit" name="monitor" value="Execute Query">
      </font>
    </td></tr>
  </table>
</table>
</form>

<%if error%>
	<p style="font-weight: bold; color: red; font-family: Tahoma,Arial,Helvetica,sans-serif; font-size: small">Error:
	  <%if error_connect%>Could not connect to database: <%escape_html error_connect%><%endif%>
	  <%if error_prepare%>Could not prepare query: <%escape_html error_prepare%><%endif%>
	  <%if error_execute%>Could not execute query: <%escape_html error_execute%><%endif%>
	  <%if error_other%><%escape_html error_other%><%endif%>
	</p>
<%endif%>

<%if results%>
  <%unless results starts "Rows affected"%><p>Your query returned <%rows%> rows.</p><%endunless%>
  <%results%>
<%endif%>

</body>
</html>
