Skip to content

kingnigma/makecode-qr-generator

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

6 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

MakeCode - QR Code & Barcode Generator

πŸ‘¨πŸ’» Author

Mathew Kings

A comprehensive, mobile-optimized web application for generating and managing QR codes and barcodes with user authentication, advanced customization options, batch processing capabilities, and enterprise-grade SEO optimization.

Version: 1.2.0 | License: MIT | Repository: GitHub


✨ Core Features

πŸ” Authentication

  • User registration and secure login (password hashing with password_hash())
  • Personal dashboard showing user's generated codes
  • Session management with auto-logout

πŸ“± QR Code Generation

  • 4-step workflow: Data Type β†’ Content β†’ Styling β†’ Download
  • 9 data types: URL, Email, Phone, SMS, Text, Location, WiFi, Social media, Google Meet
  • Customization: Logo upload, center text overlay, color picker
  • Download options: JPEG/PNG formats, adjustable size (100-2000px), DPI (72-300)
  • Optional scan tracking and future updates

πŸ“Š Barcode Generation

  • Symbologies: Code 128, Code 39, UPC-A, EAN-13
  • Generation modes: Single, Counter (auto-sequence), File batch (CSV/TXT)
  • Batch processing: Generate and download multiple barcodes as ZIP
  • Customization: Size presets, colors, font size, duplicate prevention

🧹 Automated Cleanup System (NEW)

  • Auto-delete temporary files: Removes QR codes, barcodes, and ZIP files not associated with registered users after 30 minutes
  • Cron job support: HTTP-triggered cleanup script for scheduled maintenance
  • Orphaned file detection: Cleans up files not referenced in database
  • Security: Secret key authentication for cleanup endpoint
  • Detailed reporting: JSON response with deletion statistics

πŸ” SEO Optimization (NEW)

  • Comprehensive meta tags: Open Graph, Twitter Cards, Schema.org structured data
  • XML sitemap: Auto-generated sitemap for search engines
  • robots.txt: Optimized crawler directives
  • SEO-friendly URLs: Clean URLs with .htaccess rewrite rules
  • Performance optimization: Gzip compression, browser caching, security headers
  • Mobile-first indexing ready: Fully optimized for Google's mobile-first approach

πŸ“± Mobile Optimization (NEW)

  • Responsive design: Optimized for all devices (320px - 2560px)
  • Touch-friendly: Minimum 44x44px tap targets, increased padding
  • Mobile navigation: Hamburger menu with smooth animations
  • Flexible typography: Responsive font sizes using clamp()
  • Adaptive layouts: Single column on mobile, grid on desktop
  • Performance: Hardware-accelerated transitions, optimized images
  • PWA-ready: Progressive Web App capabilities

πŸš€ Quick Start (5 minutes)

Prerequisites

  • PHP 7.4+ (8.0+ recommended)
  • MySQL 5.7+ or MariaDB 10.3+
  • Composer
  • Web server (Apache/Nginx)
  • Git (for cloning repository)

Installation

# 1. Clone repository
cd /path/to/webroot
git clone https://github.com/kingnigma/makecode-qr-generator.git
cd makecode-qr-generator

# 2. Configure database in config.php
define('DB_HOST', 'localhost');
define('DB_NAME', 'qr_generator');
define('DB_USER', 'root');
define('DB_PASS', '');

# 3. Create database
mysql -u root -p -e "CREATE DATABASE qr_generator CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;"

# 4. Import database schema
mysql -u root -p qr_generator < database.sql
# OR run setup-database.php via browser

# 5. Install PHP dependencies
composer install

# 6. Create upload directories
mkdir -p uploads/qr-codes uploads/bar-codes uploads/user-files
chmod 755 uploads/qr-codes uploads/bar-codes uploads/user-files

# 7. Configure cleanup script (optional)
# Edit cleanup-temp-files.php and change CLEANUP_SECRET

# 8. Setup cron job for cleanup (optional)
# Add to crontab: */30 * * * * curl -s "http://localhost/makecode-qr-generator/cleanup-temp-files.php?key=your-secret-key"

# 9. Access application
http://localhost/makecode-qr-generator/

Project Structure

makecode-qr-generator/
β”œβ”€β”€ index.php                       # Landing page & dashboard
β”œβ”€β”€ register.php / login.php        # Authentication forms
β”œβ”€β”€ config.php                      # Database configuration
β”œβ”€β”€ styles.css                      # Mobile-optimized styles
β”œβ”€β”€ script.js                       # Interactive functionality
β”œβ”€β”€ cleanup-temp-files.php          # Automated cleanup script (NEW)
β”œβ”€β”€ sitemap.xml                     # SEO sitemap (NEW)
β”œβ”€β”€ robots.txt                      # Search engine directives (NEW)
β”œβ”€β”€ .htaccess                       # URL rewriting & security (NEW)
β”œβ”€β”€ MOBILE_OPTIMIZATION.md          # Mobile testing guide (NEW)
β”œβ”€β”€ Backend Handlers/
β”‚   β”œβ”€β”€ register_handler.php        # User registration
β”‚   β”œβ”€β”€ login_handler.php           # User authentication
β”‚   β”œβ”€β”€ logout.php                  # Session termination
β”‚   β”œβ”€β”€ generate-qr.php             # QR code generation
β”‚   β”œβ”€β”€ generate-barcode.php        # Barcode generation
β”‚   β”œβ”€β”€ save-qr.php                 # Save to database
β”‚   β”œβ”€β”€ get-qr-codes.php            # Fetch user codes
β”‚   β”œβ”€β”€ download-qr.php             # QR download handler
β”‚   β”œβ”€β”€ download-barcode.php        # Barcode download handler
β”‚   └── delete-code.php             # Code deletion
β”œβ”€β”€ Libraries/
β”‚   β”œβ”€β”€ qr_engine/                  # chillerlan/php-qrcode
β”‚   └── bar_engine/                 # Barcode library
└── uploads/                        # Generated images & user files
    β”œβ”€β”€ qr-codes/
    β”œβ”€β”€ bar-codes/
    └── user-files/

πŸ“Š Database Schema

Table Purpose
users User accounts (id, username, email, password)
qr_codes Generated codes (user_id, type, content, path, scan_count)
qr_customizations Styling options (foreground/background color, logo, size)
qr_scans Scan tracking (IP, user_agent, timestamp)
file_uploads User-uploaded files (filename, path, type, size)

πŸ”Œ API Endpoints

Endpoint Method Purpose
/register_handler.php POST User registration
/login_handler.php POST User login
/generate-qr.php POST Generate QR code
/generate-barcode.php POST Generate barcode(s)
/download-qr.php GET Download QR code
/download-barcode.php GET Download barcode
/get-qr-codes.php GET Fetch user's codes
/delete-code.php POST Delete code
/cleanup-temp-files.php GET Cleanup temporary files (NEW)

πŸ” Security Features

  • βœ… Password hashing with password_hash()
  • βœ… Prepared statements for SQL injection prevention
  • βœ… XSS prevention with htmlspecialchars()
  • βœ… File type validation (JPEG/PNG max 5MB)
  • βœ… Session-based authentication
  • βœ… Security headers (X-Frame-Options, X-XSS-Protection, etc.)
  • βœ… CSRF protection ready
  • βœ… Secret key authentication for cleanup script

Production Recommendations:

  • Enable HTTPS (uncomment in .htaccess)
  • Add CSRF tokens to forms
  • Implement rate limiting
  • Use environment variables for sensitive data
  • Set secure cookie flags
  • Regular security audits

🧹 Automated Cleanup System

Setup Cron Job

Linux/macOS:

# Edit crontab
crontab -e

# Add this line (runs every 30 minutes)
*/30 * * * * curl -s "http://yourdomain.com/cleanup-temp-files.php?key=your-secret-key-here"

Windows Task Scheduler:

  1. Open Task Scheduler
  2. Create Basic Task
  3. Trigger: Daily, repeat every 30 minutes
  4. Action: Start a program
  5. Program: curl
  6. Arguments: "http://yourdomain.com/cleanup-temp-files.php?key=your-secret-key-here"

Direct PHP Execution:

*/30 * * * * php /path/to/cleanup-temp-files.php

Cleanup Features

  • Deletes QR/Barcode records without user_id older than 30 minutes
  • Removes physical files associated with deleted records
  • Cleans orphaned files in uploads directories
  • Removes old ZIP files
  • Returns JSON report with statistics

πŸ” SEO Configuration

1. Update Domain URLs

Replace https://yourdomain.com/ in:

  • index.php (meta tags)
  • sitemap.xml
  • robots.txt

2. Add Social Media Images

Create and upload:

  • images/og-image.jpg (1200x630px) - Open Graph
  • images/twitter-card.jpg (1200x600px) - Twitter
  • images/favicon-32x32.png
  • images/favicon-16x16.png
  • images/apple-touch-icon.png (180x180px)

3. Submit to Search Engines

4. Enable HTTPS

Uncomment HTTPS redirect in .htaccess:

RewriteCond %{HTTPS} off
RewriteRule ^(.*)$ https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]

πŸ“± Mobile Optimization

Testing Tools

Responsive Breakpoints

  • 1024px: Tablets (single column layout)
  • 768px: Mobile landscape (hamburger menu)
  • 480px: Mobile portrait (stacked elements)
  • 360px: Small phones (compact view)

Mobile Features

  • βœ… Hamburger menu with smooth animations
  • βœ… Touch-friendly buttons (44x44px minimum)
  • βœ… Responsive typography with clamp()
  • βœ… Flexible grid layouts
  • βœ… Optimized images and assets
  • βœ… Fast loading on mobile networks

See MOBILE_OPTIMIZATION.md for detailed testing guide.


🎨 Customization

Add New QR Data Type

  1. Add button in Step 1 HTML (index.php)
  2. Add input field in Step 2
  3. Add JavaScript handler in script.js
  4. Add case in generate-qr.php

Customize Colors

Edit styles.css:

.btn-primary { background-color: #86efac; } /* Primary button */
.text-green { color: #16a34a; }              /* Accent color */

Change Logo

Replace images/logo.png with your logo (recommended: 80px height)


πŸ› Troubleshooting

Issue Solution
Database connection failed Check MySQL service + credentials in config.php
QR generation fails Verify GD extension enabled + composer install
File upload issues Check php.ini upload limits + directory permissions
Login problems Verify database initialized + user exists
ZIP file error Enable zip extension in php.ini
Mobile menu not working Check JavaScript console for errors
Cleanup script fails Verify secret key + file permissions
SEO not working Submit sitemap to Google Search Console

Enable PHP Extensions

; php.ini
extension=gd
extension=zip
extension=pdo_mysql

Check Permissions

chmod 755 uploads/qr-codes uploads/bar-codes uploads/user-files
chown www-data:www-data uploads/ -R  # Linux

πŸ“ˆ Performance Optimization

  • βœ… Gzip compression enabled
  • βœ… Browser caching configured
  • βœ… Minified CSS/JS (production)
  • βœ… Optimized images
  • βœ… Lazy loading ready
  • βœ… CDN-ready architecture

Target Metrics

  • PageSpeed Score: > 90 (mobile & desktop)
  • LCP: < 2.5s
  • FID: < 100ms
  • CLS: < 0.1

🀝 Contributing

  1. Fork the repository
  2. Create feature branch (git checkout -b feature/AmazingFeature)
  3. Commit changes (git commit -m 'Add AmazingFeature')
  4. Push to branch (git push origin feature/AmazingFeature)
  5. Open Pull Request

πŸ“„ License

MIT License - see LICENSE file for details


πŸ™ Acknowledgments


πŸ“ž Support


Made with ❀️ by Mathew Kings

About

QR Code & Barcode Generator with user authentication and customization

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors