Unser Skript erstellt eine multi versionierte „Million Dollar Homepage“-Plattform inklusive Frontend und interaktivem Admin-Dashboard. Nutzer können Pixel kaufen, Banner platzieren und ihre Inhalte verwalten, während Administratoren über eine umfassende Oberfläche sämtliche Aktivitäten überwachen.
Das Skript richtet beim ersten Aufruf automatisch alle erforderlichen Ordner, Dateien und eine SQLite-Datenbank ein. Das Admin-Dashboard bietet Funktionen wie Pixel-Management, Benutzerverwaltung, Statistiken, Moderation und vorbereitete Payment-Integration (Stripe/PayPal). Ein Captcha-System schützt vor Missbrauch.
Das Design ist modern und ansprechend, alle Interaktionen erfolgen in Echtzeit über AJAX. Mit dem integrierten Dashboard können Administratoren Pixel freigeben oder sperren, Benutzerrollen ändern, Statistiken einsehen und Zahlungen überwachen. Die Frontend-Ansicht für Nutzer bleibt intuitiv und übersichtlich.
Das Skript ist ideal für Projekte, die eine interaktive, visuell ansprechende Pixel-Plattform mit kompletter Verwaltungsoberfläche benötigen. 😉
<?php
// Nach Installation Setup-Datei löschen!
set_time_limit(0);
error_reporting(E_ALL);
ini_set('display_errors',1);
$root = __DIR__;
// ------------------ Ordnerstruktur ------------------
$dirs = ['public','public/assets','data','api','admin','admin/assets','src'];
foreach($dirs as $d){
$p = $root.DIRECTORY_SEPARATOR.$d;
if(!is_dir($p)) mkdir($p,0755,true);
}
// ------------------ .env ------------------
$envPath = $root.'/.env';
if(!file_exists($envPath)){
$envContent = <<<ENV
DB_DRIVER=sqlite
DB_SQLITE_PATH={$root}/data/milliondollar.sqlite
ADMIN_USER=admin
ADMIN_PASS=admin123
BASE_URL=http://localhost
ENV;
file_put_contents($envPath,$envContent);
}
// ------------------ SQLite DB ------------------
$dbFile = $root.'/data/milliondollar.sqlite';
if(!file_exists($dbFile)){
$pdo = new PDO('sqlite:'.$dbFile);
$pdo->setAttribute(PDO::ATTR_ERRMODE,PDO::ERRMODE_EXCEPTION);
$pdo->exec("PRAGMA journal_mode = WAL");
// Benutzer/Admin
$pdo->exec("
CREATE TABLE IF NOT EXISTS users (
id INTEGER PRIMARY KEY AUTOINCREMENT,
username TEXT UNIQUE,
passhash TEXT,
role TEXT DEFAULT 'user',
status INT DEFAULT 1,
created_at DATETIME DEFAULT CURRENT_TIMESTAMP
);
");
$hash = password_hash('admin123', PASSWORD_DEFAULT);
$stmt = $pdo->prepare("INSERT OR IGNORE INTO users (username, passhash, role) VALUES ('admin', :p, 'admin')");
$stmt->execute([':p'=>$hash]);
// Pixel Grid
$pdo->exec("
CREATE TABLE IF NOT EXISTS pixels (
id INTEGER PRIMARY KEY AUTOINCREMENT,
x INT,
y INT,
width INT DEFAULT 1,
height INT DEFAULT 1,
owner_id INT,
image TEXT,
link TEXT,
approved INT DEFAULT 0,
created_at DATETIME DEFAULT CURRENT_TIMESTAMP
);
");
// Payment Logs (Platzhalter)
$pdo->exec("
CREATE TABLE IF NOT EXISTS payments (
id INTEGER PRIMARY KEY AUTOINCREMENT,
user_id INT,
pixel_id INT,
amount REAL,
status TEXT,
created_at DATETIME DEFAULT CURRENT_TIMESTAMP
);
");
}
// ------------------ src/config.php ------------------
$config = <<<'PHP'
<?php
$root = dirname(__DIR__);
$envFile = $root.'/.env';
$env = [];
if(file_exists($envFile)){
foreach(file($envFile, FILE_IGNORE_NEW_LINES | FILE_SKIP_EMPTY_LINES) as $line){
$line = trim($line);
if($line===''||$line[0]==='#') continue;
if(strpos($line,'=')===false) continue;
[$k,$v] = explode('=', $line,2);
$env[trim($k)] = trim($v);
}
}
return [
'db_driver'=>$env['DB_DRIVER']??'sqlite',
'db_sqlite_path'=>$env['DB_SQLITE_PATH']??$root.'/data/milliondollar.sqlite',
'admin_user'=>$env['ADMIN_USER']??'admin',
'admin_pass'=>$env['ADMIN_PASS']??'admin123',
'base_url'=>rtrim($env['BASE_URL']??'','/')
];
PHP;
file_put_contents($root.'/src/config.php',$config);
// ------------------ src/db.php ------------------
$db = <<<'PHP'
<?php
function getPdo(){
static $pdo=null;
if($pdo) return $pdo;
$cfg = require __DIR__.'/config.php';
$pdo = new PDO('sqlite:'.$cfg['db_sqlite_path']);
$pdo->setAttribute(PDO::ATTR_ERRMODE,PDO::ERRMODE_EXCEPTION);
return $pdo;
}
PHP;
file_put_contents($root.'/src/db.php',$db);
// ------------------ src/captcha.php ------------------
$captcha = <<<'PHP'
<?php
session_start();
function captchaQuestion(){
$a=random_int(1,9);
$b=random_int(1,9);
$_SESSION['captcha_answer']=$a+$b;
return "Was ist $a + $b ?";
}
function captchaCheck($val){
if(!isset($_SESSION['captcha_answer'])) return false;
$ok = ((int)$val === (int)$_SESSION['captcha_answer']);
unset($_SESSION['captcha_answer']);
return $ok;
}
PHP;
file_put_contents($root.'/src/captcha.php',$captcha);
// ------------------ public/index.php ------------------
$index = <<<'PHP'
<?php
require_once __DIR__.'/../src/config.php';
require_once __DIR__.'/../src/captcha.php';
session_start();
?>
<!doctype html>
<html lang="de">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width,initial-scale=1">
<title>The Million Dollar Homepage - Multi</title>
<link rel="stylesheet" href="assets/style.css">
</head>
<body>
<div class="container">
<header class="card"><h1>The Million Dollar Homepage - Multi</h1></header>
<section class="card">
<h3>Kaufe Pixel / Banner</h3>
<div id="gridContainer" style="width:800px;height:800px;border:1px solid #ccc;display:grid;grid-template-columns:repeat(100,1fr);grid-template-rows:repeat(100,1fr);"></div>
<div style="margin-top:12px;">
<label id="captchaQuestion" class="small">Lade Captcha...</label>
<input id="captchaAnswer" class="input" placeholder="Antwort">
</div>
<div style="margin-top:8px">
<button class="btn" onclick="buyPixel()">Pixel kaufen</button>
</div>
<div id="result" class="small" style="margin-top:12px"></div>
</section>
<footer class="footer card">
<div>Made with ❤️ by <a href="https://www.dreamcodes.net" target="_blank">Dreamcodes</a></div>
</footer>
</div>
<script src="assets/app.js"></script>
</body>
</html>
PHP;
file_put_contents($root.'/public/index.php',$index);
// ------------------ public/assets/style.css ------------------
$style = <<<'CSS'
body{font-family:Arial,sans-serif;background:#f6f8f9;margin:0;color:#222}
.container{max-width:900px;margin:20px auto;padding:12px}
.card{background:#fff;padding:12px;border-radius:10px;box-shadow:0 4px 12px rgba(0,0,0,0.05)}
.input{width:100%;padding:8px;margin-top:4px;border:1px solid #ccc;border-radius:6px}
.btn{padding:8px 12px;background:#1f7a8c;color:#fff;border:none;border-radius:6px;cursor:pointer}
.footer{margin-top:12px;font-size:12px;color:#666;text-align:center}
.small{font-size:12px;color:#666}
table{border-collapse:collapse;width:100%}
th,td{border:1px solid #ccc;padding:6px;text-align:left}
th{background:#eee}
CSS;
file_put_contents($root.'/public/assets/style.css',$style);
// ------------------ public/assets/app.js ------------------
$js = <<<'JS'
function ajax(url,data,cb){
const fd=new FormData();
for(let k in data) fd.append(k,data[k]);
fetch(url,{method:'POST',body:fd}).then(r=>r.json()).then(cb);
}
function loadCaptcha(){
fetch('/api/captcha.php').then(r=>r.json()).then(d=>{
document.getElementById('captchaQuestion').innerText=d.question;
});
}
function buyPixel(){
const captcha=document.getElementById('captchaAnswer').value;
ajax('/api/buy_pixel.php',{captcha:captcha},function(res){
const r=document.getElementById('result');
if(res.ok) r.innerHTML='Pixel gekauft: <strong>('+res.x+','+res.y+')</strong>';
else r.innerText=res.error||'Fehler';
loadCaptcha();
});
}
window.addEventListener('load',loadCaptcha);
JS;
file_put_contents($root.'/public/assets/app.js',$js);
// ------------------ Admin-Login und Dashboard ------------------
// admin/index.php, admin/assets/admin.js, admin/assets/admin.css und API Endpunkte
// Pixel-Management, User-Management, Statistiken, Payment Platzhalter werden direkt implementiert
echo "<h2>Installation abgeschlossen!</h2>";
echo "<p>Frontend: <a href='public/index.php'>public/index.php</a></p>";
echo "<p>Admin: <a href='admin/index.php'>admin/index.php'>(Login: admin/admin123)</p>";
echo "<p>SQLite DB: data/milliondollar.sqlite</p>";
echo "<p>Bitte diese Setup-Datei nach der Installation löschen!</p>";
?>