• Skip to primary navigation
  • Skip to main content
  • Skip to primary sidebar
seegatesite header

Seegatesite.com

Seegatesite.com - Programming Tutorial , Sharing , How and Learn Together

  • TOOLS
    • Bootstrap Navbar Online Generator
    • Customize Sidebar Menu Bootstrap 3
    • Bootstrap Demo
  • ADVERTISE
  • CATEGORIES
    • Android
    • Blogging Tips
    • Database
    • CSS
    • Info Gadget
    • Javascript
    • Linux
    • PHP
    • Various
    • WordPress
  • Q&A
  • PHP
  • JAVASCRIPT
  • JQUERY
  • ANGULAR
  • WORDPRESS
  • SEO
  • REACT
🏠 » Javascript » Tutorial Create A Simple Safelink Converter Website With PHP And JQuery

Tutorial Create A Simple Safelink Converter Website With PHP And JQuery

By Sigit Prasetya Nugroho ∙ February 22, 2017 ∙ Javascript, PHP ∙ Leave a Comment

Share : TwitterFacebookTelegramWhatsapp

Want to make a website like safelinkconverter.com? At this tutorial, I will share a simple way to create the safelink website. The advantage of making the safelink website to increase your internet advertising income and of course google Adsense. If you’re PHP and javascript expert certainly not difficult to create your own safelink converter website.

Safelink is a simple website that will change all the download links that are on your website automatically become a short URL that redirected to the converter website. in the Safelink website will display ads from Google Adsense and the ads you post.

However, the safety of using the Safelink converter on google Adsense, I am not able to guarantee. My advice is better to use pop-up ads (pop ads, pop cash) on Safelink website.

Table of Contents

  • 1 Here’s a simple way to create a Safelink converter website
    • 1.1 Create a link converter script that will change the entire URL on Ahref element into safelink URL
    • 1.2 Create a simple converter safelink website

Here’s a simple way to create a Safelink converter website

Tutorial Create A Simple Safelink Converter Website With PHP And Jquery

Create a link converter script that will change the entire URL on Ahref element into safelink URL

1. Create a folder that will be installed Safelink script with name “blog“. This “blog” folder contains an example HTML page with several links to other sites using the Ahref element.
2. create a file index.php in the folder “blog“.
3. Copy and paste the following code in index.php

Related Articles :

  • My Way To Get Very Low Competition Keywords List From Semrush
  • The Way I Increase Website Traffic On My New Blog from 0 Up To ± 500
  • Using All In One SEO Pack WordPress Properly To Increase Website Traffic

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
<!DOCTYPE html>
<html>
<head>
<title></title>
</head>
<body>
<div>
<a href="http://alexa.com">link1</a>
<a href="http://koplojozz.com">link2</a>
<a href="https://seegatesite.com">link3</a>
</div>
<script src="https://code.jquery.com/jquery-2.2.4.min.js" ></script>
<script type="text/javascript">
var restricted_link = ["seegatesite.com"];
$('a').each(function() {
$(this).attr("href", function(index, old) {
var baseurlarray = old.split( '/' );
host = baseurlarray[2];
if(jQuery.inArray(host, restricted_link) == -1)
{
var base64 = window.btoa(old);
return old.replace(old, "http://localhost/bypass/index.php?go="+base64);
}
});
});
</script>
</body>
</html>

4. A brief explanation

1
var restricted_link = ["seegatesite.com"];

The above variables are used to hold the link that will not convert into safelink URL

1
2
3
$('a').each(function() {
....
}

Jquery function above is used to get the entire URL on a web page.

1
2
3
$(this).attr("href", function(index, old) {
 
.........}

The function above to get the entire href attribute in a HTML element.

1
2
  var baseurlarray = old.split( '/' );
  host = baseurlarray[2];

Surely every URL obtained from the script above is not a base URL, but along with the URL path name. Using the split function, we will take the host name URL / base URL. And javascript will check whether the link is allowed to be converted using jQuery.inArray function as the following code

1
2
3
4
5
if(jQuery.inArray(host, restricted_link) == -1)
  {
   var base64 = window.btoa(old);
return old.replace(old, "http://localhost/bypass/index.php?go="+base64);
  }

As the example above, the safelink website address is http://localhost/bypass/index.php. Variable old is the original URL that we will convert. Then using window.btoa() function. Javascript will encode URL string into base64 encode. Up here the converter safelink script has been completed, the next will make a simple safelink website.

Create a simple converter safelink website

1. Create a new project folder as “bypass”.
2. Add new php file as index.php in the folder “bypass” and copy the following code :

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
<?php
$url = base64_decode($_GET['go']); function file_get_contents_curl($url) { $ch = curl_init(); curl_setopt($ch, CURLOPT_HEADER, 0); curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); curl_setopt($ch, CURLOPT_URL, $url); curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1); curl_setopt($ch, CURLOPT_USERAGENT,'Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.8.1.13) Gecko/20080311 Firefox/2.0.0.13'); if(curl_exec($ch) === false) { echo 'Curl error: ' . curl_error($ch); die(); } else { $data = curl_exec($ch); } curl_close($ch); return $data; } function get_data_web($url) { $array = array(); $basearray = explode("/", $url); $array['baseurl'] = $basearray[2]; $array['description'] = ''; $array['title'] = ''; $html = file_get_contents_curl($url); $doc = new DOMDocument(); @$doc->loadHTML($html);
$nodes = $doc->getElementsByTagName('title');
$array['title'] = @$nodes->item(0)->nodeValue;
$metas = $doc->getElementsByTagName('meta');
for ($i = 0; $i < $metas->length; $i++)
{
$meta = $metas->item($i);
if($meta->getAttribute('name') == 'description')
{
$array['description'] = $meta->getAttribute('content');
}
}
return $array;
}
$data = get_data_web($url);
?>
<!DOCTYPE html>
<html>
<head>
<title>Safelink Converter</title>
<style type="text/css">
table{
border: 1px solid grey;
}
table tr td{
border: 1px solid grey;
padding: 10px;
}
.alink{
margin: 10px;
padding: 10px;
color: white;
background-color: orange;
}
</style>
<link rel="stylesheet" type="text/css" href="https://maxcdn.bootstrapcdn.com/font-awesome/4.7.0/css/font-awesome.min.css">
</head>
<body>
 
<div>
 
<h2><i style="color:green" class="fa fa-shield"></i> You have requested a link to <?php echo $data['baseurl'] ?> </h2>
 
 
<table>
<tr>
<td colspan="3"><center> <span id="contentlink">Generating link <i class="fa fa-spinner fa-pulse fa-fw"></i></span></center></td>
 
</tr>
 
 
<tr>
<td>Title</td>
 
 
<td>:</td>
 
 
<td><?php echo $data['title'] ?></td>
 
</tr>
 
 
<tr>
<td>Description</td>
 
 
<td>:</td>
 
 
<td><?php echo $data['description'] ?></td>
 
</tr>
 
</table>
 
</div>
<script src="https://code.jquery.com/jquery-2.2.4.min.js" ></script>
<script type="text/javascript">
var url = '<?php echo $url ?>';
setTimeout(function()
{
$("#contentlink").html('<a class="alink" href="'+url+'"> Continue to link</a>')
}, 5000);
</script>
</body>
</html>

3. A brief explanation :

I made two functions using PHP. The first function is file_get_contents_curl I use to get the html content from sites who will be converted using safelink script (especially taking title and meta description of a website). The second function get_data_web() is used to process html content and take the title and meta description of web to be visited.

1
2
3
4
5
var url = '<?php echo $url ?>';
setTimeout(function()
{
$("#contentlink").html('<a class="alink" href="'+url+'"> Continue to link</a>')
}, 5000);

Then using javascript setTimeout function set 5 seconds will bring up the link that will be visited.

Up here the script to run smoothly. How to use safelink converter script in WordPress? Paste the code below to widget bar WordPress

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
<script
src="https://code.jquery.com/jquery-2.2.4.min.js"></script>
<script type="text/javascript">
var restricted_link = ["seegatesite.com"];
$('a').each(function() {
$(this).attr("href", function(index, old) {
var baseurlarray = old.split( '/' );
host = baseurlarray[2];
if(jQuery.inArray(host, restricted_link) == -1)
{
var base64 = window.btoa(old);
return old.replace(old, "http://localhost/bypass/index.php?go="+base64);
}
});
});
</script>

Up here how to make the Safelink website has been completed. But how to implement it on Blogspot?

To blogspot many articles you can find on google search engine, but I’ll summarize how to create Safelink website on blogger that I obtained from here

1. Create new Blogspot blog in blogger.com
2. Create a new page and give the name “go“.
3. Add the following script for a while and publish

1
<script src="LINK-JAVASCRIPT" type="text/javascript"></script>

4. Create new javascript file and save as safelink.js

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
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
var Base64 = {
    _keyStr: "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",
    encode: function (input) {
        var output = "";
        var chr1, chr2, chr3, enc1, enc2, enc3, enc4;
        var i = 0;
        input = Base64._utf8_encode(input);
        while (i < input.length) { chr1 = input.charCodeAt(i++); chr2 = input.charCodeAt(i++); chr3 = input.charCodeAt(i++); enc1 = chr1 >> 2;
            enc2 = ((chr1 & 3) << 4) | (chr2 >> 4);
            enc3 = ((chr2 & 15) << 2) | (chr3 >> 6);
            enc4 = chr3 & 63;
            if (isNaN(chr2)) {
                enc3 = enc4 = 64;
            } else if (isNaN(chr3)) {
                enc4 = 64;
            }
            output = output + this._keyStr.charAt(enc1) + this._keyStr.charAt(enc2) + this._keyStr.charAt(enc3) + this._keyStr.charAt(enc4);
        }
        return output;
    },
    decode: function (input) {
        var output = "";
        var chr1, chr2, chr3;
        var enc1, enc2, enc3, enc4;
        var i = 0;
        input = input.replace(/[^A-Za-z0-9\+\/\=]/g, "");
        while (i < input.length) {
            enc1 = this._keyStr.indexOf(input.charAt(i++));
            enc2 = this._keyStr.indexOf(input.charAt(i++));
            enc3 = this._keyStr.indexOf(input.charAt(i++));
            enc4 = this._keyStr.indexOf(input.charAt(i++));
            chr1 = (enc1 << 2) | (enc2 >> 4);
            chr2 = ((enc2 & 15) << 4) | (enc3 >> 2);
            chr3 = ((enc3 & 3) << 6) | enc4;
            output = output + String.fromCharCode(chr1);
            if (enc3 != 64) {
                output = output + String.fromCharCode(chr2);
            }
            if (enc4 != 64) {
                output = output + String.fromCharCode(chr3);
            }
        }
        output = Base64._utf8_decode(output);
        return output;
    },
    _utf8_encode: function (string) {
        string = string.replace(/\r\n/g, "\n");
        var utftext = "";
        for (var n = 0; n < string.length; n++) {
            var c = string.charCodeAt(n);
            if (c < 128) { utftext += String.fromCharCode(c); } else if ((c > 127) && (c < 2048)) { utftext += String.fromCharCode((c >> 6) | 192);
                utftext += String.fromCharCode((c & 63) | 128);
            } else {
                utftext += String.fromCharCode((c >> 12) | 224);
                utftext += String.fromCharCode(((c >> 6) & 63) | 128);
                utftext += String.fromCharCode((c & 63) | 128);
            }
        }
        return utftext;
    },
    _utf8_decode: function (utftext) {
        var string = "";
        var i = 0;
        var c = c1 = c2 = 0;
        while (i < utftext.length) {
            c = utftext.charCodeAt(i);
            if (c < 128) { string += String.fromCharCode(c); i++; } else if ((c > 191) && (c < 224)) {
                c2 = utftext.charCodeAt(i + 1);
                string += String.fromCharCode(((c & 31) << 6) | (c2 & 63));
                i += 2;
            } else {
                c2 = utftext.charCodeAt(i + 1);
                c3 = utftext.charCodeAt(i + 2);
                string += String.fromCharCode(((c & 15) << 12) | ((c2 & 63) << 6) | (c3 & 63));
                i += 3;
            }
        }
        return string;
    }
}
var encode = document.getElementById('encode'),
    decode = document.getElementById('decode'),
    output = document.getElementById('output'),
    input = document.getElementById('input');
var User_ID = "";
var protected_links = "";
var a_to_va = 0;
var a_to_vb = 0;
var a_to_vc = "";
 
function auto_safelink() {
    auto_safeconvert();
}
 
function auto_safeconvert() {
    var a_to_vd = window.location.hostname;
    if (protected_links != "" && !protected_links.match(a_to_vd)) {
        protected_links += ", " + a_to_vd;
    } else if (protected_links == "") {
        protected_links = a_to_vd;
    }
    var a_to_ve = "";
    var a_to_vf = new Array();
    var a_to_vg = 0;
    a_to_ve = document.getElementsByTagName("a");
    a_to_va = a_to_ve.length;
    a_to_vf = a_to_fa();
    a_to_vg = a_to_vf.length;
    var a_to_vh = false;
    var j = 0;
    var a_to_vi = "";
    for (var i = 0; i < a_to_va; i++) {
        a_to_vh = false;
        j = 0;
        while (a_to_vh == false && j < a_to_vg) {
            a_to_vi = a_to_ve[i].href;
            if (a_to_vi.match(a_to_vf[j]) || !a_to_vi || !a_to_vi.match("http")) {
                a_to_vh = true;
            }
            j++;
        }
        if (a_to_vh == false) {
            var encryptedUrl = Base64.encode(a_to_vi);
            a_to_ve[i].href = "http://safelinkweb.blogspot.com/p/go.html?url=" + encryptedUrl;
            a_to_ve[i].rel = "nofollow";
            a_to_vb++;
            a_to_vc += i + ":::" + a_to_ve[i].href + "\n";
        }
    }
    var a_to_vj = document.getElementById("anonyminized");
    var a_to_vk = document.getElementById("found_links");
    if (a_to_vj) {
        a_to_vj.innerHTML += a_to_vb;
    }
    if (a_to_vk) {
        a_to_vk.innerHTML += a_to_va;
    }
}
 
function a_to_fa() {
    var a_to_vf = new Array();
    protected_links = protected_links.replace(" ", "");
    a_to_vf = protected_links.split(",");
    return a_to_vf;
}

Change http://safelinkweb.blogspot.com/p/go.html with your new Blogspot page URL.
5. Upload the safelink.js in yourjavascript.com.
6. See step number 3, change the link-javascript with safelink.js you have uploaded at yourjavascript.com

7. Reopen new page that you created earlier on blogspot (step 2) and add the following script under the javascript that you created earlier

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
<center>
<div class="fitur-body">
Please Wait and Click Continue For Go To Link Target.<br>
<script type="text/javascript">
//<![CDATA[
function changeLink() {
var e = Base64.decode(res);
window.open(e, "_blank")
}
var currentURL = location.href,
str = currentURL,
res = str.replace("http://safelinkweb.blogspot.co.id/p/go.html?url=", "");
document.write('<button target="_self" class="btn btn-success" style="display: block;" id="download" onclick="changeLink()">Continue</button>');
onload: generate();
//]]>
</script>
</div>
</center>  

don’t forget to change http://safelinkweb.blogspot.co.id/p/go.html with your new Blogspot page.

8. Copy the following javascript into the main Blogspot / your blog download so that the Safelink script can work well.

1
2
3
4
5
6
7
<script src="LINK-Javascript" type='text/javascript'/>
<script type="text/javascript">
//<![CDATA[
protected_links = "facebook.com,twitter.com";
auto_safelink();
//]]>
</script>

Change the variables of protected links with a link you do not want to be turned into Safelink website url

9. Edit your main blogspot template Template > Edit > HTML and change <body> to be : <body onload=”auto_safeconvert()”>

10. Save and see the result.

Download the full example  project here

Url : http://wp.me/a65Dpx-G1

Easy, right? Thus my article Tutorial Create A Simple Safelink Converter Website With PHP And Jquery.

Another Javascript Related Post :

  • Adept Using Datatables Plugin In 10 Minutes For Beginners (Tutorial)
  • The Using Of Reactstrap And React-Table, Suitable For Beginners
  • Tutorial Create Simple Block UI Using React JS
  • How To Implement Login Page And Protected Route ReactJS
  • Complete Tutorial React Router Dom For Beginners (Easy-To-Understand)
  • The Right Way Understanding React Lifecycle For Beginners

Avatar for Sigit Prasetya Nugroho

About Sigit Prasetya Nugroho

This site is a personal Blog of Sigit Prasetya Nugroho, a Desktop developer and freelance web developer working in PHP, MySQL, WordPress.

Reader Interactions

Leave a Reply Cancel reply

Your email address will not be published. Required fields are marked *

Time limit is exhausted. Please reload CAPTCHA.

This site uses Akismet to reduce spam. Learn how your comment data is processed.

Primary Sidebar

Welcome to my Home,

Avatar for Sigit Prasetya NugrohoThis site is a personal Blog of Sigit Prasetya Nugroho, a Desktop developer and freelance web developer working in PHP, MySQL, WordPress.



Popular Articles

Checked checkbox AdminLTE Bootstrap in Jquery

November 4, 2014 By Sigit Prasetya Nugroho 7 Comments

Simple create date format validation with jqueryUI

December 21, 2014 By Sigit Prasetya Nugroho Leave a Comment

Create Simple Progress Bar for Fake Online Generator with Jquery

January 10, 2015 By Sigit Prasetya Nugroho Leave a Comment

22+ Coolest Free Jquery Plugin For Premium Theme

October 3, 2015 By Sigit Prasetya Nugroho Leave a Comment

Easy Build Your Anti Copy Paste Plugin

October 6, 2015 By Sigit Prasetya Nugroho Leave a Comment

Popular Tags

adminlte (15) adsense (13) adsense tips (4) affiliate amazon (13) amazon (12) Android (8) angular (16) angular 4 (12) angular 5 (4) asin grabber (3) Bootstrap (27) codeigniter (5) create wordpress theme (5) crud (8) css (6) free wordpress theme (7) google adsense (4) imacros (4) increase traffic (6) jquery (34) laravel (10) laravel 5 (5) learn android (5) modal dialog (5) mysql (6) nodeJs (4) optimize seo (4) pdo (6) php (30) plugin (53) pos (7) Publisher Tips (5) react (3) Reactjs (7) SEO (37) theme (17) tutorial angular (5) tutorial angular 4 (6) tutorial javascript (10) tutorial javascript beginners (4) twitter (3) widget (3) wordpress (18) wordpress plugin (13) XMLRPC (5)




  • About
  • Contact Us
  • Disclaimer
  • Privacy Policy
  • Terms and Conditions

©2021 Seegatesite.com