added reseller

This commit is contained in:
Frank Harris 2026-06-09 06:20:35 -05:00
parent 5a03946bdf
commit d587621851
23 changed files with 3618 additions and 0 deletions

View file

@ -0,0 +1,185 @@
<style>
form table.center tr td{
width:50%;
width:50%;
}
table.center{
color:#333333;
clear:both;
width:100%;
height:35px;
margin-top:-6px;
padding-top:10px;
text-align: center;
color:#FFFF;
}
table.center tr td{
border:1px solid #cfcfcf;
background:#e5e5e5;
}
table.center th{
border:1px solid #cfcfcf;
background:#c5c5c5;
}
table.center tr.first_row td{
border:1px solid #cfcfcf;
background:#c5c5c5;
}
</style>
<?php
/*
*
* OGP - Open Game Panel
* Copyright (C) Copyright (C) 2008 - 2013 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()
{
error_reporting(E_ALL);
global $db,$settings;
$isAdmin = $db->isAdmin($_SESSION['user_id']);
echo "<h2>".get_lang('account_details')."</h2>";
if( isset( $_POST['remove'] ) )
{
require_once("modules/config_games/server_config_parser.php");
require_once("includes/lib_remote.php");
$user_homes = $db->resultQuery( "SELECT *
FROM OGP_DB_PREFIXreseller_homes
WHERE home_id=" . $_POST['home_id'] );
$user_home = $user_homes[0];
$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']);
$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);
}
// Unassign Home to the current owner at DB.
$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']);
print_success(get_lang_f('home_id_deleted_successfully', $home_id) );
// Restore slots in the reseller account
$qry_accounts = $db->resultQuery("SELECT * FROM OGP_DB_PREFIXreseller_accounts WHERE account_id=".$user_home['account_id']);
$account = $qry_accounts[0];
$update_available_slots = $account['available_slots'] + $user_home['assigned_slots'];
$db->query("UPDATE OGP_DB_PREFIXreseller_accounts SET available_slots=".$update_available_slots." WHERE account_id=".$account['account_id']);
// Delete the reseller home entry
$db->query( "DELETE FROM OGP_DB_PREFIXreseller_homes
WHERE home_id=" . $home_id);
print_success(get_lang_f('the_amount_of_available_slots_has_been_incremented_to', $update_available_slots) );
}
$filter = isset($_GET['account_id']) ? "account_id=".$_GET['account_id'] : "";
$filter_and = isset($_GET['account_id']) ? $filter." AND" : "";
$user_account = $db->resultQuery("SELECT * FROM OGP_DB_PREFIXreseller_accounts WHERE $filter_and user_id=".$_SESSION['user_id']);
$where_filter = isset($_GET['account_id']) ? " WHERE ".$filter : "";
$reseller_homes = $db->resultQuery("SELECT * FROM OGP_DB_PREFIXreseller_homes".$where_filter);
if( ! empty($reseller_homes) AND ( !empty($user_account[0]) or $isAdmin ) )
{
echo "<table class='center'>";
echo "<tr><th>".get_lang('home_id')."</th><th>".get_lang('game_server')."</th>".
"<th>".get_lang('owner_user_name')."</th>";
if($isAdmin)
{
echo "<th>".get_lang('reseller_user_name')."</th>";
}
echo "<th>".get_lang('assigned_slots')."</th>".
"<th>".get_lang('status')."</th>".
"<th>".get_lang('remove_server')."</th></tr>";
$i = 0;
foreach($reseller_homes as $user_home)
{
// reseller home data
$account_id = $user_home['account_id'];
$assigned_slots = $user_home['assigned_slots'];
$status = $user_home['status'];
$user_id = $user_home['user_id'];
$home_id = $user_home['home_id'];
// reseller account data
$rs_account = $db->resultQuery("SELECT * FROM OGP_DB_PREFIXreseller_accounts WHERE account_id=".$account_id);
// reseller user info
$rs_user_info = $db->getUserById($rs_account[0]['user_id']);
$reseller_username = $rs_user_info['users_login'];
// owner user info
$ow_user_info = $db->getUserById($user_id);
$owner_username = $ow_user_info['users_login'];
$row = $db->getUserGameHome($user_id,$home_id);
echo "<tr class='tr".($i++%2)."'><td>$home_id</td><td class='tdh'>$row[game_name]";
echo empty($row['home_name']) ? get_lang('not_available') : " (".$row['home_name'].")";
echo "</td><td class='tdh'>";
if($isAdmin)
{
?>
<a href="?m=user_admin&p=edit_user&user_id=<?php echo $user_id;?>" ><?php echo $owner_username;?></a>
<?php
echo "</td>\n";
echo "</td><td class='tdh'>";
?>
<a href="?m=user_admin&p=edit_user&user_id=<?php echo $rs_account[0]['user_id'];?>" ><?php echo $reseller_username;?></a>
<?php
}
else
{
echo $owner_username;
}
echo "</td><td>$assigned_slots ".get_lang('slots').
"</td><td class='tdh'>\n".$status."</td>\n";
echo "</td><td class='tdh'>\n".
"<form method=POST><input type=hidden name=home_id value=".$home_id.
" />\n<input type=submit name=remove value='".get_lang('remove')."' />\n</form>\n".
"</td></tr>\n";
}
echo "</table>\n";
}
elseif( $isAdmin AND !isset( $_GET['account_id'] ) )
print_failure(get_lang('there_is_no_reseller_homes_related_to_any_reseller_account'));
else
{
print_failure(get_lang('there_are_no_game_servers_related_to_the_selected_reseller_account'));
}
echo create_back_button($_GET['m'], $_GET['bt']);
}
?>

View file

@ -0,0 +1,187 @@
<?php
/*
*
* OGP - Open Game Panel
* Copyright (C) Copyright (C) 2008 - 2013 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()
{
error_reporting(E_ALL);
global $db;
if(isset($_POST['remove']))
{
$query_delete_account = $db->query("DELETE FROM OGP_DB_PREFIXreseller_accounts WHERE cart_id=".$_POST['cart_id']);
$query_delete_account = $db->query("DELETE FROM OGP_DB_PREFIXreseller_carts WHERE cart_id=".$_POST['cart_id']);
}
if(isset($_POST['paid']))
{
$query = "UPDATE OGP_DB_PREFIXreseller_carts
SET paid=1
WHERE cart_id=".$_POST['cart_id'];
$db->query($query);
$query = "UPDATE OGP_DB_PREFIXreseller_accounts
SET payment_date=NOW()
WHERE cart_id=".$_POST['cart_id'];
$db->query($query);
$cart_accounts = $db->resultQuery("SELECT * FROM OGP_DB_PREFIXreseller_accounts WHERE cart_id=".$_POST['cart_id']);
foreach ( $cart_accounts as $account )
{
$months = $account['invoice_duration'] == "month" ? 1 : 12;
$total_months = $months * $account['qty'];
$db->query("UPDATE OGP_DB_PREFIXreseller_accounts
SET available_months=".$total_months.
" WHERE account_id=".$account['account_id'] );
$db->query( "UPDATE OGP_DB_PREFIXreseller_accounts ".
"SET status=ADDDATE(DATE(NOW() + INTERVAL ".$total_months." MONTH), 1) ".
"WHERE account_id=".$account['account_id'] );
}
}
$status_array = array ( "not_paid" => 0,
"paid" => 1,
"awaiting_payment" => 2,
"paid_and_installed" => 3
);
?>
<h2><?php print_lang("reseller_accounts");?></h2>
<?php
foreach($status_array as $status => $paid_value)
{
$carts = $db->resultQuery("SELECT * FROM OGP_DB_PREFIXreseller_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("account_id");?></th>
<th><?php print_lang("home_name");?></th>
<th><?php print_lang("price");?></th>
</tr>
<?php
$accounts = $db->resultQuery("SELECT * FROM OGP_DB_PREFIXreseller_accounts WHERE cart_id=".$cart['cart_id']);
$subtotal = 0;
$i = 0;
foreach($accounts as $account)
{
?>
<tr class="tr<?php echo($i++%2);?>">
<td><a href="?m=user_admin&p=edit_user&user_id=<?php echo $account['user_id'];?>" ><?php $user = $db->getUserById($account['user_id']); echo $user['users_login'];?></a></td>
<td><b class="success"><?php echo $account['cart_id'];?></b></td>
<td>
<?php
if($account['account_id'] > 0)
{
?>
<b class="success"><?php echo $account['account_id'];?></b>
<a href="?m=reseller&bt=rs_accounts&p=account_details&account_id=<?php echo $account['account_id'];?>" >(<?php print_lang('account_details');?>)</a>
<?php
}
else
{
?>
<b class="success"><?php
echo $account_id = round(($account['account_id'] - $account['account_id'] - $account['account_id']) / 1000000);
?></b>
<?php
print_lang('account_extended_to_new_cart');
}
?></td><td><?php
$qry_services = "SELECT * FROM OGP_DB_PREFIXreseller_services WHERE service_id=".$account['service_id'];
$services = $db->resultQuery($qry_services);
$service = $services[0];
$invoice_duration = $account['qty'] > 1 ? $account['invoice_duration']."s" : $account['invoice_duration'];
echo $service['service_name']." [ ".$service['slot_max_qty']." ".get_lang('slots').", ".$account['qty']." ".get_lang($invoice_duration)." ]";?></td>
<td><?php echo $account['price'].$carts[0]['currency'];?></td>
</tr><?php
$subtotal += $account['price'];
}
$total = $subtotal+($cart['tax_amount']/100*$subtotal);
?>
<tr>
<td>
<?php
if ($status == "not_paid" OR $status == "awaiting_payment" OR $account['status'] == -1 )
{
$months = $account['invoice_duration'] == "month" ? 1 : 12;
$total_months = $months * $account['qty'];
?>
<form method="post" action="">
<input type="hidden" name="cart_id" value="<?php echo $account['cart_id'];?>">
<input type="hidden" name="total_months" value="<?php echo $total_months;?>">
<input name="paid" type="submit" value="<?php print_lang("set_as_paid");?>">
</form>
<?php
}
elseif($status == "paid" )
{
?>
<form method="post" action="?m=reseller&p=bill&bt=rs_accounts">
<input type="hidden" name="cart_id" value="<?php echo $account['cart_id'];?>">
<input name="paid" type="submit" value="<?php print_lang("see_invoice");?>">
</form>
<?php
}
elseif($status == "paid_and_installed")
{
?>
<form method="post" action="?m=reseller&p=bill">
<input type="hidden" name="cart_id" value="<?php echo $account['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 $account['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 ).$carts[0]['currency']."</b>"; ?>
</td>
<td>
<?php echo get_lang('tax')." <b>".$cart['tax_amount']."% (".number_format( $cart['tax_amount']/100*$subtotal, 2 ).$carts[0]['currency'].")</b>"; ?>
</td>
<td>
<?php echo get_lang('total')." <b>".number_format( $total , 2 ).$carts[0]['currency']."</b>"; ?>
</td>
</tr>
</table>
</center>
<?php
}
}
}
}
?>

View file

@ -0,0 +1,102 @@
<?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();
$service_id = $_REQUEST['service_id'];
// Query for Selected service info.
$services = $db->resultQuery("SELECT DISTINCT * FROM OGP_DB_PREFIXreseller_services WHERE service_id=".$service_id);
$service = $services[0];
//Compiling info about invoice to create an invoice order.
$qty = $_POST['qty'];
$invoice_duration = $_POST['invoice_duration'];
$user_id = $_SESSION['user_id'];
$tax_amount = $settings['tax_amount'];
$currency = $settings['currency'];
if ($invoice_duration == "month")
{
$price_pack = $service['price_per_month'];
}
elseif ($invoice_duration == "year")
{
$price_pack = $service['price_per_year'];
}
$price = $price_pack * $qty;
if( isset( $_POST['code'] ) and $_POST['code'] != "" )
{
$discount_info = $db->resultQuery("SELECT DISTINCT percentage FROM OGP_DB_PREFIXreseller_discount_codes WHERE code='".$_POST['code']."'");
if(!empty($discount_info))
{
$discount_percentage = $discount_info[0]['percentage'];
$discount_qty = ( $price / 100 ) * $discount_percentage;
if( $discount_qty > 0 )
$price = $price - $discount_qty;
}
else
{
$discount_percentage = 0;
}
}
else
{
$discount_percentage = 0;
}
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,
"user_id" => $_SESSION['user_id'],
"qty" => $qty,
"invoice_duration" => $invoice_duration,
"discount" => $discount_percentage,
"price" => $price,
"tax_amount" => $tax_amount,
"currency" => $currency,
"paid" => 0,
"status" => 0);
echo '<meta http-equiv="refresh" content="0;url=?m=reseller&p=cart">';
}
}
?>

View file

@ -0,0 +1,592 @@
<?php
/*
*
* OGP - Open Game Panel
* Copyright (C) Copyright (C) 2008 - 2013 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.
*
*/
//require("include/html_functions.php");
function create_selection($selection,$flag)
{
return "<tr><td align='right'><label for='".clean_id_string($selection)."'>".get_lang($selection).":</label></td>
<td align='left'><input id='".clean_id_string($selection)."' type='checkbox' name='".$selection."' value='1' checked='checked' /></td></tr><tr>
<td align='left' class='info' colspan='2'>".get_lang($selection.'_info')."</td></tr>";
}
function exec_ogp_module()
{
global $db,$view,$settings;
echo "<h2>".get_lang('rs_assign_servers')."</h2>";
$remote_servers = $db->getRemoteServers();
if( $remote_servers === FALSE )
{
echo "<p class='note'>".get_lang('no_remote_servers_configured')."</p>
<p><a href='?m=server'>".get_lang('add_remote_server')."</a></p>";
return;
}
$game_cfgs = $db->getGameCfgs();
$users = $db->getUserList();
if ( $game_cfgs === FALSE )
{
echo "<p class='note'>".get_lang('no_game_configurations_found')." <a href='?m=config_games'>".get_lang('game_configurations')."</a></p>";
return;
}
$selections = array( "allow_updates" => "u",
"allow_file_management" => "f",
"allow_parameter_usage" => "p",
"allow_extra_params" => "e",
"allow_ftp" => "t");
if ( isset($_REQUEST['add_game_server']) )
{
$rserver_id = $_POST['rserver_id'];
$home_cfg_id = $_POST['home_cfg_id'];
$mod_cfg_id = $_POST['mod_cfg_id'];
$max_players = $_POST['max_players'];
$web_user_id = trim($_POST['web_user_id']);
$qry_accounts = $db->resultQuery("SELECT * FROM OGP_DB_PREFIXreseller_accounts WHERE account_id=".$_POST['account_id']);
$account = $qry_accounts[0];
$qry_service = $db->resultQuery("SELECT * FROM OGP_DB_PREFIXreseller_services WHERE service_id=".$account['service_id']);
$service = $qry_service[0];
$max_access_rights = $service['max_access_rights'];
$start_port = $service['start_port'];
$end_port = $service['end_port'];
$post_months = $_POST['invoice_duration'] == "month" ? 1 : 12;
$assigned_months = $post_months * $_POST['qty'];
$account_months = $account['invoice_duration'] == "month" ? 1 : 12;
$account_total_months = $account_months * $account['qty'];
if( $account['available_months'] >= $assigned_months AND $account['available_slots'] >= $max_players )
{
$control_password = genRandomString(8);
$access_rights = "";
$ftp = FALSE;
foreach ($selections as $selection => $flag)
{
if (isset($_POST[$selection]))
{
if( preg_match( "/$flag/", $max_access_rights ) )
{
$access_rights .= $flag;
if ($flag == "t")
{
$ftp = TRUE;
}
}
}
}
if ( empty( $web_user_id ) )
{
print_failure(get_lang('bad_user_name'));
}
else
{
foreach ( $game_cfgs as $cfg )
{
if($cfg['home_cfg_id'] == $home_cfg_id) $server_name = $cfg['game_name'];
}
foreach ( $remote_servers as $server )
{
if($server['remote_server_id'] == $rserver_id) $ogp_user = $server['ogp_user'];
}
foreach ( $users as $user )
{
if($user['user_id'] == $web_user_id) $web_user = $user['users_login'];
}
$ftppassword = genRandomString(8);
$game_path = "/home/".$ogp_user."/";
if ( ( $new_home_id = $db->addGameHome($rserver_id,$web_user_id,$home_cfg_id,
clean_path($game_path),$server_name,$control_password,$ftppassword) )!== FALSE )
{
$db->assignHomeTo("user",$web_user_id,$new_home_id,$access_rights);
$home_info = $db->getGameHomeWithoutMods($new_home_id);
require_once('includes/lib_remote.php');
$remote = new OGPRemoteLibrary($home_info['agent_ip'],$home_info['agent_port'],$home_info['encryption_key']);
if($ftp)
{
$host_stat = $remote->status_chk();
if( $host_stat === 1)
{
$remote->ftp_mgr("useradd", $home_info['home_id'], $home_info['ftp_password'], $home_info['home_path']);
$db->changeFtpStatus('enabled',$home_info['home_id']);
}
}
$home_id = $new_home_id;
$remote_server_ips = $db->getRemoteServerIPs($rserver_id);
$max_id = count($remote_server_ips) - 1;
$ip_id = ( count($remote_server_ips) > 1 ) ? $remote_server_ips[rand(0,$max_id)]['ip_id'] : $remote_server_ips['0']['ip_id'];
$add_port = $db->addGameIpPort( $home_id, $ip_id, $db->getNextAvailablePort($ip_id,$home_cfg_id) );
$mod_id = $db->addModToGameHome($home_id,$mod_cfg_id);
if ( $mod_id === FALSE )
{
print_failure(get_lang_f('failed_to_assing_mod_to_home',$mod_cfg_id));
unset($_POST);
}
else
{
$cliopts = "";
$cpus = "NA";
$nice = "0";
if ( $db->updateGameModParams($max_players,$cliopts,$cpus,$nice,$home_id,$mod_cfg_id) === FALSE )
{
print_failure(get_lang_f('failed_to_assing_mod_to_home',$mod_cfg_id));
unset($_POST);
}
else
{
$update_available_slots = $account['available_slots'] - $max_players;
$db->query("UPDATE OGP_DB_PREFIXreseller_accounts SET available_slots=".$update_available_slots." WHERE account_id=".$account['account_id']);
$status = "ADDDATE(DATE(NOW() + INTERVAL ".$assigned_months." MONTH), 1)";
$query = sprintf('INSERT INTO `%1$sreseller_homes` (`home_id`, `user_id`, `account_id`, `assigned_slots`, `status`)
VALUES(\'%2$s\', \'%3$s\', \'%4$s\', \'%5$s\', %6$s)
ON DUPLICATE KEY UPDATE
user_id=VALUES(user_id),
account_id=VALUES(account_id),
assigned_slots=VALUES(assigned_slots),
status=VALUES(status);',
'OGP_DB_PREFIX',
$db->real_escape_string($home_id),
$db->real_escape_string($web_user_id),
$db->real_escape_string($account['account_id']),
$db->real_escape_string($max_players),
$db->real_escape_string($status));
$db->query($query);
if ($_POST['installation'] == "manual")
{
print_success(get_lang('server_added_successfully_needs_manual_install'));
unset($_POST);
}
else
{
// Getting pre and post commands
$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'];
$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'];
$home_info = $db->getGameHome($home_id);
$server_xml = read_server_config(SERVER_CONFIG_LOCATION."/".$home_info['home_cfg_file']);
$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 );
// Starting Game server installation
if( $_POST['installation'] == "steam" OR $_POST['installation'] == "steamcmd" )
{
$mod_xml = xml_get_mod($server_xml, $home_info['mods'][$mod_id]['mod_key']);
$installer_name = $mod_xml->installer_name;
$modkey = $home_info['mods'][$mod_id]['mod_key'];
// 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 : '';
preg_match("/(win|linux)(32|64)?$/", $server_xml->game_key, $matches);
$os = strtolower($matches[1]) == 'linux'? 'linux':'windows';
$arch = isset($matches[2])?$matches[2]:'32';
if($precmd == "")
{
$preInstallCMD = "";
if(isset($server_xml->post_install))
$preInstallCMD .= $server_xml->pre_install;
}
else
$preInstallCMD = $precmd;
if($postcmd == "")
{
$postInstallCMD = "";
if(isset($server_xml->post_install))
$postInstallCMD .= $server_xml->post_install;
}
else
$postInstallCMD = $postcmd;
$postInstallCMD .= "\n{OGP_LOCK_FILE} " . $home_info['home_path'] . "/" . ($server_xml->exe_location ? $server_xml->exe_location . "/" : "") . $server_xml->server_exec_name;
$remote->steam_cmd($home_info['home_id'],$home_info['home_path'],$installer_name,$modname,
$betaname,$betapwd,$login,$pass,$settings['steam_guard'],
$exec_folder_path,$exec_path,$preInstallCMD,$postInstallCMD,$os,'',$arch);
print_success(get_lang('server_added_successfully_installing'));
unset($_POST);
}
elseif($_POST['installation'] == "rsync")
{
if( isset($server_xml->lgsl_query_name) )
$rs_name = $server_xml->lgsl_query_name;
elseif( isset($server_xml->gameq_query_name) )
$rs_name = $server_xml->gameq_query_name;
elseif( isset($server_xml->protocol) )
$rs_name = $server_xml->protocol;
else
$rs_name = $server_xml->mods->mod['key'];
$url = "rsync.opengamepanel.org";
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";
$full_url = "$url/ogp_game_installer/$rs_name/$os/";
$remote->start_rsync_install($home_id,$home_info['home_path'],"$full_url",$exec_folder_path,$exec_path,$precmd,$postcmd);
print_success(get_lang('server_added_successfully_installing'));
unset($_POST);
}
}
}
}
}
else
{
print_failure(get_lang_f("failed_to_add_home_to_db",$db->getError()));
unset($_POST);
}
}
}
else
{
if( $account['available_months'] < $assigned_months )
print_failure( get_lang_f('you_assigned_months_this_amount_exceeds_the_available_months_in_this_reseller_account', $assigned_months, $account['available_months']) );
elseif( $account['available_slots'] < $max_players )
print_failure( get_lang_f('you_assigned_max_players_this_amount_exceeds_the_available_slots_in_this_reseller_account', $max_players, $account['available_slots']) );
$view->refresh('home.php?m=reseller&p=rs_assign_server', 5);
}
}
if( isset($_POST['account_id']) )
{
$qry_accounts = $db->resultQuery("SELECT * FROM OGP_DB_PREFIXreseller_accounts WHERE user_id=".$_SESSION['user_id']." AND account_id=".$_POST['account_id']);
$account = $qry_accounts[0];
$qry_service = $db->resultQuery("SELECT * FROM OGP_DB_PREFIXreseller_services WHERE service_id=".$account['service_id']);
$service = $qry_service[0];
$invoice_duration_string = $account['qty'] > 1 ? $account['invoice_duration']."s" : $account['invoice_duration'];
echo "<h4>" . $service['service_name'] . "&nbsp;/&nbsp;" . $account['qty'] . " " . get_lang( $invoice_duration_string ) . "&nbsp;&nbsp;&nbsp;[".get_lang_f( 'available_slots', $account['available_slots'] ).
"&nbsp;/&nbsp;".get_lang_f( 'available_months', $account['available_months'] ).
"]&nbsp;<a href='?m=reseller&p=account_details&bt=rs_assign_server&account_id=".$account['account_id'].
"' >(".get_lang('account_details').")</a></h4>";
}
// View form to add more servers.
echo "<form action='?m=reseller&amp;p=rs_assign_server' method='post'>";
echo "<table class='center'>";
if( !isset($_POST['account_id']) )
{
$accounts = $db->resultQuery("SELECT * FROM OGP_DB_PREFIXreseller_accounts WHERE user_id=".$_SESSION['user_id']. "");
if( ! empty( $accounts ) )
{
echo "<tr><td align=right><b>".get_lang('select_reseller_account')."</b></td><td align=left><select onchange=".'"this.form.submit()"'." name='account_id'>\n";
echo "<option></option>\n";
foreach( $accounts as $account )
{
$qry_service = $db->resultQuery("SELECT * FROM OGP_DB_PREFIXreseller_services WHERE service_id=".$account['service_id']);
$service = $qry_service[0];
echo "<option value='".$account['account_id']."'>".
$service['service_name']." (".get_lang_f('available_slots', $account['available_slots'])."&nbsp;/&nbsp;".get_lang_f('available_months', $account['available_months']).")</option>\n";
}
echo "</select>\n";
echo "</td></tr>";
}
else
{
print_failure(get_lang('there_is_no_reseller_accounts_available_yet'));
echo create_back_button($_GET['m'],"rs_packs_shop");
}
}
else
{
if( $account['available_slots'] < 1 )
{
print_failure(get_lang('there_is_no_slots_available_in_this_reseller_account'));
echo create_back_button($_GET['m'],"rs_packs_shop");
return;
}
elseif( !isset( $_POST['home_cfg_id'] ) )
{
$rhost_id = $service['remote_server_id'];
$remote_server = $db->getRemoteServer($rhost_id);
require_once('includes/lib_remote.php');
$remote = new OGPRemoteLibrary($remote_server['agent_ip'],$remote_server['agent_port'],$remote_server['encryption_key']);
$host_stat = $remote->status_chk();
if( $host_stat === 1)
$os = $remote->what_os();
else
{
print_failure(get_lang_f("caution_agent_offline_can_not_get_os_and_arch_showing_servers_for_all_platforms"));
$os = "Unknown OS";
}
echo "<tr><td align=right><b>".get_lang('select_game')."</b></td><td align=left>\n".
"<select name='home_cfg_id' onchange='this.form.submit()' >\n".
"<option></option>\n";
// Linux 64 bits + wine
if( preg_match("/Linux/", $os) AND preg_match("/64/", $os) AND preg_match("/wine/", $os) )
{
foreach ( $game_cfgs as $row )
{
if ( preg_match("/linux/", $row['game_key']) )
echo "<option value='".$row['home_cfg_id']."'>".$row['game_name'];
if ( preg_match("/64/", $row['game_key']) ) echo " (64 bit)";
echo "</option>\n";
}
echo "<option style='background:black;color:white;' value=''>".get_lang('wine_games').":</option>\n";
foreach ( $game_cfgs as $row )
{
if ( preg_match("/win/", $row['game_key']) )
echo "<option value='".$row['home_cfg_id']."'>".$row['game_name'];
if ( preg_match("/64/", $row['game_key']) ) echo " (64 bit)";
echo "</option>\n";
}
}
// Linux 64 bits
elseif( preg_match("/Linux/", $os) AND preg_match("/64/", $os) )
{
foreach ( $game_cfgs as $row )
{
if ( preg_match("/linux/", $row['game_key']))
echo "<option value='".$row['home_cfg_id']."'>".$row['game_name'];
if ( preg_match("/64/", $row['game_key']) ) echo " (64 bit)";
echo "</option>\n";
}
}
// Linux 32 bits + wine
elseif( preg_match("/Linux/", $os) AND preg_match("/wine/", $os) )
{
foreach ( $game_cfgs as $row )
{
if ( preg_match("/linux32/", $row['game_key']) )
echo "<option value='".$row['home_cfg_id']."'>".$row['game_name']."</option>\n";
}
echo "<option style='background:black;color:white;' value=''>".get_lang('wine_games')."</option>\n";
foreach ( $game_cfgs as $row )
{
if ( preg_match("/win32/", $row['game_key']) )
echo "<option value='".$row['home_cfg_id']."'>".$row['game_name']."</option>\n";
}
}
// Linux 32 bits
elseif( preg_match("/Linux/", $os) )
{
foreach ( $game_cfgs as $row )
{
if ( preg_match("/linux32/", $row['game_key']) )
echo "<option value='".$row['home_cfg_id']."'>".$row['game_name']."</option>\n";
}
}
// Windows 64 bits (CYGWIN)
elseif( preg_match("/CYGWIN/", $os) AND preg_match("/64/", $os))
{
foreach ( $game_cfgs as $row )
{
if ( preg_match("/win/", $row['game_key']) )
echo "<option value='".$row['home_cfg_id']."'>".$row['game_name'];
if ( preg_match("/64/", $row['game_key']) ) echo " (64 bit)";
echo "</option>\n";
}
}
// Windows 32 bits (CYGWIN)
elseif( preg_match("/CYGWIN/", $os))
{
foreach ( $game_cfgs as $row )
{
if ( preg_match("/win32/", $row['game_key']) )
echo "<option value='".$row['home_cfg_id']."'>".$row['game_name']."</option>\n";
}
}
elseif ( $os == "Unknown OS" )
{
foreach ( $game_cfgs as $row )
{
echo "<option value='".$row['home_cfg_id']."'>".$row['game_name'];
if ( preg_match("/64/", $row['game_key']) ) echo " (64 bit)";
echo "</option>\n";
}
}
echo "</select>\n".
"<input type='hidden' name='account_id' value='".$account['account_id']."' />".
"<input type='hidden' name='rserver_id' value='".$rhost_id."' />".
"</td></tr>";
}
elseif( ! isset( $_POST['mod_cfg_id'] ) )
{
?>
<tr>
<td align=right><b><?php print_lang('select_mod'); ?></b></td><td align=left>
<select name="mod_cfg_id" onchange="this.form.submit()" >
<option></option>
<?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>
<input type="hidden" name="home_cfg_id" value="<?php echo $_POST['home_cfg_id']; ?>"/>
<input type="hidden" name="account_id" value="<?php echo $account['account_id']; ?>" />
<input type="hidden" name="rserver_id" value="<?php echo $_POST['rserver_id']; ?>" />
</td>
<tr>
<?php
}
elseif( ! isset( $_POST['max_players'] ) )
{
$cfg_info = $db->resultQuery("SELECT DISTINCT home_cfg_file FROM OGP_DB_PREFIXconfig_homes WHERE home_cfg_id=" . $_POST['home_cfg_id']);
$server_xml = read_server_config(SERVER_CONFIG_LOCATION.$cfg_info[0]['home_cfg_file']);
if( isset( $server_xml->installer ) )
{
$installation = $server_xml->installer;
}
else
{
if( isset($server_xml->lgsl_query_name) )
$lgslname = $server_xml->lgsl_query_name;
elseif( isset($server_xml->gameq_query_name) )
$lgslname = $server_xml->gameq_query_name;
elseif( isset($server_xml->protocol) )
$lgslname = $server_xml->protocol;
else
$lgslname = $server_xml->mods->mod['key'];
$sync_list = @file("modules/gamemanager/rsync.list", FILE_IGNORE_NEW_LINES);
if ( in_array($lgslname, $sync_list) )
{
$installation = "rsync";
}
else
{
$installation = "manual";
}
}
echo "<tr><td align=right>";
if ( $server_xml->max_user_amount )
{
echo "<b>".get_lang('max_players')."</b></td>";
$account['available_slots'];
$max_selectable_players = $server_xml->max_user_amount <= $account['available_slots'] ? $server_xml->max_user_amount : $account['available_slots'];
echo "<td align=left>".create_drop_box_from_array(range(0,$max_selectable_players),
'max_players" onchange="this.form.submit()',0,true).
'<input type="hidden" name="mod_cfg_id" value="'.$_POST['mod_cfg_id'].'"/>'.
'<input type="hidden" name="home_cfg_id" value="'.$_POST['home_cfg_id'].'"/>'.
'<input type="hidden" name="installation" value="'.$installation.'"/>'.
"<input type='hidden' name='account_id' value='".$account['account_id']."' />". "<input type='hidden' name='rserver_id' value='".$_POST['rserver_id']."' />";
}
echo "</td></tr>";
}
elseif( ! isset( $_POST['invoice_duration'] ) )
{
echo "<tr><td align=right>";
echo "<b>".get_lang('invoice_duration')."</b></td>";
?>
<td align=left>
<select name="qty">
<?php
$qty=1;
while($qty<=12)
{
if( $qty > $account['available_months'] )
break;
echo "<option value='$qty'>$qty</option>";
$qty++;
}
?>
</select>
<select name="invoice_duration">
<?php
if( $settings['price_per_month'] == 1 AND $account['available_months'] > 0 ) echo '<option value="month">'.get_lang('months').'</option>';
if( $settings['price_per_year'] == 1 AND $account['available_months'] > 11 ) echo '<option value="year">'.get_lang('years').'</option>';
?>
</select>
<?php
$max_access_rights = $service['max_access_rights'];
// Select user
echo "<tr><td align=right><b>".get_lang('assign_to')."</b></td>\n".
"<td class='left'><select name='web_user_id'>\n";
$users = $db->getUserList();
foreach ( $users as $user )
echo "<option value='".$user['user_id']."'>".$user['users_login']."</option>\n";
echo "</select>\n</td></tr>";
// Select permisions
echo "<tr><td colspan=2><h4>".get_lang('access_rights')."</h4></td></tr>";
foreach ( $selections as $selection => $flag)
{
if( preg_match( "/$flag/", $max_access_rights ) )
echo create_selection($selection,$flag);
}
echo '<input type="hidden" name="mod_cfg_id" value="'.$_POST['mod_cfg_id'].'"/>'.
'<input type="hidden" name="home_cfg_id" value="'.$_POST['home_cfg_id'].'"/>'.
'<input type="hidden" name="installation" value="'.$_POST['installation'].'"/>'.
'<input type="hidden" name="max_players" value="'.$_POST['max_players'].'"/>'.
"<input type='hidden' name='account_id' value='".$account['account_id']."' />".
"<input type='hidden' name='rserver_id' value='".$_POST['rserver_id']."' />".
"</td><tr><td align='center' colspan='2'>".
"<input type='submit' name='add_game_server' value='".get_lang('add_game_server')."' />";
"</td></tr>";
}
}
echo "</table></form>";
}
?>

146
Panel/modules/reseller/bill.php Executable file
View file

@ -0,0 +1,146 @@
<?php
function exec_ogp_module()
{
if(isset($_POST['cart_id']))
{
//Include database connection details
require('includes/config.inc.php');
global $db,$view;
if(isset($_GET['type']) && $_GET['type'] == 'cleared')
{
echo '<body onload="window.print()" >';
$view->setCharset(get_lang('lang_charset'));
}
$settings = $db->getSettings();
$user_id = $_SESSION['user_id'];
$cart_id = $_POST['cart_id'];
$isAdmin = $db->isAdmin( $_SESSION['user_id'] );
if ( $isAdmin )
$accounts = $db->resultQuery( "SELECT * FROM OGP_DB_PREFIXreseller_accounts WHERE cart_id=".$cart_id );
else
$accounts = $db->resultQuery( "SELECT * FROM OGP_DB_PREFIXreseller_accounts WHERE cart_id=".$cart_id." AND user_id=".$user_id );
$cart = $db->resultQuery( "SELECT * FROM OGP_DB_PREFIXreseller_carts WHERE cart_id=".$cart_id );
if( !empty($accounts) )
{
?>
<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['paypal_email']."</b>"; ?></td>
</tr>
<tr>
<td height="23" colspan="5">&nbsp;</td>
</tr>
<tr>
<td style="border: 2px solid #000000" bgcolor="#CCCCCC" height="23" ><div align=center><strong><?php print_lang("service");?></strong></div></td>
<td style="border: 2px solid #000000" bgcolor="#CCCCCC"><div align=center><strong><?php print_lang("invoice_duration");?></strong></div></td>
<td style="border: 2px solid #000000" bgcolor="#CCCCCC"><div align=center><strong><?php print_lang("service_price");?></strong></div></td>
<td style="border: 2px solid #000000" bgcolor="#CCCCCC"><div align=center><strong><?php print_lang("discount");?></strong></div></td>
<td style="border: 2px solid #000000" bgcolor="#CCCCCC"><div align=center><strong><?php print_lang("account_price");?></strong></div></td>
</tr>
<?php
$subtotal = 0;
foreach($accounts as $account)
{
$account_id = $account['account_id'];
$user_id = $account['user_id'];
$service_id = $account['service_id'];
$service = $db->resultQuery( "SELECT *
FROM OGP_DB_PREFIXreseller_services
WHERE service_id=".$service_id );
$cart = $db->resultQuery( "SELECT *
FROM OGP_DB_PREFIXreseller_carts
WHERE cart_id=".$account['cart_id'] );
$currency = $cart[0]['currency'];
$service_name = $service[0]['service_name'];
$slots_max_qty = $service[0]['slot_max_qty'];
$qty = $account['qty'];
$invoice_duration = $account['invoice_duration'];
$discount = $account['discount'];
$price = $account['price'];
$subtotal += $price;
//Calculating Costs
if ($invoice_duration == "month")
{
$price_slot=$service[0]['price_per_month'];
}
elseif ($invoice_duration == "year")
{
$price_slot=$service[0]['price_per_year'];
}
?>
<tr>
<td height="23"><?php echo $service_name; ?></td>
<td><?php echo $qty." ".get_lang($invoice_duration."s"); ?></td>
<td><?php echo $price_slot.$currency." / ".get_lang($invoice_duration)." (&nbsp;".$qty*$price_slot.$currency."&nbsp;)"; ?></td>
<td><?php echo $discount; ?>%</td>
<td><?php echo $price.$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 $subtotal.$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.$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("payment_date");?> : </strong></div></td>
<td style="border: 2px solid #000000"><?php echo $account['payment_date']; ?></td>
</tr>
<tr>
<td height="21" colspan="2">&nbsp;</td>
</tr>
</table>
<br><br>
<form method='post' action='?m=reseller&p=bill&bt=<?php echo $_GET['bt']; ?>&type=cleared' >
<input type="hidden" name="cart_id" value="<?php echo $_POST['cart_id'];?>">
<input type="submit" value="<?php print_lang('print_invoice') ?>" />
</form>
<?php
}
}
echo create_back_button($_GET['m'], $_GET['bt']);
}
?>

50
Panel/modules/reseller/cart.css Executable file
View file

@ -0,0 +1,50 @@
form table.center tr td{
width:50%;
width:50%;
}
table.center{
color:#333333;
clear:both;
width:100%;
height:35px;
margin-top:-6px;
padding-top:10px;
text-align: center;
color:#FFFF;
}
table.center tr td{
border:1px solid #cfcfcf;
background:#e5e5e5;
}
table.center th{
border:1px solid #cfcfcf;
background:#c5c5c5;
}
table.center tr.first_row td{
border:1px solid #cfcfcf;
background:#c5c5c5;
}
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";
color:black;
margin-left: auto;
margin-right: auto;
margin-top:20px;
margin-bottom:20px;
}

431
Panel/modules/reseller/cart.php Executable file
View file

@ -0,0 +1,431 @@
<?php
/*
*
* OGP - Open Game Panel
* Copyright (C) Copyright (C) 2008 - 2013 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 clean($str){
global $db;
$str = @trim($str);
if(get_magic_quotes_gpc())
{
$str = stripslashes($str);
}
return $db->real_escape_string($str);
}
function saveOrderToDb($account_id,$service_id,$user_id,$qty,$invoice_duration,$discount,$price,$cart_id,$available_slots,$payment_date){
global $db, $view;
if( $account_id == '' or $account_id <= -1000000)
{
$fields['service_id'] = $service_id;
$fields['user_id'] = $user_id;
$fields['qty'] = $qty;
$fields['invoice_duration'] = $invoice_duration;
$fields['discount'] = $discount;
$fields['price'] = $price;
$fields['cart_id'] = $cart_id;
$fields['available_slots'] = $available_slots;
$fields['payment_date'] = $payment_date;
return $db->resultInsertId('reseller_accounts', $fields);
}
else
{
$query = sprintf("UPDATE
`OGP_DB_PREFIXreseller_accounts` SET
`service_id` = '%d',
`user_id` = '%d',
`qty` = '%s',
`invoice_duration` = '%s',
`discount` = '%s',
`price` = '%s',
`cart_id` = '%d',
`available_slots` = '%d',
`payment_date` = '%s'
WHERE
account_id=%d",
clean($service_id),
clean($user_id),
clean($qty),
clean($invoice_duration),
clean($discount),
clean($price),
clean($cart_id),
clean($available_slots),
clean($payment_date),
clean($account_id));
if(!$db->query( $query ))
return false;
return $accound_id;
}
}
function assignOrdersToCart($user_id,$tax_amount,$currency)
{
global $db;
$fields['user_id'] = $user_id;
$fields['tax_amount'] = $tax_amount;
$fields['currency'] = $currency;
return $db->resultInsertId('reseller_carts', $fields);
}
function exec_ogp_module()
{
global $db,$view,$settings;
if( isset( $_POST["buy"] ) or isset( $_POST["pay"] ) )
{
if( isset( $_SESSION['CART'] ) )
{
$accounts = $_SESSION['CART'];
// Create a new cart on DB
$cart_id = assignOrdersToCart($_SESSION['user_id'],$settings['tax_amount'],$settings['currency']);
foreach($accounts as $account)
{
$service_id = $account['service_id'];
$user_id = $account['user_id'];
$qty = $account['qty'];
$invoice_duration = $account['invoice_duration'];
$discount = $account['discount'];
$price = $account['price'];
$paid = $account['paid'];
$service_info = $db->resultQuery( "SELECT * FROM OGP_DB_PREFIXreseller_services WHERE service_id=".$service_id );
$available_slots = $service_info[0]['slot_max_qty'];
//Save account to DB
if(!saveOrderToDb('',$service_id,$user_id,$qty,$invoice_duration,$discount,$price,$cart_id,$available_slots,"0"))
print_failure("A service could not be added to the database");
}
// Remove Cart From Session
unset($_SESSION['CART']);
$db->query( "UPDATE OGP_DB_PREFIXreseller_carts
SET paid=2
WHERE cart_id=".$cart_id);
}
else
{
$cart_id = $_POST['cart_id'];
}
}
if( isset( $_POST["extend"] ) or isset( $_POST["extend_and_pay"] ) )
{
$accounts = $db->resultQuery("SELECT * FROM OGP_DB_PREFIXreseller_accounts WHERE account_id=".$_POST['account_id']);
// Create a new cart on DB
$cart_id = assignOrdersToCart($_SESSION['user_id'],$settings['tax_amount'],$settings['currency']);
$account = $accounts[0];
$service_id = $account['service_id'];
$account_id = $account['account_id'];
$available_slots = $account['available_slots'];
$old_qty = $account['qty'];
$old_invoice_duration = $account['invoice_duration'];
$old_discount = $account['discount'];
$old_price = $account['price'];
$old_payment_date = $account['payment_date'];
// Get new invoice duration
$qty = $_POST['qty'];
$invoice_duration = $_POST['invoice_duration'];
//Calculating New Price
$services = $db->resultQuery( "SELECT *
FROM OGP_DB_PREFIXreseller_services
WHERE service_id=".$service_id );
$service = $services[0];
if ($invoice_duration == "month")
{
$price_pack = $service['price_per_month'];
}
elseif ($invoice_duration == "year")
{
$price_pack = $service['price_per_year'];
}
$price = $price_pack*$qty;
//Save the old account information in the old cart with a negative signed(-) int for billing purposses
$old_cart_id = $account['cart_id'];
$ext_account_id = ( 0 - $account['account_id'] ) * 1000000;
do {
$test_account_query = $db->resultQuery("SELECT * FROM OGP_DB_PREFIXreseller_accounts WHERE account_id=".$ext_account_id);
if( empty( $test_account_query[0] ) ) break;
--$ext_account_id;
} while( ! empty( $test_account_query[0] ) );
saveOrderToDb("$ext_account_id",$service_id,$_SESSION['user_id'],$old_qty,$old_invoice_duration,$old_discount,$old_price,$old_cart_id,$available_slots,$old_payment_date);
//Save the old account in to the new cart.
saveOrderToDb("$account_id",$service_id,$_SESSION['user_id'],$qty,$invoice_duration,"0",$price,$cart_id,$available_slots,"0");
//Set status to -2 at the old account information so it's known as an extended account.
$db->query( "UPDATE OGP_DB_PREFIXreseller_accounts
SET status=-2
WHERE account_id=$ext_account_id");
//Set status to 0 at the account information at the new cart, waiting for account extension payment.
$db->query( "UPDATE OGP_DB_PREFIXreseller_accounts
SET status=0
WHERE account_id=$account_id");
//Set status to 0 at the account information at the new cart, awaiting payment.
$db->query( "UPDATE OGP_DB_PREFIXreseller_carts
SET paid=2
WHERE cart_id=".$cart_id);
}
if(isset($_POST['remove']))
{
$cart_id = $_POST['cart_id'];
if( isset( $_SESSION['CART'][$cart_id] ) )
{
unset($_SESSION['CART'][$cart_id]);
}
$account_id = $_POST['account_id'];
$db->query( "DELETE FROM OGP_DB_PREFIXreseller_accounts WHERE account_id=".$account_id );
$accounts_in_cart = $db->resultQuery( "SELECT * FROM OGP_DB_PREFIXreseller_accounts WHERE cart_id=".$cart_id );
if( !$accounts_in_cart )
{
$db->query( "DELETE FROM OGP_DB_PREFIXreseller_carts WHERE cart_id=".$cart_id );
}
}
if ( isset( $_POST["cart_id"] ) AND ( isset( $_POST["pay"] ) or isset( $_POST["extend_and_pay"] ) ) )
{
$view->refresh('home.php?m=reseller&p=paypal&cart_id='.$_POST["cart_id"], 0);
}
?><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_PREFIXreseller_carts WHERE user_id=".$_SESSION['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_PREFIXreseller_carts AS cart JOIN
OGP_DB_PREFIXreseller_accounts AS account
ON account.cart_id=cart.cart_id
WHERE cart.cart_id=".$cart_id );
}
}
if( empty( $carts ) )
{
print_failure( get_lang('there_are_no_accounts_in_cart') );
?>
<a href="?m=reseller&p=rs_packs_shop"><?php print_lang('back'); ?></a>
<?php
return;
}
foreach ( $carts as $accounts )
{
if( !empty( $accounts ) )
{
?>
<center>
<table style="width:95%;text-align:center;" class="center">
<tr>
<th>
<?php print_lang("service");?></th>
<th>
<?php print_lang("service_price");?>
</th>
<th>
<?php print_lang("discount");?>
</th>
<th>
<?php print_lang("price");?>
</th>
<th>
<?php print_lang("account_actions");?>
</th>
</tr>
<?php
$subtotal = 0;
$i = 0;
foreach($accounts as $account)
{
$invoice_duration = ( $account['qty'] > 1 ) ? $account['invoice_duration']."s" : $account['invoice_duration'];
$subtotal += $account['price'];
$service_info = $db->resultQuery( "SELECT * FROM OGP_DB_PREFIXreseller_services WHERE service_id=".$account['service_id'] );
?>
<tr class="tr<?php echo($i++%2);?>">
<td>
<?php
echo "<b>".$service_info[0]['service_name']."</b> [".$account['qty']." ".get_lang($invoice_duration).", ".$service_info[0]['slot_max_qty']." ".get_lang('slots')."]" ;
?>
</td>
<td>
<?php
echo ($service_info[0]['price_per_'.$account['invoice_duration']] * $account['qty']).$account['currency'];
?>
</td>
<td>
<?php
echo $account['discount']."% (" .( ( $service_info[0]['price_per_'.$account['invoice_duration']] / 100) * $account['discount'] ) * $account['qty'] . $account['currency'] . ")";
?>
</td>
<td>
<?php
echo $account['price'].$account['currency'];
?>
</td>
<td style="text-align:center;">
<?php
if($account['paid'] == 0 or $account['paid'] == 2)
{
?>
<form method="post" action="">
<input type="hidden" name="cart_id" value="<?php echo $account['cart_id'];?>">
<input type="hidden" name="account_id" value="<?php echo $account['account_id'];?>">
<input type="submit" name="remove" value="<?php print_lang("remove_from_cart");?>">
</form>
<?php
}
if($account['paid'] == 1 and $account['status'] == "-2")
{
print_lang('account_extended_to_new_cart');
}
if($account['status'] == "-1")
{
?>
<form method="post" action="">
<input type="hidden" name="cart_id" value="<?php echo $account['cart_id'];?>">
<input type="hidden" name="account_id" value="<?php echo $account['account_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['price_per_month'] == 1) echo '<option value="month">'.get_lang('months').'</option>';
if( $settings['price_per_year'] == 1) echo '<option value="year">'.get_lang('years').'</option>';
?>
</select>
<input type="submit" name="extend" value="<?php print_lang("extend");?>">
</form>
<?php
}
elseif( $account['status'] > 0 )
{
?>
<form method="post" action="home.php?m=reseller&p=rs_assign_server">
<input type="hidden" name="account_id" value="<?php echo $account['account_id'];?>">
<input type="submit" name="remove" value="<?php print_lang("rs_assign_servers");?>">
</form>
<?php
}
?>
</td>
</tr>
<?php
}
?>
</table>
<table style="width:95%;text-align:left;" class="center">
<tr>
<td>
<?php print_lang("subtotal");?></td>
<td>
<?php
echo $subtotal.$account['currency'];?>
</td>
</tr>
<tr>
<td>
<?php print_lang("tax");?></td>
<td>
<?php echo $account['tax_amount'];?>%
</td>
</tr>
<tr>
<td>
<?php print_lang("total");?>
</td>
<td>
<?php
$total = $subtotal+($account['tax_amount']/100*$subtotal);
echo number_format( $total , 2 ).$account['currency'];
?>
</td>
<td>
<?php
if($account['paid'] == 1)
{
?>
<form method="post" action="?m=reseller&p=bill&bt=cart">
<input type="hidden" name="cart_id" value="<?php echo $account['cart_id'];?>">
<input name="paid" type="submit" value="<?php print_lang("see_invoice");?>">
</form>
<?php
}
elseif($account['paid'] == 2)
{
?>
<form method="post" action="">
<input type="hidden" name="cart_id" value="<?php echo $account['cart_id'];?>">
<input name="pay" type="submit" value="<?php print_lang("pay_from_paypal");?>">
</form>
<?php
}
elseif($account['paid'] == 3)
{
?>
<form method="post" action="?m=reseller&p=bill&bt=cart">
<input type="hidden" name="cart_id" value="<?php echo $account['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 $account['cart_id'];?>">
<input name="buy" type="submit" value="<?php print_lang("buy");?>">
</form>
<?php
}
?>
</form>
</td>
</tr>
</table>
</center>
<?php
}
}
?>
<a href="?m=reseller&p=rs_packs_shop"><?php print_lang('back'); ?></a>
<?php
}
?>

View file

@ -0,0 +1,137 @@
<?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);
//Remove outdated user homes, It must be a cron or in home.php
$user_homes = $db->resultQuery( "SELECT *
FROM OGP_DB_PREFIXreseller_homes
WHERE status>0 AND status<NOW()" );
if (!is_array($user_homes))
{
echo "Nothing to do at reseller homes.\r\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']);
$ftp_login = isset($home_info['ftp_login']) ? $home_info['ftp_login'] : $home_id;
$remote->ftp_mgr("userdel", $ftp_login);
$db->changeFtpStatus('disabled',$home_id);
$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);
}
// Unassign Home to the current owner at DB.
$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']);
echo "Home ID $home_id removed successfully.\r\n";
// Restore slots in the reseller account
$qry_accounts = $db->resultQuery("SELECT * FROM OGP_DB_PREFIXreseller_accounts WHERE account_id=".$user_home['account_id']);
$account = $qry_accounts[0];
$update_available_slots = $account['available_slots'] + $user_home['assigned_slots'];
$db->query("UPDATE OGP_DB_PREFIXreseller_accounts SET available_slots=".$update_available_slots." WHERE account_id=".$account['account_id']);
// Delete the reseller home entry
$db->query( "DELETE FROM " . $table_prefix . "reseller_homes
WHERE home_id=" . $home_id);
echo "The amount of available slots available at the reseller account with ID ".$account['account_id']." has been updated,\r\nnow haves ".$update_available_slots." free slots.\r\n";
}
}
$reseller_accounts = $db->resultQuery( "SELECT * FROM OGP_DB_PREFIXreseller_accounts WHERE status>0" );
if (!is_array($reseller_accounts))
{
echo "Nothing to do at reseller accounts.\r\n";
}
else
{
$changes = FALSE;
foreach($reseller_accounts as $account)
{
$months_old_query = $db->resultQuery( "SELECT TIMESTAMPDIFF(MONTH,'".$account['payment_date']."',NOW());" );
$months_old = $months_old_query[0]["TIMESTAMPDIFF(MONTH,'".$account['payment_date']."',NOW())"];
if( $months_old > 0 )
{
$months = $account['invoice_duration'] == "month" ? 1 : 12;
$total_months = $months * $account['qty'];
$update_available_months = $total_months - $months_old;
if( $update_available_months <= 0 )
{
$db->query("UPDATE OGP_DB_PREFIXreseller_accounts SET available_months=".$update_available_months." WHERE account_id=".$account['account_id']);
$db->query("UPDATE OGP_DB_PREFIXreseller_accounts SET status=-1 WHERE account_id=".$account['account_id']);
echo "The reseller account with ID ".$account['account_id']." has expired (0 months available).\r\n";
$changes = TRUE;
}
else
{
if( $account['available_months'] != $update_available_months )
{
$db->query("UPDATE OGP_DB_PREFIXreseller_accounts SET available_months=".$update_available_months." WHERE account_id=".$account['account_id']);
echo "The amount of available months at reseller account ID ".$account['account_id']." has been updated,\r\n".$update_available_months." months remaining to expire.\r\n";
$changes = TRUE;
}
}
}
}
if( ! $changes )
{
echo "Nothing to do at reseller accounts.\r\n";
}
}
?>

View file

View file

@ -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.");
}
}
}
?>

102
Panel/modules/reseller/module.php Executable file
View file

@ -0,0 +1,102 @@
<?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 = "Reseller";
$module_version = "0.1";
$db_version = 0;
$module_required = FALSE;
$module_menus = array(
array( 'subpage' => 'rs_packs_shop', 'name'=>'Reseller Packs', 'group'=>'user' ),
array( 'subpage' => 'rs_accounts', 'name'=>'Reseller Accounts', 'group'=>'admin' ),
array( 'subpage' => 'rs_services', 'name'=>'Reseller Services', 'group'=>'admin' ),
array( 'subpage' => 'rs_settings', 'name'=>'Reseller Settings', 'group'=>'admin' )
);
$install_queries = array();
$install_queries[0] = array(
"DROP TABLE IF EXISTS `".OGP_DB_PREFIX."reseller_services`;",
"CREATE TABLE IF NOT EXISTS `".OGP_DB_PREFIX."reseller_services` (
`service_id` int(11) NOT NULL auto_increment,
`service_name` varchar(60) NOT NULL,
`slot_max_qty` int(11) NOT NULL,
`price_per_month` float(15,4) NOT NULL,
`price_per_year` float(15,4) NOT NULL,
`description` varchar(1000) NOT NULL,
`remote_server_id` int(11) NOT NULL,
`start_port` int(11) NOT NULL,
`end_port` int(11) NOT NULL,
`max_access_rights` varchar(255) NOT NULL,
PRIMARY KEY (`service_id`)
) ENGINE=MyISAM DEFAULT CHARSET=UTF8;",
"DROP TABLE IF EXISTS `".OGP_DB_PREFIX."reseller_accounts`;",
"CREATE TABLE IF NOT EXISTS `".OGP_DB_PREFIX."reseller_accounts` (
`account_id` int(11) NOT NULL auto_increment,
`service_id` int(11) NOT NULL,
`user_id` int(11) NOT NULL,
`qty` int(11) NULL,
`invoice_duration` varchar(7) NOT NULL,
`discount` int(11) NOT NULL,
`price` int(11) NOT NULL,
`payment_date` varchar(20) NOT NULL DEFAULT '0',
`cart_id` int(11) NOT NULL,
`status` varchar(16) NOT NULL DEFAULT '0',
`available_months` int(11) NOT NULL DEFAULT '0',
`available_slots` int(11) NOT NULL DEFAULT '0',
PRIMARY KEY (`account_id`)
) ENGINE=MyISAM DEFAULT CHARSET=UTF8;",
"DROP TABLE IF EXISTS `".OGP_DB_PREFIX."reseller_carts`;",
"CREATE TABLE IF NOT EXISTS `".OGP_DB_PREFIX."reseller_carts` (
`cart_id` int(11) NOT NULL auto_increment,
`user_id` int(11) NOT NULL,
`paid` int(11) NULL,
`tax_amount` varchar(20) NOT NULL DEFAULT '0',
`currency` varchar(3) NOT NULL DEFAULT '0',
PRIMARY KEY (`cart_id`)
) ENGINE=MyISAM DEFAULT CHARSET=UTF8;",
"DROP TABLE IF EXISTS `".OGP_DB_PREFIX."reseller_discount_codes`;",
"CREATE TABLE IF NOT EXISTS `".OGP_DB_PREFIX."reseller_discount_codes` (
`discount_id` int(11) NOT NULL auto_increment,
`service_id` int(11) NOT NULL,
`percentage` int(11) NOT NULL,
`description` varchar(255) NOT NULL DEFAULT '0',
`code` varchar(255) NOT NULL,
PRIMARY KEY (`discount_id`)
) ENGINE=MyISAM;",
"DROP TABLE IF EXISTS `".OGP_DB_PREFIX."reseller_homes`;",
"CREATE TABLE IF NOT EXISTS `".OGP_DB_PREFIX."reseller_homes` (
`home_id` int(11) NOT NULL,
`user_id` int(11) NOT NULL,
`account_id` int(11) NOT NULL,
`assigned_slots` int(11) NOT NULL,
`status` varchar(16) NOT NULL DEFAULT '0',
PRIMARY KEY (`home_id`)
) ENGINE=MyISAM;"
);
?>

View file

@ -0,0 +1,16 @@
<navigation>
<!-- User Side -->
<page key="rs_assign_server" file="assign_server.php" access="user,admin" />
<page key="rs_packs_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" />
<!-- Admin Side -->
<page key="rs_settings" file="settings.php" access="admin" />
<page key="rs_services" file="services.php" access="admin" />
<page key="rs_accounts" file="accounts.php" access="admin" />
<!-- Billing -->
<page key="account_details" file="account_details.php" access="user,admin" />
<page key="paid" file="paid.php" access="user,admin" />
<page key="bill" file="bill.php" access="user,admin" />
</navigation>

Binary file not shown.

Before

Width:  |  Height:  |  Size: 356 KiB

After

Width:  |  Height:  |  Size: 327 KiB

Before After
Before After

View file

@ -0,0 +1,166 @@
<?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();
$this_script = 'http://'.$_SERVER['HTTP_HOST'].$_SERVER['PHP_SELF'];
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=reseller&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'] ) )
{
if( $ipn['payment_status']=="Completed" OR $ipn['payment_status']=="Canceled_Reversal" )
{
$query = "UPDATE " . $table_prefix . "reseller_carts
SET paid=1
WHERE cart_id=".$ipn['item_number'];
$db->query($query);
$query = "UPDATE " . $table_prefix . "reseller_accounts
SET payment_date=NOW()
WHERE cart_id=".$ipn['item_number'];
$db->query($query);
$cart_accounts = $db->resultQuery("SELECT * FROM OGP_DB_PREFIXreseller_accounts WHERE cart_id=".$ipn['item_number']);
foreach ( $cart_accounts as $account )
{
$months = $account['invoice_duration'] == "month" ? 1 : 12;
$total_months = $months * $account['qty'];
$db->query("UPDATE OGP_DB_PREFIXreseller_accounts
SET available_months=".$total_months.
" WHERE account_id=".$account['account_id'] );
$db->query( "UPDATE OGP_DB_PREFIXreseller_accounts ".
"SET status=ADDDATE(DATE(NOW() + INTERVAL ".$total_months." MONTH), 1) ".
"WHERE account_id=".$account['account_id'] );
}
}
elseif( $ipn['payment_status']=="Pending" OR $ipn['payment_status']=="In-Progress" )
{
$query = "UPDATE " . $table_prefix . "reseller_carts
SET paid=2
WHERE cart_id=".$ipn['item_number'];
$db->query($query);
}
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 " . $table_prefix . "reseller_carts
SET paid=2
WHERE cart_id=".$ipn['item_number'];
$db->query($query);
$cart_accounts = $db->resultQuery("SELECT * FROM OGP_DB_PREFIXreseller_accounts WHERE cart_id=".$ipn['item_number']);
foreach ( $cart_accounts as $account )
{
$months = $account['invoice_duration'] == "month" ? 1 : 12;
$total_months = $months * $account['qty'];
$db->query("UPDATE OGP_DB_PREFIXreseller_accounts
SET available_months=0 ".
"WHERE account_id=".$account['account_id'] );
$db->query( "UPDATE OGP_DB_PREFIXreseller_accounts ".
"SET status=0 ".
"WHERE account_id=".$account['account_id'] );
}
}
$subject = "Payment ".$ipn['payment_status'];
mymail($to, $subject, $body, $panel_settings);
}
?>

18
Panel/modules/reseller/paid.php Executable file
View file

@ -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=reseller&p=cart'>";
}
?>

View file

@ -0,0 +1,277 @@
<?php
/*******************************************************************************
* PHP Paypal IPN Integration Class
*******************************************************************************
* Author: Micah Carrick
* Email: email@micahcarrick.com
* 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', 'somebody@domain.com');
* $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 __construct() {
// 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 "<center><br/><br/>If you are not automatically redirected to ";
echo "paypal within 5 seconds...<br/><br/>\n";
echo "<input type=\"submit\" value=\"Click Here\"></center>\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>";
}
}

View file

@ -0,0 +1,78 @@
<?php
function exec_ogp_module()
{
require('includes/config.inc.php');
global $db,$view;
$settings = $db->getSettings();
$cart_id = $_GET['cart_id'];
if(!empty($cart_id))
{
$accounts = $db->resultQuery( "SELECT * FROM OGP_DB_PREFIXreseller_accounts WHERE cart_id=".$cart_id );
$carts = $db->resultQuery( "SELECT * FROM OGP_DB_PREFIXreseller_carts WHERE cart_id=".$cart_id );
$cart = $carts[0];
if( !empty( $accounts ) )
{
$cart['price'] = 0;
foreach($accounts as $account)
{
if( $account['qty'] > 1 )
$account['invoice_duration'] = $account['invoice_duration']."s";
$cart['price'] += $account['price'];
if( !isset( $cart['name'] ) )
$cart['name'] = $account['qty'].get_lang($account['invoice_duration']).",".$account['available_slots'].get_lang('slots');
else
$cart['name'] .= ' + '.$account['qty'].get_lang($account['invoice_duration']).",".$account['available_slots'].get_lang('slots');
}
$total = $cart['price']+($cart['tax_amount']/100*$cart['price']);
if ($total === 0)
{
$db->query("UPDATE " . $table_prefix . "reseller_carts
SET paid=1
WHERE cart_id=".$cart_id);
$view->refresh("home.php?m=reseller&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')
$this_script = 'http://'.$_SERVER['HTTP_HOST'].$_SERVER['PHP_SELF'];
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=reseller&p=paid');
$p->add_field('cancel_return', $this_script.'?m=reseller&p=cart');
$p->add_field('notify_url', $current_folder_url.'modules/reseller/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('redirecting_to_paypal')."</h2>";
echo "<center><img style='border:4px dotted white;background:black' src='modules/addonsmanager/loading.gif' width='180' height='180' /img></center>";
$p->submit_paypal_post(); // submit the fields to paypal
//$p->dump_fields(); // for debugging, output a table of all the fields
}
}
}
}
?>

View file

@ -0,0 +1,50 @@
form table.center tr td{
width:50%;
width:50%;
}
table.center{
color:#333333;
clear:both;
width:100%;
height:35px;
margin-top:-6px;
padding-top:10px;
text-align: center;
color:#FFFF;
}
table.center tr td{
border:1px solid #cfcfcf;
background:#e5e5e5;
}
table.center th{
border:1px solid #cfcfcf;
background:#c5c5c5;
}
table.center tr.first_row td{
border:1px solid #cfcfcf;
background:#c5c5c5;
}
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";
color:black;
margin-left: auto;
margin-right: auto;
margin-top:20px;
margin-bottom:20px;
}

View file

@ -0,0 +1,30 @@
form table.center tr td{
width:50%;
width:50%;
}
table.center{
color:#333333;
clear:both;
width:100%;
height:35px;
margin-top:-6px;
padding-top:10px;
text-align: center;
color:#FFFF;
}
table.center tr td{
border:1px solid #cfcfcf;
background:#e5e5e5;
}
table.center th{
border:1px solid #cfcfcf;
background:#c5c5c5;
}
table.center tr.first_row td{
border:1px solid #cfcfcf;
background:#c5c5c5;
}

View file

@ -0,0 +1,30 @@
form table.center tr td{
width:50%;
width:50%;
}
table.center{
color:#333333;
clear:both;
width:100%;
height:35px;
margin-top:-6px;
padding-top:10px;
text-align: center;
color:#FFFF;
}
table.center tr td{
border:1px solid #cfcfcf;
background:#e5e5e5;
}
table.center th{
border:1px solid #cfcfcf;
background:#c5c5c5;
}
table.center tr.first_row td{
border:1px solid #cfcfcf;
background:#c5c5c5;
}

View file

@ -0,0 +1,395 @@
<style>
form table.center tr td{
width:50%;
width:50%;
}
table.center{
color:#333333;
clear:both;
width:100%;
height:35px;
margin-top:-6px;
padding-top:10px;
text-align: center;
color:#FFFF;
}
table.center tr td{
border:1px solid #cfcfcf;
background:#e5e5e5;
}
table.center th{
border:1px solid #cfcfcf;
background:#c5c5c5;
}
table.center tr.first_row td{
border:1px solid #cfcfcf;
background:#c5c5c5;
}
</style>
<?php
/*
*
* OGP - Open Game Panel
* Copyright (C) Copyright (C) 2008 - 2013 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 to sanitize values received from the form. Prevents SQL injection
function clean($str){
global $db;
$str = @trim($str);
if(get_magic_quotes_gpc())
{
$str = stripslashes($str);
}
return $db->real_escape_string($str);
}
function exec_ogp_module()
{
global $db;
//Querying UPDATE a service FROM DB
if (isset($_POST['service']) AND isset($_POST['edit_service']))
{
//Sanitize the POST values
$new_price_per_month = clean($_POST['new_price_per_month']);
$new_price_per_year = clean($_POST['new_price_per_year']);
$remote_server_id = clean($_POST['remote_server_id']);
$start_port = clean($_POST['start_port']);
$end_port = clean($_POST['end_port']);
$service = clean($_POST['service']);
$change_service_settings = "UPDATE OGP_DB_PREFIXreseller_services SET
price_per_month='".$new_price_per_month."',
price_per_year='".$new_price_per_year."',
remote_server_id='".$remote_server_id."',
start_port='".$start_port."',
end_port='".$end_port."'
WHERE service_id=".$service;
$db->query($change_service_settings);
}
//Querying INSERT new service INTO DB
if(isset($_POST['slot_max_qty']) AND isset($_POST['price_per_month']) AND isset($_POST['price_per_year']))
{
//Sanitize the POST values
$service_name = clean($_POST['service_name']);
$slot_max_qty = clean($_POST['slot_max_qty']);
$price_per_month = clean($_POST['price_per_month']);
$price_per_year = clean($_POST['price_per_year']);
$description = clean($_POST['description']);
$remote_server_id = clean($_POST['remote_server_id']);
$start_port = clean($_POST['start_port']);
$end_port = clean($_POST['end_port']);
$max_access_rights = "";
if(isset($_POST['allow_updates']))$max_access_rights .= clean($_POST['allow_updates']);
if(isset($_POST['allow_file_management']))$max_access_rights .= clean($_POST['allow_file_management']);
if(isset($_POST['allow_parameter_usage']))$max_access_rights .= clean($_POST['allow_parameter_usage']);
if(isset($_POST['allow_extra_params']))$max_access_rights .= clean($_POST['allow_extra_params']);
if(isset($_POST['allow_ftp_usage']))$max_access_rights .= clean($_POST['allow_ftp_usage']);
$qry_add_service = "INSERT INTO OGP_DB_PREFIXreseller_services(service_id,
service_name,
slot_max_qty ,
price_per_month,
price_per_year,
description,
remote_server_id,
start_port,
end_port,
max_access_rights) VALUES(NULL, '".$service_name.
"', '".$slot_max_qty.
"', '".$price_per_month.
"', '".$price_per_year.
"', '".$description.
"', '".$remote_server_id.
"', '".$start_port.
"', '".$end_port.
"', '".$max_access_rights."')";
$db->query($qry_add_service);
}
//Querying DELETE service FROM DB
if (isset($_POST['remove_service']) AND isset($_POST['service_id']))
{
$db->query( "DELETE FROM OGP_DB_PREFIXreseller_services WHERE service_id=" . $_POST['service_id'] );
$db->query( "DELETE FROM OGP_DB_PREFIXreseller_discount_codes WHERE service_id=" . $_POST['service_id'] );
}
if( isset( $_POST['add_discount_code'] ) )
{
//Sanitize the POST values
$service_id = clean($_POST['service_id']);
echo $service_id;
$percentage = clean($_POST['percentage']);
$description = clean($_POST['description']);
$code = clean($_POST['code']);
$add_code = "INSERT INTO OGP_DB_PREFIXreseller_discount_codes(discount_id, service_id, percentage, description, code) VALUES(NULL, '".$service_id."', '".$percentage."', '".$description."', '".$code."')";
$db->query($add_code);
}
if (isset($_POST['remove_code']) AND isset($_POST['discount_id']))
{
$db->query( "DELETE FROM OGP_DB_PREFIXreseller_discount_codes WHERE discount_id=" . $_POST['discount_id'] );
}
global $settings;
?>
<h2><?php print_lang('add_service');?></h2>
<form method="POST" action="">
<table class="center">
<tr>
<td align=right><?php print_lang('service_name');?></td>
<td align=left><input name="service_name" type="text" size="60" value="100 Slot Pack"/></td>
</tr>
<tr>
<td align=right><?php print_lang('max_slot_qty');?></td>
<td align=left><input name="slot_max_qty" type="text" size="8" value="100"/><?php print_lang('slots');?></td>
</tr>
<tr>
<td align=right><?php print_lang('price_per_month');?></td>
<td align=left><input name="price_per_month" type="text" size="8" value="0"/><?php if(isset($settings['currency']))echo $settings['currency'];?></td>
</tr>
<tr>
<td align=right><?php print_lang('price_per_year');?></td>
<td align=left><input name="price_per_year" type="text" size="8" value="0"/><?php if(isset($settings['currency']))echo $settings['currency'];?></td>
</tr>
<tr>
<td align=right><?php print_lang('description');?></td>
<td align=left><textarea name='description' cols='45' rows='5'></textarea></td>
</tr>
<tr>
<td align=right><?php print_lang('remote_server');?></td>
<td align=left>
<select name="remote_server_id">
<?php
$remote_servers = $db->getRemoteServers();
foreach ( $remote_servers as $server )
{
echo "<option value='".$server['remote_server_id']."'>".
$server['remote_server_name']." (".$server['agent_ip'].")</option>\n";
}
?>
</select>
</td>
</tr>
<tr>
<td align=right><?php print_lang('ports_range');?></td>
<td align=left>
<input name="start_port" type="text" size="10" value="27000"/> -
<input name="end_port" type="text" size="10" value="27300"/>
</td>
</tr>
<tr>
<td align=right><?php print_lang('max_access_rights');?></td>
<td align=left>
<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');?>
</td>
</tr>
<tr>
<td colspan=2><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_PREFIXreseller_services");
if ($services > 0)
{
?>
<h2><?php print_lang('reseller_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('ports_range');?></th>
<th><?php print_lang('price_per_month');?></th>
<th><?php print_lang('price_per_year');?></th>
</tr>
<?php
foreach($services as $row)
{
?>
<tr class="tr<?php $i = 0; echo($i++%2);?>">
<td style="width:10px;"><b class="failure" ><?php echo $row['service_id'];?></b></td>
<td><?php echo $row['service_name'];?></td>
<form method="post" action="">
<td align=left>
<select name="remote_server_id">
<?php
$remote_servers = $db->getRemoteServers();
foreach ( $remote_servers as $server )
{
$selected = $server['remote_server_id'] == $row['remote_server_id'] ? "selected='selected'":"";
echo "<option value='".$server['remote_server_id']."' $selected >".
$server['remote_server_name']." (".$server['agent_ip'].")</option>\n";
}
?>
</select>
</td>
<input name="service" type="hidden" value="<?php echo $row['service_id'];?>"/>
<input name="edit_service" type="hidden" />
<td style="width:15%;" ><input name="start_port" type="text" value="<?php echo $row['start_port'];?>" size="6"/><input name="end_port" type="text" value="<?php echo $row['end_port'];?>" size="6"/></td>
<td style="width:15%;" ><input name="new_price_per_month" type="text" value="<?php echo $row['price_per_month'];?>" size="6"/><?php if(isset($settings['currency']))echo $settings['currency'];?></td>
<td style="width:15%;" ><input name="new_price_per_year" type="text" value="<?php echo $row['price_per_year'];?>" size="6"/><?php if(isset($settings['currency']))echo $settings['currency'];?></td>
<td><input type="submit" value="<?php print_lang('edit');?>"/></td>
</form>
</tr>
<?php
}
?>
</tr>
</table>
<br>
<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
}
?>
</select>
<input type="submit" name="remove_service" value="<?php print_lang('remove_service');?>"/>
</form>
</td>
</tr>
</tr>
</table>
<br>
<h2><?php print_lang('add_discount');?></h2>
<form method="POST" action="">
<table class="center">
<tr>
<td align=right><?php print_lang('discount_name');?></td>
<td align=left><input name="description" type="text" size="60" value="10% off at all orders"/></td>
</tr>
<tr>
<td align=right><?php print_lang('applies_to');?></td>
<td align=left>
<select name="service_id">
<option value="0"><?php print_lang('all_services');?></option>
<?php
foreach($services as $service)
{
?>
<option value="<?php echo $service['service_id'];?>"><?php echo $service['service_name'];?></option>
<?php
}
?>
</select>
</td>
</tr>
<tr>
<td align=right><?php print_lang('percentage');?></td>
<td align=left><input name="percentage" type="text" size="8" value="10"/>%</td>
</tr>
<tr>
<td align=right><?php print_lang('code');?></td>
<td align=left><input type=text name='code' size='50' value="<?php echo genRandomString('8'); ?>" /></td>
</tr>
<tr>
<td colspan=2><input type="submit" name="add_discount_code" value="<?php print_lang('add_discount_code');?>"/></td>
</tr>
</table>
</form>
<br>
<?php
$discount_codes = $db->resultQuery("SELECT * FROM OGP_DB_PREFIXreseller_discount_codes");
if ($discount_codes > 0)
{
?>
<h2><?php print_lang('reseller_discount_codes');?></h2>
<table class="center" style='text-align:center;'>
<tr>
<th><?php print_lang('description');?></th>
<th><?php print_lang('percentage');?></th>
<th><?php print_lang('code');?></th>
<th><?php print_lang('applies_to');?></th>
</tr>
<?php
foreach($discount_codes as $row)
{
if( $row['service_id'] != "0" )
{
$service = $db->resultQuery("SELECT service_name FROM OGP_DB_PREFIXreseller_services WHERE service_id=".$row['service_id']);
$service_name = $service[0]['service_name'];
}
else
{
$service_name = get_lang('all_services');
}
?>
<tr class="tr<?php $i = 0; echo($i++%2);?>">
<td style="width:50%;"><b class="failure" ><?php echo $row['description'];?></b></td>
<td style="width:10%;"><?php echo $row['percentage'];?>%</td>
<td style="width:10%;"><?php echo $row['code'];?></td>
<td><?php echo $service_name;?></td>
</tr>
<?php
}
?>
</tr>
</table>
<br>
<table class="center">
<tr>
<tr>
<td>
<form action="" method="post">
<select name="discount_id">
<?php
foreach($discount_codes as $code)
{
?>
<option value="<?php echo $code['discount_id'];?>"><?php echo $code['description'];?></option>
<?php
}
?>
<input type="submit" name="remove_code" value="<?php print_lang('remove_code');?>"/>
</form>
</td>
</tr>
</tr>
</table>
<br>
<?php
}
}
}
?>

View file

@ -0,0 +1,83 @@
<?php
function exec_ogp_module()
{
require_once('includes/form_table_class.php');
global $db,$view,$settings;
$currencies = Array (
0 => "EUR",
1 => "USD",
2 => "AUD",
3 => "BRL",
4 => "CAD",
5 => "CZK",
6 => "DKK",
8 => "HKD",
9 => "HUF",
10 => "ILS",
11 => "JPY",
12 => "MYR",
13 => "MXN",
14 => "NOK",
15 => "NZD",
16 => "PHP",
17 => "PLN",
18 => "GBP",
19 => "SGD",
20 => "SEK",
21 => "CHF",
22 => "TWD",
23 => "THB",
24 => "TRY"
);
$settings = $db->getSettings();
$settings['currency'] = isset($settings['currency']) ? $settings['currency'] : "EUR";
$settings['price_per_month'] = isset($settings['price_per_month']) ? $settings['price_per_month'] : 1;
$settings['price_per_year'] = isset($settings['price_per_year']) ? $settings['price_per_year'] : 1;
$settings['tax_amount'] = isset($settings['tax_amount']) ? $settings['tax_amount'] : 21;
$settings['paypal_email'] = isset($settings['paypal_email']) ? $settings['paypal_email'] : "Business@E-mail";
function checked($value){
global $settings;
if( $settings[$value] == 1 )
return 'checked="checked"';
}
if ( isset($_REQUEST['update_settings']) )
{
$settings = array("currency" => $_REQUEST['currency'],
"price_per_month" => @$_REQUEST['price_per_month'],
"price_per_year" => @$_REQUEST['price_per_year'],
"tax_amount" => $_REQUEST['tax_amount'],
"paypal_email" => $_REQUEST['paypal_email']);
$db->setSettings($settings);
print_success(get_lang('settings_updated'));
$view->refresh("?m=reseller&p=rs_settings");
return;
}
echo "<h2>".get_lang('reseller_settings')."</h2>";
$ft = new FormTable();
$ft->start_form("?m=reseller&p=rs_settings");
echo "<h4>".get_lang('currency')."</h4>";
$ft->start_table();
$ft->add_custom_field('currency',
create_drop_box_from_array($currencies,"currency",$settings['currency']));
$ft->end_table();
echo "<h4>".get_lang('available_invoice_types')."</h4>";
$ft->start_table();
$ft->add_custom_field('price_per_month','<input type="checkbox" name="price_per_month" value="1" '.checked('price_per_month').'/>');
$ft->add_custom_field('price_per_year','<input type="checkbox" name="price_per_year" value="1" '.checked('price_per_year').'/>');
$ft->end_table();
echo "<h4>".get_lang('tax_amount')."</h4>";
$ft->start_table();
$ft->add_field('string','tax_amount',$settings['tax_amount'],2);
$ft->end_table();
echo "<h4>".get_lang('paypal_email')."</h4>";
$ft->start_table();
$ft->add_field('string','paypal_email',$settings['paypal_email'],35);
$ft->end_table();
$ft->add_button("submit","update_settings",get_lang('update_settings'));
$ft->end_form();
}
?>

234
Panel/modules/reseller/shop.php Executable file
View file

@ -0,0 +1,234 @@
<?php
/*
*
* OGP - Open Game Panel
* Copyright (C) Copyright (C) 2008 - 2013 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 to sanitize values received from the form. Prevents SQL injection
function clean($str){
global $db;
$str = @trim($str);
if(get_magic_quotes_gpc())
{
$str = stripslashes($str);
}
return $db->real_escape_string($str);
}
function exec_ogp_module()
{
global $db, $settings;
if(!isset($settings['price_per_month']) and !isset($settings['price_per_year']))
{
print_failure("Configure the reseller settings");
return;
}
if(isset($settings['price_per_month']) and $settings['price_per_month'] == 0 and isset($settings['price_per_year']) and $settings['price_per_year'] == 0)
{
print_failure("Atleast one invoice type must be checked in the reseller settings.");
return;
}
if (isset($_POST['save']) AND !empty($_POST['description']))
{
$new_description = clean($_POST['description']);
$service = clean($_POST['service_id']);
$change_description = "UPDATE OGP_DB_PREFIXreseller_services
SET description ='".$new_description."'
WHERE service_id=".$service;
$save = $db->query($change_description);
}
?>
<table class="center">
<tr>
<td>
<a href="?m=reseller&p=cart"><img SRC="images/cart.png" BORDER="0" WIDTH=22 HEIGHT=20/><?php print_lang('your_cart');?></a>
</td>
<td>
<a href="?m=reseller&p=rs_assign_server"><b>[+]</b><?php print_lang('rs_assign_servers');?></a>
</td>
</tr>
<tr>
<td colspan=2>
<?php
echo date('d-m-Y');
?>
</td>
</tr>
<tr>
<td colspan=2>
<?php
echo date('H:i');
?>
</td>
</tr>
</table>
<?php
// Shop Form
$isAdmin = $db->isAdmin($_SESSION['user_id'] );
if(isset($_REQUEST['service_id'])) $where_service_id = " WHERE service_id=".$_REQUEST['service_id']; else $where_service_id = "";
$qry_services = "SELECT * FROM OGP_DB_PREFIXreseller_services".$where_service_id;
$services = $db->resultQuery($qry_services);
if(empty($services))
{
if($isAdmin)
{
?>
<a href="?m=reseller&p=rs_services"><?php print_lang('add_some_services'); ?></a>
<?php
}
return;
}
foreach ($services as $key => $row) {
$service_id[$key] = $row['service_id'];
$slot_max_qty[$key] = $row['slot_max_qty'];
$price_per_month[$key] = $row['price_per_month'];
$price_per_year[$key] = $row['price_per_year'];
$description[$key] = $row['description'];
$max_access_rights[$key] = $row['max_access_rights'];
}
array_multisort($service_id,
$slot_max_qty,
$price_per_month,
$price_per_year,
$description,
$max_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="modules/reseller/pack_image.png" width=280 height=132 border=0 alt="Bad Image" onsubmit="submit-form();" value="More Info" />
<center><b><?php echo $row['service_name'];?></b></center>
<?php
if( isset( $settings['price_per_month'] ) and $settings['price_per_month'] == 1 )
{
?>
<center><em style="text-align:center;background-color:orange;color:blue;"><?php echo "<b>" .
floatval(round(($row['price_per_month']),2 )) . "</b>&nbsp;" . $settings['currency'] . "/" . get_lang('month') ;?></em></center>
<?php
}
if( isset( $settings['price_per_year'] ) and $settings['price_per_year'] == 1 )
{
?>
<center><em style="text-align:center;background-color:orange;color:blue;"><?php echo "<b>" .
floatval(round(($row['price_per_year']),2 )) . "</b>&nbsp;" . $settings['currency'] . "/" . get_lang('year') ;?></em></center>
<?php
}
?>
</form>
</div>
<?php
} else
{
?>
<div style="float:left; border: 4px solid transparent;border-bottom: 25px solid transparent;">
<img src="modules/reseller/pack_image.png" width=280 height=132 border=0 alt="Bad Image">
<center><b><?php echo $row['service_name']."</b></center>";
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' >$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=reseller&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">
<?php echo $row['service_name'];?>
</td>
<tr>
<td align="right"><?php print_lang('discount_code');?> ::</td>
<td align="left">
<input type="text" name="code" size="15" value="">
</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['price_per_month'] == 1) echo '<option value="month">'.get_lang('months').'</option>';
if( $settings['price_per_year'] == 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=reseller&p=rs_packs_shop" method="POST">
<button><< <?php print_lang('back_to_list');?></button>
</form>
</td>
</tr>
</table>
<?php
}
}
?>
</div>
<?php
}
?>