예제 #1
0
<?php

ob_start('ob_gzhandler');
require_once $_SERVER['DOCUMENT_ROOT'] . '/class/autoload.php';
use NERDZ\Core\User;
use NERDZ\Core\System;
$user = new User();
ob_start(array('NERDZ\\Core\\Utils', 'minifyHTML'));
if (!$user->isLogged()) {
    die($user->lang('REGISTER'));
}
$vals = [];
$vals['tok_n'] = NERDZ\Core\Security::getCsrfToken('edit');
$longlangs = System::getAvailableLanguages(1);
$vals['langs_a'] = [];
$i = 0;
foreach ($longlangs as $id => $val) {
    $vals['langs_a'][$i]['longlang_n'] = $val;
    $vals['langs_a'][$i]['shortlang_n'] = $id;
    ++$i;
}
$vals['mylang_n'] = $user->getLanguage($_SESSION['id']);
$vals['myboardlang_n'] = $user->getBoardLanguage($_SESSION['id']);
$user->getTPL()->assign($vals);
$user->getTPL()->draw('preferences/language');
예제 #2
0
<?php

require_once $_SERVER['DOCUMENT_ROOT'] . '/class/autoload.php';
use NERDZ\Core\Comments;
use NERDZ\Core\User;
$user = new User();
$message = new Comments();
if (!$user->isLogged() || empty($_GET['message'])) {
    $_GET['message'] = $user->lang('ERROR');
}
$vals = [];
$vals['message_n'] = $message->bbcode($message->parseQuote(htmlspecialchars($_GET['message'], ENT_QUOTES, 'UTF-8')));
$user->getTPL()->assign($vals);
$user->getTPL()->draw('base/preview');
예제 #3
0
<?php

ob_start('ob_gzhandler');
require_once $_SERVER['DOCUMENT_ROOT'] . '/class/autoload.php';
use NERDZ\Core\Project;
use NERDZ\Core\User;
use NERDZ\Core\Utils;
$user = new User();
$project = new Project();
ob_start(array('NERDZ\\Core\\Utils', 'minifyHTML'));
$id = isset($_POST['id']) && is_numeric($_POST['id']) ? $_POST['id'] : false;
if (!$user->isLogged() || !$id || !($info = $project->getObject($id)) || $project->getOwner($id) != $_SESSION['id']) {
    die($user->lang('ERROR'));
}
$vals = [];
function sortbyusername($a, $b)
{
    return strtolower($a) < strtolower($b) ? -1 : 1;
}
$vals['photo_n'] = $info->photo;
$vals['website_n'] = $info->website;
$vals['name_n'] = $info->name;
$mem = $project->getMembers($info->counter);
$vals['members_n'] = count($mem);
$vals['members_a'] = [];
foreach ($mem as &$uid) {
    $uid = User::getUsername($uid);
}
$vals['members_a'] = $mem;
usort($vals['members_a'], 'sortbyusername');
$vals['tok_n'] = NERDZ\Core\Security::getCsrfToken('edit');
예제 #4
0
// intval below
$pid = isset($_GET['pid']) && is_numeric($_GET['pid']) ? intval($_GET['pid']) : false;
$action = NERDZ\Core\Utils::actionValidator(!empty($_GET['action']) && is_string($_GET['action']) ? $_GET['action'] : false);
$found = true;
if ($id) {
    $id = intval($id);
    //intval here, so we can display the user not found message
    if (false === ($info = $user->getObject($id))) {
        $username = $user->lang('USER_NOT_FOUND');
        $found = false;
        $post = new stdClass();
        $post->message = '';
    } else {
        $username = $info->username;
        if ($pid && !$user->hasInBlacklist($id)) {
            if (!$user->isLogged() && $info->private || !($post = Db::query(['SELECT "message" FROM "posts" WHERE "pid" = :pid AND "to" = :id', [':pid' => $pid, ':id' => $id]], Db::FETCH_OBJ))) {
                $post = new stdClass();
                $post->message = '';
            }
        } else {
            $post = new stdClass();
            $post->message = '';
        }
    }
    /*else abbiamo la variabili $info con tutti i dati dell'utente in un oggetto */
} else {
    die(header('Location: /index.php'));
}
ob_start(array('NERDZ\\Core\\Utils', 'minifyHTML'));
$a = explode(' ', $messages->parseNews(Messages::stripTags(str_replace("\n", ' ', $post->message))));
$i = 25;
예제 #5
0
<?php

ob_start('ob_gzhandler');
require_once $_SERVER['DOCUMENT_ROOT'] . '/class/autoload.php';
use NERDZ\Core\Db;
use NERDZ\Core\User;
use NERDZ\Core\Captcha;
$user = new User();
$cptcka = new Captcha();
$captcha = isset($_POST['captcha']) ? $_POST['captcha'] : false;
if (!$captcha) {
    die(NERDZ\Core\Utils::jsonResponse('error', $user->lang('MISSING') . ': ' . $user->lang('CAPTCHA')));
}
if (!$cptcka->check($captcha)) {
    die(NERDZ\Core\Utils::jsonResponse('error', $user->lang('WRONG_CAPTCHA')));
}
if ($user->isLogged()) {
    die(NERDZ\Core\Utils::jsonResponse('error', $user->lang('ALREADY_LOGGED')));
}
require_once $_SERVER['DOCUMENT_ROOT'] . '/pages/common/validateuser.php';
$ret = Db::query(['INSERT INTO users ("username","password","name","surname","email","gender","birth_date","lang","board_lang","timezone","remote_addr", "http_user_agent")
        VALUES (:username, crypt(:password, gen_salt(\'bf\', 7)) , :name, :surname, :email, :gender, :date, :lang, :lang, :timezone, :remote_addr, :http_user_agent)', [':username' => $userData['username'], ':password' => $userData['password'], ':name' => $userData['name'], ':surname' => $userData['surname'], ':email' => $userData['email'], ':gender' => $userData['gender'], ':timezone' => $userData['timezone'], ':date' => $birth['date'], ':lang' => $user->getLanguage(), ':remote_addr' => $_SERVER['REMOTE_ADDR'], ':http_user_agent' => isset($_SERVER['HTTP_USER_AGENT']) ? htmlspecialchars($_SERVER['HTTP_USER_AGENT'], ENT_QUOTES, 'UTF-8') : '']], Db::FETCH_ERRSTR);
if ($ret != Db::NO_ERRSTR) {
    die(NERDZ\Core\Utils::jsonDbResponse($ret));
}
if (!$user->login($userData['username'], $userData['password'], $setCookie = true)) {
    die(NERDZ\Core\Utils::jsonResponse('error', $user->lang('ERROR') . ': Login'));
}
die(NERDZ\Core\Utils::jsonResponse('ok', $user->lang('LOGIN_OK')));
예제 #6
0
<?php

require_once $_SERVER['DOCUMENT_ROOT'] . '/class/autoload.php';
use NERDZ\Core\Db;
use NERDZ\Core\Config;
use NERDZ\Core\User;
use NERDZ\Core\Messages;
use NERDZ\Core\Security;
$user = new User();
$l = "\t\n\r\v ����� ­";
$userData = [];
$userData['name'] = isset($_POST['name']) ? trim($_POST['name'], $l) : false;
$userData['surname'] = isset($_POST['surname']) ? trim($_POST['surname'], $l) : false;
$userData['email'] = isset($_POST['email']) ? trim($_POST['email'], $l) : false;
$userData['timezone'] = isset($_POST['timezone']) ? trim($_POST['timezone'], $l) : false;
if ($user->isLogged()) {
    $updatedPassword = false;
    if (empty($_POST['password'])) {
        if (!($obj = Db::query(['SELECT "password" FROM "users" WHERE counter = :id', [':id' => $_SESSION['id']]], Db::FETCH_OBJ))) {
            die(NERDZ\Core\Utils::jsonResponse('error', $user->lang('ERROR')));
        }
        $userData['password'] = $obj->password;
        //saved hashed password
    } else {
        $userData['password'] = $_POST['password'];
        $updatedPassword = true;
    }
} else {
    $userData['password'] = isset($_POST['password']) ? $_POST['password'] : false;
    $userData['username'] = isset($_POST['username']) ? trim($_POST['username'], $l) : false;
}
예제 #7
0
<?php

ob_start('ob_gzhandler');
require_once $_SERVER['DOCUMENT_ROOT'] . '/class/autoload.php';
use NERDZ\Core\User;
use NERDZ\Core\Db;
$user = new User();
if (!$user->isLogged() || empty($_POST['id']) || !is_numeric($_POST['id'])) {
    die(NERDZ\Core\Utils::jsonResponse('error', $user->lang('LOGIN')));
}
switch (isset($_GET['action']) ? strtolower($_GET['action']) : '') {
    case 'del':
        if (Db::NO_ERRNO != Db::query(['DELETE FROM "blacklist" WHERE "from" = :me AND "to" = :to', [':me' => $_SESSION['id'], ':to' => $_POST['id']]], Db::FETCH_ERRNO)) {
            die(NERDZ\Core\Utils::jsonResponse('error', $user->lang('ERROR')));
        }
        break;
    case 'add':
        $motivation = empty($_POST['motivation']) ? '' : htmlspecialchars(trim($_POST['motivation']), ENT_QUOTES, 'UTF-8');
        if (!$user->hasInBlacklist($_POST['id'])) {
            if (Db::NO_ERRNO != Db::query(['INSERT INTO "blacklist"("from","to","motivation") VALUES (:me,:to,:motivation)', [':me' => $_SESSION['id'], ':to' => $_POST['id'], ':motivation' => $motivation]], Db::FETCH_ERRNO)) {
                die(NERDZ\Core\Utils::jsonResponse('error', $user->lang('ERROR')));
            }
        } else {
            die(NERDZ\Core\Utils::jsonResponse('error', $user->lang('ERROR') . '1'));
        }
        break;
    default:
        die(NERDZ\Core\Utils::jsonResponse('error', $user->lang('ERROR') . '2'));
        break;
}
die(NERDZ\Core\Utils::jsonResponse('ok', 'OK'));
예제 #8
0
<?php

require_once $_SERVER['DOCUMENT_ROOT'] . '/class/autoload.php';
use NERDZ\Core\Db;
use NERDZ\Core\Project;
use NERDZ\Core\Utils;
use NERDZ\Core\User;
use NERDZ\Core\Config;
use NERDZ\Core\Messages;
$project = new Project($gid);
$messages = new Messages();
$user = new User();
$vals = [];
$enter = true;
$vals['logged_b'] = $user->isLogged();
$vals['singlepost_b'] = isset($pid) && isset($gid) && is_numeric($pid);
$vals['followers_b'] = isset($action) && $action == 'followers';
$vals['members_b'] = isset($action) && $action == 'members';
$vals['interactions_b'] = isset($action) && $action == 'interactions';
if ($info->private && !$vals['logged_b'] || !$info->visible && !$vals['logged_b'] || $vals['interactions_b'] && !$vals['logged_b']) {
    $included = true;
    require_once $_SERVER['DOCUMENT_ROOT'] . '/pages/register.php';
    $user->getTPL()->assign($vals);
    require_once $_SERVER['DOCUMENT_ROOT'] . '/pages/common/vars.php';
    $user->getTPL()->draw('project/private');
} else {
    $mem = $project->getMembers($info->counter);
    $icansee = true;
    if ($vals['logged_b'] && !$info->visible) {
        $icansee = $_SESSION['id'] == $project->getOwner() || in_array($_SESSION['id'], $mem);
    }