Ejemplo n.º 1
0
<?php

/*
 * @CODOLICENSE
 */
defined('IN_CODOF') or die;
dispatch_post('sso/authorize', function () {
    //CSRF protection
    if (\CODOF\Access\Request::valid($_POST['token'])) {
        //$id = $_POST['uid'];
        $user = $_POST['sso'];
        $posted_token = $user['token'];
        $secret = CODOF\Util::get_opt('sso_secret');
        if (!empty($user)) {
            unset($user['token']);
            $sso_token = md5(urlencode(json_encode($user)) . $secret . $_POST['timestamp']);
        }
        $username = $user['name'];
        $mail = $user['mail'];
        if ($sso_token != $posted_token) {
            echo 'error';
            exit;
        }
        $db = DB::getPDO();
        if (!CODOF\User\User::mailExists($mail)) {
            //this user does not have an account in codoforum
            $reg = new \CODOF\User\Register($db);
            if (\CODOF\User\User::usernameExists($username)) {
                $username .= time();
            }
            $reg->username = $username;
Ejemplo n.º 2
0
    $forum = new \Controller\forum();
    $forum->manage_topic();
    CODOF\Smarty\Layout::load($forum->view, $forum->css_files, $forum->js_files);
});
dispatch_get('/tags/:tag/:page', function ($tag, $page = 1) {
    if (!isset($tag)) {
        return \CODOF\Smarty\Layout::not_found();
    }
    CODOF\Store::set('meta:robots', 'noindex, follow');
    $clean_tag = strip_tags($tag);
    $forum = new Controller\forum();
    $forum->listTaggedTopics($clean_tag, $page);
    CODOF\Smarty\Layout::load($forum->view, $forum->css_files, $forum->js_files);
});
//-------------INDEX------------------------------------------------------------
dispatch_get('/', function () {
    global $installed;
    if (!$installed) {
        $url = str_replace("index.php?u=/", "", RURI);
        header("Location: " . $url . "install/index.php");
    }
    $forum = new \Controller\forum();
    $forum->topics(1);
    CODOF\Smarty\Layout::load($forum->view, $forum->css_files, $forum->js_files);
});
function not_found($errno, $errstr, $errfile = null, $errline = null)
{
    CODOF\Smarty\Layout::not_found();
}
Request::start();