$opposite_key = $action === 'like' ? 'dislikes' : 'likes'; $opposite_set = $action === 'like' ? 'disliked' : 'liked'; if ($_COOKIE[$like_cookie] === $set) { $hashover->cookies->expireCookie($like_cookie); like_decrease($key, $comment[$key]); } if ($_COOKIE[$like_cookie] === $opposite_set) { set_like($hashover, $like_cookie, $set, $comment[$key]); like_decrease($opposite_key, $comment[$opposite_key]); } } } // Function for liking a comment if (!empty($_POST['url']) and !empty($_POST['thread']) and !empty($_POST['like']) and !empty($_POST['action'])) { // Instanciate HashOver class $hashover = new HashOver('api'); $hashover->setup->setPageURL($_POST['url']); $hashover->initiate(); $storageMode =& $hashover->readComments->data->storageMode; $file = str_replace('../', '', $_POST['like']); // Exit with error is file doesn't exist if ($storageMode === 'flat-file') { $file = $_POST['thread'] . '/' . $file; $file = '../pages/' . $file . '.' . $hashover->setup->dataFormat; if (!file_exists($file)) { exit('<b>HashOver</b>: File: "' . $file . '" non-existent!'); } } // Read comment $comment = $hashover->readComments->data->read($file, true); // Exit with error if failed to read comment
// Enable display of PHP errors ini_set('display_errors', true); error_reporting(E_ALL); // Tell browser this is XML/RSS header('Content-Type: application/xml; charset=utf-8'); // Autoload class files spl_autoload_register(function ($classname) { $classname = strtolower($classname); $error = '"' . $classname . '.php" file could not be included!'; if (!@(include '../scripts/' . $classname . '.php')) { echo '(document.getElementById (\'hashover\') || document.body).innerHTML += \'' . $error . '\';'; exit; } }); // Instantiate HashOver class $hashover = new HashOver('api'); $hashover->setup->setPageURL('request'); $hashover->initiate(); $hashover->parsePrimary(); // Create new DOM document. $xml = new DOMDocument('1.0', 'UTF-8'); $xml->preserveWhiteSpace = false; $xml->formatOutput = true; // Create main RSS element $rss = $xml->createElement('rss'); $rss->setAttribute('version', '2.0'); $rss->setAttribute('xmlns:dc', 'http://purl.org/dc/elements/1.1/'); $rss->setAttribute('xmlns:content', 'http://purl.org/rss/1.0/modules/content/'); $rss->setAttribute('xmlns:atom', 'http://www.w3.org/2005/Atom'); // Display error if the API is disabled if ($hashover->setup->APIStatus('rss') === 'disabled') {
if (!empty($_POST['title'])) { $page_title = $_POST['title']; } else { // Error on failure exit('document.getElementById (\'hashover\').innerHTML = \'<b>HashOver</b>: Failed to obtain page title.\';'); } } // Autoload class files spl_autoload_register(function ($classname) { $classname = strtolower($classname); if (!@(include './' . $classname . '.php')) { exit('<b>HashOver</b>: "' . $classname . '.php" file could not be included!'); } }); // Instantiate HashOver class $hashover = new HashOver('javascript', $page_url, $page_title); $hashover->parseAll(); // Start output buffer ob_start(); // Attempt to include JavaScript frontend code if (!(include './javascript-mode.php')) { ob_end_clean(); exit('document.getElementById (\'hashover\').innerHTML = \'<b>HashOver - Error:</b> file "javascript-mode.php" could not be included!\';'); } // Get output buffer contents and turn off output buffering $javascript = ob_get_contents(); ob_end_clean(); // Minify JavaScript if enabled, and non-minified version isn't requested if ($hashover->settings->minifiesJavaScript === true) { if (!isset($_GET['hashover-unminified'])) { $jsminifier = new JSMinifier();
header('Cache-Control: post-check=0, pre-check=0', false); header('Pragma: no-cache'); // Autoload class files spl_autoload_register(function ($classname) { $classname = strtolower($classname); $error = '"' . $classname . '.php" file could not be included!'; 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':
// Use UTF-8 character set ini_set('default_charset', 'UTF-8'); // Enable display of PHP errors ini_set('display_errors', true); error_reporting(E_ALL); // Tell browser this is XML/RSS header('Content-Type: application/xml; charset=utf-8'); // Autoload class files spl_autoload_register(function ($classname) { $classname = strtolower($classname); if (!@(include '../scripts/' . $classname . '.php')) { exit('<b>HashOver</b>: "' . $classname . '.php" file could not be included!'); } }); // Instantiate HashOver class $hashover = new HashOver('api', !empty($_GET['url']) ? $_GET['url'] : ''); $hashover->parseAll(); // Create new DOM document. $xml = new DOMDocument('1.0', 'UTF-8'); $xml->preserveWhiteSpace = false; $xml->formatOutput = true; // Create main RSS element $rss = $xml->createElement('rss'); $rss->setAttribute('version', '2.0'); $rss->setAttribute('xmlns:dc', 'http://purl.org/dc/elements/1.1/'); $rss->setAttribute('xmlns:content', 'http://purl.org/rss/1.0/modules/content/'); $rss->setAttribute('xmlns:atom', 'http://www.w3.org/2005/Atom'); // Display error if the API is disabled if ($hashover->setup->APIStatus('rss') === 'disabled') { $title = $xml->createElement('title'); $title_value = $xml->createTextNode('HashOver: RSS API is not enabled.');
header('Expires: Wed, 08 May 1991 12:00:00 GMT'); header('Last-Modified: ' . gmdate('D, d M Y H:i:s') . ' GMT'); header('Cache-Control: no-store, no-cache, must-revalidate'); header('Cache-Control: post-check=0, pre-check=0', false); header('Pragma: no-cache'); // Autoload class files spl_autoload_register(function ($classname) { $classname = strtolower($classname); $error = '"' . $classname . '.php" file could not be included!'; if (!@(include './' . $classname . '.php')) { echo '(document.getElementById (\'hashover\') || document.body).innerHTML += \'' . $error . '\';'; exit; } }); // Instantiate HashOver class $hashover = new HashOver('javascript'); $hashover->setup->setPageURL('request'); $hashover->setup->setPageTitle('request'); $hashover->initiate(); $hashover->parsePrimary($hashover->setup->collapsesComments); $hashover->parsePopular(); $hashover->finalize(); // Start output buffer ob_start(); // Attempt to include JavaScript frontend code if (!(include './javascript-mode.php')) { ob_end_clean(); exit('document.getElementById (\'hashover\').innerHTML = \'<b>HashOver - Error:</b> file "javascript-mode.php" could not be included!\';'); } // Get output buffer contents and turn off output buffering $javascript = ob_get_contents();
header('Expires: Wed, 08 May 1991 12:00:00 GMT'); header('Last-Modified: ' . gmdate('D, d M Y H:i:s') . ' GMT'); header('Cache-Control: no-store, no-cache, must-revalidate'); header('Cache-Control: post-check=0, pre-check=0', false); header('Pragma: no-cache'); // Autoload class files spl_autoload_register(function ($classname) { $classname = strtolower($classname); $error = '"' . $classname . '.php" file could not be included!'; if (!@(include '../scripts/' . $classname . '.php')) { echo '(document.getElementById (\'hashover\') || document.body).innerHTML += \'' . $error . '\';'; exit; } }); // Instantiate HashOver class $hashover = new HashOver('api'); $hashover->statistics->mode = 'javascript'; $hashover->setup->setPageURL('request'); $hashover->initiate(); // Display error if the API is disabled if ($hashover->setup->APIStatus('latest') === 'disabled') { $error = 'This API is not enabled.'; echo '(document.getElementById (\'hashover\') || document.body).innerHTML += \'' . $error . '\';'; exit; } $latest = array(); $comments = array(); $output_key = 0; if (!empty($_GET['global']) and $_GET['global'] === 'yes') { $file = './pages/'; $metadata = json_decode(file_get_contents($file . '.metadata'), true);
header('Expires: Wed, 08 May 1991 12:00:00 GMT'); header('Last-Modified: ' . gmdate('D, d M Y H:i:s') . ' GMT'); header('Cache-Control: no-store, no-cache, must-revalidate'); header('Cache-Control: post-check=0, pre-check=0', false); header('Pragma: no-cache'); // Autoload class files spl_autoload_register(function ($classname) { $classname = strtolower($classname); $error = '"' . $classname . '.php" file could not be included!'; if (!@(include '../scripts/' . $classname . '.php')) { echo '(document.getElementById (\'hashover\') || document.body).innerHTML += \'' . $error . '\';'; exit; } }); // Instantiate HashOver class $hashover = new HashOver('api'); // Display error if the API is disabled if (!isset($_POST['ajax']) and $hashover->setup->APIStatus('json') === 'disabled') { exit(json_encode(array('error' => '<b>HashOver</b>: This API is not enabled.'))); } // Configure HashOver and load comments $hashover->setup->setPageURL('request'); $hashover->initiate(); // Setup where to start reading comments $start = !empty($_POST['start']) ? $_POST['start'] : 0; // Check for comments if ($hashover->readComments->totalCount > 1) { // Parse primary comments // TODO: Use starting point $hashover->parsePrimary(false, 0); // Display as JSON data