TM (Geektimes / Megamozg) parser with open comment system.
  @Author: SalatProduction (c)
  @Date: 26.06.2015
  @Version: 1.2
  @Email: megaphpdestroyer@gmail.ru
 */

if (!isset($_SERVER['HTTP_X_REQUESTED_WITH']) && empty($_SERVER['HTTP_X_REQUESTED_WITH']) && strtolower($_SERVER['HTTP_X_REQUESTED_WITH']) !== 'xmlhttprequest') die(header('Location: /404'));

define('_EXEC', true);

require_once($_SERVER['DOCUMENT_ROOT'] . '/config.php');
require_once($_SERVER['DOCUMENT_ROOT'] . '/inc/autoload.class.php');

application::getApplication();
application::Import(['mysql', 'model', 'htmldom']);

if (!empty($_POST['loadComments'])) {
    LoadOrigComments($_POST['loadComments']);
}

if (!empty($_POST['button'])) {
    switch ($_POST['button']) {
        case 'search' :
            SearchQuery($_POST['searchQuery']);
    }
}

//Load commnets from original post (AJAX)
function LoadOrigComments($post) {
    $html = file_get_html('http://'.config::$host['service'].'.ru/post/' . $post);