Welcome to the Second Life Forums Archive

These forums are CLOSED. Please visit the new forums HERE

Library: FOSSL Vending system v0.5

Ilobmirt Tenk
Registered User
Join date: 4 Jun 2007
Posts: 135
10-01-2007 07:05
I have decided to open source my vending system for all the world to see.
There will be a bunch of scripts involved so please be patient as they are posted.
Please also feel free to ask questions about the vendor, I'm sure that there is something missing in this faq.

Thank you for taking a look at this Open source Vendor.

------------------------------

FAQ

FOSSL Vendor v0.5
=================

(c)2007 Ilobmirt Tenk

=========
Licensing
=========

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 3 of the License, or
(at your option) any later version.

This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.

You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.


========
Overview
========

FOSSL Vendor is a vendor designed to be fully featured and web capable, yet without
the implications of cost up front or by commishion. Its functionality was inspired
by the real life way we handle sales via, reciept. Though future relases of
this program are aimed to make the system easier to manage, more efficient, and less of a
hassle to setup, Ideal users of this vending system should be well informed on how many
modern vending systems operate.


================
Current Features
================

FOSSL Vendor is capable of the following...

* Selling a displayed object in-world

* Selling a displayed object as a gift

* Server-side spoof detection - Good chance that any hint of someone mucking with (in/out)-world communications will be logged

* Tracking each sale as a reciept

* Rezzes display objects at a specified location

* Floating text indicating product index

* Controllable via, verbal commands

a) count - Current count of how many people got an information
notecard about your business

b) remove - Retires the vendor from the registered vendors list

c) reciept - Displays the current list of reciepts waiting to be
registered on the web server

d) debug - Toggles verbose llOwnerSay output about the vendor's
current proccesses

e) reset - Resets the main vendor script


=======
Roadmap
=======

FOSSL Vendor v0.5 (Freedom) -
----------------------------------

* First release to the public under GPL v3 License

* Packaged with an example FOSSL Vendor configuration


FOSSL Vendor v1 (Independence) -
----------------------------------

* In-word modules of the vending system are no longer hard coded.
Settings can be configured via, notecard

* Vendor capabilities can be enabled or disabled. Vendor will not have
to requre a web-server to be functional

* Improved Server/Client side Security

* Added new verbal commands

* enable ____ - Enables a FOSSL Vendor capability if not already enabled

* disable ____ - Disables a FOSSL Vendor capability if not already disabled

* toggle ____ - Toggles enabling/disabling of a FOSSL Vendor capability

* set ___ = ___ - Verbally configures a certain variable without the need to open up the
settings notecard and edit it manually

* autoUpdate - Toggles whether the main FOSSL Vendor script will reset after adding/removing/changing
other items within the vendor

* on - When in an offline mode, returns vendor to an online state. All capabilities that are disbled by going offline are restored.

* off - When in an online mode, sets the vendor to an offline state. All capabilities are disabled.

* Packaged with a ready-to-go offline mode FOSSL Vendor configuration


FOSSL Vendor v2 (Liberty) -
----------------------------

* Modifications to the server and the client will extend distributing objects beyond redeeming giftcards.
This could allow for decentralised distribution server configurations

* Modifications to the texturing system will reduce the need to package textures with all your vendors.

* Impoved Linked prim relations allow one to be more creative with their FOSSL Vending system. EX: Clickable
pictures that will adjust the current displayed product index.

* New error checking module

* Checks if vendor is a part of registered vendors list

* Checks if other vendors on the registered vendors list are online

* Checks for any disparity in sales and giftcard data

* Packaged with a few FOSSL Vendor Configurations

* Stand-alone off-line vendor

* FOSSL Product distribution server

* Single prim FOSSL Vending box

* Fossl Vendor with products searchable by image


=========
Operation
=========

The FOSSL Vending system makes use of an external web server to
track sales and verify giftcard activations and redemptions. FOSSL Vendor basses
its logic off the use of reciepts to attach a user to a sale.

Before any transactions occur, a FOSSL Vendor will register itself to the web Server
for the asurance that each transaction is comming only from your own objects and that
no other object is messing with your sales data.

Whenever a sale occurs, it is stored as a record locally on
that vendor untill it gets to contact the server. When the server gets that record, it
checks that source from a list of registered vendors. If It matches something on that list,
the sale is recorded to a sales database. Otherwise, it will deny the record and write up a
warning message using MIME data from the http request to log who tried to mess with the sales data.

The giftcarding system is another story. In a nutshell, the giftcard will make requests to the
vendor to activate or redeem the card. Vendors will then have the web server authenticate gift card
for activation or redemption. All private data that is communicated in-world uses e-mail. All data that
goes off-world travels through http request via , post. No private data travels Secondlife through any
"vocal" channel. (llSay, llWhisper, llShout, or llRegionSay) Gift cards use scripted memory to store
its current state. Though this might increase the chances of memory loss, it also makes it much more
difficult for others to scam the FOSSL Vendor system. If by chance you find someone exploiting the giftcarding
system, either they intercepted http or email messages, spoofed their uuids, or had unauthorised access to your
database. Something that either Linden Labs should worry about or your web server provider should worry about.


=============
Files/Modules
=============

14 In-world modules
-------------------

FOSSLGiftCardInfoStorage - Stores reciept data for the giftcard

FOSSLGiftCardMain - Controlls giftcard activation and redemption proccess

FOSSLVendorMain - Main module for the FOSSL Vendor System

FOSSLVendorNextArrow - Deals with moving product index forward

FOSSLVendorPrevArrow - Deals with moving product index backward

FOSSLVendorFloatingText - Displays floating text above an object

FOSSLVendorRezBall - Tells the main module where to rez the display objects

FOSSLVendorImageDisplay - A non-vital module currently usefull for determining link number

FOSSLVendorBuyModule - Deals with buying the currently displayed item

FOSSLVendorGiftModule - Deals with buying the currently displayed item as a gift

FOSSLVendorInfoModule - Deals with giving people an info notecard

FOSSLVendorGiftcardActivator - Deals with activating giftcards

FOSSLVendorGiftcardRedeemer - Deals with redeeming giftcards

FOSSLVendorInstantMessager - deals with instant messaging someone about their purchase

8 Web Server modules
--------------------

FOSSLVendorRegistration - Adds a vendor to the registered vendors list

FOSSLVendorDeRegistration - Removes a vendor from the registerd vendors list

FOSSLVendorObtainUUID - Obtians a registered vendor UUID

FOSSLVendorSalesRegistration - Register a sales reciept from a registered vendor

FOSSLVendorSalesStatistics - Shows the number of sales as well as the best selling product

FOSSLVendorGetGiftcardReciept - Gets the reciept of a users giftcard purchase by registered vendor's request

FOSSLVendorGiftcardActivation - Activates a giftcard from a registered vendor given reciept info

FOSSLVendorGiftcardRedemption - Redeems a giftcard from a registered vendor given reciept info

6 Web Server Files
------------------

vendors.txt - Flat text database of registered vendors

sales.txt - Flat text database of all sales reciepts

ActivatedCards.txt - Flat text database of all activated giftcards

RedeemedCards.txt - Flat text database of all redeemed giftcards

RetiredVendors-Year-Month.txt - Flat text database of all vendors removed from registered vendors database from that month.

WARNING.log - A log of all errors and potential threats that happened to your database.


=====
Setup
=====

1) Before you set up your vendor in-world, be sure that you have set up the server-side scripts
on your own web server capable of php and writing to text files. If you do not have a web server,
I highly reccomend 110MB.com for its cost-free and ad(banner/pop-up/etc)-free web services. (http://www.110mb.com/)
The scripts should reside in a single folder along with some blank files (soon to be filled with sales data)

2) There are 6 php scripts that require you use your avatar's UUID (FOSSLVendorSalesRegistration.php, FOSSLVendorRegistration.php, FOSSLVendorDeRegistration.php, FOSSLVendorGiftcardActivation.php, FOSSLVendorGiftcardRedemption.php, and FOSSLVendorGetGiftcardReciept.php)
Find the sections that contain "********-****-****-****-************" and replace those with your own UUID.

3) There are 5 lsl scripts that require your input (FOSSLVendorGiftcardActivator, FOSSLVendorGiftcardRedeemer, FOSSLVendorInstantMessager, FOSSLVendorMain, and FOSSLGiftCardMain). Between the lines that say "Customize the following variables"
and "Customize the above variables". Edit the variables to match your server side and prefered settings.

4) Rename each prim in your vendor accordingly. The name of the prim should match the name of the object each script came in.
Exceptions to this are the root prim scripts and the gift card scripts.

5) Add a notecard named "Products" each line is a record in the format of "strItemName#intPrice"
strItemName would be the name of the object added to the vendor while intPrice would be the amount it sells for.

6) For each product, you must have 3 objects...

a) The first one is the product that is sold. It is defined by strItemName

b) The second one is the one the vendor will display like a hologram. It is defined as strItemName + ";(DISPLAY)"

c) The third one is a texture for display purposes. It is defined as strItemName + ";(PICTURE)"

So if your selling an item named "Super Item Of Doom" you will need to put the following into your vendor...

1) Super Item Of Doom

2) Super Item Of Doom(DISPLAY)

3) Super Item Of Doom(PICTURE)

7) You should now be in business! Have fun selling your wares ^_-



===============
Troubleshooting
===============

Error Message:"You're not my object. GET OUT OF MY SERVER!!!"

Cause: Vendor calling the page is not on the registered vendors list


Error Message:"Oops. Your already on the list."

Cause: Vendor that is registering itself on the web server is already registered


Error Message:"It appears to me that this giftcard has already been redeemed.
In order to make a request for a server that will redeem your giftcard, your giftcard must not be already redeemed.
If this is in error, please send an Issue report stating your problem.
Please note that this event has been recorded and will be used to verify your claims."

Cause: When activating or redeeming, It appears to be that that sales record has been used to redeem a giftcard.


Error Message:"It appears to me that this gift card isn't activated.
In order to make a request for a vendor that will redeem your giftcard, you must first purchase something and then activate your giftcard.
If this is in error, please send an Issue report stating your problem.
Please note that this event has been recorded and will be used to verify your claims."

Cause: There is no record on ActivatedCards.txt that indicate the card has been activated.


Error Message:"It appears to me that you haven't bought one of our products.
In order to make a request for a vendor that will redeem your giftcard, you must first purchase something and then activate your giftcard.
If this is in error, please send an Issue report stating your problem.
Please note that this event has been recorded and will be used to verify your claims."

Cause: The record supplied from the giftcard isn't found in sales.txt


Error Message:"ERROR:No gift cards to activate."

Cause: All the cards have been activated for a particular user


Error Message:"ERROR:No gift cards were bought."

Cause: That user hasn't bought any giftcards.

Error: Upon Redeeming a giftcard it says "Server found a vendor to redeem giftcard at. Requesting redemption..." but constantly times out.

Cause: Your Registered vendors list isn't properley updated. Clear that list and reset all your vendors.
Ilobmirt Tenk
Registered User
Join date: 4 Jun 2007
Posts: 135
FOSSLVendorNextArrow.lsl AND FOSSLVendorPrevArrow.lsl
10-02-2007 03:40
CODE

//---------------------------------------------------------------------------------//
//Copyright Info Below... Please Do not Remove //
//---------------------------------------------------------------------------------//

//(c)2007 Ilobmirt Tenk

//This file is part of the FOSSL Vendor Project

// FOSSL Vendor 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 3 of the License, or
// (at your option) any later version.

// FOSSL Vendor is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.

// You should have received a copy of the GNU General Public License
// along with this program. If not, see <http://www.gnu.org/licenses/>.

//---------------------------------------------------------------------------------//
//Copyright Info Above... Please Do not Remove //
//---------------------------------------------------------------------------------//

default
{

touch_start(integer total_number)
{

//If an avatar touches this object, tell the main script that (insert avatar's name here) touched it.
if (llDetectedType(0) & AGENT){
llMessageLinked(LINK_ROOT,0,llDetectedName(0),NULL_KEY);
}

}
}
Ilobmirt Tenk
Registered User
Join date: 4 Jun 2007
Posts: 135
FOSSLVendorImageDisplay.lsl
10-02-2007 03:41
CODE

//---------------------------------------------------------------------------------//
//Copyright Info Below... Please Do not Remove //
//---------------------------------------------------------------------------------//

//(c)2007 Ilobmirt Tenk

//This file is part of the FOSSL Vendor Project

// FOSSL Vendor 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 3 of the License, or
// (at your option) any later version.

// FOSSL Vendor is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.

// You should have received a copy of the GNU General Public License
// along with this program. If not, see <http://www.gnu.org/licenses/>.

//---------------------------------------------------------------------------------//
//Copyright Info Above... Please Do not Remove //
//---------------------------------------------------------------------------------//

default
{

touch_start(integer total_number)
{
llSay(0, "Touched link #" + (string) llGetLinkNumber());
}

}
Ilobmirt Tenk
Registered User
Join date: 4 Jun 2007
Posts: 135
FOSSLVendorFloatingText.lsl
10-02-2007 03:42
CODE

//---------------------------------------------------------------------------------//
//Copyright Info Below... Please Do not Remove //
//---------------------------------------------------------------------------------//

//(c)2007 Ilobmirt Tenk

//This file is part of the FOSSL Vendor Project

// FOSSL Vendor 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 3 of the License, or
// (at your option) any later version.

// FOSSL Vendor is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.

// You should have received a copy of the GNU General Public License
// along with this program. If not, see <http://www.gnu.org/licenses/>.

//---------------------------------------------------------------------------------//
//Copyright Info Above... Please Do not Remove //
//---------------------------------------------------------------------------------//

default
{
state_entry()
{

llSetAlpha(0.0, ALL_SIDES); // set entire prim 100% invisible upon script start.

}

//whenever main script tells it to update the visible text, it shall do so.
link_message(integer sender_num, integer num, string str, key id){

list strSplit = llParseString2List(str,["#"],[]);

if( llList2String(strSplit,0)== "updateIndex"){

llSetText(llList2String(strSplit,1),<1.0,1.0,1.0>,1.0);
llSetTimerEvent(5.0); //script will remove text after 5 seconds
}

}

//5 seconds passed, time to clear the text.
timer(){

llSetTimerEvent(0.0);//stops triggering the timer event
llSetText("",<0,0,0>,0);//clears the text

}

}
Ilobmirt Tenk
Registered User
Join date: 4 Jun 2007
Posts: 135
FOSSLVendorRezBall.lsl
10-02-2007 03:43
CODE

//---------------------------------------------------------------------------------//
//Copyright Info Below... Please Do not Remove //
//---------------------------------------------------------------------------------//

//(c)2007 Ilobmirt Tenk

//This file is part of the FOSSL Vendor Project

// FOSSL Vendor 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 3 of the License, or
// (at your option) any later version.

// FOSSL Vendor is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.

// You should have received a copy of the GNU General Public License
// along with this program. If not, see <http://www.gnu.org/licenses/>.

//---------------------------------------------------------------------------------//
//Copyright Info Above... Please Do not Remove //
//---------------------------------------------------------------------------------//

default
{

//turn invisible upon state entry
state_entry(){

llSetAlpha(0.0, ALL_SIDES); // set entire prim 100% invisible.

}

//upon request, this will return a vecor location of where to rez the prims.
link_message(integer sender_num, integer num, string str, key id){

if(str == "getLocation"){

//sends to root prim its vector location
llMessageLinked(LINK_ROOT,0,(string)llGetPos(),NULL_KEY);

}

}

}
Ilobmirt Tenk
Registered User
Join date: 4 Jun 2007
Posts: 135
FOSSLVendorBuyModule.lsl
10-02-2007 03:44
CODE

//---------------------------------------------------------------------------------//
//Copyright Info Below... Please Do not Remove //
//---------------------------------------------------------------------------------//

//(c)2007 Ilobmirt Tenk

//This file is part of the FOSSL Vendor Project

// FOSSL Vendor 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 3 of the License, or
// (at your option) any later version.

// FOSSL Vendor is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.

// You should have received a copy of the GNU General Public License
// along with this program. If not, see <http://www.gnu.org/licenses/>.

//---------------------------------------------------------------------------------//
//Copyright Info Above... Please Do not Remove //
//---------------------------------------------------------------------------------//

integer intCurrentPrice = 200;

default
{

state_entry(){

//get the permission to sell stuff upon initializing
llRequestPermissions(llGetOwner(),PERMISSION_DEBIT); //Asks store owner for the ability to sell things.
//llSetPayPrice(PAY_HIDE, [200, PAY_HIDE, PAY_HIDE, PAY_HIDE]);

}

on_rez(integer start_param){

llResetScript();

}

link_message(integer sender_num, integer num, string str, key id){

if( str == "updatePrice"){

intCurrentPrice = num;
//llSetPayPrice(PAY_HIDE, [intCurrentPrice, PAY_HIDE, PAY_HIDE, PAY_HIDE]);

}

}

//touch_start(integer total_number)
//{

//If an avatar touches this object, tell the main script that (insert avatar's name here) touched it.
// if (llDetectedType(0) & AGENT){
// llMessageLinked(LINK_ROOT,0,llDetectedName(0),NULL_KEY);
//}

//}

money(key giver, integer amount) {

// has the user paid the correct amount?
if (amount == intCurrentPrice)
{
// if so, thank the payer by name.
llSay(0,"Thank you, " + llKey2Name(giver) + ".");
//give them the lovely object displayed on the vendor

//send message back to root object to give out product
llMessageLinked(LINK_ROOT,0,(string)giver,NULL_KEY);
}

// is the amount paid less than it needs to be?
else if (amount < intCurrentPrice)
{
// if so, tell them they're getting a refund, then refund their money.
llSay(0,"You didn't pay enough, " + llKey2Name(giver) + ". Refunding your payment of L$" + (string)amount + ".");
llGiveMoney(giver, amount); // refund amount paid.
}

// if it's not exactly the amount required, and it's not less than the amount required,
// the payer has paid too much.
else
{
// tell them they've overpaid.
integer intRefund = amount - intCurrentPrice; // determine how much extra they've paid.
llSay(0,"You paid too much, " + llKey2Name(giver) + ". Your change is L$" + (string)intRefund + ".");
llGiveMoney(giver, intRefund); // refund their change.
//give them the lovely object displayed on the vendor

//send message back to root object to give out product.
llMessageLinked(LINK_ROOT,0,(string)giver,NULL_KEY);

}

}
}
Ilobmirt Tenk
Registered User
Join date: 4 Jun 2007
Posts: 135
FOSSLVendorGiftModule.lsl
10-02-2007 03:45
CODE

//---------------------------------------------------------------------------------//
//Copyright Info Below... Please Do not Remove //
//---------------------------------------------------------------------------------//

//(c)2007 Ilobmirt Tenk

//This file is part of the FOSSL Vendor Project

// FOSSL Vendor 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 3 of the License, or
// (at your option) any later version.

// FOSSL Vendor is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.

// You should have received a copy of the GNU General Public License
// along with this program. If not, see <http://www.gnu.org/licenses/>.

//---------------------------------------------------------------------------------//
//Copyright Info Above... Please Do not Remove //
//---------------------------------------------------------------------------------//

integer intCurrentPrice = 200;

default
{

state_entry(){

//get the permission to sell stuff upon initializing
llRequestPermissions(llGetOwner(),PERMISSION_DEBIT); //Asks store owner for the ability to sell things.
//llSetPayPrice(PAY_HIDE, [200, PAY_HIDE, PAY_HIDE, PAY_HIDE]);

}

on_rez(integer start_param){

llResetScript();

}

link_message(integer sender_num, integer num, string str, key id){

if(llGetLinkName( str == "updatePrice"){

intCurrentPrice = num;
//llSetPayPrice(PAY_HIDE, [intCurrentPrice, PAY_HIDE, PAY_HIDE, PAY_HIDE]);

}

}

//touch_start(integer total_number)
//{

//If an avatar touches this object, tell the main script that (insert avatar's name here) touched it.
// if (llDetectedType(0) & AGENT){
// llMessageLinked(LINK_ROOT,0,llDetectedName(0),NULL_KEY);
//}

//}

money(key giver, integer amount) {

// has the user paid the correct amount?
if (amount == intCurrentPrice)
{
// if so, thank the payer by name.
llSay(0,"Thank you, " + llKey2Name(giver) + ".");
//give them the lovely object displayed on the vendor

//send message back to root object to give out product
llMessageLinked(LINK_ROOT,0,(string)giver,NULL_KEY);
}

// is the amount paid less than it needs to be?
else if (amount < intCurrentPrice)
{
// if so, tell them they're getting a refund, then refund their money.
llSay(0,"You didn't pay enough, " + llKey2Name(giver) + ". Refunding your payment of L$" + (string)amount + ".");
llGiveMoney(giver, amount); // refund amount paid.
}

// if it's not exactly the amount required, and it's not less than the amount required,
// the payer has paid too much.
else
{
// tell them they've overpaid.
integer intRefund = amount - intCurrentPrice; // determine how much extra they've paid.
llSay(0,"You paid too much, " + llKey2Name(giver) + ". Your change is L$" + (string)intRefund + ".");
llGiveMoney(giver, intRefund); // refund their change.
//give them the lovely object displayed on the vendor

//send message back to root object to give out product.
llMessageLinked(LINK_ROOT,0,(string)giver,NULL_KEY);

}

}
}
Ilobmirt Tenk
Registered User
Join date: 4 Jun 2007
Posts: 135
FOSSLVendorInfoModule.lsl
10-02-2007 03:46
CODE

//---------------------------------------------------------------------------------//
//Copyright Info Below... Please Do not Remove //
//---------------------------------------------------------------------------------//

//(c)2007 Ilobmirt Tenk

//This file is part of the FOSSL Vendor Project

// FOSSL Vendor 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 3 of the License, or
// (at your option) any later version.

// FOSSL Vendor is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.

// You should have received a copy of the GNU General Public License
// along with this program. If not, see <http://www.gnu.org/licenses/>.

//---------------------------------------------------------------------------------//
//Copyright Info Above... Please Do not Remove //
//---------------------------------------------------------------------------------//

default
{

touch_start(integer total_number)
{

//If an avatar touches this object, tell the main script that (insert avatar's name here) touched it.
if (llDetectedType(0) & AGENT){
llMessageLinked(LINK_ROOT,0,llDetectedName(0),NULL_KEY);
}

}
}
Ilobmirt Tenk
Registered User
Join date: 4 Jun 2007
Posts: 135
FOSSLVendorGiftcardActivator.lsl
10-02-2007 03:47
CODE

//---------------------------------------------------------------------------------//
//Copyright Info Below... Please Do not Remove //
//---------------------------------------------------------------------------------//

//(c)2007 Ilobmirt Tenk

//This file is part of the FOSSL Vendor Project

// FOSSL Vendor 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 3 of the License, or
// (at your option) any later version.

// FOSSL Vendor is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.

// You should have received a copy of the GNU General Public License
// along with this program. If not, see <http://www.gnu.org/licenses/>.

//---------------------------------------------------------------------------------//
//Copyright Info Above... Please Do not Remove //
//---------------------------------------------------------------------------------//

//use this prim to communicate between company server and gift card to initialise gift card activation

//=================================================================//
//List all the global variables here...
//=================================================================//

key keyHttpRequest; //used to identify http answers targeted for this object
key keyActivationRequest;
list strCard; //the list of unactivated gift card purchases made by owner of the gift card

key keyCardOwnerId; //key of the owner of the activating giftcard

key keyCard; //key of the card requesting activation

string strResponse = "";

integer blnActivating = 0; // 0 = false, 1 = true (if this object is in the proccess of validating someone's card)

//=================================================================//
//Customize the following variables
//=================================================================//
string strGetCardPage = ""; //Determines where to go to get a customer's giftcard info

string strActivateCardPage = ""; //Determines where to go to activate a customer's giftcard

integer intCardRequestChannel = -1; //channel in which to listen to notecards speak.

integer intReplyChannel = -2; //channel in which to reply to the notecards

//=================================================================//
//Customize the above variables
//=================================================================//

default
{
state_entry(){

llListen(intCardRequestChannel,"",NULL_KEY,"");//All Gift cards will request for activation from their activation channel
//llOwnerSay("listening for cards.");

}
on_rez(integer start_param)
{
llResetScript();
}

listen(integer channel, string name, key id, string message){ //Triggered when a gift card requests activation

//llOwnerSay("Did I hear a request?");

if(channel == intCardRequestChannel && blnActivating == 1){

//llOwnerSay("Busy:"+(string)id);
llSay(intReplyChannel,"Busy:"+(string)id);
//llSay(0,"Error:Busy Activating.");

}
else if(channel == intCardRequestChannel && blnActivating == 0 && (key) message == llGetOwnerKey(id)){

//obtain the card message
//message has owner id
blnActivating = 1;
llSetTimerEvent(10.0); // If the vendor cannot get positive identification after 10 seconds, send a timeout
keyCardOwnerId = (key) message;
keyCard = id;
keyHttpRequest = llHTTPRequest(strGetCardPage,[HTTP_METHOD, "POST", HTTP_MIMETYPE, "application/x-www-form-urlencoded"],"buyerKey="+ (string) keyCardOwnerId +"&buyerName="+ llKey2Name(keyCardOwnerId));
llSay(intReplyChannel,"Success:"+(string)id);
//llOwnerSay("I hear you loud and clear!");

}


}

http_response(key request_id, integer status, list metadata, string body){ //triggered when company server replies

if(request_id == keyHttpRequest){

//llOwnerSay("http Response found!");
//llOwnerSay("Server Replies:\n"+body);
strResponse = body;
strCard = llParseString2List(strResponse,["#"],[]);


////llOwnerSay(body);

if(body == "ERROR:No gift cards were bought."){ //If the owner didn't buy any gift cards

llSay(intReplyChannel,body);

}
else if(body == "ERROR:No gift cards to activate."){ //If the owner has activated all the gift cards

llSay(intReplyChannel,body);

}
else if(body == "You're not my object. GET OUT OF MY SERVER!!!"){

llSay(intReplyChannel,"ERROR:Vendor doesn't appear to be authenticated.");

}
else{ //if there are still gift cards to activate

//Activate the oldest unactivated card
//llOwnerSay("Server sends good news about activation request");
llSay(intReplyChannel,"Card info retrieved.");
llSetTimerEvent(10.0); //server didn't timeout. reset timer
keyActivationRequest = llHTTPRequest(strActivateCardPage,[HTTP_METHOD, "POST", HTTP_MIMETYPE, "application/x-www-form-urlencoded"],"activatorKey="+ llList2String(strCard,0) +"&activatorName="+ llList2String(strCard,1)+"&salesID="+llList2String(strCard,2));
llSay(intReplyChannel,"Card info retrieved.");

}

}
else if(request_id == keyActivationRequest){

//If server returned the sales ID, it must have passed
if(body == llList2String(strCard,2)){

//tell card to expect an e-mail soon
llSay(intReplyChannel,"Card has been activated!");
llEmail((string)keyCard+"@lsl.secondlife.com","Activation Success",llList2String(strCard,0)+"#"+llList2String(strCard,1)+"#"+llList2String(strCard,2)+"#"+llList2String(strCard,3));
blnActivating = 0;

}
else{

//send bad news
llSay(intReplyChannel,body);

}

}

}

timer(){

//servers must have timed out :(
//report it
llSay(intReplyChannel,"ERROR:Servers have timed out while activating giftcard!");
llSetTimerEvent(0.0);
blnActivating = 0;

}

}
Ilobmirt Tenk
Registered User
Join date: 4 Jun 2007
Posts: 135
FOSSLVendorGiftcardRedeemer.lsl
10-02-2007 03:49
CODE

//---------------------------------------------------------------------------------//
//Copyright Info Below... Please Do not Remove //
//---------------------------------------------------------------------------------//

//(c)2007 Ilobmirt Tenk

//This file is part of the FOSSL Vendor Project

// FOSSL Vendor 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 3 of the License, or
// (at your option) any later version.

// FOSSL Vendor is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.

// You should have received a copy of the GNU General Public License
// along with this program. If not, see <http://www.gnu.org/licenses/>.

//---------------------------------------------------------------------------------//
//Copyright Info Above... Please Do not Remove //
//---------------------------------------------------------------------------------//

//use this prim to communicate between company server and gift card to initialise gift card redemption

//=================================================================//
//List all the global variables here...
//=================================================================//

key keyRedemptionRequest;

list strCard; //the unredeemed gift card purchases made by owner of the gift card

key keyCardOwnerId; //key of the card's purchaser

key keyRedeemerId; //key of the card's redeemer

string strSalesID = ""; //Id of the gift card's sale

string strProduct = ""; //Name of the product

key keyCard; //key of the card requesting activation

list strRecord; //the record recieved from the requesting gift card

integer blnActivating = 0; // 0 = false, 1 = true (if this object is in the proccess of validating someone's card)

integer intTimeout = 0;

//=================================================================//
//Customize the following variables
//=================================================================//
integer intTimeoutLength = 10; //Time before this vendor decides the server might not be responding

string strRedeemCardPage = ""; //Determines where vendor will send giftcard info to determine redemption

//=================================================================//
//Customize the above variables
//=================================================================//

default
{
state_entry(){

////llOwnerSay("listening on e-mail for cards.");
llSetTimerEvent(1.0);
}
on_rez(integer start_param)
{
llResetScript();
}

timer(){

//If vendor doesn't recieve info in 10 seconds, quit the registration proccess
if(llGetUnixTime() - intTimeout >= intTimeoutLength && blnActivating == 1){

llEmail((string)keyCard+"@lsl.secondlife.com","Registration Timeout", "ERROR:Vendor has timed out while registering giftcard.");
blnActivating = 0;

}
else if(blnActivating == 0){

//I guess its a good time to get the next e-mail message
llGetNextEmail("","");

}

}

email(string time, string address, string subj, string message, integer num_left){ //Triggered when a gift card requests activation

////llOwnerSay("Did I hear a request?");
list strAddressID = llParseString2List(address,["@lsl.secondlife.com"],[]);

if(llList2String(strAddressID,0) !="" && subj=="Requesting Redemption" && blnActivating == 0){

//obtain the card message

//message is a record in the form of... buyer id, redeemer id, sales id

//message has owner id
blnActivating = 1;
//extract a record out of the message
strRecord = llParseString2List(llDeleteSubString(message, 0, llSubStringIndex(message, "\n\n") + 1),["#"],[]);
intTimeout = llGetUnixTime(); // If the vendor cannot get positive identification after 10 seconds, send a timeout
keyCardOwnerId = llList2Key(strRecord,0);
keyRedeemerId = llList2Key(strRecord,1);
strSalesID = llList2String(strRecord,2);
strProduct = llList2String(strRecord,3);
keyCard = llList2Key(strAddressID,0);

//Now that we have all the info we need from our giftcard, call up the server and have it redeemed
keyRedemptionRequest = llHTTPRequest(strRedeemCardPage,[HTTP_METHOD, "POST", HTTP_MIMETYPE, "application/x-www-form-urlencoded"],"buyerKey="+ (string) keyCardOwnerId +"&buyerName="+ llKey2Name(keyCardOwnerId)+"&redeemerKey="+ (string) keyRedeemerId +"&redeemerName="+ llKey2Name(keyRedeemerId)+"&salesID="+strSalesID);
////llOwnerSay("I hear you loud and clear!");

}
else if(blnActivating == 1){

//the vendor is busy activating, tell it to go someplace else
llEmail(address,"Busy Redeeming","This vendor is busy redeeming another card.");
llSay(0,"Error:Busy Activating.");

}

}

http_response(key request_id, integer status, list metadata, string body){ //triggered when company server replies

if(request_id == keyRedemptionRequest){

////llOwnerSay("http Response found!");

//A good response would be to see the sales ID
if(body == strSalesID){

llEmail((string) keyCard +"@lsl.secondlife.com","Redeeming Card Successfull","The card has been added to the redeemed cards list. You should recieve your gift soon.");
llGiveInventory(keyRedeemerId,strProduct);
//I guess its a good time to get the next e-mail message
llGetNextEmail("","");


}

//Something is up with the information given to it
else if(body == "It appears to me that this giftcard has already been redeemed.\nIn order to redeem your giftcard, your giftcard must not already be redeemed./nIf this is in error, please send an Issue report stating your problem.\nPlease note that this event has been recorded and will be used to verify your claims." || body == "It appears to me that this giftcard has not been activated.\nIn order to redeem your giftcard, your giftcard must be activated./nIf this is in error, please send an Issue report stating your problem.\nPlease note that this event has been recorded and will be used to verify your claims." || body == "It appears to me that this giftcard has not been purchased.\nIn order to activate your giftcard, you must first purchase something./nIf this is in error, please send an Issue report stating your problem.\nPlease note that this event has been recorded and will be used to verify your claims."){

llEmail((string) keyCard +"@lsl.secondlife.com","Error Redeeming Card",body);

}
//Server seems to hate the vendor
else if(body == "You're not my object. GET OUT OF MY SERVER!!!"){

llEmail((string) keyCard +"@lsl.secondlife.com","Error Redeeming Card","It appears that the server dislikes this vendor.");

}
//server is probably not online
else{

llEmail((string) keyCard +"@lsl.secondlife.com","Error Redeeming Card","Server appears to be offline.");

}
//Now that we have replied to our request, allow the server to listen to more requests
blnActivating = 0;

}


}

}
Ilobmirt Tenk
Registered User
Join date: 4 Jun 2007
Posts: 135
FOSSLVendorInstantMessager.lsl
10-02-2007 03:51
CODE

//---------------------------------------------------------------------------------//
//Copyright Info Below... Please Do not Remove //
//---------------------------------------------------------------------------------//

//(c)2007 Ilobmirt Tenk

//This file is part of the FOSSL Vendor Project

// FOSSL Vendor 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 3 of the License, or
// (at your option) any later version.

// FOSSL Vendor is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.

// You should have received a copy of the GNU General Public License
// along with this program. If not, see <http://www.gnu.org/licenses/>.

//---------------------------------------------------------------------------------//
//Copyright Info Above... Please Do not Remove //
//---------------------------------------------------------------------------------//

//=================================================================//
//Customize the following variables
//=================================================================//

string strOwnerName = "John Doe";

//=================================================================//
//Customize the above variables
//=================================================================//

default
{

link_message(integer sender_num, integer num, string str, key id){

//respond only to commands given by the prim its in
if(sender_num == llGetLinkNumber()){

//parse input string and determine what to say about the purcahse
integer blnGift=0;
list lstInfo = llParseString2List(str,["^"],[]);
string strPurchaseName = llList2String(lstInfo,0);
list lstRecord = llParseString2List(llList2String(lstInfo,1),["#"],[]);
string strMessage = "Thank you " + llKey2Name(id) + " for purchasing our ";
//determine if object sold is a gift. If so, do the proper formattiing
if(llSubStringIndex(strPurchaseName,"(GIFT)") != -1){

strPurchaseName = llGetSubString(strPurchaseName,0,-(1+llStringLength("(GIFT)")));
strMessage += strPurchaseName +" as a gift.";

}
else{

strMessage += strPurchaseName + ".";

}

strMessage += "\nIf in the event that technical difficulties occur, please send an error report to \""+strOwnerName+"\" in the form of a notecard. If this is related towards a purchase, please have your reciept info in that notecard.\n\n";

llInstantMessage(id,strMessage);

string strReciept = "Here is your Reciept. Keep this info in a safe place. If a technical error affects your purchase (IE: product not delivered, Dissapearance from inventory) this information will prove of your purchase and warrant help.\n\n";
strReciept += "Reciept : \n";
strReciept += "Vendor ID - " + (string)llGetKey() +"\n";
strReciept += "Location - "+ llGetRegionName() +"\n";
strReciept += "Product - " + strPurchaseName + "\n";
strReciept += "Date - " + llList2String(lstRecord,4)+ "\n";
strReciept += "Time - " + llList2String(lstRecord,5) + "\n\n";

llInstantMessage(id,strReciept);

//If the server appears to be down, give them a warning that the server is down
if(num == 1){

llInstantMessage(id,"WARNING:\nIt appears that our database is down. This shouldn't prevent the vendors from giving you your product. However, this will affect things that rely on our database such as giftcards. Please be patient and hopefully, our database will come back online.\n\n");

}

}
else{

//Nothing so far that needs to be said if the server is up.

}

}

}
Ilobmirt Tenk
Registered User
Join date: 4 Jun 2007
Posts: 135
FOSSLVendorMain.lsl
10-02-2007 03:52
CODE

//---------------------------------------------------------------------------------//
//Copyright Info Below... Please Do not Remove //
//---------------------------------------------------------------------------------//

//(c)2007 Ilobmirt Tenk

//This file is part of the FOSSL Vendor Project

// FOSSL Vendor 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 3 of the License, or
// (at your option) any later version.

// FOSSL Vendor is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.

// You should have received a copy of the GNU General Public License
// along with this program. If not, see <http://www.gnu.org/licenses/>.

//---------------------------------------------------------------------------------//
//Copyright Info Above... Please Do not Remove //
//---------------------------------------------------------------------------------//

//=================================================================//
//List all the global variables here...
//=================================================================//
vector vecRezModel; //Location to rez preview product

list strProducts; //List of product names

list intProductCost; //List of product costs

list strDatabase; //List of reciepts ready to be sent to server

integer intProducts = 0; //Number of products loaded

integer intWaitList = 0; //Number of reciepts waiting to be loaded to the server

integer intProductIndex = 0; //Current index of visible product shown

integer intInfoCount = 0; //Number of times people clicked on the info button

key keyProductsId; //Used to load a product notecard

key keyHttpRequest; //Used to communicate with the http server

key keyHttpVendorRegistration; //Used to communicate to the server to register this object

integer blnHttpInProgress = 0; //Used to determine if vendor is currently already proccessing a reciept to go to the server

integer blnServerDown = 0; //Used to determine if the http server is down

integer blnDebug = 0; //Used to determine if vendor will output debugging information

//=================================================================//
//Customize the following variables
//=================================================================//
string strSalesPage = ""; //Determines where to send sales reciepts to register every user purchase

string strAddVendorPage = ""; //Determines where to ask for vendor registration to allow your server to register sales and validate gift cards

string strRemoveVendorPage = ""; //Determines where to ask your server to remove the vendor off your vendor list

string strGiftcardName= ""; //Name of the giftcard object

string strGiftcardHowToName = ""; //Name of the howto notecard that comes with the giftcard object

string strInfoCardName = ""; //Name of the information notecard that talks about your company

integer intPictureIndex = 0; //Linked index of the prim that displays the product picture

integer intCommChannel = 45; //Channel in which you can communicate to your vending machine

//=================================================================//
//Customize the above variables
//=================================================================//



//=================================================================//
//Define global Functions here...
//=================================================================//
updateProduct(){

llSetPayPrice(PAY_HIDE, [llList2Integer(intProductCost,intProductIndex), PAY_HIDE, PAY_HIDE, PAY_HIDE]);
llMessageLinked(LINK_ALL_OTHERS,llList2Integer(intProductCost,intProductIndex),"updatePrice",NULL_KEY); //set the prices for the buy/gift buttons
llMessageLinked(LINK_ALL_OTHERS,0,"updateIndex#"+(string)(intProductIndex+1)+"/"+(string)intProducts,NULL_KEY); //tell objText to display the current product index for a few seconds
llSetLinkTexture(intPictureIndex, llList2String(strProducts,intProductIndex)+"(PICTURE)",ALL_SIDES);
rezProduct(); //Update the product on display

}

rezProduct(){

llWhisper(-88,"reload");//display objects that hear this will auto delete
llRezObject(llList2String(strProducts,intProductIndex)+"(DISPLAY)", vecRezModel, ZERO_VECTOR, llEuler2Rot(<270.0,0.0,90.0>*DEG_TO_RAD), 96);

}

recordPurchase(string strUserKey,string strName, integer intIndex){

//get the time of day in linden time
integer intHours = (integer)llGetWallclock() / 3600;
integer intMinutes = ((integer)llGetWallclock() % 3600) /60;
integer intSeconds = (integer)llGetWallclock() % 60;

//add the data into a pending record used as a "reciept"
string strRecord = strUserKey +"#";
strRecord += llKey2Name((key)strUserKey)+"#";
strRecord += strName+"#";
strRecord += llList2String(intProductCost,intIndex)+"#";
strRecord += llGetDate()+"#";
strRecord += (string)intHours+":"+(string)intMinutes+":"+(string)intSeconds;

//To reduce time that the vendor has to freeze, IMs will be sent to another script.
//The input will be a record in the form of... Product Name^strRecord
string strIM = strName+"^"+strRecord;
llMessageLinked(LINK_THIS, blnServerDown, strIM, (key)strUserKey);

//take that record and add it to the waitlist
strDatabase = llListReplaceList(strDatabase,[strRecord],intWaitList,intWaitList);

//increment # of people on the waitlist
intWaitList++;

//get record to the server asap
if(blnHttpInProgress == 0){ //if an http request is not in progress

listToServer(strSalesPage); //start an http request
}

}

listToServer(string strDatabasePage){

//Signify that an http request is in progress
blnHttpInProgress = 1;

//change the record into an indexable list
list strRecipientData = llParseString2List(llList2String(strDatabase,intWaitList-1),["#"],[]);

//try and contact the server to see if it can write the record
keyHttpRequest = llHTTPRequest(strDatabasePage,[HTTP_METHOD, "POST",HTTP_MIMETYPE, "application/x-www-form-urlencoded"],"buyerKey="+llList2String(strRecipientData,0)+"&buyerName="+llList2String(strRecipientData,1)+"&objectSold="+llList2String(strRecipientData,2)+"&objectPrice="+llList2String(strRecipientData,3)+"&saleDate="+llList2String(strRecipientData,4)+"&saleTime="+llList2String(strRecipientData,5));

}

default
{
state_entry()
{
//add self to vendor list upon rezzing
keyHttpVendorRegistration = llHTTPRequest(strAddVendorPage, [HTTP_METHOD,"PUT"],"");
llSay(0, "Ready For Business!");
keyProductsId = llGetNotecardLine("Products", intProducts); //Obtain the first line of the product list
llMessageLinked(LINK_ALL_OTHERS,0,"getLocation",NULL_KEY); //obtain prieview rez location
llListen(intCommChannel,"",llGetOwner(),"count"); //activate listen event whenever I say count on chanel 88
llListen(intCommChannel,"",llGetOwner(),"remove"); //activate listen event whenever I say remove on chanel 88
llListen(intCommChannel,"",llGetOwner(),"reciept"); //activate listen event whenever I say reciept on chanel 88
llListen(intCommChannel,"",llGetOwner(),"debug"); //activate listen event whenever I say debug on chanel 88
llListen(intCommChannel,"",llGetOwner(),"reset"); //activate listen event whenever I say reset on chanel 88
llRequestPermissions(llGetOwner(),PERMISSION_DEBIT); //Asks store owner for the ability to sell things.
}

on_rez(integer start_param){

//reset the script when I rez it
llResetScript();

}

changed(integer change){

// If I change the contents of the vendor
if(change & CHANGED_INVENTORY){

//reset the script to make use of the changes
llResetScript();

}

}

link_message(integer sender_num, integer num, string str, key id){

//when a linked object has been touched, respond accordingly
string strCallerName = llGetLinkName(sender_num);

if(strCallerName == "nextArrow"){

if(blnDebug == 1){llOwnerSay("Moving on to next item.");}
intProductIndex++;
if(intProductIndex >= intProducts){
intProductIndex = 0;
}
updateProduct();

}
else if(strCallerName == "prevArrow"){

if(blnDebug == 1){llOwnerSay("Moving on to previous item.");}
intProductIndex--;
if(intProductIndex < 0){
intProductIndex = intProducts-1;
}
updateProduct();

}
else if(strCallerName == "scrBuy"){

if(blnDebug == 1){llOwnerSay( llKey2Name((key)str) + " has bought your item.");}
llWhisper(0,"Thank you " + llKey2Name((key)str) + " for purchasing the " + llList2String(strProducts,intProductIndex)+".");

recordPurchase((key)str,llList2String(strProducts,intProductIndex), intProductIndex);

llGiveInventory((key)str,llList2String(strProducts,intProductIndex));

}
else if(strCallerName == "scrGift"){

list lstCard = [strGiftcardName,strGiftcardHowToName];

if(blnDebug == 1){llOwnerSay( llKey2Name((key)str) + " has bought your item as a gift.");}
llSay(0,"Thank you " + llKey2Name((key)str) + " for purchasing the " + llList2String(strProducts,intProductIndex)+" as a gift.");
llGiveInventoryList((key)str,strGiftcardName,lstCard);

recordPurchase((key)str,llList2String(strProducts,intProductIndex)+"(GIFT)", intProductIndex);

}
else if(strCallerName == "scrInfo"){

if(blnDebug == 1){llOwnerSay(llKey2Name((key)str) + " wants to know more about your business.");}
llGiveInventory((key)str,strInfoCardName);
intInfoCount++;

}
else if(strCallerName == "rezBall"){

if(blnDebug == 1){llOwnerSay("Model Rezzer at Loaction " + str + " .");}
vecRezModel = (vector)str;

}
//it must have came from the SLX script
else if(num == 17){

string strItemName = llDumpList2String(llDeleteSubList(llParseString2List(str, [" ", "\n"], []), -1, -1), " ");
string AvatarKey = (string)id;
integer intRemoteIndex = llListFindList(strProducts,[strItemName]);

recordPurchase(id,llList2String(strProducts,intRemoteIndex),intRemoteIndex);

}
else{

}

}

//used to read product data
//Data should be a record per line
//Record format should be "strItemName#intPrice"
dataserver(key query_id, string data) {

if (query_id == keyProductsId) {
if (data != EOF) { // not at the end of the notecard

//split the record into product names and prices
list lstSplit = llParseString2List(data,["#"],[]);

strProducts += [llList2String(lstSplit,0)];
intProductCost += [llList2Integer(lstSplit,1)];

++intProducts; // increase line count
keyProductsId = llGetNotecardLine("Products", intProducts); // request next line
}
else{

if(blnDebug == 1){llSay(0,(string)intProducts + " products loaded.");}

}
}

}

http_response(key request_id, integer status, list metadata, string body)
{
//used for when you have a sale
if (request_id == keyHttpRequest){
if(blnDebug == 1){llOwnerSay("Web server contacted.");}

if(status >= 200 && status<= 206){ //good http error messages

if(blnDebug == 1){llOwnerSay("Web server sends good news about database request.");}
blnServerDown = 0;

//time to reduce the message stack
llSetTimerEvent(0.0);//stop the timer event from triggering
intWaitList--; //decrease stack index #
strDatabase = llDeleteSubList(strDatabase,intWaitList,intWaitList); //remove pended record
if(intWaitList > 0){ //if theres still more records to submit...

listToServer(strSalesPage);//send the next item on the stack on its way to the server

}
else{

//pretty much done till another item is purchased
blnHttpInProgress = 0; //signify no http requests are being made
}

}
else{//if(status >= 400 && status<= 417){ //bad http error messages

if(blnDebug == 1){llOwnerSay("Web server sends bad news about database request.");}
blnServerDown = 1;
//time to start a timer event to see when the server is capable of recieving.
llSetTimerEvent(300); //set the timer event to occur every 5 minutes to check up on the server
}
}
//used for when you add/remove a vendor
else if(request_id == keyHttpVendorRegistration){
if(blnDebug == 1){llOwnerSay("Server replies:\n\n"+body);}
}

}

timer(){

listToServer(strSalesPage);//check up on the server to see if the script can post data

}

listen( integer channel, string name, key id, string message ){

if(id == llGetOwner()){
if(message == "count"){
llOwnerSay("Notecard info request at " + (string)intInfoCount + ".");
}
else if(message == "remove"){
keyHttpVendorRegistration = llHTTPRequest(strRemoveVendorPage, [HTTP_METHOD,"PUT"],"");
llOwnerSay("I took myself off your vendor list.");
}
else if(message == "reciept"){

integer intRecieptIndex = 0;

llOwnerSay("Current Reciepts in Waitlist:\n");
for(intRecieptIndex = 0;intRecieptIndex < intWaitList;intRecieptIndex++){

llOwnerSay(llList2String(strDatabase,intRecieptIndex));

}

}
else if(message == "debug"){

if(blnDebug == 1){

blnDebug = 0;

}
else{

blnDebug = 1;

}

}
else if(message == "reset"){ //script wants to be reset get pending users before reseting

integer intRecieptIndex = 0;

llOwnerSay("Reciepts in Waitlist Before Reset:\n");
for(intRecieptIndex = 0;intRecieptIndex < intWaitList;intRecieptIndex++){

llOwnerSay(llList2String(strDatabase,intRecieptIndex));

}

llResetScript();

}
else{
llOwnerSay("I dunno what youre talking about.");
}
}

}

}
Ilobmirt Tenk
Registered User
Join date: 4 Jun 2007
Posts: 135
FOSSLDisplayModule.lsl
10-02-2007 03:53
CODE

//---------------------------------------------------------------------------------//
//Copyright Info Below... Please Do not Remove //
//---------------------------------------------------------------------------------//

//(c)2007 Ilobmirt Tenk

//This file is part of the FOSSL Vendor Project

// FOSSL Vendor 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 3 of the License, or
// (at your option) any later version.

// FOSSL Vendor is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.

// You should have received a copy of the GNU General Public License
// along with this program. If not, see <http://www.gnu.org/licenses/>.

//---------------------------------------------------------------------------------//
//Copyright Info Above... Please Do not Remove //
//---------------------------------------------------------------------------------//

integer intParam = 0;

default
{
on_rez(integer start_param){

intParam = start_param;
if(intParam == 0){

llDie();

}
else{

llListen(-88,"",NULL_KEY,"reload");
llTargetOmega(<0,0,1>,3.14159,1);

}

}

changed(integer change){

if(intParam = 0){

llDie();

}

}

listen(integer channel, string name, key id, string message)
{

llDie();

}

}
Ilobmirt Tenk
Registered User
Join date: 4 Jun 2007
Posts: 135
FOSSLGiftCardInfoStorage.lsl
10-02-2007 03:54
CODE

//---------------------------------------------------------------------------------//
//Copyright Info Below... Please Do not Remove //
//---------------------------------------------------------------------------------//

//(c)2007 Ilobmirt Tenk

//This file is part of the FOSSL Vendor Project

// FOSSL Vendor 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 3 of the License, or
// (at your option) any later version.

// FOSSL Vendor is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.

// You should have received a copy of the GNU General Public License
// along with this program. If not, see <http://www.gnu.org/licenses/>.

//---------------------------------------------------------------------------------//
//Copyright Info Above... Please Do not Remove //
//---------------------------------------------------------------------------------//

key keyBuyer; //Key of the person whom activated it
string strSalesId = ""; //Id of the sale of the activated gift
string strItem = ""; //Name of the object being gifted

integer blnActivated = 0; //determines if giftcard has been activated
integer blnRedeemed = 0; //determines if giftcard has been redeemed



default
{

//Gives info to the other script in the prim upon request
link_message(integer sender_num, integer num, string str, key id){

//respond only to commands given by the prim its in
if(sender_num == llGetLinkNumber() && num == 1){ //if it requests info

llMessageLinked(LINK_THIS,2,(string)blnActivated+"#"+(string)blnRedeemed+"#"+(string)keyBuyer+"#"+strSalesId+"#"+strItem,NULL_KEY);

}
else if(sender_num == llGetLinkNumber() && num == 3){ //if it wants to save data

list lstRecord = llParseString2List(str,["#"],[]);

keyBuyer = llList2Key(lstRecord,2);
strSalesId = llList2String(lstRecord,3);
strItem = llList2String(lstRecord,4);

blnActivated = llList2Integer(lstRecord,0);
blnRedeemed = llList2Integer(lstRecord,1);

llOwnerSay("Data Saved.");

}
else if(sender_num == llGetLinkNumber() && num == 5){//if it wants to e-mail data

llEmail((string)id+"@lsl.secondlife.com","Requesting Redemption",str);

}
else{

//do nothing

}

}

}
Ilobmirt Tenk
Registered User
Join date: 4 Jun 2007
Posts: 135
FOSSLGiftcardMain.lsl
10-02-2007 03:55
CODE

//---------------------------------------------------------------------------------//
//Copyright Info Below... Please Do not Remove //
//---------------------------------------------------------------------------------//

//(c)2007 Ilobmirt Tenk

//This file is part of the FOSSL Vendor Project

// FOSSL Vendor 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 3 of the License, or
// (at your option) any later version.

// FOSSL Vendor is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.

// You should have received a copy of the GNU General Public License
// along with this program. If not, see <http://www.gnu.org/licenses/>.

//---------------------------------------------------------------------------------//
//Copyright Info Above... Please Do not Remove //
//---------------------------------------------------------------------------------//

//Define global variables here

//---------------------------------------------------------------------------------//
//These variables are transfered to/from info the infoMe script //
//---------------------------------------------------------------------------------//
key keyBuyer; //Key of the person whom activated it
string strSalesId = ""; //Id of the sale of the activated gift
string strItem = ""; //Name of the object being gifted

integer blnActivated = 0; //determines if giftcard has been activated
integer blnRedeemed = 0; //determines if giftcard has been redeemed
//---------------------------------------------------------------------------------//

//---------------------------------------------------------------------------------//
//These global variables will not be transfered to the infoMe script //
//---------------------------------------------------------------------------------//
integer intTimer = 0; //time keeper
integer blnIsBusy = 0; //If the vendor is busy activating/redeeming
integer blnIsChosen = 0; //When activating, if it hears something from the vendor, will it ignore the vendors reply that its busy because it previously been chosen?
integer intListen = 0 ; //The channel in which this object looks for vendor responses
integer blnLookInEmail = 0; //Is the card required to look at its email while it is activating?
key keyVendor = NULL_KEY; //The key of the vendor Activating/Redeeming
key keyHttpResponse = NULL_KEY; //The key of an http response to your server
integer intCardRequestChannel = -2007; //channel in which to speak.
integer intReplyChannel = -1998; //channel in which to listen for a reply
string strSkipList = "";
//---------------------------------------------------------------------------------//

//=================================================================//
//Customize the following variables
//=================================================================//

string strHttpGetVendorPage = ""; //fill this in to define where card will ask for a vendor uuid

string strYourUUID = ""; //This is your own UUID

//=================================================================//
//Customize the above variables
//=================================================================//

//create a function to backup the data after activation and redemption
saveInfo(){

llMessageLinked(LINK_THIS,3,(string)blnActivated+"#"+(string)blnRedeemed+"#"+(string)keyBuyer+"#"+strSalesId+"#"+strItem,NULL_KEY);

}

//create a function that asks for redemption from a given vendor

redeemCard(){

llMessageLinked(LINK_THIS,5,(string)keyBuyer+"#"+(string)llGetOwner()+"#"+strSalesId+"#"+strItem,keyVendor);

}

//create a function that asks for a vendor to redeem from
getVendor(){

keyHttpResponse = llHTTPRequest(strHttpGetVendorPage,[HTTP_METHOD, "POST", HTTP_MIMETYPE, "application/x-www-form-urlencoded"], "salesID="+strSalesId+"&skipList="+strSkipList);

}


//This is the state in which this giftcard will start out in
//This script will reset upon rezzing and then load variables from another script
//Based upon the retrieved values, this script will change states

default
{

//Ask for the variable values from another script
state_entry(){

llSetText("",<0.0,0.0,0.0>,0.0); // clear all floating text
llSetSitText("");
llSitTarget(<0, 0, 0.1>, ZERO_ROTATION); // needed for llAvatarOnSitTarget to work
llMessageLinked(LINK_THIS,1,"Need Info.",NULL_KEY);
llSetTimerEvent(10.0); //If card couldn't initialize before 10 seconds are up, you know you have a problem
llOwnerSay("Giftcard initializing... Please wait.");

}

//Whenever this object rezzes, reset this script. Important for determining the current owner as this object passes between people's hands
on_rez(integer start_param){

llResetScript();

}

//Recieve variable values from another script
link_message(integer sender_num, integer num, string str, key id){

//respond only to commands given by the prim its in
if(sender_num == llGetLinkNumber() && num == 2){ //if it requests info

//Load the recieved data
list lstRecord = llParseString2List(str,["#"],[]);

key keyBuyer = llList2Key(lstRecord,2);
string strSalesId = llList2String(lstRecord,3);
string strItem = llList2String(lstRecord,4);

integer blnActivated = llList2Integer(lstRecord,0);
integer blnRedeemed = llList2Integer(lstRecord,1);
llOwnerSay("Giftcard Initialized!");

//based upon what settings blnActivated and blnRedeemed are at, either activate the card, redeem the card, or destroy the card
if(blnActivated == 0){

//This card isn't activated, activate the card now
state Activation;

}
else{

if(blnRedeemed == 0){

//This card isn't redeemed, redeem the card now
state Redemption;

}
else{

//This card has outlived its usefulness
llOwnerSay("This giftcard has expired. If this object hasn't deleted itself. It's best to remove this object manually.");

}

}

}

}

timer(){

//It took too long to retrieve information. Something must be wrong
llSetTimerEvent(0.0);

llOwnerSay("ERROR: Initialization timeout. Giftcard couldn't retrieve needed data within a certain time.");

}

}

//This state is in charge of activating the giftcard
//When information retrieval is successfull, save the data in another script
state Activation{

state_entry(){

llOwnerSay("Giftcard is activating. Please don't return giftcard until activation is over.");
intTimer = llGetUnixTime();
llSetTimerEvent(1.0);
intListen = llListen(intReplyChannel,"",NULL_KEY,""); //listen to the replies of any vendor
llSay(intCardRequestChannel,(string)llGetOwner()); //Make a request to activate from a nearby vendor


}

//Whenever this object rezzes, reset this script. Important for determining the current owner as this object passes between people's hands
on_rez(integer start_param){

llResetScript();

}

//This event will trigger whenever a vendor replies to the giftcard's requests for activation
listen(integer channel, string name, key id, string message){

//Don't let fake vendors feed you fake information, only the real vendors are owned by Yourself
if((string) llGetOwnerKey(id) == strYourUUID){

//If Vendor hasn't yet chosen this giftcard for activation, listen for it
if(blnIsChosen == 0){

//congratulations! The vendor chose to activate your card
if(message = "Success:"+(string)llGetKey()){

blnIsChosen = 1; //Gifcard now knows that it has been chosen it will wait till vendor gives the giftcard its info
blnIsBusy = 0; //Giftcard no longer has to wait a while till it can be activated
keyVendor = id; //Know where you'll be recieving your e-mail addresses from to get your data
intTimer = llGetUnixTime(); //reset countdown timer
llOwnerSay("Vendor has heard your giftcard's request for activation and is now in the process of activating it.");

}
//did it say it was busy?
else if("Busy:"+(string)llGetKey()){

blnIsBusy = 1; //Giftcard might have to wait a while till it can be activated
intTimer = llGetUnixTime(); //reset countdown timer
llOwnerSay("Vendor appears to be busy activating another giftcard");

}

}
//Vendor chose this giftcard. Wait till vendor returns with either the data or the error
else{

//Offworld dataabase had saved activation data
if(message == "Card has been activated!" && id == keyVendor){

llOwnerSay("Activation data has been saved to the server.\nWaiting to recieve activation data via, e-mail.");
blnLookInEmail = 1; //time for the giftcard to look at its e-mail
intTimer = llGetUnixTime(); //reset countdown timer

}
//Vendor returned with an error
else if( llGetSubString(message,0,llStringLength("ERROR:")-1) == "ERROR:" && id == keyVendor){

llOwnerSay(message);
llSetText("!!!ERROR!!!",<1.0,0.0,0.0>,1.0);
llSetTimerEvent(0.0); //stop timer events

}

}

}

}

//This event will trigger every second
//depending on how long it has been since the last intTime set, it will either update the floating text, or timeout
timer(){

//Is the vendor busy?
if(blnIsBusy == 1){

if((10-(llGetUnixTime()-intTimer))>=0){

llSetText("Vendor Busy:\nActivating in "+(string)(10-(llGetUnixTime()-intTimer))+" ...",<0.0,1.0,0.0>,1.0);

}
else{

llSay(intCardRequestChannel,(string)llGetOwner()); //Make a request to activate from a nearby vendor
blnIsBusy = 0;

}

}
else{

//show pretty animated text cycling between red, white, and blue.
if(llGetUnixTime()%3 == 0){

llSetText("Activating...",<0.0,0.0,1.0>,1.0);

}
else if(llGetUnixTime()%3 == 2){

llSetText("Activating..",<1.0,1.0,1.0>,1.0);

}
else{

llSetText("Activating.",<1.0,0.0,0.0>,1.0);

}
//////////////////////////////////////////////////

//If the giftcard has been chosen, it is given 10 seconds to first recieve acknoledgement that data has been retrived on the vendor.The next ten seconds are for recieving the data via, e-mail
if(blnIsChosen == 1 && (llGetUnixTime() - intTimer) <= 30){

llSetText("Vendor Activating:\nTimeout in "+(string)(30-(llGetUnixTime()-intTimer))+" ...",<1.0,1.0,1.0>,1.0);
if(blnLookInEmail == 1){

//check for e-mail from only the activating vendor and only if the message title says activation is a success
llGetNextEmail((string)keyVendor+"@lsl.secondlife.com","Activation Success");

}

}
//vendor failed to get activatin data in a reasonable time. End requesting for data
else if(blnIsChosen == 1 && (llGetUnixTime() - intTimer) > 30){

llSetText("!!!Vendor Timed Out!!!",<1.0,0.0,0.0>,1.0);
llSetTimerEvent(0.0); //stop timer events

}

}

}

//This event is triggered after the vendor recieves data from your server and sends that data to this object
email(string time, string address, string subj, string message, integer num_left){

list lstRecord = llParseString2List(llDeleteSubString(message, 0, llSubStringIndex(message, "\n\n") + 1),["#"],[]);

keyBuyer = llList2Key(lstRecord,0);
strSalesId = llList2String(lstRecord,2);
strItem = llList2String(lstRecord,3);
//Remove the string "(GIFT)" out of the item name if it exists
if(llSubStringIndex(strItem,"(GIFT)") != -1){

strItem = llGetSubString(strItem,0,-(1+llStringLength("(GIFT)")));

}
blnActivated = 1;

llSetObjectName("Giftcard for a "+strItem);
llSetTimerEvent(0.0);
llListenRemove(intListen);
llSetText("!!!ACTIVATED!!!",<1.0,1.0,1.0>,1.0);

saveInfo();

llOwnerSay("Data has been retrieved. Card is now activated.\n You may now return this giftcard to your inventory.");

}

}

//This state is in charge of redeeming the giftcard
//When all is said and done, make sure that this card is destroyed to prevent possible exploits
state Redemption{

state_entry(){

llMessageLinked(LINK_THIS,1,"Need Info.",NULL_KEY);
llSetSitText("Redeem");
intTimer = llGetUnixTime();
llSetTimerEvent(0.0); //don't start countdown till user sits on it

}

//Recieve variable values from another script
link_message(integer sender_num, integer num, string str, key id){

//respond only to commands given by the prim its in
if(sender_num == llGetLinkNumber() && num == 2){ //if it requests info

//Load the recieved data
list lstRecord = llParseString2List(str,["#"],[]);

keyBuyer = llList2Key(lstRecord,2);
strSalesId = llList2String(lstRecord,3);
strItem = llList2String(lstRecord,4);

blnActivated = llList2Integer(lstRecord,0);
blnRedeemed = llList2Integer(lstRecord,1);

llOwnerSay("Giftcard is ready to redeem itself for a "+strItem+". Right Click, and then select \"Redeem\" to start the proccess.");

}

}

//Whenever this object rezzes, reset this script. Important for determining the current owner as this object passes between people's hands
on_rez(integer start_param){

llResetScript();

}

//This is triggered when the avatar sits on top of the notecard. Instead of sitting, the avatar will request redemption
changed(integer change){

//If an avatar tries to redeem the card...
if(change & CHANGED_LINK){

//If it was caused by the owner, redeem the object
if(llAvatarOnSitTarget() == llGetOwner() && blnIsBusy == 0){

llOwnerSay("Redeeming... Please wait...");
llSetTimerEvent(1.0);
blnIsBusy = 1;
strSkipList = "";
getVendor();
intTimer = llGetUnixTime();

}

llUnSit(llAvatarOnSitTarget()); //unsit whomever is on the card

}

}

//This event will trigger every second
//depending on how long it has been since the last intTime set, it will either update the floating text, or timeout
timer(){

if(llGetUnixTime() - intTimer <= 60){

llSetText("Vendor Redeeming:\nTimeout in "+(string)(60-(llGetUnixTime()-intTimer))+" ...",<1.0,1.0,1.0>,1.0);
llGetNextEmail((string)keyVendor+"@lsl.secondlife.com","");

}
else if(llGetUnixTime() - intTimer > 60){

llSetText("!!!Vendor Timed Out!!!",<1.0,0.0,0.0>,1.0);
llSetTimerEvent(0.0); //stop timer events

}

}

//This event is triggered after the vendor recieves data from your server and sends that data to this object
email(string time, string address, string subj, string message, integer num_left){

key keyAddressID = llList2Key(llParseString2List(address,["@lsl.secondlife.com"],[]),0);
string strRecord = llDeleteSubString(message, 0, llSubStringIndex(message, "\n\n") + 1);

//if the vendor is busy redeeming
if(subj == "Busy Redeeming"){

//If there were no vendors to skip before
if(strSkipList == ""){

strSkipList += (string) keyVendor;

}
else{

strSkipList += "#"+(string) keyVendor;

}

llOwnerSay("The current vendor appears to be busy.\nMoving on to next vendor...");
getVendor();
intTimer = llGetUnixTime();

}
else if(subj == "Error Redeeming Card"){

llSetText("!!!ERROR!!!",<1.0,0.0,0.0>,1.0);
llOwnerSay("There appears to be an error from within the server.\nServer response :\n"+strRecord);
llSetTimerEvent(0.0); //stop timer events

}
//congratulations! You've been successfull redeeming the giftcard!
else if(subj == "Redeeming Card Successfull"){

llSetText("!!!REDEEMED!!!",<1.0,1.0,1.0>,1.0);
llSetTimerEvent(0.0);
blnRedeemed = 1;
saveInfo();
llOwnerSay("Congratulations! Redeeming this giftcard appears to be successfull! Hold on while your gift is shipped to you!");
//If this object is attached, consider detaching it before removal
if(llGetAttached() != 0){

llDetachFromAvatar();

}
llDie(); // time to die >:D


}

}

//This event is triggered after requesting for a vendor id to get an object from
http_response(key request_id, integer status, list metadata, string body){

//If the http response was due to requesting a vendor id...
if(request_id == keyHttpResponse){

//If the server is up...
if(status >= 200 && status<= 206){ //good http error messages

//If message results in pointing to a vendor id
if(llStringLength(body) == llStringLength("********-****-****-****-************") && llGetListLength(llParseString2List(body,["-"],[])) == 5){ // check string

//we got ourselves a vendor to talk to
keyVendor = (key) body;
llOwnerSay("Server found a vendor to redeem giftcard at. Requesting redemption...");
redeemCard();
intTimer = llGetUnixTime();

}
else if(llStringLength(body) != 0){ // must be an error message from the server

llSetText("!!!ERROR!!!",<1.0,0.0,0.0>,1.0);
llOwnerSay("There appears to be an error from within the server.\nServer response :\n"+body);
llSetTimerEvent(0.0); //stop timer events

}
else{ //Must be because there are no vendors ready to redeem giftcards

llSetText("!!!All Vendors Busy!!!",<1.0,0.0,0.0>,1.0);
llOwnerSay("All the vendors appear to be busy at this time. Consider Re-trying at a later time.");
blnIsBusy = 0;
llSetTimerEvent(0.0); //stop timer events

}

}
else{

llSetText("!!!Server Down!!!",<1.0,0.0,0.0>,1.0);
llOwnerSay("The server appears to be down at this time.\n Consider waiting till it comes back online to redeem this giftcard.");
llSetTimerEvent(0.0); //stop timer events

}

}

}

}
Ilobmirt Tenk
Registered User
Join date: 4 Jun 2007
Posts: 135
FOSSLVendorRegistration.php
10-02-2007 03:57
CODE

<?



//---------------------------------------------------------------------------------//

//Copyright Info Below... Please Do not Remove //

//---------------------------------------------------------------------------------//



//(c)2007 Ilobmirt Tenk



//This file is part of the FOSSL Vendor Project



// FOSSL Vendor 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 3 of the License, or

// (at your option) any later version.



// FOSSL Vendor is distributed in the hope that it will be useful,

// but WITHOUT ANY WARRANTY; without even the implied warranty of

// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the

// GNU General Public License for more details.



// You should have received a copy of the GNU General Public License

// along with this program. If not, see <http://www.gnu.org/licenses/>.



//---------------------------------------------------------------------------------//

//Copyright Info Above... Please Do not Remove //

//---------------------------------------------------------------------------------//



//Add a vendor to the vendors.txt database



// Only works with PHP compiled as an Apache module

$headers = apache_request_headers();



$objectName = $headers["X-SecondLife-Object-Name"];

$objectKey = $headers["X-SecondLife-Object-Key"];//required for adding to the database

$ownerKey = $headers["X-SecondLife-Owner-Key"]; //required for verification

$ownerName = $headers["X-SecondLife-Owner-Name"];

$region = $headers["X-SecondLife-Region"];

$slVersion = $headers["User-Agent "];

$simPosition = $headers["X-SecondLife-Local-Position"];



//If the vendor's owner is from yourself, it must be a real vendor



if($ownerKey == "********-****-****-****-************"){



//Verify if the vendor wasn't already in the vendors.txt database

$vendorFound = false; //initialize as false, then make it true when found

//get the whole vendors file into an array for fast searching

$vendorsFile = file('./vendors.txt');

foreach($vendorsFile as $index_num => $index_value){



$vendorArrayID = explode("#",$index_value);



if($objectKey == $vendorArrayID[0]){



$vendorFound = true;

break;



}



}





//If this is a new addition, add this vendor id to the database

if($vendorFound == false){



$vendorsFile = fopen("./vendors.txt","a");

fwrite($vendorsFile,$objectKey."#".time()."\n");

fclose($vendorsFile);



}

else{



echo "Oops. Your already on the list.";



}



}

else{



echo "You're not my object. GET OUT OF MY SERVER!!!";



//report the incident

$reportFile = fopen("./WARNING.log","a");

fwrite($reportFile,"AddVendor.php -\n");

fwrite($reportFile,$ownerName." tried to ADD a fake vendor to \"./vendors.txt\" with an object named ".$objectName.".\n");

fwrite($reportFile,"Other info about the incident contains :\n");

fwrite($reportFile,"object key - ".$objectKey."\n");

fwrite($reportFile,"owner key - ".$ownerKey."\n");

fwrite($reportFile,"region - ".$region."\n");

fwrite($reportFile,"location within region - ".$simPosition."\n");

fwrite($reportFile,"Version of sl viewer - ".$slVersion."\n");

fwrite($reportFile,"time - ".date("l dS \of F Y h:i:s A e")."\n\n\n");

fclose($reportFile);



}



?>
Ilobmirt Tenk
Registered User
Join date: 4 Jun 2007
Posts: 135
FOSSLVendorDeRegistration.php
10-02-2007 03:58
CODE

<?



//---------------------------------------------------------------------------------//

//Copyright Info Below... Please Do not Remove //

//---------------------------------------------------------------------------------//



//(c)2007 Ilobmirt Tenk



//This file is part of the FOSSL Vendor Project



// FOSSL Vendor 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 3 of the License, or

// (at your option) any later version.



// FOSSL Vendor is distributed in the hope that it will be useful,

// but WITHOUT ANY WARRANTY; without even the implied warranty of

// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the

// GNU General Public License for more details.



// You should have received a copy of the GNU General Public License

// along with this program. If not, see <http://www.gnu.org/licenses/>.



//---------------------------------------------------------------------------------//

//Copyright Info Above... Please Do not Remove //

//---------------------------------------------------------------------------------//



//Remove a vendor to the vendors.txt database



// Only works with PHP compiled as an Apache module

$headers = apache_request_headers();



$objectName = $headers["X-SecondLife-Object-Name"];

$objectKey = $headers["X-SecondLife-Object-Key"];//required for removing from the database

$ownerKey = $headers["X-SecondLife-Owner-Key"]; //required for verification

$ownerName = $headers["X-SecondLife-Owner-Name"];

$region = $headers["X-SecondLife-Region"];

$slVersion = $headers["User-Agent "];

$simPosition = $headers["X-SecondLife-Local-Position"];



//If the vendor's owner is from yourself, it must be a real vendor



if($ownerKey == "********-****-****-****-************"){





//Verify if the vendor is in the vendors.txt database

$vendorFound = false; //initialize as false, then make it true when found

//get the whole vendors file into an array for fast searching

$vendorsFile = file('./vendors.txt');

foreach($vendorsFile as $index_num => $index_value){



$vendorArrayID = explode("#",$index_value);



if($objectKey == $vendorArrayID[0]){



$vendorFound = true;

break;



}



}



//If found, remove vendor from the database vendors.txt and make note of it in RetiredVendors-YYYY-MM.txt

if($vendorFound == true){



$newVendorsFile = array();

foreach($vendorsFile as $index_num => $index_value){



$vendorArrayID = explode("#",$index_value);



//vendor not found. Add to new list

if($objectKey != $vendorArrayID[0]){



$newVendorsFile[$index_num]=$index_value;



}

//vendor found. Append to RetiredVendors-YYYY-MM.txt

else{



$retiredFile=fopen("./RetiredVendors-".date("Y-m").".txt","a");

fwrite($retiredFile,$vendorArrayID[0]."#".$vendorArrayID[1]."#".time()."\n");

fclose($retiredFile);



}



}



//write the new list to the file vendors.txt

$newVFile = fopen("./vendors.txt","w");

foreach($newVendorsFile as $index_num => $index_value){



fwrite($newVFile,$index_value);



}

fclose($newVFile);



}

else{



echo "I can't remove something that doesn't exist";



}



}

else{



echo "You're not my object. GET OUT OF MY SERVER!!!";



//report the incident

$reportFile = fopen("./WARNING.log","a");

fwrite($reportFile,"RemoveVendor.php -\n");

fwrite($reportFile,$ownerName." tried to REMOVE a legitimate vendor from \"./vendors.txt\" with an object named ".$objectName.".\n");

fwrite($reportFile,"Other info about the incident contains :\n");

fwrite($reportFile,"object key - ".$objectKey."\n");

fwrite($reportFile,"owner key - ".$ownerKey."\n");

fwrite($reportFile,"region - ".$region."\n");

fwrite($reportFile,"location within region - ".$simPosition."\n");

fwrite($reportFile,"Version of sl viewer - ".$slVersion."\n");

fwrite($reportFile,"time - ".date("l dS \of F Y h:i:s A e")."\n\n\n");

fclose($reportFile);



}



?>
Ilobmirt Tenk
Registered User
Join date: 4 Jun 2007
Posts: 135
FOSSLVendorObtainUUID.php
10-02-2007 03:59
CODE

<?



//---------------------------------------------------------------------------------//

//Copyright Info Below... Please Do not Remove //

//---------------------------------------------------------------------------------//



//(c)2007 Ilobmirt Tenk



//This file is part of the FOSSL Vendor Project



// FOSSL Vendor 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 3 of the License, or

// (at your option) any later version.



// FOSSL Vendor is distributed in the hope that it will be useful,

// but WITHOUT ANY WARRANTY; without even the implied warranty of

// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the

// GNU General Public License for more details.



// You should have received a copy of the GNU General Public License

// along with this program. If not, see <http://www.gnu.org/licenses/>.



//---------------------------------------------------------------------------------//

//Copyright Info Above... Please Do not Remove //

//---------------------------------------------------------------------------------//



//Get a vendor from the vendors.txt database



// Only works with PHP compiled as an Apache module

$headers = apache_request_headers();



$objectName = $headers["X-SecondLife-Object-Name"];

$objectKey = $headers["X-SecondLife-Object-Key"];//required for adding to the database

$ownerKey = $headers["X-SecondLife-Owner-Key"]; //required for verification

$ownerName = $headers["X-SecondLife-Owner-Name"];

$region = $headers["X-SecondLife-Region"];

$slVersion = $headers["User-Agent "];

$simPosition = $headers["X-SecondLife-Local-Position"];



// get things from $_POST[]

$strSalesID = $_POST["salesID"];

$strVendorSkipList = $_POST["skipList"];



//find out if the object has been bought and activated

$giftcardBought = false; //initialize as false, then make it true when found in Sales.txt

$giftcardActivated = false; //initialize as false, then make it true when found in ActivatedCards.txt

$giftcardRedeemed = false; //initialize as false, then make it true when found in RedeemedCards.txt



//get the whole sales, Activated Card, and Redeemed Card file into an array for fast searching



//Record = vendor ID, buyer ID, buyer name, object name, object price, sale date, sale time, unix time, sale ID

$salesFile = file('./sales.txt');

//Record = vendor ID, activator ID, Activator name, activation time, sale ID

$activatedFile = file('./ActivatedCards.txt');

//Record = vendor ID, Redeemer ID, Redeemer name, Redemption time, sale ID

$redeemedFile = file('./RedeemedCards.txt');



foreach($salesFile as $index_num => $index_value){



$salesArrayID = explode("#",$index_value);



if($strSalesID == $salesArrayID[8]){



$giftcardBought = true;

break;



}



}



foreach($activatedFile as $index_num => $index_value){



$activatedArrayID = explode("#",$index_value);



if($strSalesID == $activatedArrayID[4]){



$giftcardActivated = true;

break;



}



}



foreach($redeemedFile as $index_num => $index_value){



$redeemedArrayID = explode("#",$index_value);



if($strSalesID == $redeemedArrayID[4]){



$giftcardRedeemed = true;

break;



}



}



//If the card has been bought, activated, but not redeemed, proceed to give a vendor id that's not on the skip list



if($giftcardBought == true){



if($giftcardActivated == true){



if($giftcardRedeemed == false){



//everything is ok, proceed to get a vendor ID



//insert vendor id read here

$vendorFound = false; //initialize as false, then make it true when found

//get the whole vendors file into an array for fast searching

$vendorsFile = file('./vendors.txt');

$skipList = explode("#",$strVendorSkipList);

foreach($vendorsFile as $index_num => $index_value){



$vendorArrayID = explode("#",$index_value);

$vendorFound = true;



foreach($skipList as $skip_index => $skip_value){



if($vendorArrayID[0] == $skip_value){



$vendorFound = false;



}



}



if($vendorFound == true){



echo $vendorArrayID[0];

break;



}



}





}

else{



echo "It appears to me that this giftcard has already been redeemed.\nIn order to make a request for a server that will redeem your giftcard, your giftcard must not be already redeemed./nIf this is in error, please send an Issue report stating your problem.\nPlease note that this event has been recorded and will be used to verify your claims.";



//report the incident

$reportFile = fopen("./WARNING.log","a");

fwrite($reportFile,$ownerName." tried to OBTAIN a vendor id from \"./vendors.txt\" with an object named ".$objectName.".\n");

fwrite($reportFile,"Other info about the incident contains :\n");

fwrite($reportFile,"Nature of Incident - someone was trying to reedem a card that was already redeemd. Could someone have forged a giftcard and redeemed that before the intended buyer redeemed his/her real giftcard?");

fwrite($reportFile,"object key - ".$objectKey."\n");

fwrite($reportFile,"owner key - ".$ownerKey."\n");

fwrite($reportFile,"region - ".$region."\n");

fwrite($reportFile,"location within region - ".$simPosition."\n");

fwrite($reportFile,"Version of sl viewer - ".$slVersion."\n");

fwrite($reportFile,"time - ".date("l dS \of F Y h:i:s A e")."\n\n\n");

fclose($reportFile);



}



}

else{



echo "It appears to me that this gift card isn't activated.\nIn order to make a request for a vendor that will redeem your giftcard, you must first purchase something and then activate your giftcard./nIf this is in error, please send an Issue report stating your problem.\nPlease note that this event has been recorded and will be used to verify your claims.";



//report the incident

$reportFile = fopen("./WARNING.log","a");

fwrite($reportFile,$ownerName." tried to OBTAIN a vendor id from \"./vendors.txt\" with an object named ".$objectName.".\n");

fwrite($reportFile,"Other info about the incident contains :\n");

fwrite($reportFile,"Nature of Incident - giftcard uses a sales ID doesn't exist in ActivatedCards.txt but exists in sales.txt. It could be forged.");

fwrite($reportFile,"object key - ".$objectKey."\n");

fwrite($reportFile,"owner key - ".$ownerKey."\n");

fwrite($reportFile,"region - ".$region."\n");

fwrite($reportFile,"location within region - ".$simPosition."\n");

fwrite($reportFile,"Version of sl viewer - ".$slVersion."\n");

fwrite($reportFile,"time - ".date("l dS \of F Y h:i:s A e")."\n\n\n");

fclose($reportFile);



}



}

else{



echo "It appears to me that you haven't bought one of our products.\nIn order to make a request for a vendor that will redeem your giftcard, you must first purchase something and then activate your giftcard./nIf this is in error, please send an Issue report stating your problem.\nPlease note that this event has been recorded and will be used to verify your claims.";



//report the incident

$reportFile = fopen("./WARNING.log","a");

fwrite($reportFile,$ownerName." tried to OBTAIN a vendor id from \"./vendors.txt\" with an object named ".$objectName.".\n");

fwrite($reportFile,"Other info about the incident contains :\n");

fwrite($reportFile,"Nature of Incident - giftcard uses a sales ID doesn't exist. It could be forged.");

fwrite($reportFile,"object key - ".$objectKey."\n");

fwrite($reportFile,"owner key - ".$ownerKey."\n");

fwrite($reportFile,"region - ".$region."\n");

fwrite($reportFile,"location within region - ".$simPosition."\n");

fwrite($reportFile,"Version of sl viewer - ".$slVersion."\n");

fwrite($reportFile,"time - ".date("l dS \of F Y h:i:s A e")."\n\n\n");

fclose($reportFile);



}



?>
Ilobmirt Tenk
Registered User
Join date: 4 Jun 2007
Posts: 135
FOSSLVendorSalesRegistration.php
10-02-2007 04:00
CODE

<?



//---------------------------------------------------------------------------------//

//Copyright Info Below... Please Do not Remove //

//---------------------------------------------------------------------------------//



//(c)2007 Ilobmirt Tenk



//This file is part of the FOSSL Vendor Project



// FOSSL Vendor 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 3 of the License, or

// (at your option) any later version.



// FOSSL Vendor is distributed in the hope that it will be useful,

// but WITHOUT ANY WARRANTY; without even the implied warranty of

// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the

// GNU General Public License for more details.



// You should have received a copy of the GNU General Public License

// along with this program. If not, see <http://www.gnu.org/licenses/>.



//---------------------------------------------------------------------------------//

//Copyright Info Above... Please Do not Remove //

//---------------------------------------------------------------------------------//



// Only works with PHP compiled as an Apache module

$headers = apache_request_headers();



$objectName = $headers["X-SecondLife-Object-Name"];

$objectKey = $headers["X-SecondLife-Object-Key"];

$ownerKey = $headers["X-SecondLife-Owner-Key"];

$ownerName = $headers["X-SecondLife-Owner-Name"];

$region = $headers["X-SecondLife-Region"];

$slVersion = $headers["User-Agent "];

$simPosition = $headers["X-SecondLife-Local-Position"];



// and so on for getting all the other variables ...



// get things from $_POST[]

// this will create a record for flat file storage

$buyerKey = $_POST["buyerKey"];

$buyerName = $_POST["buyerName"];

$objectSold = $_POST["objectSold"];

$objectPrice = $_POST["objectPrice"];

$saleDate = $_POST["saleDate"];

$saleTime = $_POST["saleTime"];

//create a sale key based off the time

$saleKeyPart1 = implode("",explode("-",$saleDate));

$saleKeyPart2 = implode("",explode(":",$saleTime));

$saleKeyPart3 = $saleKeyPart1.$saleKeyPart2;

$saleKeyPart4 = intval($saleKeyPart3);

$saleKey = md5($saleKeyPart3);





//insert vendor id read here

$vendorFound = false; //initialize as false, then make it true when found

//get the whole vendors file into an array for fast searching

$vendorsFile = file('./vendors.txt');

foreach($vendorsFile as $index_num => $index_value){



$vendorArrayID = explode("#",$index_value);



if($objectKey == $vendorArrayID[0]){



$vendorFound = true;

break;



}



}





//write to a sales file if the owner of the object is Ilobmirt Tenk

if($ownerName == "Ilobmirt Tenk" and $ownerKey == "********-****-****-****-************" and $vendorFound == true){



//open up a file called sales.txt

$salesFile = fopen('sales.txt','a');

//write to the file

fwrite($salesFile,$objectKey."#".$buyerKey."#".$buyerName."#".$objectSold."#".$objectPrice."#".$saleDate."#".$saleTime."#".time()."#".$saleKey."\n"); //vendor Id

/*fwrite($salesFile,"#");

fwrite($salesFile,$buyerKey); //buyer Id

fwrite($salesFile,"#");

fwrite($salesFile,$buyerName); //buyer name

fwrite($salesFile,"#");

fwrite($salesFile,$objectSold); //object Name

fwrite($salesFile,"#");

fwrite($salesFile,$objectPrice); //object Price

fwrite($salesFile,"#");

fwrite($salesFile,$saleDate); //sale Date

fwrite($salesFile,"#");

fwrite($salesFile,$saleTime); //sale Time

fwrite($salesFile,"#");

fwrite($salesFile,$saleKey); //sale Key

fwrite($salesFile,"\n");*/

//close the file

fclose($salesFile);



}

else{



echo "You're not my object. GET OUT OF MY SERVER!!!";



//report the incident

$reportFile = fopen("./WARNING.log","a");

fwrite($reportFile,"Sales.php -\n");

fwrite($reportFile,$ownerName." tried to ADD a fake reciept to \"./sales.txt\" with an object named ".$objectName.".\n");

fwrite($reportFile,"Other info about the incident contains :\n");

fwrite($reportFile,"object key - ".$objectKey."\n");

fwrite($reportFile,"owner key - ".$ownerKey."\n");

fwrite($reportFile,"region - ".$region."\n");

fwrite($reportFile,"location within region - ".$simPosition."\n");

fwrite($reportFile,"Version of sl viewer - ".$slVersion."\n");

fwrite($reportFile,"time - ".date("l dS \of F Y h:i:s A e")."\n\n\n");

fclose($reportFile);



}



?>
Ilobmirt Tenk
Registered User
Join date: 4 Jun 2007
Posts: 135
FOSSLVendorGetGiftcardReciept.php
10-02-2007 04:01
CODE

<?



//---------------------------------------------------------------------------------//

//Copyright Info Below... Please Do not Remove //

//---------------------------------------------------------------------------------//



//(c)2007 Ilobmirt Tenk



//This file is part of the FOSSL Vendor Project



// FOSSL Vendor 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 3 of the License, or

// (at your option) any later version.



// FOSSL Vendor is distributed in the hope that it will be useful,

// but WITHOUT ANY WARRANTY; without even the implied warranty of

// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the

// GNU General Public License for more details.



// You should have received a copy of the GNU General Public License

// along with this program. If not, see <http://www.gnu.org/licenses/>.



//---------------------------------------------------------------------------------//

//Copyright Info Above... Please Do not Remove //

//---------------------------------------------------------------------------------//



//gets a list of unactivated gift cards of one person and returns the result to the vendor



// Only works with PHP compiled as an Apache module

$headers = apache_request_headers();



$objectName = $headers["X-SecondLife-Object-Name"];

$objectKey = $headers["X-SecondLife-Object-Key"];

$ownerKey = $headers["X-SecondLife-Owner-Key"];

$ownerName = $headers["X-SecondLife-Owner-Name"];

$region = $headers["X-SecondLife-Region"];



// get things from $_POST[]

// this will obtain records from flat file storage

$buyerKey = $_POST["buyerKey"];

$buyerName = $_POST["buyerName"];





//determine if vendor is a part of the vendor's list

$vendorFound = false; //initialize as false, then make it true when found

//get the whole vendors file into an array for fast searching

$vendorsFile = file('./vendors.txt');

foreach($vendorsFile as $index_num => $index_value){



$vendorArrayID = explode("#",$index_value);



if($objectKey == $vendorArrayID[0]){



$vendorFound = true;

break;



}



}





//If the vendor came from myself and it registered like a good vendor should, it must be a real tenkwear vendor asking to get an unactivated card

if($ownerKey == "********-****-****-****-************" and $vendorFound == true){



$salesFile = file('./sales.txt');

$usersCards = array();

$usersUnactivatedCards = array();

$intUserRecords = 0;

$intUserUnactivated = 0;



//reduce records to those of the user

foreach($salesFile as $index_num => $index_line){



$lineElements = explode("#",$index_line);

$isGiftCard = substr($lineElements[3],-strlen("(GIFT)"),strlen("(GIFT)"));//strpos($lineElements[3],"(GIFT)");



if($buyerKey == $lineElements[1] and $buyerName == $lineElements[2] and $isGiftCard == "(GIFT)"){ //if the giftcard owner matches the buyer id on the record...



$usersCards[$intUserRecords] = $index_line; //record the record as a part of the users card purchases

//echo "Usercards[".$intUserRecords."]=".$usersCards[$intUserRecords];

$intUserRecords++;



}



}



//If there are no records of a user buying a gift card, end the script right here.

if($intUserRecords == 0){



echo "ERROR:No gift cards were bought.";

exit;



}



//reduce records to those the user hasn't activated

$activatedCards = file('./ActivatedCards.txt');



foreach($usersCards as $users_index => $users_line){



$blnActivated = false; // This will change to true if found within the records of registeredCards.txt

$userSale = explode("#",$users_line);

$strUserSaleId = $userSale[8];



foreach($activatedCards as $activated_index => $activated_line){



$registeredSale = explode("#",$activated_line);

$strRegisteredSaleId = $registeredSale[4];



if($strUserSaleId == $strRegisteredSaleId){ //card is known to be registered, dont include it in the next list



$blnActivated = true;

break;



}



}



if($blnActivated == false){ // if it has been determined that the card wasn't activated



$usersUnactivatedCards[$intUserUnactivated] = $users_line;

//echo "usersUnactivatedCards[".$intUserUnactivated."] = ".$usersUnactivatedCards[$intUserUnactivated];

$intUserUnactivated++;



}



}



//If there are no more unregistered gift cards, end the script right here

if($intUserUnactivated == 0){



echo "ERROR:No gift cards to activate.";

exit;



}



//echo out the record of the first gift that wasn't activated

$activationRecord = explode("#",$usersUnactivatedCards[0]);

//record = buyer Id, buyer Name, Sales ID, Object Name

echo $activationRecord[1]."#".$activationRecord[2]."#".$activationRecord[8]."#".$activationRecord[3];



}

else{



echo "You're not my object. GET OUT OF MY SERVER!!!";



//report the incident

$reportFile = fopen("./WARNING.log","a");

fwrite($reportFile,"GetCard.php -\n");

fwrite($reportFile,$ownerName." tried to GET a sales reciept from \"./sales.txt\" with an object named ".$objectName.".\n");

fwrite($reportFile,"Other info about the incident contains :\n");

fwrite($reportFile,"object key - ".$objectKey."\n");

fwrite($reportFile,"owner key - ".$ownerKey."\n");

fwrite($reportFile,"region - ".$region."\n");

fwrite($reportFile,"location within region - ".$simPosition."\n");

fwrite($reportFile,"Version of sl viewer - ".$slVersion."\n");

fwrite($reportFile,"time - ".date("l dS \of F Y h:i:s A e")."\n\n\n");

fclose($reportFile);



}



?>
Ilobmirt Tenk
Registered User
Join date: 4 Jun 2007
Posts: 135
FOSSLVendorGiftcardActivation.php
10-02-2007 04:01
CODE

<?



//---------------------------------------------------------------------------------//

//Copyright Info Below... Please Do not Remove //

//---------------------------------------------------------------------------------//



//(c)2007 Ilobmirt Tenk



//This file is part of the FOSSL Vendor Project



// FOSSL Vendor 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 3 of the License, or

// (at your option) any later version.



// FOSSL Vendor is distributed in the hope that it will be useful,

// but WITHOUT ANY WARRANTY; without even the implied warranty of

// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the

// GNU General Public License for more details.



// You should have received a copy of the GNU General Public License

// along with this program. If not, see <http://www.gnu.org/licenses/>.



//---------------------------------------------------------------------------------//

//Copyright Info Above... Please Do not Remove //

//---------------------------------------------------------------------------------//



// Only works with PHP compiled as an Apache module

$headers = apache_request_headers();



$objectName = $headers["X-SecondLife-Object-Name"];

$objectKey = $headers["X-SecondLife-Object-Key"];

$ownerKey = $headers["X-SecondLife-Owner-Key"];

$ownerName = $headers["X-SecondLife-Owner-Name"];

$region = $headers["X-SecondLife-Region"];

$slVersion = $headers["User-Agent "];

$simPosition = $headers["X-SecondLife-Local-Position"];



// and so on for getting all the other variables ...



// get things from $_POST[]

// this will create a record for flat file storage

$activatorKey = $_POST["activatorKey"];

$activatorName = $_POST["activatorName"];

$salesID = $_POST["salesID"];



//determine if vendor is a part of the vendor's list

$vendorFound = false; //initialize as false, then make it true when found

//get the whole vendors file into an array for fast searching

$vendorsFile = file('./vendors.txt');

foreach($vendorsFile as $index_num => $index_value){



$vendorArrayID = explode("#",$index_value);



if($objectKey == $vendorArrayID[0]){



$vendorFound = true;

break;



}



}





//If the vendor came from myself and it registered like a good vendor should, it must be a real tenkwear vendor asking to activate a card

if($ownerKey == "********-****-****-****-************" and $vendorFound == true){



//time to validate the owner and sales ID

//find out if the object has been bought, activated, and redeemed

$giftcardBought = false; //initialize as false, then make it true when found in Sales.txt

$giftcardBuyerMatch = false; //initialize as false, then make it true when found in Sales.txt

$giftcardActivated = false; //initialize as false, then make it true when found in ActivatedCards.txt

$giftcardRedeemed = false; //initialize as false, then make it true when found in RedeemedCards.txt



//get the whole sales, Activated Card, and Redeemed Card file into an array for fast searching



//Record = vendor ID, buyer ID, buyer name, object name, object price, sale date, sale time, unix time, sale ID

$salesFile = file('./sales.txt');

//Record = vendor ID, activator ID, Activator name, activation time, sale ID

$activatedFile = file('./ActivatedCards.txt');

//Record = vendor ID, Redeemer ID, Redeemer name, Redemption time, sale ID

$redeemedFile = file('./RedeemedCards.txt');



foreach($salesFile as $index_num => $index_value){



$salesArrayID = explode("#",$index_value);



if($salesID == $salesArrayID[8]){



$giftcardBought = true;

if($activatorKey == $salesArrayID[1] && $activatorName == $salesArrayID[2]){



$giftcardBuyerMatch = true;



}

break;



}



}



foreach($activatedFile as $index_num => $index_value){



$activatedArrayID = explode("#",$index_value);



if($salesID == $activatedArrayID[4]){



$giftcardActivated = true;

break;



}



}



foreach($redeemedFile as $index_num => $index_value){



$redeemedArrayID = explode("#",$index_value);



if($salesID == $redeemedArrayID[4]){



$giftcardRedeemed = true;

break;



}



}



//If giftcard has been bought, not activated or redeemed, add to the database ActivatedCards.txt

if($giftcardBought == true && $giftcardBuyerMatch == true){



if($giftcardActivated == false){



if($giftcardRedeemed == false){



//Alright! Time to activate

echo $salesID;

$activatedcardFile = fopen('./ActivatedCards.txt','a');

fwrite($activatedcardFile,$objectKey."#".$activatorKey."#".$activatorName."#".time()."#".$salesID);

fclose($activatedcardFile);



}

else{



echo "It appears to me that this giftcard has already been redeemed.\nIn order to activate your giftcard, your giftcard must not be redeemed./nIf this is in error, please send an Issue report stating your problem.\nPlease note that this event has been recorded and will be used to verify your claims.";



//report the incident

$reportFile = fopen("./WARNING.log","a");

fwrite($reportFile,"ActivateCard.php -\n");

fwrite($reportFile,$ownerName." tried to ADD a fake record to \"./ActivatedCards.txt\" with an object named ".$objectName.".\n");

fwrite($reportFile,"Other info about the incident contains :\n");

fwrite($reportFile,"Nature of Incident - someone was trying to activate a card that was redeemd. Possible Forgery of information.");

fwrite($reportFile,"object key - ".$objectKey."\n");

fwrite($reportFile,"owner key - ".$ownerKey."\n");

fwrite($reportFile,"region - ".$region."\n");

fwrite($reportFile,"location within region - ".$simPosition."\n");

fwrite($reportFile,"Version of sl viewer - ".$slVersion."\n");

fwrite($reportFile,"time - ".date("l dS \of F Y h:i:s A e")."\n\n\n");

fclose($reportFile);



}



}

else{



echo "It appears to me that this giftcard has already been activated.\nIn order to activate your giftcard, your giftcard must not be already activated./nIf this is in error, please send an Issue report stating your problem.\nPlease note that this event has been recorded and will be used to verify your claims.";



//report the incident

$reportFile = fopen("./WARNING.log","a");

fwrite($reportFile,"ActivateCard.php -\n");

fwrite($reportFile,$ownerName." tried to ADD a fake record to \"./ActivatedCards.txt\" with an object named ".$objectName.".\n");

fwrite($reportFile,"Other info about the incident contains :\n");

fwrite($reportFile,"Nature of Incident - someone was trying to activate a card that was activated. Possible Forgery of information.");

fwrite($reportFile,"object key - ".$objectKey."\n");

fwrite($reportFile,"owner key - ".$ownerKey."\n");

fwrite($reportFile,"region - ".$region."\n");

fwrite($reportFile,"location within region - ".$simPosition."\n");

fwrite($reportFile,"Version of sl viewer - ".$slVersion."\n");

fwrite($reportFile,"time - ".date("l dS \of F Y h:i:s A e")."\n\n\n");

fclose($reportFile);



}



}

else{



echo "It appears to me that this giftcard has not been purchased.\nIn order to activate your giftcard, you must first purchase something./nIf this is in error, please send an Issue report stating your problem.\nPlease note that this event has been recorded and will be used to verify your claims.";



//report the incident

$reportFile = fopen("./WARNING.log","a");

fwrite($reportFile,"ActivateCard.php -\n");

fwrite($reportFile,$ownerName." tried to ADD a fake record to \"./ActivatedCards.txt\" with an object named ".$objectName.".\n");

fwrite($reportFile,"Other info about the incident contains :\n");

fwrite($reportFile,"Nature of Incident - someone was trying to activate a card that was in conflict of sales.txt. Either the sale ID wasn't found, or the buyer's Id wasn't matching the sales ID. Possible Forgery of information.");

fwrite($reportFile,"object key - ".$objectKey."\n");

fwrite($reportFile,"owner key - ".$ownerKey."\n");

fwrite($reportFile,"region - ".$region."\n");

fwrite($reportFile,"location within region - ".$simPosition."\n");

fwrite($reportFile,"Version of sl viewer - ".$slVersion."\n");

fwrite($reportFile,"time - ".date("l dS \of F Y h:i:s A e")."\n\n\n");

fclose($reportFile);



}



}

else{



echo "You're not my object. GET OUT OF MY SERVER!!!";



//report the incident

$reportFile = fopen("./WARNING.log","a");

fwrite($reportFile,"ActivateCard.php -\n");

fwrite($reportFile,$ownerName." tried to ADD a fake record to \"./ActivatedCards.txt\" with an object named ".$objectName.".\n");

fwrite($reportFile,"Other info about the incident contains :\n");

fwrite($reportFile,"object key - ".$objectKey."\n");

fwrite($reportFile,"owner key - ".$ownerKey."\n");

fwrite($reportFile,"region - ".$region."\n");

fwrite($reportFile,"location within region - ".$simPosition."\n");

fwrite($reportFile,"Version of sl viewer - ".$slVersion."\n");

fwrite($reportFile,"time - ".date("l dS \of F Y h:i:s A e")."\n\n\n");

fclose($reportFile);



}



?>
Ilobmirt Tenk
Registered User
Join date: 4 Jun 2007
Posts: 135
FOSSLVendorGiftcardRedemption.php
10-02-2007 04:02
CODE

<?



//---------------------------------------------------------------------------------//

//Copyright Info Below... Please Do not Remove //

//---------------------------------------------------------------------------------//



//(c)2007 Ilobmirt Tenk



//This file is part of the FOSSL Vendor Project



// FOSSL Vendor 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 3 of the License, or

// (at your option) any later version.



// FOSSL Vendor is distributed in the hope that it will be useful,

// but WITHOUT ANY WARRANTY; without even the implied warranty of

// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the

// GNU General Public License for more details.



// You should have received a copy of the GNU General Public License

// along with this program. If not, see <http://www.gnu.org/licenses/>.



//---------------------------------------------------------------------------------//

//Copyright Info Above... Please Do not Remove //

//---------------------------------------------------------------------------------//



// Only works with PHP compiled as an Apache module

$headers = apache_request_headers();



$objectName = $headers["X-SecondLife-Object-Name"];

$objectKey = $headers["X-SecondLife-Object-Key"];

$ownerKey = $headers["X-SecondLife-Owner-Key"];

$ownerName = $headers["X-SecondLife-Owner-Name"];

$region = $headers["X-SecondLife-Region"];

$slVersion = $headers["User-Agent "];

$simPosition = $headers["X-SecondLife-Local-Position"];



// and so on for getting all the other variables ...



// get things from $_POST[]

// this will create a record for flat file storage

$redeemerKey = $_POST["redeemerKey"];

$redeemerName = $_POST["redeemerName"];

$buyerKey = $_POST["buyerKey"];

$buyerName = $_POST["buyerName"];

$salesID = $_POST["salesID"];



//determine if vendor is a part of the vendor's list

$vendorFound = false; //initialize as false, then make it true when found

//get the whole vendors file into an array for fast searching

$vendorsFile = file('./vendors.txt');

foreach($vendorsFile as $index_num => $index_value){



$vendorArrayID = explode("#",$index_value);



if($objectKey == $vendorArrayID[0]){



$vendorFound = true;

break;



}



}





//If the vendor came from myself and it registered like a good vendor should, it must be a real tenkwear vendor asking to redeem a card

if($ownerKey == "********-****-****-****-************" and $vendorFound == true){



//time to validate the owner and sales ID

//find out if the object has been bought, activated, and redeemed

$giftcardBought = false; //initialize as false, then make it true when found in Sales.txt

$giftcardBuyerMatch = false; //initialize as false, then make it true when found in Sales.txt

$giftcardActivated = false; //initialize as false, then make it true when found in ActivatedCards.txt

$giftcardActivatorMatch = false; //initialize as false, then make it true when found in Sales.txt

$giftcardRedeemed = false; //initialize as false, then make it true when found in RedeemedCards.txt



//get the whole sales, Activated Card, and Redeemed Card file into an array for fast searching



//Record = vendor ID, buyer ID, buyer name, object name, object price, sale date, sale time, unix time, sale ID

$salesFile = file('./sales.txt');

//Record = vendor ID, activator ID, Activator name, activation time, sale ID

$activatedFile = file('./ActivatedCards.txt');

//Record = vendor ID, Redeemer ID, Redeemer name, Redemption time, sale ID

$redeemedFile = file('./RedeemedCards.txt');



foreach($salesFile as $index_num => $index_value){



$salesArrayID = explode("#",$index_value);



if($salesID == $salesArrayID[8]){



$giftcardBought = true;

if($buyerKey == $salesArrayID[1] && $buyerName == $salesArrayID[2]){



$giftcardBuyerMatch = true;



}

break;



}



}



foreach($activatedFile as $index_num => $index_value){



$activatedArrayID = explode("#",$index_value);



if($salesID == $activatedArrayID[4]){



$giftcardActivated = true;

if($buyerKey == $salesArrayID[1] && $buyerName == $salesArrayID[2]){



$giftcardActivatorMatch = true;



}

break;



}



}



foreach($redeemedFile as $index_num => $index_value){



$redeemedArrayID = explode("#",$index_value);



if($salesID == $redeemedArrayID[4]){



$giftcardRedeemed = true;

break;



}



}



//If giftcard has been bought, not activated or redeemed, add to the database ActivatedCards.txt

if($giftcardBought == true && $giftcardBuyerMatch == true){



if($giftcardActivated == true && $giftcardActivatorMatch == true){



if($giftcardRedeemed == false){



//Alright! Time to activate

echo $salesID;

$redeemedcardFile = fopen('./RedeemedCards.txt','a');

fwrite($redeemedcardFile,$objectKey."#".$redeemerKey."#".$redeemerName."#".time()."#".$salesID);

fclose($redeemedcardFile);



}

else{



echo "It appears to me that this giftcard has already been redeemed.\nIn order to redeem your giftcard, your giftcard must not already be redeemed./nIf this is in error, please send an Issue report stating your problem.\nPlease note that this event has been recorded and will be used to verify your claims.";



//report the incident

$reportFile = fopen("./WARNING.log","a");

fwrite($reportFile,"RedeemCard.php -\n");

fwrite($reportFile,$ownerName." tried to ADD a fake record to \"./RedeemedCards.txt\" with an object named ".$objectName.".\n");

fwrite($reportFile,"Other info about the incident contains :\n");

fwrite($reportFile,"Nature of Incident - someone was trying to activate a card that was already redeemd. Could someone have forged a giftcard and redeemed that before the intended buyer redeemed his/her real giftcard?");

fwrite($reportFile,"object key - ".$objectKey."\n");

fwrite($reportFile,"owner key - ".$ownerKey."\n");

fwrite($reportFile,"region - ".$region."\n");

fwrite($reportFile,"location within region - ".$simPosition."\n");

fwrite($reportFile,"Version of sl viewer - ".$slVersion."\n");

fwrite($reportFile,"time - ".date("l dS \of F Y h:i:s A e")."\n\n\n");

fclose($reportFile);



}



}

else{



echo "It appears to me that this giftcard has not been activated.\nIn order to redeem your giftcard, your giftcard must be activated./nIf this is in error, please send an Issue report stating your problem.\nPlease note that this event has been recorded and will be used to verify your claims.";



//report the incident

$reportFile = fopen("./WARNING.log","a");

fwrite($reportFile,"RedeemCard.php -\n");

fwrite($reportFile,$ownerName." tried to ADD a fake record to \"./RedeemedCards.txt\" with an object named ".$objectName.".\n");

fwrite($reportFile,"Other info about the incident contains :\n");

fwrite($reportFile,"Nature of Incident - someone was trying to redeem a card that was in conflict of ActivatedCards.txt. Either the sale ID wasn't found, or the buyer's Id wasn't matching the sales ID. Possible Forgery of information.");

fwrite($reportFile,"object key - ".$objectKey."\n");

fwrite($reportFile,"owner key - ".$ownerKey."\n");

fwrite($reportFile,"region - ".$region."\n");

fwrite($reportFile,"location within region - ".$simPosition."\n");

fwrite($reportFile,"Version of sl viewer - ".$slVersion."\n");

fwrite($reportFile,"time - ".date("l dS \of F Y h:i:s A e")."\n\n\n");

fclose($reportFile);



}



}

else{



echo "It appears to me that this giftcard has not been purchased.\nIn order to activate your giftcard, you must first purchase something./nIf this is in error, please send an Issue report stating your problem.\nPlease note that this event has been recorded and will be used to verify your claims.";



//report the incident

$reportFile = fopen("./WARNING.log","a");

fwrite($reportFile,"RedeemCard.php -\n");

fwrite($reportFile,$ownerName." tried to ADD a fake record to \"./RedeemedCards.txt\" with an object named ".$objectName.".\n");

fwrite($reportFile,"Other info about the incident contains :\n");

fwrite($reportFile,"Nature of Incident - someone was trying to redeem a card that was in conflict of sales.txt. Either the sale ID wasn't found, or the buyer's Id wasn't matching the sales ID. Possible Forgery of information.");

fwrite($reportFile,"object key - ".$objectKey."\n");

fwrite($reportFile,"owner key - ".$ownerKey."\n");

fwrite($reportFile,"region - ".$region."\n");

fwrite($reportFile,"location within region - ".$simPosition."\n");

fwrite($reportFile,"Version of sl viewer - ".$slVersion."\n");

fwrite($reportFile,"time - ".date("l dS \of F Y h:i:s A e")."\n\n\n");

fclose($reportFile);



}



}

else{



echo "You're not my object. GET OUT OF MY SERVER!!!";



//report the incident

$reportFile = fopen("./WARNING.log","a");

fwrite($reportFile,"RedeemCard.php -\n");

fwrite($reportFile,$ownerName." tried to ADD a fake record to \"./RedeemedCards.txt\" with an object named ".$objectName.".\n");

fwrite($reportFile,"Other info about the incident contains :\n");

fwrite($reportFile,"object key - ".$objectKey."\n");

fwrite($reportFile,"owner key - ".$ownerKey."\n");

fwrite($reportFile,"region - ".$region."\n");

fwrite($reportFile,"location within region - ".$simPosition."\n");

fwrite($reportFile,"Version of sl viewer - ".$slVersion."\n");

fwrite($reportFile,"time - ".date("l dS \of F Y h:i:s A e")."\n\n\n");

fclose($reportFile);



}



?>
Ilobmirt Tenk
Registered User
Join date: 4 Jun 2007
Posts: 135
FOSSLVendorSalesStatistics.php
10-02-2007 04:03
CODE

<?php



//---------------------------------------------------------------------------------//

//Copyright Info Below... Please Do not Remove //

//---------------------------------------------------------------------------------//



//(c)2007 Ilobmirt Tenk



//This file is part of the FOSSL Vendor Project



// FOSSL Vendor 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 3 of the License, or

// (at your option) any later version.



// FOSSL Vendor is distributed in the hope that it will be useful,

// but WITHOUT ANY WARRANTY; without even the implied warranty of

// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the

// GNU General Public License for more details.



// You should have received a copy of the GNU General Public License

// along with this program. If not, see <http://www.gnu.org/licenses/>.



//---------------------------------------------------------------------------------//

//Copyright Info Above... Please Do not Remove //

//---------------------------------------------------------------------------------//



// Get a file into an array. This will come from the flat file we saved as sales.txt

$lines = file('./sales.txt');

$strCurrentLine = "";

$intSales=0;

$strProducts=array("");

$strMostPopularProduct="";

$intMostPopularCount = 0;

$strPrevProduct="";

$intCurrentCount = 0;



// Loop through our array extracting the 3'rd key from our records

foreach ($lines as $line_num => $line) {



$strCurrentLine = explode("#",$lines[$line_num]);//convert record into an accessable array

$strProducts[$line_num] = $strCurrentLine[3]; //get name key out of record and store its value in the strProducts Array



}



//Sort strProducts by # of occurences

sort($strProducts);

$strProducts[count($lines)+1]="";

foreach($strProducts as $index_num => $index_value){



if($index_value != $strPrevProduct){//one is done counting a certain item



if($intCurrentCount > $intMostPopularCount){//If we have a new best seller



//remember that we were tracking the product untill this point

//use strPrevProduct

$intMostPopularCount = $intCurrentCount;

$strMostPopularProduct = $strPrevProduct;



}

elseif($intCurrentCount == $intMostPopularCount){//If we have a tie



//just append the tieing products name to the list as the most popular product

$strMostPopularProduct .= " + " . $strPrevProduct;



}

else{ //If we dont have a new best seller



//don't touch the best seller variables



}



//reset the count to 1 (since you just started counting another product)

$intCurrentCount = 1;



}

else{//one is still counting a certain item



$intCurrentCount++;

//echo $index_value." counted to ".$intCurrentCount."<br>";



}



$strPrevProduct = $index_value; //keep track of what the last value was



}



//Now that we have the # of sales and the best selling product along with its sell count, echo the results to the screen.

echo "Total number of sales is ".count($lines).".<br>";

echo "Best selling product is ".$strMostPopularProduct." with ".$intMostPopularCount. " packages sold.<br>";



?>
Ilobmirt Tenk
Registered User
Join date: 4 Jun 2007
Posts: 135
Closing thoughts...
10-02-2007 04:11
What you have seen here has been my first major application of the lsl and php scripting languages. I have learned a great deal of techniques from this scripting exercise. I hope to use this and all subsequent versions of this vendor to refine my coding talent.

In the meantime, I hope that you enjoy reading this code as much as I had writing it.

~Ilobmirt Tenk
Jesse Barnett
500,000 scoville units
Join date: 21 May 2006
Posts: 4,160
10-02-2007 04:30
If you are just releasing this for others and have no questions concerning the code then you should send it to the library. Please insert PHP tags first for those of us that have installed GreaseMonkey, the code becomes much more readable and hopefully some day bbcode will be reenabled and all will be able to see it properly formatted.
_____________________
I (who is a she not a he) reserve the right to exercise selective comprehension of the OP's question at anytime.
From: someone
I am still around, just no longer here. See you across the aisle. Hope LL burns in hell for archiving this forum
1 2