Register for your free account! | Forgot your password?

You last visited: Today at 16:47

  • Please register to post and access all features, it's quick, easy and FREE!

Advertisement



[Release] Compose Log Reader - PHP

Discussion on [Release] Compose Log Reader - PHP within the EO PServer Guides & Releases forum part of the EO PServer Hosting category.

Reply
 
Old   #1
 
elite*gold: 0
Join Date: Jul 2012
Posts: 80
Received Thanks: 40
[Release] Compose Log Reader - PHP

Since alot of servers lately that I have seen are over ran with auto composing, I figured I would create something that allows
server owners and their staff to check the compose logs easier than using notepad.

What this does:
Owners put their compose logs in the folder, and go to the index.php page, enter the name of the file, example: sacrifice 2012-9-20.log
Then hit the "Run" buttonNote: if your compose log is huge, this may take some time to insert the data. The script
goes through the file and creates a table based on the name of the file. When its done it spits out a link that enables you to view
the compose log easier (See the first picture).

While on the read.php page, you have the ability to change between any tables currently in that database (which is why you shouldnt use
the default "my" database for this)(See image 1 number 1). You also can change the composer, so its easier to read based on who is
doing the composing (See image 1 number 2). After changing the composer you get a list of their composes with the difference per compose.
(See Image 2).


Setting this up:

Its quite simple to set up.

1. Open the fig.php file and change the following to suit your server.
Code:
$host = "127.0.0.1";  //This is the host for your db. Usually 127.0.0.1 or localhost
$user = "root"; //This is your db's username
$pw = "test";  //This is your db's password
$db = "log";  //This is your database
2. Open the folder you made for this. And put your compose log in there. You can find the log by going to your MsgServer/d_log/MonthFolder/
Inside that folder find your sacrificeYear-Month-Day.log file.

3. Open your browser to the folder you made for this. Example would be

4. Input the name of the file you put into the folder. Example sacrifice 2012-9-20.log and then hit "Run". Wait for the script to do
its work, and then click on the link the script gives you.

5. Enjoy it

As I said before, if your compose log is huge, this may take a few minutes to run.
While I have tested this to the fullest, I take no responsibility if it screws something up. Use at your own risk

Pictures

1. Tables found in the database. Good way of keeping track of your compose logs, just in case you want to let your staff check them.
2. The Composers name. When you change the selected dropdown, it will pull the logs for that user.


What it looks like while looking at a characters composes.



Make sure the log file is in the directory with the others.
Attached Files
File Type: rar compose_log_reader.rar (69.3 KB, 54 views)
Gekru is offline  
Thanks
9 Users
Old 09/21/2012, 08:20   #2
 
wolfvb's Avatar
 
elite*gold: 0
Join Date: Nov 2010
Posts: 238
Received Thanks: 218
nice work and great work
wolfvb is offline  
Old 09/22/2012, 03:08   #3
 
hio77's Avatar
 
elite*gold: 20
Join Date: Jun 2006
Posts: 1,759
Received Thanks: 827
not bad, one thing ild suggest you do for this however.. store it in a sqlite DB, there is no reason to be bloating mysql with a log that your gonna be manually calling upon anyway.

also, ild suggest looking into using a more OOP style of doing this, a few of your methods have a bit too much overhead, making the process time a lot worse.
hio77 is offline  
Old 09/22/2012, 04:11   #4
 
elite*gold: 0
Join Date: Jul 2012
Posts: 80
Received Thanks: 40
Quote:
not bad, one thing ild suggest you do for this however.. store it in a sqlite DB, there is no reason to be bloating mysql with a log that your gonna be manually calling upon anyway.

also, ild suggest looking into using a more OOP style of doing this, a few of your methods have a bit too much overhead, making the process time a lot worse.
Thanks for your criticism, but during my tests, I have found that mySQL was over-all a lot quicker.

As for using OOP programming instead of the old school functions. When coding up a small project such as this that only consists of a few pages, the time consumption needed to write up the OOP code far out weighs the potential this script has.
Gekru is offline  
Old 09/22/2012, 15:05   #5
 
hio77's Avatar
 
elite*gold: 20
Join Date: Jun 2006
Posts: 1,759
Received Thanks: 827
Quote:
Originally Posted by Gekru View Post
Thanks for your criticism, but during my tests, I have found that mySQL was over-all a lot quicker.

As for using OOP programming instead of the old school functions. When coding up a small project such as this that only consists of a few pages, the time consumption needed to write up the OOP code far out weighs the potential this script has.
you cant exactly compare the two with the methods you used, ild recommend using something like PDO for universal nature of it.

one thing also worth noting, SQLITE tends to preform better than mySQL when reading a lot more than insert/updating. if testing more so in the conversion stage, then you would see a faster completion time with mySQL.

ultimately, for what this would be used for, regardless of the database, it wont shine as clearly as say a 1000K hits per day site would. however it all comes down to the fact that this is only a log, thus bloating your database.. remembering that there is then required for mySQL to use more ram and so on..

as for OOP, personally i don't see any reason not to use it, yes this was a simple task, in-which procedural coding does seem more fitting, but hey.. never know when your gonna want to incorporate this with your control panel, your website etc..

what you have made here, will be used by many im sure, highly useful. personally i always did this by sight, however there was no bots back when i ran servers...

keep up the good work, its good to see people actually coding things in the eo community
hio77 is offline  
Old 09/22/2012, 21:28   #6
 
elite*gold: 0
Join Date: Jul 2012
Posts: 80
Received Thanks: 40
Quote:
Originally Posted by hio77 View Post
you cant exactly compare the two with the methods you used, ild recommend using something like PDO for universal nature of it.

one thing also worth noting, SQLITE tends to preform better than mySQL when reading a lot more than insert/updating. if testing more so in the conversion stage, then you would see a faster completion time with mySQL.

ultimately, for what this would be used for, regardless of the database, it wont shine as clearly as say a 1000K hits per day site would. however it all comes down to the fact that this is only a log, thus bloating your database.. remembering that there is then required for mySQL to use more ram and so on..

as for OOP, personally i don't see any reason not to use it, yes this was a simple task, in-which procedural coding does seem more fitting, but hey.. never know when your gonna want to incorporate this with your control panel, your website etc..

what you have made here, will be used by many im sure, highly useful. personally i always did this by sight, however there was no bots back when i ran servers...

keep up the good work, its good to see people actually coding things in the eo community

I actually thought about using OOP, and PDO for this, but then I looked at who would be the ones using the files. The majority of the people around here wouldn't have any idea how to edit the files if I did either.

OOP would be awesome if this met a few requirements but sadly it doesn't

1. It isn't edited by a team of people, this is where OOP really comes into play.
2. You can't really do many updates to the files.
3. The project is really small, usually you would only use OOP for larger projects as it's meant to make updating, editing easier.
4. Most people around here wouldn't have any clue on how to edit the files, and would require constant help.
Gekru is offline  
Old 09/27/2012, 04:37   #7
 
funhacker's Avatar
 
elite*gold: 20
Join Date: Sep 2007
Posts: 1,767
Received Thanks: 1,746
I use PDO, and you can setup to be very user friendly for people to adapt to their own projects. Here is a snippet from my database.php file
I have a class for each database I need to connect to using the PDO class.
Obviously all they have to do is change the host/database/user/password and port values.

However downside of PDO is that anything 5.3 or greater does not work with mysql 4.0 or below (4.0 is what EO uses)
So you have to use php5.2 or 5.1 (PDO does not exist any further below)

Code:
class NewACME_MY_Database extends PDO
	{
		//Declare variables
		private
			$driver,
			$host,
			$database,
			$user,
			$password,
			$port;

		//Setup constructor
		public function __construct()
		{
			//Set all the variables
			$this->driver = 'mysql';
			$this->host = 'localhost';
			$this->database = 'my';
			$this->user = 'userName';
			$this->password = 'Password';
			$this->port = 3307;

			//Setup the DNS
			$dns = $this->driver.':dbname='.$this->database.';host='.$this->host.';port='.$this->port;

			//Setup the PDO
			parent::__construct($dns,$this->user,$this->password);
		}
	}
and here is an example of a class that uses multiple database classes to access mysql information

Code:
<?php
	//Include the database file, account
	include_once('classes/database.php');
	include_once('classes/account.php');

	class MainAccount
	{
		//Declare constants
		const
			CURRENT_DATE = 'CUR_DATE';
		//Declare variables
		private
			$id,
			$name,
			$ap,
			$paypal_email,
			$monthly_limit,
			$first_purchase,
			$total_purchased,
			$total_sold,
			$accounts_new,
			$accounts_classic,
			$current_limit;

		//Declare get methods
		function getID()
		{return $this->id;}
		function getName()
		{return $this->name;}
		function getAP()
		{return $this->ap;}
		function getPaypalEmail()
		{return $this->paypal_email;}
		function getMonthlyLimit()
		{return $this->monthly_limit;}
		function getFirstPurchase()
		{return $this->first_purchase;}
		function getTotalPurchased()
		{return $this->total_purchased;}
		function getTotalSold()
		{return $this->total_sold;}
		function getAccountsNew()
		{return $this->accounts_new;}
		function getAccountsClassic()
		{return $this->accounts_classic;}
		function getAccounts($server)
		{
			switch ($server) {
				case 'new':
					return $this->accounts_new;

				case 'classic':
					return $this->accounts_classic;
			}
		}
		function getAccountCount()
		{
			return count($this->accounts_new) + count($this->accounts_classic);
		}
		function getError()
		{return   $this->error;}
		function getTotalPurchasedByDate($date)
		{
			//determine if this is a current month check
			//if($date == )
		}

		//Declare constructor
		function __construct($id)
		{
			//Set the ID
			$this->id = $id;

			//Setup the database
			$database = new SMF_Database();

			//Setup the SQL
			$sql = 'select * from smf_members where id_member = '.$id;

			//Prepare the SQL
			$statement = $database->prepare($sql);

			//Execute the SQL
			$statement->execute();

			//bind the columns
			$statement->bindColumn('real_name',$name);

			//if there was an entry (there should be)
			if($statement->fetch(PDO::FETCH_BOUND))
			{
				//Set the name
				$this->name = $name;
			}

			//Setup the database
			$database = new CP_Database();

			//Setup the SQL
			$sql = 'select * from cp_member_details where id_user = '.$id;

			//prepare the sQL
			$statement = $database->prepare($sql);

			//execute the SQL
			$statement->execute();

			//bind the columns
			$statement->bindColumn('ap',$ap);
			$statement->bindColumn('paypal_email',$paypal_email);
			$statement->bindColumn('monthly_limit',$monthly_limit);
			$statement->bindColumn('first_purchase',$first_purchase);
			$statement->bindColumn('total_purchased',$total_purchased);
			$statement->bindColumn('total_sold',$total_sold);

			//if there was an entry
			if($statement->fetch(PDO::FETCH_BOUND))
			{
				//Set all the values
				$this->ap = $ap;
				$this->paypal_email = $paypal_email;
				$this->monthly_limit = $monthly_limit;
				$this->first_purchase = $first_purchase;
				$this->total_purchased = $total_purchased;
				$this->total_sold = $total_sold;
			}
			else
			{
				//Set all the basic values
				$this->ap = 0;
				$this->paypal_email = 'N/A';
				$this->monthly_limit = 'N/A';
				$this->first_purchase = 'N/A';
				$this->total_purchased = 'N/A';
				$this->total_sold = 'N/A';
			}
			//Setup the SQL statement
			$sql = 'select * from cp_linked_accounts_newacme where id_user = '.$id;

			//prepare the SQL statement
			$statement = $database->prepare($sql);

			//execute the script
			$statement->execute();

			//bind columns
			$statement->bindColumn('id_account',$accountID);

			//whilst there are still rows to fetch
			while($statement->fetch(PDO::FETCH_BOUND))
			{
				//Add new account
				$this->accounts_new[count($this->accounts_new)] = new NewACMEAccount($accountID);
			}

			//Setup the SQL statement
			$sql = 'select * from cp_linked_accounts_classicacme where id_user = '.$id;

			//prepare the SQL statement
			$statement = $database->prepare($sql);

			//execute the script
			$statement->execute();

			//bind columns
			$statement->bindColumn('id_account',$accountID);

			//whilst there are still rows to fetch
			while($statement->fetch(PDO::FETCH_BOUND))
			{
				//Add the new account
				$this->accounts_classic[count($this->accounts_classic)] = new ClassicACMEAccount($accountID);
			}
		}

		function addNewAccount($accountID)
		{
			//Create the account
			$account = new NewACMEAccount($accountID);

			//Add it to the end of the array
			$this->accounts_new[count($this->accounts_new)] = $account;
		}

		function addClassicAccount($accountID)
		{
			//Create the account
			$account = new ClassicACMEAccount($accountID);

			//Add it to the end of the array
			$this->accounts_classic[count($this->accounts_classic)] = $account;
		}

		function removeNewAccount($index)
		{
			//Loop through each account
			for ($i=0; $i < count($this->accounts_new); $i++) 
			{ 
				//if this is the account being removed
				if($i == $index)
				//continue to the next and set the index change
				{$indexChange = -1; continue;}

				//copy over the account
				$accounts[$i+$indexChange]=$this->accounts_new[$i];
			}

			//copy over the accounts
			$this->accounts_new = $accounts;
		}

		function removeClassicAccount($index)
		{
			//Loop through each account
			for ($i=0; $i < count($this->accounts_classic); $i++) 
			{ 
				//if this is the account being removed
				if($i == $index)
				//continue to the next and set the index change
				{$indexChange = -1; continue;}

				//copy over the account
				$accounts[$i+$indexChange]=$this->accounts_classic[$i];
			}

			//copy over the accounts
			$this->accounts_classic = $accounts;
		}

		function newAccountExistsByIndex($index)
		{
			return $index < count($this->accounts_new);
		}

		function classicAccountExistsByIndex($index)
		{
			return $index < count($this->accounts_classic);
		}
	}
?>
funhacker is offline  
Old 09/27/2012, 05:42   #8
 
elite*gold: 0
Join Date: Jul 2012
Posts: 80
Received Thanks: 40
For larger projects such as a website, blog, CMS, or forum, absolutely, your access class would be beneficial. But for a project that only involves one single table, and a couple of viewable pages. PDO and the class wouldn't do much in terms of speed.


Also I don't see the point in making the class that extends the PDO when it doesn't do anything but set up connection procedures. One could easily add a variable into a config file and link to the variable on each page it's needed.
Gekru is offline  
Old 09/28/2012, 22:33   #9
 
funhacker's Avatar
 
elite*gold: 20
Join Date: Sep 2007
Posts: 1,767
Received Thanks: 1,746
Quote:
Originally Posted by Gekru View Post
For larger projects such as a website, blog, CMS, or forum, absolutely, your access class would be beneficial. But for a project that only involves one single table, and a couple of viewable pages. PDO and the class wouldn't do much in terms of speed.


Also I don't see the point in making the class that extends the PDO when it doesn't do anything but set up connection procedures. One could easily add a variable into a config file and link to the variable on each page it's needed.
For now I only use it purely as a config class, but I went with individual classes so that if I decide to extend them latter no major re-writes are needed
funhacker is offline  
Old 09/28/2012, 22:58   #10
 
elite*gold: 0
Join Date: Jul 2012
Posts: 80
Received Thanks: 40
Sounds like a good plan to me
Gekru is offline  
Reply


Similar Threads Similar Threads
[Release]Anti-Compose Bot NPC
05/11/2012 - EO PServer Guides & Releases - 19 Replies
Intro I said I would do this release a few days ago but kept putting it off so here it is. Release Function: This release will make the main compose NPC of EO (Market-Aderes) randomly decide to move to locations near him. This should prevent the Auto-Compose Bot that has made some things unfair for other players. Future Updates: I will be working on an app that you will assign NPC ID values to which in turn it will assign the random move script to this NPC. There will also be a...
[Release] IniFile Reader!
02/27/2012 - CO2 PServer Guides & Releases - 15 Replies
Greetings Guys, I was bored so I made a dll to read your Ini files. all you need is to add the dll as a reference to your project and start using it. an example: using System; using System.Collections.Generic; using System.Linq; using System.Text;
[RELEASE] Compose +1 to +12 in 1 NPC
07/06/2009 - CO2 PServer Guides & Releases - 2 Replies
in Client, seacrh for #region NPC Talk and put this code under CurrentNPC = NPCID; if (CurrentNPC == 1554) { SendPacket(General.MyPackets.NPCSay("I can compose, bless and enchant your items, which do you want?")); SendPacket(General.MyPackets.NPCLink("Compose +1 - +9", 1)); SendPacket(General.MyPackets.NPCLink("Enchant ", 2)); ...
[Release] InI File Reader
06/28/2009 - CO2 PServer Guides & Releases - 2 Replies
Well This Should be All.



All times are GMT +1. The time now is 16:48.


Powered by vBulletin®
Copyright ©2000 - 2026, Jelsoft Enterprises Ltd.
SEO by vBSEO ©2011, Crawlability, Inc.
This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.

Support | Contact Us | FAQ | Advertising | Privacy Policy | Terms of Service | Abuse
Copyright ©2026 elitepvpers All Rights Reserved.