Skip to content

BardoQi/YOURLS

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

95 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>	
	<meta http-equiv="content-type" content="text/html; charset=utf-8" />
	<title>YOURLS: Your Own URL Shortener (and a WordPress plugin)</title>
	<style type="text/css" media="screen">
		/* Default Style */
		body {
			font-family: Verdana, Arial;
			font-size: 12px;
			color: #000000;
			background: #ffffff;
		}
		p {
			padding-left: 10px;
		}
		code {
			background:#eaeaef;
			padding:0 2px;
		}
		tt {
			background:#ffc;
			padding:0 2px;		
		}
		pre tt {
			display:block;
		}
		blockquote {
			margin: 10px 20px 0px 20px;
			padding: 10px;
			border: 1px solid #8d8d8d;
			background-color: #f5f5f5;
		}
		li {
			margin-top: 20px;
		}
		ul li ul li {
			margin-top: 10px;
		}
		a, a:active, a:link, a:visited {
			color: #5b87b4;
			text-decoration: none;
		}
		a:hover {
			color: #5577a5;
			text-decoration: underline;
		}
		div.sshot {
			text-align:center;
		}
		div.sshot img {
			border:1px solid #5b87b4;
			zdisplay:block;
			margin-bottom:1em;
		}
		/* Place Holder Style */
		#Container {
			width: 780px;
			margin-left: auto;
			margin-right: auto; 
		}
		#Content {
			background-color: #fafafa;
			border: 1px solid #a2b6cb;
			padding: 10px;
			margin-top: -13px;
		}
		/* Title Style */
		h1 {
			font-family: Verdana, Arial;
			font-size: 22px;
			font-weight: bold;
			color: #2a85b3;
			border-bottom: 1px solid #2a85b3;
			margin-bottom: 10px;
			background:transparent url(http://yourls.org/images/yourls-logo.png) top center no-repeat;
			padding-top:90px;
		}
		h1:hover span {
			color: #73A4D6;
		}
		h2 {
			font-family: Verdana, Arial;
			font-size: 18px;
			font-weight: bold;
			color: #5b87b4;
		}
		h2:before {
			content: '\00BB';
			color:#BFE0FE;
		}
		h3 {
			font-family: Verdana, Arial;
			font-size: 14px;
			font-weight: bold;
			color: #73a4d6;
			margin-top:2em;
		}
		h3:before {
			content: '\00BB';
			color:#BFE0FE;
		}
		/* Tabs */
		ul#Tabs {
			font-family: Verdana, Arial;
			font-size: 12px;
			font-weight: bold;
			list-style-type: none;
			padding-bottom: 28px;
			border-bottom: 1px solid #a2b6cb;
			margin-bottom: 12px;
			z-index: 1;
		}
		#Tabs li.Tab {
			float: right;
			height: 25px;
			background-color: #deedfb;
			margin: 2px 0px 0px 5px;
			border: 1px solid #a2b6cb;
		}
		#Tabs li.Tab a {
			float: left;
			display: block;
			color: #666666;
			text-decoration: none;
			padding: 5px;
		}
		#Tabs li.Tab a:hover {
			background-color: #bfe0fe;
			border-bottom: 1px solid #bfe0fe;
		}
		/* Selected Tab */
		#Tabs li.SelectedTab {
			float: right;
			height: 25px;
			background-color: #fafafa;
			margin: 2px 0px 0px 5px;
			border-top: 1px solid #a2b6cb;
			border-right: 1px solid #a2b6cb;
			border-bottom: 1px solid #fafafa;
			border-left: 1px solid #a2b6cb;
		}
		#Tabs li.SelectedTab a {
			float: left;
			display: block;
			color: #666666;
			text-decoration: none;
			padding: 5px;
			cursor: default;
		}
		/* Copyright */
		#Copyright {
			text-align: center;
		}
	</style>
</head>
<body>
<div id="Container">
	<!-- Title -->
	<h1>YOURLS: <span>Y</span>our <span>O</span>wn <span>URL</span> <span>S</span>hortener (and a WordPress plugin)</h1>

	<!-- Tabs -->
	<ul id="Tabs">
		<li id="FAQTab" class="Tab"><a href="#FAQ" onclick="toggle(this);">FAQ</a></li>
		<li id="APITab" class="Tab"><a href="#API" onclick="toggle(this);">API</a></li>
		<li id="PluginTab" class="Tab"><a href="#Plugin" onclick="toggle(this);">WordPress plugin</a></li>
		<li id="ConfigTab" class="Tab"><a href="#Config" onclick="toggle(this);">Configuration</a></li>
		<li id="InstallTab" class="Tab"><a href="#Install" onclick="toggle(this);">Installation</a></li>
		<li id="AboutTab" class="SelectedTab"><a href="#About" onclick="toggle(this);">About</a></li>
	</ul>

	<!-- Content -->
	<div id="Content">
		<!-- Index -->
		<div id="AboutDiv">
			<h2>About YOURLS</h2>
			
			<h3>What is YOURLS</h3>
			<p>YOURLS is a small set of PHP scripts that will allow you to run your own URL shortening service (<em>a la</em> TinyURL). You can make it private or public, you can pick custom keyword URLs, it comes with its own API. You will love it.</p>
			<p>There's a <a href="#Plugin" onclick="toggle(this);">WordPress plugin</a> available for YOURLS, making integration with your blog a snap: create short URLs and tweet them automagically as you publish blog posts.</p>
			<p>YOURLS is in early stages of its life. While functional, it regularly evolves and improves. Please keep current and up to date to get the most of it</p>
			
			<h3>YOURLS Features</h3>
			<ul>
				<li>Public (everybody can create short links) or private (your links only)</li>
				<li>Random (sequential) or custom URL keyword</li>
				<li>Handy bookmarklet to easily shorten and share links</li>
				<li>Track click count on your links</li>
				<li>Neat AJAXed interface</li>
				<li>Developer API</li>
			</ul>
			
			<h3>Screenshots</h3>
			
			<div class="sshot">
				<img src="http://yourls.org/images/head.gif" />
				<img src="http://yourls.org/images/stats.gif" />
				<img src="http://yourls.org/images/footer.gif" />
			</div>
			
			<h3>Download</h3>
			
			<p><a href="http://code.google.com/p/yourls/downloads/list">Download YOURLS</a> from Google Code</p>
			
			<h3>Credits</h3>
			
			<p>YOURLS is made by:</p>
			<ul>
				<li><a href="http://lesterchan.net/" title="Visit Lester Chan's site">Lester Chan</a> &ndash <a href="http://twitter.com/gamerz">@GamerZ</a> on Twitter</li>
				<li><a href="http://planetozh.com/" title"Visit Ozh's site">Ozh RICHARD</a> &ndash <a href="http://twitter.com/ozh">@Ozh</a> on Twitter</li>
			</ul>
		</div>

		<!-- Installation Instructions -->
		<div id="InstallDiv" style="display: none;">
			<h2>Installation Instructions</h2>
			<ol>
				<li>Unzip the YOURLS archive</li>
				<li>Copy <code>includes/config-sample.php</code> to <code>includes/config.php</code></li>
				<li>Open <code>includes/config.php</code> with a raw text editor (like Notepad) and fill in the required settings</li>
				<li>Upload the unzipped files to your domain <code>public_html</code> or <code>www</code> folder</li>
				<li>Create a new database (see <a href="#Config" onclick="toggle(this);">Configuration</a> &ndash; you can also use an existing one)</li>
				<li>Point your browser to <code>http://yoursite.com/admin/install.php</code></li>
			</ol>
		</div>

		<!-- Configuration Instructions -->	
		<div id="ConfigDiv" style="display: none;">
			<h2>Configuration (in includes/config.php)</h2>
			<h3>MySQL settings</h3>
			<ul>
				<li><code>YOURLS_DB_USER</code><br/>
				your MySQL username<br/>
				<em>Example:</em> <tt>'joe'</tt></li>
				<li><code>YOURLS_DB_PASS</code><br/>
				your MySQL password<br/>
				<em>Example:</em> <tt>'MySeCreTPaSsW0rd'</tt></li>
				<li><code>YOURLS_DB_NAME</code>:
				The database name<br/>
				<em>Example:</em> <tt>'yourls'</tt></li>
				<li><code>YOURLS_DB_HOST</code><br/>
				The database host<br/>
				<em>Example:</em> <tt>'localhost'</tt></li>
				<li><code>YOURLS_DB_TABLE_URL</code><br/>
				The table name to store URLs<br/>
				<em>Example:</em> <tt>'url'</tt></li>
				<li><code>YOURLS_DB_TABLE_NEXTDEC</code><br/>
				The table name to store the next sequential link decimal id<br/>
				<em>Example:</em> <tt>'nextdec'</tt></li>
			</ul>
			
			<h3>Site options</h3>
			<ul>
				<li><code>YOURLS_SITE</code><br/>
				Your (short) domain URL, no trailing slash<br/>
				<em>Example:</em> <tt>'http://ozh.in'</tt></li>
				<li><code>YOURLS_HOURS_OFFSET</code><br/>
				Timezone GMT offset<br/>
				<em>Example:</em> <tt>'-5'</tt></li>
				<li><code>YOURLS_PRIVATE</code><br/>
				Private means protected with login/pass as defined below. Set to false for public usage<br/>
				<em>Example:</em> <tt>'true'</tt></li>
				<li><code>YOURLS_COOKIEKEY</code><br/>
				A random secret hash used to encrypt cookies. You don't have to remember it, make it long and complicated. Hint: generate a unique one at <a href="http://yourls.org/cookiekey.php">http://yourls.org/cookiekey.php</a><br/>
				<em>Example:</em> <tt>'qQ4KhL_pu|s@Zm7n#%:b^{A[vhm'</tt></li>
				<li><code>yourls_user_passwords</code><br/>
				A list of username(s) and password(s) allowed to access the site if private<br/>
				<em>Example:</em> <tt>'joe' => 'mypassword'</tt></li>
			</ul>
			
			<h3>URL Shortening settings</h3>
			<ul>
				<li><code>YOURLS_URL_CONVERT</code><br/>
				URL shortening method: base <tt>36</tt> or <tt>62</tt>. See <a onclick="toggle(this);" href="#FAQ">FAQ</a> for more explanations</li>
				<li><code>yourls_reserved_URL</code><br/>
				A list of reserved keywords that won't be used as short URLs. Define here negative, unwanted or potentially misleading keywords<br/>
				<em>Example:</em> <tt>'porn', 'faggot', 'sex', 'nigger', 'fuck', 'cunt', 'dick', 'gay'</tt></li>
			</ul>
		</div>
		
		<!-- WordPress plugin -->
		<div id="PluginDiv" style="display:none">
			<h2>WordPress Plugin</h2>
			
			<h3>Features</h3>
			<ul>
				<li>Generate short URLs for each new post or page</li>
				<li>Send a tweet on your Twitter account with the post title and short URL as you publish them</li>
				<li>Works if YOURLS is hosted on the same server or on a remote server</li>
				<li>Also compatible with tr.im, is.gd, tinyurl.com and bit.ly for maximum fun</li>
			</ul>
			
			<h3>Screenshots</h3>
			<div class="sshot">
			<img src="http://yourls.org/images/wpplugin.gif"/>
			</div>
			
			<h3>Download &amp; more informations</h3>
			<ul>
				<li>Download <a href="http://wordpress.org/extend/plugins/yourls-wordpress-to-twitter/">YOURLS: WordPress to Twitter</a> from the official WordPress plugin repository</li>
				<li>More information, tips and feedback on <a href="http://planetozh.com/blog/yourls-wordpress-to-twitter-a-short-url-plugin/">the plugin page</a> from planetOzh</li>
			</ul>
		
		</div>
		
		<!-- API -->
		<div id="APIDiv" style="display:none">
			<h2>YOURLS' API</h2>
			
			<h3>Features</h3>
			<ul>
				<li>Generate or get existing short URLs, with sequential or custom keyword</li>
				<li>Get some statistics about your links: top clicked links, least clicked links, newest links</li>
				<li>Output format: JSON, XML, or simple raw text</li>
			</ul>
			
			<h3>Usage</h3>
			<p>You need to send parameters to <code>http://yoursite.com/yourls-api.php</code> either via <code>GET</code> or <code>POST</code>. These parameters are:</p>
			<ul>
				<li>A valid <code>username</code></li>
				<li>A valid <code>password</code></li>
				<li>The requested <code>action</code>: either <tt>"shorturl"</tt> (get short URL for a link) or <tt>"stats"</tt> (get stats about your links)</li>
				<li>With <tt>action = "shorturl"</tt> :
					<ul>
						<li>the <code>url</code> to shorten</li>
						<li>optional <code>keyword</code> for custom short URLs</li>
						<li>output <code>format</code>: either <tt>"json"</tt>, <tt>"xml"</tt> or <tt>"simple"</tt></li>
					</ul>
				</li>
				<li>With <tt>action = "stats"</tt> :
					<ul>
						<li>the <code>filter</code>: either <tt>"top"</tt>, <tt>"bottom"</tt> , <tt>"rand"</tt> or <tt>"last"</tt></li>
						<li>the <code>limit</code> (maximum number of links to return)</li>
						<li>output <code>format</code>: either <tt>"json"</tt> or <tt>"xml"</tt></li>
					</ul>
				</li>
			</ul>
			
			<h3>Sample return</h3>
			<pre><tt>&lt;result&gt;
	&lt;url&gt;
		&lt;id&gt;62019439011&lt;/id&gt;
		&lt;keyword&gt;shorter&lt;/keyword&gt;
		&lt;url&gt;http://somereallylongurlyouneedtoshrink.com/&lt;/url&gt;
		&lt;date&gt;2009-06-23 18:08:07&lt;/date&gt;
		&lt;ip&gt;127.0.0.1&lt;/ip&gt;
	&lt;/url&gt;
	&lt;status&gt;success&lt;/status&gt;
	&lt;message&gt;http://somereallylongurlyouneedtoshrink.com/ (ID: shorter) added to database&lt;/message&gt;
	&lt;shorturl&gt;http://yoursite.com/shorter&lt;/shorturl&gt;
&lt;/result&gt;</tt></pre>

			<h3>Sample file</h3>
			<p>There's a sample file included that serves as an example on how to play with the API</p>

		</div>
		

		<!-- FAQ Instructions -->	
		<div id="FAQDiv" style="display: none;">
			<h2>FAQ</h2>

			<h3>Server requirements</h3>
			<ol>
				<li>A server with <strong>mod_rewrite</strong> enabled</li>
				<li>At least <strong>PHP 4.3</strong></li>
				<li>At least <strong>MYSQL 4.1</strong></li>
			</ol>

			<h3>Server recommendations</h3>
			<ul>
				<li>PHP <a href="http://www.php.net/curl">CURL extension</a> installed if you plan on playing with the API</li>
				<li>PHP <a href="http://www.php.net/manual/en/ref.bc.php">BCMath extension</a> for handling large integers (ie many (really many many) links or long custom keyword URLs)</li>	
			</ul>
			
			<h3>Limitations</h3>
			<ul>
				<li>Maximum length of custom keyword is <strong>12 characters</strong></li>
				<li><strong>4,738,381,338,321,617,846</strong> available URLs</li>
			</ul>
			
			<h3>Difference Between Base 36 And Base 62 Encoding</h3>
			<ul>
				<li>Base 36 encoding uses <code>0123456789abcdefghijklmnopqrstuvwxyz</code></li>
				<li>Base 62 encoding uses <code>0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz</code></li>
				<li>Stick to one setting, don't change after you've created links as it will change all your short URLs!</li>
				<li>Base 36 should be picked. Use 62 only if you understand what it implies.</li>
				<li>Using base 62 means you *need* PHP extension BCMath</li>
				<li>Consider Base 62 encoding a <code>beta feature</code></li>
			</ul>
			
			<h3>Getting a short domain name for your YOURLS install</h3>
			<ul>
				<li>Unless you plan on making it public, any shared hosting should be fine</li>
				<li><a href="http://domai.nr/">Domainr</a> is a fun search tool that might inspire and help you</li>
				<li>Aim for exotic top level domains (.in, .im, .li ...), they're often cheap and a lot are still available. <a href="https://www.gandi.net/domain/buy/search/">Gandi</a> is a pretty comprehensive registrar, for instance.</li>
			</ul>

			<h3>YOURLS needs its own .htaccess</h3>
			<ul>
				<li>You cannot install YOURLS and, say, WordPress, in the same directory. Both of them need to handle URLs differently</li>
				<li>If you want to install YOURLS on the same domain than your blog, give it its own (short) subdirectory, such as yourblog.com/s/ (for "short") or yourblog.com/x/ (for "exit")</li>
			</ul>
			
			<h3>If YOURLS generates 404 for your short URLs</h3>
			<ul>
				<li>Make sure <strong>mod_rewrite</strong> is enabled with your Apache server</li>
				<li>Some (crappy) hosts such as GoDaddy or 1and1 need <a href="http://code.google.com/p/yourls/issues/detail?id=25">a small fix</a> to .htaccess:</li>
			</ul>
			
			<h3>Feedback and bug reporting</h3>
			<ul>
				<li>Please don't get in touch directly by mail or Twitter</li>
				<li>Raise an <a href="http://code.google.com/p/yourls/issues/list">issue here</a> and give all the details. Thanks!</li>
			</ul>

		</div>
	</div>
</div>

<p id="Copyright">YOURLS: Your Own URL Shortener<br />All Free & GPL &ndash; 2009</p>

	<script type="text/javascript">
	/* <![CDATA[*/
	// Dynamically get tabs
	function getTabs() {
		var d = document.getElementById('Tabs');
		var matches = d.innerHTML.match(/<li id="(.+?)Tab"/g);
		var tabs = []
		for (i in matches) {
		  tabs[i]= matches[i].replace('<li id="','').replace('Tab"', '');
		}
		tabs = tabs.reverse();
		return (tabs)
	}
	// Toggle tab display
	function toggle(el) {
		//var tabs = ["About", "Install", "Config", "Plugin", "FAQ"];
		var target = el.toString().replace(/^.*#/, '');
		for (var tab in tabs) {
			// reinit tabs
			document.getElementById(tabs[tab]+'Tab').className = 'Tab';
			// reinit divs
			document.getElementById(tabs[tab]+'Div').style.display= 'none';
		}
		// highlight & display target
		document.getElementById(target+'Div').style.display = 'block';
		document.getElementById(target+'Tab').className = 'SelectedTab';
		el.blur();
	}
	// Get tab list
	var tabs = getTabs();
	// On page load/refresh display required tab
	if (location.hash) {
		toggle(location.hash);
	}
	/* ]]> */
	</script>


</body>
</html>

About

🔗 Your Own URL Shortener

Resources

License

Code of conduct

Stars

Watchers

Forks

Packages

No packages published

Languages

  • PHP 89.5%
  • JavaScript 7.2%
  • CSS 3.1%
  • HTML 0.2%