readpoint.php 2.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  1. <?php
  2. defined('IN_PHPCMS') or exit('No permission resources.');
  3. class readpoint {
  4. public $userid,$username;
  5. function __construct() {
  6. $this->userid = param::get_cookie('_userid');
  7. if(!$this->userid) {
  8. header("Location: index.php?m=member&c=index&a=login&forward=".urlencode(get_url()));
  9. exit;
  10. }
  11. $this->username = param::get_cookie('_username');
  12. }
  13. public function init() {
  14. $allow_visitor = new_html_special_chars($_GET['allow_visitor']);
  15. $auth = sys_auth($allow_visitor,'DECODE');
  16. if(strpos($auth,'|')===false) showmessage(L('illegal_operation'));
  17. $auth_str = explode('|', $auth);
  18. $flag = $auth_str[0];
  19. if(!preg_match('/^([0-9]+)|([0-9]+)/', $flag)) showmessage(L('illegal_operation'));
  20. $readpoint = intval($auth_str[1]);
  21. $paytype = intval($auth_str[2]);
  22. $http_referer = urldecode($_GET['http_referer']);
  23. if(!$readpoint) showmessage(L('illegal_operation'));
  24. pc_base::load_app_class('spend','pay',0);
  25. $flag_arr = explode('_', $flag);
  26. $catid = $flag_arr[0];
  27. $siteids = getcache('category_content','commons');
  28. $siteid = $siteids[$catid];
  29. $CATEGORYS = getcache('category_content_'.$siteid,'commons');
  30. if(isset($CATEGORYS[$catid])) {
  31. $setting = string2array($CATEGORYS[$catid]['setting']);
  32. $repeatchargedays = intval($setting['repeatchargedays']);
  33. if($repeatchargedays) {
  34. $fromtime = SYS_TIME - 86400 * $repeatchargedays;
  35. $r = spend::spend_time($this->userid,$fromtime,$flag);
  36. if($r) showmessage(L('have_pay'),$http_referer,1000);
  37. }
  38. }
  39. if($paytype) {
  40. if(spend::amount($readpoint, L('msg_readpoint'), $this->userid, $this->username, '', '', $flag)==false) {
  41. $msg = spend::get_msg();
  42. $http_referer = APP_PATH.'index.php?m=pay&c=deposit&a=pay';
  43. } else {
  44. $msg = L('readpoint_pay',array('readpoint'=>$readpoint));
  45. }
  46. } else {
  47. if(spend::point($readpoint, L('msg_readpoint'), $this->userid, $this->username, '', '', $flag)==false) {
  48. $msg = spend::get_msg();
  49. $http_referer = APP_PATH.'index.php?m=pay&c=deposit&a=pay';
  50. } else {
  51. $msg = L('readpoint_pay_point',array('readpoint'=>$readpoint));
  52. }
  53. }
  54. showmessage($msg,$http_referer,3000);
  55. }
  56. }
  57. ?>