* templates/posts_list.tpl * extends file="master.tpl" block name="content" <div class="container-fluid"> <h1>$Page->Title</h1>
// config.php ini_set('display_errors', 1); error_reporting(E_ALL); Solution: Check permissions and paths
* Generated grid * $Grid->Render() </div> /block Modify page controller files:
CREATE TABLE posts ( id INT PRIMARY KEY AUTO_INCREMENT, category_id INT, title VARCHAR(255) NOT NULL, content TEXT, author VARCHAR(100), status ENUM('draft', 'published') DEFAULT 'draft', publish_date DATE, views INT DEFAULT 0, created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP, FOREIGN KEY (category_id) REFERENCES categories(id) ON DELETE SET NULL ); phprad classic
<!-- Custom HTML/PHP here --> <h2>Monthly Sales</h2> <?php // Your custom query $result = $DB->Execute("SELECT MONTH(publish_date) as month, COUNT(*) as count FROM posts GROUP BY MONTH(publish_date)"); ?>
1. Modify .htaccess for Security # Deny access to sensitive directories RedirectMatch 403 ^/blog-admin/(classes|templates_c|includes)/.*$ Prevent directory listing Options -Indexes Protect config file <Files config.php> Order allow,deny Deny from all </Files> 2. Enable HTTPS Redirection // common.php - force HTTPS if (!isset($_SERVER['HTTPS']) || $_SERVER['HTTPS'] !== 'on') header("Location: https://" . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI']); exit();
1. Prepare Production Environment # Create production database mysql -u root -p CREATE DATABASE blog_production; GRANT ALL ON blog_production.* TO 'app_user'@'localhost' IDENTIFIED BY 'strong_password'; Export development database mysqldump -u dev_user -p blog_development > database.sql Import to production mysql -u app_user -p blog_production < database.sql 2. Update Configuration // config.php - Production settings $config['db_host'] = 'localhost'; $config['db_user'] = 'app_user'; $config['db_password'] = 'strong_password'; $config['db_name'] = 'blog_production'; $config['debug_mode'] = false; $config['error_reporting'] = E_ALL & ~E_NOTICE & ~E_WARNING; 3. Secure File Permissions # Set proper ownership chown -R www-data:www-data /var/www/blog-admin/ chmod -R 755 /var/www/blog-admin/ chmod -R 770 /var/www/blog-admin/templates_c/ chmod -R 770 /var/www/blog-admin/uploads/ chmod 640 /var/www/blog-admin/config.php 4. Enable Production Cache // config.php $config['smarty_caching'] = true; $config['smarty_cache_lifetime'] = 86400; // 24 hours Troubleshooting Common Issues Problem: White screen after generation Solution: Enable error reporting * templates/posts_list
// cron/daily_report.php <?php require_once("../config.php"); // Generate and email daily summary $sql = "SELECT COUNT(*) as total FROM posts WHERE DATE(created_at) = CURDATE()"; $result = $DB->Execute($sql); $total = $result->fields['total']; mail("admin@example.com", "Daily Report", "Posts today: " . $total); 1. Enable Caching // config.php $config['cache_enabled'] = true; $config['cache_lifetime'] = 3600; // 1 hour $config['cache_dir'] = 'cache/'; 2. Optimize Database Queries // Add indexes to database tables ALTER TABLE posts ADD INDEX idx_status_publish (status, publish_date); ALTER TABLE posts ADD INDEX idx_category (category_id); 3. Enable Pagination // In list page configuration $config['page_size'] = 20; $config['use_pagination'] = true; 4. Lazy Loading for Related Data // Modify class to load relations on demand public function GetCategory()
// pages/posts_add.php public function OnBeforeSave()
<table class="table"> <thead> <tr><th>Month</th><th>Posts</th></tr> </thead> <tbody> <?php while($row = $result->fetch()): ?> <tr> <td><?= $row['month'] ?></td> <td><?= $row['count'] ?></td> </tr> <?php endwhile; ?> </tbody> </table> $_SERVER['HTTP_HOST']
Configure file fields in project:
// Log the insertion $this->LogActivity("New post created: " . $this->title);
// login.php session_start(); $ip = $_SERVER['REMOTE_ADDR']; $attempts = $_SESSION['login_attempts'][$ip] ?? 0; if ($attempts >= 5) $wait = 300; // 5 minutes die("Too many attempts. Please wait $wait seconds.");