Ejemplo n.º 1
0
 function delete($ids)
 {
     $p = array('ids' => $ids);
     $rets = $this->get($p);
     if (!$rets) {
         return 0;
     }
     $ret = 1;
     foreach ($rets['list'] as $r) {
         $id = $r['id'];
         if ($r['site_url']) {
             $ftpkey = getftpkey($r['site_url']);
             ftpcmd('delete', $r['url'], '', $ftp_key);
         } else {
             jio()->DeleteFile(topic_attach($id));
         }
         $ret = $ret && DB::query("delete from " . DB::table($this->table) . " where `id`='{$id}'");
         if ($r['tid'] > 0) {
             $this->set_topic_attachid($r['tid']);
         }
     }
     return $ret;
 }
Ejemplo n.º 2
0
 function Download()
 {
     global $_J;
     $attach_config = jconf::get('attach');
     $uid = MEMBER_ID;
     if ($uid < 1) {
         $this->Messager("请先<a href='index.php?mod=login'>点此登录</a>或者<a href='index.php?mod=member'>点此注册</a>一个帐号", 'index.php?mod=login');
     }
     $candown = jclass('member')->HasPermission('uploadattach', 'down');
     if (!$candown) {
         $this->Messager("您没有下载附件的权限", null);
     }
     $readmod = 2;
     $downfile = get_param('downfile');
     if (!$downfile) {
         $this->Messager("您的下载链接地址错误", null);
     }
     @(list($dasize, $daid, $datime, $dadown) = explode('|', base64_decode($downfile)));
     $daid = (int) $daid;
     if ($daid <= 0) {
         $this->Messager("您的下载链接地址错误", null);
     }
     $down_attach_file = $this->AttachLogic->get_down_info($daid);
     if (empty($down_attach_file)) {
         $this->Messager("您的下载链接地址错误", null);
     }
     if ($dadown != $down_attach_file['download']) {
         defined('NEDU_MOYO') || $this->Messager("您的下载链接地址已经过期或失效!或您使用的是<font class='R'>360浏览器</font>,因其系统缺陷,请更换其它浏览器进行下载!", null);
     }
     $MIMETypes = array('doc' => 'application/msword', 'ppt' => 'application/vnd.ms-powerpoint', 'pdf' => 'application/pdf', 'xls' => 'application/vnd.ms-excel', 'txt' => 'text/plain', 'rar' => 'application/octet-stream', 'zip' => 'application/zip', 'docx' => 'application/vnd.openxmlformats-officedocument.wordprocessingml.document', 'xlsx' => 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet', 'pptx' => 'application/vnd.openxmlformats-officedocument.presentationml.presentation');
     $de_attach_file_type = explode('|', $this->Config['attach_file_type']);
     foreach ($de_attach_file_type as $val) {
         if (!isset($MIMETypes[$val])) {
             $MIMETypes[$val] = 'application/octet-stream';
         }
     }
     if (!isset($MIMETypes[$down_attach_file['filetype']])) {
         $this->Messager("您只能下载(" . strtoupper(str_replace('|', ',', $this->Config['attach_file_type'])) . ")类型的文件", null);
     }
     if (!$down_attach_file['file'] || empty($down_attach_file['site_url']) && !(file_exists($down_attach_file['file']) && is_readable($down_attach_file['file']))) {
         $this->Messager("在服务器上找不到您要下载的文件,或文件不可读,或被删除,或数据错误,请联系网站管理员", null);
     }
     $auid = $down_attach_file['uid'];
     $score = $down_attach_file['score'];
     $this->AttachLogic->mod_download_num($daid);
     if ($score > 0) {
         if (!in_array($_J['member']['role_id'], explode(',', $attach_config['no_score_user']))) {
             update_credits_by_action('attach_down', $uid, 1, -$score);
         }
         if ($auid != $uid) {
             update_credits_by_action('down_my_attach', $auid, 1, $score);
         }
     }
     if ($down_attach_file['site_url']) {
         $ftptype = getftptype($down_attach_file['site_url']);
         if ($ftptype == 'Aliyun') {
             $ftpkey = getftpkey($down_attach_file['site_url']);
             $ftps = jconf::get('ftp');
             if ($ftps[$ftpkey]['type'] == 'Aliyun') {
                 define('ALI_LOG', FALSE);
                 define('ALI_DISPLAY_LOG', FALSE);
                 define('ALI_LANG', 'zh');
                 define('OSS_ACCESS_ID', $ftps[$ftpkey]['username']);
                 define('OSS_ACCESS_KEY', $ftps[$ftpkey]['password']);
                 define('OSS_BUCKET', $ftps[$ftpkey]['attachdir']);
                 define('OSS_HOST_NAME', $ftps[$ftpkey]['host']);
                 define('OSS_HOST_PORT', $ftps[$ftpkey]['port']);
                 define('OSS_SIGN_TIMEOUT', $ftps[$ftpkey]['timeout']);
                 define('OSS_ENABLED', $ftps[$ftpkey]['on']);
                 $oss = jclass('jishigou/oss');
                 $file = str_replace('./', '', $down_attach_file['file']);
                 $filename = urlencode(array_iconv($this->Config['charset'], 'UTF-8', $down_attach_file['name']));
                 $res = $oss->sign_url($file . '?response-content-disposition=attachment; filename=' . $filename, str_replace('http:/' . '/', '', $down_attach_file['site_url']));
                 $res = str_replace("?OSSAccessKeyId", "&OSSAccessKeyId", $res);
                 $res = str_replace("%3F", "?", $res);
                 $res = str_replace("disposition%3Dattachment", "disposition=attachment", $res);
                 header('location:' . $res);
             }
         } else {
             $fileurl = $down_attach_file['site_url'] . '/' . str_replace('./', '', $down_attach_file['file']);
             $this->Messager("文件存储在外部地址或FTP空间,正在跳转,请稍侯......", $fileurl);
         }
     } else {
         $fileType = $MIMETypes[$down_attach_file['filetype']];
         $down_attach_file['name'] = '"' . (strtolower(str_replace('-', '', $this->Config['charset'])) == 'utf8' && strexists($_SERVER['HTTP_USER_AGENT'], 'MSIE') ? urlencode($down_attach_file['name']) : $down_attach_file['name']) . '"';
         ob_end_clean();
         ob_start();
         header('Cache-control: max-age=31536000');
         header('Expires: ' . gmdate('D, d M Y H:i:s', time() + 31536000) . ' GMT');
         header('Content-Encoding: none');
         header('Content-type: ' . $fileType);
         header('Content-Disposition: attachment; filename=' . $down_attach_file['name']);
         header('Content-Length: ' . filesize($down_attach_file['file']));
         if ($readmod == 1 || $readmod == 3) {
             if ($fp = @fopen($down_attach_file['file'], 'rb')) {
                 @fseek($fp, 0);
                 if (function_exists('fpassthru') && $readmod == 3) {
                     @fpassthru($fp);
                 } else {
                     echo @fread($fp, filesize($down_attach_file['file']));
                 }
             }
             @fclose($fp);
         } else {
             @readfile($down_attach_file['file']);
         }
         @flush();
         @ob_flush();
     }
 }
Ejemplo n.º 3
0
 function doVerify()
 {
     $act = $this->Get['act'];
     $uids = array();
     $uid = (int) $this->Get['uid'];
     $uids = $this->Post['uids'];
     if ($uid) {
         $uids[$uid] = $uid;
     }
     $msg = jget('msg');
     if ($act == 'yes') {
         if ($uids) {
             foreach ($uids as $uid) {
                 if ($uid < 1) {
                     continue;
                 }
                 $message = '';
                 $nickname = DB::result_first(" select `nickname` from `" . TABLE_PREFIX . "members` where `uid` = '{$uid}'");
                 $query = $this->DatabaseHandler->Query("select * from " . TABLE_PREFIX . "members_verify where `uid` = '{$uid}'");
                 $member_verify = $query->GetRow();
                 if ($member_verify) {
                     if ($member_verify['face'] || $member_verify['face_url']) {
                         $image_path = RELATIVE_ROOT_PATH . 'images/face/' . face_path($uid);
                         if (!is_dir($image_path)) {
                             jio()->MakeDir($image_path);
                         }
                         $image_file_b = $dst_file = $image_path . $uid . '_b.jpg';
                         $image_file_s = $dst_file = $image_path . $uid . '_s.jpg';
                         $image_verify_path = RELATIVE_ROOT_PATH . 'images/face_verify/' . face_path($uid);
                         $image_verify_file_b = $dst_file = $image_verify_path . $uid . '_b.jpg';
                         $image_verify_file_s = $dst_file = $image_verify_path . $uid . '_s.jpg';
                         if ($member_verify['face_url']) {
                             $ftp_key = getftpkey($member_verify['face_url']);
                             if ($ftp_key < 0) {
                                 $this->Messager('请检查FTP是否可用');
                             }
                             ftpcmd('get', $image_file_b, $image_verify_file_b, $ftp_key);
                             ftpcmd('get', $image_file_s, $image_verify_file_s, $ftp_key);
                             $ftp_result = ftpcmd('upload', $image_file_b, '', $ftp_key);
                             $ftp_result = ftpcmd('upload', $image_file_s, '', $ftp_key);
                             $sql = "update `" . TABLE_PREFIX . "members` set `face`='{$image_file_s}', `face_url`='{$member_verify['face_url']}' where `uid`='" . $uid . "'";
                             $this->DatabaseHandler->Query($sql);
                         } else {
                             if ($member_verify['face']) {
                                 @copy($image_verify_file_b, $image_file_b);
                                 @copy($image_verify_file_s, $image_file_s);
                                 $sql = "update `" . TABLE_PREFIX . "members` set `face`='{$image_file_s}' where `uid`='" . $uid . "'";
                                 $this->DatabaseHandler->Query($sql);
                             }
                         }
                         if ($this->Config['extcredits_enable'] && $member_verify['uid'] > 0) {
                             update_credits_by_action('face', $member_verify['uid']);
                         }
                         $message .= '你更新的头像已经通过审核,可以通过ctrl+f5强制刷新来查看新头像;';
                     }
                     if ($member_verify["signature"]) {
                         $sql = "update " . TABLE_PREFIX . "members set signature = '{$member_verify['signature']}',signtime = '" . time() . "' where uid = '{$uid}' ";
                         $this->DatabaseHandler->Query($sql);
                         $message .= '你更新的签名已经更过审核;';
                     }
                     $this->DatabaseHandler->Query("delete from " . TABLE_PREFIX . "members_verify where uid = '{$uid}'");
                     $pm_post = array('message' => $message, 'to_user' => $nickname);
                     jlogic('pm')->pmSend($pm_post);
                 }
             }
         }
     } else {
         if ($msg) {
             $to_user = DB::result_first("select `nickname` from `" . TABLE_PREFIX . "members` where `uid` = '{$uid}'");
             if ($to_user) {
                 $pm_post = array('message' => $msg, 'to_user' => $to_user);
                 jlogic('pm')->pmSend($pm_post);
             }
         }
         $this->DatabaseHandler->Query("delete from `" . TABLE_PREFIX . "members_verify` where `uid` = '{$uid}'");
     }
     $this->Messager("操作成功");
 }