fix: some admin pages implementation

This commit is contained in:
Floorb 2023-05-12 02:06:31 -04:00
parent 0b4dd8f8f4
commit 708eb9be6f
37 changed files with 134 additions and 269 deletions

View file

@ -7,6 +7,13 @@ class AdminLog extends Model {
public const ACTION_LOGIN = 0; public const ACTION_LOGIN = 0;
public const ACTION_FAIL_LOGIN = 1; public const ACTION_FAIL_LOGIN = 1;
public const ACTION_EDIT_CONFIG = 2; public const ACTION_EDIT_CONFIG = 2;
public const ACTION_NAMES = [
'Login',
'Failed Login',
'Edit Config'
];
protected $table = 'admin_logs'; protected $table = 'admin_logs';
protected $fillable = ['user_id', 'action', 'ip', 'time']; protected $fillable = ['user_id', 'action', 'ip', 'time'];

View file

@ -309,4 +309,23 @@ function pp_filename_escape(string $filename, string $extension) : string {
} }
return $filename . $extension; return $filename . $extension;
}
function pp_setup_pagination() : array {
$per_page = 20;
$current_page = 0;
if (!empty($_GET['page'])) {
$current_page = max(0, intval($_GET['page']));
}
if (!empty($_GET['per_page'])) {
$per_page = max(1, min(100, intval($_GET['per_page'])));
}
return [$per_page, $current_page];
}
function pp_output_paginator(int $per_page, int $current_page) : void {
} }

View file

@ -14,7 +14,6 @@
"license": "MIT", "license": "MIT",
"dependencies": { "dependencies": {
"@rollup/plugin-commonjs": "^24.0.1", "@rollup/plugin-commonjs": "^24.0.1",
"@rollup/plugin-node-resolve": "^15.0.1", "@rollup/plugin-node-resolve": "^15.0.1"
"zxcvbn": "^4.4.2"
} }
} }

21
phpcs.xml Normal file
View file

@ -0,0 +1,21 @@
<ruleset name="MyStandard">
<description>My custom coding standard.</description>
<rule ref="PEAR">
<exclude name="PEAR.NamingConventions.ValidFunctionName"/>
<exclude name="PEAR.NamingConventions.ValidVariableName"/>
<exclude name="PEAR.Commenting.ClassComment"/>
<exclude name="Generic.Commenting.DocComment.MissingShort"/>
<exclude name="PEAR.Commenting.ClassComment.Missing"/>
<exclude name="PEAR.Commenting.FileComment.Missing"/>
<exclude name="PEAR.Commenting.FunctionComment.Missing"/>
<exclude name="PEAR.Functions.FunctionCallSignature.ContentAfterOpenBracket"/>
<exclude name="PEAR.Functions.FunctionCallSignature.CloseBracketLine"/>
<exclude name="PEAR.NamingConventions.ValidFunctionName.PrivateNoUnderscore"/>
<exclude name="PEAR.Commenting.FileComment.MissingCategoryTag"/>
<exclude name="PEAR.Commenting.FileComment.MissingPackageTag"/>
<exclude name="PEAR.Commenting.FileComment.MissingLinkTag"/>
<exclude name="PEAR.Commenting.FileComment.MissingVersion"/>
<exclude name="PEAR.Commenting.InlineComment"/>
<exclude name="Generic.PHP.DisallowShortOpenTag" />
</rule>
</ruleset>

16
psalm.xml Normal file
View file

@ -0,0 +1,16 @@
<?xml version="1.0"?>
<psalm
errorLevel="7"
resolveFromConfigFile="true"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns="https://getpsalm.org/schema/config"
xsi:schemaLocation="https://getpsalm.org/schema/config vendor/vimeo/psalm/config.xsd"
findUnusedBaselineEntry="true"
>
<projectFiles>
<directory name="includes" />
<ignoreFiles>
<directory name="vendor" />
</ignoreFiles>
</projectFiles>
</psalm>

View file

@ -127,13 +127,6 @@ $admin_logs = AdminLog::with('user')
<!-- Start Footer --> <!-- Start Footer -->
<div class="row footer"> <div class="row footer">
<div class="col-md-6 text-left">
<a href="https://github.com/jordansamuel/PASTE" target="_blank">Updates</a> &mdash; <a
href="https://github.com/jordansamuel/PASTE/issues" target="_blank">Bugs</a>
</div>
<div class="col-md-6 text-right">
Powered by <a href="https://phpaste.sourceforge.io" target="_blank">Paste</a>
</div>
</div> </div>
<!-- End Footer --> <!-- End Footer -->
</div> </div>

View file

@ -3,7 +3,7 @@ if (!defined('IN_PONEPASTE')) {
die('This file may not be accessed directly.'); die('This file may not be accessed directly.');
} }
require_once('../includes/common.php'); require_once('../../includes/common.php');
use PonePaste\Models\AdminLog; use PonePaste\Models\AdminLog;
use PonePaste\Models\User; use PonePaste\Models\User;

View file

@ -5,7 +5,7 @@ use PonePaste\Models\AdminLog;
define('IN_PONEPASTE', 1); define('IN_PONEPASTE', 1);
require_once('common.php'); require_once('common.php');
const CONFIG_FILE_PATH = '../config/site.php'; const CONFIG_FILE_PATH = '../../config/site.php';
function updateConfiguration(string $path, array $new_config) : void { function updateConfiguration(string $path, array $new_config) : void {
$fp = fopen($path, 'w'); $fp = fopen($path, 'w');
@ -366,32 +366,10 @@ if ($_SERVER['REQUEST_METHOD'] === 'POST') {
<!-- Start Footer --> <!-- Start Footer -->
<div class="row footer"> <div class="row footer">
<div class="col-md-6 text-left">
<a href="https://github.com/jordansamuel/PASTE" target="_blank">Updates</a> &mdash; <a
href="https://github.com/jordansamuel/PASTE/issues" target="_blank">Bugs</a>
</div>
<div class="col-md-6 text-right">
Powered by <a href="https://phpaste.sourceforge.io" target="_blank">Paste</a>
</div>
</div> </div>
<!-- End Footer --> <!-- End Footer -->
</div> </div>
<!-- End content --> <!-- End content -->
<script>
function show() {
document.getElementById('smtp_pass').setAttribute('type', 'text');
}
function hide() {
document.getElementById('smtp_pass').setAttribute('type', 'password');
}
if (document.getElementById('smtppasstoggle').hasAttribute('checked')) {
show();
} else {
hide();
}
</script>
</body> </body>
</html> </html>

View file

Before

Width:  |  Height:  |  Size: 402 KiB

After

Width:  |  Height:  |  Size: 402 KiB

View file

@ -1,6 +1,8 @@
<?php <?php
define('IN_PONEPASTE', 1); define('IN_PONEPASTE', 1);
require_once(__DIR__ . '/common.php'); require_once(__DIR__ . '/common.php');
use PonePaste\Models\AdminLog;
use PonePaste\Models\User; use PonePaste\Models\User;
use PonePaste\Models\Paste; use PonePaste\Models\Paste;
use PonePaste\Models\PageView; use PonePaste\Models\PageView;
@ -8,14 +10,6 @@ use PonePaste\Models\PageView;
$today_users_count = 0; $today_users_count = 0;
$today_pastes_count = 0; $today_pastes_count = 0;
$query = $conn->query("SELECT @last_id := MAX(id) FROM page_view");
$row = $query->fetch(PDO::FETCH_NUM);
$page_last_id = intval($row[0]);
$query = $conn->prepare('SELECT tpage, tvisit FROM page_view ORDER BY id DESC LIMIT 1');
$query->execute();
$row = $query->fetch();
$last_page_view = PageView::select('tpage', 'tvisit') $last_page_view = PageView::select('tpage', 'tvisit')
->orderBy('id', 'desc') ->orderBy('id', 'desc')
->first(); ->first();
@ -26,38 +20,32 @@ $admin_email = getSiteInfo()['site_info']['email'];
$c_date = date('jS F Y'); $c_date = date('jS F Y');
/* Number of users today */ /* Number of users today */
$query = $conn->prepare('SELECT COUNT(*) FROM users WHERE `date` = ?'); $today_users_count = User::where(['created_at' => 'TODAY()'])->count();
$query->execute([$c_date]);
$today_users_count = intval($query->fetch(PDO::FETCH_NUM)[0]);
/* Number of pastes today */ /* Number of pastes today */
$query = $conn->query('SELECT COUNT(*) FROM pastes where DATE(created_at) = DATE(NOW())'); $today_pastes_count = Paste::where(['created_at' => 'TODAY()'])->count();
$today_pastes_count = intval($query->fetch(PDO::FETCH_NUM)[0]);
for ($loop = 0; $loop <= 6; $loop++) {
$myid = $page_last_id - $loop;
$query = $conn->prepare("SELECT date, tpage, tvisit FROM page_view WHERE id = ?");
$query->execute([$myid]);
while ($row = $query->fetch()) { foreach (PageView::orderBy('id', 'desc')->take(7)->get() as $row) {
$sdate = $row['date']; $sdate = $row['date'];
$sdate = str_replace(date('Y'), '', $sdate); $sdate = str_replace(date('Y'), '', $sdate);
$sdate = str_replace('January', 'Jan', $sdate); $sdate = str_replace('January', 'Jan', $sdate);
$sdate = str_replace('February', 'Feb', $sdate); $sdate = str_replace('February', 'Feb', $sdate);
$sdate = str_replace('March', 'Mar', $sdate); $sdate = str_replace('March', 'Mar', $sdate);
$sdate = str_replace('April', 'Apr', $sdate); $sdate = str_replace('April', 'Apr', $sdate);
$sdate = str_replace('August', 'Aug', $sdate); $sdate = str_replace('August', 'Aug', $sdate);
$sdate = str_replace('September', 'Sep', $sdate); $sdate = str_replace('September', 'Sep', $sdate);
$sdate = str_replace('October', 'Oct', $sdate); $sdate = str_replace('October', 'Oct', $sdate);
$sdate = str_replace('November', 'Nov', $sdate); $sdate = str_replace('November', 'Nov', $sdate);
$sdate = str_replace('December', 'Dec', $sdate); $sdate = str_replace('December', 'Dec', $sdate);
$ldate[$loop] = $sdate; $ldate[] = $sdate;
$tpage[$loop] = $row['tpage']; $tpage[] = $row['tpage'];
$tvisit[$loop] = $row['tvisit']; $tvisit[] = $row['tvisit'];
}
} }
$admin_histories = AdminLog::with('user')->orderBy('id', 'desc')->take(10)->get();
function getRecentadmin($count = 5) { function getRecentadmin($count = 5) {
return Paste::with('user') return Paste::with('user')
->orderBy('id') ->orderBy('id')
@ -147,7 +135,6 @@ function getRecentadmin($count = 5) {
<table class="table table-hover"> <table class="table table-hover">
<thead> <thead>
<tr> <tr>
<td>ID</td>
<td>Username</td> <td>Username</td>
<td>Date</td> <td>Date</td>
<td>IP</td> <td>IP</td>
@ -230,36 +217,24 @@ function getRecentadmin($count = 5) {
</div> </div>
<div class="panel-body table-responsive"> <div class="panel-body table-responsive">
<table class="table table-hover"> <table class="table table-hover">
<thead> <thead>
<tr> <tr>
<td>ID</td> <td>Username</td>
<td>Last Login Date</td> <td>Date</td>
<td>IP</td> <td>Action</td>
<td>ID</td> <td>IP Address</td>
<td>Last Login Date</td>
</tr> </tr>
</thead> </thead>
<tbody> <tbody>
<?php <?php foreach ($admin_histories as $entry): ?>
$res = getreports($conn, 7); <tr>
foreach ($res as $row) { <td><?= pp_html_escape($entry->user->username); ?></td>
$r_paste = Trim($row['p_report']); <td><?= pp_html_escape($entry->time); ?></td>
$r_id = Trim($row['id']); <td><?= pp_html_escape(AdminLog::ACTION_NAMES[$entry->action]); ?></td>
$r_date = Trim($row['t_report']); <td><?= pp_html_escape($entry->ip); ?></td>
$m_report = Trim($row['m_report']); </tr>
$r_reason = Trim($row['rep_reason']); <?php endforeach; ?>
echo '
<tr>
<td>' . $r_id . '</td>
<td>' . $r_paste . '</td>
<td>' . $m_report . '</td>
<td>' . $r_date . '</td>
<td>' . $r_reason . '</td>
</tr> ';
}
?>
</tbody> </tbody>
</table> </table>
@ -267,30 +242,12 @@ function getRecentadmin($count = 5) {
</div> </div>
</div> </div>
<!-- End Admin History --> <!-- End Admin History -->
<div class="col-md-12 col-lg-6">
<div class="panel panel-widget">
<div class="panel-title">
</div>
<p style="height: auto;">
<br/>You have the latest version
</p>
</div>
</div>
</div> </div>
</div> </div>
<!-- END CONTAINER --> <!-- END CONTAINER -->
<!-- Start Footer --> <!-- Start Footer -->
<div class="row footer"> <div class="row footer">
<div class="col-md-6 text-left">
<a href="https://github.com/jordansamuel/PASTE" target="_blank">Updates</a> &mdash; <a
href="https://github.com/jordansamuel/PASTE/issues" target="_blank">Bugs</a>
</div>
<div class="col-md-6 text-right">
A fork of <a href="https://phpaste.sourceforge.io" target="_blank">Paste</a>
</div>
</div> </div>
<!-- End Footer --> <!-- End Footer -->

View file

Before

Width:  |  Height:  |  Size: 15 KiB

After

Width:  |  Height:  |  Size: 15 KiB

View file

@ -1,6 +1,6 @@
<?php <?php
define('IN_PONEPASTE', 1); define('IN_PONEPASTE', 1);
require_once(__DIR__ . '/../includes/common.php'); require_once(__DIR__ . '/../../includes/common.php');
use PonePaste\Models\User; use PonePaste\Models\User;
use PonePaste\Models\AdminLog; use PonePaste\Models\AdminLog;
@ -21,7 +21,7 @@ if ($current_user === null || !$current_user->admin) {
} }
if ($_SERVER['REQUEST_METHOD'] == 'POST') { if ($_SERVER['REQUEST_METHOD'] == 'POST') {
if (password_verify($_POST['password'], $current_user->admin_password_hash)) { if (pp_password_verify($_POST['password'], $current_user->admin_password_hash)) {
updateAdminHistory($current_user, AdminLog::ACTION_LOGIN); updateAdminHistory($current_user, AdminLog::ACTION_LOGIN);
$_SESSION['admin_login'] = true; $_SESSION['admin_login'] = true;
header("Location: dashboard.php"); header("Location: dashboard.php");

View file

@ -263,13 +263,6 @@ if (isset($_GET['delete'])) {
<!-- Start Footer --> <!-- Start Footer -->
<div class="row footer"> <div class="row footer">
<div class="col-md-6 text-left">
<a href="https://github.com/jordansamuel/PASTE" target="_blank">Updates</a> &mdash; <a
href="https://github.com/jordansamuel/PASTE/issues" target="_blank">Bugs</a>
</div>
<div class="col-md-6 text-right">
Powered by <a href="https://phpaste.sourceforge.io" target="_blank">Paste</a>
</div>
</div> </div>
<!-- End Footer --> <!-- End Footer -->
</div> </div>

View file

@ -25,9 +25,6 @@
<li class="col-xs-3 col-sm-2 col-md-1"> <li class="col-xs-3 col-sm-2 col-md-1">
<a href="stats.php"><i class="fa fa-line-chart"></i>Statistics</a> <a href="stats.php"><i class="fa fa-line-chart"></i>Statistics</a>
</li> </li>
<li class="col-xs-3 col-sm-2 col-md-1">
<a href="ads.php"><i class="fa fa-gbp"></i>Ads</a>
</li>
<li class="col-xs-3 col-sm-2 col-md-1"> <li class="col-xs-3 col-sm-2 col-md-1">
<a href="sitemap.php"><i class="fa fa-map-signs"></i>Sitemap</a> <a href="sitemap.php"><i class="fa fa-map-signs"></i>Sitemap</a>
</li> </li>

View file

@ -209,27 +209,11 @@ require_once('common.php');
<!-- Start Footer --> <!-- Start Footer -->
<div class="row footer"> <div class="row footer">
<div class="col-md-6 text-left">
<a href="https://github.com/jordansamuel/PASTE" target="_blank">Updates</a> &mdash; <a
href="https://github.com/jordansamuel/PASTE/issues" target="_blank">Bugs</a>
</div>
<div class="col-md-6 text-right">
Powered by <a href="https://phpaste.sourceforge.io" target="_blank">Paste</a>
</div>
</div> </div>
<!-- End Footer --> <!-- End Footer -->
</div> </div>
<!-- End content --> <!-- End content -->
<script type="text/javascript" language="javascript" class="init">
$(document).ready(function () {
$('#pastesTable').dataTable({
"processing": true,
"serverSide": true,
"ajax": "ajax_pastes.php"
});
});
</script>
</body> </body>
</html> </html>

View file

@ -18,41 +18,6 @@ if (isset($_GET['logout'])) {
$date = date('jS F Y'); $date = date('jS F Y');
$ip = $_SERVER['REMOTE_ADDR']; $ip = $_SERVER['REMOTE_ADDR'];
require_once('../includes/config.php'); require_once('../includes/config.php');
$con = mysqli_connect($dbhost, $dbuser, $dbpassword, $dbname);
if (mysqli_connect_errno()) {
$sql_error = mysqli_connect_error();
die("Unable connect to database");
}
$query = "SELECT @last_id := MAX(id) FROM admin_history";
$result = mysqli_query($con, $query);
while ($row = mysqli_fetch_array($result)) {
$last_id = $row['@last_id := MAX(id)'];
}
$query = "SELECT * FROM admin_history WHERE id=" . Trim($last_id);
$result = mysqli_query($con, $query);
while ($row = mysqli_fetch_array($result)) {
$last_date = $row['last_date'];
$last_ip = $row['ip'];
}
if ($last_ip == $ip) {
if ($last_date == $date) {
} else {
$query = "INSERT INTO admin_history (last_date,ip) VALUES ('$date','$ip')";
mysqli_query($con, $query);
}
} else {
$query = "INSERT INTO admin_history (last_date,ip) VALUES ('$date','$ip')";
mysqli_query($con, $query);
}
?> ?>

View file

@ -311,13 +311,6 @@ if ($last_ip == $ip) {
<!-- Start Footer --> <!-- Start Footer -->
<div class="row footer"> <div class="row footer">
<div class="col-md-6 text-left">
<a href="https://github.com/jordansamuel/PASTE" target="_blank">Updates</a> &mdash; <a
href="https://github.com/jordansamuel/PASTE/issues" target="_blank">Bugs</a>
</div>
<div class="col-md-6 text-right">
Powered by <a href="https://phpaste.sourceforge.io" target="_blank">Paste</a>
</div>
</div> </div>
<!-- End Footer --> <!-- End Footer -->
</div> </div>

View file

@ -1,6 +1,16 @@
<?php <?php
use PonePaste\Models\User;
define('IN_PONEPASTE', 1); define('IN_PONEPASTE', 1);
require_once(__DIR__ . '/common.php'); require_once(__DIR__ . '/common.php');
list($per_page, $current_page) = pp_setup_pagination();
$total_users = User::count();
$all_users = User::limit($per_page)->offset($current_page * $per_page)->get();
?> ?>
<!DOCTYPE html> <!DOCTYPE html>
@ -41,54 +51,6 @@ require_once(__DIR__ . '/common.php');
<!-- START CONTAINER --> <!-- START CONTAINER -->
<div class="container-widget"> <div class="container-widget">
<?php include 'menu.php'; ?> <?php include 'menu.php'; ?>
<!-- End Menu -->
<?php
if (isset($_GET['delete'])) {
$user_id = htmlentities(Trim($_GET['delete']));
$query = "DELETE FROM users WHERE id=$user_id";
$result = mysqli_query($con, $query);
if (mysqli_errno($con)) {
$msg = '<div class="paste-alert alert6" style="text-align: center;">
' . mysqli_error($con) . '
</div>';
} else {
$msg = '<div class="paste-alert alert3" style="text-align: center;">
User deleted
</div>';
}
}
if (isset($_GET['ban'])) {
$ban_id = htmlentities(Trim($_GET['ban']));
$query = "UPDATE users SET verified='2' WHERE id='$ban_id'";
$result = mysqli_query($con, $query);
if (mysqli_errno($con)) {
$msg = '<div class="paste-alert alert6" style="text-align: center;">
' . mysqli_error($con) . '
</div>';
} else {
$msg = '<div class="paste-alert alert3" style="text-align: center;">
User banned
</div>';
}
}
if (isset($_GET['unban'])) {
$ban_id = htmlentities(Trim($_GET['unban']));
$query = "UPDATE users SET verified='1' WHERE id='$ban_id'";
$result = mysqli_query($con, $query);
if (mysqli_errno($con)) {
$msg = '<div class="paste-alert alert6" style="text-align: center;">
' . mysqli_error($con) . '
</div>';
} else {
$msg = '<div class="paste-alert alert3" style="text-align: center;">
User unbanned
</div>';
}
}
?>
<!-- Start Users --> <!-- Start Users -->
<div class="row"> <div class="row">
@ -149,7 +111,6 @@ require_once(__DIR__ . '/common.php');
id="usersTable"> id="usersTable">
<thead> <thead>
<tr> <tr>
<th>ID</th>
<th>Username</th> <th>Username</th>
<th>Date Registered</th> <th>Date Registered</th>
<th>Ban User</th> <th>Ban User</th>
@ -158,9 +119,17 @@ require_once(__DIR__ . '/common.php');
</tr> </tr>
</thead> </thead>
<tbody> <tbody>
<?php foreach ($all_users as $user): ?>
<tr>
<td>
<a href="<?= urlForMember($user); ?>"><?= pp_html_escape($user->username); ?></a>
</td>
<td><?= pp_html_escape($user->created_at); ?> </td>
</tr>
<?php endforeach; ?>
</tbody> </tbody>
</table> </table>
<?= paginate($current_page, $per_page, $total_users); ?>
</div> </div>
<?php } ?> <?php } ?>
</div> </div>
@ -172,28 +141,10 @@ require_once(__DIR__ . '/common.php');
<!-- Start Footer --> <!-- Start Footer -->
<div class="row footer"> <div class="row footer">
<div class="col-md-6 text-left">
<a href="https://github.com/jordansamuel/PASTE" target="_blank">Updates</a> &mdash; <a
href="https://github.com/jordansamuel/PASTE/issues" target="_blank">Bugs</a>
</div>
<div class="col-md-6 text-right">
Powered by <a href="https://phpaste.sourceforge.io" target="_blank">Paste</a>
</div>
</div> </div>
<!-- End Footer --> <!-- End Footer -->
</div> </div>
<!-- End content --> <!-- End content -->
<script type="text/javascript" language="javascript" class="init">
$(document).ready(function () {
$('#usersTable').dataTable({
"processing": true,
"serverSide": true,
"ajax": "ajax_users.php",
"order": [[0, "desc"]]
});
});
</script>
<script type="text/javascript" src="js/bootstrap.min.js"></script>
</body> </body>
</html> </html>

View file

@ -1,15 +0,0 @@
<main class="bd-main">
<div class="bd-side-background"></div>
<div class="bd-main-container container">
<div class="bd-duo">
<div class="bd-lead">
<h1 class="title is-5">Paste Reported
<h1>
<p class="help is-danger subtitle is-6"><?php echo $repmes; ?></p>
<a href="./" class="btn btn-default">New Paste</a><br>
<a href="./archive" class="btn btn-default">Archive</a><br>
<a href="./discover" class="btn btn-default">Discover</a>
</div>
</div>
</div>
</main>

View file

@ -98,7 +98,7 @@ class InstalledVersions
{ {
foreach (self::getInstalled() as $installed) { foreach (self::getInstalled() as $installed) {
if (isset($installed['versions'][$packageName])) { if (isset($installed['versions'][$packageName])) {
return $includeDevRequirements || empty($installed['versions'][$packageName]['dev_requirement']); return $includeDevRequirements || !isset($installed['versions'][$packageName]['dev_requirement']) || $installed['versions'][$packageName]['dev_requirement'] === false;
} }
} }
@ -119,7 +119,7 @@ class InstalledVersions
*/ */
public static function satisfies(VersionParser $parser, $packageName, $constraint) public static function satisfies(VersionParser $parser, $packageName, $constraint)
{ {
$constraint = $parser->parseConstraints($constraint); $constraint = $parser->parseConstraints((string) $constraint);
$provided = $parser->parseConstraints(self::getVersionRanges($packageName)); $provided = $parser->parseConstraints(self::getVersionRanges($packageName));
return $provided->matches($constraint); return $provided->matches($constraint);
@ -328,7 +328,9 @@ class InstalledVersions
if (isset(self::$installedByVendor[$vendorDir])) { if (isset(self::$installedByVendor[$vendorDir])) {
$installed[] = self::$installedByVendor[$vendorDir]; $installed[] = self::$installedByVendor[$vendorDir];
} elseif (is_file($vendorDir.'/composer/installed.php')) { } elseif (is_file($vendorDir.'/composer/installed.php')) {
$installed[] = self::$installedByVendor[$vendorDir] = require $vendorDir.'/composer/installed.php'; /** @var array{root: array{name: string, pretty_version: string, version: string, reference: string|null, type: string, install_path: string, aliases: string[], dev: bool}, versions: array<string, array{pretty_version?: string, version?: string, reference?: string|null, type?: string, install_path?: string, aliases?: string[], dev_requirement: bool, replaced?: string[], provided?: string[]}>} $required */
$required = require $vendorDir.'/composer/installed.php';
$installed[] = self::$installedByVendor[$vendorDir] = $required;
if (null === self::$installed && strtr($vendorDir.'/composer', '\\', '/') === strtr(__DIR__, '\\', '/')) { if (null === self::$installed && strtr($vendorDir.'/composer', '\\', '/') === strtr(__DIR__, '\\', '/')) {
self::$installed = $installed[count($installed) - 1]; self::$installed = $installed[count($installed) - 1];
} }
@ -340,12 +342,17 @@ class InstalledVersions
// only require the installed.php file if this file is loaded from its dumped location, // only require the installed.php file if this file is loaded from its dumped location,
// and not from its source location in the composer/composer package, see https://github.com/composer/composer/issues/9937 // and not from its source location in the composer/composer package, see https://github.com/composer/composer/issues/9937
if (substr(__DIR__, -8, 1) !== 'C') { if (substr(__DIR__, -8, 1) !== 'C') {
self::$installed = require __DIR__ . '/installed.php'; /** @var array{root: array{name: string, pretty_version: string, version: string, reference: string|null, type: string, install_path: string, aliases: string[], dev: bool}, versions: array<string, array{pretty_version?: string, version?: string, reference?: string|null, type?: string, install_path?: string, aliases?: string[], dev_requirement: bool, replaced?: string[], provided?: string[]}>} $required */
$required = require __DIR__ . '/installed.php';
self::$installed = $required;
} else { } else {
self::$installed = array(); self::$installed = array();
} }
} }
$installed[] = self::$installed;
if (self::$installed !== array()) {
$installed[] = self::$installed;
}
return $installed; return $installed;
} }

View file

@ -3,7 +3,7 @@
'name' => 'aftercase/ponepaste', 'name' => 'aftercase/ponepaste',
'pretty_version' => 'dev-main', 'pretty_version' => 'dev-main',
'version' => 'dev-main', 'version' => 'dev-main',
'reference' => '7be5984b3eea1200a34b91ba7330a415e3a61ff5', 'reference' => '9bd921ee714769fcddbcbbd0d7c49a64336794f9',
'type' => 'library', 'type' => 'library',
'install_path' => __DIR__ . '/../../', 'install_path' => __DIR__ . '/../../',
'aliases' => array(), 'aliases' => array(),
@ -13,7 +13,7 @@
'aftercase/ponepaste' => array( 'aftercase/ponepaste' => array(
'pretty_version' => 'dev-main', 'pretty_version' => 'dev-main',
'version' => 'dev-main', 'version' => 'dev-main',
'reference' => '7be5984b3eea1200a34b91ba7330a415e3a61ff5', 'reference' => '9bd921ee714769fcddbcbbd0d7c49a64336794f9',
'type' => 'library', 'type' => 'library',
'install_path' => __DIR__ . '/../../', 'install_path' => __DIR__ . '/../../',
'aliases' => array(), 'aliases' => array(),