Ejemplo n.º 1
0
function conv_link_video($link)
{
    if (!$link) {
        return;
    }
    // 비디오, 오디오 체크
    $vext = array("mp4", "m4v", "f4v", "mov", "flv", "webm", "acc", "m4a", "f4a", "mp3", "ogg", "oga", "rss");
    list($link_video) = explode("|", $link);
    $file = apms_get_filename($link_video);
    $str = '';
    if (isset($file['ext']) && $file['ext'] && in_array($file['ext'], $vext)) {
        if (apms_jwplayer($link_video)) {
            $str = '<p>{동영상:' . $link_video . '|file=1}</p>';
        }
    } else {
        $video = apms_video_info($link_video);
        if (isset($video['vid']) && $video['vid']) {
            $str = '<p>{동영상:' . $link_video . '}</p>';
        }
    }
    return $str;
}
Ejemplo n.º 2
0
function apms_wr_thumbnail($bo_table, $write, $thumb_width, $thumb_height, $is_create = false, $is_crop = true, $crop_mode = 'center', $is_sharpen = true, $um_value = '80/0.5/3')
{
    global $g5, $config;
    $img = array();
    $limg = array();
    $lalt = array();
    $link = array();
    $thumb = array();
    $chk_img = isset($write['chk_img']) && $write['chk_img'] ? true : false;
    // Check Image
    $rows = isset($write['img_rows']) && $write['img_rows'] > 1 ? $write['img_rows'] : 1;
    // 비밀글 & 블라인드글
    if (strstr($write['wr_option'], 'secret') || $write['as_shingo'] < 0) {
        if ($chk_img) {
            return 0;
        }
        if ($rows > 1) {
            $thumb[0] = array('is_thumb' => false, 'src' => '', 'alt' => '', 'org' => '', 'height' => '');
        } else {
            $thumb = array('is_thumb' => false, 'src' => '', 'alt' => '', 'org' => '', 'height' => '');
        }
        return $thumb;
    }
    $wr_id = $write['wr_id'];
    $wr_content = $write['wr_content'];
    $is_thumb_no = isset($write['is_thumb_no']) && $write['is_thumb_no'] ? true : false;
    $no_img = isset($write['no_img']) && $write['no_img'] ? $write['no_img'] : '';
    // 링크
    for ($i = 1; $i <= G5_LINK_COUNT; $i++) {
        $link[$i] = get_text($write["wr_link{$i}"]);
    }
    unset($write);
    $result = sql_query(" select bf_file, bf_content from {$g5['board_file_table']} where bo_table = '{$bo_table}' and wr_id = '{$wr_id}' and bf_type between '1' and '3' order by bf_no", false);
    $z = 0;
    for ($i = 0; $row = sql_fetch_array($result); $i++) {
        if ($row['bf_file']) {
            $img[$z]['edit'] = false;
            $img[$z]['is_thumb'] = true;
            $img[$z]['alt'] = get_text($row['bf_content']);
            $img[$z]['img'] = G5_DATA_URL . '/file/' . $bo_table . '/' . $row['bf_file'];
            $z++;
            if ($z == $rows) {
                break;
            }
        }
    }
    if ($z != $rows) {
        if (!$wr_content) {
            $write_table = $g5['write_prefix'] . $bo_table;
            $sql = " select wr_content from {$write_table} where wr_id = '{$wr_id}' ";
            $write = sql_fetch($sql);
            $wr_content = $write['wr_content'];
        }
        $matches = get_editor_image($wr_content, false);
        $edt = true;
        for ($i = 0; $i < count($matches[1]); $i++) {
            // 이미지 path 구함
            $p = @parse_url($matches[1][$i]);
            if (strpos($p['path'], '/' . G5_DATA_DIR . '/') != 0) {
                $data_path = preg_replace('/^\\/.*\\/' . G5_DATA_DIR . '/', '/' . G5_DATA_DIR, $p['path']);
            } else {
                $data_path = $p['path'];
            }
            $srcfile = G5_PATH . $data_path;
            //if(preg_match("/\.({$config['cf_image_extension']})$/i", $srcfile)) {
            if (is_file($srcfile)) {
                $size = @getimagesize($srcfile);
                if (empty($size)) {
                    continue;
                }
                $img[$z]['edit'] = true;
                $img[$z]['is_thumb'] = true;
                $img[$z]['img'] = $matches[1][$i];
                preg_match("/alt=[\"\\']?([^\"\\']*)[\"\\']?/", $matches[0][$i], $malt);
                $img[$z]['alt'] = get_text($malt[1]);
                $z++;
                if ($z == $rows) {
                    break;
                }
            } else {
                $limg[] = $matches[1][$i];
                preg_match("/alt=[\"\\']?([^\"\\']*)[\"\\']?/", $matches[0][$i], $malt);
                $lalt[] = get_text($malt[1]);
            }
            //}
        }
    }
    if ($z != $rows) {
        // 링크동영상 체크
        for ($i = 1; $i <= count($link); $i++) {
            $video = apms_video_info($link[$i]);
            if (!$video['type']) {
                continue;
            }
            $srcfile = apms_video_img($video['video_url'], $video['vid'], $video['type']);
            if (!$srcfile || $srcfile == 'none') {
                continue;
            }
            $size = @getimagesize($srcfile);
            if (empty($size)) {
                continue;
            }
            $img[$z]['edit'] = true;
            $img[$z]['is_thumb'] = true;
            $img[$z]['img'] = str_replace(G5_PATH, G5_URL, $srcfile);
            $z++;
            if ($z == $rows) {
                break;
            }
        }
    }
    if ($z != $rows) {
        //본문동영상 이미지 체크
        if (preg_match_all("/{동영상\\:([^}]*)}/is", $wr_content, $match)) {
            $match_cnt = count($match[1]);
            for ($i = 0; $i < $match_cnt; $i++) {
                $video = apms_video_info(trim(strip_tags($match[1][$i])));
                if (!$video['type']) {
                    continue;
                }
                $srcfile = apms_video_img($video['video_url'], $video['vid'], $video['type']);
                if (!$srcfile || $srcfile == 'none') {
                    continue;
                }
                $size = @getimagesize($srcfile);
                if (empty($size)) {
                    continue;
                }
                $img[$z]['edit'] = true;
                $img[$z]['is_thumb'] = true;
                $img[$z]['img'] = str_replace(G5_PATH, G5_URL, $srcfile);
                $z++;
                if ($z == $rows) {
                    break;
                }
            }
        }
    }
    if ($z != $rows) {
        //링크 이미지
        for ($i = 0; $i < count($limg); $i++) {
            $img[$z]['edit'] = true;
            $img[$z]['is_thumb'] = false;
            $img[$z]['img'] = $limg[$i];
            $img[$z]['alt'] = $lalt[$i];
            $z++;
            if ($z == $rows) {
                break;
            }
        }
    }
    // Check Image
    if ($chk_img) {
        $chk_img = isset($img[0]['img']) && $img[0]['img'] ? 1 : 0;
        return $chk_img;
    }
    if ($z == 0) {
        if ($no_img) {
            $img[$z]['edit'] = false;
            $img[$z]['is_thumb'] = true;
            $img[$z]['org'] = $no_img;
            $img[$z]['img'] = $no_img;
            $img[$z]['alt'] = '';
        } else {
            if ($rows > 1) {
                $thumb[0] = array('is_thumb' => false, 'src' => '', 'alt' => '', 'org' => '', 'height' => '');
            } else {
                $thumb = array('is_thumb' => false, 'src' => '', 'alt' => '', 'org' => '', 'height' => '');
            }
            return $thumb;
        }
    }
    // 썸네일
    $tmp = array();
    $j = 0;
    for ($i = 0; $i < count($img); $i++) {
        if ($img[$i]['is_thumb'] && $thumb_width > 0 && !$is_thumb_no) {
            $tmpimg = apms_thumbnail($img[$i]['img'], $thumb_width, $thumb_height, $is_create, $is_crop, $crop_mode, $is_sharpen, $um_value);
            if (!$tmpimg['src']) {
                continue;
            }
            $tmp[$j]['is_thumb'] = true;
            $tmp[$j]['src'] = $tmpimg['src'];
            $tmp[$j]['height'] = $tmpimg['height'];
        } else {
            $tmp[$j]['is_thumb'] = false;
            $tmp[$j]['src'] = $img[$i]['img'];
            $tmp[$j]['height'] = '';
        }
        $tmp[$j]['org'] = $img[$i]['img'];
        $tmp[$j]['alt'] = $img[$i]['alt'];
        $j++;
    }
    if ($j == 0) {
        if ($rows > 1) {
            $thumb[0] = array('is_thumb' => false, 'src' => '', 'alt' => '', 'org' => '', 'height' => '');
        } else {
            $thumb = array('is_thumb' => false, 'src' => '', 'alt' => '', 'org' => '', 'height' => '');
        }
    } else {
        $thumb = $rows > 1 ? $tmp : $tmp[0];
    }
    return $thumb;
}
Ejemplo n.º 3
0
function apms_it_write_thumbnail($it_id, $wr_content, $thumb_width, $thumb_height, $is_create = false, $is_crop = true, $crop_mode = 'center', $is_sharpen = true, $um_value = '80/0.5/3')
{
    global $g5, $config;
    $filename = $alt = "";
    $matches = get_editor_image($wr_content, false);
    $limg = array();
    $lalt = array();
    for ($i = 0; $i < count($matches[1]); $i++) {
        // 이미지 path 구함
        $p = @parse_url($matches[1][$i]);
        if (strpos($p['path'], '/' . G5_DATA_DIR . '/') != 0) {
            $data_path = preg_replace('/^\\/.*\\/' . G5_DATA_DIR . '/', '/' . G5_DATA_DIR, $p['path']);
        } else {
            $data_path = $p['path'];
        }
        $srcfile = G5_PATH . $data_path;
        //if(preg_match("/\.({$config['cf_image_extension']})$/i", $srcfile)) {
        if (is_file($srcfile)) {
            $size = @getimagesize($srcfile);
            if (empty($size)) {
                continue;
            }
            $fileurl = $matches[1][$i];
            preg_match("/alt=[\"\\']?([^\"\\']*)[\"\\']?/", $matches[0][$i], $malt);
            $alt = get_text($malt[1]);
            break;
        } else {
            $limg[] = $matches[1][$i];
            preg_match("/alt=[\"\\']?([^\"\\']*)[\"\\']?/", $matches[0][$i], $malt);
            $lalt[] = get_text($malt[1]);
        }
        //}
    }
    if (!$filename) {
        //본문동영상 이미지 체크
        if (preg_match_all("/{동영상\\:([^}]*)}/is", $wr_content, $match)) {
            $match_cnt = count($match[1]);
            for ($i = 0; $i < $match_cnt; $i++) {
                $video = apms_video_info(trim(strip_tags($match[1][$i])));
                if (!$video['type']) {
                    continue;
                }
                $srcfile = apms_video_img($video['video_url'], $video['vid'], $video['type']);
                if (!$srcfile || $srcfile == 'none') {
                    continue;
                }
                $size = @getimagesize($srcfile);
                if (empty($size)) {
                    continue;
                }
                $fileurl = str_replace(G5_PATH, G5_URL, $srcfile);
                break;
            }
        }
    }
    if (!$filename) {
        //기타
        //링크
        if (count($limg) > 0) {
            $thumb = array('is_thumb' => false, 'src' => $limg[0], 'alt' => $lalt[0], 'org' => $limg[0], 'height' => '');
            return $thumb;
        }
        //상품
        $edt = false;
        $it = apms_it($it_id);
        $thumb = apms_it_thumbnail($it, $thumb_width, $thumb_height, $is_create, $is_crop, $crop_mode, $is_sharpen, $um_value);
        if (!$thumb['src']) {
            $thumb = array('is_thumb' => false, 'src' => '', 'alt' => '', 'org' => '', 'height' => '');
        }
        return $thumb;
    }
    $thumb = apms_thumbnail($fileurl, $thumb_width, $thumb_height, $is_create, $is_crop, $crop_mode, $is_sharpen, $um_value);
    $thumb['is_thumb'] = true;
    $thumb['alt'] = $alt;
    $thumb['org'] = $fileurl;
    return $thumb;
}