Viewing topic:MySQL database/with admin access
Page: 1
Topic post 12-05-2008 - 15:49
Quote:


[15-12-2007 10:48] Jim wrote:
Hey Jalkson!

Thanks for the compliments .

About the user recognition, using the hostname like you said is the way to go. What i did for my bot is created a table with all the hostnames (inc nick) in it who have admin access.

This way you can do it different, you can save the hostname, and in a second row you can set his admin level.

Each time a user says something, just quickly check his user level (is he has any) and now you know what he can, and what he can't do.

This is how i did it:

code
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36

<?php
 
// Bot.php
 
		/**
		* Store all the admin's in a variable
		*/
		$admin1 = mysql_query("SELECT * FROM admin&quot;);
		$admin = "";
		while ($admin2 = mysql_fetch_assoc($admin1)){
			$admin .= $admin2['admin']." ";
		}	
 
 
		/**
		* Extract the hostname of posters
		*/
		preg_match('/^:(.*?)!(.*?)$/i', $ex[0], $matches);
		$hostname = "!".$matches[2];
		$username = $matches[1];
 
 
// Functions.php
 
function is_admin($hostname){
	global $admin;
	$pos = strpos($admin, $hostname);
	if ($pos === FALSE){
		return FALSE;
	}else{
		return TRUE;
	} 
 
}
 
?>
 


It's quite old code, and it's very ugly. But it works good enough.

Let me know if you have other problems.

(Notice that the code BB is wrong, at the end of some lines the quotes are turned into html code, this will soon be fixed with the new backend... Sorry!)


I used that code; I fixed all of the errors, but It still doesnt stop others from doing commands. What do I put in the MySQL table/row for it to only work for my host?
Topic post 12-05-2008 - 19:18
You have to set your hostname in the table. So Jim!*@hostname.com for example.

Do you have a good table set? How does your table look like? And how do you use the code in your bot?

And erm, welcome to CM!
Topic post 13-05-2008 - 00:42
Thanks, for the welcome. Im really really new at this, but Im a fast learner. Its used in my script as a user recongization thing for the commands on my bot.
Topic post 13-05-2008 - 11:17
Hehe i understand that

Did you make a table in your database? (CREATE TABLE admin (... etc)

Topic post 15-05-2008 - 01:05
I think I did, atleast I hope I did.
Topic post 15-05-2008 - 09:04
Oh... Hmm do you have PHPmyAdmin installed or something like that? That's a SQL administration tool where you can check if you have the table set.

And are you sure you have SQL connection open? (mysql_connect and mysql_select_db)

Hmm, once i get home I'll send you the full code of my bot. Is it OK if I send an email to the adres you've registered with?
Topic post 03-06-2008 - 03:59
Quote:


[15-05-2008 09:04] Jim wrote:
Oh... Hmm do you have PHPmyAdmin installed or something like that? That's a SQL administration tool where you can check if you have the table set.

And are you sure you have SQL connection open? (mysql_connect and mysql_select_db)

Hmm, once i get home I'll send you the full code of my bot. Is it OK if I send an email to the adres you've registered with?


Sorry for the late reply. Been out of town. Sure, email it to me at michaelpwnsyouall@yahoo.com

©Copyrights Combined Minds. All rights reserved 2006 - 2008 : Disclaimer
Realized by www.Minna-Media.com