DieFeM 9 жил өмнө
commit
89e5ecc446

+ 25 - 0
README.txt

@@ -0,0 +1,25 @@
+Hi guys!
+
+EXIM as smarthost is only needed for hosts with dynamically assigned IP because it avoids to be blocked by some mail servers like hotmail.
+
+Upload all files.
+
+Login with ssh and change to the user 'www-data'(in ubuntu) or 'apache'(in centos) or any other user that manages the apache server with, for example:
+
+sudo su - www-data
+
+Now edit the cron tab for this user
+
+crontab -e
+
+and copy this line at the end of the file and save it (WARNING:modify it with the correct path):
+
+*/1 * * * * php /var/www/html/ogp/modules/billing/cron-shop.php
+
+Now this script searches for expired game homes every minute, and wil stop and remove them if they are expired.
+If you would like to do this at midnight every day instead of every minute you should use
+
+0 0 * * * php /var/www/html/ogp/modules/billing/cron-shop.php
+
+TIP: Searching in google, for example, "cron every month" you will find the correct code to search expired homes and remove them every month.
+

+ 87 - 0
exim SMTP.txt

@@ -0,0 +1,87 @@
+
+Use exim4 as smarthost SMTP server.(UBUNTU)
+
+apt-get install exim4
+
+su -
+
+$ dpkg-reconfigure exim4-config
+
+General type of mail configuration: mail sent by smarthost; received via SMTP or fetchmail
+System mail name: localhost
+Ip Address to listen on: 127.0.0.1
+Other destinations~: yourdyndns.domain.com
+Machines to Relay for: <empty>
+IP address or hostname of the outgoing smarthost: smtp.gmail.com::587
+Hide local mail name in outgoing mail: No
+Keep number of DNS queries minimal: No
+Delivery method for local mail: mbox format in /var/mail/
+Split configuration into small files: Yes
+
+vi /etc/exim4/passwd.client
+
+gmail-smtp.l.google.com:[email protected]:password_relay
+*.google.com:[email protected]:password_relay
+smtp.gmail.com:[email protected]:password_relay
+
+$ chmod 640 /etc/exim4/passwd.client
+
+$ chown root:Debian-exim /etc/exim4/passwd.client
+
+
+$ vi /etc/exim4/email-addresses
+
+root@localhost: [email protected]
+
+$ chmod 640 /etc/exim4/email-addresses
+
+5. Verifing Exim config.
+
+$ vi /etc/exim4/update-exim4.conf
+
+dc_eximconfig_configtype='smarthost'
+dc_other_hostnames='yourdyndns.domain.com'
+dc_local_interfaces='127.0.0.1'
+dc_readhost='yourdyndns.domain.com'
+dc_relay_domains="
+dc_minimaldns='false'
+dc_relay_nets="
+dc_smarthost='smtp.gmail.com::587'
+CFILEMODE='644'
+dc_use_split_config='true'
+dc_hide_mailname='false'
+dc_mailname_in_oh='true'
+dc_localdelivery='mail_spool'
+
+6. restart service MTA.
+
+$ /etc/init.d/exim4 restart
+
+
+(RedHat)centos-fedora
+yum install exim
+
+So what to do is: edit "/etc/exim/exim.conf", add:
+
+
+# routers section
+send_via_gmail:
+  driver = manualroute
+  domains = ! +local_domains
+  transport = gmail_smtp
+  route_list = * gmail-smtp.l.google.com
+
+# transports section
+gmail_smtp:
+  driver = smtp
+  port = 587
+  hosts_require_auth = gmail-smtp.l.google.com
+  hosts_require_tls = gmail-smtp.l.google.com
+
+# authenticators section
+gmail_login:
+  driver = plaintext
+  public_name = LOGIN
+  client_send = : [email protected] : yourpassword
+
+[root@localhost ~]# service exim start

BIN
images/cart.png


+ 164 - 0
lang/Danish/modules/billing.php

@@ -0,0 +1,164 @@
+<?php
+/*
+ *
+ * OGP - Open Game Panel
+ * Copyright (C) Copyright (C) 2008 - 2014 The OGP Development Team
+ *
+ * http://www.opengamepanel.org/
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or 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, write to the Free Software
+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
+ *
+ */
+
+// Shop Settings
+define('currency', "Currency");
+define('available_invoice_types', "Available Invoice Types");
+define('hourly', "Hourly");
+define('monthly', "Monthly");
+define('annually', "Annually");
+define('tax_amount', "Tax Amount");
+define('paypal_email', "PayPal E-mail");
+define('update_settings', "Update Settings");
+define('settings_updated', "Settings Updated.");
+define('payment_gateway', "Payment Gateway");
+define('paygol_service', "PayGol Service");
+define('paygol_service_id', "PayGol Service ID");
+define('paypal', "PayPal");
+define('paygol', "PayGol");
+define('skrill', "Skrill");
+define('skrill_merchant_info', "Skrill merchant information");
+define('skrill_merchant_id', "Merchant ID.");
+define('skrill_email', "Skrill Email");
+define('skrill_secret_word', "Secret word");
+define('skrill_secret_word_info', "The password must be set from your Skrill merchant account,<br>
+									at <b>Settings</b>, click on <b>Developer Settings</b>,<br>
+									If this option is not listed send an email to <i>[email protected]</i>.");
+define('hash_stored_correctly', "Hash stored correctly");
+define('currency_not_available_at', "The currency \"%s\" is not available at %s.");
+define('robokassa', "Robokassa");
+define('robokassa_service', "Robokassa service");
+define('robokassa_merchant_login', "Merchant Login");
+define('robokassa_securepass1', "Secure Password 1");
+define('robokassa_securepass2', "Secure Password 2");
+
+// Shop
+define('your_cart', "Your Cart");
+define('starting_on', "Starting on");
+define('slots', "Slots");
+define('hour', "Hour");
+define('month', "Month");
+define('year', "Year");
+define('hours', "Hours");
+define('months', "Months");
+define('years', "Years");
+define('service_name', "Service name");
+define('rcon_pass', "RCON password");
+define('ftp_pass', "FTP password");
+define('available_ips', "Available IPs");
+define('max_players', "Max Players");
+define('invoice_duration', "Invoice Duration");
+define('calculate_price', "Calculate Price");
+define('buy', "BUY");
+define('back_to_list', "Back to the list");
+define('ip', "IP");
+define('subtotal', "Subtotal");
+define('rate', "Rate");
+define('total', "Total");
+define('save', "Save");
+define('you_need_to', "You need to");
+define('register', "Register");
+define('and', "and");
+define('log_in', "Log In");
+define('to_purchase_a_service', "to purchase a service");
+define('available_services', "Available Services");
+define('payment_is_pending_of_approval', "The payment is pending of approval.");
+define('back_to_your_cart', "Go back to your cart.");
+define('expired', "Expired");
+define('removed', "Removed");
+define('extended', "Extended");
+define('installation_and_expiration_date', "Installation and expiration date");
+define('expiration_date', "Expiration date");
+define('removal_date', "Removal date");
+define('installation_date', "Installation date");
+define('enable_server', "Enable server");
+define('success', "SUCCESS");
+define('redirecting_to_game_monitor', "Redirecting to Game Monitor...");
+define('starting_installations', "Starting installations...");
+
+// Orders
+define('order_id', "Order ID");
+define('home_name', "Home Name");
+define('tax', "Tax");
+define('pay_from', "Pay From %s");
+define('set_as_paid', "Set As Paid");
+define('create_server', "Create Server");
+define('see_invoice', "See Invoice");
+define('paid', "Paid");
+define('not_paid', "Not Paid");
+define('procesing_payment', "Procesing Payment");
+define('paid_and_installed', "Paid And Installed");
+define('add_to_cart', "Add To Cart");
+define('cart_id', "Cart ID");
+define('order_desc', "Order Description");
+define('remove_from_cart', "Remove From Cart");
+define('remove_cart', "Remove Cart");
+define('there_are_no_orders_in_cart', "There are no orders in this cart.");
+define('redirecting_to', "Redirecting to %s...");
+
+// Services
+define('id', "ID#");
+define('remote_server', "Remote Server");
+define('price_hourly', "Price Hourly");
+define('price_monthly', "Price Monthly");
+define('price_year', "Price Year");
+define('service_image_url', "Service Image URL");
+define('remove_service', "Remove Service");
+define('add_service', "Add Service");
+define('current_services', "Current Services");
+define('max_slot_qty', "Max. Slot Quantity");
+define('min_slot_qty', "Min. Slot Quantity");
+define('ftp_account', "FTP Account");
+define('select_install_method', "Select install method");
+define('url_for_manual_install', "URL For Manual Install");
+define('description', "Description");
+define('image_url', "Image URL");
+define('access_rights', "Access Rights");
+define('allow_update', "Allow Update");
+define('allow_file_management', "Allow File Management");
+define('allow_parameter_usage', "Allow Parameter Usage");
+define('allow_extra_parameters_usage', "Allow Extra Parameters Usage");
+define('allow_ftp_usage', "Allow FTP Usage");
+define('allow_custom_fields', "Allow Custom Fields");
+define('enabled', "Enabled");
+define('disabled', "Disabled");
+define('steam', "Steam");
+define('rsync', "Rsync");
+define('manual_from_url', "Manual From URL");
+
+// View Invoice
+define('business', "Business");
+define('business_email', "Business Email");
+define('game_server_order', "Game Server Order");
+define('item', "Item");
+define('slot_cost', "Slot Cost");
+define('slot_quantity', "Slot Quantity");
+define('order_price', "Order Price");
+define('order', "Order");
+define('date', "Date");
+define('price', "Price");
+define('invoice', "Invoice");
+define('print_invoice', "Print Invoice");
+define('extend', "Extend");
+?>

+ 157 - 0
lang/English/modules/billing.php

@@ -0,0 +1,157 @@
+<?php
+/*
+ *
+ * OGP - Open Game Panel
+ * Copyright (C) 2008 - 2016 The OGP Development Team
+ *
+ * http://www.opengamepanel.org/
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or 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, write to the Free Software
+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
+ *
+ */
+#####################################################################
+# English language variables
+#
+##################################################################### 
+
+define('currency', "Currency");
+define('available_invoice_types', "Available Invoice Types");
+define('hourly', "Hourly");
+define('monthly', "Monthly");
+define('annually', "Annually");
+define('tax_amount', "Tax Amount");
+define('paypal_email', "PayPal E-mail");
+define('update_settings', "Update Settings");
+define('settings_updated', "Settings Updated.");
+define('payment_gateway', "Payment Gateway");
+define('paygol_service', "PayGol Service");
+define('paygol_service_id', "PayGol Service ID");
+define('paypal', "PayPal");
+define('paygol', "PayGol");
+define('skrill', "Skrill");
+define('skrill_merchant_info', "Skrill merchant information");
+define('skrill_merchant_id', "Merchant ID.");
+define('skrill_email', "Skrill Email");
+define('skrill_secret_word', "Secret word");
+define('skrill_secret_word_info', "The password must be set from your Skrill merchant account,<br>at <b>Settings</b> click on <b>Developer Settings</b>.<br>If this option is not listed send an email to <i>[email protected]</i>.");
+define('hash_stored_correctly', "Hash stored correctly");
+define('currency_not_available_at', "The currency \"%s\" is not available at %s.");
+define('robokassa', "Robokassa");
+define('robokassa_service', "Robokassa service");
+define('robokassa_merchant_login', "Merchant Login");
+define('robokassa_securepass1', "Secure Password 1");
+define('robokassa_securepass2', "Secure Password 2");
+define('your_cart', "Your Cart");
+define('starting_on', "Starting on");
+define('slots', "Slots");
+define('hour', "Hour");
+define('month', "Month");
+define('year', "Year");
+define('hours', "Hours");
+define('months', "Months");
+define('years', "Years");
+define('service_name', "Service name");
+define('rcon_pass', "RCON password");
+define('ftp_pass', "FTP password");
+define('available_ips', "Available IPs");
+define('max_players', "Max Players");
+define('invoice_duration', "Invoice Duration");
+define('calculate_price', "Calculate Price");
+define('buy', "BUY");
+define('back_to_list', "Back to the list");
+define('ip', "IP");
+define('subtotal', "Subtotal");
+define('rate', "Rate");
+define('total', "Total");
+define('save', "Save");
+define('you_need_to', "You need to");
+define('register', "Register");
+define('and', "and");
+define('log_in', "Log In");
+define('to_purchase_a_service', "to purchase a service");
+define('available_services', "Available Services");
+define('payment_is_pending_of_approval', "The payment is pending of approval.");
+define('back_to_your_cart', "Go back to your cart.");
+define('expired', "Expired");
+define('removed', "Removed");
+define('extended', "Extended");
+define('installation_and_expiration_date', "Installation and expiration date");
+define('expiration_date', "Expiration date");
+define('removal_date', "Removal date");
+define('installation_date', "Installation date");
+define('enable_server', "Enable server");
+define('success', "SUCCESS");
+define('redirecting_to_game_monitor', "Redirecting to Game Monitor...");
+define('starting_installations', "Starting installations...");
+define('order_id', "Order ID");
+define('home_name', "Home Name");
+define('tax', "Tax");
+define('pay_from', "Pay From %s");
+define('set_as_paid', "Set As Paid");
+define('create_server', "Create Server");
+define('see_invoice', "See Invoice");
+define('paid', "Paid");
+define('not_paid', "Not Paid");
+define('procesing_payment', "Procesing Payment");
+define('paid_and_installed', "Paid And Installed");
+define('add_to_cart', "Add To Cart");
+define('cart_id', "Cart ID");
+define('order_desc', "Order Description");
+define('remove_from_cart', "Remove From Cart");
+define('remove_cart', "Remove Cart");
+define('there_are_no_orders_in_cart', "There are no orders in this cart.");
+define('redirecting_to', "Redirecting to %s...");
+define('id', "ID#");
+define('remote_server', "Remote Server");
+define('price_hourly', "Price Hourly");
+define('price_monthly', "Price Monthly");
+define('price_year', "Price Year");
+define('service_image_url', "Service Image URL");
+define('remove_service', "Remove Service");
+define('add_service', "Add Service");
+define('current_services', "Current Services");
+define('max_slot_qty', "Max. Slot Quantity");
+define('min_slot_qty', "Min. Slot Quantity");
+define('ftp_account', "FTP Account");
+define('select_install_method', "Select install method");
+define('url_for_manual_install', "URL For Manual Install");
+define('description', "Description");
+define('image_url', "Image URL");
+define('access_rights', "Access Rights");
+define('allow_update', "Allow Update");
+define('allow_file_management', "Allow File Management");
+define('allow_parameter_usage', "Allow Parameter Usage");
+define('allow_extra_parameters_usage', "Allow Extra Parameters Usage");
+define('allow_ftp_usage', "Allow FTP Usage");
+define('allow_custom_fields', "Allow Custom Fields");
+define('enabled', "Enabled");
+define('disabled', "Disabled");
+define('steam', "Steam");
+define('rsync', "Rsync");
+define('manual_from_url', "Manual From URL");
+define('business', "Business");
+define('business_email', "Business Email");
+define('game_server_order', "Game Server Order");
+define('item', "Item");
+define('slot_cost', "Slot Cost");
+define('slot_quantity', "Slot Quantity");
+define('order_price', "Order Price");
+define('order', "Order");
+define('date', "Date");
+define('price', "Price");
+define('invoice', "Invoice");
+define('print_invoice', "Print Invoice");
+define('extend', "Extend");
+?>

+ 164 - 0
lang/French/modules/billing.php

@@ -0,0 +1,164 @@
+<?php
+/*
+ *
+ * OGP - Open Game Panel
+ * Copyright (C) Copyright (C) 2008 - 2012 The OGP Development Team
+ *
+ * http://www.opengamepanel.org/
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or 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, write to the Free Software
+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
+ *
+ */
+
+// Shop Settings
+define('currency', "Devise");
+define('available_invoice_types', "Types de facturation disponibles");
+define('hourly', "Par heure");
+define('monthly', "Par mois");
+define('annually', "Par an");
+define('tax_amount', "Montant de la taxe");
+define('paypal_email', "E-mail Paypal");
+define('update_settings', "Mise à jour des paramètres");
+define('settings_updated', "Paramètres mis à jour.");
+define('payment_gateway', "Moyen de paiement");
+define('paygol_service', "PayGol");
+define('paygol_service_id', "PayGol Service ID");
+define('paypal', "PayPal");
+define('paygol', "PayGol");
+define('skrill', "Skrill");
+define('skrill_merchant_info', "Skrill merchant information");
+define('skrill_merchant_id', "Merchant ID.");
+define('skrill_email', "Skrill Email");
+define('skrill_secret_word', "Secret word");
+define('skrill_secret_word_info', "The password must be set from your Skrill merchant account,<br>
+									at <b>Settings</b>, click on <b>Developer Settings</b>,<br>
+									If this option is not listed send an email to <i>[email protected]</i>.");
+define('hash_stored_correctly', "Hash stored correctly");
+define('currency_not_available_at', "The currency \"%s\" is not available at %s.");
+define('robokassa', "Robokassa");
+define('robokassa_service', "Robokassa service");
+define('robokassa_merchant_login', "Merchant Login");
+define('robokassa_securepass1', "Secure Password 1");
+define('robokassa_securepass2', "Secure Password 2");
+
+// Shop
+define('your_cart', "Votre panier");
+define('starting_on', "Dès");
+define('slots', "slots");
+define('hour', "Heure");
+define('month', "Mois");
+define('year', "Année");
+define('hours', "Heures");
+define('months', "Mois");
+define('years', "Années");
+define('service_name', "Nom du service");
+define('rcon_pass', "Mot de passe RCON");
+define('ftp_pass', "Mot de passe FTP");
+define('available_ips', "IPs disponibles");
+define('max_players', "Joueurs maximums");
+define('invoice_duration', "Durée");
+define('calculate_price', "Calculer le prix");
+define('buy', "ACHETER");
+define('back_to_list', "Retourner à la liste");
+define('ip', "IP");
+define('subtotal', "Sous-total");
+define('rate', "Taux");
+define('total', "Total");
+define('save', "Sauvegarder");
+define('you_need_to', "Vous devez vous");
+define('register', "enregistrer");
+define('and', "et vous");
+define('log_in', "connecter");
+define('to_purchase_a_service', "pour acheter un service");
+define('available_services', "Services disponibles");
+define('payment_is_pending_of_approval', "The payment is pending of approval.");
+define('back_to_your_cart', "Go back to your cart.");
+define('expired', "Expired");
+define('removed', "Removed");
+define('extended', "Extended");
+define('installation_and_expiration_date', "Installation and expiration date");
+define('expiration_date', "Expiration date");
+define('removal_date', "Removal date");
+define('installation_date', "Installation date");
+define('enable_server', "Enable server");
+define('success', "SUCCESS");
+define('redirecting_to_game_monitor', "Redirecting to Game Monitor...");
+define('starting_installations', "Starting installations...");
+
+// Orders
+define('order_id', "Commande ID");
+define('home_name', "Nom du service");
+define('tax', "Taxe");
+define('pay_from', "Payer à partir de %s");
+define('set_as_paid', "Définir comme payé");
+define('create_server', "Créer le serveur");
+define('see_invoice', "Voir la facture");
+define('paid', "Payé");
+define('not_paid', "Non payé");
+define('procesing_payment', "Paiement en cours");
+define('paid_and_installed', "Payé et installé");
+define('add_to_cart', "Ajouet au panier");
+define('cart_id', "ID du panier");
+define('order_desc', "Description de la commande");
+define('remove_from_cart', "Supprimer du panier");
+define('remove_cart', "Supprimer le panier");
+define('there_are_no_orders_in_cart', "Il n'y a pas de commande dans ce panier.");
+define('redirecting_to', "Redirection vers %s...");
+
+// Services
+define('id', "ID#");
+define('remote_server', "Serveur distant");
+define('price_hourly', "Prix / heure");
+define('price_monthly', "Prix / mois");
+define('price_year', "Prix / année");
+define('service_image_url', "URL vers image du service");
+define('remove_service', "Supprimer le service");
+define('add_service', "Ajouter un service");
+define('current_services', "Services existants");
+define('max_slot_qty', "Quantité de slots max.");
+define('min_slot_qty', "Quantité de slots min.");
+define('ftp_account', "Compte FTP");
+define('select_install_method', "Méthode d'installation");
+define('url_for_manual_install', "URL pour installation manuelle");
+define('description', "Description");
+define('image_url', "URL de l'image");
+define('access_rights', "Droits d'accès");
+define('allow_update', "Autoriser la mise à jour");
+define('allow_file_management', "Autoriser la gestion des fichiers");
+define('allow_parameter_usage', "Autoriser les paramètres");
+define('allow_extra_parameters_usage', "Autoriser les paramètres personnalisés");
+define('allow_ftp_usage', "Autoriser le FTP");
+define('allow_custom_fields', "Allow Custom Fields");
+define('enabled', "Activé");
+define('disabled', "Désactivé");
+define('steam', "Steam");
+define('rsync', "Rsync");
+define('manual_from_url', "Manuelle depuis une URL");
+
+// View Invoice
+define('business', "Business");
+define('business_email', "E-mail business");
+define('game_server_order', "Commande serveur de jeux");
+define('item', "Objet");
+define('slot_cost', "Coût du slot");
+define('slot_quantity', "Quantité de slot");
+define('order_price', "Prix de la commande");
+define('order', "Commande");
+define('date', "Date");
+define('price', "Prix");
+define('invoice', "Facture");
+define('print_invoice', "Imprimer la facture");
+define('extend', "Etendre");
+?>

+ 164 - 0
lang/German/modules/billing.php

@@ -0,0 +1,164 @@
+<?php
+/*
+ *
+ * OGP - Open Game Panel
+ * Copyright (C) Copyright (C) 2008 - 2012 The OGP Development Team
+ *
+ * http://www.opengamepanel.org/
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or 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, write to the Free Software
+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
+ *
+ */
+
+// Shop Settings
+define('currency', "Currency");
+define('available_invoice_types', "Available Invoice Types");
+define('hourly', "Hourly");
+define('monthly', "Monthly");
+define('annually', "Annually");
+define('tax_amount', "Tax Amount");
+define('paypal_email', "PayPal E-mail");
+define('update_settings', "Update Settings");
+define('settings_updated', "Settings Updated.");
+define('payment_gateway', "Payment Gateway");
+define('paygol_service', "PayGol Service");
+define('paygol_service_id', "PayGol Service ID");
+define('paypal', "PayPal");
+define('paygol', "PayGol");
+define('skrill', "Skrill");
+define('skrill_merchant_info', "Skrill merchant information");
+define('skrill_merchant_id', "Merchant ID.");
+define('skrill_email', "Skrill Email");
+define('skrill_secret_word', "Secret word");
+define('skrill_secret_word_info', "The password must be set from your Skrill merchant account,<br>
+									at <b>Settings</b>, click on <b>Developer Settings</b>,<br>
+									If this option is not listed send an email to <i>[email protected]</i>.");
+define('hash_stored_correctly', "Hash stored correctly");
+define('currency_not_available_at', "The currency \"%s\" is not available at %s.");
+define('robokassa', "Robokassa");
+define('robokassa_service', "Robokassa service");
+define('robokassa_merchant_login', "Merchant Login");
+define('robokassa_securepass1', "Secure Password 1");
+define('robokassa_securepass2', "Secure Password 2");
+
+// Shop
+define('your_cart', "Your Cart");
+define('starting_on', "Starting on");
+define('slots', "Slots");
+define('hour', "Hour");
+define('month', "Month");
+define('year', "Year");
+define('hours', "Hours");
+define('months', "Months");
+define('years', "Years");
+define('service_name', "Service name");
+define('rcon_pass', "RCON password");
+define('ftp_pass', "FTP password");
+define('available_ips', "Available IPs");
+define('max_players', "Max Players");
+define('invoice_duration', "Invoice Duration");
+define('calculate_price', "Calculate Price");
+define('buy', "BUY");
+define('back_to_list', "Back to the list");
+define('ip', "IP");
+define('subtotal', "Subtotal");
+define('rate', "Rate");
+define('total', "Total");
+define('save', "Save");
+define('you_need_to', "You need to");
+define('register', "Register");
+define('and', "and");
+define('log_in', "Log In");
+define('to_purchase_a_service', "to purchase a service");
+define('available_services', "Available Services");
+define('payment_is_pending_of_approval', "The payment is pending of approval.");
+define('back_to_your_cart', "Go back to your cart.");
+define('expired', "Expired");
+define('removed', "Removed");
+define('extended', "Extended");
+define('installation_and_expiration_date', "Installation and expiration date");
+define('expiration_date', "Expiration date");
+define('removal_date', "Removal date");
+define('installation_date', "Installation date");
+define('enable_server', "Enable server");
+define('success', "SUCCESS");
+define('redirecting_to_game_monitor', "Redirecting to Game Monitor...");
+define('starting_installations', "Starting installations...");
+
+// Orders
+define('order_id', "Order ID");
+define('home_name', "Home Name");
+define('tax', "Tax");
+define('pay_from', "Pay From %s");
+define('set_as_paid', "Set As Paid");
+define('create_server', "Create Server");
+define('see_invoice', "See Invoice");
+define('paid', "Paid");
+define('not_paid', "Not Paid");
+define('procesing_payment', "Procesing Payment");
+define('paid_and_installed', "Paid And Installed");
+define('add_to_cart', "Add To Cart");
+define('cart_id', "Cart ID");
+define('order_desc', "Order Description");
+define('remove_from_cart', "Remove From Cart");
+define('remove_cart', "Remove Cart");
+define('there_are_no_orders_in_cart', "There are no orders in this cart.");
+define('redirecting_to', "Redirecting to %s...");
+
+// Services
+define('id', "ID#");
+define('remote_server', "Remote Server");
+define('price_hourly', "Price Hourly");
+define('price_monthly', "Price Monthly");
+define('price_year', "Price Year");
+define('service_image_url', "Service Image URL");
+define('remove_service', "Remove Service");
+define('add_service', "Add Service");
+define('current_services', "Current Services");
+define('max_slot_qty', "Max. Slot Quantity");
+define('min_slot_qty', "Min. Slot Quantity");
+define('ftp_account', "FTP Account");
+define('select_install_method', "Select install method");
+define('url_for_manual_install', "URL For Manual Install");
+define('description', "Description");
+define('image_url', "Image URL");
+define('access_rights', "Access Rights");
+define('allow_update', "Allow Update");
+define('allow_file_management', "Allow File Management");
+define('allow_parameter_usage', "Allow Parameter Usage");
+define('allow_extra_parameters_usage', "Allow Extra Parameters Usage");
+define('allow_ftp_usage', "Allow FTP Usage");
+define('allow_custom_fields', "Allow Custom Fields");
+define('enabled', "Enabled");
+define('disabled', "Disabled");
+define('steam', "Steam");
+define('rsync', "Rsync");
+define('manual_from_url', "Manual From URL");
+
+// View Invoice
+define('business', "Business");
+define('business_email', "Business Email");
+define('game_server_order', "Game Server Order");
+define('item', "Item");
+define('slot_cost', "Slot Cost");
+define('slot_quantity', "Slot Quantity");
+define('order_price', "Order Price");
+define('order', "Order");
+define('date', "Date");
+define('price', "Price");
+define('invoice', "Invoice");
+define('print_invoice', "Print Invoice");
+define('extend', "Extend");
+?>

+ 165 - 0
lang/Hungarian/modules/billing.php

@@ -0,0 +1,165 @@
+<?php
+/*
+ *
+ * OGP - Open Game Panel
+ * Copyright (C) Copyright (C) 2008 - 2012 The OGP Development Team
+ *
+ * http://www.opengamepanel.org/
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or 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, write to the Free Software
+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
+ *
+ */
+
+// Shop Settings
+define('currency', "Currency");
+define('available_invoice_types', "Available Invoice Types");
+define('hourly', "Hourly");
+define('monthly', "Monthly");
+define('annually', "Annually");
+define('tax_amount', "Tax Amount");
+define('paypal_email', "PayPal E-mail");
+define('update_settings', "Update Settings");
+define('settings_updated', "Settings Updated.");
+define('payment_gateway', "Payment Gateway");
+define('paygol_service', "PayGol Service");
+define('paygol_service_id', "PayGol Service ID");
+define('paypal', "PayPal");
+define('paygol', "PayGol");
+define('skrill', "Skrill");
+define('skrill_merchant_info', "Skrill merchant information");
+define('skrill_merchant_id', "Merchant ID.");
+define('skrill_email', "Skrill Email");
+define('skrill_secret_word', "Secret word");
+define('skrill_secret_word_info', "The password must be set from your Skrill merchant account,<br>
+									at <b>Settings</b>, click on <b>Developer Settings</b>,<br>
+									If this option is not listed send an email to <i>[email protected]</i>.");
+define('hash_stored_correctly', "Hash stored correctly");
+define('currency_not_available_at', "The currency \"%s\" is not available at %s.");
+define('robokassa', "Robokassa");
+define('robokassa_service', "Robokassa service");
+define('robokassa_merchant_login', "Merchant Login");
+define('robokassa_securepass1', "Secure Password 1");
+define('robokassa_securepass2', "Secure Password 2");
+
+// Shop
+define('your_cart', "Your Cart");
+define('starting_on', "Starting on");
+define('slots', "Slots");
+define('hour', "Hour");
+define('month', "Month");
+define('year', "Year");
+define('hours', "Hours");
+define('months', "Months");
+define('years', "Years");
+define('service_name', "Service name");
+define('rcon_pass', "RCON password");
+define('ftp_pass', "FTP password");
+define('available_ips', "Available IPs");
+define('max_players', "Max Players");
+define('invoice_duration', "Invoice Duration");
+define('calculate_price', "Calculate Price");
+define('buy', "BUY");
+define('back_to_list', "Back to the list");
+define('ip', "IP");
+define('subtotal', "Subtotal");
+define('rate', "Rate");
+define('total', "Total");
+define('save', "Save");
+define('you_need_to', "You need to");
+define('register', "Register");
+define('and', "and");
+define('log_in', "Log In");
+define('to_purchase_a_service', "to purchase a service");
+define('available_services', "Available Services");
+define('payment_is_pending_of_approval', "The payment is pending of approval.");
+define('back_to_your_cart', "Go back to your cart.");
+define('expired', "Expired");
+define('removed', "Removed");
+define('extended', "Extended");
+define('installation_and_expiration_date', "Installation and expiration date");
+define('expiration_date', "Expiration date");
+define('removal_date', "Removal date");
+define('installation_date', "Installation date");
+define('enable_server', "Enable server");
+define('success', "SUCCESS");
+define('redirecting_to_game_monitor', "Redirecting to Game Monitor...");
+define('starting_installations', "Starting installations...");
+
+// Orders
+
+define('order_id', "Order ID");
+define('home_name', "Home Name");
+define('tax', "Tax");
+define('pay_from', "Pay From %s");
+define('set_as_paid', "Set As Paid");
+define('create_server', "Create Server");
+define('see_invoice', "See Invoice");
+define('paid', "Paid");
+define('not_paid', "Not Paid");
+define('procesing_payment', "Procesing Payment");
+define('paid_and_installed', "Paid And Installed");
+define('add_to_cart', "Add To Cart");
+define('cart_id', "Cart ID");
+define('order_desc', "Order Description");
+define('remove_from_cart', "Remove From Cart");
+define('remove_cart', "Remove Cart");
+define('there_are_no_orders_in_cart', "There are no orders in this cart.");
+define('redirecting_to', "Redirecting to %s...");
+
+// Services
+define('id', "ID#");
+define('remote_server', "Remote Server");
+define('price_hourly', "Price Hourly");
+define('price_monthly', "Price Monthly");
+define('price_year', "Price Year");
+define('service_image_url', "Service Image URL");
+define('remove_service', "Remove Service");
+define('add_service', "Add Service");
+define('current_services', "Current Services");
+define('max_slot_qty', "Max. Slot Quantity");
+define('min_slot_qty', "Min. Slot Quantity");
+define('ftp_account', "FTP Account");
+define('select_install_method', "Select install method");
+define('url_for_manual_install', "URL For Manual Install");
+define('description', "Description");
+define('image_url', "Image URL");
+define('access_rights', "Access Rights");
+define('allow_update', "Allow Update");
+define('allow_file_management', "Allow File Management");
+define('allow_parameter_usage', "Allow Parameter Usage");
+define('allow_extra_parameters_usage', "Allow Extra Parameters Usage");
+define('allow_ftp_usage', "Allow FTP Usage");
+define('allow_custom_fields', "Allow Custom Fields");
+define('enabled', "Enabled");
+define('disabled', "Disabled");
+define('steam', "Steam");
+define('rsync', "Rsync");
+define('manual_from_url', "Manual From URL");
+
+// View Invoice
+define('business', "Business");
+define('business_email', "Business Email");
+define('game_server_order', "Game Server Order");
+define('item', "Item");
+define('slot_cost', "Slot Cost");
+define('slot_quantity', "Slot Quantity");
+define('order_price', "Order Price");
+define('order', "Order");
+define('date', "Date");
+define('price', "Price");
+define('invoice', "Invoice");
+define('print_invoice', "Print Invoice");
+define('extend', "Extend");
+?>

+ 164 - 0
lang/Polish/modules/billing.php

@@ -0,0 +1,164 @@
+<?php
+/*
+ *
+ * OGP - Open Game Panel
+ * Copyright (C) Copyright (C) 2008 - 2012 The OGP Development Team
+ *
+ * http://www.opengamepanel.org/
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or 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, write to the Free Software
+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
+ *
+ */
+
+// Shop Settings
+define('currency', "Currency");
+define('available_invoice_types', "Available Invoice Types");
+define('hourly', "Hourly");
+define('monthly', "Monthly");
+define('annually', "Annually");
+define('tax_amount', "Tax Amount");
+define('paypal_email', "PayPal E-mail");
+define('update_settings', "Update Settings");
+define('settings_updated', "Settings Updated.");
+define('payment_gateway', "Payment Gateway");
+define('paygol_service', "PayGol Service");
+define('paygol_service_id', "PayGol Service ID");
+define('paypal', "PayPal");
+define('paygol', "PayGol");
+define('skrill', "Skrill");
+define('skrill_merchant_info', "Skrill merchant information");
+define('skrill_merchant_id', "Merchant ID.");
+define('skrill_email', "Skrill Email");
+define('skrill_secret_word', "Secret word");
+define('skrill_secret_word_info', "The password must be set from your Skrill merchant account,<br>
+									at <b>Settings</b>, click on <b>Developer Settings</b>,<br>
+									If this option is not listed send an email to <i>[email protected]</i>.");
+define('hash_stored_correctly', "Hash stored correctly");
+define('currency_not_available_at', "The currency \"%s\" is not available at %s.");
+define('robokassa', "Robokassa");
+define('robokassa_service', "Robokassa service");
+define('robokassa_merchant_login', "Merchant Login");
+define('robokassa_securepass1', "Secure Password 1");
+define('robokassa_securepass2', "Secure Password 2");
+
+// Shop
+define('your_cart', "Your Cart");
+define('starting_on', "Starting on");
+define('slots', "Slots");
+define('hour', "Hour");
+define('month', "Month");
+define('year', "Year");
+define('hours', "Hours");
+define('months', "Months");
+define('years', "Years");
+define('service_name', "Service name");
+define('rcon_pass', "RCON password");
+define('ftp_pass', "FTP password");
+define('available_ips', "Available IPs");
+define('max_players', "Max Players");
+define('invoice_duration', "Invoice Duration");
+define('calculate_price', "Calculate Price");
+define('buy', "BUY");
+define('back_to_list', "Back to the list");
+define('ip', "IP");
+define('subtotal', "Subtotal");
+define('rate', "Rate");
+define('total', "Total");
+define('save', "Save");
+define('you_need_to', "You need to");
+define('register', "Register");
+define('and', "and");
+define('log_in', "Log In");
+define('to_purchase_a_service', "to purchase a service");
+define('available_services', "Available Services");
+define('payment_is_pending_of_approval', "The payment is pending of approval.");
+define('back_to_your_cart', "Go back to your cart.");
+define('expired', "Expired");
+define('removed', "Removed");
+define('extended', "Extended");
+define('installation_and_expiration_date', "Installation and expiration date");
+define('expiration_date', "Expiration date");
+define('removal_date', "Removal date");
+define('installation_date', "Installation date");
+define('enable_server', "Enable server");
+define('success', "SUCCESS");
+define('redirecting_to_game_monitor', "Redirecting to Game Monitor...");
+define('starting_installations', "Starting installations...");
+
+// Orders
+define('order_id', "Order ID");
+define('home_name', "Home Name");
+define('tax', "Tax");
+define('pay_from', "Pay From %s");
+define('set_as_paid', "Set As Paid");
+define('create_server', "Create Server");
+define('see_invoice', "See Invoice");
+define('paid', "Paid");
+define('not_paid', "Not Paid");
+define('procesing_payment', "Procesing Payment");
+define('paid_and_installed', "Paid And Installed");
+define('add_to_cart', "Add To Cart");
+define('cart_id', "Cart ID");
+define('order_desc', "Order Description");
+define('remove_from_cart', "Remove From Cart");
+define('remove_cart', "Remove Cart");
+define('there_are_no_orders_in_cart', "There are no orders in this cart.");
+define('redirecting_to', "Redirecting to %s...");
+
+// Services
+define('id', "ID#");
+define('remote_server', "Remote Server");
+define('price_hourly', "Price Hourly");
+define('price_monthly', "Price Monthly");
+define('price_year', "Price Year");
+define('service_image_url', "Service Image URL");
+define('remove_service', "Remove Service");
+define('add_service', "Add Service");
+define('current_services', "Current Services");
+define('max_slot_qty', "Max. Slot Quantity");
+define('min_slot_qty', "Min. Slot Quantity");
+define('ftp_account', "FTP Account");
+define('select_install_method', "Select install method");
+define('url_for_manual_install', "URL For Manual Install");
+define('description', "Description");
+define('image_url', "Image URL");
+define('access_rights', "Access Rights");
+define('allow_update', "Allow Update");
+define('allow_file_management', "Allow File Management");
+define('allow_parameter_usage', "Allow Parameter Usage");
+define('allow_extra_parameters_usage', "Allow Extra Parameters Usage");
+define('allow_ftp_usage', "Allow FTP Usage");
+define('allow_custom_fields', "Allow Custom Fields");
+define('enabled', "Enabled");
+define('disabled', "Disabled");
+define('steam', "Steam");
+define('rsync', "Rsync");
+define('manual_from_url', "Manual From URL");
+
+// View Invoice
+define('business', "Business");
+define('business_email', "Business Email");
+define('game_server_order', "Game Server Order");
+define('item', "Item");
+define('slot_cost', "Slot Cost");
+define('slot_quantity', "Slot Quantity");
+define('order_price', "Order Price");
+define('order', "Order");
+define('date', "Date");
+define('price', "Price");
+define('invoice', "Invoice");
+define('print_invoice', "Print Invoice");
+define('extend', "Extend");
+?>

+ 164 - 0
lang/Portuguese/modules/billing.php

@@ -0,0 +1,164 @@
+<?php
+/*
+ *
+ * OGP - Open Game Panel
+ * Copyright (C) Copyright (C) 2008 - 2012 The OGP Development Team
+ *
+ * http://www.opengamepanel.org/
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or 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, write to the Free Software
+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
+ *
+ */
+
+// Shop Settings
+define('currency', "Currency");
+define('available_invoice_types', "Available Invoice Types");
+define('hourly', "Hourly");
+define('monthly', "Monthly");
+define('annually', "Annually");
+define('tax_amount', "Tax Amount");
+define('paypal_email', "PayPal E-mail");
+define('update_settings', "Update Settings");
+define('settings_updated', "Settings Updated.");
+define('payment_gateway', "Payment Gateway");
+define('paygol_service', "PayGol Service");
+define('paygol_service_id', "PayGol Service ID");
+define('paypal', "PayPal");
+define('paygol', "PayGol");
+define('skrill', "Skrill");
+define('skrill_merchant_info', "Skrill merchant information");
+define('skrill_merchant_id', "Merchant ID.");
+define('skrill_email', "Skrill Email");
+define('skrill_secret_word', "Secret word");
+define('skrill_secret_word_info', "The password must be set from your Skrill merchant account,<br>
+									at <b>Settings</b>, click on <b>Developer Settings</b>,<br>
+									If this option is not listed send an email to <i>[email protected]</i>.");
+define('hash_stored_correctly', "Hash stored correctly");
+define('currency_not_available_at', "The currency \"%s\" is not available at %s.");
+define('robokassa', "Robokassa");
+define('robokassa_service', "Robokassa service");
+define('robokassa_merchant_login', "Merchant Login");
+define('robokassa_securepass1', "Secure Password 1");
+define('robokassa_securepass2', "Secure Password 2");
+
+// Shop
+define('your_cart', "Your Cart");
+define('starting_on', "Starting on");
+define('slots', "Slots");
+define('hour', "Hour");
+define('month', "Month");
+define('year', "Year");
+define('hours', "Hours");
+define('months', "Months");
+define('years', "Years");
+define('service_name', "Service name");
+define('rcon_pass', "RCON password");
+define('ftp_pass', "FTP password");
+define('available_ips', "Available IPs");
+define('max_players', "Max Players");
+define('invoice_duration', "Invoice Duration");
+define('calculate_price', "Calculate Price");
+define('buy', "BUY");
+define('back_to_list', "Back to the list");
+define('ip', "IP");
+define('subtotal', "Subtotal");
+define('rate', "Rate");
+define('total', "Total");
+define('save', "Save");
+define('you_need_to', "You need to");
+define('register', "Register");
+define('and', "and");
+define('log_in', "Log In");
+define('to_purchase_a_service', "to purchase a service");
+define('available_services', "Available Services");
+define('payment_is_pending_of_approval', "The payment is pending of approval.");
+define('back_to_your_cart', "Go back to your cart.");
+define('expired', "Expired");
+define('removed', "Removed");
+define('extended', "Extended");
+define('installation_and_expiration_date', "Installation and expiration date");
+define('expiration_date', "Expiration date");
+define('removal_date', "Removal date");
+define('installation_date', "Installation date");
+define('enable_server', "Enable server");
+define('success', "SUCCESS");
+define('redirecting_to_game_monitor', "Redirecting to Game Monitor...");
+define('starting_installations', "Starting installations...");
+
+// Orders
+define('order_id', "Order ID");
+define('home_name', "Home Name");
+define('tax', "Tax");
+define('pay_from', "Pay From %s");
+define('set_as_paid', "Set As Paid");
+define('create_server', "Create Server");
+define('see_invoice', "See Invoice");
+define('paid', "Paid");
+define('not_paid', "Not Paid");
+define('procesing_payment', "Procesing Payment");
+define('paid_and_installed', "Paid And Installed");
+define('add_to_cart', "Add To Cart");
+define('cart_id', "Cart ID");
+define('order_desc', "Order Description");
+define('remove_from_cart', "Remove From Cart");
+define('remove_cart', "Remove Cart");
+define('there_are_no_orders_in_cart', "There are no orders in this cart.");
+define('redirecting_to', "Redirecting to %s...");
+
+// Services
+define('id', "ID#");
+define('remote_server', "Remote Server");
+define('price_hourly', "Price Hourly");
+define('price_monthly', "Price Monthly");
+define('price_year', "Price Year");
+define('service_image_url', "Service Image URL");
+define('remove_service', "Remove Service");
+define('add_service', "Add Service");
+define('current_services', "Current Services");
+define('max_slot_qty', "Max. Slot Quantity");
+define('min_slot_qty', "Min. Slot Quantity");
+define('ftp_account', "FTP Account");
+define('select_install_method', "Select install method");
+define('url_for_manual_install', "URL For Manual Install");
+define('description', "Description");
+define('image_url', "Image URL");
+define('access_rights', "Access Rights");
+define('allow_update', "Allow Update");
+define('allow_file_management', "Allow File Management");
+define('allow_parameter_usage', "Allow Parameter Usage");
+define('allow_extra_parameters_usage', "Allow Extra Parameters Usage");
+define('allow_ftp_usage', "Allow FTP Usage");
+define('allow_custom_fields', "Allow Custom Fields");
+define('enabled', "Enabled");
+define('disabled', "Disabled");
+define('steam', "Steam");
+define('rsync', "Rsync");
+define('manual_from_url', "Manual From URL");
+
+// View Invoice
+define('business', "Business");
+define('business_email', "Business Email");
+define('game_server_order', "Game Server Order");
+define('item', "Item");
+define('slot_cost', "Slot Cost");
+define('slot_quantity', "Slot Quantity");
+define('order_price', "Order Price");
+define('order', "Order");
+define('date', "Date");
+define('price', "Price");
+define('invoice', "Invoice");
+define('print_invoice', "Print Invoice");
+define('extend', "Extend");
+?>

+ 164 - 0
lang/Russian/modules/billing.php

@@ -0,0 +1,164 @@
+<?php
+/*
+ *
+ * OGP - Open Game Panel
+ * Copyright (C) Copyright (C) 2008 - 2012 The OGP Development Team
+ *
+ * http://www.opengamepanel.org/
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or 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, write to the Free Software
+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
+ *
+ */
+
+// Shop Settings
+define('currency', "Currency");
+define('available_invoice_types', "Available Invoice Types");
+define('hourly', "Hourly");
+define('monthly', "Monthly");
+define('annually', "Annually");
+define('tax_amount', "Tax Amount");
+define('paypal_email', "PayPal E-mail");
+define('update_settings', "Update Settings");
+define('settings_updated', "Settings Updated.");
+define('payment_gateway', "Payment Gateway");
+define('paygol_service', "PayGol Service");
+define('paygol_service_id', "PayGol Service ID");
+define('paypal', "PayPal");
+define('paygol', "PayGol");
+define('skrill', "Skrill");
+define('skrill_merchant_info', "Skrill merchant information");
+define('skrill_merchant_id', "Merchant ID.");
+define('skrill_email', "Skrill Email");
+define('skrill_secret_word', "Secret word");
+define('skrill_secret_word_info', "The password must be set from your Skrill merchant account,<br>
+								   at <b>Settings</b>, click on <b>Developer Settings</b>,<br>
+								   If this option is not listed send an email to <i>[email protected]</i>.");
+define('hash_stored_correctly', "Hash stored correctly");
+define('currency_not_available_at', "The currency \"%s\" is not available at %s.");
+define('robokassa', "Robokassa");
+define('robokassa_service', "Robokassa service");
+define('robokassa_merchant_login', "Merchant Login");
+define('robokassa_securepass1', "Secure Password 1");
+define('robokassa_securepass2', "Secure Password 2");
+
+// Shop
+define('your_cart', "Your Cart");
+define('starting_on', "Starting on");
+define('slots', "Slots");
+define('hour', "Hour");
+define('month', "Month");
+define('year', "Year");
+define('hours', "Hours");
+define('months', "Months");
+define('years', "Years");
+define('service_name', "Service name");
+define('rcon_pass', "RCON password");
+define('ftp_pass', "FTP password");
+define('available_ips', "Available IPs");
+define('max_players', "Max Players");
+define('invoice_duration', "Invoice Duration");
+define('calculate_price', "Calculate Price");
+define('buy', "BUY");
+define('back_to_list', "Back to the list");
+define('ip', "IP");
+define('subtotal', "Subtotal");
+define('rate', "Rate");
+define('total', "Total");
+define('save', "Save");
+define('you_need_to', "You need to");
+define('register', "Register");
+define('and', "and");
+define('log_in', "Log In");
+define('to_purchase_a_service', "to purchase a service");
+define('available_services', "Available Services");
+define('payment_is_pending_of_approval', "The payment is pending of approval.");
+define('back_to_your_cart', "Go back to your cart.");
+define('expired', "Expired");
+define('removed', "Removed");
+define('extended', "Extended");
+define('installation_and_expiration_date', "Installation and expiration date");
+define('expiration_date', "Expiration date");
+define('removal_date', "Removal date");
+define('installation_date', "Installation date");
+define('enable_server', "Enable server");
+define('success', "SUCCESS");
+define('redirecting_to_game_monitor', "Redirecting to Game Monitor...");
+define('starting_installations', "Starting installations...");
+
+// Orders
+define('order_id', "Order ID");
+define('home_name', "Home Name");
+define('tax', "Tax");
+define('pay_from', "Pay From %s");
+define('set_as_paid', "Set As Paid");
+define('create_server', "Create Server");
+define('see_invoice', "See Invoice");
+define('paid', "Paid");
+define('not_paid', "Not Paid");
+define('procesing_payment', "Procesing Payment");
+define('paid_and_installed', "Paid And Installed");
+define('add_to_cart', "Add To Cart");
+define('cart_id', "Cart ID");
+define('order_desc', "Order Description");
+define('remove_from_cart', "Remove From Cart");
+define('remove_cart', "Remove Cart");
+define('there_are_no_orders_in_cart', "There are no orders in this cart.");
+define('redirecting_to', "Redirecting to %s...");
+
+// Services
+define('id', "ID#");
+define('remote_server', "Remote Server");
+define('price_hourly', "Price Hourly");
+define('price_monthly', "Price Monthly");
+define('price_year', "Price Year");
+define('service_image_url', "Service Image URL");
+define('remove_service', "Remove Service");
+define('add_service', "Add Service");
+define('current_services', "Current Services");
+define('max_slot_qty', "Max. Slot Quantity");
+define('min_slot_qty', "Min. Slot Quantity");
+define('ftp_account', "FTP Account");
+define('select_install_method', "Select install method");
+define('url_for_manual_install', "URL For Manual Install");
+define('description', "Description");
+define('image_url', "Image URL");
+define('access_rights', "Access Rights");
+define('allow_update', "Allow Update");
+define('allow_file_management', "Allow File Management");
+define('allow_parameter_usage', "Allow Parameter Usage");
+define('allow_extra_parameters_usage', "Allow Extra Parameters Usage");
+define('allow_ftp_usage', "Allow FTP Usage");
+define('allow_custom_fields', "Allow Custom Fields");
+define('enabled', "Enabled");
+define('disabled', "Disabled");
+define('steam', "Steam");
+define('rsync', "Rsync");
+define('manual_from_url', "Manual From URL");
+
+// View Invoice
+define('business', "Business");
+define('business_email', "Business Email");
+define('game_server_order', "Game Server Order");
+define('item', "Item");
+define('slot_cost', "Slot Cost");
+define('slot_quantity', "Slot Quantity");
+define('order_price', "Order Price");
+define('order', "Order");
+define('date', "Date");
+define('price', "Price");
+define('invoice', "Invoice");
+define('print_invoice', "Print Invoice");
+define('extend', "Extend");
+?>

+ 167 - 0
lang/Spanish/modules/billing.php

@@ -0,0 +1,167 @@
+<?php
+/*
+ *
+ * OGP - Open Game Panel
+ * Copyright (C) Copyright (C) 2008 - 2012 The OGP Development Team
+ *
+ * http://www.opengamepanel.org/
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or 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, write to the Free Software
+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
+ *
+ */
+
+// Shop Settings
+
+define('currency', "Moneda");
+define('available_invoice_types', "Tipo de facturación");
+define('hourly', "Por horas");
+define('monthly', "Mensual");
+define('annually', "Anual");
+define('tax_amount', "Cantidad de IVA");
+define('paypal_email', "Email de PayPal");
+define('update_settings', "Actualizar configuración");
+define('settings_updated', "Configuración actualizada.");
+define('payment_gateway', "Pasarela de pago");
+define('paygol_service', "Servicio PayGol");
+define('paygol_service_id', "ID de PayGol");
+define('paypal', "PayPal");
+define('paygol', "PayGol");
+define('skrill', "Skrill");
+define('skrill_merchant_info', "Información de cuenta Skrill");
+define('skrill_merchant_id', "ID de Negocio.");
+define('skrill_email', "Email de Skrill");
+define('skrill_secret_word', "Palabra secreta");
+define('skrill_secret_word_info', "La palabra secreta se configura desde su cuenta de negocio de Skrill,<br>
+									en <b>Ajustes</b> pulse sobre <b>Ajustes del desarrollador</b>,<br>
+									si esta opción no aparece envie un email a <i>[email protected]</i>.");
+define('hash_stored_correctly', "Hash guardado correctamente");
+define('currency_not_available_at', "La divisa \"%s\" no esta disponible en %s.");
+define('robokassa', "Robokassa");
+define('robokassa_service', "Servicio Robokassa");
+define('robokassa_merchant_login', "Ususrio Robokassa");
+define('robokassa_securepass1', "Contraseña Segura 1");
+define('robokassa_securepass2', "Contraseña Segura 2");
+
+// Shop
+define('your_cart', "Su Carro");
+define('starting_on', "Desde");
+define('slots', "Slots");
+define('hour', "Hora");
+define('month', "Mes");
+define('year', "Año");
+define('hours', "Horas");
+define('months', "Meses");
+define('years', "Años");
+define('service_name', "Nombre del servicio");
+define('rcon_pass', "Contraseña RCON");
+define('ftp_pass', "Contraseña FTP");
+define('available_ips', "IP disponibles");
+define('max_players', "Max Jugadores");
+define('invoice_duration', "Duración");
+define('calculate_price', "Calcular Precio");
+define('buy', "Comprar");
+define('back_to_list', "Volver a la lista");
+define('ip', "IP");
+define('subtotal', "Subtotal");
+define('rate', "Impuesto");
+define('total', "Total");
+define('save', "Guardar");
+define('you_need_to', "Necesitas");
+define('register', "Registrarte");
+define('log_in', "Loguearte");
+define('to_purchase_a_service', "para comprar un servicio");
+define('available_services', "Servicios disponibles");
+define('payment_is_pending_of_approval', "El pago está pendiente de aprovacion.");
+define('back_to_your_cart', "Vuelve a tu carro.");
+define('expired', "Caducado");
+define('removed', "Eliminado");
+define('extended', "Extendido");
+define('installation_and_expiration_date', "Fecha de instalación y caducidad");
+define('expiration_date', "Fecha de caducidad");
+define('removal_date', "Fecha de eliminación");
+define('installation_date', "Fecha de instalación");
+define('enable_server', "Reactivar servicio");
+define('success', "COMPLETADO");
+define('redirecting_to_game_monitor', "Redireccionando al monitor...");
+define('starting_installations', "Iniciando instalaciones...");
+
+// Orders
+
+define('order_id', "ID de pedido");
+define('home_name', "Nombre Principal");
+define('tax', "Impuesto");
+define('pay_from', "Pagar desde %s");
+define('set_as_paid', "Marcar como pagado");
+define('create_server', "Crear el Servidor");
+define('see_invoice', "Ver Factura");
+define('paid', "Pagado");
+define('not_paid', "No Pagado");
+define('procesing_payment', "Procesando Pago");
+define('paid_and_installed', "Pagado e instalado");
+define('add_to_cart', "Añadir Al Carro");
+define('cart_id', "ID De carro");
+define('order_desc', "Descripcion Del Pedido");
+define('remove_from_cart', "Quitar Del Carro");
+define('remove_cart', "Eliminar El Carro");
+define('there_are_no_orders_in_cart', "No hay ningún pedido en su carro.");
+define('redirecting_to', "Redirigiendo a %s...");
+
+// Services
+define('id', "ID#");
+define('remote_server', "Servidor Remoto");
+define('price_hourly', "Precio por hora");
+define('price_monthly', "Precio mensual");
+define('price_year', "Precio anual");
+define('service_image_url', "URL de la imagen");
+define('remove_service', "Eliminar Servicio");
+define('add_service', "Añadir Servicio");
+define('current_services', "Servicios Actuales");
+define('max_slot_qty', "Cantidad Maxima de Slots");
+define('min_slot_qty', "Cantidad Minima de Slots");
+define('ftp_account', "Cuenta FTP");
+define('select_install_method', "Metodo de instalación");
+define('url_for_manual_install', "URL para instalación manual");
+define('description', "Descripción");
+define('image_url', "URL de la imagen");
+define('access_rights', "Derechos de acceso");
+define('allow_update', "Habilitar Actualizaciones");
+define('allow_file_management', "Habilitar Edicion de archivos");
+define('allow_parameter_usage', "Habilitar Parametros");
+define('allow_extra_parameters_usage', "Habilitar Parametros Extra");
+define('allow_ftp_usage', "Habilitar FTP");
+define('allow_custom_fields', "Habilitar Campos Personalizados");
+define('enabled', "Activado");
+define('disabled', "Desactivado");
+define('steam', "Steam");
+define('rsync', "Rsync");
+define('manual_from_url', "Manual desde URL");
+
+// View Invoice
+define('business', "Negocio");
+define('business_email', "Email del Negocio");
+define('game_server_order', "Pedido De Servidor De Juegos");
+define('item', "Objeto");
+define('slot_cost', "Coste por Slot");
+define('slot_quantity', "Cantidad de Slots");
+define('order_price', "Precio del Pedido");
+define('order', "Pedido");
+define('date', "Fecha");
+define('price', "Precio");
+define('invoice', "Factura");
+define('print_invoice', "Imprimir Factura");
+define('extend', "Extender");
+define('and', "y");
+
+?>

+ 108 - 0
modules/billing/add_to_cart.php

@@ -0,0 +1,108 @@
+<?php
+/*
+ *
+ * OGP - Open Game Panel
+ * Copyright (C) 2008 - 2010 The OGP Development Team
+ *
+ * http://www.opengamepanel.org/
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or 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, write to the Free Software
+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
+ *
+ */
+
+function exec_ogp_module()
+{
+	global $db;
+	$settings = $db->getSettings();
+	
+	require('includes/config.inc.php');
+	
+	$service_id = $_REQUEST['service_id'];
+	
+	// Query for Selected service info.
+	$qry_service = "SELECT DISTINCT service_id, home_cfg_id, mod_cfg_id, service_name, remote_server_id, slot_max_qty, slot_min_qty, price_hourly, price_monthly, price_year, description, img_url FROM ".$table_prefix."billing_services WHERE service_id=".$service_id;
+	$result_service = $db->resultQuery($qry_service);		
+	$row_service = $result_service[0];
+	//Compiling info about invoice to create an invoice order.
+
+	// remote server value
+	$remote_server_id = $row_service['remote_server_id'];
+
+	// request ogp user to create a home path.
+	$r_server = $db->getRemoteServer($remote_server_id);
+	$ogp_user = $r_server['ogp_user'];
+
+	// request the user name and the game name to generate a game home name.
+	$home_name = $_POST['home_name'];
+
+	//Calculating Price
+	if ($_POST['invoice_duration'] == "hour")
+	{
+		$price_slot=$row_service['price_hourly'];
+	}
+	elseif ($_POST['invoice_duration'] == "month")
+	{
+		$price_slot=$row_service['price_monthly'];
+	}
+	elseif ($_POST['invoice_duration'] == "year")
+	{
+		$price_slot=$row_service['price_year']*12;
+	}
+	
+	$price = $_POST['max_players']*$price_slot*$_POST['qty'];
+	
+	//Game Server Values
+	$ip_id = $_POST['ip_id'];
+	$ip = $db->getIpById($ip_id);
+	$max_players = $_POST['max_players'];
+	$qty = $_POST['qty'];
+	$invoice_duration = $_POST['invoice_duration'];
+	$user_id = $_SESSION['user_id'];
+	$remote_control_password = $_POST['remote_control_password'];
+	$ftp_password = $_POST['ftp_password'];
+	$tax_amount = $settings['tax_amount'];
+	$currency = $settings['currency'];
+	
+	global $view;
+		
+	if( isset( $_POST["add_to_cart"] ) )
+	{
+		if( isset( $_SESSION['CART'] ) )
+		{
+			$i = count( $_SESSION['CART'] );
+			$i++;
+		}
+		else
+		{
+			$i = 0;
+		}
+		
+		$_SESSION['CART'][$i] = array( "cart_id" => $i,
+									   "service_id" => $service_id,
+									   "home_name" => $home_name, 
+									   "ip" => $ip_id,
+									   "max_players" => $max_players, 
+									   "qty" => $qty, 
+									   "invoice_duration" => $invoice_duration, 
+									   "price" => $price, 
+									   "remote_control_password" => $remote_control_password, 
+									   "ftp_password" => $ftp_password,
+									   "tax_amount" => $tax_amount,
+									   "currency" => $currency,
+									   "paid" => 0);
+		echo '<meta http-equiv="refresh" content="0;url=?m=billing&amp;p=cart">';
+	}
+}
+?>

+ 151 - 0
modules/billing/bill.php

@@ -0,0 +1,151 @@
+<?php
+function exec_ogp_module()
+{
+	//Include database connection details
+	require('includes/config.inc.php');
+
+	global $db,$view,$settings;
+	if(isset($_GET['type']) && $_GET['type'] == 'cleared')
+	{
+		echo '<body onload="window.print()" >';
+		$view->setCharset(get_lang('lang_charset'));
+	}	
+
+	$user_id = $_SESSION['user_id'];
+	$cart_id = $_POST['cart_id'];
+	$isAdmin = $db->isAdmin( $_SESSION['user_id'] );
+	if ( $isAdmin )
+		$orders = $db->resultQuery( "SELECT * FROM OGP_DB_PREFIXbilling_orders WHERE cart_id=".$cart_id );
+	else
+		$orders = $db->resultQuery( "SELECT * FROM OGP_DB_PREFIXbilling_orders WHERE cart_id=".$cart_id." AND user_id=".$user_id );
+		
+	$cart = $db->resultQuery( "SELECT * FROM OGP_DB_PREFIXbilling_carts WHERE cart_id=".$cart_id );
+			
+	if( !empty($orders) )
+	{
+		?>
+		<br><br>
+		<table width="772" height="438" border="0" style="color:#000000" bgcolor="#FFFFFF">
+			  <tr bgcolor="#000000">
+				<td colspan="5" align="center"  style="color:white">
+					<p style="font-size:18pt"><b><?php print_lang("invoice");?></b></p>
+				</td>
+			  </tr>
+			  <tr>
+				<td height="21" colspan="5">&nbsp;</td>
+			  </tr>
+			  <tr>
+				<td width="150" height="21" align="left"><?php print_lang("business");?>:<br><b><?php  echo "<b>".$settings['panel_name']."</b>"; ?></td>
+				<td colspan="2" rowspan="3">&nbsp;</td>
+				<td colspan="2" rowspan="3"><img width="300" height="100" src="images/banner.gif"></td>
+			  </tr>
+			  <tr>
+				<td width="150" height="21" align="left"><?php print_lang("business_email");?>:<br><?php  echo "<b>".$settings['panel_email_address']."</b>"; ?></td>
+			  </tr>
+			  <tr>
+				<td height="23" colspan="5">&nbsp;</td>
+			  </tr>
+			  <tr>
+				<td height="23" style="border: 2px solid #000000" bgcolor="#CCCCCC"><div align="center"><strong><?php print_lang("item");?></strong></div></td>
+				<td width="150" style="border: 2px solid #000000" bgcolor="#CCCCCC"><div align="center"><strong><?php print_lang("invoice_duration");?></strong></div></td>
+				<td width="150" style="border: 2px solid #000000" bgcolor="#CCCCCC"><div align="center"><strong><?php print_lang("slot_cost");?></strong></div></td>
+				<td style="border: 2px solid #000000" bgcolor="#CCCCCC"><div align="center"><strong><?php print_lang("slot_quantity");?></strong></div></td>
+				<td style="border: 2px solid #000000" bgcolor="#CCCCCC"><div align="center"><strong><?php print_lang("order_price");?></strong></div></td>
+			  </tr>
+		<?php
+		$subtotal = 0;		
+		foreach($orders as $order)
+		{
+			$order_id = $order['order_id'];
+			$user_id = $order['user_id'];
+			$service_id = $order['service_id'];
+			$home_name = $order['home_name']." - ".$order_id;
+			$ip = $order['ip'];
+			$max_players = $order['max_players'];
+			$qty = $order['qty'];
+			$invoice_duration = $order['invoice_duration'];
+			$price = $order['price'];
+			$subtotal += $price;
+			$qry_service = "SELECT DISTINCT price_hourly, price_monthly, price_year FROM ".$table_prefix."billing_services WHERE service_id=".$service_id;
+			$result_service = $db->resultQuery($qry_service);
+			$row_service = $result_service[0];
+
+				//Calculating Costs
+				
+			if ($invoice_duration == "hour")
+			{
+			$price_slot=$row_service['price_hourly'];
+			}
+			elseif ($invoice_duration == "month")
+			{
+			$price_slot=$row_service['price_monthly'];
+			}
+			elseif ($invoice_duration == "year")
+			{
+			$price_slot=$row_service['price_year']*12;
+			}
+			$duration = $invoice_duration > 1 ? $invoice_duration."s":$invoice_duration;
+			?>			  
+			  <tr>
+				<td height="23"><?php  echo $order['home_name']; ?></td>
+				<td><?php  echo $qty." ".get_lang($duration); ?></td>
+				<td><?php  echo number_format( $price_slot, 2 )." ".$settings['currency']."/".get_lang($invoice_duration); ?></td>
+				<td><?php  echo $max_players; ?></td>
+				<td><?php  echo number_format( $price, 2 )." ".$settings['currency']; ?></td>
+			  </tr><?php
+		}
+		
+		$total = $subtotal+($cart[0]['tax_amount']/100*$subtotal);
+		
+		?>
+			  <tr>
+				<td height="24" colspan="5">&nbsp;</td>
+			  </tr>
+			  <tr>
+				<td colspan="3" rowspan="4">&nbsp;</td>
+				<td height="23" style="border: 2px solid #000000"><div align="right"><strong><?php print_lang("subtotal");?> : </strong></div></td>
+				<td style="border: 2px solid #000000"><?php  echo number_format( $subtotal, 2 )." ".$settings['currency']; ?></td>
+			  </tr>
+			  <tr>
+				<td height="23" style="border: 2px solid #000000"><div align="right"><strong><?php print_lang("tax");?> : </strong></div></td>
+				<td style="border: 2px solid #000000"><?php  echo $cart[0]['tax_amount']."%"; ?></td>
+			  </tr>
+			  <tr>
+				<td height="23" style="border: 2px solid #000000" bgcolor="#CCCCCC"><div align="right"><strong><?php print_lang("total");?> : </strong></div></td>
+				<td style="border: 2px solid #000000" bgcolor="#CCCCCC"><?php  echo $total." ".$settings['currency']; ?></td>
+			  </tr>
+			  <tr>
+				<td height="23" style="border: 2px solid #000000" bgcolor="#CCCCCC"><div align="right"><strong><?php print_lang("cart_id");?> : </strong></div></td>
+				<td style="border: 2px solid #000000" ><?php  echo $cart_id; ?></td>
+			  </tr>
+			  <tr>
+				<td height="23" style="border: 2px solid #000000" bgcolor="#CCCCCC"><div align="right"><strong><?php print_lang("date");?> : </strong></div></td>
+				<td style="border: 2px solid #000000"><?php  echo $cart[0]['date']; ?></td>
+			  </tr>
+			  <tr>
+				<td height="21" colspan="2">&nbsp;</td>
+			  </tr>
+			</table>
+			<br><br>
+			<form method='post' action='?m=billing&p=bill&type=cleared' >
+			<input type="hidden" name="cart_id" value="<?php echo $_POST['cart_id'];?>">
+			<input type="submit" value="<?php print_lang('print_invoice') ?>" />
+			</form>
+			<form method='post' action='?m=billing&p=<?php 
+			$isAdmin = $db->isAdmin($_SESSION['user_id']);
+			if ($isAdmin)
+			{
+				echo 'orders';
+			}
+			else
+			{
+				echo 'cart';
+			}
+			echo "'><input type='submit' value='";
+			print_lang('back');
+			?>'/>
+			</form>
+			<br><br><?php
+	}
+}	
+?>

+ 434 - 0
modules/billing/cart.php

@@ -0,0 +1,434 @@
+<?php
+function saveOrderToDb($user_id,$service_id,$home_name,$ip,$max_players,$qty,$invoice_duration,$price,$remote_control_password,$ftp_password,$cart_id,$home_id = "0",$extended = "0"){
+	global $db;
+	$fields['user_id'] = $user_id;
+	$fields['service_id'] = $service_id;
+	$fields['home_name'] = $home_name;
+	$fields['ip'] = $ip;
+	$fields['max_players'] = $max_players;
+	$fields['qty'] = $qty;
+	$fields['invoice_duration'] = $invoice_duration;
+	$fields['price'] = $price;
+	$fields['remote_control_password'] = $remote_control_password;
+	$fields['ftp_password'] = $ftp_password;
+	$fields['cart_id'] = $cart_id;
+	$fields['home_id'] = $home_id;
+	$fields['extended'] = $extended;
+	return $db->resultInsertId( 'billing_orders', $fields );
+}
+
+function assignOrdersToCart($user_id,$tax_amount,$currency){
+	global $db;
+	$fields['user_id'] = $user_id;
+	$fields['paid'] = '0';
+	$fields['tax_amount'] = $tax_amount;
+	$fields['currency'] = $currency;
+	return $db->resultInsertId( 'billing_carts', $fields );
+}
+
+function exec_ogp_module()
+{
+	error_reporting(E_ALL);
+	
+	global $db,$view,$settings;
+	
+	$user_id = $_SESSION['user_id'];
+	
+	
+	if( isset( $_POST["buy"] ) or isset( $_POST["pay_paypal"] ) or isset( $_POST["pay_paygol"] ) or isset( $_POST["pay_skrill"] ) or isset( $_POST["pay_robokassa"] ) )
+	{
+		if( isset( $_SESSION['CART'] ) )
+		{
+			$orders = $_SESSION['CART'];
+			// Fill The Cart on DB
+			$cart_id = assignOrdersToCart($user_id,$settings['tax_amount'],$settings['currency']);
+			foreach($orders as $order) 
+			{
+				$service_id = $order['service_id'];
+				$home_name = $order['home_name'];
+				$ip = $order['ip'];
+				$max_players = $order['max_players'];
+				$qty = $order['qty'];
+				$invoice_duration = $order['invoice_duration'];
+				$price = $order['price'];
+				$remote_control_password = $order['remote_control_password'];
+				$ftp_password = $order['ftp_password'];
+				//Save order to DB
+				saveOrderToDb($user_id,$service_id,$home_name,$ip,$max_players,$qty,$invoice_duration,$price,$remote_control_password,$ftp_password,$cart_id);
+			}
+			// Remove Cart From Session
+			unset($_SESSION['CART']);
+		}
+		else
+		{
+			$cart_id = $_POST['cart_id'];
+		}
+		
+		if ( !empty( $cart_id ) and isset( $_POST["pay_paypal"] ) and $settings['paypal'] == "1" )
+		{
+			echo '<meta http-equiv="refresh" content="0;url=home.php?m=billing&p=paypal&cart_id='.$cart_id.'" >';
+		}
+		elseif ( !empty( $cart_id ) and isset( $_POST["pay_paygol"] ) and $settings['paygol'] == "1" )
+		{
+			echo '<meta http-equiv="refresh" content="0;url=home.php?m=billing&p=paygol&cart_id='.$cart_id.'" >';
+		}
+		elseif ( !empty( $cart_id ) and isset( $_POST["pay_skrill"] ) and $settings['skrill'] == "1" )
+		{
+			echo '<meta http-equiv="refresh" content="0;url=home.php?m=billing&p=skrill&cart_id='.$cart_id.'" >';
+		}
+		elseif ( !empty( $cart_id ) and isset( $_POST["pay_robokassa"] ) and $settings['robokassa'] == "1" )
+		{
+			echo '<meta http-equiv="refresh" content="0;url=home.php?m=billing&p=robokassa&cart_id='.$cart_id.'" >';
+		}
+	}
+	
+	if( isset( $_POST["extend"] ) or isset( $_POST["extend_and_pay_paypal"] ) or isset( $_POST["extend_and_pay_paygol"] ) or isset( $_POST["extend_and_pay_skrill"] ) or isset( $_POST["extend_and_pay_robokassa"] ) )
+	{
+		$orders = $db->resultQuery("SELECT * FROM OGP_DB_PREFIXbilling_orders WHERE order_id=".$_POST['order_id']);
+		// Fill The Cart on DB
+		$cart_id = assignOrdersToCart($user_id,$settings['tax_amount'],$settings['currency']);
+		foreach($orders as $order) 
+		{
+			$service_id = $order['service_id'];
+			$home_name = $order['home_name'];
+			$ip = $order['ip'];
+			$max_players = $order['max_players'];
+			$qty = $_POST['qty'];
+			$invoice_duration = $_POST['invoice_duration'];
+			$remote_control_password = $order['remote_control_password'];
+			$ftp_password = $order['ftp_password'];
+			$home_id = $order['home_id'];
+			
+			$services = $db->resultQuery( "SELECT * 
+										   FROM OGP_DB_PREFIXbilling_services 
+										   WHERE service_id=".$service_id );
+			$service = $services[0];
+			//Calculating Price
+			switch ($_POST['invoice_duration']) 
+			{
+				case "hour":
+					$price_slot = $service['price_hourly'];
+					break;
+				case "month":
+					$price_slot = $service['price_monthly'];
+					break;
+				case "year":
+					$price_slot = $service['price_year']*12;
+					break;
+			}
+			$price = $max_players*$price_slot*$_POST['qty'];
+			//Save order to DB
+			$order_id = saveOrderToDb($user_id,$service_id,$home_name,$ip,$max_players,$qty,$invoice_duration,$price,$remote_control_password,$ftp_password,$cart_id,$home_id,"1");
+			//Change the old order expiration to -2 so it can not be extended, since there is a new order managing the same game home.
+			$db->query( "UPDATE OGP_DB_PREFIXbilling_orders
+						 SET end_date=-2
+						 WHERE order_id=".$_POST['order_id']);
+		}
+		
+		if ( !empty( $cart_id ) and isset( $_POST["extend_and_pay_paypal"] ) and $settings['paypal'] == "1" )
+		{
+			echo '<meta http-equiv="refresh" content="0;url=home.php?m=billing&p=paypal&cart_id='.$cart_id.'" >';
+		}
+		elseif ( !empty( $cart_id ) and isset( $_POST["extend_and_pay_paygol"] ) and $settings['paygol'] == "1" )
+		{
+			echo '<meta http-equiv="refresh" content="0;url=home.php?m=billing&p=paygol&cart_id='.$cart_id.'" >';
+		}
+		elseif ( !empty( $cart_id ) and isset( $_POST["extend_and_pay_skrill"] ) and $settings['skrill'] == "1" )
+		{
+			echo '<meta http-equiv="refresh" content="0;url=home.php?m=billing&p=skrill&cart_id='.$cart_id.'" >';
+		}
+		elseif ( !empty( $cart_id ) and isset( $_POST["extend_and_pay_robokassa"] ) and $settings['robokassa'] == "1" )
+		{
+			echo '<meta http-equiv="refresh" content="0;url=home.php?m=billing&p=robokassa&cart_id='.$cart_id.'" >';
+		}
+	}
+	
+	if(isset($_POST['remove']))
+	{
+		$cart_id = $_POST['cart_id'];
+		if( isset( $_SESSION['CART'][$cart_id] ) )
+		{
+			unset($_SESSION['CART'][$cart_id]);
+		}
+		$order_id = $_POST['order_id'];
+		$db->query( "DELETE FROM OGP_DB_PREFIXbilling_orders WHERE order_id=".$order_id );
+		$orders_in_cart = $db->resultQuery( "SELECT * FROM OGP_DB_PREFIXbilling_orders WHERE cart_id=".$cart_id );
+		if( !$orders_in_cart )
+		{
+			$db->query( "DELETE FROM OGP_DB_PREFIXbilling_carts WHERE cart_id=".$cart_id );
+		}
+
+	}
+		
+	?>
+	<style>
+	h4 {
+		width:250px;
+		height:25px;
+		background:#f5f5f5;
+		border-top-style:solid;
+		border-top-color:#afafaf;
+		border-top-width:1px;
+		border-style: solid;
+		border-color: #CFCFCF;
+		border-width: 1px;
+		padding-top:8px;
+		text-align: center;
+		font-family:"Trebuchet MS";
+	}
+	</style>
+	<h2><?php print_lang("your_cart");?></h2>
+	<?php
+	if( isset($_SESSION['CART']) and !empty($_SESSION['CART']) )
+	{
+		$carts[0] = $_SESSION['CART'];
+	}
+
+	$user_carts = $db->resultQuery( "SELECT * FROM OGP_DB_PREFIXbilling_carts WHERE user_id=".$user_id );
+	
+	if( $user_carts >=1 )
+	{
+		foreach ( $user_carts as $user_cart )
+		{
+			$cart_id = $user_cart['cart_id'];
+			$carts[$cart_id] = $db->resultQuery( "SELECT * FROM OGP_DB_PREFIXbilling_carts AS cart JOIN
+																OGP_DB_PREFIXbilling_orders AS orders  
+																ON orders.cart_id=cart.cart_id
+																WHERE cart.cart_id=".$cart_id );
+		}
+	}
+	
+	if( empty( $carts ) )
+	{
+		print_failure( get_lang('there_are_no_orders_in_cart') );
+		?>		
+		<a href="?m=billing&p=shop"><?php print_lang('back'); ?></a>
+		<?php
+		return;
+	}
+	foreach ( $carts as $orders )
+	{
+		if( !empty( $orders ) )
+		{
+			?>
+	<center>
+		<table style="width:95%;text-align:center;" class="center">
+			<tr>
+			 <th>
+			CART ID</th>
+			 <th>
+			<?php print_lang("order_desc");?></th>
+			 <th>
+			<?php print_lang("price");?>
+			 </th>
+			 <?php
+			 if(isset($orders[0]['paid']) and $orders[0]['paid'] == 3)
+			 {
+			 ?>
+			 <th>
+			 <?php print_lang('expiration_date');?>
+			 </th>
+			 <th>
+			 <?php print_lang('removal_date');?>
+			 </th>
+			 <?php
+			 }
+			 ?>
+			 <th>
+			 </th>
+			</tr>
+			<?php 
+			$subtotal = 0;
+			foreach($orders as $order)
+			{
+				if ( $order['qty'] > 1 ) 
+					$order['invoice_duration'] = $order['invoice_duration']."s";
+
+				$subtotal += $order['price'];
+				?>
+			<tr class="tr">
+			 <td>
+				<?php
+					echo "<b>".$order['cart_id']."</b>";
+				?>
+			 </td>
+			 <td>
+				<?php 
+				echo "<b>".$order['home_name']."</b> [".$order['qty']." ".get_lang($order['invoice_duration']).", ".$order['max_players']." ".get_lang('slots')."]";
+				?>
+			 </td>
+			 <td>
+				<?php 
+				echo $order['price'].$order['currency'];
+				?>
+			 </td>
+				<?php
+				if($order['paid'] == 0)
+				{
+					?>
+			 <td>
+			  <form method="post" action="">
+			   <input type="hidden" name="cart_id" value="<?php echo $order['cart_id'];?>">
+			   <input type="hidden" name="order_id" value="<?php echo @$order['order_id'];?>">
+			   <input type="submit" name="remove" value="<?php print_lang("remove_from_cart");?>">
+			  </form>
+			 </td><?php
+				}
+				elseif($order['paid'] == 3)
+				{
+					$warning_end_date = $order['end_date'] < date('YmdHi') ? "<b style='color:red;'>".get_lang('expired')."</b>" : "";
+					$warning_finish_date = $order['finish_date'] < date('YmdHi') ? "<b style='color:red;'>".get_lang('removed')."</b>" : "";
+					$warning_finish_date = ($order['end_date'] == '-2' and $order['finish_date'] != '-2') ? "&nbsp;<b style='color:green;'>".get_lang('extended')."</b>":$warning_finish_date;
+					$end_date = new DateTime($order['end_date']);
+					$formated_end_date = ($order['end_date'] != '-1' and $order['end_date'] != '-2') ? $end_date->format('d/m/Y H:i') : "";
+					$finish_date = new DateTime($order['finish_date']);
+					$formated_finish_date = $order['finish_date'] != '-2' ? $finish_date->format('d/m/Y H:i') : "";
+				?>
+			 <td>
+				<?php echo "$formated_end_date$warning_end_date";?>
+			 </td>
+			 <td>
+				<?php echo "$formated_finish_date$warning_finish_date";?>
+			 </td>
+			<?php
+				}
+				
+				if( isset( $order['end_date'] ) and $order['end_date'] == "-1" )
+				{
+					?>
+			 <td>
+			  <form method="post" action="">
+			   <input type="hidden" name="cart_id" value="<?php echo $order['cart_id'];?>">
+			   <input type="hidden" name="order_id" value="<?php echo $order['order_id'];?>">
+			   <select name="qty">
+					<?php 
+					$qty=1;
+					while($qty<=12)
+					{
+					echo "<option value='$qty'>$qty</option>";
+					$qty++;
+					}
+					?>
+			   </select>
+			   <select name="invoice_duration">
+					<?php
+					if( $settings['hourly'] == 1) echo '<option value="hour">'.get_lang('hours').'</option>';
+					if( $settings['monthly'] == 1) echo '<option value="month">'.get_lang('months').'</option>';
+					if( $settings['annually'] == 1) echo '<option value="year">'.get_lang('years').'</option>';
+					?>
+			   </select>
+			   <input type="submit" name="extend" value="<?php print_lang("extend");?>">
+			   <?php
+			   if($settings['paypal'] == "1")
+					echo '<input name="extend_and_pay_paypal" type="submit" value="'.get_lang("extend")." ".get_lang("and")." ".get_lang_f("pay_from", get_lang('paypal')).'">';
+				if($settings['paygol'] == "1")
+					echo '<input name="extend_and_pay_paygol" type="submit" value="'.get_lang("extend")." ".get_lang("and")." ".get_lang_f("pay_from", get_lang('paygol')).'">';
+				if($settings['skrill'] == "1")
+					echo '<input name="extend_and_pay_skrill" type="submit" value="'.get_lang("extend")." ".get_lang("and")." ".get_lang_f("pay_from", get_lang('skrill')).'">';
+				if($settings['robokassa'] == "1")
+					echo '<input name="extend_and_pay_robokassa" type="submit" value="'.get_lang("extend")." ".get_lang("and")." ".get_lang_f("pay_from", get_lang('robokassa')).'">';
+			   ?>
+			  </form>
+			 </td><?php
+				}
+				?>
+			</tr><?php
+			}
+			?>
+		</table>
+		<table style="width:95%;text-align:left;" class="center">
+			<tr>
+			 <td>
+			<?php print_lang("subtotal");?></td>
+			 <td>
+			<?php 
+			echo $subtotal.$order['currency'];?>
+			 </td>
+			</tr>
+			<tr>
+			 <td>
+			<?php print_lang("tax");?></td>
+			 <td>
+			<?php echo $order['tax_amount'];?>%
+			 </td>
+			</tr>
+			<tr>
+			 <td>
+			<?php print_lang("total");?>
+			 </td>
+			 <td>
+			<?php 
+			  $total = $subtotal+($order['tax_amount']/100*$subtotal);
+			  echo number_format( $total , 2 ).$order['currency'];
+			?>
+			 </td>
+			 <td>
+			  <?php
+			  if($order['paid'] == 1)
+			  {
+			  ?>
+			 <form method="post" action="home.php?m=billing&p=create_servers">
+			  <input type="hidden" name="cart_id" value="<?php echo $order['cart_id'];?>">
+			  <?php
+			 if($order['extended'] == "1")
+			 {
+			 ?>
+			  <input name="enable_server" type="submit" value="<?php print_lang("enable_server");?>">
+			 <?php 
+			 }
+			 else
+			 {
+			 ?>
+			  <input name="create_server" type="submit" value="<?php print_lang("create_server");?>">
+			 <?php 
+			 }
+			?>
+			 </form>
+			  <?php
+			  }
+			  elseif($order['paid'] == 2)
+			  {
+			  echo get_lang_f("payment_is_pending_of_approval");
+			  }
+			  elseif($order['paid'] == 3)
+			  {
+			  ?>
+			 <form method="post" action="?m=billing&p=bill">
+			  <input type="hidden" name="cart_id" value="<?php echo $order['cart_id'];?>">
+			  <input name="paid" type="submit" value="<?php print_lang("see_invoice");?>">
+			 </form>
+			  <?php
+			  }
+			  else
+			  {
+			  ?>
+			 <form method="post" action="">
+			  <input type="hidden" name="cart_id" value="<?php echo $order['cart_id'];?>">
+			  <input name="buy" type="submit" value="<?php print_lang("buy");?>">
+			  <?php
+			   if($settings['paypal'] == "1")
+					echo '<input name="pay_paypal" type="submit" value="'.get_lang_f("pay_from", get_lang('paypal')).'">';
+				if($settings['paygol'] == "1")
+					echo '<input name="pay_paygol" type="submit" value="'.get_lang_f("pay_from", get_lang('paygol')).'">';
+				if($settings['skrill'] == "1")
+					echo '<input name="pay_skrill" type="submit" value="'.get_lang_f("pay_from", get_lang('skrill')).'">';
+				if($settings['robokassa'] == "1")
+					echo '<input name="pay_robokassa" type="submit" value="'.get_lang_f("pay_from", get_lang('robokassa')).'">';
+			   ?>
+			 </form>
+			  <?php
+			  }
+			  ?>
+			  </form>
+			 </td>
+			</tr>
+		</table>
+	</center>
+			<?php
+		}
+	}
+	?>		
+	<a href="?m=billing&p=shop"><?php print_lang('back'); ?></a>
+	<?php
+}
+?>

+ 269 - 0
modules/billing/create_servers.php

@@ -0,0 +1,269 @@
+<?php
+require_once("includes/lib_remote.php");
+require_once("modules/config_games/server_config_parser.php");
+function exec_ogp_module()
+{
+	global $db,$view,$settings;
+	$user_id = $_SESSION['user_id'];
+	$cart_id = $_POST['cart_id'];
+	$cart_paid = $db->resultQuery( "SELECT paid FROM OGP_DB_PREFIXbilling_carts WHERE paid=1 AND cart_id=".$cart_id );
+	$isAdmin = $db->isAdmin( $_SESSION['user_id'] );
+	if ( $isAdmin )
+		$orders = $db->resultQuery( "SELECT * FROM OGP_DB_PREFIXbilling_orders WHERE cart_id=".$cart_id );
+	else
+		$orders = $db->resultQuery( "SELECT * FROM OGP_DB_PREFIXbilling_orders WHERE cart_id=".$cart_id." AND user_id=".$user_id );
+		
+	if( !empty($orders) and !empty($cart_paid) )
+	{
+		foreach($orders as $order)
+		{
+			$order_id = $order['order_id'];
+			$service_id = $order['service_id'];
+			$home_name = $order['home_name'];
+			$remote_control_password = $order['remote_control_password'];
+			$ftp_password = $order['ftp_password'];
+			$ip = $order['ip'];
+			$max_players = $order['max_players'];
+			$user_id = $order['user_id'];
+			$extended = $order['extended'] == "1" ? TRUE : FALSE;
+			
+			//Query service info	
+			$service = $db->resultQuery( "SELECT * 
+							   FROM OGP_DB_PREFIXbilling_services 
+							   WHERE service_id=".$service_id );
+							   
+			if( !empty( $service[0] ) )
+			{
+				$home_cfg_id = $service[0]['home_cfg_id'];
+				$mod_cfg_id = $service[0]['mod_cfg_id'];
+				$remote_server_id = $service[0]['remote_server_id'];
+				$ftp = $service[0]['ftp'];
+				$install_method = $service[0]['install_method'];
+				$manual_url = $service[0]['manual_url'];
+				$access_rights = $service[0]['access_rights'];
+			}
+			else
+				return;
+						
+			if($extended)
+			{
+				$home_id = $order['home_id'];
+				
+				//Get The home info without mods in 1 array (Necesary for remote connection).
+				$home_info = $db->getGameHomeWithoutMods($home_id);
+				
+				//Create the remote connection
+				$remote = new OGPRemoteLibrary($home_info['agent_ip'],$home_info['agent_port'],$home_info['encryption_key'],$home_info['timeout']);
+				
+				//Reassign the server
+				$db->assignHomeTo( "user", $user_id, $home_id, $access_rights );
+				
+				//Reenable the FTP account
+				if ($ftp == "enabled")
+				{
+					$remote->ftp_mgr("useradd", $home_info['home_id'], $home_info['ftp_password'], $home_info['home_path']);
+					$db->changeFtpStatus('enabled',$home_info['home_id']);
+				}
+				echo "<h4>".get_lang('success')."</h4><br><p>".get_lang('redirecting_to_game_monitor')."</p><br>";
+			}
+			else
+			{
+				//OPTIONS, change it at your choice;
+				$extra_params = "";//no extra params defined by default
+				$cpu_affinity = "NA";//Affinity to one core/thread of the cpu by number, use NA to disable it
+				$nice = "0";//Min priority=19 Max Priority=-19
+				
+				//Add Game home to database
+				$rserver = $db->getRemoteServer($remote_server_id);
+				$game_path = "/home/".$rserver['ogp_user']."/OGP_User_Files/billing/";
+				$home_id = $db->addGameHome( $remote_server_id, $user_id, $home_cfg_id, $game_path, $home_name, $remote_control_password, $ftp_password);
+				
+				//Add IP:Port Pair to the Game Home
+				$add_port = $db->addGameIpPort( $home_id, $ip, $db->getNextAvailablePort($ip,$home_cfg_id) );
+				
+				//Assign the Game Mod to the Game Home
+				$mod_id = $db->addModToGameHome( $home_id, $mod_cfg_id );
+				$db->updateGameModParams( $max_players, $extra_params, $cpu_affinity, $nice, $home_id, $mod_cfg_id );
+				$db->assignHomeTo( "user", $user_id, $home_id, $access_rights );
+				
+				//Get The home info without mods in 1 array (Necesary for remote connection).
+				$home_info = $db->getGameHomeWithoutMods($home_id);
+				
+				//Create the remote connection
+				$remote = new OGPRemoteLibrary($home_info['agent_ip'],$home_info['agent_port'],$home_info['encryption_key'],$home_info['timeout']);
+								
+				//Get Full home info in 1 array
+				$home_info = $db->getGameHome($home_id);
+				
+				//Read the Game Config from the XML file
+				$server_xml = read_server_config(SERVER_CONFIG_LOCATION."/".$home_info['home_cfg_file']);
+				
+				//Get Values from XML
+				$modkey = $home_info['mods'][$mod_id]['mod_key'];
+				$mod_xml = xml_get_mod($server_xml, $modkey);
+				$installer_name = $mod_xml->installer_name;
+				$mod_cfg_id = $home_info['mods'][$mod_id]['mod_cfg_id'];
+				
+				//Get Preinstall commands from db
+				$game_mod_precmd = $db->resultQuery("SELECT DISTINCT precmd FROM OGP_DB_PREFIXgame_mods WHERE mod_id='$mod_id'");
+				if ($game_mod_precmd[0]['precmd'] === NULL OR empty($game_mod_precmd[0]['precmd']))
+				{
+					$config_mod_precmd = $db->resultQuery("SELECT DISTINCT def_precmd FROM OGP_DB_PREFIXconfig_mods WHERE mod_cfg_id='$mod_cfg_id'");
+					if ($config_mod_precmd[0]['def_precmd'] === NULL OR empty($config_mod_precmd[0]['def_precmd']))
+						$precmd = "";
+					else
+						$precmd = $config_mod_precmd[0]['def_precmd'];
+				}
+				else
+					$precmd = $game_mod_precmd[0]['precmd'];
+					
+				//Get Postinstall commands from db
+				$game_mod_postcmd = $db->resultQuery("SELECT DISTINCT postcmd FROM OGP_DB_PREFIXgame_mods WHERE mod_id='$mod_id'");
+				if ($game_mod_postcmd[0]['postcmd'] === NULL OR empty($game_mod_postcmd[0]['postcmd']))
+				{
+					$config_mod_postcmd = $db->resultQuery("SELECT DISTINCT def_postcmd FROM OGP_DB_PREFIXconfig_mods WHERE mod_cfg_id='$mod_cfg_id'");
+					if ($config_mod_postcmd[0]['def_postcmd'] === NULL OR empty($config_mod_postcmd[0]['def_postcmd']))
+						$postcmd = "";
+					else
+						$postcmd = $config_mod_postcmd[0]['def_postcmd'];
+				}
+				else
+					$postcmd = $game_mod_postcmd[0]['postcmd'];
+
+				//Enable FTP account in remote server
+				if ($ftp == "enabled")
+				{
+					$remote->ftp_mgr("useradd", $home_info['home_id'], $home_info['ftp_password'], $home_info['home_path']);
+					$db->changeFtpStatus('enabled',$home_info['home_id']);
+				}
+				
+				//Install files for this service in the remote server
+				// -Steam
+				$exec_folder_path = clean_path($home_info['home_path'] . "/" . $server_xml->exe_location );
+				$exec_path = clean_path($exec_folder_path . "/" . $server_xml->server_exec_name );
+				
+				if ($install_method == "steam")
+				{
+					if ( $server_xml->installer == "steamcmd" )
+					{
+						if( preg_match("/win32/", $server_xml->game_key) OR preg_match("/win64/", $server_xml->game_key) ) 
+							$cfg_os = "windows";
+						elseif( preg_match("/linux/", $server_xml->game_key) )
+							$cfg_os = "linux";
+						
+						// Some games like L4D2 require anonymous login
+						if($mod_xml->installer_login){
+							$login = $mod_xml->installer_login;
+							$pass = '';
+						}else{
+							$login = $settings['steam_user'];
+							$pass = $settings['steam_pass'];
+						}
+						
+						$modname = ( $installer_name == '90' and !preg_match("/(cstrike|valve)/", $modkey) ) ? $modkey : '';
+						$betaname = isset($mod_xml->betaname) ? $mod_xml->betaname : '';
+						$betapwd = isset($mod_xml->betapwd) ? $mod_xml->betapwd : '';
+						
+						$remote->steam_cmd( $home_id,$home_info['home_path'],$installer_name,$modname,
+											$betaname,$betapwd,$login,$pass,$settings['steam_guard'],
+											$exec_folder_path,$exec_path,$precmd,$postcmd,$cfg_os ); 
+					}
+				}
+				// -Rsync
+				elseif ($install_method == "rsync")
+				{
+					//Rsync Server
+					$url = "rsync.opengamepanel.org";
+					//OS
+					if( preg_match("/win32/", $server_xml->game_key) OR preg_match("/win64/", $server_xml->game_key) ) 
+						$os = "windows";
+					elseif( preg_match("/linux/", $server_xml->game_key) )
+						$os = "linux";
+					//Rsync Game Name
+					if( isset($server_xml->lgsl_query_name) )
+					{
+						$rs_gname = $server_xml->lgsl_query_name;
+						if($rs_gname == "quake3")
+						{
+							if($server_xml->game_name == "Quake 3")
+								$rs_gname = "q3";
+						}
+					}
+					elseif( isset($server_xml->gameq_query_name) )
+					{
+						$rs_gname = $server_xml->gameq_query_name;
+						if($rs_gname == "minecraft")
+						{
+							if($server_xml->game_name == "Minecraft Tekkit")
+								$rs_gname = "tekkit";
+							elseif($server_xml->game_name == "Minecraft Bukkit")
+								$rs_gname = "bukkit";
+						}
+					}
+					elseif( isset($server_xml->protocol) )
+						$rs_gname = $server_xml->protocol;
+					else
+						$rs_gname = $server_xml->mods->mod['key'];
+					//Starting Sync
+					$full_url = "$url/ogp_game_installer/$rs_gname/$os/";
+					$remote->start_rsync_install($home_id,$home_info['home_path'],"$full_url",$exec_folder_path,$exec_path,$precmd,$postcmd);
+				}
+				// -Manual
+				elseif ($install_method == "manual")
+				{
+					// Start File Download and uncompress
+					$filename = !empty($manual_url) ? substr($manual_url, -9) : "";
+					$remote->start_file_download($manual_url,$home_info['home_path'],$filename,"uncompress");
+				}
+				echo "<h4>".get_lang('success')."</h4><br><p>".get_lang('starting_installations')."</p><br>";
+			}
+			// Set expiration date in ogp database
+			if ($order['invoice_duration'] == "hour")
+			{
+				$add_time = time() + ($order['qty'] * 60 * 60);
+				$end_date = date('YmdHi',$add_time);
+				$period_to_extend = time() + ( ( $order['qty'] * 60 * 60 ) + 900 ); // Fifteen minutes to extend or finish the server.
+				$finish_date = date('YmdHi',$period_to_extend);
+			}
+			elseif ($order['invoice_duration'] == "month")
+			{
+				$end_date = date('YmdHi', strtotime('+'.$order['qty'].' month'));
+				$finish_date = date('YmdHi', strtotime('+'.$order['qty'].' month 5 day')); // 5 days to extend or finish the server.
+			}
+			elseif ($order['invoice_duration'] == "year")
+			{
+				$end_date = date('YmdHi', strtotime('+'.$order['qty'].' year'));
+				$finish_date = date('YmdHi', strtotime('+'.$order['qty'].' year 15 day')); // Fifteen days to extend or finish the server.
+			}
+			// set order expire date
+			$db->query("UPDATE OGP_DB_PREFIXbilling_orders
+						SET end_date='$end_date' 
+						WHERE order_id=".$order_id);
+	
+			$db->query("UPDATE OGP_DB_PREFIXbilling_orders
+						SET finish_date='$finish_date' 
+						WHERE order_id=".$order_id);
+						
+			// Save home id created by this order
+			$db->query("UPDATE OGP_DB_PREFIXbilling_orders
+						SET home_id=$home_id 
+						WHERE order_id=".$order_id);
+						
+		}
+
+		//Update Cart Payment Status as 3(paid and installed)
+		$db->query("UPDATE OGP_DB_PREFIXbilling_carts
+					SET paid=3
+					WHERE cart_id=".$cart_id);
+
+		// Set payment/creation date
+		$date = date('d/m/Y H:i');
+		$db->query("UPDATE OGP_DB_PREFIXbilling_carts 
+					SET date='$date' 
+					WHERE cart_id=".$cart_id);
+
+		//Refresh to Game Monitor.
+		$view->refresh("home.php?m=gamemanager&p=game_monitor");
+	}
+}
+?>

+ 124 - 0
modules/billing/cron-shop.php

@@ -0,0 +1,124 @@
+<?php
+/*
+ *
+ * OGP - Open Game Panel
+ * Copyright (C) 2008 - 2010 The OGP Development Team
+ *
+ * http://www.opengamepanel.org/
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or 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, write to the Free Software
+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
+ *
+ */
+chdir(realpath(dirname(__FILE__))); /* Change to the current file path */
+chdir("../.."); /* Base path to ogp web files */
+// Report all PHP errors
+error_reporting(E_ALL);
+// Path definitions
+define("CONFIG_FILE","includes/config.inc.php");
+//Requiere
+require_once("includes/functions.php");
+require_once("includes/helpers.php");
+require_once("includes/html_functions.php");
+require_once("modules/config_games/server_config_parser.php");
+require_once("includes/lib_remote.php");
+require_once CONFIG_FILE;
+// Connect to the database server and select database.
+$db = createDatabaseConnection($db_type, $db_host, $db_user, $db_pass, $db_name, $table_prefix);
+
+$panel_settings = $db->getSettings();
+if( isset($panel_settings['time_zone']) && $panel_settings['time_zone'] != "" )
+	date_default_timezone_set($panel_settings['time_zone']);
+
+$today=date('YmdHi');
+$user_homes = $db->resultQuery( "SELECT * 
+								 FROM " . $table_prefix .  "billing_orders  
+								 WHERE end_date>0 AND end_date<".$today );
+								 
+if (!is_array($user_homes))
+{
+	echo "Nothing to do.\n";
+}
+else
+{
+	foreach($user_homes as $user_home)
+	{
+		$user_id = $user_home['user_id'];
+		$home_id = $user_home['home_id'];
+		$home_info = $db->getGameHomeWithoutMods($home_id);
+		$server_info = $db->getRemoteServerById($home_info['remote_server_id']);
+		$remote = new OGPRemoteLibrary($server_info['agent_ip'], $server_info['agent_port'], $server_info['encryption_key'],$server_info['timeout']);
+		$ftp_login = isset($home_info['ftp_login']) ? $home_info['ftp_login'] : $home_id;
+		$remote->ftp_mgr("userdel", $ftp_login);
+		$db->changeFtpStatus('disabled',$home_id);
+		$server_xml = read_server_config(SERVER_CONFIG_LOCATION."/".$home_info['home_cfg_file']);
+		if(isset($server_xml->control_protocol_type))$control_type = $server_xml->control_protocol_type; else $control_type = "";
+		$addresses = $db->getHomeIpPorts($home_id);
+		foreach($addresses as $address)
+		{	
+			$remote->remote_stop_server($home_id,$address['ip'],$address['port'],$server_xml->control_protocol,$home_info['control_password'],$control_type,$home_info['home_path']);
+		}
+		$db->unassignHomeFrom("user", $user_id, $home_id);
+							 
+		// Reset the invoice end date
+		$db->query( "UPDATE " . $table_prefix . "billing_orders
+					 SET end_date=-1
+					 WHERE order_id=".$user_home['order_id']);
+					 
+		echo "Home ID $home_id unassigned succesfull.";
+	}
+}
+
+$user_homes = $db->resultQuery( "SELECT * 
+								 FROM " . $table_prefix .  "billing_orders  
+								 WHERE end_date=-1 AND finish_date>0 AND finish_date<".$today );
+								 
+if (!is_array($user_homes))
+{
+	echo "Any server finishes now.";
+}
+else
+{
+	foreach($user_homes as $user_home)
+	{
+		$user_id = $user_home['user_id'];
+		$home_id = $user_home['home_id'];
+		$home_info = $db->getGameHomeWithoutMods($home_id);
+		$server_info = $db->getRemoteServerById($home_info['remote_server_id']);
+		$remote = new OGPRemoteLibrary($server_info['agent_ip'], $server_info['agent_port'], $server_info['encryption_key'],$server_info['timeout']);
+				
+		// Remove the game home from db 
+		$db->deleteGameHome($home_id);
+		
+		// Remove the game home files from remote server
+		$remote->remove_home($home_info['home_path']);
+		
+		// Set order as not installed
+		$db->query( "UPDATE " . $table_prefix . "billing_orders
+					 SET home_id=0
+					 WHERE cart_id=".$ipn['item_number']); 
+					 
+		// Reset the invoice end date
+		$db->query( "UPDATE " . $table_prefix . "billing_orders
+					 SET end_date=-2
+					 WHERE order_id=".$user_home['order_id']);
+					 
+		$db->query( "UPDATE " . $table_prefix . "billing_orders
+					 SET finish_date=-2
+					 WHERE order_id=".$user_home['order_id']);
+					 
+		echo "Home ID $home_id finished completely.";
+	}
+}
+?>

+ 309 - 0
modules/billing/ipnlistener.php

@@ -0,0 +1,309 @@
+<?php
+/**
+ *  PayPal IPN Listener
+ *
+ *  A class to listen for and handle Instant Payment Notifications (IPN) from 
+ *  the PayPal server.
+ *
+ *  https://github.com/Quixotix/PHP-PayPal-IPN
+ *
+ *  @package    PHP-PayPal-IPN
+ *  @author     Micah Carrick
+ *  @copyright  (c) 2011 - Micah Carrick
+ *  @version    2.0.5
+ *  @license    http://opensource.org/licenses/gpl-3.0.html
+ */
+class IpnListener {
+    
+    /**
+     *  If true, the recommended cURL PHP library is used to send the post back 
+     *  to PayPal. If flase then fsockopen() is used. Default true.
+     *
+     *  @var boolean
+     */
+    public $use_curl = false;     
+    
+    /**
+     *  If true, explicitly sets cURL to use SSL version 3. Use this if cURL
+     *  is compiled with GnuTLS SSL.
+     *
+     *  @var boolean
+     */
+    public $force_ssl_v3 = false;     
+   
+    /**
+     *  If true, cURL will use the CURLOPT_FOLLOWLOCATION to follow any 
+     *  "Location: ..." headers in the response.
+     *
+     *  @var boolean
+     */
+    public $follow_location = false;     
+    
+    /**
+     *  If true, an SSL secure connection (port 443) is used for the post back 
+     *  as recommended by PayPal. If false, a standard HTTP (port 80) connection
+     *  is used. Default true.
+     *
+     *  @var boolean
+     */
+    public $use_ssl = true;      
+    
+    /**
+     *  If true, the paypal sandbox URI www.sandbox.paypal.com is used for the
+     *  post back. If false, the live URI www.paypal.com is used. Default false.
+     *
+     *  @var boolean
+     */
+    public $use_sandbox = false; 
+    
+    /**
+     *  The amount of time, in seconds, to wait for the PayPal server to respond
+     *  before timing out. Default 30 seconds.
+     *
+     *  @var int
+     */
+    public $timeout = 30;       
+    
+    private $post_data = array();
+    private $post_uri = '';     
+    private $response_status = '';
+    private $response = '';
+
+    const PAYPAL_HOST = 'www.paypal.com';
+    const SANDBOX_HOST = 'www.sandbox.paypal.com';
+    
+    /**
+     *  Post Back Using cURL
+     *
+     *  Sends the post back to PayPal using the cURL library. Called by
+     *  the processIpn() method if the use_curl property is true. Throws an
+     *  exception if the post fails. Populates the response, response_status,
+     *  and post_uri properties on success.
+     *
+     *  @param  string  The post data as a URL encoded string
+     */
+    protected function curlPost($encoded_data) {
+
+        if ($this->use_ssl) {
+            $uri = 'https://'.$this->getPaypalHost().'/cgi-bin/webscr';
+            $this->post_uri = $uri;
+        } else {
+            $uri = 'http://'.$this->getPaypalHost().'/cgi-bin/webscr';
+            $this->post_uri = $uri;
+        }
+        
+        $ch = curl_init();
+        
+        curl_setopt($ch, CURLOPT_URL, $uri);
+        curl_setopt($ch, CURLOPT_POST, true);
+        curl_setopt($ch, CURLOPT_POSTFIELDS, $encoded_data);
+        curl_setopt($ch, CURLOPT_FOLLOWLOCATION, $this->follow_location);
+        curl_setopt($ch, CURLOPT_TIMEOUT, $this->timeout);
+        curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
+        curl_setopt($ch, CURLOPT_HEADER, true);
+        
+        if ($this->force_ssl_v3) {
+            curl_setopt($ch, CURLOPT_SSLVERSION, 3);
+        }
+        
+        $this->response = curl_exec($ch);
+        $this->response_status = strval(curl_getinfo($ch, CURLINFO_HTTP_CODE));
+        
+        if ($this->response === false || $this->response_status == '0') {
+            $errno = curl_errno($ch);
+            $errstr = curl_error($ch);
+            throw new Exception("cURL error: [$errno] $errstr");
+        }
+    }
+    
+    /**
+     *  Post Back Using fsockopen()
+     *
+     *  Sends the post back to PayPal using the fsockopen() function. Called by
+     *  the processIpn() method if the use_curl property is false. Throws an
+     *  exception if the post fails. Populates the response, response_status,
+     *  and post_uri properties on success.
+     *
+     *  @param  string  The post data as a URL encoded string
+     */
+    protected function fsockPost($encoded_data) {
+    
+        if ($this->use_ssl) {
+            $uri = 'ssl://'.$this->getPaypalHost();
+            $port = '443';
+            $this->post_uri = $uri.'/cgi-bin/webscr';
+        } else {
+            $uri = $this->getPaypalHost(); // no "http://" in call to fsockopen()
+            $port = '80';
+            $this->post_uri = 'http://'.$uri.'/cgi-bin/webscr';
+        }
+
+        $fp = fsockopen($uri, $port, $errno, $errstr, $this->timeout);
+        
+        if (!$fp) { 
+            // fsockopen error
+            throw new Exception("fsockopen error: [$errno] $errstr");
+        } 
+
+        $header = "POST /cgi-bin/webscr HTTP/1.0\r\n";
+        $header .= "Host: ".$this->getPaypalHost()."\r\n";
+        $header .= "Content-Type: application/x-www-form-urlencoded\r\n";
+        $header .= "Content-Length: ".strlen($encoded_data)."\r\n";
+        $header .= "Connection: Close\r\n\r\n";
+        
+        fputs($fp, $header.$encoded_data."\r\n\r\n");
+        
+        while(!feof($fp)) { 
+            if (empty($this->response)) {
+                // extract HTTP status from first line
+                $this->response .= $status = fgets($fp, 1024); 
+                $this->response_status = trim(substr($status, 9, 4));
+            } else {
+                $this->response .= fgets($fp, 1024); 
+            }
+        } 
+        
+        fclose($fp);
+    }
+    
+    private function getPaypalHost() {
+        if ($this->use_sandbox) return IpnListener::SANDBOX_HOST;
+        else return IpnListener::PAYPAL_HOST;
+    }
+    
+    /**
+     *  Get POST URI
+     *
+     *  Returns the URI that was used to send the post back to PayPal. This can
+     *  be useful for troubleshooting connection problems. The default URI
+     *  would be "ssl://www.sandbox.paypal.com:443/cgi-bin/webscr"
+     *
+     *  @return string
+     */
+    public function getPostUri() {
+        return $this->post_uri;
+    }
+    
+    /**
+     *  Get Response
+     *
+     *  Returns the entire response from PayPal as a string including all the
+     *  HTTP headers.
+     *
+     *  @return string
+     */
+    public function getResponse() {
+        return $this->response;
+    }
+    
+    /**
+     *  Get Response Status
+     *
+     *  Returns the HTTP response status code from PayPal. This should be "200"
+     *  if the post back was successful. 
+     *
+     *  @return string
+     */
+    public function getResponseStatus() {
+        return $this->response_status;
+    }
+    
+    /**
+     *  Get Text Report
+     *
+     *  Returns a report of the IPN transaction in plain text format. This is
+     *  useful in emails to order processors and system administrators. Override
+     *  this method in your own class to customize the report.
+     *
+     *  @return string
+     */
+    public function getTextReport() {
+        
+        $r = '';
+        
+        // date and POST url
+        for ($i=0; $i<80; $i++) { $r .= '-'; }
+        $r .= "\n[".date('m/d/Y g:i A').'] - '.$this->getPostUri();
+        if ($this->use_curl) $r .= " (curl)\n";
+        else $r .= " (fsockopen)\n";
+        
+        // HTTP Response
+        for ($i=0; $i<80; $i++) { $r .= '-'; }
+        $r .= "\n{$this->getResponse()}\n";
+        
+        // POST vars
+        for ($i=0; $i<80; $i++) { $r .= '-'; }
+        $r .= "\n";
+        
+        foreach ($this->post_data as $key => $value) {
+            $r .= str_pad($key, 25)."$value\n";
+        }
+        $r .= "\n\n";
+        
+        return $r;
+    }
+    
+    /**
+     *  Process IPN
+     *
+     *  Handles the IPN post back to PayPal and parsing the response. Call this
+     *  method from your IPN listener script. Returns true if the response came
+     *  back as "VERIFIED", false if the response came back "INVALID", and 
+     *  throws an exception if there is an error.
+     *
+     *  @param array
+     *
+     *  @return boolean
+     */    
+    public function processIpn($post_data=null) {
+
+        $encoded_data = 'cmd=_notify-validate';
+        
+        if ($post_data === null) { 
+            // use raw POST data 
+            if (!empty($_POST)) {
+                $this->post_data = $_POST;
+                $encoded_data .= '&'.file_get_contents('php://input');
+            } else {
+                throw new Exception("No POST data found.");
+            }
+        } else { 
+            // use provided data array
+            $this->post_data = $post_data;
+            
+            foreach ($this->post_data as $key => $value) {
+                $encoded_data .= "&$key=".urlencode($value);
+            }
+        }
+
+        if ($this->use_curl) $this->curlPost($encoded_data); 
+        else $this->fsockPost($encoded_data);
+        
+        if (strpos($this->response_status, '200') === false) {
+            throw new Exception("Invalid response status: ".$this->response_status);
+        }
+        
+        if (strpos($this->response, "VERIFIED") !== false) {
+            return true;
+        } elseif (strpos($this->response, "INVALID") !== false) {
+            return false;
+        } else {
+            throw new Exception("Unexpected response from PayPal.");
+        }
+    }
+    
+    /**
+     *  Require Post Method
+     *
+     *  Throws an exception and sets a HTTP 405 response header if the request
+     *  method was not POST. 
+     */    
+    public function requirePostMethod() {
+        // require POST requests
+        if ($_SERVER['REQUEST_METHOD'] && $_SERVER['REQUEST_METHOD'] != 'POST') {
+            header('Allow: POST', true, 405);
+            throw new Exception("Invalid HTTP request method.");
+        }
+    }
+}
+?>

+ 133 - 0
modules/billing/module.php

@@ -0,0 +1,133 @@
+<?php
+/*
+ *
+ * OGP - Open Game Panel
+ * Copyright (C) 2008 - 2010 The OGP Development Team
+ *
+ * http://www.opengamepanel.org/
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or 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, write to the Free Software
+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
+ *
+ */
+
+// Module general information
+$module_title = "billing";
+$module_version = "6.4";
+$db_version = 4;
+$module_required = FALSE;
+$module_menus = array(
+    array( 'subpage' => 'shop', 'name'=>'Shop', 'group'=>'user' ),
+	array( 'subpage' => 'shop_guest', 'name'=>'Shop', 'group'=>'guest' ),
+    array( 'subpage' => 'orders', 'name'=>'Orders', 'group'=>'admin' ),
+	array( 'subpage' => 'services', 'name'=>'Services', 'group'=>'admin' ),
+	array( 'subpage' => 'shop_settings', 'name'=>'Shop Settings', 'group'=>'admin' )
+);
+
+$install_queries = array();
+$install_queries[0] = array(
+	"DROP TABLE IF EXISTS `".OGP_DB_PREFIX."billing_services`;",
+    "CREATE TABLE IF NOT EXISTS `".OGP_DB_PREFIX."billing_services` (
+	`service_id` int(11) NOT NULL auto_increment,
+	`home_cfg_id` int(11) NOT NULL,
+	`mod_cfg_id` int(11) NOT NULL,
+	`service_name` varchar(255) NOT NULL,
+	`remote_server_id` int(11) NOT NULL,
+	`slot_max_qty` int(11) NOT NULL,
+	`slot_min_qty` int(11) NOT NULL,
+	`price_hourly` float(15,4) NOT NULL,
+	`price_monthly` float(15,4) NOT NULL,
+	`price_year` float(15,4) NOT NULL,
+	`description` varchar(1000) NOT NULL,
+	`img_url` varchar(255) NOT NULL,
+	`ftp` varchar(255) NOT NULL,
+	`install_method` varchar(255) NOT NULL,
+	`manual_url` varchar(255) NOT NULL, 
+	`access_rights` varchar(255) NOT NULL, 
+	PRIMARY KEY  (`service_id`)
+    ) ENGINE=MyISAM DEFAULT CHARSET=UTF8;",
+	
+    "DROP TABLE IF EXISTS `".OGP_DB_PREFIX."billing_orders`;",
+    "CREATE TABLE IF NOT EXISTS `".OGP_DB_PREFIX."billing_orders` (
+	`order_id` int(11) NOT NULL auto_increment,	
+	`user_id` int(11) NOT NULL,
+	`service_id` int(11) NOT NULL,
+	`home_path` varchar(255) NOT NULL,
+	`home_name` varchar(255) NOT NULL,
+	`ip` varchar(255) NOT NULL,
+	`port` varchar(5) NOT NULL,
+	`qty` int(11) NOT NULL,
+	`invoice_duration` varchar(16) NOT NULL,
+	`max_players` int(11) NOT NULL,
+	`remote_control_password` varchar(10) NULL,
+	`ftp_password` varchar(10) NULL,
+	`subtotal` float(15,2) NOT NULL,
+	`rate` int(11) NOT NULL,
+	`total` float(15,2) NOT NULL,
+	`date` varchar(10) NULL,
+	PRIMARY KEY  (`order_id`)
+	) ENGINE=MyISAM;"
+);
+
+$install_queries[1] = array(
+    "DROP TABLE IF EXISTS `".OGP_DB_PREFIX."billing_carts`;",
+    "CREATE TABLE IF NOT EXISTS `".OGP_DB_PREFIX."billing_carts` (
+	`cart_id` int(11) NOT NULL auto_increment,
+	`user_id` int(11) NOT NULL,
+	`paid` int(11) NULL,
+	PRIMARY KEY  (`cart_id`)
+    ) ENGINE=MyISAM DEFAULT CHARSET=UTF8;",
+	
+	"DROP TABLE IF EXISTS `".OGP_DB_PREFIX."billing_orders`;",
+    "CREATE TABLE IF NOT EXISTS `".OGP_DB_PREFIX."billing_orders` (
+	`order_id` int(11) NOT NULL auto_increment,
+	`user_id` int(11) NOT NULL,
+	`service_id` int(11) NOT NULL,
+	`home_path` varchar(255) NOT NULL,
+	`home_name` varchar(255) NOT NULL,
+	`ip` varchar(255) NOT NULL,
+	`qty` int(11) NOT NULL,
+	`invoice_duration` varchar(16) NOT NULL,
+	`max_players` int(11) NOT NULL,
+	`price` float(15,2) NOT NULL,
+	`remote_control_password` varchar(10) NULL,
+	`ftp_password` varchar(10) NULL,
+	`paid` varchar(1) NULL,
+	`date` varchar(10) NULL,
+	`cart_id` int(11) NOT NULL,
+	PRIMARY KEY  (`order_id`)
+	) ENGINE=MyISAM;"
+);
+
+$install_queries[2] = array(
+	"ALTER TABLE `".OGP_DB_PREFIX."billing_orders` DROP `date`;",
+	"ALTER TABLE `".OGP_DB_PREFIX."billing_orders` DROP `home_path`;",
+	"ALTER TABLE `".OGP_DB_PREFIX."billing_orders` DROP `paid`;",
+    "ALTER TABLE `".OGP_DB_PREFIX."billing_orders` ADD `home_id` varchar(255) NOT NULL DEFAULT '0';",
+	"ALTER TABLE `".OGP_DB_PREFIX."billing_orders` ADD `end_date` varchar(16) NOT NULL DEFAULT '0';",
+	"ALTER TABLE `".OGP_DB_PREFIX."billing_carts` ADD `date` varchar(16) NOT NULL DEFAULT '0';",
+	"ALTER TABLE `".OGP_DB_PREFIX."billing_carts` ADD `tax_amount` varchar(16) NOT NULL DEFAULT '0';",
+	"ALTER TABLE `".OGP_DB_PREFIX."billing_carts` ADD `currency` varchar(3) NOT NULL DEFAULT '0';"
+);
+
+$install_queries[3] = array(
+	"ALTER TABLE `".OGP_DB_PREFIX."billing_orders` ADD `finish_date` varchar(16) NOT NULL DEFAULT '0';"
+);
+
+$install_queries[4] = array(
+	"ALTER TABLE `".OGP_DB_PREFIX."billing_orders` ADD `extended` tinyint(1) NOT NULL;"
+);
+
+
+?>

+ 20 - 0
modules/billing/navigation.xml

@@ -0,0 +1,20 @@
+<navigation>
+  <!-- User Side -->
+  <page key="shop" file="shop.php" access="user,admin" />
+  <page key="cart" file="cart.php" access="user,admin" />
+  <page key="add_to_cart" file="add_to_cart.php" access="user,admin" />
+  <page key="paypal" file="paypal.php" access="user,admin" /> 
+  <page key="paygol" file="paygol.php" access="user,admin" /> 
+  <page key="skrill" file="skrill.php" access="user,admin" />
+  <page key="robokassa" file="robokassa.php" access="user,admin" />
+  <!-- Admin Side -->
+  <page key="shop_settings" file="settings.php" access="admin" />
+  <page key="services" file="services.php" access="admin" />
+  <page key="orders" file="orders.php" access="admin" />
+  <!-- Billing -->
+  <page key="paid" file="paid.php" access="user,admin" />
+  <page key="bill" file="bill.php" access="user,admin" /> 
+  <page key="create_servers" file="create_servers.php" access="user,admin" />
+  <!-- Guest -->
+  <page key="shop_guest" file="shop_guest.php" access="guest" />
+</navigation>

+ 190 - 0
modules/billing/orders.php

@@ -0,0 +1,190 @@
+<?php 
+function exec_ogp_module()
+{
+	error_reporting(E_ALL);
+	
+	global $db,$settings;
+	
+	if(isset($_POST['remove']))
+	{
+		$query_delete_order = $db->query("DELETE FROM OGP_DB_PREFIXbilling_orders WHERE cart_id=".$_POST['cart_id']);
+		$query_delete_order = $db->query("DELETE FROM OGP_DB_PREFIXbilling_carts WHERE cart_id=".$_POST['cart_id']);
+	}
+	if(isset($_POST['paid']))
+	{
+		$query_set_as_paid =  $db->query("UPDATE OGP_DB_PREFIXbilling_carts
+										  SET paid=1
+										  WHERE cart_id=".$_POST['cart_id']);
+	}
+	$status_array = array ( "not_paid" => 0,
+							"paid" => 1,
+							"procesing_payment" => 2,
+							"paid_and_installed" => 3
+						  );
+	?>
+	<style>
+	h4 {
+		width:250px;
+		height:25px;
+		background:#f5f5f5;
+		border-top-style:solid;
+		border-top-color:#afafaf;
+		border-top-width:1px;
+		border-style: solid;
+		border-color: #CFCFCF;
+		border-width: 1px;
+		padding-top:8px;
+		text-align: center;
+		font-family:"Trebuchet MS";
+	}
+	</style>
+	<h2><?php print_lang("orders");?></h2>
+	<?php
+
+	foreach($status_array as $status => $paid_value)
+	{
+		$carts = $db->resultQuery("SELECT * FROM OGP_DB_PREFIXbilling_carts WHERE paid=$paid_value;");
+
+		if( $carts > 0 )
+		{
+			?>
+		<h4><?php print_lang($status);?></h4><?php
+			foreach($carts as $cart) 
+			{
+			?>
+		<center>
+			<table style="width:100%;text-align:center;" class="center">
+				<tr>
+					<th><?php print_lang("login");?></th>
+					<th><?php print_lang("cart_id");?></th>
+					<th><?php print_lang("order_id");?></th>
+					<th><?php print_lang("home_name");?></th>
+					<th><?php print_lang("price");?></th>
+				<?php
+				if($status == "paid_and_installed")
+				{?>
+					<th><?php print_lang("installation_and_expiration_date");?></th>
+				<?php
+				}?>
+				</tr>
+				<?php  
+				$orders = $db->resultQuery("SELECT * FROM OGP_DB_PREFIXbilling_orders WHERE cart_id=".$cart['cart_id']);
+				$subtotal = 0;
+				foreach($orders as $order) 
+				{
+				if($order['qty'] > 1)
+					$order['invoice_duration'] = $order['invoice_duration']."s";
+				?>
+				<tr class="tr">
+					<td><a href="?m=user_admin&p=edit_user&user_id=<?php echo $order['user_id'];?>" ><?php $user = $db->getUserById($order['user_id']); echo $user['users_login'];?></a></td>
+					<td><b class="success"><?php echo $order['cart_id'];?></b></td>
+					<td><b class="success"><?php echo $order['order_id'];?></b></td>
+					<td><?php echo $order['home_name']." [ ".$order['max_players']." ".get_lang('slots').", ".$order['qty']." ".get_lang($order['invoice_duration'])." ]";?></td>
+					<td><?php echo $order['price'].$cart['currency'];?></td>
+					<?php
+					if($status == "paid_and_installed")
+					{
+						$warning_end_date = $order['end_date'] < date('YmdHi') ? "<b style='color:red;'>".get_lang('expired')."</b>":"";
+						$warning_finish_date = $order['finish_date'] < date('YmdHi') ? "<b style='color:red;'>".get_lang('removed')."</b>":"";
+						$warning_finish_date = ($order['end_date'] == '-2' and $order['finish_date'] != '-2') ? "&nbsp;<b style='color:green;'>".get_lang('extended')."</b>":$warning_finish_date;
+						$end_date = new DateTime($order['end_date']);
+						$formated_end_date = ($order['end_date'] != '-1' and $order['end_date'] != '-2')? $end_date->format('d/m/Y H:i') : "";
+						$finish_date = new DateTime($order['finish_date']);
+						$formated_finish_date = $order['finish_date'] != '-2' ? $finish_date->format('d/m/Y H:i') : "";
+						echo '<td>'.get_lang('expiration_date').": <b>$formated_end_date$warning_end_date</b>";
+						echo '<br>'.get_lang('removal_date').": <b>$formated_finish_date$warning_finish_date</b></td>";
+					}
+					?>
+			    </tr><?php 
+				$subtotal += $order['price'];
+				}
+				$total = $subtotal+($settings['tax_amount']/100*$subtotal);
+				?>
+				<tr>
+					<td>
+				<?php
+				if ($status == "not_paid")
+				{
+					?>
+					 <form method="post" action="">
+					  <input type="hidden" name="cart_id" value="<?php echo $order['cart_id'];?>">
+					  <input name="paid" type="submit" value="<?php print_lang("set_as_paid");?>">
+					 </form>
+					<?php
+				}
+				elseif($status == "paid")
+				{
+					?>
+					 <form method="post" action="home.php?m=billing&p=create_servers">
+					  <input type="hidden" name="cart_id" value="<?php echo $order['cart_id'];?>">
+					<?php
+					if($order['extended'] == "1")
+					{
+					?>
+					  <input name="enable_server" type="submit" value="<?php print_lang("enable_server");?>">
+					<?php 
+					}
+					else
+					{
+					?>
+					  <input name="create_server" type="submit" value="<?php print_lang("create_server");?>">
+					<?php 
+					}
+					?>
+					 </form>
+					<?php
+				}
+				elseif($status == "procesing_payment")
+				{
+					?>
+					 <form method="post" action="">
+					  <input type="hidden" name="cart_id" value="<?php echo $order['cart_id'];?>">
+					  <input name="paid" type="submit" value="<?php print_lang("set_as_paid");?>">
+					 </form>
+					<?php
+				}
+				elseif($status == "paid_and_installed")
+				{
+					?>
+					 <form method="post" action="?m=billing&p=bill">
+					  <input type="hidden" name="cart_id" value="<?php echo $order['cart_id'];?>">
+					  <input name="paid" type="submit" value="<?php print_lang("see_invoice");?>">
+					 </form>
+					<?php
+				}
+				?>
+					</td>
+					<td>
+					 <form method="post" action="">
+					  <input type="hidden" name="cart_id" value="<?php echo $order['cart_id'];?>">
+					  <input name="remove" type="submit" value="<?php print_lang("remove_cart");?>">
+					 </form>
+					</td>
+					<td>
+					 <?php echo get_lang('subtotal')." <b>".number_format( $subtotal , 2 ).$cart['currency']."</b>"; ?>
+					</td>
+					<td>
+					 <?php echo get_lang('tax')." <b>".$settings['tax_amount']."% (".number_format( $settings['tax_amount']/100*$subtotal, 2 ).$cart['currency'].")</b>"; ?>
+					</td>
+					<td>
+					 <?php echo get_lang('total')." <b>".number_format( $total , 2 ).$cart['currency']."</b>"; ?>
+					</td>
+					<?php
+					if($status == "paid_and_installed")
+					{
+					?>
+					<td>
+					 <?php echo get_lang('installation_date')." <b>".$cart['date']."</b>"; ?>
+					</td>
+					<?php
+					}
+					?>
+				</tr>
+			</table>
+		</center>
+				<?php
+			}
+		}
+	}
+}
+?>

+ 308 - 0
modules/billing/paid-ipn.php

@@ -0,0 +1,308 @@
+<?php
+ini_set('log_errors', true);
+ini_set('error_log', dirname(__FILE__).'/ipn_errors.log');
+
+// instantiate the IpnListener class
+include('ipnlistener.php');
+$listener = new IpnListener();
+
+// Enable sandbox for developers (https://developer.paypal.com)
+//$listener->use_sandbox = true;
+
+try {
+    $listener->requirePostMethod();
+    $verified = $listener->processIpn();
+} catch (Exception $e) {
+    error_log($e->getMessage());
+}
+
+chdir("../../"); /* It just makes life easier */
+
+set_include_path(get_include_path() . PATH_SEPARATOR . "includes/");
+
+/* Includes */
+require_once("helpers.php");
+require_once("config.inc.php");
+require_once("functions.php");
+require_once("lib_remote.php");
+require_once("lang.php");
+require_once("modules/config_games/server_config_parser.php");
+ogpLang();
+
+/* Query DB */
+$db = createDatabaseConnection($db_type, $db_host, $db_user, $db_pass, $db_name, $table_prefix);
+
+$panel_settings	= $db->getSettings();
+
+$s = ( isset($_SERVER['HTTPS']) and  get_true_boolean($_SERVER['HTTPS']) ) ? "s" : "";
+$p = isset($_SERVER['SERVER_PORT']) & $_SERVER['SERVER_PORT'] != "80" ? ":".$_SERVER['SERVER_PORT'] : NULL ;
+$this_script = 'http'.$s.'://'.$_SERVER['SERVER_NAME'].$p.$_SERVER['SCRIPT_NAME'];
+				
+function curPageName() 
+{
+	return substr($_SERVER["SCRIPT_NAME"],strrpos($_SERVER["SCRIPT_NAME"],"/")+1);
+}
+
+$current_folder_url = str_replace( curPageName(), "", $this_script);
+
+if( empty( $panel_settings['panel_name'] ) )
+	$panel_name = "Open Game Panel";
+else
+	$panel_name = $panel_settings['panel_name'];
+
+$ipn = $_POST;
+
+if(empty($ipn))
+{
+	exit(0);
+}
+
+$to = $ipn['receiver_email'] . ', ' . $ipn['payer_email'];
+
+$body = "<b>PayPal Payment For <a href='".
+		$current_folder_url.
+		"../../index.php?m=billing&p=shop_guest' >".
+		$panel_name."</a></b><br><br>".
+		"<h2>Order</h2>".
+		"- Item: ".$ipn['item_name']."<br>".
+		"- Item number: ".$ipn['item_number']."<br>".
+		"- Quantity: ".$ipn['quantity']."<br>".
+		"- Shipping: ".$ipn['shipping']."<br>".
+		"- Tax: ".$ipn['tax']."<br>".
+		"- Currency: ".$ipn['mc_currency']."<br>".
+		"- Currency fee: ".$ipn['mc_fee']."<br>".
+		"- Currency gross: ".$ipn['mc_gross']."<br>".
+		"- Transaction type: ".$ipn['txn_type']."<br>".
+		"- Transaction ID: ".$ipn['txn_id']."<br>".
+		"- Notify version: ".$ipn['notify_version']."<br><br>".
+		"<h2>Payer Info</h2>".
+		"- ID: ".$ipn['payer_id']."<br>".
+		"- First name: ".$ipn['first_name']."<br>".
+		"- Last name: ".$ipn['last_name']."<br>".	
+		"- Email: ".$ipn['payer_email']."<br>".
+		"- Email status: ".$ipn['payer_status']."<br><br>".
+		"<h2>Address</h2>".
+		"- Name: ".$ipn['address_name']."<br>".
+		"- Street: ".$ipn['address_street']."<br>".
+		"- City: ".$ipn['address_city']."<br>".
+		"- State: ".$ipn['address_state']."<br>".
+		"- Zip: ".$ipn['address_zip']."<br>".
+		"- Country code: ".$ipn['address_country_code']."<br>".
+		"- Country: ".$ipn['address_country']."<br>".
+		"- Residence country code: ".$ipn['residence_country']."<br>".
+		"- Address status: ".$ipn['address_status']."<br><br>".
+		"<h2>Payment Receiver Info</h2>".
+		"- Email: ".$ipn['receiver_email']."<br>".
+		"- ID: ".$ipn['receiver_id']."<br><br>".
+		"<h2>Payment</h2>".
+		"- Type: ".$ipn['payment_type']."<br>".
+		"- Date: ".$ipn['payment_date']."<br>".
+		"- Status: ".$ipn['payment_status']."<br>";
+/*
+The processIpn() method returned true if the IPN was "VERIFIED" and false if it
+was "INVALID".
+*/
+if ($verified AND isset( $ipn['payment_status'] ) ) 
+{
+	$user_homes = $db->resultQuery( "SELECT * 
+									 FROM OGP_DB_PREFIXbilling_carts AS cart
+									 JOIN
+									 OGP_DB_PREFIXbilling_orders AS orders  
+									 ON 
+									 orders.cart_id=cart.cart_id
+									 WHERE cart.cart_id=".$ipn['item_number']);
+	if( $ipn['payment_status']=="Completed" OR $ipn['payment_status']=="Canceled_Reversal" )
+	{  
+		$cart_id = $ipn['item_number'];
+
+		$cart_price_info = $db->resultQuery( "SELECT price,tax_amount 
+											 FROM OGP_DB_PREFIXbilling_carts AS cart
+											 JOIN
+											 OGP_DB_PREFIXbilling_orders AS orders  
+											 ON 
+											 orders.cart_id=cart.cart_id
+											 WHERE cart.cart_id=".$cart_id);
+											 
+		$cart_price = number_format( $cart_price_info[0]['price'] + (($cart_price_info[0]['price']/100)*$cart_price_info[0]['tax_amount']) , 2 );
+		$paid_price = $ipn['mc_gross'];
+		if($cart_price > $paid_price)
+		{	
+			// If for some reason someone achieves to hack the price then we will just change the order price.
+			// By a rule of Three:
+			// new price without tax = ( new price with tax * old price without tax ) / old price with tax
+			$new_price = ( ($cart_price - $paid_price) * $cart_price_info[0]['price'] ) / $cart_price;
+			// we don't want to loose money in this fraudulent transaction, 
+			// so if the rounded new price is less than the new price then we sum one cent to the rounded value.
+			if($new_price > number_format( $new_price, 2 ))
+				$new_price = number_format( $new_price, 2 ) + 0.01;
+			
+			$subject = "Error: Incorrect payment amount";
+			$body = "<b>PayPal Payment For <a href='".
+					$current_folder_url.
+					"../../index.php?m=billing&p=shop_guest' >".
+					$panel_name."</a></b><br><br>".
+					"<h2>Order</h2>".
+					"- Item: ".$ipn['item_name']."<br>".
+					"- Item number: ".$ipn['item_number']."<br>".
+					"- Quantity: ".$ipn['quantity']."<br>".
+					"- Shipping: ".$ipn['shipping']."<br>".
+					"- Tax: ".$ipn['tax']."<br>".
+					"- Currency: ".$ipn['mc_currency']."<br>".
+					"- Currency fee: ".$ipn['mc_fee']."<br>".
+					"- Currency gross: ".$ipn['mc_gross']."<br>".
+					"- Transaction type: ".$ipn['txn_type']."<br>".
+					"- Transaction ID: ".$ipn['txn_id']."<br>".
+					"- Notify version: ".$ipn['notify_version']."<br><br>".
+					"<h2>Payer Info</h2>".
+					"- ID: ".$ipn['payer_id']."<br>".
+					"- First name: ".$ipn['first_name']."<br>".
+					"- Last name: ".$ipn['last_name']."<br>".	
+					"- Email: ".$ipn['payer_email']."<br>".
+					"- Email status: ".$ipn['payer_status']."<br><br>".
+					"<h2>Address</h2>".
+					"- Name: ".$ipn['address_name']."<br>".
+					"- Street: ".$ipn['address_street']."<br>".
+					"- City: ".$ipn['address_city']."<br>".
+					"- State: ".$ipn['address_state']."<br>".
+					"- Zip: ".$ipn['address_zip']."<br>".
+					"- Country code: ".$ipn['address_country_code']."<br>".
+					"- Country: ".$ipn['address_country']."<br>".
+					"- Residence country code: ".$ipn['residence_country']."<br>".
+					"- Address status: ".$ipn['address_status']."<br><br>".
+					"<h2>Payment Receiver Info</h2>".
+					"- Email: ".$ipn['receiver_email']."<br>".
+					"- ID: ".$ipn['receiver_id']."<br><br>".
+					"<h2>Payment</h2>".
+					"- Type: ".$ipn['payment_type']."<br>".
+					"- Date: ".$ipn['payment_date']."<br>".
+					"- Status: ".$ipn['payment_status']."<br>".
+					'<b style="color:red;">amount paid</b>: '.$paid_price."<br>".
+					'<b style="color:red;">amount owed</b>: '.$new_price."<br>";
+			mymail($panel_settings['panel_email_address'], $subject, $body, $panel_settings);
+			die("Error: Incorrect payment amount");
+		}
+		$query = "UPDATE OGP_DB_PREFIXbilling_carts
+				  SET paid=1
+				  WHERE cart_id=".$ipn['item_number'];
+				  
+		foreach($user_homes as $user_home)
+		{			
+			if($user_home['home_id'] != 0)
+			{
+				$home_id = $user_home['home_id'];
+				$home_info = $db->getGameHomeWithoutMods($home_id);
+				$server_info = $db->getRemoteServerById($home_info['remote_server_id']);
+				$remote = new OGPRemoteLibrary($server_info['agent_ip'], $server_info['agent_port'], $server_info['encryption_key'], $server_info['timeout']);
+
+				if ( isset( $home_info['ftp_password'] ) AND !empty( $home_info['ftp_password'] ) )
+				{
+					$remote->ftp_mgr("useradd", $home_info['home_id'], $home_info['ftp_password'], $home_info['home_path']);
+					$db->changeFtpStatus('enabled',$home_info['home_id']);
+				}
+
+				if ($user_home['end_date'] == "0")
+				{
+					if ($user_home['invoice_duration'] == "hour")
+					{
+						$add_time = time() + ($user_home['qty'] * 60 * 60);
+						$end_date = date('YmdHi',$add_time);
+						$period_to_extend = time() + ( ( $user_home['qty'] * 60 * 60 ) + 900 ); // Fifteen minutes to extend or finish the server.
+						$finish_date = date('YmdHi',$period_to_extend);
+					}
+					elseif ($user_home['invoice_duration'] == "month")
+					{
+						$end_date = date('YmdHi', strtotime('+'.$user_home['qty'].' month'));
+						$finish_date = date('YmdHi', strtotime('+'.$user_home['qty'].' month 5 day'));
+					}
+					elseif ($user_home['invoice_duration'] == "year")
+					{
+						$end_date = date('YmdHi', strtotime('+'.$user_home['qty'].' year'));
+						$finish_date = date('YmdHi', strtotime('+'.$user_home['qty'].' year 15 day'));
+					}
+			
+					//Set the expiration date to the new order
+					$db->query("UPDATE OGP_DB_PREFIXbilling_orders
+								SET end_date='$end_date'
+								WHERE order_id=".$user_home['order_id']);
+								 
+					$db->query("UPDATE OGP_DB_PREFIXbilling_orders
+								SET finish_date='$finish_date' 
+								WHERE order_id=".$user_home['order_id']);
+								 
+					// Set payment/creation date
+					$date = date('d/m/Y H:i');
+					$db->query("UPDATE OGP_DB_PREFIXbilling_carts
+								SET date='$date'
+								WHERE cart_id=".$ipn['item_number']);
+				}
+				
+				$services = $db->resultQuery( "SELECT * 
+											   FROM OGP_DB_PREFIXbilling_services
+											   WHERE service_id=".$user_home['service_id']);
+				$service = $services[0];
+				$user_id = $user_home['user_id'];
+				$db->assignHomeTo("user", $user_id, $home_id, $service['access_rights']);
+				
+				$query = "UPDATE OGP_DB_PREFIXbilling_carts
+						  SET paid=3
+						  WHERE cart_id=".$ipn['item_number'];
+			}
+		}
+	}
+	elseif( $ipn['payment_status']=="Pending" OR $ipn['payment_status']=="In-Progress" )
+	{
+		$query = "UPDATE OGP_DB_PREFIXbilling_carts
+				  SET paid=2
+				  WHERE cart_id=".$ipn['item_number'];
+	}
+	elseif( $ipn['payment_status']=="Reversed" OR $ipn['payment_status']=="Refunded" OR $ipn['payment_status']=="Denied" OR $ipn['payment_status']=="Expired" OR $ipn['payment_status']=="Failed" OR $ipn['payment_status']=="Voided" OR $ipn['payment_status']=="Partially_Refunded" )
+	{
+		$body .= "- Reason code: ".$ipn['reason_code']; 
+				 
+		$query = "UPDATE OGP_DB_PREFIXbilling_carts
+				  SET paid=0
+				  WHERE cart_id=".$ipn['item_number'];
+		
+		foreach($user_homes as $user_home)
+		{
+			$user_id = $user_home['user_id'];
+			
+			if($user_home['home_id'] != 0)
+			{
+				$home_id = $user_home['home_id'];
+				$home_info = $db->getGameHomeWithoutMods($home_id);
+				$server_info = $db->getRemoteServerById($home_info['remote_server_id']);
+				$remote = new OGPRemoteLibrary($server_info['agent_ip'], $server_info['agent_port'], $server_info['encryption_key'], $server_info['timeout']);
+				$update_ftp_users = "pure-pw userdel ".$home_id." && pure-pw mkdb";
+				$remote->sudo_exec( $update_ftp_users );
+				$addresses = $db->getHomeIpPorts($home_id);
+				
+				foreach($addresses as $address)
+				{	
+					$server_xml = read_server_config(SERVER_CONFIG_LOCATION."/".$home_info['home_cfg_file']);
+					if(isset($server_xml->control_protocol_type))$control_type = $server_xml->control_protocol_type; else $control_type = "";
+					$remote->remote_stop_server($home_id,$address['ip'],$address['port'],$server_xml->control_protocol,$home_info['control_password'],$control_type);
+				}
+				$db->unassignHomeFrom("user", $user_id, $home_id);
+				
+				/*
+				// Remove the game home from db 
+				$db->deleteGameHome($home_id);
+				
+				// Remove the game home files from remote server
+				$remote->remove_home($home_info['home_path']);
+				
+				// Set order as not installed
+				$db->resultQuery( "UPDATE OGP_DB_PREFIXbilling_orders
+								   SET home_id=0
+								   WHERE home_id=".$home_id); 
+				*/
+			}
+		}
+	}		  
+	$db->query($query);
+	$subject = "Payment ".$ipn['payment_status'];
+	mymail($to, $subject, $body, $panel_settings);
+}
+
+?>

+ 18 - 0
modules/billing/paid.php

@@ -0,0 +1,18 @@
+<?php
+function exec_ogp_module()
+{	
+	if (isset($_POST['payment_status']) AND ($_POST['payment_status']=="Completed" OR $_POST['payment_status']=="Canceled_Reversal"))
+	{
+		echo "<html><head><title>Success</title></head><body><h4>Thank you for your order.</h4>";
+	}
+	else if (isset($_POST['payment_status']) AND ( $_POST['payment_status']=="Pending" OR $_POST['payment_status']=="In-Progress" OR $_POST['payment_status']=="Partially_Refunded" ) )
+	{
+		echo "<html><head><title>Pending</title></head><body><h4>Pending<br>Thank you for your order.</h4><br><p style='color:red'>Payment process is pending</p>";
+	}
+	else if (isset($_POST['payment_status']) AND ($_POST['payment_status']=="Reversed" OR $_POST['payment_status']=="Refunded" OR $_POST['payment_status']=="Denied" OR $_POST['payment_status']=="Expired" OR $_POST['payment_status']=="Failed" OR $_POST['payment_status']=="Voided"))
+	{
+		echo "<html><head><title>Reversed OR Refunded</title></head><body><h4>Reversed OR Refunded</h4>";
+	}
+	echo "<meta HTTP-EQUIV='REFRESH' content='2; url=?m=billing&p=cart'>";
+}
+?>

+ 156 - 0
modules/billing/paygol-ipn.php

@@ -0,0 +1,156 @@
+<?php
+// check that the request comes from PayGol server
+if(!in_array($_SERVER['REMOTE_ADDR'],
+  array('109.70.3.48', '109.70.3.146', '109.70.3.58'))) {
+  header("HTTP/1.0 403 Forbidden");
+  die("Error: Unknown IP");
+}
+
+ini_set('log_errors', true);
+ini_set('error_log', dirname(__FILE__).'/paygol-ipn_errors.log');
+chdir("../../"); /* It just makes life easier */
+
+set_include_path(get_include_path() . PATH_SEPARATOR . "includes/");
+
+/* Includes */
+require_once("helpers.php");
+require_once("config.inc.php");
+require_once("functions.php");
+require_once("lib_remote.php");
+require_once("lang.php");
+require_once("modules/config_games/server_config_parser.php");
+ogpLang();
+
+/* Query DB */
+$db = createDatabaseConnection($db_type, $db_host, $db_user, $db_pass, $db_name, $table_prefix);
+
+$panel_settings	= $db->getSettings();
+
+$body = 'message_id	= '.$_GET['message_id']."<br>".
+		'shortcode	= '.$_GET['shortcode']."<br>".
+		'keyword	= '.$_GET['keyword']."<br>".
+		'message	= '.$_GET['message']."<br>".
+		'sender		= '.$_GET['sender']."<br>".
+		'operator	= '.$_GET['operator']."<br>".
+		'country	= '.$_GET['country']."<br>".
+		'points		= '.$_GET['points']."<br>".
+		'price		= '.$_GET['price']."<br>".
+		'currency	= '.$_GET['currency']."<br>".
+		'service_id	= '.$_GET['service_id']."<br>".
+		'###cart_id	= '.$_GET['custom']."<br>";
+
+$cart_id = $_GET['custom'];
+
+$cart_price_info = $db->resultQuery( "SELECT price,tax_amount 
+									 FROM OGP_DB_PREFIXbilling_carts AS cart
+									 JOIN
+									 OGP_DB_PREFIXbilling_orders AS orders  
+									 ON 
+									 orders.cart_id=cart.cart_id
+									 WHERE cart.cart_id=".$cart_id);
+									 
+$cart_price = number_format( $cart_price_info[0]['price'] + (($cart_price_info[0]['price']/100)*$cart_price_info[0]['tax_amount']) , 2 );
+$paid_price = $_GET['price'];
+if($cart_price > $paid_price)
+{	
+	// If for some reason someone achieves to hack the price then we will just change the order price.
+	// By a rule of Three:
+	// new price without tax = ( new price with tax * old price without tax ) / old price with tax
+	$new_price = ( ($cart_price - $paid_price) * $cart_price_info[0]['price'] ) / $cart_price;
+	// we don't want to loose money in this fraudulent transaction, 
+	// so if the rounded new price is less than the new price then we sum one cent to the rounded value.
+	if($new_price > number_format( $new_price, 2 ))
+		$new_price = number_format( $new_price, 2 ) + 0.01;
+	
+	$subject = "Error: Incorrect payment amount";
+	$body = 'message_id	 = '.$_GET['message_id']."<br>".
+			'shortcode	 = '.$_GET['shortcode']."<br>".
+			'keyword	 = '.$_GET['keyword']."<br>".
+			'message	 = '.$_GET['message']."<br>".
+			'sender		 = '.$_GET['sender']."<br>".
+			'operator	 = '.$_GET['operator']."<br>".
+			'country	 = '.$_GET['country']."<br>".
+			'points		 = '.$_GET['points']."<br>".
+			'price		 = '.$_GET['price']."<br>".
+			'currency	 = '.$_GET['currency']."<br>".
+			'service_id	 = '.$_GET['service_id']."<br>".
+			'CART ID	 = '.$_GET['custom']."<br>".
+			'<b style="color:red;">Amount paid</b>: '.$paid_price."<br>".
+			'<b style="color:red;">Amount owed</b>: '.$new_price."<br>";
+	mymail($panel_settings['panel_email_address'], $subject, $body, $panel_settings);
+	die("Error: Incorrect payment amount");
+}
+
+// Here you can do whatever you want with the variables, for instance inserting or updating data into your Database
+
+$user_homes = $db->resultQuery( "SELECT * 
+								 FROM OGP_DB_PREFIXbilling_carts AS cart
+								 JOIN
+								 OGP_DB_PREFIXbilling_orders AS orders  
+								 ON 
+								 orders.cart_id=cart.cart_id
+								 WHERE cart.cart_id=".$cart_id);
+
+$query = "UPDATE " . $table_prefix . "billing_carts
+		  SET paid=1
+		  WHERE cart_id=".$cart_id;
+				  
+foreach($user_homes as $user_home)
+{			
+	if($user_home['home_id'] != 0)
+	{
+		$home_id = $user_home['home_id'];
+		$home_info = $db->getGameHomeWithoutMods($home_id);
+		$server_info = $db->getRemoteServerById($home_info['remote_server_id']);
+		$remote = new OGPRemoteLibrary($server_info['agent_ip'], $server_info['agent_port'], $server_info['encryption_key'], $server_info['timeout']);
+		
+		if ( isset( $home_info['ftp_password'] ) AND !empty( $home_info['ftp_password'] ) )
+		{
+			$remote->ftp_mgr("useradd", $home_info['home_id'], $home_info['ftp_password'], $home_info['home_path']);
+			$db->changeFtpStatus('enabled',$home_info['home_id']);
+		}
+
+		if ($user_home['end_date'] == "0")
+		{
+			if ($user_home['invoice_duration'] == "hour")
+			{
+				$add_time = time() + ($user_home['qty'] * 60 * 60);
+				$end_date = date('YmdHi',$add_time);
+			}
+			elseif ($user_home['invoice_duration'] == "month")
+			{
+				$end_date = date('YmdHi', strtotime('+'.$user_home['qty'].' month'));
+			}
+			elseif ($user_home['invoice_duration'] == "year")
+			{
+				$end_date = date('YmdHi', strtotime('+'.$user_home['qty'].' year'));
+			}
+			//Set the expiration date to the new order
+			$db->query( "UPDATE " . $table_prefix . "billing_orders
+						 SET end_date='$end_date'
+						 WHERE order_id=".$user_home['order_id']);
+						 
+			// Set payment/creation date
+			$date = date('d/m/Y H:i');
+			$db->query( "UPDATE OGP_DB_PREFIXbilling_carts
+						 SET date='$date'
+						 WHERE cart_id=".$cart_id);
+		}
+		
+		$services = $db->resultQuery( "SELECT * 
+									   FROM OGP_DB_PREFIXbilling_services
+									   WHERE service_id=".$user_home['service_id']);
+		$service = $services[0];
+		$user_id = $user_home['user_id'];
+		$db->assignHomeTo("user", $user_id, $home_id, $service['access_rights']);
+		
+		$query = "UPDATE " . $table_prefix . "billing_carts
+				  SET paid=3
+				  WHERE cart_id=".$cart_id;
+	}
+}
+	
+$db->query($query);
+$subject = "Payment done.";
+mymail($panel_settings['panel_email_address'], $subject, $body, $panel_settings);
+?>

+ 66 - 0
modules/billing/paygol.php

@@ -0,0 +1,66 @@
+<?php
+function curPageName() 
+{
+	return substr($_SERVER["SCRIPT_NAME"],strrpos($_SERVER["SCRIPT_NAME"],"/")+1);
+}
+
+function exec_ogp_module()
+{
+	global $db,$view;
+	
+	$settings = $db->getSettings();
+	
+	$cart_id = $_GET['cart_id'];
+
+	if(!empty($cart_id))
+	{		
+		$orders = $db->resultQuery( "SELECT * FROM OGP_DB_PREFIXbilling_orders WHERE cart_id=".$cart_id );
+		if( !empty( $orders ) )
+		{
+			$cart['price'] = 0;
+			foreach($orders as $order) 
+			{
+				if( $order['qty'] > 1 )
+					$order['invoice_duration'] = $order['invoice_duration']."s";
+				
+				$cart['price'] += $order['price'];
+				
+				if( !isset( $cart['name'] ) )
+					$cart['name'] = $order['home_name']."(".$order['qty'].get_lang($order['invoice_duration']).",".$order['max_players'].get_lang('slots').")";
+				else
+					$cart['name'] .= ' + '.$order['home_name']."(".$order['qty'].get_lang($order['invoice_duration']).",".$order['max_players'].get_lang('slots').")";
+			}
+			
+			$total = $cart['price']+($settings['tax_amount']/100*$cart['price']);
+			if ($total === 0)
+			{
+				$db->query("UPDATE " . $table_prefix . "billing_carts
+												SET paid=1
+												WHERE cart_id=".$cart_id);
+				$view->refresh("home.php?m=billing&p=cart",0);
+			}
+			else
+			{
+				$s = ( isset($_SERVER['HTTPS']) and  get_true_boolean($_SERVER['HTTPS']) ) ? "s" : "";
+				$p = isset($_SERVER['SERVER_PORT']) & $_SERVER['SERVER_PORT'] != "80" ? ":".$_SERVER['SERVER_PORT'] : NULL ;
+				$this_script = 'http'.$s.'://'.$_SERVER['SERVER_NAME'].$p.$_SERVER['SCRIPT_NAME'];
+				$current_folder_url = str_replace( curPageName(), "", $this_script);
+				
+				echo '<script src="http://www.paygol.com/micropayment/js/paygol.js" type="text/javascript"></script>'.
+					 '<form name="pg_frm">'.
+				     ' <input type="hidden" name="pg_serviceid" value="'.$settings['paygol_service_id'].'">'."\n".
+					 ' <input type="hidden" name="pg_currency" value="'.$settings['currency'].'">'."\n".
+					 ' <input type="hidden" name="pg_name" value=\''.$cart['name'].'\'>'."\n".
+					 ' <input type="hidden" name="pg_custom" value="'.$cart_id.'">'."\n".
+					 ' <input type="hidden" name="pg_price" value="'.number_format( $total , 2 ).'">'."\n".
+					 ' <input type="hidden" name="pg_return_url" value="'.urlencode($this_script.'?m=billing&p=cart').'">'."\n".
+					 ' <input type="hidden" name="pg_cancel_url" value="'.$this_script.'?m=billing&p=cart">'."\n".
+					 ' <input type="hidden" name="pg_notify_url" value="'.$current_folder_url.'modules/billing/paygol-ipn.php">'."\n".
+					 ' <input type="image" name="pg_button" class="paygol" src="http://www.paygol.com/micropayment/img/buttons/150/black_en_pbm.png"'.
+					 ' border="0" onClick="pg_reDirect(this.form)">'."\n".
+					 '</form>';
+			}
+		}
+	}
+}
+?>

+ 273 - 0
modules/billing/paypal.class.php

@@ -0,0 +1,273 @@
+<?php
+/*******************************************************************************
+ *                      PHP Paypal IPN Integration Class
+ *******************************************************************************
+ *      Author:     Micah Carrick
+ *      Email:      [email protected]
+ *      Website:    http://www.micahcarrick.com
+ *
+ *      File:       paypal.class.php
+ *      Version:    1.3.0
+ *      Copyright:  (c) 2005 - Micah Carrick 
+ *                  You are free to use, distribute, and modify this software 
+ *                  under the terms of the GNU General Public License.  See the
+ *                  included license.txt file.
+ *      
+ *******************************************************************************
+ *  VERION HISTORY:
+ *      v1.3.0 [10.10.2005] - Fixed it so that single quotes are handled the 
+ *                            right way rather than simple stripping them.  This
+ *                            was needed because the user could still put in
+ *                            quotes.
+ *  
+ *      v1.2.1 [06.05.2005] - Fixed typo from previous fix :)
+ *
+ *      v1.2.0 [05.31.2005] - Added the optional ability to remove all quotes
+ *                            from the paypal posts.  The IPN will come back
+ *                            invalid sometimes when quotes are used in certian
+ *                            fields.
+ *
+ *      v1.1.0 [05.15.2005] - Revised the form output in the submit_paypal_post
+ *                            method to allow non-javascript capable browsers
+ *                            to provide a means of manual form submission.
+ *
+ *      v1.0.0 [04.16.2005] - Initial Version
+ *
+ *******************************************************************************
+ *  DESCRIPTION:
+ *
+ *      NOTE: See www.micahcarrick.com for the most recent version of this class
+ *            along with any applicable sample files and other documentaion.
+ *
+ *      This file provides a neat and simple method to interface with paypal and
+ *      The paypal Instant Payment Notification (IPN) interface.  This file is
+ *      NOT intended to make the paypal integration "plug 'n' play". It still
+ *      requires the developer (that should be you) to understand the paypal
+ *      process and know the variables you want/need to pass to paypal to
+ *      achieve what you want.  
+ *
+ *      This class handles the submission of an order to paypal aswell as the
+ *      processing an Instant Payment Notification.
+ *  
+ *      This code is based on that of the php-toolkit from paypal.  I've taken
+ *      the basic principals and put it in to a class so that it is a little
+ *      easier--at least for me--to use.  The php-toolkit can be downloaded from
+ *      http://sourceforge.net/projects/paypal.
+ *      
+ *      To submit an order to paypal, have your order form POST to a file with:
+ *
+ *          $p = new paypal_class;
+ *          $p->add_field('business', '[email protected]');
+ *          $p->add_field('first_name', $_POST['first_name']);
+ *          ... (add all your fields in the same manor)
+ *          $p->submit_paypal_post();
+ *
+ *      To process an IPN, have your IPN processing file contain:
+ *
+ *          $p = new paypal_class;
+ *          if ($p->validate_ipn()) {
+ *          ... (IPN is verified.  Details are in the ipn_data() array)
+ *          }
+ *
+ *
+ *      In case you are new to paypal, here is some information to help you:
+ *
+ *      1. Download and read the Merchant User Manual and Integration Guide from
+ *         http://www.paypal.com/en_US/pdf/integration_guide.pdf.  This gives 
+ *         you all the information you need including the fields you can pass to
+ *         paypal (using add_field() with this class) aswell as all the fields
+ *         that are returned in an IPN post (stored in the ipn_data() array in
+ *         this class).  It also diagrams the entire transaction process.
+ *
+ *      2. Create a "sandbox" account for a buyer and a seller.  This is just
+ *         a test account(s) that allow you to test your site from both the 
+ *         seller and buyer perspective.  The instructions for this is available
+ *         at https://developer.paypal.com/ as well as a great forum where you
+ *         can ask all your paypal integration questions.  Make sure you follow
+ *         all the directions in setting up a sandbox test environment, including
+ *         the addition of fake bank accounts and credit cards.
+ * 
+ *******************************************************************************
+*/
+
+class paypal_class {
+    
+   var $last_error;                 // holds the last error encountered
+   
+   var $ipn_log;                    // bool: log IPN results to text file?
+   
+   var $ipn_log_file;               // filename of the IPN log
+   var $ipn_response;               // holds the IPN response from paypal   
+   var $ipn_data = array();         // array contains the POST values for IPN
+   
+   var $fields = array();           // array holds the fields to submit to paypal
+
+   
+   function paypal_class() {
+       
+      // initialization constructor.  Called when class is created.
+      
+      $this->paypal_url = 'https://www.paypal.com/cgi-bin/webscr';
+      
+      $this->last_error = '';
+      
+      $this->ipn_log_file = '.ipn_results.log';
+      $this->ipn_log = true; 
+      $this->ipn_response = '';
+      
+      // populate $fields array with a few default values.  See the paypal
+      // documentation for a list of fields and their data types. These defaul
+      // values can be overwritten by the calling script.
+
+      $this->add_field('rm','2');           // Return method = POST
+      $this->add_field('cmd','_xclick'); 
+      
+   }
+   
+   function add_field($field, $value) {
+      
+      // adds a key=>value pair to the fields array, which is what will be 
+      // sent to paypal as POST variables.  If the value is already in the 
+      // array, it will be overwritten.
+            
+      $this->fields["$field"] = $value;
+   }
+
+   function submit_paypal_post() {
+ 
+      // this function actually generates an entire HTML page consisting of
+      // a form with hidden elements which is submitted to paypal via the 
+      // BODY element's onLoad attribute.  We do this so that you can validate
+      // any POST vars from you custom form before submitting to paypal.  So 
+      // basically, you'll have your own form which is submitted to your script
+      // to validate the data, which in turn calls this function to create
+      // another hidden form and submit to paypal.
+ 
+      // The user will briefly see a message on the screen that reads:
+      // "Please wait, your order is being processed..." and then immediately
+      // is redirected to paypal.
+
+      echo "<head><title>Processing Payment...</title></head>\n";
+      echo "<body onLoad=\"document.forms['paypal_form'].submit();\">\n";
+      echo "<form method=\"post\" name=\"paypal_form\" ";
+      echo "action=\"".$this->paypal_url."\">\n";
+
+      foreach ($this->fields as $name => $value) {
+         echo "<input type=\"hidden\" name=\"$name\" value=\"$value\"/>\n";
+      }      
+      echo "</form>\n";
+      echo "</body>\n";    
+   }
+   
+   function validate_ipn() {
+
+      // parse the paypal URL
+      $url_parsed=parse_url($this->paypal_url);        
+
+      // generate the post string from the _POST vars aswell as load the
+      // _POST vars into an arry so we can play with them from the calling
+      // script.
+      $post_string = '';    
+      foreach ($_POST as $field=>$value) { 
+         $this->ipn_data["$field"] = $value;
+         $post_string .= $field.'='.urlencode(stripslashes($value)).'&'; 
+      }
+      $post_string.="cmd=_notify-validate"; // append ipn command
+
+      // open the connection to paypal
+      $fp = fsockopen($url_parsed[host],"80",$err_num,$err_str,30); 
+      if(!$fp) {
+          
+         // could not open the connection.  If loggin is on, the error message
+         // will be in the log.
+         $this->last_error = "fsockopen error no. $errnum: $errstr";
+         $this->log_ipn_results(false);       
+         return false;
+         
+      } else { 
+ 
+         // Post the data back to paypal
+         fputs($fp, "POST $url_parsed[path] HTTP/1.1\r\n"); 
+         fputs($fp, "Host: $url_parsed[host]\r\n"); 
+         fputs($fp, "Content-type: application/x-www-form-urlencoded\r\n"); 
+         fputs($fp, "Content-length: ".strlen($post_string)."\r\n"); 
+         fputs($fp, "Connection: close\r\n\r\n"); 
+         fputs($fp, $post_string . "\r\n\r\n"); 
+
+         // loop through the response from the server and append to variable
+         while(!feof($fp)) { 
+            $this->ipn_response .= fgets($fp, 1024); 
+         } 
+
+         fclose($fp); // close connection
+
+      }
+      
+      if (eregi("VERIFIED",$this->ipn_response)) {
+  
+         // Valid IPN transaction.
+         $this->log_ipn_results(true);
+         return true;       
+         
+      } else {
+  
+         // Invalid IPN transaction.  Check the log for details.
+         $this->last_error = 'IPN Validation Failed.';
+         $this->log_ipn_results(false);   
+         return false;
+         
+      }
+      
+   }
+   
+   function log_ipn_results($success) {
+       
+      if (!$this->ipn_log) return;  // is logging turned off?
+      
+      // Timestamp
+      $text = '['.date('m/d/Y g:i A').'] - '; 
+      
+      // Success or failure being logged?
+      if ($success) $text .= "SUCCESS!\n";
+      else $text .= 'FAIL: '.$this->last_error."\n";
+      
+      // Log the POST variables
+      $text .= "IPN POST Vars from Paypal:\n";
+      foreach ($this->ipn_data as $key=>$value) {
+         $text .= "$key=$value, ";
+      }
+ 
+      // Log the response from the paypal server
+      $text .= "\nIPN Response from Paypal Server:\n ".$this->ipn_response;
+      
+      // Write to log
+      $fp=fopen($this->ipn_log_file,'a');
+      fwrite($fp, $text . "\n\n"); 
+
+      fclose($fp);  // close file
+   }
+
+   function dump_fields() {
+ 
+      // Used for debugging, this function will output all the field/value pairs
+      // that are currently defined in the instance of the class using the
+      // add_field() function.
+      
+      echo "<h3>paypal_class->dump_fields() Output:</h3>";
+      echo "<table width=\"95%\" border=\"1\" cellpadding=\"2\" cellspacing=\"0\">
+            <tr>
+               <td bgcolor=\"black\"><b><font color=\"white\">Field Name</font></b></td>
+               <td bgcolor=\"black\"><b><font color=\"white\">Value</font></b></td>
+            </tr>"; 
+      
+      ksort($this->fields);
+      foreach ($this->fields as $key => $value) {
+         echo "<tr><td>$key</td><td>".urldecode($value)."&nbsp;</td></tr>";
+      }
+ 
+      echo "</table><br>"; 
+   }
+}         
+
+
+ 

+ 76 - 0
modules/billing/paypal.php

@@ -0,0 +1,76 @@
+<?php
+function exec_ogp_module()
+{
+	global $db,$view;
+	
+	$settings = $db->getSettings();
+	
+	$cart_id = $_GET['cart_id'];
+
+	if(!empty($cart_id))
+	{		
+		$orders = $db->resultQuery( "SELECT * FROM OGP_DB_PREFIXbilling_orders WHERE cart_id=".$cart_id );
+		if( !empty( $orders ) )
+		{
+			$cart['price'] = 0;
+			foreach($orders as $order) 
+			{
+				if( $order['qty'] > 1 )
+					$order['invoice_duration'] = $order['invoice_duration']."s";
+				
+				$cart['price'] += $order['price'];
+				
+				if( !isset( $cart['name'] ) )
+					$cart['name'] = $order['home_name']."(".$order['qty'].get_lang($order['invoice_duration']).",".$order['max_players'].get_lang('slots').")";
+				else
+					$cart['name'] .= ' + '.$order['home_name']."(".$order['qty'].get_lang($order['invoice_duration']).",".$order['max_players'].get_lang('slots').")";
+			}
+			
+			$total = $cart['price']+($settings['tax_amount']/100*$cart['price']);
+			if ($total === 0)
+			{
+				$db->query("UPDATE " . $table_prefix . "billing_carts
+												SET paid=1
+												WHERE cart_id=".$cart_id);
+				$view->refresh("home.php?m=billing&p=cart",0);
+			}
+			else
+			{
+				// Setup class
+				require_once('paypal.class.php');  // include the class file
+				
+				$receiver_email = $settings['paypal_email'];
+				
+				$p = new paypal_class;             // initiate an instance of the class
+				//$p->paypal_url = 'https://www.sandbox.paypal.com/cgi-bin/webscr';   // Paypal Sandbox URL for developers (https://developer.paypal.com)
+				$p->paypal_url = 'https://www.paypal.com/cgi-bin/webscr';     // PayPal url
+					
+				// setup a variable for this script (ie: 'http://www.micahcarrick.com/paypal.php')
+				$s = ( isset($_SERVER['HTTPS']) and  get_true_boolean($_SERVER['HTTPS']) ) ? "s" : "";
+				$port = isset($_SERVER['SERVER_PORT']) & $_SERVER['SERVER_PORT'] != "80" ? ":".$_SERVER['SERVER_PORT'] : NULL ;
+				$this_script = 'http'.$s.'://'.$_SERVER['SERVER_NAME'].$port.$_SERVER['SCRIPT_NAME'];
+				
+				function curPageName() 
+				{
+					return substr($_SERVER["SCRIPT_NAME"],strrpos($_SERVER["SCRIPT_NAME"],"/")+1);
+				}
+				
+				$current_folder_url = str_replace( curPageName(), "", $this_script);
+				
+				$p->add_field('business', $receiver_email);
+				$p->add_field('currency_code', $settings['currency']);
+				$p->add_field('return', $this_script.'?m=billing&p=paid');
+				$p->add_field('cancel_return', $this_script.'?m=billing&p=cart');
+				$p->add_field('notify_url', $current_folder_url.'modules/billing/paid-ipn.php');
+				$p->add_field('item_name', $cart['name']);
+				$p->add_field('item_number', $cart_id);
+				$p->add_field('amount', number_format( $total , 2 ));
+				echo "<h2>".get_lang_f('redirecting_to',get_lang('paypal'))."</h2>";
+				echo "<img style='border:4px dotted white;background:black' src='modules/addonsmanager/loading.gif' width='180' height='180' /img>";
+				$p->submit_paypal_post(); // submit the fields to paypal
+				//$p->dump_fields();      // for debugging, output a table of all the fields
+			}
+		}
+	}
+}
+?>

+ 153 - 0
modules/billing/robokassa-ipn.php

@@ -0,0 +1,153 @@
+<?php
+if(!isset($_REQUEST["OutSum"]) or !isset($_REQUEST["InvId"]) or !isset($_REQUEST["SignatureValue"]))
+	exit;
+
+ini_set('log_errors', true);
+ini_set('error_log', dirname(__FILE__).'/robokassa-ipn_errors.log');
+chdir("../../"); /* It just makes life easier */
+
+set_include_path(get_include_path() . PATH_SEPARATOR . "includes/");
+
+/* Includes */
+require_once("helpers.php");
+require_once("config.inc.php");
+require_once("functions.php");
+require_once("lib_remote.php");
+require_once("lang.php");
+require_once("modules/config_games/server_config_parser.php");
+ogpLang();
+
+/* Query DB */
+$db = createDatabaseConnection($db_type, $db_host, $db_user, $db_pass, $db_name, $table_prefix);
+
+$panel_settings	= $db->getSettings();
+
+// HTTP parameters:
+$out_summ = $_REQUEST["OutSum"];
+$inv_id = $_REQUEST["InvId"];
+$crc = $_REQUEST["SignatureValue"];
+
+$cart_price_info = $db->resultQuery( "SELECT price,tax_amount,currency 
+									 FROM OGP_DB_PREFIXbilling_carts AS cart
+									 JOIN
+									 OGP_DB_PREFIXbilling_orders AS orders  
+									 ON 
+									 orders.cart_id=cart.cart_id
+									 WHERE cart.cart_id=".$inv_id);
+									 
+$cart_price = number_format( $cart_price_info[0]['price'] + (($cart_price_info[0]['price']/100)*$cart_price_info[0]['tax_amount']) , 2 );
+$paid_price = $out_summ;
+if($cart_price > $paid_price)
+{	
+	// If for some reason someone achieves to hack the price then we will just change the order price.
+	// By a rule of Three:
+	// new price without tax = ( new price with tax * old price without tax ) / old price with tax
+	$new_price = ( ($cart_price - $paid_price) * $cart_price_info[0]['price'] ) / $cart_price;
+	// we don't want to loose money in this fraudulent transaction, 
+	// so if the rounded new price is less than the new price then we sum one cent to the rounded value.
+	if($new_price > number_format( $new_price, 2 ))
+		$new_price = number_format( $new_price, 2 ) + 0.01;
+	
+	$subject = "Error: Incorrect payment amount";
+	$body = 'CART ID	 = '.$inv_id."<br>".
+			'Price		 = '.$cart_price."<br>".
+			'<b style="color:red;">Amount paid</b>: '.$paid_price."<br>".
+			'<b style="color:red;">Amount owed</b>: '.$new_price."<br>";
+	mymail($panel_settings['panel_email_address'], $subject, $body, $panel_settings);
+	die("Error: Incorrect payment amount");
+}
+// your registration data
+$mrh_pass2 = $panel_settings['robokassa_securepass2'];   // merchant pass2 here
+
+// HTTP parameters: $out_summ, $inv_id, $crc
+$crc = strtoupper($crc);   // force uppercase
+
+// build own CRC
+$my_crc = strtoupper(md5("$out_summ:$inv_id:$mrh_pass2"));
+
+if (strtoupper($my_crc) != strtoupper($crc))
+{
+  echo "bad sign\n";
+  exit();
+}
+// perform some action (change order state to paid)
+else
+{
+	$body = 'Amount	paid		: '.$out_summ."<br>".
+			'CART ID			: '.$inv_id."<br>";
+
+	
+	// Here you can do whatever you want with the variables, for instance inserting or updating data into your Database
+
+	$user_homes = $db->resultQuery( "SELECT * 
+									 FROM OGP_DB_PREFIXbilling_carts AS cart
+									 JOIN
+									 OGP_DB_PREFIXbilling_orders AS orders  
+									 ON 
+									 orders.cart_id=cart.cart_id
+									 WHERE cart.cart_id=".$cart_id);
+
+	$query = "UPDATE " . $table_prefix . "billing_carts
+			  SET paid=1
+			  WHERE cart_id=".$cart_id;
+					  
+	foreach($user_homes as $user_home)
+	{
+		if($user_home['home_id'] != 0)
+		{
+			$home_id = $user_home['home_id'];
+			$home_info = $db->getGameHomeWithoutMods($home_id);
+			$server_info = $db->getRemoteServerById($home_info['remote_server_id']);
+			$remote = new OGPRemoteLibrary($server_info['agent_ip'], $server_info['agent_port'], $server_info['encryption_key'], $server_info['timeout']);
+			
+			if ( isset( $home_info['ftp_password'] ) AND !empty( $home_info['ftp_password'] ) )
+			{
+				$remote->ftp_mgr("useradd", $home_info['home_id'], $home_info['ftp_password'], $home_info['home_path']);
+				$db->changeFtpStatus('enabled',$home_info['home_id']);
+			}
+
+			if ($user_home['end_date'] == "0")
+			{
+				if ($user_home['invoice_duration'] == "hour")
+				{
+					$add_time = time() + ($user_home['qty'] * 60 * 60);
+					$end_date = date('YmdHi',$add_time);
+				}
+				elseif ($user_home['invoice_duration'] == "month")
+				{
+					$end_date = date('YmdHi', strtotime('+'.$user_home['qty'].' month'));
+				}
+				elseif ($user_home['invoice_duration'] == "year")
+				{
+					$end_date = date('YmdHi', strtotime('+'.$user_home['qty'].' year'));
+				}
+				//Set the expiration date to the new order
+				$db->query( "UPDATE " . $table_prefix . "billing_orders
+							 SET end_date='$end_date'
+							 WHERE order_id=".$user_home['order_id']);
+							 
+				// Set payment/creation date
+				$date = date('d/m/Y H:i');
+				$db->query( "UPDATE OGP_DB_PREFIXbilling_carts
+							 SET date='$date'
+							 WHERE cart_id=".$cart_id);
+			}
+			
+			$services = $db->resultQuery( "SELECT * 
+										   FROM OGP_DB_PREFIXbilling_services
+										   WHERE service_id=".$user_home['service_id']);
+			$service = $services[0];
+			$user_id = $user_home['user_id'];
+			$db->assignHomeTo("user", $user_id, $home_id, $service['access_rights']);
+			
+			$query = "UPDATE " . $table_prefix . "billing_carts
+					  SET paid=3
+					  WHERE cart_id=".$cart_id;
+		}
+	}
+	
+	$db->query($query);
+	$subject = "Payment done.";
+	mymail($panel_settings['panel_email_address'], $subject, $body, $panel_settings);
+}
+?>

+ 64 - 0
modules/billing/robokassa.php

@@ -0,0 +1,64 @@
+<?php
+function curPageName() 
+{
+	return substr($_SERVER["SCRIPT_NAME"],strrpos($_SERVER["SCRIPT_NAME"],"/")+1);
+}
+
+function exec_ogp_module()
+{
+	global $db,$view,$settings;
+	
+	$cart_id = $_GET['cart_id'];
+
+	if(!empty($cart_id))
+	{		
+		$orders = $db->resultQuery( "SELECT * FROM OGP_DB_PREFIXbilling_orders WHERE cart_id=".$cart_id );
+		if( !empty( $orders ) )
+		{
+			$cart['price'] = 0;
+			foreach($orders as $order) 
+			{
+				if( $order['qty'] > 1 )
+					$order['invoice_duration'] = $order['invoice_duration']."s";
+				
+				$cart['price'] += $order['price'];
+				
+				if( !isset( $cart['name'] ) )
+					$cart['name'] = $order['home_name']."(".$order['qty'].get_lang($order['invoice_duration']).",".$order['max_players'].get_lang('slots').")";
+				else
+					$cart['name'] .= ' + '.$order['home_name']."(".$order['qty'].get_lang($order['invoice_duration']).",".$order['max_players'].get_lang('slots').")";
+			}
+			
+			$total = $cart['price']+($settings['tax_amount']/100*$cart['price']);
+			if ($total === 0)
+			{
+				$db->query("UPDATE " . $table_prefix . "billing_carts
+												SET paid=1
+												WHERE cart_id=".$cart_id);
+				$view->refresh("home.php?m=billing&p=cart",0);
+			}
+			else
+			{
+				$mrh_login = $settings['robokassa_merchant_login'];      // your login here
+				$mrh_pass1 = $settings['robokassa_securepass1'];   // merchant pass1 here
+
+				// order properties
+				$inv_id    = $cart_id; // shop's invoice number 
+									   // (unique for shop's lifetime)
+				$inv_desc  = urlencode($cart['name']);   // invoice desc
+				$out_summ  = number_format( $total , 2 );  // invoice summ
+
+				// build CRC value
+				$crc  = md5("$mrh_login:$out_summ:$inv_id:$mrh_pass1");
+
+				// build URL
+				$url = "https://auth.robokassa.ru/Merchant/Index.aspx?MrchLogin=$mrh_login&".
+					   "OutSum=$out_summ&InvId=$inv_id&Desc=$inv_desc&SignatureValue=$crc";
+				echo "<h2>".get_lang_f('redirecting_to',get_lang('robokassa'))."</h2>";
+				echo "<img style='border:4px dotted white;background:black' src='modules/addonsmanager/loading.gif' width='180' height='180' /img>";
+				echo '<meta HTTP-EQUIV="REFRESH" content="0; url='.$url.'">';
+			}
+		}
+	}
+}
+?>

+ 283 - 0
modules/billing/services.php

@@ -0,0 +1,283 @@
+<?php
+function exec_ogp_module()
+{		
+	global $db;
+	
+	//Querying UPDATE a service FROM DB
+	if (isset($_POST['service']) AND isset($_POST['new_url']))
+	{
+		$new_price_hourly = $_POST['new_price_hourly'];
+		$new_price_monthly = $_POST['new_price_monthly'];
+		$new_price_year = $_POST['new_price_year'];
+		$new_url = $_POST['new_url'];
+		$service = $_POST['service'];
+
+		//Create INSERT query
+		$qry_change_url = "UPDATE OGP_DB_PREFIXbilling_services
+						   SET price_hourly ='".$new_price_hourly."',
+							   price_monthly ='".$new_price_monthly."', 
+							   price_year ='".$new_price_year."',
+							   img_url ='".$new_url."'
+							   WHERE service_id=".$service;
+		$db->query($qry_change_url);
+	}
+
+	//Querying INSERT new service INTO DB
+	if(isset($_POST['mod_cfg_id']) AND isset($_POST['remote_server_id']) AND isset($_POST['slot_max_qty']) AND isset($_POST['price_hourly']) AND isset($_POST['price_monthly']) AND isset($_POST['price_year']))
+	{
+		//Sanitize the POST values
+		$home_cfg_id = $_POST['home_cfg_id'];
+		$mod_cfg_id = $_POST['mod_cfg_id'];
+		$service_name = $_POST['service_name'];
+		$remote_server_id = $_POST['remote_server_id'];
+		$slot_max_qty = $_POST['slot_max_qty'];
+		$slot_min_qty = $_POST['slot_min_qty'];
+		$price_hourly = $_POST['price_hourly'];
+		$price_monthly = $_POST['price_monthly'];
+		$price_year = $_POST['price_year'];
+		$description = $_POST['description'];
+		$img_url = $_POST['img_url'];
+		$ftp = $_POST['ftp'];
+		$install_method = $_POST['install_method'];
+		$manual_url = $_POST['manual_url'];
+		$access_rights = "";
+		if(isset($_POST['allow_updates']))$access_rights .= $_POST['allow_updates'];
+		if(isset($_POST['allow_file_management']))$access_rights .= $_POST['allow_file_management'];
+		if(isset($_POST['allow_parameter_usage']))$access_rights .= $_POST['allow_parameter_usage'];
+		if(isset($_POST['allow_extra_params']))$access_rights .= $_POST['allow_extra_params'];
+		if(isset($_POST['allow_ftp_usage']))$access_rights .= $_POST['allow_ftp_usage'];
+		if(isset($_POST['allow_custom_fields']))$access_rights .= $_POST['allow_custom_fields'];
+		
+		$qry_add_service = "INSERT INTO OGP_DB_PREFIXbilling_services(service_id, home_cfg_id, mod_cfg_id, service_name, remote_server_id, slot_max_qty , slot_min_qty, price_hourly, price_monthly, price_year, description, img_url, ftp, install_method, manual_url, access_rights) VALUES(NULL, '".$home_cfg_id."', '".$mod_cfg_id."', '".$service_name."', '".$remote_server_id."', '".$slot_max_qty."', '".$slot_min_qty."', '".$price_hourly."', '".$price_monthly."', '".$price_year."', '".$description."', '".$img_url."', '".$ftp."', '".$install_method."', '".$manual_url."', '".$access_rights."')";
+		$db->query($qry_add_service);	
+	}
+	
+	//Querying REMOVE service FROM DB
+	if (isset($_POST['service_id']))
+	{
+		$db->query( "DELETE FROM OGP_DB_PREFIXbilling_services WHERE service_id=" . $_POST['service_id'] );
+	}
+	
+	?>
+	<h2><?php print_lang('add_service');?></h2>
+	<form method="POST" action="">
+	<table class="center">
+	<!-- Part2 - Select  MOD	 -->		
+	<?php 
+	if(isset($_POST['home_cfg_id']))
+	{
+	?>
+		<tr>
+		<td>
+		<select name="modcfgid">
+		<?php
+		$mod_qry = $db->resultQuery("SELECT DISTINCT mod_cfg_id, mod_name, game_name FROM OGP_DB_PREFIXconfig_mods NATURAL JOIN OGP_DB_PREFIXconfig_homes WHERE home_cfg_id=" . $_POST['home_cfg_id']);
+		foreach($mod_qry as $array_mods) 
+		{ 
+			if($array_mods['mod_name'] == "none")$array_mods['mod_name']=$array_mods['game_name'];
+		?>
+			<option value="<?php echo $array_mods['mod_cfg_id'];?>"><?php  echo $array_mods['mod_name'];?></option>
+		<?php 
+			
+		}
+		?>
+		</select>
+		</td>
+		<input type="hidden" name="homecfgid" value="<?php echo $_POST['home_cfg_id'];?>"/>
+		<tr>
+		<?php 
+	}
+	else if (isset($_POST['modcfgid']) AND isset($_POST['homecfgid']))
+	{
+		?>
+		</tr>
+		<tr>
+		<?php 
+		$result3 = $db->resultQuery("SELECT DISTINCT remote_server_id, remote_server_name, agent_ip, ogp_user FROM OGP_DB_PREFIXremote_servers"); 
+		?>
+		<td><?php print_lang('remote_server');?></td>
+		<td>
+		<select name="remote_server_id">
+		<?php  
+		foreach($result3 as $row3) 
+		{
+		?>
+		<option value="<?php echo $row3['remote_server_id']; ?>">(<?php echo $row3['remote_server_id']; ?>) - IP[<?php echo $row3['agent_ip']; ?>]</option>
+		<?php  
+		} 
+		?>
+		</select>
+		</td>
+		</tr>
+		<tr>
+		<?php
+		$mods = $db->resultQuery("SELECT DISTINCT mod_cfg_id, mod_name, game_name FROM OGP_DB_PREFIXconfig_mods NATURAL JOIN OGP_DB_PREFIXconfig_homes WHERE mod_cfg_id=" . $_POST['modcfgid']);
+		foreach($mods as $mod) 
+		{ 
+		?>
+			<td><?php print_lang('service_name');?></td>
+			<td><input name="service_name" type="text" size="61" value="<?php if($mod['mod_name']=="none")echo $mod['game_name']; else echo $mod['game_name']." - ".$mod['mod_name'];?>"/></td>
+			<input name="mod_cfg_id" type="hidden" value="<?php echo $mod['mod_cfg_id'];}?>"/>
+			<input name="home_cfg_id" type="hidden" value="<?php echo $_POST['homecfgid'];?>"/>
+		</tr>
+		<tr>
+			<td><?php print_lang('max_slot_qty');?></td>
+			<td><input name="slot_max_qty" type="text" size="8" value="32"/></td>
+		</tr>
+		<tr>
+			<td><?php print_lang('min_slot_qty');?></td>
+			<td><input name="slot_min_qty" type="text" size="8" value="10"/></td>
+		</tr>
+		<tr>
+			<td><?php print_lang('price_hourly');?></td>
+			<td><input name="price_hourly" type="text" size="8" value="0"/></td>
+		</tr>
+		<tr>
+			<td><?php print_lang('price_monthly');?></td>
+			<td><input name="price_monthly" type="text" size="8" value="0"/></td>
+		</tr>
+		<tr>
+			<td><?php print_lang('price_year');?></td>
+			<td><input name="price_year" type="text" size="8" value="0"/></td>
+		</tr>
+		<tr>
+			<td><?php print_lang('ftp_account');?></td>
+			<td>
+			<select name="ftp">
+			<option value="enabled"><?php print_lang('enabled');?></option>
+			<option value="disabled"><?php print_lang('disabled');?></option>
+			</td>
+		</tr>
+		<tr>
+			<td><?php print_lang('select_install_method');?></td>
+			<td>
+			<select name="install_method">
+			<option value="steam"><?php print_lang('steam');?></option>
+			<option value="rsync"><?php print_lang('rsync');?></option>
+			<option value="manual"><?php print_lang('manual_from_url');?></option>
+			</td>
+		</tr>
+		<tr>
+			<td><?php print_lang('url_for_manual_install');?></td>
+			<td><input name="manual_url" type="text" size="61"/></td>
+		</tr>
+		<tr>
+			<td><?php print_lang('description');?></td>
+			<td><textarea name='description' cols='45' rows='5'></textarea></td>
+		</tr>
+		<tr>
+			<td><?php print_lang('image_url');?></td>
+			<td><textarea name='img_url' cols='45' rows='1'>http://exapmle_domain/example_img.jpg</textarea></td>
+		</tr>
+		<tr>
+			<td><?php print_lang('access_rights');?></td>
+			<td>
+			<input name="allow_updates" type="checkbox" value="u" checked="checked"/><?php print_lang('allow_update');?><br>
+			<input name="allow_file_management" type="checkbox" value="f" checked="checked"/><?php print_lang('allow_file_management');?><br>
+			<input name="allow_parameter_usage" type="checkbox" value="p" checked="checked"/><?php print_lang('allow_parameter_usage');?><br>
+			<input name="allow_extra_params" type="checkbox" value="e" checked="checked"/><?php print_lang('allow_extra_parameters_usage');?><br>
+			<input name="allow_ftp_usage" type="checkbox" value="t" checked="checked"/><?php print_lang('allow_ftp_usage');?><br>
+			<input name="allow_custom_fields" type="checkbox" value="c" checked="checked"/><?php print_lang('allow_custom_fields');?>
+			</td>
+		</tr>
+
+		<tr>
+			<td></td>
+		<?php 
+	}	
+	else
+	{
+		?>
+		<!-- Part 1 - Select GAME  -->
+		<tr>
+			<td><select name='home_cfg_id'>
+			<?php
+			global $db;
+			$games = $db->getGameCfgs();
+			foreach($games as $game) 
+			{
+				echo "<option value='".$game['home_cfg_id']."'>".$game['game_name'];
+				if ( preg_match("/linux/", $game['game_key']) )
+				echo " (Linux) ";
+				if ( preg_match("/win/", $game['game_key']) )
+				echo " (Windows) ";
+				if ( preg_match("/64/", $game['game_key']) )
+				echo " (64bit) ";
+				echo "</option>";
+				
+			}
+			?>
+			</select></td>
+		</tr>
+		<?php 
+	}
+	?>
+		<td><input type="submit" value="<?php print_lang('add_service');?>"/></td>
+		</tr>
+		</form>
+
+	<!-- Show Services on DB -->
+	</table>
+	<br>
+	<?php  
+	$services = $db->resultQuery("SELECT * FROM OGP_DB_PREFIXbilling_services  NATURAL JOIN OGP_DB_PREFIXremote_servers");
+	if ($services > 0)
+	{
+		?>
+		<h2><?php print_lang('current_services');?></h2>
+		<table class="center" style='text-align:center;'>
+		<tr>
+			<th><?php print_lang('id');?></th>
+			<th><?php print_lang('service_name');?></th>
+			<th><?php print_lang('remote_server');?></th>
+			<th><?php print_lang('price_hourly');?></th>
+			<th><?php print_lang('price_monthly');?></th>
+			<th><?php print_lang('price_year');?></th>
+			<th><?php print_lang('service_image_url');?></th>
+		</tr>
+		<?php
+		foreach($services as $row)
+		{ 
+		?>
+		<tr class="tr<?php  $i = 0; echo($i++%2);?>">
+			<td><b class="success" ><?php echo $row['service_id'];?></b></td>
+			<td><?php echo $row['service_name'];?></td>
+			<td><?php echo $row['remote_server_name'];?></td>
+			<form method="post" action="">
+			<input name="service" type="hidden" value="<?php echo $row['service_id'];?>"/>
+			<td><input name="new_price_hourly" type="text" value="<?php echo $row['price_hourly'];?>" size="6"/></td>
+			<td><input name="new_price_monthly" type="text" value="<?php echo $row['price_monthly'];?>" size="6"/></td>
+			<td><input name="new_price_year" type="text" value="<?php echo $row['price_year'];?>" size="6"/></td>
+			<td><input name="new_url" type="text" value="<?php echo $row['img_url'];?>"/></td>
+			<td><input type="submit" value="<?php print_lang('edit');?>"/></td>
+			</form>
+		</tr>
+		<?php 
+		} 
+		?>
+		</tr>
+		</table>
+		<table class="center">
+			<tr>
+				<tr>
+					<td>
+						<form action="" method="post">
+							<select name="service_id">
+						<?php
+						foreach($services as $service) 
+						{ 
+						?>
+						<option value="<?php echo $service['service_id'];?>"><?php  echo $service['service_name'];?></option>				
+						<?php 
+						} 
+						?>
+						<input type="submit" value="<?php print_lang('remove_service');?>"/>
+					</form>
+				</td>
+			</tr>
+		</tr>
+	</table>
+	<?php
+	}
+}
+?>

+ 318 - 0
modules/billing/settings.php

@@ -0,0 +1,318 @@
+<?php
+function curPageName() 
+{
+	return substr($_SERVER["SCRIPT_NAME"],strrpos($_SERVER["SCRIPT_NAME"],"/")+1);
+}
+
+function exec_ogp_module()
+{		
+	require('includes/config.inc.php');
+	require_once('modules/settings/functions.php');
+    require_once('includes/form_table_class.php');
+    global $db,$view,$settings;
+	
+	$pp_currencies = Array ( 
+							'AUD'	=>	'Australian Dollar',
+							'BRL'	=>	'Brazilian Real',
+							'CAD'	=>	'Canadian Dollar',
+							'CZK'	=>	'Czech Koruna',
+							'DKK'	=>	'Danish Krone',
+							'EUR'	=>	'Euro',
+							'HKD'	=>	'Hong Kong Dollar',
+							'HUF'	=>	'Hungarian Forint',
+							'ILS'	=>	'Israeli New Sheqel',
+							'JPY'	=>	'Japanese Yen',
+							'MYR'	=>	'Malaysian Ringgit',
+							'MXN'	=>	'Mexican Peso',
+							'NOK'	=>	'Norwegian Krone',
+							'NZD'	=>	'New Zealand Dollar',
+							'PHP'	=>	'Philippine Peso',
+							'PLN'	=>	'Polish Zloty',
+							'GBP'	=>	'Pound Sterling',
+							'RUB'	=>	'Russian Ruble',
+							'SGD'	=>	'Singapore Dollar',
+							'SEK'	=>	'Swedish Krona',
+							'CHF'	=>	'Swiss Franc',
+							'TWD'	=>	'Taiwan New Dollar',
+							'THB'	=>	'Thai Baht',
+							'TRY'	=>	'Turkish Lira',
+							'USD'	=>	'U.S. Dollar'
+						);
+	
+	$sk_currencies = Array ( 
+							'AUD'	=>	'Australian Dollar',
+							'BGN'	=>	'Bulgarian Leva',
+							'CAD'	=>	'Canadian Dollar',
+							'HRK'	=>	'Croatian Kuna',
+							'CZK'	=>	'Czech Koruna',
+							'DKK'	=>	'Danish Krone',
+							'EEK'	=>	'Estonian Kroon',
+							'EUR'	=>	'Euro',
+							'HKD'	=>	'Hong Kong Dollar',
+							'HUF'	=>	'Hungarian Forint',
+							'ISK'	=>	'Iceland Krona',
+							'INR'	=>	'Indian Rupee',
+							'ILS'	=>	'Israeli New Sheqel',
+							'JPY'	=>	'Japanese Yen',
+							'JOD'	=>	'Jordanian Dinar',
+							'LVL'	=>	'Latvian Lat',
+							'LTL'	=>	'Lithuanian Litas',
+							'MYR'	=>	'Malaysian Ringgit',
+							'MAD'	=>	'Moroccan Dirham',
+							'NOK'	=>	'Norwegian Krone',
+							'NZD'	=>	'New Zealand Dollar',
+							'OMR'	=>	'Omani Rial',
+							'PLN'	=>	'Polish Zloty',
+							'GBP'	=>	'Pound Sterling',
+							'QAR'	=>	'Qatari Rial',
+							'RON'	=>	'Romanian Leu New',
+							'SAR'	=>	'Saudi Riyal',
+							'RSD'	=>	'Serbian dinar',
+							'SGD'	=>	'Singapore Dollar',
+							'SKK'	=>	'Slovakian Koruna',
+							'ZAR'	=>	'South-African Rand',
+							'KRW'	=>	'South-Korean Won',
+							'SEK'	=>	'Swedish Krona',
+							'CHF'	=>	'Swiss Franc',
+							'TWD'	=>	'Taiwan New Dollar',
+							'THB'	=>	'Thai Baht',
+							'TND'	=>	'Tunisian Dinar',
+							'TRY'	=>	'Turkish Lira',
+							'AED'	=>	'Utd. Arab Emir. Dirham',
+							'USD'	=>	'U.S. Dollar'
+						);
+
+	$pg_currencies = Array ( 
+							"AED"	=>	"United Arab Emirates Dirham",
+							"ALL"	=>	"Albania Lek",
+							"ARS"	=>	"Argentina Peso",
+							"AUD"	=>	"Australia Dollar",
+							"AZN"	=>	"Azerbaijan New Manat",
+							"BAM"	=>	"Bosnia and Herzegovina Convertible Marka",
+							"BGN"	=>	"Bulgaria Lev",
+							"BOB"	=>	"Bolivia Boliviano",
+							"BRL"	=>	"Brazil Real",
+							"BYR"	=>	"Belarus Ruble",
+							"CAD"	=>	"Canada Dollar",
+							"CHF"	=>	"Switzerland Franc",
+							"CLP"	=>	"Chile Peso",
+							"COP"	=>	"Colombia Peso",
+							"CRC"	=>	"Costa Rica Colon",
+							"CZK"	=>	"Czech Republic Koruna",
+							"DKK"	=>	"Denmark Krone",
+							"DOP"	=>	"Dominican Republic Peso",
+							"EGP"	=>	"Egypt Pound",
+							"EUR"	=>	"Euro",
+							"GBP"	=>	"United Kingdom Pound",
+							"GTQ"	=>	"Guatemala Quetzal",
+							"HKD"	=>	"Hong Kong Dollar",
+							"HRK"	=>	"Croatia Kuna",
+							"HUF"	=>	"Hungary Forint",
+							"IDR"	=>	"Indonesia Rupiah",
+							"ILS"	=>	"Israel Shekel",
+							"IQD"	=>	"Iraq Dinar",
+							"JOD"	=>	"Jordan Dinar",
+							"KES"	=>	"Kenya Shilling",
+							"KGS"	=>	"Kyrgyzstan Som",
+							"KWD"	=>	"Kuwait Dinar",
+							"LTL"	=>	"Lithuania Litas",
+							"LVL"	=>	"Latvia Lat",
+							"MAD"	=>	"Morocco Dirham",
+							"MKD"	=>	"Macedonia Denar",
+							"MXN"	=>	"Mexico Peso",
+							"MYR"	=>	"Malaysia Ringgit",
+							"NGN"	=>	"Nigeria Naira",
+							"NIO"	=>	"Nicaragua Cordoba",
+							"NOK"	=>	"Norway Krone",
+							"PEN"	=>	"Peru Nuevo Sol",
+							"PLN"	=>	"Poland Zloty",
+							"QAR"	=>	"Qatar Riyal",
+							"RSD"	=>	"Serbia Dinar",
+							"RUB"	=>	"Russia Ruble",
+							"SAR"	=>	"Saudi Arabia Riyal",
+							"SEK"	=>	"Sweden Krona",
+							"THB"	=>	"Thailand Baht",
+							"TRY"	=>	"Turkey Lira",
+							"TWD"	=>	"Taiwan New Dollar",
+							"TZS"	=>	"Tanzania Shilling",
+							"UAH"	=>	"Ukraine Hryvna",
+							"USD"	=>	"U.S. Dollar",
+							"UYU"	=>	"Uruguay Peso",
+							"VEF"	=>	"Venezuela Bolivar",
+							"VND"	=>	"Viet Nam Dong",
+							"ZAR"	=>	"South Africa Rand"
+						);
+
+	$rk_currencies = Array (
+							"RUB"	=>	"Russia Ruble"
+						);				
+	
+	$settings['paypal'] = isset($settings['paypal']) ? $settings['paypal'] : "1";
+	$settings['paygol'] = isset($settings['paygol']) ? $settings['paygol'] : "1";
+	$settings['skrill'] = isset($settings['skrill']) ? $settings['skrill'] : "1";
+	$settings['robokassa'] = isset($settings['robokassa']) ? $settings['robokassa'] : "1";
+	$settings['currency'] = isset($settings['currency']) ? $settings['currency'] : "EUR";
+	$settings['hourly'] = isset($settings['hourly']) ? $settings['hourly'] : 1;
+	$settings['monthly'] = isset($settings['monthly']) ? $settings['monthly'] : 1;
+	$settings['annually'] = isset($settings['annually']) ? $settings['annually'] : 1;
+	$settings['tax_amount'] = isset($settings['tax_amount']) ? $settings['tax_amount'] : 18;
+	$settings['paypal_email'] = isset($settings['paypal_email']) ? $settings['paypal_email'] : "Business@E-mail";
+	$settings['skrill_merchant_id'] = isset($settings['skrill_merchant_id']) ? $settings['skrill_merchant_id'] : "";
+	$settings['skrill_email'] = isset($settings['skrill_email']) ? $settings['skrill_email'] : "Business@E-mail";
+	$settings['skrill_secret_word'] = (isset($settings['skrill_secret_word']) and $settings['skrill_secret_word'] != "") ? get_lang('hash_stored_correctly') : "";
+	$settings['paygol_service_id'] = isset($settings['paygol_service_id']) ? $settings['paygol_service_id'] : "0";
+	$settings['robokassa_merchant_login'] = isset($settings['robokassa_merchant_login']) ? $settings['robokassa_merchant_login'] : "";
+	$settings['robokassa_securepass1'] = isset($settings['robokassa_securepass1']) ? $settings['robokassa_securepass1'] : "";
+	$settings['robokassa_securepass2'] = isset($settings['robokassa_securepass2']) ? $settings['robokassa_securepass2'] : "";
+	function checked($value){
+		global $settings;
+		if( $settings[$value] == 1 )
+			return 'checked="checked"';
+	}
+	
+	$currencies = array();
+	
+	if($settings['paypal'] == "1")
+		$currencies = array_merge($currencies,$pp_currencies);
+	if($settings['paygol'] == "1")
+		$currencies = array_merge($currencies,$pg_currencies);
+	if($settings['skrill'] == "1")
+		$currencies = array_merge($currencies,$sk_currencies);
+	if($settings['robokassa'] == "1")
+		$currencies = array_merge($currencies,$rk_currencies);
+		
+	asort($currencies);
+
+	if(isset($_POST['currency']))
+	{
+			$currency = $_REQUEST['currency'];
+			$ERROR = FALSE;
+			$_SESSION['err_str'] = "";
+			if($_REQUEST['paypal'] == '1')
+			{
+				if(!array_key_exists($currency,$pp_currencies))
+				{
+					$_SESSION['err_str'] .= get_lang_f('currency_not_available_at',$currencies[$currency],get_lang('paypal'))."<br>";
+					$ERROR = TRUE;
+				}
+			}
+			if($_REQUEST['paygol'] == '1')
+			{
+				if(!array_key_exists($currency,$pg_currencies))
+				{
+					$_SESSION['err_str'] .= get_lang_f('currency_not_available_at',$currencies[$currency],get_lang('paygol'))."<br>";
+					$ERROR = TRUE;
+				}
+			}
+			if($_REQUEST['skrill'] == '1')
+			{
+				if(!array_key_exists($currency,$sk_currencies))
+				{
+					$_SESSION['err_str'] .= get_lang_f('currency_not_available_at',$currencies[$currency],get_lang('skrill'));
+					$ERROR = TRUE;
+				}
+			}
+			if($_REQUEST['robokassa'] == '1')
+			{
+				if(!array_key_exists($currency,$rk_currencies))
+				{
+					$_SESSION['err_str'] .= get_lang_f('currency_not_available_at',$currencies[$currency],get_lang('robokassa'));
+					$currency = "RUB";
+				}
+			}
+		if($ERROR)
+			$currency = "EUR";
+	}
+	
+    if ( isset($_REQUEST['update_settings']) )
+    {
+        $settings = array(
+			"paypal" => $_REQUEST['paypal'],
+			"paygol" => $_REQUEST['paygol'],
+			"skrill" => $_REQUEST['skrill'],
+			"robokassa" => $_REQUEST['robokassa'],
+			"currency" => $currency,
+			"hourly" => @$_REQUEST['hourly'],
+			"monthly" => @$_REQUEST['monthly'],
+			"annually" => @$_REQUEST['annually'],
+			"tax_amount" => $_REQUEST['tax_amount'],
+			"paypal_email" => $_REQUEST['paypal_email'],
+			"skrill_merchant_id" => $_REQUEST['skrill_merchant_id'],
+			"skrill_email" => $_REQUEST['skrill_email'],
+			"paygol_service_id" => $_REQUEST['paygol_service_id'],
+			"robokassa_merchant_login" => $_REQUEST['robokassa_merchant_login'],
+			"robokassa_securepass1" => $_REQUEST['robokassa_securepass1'],
+			"robokassa_securepass2" => $_REQUEST['robokassa_securepass2']);
+			
+		if($_REQUEST['skrill_secret_word'] != get_lang('hash_stored_correctly'))
+		{
+			if($_REQUEST['skrill_secret_word'] != "")
+				$settings['skrill_secret_word'] = md5($_REQUEST['skrill_secret_word']);
+			else
+				$settings['skrill_secret_word'] = "";
+		}
+        $db->setSettings($settings);
+        print_success(get_lang('settings_updated'));
+        $view->refresh("?m=billing&p=shop_settings");
+        return;
+    }
+	
+	$s = ( isset($_SERVER['HTTPS']) and  get_true_boolean($_SERVER['HTTPS']) ) ? "s" : "";
+	$p = isset($_SERVER['SERVER_PORT']) & $_SERVER['SERVER_PORT'] != "80" ? ":".$_SERVER['SERVER_PORT'] : NULL ;
+	$this_script = 'http'.$s.'://'.$_SERVER['SERVER_NAME'].$p.$_SERVER['SCRIPT_NAME'];
+	$current_folder_url = str_replace( curPageName(), "", $this_script);
+	$robokassa_Result_URL = $current_folder_url.'modules/billing/robokassa-ipn.php';
+	
+    echo "<style>
+		  h4{
+			width:250px;
+			height:25px;
+			background:#f5f5f5;
+			border-top-style:solid;
+			border-top-color:#afafaf;
+			border-top-width:1px;
+			border-style: solid;
+			border-color: #CFCFCF;
+			border-width: 1px;
+			padding-top:8px;
+			text-align: center;
+			font-family:'Trebuchet MS';
+			}
+			</style>
+			";
+    echo "<h2>".get_lang('shop_settings')."</h2>";
+	print_failure($_SESSION['err_str']);
+    $ft = new FormTable();
+    $ft->start_form("?m=billing&p=shop_settings");
+    $ft->start_table();
+	echo "<tr><td colspan='2' ><h4>".get_lang('payment_gateway')."</h4></td></tr>";
+	$ft->add_custom_field('paypal','<input type="checkbox" name="paypal" value="1" '.checked('paypal').'/>');
+	$ft->add_custom_field('paygol','<input type="checkbox" name="paygol" value="1" '.checked('paygol').'/>');
+	$ft->add_custom_field('skrill','<input type="checkbox" name="skrill" value="1" '.checked('skrill').'/>');
+	$ft->add_custom_field('robokassa','<input type="checkbox" name="robokassa" value="1" '.checked('robokassa').'/>');
+	$ft->add_custom_field('currency',
+        create_drop_box_from_array($currencies,"currency",$settings['currency'],false));
+	echo "<tr><td colspan='2' ><h4>".get_lang('available_invoice_types')."</h4></td></tr>";
+	$ft->add_custom_field('hourly','<input type="checkbox" name="hourly" value="1" '.checked('hourly').'/>');
+	$ft->add_custom_field('monthly','<input type="checkbox" name="monthly" value="1" '.checked('monthly').'/>');
+	$ft->add_custom_field('annually','<input type="checkbox" name="annually" value="1" '.checked('annually').'/>');
+	echo "<tr><td colspan='2' ><h4>".get_lang('tax_amount')."</h4></td></tr>";
+	$ft->add_field('string','tax_amount',$settings['tax_amount'],2);
+	echo "<tr><td colspan='2' ><h4>".get_lang('paypal_email')."</h4></td></tr>";
+	$ft->add_field('string','paypal_email',$settings['paypal_email'],35);
+	echo "<tr><td colspan='2' ><h4>".get_lang('skrill_merchant_info')."</h4></td></tr>";
+	$ft->add_field('string','skrill_merchant_id',$settings['skrill_merchant_id'],35);
+	$ft->add_field('string','skrill_email',$settings['skrill_email'],35);
+	$ft->add_field('string','skrill_secret_word',$settings['skrill_secret_word'],35);
+	echo "<tr><td colspan='2' ><h4>".get_lang('paygol_service')."</h4></td></tr>";
+	$ft->add_field('string','paygol_service_id',$settings['paygol_service_id'],35);
+	echo "<tr><td colspan='2' ><h4>".get_lang('robokassa_service')."</h4></td></tr>";
+	$ft->add_field('string','robokassa_merchant_login',$settings['robokassa_merchant_login'],35);
+	$ft->add_field('password','robokassa_securepass1',$settings['robokassa_securepass1'],35);
+	$ft->add_field('password','robokassa_securepass2',$settings['robokassa_securepass2'],35);
+	echo "<tr><td align='right'>Result_URL:</td><td align='left'><b>".$robokassa_Result_URL."</b></td></tr>";
+	$ft->end_table();
+	$ft->add_button("submit","update_settings",get_lang('update_settings'));
+	$ft->end_form();
+}
+?>

+ 251 - 0
modules/billing/shop.php

@@ -0,0 +1,251 @@
+<?php
+/*
+ *
+ * OGP - Open Game Panel
+ * Copyright (C) 2008 - 2010 The OGP Development Team
+ *
+ * http://www.opengamepanel.org/
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or 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, write to the Free Software
+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
+ *
+ */
+function exec_ogp_module()
+{	
+	global $db;
+
+	$settings = $db->getSettings();
+		
+	if (isset($_POST['save']) AND !empty($_POST['description']))
+	{
+		$new_description = str_replace("\\r\\n", "<br>", $_POST['description']);
+		$service = $_POST['service_id'];
+		
+		$change_description = "UPDATE OGP_DB_PREFIXbilling_services
+						       SET description ='".$new_description."'
+						       WHERE service_id=".$service;
+		$save = $db->query($change_description);
+	}
+	?>
+	<table class="center">
+	<tr>
+	<td>
+	<a href="?m=billing&p=cart"><img SRC="images/cart.png" BORDER="0" WIDTH=22 HEIGHT=20/><?php print_lang('your_cart');?></a>
+	</td>
+	</tr>
+	<tr>
+	<td>
+	<?php 
+	echo date('d-m-Y');
+	?>
+	</td>
+	</tr>
+	<tr>
+	<td>
+	<?php 
+	echo date('H:i');
+	?>
+	</td>
+	</tr>
+	</table>
+	<?php 
+	// Shop Form
+	if(isset($_REQUEST['service_id'])) $where_service_id = " WHERE service_id=".$_REQUEST['service_id']; else $where_service_id = "";
+	$qry_services = "SELECT * FROM OGP_DB_PREFIXbilling_services".$where_service_id;
+	$services = $db->resultQuery($qry_services);
+					
+	foreach ($services as $key => $row) {
+		$service_id[$key] = $row['service_id'];
+		$home_cfg_id[$key] = $row['home_cfg_id'];
+		$mod_cfg_id[$key] = $row['mod_cfg_id'];
+		$service_name[$key] = $row['service_name'];
+		$remote_server_id[$key] = $row['remote_server_id'];
+		$slot_max_qty[$key] = $row['slot_max_qty'];
+		$slot_min_qty[$key] = $row['slot_min_qty'];
+		$price_hourly[$key] = $row['price_hourly'];
+		$price_monthly[$key] = $row['price_monthly'];
+		$price_year[$key] = $row['price_year'];
+		$description[$key] = $row['description'];
+		$img_url[$key] = $row['img_url'];
+		$ftp[$key] = $row['ftp'];
+		$install_method[$key] = $row['install_method'];
+		$manual_url[$key] = $row['manual_url'];
+		$access_rights[$key] = $row['access_rights'];
+	}
+	array_multisort($service_name,
+					$service_id,
+					$home_cfg_id,
+					$mod_cfg_id,
+					$remote_server_id,
+					$slot_max_qty,
+					$slot_min_qty,
+					$price_hourly,
+					$price_monthly,
+					$price_year,
+					$description,
+					$img_url,
+					$ftp,
+					$install_method,
+					$manual_url,
+					$access_rights, SORT_DESC, $services);
+	?>
+	<div style="border-left:10px solid transparent;">
+	<?php		
+	foreach( $services as $row )
+	{
+		if(!isset($_REQUEST['service_id']))
+		{
+			?>
+			<div style="float:left; border: 4px solid transparent;border-bottom: 25px solid transparent;">
+			<form action="" method="POST">
+				<input name="service_id" type="hidden" value="<?php echo $row['service_id'];?>" />
+				<input type="image" src="<?php echo $row['img_url'] ;?>" width=280 height=132 border=0 alt="Bad Image" onsubmit="submit-form();" value="More Info" />
+				<center><b><?php echo $row['service_name'];?></b></center>
+				<center><em style="text-align:center;background-color:orange;color:blue;"><?php echo get_lang('starting_on') . " <b>" .
+				floatval(round(($row['price_monthly']*$row['slot_min_qty']),2 )) . "</b>&nbsp;" . $settings['currency'] . "/" . get_lang('month') . 
+				" (" . $row['slot_min_qty'] . " " . get_lang('slots') . ").";?></em></center>
+			</form>
+			</div>
+			<?php 
+		}		else
+		{	
+			?>
+			<div style="float:left; border: 4px solid transparent;border-bottom: 25px solid transparent;">
+			<img src="<?php echo $row['img_url'] ;?>" width=280 height=132 border=0 alt="Bad Image">
+			<center><b><?php echo $row['service_name']."</b></center>";
+			$isAdmin = $db->isAdmin($_SESSION['user_id'] );
+			if($isAdmin)
+			{
+				if(!isset($_POST['edit']))
+				{
+					echo "<p style='color:gray;width:280px;' >$row[description]<p>";
+					echo "<form action='' method='post'>".
+						 "<input type='hidden' name='service_id' value='$row[service_id]' />".
+						 "<input type='submit' name='edit' value='" . get_lang('edit') . "' />".
+						 "</form>";
+				}
+				else
+				{
+					echo "<form action='' method='post'>".
+						 "<textarea style='resize:none;width:280px;height:132px;' name='description' >".str_replace("<br>", "\r\n", $row['description'])."</textarea><br>".
+						 "<input type='hidden' name='service_id' value='$row[service_id]' />".
+						 "<input type='submit' name='save' value='" . get_lang('save') . "' />".
+						 "</form>";
+				}
+			}
+			else
+				echo "<p style='color:gray;width:280px;' >$row[description]<p>";
+			?>
+			</div>
+			<table style="width:420px;float:left;">
+			<form method="post" action="?m=billing&p=add_to_cart<?php if(isset($_POST['service_id'])) echo "&service_id=".$_POST['service_id'];?>">
+			<tr>
+			<td align="right"><?php print_lang('service_name');?> ::</td>
+			<td align="left">
+			<input type="text" name="home_name" size="40" value="<?php echo $row['service_name'];?>">
+			</td>
+			<tr>
+			<td align="right"><?php print_lang('rcon_pass');?> ::</td>
+			<td align="left">
+			<input type="text" name="remote_control_password" size="15" value="<?php echo genRandomString(10);?>">
+			</td>
+			</tr>
+			<?php
+			if($row['ftp'] == "enabled")
+			{
+			?>
+				<tr>
+				<td align="right"><?php print_lang('ftp_pass');?> ::</td>
+				<td align="left">
+				<input type="text" name="ftp_password" size="15" value="<?php echo genRandomString(10);?>">
+				</td>
+				</tr>
+			<?php
+			}
+			?>
+			<tr>
+			  <td align="right"><?php print_lang('available_ips');?> ::</td>
+			  <td align="left">
+			  <select name='ip_id'>
+			<?php
+			$qry_ip = "SELECT ip_id,ip FROM OGP_DB_PREFIXremote_server_ips WHERE remote_server_id=".$row['remote_server_id'];
+			$ips = $db->resultQuery($qry_ip);
+
+			foreach($ips as $ip)
+			{
+				printf("<option value='%s'>%s</option>", $ip['ip_id'], $ip['ip']);
+			}?>
+			  </select>
+			  </td>
+			</tr>
+			<tr> 
+			  <td align="right"><?php print_lang('max_players');?> ::</td>
+			  <td  align="left">
+			  <select name="max_players">
+			  <?php 
+			  $players=$row['slot_min_qty'];
+			  while($players<=$row['slot_max_qty'])
+			  {
+			  echo "<option value='$players'>$players</option>";
+			  $players++;
+			  }
+			  ?>
+			  </select>
+			  </td>
+			</tr>
+			<tr> 
+			  <td align="right"><?php print_lang('invoice_duration');?> ::</td>
+			  <td align="left">
+			  <select name="qty">
+			  <?php 
+			  $qty=1;
+			  while($qty<=12)
+			  {
+			  echo "<option value='$qty'>$qty</option>";
+			  $qty++;
+			  }
+			  ?>
+			  </select>
+			  <select name="invoice_duration">
+			  <?php
+			  if( $settings['hourly'] == 1) echo '<option value="hour">'.get_lang('hours').'</option>';
+			  if( $settings['monthly'] == 1) echo '<option value="month">'.get_lang('months').'</option>';
+			  if( $settings['annually'] == 1) echo '<option value="year">'.get_lang('years').'</option>';
+			  ?>
+			  </select>
+			  </td>
+			</tr>
+			<tr>
+			  <td align="left" colspan="2">
+			  	<input name="service_id" type="hidden" value="<?php echo $row['service_id'];?>"/>
+				<input type="submit" name="add_to_cart" value="<?php print_lang('add_to_cart');?>"/>
+			  </form>
+			  </td>
+			</tr>
+			<tr>
+			<td align="left" colspan="2">
+			<form action ="?m=billing&p=shop" method="POST">
+			  <button><< <?php print_lang('back_to_list');?></button>
+			</form>
+			</td>
+			</tr>
+			</table>
+			<?php
+		}
+	}
+	?>
+	</div>
+	<?php  
+}
+?>

+ 87 - 0
modules/billing/shop_guest.php

@@ -0,0 +1,87 @@
+<?php
+/*
+ *
+ * OGP - Open Game Panel
+ * Copyright (C) 2008 - 2010 The OGP Development Team
+ *
+ * http://www.opengamepanel.org/
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or 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, write to the Free Software
+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
+ *
+ */
+function exec_ogp_module()
+{
+	require('includes/config.inc.php');	
+	global $db;
+	$settings = $db->getSettings();
+	?>
+	<p style="text-align:center;background-color:cyan;color:blue;">&nbsp;<?php print_lang("you_need_to");?> <a href="?m=register&p=form"><?php print_lang("register");?></a> <?php print_lang("and");?> <a href="index.php"><?php print_lang("log_in");?></a>&nbsp;<?php print_lang("to_purchase_a_service");?>.</p>
+	<h2><?php print_lang("available_services");?></h2>
+	<div style="border: 5px solid transparent;">
+	<?php  
+	$qry_services = "SELECT * FROM OGP_DB_PREFIXbilling_services";
+	$services = $db->resultQuery($qry_services);
+	foreach ($services as $key => $row) {
+		$service_id[$key] = $row['service_id'];
+		$home_cfg_id[$key] = $row['home_cfg_id'];
+		$mod_cfg_id[$key] = $row['mod_cfg_id'];
+		$service_name[$key] = $row['service_name'];
+		$remote_server_id[$key] = $row['remote_server_id'];
+		$slot_max_qty[$key] = $row['slot_max_qty'];
+		$slot_min_qty[$key] = $row['slot_min_qty'];
+		$price_hourly[$key] = $row['price_hourly'];
+		$price_monthly[$key] = $row['price_monthly'];
+		$price_year[$key] = $row['price_year'];
+		$description[$key] = $row['description'];
+		$img_url[$key] = $row['img_url'];
+		$ftp[$key] = $row['ftp'];
+		$install_method[$key] = $row['install_method'];
+		$manual_url[$key] = $row['manual_url'];
+		$access_rights[$key] = $row['access_rights'];
+	}
+	//Sort by service name, the 1st position in this array multisort, service_name, defines the row that sorts the array, if there are two equal service names then the next row, service_id, will sort these rows.
+	array_multisort($service_name,
+					$service_id,
+					$home_cfg_id,
+					$mod_cfg_id,
+					$remote_server_id,
+					$slot_max_qty,
+					$slot_min_qty,
+					$price_hourly,
+					$price_monthly,
+					$price_year,
+					$description,
+					$img_url,
+					$ftp,
+					$install_method,
+					$manual_url,
+					$access_rights, SORT_DESC, $services);
+	
+	foreach($services as $row)
+	{ 
+	?>
+	<div style="float:left; border: 4px solid transparent;border-bottom: 25px solid transparent;">
+	<img src="<?php echo $row['img_url'] ;?>" width=280 height=132 border=0 alt="Bad Image">
+	<br>
+	<center><b><?php echo $row['service_name'];?></b></center>
+	<center><em style="text-align:center;background-color:orange;color:blue;"><?php echo get_lang('starting_on') . " <b>" . floatval(round(($row['price_monthly']*$row['slot_min_qty']),2 )) . "</b>&nbsp;" . $settings['currency'] . "/" . get_lang('month') . " (" . $row['slot_min_qty'] . " " . get_lang('slots') . ").";?></em></center>
+	</div>
+	<?php 
+	}
+	?>
+	</div>
+	<?php
+}
+?>

+ 151 - 0
modules/billing/skrill-ipn.php

@@ -0,0 +1,151 @@
+<?php
+if(!isset($_POST['cart_id']) or !is_numeric($_POST['cart_id']))
+	exit();
+ini_set('log_errors', true);
+ini_set('error_log', dirname(__FILE__).'/skrill-ipn_errors.log');
+chdir("../../"); /* It just makes life easier */
+
+set_include_path(get_include_path() . PATH_SEPARATOR . "includes/");
+
+/* Includes */
+require_once("helpers.php");
+require_once("config.inc.php");
+require_once("functions.php");
+require_once("lib_remote.php");
+require_once("lang.php");
+require_once("modules/config_games/server_config_parser.php");
+ogpLang();
+
+/* Query DB */
+$db = createDatabaseConnection($db_type, $db_host, $db_user, $db_pass, $db_name, $table_prefix);
+
+$panel_settings	= $db->getSettings();
+
+$s = ( isset($_SERVER['HTTPS']) and  get_true_boolean($_SERVER['HTTPS']) ) ? "s" : "";
+$p = isset($_SERVER['SERVER_PORT']) & $_SERVER['SERVER_PORT'] != "80" ? ":".$_SERVER['SERVER_PORT'] : NULL ;
+$this_script = 'http'.$s.'://'.$_SERVER['SERVER_NAME'].$p.$_SERVER['SCRIPT_NAME'];
+				
+function curPageName() 
+{
+	return substr($_SERVER["SCRIPT_NAME"],strrpos($_SERVER["SCRIPT_NAME"],"/")+1);
+}
+
+$current_folder_url = str_replace( curPageName(), "", $this_script);
+
+if( empty( $panel_settings['panel_name'] ) )
+	$panel_name = "Open Game Panel";
+else
+	$panel_name = $panel_settings['panel_name'];
+
+$cart_id = $_POST['cart_id'];
+
+$cart_price_info = $db->resultQuery( "SELECT price,tax_amount,currency 
+									 FROM OGP_DB_PREFIXbilling_carts AS cart
+									 JOIN
+									 OGP_DB_PREFIXbilling_orders AS orders  
+									 ON 
+									 orders.cart_id=cart.cart_id
+									 WHERE cart.cart_id=".$cart_id);
+
+if(!$cart_price_info or empty($cart_price_info))	
+	exit();
+
+$cart_price = number_format( $cart_price_info[0]['price'] + (($cart_price_info[0]['price']/100)*$cart_price_info[0]['tax_amount']) , 2 );
+$cart_currency = $cart_price_info[0]['currency'];
+// Validate the Moneybookers signature
+$concatFields = $panel_settings['skrill_merchant_id'].
+				$_POST['transaction_id'].
+				strtoupper($panel_settings['skrill_secret_word']).
+				$cart_price.
+				$cart_currency.
+				$_POST['status'];
+
+// Ensure the signature is valid, the status code == 2,
+// and that the money is going to you
+if (strtoupper(md5($concatFields)) == $_POST['md5sig']
+    && $_POST['status'] == 2
+    && $_POST['pay_to_email'] == $panel_settings['skrill_email'])
+{
+	$body = 'Paid to email		: '.$_POST['pay_to_email']."<br>".
+			'Currency			: '.$_POST['currency']."<br>".
+			'Amount				: '.$_POST['amount']."<br>".
+			'Payment type		: '.$_POST['payment_type']."<br>".
+			'Transaction ID		: '.$_POST['transaction_id']."<br>".
+			'Paid from email	: '.$_POST['pay_from_email']."<br>".
+			'CART ID			: '.$_POST['cart_id']."<br>";
+
+	
+	// Here you can do whatever you want with the variables, for instance inserting or updating data into your Database
+
+	$user_homes = $db->resultQuery( "SELECT * 
+									 FROM OGP_DB_PREFIXbilling_carts AS cart
+									 JOIN
+									 OGP_DB_PREFIXbilling_orders AS orders  
+									 ON 
+									 orders.cart_id=cart.cart_id
+									 WHERE cart.cart_id=".$cart_id);
+
+	$query = "UPDATE " . $table_prefix . "billing_carts
+			  SET paid=1
+			  WHERE cart_id=".$cart_id;
+					  
+	foreach($user_homes as $user_home)
+	{			
+		if($user_home['home_id'] != 0)
+		{
+			$home_id = $user_home['home_id'];
+			$home_info = $db->getGameHomeWithoutMods($home_id);
+			$server_info = $db->getRemoteServerById($home_info['remote_server_id']);
+			$remote = new OGPRemoteLibrary($server_info['agent_ip'], $server_info['agent_port'], $server_info['encryption_key'], $server_info['timeout']);
+			
+			if ( isset( $home_info['ftp_password'] ) AND !empty( $home_info['ftp_password'] ) )
+			{
+				$remote->ftp_mgr("useradd", $home_info['home_id'], $home_info['ftp_password'], $home_info['home_path']);
+				$db->changeFtpStatus('enabled',$home_info['home_id']);
+			}
+
+			if ($user_home['end_date'] == "0")
+			{
+				if ($user_home['invoice_duration'] == "hour")
+				{
+					$add_time = time() + ($user_home['qty'] * 60 * 60);
+					$end_date = date('YmdHi',$add_time);
+				}
+				elseif ($user_home['invoice_duration'] == "month")
+				{
+					$end_date = date('YmdHi', strtotime('+'.$user_home['qty'].' month'));
+				}
+				elseif ($user_home['invoice_duration'] == "year")
+				{
+					$end_date = date('YmdHi', strtotime('+'.$user_home['qty'].' year'));
+				}
+				//Set the expiration date to the new order
+				$db->query( "UPDATE " . $table_prefix . "billing_orders
+							 SET end_date='$end_date'
+							 WHERE order_id=".$user_home['order_id']);
+							 
+				// Set payment/creation date
+				$date = date('d/m/Y H:i');
+				$db->query( "UPDATE OGP_DB_PREFIXbilling_carts
+							 SET date='$date'
+							 WHERE cart_id=".$cart_id);
+			}
+			
+			$services = $db->resultQuery( "SELECT * 
+										   FROM OGP_DB_PREFIXbilling_services
+										   WHERE service_id=".$user_home['service_id']);
+			$service = $services[0];
+			$user_id = $user_home['user_id'];
+			$db->assignHomeTo("user", $user_id, $home_id, $service['access_rights']);
+			
+			$query = "UPDATE " . $table_prefix . "billing_carts
+					  SET paid=3
+					  WHERE cart_id=".$cart_id;
+		}
+	}
+		
+	$db->query($query);
+	$subject = "Payment done.";
+	mymail($panel_settings['skrill_email'], $subject, $body, $panel_settings);
+}
+?>

+ 106 - 0
modules/billing/skrill.php

@@ -0,0 +1,106 @@
+<?php
+function curPageName() 
+{
+	return substr($_SERVER["SCRIPT_NAME"],strrpos($_SERVER["SCRIPT_NAME"],"/")+1);
+}
+
+function exec_ogp_module()
+{
+	global $db,$view,$settings;
+	
+	$cart_id = $_GET['cart_id'];
+
+	if(!empty($cart_id))
+	{		
+		$orders = $db->resultQuery( "SELECT * FROM OGP_DB_PREFIXbilling_orders WHERE cart_id=".$cart_id );
+		if( !empty( $orders ) )
+		{
+			$cart['price'] = 0;
+			foreach($orders as $order) 
+			{
+				if( $order['qty'] > 1 )
+					$order['invoice_duration'] = $order['invoice_duration']."s";
+				
+				$cart['price'] += $order['price'];
+				
+				if( !isset( $cart['name'] ) )
+					$cart['name'] = $order['home_name']."(".$order['qty'].get_lang($order['invoice_duration']).",".$order['max_players'].get_lang('slots').")";
+				else
+					$cart['name'] .= ' + '.$order['home_name']."(".$order['qty'].get_lang($order['invoice_duration']).",".$order['max_players'].get_lang('slots').")";
+			}
+			
+			$total = $cart['price']+($settings['tax_amount']/100*$cart['price']);
+			if ($total === 0)
+			{
+				$db->query("UPDATE " . $table_prefix . "billing_carts
+												SET paid=1
+												WHERE cart_id=".$cart_id);
+				$view->refresh("home.php?m=billing&p=cart",0);
+			}
+			else
+			{
+				$s = ( isset($_SERVER['HTTPS']) and  get_true_boolean($_SERVER['HTTPS']) ) ? "s" : "";
+				$p = isset($_SERVER['SERVER_PORT']) & $_SERVER['SERVER_PORT'] != "80" ? ":".$_SERVER['SERVER_PORT'] : NULL ;
+				$this_script = 'http'.$s.'://'.$_SERVER['SERVER_NAME'].$p.$_SERVER['SCRIPT_NAME'];
+				$current_folder_url = str_replace( curPageName(), "", $this_script);
+				
+				$lang_array = array('Danish' => 'DA',
+									'English' => 'EN',
+									'French' => 'FR',
+									'German' => 'DE',
+									'Polish' => 'PL',
+									'Russian' => 'RU',
+									'Spanish' => 'ES');
+				
+				$ogp_lang = !empty($_SESSION['users_lang']) ? $_SESSION['users_lang'] : $settings['panel_language'];
+				$skrill_lang = 'EN';
+				foreach($lang_array as $userlang => $langcode )
+				{
+					if($userlang == $ogp_lang)
+						$skrill_lang = $langcode;
+				}
+								
+				$url = "https://www.moneybookers.com/app/payment.pl";
+				$ipn_url = $current_folder_url.'modules/billing/skrill-ipn.php';
+				$return_url = $current_folder_url.'home.php?m=billing&p=cart';
+				$amount = number_format( $total , 2 );
+				
+				$fields = array(
+						'pay_to_email' => urlencode($settings['skrill_email']),
+						'status_url' => urlencode($ipn_url),
+						'language' => $skrill_lang,
+						'amount' => urlencode($amount),
+						'currency' => $settings['currency'],
+						'detail1_description' => urlencode("CART ID: ".$cart_id),
+						'detail1_text' => urlencode($cart['name']),
+						'return_url' => urlencode($return_url),
+						'return_url_text' => urlencode(get_lang('back_to_your_cart')),
+						'return_url_target' => '3',
+						'cancel_url' => urlencode($return_url),
+						'cancel_url_target' => '3',
+						'merchant_fields' => 'cart_id',
+						'cart_id' => $cart_id
+				);
+
+				//url-ify the data for the POST
+				foreach($fields as $key=>$value) 
+				{ 
+					$fields_string .= $key.'='.$value.'&'; 
+				}
+				$fields_string = rtrim($fields_string, '&');
+
+				$ch = curl_init();
+				curl_setopt($ch, CURLOPT_URL, $url);
+				curl_setopt($ch,CURLOPT_POST, 1);
+				curl_setopt($ch,CURLOPT_POSTFIELDS, $fields_string);
+				curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
+				echo curl_exec($ch);
+				curl_close($ch);			 
+					 
+				echo "<h2>".get_lang_f('redirecting_to',get_lang('skrill'))."</h2>";
+				echo "<img style='border:4px dotted white;background:black' src='modules/addonsmanager/loading.gif' width='180' height='180' /img><br><br>";
+			}
+		}
+	}
+}
+?>