style
This commit is contained in:
parent
b6252a1c1a
commit
fcdb5217ee
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
|
@ -0,0 +1,118 @@
|
|||
|
||||
html
|
||||
{
|
||||
height: 100%;
|
||||
}
|
||||
|
||||
body
|
||||
{
|
||||
display: flex;
|
||||
justify-content: center;
|
||||
align-items: center;
|
||||
min-height: 100%;
|
||||
|
||||
}
|
||||
|
||||
|
||||
@keyframes blink-shadow {
|
||||
0% { box-shadow: 0 0 32px #DDD; }
|
||||
50% { box-shadow: none; }
|
||||
100% { box-shadow: 0 0 32px #DDD; }
|
||||
}
|
||||
|
||||
#mainpnl
|
||||
{
|
||||
box-shadow: 0 0 32px #DDD;
|
||||
animation:blink-shadow ease-in-out 4s infinite;
|
||||
width: 87%;
|
||||
min-width: 300px;
|
||||
max-width: 800px;
|
||||
position: relative;
|
||||
min-height: 445px;
|
||||
}
|
||||
|
||||
#mainpnl input,
|
||||
#mainpnl textarea
|
||||
{
|
||||
width: 100%;
|
||||
}
|
||||
|
||||
.responsive-label {
|
||||
align-items:center;
|
||||
}
|
||||
@media (min-width: 768px) {
|
||||
.responsive-label .col-md-3 {
|
||||
text-align:right
|
||||
}
|
||||
}
|
||||
|
||||
#mainpnl h1
|
||||
{
|
||||
text-align: center;
|
||||
margin-top: 0;
|
||||
margin-bottom: 24px;
|
||||
font-weight: bold;
|
||||
color: #FFF;
|
||||
text-shadow: #000 0 0 2px, #888 0 0 8px;
|
||||
}
|
||||
|
||||
#mainpnl button
|
||||
{
|
||||
width: 100%;
|
||||
margin-left: 4px;
|
||||
margin-right: 4px;
|
||||
}
|
||||
|
||||
#copyinfo
|
||||
{
|
||||
margin: 4px;
|
||||
position: fixed;
|
||||
bottom: 0;
|
||||
right: 0;
|
||||
}
|
||||
|
||||
#copyinfo a:hover
|
||||
{
|
||||
font-family: "Courier New", monospace;
|
||||
color: #00F;
|
||||
}
|
||||
|
||||
#copyinfo a,
|
||||
#copyinfo a:visited,
|
||||
#copyinfo a:active
|
||||
{
|
||||
font-family: "Courier New", monospace;
|
||||
color: #AAA;
|
||||
text-decoration: none;
|
||||
}
|
||||
|
||||
#tr_link
|
||||
{
|
||||
position: absolute;
|
||||
top: 0;
|
||||
right: 0;
|
||||
margin: -1px -1px 0 0;
|
||||
border-top-left-radius: 0;
|
||||
border-bottom-right-radius: 0;
|
||||
min-width: 40px;
|
||||
text-align: center;
|
||||
}
|
||||
|
||||
#tl_link
|
||||
{
|
||||
position: absolute;
|
||||
top: 0;
|
||||
left: 0;
|
||||
margin: -1px 0 0 -1px;
|
||||
border-top-right-radius: 0;
|
||||
border-bottom-left-radius: 0;
|
||||
padding: 4px 4px 0 4px;
|
||||
}
|
||||
|
||||
.icn-google-play {
|
||||
display: inline-block;
|
||||
width: 32px;
|
||||
height: 32px;
|
||||
background: url('data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHg9IjBweCIgeT0iMHB4IgogICAgIHdpZHRoPSI1MCIgaGVpZ2h0PSI1MCIKICAgICB2aWV3Qm94PSIwIDAgNDggNDgiCiAgICAgc3R5bGU9ImZpbGw6IzAwMDAwMDsiPjxnIGlkPSJzdXJmYWNlMSI+PHBhdGggc3R5bGU9IiBmaWxsOiM0REI2QUM7IiBkPSJNIDcuNzAzMTI1IDQuMDQyOTY5IEMgNy4yOTI5NjkgNC4xNDg0MzggNyA0LjUwNzgxMyA3IDUuMTIxMDk0IEMgNyA2LjkyMTg3NSA3IDIzLjkxNDA2MyA3IDIzLjkxNDA2MyBDIDcgMjMuOTE0MDYzIDcgNDIuMjgxMjUgNyA0My4wODk4NDQgQyA3IDQzLjUzNTE1NiA3LjE5NTMxMyA0My44MzU5MzggNy41IDQzLjk0NTMxMyBMIDI3LjY3OTY4OCAyMy44ODI4MTMgWiAiPjwvcGF0aD48cGF0aCBzdHlsZT0iIGZpbGw6I0RDRTc3NTsiIGQ9Ik0gMzMuMjM4Mj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html lang="en">
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<link rel="stylesheet" href="/css/mini-default.min.css">
|
||||
<link rel="stylesheet" href="/css/style.css">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1">
|
||||
</head>
|
||||
<body>
|
||||
|
||||
|
||||
<form id="mainpnl">
|
||||
|
||||
<a href="https://play.google.com/store/apps/details?id=com.blackforestbytes.simplecloudnotifier" class="button bordered" id="tl_link"><span class="icn-google-play"></span></a>
|
||||
<a href="/index_api.php" class="button bordered" id="tr_link">API</a>
|
||||
|
||||
<h1>Simple Cloud Notifier</h1>
|
||||
|
||||
<div class="row responsive-label">
|
||||
<div class="col-sm-12 col-md-3"><label for="uid" class="doc">UserID</label></div>
|
||||
<div class="col-sm-12 col-md"><input placeholder="UserID" id="uid" class="doc" type="text"></div>
|
||||
</div>
|
||||
|
||||
<div class="row responsive-label">
|
||||
<div class="col-sm-12 col-md-3"><label for="ukey" class="doc">Authentification Key</label></div>
|
||||
<div class="col-sm-12 col-md"><input placeholder="Key" id="ukey" class="doc" type="text"></div>
|
||||
</div>
|
||||
|
||||
<div class="row responsive-label">
|
||||
<div class="col-sm-12 col-md-3"><label for="msg" class="doc">Message Title</label></div>
|
||||
<div class="col-sm-12 col-md"><input placeholder="Message" id="msg" class="doc" type="text"></div>
|
||||
</div>
|
||||
|
||||
<div class="row responsive-label">
|
||||
<div class="col-sm-12 col-md-3"><label for="txt" class="doc">Message Content</label></div>
|
||||
<div class="col-sm-12 col-md"><textarea id="txt" class="doc" rows="5"></textarea></div>
|
||||
</div>
|
||||
|
||||
<div class="row">
|
||||
<div class="col-sm-12 col-md-3"></div>
|
||||
<div class="col-sm-12 col-md"><button type="submit" class="primary bordered">Send</button></div>
|
||||
|
||||
</div>
|
||||
</form>
|
||||
|
||||
<div id="copyinfo">
|
||||
<a href="https://www.blackforestbytes.com">© blackforestbytes</a>
|
||||
</div>
|
||||
|
||||
</body>
|
||||
</html>
|
|
@ -0,0 +1,39 @@
|
|||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<link rel="stylesheet" href="/css/mini-default.min.css">
|
||||
<link rel="stylesheet" href="/css/style.css">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1">
|
||||
</head>
|
||||
<body>
|
||||
|
||||
|
||||
<form id="mainpnl">
|
||||
|
||||
<a href="https://play.google.com/store/apps/details?id=com.blackforestbytes.simplecloudnotifier" class="button bordered" id="tl_link"><span class="icn-google-play"></span></a>
|
||||
<a href="/index.php" class="button bordered" id="tr_link">Send</a>
|
||||
|
||||
<h1>Simple Cloud Notifier</h1>
|
||||
|
||||
<p>Get your user-id and user-key from the app and send notifications to your phone by performing a POST request against <code>https://simplecloudnotifier.blackforestbytes.com/send.php</code></p>
|
||||
<pre>curl \
|
||||
--data "user_id={userid}" \
|
||||
--data "user_key={userkey}" \
|
||||
--data "message={message_title}" \
|
||||
--data "content={message_content}" \
|
||||
https://simplecloudnotifier.blackforestbytes.com/send.php</pre>
|
||||
<p>The <code>content</code> parameter is optional, you can also send message with only a title</p>
|
||||
<pre>curl \
|
||||
--data "user_id={userid}" \
|
||||
--data "user_key={userkey}" \
|
||||
--data "message={message_title}" \
|
||||
https://simplecloudnotifier.blackforestbytes.com/send.php</pre>
|
||||
</form>
|
||||
|
||||
<div id="copyinfo">
|
||||
<a href="https://www.blackforestbytes.com">© blackforestbytes</a>
|
||||
</div>
|
||||
|
||||
</body>
|
||||
</html>
|
|
@ -2,9 +2,11 @@
|
|||
|
||||
include_once 'model.php';
|
||||
|
||||
if (!isset($_GET['fcm_token'])) die(json_encode(['success' => false, 'message' => 'Missing parameter [[fcm_token]]']));
|
||||
$INPUT = array_merge($_GET, $_POST);
|
||||
|
||||
$fcmtoken = $_GET['fcm_token'];
|
||||
if (!isset($INPUT['fcm_token'])) die(json_encode(['success' => false, 'message' => 'Missing parameter [[fcm_token]]']));
|
||||
|
||||
$fcmtoken = $INPUT['fcm_token'];
|
||||
$user_key = generateRandomAuthKey();
|
||||
|
||||
$pdo = getDatabase();
|
||||
|
|
34
web/send.php
34
web/send.php
|
@ -2,30 +2,32 @@
|
|||
|
||||
include_once 'model.php';
|
||||
|
||||
$INPUT = array_merge($_GET, $_POST);
|
||||
|
||||
if (!isset($_GET['user_id'])) die(json_encode(['success' => false, 'message' => 'Missing parameter [[user_id]]']));
|
||||
if (!isset($_GET['user_key'])) die(json_encode(['success' => false, 'message' => 'Missing parameter [[user_token]]']));
|
||||
if (!isset($_GET['message_title'])) die(json_encode(['success' => false, 'message' => 'Missing parameter [[message_title]]']));
|
||||
if (!isset($INPUT['user_id'])) die(json_encode(['success' => false, 'errhighlight' => 101, 'message' => 'Missing parameter [[user_id]]']));
|
||||
if (!isset($INPUT['user_key'])) die(json_encode(['success' => false, 'errhighlight' => 102, 'message' => 'Missing parameter [[user_token]]']));
|
||||
if (!isset($INPUT['message_title'])) die(json_encode(['success' => false, 'errhighlight' => 103, 'message' => 'Missing parameter [[message_title]]']));
|
||||
|
||||
$user_id = $_GET['user_id'];
|
||||
$user_key = $_GET['user_key'];
|
||||
$message = $_GET['message_title'];
|
||||
$content = isset($_POST['message_content']) ? $_POST['message_content'] : '';
|
||||
$user_id = $INPUT['user_id'];
|
||||
$user_key = $INPUT['user_key'];
|
||||
$message = $INPUT['message_title'];
|
||||
$content = file_get_contents('php://input');
|
||||
if ($content === null || $content === false) $content = '';
|
||||
|
||||
//----------------------
|
||||
|
||||
$pdo = getDatabase();
|
||||
|
||||
$stmt = $pdo->prepare('SELECT user_id, user_key, fcm_token FROM users WHERE user_id = :uid LIMIT 1');
|
||||
$stmt = $pdo->prepare('SELECT user_id, user_key, fcm_token, messages_sent FROM users WHERE user_id = :uid LIMIT 1');
|
||||
$stmt->execute(['uid' => $user_id]);
|
||||
|
||||
$datas = $stmt->fetchAll(PDO::FETCH_ASSOC);
|
||||
if (count($datas)<=0) die(json_encode(['success' => false, 'message' => 'No User found']));
|
||||
if (count($datas)<=0) die(json_encode(['success' => false, 'errhighlight' => 101, 'message' => 'No User found']));
|
||||
$data = $datas[0];
|
||||
|
||||
if ($data === null) die(json_encode(['success' => false, 'message' => 'User not found']));
|
||||
if ($data['user_id'] !== (int)$user_id) die(json_encode(['success' => false, 'message' => 'UserID not found']));
|
||||
if ($data['user_key'] !== $user_key) die(json_encode(['success' => false, 'message' => 'Authentification failed']));
|
||||
if ($data === null) die(json_encode(['success' => false, 'errhighlight' => 101, 'message' => 'User not found']));
|
||||
if ($data['user_id'] !== (int)$user_id) die(json_encode(['success' => false, 'errhighlight' => 101, 'message' => 'UserID not found']));
|
||||
if ($data['user_key'] !== $user_key) die(json_encode(['success' => false, 'errhighlight' => 102, 'message' => 'Authentification failed']));
|
||||
|
||||
$fcm = $data['fcm_token'];
|
||||
|
||||
|
@ -65,5 +67,11 @@ catch (Exception $e)
|
|||
$stmt = $pdo->prepare('UPDATE users SET timestamp_accessed=NOW(), messages_sent=messages_sent+1 WHERE user_id = :uid');
|
||||
$stmt->execute(['uid' => $user_id]);
|
||||
|
||||
echo (json_encode(['success' => true, 'message' => 'Message sent', 'response' => $httpresult]));
|
||||
echo (json_encode(
|
||||
[
|
||||
'success' => true,
|
||||
'message' => 'Message sent',
|
||||
'response' => $httpresult,
|
||||
'messagecount' => $data['messages_sent']+1
|
||||
]));
|
||||
return 0;
|
|
@ -2,14 +2,16 @@
|
|||
|
||||
include_once 'model.php';
|
||||
|
||||
$INPUT = array_merge($_GET, $_POST);
|
||||
|
||||
if (!isset($_GET['user_id'])) die(json_encode(['success' => false, 'message' => 'Missing parameter [[user_id]]']));
|
||||
if (!isset($_GET['user_key'])) die(json_encode(['success' => false, 'message' => 'Missing parameter [[user_key]]']));
|
||||
if (!isset($_GET['message'])) die(json_encode(['success' => false, 'message' => 'Missing parameter [[message]]']));
|
||||
|
||||
$user_id = $_GET['user_id'];
|
||||
$user_key = $_GET['token'];
|
||||
$fcm_token = isset($_GET['token']) ? $_GET['token'] : null;
|
||||
if (!isset($INPUT['user_id'])) die(json_encode(['success' => false, 'message' => 'Missing parameter [[user_id]]']));
|
||||
if (!isset($INPUT['user_key'])) die(json_encode(['success' => false, 'message' => 'Missing parameter [[user_key]]']));
|
||||
if (!isset($INPUT['message'])) die(json_encode(['success' => false, 'message' => 'Missing parameter [[message]]']));
|
||||
|
||||
$user_id = $INPUT['user_id'];
|
||||
$user_key = $INPUT['token'];
|
||||
$fcm_token = isset($INPUT['token']) ? $INPUT['token'] : null;
|
||||
|
||||
//----------------------
|
||||
|
||||
|
|
Loading…
Reference in New Issue