<?php

/*
 * @CODOLICENSE
 */
$smarty = \CODOF\Smarty\Single::get_instance();
$db = \DB::getPDO();
\CODOF\Util::get_config($db);
define('CODOF_VERSION', str_replace(".php", "", \CODOF\Util::get_opt('version')));
class upgrader
{
    public static $latest_version = "1.0";
    public static $base_url = "https://codoforum.com/";
    static function is_required()
    {
        if (version_compare(CODOF_VERSION, upgrader::$latest_version) == -1) {
            return true;
        }
        return false;
    }
    static function check_writable()
    {
        $paths = array("index.php", "admin/index.php", "admin", "sys", "sys/CODOF/Util.php", "sites");
        foreach ($paths as $path) {
            if (!is_writable(ABSPATH . $path)) {
                echo "#> Error-Path not writable: " . ABSPATH . $path . "<br>\n";
                return false;
            }
            echo "3.1> Files seem writable :) <br>";
            return true;
        }
/*
 * @CODOLICENSE
 */
//Limonade -> 230 ms
//display & routing
if (get_magic_quotes_gpc()) {
    $gpc = array(&$_GET, &$_POST, &$_COOKIE, &$_REQUEST);
    array_walk_recursive($gpc, function (&$value) {
        $value = stripslashes($value);
    });
}
use CODOF\Util;
use CODOF\Access\Request;
$db = \DB::getPDO();
Util::get_config($db);
\Constants::post_boot('themes/' . Util::get_opt('theme') . "/");
CODOF\Smarty\Single::get_instance();
//-------------------------server static files --------------------------------
dispatch_get('Ajax/history/posts', function () {
    if (Request::valid($_GET['_token'])) {
        $post = new \CODOF\Forum\Post();
        $post->getHistory($_GET['pid']);
    }
});
dispatch_get('Ajax/reputation/:pid/up', function ($pid) {
    if (Request::valid($_GET['_token'])) {
        $rep = new \CODOF\Forum\Reputation();
        $rep->up($pid);
    }
});