. // Check if request is for JSONP if (isset ($_GET['jsonp'])) { // If so, setup HashOver for JavaScript require ('javascript-setup.php'); $mode = 'javascript'; $postget = $_GET; } else { // If not, setup HashOver for JSON require ('json-setup.php'); $mode = 'json'; $postget = $_POST; } try { // Instantiate HashOver class $hashover = new \HashOver ($mode); $hashover->setup->setPageURL ('request'); $hashover->setup->setPageTitle ('request'); $hashover->setup->setThreadName ('request'); $hashover->initiate (); $hashover->finalize (); // Instantiate class for writing and editing comments $write_comments = new WriteComments ( $hashover->setup, $hashover->thread ); // 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 ($postget[$action])) { continue; } switch ($action) { case 'login': { $write_comments->login (); break; } case 'logout': { $write_comments->logout (); break; } case 'post': { $data = $write_comments->postComment (); $hashover->defaultMetadata (); break; } case 'edit': { $data = $write_comments->editComment (); break; } case 'delete': { $write_comments->deleteComment (); break; } } break; } // Returns comment being saved as JSON if (isset ($postget['ajax']) and isset ($data) and is_array ($data)) { // Slit file into parts $file = $data['file']; $key_parts = explode ('-', $file); // Parsed comment data $comment = $data['comment']; $parsed = $hashover->commentParser->parse ($comment, $file, $key_parts); // Return JSON or JSONP function call echo $hashover->misc->jsonData (array ( 'comment' => $parsed, 'count' => $hashover->getCommentCount () )); } } catch (\Exception $error) { $misc = new Misc ($mode); $message = $error->getMessage (); $misc->displayError ($message); }