Creata pagina con "<?php // ApprovazioneUtentiLinkedIn.php $richieste_file = __DIR__ . '/linkedin_requests.json'; $approvati_file = __DIR__ . '/approved_users.json'; function leggi_json($file) { return file_exists($file) ? json_decode(file_get_contents($file), true) : []; } function salva_json($file, $dati) { file_put_contents($file, json_encode($dati, JSON_PRETTY_PRINT)); } $richieste = leggi_json($richieste_file); $approvati = leggi_json($approvati_file); if ($_SERVER['REQUE..."
 
Nessun oggetto della modifica
 
(6 versioni intermedie di uno stesso utente non sono mostrate)
Riga 1: Riga 1:
<?php
// ApprovazioneUtentiLinkedIn.php
$richieste_file = __DIR__ . '/linkedin_requests.json';
$approvati_file = __DIR__ . '/approved_users.json';
function leggi_json($file) {
    return file_exists($file) ? json_decode(file_get_contents($file), true) : [];
}
function salva_json($file, $dati) {
    file_put_contents($file, json_encode($dati, JSON_PRETTY_PRINT));
}
$richieste = leggi_json($richieste_file);
$approvati = leggi_json($approvati_file);
if ($_SERVER['REQUEST_METHOD'] === 'POST') {
    $email = $_POST['email'];
    $azione = $_POST['azione'];
    foreach ($richieste as $i => $utente) {
        if ($utente['email'] === $email) {
            if ($azione === 'approva') {
                $utente['data_approvazione'] = date('Y-m-d');
                $approvati[] = $utente;
                salva_json($approvati_file, $approvati);
            }
            unset($richieste[$i]);
            salva_json($richieste_file, array_values($richieste));
            header('Location: ApprovazioneUtentiLinkedIn.php?esito=ok');
            exit;
        }
    }
}
?><!DOCTYPE html>
<html>
<html>
<head>
<div style="text-align: center; padding: 2rem;">
    <meta charset="UTF-8">
  <a href="https://staging.masticationpedia.org/ApprovazioneUtentiLinkedIn.php"
    <title>Approvazione Utenti LinkedIn</title>
    target="_blank"
    <style>
    style="display: inline-block; background-color: #0077b5; color: white;
        body { font-family: Arial; margin: 2rem; background: #f7f9fb; }
            padding: 0.75rem 1.5rem; border-radius: 8px; text-decoration: none;
        .card { background: white; border-radius: 8px; padding: 1.5rem; margin-bottom: 1rem; box-shadow: 0 2px 5px rgba(0,0,0,0.1); display: flex; align-items: center; }
            font-size: 1.2rem; font-weight: 500;">
        .card img { border-radius: 50%; width: 64px; height: 64px; margin-right: 1rem; }
     ✅ Gestisci richieste LinkedIn
        .card .info { flex: 1; }
  </a>
        .buttons button { margin-right: 0.5rem; padding: 0.5rem 1rem; border: none; border-radius: 4px; cursor: pointer; }
</div>
        .approva { background-color: #28a745; color: white; }
        .rifiuta { background-color: #dc3545; color: white; }
        .profilo { background-color: #0077b5; color: white; }
        h2 { color: #116089; }
    </style>
</head>
<body>
 
<h2>Richieste di accesso tramite LinkedIn</h2>
 
<?php if (isset($_GET['esito']) && $_GET['esito'] === 'ok'): ?>
     <p style="color: green;">Operazione eseguita con successo.</p>
<?php endif; ?>
 
<?php if (empty($richieste)): ?>
    <p>Nessuna richiesta in sospeso.</p>
<?php else: ?>
    <?php foreach ($richieste as $utente): ?>
        <div class="card">
            <img src="<?= htmlspecialchars($utente['foto'] ?? 'https://via.placeholder.com/64') ?>" alt="Foto profilo">
            <div class="info">
                <strong><?= htmlspecialchars($utente['nome']) ?></strong><br>
                <?= htmlspecialchars($utente['email']) ?>
            </div>
            <form method="post" class="buttons">
                <input type="hidden" name="email" value="<?= htmlspecialchars($utente['email']) ?>">
                <button type="submit" name="azione" value="approva" class="approva">✅ Approva</button>
                <button type="submit" name="azione" value="rifiuta" class="rifiuta">❌ Rifiuta</button>
                <a href="https://www.linkedin.com/in/<?= htmlspecialchars($utente['linkedin_id']) ?>" target="_blank">
                    <button type="button" class="profilo">🔗 Profilo</button>
                </a>
            </form>
        </div>
    <?php endforeach; ?>
<?php endif; ?>
 
</body>
</html>
</html>

Versione attuale delle 18:58, 17 giu 2025