removed wp specific code and set default values in config.example.php

This commit is contained in:
Gudule Lapointe
2022-02-06 16:32:38 -04:00
parent 10a6114257
commit a5c394cf3f
9 changed files with 138 additions and 292 deletions
+1 -1
View File
@@ -18,7 +18,7 @@ Version 2.x is This is a complete rewrite. The initial project was basicly an in
## Installation
- Move this directory inside your web root directory and rename it as helpers (for example), so it is reachable as <http://example.org/helpers/>
- Move this directory inside your web root directory and rename it as helpers (for example), so it is reachable as <http://yourgrid.org/helpers/>
- Copy includes/config.example.php to includes/config.php
- Edit includes/config.php with your grid and database settings
- Install required modules in your OpenSimulator (only fetch the .dll modules and OpenSim .ini files, this project provides all the web-side functionalties)
+46
View File
@@ -0,0 +1,46 @@
<?php if(CURRENCY_PROVIDER!='gloebit') die();
/**
* Gloebit default configuration
*
* DO NOT EDIT THIS FILE. It will be replaced on next update.
* Instead copy the lines to config.php, before the addons include command, and
* customize from there.
*/
/**
* Set to true to activate sandbox mode, during initial installation and tests.
* Set to false once ready to go live.
* @var boolean
*/
if(!defined('GLOEBIT_SANDBOX')) define('GLOEBIT_SANDBOX', false);
/**
* Gloebit currency conversion table
*
* Used to display a cost estimation when using the viewer Buy Currency feature.
* Conversion rate between Gloebit amount and US$ cents. Must match the packages
* and prices idsplayed on Gloebit website.
* // TODO: fetch conversion values from Gloebit website.
*
* @var array
*/
if(!defined('GLOEBIT_CONVERSION_TABLE')) define('GLOEBIT_CONVERSION_TABLE', array(
400 => 199,
1050 => 499,
2150 => 999,
4500 => 1999,
11500 => 4999,
));
/**
* Affects the suggested purchase amount. Gloebit only allow predifined amounts
* to be purchased.
* - Set threshold of 1.0 to switch to the next pack even for 1$G more
* (e.g. if user request 401, suggest 1050)
* - Set theshold to 1.1 or 1.2 to keep the low pack for small differences.
* (e.g. if user request 401, still suggest 400)
* The user can still choose another pack on the web purchase page.
*
* @GLOEBIT_CONVERSION_THRESHOLD float must be >= 1.0
*/
if(!defined('GLOEBIT_CONVERSION_THRESHOLD')) define('GLOEBIT_CONVERSION_THRESHOLD', 1.2);
+18
View File
@@ -0,0 +1,18 @@
<?php if(CURRENCY_PROVIDER!='podex') die();
/**
* Podex default configuration file.
*
* DO NOT EDIT THIS FILE. It will be replaced on next update.
* Instead copy the lines to config.php, before the addons include command, and
* customize from there.
*/
/**
* This is the message displayed to users when they use the viewer "Buy
* currency" feature. Podex Buy and sell transactions are actually provided by
* in-world terminals. Adjust the message and the url to instruct user to
* teleport to the region providing Podex terminals.
* @var [type]
*/
if(!defined('PODEX_ERROR_MESSAGE')) define('PODEX_ERROR_MESSAGE', "Please use our terminals in-world to proceed. Click OK to teleport to terminals region.");
if(!defined('PODEX_REDIRECT_URL')) define('PODEX_REDIRECT_URL', 'secondlife://Podex Exchange/128/128/21');
+2 -2
View File
@@ -130,8 +130,8 @@ function currency_xmlrpc_buy($method_name, $params, $app_data)
else {
switch(CURRENCY_PROVIDER) {
case 'podex':
$errorMessage = get_option('w4os_podex_error_message');
$errorURI = get_option('w4os_podex_redirect_url');
$errorMessage = PODEX_ERROR_MESSAGE;
$errorURI = PODEX_REDIRECT_URL;
break;
case 'gloebit':
-136
View File
@@ -1,136 +0,0 @@
<?php if ( ! defined( 'W4OS_PLUGIN' ) ) die();
/*
* config.php
*
* Helpers configuration for W4OS plugin.
* Not for use with standalone helpers.
*
* Part of "flexible_helpers_scripts" collection
* https://github.com/GuduleLapointe/flexible_helper_scripts
* by Gudule Lapointe <gudule@speculoos.world>
*/
/**
* Grid info
*/
define('OPENSIM_GRID_NAME', get_option('w4os_grid_name', 'OpenSimulator'));
define('OPENSIM_LOGIN_URI', W4OS_GRID_LOGIN_URI);
define("OPENSIM_MAIL_SENDER", get_option('w4os_offline_sender', 'no-reply@' . $_SERVER['SERVER_NAME']));
// define('OPENSIM_GRID_LOGO_URL', (get_theme_mod( 'custom_logo' )) ? wp_get_attachment_image_src( get_theme_mod( 'custom_logo' ) , 'full' )[0] : '');
/**
* Main database. For grids, use Robust database credentials. For standalone
* simulators, use OpenSim database credentials.
*/
define('OPENSIM_DB_HOST', get_option('w4os_db_host'));
define('OPENSIM_DB_NAME', get_option('w4os_db_database'));
define('OPENSIM_DB_USER', get_option('w4os_db_user'));
define('OPENSIM_DB_PASS', get_option('w4os_db_pass'));
/**
* Currency database. Used both with out without currency server
*/
define('CURRENCY_DB_HOST', get_option('w4os_economy_db_host'));
define('CURRENCY_DB_NAME', get_option('w4os_economy_db_database'));
define('CURRENCY_DB_USER', get_option('w4os_economy_db_user'));
define('CURRENCY_DB_PASS', get_option('w4os_economy_db_pass'));
define('CURRENCY_MONEY_TBL', 'balances');
define('CURRENCY_TRANSACTION_TBL', 'transactions');
/**
* Money Server settings.
*/
define('CURRENCY_USE_MONEYSERVER', true);
define('CURRENCY_SCRIPT_KEY', get_option('w4os_money_script_access_key', '123456789'));
define('CURRENCY_RATE', get_option('w4os_currency_rate', 10)); // amount in dollar...
define('CURRENCY_RATE_PER', get_option('w4os_currency_rate_per', 1000)); // ... for this amount in virtuall currency
define('CURRENCY_PROVIDER', get_option('w4os_currency_provider'));
if (!defined('CURRENCY_HELPER_URL')) define('CURRENCY_HELPER_URL', (!empty(W4OS_GRID_INFO['economy'])) ? W4OS_GRID_INFO['economy'] : get_home_url(NULL, '/economy/'));
// if (!defined('CURRENCY_HELPER_PATH')) define('CURRENCY_HELPER_PATH', dirname(__DIR__));
switch(CURRENCY_PROVIDER) {
case 'gloebit':
define('GLOEBIT_SANDBOX', get_option('w4os_gloebit_sandbox', false));
// TODO: grab conversion table from Gloebit website.
define('GLOEBIT_CONVERSION_TABLE', array(
400 => 199,
1050 => 499,
2150 => 999,
4500 => 1999,
11500 => 4999,
));
define('GLOEBIT_CONVERSION_THRESHOLD', 1.2);
break;
}
/**
* Search database credentials and settings.
* - Shared search engine (same engine used by several grids or simulator): use
* a dedicated database.
* - Hypegrid-enabled or large grids: it's better (but not mandatory) to setup a
* separate database, to optimize performances and maintenance.
* - Closed grids or closed simulators: you can safely use OpenSim database.
*/
define('SEARCH_DB_HOST', get_option('w4os_search_db_host', OPENSIM_DB_HOST));
define('SEARCH_DB_NAME', get_option('w4os_search_db_database', OPENSIM_DB_NAME));
define('SEARCH_DB_USER', get_option('w4os_search_db_user', OPENSIM_DB_USER));
define('SEARCH_DB_PASS', get_option('w4os_search_db_pass', OPENSIM_DB_PASS));
// Other registrars to Forward hosts registrations to
define('SEARCH_REGISTRARS', array(
// 'http://metaverseink.com/cgi-bin/register.py',
));
/**
* Timezone settings. Leave commented if included in a larger project. You
* dont want to mess up with timezone randomly in the middle of a process!
*/
// define('OPENSIM_USE_UTC_TIME', false);
// if (OPENSIM_USE_UTC_TIME) date_default_timezone_set('UTC');
/**
* OffLine messages DB credentials.
* @var [type]
*/
define('OFFLINE_DB_HOST', OPENSIM_DB_HOST);
define('OFFLINE_DB_NAME', OPENSIM_DB_NAME);
define('OFFLINE_DB_USER', OPENSIM_DB_USER);
define('OFFLINE_DB_PASS', OPENSIM_DB_PASS);
define('OFFLINE_DB_MYSQLI', true);
define('OFFLINE_MESSAGE_TBL', 'im_offline'); // Same DB as Offline Module V2?
// MuteList DB
define('MUTE_DB_HOST', OPENSIM_DB_HOST);
define('MUTE_DB_NAME', OPENSIM_DB_NAME);
define('MUTE_DB_USER', OPENSIM_DB_USER);
define('MUTE_DB_PASS', OPENSIM_DB_PASS);
define('MUTE_DB_MYSQLI', true);
define('MUTE_LIST_TBL', 'mute_list');
define('HYPEVENTS_URL', preg_replace(':/$:', '', get_option('w4os_hypevents_url', 'https://2do.pm/events')));
define('NULL_KEY', '00000000-0000-0000-0000-000000000000');
define('TPLINK_LOCAL', 1);
define('TPLINK_HG', 2);
define('TPLINK_V3HG', 4);
define('TPLINK_HOP', 8);
define('TPLINK_TXT', 16);
define('TPLINK_APPTP', 32);
define('TPLINK_MAP', 64);
define('TPLINK_DEFAULT', TPLINK_V3HG);
define('TPLINK', pow(2,8)-1);
define('TPLINK_NAMING', array(
'TPLINK_LOCAL' => 'local',
'TPLINK_HG' => 'HG', // inside viewer
'TPLINK_V3HG' => 'V3HG', // from website
'TPLINK_HOP' => 'hop',
'TPLINK_TXT' => 'text',
'TPLINK_APPTP' => 'teleport',
'TPLINK_MAP' => 'map',
'TPLINK_DEFAULT' => 'DEFAULT',
));
require_once('databases.php');
require_once('functions.php');
+69 -85
View File
@@ -1,91 +1,83 @@
<?php if ( ! defined( 'W4OS_PLUGIN' ) ) die();
<?php
/*
* config.php
* config.example.php
*
* Helpers configuration for W4OS plugin.
* Not for use with standalone helpers.
* Helpers configuration
* Rename this file as "config.php" before editing.
*
* Part of "flexible_helpers_scripts" collection
* https://github.com/GuduleLapointe/flexible_helper_scripts
* by Gudule Lapointe <gudule@speculoos.world>
* https://github.com/GuduleLapointe/flexible_helper_scripts
* by Gudule Lapointe <gudule@speculoos.world>
*/
/**
* Grid info
*/
define('OPENSIM_GRID_NAME', get_option('w4os_grid_name', 'OpenSimulator'));
define('OPENSIM_LOGIN_URI', W4OS_GRID_LOGIN_URI);
define("OPENSIM_MAIL_SENDER", get_option('w4os_offline_sender', 'no-reply@' . $_SERVER['SERVER_NAME']));
// define('OPENSIM_GRID_LOGO_URL', (get_theme_mod( 'custom_logo' )) ? wp_get_attachment_image_src( get_theme_mod( 'custom_logo' ) , 'full' )[0] : '');
define('OPENSIM_GRID_NAME', "Your Grid");
define('OPENSIM_LOGIN_URI', "http://yougrid.org:8002");
define("OPENSIM_MAIL_SENDER", "no-reply@{$_SERVER['SERVER_NAME']}");
// define('OPENSIM_GRID_LOGO_URL', "http://yougrid.org/logo.png");
/**
* Main database. For grids, use Robust database credentials. For standalone
* simulators, use OpenSim database credentials.
*/
define('OPENSIM_DB_HOST', get_option('w4os_db_host'));
define('OPENSIM_DB_NAME', get_option('w4os_db_database'));
define('OPENSIM_DB_USER', get_option('w4os_db_user'));
define('OPENSIM_DB_PASS', get_option('w4os_db_pass'));
define('OPENSIM_DB_HOST', 'localhost');
define('OPENSIM_DB_NAME', 'opensim');
define('OPENSIM_DB_USER', 'opensim');
define('OPENSIM_DB_PASS', 'password');
/**
* Currency database. Used both with out without currency server
* Currency database credentials and settings.
* Needed if currency is enabled on OpenSim server.
* A dedicated database is recommended, but not mandatory.
*/
define('CURRENCY_DB_HOST', get_option('w4os_economy_db_host'));
define('CURRENCY_DB_NAME', get_option('w4os_economy_db_database'));
define('CURRENCY_DB_USER', get_option('w4os_economy_db_user'));
define('CURRENCY_DB_PASS', get_option('w4os_economy_db_pass'));
define('CURRENCY_MONEY_TBL', 'balances');
define('CURRENCY_DB_HOST', OPENSIM_DB_HOST);
define('CURRENCY_DB_NAME', OPENSIM_DB_NAME);
define('CURRENCY_DB_USER', OPENSIM_DB_USER);
define('CURRENCY_DB_PASS', OPENSIM_DB_PASS);
define('CURRENCY_MONEY_TBL', 'balances');
define('CURRENCY_TRANSACTION_TBL', 'transactions');
/**
* Money Server settings.
*/
define('CURRENCY_USE_MONEYSERVER', true);
define('CURRENCY_SCRIPT_KEY', get_option('w4os_money_script_access_key', '123456789'));
define('CURRENCY_RATE', get_option('w4os_currency_rate', 10)); // amount in dollar...
define('CURRENCY_RATE_PER', get_option('w4os_currency_rate_per', 1000)); // ... for this amount in virtuall currency
define('CURRENCY_PROVIDER', get_option('w4os_currency_provider'));
if (!defined('CURRENCY_HELPER_URL')) define('CURRENCY_HELPER_URL', (!empty(W4OS_GRID_INFO['economy'])) ? W4OS_GRID_INFO['economy'] : get_home_url(NULL, '/economy/'));
define('CURRENCY_USE_MONEYSERVER', false);
define('CURRENCY_SCRIPT_KEY', '123456789');
define('CURRENCY_RATE', 10); // amount in dollar...
define('CURRENCY_RATE_PER', 1000); // ... for this amount in virtuall currency
define('CURRENCY_PROVIDER', 'gloebit'); // NULL or 'gloebit'
// define('CURRENCY_PROVIDER', 'gloebit');
define('CURRENCY_HELPER_URL', 'http://yourgrid.org/helpers/');
// if (!defined('CURRENCY_HELPER_PATH')) define('CURRENCY_HELPER_PATH', dirname(__DIR__));
switch(CURRENCY_PROVIDER) {
case 'gloebit':
define('GLOEBIT_SANDBOX', get_option('w4os_gloebit_sandbox', false));
// TODO: grab conversion table from Gloebit website.
define('GLOEBIT_CONVERSION_TABLE', array(
400 => 199,
1050 => 499,
2150 => 999,
4500 => 1999,
11500 => 4999,
));
define('GLOEBIT_CONVERSION_THRESHOLD', 1.2);
break;
}
/**
* Search database credentials and settings.
* - Shared search engine (same engine used by several grids or simulator): use
* a dedicated database.
* - Hypegrid-enabled or large grids: it's better (but not mandatory) to setup a
* separate database, to optimize performances and maintenance.
* - Closed grids or closed simulators: you can safely use OpenSim database.
* Needed if you enable search in OpenSim server.
*
* A dedicated database is:
* - strongly recommended if the search engine is shared by several grids
* - recommended and more efficient for large and/or hypergrid-enabled grids
* - optional for closed grids and standalone simulators
* These are recommendations, the Robust database can safely be used instead.
*/
define('SEARCH_DB_HOST', get_option('w4os_search_db_host', OPENSIM_DB_HOST));
define('SEARCH_DB_NAME', get_option('w4os_search_db_database', OPENSIM_DB_NAME));
define('SEARCH_DB_USER', get_option('w4os_search_db_user', OPENSIM_DB_USER));
define('SEARCH_DB_PASS', get_option('w4os_search_db_pass', OPENSIM_DB_PASS));
// Other registrars to Forward hosts registrations to
define('SEARCH_DB_HOST', OPENSIM_DB_HOST);
define('SEARCH_DB_NAME', OPENSIM_DB_NAME);
define('SEARCH_DB_USER', OPENSIM_DB_USER);
define('SEARCH_DB_PASS', OPENSIM_DB_PASS);
// Add here other registrars to Forward hosts registrations
define('SEARCH_REGISTRARS', array(
// 'http://metaverseink.com/cgi-bin/register.py',
// 'http://2do.directory/helpers/register.php',
// 'http://metaverseink.com/cgi-bin/register.py',
));
echo "been there"; die();
/**
* Timezone settings. Leave commented if included in a larger project. You
* dont want to mess up with timezone randomly in the middle of a process!
*/
// define('OPENSIM_USE_UTC_TIME', false);
// if (OPENSIM_USE_UTC_TIME) date_default_timezone_set('UTC');
define('OPENSIM_USE_UTC_TIME', true);
if (OPENSIM_USE_UTC_TIME) date_default_timezone_set('UTC');
/**
* OffLine messages DB credentials.
@@ -95,42 +87,34 @@ define('OFFLINE_DB_HOST', OPENSIM_DB_HOST);
define('OFFLINE_DB_NAME', OPENSIM_DB_NAME);
define('OFFLINE_DB_USER', OPENSIM_DB_USER);
define('OFFLINE_DB_PASS', OPENSIM_DB_PASS);
define('OFFLINE_DB_MYSQLI', true);
define('OFFLINE_MESSAGE_TBL', 'im_offline'); // Same DB as Offline Module V2?
// MuteList DB
define('MUTE_DB_HOST', OPENSIM_DB_HOST);
define('MUTE_DB_NAME', OPENSIM_DB_NAME);
define('MUTE_DB_USER', OPENSIM_DB_USER);
define('MUTE_DB_PASS', OPENSIM_DB_PASS);
define('MUTE_DB_MYSQLI', true);
define('MUTE_LIST_TBL', 'mute_list');
/**
* Mute list database.
* mute is now handled by OpenSim server (0.9.x), so we shouldn't need this
*/
// define('MUTE_DB_HOST', OPENSIM_DB_HOST);
// define('MUTE_DB_NAME', OPENSIM_DB_NAME);
// define('MUTE_DB_USER', OPENSIM_DB_USER);
// define('MUTE_DB_PASS', OPENSIM_DB_PASS);
// define('MUTE_LIST_TBL', 'mute_list');
define('HYPEVENTS_URL', preg_replace(':/$:', '', get_option('w4os_hypevents_url', 'https://2do.pm/events')));
define('HYPEVENTS_URL', preg_replace(':/$:', '', 'https://2do.pm/events'));
define('NULL_KEY', '00000000-0000-0000-0000-000000000000');
define('TPLINK_LOCAL', 1);
define('TPLINK_HG', 2);
define('TPLINK_V3HG', 4);
define('TPLINK_HOP', 8);
define('TPLINK_TXT', 16);
define('TPLINK_APPTP', 32);
define('TPLINK_MAP', 64);
define('TPLINK_DEFAULT', TPLINK_V3HG);
define('TPLINK', pow(2,8)-1);
define('TPLINK_NAMING', array(
'TPLINK_LOCAL' => 'local',
'TPLINK_HG' => 'HG', // inside viewer
'TPLINK_V3HG' => 'V3HG', // from website
'TPLINK_HOP' => 'hop',
'TPLINK_TXT' => 'text',
'TPLINK_APPTP' => 'teleport',
'TPLINK_MAP' => 'map',
'TPLINK_DEFAULT' => 'DEFAULT',
));
define('TPLINK_LOCAL', 1); // seconlife://Region/x/y/z
define('TPLINK_HG', 2); // seconlife://yourgrid.org:8002 Region/x/y/z
define('TPLINK_V3HG', 4); // the overcomplicated stuff!
define('TPLINK_HOP', 8); // hop://yourgrid.org:8002:Region/x/y/z
define('TPLINK_TXT', 16); // yourgrid.org:8002:Region/x/y/z
define('TPLINK_APPTP', 32); // secondlife:///app/teleport/yourgrid.org:8002:Region/x/y/z
define('TPLINK_MAP', 64); // secondlife:///app/map/yourgrid.org:8002:Region/x/y/z
define('TPLINK', pow(2,8)-1); // all formats
define('TPLINK_DEFAULT', TPLINK_HOP); // default
die();
require_once('databases.php');
require_once('functions.php');
$currency_addon = dirname(__DIR__) . '/addons/currency-' . CURRENCY_PROVIDER . '.php';
if(file_exists($currency_addon)) include_once($currency_addon);
+1
View File
@@ -0,0 +1 @@
<?php die();
+1
View File
@@ -0,0 +1 @@
<?php die();
-68
View File
@@ -1,68 +0,0 @@
<?php namespace OpenSimulator\Helpers;
/*
* wp-load.php
*
* Loader for helpers implmentation in W4OS WordPress plugin.
* Not needed in standalone implementations.
*
* Part of w4os - WordPress interface For OpenSimulator
* https://github.com/GuduleLapointe/w4os/
* by Gudule Lapointe <gudule@speculoos.world>
*/
if ( ! defined( 'W4OS_PLUGIN' ) ) die;
$url = getenv('REDIRECT_URL');
if(get_option('w4os_provide_economy_helpers') == true &! empty(W4OS_GRID_INFO['economy']) ) {
$economy = parse_url(W4OS_GRID_INFO['economy'])['path'];
if(preg_match(":^$economy(currency.php|landtool.php):", $url)) {
$helper = preg_replace(":^$economy:", "", $url);
require($helper);
die();
} else if($url == $economy) {
// Probably the url check, just accept it
// TODO: redirect to support page if set
die();
}
}
if ( get_option('w4os_provide_offline_messages') == true &! empty(W4OS_GRID_INFO['message']) ) {
$message = parse_url(W4OS_GRID_INFO['message'])['path'];
if(preg_match(":^$message/(SaveMessage|RetrieveMessages|offlineim)/:", "$url/")) {
require('offline.php');
} else if($message == $url) {
die(); // ignore but don't trigger an error
}
}
if ( get_option('w4os_provide_search') == true ) {
if(! empty(get_option('w4os_search_url'))) {
$search = parse_url(get_option('w4os_search_url'))['path'];
if(preg_match(":^$search/:", "$url/")) {
// error_log("search $search");
require('query.php');
die();
}
$parser = preg_replace(':^//:', '/', dirname($search) . '/parser.php');
if(preg_match(":^$parser/:", "$url/")) {
require('parser.php');
die();
}
if(! empty(get_option('w4os_hypevents_url'))) {
$hypevents = preg_replace(':^//:', '/', dirname($search) . '/eventsparser.php');
if(preg_match(":^$hypevents:", "$url/")) {
require('eventsparser.php');
die();
}
}
}
if(! empty(get_option('w4os_search_register'))) {
$register = parse_url(get_option('w4os_search_register'))['path'];
if(preg_match(":^$register:", "$url/")) {
require('register.php');
}
}
}