ProCom
Well-known member
Hey All!
Please let me start by saying I am NOT an expert... or even novice at any of this stuff. I'm a newbie just trying to hack myself into the quickest way to get the results I need.
BACKGROUND:
For years I was running queries on my Xenforo DB via PHPMyAdmin to pull hidden signals in the noisy data. Some queries I was running often enough that I wished I had a page that would just auto-display the data. I learned how to create "custom XF pages" but that was always a challenge for my non-coding brain (and creating an addon was out of the question. LOL!).
Finally with the help of some awesome peeps way smarter than me, I created a PHP page / script that I could run and access (with correct account access authentication) the data I needed!
Solution:
Below is a very simple version of this page that I can edit (most often using AI/LLMs to help create the query and page) to use for almost anything to query the XF DB!
Take a look and please provide any thoughts / feedback / fixes / optimizations, etc..
I just created a folder off of /public/<folder>/ ... then uploaded the file into it, and accessed it via browser, and voilà... DATA!!
This simple version just displays the "Last 10 Post IDs" of the forum:
Please let me start by saying I am NOT an expert... or even novice at any of this stuff. I'm a newbie just trying to hack myself into the quickest way to get the results I need.
BACKGROUND:
For years I was running queries on my Xenforo DB via PHPMyAdmin to pull hidden signals in the noisy data. Some queries I was running often enough that I wished I had a page that would just auto-display the data. I learned how to create "custom XF pages" but that was always a challenge for my non-coding brain (and creating an addon was out of the question. LOL!).
Finally with the help of some awesome peeps way smarter than me, I created a PHP page / script that I could run and access (with correct account access authentication) the data I needed!
Solution:
Below is a very simple version of this page that I can edit (most often using AI/LLMs to help create the query and page) to use for almost anything to query the XF DB!
Take a look and please provide any thoughts / feedback / fixes / optimizations, etc..
I just created a folder off of /public/<folder>/ ... then uploaded the file into it, and accessed it via browser, and voilà... DATA!!
This simple version just displays the "Last 10 Post IDs" of the forum:
PHP:<?php require "/home/nginx/domains/backyardchickens.com/public/src/config.php"; $dir = "/home/nginx/domains/backyardchickens.com/public"; require($dir . '/src/XF.php'); XF::start($dir); $app = XF::setupApp('XF\Pub\App'); $app->start(); $visitor = \XF::visitor(); // Ensure the user is logged in and is an administrator if (!$visitor->user_id || !in_array(3, array_merge([$visitor->user_group_id], $visitor->secondary_group_ids))) { echo "No Permission"; exit; } // Fetch the last 10 most recent post IDs $posts = XF::db()->fetchAll(" SELECT post_id FROM xf_post ORDER BY post_date DESC LIMIT 10 "); ?> <!DOCTYPE html> <html> <head> <title>Recent Posts</title> </head> <body> <h1>Last 10 Post IDs</h1> <?php if (!empty($posts)): ?> <ul> <?php foreach ($posts as $post): ?> <li><?php echo htmlspecialchars($post['post_id']); ?></li> <?php endforeach; ?> </ul> <?php else: ?> <p>No recent posts found.</p> <?php endif; ?> </body> </html>