function links_stat($type)
{
    global $xoopsDB, $xoopsModuleConfig;
    $labs = array('m' => array(_AM_LTYPE_MEDIA, 'm'), 'a' => array(_AM_LTYPE_DOCUMENT, 'a'));
    echo "<div><em>" . _AM_SUMMARY_TYPE . "</em> ";
    foreach ($labs as $k => $lab) {
        echo " &nbsp; ";
        if ($type == $k) {
            echo "[<b>" . $lab[0] . "</b>]";
        } else {
            echo "<a href='summary.php?type=" . $lab[1] . "'>" . $lab[0] . "</a>";
        }
    }
    echo "</div>\n";
    $res = $xoopsDB->query(sql_stat($type, true));
    list($count) = $xoopsDB->fetchRow($res);
    $start = isset($_GET['start']) ? intval($_GET['start']) : 0;
    $max = $xoopsModuleConfig['max_rows'];
    $res = $xoopsDB->query(sql_stat($type), $max, $start);
    $nav = new XoopsPageNav($count, $max, $start, "start", 'type=' . $type);
    echo "<table width='100%'>\n";
    echo "<tr><td>" . _AM_COUNT . " " . $count . "</td><td>";
    if ($count > $max) {
        echo ' &nbsp; ' . _AM_PAGE . ' ' . $nav->renderNav();
    }
    echo "</td><td align='right'>[<a href='summary.php?type={$type}&export=csv'>" . _AM_EXPORT_FILE . "</a>]</td></tr>\n";
    echo "</table>\n";
    echo "<table cellspacing='1' class='outer'>\n";
    $head = array(_AM_TITLE, _AM_LINKNAME, "URL", _AM_HITS);
    echo "<tr><th>" . join("</th><th>", $head) . "</th></tr>\n";
    $n = 0;
    $lmax = 35;
    while ($data = $xoopsDB->fetchArray($res)) {
        $bg = $n++ % 2 ? 'even' : 'odd';
        $mid = $data['mid'];
        $url = $data['url'];
        $aurl = htmlspecialchars(get_upload_url($mid, $url));
        $title = "<a href='../detail.php?mid={$mid}'>" . htmlspecialchars($data['title']) . "</a>";
        $link = htmlspecialchars($data['name']);
        $hits = $data['hits'];
        if (strlen($url) < $lmax) {
            $aname = $url;
        } else {
            $aname = '...' . substr($url, 3 - $lmax);
        }
        echo "<tr class='{$bg}'><td>{$title}</td><td>{$link}</td><td>" . "<a href='{$aurl}'>" . htmlspecialchars($aname) . "</a></td><td align='right'>{$hits}</td></tr>\n";
    }
    echo "</table>\n";
}
function ml_screenshot($mid)
{
    global $ml_shotopts;
    $path = get_upload_path($mid, _ML_SHOTNAME);
    if (!file_exists($path)) {
        global $xoopsDB;
        $res = $xoopsDB->query("SELECT url FROM " . $xoopsDB->prefix('medialinks_attach') . " WHERE midref={$mid} AND ltype='m' ORDER BY weight,linkid", 1);
        list($url) = $xoopsDB->fetchRow($res);
        if (preg_match('/^(\\w+:)\\//', $url)) {
            // get temporarily for screenshot
            $vfile = get_upload_path($mid, basename($url));
            if (!file_exists($vfile)) {
                // already get?
                if (!is_dir(dirname($vfile))) {
                    mkdir(dirname($vfile));
                }
                system("wget -q -O '{$vfile}' '{$url}'");
                $temp = $vfile;
            }
        } else {
            $vfile = get_upload_path($mid, $url);
        }
        if (file_exists($vfile)) {
            global $mlModuleConfig;
            // NOTE: this script refer from blocks
            $opts = $mlModuleConfig['shotopts'];
            $cmdpath = $mlModuleConfig['cmdpath'];
            if (!empty($cmdpath)) {
                putenv("PATH={$cmdpath}");
            }
            if (preg_match(_VIDEO_EXT, $vfile)) {
                system("ffmpeg -i \"{$vfile}\" {$opts} -vcodec mjpeg -vframes 1 -an -f rawvideo -y \"{$path}\"");
            } elseif (preg_match(_IMAGE_EXT, $vfile)) {
                system("convert \"{$vfile}\" -resize 320 \"{$path}\"");
            }
            if (filesize($path) == 0) {
                unlink($path);
            }
        }
    }
    if (!file_exists($path)) {
        $mydirname = basename(dirname(__FILE__));
        return XOOPS_URL . "/modules/{$mydirname}/images/nodata.png";
    }
    if (!empty($temp) && file_exists($temp)) {
        unlink($temp);
    }
    return get_upload_url($mid, _ML_SHOTNAME);
}
Example #3
0
 function get_file_description()
 {
     $image = $this->value;
     return '<img src="' . (strstr($image, 'http://') ? $image : get_upload_url() . '/' . $image) . '" alt="" height="100" class="pecf-view_image"/>';
     //return '<img src="' . get_option('home') . '/wp-content/uploads/' . $this->value . '" alt="" height="100" class="pecf-view_image"/>';
 }
Example #4
0
include "../../mainfile.php";
include_once "perm.php";
include_once XOOPS_ROOT_PATH . '/class/template.php';
$lid = isset($_GET['lid']) ? intval($_GET['lid']) : 0;
$mydirname = basename(dirname(__FILE__));
if ($lid) {
    $res = $xoopsDB->query("SELECT url,name,midref FROM " . $xoopsDB->prefix('medialinks_attach') . " WHERE linkid=" . $lid);
}
if (!$lid || !$res || $xoopsDB->getRowsNum($res) == 0) {
    redirect_header('index.php', 3, _NOPERM);
    exit;
}
list($url, $name, $mid) = $xoopsDB->fetchRow($res);
$xoopsDB->queryF("UPDATE " . $xoopsDB->prefix('medialinks_attach') . " SET hits=hits+1 WHERE linkid=" . $lid);
if (!preg_match('/^(\\w+:)?\\//', $url)) {
    $url = get_upload_url($mid) . "/{$url}";
}
if (preg_match('/\\.flv$/i', $url)) {
    $url = XOOPS_URL . "/modules/{$mydirname}/flvplayer.swf?file={$url}";
}
if (XOOPS_USE_MULTIBYTES && function_exists('mb_convert_encoding')) {
    function enc($text, $code = 'SJIS')
    {
        return mb_convert_encoding($text, $code, _CHARSET);
    }
} else {
    function enc($text)
    {
        return $text;
    }
}
 function get_file_description()
 {
     return '<img src="' . get_upload_url() . '/' . $this->value . '" alt="" height="100" class="ecf-view_image"/>';
 }
 function getAttach($type = null, $exp = false)
 {
     if ($type == null) {
         return $this->attach;
     }
     $id = intval($type);
     if ($id) {
         return $this->attach[$id];
     }
     $attach = array();
     $type = strtolower($type);
     $mid = $this->getVar('mid');
     foreach ($this->attach as $data) {
         if ($exp) {
             if (empty($data['name'])) {
                 $data['name'] = basename($data['url']);
             }
             $data['url'] = get_upload_url($mid, $data['url']);
             if ($type == 'm' && count($attach) == 0 && file_exists(get_upload_path($mid, _ML_SHOTNAME))) {
                 $data['shotimg'] = get_upload_url($mid, _ML_SHOTNAME);
             }
         }
         if (strtolower($data['ltype']) == $type) {
             $attach[] = $data;
         }
     }
     return $attach;
 }