예제 #1
0
?>
';
    var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(gi,s);
})();
</script>
<?php 
if (!isset($_COOKIE['stupid_and_useless_cookielaw'])) {
    ?>
<div id="cookieChoiceInfo" style="position: fixed; width: 100%; border-top-width: 1px; border-top-style: solid; border-top-color: rgb(204, 204, 204); color: rgb(119, 119, 119); font-size: 12px; margin: 0px; left: 0px; bottom: 0px; padding: 10px 0px; z-index: 1000; text-align: center; background-color: rgb(230, 230, 230);">
    <span><?php 
    echo $user->lang('COOKIE_LAW_NOTICE');
    ?>
</span>
    <a href="/terms.php#cookiePolicy" target="_blank" style="color: rgb(119, 119, 119); text-decoration: underline; margin-left: 20px;"><?php 
    echo $user->lang('INFORMATIONS');
    ?>
</a>
    <a id="cookieChoiceDismiss" href="#" style="color: rgb(255, 255, 255); padding: 3px; margin-left: 20px; background-color: rgb(255, 102, 0);">OK</a>
</div>
    <script>
    $("#cookieChoiceDismiss").on('click',function(e) {
        e.preventDefault();
        $("#cookieChoiceInfo").remove();
        document.cookie = "stupid_and_useless_cookielaw=true; expires=Fri, 31 Dec 9999 23:59:59 GMT; path=/; domain=<?php 
    echo System::getSafeCookieDomainName();
    ?>
";
    });
    </script>
<?php 
}
예제 #2
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');
예제 #3
0
    die(NERDZ\Core\Utils::jsonResponse('error', $user->lang('ERROR') . ': referer'));
}
if (!NERDZ\Core\Security::csrfControl(isset($_POST['tok']) ? $_POST['tok'] : 0, 'edit')) {
    die(NERDZ\Core\Utils::jsonResponse('error', $user->lang('ERROR') . ': token'));
}
if (!$user->isLogged()) {
    die(NERDZ\Core\Utils::jsonResponse('error', $user->lang('REGISTER')));
}
if (isset($_GET['action']) && $_GET['action'] == 'vars') {
    if (isset($_POST['vars']) && is_array($_POST['vars'])) {
        $user->setTemplateVariables($_POST['vars']);
    } else {
        die(NERDZ\Core\Utils::jsonResponse('error', $user->lang('ERROR') . ': JSON'));
    }
} else {
    $theme = isset($_POST['theme']) && is_string($_POST['theme']) ? trim($_POST['theme']) : '';
    $shorts = [];
    $templates = System::getAvailableTemplates();
    foreach ($templates as $val) {
        $shorts[] = $val['number'];
    }
    if (!in_array($theme, $shorts)) {
        die(NERDZ\Core\Utils::jsonResponse('error', $user->lang('ERROR')));
    }
    $column = (Config\MOBILE_HOST == $_SERVER['HTTP_HOST'] ? 'mobile_' : '') . 'template';
    if (Db::NO_ERRNO != Db::query(['UPDATE "profiles" SET "' . $column . '" = :theme WHERE "counter" = :id', [':theme' => $theme, ':id' => $_SESSION['id']]], Db::FETCH_ERRNO)) {
        die(NERDZ\Core\Utils::jsonResponse('error', 'Update: ' . $user->lang('ERROR')));
    }
    $_SESSION['template'] = $theme;
}
die(NERDZ\Core\Utils::jsonResponse('ok', 'OK'));
예제 #4
0
 public static function dumpException($e, $moredata = false)
 {
     System::dumpError(($moredata != false ? "{$moredata}: " : '') . $e->getMessage());
 }
예제 #5
0
 public static function getResourceDomain()
 {
     return System::isOnHTTPS() ? 'https://' . Config\HTTPS_DOMAIN : Config\STATIC_DOMAIN;
 }
예제 #6
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;
 }
예제 #7
0
 public function add($to, $message, $options = [])
 {
     extract($options);
     $news = !empty($news);
     $project = !empty($project);
     $issue = !empty($issue);
     $language = !empty($language) ? $language : false;
     if ($language) {
         if (!in_array($language, System::getAvailableLanguages())) {
             return 'error: INVALID_LANGUAGE';
         }
     } else {
         $language = $this->user->getLanguage();
     }
     $table = ($project ? 'groups_' : '') . 'posts';
     $retStr = Db::query(['INSERT INTO "' . $table . '" ("from","to","message","news","lang") VALUES (:id,:to,:message, :news, :language)', [':id' => $_SESSION['id'], ':to' => $to, ':message' => Comments::parseQuote(htmlspecialchars($message, ENT_QUOTES, 'UTF-8')), ':news' => $news ? 'true' : 'false', ':language' => $language]], Db::FETCH_ERRSTR);
     if ($retStr != Db::NO_ERRSTR) {
         return $retStr;
     }
     if ($project && $issue && $to == Config\ISSUE_BOARD) {
         require_once __DIR__ . '/vendor/autoload.php';
         $client = new \Github\Client();
         $client->authenticate(Config\ISSUE_GIT_KEY, null, \Github\client::AUTH_URL_TOKEN);
         $message = static::stripTags($message);
         try {
             $client->api('issue')->create('nerdzeu', 'nerdz.eu', ['title' => substr($message, 0, 128), 'body' => User::getUsername() . ': ' . $message]);
         } catch (\Github\Exception\RuntimeException $exception) {
             System::dumpError('GitHub API: ' . $exception->getMessage());
             System::dumpError('GitHub API: ' . $exception->getPrevious());
         }
     }
     return $retStr;
 }
예제 #8
0
 public function getLanguage($id = null)
 {
     $logged = $this->isLogged();
     if (!$id && !$logged) {
         return System::getBrowserLanguage();
     }
     if ($logged && ($id == $_SESSION['id'] || !$id)) {
         if (empty($_SESSION['lang'])) {
             if (!($o = Db::query(['SELECT "lang" FROM "users" WHERE "counter" = :id', [':id' => $id]], Db::FETCH_OBJ))) {
                 return System::getBrowserLanguage();
             }
             if (empty($o->lang)) {
                 $_SESSION['lang'] = System::getBrowserLanguage();
                 $this->setLanguage($_SESSION['lang']);
             } else {
                 $_SESSION['lang'] = $o->lang;
             }
         }
         return $_SESSION['lang'];
     }
     if (!($o = Db::query(['SELECT "lang" FROM "users" WHERE "counter" = :id', [':id' => $id]], Db::FETCH_OBJ))) {
         return System::getBrowserLanguage();
     }
     return empty($o->lang) ? System::getBrowserLanguage() : $o->lang;
 }
예제 #9
0
        if (isset($_POST['start']) && isset($_POST['num']) && is_numeric($_POST['start']) && is_numeric($_POST['num'])) {
            $_list = $comments->getLastComments($hpid, $_POST['num'], $_POST['start'], $prj);
        } else {
            if (isset($_POST['hcid']) && is_numeric($_POST['hcid'])) {
                $_list = $comments->getCommentsAfterHcid($hpid, $_POST['hcid'], $prj);
            } else {
                $_list = $comments->getAll($hpid, $prj);
            }
        }
        $doShowForm = !isset($_POST['hcid']) && (!isset($_POST['start']) || $_POST['start'] == 0) && !isset($_POST['forceNoForm']);
        if (empty($_list) && !$doShowForm) {
            die;
        }
        $vals = [];
        $vals['currentuserprofile_n'] = \NERDZ\Core\Utils::userLink($_SESSION['id']);
        $vals['currentusergravatar_n'] = $user->getGravatar($_SESSION['id']);
        $vals['currentusername_n'] = User::getUsername();
        $vals['onerrorimgurl_n'] = System::getResourceDomain() . '/static/images/red_x.png';
        $vals['list_a'] = $_list;
        $vals['showform_b'] = $doShowForm;
        $vals['hpid_n'] = $hpid;
        $vals['commentcount_n'] = (new Messages())->countComments($hpid, $prj);
        $vals['needmorebtn_b'] = $doShowForm && $vals['commentcount_n'] > 10;
        $vals['needeverycommentbtn_b'] = $doShowForm && $vals['commentcount_n'] > 20;
        $user->getTPL()->assign($vals);
        $user->getTPL()->draw(($prj ? 'project' : 'profile') . '/comments');
        break;
    default:
        die($user->lang('ERROR'));
        break;
}
예제 #10
0
echo Config\LOGIN_SSL_ONLY ? 'true' : 'false';
?>
,
        domain: "<?php 
echo Config\HTTPS_DOMAIN;
?>
"
    };
<?php 
/* END SSL_VARIABLES */
/* BEGIN NERDZ_VERSION */
if (isset($headers['js']['staticData']['outputVersion']) && $headers['js']['staticData']['outputVersion'] === true) {
    unset($headers['js']['staticData']['outputVersion']);
    ?>
    var Nversion = '<?php 
    echo System::getVersion();
    ?>
';
<?php 
}
/* END NERDZ_VERSION */
/* BEGIN NERDZ_STATIC_DATA */
?>
var Nstatic = <?php 
echo json_encode(isset($headers['js']['staticData']) ? $headers['js']['staticData'] : [], JSON_HEX_TAG);
?>
;
<?php 
/* END NERDZ_STATIC_DATA */
/* BEGIN BLACKLIST_STUFF */
if ($logged) {
예제 #11
0
ob_start('ob_gzhandler');
require_once $_SERVER['DOCUMENT_ROOT'] . '/class/autoload.php';
use NERDZ\Core\User;
use NERDZ\Core\System;
$user = new User();
if (!NERDZ\Core\Security::refererControl()) {
    die(NERDZ\Core\Utils::jsonResponse('error', $user->lang('ERROR') . ': referer'));
}
if (!NERDZ\Core\Security::csrfControl(isset($_POST['tok']) ? $_POST['tok'] : 0, 'edit')) {
    die(NERDZ\Core\Utils::jsonResponse('error', $user->lang('ERROR') . ': token'));
}
if (!$user->isLogged()) {
    die(NERDZ\Core\Utils::jsonResponse('error', $user->lang('REGISTER')));
}
$lang = isset($_POST['lang']) && is_string($_POST['lang']) ? trim($_POST['lang']) : '';
if (!in_array($lang, System::getAvailableLanguages())) {
    die(NERDZ\Core\Utils::jsonResponse('error', $user->lang('ERROR')));
}
switch (isset($_GET['action']) ? strtolower($_GET['action']) : '') {
    case 'userlang':
        if (!$user->setLanguage($lang)) {
            die(NERDZ\Core\Utils::jsonResponse('error', $user->lang('ERROR')));
        }
        $_SESSION['lang'] = $lang;
        break;
    case 'boardlang':
        if (!$user->setBoardLanguage($lang)) {
            die(NERDZ\Core\Utils::jsonResponse('error', $user->lang('ERROR')));
        }
        $_SESSION['board_lang'] = $lang;
        break;