• 28-04-2025, 21:27:14
    #1
    Merhaba, wp de şifreli sayfa yapmak istiyorum ancak biraz klasikten farklı
    Örneğin sayfayı görüntüleyen şifreli kişinin görüntüleme bilgisini almak istiyorum. Ne zaman girdi sayfaya gibi bu gibi kişilere özel şifre için bir eklenti mevcutmu
  • 28-04-2025, 21:41:40
    #2
    fatbotter.com
    https://fatgpt.com.tr/test/
    şifre: 123456




    Önce kayıtların tutulacağı veritabanı tablosunu oluşturmak için aşağıdaki sql kodunu phpmyadmin'den çalıştırın.

    CREATE TABLE `wp_password_access_logs` (
      `id` mediumint(9) NOT NULL AUTO_INCREMENT,
      `post_id` bigint(20) NOT NULL,
      `post_title` text NOT NULL,
      `access_ip` varchar(100) NOT NULL,
      `access_time` datetime NOT NULL,
      `user_agent` text NOT NULL,
      PRIMARY KEY (`id`)
    ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
    Ardından aşağıdaki php kodunu temanızın functions.php dosyasına koyun.

    // Şifre korumalı sayfalar için giriş log sistemi
    function custom_password_form() {
        global $post;
        $label = 'pwbox-'.( empty( $post->ID ) ? rand() : $post->ID );
        $output = '<form action="' . esc_url( site_url( 'wp-login.php?action=postpass', 'login_post' ) ) . '" method="post" class="post-password-form">';
        $output .= '<p>' . __( 'Bu içerik şifre korumalıdır. İçeriği görmek için lütfen şifreyi giriniz:' ) . '</p>';
        $output .= '<p><label for="' . $label . '">' . __( 'Şifre:' ) . ' <input name="post_password" id="' . $label . '" type="password" size="20" /></label>';
        
        // Kullanıcı IP adresi ve diğer bilgileri gizli alan olarak ekle
        $output .= '<input type="hidden" name="access_ip" value="' . $_SERVER['REMOTE_ADDR'] . '">';
        $output .= '<input type="hidden" name="access_time" value="' . current_time('mysql') . '">';
        $output .= '<input type="hidden" name="post_id" value="' . $post->ID . '">';
        
        $output .= ' <input type="submit" name="Submit" value="' . esc_attr__( "Giriş" ) . '" /></p></form>';
        
        return $output;
    }
    add_filter('the_password_form', 'custom_password_form');
    
    // Şifre girişini kontrol et ve log kaydet
    function log_password_access() {
        if (isset($_POST['post_password']) && !empty($_POST['post_password'])) {
            $post_id = isset($_POST['post_id']) ? intval($_POST['post_id']) : 0;
            $access_ip = isset($_POST['access_ip']) ? sanitize_text_field($_POST['access_ip']) : $_SERVER['REMOTE_ADDR'];
            $access_time = isset($_POST['access_time']) ? sanitize_text_field($_POST['access_time']) : current_time('mysql');
            $user_agent = isset($_SERVER['HTTP_USER_AGENT']) ? $_SERVER['HTTP_USER_AGENT'] : '';
            
            // Şifrenin doğru olup olmadığını kontrol et
            $post = get_post($post_id);
            if ($post && $post->post_password == $_POST['post_password']) {
                // Şifre doğru, erişimi logla
                $log_data = array(
                    'post_id' => $post_id,
                    'post_title' => get_the_title($post_id),
                    'access_ip' => $access_ip,
                    'access_time' => $access_time,
                    'user_agent' => $user_agent
                );
                
                // Log veritabanına kaydet
                global $wpdb;
                $table_name = $wpdb->prefix . 'password_access_logs';
                $wpdb->insert($table_name, $log_data);
            }
        }
    }
    add_action('wp_loaded', 'log_password_access');
    
    // Admin panele log görüntüleme sayfası ekle
    function register_password_access_logs_page() {
        add_menu_page(
            'Şifreli Sayfa Erişim Logları',
            'Şifre Logları',
            'manage_options',
            'password-access-logs',
            'display_password_access_logs',
            'dashicons-lock',
            30
        );
    }
    add_action('admin_menu', 'register_password_access_logs_page');
    
    // Log gösterme fonksiyonu
    function display_password_access_logs() {
        global $wpdb;
        $table_name = $wpdb->prefix . 'password_access_logs';
        
        // Tüm logları al
        $logs = $wpdb->get_results("SELECT * FROM $table_name ORDER BY access_time DESC", ARRAY_A);
        
        echo '<div class="wrap">';
        echo '<h1>Şifreli Sayfa Erişim Logları</h1>';
        
        if (empty($logs)) {
            echo '<p>Henüz kaydedilmiş log bulunmamaktadır.</p>';
        } else {
            echo '<table class="wp-list-table widefat fixed striped">';
            echo '<thead><tr>';
            echo '<th>ID</th>';
            echo '<th>Sayfa</th>';
            echo '<th>IP Adresi</th>';
            echo '<th>Erişim Zamanı</th>';
            echo '<th>Tarayıcı</th>';
            echo '</tr></thead>';
            
            echo '<tbody>';
            foreach ($logs as $log) {
                echo '<tr>';
                echo '<td>' . esc_html($log['id']) . '</td>';
                echo '<td>' . esc_html($log['post_title']) . ' (ID: ' . esc_html($log['post_id']) . ')</td>';
                echo '<td>' . esc_html($log['access_ip']) . '</td>';
                echo '<td>' . esc_html($log['access_time']) . '</td>';
                echo '<td>' . esc_html($log['user_agent']) . '</td>';
                echo '</tr>';
            }
            echo '</tbody>';
            
            echo '</table>';
        }
        
        echo '</div>';
    }
  • 29-04-2025, 12:02:50
    #3
    lookout adlı üyeden alıntı: mesajı görüntüle
    https://fatgpt.com.tr/test/
    şifre: 123456




    Önce kayıtların tutulacağı veritabanı tablosunu oluşturmak için aşağıdaki sql kodunu phpmyadmin'den çalıştırın.

    CREATE TABLE `wp_password_access_logs` (
      `id` mediumint(9) NOT NULL AUTO_INCREMENT,
      `post_id` bigint(20) NOT NULL,
      `post_title` text NOT NULL,
      `access_ip` varchar(100) NOT NULL,
      `access_time` datetime NOT NULL,
      `user_agent` text NOT NULL,
      PRIMARY KEY (`id`)
    ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
    Ardından aşağıdaki php kodunu temanızın functions.php dosyasına koyun.

    // Şifre korumalı sayfalar için giriş log sistemi
    function custom_password_form() {
        global $post;
        $label = 'pwbox-'.( empty( $post->ID ) ? rand() : $post->ID );
        $output = '<form action="' . esc_url( site_url( 'wp-login.php?action=postpass', 'login_post' ) ) . '" method="post" class="post-password-form">';
        $output .= '<p>' . __( 'Bu içerik şifre korumalıdır. İçeriği görmek için lütfen şifreyi giriniz:' ) . '</p>';
        $output .= '<p><label for="' . $label . '">' . __( 'Şifre:' ) . ' <input name="post_password" id="' . $label . '" type="password" size="20" /></label>';
        
        // Kullanıcı IP adresi ve diğer bilgileri gizli alan olarak ekle
        $output .= '<input type="hidden" name="access_ip" value="' . $_SERVER['REMOTE_ADDR'] . '">';
        $output .= '<input type="hidden" name="access_time" value="' . current_time('mysql') . '">';
        $output .= '<input type="hidden" name="post_id" value="' . $post->ID . '">';
        
        $output .= ' <input type="submit" name="Submit" value="' . esc_attr__( "Giriş" ) . '" /></p></form>';
        
        return $output;
    }
    add_filter('the_password_form', 'custom_password_form');
    
    // Şifre girişini kontrol et ve log kaydet
    function log_password_access() {
        if (isset($_POST['post_password']) && !empty($_POST['post_password'])) {
            $post_id = isset($_POST['post_id']) ? intval($_POST['post_id']) : 0;
            $access_ip = isset($_POST['access_ip']) ? sanitize_text_field($_POST['access_ip']) : $_SERVER['REMOTE_ADDR'];
            $access_time = isset($_POST['access_time']) ? sanitize_text_field($_POST['access_time']) : current_time('mysql');
            $user_agent = isset($_SERVER['HTTP_USER_AGENT']) ? $_SERVER['HTTP_USER_AGENT'] : '';
            
            // Şifrenin doğru olup olmadığını kontrol et
            $post = get_post($post_id);
            if ($post && $post->post_password == $_POST['post_password']) {
                // Şifre doğru, erişimi logla
                $log_data = array(
                    'post_id' => $post_id,
                    'post_title' => get_the_title($post_id),
                    'access_ip' => $access_ip,
                    'access_time' => $access_time,
                    'user_agent' => $user_agent
                );
                
                // Log veritabanına kaydet
                global $wpdb;
                $table_name = $wpdb->prefix . 'password_access_logs';
                $wpdb->insert($table_name, $log_data);
            }
        }
    }
    add_action('wp_loaded', 'log_password_access');
    
    // Admin panele log görüntüleme sayfası ekle
    function register_password_access_logs_page() {
        add_menu_page(
            'Şifreli Sayfa Erişim Logları',
            'Şifre Logları',
            'manage_options',
            'password-access-logs',
            'display_password_access_logs',
            'dashicons-lock',
            30
        );
    }
    add_action('admin_menu', 'register_password_access_logs_page');
    
    // Log gösterme fonksiyonu
    function display_password_access_logs() {
        global $wpdb;
        $table_name = $wpdb->prefix . 'password_access_logs';
        
        // Tüm logları al
        $logs = $wpdb->get_results("SELECT * FROM $table_name ORDER BY access_time DESC", ARRAY_A);
        
        echo '<div class="wrap">';
        echo '<h1>Şifreli Sayfa Erişim Logları</h1>';
        
        if (empty($logs)) {
            echo '<p>Henüz kaydedilmiş log bulunmamaktadır.</p>';
        } else {
            echo '<table class="wp-list-table widefat fixed striped">';
            echo '<thead><tr>';
            echo '<th>ID</th>';
            echo '<th>Sayfa</th>';
            echo '<th>IP Adresi</th>';
            echo '<th>Erişim Zamanı</th>';
            echo '<th>Tarayıcı</th>';
            echo '</tr></thead>';
            
            echo '<tbody>';
            foreach ($logs as $log) {
                echo '<tr>';
                echo '<td>' . esc_html($log['id']) . '</td>';
                echo '<td>' . esc_html($log['post_title']) . ' (ID: ' . esc_html($log['post_id']) . ')</td>';
                echo '<td>' . esc_html($log['access_ip']) . '</td>';
                echo '<td>' . esc_html($log['access_time']) . '</td>';
                echo '<td>' . esc_html($log['user_agent']) . '</td>';
                echo '</tr>';
            }
            echo '</tbody>';
            
            echo '</table>';
        }
        
        echo '</div>';
    }
    yardımınız için çok teşekkür ederim hocam fakat log gözükmüyor acaba veritabanını yanlış yerde mi başlattım
  • 29-04-2025, 12:10:33
    #4
    fatbotter.com
    Sigma adlı üyeden alıntı: mesajı görüntüle
    yardımınız için çok teşekkür ederim hocam fakat log gözükmüyor acaba veritabanını yanlış yerde mi başlattım
    Rica ederim.

    wp_password_access_logs tablosu oluşmuş mu bir bakın. Belki de tablo ön ekiniz farklıdır. Default halı wp_ olur ancak farklı ön ek var ise ismi düzeltmeniz gerek.
  • 29-04-2025, 15:31:36
    #5
    Çok teşekkür ederim hocam ön eki düzeltince halloldu