Sponsored Content
Top Forums Web Development Notes with Ravinder on Badging System Development Part II Post 303028302 by Neo on Thursday 3rd of January 2019 10:47:02 PM
Old 01-03-2019
Ravinder,

I think it quite easy to do the "sequential days active" badge. This simple logic came to me in my sleep. We simply use a query like this:

Code:
mysql> SELECT UNIX_TIMESTAMP()/(60*60*24);
+-----------------------------+
| UNIX_TIMESTAMP()/(60*60*24) |
+-----------------------------+
|                  17900.1528 |
+-----------------------------+
1 row in set (0.00 sec)

to give us the number of days since the beginning of unixtime.

We store this value, rounded down in a new lastdayactive field in the user table;

Then we insert a 1 in the in the daysinsequence field in the same table.

Then we compare UNIX_TIMESTAMP()/(60*60*24) with lastdayactive and if this is one day greater (and less than two) than before, we update lastdayactive and increment daysinsequence.

If UNIX_TIMESTAMP()/(60*60*24) - lastdayactive is greater than 1 day we update lastdayactive and reset daysinsequence to 1.

It's quite simple, I think.

Hence, you get a D on this one (for implementation logic, sorry for that) because it is very simple to do but you could not do it after many days ... but an A for a great idea Smilie


I will implement this badge when I am back from my trip upcountry.
This User Gave Thanks to Neo For This Post:
 

3 More Discussions You Might Find Interesting

1. What is on Your Mind?

New Badging System - Badges Prototype Beta 1 (Badges Only)

Today I mapped out the new badging system using FA icons, Beta 1 in no particular order except a 6 x 8 grid: https://www.unix.com/members/1-albums215-picture991.png The prototype HTML code for this layout: <style> .fa-badge-grid { font-size: 1.5em; } .row { ... (38 Replies)
Discussion started by: Neo
38 Replies

2. What is on Your Mind?

Status of Badging System - Beta 1

Dear All, Here is the current status of the badging system: The Beta 1 phase of the new badging system is close to completion. 42 prototype badges have been "allocated" 6 prototype badge slots are held in reserve The "alert you have new badges" prototype is running and is currently... (4 Replies)
Discussion started by: Neo
4 Replies

3. What is on Your Mind?

Badging System: UNIX.COM Bug Hunter Badge (New)

I have moved the bug badge out of reserve and into the main stream. Basically, I will assign a color level like the others, based on who has made a good actionable bug report for UNIX.COM. "Good" means screenshots, links, and even details from web dev tools our the HTML source code. So far,... (0 Replies)
Discussion started by: Neo
0 Replies
TIME.CONF(5)							 Linux-PAM Manual						      TIME.CONF(5)

NAME
time.conf - configuration file for the pam_time module DESCRIPTION
The pam_time PAM module does not authenticate the user, but instead it restricts access to a system and or specific applications at various times of the day and on specific days or over various terminal lines. This module can be configured to deny access to (individual) users based on their name, the time of day, the day of week, the service they are applying for and their terminal from which they are making their request. For this module to function correctly there must be a correctly formatted /etc/security/time.conf file present. White spaces are ignored and lines maybe extended with '' (escaped newlines). Text following a '#' is ignored to the end of the line. The syntax of the lines is as follows: services;ttys;users;times In words, each rule occupies a line, terminated with a newline or the beginning of a comment; a '#'. It contains four fields separated with semicolons, ';'. The first field, the services field, is a logic list of PAM service names that the rule applies to. The second field, the tty field, is a logic list of terminal names that this rule applies to. The third field, the users field, is a logic list of users or a netgroup of users to whom this rule applies. For these items the simple wildcard '*' may be used only once. With netgroups no wildcards or logic operators are allowed. The times field is used to indicate the times at which this rule applies. The format here is a logic list of day/time-range entries. The days are specified by a sequence of two character entries, MoTuSa for example is Monday Tuesday and Saturday. Note that repeated days are unset MoMo = no day, and MoWk = all weekdays bar Monday. The two character combinations accepted are Mo Tu We Th Fr Sa Su Wk Wd Al, the last two being week-end days and all 7 days of the week respectively. As a final example, AlFr means all days except Friday. Each day/time-range can be prefixed with a '!' to indicate "anything but". The time-range part is two 24-hour times HHMM, separated by a hyphen, indicating the start and finish time (if the finish time is smaller than the start time it is deemed to apply on the following day). For a rule to be active, ALL of service+ttys+users must be satisfied by the applying process. Note, currently there is no daemon enforcing the end of a session. This needs to be remedied. Poorly formatted rules are logged as errors using syslog(3). EXAMPLES
These are some example lines which might be specified in /etc/security/time.conf. All users except for root are denied access to console-login at all times: login ; tty* & !ttyp* ; !root ; !Al0000-2400 Games (configured to use PAM) are only to be accessed out of working hours. This rule does not apply to the user waster: games ; * ; !waster ; Wd0000-2400 | Wk1800-0800 SEE ALSO
pam_time(8), pam.d(5), pam(8) AUTHOR
pam_time was written by Andrew G. Morgan <morgan@kernel.org>. Linux-PAM Manual 04/01/2010 TIME.CONF(5)
All times are GMT -4. The time now is 01:40 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy