Skip to content

Commit

Permalink
Merge pull request #2 from kleeja-official/new-features
Browse files Browse the repository at this point in the history
give a developer more access to mage integration between thier plugins an KJP
  • Loading branch information
MitanOmar authored Jun 27, 2019
2 parents ddfff0e + d31e579 commit 7f3ae06
Show file tree
Hide file tree
Showing 11 changed files with 248 additions and 254 deletions.
67 changes: 3 additions & 64 deletions html/admin/archive_data.html
Original file line number Diff line number Diff line change
Expand Up @@ -9,70 +9,9 @@
<div class="card-body">

<div class="row">
<div class="col-sm-12 mb-2">
<div class="card">
<div class="card-header">
<div class="d-flex justify-content-between p-1">
<div>
{olang.KJP_ALL_TRNC}
<span class="badge badge-secondary badge-pill">{archive_trnc_count}</span>
</div>
</div>
<p class="m-0"><small class="muted">{olang.KJP_TRNC_CP_INFO}</small></p>
</div>
<ul class="list-group list-group-flush">
<LOOP NAME="archive_panel_1">
<li class="list-group-item d-flex justify-content-between align-items-center">
{{methodName}}
<span class="badge badge-secondary">{{htmlContent}}</span>
</li>
</LOOP>
</ul>
</div>
</div>


<div class="col-sm-6 mb-2">
<div class="card">
<div class="card-header">
<div class="d-flex justify-content-between p-1">
<div>
{olang.KJP_FILE_TRNCS}
<span class="badge badge-secondary badge-pill">{archive_file_trnc}</span>
</div>
</div>
</div>
<ul class="list-group list-group-flush">
<LOOP NAME="archive_panel_2_1">
<li class="list-group-item d-flex justify-content-between align-items-center">
{{methodName}}
<span class="badge badge-secondary">{{htmlContent}}</span>
</li>
</LOOP>
</ul>
</div>
</div>

<div class="col-sm-6 mb-2">
<div class="card">
<div class="card-header">
<div class="d-flex justify-content-between p-1">
<div>
{olang.KJP_GRP_TRNCS}
<span class="badge badge-secondary badge-pill">{archive_group_trnc}</span>
</div>
</div>
</div>
<ul class="list-group list-group-flush">
<LOOP NAME="archive_panel_2_2">
<li class="list-group-item d-flex justify-content-between align-items-center">
{{methodName}}
<span class="badge badge-secondary">{{htmlContent}}</span>
</li>
</LOOP>
</ul>
</div>
</div>
<LOOP NAME="archiveTables">
{{html}}
</LOOP>
</div>

<hr class="my-4">
Expand Down
18 changes: 18 additions & 0 deletions html/admin/help.html
Original file line number Diff line number Diff line change
Expand Up @@ -278,6 +278,24 @@ <h2 class="mb-0">
</div>
</div>

<LOOP NAME="KJP_HELP">
<div class="card mb-1">
<div class="card-header" id="{{ID}}_1">
<h2 class="mb-0">
<button class="btn btn-link" type="button" data-toggle="collapse" data-target="#{{ID}}_2"
aria-expanded="true" aria-controls="{{ID}}_2">
{{TITLE}}
</button>
</h2>
</div>
<div id="{{ID}}_2" class="collapse" aria-labelledby="{{ID}}_1" data-parent="#accordionHelpList">
<div class="card-body">
{{CONTENT}}
</div>
</div>
</div>
</LOOP>


</div>
</div>
2 changes: 1 addition & 1 deletion html/pay_card.html
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

</div>
<div class="card-body" style="margin: 15px;">
<h5 class="card-title">{payAction} : {itemName}</h5>
<h5 class="card-title">{payAction}</h5>

<p> {olang.KJP_NOTE_4_BYR} </p>

Expand Down
19 changes: 10 additions & 9 deletions init.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?php
// kleeja plugin
// developer: Mitan Omar
// developer: KLEEJA TEAM

// prevent illegal run
if (! defined('IN_PLUGINS_SYSTEM'))
Expand All @@ -18,7 +18,7 @@
// who wrote this plugin?
'plugin_developer' => 'Kleeja Team',
// this plugin version
'plugin_version' => '1.1',
'plugin_version' => '1.2.1',
// explain what is this plugin, why should i use it?
'plugin_description' => [
'en' => 'Selling Files and Premium Groups',
Expand All @@ -30,7 +30,7 @@
// max version of kleeja that support this plugin, use 0 for unlimited
'plugin_kleeja_version_max' => '3.9',
// should this plugin run before others?, 0 is normal, and higher number has high priority
'plugin_priority' => 0 ,
'plugin_priority' => 10 , // only for define support_kjPay
// setting page to display in plugins page
'settings_page' => 'cp=options&smt=kleeja_payment'
];
Expand Down Expand Up @@ -346,7 +346,7 @@
} ,

'err_navig_download_page' => function($args) {
global $config, $SQL, $dbprefix, $lang , $tpl , $THIS_STYLE_PATH_ABS;
global $config, $SQL, $dbprefix, $olang, $lang , $tpl , $THIS_STYLE_PATH_ABS;

if (ig('file') && (int) g('file'))
{
Expand All @@ -358,7 +358,7 @@
foreach (getPaymentMethods() as $value)
{
$value = trim($value);
$payment_methods[$value] = ['name' => strtoupper($value) , 'method' => $value];
$payment_methods[$value] = ['name' => $olang['KJP_MTHD_NAME_' . strtoupper($value)] , 'method' => $value];
}

if (ip('buy_file'))
Expand Down Expand Up @@ -484,6 +484,7 @@
exit;
}


$PAY->CreatePayment('buy_file', $fileInfo);

// get some vars for kleeja # compact(':)')
Expand Down Expand Up @@ -660,7 +661,7 @@
{
$value = trim($value);

$MethodOption .= "<option value='{$value}'>" . strtoupper($value) . "</option>\n";
$MethodOption .= "<option value='{$value}'>" . $olang['KJP_MTHD_NAME_' . strtoupper($value)] . "</option>\n";
// loop inside loop doesn't work in kleeja styles
}

Expand Down Expand Up @@ -692,7 +693,7 @@

$payCookieInfoExplode = explode('_', $payCookieInfo);

$fileName = getFileInfo($payCookieInfoExplode[0])['real_filename'];
$fileName = getFileInfo($payCookieInfoExplode[0])['name'];


if (ip('sendMail'))
Expand Down Expand Up @@ -1129,7 +1130,7 @@
{
$payments[] = [
'ID' => $row['id'],
'METHOD' => $row['payment_method'],
'METHOD' => $olang['KJP_MTHD_NAME_' . strtoupper($row['payment_method'])],
'FILE_NAME' => $row['item_name'],
'BUYER' => ! empty($UserById[$row['user']]) ? $UserById[$row['user']] : 'Guest',
'DATE_TIME' => "{$row['payment_year']}-{$row['payment_month']}-{$row['payment_day']} / {$row['payment_time']}",
Expand All @@ -1154,7 +1155,7 @@
{ // no be sure that every user will change hes files only
$show_price_panel = true;
$FileID = $file_info['id'];
$FileName = $file_info['real_filename'];
$FileName = $file_info['name'];
$FileSize = readable_size($file_info['size']);
$FileUser = $usrcp->name();
$FilePrice = $file_info['price'];
Expand Down
12 changes: 10 additions & 2 deletions language/ar.php
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,7 @@
'KJP_PAY_TKN' => 'رمز الدفع',
'KJP_VIW_TPL_PAYPAL_PAYER_MAIL' => 'بريد المشتري',
'KJP_PAY_ITM' => 'العنصر',
'KJP_FILE_PAYMNT' => 'كل عمليات الدفع للملف',
'KJP_GRP_PAYMNT' => 'كل دفعات الانضمام للمجموعة',
'KJP_PAY_OF' => 'كل عمليات %s',
'KJP_USR_PAYMNT' => 'جميع عمليات الدفع للمستخدم',
'KJP_IP_PAYMNT' => 'جميع عمليات الدفع للزائر',
'KJP_PRC_FILE' => 'تسعير ملف',
Expand Down Expand Up @@ -155,4 +154,13 @@
'KJP_POUT_ARCH' => 'أرشيف عمليات السحب',
'MIN_PAYOUT_LIMIT' => 'الحد الأدنى لسحب الربح',
'KJP_MIN_POUT_LMT' => 'الحد الأدنى لسحب الربح %u %s',

'KJP_ACT_BUY_FILE' => 'شراء الملف %s' ,
'KJP_ACT_JOIN_GROUP' => 'الانضمام إلى المجموعة %s' ,
'KJP_ARCH_TBL_NAME' => 'مدفوعات %s' ,
'KJP_ACT_ARCH_JOIN_GROUP' => 'الانضمام إلى المجموعة' ,
'KJP_ACT_ARCH_BUY_FILE' => 'شراء الملف' ,
'KJP_MTHD_NAME_CARDS' => 'سترايب ( بطاقات فيزا و ماستر )' ,
'KJP_MTHD_NAME_PAYPAL' => 'باي بال' ,
'KJP_MTHD_NAME_BALANCE' => 'رصيد حساب' ,
];
15 changes: 13 additions & 2 deletions language/en.php
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,7 @@
'KJP_PAY_AMNT' => 'Amount',
'KJP_PAY_TKN' => 'Payment Token',
'KJP_PAY_ITM' => 'Item',
'KJP_FILE_PAYMNT' => 'All payments of file',
'KJP_GRP_PAYMNT' => 'All payments of joining group',
'KJP_PAY_OF' => 'All payments of %s',
'KJP_USR_PAYMNT' => 'All payments of user',
'KJP_IP_PAYMNT' => 'All payments of an IP (non-user)',
'KJP_PRC_FILE' => 'Pricing a file',
Expand Down Expand Up @@ -157,4 +156,16 @@
'KJP_POUT_ARCH' => 'Archive Payouts',
'MIN_PAYOUT_LIMIT' => 'Min Withdrawal Limit',
'KJP_MIN_POUT_LMT' => 'The Min Withdrawal Limit is %u %s',
// for actions & archives
'KJP_ACT_BUY_FILE' => 'Purchasing File %s' ,
'KJP_ACT_JOIN_GROUP' => 'Joining Group %s' ,
'KJP_ACT_NAME_BUY_FILE' => 'Purchasing File %s' ,
'KJP_ACT_NAME_JOIN_GROUP' => 'Joining Group %s' ,
'KJP_ARCH_TBL_NAME' => 'Payments Of %s' ,
'KJP_ACT_ARCH_JOIN_GROUP' => 'Joining Group' ,
'KJP_ACT_ARCH_BUY_FILE' => 'Buying Files' ,
'KJP_MTHD_NAME_CARDS' => 'Stripe (visa , master)' ,
'KJP_MTHD_NAME_PAYPAL' => 'PayPal' ,
'KJP_MTHD_NAME_BALANCE' => 'Balance' ,
'KJP_ALL_PAY_OF' => 'All payments of %s' ,
];
49 changes: 36 additions & 13 deletions method/balance.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@ class kjPayMethod_balance implements KJPaymentMethod

public function paymentStart()
{
global $lang , $config;

if (! user_can('recaive_profits'))
{
/**
Expand All @@ -18,7 +20,7 @@ public function paymentStart()
* anyway , the Guest don't have this permission
* if the user have this permission , that mean it's able for hem to use the balance
*/
kleeja_err('member area');
kleeja_err($lang['USER_PLACE']);

exit;
}
Expand All @@ -45,19 +47,19 @@ public function CreatePayment($do, $info)
[
'payment_action' => $do ,
'item_id' => g('id') ,
'item_name' => $do === 'buy_file' ? $info['real_filename'] : $info['name'] ,
'item_name' => $info['name'] ,
];

$kjFormKeyGet = kleeja_add_form_key_get('payFor_' . $do . ($do === 'buy_file' ? $info['real_filename'] . $info['id'] : $info['name'] . $info['id']));
$kjFormKeyPost = kleeja_add_form_key('payFor_' . $do . ($do === 'buy_file' ? $info['real_filename'] . $info['id'] : $info['name'] . $info['id']));
$kjFormKeyGet = kleeja_add_form_key_get('payFor_' . $do . $info['name'] . $info['id']);
$kjFormKeyPost = kleeja_add_form_key('payFor_' . $do . $info['name'] . $info['id']);

$this->varsForCreate['no_request'] = false;
$this->varsForCreate['titlee'] = 'Pay By Balance';
$this->varsForCreate['stylee'] = 'pay_balance';
$this->varsForCreate['styleePath'] = file_exists($THIS_STYLE_PATH_ABS . 'kj_payment/pay_balance.html') ? $THIS_STYLE_PATH_ABS . 'kj_payment/' : dirname(__FILE__) . '/../html/';
$this->varsForCreate['FormAction'] = $config['siteurl'] . 'go.php?go=kj_payment&method=balance&action=check&' . $kjFormKeyGet;
$this->varsForCreate['itemName'] = $do === 'buy_file' ? $info['real_filename'] : $info['name'];
$this->varsForCreate['payAction'] = $do === 'buy_file' ? $olang['KJP_BUY_FILE'] : $olang['KJP_JUNG_GRP'];
$this->varsForCreate['itemName'] = $info['name'];
$this->varsForCreate['payAction'] = sprintf($olang['KJP_ACT_' . strtoupper($do)], $info['name']);
$this->varsForCreate['paymentCurrency'] = $this->currency;
$this->varsForCreate['itemPrice'] = $info['price'] . ' ' . $this->currency;
$this->varsForCreate['kjFormKeyPost'] = $kjFormKeyPost;
Expand All @@ -76,12 +78,12 @@ public function checkPayment()
if (! $usrcp->name())
{
// to be sure 100% , thats we are on the right way
kleeja_err($lang['USER_PLACE']);
kleeja_err($lang['USER_PLACE'], '', true, $config['siteurl']);
}
// is he comming from our page
elseif (! isset($_SESSION['kj_payment']) || empty($_SESSION['kj_payment']))
{
kleeja_err('What Are U Doing Here ??');
kleeja_err('What Are U Doing Here ??', '', true, $config['siteurl']);

exit;
}
Expand All @@ -94,21 +96,23 @@ public function checkPayment()
exit;
}
// really really , check if the item is exists
elseif (($_SESSION['kj_payment']['payment_action'] == 'buy_file') && ! $fileinfo = getFileInfo($_SESSION['kj_payment']['item_id']))
elseif (($_SESSION['kj_payment']['payment_action'] == 'buy_file') && ! $itemInfo = getFileInfo($_SESSION['kj_payment']['item_id']))
{
kleeja_err($olang['KJP_FL_NT_FUND']);

exit;
}
elseif (($_SESSION['kj_payment']['payment_action'] == 'join_group') && ! $groupinfo = getGroupInfo($d_groups, $_SESSION['kj_payment']['item_id']))
elseif (($_SESSION['kj_payment']['payment_action'] == 'join_group') && ! $itemInfo = getGroupInfo($d_groups, $_SESSION['kj_payment']['item_id']))
{
kleeja_err($olang['KJP_GP_NT_FUND']);

exit;
}
//export here $itemInfo
is_array($plugin_run_result = Plugins::getInstance()->run('KjPay:itemInfoExport_' . $_SESSION['kj_payment']['payment_action'], get_defined_vars())) ? extract($plugin_run_result) : null; //run hook

// no Error , let's check if the user have this amount in hes balance or not
$itemPrice = $_SESSION['kj_payment']['payment_action'] == 'buy_file' ? $fileinfo['price'] : $groupinfo['price'];
$itemPrice = $itemInfo['price'];

if ($itemPrice <= 0)
{
Expand All @@ -121,7 +125,9 @@ public function checkPayment()
if ($itemPrice > $userBalance)
{
// son , collect some money , then come to buy
kleeja_err($olang['KJP_NO_BLNC']);
kleeja_err($olang['KJP_NO_BLNC'], '', true, $config['siteurl']);

exit;
}

// i will take the money from you , then i will give you the item loooool
Expand All @@ -135,7 +141,7 @@ public function checkPayment()
$payment_currency = $this->currency;
$payment_action = $_SESSION['kj_payment']['payment_action'];
$payment_token = createToken();
$payment_amount = $_SESSION['kj_payment']['payment_action'] === 'buy_file' ? $fileinfo['price'] : $groupinfo['price'];
$payment_amount = $itemInfo['price'];
$payment_payer_ip = get_ip();
$item_id = $_SESSION['kj_payment']['item_id'];
$item_name = $_SESSION['kj_payment']['item_name'];
Expand All @@ -154,10 +160,12 @@ public function checkPayment()
$SQL->build($insert_query);
$_SESSION['kj_payment']['db_id'] = $SQL->insert_id();
$_SESSION['kj_payment']['payment_token'] = $payment_token;
$foundedAction = false;

// if the payment is for joining a group and the payer is in login and member in kleeja
if ($_SESSION['kj_payment']['payment_action'] == 'join_group' && $usrcp->name())
{
$foundedAction = true;
$this->toGlobal['groupName'] = $_SESSION['kj_payment']['item_name'];
$update_user = [
'UPDATE' => "{$dbprefix}users",
Expand All @@ -169,6 +177,7 @@ public function checkPayment()
}
elseif ($_SESSION['kj_payment']['payment_action'] == 'buy_file')
{
$foundedAction = true;
$this->downloadLinkMailer = $usrcp->mail();
$this->toGlobal['down_link'] = $config['siteurl'] . 'do.php?downPaidFile=' . $_SESSION['kj_payment']['item_id'] . '_' . $_SESSION['kj_payment']['db_id'] . '_' . $_SESSION['kj_payment']['payment_token'];
$this->toGlobal['file_name'] = $_SESSION['kj_payment']['item_name'];
Expand All @@ -181,6 +190,20 @@ public function checkPayment()
$SQL->query("UPDATE {$dbprefix}users SET `balance` = balance+{$user_profits} WHERE id = {$user_id}");
}
}

if (! $foundedAction)
{
$toGlobal = [];
//export here $toGlobal and do what u want
is_array($plugin_run_result = Plugins::getInstance()->run('KjPay:notFoundedAction_' . $_SESSION['kj_payment']['payment_action'], get_defined_vars())) ? extract($plugin_run_result) : null; //run hook
if (count($toGlobal) !== 0)
{
foreach ($toGlobal as $key => $value)
{
$this->toGlobal[$key] = $value;
}
}
}
// now we can say that the payment made successfuly
$this->successPayment = true;
}
Expand Down
Loading

0 comments on commit 7f3ae06

Please sign in to comment.