Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 14 additions & 7 deletions Dockerfile.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,17 +20,16 @@
apt-transport-https \
curl

# setup nodejs repo
# setup nodejs repo (node 20 LTS)
RUN set -exu \
&& curl -fsSL https://deb.nodesource.com/gpgkey/nodesource.gpg.key | gpg --dearmor | apt-key add - \
&& echo "deb https://deb.nodesource.com/node_14.x bookworm main" | tee /etc/apt/sources.list.d/nodesource.list
&& curl -fsSL https://deb.nodesource.com/setup_20.x | bash -

# setup php8.0 repo
RUN set -exu \
&& echo "deb https://packages.sury.org/php/ $(lsb_release -sc) main" > /etc/apt/sources.list.d/php.list \
&& curl -fsSL https://packages.sury.org/php/apt.gpg | apt-key add -

# install php5.6, some extensions, and nodejs
# install php8.0, some extensions, and nodejs
RUN set -exu \
&& DEBIAN_FRONTEND=noninteractive apt-get -yq update \
&& DEBIAN_FRONTEND=noninteractive apt-get -yq install \
Expand All @@ -40,8 +39,8 @@
php8.0-mysql \
php8.0-exif \
php8.0-gd \
nodejs \
npm
php8.0-curl \
nodejs

# clean apt caches
RUN set -exu \
Expand All @@ -64,15 +63,23 @@
RUN set -exu \
&& chown -R builder:builder /var/www

# install composer
RUN set -exu \
&& curl -sS https://getcomposer.org/installer | php -- --install-dir=/usr/local/bin --filename=composer

# switch to our nonroot user
USER builder

# run npm install
# run npm install and composer install
WORKDIR /var/www/src
RUN set -exu \
&& cd /var/www/src \
&& npm install

WORKDIR /var/www
RUN set -exu \
&& composer install --no-dev --no-interaction --no-progress

# back to root
USER root

Expand Down
2 changes: 2 additions & 0 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@ services:
- "com.centurylinklabs.watchtower.enable=true"
env_file:
- ./php.env
extra_hosts:
- "host-gateway:host-gateway"
volumes:
- ./upload:/var/www/upload:rw
- ./config/php-fpm.conf:/etc/php/8.0/fpm/php-fpm.conf:ro
Expand Down
9 changes: 9 additions & 0 deletions php.env.example
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,15 @@ BAN_PASSWORD=secret

CAPTCHA_BYPASS=false

# OpenTelemetry — traces sent to FishVision's Tempo via host-gateway
# Set OTEL_SDK_DISABLED=true to disable tracing without removing config
OTEL_SERVICE_NAME=wiki
OTEL_EXPORTER_OTLP_ENDPOINT=http://host-gateway:4319
OTEL_EXPORTER_OTLP_PROTOCOL=http/json
OTEL_TRACES_SAMPLER=parentbased_always_on
OTEL_PHP_AUTOLOAD_ENABLED=true
OTEL_SDK_DISABLED=false

# passed to json_decode()
# needs to resolve as an array
BANLIST='["127\.0\.0\.1", "^2600:123"]'
12 changes: 6 additions & 6 deletions wwwroot/ban.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,32 +8,32 @@
if(is_numeric($_POST['id']) and $_POST['password'] == BAN_PASSWORD)
{
$ID = $_POST['id'];
mysqli_query($mysql,"Update `Wiki_Accounts` set `Verified`='-1' where `ID`='$ID'");
wiki_query("Update `Wiki_Accounts` set `Verified`='-1' where `ID`='$ID'");
echo "User banned.<br />";

if($_POST['revert'] == "on")
{
$Reverted = array();
$BadAccount = $ID;

$PageQuery = mysqli_query($mysql,"SELECT `PageID` FROM `Wiki_Edits` WHERE `AccountID`='$BadAccount'");
$PageQuery = wiki_query("SELECT `PageID` FROM `Wiki_Edits` WHERE `AccountID`='$BadAccount'");
while(list($PageID) = mysqli_fetch_array($PageQuery))
{
if(empty($Reverted[$PageID]))
{
$DataQuery = mysqli_query($mysql,"SELECT `Name`,`Description`,`Title`,`Content` FROM `Wiki_Edits` WHERE `PageID`='$PageID' AND `AccountID`!='$BadAccount' ORDER BY `ID` DESC LIMIT 1");
$DataQuery = wiki_query("SELECT `Name`,`Description`,`Title`,`Content` FROM `Wiki_Edits` WHERE `PageID`='$PageID' AND `AccountID`!='$BadAccount' ORDER BY `ID` DESC LIMIT 1");
list($PageName, $PageDescription, $PageTitle, $PageContent) = mysqli_fetch_array($DataQuery);

$Time = Time();
$Size = strlen($PageContent);

mysqli_query($mysql,"UPDATE `Wiki_Pages` SET `EditTime`='$Time',`Title`='$PageTitle',`Content`='$PageContent' WHERE `ID`='$PageID'");
wiki_query("UPDATE `Wiki_Pages` SET `EditTime`='$Time',`Title`='$PageTitle',`Content`='$PageContent' WHERE `ID`='$PageID'");
$SQLError .= mysqli_error($mysql);

mysqli_query($mysql,"INSERT INTO `Wiki_Edits` VALUES ('NULL', '$PageID', '{$_SESSION['ID']}', '$Time', '$Size', '$PageName', 'Rachel&#39;s Super Revert: $PageDescription', '$PageTitle', '$PageContent', '')");
wiki_query("INSERT INTO `Wiki_Edits` VALUES ('NULL', '$PageID', '{$_SESSION['ID']}', '$Time', '$Size', '$PageName', 'Rachel&#39;s Super Revert: $PageDescription', '$PageTitle', '$PageContent', '')");
$SQLError .= mysqli_error($mysql);

mysqli_query($mysql,"UPDATE `Wiki_Accounts` SET `EditTime`='$Time' WHERE `ID`='{$_SESSION['ID']}'");
wiki_query("UPDATE `Wiki_Accounts` SET `EditTime`='$Time' WHERE `ID`='{$_SESSION['ID']}'");
$SQLError .= mysqli_error($mysql);

$Reverted[$PageID] = TRUE;
Expand Down
13 changes: 13 additions & 0 deletions wwwroot/composer.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
{
"require": {
"open-telemetry/sdk": "^1.0",
"open-telemetry/exporter-otlp": "^1.0.0",
"open-telemetry/gen-otlp-protobuf": "^1.2.1",
"google/protobuf": "^4.0",
"php-http/curl-client": "^2.0",
"nyholm/psr7": "^1.0"
},
"config": {
"sort-packages": true
}
}
2 changes: 1 addition & 1 deletion wwwroot/fun/edits.php
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@

if(empty($Data[$PageID]))
{
$PageQuery = mysqli_query($mysql,"SELECT `Path` FROM `Wiki_Pages` WHERE `ID`='$PageID'");
$PageQuery = wiki_query("SELECT `Path` FROM `Wiki_Pages` WHERE `ID`='$PageID'");
list($PagePath) = mysqli_fetch_array($PageQuery);

$Data[$PageID] = $PagePath;
Expand Down
4 changes: 2 additions & 2 deletions wwwroot/fun/names.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
if(empty($ID))
$ID = $_SESSION['ID'];

$AccountQuery = mysqli_query($mysql,"Select `Name` from `Wiki_Accounts` where `ID`='$ID'");
$AccountQuery = wiki_query("Select `Name` from `Wiki_Accounts` where `ID`='$ID'");
list($AccountName) = mysqli_fetch_array($AccountQuery);

$hostname = gethostbyaddr($AccountName);
Expand All @@ -26,7 +26,7 @@
$Title = "Names $hostname has edited with";
}

$NameQuery = mysqli_query($mysql,"Select `Name`, max(`EditTime`),count(*) as n
$NameQuery = wiki_query("Select `Name`, max(`EditTime`),count(*) as n
from `Wiki_Edits`
where `AccountID`='$ID'
group by `Name`
Expand Down
4 changes: 2 additions & 2 deletions wwwroot/fun/paginate.php
Original file line number Diff line number Diff line change
Expand Up @@ -46,11 +46,11 @@ function Paginate($Query, $Limit, $Page = 1, $QueryString = '')
$Start = $Page * $Limit;
$paginationOffset = $Limit * 3;

$CountQuery = mysqli_query($mysql,"$Query limit $Start, $paginationOffset");
$CountQuery = wiki_query("$Query limit $Start, $paginationOffset");
$Rows = mysqli_num_rows($CountQuery);
$Pages = $Page + ceil($Rows / $Limit);

$PageQuery = mysqli_query($mysql,"$Query limit $Start, $Limit");
$PageQuery = wiki_query("$Query limit $Start, $Limit");
while($Result = mysqli_fetch_array($PageQuery))
{
$Data[] = $Result;
Expand Down
6 changes: 3 additions & 3 deletions wwwroot/functions.php
Original file line number Diff line number Diff line change
Expand Up @@ -227,18 +227,18 @@ function RandomRow($table, $column)

global $mysql;
$max_sql = "SELECT max($column) AS max_id FROM $table";
$max_row = mysqli_fetch_array(mysqli_query($mysql,$max_sql));
$max_row = mysqli_fetch_array(wiki_query($max_sql));

$random_number = mt_rand(1, $max_row['max_id']);

$random_sql = "SELECT * FROM $table WHERE $column >= $random_number ORDER BY $column ASC LIMIT 1";
$random_row = mysqli_fetch_array(mysqli_query($mysql,$random_sql));
$random_row = mysqli_fetch_array(wiki_query($random_sql));

while (!is_array($random_row))
{
$random_sql = "SELECT * FROM $table WHERE $column < $random_number ORDER BY $column DESC LIMIT 1";

$random_row = mysqli_fetch_array(mysqli_query($mysql,$random_sql));
$random_row = mysqli_fetch_array(wiki_query($random_sql));
}

return $random_row;
Expand Down
Loading