function rex_image($filepath)
 {
     global $REX;
     // ----- check params
     if (!file_exists($filepath)) {
         $this->sendError('Imagefile does not exist - ' . $filepath);
         exit;
     }
     // ----- check filesize
     $max_file_size = $REX['ADDON']['image_manager']['max_resizekb'] * 1024;
     $filesize = filesize($filepath);
     if ($filesize > $max_file_size) {
         $error = 'Imagefile is to big.';
         $error .= ' Only files < ' . $REX['ADDON']['image_manager']['max_resizekb'] . 'kb are allowed';
         $error .= '- ' . $filepath . ', ' . OOMedia::_getFormattedSize($filesize);
         $this->sendError($error);
         exit;
     }
     // ----- imagepfad speichern
     $this->img = array();
     $this->img['file'] = basename($filepath);
     $this->img['filepath'] = $filepath;
     $this->img['quality'] = $REX['ADDON']['image_manager']['jpg_quality'];
     $this->img['format'] = strtoupper(OOMedia::_getExtension($this->img['filepath']));
 }
 function isCached($image, $cacheParams)
 {
     if (!rex_image::isValid($image)) {
         trigger_error('Given image is not a valid rex_image', E_USER_ERROR);
     }
     $original_cache_file = $this->getCacheFile($image, $cacheParams);
     $cache_files = glob($original_cache_file . '*');
     // ----- check for cache file
     if (is_array($cache_files) && count($cache_files) == 1) {
         $cache_file = $cache_files[0];
         // time of cache
         $cachetime = filectime($cache_file);
         $imagepath = $image->getFilePath();
         if ($original_cache_file != $cache_file) {
             $image->img['format'] = strtoupper(OOMedia::_getExtension($cache_file));
             $image->img['file'] = $image->img['file'] . '.' . OOMedia::_getExtension($cache_file);
         }
         // file exists?
         if (file_exists($imagepath)) {
             $filetime = filectime($imagepath);
         } else {
             // Missing original file for cache-validation!
             $image->sendErrorImage();
         }
         // cache is newer?
         if ($cachetime > $filetime) {
             return true;
         }
     }
     return false;
 }
 function execute()
 {
     global $REX;
     $from_path = realpath($this->image->img['filepath']);
     if (($ext = self::getExtension($from_path)) && in_array(strtolower($ext), self::$convert_types)) {
         // convert possible
         $convert_path = self::getConvertPath();
         if ($convert_path != '') {
             // convert to image and save in tmp
             $to_path = $REX['GENERATED_PATH'] . '/files/image_manager__convert2img_' . md5($this->image->img['filepath']) . '_' . $this->image->img['file'] . '.png';
             $cmd = $convert_path . ' -density 150 "' . $from_path . '[0]" -colorspace RGB "' . $to_path . '"';
             // echo $cmd;
             exec($cmd, $out, $ret);
             if ($ret != 0) {
                 return false;
             }
             $this->image->img['file'] = $this->image->img['file'] . '.png';
             $this->image->img['filepath'] = $to_path;
             $this->image->img['format'] = strtoupper(OOMedia::_getExtension($to_path));
             $this->tmp_imagepath = $to_path;
             $this->image->prepare();
         }
     } else {
         // no image
     }
     return;
 }
 /**
  * @access public
  */
 function searchCategoryByName($name)
 {
     $query = 'SELECT id FROM ' . OOMedia::getTableName() . ' WHERE name = "' . addslashes($name) . '"';
     $sql = new sql();
     $result = $sql->get_array($query);
     $media = array();
     foreach ($result as $line) {
         $media[] = OOMediaCategory::getCategoryById($line['id']);
     }
     return $media;
 }
 function get()
 {
     $section =& $this->getSection();
     $form = $section->getForm();
     // Buttons erst hier einfügen, da vorher die ID noch nicht vorhanden ist
     $this->addButton('Medienpool öffnen', 'javascript:openMediaPool(\'&amp;opener_form=' . $form->getName() . '&amp;opener_input_field=' . $this->getId() . '\');');
     $this->addButton('Medium entfernen', 'javascript:setValue(\'' . $this->getId() . '\',\'\');', 'file_del.gif');
     $this->addButton('Medium hinzufügen', 'javascript:openMediaPool(\'&amp;action=media_upload&amp;subpage=add_file&amp;opener_form=' . $form->getName() . '&amp;opener_input_field=' . $this->getId() . '\');', 'file_add.gif');
     $preview = '';
     if ($this->isPreviewEnabled() && $this->getValue() != '' && OOMedia::_isImage($this->getValue())) {
         $preview = '<img class="preview" src="' . $this->previewUrl($this->getValue()) . '" />';
     }
     return $preview . parent::get();
 }
 function rex_image($filepath)
 {
     global $REX;
     // ----- check params
     if (!file_exists($filepath)) {
         // 'Imagefile does not exist - '. $filepath
         $this->sendErrorImage();
     }
     // ----- imagepfad speichern
     $this->img = array();
     $this->img['file'] = basename($filepath);
     $this->img['filepath'] = $filepath;
     $this->img['quality'] = $REX['ADDON']['image_manager']['jpg_quality'];
     $this->img['format'] = strtolower(OOMedia::_getExtension($this->img['filepath']));
 }
 function rex_thumbnail($imgfile)
 {
     global $REX;
     // ----- imagepfad speichern
     $this->img = array();
     $this->imgfile = $imgfile;
     // ----- gif support ?
     $this->gifsupport = function_exists('imageGIF');
     // ----- detect image format
     $this->img['format'] = strtoupper(OOMedia::_getExtension($imgfile));
     $this->img['src'] = false;
     if (strpos($imgfile, 'cache/') === false) {
         if ($this->img['format'] == 'JPG' || $this->img['format'] == 'JPEG') {
             // --- JPEG
             $this->img['format'] = 'JPEG';
             $this->img['src'] = @ImageCreateFromJPEG($imgfile);
         } elseif ($this->img['format'] == 'PNG') {
             // --- PNG
             $this->img['src'] = @ImageCreateFromPNG($imgfile);
         } elseif ($this->img['format'] == 'GIF') {
             // --- GIF
             if ($this->gifsupport) {
                 $this->img['src'] = @ImageCreateFromGIF($imgfile);
             }
         } elseif ($this->img['format'] == 'WBMP') {
             // --- WBMP
             $this->img['src'] = @ImageCreateFromWBMP($imgfile);
         }
         // ggf error image senden
         if (!$this->img['src']) {
             $this->sendError();
             exit;
         }
         $this->img['width'] = imagesx($this->img['src']);
         $this->img['height'] = imagesy($this->img['src']);
         $this->img['width_offset_thumb'] = 0;
         $this->img['height_offset_thumb'] = 0;
         // --- default quality jpeg
         $this->img['quality'] = $REX['ADDON']['image_resize']['jpg_quality'];
         $this->filters = array();
     }
 }
Example #8
0
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));
}
Example #9
0
 /**
  * Execute the search for the given SearchCommand
  *
  * @param  SearchCommand $search
  * @return SearchResult
  */
 public function fire(SearchCommand $search)
 {
     $search_result = new SearchResult();
     $fields = array('filename', 'title');
     $s = \rex_sql::factory();
     $s->setQuery('SELECT * FROM ' . Watson::getTable('file') . ' LIMIT 0');
     $fieldnames = $s->getFieldnames();
     foreach ($fieldnames as $fieldname) {
         if (substr($fieldname, 0, 4) == 'med_') {
             $fields[] = $fieldname;
         }
     }
     $sql_query = ' SELECT      filename,
                                 title
                     FROM        ' . Watson::getTable('file') . '
                     WHERE       ' . $search->getSqlWhere($fields) . '
                     ORDER BY    filename';
     $results = $this->getDatabaseResults($sql_query);
     if (count($results)) {
         foreach ($results as $result) {
             $title = $result['title'] != '' ? ' (' . Watson::translate('watson_media_title') . ': ' . $result['title'] . ')' : '';
             $entry = new SearchResultEntry();
             $entry->setValue($result['filename']);
             $entry->setDescription(Watson::translate('watson_open_media') . $title);
             $entry->setIcon('icon_media.png');
             $entry->setUrl('javascript:newPoolWindow(\'' . Watson::getUrl(array('page' => 'mediapool', 'subpage' => 'detail', 'file_name' => $result['filename'])) . '\')');
             $m = \OOMedia::getMediaByFileName($result['filename']);
             if ($m instanceof \OOMedia) {
                 if ($m->isImage()) {
                     $entry->setQuickLookUrl(Watson::getUrl(array('rex_img_type' => 'rex_mediapool_maximized', 'rex_img_file' => $result['filename'])));
                 }
             }
             $search_result->addEntry($entry);
         }
     }
     return $search_result;
 }
Example #10
0
 public static function getImageTag($imageFile, $imageType = '', $width = 0, $height = 0)
 {
     $media = OOMedia::getMediaByFileName($imageFile);
     // make sure media object is valid
     if (OOMedia::isValid($media)) {
         $mediaWidth = $media->getWidth();
         $mediaHeight = $media->getHeight();
         $altAttribute = $media->getTitle();
     } else {
         $mediaWidth = '';
         $mediaHeight = '';
         $altAttribute = '';
     }
     // image width
     if ($width == 0) {
         $imgWidth = $mediaWidth;
     } else {
         $imgWidth = $width;
     }
     // image height
     if ($height == 0) {
         $imgHeight = $mediaHeight;
     } else {
         $imgHeight = $height;
     }
     // get url
     if ($imageType == '') {
         $url = self::getMediaFile($imageFile);
     } else {
         $url = self::getImageManagerFile($imageFile, $imageType);
     }
     return '<img src="' . $url . '" width="' . $imgWidth . '" height="' . $imgHeight . '" alt="' . $altAttribute . '" />';
 }
Example #11
0
    function showList($eingeloggt = FALSE, $msg = "", $returnUrl = false)
    {
        $I18N_NEWS_DB = new i18n(REX_LANG, REX_INCLUDE_PATH . '/addons/' . MY_PAGE . '/lang');
        if (!empty($msg)) {
            print "<div class=\"msg\">{$msg}</div>\n";
        }
        $conf['max'] = $this->num == "" ? $conf['max'] = 10 : $this->num;
        $conf['page'] = $_GET['page'] ? $_GET['page'] : 1;
        if ($this->pagination == 0) {
            $conf['page'] = 1;
        }
        $conf['page'] = (int) $conf['page'];
        if ($this->archive == "" or $this->archive == "0") {
            $addWhere = 'WHERE (
                    ((offline_date = "0000-00-00") OR (REPLACE(offline_date, "-", "") > CURDATE() + 0))
                    AND
                    ((archive_date = "0000-00-00") OR REPLACE(archive_date, "-", "") > CURDATE() + 0)
                    AND 
                    ((online_date = "0000-00-00") OR REPLACE(online_date, "-", "") <= CURDATE() + 0)
            )';
        } elseif ($this->archive == "1") {
            $addWhere = 'WHERE (
                    (
                        (offline_date != "0000-00-00") AND (REPLACE(offline_date, "-", "") > CURDATE() + 0)
                        OR (offline_date = "0000-00-00")
                    )
                    AND
                    ((archive_date != "0000-00-00") AND REPLACE(archive_date, "-", "") <= CURDATE() + 0)
                    AND 
                    ((online_date = "0000-00-00") OR REPLACE(online_date, "-", "") <= CURDATE() + 0)
             )';
        } else {
            $addWhere = 'WHERE (
                    ((offline_date = "0000-00-00") OR (REPLACE(offline_date, "-", "") > CURDATE() + 0))
                    AND
                    ((online_date = "0000-00-00") OR REPLACE(online_date, "-", "") <= CURDATE() + 0)
            )';
        }
        $_cat = $_GET['cat'];
        if (isset($_cat)) {
            $addSQL = 'AND category LIKE "%|' . $_cat . '|%" ';
        }
        if ($this->category > 0 and $this->category != 999) {
            $addSQL = 'AND category LIKE "%|' . $this->category . '|%" ';
        }
        if ($this->active == 0) {
            $addSQL .= 'AND status = "0" ';
        }
        if ($this->active == 1) {
            $addSQL .= 'AND status = "1" ';
        }
        if ($this->language != "") {
            $addSQL .= 'AND clang = ' . $this->language;
        }
        if ($this->view == 1) {
            $addSQL .= ' AND flag = 1';
        } else {
            if ($this->view == 2) {
                $addSQL .= ' AND flag = 0';
            }
        }
        // 21.04.2013: StickyNews auf Startseite priorisiert
        $addSticky = $addOrderBy = "";
        if ($this->id == $this->start_article_id) {
            $addSticky = ',
				CASE 
				WHEN REPLACE(stickyUntil, "-", "") > CURDATE() + 0 THEN true
				ELSE false
				END as st		
			';
            $addOrderBy = 'st DESC, ';
        }
        $qry = 'SELECT * ' . $addSticky . '
				FROM ' . TBL_NEWS . ' 
				' . $addWhere . '
				' . $addSQL . '
				ORDER BY ' . $addOrderBy . 'online_date ' . $this->sort;
        if ($result = mysql_query($qry)) {
            $total = mysql_num_rows($result);
        }
        $pnum = round(ceil($total / $conf['max']), $conf['max']);
        $limitStart = ($conf['page'] - 1) * $conf['max'];
        $limitEnd = $conf['max'];
        $qry .= ' LIMIT ' . $limitStart . ',' . $limitEnd;
        $sql = new rex_sql();
        if ($this->debug == 1) {
            $sql->debugsql = true;
        }
        $data = $sql->getArray($qry);
        if ($this->pagination == 1 and $total > $conf['max']) {
            $pager['jumplist'] = self::drawJumplist(rex_getUrl('', '', array("page" => 'SEITENZAHL'), '&amp;'), "&lt;", " ", "&gt;", $conf['page'], $pnum);
        }
        // http://www.redaxo.org/de/forum/addons-f30/news-addon-d-mind-t18730.html
        if (!class_exists('Smarty')) {
            include 'redaxo/include/addons/news/libs/Smarty.class.php';
        }
        $t = new Smarty();
        $t->debugging = false;
        $t->caching = false;
        $t->cache_lifetime = 120;
        $t->config_dir = 'redaxo/include/addons/news/view/configs/';
        $t->compile_dir = 'redaxo/include/addons/news/view/templates_c/';
        $t->cache_dir = 'redaxo/include/addons/news/view/cache/';
        $t->template_dir = 'redaxo/include/addons/news/view/templates/';
        if (is_array($data) && sizeof($data) > 0) {
            $i = 1;
            foreach ($data as $row) {
                // Selbe News ausschliessen, falls in rechter Spalte Liste
                if ($row['id'] == rex_request('newsid')) {
                    continue;
                }
                include "redaxo/include/addons/" . MY_PAGE . "/conf/conf.php";
                if ($this->detailArticle) {
                    if ($REX_NEWS_CONF['rewrite'] == 1) {
                        $url = self::rewriteNewsUrls($row['name'], $row['id']);
                    } else {
                        $url = rex_getUrl($this->detailArticle, $this->language, array('newsid' => $row['id']), '&amp;');
                    }
                }
                $item[$i]['id'] = $row['id'];
                $item[$i]['name'] = $row['name'];
                $item[$i]['url'] = $url;
                $item[$i]['date'] = $this->rex_news_format_date($row['online_date'], $this->language);
                $item[$i]['source'] = $row["source"];
                $teaser = "";
                if ($row['teaser'] != "") {
                    $teaser = $row['teaser'];
                    $item[$i]['teaser'] = $teaser;
                } else {
                    $teaser2 = htmlspecialchars_decode($row["article"]);
                    $teaser2 = str_replace("<br />", "", $teaser);
                    $teaser2 = rex_a79_textile($teaser);
                    $teaser2 = str_replace("###", "&#x20;", $teaser);
                    $teaser2 = strip_tags($teaser);
                    $item[$i]['teaser'] = substr($teaser2, 0, strpos($teaser2, ".", 80) + 1);
                }
                $text = htmlspecialchars_decode($row["article"]);
                $text = str_replace("<br />", "", $text);
                $text = rex_a79_textile($text);
                $text = str_replace("###", "&#x20;", $text);
                $text = strip_tags($text);
                $item[$i]['text'] = $text;
                if ($row["thumb"] != "" and $this->images == true) {
                    // Bildausgabe
                    $images = explode(",", $row["thumb"]);
                    if (file_exists($REX['HTDOCS_PATH'] . 'files/' . $images[0])) {
                        $media = OOMedia::getMediaByName($images[0]);
                        if (is_array($media) and sizeof($media) > 0) {
                            $mediaTitle = $media->getValue('title');
                            $MediaDesc = $media->getValue('med_description');
                        }
                    }
                    $item[$i]['image'] = '<a href="' . $url . '" title="' . $row['name'] . '"><img src="index.php?rex_img_type=' . $REX_NEWS_CONF['image_list_type'] . '&amp;rex_img_file=' . $images[0] . '" title="' . $mediaTitle . '" alt="' . $MediaDesc . '" /></a>';
                }
                $i++;
            }
        }
        $t->assign("pager", $pager);
        $t->assign("data", $item);
        $t->display($this->template);
    }
Example #12
0
<?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;
/**
 * check if mediatpye(extension) is allowed for upload
 *
 * @param string $filename
 * @param array  $args
 * @return  bool
 */
function rex_mediapool_isAllowedMediaType($filename, $args = array())
{
    $file_ext = '.' . OOMedia::_getExtension($filename);
    if ($filename === '' || strpos($file_ext, ' ') !== false || $file_ext === '.') {
        return false;
    }
    $blacklist = rex_mediapool_getMediaTypeBlacklist();
    $whitelist = rex_mediapool_getMediaTypeWhitelist($args);
    if (in_array($file_ext, $blacklist)) {
        return false;
    }
    if (count($whitelist) > 0 && !in_array($file_ext, $whitelist)) {
        return false;
    }
    return true;
}
 function _formatRexMedia($value, $format)
 {
     if (!is_array($format)) {
         $format = array();
     }
     $params = $format['params'];
     // Resize aktivieren, falls nicht anders übergeben
     if (empty($params['resize'])) {
         $params['resize'] = true;
     }
     $media = OOMedia::getMediaByName($value);
     // Bilder als Thumbnail
     if ($media->isImage()) {
         $value = $media->toImage($params);
     } else {
         $value = $media->toIcon();
     }
     return $value;
 }
     $rex_file_category = 0;
 }
 // function in function.rex_mediapool.inc.php
 $return = rex_mediapool_saveMedia($_FILES['file_new'], $rex_file_category, $FILEINFOS, $REX['USER']->getValue("login"));
 $info = $return['msg'];
 $subpage = "";
 // ----- EXTENSION POINT
 if ($return['ok'] == 1) {
     rex_register_extension_point('MEDIA_ADDED', '', $return);
 }
 if (rex_post('saveandexit', 'boolean') && $return['ok'] == 1) {
     $file_name = $return['filename'];
     $ffiletype = $return['type'];
     $title = $return['title'];
     if ($opener_input_field == 'TINYIMG') {
         if (OOMedia::_isImage($file_name)) {
             $js = "insertImage('{$file_name}','{$title}');";
         }
     } elseif ($opener_input_field == 'TINY') {
         $js = "insertLink('" . $file_name . "');";
     } elseif ($opener_input_field != '') {
         if (substr($opener_input_field, 0, 14) == "REX_MEDIALIST_") {
             $js = "selectMedialist('" . $file_name . "');";
         } else {
             $js = "selectMedia('" . $file_name . "');";
         }
     }
     echo "<script language=javascript>\n";
     echo $js;
     // echo "\nself.close();\n";
     echo "</script>";
Example #16
0
<?php

if ('REX_MEDIA[1]') {
    $bild = OOMedia::getMediaByName('REX_MEDIA[1]');
    $bildTitle = $bild->getTitle();
    $bildDateiName = $bild->getFileName();
    $bildBreite = $bild->getWidth();
    $bildHoehe = $bild->getHeight();
    $focuspoint_css = $bild->getValue('med_focuspoint_css');
    $focuspoint_data = explode(",", $bild->getValue('med_focuspoint_data'), 2);
    if (count($focuspoint_data) == 2) {
        echo '
        <div class="focuspoint"
          data-focus-x="' . $focuspoint_data[0] . '"
          data-focus-y="' . $focuspoint_data[1] . '"
          data-image-w="' . $bildBreite . '"
          data-image-h="' . $bildHoehe . '">
          <img src="/files/' . $bildDateiName . '" alt="' . htmlspecialchars($bildTitle) . '" />
        </div>
        ';
    } else {
        echo '<img src="/files/' . $bildDateiName . '" alt="' . htmlspecialchars($bildTitle) . '" />';
    }
}
        $debug = '';
        foreach ($validatorError as $var) {
            $validate = $var;
            preg_match('/([0-9]+)/', $validate, $line);
            $debug .= "Fehler in Zeile " . $line[0] . '<a href="#"> geh hin</a><br />';
            $validate = ereg_replace('<li', '<div class="warning"', $validate);
            $validate = ereg_replace('</li', '</div', $validate);
            $validate = ereg_replace('<p', '<strong', $validate);
            $validate = ereg_replace('</p', '</strong', $validate);
            $debug .= $validate;
        }
    }
    $textarea = $_POST['styles'];
    $file = $_POST['fileEdit'];
}
$cssFiles = OOMedia::getMediaByExtension("css");
if (!isset($cssSelectFile)) {
    $cssSelectFile = '';
}
if (count($cssFiles) >= "1") {
    foreach ($cssFiles as $cssFile) {
        $cssFileName = $cssFile->getFileName();
        if (!isset($_POST['save'])) {
            if (isset($file) and $cssFileName == $file or isset($_POST['fileEdit']) and $cssFileName == $_POST['fileEdit']) {
                $selected = 'selected="selected"';
            } else {
                $selected = '';
            }
        }
        $cssSelectFile .= '<option value="' . $cssFileName . '" ' . $selected . '>' . $cssFileName . '</option>' . "\n";
    }
function rex_medienpool_Mediaform($form_title, $button_title, $rex_file_category, $file_chooser, $close_form)
{
    global $I18N, $REX, $REX_USER, $subpage, $ftitle;
    $s = '';
    $cats_sel = new rex_select();
    $cats_sel->setStyle('class="inp100"');
    $cats_sel->setSize(1);
    $cats_sel->setName('rex_file_category');
    $cats_sel->setId('rex_file_category');
    $cats_sel->addOption($I18N->msg('pool_kats_no'), "0");
    $mediacat_ids = array();
    $rootCat = 0;
    if ($rootCats = OOMediaCategory::getRootCategories()) {
        foreach ($rootCats as $rootCat) {
            rex_medienpool_addMediacatOptionsWPerm($cats_sel, $rootCat, $mediacat_ids);
        }
    }
    $cats_sel->setSelected($rex_file_category);
    if (isset($msg) and $msg != "") {
        $s .= rex_warning($msg);
        $msg = "";
    }
    if (!isset($ftitle)) {
        $ftitle = '';
    }
    $add_file = '';
    if ($file_chooser) {
        $devInfos = '';
        if ($REX_USER->hasPerm('advancedMode[]')) {
            $devInfos = '<span class="rex-notice">
         <span>' . $I18N->msg('pool_max_uploadsize') . ':</span> ' . OOMedia::_getFormattedSize(rex_ini_get('upload_max_filesize')) . '

         <!-- Upload-Temp-Dir: ' . rex_ini_get('upload_tmp_dir') . '
         Uploads: ' . (rex_ini_get('file_uploads') == 1 ? 'On' : 'Off') . '<br />
         Max-Upload-Time: ' . rex_ini_get('max_input_time') . 's   -->

       </span>';
        }
        $add_file = '<p>
                   <label for="file_new">' . $I18N->msg('pool_file_file') . '</label>
                   <input type="file" id="file_new" name="file_new" size="30" />
                   ' . $devInfos . '
                 </p>';
    }
    $add_submit = '';
    if (rex_session('media[opener_input_field]') != '') {
        $add_submit = '<input type="submit" class="rex-sbmt" name="saveandexit" value="' . $I18N->msg('pool_file_upload_get') . '"' . rex_accesskey($I18N->msg('pool_file_upload_get'), $REX['ACKEY']['SAVE']) . ' />';
    }
    $s .= '
  		<div class="rex-mpl-oth">
  		<form action="index.php" method="post" enctype="multipart/form-data">
           <fieldset>
             <legend class="rex-lgnd"><span >' . $form_title . '</span></legend>
               <input type="hidden" name="page" value="medienpool" />
               <input type="hidden" name="media_method" value="add_file" />
               <input type="hidden" name="subpage" value="' . $subpage . '" />
               <p>
                 <label for="ftitle">' . $I18N->msg('pool_file_title') . '</label>
                 <input type="text" size="20" id="ftitle" name="ftitle" value="' . htmlspecialchars(stripslashes($ftitle)) . '" />
               </p>
               <p>
                 <label for="rex_file_category">' . $I18N->msg('pool_file_category') . '</label>
                 ' . $cats_sel->get() . '
               </p>
               ' . $add_file . '
               <p class="rex-sbmt">
                 <input type="submit" name="save" value="' . $button_title . '"' . rex_accesskey($button_title, $REX['ACKEY']['SAVE']) . ' />
                 ' . $add_submit . '
               </p>
           </fieldset>
        ';
    if ($close_form) {
        $s .= '</form></div>' . "\n";
    }
    return $s;
}
 /**
  * @access public
  */
 function getMedia()
 {
     global $REX;
     if ($this->_files === null) {
         $this->_files = array();
         $id = $this->getId();
         $list_path = $REX['INCLUDE_PATH'] . '/generated/files/' . $id . '.mlist';
         if (!file_exists($list_path)) {
             require_once $REX['INCLUDE_PATH'] . '/functions/function_rex_generate.inc.php';
             rex_generateMediaList($id);
         }
         if (file_exists($list_path)) {
             require_once $list_path;
             if (isset($REX['MEDIA']['MEDIA_CAT_ID'][$id]) && is_array($REX['MEDIA']['MEDIA_CAT_ID'][$id])) {
                 foreach ($REX['MEDIA']['MEDIA_CAT_ID'][$id] as $filename) {
                     $this->_files[] =& OOMedia::getMediaByFileName($filename);
                 }
             }
         }
     }
     return $this->_files;
 }
Example #20
0
</th>
                        <th colspan="3"><?php 
echo $I18N->msg('im_export_function');
?>
</th>
                    </tr>
                </thead>
                <tbody>
<?php 
$dir = getImportDir();
$files = readImportFolder('.tar.gz');
sort($files);
foreach ($files as $file) {
    $filepath = $dir . '/' . $file;
    $filec = date('d.m.Y H:i', filemtime($filepath));
    $filesize = OOMedia::_getFormattedSize(filesize($filepath));
    echo '<tr>
                        <td>' . $file . '</td>
                        <td>' . $filesize . '</td>
                        <td>' . $filec . '</td>
                        <td><a href="index.php?page=import_export&amp;subpage=import&amp;function=fileimport&amp;impname=' . $file . '" title="' . $I18N->msg('im_export_import_file') . '" onclick="return confirm(\'' . $I18N->msg('im_export_proceed_file_import') . '\')">' . $I18N->msg('im_export_to_import') . '</a></td>
                        <td><a href="index.php?page=import_export&amp;subpage=import&amp;function=download&amp;impname=' . $file . '" title="' . $I18N->msg('im_export_download_file') . '">' . $I18N->msg('im_export_download') . '</a></td>
                        <td><a href="index.php?page=import_export&amp;subpage=import&amp;function=delete&amp;impname=' . $file . '" title="' . $I18N->msg('im_export_delete_file') . '" onclick="return confirm(\'' . $I18N->msg('im_export_delete') . ' ?\')">' . $I18N->msg('im_export_delete') . '</a></td>
                    </tr>';
}
?>
                </tbody>
            </table>

    <div class="rex-clearer"></div>
</div><!-- END rex-area -->
 function execute()
 {
     if (!$this->image->isImage()) {
         return false;
     }
     $gdimage =& $this->image->getImage();
     $w = $this->image->getWidth();
     $h = $this->image->getHeight();
     $filename = $this->image->getFileName();
     if ($im_image = OOMedia::getMediaByName($filename)) {
         $focuspoint_data = explode(",", $im_image->getValue('med_focuspoint_data'), 2);
         if (count($focuspoint_data) == 2) {
             // Mittelpunkt finden
             $x = ceil($w / 2);
             $y = ceil($h / 2);
             // focusoffsets einarbeiten
             $fp_w = $focuspoint_data[0];
             $fp_h = $focuspoint_data[1];
             // Neuen Mittelpunkt finden
             $nx = $x + ceil($x * $fp_w);
             $ny = $y - ceil($y * $fp_h);
             // Abstand zum Rand herausfinden
             $nw = $w - $nx;
             // 1/2 Breite
             if ($fp_w < 0) {
                 $nw = $nx;
                 // 1/2 Breite
             }
             $nh = $ny;
             // 1/2 Breite
             if ($fp_h < 0) {
                 $nh = $h - $ny;
                 // 1/2 Breite
             }
             $npx = $nx - $nw;
             $npy = $ny - $nh;
             $nw = $nw * 2;
             $nh = $nh * 2;
             if (function_exists('ImageCreateTrueColor')) {
                 $des = @ImageCreateTrueColor($nw, $nh);
             } else {
                 $des = @ImageCreate($nw, $nh);
             }
             $this->keepTransparent($des);
             imagecopyresampled($des, $gdimage, 0, 0, $npx, $npy, $nw, $nh, $nw, $nh);
             $gdimage = $des;
             $this->image->refreshDimensions();
             $w = $nw;
             $h = $nh;
         }
     }
     if (!isset($this->params['style']) || !in_array($this->params['style'], $this->options)) {
         $this->params['style'] = 'maximum';
     }
     // relatives resizen
     if (substr(trim($this->params['width']), -1) === '%') {
         $this->params['width'] = round($w * (rtrim($this->params['width'], '%') / 100));
     }
     if (substr(trim($this->params['height']), -1) === '%') {
         $this->params['height'] = round($h * (rtrim($this->params['height'], '%') / 100));
     }
     if ($this->params['style'] == 'maximum') {
         $this->resizeMax($w, $h);
     } elseif ($this->params['style'] == 'minimum') {
         $this->resizeMin($w, $h);
     } else {
         // warp => nichts tun
     }
     // ----- not enlarge image
     if ($w <= $this->params['width'] && $h <= $this->params['height'] && $this->params['allow_enlarge'] == 'not_enlarge') {
         $this->params['width'] = $w;
         $this->params['height'] = $h;
         $this->keepTransparent($gdimage);
         return;
     }
     if (!isset($this->params['width'])) {
         $this->params['width'] = $w;
     }
     if (!isset($this->params['height'])) {
         $this->params['height'] = $h;
     }
     if (function_exists('ImageCreateTrueColor')) {
         $des = @ImageCreateTrueColor($this->params['width'], $this->params['height']);
     } else {
         $des = @ImageCreate($this->params['width'], $this->params['height']);
     }
     if (!$des) {
         return;
     }
     $this->keepTransparent($des);
     imagecopyresampled($des, $gdimage, 0, 0, 0, 0, $this->params['width'], $this->params['height'], $w, $h);
     $gdimage = $des;
     $this->image->refreshDimensions();
 }
 /**
  * @access public
  * @static
  */
 function _isImage($filename)
 {
     static $imageExtensions;
     if (!isset($imageExtensions)) {
         $imageExtensions = array('gif', 'jpeg', 'jpg', 'png', 'bmp');
     }
     return in_array(OOMedia::_getExtension($filename), $imageExtensions);
 }
/**
 * Generiert eine Liste mit allen Media einer Dateiendung
 *
 * @param $extension Dateiendung der zu generierenden Liste
 *
 * @return TRUE bei Erfolg, sonst FALSE
 */
function rex_generateMediaExtensionList($extension)
{
    global $REX;
    $query = 'SELECT filename FROM ' . OOMedia::_getTableName() . ' WHERE SUBSTRING(filename,LOCATE( ".",filename)+1) = "' . $extension . '"';
    $sql = rex_sql::factory();
    $sql->setQuery($query);
    $content = '<?php' . "\n";
    for ($i = 0; $i < $sql->getRows(); $i++) {
        $content .= '$REX[\'MEDIA\'][\'EXTENSION\'][\'' . $extension . '\'][' . $i . '] = \'' . $sql->getValue('filename') . '\';' . "\n";
        $sql->next();
    }
    $content .= '?>';
    $list_file = $REX['GENERATED_PATH'] . "/files/{$extension}.mextlist";
    if (rex_file::put($list_file, $content)) {
        return true;
    }
    return false;
}
 public static function getImagesHTML()
 {
     global $REX;
     $return = [];
     /**
      * prepare images from MetaInfo
      */
     if (self::$curArticle->getValue('art_open_graph_images')) {
         $images = explode(',', self::$curArticle->getValue('art_open_graph_images'));
         foreach ($images as $image) {
             $ogImage = new Image();
             $image = \OOMedia::getMediaByFileName($image);
             if (false && \rex_addon::isActivated('seo42')) {
                 $ogImage->setUrl(\seo42::getMediaUrl($image));
             } else {
                 $ogImage->setUrl($REX['SERVER'] . $REX['MEDIA_DIR'] . '/' . $image->getFileName());
             }
             $ogImage->setType($image->getType());
             $ogImage->setWidth($image->getWidth());
             $ogImage->setHeigt($image->getHeight());
             self::addImage($ogImage);
         }
     }
     /** @var Image $image */
     foreach (self::$images as $image) {
         $return[] = '<meta property="og:image" content="' . $image->getUrl() . '">';
         if ($image->getSecureUrl() || $REX['ADDON']['open_graph']['settings']['https']) {
             if (!$image->getSecureUrl()) {
                 if (strpos($image->getUrl(), $REX['SERVER']) == 0) {
                     $image->setSecureUrl(str_replace('http://', 'https://', $image->getUrl()));
                 }
             }
             if ($image->getSecureUrl()) {
                 $return[] = '<meta property="og:image:secure_url" content="' . $image->getSecureUrl() . '">';
             }
         }
         if ($image->getWidth()) {
             $return[] = '<meta property="og:image:width" content="' . $image->getWidth() . '">';
         }
         if ($image->getHeigt()) {
             $return[] = '<meta property="og:image:height" content="' . $image->getHeigt() . '">';
         }
         if ($image->getType()) {
             $return[] = '<meta property="og:image:type" content="' . $image->getType() . '">';
         }
     }
     return implode("\n\t", $return) . "\n\t";
 }
 function isImageType($type)
 {
     return in_array($type, OOMedia::getImageTypes());
 }
 function matchMedia(&$sql, $content)
 {
     $vars = array('REX_FILE', 'REX_MEDIA');
     foreach ($vars as $var) {
         $matches = $this->getVarParams($content, $var);
         foreach ($matches as $match) {
             list($param_str, $args) = $match;
             list($id, $args) = $this->extractArg('id', $args, 0);
             if ($id > 0 && $id < 11) {
                 // Mimetype ausgeben
                 if (isset($args['mimetype'])) {
                     $OOM = OOMedia::getMediaByName($this->getValue($sql, 'file' . $id));
                     if ($OOM) {
                         $replace = $OOM->getType();
                     }
                 } else {
                     $replace = $this->getValue($sql, 'file' . $id);
                 }
                 $replace = $this->handleGlobalVarParams($var, $args, $replace);
                 $content = str_replace($var . '[' . $param_str . ']', $replace, $content);
             }
         }
     }
     return $content;
 }
             } else {
                 $file_size = round($size / $tb, 2) . " TBbytes";
             }
         }
     }
 }
 if ($file_title == "") {
     $file_title = "[" . $I18N->msg('pool_file_notitle') . "]";
 }
 if ($file_description == "") {
     $file_description = "[" . $I18N->msg('pool_file_nodescription') . "]";
 }
 // ----- opener
 if ($_SESSION["media[opener_input_field]"] == 'TINY') {
     $opener_link = '';
     if (OOMedia::isImageType($file_type)) {
         $opener_link .= "<a href=\"javascript:insertImage('{$file_name}','" . str_replace(" ", "&nbsp;", converDescription($file_description)) . "','" . $files->getValue("width") . "','" . $files->getValue("height") . "');\">" . $I18N->msg('pool_image_get') . "</a><br>";
     }
     $opener_link .= "<a href=\"javascript:insertLink('" . $file_name . "');\">" . $I18N->msg('pool_link_get') . "</a>";
 } elseif ($_SESSION["media[opener_input_field]"] != '') {
     $opener_link = "<a href=\"javascript:selectMedia('" . $file_name . "');\">" . $I18N->msg('pool_file_get') . "</a>";
     if (substr($_SESSION["media[opener_input_field]"], 0, 14) == "REX_MEDIALIST_") {
         $opener_link = "<a href=\"javascript:addMedialist('" . $file_name . "');\">" . $I18N->msg('pool_file_get') . "</a>";
     }
 }
 $ilink = 'index.php?page=medienpool&amp;subpage=detail&amp;file_id=' . $file_id . '&amp;rex_file_category=' . $rex_file_category;
 echo '<tr>' . "\n";
 if ($PERMALL) {
     echo '  <td class="icon"><input type="checkbox" name="selectedmedia[]" value="' . $file_id . '"></td>' . "\n";
 } else {
     echo '  <td class="icon">&nbsp;</td>' . "\n";
 function getCreateDate($format = null)
 {
     return OOMedia::_getDate($this->_createdate, $format);
 }
 /**
  * @access public
  */
 function getFiles()
 {
     if ($this->_files === null) {
         $this->_files = array();
         $qry = 'SELECT file_id FROM ' . OOMedia::_getTableName() . ' WHERE category_id = ' . $this->getId();
         $sql = new rex_sql();
         $sql->setQuery($qry);
         $result = $sql->getArray();
         if (is_array($result)) {
             foreach ($result as $line) {
                 $this->_files[] =& OOMedia::getMediaById($line['file_id']);
             }
         }
     }
     return $this->_files;
 }
/**
 * Ausgabe des Medienpool Formulars
 */
function rex_mediapool_Mediaform($form_title, $button_title, $rex_file_category, $file_chooser, $close_form)
{
    global $I18N, $REX, $subpage, $ftitle, $warning, $info;
    $s = '';
    $cats_sel = new rex_mediacategory_select();
    $cats_sel->setStyle('class="rex-form-select"');
    $cats_sel->setSize(1);
    $cats_sel->setName('rex_file_category');
    $cats_sel->setId('rex_file_category');
    $cats_sel->addOption($I18N->msg('pool_kats_no'), "0");
    $cats_sel->setAttribute('onchange', 'this.form.submit()');
    $cats_sel->setSelected($rex_file_category);
    if (isset($warning) and $warning != "") {
        $s .= rex_warning($warning);
        $warning = "";
    }
    if (isset($info) and $info != "") {
        $s .= rex_info($info);
        $info = "";
    }
    if (!isset($ftitle)) {
        $ftitle = '';
    }
    $add_file = '';
    if ($file_chooser) {
        $devInfos = '';
        if ($REX['USER']->hasPerm('advancedMode[]')) {
            $devInfos = '<span class="rex-form-notice">
         ' . $I18N->msg('phpini_settings') . ':<br />
         ' . (rex_ini_get('file_uploads') == 0 ? '<span>' . $I18N->msg('pool_upload') . ':</span> <em>' . $I18N->msg('pool_upload_disabled') . '</em><br />' : '') . '
         <span>' . $I18N->msg('pool_max_uploadsize') . ':</span> ' . OOMedia::_getFormattedSize(rex_ini_get('upload_max_filesize')) . '<br />
         <span>' . $I18N->msg('pool_max_uploadtime') . ':</span> ' . rex_ini_get('max_input_time') . 's
       </span>';
        }
        $add_file = '
                <div class="rex-form-row">
                  <p class="rex-form-file">
                    <label for="file_new">' . $I18N->msg('pool_file_file') . '</label>
                    <input class="rex-form-file" type="file" id="file_new" name="file_new" size="30" />
                    ' . $devInfos . '
                  </p>
                </div>';
    }
    $arg_fields = '';
    foreach (rex_request('args', 'array') as $arg_name => $arg_value) {
        $arg_fields .= '<input type="hidden" name="args[' . $arg_name . ']" value="' . $arg_value . '" />' . "\n";
    }
    $arg_fields = '';
    $opener_input_field = rex_request('opener_input_field', 'string');
    if ($opener_input_field != '') {
        $arg_fields .= '<input type="hidden" name="opener_input_field" value="' . htmlspecialchars($opener_input_field) . '" />' . "\n";
    }
    $add_submit = '';
    if ($close_form) {
        $add_submit = '<input type="submit" class="rex-form-submit" name="saveandexit" value="' . $I18N->msg('pool_file_upload_get') . '"' . rex_accesskey($I18N->msg('pool_file_upload_get'), $REX['ACKEY']['SAVE']) . ' />';
    }
    $s .= '
      <div class="rex-form" id="rex-form-mediapool-other">
        <form action="index.php" method="post" enctype="multipart/form-data">
          <fieldset class="rex-form-col-1">
            <legend>' . $form_title . '</legend>
            <div class="rex-form-wrapper">
              <input type="hidden" name="page" value="mediapool" />
              <input type="hidden" name="media_method" value="add_file" />
              <input type="hidden" name="subpage" value="' . $subpage . '" />
              ' . $arg_fields . '
              
              <div class="rex-form-row">
                <p class="rex-form-text">
                  <label for="ftitle">' . $I18N->msg('pool_file_title') . '</label>
                  <input class="rex-form-text" type="text" size="20" id="ftitle" name="ftitle" value="' . htmlspecialchars(stripslashes($ftitle)) . '" />
                </p>
              </div>
              
              <div class="rex-form-row">
                <p class="rex-form-select">
                  <label for="rex_file_category">' . $I18N->msg('pool_file_category') . '</label>
                  ' . $cats_sel->get() . '
                </p>
              </div>

              <div class="rex-clearer"></div>';
    // ----- EXTENSION POINT
    $s .= rex_register_extension_point('MEDIA_FORM_ADD', '');
    $s .= $add_file . '
              <div class="rex-form-row">
                <p class="rex-form-submit">
                 <input class="rex-form-submit" type="submit" name="save" value="' . $button_title . '"' . rex_accesskey($button_title, $REX['ACKEY']['SAVE']) . ' />
                 ' . $add_submit . '
                </p>
              </div>

              <div class="rex-clearer"></div>
            </div>
          </fieldset>
        ';
    if ($close_form) {
        $s .= '</form></div>' . "\n";
    }
    return $s;
}