credit.php 1.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  1. <?php
  2. /*
  3. [UCenter] (C)2001-2099 Comsenz Inc.
  4. This is NOT a freeware, use is subject to license terms
  5. $Id: credit.php 1059 2011-03-01 07:25:09Z monkey $
  6. */
  7. !defined('IN_UC') && exit('Access Denied');
  8. class creditcontrol extends base {
  9. function __construct() {
  10. $this->creditcontrol();
  11. }
  12. function creditcontrol() {
  13. parent::__construct();
  14. $this->init_input();
  15. $this->load('note');
  16. $this->load('misc');
  17. }
  18. function onrequest() {
  19. $uid = intval($this->input('uid'));
  20. $from = intval($this->input('from'));
  21. $to = intval($this->input('to'));
  22. $toappid = intval($this->input('toappid'));
  23. $amount = intval($this->input('amount'));
  24. $status = 0;
  25. $this->settings['creditexchange'] = @unserialize($this->settings['creditexchange']);
  26. if(isset($this->settings['creditexchange'][$this->app['appid'].'_'.$from.'_'.$toappid.'_'.$to])) {
  27. $toapp = $app = $this->cache['apps'][$toappid];
  28. $apifilename = isset($toapp['apifilename']) && $toapp['apifilename'] ? $toapp['apifilename'] : 'uc.php';
  29. if($toapp['extra']['apppath'] && @include $toapp['extra']['apppath'].'./api/'.$apifilename) {
  30. $uc_note = new uc_note();
  31. $status = $uc_note->updatecredit(array('uid' => $uid, 'credit' => $to, 'amount' => $amount), '');
  32. } else {
  33. $url = $_ENV['note']->get_url_code('updatecredit', "uid=$uid&credit=$to&amount=$amount", $toappid);
  34. $status = trim($_ENV['misc']->dfopen($url, 0, '', '', 1, $toapp['ip'], UC_NOTE_TIMEOUT));
  35. }
  36. }
  37. echo $status ? 1 : 0;
  38. exit;
  39. }
  40. }
  41. ?>