[2.0.18] Cash Mod

All new MODs released in our MOD Database will be announced in here. All support for released MODs needs to take place in here. No new MODs will be accepted into the MOD Database for phpBB2
Forum rules
READ: phpBB.com Board-Wide Rules and Regulations

On February 1, 2009 this forum will be set to read only as part of retiring of phpBB2.

Rating:

Excellent!
1036
66%
Very Good
239
15%
Good
121
8%
Fair
36
2%
Poor
126
8%
 
Total votes: 1558

User avatar
Xore
Former Team Member
Posts: 2594
Joined: Wed Apr 16, 2003 7:42 pm
Location: the wastelands between insomnia and clairvoyance
Contact:

Post by Xore » Thu Jul 10, 2003 1:57 pm

[ content removed - Xore ]
Last edited by Xore on Mon Apr 12, 2004 9:49 pm, edited 1 time in total.
Camels in the Mist
<noise type="random" source="camel" />
Cash Mod

User avatar
Xore
Former Team Member
Posts: 2594
Joined: Wed Apr 16, 2003 7:42 pm
Location: the wastelands between insomnia and clairvoyance
Contact:

Post by Xore » Thu Jul 10, 2003 2:34 pm

[ content removed - Xore ]
Last edited by Xore on Mon Apr 12, 2004 9:50 pm, edited 1 time in total.
Camels in the Mist
<noise type="random" source="camel" />
Cash Mod

User avatar
Xore
Former Team Member
Posts: 2594
Joined: Wed Apr 16, 2003 7:42 pm
Location: the wastelands between insomnia and clairvoyance
Contact:

Post by Xore » Thu Jul 10, 2003 2:37 pm

[ content removed - Xore ]
Last edited by Xore on Mon Apr 12, 2004 9:51 pm, edited 1 time in total.
Camels in the Mist
<noise type="random" source="camel" />
Cash Mod

User avatar
Xore
Former Team Member
Posts: 2594
Joined: Wed Apr 16, 2003 7:42 pm
Location: the wastelands between insomnia and clairvoyance
Contact:

Post by Xore » Thu Jul 10, 2003 2:43 pm

[ content removed - Xore ]
Last edited by Xore on Mon Apr 12, 2004 9:51 pm, edited 1 time in total.
Camels in the Mist
<noise type="random" source="camel" />
Cash Mod

User avatar
Xore
Former Team Member
Posts: 2594
Joined: Wed Apr 16, 2003 7:42 pm
Location: the wastelands between insomnia and clairvoyance
Contact:

Post by Xore » Fri Jul 11, 2003 2:29 am

[ content removed - Xore ]
Last edited by Xore on Mon Apr 12, 2004 9:55 pm, edited 15 times in total.
Camels in the Mist
<noise type="random" source="camel" />
Cash Mod

deadferret
Registered User
Posts: 36
Joined: Wed Dec 11, 2002 9:45 pm

Post by deadferret » Mon Aug 04, 2003 3:41 pm

Rancisis wrote: deadferret, could you post the queries you used to install it on mssql?
I could then add them to my sql installer (might be useful for future people who want to install it...)


Ok here it is. I tested this twice on Ms Sql 2000 and it works when you run each query individually. Please test this as well in your database and make sure everything works before using in a production environement.
##############################
## Follow each query in order, do not group
## them. Ms Sql 2000 is very picky.
##
## Replace "userid" with your id for the
## database. (I.e. dbo or sysadmin, etc)
##############################

## Query 1 (Not much change for the insert)
INSERT INTO phpbb_config (config_name, config_value) VALUES ('cash_disable',0);
INSERT INTO phpbb_config (config_name, config_value) VALUES ('cash_display_after_posts',1);
INSERT INTO phpbb_config (config_name, config_value) VALUES ('cash_post_message','You earned %s for that post');
INSERT INTO phpbb_config (config_name, config_value) VALUES ('cash_disable_spam_num',10);
INSERT INTO phpbb_config (config_name, config_value) VALUES ('cash_disable_spam_time',24);
INSERT INTO phpbb_config (config_name, config_value) VALUES ('cash_disable_spam_message','You have exceeded the alloted amount of posts and will not earn anything for your post');
INSERT INTO phpbb_config (config_name, config_value) VALUES ('cash_installed','yes');
INSERT INTO phpbb_config (config_name, config_value) VALUES ('cash_version','2.0.2');
INSERT INTO phpbb_config (config_name, config_value) VALUES ('points_name','Points');

## Query 2a
CREATE TABLE [userid].[phpbb_cash] (
[cash_id] [int] IDENTITY (1, 1) NOT NULL ,
[cash_order] [int] NOT NULL ,
[cash_enabled] [int] NOT NULL ,
[cash_dbfield] [varchar] (64) COLLATE SQL_Latin1_General_CP1_CI_AS NOT NULL ,
[cash_name] [varchar] (64) COLLATE SQL_Latin1_General_CP1_CI_AS NOT NULL ,
[cash_image] [int] NOT NULL ,
[cash_imageurl] [varchar] (255) COLLATE SQL_Latin1_General_CP1_CI_AS NOT NULL ,
[cash_exchange] [int] NOT NULL ,
[cash_before] [int] NOT NULL ,
[cash_perpost] [int] NOT NULL ,
[cash_postbonus] [int] NOT NULL ,
[cash_perreply] [int] NOT NULL ,
[cash_maxearn] [int] NOT NULL ,
[cash_perchar] [float] NOT NULL ,
[cash_includequotes] [int] NOT NULL ,
[cash_profiledisplay] [int] NOT NULL ,
[cash_donate] [int] NOT NULL ,
[cash_modedit] [int] NOT NULL ,
[cash_allowneg] [int] NOT NULL ,
[cash_postdisplay] [int] NOT NULL ,
[cash_forumlisttype] [int] NOT NULL ,
[cash_forumlist] [varchar] (255) COLLATE SQL_Latin1_General_CP1_CI_AS NOT NULL ,
[cash_log] [int] NOT NULL
) ON [PRIMARY]

## Query 2b
ALTER TABLE [userid].[phpbb_cash] WITH NOCHECK ADD
CONSTRAINT [PK_phpbb_cash] PRIMARY KEY CLUSTERED
(
[cash_id]
) ON [PRIMARY]

## Query 2c
ALTER TABLE [userid].[phpbb_cash] WITH NOCHECK ADD
CONSTRAINT [DF__phpbb_cas__cash___6BE40491] DEFAULT (0) FOR [cash_order],
CONSTRAINT [DF__phpbb_cas__cash___6CD828CA] DEFAULT (1) FOR [cash_enabled],
CONSTRAINT [DF__phpbb_cas__cash___6DCC4D03] DEFAULT ('GP') FOR [cash_name],
CONSTRAINT [DF__phpbb_cas__cash___6EC0713C] DEFAULT (0) FOR [cash_image],
CONSTRAINT [DF_phpbb_cash_cash_imageurl] DEFAULT ('noimage.jpg') FOR [cash_imageurl],
CONSTRAINT [DF__phpbb_cas__cash___6FB49575] DEFAULT (1) FOR [cash_exchange],
CONSTRAINT [DF__phpbb_cas__cash___70A8B9AE] DEFAULT (1) FOR [cash_before],
CONSTRAINT [DF__phpbb_cas__cash___719CDDE7] DEFAULT (25) FOR [cash_perpost],
CONSTRAINT [DF__phpbb_cas__cash___72910220] DEFAULT (2) FOR [cash_postbonus],
CONSTRAINT [DF__phpbb_cas__cash___73852659] DEFAULT (25) FOR [cash_perreply],
CONSTRAINT [DF__phpbb_cas__cash___74794A92] DEFAULT (75) FOR [cash_maxearn],
CONSTRAINT [DF__phpbb_cas__cash___756D6ECB] DEFAULT (0.02) FOR [cash_perchar],
CONSTRAINT [DF__phpbb_cas__cash___76619304] DEFAULT (0) FOR [cash_includequotes],
CONSTRAINT [DF__phpbb_cas__cash___7755B73D] DEFAULT (1) FOR [cash_profiledisplay],
CONSTRAINT [DF__phpbb_cas__cash___7849DB76] DEFAULT (1) FOR [cash_donate],
CONSTRAINT [DF__phpbb_cas__cash___793DFFAF] DEFAULT (0) FOR [cash_modedit],
CONSTRAINT [DF__phpbb_cas__cash___7A3223E8] DEFAULT (0) FOR [cash_allowneg],
CONSTRAINT [DF__phpbb_cas__cash___7B264821] DEFAULT (1) FOR [cash_postdisplay],
CONSTRAINT [DF__phpbb_cas__cash___7C1A6C5A] DEFAULT (1) FOR [cash_forumlisttype],
CONSTRAINT [DF_phpbb_cash_cash_forumlist] DEFAULT ('nadda') FOR [cash_forumlist],
CONSTRAINT [DF__phpbb_cas__cash___7D0E9093] DEFAULT (1) FOR [cash_log]

## Query 3a
CREATE TABLE [userid].[phpbb_cash_exchange] (
[ex_cash_id1] [int] NOT NULL ,
[ex_cash_id2] [int] NOT NULL ,
[ex_cash_enabled] [int] NOT NULL
) ON [PRIMARY]

## Query 3b
ALTER TABLE [userid].[phpbb_cash_exchange] WITH NOCHECK ADD
CONSTRAINT [PK_phpbb_cash_exchange] PRIMARY KEY CLUSTERED
(
[ex_cash_id1],
[ex_cash_id2]
) ON [PRIMARY]

## Query 3c
ALTER TABLE [userid].[phpbb_cash_exchange] WITH NOCHECK ADD
CONSTRAINT [DF__phpbb_cas__ex_ca__7FEAFD3E] DEFAULT (0) FOR [ex_cash_id1],
CONSTRAINT [DF__phpbb_cas__ex_ca__00DF2177] DEFAULT (0) FOR [ex_cash_id2],
CONSTRAINT [DF__phpbb_cas__ex_ca__01D345B0] DEFAULT (0) FOR [ex_cash_enabled]

## Query 4a
CREATE TABLE [userid].[phpbb_cash_log] (
[log_id] [int] IDENTITY (1, 1) NOT NULL ,
[log_time] [int] NOT NULL ,
[log_type] [int] NOT NULL ,
[log_text] [varchar] (255) COLLATE SQL_Latin1_General_CP1_CI_AS NOT NULL
) ON [PRIMARY]

## Query 4b
ALTER TABLE [userid].[phpbb_cash_log] WITH NOCHECK ADD
CONSTRAINT [PK_phpbb_cash_log] PRIMARY KEY CLUSTERED
(
[log_id]
) ON [PRIMARY]

## Query 4c
ALTER TABLE [userid].[phpbb_cash_log] WITH NOCHECK ADD
CONSTRAINT [DF__phpbb_cas__log_t__04AFB25B] DEFAULT (0) FOR [log_time],
CONSTRAINT [DF__phpbb_cas__log_t__05A3D694] DEFAULT (0) FOR [log_type]

## Query 4d
CREATE INDEX [log_time] ON [userid].[phpbb_cash_log]([log_time], [log_type]) ON [PRIMARY]
Two nutz short of a squirrel...

User avatar
Rancisis
Registered User
Posts: 161
Joined: Sun Dec 08, 2002 10:57 am
Location: Belgium

Post by Rancisis » Mon Aug 04, 2003 6:32 pm

deadferret wrote: Ok here it is. I tested this twice on Ms Sql 2000 and it works when you run each query individually. Please test this as well in your database and make sure everything works before using in a production environement.
thx a lot, I made some adjustments and I'm not sure if it will work.
But I think it will, would test it but don't have any mssql...
Anyway, here's the updated installer.

Add all 3 files to your install directory and excecute cm_db_install.php.
:arrow: cm_db_install.php

Code: Select all

<?php
/***************************************************************************
*                             cm_db_install.php
*                            -------------------
*   begin                : Thuesday, July 15, 2003
*   copyright            : (C) 2003 Xore
*   email                : xore@azuriah.com
*
*   $Id: album_db_install.php,v 1.0 2003/02/02 12:41:19 ngoctu Exp $
*
***************************************************************************/

/***************************************************************************
*
*   This program is free software; you can redistribute it and/or modify
*   it under the terms of the GNU General Public License as published by
*   the Free Software Foundation; either version 2 of the License, or
*   (at your option) any later version.
*
***************************************************************************/

define('IN_PHPBB', true);

$phpbb_root_path = './';
include($phpbb_root_path.'extension.inc');
include($phpbb_root_path.'common.'.$phpEx);

$userdata = session_pagestart($user_ip, PAGE_INDEX);
init_userprefs($userdata);

include($phpbb_root_path.'includes/db.'.$phpEx);

?>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html><head>
<meta http-equiv="Content-Type" content="text/html;">
<meta http-equiv="Content-Style-Type" content="text/css">
<style type="text/css">
<!--
font,th,td,p,body { font-family: "Courier New", courier; font-size: 11pt }

a:link,a:active,a:visited { color : #006699; }
a:hover      { text-decoration: underline; color : #DD6900;}

hr   { height: 0px; border: solid #D1D7DC 0px; border-top-width: 1px;}

.maintitle,h1,h2   {font-weight: bold; font-size: 22px; font-family: "Trebuchet MS",Verdana, Arial, Helvetica, sans-serif; text-decoration: none; line-height : 120%; color : #000000;}

.ok {color:green}
-->
</style>
</head>
<body bgcolor="#FFFFFF" text="#000000" link="#006699" vlink="#5584AA">

<table width="100%" border="0" cellspacing="10" cellpadding="0"><tr>
<td align="center" width="100%" valign="middle">
<span class="maintitle">Installing CashMod SQL properties</span>
</td></tr></table><br clear="all" />

<?php
//
// Here we go
//
include($phpbb_root_path.'includes/sql_parse.'.$phpEx);

$available_dbms = array(
   "mysql" => array(
      "SCHEMA" => "cm_mysql",
      "DELIM" => ";",
      "DELIM_BASIC" => ";",
      "COMMENTS" => "remove_remarks"
   ),
   "mysql4" => array(
      "SCHEMA" => "cm_mysql",
      "DELIM" => ";",
      "DELIM_BASIC" => ";",
      "COMMENTS" => "remove_remarks"
   ),
   "mssql" => array(
      "SCHEMA" => "cm_mssql",
      "DELIM" => "GO",
      "DELIM_BASIC" => ";",
      "COMMENTS" => "remove_comments"
   ),
   "mssql-odbc" =>   array(
      "SCHEMA" => "cm_mssql",
      "DELIM" => "GO",
      "DELIM_BASIC" => ";",
      "COMMENTS" => "remove_comments"
   ),
   "postgres" => array(
      "LABEL" => "PostgreSQL 7.x",
      "SCHEMA" => "cm_postgres",
      "DELIM" => ";",
      "DELIM_BASIC" => ";",
      "COMMENTS" => "remove_comments"
   )
);

$dbms_file = $available_dbms[$dbms]['SCHEMA'] . '.sql';

$remove_remarks = $available_dbms[$dbms]['COMMENTS'];;
$delimiter = $available_dbms[$dbms]['DELIM'];
$delimiter_basic = $available_dbms[$dbms]['DELIM_BASIC'];

if ( !($fp = @fopen($dbms_file, 'r')) )
{
   message_die(GENERAL_MESSAGE, "Can't open " . $dbms_file);
}

fclose($fp);

//
// process db schema & basic
//
$sql_query = @fread(@fopen($dbms_file, 'r'), @filesize($dbms_file));
$sql_query = preg_replace('/phpbb_/', $table_prefix, $sql_query);

$sql_query = $remove_remarks($sql_query);
$sql_query = split_sql_file($sql_query, $delimiter);

$sql_count = count($sql_query);

for($i = 0; $i < $sql_count; $i++)
{
   echo "Running :: " . $sql_query[$i];
   flush();

   if ( !($result = $db->sql_query($sql_query[$i])) )
   {
      $errored = true;
      $error = $db->sql_error();
      echo " -> <b>FAILED</b> ---> <u>" . $error['message'] . "</u><br /><br />\n\n";
   }
   else
   {
      echo " -> <b><span class=\"ok\">COMPLETED</span></b><br /><br />\n\n";
   }
}


$message = '';

if ( $errored )
{
   $message .= '<br />Some queries failed :-(';
}
else
{
   $message .= '<br />CashMod SQL quiries generated successfully.';
}

echo "\n<br />\n<b>COMPLETE!</b><br />\n";
echo $message . "<br />";
echo "<br /><b>NOW DELETE THIS FILE</b><br />\n";
echo "</body>";
echo "</html>";

?>
:arrow: cm_mysql.sql

Code: Select all

#
# CashMod v2.0.2 for phpBB 2.0.5 - MySQL schema & basic
# 

INSERT INTO {$table_prefix}config (config_name, config_value) VALUES
	('cash_disable',0),
	('cash_display_after_posts',1),
	('cash_post_message','You earned %s for that post'),
	('cash_disable_spam_num',10),
	('cash_disable_spam_time',24),
	('cash_disable_spam_message','You have exceeded the alloted amount of posts and will not earn anything for your post'),
	('cash_installed','yes'),
	('cash_version','2.0.2'),
	('points_name','Points');

CREATE TABLE {$table_prefix}cash (
	cash_id SMALLINT(6) NOT NULL AUTO_INCREMENT ,
	cash_order SMALLINT(6) NOT NULL ,
	cash_enabled TINYINT(1) DEFAULT '1' NOT NULL ,
	cash_dbfield VARCHAR(64) NOT NULL ,
	cash_name VARCHAR(64) DEFAULT 'GP' NOT NULL ,
	cash_image TINYINT(1) DEFAULT '0' NOT NULL ,
	cash_imageurl VARCHAR(255) NOT NULL ,
	cash_exchange INT(11) DEFAULT '1' NOT NULL ,
	cash_before TINYINT(1) DEFAULT '1' NOT NULL ,
	cash_perpost INT(11) DEFAULT '25' NOT NULL ,
	cash_postbonus INT(11) DEFAULT '2' NOT NULL ,
	cash_perreply INT(11) DEFAULT '25' NOT NULL ,
	cash_maxearn INT(11) DEFAULT '75' NOT NULL ,
	cash_perchar DECIMAL(10,3) DEFAULT '.02' NOT NULL ,
	cash_includequotes TINYINT(1) DEFAULT '0' NOT NULL ,
	cash_profiledisplay TINYINT(1) DEFAULT '1' NOT NULL ,
	cash_donate TINYINT(1) DEFAULT '1' NOT NULL ,
	cash_modedit TINYINT(1) DEFAULT '0' NOT NULL ,
	cash_allowneg TINYINT(1) DEFAULT '0' NOT NULL ,
	cash_postdisplay TINYINT(1) DEFAULT '1' NOT NULL ,
	cash_forumlisttype TINYINT(1) DEFAULT '1' NOT NULL ,
	cash_forumlist VARCHAR(255) NOT NULL ,
	cash_log TINYINT(1) DEFAULT '1' NOT NULL ,
	PRIMARY KEY (cash_id));

CREATE TABLE {$table_prefix}cash_log (
	log_id INT(11) NOT NULL auto_increment,
	log_time INT(11) NOT NULL,
	log_type SMALLINT(6) NOT NULL,
	log_text VARCHAR(255) NOT NULL,
	PRIMARY KEY (log_id) ,
	INDEX (log_time, log_type));

CREATE TABLE {$table_prefix}cash_exchange (
	ex_cash_id1 INT(11) NOT NULL ,
	ex_cash_id2 INT(11) NOT NULL ,
	ex_cash_enabled INT(1) NOT NULL DEFAULT '0',
	PRIMARY KEY (ex_cash_id1,ex_cash_id2));
:arrow: cm_mysql.sql

Code: Select all

#
# CashMod v2.0.2 for phpBB 2.0.5 - MsSQL schema & basic
# 

BEGIN TRANSACTION
GO

ALTER TABLE [phpbb_config] WITH NOCHECK ADD 
	CONSTRAINT [DF_phpbb_phpbb_config_cash_disable] DEFAULT (0) FOR [cash_disable],
	CONSTRAINT [DF_phpbb_phpbb_config_cash_display_after_posts] DEFAULT (1) FOR [cash_display_after_posts],
	CONSTRAINT [DF_phpbb_phpbb_config_cash_post_message] DEFAULT (You earned %s for that post) FOR [cash_post_message],
	CONSTRAINT [DF_phpbb_phpbb_config_cash_disable_spam_num] DEFAULT (10) FOR [cash_disable_spam_num],
	CONSTRAINT [DF_phpbb_phpbb_config_cash_disable_spam_time] DEFAULT (24) FOR [cash_disable_spam_time],
	CONSTRAINT [DF_phpbb_phpbb_cash_disable_spam_message] DEFAULT (You have exceeded the alloted amount of posts and will not earn anything for your post) FOR [cash_disable_spam_message],
	CONSTRAINT [DF_phpbb_phpbb_cash_installed] DEFAULT (yes) FOR [cash_installed],
	CONSTRAINT [DF_phpbb_phpbb_cash_version] DEFAULT (2.0.2) FOR [cash_version],
	CONSTRAINT [DF_phpbb_phpbb_points_name] DEFAULT (Points) FOR [points_name]
GO

CREATE TABLE [userid].[phpbb_cash] (
[cash_id] [int] IDENTITY (1, 1) NOT NULL ,
[cash_order] [int] NOT NULL ,
[cash_enabled] [int] NOT NULL ,
[cash_dbfield] [varchar] (64) COLLATE SQL_Latin1_General_CP1_CI_AS NOT NULL ,
[cash_name] [varchar] (64) COLLATE SQL_Latin1_General_CP1_CI_AS NOT NULL ,
[cash_image] [int] NOT NULL ,
[cash_imageurl] [varchar] (255) COLLATE SQL_Latin1_General_CP1_CI_AS NOT NULL ,
[cash_exchange] [int] NOT NULL ,
[cash_before] [int] NOT NULL ,
[cash_perpost] [int] NOT NULL ,
[cash_postbonus] [int] NOT NULL ,
[cash_perreply] [int] NOT NULL ,
[cash_maxearn] [int] NOT NULL ,
[cash_perchar] [float] NOT NULL ,
[cash_includequotes] [int] NOT NULL ,
[cash_profiledisplay] [int] NOT NULL ,
[cash_donate] [int] NOT NULL ,
[cash_modedit] [int] NOT NULL ,
[cash_allowneg] [int] NOT NULL ,
[cash_postdisplay] [int] NOT NULL ,
[cash_forumlisttype] [int] NOT NULL ,
[cash_forumlist] [varchar] (255) COLLATE SQL_Latin1_General_CP1_CI_AS NOT NULL ,
[cash_log] [int] NOT NULL
) ON [PRIMARY] 
GO

ALTER TABLE [userid].[phpbb_cash] WITH NOCHECK ADD
CONSTRAINT [PK_phpbb_cash] PRIMARY KEY CLUSTERED
(
[cash_id]
) ON [PRIMARY] 
GO

ALTER TABLE [userid].[phpbb_cash] WITH NOCHECK ADD
CONSTRAINT [DF__phpbb_cas__cash___6BE40491] DEFAULT (0) FOR [cash_order],
CONSTRAINT [DF__phpbb_cas__cash___6CD828CA] DEFAULT (1) FOR [cash_enabled],
CONSTRAINT [DF__phpbb_cas__cash___6DCC4D03] DEFAULT ('GP') FOR [cash_name],
CONSTRAINT [DF__phpbb_cas__cash___6EC0713C] DEFAULT (0) FOR [cash_image],
CONSTRAINT [DF_phpbb_cash_cash_imageurl] DEFAULT ('noimage.jpg') FOR [cash_imageurl],
CONSTRAINT [DF__phpbb_cas__cash___6FB49575] DEFAULT (1) FOR [cash_exchange],
CONSTRAINT [DF__phpbb_cas__cash___70A8B9AE] DEFAULT (1) FOR [cash_before],
CONSTRAINT [DF__phpbb_cas__cash___719CDDE7] DEFAULT (25) FOR [cash_perpost],
CONSTRAINT [DF__phpbb_cas__cash___72910220] DEFAULT (2) FOR [cash_postbonus],
CONSTRAINT [DF__phpbb_cas__cash___73852659] DEFAULT (25) FOR [cash_perreply],
CONSTRAINT [DF__phpbb_cas__cash___74794A92] DEFAULT (75) FOR [cash_maxearn],
CONSTRAINT [DF__phpbb_cas__cash___756D6ECB] DEFAULT (0.02) FOR [cash_perchar],
CONSTRAINT [DF__phpbb_cas__cash___76619304] DEFAULT (0) FOR [cash_includequotes],
CONSTRAINT [DF__phpbb_cas__cash___7755B73D] DEFAULT (1) FOR [cash_profiledisplay],
CONSTRAINT [DF__phpbb_cas__cash___7849DB76] DEFAULT (1) FOR [cash_donate],
CONSTRAINT [DF__phpbb_cas__cash___793DFFAF] DEFAULT (0) FOR [cash_modedit],
CONSTRAINT [DF__phpbb_cas__cash___7A3223E8] DEFAULT (0) FOR [cash_allowneg],
CONSTRAINT [DF__phpbb_cas__cash___7B264821] DEFAULT (1) FOR [cash_postdisplay],
CONSTRAINT [DF__phpbb_cas__cash___7C1A6C5A] DEFAULT (1) FOR [cash_forumlisttype],
CONSTRAINT [DF_phpbb_cash_cash_forumlist] DEFAULT ('nadda') FOR [cash_forumlist],
CONSTRAINT [DF__phpbb_cas__cash___7D0E9093] DEFAULT (1) FOR [cash_log] 
GO

CREATE TABLE [userid].[phpbb_cash_exchange] (
[ex_cash_id1] [int] NOT NULL ,
[ex_cash_id2] [int] NOT NULL ,
[ex_cash_enabled] [int] NOT NULL
) ON [PRIMARY] 
GO

ALTER TABLE [userid].[phpbb_cash_exchange] WITH NOCHECK ADD
CONSTRAINT [PK_phpbb_cash_exchange] PRIMARY KEY CLUSTERED
(
[ex_cash_id1],
[ex_cash_id2]
) ON [PRIMARY] 
GO

ALTER TABLE [userid].[phpbb_cash_exchange] WITH NOCHECK ADD
CONSTRAINT [DF__phpbb_cas__ex_ca__7FEAFD3E] DEFAULT (0) FOR [ex_cash_id1],
CONSTRAINT [DF__phpbb_cas__ex_ca__00DF2177] DEFAULT (0) FOR [ex_cash_id2],
CONSTRAINT [DF__phpbb_cas__ex_ca__01D345B0] DEFAULT (0) FOR [ex_cash_enabled] 
GO

CREATE TABLE [userid].[phpbb_cash_log] (
[log_id] [int] IDENTITY (1, 1) NOT NULL ,
[log_time] [int] NOT NULL ,
[log_type] [int] NOT NULL ,
[log_text] [varchar] (255) COLLATE SQL_Latin1_General_CP1_CI_AS NOT NULL
) ON [PRIMARY] 
GO

ALTER TABLE [userid].[phpbb_cash_log] WITH NOCHECK ADD
CONSTRAINT [PK_phpbb_cash_log] PRIMARY KEY CLUSTERED
(
[log_id]
) ON [PRIMARY] 
GO

ALTER TABLE [userid].[phpbb_cash_log] WITH NOCHECK ADD
CONSTRAINT [DF__phpbb_cas__log_t__04AFB25B] DEFAULT (0) FOR [log_time],
CONSTRAINT [DF__phpbb_cas__log_t__05A3D694] DEFAULT (0) FOR [log_type] 
GO

CREATE INDEX [log_time] ON [userid].[phpbb_cash_log]([log_time], [log_type]) ON [PRIMARY] 
GO

COMMIT
GO

User avatar
Xore
Former Team Member
Posts: 2594
Joined: Wed Apr 16, 2003 7:42 pm
Location: the wastelands between insomnia and clairvoyance
Contact:

Post by Xore » Mon Aug 04, 2003 7:17 pm

teste87 wrote: Hum, I'm thinking something like Index Page, like Show Points MOD does ...


So, i've got kind of an idea as to what Cash Mod is going to contain, and what it isn't.

Some things i want to leave out, because it's not something that everybody's going to want or even use, and other things because it just doesn't fit in properly with what my concept of the mod should be.

With that said, that doesn't necessarily mean that Cash Mod will be limited to what i program into it. I just don't want the original mod itself to become confusing and overbloated with features, as i'm finding it's becoming already.

What i'll probably do is release separated 'mini' mods that plug into Cash Mod, to enhance it in different ways, depending on what people seem to want.

Further along those lines, i welcome mod authors to do similarly, to create their own unique additions to the cash mod.

Some current ideas are:
  • Show points on index page
  • Randomize points gain
  • Games
  • Non-integer Cash values
  • Officially validated releases of shop/lottery/bank/rpg mods :mrgreen:
  • Stock exchange / currency updater, for real currency exchange values / stock exchange.
  • Active users rewards
If you are a mod author and reading this, please consider creating one or more of these. The admiring masses will love you for it :-)
Last edited by Xore on Tue Aug 19, 2003 12:25 am, edited 2 times in total.
Camels in the Mist
<noise type="random" source="camel" />
Cash Mod

User avatar
Xore
Former Team Member
Posts: 2594
Joined: Wed Apr 16, 2003 7:42 pm
Location: the wastelands between insomnia and clairvoyance
Contact:

Post by Xore » Mon Aug 04, 2003 9:10 pm

deadferret wrote:
Rancisis wrote:thx a lot, I made some adjustments and I'm not sure if it will work.
But I think it will, would test it but don't have any mssql...


I will test it later tonight. I have been updating my site with all of the old mods since I trasnferred from mysql to mssql.


Hi, i appreciate the inroads you guys are making on the mssql issue.

Rancisis, i've decided that unless it proves continually bork, i'm going to try with a 1-file sql install solution.
[note, if this doesn't work out, then, with your permission, i'll bundle your installer with the next release]

deadferret, i was wondering if you could try this out. It contains some (not all) of the db updates that will be existant with Cash Mod 2.1.0, however it should still be 2.0.x back compatible. I'm almost certain there will be execution errors with this, however, if you could let me know what i'm doing wrong, i'd really appreciate it. thanks :-)


sql_install.php

Code: Select all

<?php 
/*************************************************************************** 
 *                              sql_install.php 
 *                            -------------------
 *   begin                : Thursday, Apr 17, 2003
 *   copyright            : (C) 2003 Xore
 *   email                : xore@azuriah.com
 *
 *   $Id: sql_install.php,v 1.1.0.0 2003/08/04 14:12:03 Xore $
 *
 *
 ***************************************************************************/

/***************************************************************************
 *
 *   This program is free software; you can redistribute it and/or modify
 *   it under the terms of the GNU General Public License as published by
 *   the Free Software Foundation; either version 2 of the License, or
 *   (at your option) any later version.
 *
 ***************************************************************************/

define('IN_PHPBB', true); 
$phpbb_root_path = './'; 
include($phpbb_root_path . 'extension.inc'); 
include($phpbb_root_path . 'common.'.$phpEx); 

// 
// Start session management 
// 
$userdata = session_pagestart($user_ip, PAGE_INDEX); 
init_userprefs($userdata); 
// 
// End session management 
// 

if( !$userdata['session_logged_in'] ) 
{ 
	redirect(append_sid("login.$phpEx?redirect=mysql_install.$phpEx", true));
} 

if( $userdata['user_level'] != ADMIN ) 
{ 
   message_die(GENERAL_MESSAGE, 'You are not authorised to access this page'); 
} 

$page_title = 'Installing Cash Mod v 2.0.0 Tables, Updating Configuration settings'; 
include($phpbb_root_path . 'includes/page_header.'.$phpEx); 

print<<<DELIM
<table width="100%" cellspacing="1" cellpadding="2" border="0" class="forumline">
  <tr>
    <th class="thHead">Updating the database</th>
  </tr>
  <tr>
    <td>
      <span class="genmed">
        <ul type="circle">

DELIM;

$current_time = time();

switch ( SQL_LAYER )
{
	case 'msaccess':
	break;
	case 'postgresql':
	break;
	case 'mssql':
	case 'mssql-odbc':
		$sql = array(
		   "INSERT INTO {$table_prefix}config (config_name, config_value) VALUES ('cash_disable',0);",
		   "INSERT INTO {$table_prefix}config (config_name, config_value) VALUES ('cash_display_after_posts',1);",
		   "INSERT INTO {$table_prefix}config (config_name, config_value) VALUES ('cash_post_message','You earned %s for that post');",
		   "INSERT INTO {$table_prefix}config (config_name, config_value) VALUES ('cash_disable_spam_num',10);",
		   "INSERT INTO {$table_prefix}config (config_name, config_value) VALUES ('cash_disable_spam_time',24);",
		   "INSERT INTO {$table_prefix}config (config_name, config_value) VALUES ('cash_disable_spam_message','You have exceeded the alloted amount of posts and will not earn anything for your post');",
		   "INSERT INTO {$table_prefix}config (config_name, config_value) VALUES ('cash_installed','yes');",
		   "INSERT INTO {$table_prefix}config (config_name, config_value) VALUES ('cash_version','2.0.2');",
		   "INSERT INTO {$table_prefix}config (config_name, config_value) VALUES ('points_name','Points');",

		   "CREATE TABLE [userid].[{$table_prefix}cash] ( 
			[cash_id] [int] IDENTITY (1, 1) NOT NULL ,
			[cash_order] [int] NOT NULL ,
			[cash_enabled] [int] NOT NULL ,
			[cash_dbfield] [varchar] (64) COLLATE SQL_Latin1_General_CP1_CI_AS NOT NULL ,
			[cash_name] [varchar] (64) COLLATE SQL_Latin1_General_CP1_CI_AS NOT NULL ,
			[cash_image] [int] NOT NULL ,
			[cash_imageurl] [varchar] (255) COLLATE SQL_Latin1_General_CP1_CI_AS NOT NULL ,
			[cash_exchange] [int] NOT NULL ,
			[cash_before] [int] NOT NULL ,
			[cash_perpost] [int] NOT NULL ,
			[cash_postbonus] [int] NOT NULL ,
			[cash_perreply] [int] NOT NULL ,
			[cash_maxearn] [int] NOT NULL ,
			[cash_perchar] [float] NOT NULL ,
			[cash_includequotes] [int] NOT NULL ,
			[cash_profiledisplay] [int] NOT NULL ,
			[cash_donate] [int] NOT NULL ,
			[cash_modedit] [int] NOT NULL ,
			[cash_allowneg] [int] NOT NULL ,
			[cash_postdisplay] [int] NOT NULL ,
			[cash_forumlisttype] [int] NOT NULL ,
			[cash_forumlist] [varchar] (255) COLLATE SQL_Latin1_General_CP1_CI_AS NOT NULL ,
			[cash_log] [int] NOT NULL
			) ON [PRIMARY]",

		   "ALTER TABLE [userid].[{$table_prefix}cash] WITH NOCHECK ADD 
			CONSTRAINT [PK_{$table_prefix}cash] PRIMARY KEY CLUSTERED 
			( 
			[cash_id] 
			) ON [PRIMARY]",

		   "ALTER TABLE [userid].[{$table_prefix}cash] WITH NOCHECK ADD 
			CONSTRAINT [DF_{$table_prefix}cash_order]          DEFAULT (0) FOR [cash_order], 
			CONSTRAINT [DF_{$table_prefix}cash_enabled]        DEFAULT (1) FOR [cash_enabled], 
			CONSTRAINT [DF_{$table_prefix}cash_name]           DEFAULT ('GP') FOR [cash_name], 
			CONSTRAINT [DF_{$table_prefix}cash_image]          DEFAULT (0) FOR [cash_image], 
			CONSTRAINT [DF_{$table_prefix}cash_imageurl]       DEFAULT ('noimage.jpg') FOR [cash_imageurl], 
			CONSTRAINT [DF_{$table_prefix}cash_exchange]       DEFAULT (1) FOR [cash_exchange], 
			CONSTRAINT [DF_{$table_prefix}cash_before]         DEFAULT (1) FOR [cash_before], 
			CONSTRAINT [DF_{$table_prefix}cash_perpost]        DEFAULT (25) FOR [cash_perpost], 
			CONSTRAINT [DF_{$table_prefix}cash_postbonus]      DEFAULT (2) FOR [cash_postbonus], 
			CONSTRAINT [DF_{$table_prefix}cash_perreply]       DEFAULT (25) FOR [cash_perreply], 
			CONSTRAINT [DF_{$table_prefix}cash_maxearn]        DEFAULT (75) FOR [cash_maxearn], 
			CONSTRAINT [DF_{$table_prefix}cash_perchar]        DEFAULT (0.02) FOR [cash_perchar], 
			CONSTRAINT [DF_{$table_prefix}cash_includequotes]  DEFAULT (0) FOR [cash_includequotes], 
			CONSTRAINT [DF_{$table_prefix}cash_profiledisplay] DEFAULT (1) FOR [cash_profiledisplay], 
			CONSTRAINT [DF_{$table_prefix}cash_donate]         DEFAULT (1) FOR [cash_donate], 
			CONSTRAINT [DF_{$table_prefix}cash_modedit]        DEFAULT (0) FOR [cash_modedit], 
			CONSTRAINT [DF_{$table_prefix}cash_allowneg]       DEFAULT (0) FOR [cash_allowneg], 
			CONSTRAINT [DF_{$table_prefix}cash_postdisplay]    DEFAULT (1) FOR [cash_postdisplay], 
			CONSTRAINT [DF_{$table_prefix}cash_forumlisttype]  DEFAULT (1) FOR [cash_forumlisttype], 
			CONSTRAINT [DF_{$table_prefix}cash_forumlist]      DEFAULT ('') FOR [cash_forumlist], 
			CONSTRAINT [DF_{$table_prefix}cash_log]            DEFAULT (1) FOR [cash_log]",

		   "CREATE TABLE [userid].[{$table_prefix}cash_exchange] ( 
			[ex_cash_id1] [int] NOT NULL , 
			[ex_cash_id2] [int] NOT NULL , 
			[ex_cash_enabled] [int] NOT NULL 
			) ON [PRIMARY]",

		   "ALTER TABLE [userid].[{$table_prefix}cash_exchange] WITH NOCHECK ADD 
			CONSTRAINT [PK_{$table_prefix}cash_exchange] PRIMARY KEY CLUSTERED 
			( 
			[ex_cash_id1], 
			[ex_cash_id2] 
			) ON [PRIMARY]",

		   "ALTER TABLE [userid].[{$table_prefix}cash_exchange] WITH NOCHECK ADD 
			CONSTRAINT [DF_{$table_prefix}cash_enabled] DEFAULT (1) FOR [ex_cash_enabled]",

		   "CREATE TABLE [userid].[{$table_prefix}cash_log] ( 
			[log_id] [int] IDENTITY (1, 1) NOT NULL , 
			[log_time] [int] NOT NULL , 
			[log_type] [int] NOT NULL , 
			[log_text] [varchar] (255) COLLATE SQL_Latin1_General_CP1_CI_AS NOT NULL 
			) ON [PRIMARY]",


		   "ALTER TABLE [userid].[{$table_prefix}cash_log] WITH NOCHECK ADD 
			CONSTRAINT [PK_{$table_prefix}cash_log] PRIMARY KEY CLUSTERED 
			( 
			[log_id] 
			) ON [PRIMARY]",

		   "ALTER TABLE [userid].[{$table_prefix}cash_log] WITH NOCHECK ADD 
			CONSTRAINT [DF_{$table_prefix}log_time] DEFAULT (0) FOR [log_time], 
			CONSTRAINT [DF_{$table_prefix}log_type] DEFAULT (0) FOR [log_type]",

		   "CREATE INDEX [log_time] ON [userid].[{$table_prefix}cash_log]([log_time], [log_type]) ON [PRIMARY]",

		   "CREATE TABLE [userid].[{$table_prefix}cash_groups] ( 
			[group_id] [int] IDENTITY (3, 1) NOT NULL ,
			[group_type] [int] IDENTITY (3, 1) NOT NULL ,
			[group_cashid] [int] IDENTITY (3, 1) NOT NULL ,
			[group_order] [varchar] (64) COLLATE SQL_Latin1_General_CP1_CI_AS NOT NULL ,
			[cash_status] [varchar] (64) COLLATE SQL_Latin1_General_CP1_CI_AS NOT NULL ,
			[cash_perpost] [int] NOT NULL ,
			[cash_postbonus] [int] NOT NULL ,
			[cash_perreply] [int] NOT NULL ,
			[cash_perchar] [float] NOT NULL ,
			[cash_maxearn] [int] NOT NULL ,
			) ON [PRIMARY]",

		   "ALTER TABLE [userid].[{$table_prefix}cash_groups] WITH NOCHECK ADD 
			CONSTRAINT [PK_{$table_prefix}cash_groups] PRIMARY KEY CLUSTERED 
			( 
			[group_id],[group_type],[group_cashid]
			) ON [PRIMARY]",

		   "ALTER TABLE [userid].[{$table_prefix}cash_groups] WITH NOCHECK ADD 
			CONSTRAINT [DF_{$table_prefix}cash_group_order]      DEFAULT (0) FOR [group_order], 
			CONSTRAINT [DF_{$table_prefix}cash_cash_status]      DEFAULT (0) FOR [cash_status], 
			CONSTRAINT [DF_{$table_prefix}cash_groups_perpost]   DEFAULT (25) FOR [cash_perpost], 
			CONSTRAINT [DF_{$table_prefix}cash_groups_postbonus] DEFAULT (2) FOR [cash_postbonus], 
			CONSTRAINT [DF_{$table_prefix}cash_groups_perreply]  DEFAULT (25) FOR [cash_perreply], 
			CONSTRAINT [DF_{$table_prefix}cash_groups_maxearn]   DEFAULT (75) FOR [cash_maxearn], 
			CONSTRAINT [DF_{$table_prefix}cash_groups_perchar]   DEFAULT (0.02) FOR [cash_perchar]",
		);
	break;
	case 'mysql':
	case 'mysql4':
	default:
		$sql = array(
		   "INSERT INTO {$table_prefix}config (config_name, config_value) VALUES
			('cash_disable',0),
			('cash_display_after_posts',1),
			('cash_post_message','You earned %s for that post'),
			('cash_disable_spam_num',10),
			('cash_disable_spam_time',24),
			('cash_disable_spam_message','You have exceeded the alloted amount of posts and will not earn anything for your post'),
			('cash_installed','yes'),
			('cash_version','2.0.0'),
			('points_name','Points')",

		   "CREATE TABLE {$table_prefix}cash (
			cash_id SMALLINT(6) NOT NULL AUTO_INCREMENT ,
			cash_order SMALLINT(6) NOT NULL ,
			cash_enabled TINYINT(1) DEFAULT '1' NOT NULL ,
			cash_dbfield VARCHAR(64) NOT NULL ,
			cash_name VARCHAR(64) DEFAULT 'GP' NOT NULL ,
			cash_image TINYINT(1) DEFAULT '0' NOT NULL ,
			cash_imageurl VARCHAR(255) NOT NULL ,
			cash_exchange INT(11) DEFAULT '1' NOT NULL ,
			cash_before TINYINT(1) DEFAULT '1' NOT NULL ,
			cash_perpost INT(11) DEFAULT '25' NOT NULL ,
			cash_postbonus INT(11) DEFAULT '2' NOT NULL ,
			cash_perreply INT(11) DEFAULT '25' NOT NULL ,
			cash_maxearn INT(11) DEFAULT '75' NOT NULL ,
			cash_perchar DECIMAL(10,3) DEFAULT '.02' NOT NULL ,
			cash_jiggle INT(11) DEFAULT '0' NOT NULL ,
			cash_allowance TINYINT(1) DEFAULT '1' NOT NULL ,
			cash_allowancetime TINYINT(2) DEFAULT '2' NOT NULL ,
			cash_includequotes TINYINT(1) DEFAULT '0' NOT NULL ,
			cash_profiledisplay TINYINT(1) DEFAULT '1' NOT NULL ,
			cash_donate TINYINT(1) DEFAULT '1' NOT NULL ,
			cash_modedit TINYINT(1) DEFAULT '0' NOT NULL ,
			cash_allowneg TINYINT(1) DEFAULT '0' NOT NULL ,
			cash_postdisplay TINYINT(1) DEFAULT '1' NOT NULL ,
			cash_forumlisttype TINYINT(1) DEFAULT '1' NOT NULL ,
			cash_forumlist VARCHAR(255) NOT NULL ,
			cash_log TINYINT(1) DEFAULT '1' NOT NULL ,
			PRIMARY KEY (cash_id)
			);",

		   "CREATE TABLE {$table_prefix}cash_groups (
			group_id MEDIUMINT(6) NOT NULL ,
			group_type TINYINT(2) NOT NULL ,
			group_cashid SMALLINT(6) NOT NULL ,
			group_order SMALLINT(6) DEFAULT '0' NOT NULL ,
			cash_status TINYINT(2) DEFAULT '1' NOT NULL ,
			cash_perpost INT(11) DEFAULT '25' NOT NULL ,
			cash_postbonus INT(11) DEFAULT '2' NOT NULL ,
			cash_perreply INT(11) DEFAULT '25' NOT NULL ,
			cash_perchar DECIMAL(10,3) DEFAULT '.02' NOT NULL ,
			cash_maxearn INT(11) DEFAULT '75' NOT NULL ,
			cash_jiggle INT(11) DEFAULT '0' NOT NULL ,
			cash_allowance TINYINT(1) DEFAULT '1' NOT NULL ,
			cash_allowancetime TINYINT(2) DEFAULT '2' NOT NULL ,
			PRIMARY KEY (group_id, group_type, group_cashid)
			);",

		   "CREATE TABLE {$table_prefix}cash_log (
			log_id INT(11) NOT NULL auto_increment,
			log_time INT(11) NOT NULL,
			log_type SMALLINT(6) NOT NULL,
			log_text VARCHAR(255) NOT NULL,
			PRIMARY KEY (log_id) ,
			INDEX (log_time, log_type) 
			);",

		   "CREATE TABLE {$table_prefix}cash_exchange (
			ex_cash_id1 INT(11) NOT NULL ,
			ex_cash_id2 INT(11) NOT NULL ,
			ex_cash_enabled INT(1) NOT NULL DEFAULT '0',
			PRIMARY KEY (ex_cash_id1,ex_cash_id2) 
			);"

		);
	break;
}

foreach ( $sql AS $query ) 
{ 
   if ( !($result = $db->sql_query($query)) )
   { 
      $error = $db->sql_error();
      print('<li>' . nl2br($query) . '<br /> +++ <font color="#FF0000"><b>Error:</b></font> ' . $error['message'] . '</li><br />');
   } 
   else 
   { 
      print('<li>' . nl2br($query) . '<br /> +++ <font color="#00AA00"><b>Successfull</b></font></li><br />');
   } 
}

$forum_url = append_sid("index.$phpEx");
$phpbb_url = "http://www.phpbb.com/phpBB/viewtopic.php?t=94055";

print<<<DELIM
        </ul>
      </span>
    </td>
  </tr>
  <tr>
    <td class="catBottom" height="28">&</td>
  </tr>
  <tr>
    <td class="catBottom" colspan="2" align="center">Finished</td>
  </tr>
</table>

<br />
<br />

<table width="100%" cellspacing="1" cellpadding="2" border="0" class="forumline">
  <tr>
    <th class="thHead">SQL Installation complete</th>
  </tr>
  <tr>
    <td>
      <span class="genmed">Please delete this file (mysql_install.php).<br />
      If you have any problems, please visit <a href="{$phpbb_url}" target="_new">phpbb.com (CashMod v 2.0.0 Support Thread)</a> and ask for help.</span>
    </td>
  </tr>
  <tr>
    <td class="catBottom" height="28" align="center">
      <span class="genmed"><a href="{$forum_url}">Click Here to return to your forum.</a>
      </span>
    </td>
  </tr>
</table>

DELIM;

include($phpbb_root_path . 'includes/page_tail.'.$phpEx); 

?>
Camels in the Mist
<noise type="random" source="camel" />
Cash Mod

deadferret
Registered User
Posts: 36
Joined: Wed Dec 11, 2002 9:45 pm

Post by deadferret » Tue Aug 05, 2003 9:13 pm

Xore wrote: it's a block print function. i've never experienced problems with it before.

if you keep getting errors, replace

...

Hope that helps :-)


Modified it.

Here is the result (I ran in mt test forum 2.0.6) that I don't understand how to fix:
CREATE TABLE [userid].[phpbb_cash_groups] (
[group_id] [int] IDENTITY (3, 1) NOT NULL ,
[group_type] [int] IDENTITY (3, 1) NOT NULL ,
[group_cashid] [int] IDENTITY (3, 1) NOT NULL ,
[group_order] [varchar] (64) COLLATE SQL_Latin1_General_CP1_CI_AS NOT NULL ,
[cash_status] [varchar] (64) COLLATE SQL_Latin1_General_CP1_CI_AS NOT NULL ,
[cash_perpost] [int] NOT NULL ,
[cash_postbonus] [int] NOT NULL ,
[cash_perreply] [int] NOT NULL ,
[cash_perchar] [float] NOT NULL ,
[cash_maxearn] [int] NOT NULL ,
) ON [PRIMARY]

Code: Select all

+++ Error: Multiple identity columns specified for table 'phpbb_cash_groups'. Only one identity column per table is allowed.


Do you need all of those IDENTITY fields to be an identity?
Two nutz short of a squirrel...

deadferret
Registered User
Posts: 36
Joined: Wed Dec 11, 2002 9:45 pm

Post by deadferret » Tue Aug 05, 2003 9:25 pm

Here is the final modified script that I used to get a Successful Mssql install. Please note the changes in the switch (since I do not use odbc) and the removal of the two IDENTITY pieces.

Code: Select all

<?php 
/*************************************************************************** 
*                              sql_install.php 
*                            ------------------- 
*   begin                : Thursday, Apr 17, 2003 
*   copyright            : (C) 2003 Xore 
*   email                : xore@azuriah.com 
* 
*   $Id: sql_install.php,v 1.1.0.0 2003/08/04 14:12:03 Xore $ 
* 
* 
***************************************************************************/ 

/*************************************************************************** 
* 
*   This program is free software; you can redistribute it and/or modify 
*   it under the terms of the GNU General Public License as published by 
*   the Free Software Foundation; either version 2 of the License, or 
*   (at your option) any later version. 
* 
***************************************************************************/ 

define('IN_PHPBB', true); 
$phpbb_root_path = './'; 
include($phpbb_root_path . 'extension.inc'); 
include($phpbb_root_path . 'common.'.$phpEx); 

// 
// Start session management 
// 
$userdata = session_pagestart($user_ip, PAGE_INDEX); 
init_userprefs($userdata); 
// 
// End session management 
// 

if( !$userdata['session_logged_in'] ) 
{ 
   redirect(append_sid("login.$phpEx?redirect=sql_install.$phpEx", true)); 
} 

if( $userdata['user_level'] != ADMIN ) 
{ 
   message_die(GENERAL_MESSAGE, 'You are not authorised to access this page'); 
} 

$page_title = 'Installing Cash Mod v 2.0.0 Tables, Updating Configuration settings'; 
include($phpbb_root_path . 'includes/page_header.'.$phpEx); 

?> 
<table width="100%" cellspacing="1" cellpadding="2" border="0" class="forumline"> 
  <tr> 
    <th class="thHead">Updating the database</th> 
  </tr> 
  <tr> 
    <td> 
      <span class="genmed"> 
        <ul type="circle"> 

<?php 

$current_time = time(); 

switch ( SQL_LAYER ) 
{ 
   case 'msaccess': 
   break; 
   case 'postgresql': 
   break; 
   case 'mssql-odbc':  
   case 'mssql':
      $sql = array( 
         "INSERT INTO {$table_prefix}config (config_name, config_value) VALUES ('cash_disable',0);", 
         "INSERT INTO {$table_prefix}config (config_name, config_value) VALUES ('cash_display_after_posts',1);", 
         "INSERT INTO {$table_prefix}config (config_name, config_value) VALUES ('cash_post_message','You earned %s for that post');", 
         "INSERT INTO {$table_prefix}config (config_name, config_value) VALUES ('cash_disable_spam_num',10);", 
         "INSERT INTO {$table_prefix}config (config_name, config_value) VALUES ('cash_disable_spam_time',24);", 
         "INSERT INTO {$table_prefix}config (config_name, config_value) VALUES ('cash_disable_spam_message','You have exceeded the alloted amount of posts and will not earn anything for your post');", 
         "INSERT INTO {$table_prefix}config (config_name, config_value) VALUES ('cash_installed','yes');", 
         "INSERT INTO {$table_prefix}config (config_name, config_value) VALUES ('cash_version','2.0.2');", 
         "INSERT INTO {$table_prefix}config (config_name, config_value) VALUES ('points_name','Points');", 

         "CREATE TABLE [userid].[{$table_prefix}cash] ( 
         [cash_id] [int] IDENTITY (1, 1) NOT NULL , 
         [cash_order] [int] NOT NULL , 
         [cash_enabled] [int] NOT NULL , 
         [cash_dbfield] [varchar] (64) COLLATE SQL_Latin1_General_CP1_CI_AS NOT NULL , 
         [cash_name] [varchar] (64) COLLATE SQL_Latin1_General_CP1_CI_AS NOT NULL , 
         [cash_image] [int] NOT NULL , 
         [cash_imageurl] [varchar] (255) COLLATE SQL_Latin1_General_CP1_CI_AS NOT NULL , 
         [cash_exchange] [int] NOT NULL , 
         [cash_before] [int] NOT NULL , 
         [cash_perpost] [int] NOT NULL , 
         [cash_postbonus] [int] NOT NULL , 
         [cash_perreply] [int] NOT NULL , 
         [cash_maxearn] [int] NOT NULL , 
         [cash_perchar] [float] NOT NULL , 
         [cash_includequotes] [int] NOT NULL , 
         [cash_profiledisplay] [int] NOT NULL , 
         [cash_donate] [int] NOT NULL , 
         [cash_modedit] [int] NOT NULL , 
         [cash_allowneg] [int] NOT NULL , 
         [cash_postdisplay] [int] NOT NULL , 
         [cash_forumlisttype] [int] NOT NULL , 
         [cash_forumlist] [varchar] (255) COLLATE SQL_Latin1_General_CP1_CI_AS NOT NULL , 
         [cash_log] [int] NOT NULL 
         ) ON [PRIMARY]", 

         "ALTER TABLE [userid].[{$table_prefix}cash] WITH NOCHECK ADD 
         CONSTRAINT [PK_{$table_prefix}cash] PRIMARY KEY CLUSTERED 
         ( 
         [cash_id] 
         ) ON [PRIMARY]", 

         "ALTER TABLE [userid].[{$table_prefix}cash] WITH NOCHECK ADD 
         CONSTRAINT [DF_{$table_prefix}cash_order]          DEFAULT (0) FOR [cash_order], 
         CONSTRAINT [DF_{$table_prefix}cash_enabled]        DEFAULT (1) FOR [cash_enabled], 
         CONSTRAINT [DF_{$table_prefix}cash_name]           DEFAULT ('GP') FOR [cash_name], 
         CONSTRAINT [DF_{$table_prefix}cash_image]          DEFAULT (0) FOR [cash_image], 
         CONSTRAINT [DF_{$table_prefix}cash_imageurl]       DEFAULT ('noimage.jpg') FOR [cash_imageurl], 
         CONSTRAINT [DF_{$table_prefix}cash_exchange]       DEFAULT (1) FOR [cash_exchange], 
         CONSTRAINT [DF_{$table_prefix}cash_before]         DEFAULT (1) FOR [cash_before], 
         CONSTRAINT [DF_{$table_prefix}cash_perpost]        DEFAULT (25) FOR [cash_perpost], 
         CONSTRAINT [DF_{$table_prefix}cash_postbonus]      DEFAULT (2) FOR [cash_postbonus], 
         CONSTRAINT [DF_{$table_prefix}cash_perreply]       DEFAULT (25) FOR [cash_perreply], 
         CONSTRAINT [DF_{$table_prefix}cash_maxearn]        DEFAULT (75) FOR [cash_maxearn], 
         CONSTRAINT [DF_{$table_prefix}cash_perchar]        DEFAULT (0.02) FOR [cash_perchar], 
         CONSTRAINT [DF_{$table_prefix}cash_includequotes]  DEFAULT (0) FOR [cash_includequotes], 
         CONSTRAINT [DF_{$table_prefix}cash_profiledisplay] DEFAULT (1) FOR [cash_profiledisplay], 
         CONSTRAINT [DF_{$table_prefix}cash_donate]         DEFAULT (1) FOR [cash_donate], 
         CONSTRAINT [DF_{$table_prefix}cash_modedit]        DEFAULT (0) FOR [cash_modedit], 
         CONSTRAINT [DF_{$table_prefix}cash_allowneg]       DEFAULT (0) FOR [cash_allowneg], 
         CONSTRAINT [DF_{$table_prefix}cash_postdisplay]    DEFAULT (1) FOR [cash_postdisplay], 
         CONSTRAINT [DF_{$table_prefix}cash_forumlisttype]  DEFAULT (1) FOR [cash_forumlisttype], 
         CONSTRAINT [DF_{$table_prefix}cash_forumlist]      DEFAULT ('nothing') FOR [cash_forumlist], 
         CONSTRAINT [DF_{$table_prefix}cash_log]            DEFAULT (1) FOR [cash_log]", 

         "CREATE TABLE [userid].[{$table_prefix}cash_exchange] ( 
         [ex_cash_id1] [int] NOT NULL , 
         [ex_cash_id2] [int] NOT NULL , 
         [ex_cash_enabled] [int] NOT NULL 
         ) ON [PRIMARY]", 

         "ALTER TABLE [userid].[{$table_prefix}cash_exchange] WITH NOCHECK ADD 
         CONSTRAINT [PK_{$table_prefix}cash_exchange] PRIMARY KEY CLUSTERED 
         ( 
         [ex_cash_id1], 
         [ex_cash_id2] 
         ) ON [PRIMARY]", 

         "ALTER TABLE [userid].[{$table_prefix}cash_exchange] WITH NOCHECK ADD 
         CONSTRAINT [DF_{$table_prefix}cash_enabled_b] DEFAULT (1) FOR [ex_cash_enabled]", 

         "CREATE TABLE [userid].[{$table_prefix}cash_log] ( 
         [log_id] [int] IDENTITY (1, 1) NOT NULL , 
         [log_time] [int] NOT NULL , 
         [log_type] [int] NOT NULL , 
         [log_text] [varchar] (255) COLLATE SQL_Latin1_General_CP1_CI_AS NOT NULL 
         ) ON [PRIMARY]", 


         "ALTER TABLE [userid].[{$table_prefix}cash_log] WITH NOCHECK ADD 
         CONSTRAINT [PK_{$table_prefix}cash_log] PRIMARY KEY CLUSTERED 
         ( 
         [log_id] 
         ) ON [PRIMARY]", 

         "ALTER TABLE [userid].[{$table_prefix}cash_log] WITH NOCHECK ADD 
         CONSTRAINT [DF_{$table_prefix}log_time] DEFAULT (0) FOR [log_time], 
         CONSTRAINT [DF_{$table_prefix}log_type] DEFAULT (0) FOR [log_type]", 

         "CREATE INDEX [log_time] ON [userid].[{$table_prefix}cash_log]([log_time], [log_type]) ON [PRIMARY]", 

         "CREATE TABLE [userid].[{$table_prefix}cash_groups] ( 
         [group_id] [int] IDENTITY (3, 1) NOT NULL , 
         [group_type] [int] NOT NULL , 
         [group_cashid] [int] NOT NULL , 
         [group_order] [varchar] (64) COLLATE SQL_Latin1_General_CP1_CI_AS NOT NULL , 
         [cash_status] [varchar] (64) COLLATE SQL_Latin1_General_CP1_CI_AS NOT NULL , 
         [cash_perpost] [int] NOT NULL , 
         [cash_postbonus] [int] NOT NULL , 
         [cash_perreply] [int] NOT NULL , 
         [cash_perchar] [float] NOT NULL , 
         [cash_maxearn] [int] NOT NULL , 
         ) ON [PRIMARY]", 

         "ALTER TABLE [userid].[{$table_prefix}cash_groups] WITH NOCHECK ADD 
         CONSTRAINT [PK_{$table_prefix}cash_groups] PRIMARY KEY CLUSTERED 
         ( 
         [group_id],[group_type],[group_cashid] 
         ) ON [PRIMARY]", 

         "ALTER TABLE [userid].[{$table_prefix}cash_groups] WITH NOCHECK ADD 
         CONSTRAINT [DF_{$table_prefix}cash_group_order]      DEFAULT (0) FOR [group_order], 
         CONSTRAINT [DF_{$table_prefix}cash_cash_status]      DEFAULT (0) FOR [cash_status], 
         CONSTRAINT [DF_{$table_prefix}cash_groups_perpost]   DEFAULT (25) FOR [cash_perpost], 
         CONSTRAINT [DF_{$table_prefix}cash_groups_postbonus] DEFAULT (2) FOR [cash_postbonus], 
         CONSTRAINT [DF_{$table_prefix}cash_groups_perreply]  DEFAULT (25) FOR [cash_perreply], 
         CONSTRAINT [DF_{$table_prefix}cash_groups_maxearn]   DEFAULT (75) FOR [cash_maxearn], 
         CONSTRAINT [DF_{$table_prefix}cash_groups_perchar]   DEFAULT (0.02) FOR [cash_perchar]", 
      ); 
   break; 
   case 'mysql': 
   case 'mysql4': 
   default: 
      $sql = array( 
         "INSERT INTO {$table_prefix}config (config_name, config_value) VALUES 
         ('cash_disable',0), 
         ('cash_display_after_posts',1), 
         ('cash_post_message','You earned %s for that post'), 
         ('cash_disable_spam_num',10), 
         ('cash_disable_spam_time',24), 
         ('cash_disable_spam_message','You have exceeded the alloted amount of posts and will not earn anything for your post'), 
         ('cash_installed','yes'), 
         ('cash_version','2.0.0'), 
         ('points_name','Points')", 

         "CREATE TABLE {$table_prefix}cash ( 
         cash_id SMALLINT(6) NOT NULL AUTO_INCREMENT , 
         cash_order SMALLINT(6) NOT NULL , 
         cash_enabled TINYINT(1) DEFAULT '1' NOT NULL , 
         cash_dbfield VARCHAR(64) NOT NULL , 
         cash_name VARCHAR(64) DEFAULT 'GP' NOT NULL , 
         cash_image TINYINT(1) DEFAULT '0' NOT NULL , 
         cash_imageurl VARCHAR(255) NOT NULL , 
         cash_exchange INT(11) DEFAULT '1' NOT NULL , 
         cash_before TINYINT(1) DEFAULT '1' NOT NULL , 
         cash_perpost INT(11) DEFAULT '25' NOT NULL , 
         cash_postbonus INT(11) DEFAULT '2' NOT NULL , 
         cash_perreply INT(11) DEFAULT '25' NOT NULL , 
         cash_maxearn INT(11) DEFAULT '75' NOT NULL , 
         cash_perchar DECIMAL(10,3) DEFAULT '.02' NOT NULL , 
         cash_jiggle INT(11) DEFAULT '0' NOT NULL , 
         cash_allowance TINYINT(1) DEFAULT '1' NOT NULL , 
         cash_allowancetime TINYINT(2) DEFAULT '2' NOT NULL , 
         cash_includequotes TINYINT(1) DEFAULT '0' NOT NULL , 
         cash_profiledisplay TINYINT(1) DEFAULT '1' NOT NULL , 
         cash_donate TINYINT(1) DEFAULT '1' NOT NULL , 
         cash_modedit TINYINT(1) DEFAULT '0' NOT NULL , 
         cash_allowneg TINYINT(1) DEFAULT '0' NOT NULL , 
         cash_postdisplay TINYINT(1) DEFAULT '1' NOT NULL , 
         cash_forumlisttype TINYINT(1) DEFAULT '1' NOT NULL , 
         cash_forumlist VARCHAR(255) NOT NULL , 
         cash_log TINYINT(1) DEFAULT '1' NOT NULL , 
         PRIMARY KEY (cash_id) 
         );", 

         "CREATE TABLE {$table_prefix}cash_groups ( 
         group_id MEDIUMINT(6) NOT NULL , 
         group_type TINYINT(2) NOT NULL , 
         group_cashid SMALLINT(6) NOT NULL , 
         group_order SMALLINT(6) DEFAULT '0' NOT NULL , 
         cash_status TINYINT(2) DEFAULT '1' NOT NULL , 
         cash_perpost INT(11) DEFAULT '25' NOT NULL , 
         cash_postbonus INT(11) DEFAULT '2' NOT NULL , 
         cash_perreply INT(11) DEFAULT '25' NOT NULL , 
         cash_perchar DECIMAL(10,3) DEFAULT '.02' NOT NULL , 
         cash_maxearn INT(11) DEFAULT '75' NOT NULL , 
         cash_jiggle INT(11) DEFAULT '0' NOT NULL , 
         cash_allowance TINYINT(1) DEFAULT '1' NOT NULL , 
         cash_allowancetime TINYINT(2) DEFAULT '2' NOT NULL , 
         PRIMARY KEY (group_id, group_type, group_cashid) 
         );", 

         "CREATE TABLE {$table_prefix}cash_log ( 
         log_id INT(11) NOT NULL auto_increment, 
         log_time INT(11) NOT NULL, 
         log_type SMALLINT(6) NOT NULL, 
         log_text VARCHAR(255) NOT NULL, 
         PRIMARY KEY (log_id) , 
         INDEX (log_time, log_type) 
         );", 

         "CREATE TABLE {$table_prefix}cash_exchange ( 
         ex_cash_id1 INT(11) NOT NULL , 
         ex_cash_id2 INT(11) NOT NULL , 
         ex_cash_enabled INT(1) NOT NULL DEFAULT '0', 
         PRIMARY KEY (ex_cash_id1,ex_cash_id2) 
         );" 

      ); 
   break; 
} 

foreach ( $sql AS $query ) 
{ 
   if ( !($result = $db->sql_query($query)) ) 
   { 
      $error = $db->sql_error(); 
      print('<li>' . nl2br($query) . '<br /> +++ <font color="#FF0000"><b>Error:</b></font> ' . $error['message'] . '</li><br />'); 
   } 
   else 
   { 
      print('<li>' . nl2br($query) . '<br /> +++ <font color="#00AA00"><b>Successfull</b></font></li><br />'); 
   } 
} 

$forum_url = append_sid("index.$phpEx"); 
$phpbb_url = "http://www.phpbb.com/phpBB/viewtopic.php?t=94055"; 

?> 
        </ul> 
      </span> 
    </td> 
  </tr> 
  <tr> 
    <td class="catBottom" height="28">&</td> 
  </tr> 
  <tr> 
    <td class="catBottom" colspan="2" align="center">Finished</td> 
  </tr> 
</table> 

<br /> 
<br /> 

<table width="100%" cellspacing="1" cellpadding="2" border="0" class="forumline"> 
  <tr> 
    <th class="thHead">SQL Installation complete</th> 
  </tr> 
  <tr> 
    <td> 
      <span class="genmed">Please delete this file (mysql_install.php).<br /> 
      If you have any problems, please visit <a href="<?php echo $phpbb_url ?>" target="_new">phpbb.com (CashMod v 2.0.0 Support Thread)</a> and ask for help.</span> 
    </td> 
  </tr> 
  <tr> 
    <td class="catBottom" height="28" align="center"> 
      <span class="genmed"><a href="<?php echo $forum_url ?>">Click Here to return to your forum.</a> 
      </span> 
    </td> 
  </tr> 
</table> 

<?php 

include($phpbb_root_path . 'includes/page_tail.'.$phpEx); 

?>
Two nutz short of a squirrel...

User avatar
Xore
Former Team Member
Posts: 2594
Joined: Wed Apr 16, 2003 7:42 pm
Location: the wastelands between insomnia and clairvoyance
Contact:

Post by Xore » Tue Aug 05, 2003 9:28 pm

deadferret wrote: Here is the final modified script that I used to get a Successful Mssql install. Please note the changes in the switch (since I do not use odbc) and the removal of the two IDENTITY pieces.


If identity is an auto-incrementer (as i now suspect it is)

then that one block of code should look like this:

Code: Select all

		   "CREATE TABLE [userid].[{$table_prefix}cash_groups] ( 
			[group_id] [int] NOT NULL ,
			[group_type] [int] NOT NULL ,
			[group_cashid] [int] NOT NULL ,
			[group_order] [int] NOT NULL ,
			[cash_status] [int] NOT NULL ,
			[cash_perpost] [int] NOT NULL ,
			[cash_postbonus] [int] NOT NULL ,
			[cash_perreply] [int] NOT NULL ,
			[cash_perchar] [float] NOT NULL ,
			[cash_maxearn] [int] NOT NULL ,
			) ON [PRIMARY]",

		   "ALTER TABLE [userid].[{$table_prefix}cash_groups] WITH NOCHECK ADD 
			CONSTRAINT [PK_{$table_prefix}cash_groups] PRIMARY KEY CLUSTERED 
			( 
			[group_id],[group_type],[group_cashid]
			) ON [PRIMARY]",
Camels in the Mist
<noise type="random" source="camel" />
Cash Mod

User avatar
Xore
Former Team Member
Posts: 2594
Joined: Wed Apr 16, 2003 7:42 pm
Location: the wastelands between insomnia and clairvoyance
Contact:

Post by Xore » Tue Aug 05, 2003 9:38 pm

deadferret wrote:
Xore wrote:
Edit: wait a sec... is IDENTITY the mssql version of auto-increment? If so, you can take the identity fields for those columns


Yes. I removed the last two as you can see from my other post and everything was finally successful.


Actually, that shouldn't have any IDENTITY on it at all, since it's a foreign key. now that i realize this, i know none of them should have IDENTITY on them in that table
deadferret wrote: One other error I found was that you had duplicated two constraint names. If you look under the exchange table Alter Table Add Constraint I changed the name of it by adding on the "_b" to it.


Thanks, i appreciate the help :-)

Now all i need to do is fix the queries in admin_cash_currencies so that it drops the constraint first before the column
Camels in the Mist
<noise type="random" source="camel" />
Cash Mod

deadferret
Registered User
Posts: 36
Joined: Wed Dec 11, 2002 9:45 pm

Post by deadferret » Tue Aug 05, 2003 9:39 pm

Xore wrote: If identity is an auto-incrementer (as i now suspect it is)

then that one block of code should look like this:

Code: Select all

		   "CREATE TABLE [userid].[{$table_prefix}cash_groups] ( 
			[group_id] [int] NOT NULL ,
			[group_type] [int] NOT NULL ,
			[group_cashid] [int] NOT NULL ,
			[group_order] [int] NOT NULL ,
			[cash_status] [int] NOT NULL ,
			[cash_perpost] [int] NOT NULL ,
			[cash_postbonus] [int] NOT NULL ,
			[cash_perreply] [int] NOT NULL ,
			[cash_perchar] [float] NOT NULL ,
			[cash_maxearn] [int] NOT NULL ,
			) ON [PRIMARY]",

		   "ALTER TABLE [userid].[{$table_prefix}cash_groups] WITH NOCHECK ADD 
			CONSTRAINT [PK_{$table_prefix}cash_groups] PRIMARY KEY CLUSTERED 
			( 
			[group_id],[group_type],[group_cashid]
			) ON [PRIMARY]",


That worked perfectly.
Two nutz short of a squirrel...

User avatar
Xore
Former Team Member
Posts: 2594
Joined: Wed Apr 16, 2003 7:42 pm
Location: the wastelands between insomnia and clairvoyance
Contact:

Post by Xore » Tue Aug 05, 2003 9:45 pm

deadferret wrote: I suppose one last thing I would request you add is some "drop" and "delete from" sql in case something goes wrong with part of the script.

Cool stuff! :D


you mean in case the constraints don't successfully apply, to drop the tables that are thereby bork?

i could give it a try, but it's not as easy since it's just a straight try - succeed/fail loop with no error checking. However, if a query fails, it lets the user know, so they can fix it manually.

i'm still looking for the double constraint you mentioned earlier

[edit: nevermind i just found it]
Camels in the Mist
<noise type="random" source="camel" />
Cash Mod

Post Reply

Return to “[2.0.x] MOD Database Releases”

Who is online

Users browsing this forum: No registered users and 12 guests