Example #1
0
function view_pic($sn = "")
{
    global $xoopsDB, $xoopsUser, $xoopsModule, $xoopsModuleConfig, $xoopsTpl, $xoTheme;
    $tadgallery = new tadgallery();
    //判斷是否對該模組有管理權限,  若空白
    if ($xoopsUser) {
        $nowuid = $xoopsUser->getVar('uid');
        $module_id = $xoopsModule->getVar('mid');
        $isAdmin = $xoopsUser->isAdmin($module_id);
    } else {
        $isAdmin = false;
        $nowuid = "";
    }
    $sql = "select * from " . $xoopsDB->prefix("tad_gallery") . " where sn='{$sn}'";
    $result = $xoopsDB->query($sql) or redirect_header($_SERVER['PHP_SELF'], 3, mysql_error());
    $all = $xoopsDB->fetchArray($result);
    //$csn,$title,$description,$filename,$size,$type,$width,$height,$dir,$uid,$post_date,$counter,$exif,$good,$tag,$photo_sort
    foreach ($all as $k => $v) {
        ${$k} = $v;
        $xoopsTpl->assign($k, $v);
    }
    $photo_s = $tadgallery->get_pic_url($dir, $sn, $filename, "s");
    $photo_m = $tadgallery->get_pic_url($dir, $sn, $filename, "m");
    $photo_l = $tadgallery->get_pic_url($dir, $sn, $filename);
    $xoopsTpl->assign("photo_s", $photo_s);
    $xoopsTpl->assign("photo_m", $photo_m);
    $xoopsTpl->assign("photo_l", $photo_l);
    if (!empty($csn)) {
        $ok_cat = $tadgallery->chk_cate_power();
        $cate = $tadgallery->get_tad_gallery_cate($csn);
        if (!in_array($csn, $ok_cat)) {
            redirect_header("index.php?csn={$csn}&op=passwd_form", 3, sprintf(_TADGAL_NO_PASSWD_CONTENT, $cate['title']));
            exit;
        }
        $sql = "select * from " . $xoopsDB->prefix("tad_gallery") . " where csn='{$csn}' order by photo_sort , post_date";
        $result = $xoopsDB->query($sql) or redirect_header($_SERVER['PHP_SELF'], 3, mysql_error());
        $slides1 = $slides2 = "";
        $i = 0;
        $start = false;
        while ($all = $xoopsDB->fetchArray($result)) {
            if ($sn == $all['sn']) {
                $start = true;
                $i = 0;
            }
            if ($start) {
                $slides1[$i]['sn'] = $all['sn'];
                $slides1[$i]['photo'] = $tadgallery->get_pic_url($all['dir'], $all['sn'], $all['filename']);
                $slides1[$i]['description'] = strip_tags($all['description']);
                $slides1[$i]['thumb'] = $tadgallery->get_pic_url($all['dir'], $all['sn'], $all['filename'], 's');
            } else {
                $slides2[$i]['sn'] = $all['sn'];
                $slides2[$i]['photo'] = $tadgallery->get_pic_url($all['dir'], $all['sn'], $all['filename']);
                $slides2[$i]['description'] = strip_tags($all['description']);
                $slides2[$i]['thumb'] = $tadgallery->get_pic_url($all['dir'], $all['sn'], $all['filename'], 's');
            }
            $i++;
        }
    }
    $xoopsTpl->assign("slides1", $slides1);
    $xoopsTpl->assign("slides2", $slides2);
    //找出上一張或下一張
    $pnp = get_pre_next($csn, $sn);
    $xoopsTpl->assign("next", $pnp['next']);
    $xoopsTpl->assign("back", $pnp['pre']);
    $arr = get_tadgallery_cate_path($csn);
    $jBreadCrumbPath = breadcrumb($csn, $arr);
    $xoopsTpl->assign("path", $jBreadCrumbPath);
    if (!file_exists(XOOPS_ROOT_PATH . "/modules/tadtools/fancybox.php")) {
        redirect_header("index.php", 3, _MA_NEED_TADTOOLS);
    }
    include_once XOOPS_ROOT_PATH . "/modules/tadtools/fancybox.php";
    $fancybox = new fancybox('.fancybox');
    $fancybox_code = $fancybox->render(false);
    $xoopsTpl->assign('fancybox_code', $fancybox_code);
    $title = empty($title) ? $filename : $title;
    $div_width = $xoopsModuleConfig['thumbnail_m_width'] + 30;
    $size_txt = sizef($size);
    if ($uid == $nowuid or $isAdmin) {
        $xoopsTpl->assign('show_del', 1);
        //$del_btn="<a src='javascript:delete_tad_gallery_func($sn)' title='"._TADGAL_DEL_PIC."' class='btn btn-danger'>"._TAD_DEL."</a>";
        $xoopsTpl->assign('good', $good);
        $del_js = "\n    <script>\n    function delete_tad_gallery_func(sn){\n      var sure = window.confirm('" . _TAD_DEL_CONFIRM . "');\n      if (!sure)  return;\n      location.href=\"{$_SERVER['PHP_SELF']}?op=delete_tad_gallery&sn=\" + sn;\n    }\n    </script>";
    } else {
        $del_btn = $admin_tool = $del_js = "";
    }
    $xoopsTpl->assign('del_btn', $del_btn);
    //秀出各種尺寸圖示
    if ($xoopsModuleConfig['show_copy_pic']) {
        $xoopsTpl->assign("photo_s", $photo_s);
        $xoopsTpl->assign("photo_m", $photo_m);
        $xoopsTpl->assign("photo_l", $photo_l);
        $xoopsTpl->assign("description", $description);
        $xoopsTpl->assign("sel_size", 1);
    } else {
        $xoopsTpl->assign("sel_size", 0);
    }
    //推文工具
    $push = push_url($xoopsModuleConfig['use_social_tools']);
    $xoopsTpl->assign("push", $push);
    $xoopsTpl->assign("pic_toolbar", $xoopsModuleConfig['pic_toolbar']);
    $xoopsTpl->assign("thumb_slider", $xoopsModuleConfig['thumb_slider']);
    //計數器
    add_tad_gallery_counter($sn);
    //地圖部份
    $info = explode("||", $exif);
    foreach ($info as $v) {
        $exif_arr = explode("=", $v);
        $exif_arr[1] = str_replace("&#65533;", "", $exif_arr[1]);
        $bb = "\$photoexif{$exif_arr[0]}=\"{$exif_arr[1]}\";";
        if (empty($exif_arr[0])) {
            continue;
        }
        @eval($bb);
    }
    $latitude = $photoexif['GPS']['latitude'];
    $longitude = $photoexif['GPS']['longitude'];
    $xoopsTpl->assign("latitude", $latitude);
    $xoopsTpl->assign("longitude", $longitude);
    $jquery_path = get_jquery(true);
    $xoopsTpl->assign("jquery", $jquery_path);
    $xoopsTpl->assign("path", $jBreadCrumbPath);
    $xoopsTpl->assign("del_js", $del_js);
    $xoopsTpl->assign("div_width", $div_width);
    $facebook_comments = facebook_comments($xoopsModuleConfig['facebook_comments_width'], 'tadgallery', 'view.php', 'sn', $sn);
    $xoopsTpl->assign("facebook_comments", $facebook_comments);
    $fb_tag = "\n      <meta property=\"og:title\" content=\"{$title}\" />\n      <meta property=\"og:description\" content=\"{$description}\" />\n      <meta property=\"og:image\" content=\"" . $tadgallery->get_pic_url($dir, $sn, $filename, "m") . "\" />\n      ";
    $xoopsTpl->assign("xoops_module_header", $fb_tag);
    $xoopsTpl->assign("xoops_pagetitle", $title);
    if (is_object($xoTheme)) {
        $xoTheme->addMeta('meta', 'keywords', $title);
        $xoTheme->addMeta('meta', 'description', $description);
    } else {
        $xoopsTpl->assign('xoops_meta_keywords', 'keywords', $title);
        $xoopsTpl->assign('xoops_meta_description', $description);
    }
}
Example #2
0
function view_pic($sn = "")
{
    global $xoopsDB, $xoopsUser, $xoopsModule, $xoopsModuleConfig, $isAdmin;
    //所有分類名稱
    $cate_all = get_tad_gallery_cate_all();
    $sql = "select csn,title,description,filename,size,type,width,height,dir,uid from " . $xoopsDB->prefix("tad_gallery") . " where sn='{$sn}'";
    $result = $xoopsDB->query($sql) or redirect_header($_SERVER['PHP_SELF'], 3, mysql_error());
    list($csn, $title, $description, $filename, $size, $type, $width, $height, $dir, $uid) = $xoopsDB->fetchRow($result);
    if (!empty($csn)) {
        $ok_cat = tadgallery::chk_cate_power();
        if (!in_array($csn, $ok_cat)) {
            header("location:{$_SERVER['PHP_SELF']}");
        }
    }
    //找出上一張或下一張
    $pnp = get_pre_next($csn, $sn);
    $back_btn = !empty($pnp['pre']) ? " id='pre_photo' onClick=\"location.href='{$_SERVER['PHP_SELF']}?sn={$pnp['pre']}'\"  onkeypress=\"location.href='{$_SERVER['PHP_SELF']}?sn={$pnp['pre']}'\"" : "";
    $next_btn = !empty($pnp['next']) ? " id='next_photo' onClick=\"location.href='{$_SERVER['PHP_SELF']}?sn={$pnp['next']}'\" onkeypress=\"location.href='{$_SERVER['PHP_SELF']}?sn={$pnp['next']}'\" " : "";
    $title = empty($title) ? $filename : $title;
    //計數器
    add_tad_gallery_counter($sn);
    //縮圖
    if ($width / $height > 2) {
        $mpic = getimagesize(tadgallery::get_pic_url($dir, $sn, $filename, "m", "dir"));
        $pic180 = "<marquee width='{$xoopsModuleConfig['thumbnail_m_width']}' behavior='scroll' height='{$mpic[1]}' direction=left scrolldelay=0 scrollamount=3><a href='" . tadgallery::get_pic_url($dir, $sn, $filename) . "'><img src='" . tadgallery::get_pic_url($dir, $sn, $filename, "m") . "'  alt='{$title}' class='instant itiltnone icolorFCFCFC' /></a></marquee>";
    } else {
        if ($width > $height) {
            $new_wh = round($xoopsModuleConfig['thumbnail_m_width'] * $height / $width, 0);
            $pcss = "width:{$xoopsModuleConfig['thumbnail_m_width']}px;height:{$new_wh}px;";
            $pacss = "width:{$new_wh}px;height:{$new_wh}px;";
        } else {
            $new_wh = round($xoopsModuleConfig['thumbnail_m_width'] * $width / $height, 0);
            $new_wh_a = $new_wh / 2;
            $pcss = "width:{$new_wh}px;height:{$xoopsModuleConfig['thumbnail_m_width']}px;";
            $pacss = "width:{$new_wh_a}px;height:{$xoopsModuleConfig['thumbnail_m_width']}px;";
        }
        $photo = tadgallery::get_pic_url($dir, $sn, $filename, "m");
        $pic180 = "\n    <table id='view_photo' style='{$pcss}background-image:url('{$photo}');background-position: top center;background-repeat: no-repeat;background-color: black;'>\n    <tr>\n    <td {$back_btn} style='{$pacss}background-position: top center;background-repeat: no-repeat;border:0px;'></td>\n    <td {$next_btn} style='{$pacss}background-position: top center;background-repeat: no-repeat;border:0px;'></td></tr>\n    </table>\n  ";
    }
    $data = "\n  <table id='main' style='width:100%;'>\n  <tr><td align='center'><a name='photo_top'>{$pic180}</a></td></tr>\n  <tr><td style='color:#E0E0E0;text-align:center'>{$title}</td></tr>\n  <tr><td style='color:#E0E0E0'>" . nl2br($description) . "</td></tr>\n  </table>\n  ";
    return $data;
}