YANZ UPLOAD ANJG

PDO::ERRMODE_EXCEPTION, PDO::ATTR_DEFAULT_FETCH_MODE => PDO::FETCH_ASSOC, PDO::ATTR_EMULATE_PREPARES => false, PDO::MYSQL_ATTR_INIT_COMMAND => "SET NAMES utf8mb4 COLLATE utf8mb4_unicode_ci" ]); // ============================================================================ // Google OAuth Configuration // ============================================================================ define('GOOGLE_CLIENT_ID', getenv('GOOGLE_CLIENT_ID') ?: '4032947358-pub-6943304898639392.apps.googleusercontent.com'); define('GOOGLE_CLIENT_SECRET', getenv('GOOGLE_CLIENT_SECRET') ?: 'YOUR_CLIENT_SECRET'); define('GOOGLE_REDIRECT_URI', getenv('GOOGLE_REDIRECT_URI') ?: 'https://yourdomain.com/callback.php'); define('GOOGLE_API_KEY', getenv('GOOGLE_API_KEY') ?: 'YOUR_API_KEY'); // ============================================================================ // Application Configuration // ============================================================================ define('APP_NAME', 'DirectoryNation'); define('APP_VERSION', '1.0.0'); define('APP_URL', getenv('APP_URL') ?: 'https://yourdomain.com'); define('APP_TIMEZONE', 'UTC'); // Session configuration define('SESSION_TIMEOUT', 3600); // 1 hour define('SESSION_NAME', 'directorynation_session'); define('REMEMBER_ME_DURATION', 2592000); // 30 days // ============================================================================ // Security Configuration // ============================================================================ define('CSRF_TOKEN_LENGTH', 32); define('PASSWORD_MIN_LENGTH', 8); define('PASSWORD_HASH_ALGO', PASSWORD_BCRYPT); define('PASSWORD_HASH_OPTIONS', ['cost' => 12]); // API Configuration define('API_RATE_LIMIT', 100); // requests per minute define('API_RATE_LIMIT_WINDOW', 60); // seconds // CORS Configuration define('ALLOWED_ORIGINS', [ 'http://localhost:3000', 'http://localhost:8000', 'https://yourdomain.com', 'https://www.yourdomain.com' ]); // ============================================================================ // Email Configuration // ============================================================================ define('MAIL_HOST', getenv('MAIL_HOST') ?: 'smtp.gmail.com'); define('MAIL_PORT', getenv('MAIL_PORT') ?: 587); define('MAIL_USERNAME', getenv('MAIL_USERNAME') ?: 'your-email@gmail.com'); define('MAIL_PASSWORD', getenv('MAIL_PASSWORD') ?: 'your-app-password'); define('MAIL_FROM_ADDRESS', getenv('MAIL_FROM_ADDRESS') ?: 'noreply@directorynation.com'); define('MAIL_FROM_NAME', getenv('MAIL_FROM_NAME') ?: 'DirectoryNation'); // ============================================================================ // AWS Configuration (Optional) // ============================================================================ define('AWS_ACCESS_KEY', getenv('AWS_ACCESS_KEY') ?: ''); define('AWS_SECRET_KEY', getenv('AWS_SECRET_KEY') ?: ''); define('AWS_REGION', getenv('AWS_REGION') ?: 'us-east-1'); define('AWS_S3_BUCKET', getenv('AWS_S3_BUCKET') ?: 'directorynation-uploads'); // ============================================================================ // File Upload Configuration // ============================================================================ define('MAX_UPLOAD_SIZE', 5242880); // 5 MB define('ALLOWED_FILE_TYPES', ['jpg', 'jpeg', 'png', 'gif', 'pdf', 'doc', 'docx']); define('UPLOAD_DIR', __DIR__ . '/uploads/'); define('TEMP_DIR', sys_get_temp_dir()); // ============================================================================ // Pagination Configuration // ============================================================================ define('ITEMS_PER_PAGE', 20); define('MAX_ITEMS_PER_PAGE', 100); // ============================================================================ // Cache Configuration // ============================================================================ define('CACHE_ENABLED', true); define('CACHE_DRIVER', getenv('CACHE_DRIVER') ?: 'file'); // 'file', 'redis', 'memcached' define('CACHE_TTL', 3600); // 1 hour define('CACHE_DIR', __DIR__ . '/cache/'); // ============================================================================ // Logging Configuration // ============================================================================ define('LOG_DIR', __DIR__ . '/logs/'); define('LOG_LEVEL', getenv('LOG_LEVEL') ?: 'info'); // 'debug', 'info', 'warning', 'error' // ============================================================================ // Paths and URLs // ============================================================================ define('ROOT_PATH', __DIR__); define('PUBLIC_PATH', __DIR__ . '/public/'); define('STORAGE_PATH', __DIR__ . '/storage/'); define('RESOURCES_PATH', __DIR__ . '/resources/'); define('PUBLIC_URL', APP_URL . '/public/'); define('STORAGE_URL', APP_URL . '/storage/'); define('ASSETS_URL', APP_URL . '/assets/'); // ============================================================================ // Feature Flags // ============================================================================ define('FEATURE_GOOGLE_SIGNIN', true); define('FEATURE_EMAIL_VERIFICATION', true); define('FEATURE_TWO_FACTOR_AUTH', false); define('FEATURE_SOCIAL_SHARING', true); define('FEATURE_ANALYTICS', true); // ============================================================================ // Pricing Configuration // ============================================================================ define('PRICING_PLANS', [ 'basic' => [ 'name' => 'Basic', 'price' => 29, 'currency' => 'USD', 'billing_cycle' => 'monthly', 'features' => [ 'listings' => 5, 'team_members' => 1, 'analytics' => 'monthly', 'support' => 'email' ] ], 'pro' => [ 'name' => 'Pro', 'price' => 79, 'currency' => 'USD', 'billing_cycle' => 'monthly', 'features' => [ 'listings' => 25, 'team_members' => 5, 'analytics' => 'weekly', 'support' => 'priority' ] ], 'enterprise' => [ 'name' => 'Enterprise', 'price' => 0, // Custom pricing 'currency' => 'USD', 'billing_cycle' => 'custom', 'features' => [ 'listings' => 'unlimited', 'team_members' => 'unlimited', 'analytics' => 'realtime', 'support' => 'dedicated' ] ] ]); // ============================================================================ // Helper Functions // ============================================================================ /** * Get environment variable with default value * * @param string $key Environment variable key * @param mixed $default Default value if not found * @return mixed Environment variable value or default */ function env($key, $default = null) { $value = getenv($key); return $value !== false ? $value : $default; } /** * Check if application is in debug mode * * @return bool */ function is_debug() { return DEBUG_MODE; } /** * Check if application is in production * * @return bool */ function is_production() { return !DEBUG_MODE; } /** * Get application version * * @return string */ function app_version() { return APP_VERSION; } /** * Get application name * * @return string */ function app_name() { return APP_NAME; } /** * Get application URL * * @param string $path Optional path to append * @return string */ function app_url($path = '') { return APP_URL . ($path ? '/' . ltrim($path, '/') : ''); } /** * Get storage URL * * @param string $path Path to file * @return string */ function storage_url($path = '') { return STORAGE_URL . ltrim($path, '/'); } /** * Get asset URL * * @param string $path Path to asset * @return string */ function asset_url($path = '') { return ASSETS_URL . ltrim($path, '/'); } /** * Log a message * * @param string $message Message to log * @param string $level Log level (debug, info, warning, error) * @param array $context Additional context * @return void */ function log_message($message, $level = 'info', $context = []) { $timestamp = date('Y-m-d H:i:s'); $log_file = LOG_DIR . $level . '.log'; // Create log directory if it doesn't exist if (!is_dir(LOG_DIR)) { mkdir(LOG_DIR, 0755, true); } $context_str = !empty($context) ? ' | ' . json_encode($context) : ''; $log_entry = "[$timestamp] $message$context_str\n"; file_put_contents($log_file, $log_entry, FILE_APPEND); } /** * Get database connection * * @return PDO * @throws PDOException */ function get_db() { static $pdo = null; if ($pdo === null) { try { $dsn = "mysql:host=" . DB_HOST . ";port=" . DB_PORT . ";dbname=" . DB_NAME . ";charset=" . DB_CHARSET; $pdo = new PDO($dsn, DB_USER, DB_PASS, DB_OPTIONS); } catch (PDOException $e) { log_message('Database connection failed: ' . $e->getMessage(), 'error'); throw $e; } } return $pdo; } /** * Set timezone */ date_default_timezone_set(APP_TIMEZONE); // ============================================================================ // End of Configuration // ============================================================================ ?>