« Back to History
post_image_rules_manage.php
|
20260921_175631.php
Initial Domain Snapshot
Copy Code
<?php error_reporting(E_ALL); ini_set('display_errors', 1); require_once __DIR__ . '/../config.php'; $pdo = db_connect(); $msg = ''; /* ---------- SAVE RULE ---------- */ if ($_SERVER['REQUEST_METHOD'] === 'POST') { $post_id = (int)($_POST['post_id'] ?? 0); $interval = (int)($_POST['image_interval'] ?? 0); $mode = ($_POST['image_mode'] === 'sequential') ? 'sequential' : 'random'; $reuse = isset($_POST['image_reuse']) ? 1 : 0; $folder = trim($_POST['folder_name'] ?? ''); if ($post_id > 0) { $pdo->prepare(" INSERT INTO post_image_rules (post_id, image_interval, image_mode, image_reuse, folder_name) VALUES (?,?,?,?,?) ON DUPLICATE KEY UPDATE image_interval=VALUES(image_interval), image_mode=VALUES(image_mode), image_reuse=VALUES(image_reuse), folder_name=VALUES(folder_name) ")->execute([$post_id,$interval,$mode,$reuse,$folder]); $msg = '✅ Image rule saved'; } } /* ---------- DATA ---------- */ $posts = $pdo->query(" SELECT id,title FROM posts ORDER BY created_at DESC ")->fetchAll(PDO::FETCH_ASSOC); $rules = []; foreach ($pdo->query("SELECT * FROM post_image_rules") as $r) { $rules[$r['post_id']] = $r; } ?> <!doctype html> <html> <head> <meta charset="utf-8"> <title>Post Image Rules</title> <style> body{font-family:system-ui;background:#f4f6f8} .wrap{max-width:1100px;margin:30px auto;background:#fff;border:1px solid #ddd;padding:20px} table{width:100%;border-collapse:collapse} th,td{border-bottom:1px solid #eee;padding:8px;text-align:left} input,select{padding:6px;width:100%} button{padding:6px 14px} .small{font-size:12px;color:#666} </style> </head> <body> <div class="wrap"> <h2>Post → Image Display Rules</h2> <?php if($msg): ?><p><?=htmlspecialchars($msg)?></p><?php endif; ?> <form method="post"> <table> <tr> <th>Post</th> <th>After how many shayari</th> <th>Mode</th> <th>Reuse</th> <th>Folder name</th> <th>Save</th> </tr> <tr> <td> <select name="post_id" required> <option value="">Select Post</option> <?php foreach($posts as $p): ?> <option value="<?=$p['id']?>"><?=htmlspecialchars($p['title'])?></option> <?php endforeach; ?> </select> </td> <td><input type="number" name="image_interval" min="0" placeholder="0 = off"></td> <td> <select name="image_mode"> <option value="random">Random</option> <option value="sequential">Sequential</option> </select> </td> <td style="text-align:center"> <input type="checkbox" name="image_reuse"> allow </td> <td><input name="folder_name" placeholder="uploads folder"></td> <td><button type="submit">Save</button></td> </tr> </table> </form> <hr> <h3>Existing Rules</h3> <table> <tr> <th>Post ID</th><th>Interval</th><th>Mode</th><th>Reuse</th><th>Folder</th> </tr> <?php foreach($rules as $pid=>$r): ?> <tr> <td><?=$pid?></td> <td><?=$r['image_interval']?></td> <td><?=$r['image_mode']?></td> <td><?=$r['image_reuse']?'Yes':'No'?></td> <td><?=htmlspecialchars($r['folder_name'])?></td> </tr> <?php endforeach; ?> </table> <p class="small"> Images path: <b>/public_html/uploads/{folder_name}/</b> </p> </div> </body> </html>