📂 File Browser

applications/includes
☀️ Light Mode
🎯 Quick Launch:

📁 Directories

📄 Files

🐘 auth.php
▶ Open 📄 View Source
🐘 config.php
▶ Open 📄 View Source
🐘 functions.php
▶ Open 📄 View Source

📄 Source: functions.php

<?php
// Helper functions
require_once 'config.php';

function sanitize($input) {
    return htmlspecialchars(strip_tags(trim($input)), ENT_QUOTES, 'UTF-8');
}

function generateSlug($string) {
    $string = strtolower($string);
    $string = preg_replace('/[^a-z0-9-]/', '-', $string);
    $string = preg_replace('/-+/', '-', $string);
    return trim($string, '-');
}

function getStatusBadge($status) {
    $badges = [
        'pending' => ['label' => '⏳ Pending', 'class' => 'status-pending'],
        'approved' => ['label' => '✅ Approved', 'class' => 'status-approved'],
        'rejected' => ['label' => '❌ Rejected', 'class' => 'status-rejected']
    ];
    return $badges[$status] ?? ['label' => $status, 'class' => ''];
}

function getPlatformLabel($platform) {
    $labels = [
        'discord' => '🟣 Discord',
        'google' => '🔴 Google',
        'roblox' => '🟠 Roblox',
        'none' => '📝 None'
    ];
    return $labels[$platform] ?? $platform;
}

function truncate($string, $length = 100) {
    if (strlen($string) <= $length) return $string;
    return substr($string, 0, $length) . '...';
}

function timeAgo($timestamp) {
    $time = strtotime($timestamp);
    $diff = time() - $time;
    
    if ($diff < 60) return $diff . 's ago';
    if ($diff < 3600) return floor($diff / 60) . 'm ago';
    if ($diff < 86400) return floor($diff / 3600) . 'h ago';
    if ($diff < 604800) return floor($diff / 86400) . 'd ago';
    
    return date('M j, Y', $time);
}

function getQuestionTypes() {
    return [
        'text' => 'Short Text',
        'textarea' => 'Paragraph',
        'choice' => 'Multiple Choice',
        'checkbox' => 'Checkboxes'
    ];
}

function getMaxChars($type) {
    switch ($type) {
        case 'text':
            return 2048;
        case 'textarea':
            return 4096;
        default:
            return null;
    }
}

// Generate random string
function randomString($length = 8) {
    return substr(str_shuffle('abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789'), 0, $length);
}

// Validate time limit
function validateTimeLimit($minutes) {
    $minutes = intval($minutes);
    if ($minutes < 5) return 5;
    if ($minutes > 180) return 180;
    return $minutes;
}

// Get remaining time for application
function getRemainingTime($startTime, $timeLimit) {
    $elapsed = time() - strtotime($startTime);
    $remaining = ($timeLimit * 60) - $elapsed;
    return max(0, $remaining);
}

// Format time
function formatTime($seconds) {
    $minutes = floor($seconds / 60);
    $seconds = $seconds % 60;
    return sprintf("%02d:%02d", $minutes, $seconds);
}
?>
← Back