function extendedVisitorStatistics($max_items) { global $serendipity; // ---------------QUERIES for Viewing statistics ---------------------------------------------- $day = date('Y-m-d'); list($year, $month, $day) = explode('-', $day); $visitors_count_firstday = serendipity_db_query("SELECT day FROM {$serendipity['dbPrefix']}visitors ORDER BY counter_id ASC LIMIT 1", true); $visitors_count_today = serendipity_db_query("SELECT visits FROM {$serendipity['dbPrefix']}visitors_count WHERE year = '" . $year . "' AND month = '" . $month . "' AND day = '" . $day . "'", true); $visitors_count = serendipity_db_query("SELECT SUM(visits) FROM {$serendipity['dbPrefix']}visitors_count", true); $hits_count_today = serendipity_db_query("SELECT hits FROM {$serendipity['dbPrefix']}visitors_count WHERE year = '" . $year . "' AND month = '" . $month . "' AND day = '" . $day . "'", true); $hits_count = serendipity_db_query("SELECT SUM(hits) FROM {$serendipity['dbPrefix']}visitors_count", true); $visitors_latest = serendipity_db_query("SELECT counter_id, day, time, ref, browser, ip FROM {$serendipity['dbPrefix']}visitors ORDER BY counter_id DESC LIMIT " . $max_items . ""); $top_refs = serendipity_db_query("SELECT refs, count FROM {$serendipity['dbPrefix']}refs ORDER BY count DESC LIMIT 20"); ?> <h2><?php echo PLUGIN_EVENT_STATISTICS_OUT_EXT_STATISTICS; ?> </h2> <div class="serendipity_statistics extended_statistics clearfix"> <section> <h3><?php echo PLUGIN_EVENT_STATISTICS_EXT_VISITORS; ?> </h3> <p><?php echo PLUGIN_EVENT_STATISTICS_EXT_VISSINCE . " " . $visitors_count_firstday[0]; ?> </p> <span class="msg_notice"><span class="icon-info-circled"></span> <?php echo PLUGIN_EVENT_STATISTICS_EXT_COUNTDESC; ?> </span> <dl> <dt><?php echo PLUGIN_EVENT_STATISTICS_EXT_VISTODAY; ?> </dt> <dd><?php echo $visitors_count_today[0]; ?> </dd> <dt><?php echo PLUGIN_EVENT_STATISTICS_EXT_VISTOTAL; ?> </dt> <dd><?php echo $visitors_count[0]; ?> </dd> <dt><?php echo PLUGIN_EVENT_STATISTICS_EXT_HITSTODAY; ?> </dt> <dd><?php echo $hits_count_today[0]; ?> </dd> <dt><?php echo PLUGIN_EVENT_STATISTICS_EXT_HITSTOTAL; ?> </dt> <dd><?php echo $hits_count[0]; ?> </dd> <dl> </section> <section> <h3><?php echo PLUGIN_EVENT_STATISTICS_EXT_TOPREFS; ?> </h3> <?php $i = 1; if (is_array($top_refs)) { echo '<ol>'; foreach ($top_refs as $key => $row) { echo '<li><a href="http://' . $row['refs'] . '" target="_blank">' . $row['refs'] . '</a> (' . $row['count'] . ')</li>'; } echo '</ol>'; } else { echo "<span class='msg_notice'><span class='icon-info-circled'></span> " . PLUGIN_EVENT_STATISTICS_EXT_TOPREFS_NONE . "</span>"; } ?> </section> <section class="wide_box"> <h3><?php echo PLUGIN_EVENT_STATISTICS_EXT_MONTHGRAPH; ?> </h3> <?php if ($visitors_count[0] > 0) { ?> <table> <tbody> <tr> <th scope="row"><?php echo MONTHS; ?> </th> <?php $mon = array('1' => 'Jan', '2' => 'Feb', '3' => 'Mar', '4' => 'Apr', '5' => 'May', '6' => 'Jun', '7' => 'Jul', '8' => 'Aug', '9' => 'Sep', '10' => 'Oct', '11' => 'Nov', '12' => 'Dec'); for ($i = 1; $i < 13; $i++) { echo '<td>' . serendipity_strftime('%b', mktime(0, 0, 0, $i, 1, 2000)) . '</td>'; } ?> </tr> <tr> <th scope="row">Visits</th> <?php $num = $this->statistics_getmonthlystats(); for ($i = 1; $i < 13; $i++) { echo '<td>' . $num[$i] . '</td>'; } ?> </tr> <tr> <th scope="row">+/~/-</th> <?php $num = $this->statistics_getmonthlystats(); $rep = $num; rsort($rep); for ($i = 1; $i < 13; $i++) { $maxVisHeigh = 100 / $rep[0] * 2; $monthHeight = round($num[$i] * $maxVisHeigh); echo '<td class="stats_imagecell"><img src="plugins/serendipity_event_statistics/'; if ($num[$i] * $maxVisHeigh / 2 <= 33) { echo 'red.png'; } else { if ($num[$i] * $maxVisHeigh / 2 > 33 && $num[$i] * $maxVisHeigh / 2 < 66) { echo 'yellow.png'; } else { echo 'green.png'; } } echo '" width="8" height="' . $monthHeight . '" style="height:' . $monthHeight . 'px" alt="'; if ($num[$i] * $maxVisHeigh / 2 <= 33) { echo '-'; } else { if ($num[$i] * $maxVisHeigh / 2 > 33 && $num[$i] * $maxVisHeigh / 2 < 66) { echo '~'; } else { echo '+'; } } echo '" /></td>'; } ?> </tr> </tbody> </table> <?php } ?> </section> <section class="wide_box"> <h3><?php echo PLUGIN_EVENT_STATISTICS_EXT_DAYGRAPH; ?> </h3> <?php if ($visitors_count[0] > 0) { ?> <table> <tbody> <tr> <th scope="row"><?php echo DAYS; ?> </th> <?php for ($i = 1; $i < 32; $i++) { echo '<td>' . $i . '</td>'; } ?> </tr> <tr> <th scope="row">Visits</th> <?php $num = $this->statistics_getdailystats(); for ($i = 1; $i < 32; $i++) { echo '<td>' . $num[$i] . '</td>'; } ?> </tr> <tr> <th scope="row">+/~/-</th> <?php $num = $this->statistics_getdailystats(); $rep = $num; rsort($rep); for ($i = 1; $i < 32; $i++) { $maxVisHeigh = 100 / $rep[0] * 2; $dailyHeight = round($num[$i] * $maxVisHeigh); echo '<td class="stats_imagecell"><img src="plugins/serendipity_event_statistics/'; if ($num[$i] * $maxVisHeigh / 2 <= 33) { echo 'red.png'; } else { if ($num[$i] * $maxVisHeigh / 2 > 33 && $num[$i] * $maxVisHeigh / 2 < 66) { echo 'yellow.png'; } else { echo 'green.png'; } } echo '" width="8" height="' . $dailyHeight . '" style="height:' . $dailyHeight . 'px" alt="'; if ($num[$i] * $maxVisHeigh / 2 <= 33) { echo '-'; } else { if ($num[$i] * $maxVisHeigh / 2 > 33 && $num[$i] * $maxVisHeigh / 2 < 66) { echo '~'; } else { echo '+'; } } echo '" /></td>'; } ?> </tr> </table> <?php } ?> </section> <section class="wide_box"> <h3><?php echo PLUGIN_EVENT_STATISTICS_EXT_VISLATEST; ?> </h3> <dl> <?php $i = 1; if (is_array($visitors_latest)) { foreach ($visitors_latest as $key => $row) { echo '<dt class="stats_header">' . $row['day'] . ' (' . $row['time'] . ')'; echo "<span>" . ($row['ip'] ? gethostbyaddr($row['ip']) : '-') . "</span>\n"; echo "</dt>\n"; if ($row['ref'] != 'unknown') { echo "<dd><a href=\"" . $row['ref'] . "\">" . $row['ref'] . "</a></dd>\n"; } if ($row['ref'] == 'unknown') { echo "<dd>" . $row['ref'] . "</dd>\n"; } echo "<dd>" . $row['browser'] . "</dd>\n"; } } ?> </dl> </section> </div> <?php }
function printComments($comments) { if (!is_array($comments) || count($comments) < 1) { return; } foreach ($comments as $i => $comment) { $comment['comment'] = function_exists('serendipity_specialchars') ? serendipity_specialchars(strip_tags($comment['body'])) : htmlspecialchars(strip_tags($comment['body']), ENT_COMPAT, LANG_CHARSET); if (!empty($comment['url']) && substr($comment['url'], 0, 7) != 'http://' && substr($comment['url'], 0, 8) != 'https://') { $comment['url'] = 'http://' . $comment['url']; } serendipity_plugin_api::hook_event('frontend_display', $comment); $name = empty($comment['username']) ? ANONYMOUS : $comment['username']; $body = $comment['comment']; $this->pdf->SetFont('Arial', '', 9); $html = $this->prep_out($body . "\n" . ' ' . $name . ' ' . ON . ' ' . serendipity_mb('ucfirst', $this->prep_out(serendipity_strftime('%b %e %Y, %H:%M', $comment['timestamp'])))) . "\n"; if (serendipity_db_bool($this->get_config('html2pdf'))) { $this->pdf->WriteHTML($html); } else { $this->pdf->Write(3, $html); } $this->pdf->Ln(); $this->pdf->Ln(); } }
/** * Create a HTML SELECT dropdown field which represents all hierarchical comments * * @access public * @param int The entry ID to show comments for * @param array The existing comments for this entry * @param int The ID of the comment that is being referred to (last selection) * @param int The parent ID of the last comment [for recursive usage] * @param int The current nesting/hierarchy level [for recursive usage] * @param string The HTML indention string that gets prepended to a comment [for recursive usage] * @return string The HTML SELECT code */ function serendipity_generateCommentList($id, $comments = NULL, $selected = 0, $parent = 0, $level = 0, $indent = '') { global $serendipity; if (!is_array($comments)) { if (empty($id)) { $comments = array(); } else { $comments = serendipity_fetchComments($id); } } $retval = $parent ? '' : '<select id="serendipity_replyTo" onchange="' . (!empty($serendipity['plugindata']['onchange']) ? $serendipity['plugindata']['onchange'] : '') . '" name="serendipity[replyTo]"><option value="0">[ ' . TOP_LEVEL . ' ]</option>'; $i = 0; foreach ($comments as $comment) { if ($comment['parent_id'] == $parent) { $i++; $retval .= '<option value="' . $comment['id'] . '"' . ($selected == $comment['id'] || isset($serendipity['POST']['replyTo']) && $comment['id'] == $serendipity['POST']['replyTo'] ? ' selected="selected"' : '') . '>' . str_repeat(' ', $level * 2) . '#' . $indent . $i . ': ' . (empty($comment['author']) ? ANONYMOUS : htmlspecialchars($comment['author'])) . ' ' . ON . ' ' . serendipity_mb('ucfirst', serendipity_strftime(DATE_FORMAT_SHORT, $comment['timestamp'])) . "</option>\n"; $retval .= serendipity_generateCommentList($id, $comments, $selected, $comment['id'], $level + 1, $indent . $i . '.'); } } $retval .= $parent ? '' : '</select>'; return $retval; }
function makeDate($created_at, $dateformat) { if (serendipity_db_bool($this->get_config('use_time_ago'))) { return Twitter::create_status_ago_string($created_at); } $old_date = explode(" ", $created_at); $old_time = explode(":", $old_date[3]); switch ($old_date[1]) { case 'Jan': $old_date[1] = 1; break; case 'Feb': $old_date[1] = 2; break; case 'Mar': $old_date[1] = 3; break; case 'Apr': $old_date[1] = 4; break; case 'May': $old_date[1] = 5; break; case 'Jun': $old_date[1] = 6; break; case 'Jul': $old_date[1] = 7; break; case 'Aug': $old_date[1] = 8; break; case 'Sep': $old_date[1] = 9; break; case 'Oct': $old_date[1] = 10; break; case 'Nov': $old_date[1] = 11; break; case 'Dec': $old_date[1] = 12; break; } $timestamp = mktime($old_time[0], $old_time[1], $old_time[2], $old_date[1], $old_date[2], $old_date[5]); if (LANG_CHARSET == 'UTF-8') { return serendipity_strftime($dateformat, $timestamp); } else { return utf8_encode(serendipity_strftime($dateformat, $timestamp)); } }
function serveComments() { global $serendipity; $serendipity['view'] = 'comments'; $uri = $_SERVER['REQUEST_URI']; $_args = serendipity_getUriArguments($uri, true); // Need to also match "." character $timedesc = array(); /* Attempt to locate hidden variables within the URI */ foreach ($_args as $k => $v) { if ($v == PATH_COMMENTS) { continue; } if (preg_match('@^(last|f|t|from|to)[\\s_-]*([\\d-/ ]+)$@', strtolower(urldecode($v)), $m)) { if ($m[1] == 'last') { $usetime = time() - $m[2] * 86400; $serendipity['GET']['commentStartTime'] = $usetime; $timedesc['start'] = serendipity_strftime(DATE_FORMAT_SHORT, $usetime); continue; } $date = strtotime($m[2]); if ($date < 1) { continue; } if ($m[1] == 'f' || $m[1] == 'from') { $serendipity['GET']['commentStartTime'] = $date; $timedesc['start'] = serendipity_strftime(DATE_FORMAT_SHORT, $date); } else { $serendipity['GET']['commentEndTime'] = $date; $timedesc['end'] = serendipity_strftime(DATE_FORMAT_SHORT, $date); } } elseif ($v == 'trackbacks' || $v == 'comments_and_trackbacks' || $v == 'comments') { $serendipity['GET']['commentMode'] = $v; } elseif (!empty($v)) { $serendipity['GET']['viewCommentAuthor'] .= urldecode($v); } } $serendipity['head_title'] = COMMENTS_FROM . ' ' . serendipity_specialchars($serendipity['GET']['viewCommentAuthor']); if (isset($timedesc['start']) && isset($timedesc['end'])) { $serendipity['head_title'] .= ' (' . $timedesc['start'] . ' - ' . $timedesc['end'] . ')'; } elseif (isset($timedesc['start'])) { $serendipity['head_title'] .= ' (> ' . $timedesc['start'] . ')'; } elseif (isset($timedesc['end'])) { $serendipity['head_title'] .= ' (< ' . $timedesc['end'] . ')'; } $serendipity['head_subtitle'] = $serendipity['blogTitle']; $serendipity['GET']['action'] = 'comments'; include S9Y_INCLUDE_PATH . 'include/genpage.inc.php'; }
function generate_content(&$title) { global $serendipity; $title = $this->get_config('title', $this->title); $intro = $this->get_config('intro'); $outro = $this->get_config('outro'); $maxlength = $this->get_config('maxlength'); $max_entries = $this->get_config('max_entries'); $min_age = $this->get_config('min_age'); $max_age = $this->get_config('max_age'); $specialage = $this->get_config('specialage'); $displaydate = $this->get_config('displaydate', 'true'); $dateformat = $this->get_config('dateformat'); $full = serendipity_db_bool($this->get_config('full')); $displayauthor = serendipity_db_bool($this->get_config('displayauthor', false)); if (!is_numeric($min_age) || $min_age < 0 || $specialage == 'year') { $min_age = 365 + date('L', serendipity_serverOffsetHour()); } if (!is_numeric($max_age) || $max_age < 1 || $specialage == 'year') { $max_age = 365 + date('L', serendipity_serverOffsetHour()); } if (!is_numeric($max_entries) || $max_entries < 1) { $max_entries = 5; } if (!is_numeric($maxlength) || $maxlength < 0) { $maxlength = 30; } if (strlen($dateformat) < 1) { $dateformat = '%a, %d.%m.%Y %H:%M'; } $oldLim = $serendipity['fetchLimit']; $nowts = serendipity_serverOffsetHour(); $maxts = mktime(23, 59, 59, date('m', $nowts), date('d', $nowts), date('Y', $nowts)); $mints = mktime(0, 0, 0, date('m', $nowts), date('d', $nowts), date('Y', $nowts)); $e = serendipity_fetchEntries(array($mints - $max_age * 86400, $maxts - $min_age * 86400), $full, $max_entries); $serendipity['fetchLimit'] = $oldLim; echo empty($intro) ? '' : '<div class="serendipity_history_intro">' . $intro . '</div>' . "\n"; if (!is_array($e)) { return false; } if (($e_c = count($e)) == 0) { return false; } for ($x = 0; $x < $e_c; $x++) { $url = serendipity_archiveURL($e[$x]['id'], $e[$x]['title'], 'serendipityHTTPPath', true, array('timestamp' => $e[$x]['timestamp'])); $date = $displaydate == '0' ? '' : serendipity_strftime($dateformat, $e[$x]['timestamp']); $author = $displayauthor ? $e[$x]['author'] . ': ' : ''; echo '<div class="serendipity_history_info">'; if ($displayauthor) { echo '<span class="serendipity_history_author">' . $author . ' </span>'; } if ($displaydate) { echo '<span class="serendipity_history_date">' . $date . ' </span>'; } $t = $maxlength == 0 || strlen($e[$x]['title']) <= $maxlength ? $e[$x]['title'] : trim(serendipity_mb('substr', $e[$x]['title'], 0, $maxlength - 3)) . ' [...]'; echo '<a href="' . $url . '" title="' . str_replace("'", "`", serendipity_specialchars($e[$x]['title'])) . '">"' . serendipity_specialchars($t) . '"</a></div>'; if ($full) { echo '<div class="serendipity_history_body">' . strip_tags($e[$x]['body']) . '</div>'; } } echo empty($outro) ? '' : '<div class="serendipity_history_outro">' . $outro . '</div>'; }
function inspectConfig($is_smarty, $what, $elcount, $config_item, $config_value, $type, $cname, $cdesc, $value, $default, $lang_direction, $hvalue, $radio, $radio2, $select, $per_row, $per_row2) { global $serendipity; if ($is_smarty && $what == 'desc') { echo $cdesc; return true; } if ($is_smarty && $what == 'name') { echo $cname; return true; } switch ($type) { case 'seperator': ?> <tr> <td colspan="2"><hr noshade="noshade" size="1" /></td> </tr> <?php break; case 'select': if (!$is_smarty) { ?> <tr> <td style="border-bottom: 1px solid #000000; vertical-align: top"><strong><?php echo $cname; ?> </strong> <?php if ($cdesc != '') { ?> <br><span style="color: #5E7A94; font-size: 8pt;"> <?php echo $cdesc; ?> </span> <?php } ?> </td> <td style="border-bottom: 1px solid #000000; vertical-align: middle" width="250"> <div> <?php } ?> <select class="direction_<?php echo $lang_direction; ?> " name="serendipity[plugin][<?php echo $config_item; ?> ]"> <?php foreach ($select as $select_value => $select_desc) { $id = function_exists('serendipity_specialchars') ? serendipity_specialchars($config_item . $select_value) : htmlspecialchars($config_item . $select_value, ENT_COMPAT, LANG_CHARSET); ?> <option title="<?php echo function_exists('serendipity_specialchars') ? serendipity_specialchars($select_desc) : htmlspecialchars($select_desc, ENT_COMPAT, LANG_CHARSET); ?> "<?php echo $select_value == $hvalue ? ' selected="selected"' : ''; ?> value="<?php echo $select_value; ?> "><?php echo function_exists('serendipity_specialchars') ? serendipity_specialchars($select_desc) : htmlspecialchars($select_desc, ENT_COMPAT, LANG_CHARSET); ?> </option> <?php } ?> </select> <?php if (!$is_smarty) { ?> </div> </td> </tr> <?php } break; case 'tristate': $per_row = 3; $radio['value'][] = 'default'; $radio['desc'][] = USE_DEFAULT; case 'boolean': $radio['value'][] = 'true'; $radio['desc'][] = YES; $radio['value'][] = 'false'; $radio['desc'][] = NO; case 'radio': if (!count($radio) > 0) { $radio = $radio2; } if (empty($per_row)) { $per_row = $per_row2; if (empty($per_row)) { $per_row = 2; } } if (!$is_smarty) { ?> <tr> <td style="border-bottom: 1px solid #000000; vertical-align: top"><strong><?php echo $cname; ?> </strong> <?php if ($cdesc != '') { ?> <br /><span style="color: #5E7A94; font-size: 8pt;"> <?php echo $cdesc; ?> </span> <?php } ?> </td> <td style="border-bottom: 1px solid #000000; vertical-align: middle;" width="250"> <?php } $counter = 0; foreach ($radio['value'] as $radio_index => $radio_value) { $id = function_exists('serendipity_specialchars') ? serendipity_specialchars($config_item . $radio_value) : htmlspecialchars($config_item . $radio_value, ENT_COMPAT, LANG_CHARSET); $counter++; $checked = ""; if ($radio_value == 'true' && ($hvalue === '1' || $hvalue === 'true')) { $checked = " checked"; } elseif ($radio_value == 'false' && ($hvalue === '' || $hvalue === '0' || $hvalue === 'false')) { $checked = " checked"; } elseif ($radio_value == $hvalue) { $checked = " checked"; } if ($counter == 1) { ?> <div> <?php } ?> <input class="input_radio direction_<?php echo $lang_direction; ?> " type="radio" id="serendipity_plugin_<?php echo $id; ?> " name="serendipity[plugin][<?php echo $config_item; ?> ]" value="<?php echo $radio_value; ?> " <?php echo $checked; ?> title="<?php echo function_exists('serendipity_specialchars') ? serendipity_specialchars($radio['desc'][$radio_index]) : htmlspecialchars($radio['desc'][$radio_index], ENT_COMPAT, LANG_CHARSET); ?> " /> <label for="serendipity_plugin_<?php echo $id; ?> "><?php echo function_exists('serendipity_specialchars') ? serendipity_specialchars($radio['desc'][$radio_index]) : htmlspecialchars($radio['desc'][$radio_index], ENT_COMPAT, LANG_CHARSET); ?> </label> <?php if ($counter == $per_row) { $counter = 0; ?> </div> <?php } } if (!$is_smarty) { ?> </td> </tr> <?php } break; case 'string': if (!$is_smarty) { ?> <tr> <td style="border-bottom: 1px solid #000000"> <strong><?php echo $cname; ?> </strong> <br><span style="color: #5E7A94; font-size: 8pt;"> <?php echo $cdesc; ?> </span> </td> <td style="border-bottom: 1px solid #000000" width="250"> <div> <?php } ?> <input class="input_textbox direction_<?php echo $lang_direction; ?> " type="text" name="serendipity[plugin][<?php echo $config_item; ?> ]" value="<?php echo $hvalue; ?> " size="30" /> <?php if (!$is_smarty) { ?> </div> </td> </tr> <?php } break; case 'html': case 'text': if (!$is_smarty) { echo '<tr>'; } if (!$serendipity['wysiwyg']) { if (!$is_smarty) { ?> <td><strong><?php echo $cname; ?> </strong> <span style="color: #5E7A94; font-size: 8pt;"> <?php echo $cdesc; ?> </span></td> <td align="right"> <?php } if (!$serendipity['wysiwyg']) { ?> <nobr><span id="tools_<?php echo $config_item; ?> " style="display: none"> <?php if ($serendipity['nl2br']['iso2br']) { ?> <input type="button" class="serendipityPrettyButton input_button" name="insX" value="NoBR" accesskey="x" style="font-style: italic" onclick="wrapSelection(document.forms['serendipityEntry']['serendipity[plugin][<?php echo $config_item; ?> ]'],'<nl>','</nl>')" /> <?php } ?> <input type="button" class="serendipityPrettyButton input_button wrap_selection" name="insI" value="I" accesskey="i" data-tarea="nuggets<?php echo $elcount; ?> " data-tag="em" style="font-style: italic" onclick="wrapSelection(document.forms['serendipityEntry']['serendipity[plugin][<?php echo $config_item; ?> ]'],'<em>','</em>')" /> <input type="button" class="serendipityPrettyButton input_button wrap_selection" name="insB" value="B" accesskey="b" data-tarea="nuggets<?php echo $elcount; ?> " data-tag="strong" style="font-weight: bold" onclick="wrapSelection(document.forms['serendipityEntry']['serendipity[plugin][<?php echo $config_item; ?> ]'],'<strong>','</strong>')" /> <input type="button" class="serendipityPrettyButton input_button wrap_selection" name="insU" value="U" accesskey="u" data-tarea="nuggets<?php echo $elcount; ?> " data-tag="u" style="text-decoration: underline;" onclick="wrapSelection(document.forms['serendipityEntry']['serendipity[plugin][<?php echo $config_item; ?> ]'],'<u>','</u>')" /> <input type="button" class="serendipityPrettyButton input_button wrap_selection" name="insQ" value="<?php echo QUOTE; ?> " accesskey="q" data-tarea="nuggets<?php echo $elcount; ?> " data-tag="blockquote" style="font-style: italic" onclick="wrapSelection(document.forms['serendipityEntry']['serendipity[plugin][<?php echo $config_item; ?> ]'],'<blockquote>','</blockquote>')" /> <input type="button" class="serendipityPrettyButton input_button wrap_insimg" name="insJ" value="img" accesskey="j" data-tarea="nuggets<?php echo $elcount; ?> " onclick="wrapInsImage(document.forms['serendipityEntry']['serendipity[plugin][<?php echo $config_item; ?> ]'])" /> <?php if (version_compare(serendipity_getCoreVersion($serendipity['version']), "2.0", ">=")) { ?> <button class="wrap_insmedia" type="button" name="insImage" data-tarea="nuggets<?php echo $elcount; ?> "><?php echo MEDIA; ?> </button> <?php } else { ?> <input type="button" class="serendipityPrettyButton input_button wrap_insmedia" name="insImage" value="<?php echo MEDIA; ?> " style="" onclick="window.open('serendipity_admin_image_selector.php?serendipity[textarea]=<?php echo urlencode('serendipity[plugin][' . $config_item . ']'); ?> ', 'ImageSel', 'width=800,height=600,toolbar=no,scrollbars=1,scrollbars,resize=1,resizable=1');" /> <?php } ?> <input type="button" class="serendipityPrettyButton input_button wrap_insurl" name="insU" value="URL" accesskey="l" data-tarea="nuggets<?php echo $elcount; ?> " style="color: blue; text-decoration: underline;" onclick="wrapSelectionWithLink(document.forms['serendipityEntry']['serendipity[plugin][<?php echo $config_item; ?> ]'])" /> </span></nobr> <?php } ?> <script type="text/javascript" language="JavaScript"> var tb_<?php echo $config_item; ?> = document.getElementById('tools_<?php echo $config_item; ?> '); tb_<?php echo $config_item; ?> .style.display = ''; </script> <?php if (version_compare(serendipity_getCoreVersion($serendipity['version']), "2.0", ">=")) { ?> <script src="<?php echo serendipity_getTemplateFile('admin/js/jquery.magnific-popup.js'); ?> "></script><?php } // add extra data in the entry's array so that emoticonchooser plugin // behaves well with wysiwyg editors, then clean up ;-) (same apply below) $entry['backend_entry_toolbar_body:nugget'] = 'nuggets' . $elcount; $entry['backend_entry_toolbar_body:textarea'] = 'serendipity[plugin][' . $config_item . ']'; serendipity_plugin_api::hook_event('backend_entry_toolbar_body', $entry); unset($entry['backend_entry_toolbar_body:textarea']); unset($entry['backend_entry_toolbar_body:nugget']); } else { if (!$is_smarty) { ?> <td colspan="2"><strong><?php echo $cname; ?> </strong> <span style="color: #5E7A94; font-size: 8pt;"> <?php echo $cdesc; ?> </span></td> <td> <?php } if (version_compare(serendipity_getCoreVersion($serendipity['version']), "2.0", ">=")) { serendipity_emit_htmlarea_code("nuggets{$elcount}", ""); ?> <script src="<?php echo serendipity_getTemplateFile('admin/js/jquery.magnific-popup.js'); ?> "></script><?php } $entry['backend_entry_toolbar_body:nugget'] = 'nuggets' . $elcount; $entry['backend_entry_toolbar_body:textarea'] = 'serendipity[plugin][' . $config_item . ']'; serendipity_plugin_api::hook_event('backend_entry_toolbar_body', $entry); unset($entry['backend_entry_toolbar_body:textarea']); unset($entry['backend_entry_toolbar_body:nugget']); ?> <?php } if (!$is_smarty) { ?> </td> </tr> <tr> <td colspan="2"> <?php } ?> <div> <textarea class="direction_<?php echo $lang_direction; ?> " style="width: 100%" id="nuggets<?php echo $elcount; ?> " name="serendipity[plugin][<?php echo $config_item; ?> ]" rows="20" cols="80"><?php echo $hvalue; ?> </textarea> </div> <?php if (!$is_smarty) { ?> </td> </tr> <?php } if ($type == 'html') { $this->htmlnugget[] = $elcount; if (version_compare(preg_replace('@[^0-9\\.]@', '', $serendipity['version']), '0.9', '<')) { serendipity_emit_htmlarea_code('nuggets' . $elcount, 'nuggets' . $elcount); } else { serendipity_emit_htmlarea_code('nuggets', 'nuggets', true); } } break; case 'content': if (!$is_smarty) { ?> <tr><td colspan="2"><?php echo $default; ?> </td></tr><?php } else { echo $default; } break; case 'hidden': if (!$is_smarty) { ?> <tr><td colspan="2"><?php } ?> <input class="direction_<?php echo $lang_direction; ?> " type="hidden" name="serendipity[plugin][<?php echo $config_item; ?> ]" value="<?php echo $value; ?> " /><?php if (!$is_smarty) { ?> </td></tr><?php } break; case 'timestamp': if (!$is_smarty) { ?> <tr> <td style="border-bottom: 1px solid #000000"> <strong><?php echo $cname; ?> </strong> <br><span style="color: #5E7A94; font-size: 8pt;"> <?php echo $cdesc; ?> </span> </td> <td style="border-bottom: 1px solid #000000" width="250"> <div> <?php } ?> <input class="input_textbox direction_<?php echo $lang_direction; ?> " type="text" name="serendipity[plugin][<?php echo $config_item; ?> ]" value="<?php echo serendipity_strftime(DATE_FORMAT_SHORT, $hvalue); ?> " size="30" /> <?php if (!$is_smarty) { ?> </div> </td> </tr> <?php } break; } }
function event_hook($event, &$bag, &$eventData, $addData = null) { global $serendipity; $hooks =& $bag->get('event_hooks'); if (isset($hooks[$event])) { switch ($event) { case 'backend_sidebar_entries': if ($serendipity['version'][0] < 2) { ?> <li class="serendipitySideBarMenuLink serendipitySideBarMenuEntryLinks"><a href="?serendipity[adminModule]=event_display&serendipity[adminAction]=adminnotes"><?php echo PLUGIN_ADMINNOTES_TITLE; ?> </a></li> <?php } // Serendipity 2.0 now uses the new backend_sidebar_admin hook break; case 'backend_sidebar_admin': if ($serendipity['version'][0] > 1) { ?> <li><a href="?serendipity[adminModule]=event_display&serendipity[adminAction]=adminnotes"><?php echo PLUGIN_ADMINNOTES_TITLE; ?> </a></li> <?php } break; case 'backend_sidebar_entries_event_display_adminnotes': $this->shownotes(); break; case 'js_backend': ?> /* serendipity_event_adminnotes (quicknotes) start */ function fulltext_toggle(id) { if ( document.getElementById(id + '_full').style.display == '' ) { document.getElementById(id + '_full').style.display='none'; document.getElementById(id + '_summary').style.display=''; document.getElementById(id + '_text').innerHTML = '<?php echo TOGGLE_ALL; ?> '; } else { document.getElementById(id + '_full').style.display=''; document.getElementById(id + '_summary').style.display='none'; document.getElementById(id + '_text').innerHTML = '<?php echo HIDE; ?> '; } return false; } /* serendipity_event_adminnotes (quicknotes) end */ <?php break; case 'backend_frontpage_display': if ($serendipity['version'][0] > 1) { break; } ?> <script type="text/javascript"> function fulltext_toggle(id) { if ( document.getElementById(id + '_full').style.display == '' ) { document.getElementById(id + '_full').style.display='none'; document.getElementById(id + '_summary').style.display=''; document.getElementById(id + '_text').innerHTML = '<?php echo TOGGLE_ALL; ?> '; } else { document.getElementById(id + '_full').style.display=''; document.getElementById(id + '_summary').style.display='none'; document.getElementById(id + '_text').innerHTML = '<?php echo HIDE; ?> '; } return false; } </script> <?php $cutoff = $this->get_config('cutoff'); $notes = $this->getMyNotes(); $zoom = serendipity_getTemplateFile('admin/img/zoom.png'); if (is_array($notes)) { foreach ($notes as $id => $note) { echo '<div class="serendipity_note note_' . $this->output($note['notetype']) . ' note_owner_' . $note['authorid'] . ($serendipity['COOKIE']['lastnote'] < $note['noteid'] ? ' note_new' : '') . '">' . "\n"; echo ' <div class="note_subject"><strong>' . $this->output($note['subject']) . '</strong> ' . POSTED_BY . ' ' . (function_exists('serendipity_specialchars') ? serendipity_specialchars($note['realname']) : htmlspecialchars($note['realname'], ENT_COMPAT, LANG_CHARSET)) . ' ' . ON . ' ' . serendipity_strftime(DATE_FORMAT_SHORT, $note['notetime']) . '</div>' . "\n"; if (strlen($note['body']) > $cutoff) { $output = $this->output($note['body']); echo ' <div id="' . $id . '_full" style="display: none" class="note_body">' . $output . '</div>' . "\n"; echo ' <div id="' . $id . '_summary" class="note_body">' . serendipity_mb('substr', $output, 0, $cutoff) . '...</div>' . "\n"; echo ' <div class="note_summarylink"><a href="#' . $id . '_full" onclick="fulltext_toggle(' . $id . '); return false;" title="' . VIEW . '" class="serendipityIconLink"><img src="' . $zoom . '" alt="' . TOGGLE_ALL . '" /><span id="' . $id . '_text">' . TOGGLE_ALL . '</span></a></div>'; } else { echo ' <div class="note_body">' . $this->output($note['body']) . '</div>' . "\n"; } echo "</div>\n"; } serendipity_JSsetCookie('lastnote', $notes[0]['noteid']); } break; case 'backend_dashboard': $cutoff = $this->get_config('cutoff'); $notes = $this->getMyNotes(); if (is_array($notes)) { ?> <section id="dashboard_quicknotes" class="equal_heights quick_list dashboard_widget"> <h3><?php echo PLUGIN_ADMINNOTES_TITLE; ?> </h3> <ol class="plainList"> <?php foreach ($notes as $id => $note) { ?> <li class="serendipity_note note_<?php echo $this->output($note['notetype']); ?> note_owner_<?php echo $note['authorid'] . ($serendipity['COOKIE']['lastnote'] < $note['noteid'] ? ' note_new' : ''); ?> "> <div class="note_subject"> <h3><?php echo $this->output($note['subject']); ?> </h3> <?php echo POSTED_BY . ' ' . (function_exists('serendipity_specialchars') ? serendipity_specialchars($note['realname']) : htmlspecialchars($note['realname'], ENT_COMPAT, LANG_CHARSET)) . ' ' . ON . ' ' . serendipity_strftime(DATE_FORMAT_SHORT, $note['notetime']) . "\n"; ?> </div> <?php if (strlen($note['body']) > $cutoff) { $output = $this->output($note['body']); ?> <div id="<?php echo $id; ?> _full" style="display: none" class="note_body"> <?php echo $output . "\n"; ?> </div> <div id="<?php echo $id; ?> _summary" class="note_body"> <?php echo serendipity_mb('substr', $output, 0, $cutoff) . "…\n"; ?> </div> <div class="note_summarylink"> <button class="button_link toggle_comment_full" type="button" onclick="fulltext_toggle(<?php echo $id; ?> ); return false;" data-href="#qn<?php echo $id; ?> _full" title="<?php echo TOGGLE_ALL; ?> "><span class="icon-right-dir"></span><span class="visuallyhidden"> <?php echo TOGGLE_ALL; ?> </span></button> </div> <?php } else { ?> <div class="note_body"> <?php echo $this->output($note['body']) . "\n"; ?> </div> <?php } ?> </li> <?php } ?> </ol> </section> <?php serendipity_JSsetCookie('lastnote', $notes[0]['noteid']); } break; case 'css_backend': if (!strpos($eventData, '.note_')) { echo "\n/* plugin adminnotes start */\n"; // class exists in CSS, so a user has customized it and we don't need default if ($serendipity['version'][0] < 2) { echo file_get_contents(dirname(__FILE__) . '/notes.css'); } else { ?> .note_subject { margin: 0px 0px 1em; } .note_subject h3 { line height: 1.6; margin: 0; } .note_new { border: 2px solid rgb(0, 255, 0); margin: -0.2em; padding: 0.2em; } <?php } echo "/* plugin adminnotes end */\n\n"; } break; } } return true; }
function showEntries() { global $serendipity; if ($serendipity['GET']['custom_sortyears'] == 'all') { $range = null; } else { $range = array(mktime(0, 0, 0, 1, 1, $serendipity['GET']['custom_sortyears']), mktime(0, 0, 0, 1, 1, $serendipity['GET']['custom_sortyears'] + 1)); } if ($serendipity['GET']['custom_sortauthors'] != 'all') { $serendipity['GET']['viewAuthor'] = (int) $serendipity['GET']['custom_sortauthors']; } switch ($serendipity['GET']['custom_sortfield']) { case 'category': $sql_order = 'c.category_name'; break; case 'timestamp': $sql_order = 'e.timestamp'; break; case 'title': $sql_order = 'e.title'; break; } if ($serendipity['GET']['custom_sortorder'] == 'desc') { $sql_order = $sql_order . ' DESC'; } $entries = serendipity_fetchEntries($range, false, '', false, false, $sql_order); $pool = array(); if (is_array($entries)) { foreach ($entries as $entry) { $entryLink = serendipity_archiveURL($entry['id'], $entry['title'], 'serendipityHTTPPath', true, array('timestamp' => $entry['timestamp'])); $entryHTML = '<a href="' . $entryLink . '" title="' . (function_exists('serendipity_specialchars') ? serendipity_specialchars($entry['title']) : htmlspecialchars($entry['title'], ENT_COMPAT, LANG_CHARSET)) . '">' . $entry['title'] . '</a><br />'; $key = ''; switch ($serendipity['GET']['custom_sortfield']) { case 'category': if (isset($entry['categories'][0])) { $key = $entry['categories'][0]['category_name']; } else { $key = $entry['category_name']; } break; case 'timestamp': $key = serendipity_strftime('%B %Y', $entry['timestamp']); break; case 'title': $key = strtoupper(substr($entry['title'], 0, 1)); break; } $pool[$key][] = $entryHTML; } } foreach ($pool as $key => $content) { echo '<dl>'; echo '<dt>' . $key . '</dt>' . "\n"; foreach ($content as $HTML) { echo '<dd>' . $HTML . '</dd>' . "\n"; } echo '</dl>'; } }
$template_config_groups = NULL; $template_config = NULL; $template_loaded_config = NULL; } } if (is_array($template_config)) { serendipity_plugin_api::hook_event('backend_templates_configuration_top', $template_config); $data["has_config"] = true; if ($serendipity['POST']['adminAction'] == 'configure' && serendipity_checkFormToken()) { $storage = new template_option(); $storage->import($template_config); foreach ($serendipity['POST']['template'] as $option => $value) { $storage->set_config($option, $value); } $data["adminAction"] = "configure"; $data["save_time"] = sprintf(SETTINGS_SAVED_AT, serendipity_strftime('%H:%M:%S')); } $data["form_token"] = serendipity_setFormToken(); include_once S9Y_INCLUDE_PATH . 'include/functions_plugins_admin.inc.php'; $template_vars =& serendipity_loadThemeOptions($template_config); $template_options = new template_option(); $template_options->import($template_config); $template_options->values =& $template_vars; $data["configuration"] = serendipity_plugin_config($template_options, $template_vars, $serendipity['template'], $serendipity['template'], $template_options->keys, true, true, true, true, 'template', $template_config_groups); serendipity_plugin_api::hook_event('backend_templates_configuration_bottom', $template_config); } else { serendipity_plugin_api::hook_event('backend_templates_configuration_none', $template_config); } $i = 0; $stack = array(); serendipity_plugin_api::hook_event('backend_templates_fetchlist', $stack);
} $use_dir = serendipity_uploadSecure($serendipity['GET']['dir']); $checkpath = array(array('relpath' => $use_dir)); if (!serendipity_directoryACL($checkpath, 'write')) { return; } if (!empty($serendipity['POST']['save'])) { $newDir = serendipity_uploadSecure($serendipity['POST']['newDir']); $oldDir = serendipity_uploadSecure($serendipity['POST']['oldDir']); if ($oldDir != $newDir) { serendipity_moveMediaDirectory($oldDir, $newDir); $use_dir = $newDir; } serendipity_ACLGrant(0, 'directory', 'read', $serendipity['POST']['read_authors'], $use_dir); serendipity_ACLGrant(0, 'directory', 'write', $serendipity['POST']['write_authors'], $use_dir); echo '<div>' . sprintf(SETTINGS_SAVED_AT, serendipity_strftime('%H:%M:%S')) . '</div>'; } $groups = serendipity_getAllGroups(); $read_groups = serendipity_ACLGet(0, 'directory', 'read', $use_dir); $write_groups = serendipity_ACLGet(0, 'directory', 'write', $use_dir); if (!empty($serendipity['POST']['update_children'])) { $dir_list = serendipity_traversePath($serendipity['serendipityPath'] . $serendipity['uploadPath'], $use_dir, true, NULL, 1, NULL, 'write', NULL); foreach ($dir_list as $f => $dir) { // Apply parent ACL to children. serendipity_ACLGrant(0, 'directory', 'read', $serendipity['POST']['read_authors'], $dir['relpath']); serendipity_ACLGrant(0, 'directory', 'write', $serendipity['POST']['write_authors'], $dir['relpath']); } } ?> <div class="image_directory_edit"><strong><?php
function showBackend() { global $serendipity; if (!empty($serendipity['POST']['action'])) { $serendipity['GET']['action'] =& $serendipity['POST']['action']; } echo '<strong>' . FAQs . '</strong><hr />'; switch ($serendipity['GET']['action']) { case 'faqs': if ($serendipity['POST']['typeSave'] == "true" && !empty($serendipity['POST']['SAVECONF'])) { $serendipity['POST']['typeSubmit'] = true; $bag = new serendipity_property_bag(); $this->introspect($bag); $name = function_exists('serendipity_specialchars') ? serendipity_specialchars($bag->get('name')) : htmlspecialchars($bag->get('name'), ENT_COMPAT, LANG_CHARSET); $desc = function_exists('serendipity_specialchars') ? serendipity_specialchars($bag->get('description')) : htmlspecialchars($bag->get('description'), ENT_COMPAT, LANG_CHARSET); $config_faq = $bag->get('configuration_faq'); foreach ($config_faq as $config_item) { $cbag = new serendipity_property_bag(); if ($this->introspect_faq_item($config_item, $cbag)) { $this->faq[$config_item] = serendipity_get_bool($serendipity['POST']['plugin'][$config_item]); } } $result = $this->updateFAQ(); if (is_bool($result)) { echo '<div class="serendipityAdminMsgSuccess"><img style="width: 22px; height: 22px; border: 0px; padding-right: 4px; vertical-align: middle" src="' . serendipity_getTemplateFile('admin/img/admin_msg_success.png') . '" alt="" />' . DONE . ': ' . sprintf(SETTINGS_SAVED_AT, serendipity_strftime('%H:%M:%S')) . '</div>'; } else { echo '<div class="serendipityAdminMsgError"><img style="width: 22px; height: 22px; border: 0px; padding-right: 4px; vertical-align: middle" src="' . serendipity_getTemplateFile('admin/img/admin_msg_error.png') . '" alt="" />' . ERROR . ': ' . $result . '</div>'; } } if (!empty($serendipity['POST']['id'])) { $serendipity['GET']['id'] =& $serendipity['POST']['id']; } if (is_numeric($serendipity['GET']['id'])) { $this->fetchFAQ($serendipity['GET']['id']); } if (!is_numeric($serendipity['GET']['cid'])) { $cid =& $this->faq['cid']; } else { $cid =& $serendipity['GET']['cid']; } echo '<p><a href="?serendipity[adminModule]=event_display&serendipity[adminAction]=faq">' . FAQ_CATEGORIES . '</a> <a href="?serendipity[adminModule]=event_display&serendipity[adminAction]=faq&serendipity[action]=show_faqs&serendipity[cid]=' . $cid . '">' . FAQS . '</a></p>'; echo '<form action="serendipity_admin.php" method="post" name="serendipityEntry">'; echo '<input type="hidden" name="serendipity[adminModule]" value="event_display" />'; echo '<input type="hidden" name="serendipity[adminAction]" value="faq" />'; echo '<input type="hidden" name="serendipity[action]" value="faqs" />'; echo '<div>'; echo '<input type="hidden" name="serendipity[typeSave]" value="true" />'; $this->showFAQForm(); echo '</div>'; echo '</form>'; break; case 'categories': echo '<p><a href="?serendipity[adminModule]=event_display&serendipity[adminAction]=faq">' . FAQ_CATEGORIES . '</a></p>'; if (!empty($serendipity['GET']['id'])) { $serendipity['POST']['id'] =& $serendipity['GET']['id']; } if (is_numeric($serendipity['POST']['id'])) { $this->fetchCategory($serendipity['POST']['id']); } if ($serendipity['POST']['categorySave'] == "true" && !empty($serendipity['POST']['SAVECONF'])) { $serendipity['POST']['categorySubmit'] = true; $bag = new serendipity_property_bag(); $this->introspect($bag); $name = function_exists('serendipity_specialchars') ? serendipity_specialchars($bag->get('name')) : htmlspecialchars($bag->get('name'), ENT_COMPAT, LANG_CHARSET); $desc = function_exists('serendipity_specialchars') ? serendipity_specialchars($bag->get('description')) : htmlspecialchars($bag->get('description'), ENT_COMPAT, LANG_CHARSET); $config_faq = $bag->get('configuration_category'); foreach ($config_faq as $config_item) { $cbag = new serendipity_property_bag(); if ($this->introspect_category_item($config_item, $cbag)) { $this->category[$config_item] = serendipity_get_bool($serendipity['POST']['plugin'][$config_item]); } } $result = $this->updateCategory(); if (is_bool($result)) { echo '<div class="serendipityAdminMsgSuccess"><img style="width: 22px; height: 22px; border: 0px; padding-right: 4px; vertical-align: middle" src="' . serendipity_getTemplateFile('admin/img/admin_msg_success.png') . '" alt="" />' . DONE . ': ' . sprintf(SETTINGS_SAVED_AT, serendipity_strftime('%H:%M:%S')) . '</div>'; } else { echo '<div class="serendipityAdminMsgError"><img style="width: 22px; height: 22px; border: 0px; padding-right: 4px; vertical-align: middle" src="' . serendipity_getTemplateFile('admin/img/admin_msg_error.png') . '" alt="" />ERROR: ' . $result . '</div>'; } } echo '<form action="serendipity_admin.php" method="post" name="serendipityEntry">'; echo '<input type="hidden" name="serendipity[adminModule]" value="event_display" />'; echo '<input type="hidden" name="serendipity[adminAction]" value="faq" />'; echo '<input type="hidden" name="serendipity[action]" value="categories" />'; echo '<div>'; echo '<input type="hidden" name="serendipity[categorySave]" value="true" />'; $this->showCategoryForm(); echo '</div>'; echo '</form>'; break; case 'show_faqs': echo '<p><a href="?serendipity[adminModule]=event_display&serendipity[adminAction]=faq">' . FAQ_CATEGORIES . '</a> ' . FAQS . '</p>'; if (!empty($serendipity['POST']['faqDelete']) && is_numeric($serendipity['POST']['id'])) { $result = $this->deleteFAQ($serendipity['POST']['id']); if (is_bool($result)) { echo '<div class="serendipityAdminMsgSuccess"><img style="width: 22px; height: 22px; border: 0px; padding-right: 4px; vertical-align: middle" src="' . serendipity_getTemplateFile('admin/img/admin_msg_success.png') . '" alt="" />' . DONE . ': ' . sprintf(RIP_ENTRY, $serendipity['POST']['id']) . '</div>'; } else { echo '<div class="serendipityAdminMsgError"><img style="width: 22px; height: 22px; border: 0px; padding-right: 4px; vertical-align: middle" src="' . serendipity_getTemplateFile('admin/img/admin_msg_error.png') . '" alt="" />ERROR: ' . $result . '</div>'; } } if ($serendipity['GET']['actiondo'] == 'faqMoveUp') { $this->faqMove($serendipity['GET']['id'], $serendipity['GET']['cid'], D_FAQ_MOVEUP); } elseif ($serendipity['GET']['actiondo'] == 'faqMoveDown') { $this->faqMove($serendipity['GET']['id'], $serendipity['GET']['cid'], D_FAQ_MOVEDOWN); } if (!empty($serendipity['POST']['cid'])) { $serendipity['GET']['cid'] =& $serendipity['POST']['cid']; } $faqs = $this->fetchFaqByCid($serendipity['GET']['cid']); $faqs = $this->prepareMove($faqs); echo '<table cellspacing="0" cellpadding="3" width="100%" border="0">'; if (is_array($faqs)) { foreach ($faqs as $faq) { echo '<tr>'; echo '<td width="16"><a href="?serendipity[adminModule]=event_display&serendipity[adminAction]=faq&serendipity[action]=faqs&serendipity[cid]=' . $serendipity['GET']['cid'] . '&serendipity[id]=' . $faq['id'] . '"><img src="' . serendipity_getTemplateFile('admin/img/edit.png') . '" width="16" height="16" title="' . EDIT . '" /></a></td>'; echo '<td width="16"><a href="?serendipity[adminModule]=event_display&serendipity[adminAction]=faq&serendipity[action]=deleteFAQ&serendipity[cid]=' . $serendipity['GET']['cid'] . '&serendipity[id]=' . $faq['id'] . '"><img src="' . serendipity_getTemplateFile('admin/img/delete.png') . '" width="16" height="16" title="' . DELETE . '" /></a></td>'; echo '<td width="16"> </td>'; echo '<td width="300" style="padding-left:20px"><img src="' . serendipity_getTemplateFile('admin/img/folder.png') . '" width="16" height="16" /> ' . $faq['question'] . '</td>'; echo '<td width="16">' . ($faq['up'] == true ? '<a href="?serendipity[adminModule]=event_display&serendipity[adminAction]=faq&serendipity[action]=show_faqs&serendipity[actiondo]=faqMoveUp&serendipity[cid]=' . $serendipity['GET']['cid'] . '&serendipity[id]=' . $faq['id'] . '"><img src="' . serendipity_getTemplateFile('admin/img/uparrow.png') . '" width="16" height="16" alt="' . UP . '" /></a>' : ' ') . '</td>'; echo '<td width="16">' . ($faq['down'] == true ? '<a href="?serendipity[adminModule]=event_display&serendipity[adminAction]=faq&serendipity[action]=show_faqs&serendipity[actiondo]=faqMoveDown&serendipity[cid]=' . $serendipity['GET']['cid'] . '&serendipity[id]=' . $faq['id'] . '"><img src="' . serendipity_getTemplateFile('admin/img/downarrow.png') . '" width="16" height="16" alt="' . DOWN . '" /></a>' : ' ') . '</td>'; echo '</tr>'; } } echo '<tr>'; echo '<td colspan="6" align="right"><a href="?serendipity[adminModule]=event_display&serendipity[adminAction]=faq&serendipity[action]=faqs&serendipity[cid]=' . $serendipity['GET']['cid'] . '" class="serendipityPrettyButton">' . FAQ_NEWFAQ . '</a></td>'; echo '</tr>'; echo '</table>'; break; case 'deleteCategory': if (is_numeric($serendipity['GET']['id'])) { echo '<form action="serendipity_admin.php" method="post" name="serendipityEntry">'; echo '<input type="hidden" name="serendipity[adminModule]" value="event_display" />'; echo '<input type="hidden" name="serendipity[adminAction]" value="faq" />'; echo '<input type="hidden" name="serendipity[id]" value="' . $serendipity['GET']['id'] . '" />'; echo '<strong>' . FAQ_CATEGORIES . '</strong><br /><br />'; echo FAQ_REALYDELETECATEGORY . ' '; echo '<input class="serendipityPrettyButton input_button" type="submit" name="serendipity[categoryDelete]" value="' . YES . '" /> <input class="serendipityPrettyButton input_button" type="submit" name="" value="' . NO . '" />'; echo '</form>'; } break; case 'deleteFAQ': if (is_numeric($serendipity['GET']['id'])) { echo '<form action="serendipity_admin.php" method="post" name="serendipityEntry">'; echo '<input type="hidden" name="serendipity[adminModule]" value="event_display" />'; echo '<input type="hidden" name="serendipity[adminAction]" value="faq" />'; echo '<input type="hidden" name="serendipity[action]" value="show_faqs" />'; echo '<input type="hidden" name="serendipity[id]" value="' . $serendipity['GET']['id'] . '" />'; echo '<input type="hidden" name="serendipity[cid]" value="' . $serendipity['GET']['cid'] . '" />'; echo '<strong>' . FAQ_CATEGORIES . '</strong><br /><br />'; echo FAQ_REALYDELETECATEGORY . ' '; echo '<input class="serendipityPrettyButton input_button" type="submit" name="serendipity[faqDelete]" value="' . YES . '" /> <input class="serendipityPrettyButton input_button" type="submit" name="" value="' . NO . '" />'; echo '</form>'; } break; default: if (isset($serendipity['GET']['cat_lang'])) { $this_cat_lang =& $serendipity['GET']['cat_lang']; } else { $this_cat_lang =& $serendipity['lang']; } if ($serendipity['GET']['action'] == 'category_moveup') { $this->categoryMove($serendipity['GET']['id'], D_FAQ_MOVEUP); } elseif ($serendipity['GET']['action'] == 'category_movedown') { $this->categoryMove($serendipity['GET']['id'], D_FAQ_MOVEDOWN); } echo '<strong>' . FAQ_CATEGORIES . '</strong> (' . $serendipity['languages'][$this_cat_lang] . ')<br /><br />'; if (!empty($serendipity['POST']['categoryDelete']) && is_numeric($serendipity['POST']['id'])) { $faqs = $this->fetchFaqByCid($serendipity['POST']['id']); if (is_array($faqs)) { foreach ($faqs as $faq) { $this->deleteFAQ($faq['id']); } } $result = $this->deleteCategory($serendipity['POST']['id']); if (is_bool($result)) { echo '<div class="serendipityAdminMsgSuccess"><img style="width: 22px; height: 22px; border: 0px; padding-right: 4px; vertical-align: middle" src="' . serendipity_getTemplateFile('admin/img/admin_msg_success.png') . '" alt="" />' . DONE . ': ' . sprintf(RIP_ENTRY, $serendipity['POST']['id']) . '</div>'; } else { echo '<div class="serendipityAdminMsgError"><img style="width: 22px; height: 22px; border: 0px; padding-right: 4px; vertical-align: middle" src="' . serendipity_getTemplateFile('admin/img/admin_msg_error.png') . '" alt="" />ERROR: ' . $result . '</div>'; } } echo '<table cellspacing="0" cellpadding="3" width="100%" border="0">'; echo '<tr><td colspan="7">'; $lang_links = ''; foreach ($serendipity['languages'] as $lang_key => $lang_value) { if (strlen($lang_links)) { $lang_links .= ' '; } if ($this_cat_lang == $lang_key) { $lang_links .= '<span style="border:1px solid #000000">'; } $lang_links .= '<a href="?serendipity[adminModule]=event_display&serendipity[adminAction]=faq&serendipity[cat_lang]=' . $lang_key . '">' . $lang_key . '</a>'; if ($this_cat_lang == $lang_key) { $lang_links .= '</span>'; } } echo $lang_links; echo '</td></tr>'; $fcats = $this->fetchCategories($this_cat_lang); if (is_array($fcats)) { $fcats = serendipity_walkRecursive($fcats); $fcats = $this->prepareMove($fcats); foreach ($fcats as $category) { echo '<tr>'; echo '<td width="16"><a href="?serendipity[adminModule]=event_display&serendipity[adminAction]=faq&serendipity[action]=categories&serendipity[id]=' . $category['id'] . '&serendipity[cat_lang]=' . $this_cat_lang . '"><img src="' . serendipity_getTemplateFile('admin/img/edit.png') . '" width="16" height="16" title="' . EDIT . '" /></a></td>'; echo '<td width="16"><a href="?serendipity[adminModule]=event_display&serendipity[adminAction]=faq&serendipity[action]=deleteCategory&serendipity[id]=' . $category['id'] . '"><img src="' . serendipity_getTemplateFile('admin/img/delete.png') . '" width="16" height="16" title="' . DELETE . '" /></a></td>'; echo '<td width="16"> </td>'; echo '<td width="300" style="padding-left:' . 20 * $category['depth'] . 'px"><img src="' . serendipity_getTemplateFile('admin/img/folder.png') . '" width="16" height="16" /> <a href="?serendipity[adminModule]=event_display&serendipity[adminAction]=faq&serendipity[action]=show_faqs&serendipity[cid]=' . $category['id'] . '">' . $category['category'] . '</a></td>'; echo '<td>' . $this->countFAQbyCid($category['id']) . ' ' . FAQ_NAME . '</td>'; echo '<td width="16">' . ($category['up'] == true ? '<a href="?serendipity[adminModule]=event_display&serendipity[adminAction]=faq&serendipity[action]=category_moveup&serendipity[id]=' . $category['id'] . '"><img src="' . serendipity_getTemplateFile('admin/img/uparrow.png') . '" width="16" height="16" alt="' . UP . '" /></a>' : ' ') . '</td>'; echo '<td width="16">' . ($category['down'] == true ? '<a href="?serendipity[adminModule]=event_display&serendipity[adminAction]=faq&serendipity[action]=category_movedown&serendipity[id]=' . $category['id'] . '"><img src="' . serendipity_getTemplateFile('admin/img/downarrow.png') . '" width="16" height="16" alt="' . DOWN . '" /></a>' : ' ') . '</td>'; echo '</tr>'; } } echo '<tr>'; echo '<td colspan="7" align="right"><a href="?serendipity[adminModule]=event_display&serendipity[adminAction]=faq&serendipity[action]=categories&serendipity[cat_lang]=' . $this_cat_lang . '" class="serendipityPrettyButton">' . FAQ_NEWCATEGORY . '</a></td>'; echo '</tr>'; echo '</table>'; break; } }
function event_hook($event, &$bag, &$eventData, $addData = null) { global $serendipity; $hooks =& $bag->get('event_hooks'); $comic_cat = $this->get_config('category', ''); $show_t = $this->get_config('show_title', 'true'); $show_raw = $this->get_config('raw', 'true'); $hide_fp = $this->get_config('hide', 'true'); if ($event == 'css') { if (stristr('.serendipity_comics', $addData)) { // class exists in CSS, so a user has customized it and we don't need default return true; } ?> .serendipity_comics { font-size: 15px; font-weight: bold; text-align: center; margin-top: 5px; margin-bottom: 10px; margin-left: auto; margin-right: auto; border: 0px; display: block; } <?php return true; } elseif ($event == 'entries_header' || $event == 'frontend_fetchentries') { // determine location and show on the front page only $geturi = serendipity_getUriArguments($GLOBALS['uri']); if (!isset($geturi[0]) && !isset($serendipity['GET']['id']) && !isset($serendipity['GET']['category']) && $comic_cat) { $comic = serendipity_db_query("SELECT e.id, e.title, e.timestamp, e.body\n\t\t\t\t\tFROM {$serendipity['dbPrefix']}entries e\n\t\t\t\t\tINNER JOIN {$serendipity['dbPrefix']}entrycat\n\t\t\t\t\t\tON e.id = {$serendipity['dbPrefix']}entrycat.entryid\n\t\t\t\t\tWHERE e.isdraft = 'false'\n\t\t\t\t\t\tAND e.timestamp <= " . $this->timeOffset(time()) . "\n\t\t\t\t\t\tAND {$serendipity['dbPrefix']}entrycat.categoryid = {$comic_cat}\n\t\t\t\t\tORDER BY e.timestamp DESC\n\t\t\t\t\tLIMIT 1"); if ($event == 'entries_header' && $serendipity['GET']['page'] == '1') { if ($show_t == 'true') { echo '<h4 class="serendipity_title"><a href="' . serendipity_archiveURL($comic[0]['id'], $comic[0]['title'], 'baseURL', true, array('timestamp' => $comic[0]['timestamp'])) . '">'; echo PLUGIN_COMICS_LATEST . (function_exists('serendipity_specialchars') ? serendipity_specialchars(serendipity_strftime(DATE_FORMAT_ENTRY, $comic['0']['timestamp'])) : htmlspecialchars(serendipity_strftime(DATE_FORMAT_ENTRY, $comic['0']['timestamp']), ENT_COMPAT, LANG_CHARSET)) . '</a></h4>'; } if ($show_raw == 'true') { echo $comic['0']['body']; } else { echo '<div class="serendipity_entry"><div class="serendipity_entry_body">'; $entry = array('html_nugget' => $comic['0']['body']); serendipity_plugin_api::hook_event('frontend_display', $entry); echo $entry['html_nugget']; echo '</div></div>'; } echo $this->jumplinks($comic['0']['id'], $comic_cat); } elseif ($event == 'frontend_fetchentries' && !$serendipity['GET']['page'] && !isset($serendipity['GET']['adminModule'])) { if ($hide_fp == 'true') { $cond = " INNER JOIN {$serendipity['dbPrefix']}entrycat ON e.id = {$serendipity['dbPrefix']}entrycat.entryid "; if (empty($eventData['joins'])) { $eventData['joins'] = $cond; } else { $eventData['joins'] .= $cond; } $cond = "{$serendipity['dbPrefix']}entrycat.categoryid != {$comic_cat}"; } else { $cond = "e.id != {$comic['0']['id']}"; } if (empty($eventData['and'])) { $eventData['and'] = " WHERE {$cond} "; } else { $eventData['and'] .= " AND {$cond} "; } } } return true; } elseif ($event == 'entry_display' && isset($serendipity['GET']['id']) && $comic_cat) { $thiscat = serendipity_fetchEntryCategories($serendipity['GET']['id']); if ($thiscat['0']['0'] == $comic_cat) { $elements = count($eventData); for ($i = 0; $i < $elements; $i++) { unset($eventData[$i]['properties']['ep_cache_extended']); $eventData[$i]['exflag'] = 1; $eventData[$i]['extended'] .= sprintf($this->jumplinks($serendipity['GET']['id'], $comic_cat)); } } return true; } else { return false; } }
ob_end_clean(); } } if (isset($_POST['REMOVE']) && serendipity_checkFormToken()) { if (is_array($_POST['serendipity']['plugin_to_remove'])) { foreach ($_POST['serendipity']['plugin_to_remove'] as $key) { $plugin =& serendipity_plugin_api::load_plugin($key); if ($plugin->serendipity_owner == '0' || $plugin->serendipity_owner == $serendipity['authorid'] || serendipity_checkPermission('adminPluginsMaintainOthers')) { serendipity_plugin_api::remove_plugin_instance($key); } } } } if (isset($_POST['SAVE'])) { $data['save'] = true; $data['timestamp'] = serendipity_strftime('%H:%M:%S'); } ob_start(); serendipity_plugin_api::hook_event('backend_pluginlisting_header', $null); $data['backend_pluginlisting_header'] = ob_get_contents(); ob_end_clean(); ob_start(); serendipity_plugin_api::hook_event('backend_plugins_sidebar_header', $serendipity); $data['backend_plugins_sidebar_header'] = ob_get_contents(); ob_end_clean(); $data['sidebar_plugins'] = show_plugins(false, $sidebars); ob_start(); serendipity_plugin_api::hook_event('backend_plugins_event_header', $serendipity); $data['backend_plugins_event_header'] = ob_get_contents(); ob_end_clean(); $data['event_plugins'] = show_plugins(true);
if ($m[1] == 'last') { $usetime = time() - $m[2] * 86400; $serendipity['GET']['commentStartTime'] = $usetime; $timedesc['start'] = serendipity_strftime(DATE_FORMAT_SHORT, $usetime); continue; } $date = strtotime($m[2]); if ($date < 1) { continue; } if ($m[1] == 'f' || $m[1] == 'from') { $serendipity['GET']['commentStartTime'] = $date; $timedesc['start'] = serendipity_strftime(DATE_FORMAT_SHORT, $date); } else { $serendipity['GET']['commentEndTime'] = $date; $timedesc['end'] = serendipity_strftime(DATE_FORMAT_SHORT, $date); } } elseif ($v == 'trackbacks' || $v == 'comments_and_trackbacks' || $v == 'comments') { $serendipity['GET']['commentMode'] = $v; } elseif (!empty($v)) { $serendipity['GET']['viewCommentAuthor'] .= urldecode($v); } } $serendipity['head_title'] = COMMENTS_FROM . ' ' . htmlspecialchars($serendipity['GET']['viewCommentAuthor']); if (isset($timedesc['start']) && isset($timedesc['end'])) { $serendipity['head_title'] .= ' (' . $timedesc['start'] . ' - ' . $timedesc['end'] . ')'; } elseif (isset($timedesc['start'])) { $serendipity['head_title'] .= ' (> ' . $timedesc['start'] . ')'; } elseif (isset($timedesc['end'])) { $serendipity['head_title'] .= ' (< ' . $timedesc['end'] . ')'; }
function admin_save() { global $serendipity; global $template_vars; serendipity_smarty_init(); if (isset($template_vars['sidebars'])) { $sidebars = explode(',', $template_vars['sidebars']); } elseif (isset($serendipity['sidebars'])) { $sidebars = $serendipity['sidebars']; } else { $sidebars = array('left', 'hide', 'right'); } $plugin_list = array(); $view_list = array(); $category_view_list = array(); $usergroups_view_list = array(); foreach ($sidebars as $sidebar) { $plugins = serendipity_plugin_api::enum_plugins($sidebar); $i = 0; if (is_array($plugins)) { if ($sidebar == 'left') { $pside = 0; } elseif ($sidebar == 'right') { $pside = 1; } else { $pside = $sidebar; } foreach ($plugins as $plugin) { if (isset($_REQUEST['plugin_' . $pside . '_' . $i])) { $plugin_list[$pside][$i] = 0; } else { $plugin_list[$pside][$i] = 1; } $i++; } } } $this->set_config('plugin_list', serialize($plugin_list)); foreach ((array) $_REQUEST['plugin_view'] as $instance => $prop) { if ($prop == 'myself') { $view_list[base64_decode($instance)] = $serendipity['authorid']; } elseif ($prop == 'member') { $view_list[base64_decode($instance)] = 'member'; } elseif ($prop == 'everyone') { //--JAM: 2005-10-18 $view_list[base64_decode($instance)] = 'everyone'; } } $this->set_config('view_list', serialize($view_list)); foreach ((array) $_REQUEST['plugin_category_view'] as $instance => $prop) { $category_view_list[base64_decode($instance)] = implode(',', $prop); } $this->set_config('category_view_list', serialize($category_view_list)); foreach ((array) $_REQUEST['plugin_usergroups_view'] as $instance => $prop) { $usergroups_view_list[base64_decode($instance)] = implode(',', $prop); } $this->set_config('usergroups_view_list', serialize($usergroups_view_list)); echo '<div class="serendipityAdminMsgSuccess"><img style="width: 22px; height: 22px; border: 0px; padding-right: 4px; vertical-align: middle" src="' . serendipity_getTemplateFile('admin/img/admin_msg_success.png') . '" alt="" />' . sprintf(SETTINGS_SAVED_AT, serendipity_strftime('%T')) . "<br /><br />\n</div>"; }
function admin_delete_commit() { $streams = unserialize($this->get_config('streams')); $id = $_REQUEST['motm_id']; array_splice($streams, $id, 1); $this->set_config('streams', serialize($streams)); echo '<div class="serendipityAdminMsgSuccess"><img style="width: 22px; height: 22px; border: 0px; padding-right: 4px; vertical-align: middle" src="' . serendipity_getTemplateFile('admin/img/admin_msg_success.png') . '" alt="" />' . sprintf(SETTINGS_SAVED_AT, serendipity_strftime('%T')) . '<br><br>\\n</div>'; }
function generate_content(&$title) { global $serendipity; $title = $this->title; $max_entries = $this->get_config('max_entries'); $max_chars = $this->get_config('max_chars'); $wordwrap = $this->get_config('wordwrap'); $dateformat = $this->get_config('dateformat'); $box_cols = $this->get_config('box_cols'); $box_rows = $this->get_config('box_rows'); // Create table, if not yet existant if ($this->get_config('version') != '1.0') { $q = "CREATE TABLE {$serendipity['dbPrefix']}shoutbox (\n id {AUTOINCREMENT} {PRIMARY},\n timestamp int(10) {UNSIGNED} NULL,\n ip varchar(15) default NULL,\n body text\n )"; $sql = serendipity_db_schema_import($q); $this->set_config('version', '1.0'); } //Put new shout into the database if necessary if (!empty($_REQUEST['action']) && $_REQUEST['action'] == 'fillshoutbox' && $_REQUEST['serendipity']['shouttext'] != '') { $sql = sprintf("INSERT INTO %sshoutbox (\n timestamp,\n ip,\n body\n ) VALUES (\n %s,\n '%s',\n '%s'\n )", $serendipity['dbPrefix'], time(), serendipity_db_escape_string($_SERVER['REMOTE_ADDR']), serendipity_db_escape_string($_REQUEST['serendipity']['shouttext'])); serendipity_db_query($sql); } if (!empty($serendipity['GET']['action']) && $serendipity['GET']['action'] == 'shoutboxdelete' && $_SESSION['serendipityAuthedUser'] === true) { $sql = sprintf("DELETE from %sshoutbox\n WHERE id = %d", $serendipity['dbPrefix'], (int) $serendipity['GET']['comment_id']); serendipity_db_query($sql); } if (!$max_entries || !is_numeric($max_entries) || $max_entries < 1) { $max_entries = 15; } if (!$max_chars || !is_numeric($max_chars) || $max_chars < 1) { $max_chars = 120; } if (!$wordwrap || !is_numeric($wordwrap) || $wordwrap < 1) { $wordwrap = 30; } if (!$dateformat || strlen($dateformat) < 1) { $dateformat = '%a, %d.%m.%Y %H:%M'; } if (!$box_cols || !is_numeric($box_cols) || $box_cols < 1) { $box_cols = 15; } if (!$box_rows || !is_numeric($box_rows) || $box_rows < 1) { $box_rows = 4; } ?> <form action="<?php echo serendipity_currentURL(true); ?> " method="post"> <input type="hidden" name="action" value="fillshoutbox" /> <textarea name="serendipity[shouttext]" rows="<?php echo $box_rows; ?> " cols="<?php echo $box_cols; ?> " style="width: 90%"></textarea> <input name='submit' type='submit' value='<?php echo PLUGIN_SHOUTBOX_SUBMIT; ?> ' /> </form> <?php $q = 'SELECT s.body AS comment, s.timestamp AS stamp, s.id AS comment_id FROM ' . $serendipity['dbPrefix'] . 'shoutbox AS s ORDER BY s.timestamp DESC LIMIT ' . $max_entries; ?> <div class="serendipity_shoutbox"> <?php $sql = serendipity_db_query($q); if ($sql && is_array($sql)) { foreach ($sql as $key => $row) { $comments = wordwrap(strip_tags($row['comment']), $max_chars, '@@@', 1); $aComment = explode('@@@', $comments); $comment = $aComment[0]; if (count($aComment) > 1) { $comment .= ' [...]'; } $deleteLink = ""; if ($_SESSION['serendipityAuthedUser'] === true) { $deleteLink = '<a href="' . $serendipity['baseURL'] . '?serendipity[action]=shoutboxdelete&serendipity[comment_id]=' . $row['comment_id'] . '">' . PLUGIN_SHOUTBOX_DELETE . '</a>'; } $entry = array('comment' => $comment); serendipity_plugin_api::hook_event('frontend_display', $entry); $entry['comment'] = wordwrap($entry['comment'], $wordwrap, "\n", 1); echo '<div class="serendipity_shoutbox_date">' . htmlspecialchars(serendipity_strftime($dateformat, $row['stamp'])) . '</div>' . "\n" . '<div class="serendipity_shoutbox_comment">' . $entry['comment'] . '</div>' . "\n" . '<div class="serendipity_shoutbox_delete">' . $deleteLink . '</div>' . "\n\n"; } } ?> </div> <?php }
function template_options($template, $catid) { global $serendipity, $template_config; if (!serendipity_checkPermission('adminTemplates')) { return; } $template = str_replace('.', '', urldecode($template)); $catid = (int) $catid; $tpl_path = $serendipity['serendipityPath'] . $serendipity['templatePath'] . $template; if (!is_dir($tpl_path)) { return false; } $serendipity['GET']['adminModule'] == 'templates'; $serendipity['smarty_vars']['template_option'] = $template . '_' . $catid; echo '<h3>' . STYLE_OPTIONS . '</h3>'; if (file_exists($tpl_path . '/config.inc.php')) { serendipity_smarty_init(); include_once $tpl_path . '/config.inc.php'; } if (is_array($template_config)) { serendipity_plugin_api::hook_event('backend_templates_configuration_top', $template_config); if ($serendipity['POST']['adminSubAction'] == 'configure') { foreach ($serendipity['POST']['template'] as $option => $value) { categorytemplate_option::set_config($option, $value, $serendipity['smarty_vars']['template_option']); } echo '<div class="serendipityAdminMsgSuccess"><img style="height: 22px; width: 22px; border: 0px; padding-right: 4px; vertical-align: middle" src="' . serendipity_getTemplateFile('admin/img/admin_msg_success.png') . '" alt="" />' . DONE . ': ' . sprintf(SETTINGS_SAVED_AT, serendipity_strftime('%H:%M:%S')) . '</div>'; } echo '<form method="post" action="serendipity_admin.php">'; echo '<input type="hidden" name="serendipity[adminModule]" value="templates" />'; echo '<input type="hidden" name="serendipity[adminSubAction]" value="configure" />'; echo '<input type="hidden" name="serendipity[adminAction]" value="cattemplate" />'; echo '<input type="hidden" name="serendipity[adminModule]" value="event_display" />'; echo '<input type="hidden" name="serendipity[catid]" value="' . $catid . '" />'; echo '<input type="hidden" name="serendipity[cat_template]" value="' . urlencode($template) . '" />'; include S9Y_INCLUDE_PATH . 'include/functions_plugins_admin.inc.php'; $template_vars =& serendipity_loadThemeOptions($template_config, $serendipity['smarty_vars']['template_option']); $template_options = new categorytemplate_option(); $template_options->import($template_config); $template_options->values =& $template_vars; serendipity_plugin_config($template_options, $template_vars, $serendipity['template'], $serendipity['template'], $template_options->keys, true, true, true, true, 'template'); echo '</form><br />'; serendipity_plugin_api::hook_event('backend_templates_configuration_bottom', $template_config); } else { echo '<p>' . STYLE_OPTIONS_NONE . '</p>'; serendipity_plugin_api::hook_event('backend_templates_configuration_none', $template_config); } }
function generate_content(&$title) { global $serendipity; $title = $this->get_config('title', $this->title); $cachetime = $this->get_config('cachetimeout', 60) * 60; // turn to seconds $cachef = $serendipity['serendipityPath'] . 'templates_c/statistics_cache.html'; if (!file_exists($cachef) || filesize($cachef) == 0 || filemtime($cachef) < time() - $cachetime) { // Create statistics list($year, $month, $day) = explode('-', date('Y-m-d')); $lastmonday = date('Ymd', strtotime('last monday')); $nextsunday = date('Ymd', strtotime('next sunday')); if (date('w', strtotime('today')) == "1") { // now it is monday $lastmonday = date('Ymd', strtotime('today')); } else { if (date('w', strtotime('today')) == "0") { // now it is sunday $nextsunday = date('Ymd', strtotime('today')); } } $content = ''; if (serendipity_db_bool($this->get_config('show_lastentry'))) { $res = serendipity_db_query("SELECT timestamp FROM {$serendipity['dbPrefix']}entries WHERE isdraft = 'false' AND timestamp <= " . time() . " ORDER BY timestamp DESC LIMIT 1", true, 'assoc'); if (is_array($res) && isset($res['timestamp'])) { $content .= '<div class="stat_lastentry">' . sprintf($this->get_config('text_lastentry'), '<span class="stat_string">' . htmlspecialchars(serendipity_strftime(DATE_FORMAT_SHORT, $res['timestamp'])) . '</span>') . "</div>\n"; } } if (serendipity_db_bool($this->get_config('show_entrycount'))) { $res = serendipity_db_query("SELECT count(id) as entrycount FROM {$serendipity['dbPrefix']}entries WHERE isdraft = 'false' AND timestamp <= " . time(), true, 'assoc'); if (is_array($res) && isset($res['entrycount'])) { $content .= '<div class="stat_entrycount">' . sprintf($this->get_config('text_entrycount'), '<span class="stat_number">' . $res['entrycount'] . '</span>') . "</div>\n"; } } if (serendipity_db_bool($this->get_config('show_commentcount'))) { $res = serendipity_db_query("SELECT count(id) AS commentcount FROM {$serendipity['dbPrefix']}comments WHERE type = 'NORMAL' AND status = 'approved'", true, 'assoc'); if (is_array($res) && isset($res['commentcount'])) { $content .= '<div class="stat_commentcount">' . sprintf($this->get_config('text_commentcount'), '<span class="stat_number">' . $res['commentcount'] . '</span>') . "</div>\n"; } } if (serendipity_db_bool($this->get_config('show_monthvisitors'))) { $res = serendipity_db_query("SELECT sum(visits) AS monthvisitors FROM {$serendipity['dbPrefix']}visitors_count WHERE year='" . $year . "' AND month='" . $month . "'", true, 'assoc'); if (is_array($res) && isset($res['monthvisitors'])) { $content .= '<div class="stat_monthvisitors">' . sprintf($this->get_config('text_monthvisitors'), '<span class="stat_number">' . $res['monthvisitors'] . '</span>') . "</div>\n"; } } if (serendipity_db_bool($this->get_config('show_dayvisitors'))) { $res = serendipity_db_query("SELECT sum(visits) AS dayvisitors FROM {$serendipity['dbPrefix']}visitors_count WHERE year='" . $year . "' AND month='" . $month . "' AND day='" . $day . "'", true, 'assoc'); if (is_array($res) && isset($res['dayvisitors'])) { $content .= '<div class="stat_dayhvisitors">' . sprintf($this->get_config('text_dayvisitors'), '<span class="stat_number">' . $res['dayvisitors'] . '</span>') . "</div>\n"; } } if (serendipity_db_bool($this->get_config('show_weekvisitors'))) { $res = serendipity_db_query("SELECT sum(visits) AS weekvisitors FROM {$serendipity['dbPrefix']}visitors_count WHERE CONCAT(year,month,day) >= '" . $lastmonday . "' AND CONCAT(year,month,day) <= '" . $nextsunday . "'", true, 'assoc'); if (is_array($res) && isset($res['weekvisitors'])) { $content .= '<div class="stat_weekhvisitors">' . sprintf($this->get_config('text_weekvisitors'), '<span class="stat_number">' . $res['weekvisitors'] . '</span>') . "</div>\n"; } } // This one is MySQL specific. Don't know how postgreSQL does it. if (serendipity_db_bool($this->get_config('show_currentvisitors'))) { $max = time(); $min = $max - 15 * 60; if ($serendipity['dbType'] == 'sqlite' || $serendipity['dbType'] == 'sqlite3' || $serendipity['dbType'] == 'pdo-sqlite') { $max_ts = date('H:i', $max); $min_ts = date('H:i', $min); $q = "SELECT count(counter_id) AS currentvisitors FROM {$serendipity['dbPrefix']}visitors WHERE day LIKE '" . date('Y-m-d') . "' AND (time BETWEEN '{$min_ts}' AND '{$max_ts}')"; } else { $max_ts = date('Hi', $max); $min_ts = date('Hi', $min); $q = "SELECT count(counter_id) AS currentvisitors FROM {$serendipity['dbPrefix']}visitors WHERE day LIKE '" . date('Y-m-d') . "' AND (REPLACE(time, ':', '') BETWEEN {$min_ts} AND {$max_ts})"; } $res = serendipity_db_query($q, true, 'assoc'); if (is_array($res) && isset($res['currentvisitors'])) { $content .= '<div class="stat_currentvisitors">' . sprintf($this->get_config('text_currentvisitors'), '<span class="stat_number">' . $res['currentvisitors'] . '</span>') . "</div>\n"; } } // Write cache $fp = @fopen($cachef, 'w'); if ($fp) { fwrite($fp, $content); fclose($fp); } } else { // Read from cache $content = @file_get_contents($cachef); } echo $content; }
if ($plugin->serendipity_owner == '0' || $plugin->serendipity_owner == $serendipity['authorid'] || serendipity_checkPermission('adminPluginsMaintainOthers')) { serendipity_plugin_api::remove_plugin_instance($key); } } } } ?> <?php if (isset($_POST['SAVE'])) { ?> <div class="serendipityAdminMsgSuccess"><img style="width: 22px; height: 22px; border: 0px; padding-right: 4px; vertical-align: middle" src="<?php echo serendipity_getTemplateFile('admin/img/admin_msg_success.png'); ?> " alt="" /><?php echo DONE . ': ' . sprintf(SETTINGS_SAVED_AT, serendipity_strftime('%H:%M:%S')); ?> </div> <?php } ?> <div><?php echo BELOW_IS_A_LIST_OF_INSTALLED_PLUGINS; ?> </div> <?php if (!isset($serendipity['eyecandy']) || serendipity_db_bool($serendipity['eyecandy'])) { echo '<script src="' . serendipity_getTemplateFile('dragdrop.js') . '" type="text/javascript"></script>'; echo '<div class="warning js_warning"><em>' . PREFERENCE_USE_JS_WARNING . '</em></div>'; }
/** * A wrapper function call for formatting Timestamps. * * Utilizes serendipity_strftime() and prepares the output timestamp with a few tweaks, and applies automatic uppercasing of the return. * * @see serendipity_strftime() * @param string Output format for the timestamp * @param int Timestamp to use for displaying * @param boolean Indicates, if timezone calculations shall be used. * @param boolean Whether to use strftime or simply date * @return string The formatted timestamp */ function serendipity_formatTime($format, $time, $useOffset = true, $useDate = false) { static $cache; if (!isset($cache)) { $cache = array(); } if (!isset($cache[$format])) { $cache[$format] = $format; if (strtoupper(substr(PHP_OS, 0, 3)) === 'WIN') { $cache[$format] = str_replace('%e', '%d', $cache[$format]); } } return serendipity_mb('ucfirst', serendipity_strftime($cache[$format], (int) $time, $useOffset, $useDate)); }
return; } if (!empty($serendipity['POST']['save'])) { $newDir = serendipity_uploadSecure(serendipity_makeFilename($serendipity['POST']['newDir'])); $oldDir = serendipity_uploadSecure($serendipity['POST']['oldDir']); if ($oldDir != $newDir) { //is this possible? ob_start(); serendipity_moveMediaDirectory($oldDir, $newDir); $data['ob_serendipity_moveMediaDirectory'] = ob_get_contents(); ob_end_clean(); $use_dir = $newDir; } serendipity_ACLGrant(0, 'directory', 'read', $serendipity['POST']['read_authors'], $use_dir); serendipity_ACLGrant(0, 'directory', 'write', $serendipity['POST']['write_authors'], $use_dir); $data['print_SETTINGS_SAVED_AT'] = sprintf(SETTINGS_SAVED_AT, serendipity_strftime('%H:%M:%S')); } $groups = serendipity_getAllGroups(); $read_groups = serendipity_ACLGet(0, 'directory', 'read', $use_dir); $write_groups = serendipity_ACLGet(0, 'directory', 'write', $use_dir); if (!empty($serendipity['POST']['update_children'])) { $dir_list = serendipity_traversePath($serendipity['serendipityPath'] . $serendipity['uploadPath'], $use_dir, true, NULL, 1, NULL, 'write', NULL); foreach ($dir_list as $f => $dir) { // Apply parent ACL to children. serendipity_ACLGrant(0, 'directory', 'read', $serendipity['POST']['read_authors'], $dir['relpath']); serendipity_ACLGrant(0, 'directory', 'write', $serendipity['POST']['write_authors'], $dir['relpath']); } } $data['groups'] = $groups; $data['use_dir'] = $use_dir; $data['formtoken'] = serendipity_setFormToken();
echo '<div class="serendipityAdminMsgNote"><img style="width: 22px; height: 22px; border: 0px; padding-right: 4px; vertical-align: middle" src="' . serendipity_getTemplateFile('admin/img/admin_msg_note.png') . '" alt="" />' . WARNING_TEMPLATE_DEPRECATED . '</div>'; } echo '<h3>' . STYLE_OPTIONS . ' (' . $serendipity['template'] . ')</h3>'; if (file_exists($serendipity['serendipityPath'] . $serendipity['templatePath'] . $serendipity['template'] . '/config.inc.php')) { serendipity_smarty_init(); include_once $serendipity['serendipityPath'] . $serendipity['templatePath'] . $serendipity['template'] . '/config.inc.php'; } if (is_array($template_config)) { serendipity_plugin_api::hook_event('backend_templates_configuration_top', $template_config); if ($serendipity['POST']['adminAction'] == 'configure' && serendipity_checkFormToken()) { $storage = new template_option(); $storage->import($template_config); foreach ($serendipity['POST']['template'] as $option => $value) { $storage->set_config($option, $value); } echo '<div class="serendipityAdminMsgSuccess"><img style="height: 22px; width: 22px; border: 0px; padding-right: 4px; vertical-align: middle" src="' . serendipity_getTemplateFile('admin/img/admin_msg_success.png') . '" alt="" />' . DONE . ': ' . sprintf(SETTINGS_SAVED_AT, serendipity_strftime('%H:%M:%S')) . '</div>'; } echo '<form method="post" action="serendipity_admin.php">'; echo '<input type="hidden" name="serendipity[adminModule]" value="templates" />'; echo '<input type="hidden" name="serendipity[adminAction]" value="configure" />'; echo serendipity_setFormToken(); include S9Y_INCLUDE_PATH . 'include/functions_plugins_admin.inc.php'; $template_vars =& serendipity_loadThemeOptions($template_config); $template_options = new template_option(); $template_options->import($template_config); $template_options->values =& $template_vars; serendipity_plugin_config($template_options, $template_vars, $serendipity['template'], $serendipity['template'], $template_options->keys, true, true, true, true, 'template', $template_config_groups); echo '</form><br />'; serendipity_plugin_api::hook_event('backend_templates_configuration_bottom', $template_config); } else { echo '<p>' . STYLE_OPTIONS_NONE . '</p>';
/** * Convert a IPTC/EXIF/XMP item * * @param string The content * @param string The type of the content * @return string The converted content * */ function serendipity_metaFieldConvert(&$item, $type) { switch ($type) { case 'math': $parts = explode('/', $item); return $parts[0] / $parts[1]; break; case 'or': if ($item == '1') { return 'Landscape'; } else { return 'Portrait'; } case 'date': return strtotime($item); break; case 'date2': $parts = preg_split('&[ :]&', $item); return mktime($parts[3], $parts[4], $parts[5], $parts[1], $parts[2], $parts[0]); break; case 'IPTCdate': preg_match('@(\\d{4})(\\d{2})(\\d{2})@', $item, $parts); return mktime(0, 0, 0, intval($parts[2]), intval($parts[3]), intval($parts[1])); break; case 'IPTCtime': preg_match('@(\\d{2})(\\d{2})(\\d{2})([\\+-])(\\d{2})(\\d{2})@', $item, $parts); $time = serendipity_strftime("%H:%M", mktime(intval($parts[1]), intval($parts[2]), intval($parts[3]), 0, 0, 0)); $timezone = serendipity_strftime("%H:%M", mktime(intval($parts[5]), intval($parts[6]), 0, 0, 0, 0)); return $time . " GMT" . $parts[4] . $timezone; break; case 'rdf': if (preg_match('@<rdf:li[^>]*>(.*)</rdf:li>@i', $item, $ret)) { return $ret[1]; } break; case 'text': default: return trim($item); break; } return ''; }
function showBackend() { global $serendipity; if ($serendipity['POST']['pollSave'] || $serendipity['POST']['pollOptionAdd'] || is_array($serendipity['POST']['pollOptionRemove'])) { $serendipity['POST']['pollSubmit'] = true; if ($serendipity['POST']['poll'] == '__new') { $serendipity['POST']['poll'] = $this->insertPoll(); } else { $this->updatePoll($serendipity['POST']['poll']); $this->updateOptions($serendipity['POST']['poll'], $serendipity['POST']['pollOptions']); } } if ($serendipity['POST']['pollOptionAdd']) { $serendipity['POST']['pollSubmit'] = true; $this->addOption($serendipity['POST']['poll'], $serendipity['POST']['pollNewOption']); } if (is_array($serendipity['POST']['pollOptionRemove'])) { $serendipity['POST']['pollSubmit'] = true; foreach ($serendipity['POST']['pollOptionRemove'] as $optid => $optval) { $this->deleteOption($optid); } } if ($serendipity['POST']['poll'] != '__new') { $this->poll = serendipity_common_pollbox::fetchPoll($serendipity['POST']['poll']); } if ($serendipity['version'][0] == '2') { echo '<h2>' . PLUGIN_POLL_SELECT . '</h2>'; } if (!empty($serendipity['POST']['pollDelete']) && $serendipity['POST']['poll'] != '__new') { serendipity_db_query("DELETE FROM {$serendipity['dbPrefix']}polls WHERE id = " . (int) $serendipity['POST']['poll']); serendipity_db_query("DELETE FROM {$serendipity['dbPrefix']}polls_options WHERE pollid = " . (int) $serendipity['POST']['poll']); if ($serendipity['version'][0] == '1') { ?> <div class="serendipityAdminMsgSuccess"><img style="width: 22px; height: 22px; border: 0px; padding-right: 4px; vertical-align: middle" src="<?php echo serendipity_getTemplateFile('admin/img/admin_msg_success.png'); ?> " alt="" /><?php echo DONE . ': ' . sprintf(RIP_ENTRY, (int) $serendipity['POST']['poll']); ?> </div> <?php } else { ?> <span class="msg_success"><span class="icon-ok-circled"></span> <?php echo DONE . ': ' . sprintf(RIP_ENTRY, (int) $serendipity['POST']['poll']); ?> </span> <?php } } if (!empty($serendipity['POST']['pollActivate']) && $serendipity['POST']['poll'] != '__new') { serendipity_db_query("UPDATE {$serendipity['dbPrefix']}polls SET active = 0"); serendipity_db_query("UPDATE {$serendipity['dbPrefix']}polls SET active = 1 WHERE id = " . (int) $serendipity['POST']['poll']); } echo '<form action="serendipity_admin.php" method="post" id="serendipity_poll_form">'; echo '<div>'; echo ' <input type="hidden" name="serendipity[adminModule]" value="event_display" />'; echo ' <input type="hidden" name="serendipity[adminAction]" value="poll" />'; echo '</div>'; if ($serendipity['version'][0] == '1') { echo '<div>'; } else { echo '<div class="form_select">'; } if ($serendipity['version'][0] == '1') { echo '<strong>' . PLUGIN_POLL_SELECT . '</strong><br /><br />'; } echo '<select name="serendipity[poll]">'; echo ' <option value="__new">' . NEW_ENTRY . '</option>'; echo ' <option value="__new">-----------------</option>'; $polls =& $this->fetchPolls(); if (is_array($polls)) { foreach ($polls as $poll) { echo ' <option value="' . $poll['id'] . '" ' . ($serendipity['POST']['poll'] == $poll['id'] ? 'selected="selected"' : '') . '>'; echo ($poll['active'] == 1 ? '*' : '') . (function_exists('serendipity_specialchars') ? serendipity_specialchars($poll['title']) : htmlspecialchars($poll['title'], ENT_COMPAT, LANG_CHARSET)) . ' (' . serendipity_strftime('%d.%m.%Y', $poll['timestamp']) . ')</option>'; } } if ($serendipity['version'][0] == '1') { echo '</select> <input class="serendipityPrettyButton input_button" type="submit" name="serendipity[pollSubmit]" value="' . GO . '" />'; echo ' <strong>-' . WORD_OR . '-</strong> <input class="serendipityPrettyButton input_button" type="submit" name="serendipity[pollDelete]" value="' . DELETE . '" />'; echo ' <strong>-' . WORD_OR . '-</strong> <input class="serendipityPrettyButton input_button" type="submit" name="serendipity[pollActivate]" value="' . PLUGIN_POLL_ACTIVATE . '" />'; } else { echo '</select>'; echo ' <input type="submit" name="serendipity[pollSubmit]" value="' . EDIT . '">'; echo ' <input class="state_cancel" type="submit" name="serendipity[pollDelete]" value="' . DELETE . '">'; echo ' <input type="submit" name="serendipity[pollActivate]" value="' . PLUGIN_POLL_ACTIVATE . '">'; } echo '</div>'; if ($serendipity['POST']['pollSubmit']) { if ($serendipity['version'][0] == '1') { echo '<div>'; } else { echo '<div class="clearfix">'; } $this->showForm(); echo '</div>'; } echo '</form>'; }
function generate_content(&$title) { global $serendipity; $number = $this->get_config('number'); $dateformat = $this->get_config('dateformat'); $category = $this->get_config('category', 'none'); $show_where = $this->get_config('show_where', 'both'); if ($show_where == 'extended' && (!isset($serendipity['GET']['id']) || !is_numeric($serendipity['GET']['id']))) { return false; } else { if ($show_where == 'overview' && isset($serendipity['GET']['id']) && is_numeric($serendipity['GET']['id'])) { return false; } } if ($category == '_cur') { $category = $serendipity['GET']['category']; if (empty($category) && !empty($serendipity['GET']['id'])) { $entry = serendipity_fetchEntry('id', $serendipity['GET']['id']); $category = $entry['categories'][0]['categoryid']; } } $title = $this->get_config('title', $this->title); $number_from_sw = $this->get_config('number_from'); $randomize = $this->get_config('randomize') == "yes" ? true : false; $sql_condition = array(); $sql_condition['joins'] = ''; $sql_condition['and'] = ''; if ($category != 'none' && !empty($category)) { $sql_categories = array(); if (is_numeric($category)) { $sql_categories[] = $category; } else { $sql_categories = explode('^', $category); } $category_parts = array(); foreach ($sql_categories as $sql_category) { $category_parts[] = "\n" . implode(' AND ', serendipity_fetchCategoryRange($sql_category)); } $sql_condition['and'] .= ' AND (c.category_left BETWEEN ' . implode(' OR c.category_left BETWEEN ', $category_parts) . ')'; } if (!$number || !is_numeric($number) || $number < 1) { $number = 10; } $sql_number = serendipity_db_limit_sql($number); $db = $serendipity['dbType']; switch ($number_from_sw) { case 'skip': $sql_number = serendipity_db_limit_sql(serendipity_db_limit($serendipity['fetchLimit'], $number)); break; } if (!$dateformat || strlen($dateformat) < 1) { $dateformat = '%A, %B %e %Y'; } if ($randomize) { if ($db == 'mysql' || $db == 'mysqli') { $sql_order = "ORDER BY RAND()"; } else { // SQLite and PostgreSQL support this, hooray. $sql_order = "ORDER BY RANDOM()"; } } else { $sql_order = "ORDER BY timestamp DESC "; } $sql_condition['and'] .= "AND timestamp <= " . time(); serendipity_ACL_SQL($sql_condition, $category == 'none'); if (!stristr($sql_condition['joins'], $serendipity['dbPrefix'] . 'category')) { $sql_condition['joins'] = ' LEFT OUTER JOIN ' . $serendipity['dbPrefix'] . 'category AS c ON ec.categoryid = c.categoryid ' . $sql_condition['joins']; } if (!stristr($sql_condition['joins'], $serendipity['dbPrefix'] . 'entrycat')) { $sql_condition['joins'] = ' LEFT OUTER JOIN ' . $serendipity['dbPrefix'] . 'entrycat AS ec ON id = ec.entryid ' . $sql_condition['joins']; } $entries_query = "SELECT DISTINCT id,\n title,\n timestamp,\n epm.value AS multilingual_title\n FROM {$serendipity['dbPrefix']}entries AS e\n {$sql_condition['joins']}\n\n LEFT OUTER JOIN {$serendipity['dbPrefix']}entryproperties AS epm\n ON (epm.entryid = e.id AND epm.property = 'multilingual_title_" . $serendipity['lang'] . "')\n\n WHERE isdraft = 'false' {$sql_condition['and']}\n {$sql_order}\n {$sql_number}"; $entries = serendipity_db_query($entries_query); if (is_string($entries)) { echo $entries . "<br />\n"; echo $entries_query . "<br />\n"; } if (isset($entries) && is_array($entries)) { echo '<dl>' . "\n"; foreach ($entries as $k => $entry) { if (!empty($entry['multilingual_title'])) { $entry['title'] = $entry['multilingual_title']; } $entryLink = serendipity_archiveURL($entry['id'], $entry['title'], 'serendipityHTTPPath', true, array('timestamp' => $entry['timestamp'])); if (empty($entry['title'])) { $entry['title'] = '#' . $entry['id']; } echo '<dt class="serendipity_recententries_entrylink"><a href="' . $entryLink . '" title="' . serendipity_specialchars($entry['title']) . '">' . serendipity_specialchars($entry['title']) . '</a></dt>' . "\n" . '<dd class="serendipity_recententries_entrydate serendipitySideBarDate">' . serendipity_specialchars(serendipity_strftime($dateformat, $entry['timestamp'])) . '</dd>' . "\n"; } echo '</dl>' . "\n\n"; } }
function generate_content(&$title, $returnRaw = false) { global $serendipity; $title = $this->get_config('title', $title); $autoprune = serendipity_db_bool($this->get_config('autoprune', false)); $countdown = serendipity_db_bool($this->get_config('countdown', false)); $showtime = 1 + (int) $this->get_config('showtime', 2); $skipfirst = serendipity_db_bool($this->get_config('skipfirst', true)); $datefm = $this->get_config('datefm'); $datefm2 = $this->get_config('datefm2'); $ts = time(); $timeout = $ts - 60 * 60 * 24 * $showtime; if ($autoprune) { $filter = ""; } else { $filter = "WHERE eventdate2 > " . $timeout; } $items = serendipity_db_query("SELECT * from {$serendipity['dbPrefix']}mycalendar " . $filter . " ORDER BY eventdate LIMIT " . $this->get_config('items', 5)); if (!is_array($items)) { return true; } $olddays = 0; foreach ($items as $item) { $cont = function_exists('serendipity_specialchars') ? serendipity_specialchars($item['eventname']) : htmlspecialchars($item['eventname'], ENT_COMPAT, LANG_CHARSET); if (!empty($item['eventurl'])) { if (!empty($item['eventurltitle'])) { $ltitle = $item['eventurltitle']; } else { $ltitle = $item['eventname']; } $cont = '<a href="' . (function_exists('serendipity_specialchars') ? serendipity_specialchars($item['eventurl']) : htmlspecialchars($item['eventurl'], ENT_COMPAT, LANG_CHARSET)) . '" title="' . (function_exists('serendipity_specialchars') ? serendipity_specialchars($ltitle) : htmlspecialchars($ltitle, ENT_COMPAT, LANG_CHARSET)) . '">' . $cont . '</a>'; } $daystostart = ceil(($item['eventdate'] - $ts) / 86400); if (empty($item['eventdate2'])) { $daystoend = $daystostart; } else { $daystoend = ceil(($item['eventdate2'] - $ts) / 86400); } if ($daystoend > -$showtime) { $_dayout = serendipity_strftime($datefm, $item['eventdate'], false); $dayout = $_dayout; if (!empty($item['eventdate2']) && $item['eventdate'] != $item['eventdate2'] && trim($datefm2) != '') { $dayout .= '<span class="s9y_mc_date2"> - ' . serendipity_strftime($datefm2, $item['eventdate2'], false) . '</span>'; } $cont = '<span class="s9y_mc_date">' . $dayout . '</span>' . ' - <span class="s9y_mc_c">' . $cont . '</span>'; if ($daystostart > 0 and $olddays > 0 || !$skipfirst) { # An entry is in the future only if is in the future and it # is not the first future entry $cont = '<div class="s9y_mc s9y_mc_future">' . $cont; if ($countdown) { $cont .= '<span class="s9y_mc_day"> (' . $daystostart . ' ' . DAYS . ')</span>'; } $cont .= '</div>'; } elseif ($daystoend >= 0 and $olddays <= 0) { # An entry is current, if it is the first future entry $cont = '<div class="s9y_mc s9y_mc_current">' . $cont . '</div>'; } else { # Everything else is old $cont = '<div class="s9y_mc s9y_mc_past">' . $cont . '</div>'; } if ($returnRaw) { $returnRawItems[] = array('date' => date('r', $item['eventdate']), 'content' => $cont, 'title' => $item['eventname'], 'url' => !empty($item['eventurl']) ? $item['eventurl'] : $serendipity['baseURL']); } else { echo "{$cont}\n"; } } elseif ($autoprune) { serendipity_db_query("DELETE FROM {$serendipity['dbPrefix']}mycalendar WHERE eventdate2 < " . $timeout); $autoprune = false; } $olddays = $daystostart; } if ($returnRaw) { return $returnRawItems; } if (serendipity_db_bool($this->get_config('rss'))) { $url = $serendipity['baseURL'] . ($serendipity['rewrite'] == 'none' ? $serendipity['indexFile'] . '?/' : '') . 'plugin/mycalendar.rss'; echo '<a class="serendipity_xml_icon rsslink" href="' . $url . '" title="RSS"><img src="' . serendipity_getTemplateFile('img/xml.gif') . '" alt="XML" style="border: 0px" /></a>'; } return true; }
function generate_content(&$title) { global $serendipity; $title = $this->get_config('title', $this->title); $max_entries = $this->get_config('max_entries'); $max_chars = $this->get_config('max_chars'); $wordwrap = $this->get_config('wordwrap'); $dateformat = $this->get_config('dateformat'); if (!$max_entries || !is_numeric($max_entries) || $max_entries < 1) { $max_entries = 15; } if (!$max_chars || !is_numeric($max_chars) || $max_chars < 1) { $max_chars = 120; } if (!$wordwrap || !is_numeric($wordwrap) || $wordwrap < 1) { $wordwrap = 30; } if (!$dateformat || strlen($dateformat) < 1) { $dateformat = '%a, %d.%m.%Y %H:%M'; } $viewtype = ''; if ($this->get_config('viewmode') == 'comments') { $viewtype .= ' AND co.type = \'NORMAL\''; } elseif ($this->get_config('viewmode') == 'trackbacks') { $viewtype .= ' AND (co.type = \'TRACKBACK\' OR co.type = \'PINGBACK\')'; } $cond = array(); $cond['and'] = ' AND e.isdraft = \'false\' '; if ($this->get_config('authorid') == 'login') { serendipity_ACL_SQL($cond, true); serendipity_plugin_api::hook_event('frontend_fetchentries', $cond, array('source' => 'entries')); } $q = 'SELECT co.body AS comment, co.timestamp AS stamp, co.author AS user, e.title AS subject, e.timestamp AS entrystamp, e.id AS entry_id, co.id AS comment_id, co.type AS comment_type, co.url AS comment_url, co.title AS comment_title, co.email AS comment_email FROM ' . $serendipity['dbPrefix'] . 'comments AS co, ' . $serendipity['dbPrefix'] . 'entries AS e ' . $cond['joins'] . ' WHERE e.id = co.entry_id AND NOT (co.type = \'TRACKBACK\' AND co.author = \'' . serendipity_db_escape_string($serendipity['blogTitle']) . '\' AND co.title != \'\') AND co.status = \'approved\' ' . $viewtype . ' ' . $cond['and'] . ' ORDER BY co.timestamp DESC LIMIT ' . $max_entries; $sql = serendipity_db_query($q); // echo $q; if ($sql && is_array($sql)) { foreach ($sql as $key => $row) { if (function_exists('mb_strimwidth')) { $comment = mb_strimwidth(strip_tags($row['comment']), 0, $max_chars, " [...]", LANG_CHARSET); } else { $comments = wordwrap(strip_tags($row['comment']), $max_chars, '@@@', 1); $aComment = explode('@@@', $comments); $comment = $aComment[0]; if (count($aComment) > 1) { $comment .= ' [...]'; } } $showurls = $this->get_config('showurls', 'trackbacks'); $isTrackBack = $row['comment_type'] == 'TRACKBACK' || $row['comment_type'] == 'PINGBACK'; if ($row['comment_url'] != '' && ($isTrackBack && ($showurls == 'trackbacks' || $showurls == 'all') || !$isTrackBack && ($showurls == 'comments' || $showurls == 'all'))) { /* Fix invalid cases in protocoll part */ $row['comment_url'] = preg_replace('@^http://@i', 'http://', $row['comment_url']); $row['comment_url'] = preg_replace('@^https://@i', 'https://', $row['comment_url']); if (substr($row['comment_url'], 0, 7) != 'http://' && substr($row['comment_url'], 0, 8) != 'https://') { $row['comment_url'] = 'http://' . $row['comment_url']; } $user = '******' . htmlspecialchars(strip_tags($row['comment_url'])) . '" title="' . htmlspecialchars(strip_tags($row['comment_title'])) . '">' . htmlspecialchars(strip_tags($row['user'])) . '</a>'; } else { $user = htmlspecialchars(strip_tags($row['user'])); } $user = trim($user); if (empty($user)) { $user = PLUGIN_COMMENTS_ANONYMOUS; } if (function_exists('mb_strimwidth')) { $pos = 0; $parts = array(); $enc = LANG_CHARSET; $comment_len = mb_strlen($comment, $enc); while ($pos < $comment_len) { $part = mb_strimwidth($comment, $pos, $wordwrap, '', $enc); $pos += mb_strlen($part, $enc); $parts[] = $part; } $comment = implode("\n", $parts); } else { $comment = wordwrap($comment, $wordwrap, "\n", 1); } $entry = array('comment' => $comment, 'email' => $row['comment_email'], 'url' => $row['comment_url'], 'author' => $row['user']); // Let's help the BBCOde plugin a bit: if (class_exists('serendipity_event_bbcode')) { $entry['comment'] = preg_replace('@((\\[.*)[\\n\\r]+(.*\\]))+@imsU', '\\2\\3', $entry['comment']); $entry['comment'] = preg_replace('@((\\[.+\\].*)[\\r\\n]+(.*\\[/.+\\]))+@imsU', '\\2\\3', $entry['comment']); } $addData = array('from' => 'serendipity_plugin_comments:generate_content'); serendipity_plugin_api::hook_event('frontend_display', $entry, $addData); printf('<div class="plugin_comment_wrap">' . PLUGIN_COMMENTS_ABOUT . '</div>', '<div class="plugin_comment_subject"><span class="plugin_comment_author">' . $user . '</span>', ' <a class="highlight" href="' . serendipity_archiveURL($row['entry_id'], $row['subject'], 'baseURL', true, array('timestamp' => $row['entrystamp'])) . '#c' . $row['comment_id'] . '" title="' . htmlspecialchars($row['subject']) . '">' . htmlspecialchars($row['subject']) . '</a></div>' . "\n" . '<div class="plugin_comment_date">' . htmlspecialchars(serendipity_strftime($dateformat, $row['stamp'])) . '</div>' . "\n" . '<div class="plugin_comment_body">' . strip_tags($entry['comment'], '<br /><img><a>') . '</div>' . "\n\n"); } } }
function showBackend() { global $serendipity; if ($serendipity['POST']['staticblock'] != '__new') { $this->fetchStaticBlock($serendipity['POST']['staticblock']); } if ($serendipity['POST']['staticSave'] == "true" && !empty($serendipity['POST']['SAVECONF'])) { $serendipity['POST']['staticSubmit'] = true; $bag = new serendipity_property_bag(); $this->introspect($bag); $name = function_exists('serendipity_specialchars') ? serendipity_specialchars($bag->get('name')) : htmlspecialchars($bag->get('name'), ENT_COMPAT, LANG_CHARSET); $desc = function_exists('serendipity_specialchars') ? serendipity_specialchars($bag->get('description')) : htmlspecialchars($bag->get('description'), ENT_COMPAT, LANG_CHARSET); $config_names = $bag->get('page_configuration'); foreach ($config_names as $config_item) { $cbag = new serendipity_property_bag(); if ($this->introspect_item($config_item, $cbag)) { $this->staticblock[$config_item] = serendipity_get_bool($_POST['serendipity']['plugin'][$config_item]); } } if ($serendipity['versioon'][0] < 2) { echo '<div class="serendipityAdminMsgSuccess"><img style="width: 22px; height: 22px; border: 0px; padding-right: 4px; vertical-align: middle" src="' . serendipity_getTemplateFile('admin/img/admin_msg_success.png') . '" alt="" />' . DONE . ': ' . sprintf(SETTINGS_SAVED_AT, serendipity_strftime('%H:%M:%S')) . '</div>' . "\n"; } else { echo '<div class="msg_success"><span class="icon-ok-circled"></span> ' . DONE . ': ' . sprintf(SETTINGS_SAVED_AT, serendipity_strftime('%H:%M:%S')) . '</div>' . "\n"; } $this->updateStaticBlock(); } if (!empty($serendipity['POST']['staticDelete']) && $serendipity['POST']['staticblock'] != '__new') { serendipity_db_query("DELETE FROM {$serendipity['dbPrefix']}staticblocks WHERE id = " . (int) $serendipity['POST']['staticblock']); if ($serendipity['versioon'][0] < 2) { echo '<div class="serendipityAdminMsgSuccess"><img style="width: 22px; height: 22px; border: 0px; padding-right: 4px; vertical-align: middle" src="' . serendipity_getTemplateFile('admin/img/admin_msg_success.png') . '" alt="" />' . DONE . ': ' . sprintf(RIP_ENTRY, $this->staticblock['title']) . '</div>' . "\n"; } else { echo '<div class="msg_success"><span class="icon-ok-circled"></span> ' . DONE . ': ' . sprintf(RIP_ENTRY, $this->staticblock['title']) . '</div>' . "\n"; } } echo '<table align="center"> <tr> <th>' . STATICBLOCK_SELECT_TEMPLATES . '</th> <th rowspan="2"> - ' . WORD_OR . ' - </th> <th>' . STATICBLOCK_SELECT_BLOCKS . '</th> </tr> <tr> <td style="text-align: center; vertical-align: top">' . $this->showBlockForm('template') . '</td> <td style="text-align: center; vertical-align: top">' . $this->showBlockForm('block') . '</td> </tr> </table>' . "\n\n"; $solidus = $serendipity['version'][0] < 2 ? ' /' : ''; /* SHOW SELECTION */ echo $this->showBlockForm('form'); if ($serendipity['POST']['staticSubmit']) { echo '<h2>'; if ($serendipity['POST']['type'] == 'template') { echo STATICBLOCK_EDIT_TEMPLATES; } else { echo STATICBLOCK_EDIT_BLOCKS; } echo '</h2>' . "\n\n"; echo '<div>' . "\n"; echo ' <input type="hidden" name="serendipity[staticSave]" value="true"' . $solidus . '>' . "\n"; echo ' <input type="hidden" name="serendipity[staticblock]" value="' . $serendipity['POST']['staticblock'] . '"' . $solidus . '>' . "\n"; echo ' <input type="hidden" name="serendipity[type]" value="' . $serendipity['POST']['type'] . '"' . $solidus . '>' . "\n"; echo '</div>' . "\n\n"; $this->showForm($serendipity['POST']['type']); } echo '</form>' . "\n"; }