Exemple #1
0
 public function getUrl(PwPayVo $vo)
 {
     $strTransactionId = $vo->getOrderNo();
     $strBillDate = substr($strTransactionId, 10, 8);
     $strSpBillNo = substr($strTransactionId, -10);
     $param = array('cmdno' => '1', 'date' => $strBillDate, 'bargainor_id' => $this->tenpay, 'transaction_id' => $strTransactionId, 'sp_billno' => $strSpBillNo, 'total_fee' => $vo->getFee() * 100, 'bank_type' => 0, 'fee_type' => 1, 'return_url' => $this->baseurl, 'attach' => 'my_magic_string', 'desc' => Pw::convert($vo->getTitle(), 'gbk'));
     return $this->_bulidUrl($this->tenpay_url, $this->tenpay_key, $param);
 }
Exemple #2
0
 private static function _convert($text = '')
 {
     return Pw::convert($text, 'UTF-8');
     /*if ($text !== utf8_decode(utf8_encode($text))) {
     			$text = WindConvert::convert($text, 'UTF-8', 'GBK');
     		}
     		return $text;*/
 }
 /**
  * 发送短信
  *
  * @return bool
  */
 public function sendMobileMessage($mobile, $content)
 {
     $content = Pw::convert($content, 'UTF-8');
     $url = PwApplicationHelper::acloudUrl(array('a' => 'forward', 'do' => 'sendSms', 'mobile' => $mobile, 'content' => $content));
     $info = PwApplicationHelper::requestAcloudData($url);
     if (!is_array($info)) {
         return new PwError('APPCENTER:center.connect.fail');
     }
     if ($info['code'] !== '0') {
         return new PwError($info['msg']);
     }
     return true;
 }
Exemple #4
0
 /**
  * 根据所给 IP 地址或域名返回所在地区信息
  *
  * @param string $ip
  * @return string
  */
 public function getIpFromWry($ip)
 {
     $unknowIp = "Unknown";
     if (!$this->_fp) {
         return $unknowIp;
     }
     $ip = $this->packip($ip);
     // 二分法搜索索引区间
     $l = 0;
     $u = $this->_totalip;
     $findip = $this->_lastip;
     while ($l <= $u) {
         $i = floor(($l + $u) / 2);
         fseek($this->_fp, $this->_firstip + $i * 7);
         $beginip = strrev(fread($this->_fp, 4));
         if ($ip < $beginip) {
             $u = $i - 1;
         } else {
             fseek($this->_fp, $this->getlong3());
             $endip = strrev(fread($this->_fp, 4));
             if ($ip > $endip) {
                 $l = $i + 1;
             } else {
                 $findip = $this->_firstip + $i * 7;
                 break;
             }
         }
     }
     //获取查找到的IP地址
     fseek($this->_fp, $findip);
     $location['beginip'] = long2ip($this->getlong());
     $offset = $this->getlong3();
     fseek($this->_fp, $offset);
     $location['endip'] = long2ip($this->getlong());
     $byte = fread($this->_fp, 1);
     switch (ord($byte)) {
         case 1:
             $countryOffset = $this->getlong3();
             fseek($this->_fp, $countryOffset);
             $byte = fread($this->_fp, 1);
             switch (ord($byte)) {
                 case 2:
                     fseek($this->_fp, $this->getlong3());
                     $country = $this->getstring();
                     fseek($this->_fp, $countryOffset + 4);
                     $area = $this->getarea();
                     break;
                 default:
                     $country = $this->getstring($byte);
                     $area = $this->getarea();
                     break;
             }
             break;
         case 2:
             fseek($this->_fp, $this->getlong3());
             $country = $this->getstring();
             fseek($this->_fp, $offset + 8);
             $area = $this->getarea();
             break;
         default:
             $country = $this->getstring($byte);
             $area = $this->getarea();
             break;
     }
     if ($country == " CZ88.NET") {
         $country = $unknowIp;
     }
     if ($area == " CZ88.NET") {
         $area = "";
     }
     return Pw::convert($country . $area, 'GBK');
 }
 public function downloadAction()
 {
     $aid = (int) $this->getInput('aid', 'get');
     $submit = (int) $this->getInput('submit', 'post');
     $attach = Wekit::load('attach.PwThreadAttach')->getAttach($aid);
     if (!$attach) {
         $this->showError('BBS:thread.buy.attach.error');
     }
     Wind::import('SRV:forum.bo.PwForumBo');
     $forum = new PwForumBo($attach['fid']);
     if (!$forum->isForum()) {
         $this->showError('data.error');
     }
     if ($attach['cost'] && !$this->loginUser->isExists()) {
         $this->showError('download.fail.login.not', 'bbs/attach/download');
     }
     if (!$forum->allowDownload($this->loginUser)) {
         if (!$this->loginUser->isExists()) {
             $this->showError('download.fail.login.not', 'bbs/attach/download');
         }
         $this->showError(array('BBS:forum.permissions.download.allow', array('{grouptitle}' => $this->loginUser->getGroupInfo('name'))));
     }
     if (!$forum->foruminfo['allow_download'] && !$this->loginUser->getPermission('allow_download')) {
         if (!$this->loginUser->isExists()) {
             $this->showError('download.fail.login.not', 'bbs/attach/download');
         }
         $this->showError(array('permission.download.allow', array('{grouptitle}' => $this->loginUser->getGroupInfo('name'))));
     }
     Wind::import('SRV:credit.bo.PwCreditBo');
     $creditBo = PwCreditBo::getInstance();
     // 购买积分检查
     if (($attach = $this->_checkAttachCost($attach)) instanceof PwError) {
         $this->showError($attach->getError());
     }
     // 下载积分检查
     if (($reduceDownload = $this->_checkAttachDownload('download_att', $attach, $forum)) instanceof PwError) {
         $this->showError($reduceDownload->getError());
     }
     //下载积分提示
     $lang = Wind::getComponent('i18n');
     if (1 == $this->loginUser->getPermission('allow_download') && $reduceDownload && $attach['cost']) {
         $dataShow = $lang->getMessage('BBS:thread.attachbuy.message.all', array('{buyCount}' => -$attach['cost'] . $creditBo->cType[$attach['ctype']], '{downCount}' => rtrim($reduceDownload, ',')));
     } elseif (1 == $this->loginUser->getPermission('allow_download') && $reduceDownload && !$attach['cost']) {
         $dataShow = $lang->getMessage('BBS:thread.attachbuy.message.download', array('{downCount}' => rtrim($reduceDownload, ',')));
     } elseif ($attach['cost']) {
         $dataShow = $lang->getMessage('BBS:thread.attachbuy.message.buy', array('{count}' => $this->loginUser->getCredit($attach['ctype']) . $creditBo->cType[$attach['ctype']], '{buyCount}' => -$attach['cost'] . $creditBo->cType[$attach['ctype']]));
     } else {
         $dataShow = $lang->getMessage('BBS:thread.attachbuy.message.success');
     }
     !$submit && $this->showMessage($dataShow);
     //购买积分操作
     $this->_operateBuyCredit($attach);
     // 下载积分
     if ($reduceDownload) {
         Wind::import('SRV:attach.dm.PwThreadAttachBuyDm');
         $dm = new PwThreadAttachBuyDm();
         $dm->setAid($aid)->setCreatedUserid($this->loginUser->uid)->setCreatedTime(Pw::getTime())->setCtype($attach['ctype'])->setCost($attach['cost']);
         Wekit::load('attach.PwThreadAttachDownload')->add($dm);
         $this->_operateCredit('download_att', $forum);
     }
     //更新附件点击数
     Wind::import('SRV:attach.dm.PwThreadAttachDm');
     $dm = new PwThreadAttachDm($aid);
     $dm->addHits(1);
     Wekit::load('attach.PwThreadAttach')->updateAttach($dm);
     $filename = basename($attach['path']);
     $fileext = substr(strrchr($attach['path'], '.'), 1);
     $filesize = 0;
     if (strpos(Wind::getApp()->getRequest()->getServer('HTTP_USER_AGENT'), 'MSIE') !== false && $fileext == 'torrent') {
         $attachment = 'inline';
     } else {
         $attachment = 'attachment';
     }
     $attach['name'] = trim(str_replace('&nbsp;', ' ', $attach['name']));
     if (strtoupper(Wekit::V('charset')) == 'UTF-8') {
         $attach['name'] = Pw::convert($attach['name'], "gbk", 'utf-8');
     }
     $filesize = 0;
     $fgeturl = Wind::getComponent('storage')->getDownloadUrl($attach['path']);
     if (strpos($fgeturl, 'http') !== 0) {
         if (!is_readable($fgeturl)) {
             $this->showError('BBS:thread.buy.attach.error');
         }
         $filesize = filesize($fgeturl);
     }
     $timestamp = Pw::getTime();
     $ctype = '';
     switch ($fileext) {
         case "pdf":
             $ctype = "application/pdf";
             break;
         case "rar":
         case "zip":
             $ctype = "application/zip";
             break;
         case "doc":
             $ctype = "application/msword";
             break;
         case "xls":
             $ctype = "application/vnd.ms-excel";
             break;
         case "ppt":
             $ctype = "application/vnd.ms-powerpoint";
             break;
         case "gif":
             $ctype = "image/gif";
             break;
         case "png":
             $ctype = "image/png";
             break;
         case "jpeg":
         case "jpg":
             $ctype = "image/jpeg";
             break;
         case "wav":
             $ctype = "audio/x-wav";
             break;
         case "mpeg":
         case "mpg":
         case "mpe":
             $ctype = "video/x-mpeg";
             break;
         case "mov":
             $ctype = "video/quicktime";
             break;
         case "avi":
             $ctype = "video/x-msvideo";
             break;
         case "txt":
             $ctype = "text/plain";
             break;
         default:
             $ctype = "application/octet-stream";
     }
     ob_end_clean();
     header('Last-Modified: ' . gmdate('D, d M Y H:i:s', $timestamp + 86400) . ' GMT');
     header('Expires: ' . gmdate('D, d M Y H:i:s', $timestamp + 86400) . ' GMT');
     header('Cache-control: max-age=86400');
     header('Content-Encoding: none');
     header("Content-Disposition: {$attachment}; filename=\"{$attach['name']}\"");
     header("Content-type: {$ctype}");
     header("Content-Transfer-Encoding: binary");
     $filesize && header("Content-Length: {$filesize}");
     $i = 1;
     while (!@readfile($fgeturl)) {
         if (++$i > 3) {
             break;
         }
     }
     exit;
 }
 public function setUrl($url)
 {
     $this->_data['url'] = Pw::convert(trim($url), Wind::getApp()->getResponse()->getCharset(), 'UTF-8');
     return $this;
 }
 /**
  * 更新session
  */
 protected function updateSession($user_id, $nick, $type)
 {
     $sessionId = Pw::getCookie($this->_getLoginSessionService()->getCookieName());
     $bindInfo = $this->_getAccountBindDs()->getByAppUidAndType($user_id, $type);
     $isBound = $bindInfo ? 1 : 0;
     $bbsUid = intval($bindInfo['uid']) ? intval($bindInfo['uid']) : 0;
     if ($type != 'alipay') {
         $nick = Pw::convert(trim($nick), Wind::getApp()->getResponse()->getCharset(), 'UTF-8');
     }
     $data = array('data' => array('nick' => $nick, 'user_id' => $user_id, 'isBound' => $isBound, 'bbs_uid' => $bbsUid, 'sign' => $this->getSignSting()));
     $this->_getLoginSessionService()->updateLoginSession($sessionId, $data);
 }
 public function setNick($nick)
 {
     $this->_data['nick'] = Pw::convert(trim($nick), Wind::getApp()->getResponse()->getCharset(), 'UTF-8');
     return $this;
 }
 public function setGender($gender)
 {
     $this->_data['gender'] = Pw::convert(trim($gender), Wind::getApp()->getResponse()->getCharset(), 'UTF-8');
     return $this;
 }