diff --git a/README.md b/README.md index 7a265fe..bfb0faf 100644 --- a/README.md +++ b/README.md @@ -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 +- Move this directory inside your web root directory and rename it as helpers (for example), so it is reachable as - 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) diff --git a/addons/currency-gloebit.php b/addons/currency-gloebit.php new file mode 100644 index 0000000..c232e8e --- /dev/null +++ b/addons/currency-gloebit.php @@ -0,0 +1,46 @@ + 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); diff --git a/addons/currency-podex.php b/addons/currency-podex.php new file mode 100644 index 0000000..eaeb5cd --- /dev/null +++ b/addons/currency-podex.php @@ -0,0 +1,18 @@ + - */ - -/** - * 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'); diff --git a/includes/config.example.php b/includes/config.example.php index 063e283..e3ff5da 100644 --- a/includes/config.example.php +++ b/includes/config.example.php @@ -1,91 +1,83 @@ - + * https://github.com/GuduleLapointe/flexible_helper_scripts + * by Gudule Lapointe */ /** * 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); diff --git a/includes/index.php b/includes/index.php new file mode 100644 index 0000000..36bfa89 --- /dev/null +++ b/includes/index.php @@ -0,0 +1 @@ + - */ - -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'); - } - } -}