Thread: [PHP/vB] Server Status

Results 1 to 8 of 8
  1. #1 [PHP/vB] Server Status 
    Z
    Z is offline
    Registered Member
    Z's Avatar
    Join Date
    Jun 2007
    Age
    26
    Posts
    1,391
    Thanks given
    6
    Thanks received
    30
    Rep Power
    853
    This is not a the newest version but is the closest thing to it that I'm willing to release.
    It's a lot cleaner than the old one I released. Commenting was removed.

    Features:
    Add/Update Server
    Moderation (Remove Server/Clear Votes/Edit(Not Done))
    BBCode parsing in features
    Uses vB database class
    Viewing Server
    Voting
    Maybe more? Idk this is just the old file

    What's Removed:
    Commenting
    Moderator Editing
    Signatures
    Cron Job

    There will NOT be any more updates for this being posted on Rune-Server.
    It's still not the best script out there but it's a lot better than it used to be.


    Code:
    <html>
    <head>
    <script LANGUAGE="JavaScript">
    function confirmSubmit()
    {
    var agree=confirm("Are you sure you wish to continue?");
    if (agree)
    	return true ;
    else
    	return false ;
    }
    </script>
    </head>
    </html>
    
    <?php
    	require_once(DIR . '/includes/class_bbcode.php');
    	$loggedIn = $vbulletin->userinfo['userid'];
    	$bbcode_parse  =& new vB_BbCodeParser($vbulletin, fetch_tag_list());
    	$mod_access = array("6");
    
    	function cleanInput($string) {
    		return str_replace("select", "", str_replace("union", "", mysql_real_escape_string($string)));
    	}
    	
    	function getVotes($id) {
    		$gVotes = mysql_query("SELECT * FROM server_votes WHERE vote='1' AND server_id='" . $id . "'");
    		$bVotes =mysql_query("SELECT * FROM server_votes WHERE vote='-1' AND server_id='" . $id . "'");
    		$goodVotes = mysql_num_rows($gVotes);
    		$badVotes = mysql_num_rows($bVotes);
    		return ($goodVotes - $badVotes);
    	}
    
    	switch(cleanInput($_GET['action'])) {
    		default:
    			$rank = 1;
    			echo("<table class=\"tborder\" align=\"center\" border=\"0\" cellpadding=\"3\" cellspacing=\"1\">");
    			echo("<tr align=\"center\">");
    			echo("<td align=\"center\" class=\"tcat\">Rank</td>");
    			echo("<td align=\"center\" class=\"tcat\">Server</td>");
    			echo("<td align=\"center\" class=\"tcat\">Owner</td>");
    			echo("<td align=\"center\" class=\"tcat\">Status</td>");
    			echo("<td align=\"center\" class=\"tcat\" width=\"20%\">Uptime Percentage</td>");
    			echo("<td align=\"center\" class=\"tcat\">Votes</td></tr>");
    			$result = $db->query_read("SELECT s.*, IFNULL(v.score,0) AS score FROM server_status AS s LEFT JOIN (SELECT server_id, SUM(IF(vote=1,1,0))-SUM(IF(vote=-1,1,0)) AS score FROM server_votes GROUP BY server_id) AS v ON s.owner_id = v.server_id ORDER BY s.up, v.score DESC");
    
    			while($row = $db->fetch_array($result)) {
    				$owner = $db->query_read("SELECT * FROM " . TABLE_PREFIX . "user WHERE userid='".$row['owner_id']."'");
    				$ownerData = $db->fetch_array($owner);
    
    				if ($row['up'] == 1) {
    					$status = "<font color='green'>Online</font>";
    				} else {
    					$status = "<font color='red'>Offline</font>";
    				}
    
    				$percent = number_format(($row['total_uptime'] / ($row['total_uptime'] + $row['total_downtime'])) * 100,2);
    				echo("<tr align=\"center\">");
    				echo("<td class=\"alt1\" nowrap=\"nowrap\" width=\"5%\">".$rank."</td>");
    				echo("<td class=\"alt1\" nowrap=\"nowrap\" width=\"15%\"><a href=\"index.php?pageid=serverstatus&action=view&server=" . $row['owner_id'] . "\">" . $row['server_name'] . "</a></td>");
    				echo("<td class=\"alt1\" nowrap=\"nowrap\" width=\"15%\" align=\"center\">".$ownerData['username']."</td>");
    				echo("<td class=\"alt1\" nowrap=\"nowrap\" width=\"15%\" align=\"center\">$status</td>");
    				echo("<td class=\"alt1\" nowrap=\"nowrap\" width=\"15%\" align=\"center\">$percent%</td>");
    				echo("<td class=\"alt1\" nowrap=\"nowrap\" width=\"15%\" align=\"center\">".getVotes($row['owner_id'])."</td></tr>");
    			}
    			echo("</table>");
    			break;
    
    		case view:
    			$server = cleanInput($_GET['server']);
    			$result = $db->query("SELECT * FROM server_status WHERE owner_id='".$server."'");
    			$row = $db->fetch_array($result);
    			$owner = $db->query("SELECT * FROM " . TABLE_PREFIX . "user WHERE userid='" . $row['owner_id'] . "'");
    			$ownerData = $db->fetch_array($owner);
    			$votes = getVotes($row['owner_id']);
    			if($votes > 0) {
    				$rating = "<font color='green'><b>".$votes."</b></font>";
    			} else if($votes <= -1) {
    				$rating = "<font color='red'><b>".$votes."</b></font>";
    			} else {
    				$rating = $votes;
    			}
    
    			if($row['owner_id'] == ""){
    				echo("<table class=\"tborder\" align=\"center\" border=\"0\" cellpadding=\"5\" cellspacing=\"1\" width=\"100%\">");
    				echo("<td class=\"alt2\" rowspan=\><center>The data you've happened to 'stumble' upon doesn't match our databases nor any pages of our site; feel free to try again though.</center></td>");;
    				echo("</table>");
    			} else {
    				$percent = number_format(($row['total_uptime'] / ($row['total_uptime'] + $row['total_downtime'])) * 100,2);
    				if ($row['up'] == 1) {
    					$status = "<font color='green'>Online</font>";
    				} else {
    					$status = "<font color='red'>Offline</font>";
    				}
    				$values = array("Server Name" => $row['server_name'], "Server Ip" => $row['server_ip'], "Owner" => "<a href=\"member.php?u=" . $row['owner_id'] . "\">".$ownerData['username']."</a></td>", "Website" => $row['server_site'], "Date Added" => $row['added_on'], "Status" => $status, "Total Uptime" => $row['total_uptime']." Minutes", "Total Downtime" => $row['total_downtime']." Minutes", "Uptime Percent" => $percent."%", "Rating" => $rating);
    				echo("<table class=\"tborder\" align=\"center\" border=\"0\" cellpadding=\"5\" cellspacing=\"1\" width=\"100%\">");
    				echo("<tr align=\"center\">");
    				echo("<td width=\"50%\" align=\"center\" class=\"alt1Active\" id=\"f2\"><a href=\"index.php?pageid=serverstatus&action=vote&v=g&id=" . $row['owner_id'] . "\"><img alt=\"Rate Good\" border=\"0\" src=\"./serverstatus/arrowup.gif\"/></a></td>");
    				echo("<td width=\"50%\" align=\"center\" class=\"alt1Active\" id=\"f2\"><a href=\"index.php?pageid=serverstatus&action=vote&v=b&id=" . $row['owner_id'] . "\"><img alt=\"Rate Bad\" border=\"0\" src=\"./serverstatus/arrowdown.gif\"/></a></td></tr>");
    
    				foreach($values as $label => $value) {
    					echo("<td width=\"30%\" align=\"left\" class=\"alt1Active\" id=\"f2\"><b>".$label.":<b></td>");
    					echo("<td width=\"70%\" align=\"left\" nowrap=\"nowrap\" class=\"alt2\">".$value."</td></tr>");
    				}
    				$features = $bbcode_parse->do_parse($row['server_features'],1, 1, 1, 1, 1);
    				echo("<tr align=\"center\">");
    				echo("<td width=\"100%\" colspan=\"2\" align=\"left\" class=\"alt1Active\" id=\"f2\"><b>Features:</b></td></tr>");
    				echo("<tr align=\"center\"><td width=\"100%\" colspan=\"2\" align=\"left\" class=\"alt2\">$features</td></tr>");
    
    				if (in_array($vbulletin->userinfo['usergroupid'], $mod_access)) {
    					echo("<td width=\"30%\" align=\"left\" class=\"alt1Active\" id=\"f2\"><b>Moderation:</b></td>");
    					echo("<td width=\"70%\" align=\"left\" nowrap=\"nowrap\" class=\"alt2\"><form action=\"index.php?pageid=serverstatus&action=moderation\" method=\"post\">");
    					echo("<select name=\"a\"><optgroup label=\"Server\"><option value=\"edit\">Edit Details</option><option value=\"delete\">Remove Server</option><option value=\"votes\">Delete Votes</option></optgroup></select>");
    					echo("<input type=\"hidden\" name=\"s\" value=\"".$row['owner_id']."\">");
    					echo("<input type=\"submit\" class=\"button\" id=\"inlinego\" value=\"Go\" onClick=\"return confirmSubmit()\"/></form></center></td>");
    				}
    				echo("</table>");
    			}
    			break;
    
    		case myserver:
    			$result = $db->query("SELECT * FROM server_status WHERE owner_id='".$loggedIn."'");
    			$row = $db->fetch_array($result);
    			if (!isset($_POST['server_name'])) {
    				echo("<form method=\"post\" action=\"index.php?pageid=serverstatus&action=myserver name=\"editserver\"\">");
    				echo("<table class=\"tborder\" align=\"center\" border=\"0\" cellpadding=\"5\" cellspacing=\"1\" width=\"100%\">");
    				echo("<tr align=\"center\"><td width=\"50%\" align=\"left\" class=\"alt1Active\" id=\"f2\"><div><strong>Server Name:</strong></div></td>");
    				echo("<td width=\"50%\" align=\"left\" nowrap=\"nowrap\" class=\"alt2\"><input name=\"server_name\" type=\"text\" value=\"".$row['server_name']."\" /></td></tr>");
    				echo("<tr align=\"center\"><td width=\"50%\" align=\"left\" class=\"alt1Active\" id=\"f2\"><div><strong>Server Ip:</strong></div></td>");
    				echo("<td width=\"50%\" align=\"left\" nowrap=\"nowrap\" class=\"alt2\"><input name=\"server_ip\" type=\"text\" value=\"".$row['server_ip']."\"/></td></tr>");
    				echo("<tr align=\"center\"><td width=\"50%\" align=\"left\" class=\"alt1Active\" id=\"f2\"><div><strong>Server Site:</strong></div></td>");
    				echo("<td width=\"50%\" align=\"left\" nowrap=\"nowrap\" class=\"alt2\"><input name=\"server_site\" type=\"text\" value=\"".$row['server_site']."\"/></td></tr>");
    				echo("<tr align=\"center\"><td width=\"50%\" align=\"left\" class=\"alt1Active\" id=\"f2\"><div><strong>Features:</strong></div></td>");
    				echo("<td width=\"50%\" align=\"left\" nowrap=\"nowrap\" class=\"alt2\"><textarea name=\"server_features\" rows=\"5\" cols=\"45\" wrap=\"physical\">".$row['server_features']."</textarea></td></tr>");
    				echo("<tr align=\"center\"><td width=\"50%\" class=\"alt2Active\" id=\"f2\"><font color=\"red\">*</font> Please note that the only port aloud on the server status is 43594; which is automaticly set.</td>");
    				echo("<td width=\"50%\" class=\"alt2Active\" id=\"f2\"><font color=\"red\">*</font> Please also keep in mind upon updating your server; uptimes and downtimes will be reset.</td></tr>");
    				echo("<tr align=\"center\"><td width=\"50%\" nowrap=\"nowrap\" class=\"alt2\"><input type=\"submit\" class=\"button\" value=\"Update\" tabindex=\"2\"/></td>");
    				echo("<td width=\"50%\" nowrap=\"nowrap\" class=\"alt2\"><input type=\"reset\" class=\"button\" value=\"Reset\" tabindex=\"2\"/></td></tr></table></form>");
    			} else {
    				if($_POST['server_name'] == '' || $_POST['server_ip'] == '' || $_POST['server_features'] == '') {
    					echo("<tr alight=\"center\"><td class=\"tcat\">vBulletin Message</td></tr><tr><td class=\"panelsurround\" align=\center\"><div class=\"panel\">");
    					echo("<div style=\"margin: 10px\">Please complete all required fields.</div></div></div><div style=\"margin-top:6px\"><center><input type=\"submit\" class=\"button\" value=\"Server List\" accesskey=\"s\" onclick=\"history.back(2); return false\" /></center></div></td></tr>");
    				} else {
    					$server_ip = $_POST['server_ip'];
    					$fp = @fsockopen($server_ip, 43594, $errno, $errstr, 10);
    					if ($fp) {
    						if($row['server_name'] == "") {
    							echo("<center>Your server has been successfully added to the Server List!</center");
    							$db->query_write("INSERT INTO server_status (owner_id, server_ip, server_site, server_features, server_name, up, total_uptime, total_downtime, added_on) VALUES('".$loggedIn."', '".cleanInput($_POST['server_ip'])."', '".cleanInput($_POST['server_site'])."', '".cleanInput($_POST['server_features'])."', '".cleanInput($_POST['server_name'], '".date("m-d-Y")."')."', '1', '1', '0')");
    						} else {
    							echo("<center>Your server has successfully been updated!</center>");
    							$db->query_write("UPDATE server_status SET server_ip='".cleanInput($_POST['server_ip'])."', added_on='".date("m-d-Y")."', server_site='".cleanInput($_POST['server_site'])."', up='1', total_uptime='1', total_downtime='0', server_name='".cleanInput($_POST['server_name'])."', server_features='".cleanInput($_POST['server_features'])."' WHERE owner_id='".$loggedIn."'");
    						}
    					} else {
    						echo("<center>The server Ip you've enter is not currently online; and therefore has not been added.</center>");
    					}
    				}
    			}
    		break;
    			
    		case moderation:
    			$do = cleanInput($_POST['a']);
    			if (in_array($vbulletin->userinfo['usergroupid'], $mod_access)) {
    				if($do == 'delete') {
    					$server = cleanInput($_POST['s']);
    					$db->query_write("DELETE FROM server_status WHERE owner_id='".$server."'");
    					echo("The server has been deleted.");
    				} else if($do == 'votes') {
    					$server = cleanInput($_POST['s']);
    					$db->query_write("DELETE FROM server_votes WHERE server_id='".$server."'");
    					echo("The server's votes have been cleared.");
    				} else if($do == 'edit') {
    					echo("To be implemented yet....");
    				} else {
    					echo("Unrecognized action.");
    				}
    			} else {
    				echo("You do not have the privileges to perform that action");
    			}
    		break;
    			
    		case vote:
    			$serverId = cleanInput($_GET['id']);
    			$result = $db->query("SELECT * FROM server_status WHERE owner_id='".$serverId."'");
    			$row = mysql_fetch_array($result);
    			if($row['owner_id'] == '') {
    				echo("The server you're trying to vote for is invalid; if you think this is an error please contact an administrator.");
    			} else {
    				$vote = cleanInput($_GET['v']);
    				$vs = array("g", "b");
    				if(!in_array($vote, $vs)) {
    					echo("You're a great hacker man.");
    				} else {
    					if($vote == 'g') {
    						$value = '1';
    					} else {
    						$value = '-1';
    					}
    					$validate = $db->query("SELECT * FROM server_votes WHERE server_id='$serverId' AND voter_id='$loggedIn' ORDER BY voteId DESC LIMIT 1");
    					$row = mysql_fetch_array($validate);
    					if($row['next_vote'] <= time()) {
    						require_once('recaptchalib.php');
    						$publickey = "6LctGbsSAAAAALwYsAJAfLNY-wEAH3ZBcuD8yZho ";
    						$privatekey = "6LctGbsSAAAAAK3YFbqETuQzMp8gD8YUdG9a5eW8 ";
    						$resp = null;
    						$error = null;
    						echo("<html><body><form action=\"\" method=\"post\">");
    						if ($_POST["recaptcha_response_field"]) {
    								$resp = recaptcha_check_answer ($privatekey, $_SERVER["REMOTE_ADDR"], $_POST["recaptcha_challenge_field"], $_POST["recaptcha_response_field"]);
    								if ($resp->is_valid) {
    									$next_vote = time() + (21600);
    									echo("<table class=\"tborder\" cellpadding=\"6\" cellspacing=\"1\" border=\"0\" width=\"100%\" align=\"center\">Thank you for your input on this server.  Your vote has now been updated; You will now be redirect to the main page in five seconds.</table>");
    									$db->query_write("INSERT INTO server_votes (server_id, voter_id, vote, next_vote) VALUES('$serverId', '$loggedIn', '$value', $next_vote) ");
    									echo("<meta http-equiv=\"refresh\" content=\"5;url=index.php?pageid=serverstatus\">");
    								} else {
    									$error = $resp->error;
    								}
    						} else {
    							echo("<center>");
    							echo recaptcha_get_html($publickey, $error);
    							echo("<br/><input type=\"submit\" value=\"Vote!\" /></form></center></body></html>");
    						}
    					} else {
    						echo("<center>You have already voted for this server in the past 6 hours!<br>You will not be redirected to the main page.</center>");
    						echo("<meta http-equiv=\"refresh\" content=\"5;url=index.php?pageid=serverstatus\">");
    					}
    				}
    			}				
    		break;
    	}
    ?>
    This is a vbCmps page at the moment and there IS a stand-alone page but it's only at RS2-Server and is currently in development.

    Sql Dump:
    Code:
    SET SQL_MODE="NO_AUTO_VALUE_ON_ZERO";
    
    
    /*!40101 SET @[email protected]@CHARACTER_SET_CLIENT */;
    /*!40101 SET @[email protected]@CHARACTER_SET_RESULTS */;
    /*!40101 SET @[email protected]@COLLATION_CONNECTION */;
    /*!40101 SET NAMES utf8 */;
    
    CREATE TABLE IF NOT EXISTS `server_status` (
      `owner_id` int(22) NOT NULL,
      `total_uptime` int(255) NOT NULL,
      `total_downtime` int(255) NOT NULL,
      `up` int(1) NOT NULL,
      `server_name` varchar(22) NOT NULL,
      `server_ip` varchar(33) NOT NULL,
      `server_site` varchar(33) NOT NULL,
      `added_on` varchar(22) NOT NULL,
      `server_features` text NOT NULL
    ) ENGINE=MyISAM DEFAULT CHARSET=latin1;
    
    INSERT INTO `server_status` (`owner_id`, `total_uptime`, `total_downtime`, `up`, `server_name`, `server_ip`, `server_site`, `added_on`, `server_features`) VALUES
    (1, 1, 0, 1, 'DoraScape', 'allgofree.redirectme.net', 'dora.com', '06-30-2010', '');
    
    CREATE TABLE IF NOT EXISTS `server_votes` (
      `voter_id` int(22) NOT NULL,
      `server_id` int(22) NOT NULL,
      `vote` int(1) NOT NULL,
      `next_vote` bigint(255) NOT NULL,
      `voteId` bigint(255) NOT NULL AUTO_INCREMENT,
      PRIMARY KEY (`voteId`)
    ) ENGINE=MyISAM  DEFAULT CHARSET=latin1 AUTO_INCREMENT=13 ;
    How to use it:
    1. Install vbCmps if it's not already installed
    2. Go to cmps drop down and click add page
    3. Click "Php File Page"
    4. Set:
    1. Page Title: Server Status
    2. Page Identifier: serverstatus
    3. Path to File: ./serverstatus/serverstatus.php
    4. Clean File Output: Yes

    5. Open up phpmyadmin and execute the sql dump post above.
    6. If you didn't already, save that php file above as serverstatus.php and create a new directory ./serverstatus and put it in there.
    7. Put these images in your ./serverstatus directory:

    arrowdown.gif


    arrowup.gif

    Edit one more thing...
    recaptchalib.php:
    Code:
    <?php
    define("RECAPTCHA_API_SERVER", "http://www.google.com/recaptcha/api");
    define("RECAPTCHA_API_SECURE_SERVER", "https://www.google.com/recaptcha/api");
    define("RECAPTCHA_VERIFY_SERVER", "www.google.com");
    
    /**
     * Encodes the given data into a query string format
     * @param $data - array of string elements to be encoded
     * @return string - encoded request
     */
    function _recaptcha_qsencode ($data) {
            $req = "";
            foreach ( $data as $key => $value )
                    $req .= $key . '=' . urlencode( stripslashes($value) ) . '&';
    
            // Cut the last '&'
            $req=substr($req,0,strlen($req)-1);
            return $req;
    }
    
    
    
    /**
     * Submits an HTTP POST to a reCAPTCHA server
     * @param string $host
     * @param string $path
     * @param array $data
     * @param int port
     * @return array response
     */
    function _recaptcha_http_post($host, $path, $data, $port = 80) {
    
            $req = _recaptcha_qsencode ($data);
    
            $http_request  = "POST $path HTTP/1.0\r\n";
            $http_request .= "Host: $host\r\n";
            $http_request .= "Content-Type: application/x-www-form-urlencoded;\r\n";
            $http_request .= "Content-Length: " . strlen($req) . "\r\n";
            $http_request .= "User-Agent: reCAPTCHA/PHP\r\n";
            $http_request .= "\r\n";
            $http_request .= $req;
    
            $response = '';
            if( false == ( $fs = @fsockopen($host, $port, $errno, $errstr, 10) ) ) {
                    die ('Could not open socket');
            }
    
            fwrite($fs, $http_request);
    
            while ( !feof($fs) )
                    $response .= fgets($fs, 1160); // One TCP-IP packet
            fclose($fs);
            $response = explode("\r\n\r\n", $response, 2);
    
            return $response;
    }
    
    
    
    /**
     * Gets the challenge HTML (javascript and non-javascript version).
     * This is called from the browser, and the resulting reCAPTCHA HTML widget
     * is embedded within the HTML form it was called from.
     * @param string $pubkey A public key for reCAPTCHA
     * @param string $error The error given by reCAPTCHA (optional, default is null)
     * @param boolean $use_ssl Should the request be made over ssl? (optional, default is false)
    
     * @return string - The HTML to be embedded in the user's form.
     */
    function recaptcha_get_html ($pubkey, $error = null, $use_ssl = false)
    {
    	if ($pubkey == null || $pubkey == '') {
    		die ("To use reCAPTCHA you must get an API key from <a href='https://www.google.com/recaptcha/admin/create'>https://www.google.com/recaptcha/admin/create</a>");
    	}
    	
    	if ($use_ssl) {
                    $server = RECAPTCHA_API_SECURE_SERVER;
            } else {
                    $server = RECAPTCHA_API_SERVER;
            }
    
            $errorpart = "";
            if ($error) {
               $errorpart = "&amp;error=" . $error;
            }
            return '<script type="text/javascript" src="'. $server . '/challenge?k=' . $pubkey . $errorpart . '"></script>
    
    	<noscript>
      		<iframe src="'. $server . '/noscript?k=' . $pubkey . $errorpart . '" height="300" width="500" frameborder="0"></iframe><br/>
      		<textarea name="recaptcha_challenge_field" rows="3" cols="40"></textarea>
      		<input type="hidden" name="recaptcha_response_field" value="manual_challenge"/>
    	</noscript>';
    }
    
    
    
    
    /**
     * A ReCaptchaResponse is returned from recaptcha_check_answer()
     */
    class ReCaptchaResponse {
            var $is_valid;
            var $error;
    }
    
    
    /**
      * Calls an HTTP POST function to verify if the user's guess was correct
      * @param string $privkey
      * @param string $remoteip
      * @param string $challenge
      * @param string $response
      * @param array $extra_params an array of extra variables to post to the server
      * @return ReCaptchaResponse
      */
    function recaptcha_check_answer ($privkey, $remoteip, $challenge, $response, $extra_params = array())
    {
    	if ($privkey == null || $privkey == '') {
    		die ("To use reCAPTCHA you must get an API key from <a href='https://www.google.com/recaptcha/admin/create'>https://www.google.com/recaptcha/admin/create</a>");
    	}
    
    	if ($remoteip == null || $remoteip == '') {
    		die ("For security reasons, you must pass the remote ip to reCAPTCHA");
    	}
    
    	
    	
            //discard spam submissions
            if ($challenge == null || strlen($challenge) == 0 || $response == null || strlen($response) == 0) {
                    $recaptcha_response = new ReCaptchaResponse();
                    $recaptcha_response->is_valid = false;
                    $recaptcha_response->error = 'incorrect-captcha-sol';
                    return $recaptcha_response;
            }
    
            $response = _recaptcha_http_post (RECAPTCHA_VERIFY_SERVER, "/recaptcha/api/verify",
                                              array (
                                                     'privatekey' => $privkey,
                                                     'remoteip' => $remoteip,
                                                     'challenge' => $challenge,
                                                     'response' => $response
                                                     ) + $extra_params
                                              );
    
            $answers = explode ("\n", $response [1]);
            $recaptcha_response = new ReCaptchaResponse();
    
            if (trim ($answers [0]) == 'true') {
                    $recaptcha_response->is_valid = true;
            }
            else {
                    $recaptcha_response->is_valid = false;
                    $recaptcha_response->error = $answers [1];
            }
            return $recaptcha_response;
    
    }
    
    /**
     * gets a URL where the user can sign up for reCAPTCHA. If your application
     * has a configuration page where you enter a key, you should provide a link
     * using this function.
     * @param string $domain The domain where the page is hosted
     * @param string $appname The name of your application
     */
    function recaptcha_get_signup_url ($domain = null, $appname = null) {
    	return "https://www.google.com/recaptcha/admin/create?" .  _recaptcha_qsencode (array ('domains' => $domain, 'app' => $appname));
    }
    
    function _recaptcha_aes_pad($val) {
    	$block_size = 16;
    	$numpad = $block_size - (strlen ($val) % $block_size);
    	return str_pad($val, strlen ($val) + $numpad, chr($numpad));
    }
    
    /* Mailhide related code */
    
    function _recaptcha_aes_encrypt($val,$ky) {
    	if (! function_exists ("mcrypt_encrypt")) {
    		die ("To use reCAPTCHA Mailhide, you need to have the mcrypt php module installed.");
    	}
    	$mode=MCRYPT_MODE_CBC;   
    	$enc=MCRYPT_RIJNDAEL_128;
    	$val=_recaptcha_aes_pad($val);
    	return mcrypt_encrypt($enc, $ky, $val, $mode, "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0");
    }
    
    
    function _recaptcha_mailhide_urlbase64 ($x) {
    	return strtr(base64_encode ($x), '+/', '-_');
    }
    
    /* gets the reCAPTCHA Mailhide url for a given email, public key and private key */
    function recaptcha_mailhide_url($pubkey, $privkey, $email) {
    	if ($pubkey == '' || $pubkey == null || $privkey == "" || $privkey == null) {
    		die ("To use reCAPTCHA Mailhide, you have to sign up for a public and private key, " .
    		     "you can do so at <a href='http://www.google.com/recaptcha/mailhide/apikey'>http://www.google.com/recaptcha/mailhide/apikey</a>");
    	}
    	
    
    	$ky = pack('H*', $privkey);
    	$cryptmail = _recaptcha_aes_encrypt ($email, $ky);
    	
    	return "http://www.google.com/recaptcha/mailhide/d?k=" . $pubkey . "&c=" . _recaptcha_mailhide_urlbase64 ($cryptmail);
    }
    
    /**
     * gets the parts of the email to expose to the user.
     * eg, given [email protected],com return ["john", "example.com"].
     * the email is then displayed as [email protected]
     */
    function _recaptcha_mailhide_email_parts ($email) {
    	$arr = preg_split("/@/", $email );
    
    	if (strlen ($arr[0]) <= 4) {
    		$arr[0] = substr ($arr[0], 0, 1);
    	} else if (strlen ($arr[0]) <= 6) {
    		$arr[0] = substr ($arr[0], 0, 3);
    	} else {
    		$arr[0] = substr ($arr[0], 0, 4);
    	}
    	return $arr;
    }
    
    /**
     * Gets html to display an email address given a public an private key.
     * to get a key, go to:
     *
     * http://www.google.com/recaptcha/mailhide/apikey
     */
    function recaptcha_mailhide_html($pubkey, $privkey, $email) {
    	$emailparts = _recaptcha_mailhide_email_parts ($email);
    	$url = recaptcha_mailhide_url ($pubkey, $privkey, $email);
    	
    	return htmlentities($emailparts[0]) . "<a href='" . htmlentities ($url) .
    		"' onclick=\"window.open('" . htmlentities ($url) . "', '', 'toolbar=0,scrollbars=0,location=0,statusbar=0,menubar=0,resizable=0,width=500,height=300'); return false;\" title=\"Reveal this e-mail address\">...</a>@" . htmlentities ($emailparts [1]);
    
    }
    
    
    ?>
    Also put that in your ./serverstatus directory

    Quote Originally Posted by Scar View Post
    heres a working demo guys: [Only registered and activated users can see links. ] and nice job.
    That is a basic demo, this script is the older version of that pretty much .

    Do not move this.
    Reply With Quote  
     

  2. #2  
    Registered Member
    Payton's Avatar
    Join Date
    Nov 2008
    Posts
    3,131
    Thanks given
    164
    Thanks received
    192
    Rep Power
    490
    same one used on RS2 server? Nice, and good tut.
    Livin' out the dream
    Well it may be the dream to you,
    But I do everything I dream
    So to me its DejaVu.
    Reply With Quote  
     

  3. #3  
    Z
    Z is offline
    Registered Member
    Z's Avatar
    Join Date
    Jun 2007
    Age
    26
    Posts
    1,391
    Thanks given
    6
    Thanks received
    30
    Rep Power
    853
    Scar, that's not the actual script that you're using atm...This is like the first revision I made when I started talking to you .
    Reply With Quote  
     

  4. #4  
    Registered Member

    Join Date
    Oct 2009
    Posts
    1,595
    Thanks given
    100
    Thanks received
    50
    Rep Power
    232
    good job.
    [Only registered and activated users can see links. ]
    Reply With Quote  
     

  5. #5  
    Banned

    Join Date
    Oct 2009
    Age
    26
    Posts
    1,579
    Thanks given
    4
    Thanks received
    23
    Rep Power
    0
    Very nice!
    Reply With Quote  
     

  6. #6  
    Officially Retired

    Huey's Avatar
    Join Date
    Jan 2008
    Age
    19
    Posts
    16,489
    Thanks given
    3,387
    Thanks received
    7,726
    Rep Power
    5000
    How is this a tutorial and you didn't even explain a damn thing?

    Edit- Worst tutorial i've ever seen you are horrible at explaining tutorials no offense and this is not a flame.

    Listen children don't become this guy.
    Quote Originally Posted by Owner Spikey View Post
    Why can I attack lower level npc's in a matter of a mouse hover but for a higher level npc the only choice to attack is by right clicking option attack?

    Reply With Quote  
     

  7. #7  
    Z
    Z is offline
    Registered Member
    Z's Avatar
    Join Date
    Jun 2007
    Age
    26
    Posts
    1,391
    Thanks given
    6
    Thanks received
    30
    Rep Power
    853
    Quote Originally Posted by Huey View Post
    How is this a tutorial and you didn't even explain a damn thing?

    Edit- Worst tutorial i've ever seen you are horrible at explaining tutorials no offense and this is not a flame.
    Since someone deleted my post and I cannot stand your post I'll just post something more friendly.

    Kk thanks for the comment hard-ass. This is a tutorial on how to set it up, now explaining the methods. Why would I explain it? VERY few people would have any idea what I meant and it'd be a total waste of time.
    Reply With Quote  
     

  8. #8  
    Registered Member

    Join Date
    May 2008
    Posts
    140
    Thanks given
    39
    Thanks received
    13
    Rep Power
    176
    Wow just by the demo I think it's pretty cool.
    Reply With Quote  
     


Thread Information
Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)


User Tag List

Posting Permissions
  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •