<?php
error_reporting(E_ALL); ini_set('display_errors',1);
$pdo = new PDO('mysql:host=localhost;dbname=monara_ratings_db;charset=utf8','monara_ratings_user','.{L*tHx@O9MR');
$tables = $pdo->query('SHOW TABLES')->fetchAll(PDO::FETCH_COLUMN);
echo "ratings tables: ".implode(', ',$tables)."\n";
foreach ($tables as $t) {
    $cnt = $pdo->query("SELECT COUNT(*) FROM `$t`")->fetchColumn();
    echo "  $t: $cnt\n";
}
// booking payment stats hotel
$pdo2 = new PDO('mysql:host=localhost;dbname=monara_hotel;charset=utf8','monara_hotel', file_get_contents('/dev/null'));
$wp = file_get_contents('/home/monara/public_html/Hotel_Sapphire/wp-config.php');
preg_match("/define\(\s*'DB_PASSWORD'\s*,\s*'([^']*)'/", $wp, $p);
$pdo2 = new PDO('mysql:host=localhost;dbname=monara_hotel;charset=utf8','monara_hotel',$p[1]);
echo "\n=== booking payment types ===\n";
$rows = $pdo2->query("SELECT action_type, paypal_payment_status, COUNT(*) c, SUM(final_trip_price) total FROM wp_eagle_booking GROUP BY action_type, paypal_payment_status")->fetchAll(PDO::FETCH_ASSOC);
foreach ($rows as $r) echo "{$r['action_type']} | {$r['paypal_payment_status']} | count={$r['c']} | sum={$r['total']}\n";
echo "\nrecent bookings:\n";
$recent = $pdo2->query("SELECT id, guest_name, guest_email, final_trip_price, action_type, paypal_payment_status, booking_date FROM wp_eagle_booking ORDER BY id DESC LIMIT 5")->fetchAll(PDO::FETCH_ASSOC);
foreach ($recent as $r) echo json_encode($r)."\n";
// cinema
echo "\n=== cinema submit ===\n";
if (file_exists('/home/monara/public_html/cinema_booking/submit.php')) echo substr(file_get_contents('/home/monara/public_html/cinema_booking/submit.php'),0,800);
else echo "no submit.php\n";
