ad

Friday, 22 May 2015

Mini web based chatting application in PHP - NO database required!

I've been getting couple of requests about a chat application that doesn't require database to work.

Here it is, you may ask what're the requirements and setup to make it work? Well.. None! All you do is upload the file to your server and you're good to go!

So what this script offers; it allows you to chat, that's pretty much it's for sake of simplicity, there's no nickname option, your messages are anonymous unless you decide to tell who you are in chat. This script will delete old messages, for example as soon as there's 25 messages in the file, it will erase em all! No login, not registration nothing, it's as simple as it gets!

Although I must admit it's not the most secure way, but it's what it is, if you're looking for more secure system, try the chatting system in my samforum script. It's a free forum made from scratch in PHP.

Couple screenies?


Files

https://dl.dropboxusercontent.com/u/28490184/webdevtown/mini%20chat%20application%20no%20database%20needed.rar

Share if you like!

Thursday, 21 May 2015

How to spoof referrals tutorial

In this quick tutorial I'll be showing you guys how referral spoofing works and then ultimately give you an example of it in action.

First lemme tell you guys what spoofing is, spoofing it something, that masquerades/changes itself to something else. Or in lay mans terms.. lets say you gotta be 18+ to go to club but cant enter since you're just 17.. your friend has an idea that he can make you look 18+, so what he does is he puts some weird makeup on your face and voila! you're looking just like 18+ dude! It's spoofing! you've made yourself look like something that you're not.

Before we go further, I recommend reading this tutorial. HTTP the very basics

Alright! now lets get some practical example, there's couple types of spoofing, here's some of them. In this particular tutorial we'll be talking about referral spoofing. But before that those who just popped on this tutorial lemme explain what referral is.. and yeah if you read my HTTP the very basics it's gonna be easy as a pie!

You know whenever you open a page, there's data that's send to server, server's basically requesting some data, for example, website address, IP address.. and referral address! referral address is the previous website link, for example, if you've come to this site(www.webdevtown.com) form some forum, site will save that forum's address.

Here's example of couple request headers
Accept: Content-Types that are acceptable for the response.

Host: The domain name of the server (for virtual hosting), and the TCP port number on which the server is listening. The port number may be omitted if the port is the standard port for the service requested.

Referer: This is the address of the previous web page from which a link to the currently requested page was followed. (The word “referrer” has been misspelled in the RFC as well as in most implementations to the point that it has become standard usage and is considered correct terminology)

User agent The user agent string of the user agent

Full list can be found here

So lets continue and.. and get to actual example. For this what you'll need is a server with PHP installed. What we're going to do is, save HTTP referral in a text file. So we know where the hits are coming from.
Here's the code for that.
    //error_reporting(0);
    $referer = $_SERVER["HTTP_REFERER"] . PHP_EOL;
    $opened_file = fopen("referers.txt", "ab");
    if(isset($referer)){
        echo "referer is set";
        fwrite($opened_file, $referer);
        fclose($opened_file);
    }else{
        echo "you aint being referer from any site";
    }
   
    echo $referer;


</br> <a href="index.php"> Click me! </a>


Post this on your webpage, make sure it's .php file. We're also going to download a plugin for firefox so we can send fake referrals! here's the plugin.

Alright, so you've the plugin and the file's been uploaded, lets open the site for first time. Loaded? Now open the referels file it's created on your server.. It shouldn't have anything in, since there was no referral.. now lets open our refcontrol plugin, choose custom and enter in custom referel URL.
spoof, fake referel










Press okay, then okay again and load the page. As expected page will load normally, however! it will show youtube as a referral! Magic!? and if you open referel file it should show www.youtube.com!

You've basically spoofed the referral. Now to make the process automatic, here's what you'll need to do, use cURL extension(little tutorial here) and send random referrals every time page refreshes!  You can even use proxy along with random referral! Here's auto proxy changing script.

Please share if you liked this tutorial!

Monday, 18 May 2015

Force visitors to go through adf.ly link!

Well this little idea come to my mind recently where anyone who visits your website will have to go through adf.ly link to get access to it. It will create a session, to check if user has already visited the site.. if user closes the browser it will make the user go through link again!

How it works.
- Someone goes to your website
- Script will check if they've already clicked on adf.ly link and finished the AD. NOTE: If web browser is closed, script will forget everything and make user go through adf.ly again.

How to use this script.
I've two files, index.php and callback.php, index.php contains the code you should post in your website's main page. Just copy paste the code. Don't forget the PHP tags though. I've also got callback.php file there's not much you need to know about it, if you're a developer have a look.

What changes you need to make for this script to work.
All you need to do is, where it says $adf_link change it to your adf.ly link. And in callback.php file where it says $secret_key change it to whatever key you wish.

For this script to work you need to shrink adf.ly link in a certain way, here's what needs to be shinked.
www.websitename.com/callback.php?secret_ley=your_secret_key Just shrink it!

Once shrinked, just do whatever I said above about replacing the link and key.. and you're done!

Download:
https://dl.dropboxusercontent.com/u/28490184/webdevtown/Adf%20force%20visit.rar

How it works.
- Someone goes to your website
- Script will check if they've already made clicked on adf.ly link and finished the ad. NOTE: If web browser is closed, script will forget everything and make user go through adf.ly again.

How to use this script.
I've two files, index.php and callback.php, index.php contains the code you should post on your website's main page. Just copy paste the code. I've also got callback.php file there's not much you need to know about it, if you're a developer have a look.

What changes you need to make for this script to work.
All you need to do is, where it says adf_link change it to your adf.ly link. And in callback.php file where it says secret_key change it to whatever key you wish.

For this script to work you need to shink adf.ly link in a certain way, here's what needs to be shinked.
www.websitename.com/callback.php?secret_ley=your secret key

Once shrinked, just do whatever I said above about replacing the link and key.. and you're done!
Well this little idea come to my mind recently where anyone who visits your website will have to go through adf.ly link to get access to it. It will create a session, if user closes the browser it will make the user go through link again!

How it works.
- Someone goes to your website
- Script will check if they've already made clicked on adf.ly link and finished the ad. NOTE: If web browser is closed, script will forget everything and make user go through adf.ly again.

How to use this script.
I've two files, index.php and callback.php, index.php contains the code you should post on your website's main page. Just copy paste the code. I've also got callback.php file there's not much you need to know about it, if you're a developer have a look.

What changes you need to make for this script to work.
All you need to do is, where it says adf_link change it to your adf.ly link. And in callback.php file where it says secret_key change it to whatever key you wish.

For this script to work you need to shink adf.ly link in a certain way, here's what needs to be shinked.
www.websitename.com/callback.php?secret_ley=your secret key

Once shrinked, just do whatever I said above about replacing the link and key.. and you're done!
Well this little idea come to my mind recently where anyone who visits your website will have to go through adf.ly link to get access to it. It will create a session, if user closes the browser it will make the user go through link again!

How it works.
- Someone goes to your website
- Script will check if they've already made clicked on adf.ly link and finished the ad. NOTE: If web browser is closed, script will forget everything and make user go through adf.ly again.

How to use this script.
I've two files, index.php and callback.php, index.php contains the code you should post on your website's main page. Just copy paste the code. I've also got callback.php file there's not much you need to know about it, if you're a developer have a look.

What changes you need to make for this script to work.
All you need to do is, where it says adf_link change it to your adf.ly link. And in callback.php file where it says secret_key change it to whatever key you wish.

For this script to work you need to shink adf.ly link in a certain way, here's what needs to be shinked.
www.websitename.com/callback.php?secret_ley=your secret key

Once shrinked, just do whatever I said above about replacing the link and key.. and you're done!
Well this little idea come to my mind recently where anyone who visits your website will have to go through adf.ly link to get access to it. It will create a session, if user closes the browser it will make the user go through link again!

How it works.
- Someone goes to your website
- Script will check if they've already made clicked on adf.ly link and finished the ad. NOTE: If web browser is closed, script will forget everything and make user go through adf.ly again.

How to use this script.
I've two files, index.php and callback.php, index.php contains the code you should post on your website's main page. Just copy paste the code. I've also got callback.php file there's not much you need to know about it, if you're a developer have a look.

What changes you need to make for this script to work.
All you need to do is, where it says adf_link change it to your adf.ly link. And in callback.php file where it says secret_key change it to whatever key you wish.

For this script to work you need to shink adf.ly link in a certain way, here's what needs to be shinked.
www.websitename.com/callback.php?secret_ley=your secret key

Once shrinked, just do whatever I said above about replacing the link and key.. and you're done!

PHP login authentication script without any database

I've been receiving requests from people having issues with databases, connection, table creation.. just the word SQL is enough to scare them. So I decided to create this logging in script, for this script there is no requirements. I haven't documented my code since I wrote it in hurry. Though it's written in object oriented I haven't really done any hashing.

This is how you use it, upload your file, create a text file named admin.txt and put username one 1st and password on 2nd line. Then all you do is, open htaccess file and post this code in, and you're good to go!
<files "admin.php"> deny from all </files>

Code preview
class webdevtowncomAdfAutoLoad{

    static function fire()
    {
        $webdevtowncomAdfAutoLoad = new webdevtowncomAdfAutoLoad;
        return $webdevtowncomAdfAutoLoad;
    }

    public function file_handling()
    {
        $file_path = 'admin.txt';
        $file_read = file($file_path) or die('admin.txt file doesn\'t exist');
       
        $has_user_and_pass = count($file_read);
        if(( $has_user_and_pass <= 1 ) or ( $has_user_and_pass > 2 ) ){
            die('Please make sure you have username and password in your admin.txt file, and they\'re seperated by break, username in one line and password in another.');
        }else{
            $stored_username = $file_read[0];
            $stored_password = $file_read[1];
            if( (strlen($stored_username) > 5 ) and (strlen($stored_password) > 5) ){
                $this->stored_username = trim($file_read[0]);
                $this->stored_password = trim($file_read[1]);
            }else{
                die('Your username or password is too weak. Please open admin.txt file and check it');
            }

        }
    }
   
    public function show_form()
    {
       
        //session is already starting when calling funciton get data from admin file already
        if(!isset($_SESSION["logged_in"])){
            echo "<form method=\"POST\" action=\"{$_SERVER["PHP_SELF"]}\"> 



Download
https://dl.dropboxusercontent.com/u/28490184/webdevtown/loggin%20in%20script.rar

XML with examples for beginners

Lets talk about XML. XML strands for Extensible Markup Language. It's just like HTML, it has tags, however those tags are not predefined, you can make up any tag you wish. XML is used to store data, although you could use HTML for it, it'd be really hard to organize, manage and describe data using HTML tags.

Here's how a simple XML document look like.
<?xml version="1.0"?>
<note>
    <to>Tove</to>
    <from>Jani</from>
    <heading>Reminder</heading>
    <body> Don't forget me this weekend! </body>
</note>


Basic XML structure.
1. XML version declaration.
2. Root element, opening/closing. Also called parent.
3. Child elements and siblings..

So it's,
VERSION DECLARATION
<root opening>
    <child opening1> content </child closing1>
    <child opening2> content</child closing2>
    <more child opening> more content </more child closing>
<\root closing>


Know that all our structure goes inside the root elements and you cannot have more than one root element on a page.

Before we move any further, lemme tell you guys what parent, child and sibling is. We have child that's nested within parent element.
<parent>
    <child>Text</child>
</parent>


Here <root> is parent of <paragraph> and <paragraph> is parent to <sentence>. <sentence> is child of <paragraph>. And those two <sentence> are sibling to each other.
<root>     
    <paragraph>       
        <sentence>This is a sentence</sentence>     
        <sentence>This is another sentence</sentence>
    </paragraph>
</root>


These elements can also have attributes. Attributes provide additional information. Example below we've a <person> which is a parent element, with attribute gender and its value is 'female'.
<person gender="female">
  <firstname>Anna</firstname>
  <lastname>Smith</lastname>
</person>


We've covered the basics, now here's the fun part. You can fetch those information, or allow others to do it, different languages provide different extensions, in PHP we've SimpleXML parser. It allows you to get element name, attributes, text nodes etc..

For example, code below will return an object representation of languages.xml file, you can then iterate through it and display appropriate information,
$languages = simplexml_load_file("languages.xml");

Another practical example would be to load a website that provides content in XML format using file_get_contents() function and use simplexml_load_string() to then loop and get specific data. You then could even post that data on your site if allowed.

Thursday, 14 May 2015

SQL Structured Query Language is EASY - quick introduction!

Hello, I will not bother going into deep shit like its history and whatnot, so let's dive right into it!

Well first and most importantly you need to know what exactly SQL is and what how is it useful. SQL is sort of programming language designed to manage data that is in RDBMS

RDBMS relational database management system is a system designed to retrieve, extract and insert information into database. While doing so it's interacting with database. mySQL is one of the examples.

Database is a collection of organized information, for example, name, last_name, email etc.. You're accessing it using relational database management system(RDBMS)  Here is a list most popular DB engines.

Our data is stored in tables, this is how it would look like. Table is just a set of columns and rows.
database table sql







Column is often referred as field, in picture above there is 4 fields, titel, interpret, jahr and id. And row is also called record.

You may ask, alright now how can this be useful to me? Well it can be pretty damn useful. Lets say you have started working on a site index.php is a page for regular users/guest and premium.php is for VIP members only.. how would you distinguish VIP members from regular ones? Well you can do so by asking them to signup, you would store their username and password in the database.. you could write a registration system, which would use an extension(sqli, pdo etc) to connect to database and then use SQL queries to perform tasks.. you could insert their info, retrieve info to check if user of that name already exists etc.. check if user is VIP when user is logging in.

Let's say we are writing a login system we need to check if information user send us using POST(more about this here) is correct or not. This is what we do.
SELECT username, password FROM table_name WHERE username = $username and password = $password

We are essentially saying SELECT the username and password from the table table_name WHERE username is equal to $username variable AND password is equal to $password variable's value. $password and $username contains the value we received from user.

Lets talk a little more about table because this important.. usually you'd want to create different tables for different kind of information, you don't want to fill a single table with every single piece of info you have. Suppose you are writing a registration system, you would store, username, password, and email in one table and recovery questions in another.. I know this is getting confusing already, here's an example.

Table users:
username|password|email
jon           123456    jon@gmail.com
brown      3643554  brown@gmail.com

Table recovery:
Hm... we need a way to relate recovery questions to each user don't we? if we didn't do it how would we know which question belongs to user.. you could say why not just write username in front of the question.. well we could very well do it.. but then we aren't separating the information or if we're doing it in different table we're repeating information which we don't want. So solve this problem we just add an id field to our users table, whenever we insert anything using INSERT keyword INTO users table we also give it an id which increments automatically.. So changing a bit this is how our users table would look like this time.

Table users:
id|username |password|email
1  jon           123456    jon@gmail.com
2  brown      3643554  brown@gmail.com

Now when we're inserting data in users table we also insert data into recovery table.

Table users:
id                 |          recovery_question            |         recovery_answer
1                             Where were you born?                  usa
2                             Your favorite food?                      rice chicken

We now know that id 1 refers to jon and 2 to brown. We're creating relations here.

You also need to know that in SQL database there's certain data types. If you're storing a name you'd need to give it data type text, or varchar.. for number you'd need to give it integer. The list can be found here.

To finish this off, here's a few examples that will give you a better understand

Saturday, 9 May 2015

Proxy checker 1.0 - Saves working proxies from the list

Proxy checker 1.0
This proxy checker bot will check whether proxies in the provided proxy list are working or not, it will read proxies from proxy.txt file and save working ones in the working_proxies.txt file. This script can be used in combination with my other Proxy visitor 1.0 script. You can sort working proxies using this script and use them in proxy visitor 1.0. You can check proxy visitor here.

Bottom one was my original proxy list, and 2nd from bottom is new working list.




















How to use.
Well there is not much to say, just upload the proxy list and index.php file to your server and you should be good to go. Just make sure proxy's separated by breaks, not by commas. It should look something like this.

Example:
115.238.225.26:80
123.121.99.214:8118
201.209.235.241:8080
83.111.153.254:8081
60.216.225.157:8118
218.204.143.196:8118

https://dl.dropboxusercontent.com/u/28490184/webdevtown/proxy%20checker.rar

Friday, 8 May 2015

Auto proxy visitor 1.0. Visit any website with cURL using proxy and get a new visitor on every refresh!

WeWrote this little class for public use, just provide it with your url, proxy, port and useragent and you're good to go.
Wrote this little class for public use, just provide it with your url, proxy, port and useragent and you're good to go.
Wrote this little class for public use, just provide it with your url, proxy, port and useragent and you're good to go.
Wrote this little class for public use, just provide it with your url, proxy, port and useragent and you're good to go.

Auto proxy visitor 1.0

Well had this little idea,  basically all you do it upload this script on your server and leave it! This will start refreshing your page in the time you have set, it ofcourse will also change your IP address, which means on every automatic refresh it makes, you will get a random visitor. In a sense it can be used to make money, it will drastically increase your impressions. This script can also be easily used to bot sites that pay per visitor, or referrer. Some call it botting.

Now time for business, how to use this script, and it's the easiest part! In the index.php file just edit $seconds, $url and put in working random proxies, and that is all done! Then just upload the script to your server, open page and see it rolling!

Little sample of code.
    //Credits must stay intact
    //Script by s.samiuddin
    //For more scripts and tutorials visit http://www.webdevtown.com
    //If this script is uploaded on any website without credits, it will be taken down.
   
    include("website_proxy_visitor.php");
   
    /****************************/
    ////// Proxies to be used ////
    /****************************/
    $proxy_list = "
           
            211.23.248.22,
            42.159.193.148,
            101.69.199.99
                                   
        ";
   
    $seconds           = 10;
    $url                     = "http://ipchicken.com";
    $port                   = 80;
    $user_agent        = "Mozilla/5.0 (Windows NT 6.1; WOW64; rv:37.0) Gecko/20100101 Firefox/37.0";
   
    $ProxyVisitor = new ProxyVisitor($url, $port, $user_agent, $proxy_list);
?>

<html>
    <head> <meta http-equiv="refresh" content="<?PHP echo $seconds ; ?>" > </head>
</html>


https://dl.dropboxusercontent.com/u/28490184/webdevtown/auto%20proxy%20visitor.rar

IP ban users from your website [Script]

What this script does
I wrote this quick script to ban IP's. It is quite straight forward to use you can, block, unblock user's IP address. If user is banned from accessing the site script will send him to a page notifying them that their IP has been blocked.

How Admin panel works:
This script does not user any admin table to check if user logging in is admin. It first checks by IP, if IP specified in ip_ban.php file matches client IP it will allow access to the page. Note: Access to just page. Then it will ask you for two keys, Key 1, and Key 2, these are the keys that have also been set in ip_ban.php file. You must change these keys to whatever but unique keys, so whenever you try logging in, it will try matching the keys you enter to the ones set in script.

Change IP address(allowed_ip) to your IP address.
    $allowed_ip = "127.0.0.1";
    if($_SERVER["REMOTE_ADDR"] !== $allowed_ip){
        header("location: index.php");
    }


Keys to change
/*********************************************/
//CHANGE THE KEYS!
/*********************************************/
$default_key_1 = "1stkey";
$default_key_2 = "2ndkey";
/*********************************************/
/*********************************************/


How to use
It is pretty simple to use this script, all you need to do is go to phpmyadmin and create a database named whatever you wish, and then import the ip_ban_table.sql file I have provided. Then just connect to database by changing the information in connection_to_db.php file and you are good to go.

Additional info
- To open admin panel go to ip_ban.php
- index.php is our default page, if your site uses different page, or have more than one page, all you need to do is post this code at the top of those pages.
<?PHP
    include("is_ip_banned.php");
?>


Screenies
Banning unbanning panel
banning user ip address



















Admin login








Download
https://dl.dropboxusercontent.com/u/28490184/webdevtown/IP%20ban%20script.rar

Wednesday, 6 May 2015

Beginners tutorial on how to make a basic login script in PHP using PDO extension

As the title says, I will be going through the process of making a very simple logging in system in PHP.
I am assuming you have a basic PHP, PDO and SQL knowledge, but even if you do not, I will be explaining every step in layman's terms. If you still do not understand something, feel free to email me or simple leave a comment below.

For this script to work, you will obviously need a table that contains registered users information, such as username and password, and of-course a primary key column - user_id in our case.

My table(registered_users ) is structured like this. 
user_id      ||      username      ||      user_password
1               |       phpdevsami     |      123456
2               |       brown24         |       5656kilo

Here is an overview of what we will be doing.
  1. We will first of all check if a session exists or not, it the session exists, which also means user is logged in, we will not show and form, on the other and if session does not exist, we will display the form. Basically you do not want to show the form if user is logged in.
  2. Our form will send data to "process_login.php" file. In this file we will check if user has submitted the form, whether fields has been filled, and finally we will send username and password to database and try matching it against the already existing information in the database.
  3. Finally if we find matched information in step 2 we will create a session and direct user to homepage.

Explanation:
POST[] is an associative array that contains all the data that's posted from a form. More about POST and GET method on my other tutorial. 
session_start() function will start the function. Session is a simple way of storing information into a variable that will be available across multiple pages. Session is not stored in user computer but in a server with unique session ID. 
session_destroy() function ends the session.
isset() function checks if variable is set and is not NULL.
$_SESSION[] is an array, you give it a name and value, which can then be accessed on other pages.
include() function includes a desired file to current page.
empty() function checks if the variable has any value or not.

Our files:
index.php
process_login.php
process_login.php
logout_user.php

Lets start with index.php, it does exactly what I mentioned in step 1.
    session_start();
    if(!isset($_SESSION["logged_in"])){
        include("login_form.html");
    }else{
        echo "Hello, " . $_SESSION["logged_in"] . "</br>";
        echo "<a href=\"logout_user.php\"> Logout </a>";
    }


Here's our login form from login_form.php. Just a basic HTML form.
        <form method="POST" action="process_login.php">
            <label for="username"> Your username: </label>
            <input id="username" name="username" type="text" required > </br>
           
            <label for="password"> Your password: </label>
            <input id="password" name="password" type="password" required> </br>
           
            <input name="login" type="submit" value="Login" required>
        </form>


process_login.php processing all the information, making requests to database and checking if user and password exist in the database. Creating session if they do, showing message if they do not.
class Process_login
    {
        function __construct($conn)
        {
            $this->conn = $conn;
            if(isset($_POST["login"])){
               
                if( (!empty($_POST["username"])) && (!empty($_POST["password"])) ){
               
                    $username = $_POST["username"];
                    $user_password = $_POST["password"];
                   
                    $select_data = $this->conn->prepare("SELECT username, user_password FROM registered_users WHERE username = :username and user_password = :user_password");
                    $select_data->execute(array(':username'=>$username, ':user_password'=>$user_password));
                    $select_user_and_pass = $select_data->fetch(PDO::FETCH_ASSOC);
                   
                    if(!empty($select_user_and_pass)){
                        session_start();
                        $_SESSION["logged_in"] = $username;
                        header("location: index.php");
                    }else{
                        echo "Wrong username or password </br>";
                        echo "<a href=\"index.php\"> Try again </a>";
                    }
                }else{
                    echo "Please fill in all the fields";
                }
            }
        }
   
    }
    $process_login = new Process_login($conn);


And finally logout_user.php, ending the session. Logging user out.
    session_start();
    if(!isset($_SESSION["logged_in"])){
        echo "To logout, you'd need to login first, <a href=\"index.php\"> login here </a>";
    }else{
        echo "You've been logged out " . $_SESSION["logged_in"] . "</br>";
        echo "<a href=\"index.php\"> Return to homepage </a>";
        session_destroy();
    }


Allow people to download your content with ease! Just upload and you're done!

Sometimes you want to just drop it into your website directory and allow people to download the files. Well this is exactly what this script will do. All you have to do is, make a folder named "uploads", write this in  your main file(ofcouse upload the "dynamic_download_class.php" file too),
include("dynamic_download_class.php");
$show_files = new Show_files("uploads");


..and you're good to go. I uploaded a few file to give you an idea of what this script does exactly.












I uploaded couple files to my "uploads" folder and it started displaying those files while allowing them to be downloaded by users.

Download:
https://dl.dropboxusercontent.com/u/28490184/webdevtown/dynamic_download_class.php

Monday, 4 May 2015

Detect user's country and redirect them to a different site or page in PHP

This a simple script that finds user's country based on their IP and shows message or redirects them. This script uses a service called geoPlugin.

This is how you would used it. I have provided with one file, "country_checker_class.php", all this file does it gets users IP and returns message or sends a header back. Now if you scroll down a little you will see an array with couple country names, these are the names that will be allowed to view your website. If a name does not exist in that list, user will be shown a message.

Array
    //***************************************************//
    //Add the countries that are allowed to array.
    //Last item in array will have no comma at the end.
    //***************************************************//
    $countries_allowed = array(
        'United states',
        'united Kingdom',
        'india'
    );


Now if you do not way it to show message but redirect user to a different page, all you have to do is check for the function "show_allowed_or_not()" and at the bottom part where it says return change it to, header("location: your url");  And you're good to go.

Like so:
        function show_allowed_or_not(){
            $ip_address = "90.192.168.54";
            $data = file_get_contents('http://www.geoplugin.net/php.gp?ip='.$ip_address);
            $data= unserialize($data);
            $data= strtolower($data['geoplugin_countryName']);

            $result = in_array($data, $this->countries_allowed);
           
            if($result){
                return "Country allowed";
            }else{
                header("location: http://www.google.com");
            }
        }


Finally you should just include the country_checker_class.php" file to your main file(index.php usually) and it's all done!
include("country_checker_class.php");

Download the script:
https://dl.dropboxusercontent.com/u/28490184/webdevtown/country_checker_class.php

Saturday, 2 May 2015

Free content locker script, get PPD downloads!

Well there has been people requesting me to make a script that's similar to a content locker. So here it is.

User tried inserting random key, without actually getting it from PPD download link.
download pdd files content locker script make money











 
User finished the survey and inserted the right key. Download unlocked
unlocker survey ppd














And this is how it will work, it's quite simple actually. All you need to do is, generate a random string, and paste it in a file and upload that file to your PPD site. Next you're going to open index.php file and edit all the information, website_title, survery_link, file_name, key and hidden_file_url.

First two are obvious, 3rd one is file name of the file that user is trying to download. It can be anything, like runescape_account_gold_generator.exe or make_money.pdf.. 4th is the key you put in the file that you uploaded to PPD. and 5th is the actual download link where user is send to, to download the actual file.

Here's an example.
$website_title                = "Free premium content!";
$survey_link                  = "http://www.ppd_site.com/survery.php";
$file_name                    = "Amazon_auto_generator.exe";
$key                             = "guk45009suk@67857987tuk6895464nuk56@65465puk";
$hidden_file_url            = "http://www.megashare.com/Amazon_auto_generator.exe";


Download
https://dl.dropboxusercontent.com/u/28490184/webdevtown/content%20locker%20by%20webdevtown.rar

Friday, 1 May 2015

Namespaces explained

Name is a name that belongs to a certain class. Space is the space certain class is in. For example, you have two drawers, one's yours and another one your brother's. Now you both put your stuff in there, your watch, mobiles, pens storage devices etc.. One way to know which drawer belongs to who is to memorize its position, you could say my stuff is in the top drawers and your brother's in the bottom one.

Another and better way is to label them, you put your name on the first one, your brother puts his on his. That's essentially what namespace is in programming. You label your classes.

Have a look at this structure.
classes/html_parser_class.php
classes/captch_class.php
classes/validator_class.php
classes/login_parser_class.php
classes/jp_graph_class.php

You are working on a project that requires following classes, now imagine for a moment that "html_parser_class.php" has a class named "ShowTheData" but so does "jp_graph_class.php". What happens if we instantiate both of the class? A fatal error will display saying cannot redeclare (classname) in file you are trying to instantiate it in. All this hassle because both classs have same class name.

Imaging you are working on a class of your own and want to name it "ShowTheData", well unfortunately you can not, PHP will get confused and tell you that you cannot redeclare the class, even though your new class displays something completely differently than other two classes.

To solve this problem we label our classes. We go to our class file and user "namespace" keyword, with a label name. Like so:
namespace admin_login;

We go to every class file and label it.  Now when we want to instantiate it we use, new keyword, our label name, backslash and the classname, like this:
$admin = new admin_login\Admin;

If you do this with every class you write, give it a label you can have same name
for different class without any issue.