105 Commits

Author SHA1 Message Date
Eike Rathke
7ce5408609 With MySQL use cast(okey as unsigned) instead of cast(okey as integer)
The autologin ("Save information") functionality in 2.3.1 is broken since

    commit 52a41b37d554da11acc932eeec44c5fb1414a492
    CommitDate: Fri Mar 23 18:01:32 2018 +0100

	Rework autologin to use a token approach

Although a cookie serendipity[author_autologintoken] with correct
expiration (one month) which random data content is present as value
in the serendipity_options table with name autologin_Username and
correct timestamp as okey and that is found with manually executing
the SQL statement

  SELECT name, value, okey FROM serendipity_options WHERE name = 'autologin_Username' AND okey > 1565801743 LIMIT 1

like done in include/functions_config.inc.php
serendipity_checkAutologin(), the login is forgotten after 30 minutes
or so. That was not the case with 2.1.5 where the login was valid for
weeks.

Of

    if (stristr($serendipity['dbType'], 'sqlite')) {
        $cast = "okey";
    } else {
        // Adds explicits casting for mysql, postgresql and others.
        $cast = "cast(okey as integer)";
    }

from which $cast then is used in the SQL statement instead of a plain
okey; when doing that manually with

  SELECT name, value, okey FROM serendipity_options WHERE name = 'autologin_Username' AND cast(okey as integer) > 1565801743 LIMIT 1

it produces the MySQL error

  #1064 - You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'integer) > 1565801743 LIMIT 1' at line 1

This also with $serendipity['dbType'] = 'mysqli' for the above code.

Indeed, cast(okey as integer) is invalid in MySQL and should be
cast(okey as unsigned) instead which then also works manually, see
https://stackoverflow.com/a/12127022 and
https://dev.mysql.com/doc/refman/5.7/en/cast-functions.html#function_cast

Same in serendipity_issueAutologin().

Changing those two places accordingly resolves the autologin not
persistent problem.

Additionally, inspecting the serendipity_options table revealed loads
of old serendipity[author_authorinformation] cookie information that
was never deleted in serendipity_issueAutologin() with the

  OR (okey LIKE 'l_%' AND $cast < " . (time() - 1814400) . ")")

expression producing a MySQL error. This has to be done manually
once as also 2.3.1 will not delete it anymore.

Backported from master branch.

Signed-off-by: Thomas Hochstein <thh@inter.net>
2019-10-13 18:06:50 +02:00
Jari Turkia
260efcc5a6 Make sure there is a $serendipity['lang'] defined by serendipity_getSessionLanguage() 2019-03-10 11:31:25 +01:00
onli
f948279583 Fix autologin token, form tokens failed cause session was not set 2019-02-20 23:06:13 +01:00
onli
c737565c13 Improve autologin token security by setting httpOnly and secure flag 2019-02-20 22:24:05 +01:00
onli
c7c133ef1d Set the bcrypt hashtype as the default for user creation 2018-06-12 22:43:19 +02:00
onli
eafc4dd625 Move from SHA1 to bcrypt
SHA1 is not an ideal password hash, even when salted, because it is cheap to compute. Since version 5.5 PHP offers bcrypt built in, which is a more expensive and secure hash function specifically suited for passwords
2018-03-23 18:02:02 +01:00
onli
52a41b37d5 Rework autologin to use a token approach
The prior code stored encrypted user data in the cookie that was then checked. This new approach is cleaner, as it only stores a token, and it does not use problematic crypto functions deprecated in PHP 7.2
2018-03-23 18:01:32 +01:00
onli
19b023529d Merge pull request #448 from gnuheidix/admin_username
HTTP500: crashing when username is an array
2017-04-11 15:02:50 +02:00
klemens
5a95db314a spelling fixes 2017-04-06 22:26:07 +02:00
Thomas Heidrich
3a7e04c69c improved check quality
!empty verifies that $username has been set with a significant value of any kind; is_string makes sure the type is really what is being expected in the following code.
2017-02-09 23:39:06 +01:00
Thomas Heidrich
e28bbf04d2 avoid HTTP500 crashing when username is an array 2017-02-08 20:19:43 +01:00
Matthias Mees
7410465496 Improve accessibility of iconfont icons
Iconfont icons are of no value to screenreader users; in our case,
they get alternative text. By adding 'aria-hidden="true"' to the
<span> holding the iconfont icon, we avoid the screenreader trying
to announce the iconfont icon.
2016-10-26 11:29:25 +02:00
onli
6419df26e0 Improve getTemplateFile performance by avoiding double lookups 2016-07-24 20:22:14 +02:00
onli
8affa1126a Massively simplify fallback chain logic
Should've been tested in the alpha, but given the problems with the preview logic (see http://board.s9y.org/viewtopic.php?f=3&t=20791) I'm convinced we need this now. This mainly reworks serendipity_getTemplateFile to follow a simple scheme on where to look for templates – either in the backend or frontend, based on where we are but overridable, then in the engine, then in the defaultTemplate as fallback.
2016-07-24 20:13:36 +02:00
onli
73ea0c4b1e Restore session id change on logout (#399) 2016-04-27 18:12:48 +00:00
onli
a8ac90c466 Init php 7 compatibility (#399)
A first approach at fixing s9y for php 7, which makes it possible to
write an entry without any error message. The specific changes are: 1.
__construct for the plugin classes 2. Update Cache Lite to a modern
version to fix its similar constructor problem 3. Remove the
session_regenerate_id call from the session destructor (should get
re-added to session creation where necessary) 4. Remove error handler to
prevent silenced warnings from becoming fatal exceptions
2016-04-26 22:39:11 +00:00
Ian
d93674485d cleaups 2016-03-19 17:18:11 +01:00
Ian
d7b1e7d23d minor whitespace and code cleanup
and a small github docnote fix
and added a todo for transforming a filename into a valid  upload path
2015-09-30 11:22:37 +02:00
Ian
d5eae21a9c suggested fix for the Serendipity fallback chaining
This fixes the plugin tpl fallback for all plugins, already using the parseTemplate() method. All others, which may still follow the themes fallback (like contactform etc), would need to always be part of the user template $serendipity['template'], or be fixed later on.

This also fixes the backend chaining, which now simply follows the force with a possible engine and then uses $serendipity['template_backend'] (2k11), $serendipity['defaultTemplate'] (2k11), 'default'.

As a third, this now uses the correct preview_iframe.tpl file on save and checks for a correct set jquery_backend.js in the user theme $serendipity['template'].

Please double check this approach for cases I did not find yet. Thanks! :)


References #343
2015-08-16 18:05:59 +02:00
Ian
8b8dcfd968 minors 2015-08-15 16:44:45 +02:00
Garvin Hicking
e7d822be11 Things I noticed for s9y.github.io 2015-03-19 16:17:30 +01:00
Garvin Hicking
98cd0e0541 fix 2015-03-16 14:07:24 +01:00
Garvin Hicking
5f59a811e8 Allow to set custom cookie validity.
Will be needed for blog.s9y.org templatechooser, which is why I need it in 2.0.1
2015-03-16 13:58:52 +01:00
Garvin Hicking
88a4776891 Fix not initializing smarty framework in the preview iframe, which lead to templates
config.inc.php files not being loaded (to hook into a config.inc.php)
2015-03-13 15:37:10 +01:00
Ian
aca77bd482 cleanup cosmetics 2014-12-10 14:34:54 +01:00
Garvin Hicking
4d17c0ae02 Added SQLite3 OO layer, old one did not work for PHP 5.4+
PDO SQlite3 is preferrable though
2014-11-24 11:48:16 +01:00
Garvin Hicking
26535ec09c Patch remaining usages of html_entity_decode
Document
2014-11-24 09:57:47 +01:00
onli
92afc37753 Introduce serendipity_specialchars-wrapper for encoding bug (#236)
PHP 5.4 sets UTF-8 as the default for htmlspecialchars, htmlentities and html_entity_decode. The first two will echo an empty string when given a string with umlauts. This commits introduces serendipity_specialchar-wrapper that are meant to be a temporary solution for the s9y-core until PHP 5.6 fixed the bug, so the native charset option of s9y continues to work.
2014-11-23 23:41:08 +01:00
Ian
d15c4c81b8 force_frontend_fallback chaining
References #148
2014-11-19 15:23:10 +01:00
Ian
530dff515b fix whitespaces and change a msg error string to 2.0 style 2014-11-17 19:37:17 +01:00
Garvin Hicking
83d19d183d stricter array check, thanks to wesley 2014-07-11 11:58:07 +02:00
Garvin Hicking
20cf96e969 move "smarty preview" to actual case, should fix the "entry saved" missing message 2014-06-03 11:09:00 +02:00
onli
3f18352bdc let preview use frontend-theme templates (#172) 2014-05-30 00:14:11 +02:00
onli
694b446e1a Move serendipiy_editor.js.tpl convertion into core
http://board.s9y.org/viewtopic.php?f=11&t=19927
2014-05-16 16:13:16 +02:00
Garvin Hicking
dd83225447 This is my proposal on implementing the ability to switch frontend and backend templates independently.
- This introduces a new option "template_backend" that will be set to indicate the backend template, defaults to 2k11.
- The "Engine: xxx" line in info.txt still works, but only for the frontend
- The frontend fallback chain defaults to the old "default" template to ensure that themes will work that have "old-style" HTML output
- The backend fallback chain only falls back to 2k11 and then "default"
- In the future, we will remove templates/default/admin once the mechanism is proven stable

To test this in all cases you can:

- Copy 2k11/ to 2k11-custom, edit info.txt, give it a distinct name. Edit the admin/index.tpl file to add some code to ensure that you will see that template in the backend if you pick it, or adjust the style.css or whatever.
- Copy idea/ to idea-custom, edit info.txt, add a "Engine: 2k11" line. Now you can test how a template would look like that fallsback on 2k11 instead of "default"

Those permutations can be checked and come to my mind:

- Backend: 2k11, Frontend: 2k11
- Backend: 2k11-custom, Frontend: 2k11
- Backend: 2k11, Frontend: 2k11-custom

- Backend: 2k11, Frontend: idea
- Backend: 2k11, Frontend: idea-custom

- Backend: 2k11-custom, Frontend: idea
- Backend: 2k11-custom, Frontend: idea-custom

They seem to work.

Currently the display of backend and frontend theme in templates.inc.tpl takes up some larger space. Maybe it could be prettified somehow, maybe put frontend and backend template next to each other, not beneath each other? Maybe @yellowled has some suggestions.

@onli and @ophian - please have a look at this, since you both also worked on the fallback chains. Please tell me if you have issues with this. We can easily revert, if you see this approach as not workable. This is more a "proof of concept" draft.
2014-05-14 12:58:06 +02:00
onli
06880647b7 fix jquerey check
template_engine in 2k11 is set to null, which is still set
2014-04-28 10:25:05 +02:00
onli
99c1f4c87c Fix fallback chain
Engine: default in info.txt will now lead to the template to use template/default as fallback before the default-template (2k11 currently). An approach to fix #130

Also, template_engine is not automatically set to default, as this was implicitly always the case
2014-04-27 20:23:56 +02:00
onli
7bf373248b serendipity_editor.js.tpl without core
To have this in the plugin api didn't look right. the fallback to default works this time, so this should be alright.
2014-03-23 23:53:55 +01:00
onli
7f4dbb3e2e Include JS in installer and upgrader
This should fix issue #80 by giving serendipity_editor.js of default to the
installer and  the normal template JS to the upgrader
2014-03-09 16:00:38 +01:00
Garvin Hicking
703d9f2ce0 Re-add the serendipity_jssetcookie function, because plugin use this API and it would otherwise create a fatal PHP error. 2014-03-05 11:54:00 +01:00
onli
2dcee8eae1 fix entry view link after edits 2014-01-18 23:19:18 +01:00
onli
d80a8334c8 Use return instead of echo in the remaining core
Debug-messages still may use echo, and some functions in functions_image and trackback still use it to generate progress messages, which should get cleaned up as well but is not that urgent
2013-07-05 19:16:11 +02:00
onli
a654b13a9a Complete include_once usage, romove constants 2013-06-22 12:32:54 +02:00
onli
487f71bd0b Fix preview of future entries
by hiding the footer. NOTE: This whole area needs a cleanup and is not smartified yet
2013-06-20 00:07:23 +02:00
onli
43a8bb9a39 smartify placement of entryeditor page elements 2013-06-14 23:26:49 +02:00
onli
d6857176d8 further smartify serendipity_iframe 2013-06-14 23:05:09 +02:00
onli
88bb8e0920 removed unused register_handle (alternative poc) 2013-03-06 20:44:11 +01:00
onli
0cd974fa6d proof-of-concept .js.tpl: Added fallback for serendipity_editor.js.tpl as serendipity_editor.js to default-template, and changed serendipity_get_file to react to .js.tpl-files in template-directories 2013-03-06 14:55:21 +01:00
Ian
c0c5cf747a revert last commit and fix only error line 1512 2012-12-13 15:44:11 +01:00
Ian
6340e21614 upport: Only variables should be assigned by reference 2012-12-13 14:03:43 +01:00