// 존재하는 파일이 있다면 삭제합니다.
            @unlink(G5_DATA_PATH . '/qa/' . $write['qa_file' . $i]);
            // 이미지파일이면 썸네일삭제
            if (preg_match("/\\.({$config['cf_image_extension']})\$/i", $write['qa_file' . $i])) {
                delete_qa_thumbnail($row['qa_file' . $i]);
            }
        }
        // 프로그램 원래 파일명
        $upload[$i]['source'] = $filename;
        $upload[$i]['filesize'] = $filesize;
        // 아래의 문자열이 들어간 파일은 -x 를 붙여서 웹경로를 알더라도 실행을 하지 못하도록 함
        $filename = preg_replace("/\\.(php|phtm|htm|cgi|pl|exe|jsp|asp|inc)/i", "\$0-x", $filename);
        shuffle($chars_array);
        $shuffle = implode('', $chars_array);
        // 첨부파일 첨부시 첨부파일명에 공백이 포함되어 있으면 일부 PC에서 보이지 않거나 다운로드 되지 않는 현상이 있습니다. (길상여의 님 090925)
        $upload[$i]['file'] = abs(ip2long($_SERVER['REMOTE_ADDR'])) . '_' . substr($shuffle, 0, 8) . '_' . replace_filename($filename);
        $dest_file = G5_DATA_PATH . '/qa/' . $upload[$i]['file'];
        // 업로드가 안된다면 에러메세지 출력하고 죽어버립니다.
        $error_code = move_uploaded_file($tmp_file, $dest_file) or die($_FILES['bf_file']['error'][$i]);
        // 올라간 파일의 퍼미션을 변경합니다.
        chmod($dest_file, G5_FILE_PERMISSION);
    }
}
if ($w == '' || $w == 'a' || $w == 'r') {
    if ($w == '' || $w == 'r') {
        $row = sql_fetch(" select MIN(qa_num) as min_qa_num from {$g5['qa_content_table']} ");
        $qa_num = $row['min_qa_num'] - 1;
    }
    if ($w == 'a') {
        $qa_num = $write['qa_num'];
        $qa_parent = $write['qa_id'];
	{
		// Display generic error message
		echo '<p>Sorry, weather data not available at this time.</p>' . "\n";
		// Displaying the actual error message below is a bad idea because
		// it can reveal your directory/file structure to malicious users.
		// Unless you're in a test environment or trying to debug a permissions
		// issue, it is recommended that you leave the line below commented out. 
		// echo '<p>' . $error '</p>' . "\n";
	}
	// Display the data
	else
	{
		echo '<div id="nws-container">' . "\n";
		echo '<h1>Current Weather</h1>' . "\n";
		echo '<span class="primary">' . "\n";
		echo '<img src="' . $icons_path . replace_filename($xml->icon_url_name) . '" alt=" ">'  . "\n";
		// Casting temp_f as a float removes trailing zeros
		echo '<h2>' . (float)$xml->temp_f . '&#176; F</h2>' . "\n";
		echo '<p class="nws-description">' . $xml->weather . '</p>' . "\n";
		echo '</span>' . "\n";
		echo '<ul>' . "\n";
		// Some things are seasonal, only show them if they exist
		
		// If there's a windchill, display it
		if ($xml->windchill_f)
		{
			echo '<li><strong>Wind Chill: </strong>' . $xml->windchill_f . '&#176; F</li>' . "\n";
		}
		// If there's a heat index, display it
		if ($xml->heat_index_f)
		{
Beispiel #3
0
function apms_upload_file($dir, $pf_id)
{
    global $config, $g5, $default;
    if (!$pf_id) {
        return;
    }
    //파일타입 설정
    switch ($dir) {
        case 'item':
            $pf_dir = 1;
            $pf_file = G5_DATA_PATH . '/item/' . $pf_id;
            break;
        case 'partner':
            $pf_dir = 2;
            $pf_file = G5_DATA_PATH . '/apms/' . $dir;
            break;
        default:
            return;
    }
    //디렉토리가 없다면 생성합니다. (퍼미션도 변경하구요.)
    @mkdir($pf_file, G5_DIR_PERMISSION);
    @chmod($pf_file, G5_DIR_PERMISSION);
    $chars_array = array_merge(range(0, 9), range('a', 'z'), range('A', 'Z'));
    // 가변 파일 업로드
    $file_upload_msg = '';
    $upload = array();
    for ($i = 0; $i < count($_FILES['pf_file']['name']); $i++) {
        $upload[$i]['id'] = $pf_id;
        $upload[$i]['dir'] = $pf_dir;
        $upload[$i]['file'] = '';
        $upload[$i]['source'] = '';
        $upload[$i]['filesize'] = 0;
        $upload[$i]['image'] = array();
        $upload[$i]['image'][0] = '';
        $upload[$i]['image'][1] = '';
        $upload[$i]['image'][2] = '';
        $upload[$i]['guest_use'] = isset($_POST['pf_guest'][$i]) && $_POST['pf_guest'][$i] ? 1 : 0;
        $upload[$i]['purchase_use'] = isset($_POST['pf_purchase'][$i]) && $_POST['pf_purchase'][$i] ? 1 : 0;
        $upload[$i]['download_use'] = isset($_POST['pf_download'][$i]) && $_POST['pf_download'][$i] ? 1 : 0;
        $upload[$i]['view_use'] = isset($_POST['pf_view'][$i]) && $_POST['pf_view'][$i] ? 1 : 0;
        // 삭제에 체크가 되어있다면 파일을 삭제합니다.
        if (isset($_POST['pf_file_del'][$i]) && $_POST['pf_file_del'][$i]) {
            $upload[$i]['del_check'] = true;
            $row = sql_fetch(" select pf_file from {$g5['apms_file']} where pf_id = '{$pf_id}' and pf_dir = '{$pf_dir}' and pf_no = '{$i}' ");
            @unlink($pf_file . '/' . $row['pf_file']);
        } else {
            $upload[$i]['del_check'] = false;
        }
        $tmp_file = $_FILES['pf_file']['tmp_name'][$i];
        $filesize = $_FILES['pf_file']['size'][$i];
        $filename = $_FILES['pf_file']['name'][$i];
        $filename = get_safe_filename($filename);
        // 서버에 설정된 값보다 큰파일을 업로드 한다면
        if ($filename) {
            if ($_FILES['pf_file']['error'][$i] == 1) {
                $file_upload_msg .= '\\"' . $filename . '\\" 파일의 용량이 서버에 설정(' . ini_get('upload_max_filesize') . ')된 값보다 크므로 업로드 할 수 없습니다.\\n';
                continue;
            } else {
                if ($_FILES['pf_file']['error'][$i] != 0) {
                    $file_upload_msg .= '\\"' . $filename . '\\" 파일이 정상적으로 업로드 되지 않았습니다.\\n';
                    continue;
                }
            }
        }
        if (is_uploaded_file($tmp_file)) {
            // 관리자가 아니면서 설정한 업로드 사이즈보다 크다면 건너뜀
            if (!$is_admin && $filesize > $default['pt_upload_size']) {
                $file_upload_msg .= '\\"' . $filename . '\\" 파일의 용량(' . number_format($filesize) . ' 바이트)이 설정(' . number_format($default['pt_upload_size']) . ' 바이트)된 값보다 크므로 업로드 하지 않습니다.\\n';
                continue;
            }
            //=================================================================\
            // 090714
            // 이미지나 플래시 파일에 악성코드를 심어 업로드 하는 경우를 방지
            // 에러메세지는 출력하지 않는다.
            //-----------------------------------------------------------------
            $timg = @getimagesize($tmp_file);
            // image type
            if (preg_match("/\\.({$config['cf_image_extension']})\$/i", $filename) || preg_match("/\\.({$config['cf_flash_extension']})\$/i", $filename)) {
                if ($timg['2'] < 1 || $timg['2'] > 16) {
                    continue;
                }
            }
            //=================================================================
            $upload[$i]['image'] = $timg;
            // 프로그램 원래 파일명
            $upload[$i]['source'] = $filename;
            $upload[$i]['filesize'] = $filesize;
            // 아래의 문자열이 들어간 파일은 -x 를 붙여서 웹경로를 알더라도 실행을 하지 못하도록 함
            $filename = preg_replace("/\\.(php|phtm|htm|cgi|pl|exe|jsp|asp|inc)/i", "\$0-x", $filename);
            shuffle($chars_array);
            $shuffle = implode('', $chars_array);
            // 첨부파일 첨부시 첨부파일명에 공백이 포함되어 있으면 일부 PC에서 보이지 않거나 다운로드 되지 않는 현상이 있습니다. (길상여의 님 090925)
            $upload[$i]['file'] = abs(ip2long($_SERVER['REMOTE_ADDR'])) . '_' . substr($shuffle, 0, 8) . '_' . replace_filename($filename);
            $dest_file = $pf_file . '/' . $upload[$i]['file'];
            // 업로드가 안된다면 에러메세지 출력하고 죽어버립니다.
            $error_code = move_uploaded_file($tmp_file, $dest_file) or die($_FILES['pf_file']['error'][$i]);
            // 올라간 파일의 퍼미션을 변경합니다.
            chmod($dest_file, G5_FILE_PERMISSION);
        }
    }
    //------------------------------------------------------------------------------
    // 가변 파일 업로드
    for ($i = 0; $i < count($upload); $i++) {
        //파일유형체크
        $upload[$i]['ext'] = apms_check_ext($upload[$i]['source']);
        if (!get_magic_quotes_gpc()) {
            $upload[$i]['source'] = addslashes($upload[$i]['source']);
        }
        $row = sql_fetch(" select count(*) as cnt from {$g5['apms_file']} where pf_id = '{$pf_id}' and pf_dir = '{$pf_dir}' and pf_no = '{$i}' ");
        if ($row['cnt']) {
            // 삭제에 체크가 있거나 파일이 있다면 업데이트를 합니다.
            // 그렇지 않다면 내용만 업데이트 합니다.
            if ($upload[$i]['del_check'] || $upload[$i]['file']) {
                $sql = " update {$g5['apms_file']}\n\t\t\t\t\t\t\tset pf_source\t\t= '{$upload[$i]['source']}',\n\t\t\t\t\t\t\t\tpf_file\t\t\t= '{$upload[$i]['file']}',\n\t\t\t\t\t\t\t\tpf_filesize\t\t= '{$upload[$i]['filesize']}',\n\t\t\t\t\t\t\t\tpf_width\t\t= '{$upload[$i]['image']['0']}',\n\t\t\t\t\t\t\t\tpf_height\t\t= '{$upload[$i]['image']['1']}',\n\t\t\t\t\t\t\t\tpf_type\t\t\t= '{$upload[$i]['image']['2']}',\n\t\t\t\t\t\t\t\tpf_guest_use\t= '{$upload[$i]['guest_use']}',\n\t\t\t\t\t\t\t\tpf_purchase_use = '{$upload[$i]['purchase_use']}',\n\t\t\t\t\t\t\t\tpf_download_use = '{$upload[$i]['download_use']}',\n\t\t\t\t\t\t\t\tpf_view_use\t\t= '{$upload[$i]['view_use']}',\n\t\t\t\t\t\t\t\tpf_ext\t\t\t= '{$upload[$i]['ext']}',\n\t\t\t\t\t\t\t\tpf_datetime\t\t= '" . G5_TIME_YMDHIS . "'\n\t\t\t\t\t\t  where pf_id = '{$pf_id}' and pf_dir = '{$pf_dir}' and pf_no = '{$i}' ";
                sql_query($sql);
            } else {
                $sql = " update {$g5['apms_file']}\n\t\t\t\t\t\t\tset\tpf_guest_use\t= '{$upload[$i]['guest_use']}',\n\t\t\t\t\t\t\t\tpf_purchase_use = '{$upload[$i]['purchase_use']}',\n\t\t\t\t\t\t\t\tpf_download_use = '{$upload[$i]['download_use']}',\n\t\t\t\t\t\t\t\tpf_view_use\t\t= '{$upload[$i]['view_use']}'\n\t\t\t\t\t\t  where pf_id = '{$pf_id}' and pf_dir = '{$pf_dir}' and pf_no = '{$i}' ";
                sql_query($sql);
            }
        } else {
            $sql = " insert into {$g5['apms_file']}\n\t\t\t\t\t\tset pf_id\t\t\t\t= '{$upload[$i]['id']}',\n\t\t\t\t\t\t\tpf_no\t\t\t\t= '{$i}',\n\t\t\t\t\t\t\tpf_source\t\t\t= '{$upload[$i]['source']}',\n\t\t\t\t\t\t\tpf_file\t\t\t\t= '{$upload[$i]['file']}',\n\t\t\t\t\t\t\tpf_download\t\t\t= '0',\n\t\t\t\t\t\t\tpf_filesize\t\t\t= '{$upload[$i]['filesize']}',\n\t\t\t\t\t\t\tpf_width\t\t\t= '{$upload[$i]['image']['0']}',\n\t\t\t\t\t\t\tpf_height\t\t\t= '{$upload[$i]['image']['1']}',\n\t\t\t\t\t\t\tpf_type\t\t\t\t= '{$upload[$i]['image']['2']}',\n\t\t\t\t\t\t\tpf_guest_use\t\t= '{$upload[$i]['guest_use']}',\n\t\t\t\t\t\t\tpf_purchase_use\t\t= '{$upload[$i]['purchase_use']}',\n\t\t\t\t\t\t\tpf_download_use\t\t= '{$upload[$i]['download_use']}',\n\t\t\t\t\t\t\tpf_view_use\t\t\t= '{$upload[$i]['view_use']}',\n\t\t\t\t\t\t\tpf_dir\t\t\t\t= '{$upload[$i]['dir']}',\n\t\t\t\t\t\t\tpf_ext\t\t\t\t= '{$upload[$i]['ext']}',\n\t\t\t\t\t\t\tpf_datetime\t\t\t= '" . G5_TIME_YMDHIS . "' ";
            sql_query($sql);
        }
    }
    // 업로드된 파일 내용에서 가장 큰 번호를 얻어 거꾸로 확인해 가면서
    // 파일 정보가 없다면 테이블의 내용을 삭제합니다.
    $row = sql_fetch(" select max(pf_no) as max_pf_no from {$g5['apms_file']} where pf_id = '{$pf_id}' and pf_dir = '{$pf_dir}' ");
    for ($i = (int) $row['max_pf_no']; $i >= 0; $i--) {
        $row2 = sql_fetch(" select pf_file from {$g5['apms_file']} where pf_id = '{$pf_id}' and pf_dir = '{$pf_dir}' and pf_no = '{$i}' ");
        // 정보가 있다면 빠집니다.
        if ($row2['pf_file']) {
            break;
        }
        // 그렇지 않다면 정보를 삭제합니다.
        sql_query(" delete from {$g5['apms_file']} where pf_id = '{$pf_id}' and pf_dir = '{$pf_dir}' and pf_no = '{$i}' ");
    }
    return $file_upload_msg;
}
Beispiel #4
0
function apms_editor_image($content, $mode = '')
{
    if (!$content) {
        return;
    }
    if ($mode == 'move') {
        return $content;
    }
    // 이동은 처리하지 않음
    $imgs = get_editor_image($content, false);
    for ($i = 0; $i < count($imgs[1]); $i++) {
        // 이미지 path 구함
        $imgurl = @parse_url($imgs[1][$i]);
        $destfile = $_SERVER['DOCUMENT_ROOT'] . $imgurl['path'];
        if (is_file($destfile)) {
            if ($mode == 'copy') {
                //다른이름으로 복사
                $ym = date('ym', G5_SERVER_TIME);
                $data_dir = G5_DATA_PATH . '/editor/' . $ym;
                $data_url = G5_DATA_URL . '/editor/' . $ym;
                if (!is_dir($data_dir)) {
                    @mkdir($data_dir, G5_DIR_PERMISSION);
                    @chmod($data_dir, G5_DIR_PERMISSION);
                }
                $filename = basename($destfile);
                $chars_array = array_merge(range(0, 9), range('a', 'z'), range('A', 'Z'));
                shuffle($chars_array);
                $shuffle = implode('', $chars_array);
                $file_name = abs(ip2long($_SERVER['REMOTE_ADDR'])) . '_' . substr($shuffle, 0, 8) . '_' . replace_filename($filename);
                $save_file = sprintf('%s/%s', $data_dir, $file_name);
                $save_url = sprintf('%s/%s', $data_url, $file_name);
                @copy($destfile, $save_file);
                @chmod($save_file, G5_FILE_PERMISSION);
                $content = str_replace($imgs[1][$i], $save_url, $content);
            } else {
                //이미지 삭제
                @chmod($destfile, G5_FILE_PERMISSION);
                @unlink($destfile);
            }
        }
    }
    return $mode == 'copy' ? $content : '';
}
Beispiel #5
0
 $sql = " insert into {$move_write_table}\n                        set wr_num = '{$next_wr_num}',\n                             wr_reply = '{$row2['wr_reply']}',\n                             wr_is_comment = '{$row2['wr_is_comment']}',\n                             wr_comment = '{$row2['wr_comment']}',\n                             wr_comment_reply = '{$row2['wr_comment_reply']}',\n                             ca_name = '" . addslashes($row2['ca_name']) . "',\n                             wr_option = '{$row2['wr_option']}',\n                             wr_subject = '" . addslashes($row2['wr_subject']) . "',\n                             wr_content = '" . addslashes($tmp_content) . "',\n                             wr_link1 = '" . addslashes($row2['wr_link1']) . "',\n                             wr_link2 = '" . addslashes($row2['wr_link2']) . "',\n                             wr_link1_hit = '{$row2['wr_link1_hit']}',\n                             wr_link2_hit = '{$row2['wr_link2_hit']}',\n                             wr_hit = '{$row2['wr_hit']}',\n                             wr_good = '{$row2['wr_good']}',\n                             wr_nogood = '{$row2['wr_nogood']}',\n                             mb_id = '{$row2['mb_id']}',\n                             wr_password = '******'wr_password']}',\n                             wr_name = '" . addslashes($row2['wr_name']) . "',\n                             wr_email = '" . addslashes($row2['wr_email']) . "',\n                             wr_homepage = '" . addslashes($row2['wr_homepage']) . "',\n                             wr_datetime = '{$row2['wr_datetime']}',\n                             wr_file = '{$row2['wr_file']}',\n                             wr_last = '{$row2['wr_last']}',\n                             wr_ip = '{$row2['wr_ip']}',\n                             as_type = '{$row2['as_type']}',\n\t\t\t\t\t\t\t as_img = '{$row2['as_img']}',\n                             as_list = '{$row2['as_list']}',\n                             as_publish = '{$row2['as_publish']}',\n\t\t\t\t\t\t\t as_extra = '{$row2['as_extra']}',\n\t\t\t\t\t\t\t as_download = '{$row2['as_download']}',\n\t\t\t\t\t\t\t as_down = '{$row2['as_down']}',\n\t\t\t\t\t\t\t as_view = '{$row2['as_view']}',\n\t\t\t\t\t\t\t as_level = '{$row2['as_level']}',\n\t\t\t\t\t\t\t as_lucky = '{$row2['as_lucky']}',\n\t\t\t\t\t\t\t as_poll = '{$row2['as_poll']}',\n\t\t\t\t\t\t\t as_star_score = '{$row2['as_star_score']}',\n\t\t\t\t\t\t\t as_star_cnt = '{$row2['as_star_cnt']}',\n\t\t\t\t\t\t\t as_re_mb = '{$row2['as_re_mb']}',\n\t\t\t\t\t\t\t as_re_name = '{$row2['as_re_name']}',\n                             as_tag = '" . addslashes($row2['as_tag']) . "',\n                             as_icon = '" . addslashes($row2['as_icon']) . "',\n                             as_update = '{$row2['as_update']}',\n                             wr_1 = '" . addslashes($row2['wr_1']) . "',\n                             wr_2 = '" . addslashes($row2['wr_2']) . "',\n                             wr_3 = '" . addslashes($row2['wr_3']) . "',\n                             wr_4 = '" . addslashes($row2['wr_4']) . "',\n                             wr_5 = '" . addslashes($row2['wr_5']) . "',\n                             wr_6 = '" . addslashes($row2['wr_6']) . "',\n                             wr_7 = '" . addslashes($row2['wr_7']) . "',\n                             wr_8 = '" . addslashes($row2['wr_8']) . "',\n                             wr_9 = '" . addslashes($row2['wr_9']) . "',\n                             wr_10 = '" . addslashes($row2['wr_10']) . "' ";
 sql_query($sql);
 $insert_id = sql_insert_id();
 // 코멘트가 아니라면
 if (!$row2['wr_is_comment']) {
     $save_parent = $insert_id;
     $sql3 = " select * from {$g5['board_file_table']} where bo_table = '{$bo_table}' and wr_id = '{$row2['wr_id']}' order by bf_no ";
     $result3 = sql_query($sql3);
     for ($k = 0; $row3 = sql_fetch_array($result3); $k++) {
         $tmp_file = $row3['bf_file'];
         if ($tmp_file) {
             if ($is_same_board) {
                 // 동일 게시판
                 shuffle($chars_array);
                 $shuffle = implode('', $chars_array);
                 $tmp_file = abs(ip2long($_SERVER['REMOTE_ADDR'])) . '_' . substr($shuffle, 0, 8) . '_' . replace_filename($row3['bf_source']);
             }
             // 원본파일을 복사하고 퍼미션을 변경
             @copy($src_dir . '/' . $row3['bf_file'], $dst_dir . '/' . $tmp_file);
             @chmod($dst_dir / $tmp_file, G5_FILE_PERMISSION);
         }
         $sql = " insert into {$g5['board_file_table']}\n                                set bo_table = '{$move_bo_table}',\n                                     wr_id = '{$insert_id}',\n                                     bf_no = '{$row3['bf_no']}',\n                                     bf_source = '" . addslashes($row3['bf_source']) . "',\n                                     bf_file = '{$tmp_file}',\n                                     bf_download = '{$row3['bf_download']}',\n                                     bf_content = '" . addslashes($row3['bf_content']) . "',\n                                     bf_filesize = '{$row3['bf_filesize']}',\n                                     bf_width = '{$row3['bf_width']}',\n                                     bf_height = '{$row3['bf_height']}',\n                                     bf_type = '{$row3['bf_type']}',\n                                     bf_datetime = '{$row3['bf_datetime']}' ";
         sql_query($sql);
         if ($sw == 'move' && $row3['bf_file'] && $bo_table != $move_bo_table) {
             $save[$cnt]['bf_file'][$k] = $src_dir . '/' . $row3['bf_file'];
         }
     }
     // 설문복사
     if ($sw == 'copy') {
         $sql4 = " select * from {$g5['apms_poll']} where bo_table = '{$bo_table}' and wr_id = '{$row2['wr_id']}' order by po_id ";
         $result4 = sql_query($sql4);