Last active
February 26, 2022 22:44
-
-
Save FokkeZB/5899387 to your computer and use it in GitHub Desktop.
Script to create custom shortcuts on the iOS springboard. Check it out at: http://dev.fokkezb.nl/shortcutter
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<? | |
if ($_SERVER['REQUEST_METHOD'] == 'POST') { | |
if (!empty($_FILES['icon']['tmp_name']) && !$_FILES["file"]["error"]) { | |
$icon = new Imagick($_FILES['icon']['tmp_name']); | |
unlink($_FILES['icon']['tmp_name']); | |
} | |
if (empty($icon)) { | |
$icon = new Imagick(dirname(__FILE__) . '/icon.png'); | |
} | |
$icon->setImageFormat('png'); | |
$icon->cropThumbnailImage(144, 144); | |
$icon_144 = $icon->getImageBlob(); | |
$icon->cropThumbnailImage(114, 114); | |
$icon_114 = $icon->getImageBlob(); | |
$icon->cropThumbnailImage(72, 72); | |
$icon_72 = $icon->getImageBlob(); | |
$icon->cropThumbnailImage(57, 57); | |
$icon_57 = $icon->getImageBlob(); | |
$html = 'data:text/html;charset=UTF-8,'; | |
$html .= rawurlencode( | |
'<!DOCTYPE html>' | |
. '<html>' | |
. '<head>' | |
. '<meta charset="UTF-8" />' | |
. '<title>' . $_POST['title'] . '</title>' | |
. '<meta name="viewport" content="width=device-width, initial-scale=1.0" />' | |
. '<meta name="apple-mobile-web-app-capable" content="yes" />' | |
. '<meta name="apple-mobile-web-app-status-bar-style" content="black" />' | |
. '<link rel="apple-touch-startup-image" href="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAUAAAAHMCAMAAACTPIE7AAAAGXRFWHRTb2Z0d2FyZQBBZG9iZSBJbWFnZVJlYWR5ccllPAAAAAZQTFRFAAAA////pdmf3QAAAKpJREFUeNrswTEBAAAAwqD1T20JT6AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAP4mgAADAEDqAAHrKiAyAAAAAElFTkSuQmCC" />' | |
. '<script>' | |
. 'if (!window.navigator.standalone) {' | |
. 'document.write(\'<link rel="apple-touch-icon-precomposed" href="data:image/png;base64,' . base64_encode($icon_57) . '" />\');' | |
. 'document.write(\'<link rel="apple-touch-icon-precomposed" sizes="72x72" href="data:image/png;base64,' . base64_encode($icon_72) . '" />\');' | |
. 'document.write(\'<link rel="apple-touch-icon-precomposed" sizes="114x114" href="data:image/png;base64,' . base64_encode($icon_114) . '" />\');' | |
. 'document.write(\'<link rel="apple-touch-icon-precomposed" sizes="144x144" href="data:image/png;base64,' . base64_encode($icon_144) . '" />\');' | |
. '}' | |
. '</script>' | |
. '</head>' | |
. '<body style="display:none;" onload="document.body.style.display=\'block\';">' | |
. '<a id="url" href="' . $_POST['url'] . '" name="url"></a>' | |
. '<script>' | |
. 'if (window.navigator.standalone) {' | |
. 'var e = document.getElementById(\'url\');' | |
. 'var ev = document.createEvent(\'MouseEvents\');' | |
. 'ev.initEvent(\'click\', true, true);' | |
. 'e.dispatchEvent(ev);' | |
. '} else {' | |
. 'document.write(\'<h1>Add me to your homescreen</h1>\');' | |
. '}' | |
. '</script>' | |
. '</body>' | |
. '</html>' | |
); | |
header('Location: ' . $html); | |
exit; | |
} | |
?> | |
<html> | |
<head> | |
<title>Shortcutter</title> | |
<meta name="viewport" content="width=device-width, minimum-scale=1.0, maximum-scale=1.0, user-scalable=no"> | |
</head> | |
<body> | |
<form method="post" enctype="multipart/form-data"> | |
Find some <a href="http://handleopenurl.com/" target="_blank">URL scheme</a><br /> | |
<input type="text" name="url" value="twitter://post?message=<?= urlencode('#shortcutter') ?>" placeholder="URL (scheme)" /><br /> | |
Give it a title:<br /> | |
<input type="text" name="title" value="Tweet" placeholder="Titel" /><br /> | |
Maybe upload a custom icon:<br /> | |
<input type="file" name="icon" /><br /><br /> | |
<input type="submit" value="Generate" /> | |
</form> | |
</body> | |
</html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment