forked from YOURLS/YOURLS
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsample-public-front-page.php.txt
108 lines (91 loc) · 3.07 KB
/
sample-public-front-page.php.txt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
<?php
// Start YOURLS engine
require_once( dirname(__FILE__).'/includes/load-yourls.php' );
?>
<html>
<head>
<title>YOURLS Public Interface Sample</title>
<style>
body {
background:#F3FAFD;
color:#5B87B4;
font:16px/30px verdana,arial,sans-serif;
}
h1 {text-align:center}
h2 {border-bottom:1px solid white;}
#container {
width: 780px;
margin-left: auto;
margin-right: auto;
background-color: #fff;
border: 2px solid #2A85B3;
padding: 10px;
margin-top: -13px;
-moz-border-radius:15px;
-webkit-border-radius:15px;
}
#footer {
text-align:center;
margin-top:20px;
}
#footer p {
padding:5px;
background:white;
margin:0 auto;
width:750px;
-moz-border-radius:10px;
-webkit-border-radius:10px;
border:1px solid #2A85B3;
-moz-border-radius-bottomleft:35px;
-moz-border-radius-bottomright:35px;
-webkit-border-bottom-left-radius:25px;
-webkit-border-bottom-right-radius:25px;
}
#footer p a {
background:#fff url(http://yourls.org/images/favicon.gif) 2px center no-repeat;
padding-left:20px;
}
div#copybox { width:600px}
div#sharebox {height:auto; width:600px; margin-top: 20px}
</style>
<link rel="stylesheet" href="<?php echo YOURLS_SITE; ?>/css/share.css?v=<?php echo YOURLS_VERSION; ?>" type="text/css" media="screen" />
<script src="<?php echo YOURLS_SITE; ?>/js/jquery-1.3.2.min.js" type="text/javascript"></script>
<script src="<?php echo YOURLS_SITE; ?>/js/share.js?v=<?php echo YOURLS_VERSION; ?>" type="text/javascript"></script>
</head>
<body>
<h1>YOURLS: Your Own URL Shortener</h1>
<div id="container">
<?php
// Part to be executed if FORM has been submitted
if ( isset($_REQUEST['url']) ) {
$url = $_REQUEST['url'];
$keyword = isset( $_REQUEST['keyword'] ) ? $_REQUEST['keyword'] : '' ;
$return = yourls_add_new_link( $url, $keyword );
$shorturl = $return['shorturl'];
$message = $return['message'];
echo <<<RESULT
<h2>URL has been shortened</h2>
<p>Original URL: <code><a href="$url">$url</a></code></p>
<p>Short URL: <code><a href="$shorturl">$shorturl</a></code></p>
<p>$message</p>
RESULT;
// Include the Copy box and the Quick Share box
yourls_share_box( $url, $shorturl );
// Part to be executed when no form has been submitted
} else {
echo <<<HTML
<h2>Enter a new URL to shorten</h2>
<form method="post" action="">
<p><label>URL: <input type="text" name="url" value="http://" size="50" /></label></p>
<p><label>Optional custom keyword: <input type="text" name="keyword" size="5" /></label></p>
<p><input type="submit" value="Shorten" /></p>
</form>
HTML;
}
?>
<!-- Example bookmarklet. Be sure to rename the link target from "sample-public-front-page.php" to whatever you'll use (probably index.php) -->
<p><a href="javascript:void(location.href='<?php echo YOURLS_SITE; ?>/sample-public-front-page.php?format=simple&action=shorturl&url='+escape(location.href))">bookmarklet</a>
</div>
<div id="footer"><p>Powered by <a href="http://yourls.org/" title="YOURLS">YOURLS</a> v<?php echo YOURLS_VERSION; ?></p></div>
</body>
</html>