# the menu
$ViewMenu = 'system/menu.php';
# valid includes
-$_validPages["about"] = "about";
-
+$_validPages["domains"] = "domains";
+$_validPages["urls"] = "urls";
$_requestMode = "home";
if(isset($_GET['p']) && !empty($_GET['p'])) {
*/
protected array $_queryOptions;
+ /**
+ * The available sort columns.
+ * Used in query and sort options in FE
+ *
+ * @var array|array[]
+ */
+ protected array $_sortOptions = array();
+
/**
* Set the following options which can be used in DB queries
* array(
*
* @param array $options
*/
- protected function setQueryOptions(array $options): void {
+ public function setQueryOptions(array $options): void {
if(!isset($options['limit'])) $options['limit'] = 20;
if(!isset($options['offset'])) $options['offset'] = false;
$this->_queryOptions = $options;
}
+ /**
+ * Return the available sort options and the active used one
+ *
+ * @return array|array[]
+ */
+ public function getSortOptions(): array {
+ return $this->_sortOptions;
+ }
+
/**
* set some defaults by init of the class
*
class Domains extends Base {
+ /**
+ * The available sort columns.
+ * Used in query and sort options in FE
+ *
+ * @var array|array[]
+ */
+ public array $_sortOptions = array(
+ 'default' => array('col' => 'd.url', 'displayText' => 'URL (default)'),
+ 'created' => array('col' => 'd.created', 'displayText' => 'Created')
+ );
+
/**
* Domains constructor.
*
--- /dev/null
+<?php
+/**
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see http://www.gnu.org/licenses/gpl-3.0.
+ *
+ * 2022 - 2024 https://www.bananas-playground.net/projekt/aranea
+ */
+
+ /**
+ * Management class.
+ * Handles general stuff.
+ */
+
+class Management {
+ /**
+ * the database object
+ *
+ * @var mysqli
+ */
+ protected mysqli $_DB;
+
+ /**
+ * Management constructor.
+ *
+ * @param mysqli $databaseConnectionObject
+ */
+ public function __construct(mysqli $databaseConnectionObject) {
+ $this->_DB = $databaseConnectionObject;
+ }
+
+ /**
+ * Return the data from the stats table
+ *
+ * @return array
+ */
+ public function stats(): array {
+ $ret = array();
+
+ $queryStr = "SELECT `action`, `value`
+ FROM `stats`
+ ORDER BY `action` ASC";
+ if(QUERY_DEBUG) Helper::sysLog("[QUERY] ".__METHOD__." query: ".Helper::cleanForLog($queryStr));
+
+ try {
+ $query = $this->_DB->query($queryStr);
+
+ if($query !== false && $query->num_rows > 0) {
+ while(($result = $query->fetch_assoc()) != false) {
+ $ret[] = $result;
+ }
+ }
+ }
+ catch (Exception $e) {
+ Helper::sysLog("[ERROR] ".__METHOD__." mysql catch: ".$e->getMessage());
+ }
+
+ return $ret;
+ }
+}
--- /dev/null
+<?php
+/**
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see http://www.gnu.org/licenses/gpl-3.0.
+ *
+ * 2022 - 2024 https://www.bananas-playground.net/projekt/aranea
+ */
+
+$TemplateData['pageTitle'] = 'Domains';
+
+require_once 'lib/domains.class.php';
+$Domains = new Domains($DB);
+
+# pagination
+$TemplateData['pagination'] = array('pages' => 0, 'currentGetParameters' => array('p' => 'domains'));
+
+$_curPage = 1;
+if(isset($_GET['page']) && !empty($_GET['page'])) {
+ $_curPage = trim($_GET['page']);
+ $_curPage = Helper::validate($_curPage,'digit') ? $_curPage : 1;
+}
+
+$_sort = 'default';
+if(isset($_GET['s']) && !empty($_GET['s'])) {
+ $_sort = trim($_GET['s']);
+ $_sort = Helper::validate($_sort,'nospace') ? $_sort : 'default';
+}
+
+$_sortDirection = '';
+if(isset($_GET['sd']) && !empty($_GET['sd'])) {
+ $_sortDirection = trim($_GET['sd']);
+ $_sortDirection = Helper::validate($_sortDirection,'nospace') ? $_sortDirection : '';
+}
+
+$_rpp = RESULTS_PER_PAGE;
+if(isset($_GET['rpp']) && !empty($_GET['rpp'])) {
+ $_rpp = trim($_GET['rpp']);
+ $_rpp = Helper::validate($_rpp,'digit') ? $_rpp : RESULTS_PER_PAGE;
+}
+
+$queryOptions = array(
+ 'limit' => $_rpp,
+ 'offset' => ($_rpp * ($_curPage-1)),
+ 'sort' => $_sort,
+ 'sortDirection' => $_sortDirection
+);
+## pagination end
+
+
+
+## pagination
+if(!empty($TemplateData['searchresults']['amount'])) {
+ $TemplateData['pagination']['pages'] = (int)ceil($TemplateData['searchresults']['amount'] / $_rpp);
+ $TemplateData['pagination']['curPage'] = $_curPage;
+
+ $TemplateData['pagination']['currentGetParameters']['page'] = $_curPage;
+ $TemplateData['pagination']['currentGetParameters']['s'] = $_sort;
+ $TemplateData['pagination']['currentGetParameters']['sd'] = $_sortDirection;
+ $TemplateData['pagination']['currentGetParameters']['rpp'] = $_rpp;
+ $TemplateData['pagination']['sortOptions'] = $Domains->getSortOptions();
+}
+
+if($TemplateData['pagination']['pages'] > 11) {
+ # first pages
+ $TemplateData['pagination']['visibleRange'] = range(1,3);
+ # last pages
+ foreach(range($TemplateData['pagination']['pages']-2, $TemplateData['pagination']['pages']) as $e) {
+ $TemplateData['pagination']['visibleRange'][] = $e;
+ }
+ # pages before and after current page
+ $cRange = range($TemplateData['pagination']['curPage']-1, $TemplateData['pagination']['curPage']+1);
+ foreach($cRange as $e) {
+ $TemplateData['pagination']['visibleRange'][] = $e;
+ }
+ $TemplateData['pagination']['currentRangeStart'] = array_shift($cRange);
+ $TemplateData['pagination']['currentRangeEnd'] = array_pop($cRange);
+}
+else {
+ $TemplateData['pagination']['visibleRange'] = range(1,$TemplateData['pagination']['pages']);
+}
+## pagination end
--- /dev/null
+<?php
+/**
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see http://www.gnu.org/licenses/gpl-3.0.
+ *
+ * 2022 - 2024 https://www.bananas-playground.net/projekt/aranea
+ */
+?>
+<h1>Domains</h1>
require_once 'lib/urls.class.php';
$Urls = new Urls($DB);
+require_once 'lib/management.class.php';
+$Management = new Management($DB);
+
$TemplateData['latestDomains'] = $Domains->latest();
$TemplateData['latestUrls'] = $Urls->latest();
+$TemplateData['stats'] = $Management->stats();
<h1>Home</h1>
<div class="uk-grid uk-child-width-1-1 uk-child-width-1-2@m uk-child-width-1-3@l">
- <div>
+ <div class="uk-overflow-auto">
<h3>Latest Domains</h3>
<table class="uk-table uk-table-striped">
<thead>
</tbody>
</table>
</div>
- <div>
+ <div class="uk-overflow-auto">
<h3>Latest URLs</h3>
<table class="uk-table uk-table-striped">
<thead>
</tbody>
</table>
</div>
- <div>
+ <div class="uk-overflow-auto">
<h3>Info</h3>
<table class="uk-table uk-table-striped">
<thead>
</thead>
<tbody>
<?php
- if(!empty($TemplateData['latestUrls'])) {
- foreach($TemplateData['latestUrls'] as $k=>$value) {
+ if(!empty($TemplateData['stats'])) {
+ foreach($TemplateData['stats'] as $k=>$value) {
?>
<tr>
- <td><?php echo $value['url']; ?></a></td>
+ <td><?php echo $value['action']; ?></a></td>
+ <td><?php echo $value['value']; ?></a></td>
</tr>
<?php
}
*
* 2022 - 2024 https://www.bananas-playground.net/projekt/aranea
*/
+?>
+<nav class="uk-navbar-container">
+ <div class="uk-container">
+ <div class="uk-navbar">
+ <div class="uk-navbar-left">
+ <ul class="uk-navbar-nav">
+ <li>
+ <a class="uk-navbar-item uk-logo" href="index.php" aria-label="Back to Home">🕷</a>
+ </li>
+ <li class="<?php if($_requestMode == "domains") echo 'uk-active'; ?>">
+ <a href="index.php?p=packages">Domains</a>
+ </li>
+ <li class="<?php if($_requestMode == "urls") echo 'uk-active'; ?>">
+ <a href="index.php?p=categories">URLs</a>
+ </li>
+ <li class="<?php if($_requestMode == "stats") echo 'uk-active'; ?>">
+ <a href="index.php?p=stats">Stats</a>
+ </li>
+ </ul>
+ </div>
+ </div>
+ </div>
+</nav>