Skip to content

Commit

Permalink
Update findkey.php to prompt for key and search both live_transmition…
Browse files Browse the repository at this point in the history
…s and live_transmitions_history tables
  • Loading branch information
Daniel Neto committed Aug 5, 2024
1 parent a2abf15 commit 06c2a42
Showing 1 changed file with 11 additions and 6 deletions.
17 changes: 11 additions & 6 deletions plugin/Live/tools/findkey.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,15 +13,15 @@
$key = trim(fgets(STDIN));

// Prepare the SQL queries for both tables
$sql1 = "SELECT lt.users_id, u.user, u.channelname, 'live_transmitions' as source
$sql1 = "SELECT lt.users_id, u.user, u.channelname, lt.modified , 'live_transmitions'as source
FROM
`live_transmitions` lt
JOIN
`users` u ON lt.`users_id` = u.`id`
WHERE
lt.`key` = ?";

$sql2 = "SELECT lth.users_id, u.user, u.channelname, 'live_transmitions_history' as source
$sql2 = "SELECT lth.users_id, u.user, u.channelname, lth.modified , 'live_transmitions_history' as source
FROM
`live_transmitions_history` lth
JOIN
Expand All @@ -34,10 +34,14 @@
$fullData1 = sqlDAL::fetchAllAssoc($res1);
sqlDAL::close($res1);

// Execute the second query
$res2 = sqlDAL::readSql($sql2, 's', [$key]);
$fullData2 = sqlDAL::fetchAllAssoc($res2);
sqlDAL::close($res2);
if(empty($fullData1)){
// Execute the second query
$res2 = sqlDAL::readSql($sql2, 's', [$key]);
$fullData2 = sqlDAL::fetchAllAssoc($res2);
sqlDAL::close($res2);
}else{
$fullData2 = array();
}

// Merge the results
$fullData = array_merge($fullData1, $fullData2);
Expand All @@ -50,6 +54,7 @@
echo "Username: " . $row['user'] . "\n";
echo "Channel Name: " . $row['channelname'] . "\n";
echo "Source: " . $row['source'] . "\n";
echo "Source: " . $row['nodified'] . "\n";
echo "--------------------------\n";
$rows[] = $row;
}
Expand Down

0 comments on commit 06c2a42

Please sign in to comment.