Skip to content

Commit eddd5c4

Browse files
committed
3.7.3
1 parent 798deac commit eddd5c4

File tree

29 files changed

+2208
-2226
lines changed

29 files changed

+2208
-2226
lines changed

.github/workflows/operations.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,8 @@ jobs:
2222

2323
- name: Setup PHP
2424
run: |
25-
curl -fsSL https://packages.sury.org/php/apt.gpg| gpg --dearmor -o /etc/apt/trusted.gpg.d/sury-keyring.gpg
26-
echo "deb https://packages.sury.org/php/ bullseye main" | tee /etc/apt/sources.list.d/sury-php.list
25+
curl -sS https://packages.bespin.ovh/repo/gpgkeys/packages.bespin.ovh.pub | gpg --dearmor > /etc/apt/trusted.gpg.d/packages.bespin.ovh.gpg
26+
echo "deb https://packages.bespin.ovh/repo/repomanager-php/bullseye/main_prod bullseye main" > /etc/apt/sources.list.d/php.list
2727
2828
- name: Install PHP modules
2929
run: apt-get update && apt-get install -y php8.1-fpm php8.1-cli php8.1-sqlite3 php8.1-xml php8.1-curl sqlite3

docker/Dockerfile

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,8 +26,8 @@ RUN apt-get install postfix -y
2626

2727
# Add nginx and PHP 8.1 repositories
2828
RUN curl -sS https://packages.bespin.ovh/repo/gpgkeys/packages.bespin.ovh.pub | gpg --dearmor > /etc/apt/trusted.gpg.d/packages.bespin.ovh.gpg
29-
RUN echo "deb https://packages.bespin.ovh/repo/repomanager-nginx/bullseye/nginx_prod bullseye nginx" > /etc/apt/sources.list.d/repomanager-repomanager-nginx_bullseye_nginx.list
30-
RUN echo "deb https://packages.bespin.ovh/repo/repomanager-docker/bullseye/main_prod bullseye main" > /etc/apt/sources.list.d/repomanager-repomanager-docker_bullseye_main.list
29+
RUN echo "deb https://packages.bespin.ovh/repo/repomanager-nginx/bullseye/nginx_prod bullseye nginx" > /etc/apt/sources.list.d/nginx.list
30+
RUN echo "deb https://packages.bespin.ovh/repo/repomanager-php/bullseye/main_prod bullseye main" > /etc/apt/sources.list.d/php.list
3131
RUN apt-get update -y
3232

3333
# Install nginx and PHP 8.1
@@ -52,6 +52,7 @@ RUN rm -rf /etc/nginx/sites-enabled/default /var/www/html
5252
# Configure PHP
5353
RUN cp /tmp/repomanager/docker/config/php/www.conf /etc/php/8.1/fpm/pool.d/www.conf
5454
RUN sed -i "s/^upload_max_filesize.*$/upload_max_filesize = $max_upload_size/g" /etc/php/8.1/fpm/php.ini
55+
RUN sed -i "s/^post_max_size.*$/post_max_size = $max_upload_size/g" /etc/php/8.1/fpm/php.ini
5556

5657
# Configure SQLite
5758
RUN echo ".headers on" > /root/.sqliterc

docker/entrypoint.sh

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ if [ ! -z "$MAX_UPLOAD_SIZE" ];then
2323
sed -i "s/client_max_body_size.*$/client_max_body_size ${MAX_UPLOAD_SIZE};/g" /etc/nginx/sites-enabled/repomanager.conf
2424
# PHP configuration
2525
sed -i "s/^upload_max_filesize.*$/upload_max_filesize = ${MAX_UPLOAD_SIZE}/g" /etc/php/8.1/fpm/php.ini
26+
sed -i "s/^post_max_size.*$/post_max_size = ${MAX_UPLOAD_SIZE}/g" /etc/php/8.1/fpm/php.ini
2627
fi
2728

2829
# Start services

notifications/notifications.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"NT01" : {
33
"title" : "Welcome to Repomanager",
4-
"message" : "Hey! This is the notification section, sometimes you will see some important messages here. <br><br>For any help, please check out the <a href='https://github.com/lbr38/repomanager/wiki'>documentation</a> or feel free to add an issue on <a href='https://github.com/lbr38/repomanager/issues'>github</a>."
4+
"message" : "Hey! This is the notification section, sometimes you will see some important messages here. <br><br>For any help, please check out the documentation <a href='https://github.com/lbr38/repomanager/wiki'>here</a> or feel free to add an issue on <a href='https://github.com/lbr38/repomanager/issues'>github</a>."
55
}
66
}

www/controllers/App/Config/System.php

Lines changed: 22 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -25,18 +25,22 @@ public static function get()
2525
/**
2626
* Server url
2727
*/
28-
if (!empty($_SERVER['SERVER_NAME'])) {
29-
if (!defined('__SERVER_URL__')) {
28+
if (!defined('__SERVER_URL__')) {
29+
if (!empty($_SERVER['HTTP_HOST'])) {
3030
define('__SERVER_URL__', __SERVER_PROTOCOL__ . '://' . $_SERVER['HTTP_HOST']);
31+
} else {
32+
define('__SERVER_URL__', '');
3133
}
3234
}
3335

3436
/**
3537
* Server IP
3638
*/
37-
if (!empty($_SERVER['SERVER_ADDR'])) {
38-
if (!defined('__SERVER_IP__')) {
39+
if (!defined('__SERVER_IP__')) {
40+
if (!empty($_SERVER['SERVER_ADDR'])) {
3941
define('__SERVER_IP__', $_SERVER['SERVER_ADDR']);
42+
} else {
43+
define('__SERVER_IP__', '');
4044
}
4145
}
4246

@@ -50,7 +54,11 @@ public static function get()
5054
if (!empty($_POST['sourceUrl'])) {
5155
define('__ACTUAL_URL__', $_POST['sourceUrl']);
5256
} else {
53-
define('__ACTUAL_URL__', __SERVER_PROTOCOL__ . '://' . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI']);
57+
if (!empty($_SERVER['HTTP_HOST']) and !empty($_SERVER['REQUEST_URI'])) {
58+
define('__ACTUAL_URL__', __SERVER_PROTOCOL__ . '://' . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI']);
59+
} else {
60+
define('__ACTUAL_URL__', '');
61+
}
5462
}
5563
}
5664

@@ -64,16 +72,22 @@ public static function get()
6472
if (!empty($_POST['sourceUri'])) {
6573
define('__ACTUAL_URI__', explode('/', $_POST['sourceUri']));
6674
} else {
67-
define('__ACTUAL_URI__', explode('/', parse_url($_SERVER["REQUEST_URI"], PHP_URL_PATH)));
75+
if (!empty($_SERVER["REQUEST_URI"])) {
76+
define('__ACTUAL_URI__', explode('/', parse_url($_SERVER["REQUEST_URI"], PHP_URL_PATH)));
77+
} else {
78+
define('__ACTUAL_URI__', '');
79+
}
6880
}
6981
}
7082

7183
/**
7284
* Parameters
7385
*/
74-
if (!empty($_SERVER['QUERY_STRING'])) {
75-
if (!defined('__QUERY_STRING__')) {
86+
if (!defined('__QUERY_STRING__')) {
87+
if (!empty($_SERVER['QUERY_STRING'])) {
7688
define('__QUERY_STRING__', parse_url($_SERVER["QUERY_STRING"], PHP_URL_PATH));
89+
} else {
90+
define('__QUERY_STRING__', '');
7791
}
7892
}
7993

www/controllers/Layout/Container/vars/stats/list.vars.inc.php

Lines changed: 179 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -17,23 +17,191 @@
1717
*/
1818
$myrepo->getAllById('', '', $envId);
1919

20+
/**
21+
* Snapshot access stats
22+
*/
23+
2024
/**
2125
* If a filter has been selected for the main chart, the page is reloaded in the background by jquery and retrieves the chart data from the selected filter
2226
*/
23-
if (!empty($_GET['repo_access_chart_filter'])) {
24-
if (\Controllers\Common::validateData($_GET['repo_access_chart_filter']) == "1week") {
25-
$repo_access_chart_filter = "1week";
27+
if (!empty($_GET['chartFilter'])) {
28+
if (\Controllers\Common::validateData($_GET['chartFilter']) == "1week") {
29+
$chartFilter = "1week";
2630
}
27-
if (\Controllers\Common::validateData($_GET['repo_access_chart_filter']) == "1month") {
28-
$repo_access_chart_filter = "1month";
31+
if (\Controllers\Common::validateData($_GET['chartFilter']) == "1month") {
32+
$chartFilter = "1month";
2933
}
30-
if (\Controllers\Common::validateData($_GET['repo_access_chart_filter']) == "3months") {
31-
$repo_access_chart_filter = "3months";
34+
if (\Controllers\Common::validateData($_GET['chartFilter']) == "3months") {
35+
$chartFilter = "3months";
3236
}
33-
if (\Controllers\Common::validateData($_GET['repo_access_chart_filter']) == "6months") {
34-
$repo_access_chart_filter = "6months";
37+
if (\Controllers\Common::validateData($_GET['chartFilter']) == "6months") {
38+
$chartFilter = "6months";
3539
}
36-
if (\Controllers\Common::validateData($_GET['repo_access_chart_filter']) == "1year") {
37-
$repo_access_chart_filter = "1year";
40+
if (\Controllers\Common::validateData($_GET['chartFilter']) == "1year") {
41+
$chartFilter = "1year";
3842
}
3943
}
44+
45+
/**
46+
* Retrieve last access logs from database
47+
*/
48+
if ($myrepo->getPackageType() == 'rpm') {
49+
$lastAccess = $mystats->getLastAccess($myrepo->getName(), '', '', $myrepo->getEnv());
50+
}
51+
if ($myrepo->getPackageType() == 'deb') {
52+
$lastAccess = $mystats->getLastAccess($myrepo->getName(), $myrepo->getDist(), $myrepo->getSection(), $myrepo->getEnv());
53+
}
54+
55+
/**
56+
* Sort by date and time
57+
*/
58+
if (!empty($lastAccess)) {
59+
array_multisort(array_column($lastAccess, 'Date'), SORT_DESC, array_column($lastAccess, 'Time'), SORT_DESC, $lastAccess);
60+
}
61+
62+
/**
63+
* Count repo size and packages count
64+
*/
65+
if ($myrepo->getPackageType() == 'rpm') {
66+
$repoSize = \Controllers\Filesystem\Directory::getSize(REPOS_DIR . '/' . $myrepo->getDateFormatted() . '_' . $myrepo->getName());
67+
$packagesCount = count(\Controllers\Common::findRecursive(REPOS_DIR . '/' . $myrepo->getDateFormatted() . '_' . $myrepo->getName(), 'rpm'));
68+
}
69+
if ($myrepo->getPackageType() == 'deb') {
70+
$repoSize = \Controllers\Filesystem\Directory::getSize(REPOS_DIR . '/' . $myrepo->getName() . '/' . $myrepo->getDist() . '/' . $myrepo->getDateFormatted() . '_' . $myrepo->getSection());
71+
$packagesCount = count(\Controllers\Common::findRecursive(REPOS_DIR . '/' . $myrepo->getName() . '/' . $myrepo->getDist() . '/' . $myrepo->getDateFormatted() . '_' . $myrepo->getSection(), 'deb'));
72+
}
73+
74+
/**
75+
* Convert repo size in the most suitable byte format
76+
*/
77+
$repoSize = \Controllers\Common::sizeFormat($repoSize);
78+
79+
/**
80+
* If no filter has been selected by the user then we set it to 1 week by default
81+
*/
82+
if (empty($chartFilter)) {
83+
$chartFilter = "1week";
84+
}
85+
86+
/**
87+
* Initialize the starting date of the chart, according to the selected filter
88+
*/
89+
if ($chartFilter == "1week") {
90+
// the beginning of the counter starts at the current date -1 week.
91+
$dateCounter = date('Y-m-d', strtotime('-1 week', strtotime(DATE_YMD)));
92+
}
93+
if ($chartFilter == "1month") {
94+
// the beginning of the counter starts at the current date -1 month.
95+
$dateCounter = date('Y-m-d', strtotime('-1 month', strtotime(DATE_YMD)));
96+
}
97+
if ($chartFilter == "3months") {
98+
// the beginning of the counter starts at the current date -3 months.
99+
$dateCounter = date('Y-m-d', strtotime('-3 months', strtotime(DATE_YMD)));
100+
}
101+
if ($chartFilter == "6months") {
102+
// the beginning of the counter starts at the current date -6 months.
103+
$dateCounter = date('Y-m-d', strtotime('-6 months', strtotime(DATE_YMD)));
104+
}
105+
if ($chartFilter == "1year") {
106+
// the beginning of the counter starts at the current date -1 year.
107+
$dateCounter = date('Y-m-d', strtotime('-1 year', strtotime(DATE_YMD)));
108+
}
109+
110+
$repoAccessChartLabels = '';
111+
$repoAccessChartData = '';
112+
113+
/**
114+
* Process all dates until the current date (which is also processed)
115+
*/
116+
while ($dateCounter != date('Y-m-d', strtotime('+1 day', strtotime(DATE_YMD)))) {
117+
if ($myrepo->getPackageType() == 'rpm') {
118+
$dateAccessCount = $mystats->getDailyAccessCount($myrepo->getName(), '', '', $myrepo->getEnv(), $dateCounter);
119+
}
120+
if ($myrepo->getPackageType() == 'deb') {
121+
$dateAccessCount = $mystats->getDailyAccessCount($myrepo->getName(), $myrepo->getDist(), $myrepo->getSection(), $myrepo->getEnv(), $dateCounter);
122+
}
123+
124+
if (!empty($dateAccessCount)) {
125+
$repoAccessChartData .= $dateAccessCount . ', ';
126+
} else {
127+
$repoAccessChartData .= '0, ';
128+
}
129+
130+
/**
131+
* Add the current date to the labels
132+
*/
133+
$repoAccessChartLabels .= "'$dateCounter', ";
134+
135+
/**
136+
* Increment by 1 day to be able to process the next date
137+
*/
138+
$dateCounter = date('Y-m-d', strtotime('+1 day', strtotime($dateCounter)));
139+
}
140+
141+
/**
142+
* Remove the last comma
143+
*/
144+
$repoAccessChartLabels = rtrim($repoAccessChartLabels, ', ');
145+
$repoAccessChartData = rtrim($repoAccessChartData, ', ');
146+
147+
/**
148+
* Snapshot size stats
149+
*/
150+
151+
/**
152+
* Get stats for the last 60 days
153+
*/
154+
$stats = $mystats->getAll($myrepo->getEnvId());
155+
$envSizeStats = $mystats->getEnvSize($myrepo->getEnvId(), 60);
156+
157+
if (!empty($envSizeStats)) {
158+
$sizeDateLabels = '';
159+
$sizeData = '';
160+
161+
foreach ($envSizeStats as $stat) {
162+
$date = DateTime::createFromFormat('Y-m-d', $stat['Date'])->format('d-m-Y');
163+
164+
// Convert bytes to MB
165+
$size = round(round($stat['Size'] / 1024) / 1024);
166+
167+
/**
168+
* Build data for chart
169+
*/
170+
$sizeDateLabels .= '"' . $date . '", ';
171+
$sizeData .= '"' . $size . '", ';
172+
}
173+
174+
/**
175+
* Remove last comma
176+
*/
177+
$sizeDateLabels = rtrim($sizeDateLabels, ', ');
178+
$sizeData = rtrim($sizeData, ', ');
179+
}
180+
181+
/**
182+
* Snapshot package count stats
183+
*/
184+
185+
$pkgCountStats = $mystats->getPkgCount($myrepo->getEnvId(), 60);
186+
187+
if (!empty($pkgCountStats)) {
188+
$countDateLabels = '';
189+
$countData = '';
190+
191+
foreach ($pkgCountStats as $stat) {
192+
$date = DateTime::createFromFormat('Y-m-d', $stat['Date'])->format('d-m-Y');
193+
$count = $stat['Packages_count'];
194+
195+
/**
196+
* Build data for chart
197+
*/
198+
$countDateLabels .= '"' . $date . '", ';
199+
$countData .= '"' . $count . '", ';
200+
}
201+
202+
/**
203+
* Remove last comma
204+
*/
205+
$countDateLabels = rtrim($countDateLabels, ', ');
206+
$countData = rtrim($countData, ', ');
207+
}

0 commit comments

Comments
 (0)