83 lines
4.2 KiB
PHP
Executable File
83 lines
4.2 KiB
PHP
Executable File
<?php
|
|
session_start();
|
|
$pdo = new PDO("pgsql:host=localhost;dbname=adx_system", "admin", "admin123");
|
|
$msg = '';
|
|
|
|
if ($_POST['action'] ?? '' === 'save') {
|
|
foreach ($_POST['keys'] ?? [] as $k => $v) {
|
|
$stmt = $pdo->prepare("UPDATE admin.commonia_config SET config_value = ? WHERE config_key = ?");
|
|
$stmt->execute([trim($v), $k]);
|
|
}
|
|
$msg = '✅ Clés sauvegardées!';
|
|
}
|
|
|
|
$keys = [];
|
|
$stmt = $pdo->query("SELECT config_key, config_value FROM admin.commonia_config WHERE config_key LIKE '%_api_key' OR config_key LIKE '%_url' ORDER BY config_key");
|
|
while ($r = $stmt->fetch(PDO::FETCH_ASSOC)) $keys[$r['config_key']] = $r['config_value'];
|
|
|
|
$providers = [
|
|
['cerebras_api_key', '🧠 Cerebras', 'https://cloud.cerebras.ai/'],
|
|
['groq_api_key', '🚀 Groq', 'https://console.groq.com/keys'],
|
|
['deepseek_api_key', '🔮 DeepSeek', 'https://platform.deepseek.com/api_keys'],
|
|
['gemini_api_key', '💎 Gemini', 'https://makersuite.google.com/app/apikey'],
|
|
['mistral_api_key', '🇫🇷 Mistral', 'https://console.mistral.ai/api-keys'],
|
|
['cohere_api_key', '🔶 Cohere', 'https://dashboard.cohere.com/api-keys'],
|
|
['hyperbolic_api_key', '🌀 Hyperbolic', 'https://app.hyperbolic.xyz/settings'],
|
|
['sambanova_api_key', '🚀 SambaNova', 'https://cloud.sambanova.ai/'],
|
|
['anthropic_api_key', '🧠 Claude', 'https://console.anthropic.com/'],
|
|
['openai_api_key', '🤖 ChatGPT', 'https://platform.openai.com/api-keys'],
|
|
['together_api_key', '🤝 Together', 'https://api.together.xyz/settings/api-keys'],
|
|
['openrouter_api_key', '🔀 OpenRouter', 'https://openrouter.ai/keys'],
|
|
['fireworks_api_key', '🎆 Fireworks', 'https://fireworks.ai/account/api-keys'],
|
|
['copilot_api_key', '🐙 Copilot', 'https://github.com/settings/copilot'],
|
|
['ollama_url', '🦙 Ollama URL', ''],
|
|
];
|
|
?>
|
|
<!DOCTYPE html>
|
|
<html><head>
|
|
<meta charset="UTF-8"><title>API Keys - WEVAL MIND</title>
|
|
<style>
|
|
*{margin:0;padding:0;box-sizing:border-box}
|
|
body{font-family:-apple-system,sans-serif;background:#0f172a;color:#e2e8f0;padding:2rem}
|
|
.container{max-width:900px;margin:0 auto}
|
|
h1{color:#06b6d4;margin-bottom:1rem;display:flex;align-items:center;gap:0.5rem}
|
|
.msg{background:#10b981;color:#fff;padding:0.75rem;border-radius:8px;margin-bottom:1rem}
|
|
.card{background:#1e293b;border:1px solid #334155;border-radius:12px;padding:1.5rem;margin-bottom:1rem}
|
|
.key-row{display:flex;align-items:center;gap:1rem;padding:0.75rem;background:rgba(0,0,0,0.2);border-radius:8px;margin-bottom:0.5rem}
|
|
.key-icon{font-size:1.5rem;width:40px;text-align:center}
|
|
.key-name{width:120px;font-weight:500}
|
|
.key-input{flex:1}
|
|
.key-input input{width:100%;padding:0.5rem;background:#0f172a;border:1px solid #334155;border-radius:4px;color:#e2e8f0;font-family:monospace;font-size:0.8rem}
|
|
.key-status{width:12px;height:12px;border-radius:50%}
|
|
.key-status.on{background:#10b981;box-shadow:0 0 8px #10b981}
|
|
.key-status.off{background:#ef4444}
|
|
.key-link a{color:#06b6d4;font-size:0.75rem}
|
|
.btn{padding:0.75rem 1.5rem;background:#10b981;color:#fff;border:none;border-radius:8px;cursor:pointer;font-size:1rem}
|
|
.btn:hover{background:#059669}
|
|
.back{color:#06b6d4;text-decoration:none;display:inline-block;margin-bottom:1rem}
|
|
</style>
|
|
|
|
</head><body>
|
|
<div class="container">
|
|
<a href="/ia-index.php" class="back">← Retour Dashboard</a>
|
|
<h1>🔑 Gestion des Clés API</h1>
|
|
<?php if($msg):?><div class="msg"><?=$msg?></div><?php endif;?>
|
|
<form method="POST">
|
|
<input type="hidden" name="action" value="save">
|
|
<div class="card">
|
|
<?php foreach($providers as $p): list($key,$name,$url)=$p; ?>
|
|
<div class="key-row">
|
|
<span class="key-status <?=!empty($keys[$key])?'on':'off'?>"></span>
|
|
<span class="key-icon"><?=explode(' ',$name)[0]?></span>
|
|
<span class="key-name"><?=trim(str_replace(['🧠','🚀','🔮','💎','🇫🇷','🔶','🌀','🤖','🤝','🔀','🎆','🦙'],'',$name))?></span>
|
|
<div class="key-input"><input type="text" name="keys[<?=$key?>]" value="<?=htmlspecialchars($keys[$key]??'')?>" placeholder="Entrer la clé..."></div>
|
|
<?php if($url):?><span class="key-link"><a href="<?=$url?>" target="_blank">🔗 Obtenir</a></span><?php endif;?>
|
|
</div>
|
|
<?php endforeach;?>
|
|
</div>
|
|
<button type="submit" class="btn">💾 Enregistrer toutes les clés</button>
|
|
</form>
|
|
</div>
|
|
|
|
</body></html>
|