<?xml version="1.0" encoding="UTF-8"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en-gb">
	<link rel="self" type="application/atom+xml" href="https://forum.eggheads.org/app.php/feed/topic/18878" />

	<title>egghelp/eggheads community</title>
	<subtitle>Discussion of eggdrop bots, shell accounts and tcl scripts.</subtitle>
	<link href="https://forum.eggheads.org/index.php" />
	<updated>2012-03-10T11:33:08-04:00</updated>

	<author><name><![CDATA[egghelp/eggheads community]]></name></author>
	<id>https://forum.eggheads.org/app.php/feed/topic/18878</id>

		<entry>
		<author><name><![CDATA[caesar]]></name></author>
		<updated>2012-03-10T11:33:08-04:00</updated>

		<published>2012-03-10T11:33:08-04:00</published>
		<id>https://forum.eggheads.org/viewtopic.php?p=98994#p98994</id>
		<link href="https://forum.eggheads.org/viewtopic.php?p=98994#p98994"/>
		<title type="html"><![CDATA[store user in db to get access to chan]]></title>

		
		<content type="html" xml:base="https://forum.eggheads.org/viewtopic.php?p=98994#p98994"><![CDATA[
Just add this:<div class="codebox"><p>Code: </p><pre><code>  bind pub o|o .dbadd [namespace current]::dbAdd  # add  proc dbAdd {nick uhost handle chan text} {    if {[scan $text {%s%[^!]!%[^@]@%s} user n u h] != 4} {      putserv "NOTICE $nick :Usage: .dbadd &lt;user&gt; &lt;maskhost&gt;"    } else {      set user [::mysql::escape $user]      set maskHost [::mysql::escape "$n!$u@$h"]      set con [::mysql::connect -host $hostname -user $username -password $password -db $database]      set query [::mysql::query $con "INSERT INTO access VALUES ('$user', '$maskHost')"]      ::mysql::endquery $query      ::mysql::close $con     }  }</code></pre></div>to the other code just before the last <em class="text-italics"><strong class="text-strong">}</strong></em>, so in the end it would be something like:<div class="codebox"><p>Code: </p><pre><code>namespace eval dbCheck {# and so on..# this new code}</code></pre></div>Haven't tested anything but in theory should do what you need. <img class="smilies" src="https://forum.eggheads.org/images/smilies/icon_razz.gif" width="15" height="15" alt=":P" title="Razz"><br><br>PS: You should take in to consideration nml375's comment (on escaping) when you will insert a valid select statement for the first code.<p>Statistics: Posted by <a href="https://forum.eggheads.org/memberlist.php?mode=viewprofile&amp;u=187">caesar</a> — Sat Mar 10, 2012 11:33 am</p><hr />
]]></content>
	</entry>
		<entry>
		<author><name><![CDATA[Fire-Fox]]></name></author>
		<updated>2012-03-10T09:29:49-04:00</updated>

		<published>2012-03-10T09:29:49-04:00</published>
		<id>https://forum.eggheads.org/viewtopic.php?p=98992#p98992</id>
		<link href="https://forum.eggheads.org/viewtopic.php?p=98992#p98992"/>
		<title type="html"><![CDATA[store user in db to get access to chan]]></title>

		
		<content type="html" xml:base="https://forum.eggheads.org/viewtopic.php?p=98992#p98992"><![CDATA[
Thanks caesar!<br><br>Sure think i can use it <img class="smilies" src="https://forum.eggheads.org/images/smilies/icon_smile.gif" width="15" height="15" alt=":)" title="Smile"> just need to figure out to put in a admin trigger to add users <img class="smilies" src="https://forum.eggheads.org/images/smilies/icon_smile.gif" width="15" height="15" alt=":)" title="Smile"> with user and hostname <img class="smilies" src="https://forum.eggheads.org/images/smilies/icon_smile.gif" width="15" height="15" alt=":)" title="Smile"><p>Statistics: Posted by <a href="https://forum.eggheads.org/memberlist.php?mode=viewprofile&amp;u=8230">Fire-Fox</a> — Sat Mar 10, 2012 9:29 am</p><hr />
]]></content>
	</entry>
		<entry>
		<author><name><![CDATA[nml375]]></name></author>
		<updated>2012-03-10T08:54:10-04:00</updated>

		<published>2012-03-10T08:54:10-04:00</published>
		<id>https://forum.eggheads.org/viewtopic.php?p=98990#p98990</id>
		<link href="https://forum.eggheads.org/viewtopic.php?p=98990#p98990"/>
		<title type="html"><![CDATA[store user in db to get access to chan]]></title>

		
		<content type="html" xml:base="https://forum.eggheads.org/viewtopic.php?p=98990#p98990"><![CDATA[
caesar,<br>Whenever you inject data from an untrusted source, you should use mysql_real_escape_string (::mysql::escape in mysqltcl) in order to avoid SQL injection exploits. Although the MySQL driver does not enable the multiple statement extension by default, you could still bypass the WHERE-clause of your query (generally speaking, irc nicknames and hostnames do not support spaces making it rather difficult to exploit "OR 1" here).<br><br>As such, escaping the nickname is correct, though you should do the very same for the hostname.<p>Statistics: Posted by <a href="https://forum.eggheads.org/memberlist.php?mode=viewprofile&amp;u=8052">nml375</a> — Sat Mar 10, 2012 8:54 am</p><hr />
]]></content>
	</entry>
		<entry>
		<author><name><![CDATA[caesar]]></name></author>
		<updated>2012-03-10T07:27:27-04:00</updated>

		<published>2012-03-10T07:27:27-04:00</published>
		<id>https://forum.eggheads.org/viewtopic.php?p=98989#p98989</id>
		<link href="https://forum.eggheads.org/viewtopic.php?p=98989#p98989"/>
		<title type="html"><![CDATA[store user in db to get access to chan]]></title>

		
		<content type="html" xml:base="https://forum.eggheads.org/viewtopic.php?p=98989#p98989"><![CDATA[
<div class="codebox"><p>Code: </p><pre><code>namespace eval dbCheck {  set dbInfo "host user pass database"  bind join - "#channel *" [namespace current]::dbJoin  proc dbJoin {nick uhost handle chan} {    if {[isbotnick $nick]} return    variable dbInfo    if {[scan $dbInfo %s%s%s%s hostname username password database] != 4} return    set con [::mysql::connect -host $hostname -user $username -password $password -db $database]    set results [::mysql::query $con "INSERT YOUR SELECT STATEMENT"]    if {![::mysql::moreresult $results]} {      # kick, ban or whatever    }    ::mysql::endquery $results    ::mysql::close $con  }}</code></pre></div>Something like this? Don't forget to add an actual select statement and a punishment or whatever you wish. Haven't tested it, but should do what you where looking for.<br><br>I would use a statement like:<div class="codebox"><p>Code: </p><pre><code>set user [::mysql::escape $nick]set results [::mysql::query $con "SELECT 1 from access WHERE nick = '$user' AND uhost = '$uhost'"]</code></pre></div>Don't know if $nick should be escaped but will throw that in anyway.<br><br>If you wish to make this to work for multiple channels, or be able to turn this on/off then you should use something like:<div class="codebox"><p>Code: </p><pre><code>  setudef flag dbCheck  bind join - * [namespace current]::dbJoin  proc dbJoin {nick uhost handle chan} {    if {[isbotnick $nick]} return    if {![channel get $chan dbCheck]} return</code></pre></div>instead of the:<div class="codebox"><p>Code: </p><pre><code>  bind join - "#channel *" [namespace current]::dbJoin  proc dbJoin {nick uhost handle chan} {    if {[isbotnick $nick]} return</code></pre></div>If you do then don't forget to <em class="text-italics">.chanset #channel +dbCheck</em> to activate it. <img class="smilies" src="https://forum.eggheads.org/images/smilies/icon_smile.gif" width="15" height="15" alt=":)" title="Smile"><p>Statistics: Posted by <a href="https://forum.eggheads.org/memberlist.php?mode=viewprofile&amp;u=187">caesar</a> — Sat Mar 10, 2012 7:27 am</p><hr />
]]></content>
	</entry>
		<entry>
		<author><name><![CDATA[Fire-Fox]]></name></author>
		<updated>2012-03-09T20:27:51-04:00</updated>

		<published>2012-03-09T20:27:51-04:00</published>
		<id>https://forum.eggheads.org/viewtopic.php?p=98987#p98987</id>
		<link href="https://forum.eggheads.org/viewtopic.php?p=98987#p98987"/>
		<title type="html"><![CDATA[store user in db to get access to chan]]></title>

		
		<content type="html" xml:base="https://forum.eggheads.org/viewtopic.php?p=98987#p98987"><![CDATA[
Hey!<br><br>I belive i did see a script here on the site, that did. add user to db and the user gained access to a channel is that right? <br><br>if not does someone have one ?<p>Statistics: Posted by <a href="https://forum.eggheads.org/memberlist.php?mode=viewprofile&amp;u=8230">Fire-Fox</a> — Fri Mar 09, 2012 8:27 pm</p><hr />
]]></content>
	</entry>
	</feed>
