示例#1
0
				$apps = CoreUtils::$VECTOR_APPS;
				echo "<option value=''".($vectorapp===''?' selected':'').">{$apps['']}</option>";
				unset($apps['']);
				echo "<optgroup label='Vectoring applications'>";
				foreach ($apps as $id => $label)
					echo "<option value='$id'".($vectorapp===$id?' selected':'').">$label</option>";
				echo "</optgroup>";
					?></select>
<?php   if ($sameUser){ ?>
					<button class="save typcn typcn-tick green" disabled>Save</button>
<?php   } ?>
				</label>
			</form>
			<form action="/preference/set/p_hidediscord">
				<label>
					<input type="checkbox" name="value" value="1"<?=UserPrefs::get('p_hidediscord', $User->id)?' checked':''?> <?=!$sameUser?' disabled':''?>>
					<span>Hide Discord server link from the sidebar</span>
<?php   if ($sameUser){ ?>
					<button class="save typcn typcn-tick green" disabled>Save</button>
<?php   } ?>
				</label>
			</form>
		</section>
		<section class="sessions">
			<h2><?=$sameUser? Users::PROFILE_SECTION_PRIVACY_LEVEL['staff']:''?>Sessions</h2>
<?php   if (isset($CurrentSession) || !empty($Sessions)){ ?>
			<p>Below is a list of all the browsers <?=$sameUser?"you've":'this user has'?> logged in from.</p>
			<ul class="session-list"><?php
				if (isset($CurrentSession)) Users::renderSessionLi($CurrentSession,CURRENT);
				if (!empty($Sessions)){
					foreach ($Sessions as $s) Users::renderSessionLi($s);
示例#2
0
 /**
  * Get HTML for a color group
  *
  * @param int|array  $GroupID
  * @param array|null $AllColors
  * @param bool       $wrap
  * @param bool       $colon
  * @param bool       $colorNames
  * @param bool       $force_extra_info
  *
  * @return string
  */
 static function getHTML($GroupID, $AllColors = null, bool $wrap = true, bool $colon = true, bool $colorNames = false, bool $force_extra_info = false) : string
 {
     global $CGDb;
     if (is_array($GroupID)) {
         $Group = $GroupID;
     } else {
         $Group = $CGDb->where('groupid', $GroupID)->getOne('colorgroups');
     }
     $label = CoreUtils::escapeHTML($Group['label']) . ($colon ? ': ' : '');
     $HTML = "<span class='cat'>{$label}" . ($colorNames && Permission::sufficient('staff') ? '<span class="admin"><button class="blue typcn typcn-pencil edit-cg"></button><button class="red typcn typcn-trash delete-cg"></button></span>' : '') . "</span>";
     if (!isset($AllColors)) {
         $Colors = self::getColors($Group['groupid']);
     } else {
         $Colors = $AllColors[$Group['groupid']] ?? null;
     }
     if (!empty($Colors)) {
         $extraInfo = $force_extra_info || !UserPrefs::get('cg_hideclrinfo');
         foreach ($Colors as $i => $c) {
             $title = CoreUtils::aposEncode($c['label']);
             $color = '';
             if (!empty($c['hex'])) {
                 $color = $c['hex'];
                 $title .= "' style='background-color:{$color}' class='valid-color";
             }
             $append = "<span title='{$title}'>{$color}</span>";
             if ($colorNames) {
                 $append = "<div class='color-line" . (!$extraInfo || empty($color) ? ' no-detail' : '') . "'>{$append}<span><span class='label'>{$c['label']}";
                 if ($extraInfo && !empty($color)) {
                     $rgb = CoreUtils::hex2Rgb($color);
                     $rgb = 'rgb(' . implode(',', $rgb) . ')';
                     $append .= "</span><span class='ext'>{$color} &bull; {$rgb}";
                 }
                 $append .= '</span></div>';
             }
             $HTML .= $append;
         }
     }
     return $wrap ? "<li id='cg{$Group['groupid']}'>{$HTML}</li>" : $HTML;
 }
示例#3
0
 function getVectorAppName() : string
 {
     $pref = UserPrefs::get('p_vectorapp', $this->id);
     return CoreUtils::$VECTOR_APPS[$pref] ?? 'unrecognized application';
 }
示例#4
0
 static function getAppearancesSectionHTML(Episode $Episode) : string
 {
     global $CGDb, $Color;
     $HTML = '';
     $EpTagIDs = Episodes::getTagIDs($Episode);
     if (!empty($EpTagIDs)) {
         $TaggedAppearances = $CGDb->rawQuery("SELECT p.id, p.label, p.private\n\t\t\t\tFROM tagged t\n\t\t\t\tLEFT JOIN appearances p ON t.ponyid = p.id\n\t\t\t\tWHERE t.tid IN (" . implode(',', $EpTagIDs) . ") && p.ishuman = ?\n\t\t\t\tORDER BY p.label", array($Episode->isMovie));
         if (!empty($TaggedAppearances)) {
             $hidePreviews = UserPrefs::get('ep_noappprev');
             $pages = CoreUtils::makePlural('page', count($TaggedAppearances));
             $HTML .= "<section class='appearances'><h2>Related <a href='/cg'>{$Color} Guide</a> {$pages}</h2>";
             $LINKS = '<ul>';
             $isStaff = Permission::sufficient('staff');
             foreach ($TaggedAppearances as $p) {
                 $safeLabel = Appearances::getSafeLabel($p);
                 if (Appearances::isPrivate($p, true)) {
                     $preview = "<span class='typcn typcn-" . ($isStaff ? 'lock-closed' : 'time') . " color-" . ($isStaff ? 'orange' : 'darkblue') . "'></span> ";
                 } else {
                     if ($hidePreviews) {
                         $preview = '';
                     } else {
                         $preview = Appearances::getPreviewURL($p);
                         $preview = "<img src='{$preview}' class='preview'>";
                     }
                 }
                 $LINKS .= "<li><a href='/cg/v/{$p['id']}-{$safeLabel}'>{$preview}{$p['label']}</a></li>";
             }
             $HTML .= "{$LINKS}</ul></section>";
         }
     }
     return $HTML;
 }
示例#5
0
            $Appearances = Appearances::get($EQG, null, 'id,label,private');
            if (isset($_REQUEST['ajax'])) {
                Response::done(array('html' => CGUtils::getFullListHTML($Appearances, $GuideOrder, NOWRAP)));
            }
            $js = array();
            if (Permission::sufficient('staff')) {
                $js[] = 'Sortable';
            }
            $js[] = "{$do}-full";
            CoreUtils::loadPage(array('title' => "Full List - {$Color} Guide", 'view' => "{$do}-full", 'css' => "{$do}-full", 'js' => $js));
        }
    }
}
// Guide page output & display
$title = '';
$AppearancesPerPage = UserPrefs::get('cg_itemsperpage');
$Ponies = [];
try {
    $elasticAvail = CoreUtils::elasticClient()->ping();
} catch (Elasticsearch\Common\Exceptions\NoNodesAvailableException $e) {
    $elasticAvail = false;
}
if ($elasticAvail) {
    $search = new ElasticsearchDSL\Search();
    $orderByID = true;
    $Pagination = new Pagination('cg', $AppearancesPerPage);
    // Search query exists
    if (!empty($_GET['q']) && mb_strlen(trim($_GET['q'])) > 0) {
        $SearchQuery = preg_replace(new RegExp('[^\\w\\d\\s\\*\\?]'), '', trim($_GET['q']));
        $title .= "{$SearchQuery} - ";
        if (preg_match(new RegExp('[\\*\\?]'), $SearchQuery)) {
示例#6
0
         UserPrefs::set('discord_token', 'true', $user->id);
         Response::done(array('name' => $user->name, 'role' => $user->role));
     }
     $ismember = Permission::sufficient('member', $currentUser->role);
     $isstaff = Permission::sufficient('staff', $currentUser->role);
     if (!$ismember || $isstaff) {
         UserPrefs::set('discord_token', '');
         Response::fail(!$ismember ? 'You are not a club member' : 'Staff members cannot use this feature');
     }
     $token = UserPrefs::get('discord_token');
     if ($token === 'true') {
         Response::fail("You have already been verified using this automated method. If - for yome reason - you still don't have the Club Members role please ask for assistance in the <strong>#support</strong> channel.");
     }
     if (empty($token)) {
         $token = preg_replace(new RegExp('[^a-z\\d]', 'i'), '', base64_encode(random_bytes(12)));
         UserPrefs::set('discord_token', $token);
     }
     Response::done(array('token' => $token));
 }
 CSRFProtection::protect();
 if (empty($data)) {
     CoreUtils::notFound();
 }
 if ($data === 'suggestion') {
     if (Permission::insufficient('member')) {
         Response::fail('You must be a club member to use this feature.');
     }
     if (Users::reservationLimitExceeded(RETURN_AS_BOOL)) {
         Response::fail('You already have the maximum  4 reservations. Close this dialog to view or cancel them.', ['limithit' => true]);
     }
     $postIDs = $Database->rawQuery('SELECT id FROM requests
示例#7
0
 /**
  * User Information Fetching
  * -------------------------
  * Fetch user info from dA upon request to nonexistant user
  *
  * @param string $username
  * @param string $dbcols
  *
  * @return User|null|false
  */
 function fetch($username, $dbcols = null)
 {
     global $Database, $USERNAME_REGEX;
     if (!$USERNAME_REGEX->match($username)) {
         return null;
     }
     $oldName = $Database->where('old', $username)->getOne('log__da_namechange', 'id');
     if (!empty($oldName)) {
         return self::get($oldName['id'], 'id', $dbcols);
     }
     try {
         $userdata = DeviantArt::request('user/whois', null, array('usernames[0]' => $username));
     } catch (CURLRequestException $e) {
         return null;
     }
     if (empty($userdata['results'][0])) {
         return false;
     }
     $userdata = $userdata['results'][0];
     $ID = strtolower($userdata['userid']);
     /** @var $DBUser User */
     $DBUser = $Database->where('id', $ID)->getOne('users', 'name');
     $userExists = !empty($DBUser);
     $insert = array('name' => $userdata['username'], 'avatar_url' => URL::makeHttps($userdata['usericon']));
     if (!$userExists) {
         $insert['id'] = $ID;
     }
     if (!($userExists ? $Database->where('id', $ID)->update('users', $insert) : $Database->insert('users', $insert))) {
         throw new \Exception('Saving user data failed' . (Permission::sufficient('developer') ? ': ' . $Database->getLastError() : ''));
     }
     if (!$userExists) {
         Logs::action('userfetch', array('userid' => $insert['id']));
     }
     $names = array($username);
     if ($userExists && $DBUser->name !== $username) {
         $names[] = $DBUser->name;
     }
     foreach ($names as $name) {
         if (strcasecmp($name, $insert['name']) !== 0) {
             if (UserPrefs::get('discord_token', $ID) === 'true') {
                 UserPrefs::set('discord_token', '', $ID);
             }
             Logs::action('da_namechange', array('old' => $name, 'new' => $insert['name'], 'id' => $ID), Logs::FORCE_INITIATOR_WEBSERVER);
         }
     }
     return self::get($insert['name'], 'name', $dbcols);
 }
示例#8
0
    }
}
if (!empty(GA_TRACKING_CODE) && Permission::insufficient('developer')) {
    ?>
<script>
(function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){
(i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o),
m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m)
})(window,document,'script','https://www.google-analytics.com/analytics.js','ga');

ga('create','<?php 
    echo GA_TRACKING_CODE;
    ?>
','auto');
<?php 
    if ($signedIn && !UserPrefs::get('p_disable_ga')) {
        ?>
ga('set', 'userId', '<?php 
        echo $currentUser->id;
        ?>
');
<?php 
    }
    ?>
ga('require','displayfeatures');
ga('send','pageview');
</script>
<?php 
}
?>
</head>
示例#9
0
<?php 
    if ($signedIn) {
        ?>
			<button id="signout" class="typcn typcn-arrow-back">Sign out</button>
<?php 
    } else {
        ?>
			<button class="typcn green da-login" id="signin">Sign in</button>
			<!--suppress ES6ConvertVarToLetConst, JSUnusedLocalSymbols -->
			<script>var OAUTH_URL = "<?php 
        echo OAUTH_AUTHORIZATION_URL;
        ?>
";</script>
<?php 
    }
    if (!UserPrefs::get('p_hidediscord')) {
        ?>
			<a class="btn typcn discord-join" href="http://fav.me/d9zt1wv" target="_blank">Join Discord</a>
<?php 
    }
    ?>
		</div>
	</section>
<?php 
    if ($view === 'episode' && !empty($CurrentEpisode)) {
        ?>
	<section id="voting">
		<h2><?php 
        echo $CurrentEpisode->isMovie ? 'Movie' : 'Episode';
        ?>
 rating</h2>
示例#10
0
 /**
  * Return the markup of a set of tags belonging to a specific pony
  *
  * @param int         $PonyID
  * @param bool        $wrap
  * @param string|null $Search
  *
  * @return string
  */
 static function getTagsHTML($PonyID, $wrap = WRAP, $Search = null)
 {
     global $CGDb;
     $Tags = Tags::getFor($PonyID, null, Permission::sufficient('staff'));
     $HTML = '';
     if (Permission::sufficient('staff') && $PonyID !== 0) {
         $HTML .= "<input type='text' class='addtag tag' placeholder='Enter tag' pattern='" . TAG_NAME_PATTERN . "' maxlength='30' required>";
     }
     $HideSynon = Permission::sufficient('staff') && UserPrefs::get('cg_hidesynon');
     if (!empty($Tags)) {
         foreach ($Tags as $i => $t) {
             $isSynon = !empty($t['synonym_of']);
             $searchedFor = !empty($Search) && in_array($t['tid'], $Search['orig_tid']);
             if ($isSynon && $HideSynon && !$searchedFor) {
                 continue;
             }
             $class = " class='tag id-{$t['tid']}" . ($isSynon ? ' synonym' : '') . (!empty($t['type']) ? ' typ-' . $t['type'] : '') . "'";
             $title = !empty($t['title']) ? " title='" . CoreUtils::aposEncode($t['title']) . "'" : '';
             if ($searchedFor || Permission::insufficient('staff') && !empty($Search['tid_assoc'][$t['tid']])) {
                 $t['name'] = "<mark>{$t['name']}</mark>";
             }
             $syn_of = $isSynon ? " data-syn-of='{$t['synonym_of']}'" : '';
             $HTML .= "<span{$class}{$title}{$syn_of}>{$t['name']}</span>";
         }
     }
     return $wrap ? "<div class='tags'>{$HTML}</div>" : $HTML;
 }
示例#11
0
    if (isset($_GET['error_description'])) {
        $errdesc = $_GET['error_description'];
    }
    global $signedIn;
    if ($signedIn) {
        HTTP::redirect($_GET['state']);
    }
    Episodes::loadPage();
}
$currentUser = DeviantArt::getToken($_GET['code']);
$signedIn = !empty($currentUser);
if (isset($_GET['error'])) {
    $err = $_GET['error'];
    if (isset($_GET['error_description'])) {
        $errdesc = $_GET['error_description'];
    }
    if ($err === 'user_banned') {
        $errdesc .= "\n\nIf you'd like to appeal your ban, please <a href='http://mlp-vectorclub.deviantart.com/notes/'>send the group a note</a>.";
    }
    Episodes::loadPage();
}
if (preg_match(new RegExp('^[a-z\\d]+$', 'i'), $_GET['state'], $_match)) {
    $confirm = str_replace('{{CODE}}', $_match[0], file_get_contents(INCPATH . 'views/loginConfrim.html'));
    $confirm = str_replace('{{USERID}}', Permission::sufficient('developer') || UserPrefs::get('p_disable_ga') ? '' : $currentUser->id, $confirm);
    die($confirm);
} else {
    if (preg_match($REWRITE_REGEX, $_GET['state'])) {
        HTTP::redirect($_GET['state']);
    }
}
HTTP::redirect('/');
示例#12
0
use App\Permission;
use App\RegExp;
use App\Response;
use App\UserPrefs;
/** @var $data string */
if (!Permission::sufficient('user') || !POST_REQUEST) {
    CoreUtils::notFound();
}
CSRFProtection::protect();
if (!preg_match(new RegExp('^([gs]et)/([a-z_]+)$'), CoreUtils::trim($data), $_match)) {
    Response::fail('Preference key invalid');
}
$getting = $_match[1] === 'get';
$key = $_match[2];
// TODO Support changing some preferences of other users by staff
$currvalue = UserPrefs::get($key);
if ($getting) {
    Response::done(array('value' => $currvalue));
}
try {
    $newvalue = UserPrefs::process($key);
} catch (Exception $e) {
    Response::fail('Preference value error: ' . $e->getMessage());
}
if ($newvalue === $currvalue) {
    Response::done(array('value' => $newvalue));
}
if (!UserPrefs::set($key, $newvalue)) {
    Response::dbError();
}
Response::done(array('value' => $newvalue));