예제 #1
0
파일: About.php 프로젝트: ponydevs/MLPVC-RR
 static function getElasticSearchVersion()
 {
     try {
         $info = CoreUtils::elasticClient()->info();
     } catch (ElasticNoNodesAvailableException $e) {
         return;
     }
     return $info['version']['number'];
 }
예제 #2
0
파일: admin.php 프로젝트: ponydevs/MLPVC-RR
?>
</div>
	</section>

	<section class="mass-approve">
		<h2><span class="typcn typcn-tick"></span>Bulk approve posts</h2>
		<p>If you've approved a bunch of submissions and want to mark all of them as approved on the site, then, if you have the group watched you can visit <a href="http://www.deviantart.com/notifications/#view=groupdeviations%3A17450764" target="_blank">this link</a> to go directly to the stack containing the new items. Once you're there, press <kbd>Ctrl</kbd><kbd>A</kbd> (which will select the entire page) followed by <kbd>Ctrl</kbd><kbd>C</kbd> (copying the selected content), then click into the box below (you should see a blinking cursor afterwards) and finally hit <kbd>Ctrl</kbd><kbd>V</kbd>. The script will look through the page, collecting any deviation links it finds, then sends the IDs over to the server to mark them as approved if they were used to finish posts on the site.</p>
		<div class="textarea" contenteditable="true"></div>
	</section>

<?  if (Permission::sufficient('developer')){ ?>
	<section class="elastic-status">
		<h2>Elastic status</h2>
<?php 
try {
    $client = CoreUtils::elasticClient();
    $client->ping();
    ?>
		<pre><code><strong>Indices</strong><br><?php 
    echo $client->cat()->indices(['v' => true]);
    ?>
</code></pre>
		<pre><code><strong>Nodes</strong><br><?php 
    echo $client->cat()->nodes(['v' => true]);
    ?>
</code></pre>
<?php 
} catch (\Elasticsearch\Common\Exceptions\NoNodesAvailableException $e) {
    echo "<pre><code><strong>Server is down.</strong></code></pre>";
}
?>
예제 #3
0
            }
            $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)) {
            $queryString = new ElasticsearchDSL\Query\QueryStringQuery($SearchQuery, ['fields' => ['label^20', 'tags'], 'default_operator' => 'and', 'phrase_slop' => 3]);
            $search->addQuery($queryString);
            $orderByID = false;
예제 #4
0
 static function updateIndex(int $AppearanceID, string $fields = self::ELASTIC_COLUMNS) : array
 {
     global $CGDb;
     $Appearance = $CGDb->where('id', $AppearanceID)->getOne('appearances', $fields);
     try {
         CoreUtils::elasticClient()->update(self::toElasticArray($Appearance, false, true));
     } catch (ElasticNoNodesAvailableException $e) {
         error_log('ElasticSearch server was down when server attempted to index appearance ' . $AppearanceID);
     }
     return $Appearance;
 }