コード例 #1
0
/**
 * Toggle whether an entry allows comments
 *
 * @access public
 * @param   int     The ID of the entry where the switch shall be toggled
 * @param   string  Whether the entry shall be opened or closed for comments
 * @return null
 */
function serendipity_allowCommentsToggle($entry_id, $switch = 'disable')
{
    global $serendipity;
    if ($_SESSION['serendipityAuthedUser'] === true) {
        $admin = '';
        if (!serendipity_checkPermission('adminEntriesMaintainOthers')) {
            $admin = " AND authorid = " . (int) $_SESSION['serendipityAuthorid'];
        }
        $query = "UPDATE {$serendipity['dbPrefix']}entries SET allow_comments = '" . ($switch == 'disable' ? 'false' : 'true') . "' WHERE id = '" . (int) $entry_id . "' {$admin}";
        serendipity_db_query($query);
        if (serendipity_isResponseClean($_SERVER['HTTP_REFERER'])) {
            header('Status: 302 Found');
            header('Location: ' . $_SERVER['HTTP_REFERER']);
            exit;
        }
    } else {
        die('What are you up to? You need to be an admin to close comments');
    }
}
コード例 #2
0
ファイル: comment.php プロジェクト: jimjag/Serendipity
                    $serendipity['smarty']->assign(array('is_showcomments' => true, 'is_comment_allowed' => $comment_allowed));
                    if ($comment_allowed) {
                        serendipity_displayCommentForm($id, '?', NULL, $serendipity['POST'], true, serendipity_db_bool($ca['moderate_comments']), $ca);
                    }
                }
            } else {
                $comment['url'] = $serendipity['POST']['url'];
                $comment['comment'] = trim($serendipity['POST']['comment']);
                $comment['name'] = $serendipity['POST']['name'];
                $comment['email'] = $serendipity['POST']['email'];
                $comment['subscribe'] = $serendipity['POST']['subscribe'];
                $comment['parent_id'] = $serendipity['POST']['replyTo'];
                if (!empty($comment['comment'])) {
                    if (serendipity_saveComment($id, $comment, 'NORMAL')) {
                        $sc_url = $serendipity['baseURL'] . 'comment.php?serendipity[entry_id]=' . $id . '&success=true&url=' . urlencode($_SERVER['HTTP_REFERER']);
                        if (serendipity_isResponseClean($sc_url)) {
                            header('Status: 302 Found');
                            header('Location: ' . $sc_url);
                        }
                        exit;
                    } else {
                        $serendipity['smarty']->assign(array('is_comment_notadded' => true, 'comment_url' => serendipity_specialchars($_SERVER['HTTP_REFERER']), 'comment_string' => explode('%s', COMMENT_NOT_ADDED_CLICK)));
                    }
                } else {
                    $serendipity['smarty']->assign(array('is_comment_empty' => true, 'comment_url' => serendipity_specialchars($_SERVER['HTTP_REFERER']), 'comment_string' => explode('%s', EMPTY_COMMENT)));
                }
            }
        }
        $serendipity['smarty']->display(serendipity_getTemplateFile($serendipity['smarty_file'], 'serendipityPath'));
    }
}
コード例 #3
0
function serveEntry($matches)
{
    global $serendipity;
    $serendipity['view'] = 'entry';
    $uri = $_SERVER['REQUEST_URI'];
    if (isset($serendipity['GET']['id'])) {
        $matches[1] = (int) $serendipity['GET']['id'];
    } elseif (isset($_GET['p'])) {
        $matches[1] = $_GET['p'];
    } else {
        $matches[1] = serendipity_searchPermalink($serendipity['permalinkStructure'], $uri, !empty($matches[2]) ? $matches[2] : $matches[1], 'entry');
    }
    serendipity_rememberComment();
    if (!empty($serendipity['POST']['submit']) && !isset($_REQUEST['serendipity']['csuccess'])) {
        $comment['url'] = $serendipity['POST']['url'];
        $comment['comment'] = trim($serendipity['POST']['comment']);
        $comment['name'] = $serendipity['POST']['name'];
        $comment['email'] = $serendipity['POST']['email'];
        $comment['subscribe'] = $serendipity['POST']['subscribe'];
        $comment['parent_id'] = $serendipity['POST']['replyTo'];
        if (!empty($comment['comment'])) {
            if (serendipity_saveComment($serendipity['POST']['entry_id'], $comment, 'NORMAL')) {
                $sc_url = ($_SERVER['HTTPS'] == 'on' ? 'https://' : 'http://') . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI'] . (strstr($_SERVER['REQUEST_URI'], '?') ? '&' : '?') . 'serendipity[csuccess]=' . (isset($serendipity['csuccess']) ? $serendipity['csuccess'] : 'true');
                if (serendipity_isResponseClean($sc_url)) {
                    header('Status: 302 Found');
                    header('Location: ' . $sc_url);
                }
                exit;
            } else {
                $serendipity['messagestack']['comments'][] = COMMENT_NOT_ADDED;
            }
        } else {
            $serendipity['messagestack']['comments'][] = sprintf(EMPTY_COMMENT, '', '');
        }
    }
    $id = (int) $matches[1];
    if ($id === 0) {
        $id = false;
    }
    $_GET['serendipity']['action'] = 'read';
    $_GET['serendipity']['id'] = $id;
    $title = serendipity_db_query("SELECT title FROM {$serendipity['dbPrefix']}entries WHERE id={$id} AND isdraft = 'false' " . (!serendipity_db_bool($serendipity['showFutureEntries']) ? " AND timestamp <= " . serendipity_db_time() : ''), true);
    if (is_array($title)) {
        $serendipity['head_title'] = serendipity_specialchars($title[0]);
        $serendipity['head_subtitle'] = serendipity_specialchars($serendipity['blogTitle']);
    } else {
        $serendipity['view'] = '404';
        $serendipity['viewtype'] = '404_1';
        header('HTTP/1.0 404 Not found');
        header('Status: 404 Not found');
    }
    include S9Y_INCLUDE_PATH . 'include/genpage.inc.php';
}
コード例 #4
0
 /**
  * function backend_eventcal_dbclean($cm, $cy)
  * @param current month and year
  * main backend function navigation number 4
  * plugins panel administration
  * switch into dump, insert, erase, delete, increment, ical, ilog 
  *
  */
 function backend_eventcal_dbclean($cm, $cy)
 {
     global $serendipity;
     if (isset($serendipity['eventcaldroptable']) === true) {
         echo '<div class="backend_eventcal_head"><h2>' . PLUGIN_EVENTCAL_ADMIN_ERASE . '</h2></div><br />' . "\n";
     }
     $adminpath = $_SERVER['PHP_SELF'] . '?serendipity[adminModule]=event_display&serendipity[adminAction]=eventcal&serendipity[eventcalcategory]=adevplad';
     $dbclean = !empty($serendipity['GET']['eventcaldbclean']) ? $serendipity['GET']['eventcaldbclean'] : 'start';
     $attention = '<img class="backend_attention" src="' . $serendipity['serendipityHTTPPath'] . 'templates/default/admin/img/admin_msg_note.png" alt="" />';
     echo '<div class="backend_eventcal_dbclean_title"><h4 class="backend_eventcal_inline">' . PLUGIN_EVENTCAL_ADMIN_DBC_TITLE . '</h4> [ <b class="eventcal_reiter eventcal_reiter_dim">' . PLUGIN_EVENTCAL_ADMIN_DBC_TITLE_DESC . '</b> ]</div>' . "\n";
     echo '<div class="backend_eventcal_dbclean_menu">' . "\n";
     echo '  <ul class="backend_eventcal_dbclean_menu">' . "\n";
     echo '    <li class="backend_eventcal_dbclean_menu" ' . (@$serendipity['GET']['eventcaldbclean'] == 'dbdump' ? 'id="active"' : '') . '><a href="' . $adminpath . '&serendipity[eventcaldbclean]=dbdump">' . PLUGIN_EVENTCAL_ADMIN_DBC_DUMP . '</a> <span class="backend_eventcal_right">[ <b class="eventcal_reiter eventcal_reiter_dim">' . PLUGIN_EVENTCAL_ADMIN_DBC_DUMP_DESC . '</b> ]</span></li>' . "\n";
     echo '    <li class="backend_eventcal_dbclean_menu" ' . (@$serendipity['GET']['eventcaldbclean'] == 'dbdownload' ? 'id="active"' : '') . '><a href="' . $adminpath . '&serendipity[eventcaldbclean]=dbdownload">' . PLUGIN_EVENTCAL_ADMIN_DBC_DOWNLOAD . '</a> <span class="backend_eventcal_right">[ <b class="eventcal_reiter eventcal_reiter_dim">' . PLUGIN_EVENTCAL_ADMIN_DBC_DOWNLOAD_DESC . '</b> ]</span></li>' . "\n";
     echo '    <li class="backend_eventcal_dbclean_menu" ' . (@$serendipity['GET']['eventcaldbclean'] == 'dbinsert' ? 'id="active"' : '') . '><a href="' . $adminpath . '&serendipity[eventcaldbclean]=dbinsert">' . PLUGIN_EVENTCAL_ADMIN_DBC_INSERT . '</a> <span class="backend_eventcal_right">[ <b class="eventcal_reiter eventcal_reiter_dim">' . PLUGIN_EVENTCAL_ADMIN_DBC_INSERT_DESC . '</b> ]</span></li>' . "\n";
     echo '    <li class="backend_eventcal_dbclean_menu" ' . (@$serendipity['GET']['eventcaldbclean'] == 'dberase' ? 'id="active"' : '') . '><a href="' . $adminpath . '&serendipity[eventcaldbclean]=dberase">' . PLUGIN_EVENTCAL_ADMIN_DBC_ERASE . '</a> <span class="backend_eventcal_right">[ <b class="eventcal_reiter eventcal_reiter_dim">' . PLUGIN_EVENTCAL_ADMIN_DBC_ERASE_DESC . '</b> ]</span></li>' . "\n";
     echo '    <li class="backend_eventcal_dbclean_menu" ' . (@$serendipity['GET']['eventcaldbclean'] == 'dbdelold' ? 'id="active"' : '') . '><a href="' . $adminpath . '&serendipity[eventcaldbclean]=dbdelold">' . PLUGIN_EVENTCAL_ADMIN_DBC_DELOLD . '</a> <span class="backend_eventcal_right">[ <b class="eventcal_reiter eventcal_reiter_dim">' . PLUGIN_EVENTCAL_ADMIN_DBC_DELOLD_DESC . '</b> ]</span></li>' . "\n";
     echo '    <li class="backend_eventcal_dbclean_menu" ' . (@$serendipity['GET']['eventcaldbclean'] == 'dbincrement' ? 'id="active"' : '') . '><a href="' . $adminpath . '&serendipity[eventcaldbclean]=dbincrement">' . PLUGIN_EVENTCAL_ADMIN_DBC_INCREMENT . '</a> <span class="backend_eventcal_right">[ <b class="eventcal_reiter eventcal_reiter_dim">' . PLUGIN_EVENTCAL_ADMIN_DBC_INCREMENT_DESC . '</b> ]</span></li>' . "\n";
     echo '    <li class="backend_eventcal_dbclean_menu" ' . (@$serendipity['GET']['eventcaldbclean'] == 'dbicalall' ? 'id="active"' : '') . '><a href="' . $adminpath . '&serendipity[eventcaldbclean]=dbicalall">' . PLUGIN_EVENTCAL_ADMIN_DBC_ICALALL . '</a> <span class="backend_eventcal_right">[ <b class="eventcal_reiter eventcal_reiter_dim">' . PLUGIN_EVENTCAL_ADMIN_DBC_ICALALL_DESC . '</b> ]</span></li>' . "\n";
     echo '    <li class="backend_eventcal_dbclean_menu" ' . (@$serendipity['GET']['eventcaldbclean'] == 'dbicallog' ? 'id="active"' : '') . '><a href="' . $adminpath . '&serendipity[eventcaldbclean]=dbicallog">' . PLUGIN_EVENTCAL_ADMIN_DBC_ILOG . '</a> <span class="backend_eventcal_right">[ <b class="eventcal_reiter eventcal_reiter_dim">' . PLUGIN_EVENTCAL_ADMIN_DBC_ILOG_DESC . '</b> ]</span></li>' . "\n";
     echo '  </ul>' . "\n";
     echo '</div>' . "\n";
     if (isset($serendipity['eventcal']['ilogerror']) === true) {
         echo '<div class="backend_eventcal_noresult backend_eventcal_dbclean_error"><h3>' . $attention . PLUGIN_EVENTCAL_ADMIN_LOG_ERROR . '</h3></div>';
     }
     /* check if table exists, so there is nothing to do except some insert stuff SHOW TABLE STATUS LIKE 'tabellenname' SHOW TABLES LIKE 'tabellenname'*/
     if (serendipity_db_query("SHOW TABLES LIKE '{$serendipity['dbPrefix']}eventcal'", true, 'num', false) === false && $dbclean != 'dbinsert' && $dbclean != 'dbicallog') {
         $dbclean = 'dbnixda';
     }
     if (!empty($dbclean)) {
         switch ($dbclean) {
             case 'dbdump':
                 if ($this->backend_eventcal_backup()) {
                     echo '<div class="backend_eventcal_dbclean_innercat"><h3>' . strtoupper(PLUGIN_EVENTCAL_ADMIN_DBC_DUMP_TITLE) . '</h3></div>' . "\n";
                     $url = $_SERVER['HTTP_HOST'] . $adminpath . '&serendipity[eventcaldbclean]=dbdownload&serendipity[eventcalshowdownloads]=dump';
                     if (serendipity_isResponseClean($url)) {
                         header('Location: http://' . $url);
                     }
                 } else {
                     echo $this->backend_eventcal_smsg() . PLUGIN_EVENTCAL_ADMIN_DBC_DUMP_MSG . $this->backend_eventcal_emsg();
                 }
                 return true;
                 break;
             case 'dbdownload':
                 echo '<div class="backend_eventcal_dbclean_innercat"><h3>' . strtoupper(PLUGIN_EVENTCAL_ADMIN_DBC_DUMP_TITLE) . '</h3></div>' . "\n";
                 if (@$serendipity['GET']['eventcalshowdownloads'] == 'dump') {
                     echo '<div class="backend_guestbook_dbclean_error"><h3>' . $attention . PLUGIN_EVENTCAL_ADMIN_DBC_DUMP_DONE . "</h3></div>\n";
                 }
                 if (is_dir('templates_c/eventcal')) {
                     echo "<div class='backend_eventcal_dbclean_innertitle'>templates_c/eventcal/ <b><u>backup files</u></b></div>\n";
                     echo "<div class='backend_eventcal_dbclean_object'>\n";
                     $this->backend_read_backup_dir('templates_c/eventcal/', $adminpath . '&serendipity[eventcaldbclean]=dbdelfile&serendipity[eventcaldbcleanfilename]=');
                     echo "</div>\n";
                 } else {
                     echo '<div class="backend_eventcal_dbclean_error"><h3>' . $attention . PLUGIN_EVENTCAL_ADMIN_DBC_DOWNLOAD_MSG . "</h3></div>\n";
                 }
                 return true;
                 break;
             case 'dbinsert':
                 echo '<div class="backend_eventcal_dbclean_innercat"><h3>' . strtoupper(PLUGIN_EVENTCAL_ADMIN_DBC_INSERT_TITLE) . '</h3></div>' . "\n";
                 echo $this->backend_eventcal_smsg() . PLUGIN_EVENTCAL_ADMIN_DBC_INSERT_MSG . $this->backend_eventcal_emsg();
                 return true;
                 break;
             case 'dberase':
                 echo '<div class="backend_eventcal_dbclean_innercat"><h3>' . strtoupper(PLUGIN_EVENTCAL_ADMIN_DBC_ERASE_TITLE) . '</h3></div>';
                 #$this->uninstall(); // ok, questionaire
                 $isTable = $this->uninstall() ? true : false;
                 // ok, questionaire
                 // give back ok
                 if (isset($serendipity['eventcaldroptable']) === true && $isTable) {
                     echo '<div class="serendipity_center eventcal_tpl_message">' . "\n";
                     echo '    <div class="serendipity_center serendipity_msg_notice">' . "\n";
                     echo '        <div class="eventcal_tpl_message_inner">' . "\n";
                     echo sprintf(PLUGIN_EVENTCAL_ADMIN_DROP_OK, $serendipity['dbPrefix'] . 'eventcal');
                     echo '        </div>' . "\n";
                     echo '    </div>' . "\n";
                     echo '</div>' . "\n";
                 }
                 return true;
                 break;
             case 'dbdelold':
                 echo '<div class="backend_eventcal_dbclean_innercat"><h3>' . strtoupper(PLUGIN_EVENTCAL_ADMIN_DBC_DELOLD_TITLE) . '</h3></div>';
                 if ($serendipity['eventcalfreetable'] === false) {
                     echo $this->backend_eventcal_questionaire(PLUGIN_EVENTCAL_ADMIN_FREE_SURE, $adminpath, '', '&serendipity[eventcaldbclean]=dbdelold&serendipity[eventcaldbcleanfreeold]=1');
                 } else {
                     $dnum = $this->backend_eventcal_free_record();
                     // give back ok else noresult
                     if ($dnum) {
                         echo '<div class="serendipity_center eventcal_tpl_message">' . "\n";
                         echo '    <div class="serendipity_center serendipity_msg_notice">' . "\n";
                         echo '        <div class="eventcal_tpl_message_inner">' . "\n";
                         echo sprintf(PLUGIN_EVENTCAL_ADMIN_DBC_DELOLD_MSG, $dnum);
                         echo '        </div>' . "\n";
                         echo '    </div>' . "\n";
                         echo '</div>' . "\n";
                     } else {
                         echo '<div class="backend_eventcal_dbclean_error"><h3>' . $attention . sprintf(PLUGIN_EVENTCAL_ADMIN_NORESULT, PLUGIN_EVENTCAL_ADMIN_NORESULT_FREE) . '</h3></div>';
                     }
                 }
                 return true;
                 break;
             case 'dbincrement':
                 echo '<div class="backend_eventcal_dbclean_innercat"><h3>' . strtoupper(PLUGIN_EVENTCAL_ADMIN_DBC_INCREMENT_TITLE) . '</h3></div>';
                 if ($serendipity['eventcalinctable'] === false) {
                     echo $this->backend_eventcal_questionaire(PLUGIN_EVENTCAL_ADMIN_CLEAN_SURE . '<br />' . PLUGIN_EVENTCAL_ADMIN_CLEAN_SURE_ADD, $adminpath, '', '&serendipity[eventcaldbclean]=dbincrement&serendipity[eventcaldbcleanfreeinc]=1');
                 } else {
                     $srec = $this->backend_eventcal_free_record();
                     // give back ok else noresult
                     if ($srec) {
                         echo '<div class="serendipity_center eventcal_tpl_message">' . "\n";
                         echo '    <div class="serendipity_center serendipity_msg_notice">' . "\n";
                         echo '        <div class="eventcal_tpl_message_inner">' . "\n";
                         echo sprintf(PLUGIN_EVENTCAL_ADMIN_DBC_INCREMENT_MSG, $srec);
                         echo '        </div>' . "\n";
                         echo '    </div>' . "\n";
                         echo '</div>' . "\n";
                     } else {
                         echo '<div class="backend_eventcal_dbclean_error"><h3>' . $attention . sprintf(PLUGIN_EVENTCAL_ADMIN_NORESULT, PLUGIN_EVENTCAL_ADMIN_NORESULT_FREE) . '</h3></div>';
                     }
                 }
                 return true;
                 break;
             case 'dbicalall':
                 echo '<div class="backend_eventcal_dbclean_innercat"><h3>' . strtoupper(PLUGIN_EVENTCAL_ADMIN_DBC_ICALALL_TITLE) . '</h3></div>';
                 /* return of mailfunction and external_plugin hook send iCal via email */
                 if (isset($serendipity['GET']['mailData'])) {
                     if ($serendipity['GET']['mailData'] == 1) {
                         echo $this->backend_eventcal_smsg() . PLUGIN_EVENTCAL_SENDMAIL_BLAHBLAH . $this->backend_eventcal_emsg();
                     } else {
                         echo $this->backend_eventcal_smsg() . PLUGIN_EVENTCAL_SENDMAIL_ERROR . ' ' . CAL_EVENT_PLEASECORRECT . $this->backend_eventcal_emsg();
                     }
                 }
                 // create external plugin does and donts
                 if (!isset($serendipity['GET']['mailData'])) {
                     if ($this->get_config('log_email')) {
                         //we use $serendipity['serendipityHTTPPath'] like /http_root better than $serendipity['baseURL'] like http://hostname/... while this gets done somewhere else and depends on differences where to sent
                         $url = $serendipity['serendipityHTTPPath'] . ($serendipity['rewrite'] == 'none' ? $serendipity['indexFile'] . '?/' : '') . 'plugin/ics_export/0/0/0/ml/' . $this->get_config('log_email') . '/all';
                         echo $this->backend_eventcal_smsg() . PLUGIN_EVENTCAL_ADMIN_ICAL_EMAILLINK . '<br /><br /><a href="' . $url . '"><input type="button" class="serendipityPrettyButton" name="ical email" value=" ' . CAL_EVENT_FORM_BUTTON_SUBMIT . ' " /></a>' . $this->backend_eventcal_emsg();
                     } else {
                         $url = $serendipity['serendipityHTTPPath'] . ($serendipity['rewrite'] == 'none' ? $serendipity['indexFile'] . '?/' : '') . 'plugin/ics_export/0/0/0/dl/none/all';
                         echo $this->backend_eventcal_smsg();
                         echo '<form name="checkform" method="post" action="' . $this->fetchPluginUri() . '">';
                         echo '<input type="hidden" name="calendar[icseptarget]" value="' . $url . '" />';
                         echo PLUGIN_EVENTCAL_ADMIN_ICAL_DOWNLINK . '<br /><br /><input type="submit" class="serendipityPrettyButton" name="ical download" value=" ' . CAL_EVENT_FORM_BUTTON_SUBMIT . ' " />';
                         echo '</form>';
                         echo $this->backend_eventcal_emsg();
                     }
                 }
                 return true;
                 break;
             case 'dbicallog':
                 echo '<div class="backend_eventcal_dbclean_innercat"><h3>' . strtoupper(PLUGIN_EVENTCAL_ADMIN_DBC_ILOG_TITLE) . '</h3></div>';
                 if (file_exists('templates_c/eventcal/ical.log')) {
                     echo '<div class="backend_eventcal_dbclean_innertitle">ical.log - ' . date('Y-m-d H:i:s') . '</div>';
                     echo '<div class="backend_eventcal_dbclean_object">';
                     $this->backend_eventcal_highlight_num('templates_c/eventcal/ical.log');
                     echo '</div>';
                 } else {
                     echo '<div class="backend_eventcal_dbclean_error"><h3>' . $attention . PLUGIN_EVENTCAL_ADMIN_DBC_ILOG_MSG . '</h3></div>';
                 }
                 return true;
                 break;
             case 'dbdelfile':
                 $delfile = false;
                 if (isset($serendipity['GET']['eventcaldbcleanfilename'])) {
                     $old = getcwd();
                     // Save the current directory
                     chdir('templates_c/eventcal/');
                     if (is_file($serendipity['GET']['eventcaldbcleanfilename'])) {
                         unlink($serendipity['GET']['eventcaldbcleanfilename']);
                     }
                     chdir($old);
                     // Restore the old working directory
                     echo '<div class="backend_eventcal_dbclean_error"><h3>' . $attention . sprintf(PLUGIN_EVENTCAL_ADMIN_DBC_DELFILE_MSG, $serendipity['GET']['eventcaldbcleanfilename']) . '!</h3></div>';
                 }
                 return true;
                 break;
             case 'dbnixda':
                 echo '<div class="backend_eventcal_dbclean_innercat"><h3>' . strtoupper(PLUGIN_EVENTCAL_ADMIN_DBC_NIXDA_TITLE) . '</h3></div>';
                 echo '<div class="backend_eventcal_dbclean_error"><h3>' . $attention . PLUGIN_EVENTCAL_ADMIN_DBC_NIXDA_DESC . '!</h3></div>';
                 return true;
                 break;
             default:
                 return false;
                 break;
         }
     }
 }