示例#1
0
 private static function getURLFromCid($hcid, $project = false)
 {
     $prefix = $project ? 'groups_' : '';
     if (!($o = Db::query(['SELECT p.to, p.pid FROM "' . $prefix . 'posts" p INNER JOIN "' . $prefix . 'comments" c ON c."hcid" = :hcid AND c.hpid = p.hpid', [':hcid' => $hcid]], Db::FETCH_OBJ))) {
         return System::getCurrentHostAddress();
     }
     return System::getCurrentHostAddress() . ($project ? Utils::projectLink(Project::getName($o->to)) : Utils::userLink(User::getUsername($o->to))) . $o->pid . '#c' . $hcid;
 }
<?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');
示例#3
0
 public function defollow($id, $prj = false)
 {
     if (!$this->isLogged()) {
         return Utils::$REGISTER_DB_MESSAGE;
     }
     // defollow to remove from members, if member
     if ($prj) {
         $project = new Project($id);
         if (in_array($_SESSION['id'], $project->getMembers())) {
             return Db::query(['DELETE FROM "groups_members" WHERE "to" = :id AND "from" = :me', [':id' => $id, ':me' => $_SESSION['id']]], Db::FETCH_ERRSTR);
         }
     }
     $table = ($prj ? 'groups_' : '') . 'followers';
     return Db::query(['DELETE FROM "' . $table . '" WHERE "to" = :id AND "from" = :me', [':id' => $id, ':me' => $_SESSION['id']]], Db::FETCH_ERRSTR);
 }
示例#4
0
<?php

require_once $_SERVER['DOCUMENT_ROOT'] . '/class/autoload.php';
use NERDZ\Core\Db;
use NERDZ\Core\Config;
use NERDZ\Core\Utils;
use NERDZ\Core\Project;
use NERDZ\Core\User;
use NERDZ\Core\Messages;
$user = new User();
$project = new Project();
if (!$user->isLogged()) {
    die(NERDZ\Core\Utils::jsonResponse('error', $user->lang('REGISTER')));
}
foreach ($_POST as &$val) {
    $val = trim($val);
}
if (empty($_POST['description']) || !is_string($_POST['description'])) {
    //always required
    die(NERDZ\Core\Utils::jsonResponse('error', $user->lang('MUST_COMPLETE_FORM') . "\n\n" . $user->lang('MISSING') . ":\n" . $user->lang('DESCRIPTION')));
}
$projectData = [];
$projectData['description'] = $_POST['description'];
$projectData['owner'] = $_SESSION['id'];
//required for creation
if (isset($create)) {
    if (empty($_POST['name']) || !is_string($_POST['name'])) {
        die(NERDZ\Core\Utils::jsonResponse('error', $user->lang('MUST_COMPLETE_FORM') . "\n\n" . $user->lang('MISSING') . ":\n" . $user->lang('NAME')));
    }
    $projectData['name'] = $_POST['name'];
    if ($project->getId($projectData['name']) !== 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\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

if (!isset($id)) {
    die('$id required');
}
require_once $_SERVER['DOCUMENT_ROOT'] . '/class/autoload.php';
use NERDZ\Core\Project;
use NERDZ\Core\User;
use NERDZ\Core\Db;
use NERDZ\Core\Utils;
$user = new User();
$prj = isset($prj);
$entity = $prj ? new Project() : new User();
$limit = isset($_GET['lim']) ? NERDZ\Core\Security::limitControl($_GET['lim'], 20) : 20;
$order = isset($_GET['desc']) && $_GET['desc'] == 1 ? 'DESC' : 'ASC';
$myvals = [];
$myvals['me_n'] = $_SESSION['id'];
$myvals['list_a'] = $entity->getInteractions($id, $limit);
if ($prj) {
    $myvals['to_n'] = Project::getName($id);
    $myvals['to4link_n'] = Utils::projectLink($myvals['to_n']);
} else {
    $myvals['to_n'] = $myvals['to4link_n'] = '';
}
$validFields = ['time'];
NERDZ\Core\Security::setNextAndPrevURLs($myvals, $limit, ['order' => $order, 'field' => empty($_GET['orderby']) ? '' : $_GET['orderby'], 'validFields' => $validFields]);
$user->getTPL()->assign($myvals);
return $user->getTPL()->draw(($prj ? 'project' : 'profile') . '/interactions', true);
示例#7
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);
    }
示例#8
0
use NERDZ\Core\Trend;
use NERDZ\Core\Utils;
use NERDZ\Core\Config;
use NERDZ\Core\User;
use NERDZ\Core\Project;
$vals = [];
$vals['querystring_n'] = $q;
$vals['type_n'] = !preg_match('/^#[a-z][a-z0-9]{0,33}$/i', $q) && isset($_GET['type']) ? $_GET['type'] == 'profile' ? 'profile' : 'project' : 'tag';
if ($vals['type_n'] == 'tag') {
    $vals['where_n'] = 'home';
    $vals['toid_n'] = $vals['to_n'] = $vals['to4link_n'] = '';
} else {
    $prj = $vals['type_n'] == 'project';
    $vals['where_n'] = isset($_GET['location']) ? $_GET['location'] == 'home' ? 'home' : ($_GET['location'] == 'profile' ? 'profile' : 'project') : 'home';
    $vals['toid_n'] = isset($_GET['id']) && is_numeric($_GET['id']) ? intval($_GET['id']) : false;
    if ($vals['toid_n']) {
        if ($prj) {
            $vals['to_n'] = Project::getName($vals['toid_n']);
            $vals['to4link_n'] = Utils::projectLink($vals['to_n']);
        } else {
            $vals['to_n'] = User::getUsername($vals['toid_n']);
            $vals['to4link_n'] = Utils::userLink($vals['to_n']);
        }
    } else {
        $vals['toid_n'] = $vals['to_n'] = $vals['to4link_n'] = '';
    }
}
require_once $_SERVER['DOCUMENT_ROOT'] . '/pages/common/trends.html.php';
require_once $_SERVER['DOCUMENT_ROOT'] . '/pages/common/vars.php';
$user->getTPL()->assign($vals);
$user->getTPL()->draw('search/layout');
 private function get($params, $type)
 {
     extract($params);
     $post = !empty($post) ? $post : false;
     $row = !empty($row) ? $row : false;
     $ret = [];
     if (!$row) {
         return $ret;
     }
     $ret['fromid_n'] = $row->from;
     $ret['from_n'] = User::getUsername($row->from);
     $ret['from4link_n'] = Utils::userLink($ret['from_n']);
     $ret['type_n'] = $type;
     if ($post) {
         $ret['hpid_n'] = $row->hpid;
         $ret['pid_n'] = $post->pid;
         if ($this->isProject($type)) {
             $ret['to_n'] = Project::getName($post->to);
             $ret['to4link_n'] = Utils::projectLink($ret['to_n']) . $ret['pid_n'];
         } else {
             $ret['to_n'] = User::getUsername($post->to);
             $ret['to4link_n'] = Utils::userLink($ret['to_n']) . $ret['pid_n'];
         }
     } else {
         // followers - members
         $ret['toid_n'] = $row->to;
         if ($this->isProject($type)) {
             $ret['to_n'] = Project::getName($row->to);
             $ret['to4link_n'] = Utils::projectLink($ret['to_n']);
         } else {
             $ret['to_n'] = User::getUsername($row->to);
             $ret['to4link_n'] = Utils::userLink($ret['to_n']);
         }
     }
     $ret['datetime_n'] = $this->user->getDateTime($row->time);
     $ret['timestamp_n'] = $row->time;
     return $ret;
 }