Esempio n. 1
0
 /**
  * Handle the match
  */
 function handle($match, $state, $pos, &$handler)
 {
     global $ID;
     $match = substr($match, 9, -11);
     // strip markup
     list($flags, $match) = explode('>', $match, 2);
     $flags = explode('&', substr($flags, 1));
     $items = explode('*', $match);
     $pages = array();
     $c = count($items);
     for ($i = 0; $i < $c; $i++) {
         if (!preg_match('/\\[\\[(.+?)\\]\\]/', $items[$i], $match)) {
             continue;
         }
         list($id, $title, $description) = explode('|', $match[1], 3);
         list($id, $section) = explode('#', $id, 2);
         if (!$id) {
             $id = $ID;
         }
         resolve_pageid(getNS($ID), $id, $exists);
         // page has an image title
         if ($title && preg_match('/\\{\\{(.+?)\\}\\}/', $title, $match)) {
             list($image, $title) = explode('|', $match[1], 2);
             list($ext, $mime) = mimetype($image);
             if (!substr($mime, 0, 5) == 'image') {
                 $image = '';
             }
             $pages[] = array('id' => $id, 'section' => cleanID($section), 'title' => trim($title), 'image' => trim($image), 'description' => trim($description), 'exists' => $exists);
             // text title (if any)
         } else {
             $pages[] = array('id' => $id, 'section' => cleanID($section), 'title' => trim($title), 'description' => trim($description), 'exists' => $exists);
         }
     }
     return array($flags, $pages);
 }
Esempio n. 2
0
 private static function add_file_callback($id, $new_file, $filename)
 {
     $CI =& get_instance();
     $hash = md5_file($new_file);
     $storage_id = null;
     $query = $CI->db->select('id, hash')->from('file_storage')->where('hash', $hash)->get()->result_array();
     foreach ($query as $row) {
         $data_id = implode("-", array($row['hash'], $row['id']));
         $old_file = $CI->mfile->file($data_id);
         // TODO: set $new_file
         if (files_are_equal($old_file, $new_file)) {
             $storage_id = $row["id"];
             break;
         }
     }
     if ($storage_id === null) {
         $filesize = filesize($new_file);
         $mimetype = mimetype($new_file);
         $CI->db->insert("file_storage", array("filesize" => $filesize, "mimetype" => $mimetype, "hash" => $hash, "date" => time()));
         $storage_id = $CI->db->insert_id();
     }
     $data_id = $hash . "-" . $storage_id;
     // TODO: all this doesn't have to run if the file exists. updating the mtime would be enough
     //       that would also be better for COW filesystems
     $dir = $CI->mfile->folder($data_id);
     file_exists($dir) || mkdir($dir);
     $new_path = $CI->mfile->file($data_id);
     $dest = new \service\storage($new_path);
     $tmpfile = $dest->begin();
     rename($new_file, $tmpfile);
     $dest->commit();
     $CI->mfile->add_file($id, $filename, $storage_id);
 }
 function handle_output(&$event, $param)
 {
     if ($event->data['do'] != 'imageshack') {
         return;
     }
     global $lang;
     echo '<h1 id="media__ns">' . $this->getLang('name') . '</h1>';
     echo '<p>' . $this->getLang('intro') . '</p>';
     echo '<form action="' . DOKU_BASE . 'lib/exe/mediamanager.php" method="post" enctype="multipart/form-data">';
     echo '<input type="hidden" name="do" value="imageshack" />';
     echo '<input type="file" name="imageshack_file" />';
     echo '<input type="submit" value="' . $lang['btn_upload'] . '" class="button" />';
     echo '</form>';
     // output the uploads stored in the current session
     if (is_array($_SESSION['imageshack'])) {
         $files = array_reverse($_SESSION['imageshack']);
         $twibble = 1;
         foreach ($files as $item) {
             $twibble *= -1;
             $zebra = $twibble == -1 ? 'odd' : 'even';
             list($ext, $mime, $dl) = mimetype($item['name']);
             $class = preg_replace('/[^_\\-a-z0-9]+/i', '_', $ext);
             $class = 'select mediafile mf_' . $class;
             echo '<div class="' . $zebra . '">' . NL;
             echo '<a name="h_' . $item['link'] . '" class="' . $class . '">' . hsc($item['name']) . '</a> ';
             echo '<span class="info">(' . $item['width'] . '&#215;' . $item['height'] . ' ' . filesize_h($item['size']) . ')</span>' . NL;
             echo ' <a href="' . $item['adlink'] . '" target="_blank"><img src="' . DOKU_BASE . 'lib/images/magnifier.png" ' . 'alt="' . $lang['mediaview'] . '" title="' . $lang['mediaview'] . '" class="btn" /></a>' . NL;
             echo '<div class="example" id="ex_' . str_replace(':', '_', $item['link']) . '">';
             echo $lang['mediausage'] . ' <code>{{' . hsc($item['link']) . '}}</code>';
             echo '</div>';
             if ($item['width'] > 120 || $item['height'] > 100) {
                 $w = 120;
                 $h = 100;
             } else {
                 $w = $item['width'];
                 $h = $item['height'];
             }
             $src = ml($item['link'], array('w' => $w, 'h' => $h));
             $p = array();
             $p['width'] = $w;
             $p['height'] = $h;
             $p['alt'] = $item['name'];
             $p['class'] = 'thumb';
             $att = buildAttributes($p);
             // output
             echo '<div class="detail">';
             echo '<div class="thumb">';
             echo '<a name="d_' . $item['link'] . '" class="select">';
             echo '<img src="' . $src . '" ' . $att . ' />';
             echo '</a>';
             echo '</div>';
             echo '</div>';
             echo '<div class="clearer"></div>' . NL;
             echo '</div>' . NL;
         }
     }
     $event->preventDefault();
 }
Esempio n. 4
0
 /**
  * Adds the file $src as a picture file without adding it to the content.
  * Returns name of the file in the document for reference.
  *
  * @param string $src
  * @return string
  */
 function addFileAsPicture($src)
 {
     $name = '';
     if (file_exists($src)) {
         list($ext, $mime) = mimetype($src);
         $name = 'Pictures/' . md5($src) . '.' . $ext;
         $this->addFile($name, $mime, io_readfile($src, false));
     }
     return $name;
 }
 function _media($src, $title = NULL, $align = NULL, $width = NULL, $height = NULL, $cache = NULL)
 {
     $ret = '';
     list($ext, $mime) = mimetype($src);
     if (substr($mime, 0, 5) == 'image') {
         //add image tag
         $ret .= '<img src="media/' . str_replace(':', '/', $src) . '"';
         $ret .= ' class="media' . $align . '"';
         if (!is_null($title)) {
             $ret .= ' title="' . $this->_xmlEntities($title) . '"';
             $ret .= ' alt="' . $this->_xmlEntities($title) . '"';
         } else {
             $ret .= ' alt=""';
         }
         if (!is_null($width)) {
             $ret .= ' width="' . $this->_xmlEntities($width) . '"';
         }
         if (!is_null($height)) {
             $ret .= ' height="' . $this->_xmlEntities($height) . '"';
         }
         $ret .= ' />';
     } elseif ($mime == 'application/x-shockwave-flash') {
         $ret .= '<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000"' . ' codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,40,0"';
         if (!is_null($width)) {
             $ret .= ' width="' . $this->_xmlEntities($width) . '"';
         }
         if (!is_null($height)) {
             $ret .= ' height="' . $this->_xmlEntities($height) . '"';
         }
         $ret .= '>' . DOKU_LF;
         $ret .= '<param name="movie" value="media/' . str_replace(':', '/', $src) . '" />' . DOKU_LF;
         $ret .= '<param name="quality" value="high" />' . DOKU_LF;
         $ret .= '<embed src="media/' . str_replace(':', '/', $src) . '"' . ' quality="high"';
         if (!is_null($width)) {
             $ret .= ' width="' . $this->_xmlEntities($width) . '"';
         }
         if (!is_null($height)) {
             $ret .= ' height="' . $this->_xmlEntities($height) . '"';
         }
         $ret .= ' type="application/x-shockwave-flash"' . ' pluginspage="http://www.macromedia.com/go/getflashplayer"></embed>' . DOKU_LF;
         $ret .= '</object>' . DOKU_LF;
     } elseif (!is_null($title)) {
         // well at least we have a title to display
         $ret .= $this->_xmlEntities($title);
     } else {
         // just show the source
         $ret .= $this->_xmlEntities($src);
     }
     return $ret;
 }
Esempio n. 6
0
 /**
  * Output the stored data
  *
  * If outputted in an aggregation we collect the images into a gallery.
  *
  * @param string|int $value the value stored in the database
  * @param \Doku_Renderer $R the renderer currently used to render the data
  * @param string $mode The mode the output is rendered in (eg. XHTML)
  * @return bool true if $mode could be satisfied
  */
 public function renderValue($value, \Doku_Renderer $R, $mode)
 {
     // get width and height from config
     $width = null;
     $height = null;
     if ($this->config['width']) {
         $width = $this->config['width'];
     }
     if ($this->config['height']) {
         $height = $this->config['height'];
     }
     if (!empty($R->info['struct_table_hash'])) {
         // this is an aggregation, check for special values
         if ($this->config['agg_width']) {
             $width = $this->config['agg_width'];
         }
         if ($this->config['agg_height']) {
             $height = $this->config['agg_height'];
         }
     }
     // depending on renderer type directly output or get value from it
     $returnLink = null;
     $html = '';
     if (!media_isexternal($value)) {
         if (is_a($R, '\\Doku_Renderer_xhtml')) {
             /** @var \Doku_Renderer_xhtml $R */
             $html = $R->internalmedia($value, null, null, $width, $height, null, 'direct', true);
         } else {
             $R->internalmedia($value, null, null, $width, $height, null, 'direct');
         }
     } else {
         if (is_a($R, '\\Doku_Renderer_xhtml')) {
             /** @var \Doku_Renderer_xhtml $R */
             $html = $R->externalmedia($value, null, null, $width, $height, null, 'direct', true);
         } else {
             $R->externalmedia($value, null, null, $width, $height, null, 'direct');
         }
     }
     // add gallery meta data in XHTML
     if ($mode == 'xhtml') {
         list(, $mime, ) = mimetype($value, false);
         if (substr($mime, 0, 6) == 'image/') {
             $hash = !empty($R->info['struct_table_hash']) ? "[gal-" . $R->info['struct_table_hash'] . "]" : '';
             $html = str_replace('href', "rel=\"lightbox{$hash}\" href", $html);
         }
         $R->doc .= $html;
     }
     return true;
 }
Esempio n. 7
0
 /**
  * Move the old revisions of the media file that is specified in the options
  *
  * @param string $src_ns   The original namespace
  * @param string $src_name The original basename of the moved doc (empty for namespace moves)
  * @param string $dst_ns   The namespace after the move
  * @param string $dst_name The basename after the move (empty for namespace moves)
  * @return bool If the attic files were moved successfully
  */
 public function moveMediaAttic($src_ns, $src_name, $dst_ns, $dst_name)
 {
     global $conf;
     $ext = mimetype($src_name);
     if ($ext[0] !== false) {
         $name = substr($src_name, 0, -1 * strlen($ext[0]) - 1);
     } else {
         $name = $src_name;
     }
     $newext = mimetype($dst_name);
     if ($newext[0] !== false) {
         $newname = substr($dst_name, 0, -1 * strlen($newext[0]) - 1);
     } else {
         $newname = $dst_name;
     }
     $regex = '\\.\\d+\\.' . preg_quote((string) $ext[0], '/');
     return $this->execute($conf['mediaolddir'], $src_ns, $name, $dst_ns, $newname, $regex);
 }
Esempio n. 8
0
File: Http.php Progetto: pyrsmk/lumy
 public function __construct()
 {
     // Prepare
     parent::__construct();
     $manager = new Manager(new ArrayDriver());
     $this->__lock = $manager->caller(new Path());
     $this->__lock->deny('all');
     // REST
     $this->middleware(function ($middlewares) {
         if (isset($_POST['_METHOD'])) {
             $_SERVER['REQUEST_METHOD'] = strtoupper($_POST['_METHOD']);
             unset($_POST['_METHOD']);
         }
         $middlewares->next();
     });
     // Return allowed files
     $this->middleware(function ($middlewares) {
         $path = $this->_formatPath($this['request']->getResourceUri());
         if (file_exists($path) && is_file($path) && $this->__lock->can($this->_formatPath($path))) {
             // Get mime type
             $mime = mimetype($path);
             // Try some more extensions
             if ($mime == 'text/plain') {
                 if (strpos($path, '.css')) {
                     $mime = 'text/css';
                 }
                 if (strpos($path, '.js')) {
                     $mime = 'application/javascript';
                 }
                 if (strpos($path, '.json')) {
                     $mime = 'application/json';
                 }
             }
             // Set content type
             if ($mime != 'text/plain') {
                 header('Content-Type: ' . $mime);
             }
             // Print file
             echo file_get_contents($path);
             exit;
         }
         $middlewares->next();
     });
 }
Esempio n. 9
0
function sl_upload($srcFile, $dstFile)
{
    $uploadType = Get::cfg('uploadType');
    // check if the mime type is allowed by the whitelist
    // if the whitelist is empty all types are accepted
    require_once _lib_ . '/lib.mimetype.php';
    $upload_whitelist = Get::sett('file_upload_whitelist', 'zip,jpg,gif,png,txt,csv,rtf,xml,doc,docx,xls,xlsx,ppt,pptx,odt,ods,odp,pdf,xps,mp4,mp3,flv,swf,mov,wav,ogg,flac,wma,wmv');
    $upload_whitelist_arr = explode(',', trim($upload_whitelist, ','));
    if (!empty($upload_whitelist_arr)) {
        $valid_ext = false;
        $file_ext = strtolower(substr(strrchr($dstFile, "."), 1));
        foreach ($upload_whitelist_arr as $k => $v) {
            // remove extra spaces and set lower case
            $ext = trim(strtolower($v));
            $mt = mimetype($ext);
            if ($mt) {
                $mimetype_arr[] = $mt;
            }
            getOtherMime($ext, $mimetype_arr);
            if ($ext == $file_ext) {
                $valid_ext = true;
            }
        }
        $mimetype_arr = array_unique($mimetype_arr);
        if (class_exists('file') && method_exists('finfo', 'file')) {
            $finfo = new finfo(FILEINFO_MIME_TYPE);
            $file_mime_type = $finfo->file($srcFile);
        } else {
            $file_mime_type = mime_content_type($srcFile);
        }
        if (!$valid_ext || !in_array($file_mime_type, $mimetype_arr)) {
            return false;
        }
    }
    $dstFile = stripslashes($dstFile);
    if ($uploadType == "ftp") {
        return sl_upload_ftp($srcFile, $dstFile);
    } elseif ($uploadType == "cgi") {
        return sl_upload_cgi($srcFile, $dstFile);
    } else {
        return sl_upload_fs($srcFile, $dstFile);
    }
}
Esempio n. 10
0
function download($path, $home, $force = true)
{
    if (is_file($home . $path) && $force) {
        header('Content-type: application/octet-stream');
        header('Content-Disposition: attachment; filename="' . basename($path) . '";');
        header('Content-Transfer-Encoding: binary');
        readfile($home . $path);
    } elseif (is_file($home . $path)) {
        header('Content-type: ' . mimetype($home . $path));
        readfile($home . $path);
    } else {
        header($_SERVER['SERVER_PROTOCOL'] . ' 404 Not Found');
        header('Status: 404 Not Found');
        $_SERVER['REDIRECT_STATUS'] = 404;
        if (!$force) {
            echo 'The requested file is not available.';
        }
    }
}
Esempio n. 11
0
 public function internalmedia($src, $title = NULL, $align = NULL, $width = NULL, $height = NULL, $cache = NULL, $linking = NULL, $return = false)
 {
     global $ID;
     list($src, $hash) = explode('#', $src, 2);
     resolve_mediaid(getNS($ID), $src, $exists);
     $noLink = false;
     $render = $linking == 'linkonly' ? false : true;
     $link = $this->_getMediaLinkConf($src, $title, $align, $width, $height, $cache, $render);
     list($ext, $mime, $dl) = mimetype($src, false);
     if (substr($mime, 0, 5) == 'image' && $render) {
         if ($linking == NULL || $linking == '' || $linking == 'details') {
             $linking = 'direct';
         }
         $link['url'] = ml($src, array('id' => $ID, 'cache' => $cache), $linking == 'direct');
     } elseif ($mime == 'application/x-shockwave-flash' && $render) {
         // don't link flash movies
         $noLink = true;
     } else {
         // add file icons
         $class = preg_replace('/[^_\\-a-z0-9]+/i', '_', $ext);
         $link['class'] .= ' mediafile mf_' . $class;
         $link['url'] = ml($src, array('id' => $ID, 'cache' => $cache), true);
         if ($exists) {
             $link['title'] .= ' (' . filesize_h(filesize(mediaFN($src))) . ')';
         }
     }
     if ($hash) {
         $link['url'] .= '#' . $hash;
     }
     //markup non existing files
     if (!$exists) {
         $link['class'] .= ' wikilink2';
     }
     //output formatted
     if ($linking == 'nolink' || $noLink) {
         $this->doc .= $link['name'];
     } else {
         $this->doc .= $this->_formatLink($link);
     }
 }
Esempio n. 12
0
 /**
  * Renders internal and external media
  *
  * @author Andreas Gohr <*****@*****.**>
  */
 function _media($src, $title = NULL, $align = NULL, $width = NULL, $height = NULL, $cache = NULL, $render = true)
 {
     $ret = '';
     list($ext, $mime, $dl) = mimetype($src);
     if (substr($mime, 0, 5) == 'image') {
         // first get the $title
         if (!is_null($title)) {
             $title = $this->_xmlEntities($title);
         } elseif ($ext == 'jpg' || $ext == 'jpeg') {
             //try to use the caption from IPTC/EXIF
             require_once DOKU_INC . 'inc/JpegMeta.php';
             $jpeg = new JpegMeta(mediaFN($src));
             if ($jpeg !== false) {
                 $cap = $jpeg->getTitle();
             }
             if ($cap) {
                 $title = $this->_xmlEntities($cap);
             }
         }
         if (!$render) {
             // if the picture is not supposed to be rendered
             // return the title of the picture
             if (!$title) {
                 // just show the sourcename
                 $title = $this->_xmlEntities(utf8_basename(noNS($src)));
             }
             return $title;
         }
         //add image tag
         $ret .= '<img src="' . ml($src, array('w' => $width, 'h' => $height, 'cache' => $cache)) . '"';
         $ret .= ' class="media' . $align . '"';
         if ($title) {
             $ret .= ' title="' . $title . '"';
             $ret .= ' alt="' . $title . '"';
         } else {
             $ret .= ' alt=""';
         }
         if (!is_null($width)) {
             $ret .= ' width="' . $this->_xmlEntities($width) . '"';
         }
         if (!is_null($height)) {
             $ret .= ' height="' . $this->_xmlEntities($height) . '"';
         }
         $ret .= ' />';
     } elseif ($mime == 'application/x-shockwave-flash') {
         if (!$render) {
             // if the flash is not supposed to be rendered
             // return the title of the flash
             if (!$title) {
                 // just show the sourcename
                 $title = utf8_basename(noNS($src));
             }
             return $this->_xmlEntities($title);
         }
         $att = array();
         $att['class'] = "media{$align}";
         if ($align == 'right') {
             $att['align'] = 'right';
         }
         if ($align == 'left') {
             $att['align'] = 'left';
         }
         $ret .= html_flashobject(ml($src, array('cache' => $cache), true, '&'), $width, $height, array('quality' => 'high'), null, $att, $this->_xmlEntities($title));
     } elseif ($title) {
         // well at least we have a title to display
         $ret .= $this->_xmlEntities($title);
     } else {
         // just show the sourcename
         $ret .= $this->_xmlEntities(utf8_basename(noNS($src)));
     }
     return $ret;
 }
Esempio n. 13
0
 */
if (!defined('DOKU_INC')) {
    define('DOKU_INC', dirname(__FILE__) . '/../../');
}
define('DOKU_DISABLE_GZIP_OUTPUT', 1);
require_once DOKU_INC . 'inc/init.php';
//close session
session_write_close();
$mimetypes = getMimeTypes();
//get input
$MEDIA = stripctl(getID('media', false));
// no cleaning except control chars - maybe external
$CACHE = calc_cache($_REQUEST['cache']);
$WIDTH = (int) $_REQUEST['w'];
$HEIGHT = (int) $_REQUEST['h'];
list($EXT, $MIME, $DL) = mimetype($MEDIA, false);
if ($EXT === false) {
    $EXT = 'unknown';
    $MIME = 'application/octet-stream';
    $DL = true;
}
// check for permissions, preconditions and cache external files
list($STATUS, $STATUSMESSAGE) = checkFileStatus($MEDIA, $FILE);
// prepare data for plugin events
$data = array('media' => $MEDIA, 'file' => $FILE, 'orig' => $FILE, 'mime' => $MIME, 'download' => $DL, 'cache' => $CACHE, 'ext' => $EXT, 'width' => $WIDTH, 'height' => $HEIGHT, 'status' => $STATUS, 'statusmessage' => $STATUSMESSAGE);
// handle the file status
$evt = new Doku_Event('FETCH_MEDIA_STATUS', $data);
if ($evt->advise_before()) {
    // redirects
    if ($data['status'] > 300 && $data['status'] <= 304) {
        send_redirect($data['statusmessage']);
Esempio n. 14
0
/**
 * returns the full path to the mediafile specified by ID
 *
 * The filename is URL encoded to protect Unicode chars
 *
 * @author Andreas Gohr <*****@*****.**>
 * @author Kate Arzamastseva <*****@*****.**>
 *
 * @param string     $id  media id
 * @param string|int $rev empty string or revision timestamp
 * @return string full path
 */
function mediaFN($id, $rev = '')
{
    global $conf;
    $id = cleanID($id);
    $id = str_replace(':', '/', $id);
    if (empty($rev)) {
        $fn = $conf['mediadir'] . '/' . utf8_encodeFN($id);
    } else {
        $ext = mimetype($id);
        $name = substr($id, 0, -1 * strlen($ext[0]) - 1);
        $fn = $conf['mediaolddir'] . '/' . utf8_encodeFN($name . '.' . (int) $rev . '.' . $ext[0]);
    }
    return $fn;
}
Esempio n. 15
0
 function emailer($to, $subject, $body, $reply = '', $cc = '', $bcc = '', $from = '', $text_type = 'html', $x_prio = '3', $attach_path = '', $attach_file = '')
 {
     global $USER_PRIV, $_CHARSET, $dbh;
     #
     if (strlen($_CHARSET) == 0) {
         $_CHARSET = 'utf-8';
     }
     #	12/08/2009
     //		if($_SESSION['misc']['MAILSRV']=='none') { die('(emailer.inc) MailServer is set to NONE!'); }
     if (!isset($_SESSION['misc']['MAILSRV']) || $_SESSION['misc']['MAILSRV'] == 'none' || strlen($_SESSION['misc']['MAILSRV']) == 0) {
         $_SESSION['misc']['MAILSRV'] = 'ini';
     }
     if ($_SESSION['misc']['MAILSRV'] != 'ini') {
         if (!checkdnsrr($_SESSION['misc']['MAILSRV'], 'MX')) {
             $_SESSION['misc']['MAILSRV'] = 'ini';
         }
     }
     #
     define(_CR_, "\r\n");
     define(_TAB_, "\t");
     #
     $user_body = $body;
     #	12/08/2009
     #
     #	Initializations
     #
     if ($reply == '') {
         $reply = $_SESSION['misc']['E_NOREPLY'];
     }
     if ($from == '') {
         $from = 'robot#robot@' . $_SERVER['HTTP_HOST'];
     }
     list($user_id, $from_id) = explode('#', $from);
     if ($reply == '') {
         $reply = '*****@*****.**';
     }
     #	11/08/2009
     if ($user_id == '') {
         $user_id = 'robot';
     }
     #	11/08/2009
     if ($from_id == '') {
         $from_id = 'robot@' . $_SERVER['HTTP_HOST'];
     }
     #	11/08/2009
     $domain = $_SERVER['SERVER_NAME'];
     $mime_boundary = '------------{' . md5(uniqid(time())) . '}';
     #
     #	Set the common header
     #
     $headers = 'MIME-Version: 1.0' . _CR_;
     #
     #	$headers .= 'Return-Receipt-To: '.$_SESSION['misc']['E_ADMIN'].'<'.$_SESSION['misc']['E_ADMIN'].'>'._CR_;
     #
     //		if($reply)	{ $headers .= 'Reply-To:'.$reply._CR_; }
     $headers .= 'Reply-To:' . $reply . _CR_;
     #	11/08/2009
     #
     if (is_array($cc)) {
         #	Send copy to
         #
         $t = count($cc);
         $headers .= 'Cc:';
         for ($i = 0; $i < $t; $i++) {
             $headers .= $cc[$i] . ', ';
         }
         $headers = substr($headers, 0, -2) . _CR_;
     } else {
         if ($cc) {
             $headers .= 'Cc:' . $cc . _CR_;
         }
     }
     #
     if (is_array($bcc)) {
         #	Send blind copy to
         #
         $t = count($bcc);
         $headers .= 'Bcc:';
         for ($i = 0; $i < $t; $i++) {
             $headers .= $bcc[$i] . ', ';
         }
         $headers = substr($headers, 0, -2) . _CR_;
     } else {
         if ($bcc) {
             $headers .= 'Bcc:' . $bcc . _CR_;
         }
     }
     #
     $headers .= 'User-Agent: ' . $_SERVER['HTTP_USER_AGENT'] . _CR_;
     $headers .= 'From: ' . $user_id . ' <' . $from_id . '>' . _CR_;
     //		$headers .= 'Message-ID: <'.md5(uniqid(time())).'@{'.$domain.'}>'._CR_;
     $headers .= 'Message-ID: <' . md5(uniqid(time())) . '@' . $domain . '>' . _CR_;
     #	11/08/2009
     #
     switch ($x_prio) {
         case '1':
             $x_prio .= ' (Highest)';
             break;
         case '2':
             $x_prio .= ' (High)';
             break;
         case '3':
             $x_prio .= ' (Normal)';
             break;
         case '4':
             $x_prio .= ' (Low)';
             break;
         case '5':
             $x_prio .= ' (Lowest)';
             break;
             #
         #
         default:
             $x_prio = '3 (Normal)';
             #	12/08/2009
     }
     if ($x_prio) {
         $headers .= 'X-Priority: ' . $x_prio . _CR_;
     }
     #
     #	Message Priority for Exchange Servers
     #
     #	$headers .=	'X-MSmail-Priority: '.$x_prio_des._CR_;
     #
     #	!!! WARNING !!!---# Hotmail and others do NOT like PHP mailer...
     #	$headers .=	'X-Mailer: PHP/'.phpversion()._CR_;---#
     #
     #	$headers .= 'X-Mailer: Microsoft Office Outlook, Build 11.0.6353'._CR_;
     #	$headers .= 'X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2900.2527'._CR_;
     #
     //		$headers .= 'X-Sender: '.$_SESSION['misc']['E_ROBOT']._CR_;
     $headers .= 'X-Sender: ' . $user_id . ' <' . $from_id . '>' . _CR_;
     #	12/08/2009
     $headers .= 'X-AntiAbuse: This is a solicited email for - ' . $to . ' - ' . _CR_;
     $headers .= 'X-AntiAbuse: Servername - {' . $domain . '}' . _CR_;
     //		$headers .= 'X-AntiAbuse: User - '.$_SESSION['misc']['E_ROBOT']._CR_;
     $headers .= 'X-AntiAbuse: User - ' . $from_id . _CR_;
     #	12/08/2009
     #
     #	Set the right start of header
     #
     //		if($attach_file)						#	25/11/2009
     if ($attach_path && $attach_file) {
         include SITE_ROOT . 'common/fun2inc/mimetype.inc';
         #
         # INS 25/11/2009 : BEG
         #---------------------
         if (!is_array($attach_path) || !is_array($attach_file)) {
             $_attach_path = array();
             $_attach_file = array();
             $_attach_path[] = $attach_path;
             $_attach_file[] = $attach_file;
         } else {
             $_attach_path = $attach_path;
             $_attach_file = $attach_file;
         }
         #
         $a = 0;
         foreach ($_attach_file as $key => $attach_file) {
             $attach_path = $_attach_path[$key];
             #---------------------
             # INS 25/11/2009 : END
             #
             $file_name_type = mimetype($attach_path, $attach_file);
             $file_name_name = $attach_file;
             #
             #	Read the file to be attached
             #
             $data = '';
             //				$file = @fopen($attach_path.$attach_file,'rb') or die('(emailer.inc) Cannot open: '.$attach_path.$attach_file);
             $file = @fopen($attach_path . $attach_file, 'rb');
             #	12/08/2009
             if ($file) {
                 while (!feof($file)) {
                     $data .= @fread($file, 4096);
                 }
                 @fclose($file);
             }
             #
             #	Base64 encode the file data
             #
             $data = chunk_split(base64_encode($data));
             #
             if ($a == 0) {
                 #
                 #	Complete headers
                 #
                 $headers .= 'Content-Type: multipart/mixed;' . _CR_;
                 $headers .= ' boundary="' . $mime_boundary . '"' . "\n\n";
                 #
                 #	Add a multipart boundary above the text message
                 #
                 $mail_body_attach = 'This is a multi-part message in MIME format.' . _CR_;
                 $mail_body_attach .= '--' . $mime_boundary . "\n";
                 //					$mail_body_attach .= 'Content-Type: text/'.$text_type.'; charset=utf-8;'."\n";			# us-ascii,	iso-8859-1
                 $mail_body_attach .= 'Content-Type: text/' . $text_type . '; charset=' . $_CHARSET . ';' . "\n";
                 #	12/08/2009
                 $mail_body_attach .= 'Content-Transfer-Encoding: 8bit' . "\n\n";
                 # 7bit, 8bit
                 $mail_body_attach .= $body . "\n";
                 #
                 $body = $mail_body_attach;
                 #	INS 25/11/2009
             }
             #
             #	Add file attachment
             #
             #
             # MOD 25/11/2009 : BEG
             #---------------------
             //				$mail_body_attach .= '--'.$mime_boundary."\n";
             //				$mail_body_attach .= 'Content-Type: '.$file_name_type.";\n";
             //				$mail_body_attach .= ' name="'.$file_name_name.'"'."\n";
             //				$mail_body_attach .= 'Content-Disposition: attachment;'."\n";
             //				$mail_body_attach .= ' filename="'.$file_name_name.'"'."\n";
             //				$mail_body_attach .= 'Content-Transfer-Encoding: base64'."\n\n";
             //				$mail_body_attach .= $data."\n";
             #
             //				$body = $mail_body_attach;
             #
             $mail_file_attach = '--' . $mime_boundary . "\n";
             $mail_file_attach .= 'Content-Type: ' . $file_name_type . ";\n";
             $mail_file_attach .= ' name="' . $file_name_name . '"' . "\n";
             $mail_file_attach .= 'Content-Disposition: attachment;' . "\n";
             $mail_file_attach .= ' filename="' . $file_name_name . '"' . "\n";
             $mail_file_attach .= 'Content-Transfer-Encoding: base64' . "\n\n";
             $mail_file_attach .= $data . "\n";
             #
             $body .= $mail_file_attach;
             #---------------------
             # MOD 25/11/2009 : END
             #
             $a++;
             #	25/11/2009
         }
     } else {
         if ($text_type == 'plain') {
             //				$headers .= 'Content-Type: text/'.$text_type.'; charset=utf-8;'._CR_;			# us-ascii, iso-8859-1
             $headers .= 'Content-Type: text/' . $text_type . '; charset=' . $_CHARSET . ';' . "\n";
             #	12/08/2009
             $headers .= 'Content-Transfer-Encoding: 8bit' . _CR_;
             # 7bit, 8bit
         }
         if ($text_type == 'html') {
             $headers .= 'Content-Type: multipart/alternative;' . _CR_;
             $headers .= ' boundary="' . $mime_boundary . '"' . "\n\n";
             #
             #	Add ascii
             #
             $mail_body_multipart = 'This is a multi-part message in MIME format.' . _CR_;
             $mail_body_multipart .= '--' . $mime_boundary . "\n";
             //				$mail_body_multipart .= 'Content-Type: text/plain; charset=utf-8; format=flowed'."\n";
             $mail_body_multipart .= 'Content-Type: text/plain; charset=' . $_CHARSET . '; format=flowed' . "\n";
             #	12/08/2009
             $mail_body_multipart .= 'Content-Transfer-Encoding: 8bit' . "\n\n";
             $mail_body_multipart .= $body . "\n\n";
             #
             #	Add html
             #
             $mail_body_multipart .= '--' . $mime_boundary . "\n";
             //				$mail_body_multipart .= 'Content-Type: text/html; charset=utf-8'."\n";
             $mail_body_multipart .= 'Content-Type: text/html; charset=' . $_CHARSET . "\n";
             #	12/08/2009
             $mail_body_multipart .= 'Content-Transfer-Encoding: 8bit' . "\n\n";
             $mail_body_multipart .= $body . "\n";
             #
             $body = $mail_body_multipart . "\n" . '--' . $mime_boundary . "--\n";
         }
     }
     #
     if ($_SESSION['misc']['MAILSRV'] != 'ini') {
         if (strlen($_SESSION['misc']['MAILSRV']) != 0) {
             ini_set(SMTP, $_SESSION['misc']['MAILSRV']);
         }
         if (strlen($_SESSION['misc']['MAILSRVPORT']) != 0) {
             ini_set(smtp_port, $_SESSION['misc']['MAILSRVPORT']);
         }
     }
     if (strlen($_SESSION['misc']['E_SENDER']) != 0) {
         ini_set(sendmail_from, $_SESSION['misc']['E_SENDER']);
     }
     #
     #	$extra_header = '-fwebmaster@{'.$domain.'}'; # this is the User of the machine or hosting account
     #
     //echo 'Subject:'.$subject
     //	.'<br>Reply:'.$reply
     //	.'<br>cc:'.$cc
     //	.'<br>To:'.$to
     //	.'<br>Body:<br>'.$body
     //	.'<br>From_id:'.$from_id
     //	.'<br>headers:'.$headers
     //	.'<br>Mail Server:'.$_SESSION['misc']['MAILSRV'].':'.$_SESSION['misc']['MAILSRVPORT']
     //	.'<br>E sender:'.$_SESSION['misc']['E_SENDER']
     //	;
     //die();
     //$tmp = false;	#debug
     $tmp = @mail($to, $subject, $body, $headers);
     #, $extra_header);
     #
     if ($_SESSION['misc']['MAILSRV'] != 'ini') {
         ini_restore(sendmail_from);
     }
     #
     if ($tmp == true) {
         if ($dbh) {
             _log_email(1, $from_id, $to, $reply, $subject, $user_body, $body, $headers);
             #	12/08/2009
         }
         return '*OK*';
     } else {
         if ($dbh) {
             _log_email(0, $from_id, $to, $reply, $subject, $user_body, $body, $headers);
             #	12/08/2009
         }
         #
         echo '<hr>There has been a mail error sending to:' . $to . '<hr>';
         //			if($USER_PRIV>=80)						#	18/02/2009
         if ($USER_PRIV > 79 || DEBUG == true) {
             echo 'Subject:' . $subject . '<br>Reply:' . $reply . '<br>cc:' . $cc . '<br>Body:<br>' . $body . '<br>From_id:' . $from_id . '<br>Mail Server:' . $_SESSION['misc']['MAILSRV'] . ':' . $_SESSION['misc']['MAILSRVPORT'] . '<br>Headers:' . $headers;
         }
         die('emailer');
     }
 }
Esempio n. 16
0
 /**
  * Embed audio in HTML
  *
  * @author Anika Henke <*****@*****.**>
  *
  * @param string $src       - ID of audio to embed
  * @param array  $atts      - additional attributes for the <audio> tag
  * @return string
  */
 function _audio($src, $atts = array())
 {
     $files = array();
     $isExternal = media_isexternal($src);
     if ($isExternal) {
         // take direct source for external files
         list(, $srcMime) = mimetype($src);
         $files[$srcMime] = $src;
     } else {
         // prepare alternative formats
         $extensions = array('ogg', 'mp3', 'wav');
         $files = media_alternativefiles($src, $extensions);
     }
     $out = '';
     // open audio tag
     $out .= '<audio ' . buildAttributes($atts) . ' controls="controls">' . NL;
     $fallback = '';
     // output source for each alternative audio format
     foreach ($files as $mime => $file) {
         if ($isExternal) {
             $url = $file;
             $linkType = 'externalmedia';
         } else {
             $url = ml($file, '', true, '&');
             $linkType = 'internalmedia';
         }
         $title = $atts['title'] ? $atts['title'] : $this->_xmlEntities(utf8_basename(noNS($file)));
         $out .= '<source src="' . hsc($url) . '" type="' . $mime . '" />' . NL;
         // alternative content (just a link to the file)
         $fallback .= $this->{$linkType}($file, $title, null, null, null, $cache = null, $linking = 'linkonly', $return = true);
     }
     // finish
     $out .= $fallback;
     $out .= '</audio>' . NL;
     return $out;
 }
Esempio n. 17
0
/**
 * Prints the third column in full-screen media manager
 * Depending on the opened tab this may be details of the
 * selected file, the meta editing dialog or
 * list of file revisions
 *
 * @author Kate Arzamastseva <*****@*****.**>
 */
function tpl_mediaFileDetails($image, $rev)
{
    global $AUTH, $NS, $conf, $DEL, $lang, $INPUT;
    $removed = !file_exists(mediaFN($image)) && file_exists(mediaMetaFN($image, '.changes')) && $conf['mediarevisions'];
    if (!$image || !file_exists(mediaFN($image)) && !$removed || $DEL) {
        return;
    }
    if ($rev && !file_exists(mediaFN($image, $rev))) {
        $rev = false;
    }
    if (isset($NS) && getNS($image) != $NS) {
        return;
    }
    $do = $INPUT->str('mediado');
    $opened_tab = $INPUT->str('tab_details');
    $tab_array = array('view');
    list(, $mime) = mimetype($image);
    if ($mime == 'image/jpeg') {
        $tab_array[] = 'edit';
    }
    if ($conf['mediarevisions']) {
        $tab_array[] = 'history';
    }
    if (!$opened_tab || !in_array($opened_tab, $tab_array)) {
        $opened_tab = 'view';
    }
    if ($INPUT->bool('edit')) {
        $opened_tab = 'edit';
    }
    if ($do == 'restore') {
        $opened_tab = 'view';
    }
    media_tabs_details($image, $opened_tab);
    echo '<div class="panelHeader"><h3>';
    list($ext) = mimetype($image, false);
    $class = preg_replace('/[^_\\-a-z0-9]+/i', '_', $ext);
    $class = 'select mediafile mf_' . $class;
    $tabTitle = '<strong><a href="' . ml($image) . '" class="' . $class . '" title="' . $lang['mediaview'] . '">' . $image . '</a>' . '</strong>';
    if ($opened_tab === 'view' && $rev) {
        printf($lang['media_viewold'], $tabTitle, dformat($rev));
    } else {
        printf($lang['media_' . $opened_tab], $tabTitle);
    }
    echo '</h3></div>' . NL;
    echo '<div class="panelContent">' . NL;
    if ($opened_tab == 'view') {
        media_tab_view($image, $NS, $AUTH, $rev);
    } elseif ($opened_tab == 'edit' && !$removed) {
        media_tab_edit($image, $NS, $AUTH);
    } elseif ($opened_tab == 'history' && $conf['mediarevisions']) {
        media_tab_history($image, $NS, $AUTH);
    }
    echo '</div>' . NL;
}
Esempio n. 18
0
 function render($format, &$renderer, $data)
 {
     if ($format !== 'xhtml') {
         return false;
     }
     // cancel if not xhtml
     global $INFO, $conf;
     if (DEBUG_MODE_ACTIVE != false || stripos($data[0], "perf") !== false) {
         $this->get_execution_time();
     }
     // skip ns
     if (strlen($data[1]) > 0) {
         $data[1] = str_replace(':', '/', $data[1]);
         // strip ending slash if exist
         $data[1] = rtrim($data[1], '/');
         //    echo $data[1].': Länge = '.strlen($data[1])." -> Letzte Position = ".strrpos($data[1],'/').'<br>';
     }
     // Media Filter by Extension ---------------------------------------
     $defFileTypes = explode(':', $data[0]);
     // split use case entry and file extensions
     $data[0] = $defFileTypes[0];
     // store pure use case entry back to data
     unset($defFileTypes[0]);
     // delete the use case entry to keep file extensions only
     $defFileTypes2 = implode(', ', $defFileTypes);
     // just for output the filter on summary
     $defFileTypes = implode('', $defFileTypes);
     // string of file extensions to easily compare it by strpos
     if ($defFileTypes2 == false) {
         $defFileTypes2 = 'none';
     }
     // -----------------------------------------------------------------
     // $data is an array
     // $data[0] is the report type: 'all' or 'valid' or 'missing' or 'orphan' or 'summary'
     // $defFileTypes is string of excluded media file types
     // -----------------------------------------------------------------------------
     // ! CHECK: Where are the excluded namespaces ?
     // -----------------------------------------------------------------------------
     // retrive all media files
     $listMediaFiles = array();
     $listMediaFiles = $this->_get_allMediaFiles($conf['mediadir'], $defFileTypes);
     $listMediaFiles = $this->array_flat($listMediaFiles);
     $media_file_counter = count($listMediaFiles);
     /*        echo '<pre>';
             print_r($data);
             echo '</pre>';  */
     if (DEBUG_MODE_ACTIVE != false || stripos($data[0], "perf") !== false) {
         $output .= '<div class="xm_perf">                                  
                               <p style="margin-top:10px;"><img src="' . DOKU_URL . '/lib/plugins/orphanmedia/images/a1.png" class="a1_img"><b><u>PERFORMANCE MEASUREMENT</u></b></p>' . NL . '<table class="xm_perf_tbl">' . NL . '<tr><td class="xm_perf_tbl"> used syntax: </td>                <td class="xm_perf_tbl"> ' . $data[99] . ' </td></tr>' . NL . '<tr><td class="xm_perf_tbl"> list of media files created: </td><td class="xm_perf_tbl"> ' . $this->get_execution_time() . ' s  </td></tr>' . NL;
     }
     // retrieve all page files
     $listPageFiles = array();
     $listPageFiles = $this->_get_allPageFiles($conf['datadir'], $data);
     $listPageFiles = $this->array_flat($listPageFiles);
     $page_counter = count($listPageFiles);
     if (DEBUG_MODE_ACTIVE != false || stripos($data[0], "perf") !== false) {
         $output .= '<tr><td class="xm_perf_tbl"> list of page files created: </td> <td class="xm_perf_tbl">' . $this->get_execution_time() . ' s </td><tr>' . NL;
     }
     // retrieve all media links per page file
     $listPageFile_MediaLinks = array();
     $listPageFile_MediaLinks = $this->_get_allMediaLinks($listPageFiles, $defFileTypes, $data[1]);
     //            echo sprintf("<p>%s</p>\n", var_dump($listPageFile_MediaLinks));
     if (DEBUG_MODE_ACTIVE != false || stripos($data[0], "perf") !== false) {
         $output .= '<tr><td class="xm_perf_tbl"> media links extracted from pages: </td><td class="xm_perf_tbl">' . $this->get_execution_time() . ' s </td></tr>' . NL;
     }
     // analyse matches of media files and pages->media links
     // what if savedir option is used ? => $conf['mediadir']
     $doku_media = $conf['mediadir'] . '/';
     $doku_pages = $conf['datadir'] . '/';
     //$doku_media = str_replace("\\","/",DOKU_MEDIA);
     //$doku_pages = str_replace("\\","/",DOKU_PAGES);
     $listMediaFiles = array($listMediaFiles, array_pad(array(), count($listMediaFiles), '0'));
     $position = 0;
     foreach ($listMediaFiles[0] as &$media_file_path) {
         // strip ...dokuwiki/data/media path
         $media_file_path = str_replace("\\", "/", $media_file_path);
         $media_file_path = str_replace($doku_media, "", $media_file_path);
         // underline maybe a blank on windows systems
         // so we have to replace the blanks of $media_file_path by underline characters
         $media_file_path = str_replace(" ", "_", $media_file_path);
         // 1. direct matches where pages->media links are identical to media file path
         foreach ($listPageFile_MediaLinks as &$perPage_MediaLinks) {
             for ($i = 1; $i < count($perPage_MediaLinks); $i++) {
                 // prevent destroying unc path
                 if (stripos($perPage_MediaLinks[$i], ":\\") === false && stripos($perPage_MediaLinks[$i], "://") === false) {
                     $perPage_MediaLinks[$i] = str_replace(":", "/", $perPage_MediaLinks[$i]);
                 }
                 // strip initial slash if exist
                 if (strpos($perPage_MediaLinks[$i], "/") === 0) {
                     $perPage_MediaLinks[$i] = ltrim($perPage_MediaLinks[$i], "/");
                 }
                 // case 1: find full qualified links: Page_MediaLink = media_file path
                 if ($perPage_MediaLinks[$i] === $media_file_path) {
                     $perPage_MediaLinks[$i] .= "|valid";
                     $listMediaFiles[1][$position] = "found";
                     continue;
                 }
                 // case 2: find relative links: Page_path + Page_MediaLink = media_file path
                 //example: Page = tst:start with a media link syntax like {{picture}} = mediafile(tst:picture)
                 if (stripos($data[2], "relativ") === false) {
                     if (strpos($perPage_MediaLinks[$i], "|valid") === false && strpos($perPage_MediaLinks[$i], "|relative") === false) {
                         $pagePath = rtrim($perPage_MediaLinks[0], end(explode("/", $perPage_MediaLinks[0]))) . $perPage_MediaLinks[$i];
                         // strip ...dokuwiki/data/pages path
                         $pagePath = str_replace("\\", "/", $pagePath);
                         $pagePath = str_replace($doku_pages, "", $pagePath);
                         //echo $pagePath.'<br />';
                         if ($pagePath === $media_file_path) {
                             $perPage_MediaLinks[$i] .= "|relative";
                             $listMediaFiles[1][$position] = "found";
                             continue;
                         }
                     }
                 }
                 // case 3: it is an external linked media by http or https
                 if (stripos($data[2], "extern") === false) {
                     if (strpos($perPage_MediaLinks[$i], 'http:') !== false || strpos($perPage_MediaLinks[$i], 'https:') !== false) {
                         if (strpos($perPage_MediaLinks[$i], "|valid") === false && strpos($perPage_MediaLinks[$i], "|relative") === false) {
                             $t_flag = $this->url_exist($perPage_MediaLinks[$i]);
                             if ($t_flag !== false) {
                                 $perPage_MediaLinks[$i] .= "|relative";
                                 $listMediaFiles[1][$position] = "found";
                                 continue;
                             }
                         }
                     }
                 }
             }
         }
         $position++;
     }
     if (DEBUG_MODE_ACTIVE != false || stripos($data[0], "perf") !== false) {
         $output .= '<tr><td class="xm_perf_tbl"> local and relative media found: </td><td  class="xm_perf_tbl">' . $this->get_execution_time() . ' s </td></tr>' . NL;
     }
     // 2. missing media files
     $ok_img = "ok.png";
     $nok_img = "nok.png";
     if (strlen($defFileTypes) > 1) {
         $filterInfo .= '<span>Filter settings: ' . $defFileTypes . '<br />';
     }
     $output_valid = '<div class="level1">' . '  <span>The following existing media files are referenced by full qualified path:</span><br />' . '<table class="inline">' . '<tr><th  class="orph_col0 centeralign">i</th>
                                <th  class="orph_col1 centeralign">#</th>
                                <th  class="orph_col2 centeralign"> Page files </th>
                                <th  class="orph_col3 centeralign"> valid Media </th></tr>';
     $output_relative = '<div class="level1">' . '  <span>The following existing media files are referenced by relative path:</span><br />' . '<table class="inline">' . '<tr><th  class="orph_col0 centeralign">i</th>
                                <th  class="orph_col1 centeralign">#</th>
                                <th  class="orph_col2 centeralign"> Page files </th>
                                <th  class="orph_col3 centeralign"> relative Media </th></tr>';
     $output_missing = '<div class="level1">' . '  <span>The following media files are missing:</span><br />' . '<table class="inline">' . '<tr><th  class="orph_col0 centeralign">i</th>
                                <th  class="orph_col1 centeralign">#</th>
                                <th  class="orph_col2 centeralign"> Page files </th>
                                <th  class="orph_col3 centeralign"> missing Media </th></tr>';
     $output_orphan = '<div class="level1">' . '  <span>The following media files are orphan:</span><br />' . '<table class="inline">' . '<tr><th  class="orph_col0 centeralign">i</th>
                                <th  class="orph_col1 centeralign">#</th>
                                <th  class="orph_col2 centeralign"> Media files </th>
                                <th  class="orph_col3 centeralign"> Preview orphan Media </th></tr>';
     foreach ($listPageFile_MediaLinks as $perPage_MediaLinks) {
         for ($i = 1; $i < count($perPage_MediaLinks); $i++) {
             $refLink_counter++;
             if (strpos($perPage_MediaLinks[$i], "|valid") > 0) {
                 $valid_counter++;
                 $output_valid .= $this->_prepare_output(rtrim($perPage_MediaLinks[$i], "|valid"), $perPage_MediaLinks[0], $ok_img, $valid_counter);
             }
             if (strpos($perPage_MediaLinks[$i], "|relative") > 0) {
                 $relative_counter++;
                 $output_relative .= $this->_prepare_output(rtrim($perPage_MediaLinks[$i], "|relative"), $perPage_MediaLinks[0], $ok_img, $relative_counter);
             }
             if (strpos($perPage_MediaLinks[$i], "|valid") === false && strpos($perPage_MediaLinks[$i], "|relative") === false) {
                 $missing_counter++;
                 $output_missing .= $this->_prepare_output($perPage_MediaLinks[$i], $perPage_MediaLinks[0], $nok_img, $missing_counter);
             }
         }
     }
     if (DEBUG_MODE_ACTIVE != false || stripos($data[0], "perf") !== false) {
         $output .= '<tr><td class="xm_perf_tbl"> missing media detected: </td><td class="xm_perf_tbl">' . $this->get_execution_time() . ' s </td></tr>' . NL;
     }
     $position = 0;
     $prviewcounter = 0;
     foreach ($listMediaFiles[1] as $check) {
         if ($check === '0') {
             $orphan_counter++;
             if (!$conf['useslash']) {
                 $rt2 = str_replace("/", ":", $listMediaFiles[0][$position]);
             } else {
                 $rt2 = $listMediaFiles[0][$position];
             }
             $m_link = $conf['mediadir'] . '/' . $listMediaFiles[0][$position];
             $style = '';
             $w_max = 200;
             $h_max = 75;
             if (preg_match("/\\.(jpe?g|gif|png)\$/", $m_link) && file_exists($m_link) && $prviewcounter < $this->getConf('prev_limit')) {
                 $minfo = getimagesize($m_link);
                 $w = (int) $minfo[0];
                 $h = (int) $minfo[1];
                 if ($w > $w_max || $h > $h_max) {
                     if ($h > $h_max) {
                         $ratio = $h_max / $h;
                         $h = $h_max;
                         $w = floor($w * $ratio);
                     } else {
                         $ratio = $w_max / $w;
                         $w = $w_max;
                         $h = floor($h * $ratio);
                     }
                 }
                 $prviewcounter++;
                 //$style = ' style="width: '.$w.'px; height: '.$h.'px;"';
                 $picturepreview = '<a href="' . DOKU_URL . 'lib/exe/detail.php?media=' . $rt2 . '" class="media" title="' . $listMediaFiles[0][$position] . '"><img src="' . DOKU_URL . 'lib/exe/fetch.php?media=' . $rt2 . '&w=' . $w . '&h=' . $h . '" class="media" ' . $style . 'alt="' . $listMediaFiles[0][$position] . '" /></a>';
             } else {
                 list($ext, $mime, $dl) = mimetype(mediaFN($m_link), false);
                 if (@file_exists(DOKU_INC . 'lib/images/fileicons/' . $ext . '.png')) {
                     $icon = DOKU_BASE . 'lib/images/fileicons/' . $ext . '.png';
                 } else {
                     $icon = DOKU_BASE . 'lib/images/fileicons/file.png';
                 }
                 $icon = '<img src="' . $icon . '" alt="' . $m_link . '" class="icon" />';
                 $picturepreview = '<a href="' . $m_link . '" class="wikilink" title="' . $m_link . '">' . $icon . '&nbsp;' . $rt2 . '</a>';
             }
             $output_orphan .= '<tr>' . NL . '<td>' . NL . '<img src="' . DOKU_URL . '/lib/plugins/orphanmedia/images/' . $nok_img . '" alt="nok" title="orphan" align="middle" />' . NL . '</td>' . NL . '<td>' . $orphan_counter . '</td>' . NL . '<td>' . $listMediaFiles[0][$position] . '</td>' . NL . '<td>' . $picturepreview . '</td>' . NL . '</tr>' . NL;
         }
         $position++;
     }
     if (DEBUG_MODE_ACTIVE != false || stripos($data[0], "perf") !== false) {
         $output .= '<tr><td class="xm_perf_tbl"> orphans detected: </td><td class="xm_perf_tbl">' . $this->get_execution_time() . ' s </td></tr></table></div><br />' . NL;
     }
     $output_valid .= '</table></div>';
     $output_relative .= '</table></div>';
     $output_missing .= '</table></div>';
     $output_orphan .= '</table></div>';
     $output_summary = '<div class="level1">' . NL . '  <span class="orph_sum_head">Summary</span><br />' . NL . '<table class="oprph_sum_tbl">' . NL . ' <tr>' . NL . '   <td class="oprph_sum_col0" rowspan="8">&nbsp;</td>' . NL . '   <td class="oprph_sum_col1">Page files</td>' . NL . '   <td class="oprph_sum_col2">' . $page_counter . '</td>' . NL . ' </tr>' . NL . ' <tr>' . NL . '   <td>Media files</td>' . NL . '   <td>' . $media_file_counter . '</td>' . NL . ' </tr>' . NL . ' <tr>' . NL . '   <td>Media references</td>' . NL . '   <td>' . $refLink_counter . '</td>' . NL . ' </tr>' . NL . ' <tr>' . NL . '   <td>Filter</td>' . NL . '   <td>' . $defFileTypes2 . '</td>' . NL . ' </tr>' . NL . ' <tr>' . NL . '   <td><b>Valid</b>, qualified references</td>' . NL . '   <td>' . $valid_counter . '</td>' . NL . ' </tr>' . NL . ' <tr>' . NL . '   <td><b>Valid</b>, relative references</td>' . NL . '   <td>' . $relative_counter . '</td>' . NL . ' </tr>' . NL . ' <tr>' . NL . '   <td><b>Missing</b> media files</td>' . NL . '   <td>' . $missing_counter . '</td>' . NL . ' </tr>' . NL . ' <tr>' . NL . '   <td><b>Orphan</b> media files</td>' . NL . '   <td>' . $orphan_counter . '</td>' . NL . ' </tr>' . NL . '</table></div>' . NL;
     if (stristr($data[0], "valid") === false && stristr($data[0], "all") === false) {
         $output_valid = '';
     }
     if (stristr($data[0], "relative") === false && stristr($data[0], "all") === false) {
         $output_relative = '';
     }
     if (stristr($data[0], "missing") === false && stristr($data[0], "all") === false) {
         $output_missing = '';
     }
     if (stristr($data[0], "orphan") === false && stristr($data[0], "all") === false) {
         $output_orphan = '';
     }
     $renderer->doc .= $output . $output_summary . $output_valid . $output_relative . $output_missing . $output_orphan;
     return true;
 }
Esempio n. 19
0
 /**
  * @param string $src
  * @param  $width
  * @param  $height
  * @param  $align
  * @param  $title
  * @param  $style
  * @param  $returnonly
  */
 function _odtAddImage($src, $width = NULL, $height = NULL, $align = NULL, $title = NULL, $style = NULL, $returnonly = false)
 {
     $doc = '';
     if (file_exists($src)) {
         list($ext, $mime) = mimetype($src);
         $name = 'Pictures/' . md5($src) . '.' . $ext;
         $this->docHandler->addFile($name, $mime, io_readfile($src, false));
     } else {
         $name = $src;
     }
     // make sure width and height are available
     if (!$width || !$height) {
         list($width, $height) = $this->_odtGetImageSize($src, $width, $height);
     } else {
         // Adjust values for ODT
         $width = $this->adjustXLengthValueForODT($width);
         $height = $this->adjustYLengthValueForODT($height);
     }
     if ($align) {
         $anchor = 'paragraph';
     } else {
         $anchor = 'as-char';
     }
     if (!$style or !array_key_exists($style, $this->autostyles)) {
         $style = $this->styleset->getStyleName('media ' . $align);
     }
     if ($title) {
         $doc .= '<draw:frame draw:style-name="' . $style . '" draw:name="' . $this->_xmlEntities($title) . ' Legend"
                         text:anchor-type="' . $anchor . '" draw:z-index="0" svg:width="' . $width . '">';
         $doc .= '<draw:text-box>';
         $doc .= '<text:p text:style-name="' . $this->styleset->getStyleName('legend center') . '">';
     }
     $doc .= '<draw:frame draw:style-name="' . $style . '" draw:name="' . $this->_xmlEntities($title) . '"
                     text:anchor-type="' . $anchor . '" draw:z-index="0"
                     svg:width="' . $width . '" svg:height="' . $height . '" >';
     $doc .= '<draw:image xlink:href="' . $this->_xmlEntities($name) . '"
                     xlink:type="simple" xlink:show="embed" xlink:actuate="onLoad"/>';
     $doc .= '</draw:frame>';
     if ($title) {
         $doc .= $this->_xmlEntities($title) . '</text:p></draw:text-box></draw:frame>';
     }
     if ($returnonly) {
         return $doc;
     } else {
         $this->doc .= $doc;
     }
 }
Esempio n. 20
0
 function update_file_metadata()
 {
     if (!$this->input->is_cli_request()) {
         return;
     }
     $chunk = 500;
     $total = $this->db->count_all("file_storage");
     for ($limit = 0; $limit < $total; $limit += $chunk) {
         $query = $this->db->select('hash, id')->from('file_storage')->limit($chunk, $limit)->get()->result_array();
         foreach ($query as $key => $item) {
             $data_id = $item["hash"] . '-' . $item['id'];
             $mimetype = mimetype($this->mfile->file($data_id));
             $this->db->where('id', $item['id'])->set(array('mimetype' => $mimetype))->update('file_storage');
         }
     }
 }
Esempio n. 21
0
/**
 * Return other media files with the same base name
 * but different extensions.
 *
 * @param string $src       - ID of media file
 * @param array $exts       - alternative extensions to find other files for
 * @return array            - mime type => file ID
 *
 * @author Anika Henke <*****@*****.**>
 */
function media_alternativefiles($src, $exts)
{
    $files = array();
    list($srcExt, $srcMime) = mimetype($src);
    $filebase = substr($src, 0, -1 * (strlen($srcExt) + 1));
    foreach ($exts as $ext) {
        $fileid = $filebase . '.' . $ext;
        $file = mediaFN($fileid);
        if (file_exists($file)) {
            list($fileExt, $fileMime) = mimetype($file);
            $files[$fileMime] = $fileid;
        }
    }
    return $files;
}
Esempio n. 22
0
function media_printicon($filename)
{
    list($ext, $mime, $dl) = mimetype(mediaFN($filename), false);
    if (@file_exists(DOKU_INC . 'lib/images/fileicons/' . $ext . '.png')) {
        $icon = DOKU_BASE . 'lib/images/fileicons/' . $ext . '.png';
    } else {
        $icon = DOKU_BASE . 'lib/images/fileicons/file.png';
    }
    return '<img src="' . $icon . '" alt="' . $filename . '" class="icon" />';
}
Esempio n. 23
0
 function copy_media($media, $external = false)
 {
     $name = epub_clean_name(str_replace(':', '_', basename($media)));
     $ret_name = $name;
     $mime_type = mimetype($name);
     list($type, $ext) = explode('/', $mime_type[1]);
     if ($type !== 'image') {
         return;
     }
     if ($external) {
         if (!$this->allow_url_fopen) {
             return;
         }
         $tmp = str_replace('https://', "", $media);
         $tmp = str_replace('http://', "", $media);
         $tmp = str_replace('www.', "", $tmp);
         if ($this->isWin) {
             $tmp = preg_replace('/^[A-Z]:/', "", $tmp);
         }
         $tmp = ltrim($tmp, '/\\/');
         $elems = explode('/', $tmp);
         if ($this->isWin) {
             $elems = explode('\\', $tmp);
         }
         if (count($elems && $elems[0])) {
             $elems[0] = preg_replace('#/\\W#', '_', $elems[0]);
             $name = $elems[0] . "_" . $name;
         }
     }
     if (!preg_match("/^Images/", $name)) {
         $name = "Images/{$name}";
     }
     $file = $this->oebps . $name;
     if (file_exists($file)) {
         return $name;
     }
     if (!$external) {
         $media = mediaFN($media);
     }
     if (copy($media, $file)) {
         epub_write_item($name, $mime_type[1]);
         return $name;
     } else {
         if (!$this->isWin && epub_save_image($media, $file)) {
             epub_write_item($name, $mime_type[1]);
             return $name;
         }
     }
     return false;
 }
Esempio n. 24
0
 /**
  * Renders internal and external media
  * 
  * @author Andreas Gohr <*****@*****.**>
  */
 function _media($src, $title = NULL, $align = NULL, $width = NULL, $height = NULL, $cache = NULL)
 {
     $ret = '';
     list($ext, $mime) = mimetype($src);
     if (substr($mime, 0, 5) == 'image') {
         //add image tag
         $ret .= '<img src="' . ml($src, array('w' => $width, 'h' => $height, 'cache' => $cache)) . '"';
         $ret .= ' class="media' . $align . '"';
         if (!is_null($title)) {
             $ret .= ' title="' . $this->_xmlEntities($title) . '"';
             $ret .= ' alt="' . $this->_xmlEntities($title) . '"';
         } elseif ($ext == 'jpg' || $ext == 'jpeg') {
             //try to use the caption from IPTC/EXIF
             require_once DOKU_INC . 'inc/JpegMeta.php';
             $jpeg =& new JpegMeta(mediaFN($src));
             if ($jpeg !== false) {
                 $cap = $jpeg->getTitle();
             }
             if ($cap) {
                 $ret .= ' title="' . $this->_xmlEntities($cap) . '"';
                 $ret .= ' alt="' . $this->_xmlEntities($cap) . '"';
             }
         } else {
             $ret .= ' alt=""';
         }
         if (!is_null($width)) {
             $ret .= ' width="' . $this->_xmlEntities($width) . '"';
         }
         if (!is_null($height)) {
             $ret .= ' height="' . $this->_xmlEntities($height) . '"';
         }
         $ret .= ' />';
     } elseif ($mime == 'application/x-shockwave-flash') {
         $ret .= '<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000"' . ' codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,40,0"';
         if (!is_null($width)) {
             $ret .= ' width="' . $this->_xmlEntities($width) . '"';
         }
         if (!is_null($height)) {
             $ret .= ' height="' . $this->_xmlEntities($height) . '"';
         }
         $ret .= '>' . DOKU_LF;
         $ret .= '<param name="movie" value="' . ml($src) . '" />' . DOKU_LF;
         $ret .= '<param name="quality" value="high" />' . DOKU_LF;
         $ret .= '<embed src="' . ml($src) . '"' . ' quality="high"';
         if (!is_null($width)) {
             $ret .= ' width="' . $this->_xmlEntities($width) . '"';
         }
         if (!is_null($height)) {
             $ret .= ' height="' . $this->_xmlEntities($height) . '"';
         }
         $ret .= ' type="application/x-shockwave-flash"' . ' pluginspage="http://www.macromedia.com/go/getflashplayer"></embed>' . DOKU_LF;
         $ret .= '</object>' . DOKU_LF;
     } elseif (!is_null($title)) {
         // well at least we have a title to display
         $ret .= $this->_xmlEntities($title);
     } else {
         // just show the sourcename
         $ret .= $this->_xmlEntities(noNS($src));
     }
     return $ret;
 }
Esempio n. 25
0
 /**
  * Send the diff for some media change
  *
  * @fixme this should embed thumbnails of images in HTML version
  * @param string   $subscriber_mail The target mail address
  * @param string   $template        Mail template ('uploadmail', ...)
  * @param string   $id              Media file for which the notification is
  * @param int|bool $rev             Old revision if any
  * @return bool                     true if successfully sent
  */
 public function send_media_diff($subscriber_mail, $template, $id, $rev = false)
 {
     global $conf;
     $file = mediaFN($id);
     list($mime, $ext) = mimetype($id);
     $trep = array('MIME' => $mime, 'MEDIA' => ml($id, '', true, '&', true), 'SIZE' => filesize_h(filesize($file)));
     if ($rev && $conf['mediarevisions']) {
         $trep['OLD'] = ml($id, "rev={$rev}", true, '&', true);
     } else {
         $trep['OLD'] = '---';
     }
     $headers = array('Message-Id' => $this->getMessageID($id, @filemtime($file)));
     if ($rev) {
         $headers['In-Reply-To'] = $this->getMessageID($id, $rev);
     }
     $this->send($subscriber_mail, 'upload', $id, $template, $trep, null, $headers);
 }
Esempio n. 26
0
 /**
  * Uploads a file to the wiki.
  *
  * Michael Klier <*****@*****.**>
  */
 function putAttachment($id, $file, $params)
 {
     $id = cleanID($id);
     global $conf;
     global $lang;
     $auth = auth_quickaclcheck(getNS($id) . ':*');
     if ($auth >= AUTH_UPLOAD) {
         if (!isset($id)) {
             return new IXR_ERROR(1, 'Filename not given.');
         }
         $ftmp = $conf['tmpdir'] . '/' . md5($id . clientIP());
         // save temporary file
         @unlink($ftmp);
         $buff = base64_decode($file);
         io_saveFile($ftmp, $buff);
         // get filename
         list($iext, $imime, $dl) = mimetype($id);
         $id = cleanID($id);
         $fn = mediaFN($id);
         // get filetype regexp
         $types = array_keys(getMimeTypes());
         $types = array_map(create_function('$q', 'return preg_quote($q,"/");'), $types);
         $regex = join('|', $types);
         // because a temp file was created already
         if (preg_match('/\\.(' . $regex . ')$/i', $fn)) {
             //check for overwrite
             $overwrite = @file_exists($fn);
             if ($overwrite && (!$params['ow'] || $auth < AUTH_DELETE)) {
                 return new IXR_ERROR(1, $lang['uploadexist'] . '1');
             }
             // check for valid content
             $ok = media_contentcheck($ftmp, $imime);
             if ($ok == -1) {
                 return new IXR_ERROR(1, sprintf($lang['uploadexist'] . '2', ".{$iext}"));
             } elseif ($ok == -2) {
                 return new IXR_ERROR(1, $lang['uploadspam']);
             } elseif ($ok == -3) {
                 return new IXR_ERROR(1, $lang['uploadxss']);
             }
             // prepare event data
             $data[0] = $ftmp;
             $data[1] = $fn;
             $data[2] = $id;
             $data[3] = $imime;
             $data[4] = $overwrite;
             // trigger event
             return trigger_event('MEDIA_UPLOAD_FINISH', $data, array($this, '_media_upload_action'), true);
         } else {
             return new IXR_ERROR(1, $lang['uploadwrong']);
         }
     } else {
         return new IXR_ERROR(1, "You don't have permissions to upload files.");
     }
 }
 /**
  * Override the mpdf _getImage function
  *
  * This function takes care of gathering the image data from HTTP or
  * local files before passing the data back to mpdf's original function
  * making sure that only cached file paths are passed to mpdf. It also
  * takes care of checking image ACls.
  */
 function _getImage(&$file, $firsttime = true, $allowvector = true, $orig_srcpath = false)
 {
     global $conf;
     // build regex to parse URL back to media info
     $re = preg_quote(ml('xxx123yyy', '', true, '&', true), '/');
     $re = str_replace('xxx123yyy', '([^&\\?]*)', $re);
     // extract the real media from a fetch.php uri and determine mime
     if (preg_match("/^{$re}/", $file, $m) || preg_match('/[&\\?]media=([^&\\?]*)/', $file, $m)) {
         $media = rawurldecode($m[1]);
         list($ext, $mime) = mimetype($media);
     } else {
         list($ext, $mime) = mimetype($file);
     }
     // local files
     $local = '';
     if (substr($file, 0, 9) == 'dw2pdf://') {
         // support local files passed from plugins
         $local = substr($file, 9);
     } elseif (!preg_match('/(\\.php|\\?)/', $file)) {
         $re = preg_quote(DOKU_URL, '/');
         // directly access local files instead of using HTTP, skip dynamic content
         $local = preg_replace("/^{$re}/i", DOKU_INC, $file);
     }
     if (substr($mime, 0, 6) == 'image/') {
         if (!empty($media)) {
             // any size restrictions?
             $w = $h = 0;
             if (preg_match('/[\\?&]w=(\\d+)/', $file, $m)) {
                 $w = $m[1];
             }
             if (preg_match('/[\\?&]h=(\\d+)/', $file, $m)) {
                 $h = $m[1];
             }
             if (media_isexternal($media)) {
                 $local = media_get_from_URL($media, $ext, -1);
                 if (!$local) {
                     $local = $media;
                 }
                 // let mpdf try again
             } else {
                 $media = cleanID($media);
                 //check permissions (namespace only)
                 if (auth_quickaclcheck(getNS($media) . ':X') < AUTH_READ) {
                     $file = '';
                 }
                 $local = mediaFN($media);
             }
             //handle image resizing/cropping
             if ($w && file_exists($local)) {
                 if ($h) {
                     $local = media_crop_image($local, $ext, $w, $h);
                 } else {
                     $local = media_resize_image($local, $ext, $w, $h);
                 }
             }
         } elseif (media_isexternal($file)) {
             // fixed external URLs
             $local = media_get_from_URL($file, $ext, $conf['cachetime']);
         }
         if ($local) {
             $file = $local;
             $orig_srcpath = $local;
         }
     }
     return parent::_getImage($file, $firsttime, $allowvector, $orig_srcpath);
 }
Esempio n. 28
0
 /**
  * Callback function to automatically embed images referenced in HTML templates
  *
  * @param array $matches
  * @return string placeholder
  */
 protected function autoembed_cb($matches)
 {
     static $embeds = 0;
     $embeds++;
     // get file and mime type
     $media = cleanID($matches[1]);
     list(, $mime) = mimetype($media);
     $file = mediaFN($media);
     if (!file_exists($file)) {
         return $matches[0];
     }
     //bad reference, keep as is
     // attach it and set placeholder
     $this->attachFile($file, $mime, '', 'autoembed' . $embeds);
     return '%%autoembed' . $embeds . '%%';
 }
 /**
  * Formats and prints one file in the list
  *
  * @see media_printfile()
  */
 function _mod_media_printfile($item, $auth, $jump, $display_namespace = false)
 {
     global $lang;
     global $conf;
     // Prepare zebra coloring
     // I always wanted to use this variable name :-D
     static $twibble = 1;
     $twibble *= -1;
     $zebra = $twibble == -1 ? 'odd' : 'even';
     // Automatically jump to recent action
     if ($jump == $item['id']) {
         $jump = ' id="scroll__here" ';
     } else {
         $jump = '';
     }
     // Prepare fileicons
     list($ext, $mime, $dl) = mimetype($item['file'], false);
     $class = preg_replace('/[^_\\-a-z0-9]+/i', '_', $ext);
     $class = 'select mediafile mf_' . $class;
     // Prepare filename
     $file = $this->_getOriginalFileName($item['id']);
     if ($file === false) {
         $file = utf8_decodeFN($item['file']);
     }
     // build fake media id
     $ns = getNS($item['id']);
     $fakeId = $ns === false ? $file : "{$ns}:{$file}";
     $fakeId_escaped = hsc($fakeId);
     // Prepare info
     $info = '';
     if ($item['isimg']) {
         $info .= (int) $item['meta']->getField('File.Width');
         $info .= '&#215;';
         $info .= (int) $item['meta']->getField('File.Height');
         $info .= ' ';
     }
     $info .= '<i>' . dformat($item['mtime']) . '</i>';
     $info .= ' ';
     $info .= filesize_h($item['size']);
     // output
     echo '<div class="' . $zebra . '"' . $jump . ' title="' . $fakeId_escaped . '">' . NL;
     if (!$display_namespace) {
         echo '<a name="h_:' . $item['id'] . '" class="' . $class . '">' . hsc($file) . '</a> ';
     } else {
         echo '<a name="h_:' . $item['id'] . '" class="' . $class . '">' . $fakeId_escaped . '</a><br/>';
     }
     echo '<span class="info">(' . $info . ')</span>' . NL;
     // view button
     $link = ml($fakeId, '', true);
     echo ' <a href="' . $link . '" target="_blank"><img src="' . DOKU_BASE . 'lib/images/magnifier.png" ' . 'alt="' . $lang['mediaview'] . '" title="' . $lang['mediaview'] . '" class="btn" /></a>';
     // mediamanager button
     $link = wl('', array('do' => 'media', 'image' => $fakeId, 'ns' => $ns));
     echo ' <a href="' . $link . '" target="_blank"><img src="' . DOKU_BASE . 'lib/images/mediamanager.png" ' . 'alt="' . $lang['btn_media'] . '" title="' . $lang['btn_media'] . '" class="btn" /></a>';
     // delete button
     if ($item['writable'] && $auth >= AUTH_DELETE) {
         $link = DOKU_BASE . 'lib/exe/mediamanager.php?delete=' . rawurlencode($fakeId) . '&amp;sectok=' . getSecurityToken();
         echo ' <a href="' . $link . '" class="btn_media_delete" title="' . $fakeId_escaped . '">' . '<img src="' . DOKU_BASE . 'lib/images/trash.png" alt="' . $lang['btn_delete'] . '" ' . 'title="' . $lang['btn_delete'] . '" class="btn" /></a>';
     }
     echo '<div class="example" id="ex_' . str_replace(':', '_', $item['id']) . '">';
     echo $lang['mediausage'] . ' <code>{{:' . str_replace(array('{', '}'), array('(', ')'), $fakeId_escaped) . '}}</code>';
     echo '</div>';
     if ($item['isimg']) {
         media_printimgdetail($item);
     }
     echo '<div class="clearer"></div>' . NL;
     echo '</div>' . NL;
 }
Esempio n. 30
0
 function _odtAddImage($src, $width = NULL, $height = NULL, $align = NULL, $title = NULL, $style = NULL)
 {
     if (file_exists($src)) {
         list($ext, $mime) = mimetype($src);
         $name = 'Pictures/' . md5($src) . '.' . $ext;
         if (!$this->manifest[$name]) {
             $this->manifest[$name] = $mime;
             $this->ZIP->add_File(io_readfile($src, false), $name, 0);
         }
     } else {
         $name = $src;
     }
     // make sure width and height are available
     if (!$width || !$height) {
         list($width, $height) = $this->_odtGetImageSize($src, $width, $height);
     }
     if ($align) {
         $anchor = 'paragraph';
     } else {
         $anchor = 'as-char';
     }
     if (!$style or !array_key_exists($style, $this->autostyles)) {
         $style = 'media' . $align;
     }
     if ($title) {
         $this->doc .= '<draw:frame draw:style-name="' . $style . '" draw:name="' . $this->_xmlEntities($title) . ' Legend"
                         text:anchor-type="' . $anchor . '" draw:z-index="0" svg:width="' . $width . '">';
         $this->doc .= '<draw:text-box>';
         $this->doc .= '<text:p text:style-name="legendcenter">';
     }
     $this->doc .= '<draw:frame draw:style-name="' . $style . '" draw:name="' . $this->_xmlEntities($title) . '"
                     text:anchor-type="' . $anchor . '" draw:z-index="0"
                     svg:width="' . $width . '" svg:height="' . $height . '" >';
     $this->doc .= '<draw:image xlink:href="' . $this->_xmlEntities($name) . '"
                     xlink:type="simple" xlink:show="embed" xlink:actuate="onLoad"/>';
     $this->doc .= '</draw:frame>';
     if ($title) {
         $this->doc .= $this->_xmlEntities($title) . '</text:p></draw:text-box></draw:frame>';
     }
 }