credit.php
1.51 KB
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
<?php
/*
[UCenter] (C)2001-2099 Comsenz Inc.
This is NOT a freeware, use is subject to license terms
$Id: credit.php 1059 2011-03-01 07:25:09Z monkey $
*/
!defined('IN_UC') && exit('Access Denied');
class creditcontrol extends base {
function __construct() {
$this->creditcontrol();
}
function creditcontrol() {
parent::__construct();
$this->init_input();
$this->load('note');
$this->load('misc');
}
function onrequest() {
$uid = intval($this->input('uid'));
$from = intval($this->input('from'));
$to = intval($this->input('to'));
$toappid = intval($this->input('toappid'));
$amount = intval($this->input('amount'));
$status = 0;
$this->settings['creditexchange'] = @unserialize($this->settings['creditexchange']);
if(isset($this->settings['creditexchange'][$this->app['appid'].'_'.$from.'_'.$toappid.'_'.$to])) {
$toapp = $app = $this->cache['apps'][$toappid];
$apifilename = isset($toapp['apifilename']) && $toapp['apifilename'] ? $toapp['apifilename'] : 'uc.php';
if($toapp['extra']['apppath'] && @include $toapp['extra']['apppath'].'./api/'.$apifilename) {
$uc_note = new uc_note();
$status = $uc_note->updatecredit(array('uid' => $uid, 'credit' => $to, 'amount' => $amount), '');
} else {
$url = $_ENV['note']->get_url_code('updatecredit', "uid=$uid&credit=$to&amount=$amount", $toappid);
$status = trim($_ENV['misc']->dfopen($url, 0, '', '', 1, $toapp['ip'], UC_NOTE_TIMEOUT));
}
}
echo $status ? 1 : 0;
exit;
}
}
?>