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
GROUP.CONF(5)							 Linux-PAM Manual						     GROUP.CONF(5)

NAME
group.conf - configuration file for the pam_group module DESCRIPTION
The pam_group PAM module does not authenticate the user, but instead it grants group memberships (in the credential setting phase of the authentication module) to the user. Such memberships are based on the service they are applying for. For this module to function correctly there must be a correctly formatted /etc/security/group.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;groups 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 UNIX group, or a netgroup of users to whom this rule applies. Group names are preceded by a '%' symbol, while netgroup names are preceded by a '@' symbol. For these items the simple wildcard '*' may be used only once. With UNIX groups or netgroups no wildcards or logic operators are allowed. The times field is used to indicate "when" these groups are to be given to the user. 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). The groups field is a comma or space separated list of groups that the user inherits membership of. These groups are added if the previous fields are satisfied by the user's request. For a rule to be active, ALL of service+ttys+users must be satisfied by the applying process. EXAMPLES
These are some example lines which might be specified in /etc/security/group.conf. Running 'xsh' on tty* (any ttyXXX device), the user 'us' is given access to the floppy (through membership of the floppy group) xsh;tty*&!ttyp*;us;Al0000-2400;floppy Running 'xsh' on tty* (any ttyXXX device), the user 'sword' is given access to games (through membership of the floppy group) after work hours. xsh; tty* ;sword;!Wk0900-1800;games, sound xsh; tty* ;*;Al0900-1800;floppy Any member of the group 'admin' running 'xsh' on tty*, is granted access (at any time) to the group 'plugdev' xsh; tty* ;%admin;Al0000-2400;plugdev SEE ALSO
pam_group(8), pam.d(5), pam(7) AUTHOR
pam_group was written by Andrew G. Morgan <morgan@kernel.org>. Linux-PAM Manual 06/04/2011 GROUP.CONF(5)
All times are GMT -4. The time now is 01:45 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy