function white_pageinfo($ret = false)
{
    global $conf;
    global $lang;
    global $INFO;
    global $ID;
    // return if we are not allowed to view the page
    if (!auth_quickaclcheck($ID)) {
        return false;
    }
    $date = dformat($INFO['lastmod']);
    // print it
    if ($INFO['exists']) {
        $out = '';
        $out .= $lang['lastmod'];
        $out .= ' ';
        $out .= $date;
        if ($ret) {
            return $out;
        } else {
            echo $out;
            return true;
        }
    }
    return false;
}
 /**
  * Build a nice email from the submitted data and send it
  */
 function run($data, $thanks, $argv)
 {
     global $ID;
     // get recipient address(es)
     $to = join(',', $argv);
     $sub = sprintf($this->getLang('mailsubject'), $ID);
     $txt = sprintf($this->getLang('mailintro') . "\n\n\n", dformat());
     foreach ($data as $opt) {
         $value = $opt->getParam('value');
         $label = $opt->getParam('label');
         switch ($opt->getFieldType()) {
             case 'fieldset':
                 $txt .= "\n====== " . hsc($label) . " ======\n\n";
                 break;
             default:
                 if ($value === null || $label === null) {
                     break;
                 }
                 $txt .= $label . "\n";
                 $txt .= "\t\t{$value}\n";
         }
     }
     global $conf;
     if (!mail_send($to, $sub, $txt, $conf['mailfrom'])) {
         throw new Exception($this->getLang('e_mail'));
     }
     return $thanks;
 }
Exemple #3
0
 /**
  * Return a page id based on the given format and title.
  *
  * @param $format string the format of the id to generate
  * @param $title  string the title of the page to create
  * @return string a page id
  */
 public static function mkpostid($format, $title)
 {
     global $conf;
     $replace = array('%{title}' => str_replace(':', $conf['sepchar'], $title), '%{user}' => $_SERVER['REMOTE_USER']);
     $out = $format;
     $out = str_replace(array_keys($replace), array_values($replace), $out);
     $out = dformat(null, $out);
     return cleanID($out);
 }
 /**
  * Build a nice email from the submitted data and send it
  *
  * @param helper_plugin_bureaucracy_field[] $fields
  * @param string                            $thanks
  * @param array                             $argv
  * @return string thanks message
  * @throws Exception mailing failed
  */
 public function run($fields, $thanks, $argv)
 {
     global $ID;
     global $conf;
     $mail = new Mailer();
     $this->prepareNamespacetemplateReplacements();
     $this->prepareDateTimereplacements();
     $this->prepareLanguagePlaceholder();
     $this->prepareNoincludeReplacement();
     $this->prepareFieldReplacements($fields);
     //set default subject
     $this->subject = sprintf($this->getLang('mailsubject'), $ID);
     //build html&text table, collect replyto and subject
     list($table_html, $table_text) = $this->processFieldsBuildTable($fields, $mail);
     //Body
     if ($this->mailtemplate) {
         //show template
         $this->patterns['__tablehtml__'] = '/@TABLEHTML@/';
         $this->patterns['__tabletext__'] = '/@TABLETEXT@/';
         $this->values['__tablehtml__'] = $table_html;
         $this->values['__tabletext__'] = $table_text;
         list($this->_mail_html, $this->_mail_text) = $this->getContent();
     } else {
         //show simpel listing
         $this->_mail_html .= sprintf($this->getLang('mailintro') . "<br><br>", dformat());
         $this->_mail_html .= $table_html;
         $this->_mail_text .= sprintf($this->getLang('mailintro') . "\n\n", dformat());
         $this->_mail_text .= $table_text;
     }
     $mail->setBody($this->_mail_text, null, null, $this->_mail_html);
     // Reply-to
     if (!empty($this->replyto)) {
         $replyto = $mail->cleanAddress($this->replyto);
         $mail->setHeader('Reply-To', $replyto, false);
     }
     // To
     $to = $this->replace(implode(',', $argv));
     // get recipient address(es)
     $to = $mail->cleanAddress($to);
     $mail->to($to);
     // From
     if (empty($this->from)) {
         $this->from = $conf['mailfrom'];
     }
     $this->from = $this->replace($this->from);
     $mail->from($this->from);
     // Subject
     $this->subject = $this->replace($this->subject);
     $mail->subject($this->subject);
     if (!$mail->send()) {
         throw new Exception($this->getLang('e_mail'));
     }
     return $thanks;
 }
Exemple #5
0
/**
 * prepares the signature string as configured in the config
 *
 * @author Andreas Gohr <*****@*****.**>
 */
function toolbar_signature()
{
    global $conf;
    global $INFO;
    $sig = $conf['signature'];
    $sig = strftime($sig);
    $sig = str_replace('@USER@', $_SERVER['REMOTE_USER'], $sig);
    $sig = str_replace('@NAME@', $INFO['userinfo']['name'], $sig);
    $sig = str_replace('@MAIL@', $INFO['userinfo']['mail'], $sig);
    $sig = str_replace('@DATE@', dformat(), $sig);
    $sig = str_replace('\\\\n', '\\n', addslashes($sig));
    return $sig;
}
 /**
  * send an email to inform about a changed page
  *
  * @param $event
  * @param $param
  * @return bool false if the receiver is invalid or there was an error passing the mail to the MTA
  */
 function send_change_mail(&$event, $param)
 {
     global $ID;
     global $ACT;
     global $INFO;
     global $conf;
     $data = pageinfo();
     if ($ACT != 'save') {
         return true;
     }
     // IO_WIKIPAGE_WRITE is always called twice when saving a page. This makes sure to only send the mail once.
     if (!$event->data[3]) {
         return true;
     }
     // Does the publish plugin apply to this page?
     if (!$this->hlp->isActive($ID)) {
         return true;
     }
     //are we supposed to send change-mails at all?
     if ($this->getConf('apr_mail_receiver') === '') {
         return true;
     }
     // get mail receiver
     $receiver = $this->getConf('apr_mail_receiver');
     $validator = new EmailAddressValidator();
     $validator->allowLocalAddresses = true;
     if (!$validator->check_email_address($receiver)) {
         dbglog(sprintf($this->getLang('mail_invalid'), htmlspecialchars($receiver)));
         return false;
     }
     // get mail sender
     $ReplyTo = $data['userinfo']['mail'];
     if ($ReplyTo == $receiver) {
         return true;
     }
     if ($INFO['isadmin'] == '1') {
         return true;
     }
     // get mail subject
     $timestamp = dformat($data['lastmod'], $conf['dformat']);
     $subject = $this->getLang('apr_mail_subject') . ': ' . $ID . ' - ' . $timestamp;
     $body = $this->create_mail_body('change');
     $mail = new Mailer();
     $mail->to($receiver);
     $mail->subject($subject);
     $mail->setBody($body);
     $mail->setHeader("Reply-To", $ReplyTo);
     $returnStatus = $mail->send();
     return $returnStatus;
 }
Exemple #7
0
/**
 * prepares the signature string as configured in the config
 *
 * @author Andreas Gohr <*****@*****.**>
 */
function toolbar_signature()
{
    global $conf;
    global $INFO;
    /** @var Input $INPUT */
    global $INPUT;
    $sig = $conf['signature'];
    $sig = dformat(null, $sig);
    $sig = str_replace('@USER@', $INPUT->server->str('REMOTE_USER'), $sig);
    $sig = str_replace('@NAME@', $INFO['userinfo']['name'], $sig);
    $sig = str_replace('@MAIL@', $INFO['userinfo']['mail'], $sig);
    $sig = str_replace('@DATE@', dformat(), $sig);
    $sig = str_replace('\\\\n', '\\n', addslashes($sig));
    return $sig;
}
Exemple #8
0
 /**
  * Build a nice email from the submitted data and send it
  */
 function run($fields, $thanks, $argv)
 {
     global $ID;
     $this->prepareLanguagePlaceholder();
     // get recipient address(es)
     $to = join(',', $argv);
     $replyto = array();
     $headers = null;
     $subject = sprintf($this->getLang('mailsubject'), $ID);
     $txt = sprintf($this->getLang('mailintro') . "\n\n\n", dformat());
     foreach ($fields as $opt) {
         /** @var syntax_plugin_bureaucracy_field $opt */
         $value = $opt->getParam('value');
         $label = $opt->getParam('label');
         switch ($opt->getFieldType()) {
             case 'fieldset':
                 $txt .= "\n====== " . hsc($label) . " ======\n\n";
                 break;
             case 'subject':
                 $subject = $label;
                 break;
             case 'email':
                 if (!is_null($opt->getParam('replyto'))) {
                     $replyto[] = $value;
                 }
                 /** fall through */
             /** fall through */
             default:
                 if ($value === null || $label === null) {
                     break;
                 }
                 $txt .= $label . "\n";
                 $txt .= "\t\t{$value}\n";
         }
         $this->prepareFieldReplacements($label, $value);
     }
     $subject = $this->replaceDefault($subject);
     if (!empty($replyto)) {
         $headers = mail_encode_address(join(',', $replyto), 'Reply-To');
     }
     global $conf;
     if (!mail_send($to, $subject, $txt, $conf['mailfrom'], '', '', $headers)) {
         throw new Exception($this->getLang('e_mail'));
     }
     return $thanks;
 }
/**
 * Print some info about the current page
 *
 * @author  Andreas Gohr <*****@*****.**>
 * @author  Giuseppe Di Terlizzi <*****@*****.**>
 *
 * @param   bool $ret return content instead of printing it
 * @return  bool|string
 */
function bootstrap3_pageinfo($ret = false)
{
    global $conf;
    global $lang;
    global $INFO;
    global $ID;
    // return if we are not allowed to view the page
    if (!auth_quickaclcheck($ID)) {
        return false;
    }
    // prepare date and path
    $fn = $INFO['filepath'];
    if (!$conf['fullpath']) {
        if ($INFO['rev']) {
            $fn = str_replace(fullpath($conf['olddir']) . '/', '', $fn);
        } else {
            $fn = str_replace(fullpath($conf['datadir']) . '/', '', $fn);
        }
    }
    $date_format = bootstrap3_conf('pageInfoDateFormat');
    $page_info = bootstrap3_conf('pageInfo');
    $fn = utf8_decodeFN($fn);
    $date = $date_format == 'dformat' ? dformat($INFO['lastmod']) : datetime_h($INFO['lastmod']);
    // print it
    if ($INFO['exists']) {
        $fn_full = $fn;
        if (!in_array('extension', $page_info)) {
            $fn = str_replace(array('.txt.gz', '.txt'), '', $fn);
        }
        $out = '<ul class="list-inline">';
        if (in_array('filename', $page_info)) {
            $out .= sprintf('<li><i class="fa fa-fw fa-file-text-o text-muted"></i> <span title="%s">%s</span></li>', $fn_full, $fn);
        }
        if (in_array('date', $page_info)) {
            $out .= sprintf('<li><i class="fa fa-fw fa-calendar text-muted"></i> %s <span title="%s">%s</span></li>', $lang['lastmod'], dformat($INFO['lastmod']), $date);
        }
        if (in_array('editor', $page_info)) {
            if (isset($INFO['editor'])) {
                $user = editorinfo($INFO['editor']);
                if (bootstrap3_conf('useGravatar')) {
                    global $auth;
                    $user_data = $auth->getUserData($INFO['editor']);
                    $HTTP = new DokuHTTPClient();
                    $gravatar_img = get_gravatar($user_data['mail'], 16);
                    $gravatar_check = $HTTP->get($gravatar_img . '&d=404');
                    if ($gravatar_check) {
                        $user_img = sprintf('<img src="%s" alt="" width="16" class="img-rounded" /> ', $gravatar_img);
                        $user = str_replace(array('iw_user', 'interwiki'), '', $user);
                        $user = $user_img . $user;
                    }
                }
                $out .= sprintf('<li class="text-muted">%s %s</li>', $lang['by'], $user);
            } else {
                $out .= sprintf('<li>(%s)</li>', $lang['external_edit']);
            }
        }
        if ($INFO['locked'] && in_array('locked', $page_info)) {
            $out .= sprintf('<li><i class="fa fa-fw fa-lock text-muted"></i> %s %s</li>', $lang['lockedby'], editorinfo($INFO['locked']));
        }
        $out .= '</ul>';
        if ($ret) {
            return $out;
        } else {
            echo $out;
            return true;
        }
    }
    return false;
}
Exemple #10
0
 /**
  * Prepare default token replacement strings
  *
  * Populates the '$replacements' property.
  * Should be called by the class constructor
  */
 protected function prepareTokenReplacements()
 {
     global $INFO;
     global $conf;
     /* @var Input $INPUT */
     global $INPUT;
     global $lang;
     $ip = clientIP();
     $cip = gethostsbyaddrs($ip);
     $this->replacements['text'] = array('DATE' => dformat(), 'BROWSER' => $INPUT->server->str('HTTP_USER_AGENT'), 'IPADDRESS' => $ip, 'HOSTNAME' => $cip, 'TITLE' => $conf['title'], 'DOKUWIKIURL' => DOKU_URL, 'USER' => $INPUT->server->str('REMOTE_USER'), 'NAME' => $INFO['userinfo']['name'], 'MAIL' => $INFO['userinfo']['mail']);
     $signature = str_replace('@DOKUWIKIURL@', $this->replacements['text']['DOKUWIKIURL'], $lang['email_signature_text']);
     $this->replacements['text']['EMAILSIGNATURE'] = "\n-- \n" . $signature . "\n";
     $this->replacements['html'] = array('DATE' => '<i>' . hsc(dformat()) . '</i>', 'BROWSER' => hsc($INPUT->server->str('HTTP_USER_AGENT')), 'IPADDRESS' => '<code>' . hsc($ip) . '</code>', 'HOSTNAME' => '<code>' . hsc($cip) . '</code>', 'TITLE' => hsc($conf['title']), 'DOKUWIKIURL' => '<a href="' . DOKU_URL . '">' . DOKU_URL . '</a>', 'USER' => hsc($INPUT->server->str('REMOTE_USER')), 'NAME' => hsc($INFO['userinfo']['name']), 'MAIL' => '<a href="mailto:"' . hsc($INFO['userinfo']['mail']) . '">' . hsc($INFO['userinfo']['mail']) . '</a>');
     $signature = $lang['email_signature_text'];
     if (!empty($lang['email_signature_html'])) {
         $signature = $lang['email_signature_html'];
     }
     $signature = str_replace(array('@DOKUWIKIURL@', "\n"), array($this->replacements['html']['DOKUWIKIURL'], '<br />'), $signature);
     $this->replacements['html']['EMAILSIGNATURE'] = $signature;
 }
Exemple #11
0
 /**
  * Render the day header
  *
  * @param Doku_Renderer $R
  * @param int $date
  */
 protected function dayheader(&$R, $date)
 {
     if ($R->getFormat() == 'xhtml') {
         /* @var Doku_Renderer_xhtml $R  */
         $R->doc .= '<h3 class="changes">';
         $R->cdata(dformat($date, $this->getConf('dayheaderfmt')));
         $R->doc .= '</h3>';
     } else {
         $R->header(dformat($date, $this->getConf('dayheaderfmt')), 3, 0);
     }
 }
Exemple #12
0
function _tpl_pageinfo()
{
    global $conf;
    global $lang;
    global $INFO;
    global $ID;
    // return if we are not allowed to view the page
    if (!auth_quickaclcheck($ID)) {
        return;
    }
    // prepare date and path
    $date = dformat($INFO['lastmod']);
    // echo it
    if ($INFO['exists']) {
        echo $lang['lastmod'], ': ', $date;
        if ($_SERVER['REMOTE_USER']) {
            if ($INFO['editor']) {
                echo ' ', $lang['by'], ' ', $INFO['editor'];
            } else {
                echo ' (', $lang['external_edit'], ')';
            }
            if ($INFO['locked']) {
                echo ' &middot; ', $lang['lockedby'], ': ', $INFO['locked'];
            }
        }
        return true;
    }
    return false;
}
Exemple #13
0
    ?>
      </p>

      <p>&larr; <?php 
    echo $lang['img_backto'];
    ?>
 <?php 
    tpl_pagelink($ID);
    ?>
</p>

      <dl class="img_tags">
        <?php 
    $t = tpl_img_getTag('Date.EarliestTime');
    if ($t) {
        print '<dt>' . $lang['img_date'] . ':</dt><dd>' . dformat($t) . '</dd>';
    }
    $t = tpl_img_getTag('File.Name');
    if ($t) {
        print '<dt>' . $lang['img_fname'] . ':</dt><dd>' . hsc($t) . '</dd>';
    }
    $t = tpl_img_getTag(array('Iptc.Byline', 'Exif.TIFFArtist', 'Exif.Artist', 'Iptc.Credit'));
    if ($t) {
        print '<dt>' . $lang['img_artist'] . ':</dt><dd>' . hsc($t) . '</dd>';
    }
    $t = tpl_img_getTag(array('Iptc.CopyrightNotice', 'Exif.TIFFCopyright', 'Exif.Copyright'));
    if ($t) {
        print '<dt>' . $lang['img_copyr'] . ':</dt><dd>' . hsc($t) . '</dd>';
    }
    $t = tpl_img_getTag('File.Format');
    if ($t) {
Exemple #14
0
    /**
     * Date - creation or last modification date if not set otherwise
     */
    function _dateCell() {    
        global $conf;

        if($this->column['date'] == 2) {
            $this->page['date'] = $this->_getMeta(array('date', 'modified'));
        } elseif(!$this->page['date'] && $this->page['exists']) {
            $this->page['date'] = $this->_getMeta(array('date', 'created'));
        }

        if ((!$this->page['date']) || (!$this->page['exists'])) {
            return $this->_printCell('date', '');
        } else {
            return $this->_printCell('date', dformat($this->page['date'], $conf['dformat']));
        }
    }
Exemple #15
0
/**
 * Refresh a page lock and save draft
 *
 * Andreas Gohr <*****@*****.**>
 */
function ajax_lock()
{
    global $conf;
    global $lang;
    global $ID;
    global $INFO;
    global $INPUT;
    $ID = cleanID($INPUT->post->str('id'));
    if (empty($ID)) {
        return;
    }
    $INFO = pageinfo();
    if (!$INFO['writable']) {
        echo 'Permission denied';
        return;
    }
    if (!checklock($ID)) {
        lock($ID);
        echo 1;
    }
    if ($conf['usedraft'] && $INPUT->post->str('wikitext')) {
        $client = $_SERVER['REMOTE_USER'];
        if (!$client) {
            $client = clientIP(true);
        }
        $draft = array('id' => $ID, 'prefix' => substr($INPUT->post->str('prefix'), 0, -1), 'text' => $INPUT->post->str('wikitext'), 'suffix' => $INPUT->post->str('suffix'), 'date' => $INPUT->post->int('date'), 'client' => $client);
        $cname = getCacheName($draft['client'] . $ID, '.draft');
        if (io_saveFile($cname, serialize($draft))) {
            echo $lang['draftdate'] . ' ' . dformat();
        }
    }
}
 /**
  * Replace placeholders in sql
  */
 function _replacePlaceholdersInSQL(&$data)
 {
     global $USERINFO;
     // allow current user name in filter:
     $data['sql'] = str_replace('%user%', $_SERVER['REMOTE_USER'], $data['sql']);
     $data['sql'] = str_replace('%groups%', implode("','", (array) $USERINFO['grps']), $data['sql']);
     // allow current date in filter:
     $data['sql'] = str_replace('%now%', dformat(null, '%Y-%m-%d'), $data['sql']);
     // language filter
     $data['sql'] = $this->makeTranslationReplacement($data['sql']);
 }
Exemple #17
0
/**
 * Formats and prints one file in the list in the thumbnails view
 *
 * @author Kate Arzamastseva <*****@*****.**>
 */
function media_printfile_thumbs($item, $auth, $jump = false, $display_namespace = false)
{
    // Prepare filename
    $file = utf8_decodeFN($item['file']);
    // output
    echo '<li><dl title="' . hsc($item['id']) . '">' . NL;
    echo '<dt>';
    if ($item['isimg']) {
        media_printimgdetail($item, true);
    } else {
        echo '<a id="d_:' . $item['id'] . '" class="image" title="' . $item['id'] . '" href="' . media_managerURL(array('image' => hsc($item['id']), 'ns' => getNS($item['id']), 'tab_details' => 'view')) . '">';
        echo media_printicon($item['id'], '32x32');
        echo '</a>';
    }
    echo '</dt>' . NL;
    if (!$display_namespace) {
        $name = hsc($file);
    } else {
        $name = hsc($item['id']);
    }
    echo '<dd class="name"><a href="' . media_managerURL(array('image' => hsc($item['id']), 'ns' => getNS($item['id']), 'tab_details' => 'view')) . '" id="h_:' . $item['id'] . '">' . $name . '</a></dd>' . NL;
    if ($item['isimg']) {
        $size = '';
        $size .= (int) $item['meta']->getField('File.Width');
        $size .= '&#215;';
        $size .= (int) $item['meta']->getField('File.Height');
        echo '<dd class="size">' . $size . '</dd>' . NL;
    } else {
        echo '<dd class="size">&#160;</dd>' . NL;
    }
    $date = dformat($item['mtime']);
    echo '<dd class="date">' . $date . '</dd>' . NL;
    $filesize = filesize_h($item['size']);
    echo '<dd class="filesize">' . $filesize . '</dd>' . NL;
    echo '</dl></li>' . NL;
}
Exemple #18
0
/**
 * Refresh a page lock and save draft
 *
 * Andreas Gohr <*****@*****.**>
 */
function ajax_lock()
{
    global $conf;
    global $lang;
    $id = cleanID($_POST['id']);
    if (empty($id)) {
        return;
    }
    if (!checklock($id)) {
        lock($id);
        echo 1;
    }
    if ($conf['usedraft'] && $_POST['wikitext']) {
        $client = $_SERVER['REMOTE_USER'];
        if (!$client) {
            $client = clientIP(true);
        }
        $draft = array('id' => $id, 'prefix' => substr($_POST['prefix'], 0, -1), 'text' => $_POST['wikitext'], 'suffix' => $_POST['suffix'], 'date' => (int) $_POST['date'], 'client' => $client);
        $cname = getCacheName($draft['client'] . $id, '.draft');
        if (io_saveFile($cname, serialize($draft))) {
            echo $lang['draftdate'] . ' ' . dformat();
        }
    }
}
            include $config_file;
        }
    }
    foreach ($fields as $key => $tag) {
        $t = array();
        if (!empty($tag[0])) {
            $t = array($tag[0]);
        }
        if (is_array($tag[3])) {
            $t = array_merge($t, $tag[3]);
        }
        $value = tpl_img_getTag($t);
        if ($value) {
            echo '<dt>' . $lang[$tag[1]] . ':</dt><dd>';
            if ($tag[2] == 'date') {
                echo dformat($value);
            } else {
                echo hsc($value);
            }
            echo '</dd>';
        }
    }
    ?>
                    </dl>
                    <?php 
    //Comment in for Debug// dbg(tpl_img_getTag('Simple.Raw'));
    ?>
                </div>
                <div class="clearer"></div>
            </div><!-- /.content -->
Exemple #20
0
 function tpl_created($fmt = '')
 {
     echo hsc(dformat($this->data['created'], $fmt));
 }
 /**
  * Set the text and HTML body and apply replacements
  *
  * This function applies a whole bunch of default replacements in addition
  * to the ones specidifed as parameters
  *
  * If you pass the HTML part or HTML replacements yourself you have to make
  * sure you encode all HTML special chars correctly
  *
  * @param string $text     plain text body
  * @param array  $textrep  replacements to apply on the text part
  * @param array  $htmlrep  replacements to apply on the HTML part, leave null to use $textrep
  * @param string $html     the HTML body, leave null to create it from $text
  * @param bool   $wrap     wrap the HTML in the default header/Footer
  */
 public function setBody($text, $textrep = null, $htmlrep = null, $html = null, $wrap = true)
 {
     global $INFO;
     global $conf;
     /* @var Input $INPUT */
     global $INPUT;
     $htmlrep = (array) $htmlrep;
     $textrep = (array) $textrep;
     // create HTML from text if not given
     if (is_null($html)) {
         $html = $text;
         $html = hsc($html);
         $html = preg_replace('/^-----*$/m', '<hr >', $html);
         $html = nl2br($html);
     }
     if ($wrap) {
         $wrap = rawLocale('mailwrap', 'html');
         $html = preg_replace('/\\n-- <br \\/>.*$/s', '', $html);
         //strip signature
         $html = str_replace('@HTMLBODY@', $html, $wrap);
     }
     // copy over all replacements missing for HTML (autolink URLs)
     foreach ($textrep as $key => $value) {
         if (isset($htmlrep[$key])) {
             continue;
         }
         if (media_isexternal($value)) {
             $htmlrep[$key] = '<a href="' . hsc($value) . '">' . hsc($value) . '</a>';
         } else {
             $htmlrep[$key] = hsc($value);
         }
     }
     // embed media from templates
     $html = preg_replace_callback('/@MEDIA\\(([^\\)]+)\\)@/', array($this, 'autoembed_cb'), $html);
     // prepare default replacements
     $ip = clientIP();
     $cip = gethostsbyaddrs($ip);
     $trep = array('DATE' => dformat(), 'BROWSER' => $INPUT->server->str('HTTP_USER_AGENT'), 'IPADDRESS' => $ip, 'HOSTNAME' => $cip, 'TITLE' => $conf['title'], 'DOKUWIKIURL' => DOKU_URL, 'USER' => $INPUT->server->str('REMOTE_USER'), 'NAME' => $INFO['userinfo']['name'], 'MAIL' => $INFO['userinfo']['mail']);
     $trep = array_merge($trep, (array) $textrep);
     $hrep = array('DATE' => '<i>' . hsc(dformat()) . '</i>', 'BROWSER' => hsc($INPUT->server->str('HTTP_USER_AGENT')), 'IPADDRESS' => '<code>' . hsc($ip) . '</code>', 'HOSTNAME' => '<code>' . hsc($cip) . '</code>', 'TITLE' => hsc($conf['title']), 'DOKUWIKIURL' => '<a href="' . DOKU_URL . '">' . DOKU_URL . '</a>', 'USER' => hsc($INPUT->server->str('REMOTE_USER')), 'NAME' => hsc($INFO['userinfo']['name']), 'MAIL' => '<a href="mailto:"' . hsc($INFO['userinfo']['mail']) . '">' . hsc($INFO['userinfo']['mail']) . '</a>');
     $hrep = array_merge($hrep, (array) $htmlrep);
     // Apply replacements
     foreach ($trep as $key => $substitution) {
         $text = str_replace('@' . strtoupper($key) . '@', $substitution, $text);
     }
     foreach ($hrep as $key => $substitution) {
         $html = str_replace('@' . strtoupper($key) . '@', $substitution, $html);
     }
     $this->setHTML($html);
     $this->setText($text);
 }
 /**
  * Adapted version of pageTemplate() function
  */
 function _pageTemplate($data)
 {
     global $conf, $INFO;
     $id = $data['id'];
     $user = $_SERVER['REMOTE_USER'];
     $tpl = io_readFile(DOKU_PLUGIN . 'discussion/_template.txt');
     // standard replacements
     $replace = array('@NS@' => $data['ns'], '@PAGE@' => strtr(noNS($id), '_', ' '), '@USER@' => $user, '@NAME@' => $INFO['userinfo']['name'], '@MAIL@' => $INFO['userinfo']['mail'], '@DATE@' => dformat($conf['dformat']));
     // additional replacements
     $replace['@BACK@'] = $data['back'];
     $replace['@TITLE@'] = $data['title'];
     // avatar if useavatar and avatar plugin available
     if ($this->getConf('useavatar') && @file_exists(DOKU_PLUGIN . 'avatar/syntax.php') && !plugin_isdisabled('avatar')) {
         $replace['@AVATAR@'] = '{{avatar>' . $user . ' }} ';
     } else {
         $replace['@AVATAR@'] = '';
     }
     // tag if tag plugin is available
     if (@file_exists(DOKU_PLUGIN . 'tag/syntax/tag.php') && !plugin_isdisabled('tag')) {
         $replace['@TAG@'] = "\n\n{{tag>}}";
     } else {
         $replace['@TAG@'] = '';
     }
     // do the replace
     $tpl = str_replace(array_keys($replace), array_values($replace), $tpl);
     return $tpl;
 }
Exemple #23
0
    function _showlist(&$renderer, $result, $showbin = false, $showtime = false)
    {
        $renderer->doc .= '
<script type="text/javascript"><!--//--><![CDATA[//><!-- 
function actionList(action,page) {
  var msg = "";
  var flag = true;
  var flagconfirm = true;
  if (action == "del") {
    msg = "' . $this->getLang('bookcreator_confirmdel') . '";
  } else {
    if (book_countPages("bookcreator") == 0) {
      flag = false;
    }  
    msg = "' . $this->getLang('bookcreator_confirmload') . '";
  }
  
  if (flag) flagconfirm = confirm(msg);
  if(flagconfirm) {
    document.bookcreator__selections__list.task.value=action;
    document.bookcreator__selections__list.page.value=page;
    document.bookcreator__selections__list.submit();
    return true;
  }  
}
//--><!]]></script>';
        $renderer->listu_open();
        foreach ($result as $item) {
            $itemtitle = p_get_first_heading($item['id']);
            $nons = noNS($item['id']);
            $renderer->listitem_open(1);
            if ($showbin && auth_quickaclcheck($item['id']) >= AUTH_DELETE) {
                $renderer->doc .= "<a href=\"javascript:actionList('del','" . $nons . "');\" ><img src='" . DOKU_URL . "lib/plugins/bookcreator/images/remove.png' title='" . $this->getLang('bookcreator_delselection') . "' border='0' style='vertical-align:middle;' /></a> ";
            }
            $renderer->doc .= "<a href='" . wl($this->getConf('save_namespace') . ":" . $nons) . "'><img src='" . DOKU_URL . "lib/plugins/bookcreator/images/include.png' title='" . $this->getLang('bookcreator_showpage') . "' border='0' style='vertical-align:middle;' /></a> ";
            $renderer->doc .= "<a href=\"javascript:actionList('read','" . $nons . "');\" title='" . $this->getLang('bookcreator_loadselection') . "'>" . $itemtitle . "</a>";
            if ($showtime) {
                $renderer->cdata(' (' . dformat($item['mtime']) . ')');
            }
            $renderer->listitem_close();
        }
        $renderer->listu_close();
    }
Exemple #24
0
/**
 * 
 * Show diff
 * between current page version and provided $text
 * or between the revisions provided via GET or POST
 *
 * @author Andreas Gohr <*****@*****.**>
 * @param  string $text  when non-empty: compare with this text with most current version
 * @param  bool   $intro display the intro text
 * @param  string $type  type of the diff (inline or sidebyside)
 */
function revisionsfull_html_diff($text = '', $intro = true, $type = null)
{
    global $ID;
    global $REV;
    global $lang;
    global $INPUT;
    global $INFO;
    $pagelog = new PageChangeLog($ID);
    /*
     * Determine diff type
     */
    if (!$type) {
        $type = $INPUT->str('difftype');
        if (empty($type)) {
            $type = get_doku_pref('difftype', $type);
            if (empty($type) && $INFO['ismobile']) {
                $type = 'inline';
            }
        }
    }
    if (!in_array($type, array('inline', 'sidebyside'))) {
        $type = 'full';
    }
    /*
     * Determine requested revision(s)
     */
    // we're trying to be clever here, revisions to compare can be either
    // given as rev and rev2 parameters, with rev2 being optional. Or in an
    // array in rev2.
    $rev1 = $REV;
    $rev2 = $INPUT->ref('rev2');
    if (is_array($rev2)) {
        $rev1 = (int) $rev2[0];
        $rev2 = (int) $rev2[1];
        if (!$rev1) {
            $rev1 = $rev2;
            unset($rev2);
        }
    } else {
        $rev2 = $INPUT->int('rev2');
    }
    /*
     * Determine left and right revision, its texts and the header
     */
    $r_minor = '';
    $l_minor = '';
    if ($text) {
        // compare text to the most current revision
        $l_rev = '';
        $l_text = rawWiki($ID, '');
        $l_head = '<a class="wikilink1" href="' . wl($ID) . '">' . $ID . ' ' . dformat((int) @filemtime(wikiFN($ID))) . '</a> ' . $lang['current'];
        $r_rev = '';
        $r_text = cleanText($text);
        $r_head = $lang['yours'];
    } else {
        if ($rev1 && isset($rev2) && $rev2) {
            // two specific revisions wanted
            // make sure order is correct (older on the left)
            if ($rev1 < $rev2) {
                $l_rev = $rev1;
                $r_rev = $rev2;
            } else {
                $l_rev = $rev2;
                $r_rev = $rev1;
            }
        } elseif ($rev1) {
            // single revision given, compare to current
            $r_rev = '';
            $l_rev = $rev1;
        } else {
            // no revision was given, compare previous to current
            $r_rev = '';
            $revs = $pagelog->getRevisions(0, 1);
            $l_rev = $revs[0];
            $REV = $l_rev;
            // store revision back in $REV
        }
        // when both revisions are empty then the page was created just now
        if (!$l_rev && !$r_rev) {
            $l_text = '';
        } else {
            $l_text = rawWiki($ID, $l_rev);
        }
        $r_text = rawWiki($ID, $r_rev);
        list($l_head, $r_head, $l_minor, $r_minor) = html_diff_head($l_rev, $r_rev, null, false, $type == 'inline');
    }
    /*
     * Build navigation
     */
    $l_nav = '';
    $r_nav = '';
    if (!$text) {
        list($l_nav, $r_nav) = html_diff_navigation($pagelog, $type, $l_rev, $r_rev);
    }
    /*
     * Create diff object and the formatter
     */
    $diff = new Diff(explode("\n", $l_text), explode("\n", $r_text));
    if ($type == 'inline') {
        $diffformatter = new InlineDiffFormatter();
    } elseif ($type == 'sidebyside') {
        $diffformatter = new TableDiffFormatter();
    } else {
        $diffformatter = new FullTableDiffFormatter();
    }
    /*
     * Display intro
     */
    if ($intro) {
        print p_locale_xhtml('diff');
    }
    /*
     * Display type and exact reference
     */
    if (!$text) {
        ptln('<div class="diffoptions group">');
        $form = new Doku_Form(array('action' => wl()));
        $form->addHidden('id', $ID);
        $form->addHidden('rev2[0]', $l_rev);
        $form->addHidden('rev2[1]', $r_rev);
        $form->addHidden('do', 'diff');
        $form->addElement(form_makeListboxField('difftype', array('full' => 'Full Side by Side', 'sidebyside' => $lang['diff_side'], 'inline' => $lang['diff_inline']), $type, $lang['diff_type'], '', '', array('class' => 'quickselect')));
        $form->addElement(form_makeButton('submit', 'diff', 'Go'));
        $form->printForm();
        ptln('<p>');
        // link to exactly this view FS#2835
        echo html_diff_navigationlink($type, 'difflink', $l_rev, $r_rev ? $r_rev : $INFO['currentrev']);
        ptln('</p>');
        ptln('</div>');
        // .diffoptions
    }
    /*
     * Display diff view table
     */
    ?>
    <div class="table">
    <table class="diff diff_<?php 
    echo $type;
    ?>
">

        <?php 
    //navigation and header
    if ($type == 'inline') {
        if (!$text) {
            ?>
                <tr>
                    <td class="diff-lineheader">-</td>
                    <td class="diffnav"><?php 
            echo $l_nav;
            ?>
</td>
                </tr>
                <tr>
                    <th class="diff-lineheader">-</th>
                    <th <?php 
            echo $l_minor;
            ?>
>
                        <?php 
            echo $l_head;
            ?>
                    </th>
                </tr>
            <?php 
        }
        ?>
            <tr>
                <td class="diff-lineheader">+</td>
                <td class="diffnav"><?php 
        echo $r_nav;
        ?>
</td>
            </tr>
            <tr>
                <th class="diff-lineheader">+</th>
                <th <?php 
        echo $r_minor;
        ?>
>
                    <?php 
        echo $r_head;
        ?>
                </th>
            </tr>
        <?php 
    } else {
        if (!$text) {
            ?>
                <tr>
                    <td colspan="2" class="diffnav"><?php 
            echo $l_nav;
            ?>
</td>
                    <td colspan="2" class="diffnav"><?php 
            echo $r_nav;
            ?>
</td>
                </tr>
            <?php 
        }
        ?>
            <tr>
                <th colspan="2" <?php 
        echo $l_minor;
        ?>
>
                    <?php 
        echo $l_head;
        ?>
                </th>
                <th colspan="2" <?php 
        echo $r_minor;
        ?>
>
                    <?php 
        echo $r_head;
        ?>
                </th>
            </tr>
        <?php 
    }
    //diff view
    echo html_insert_softbreaks($diffformatter->format($diff));
    ?>

    </table>
    </div>
<?php 
}
Exemple #25
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;
}
Exemple #26
0
/**
 * Print some info about the current page
 *
 * @author Andreas Gohr <*****@*****.**>
 */
function tpl_pageinfo($ret = false)
{
    global $conf;
    global $lang;
    global $INFO;
    global $ID;
    // return if we are not allowed to view the page
    if (!auth_quickaclcheck($ID)) {
        return false;
    }
    // prepare date and path
    $fn = $INFO['filepath'];
    if (!$conf['fullpath']) {
        if ($INFO['rev']) {
            $fn = str_replace(fullpath($conf['olddir']) . '/', '', $fn);
        } else {
            $fn = str_replace(fullpath($conf['datadir']) . '/', '', $fn);
        }
    }
    $fn = utf8_decodeFN($fn);
    $date = dformat($INFO['lastmod']);
    // print it
    if ($INFO['exists']) {
        $out = '';
        $out .= $fn;
        $out .= ' &middot; ';
        $out .= $lang['lastmod'];
        $out .= ': ';
        $out .= $date;
        if ($INFO['editor']) {
            $out .= ' ' . $lang['by'] . ' ';
            $out .= editorinfo($INFO['editor']);
        } else {
            $out .= ' (' . $lang['external_edit'] . ')';
        }
        if ($INFO['locked']) {
            $out .= ' &middot; ';
            $out .= $lang['lockedby'];
            $out .= ': ';
            $out .= editorinfo($INFO['locked']);
        }
        if ($ret) {
            return $out;
        } else {
            echo $out;
            return true;
        }
    }
    return false;
}
Exemple #27
0
/**
 * Preprocess edit form data
 *
 * @author   Andreas Gohr <*****@*****.**>
 *
 * @triggers HTML_EDITFORM_OUTPUT
 */
function html_edit()
{
    global $ID;
    global $REV;
    global $DATE;
    global $PRE;
    global $SUF;
    global $INFO;
    global $SUM;
    global $lang;
    global $conf;
    global $TEXT;
    global $RANGE;
    if (isset($_REQUEST['changecheck'])) {
        $check = $_REQUEST['changecheck'];
    } elseif (!$INFO['exists']) {
        // $TEXT has been loaded from page template
        $check = md5('');
    } else {
        $check = md5($TEXT);
    }
    $mod = md5($TEXT) !== $check;
    $wr = $INFO['writable'] && !$INFO['locked'];
    $include = 'edit';
    if ($wr) {
        if ($REV) {
            $include = 'editrev';
        }
    } else {
        // check pseudo action 'source'
        if (!actionOK('source')) {
            msg('Command disabled: source', -1);
            return;
        }
        $include = 'read';
    }
    global $license;
    $form = new Doku_Form(array('id' => 'dw__editform'));
    $form->addHidden('id', $ID);
    $form->addHidden('rev', $REV);
    $form->addHidden('date', $DATE);
    $form->addHidden('prefix', $PRE . '.');
    $form->addHidden('suffix', $SUF);
    $form->addHidden('changecheck', $check);
    $data = array('form' => $form, 'wr' => $wr, 'media_manager' => true, 'target' => isset($_REQUEST['target']) && $wr && $RANGE !== '' ? $_REQUEST['target'] : 'section', 'intro_locale' => $include);
    if ($data['target'] !== 'section') {
        // Only emit event if page is writable, section edit data is valid and
        // edit target is not section.
        trigger_event('HTML_EDIT_FORMSELECTION', $data, 'html_edit_form', true);
    } else {
        html_edit_form($data);
    }
    if (isset($data['intro_locale'])) {
        echo p_locale_xhtml($data['intro_locale']);
    }
    $form->addHidden('target', $data['target']);
    $form->addElement(form_makeOpenTag('div', array('id' => 'wiki__editbar')));
    $form->addElement(form_makeOpenTag('div', array('id' => 'size__ctl')));
    $form->addElement(form_makeCloseTag('div'));
    if ($wr) {
        $form->addElement(form_makeOpenTag('div', array('class' => 'editButtons')));
        $form->addElement(form_makeButton('submit', 'save', $lang['btn_save'], array('id' => 'edbtn__save', 'accesskey' => 's', 'tabindex' => '4')));
        $form->addElement(form_makeButton('submit', 'preview', $lang['btn_preview'], array('id' => 'edbtn__preview', 'accesskey' => 'p', 'tabindex' => '5')));
        $form->addElement(form_makeButton('submit', 'draftdel', $lang['btn_cancel'], array('tabindex' => '6')));
        $form->addElement(form_makeCloseTag('div'));
        $form->addElement(form_makeOpenTag('div', array('class' => 'summary')));
        $form->addElement(form_makeTextField('summary', $SUM, $lang['summary'], 'edit__summary', 'nowrap', array('size' => '50', 'tabindex' => '2')));
        $elem = html_minoredit();
        if ($elem) {
            $form->addElement($elem);
        }
        $form->addElement(form_makeCloseTag('div'));
    }
    $form->addElement(form_makeCloseTag('div'));
    if ($wr && $conf['license']) {
        $form->addElement(form_makeOpenTag('div', array('class' => 'license')));
        $out = $lang['licenseok'];
        $out .= ' <a href="' . $license[$conf['license']]['url'] . '" rel="license" class="urlextern"';
        if ($conf['target']['extern']) {
            $out .= ' target="' . $conf['target']['extern'] . '"';
        }
        $out .= '>' . $license[$conf['license']]['name'] . '</a>';
        $form->addElement($out);
        $form->addElement(form_makeCloseTag('div'));
    }
    if ($wr) {
        // sets changed to true when previewed
        echo '<script type="text/javascript" charset="utf-8"><!--//--><![CDATA[//><!--' . NL;
        echo 'textChanged = ' . ($mod ? 'true' : 'false');
        echo '//--><!]]></script>' . NL;
    }
    ?>
    <div style="width:99%;">

    <div class="toolbar">
    <div id="draft__status"><?php 
    if (!empty($INFO['draft'])) {
        echo $lang['draftdate'] . ' ' . dformat();
    }
    ?>
</div>
    <div id="tool__bar"><?php 
    if ($wr && $data['media_manager']) {
        ?>
<a href="<?php 
        echo DOKU_BASE;
        ?>
lib/exe/mediamanager.php?ns=<?php 
        echo $INFO['namespace'];
        ?>
"
        target="_blank"><?php 
        echo $lang['mediaselect'];
        ?>
</a><?php 
    }
    ?>
</div>

    </div>
    <?php 
    html_form('edit', $form);
    print '</div>' . NL;
}
Exemple #28
0
 /**
  * List recent edits matching the given filter
  */
 function _list($filter)
 {
     global $conf;
     global $lang;
     echo '<hr /><br />';
     echo '<form action="" method="post"><div class="no">';
     echo '<input type="hidden" name="filter" value="' . hsc($filter) . '" />';
     formSecurityToken();
     $recents = getRecents(0, $this->max_lines);
     echo '<ul>';
     $cnt = 0;
     foreach ($recents as $recent) {
         if ($filter) {
             if (strpos(rawWiki($recent['id']), $filter) === false) {
                 continue;
             }
         }
         $cnt++;
         $date = dformat($recent['date']);
         echo $recent['type'] === DOKU_CHANGE_TYPE_MINOR_EDIT ? '<li class="minor">' : '<li>';
         echo '<div class="li">';
         echo '<input type="checkbox" name="revert[]" value="' . hsc($recent['id']) . '" checked="checked" id="revert__' . $cnt . '" />';
         echo ' <label for="revert__' . $cnt . '">' . $date . '</label> ';
         echo '<a href="' . wl($recent['id'], "do=diff") . '">';
         $p = array();
         $p['src'] = DOKU_BASE . 'lib/images/diff.png';
         $p['width'] = 15;
         $p['height'] = 11;
         $p['title'] = $lang['diff'];
         $p['alt'] = $lang['diff'];
         $att = buildAttributes($p);
         echo "<img {$att} />";
         echo '</a> ';
         echo '<a href="' . wl($recent['id'], "do=revisions") . '">';
         $p = array();
         $p['src'] = DOKU_BASE . 'lib/images/history.png';
         $p['width'] = 12;
         $p['height'] = 14;
         $p['title'] = $lang['btn_revs'];
         $p['alt'] = $lang['btn_revs'];
         $att = buildAttributes($p);
         echo "<img {$att} />";
         echo '</a> ';
         echo html_wikilink(':' . $recent['id'], useHeading('navigation') ? null : $recent['id']);
         echo ' – ' . htmlspecialchars($recent['sum']);
         echo ' <span class="user">';
         echo $recent['user'] . ' ' . $recent['ip'];
         echo '</span>';
         echo '</div>';
         echo '</li>';
         @set_time_limit(10);
         flush();
     }
     echo '</ul>';
     echo '<p>';
     echo '<button type="submit">' . $this->getLang('revert') . '</button> ';
     printf($this->getLang('note2'), hsc($filter));
     echo '</p>';
     echo '</div></form>';
 }
 /**
  * Formats and prints one file in the list in the thumbnails view
  *
  * @see media_printfile_thumbs()
  */
 function _mod_media_printfile_thumbs($item, $auth, $jump = false, $display_namespace = false)
 {
     global $lang;
     global $conf;
     // 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);
     // output
     echo '<li><dl title="' . $fakeId_escaped . '">' . NL;
     echo '<dt>';
     if ($item['isimg']) {
         media_printimgdetail($item, true);
     } else {
         echo '<a name="d_:' . $item['id'] . '" class="image" title="' . $fakeId_escaped . '" href="' . media_managerURL(array('image' => $fakeId, 'ns' => $ns, 'tab_details' => 'view')) . '">';
         echo media_printicon($fakeId_escaped);
         echo '</a>';
     }
     echo '</dt>' . NL;
     if (!$display_namespace) {
         $name = hsc($file);
     } else {
         $name = $fakeId_escaped;
     }
     echo '<dd class="name"><a href="' . media_managerURL(array('image' => $fakeId, 'ns' => $ns, 'tab_details' => 'view')) . '" name="h_:' . $item['id'] . '">' . $name . '</a></dd>' . NL;
     if ($item['isimg']) {
         $size = '';
         $size .= (int) $item['meta']->getField('File.Width');
         $size .= '&#215;';
         $size .= (int) $item['meta']->getField('File.Height');
         echo '<dd class="size">' . $size . '</dd>' . NL;
     } else {
         echo '<dd class="size">&#160;</dd>' . NL;
     }
     $date = dformat($item['mtime']);
     echo '<dd class="date">' . $date . '</dd>' . NL;
     $filesize = filesize_h($item['size']);
     echo '<dd class="filesize">' . $filesize . '</dd>' . NL;
     echo '</dl></li>' . NL;
 }
Exemple #30
0
/**
 * Sends a notify mail on page change or registration
 *
 * @param  string  $id       The changed page
 * @param  string  $who      Who to notify (admin|subscribers|register)
 * @param  int     $rev      Old page revision
 * @param  string  $summary  What changed
 * @param  boolean $minor    Is this a minor edit?
 * @param  array   $replace  Additional string substitutions, @KEY@ to be replaced by value
 *
 * @author Andreas Gohr <*****@*****.**>
 */
function notify($id, $who, $rev = '', $summary = '', $minor = false, $replace = array())
{
    global $lang;
    global $conf;
    global $INFO;
    // decide if there is something to do
    if ($who == 'admin') {
        if (empty($conf['notify'])) {
            return;
        }
        //notify enabled?
        $text = rawLocale('mailtext');
        $to = $conf['notify'];
        $bcc = '';
    } elseif ($who == 'subscribers') {
        if (!$conf['subscribers']) {
            return;
        }
        //subscribers enabled?
        if ($conf['useacl'] && $_SERVER['REMOTE_USER'] && $minor) {
            return;
        }
        //skip minors
        $data = array('id' => $id, 'addresslist' => '', 'self' => false);
        trigger_event('COMMON_NOTIFY_ADDRESSLIST', $data, 'subscription_addresslist');
        $bcc = $data['addresslist'];
        if (empty($bcc)) {
            return;
        }
        $to = '';
        $text = rawLocale('subscr_single');
    } elseif ($who == 'register') {
        if (empty($conf['registernotify'])) {
            return;
        }
        $text = rawLocale('registermail');
        $to = $conf['registernotify'];
        $bcc = '';
    } else {
        return;
        //just to be safe
    }
    $ip = clientIP();
    $text = str_replace('@DATE@', dformat(), $text);
    $text = str_replace('@BROWSER@', $_SERVER['HTTP_USER_AGENT'], $text);
    $text = str_replace('@IPADDRESS@', $ip, $text);
    $text = str_replace('@HOSTNAME@', gethostsbyaddrs($ip), $text);
    $text = str_replace('@NEWPAGE@', wl($id, '', true, '&'), $text);
    $text = str_replace('@PAGE@', $id, $text);
    $text = str_replace('@TITLE@', $conf['title'], $text);
    $text = str_replace('@DOKUWIKIURL@', DOKU_URL, $text);
    $text = str_replace('@SUMMARY@', $summary, $text);
    $text = str_replace('@USER@', $_SERVER['REMOTE_USER'], $text);
    $text = str_replace('@NAME@', $INFO['userinfo']['name'], $text);
    $text = str_replace('@MAIL@', $INFO['userinfo']['mail'], $text);
    foreach ($replace as $key => $substitution) {
        $text = str_replace('@' . strtoupper($key) . '@', $substitution, $text);
    }
    if ($who == 'register') {
        $subject = $lang['mail_new_user'] . ' ' . $summary;
    } elseif ($rev) {
        $subject = $lang['mail_changed'] . ' ' . $id;
        $text = str_replace('@OLDPAGE@', wl($id, "rev={$rev}", true, '&'), $text);
        $df = new Diff(explode("\n", rawWiki($id, $rev)), explode("\n", rawWiki($id)));
        $dformat = new UnifiedDiffFormatter();
        $diff = $dformat->format($df);
    } else {
        $subject = $lang['mail_newpage'] . ' ' . $id;
        $text = str_replace('@OLDPAGE@', 'none', $text);
        $diff = rawWiki($id);
    }
    $text = str_replace('@DIFF@', $diff, $text);
    if (utf8_strlen($conf['title']) < 20) {
        $subject = '[' . $conf['title'] . '] ' . $subject;
    } else {
        $subject = '[' . utf8_substr($conf['title'], 0, 20) . '...] ' . $subject;
    }
    mail_send($to, $subject, $text, $conf['mailfrom'], '', $bcc);
}