Example #1
0
<?php

ob_start('ob_gzhandler');
require_once $_SERVER['DOCUMENT_ROOT'] . '/class/autoload.php';
$user = new NERDZ\Core\User();
$tplcfg = $user->getTemplateCfg();
ob_start(array('NERDZ\\Core\\Utils', 'minifyHTML'));
?>
    <!DOCTYPE html>
    <html lang="<?php 
echo $user->getBoardLanguage();
?>
">
    <head>
    <meta name="description" content="NERDZ is a mix between a social network and a forum. You can share your code, enjoy information technology, talk about nerd stuff and more. Join in!" />
    <title><?php 
echo NERDZ\Core\Utils::getSiteName(), ' - ', $user->lang('TERMS');
?>
</title>
<?php 
$headers = $tplcfg->getTemplateVars('terms');
require_once $_SERVER['DOCUMENT_ROOT'] . '/pages/common/jscssheaders.php';
?>
    </head>
    <?php 
ob_flush();
?>
<body>
    <div id="body">
<?php 
require_once $_SERVER['DOCUMENT_ROOT'] . '/pages/header.php';
Example #2
0
<?php

ob_start('ob_gzhandler');
require_once $_SERVER['DOCUMENT_ROOT'] . '/class/autoload.php';
$user = new NERDZ\Core\User();
$tplcfg = $user->getTemplateCfg();
ob_start(array('NERDZ\\Core\\Utils', 'minifyHTML'));
?>
<!DOCTYPE html>
<html lang="<?php 
echo $user->getBoardLanguage();
?>
">
    <head>
        <meta name="author" content="Paolo Galeone" />
        <meta name="keywords" content="nerdz, social network, user profile, paste, source code, programming" />
        <meta name="description" content="NERDZ is a mix between a social network and a forum. You can share your code, enjoy information technology, talk about nerd stuff and more. Join in!" />
        <meta name="robots" content="index,follow" />
        <title><?php 
echo NERDZ\Core\Utils::getSiteName();
?>
 - BBCode</title>
<?php 
$headers = $tplcfg->getTemplateVars('bbcode');
require_once $_SERVER['DOCUMENT_ROOT'] . '/pages/common/jscssheaders.php';
ob_flush();
?>
    </head>
<body>
    <div id="body">
<?php 
Example #3
0
<?php

//Variables avaiable in every page present in the root of nerdz (/home.php, /profile.php and so on)
if (!isset($user)) {
    die('$user required');
}
// use function to create variable scope and avoid conflicts
$func = function () use($user) {
    $commonvars = [];
    $commonvars['tok_n'] = NERDZ\Core\Security::getCsrfToken();
    $commonvars['myusername_n'] = NERDZ\Core\User::getUsername();
    $commonvars['myusername4link_n'] = \NERDZ\Core\Utils::userLink($commonvars['myusername_n']);
    $langKey = 'lang' . NERDZ\Core\Config\SITE_HOST;
    if (!($commonvars['langs_a'] = NERDZ\Core\Utils::apc_get($langKey))) {
        $commonvars['langs_a'] = NERDZ\Core\Utils::apc_set($langKey, function () {
            $ret = [];
            $i = 0;
            $longlangs = NERDZ\Core\System::getAvailableLanguages(1);
            foreach ($longlangs as $id => $val) {
                $ret[$i]['longlang_n'] = $val;
                $ret[$i]['shortlang_n'] = $id;
                ++$i;
            }
            return $ret;
        }, 3600);
    }
    $commonvars['mylang_n'] = $user->getLanguage();
    $commonvars['flagdir_n'] = NERDZ\Core\System::getResourceDomain() . '/static/images/flags/';
    $banners = (new NERDZ\Core\Banners())->getBanners();
    $commonvars['banners_a'] = [];
    shuffle($banners);
Example #4
0
<?php

$vals = [];
$vals['logged_b'] = $user->isLogged();
if ($vals['logged_b']) {
    $vals['myusername_n'] = NERDZ\Core\User::getUsername();
    $vals['myusername4link_n'] = \NERDZ\Core\Utils::userLink($vals['myusername_n']);
}
$vals['tok_n'] = NERDZ\Core\Security::getCsrfToken();
$user->getTPL()->assign($vals);
$user->getTPL()->draw('base/header');
Example #5
0
<?php

ob_start('ob_gzhandler');
require_once $_SERVER['DOCUMENT_ROOT'] . '/class/autoload.php';
$user = new NERDZ\Core\User();
$tplcfg = $user->getTemplateCfg();
if (!$user->isLogged()) {
    die(header('Location: index.php'));
}
ob_start(array('NERDZ\\Core\\Utils', 'minifyHTML'));
?>
    <!DOCTYPE html>
    <html lang="<?php 
echo $user->getBoardLanguage();
?>
">
    <head>
    <meta name="author" content="Paolo Galeone" />
    <meta name="description" content="NERDZ is a mix between a social network and a forum. You can share your code, enjoy information technology, talk about nerd stuff and more. Join in!" />
    <title><?php 
echo NERDZ\Core\Utils::getSiteName();
?>
 - PM</title>
<?php 
$headers = $tplcfg->getTemplateVars('pm');
require_once $_SERVER['DOCUMENT_ROOT'] . '/pages/common/jscssheaders.php';
?>
    </head>
    <?php 
ob_flush();
?>
Example #6
0
<?php

ob_start('ob_gzhandler');
require_once $_SERVER['DOCUMENT_ROOT'] . '/class/autoload.php';
use NERDZ\Core\Db;
$user = new NERDZ\Core\User();
if (!$user->isLogged()) {
    die(NERDZ\Core\Utils::jsonResponse('error', $user->lang('REGISTER')));
}
$viewonline = empty($_SESSION['mark_offline']) ? '1' : '0';
if (Db::NO_ERRNO != Db::query(array('UPDATE "users" SET "last" = NOW(), "viewonline" = :on WHERE "counter" = :id', array(':on' => $viewonline, ':id' => $_SESSION['id'])), Db::FETCH_ERRNO)) {
    die(NERDZ\Core\Utils::jsonResponse('error', 'Time'));
}
if (!($o = Db::query(array('SELECT "remote_addr","http_user_agent" FROM "users" WHERE "counter" = :id', array(':id' => $_SESSION['id'])), Db::FETCH_OBJ))) {
    die(NERDZ\Core\Utils::jsonResponse('error', $user->lang('ERROR')));
}
if (empty($o->remote_addr) || empty($_SESSION['remote_addr']) || $o->remote_addr != $_SERVER['REMOTE_ADDR']) {
    if (Db::NO_ERRNO != Db::query(array('UPDATE "users" SET "remote_addr" = :addr WHERE "counter" = :id', array(':addr' => $_SERVER['REMOTE_ADDR'], ':id' => $_SESSION['id'])), Db::FETCH_ERRNO)) {
        die(NERDZ\Core\Utils::jsonResponse('error', 'IP'));
    }
    $_SESSION['remote_addr'] = $_SERVER['REMOTE_ADDR'];
}
if (empty($o->http_user_agent) || empty($_SESSION['http_user_agent']) || $o->http_user_agent != $_SERVER['HTTP_USER_AGENT']) {
    if (Db::NO_ERRNO != Db::query(array('UPDATE "users" SET "http_user_agent" = :uag WHERE "counter" = :id', array(':uag' => htmlspecialchars($_SERVER['HTTP_USER_AGENT'], ENT_QUOTES, 'UTF-8'), ':id' => $_SESSION['id'])), Db::FETCH_ERRNO)) {
        die(NERDZ\Core\Utils::jsonResponse('error', 'UA'));
    }
    $_SESSION['http_user_agent'] = $_SERVER['HTTP_USER_AGENT'];
}
die(NERDZ\Core\Utils::jsonResponse('ok', 'OK'));
Example #7
0
<?php

ob_start('ob_gzhandler');
require_once $_SERVER['DOCUMENT_ROOT'] . '/class/autoload.php';
$user = new NERDZ\Core\User();
ob_start(array('NERDZ\\Core\\Utils', 'minifyHTML'));
if (!$user->isLogged()) {
    die($user->lang('REGISTER'));
}
$user->getTPL()->draw('preferences/delete');
Example #8
0
<?php

ob_start('ob_gzhandler');
require_once $_SERVER['DOCUMENT_ROOT'] . '/class/autoload.php';
$user = new NERDZ\Core\User();
if (!$user->isLogged()) {
    die(NERDZ\Core\Utils::jsonResponse('error', $user->lang('REGISTER')));
}
if (!NERDZ\Core\Security::refererControl()) {
    die(NERDZ\Core\Utils::jsonResponse('error', $user->lang('ERROR')));
}
if (!NERDZ\Core\Security::csrfControl(isset($_POST['tok']) ? $_POST['tok'] : 0)) {
    die(NERDZ\Core\Utils::jsonResponse('error', $user->lang('ERROR') . ': token'));
}
$user->logout();
die(NERDZ\Core\Utils::jsonResponse('ok', $user->lang('LOGOUT_OK')));
Example #9
0
<?php

require_once $_SERVER['DOCUMENT_ROOT'] . '/class/autoload.php';
$user = new NERDZ\Core\User();
if (!($logged = $user->isLogged())) {
    die($user->lang('REGISTER'));
}
$prj = isset($_GET['action']) && $_GET['action'] == 'project';
$truncate = true;
$path = 'home';
require $_SERVER['DOCUMENT_ROOT'] . '/pages/common/postlist.html.php';
Example #10
0
<?php

ob_start('ob_gzhandler');
require_once $_SERVER['DOCUMENT_ROOT'] . '/class/autoload.php';
use NERDZ\Core\Db;
$user = new NERDZ\Core\User();
ob_start(array('NERDZ\\Core\\Utils', 'minifyHTML'));
if (!$user->isLogged()) {
    die($user->lang('REGISTER'));
}
if (!($obj = Db::query(array('SELECT * FROM "users" WHERE "counter" = ?', array($_SESSION['id'])), Db::FETCH_OBJ))) {
    die($user->lang('ERROR'));
}
$vals = [];
$vals['username_n'] = $obj->username;
$vals['name_n'] = $obj->name;
$vals['surname_n'] = $obj->surname;
$vals['timezone_n'] = $obj->timezone;
$vals['ismale_b'] = $obj->gender == 1;
$vals['email_n'] = $obj->email;
$now = date('o');
$vals['years_a'] = array_reverse(range($now - 100, $now - 1));
$vals['months_a'] = range(1, 12);
$vals['days_a'] = range(1, 31);
$date = explode('-', $obj->birth_date);
$vals['year_n'] = $date[0];
$vals['month_n'] = $date[1];
$vals['day_n'] = $date[2];
$vals['timezones_a'] = DateTimeZone::listIdentifiers();
$vals['tok_n'] = NERDZ\Core\Security::getCsrfToken('edit');
$user->getTPL()->assign($vals);
Example #11
0
<?php

ob_start('ob_gzhandler');
require_once $_SERVER['DOCUMENT_ROOT'] . '/class/autoload.php';
ob_start(array('NERDZ\\Core\\Utils', 'minifyHTML'));
$user = new NERDZ\Core\User();
$vals = [];
$vals['tok_n'] = NERDZ\Core\Security::getCsrfToken('pm');
$user->getTPL()->assign($vals);
$user->getTPL()->draw('pm/form');
Example #12
0
<?php

// require_once $prj, $path variables
if (!isset($prj, $path)) {
    die('$prj, $path required');
}
ob_start('ob_gzhandler');
require_once $_SERVER['DOCUMENT_ROOT'] . '/class/autoload.php';
use NERDZ\Core;
ob_start(array('NERDZ\\Core\\Utils', 'minifyHTML'));
$user = new NERDZ\Core\User();
$messages = new NERDZ\Core\Messages();
$logged = $user->isLogged();
// boards
$id = isset($_POST['id']) && is_numeric($_POST['id']) ? $_POST['id'] : false;
$limit = isset($_POST['limit']) ? NERDZ\Core\Security::limitControl($_POST['limit'], 10) : 10;
$beforeHpid = isset($_POST['hpid']) && is_numeric($_POST['hpid']) ? $_POST['hpid'] : false;
// homepage
if (isset($_POST['onlyfollowed'])) {
    $lang = false;
    $onlyfollowed = true;
} else {
    $lang = isset($_POST['lang']) ? $_POST['lang'] : false;
    $onlyfollowed = false;
}
$vote = isset($_POST['vote']) && is_string($_POST['vote']) ? trim($_POST['vote']) : false;
//search
$specific = isset($_GET['specific']);
$action = isset($_GET['action']) && $_GET['action'] === 'profile' ? 'profile' : 'project';
$search = !empty($_POST['q']) ? trim(htmlspecialchars($_POST['q'], ENT_QUOTES, 'UTF-8')) : false;
//rewrite $path if searching not in home
Example #13
0
<?php

require_once $_SERVER['DOCUMENT_ROOT'] . '/class/autoload.php';
use NERDZ\Core\Utils;
use NERDZ\Core\Config;
use NERDZ\Core\Db;
$user = new NERDZ\Core\User();
$vals = [];
$cache = 'nerdz_stats' . Config\SITE_HOST;
if (!($ret = Utils::apc_get($cache))) {
    $ret = Utils::apc_set($cache, function () use($cache) {
        function createArray(&$ret, $query, $position)
        {
            if (!($o = Db::query($query, Db::FETCH_OBJ))) {
                $ret[$position] = -1;
            } else {
                $ret[$position] = $o->cc;
            }
        }
        $queries = [0 => 'SELECT COUNT(counter)     AS cc FROM users', 1 => 'SELECT COUNT(hpid)        AS cc FROM posts', 2 => 'SELECT COUNT(hcid)        AS cc FROM comments', 3 => 'SELECT COUNT(counter)     AS cc FROM groups', 4 => 'SELECT COUNT(hpid)        AS cc FROM groups_posts', 5 => 'SELECT COUNT(hcid)        AS cc FROM groups_comments', 6 => 'SELECT COUNT(counter)     AS cc FROM users  WHERE last > (NOW() - INTERVAL \'4 MINUTES\') AND viewonline IS TRUE', 7 => 'SELECT COUNT(counter)     AS cc FROM users  WHERE last > (NOW() - INTERVAL \'4 MINUTES\') AND viewonline IS FALSE', 8 => 'SELECT COUNT(remote_addr) AS cc FROM guests WHERE last > (NOW() - INTERVAL \'4 MINUTES\')'];
        foreach ($queries as $position => $query) {
            createArray($ret, $query, $position);
        }
        if (!($bots = Utils::apc_get($cache . 'bots'))) {
            $bots = Utils::apc_set($cache . 'bots', function () {
                $txt = file_get_contents($_SERVER['DOCUMENT_ROOT'] . '/data/bots.json');
                return json_decode(preg_replace('#(/\\*([^*]|[\\r\\n]|(\\*+([^*/]|[\\r\\n])))*\\*+/)|([\\s\\t](//).*)#', '', $txt), true);
            }, 86400);
        }
        $ret[9] = 0;
        $ret[10] = [];