function buildEntry($item, &$entry) { global $serendipity; $bodyonly = serendipity_get_bool($this->data['bodyonly']); if ($item['description']) { $entry['body'] = $this->decode($item['description']); } if ($item['content:encoded']) { if (!isset($entry['body']) || $bodyonly) { $data =& $entry['body']; } else { $data =& $entry['extended']; } // See if the 'description' element is a substring of the 'content:encoded' part. If it is, // we will only fetch the full 'content:encoded' part. If it's not a substring, we append // the 'content:encoded' part to either body or extended entry (respecting the 'bodyonly' // switch). We substract 4 letters because of possible '...' additions to an entry. $testbody = substr(trim(strip_tags($entry['body'])), 0, -4); if ($testbody != substr(trim(strip_tags($item['content:encoded'])), 0, strlen($testbody))) { $data .= $this->decode($item['content:encoded']); } else { $data = $this->decode($item['content:encoded']); } } $entry['title'] = $this->decode($item['title']); if (!isset($item['pubdate']) && isset($item['pubDate'])) { $item['pubdate'] = $item['pubDate']; } $entry['timestamp'] = $this->decode(strtotime(isset($item['pubdate']) ? $item['pubdate'] : $item['dc:date'])); if ($entry['timestamp'] == -1) { // strtotime does not seem to parse ISO 8601 dates if (preg_match('@^([0-9]{4})\\-([0-9]{2})\\-([0-9]{2})T([0-9]{2}):([0-9]{2}):([0-9]{2})[\\-\\+]([0-9]{2}):([0-9]{2})$@', isset($item['pubdate']) ? $item['pubdate'] : $item['dc:date'], $timematch)) { $entry['timestamp'] = mktime($timematch[4] - $timematch[7], $timematch[5] - $timematch[8], $timematch[6], $timematch[2], $timematch[3], $timematch[1]); } else { $entry['timestamp'] = time(); } } if ($this->data['type'] == 'draft') { $entry['isdraft'] = 'true'; } else { $entry['isdraft'] = 'false'; } if (!empty($item['category'])) { $cat = serendipity_fetchCategoryInfo(0, trim($this->decode($item['category']))); if (is_array($cat) && isset($cat['categoryid'])) { $entry['categories'][] = $cat['categoryid']; } } if (!is_array($entry['categories'])) { $entry['categories'][] = $this->data['category']; } if (!isset($entry['extended'])) { $entry['extended'] = ''; } $entry['allow_comments'] = true; return true; }
function event_hook($event, &$bag, &$eventData, $addData = null) { global $serendipity; static $login_url = null; if ($login_url === null) { $login_url = $serendipity['baseURL'] . $serendipity['indexFile'] . '?/plugin/loginbox'; } $hooks =& $bag->get('event_hooks'); if (isset($hooks[$event])) { switch ($event) { case 'frontend_saveComment': if (!isset($serendipity['csuccess'])) { $serendipity['csuccess'] = 'true'; } if (serendipity_db_bool($this->get_config('registered_only')) && !serendipity_userLoggedIn() && $addData['source2'] != 'adduser') { $eventData = array('allow_comments' => false); $serendipity['messagestack']['comments'][] = PLUGIN_ADDUSER_REGISTERED_ONLY_REASON; return false; } if (serendipity_db_bool($this->get_config('registered_only')) && !$this->inGroup() && $addData['source2'] != 'adduser') { $eventData = array('allow_comments' => false); $serendipity['messagestack']['comments'][] = PLUGIN_ADDUSER_REGISTERED_ONLY_REASON; return false; } if (serendipity_db_bool($this->get_config('true_identities')) && !serendipity_userLoggedIn()) { $user = str_replace(" b", '', $addData['name']); $user = serendipity_db_escape_string(preg_replace('@\\s+@', ' ', trim($user))); $user = trim($user); $authors = serendipity_db_query("SELECT authorid FROM {$serendipity['dbPrefix']}authors WHERE realname = '" . $user . "'"); if (is_array($authors) && isset($authors[0]['authorid'])) { $eventData = array('allow_comments' => false); $serendipity['messagestack']['comments'][] = sprintf(PLUGIN_ADDUSER_REGISTERED_CHECK_REASON, $login_url, 'onclick="javascript:loginbox = window.open(this.href, \'loginbox\', \'width=300,height=300,locationbar=no,menubar=no,personalbar=no,statusbar=yes,status=yes,toolbar=no\'); return false;"'); } } break; case 'external_plugin': if ($eventData != 'loginbox') { return true; } $out = array(); serendipity_plugin_api::hook_event('backend_login_page', $out); serendipity_smarty_init(); $serendipity['smarty']->assign(array('loginform_add' => $out, 'loginform_url' => $login_url, 'loginform_user' => $_SESSION['serendipityUser'], 'loginform_mail' => $_SESSION['serendipityEmail'], 'close_window' => defined('LOGIN_ACTION'), 'is_logged_in' => serendipity_userLoggedIn(), 'is_error' => defined('LOGIN_ERROR'))); $filename = 'loginbox.tpl'; $tfile = serendipity_getTemplateFile($filename, 'serendipityPath'); if (!$tfile || $tfile == $filename) { $tfile = dirname(__FILE__) . '/' . $filename; } $inclusion = $serendipity['smarty']->security_settings[INCLUDE_ANY]; $serendipity['smarty']->security_settings[INCLUDE_ANY] = true; $serendipity['smarty']->display($tfile); break; case 'frontend_display': if (serendipity_db_bool($this->get_config('registered_only')) && !serendipity_userLoggedIn()) { $serendipity['messagestack']['comments'][] = sprintf(PLUGIN_ADDUSER_REGISTERED_ONLY_REASON, $serendipity['baseURL'] . $serendipity['indexFile'] . '?serendipity[subpage]=adduser', $serendipity['baseURL'] . 'serendipity_admin.php'); $eventData['allow_comments'] = false; } break; case 'frontend_configure': if (isset($serendipity['POST']['action']) && isset($serendipity['POST']['user']) && isset($serendipity['POST']['pass'])) { serendipity_login(); if (serendipity_userLoggedIn()) { define('LOGIN_ACTION', 'login'); header('X-s9y-auth: Login'); } else { define('LOGIN_ERROR', true); } } elseif (isset($serendipity['POST']['action']) && isset($serendipity['POST']['logout'])) { serendipity_logout(); if (!serendipity_userLoggedIn()) { header('X-s9y-auth: Logout'); define('LOGIN_ACTION', 'logout'); } } if ((serendipity_db_bool($this->get_config('registered_only')) || serendipity_db_bool($this->get_config('true_identities'))) && $_SESSION['serendipityAuthedUser']) { if (defined('IN_serendipity_admin') && $serendipity['GET']['adminAction'] == 'doEdit') { // void } else { $serendipity['COOKIE']['name'] = isset($_SESSION['serendipityRealname']) ? $_SESSION['serendipityRealname'] : $_SESSION['serendipityUser']; $serendipity['COOKIE']['email'] = $_SESSION['serendipityEmail']; if ($serendipity['POST']['comment']) { $serendipity['POST']['name'] = $serendipity['COOKIE']['name']; $serendipity['POST']['email'] = $serendipity['COOKIE']['email']; } } } return true; break; case 'entry_display': if ($serendipity['GET']['subpage'] == 'adduser' || $serendipity['POST']['subpage'] == 'adduser' || !empty($serendipity['GET']['adduser_activation']) || !empty($this->clean_page)) { if (is_array($eventData)) { $eventData['clean_page'] = true; } } break; case 'entries_header': if ($serendipity['GET']['subpage'] == 'adduser' || $serendipity['POST']['subpage'] == 'adduser' || !empty($serendipity['GET']['adduser_activation'])) { $this->clean_page = true; $url = $serendipity['baseURL'] . $serendipity['indexFile']; $hidden['subpage'] = 'adduser'; $username = substr($serendipity['POST']['adduser_user'], 0, 40); $password = substr($serendipity['POST']['adduser_pass'], 0, 32); $email = $serendipity['POST']['adduser_email']; echo '<div id="adduser_form" style="padding-left: 4px; padding-right: 10px"><a id="adduser"></a>'; // Get the config from the sidebar plugin $pair_config = array('userlevel' => USERLEVEL_EDITOR, 'no_create' => false, 'right_publish' => false, 'instructions' => $this->get_config('instructions', ''), 'usergroups' => array(), 'straight_insert' => false, 'approve' => false, 'use_captcha' => false); $config = serendipity_db_query("SELECT name, value FROM {$serendipity['dbPrefix']}config WHERE name LIKE 'serendipity_plugin_adduser:%'"); if (is_array($config)) { foreach ($config as $conf) { $names = explode('/', $conf['name']); if ($names[1] == 'instructions' && !empty($pair_config['instructions'])) { continue; } if ($names[1] == 'usergroups') { $ug = (array) explode(',', $conf['value']); foreach ($ug as $cid) { if ($cid === false || empty($cid)) { continue; } $pair_config[$names[1]][$cid] = $cid; } } else { $pair_config[$names[1]] = serendipity_get_bool($conf['value']); } } } if (!serendipity_common_adduser::adduser($username, $password, $email, $pair_config['userlevel'], $pair_config['usergroups'], $pair_config['no_create'], $pair_config['right_publish'], $pair_config['straight_insert'], $pair_config['approve'], $pair_config['use_captcha'])) { serendipity_common_adduser::loginform($url, $hidden, $pair_config['instructions'], $username, $password, $email, $pair_config['use_captcha']); } echo '</div>'; } return true; break; default: return false; } } else { return false; } }
/** * Loads all configuration values and imports them to the $serendipity array * * This function may be called twice - once for the global config and once for * user-specific config * * @access public * @param int The Authorid to fetch the configuration from (0: global) * @return null */ function serendipity_load_configuration($author = null) { global $serendipity; static $config_loaded = array(); if (isset($config_loaded[$author])) { return true; } if (!empty($author)) { // Replace default configuration directives with user-relevant data $rows =& serendipity_db_query("SELECT name,value\n FROM {$serendipity['dbPrefix']}config\n WHERE authorid = '" . (int) $author . "'"); } else { // Only get default variables, user-independent (frontend) $rows =& serendipity_db_query("SELECT name, value\n FROM {$serendipity['dbPrefix']}config\n WHERE authorid = 0"); } if (is_array($rows)) { foreach ($rows as $row) { // Convert 'true' and 'false' into booleans $serendipity[$row['name']] = serendipity_get_bool($row['value']); } } $config_loaded[$author] = true; // Set baseURL to defaultBaseURL if ((empty($author) || empty($serendipity['baseURL'])) && isset($serendipity['defaultBaseURL'])) { $serendipity['baseURL'] = $serendipity['defaultBaseURL']; } // Store default language $serendipity['default_lang'] = $serendipity['lang']; }
function showBackend() { global $serendipity; // check sidebar plugin availability $sbplav = !$this->sb_plugin_status() ? true : false; if (isset($serendipity['GET']['staticid']) && !isset($serendipity['POST']['staticpage'])) { $serendipity['POST']['staticpage'] = (int) $serendipity['GET']['staticid']; } if (isset($serendipity['GET']['pre']) && is_array($serendipity['GET']['pre'])) { // Allow to create a new staticpage from a bookmark link $serendipity['POST']['plugin'] = $serendipity['GET']['pre']; $serendipity['POST']['staticpage'] = '__new'; $serendipity['POST']['staticSubmit'] = true; } if ($serendipity['version'][0] < 2) { echo '<script type="text/javascript" src="' . $serendipity['serendipityHTTPPath'] . 'serendipity_define.js.php"></script>' . "\n"; echo '<script type="text/javascript" src="' . $serendipity['serendipityHTTPPath'] . 'serendipity_editor.js"></script>'; } ?> <div id="serendipityStaticpagesNav"> <ul> <li <?php echo $serendipity['GET']['staticpagecategory'] == 'pageedit' ? 'id="active"' : ''; ?> ><a href="<?php echo $serendipity['serendipityHTTPPath'] . 'serendipity_admin.php?serendipity[adminModule]=event_display&serendipity[adminAction]=staticpages&serendipity[staticpagecategory]=pageedit'; ?> "><?php echo STATICPAGE_CATEGORY_PAGES; ?> </a></li> <li <?php echo $serendipity['GET']['staticpagecategory'] == 'pageorder' ? 'id="active"' : ''; ?> ><a href="<?php echo $serendipity['serendipityHTTPPath'] . 'serendipity_admin.php?serendipity[adminModule]=event_display&serendipity[adminAction]=staticpages&serendipity[staticpagecategory]=pageorder'; ?> "><?php echo STATICPAGE_CATEGORY_PAGEORDER; ?> </a></li> <li <?php echo $serendipity['GET']['staticpagecategory'] == 'pagetype' || $serendipity['POST']['staticpagecategory'] == 'pagetype' ? 'id="active"' : ''; ?> ><a href="<?php echo $serendipity['serendipityHTTPPath'] . 'serendipity_admin.php?serendipity[adminModule]=event_display&serendipity[adminAction]=staticpages&serendipity[staticpagecategory]=pagetype'; ?> "><?php echo STATICPAGE_CATEGORY_PAGETYPES; ?> </a></li> <li <?php echo $serendipity['GET']['staticpagecategory'] == 'pageadd' ? 'id="active"' : ''; ?> ><a href="<?php echo $serendipity['serendipityHTTPPath'] . 'serendipity_admin.php?serendipity[adminModule]=event_display&serendipity[adminAction]=staticpages&serendipity[staticpagecategory]=pageadd'; ?> "><?php echo STATICPAGE_CATEGORY_PAGEADD; ?> </a></li> </ul> </div> <?php $spcat = !empty($serendipity['GET']['staticpagecategory']) ? $serendipity['GET']['staticpagecategory'] : $serendipity['POST']['staticpagecategory']; switch ($spcat) { case 'pageorder': echo '<strong>' . STATICPAGE_PAGEORDER_DESC . '</strong><br /><br />'; switch ($serendipity['GET']['moveto']) { case 'moveup': $this->move_up($serendipity['GET']['pagetomove']); break; case 'movedown': $this->move_down($serendipity['GET']['pagetomove']); break; } $pages = $this->fetchStaticPages(true); if (is_array($pages)) { $pages = serendipity_walkRecursive($pages); $sort_idx = 0; echo '<table>' . "\n"; foreach ($pages as $page) { echo '<tr>' . "\n"; echo '<td>'; echo str_repeat(' ', $page['depth']) . $page['pagetitle']; echo '</td>' . "\n"; echo '<td>'; if ($sort_idx == 0) { echo ' '; } else { echo '<a href="?serendipity[adminModule]=staticpages&serendipity[moveto]=moveup&serendipity[pagetomove]=' . $page['id'] . '&serendipity[adminModule]=event_display&serendipity[adminAction]=staticpages&serendipity[staticpagecategory]=pageorder" style="border: 0"><img src="' . serendipity_getTemplateFile('admin/img/uparrow.png') . '" height="16" width="16" border="0" alt="' . UP . '" /></a>'; } echo '</td>' . "\n"; echo '<td>'; if ($sort_idx == count($pages) - 1) { echo ' '; } else { echo ($page['moveup'] != '' ? ' ' : '') . '<a href="?serendipity[adminModule]=staticpages&serendipity[moveto]=movedown&serendipity[pagetomove]=' . $page['id'] . '&serendipity[adminModule]=event_display&serendipity[adminAction]=staticpages&serendipity[staticpagecategory]=pageorder" style="border: 0"><img src="' . serendipity_getTemplateFile('admin/img/downarrow.png') . '" height="16" width="16" alt="' . DOWN . '" border="0" /></a>'; } echo '</td>' . "\n"; echo '</tr>' . "\n"; $sort_idx++; } echo '</table>' . "\n"; } break; case 'pagetype': if ($serendipity['POST']['pagetype'] != '__new') { $this->fetchPageType($serendipity['POST']['pagetype']); } 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_t = $bag->get('type_configuration'); foreach ($config_t as $config_item) { $cbag = new serendipity_property_bag(); if ($this->introspect_item_type($config_item, $cbag)) { $this->pagetype[$config_item] = serendipity_get_bool($serendipity['POST']['plugin'][$config_item]); } } echo '<div class="serendipityAdminMsgSuccess">' . DONE . ': ' . sprintf(SETTINGS_SAVED_AT, serendipity_strftime('%H:%M:%S')) . '</div>'; $this->updatePageType(); } if (!empty($serendipity['POST']['typeDelete']) && $serendipity['POST']['pagetype'] != '__new') { serendipity_db_query("DELETE FROM {$serendipity['dbPrefix']}staticpages_types WHERE id = " . (int) $serendipity['POST']['pagetype']); echo '<div class="serendipityAdminMsgSuccess">' . DONE . ': ' . sprintf(RIP_ENTRY, $this->pagetype['description']) . '</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="staticpages" />'; echo '<input type="hidden" name="serendipity[staticpagecategory]" value="pagetype" />'; echo '<div>'; echo '<strong>' . PAGETYPES_SELECT . '</strong><br /><br />'; echo '<select name="serendipity[pagetype]">'; echo ' <option value="__new">' . NEW_ENTRY . '</option>'; echo ' <option value="__new">-----------------</option>'; $types = $this->fetchPageTypes(); if (is_array($types)) { foreach ($types as $type) { echo ' <option value="' . $type['id'] . '" ' . ($serendipity['POST']['pagetype'] == $type['id'] ? 'selected="selected"' : '') . '>' . (function_exists('serendipity_specialchars') ? serendipity_specialchars($type['description']) : htmlspecialchars($type['description'], ENT_COMPAT, LANG_CHARSET)) . '</option>'; } } echo '</select> <input type="submit" class="serendipityPrettyButton input_button" name="serendipity[typeSubmit]" value="' . GO . '" /> <strong>-' . WORD_OR . '-</strong> <input type="submit" class="serendipityPrettyButton input_button" name="serendipity[typeDelete]" value="' . DELETE . '" />'; echo '</select>'; echo '</div>'; echo '<div>'; if ($serendipity['POST']['typeSubmit']) { echo '<input type="hidden" name="serendipity[typeSave]" value="true" />'; $this->showForm($this->config_types, $this->pagetype, 'introspect_item_type', 'get_type', 'typeSubmit'); } echo '</form>'; echo '</div>'; break; case 'pageadd': echo '<strong>' . STATICPAGE_PAGEADD_DESC . '</strong><br /><br />'; $plugins = $this->selectPlugins(); $insplugins = $this->fetchPlugins(); if (isset($serendipity['POST']['typeSubmit'])) { foreach ($insplugins as $key => $values) { if (empty($serendipity['POST']['externalPlugins'][$key])) { serendipity_db_query('DELETE FROM ' . $serendipity['dbPrefix'] . 'staticpages WHERE id = ' . (int) $values['id']); } } if (count($serendipity['POST']['externalPlugins'])) { foreach ($serendipity['POST']['externalPlugins'] as $plugin) { $this->staticpage = array('permalink' => $plugins[$plugin]['link'], 'content' => 'plugin', 'pre_content' => $plugin, 'pagetitle' => $plugins[$plugin]['name'], 'headline' => $plugins[$plugin]['name']); $this->updateStaticPage(); } } } $insplugins = $this->fetchPlugins(); if (is_array($plugins)) { echo '<form action="serendipity_admin.php" method="post" name="serendipityPlugins">'; echo '<input type="hidden" name="serendipity[adminModule]" value="event_display" />'; echo '<input type="hidden" name="serendipity[adminAction]" value="staticpages" />'; echo '<input type="hidden" name="serendipity[staticpagecategory]" value="pageadd" />'; foreach ($plugins as $key => $plugin) { if (isset($insplugins[$key])) { $c = 'checked="checked"'; } else { $c = ''; } echo '<input class="input_checkbox" type="checkbox" name="serendipity[externalPlugins][]" value="' . $key . '" ' . $c . ' />' . $plugin['name'] . '<br />'; } echo '<input type="submit" name="serendipity[typeSubmit]" class="serendipityPrettyButton input_button" value="' . GO . '">'; echo '</form>'; } echo '<strong>' . STATICPAGE_PAGEADD_PLUGINS . '</strong><br /><br />'; $this->pluginstatus(); echo '<table>'; echo '<tr id="serendipityStaticpagesTableHeader">'; echo '<th>' . EVENT_PLUGIN . '</th>'; echo '<th>' . STATICPAGE_STATUS . '</th>'; echo '</tr>'; $i = 0; foreach ($this->pluginstats as $key => $value) { echo '<tr id="serendipityStaticpagesTable' . $i++ % 2 . '">'; echo '<td>' . $key . '</td>'; echo '<td><span id="serendipityStaticpages' . $value['color'] . '">' . $value['status'] . '</span></td>'; echo '</tr>'; } echo '</table>'; break; case 'pages': default: if ($serendipity['POST']['staticpage'] != '__new') { $this->fetchStaticPage($serendipity['POST']['staticpage']); } 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->staticpage[$config_item] = serendipity_get_bool($serendipity['POST']['plugin'][$config_item]); } } $result = $this->updateStaticPage(); if (is_string($result)) { 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>'; } else { echo '<div class="serendipityAdminMsgSuccess">' . DONE . ': ' . sprintf(SETTINGS_SAVED_AT, serendipity_strftime('%H:%M:%S')) . '</div>'; } } if (!empty($serendipity['POST']['staticDelete']) && $serendipity['POST']['staticpage'] != '__new') { if (!$this->getChildPage($serendipity['POST']['staticpage'])) { serendipity_db_query("DELETE FROM {$serendipity['dbPrefix']}staticpages WHERE id = " . (int) $serendipity['POST']['staticpage']); echo '<div class="serendipityAdminMsgSuccess">' . DONE . ': ' . sprintf(RIP_ENTRY, $this->staticpage['pagetitle']) . '</div>'; } else { 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="" />' . IMPORT_NOTES . ': ' . STATICPAGE_CANNOTDELETE_MSG . '</div>'; } } echo '<form action="serendipity_admin.php" method="post" name="serendipityEntry">'; echo '<div>'; echo ' <input type="hidden" name="serendipity[adminModule]" value="event_display" />'; echo ' <input type="hidden" name="serendipity[adminAction]" value="staticpages" />'; echo ' <input type="hidden" name="serendipity[staticpagecategory]" value="pages" />'; echo '</div>'; if (empty($serendipity['POST']['backend_template'])) { if (!empty($serendipity['COOKIE']['backend_template'])) { $serendipity['POST']['backend_template'] = $serendipity['COOKIE']['backend_template']; } } else { serendipity_JSsetCookie('backend_template', $serendipity['POST']['backend_template']); } echo '<div class="sp_templateselector">'; echo '<label for="sp_templateselector">' . STATICPAGE_TEMPLATE . '</label> <select id="sp_templateselector" name="serendipity[backend_template]">'; echo '<option ' . ($serendipity['POST']['backend_template'] == 'external' ? 'selected="selected"' : '') . ' value="external">' . STATICPAGE_TEMPLATE_EXTERNAL . '</option>'; echo '<option ' . ($serendipity['POST']['backend_template'] == 'internal' ? 'selected="selected"' : '') . ' value="internal">' . STATICPAGE_TEMPLATE_INTERNAL . '</option>'; $dh = @opendir(dirname(__FILE__) . '/backend_templates'); if ($dh) { while ($file = readdir($dh)) { if ($file != 'default_staticpage_backend.tpl' && preg_match('@^(.*).tpl$@i', $file, $m)) { echo '<option ' . ($file == $serendipity['POST']['backend_template'] ? 'selected="selected"' : '') . ' value="' . (function_exists('serendipity_specialchars') ? serendipity_specialchars($file) : htmlspecialchars($file, ENT_COMPAT, LANG_CHARSET)) . '">' . (function_exists('serendipity_specialchars') ? serendipity_specialchars($m[1]) : htmlspecialchars($m[1], ENT_COMPAT, LANG_CHARSET)) . '</option>' . "\n"; } } } $dh = @opendir($serendipity['templatePath'] . $serendipity['template'] . '/backend_templates'); if ($dh) { while ($file = readdir($dh)) { if ($file != 'default_staticpage_backend.tpl' && preg_match('@^(.*).tpl$@i', $file, $m)) { echo '<option ' . ($file == $serendipity['POST']['backend_template'] ? 'selected="selected"' : '') . ' value="' . (function_exists('serendipity_specialchars') ? serendipity_specialchars($file) : htmlspecialchars($file, ENT_COMPAT, LANG_CHARSET)) . '">' . (function_exists('serendipity_specialchars') ? serendipity_specialchars($m[1]) : htmlspecialchars($m[1], ENT_COMPAT, LANG_CHARSET)) . '</option>' . "\n"; } } } echo '</select>'; echo '</div>'; echo '<div class="sp_pageselector">'; echo '<strong>' . STATICPAGE_SELECT . '</strong><br /><br />'; echo '<select name="serendipity[staticpage]" id="staticpage_dropdown">'; echo ' <option value="__new">' . NEW_ENTRY . '</option>'; echo ' <option value="__new">-----------------</option>'; $pages = $this->fetchStaticPages(); if (is_array($pages)) { $pages = serendipity_walkRecursive($pages); foreach ($pages as $page) { if ($this->checkPageUser($page['authorid'])) { echo ' <option value="' . $page['id'] . '" ' . ($serendipity['POST']['staticpage'] == $page['id'] ? 'selected="selected"' : '') . '>'; echo str_repeat(' ', $page['depth']) . (function_exists('serendipity_specialchars') ? serendipity_specialchars($page['pagetitle']) : htmlspecialchars($page['pagetitle'], ENT_COMPAT, LANG_CHARSET)) . '</option>'; } } } echo '</select> <input class="serendipityPrettyButton input_button" type="submit" name="serendipity[staticSubmit]" value="' . GO . '" /> <strong>-' . WORD_OR . '-</strong> <input type="submit" name="serendipity[staticDelete]" onclick="return confirm(\'' . sprintf(DELETE_SURE, '\' + document.getElementById(\'staticpage_dropdown\').options[document.getElementById(\'staticpage_dropdown\').selectedIndex].text + \'') . '\');" class="serendipityPrettyButton input_button" value="' . DELETE . '" />'; echo ' <strong>-' . WORD_OR . '-</strong> <input class="serendipityPrettyButton input_button" type="submit" name="serendipity[staticPreview]" value="' . PREVIEW . '" />'; if ($sbplav) { echo '<div style="cursor: pointer; float: right;">'; echo '<img style="vertical-align: middle;" class="attention" title="Staticpage Sidebar ' . STATICPAGE_PLUGIN_AVAILABLE . '" src="' . serendipity_getTemplateFile('admin/img/admin_msg_note.png') . '" alt="info" />'; echo '</div>'; } echo '</div>'; if (!empty($serendipity['POST']['staticPreview'])) { $link = $serendipity['baseURL'] . $serendipity['indexFile'] . '?serendipity[staticid]=' . $this->staticpage['id'] . '&serendipity[staticPreview]=1'; echo '<script type="text/javascript">'; echo 'var staticpage_preview = window.open("' . $link . '", "staticpage_preview");' . "\n"; echo 'staticpage_preview.focus();' . "\n"; echo '</script>'; $serendipity['POST']['staticSubmit'] = true; echo '<p>' . sprintf(PLUGIN_STATICPAGE_PREVIEW, '<a href="' . $link . '">' . $this->staticpage['pagetitle'] . '</a>') . '</p>'; } echo '<div>'; if ($serendipity['POST']['staticSubmit'] || isset($serendipity['GET']['staticid'])) { $serendipity['POST']['plugin']['custom'] = $this->staticpage['custom']; echo '<input type="hidden" name="serendipity[staticSave]" value="true" />'; $this->showForm($this->config, $this->staticpage); echo "</div>\n"; echo '</form>'; } else { echo "</div>\n"; echo '</form>'; $this->listStaticPages(); } break; } }
/** * Preprocess the configuration value and put it into a HTML output field (radio, password, text, select, ...) * * @access public * @param string The type of the configuration item * @param string The name of the configuration item * @param string The current value of the configuration item * @param string The default value of the configuration item * @return null */ function serendipity_guessInput($type, $name, $value = '', $default = '') { global $serendipity; switch ($type) { case 'bool': $value = serendipity_get_bool($value); if ($value === null) { $value = $default; } echo '<input class="input_radio" id="radio_cfg_' . $name . '_yes" type="radio" name="' . $name . '" value="true" '; echo ($value == true ? 'checked="checked"' : '') . ' /><label for="radio_cfg_' . $name . '_yes"> ' . YES . '</label> '; echo '<input class="input_radio" id="radio_cfg_' . $name . '_no" type="radio" name="' . $name . '" value="false" '; echo ($value == true ? '' : 'checked="checked"') . ' /><label for="radio_cfg_' . $name . '_no"> ' . NO . '</label>'; break; case 'fullprotected': echo '<input autocomplete="off" class="input_textbox" type="password" size="30" name="' . $name . '" value="' . htmlspecialchars($value) . '" />'; break; case 'protected': echo '<input class="input_textbox" type="password" size="30" name="' . $name . '" value="' . htmlspecialchars($value) . '" />'; break; case 'multilist': echo '<select name="' . $name . '[]" multiple="multiple" size="5">'; foreach ((array) $default as $k => $v) { $selected = false; foreach ((array) $value as $vk => $vv) { if ($vv['confkey'] == $v['confkey']) { $selected = true; } } printf('<option value="%s"%s>%s</option>' . "\n", $v['confkey'], $selected ? ' selected="selected"' : '', $v['confvalue']); } echo '</select>'; break; case 'list': echo '<select name="' . $name . '">'; $cval = (string) $value; foreach ((array) $default as $k => $v) { $selected = (string) $k == (string) $value; if (empty($cval) && ((string) $k === 'false' || (string) $k === null)) { $selected = true; } printf('<option value="%s"%s>%s</option>' . "\n", $k, $selected ? ' selected="selected"' : '', $v); } echo '</select>'; break; case 'file': echo '<input class="input_file" type="file" size="30" name="' . $name . '" />'; break; case 'textarea': echo '<textarea rows="5" cols="40" name="' . $name . '">' . htmlspecialchars($value) . '</textarea>'; break; default: echo '<input class="input_textbox" type="text" size="30" name="' . $name . '" value="' . htmlspecialchars($value) . '" />'; break; } }
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; } }
/** * Preprocess the configuration value and put it into a HTML output field (radio, password, text, select, ...) * * @access public * @param string The type of the configuration item * @param string The name of the configuration item * @param string The current value of the configuration item * @param string The default value of the configuration item * @return null */ function serendipity_guessInput($type, $name, $value = '', $default = '') { $data = array(); $curOptions = array(); switch ($type) { case 'bool': $value = serendipity_get_bool($value); if ($value === null) { $value = $default; } break; case 'multilist': $default = (array) $default; $value = (array) $value; foreach ($default as $k => $v) { $selected = false; foreach ($value as $vk => $vv) { if ($vv['confkey'] == $v['confkey']) { $selected = true; } } $curOptions[$name][$k]['selected'] = $selected; } break; case 'list': $cval = (string) $value; $default = (array) $default; foreach ($default as $k => $v) { $selected = (string) $k == (string) $value; if (empty($cval) && ((string) $k === 'false' || (string) $k === null)) { $selected = true; } $curOptions[$name][$k]['selected'] = $selected; } break; } $data['type'] = $type; $data['name'] = $name; $data['value'] = $value; $data['default'] = $default; $data['selected'] = $curOptions; return serendipity_smarty_show('admin/guess_input.tpl', $data); }
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"; }
static function checkuser($usergroups = array()) { global $serendipity; static $debug = false; if (!empty($serendipity['GET']['adduser_activation']) && !empty($_GET['r'])) { $string = $serendipity['GET']['adduser_activation']; $q = "SELECT * FROM {$serendipity['dbPrefix']}pending_authors WHERE hash = '" . serendipity_db_escape_string($string) . "' LIMIT 1"; if ($debug) { echo "[debug] QUERY: {$q}<br />\n"; } $author = serendipity_db_query($q, true); serendipity_common_adduser::sendMail($author['username'], function_exists('serendipity_specialchars') ? serendipity_specialchars($string) : htmlspecialchars($string, ENT_COMPAT, LANG_CHARSET), $author['email'], false, false); echo PLUGIN_ADDUSER_SENTMAIL_APPROVE_ADMIN; return true; } if (!empty($serendipity['GET']['adduser_activation'])) { $string = $serendipity['GET']['adduser_activation']; unset($serendipity['GET']['adduser_activation']); if (strlen($string) != 32) { echo PLUGIN_ADDUSER_WRONG_ACTIVATION . '<hr />'; return false; } $q = "SELECT * FROM {$serendipity['dbPrefix']}pending_authors WHERE hash = '" . serendipity_db_escape_string($string) . "' LIMIT 1"; if ($debug) { echo "[debug] QUERY: {$q}<br />\n"; } $author = serendipity_db_query($q, true); if ($debug) { echo "[debug] RESULT: " . print_r($author, true) . "<br />\n"; } if (is_array($author)) { $user = serendipity_db_query("SELECT authorid FROM {$serendipity['dbPrefix']}authors WHERE username = '******'username']) . "'", true); if (is_array($user) && !empty($user['authorid'])) { printf(PLUGIN_ADDUSER_EXISTS . '<hr />', function_exists('serendipity_specialchars') ? serendipity_specialchars($author['username']) : htmlspecialchars($author['username'], ENT_COMPAT, LANG_CHARSET)); return false; } $newID = serendipity_addAuthor($author['username'], '', $author['username'], $author['email'], $author['userlevel']); if ($debug) { echo "[debug] serendipity_addAuthor: {$newID}<br />\n"; } if ($newID) { serendipity_db_query("UPDATE {$serendipity['dbPrefix']}authors\n SET right_publish = '" . ($author['right_publish'] ? '1' : '0') . "',\n password = '******'password'] . "'\n WHERE authorid = " . (int) $newID); serendipity_set_config_var('no_create', $author['no_create'], $newID); serendipity_set_config_var('lang', $serendipity['lang'], $newID); // Fetch default properties for new authors as configured. // Only set values for the keys that are supported (all booleans currently!) $config = serendipity_db_query("SELECT name, value FROM {$serendipity['dbPrefix']}config WHERE name LIKE 'serendipity_plugin_adduser:%'"); $pair_config = array('wysiwyg' => '', 'simpleFilters' => '', 'enableBackendPopup' => '', 'moderateCommentsDefault' => '', 'allowCommentsDefault' => '', 'showMediaToolbar' => '', 'use_autosave' => ''); if (is_array($config)) { foreach ($config as $conf) { $names = explode('/', $conf['name']); if (isset($pair_config[$names[1]])) { $pair_config[$names[1]] = serendipity_get_bool($conf['value']); serendipity_set_config_var($names[1], $pair_config['wysiwyg'], $newID); } } } if (is_array($usergroups) && function_exists('serendipity_updateGroups')) { if ($debug) { echo "[debug] update groups: " . print_r($usergroups, true) . "<br />\n"; } serendipity_updateGroups($usergroups, $newID, false); } elseif ($debug) { echo "[debug] no group addition: " . print_r($usergroups, true) . "<br />\n"; } } elseif ($debug) { echo "[debug] serendipity_addAuthor() failed!<br />\n"; } } $q = "SELECT authorid FROM {$serendipity['dbPrefix']}authors\n WHERE username = '******'username'] . "'\n AND password = '******'password'] . "'\n LIMIT 1"; $newauthor = serendipity_db_query($q, true); if (is_array($newauthor) && $newauthor['authorid'] > 0) { echo PLUGIN_ADDUSER_SUCCEED . '<hr />'; serendipity_db_query("DELETE FROM {$serendipity['dbPrefix']}pending_authors WHERE hash = '" . serendipity_db_escape_string($string) . "'"); return true; } else { if ($debug) { echo "[debug] QUERY: {$q}<br />\n"; echo "[debug] RESULT: " . print_r($newauthor, true) . "<br />\n"; } echo PLUGIN_ADDUSER_FAILED . '<hr />'; return false; } } return false; }