forked from SynapseTechnologies/BuckysRoom
-
Notifications
You must be signed in to change notification settings - Fork 0
/
credits.php
executable file
·62 lines (46 loc) · 2.03 KB
/
credits.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
<?php
require(dirname(__FILE__) . '/includes/bootstrap.php');
//Getting Current User ID
if( !buckys_check_user_acl(USER_ACL_REGISTERED) )
{
buckys_redirect('/index.php', MSG_PERMISSION_DENIED, MSG_TYPE_ERROR);
}
if(isset($_POST['action']) && $_POST['action'] == 'get-users')
{
$users = BuckysUser::searchUsers($_REQUEST['term'], $userID);
$result = array();
foreach($users as $row)
{
$result[] = array("id" => $row['userID'], 'label' => $row['fullName'], 'value' => $row['fullName'], 'hash' => buckys_encrypt_id($row['userID']));
}
echo json_encode( $result );
buckys_exit();
}
if(isset($_POST['action']) && $_POST['action'] == 'send-money')
{
if(!isset($_POST['receiverID']) || !isset($_POST['receiverIDHash']) || !isset($_POST['amount']) || !buckys_check_id_encrypted($_POST['receiverID'], $_POST['receiverIDHash']))
{
buckys_redirect('/credits.php', MSG_INVALID_REQUEST, MSG_TYPE_ERROR);
}
$result = BuckysTransaction::sendCredits($_POST['receiverID'], $_POST['amount']);
if($result === true){
buckys_redirect('/credits.php', MSG_SENT_CREDITS_SUCCESSFULLY);
}else{
buckys_redirect('/credits.php', $result, MSG_TYPE_ERROR);
}
exit;
}
$page = isset($_GET['page']) ? $_GET['page'] : 1;
$totalCount = BuckysTransaction::getNumOfCreditActivities($userID);
//Init Pagination Class
$pagination = new Pagination($totalCount, BuckysTransaction::$COUNT_PER_PAGE, $page);
$page = $pagination->getCurrentPage();
$activities = BuckysTransaction::getCreditActivities($BUCKYS_GLOBALS['user']['userID'], $page);
buckys_enqueue_stylesheet('account.css');
buckys_enqueue_stylesheet('credits.css');
buckys_enqueue_javascript('credits.js');
buckys_enqueue_javascript('payment.js');
$BUCKYS_GLOBALS['content'] = 'credits';
$BUCKYS_GLOBALS['title'] = "Credits - BuckysRoom";
$BUCKYS_GLOBALS['payerID'] = $userID;
require(DIR_FS_TEMPLATE . $BUCKYS_GLOBALS['template'] . "/" . $BUCKYS_GLOBALS['layout'] . ".php");