<?php

ob_start('ob_gzhandler');
require_once $_SERVER['DOCUMENT_ROOT'] . '/class/autoload.php';
use NERDZ\Core\Project;
use NERDZ\Core\User;
use NERDZ\Core\Captcha;
use NERDZ\Core\Db;
$user = new User();
$project = new Project();
if (!$user->isLogged()) {
    die(NERDZ\Core\Utils::jsonResponse('error', $user->lang('REGISTER')));
}
$id = $_POST['id'] = isset($_POST['id']) && is_numeric($_POST['id']) ? trim($_POST['id']) : false;
if ($_SESSION['id'] != $project->getOwner($id) || !NERDZ\Core\Security::refererControl()) {
    die(NERDZ\Core\Utils::jsonResponse('error', $user->lang('ERROR')));
}
if (!NERDZ\Core\Security::csrfControl(isset($_POST['tok']) ? $_POST['tok'] : 0, 'edit')) {
    die(NERDZ\Core\Utils::jsonResponse('error', $user->lang('ERROR') . ': token'));
}
switch (isset($_GET['action']) ? strtolower($_GET['action']) : '') {
    case 'del':
        $capt = new Captcha();
        if (!$capt->check(isset($_POST['captcha']) ? $_POST['captcha'] : '')) {
            die(NERDZ\Core\Utils::jsonResponse('error', $user->lang('ERROR') . ': ' . $user->lang('CAPTCHA')));
        }
        if (Db::NO_ERRNO != Db::query(['DELETE FROM "groups" WHERE "counter" = :id', [':id' => $id]], Db::FETCH_ERRNO)) {
            die(NERDZ\Core\Utils::jsonResponse('error', $user->lang('ERROR')));
        }
        break;
    case 'update':
<?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');
Example #3
0
$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);
    }
    if (!$icansee) {
        $user->getTPL()->assign($vals);
        require_once $_SERVER['DOCUMENT_ROOT'] . '/pages/common/vars.php';
        $user->getTPL()->draw('project/invisible');
    } else {
        $vals['photo_n'] = !empty($info->photo) ? Utils::getValidImageURL($info->photo) : 'https://www.gravatar.com/avatar/';
        $vals['onerrorimgurl_n'] = '/static/images/onErrorImg.php';
        $vals['id_n'] = $info->counter;
        $vals['name_n'] = $info->name;
        $vals['name4link_n'] = \NERDZ\Core\Utils::projectLink($info->name);
        if (!($o = Db::query(['SELECT EXTRACT(EPOCH FROM "creation_time") AS creation_time from "groups" WHERE "counter" = :id', [':id' => $info->counter]], Db::FETCH_OBJ))) {
            die($user->lang('ERROR'));
        }
        $vals['creationtime_n'] = $user->getDateTime($o->creation_time);