<p>&lt;!-- RANDOM CODE SNIPPET&nbsp;--&gt;</p><p>/* Language:: C */</p><p>#include &lt;stdio.h&gt;<br />#include &lt;unistd.h&gt;<br />#include &lt;mysql/mysql.h&gt;<br />#include &lt;sys/io.h&gt;<br /><br />#define BASEPORT 0x378&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; //0x3bc /* lp1 */<br />#define MECHANISMACTIVE 0<br />#define MECHANISMINACTIVE 1<br />#define STATEACTIVE 127<br />#define STATEINACTIVE 63<br /><br />int mexit(int x)<br />{<br />&nbsp;&nbsp;&nbsp; mysql_library_end();<br />&nbsp;&nbsp;&nbsp; exit(x);<br />}<br /><br />int main()<br />{<br />//required for cgi<br />&nbsp;&nbsp;&nbsp; printf(&quot;Content-type: text/html &quot;);<br />&nbsp;&nbsp;&nbsp; /* Get access to the ports */<br />&nbsp;&nbsp;&nbsp; if (ioperm(BASEPORT, 3, 1) != 0) {<br />&nbsp;&nbsp;&nbsp; perror(&quot;ioperm&quot;);<br />&nbsp;&nbsp;&nbsp; printf(&quot;error 1.n&quot;);<br />&nbsp;&nbsp;&nbsp; exit(1);<br />&nbsp;&nbsp;&nbsp; }<br /><br />&nbsp;&nbsp;&nbsp; /* Read from the status port (BASE+1) and display the result */<br />&nbsp;&nbsp;&nbsp; int mechanismstate = 0;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; //127 is open, &gt;0 means that the mechanism is closed<br />&nbsp;&nbsp;&nbsp; mechanismstate = inb(BASEPORT + 1);<br /><br />&nbsp;&nbsp;&nbsp; if (mechanismstate == 0 || mechanismstate == STATEINACTIVE) {<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; //the mechanism must not be activated<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; printf(&quot;Location: http://automator.IniCode.co/gd.php?state=2&amp;timer=10 &quot;);<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; exit(0);<br />&nbsp;&nbsp;&nbsp; } else {<br /><br />&nbsp;&nbsp;&nbsp; mechanismstate = MECHANISMINACTIVE;<br />&nbsp;&nbsp;&nbsp; /* Set data pin 1 high to trigger mechanism */<br />&nbsp;&nbsp;&nbsp; outb(1, BASEPORT);<br />&nbsp;&nbsp;&nbsp; /* Sleep for a while (400 ms) */<br />&nbsp;&nbsp;&nbsp; usleep(400000);<br />&nbsp;&nbsp;&nbsp; /* Set the data signals (D0-7) of the port to all low (0) */<br />&nbsp;&nbsp;&nbsp; outb(0, BASEPORT);<br />&nbsp;&nbsp;&nbsp; }<br />&nbsp;&nbsp;&nbsp; /* We don&#39;t need the ports anymore */<br />&nbsp;&nbsp;&nbsp; if (ioperm(BASEPORT, 3, 0) != 0) {<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; perror(&quot;ioperm&quot;);<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; exit(1);<br />&nbsp;&nbsp;&nbsp; }<br />//begin mysql bullshittery<br />&nbsp;&nbsp;&nbsp; MYSQL *conn;<br />&nbsp;&nbsp;&nbsp; MYSQL_RES *result;<br />&nbsp;&nbsp;&nbsp; MYSQL_ROW row;<br />&nbsp;&nbsp;&nbsp; int num_fields;<br />&nbsp;&nbsp;&nbsp; conn = mysql_init(NULL);<br /><br />&nbsp;&nbsp;&nbsp; if (conn == NULL) {<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; printf(&quot;Error %u: %sn&quot;, mysql_errno(conn), mysql_error(conn));<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; mexit(1);<br />&nbsp;&nbsp;&nbsp; }<br /><br />&nbsp;&nbsp;&nbsp; if (mysql_real_connect(conn, &quot;inicode&quot;, &quot;root&quot;, &quot;password&quot;, &quot;automator&quot;, 0, NULL, 0) == NULL) {<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; printf(&quot;Error %u: %sn&quot;, mysql_errno(conn), mysql_error(conn));<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; mexit(1);<br />&nbsp;&nbsp;&nbsp; }<br />&nbsp;&nbsp;&nbsp; char query[256];<br />&nbsp;&nbsp;&nbsp; char *stat = &quot;INSERT INTO gateway(`time`, `date`, `accesstime`, `state`) VALUES(CURRENT_TIME(),CURRENT_DATE(),NOW(), %d)&quot;;<br />&nbsp;&nbsp;&nbsp; int len = snprintf(query, sizeof(query), stat, mechanismstate);<br /><br />&nbsp;&nbsp;&nbsp; if (mysql_real_query(conn, query, len)) {<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; printf(&quot;Error %u: %sn&quot;, mysql_errno(conn), mysql_error(conn));<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; mysql_close(conn);<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; mexit(1);<br />&nbsp;&nbsp;&nbsp; }<br />&nbsp;&nbsp;&nbsp; mysql_close(conn);<br />&nbsp;&nbsp;&nbsp; mysql_library_end();<br />&nbsp;&nbsp;&nbsp; printf(&quot;Location: http://automator.IniCode.co/gd.php?state=1&amp;timer=30 &quot;);<br />&nbsp;&nbsp;&nbsp; exit(0);<br />}