show my subscriptions

This commit is contained in:
jhuesser 2018-06-07 13:56:05 +02:00 committed by Thomas Nilsen
parent c96cc6e1c5
commit cea55bd2b8
3 changed files with 35 additions and 0 deletions

View File

@ -4,6 +4,10 @@ require_once("template.php");
if (!file_exists("config.php")) if (!file_exists("config.php"))
{ {
require_once("install.php"); require_once("install.php");
} elseif(isset($_GET['do'])){ // we can add other actions with $_GET['do'] later.
if($_GET['do'] == "subscriptions"){
require_once("subscriptions.php");
}
} }
else{ else{

30
subscriptions.php Normal file
View File

@ -0,0 +1,30 @@
<?php
require_once("template.php");
require_once("config.php");
require_once("classes/constellation.php");
Template::render_header("Subscriptions");
$tg_user = getTelegramUserData();
if($tg_user !== false){
$query = $mysqli->query("SELECT services.id, services.name, subscribers.subscriberID, subscribers.telegramID
FROM services
LEFT JOIN services_subscriber ON services_subscriber.serviceIDFK = services.id
LEFT JOIN subscribers ON services_subscriber.subscriberIDFK = subscribers.subscriberID
WHERE subscribers.telegramID =" . $tg_user['id']);
//$query = $mysqli->query("SELECT id, name FROM services");
if ($query->num_rows){
$timestamp = time();
echo '<h1>' . _("Your subscriptions") . "</h1>";
echo '<ul class="list-group">';
while($result = $query->fetch_assoc())
{
echo '<li class="list-group-item">' . $result['name'] . '</li>';
}
echo "</ul>";
}
} else{
header('Location: index.php');
}
Template::render_footer();

View File

@ -70,6 +70,7 @@ class Template{
<?php <?php
$tg_user = getTelegramUserData(); $tg_user = getTelegramUserData();
if($tg_user !== false){ if($tg_user !== false){
echo '<li><a href="?do=subscriptions">Subscriptions</a></li>';
echo '<li><a href="https://status.jhuesser.ch/index.php?subscriber_logout=1">Logout</a></li>'; echo '<li><a href="https://status.jhuesser.ch/index.php?subscriber_logout=1">Logout</a></li>';
} else { } else {
echo '<li><a href="#"><script async src="https://telegram.org/js/telegram-widget.js?4" data-telegram-login="jhuesserstatusbot" data-size="small" data-userpic="false" data-auth-url="https://status.jhuesser.ch/check.php" data-request-access="write"></script></a></li>'; echo '<li><a href="#"><script async src="https://telegram.org/js/telegram-widget.js?4" data-telegram-login="jhuesserstatusbot" data-size="small" data-userpic="false" data-auth-url="https://status.jhuesser.ch/check.php" data-request-access="write"></script></a></li>';