Writing addons for the bank.

Programmers Guild

Moderator: Andreas the Wise

Post Reply
Erik Mortis
Posts: 7238
Joined: Thu Oct 02, 2003 10:37 pm
Location: County of Monty Crisco
Contact:

Writing addons for the bank.

Post by Erik Mortis »

The bank can now handle add ons. below is a basic example.

Some of the code is required to be able to interact with the bank.

Code: Select all

<?php

//These are the basic require files. 
require_once '../../require/util.php'; //utility functions (need to connect to the server)
require_once '../../require/config.php'; //config file needed for various constants.
require_once '../../require/bankops.php'; //needed if you want to move money. 

//There are more libraries at your disposal but I don't plan to go into them here. 

error_reporting(E_ALL); //I require this. 

begin_session(); //needed for session to work. Only put it once. and before any HTML. 

$server = bank_server_connect(); //now you have a server connection. 

//From here on what whatever you need/want for your addon.

//If you want to move money you'll need the transfer_funds() function.
//Here is an example of it in use. 
// transfer_funds($instigator, $sender, $receiver, $funds, $reason, $server)

transfer_funds('Admin', 'Admin', 'Erik', '15.9', 'Taxes', $server)
//this will show that Admin initiated a transfer from their account to Erik's for 15.9. When logged by the function it will show the reason. 
//Most of the time $instigator and $sender should be the same person. Unless you are an admin you should not be moving money from OTHER people's accounts. 
//Though in some situation, when the other user authorized it, you might be moving money from their account to yours. 
//But try to make all funds movements based on who hits the buttons. 

//make sure to use proper XHTML and to have you ending tags. htmllib.php has some premade functions for html. 
//Ask and I can send a recent copy of all required files. 
?>
More info on transfer_funds()

Code: Select all

function transfer_funds($instigator, $sender, $receiver, $funds, $reason, $server)
//Take money from one account and put it in another. 
//Returns 0 on success. Returns 1 on failure due to insufficient funds. 
//2 is returned if the account for the reciever did not exist.
//3 if the sender doesn't exist.
//4 if trying to send to yourself.
//5 if funds to move are neg
//6 if the reciever is an Inactive account.
//7 if the instigator is an Inactive account.
//We handle cleaning up the funds.
//handles error messages and logging. 
If you want to make your own require files put them in a directory called 'require'. This will be kept separate from my require and will be in the same directory that your files are kept.

include_once ('require/myfile.php'); this is how you should do your requires. Mine are 2 directories up the tree.

User avatar
Andreas the Wise
Posts: 5253
Joined: Sat Oct 27, 2007 10:41 pm
Location: The Island of Melangia, Atterock, Kildare
Contact:

Re: Writing addons for the bank.

Post by Andreas the Wise »

Would you also want the html_lib for bank menu, header, footer etc? Or do you plan to add those onto people's mods after they've done them?
The character Andreas the Wise is on indefinite leave.
However, this account still manages:
Cla'Udi - Count of Melangia
Manuel - CEO of VBNC. For all you'll ever need.
Vincent Waldgrave - Lord General of Gralus
Q - Director of SAMIN
Duke Mel'Kat - Air Pirate, Melangian, and Duke of the Flying Duchy of Glanurchy

And references may be made to Vur'Alm Xei'Bôn (a Nelagan Micron of undisclosed purpose).

Erik Mortis
Posts: 7238
Joined: Thu Oct 02, 2003 10:37 pm
Location: County of Monty Crisco
Contact:

Re: Writing addons for the bank.

Post by Erik Mortis »

I'm still trying to get functions in the right places. So some things are in odd places. but util.php has some html functions.


Just checked. bank_menu is in util.php, but won't work for a mod due to how the links are done. mods are kept in ./mod/modname/ while the bank is in ./ (from the point of view of files). bank_menu references from where it is called. so in a mod it is not called ./ which is where it expects to find files.

header and footer are in htmllib.php.


Most of the 'select' function are in util.php including one that lets you display a list of users to select from.

Erik Mortis
Posts: 7238
Joined: Thu Oct 02, 2003 10:37 pm
Location: County of Monty Crisco
Contact:

Re: Writing addons for the bank.

Post by Erik Mortis »

If you want to access session info it's easy.

These are the variables you'll need. There are a few more. but you shouldn't need them, and for security I won't make them public. but if you mess with them I'll know.
$_SESSION['authorized'] //if true they are logged in
$_SESSION['username'] //their username.
$_SESSION['subdivision'] //what subdivision they are in.
$_SESSION['country'] //what country they are in.
$_SESSION['style'] //what style they use for their style sheets. if you make your own html header you will need to access this to get the css right. ../../styles is where you can find the styles from the point of view of the mod files you are making.

vasroe
Posts: 145
Joined: Sun Dec 07, 2008 12:11 pm

Re: Writing addons for the bank.

Post by vasroe »

So does any file containing this stuff have to be on the SC bank's web server account?

If so, whom might I contact to grant me access to upload a few files to that account?

Erik Mortis
Posts: 7238
Joined: Thu Oct 02, 2003 10:37 pm
Location: County of Monty Crisco
Contact:

Re: Writing addons for the bank.

Post by Erik Mortis »

Ari, or myself have the access needed. You can send files to either of us. Though ask him first. I can't speak for his willingness to bother with this.

Erik Mortis
Posts: 7238
Joined: Thu Oct 02, 2003 10:37 pm
Location: County of Monty Crisco
Contact:

Re: Writing addons for the bank.

Post by Erik Mortis »

I'll be starting a new thread about how to work with transfer_funds(). The info here will be slightly outdated.

http://shireroth.org/forum/viewtopic.php?f=226&t=12580

Post Reply

Return to “Church of the Machine God”

Who is online

Users browsing this forum: No registered users and 3 guests