Skip to content

Instantly share code, notes, and snippets.

@ge0rg
Forked from iNPUTmice/invite.php
Last active June 14, 2016 11:04
Show Gist options
  • Save ge0rg/0b191b2e765ca36f88b5b9d08f83e5c3 to your computer and use it in GitHub Desktop.
Save ge0rg/0b191b2e765ca36f88b5b9d08f83e5c3 to your computer and use it in GitHub Desktop.
<?php
$url_parts = preg_split('/@|\/|;|\?/',$_SERVER["REQUEST_URI"]);
if (count($url_parts) < 4 || empty($url_parts[3])) {
header('Location: https://yaxim.org');
die();
} else {
$localpart = strtolower(urldecode($url_parts[2]));
$domainpart = strtolower(urldecode($url_parts[3]));
$contact = htmlentities(ucwords($localpart,"-."));
$jid = $localpart.'@'.$domainpart;
$muc = $url_parts[1] === 'j';
$token = $url_parts[4];
if ($muc) {
$url = "xmpp:" . $jid . "?join";
} else {
$url = "xmpp:" . $jid . "?roster";
if ($token)
$url = $url . ";preauth=" . $token;
}
}
function play($package) {
if (strpos(strtolower($_SERVER["HTTP_USER_AGENT"]),'android') !== false) {
return 'market://details?id=' . $package;
} else {
return 'https://play.google.com/store/apps/details?id=' . $package . '&amp;referrer=utm_source%3Dinvite';
}
}
?>
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta content="IE=edge" http-equiv="X-UA-Compatible">
<meta content="width=device-width, initial-scale=1, user-scalable=0" name="viewport">
<title>
<?php if ($muc) {?>
Invitation to <?= $contact ?>
<?php } else {?>
Invitation from <?= $contact ?>
<?php }?></title>
<link href="/stylesheets/bootstrap.min.css" rel="stylesheet">
<link href="/stylesheets/i.css" rel="stylesheet">
<style>
.main {
padding-top: 0px;
max-width: 600px;
width: 90%;
margin: 0 auto;
}
</style>
<!--[if lt IE 9]>
<script src="https://oss.maxcdn.com/html5shiv/3.7.2/html5shiv.min.js"></script>
<script src="https://oss.maxcdn.com/respond/1.4.2/respond.min.js"></script>
<![endif]-->
</head>
<body>
<div class="main">
<?php
?>
<?php if ($muc) {?>
<h3 class="text-center">You have been invited to <?= $contact ?></h3>
<?php } else {?>
<h3 class="text-center"><?= $contact ?> has invited you to chat</h3>
<?php }?>
<p class="lead">
<?php if ($muc) { ?>
Join the chat room <em><?=$contact?></em>
<?php } else { ?>
Add <em><?=$contact?></em> to your contact list
<?php } ?>
by clicking the following link:</p>
<p class="text-center">
<a class="btn btn-primary" href="<?=htmlentities($url)?>">
<?php if ($muc) { ?>
Join <?=$contact?>
<?php } else { ?>
Add <?=$contact?>
<?php } ?>
</a>
</p>
<p class="lead">
If this link does not work, you need to install and configure an XMPP client,
and visit this page again afterwards.
</p>
<p class="lead">
On Android we recommend one of:
</p>
<p class="lead">
<ul class="lead">
<li><strong><a href="<?=play('org.yaxim.androidclient')?>">yaxim</a></strong> - lightweight classic UI</li>
<li><strong><a href="<?=play('eu.siacs.conversations')?>">Conversations</a></strong> - modern and featureful</li>
<li><strong><a href="<?=play('org.yaxim.bruno')?>">Bruno</a></strong> - cute and cuddly (based on yaxim)</li>
</ul>
<p class="lead">
Check the <a href='http://xmpp.org/software/clients.html'>full list of XMPP clients</a> for other platforms.
</p>
<p>
XMPP is a provider independent form of instant messaging.
That means you can pick from many different clients and have a free choice of server operators to
<?php if ($muc) {?>
participate in the chat room <em><?=$contact?>.</em>
<?php } else { ?>
communicate with <em><?=$contact?>.</em>
<?php } ?>
</p>
<p>Visit <a href="https://yaxim.org">yaxim.org</a> for more information on this service.</p>
</div>
</body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment