Esempio n. 1
0
 public function init()
 {
     $allow_visitor = htmlspecialchars($_GET['allow_visitor']);
     $auth = sys_auth($allow_visitor, 'DECODE');
     if (strpos($auth, '|') === false) {
         showmessage(L('illegal_operation'));
     }
     $auth_str = explode('|', $auth);
     $flag = $auth_str[0];
     if (!preg_match('/^([0-9]+)|([0-9]+)/', $flag)) {
         showmessage(L('illegal_operation'));
     }
     $readpoint = intval($auth_str[1]);
     $paytype = intval($auth_str[2]);
     $http_referer = urldecode($_GET['http_referer']);
     if (!$readpoint) {
         showmessage(L('illegal_operation'));
     }
     pc_base::load_app_class('spend', 'pay', 0);
     $flag_arr = explode('_', $flag);
     $catid = $flag_arr[0];
     $siteids = getcache('category_content', 'commons');
     $siteid = $siteids[$catid];
     $CATEGORYS = getcache('category_content_' . $siteid, 'commons');
     if (isset($CATEGORYS[$catid])) {
         $setting = string2array($CATEGORYS[$catid]['setting']);
         $repeatchargedays = intval($setting['repeatchargedays']);
         if ($repeatchargedays) {
             $fromtime = SYS_TIME - 86400 * $repeatchargedays;
             $r = spend::spend_time($this->userid, $fromtime, $flag);
             if ($r) {
                 showmessage(L('have_pay'), $http_referer, 1000);
             }
         }
     }
     if ($paytype) {
         if (spend::amount($readpoint, L('msg_readpoint'), $this->userid, $this->username, '', '', $flag) == false) {
             $msg = spend::get_msg();
             $http_referer = APP_PATH . 'index.php?m=pay&c=deposit&a=pay';
         } else {
             $msg = L('readpoint_pay', array('readpoint' => $readpoint));
         }
     } else {
         if (spend::point($readpoint, L('msg_readpoint'), $this->userid, $this->username, '', '', $flag) == false) {
             $msg = spend::get_msg();
             $http_referer = APP_PATH . 'index.php?m=pay&c=deposit&a=pay';
         } else {
             $msg = L('readpoint_pay_point', array('readpoint' => $readpoint));
         }
     }
     showmessage($msg, $http_referer, 3000);
 }
Esempio n. 2
0
 function info_top_cost()
 {
     $amount = $msg = '';
     $memberinfo = $this->memberinfo;
     $_username = $this->memberinfo['username'];
     $_userid = $this->memberinfo['userid'];
     $infos = getcache('info_setting', 'commons');
     $toptype_arr = array(1, 2, 3);
     //置顶积分数组
     $toptype_price = array('1' => $infos['top_city'], '2' => $infos['top_zone'], '3' => $infos['top_district']);
     //置顶推荐位数组
     $toptype_posid = array('1' => $infos['top_city_posid'], '2' => $infos['top_zone_posid'], '3' => $infos['top_district_posid']);
     if (isset($_POST['dosubmit'])) {
         $posids = array();
         $push_api = pc_base::load_app_class('push_api', 'admin');
         $pos_data = pc_base::load_model('position_data_model');
         $catid = intval($_POST['catid']);
         $id = intval($_POST['id']);
         $flag = $catid . '_' . $id;
         $toptime = intval($_POST['toptime']);
         if ($toptime == 0 || empty($_POST['toptype'])) {
             showmessage(L('info_top_not_setting_toptime'));
         }
         //计算置顶扣费积分,时间
         if (is_array($_POST['toptype']) && !empty($_POST['toptype'])) {
             foreach ($_POST['toptype'] as $r) {
                 if (is_numeric($r) && in_array($r, $toptype_arr)) {
                     $posids[] = $toptype_posid[$r];
                     $amount += $toptype_price[$r];
                     $msg .= $r . '-';
                 }
             }
         }
         //应付总积分
         $amount = $amount * $toptime;
         //扣除置顶点数
         pc_base::load_app_class('spend', 'pay', 0);
         $pay_status = spend::point($amount, L('info_top') . $msg, $_userid, $_username, '', '', $flag);
         if ($pay_status == false) {
             $msg = spend::get_msg();
             showmessage($msg);
         }
         //置顶过期时间
         //TODO
         $expiration = SYS_TIME + $toptime * 3600;
         //获取置顶文章信息内容
         if (isset($catid) && $catid) {
             $siteids = getcache('category_content', 'commons');
             $siteid = $siteids[$catid];
             $CATEGORYS = getcache('category_content_' . $siteid, 'commons');
             $category = $CATEGORYS[$catid];
             if ($category['type'] == 0) {
                 $modelid = $category['modelid'];
                 $this->model = getcache('model', 'commons');
                 $this->content_db = pc_base::load_model('content_model');
                 $this->content_db->set_model($modelid);
                 $this->content_db->table_name = $this->content_db->db_tablepre . $this->model[$modelid]['tablename'];
                 $r = $this->content_db->get_one(array('id' => $id, 'username' => $_username, 'sysadd' => 0));
             }
         }
         if (!$r) {
             showmessage(L('illegal_operation'));
         }
         $push_api->position_update($id, $modelid, $catid, $posids, $r, $expiration, 1);
         $refer = $_POST['msg'] ? $r['url'] : '';
         if ($_POST['msg']) {
             showmessage(L('ding_success'), $refer);
         } else {
             showmessage(L('ding_success'), '', '', 'top');
         }
     } else {
         $toptype = trim($_POST['toptype']);
         $toptime = trim($_POST['toptime']);
         $types = explode('_', $toptype);
         if (is_array($types) && !empty($types)) {
             foreach ($types as $r) {
                 if (is_numeric($r) && in_array($r, $toptype_arr)) {
                     $amount += $toptype_price[$r];
                 }
             }
         }
         $amount = $amount * $toptime;
         echo $amount;
     }
 }