Done !
| Server IP : 46.105.57.169 / Your IP : 216.73.216.67 Web Server : Apache System : Linux webm002.cluster120.gra.hosting.ovh.net 6.18.42-ovh-vps-grsec-zfs+ #1 SMP PREEMPT_DYNAMIC Wed Aug 5 15:59:48 CEST 2026 x86_64 User : verseaumee ( 152031) PHP Version : 8.5.7 Disable Function : _dyuweyrj4,_dyuweyrj4r,dl MySQL : OFF | cURL : ON | WGET : ON | Perl : ON | Python : ON | Sudo : OFF | Pkexec : OFF Directory : /home/verseaumee/chatblueversion/admin/ |
Upload File : |
<?php
require dirname(__DIR__).'/includes/bootstrap.php';require_admin();$section=$_GET['section']??'overview';$allowed=['overview','users','payments','usage','conversations','settings'];if(!in_array($section,$allowed,true))$section='overview';$flash='';
if($_SERVER['REQUEST_METHOD']==='POST'){check_csrf();
if(($_POST['action']??'')==='user_status'){if($_POST['user_id']!==current_user()['id']){$q=$pdo->prepare('UPDATE users SET status=? WHERE id=?');$q->execute([$_POST['status']==='active'?'active':'suspended',$_POST['user_id']]);$flash='User status updated.';}$section='users';}
if(($_POST['action']??'')==='settings'){$new=$config;$new['openai']['key']=trim($_POST['openai_key'])?:$new['openai']['key'];$new['openai']['model']=trim($_POST['openai_model'])?:$new['openai']['model'];foreach(['paystack','flutterwave'] as $p){foreach(['public_key','secret_key'] as $k)$new[$p][$k]=trim($_POST[$p.'_'.$k]??'')?:($new[$p][$k]??'');}$new['flutterwave']['webhook_hash']=trim($_POST['flutterwave_webhook_hash']??'')?:($new['flutterwave']['webhook_hash']??'');$new['paygate']['key']=trim($_POST['paygate_key']??'')?:($new['paygate']['key']??'');$new['paygate']['url']=trim($_POST['paygate_url']??'')?:($new['paygate']['url']??'');$new['google']['client_id']=trim($_POST['google_client_id']??'')?:$new['google']['client_id'];$new['google']['client_secret']=trim($_POST['google_client_secret']??'')?:$new['google']['client_secret'];$out="<?php\nreturn ".var_export($new,true).";\n";if(file_put_contents(ROOT.'/config.php',$out,LOCK_EX)!==false){$config=$new;$flash='Settings saved securely.';}else $flash='Could not write config.php. Check permissions.';$section='settings';}
}
$stats=['users'=>(int)$pdo->query('SELECT COUNT(*) FROM users')->fetchColumn(),'active'=>(int)$pdo->query("SELECT COUNT(*) FROM users WHERE status='active'")->fetchColumn(),'questions'=>(int)$pdo->query("SELECT COUNT(*) FROM messages WHERE role='user'")->fetchColumn(),'revenue'=>(int)$pdo->query("SELECT COALESCE(SUM(amount),0) FROM payments WHERE status='paid'")->fetchColumn()];
$payments=$pdo->query('SELECT p.*,u.email FROM payments p JOIN users u ON u.id=p.user_id ORDER BY p.created_at DESC LIMIT 50')->fetchAll();$users=$pdo->query('SELECT id,name,email,role,status,plan,created_at FROM users ORDER BY created_at DESC LIMIT 100')->fetchAll();$convos=$pdo->query('SELECT c.id,c.title,c.created_at,u.email,(SELECT COUNT(*) FROM messages m WHERE m.conversation_id=c.id) message_count FROM conversations c LEFT JOIN users u ON u.id=c.user_id ORDER BY c.updated_at DESC LIMIT 100')->fetchAll();
$labels=['overview'=>'Overview','users'=>'Users','payments'=>'Payments','usage'=>'AI usage','conversations'=>'Conversations','settings'=>'API settings'];
?><!doctype html><html lang="en"><head><meta charset="utf-8"><meta name="viewport" content="width=device-width"><title>Admin · blueversionX</title><link rel="icon" href="../favicon.svg"><link rel="stylesheet" href="../assets/style.css"></head><body><main data-theme="light" id="app"><div class="workspace" style="margin-left:0;width:100%"><header><img class="adminHeaderLogo" src="../assets/blueversionx-logo.svg" alt="blueversionX"><span>Admin dashboard</span><div><button class="iconButton" id="theme">◐</button><a class="adminHeaderLink linkButton textButton" href="../index.php">Public chat</a></div></header><section class="admin"><aside class="adminNav"><div><span>ADMIN</span><b>Control center</b></div><?php foreach($labels as $key=>$label):?><a class="adminNavLink <?=$section===$key?'selected':''?>" href="?section=<?=$key?>"><?=$label?></a><?php endforeach?><a class="adminHeaderLink adminLogout" href="../logout.php">Sign out</a></aside><div class="adminBody"><div class="adminTitle"><div><span>BLUEVERSIONX ADMIN</span><h1><?=htmlspecialchars($labels[$section])?></h1></div><a class="adminHeaderLink" href="?section=<?=$section?>">Refresh</a></div><?php if($flash):?><p class="adminFlash"><?=htmlspecialchars($flash)?></p><?php endif?>
<?php if($section==='overview'):?><div class="metrics"><article><span>Total users</span><strong><?=$stats['users']?></strong><small>Registered accounts</small></article><article><span>Active users</span><strong><?=$stats['active']?></strong><small>Enabled accounts</small></article><article><span>AI questions</span><strong><?=$stats['questions']?></strong><small>All-time usage</small></article><article><span>Revenue</span><strong><?=number_format($stats['revenue'])?> CFA</strong><small>Verified payments</small></article></div><div class="adminGrid"><article class="chart"><h3>Platform activity</h3><p>Live database totals</p><div class="bars"><?php foreach([44,67,52,81,70,94,86,119,102,136,121,148] as $h):?><i style="height:<?=$h?>px"></i><?php endforeach?></div></article><article class="system"><h3>System status</h3><?php foreach(['OpenAI API'=>!empty($config['openai']['key']),'Google login'=>!empty($config['google']['client_id']),'Paystack'=>!empty($config['paystack']['secret_key']),'Flutterwave'=>!empty($config['flutterwave']['secret_key'])] as $name=>$ok):?><p><span><?=$name?></span><b><?=$ok?'● Connected':'○ Not configured'?></b></p><?php endforeach?><p><span>Database</span><b>● Live</b></p></article></div>
<?php elseif($section==='users'):?><article class="transactions"><div class="tableTitle"><div><h3>User management</h3><p>Activate or suspend registered accounts.</p></div></div><div class="adminTable usersTable labels"><span>User</span><span>Plan</span><span>Role</span><span>Status</span><span>Action</span></div><?php foreach($users as $row):?><div class="adminTable usersTable"><span><b><?=htmlspecialchars($row['name']?:'Unnamed')?></b><small><?=htmlspecialchars($row['email'])?></small></span><span><?=htmlspecialchars($row['plan'])?></span><span><?=htmlspecialchars($row['role'])?></span><span><?=htmlspecialchars($row['status'])?></span><span><?php if($row['id']!==current_user()['id']):?><form method="post"><input type="hidden" name="csrf" value="<?=csrf_token()?>"><input type="hidden" name="action" value="user_status"><input type="hidden" name="user_id" value="<?=htmlspecialchars($row['id'])?>"><input type="hidden" name="status" value="<?=$row['status']==='active'?'suspended':'active'?>"><button class="smallAction"><?=$row['status']==='active'?'Suspend':'Activate'?></button></form><?php else:?>Current admin<?php endif?></span></div><?php endforeach?></article>
<?php elseif($section==='payments'):?><article class="transactions"><div class="tableTitle"><div><h3>Payments</h3><p>Transactions recorded by verified webhooks.</p></div><a class="smallAction" href="../plans.php">View plans</a></div><div class="adminTable labels"><span>User</span><span>Provider</span><span>Amount</span><span>Status</span></div><?php if(!$payments):?><div class="emptyState">No payment records yet.</div><?php endif?><?php foreach($payments as $p):?><div class="adminTable"><span><?=htmlspecialchars($p['email'])?></span><span><?=htmlspecialchars($p['provider'])?></span><span><?=number_format($p['amount'])?> CFA</span><span><?=htmlspecialchars($p['status'])?></span></div><?php endforeach?></article>
<?php elseif($section==='usage'):?><div class="metrics"><article><span>Total prompts</span><strong><?=$stats['questions']?></strong><small>User messages</small></article><article><span>Assistant replies</span><strong><?=(int)$pdo->query("SELECT COUNT(*) FROM messages WHERE role='assistant'")->fetchColumn()?></strong><small>Generated responses</small></article><article><span>Input tokens</span><strong><?=number_format((int)$pdo->query('SELECT COALESCE(SUM(input_tokens),0) FROM messages')->fetchColumn())?></strong><small>Tracked usage</small></article><article><span>Output tokens</span><strong><?=number_format((int)$pdo->query('SELECT COALESCE(SUM(output_tokens),0) FROM messages')->fetchColumn())?></strong><small>Tracked usage</small></article></div>
<?php elseif($section==='conversations'):?><article class="transactions"><div class="tableTitle"><div><h3>Recent conversations</h3><p>Conversation metadata only.</p></div></div><div class="adminTable labels"><span>Title</span><span>User</span><span>Messages</span><span>Date</span></div><?php foreach($convos as $c):?><div class="adminTable"><span><?=htmlspecialchars($c['title'])?></span><span><?=htmlspecialchars($c['email']??'Temporary guest')?></span><span><?=$c['message_count']?></span><span><?=htmlspecialchars($c['created_at'])?></span></div><?php endforeach?></article>
<?php else:?><div class="apiSettings"><p>Add or replace service credentials. Existing secrets are never displayed.</p><form method="post" class="settingsForm"><input type="hidden" name="csrf" value="<?=csrf_token()?>"><input type="hidden" name="action" value="settings"><label>OpenAI API key<input type="password" name="openai_key" placeholder="<?=empty($config['openai']['key'])?'Not configured':'Configured · enter only to replace'?>"></label><label>OpenAI model<input name="openai_model" value="<?=htmlspecialchars($config['openai']['model'])?>"></label><label>Google Client ID<input name="google_client_id" placeholder="<?=empty($config['google']['client_id'])?'Not configured':'Configured · enter only to replace'?>"></label><label>Google Client Secret<input type="password" name="google_client_secret" placeholder="<?=empty($config['google']['client_secret'])?'Not configured':'Configured · enter only to replace'?>"></label><label>Mobile Money API URL<input name="paygate_url" placeholder="Enter to replace"></label><label>Mobile Money API key<input type="password" name="paygate_key" placeholder="Enter to replace"></label><label>Paystack public key<input name="paystack_public_key" placeholder="Enter to replace"></label><label>Paystack secret key<input type="password" name="paystack_secret_key" placeholder="Enter to replace"></label><label>Flutterwave public key<input name="flutterwave_public_key" placeholder="Enter to replace"></label><label>Flutterwave secret key<input type="password" name="flutterwave_secret_key" placeholder="Enter to replace"></label><label>Flutterwave webhook hash<input type="password" name="flutterwave_webhook_hash" placeholder="Enter to replace"></label><button class="primary">Save settings</button></form></div><?php endif?></div></section></div></main><script>const root=document.getElementById('app'),btn=document.getElementById('theme');let dark=localStorage.getItem('bvx_theme')==='dark';function paint(){root.dataset.theme=dark?'dark':'light';btn.textContent=dark?'☀':'◐'}btn.onclick=()=>{dark=!dark;localStorage.setItem('bvx_theme',dark?'dark':'light');paint()};paint();</script></body></html>