Discuss Scratch

SuperScratcher_1234
Scratcher
100+ posts

Scratch Tools (v0.0.4 ALPHA) - Building A Complete User Management System [PHP, MySQL]

Okay, this post is seriously outdated! I have changed my vision of the purpose of Scratch Tools a lot during development. The first version of Scratch Tools intended to be used by the public is hopefully coming out in less than a month! When it finally does, I will make a new topic with up-to-date information.

Scratch Tools v0.0.4 ALPHA
The very first release of Scratch Tools is finally available. Details here. You can find the development roadmap here.
Please give feedback about this! Thanks!

Introduction
Okay, here I am: a person with ambitious project ideas and small knowledge when it comes to PHP and working with databases. That's a real problem… Recently, I came up with the idea of creating a complete user management system in PHP so as to integrate it into one of my unfinished Scratch webapps and to provide the world, mainly the Scratch community, with an easy to implement user management system that would be useful for many sites. However, as I said earlier, I have little knowledge around PHP, especially when it comes to databases so it would be nearly impossible for me alone to complete this project. I know HTML, CSS, a bit of JS, but what does that help when they are not the languages such system described above would be based on? Now, don't get me wrong; I know some basic PHP, I've read hundreds of articles and tutorials on this topic, and I have created more simple PHP based applications before but it's at this level my knowledge fails me! Speaking of tutorials, I just couldn't find any on the internet that fit my needs even a little bit!

So now, I turn to you; the Scratch community. I know there are many amazing people, coders, artists, helpers here and the list goes on and on. With the help of a few dedicated people this project could turn into reality.

With that said, if you are interested in helping me with building this project then please leave a reply below. That's not all: if you decide to help and stick with the project for a while then you are eligible for all rewards stated below under the Rewards section. Got you interested? Then here is what the project would look like:

The project
Overview
In short, this project is going to be a user management system. Such system includes the ability for users to register, login, confirm their email address, and connect their account to Scratch; the ability for administrators to manage users, bans, reports, feedbacks, etc. Furthermore, there are some features that I specifically need for my future Scratch webapp so it would be extremely nice of someone to help me with those too. Here is the complete feature list:

Feature list
⦿ - Required feature ⦿ - Great-to-have feature ⦿ - Optional feature ⦿ - Features that my Scratch webapp would specifically need
Roles & Permissions
  • Multiple user roles: users, moderators, admins ⦿
  • Verifying user roles when accessing pages ⦿
Userbase
  • Registration (linking Scratch account) ⦿
  • Logging in ⦿
  • Changing account credentials ⦿
  • Deleting account ⦿
  • Creating project groups ⦿
  • Setting permission (owner, member) in project groups ⦿
  • Commenting and replying in project groups ⦿
  • Inviting users to a project group ⦿
  • Deleting project groups ⦿
  • Viewing other users and comments ⦿
  • Reporting users and comments ⦿
  • Composing feedback ⦿
  • Adding users as friends ⦿
  • Reading notifications⦿
Moderators
  • All user privileges ⦿
  • Viewing reports ⦿
  • Deleting comments ⦿
  • Disabling and enabling project groups ⦿
  • Warning users through notifications ⦿
  • Handling (replying, deleting) feedbacks Viewing feedbacks ⦿
  • Kicking users for max 5 days ⦿
Administrators
  • All user and moderator privileges ⦿
  • Toggling maintenance mod ⦿
  • Whitelisting ips that may access the website when in maintenance mode ⦿
  • Managing users, permission, and feedbacks (CRUD - Create, Read, Write, Delete) ⦿
  • Disabling and enabling registration and login⦿
  • Banning users ⦿
  • Viewing stats about the users (how many un/activated users, new users, etc) ⦿
  • Managing reports ⦿
  • Managing project groups ⦿

Organisation
I think that the ideal place for managing all the files for this project is GitHub but let me know if you would prefer to use another platform.

Technical details
Security
In order to protect user credentials, please follow these security guidelines when working on the project:
  • Passwords - Please use the
    password_hash()
    
    function to hash all passwords and sensitive details.
  • Sanitizing inputs - Please remember to sanitize any data before sending it to the database using
    mysql_real_escape_string()
    
  • Other - Please use the appropriate security measures in other cases not written above. Thank you!
PHP & MySQL
To keep the code organised, clean, and efficient please use object oriented php instead of procedural php. The project is going to use a standard up-to-date MySQL database.
Documentation
When writing code, please document it and add useful, clear, and understandable comments where needed. This way, other contributors can understand your code faster and easier therefore speeding up development and preventing unnecessary complications.
Registration and logging in
Here is how registration should happen: the visitor is taken to the registration page where they need to enter their Scratch username then hit a submit button. Then the database will be queried to check if that user already exists or not and if no, the PHP code is going to generate a unique string, insert it into a database, and send the user to a Scratch project telling him/her to comment the unique string. Once the visitor has commented the string, he/she should be able to go back and hit a button that will check if he/she has commented the string exactly. If no, the unique string is deleted from the database and the visitor has to start over. However, if yes,the string is deleted from the database as well and the visitor will be taken to a page where he/she can finish up the registration process. There will be 4 fields on this page:
  • Username - This field contains the visitor's Scratch username. It is disabled so it cannot be edited.
  • Nickname - This field is optional; it allows the visitor to enter a custom nickname.
  • Password - The visitor can enter a password here. This field is required.
  • Password again - The visitor must type out his/her password again so the two password fields match. This field is required.
Then the visitor can hit a submit button to register and all the sanitized data would be sent to a database. The date, and the ip address should be sent too. The Nickname data would be checked in the database too to make sure it's not a duplicate.Lastly, a link to the profile picture of the user on Scratch would be saved in the database as well, acting as the profile picture of the user.

This is a sample code for verifying if the user has commented the string on a project:
$project_id = '10135908/';
$project_url = 'http://scratch.mit.edu/projects/' . $project_id;
$api_url = 'http://scratch.mit.edu/site-api/comments/project/' . $project_id . '?page=1&salt=' . md5(time()); //salt is to prevent caching
$data = file_get_contents($api_url);
    if (!$data) {
        echo '<p>API access failed. Please try again later.</p>';
        return;
    }
    $success = false;
    preg_match_all('%<div id="comments-\d+" class="comment.*?" data-comment-id="\d+">.*?<a href="/users/(.*?)">.*?<div class="content">(.*?)</div>%ms', $data, $matches);
    foreach ($matches[2] as $key => $val) {
        $user = $matches[1][$key];
        $comment = trim($val);
        if ($user == $requested_user /* this variable needs to represent the username you're looking for */ && $comment == $verification_code /* whatever verification code you're looking for */) {
            $success = true;
            //do whatever you need to do to continue
            break;
        }
    }

The login process: the user enters her Scratch username and the password he/she set when registering. The data would be compared to the data in the database and if everything is alright, then the user would be logged in and redirected to the appropriate page depending on his/her role. A session cookie should be created and the session should be logged in the database to prevent multiple sessions at the same time.The time of the login and the user's ip address should also be registered in the database.
Changing credentials, moderation
For a normal user and for moderators, there should be a page where they can view and modify all of their credentials. When credentials are updated, the link pointing to the profile picture of the user on Scratch should be fetched again and updated if necessary.
Administrators
Administrators should have a dashboard where they can view all user credentials, edit all user credentials (including their own credentials), promoting or downgrading a user's permission level, viewing deleted comments and permanently removing them, disabling account, banning users, disabling registration and logging in temporarily, putting the site in maintenance mode and specifying ips that are allowed to access the site during maintenance. Administrators should be able to read and delete reports and send out, view, and delete notifications and warnings to users using their dashboard too. However, administrators should not be limited to their dashboards but should be able to interact with the website like a normal users too.
Ajax
To make user experience as smooth as possible, try to use ajax requests instead of refreshing the entire browser. Thi is optional but it would improve user experience.
Notifications
Each user should have an inbox similar to Scratch where they will receive notifications when someone has replied to their comment, invited them to a project group, promoted them in a project group, and when they receive notifications and warnings from moderators and administrators. Everything on the site is public, except for the notifications but that's the same on Scratch. Users can mark their messages as read too.
Commenting
Users should be able to comment on their and other user's profiles and in project groups. Users should only be able to delete comments on their profiles and in project groups that they own. When a user deletes a comment, it should not be permanently deleted from the database and moderators and administrators should be able to see these kinds of comments to help clear up possible conflicts. Administrators should be able to delete comments permanently.
Project groups
Okay, so you are probably asking yourself: what are these project groups? Well, they are not part of the user management system but they are a feature my Scratch web app would be based around. The point of project groupsi is to help Scratchers organize collaborations better instead of constantly remixing each other's projects and getting confused while at it. Basically, anyone registered on my site should be able to create a project group. The creator of a project group will be the owner who has full access to it. He/she can invite people by usernames (invited people will receive a notification in their inbox with a link to accept the invitation). An invited person is granted the permissions of a contributor. Owners and contributors can create tasks, add a due date to them, delete them, and mark them as done on the Board page in the project group and add labels to them. Only an owner can create labels that can be later added to tasks. Each task has a title, a brief description, and the creator of the task and the owner can assign specific people to a task. Inside a project group, there will be a chat system where the invited users can talk. Users inside a project group can also attach comments and notes to tasks.The owner of the project group can set and modify the link to the main collaboration project on Scratch, name and rename the project group, add/edit the description to the project, and delete the project group. These features (in the previous sentence) would be found under the Main tab in a project group.Lastly, a collaborator can leave the group too.
Limits
There must be limits set in place to prevent the servers from overloading or from running out of disk space.
  • Registration & Login - Only 1 user can be created per ip address.
  • Project groups - A user can have a maximum of 2 project groups at a time. The character limit in the description of a project group is 100. The maximum amount of tasks at the same time in a project group is 20. Each task can have maximum of 7 labels, up to 10 people assigned to it; its name must not exceed 50 characters, and its description can contain a maximum of 100 characters. The amount of labels in a project group can be 10 maximum and the title of a label must not be over 20 characters. A user cannot be in more than 5 project groups at a time.
  • Notifications - Notifications older than 60 days are automatically deleted except for warnings from moderators and administrators.
  • Comments - All comment should be limited to 300 characters.

Useful links
I have found the backend code (PHP) of ModShare that implements nearly all of the features I would like to see in this project. However, it is from 7 years ago so parts of it may be outdated. Still, here it is; it might help us build the foundation of this project based on it.

Please find the GitHub link for the whole project here.

“Rewards”
I cannot possibly express how thankful I am for all contributors. I know that asking so much of you for absolutely nothing is not really fair so I have gathered a list of "rewards" that all participants are eligible for. Thank you!
  • This is an opportunity for you to improve your programming skills, learn from more experienced people and teach beginners (like me). Perhaps you will make some friends along the way as well!
  • You get access to the full source code of the project so you could integrate it into your own website as well.
  • You will be promoted to manager on my future Scratch web app id you prove yourself responsible enough.
  • I will design you a custom profile picture if needed.
    I can do basic animations too and make you a GIF!
  • I will host a Node.js or Python script for you 24/7.
    This is a limited offer available for 3 people maximum. However, I can make exceptions. When submitting your script, please make sure it has no memory-leaks and it is not too resource intensive. If my sever cannot handle your script then you can modify it and resubmit it to me. The server is kept on 24/7 but there might be some outages. I will try to fix them as soon as possible. Please contact me on my profile for more details.

Project Group mockups (doesn't show all the features outlined above




I'm really looking forward to this project and hope you will join me!

Written and posted with by @SuperScratcher_1234.

Last edited by SuperScratcher_1234 (April 20, 2021 09:04:11)

StalX
Scratcher
41 posts

Scratch Tools (v0.0.4 ALPHA) - Building A Complete User Management System [PHP, MySQL]

So, the webapp you are working on is basicly like one of thoes team management apps like “Monday”? That can be very helpful!

-StalX
when green flag clicked
wait (5) secs
switch costume to [ Nod Stupidly]

Last edited by StalX (Oct. 20, 2020 14:23:44)

SuperScratcher_1234
Scratcher
100+ posts

Scratch Tools (v0.0.4 ALPHA) - Building A Complete User Management System [PHP, MySQL]

StalX wrote:

So, the webapp you are working on is basicly like one of thoes team management apps like “Monday”? That can be very helpful!

-StalX
when green flag clicked
wait (5) secs
switch costume to [ Nod Stupidly]
Yes, something similar!
Jeffalo
Scratcher
1000+ posts

Scratch Tools (v0.0.4 ALPHA) - Building A Complete User Management System [PHP, MySQL]

this sounds super cool! please keep us updated with the progress, as i for one would love to see how this is going!
SuperScratcher_1234
Scratcher
100+ posts

Scratch Tools (v0.0.4 ALPHA) - Building A Complete User Management System [PHP, MySQL]

Jeffalo wrote:

this sounds super cool! please keep us updated with the progress, as i for one would love to see how this is going!
Yeah! If I don't get any people interested within a couple of days then I'm going to start the project myself and spend most of my time on Stack Overflow! xD
Pufferfish_Test
Scratcher
500+ posts

Scratch Tools (v0.0.4 ALPHA) - Building A Complete User Management System [PHP, MySQL]

I'd absolutely love to help out with this, but sadly I barely know any php and only a basic understanding of sql. I only know node.js and front end stuff
I'll be honest with you - you're probably more likely to find collaborators if you work with node of python, as more people seem to learn these nowadays, even if over 70% of the web uses php
I will try and find a tutorial somewhere online about this incase you don't find anyone, I'm usually quite good at that
I used way too many emojis here
god286
Scratcher
1000+ posts

Scratch Tools (v0.0.4 ALPHA) - Building A Complete User Management System [PHP, MySQL]

I wish I could help out but I don’t have GitHub, I don’t know any php at all

I think for authentication you can use fluffyscratch that @jeffalo knows about. I don’t know if you would need passwords when using that, but I’m not so sure about its security though

Last edited by god286 (Oct. 20, 2020 18:47:38)

Jeffalo
Scratcher
1000+ posts

Scratch Tools (v0.0.4 ALPHA) - Building A Complete User Management System [PHP, MySQL]

Pufferfish_Test wrote:

I'd absolutely love to help out with this, but sadly I barely know any php and only a basic understanding of sql. I only know node.js and front end stuff
I'll be honest with you - you're probably more likely to find collaborators if you work with node of python, as more people seem to learn these nowadays, even if over 70% of the web uses php
I will try and find a tutorial somewhere online about this incase you don't find anyone, I'm usually quite good at that
I used way too many emojis here
nodejs. nodejs. nodejs. nodejs.

DatOneLefty
Scratcher
1000+ posts

Scratch Tools (v0.0.4 ALPHA) - Building A Complete User Management System [PHP, MySQL]

god286 wrote:

I wish I could help out but I don’t have GitHub, I don’t know any php at all

I think for authentication you can use fluffyscratch that @jeffalo knows about. I don’t know if you would need passwords when using that, but I’m not so sure about its security though
I would recommend using fluffyscratch for authentication because storing passwords gets messy and dangerous (people will often use the same password, and if your database happens to be stolen those passwords are unsafe for all sites). Another upside of fluffyscratch is that it doesn't only allow for passwordless login, it's easy verification that someone is who they say they are!

It's been a long time since I've worked on PHP, but I actively work on MySQL (for ScratchDB) so I can help out there if needed!
Maximouse
Scratcher
1000+ posts

Scratch Tools (v0.0.4 ALPHA) - Building A Complete User Management System [PHP, MySQL]

Pufferfish_Test wrote:

I'll be honest with you - you're probably more likely to find collaborators if you work with node of python, as more people seem to learn these nowadays, even if over 70% of the web uses php
For reasons. Obviously things are improving over time, but a badly designed language can't just become good.
SuperScratcher_1234
Scratcher
100+ posts

Scratch Tools (v0.0.4 ALPHA) - Building A Complete User Management System [PHP, MySQL]

Pufferfish_Test wrote:

I'd absolutely love to help out with this, but sadly I barely know any php and only a basic understanding of sql. I only know node.js and front end stuff
I'll be honest with you - you're probably more likely to find collaborators if you work with node of python, as more people seem to learn these nowadays, even if over 70% of the web uses php
I will try and find a tutorial somewhere online about this incase you don't find anyone, I'm usually quite good at that
I used way too many emojis here

Jeffalo wrote:

nodejs. nodejs. nodejs. nodejs.

Maximouse wrote:

For reasons. Obviously things are improving over time, but a badly designed language can't just become good.
Yes. All of your arguments are true and I agree that PHP is a badly designed language. However, as said earlier, more than 70% (actually 78.9%) of sites with some kind of server-side programming use PHP and most web hosting providers do not support Node.js or Python with a standard plan. Furthermore, PHP 8 is just around the corner, bringing huge improvements and consistency (hopefully ).

god286 wrote:

I wish I could help out but I don’t have GitHub, I don’t know any php at all

I think for authentication you can use fluffyscratch that @jeffalo knows about. I don’t know if you would need passwords when using that, but I’m not so sure about its security though

DatOneLefty wrote:

I would recommend using fluffyscratch for authentication because storing passwords gets messy and dangerous (people will often use the same password, and if your database happens to be stolen those passwords are unsafe for all sites). Another upside of fluffyscratch is that it doesn't only allow for passwordless login, it's easy verification that someone is who they say they are!

It's been a long time since I've worked on PHP, but I actively work on MySQL (for ScratchDB) so I can help out there if needed!
I see that a lot of you are recommending fluffyscratch. The only problem I have with it though that every time a user would like to login they would need to 1) copy a code, 2) go to a scratch project (and login to Scratch as well if they aren't already), 3) comment their code, 4) go back to the website and press a button to verify that they have commented the code. This process would be perfectly acceptable for registration but for logging in… nah.

I think that I'm going to provide users with two options:
  1. Set up a password during registration and use it while logging in
    OR
  2. Always use an authentication system like fluffyscratch to log in
Thoughts?
Jeffalo
Scratcher
1000+ posts

Scratch Tools (v0.0.4 ALPHA) - Building A Complete User Management System [PHP, MySQL]

SuperScratcher_1234 wrote:

The only problem I have with it though that every time a user would like to login they would need to 1) copy a code, 2) go to a scratch project (and login to Scratch as well if they aren't already), 3) comment their code, 4) go back to the website and press a button to verify that they have commented the code. Thoughts?
you could write a browser extension to automate it. and make it basically instant. either way, i've speedran the fluffyscratch auth process and i can do it in under 15 seconds and sometimes faster than a normal password login
SuperScratcher_1234
Scratcher
100+ posts

Scratch Tools (v0.0.4 ALPHA) - Building A Complete User Management System [PHP, MySQL]

Jeffalo wrote:

SuperScratcher_1234 wrote:

The only problem I have with it though that every time a user would like to login they would need to 1) copy a code, 2) go to a scratch project (and login to Scratch as well if they aren't already), 3) comment their code, 4) go back to the website and press a button to verify that they have commented the code. Thoughts?
you could write a browser extension to automate it. and make it basically instant. either way, i've speedran the fluffyscratch auth process and i can do it in under 15 seconds and sometimes faster than a normal password login
True, but Scratch does not allow sharing extensions. Still, a good idea! I think I'm going to give the two login options to users that I've written above and do my best regarding security.

Just to make sure everything is secure, before publicly releasing the website with the login/registration system (when it's done), I will create a new topic here and I will ask the ATers to try and hack into my site. Then I will fix any security issues asap.
fdreerf
Scratcher
1000+ posts

Scratch Tools (v0.0.4 ALPHA) - Building A Complete User Management System [PHP, MySQL]

Are you sure you'll be able to share the finished product on Scratch – the features look very fishy.
Jeffalo
Scratcher
1000+ posts

Scratch Tools (v0.0.4 ALPHA) - Building A Complete User Management System [PHP, MySQL]

fdreerf wrote:

Are you sure you'll be able to share the finished product on Scratch – the features look very fishy.
yeah, something like this would count as unmoderated chat
SuperScratcher_1234
Scratcher
100+ posts

Scratch Tools (v0.0.4 ALPHA) - Building A Complete User Management System [PHP, MySQL]

fdreerf wrote:

Are you sure you'll be able to share the finished product on Scratch – the features look very fishy.
Oops, the only thing I found that could be counted as private messaging was the ability for users, moderators, and administrators to reply privately through feedbacks. However, now that I removed that feature from the list, I think that there are no more very fishy features and my sites meets all the guidelines about user created websites:
The guidelines set by the Scratch Team for user created sites (source):
  1. All content on your site must be appropriate for Scratchers of all ages.
  2. Your site should not be giving out any of your personal information - in the website name, in the “Contact Us” area, in links to social media sites, and so on. Remember that what you post on the internet is very hard to remove.
  3. Your site should not be asking for email addresses - this often happens in the “Contact Us” area.
  4. Your site should not be providing unmoderated communication.
  5. Make sure your site is not downloading anything potentially malicious.
  6. Your site should not be selling anything.
Correct me if I'm wrong please! Thanks!
DabDatBass
Scratcher
1000+ posts

Scratch Tools (v0.0.4 ALPHA) - Building A Complete User Management System [PHP, MySQL]

(is this a website? Because I'm going to refer this as a website often xD)

This is cool- I could help; I have a semi-understanding of PHP (I'm going to lean more every day, it's a new programming language to me owo), I know a LOT of CSS that can make the website look great, and I know TONS of html.

I've been working on https://www.gamr.gq , https://www.openly.tk , and https://outdoors-man.dabdatbass.repl.co ; all of them are websites that I've worked hard on

I sadly don't have GitHub (big sad ;-; BUT I might ask my dad for an account )…

I'm going to be very active with REAL coding and not Scratch, so I could help out. A LOT.

Thanks, hopefully I can help with it!

SuperScratcher_1234
Scratcher
100+ posts

Scratch Tools (v0.0.4 ALPHA) - Building A Complete User Management System [PHP, MySQL]

DabDatBass wrote:

(is this a website? Because I'm going to refer this as a website often xD)

This is cool- I could help; I have a semi-understanding of PHP (I'm going to lean more every day, it's a new programming language to me owo), I know a LOT of CSS that can make the website look great, and I know TONS of html.

I've been working on https://www.gamr.gq , https://www.openly.tk , and https://outdoors-man.dabdatbass.repl.co ; all of them are websites that I've worked hard on

I sadly don't have GitHub (big sad ;-; BUT I might ask my dad for an account )…

I'm going to be very active with REAL coding and not Scratch, so I could help out. A LOT.

Thanks, hopefully I can help with it!

Yes, it is going to be a website! I don't think I need much help with CSS because I'm using a framework called Halfmoon but you can help me customize its styles. I've just checked out your websites, they all look very cool and impressive!

By the way, I'm learning PHP right now too.
Jeffalo
Scratcher
1000+ posts

Scratch Tools (v0.0.4 ALPHA) - Building A Complete User Management System [PHP, MySQL]

SuperScratcher_1234 wrote:

Yes, it is going to be a website! I don't think I need much help with CSS because I'm using a framework called Halfmoon
what! how do you find CSS frameworks like this? whenever i try looking for them I end up just going with boring old bootstrap or whatever! this half-moon stuff looks so clean and it takes care of the whole UI!!! i want to make something that uses it now!
SuperScratcher_1234
Scratcher
100+ posts

Scratch Tools (v0.0.4 ALPHA) - Building A Complete User Management System [PHP, MySQL]

Jeffalo wrote:

SuperScratcher_1234 wrote:

Yes, it is going to be a website! I don't think I need much help with CSS because I'm using a framework called Halfmoon
what! how do you find CSS frameworks like this? whenever i try looking for them I end up just going with boring old bootstrap or whatever! this half-moon stuff looks so clean and it takes care of the whole UI!!! i want to make something that uses it now!
I felt like that when I first found it too!

Powered by DjangoBB