PHP Hub Account Viewer
 

PHP Hub Account Viewer

Started by quicky2g, 01 December, 2008, 05:52:47

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

quicky2g

This web based php script will give you the ability to:


  • See the total number of users on your hub
  • View all you accounts for each profile
  • Search through all your accounts by nickname (Any lowercase or uppercase)

See these lines for comments about how to modify the script for your needs:


  • 24
  • 28
  • 39-43
  • 51-56
  • 89-99
  • 114
  • 128-133
  • 194
  • 226-231

Here's the script:

<html>
<head>
<title>DC Hub Accounts</title>
<style type="text/css">
table {
	margin-left: 10px;
}
table td {
	width: 80px;
	text-align: center;
	padding: 1px 1px 1px 1px;
}
table td.even {
	background-color: lightgray;
	color: darkblue;
}
table td.odd {
	background-color: white;
	color: darkblue;
}
</style>
</head>
<body>
<!-- Edit the title in the "<h1>" tag to whatever you want -->
<h1>DC Hub Accounts
<!-- Small php section below gets the total number of users -->
<?php
//Modify $dir and $userlist variable for whatever folder and file path your RegisteredUsers.xml file is in
$dir = "C:/0.4.1.1/cfg/";
$userlist = "RegisteredUsers.xml";
$xml = simplexml_load_file($dir.$userlist);
$total = count($xml->RegisteredUser);
echo " <font size=4>($total Total Users)</font>";
?>
</h1>
<fieldset style="width: 450px"><legend><b><i>View Nicknames by Profile</i></b></legend>
<form action="<?php echo $_SERVER['PHP_SELF'] ?>" method="GET">
<table>
<!--
Modify this table row to change the web page display of whatever profiles you are using
Remove table headers that you don't need
Add any table headers that you do need
-->
<tr>
	<th>&nbsp;&nbsp;Master&nbsp;&nbsp;</th>
	<th>&nbsp;&nbsp;Operator&nbsp;&nbsp;</th>
	<th>&nbsp;&nbsp;NoShare&nbsp;&nbsp;</th>
	<th>&nbsp;&nbsp;Reg&nbsp;&nbsp;</th>
	<th>&nbsp;&nbsp;TS&nbsp;&nbsp;</th>
</tr>
<!--
Modify this table row to change the values of the profiles you are using
Typically Master profiles are 0, Operators are 1, etc.
Remove any table definitions you don't need
Add any table definitions you do need
-->
<tr>
	<td><input type="radio" value="0" name="thevalue" <?php if(isset($_GET['thevalue']) && ($_GET['thevalue']==0)){echo "checked";}?>></td>
	<td><input type="radio" value="1" name="thevalue" <?php if(isset($_GET['thevalue']) && ($_GET['thevalue']==1)){echo "checked";}?>></td>
	<td><input type="radio" value="2" name="thevalue" <?php if(isset($_GET['thevalue']) && ($_GET['thevalue']==2)){echo "checked";}?>></td>
	<td><input type="radio" value="3" name="thevalue" <?php if(isset($_GET['thevalue']) && ($_GET['thevalue']==3)){echo "checked";}?>></td>
	<td><input type="radio" value="4" name="thevalue" <?php if(isset($_GET['thevalue']) && ($_GET['thevalue']==4)){echo "checked";}?>></td>
</tr>
</table>
<br />
<center><input type="submit" value="View" name="submit"></center>
</form>
</fieldset>
<br />
<fieldset style="width: 450px"><legend><b><i>Search for a Nickname</i></b></legend>
<form action="<?php echo $_SERVER['PHP_SELF'] ?>" method="GET">
<br />
<center><input style="width: 250px" type="text" name="searcher" value="
<?php
//if statement is used to get the last search value and enter it in the search box as the default value
if (isset($_GET['searcher'])) {
echo $_GET['searcher'];
}
?>
">
<input type="submit" value="Search" name="search"></center>
</form><center>Enter a "." (dot) to see all nicknames</center>
</fieldset>
<br />
</body>
</html>

<?php
/*
The if statement below will only allow IP ranges that you specify to view this webpage
All other IP ranges will be redirected to http://www.google.com
If you want to specify more IP ranges...
add another variable called $test3 or $test4 or more with the IP range that you want
then modify the beginning of the if statement to look like this

if (!eregi($test,$ip) && !eregi($test2,$ip) && !eregi($test3,$ip) && !eregi($test4,$ip)){

...or whatever suits your needs
*/
$test = "^136.224";
$test2 = "^127.0";
$ip = $_SERVER['REMOTE_ADDR'];
if (!eregi($test,$ip) && !eregi($test2,$ip)){
  header( 'Location: http://www.google.com' );
  echo "Please wait...";
  exit(0);
}
if(isset($_GET['submit'])) {
	if (isset($_GET['thevalue'])) {
		$desiredprofile = $_GET['thevalue'];
		//Uncomment next line to force profile output on page for a profile level
		//$desiredprofile = "0";
		$dom = new DOMDocument();
		//Modify $dom variable for whatever the path is to your RegisteredUsers.xml file
		$dom->load('C:/0.4.1.1/cfg/RegisteredUsers.xml');
		//count variable keeps track of how many times the <table> tag was used...it is only needed once
		$count = 0;
		//regcounter variable figures out what registered number a nickname is
		$regcounter = 0;
		//numresults variable figures out how many results are returned for the search
		$numresults = 0;
		/*
		rowcounter variable is used to count the number of rows returned from the search result
		variable is then used to alternate the row color backgrounds in the created table
		*/
		$rowcounter = 0;
  
		/*
		Big if statement below will change profile level numbers to the text text name
		Modify the $displayprofile values to whatever fits your needs
		Remove any of the elseif sections if you do not need them
		Add any elseif sections if you need them
		*/
		if ($desiredprofile == 0) {
			$displayprofile = "Master";
		} elseif ($desiredprofile == 1) {
			$displayprofile = "Operator";
		} elseif ($desiredprofile == 2) {
			$displayprofile = "NoShare";
		} elseif ($desiredprofile == 3) {
			$displayprofile = "Reg";
		} elseif ($desiredprofile == 4) {
			$displayprofile = "TS";
		}
		/*
		foreach loop looks at each RegisteredUser tag and grabs the information inside the tag
		and assigns the values inside the RegisteredUser tag to variables to be used later
		*/
		foreach ($dom->getElementsByTagname('RegisteredUser') as $element) {
			$Nick = $element->getAttribute('Nick');
			foreach (($element->childNodes) as $e) {
				if (is_a($e, 'DOMElement')) {
					if ($e->tagName == 'Nick') {
						$Nick = htmlspecialchars($e->textContent);
					} elseif ($e->tagName == 'Password') {
						$Password = htmlspecialchars($e->textContent);
					} elseif ($e->tagName == 'Profile') {
						$Profile = htmlspecialchars($e->textContent);
					}
				}
			}
			$regcounter += 1;
			if ($Profile == $desiredprofile){
				//echo "This is rowcounter: $rowcounter";
				if ($count < 1) {
					echo "<table border='1'><tr><th>Registered Number</th><th>Nickname</th></tr>";
					$count = 1;
				}
				if ($rowcounter % 2){
					echo "<tr><td class='even'>$regcounter</td><td class='even'>$Nick</td></tr>";
					$rowcounter += 1;
					$numresults += 1;
				} else {
					echo "<tr><td class='odd'>$regcounter</td><td class='odd'>$Nick</td></tr>";
					$rowcounter += 1;
					$numresults += 1;
				}
			} else {
				continue;
			}
		}
		echo "<b>$numresults</b> users with the profile: <b>$displayprofile</b><br /><br />";
	} else {
		//if a profile wasn't selected but the "View" button was clicked, the message below will show
		echo "Please select a profile to view";
	}
} elseif (isset($_GET['search'])) {
	$desiredstring = $_GET['searcher'];
	if ($desiredstring == "") {
		//if the "Search" button was clicked but no criteria was entered to search for, the message below will show
		echo "Please enter a valid nickname search string";
	} else {
		$dom = new DOMDocument();
		//Modify $dom variable for whatever the path is to your RegisteredUsers.xml file
		$dom->load('C:/0.4.1.1/cfg/RegisteredUsers.xml');
		$count = 0;
		$numresults = 0;
		$regcounter = 0;
	}
	if (isset($dom)) {
		foreach ($dom->getElementsByTagname('RegisteredUser') as $element) {
			$Nick = $element->getAttribute('Nick');
			//Do not change the foreach statement or the xml file will not be read correctly
			//For whatever reason, the foreach statement needs to read every field inside the "RegisteredUser" tag
			//even though it will not display every field
			foreach (($element->childNodes) as $e) {
				if (is_a($e, 'DOMElement')) {
					if ($e->tagName == 'Nick') {
						$Nick = htmlspecialchars($e->textContent);
					} elseif ($e->tagName == 'Password') {
						$Password = htmlspecialchars($e->textContent);
					} elseif ($e->tagName == 'Profile') {
						$Profile = htmlspecialchars($e->textContent);
					}
				}
			}
			if (eregi($desiredstring,$Nick)){
				$regcounter += 1;
				//if statement makes sure the table tags and other tag headers are only displayed once
				if ($count < 1) {
					//echo "The results of '<b>$desiredstring</b>' are:<br />";
					echo "<table border='1'><tr><th>Registered Number</th><th>Profile</th><th>Nickname</th></tr>";
					$count = 1;
				}
				
				/*
				Big if statement below will change profile level numbers to the text text name
				Modify the $displayprofile values to whatever fits your needs
				Remove any of the elseif sections if you do not need them
				Add any elseif sections if you need them
				*/
				if ($Profile == 0) {
					$Profiledisplay = "Master";
				} elseif ($Profile == 1) {
					$Profiledisplay = "Operator";
				} elseif ($Profile == 2) {
					$Profiledisplay = "NoShare";
				} elseif ($Profile == 3) {
					$Profiledisplay = "Reg";
				} elseif ($Profile == 4) {
					$Profiledisplay = "TS";
				}
				//if statement below changes the background color of the table rows to alternate by changing the "class" values
				if ($numresults % 2){
					echo "<tr><td class='even'>$regcounter</td><td class='even'>$Profiledisplay</td><td class='even'>$Nick</td></tr>";
				} else {
					echo "<tr><td class='odd'>$regcounter</td><td class='odd'>$Profiledisplay</td><td class='odd'>$Nick</td></tr>";
				}
					$numresults += 1;
			} else {
				$regcounter += 1;
				continue;
			}
		}
	}
	//if statement will show how many results there are for whatever nickname search string was entered
	if (isset($dom)){
		echo "<b>$numresults</b> results for '<b>$desiredstring</b>'<br /><br />";
	}
}
?>


Here's a few pics of what my searching looked like:

Viewing the Master Profiles



Searching for "qui"



If anyone wants a version that is able to view the passwords with the nicknames and profile levels...use this script instead (Make sure you still read the lines listed above to meet your needs):

<html>
<head>
<title>DC Hub Accounts</title>
<style type="text/css">
table {
	margin-left: 10px;
}
table td {
	width: 80px;
	text-align: center;
	padding: 1px 1px 1px 1px;
}
table td.even {
	background-color: lightgray;
	color: darkblue;
}
table td.odd {
	background-color: white;
	color: darkblue;
}
</style>
</head>
<body>
<!-- Edit the title in the "<h1>" tag to whatever you want -->
<h1>DC Hub Accounts
<!-- Small php section below gets the total number of users -->
<?php
//Modify $dir and $userlist variable for whatever folder and file path your RegisteredUsers.xml file is in
$dir = "C:/0.4.1.1/cfg/";
$userlist = "RegisteredUsers.xml";
$xml = simplexml_load_file($dir.$userlist);
$total = count($xml->RegisteredUser);
echo " <font size=4>($total Total Users)</font>";
?>
</h1>
<fieldset style="width: 450px"><legend><b><i>View Nicknames by Profile</i></b></legend>
<form action="<?php echo $_SERVER['PHP_SELF'] ?>" method="GET">
<table>
<!--
Modify this table row to change the web page display of whatever profiles you are using
Remove table headers that you don't need
Add any table headers that you do need
-->
<tr>
	<th>&nbsp;&nbsp;Master&nbsp;&nbsp;</th>
	<th>&nbsp;&nbsp;Operator&nbsp;&nbsp;</th>
	<th>&nbsp;&nbsp;NoShare&nbsp;&nbsp;</th>
	<th>&nbsp;&nbsp;Reg&nbsp;&nbsp;</th>
	<th>&nbsp;&nbsp;TS&nbsp;&nbsp;</th>
</tr>
<!--
Modify this table row to change the values of the profiles you are using
Typically Master profiles are 0, Operators are 1, etc.
Remove any table definitions you don't need
Add any table definitions you do need
-->
<tr>
	<td><input type="radio" value="0" name="thevalue" <?php if(isset($_GET['thevalue']) && ($_GET['thevalue']==0)){echo "checked";}?>></td>
	<td><input type="radio" value="1" name="thevalue" <?php if(isset($_GET['thevalue']) && ($_GET['thevalue']==1)){echo "checked";}?>></td>
	<td><input type="radio" value="2" name="thevalue" <?php if(isset($_GET['thevalue']) && ($_GET['thevalue']==2)){echo "checked";}?>></td>
	<td><input type="radio" value="3" name="thevalue" <?php if(isset($_GET['thevalue']) && ($_GET['thevalue']==3)){echo "checked";}?>></td>
	<td><input type="radio" value="4" name="thevalue" <?php if(isset($_GET['thevalue']) && ($_GET['thevalue']==4)){echo "checked";}?>></td>
</tr>
</table>
<br />
<center><input type="submit" value="View" name="submit"></center>
</form>
</fieldset>
<br />
<fieldset style="width: 450px"><legend><b><i>Search for a Nickname</i></b></legend>
<form action="<?php echo $_SERVER['PHP_SELF'] ?>" method="GET">
<br />
<center><input style="width: 250px" type="text" name="searcher" value="
<?php
//if statement is used to get the last search value and enter it in the search box as the default value
if (isset($_GET['searcher'])) {
echo $_GET['searcher'];
}
?>
">
<input type="submit" value="Search" name="search"></center>
</form><center>Enter a "." (dot) to see all nicknames</center>
</fieldset>
<br />
</body>
</html>

<?php
/*
The if statement below will only allow IP ranges that you specify to view this webpage
All other IP ranges will be redirected to http://www.google.com
If you want to specify more IP ranges...
add another variable called $test3 or $test4 or more with the IP range that you want
then modify the beginning of the if statement to look like this

if (!eregi($test,$ip) && !eregi($test2,$ip) && !eregi($test3,$ip) && !eregi($test4,$ip)){

...or whatever suits your needs
*/
$test = "^136.224";
$test2 = "^127.0";
$ip = $_SERVER['REMOTE_ADDR'];
if (!eregi($test,$ip) && !eregi($test2,$ip)){
  header( 'Location: http://www.google.com' );
  echo "Please wait...";
  exit(0);
}
if(isset($_GET['submit'])) {
	if (isset($_GET['thevalue'])) {
		$desiredprofile = $_GET['thevalue'];
		//Uncomment next line to force profile output on page for a profile level
		//$desiredprofile = "0";
		$dom = new DOMDocument();
		//Modify $dom variable for whatever the path is to your RegisteredUsers.xml file
		$dom->load('C:/0.4.1.1/cfg/RegisteredUsers.xml');
		//count variable keeps track of how many times the <table> tag was used...it is only needed once
		$count = 0;
		//regcounter variable figures out what registered number a nickname is
		$regcounter = 0;
		//numresults variable figures out how many results are returned for the search
		$numresults = 0;
		/*
		rowcounter variable is used to count the number of rows returned from the search result
		variable is then used to alternate the row color backgrounds in the created table
		*/
		$rowcounter = 0;
  
		/*
		Big if statement below will change profile level numbers to the text text name
		Modify the $displayprofile values to whatever fits your needs
		Remove any of the elseif sections if you do not need them
		Add any elseif sections if you need them
		*/
		if ($desiredprofile == 0) {
			$displayprofile = "Master";
		} elseif ($desiredprofile == 1) {
			$displayprofile = "Operator";
		} elseif ($desiredprofile == 2) {
			$displayprofile = "NoShare";
		} elseif ($desiredprofile == 3) {
			$displayprofile = "Reg";
		} elseif ($desiredprofile == 4) {
			$displayprofile = "TS";
		}
		/*
		foreach loop looks at each RegisteredUser tag and grabs the information inside the tag
		and assigns the values inside the RegisteredUser tag to variables to be used later
		*/
		foreach ($dom->getElementsByTagname('RegisteredUser') as $element) {
			$Nick = $element->getAttribute('Nick');
			foreach (($element->childNodes) as $e) {
				if (is_a($e, 'DOMElement')) {
					if ($e->tagName == 'Nick') {
						$Nick = htmlspecialchars($e->textContent);
					} elseif ($e->tagName == 'Password') {
						$Password = htmlspecialchars($e->textContent);
					} elseif ($e->tagName == 'Profile') {
						$Profile = htmlspecialchars($e->textContent);
					}
				}
			}
			$regcounter += 1;
			if ($Profile == $desiredprofile){
				//echo "This is rowcounter: $rowcounter";
				if ($count < 1) {
					echo "<table border='1'><tr><th>Registered Number</th><th>Nickname</th><th>Password</th></tr>";
					$count = 1;
				}
				if ($rowcounter % 2){
					echo "<tr><td class='even'>$regcounter</td><td class='even'>$Nick</td><td class='even'>$Password</td></tr>";
					$rowcounter += 1;
					$numresults += 1;
				} else {
					echo "<tr><td class='odd'>$regcounter</td><td class='odd'>$Nick</td><td class='odd'>$Password</td></tr>";
					$rowcounter += 1;
					$numresults += 1;
				}
			} else {
				continue;
			}
		}
		echo "<b>$numresults</b> users with the profile: <b>$displayprofile</b><br /><br />";
	} else {
		//if a profile wasn't selected but the "View" button was clicked, the message below will show
		echo "Please select a profile to view";
	}
} elseif (isset($_GET['search'])) {
	$desiredstring = $_GET['searcher'];
	if ($desiredstring == "") {
		//if the "Search" button was clicked but no criteria was entered to search for, the message below will show
		echo "Please enter a valid nickname search string";
	} else {
		$dom = new DOMDocument();
		//Modify $dom variable for whatever the path is to your RegisteredUsers.xml file
		$dom->load('C:/0.4.1.1/cfg/RegisteredUsers.xml');
		$count = 0;
		$numresults = 0;
		$regcounter = 0;
	}
	if (isset($dom)) {
		foreach ($dom->getElementsByTagname('RegisteredUser') as $element) {
			$Nick = $element->getAttribute('Nick');
			//Do not change the foreach statement or the xml file will not be read correctly
			//For whatever reason, the foreach statement needs to read every field inside the "RegisteredUser" tag
			//even though it will not display every field
			foreach (($element->childNodes) as $e) {
				if (is_a($e, 'DOMElement')) {
					if ($e->tagName == 'Nick') {
						$Nick = htmlspecialchars($e->textContent);
					} elseif ($e->tagName == 'Password') {
						$Password = htmlspecialchars($e->textContent);
					} elseif ($e->tagName == 'Profile') {
						$Profile = htmlspecialchars($e->textContent);
					}
				}
			}
			if (eregi($desiredstring,$Nick)){
				$regcounter += 1;
				//if statement makes sure the table tags and other tag headers are only displayed once
				if ($count < 1) {
					//echo "The results of '<b>$desiredstring</b>' are:<br />";
					echo "<table border='1'><tr><th>Registered Number</th><th>Profile</th><th>Nickname</th><th>Password</th></tr>";
					$count = 1;
				}
				
				/*
				Big if statement below will change profile level numbers to the text text name
				Modify the $displayprofile values to whatever fits your needs
				Remove any of the elseif sections if you do not need them
				Add any elseif sections if you need them
				*/
				if ($Profile == 0) {
					$Profiledisplay = "Master";
				} elseif ($Profile == 1) {
					$Profiledisplay = "Operator";
				} elseif ($Profile == 2) {
					$Profiledisplay = "NoShare";
				} elseif ($Profile == 3) {
					$Profiledisplay = "Reg";
				} elseif ($Profile == 4) {
					$Profiledisplay = "TS";
				}
				//if statement below changes the background color of the table rows to alternate by changing the "class" values
				if ($numresults % 2){
					echo "<tr><td class='even'>$regcounter</td><td class='even'>$Profiledisplay</td><td class='even'>$Nick</td><td class='even'>$Password</td></tr>";
				} else {
					echo "<tr><td class='odd'>$regcounter</td><td class='odd'>$Profiledisplay</td><td class='odd'>$Nick</td><td class='odd'>$Password</td></tr>";
				}
					$numresults += 1;
			} else {
				$regcounter += 1;
				continue;
			}
		}
	}
	//if statement will show how many results there are for whatever nickname search string was entered
	if (isset($dom)){
		echo "<b>$numresults</b> results for '<b>$desiredstring</b>'<br /><br />";
	}
}
?>


Enjoy!!!

quicky2g

I haven't had any problems with the RegisteredUsers.xml file being updated while the hub is running. I now have 684 registered users on the hub I run (Compared to the 683 I had when I took the screenshots that I posted) and I haven't had to restart the hub or any scripts to see the updated results on my php web page...

I think the RegisteredUsers.xml is updated when there are new registrations or accounts are deleted because my php script seems to respond to all the changes I see.

HaArD

You know that Mutor just added "Dynamic Updating of RegisteredUsers.xml" to the list of reasons he will quote about why everyone should be using API2. :)

quicky2g

Did a major update on the accounts page and added some Grimoire logging to a DB...see this post:
http://forum.ptokax.org/index.php?topic=8074.msg76924#msg76924

SMF spam blocked by CleanTalk