Tag Archive for url

Get sort url from tinyurl.com

#!/bin/sh

if [ -n "$1" ]; then
url="$1"
else
echo "Error: You must pass a URL"
exit
fi

curl -s <a href="http://tinyurl.com/create.php?url=$" >http://tinyurl.com/create.php?url=$</a>{url} | awk -F" '/name=tinyurl/ {print $2}'

source

URL validationin JavaScript

function isValidURL(url){
var RegExp = /^(([w]+:)?//)?(([dw]|%[a-fA-fd]{2,2})+(:([dw]|%[a-fA-fd]{2,2})+)?@)?([dw][-dw]{0,253}[dw].)+[w]{2,4}(:[d]+)?(/([-+_~.dw]|%[a-fA-fd]{2,2})*)*(?(&?([-+_~.dw]|%[a-fA-fd]{2,2})=?)*)?(#([-+_~.dw]|%[a-fA-fd]{2,2})*)?$/;
if(RegExp.test(url))
return true;
else
return false;
}

source

Javascript URL Redirection…

<script>
var limit="0:05"
if (document.images){
var parselimit=limit.split(":")
parselimit=parselimit[0]*60+parselimit[1]*1
}
function begintimer(){
if (!document.images)
return
if (parselimit==1)
window.location="http://<?php echo $kayit["link"]; ?>"
else{
parselimit-=1
curmin=Math.floor(parselimit/60)
cursec=parselimit%60
if (curmin!=0)
curtime=curmin+" minutes and "+cursec+" Saniye Bekleyiniz.."
else
curtime=cursec+" Saniye Bekleyiniz.."
window.status=curtime
setTimeout("begintimer()",1000)
}
}
//-->
</script>

source

Remove trailing slash from url

RewriteCond %{HTTP_HOST} ^your-domain.com$ [NC]
RewriteRule ^(.+)/$ <a href="http://%" >http://%</a>{HTTP_HOST}/$1 [R=301,L]

or, if you have 'www' part in your domain name, add this instead:

RewriteCond %{HTTP_HOST} ^(www.)?your-domain.com$ [NC]
RewriteRule ^(.+)/$ <a href="http://%" >http://%</a>{HTTP_HOST}/$1 [R=301,L]

source

Email this page

<SCRIPT LANGUAGE="JavaScript">
<!-- Original:  Ronnie T. Moore -->
<!-- Web Site:  The JavaScript Source -->

<!-- This script and many more are available free online at -->
<!-- The JavaScript Source!! <a href="http://javascript.internet.com" >http://javascript.internet.com</a> -->

<!-- Begin
function initMail(form) {
text = "Check out this page:  " + window.location;
form.message.value = "Hi " + form.sendto.value + " (" + form.to.value + "):

"
+ text + "

Your Friend,
" + form.sendername.value + "(" + form.senderemail.value + ")";
return (form.to.value != "");
}
//  End -->
</script>

//////////////////////////////////////////////////////////////////////////////
//include this form content to pages that you may want to show.

<center>
<form name=emailform method=post action="http://cgi.freedback.com/mail.pl" target="_new" onSubmit="return initMail(this);">
<input type=hidden name=subject value="** Check Out This Site! **">
<input type=hidden name=message value="">
<table>
<tr><td colspan=2 align=center>Tell a friend about this page!</td></tr>
<tr><td>Their Name:</td><td><input type=text name=sendto></td></tr>
<tr><td>Their Email:</td><td><input type=text name=to></td></tr>
<tr><td>Your Name:</td><td><input type=text name=sendername></td></tr>
<tr><td>Your Email:</td><td><input type=text name=senderemail></td></tr>
<tr><td colspan=2 align=center><input type=submit value="Ok!"></td></tr>
</table>
</form>
</center>

source

Minimal PHP Controller URL dispatch

<?php
/*

Requires an .htaccess file that rewrites the request to q=, like,
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php?q=$1 [L,QSA]

Now tha I look at it, not sure why I just didn't explode $_REQUEST_URI.

*/

$debug = 1;
$q = explode('/', $_REQUEST['q']);
$module = $q[0];
$op = $q[1];
$debug ? '<pre>'.print_r($q).'</pre>' : '';
$source = 'http://finance.yahoo.com/d/quotes.csv?s=';
$nyse_source = 'http://www.csidata.com/factsheets/nyse.txt';
$nyse_index = 'nyse_index.txt';
$nyse_index_path = $files.$nyse_index;
$files_dir = './files/';
$include_dir = './include/';
$module_path = $include_dir.$module.'.inc';

switch ($module) {

case 'fields':
include $module_path;
//$csvdata = get data for $q[1];
break;

case 'nyse':
include $module_path;

if ($op == 'refresh') {
$new_index = nyse_fetch();
$ret = nyse_compare($new_index);
print $ret;
}
elseif ($op == 'load') {
$ret = nyse_load_db();
print $ret;
}
else {
// for now just redirect
header('Location: <a href="http://www.xyz.com/api/files/" >http://www.xyz.com/api/files/</a>'.$nyse_index);
// in the future print header and read text file
//nyse_send_index();
}

break;

} //close switch

echo 'hello';

?>

source

URLRewriter.NET Regex

<rewriter>

<!-- EXCEPT FOR PREDEFINED DIRECTORIES -->

<rewrite url="~/(.+)/((js|img|css|op|mtn)/(.+))" to="~/$2" processing="stop"></rewrite>

<!-- EXCEPT FOR COMMONLY IMPORTED FILES -->

<rewrite url="^(/.+(.gif|.png|.jpg|.ico|.pdf|.css|.swf|.zip|.js)(?.+)?)$" to="$1" processing="stop" />

<!-- ALL URL WILL BE REWRITTEN  -->

<rewrite url="~/(.+)/(.+).aspx(?(.+))?$" to="~/$2.aspx?site=$1&amp;$4" processing="stop"></rewrite>

</rewriter>

source

Replace a URL with its domain name and create link

preg_replace("/http://([^/]+)[^s]*/", "<a href='$0'>$1</a>", $text);

source

url redirection

RewriteEngine On
rewritecond %{http_host} ^yoursite.com
rewriteRule ^(.*) <a href="http://www.yoursite.com/$1" >http://www.yoursite.com/$1</a> [R=301,L]

source

displaying parameter passed from url

<?php
$something = $_GET['something'];
echo "hello, $something";
?>

source