Compare commits
191 commits
Author | SHA1 | Date | |
---|---|---|---|
![]() |
afa89836d2 | ||
![]() |
d25b53ab33 | ||
![]() |
f17219d054 | ||
![]() |
1583120679 | ||
![]() |
5651c47b1d | ||
![]() |
6f5e59f140 | ||
![]() |
5e1a72f22e | ||
![]() |
08cd9e7cf8 | ||
![]() |
2ad4e86ec8 | ||
![]() |
911b0be5ac | ||
![]() |
7d834a6d03 | ||
![]() |
902066ed81 | ||
![]() |
75788116ec | ||
![]() |
2ff91c0908 | ||
![]() |
57153f383c | ||
![]() |
45955a4730 | ||
![]() |
1a72664f73 | ||
![]() |
7231835bf5 | ||
![]() |
d13d6ab98e | ||
![]() |
b41c4a57fc | ||
![]() |
845b9f724a | ||
![]() |
f0dbd5e426 | ||
![]() |
3652faf8ab | ||
![]() |
8ad8b5ca6f | ||
![]() |
3dee0f4028 | ||
![]() |
8073f2ce44 | ||
![]() |
0396958944 | ||
![]() |
dabfd02776 | ||
![]() |
59858cabfe | ||
![]() |
477912bdbf | ||
![]() |
9f5393fac5 | ||
![]() |
1ae667ed5e | ||
![]() |
763bca162a | ||
![]() |
b43ca9a94e | ||
![]() |
386707c104 | ||
![]() |
86b3840278 | ||
![]() |
d5ecdf330c | ||
![]() |
734822aa8a | ||
![]() |
b54509ba51 | ||
![]() |
07d5869a1a | ||
![]() |
6f6640ae15 | ||
![]() |
4f9ec2cb82 | ||
![]() |
795308a949 | ||
![]() |
59633724c2 | ||
![]() |
022bc27612 | ||
![]() |
5ae966bfa5 | ||
![]() |
bf9ba1ad34 | ||
![]() |
1b43034c0e | ||
![]() |
53cfef9655 | ||
![]() |
d8b745cbbd | ||
![]() |
26ad4902a0 | ||
![]() |
1048548f3e | ||
![]() |
cdc56c3c0c | ||
![]() |
00d109ca82 | ||
![]() |
5d300a80ad | ||
![]() |
927d769045 | ||
![]() |
031cfb7b14 | ||
![]() |
1ce28f77ad | ||
![]() |
63e82e911c | ||
![]() |
e704a58591 | ||
![]() |
2fdcdec291 | ||
![]() |
913cc1e96f | ||
![]() |
e67dbf1e5f | ||
![]() |
206c27b444 | ||
![]() |
13eeee540f | ||
![]() |
805ef7e2a9 | ||
![]() |
791849c7c5 | ||
![]() |
e264220e8c | ||
![]() |
28eb077cc7 | ||
![]() |
b5a90af0c1 | ||
![]() |
bfd493f944 | ||
![]() |
f8056a1dc2 | ||
![]() |
0ba76adc1d | ||
![]() |
938b95691c | ||
![]() |
ebce135ebf | ||
![]() |
f63bfe21bc | ||
![]() |
e9ed83daa9 | ||
![]() |
d1614ee205 | ||
![]() |
22d2d84b1d | ||
![]() |
9f255592ff | ||
![]() |
6128fb62a8 | ||
![]() |
0a649d16b9 | ||
![]() |
58b4b869cd | ||
![]() |
f64695f42d | ||
![]() |
23fdda8abb | ||
![]() |
a55ad19c9c | ||
![]() |
6042db4f20 | ||
![]() |
e6ec593365 | ||
![]() |
2d5b8df569 | ||
![]() |
e301952470 | ||
![]() |
1a7c9e9d75 | ||
![]() |
67348c95f4 | ||
![]() |
3c1323578e | ||
![]() |
a536d0b38c | ||
![]() |
9fbb2f0869 | ||
![]() |
f8ed38f556 | ||
![]() |
92e2af5bf0 | ||
![]() |
bf105daadc | ||
![]() |
fcea47a1e8 | ||
![]() |
f27d628524 | ||
![]() |
610ff2ecad | ||
![]() |
7bb7bd47a5 | ||
![]() |
3225e9ad6a | ||
![]() |
decdb9a900 | ||
![]() |
de84d39dc3 | ||
![]() |
62b0d05364 | ||
![]() |
c690e1b813 | ||
![]() |
dc6b755dfc | ||
![]() |
aa08d4c21c | ||
![]() |
7de05ea123 | ||
![]() |
e4eacf976a | ||
![]() |
4f3cd948d9 | ||
![]() |
c840447c30 | ||
![]() |
dccc2d2586 | ||
![]() |
8c0078f3e1 | ||
![]() |
a7cacdee4f | ||
![]() |
d564d8dbe1 | ||
![]() |
7b7dbed563 | ||
![]() |
a2f6e3069e | ||
![]() |
53d6ad0c56 | ||
![]() |
a338303e0d | ||
![]() |
764b459ffd | ||
![]() |
425bba5628 | ||
![]() |
f159121b2f | ||
![]() |
046829c045 | ||
![]() |
d12b908808 | ||
![]() |
f01ecccf8c | ||
![]() |
e977266077 | ||
![]() |
287ac16d3f | ||
![]() |
4bc97d3017 | ||
![]() |
bc31c89ced | ||
![]() |
dc8aa3a93f | ||
![]() |
bc43190bd4 | ||
![]() |
446aab42d4 | ||
![]() |
ee9506ac59 | ||
![]() |
30ada7a1da | ||
![]() |
de2675426e | ||
![]() |
4d8a10643f | ||
![]() |
ff0d65a600 | ||
![]() |
58637c0d86 | ||
![]() |
2b7f57eda2 | ||
![]() |
33fbdaec98 | ||
![]() |
4419456a1d | ||
![]() |
9e0903d042 | ||
![]() |
3fdbe8986a | ||
![]() |
1987e4bc8e | ||
![]() |
446c15389b | ||
![]() |
37b523e689 | ||
![]() |
35a9a9bdd4 | ||
![]() |
fcff948182 | ||
![]() |
611b314d96 | ||
![]() |
ca570a2f69 | ||
![]() |
e87aa3b4fb | ||
![]() |
a4c80928a1 | ||
![]() |
db9ab01aa0 | ||
![]() |
4e346b0a36 | ||
![]() |
8368bbee6c | ||
![]() |
31890cba18 | ||
![]() |
f444cca623 | ||
![]() |
17f5074992 | ||
![]() |
768b5f76c7 | ||
![]() |
f9addc74f0 | ||
![]() |
284cbbed83 | ||
![]() |
b5d70e11c7 | ||
![]() |
b939cefb69 | ||
![]() |
c7a4c5e2c5 | ||
![]() |
2b3b05fe6c | ||
![]() |
945bf34185 | ||
![]() |
cda2cf8f3c | ||
![]() |
d2906509ee | ||
![]() |
333229d642 | ||
![]() |
dda4fc1fcd | ||
![]() |
1a4e7dc049 | ||
![]() |
f432bc12e1 | ||
![]() |
6c77f5b05a | ||
![]() |
a561fe6dbd | ||
![]() |
744c849473 | ||
![]() |
e155ad0ae4 | ||
![]() |
1259362364 | ||
![]() |
667db9e4e0 | ||
![]() |
fb50e282d9 | ||
![]() |
6dacf524bc | ||
![]() |
0f123b7700 | ||
![]() |
3d28060afc | ||
![]() |
90b6795f65 | ||
![]() |
65b664b678 | ||
![]() |
369f66d896 | ||
![]() |
0c61f05ffe | ||
![]() |
5548f66fd9 | ||
![]() |
56281b0f34 | ||
![]() |
2cdb68ce7e |
1
.github/FUNDING.yml
vendored
Normal file
|
@ -0,0 +1 @@
|
|||
github: [ m1k1o ]
|
58
.github/workflows/build.yml
vendored
Normal file
|
@ -0,0 +1,58 @@
|
|||
name: "CI for builds"
|
||||
|
||||
on:
|
||||
push:
|
||||
branches:
|
||||
- master
|
||||
tags:
|
||||
- 'v*'
|
||||
|
||||
env:
|
||||
IMAGE_NAME: m1k1o/blog
|
||||
|
||||
jobs:
|
||||
build:
|
||||
runs-on: ubuntu-latest
|
||||
#
|
||||
# do not run on forks
|
||||
#
|
||||
if: github.repository_owner == 'm1k1o'
|
||||
steps:
|
||||
-
|
||||
name: Checkout
|
||||
uses: actions/checkout@v2
|
||||
-
|
||||
name: Set up QEMU
|
||||
uses: docker/setup-qemu-action@v1
|
||||
-
|
||||
name: Set up Docker Buildx
|
||||
id: buildx
|
||||
uses: docker/setup-buildx-action@v1
|
||||
-
|
||||
name: Available platforms
|
||||
run: echo ${{ steps.buildx.outputs.platforms }}
|
||||
-
|
||||
name: Extract metadata (tags, labels) for Docker
|
||||
uses: docker/metadata-action@v3
|
||||
id: meta
|
||||
with:
|
||||
images: ${{ env.IMAGE_NAME }}
|
||||
tags: |
|
||||
type=raw,value=latest,enable=${{ endsWith(github.ref, github.event.repository.default_branch) }}
|
||||
type=semver,pattern={{version}}
|
||||
type=semver,pattern={{major}}.{{minor}}
|
||||
type=semver,pattern={{major}}
|
||||
-
|
||||
name: Log in to the Container registry
|
||||
uses: docker/login-action@v1
|
||||
with:
|
||||
username: ${{ github.actor }}
|
||||
password: ${{ secrets.DOCKER_TOKEN }}
|
||||
-
|
||||
name: Build and push
|
||||
uses: docker/build-push-action@v2
|
||||
with:
|
||||
tags: ${{ steps.meta.outputs.tags }}
|
||||
labels: ${{ steps.meta.outputs.labels }}
|
||||
platforms: linux/amd64,linux/arm64,linux/arm/v7
|
||||
push: true
|
14
.gitignore
vendored
|
@ -1,18 +1,10 @@
|
|||
# Custom config (legacy)
|
||||
custom.ini
|
||||
|
||||
# Ignore images content
|
||||
# Ignore images & thumbnails directories (legacy)
|
||||
i/*
|
||||
!i/.gitkeep
|
||||
|
||||
# Ignore thumbnails content
|
||||
t/*
|
||||
!t/.gitkeep
|
||||
|
||||
# Ignore all files in data but keep folder itself (and logs subfolder)
|
||||
# Ignore all files in data but keep directory itself
|
||||
data/*
|
||||
!data/.gitkeep
|
||||
!data/logs/
|
||||
|
||||
# Ignore all logs files but keep folder itself
|
||||
data/logs/*
|
||||
!data/logs/.gitkeep
|
||||
|
|
15
.htaccess
|
@ -1,4 +1,15 @@
|
|||
<Files ~ "\.(ini|sql)$">
|
||||
Options -Indexes
|
||||
|
||||
<Files ~ "\.(db|ini|sql|log|class\.php)$">
|
||||
Order Allow,Deny
|
||||
Deny from All
|
||||
</Files>
|
||||
</Files>
|
||||
|
||||
<Files ~ "^(\.|Dockerfile|docker-compose\.yml|README\.md)">
|
||||
Order Allow,Deny
|
||||
Deny from All
|
||||
</Files>
|
||||
|
||||
# Allow uploading large images
|
||||
php_value upload_max_filesize 32M
|
||||
php_value post_max_size 32M
|
||||
|
|
30
Dockerfile
Normal file
|
@ -0,0 +1,30 @@
|
|||
FROM php:7.4-apache
|
||||
|
||||
RUN set -eux; apt-get update; \
|
||||
apt-get install -y --no-install-recommends libpq-dev \
|
||||
#
|
||||
# install curl
|
||||
libcurl4-openssl-dev \
|
||||
#
|
||||
# install gd dependencies
|
||||
zlib1g-dev libpng-dev libjpeg-dev \
|
||||
libwebp-dev libxpm-dev libfreetype6-dev; \
|
||||
#
|
||||
# clean up
|
||||
rm -rf /var/lib/apt/lists/*; \
|
||||
#
|
||||
# configure extensions
|
||||
docker-php-ext-configure gd --enable-gd \
|
||||
--with-jpeg --with-webp --with-xpm --with-freetype; \
|
||||
#
|
||||
# install extensions
|
||||
docker-php-ext-install curl gd pdo pdo_mysql pdo_pgsql exif; \
|
||||
#
|
||||
# set up environment
|
||||
a2enmod rewrite;
|
||||
|
||||
#
|
||||
# copy files
|
||||
COPY --chown=33:33 . /var/www/html
|
||||
|
||||
VOLUME /var/www/html/data
|
674
LICENSE
Normal file
|
@ -0,0 +1,674 @@
|
|||
GNU GENERAL PUBLIC LICENSE
|
||||
Version 3, 29 June 2007
|
||||
|
||||
Copyright (C) 2007 Free Software Foundation, Inc. <https://fsf.org/>
|
||||
Everyone is permitted to copy and distribute verbatim copies
|
||||
of this license document, but changing it is not allowed.
|
||||
|
||||
Preamble
|
||||
|
||||
The GNU General Public License is a free, copyleft license for
|
||||
software and other kinds of works.
|
||||
|
||||
The licenses for most software and other practical works are designed
|
||||
to take away your freedom to share and change the works. By contrast,
|
||||
the GNU General Public License is intended to guarantee your freedom to
|
||||
share and change all versions of a program--to make sure it remains free
|
||||
software for all its users. We, the Free Software Foundation, use the
|
||||
GNU General Public License for most of our software; it applies also to
|
||||
any other work released this way by its authors. You can apply it to
|
||||
your programs, too.
|
||||
|
||||
When we speak of free software, we are referring to freedom, not
|
||||
price. Our General Public Licenses are designed to make sure that you
|
||||
have the freedom to distribute copies of free software (and charge for
|
||||
them if you wish), that you receive source code or can get it if you
|
||||
want it, that you can change the software or use pieces of it in new
|
||||
free programs, and that you know you can do these things.
|
||||
|
||||
To protect your rights, we need to prevent others from denying you
|
||||
these rights or asking you to surrender the rights. Therefore, you have
|
||||
certain responsibilities if you distribute copies of the software, or if
|
||||
you modify it: responsibilities to respect the freedom of others.
|
||||
|
||||
For example, if you distribute copies of such a program, whether
|
||||
gratis or for a fee, you must pass on to the recipients the same
|
||||
freedoms that you received. You must make sure that they, too, receive
|
||||
or can get the source code. And you must show them these terms so they
|
||||
know their rights.
|
||||
|
||||
Developers that use the GNU GPL protect your rights with two steps:
|
||||
(1) assert copyright on the software, and (2) offer you this License
|
||||
giving you legal permission to copy, distribute and/or modify it.
|
||||
|
||||
For the developers' and authors' protection, the GPL clearly explains
|
||||
that there is no warranty for this free software. For both users' and
|
||||
authors' sake, the GPL requires that modified versions be marked as
|
||||
changed, so that their problems will not be attributed erroneously to
|
||||
authors of previous versions.
|
||||
|
||||
Some devices are designed to deny users access to install or run
|
||||
modified versions of the software inside them, although the manufacturer
|
||||
can do so. This is fundamentally incompatible with the aim of
|
||||
protecting users' freedom to change the software. The systematic
|
||||
pattern of such abuse occurs in the area of products for individuals to
|
||||
use, which is precisely where it is most unacceptable. Therefore, we
|
||||
have designed this version of the GPL to prohibit the practice for those
|
||||
products. If such problems arise substantially in other domains, we
|
||||
stand ready to extend this provision to those domains in future versions
|
||||
of the GPL, as needed to protect the freedom of users.
|
||||
|
||||
Finally, every program is threatened constantly by software patents.
|
||||
States should not allow patents to restrict development and use of
|
||||
software on general-purpose computers, but in those that do, we wish to
|
||||
avoid the special danger that patents applied to a free program could
|
||||
make it effectively proprietary. To prevent this, the GPL assures that
|
||||
patents cannot be used to render the program non-free.
|
||||
|
||||
The precise terms and conditions for copying, distribution and
|
||||
modification follow.
|
||||
|
||||
TERMS AND CONDITIONS
|
||||
|
||||
0. Definitions.
|
||||
|
||||
"This License" refers to version 3 of the GNU General Public License.
|
||||
|
||||
"Copyright" also means copyright-like laws that apply to other kinds of
|
||||
works, such as semiconductor masks.
|
||||
|
||||
"The Program" refers to any copyrightable work licensed under this
|
||||
License. Each licensee is addressed as "you". "Licensees" and
|
||||
"recipients" may be individuals or organizations.
|
||||
|
||||
To "modify" a work means to copy from or adapt all or part of the work
|
||||
in a fashion requiring copyright permission, other than the making of an
|
||||
exact copy. The resulting work is called a "modified version" of the
|
||||
earlier work or a work "based on" the earlier work.
|
||||
|
||||
A "covered work" means either the unmodified Program or a work based
|
||||
on the Program.
|
||||
|
||||
To "propagate" a work means to do anything with it that, without
|
||||
permission, would make you directly or secondarily liable for
|
||||
infringement under applicable copyright law, except executing it on a
|
||||
computer or modifying a private copy. Propagation includes copying,
|
||||
distribution (with or without modification), making available to the
|
||||
public, and in some countries other activities as well.
|
||||
|
||||
To "convey" a work means any kind of propagation that enables other
|
||||
parties to make or receive copies. Mere interaction with a user through
|
||||
a computer network, with no transfer of a copy, is not conveying.
|
||||
|
||||
An interactive user interface displays "Appropriate Legal Notices"
|
||||
to the extent that it includes a convenient and prominently visible
|
||||
feature that (1) displays an appropriate copyright notice, and (2)
|
||||
tells the user that there is no warranty for the work (except to the
|
||||
extent that warranties are provided), that licensees may convey the
|
||||
work under this License, and how to view a copy of this License. If
|
||||
the interface presents a list of user commands or options, such as a
|
||||
menu, a prominent item in the list meets this criterion.
|
||||
|
||||
1. Source Code.
|
||||
|
||||
The "source code" for a work means the preferred form of the work
|
||||
for making modifications to it. "Object code" means any non-source
|
||||
form of a work.
|
||||
|
||||
A "Standard Interface" means an interface that either is an official
|
||||
standard defined by a recognized standards body, or, in the case of
|
||||
interfaces specified for a particular programming language, one that
|
||||
is widely used among developers working in that language.
|
||||
|
||||
The "System Libraries" of an executable work include anything, other
|
||||
than the work as a whole, that (a) is included in the normal form of
|
||||
packaging a Major Component, but which is not part of that Major
|
||||
Component, and (b) serves only to enable use of the work with that
|
||||
Major Component, or to implement a Standard Interface for which an
|
||||
implementation is available to the public in source code form. A
|
||||
"Major Component", in this context, means a major essential component
|
||||
(kernel, window system, and so on) of the specific operating system
|
||||
(if any) on which the executable work runs, or a compiler used to
|
||||
produce the work, or an object code interpreter used to run it.
|
||||
|
||||
The "Corresponding Source" for a work in object code form means all
|
||||
the source code needed to generate, install, and (for an executable
|
||||
work) run the object code and to modify the work, including scripts to
|
||||
control those activities. However, it does not include the work's
|
||||
System Libraries, or general-purpose tools or generally available free
|
||||
programs which are used unmodified in performing those activities but
|
||||
which are not part of the work. For example, Corresponding Source
|
||||
includes interface definition files associated with source files for
|
||||
the work, and the source code for shared libraries and dynamically
|
||||
linked subprograms that the work is specifically designed to require,
|
||||
such as by intimate data communication or control flow between those
|
||||
subprograms and other parts of the work.
|
||||
|
||||
The Corresponding Source need not include anything that users
|
||||
can regenerate automatically from other parts of the Corresponding
|
||||
Source.
|
||||
|
||||
The Corresponding Source for a work in source code form is that
|
||||
same work.
|
||||
|
||||
2. Basic Permissions.
|
||||
|
||||
All rights granted under this License are granted for the term of
|
||||
copyright on the Program, and are irrevocable provided the stated
|
||||
conditions are met. This License explicitly affirms your unlimited
|
||||
permission to run the unmodified Program. The output from running a
|
||||
covered work is covered by this License only if the output, given its
|
||||
content, constitutes a covered work. This License acknowledges your
|
||||
rights of fair use or other equivalent, as provided by copyright law.
|
||||
|
||||
You may make, run and propagate covered works that you do not
|
||||
convey, without conditions so long as your license otherwise remains
|
||||
in force. You may convey covered works to others for the sole purpose
|
||||
of having them make modifications exclusively for you, or provide you
|
||||
with facilities for running those works, provided that you comply with
|
||||
the terms of this License in conveying all material for which you do
|
||||
not control copyright. Those thus making or running the covered works
|
||||
for you must do so exclusively on your behalf, under your direction
|
||||
and control, on terms that prohibit them from making any copies of
|
||||
your copyrighted material outside their relationship with you.
|
||||
|
||||
Conveying under any other circumstances is permitted solely under
|
||||
the conditions stated below. Sublicensing is not allowed; section 10
|
||||
makes it unnecessary.
|
||||
|
||||
3. Protecting Users' Legal Rights From Anti-Circumvention Law.
|
||||
|
||||
No covered work shall be deemed part of an effective technological
|
||||
measure under any applicable law fulfilling obligations under article
|
||||
11 of the WIPO copyright treaty adopted on 20 December 1996, or
|
||||
similar laws prohibiting or restricting circumvention of such
|
||||
measures.
|
||||
|
||||
When you convey a covered work, you waive any legal power to forbid
|
||||
circumvention of technological measures to the extent such circumvention
|
||||
is effected by exercising rights under this License with respect to
|
||||
the covered work, and you disclaim any intention to limit operation or
|
||||
modification of the work as a means of enforcing, against the work's
|
||||
users, your or third parties' legal rights to forbid circumvention of
|
||||
technological measures.
|
||||
|
||||
4. Conveying Verbatim Copies.
|
||||
|
||||
You may convey verbatim copies of the Program's source code as you
|
||||
receive it, in any medium, provided that you conspicuously and
|
||||
appropriately publish on each copy an appropriate copyright notice;
|
||||
keep intact all notices stating that this License and any
|
||||
non-permissive terms added in accord with section 7 apply to the code;
|
||||
keep intact all notices of the absence of any warranty; and give all
|
||||
recipients a copy of this License along with the Program.
|
||||
|
||||
You may charge any price or no price for each copy that you convey,
|
||||
and you may offer support or warranty protection for a fee.
|
||||
|
||||
5. Conveying Modified Source Versions.
|
||||
|
||||
You may convey a work based on the Program, or the modifications to
|
||||
produce it from the Program, in the form of source code under the
|
||||
terms of section 4, provided that you also meet all of these conditions:
|
||||
|
||||
a) The work must carry prominent notices stating that you modified
|
||||
it, and giving a relevant date.
|
||||
|
||||
b) The work must carry prominent notices stating that it is
|
||||
released under this License and any conditions added under section
|
||||
7. This requirement modifies the requirement in section 4 to
|
||||
"keep intact all notices".
|
||||
|
||||
c) You must license the entire work, as a whole, under this
|
||||
License to anyone who comes into possession of a copy. This
|
||||
License will therefore apply, along with any applicable section 7
|
||||
additional terms, to the whole of the work, and all its parts,
|
||||
regardless of how they are packaged. This License gives no
|
||||
permission to license the work in any other way, but it does not
|
||||
invalidate such permission if you have separately received it.
|
||||
|
||||
d) If the work has interactive user interfaces, each must display
|
||||
Appropriate Legal Notices; however, if the Program has interactive
|
||||
interfaces that do not display Appropriate Legal Notices, your
|
||||
work need not make them do so.
|
||||
|
||||
A compilation of a covered work with other separate and independent
|
||||
works, which are not by their nature extensions of the covered work,
|
||||
and which are not combined with it such as to form a larger program,
|
||||
in or on a volume of a storage or distribution medium, is called an
|
||||
"aggregate" if the compilation and its resulting copyright are not
|
||||
used to limit the access or legal rights of the compilation's users
|
||||
beyond what the individual works permit. Inclusion of a covered work
|
||||
in an aggregate does not cause this License to apply to the other
|
||||
parts of the aggregate.
|
||||
|
||||
6. Conveying Non-Source Forms.
|
||||
|
||||
You may convey a covered work in object code form under the terms
|
||||
of sections 4 and 5, provided that you also convey the
|
||||
machine-readable Corresponding Source under the terms of this License,
|
||||
in one of these ways:
|
||||
|
||||
a) Convey the object code in, or embodied in, a physical product
|
||||
(including a physical distribution medium), accompanied by the
|
||||
Corresponding Source fixed on a durable physical medium
|
||||
customarily used for software interchange.
|
||||
|
||||
b) Convey the object code in, or embodied in, a physical product
|
||||
(including a physical distribution medium), accompanied by a
|
||||
written offer, valid for at least three years and valid for as
|
||||
long as you offer spare parts or customer support for that product
|
||||
model, to give anyone who possesses the object code either (1) a
|
||||
copy of the Corresponding Source for all the software in the
|
||||
product that is covered by this License, on a durable physical
|
||||
medium customarily used for software interchange, for a price no
|
||||
more than your reasonable cost of physically performing this
|
||||
conveying of source, or (2) access to copy the
|
||||
Corresponding Source from a network server at no charge.
|
||||
|
||||
c) Convey individual copies of the object code with a copy of the
|
||||
written offer to provide the Corresponding Source. This
|
||||
alternative is allowed only occasionally and noncommercially, and
|
||||
only if you received the object code with such an offer, in accord
|
||||
with subsection 6b.
|
||||
|
||||
d) Convey the object code by offering access from a designated
|
||||
place (gratis or for a charge), and offer equivalent access to the
|
||||
Corresponding Source in the same way through the same place at no
|
||||
further charge. You need not require recipients to copy the
|
||||
Corresponding Source along with the object code. If the place to
|
||||
copy the object code is a network server, the Corresponding Source
|
||||
may be on a different server (operated by you or a third party)
|
||||
that supports equivalent copying facilities, provided you maintain
|
||||
clear directions next to the object code saying where to find the
|
||||
Corresponding Source. Regardless of what server hosts the
|
||||
Corresponding Source, you remain obligated to ensure that it is
|
||||
available for as long as needed to satisfy these requirements.
|
||||
|
||||
e) Convey the object code using peer-to-peer transmission, provided
|
||||
you inform other peers where the object code and Corresponding
|
||||
Source of the work are being offered to the general public at no
|
||||
charge under subsection 6d.
|
||||
|
||||
A separable portion of the object code, whose source code is excluded
|
||||
from the Corresponding Source as a System Library, need not be
|
||||
included in conveying the object code work.
|
||||
|
||||
A "User Product" is either (1) a "consumer product", which means any
|
||||
tangible personal property which is normally used for personal, family,
|
||||
or household purposes, or (2) anything designed or sold for incorporation
|
||||
into a dwelling. In determining whether a product is a consumer product,
|
||||
doubtful cases shall be resolved in favor of coverage. For a particular
|
||||
product received by a particular user, "normally used" refers to a
|
||||
typical or common use of that class of product, regardless of the status
|
||||
of the particular user or of the way in which the particular user
|
||||
actually uses, or expects or is expected to use, the product. A product
|
||||
is a consumer product regardless of whether the product has substantial
|
||||
commercial, industrial or non-consumer uses, unless such uses represent
|
||||
the only significant mode of use of the product.
|
||||
|
||||
"Installation Information" for a User Product means any methods,
|
||||
procedures, authorization keys, or other information required to install
|
||||
and execute modified versions of a covered work in that User Product from
|
||||
a modified version of its Corresponding Source. The information must
|
||||
suffice to ensure that the continued functioning of the modified object
|
||||
code is in no case prevented or interfered with solely because
|
||||
modification has been made.
|
||||
|
||||
If you convey an object code work under this section in, or with, or
|
||||
specifically for use in, a User Product, and the conveying occurs as
|
||||
part of a transaction in which the right of possession and use of the
|
||||
User Product is transferred to the recipient in perpetuity or for a
|
||||
fixed term (regardless of how the transaction is characterized), the
|
||||
Corresponding Source conveyed under this section must be accompanied
|
||||
by the Installation Information. But this requirement does not apply
|
||||
if neither you nor any third party retains the ability to install
|
||||
modified object code on the User Product (for example, the work has
|
||||
been installed in ROM).
|
||||
|
||||
The requirement to provide Installation Information does not include a
|
||||
requirement to continue to provide support service, warranty, or updates
|
||||
for a work that has been modified or installed by the recipient, or for
|
||||
the User Product in which it has been modified or installed. Access to a
|
||||
network may be denied when the modification itself materially and
|
||||
adversely affects the operation of the network or violates the rules and
|
||||
protocols for communication across the network.
|
||||
|
||||
Corresponding Source conveyed, and Installation Information provided,
|
||||
in accord with this section must be in a format that is publicly
|
||||
documented (and with an implementation available to the public in
|
||||
source code form), and must require no special password or key for
|
||||
unpacking, reading or copying.
|
||||
|
||||
7. Additional Terms.
|
||||
|
||||
"Additional permissions" are terms that supplement the terms of this
|
||||
License by making exceptions from one or more of its conditions.
|
||||
Additional permissions that are applicable to the entire Program shall
|
||||
be treated as though they were included in this License, to the extent
|
||||
that they are valid under applicable law. If additional permissions
|
||||
apply only to part of the Program, that part may be used separately
|
||||
under those permissions, but the entire Program remains governed by
|
||||
this License without regard to the additional permissions.
|
||||
|
||||
When you convey a copy of a covered work, you may at your option
|
||||
remove any additional permissions from that copy, or from any part of
|
||||
it. (Additional permissions may be written to require their own
|
||||
removal in certain cases when you modify the work.) You may place
|
||||
additional permissions on material, added by you to a covered work,
|
||||
for which you have or can give appropriate copyright permission.
|
||||
|
||||
Notwithstanding any other provision of this License, for material you
|
||||
add to a covered work, you may (if authorized by the copyright holders of
|
||||
that material) supplement the terms of this License with terms:
|
||||
|
||||
a) Disclaiming warranty or limiting liability differently from the
|
||||
terms of sections 15 and 16 of this License; or
|
||||
|
||||
b) Requiring preservation of specified reasonable legal notices or
|
||||
author attributions in that material or in the Appropriate Legal
|
||||
Notices displayed by works containing it; or
|
||||
|
||||
c) Prohibiting misrepresentation of the origin of that material, or
|
||||
requiring that modified versions of such material be marked in
|
||||
reasonable ways as different from the original version; or
|
||||
|
||||
d) Limiting the use for publicity purposes of names of licensors or
|
||||
authors of the material; or
|
||||
|
||||
e) Declining to grant rights under trademark law for use of some
|
||||
trade names, trademarks, or service marks; or
|
||||
|
||||
f) Requiring indemnification of licensors and authors of that
|
||||
material by anyone who conveys the material (or modified versions of
|
||||
it) with contractual assumptions of liability to the recipient, for
|
||||
any liability that these contractual assumptions directly impose on
|
||||
those licensors and authors.
|
||||
|
||||
All other non-permissive additional terms are considered "further
|
||||
restrictions" within the meaning of section 10. If the Program as you
|
||||
received it, or any part of it, contains a notice stating that it is
|
||||
governed by this License along with a term that is a further
|
||||
restriction, you may remove that term. If a license document contains
|
||||
a further restriction but permits relicensing or conveying under this
|
||||
License, you may add to a covered work material governed by the terms
|
||||
of that license document, provided that the further restriction does
|
||||
not survive such relicensing or conveying.
|
||||
|
||||
If you add terms to a covered work in accord with this section, you
|
||||
must place, in the relevant source files, a statement of the
|
||||
additional terms that apply to those files, or a notice indicating
|
||||
where to find the applicable terms.
|
||||
|
||||
Additional terms, permissive or non-permissive, may be stated in the
|
||||
form of a separately written license, or stated as exceptions;
|
||||
the above requirements apply either way.
|
||||
|
||||
8. Termination.
|
||||
|
||||
You may not propagate or modify a covered work except as expressly
|
||||
provided under this License. Any attempt otherwise to propagate or
|
||||
modify it is void, and will automatically terminate your rights under
|
||||
this License (including any patent licenses granted under the third
|
||||
paragraph of section 11).
|
||||
|
||||
However, if you cease all violation of this License, then your
|
||||
license from a particular copyright holder is reinstated (a)
|
||||
provisionally, unless and until the copyright holder explicitly and
|
||||
finally terminates your license, and (b) permanently, if the copyright
|
||||
holder fails to notify you of the violation by some reasonable means
|
||||
prior to 60 days after the cessation.
|
||||
|
||||
Moreover, your license from a particular copyright holder is
|
||||
reinstated permanently if the copyright holder notifies you of the
|
||||
violation by some reasonable means, this is the first time you have
|
||||
received notice of violation of this License (for any work) from that
|
||||
copyright holder, and you cure the violation prior to 30 days after
|
||||
your receipt of the notice.
|
||||
|
||||
Termination of your rights under this section does not terminate the
|
||||
licenses of parties who have received copies or rights from you under
|
||||
this License. If your rights have been terminated and not permanently
|
||||
reinstated, you do not qualify to receive new licenses for the same
|
||||
material under section 10.
|
||||
|
||||
9. Acceptance Not Required for Having Copies.
|
||||
|
||||
You are not required to accept this License in order to receive or
|
||||
run a copy of the Program. Ancillary propagation of a covered work
|
||||
occurring solely as a consequence of using peer-to-peer transmission
|
||||
to receive a copy likewise does not require acceptance. However,
|
||||
nothing other than this License grants you permission to propagate or
|
||||
modify any covered work. These actions infringe copyright if you do
|
||||
not accept this License. Therefore, by modifying or propagating a
|
||||
covered work, you indicate your acceptance of this License to do so.
|
||||
|
||||
10. Automatic Licensing of Downstream Recipients.
|
||||
|
||||
Each time you convey a covered work, the recipient automatically
|
||||
receives a license from the original licensors, to run, modify and
|
||||
propagate that work, subject to this License. You are not responsible
|
||||
for enforcing compliance by third parties with this License.
|
||||
|
||||
An "entity transaction" is a transaction transferring control of an
|
||||
organization, or substantially all assets of one, or subdividing an
|
||||
organization, or merging organizations. If propagation of a covered
|
||||
work results from an entity transaction, each party to that
|
||||
transaction who receives a copy of the work also receives whatever
|
||||
licenses to the work the party's predecessor in interest had or could
|
||||
give under the previous paragraph, plus a right to possession of the
|
||||
Corresponding Source of the work from the predecessor in interest, if
|
||||
the predecessor has it or can get it with reasonable efforts.
|
||||
|
||||
You may not impose any further restrictions on the exercise of the
|
||||
rights granted or affirmed under this License. For example, you may
|
||||
not impose a license fee, royalty, or other charge for exercise of
|
||||
rights granted under this License, and you may not initiate litigation
|
||||
(including a cross-claim or counterclaim in a lawsuit) alleging that
|
||||
any patent claim is infringed by making, using, selling, offering for
|
||||
sale, or importing the Program or any portion of it.
|
||||
|
||||
11. Patents.
|
||||
|
||||
A "contributor" is a copyright holder who authorizes use under this
|
||||
License of the Program or a work on which the Program is based. The
|
||||
work thus licensed is called the contributor's "contributor version".
|
||||
|
||||
A contributor's "essential patent claims" are all patent claims
|
||||
owned or controlled by the contributor, whether already acquired or
|
||||
hereafter acquired, that would be infringed by some manner, permitted
|
||||
by this License, of making, using, or selling its contributor version,
|
||||
but do not include claims that would be infringed only as a
|
||||
consequence of further modification of the contributor version. For
|
||||
purposes of this definition, "control" includes the right to grant
|
||||
patent sublicenses in a manner consistent with the requirements of
|
||||
this License.
|
||||
|
||||
Each contributor grants you a non-exclusive, worldwide, royalty-free
|
||||
patent license under the contributor's essential patent claims, to
|
||||
make, use, sell, offer for sale, import and otherwise run, modify and
|
||||
propagate the contents of its contributor version.
|
||||
|
||||
In the following three paragraphs, a "patent license" is any express
|
||||
agreement or commitment, however denominated, not to enforce a patent
|
||||
(such as an express permission to practice a patent or covenant not to
|
||||
sue for patent infringement). To "grant" such a patent license to a
|
||||
party means to make such an agreement or commitment not to enforce a
|
||||
patent against the party.
|
||||
|
||||
If you convey a covered work, knowingly relying on a patent license,
|
||||
and the Corresponding Source of the work is not available for anyone
|
||||
to copy, free of charge and under the terms of this License, through a
|
||||
publicly available network server or other readily accessible means,
|
||||
then you must either (1) cause the Corresponding Source to be so
|
||||
available, or (2) arrange to deprive yourself of the benefit of the
|
||||
patent license for this particular work, or (3) arrange, in a manner
|
||||
consistent with the requirements of this License, to extend the patent
|
||||
license to downstream recipients. "Knowingly relying" means you have
|
||||
actual knowledge that, but for the patent license, your conveying the
|
||||
covered work in a country, or your recipient's use of the covered work
|
||||
in a country, would infringe one or more identifiable patents in that
|
||||
country that you have reason to believe are valid.
|
||||
|
||||
If, pursuant to or in connection with a single transaction or
|
||||
arrangement, you convey, or propagate by procuring conveyance of, a
|
||||
covered work, and grant a patent license to some of the parties
|
||||
receiving the covered work authorizing them to use, propagate, modify
|
||||
or convey a specific copy of the covered work, then the patent license
|
||||
you grant is automatically extended to all recipients of the covered
|
||||
work and works based on it.
|
||||
|
||||
A patent license is "discriminatory" if it does not include within
|
||||
the scope of its coverage, prohibits the exercise of, or is
|
||||
conditioned on the non-exercise of one or more of the rights that are
|
||||
specifically granted under this License. You may not convey a covered
|
||||
work if you are a party to an arrangement with a third party that is
|
||||
in the business of distributing software, under which you make payment
|
||||
to the third party based on the extent of your activity of conveying
|
||||
the work, and under which the third party grants, to any of the
|
||||
parties who would receive the covered work from you, a discriminatory
|
||||
patent license (a) in connection with copies of the covered work
|
||||
conveyed by you (or copies made from those copies), or (b) primarily
|
||||
for and in connection with specific products or compilations that
|
||||
contain the covered work, unless you entered into that arrangement,
|
||||
or that patent license was granted, prior to 28 March 2007.
|
||||
|
||||
Nothing in this License shall be construed as excluding or limiting
|
||||
any implied license or other defenses to infringement that may
|
||||
otherwise be available to you under applicable patent law.
|
||||
|
||||
12. No Surrender of Others' Freedom.
|
||||
|
||||
If conditions are imposed on you (whether by court order, agreement or
|
||||
otherwise) that contradict the conditions of this License, they do not
|
||||
excuse you from the conditions of this License. If you cannot convey a
|
||||
covered work so as to satisfy simultaneously your obligations under this
|
||||
License and any other pertinent obligations, then as a consequence you may
|
||||
not convey it at all. For example, if you agree to terms that obligate you
|
||||
to collect a royalty for further conveying from those to whom you convey
|
||||
the Program, the only way you could satisfy both those terms and this
|
||||
License would be to refrain entirely from conveying the Program.
|
||||
|
||||
13. Use with the GNU Affero General Public License.
|
||||
|
||||
Notwithstanding any other provision of this License, you have
|
||||
permission to link or combine any covered work with a work licensed
|
||||
under version 3 of the GNU Affero General Public License into a single
|
||||
combined work, and to convey the resulting work. The terms of this
|
||||
License will continue to apply to the part which is the covered work,
|
||||
but the special requirements of the GNU Affero General Public License,
|
||||
section 13, concerning interaction through a network will apply to the
|
||||
combination as such.
|
||||
|
||||
14. Revised Versions of this License.
|
||||
|
||||
The Free Software Foundation may publish revised and/or new versions of
|
||||
the GNU General Public License from time to time. Such new versions will
|
||||
be similar in spirit to the present version, but may differ in detail to
|
||||
address new problems or concerns.
|
||||
|
||||
Each version is given a distinguishing version number. If the
|
||||
Program specifies that a certain numbered version of the GNU General
|
||||
Public License "or any later version" applies to it, you have the
|
||||
option of following the terms and conditions either of that numbered
|
||||
version or of any later version published by the Free Software
|
||||
Foundation. If the Program does not specify a version number of the
|
||||
GNU General Public License, you may choose any version ever published
|
||||
by the Free Software Foundation.
|
||||
|
||||
If the Program specifies that a proxy can decide which future
|
||||
versions of the GNU General Public License can be used, that proxy's
|
||||
public statement of acceptance of a version permanently authorizes you
|
||||
to choose that version for the Program.
|
||||
|
||||
Later license versions may give you additional or different
|
||||
permissions. However, no additional obligations are imposed on any
|
||||
author or copyright holder as a result of your choosing to follow a
|
||||
later version.
|
||||
|
||||
15. Disclaimer of Warranty.
|
||||
|
||||
THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY
|
||||
APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT
|
||||
HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY
|
||||
OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO,
|
||||
THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
||||
PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM
|
||||
IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF
|
||||
ALL NECESSARY SERVICING, REPAIR OR CORRECTION.
|
||||
|
||||
16. Limitation of Liability.
|
||||
|
||||
IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
|
||||
WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS
|
||||
THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY
|
||||
GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE
|
||||
USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF
|
||||
DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD
|
||||
PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS),
|
||||
EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF
|
||||
SUCH DAMAGES.
|
||||
|
||||
17. Interpretation of Sections 15 and 16.
|
||||
|
||||
If the disclaimer of warranty and limitation of liability provided
|
||||
above cannot be given local legal effect according to their terms,
|
||||
reviewing courts shall apply local law that most closely approximates
|
||||
an absolute waiver of all civil liability in connection with the
|
||||
Program, unless a warranty or assumption of liability accompanies a
|
||||
copy of the Program in return for a fee.
|
||||
|
||||
END OF TERMS AND CONDITIONS
|
||||
|
||||
How to Apply These Terms to Your New Programs
|
||||
|
||||
If you develop a new program, and you want it to be of the greatest
|
||||
possible use to the public, the best way to achieve this is to make it
|
||||
free software which everyone can redistribute and change under these terms.
|
||||
|
||||
To do so, attach the following notices to the program. It is safest
|
||||
to attach them to the start of each source file to most effectively
|
||||
state the exclusion of warranty; and each file should have at least
|
||||
the "copyright" line and a pointer to where the full notice is found.
|
||||
|
||||
<one line to give the program's name and a brief idea of what it does.>
|
||||
Copyright (C) <year> <name of author>
|
||||
|
||||
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 <https://www.gnu.org/licenses/>.
|
||||
|
||||
Also add information on how to contact you by electronic and paper mail.
|
||||
|
||||
If the program does terminal interaction, make it output a short
|
||||
notice like this when it starts in an interactive mode:
|
||||
|
||||
<program> Copyright (C) <year> <name of author>
|
||||
This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
|
||||
This is free software, and you are welcome to redistribute it
|
||||
under certain conditions; type `show c' for details.
|
||||
|
||||
The hypothetical commands `show w' and `show c' should show the appropriate
|
||||
parts of the General Public License. Of course, your program's commands
|
||||
might be different; for a GUI interface, you would use an "about box".
|
||||
|
||||
You should also get your employer (if you work as a programmer) or school,
|
||||
if any, to sign a "copyright disclaimer" for the program, if necessary.
|
||||
For more information on this, and how to apply and follow the GNU GPL, see
|
||||
<https://www.gnu.org/licenses/>.
|
||||
|
||||
The GNU General Public License does not permit incorporating your program
|
||||
into proprietary programs. If your program is a subroutine library, you
|
||||
may consider it more useful to permit linking proprietary applications with
|
||||
the library. If this is what you want to do, use the GNU Lesser General
|
||||
Public License instead of this License. But first, please read
|
||||
<https://www.gnu.org/licenses/why-not-lgpl.html>.
|
277
README.md
|
@ -1,9 +1,274 @@
|
|||
# blog
|
||||
This is a simple self-hosted, lightweight, singe-user PHP blog, where you can create your own Facebook-like feed. Give read access to other people, and you can share rich text with photos including highlighted code or links.
|
||||
|
||||
Requirements: Apache, PHP 7.0, MySQL
|
||||
In this context lightweight means:
|
||||
* No npm dependency, there won't be an annoying 1GB `node_modules` directory.
|
||||
* No pipeline. What you see is pure code without a need to install it.
|
||||
* No overhead, essential features, simple usage.
|
||||
|
||||
## How to install
|
||||
1. Copy files
|
||||
2. Import db.sql => MySQL
|
||||
3. Copy config.ini => custom.ini and define
|
||||
4. Done
|
||||
## Live demo
|
||||
Live demo is available here:
|
||||
|
||||
https://blog.m1k1o.net/
|
||||
|
||||
Please note, that this demo has very limited computing resources, strict rate limiting and can be reset at anytime. Upload of files will not always work, but as simple demo to see this product in action it is enough.
|
||||
|
||||
## Screenshots
|
||||
<details>
|
||||
<summary>Light theme</summary>
|
||||
|
||||

|
||||
</details>
|
||||
|
||||
<details>
|
||||
<summary>Dark theme</summary>
|
||||
|
||||

|
||||
</details>
|
||||
|
||||
<details>
|
||||
<summary>Legacy theme (compatible with older browsers)</summary>
|
||||
|
||||

|
||||
</details>
|
||||
|
||||
## Zero configuration setup
|
||||
Container will run without any initial configuration needed using SQLite as database provider. For better performance consider using MySQL.
|
||||
|
||||
```sh
|
||||
docker run -d -p 80:80 -v $PWD/data:/var/www/html/data m1k1o/blog:latest
|
||||
```
|
||||
|
||||
You can set environment variables, prefixed with `BLOG_` and uppercase. They can be found in `config.ini`.
|
||||
```sh
|
||||
docker run -d \
|
||||
-p 80:80 \
|
||||
-e "TZ=Europe/Vienna" \
|
||||
-e "BLOG_TITLE=Blog" \
|
||||
-e "BLOG_NAME=Max Musermann" \
|
||||
-e "BLOG_NICK=username" \
|
||||
-e "BLOG_PASS=password" \
|
||||
-e "BLOG_LANG=en" \
|
||||
-v $PWD/data:/var/www/html/data \
|
||||
m1k1o/blog:latest
|
||||
```
|
||||
|
||||
Or for docker-compose format, see [docker-compose.yml](docker-compose.yml).
|
||||
|
||||
## Install standalone app using `docker-compose` with external database
|
||||
You need to install [docker-compose](https://docs.docker.com/compose/install/).
|
||||
|
||||
### MySQL
|
||||
```yaml
|
||||
version: "3"
|
||||
services:
|
||||
webserver:
|
||||
image: m1k1o/blog:latest
|
||||
container_name: blog_apache
|
||||
environment:
|
||||
TZ: Europe/Vienna
|
||||
BLOG_DB_CONNECTION: mysql
|
||||
BLOG_MYSQL_HOST: mariadb
|
||||
BLOG_MYSQL_PORT: 3306
|
||||
BLOG_MYSQL_USER: blog
|
||||
BLOG_MYSQL_PASS: blog # use secure password
|
||||
BLOG_DB_NAME: blog
|
||||
restart: unless-stopped
|
||||
ports:
|
||||
- ${HTTP_PORT-80}:80
|
||||
volumes:
|
||||
- ${DATA-./data}:/var/www/html/data
|
||||
mariadb:
|
||||
image: mariadb:10.1
|
||||
container_name: blog_mariadb
|
||||
environment:
|
||||
MYSQL_USER: blog
|
||||
MYSQL_PASSWORD: blog # use secure password
|
||||
MYSQL_DATABASE: blog
|
||||
MYSQL_ROOT_PASSWORD: root # use secure password
|
||||
restart: unless-stopped
|
||||
volumes:
|
||||
- mariadb:/var/lib/mysql
|
||||
- ./app/db/mysql:/docker-entrypoint-initdb.d:ro
|
||||
volumes:
|
||||
mariadb:
|
||||
```
|
||||
|
||||
### Postgres
|
||||
```yaml
|
||||
version: "3"
|
||||
services:
|
||||
webserver:
|
||||
image: m1k1o/blog:latest
|
||||
container_name: blog_apache
|
||||
environment:
|
||||
TZ: Europe/Vienna
|
||||
BLOG_DB_CONNECTION: postgres
|
||||
BLOG_POSTGRES_HOST: postgres
|
||||
BLOG_POSTGRES_PORT: 5432
|
||||
BLOG_POSTGRES_USER: blog
|
||||
BLOG_POSTGRES_PASS: blog # use secure password
|
||||
BLOG_DB_NAME: blog
|
||||
restart: unless-stopped
|
||||
ports:
|
||||
- ${HTTP_PORT-80}:80
|
||||
volumes:
|
||||
- ${DATA-./data}:/var/www/html/data
|
||||
postgres:
|
||||
image: postgres:14
|
||||
container_name: blog_postgres
|
||||
environment:
|
||||
POSTGRES_USER: blog
|
||||
POSTGRES_PASSWORD: blog # use secure password
|
||||
POSTGRES_DB: blog
|
||||
restart: unless-stopped
|
||||
volumes:
|
||||
- postgres:/var/lib/postgresql/data
|
||||
- ./app/db/postgres:/docker-entrypoint-initdb.d:ro
|
||||
volumes:
|
||||
postgres:
|
||||
```
|
||||
|
||||
### Step 1: Run `docker-compose.yml`.
|
||||
Select one of configurations above and save it to `docker-compose.yml`. Then run:
|
||||
```sh
|
||||
docker-compose up -d
|
||||
```
|
||||
|
||||
You can specify these environment variables, otherwise the default ones will be used:
|
||||
* **HTTP_PORT=80** - where the blog will be accessible.
|
||||
* **DATA=./data** - directory to store the user data.
|
||||
|
||||
These environment variables can be stored in the `.env` file or passed to the command directly:
|
||||
```sh
|
||||
HTTP_PORT=3001 DATA=/home/user/blog docker-compose up -d
|
||||
```
|
||||
|
||||
### Step 2: Create `data/` directory and download `config.ini` file.
|
||||
Download default config file and copy to your new `./data/` directory.
|
||||
|
||||
```sh
|
||||
mkdir data && cd data
|
||||
wget https://raw.githubusercontent.com/m1k1o/blog/master/config.ini
|
||||
```
|
||||
|
||||
Now you can modify your config. Or you can set environment variables, in uppercase, starting with `BLOG_`, e.g. `BLOG_NAME: Max's blog`.
|
||||
|
||||
### Correct permissions
|
||||
Make sure your `./data/` directory has correct permissions. Apache is running as a `www-data` user, which needs to have write access to the `./data/` directory (for uploading images).
|
||||
|
||||
#### Prefered solution
|
||||
Change the directory owner to the `www-data` user:
|
||||
|
||||
```sh
|
||||
chown 33:33 ./data/
|
||||
```
|
||||
|
||||
Alternatively, add the `www-data` user to the user group that owns the `./data/` directory.
|
||||
|
||||
#### Bad solution (but it works)
|
||||
Set `777` permission for your `./data/`, so everyone can read, write, and execute:
|
||||
|
||||
```sh
|
||||
chmod 777 ./data/
|
||||
```
|
||||
|
||||
**NOTICE:** You should not use `777`. You are giving access to anyone for this directory. Maybe to some attacker, who can run his exploit here.
|
||||
|
||||
## Install
|
||||
If you have decided that you don't want to use Docker, you can intall it manually.
|
||||
|
||||
**Requirements:** Apache 2.0*, PHP 7.4, (MariaDB 10.1 or SQLite 3)
|
||||
|
||||
**NOTICE:** If you would like to use Nginx or another web server, make sure that the sensitive data are not exposed to the public. Since `.htaccess` is protecting those files in Apache, that could not be the case in a different environment. Take care of:
|
||||
* **config.ini** - disallow access to all *.ini* files for the public.
|
||||
* **data/logs/\_ANY_.log** - make sure no sensitive information are located in *.log*.
|
||||
|
||||
### Database Schema
|
||||
You can find database schema in `./app/db` folder.
|
||||
|
||||
### Debug mode
|
||||
To check if your server is set up correctly, turn on a debug mode (in config add `debug = true`) to see the details. In the debug mode, an error may be shown if you are missing some **PHP extensions** needed to be installed on your server.
|
||||
|
||||
## Config file
|
||||
**DO NOT** edit `./config.ini` file. If you wish to modify the config, simply make a copy to the `./data/config.ini` directory and edit it there.
|
||||
|
||||
**But, why?** If there is any change in config file (most likely adding a new feature), you will have problems with merging a new version. Also, if you would fork this repository, you might accidentally push your secrets to the git. We don't want that to happen. Content of the `/data` directory is ignored by the git, so none of your pictures or personal data should ever be published to git.
|
||||
|
||||
# Features
|
||||
|
||||
* Dark mode, retina ready, legacy theme available.
|
||||
* Use BBcode in texts.
|
||||
* Make posts available for **everyone**, **only you** or just for **friends**.
|
||||
* Extra fields in post: **Feeling**, **With** and **At**.
|
||||
* Hide posts from timeline so they are visible only when you need them to be.
|
||||
* All pasted links will get preview with page title, description and image (can be configured proxy).
|
||||
* Upload images using button *(for mobile)*.
|
||||
* Upload images using drag & drop *(drop it into textarea)*.
|
||||
* Upload images using CTRL + V *(paste it into textarea)*.
|
||||
* Highlight code in post using `[code]..your code..[/code]`.
|
||||
* Highlight your goal using `[goal]Text of your goal.[/goal]`.
|
||||
* Use tags in posts (allowed characters `A-Za-z0-9-_` terminated by space or EOL): `#song`.
|
||||
* Sort posts in reverse order (oldest first): `http://blog/#sort=reverse`.
|
||||
* Filter posts by hashtags: `http://blog/#tag=songs`.
|
||||
* Filter posts by location in url using: `http://blog/#loc=Vienna`.
|
||||
* Display posts from chosen date using (format YYYY-MM-DD or YYY-MM): `http://blog/#from=2017-06`.
|
||||
* Display posts to chosen date using (format YYYY-MM-DD or YYY-MM): `http://blog/#to=2017-06`.
|
||||
* Combine parameters in url using `&`, e.g. show posts between dates: `http://blog/#from=2017-06&to=2017-08`.
|
||||
|
||||
## Access control
|
||||
|
||||
This blog is using Mandatory Access Control (MAC), with 3 types of access levels:
|
||||
|
||||
* **Private** posts are visible only to your single account specified in `nick` and `pass`.
|
||||
* You can specify group of your **friends** and share posts only for them.
|
||||
* **Public** posts are visible to everyone, without login.
|
||||
|
||||
In `docker-compose.yml` file, specify your credentials and friends like this:
|
||||
|
||||
```yml
|
||||
version: "3"
|
||||
services:
|
||||
blog:
|
||||
image: m1k1o/blog:latest
|
||||
restart: unless-stopped
|
||||
environment:
|
||||
TZ: Europe/Vienna
|
||||
BLOG_NICK: admin_username
|
||||
BLOG_PASS: admin_password
|
||||
BLOG_FRIENDS: |
|
||||
jane:mysecretpass
|
||||
thomas:anotherpass
|
||||
ports:
|
||||
- 80:80
|
||||
volumes:
|
||||
- ./data:/var/www/html/data
|
||||
```
|
||||
|
||||
You can specify your credentials and friends in your `config.ini` file e.g.:
|
||||
|
||||
```ini
|
||||
[admin]
|
||||
force_login = true
|
||||
nick = admin_username
|
||||
pass = admin_password
|
||||
|
||||
[friends]
|
||||
friends[jane] = mysecretpass
|
||||
friends[thomas] = anotherpass
|
||||
```
|
||||
|
||||
## Localisation
|
||||
Timezone can be set in config or, for docker users, `TZ` environment variable is supported. List of timezones can be found [here](https://en.wikipedia.org/wiki/List_of_tz_database_time_zones).
|
||||
|
||||
### Language support
|
||||
Feel free to create new PR and add a new language. Specify language in config or in url: `http://blog/?hl=sk`.
|
||||
|
||||
* en - 🇬🇧 English
|
||||
* de - 🇩🇪 German
|
||||
* sk - 🇸🇰 Slovak
|
||||
* fr - 🇫🇷 French (thanks @Phundrak)
|
||||
* cz - 🇨🇿 Czech (thanks @djfinch)
|
||||
* bs - 🇧🇦 Bosnian (thanks @hajro92)
|
||||
* es - 🇪🇸 Spanish (thanks @ManuLinares)
|
||||
* ru - 🇷🇺 Russian (thanks @ozzyst)
|
||||
|
|
0
ajax.php
Executable file → Normal file
|
@ -1 +0,0 @@
|
|||
deny from all
|
15
app/ajax.class.php
Executable file → Normal file
|
@ -1,15 +1,25 @@
|
|||
<?php
|
||||
defined('PROJECT_PATH') OR exit('No direct script access allowed');
|
||||
|
||||
class Ajax
|
||||
{
|
||||
private $_response = null;
|
||||
|
||||
public function __construct(){
|
||||
ob_start();
|
||||
}
|
||||
|
||||
public function set_error($msg = null){
|
||||
$this->_response = [
|
||||
"error" => true,
|
||||
"msg" => $msg
|
||||
];
|
||||
|
||||
// Incldue debug info
|
||||
if(ob_get_length() > 0 && Config::get_safe('debug', false)){
|
||||
$this->_response["debug"] = ob_get_clean();
|
||||
}
|
||||
|
||||
// Log
|
||||
Log::put("ajax_errors", $msg);
|
||||
}
|
||||
|
@ -34,7 +44,10 @@ class Ajax
|
|||
}
|
||||
|
||||
public function json_response(){
|
||||
ob_clean();
|
||||
if(ob_get_length() > 0) {
|
||||
ob_clean();
|
||||
}
|
||||
|
||||
header('Content-Type: application/json');
|
||||
echo json_encode($this->_response);
|
||||
}
|
||||
|
|
83
app/config.class.php
Executable file → Normal file
|
@ -1,26 +1,77 @@
|
|||
<?php
|
||||
defined('PROJECT_PATH') OR exit('No direct script access allowed');
|
||||
|
||||
class Config
|
||||
{
|
||||
const CONFIG = 'config.ini';
|
||||
const CUSTOM = 'custom.ini';
|
||||
const CUSTOM = 'data/config.ini';
|
||||
const CUSTOM_FALLBACK = 'custom.ini';
|
||||
const ENV_PREFIX = 'BLOG_';
|
||||
|
||||
private static $_settings = null;
|
||||
|
||||
private static function init(){
|
||||
$config_file = PROJECT_PATH.self::CONFIG;
|
||||
|
||||
if(!is_readable($config_file)){
|
||||
throw new ConfigException('Cannot read config file');
|
||||
throw new ConfigException('Cannot read config file.');
|
||||
}
|
||||
|
||||
self::$_settings = parse_ini_file($config_file);
|
||||
$custom_config = PROJECT_PATH.self::CUSTOM;
|
||||
$default_settings = parse_ini_file($config_file);
|
||||
if($default_settings === false){
|
||||
throw new ConfigException('Cannot parse config file.');
|
||||
}
|
||||
|
||||
if(is_readable($custom_config)){
|
||||
$custom = parse_ini_file($custom_config);
|
||||
$custom_settings = [];
|
||||
if(is_readable($config_file = PROJECT_PATH.self::CUSTOM)){
|
||||
$custom = parse_ini_file($config_file);
|
||||
if($custom !== false){
|
||||
self::$_settings = array_merge(self::$_settings, $custom);
|
||||
$custom_settings = $custom;
|
||||
}
|
||||
}
|
||||
|
||||
// Fallback for legacy versions
|
||||
elseif(is_readable($config_file = PROJECT_PATH.self::CUSTOM_FALLBACK)){
|
||||
$custom = parse_ini_file($config_file);
|
||||
if($custom !== false){
|
||||
// Fallback for old direcotry structure
|
||||
if(!array_key_exists('images_path', $custom) && !array_key_exists('thumbnails_path', $custom)){
|
||||
$custom['images_path'] = 'i/';
|
||||
$custom['thumbnails_path'] = 't/';
|
||||
}
|
||||
|
||||
$custom_settings = array_merge($custom_settings, $custom);
|
||||
}
|
||||
}
|
||||
|
||||
// Fallback for versions, where mysql was default
|
||||
if(!array_key_exists('db_connection', $custom_settings) && array_key_exists('mysql_user', $custom_settings) &&
|
||||
(array_key_exists('mysql_socket', $custom_settings) || array_key_exists('mysql_host', $custom_settings))) {
|
||||
$custom_settings['db_connection'] = 'mysql';
|
||||
}
|
||||
|
||||
// Merge default and custom settings
|
||||
self::$_settings = array_merge($default_settings, $custom_settings);
|
||||
|
||||
// From envs
|
||||
$envs = getenv();
|
||||
$env_prefix_len = strlen(self::ENV_PREFIX);
|
||||
foreach($envs as $key => $value){
|
||||
if(substr($key, 0, $env_prefix_len) === self::ENV_PREFIX){
|
||||
$key = strtolower(substr($key, $env_prefix_len));
|
||||
|
||||
if($value === 'true'){
|
||||
$value = true;
|
||||
}
|
||||
elseif($value === 'false'){
|
||||
$value = false;
|
||||
}
|
||||
|
||||
// Associative arrays in environment variables
|
||||
if($key === 'visitor' || $key === 'friends'){
|
||||
$value = self::parse_env_assoc($value);
|
||||
}
|
||||
|
||||
self::$_settings[$key] = $value;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -46,6 +97,22 @@ class Config
|
|||
|
||||
return $value;
|
||||
}
|
||||
|
||||
// Parse associative array from string in format key:value
|
||||
private static function parse_env_assoc($data){
|
||||
if(!preg_match_all("/([^\s]+):([^\s]+)/s", $data, $matches)){
|
||||
return [];
|
||||
}
|
||||
|
||||
list($_, $keys, $values) = $matches;
|
||||
|
||||
$array = [];
|
||||
foreach ($values as $key => $value) {
|
||||
$array[$keys[$key]] = $value;
|
||||
}
|
||||
|
||||
return $array;
|
||||
}
|
||||
}
|
||||
|
||||
class ConfigException extends Exception {}
|
169
app/db.class.php
Executable file → Normal file
|
@ -1,4 +1,5 @@
|
|||
<?php
|
||||
defined('PROJECT_PATH') OR exit('No direct script access allowed');
|
||||
|
||||
// v3.43 (+ query counter)
|
||||
class DB
|
||||
|
@ -19,40 +20,163 @@ class DB
|
|||
return self::$_instance;
|
||||
}
|
||||
|
||||
public static function connection() {
|
||||
return Config::get_safe('db_connection', 'sqlite');
|
||||
}
|
||||
|
||||
// CONCAT() does not exist in SQLite, using || instead
|
||||
// for postgres, ERROR: could not determine data type of parameter $1
|
||||
public final static function concat(){
|
||||
$values = func_get_args();
|
||||
|
||||
if(DB::connection() === 'sqlite' || DB::connection() === 'postgres') {
|
||||
return implode(" || ", $values);
|
||||
} else {
|
||||
return 'CONCAT('.implode(", ", $values).')';
|
||||
}
|
||||
}
|
||||
|
||||
// Initialise PDO object
|
||||
private final function __construct(){
|
||||
switch(DB::connection()) {
|
||||
case 'mysql':
|
||||
$this->mysql_connect();
|
||||
break;
|
||||
case 'postgres':
|
||||
$this->postgres_connect();
|
||||
break;
|
||||
case 'sqlite':
|
||||
$this->sqlite_connect();
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
private final function mysql_connect(){
|
||||
$host = Config::get_safe('mysql_host', false);
|
||||
$port = Config::get_safe('mysql_port', false);
|
||||
$socket = Config::get_safe('mysql_socket', false);
|
||||
|
||||
if($socket === false && $host === false){
|
||||
throw new DBException("Mysql host or socket must be defined");
|
||||
throw new DBException("Mysql host or socket must be defined.");
|
||||
}
|
||||
|
||||
// Try to connect
|
||||
try {
|
||||
$this->_PDO = new \PDO(
|
||||
// Server
|
||||
'mysql:'.($socket !== false ? 'unix_socket='.$socket : 'host='.$host).';'.
|
||||
'mysql:'.
|
||||
($socket !== false
|
||||
? 'unix_socket='.$socket
|
||||
: 'host='.$host.($port !== false ? ';port='.$port : '')
|
||||
).
|
||||
// DB
|
||||
'dbname='.Config::get('db_name').';'.
|
||||
';dbname='.Config::get('db_name').
|
||||
// Charset
|
||||
'charset=utf8',
|
||||
';charset=utf8',
|
||||
// Username
|
||||
Config::get('mysql_user'),
|
||||
// Password
|
||||
Config::get_safe('mysql_pass', '')
|
||||
Config::get_safe('mysql_pass', ''),
|
||||
// Set attributes
|
||||
[
|
||||
\PDO::ATTR_ERRMODE => \PDO::ERRMODE_EXCEPTION,
|
||||
\PDO::ATTR_EMULATE_PREPARES => false
|
||||
]
|
||||
);
|
||||
|
||||
$this->_PDO->exec(
|
||||
// Set charset
|
||||
'SET NAMES utf8;'.
|
||||
|
||||
// Set timezone
|
||||
'SET time_zone="'.date('P').'";'
|
||||
);
|
||||
$this->_PDO->exec('SET NAMES utf8');
|
||||
} catch (PDOException $e) {
|
||||
throw new DBException($e->getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
// When is this not set, chat does dot work, odd behavior
|
||||
$this->_PDO->setAttribute(\PDO::ATTR_EMULATE_PREPARES, false);
|
||||
private final function postgres_connect(){
|
||||
$host = Config::get_safe('postgres_host', false);
|
||||
$port = Config::get_safe('postgres_port', false);
|
||||
$socket = Config::get_safe('postgres_socket', false);
|
||||
|
||||
// Throwing exceptions
|
||||
$this->_PDO->setAttribute(\PDO::ATTR_ERRMODE, \PDO::ERRMODE_EXCEPTION);
|
||||
//$this->_PDO->setAttribute(\PDO::MYSQL_ATTR_USE_BUFFERED_QUERY, true);
|
||||
if($socket === false && $host === false){
|
||||
throw new DBException("Postgres host or socket must be defined.");
|
||||
}
|
||||
|
||||
// Try to connect
|
||||
try {
|
||||
$this->_PDO = new \PDO(
|
||||
// Server
|
||||
'pgsql:'.
|
||||
($socket !== false
|
||||
? 'unix_socket='.$socket
|
||||
: 'host='.$host.($port !== false ? ';port='.$port : '')
|
||||
).
|
||||
// DB
|
||||
';dbname='.Config::get('db_name').
|
||||
// Charset
|
||||
';options=\'--client_encoding=UTF8\'',
|
||||
// Username
|
||||
Config::get('postgres_user'),
|
||||
// Password
|
||||
Config::get_safe('postgres_pass', ''),
|
||||
// Set attributes
|
||||
[
|
||||
\PDO::ATTR_ERRMODE => \PDO::ERRMODE_EXCEPTION,
|
||||
\PDO::ATTR_EMULATE_PREPARES => false
|
||||
]
|
||||
);
|
||||
|
||||
$this->_PDO->exec(
|
||||
// Set timezone
|
||||
'SET TIME ZONE "'.date('e').'";'
|
||||
);
|
||||
} catch (PDOException $e) {
|
||||
throw new DBException($e->getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
private final function sqlite_connect(){
|
||||
$sqlite_db = PROJECT_PATH.Config::get_safe('sqlite_db', "data/sqlite.db");
|
||||
|
||||
// First run of sqlite
|
||||
if(!file_exists($sqlite_db)) {
|
||||
if(!is_writable(dirname($sqlite_db))) {
|
||||
throw new DBException("Sqlite database directory must me writable.");
|
||||
}
|
||||
|
||||
if(!touch($sqlite_db)) {
|
||||
throw new DBException("Cannot create sqlite database file.");
|
||||
}
|
||||
|
||||
// Inilialize SQL schema
|
||||
$sql_schema = file_get_contents(APP_PATH."db/sqlite/01_schema.sql");
|
||||
|
||||
try {
|
||||
$this->_PDO = new \PDO("sqlite:".$sqlite_db, null, null, [
|
||||
\PDO::ATTR_ERRMODE => \PDO::ERRMODE_EXCEPTION
|
||||
]);
|
||||
$this->_PDO->exec($sql_schema);
|
||||
} catch (PDOException $e) {
|
||||
$this->_PDO = null;
|
||||
unlink($sqlite_db);
|
||||
|
||||
throw new DBException($e->getMessage());
|
||||
}
|
||||
|
||||
return ;
|
||||
}
|
||||
|
||||
// Try to connect
|
||||
try {
|
||||
$this->_PDO = new \PDO("sqlite:".$sqlite_db, null, null, [
|
||||
\PDO::ATTR_ERRMODE => \PDO::ERRMODE_EXCEPTION
|
||||
]);
|
||||
} catch (PDOException $e) {
|
||||
throw new DBException($e->getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
// Just flattern array to be binded : [key1, key2, [key3, [key4]]] => [key1, key2, key3, key4]
|
||||
|
@ -65,6 +189,12 @@ class DB
|
|||
return $key;
|
||||
}
|
||||
|
||||
// BUG: Force strings to be UTF-8
|
||||
// remove all 4-bytes characters.
|
||||
if(is_string($value)){
|
||||
$value = preg_replace('/[\xF0-\xF7].../s', '', $value);
|
||||
}
|
||||
|
||||
$this->_query->bindValue($key, $value);
|
||||
return ++$key;
|
||||
}
|
||||
|
@ -81,6 +211,11 @@ class DB
|
|||
$sql = $params[0];
|
||||
unset($params[0]);
|
||||
|
||||
// Replace backticks with " for postgres
|
||||
if(DB::connection() === 'postgres') {
|
||||
$sql = str_replace("`", '"', $sql);
|
||||
}
|
||||
|
||||
// Debug mode
|
||||
if(Config::get_safe('debug', false)){
|
||||
echo "<!-- ".$sql." + ".json_encode($params)." -->\n";
|
||||
|
@ -135,7 +270,11 @@ class DB
|
|||
$query .= '(';
|
||||
foreach($field as $key => $value){
|
||||
if($value === "NOW()"){
|
||||
$query .= 'NOW()';
|
||||
if(DB::connection() === 'sqlite') {
|
||||
$query .= "datetime('now', 'localtime')";
|
||||
} else {
|
||||
$query .= "NOW()";
|
||||
}
|
||||
} else {
|
||||
$query .= '?';
|
||||
$prepared_data[] = $value;
|
||||
|
@ -190,7 +329,11 @@ class DB
|
|||
$set_data = null;
|
||||
foreach($fields as $key => $value){
|
||||
if($value === "NOW()"){
|
||||
$set_data .="`{$key}` = NOW()";
|
||||
if(DB::connection() === 'sqlite') {
|
||||
$set_data .="`{$key}` = datetime('now', 'localtime')";
|
||||
} else {
|
||||
$set_data .="`{$key}` = NOW()";
|
||||
}
|
||||
} else {
|
||||
$set_data .= "`{$key}` = ?";
|
||||
$prepared_data[] = $value;
|
||||
|
|
26
app/db/postgres/01_schema.sql
Normal file
|
@ -0,0 +1,26 @@
|
|||
CREATE TABLE images (
|
||||
"id" serial PRIMARY KEY,
|
||||
"name" varchar(255) NOT NULL,
|
||||
"path" varchar(255) DEFAULT NULL,
|
||||
"thumb" varchar(255) DEFAULT NULL,
|
||||
"type" varchar(10) NOT NULL,
|
||||
"md5" char(32) NOT NULL,
|
||||
"datetime" timestamp NOT NULL,
|
||||
"status" int NOT NULL
|
||||
);
|
||||
|
||||
CREATE TYPE privacy_t as enum('private','friends','public');
|
||||
|
||||
CREATE TABLE posts (
|
||||
"id" serial PRIMARY KEY,
|
||||
"text" text NOT NULL,
|
||||
"plain_text" text NOT NULL,
|
||||
"feeling" varchar(255) NOT NULL,
|
||||
"persons" varchar(255) NOT NULL,
|
||||
"location" varchar(255) NOT NULL,
|
||||
"content" varchar(1000) NOT NULL,
|
||||
"content_type" varchar(255) NOT NULL,
|
||||
"privacy" privacy_t NOT NULL,
|
||||
"datetime" timestamp NOT NULL,
|
||||
"status" int NOT NULL
|
||||
);
|
24
app/db/sqlite/01_schema.sql
Normal file
|
@ -0,0 +1,24 @@
|
|||
CREATE TABLE `images` (
|
||||
`id` INTEGER PRIMARY KEY AUTOINCREMENT,
|
||||
`name` TEXT NOT NULL,
|
||||
`path` TEXT DEFAULT NULL,
|
||||
`thumb` TEXT DEFAULT NULL,
|
||||
`type` TEXT NOT NULL,
|
||||
`md5` TEXT NOT NULL,
|
||||
`datetime` INTEGER NOT NULL,
|
||||
`status` INTEGER NOT NULL
|
||||
);
|
||||
|
||||
CREATE TABLE `posts` (
|
||||
`id` INTEGER PRIMARY KEY AUTOINCREMENT,
|
||||
`text` TEXT NOT NULL,
|
||||
`plain_text` TEXT NOT NULL,
|
||||
`feeling` TEXT NOT NULL,
|
||||
`persons` TEXT NOT NULL,
|
||||
`location` TEXT NOT NULL,
|
||||
`content` TEXT NOT NULL,
|
||||
`content_type` TEXT NOT NULL,
|
||||
`privacy` TEXT NOT NULL,
|
||||
`datetime` INTEGER NOT NULL,
|
||||
`status` INTEGER NOT NULL
|
||||
);
|
|
@ -1 +0,0 @@
|
|||
ALTER TABLE `posts`CHANGE `pirvacy` `privacy` SET('private','friends','public') CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL;
|
95
app/image.class.php
Executable file → Normal file
|
@ -1,9 +1,21 @@
|
|||
<?php
|
||||
defined('PROJECT_PATH') OR exit('No direct script access allowed');
|
||||
|
||||
class Image
|
||||
{
|
||||
const IMAGES = 'i/';
|
||||
const THUMBS = 't/';
|
||||
const THUMB_W = 476;
|
||||
const THUMB_H = 476;
|
||||
|
||||
const PHP_FILE_UPLOAD_ERRORS = [
|
||||
0 => 'There is no error, the file uploaded with success.',
|
||||
1 => 'The uploaded file exceeds the upload_max_filesize directive in php.ini.',
|
||||
2 => 'The uploaded file exceeds the MAX_FILE_SIZE directive that was specified in the HTML form.',
|
||||
3 => 'The uploaded file was only partially uploaded.',
|
||||
4 => 'No file was uploaded.',
|
||||
6 => 'Missing a temporary folder.',
|
||||
7 => 'Failed to write file to disk.',
|
||||
8 => 'A PHP extension stopped the file upload.',
|
||||
];
|
||||
|
||||
private static function random_str($len = 10){
|
||||
$chr = '0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz';
|
||||
|
@ -50,35 +62,47 @@ class Image
|
|||
private static function thumb($source_path, $thumb_path){
|
||||
ini_set('memory_limit', '128M');
|
||||
|
||||
$thumb_w = 476;
|
||||
$thumb_h = 476;
|
||||
|
||||
$source_details = getimagesize($source_path);
|
||||
$source_w = $source_details[0];
|
||||
$source_h = $source_details[1];
|
||||
|
||||
if($source_w > $source_h){
|
||||
$new_w = $thumb_w;
|
||||
$new_w = self::THUMB_W;
|
||||
$new_h = intval($source_h * $new_w / $source_w);
|
||||
} else {
|
||||
$new_h = $thumb_h;
|
||||
$new_h = self::THUMB_H;
|
||||
$new_w = intval($source_w * $new_h / $source_h);
|
||||
}
|
||||
|
||||
switch($source_details[2]){
|
||||
case IMAGETYPE_GIF:
|
||||
$imgt = "ImageGIF";
|
||||
$imgcreatefrom = "ImageCreateFromGIF";
|
||||
$imgt = "imagegif";
|
||||
$imgcreatefrom = "imagecreatefromgif";
|
||||
break;
|
||||
|
||||
case IMAGETYPE_JPEG:
|
||||
$imgt = "ImageJPEG";
|
||||
$imgcreatefrom = "ImageCreateFromJPEG";
|
||||
$imgt = "imagejpeg";
|
||||
$imgcreatefrom = "imagecreatefromjpeg";
|
||||
break;
|
||||
|
||||
case IMAGETYPE_PNG:
|
||||
$imgt = "ImagePNG";
|
||||
$imgcreatefrom = "ImageCreateFromPNG";
|
||||
$imgt = "imagepng";
|
||||
$imgcreatefrom = "imagecreatefrompng";
|
||||
break;
|
||||
|
||||
case IMAGETYPE_WEBP:
|
||||
$imgt = "imagewebp";
|
||||
$imgcreatefrom = "imagecreatefromwebp";
|
||||
break;
|
||||
|
||||
case IMAGETYPE_WBMP:
|
||||
$imgt = "imagewbmp";
|
||||
$imgcreatefrom = "imagecreatefromwbmp";
|
||||
break;
|
||||
|
||||
case IMAGETYPE_BMP:
|
||||
$imgt = "imagebmp";
|
||||
$imgcreatefrom = "imagecreatefrombmp";
|
||||
break;
|
||||
|
||||
default:
|
||||
|
@ -86,15 +110,16 @@ class Image
|
|||
}
|
||||
|
||||
$old_image = $imgcreatefrom($source_path);
|
||||
if ($old_image === false) return false;
|
||||
|
||||
$new_image = imagecreatetruecolor($new_w, $new_h);
|
||||
imagecopyresampled($new_image, $old_image, 0, 0, 0, 0, $new_w, $new_h, $source_w, $source_h);
|
||||
|
||||
$new_image = self::fix_orientation($source_path, $new_image);
|
||||
$old_image = self::fix_orientation($source_path, $old_image);
|
||||
|
||||
$imgt($new_image, $thumb_path);
|
||||
$imgt($old_image, $source_path);
|
||||
return true;
|
||||
return $imgt($new_image, $thumb_path)
|
||||
&& $imgt($old_image, $source_path);
|
||||
}
|
||||
|
||||
public static function upload(){
|
||||
|
@ -110,37 +135,53 @@ class Image
|
|||
return $d;
|
||||
}
|
||||
|
||||
// Ensure, that directories exists
|
||||
$_images_path = Config::get('images_path');
|
||||
$_thumbnails_path = Config::get('thumbnails_path');
|
||||
if(
|
||||
(!is_dir($_images_path) && !mkdir($_images_path, 0755, true)) ||
|
||||
(!is_dir($_thumbnails_path) && !mkdir($_thumbnails_path, 0755, true))
|
||||
){
|
||||
throw new Exception("Images or thumbnails directory could not be created.");
|
||||
}
|
||||
|
||||
// Get metadata
|
||||
$name = $_FILES['file']['name'];
|
||||
$ext = pathinfo($name, PATHINFO_EXTENSION);
|
||||
|
||||
// Save to DB
|
||||
$id = DB::get_instance()->query(
|
||||
"INSERT INTO `images` ".
|
||||
"(`id`, `name`, `path`, `thumb`, `type`, `md5`, `datetime`, `status`) ".
|
||||
"VALUES (NULL, ?, NULL, NULL, ?, ?, NOW(), 0);",
|
||||
$name, $ext, $md5
|
||||
)->last_id();
|
||||
$id = DB::get_instance()->insert('images', [
|
||||
'name' => $name,
|
||||
'type' => $ext,
|
||||
'md5' => $md5,
|
||||
'datetime' => 'NOW()',
|
||||
'status' => 0,
|
||||
])->last_id();
|
||||
|
||||
// Create path name
|
||||
$name = dechex($id).self::random_str(3).".".$ext;
|
||||
$path = self::IMAGES.$name;
|
||||
$thumb = self::THUMBS.$name;
|
||||
$path = $_images_path.$name;
|
||||
$thumb = $_thumbnails_path.$name;
|
||||
|
||||
// Save path
|
||||
if(!move_uploaded_file($_FILES['file']['tmp_name'], $path)){
|
||||
throw new Exception("Can't write to image folders `i` and `t`.");
|
||||
throw new Exception(self::PHP_FILE_UPLOAD_ERRORS[$_FILES['file']['error']]);
|
||||
}
|
||||
|
||||
// Create thumb
|
||||
if(!self::thumb($path, $thumb)){
|
||||
unlink($path);
|
||||
unlink($thumb);
|
||||
throw new Exception("File is not image.");
|
||||
throw new Exception("File is not valid image.");
|
||||
}
|
||||
|
||||
// Save to DB
|
||||
DB::get_instance()->query("UPDATE `images` SET `path` = ?, `thumb` = ?, `status` = 1 WHERE `id` = ?", $path, $thumb, $id);
|
||||
DB::get_instance()->update('images', [
|
||||
'path' => $path,
|
||||
'thumb' => $thumb,
|
||||
'status' => 1,
|
||||
], "WHERE `id` = ?", $id);
|
||||
|
||||
return [
|
||||
"path" => $path,
|
||||
"thumb" => $thumb
|
||||
|
|
|
@ -1,7 +1,8 @@
|
|||
<?php
|
||||
|
||||
namespace JBBCode;
|
||||
|
||||
defined('PROJECT_PATH') OR exit('No direct script access allowed');
|
||||
|
||||
/**
|
||||
* This class represents a BBCode Definition. You may construct instances of this class directly,
|
||||
* usually through the CodeDefinitionBuilder class, to create text replacement bbcodes, or you
|
3
app/jbbcode/CodeDefinitionBuilder.php → app/jbbcode/codedefinitionbuilder.class.php
Executable file → Normal file
|
@ -1,8 +1,7 @@
|
|||
<?php
|
||||
|
||||
namespace JBBCode;
|
||||
|
||||
require_once "CodeDefinition.php";
|
||||
defined('PROJECT_PATH') OR exit('No direct script access allowed');
|
||||
|
||||
/**
|
||||
* Implements the builder pattern for the CodeDefinition class. A builder
|
|
@ -1,10 +1,7 @@
|
|||
<?php
|
||||
|
||||
namespace JBBCode;
|
||||
|
||||
require_once 'CodeDefinition.php';
|
||||
|
||||
use JBBCode\CodeDefinition;
|
||||
defined('PROJECT_PATH') OR exit('No direct script access allowed');
|
||||
|
||||
/**
|
||||
* An interface for sets of code definitons.
|
|
@ -1,12 +1,7 @@
|
|||
<?php
|
||||
|
||||
namespace JBBCode;
|
||||
|
||||
require_once 'CodeDefinition.php';
|
||||
require_once 'CodeDefinitionBuilder.php';
|
||||
require_once 'CodeDefinitionSet.php';
|
||||
require_once 'validators/CssColorValidator.php';
|
||||
require_once 'validators/UrlValidator.php';
|
||||
defined('PROJECT_PATH') OR exit('No direct script access allowed');
|
||||
|
||||
/**
|
||||
* Provides a default set of common bbcode definitions.
|
|
@ -1,8 +1,7 @@
|
|||
<?php
|
||||
|
||||
namespace JBBCode;
|
||||
|
||||
require_once 'ElementNode.php';
|
||||
defined('PROJECT_PATH') OR exit('No direct script access allowed');
|
||||
|
||||
/**
|
||||
* A DocumentElement object represents the root of a document tree. All
|
|
@ -1,8 +1,7 @@
|
|||
<?php
|
||||
|
||||
namespace JBBCode;
|
||||
|
||||
require_once 'Node.php';
|
||||
defined('PROJECT_PATH') OR exit('No direct script access allowed');
|
||||
|
||||
/**
|
||||
* An element within the tree. Consists of a tag name which defines the type of the
|
|
@ -1,12 +0,0 @@
|
|||
<?php
|
||||
require_once "/path/to/jbbcode/Parser.php";
|
||||
|
||||
$parser = new JBBCode\Parser();
|
||||
$parser->addCodeDefinitionSet(new JBBCode\DefaultCodeDefinitionSet());
|
||||
|
||||
$text = "The default codes include: [b]bold[/b], [i]italics[/i], [u]underlining[/u], ";
|
||||
$text .= "[url=http://jbbcode.com]links[/url], [color=red]color![/color] and more.";
|
||||
|
||||
$parser->parse($text);
|
||||
|
||||
print $parser->getAsHtml();
|
|
@ -1,10 +0,0 @@
|
|||
<?php
|
||||
require_once "/path/to/jbbcode/Parser.php";
|
||||
|
||||
$parser = new JBBCode\Parser();
|
||||
$parser->addCodeDefinitionSet(new JBBCode\DefaultCodeDefinitionSet());
|
||||
|
||||
$text = "The bbcode in here [b]is never closed!";
|
||||
$parser->parse($text);
|
||||
|
||||
print $parser->getAsBBCode();
|
|
@ -1,11 +0,0 @@
|
|||
<?php
|
||||
require_once "/path/to/jbbcode/Parser.php";
|
||||
|
||||
$parser = new JBBCode\Parser();
|
||||
$parser->addCodeDefinitionSet(new JBBCode\DefaultCodeDefinitionSet());
|
||||
|
||||
$text = "[b][u]There is [i]a lot[/i] of [url=http://en.wikipedia.org/wiki/Markup_language]markup[/url] in this";
|
||||
$text .= "[color=#333333]text[/color]![/u][/b]";
|
||||
$parser->parse($text);
|
||||
|
||||
print $parser->getAsText();
|
|
@ -1,7 +0,0 @@
|
|||
<?php
|
||||
require_once "/path/to/jbbcode/Parser.php";
|
||||
|
||||
$parser = new JBBCode\Parser();
|
||||
|
||||
$parser->addBBCode("quote", '<div class="quote">{param}</div>');
|
||||
$parser->addBBCode("code", '<pre class="code">{param}</pre>', false, false, 1);
|
|
@ -1,22 +0,0 @@
|
|||
<?php
|
||||
|
||||
require_once("../Parser.php");
|
||||
require_once("../visitors/SmileyVisitor.php");
|
||||
|
||||
error_reporting(E_ALL);
|
||||
|
||||
$parser = new JBBCode\Parser();
|
||||
$parser->addCodeDefinitionSet(new JBBCode\DefaultCodeDefinitionSet());
|
||||
|
||||
if (count($argv) < 2) {
|
||||
die("Usage: " . $argv[0] . " \"bbcode string\"\n");
|
||||
}
|
||||
|
||||
$inputText = $argv[1];
|
||||
|
||||
$parser->parse($inputText);
|
||||
|
||||
$smileyVisitor = new \JBBCode\visitors\SmileyVisitor();
|
||||
$parser->accept($smileyVisitor);
|
||||
|
||||
echo $parser->getAsHTML() . "\n";
|
|
@ -1,23 +0,0 @@
|
|||
<?php
|
||||
|
||||
require_once("../Parser.php");
|
||||
require_once("../visitors/TagCountingVisitor.php");
|
||||
|
||||
error_reporting(E_ALL);
|
||||
|
||||
$parser = new JBBCode\Parser();
|
||||
$parser->addCodeDefinitionSet(new JBBCode\DefaultCodeDefinitionSet());
|
||||
|
||||
if (count($argv) < 3) {
|
||||
die("Usage: " . $argv[0] . " \"bbcode string\" <tag name to check>\n");
|
||||
}
|
||||
|
||||
$inputText = $argv[1];
|
||||
$tagName = $argv[2];
|
||||
|
||||
$parser->parse($inputText);
|
||||
|
||||
$tagCountingVisitor = new \JBBCode\visitors\TagCountingVisitor();
|
||||
$parser->accept($tagCountingVisitor);
|
||||
|
||||
echo $tagCountingVisitor->getFrequency($tagName) . "\n";
|
|
@ -1,7 +1,8 @@
|
|||
<?php
|
||||
|
||||
namespace JBBCode;
|
||||
|
||||
defined('PROJECT_PATH') OR exit('No direct script access allowed');
|
||||
|
||||
/**
|
||||
* Defines an interface for validation filters for bbcode options and
|
||||
* parameters.
|
|
@ -1,7 +1,8 @@
|
|||
<?php
|
||||
|
||||
namespace JBBCode;
|
||||
|
||||
defined('PROJECT_PATH') OR exit('No direct script access allowed');
|
||||
|
||||
/**
|
||||
* A node within the document tree.
|
||||
*
|
|
@ -1,7 +1,8 @@
|
|||
<?php
|
||||
|
||||
namespace JBBCode;
|
||||
|
||||
defined('PROJECT_PATH') OR exit('No direct script access allowed');
|
||||
|
||||
/**
|
||||
* Defines an interface for a visitor to traverse the node graph.
|
||||
*
|
|
@ -1,21 +1,7 @@
|
|||
<?php
|
||||
|
||||
namespace JBBCode;
|
||||
|
||||
require_once 'ElementNode.php';
|
||||
require_once 'TextNode.php';
|
||||
require_once 'DefaultCodeDefinitionSet.php';
|
||||
require_once 'DocumentElement.php';
|
||||
require_once 'CodeDefinition.php';
|
||||
require_once 'CodeDefinitionBuilder.php';
|
||||
require_once 'CodeDefinitionSet.php';
|
||||
require_once 'NodeVisitor.php';
|
||||
require_once 'ParserException.php';
|
||||
require_once 'Tokenizer.php';
|
||||
require_once 'visitors/NestLimitVisitor.php';
|
||||
require_once 'InputValidator.php';
|
||||
|
||||
use JBBCode\CodeDefinition;
|
||||
defined('PROJECT_PATH') OR exit('No direct script access allowed');
|
||||
|
||||
/**
|
||||
* BBCodeParser is the main parser class that constructs and stores the parse tree. Through this class
|
|
@ -1,6 +1,8 @@
|
|||
<?php
|
||||
|
||||
namespace JBBCode;
|
||||
|
||||
defined('PROJECT_PATH') OR exit('No direct script access allowed');
|
||||
|
||||
use Exception;
|
||||
|
||||
class ParserException extends Exception{
|
|
@ -1,85 +0,0 @@
|
|||
<?php
|
||||
|
||||
require_once(dirname(dirname(__FILE__)) . DIRECTORY_SEPARATOR . 'Parser.php');
|
||||
|
||||
/**
|
||||
* Test cases testing the functionality of parsing bbcode and
|
||||
* retrieving a bbcode well-formed bbcode representation.
|
||||
*
|
||||
* @author jbowens
|
||||
*/
|
||||
class BBCodeToBBCodeTest extends PHPUnit_Framework_TestCase
|
||||
{
|
||||
|
||||
/**
|
||||
* A utility method for these tests that will evaluate its arguments as bbcode with
|
||||
* a fresh parser loaded with only the default bbcodes. It returns the
|
||||
* bbcode output, which in most cases should be in the input itself.
|
||||
*/
|
||||
private function defaultBBCodeParse($bbcode)
|
||||
{
|
||||
$parser = new JBBCode\Parser();
|
||||
$parser->addCodeDefinitionSet(new JBBCode\DefaultCodeDefinitionSet());
|
||||
$parser->parse($bbcode);
|
||||
return $parser->getAsBBCode();
|
||||
}
|
||||
|
||||
/**
|
||||
* Asserts that the given bbcode matches the given text when
|
||||
* the bbcode is run through defaultBBCodeParse
|
||||
*/
|
||||
private function assertBBCodeOutput($bbcode, $text)
|
||||
{
|
||||
$this->assertEquals($this->defaultBBCodeParse($bbcode), $text);
|
||||
}
|
||||
|
||||
public function testEmptyString()
|
||||
{
|
||||
$this->assertBBCodeOutput('', '');
|
||||
}
|
||||
|
||||
public function testOneTag()
|
||||
{
|
||||
$this->assertBBCodeOutput('[b]this is bold[/b]', '[b]this is bold[/b]');
|
||||
}
|
||||
|
||||
public function testOneTagWithSurroundingText()
|
||||
{
|
||||
$this->assertBBCodeOutput('buffer text [b]this is bold[/b] buffer text',
|
||||
'buffer text [b]this is bold[/b] buffer text');
|
||||
}
|
||||
|
||||
public function testMultipleTags()
|
||||
{
|
||||
$bbcode = 'this is some text with [b]bold tags[/b] and [i]italics[/i] and ' .
|
||||
'things like [u]that[/u].';
|
||||
$bbcodeOutput = 'this is some text with [b]bold tags[/b] and [i]italics[/i] and ' .
|
||||
'things like [u]that[/u].';
|
||||
$this->assertBBCodeOutput($bbcode, $bbcodeOutput);
|
||||
}
|
||||
|
||||
public function testCodeOptions()
|
||||
{
|
||||
$code = 'This contains a [url=http://jbbcode.com]url[/url] which uses an option.';
|
||||
$codeOutput = 'This contains a [url=http://jbbcode.com]url[/url] which uses an option.';
|
||||
$this->assertBBCodeOutput($code, $codeOutput);
|
||||
}
|
||||
|
||||
/**
|
||||
* @depends testCodeOptions
|
||||
*/
|
||||
public function testOmittedOption()
|
||||
{
|
||||
$code = 'This doesn\'t use the url option [url]http://jbbcode.com[/url].';
|
||||
$codeOutput = 'This doesn\'t use the url option [url]http://jbbcode.com[/url].';
|
||||
$this->assertBBCodeOutput($code, $codeOutput);
|
||||
}
|
||||
|
||||
public function testUnclosedTags()
|
||||
{
|
||||
$code = '[b]bold';
|
||||
$codeOutput = '[b]bold[/b]';
|
||||
$this->assertBBCodeOutput($code, $codeOutput);
|
||||
}
|
||||
|
||||
}
|
|
@ -1,78 +0,0 @@
|
|||
<?php
|
||||
|
||||
require_once(dirname(dirname(__FILE__)) . DIRECTORY_SEPARATOR . 'Parser.php');
|
||||
|
||||
/**
|
||||
* Test cases testing the ability to parse bbcode and retrieve a
|
||||
* plain text representation without any markup.
|
||||
*
|
||||
* @author jbowens
|
||||
*/
|
||||
class BBCodeToTextTest extends PHPUnit_Framework_TestCase
|
||||
{
|
||||
|
||||
/**
|
||||
* A utility method for these tests that will evaluate
|
||||
* its arguments as bbcode with a fresh parser loaded
|
||||
* with only the default bbcodes. It returns the
|
||||
* text output.
|
||||
*/
|
||||
private function defaultTextParse($bbcode)
|
||||
{
|
||||
$parser = new JBBCode\Parser();
|
||||
$parser->addCodeDefinitionSet(new JBBCode\DefaultCodeDefinitionSet());
|
||||
$parser->parse($bbcode);
|
||||
return $parser->getAsText();
|
||||
}
|
||||
|
||||
/**
|
||||
* Asserts that the given bbcode matches the given text when
|
||||
* the bbcode is run through defaultTextParse
|
||||
*/
|
||||
private function assertTextOutput($bbcode, $text)
|
||||
{
|
||||
$this->assertEquals($text, $this->defaultTextParse($bbcode));
|
||||
}
|
||||
|
||||
public function testEmptyString()
|
||||
{
|
||||
$this->assertTextOutput('', '');
|
||||
}
|
||||
|
||||
public function testOneTag()
|
||||
{
|
||||
$this->assertTextOutput('[b]this is bold[/b]', 'this is bold');
|
||||
}
|
||||
|
||||
public function testOneTagWithSurroundingText()
|
||||
{
|
||||
$this->assertTextOutput('buffer text [b]this is bold[/b] buffer text',
|
||||
'buffer text this is bold buffer text');
|
||||
}
|
||||
|
||||
public function testMultipleTags()
|
||||
{
|
||||
$bbcode = 'this is some text with [b]bold tags[/b] and [i]italics[/i] and ' .
|
||||
'things like [u]that[/u].';
|
||||
$text = 'this is some text with bold tags and italics and things like that.';
|
||||
$this->assertTextOutput($bbcode, $text);
|
||||
}
|
||||
|
||||
public function testCodeOptions()
|
||||
{
|
||||
$code = 'This contains a [url=http://jbbcode.com]url[/url] which uses an option.';
|
||||
$text = 'This contains a url which uses an option.';
|
||||
$this->assertTextOutput($code, $text);
|
||||
}
|
||||
|
||||
/**
|
||||
* @depends testCodeOptions
|
||||
*/
|
||||
public function testOmittedOption()
|
||||
{
|
||||
$code = 'This doesn\'t use the url option [url]http://jbbcode.com[/url].';
|
||||
$text = 'This doesn\'t use the url option http://jbbcode.com.';
|
||||
$this->assertTextOutput($code, $text);
|
||||
}
|
||||
|
||||
}
|
|
@ -1,54 +0,0 @@
|
|||
<?php
|
||||
|
||||
require_once dirname(dirname(__FILE__)) . DIRECTORY_SEPARATOR . 'Parser.php';
|
||||
|
||||
/**
|
||||
* Test cases for the default bbcode set.
|
||||
*
|
||||
* @author jbowens
|
||||
* @since May 2013
|
||||
*/
|
||||
class DefaultCodesTest extends PHPUnit_Framework_TestCase
|
||||
{
|
||||
|
||||
/**
|
||||
* Asserts that the given bbcode string produces the given html string
|
||||
* when parsed with the default bbcodes.
|
||||
*/
|
||||
public function assertProduces($bbcode, $html)
|
||||
{
|
||||
$parser = new \JBBCode\Parser();
|
||||
$parser->addCodeDefinitionSet(new JBBCode\DefaultCodeDefinitionSet());
|
||||
$parser->parse($bbcode);
|
||||
$this->assertEquals($html, $parser->getAsHtml());
|
||||
}
|
||||
|
||||
/**
|
||||
* Tests the [b] bbcode.
|
||||
*/
|
||||
public function testBold()
|
||||
{
|
||||
$this->assertProduces('[b]this should be bold[/b]', '<strong>this should be bold</strong>');
|
||||
}
|
||||
|
||||
/**
|
||||
* Tests the [color] bbcode.
|
||||
*/
|
||||
public function testColor()
|
||||
{
|
||||
$this->assertProduces('[color=red]red[/color]', '<span style="color: red">red</span>');
|
||||
}
|
||||
|
||||
/**
|
||||
* Tests the example from the documentation.
|
||||
*/
|
||||
public function testExample()
|
||||
{
|
||||
$text = "The default codes include: [b]bold[/b], [i]italics[/i], [u]underlining[/u], ";
|
||||
$text .= "[url=http://jbbcode.com]links[/url], [color=red]color![/color] and more.";
|
||||
$html = 'The default codes include: <strong>bold</strong>, <em>italics</em>, <u>underlining</u>, ';
|
||||
$html .= '<a href="http://jbbcode.com">links</a>, <span style="color: red">color!</span> and more.';
|
||||
$this->assertProduces($text, $html);
|
||||
}
|
||||
|
||||
}
|
|
@ -1,77 +0,0 @@
|
|||
<?php
|
||||
|
||||
require_once(dirname(dirname(__FILE__)) . DIRECTORY_SEPARATOR . 'Parser.php');
|
||||
|
||||
/**
|
||||
* Test cases testing the HTMLSafe visitor, which escapes all html characters in the source text
|
||||
*
|
||||
* @author astax-t
|
||||
*/
|
||||
class HTMLSafeTest extends PHPUnit_Framework_TestCase
|
||||
{
|
||||
/**
|
||||
* Asserts that the given bbcode string produces the given html string
|
||||
* when parsed with the default bbcodes.
|
||||
*/
|
||||
public function assertProduces($bbcode, $html)
|
||||
{
|
||||
$parser = new \JBBCode\Parser();
|
||||
$parser->addCodeDefinitionSet(new JBBCode\DefaultCodeDefinitionSet());
|
||||
$parser->parse($bbcode);
|
||||
|
||||
$htmlsafer = new JBBCode\visitors\HTMLSafeVisitor();
|
||||
$parser->accept($htmlsafer);
|
||||
|
||||
$this->assertEquals($html, $parser->getAsHtml());
|
||||
}
|
||||
|
||||
/**
|
||||
* Tests escaping quotes and ampersands in simple text
|
||||
*/
|
||||
public function testQuoteAndAmp()
|
||||
{
|
||||
$this->assertProduces('te"xt te&xt', 'te"xt te&xt');
|
||||
}
|
||||
|
||||
/**
|
||||
* Tests escaping quotes and ampersands inside a BBCode tag
|
||||
*/
|
||||
public function testQuoteAndAmpInTag()
|
||||
{
|
||||
$this->assertProduces('[b]te"xt te&xt[/b]', '<strong>te"xt te&xt</strong>');
|
||||
}
|
||||
|
||||
/**
|
||||
* Tests escaping HTML tags
|
||||
*/
|
||||
public function testHtmlTag()
|
||||
{
|
||||
$this->assertProduces('<b>not bold</b>', '<b>not bold</b>');
|
||||
$this->assertProduces('[b]<b>bold</b>[/b] <hr>', '<strong><b>bold</b></strong> <hr>');
|
||||
}
|
||||
|
||||
/**
|
||||
* Tests escaping ampersands in URL using [url]...[/url]
|
||||
*/
|
||||
public function testUrlParam()
|
||||
{
|
||||
$this->assertProduces('text [url]http://example.com/?a=b&c=d[/url] more text', 'text <a href="http://example.com/?a=b&c=d">http://example.com/?a=b&c=d</a> more text');
|
||||
}
|
||||
|
||||
/**
|
||||
* Tests escaping ampersands in URL using [url=...] tag
|
||||
*/
|
||||
public function testUrlOption()
|
||||
{
|
||||
$this->assertProduces('text [url=http://example.com/?a=b&c=d]this is a "link"[/url]', 'text <a href="http://example.com/?a=b&c=d">this is a "link"</a>');
|
||||
}
|
||||
|
||||
/**
|
||||
* Tests escaping ampersands in URL using [url=...] tag when URL is in quotes
|
||||
*/
|
||||
public function testUrlOptionQuotes()
|
||||
{
|
||||
$this->assertProduces('text [url="http://example.com/?a=b&c=d"]this is a "link"[/url]', 'text <a href="http://example.com/?a=b&c=d">this is a "link"</a>');
|
||||
}
|
||||
|
||||
}
|
|
@ -1,46 +0,0 @@
|
|||
<?php
|
||||
|
||||
require_once dirname(dirname(__FILE__)) . DIRECTORY_SEPARATOR . 'Parser.php';
|
||||
|
||||
/**
|
||||
* Test cases for CodeDefinition nest limits. If an element is nested beyond
|
||||
* its CodeDefinition's nest limit, it should be removed from the parse tree.
|
||||
*
|
||||
* @author jbowens
|
||||
* @since May 2013
|
||||
*/
|
||||
class NestLimitTest extends PHPUnit_Framework_TestCase
|
||||
{
|
||||
|
||||
/**
|
||||
* Tests that when elements have no nest limits they may be
|
||||
* nested indefinitely.
|
||||
*/
|
||||
public function testIndefiniteNesting()
|
||||
{
|
||||
$parser = new JBBCode\Parser();
|
||||
$parser->addBBCode('b', '<strong>{param}</strong>', false, true, -1);
|
||||
$parser->parse('[b][b][b][b][b][b][b][b]bold text[/b][/b][/b][/b][/b][/b][/b][/b]');
|
||||
$this->assertEquals('<strong><strong><strong><strong><strong><strong><strong><strong>' .
|
||||
'bold text' .
|
||||
'</strong></strong></strong></strong></strong></strong></strong></strong>',
|
||||
$parser->getAsHtml());
|
||||
}
|
||||
|
||||
/**
|
||||
* Test over nesting.
|
||||
*/
|
||||
public function testOverNesting()
|
||||
{
|
||||
$parser = new JBBCode\Parser();
|
||||
$parser->addCodeDefinitionSet(new JBBCode\DefaultCodeDefinitionSet());
|
||||
$parser->addBBCode('quote', '<blockquote>{param}</blockquote>', false, true, 2);
|
||||
$bbcode = '[quote][quote][quote]wut[/quote] huh?[/quote] i don\'t know[/quote]';
|
||||
$parser->parse($bbcode);
|
||||
$expectedBbcode = '[quote][quote] huh?[/quote] i don\'t know[/quote]';
|
||||
$expectedHtml = '<blockquote><blockquote> huh?</blockquote> i don\'t know</blockquote>';
|
||||
$this->assertEquals($expectedBbcode, $parser->getAsBBCode());
|
||||
$this->assertEquals($expectedHtml, $parser->getAsHtml());
|
||||
}
|
||||
|
||||
}
|
|
@ -1,97 +0,0 @@
|
|||
<?php
|
||||
|
||||
require_once dirname(dirname(__FILE__)) . DIRECTORY_SEPARATOR . 'Parser.php';
|
||||
|
||||
/**
|
||||
* Test cases for the code definition parameter that disallows parsing
|
||||
* of an element's content.
|
||||
*
|
||||
* @author jbowens
|
||||
*/
|
||||
class ParseContentTest extends PHPUnit_Framework_TestCase
|
||||
{
|
||||
|
||||
/**
|
||||
* Tests that when a bbcode is created with parseContent = false,
|
||||
* its contents actually are not parsed.
|
||||
*/
|
||||
public function testSimpleNoParsing()
|
||||
{
|
||||
|
||||
$parser = new JBBCode\Parser();
|
||||
$parser->addCodeDefinitionSet(new JBBCode\DefaultCodeDefinitionSet());
|
||||
$parser->addBBCode('verbatim', '{param}', false, false);
|
||||
|
||||
$parser->parse('[verbatim]plain text[/verbatim]');
|
||||
$this->assertEquals('plain text', $parser->getAsHtml());
|
||||
|
||||
$parser->parse('[verbatim][b]bold[/b][/verbatim]');
|
||||
$this->assertEquals('[b]bold[/b]', $parser->getAsHtml());
|
||||
|
||||
}
|
||||
|
||||
public function testNoParsingWithBufferText()
|
||||
{
|
||||
|
||||
$parser = new JBBCode\Parser();
|
||||
$parser->addCodeDefinitionSet(new JBBCode\DefaultCodeDefinitionSet());
|
||||
$parser->addBBCode('verbatim', '{param}', false, false);
|
||||
|
||||
$parser->parse('buffer text[verbatim]buffer text[b]bold[/b]buffer text[/verbatim]buffer text');
|
||||
$this->assertEquals('buffer textbuffer text[b]bold[/b]buffer textbuffer text', $parser->getAsHtml());
|
||||
}
|
||||
|
||||
/**
|
||||
* Tests that when a tag is not closed within an unparseable tag,
|
||||
* the BBCode output does not automatically close that tag (because
|
||||
* the contents were not parsed).
|
||||
*/
|
||||
public function testUnclosedTag()
|
||||
{
|
||||
|
||||
$parser = new JBBCode\Parser();
|
||||
$parser->addCodeDefinitionSet(new JBBCode\DefaultCodeDefinitionSet());
|
||||
$parser->addBBCode('verbatim', '{param}', false, false);
|
||||
|
||||
$parser->parse('[verbatim]i wonder [b]what will happen[/verbatim]');
|
||||
$this->assertEquals('i wonder [b]what will happen', $parser->getAsHtml());
|
||||
$this->assertEquals('[verbatim]i wonder [b]what will happen[/verbatim]', $parser->getAsBBCode());
|
||||
}
|
||||
|
||||
/**
|
||||
* Tests that an unclosed tag with parseContent = false ends cleanly.
|
||||
*/
|
||||
public function testUnclosedVerbatimTag()
|
||||
{
|
||||
$parser = new JBBCode\Parser();
|
||||
$parser->addCodeDefinitionSet(new JBBCode\DefaultCodeDefinitionSet());
|
||||
$parser->addBBCode('verbatim', '{param}', false, false);
|
||||
|
||||
$parser->parse('[verbatim]yo this [b]text should not be bold[/b]');
|
||||
$this->assertEquals('yo this [b]text should not be bold[/b]', $parser->getAsHtml());
|
||||
}
|
||||
|
||||
/**
|
||||
* Tests a malformed closing tag for a verbatim block.
|
||||
*/
|
||||
public function testMalformedVerbatimClosingTag()
|
||||
{
|
||||
$parser = new JBBCode\Parser();
|
||||
$parser->addCodeDefinitionSet(new JBBCode\DefaultCodeDefinitionSet());
|
||||
$parser->addBBCode('verbatim', '{param}', false, false);
|
||||
$parser->parse('[verbatim]yo this [b]text should not be bold[/b][/verbatim');
|
||||
$this->assertEquals('yo this [b]text should not be bold[/b][/verbatim', $parser->getAsHtml());
|
||||
}
|
||||
|
||||
/**
|
||||
* Tests an immediate end after a verbatim.
|
||||
*/
|
||||
public function testVerbatimThenEof()
|
||||
{
|
||||
$parser = new JBBCode\Parser();
|
||||
$parser->addBBCode('verbatim', '{param}', false, false);
|
||||
$parser->parse('[verbatim]');
|
||||
$this->assertEquals('', $parser->getAsHtml());
|
||||
}
|
||||
|
||||
}
|
|
@ -1,130 +0,0 @@
|
|||
<?php
|
||||
|
||||
require_once(dirname(dirname(__FILE__)) . DIRECTORY_SEPARATOR . 'Parser.php');
|
||||
|
||||
/**
|
||||
* A series of test cases for various potential parsing edge cases. This
|
||||
* includes a lot of tests using brackets for things besides genuine tag
|
||||
* names.
|
||||
*
|
||||
* @author jbowens
|
||||
*
|
||||
*/
|
||||
class ParsingEdgeCaseTest extends PHPUnit_Framework_TestCase
|
||||
{
|
||||
|
||||
/**
|
||||
* A utility method for these tests that will evaluate
|
||||
* its arguments as bbcode with a fresh parser loaded
|
||||
* with only the default bbcodes. It returns the
|
||||
* html output.
|
||||
*/
|
||||
private function defaultParse($bbcode)
|
||||
{
|
||||
$parser = new JBBCode\Parser();
|
||||
$parser->addCodeDefinitionSet(new JBBCode\DefaultCodeDefinitionSet());
|
||||
$parser->parse($bbcode);
|
||||
return $parser->getAsHtml();
|
||||
}
|
||||
|
||||
/**
|
||||
* Asserts that the given bbcode matches the given html when
|
||||
* the bbcode is run through defaultParse.
|
||||
*/
|
||||
private function assertProduces($bbcode, $html)
|
||||
{
|
||||
$this->assertEquals($html, $this->defaultParse($bbcode));
|
||||
}
|
||||
|
||||
/**
|
||||
* Tests attempting to use a code that doesn't exist.
|
||||
*/
|
||||
public function testNonexistentCodeMalformed()
|
||||
{
|
||||
$this->assertProduces('[wat]', '[wat]');
|
||||
}
|
||||
|
||||
/**
|
||||
* Tests attempting to use a code that doesn't exist, but this
|
||||
* time in a well-formed fashion.
|
||||
*
|
||||
* @depends testNonexistentCodeMalformed
|
||||
*/
|
||||
public function testNonexistentCodeWellformed()
|
||||
{
|
||||
$this->assertProduces('[wat]something[/wat]', '[wat]something[/wat]');
|
||||
}
|
||||
|
||||
/**
|
||||
* Tests a whole bunch of meaningless left brackets.
|
||||
*/
|
||||
public function testAllLeftBrackets()
|
||||
{
|
||||
$this->assertProduces('[[[[[[[[', '[[[[[[[[');
|
||||
}
|
||||
|
||||
/**
|
||||
* Tests a whole bunch of meaningless right brackets.
|
||||
*/
|
||||
public function testAllRightBrackets()
|
||||
{
|
||||
$this->assertProduces(']]]]]', ']]]]]');
|
||||
}
|
||||
|
||||
/**
|
||||
* Intermixes well-formed, meaningful tags with meaningless brackets.
|
||||
*/
|
||||
public function testRandomBracketsInWellformedCode()
|
||||
{
|
||||
$this->assertProduces('[b][[][[i]heh[/i][/b]',
|
||||
'<strong>[[][<em>heh</em></strong>');
|
||||
}
|
||||
|
||||
/**
|
||||
* Tests an unclosed tag within a closed tag.
|
||||
*/
|
||||
public function testUnclosedWithinClosed()
|
||||
{
|
||||
$this->assertProduces('[url=http://jbbcode.com][b]oh yeah[/url]',
|
||||
'<a href="http://jbbcode.com"><strong>oh yeah</strong></a>');
|
||||
}
|
||||
|
||||
/**
|
||||
* Tests half completed opening tag.
|
||||
*/
|
||||
public function testHalfOpenTag()
|
||||
{
|
||||
$this->assertProduces('[b', '[b');
|
||||
$this->assertProduces('wut [url=http://jbbcode.com',
|
||||
'wut [url=http://jbbcode.com');
|
||||
}
|
||||
|
||||
/**
|
||||
* Tests half completed closing tag.
|
||||
*/
|
||||
public function testHalfClosingTag()
|
||||
{
|
||||
$this->assertProduces('[b]this should be bold[/b',
|
||||
'<strong>this should be bold[/b</strong>');
|
||||
}
|
||||
|
||||
/**
|
||||
* Tests lots of left brackets before the actual tag. For example:
|
||||
* [[[[[[[[b]bold![/b]
|
||||
*/
|
||||
public function testLeftBracketsThenTag()
|
||||
{
|
||||
$this->assertProduces('[[[[[b]bold![/b]',
|
||||
'[[[[<strong>bold!</strong>');
|
||||
}
|
||||
|
||||
/**
|
||||
* Tests a whitespace after left bracket.
|
||||
*/
|
||||
public function testWhitespaceAfterLeftBracketWhithoutTag()
|
||||
{
|
||||
$this->assertProduces('[ ABC ] ',
|
||||
'[ ABC ] ');
|
||||
}
|
||||
|
||||
}
|
|
@ -1,130 +0,0 @@
|
|||
<?php
|
||||
|
||||
require_once(dirname(dirname(__FILE__)) . DIRECTORY_SEPARATOR . 'Parser.php');
|
||||
|
||||
class SimpleEvaluationTest extends PHPUnit_Framework_TestCase
|
||||
{
|
||||
|
||||
/**
|
||||
* A utility method for these tests that will evaluate
|
||||
* its arguments as bbcode with a fresh parser loaded
|
||||
* with only the default bbcodes. It returns the
|
||||
* html output.
|
||||
*/
|
||||
private function defaultParse($bbcode)
|
||||
{
|
||||
$parser = new JBBCode\Parser();
|
||||
$parser->addCodeDefinitionSet(new JBBCode\DefaultCodeDefinitionSet());
|
||||
$parser->parse($bbcode);
|
||||
return $parser->getAsHtml();
|
||||
}
|
||||
|
||||
/**
|
||||
* Asserts that the given bbcode matches the given html when
|
||||
* the bbcode is run through defaultParse.
|
||||
*/
|
||||
private function assertProduces($bbcode, $html)
|
||||
{
|
||||
$this->assertEquals($html, $this->defaultParse($bbcode));
|
||||
}
|
||||
|
||||
public function testEmptyString()
|
||||
{
|
||||
$this->assertProduces('', '');
|
||||
}
|
||||
|
||||
public function testOneTag()
|
||||
{
|
||||
$this->assertProduces('[b]this is bold[/b]', '<strong>this is bold</strong>');
|
||||
}
|
||||
|
||||
public function testOneTagWithSurroundingText()
|
||||
{
|
||||
$this->assertProduces('buffer text [b]this is bold[/b] buffer text',
|
||||
'buffer text <strong>this is bold</strong> buffer text');
|
||||
}
|
||||
|
||||
public function testMultipleTags()
|
||||
{
|
||||
$bbcode = <<<EOD
|
||||
this is some text with [b]bold tags[/b] and [i]italics[/i] and
|
||||
things like [u]that[/u].
|
||||
EOD;
|
||||
$html = <<<EOD
|
||||
this is some text with <strong>bold tags</strong> and <em>italics</em> and
|
||||
things like <u>that</u>.
|
||||
EOD;
|
||||
$this->assertProduces($bbcode, $html);
|
||||
}
|
||||
|
||||
public function testCodeOptions()
|
||||
{
|
||||
$code = 'This contains a [url=http://jbbcode.com/?b=2]url[/url] which uses an option.';
|
||||
$html = 'This contains a <a href="http://jbbcode.com/?b=2">url</a> which uses an option.';
|
||||
$this->assertProduces($code, $html);
|
||||
}
|
||||
|
||||
public function testAttributes()
|
||||
{
|
||||
$parser = new JBBCode\Parser();
|
||||
$builder = new JBBCode\CodeDefinitionBuilder('img', '<img src="{param}" height="{height}" alt="{alt}" />');
|
||||
$parser->addCodeDefinition($builder->setUseOption(true)->setParseContent(false)->build());
|
||||
|
||||
$expected = 'Multiple <img src="http://jbbcode.com/img.png" height="50" alt="alt text" /> options.';
|
||||
|
||||
$code = 'Multiple [img height="50" alt="alt text"]http://jbbcode.com/img.png[/img] options.';
|
||||
$parser->parse($code);
|
||||
$result = $parser->getAsHTML();
|
||||
$this->assertEquals($expected, $result);
|
||||
|
||||
$code = 'Multiple [img height=50 alt="alt text"]http://jbbcode.com/img.png[/img] options.';
|
||||
$parser->parse($code);
|
||||
$result = $parser->getAsHTML();
|
||||
$this->assertEquals($expected, $result);
|
||||
}
|
||||
|
||||
/**
|
||||
* @depends testCodeOptions
|
||||
*/
|
||||
public function testOmittedOption()
|
||||
{
|
||||
$code = 'This doesn\'t use the url option [url]http://jbbcode.com[/url].';
|
||||
$html = 'This doesn\'t use the url option <a href="http://jbbcode.com">http://jbbcode.com</a>.';
|
||||
$this->assertProduces($code, $html);
|
||||
}
|
||||
|
||||
public function testUnclosedTag()
|
||||
{
|
||||
$code = 'hello [b]world';
|
||||
$html = 'hello <strong>world</strong>';
|
||||
$this->assertProduces($code, $html);
|
||||
}
|
||||
|
||||
public function testNestingTags()
|
||||
{
|
||||
$code = '[url=http://jbbcode.com][b]hello [u]world[/u][/b][/url]';
|
||||
$html = '<a href="http://jbbcode.com"><strong>hello <u>world</u></strong></a>';
|
||||
$this->assertProduces($code, $html);
|
||||
}
|
||||
|
||||
public function testBracketInTag()
|
||||
{
|
||||
$this->assertProduces('[b]:-[[/b]', '<strong>:-[</strong>');
|
||||
}
|
||||
|
||||
public function testBracketWithSpaceInTag()
|
||||
{
|
||||
$this->assertProduces('[b]:-[ [/b]', '<strong>:-[ </strong>');
|
||||
}
|
||||
|
||||
public function testBracketWithTextInTag()
|
||||
{
|
||||
$this->assertProduces('[b]:-[ foobar[/b]', '<strong>:-[ foobar</strong>');
|
||||
}
|
||||
|
||||
public function testMultibleBracketsWithTextInTag()
|
||||
{
|
||||
$this->assertProduces('[b]:-[ [fo[o[bar[/b]', '<strong>:-[ [fo[o[bar</strong>');
|
||||
}
|
||||
|
||||
}
|
|
@ -1,74 +0,0 @@
|
|||
<?php
|
||||
|
||||
require_once(dirname(dirname(__FILE__)) . DIRECTORY_SEPARATOR . 'Tokenizer.php');
|
||||
|
||||
/**
|
||||
* Test cases testing the functionality of the Tokenizer. The tokenizer
|
||||
* is used by the parser to make parsing simpler.
|
||||
*
|
||||
* @author jbowens
|
||||
*/
|
||||
class TokenizerTest extends PHPUnit_Framework_TestCase
|
||||
{
|
||||
|
||||
public function testEmptyString()
|
||||
{
|
||||
$tokenizer = new JBBCode\Tokenizer('');
|
||||
$this->assertFalse($tokenizer->hasNext());
|
||||
}
|
||||
|
||||
public function testPlainTextOnly()
|
||||
{
|
||||
$tokenizer = new JBBCode\Tokenizer('this is some plain text.');
|
||||
$this->assertEquals('this is some plain text.', $tokenizer->next());
|
||||
$this->assertEquals('this is some plain text.', $tokenizer->current());
|
||||
$this->assertFalse($tokenizer->hasNext());
|
||||
}
|
||||
|
||||
public function testStartingBracket()
|
||||
{
|
||||
$tokenizer = new JBBCode\Tokenizer('[this has a starting bracket.');
|
||||
$this->assertEquals('[', $tokenizer->next());
|
||||
$this->assertEquals('[', $tokenizer->current());
|
||||
$this->assertEquals('this has a starting bracket.', $tokenizer->next());
|
||||
$this->assertEquals('this has a starting bracket.', $tokenizer->current());
|
||||
$this->assertFalse($tokenizer->hasNext());
|
||||
$this->assertEquals(null, $tokenizer->next());
|
||||
}
|
||||
|
||||
public function testOneTag()
|
||||
{
|
||||
$tokenizer = new JBBCode\Tokenizer('[b]');
|
||||
$this->assertEquals('[', $tokenizer->next());
|
||||
$this->assertEquals('b', $tokenizer->next());
|
||||
$this->assertEquals(']', $tokenizer->next());
|
||||
$this->assertFalse($tokenizer->hasNext());
|
||||
}
|
||||
|
||||
public function testMatchingTags()
|
||||
{
|
||||
$tokenizer = new JBBCode\Tokenizer('[url]http://jbbcode.com[/url]');
|
||||
$this->assertEquals('[', $tokenizer->next());
|
||||
$this->assertEquals('url', $tokenizer->next());
|
||||
$this->assertEquals(']', $tokenizer->next());
|
||||
$this->assertEquals('http://jbbcode.com', $tokenizer->next());
|
||||
$this->assertEquals('[', $tokenizer->next());
|
||||
$this->assertEquals('/url', $tokenizer->next());
|
||||
$this->assertEquals(']', $tokenizer->next());
|
||||
$this->assertFalse($tokenizer->hasNext());
|
||||
}
|
||||
|
||||
public function testLotsOfBrackets()
|
||||
{
|
||||
$tokenizer = new JBBCode\Tokenizer('[[][]][');
|
||||
$this->assertEquals('[', $tokenizer->next());
|
||||
$this->assertEquals('[', $tokenizer->next());
|
||||
$this->assertEquals(']', $tokenizer->next());
|
||||
$this->assertEquals('[', $tokenizer->next());
|
||||
$this->assertEquals(']', $tokenizer->next());
|
||||
$this->assertEquals(']', $tokenizer->next());
|
||||
$this->assertEquals('[', $tokenizer->next());
|
||||
$this->assertFalse($tokenizer->hasNext());
|
||||
}
|
||||
|
||||
}
|
|
@ -1,151 +0,0 @@
|
|||
<?php
|
||||
|
||||
require_once dirname(dirname(__FILE__)) . DIRECTORY_SEPARATOR . 'Parser.php';
|
||||
require_once dirname(dirname(__FILE__)) . DIRECTORY_SEPARATOR . 'validators' . DIRECTORY_SEPARATOR . 'UrlValidator.php';
|
||||
require_once dirname(dirname(__FILE__)) . DIRECTORY_SEPARATOR . 'validators' . DIRECTORY_SEPARATOR . 'CssColorValidator.php';
|
||||
|
||||
/**
|
||||
* Test cases for InputValidators.
|
||||
*
|
||||
* @author jbowens
|
||||
* @since May 2013
|
||||
*/
|
||||
class ValidatorTest extends PHPUnit_Framework_TestCase
|
||||
{
|
||||
|
||||
/**
|
||||
* Tests an invalid url directly on the UrlValidator.
|
||||
*/
|
||||
public function testInvalidUrl()
|
||||
{
|
||||
$urlValidator = new \JBBCode\validators\UrlValidator();
|
||||
$this->assertFalse($urlValidator->validate('#yolo#swag'));
|
||||
$this->assertFalse($urlValidator->validate('giehtiehwtaw352353%3'));
|
||||
}
|
||||
|
||||
/**
|
||||
* Tests a valid url directly on the UrlValidator.
|
||||
*/
|
||||
public function testValidUrl()
|
||||
{
|
||||
$urlValidator = new \JBBCode\validators\UrlValidator();
|
||||
$this->assertTrue($urlValidator->validate('http://google.com'));
|
||||
$this->assertTrue($urlValidator->validate('http://jbbcode.com/docs'));
|
||||
$this->assertTrue($urlValidator->validate('https://www.maps.google.com'));
|
||||
}
|
||||
|
||||
/**
|
||||
* Tests an invalid url as an option to a url bbcode.
|
||||
*
|
||||
* @depends testInvalidUrl
|
||||
*/
|
||||
public function testInvalidOptionUrlBBCode()
|
||||
{
|
||||
$parser = new JBBCode\Parser();
|
||||
$parser->addCodeDefinitionSet(new JBBCode\DefaultCodeDefinitionSet());
|
||||
$parser->parse('[url=javascript:alert("HACKED!");]click me[/url]');
|
||||
$this->assertEquals('[url=javascript:alert("HACKED!");]click me[/url]',
|
||||
$parser->getAsHtml());
|
||||
}
|
||||
|
||||
/**
|
||||
* Tests an invalid url as the body to a url bbcode.
|
||||
*
|
||||
* @depends testInvalidUrl
|
||||
*/
|
||||
public function testInvalidBodyUrlBBCode()
|
||||
{
|
||||
$parser = new JBBCode\Parser();
|
||||
$parser->addCodeDefinitionSet(new JBBCode\DefaultCodeDefinitionSet());
|
||||
$parser->parse('[url]javascript:alert("HACKED!");[/url]');
|
||||
$this->assertEquals('[url]javascript:alert("HACKED!");[/url]', $parser->getAsHtml());
|
||||
}
|
||||
|
||||
/**
|
||||
* Tests a valid url as the body to a url bbcode.
|
||||
*
|
||||
* @depends testValidUrl
|
||||
*/
|
||||
public function testValidUrlBBCode()
|
||||
{
|
||||
$parser = new JBBCode\Parser();
|
||||
$parser->addCodeDefinitionSet(new JBBCode\DefaultCodeDefinitionSet());
|
||||
$parser->parse('[url]http://jbbcode.com[/url]');
|
||||
$this->assertEquals('<a href="http://jbbcode.com">http://jbbcode.com</a>',
|
||||
$parser->getAsHtml());
|
||||
}
|
||||
|
||||
/**
|
||||
* Tests valid english CSS color descriptions on the CssColorValidator.
|
||||
*/
|
||||
public function testCssColorEnglish()
|
||||
{
|
||||
$colorValidator = new JBBCode\validators\CssColorValidator();
|
||||
$this->assertTrue($colorValidator->validate('red'));
|
||||
$this->assertTrue($colorValidator->validate('yellow'));
|
||||
$this->assertTrue($colorValidator->validate('LightGoldenRodYellow'));
|
||||
}
|
||||
|
||||
/**
|
||||
* Tests valid hexadecimal CSS color values on the CssColorValidator.
|
||||
*/
|
||||
public function testCssColorHex()
|
||||
{
|
||||
$colorValidator = new JBBCode\validators\CssColorValidator();
|
||||
$this->assertTrue($colorValidator->validate('#000'));
|
||||
$this->assertTrue($colorValidator->validate('#ff0000'));
|
||||
$this->assertTrue($colorValidator->validate('#aaaaaa'));
|
||||
}
|
||||
|
||||
/**
|
||||
* Tests valid rgba CSS color values on the CssColorValidator.
|
||||
*/
|
||||
public function testCssColorRgba()
|
||||
{
|
||||
$colorValidator = new JBBCode\validators\CssColorValidator();
|
||||
$this->assertTrue($colorValidator->validate('rgba(255, 0, 0, 0.5)'));
|
||||
$this->assertTrue($colorValidator->validate('rgba(50, 50, 50, 0.0)'));
|
||||
}
|
||||
|
||||
/**
|
||||
* Tests invalid CSS color values on the CssColorValidator.
|
||||
*/
|
||||
public function testInvalidCssColor()
|
||||
{
|
||||
$colorValidator = new JBBCode\validators\CssColorValidator();
|
||||
$this->assertFalse($colorValidator->validate('" onclick="javascript: alert(\"gotcha!\");'));
|
||||
$this->assertFalse($colorValidator->validate('"><marquee scrollamount="100'));
|
||||
}
|
||||
|
||||
/**
|
||||
* Tests valid css colors in a color bbcode.
|
||||
*
|
||||
* @depends testCssColorEnglish
|
||||
* @depends testCssColorHex
|
||||
*/
|
||||
public function testValidColorBBCode()
|
||||
{
|
||||
$parser = new JBBCode\Parser();
|
||||
$parser->addCodeDefinitionSet(new JBBCode\DefaultCodeDefinitionSet());
|
||||
$parser->parse('[color=red]colorful text[/color]');
|
||||
$this->assertEquals('<span style="color: red">colorful text</span>',
|
||||
$parser->getAsHtml());
|
||||
$parser->parse('[color=#00ff00]green[/color]');
|
||||
$this->assertEquals('<span style="color: #00ff00">green</span>', $parser->getAsHtml());
|
||||
}
|
||||
|
||||
/**
|
||||
* Tests invalid css colors in a color bbcode.
|
||||
*
|
||||
* @depends testInvalidCssColor
|
||||
*/
|
||||
public function testInvalidColorBBCode()
|
||||
{
|
||||
$parser = new JBBCode\Parser();
|
||||
$parser->addCodeDefinitionSet(new JBBCode\DefaultCodeDefinitionSet());
|
||||
$parser->parse('[color=" onclick="alert(\'hey ya!\');]click me[/color]');
|
||||
$this->assertEquals('[color=" onclick="alert(\'hey ya!\');]click me[/color]',
|
||||
$parser->getAsHtml());
|
||||
}
|
||||
|
||||
}
|
|
@ -1,8 +1,7 @@
|
|||
<?php
|
||||
|
||||
namespace JBBCode;
|
||||
|
||||
require_once 'Node.php';
|
||||
defined('PROJECT_PATH') OR exit('No direct script access allowed');
|
||||
|
||||
/**
|
||||
* Represents a piece of text data. TextNodes never have children.
|
|
@ -1,7 +1,8 @@
|
|||
<?php
|
||||
|
||||
namespace JBBCode;
|
||||
|
||||
defined('PROJECT_PATH') OR exit('No direct script access allowed');
|
||||
|
||||
/**
|
||||
* This Tokenizer is used while constructing the parse tree. The tokenizer
|
||||
* handles splitting the input into brackets and miscellaneous text. The
|
|
@ -1,8 +1,7 @@
|
|||
<?php
|
||||
|
||||
namespace JBBCode\validators;
|
||||
|
||||
require_once dirname(dirname(__FILE__)) . DIRECTORY_SEPARATOR . 'InputValidator.php';
|
||||
defined('PROJECT_PATH') OR exit('No direct script access allowed');
|
||||
|
||||
/**
|
||||
* An InputValidator for CSS color values. This is a very rudimentary
|
|
@ -1,8 +1,7 @@
|
|||
<?php
|
||||
|
||||
namespace JBBCode\validators;
|
||||
|
||||
require_once dirname(dirname(__FILE__)) . DIRECTORY_SEPARATOR . 'InputValidator.php';
|
||||
defined('PROJECT_PATH') OR exit('No direct script access allowed');
|
||||
|
||||
/**
|
||||
* An InputValidator for urls. This can be used to make [url] bbcodes secure.
|
|
@ -1,52 +0,0 @@
|
|||
<?php
|
||||
|
||||
namespace JBBCode\visitors;
|
||||
|
||||
/**
|
||||
* This visitor escapes html content of all strings and attributes
|
||||
*
|
||||
* @author Alexander Polyanskikh
|
||||
*/
|
||||
class HTMLSafeVisitor implements \JBBCode\NodeVisitor
|
||||
{
|
||||
public function visitDocumentElement(\JBBCode\DocumentElement $documentElement)
|
||||
{
|
||||
foreach ($documentElement->getChildren() as $child) {
|
||||
$child->accept($this);
|
||||
}
|
||||
}
|
||||
|
||||
public function visitTextNode(\JBBCode\TextNode $textNode)
|
||||
{
|
||||
$textNode->setValue($this->htmlSafe($textNode->getValue()));
|
||||
}
|
||||
|
||||
public function visitElementNode(\JBBCode\ElementNode $elementNode)
|
||||
{
|
||||
$attrs = $elementNode->getAttribute();
|
||||
if (is_array($attrs))
|
||||
{
|
||||
foreach ($attrs as &$el)
|
||||
$el = $this->htmlSafe($el);
|
||||
|
||||
$elementNode->setAttribute($attrs);
|
||||
}
|
||||
|
||||
foreach ($elementNode->getChildren() as $child) {
|
||||
$child->accept($this);
|
||||
}
|
||||
}
|
||||
|
||||
protected function htmlSafe($str, $options = null)
|
||||
{
|
||||
if (is_null($options))
|
||||
{
|
||||
if (defined('ENT_DISALLOWED'))
|
||||
$options = ENT_QUOTES | ENT_DISALLOWED | ENT_HTML401; // PHP 5.4+
|
||||
else
|
||||
$options = ENT_QUOTES; // PHP 5.3
|
||||
}
|
||||
|
||||
return htmlspecialchars($str, $options, 'UTF-8');
|
||||
}
|
||||
}
|
|
@ -1,42 +0,0 @@
|
|||
<?php
|
||||
|
||||
namespace JBBCode\visitors;
|
||||
|
||||
/**
|
||||
* This visitor is an example of how to implement smiley parsing on the JBBCode
|
||||
* parse graph. It converts :) into image tags pointing to /smiley.png.
|
||||
*
|
||||
* @author jbowens
|
||||
* @since April 2013
|
||||
*/
|
||||
class SmileyVisitor implements \JBBCode\NodeVisitor
|
||||
{
|
||||
|
||||
function visitDocumentElement(\JBBCode\DocumentElement $documentElement)
|
||||
{
|
||||
foreach($documentElement->getChildren() as $child) {
|
||||
$child->accept($this);
|
||||
}
|
||||
}
|
||||
|
||||
function visitTextNode(\JBBCode\TextNode $textNode)
|
||||
{
|
||||
/* Convert :) into an image tag. */
|
||||
$textNode->setValue(str_replace(':)',
|
||||
'<img src="/smiley.png" alt=":)" />',
|
||||
$textNode->getValue()));
|
||||
}
|
||||
|
||||
function visitElementNode(\JBBCode\ElementNode $elementNode)
|
||||
{
|
||||
/* We only want to visit text nodes within elements if the element's
|
||||
* code definition allows for its content to be parsed.
|
||||
*/
|
||||
if ($elementNode->getCodeDefinition()->parseContent()) {
|
||||
foreach ($elementNode->getChildren() as $child) {
|
||||
$child->accept($this);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
|
@ -1,60 +0,0 @@
|
|||
<?php
|
||||
|
||||
namespace JBBCode\visitors;
|
||||
|
||||
/**
|
||||
* This visitor traverses parse graph, counting the number of times each
|
||||
* tag name occurs.
|
||||
*
|
||||
* @author jbowens
|
||||
* @since January 2013
|
||||
*/
|
||||
class TagCountingVisitor implements \JBBcode\NodeVisitor
|
||||
{
|
||||
protected $frequencies = array();
|
||||
|
||||
public function visitDocumentElement(\JBBCode\DocumentElement $documentElement)
|
||||
{
|
||||
foreach ($documentElement->getChildren() as $child) {
|
||||
$child->accept($this);
|
||||
}
|
||||
}
|
||||
|
||||
public function visitTextNode(\JBBCode\TextNode $textNode)
|
||||
{
|
||||
// Nothing to do here, text nodes do not have tag names or children
|
||||
}
|
||||
|
||||
public function visitElementNode(\JBBCode\ElementNode $elementNode)
|
||||
{
|
||||
$tagName = strtolower($elementNode->getTagName());
|
||||
|
||||
// Update this tag name's frequency
|
||||
if (isset($this->frequencies[$tagName])) {
|
||||
$this->frequencies[$tagName]++;
|
||||
} else {
|
||||
$this->frequencies[$tagName] = 1;
|
||||
}
|
||||
|
||||
// Visit all the node's childrens
|
||||
foreach ($elementNode->getChildren() as $child) {
|
||||
$child->accept($this);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieves the frequency of the given tag name.
|
||||
*
|
||||
* @param $tagName the tag name to look up
|
||||
*/
|
||||
public function getFrequency($tagName)
|
||||
{
|
||||
if (!isset($this->frequencies[$tagName])) {
|
||||
return 0;
|
||||
} else {
|
||||
return $this->frequencies[$tagName];
|
||||
}
|
||||
}
|
||||
|
||||
}
|
7
app/jbbcode/visitors/NestLimitVisitor.php → app/jbbcode/visitors/nestlimitvisitor.class.php
Executable file → Normal file
|
@ -1,12 +1,7 @@
|
|||
<?php
|
||||
|
||||
namespace JBBCode\visitors;
|
||||
|
||||
require_once dirname(dirname(__FILE__)) . DIRECTORY_SEPARATOR . 'CodeDefinition.php';
|
||||
require_once dirname(dirname(__FILE__)) . DIRECTORY_SEPARATOR . 'DocumentElement.php';
|
||||
require_once dirname(dirname(__FILE__)) . DIRECTORY_SEPARATOR . 'ElementNode.php';
|
||||
require_once dirname(dirname(__FILE__)) . DIRECTORY_SEPARATOR . 'NodeVisitor.php';
|
||||
require_once dirname(dirname(__FILE__)) . DIRECTORY_SEPARATOR . 'TextNode.php';
|
||||
defined('PROJECT_PATH') OR exit('No direct script access allowed');
|
||||
|
||||
/**
|
||||
* This visitor is used by the jBBCode core to enforce nest limits after
|
5
app/lang.class.php
Executable file → Normal file
|
@ -1,4 +1,5 @@
|
|||
<?php
|
||||
defined('PROJECT_PATH') OR exit('No direct script access allowed');
|
||||
|
||||
class Lang
|
||||
{
|
||||
|
@ -14,7 +15,7 @@ class Lang
|
|||
}
|
||||
|
||||
public static function get($key){
|
||||
if(!array_key_exists($key, self::$_dictionary)){
|
||||
if(is_null(self::$_dictionary) || !array_key_exists($key, self::$_dictionary)){
|
||||
return $key;
|
||||
}
|
||||
|
||||
|
@ -24,4 +25,4 @@ class Lang
|
|||
|
||||
function __($key){
|
||||
return Lang::get($key);
|
||||
}
|
||||
}
|
||||
|
|
67
app/lang/bs.ini
Normal file
|
@ -0,0 +1,67 @@
|
|||
; index.html
|
||||
Show More = "Prikaži još"
|
||||
|
||||
Login = "Prijava"
|
||||
Logout = "Odjava"
|
||||
|
||||
Nick = "Nadimak"
|
||||
Password = "Šifra"
|
||||
Cancel = "Zatvori"
|
||||
|
||||
Post = "Objavi"
|
||||
|
||||
Edit Post = "Izmijeni Objavu"
|
||||
Change Date = "Promijeni Datum"
|
||||
Hide from Timeline = "Sakrij sa Vremenske Linije"
|
||||
Show on Timeline = "Prikaži na Vremenskoj Liniji"
|
||||
Delete Post = "Izbriši objavu"
|
||||
|
||||
Drag photos here = "Privuci fotografije ovdje"
|
||||
Drop photos here = "Privuci fotografije ovdje"
|
||||
What's on your mind? = "Šta vam je na umu?"
|
||||
Feeling = "Osjećaj"
|
||||
How are you feeling? = "Kako se osjećate?"
|
||||
With = "Sa"
|
||||
Who are you with? = "S kim ste?"
|
||||
At = "Gdje"
|
||||
Where are you? = "Gdje se nalazite?"
|
||||
Save = "Sačuvaj"
|
||||
|
||||
January = "Januar"
|
||||
February = "Februar"
|
||||
March = "Mart"
|
||||
April = "April"
|
||||
May = "Maj"
|
||||
June = "Juni"
|
||||
July = "Juli"
|
||||
August = "Avgust"
|
||||
September = "Septembar"
|
||||
October = "Oktobar"
|
||||
November = "Novembar"
|
||||
December = "Decembar"
|
||||
|
||||
Time: = "Vrijeme:"
|
||||
Hour: = "Sati:"
|
||||
Minute: = "Minute:"
|
||||
|
||||
This post will be deleted and you'll no longer be able to find it. You can also edit this post if you just want to change something. = "Ova će objava biti izbrisana i nećete je više moći pronaći. Takođe možete izmijeniti ovu objavu ako želite izvršiti izmjene."
|
||||
|
||||
with = "sa"
|
||||
here: = "ovdje:"
|
||||
|
||||
Public = "Javno"
|
||||
Friends = "Prijatelji"
|
||||
Only me = "Samo ja"
|
||||
|
||||
Show hidden content = "Prikaži skriveni sadržaj"
|
||||
Show all posts = "Prikaži sve objave"
|
||||
|
||||
; user.class.php
|
||||
You are already logged in. = "Već ste prijavljeni."
|
||||
The nick or password is incorrect. = "Nadimak ili šifra su pogrešni."
|
||||
You can't log out. There is no account. = "Ne možete se odjaviti. Račun ne postoji."
|
||||
You are not even logged in. = "Niste čak ni prijavljeni."
|
||||
|
||||
; post.class.php
|
||||
You need to be logged in to perform this action. = "Morate biti priavljeni da biste izvršili ovu radnju."
|
||||
No data. = "Nema podataka."
|
67
app/lang/cz.ini
Normal file
|
@ -0,0 +1,67 @@
|
|||
; index.html
|
||||
Show More = "Zobrazit více"
|
||||
|
||||
Login = "Přihlásit se"
|
||||
Logout = "Odhlásit se"
|
||||
|
||||
Nick = "Přihlašovací jméno"
|
||||
Password = "Heslo"
|
||||
Cancel = "Zrušit"
|
||||
|
||||
Post = "Nový příspěvek"
|
||||
|
||||
Edit Post = "Upravit příspěvek"
|
||||
Change Date = "Změnit datum"
|
||||
Hide from Timeline = "Skrýt na časové ose"
|
||||
Show on Timeline = "Zobrazit na časové ose"
|
||||
Delete Post = "Odstranit příspěvek"
|
||||
|
||||
Drag photos here = "Sem přesuňte fotografie"
|
||||
Drop photos here = "Zde vložte fotografie"
|
||||
What's on your mind? = "Na co myslíš?"
|
||||
Feeling = "Pocit"
|
||||
How are you feeling? = "Jak se cítíš?"
|
||||
With = "Spolu s"
|
||||
Who are you with? = "S kým jsi?"
|
||||
At = "Místo"
|
||||
Where are you? = "Kde jsi?"
|
||||
Save = "Uložit"
|
||||
|
||||
January = "Leden"
|
||||
February = "Únor"
|
||||
March = "Březen"
|
||||
April = "Duben"
|
||||
May = "Květen"
|
||||
June = "Červen"
|
||||
July = "Červenec"
|
||||
August = "Srpen"
|
||||
September = "Září"
|
||||
October = "Říjen"
|
||||
November = "Listopad"
|
||||
December = "Prosinec"
|
||||
|
||||
Time: = "Čas:"
|
||||
Hour: = "Hodina:"
|
||||
Minute: = "Minuta:"
|
||||
|
||||
This post will be deleted and you'll no longer be able to find it. You can also edit this post if you just want to change something. = "Tento příspěvek bude odstraněn a už ho nebude možné najít. Pokud chcete něco změnit, můžete tento příspěvek také upravit."
|
||||
|
||||
with = "s"
|
||||
here: = "zde:"
|
||||
|
||||
Public = "Veřejné"
|
||||
Friends = "Přátelé"
|
||||
Only me = "Jen já"
|
||||
|
||||
Show hidden content = "Zobrazit skrytý obsah"
|
||||
Show all posts = "Zobrazit všechny příspěvky"
|
||||
|
||||
; user.class.php
|
||||
You are already logged in. = "Už jsi přihlášený."
|
||||
The nick or password is incorrect. = "Přihlašovací jméno nebo heslo je nesprávné."
|
||||
You can't log out. There is no account. = "Nemůžeš se odhlásit. Neexistuje žádný účet."
|
||||
You are not even logged in. = "Nejsi ani přihlášený."
|
||||
|
||||
; post.class.php
|
||||
You need to be logged in to perform this action. = "Na provedení této akce musíš být přihlášený."
|
||||
No data. = "Žádná data."
|
|
@ -13,6 +13,7 @@ Post = "Verfasse einen Beitrag"
|
|||
Edit Post = "Beitrag bearbeiten"
|
||||
Change Date = "Datum ändern"
|
||||
Hide from Timeline = "In der Chronik verbergen"
|
||||
Show on Timeline = "In der Chronik anzeigen"
|
||||
Delete Post = "Beitrag löschen"
|
||||
|
||||
Drag photos here = "Fotos hierher ziehen"
|
||||
|
@ -52,6 +53,7 @@ Public = "Öffentlich"
|
|||
Friends = "Freunde"
|
||||
Only me = "Nur ich"
|
||||
|
||||
Show hidden content = "Verborgenen Inhalt anzeigen"
|
||||
Show all posts = "Alle Beiträge anzeigen"
|
||||
|
||||
; user.class.php
|
||||
|
@ -63,6 +65,3 @@ You are not even logged in. = "Du bist nicht mal eingeloggt."
|
|||
; post.class.php
|
||||
You need to be logged in to perform this action. = "Du musst angemeldet sein, um diese Aktion durchzuführen."
|
||||
No data. = "Keine Daten."
|
||||
|
||||
; log.class.php
|
||||
Can't write to %s.log file. = "Kann nicht in %s.log Datei schreiben."
|
|
@ -13,6 +13,7 @@ Post = "Post"
|
|||
Edit Post = "Edit Post"
|
||||
Change Date = "Change Date"
|
||||
Hide from Timeline = "Hide from Timeline"
|
||||
Show on Timeline = "Show on Timeline"
|
||||
Delete Post = "Delete Post"
|
||||
|
||||
Drag photos here = "Drag photos here"
|
||||
|
@ -52,6 +53,7 @@ Public = "Public"
|
|||
Friends = "Friends"
|
||||
Only me = "Only me"
|
||||
|
||||
Show hidden content = "Show hidden content"
|
||||
Show all posts = "Show all posts"
|
||||
|
||||
; user.class.php
|
||||
|
@ -63,6 +65,3 @@ You are not even logged in. = "You are not even logged in."
|
|||
; post.class.php
|
||||
You need to be logged in to perform this action. = "You need to be logged in to perform this action."
|
||||
No data. = "No data."
|
||||
|
||||
; log.class.php
|
||||
Can't write to %s.log file. = "Can't write to %s.log file."
|
67
app/lang/es.ini
Normal file
|
@ -0,0 +1,67 @@
|
|||
; index.html
|
||||
Show More = "Mostrar más"
|
||||
|
||||
Login = "Iniciar sesión"
|
||||
Logout = "Cerrar sesión"
|
||||
|
||||
Nick = "Apodo"
|
||||
Password = "Contraseña"
|
||||
Cancel = "Cancelar"
|
||||
|
||||
Post = "Publicar"
|
||||
|
||||
Edit Post = "Editar publicación"
|
||||
Change Date = "Cambiar fecha"
|
||||
Hide from Timeline = "Ocultar de la línea de tiempo"
|
||||
Show on Timeline = "Mostrar en la línea de tiempo"
|
||||
Delete Post = "Eliminar publicación"
|
||||
|
||||
Drag photos here = "Arrastra aquí las fotos"
|
||||
Drop photos here = "Suelta aquí las fotos"
|
||||
What's on your mind? = "¿Qué estas pensando?"
|
||||
Feeling = "Sintiendo"
|
||||
How are you feeling? = "¿Como te sientes?"
|
||||
With = "Con"
|
||||
Who are you with? = "¿Con quién estás?"
|
||||
At = "En"
|
||||
Where are you? = "¿Dónde estás?"
|
||||
Save = "Guardar"
|
||||
|
||||
January = "Enero"
|
||||
February = "Febrero"
|
||||
March = "Marzo"
|
||||
April = "Abril"
|
||||
May = "Mayo"
|
||||
June = "Junio"
|
||||
July = "Julio"
|
||||
August = "Agosto"
|
||||
September = "Septiembre"
|
||||
October = "Octubre"
|
||||
November = "Noviembre"
|
||||
December = "Diciembre"
|
||||
|
||||
Time: = "Hora:"
|
||||
Hour: = "Hora:"
|
||||
Minute: = "Minuto:"
|
||||
|
||||
This post will be deleted and you'll no longer be able to find it. You can also edit this post if you just want to change something. = "Esta publicación se eliminará y ya no podrá ser encontrada. También puedes editar esta publicación si solo deseas cambiar algo."
|
||||
|
||||
with = "con"
|
||||
here: = "aqui:"
|
||||
|
||||
Public = "Público"
|
||||
Friends = "Amigos"
|
||||
Only me = "Solo yo"
|
||||
|
||||
Show hidden content = "Mostrar contenido oculto"
|
||||
Show all posts = "Mostrar todas las publicaciones"
|
||||
|
||||
; user.class.php
|
||||
You are already logged in. = "Ya has iniciado sesión."
|
||||
The nick or password is incorrect. = "El apodo o la contraseña son incorrectos."
|
||||
You can't log out. There is no account. = "No puede cerrar sesión. No hay cuenta."
|
||||
You are not even logged in. = "Ni siquiera estás conectado."
|
||||
|
||||
; post.class.php
|
||||
You need to be logged in to perform this action. = "Debe haber iniciado una sesión para realizar esta acción."
|
||||
No data. = "Sin datos."
|
67
app/lang/fr.ini
Normal file
|
@ -0,0 +1,67 @@
|
|||
; index.html
|
||||
Show More = "Voir plus"
|
||||
|
||||
Login = "Connexion"
|
||||
Logout = "Déconnexion"
|
||||
|
||||
Nick = "Pseudo"
|
||||
Password = "Mot de passe"
|
||||
Cancel = "Annuler"
|
||||
|
||||
Post = "Publier"
|
||||
|
||||
Edit Post = "Modifier la publication"
|
||||
Change Date = "Changer la date"
|
||||
Hide from Timeline = "Cacher du mur"
|
||||
Show on Timeline = "Montrer sur le mur"
|
||||
Delete Post = "Supprimer la publication"
|
||||
|
||||
Drag photos here = "Glisser les photos ici"
|
||||
Drop photos here = "Déposer les photos ici"
|
||||
What's on your mind? = "Que souhaitez-vous partager ?"
|
||||
Feeling = "Je me sens"
|
||||
How are you feeling? = "Comment vous sentez-vous ?"
|
||||
With = "Avec"
|
||||
Who are you with? = "Avec qui êtes-vous ?"
|
||||
At = "À"
|
||||
Where are you? = "Où êtes-vous ?"
|
||||
Save = "Enregistrer"
|
||||
|
||||
January = "Janvier"
|
||||
February = "Février"
|
||||
March = "Mars"
|
||||
April = "Avril"
|
||||
May = "Mai"
|
||||
June = "Juin"
|
||||
July = "Juillet"
|
||||
August = "Août"
|
||||
September = "Septembre"
|
||||
October = "Octobre"
|
||||
November = "Novembre"
|
||||
December = "Décembre"
|
||||
|
||||
Time: = "Heure :"
|
||||
Hour: = "Heure :"
|
||||
Minute: = "Minutes :"
|
||||
|
||||
This post will be deleted and you'll no longer be able to find it. You can also edit this post if you just want to change something. = "Cette publication sera supprimée et vous ne pourrez plus la retrouver. Vous pouvez aussi la modifier si vous souhaitez simplement changer quelque chose."
|
||||
|
||||
with = "avec"
|
||||
here: = "à"
|
||||
|
||||
Public = "Publique"
|
||||
Friends = "Amis"
|
||||
Only me = "Seulement moi"
|
||||
|
||||
Show hidden content = "Montrer le contenu caché"
|
||||
Show all posts = "Montrer toutes les publications"
|
||||
|
||||
; user.class.php
|
||||
You are already logged in. = "Vous êtes déjà connecté."
|
||||
The nick or password is incorrect. = "Votre pseudo ou mot de passe est incorrect."
|
||||
You can't log out. There is no account. = "Vous ne pouvez pas vous déconnecter, les comptes sont désactivés."
|
||||
You are not even logged in. = "Vous n’êtes pas connecté."
|
||||
|
||||
; post.class.php
|
||||
You need to be logged in to perform this action. = "Vous devez être connecté pour pouvoir faire ça."
|
||||
No data. = "Aucune données."
|
67
app/lang/nl.ini
Normal file
|
@ -0,0 +1,67 @@
|
|||
; index.html
|
||||
Show More = "Verder Lezen"
|
||||
|
||||
Login = "Aanmelden"
|
||||
Logout = "Afmelden"
|
||||
|
||||
Nick = "Gebruiker"
|
||||
Password = "Wachtwoord"
|
||||
Cancel = "Annuleren"
|
||||
|
||||
Post = "Bericht"
|
||||
|
||||
Edit Post = "Wijzig Bericht"
|
||||
Change Date = "Wijzig Datum"
|
||||
Hide from Timeline = "Verbergen van Tijdlijn"
|
||||
Show on Timeline = "Laten zien op Tijdlijn"
|
||||
Delete Post = "Verwijder Bericht"
|
||||
|
||||
Drag photos here = "Sleep foto's hier"
|
||||
Drop photos here = "Gooi foto's hier"
|
||||
What's on your mind? = "Waar ben je mee bezig?"
|
||||
Feeling = "Gevoel"
|
||||
How are you feeling? = "Hoe voel je je?"
|
||||
With = "Met"
|
||||
Who are you with? = "Met wie ben je?"
|
||||
At = "Bij"
|
||||
Where are you? = "Waar ben je?"
|
||||
Save = "Opslaan"
|
||||
|
||||
January = "Januari"
|
||||
February = "Februari"
|
||||
March = "Maart"
|
||||
April = "April"
|
||||
May = "Mei"
|
||||
June = "Juni"
|
||||
July = "Juli"
|
||||
August = "Augustus"
|
||||
September = "September"
|
||||
October = "Oktober"
|
||||
November = "November"
|
||||
December = "December"
|
||||
|
||||
Time: = "Tijd:"
|
||||
Hour: = "Uur:"
|
||||
Minute: = "Minuten:"
|
||||
|
||||
This post will be deleted and you'll no longer be able to find it. You can also edit this post if you just want to change something. = "Dit bericht word verwijderd en kan niet meer worden gevonden. Je kan ook het bericht wijzigen als je dat liever wilt."
|
||||
|
||||
with = "met"
|
||||
here: = "Bij:"
|
||||
|
||||
Public = "Openbaar"
|
||||
Friends = "Vrienden"
|
||||
Only me = "Alleen ik"
|
||||
|
||||
Show hidden content = "Laat verborgen berichten zien"
|
||||
Show all posts = "Alle berichten zien"
|
||||
|
||||
; user.class.php
|
||||
You are already logged in. = "Je bent al ingelogt."
|
||||
The nick or password is incorrect. = "De gebruiken of het Wachtwoord is onjuist."
|
||||
You can't log out. There is no account. = "Je kan niet Afmelden. Er is geen Account."
|
||||
You are not even logged in. = "Je ben niet eens ingelogt."
|
||||
|
||||
; post.class.php
|
||||
You need to be logged in to perform this action. = "Je moet ingelogged zijn om deze actie uit te voeren."
|
||||
No data. = "Geen data."
|
67
app/lang/ru.ini
Normal file
|
@ -0,0 +1,67 @@
|
|||
; index.html
|
||||
Show More = "Показать больше"
|
||||
|
||||
Login = "Войти"
|
||||
Logout = "Выйти"
|
||||
|
||||
Nick = "Логин"
|
||||
Password = "Пароль"
|
||||
Cancel = "Отмена"
|
||||
|
||||
Post = "Пост"
|
||||
|
||||
Edit Post = "Редактировать пост"
|
||||
Change Date = "Изменить дату"
|
||||
Hide from Timeline = "Скрыть из ленты"
|
||||
Show on Timeline = "Показать в ленте"
|
||||
Delete Post = "Удалить пост"
|
||||
|
||||
Drag photos here = "Перетащите сюда фото"
|
||||
Drop photos here = "Оставь фото здесь"
|
||||
What's on your mind? = "О чем ты думаешь?"
|
||||
Feeling = "Ощущения"
|
||||
How are you feeling? = "Как ты себя чувствуешь?"
|
||||
With = "В компании"
|
||||
Who are you with? = "С кем ты?"
|
||||
At = "Локация"
|
||||
Where are you? = "Где ты?"
|
||||
Save = "Сохранить"
|
||||
|
||||
January = "Январь"
|
||||
February = "Февраль"
|
||||
March = "Март"
|
||||
April = "Апрель"
|
||||
May = "Май"
|
||||
June = "Июнь"
|
||||
July = "Июль"
|
||||
August = "Август"
|
||||
September = "Сентябрь"
|
||||
October = "Октябрь"
|
||||
November = "Ноябрь"
|
||||
December = "Декабрь"
|
||||
|
||||
Time: = "Время:"
|
||||
Hour: = "Чаc:"
|
||||
Minute: = "Минута:"
|
||||
|
||||
This post will be deleted and you'll no longer be able to find it. You can also edit this post if you just want to change something. = "Этот пост будет удален, и вы больше не сможете его найти. Вы также можете отредактировать этот пост, если просто хотите что-то изменить"
|
||||
|
||||
with = "с"
|
||||
here: = "здесь:"
|
||||
|
||||
Public = "Публичный"
|
||||
Friends = "Друзья"
|
||||
Only me = "Только я"
|
||||
|
||||
Show hidden content = "Показать скрытый контент"
|
||||
Show all posts = "Показать все посты"
|
||||
|
||||
; user.class.php
|
||||
You are already logged in. = "Вы уже залогинены."
|
||||
The nick or password is incorrect. = "Логин или пароль неверный."
|
||||
You can't log out. There is no account. = "Вы не можете выйти. Вы не залогинены."
|
||||
You are not even logged in. = "Вы не авторизовались."
|
||||
|
||||
; post.class.php
|
||||
You need to be logged in to perform this action. = "Вы должны быть залогинены, чтобы выполнить это действие."
|
||||
No data. = "Нет данных."
|
67
app/lang/sk.ini
Normal file
|
@ -0,0 +1,67 @@
|
|||
; index.html
|
||||
Show More = "Zobraziť viac"
|
||||
|
||||
Login = "Prihlásiť sa"
|
||||
Logout = "Odhlásiť sa"
|
||||
|
||||
Nick = "Prihlasovacie meno"
|
||||
Password = "Heslo"
|
||||
Cancel = "Zrušiť"
|
||||
|
||||
Post = "Nový príspevok"
|
||||
|
||||
Edit Post = "Upraviť príspevok"
|
||||
Change Date = "Zmeniť dátum"
|
||||
Hide from Timeline = "Skryť na časovej osi"
|
||||
Show on Timeline = "Zobraziť na časovej osi"
|
||||
Delete Post = "Odstrániť príspevok"
|
||||
|
||||
Drag photos here = "Sem presuňte fotografie"
|
||||
Drop photos here = "Tu vložte fotografie"
|
||||
What's on your mind? = "Na čo myslíš?"
|
||||
Feeling = "Pocit"
|
||||
How are you feeling? = "Ako sa cítiš?"
|
||||
With = "Spolu s"
|
||||
Who are you with? = "S kým si?"
|
||||
At = "Miesto"
|
||||
Where are you? = "Kde si?"
|
||||
Save = "Uložiť"
|
||||
|
||||
January = "Január"
|
||||
February = "Február"
|
||||
March = "Marec"
|
||||
April = "Apríl"
|
||||
May = "Máj"
|
||||
June = "Jún"
|
||||
July = "Júl"
|
||||
August = "August"
|
||||
September = "September"
|
||||
October = "Október"
|
||||
November = "November"
|
||||
December = "December"
|
||||
|
||||
Time: = "Čas:"
|
||||
Hour: = "Hodina:"
|
||||
Minute: = "Minúta:"
|
||||
|
||||
This post will be deleted and you'll no longer be able to find it. You can also edit this post if you just want to change something. = "Tento príspevok bude odstránený a už ho nebudete môcť nájsť. Tento príspevok môžete tiež upraviť, ak chcete niečo zmeniť."
|
||||
|
||||
with = "s"
|
||||
here: = "tu:"
|
||||
|
||||
Public = "Verejné"
|
||||
Friends = "Priatelia"
|
||||
Only me = "Iba ja"
|
||||
|
||||
Show hidden content = "Zobraziť skrytý obsah"
|
||||
Show all posts = "Zobraziť všetky príspevky"
|
||||
|
||||
; user.class.php
|
||||
You are already logged in. = "Už si prihlásený."
|
||||
The nick or password is incorrect. = "Prihlasovacie meno alebo heslo je nesprávne."
|
||||
You can't log out. There is no account. = "Nemôžeš sa odhlásiť. Neexistuje žiadny účet."
|
||||
You are not even logged in. = "Nie si ani prihlásený."
|
||||
|
||||
; post.class.php
|
||||
You need to be logged in to perform this action. = "Na vykonanie tejto akcie musíš byť prihlásený."
|
||||
No data. = "Žiadne dáta."
|
10
app/log.class.php
Executable file → Normal file
|
@ -1,9 +1,8 @@
|
|||
<?php
|
||||
defined('PROJECT_PATH') OR exit('No direct script access allowed');
|
||||
|
||||
class Log
|
||||
{
|
||||
const PATH = 'data/logs/';
|
||||
|
||||
private static $_files = [
|
||||
"ajax_access",
|
||||
"ajax_errors",
|
||||
|
@ -16,7 +15,12 @@ class Log
|
|||
return ;
|
||||
}
|
||||
|
||||
if(false === file_put_contents(PROJECT_PATH.static::PATH.$_file.".log", self::line($_text), FILE_APPEND) && Config::get_safe('debug', false)){
|
||||
$_logs_path = Config::get('logs_path');
|
||||
if(!is_dir($_logs_path) && !mkdir($_logs_path, 755, true)){
|
||||
die("Logs directory could not be created.");
|
||||
}
|
||||
|
||||
if(false === file_put_contents($_logs_path.$_file.".log", self::line($_text), FILE_APPEND) && Config::get_safe('debug', false)){
|
||||
die(sprintf("Can't write to %s.log file.", $_file));
|
||||
}
|
||||
}
|
||||
|
|
193
app/post.class.php
Executable file → Normal file
|
@ -1,4 +1,5 @@
|
|||
<?php
|
||||
defined('PROJECT_PATH') OR exit('No direct script access allowed');
|
||||
|
||||
class Post
|
||||
{
|
||||
|
@ -9,8 +10,6 @@ class Post
|
|||
}
|
||||
|
||||
private static function parse_content($c){
|
||||
require_once APP_PATH."jbbcode/Parser.php";
|
||||
|
||||
$parser = new JBBCode\Parser();
|
||||
$parser->addCodeDefinitionSet(new JBBCode\DefaultCodeDefinitionSet());
|
||||
|
||||
|
@ -30,7 +29,8 @@ class Post
|
|||
|
||||
public function asHtml(\JBBCode\ElementNode $el){
|
||||
$content = $this->getContent($el);
|
||||
return '<code class="'.$el->getAttribute().'">'.htmlentities($content).'</code>';
|
||||
$class = $el->getAttribute()['code'];
|
||||
return '<code class="'.$class.'">'.htmlentities($content).'</code>';
|
||||
}
|
||||
});
|
||||
}
|
||||
|
@ -66,7 +66,7 @@ class Post
|
|||
$c = htmlentities($c);
|
||||
$c = preg_replace('/\*([^\*]+)\*/i', "<strong>$1</strong>", $c);
|
||||
$c = preg_replace('/(https?\:\/\/[^\" \n]+)/i', "<a href=\"\\0\" target=\"_blank\">\\0</a>", $c);
|
||||
$c = preg_replace('/(\#[A-Za-z0-9-_]+)/i', "<span class=\"tag\">\\0</span>", $c);
|
||||
$c = preg_replace('/(\#[A-Za-z0-9-_]+)(\s|$)/i', "<span class=\"tag\">\\1</span>\\2", $c);
|
||||
$c = nl2br($c);
|
||||
$textNode->setValue($c);
|
||||
}
|
||||
|
@ -146,7 +146,7 @@ class Post
|
|||
$data['plain_text'] = $data['text'];
|
||||
$data['text'] = self::parse_content($data['text']);
|
||||
|
||||
DB::get_instance()->update('posts', $data, "WHERE `id` = ? AND `status` = 1", $r["id"]);
|
||||
DB::get_instance()->update('posts', $data, "WHERE `id` = ? AND `status` <> 5", $r["id"]);
|
||||
|
||||
unset($data['plain_text']);
|
||||
|
||||
|
@ -156,27 +156,66 @@ class Post
|
|||
public static function hide($r){
|
||||
self::login_protected();
|
||||
|
||||
DB::get_instance()->query("UPDATE `posts` SET `status` = 4 WHERE `id` = ?", $r["id"]);
|
||||
DB::get_instance()->query("
|
||||
UPDATE `posts`
|
||||
SET `status` = 4
|
||||
WHERE `id` = ?
|
||||
AND `status` <> 5
|
||||
", $r["id"]);
|
||||
return true;
|
||||
}
|
||||
|
||||
public static function show($r){
|
||||
self::login_protected();
|
||||
|
||||
DB::get_instance()->query("
|
||||
UPDATE `posts`
|
||||
SET `status` = 1
|
||||
WHERE `id` = ?
|
||||
AND `status` <> 5
|
||||
", $r["id"]);
|
||||
return true;
|
||||
}
|
||||
|
||||
public static function delete($r){
|
||||
self::login_protected();
|
||||
|
||||
DB::get_instance()->query("UPDATE `posts` SET `status` = 5 WHERE `id` = ?", $r["id"]);
|
||||
DB::get_instance()->query("
|
||||
UPDATE `posts`
|
||||
SET `status` = 5
|
||||
WHERE `id` = ?
|
||||
", $r["id"]);
|
||||
return true;
|
||||
}
|
||||
|
||||
public static function edit_data($r){
|
||||
self::login_protected();
|
||||
|
||||
return DB::get_instance()->query("SELECT `plain_text`, `feeling`, `persons`, `location`, `privacy`, `content_type`, `content` FROM `posts` WHERE `id` = ? AND `status` = 1", $r["id"])->first();
|
||||
return DB::get_instance()->query("
|
||||
SELECT `plain_text`, `feeling`, `persons`, `location`, `privacy`, `content_type`, `content`
|
||||
FROM `posts`
|
||||
WHERE `id` = ?
|
||||
AND `status` <> 5
|
||||
", $r["id"])->first();
|
||||
}
|
||||
|
||||
public static function get_date($r){
|
||||
self::login_protected();
|
||||
|
||||
$date = DB::get_instance()->query("SELECT DATE_FORMAT(`datetime`,'%Y %c %e %k %i') AS `date_format` FROM `posts` WHERE `id` = ? AND `status` = 1", $r["id"])->first("date_format");
|
||||
if (DB::connection() === 'sqlite') {
|
||||
$datetime = "strftime('%Y %m %d %H %M', `posts`.`datetime`)";
|
||||
} else if (DB::connection() === 'postgres') {
|
||||
$datetime = "to_char(datetime,'YYYY MM DD HH24 MI')";
|
||||
} else {
|
||||
$datetime = "DATE_FORMAT(`datetime`,'%Y %c %e %k %i')";
|
||||
}
|
||||
|
||||
$date = DB::get_instance()->query("
|
||||
SELECT $datetime AS `date_format`
|
||||
FROM `posts`
|
||||
WHERE `id` = ?
|
||||
AND `status` <> 5
|
||||
", $r["id"])->first("date_format");
|
||||
$date = array_map("intval", explode(" ", $date));
|
||||
$date[4] = floor($date[4]/10)*10;
|
||||
return $date;
|
||||
|
@ -186,8 +225,18 @@ class Post
|
|||
self::login_protected();
|
||||
|
||||
$d = $r["date"];
|
||||
$datetime = "{$d[0]}/{$d[1]}/{$d[2]} {$d[3]}:{$d[4]}";
|
||||
DB::get_instance()->query("UPDATE `posts` SET `datetime` = ? WHERE `id` = ? AND `status` = 1", $datetime, $r["id"]);
|
||||
if (DB::connection() === 'sqlite') {
|
||||
$datetime = vsprintf("%04d-%02d-%02d %02d:%02d", $d);
|
||||
} else {
|
||||
$datetime = vsprintf("%04d/%02d/%02d %02d:%02d", $d);
|
||||
}
|
||||
|
||||
DB::get_instance()->query("
|
||||
UPDATE `posts`
|
||||
SET `datetime` = ?
|
||||
WHERE `id` = ?
|
||||
AND `status` <> 5
|
||||
", $datetime, $r["id"]);
|
||||
return [ "datetime" => date("d M Y H:i", strtotime($datetime)) ];
|
||||
}
|
||||
|
||||
|
@ -209,15 +258,53 @@ class Post
|
|||
}
|
||||
|
||||
preg_match('/^https?:\/\/(www\.)?([^:\/\s]+)(.*)?$/i', $l, $url);
|
||||
$curl_request_url = $l;
|
||||
|
||||
// Get content
|
||||
$ch = curl_init();
|
||||
curl_setopt($ch, CURLOPT_HEADER, 0);
|
||||
curl_setopt($ch, CURLOPT_ENCODING , "");
|
||||
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
|
||||
curl_setopt($ch, CURLOPT_URL, $l);
|
||||
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);
|
||||
curl_setopt($ch, CURLOPT_USERAGENT, "Mozilla/5.0 (compatible; Proxycat/1.1)");
|
||||
curl_setopt($ch, CURLOPT_REFERER, '');
|
||||
curl_setopt($ch, CURLOPT_TIMEOUT, 7); // 7sec
|
||||
|
||||
// Proxy settings
|
||||
if($proxy = Config::get_safe("proxy", false)){
|
||||
$proxytype = Config::get_safe("proxytype", false);
|
||||
$proxyauth = Config::get_safe("proxyauth", false);
|
||||
if($proxytype === 'URL_PREFIX'){
|
||||
$curl_request_url = $proxy.$curl_request_url;
|
||||
|
||||
if($proxyauth){
|
||||
curl_setopt($ch, CURLOPT_USERPWD, $proxyauth);
|
||||
}
|
||||
} else {
|
||||
curl_setopt($ch, CURLOPT_PROXY, $proxy);
|
||||
|
||||
if($proxyauth){
|
||||
curl_setopt($ch, CURLOPT_PROXYUSERPWD, $proxyauth);
|
||||
}
|
||||
|
||||
switch ($proxytype) {
|
||||
case 'CURLPROXY_SOCKS4':
|
||||
$proxytype = CURLPROXY_SOCKS4;
|
||||
break;
|
||||
case 'CURLPROXY_SOCKS5':
|
||||
$proxytype = CURLPROXY_SOCKS5;
|
||||
break;
|
||||
case 'CURLPROXY_HTTP':
|
||||
default:
|
||||
$proxytype = CURLPROXY_HTTP;
|
||||
break;
|
||||
}
|
||||
|
||||
curl_setopt($ch, CURLOPT_PROXYTYPE, $proxytype);
|
||||
}
|
||||
}
|
||||
|
||||
curl_setopt($ch, CURLOPT_URL, $curl_request_url);
|
||||
$html = curl_exec($ch);
|
||||
curl_close($ch);
|
||||
|
||||
|
@ -259,11 +346,26 @@ class Post
|
|||
}
|
||||
|
||||
if($p == 'og:type'){
|
||||
$content["is_video"] = ($c == "video");
|
||||
$content["is_video"] = (preg_match("/video/", $c));
|
||||
}
|
||||
|
||||
if($n == 'twitter:image:src' || $p == 'og:image'){
|
||||
$content["thumb"] = $c;
|
||||
// Absolute url
|
||||
if(preg_match("/^(https?:)?\/\//", $c)) {
|
||||
$content["thumb"] = $c;
|
||||
}
|
||||
|
||||
// Relative url from root
|
||||
elseif(preg_match("/^\//", $c)) {
|
||||
preg_match("/^((?:https?:)?\/\/([^\/]+))(\/|$)/", $l, $m);
|
||||
$content["thumb"] = $m[1].'/'.$c;
|
||||
}
|
||||
|
||||
// Relative url from current directory
|
||||
else {
|
||||
preg_match("/^((?:https?:)?\/\/[^\/]+.*?)(\/[^\/]*)?$/", $l, $m);
|
||||
$content["thumb"] = $m[1].'/'.$c;
|
||||
}
|
||||
}
|
||||
|
||||
if($n == 'twitter:domain'){
|
||||
|
@ -285,48 +387,71 @@ class Post
|
|||
}
|
||||
|
||||
public static function load($r){
|
||||
$until = [];
|
||||
if(preg_match("/^[0-9]{4}-[0-9]{2}$/", $r["filter"]["until"])){
|
||||
$until = $r["filter"]["until"]."-01 00:00";
|
||||
$from = [];
|
||||
if(preg_match("/^[0-9]{4}-[0-9]{2}$/", @$r["filter"]["from"])){
|
||||
$from = $r["filter"]["from"]."-01 00:00";
|
||||
}
|
||||
|
||||
if(preg_match("/^[0-9]{4}-[0-9]{2}-[0-9]{2}$/", $r["filter"]["until"])){
|
||||
$until = $r["filter"]["until"]." 23:59";
|
||||
if(preg_match("/^[0-9]{4}-[0-9]{2}-[0-9]{2}$/", @$r["filter"]["from"])){
|
||||
$from = $r["filter"]["from"]." 00:00";
|
||||
}
|
||||
|
||||
$to = [];
|
||||
if(preg_match("/^[0-9]{4}-[0-9]{2}$/", @$r["filter"]["to"])){
|
||||
$to = $r["filter"]["to"]."-01 00:00";
|
||||
}
|
||||
|
||||
if(preg_match("/^[0-9]{4}-[0-9]{2}-[0-9]{2}$/", @$r["filter"]["to"])){
|
||||
$to = $r["filter"]["to"]." 00:00";
|
||||
}
|
||||
|
||||
$id = [];
|
||||
if($r["filter"]["id"]){
|
||||
if(@$r["filter"]["id"]){
|
||||
$id = intval($r["filter"]["id"]);
|
||||
}
|
||||
|
||||
$tag = [];
|
||||
if(preg_match("/^[A-Za-z0-9-_]+$/", $r["filter"]["tag"])){
|
||||
if(preg_match("/^[A-Za-z0-9-_]+$/", @$r["filter"]["tag"])){
|
||||
$tag = '#'.$r["filter"]["tag"];
|
||||
}
|
||||
|
||||
$loc = [];
|
||||
if($r["filter"]["loc"]){
|
||||
if(@$r["filter"]["loc"]){
|
||||
$loc = $r["filter"]["loc"];
|
||||
}
|
||||
|
||||
$person = [];
|
||||
if($r["filter"]["person"]){
|
||||
if(@$r["filter"]["person"]){
|
||||
$person = $r["filter"]["person"];
|
||||
}
|
||||
|
||||
return DB::get_instance()->query(
|
||||
"SELECT `id`, `text`, `feeling`, `persons`, `location`, `privacy`, `content_type`, `content`, DATE_FORMAT(`posts`.`datetime`,'%d %b %Y %H:%i') AS `datetime` ".
|
||||
"FROM `posts` ".
|
||||
"WHERE ".
|
||||
if (DB::connection() === 'sqlite') {
|
||||
$datetime = "strftime('%d %m %Y %H:%M', `posts`.`datetime`)";
|
||||
} else if (DB::connection() === 'postgres') {
|
||||
$datetime = "to_char(posts.datetime,'DD Mon YYYY HH24:MI')";
|
||||
} else {
|
||||
$datetime = "DATE_FORMAT(`posts`.`datetime`,'%d %b %Y %H:%i')";
|
||||
}
|
||||
|
||||
$like_match = "LIKE ".DB::concat("'%'", "?", "'%'");
|
||||
|
||||
return DB::get_instance()->query("
|
||||
SELECT
|
||||
`id`, `text`, `feeling`, `persons`, `location`, `privacy`, `content_type`, `content`,
|
||||
$datetime AS `datetime`, (`status` <> 1) AS `is_hidden`
|
||||
FROM `posts`
|
||||
WHERE ".
|
||||
(!User::is_logged_in() ? (User::is_visitor() ? "`privacy` IN ('public', 'friends') AND " : "`privacy` = 'public' AND ") : "").
|
||||
($until ? "`posts`.`datetime` < DATE_ADD(?, INTERVAL +1 MONTH) AND " : "").
|
||||
($from ? "`posts`.`datetime` > ? AND " : "").
|
||||
($to ? "`posts`.`datetime` < ? AND " : "").
|
||||
($id ? "`id` = ? AND " : "").
|
||||
($tag ? "`plain_text` LIKE CONCAT('%', ?, '%') AND " : "").
|
||||
($loc ? "`location` LIKE CONCAT('%', ?, '%') AND " : "").
|
||||
($person ? "`persons` LIKE CONCAT('%', ?, '%') AND " : "").
|
||||
"`status` = 1 ".
|
||||
"ORDER BY `posts`.`datetime` DESC ".
|
||||
"LIMIT ? OFFSET ?", $until, $id, $tag, $loc, $person, $r["limit"], $r["offset"]
|
||||
($tag ? "`plain_text` $like_match AND " : "").
|
||||
($loc ? "`location` $like_match AND " : "").
|
||||
($person ? "`persons` $like_match AND " : "").
|
||||
"`status` <> 5
|
||||
ORDER BY `posts`.`datetime` ".(@$r["sort"] == 'reverse' ? "ASC" : "DESC")."
|
||||
LIMIT ? OFFSET ?
|
||||
", $from, $to, $id, $tag, $loc, $person, $r["limit"], $r["offset"]
|
||||
)->all();
|
||||
}
|
||||
|
||||
|
|
4
app/splclassloader.class.php
Executable file → Normal file
|
@ -1,4 +1,6 @@
|
|||
<?php
|
||||
defined('PROJECT_PATH') OR exit('No direct script access allowed');
|
||||
|
||||
/**
|
||||
* SplClassLoader implementation that implements the technical interoperability
|
||||
* standards for PHP 5.3 namespaces and class names.
|
||||
|
@ -134,7 +136,7 @@ class SplClassLoader
|
|||
$full = ($this->_includePath !== null ? $this->_includePath . DIRECTORY_SEPARATOR : '') . $fileName;
|
||||
|
||||
if (!file_exists($full)) {
|
||||
throw new Exception("Class file for '".$className."' not found");
|
||||
throw new Exception(sprintf('Class file for "%s" not found.', $className));
|
||||
}
|
||||
|
||||
require $full;
|
||||
|
|
7
app/user.class.php
Executable file → Normal file
|
@ -1,4 +1,5 @@
|
|||
<?php
|
||||
defined('PROJECT_PATH') OR exit('No direct script access allowed');
|
||||
|
||||
class user
|
||||
{
|
||||
|
@ -34,7 +35,11 @@ class user
|
|||
return ["logged_in" => true, "is_visitor" => false];
|
||||
}
|
||||
|
||||
$visitors = Config::get_safe("visitor", []);
|
||||
// Legacy: Visitors and Friends.
|
||||
$visitors = array_merge(
|
||||
Config::get_safe("friends", []),
|
||||
Config::get_safe("visitor", [])
|
||||
);
|
||||
if(!empty($visitors) && isset($visitors[$nick]) && $visitors[$nick] === $pass){
|
||||
$_SESSION[User::SESSION_NAME] = 'visitor';
|
||||
return ["logged_in" => false, "is_visitor" => true];
|
||||
|
|
15
common.php
Executable file → Normal file
|
@ -15,11 +15,24 @@ if(Config::get_safe('debug', false)){
|
|||
ini_set('display_errors', 1);
|
||||
ini_set('display_startup_errors', 1);
|
||||
error_reporting(E_ALL);
|
||||
|
||||
// Check extensions
|
||||
$required = ['curl', 'PDO', 'pdo_mysql', 'gd', 'exif'];
|
||||
$loaded = get_loaded_extensions();
|
||||
if($missing = array_diff($required, $loaded)){
|
||||
die("Missing extensions, please install: ".implode(", ", $missing));
|
||||
}
|
||||
}
|
||||
|
||||
// Language
|
||||
Lang::load(empty($_GET["hl"]) ? Config::get("lang") : $_GET["hl"]);
|
||||
|
||||
// Timezone
|
||||
if(false !== ($TZ = Config::get_safe('timezone', getenv('TZ')))) {
|
||||
date_default_timezone_set($TZ);
|
||||
ini_set('date.timezone', $TZ);
|
||||
}
|
||||
|
||||
// Start session
|
||||
ini_set('session.cookie_httponly', 1);
|
||||
session_start();
|
||||
session_start();
|
||||
|
|
54
config.ini
Executable file → Normal file
|
@ -1,9 +1,24 @@
|
|||
[database]
|
||||
;mysql_socket = /tmp/mariadb55.sock
|
||||
db_connection = sqlite
|
||||
;sqlite_db = data/sqlite.db
|
||||
|
||||
;[database]
|
||||
;db_connection = mysql
|
||||
;mysql_socket = /tmp/mysql.sock
|
||||
;mysql_host = localhost
|
||||
;mysql_port = 3306
|
||||
;mysql_user = root
|
||||
;mysql_pass =
|
||||
;db_name = root
|
||||
;mysql_pass = root
|
||||
;db_name = blog
|
||||
|
||||
;[database]
|
||||
;db_connection = postgres
|
||||
;postgres_socket = /tmp/postgres.sock
|
||||
;postgres_host = localhost
|
||||
;postgres_port = 5432
|
||||
;postgres_user = root
|
||||
;postgres_pass = root
|
||||
;db_name = blog
|
||||
|
||||
[profile]
|
||||
title = Blog
|
||||
|
@ -19,10 +34,12 @@ lang = en
|
|||
highlight = true
|
||||
|
||||
[custom]
|
||||
theme = theme02
|
||||
;header = data/header.html
|
||||
;styles[] = static/styles/custom1.css
|
||||
;styles[] = static/styles/custom2.css
|
||||
;scripts = static/styles/scripts.css
|
||||
;footer = "Edit this if you really want to remove my backlink :("
|
||||
|
||||
[bbcode]
|
||||
;bbtags[quote] = "<quote>{param}</quote>"
|
||||
|
@ -32,12 +49,29 @@ force_login = true
|
|||
nick = demo
|
||||
pass = demo
|
||||
|
||||
[visitors]
|
||||
;visitor[user] = pass
|
||||
;visitor[user] = pass
|
||||
[friends]
|
||||
;friends[user] = pass
|
||||
;friends[user] = pass
|
||||
|
||||
[directories]
|
||||
images_path = data/i/
|
||||
thumbnails_path = data/t/
|
||||
logs_path = data/logs/
|
||||
|
||||
[proxy]
|
||||
;proxy = hostname:port
|
||||
;proxyauth = username:password
|
||||
;proxytype = CURLPROXY_HTTP ; default, if not set
|
||||
;proxytype = CURLPROXY_SOCKS4
|
||||
;proxytype = CURLPROXY_SOCKS5
|
||||
|
||||
;URL_PREFIX type:
|
||||
;proxy = http://your.page.com/proxy.cgi?
|
||||
;proxyauth = username:password
|
||||
;proxytype = URL_PREFIX
|
||||
|
||||
[system]
|
||||
system_name = blog
|
||||
version = 1.18
|
||||
debug = true
|
||||
logs = false
|
||||
;timezone = Europe/Vienna
|
||||
version = 1.42
|
||||
debug = false
|
||||
logs = false
|
||||
|
|
|
@ -1,2 +0,0 @@
|
|||
Order Allow,Deny
|
||||
Deny from All
|
|
@ -1 +0,0 @@
|
|||
deny from all
|
17
docker-compose.yml
Normal file
|
@ -0,0 +1,17 @@
|
|||
version: "3"
|
||||
|
||||
services:
|
||||
blog:
|
||||
image: m1k1o/blog:latest
|
||||
restart: unless-stopped
|
||||
environment:
|
||||
TZ: Europe/Vienna
|
||||
BLOG_TITLE: Blog
|
||||
BLOG_NAME: Max Musermann
|
||||
BLOG_NICK: username
|
||||
BLOG_PASS: password
|
||||
BLOG_LANG: en
|
||||
ports:
|
||||
- 80:80
|
||||
volumes:
|
||||
- ./data:/var/www/html/data
|
70
index.php
Executable file → Normal file
|
@ -10,12 +10,16 @@ if(empty($_SESSION['token'])){
|
|||
}
|
||||
}
|
||||
|
||||
function escape($str) {
|
||||
return htmlspecialchars($str, ENT_QUOTES, 'UTF-8');
|
||||
}
|
||||
|
||||
//$.ajaxSetup({headers:{'Csrf-Token':'token'}});
|
||||
|
||||
Log::put("visitors");
|
||||
|
||||
$hours = '';
|
||||
for($h=0;$h<=24;$h++){
|
||||
for($h=0;$h<24;$h++){
|
||||
$hours .= sprintf('<option value="%d">%02d</option>', $h, $h);
|
||||
}
|
||||
|
||||
|
@ -40,6 +44,7 @@ if(!empty($styles)){
|
|||
}
|
||||
|
||||
$styles = array_unique($styles);
|
||||
$styles = array_map('escape', $styles);
|
||||
$styles_html = '<link href="'.implode('" rel="stylesheet" type="text/css"/>'.PHP_EOL.'<link href="', $styles).'" rel="stylesheet" type="text/css"/>'.PHP_EOL;
|
||||
}
|
||||
|
||||
|
@ -47,32 +52,39 @@ if(!empty($styles)){
|
|||
$scripts = Config::get_safe("scripts", []);
|
||||
$scripts_html = '';
|
||||
if(!empty($scripts)){
|
||||
if(!is_array($styles)){
|
||||
$styles = [$styles];
|
||||
if(!is_array($scripts)){
|
||||
$scripts = [$scripts];
|
||||
}
|
||||
|
||||
$scripts = array_unique($scripts);
|
||||
$scripts = array_map('escape', $scripts);
|
||||
$scripts_html = '<script src="'.implode('" type="text/javascript"></script>'.PHP_EOL.'<script src="', $scripts).'" type="text/javascript"></script>'.PHP_EOL;
|
||||
}
|
||||
|
||||
// Use version suffix in URLs to prevent cache
|
||||
$versionSuffix = '';
|
||||
if (Config::get_safe("version", false)) {
|
||||
$versionSuffix = '?v='.rawurlencode(Config::get("version"));
|
||||
}
|
||||
|
||||
?><!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<title><?php echo Config::get("title"); ?></title>
|
||||
<title><?php echo escape(Config::get("title")); ?></title>
|
||||
|
||||
<meta name="robots" content="noindex, nofollow">
|
||||
|
||||
<meta content="width=device-width, initial-scale=1.0" name="viewport" />
|
||||
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1" />
|
||||
|
||||
<link href="static/styles/main.css?v=<?php echo Config::get("version"); ?>" rel="stylesheet" type="text/css" />
|
||||
<link href="static/styles/design.css?v=<?php echo Config::get("version"); ?>" rel="stylesheet" type="text/css" />
|
||||
<link href="static/styles/main.css<?php echo $versionSuffix?>" rel="stylesheet" type="text/css" />
|
||||
<link href="static/styles/<?php echo rawurlencode(Config::get_safe("theme", "theme01")); ?>.css<?php echo $versionSuffix?>" rel="stylesheet" type="text/css" />
|
||||
|
||||
<link href="https://fonts.googleapis.com/css?family=Open+Sans&subset=all" rel="stylesheet">
|
||||
|
||||
<link href="static/styles/lightbox.css" rel="stylesheet" type="text/css" />
|
||||
<?php echo Config::get("highlight") ? '<link href="static/styles/highlight.css" rel="stylesheet" type="text/css" />' : ''; ?>
|
||||
<?php echo Config::get_safe("highlight", false) ? '<link href="static/styles/highlight-monokai-sublime.css" rel="stylesheet" type="text/css" />'.PHP_EOL : ''; ?>
|
||||
|
||||
<?php echo $styles_html; ?>
|
||||
</head>
|
||||
|
@ -103,7 +115,6 @@ if(!empty($scripts)){
|
|||
</div>
|
||||
<div class="modal-footer">
|
||||
<div class="buttons">
|
||||
<!--<div class="left"><a>Register</a> - <a>Forgot Password</a></div>-->
|
||||
<a class="button gray close"><?php echo __("Cancel"); ?></a>
|
||||
<button type="button" class="button blue do_login"><?php echo __("Login"); ?></button>
|
||||
</div>
|
||||
|
@ -119,7 +130,7 @@ if(!empty($scripts)){
|
|||
<img class="thumb_imglink">
|
||||
<div class="play"></div>
|
||||
</div>
|
||||
<div class="info right">
|
||||
<div class="info has_thumb">
|
||||
<div class="title"></div>
|
||||
<div class="desc"></div>
|
||||
<div class="host"></div>
|
||||
|
@ -151,7 +162,10 @@ if(!empty($scripts)){
|
|||
<ul class="b_dropdown post_tools">
|
||||
<li><a class="edit_post"><?php echo __("Edit Post"); ?></a></li>
|
||||
<li><a class="edit_date"><?php echo __("Change Date"); ?></a></li>
|
||||
<li><a class="hide"><?php echo __("Hide from Timeline"); ?></a></li>
|
||||
<li>
|
||||
<a class="hide"><?php echo __("Hide from Timeline"); ?></a>
|
||||
<a class="show"><?php echo __("Show on Timeline"); ?></a>
|
||||
</li>
|
||||
<li><a class="delete_post"><?php echo __("Delete Post"); ?></a></li>
|
||||
</ul>
|
||||
|
||||
|
@ -167,13 +181,18 @@ if(!empty($scripts)){
|
|||
<div class="modal-body drop_space">
|
||||
<div class="e_drag"><span><?php echo __("Drag photos here"); ?></span></div>
|
||||
<div class="e_drop"><span><?php echo __("Drop photos here"); ?></span></div>
|
||||
<img src="<?php echo Config::get("pic_small"); ?>" width="40" height="40" class="e_profile">
|
||||
<img src="<?php echo escape(Config::get("pic_small")); ?>" width="40" height="40" class="e_profile">
|
||||
<!--<div class="e_text" contenteditable="true"></div>-->
|
||||
<div class="t_area">
|
||||
<textarea class="e_text" placeholder="<?php echo __("What's on your mind?"); ?>"></textarea>
|
||||
</div>
|
||||
</div>
|
||||
<div class="e_loading"><img src="static/images/loading.gif" /></div>
|
||||
<div class="e_loading">
|
||||
<span class="e_dots"></span>
|
||||
<span class="e_dots"></span>
|
||||
<span class="e_dots"></span>
|
||||
<div class="e_meter"><span></span></div>
|
||||
</div>
|
||||
<input type="hidden" class="i_content_type">
|
||||
<input type="hidden" class="i_content">
|
||||
<div class="modal-body content"></div>
|
||||
|
@ -270,11 +289,14 @@ if(!empty($scripts)){
|
|||
|
||||
<!-- Post Row -->
|
||||
<div class="b_post post_row">
|
||||
<div class="b_overlay">
|
||||
<a class="button"><?php echo __("Show hidden content"); ?></a>
|
||||
</div>
|
||||
<div class="b_header">
|
||||
<img src="<?php echo Config::get("pic_small"); ?>" width="40" height="40" class="b_profile">
|
||||
<img src="<?php echo escape(Config::get("pic_small")); ?>" width="40" height="40" class="b_profile">
|
||||
<div class="b_desc">
|
||||
<div class="b_sharer">
|
||||
<span class="b_name"><?php echo Config::get("name"); ?></span><span class="b_options"> - </span><span class="b_feeling"></span><span class="b_with"> <?php echo __("with"); ?> </span><span class="b_persons"></span><span class="b_here"> <?php echo __("here:"); ?> </span><span class="b_location"></span>
|
||||
<span class="b_name"><?php echo escape(Config::get("name")); ?></span><span class="b_options"> - </span><span class="b_feeling"></span><span class="b_with"> <?php echo __("with"); ?> </span><span class="b_persons"></span><span class="b_here"> <?php echo __("here:"); ?> </span><span class="b_location"></span>
|
||||
</div>
|
||||
<i class="privacy_icon"></i>
|
||||
<a class="b_date"></a>
|
||||
|
@ -294,18 +316,18 @@ if(!empty($scripts)){
|
|||
</div>
|
||||
|
||||
<div class="bluebar">
|
||||
<h1><?php echo Config::get("title"); ?></h1>
|
||||
<h1><?php echo escape(Config::get("title")); ?></h1>
|
||||
</div>
|
||||
|
||||
<div class="headbar">
|
||||
<div class="cover">
|
||||
<?php echo $header; ?>
|
||||
<div class="overlay"></div>
|
||||
<?php echo (Config::get_safe("cover", false) ? '<img src="'.Config::get("cover").'">' : (empty($header) ? '<div style="padding-bottom: 37%;"></div>' : '')); ?>
|
||||
<?php echo (Config::get_safe("cover", false) ? '<img src="'.escape(Config::get("cover")).'">' : (empty($header) ? '<div style="padding-bottom: 37%;"></div>' : '')); ?>
|
||||
<div class="profile">
|
||||
<img src="<?php echo Config::get("pic_big"); ?>">
|
||||
<img src="<?php echo escape(Config::get("pic_big")); ?>">
|
||||
</div>
|
||||
<div class="name"><?php echo Config::get("name"); ?></div>
|
||||
<div class="name"><?php echo escape(Config::get("name")); ?></div>
|
||||
</div>
|
||||
<div id="headline"></div>
|
||||
</div>
|
||||
|
@ -319,17 +341,19 @@ if(!empty($scripts)){
|
|||
|
||||
<div id="eof_feed">
|
||||
<img src="static/images/zpEYXu5Wdu6.png">
|
||||
<p><?php echo Config::get("version"); ?> © 2016-2019 <br>Miroslav Šedivý</p>
|
||||
<p><?php echo escape(Config::get("version")); ?> © 2016-2022<br>
|
||||
<?php echo Config::get_safe("footer", false) ? escape(Config::get_safe("footer")) : '<a href="https://github.com/m1k1o/blog" class="link" title="m1k1o/blog github repository" target="_blank">m1k1o/blog</a>'; ?>
|
||||
</p>
|
||||
</div>
|
||||
<script src="static/scripts/jquery.min.js"></script>
|
||||
<script>$["\x61\x6A\x61\x78\x53\x65\x74\x75\x70"]({"\x68\x65\x61\x64\x65\x72\x73":{"\x43\x73\x72\x66-\x54\x6F\x6B\x65\x6E":"<?php echo $_SESSION['token'];?>"}});</script>
|
||||
|
||||
<script src="static/scripts/lightbox.js"></script>
|
||||
<script src="static/scripts/datepick.js?v=<?php echo Config::get("version"); ?>"></script>
|
||||
<script src="static/scripts/datepick.js<?php echo $versionSuffix?>"></script>
|
||||
<script src="static/scripts/autosize.js"></script>
|
||||
<?php echo Config::get("highlight") ? '<script src="static/scripts/highlight.js"></script><script>hljs.initHighlightingOnLoad();</script>' : ''; ?>
|
||||
<script src="static/scripts/app.js?v=<?php echo Config::get("version"); ?>"></script>
|
||||
<?php echo Config::get_safe("highlight", false) ? '<script src="static/scripts/highlight-10.1.2.min.js"></script><script>hljs.initHighlightingOnLoad();</script>'.PHP_EOL : ''; ?>
|
||||
<script src="static/scripts/app.js<?php echo $versionSuffix?>"></script>
|
||||
|
||||
<?php echo $scripts_html; ?>
|
||||
</body>
|
||||
</html>
|
||||
</html>
|
||||
|
|
0
static/images/star.png
Executable file → Normal file
Before Width: | Height: | Size: 470 B After Width: | Height: | Size: 470 B |
Before Width: | Height: | Size: 6.5 KiB After Width: | Height: | Size: 6.5 KiB |
Before Width: | Height: | Size: 238 B After Width: | Height: | Size: 238 B |
Before Width: | Height: | Size: 234 B After Width: | Height: | Size: 234 B |
Before Width: | Height: | Size: 238 B After Width: | Height: | Size: 238 B |
Before Width: | Height: | Size: 201 B After Width: | Height: | Size: 201 B |
Before Width: | Height: | Size: 234 B After Width: | Height: | Size: 234 B |
Before Width: | Height: | Size: 9.9 KiB After Width: | Height: | Size: 9.9 KiB |
Before Width: | Height: | Size: 4.8 KiB After Width: | Height: | Size: 4.8 KiB |
Before Width: | Height: | Size: 201 B After Width: | Height: | Size: 201 B |
Before Width: | Height: | Size: 17 KiB After Width: | Height: | Size: 17 KiB |
BIN
static/images/theme02/2CGkY1_Ax_-.png
Normal file
After Width: | Height: | Size: 593 B |
BIN
static/images/theme02/38mmIT7r0jG.png
Normal file
After Width: | Height: | Size: 835 B |
BIN
static/images/theme02/7_Yye-V3r9M.png
Normal file
After Width: | Height: | Size: 605 B |
BIN
static/images/theme02/7wYk0RRj5-g.png
Normal file
After Width: | Height: | Size: 511 B |
BIN
static/images/theme02/BOCzaD2rwOa.png
Normal file
After Width: | Height: | Size: 292 B |
BIN
static/images/theme02/BvwOjzIAV9T.png
Normal file
After Width: | Height: | Size: 1.6 KiB |
BIN
static/images/theme02/HxCo9uaZIcB.png
Normal file
After Width: | Height: | Size: 330 B |
BIN
static/images/theme02/IBOXrWGhcIu.png
Normal file
After Width: | Height: | Size: 334 B |
BIN
static/images/theme02/LiJKvoYFmUK.png
Normal file
After Width: | Height: | Size: 513 B |
BIN
static/images/theme02/THYN1-y3aPS.png
Normal file
After Width: | Height: | Size: 1.1 KiB |
BIN
static/images/theme02/W5IvJHzSLg7.png
Normal file
After Width: | Height: | Size: 927 B |
BIN
static/images/theme02/Xe-tUjaQ4vo.png
Normal file
After Width: | Height: | Size: 1 KiB |
BIN
static/images/theme02/YFO-fzIJZ2K.png
Normal file
After Width: | Height: | Size: 628 B |
BIN
static/images/theme02/amepTQ7nV0z.png
Normal file
After Width: | Height: | Size: 418 B |
BIN
static/images/theme02/gc6VwTsu2qZ.png
Normal file
After Width: | Height: | Size: 686 B |