테스트 사이트 - 개발 중인 베타 버전입니다

홈페이지에서 아이폰으로 hwp 다운로드 시 파일이 안 열립니다. 채택완료

eocnddnpq 3년 전 조회 1,780

다른 핸드폰으로는 다운로드, 파일 열기가 되고 아이패드에서도 되는데 아이폰으로는 다운로드만 가능하고 열리지 않습니다. 한컴 뷰어을 사용하여도 안 열리고 네이버 웨일에서도 열리지 않습니다. /bbs/download.php 파일 내용은 https://sir.kr/qa/140815 이곳에 https://sir.kr/bbs/profile.php?mb_id=smmysong1" onclick="return false;" rel="nofollow" target="_blank" title="보들이윤 자기소개">보들이윤 님의 답변 내용입니다.

</strong></p>

<p><strong><?php</strong></p>

<p><strong>include_once('./_common.php');</strong></p>

<p><strong> </strong></p>

<p><strong>// clean the output buffer</strong></p>

<p><strong>ob_end_clean();</strong></p>

<p><strong> </strong></p>

<p><strong>$no = (int)$no;</strong></p>

<p><strong> </strong></p>

<p><strong>@include_once($board_skin_path.'/download.head.skin.php');</strong></p>

<p><strong> </strong></p>

<p><strong>// 쿠키에 저장된 ID값과 넘어온 ID값을 비교하여 같지 않을 경우 오류 발생</strong></p>

<p><strong>// 다른곳에서 링크 거는것을 방지하기 위한 코드</strong></p>

<p><strong>if (!get_session('ss_view_'.$bo_table.'_'.$wr_id))</strong></p>

<p><strong>    alert('잘못된 접근입니다.');</strong></p>

<p><strong> </strong></p>

<p><strong>// 다운로드 차감일 때 비회원은 다운로드 불가</strong></p>

<p><strong>if($board['bo_download_point'] < 0 && $is_guest)</strong></p>

<p><strong>    alert('다운로드 권한이 없습니다.\\n회원이시라면 로그인 후 이용해 보십시오.', G5_BBS_URL.'/login.php?wr_id='.$wr_id.'&'.$qstr.'&url='.urlencode(G5_BBS_URL.'/board.php?bo_table='.$bo_table.'&wr_id='.$wr_id));</strong></p>

<p><strong> </strong></p>

<p><strong>$sql = " select bf_source, bf_file from {$g5['board_file_table']} where bo_table = '$bo_table' and wr_id = '$wr_id' and bf_no = '$no' ";</strong></p>

<p><strong>$file = sql_fetch($sql);</strong></p>

<p><strong>if (!$file['bf_file'])</strong></p>

<p><strong>    alert_close('파일 정보가 존재하지 않습니다.');</strong></p>

<p><strong> </strong></p>

<p><strong>// JavaScript 불가일 때</strong></p>

<p><strong>if($js != 'on' && $board['bo_download_point'] < 0) {</strong></p>

<p><strong>    $msg = $file['bf_source'].' 파일을 다운로드 하시면 포인트가 차감('.number_format($board['bo_download_point']).'점)됩니다.\\n포인트는 게시물당 한번만 차감되며 다음에 다시 다운로드 하셔도 중복하여 차감하지 않습니다.\\n그래도 다운로드 하시겠습니까?';</strong></p>

<p><strong>    $url1 = G5_BBS_URL.'/download.php?'.clean_query_string($_SERVER['QUERY_STRING']).'&js=on';</strong></p>

<p><strong>    $url2 = clean_xss_tags($_SERVER['HTTP_REFERER']);</strong></p>

<p><strong> </strong></p>

<p><strong>    //$url1 = 확인link, $url2=취소link</strong></p>

<p><strong>    // 특정주소로 이동시키려면 $url3 이용</strong></p>

<p><strong>    confirm($msg, $url1, $url2);</strong></p>

<p><strong>}</strong></p>

<p><strong> </strong></p>

<p><strong>if ($member['mb_level'] < $board['bo_download_level']) {</strong></p>

<p><strong>    $alert_msg = '다운로드 권한이 없습니다.';</strong></p>

<p><strong>    if ($member['mb_id'])</strong></p>

<p><strong>        alert($alert_msg);</strong></p>

<p><strong>    else</strong></p>

<p><strong>        alert($alert_msg.'\\n회원이시라면 로그인 후 이용해 보십시오.', G5_BBS_URL.'/login.php?wr_id='.$wr_id.'&'.$qstr.'&url='.urlencode(G5_BBS_URL.'/board.php?bo_table='.$bo_table.'&wr_id='.$wr_id));</strong></p>

<p><strong>}</strong></p>

<p><strong> </strong></p>

<p><strong>$filepath = G5_DATA_PATH.'/file/'.$bo_table.'/'.$file['bf_file'];</strong></p>

<p><strong>$filepath = addslashes($filepath);</strong></p>

<p><strong>if (!is_file($filepath) || !file_exists($filepath))</strong></p>

<p><strong>    alert('파일이 존재하지 않습니다.');</strong></p>

<p><strong> </strong></p>

<p><strong>// 사용자 코드 실행</strong></p>

<p><strong>@include_once($board_skin_path.'/download.skin.php');</strong></p>

<p><strong> </strong></p>

<p><strong>// 이미 다운로드 받은 파일인지를 검사한 후 게시물당 한번만 포인트를 차감하도록 수정</strong></p>

<p><strong>$ss_name = 'ss_down_'.$bo_table.'_'.$wr_id;</strong></p>

<p><strong>if (!get_session($ss_name))</strong></p>

<p><strong>{</strong></p>

<p><strong>    // 자신의 글이라면 통과</strong></p>

<p><strong>    // 관리자인 경우 통과</strong></p>

<p><strong>    if (($write['mb_id'] && $write['mb_id'] == $member['mb_id']) || $is_admin)</strong></p>

<p><strong>        ;</strong></p>

<p><strong>    else if ($board['bo_download_level'] >= 1) // 회원이상 다운로드가 가능하다면</strong></p>

<p><strong>    {</strong></p>

<p><strong>        // 다운로드 포인트가 음수이고 회원의 포인트가 0 이거나 작다면</strong></p>

<p><strong>        if ($member['mb_point'] + $board['bo_download_point'] < 0)</strong></p>

<p><strong>            alert('보유하신 포인트('.number_format($member['mb_point']).')가 없거나 모자라서 다운로드('.number_format($board['bo_download_point']).')가 불가합니다.\\n\\n포인트를 적립하신 후 다시 다운로드 해 주십시오.');</strong></p>

<p><strong> </strong></p>

<p><strong>        // 게시물당 한번만 차감하도록 수정</strong></p>

<p><strong>        insert_point($member['mb_id'], $board['bo_download_point'], "{$board['bo_subject']} $wr_id 파일 다운로드", $bo_table, $wr_id, "다운로드");</strong></p>

<p><strong>    }</strong></p>

<p><strong> </strong></p>

<p><strong>    // 다운로드 카운트 증가</strong></p>

<p><strong>    $sql = " update {$g5['board_file_table']} set bf_download = bf_download + 1 where bo_table = '$bo_table' and wr_id = '$wr_id' and bf_no = '$no' ";</strong></p>

<p><strong>    sql_query($sql);</strong></p>

<p><strong> </strong></p>

<p><strong>    set_session($ss_name, TRUE);</strong></p>

<p><strong>}</strong></p>

<p><strong> </strong></p>

<p><strong>$g5['title'] = '다운로드 > '.conv_subject($write['wr_subject'], 255);</strong></p>

<p><strong> </strong></p>

<p><strong>//$original = urlencode($file['bf_source']);</strong></p>

<p><strong>$original = iconv('utf-8', 'euc-kr', $file['bf_source']); // SIR 잉끼님 제안코드</strong></p>

<p><strong> </strong></p>

<p><strong>@include_once($board_skin_path.'/download.tail.skin.php');</strong></p>

<p><strong> </strong></p>

<p><strong> // Must be fresh start </strong></p>

<p><strong>  if( headers_sent() ) </strong></p>

<p><strong>    die('Headers Already Sent'); </strong></p>

<p><strong> </strong></p>

<p><strong>  // Required for some browsers </strong></p>

<p><strong>  if(ini_get('zlib.output_compression')) </strong></p>

<p><strong>    ini_set('zlib.output_compression', 'Off'); </strong></p>

<p><strong> </strong></p>

<p><strong>// Parse Info / Get Extension </strong></p>

<p><strong>$fsize = filesize($filepath); </strong></p>

<p><strong>$path_parts = pathinfo($filepath); </strong></p>

<p><strong>$ext = strtolower($path_parts["extension"]); </strong></p>

<p><strong> </strong></p>

<p><strong>    // Determine Content Type </strong></p>

<p><strong>    switch ($ext) </strong></p>

<p><strong>    { </strong></p>

<p><strong>      case "pdf": $ctype="application/pdf"; break; </strong></p>

<p><strong>      case "exe": $ctype="application/octet-stream"; break; </strong></p>

<p><strong>      case "zip": $ctype="application/zip"; break; </strong></p>

<p><strong>      case "doc": $ctype="application/msword"; break; </strong></p>

<p><strong>      case "xls": $ctype="application/vnd.ms-excel"; break; </strong></p>

<p><strong>      case "ppt": $ctype="application/vnd.ms-powerpoint"; break; </strong></p>

<p><strong>      case "gif": $ctype="image/gif"; break; </strong></p>

<p><strong>      case "png": $ctype="image/png"; break; </strong></p>

<p><strong>      case "jpeg": </strong></p>

<p><strong>      case "jpg": $ctype="image/jpg"; break; </strong></p>

<p><strong>      default: $ctype="application/force-download"; </strong></p>

<p><strong>    } </strong></p>

<p><strong> </strong></p>

<p><strong>    header("Pragma: public"); // required </strong></p>

<p><strong>    header("Expires: 0"); </strong></p>

<p><strong>    header("Cache-Control: must-revalidate, post-check=0, pre-check=0"); </strong></p>

<p><strong>    header("Cache-Control: private",false); // required for certain browsers </strong></p>

<p><strong>    header("Content-Type: $ctype"); </strong></p>

<p><strong>    header("Content-Disposition: attachment; filename=\"".$original."\";" ); </strong></p>

<p><strong>    header("Content-Transfer-Encoding: binary"); </strong></p>

<p><strong>    header("Content-Length: ".$fsize); </strong></p>

<p><strong>    ob_clean(); </strong></p>

<p><strong>    flush(); </strong></p>

<p><strong> </strong></p>

<p><strong>$fp = fopen($filepath, 'rb');</strong></p>

<p><strong> </strong></p>

<p><strong>// 4.00 대체</strong></p>

<p><strong>// 서버부하를 줄이려면 print 나 echo 또는 while 문을 이용한 방법보다는 이방법이...</strong></p>

<p><strong>//if (!fpassthru($fp)) {</strong></p>

<p><strong>//    fclose($fp);</strong></p>

<p><strong>//}</strong></p>

<p><strong> </strong></p>

<p><strong>$download_rate = 10;</strong></p>

<p><strong> </strong></p>

<p><strong>while(!feof($fp)) {</strong></p>

<p><strong>    //echo fread($fp, 100*1024);</strong></p>

<p><strong>    /*</strong></p>

<p><strong>    echo fread($fp, 100*1024);</strong></p>

<p><strong>    flush();</strong></p>

<p><strong>    */</strong></p>

<p><strong> </strong></p>

<p><strong>    print fread($fp, round($download_rate * 1024));</strong></p>

<p><strong>    flush();</strong></p>

<p><strong>    usleep(1000);</strong></p>

<p><strong>}</strong></p>

<p><strong>fclose ($fp);</strong></p>

<p><strong>flush();</strong></p>

<p><strong>?></strong></p>

<p><strong>
위의 소스을 이용하고 있습니다. 오류 문구는 파일이 손상되었다는 문구가 나옵니다. 어느 부분이 문제가 되고 있는지 감이 안 잡혀 Q&A 남기게 되었습니다.

댓글을 작성하려면 로그인이 필요합니다.

답변 1개

채택된 답변
+20 포인트

아이폰에서 hwp 파일을 볼 수가 있는 상태인가요? (앱 설치)

로그인 후 평가할 수 있습니다

답변에 대한 댓글 1개

e
eocnddnpq
3년 전
네 다른 홈페이지, 메세지 등등에서 hwp을 다운로드해서 볼 때는 아무 이상 없이 확인 가능합니다.
hwp뷰어(폴라리스 오피스, 한컴오피스)와 네이버 웨일에서 확인하여 사용하였습니다.
근데 특정 홈페이지에서 다운로드한 hwp 파일은 다운로드는 되나 확인이 불가 합니다.
특정 홈페이지 주소 남깁니다.
http://www.chonansenior.org/ 이곳의 공지사항에 있는 hwp 파일을 다운로드하면 문의한 문제가 발생됩니다.

댓글을 작성하려면 로그인이 필요합니다.

답변을 작성하려면 로그인이 필요합니다.

로그인