ad

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.