토렌트 스킨파일 질문드립니다

토렌트 스킨파일 질문드립니다

QA

토렌트 스킨파일 질문드립니다

본문

현재

https://sir.kr/g5_skin/7201?sfl=wr_subject%7C%7Cwr_content&stx=%ED%86%A0%EB%A0%8C%ED%8A%B8

 

이 스킨 사용중인데

계속 토렌트 해시값이 중복됬다고 나옵니다.

아무것도 없는 게시판인데말이죠.ㅠㅠ

 

코드는..

 

torrent.extend.php


 
$file_list_limit_count = 5; //토렌트 내부파일정보를 나타낼 때 최대 몇개까지를 출력할지 결정합니다.
$meta_data = TRUE; //토렌트 코멘트 등 수정
$hash_over = TRUE; //토렌트 해쉬 값 중복
$hash_down = FALSE; //토렌트 해쉬 파일 다운로드
$torrent_preface = "[Untitled] "; //토렌트 파일 다운로드 머리말
$torrent_comment = '★ Untitled (http://untitled.untitle311apyxry1w48.com) ★'; //토렌트 파일의 코멘트(설명)부분에 나올 내용을 입력하세요.
$torrent_createby = '@_untitle_d'; //토렌트 파일을 제작한 사람이름부분에 나올 내용을 입력하세요.

//확장자 추출
function get_extension($str){
    $path_parts = pathinfo($str);
    return $path_parts['extension'];
}

//파일용량, http://blog.habonyphp.com/92
function get_filesize1($size){
    $sizes = array(" Bytes", " KB", " MB", " GB", " TB", " PB", " EB", " ZB", " YB");
    if ($size == 0){ 
        return ('n/a');
    }else{ 
        return (round($size/pow(1024, ($i = floor(log($size, 1024)))), 2) . $sizes[$i]);
    } 
}

//토렌트 해쉬 값 중복
function get_hash($table, $hash)
{
    $sql = " select count(*) as cnt from {$table} where wr_torrent_hash like '%".$hash."%' ";
    $row = sql_fetch($sql);
    if ($row['cnt'] != 0) return TRUE;
    else FALSE;
}

//토렌트 정보
function get_torrent_info($file)
{    
    global $g5;
    
    $curl = curl_init();
    curl_setopt($curl, CURLOPT_URL, G5_PLUGIN_URL.'/torrent/info.php');
    curl_setopt($curl, CURLOPT_POST, 1);
    curl_setopt($curl, CURLOPT_POSTFIELDS, "filename={$file}");
    curl_setopt($curl, CURLOPT_TIMEOUT, 10);
    curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1);
    $return = curl_exec($curl);
    curl_close($curl);
    
    return json_decode($return, TRUE);
}

//토렌트 파일 수정
function set_metadata($file, $comment, $createby, $date=FALSE)
{    
    global $g5;
    
    $curl = curl_init();
    curl_setopt($curl, CURLOPT_URL, G5_PLUGIN_URL.'/torrent/metadata.php');
    curl_setopt($curl, CURLOPT_POST, 1);
    curl_setopt($curl, CURLOPT_POSTFIELDS, "filename={$file}&comment={$comment}&createby={$createby}&date={$date}");
    curl_setopt($curl, CURLOPT_TIMEOUT, 10);
    curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1);
    $return = curl_exec($curl);
    curl_close($curl);
    
    //return $return;
}
 

 

write_update.skin.php

 



//컬럼추가
_query("alter table {$write_table} add column `wr_torrent_hash` text NOT NULL");
if ($w == '' || $w == 'r') {

    //토렌트
    $tmp_name = '';
    $tmp_hash = '';
    for ($i=0; $i<count($upload); $i++)
    {
        $dest_file = G5_DATA_PATH.'/file/'.$bo_table.'/'.$upload[$i]['file'];
        if (file_exists($dest_file) && get_extension($dest_file) == 'torrent'){
            $torrent_array = get_torrent_info($dest_file); //내부 파일 정보
            $torrent_name = $torrent_array['name']; //제목
            $torrent_hash = $torrent_array['hash']; //해쉬
            
            if ($wr_subject == 't' or $wr_subject == 'ㅅ') //글쓰기 제목
                if ($i == 0) sql_query(" update {$write_table} set wr_subject = '".addslashes($torrent_name)."' where wr_id = '{$wr_id}' ");
            $tmp_name .= $torrent_name.($board['bo_use_dhtml_editor']==0?"\n":"<br>");
                
            if ($hash_over){
                if (get_hash($write_table, $torrent_hash)){ //토렌트 해쉬 값 중복
                    @unlink($dest_file); //파일 삭제
                    insert_point($member['mb_id'], $board['bo_write_point']*(-1), "{$board['bo_subject']} {$wr_id} 토렌트 해쉬 값 중복");
                    sql_query(" delete from {$g5['board_file_table']} where bo_table = '{$bo_table}' and wr_id = '{$wr_id}' "); //파일테이블 행 삭제
                    sql_query(" delete from {$g5['board_new_table']} where bo_table = '{$bo_table}' and wr_id = '{$wr_id}' "); //최근게시물 삭제
                    sql_query(" delete from {$write_table} where wr_id = '{$wr_id}' "); //게시물 삭제
                    sql_query(" update {$g5['board_table']} set bo_count_write = bo_count_write - 1 where bo_table = '$bo_table' ");  //글숫자 감소
                    alert('토렌트 해쉬 값이 중복되었습니다.');
                }
            }
            $tmp_hash .= $torrent_hash."|";
            
            if ($hash_down) $tmp_down = $torrent_preface.$torrent_hash.".torrent";
            else $tmp_down = $torrent_preface.$torrent_name.".torrent";
            sql_query(" update {$g5['board_file_table']} set bf_source = '".addslashes($tmp_down)."' where bo_table = '{$bo_table}' and wr_id = '{$wr_id}' and bf_no = '{$i}' "); //다운로드
            
            if ($meta_data) //토렌트 수정
                set_metadata($dest_file, $torrent_comment, $torrent_createby);
        }
    }
    
    if ($wr_content == '<p>t</p>' or $wr_content == '<p>ㅅ</p>' or $wr_content == 't' or $wr_content == 'ㅅ') //글쓰기 내용
        sql_query(" update {$write_table} set wr_content = '".addslashes($tmp_name)."' where wr_id = '{$wr_id}' ");
    
    sql_query(" update {$write_table} set wr_torrent_hash = '".addslashes($tmp_hash)."' where wr_id = '{$wr_id}' "); //토렌트 해쉬 값
    
    
}

 

이 질문에 댓글 쓰기 :

답변 1

제가 사용해 보지 못해 잘못된 부분을 알 수는 없지만

위 내용으로만 파악해 보자면

파일이 다르다해도 해쉬값이 같을 확률은 존재하기는 하지마

극히 작기 때문에

torrent.extend.php애서 $hash_over를 FALSE로 처리후

사용해도 문제 없을걸로 보입니다.

 

그리고 '아무것도 없는 게시판'을 왜 데이터베이스에 접근해

그걸 체크하는지 모르겠네요.

extend폴더 사용은 극히 제한적이어야 됩니다.

 

답변을 작성하시기 전에 로그인 해주세요.
전체 6
QA 내용 검색

회원로그인

(주)에스아이알소프트 / 대표:홍석명 / (06211) 서울특별시 강남구 역삼동 707-34 한신인터밸리24 서관 1404호 / E-Mail: admin@sir.kr
사업자등록번호: 217-81-36347 / 통신판매업신고번호:2014-서울강남-02098호 / 개인정보보호책임자:김민섭(minsup@sir.kr)
© SIRSOFT