示例#1
0
    mkdir($updir);
    chmod($updir, octdec('0777'));
}
if (!file_exists($updir . '/sizes')) {
    mkdir($updir . '/sizes');
    chmod($updir . '/sizes', octdec('0777'));
}
include RMCPATH . '/class/uploader.php';
$uploader = new RMFileUploader($updir, $cat->max_file_size(), array('gif', 'jpg', 'jpeg', 'png'));
$err = array();
if (!$uploader->fetchMedia('Filedata')) {
    error($uploader->getErrors());
}
if (!$uploader->upload()) {
    error($uploader->getErrors());
}
// Insertamos el archivo en la base de datos
$image = new RMImage();
$image->setVar('title', $uploader->savedFileName);
$image->setVar('date', time());
$image->setVar('file', $uploader->savedFileName);
$image->setVar('cat', $cat->id());
$image->setVar('uid', $xoopsUser->uid());
if (!$image->save()) {
    unlink($uploader->savedDestination);
    error(__('File could not be inserted to database!', 'rmcommon'));
}
$ret['message'] = '1';
$ret['id'] = $image->id();
echo json_encode($ret);
die;
示例#2
0
/**
* Show all images existing in database
*/
function show_images()
{
    global $xoopsModule, $xoopsModuleConfig;
    $db = Database::getInstance();
    // Check if some category exists
    $catnum = RMFunctions::get_num_records("rmc_img_cats");
    if ($catnum <= 0) {
        redirectMsg('images.php?action=newcat', __('There are not categories yet! Please create one in order to add images.', 'rmcommon'), 1);
        die;
    }
    $cat = rmc_server_var($_GET, 'category', 0);
    if ($cat <= 0) {
        header('location: images.php?action=showcats');
        die;
    }
    $sql = "SELECT COUNT(*) FROM " . $db->prefix("rmc_images");
    if ($cat > 0) {
        $sql .= " WHERE cat='{$cat}'";
    }
    /**
     * Paginacion de Resultados
     */
    $page = rmc_server_var($_GET, 'page', 1);
    $limit = $xoopsModuleConfig['imgsnumber'];
    list($num) = $db->fetchRow($db->query($sql));
    $tpages = ceil($num / $limit);
    $page = $page > $tpages ? $tpages : $page;
    $start = $num <= 0 ? 0 : ($page - 1) * $limit;
    $nav = new RMPageNav($num, $limit, $page, 5);
    $nav->target_url('images.php?' . ($cat > 0 ? 'category=' . $cat : '') . '&page={PAGE_NUM}');
    // Get categories
    $sql = "SELECT * FROM " . $db->prefix("rmc_images") . " " . ($cat > 0 ? "WHERE cat='{$cat}'" : '') . " ORDER BY id_img DESC LIMIT {$start},{$limit}";
    $result = $db->query($sql);
    $images = array();
    $categories = array();
    $authors = array();
    $category = new RMImageCategory($cat);
    $sizes = $category->getVar('sizes');
    $current_size = array();
    foreach ($sizes as $size) {
        if (empty($current_size)) {
            $current_size = $size;
        } else {
            if ($current_size['width'] >= $size['width'] && $size['width'] > 0) {
                $current_size = $size;
            }
        }
    }
    while ($row = $db->fetchArray($result)) {
        $img = new RMImage();
        $img->assignVars($row);
        if (!isset($categories[$img->getVar('cat')])) {
            $categories[$img->getVar('cat')] = new RMImageCategory($img->getVar('cat'));
        }
        if (!isset($authors[$img->getVar('uid')])) {
            $authors[$img->getVar('uid')] = new XoopsUser($img->getVar('uid'));
        }
        $fd = pathinfo($img->getVar('file'));
        $images[] = array('id' => $img->id(), 'title' => $img->getVar('title'), 'date' => $img->getVar('date'), 'desc' => $img->getVar('desc', 'n'), 'cat' => $categories[$img->getVar('cat')]->getVar('name'), 'author' => $authors[$img->getVar('uid')], 'file' => XOOPS_UPLOAD_URL . '/' . date('Y', $img->getVar('date')) . '/' . date('m', $img->getVar('date')) . '/sizes/' . $fd['filename'] . '_' . $current_size['width'] . 'x' . $current_size['height'] . '.' . $fd['extension'], 'big' => XOOPS_UPLOAD_URL . '/' . date('Y', $img->getVar('date')) . '/' . date('m', $img->getVar('date')) . '/' . $fd['filename'] . '.' . $fd['extension']);
    }
    $categories = RMFunctions::load_images_categories();
    if (RMFunctions::plugin_installed('lightbox')) {
        RMLightbox::get()->add_element('#list-images a.bigimages');
        RMLightbox::get()->render();
    }
    xoops_cp_header();
    RMFunctions::create_toolbar();
    RMTemplate::get()->add_style('imgmgr.css', 'rmcommon');
    RMTemplate::get()->add_style('general.css', 'rmcommon');
    RMTemplate::get()->add_script('include/js/jquery.checkboxes.js');
    include RMTemplate::get()->get_template('images_images.php', 'module', 'rmcommon');
    xoops_cp_footer();
}
示例#3
0
        } else {
            if ($current_size['width'] >= $size['width'] && $size['width'] > 0) {
                $current_size = $size;
            }
        }
    }
    while ($row = $db->fetchArray($result)) {
        $img = new RMImage();
        $img->assignVars($row);
        $fd = pathinfo($img->getVar('file'));
        $filesurl = XOOPS_UPLOAD_URL . '/' . date('Y', $img->getVar('date')) . '/' . date('m', $img->getVar('date'));
        $thumb = date('Y', $img->getVar('date')) . '/' . date('m', $img->getVar('date')) . '/sizes/' . $fd['filename'] . '-' . $current_size['name'] . '.' . $fd['extension'];
        if (!file_exists(XOOPS_UPLOAD_PATH . '/' . $thumb)) {
            $thumb = date('Y', $img->getVar('date')) . '/' . date('m', $img->getVar('date')) . '/' . $fd['filename'] . '.' . $fd['extension'];
        }
        $images[] = array('id' => $img->id(), 'title' => $img->getVar('title'), 'thumb' => XOOPS_UPLOAD_URL . '/' . $thumb);
    }
    include RMTemplate::get()->get_template('rmc-images-list-editor.php', 'module', 'rmcommon');
} elseif ($action == 'image-details') {
    function images_send_json($data)
    {
        header('Cache-Control: no-cache, must-revalidate');
        header('Expires: Mon, 26 Jul 1997 05:00:00 GMT');
        header('Content-type: application/json');
        echo json_encode($data);
        die;
    }
    if (!$xoopsSecurity->check()) {
        images_send_json(array('message' => _e('Sorry, unauthorized operation!', 'rmcommon'), 'error' => 1));
    }
    $id = RMHttpRequest::post('id', 'integer', 0);
示例#4
0
    $current_size = array();
    foreach ($sizes as $size) {
        if (empty($current_size)) {
            $current_size = $size;
        } else {
            if ($current_size['width'] >= $size['width'] && $size['width'] > 0) {
                $current_size = $size;
            }
        }
    }
    $mimes = (include XOOPS_ROOT_PATH . '/include/mimetypes.inc.php');
    while ($row = $db->fetchArray($result)) {
        $img = new RMImage();
        $img->assignVars($row);
        if (!isset($categories[$img->getVar('cat')])) {
            $categories[$img->getVar('cat')] = new RMImageCategory($img->getVar('cat'));
        }
        if (!isset($authors[$img->getVar('uid')])) {
            $authors[$img->getVar('uid')] = new XoopsUser($img->getVar('uid'));
        }
        $fd = pathinfo($img->getVar('file'));
        $filesurl = XOOPS_UPLOAD_URL . '/' . date('Y', $img->getVar('date')) . '/' . date('m', $img->getVar('date'));
        $thumb = date('Y', $img->getVar('date')) . '/' . date('m', $img->getVar('date')) . '/sizes/' . $fd['filename'] . '_' . $current_size['width'] . 'x' . $current_size['height'] . '.' . $fd['extension'];
        if (!file_exists(XOOPS_UPLOAD_PATH . '/' . $thumb)) {
            $thumb = date('Y', $img->getVar('date')) . '/' . date('m', $img->getVar('date')) . '/' . $fd['filename'] . '.' . $fd['extension'];
        }
        $ret = array('id' => $img->id(), 'title' => $img->getVar('title'), 'date' => formatTimestamp($img->getVar('date'), 'l'), 'desc' => $img->getVar('desc', 'n'), 'cat' => $categories[$img->getVar('cat')]->getVar('name'), 'author' => $authors[$img->getVar('uid')], 'thumb' => XOOPS_UPLOAD_URL . '/' . $thumb, 'url' => $filesurl, 'file' => $fd['filename'], 'extension' => $fd['extension'], 'mime' => isset($mimes[$fd['extension']]) ? $mimes[$fd['extension']] : 'application/octet-stream', 'links' => array('file' => array('caption' => __('File URL', 'rmcommon'), 'value' => XOOPS_UPLOAD_URL . '/' . date('Y', $img->getVar('date')) . '/' . date('m', $img->getVar('date')) . '/' . $img->getVar('file')), 'none' => array('caption' => __('None', 'rmcommon'), 'value' => '')));
        $images[] = RMEvents::get()->run_event('rmcommon.loading.single.editorimgs', $ret, rmc_server_var($_REQUEST, 'url', ''));
    }
    include RMTemplate::get()->get_template('images_list_editor.php', 'module', 'rmcommon');
}
示例#5
0
$data['siterate'] = $dtfunc->ratingStars($item->getVar('siterate'));
$fg = $item->fileGroups(true);
$data['filegroups'] = array();
foreach ($fg as $g) {
    $files = $g->files(true);
    $data['filegroups'][$g->id()]['name'] = $g->name();
    foreach ($files as $file) {
        $data['filegroups'][$g->id()]['files'][] = array('file' => $file->file(), 'size' => $rmu->formatBytesSize($file->size()), 'date' => $tf->format($file->date()), 'title' => $file->title(), 'remote' => $file->remote(), 'hits' => $file->hits(), 'link' => $file->permalink());
    }
}
// Imágenes de la Descarga
$imgs = $item->screens(true);
$xoopsTpl->assign('screens_count', $item->getVar('screens'));
$data['screens'] = array();
foreach ($imgs as $img) {
    $data['screens'][] = array('id' => $img->id(), 'title' => $img->title(), 'image' => $img->url(), 'ths' => $img->url('ths'));
}
unset($imgs, $img);
//Etiquetas
$tags = $item->tags(false);
$relatedTags = array();
$data['tags'] = array();
foreach ($tags as $tag) {
    $otag = new DTTag();
    $otag->assignVars($tag);
    $data['tags'][] = array('id' => $tag['id_tag'], 'name' => $tag['tag'], 'link' => $otag->permalink());
    $relatedTags[] = $tag['id_tag'];
}
unset($tags, $otag, $tag);
// Categories
$cats = $item->categories(true);