当前位置: 首页>>代码示例>>PHP>>正文


PHP OOMedia::getMediaByFilename方法代码示例

本文整理汇总了PHP中OOMedia::getMediaByFilename方法的典型用法代码示例。如果您正苦于以下问题:PHP OOMedia::getMediaByFilename方法的具体用法?PHP OOMedia::getMediaByFilename怎么用?PHP OOMedia::getMediaByFilename使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在OOMedia的用法示例。


在下文中一共展示了OOMedia::getMediaByFilename方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: securefile

function securefile($_params)
{
    global $REX;
    $myself = 'xmediapool_password';
    $m = OOMedia::getMediaByFilename($_params['filename']);
    $password = $m->getValue('med_' . $myself . '_password');
    // htaccess-Datei auslesen
    $htaccess_path = rtrim($REX['MEDIAFOLDER'], '/\\') . '/.htaccess';
    $htaccess = '';
    if (file_exists($htaccess_path)) {
        $htaccess = file_get_contents($htaccess_path);
    }
    // RewriteBase ermitteln
    $base = trim(str_replace('\\', '/', substr(realpath($REX['MEDIAFOLDER']), strlen(realpath($_SERVER['DOCUMENT_ROOT'])))), '/');
    $frontend = str_replace('//', '/', '/' . trim(str_replace('\\', '/', substr(realpath($REX['FRONTEND_PATH']), strlen(realpath($_SERVER['DOCUMENT_ROOT'])))), '/') . '/');
    $lines = array();
    $lines[] = "RewriteEngine On\nRewriteBase /" . $base;
    // vorhandene Passwort geschützte Dateien auslesen
    $already_secured = false;
    if (preg_match_all('~^RewriteRule \\^(.*)\\$\\s.*$~im', $htaccess, $matches, PREG_SET_ORDER)) {
        foreach ($matches as $match) {
            // Wenn bei einer Datei ein Passwort gelöscht wurde, dann diese Datei nicht mehr schützen
            if ($match[1] == preg_quote($_params['filename'], '~')) {
                if (!strlen($password)) {
                    continue;
                } else {
                    $already_secured = true;
                }
            }
            $lines[] = sprintf('RewriteRule ^%s$ http://%%{HTTP_HOST}%s%s [R=302,L]', $match[1], $frontend, ltrim(rex_geturl($REX['ADDON']['DOWNLOAD_FORM_ARTICLE_ID'][$myself], '', array($myself . '_filename' => stripslashes($match[1])), '&'), '/'));
        }
    }
    // neue passwortgeschützte Datei hinzufügen
    if (!$already_secured and strlen($password)) {
        $lines[] = sprintf('RewriteRule ^%s$ http://%%{HTTP_HOST}/%s%s [R=302,L]', preg_quote($_params['filename'], '~'), $frontend, ltrim(rex_geturl($REX['ADDON']['DOWNLOAD_FORM_ARTICLE_ID'][$myself], '', array($myself . '_filename' => $_params['filename']), '&'), '/'));
    }
    // Daten in die htaccess-Datei schreiben
    file_put_contents($htaccess_path, implode("\n", $lines));
}
开发者ID:olien,项目名称:xmediapool_password,代码行数:39,代码来源:config.inc.php

示例2: elseif

<?php

// module: magnific_popup_image_out
$imageType = 'magnific_popup_image_thumb';
$imageFile = 'REX_MEDIA[1]';
if ($imageFile != '') {
    $media = OOMedia::getMediaByFilename($imageFile);
    // get title and description
    if (OOMedia::isValid($media)) {
        $title = $media->getValue('title');
        $description = $media->getValue('med_description');
    } else {
        $title = '';
        $description = '';
    }
    // get media dir
    if (isset($REX['MEDIA_DIR'])) {
        $mediaDir = $REX['MEDIA_DIR'];
    } else {
        $mediaDir = 'files';
    }
    // generate image manager url
    if (method_exists('seo42', 'getImageManagerFile')) {
        $imageManagerUrl = seo42::getImageManagerFile($imageFile, $imageType);
        $imageUrl = seo42::getMediaDir() . $imageFile;
    } elseif (method_exists('seo42', 'getImageManagerUrl')) {
        // compat
        $imageManagerUrl = seo42::getImageManagerUrl($imageFile, $imageType);
        $imageUrl = seo42::getMediaDir() . $imageFile;
    } else {
        $imageUrl = $REX['HTDOCS_PATH'] . $mediaDir . '/' . $imageFile;
开发者ID:darwin26,项目名称:magnific_popup,代码行数:31,代码来源:output.php


注:本文中的OOMedia::getMediaByFilename方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。