Welcome!

Join our community of MMO enthusiasts and game developers! By registering, you'll gain access to discussions on the latest developments in MMO server files and collaborate with like-minded individuals. Join us today and unlock the potential of MMO server development!

Join Today!

Voting Box

Initiate Mage
Joined
Mar 7, 2010
Messages
39
Reaction score
0
This will be my first contribution to the forum.

What you need?

- A site connected to your MsSQL server
- ODBC
- Brain
- Computer

First, you need to execute these queries:

Code:
USE [ACCOUNT_DBF]
ALTER TABLE [dbo].[ACCOUNT_TBL] ADD votepoints int NOT NULL CONSTRAINT [DF_ACCOUNT_TBL_votepoints]  DEFAULT (0),
 lastvote1 DATETIME,
 lastvote2 DATETIME,
 lastvote3 DATETIME
Code:
USE [WEBSITE_DBF]
GO
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[web_userpanel_log]') AND type in (N'U'))
BEGIN
CREATE TABLE [dbo].[web_userpanel_log](
	[SEQ] [int] IDENTITY(1,1) NOT NULL,
	[account] [varchar](32) NOT NULL,
	[m_szName] [varchar](32) NOT NULL,
	[m_idPlayer] [varchar](7) NOT NULL,
	[action] [varchar](max) NOT NULL,
	[datetime] [datetime] NOT NULL,
 CONSTRAINT [PK_rev3_userpanel_log] PRIMARY KEY CLUSTERED 
(
	[SEQ] ASC
)WITH (PAD_INDEX  = OFF, IGNORE_DUP_KEY = OFF) ON [PRIMARY]
) ON [PRIMARY]
END
GO
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[web_ukashlogs]') AND type in (N'U'))
BEGIN
CREATE TABLE [dbo].[web_ukashlogs](
	[ukashid] [int] IDENTITY(1,1) NOT NULL,
	[account] [varchar](50) NOT NULL,
	[pincode] [varchar](19) NOT NULL,
	[worth] [varchar](10) NOT NULL,
	[datetime] [datetime] NOT NULL,
	[done] [int] NOT NULL CONSTRAINT [DF_rev3_ukashlogs_done]  DEFAULT ((0)),
	[key] [varchar](32) NOT NULL,
 CONSTRAINT [PK_rev3_ukashlogs] PRIMARY KEY CLUSTERED 
(
	[ukashid] ASC
)WITH (PAD_INDEX  = OFF, IGNORE_DUP_KEY = OFF) ON [PRIMARY]
) ON [PRIMARY]
END
GO
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[web_staff]') AND type in (N'U'))
BEGIN
CREATE TABLE [dbo].[web_staff](
	[SEQ] [int] IDENTITY(1,1) NOT NULL,
	[Name] [varchar](32) NOT NULL,
	[Rang] [int] NOT NULL
) ON [PRIMARY]
END
GO
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[web_psclogs]') AND type in (N'U'))
BEGIN
CREATE TABLE [dbo].[web_psclogs](
	[pscid] [int] IDENTITY(1,1) NOT NULL,
	[account] [varchar](50) NOT NULL,
	[pincode] [varchar](20) NOT NULL,
	[worth] [varchar](10) NOT NULL,
	[datetime] [datetime] NOT NULL,
	[done] [int] NOT NULL CONSTRAINT [DF_rev3_psclogs_done]  DEFAULT ((0)),
	[key] [varchar](32) NOT NULL,
 CONSTRAINT [PK_rev3_psclogs] PRIMARY KEY CLUSTERED 
(
	[pscid] ASC
)WITH (PAD_INDEX  = OFF, IGNORE_DUP_KEY = OFF) ON [PRIMARY]
) ON [PRIMARY]
END
GO
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[web_newscomments]') AND type in (N'U'))
BEGIN
CREATE TABLE [dbo].[web_newscomments](
	[ncid] [int] IDENTITY(1,1) NOT NULL,
	[nid] [int] NOT NULL,
	[author] [varchar](50) NOT NULL,
	[content] [text] NOT NULL,
	[ip] [varchar](50) NOT NULL,
	[datetime] [datetime] NOT NULL,
 CONSTRAINT [PK_rev3_newscomments] PRIMARY KEY CLUSTERED 
(
	[ncid] ASC
)WITH (PAD_INDEX  = OFF, IGNORE_DUP_KEY = OFF) ON [PRIMARY]
) ON [PRIMARY] TEXTIMAGE_ON [PRIMARY]
END
GO
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[web_newscategories]') AND type in (N'U'))
BEGIN
CREATE TABLE [dbo].[web_newscategories](
	[ncatid] [int] IDENTITY(1,1) NOT NULL,
	[title] [varchar](50) NOT NULL,
	[icon] [varchar](50) NOT NULL,
 CONSTRAINT [PK_rev3_newscategories] PRIMARY KEY CLUSTERED 
(
	[ncatid] ASC
)WITH (PAD_INDEX  = OFF, IGNORE_DUP_KEY = OFF) ON [PRIMARY]
) ON [PRIMARY]
END
GO
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[web_news]') AND type in (N'U'))
BEGIN
CREATE TABLE [dbo].[web_news](
	[nid] [int] IDENTITY(1,1) NOT NULL,
	[title] [varchar](50) NOT NULL,
	[text] [text] NOT NULL,
	[category] [int] NOT NULL,
	[author] [varchar](50) NOT NULL,
	[datetime] [datetime] NOT NULL,
	[views] [int] NOT NULL CONSTRAINT [DF_rev3_news_views]  DEFAULT ((0)),
 CONSTRAINT [PK_rev3_news] PRIMARY KEY CLUSTERED 
(
	[nid] ASC
)WITH (PAD_INDEX  = OFF, IGNORE_DUP_KEY = OFF) ON [PRIMARY]
) ON [PRIMARY] TEXTIMAGE_ON [PRIMARY]
END
GO
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[web_mallcategories]') AND type in (N'U'))
BEGIN
CREATE TABLE [dbo].[web_mallcategories](
	[mcatid] [int] IDENTITY(1,1) NOT NULL,
	[category] [varchar](50) NOT NULL,
 CONSTRAINT [PK_rev3_mallcategories] PRIMARY KEY CLUSTERED 
(
	[mcatid] ASC
)WITH (PAD_INDEX  = OFF, IGNORE_DUP_KEY = OFF) ON [PRIMARY]
) ON [PRIMARY]
END
GO
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[web_mallbasket]') AND type in (N'U'))
BEGIN
CREATE TABLE [dbo].[web_mallbasket](
	[mbid] [int] IDENTITY(1,1) NOT NULL,
	[account] [varchar](50) NOT NULL,
	[item] [int] NOT NULL
) ON [PRIMARY]
END
GO
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[web_mall]') AND type in (N'U'))
BEGIN
CREATE TABLE [dbo].[web_mall](
	[mid] [int] IDENTITY(1,1) NOT NULL,
	[itemid] [int] NULL,
	[name] [varchar](100) NULL,
	[description] [varchar](200) NULL,
	[price] [int] NULL,
	[count] [int] NULL,
	[category] [int] NULL,
	[icon] [varchar](100) NULL,
	[packet] [int] NULL,
	[Item_ID_1] [int] NULL,
	[Item_Count_1] [int] NULL,
	[Item_ID_2] [int] NULL,
	[Item_Count_2] [int] NULL,
	[Item_ID_3] [int] NULL,
	[Item_Count_3] [int] NULL,
	[Item_ID_4] [int] NULL,
	[Item_Count_4] [int] NULL,
	[job] [int] NULL,
 CONSTRAINT [PK_rev3_mall] PRIMARY KEY CLUSTERED 
(
	[mid] ASC
)WITH (PAD_INDEX  = OFF, IGNORE_DUP_KEY = OFF) ON [PRIMARY]
) ON [PRIMARY]
END
GO
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[web_giftlogs]') AND type in (N'U'))
BEGIN
CREATE TABLE [dbo].[web_giftlogs](
	[giftid] [int] IDENTITY(1,1) NOT NULL,
	[item] [int] NOT NULL,
	[accfrom] [varchar](50) NOT NULL,
	[accto] [varchar](50) NOT NULL,
	[charto] [varchar](50) NULL,
	[datetime] [datetime] NOT NULL,
 CONSTRAINT [PK_rev3_giftlogs] PRIMARY KEY CLUSTERED 
(
	[giftid] ASC
)WITH (PAD_INDEX  = OFF, IGNORE_DUP_KEY = OFF) ON [PRIMARY]
) ON [PRIMARY]
END
GO
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[web_faq]') AND type in (N'U'))
BEGIN
CREATE TABLE [dbo].[web_faq](
	[faqid] [int] IDENTITY(1,1) NOT NULL,
	[question] [varchar](200) NOT NULL,
	[answer] [varchar](200) NOT NULL,
 CONSTRAINT [PK_rev3_faq] PRIMARY KEY CLUSTERED 
(
	[faqid] ASC
)WITH (PAD_INDEX  = OFF, IGNORE_DUP_KEY = OFF) ON [PRIMARY]
) ON [PRIMARY]
END
GO
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[web_downloads]') AND type in (N'U'))
BEGIN
CREATE TABLE [dbo].[web_downloads](
	[dlid] [int] IDENTITY(1,1) NOT NULL,
	[title] [varchar](50) NOT NULL,
	[description] [varchar](200) NOT NULL,
	[link] [varchar](100) NOT NULL,
	[datetime] [datetime] NOT NULL,
	[clicks] [int] NOT NULL CONSTRAINT [DF_rev3_downloads_clicks]  DEFAULT ((0)),
 CONSTRAINT [PK_rev3_downloads] PRIMARY KEY CLUSTERED 
(
	[dlid] ASC
)WITH (PAD_INDEX  = OFF, IGNORE_DUP_KEY = OFF) ON [PRIMARY]
) ON [PRIMARY]
END
GO
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[web_counter]') AND type in (N'U'))
BEGIN
CREATE TABLE [dbo].[web_counter](
	[Website] [varchar](50) NOT NULL,
	[Count] [int] NOT NULL
) ON [PRIMARY]
END
GO
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[web_config]') AND type in (N'U'))
BEGIN
CREATE TABLE [dbo].[web_config](
	[id] [int] IDENTITY(1,1) NOT NULL,
	[col] [varchar](50) NOT NULL,
	[value] [varchar](100) NOT NULL,
 CONSTRAINT [PK_rev3_config] PRIMARY KEY CLUSTERED 
(
	[id] ASC
)WITH (PAD_INDEX  = OFF, IGNORE_DUP_KEY = OFF) ON [PRIMARY]
) ON [PRIMARY]
END
GO
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[web_buylogs]') AND type in (N'U'))
BEGIN
CREATE TABLE [dbo].[web_buylogs](
	[bid] [int] IDENTITY(1,1) NOT NULL,
	[item] [int] NOT NULL,
	[account] [varchar](50) NOT NULL,
	[datetime] [datetime] NOT NULL,
 CONSTRAINT [PK_rev3_buylogs] PRIMARY KEY CLUSTERED 
(
	[bid] ASC
)WITH (PAD_INDEX  = OFF, IGNORE_DUP_KEY = OFF) ON [PRIMARY]
) ON [PRIMARY]
END
GO
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[web_banlogs]') AND type in (N'U'))
BEGIN
CREATE TABLE [dbo].[web_banlogs](
	[banid] [int] IDENTITY(1,1) NOT NULL,
	[account] [varchar](50) NOT NULL,
	[byadmin] [varchar](50) NOT NULL,
	[reason] [text] NULL,
	[datetime] [datetime] NOT NULL,
 CONSTRAINT [PK_rev3_banlogs] PRIMARY KEY CLUSTERED 
(
	[banid] ASC
)WITH (PAD_INDEX  = OFF, IGNORE_DUP_KEY = OFF) ON [PRIMARY]
) ON [PRIMARY] TEXTIMAGE_ON [PRIMARY]
END
GO
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[web_xShop]') AND type in (N'U'))
BEGIN
CREATE TABLE [dbo].[web_xShop](
	[SEQ] [int] IDENTITY(1,1) NOT NULL,
	[Display] [int] NOT NULL,
	[ID] [int] NOT NULL,
	[Name] [varchar](128) NOT NULL,
	[Description] [varchar](256) NOT NULL,
	[Job] [int] NOT NULL,
	[Sex] [int] NOT NULL,
	[Category] [int] NOT NULL,
	[Price] [int] NOT NULL,
	[Discount] [int] NOT NULL,
	[Amount] [int] NOT NULL,
	[Purchase] [int] NOT NULL,
	[Icon] [varchar](100) NOT NULL,
	[Packet] [int] NOT NULL,
	[ID_1] [int] NULL,
	[Name_1] [varchar](128) NULL,
	[Amount_1] [int] NULL,
	[ID_2] [int] NULL,
	[Name_2] [varchar](128) NULL,
	[Amount_2] [int] NULL,
	[ID_3] [int] NULL,
	[Name_3] [varchar](128) NULL,
	[Amount_3] [int] NULL,
	[ID_4] [int] NULL,
	[Name_4] [varchar](128) NULL,
	[Amount_4] [int] NULL,
	[ID_5] [int] NULL,
	[Name_5] [varchar](128) NULL,
	[Amount_5] [int] NULL
) ON [PRIMARY]
END
GO
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[web_voteitems]') AND type in (N'U'))
BEGIN
CREATE TABLE [dbo].[web_voteitems](
	[vitemid] [int] IDENTITY(1,1) NOT NULL,
	[itemid] [int] NOT NULL,
	[name] [varchar](50) NOT NULL,
	[count] [int] NOT NULL,
	[price] [int] NOT NULL,
	[icon] [varchar](50) NOT NULL,
 CONSTRAINT [PK_rev3_voteitems] PRIMARY KEY CLUSTERED 
(
	[vitemid] ASC
)WITH (PAD_INDEX  = OFF, IGNORE_DUP_KEY = OFF) ON [PRIMARY]
) ON [PRIMARY]
END
GO
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[web_vote_log]') AND type in (N'U'))
BEGIN
CREATE TABLE [dbo].[web_vote_log](
	[SEQ] [int] IDENTITY(1,1) NOT NULL,
	[Account] [varchar](32) NOT NULL,
	[m_idPlayer] [varchar](7) NOT NULL,
	[IP] [varchar](15) NOT NULL,
	[Item_Name] [varchar](50) NOT NULL,
	[Item_Id] [int] NOT NULL,
	[Amount] [int] NOT NULL,
	[Datum] [datetime] NOT NULL,
 CONSTRAINT [PK_rev3_vote_log] PRIMARY KEY CLUSTERED 
(
	[SEQ] ASC
)WITH (PAD_INDEX  = OFF, IGNORE_DUP_KEY = OFF) ON [PRIMARY]
) ON [PRIMARY]
END
GO
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[usp_user_panel_log]') AND type in (N'P', N'PC'))
BEGIN
EXEC dbo.sp_executesql @statement = N'-- =============================================
-- Author:		<Author,,Name>
-- Create date: <Create Date,,>
-- Description:	<Description,,>
-- =============================================
CREATE PROCEDURE [dbo].[usp_user_panel_log]
	@account varchar(32),
	@m_szName varchar(32),
	@m_idPlayer varchar(7),
	@action varchar(MAX)
AS
BEGIN
	SET NOCOUNT ON;

    INSERT INTO [web_userpanel_log] ( [account], [m_szName], [m_idPlayer], [action], [datetime] )
    VALUES ( @account, @m_szName, @m_idPlayer, @action, GETDATE() )
END
' 
END
GO
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[usp_LoguKash]') AND type in (N'P', N'PC'))
BEGIN
EXEC dbo.sp_executesql @statement = N'-- =============================================
-- Author:		<Author,,Name>
-- Create date: <Create Date,,>
-- Description:	<Description,,>
-- =============================================
CREATE PROCEDURE [dbo].[usp_LoguKash]
	@account varchar(32),
	@psc varchar(19),
	@worth varchar(10),
	@key varchar(32)
AS
BEGIN
	SET NOCOUNT ON;

	INSERT INTO [web_uKashlogs] ( [account], [pincode], [worth], [datetime], [done], [key] )
	VALUES ( @account, @psc, @worth, GETDATE(), 0, @key )
END
' 
END
GO
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[usp_LogPSC]') AND type in (N'P', N'PC'))
BEGIN
EXEC dbo.sp_executesql @statement = N'-- =============================================
-- Author:		<Author,,Name>
-- Create date: <Create Date,,>
-- Description:	<Description,,>
-- =============================================
CREATE PROCEDURE [dbo].[usp_LogPSC]
	@account varchar(32),
	@psc varchar(19),
	@worth varchar(10),
	@key varchar(32)
AS
BEGIN
	SET NOCOUNT ON;

	INSERT INTO [web_psclogs] ( [account], [pincode], [worth], [datetime], [done], [key] )
	VALUES ( @account, @psc, @worth, GETDATE(), 0, @key )
END
' 
END
GO
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[xShop]') AND type in (N'P', N'PC'))
BEGIN
EXEC dbo.sp_executesql @statement = N'-- =============================================
-- Author:		<Author,,Name>
-- Create date: <Create Date,,>
-- Description:	<Description,,>
-- =============================================
CREATE PROCEDURE [dbo].[xShop] 
	@SEQ int = 0,
	@Cat int = 0,
	@Account varchar(16) = '''',
	@Mode varchar(128) = ''''
AS
BEGIN
	SET NOCOUNT ON;
	
	-- Select Shop Content
	if( @Mode = ''S_Category'' )
		begin
			select * from web_mallcategories
		end
	-- Select Items from SEQ
	else if( @Mode = ''S_Items'' )
		begin
			select * from web_xShop where [Category] = @Cat and [Display] = 1 order by [Name] ASC
		end
END
' 
END
GO
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[usp_AddVote]') AND type in (N'P', N'PC'))
BEGIN
EXEC dbo.sp_executesql @statement = N'-- =============================================
-- Author:		<Author,,Name>
-- Create date: <Create Date,,>
-- Description:	<Description,,>
-- =============================================
CREATE PROCEDURE [dbo].[usp_AddVote] 
	@account varchar(32),
	@m_idPlayer varchar(7),
	@ip varchar(15),
	@Item_Name varchar(50),
	@Item_Id int,
	@Amount int
AS
BEGIN
	SET NOCOUNT ON;

    INSERT INTO [web_vote_log]( [Account], [m_idPlayer], [IP], [Item_Name], [Item_Id], [Amount], [Datum] )
    VALUES ( @account, @m_idPlayer, @ip, @Item_Name, @Item_Id, @Amount, GETDATE() )
END
' 
END


GO

Now for the PHP codes:
The source was based from this files:
I forgot where I got this and who uploaded it but, I would love to give him credits =D

Anyway, his voting scripts we're finished and has a lots of bugs. To be honest, I don't know anything about PHP, SQL, or any website programming languages. I tried to ask if someone knows how to fix it. But unfortunately, no one does. So I studied PHP, ODBC and MsSQL languages. It took me 3 days to understand the algorithm of the script and another 3 days to debug it. Off with the story. Let's proceed =D

Create 4 files and name it ajax.php, config.inc.php and votebox.inc.php, function

use this code for ajax.php
Code:
<?php
	include('config.inc.php');
	if(empty($_GET['page'])) $_GET['page'] = 1;
	
	/* VOTE BOX */
	if($_GET['a'] == 'showvotebox') {
		$_SESSION['votebox'] = 'showed';
	}
	
	if($_GET['a'] == 'hidevotebox') {
		$_SESSION['votebox'] = 'hidden';
	}
	
	if($_GET['a'] == 'voteitem') {
		$selecteditems = odbc_exec($mssql, 'SELECT * FROM [web_voteitems] WHERE vitemid=\''.mssql_escape_string($_GET['vid']).'\'');
		$selecteditem = odbc_fetch_array($selecteditems);
		odbc_exec($mssql, 'USE [ACCOUNT_DBF]');
		$userselect = odbc_exec($mssql, 'SELECT * FROM [ACCOUNT_TBL] WHERE account=\''.mssql_escape_string($_SESSION['user']).'\'');
		$user = odbc_fetch_array($userselect);
		
		if($user['votepoints'] < $selecteditem['price']) {
			echo '<span style="color: #f00;">You do not have enough Vote Points!</span><br/><br/>';
		} else {
			if(empty($_GET['char']) || !isset($_GET['char'])) {
				echo '<span style="color: #f00;">You need to have a character!</span><br/><br/>';
			} elseif($selecteditem == '') {
				echo '<span style="color: #f00;">The selected item does not exist!</span><br/><br/>';
			} else {
				odbc_exec($mssql, 'USE [CHARACTER_01_DBF]');
				$accountofchar = odbc_exec($mssql, 'SELECT account FROM [CHARACTER_TBL] WHERE m_idPlayer=\''.mssql_escape_string($_GET['char']).'\'');
				if(strtolower(odbc_result($accountofchar, 'account')) == strtolower($_SESSION['user'])) {
					send_item($_GET['char'], $selecteditem['name'], $selecteditem['count']);
					odbc_exec($mssql, 'USE [ACCOUNT_DBF]');
					odbc_exec($mssql, 'UPDATE [ACCOUNT_TBL] SET votepoints=votepoints-\''.mssql_escape_string($selecteditem['price']).'\' WHERE account=\''.mssql_escape_string($_SESSION['user']).'\'');
					echo '<script type="text/javascript">Current Vote Points(\''.$user['votepoints'].'\', \''.$selecteditem['price'].'\');</script>';
					echo 'You bought the item successfully!<br/><br/>';
				}
			}
		}
	}
	if($_GET['a'] == 'voteitemspage') {
		echo '<table>';
		odbc_exec($mssql, 'USE [WEBSITE_DBF]');
		$items = odbc_exec($mssql, 'SELECT * FROM [web_voteitems]');
		
		$page = $_GET['page'];
		$perpage = 2;
		$resultset = array();
		$counter = 0;
		while($row = odbc_fetch_array($items)) {
			$resultset[$counter++] = $row;
		}
		$count = odbc_exec($mssql, 'SELECT COUNT(*) as i FROM [web_voteitems]');
		$countpages = odbc_result($count, 'i') / $perpage;
		
		for($i = $perpage * ($page-1);$i < $perpage*$page;$i++) {
			if(isset($resultset[$i])) {
				echo '<tr>
					<td style="vertical-align: top;"><img src="./img/'.$resultset[$i]['icon'].'" /></td>
					<td valign="top">
						<b>'.$resultset[$i]['name'].'</b><br/>
						<table><tr><td><img src="img/price.png" /></td><td>'.$resultset[$i]['price'].' Vote Points</td></tr></table>';
					if(isset($_SESSION['user'])) {
						echo '<a href="javascript:voteItem('.$resultset[$i]['vitemid'].')">Take it!</a>';
					}
					echo '</td>
				</tr>
				<tr><td colspan="2"><br/></td></tr>';
			}
		}
		echo '</table>';
		for($i=0; $i < $countpages; $i++) {
			$k = $i + 1;
			if($page == $k) {
				 echo '<span id="page"><b>'.$k.'</b></span>';
			} else {
				echo '<span id="page"><a href="javascript:voteItemsPage('.$k.');">'.$k.'</a></span>';
			}
		}
	}
	if($_GET['a'] == 'voteitems') {
		echo 'Here you can vote <by>to support the server and ger free gifts.<br/><br/>';
		if(isset($_SESSION['user'])) {
			odbc_exec($mssql, 'USE [CHARACTER_01_DBF]');
			$player = odbc_exec($mssql, 'SELECT * FROM [CHARACTER_TBL] WHERE account=\''.mssql_escape_string($_SESSION['user']).'\' AND isblock=\'F\' ORDER BY playerslot');
			if(odbc_num_rows($player) >= 1) {
				echo 'Character: <form method="post"><select type="text_klein" name="character" id="character">';
				while($char = odbc_fetch_array($player)) {
					echo '<option value="'.$char['m_idPlayer'].'">'.$char['m_szName'].'</option>';
				}
				echo '</select></form><br/>';
			}
		}
		echo 'Available Gifts:<br/><br/>
		<div id="availgifts">
		<table>';
		odbc_exec($mssql, 'USE [WEBSITE_DBF]');
		$items = odbc_exec($mssql, 'SELECT * FROM [web_voteitems]');
		$page = $_GET['page'];
		if(!isset($page)) { $page = 1; }
		$perpage = 2;
		$resultset = array();
		$counter = 0;
		while($row = odbc_fetch_array($items)) {
			$resultset[$counter++] = $row;
		}
		$count = odbc_exec($mssql, 'SELECT COUNT(*) as i FROM [web_voteitems]');
		$countpages = odbc_result($count, 'i') / $perpage;
		
		for($i = $perpage * ($page-1);$i < $perpage*$page;$i++) {
			if(isset($resultset[$i])) {
				echo '<tr>
					<td style="vertical-align: top;"><img src="./img/'.$resultset[$i]['icon'].'" /></td>
					<td valign="top">
						<b>'.$resultset[$i]['name'].'</b><br/>
						<table><tr><td><img src="img/price.png" /></td><td>'.$resultset[$i]['price'].' Vote Points</td></tr></table>';
					if(isset($_SESSION['user'])) {
						echo '<a href="javascript:voteItem('.$resultset[$i]['vitemid'].');">Take it!</a>';
					}
					echo '</td>
				</tr>
				<tr><td colspan="2"><br/></td></tr>';
			}
		}
		echo '</table>';
		for($i=0; $i < $countpages; $i++) {
			$k = $i + 1;
			if($page == $k) {
				 echo '<span id="page"><b>'.$k.'</b></span>';
			} else {
				echo '<span id="page"><a href="javascript:voteItemsPage('.$k.');">'.$k.'</a></span>';
			}
		}
		echo '</div><br />';
		if(isset($_SESSION['user'])) {
			odbc_exec($mssql, 'USE [ACCOUNT_DBF]');
			$votepoints = odbc_exec($mssql, 'SELECT [votepoints] FROM [ACCOUNT_TBL] WHERE account=\''.mssql_escape_string($_SESSION['account']).'\'');
			echo 'Current Vote Points: <b><span id="currvp">'.odbc_result($votepoints, 'votepoints').'</span></b><br/><br/>';
			echo '<span id="takeitem"></span>';
			echo '<a href="javascript:voteTab();"><b>Click here to Vote!</b></a>';
		} else {
			echo '<b>You need to login to vote!</b>';

		}
	}
	if($_GET['a'] == 'vote') { // Vote Box
		odbc_exec($mssql, 'USE [ACCOUNT_DBF]');
		$userselect = odbc_exec($mssql, 'SELECT * FROM [ACCOUNT_TBL] WHERE account=\''.mssql_escape_string($_SESSION['user']).'\'');
		$user = odbc_fetch_array($userselect);
		
		$time1 = $user['lastvote1'];
		$time2 = $user['lastvote2'];
		$time3 = $user['lastvote3'];
		
		$diff1 = diff1($user['lastvote1']);
		$diff2 = diff2($user['lastvote2']);
		$diff3 = diff3($user['lastvote3']);
		$votedtoday = 0;
		if($diff1['hours'] < 12)
			$votedtoday = $votedtoday + 1;
		if($diff2['hours'] < 12)
			$votedtoday = $votedtoday + 1;
		if($diff3['hours'] < 12)
			$votedtoday = $votedtoday + 1;
		echo 'Account: <b>'.$user['account'].'</b><br/><br/>';
		echo 'Account Vote Points: <b><span id="vpoints">'.$user['votepoints'].'</span></b><br/><br/>';
		echo 'You can still vote <b><span id="vtoday"> '.(3 - $votedtoday).' </span></b> times.<br/><br/>';
		if($diff1['hours'] >= 12 || $diff2['hours'] >= 12 || $diff3['hours'] >= 12) {
			if(isset($_GET['submit'])) {
				if($_GET['submit'] == 1) {
					if($diff1['hours'] >= 12) {
						odbc_exec($mssql, 'UPDATE [ACCOUNT_TBL] SET votepoints=votepoints + 1 WHERE account=\''.mssql_escape_string($_SESSION['user']).'\'');
						odbc_exec($mssql, 'UPDATE [ACCOUNT_TBL] SET lastvote1 =\''.date('m-d-Y H:i:s').'\' WHERE account=\''.mssql_escape_string($_SESSION['user']).'\'');
						$_GET['submit'];
					}
				} elseif($_GET['submit'] == 2) {
					if($diff2['hours'] >= 12) {
						odbc_exec($mssql, 'UPDATE [ACCOUNT_TBL] SET votepoints=votepoints + 1 WHERE account=\''.mssql_escape_string($_SESSION['user']).'\'');
						odbc_exec($mssql, 'UPDATE [ACCOUNT_TBL] SET lastvote2 =\''.date('m-d-Y H:i:s').'\' WHERE account=\''.mssql_escape_string($_SESSION['user']).'\'');
						$_GET['submit'];
						
					}
				} elseif($_GET['submit'] == 3) {
					if($diff3['hours'] >= 12) {
						odbc_exec($mssql, 'UPDATE [ACCOUNT_TBL] SET votepoints=votepoints + 1 WHERE account=\''.mssql_escape_string($_SESSION['user']).'\'');
						odbc_exec($mssql, 'UPDATE [ACCOUNT_TBL] SET lastvote3 =\''.date('m-d-Y H:i:s').'\' WHERE account=\''.mssql_escape_string($_SESSION['user']).'\'');
						$_GET['submit'];
					}
				}
			}
			echo 'You get 1 vote point per page.<br>After the votes you can pick a gift!<br>Follow the instructions in order to vote for all 3 Topsites.<br/><br/><div id="topsite" style="text-align: center;">';
			if($diff1['hours'] >= 12) {
				// Top of Games
				echo '<img src="img/tog.gif" /><br/><br/>';
				echo '<span id="votetext"><a onclick="vote(1, '.$diff2['hours'].', \''.$votelist2.'\', \''.$votelist3.'\');" href="'.$votelist1.'" target="_blank">Click here to continue!</a></span>';
			} elseif($diff2['hours'] >= 12 ) {
				// Xtreme Top 100
				echo '<img src="img/xtop100.jpg" /><br/><br/>';
				echo '<span id="votetext"><a onclick="vote(2, '.$diff3['hours'].', \''.$votelist2.'\', \''.$votelist3.'\');" href="'.$votelist2.'" target="_blank">Click here to continue!</a></span>';
			} elseif($diff3['hours'] >= 12) {
				// G Top 100
				echo '<img src="img/gtop100.jpg" /><br/><br/>';
				echo '<span id="votetext"><a onclick="vote(2, '.$diff3['hours'].', \''.$votelist2.'\', \''.$votelist3.'\');" href="'.$votelist2.'" target="_blank">Click here to continue!</a></span>';
			}
			echo '</div>';
		} else {
			echo '<a href="javascript:voteItemTab();">Select an item!</a>';
		}
	}
	/* VOTE BOX END */
?>


For config.inc.php, use this code:
Code:
<?php
	session_start();
	
	// SQL Data
	define('MSSQL_HOST', 'MYSERVER\SQLEXPRESS');	// MsSQL Host
	define('MSSQL_USER', 'sa');	// MsSQL Username
	define('MSSQL_PASS', 'mypass');	// MsSQL Password
	
	// Connecting to MsSQL (ODBC)
	$mssql = odbc_connect('Driver={SQL Server};Server='.MSSQL_HOST.';', MSSQL_USER, MSSQL_PASS);
	
	// Including Files
	include('functions.inc.php');
	
	// Config
	$_CONFIG['webtitle'] = getConfigValue('webtitle', 'myweb');
	$_CONFIG['forumlink'] = getConfigValue('forumlink', 'http://forum.myweb.com/');
	$_CONFIG['pwdsalt'] = getConfigValue('pwdsalt', 'mypwdsalt');
	$_CONFIG['noreply'] = getConfigValue('noreplymail', 'noreply@myweb.com');
	$_CONFIG['ppemail'] = getConfigValue('ppemail', 'mypp@myweb.com');
	
	// PaySafeCard: Euro => Points
	$psc_values = array('10,00' => '1500', '25,00' => '3000', '50,00' => '6000', '100,00' => '13000');
	
	// Vote Sites (must be 3!)
	$votelist1 = 'http://votelink1.com'; // Top of Games
	$votelist2 = 'http://votelink2.com'; // Xtreme Top 100
	$votelist3 = 'http://votelink3.com'; // G Top 100
?>

For functions.inc.php, use this code:
Code:
<?php
	function mssql_escape_string($string) {
		$replaced_string = str_replace("'", "''", $string);
		return $replaced_string;
	}
	
	function diff1($time1) {
		$diff = strtotime(date('Y-m-d H:i:s')) - strtotime($time1);
		$minutes = $diff / 60;
		if($minutes >= 60) {
			$hours = $minutes / 60;
			$minutes = $minutes % 60;
		} else {
			$hours = 0;
		}
		return array('hours' => floor($hours), 'minutes' => $minutes);
	}
	
	function diff2($time2) {
		$diff = strtotime(date('Y-m-d H:i:s')) - strtotime($time2);
		$minutes = $diff / 60;
		if($minutes >= 60) {
			$hours = $minutes / 60;
			$minutes = $minutes % 60;
		} else {
			$hours = 0;
		}
		return array('hours' => floor($hours), 'minutes' => $minutes);
	}
	
	function diff3($time3) {
		$diff = strtotime(date('Y-m-d H:i:s')) - strtotime($time3);
		$minutes = $diff / 60;
		if($minutes >= 60) {
			$hours = $minutes / 60;
			$minutes = $minutes % 60;
		} else {
			$hours = 0;
		}
		return array('hours' => floor($hours), 'minutes' => $minutes);
	}
	
	function send_item($playerid, $itemid, $quantity) {
		global $mssql;
		odbc_exec($mssql, 'USE [CHARACTER_01_DBF]');
		odbc_exec($mssql, 'INSERT INTO [ITEM_SEND_TBL](
		m_idPlayer, serverindex, Item_Name, Item_count, idSender
		) VALUES(
		\''.mssql_escape_string($playerid).'\',
		\'01\',
		\''.mssql_escape_string($itemid).'\',
		\''.mssql_escape_string($quantity).'\',
		\'0000000\')');
	}
	
	function send_item_list($playerid, $itemidArray, $quantityArray) {
		global $mssql;
		for($i = 0;$i < count($itemidArray);$i++)
		{
			odbc_exec($mssql, 'USE [CHARACTER_01_DBF]');
			odbc_exec($mssql, 'INSERT INTO [ITEM_SEND_TBL](
			m_idPlayer, serverindex, Item_Name, Item_count, idSender
			) VALUES(
			\''.mssql_escape_string($playerid).'\',
			\'01\',
			\''.mssql_escape_string($itemidArray[$i]).'\',
			\''.mssql_escape_string($quantityArray[$i]).'\',
			\'0000000\')');
		}
	}
?>

For votebox.inc.php, use this code:
Code:
Here you can vote<br/>
to support the server and get free <b>Gifts</b>.
<br/>
<?php
	if(empty($_GET['page'])) $_GET['page'] = 1;
	
	if(isset($_SESSION['user'])) {
		odbc_exec($mssql, 'USE [CHARACTER_01_DBF]');
		$player = odbc_exec($mssql, 'SELECT * FROM [CHARACTER_TBL] WHERE account=\''.mssql_escape_string($_SESSION['user']).'\' AND isblock=\'F\' ORDER BY playerslot');
		if(odbc_num_rows($player) >= 1) {
			echo 'Character: <form method="post"><select name="character" id="character">';
			while($char = odbc_fetch_array($player)) {
				echo '<option value="'.$char['m_idPlayer'].'">'.$char['m_szName'].'</option>';
			}
			echo '</select></form><br/>';
		}
	}
?>
Available Gifts:<br/><br/>
<div id="availgifts">
<table>
<?php
	odbc_exec($mssql, 'USE [WEBSITE_DBF]');
	$items = odbc_exec($mssql, 'SELECT * FROM [web_voteitems]');
	
	$page = $_GET['page'];
	if(!isset($page)) { $page = 1; }
	$perpage = 2;
	$resultset = array();
	$counter = 0;
	while($row = odbc_fetch_array($items)) {
		$resultset[$counter++] = $row;
	}
	$count = odbc_exec($mssql, 'SELECT COUNT(*) as i FROM [web_voteitems]');
	$countpages = odbc_result($count, 'i') / $perpage;
	
	for($i = $perpage * ($page-1);$i < $perpage*$page;$i++) {
		if(isset($resultset[$i])) {
			echo '<tr>
				<td style="vertical-align: top;"><img src="./img/'.$resultset[$i]['icon'].'" /></td>
				<td valign="top">
					<b>'.$resultset[$i]['name'].'</b><br/>
					<table><tr><td><img src="img/price.png" /></td><td>'.$resultset[$i]['price'].' Vote Points</td></tr></table>';
				if(isset($_SESSION['user'])) {
					echo '<a href="javascript:voteItem('.$resultset[$i]['vitemid'].')">Take it!</a>';
				}
				echo '</td>
			</tr>
			<tr><td colspan="2"><br/></td></tr>';
		}
	}
?>
</table>
<?php
	for($i=0; $i < $countpages; $i++) {
		$k = $i + 1;
		if($page == $k) {
			 echo '<span id="page"><b>'.$k.'</b></span>';
		} else {
			echo '<span id="page"><a href="javascript:voteItemsPage('.$k.');">'.$k.'</a></span>';
		}
	}
	echo '</div><br />';
	if(isset($_SESSION['user'])) {
		odbc_exec($mssql, 'USE [ACCOUNT_DBF]');
		$votepoints = odbc_exec($mssql, 'SELECT [votepoints] FROM [ACCOUNT_DBF].dbo.[ACCOUNT_TBL] WHERE account=\''.mssql_escape_string($_SESSION['user']).'\'');
		echo 'Current Vote Points: <b><span id="votespoints">'.odbc_result($votepoints, 'votepoints').'</span></b><br/><br/>';
		echo '<span id="takeitem"></span>';
		echo '<a href="javascript:voteTab();"><b>Click here to Vote!</b></a>';
	} else {
		echo '<b>You need to login to vote!</b>';
	}
?>


That's all, now try to check if it's working...
Enjoy!



My code isn't professional, I'm just new to this programming languages. You could improve my code if you want.


Credits:
80% To the one who uploaded wwwroot.rar
20% To me for finishing his work.

If you used the wwwroot.rar, you need to change the language by yourself =D
 
Last edited:
Not working on UnitedFlyf
Member
Joined
Apr 21, 2009
Messages
1,385
Reaction score
934
Re: V19 Voting Box

Doesn't look too bad for someone that is very new to PHP/SQL... However, what makes it a v19 Voting Box?
 
Owner
Member
Joined
May 13, 2011
Messages
1,497
Reaction score
157
Re: V19 Voting Box

Thats what i am wondering to.

I am also using that script. But i added some features to it. and rescripted it again.
 
Owner
Member
Joined
May 13, 2011
Messages
1,497
Reaction score
157
Re: V19 Voting Box

Thats correct. It is from the forsaken homepage.
 
Back
Top