Esempio n. 1
0
 public function __construct($mode = 'javascript', $page_url, $page_title = '')
 {
     $this->mode = $mode;
     // Instantiate and start statistics
     $this->statistics = new Statistics($mode);
     $this->statistics->executionStart();
     // Instantiate settings class
     $this->settings = new Settings();
     // Instantiate general setup class
     $this->setup = new Setup($mode, $page_url, $page_title);
     // Instantiate cookies class
     $this->cookies = new Cookies($this->settings->domain, $this->settings->cookieExpiration, $this->settings->secureCookies);
     // Instantiate locales class
     $this->locales = new Locales($this->settings->language);
     // Instantiate class for reading comments
     $this->readComments = new ReadComments($this->setup);
     // Check if a comment was sent via HTTP POST request
     if (isset($_POST['comment'])) {
         // Instantiate class for writing and editing comments
         $write_comments = new WriteComments($this->readComments, $this->locales, $this->cookies);
         // Execute an action (write/edit/login/etc)
         $write_comments->getAction();
     }
     // Instantiate comment parser class
     $this->commentParser = new CommentParser($this->setup, $this->locales->locale);
     // Decide if comment count is pluralized
     $prime_plural = $this->readComments->primaryCount !== 2 ? 1 : 0;
     // Format comment count; Include "Showing" in non-API usages
     $locale_key = $mode === 'api' ? 'count_link' : 'showing_comments';
     $showing_comments = $this->locales->locale[$locale_key][$prime_plural];
     // Whether to show reply count separately
     if ($this->settings->showsReplyCount === true) {
         // If so, inject top level comment count into count locale string
         $this->commentCount = str_replace('_NUM_', $this->readComments->primaryCount - 1, $showing_comments);
         // Check if there are any replies
         if ($this->readComments->totalCount !== $this->readComments->primaryCount) {
             $reply_plural = $this->readComments->totalCount - $this->readComments->primaryCount !== 1 ? 1 : 0;
             $reply_locale = $this->locales->locale['count_replies'][$reply_plural];
             $reply_count = str_replace('_NUM_', $this->readComments->totalCount - 1, $reply_locale);
             // Append reply count
             $this->commentCount .= ' (' . $reply_count . ')';
         }
     } else {
         // If not, inject total comment count into count locale string
         $this->commentCount = str_replace('_NUM_', $this->readComments->totalCount - 1, $showing_comments);
     }
 }
    if (!@(include './' . $classname . '.php')) {
        echo '(document.getElementById (\'hashover\') || document.body).innerHTML += \'' . $error . '\';';
        exit;
    }
});
// Mode is based on whether request is AJAX
$mode = isset($_POST['ajax']) ? 'javascript' : 'php';
$data = null;
// Instantiate HashOver class
$hashover = new HashOver($mode);
$hashover->setup->setPageURL('request');
$hashover->setup->setPageTitle('request');
$hashover->initiate();
$hashover->finalize();
// Instantiate class for writing and editing comments
$write_comments = new WriteComments($hashover->readComments, $hashover->locales, $hashover->cookies, $hashover->login, $hashover->misc);
// Various POST data actions
$post_actions = array('login', 'logout', 'post', 'edit', 'delete');
// Execute an action (write/edit/login/etc)
foreach ($post_actions as $action) {
    if (empty($_POST[$action])) {
        continue;
    }
    switch ($action) {
        case 'login':
            if ($hashover->setup->allowsLogin !== true) {
                $write_comments->postComment();
                break;
            }
            $write_comments->login();
            break;