ad

Thursday, 31 December 2015

Complete Batch Programming tutorial For Beginners

Batch?
For those wonder what batch is, it's a list of commands for DOS(Disk operating system). It's mostly used to automate windows tasks. It's also a great way for beginners to get started with fundamentals.

How do I create a batch program?
Createa new Notepad document and Save it with .bat extension. All our code will go here. To run, we simple double click open it. If you saved it with right extension, notepad icon should be changed to this.

Now whenever you run this file, it will open CMD and run it.

Lets create our first program
Edit batch file, type "echo Hello world" without quotations and save it. 'echo' command will output/write whatever you write in front of it on CMD screen. Go ahead and open it. You'll notice that CMD opened and closed itself without you having a change to look at the message. Edit the batch and type 'pause' command in new line. Save it and open the batch file again. You should now see your message.

Wait my screen looks a little different than yours, right? While I only see 'Hello world' and 'Press and key to continue..' you also see directory and the command 'echo' you wrote in the batch file? Edit batch file again and this time add '@echo off' at the top, this command will hide the command and show you the result only.

How do I change my program title from C:\Windows... to something nicer?
Use 'title' command with whatever title you want in front of it. For example, 'title Hello world Program'. Here's what I currently have in my program you should understand every bit of it.
@echo off
title Hello world Program
echo Hello world
pause


'title' command in action.


How do I change text or background color?
Use 'color??' command where first '?' means background color and second '?' is foreground color. You might wanna try 'color redgreen' or 'color blue red', go ahead and give it a try. Here's what you'll see, an error! but that's not all CMD also tells you how to use 'color' command.

It tells us to use number instead of color name, so lets try red background and black foreground. Go through the color list and here's what our complete command looks like, 'color 40'.

Here's here's our complete code:
@echo off
title Hello world Program
color 40
echo Hello world
pause


Here's it in action


So you want to see the list of files and folders in a directory?

Assume you wanna see everyting in 'C:\wamp' directory. The command is 'dir' and directory path, or just directory name if you're in a same directory. Here's list of files I've in this directory.


Now lets use 'dir' command to see all the files, edit batch file and put 'dir C:\wamp' note that you should choose different path than mine. Here's command in action.


Variables(VERY IMPORTANT)
Lets say you want to store number 10. You can store it in a variable, variable's like an empty box where you store different values. For example to store number 6 in a 'box' variable you do, 'SET box=10', now box vairables has the value of 10 and to test it out, try 'echo box' you will see it print 10. It it doesn't work make sure there's no space between box and 10. By the way, variables name can me almost anything.. Not to mention you can also store text/string inside a variable like, SET name=jon

Code:
@echo off
SET box=10
echo %box%
pause

or
@echo off
SET name=jones
echo %box%
pause 


Lets run it


continued
http://www.webdevtown.com/2016/01/how-to-loop-in-batch-programing.html

Sunday, 27 December 2015

./composer.json does not contain valid JSON SOLVED

So I was trying to install PHP Google API library using composer. Here's Google official page that gives instructions about installing the library, the first method is using composer and second's cloning git repository. I thought I'd use composer, so I switched to my project directory, created composer.json file and pasted this JSON code as shown on google official page..
"require": {
  "google/apiclient": "1.0.*@beta"
}
    
..and executed the command 'composer install'.. and guess what? it's showed me this error:
   [Seld\JsonLint\ParsingException]
  "./composer.json" does not contain valid JSON
  Parse error on line 1:
                "google/apicl
  ---------^
  Expected one of: 'EOF', '}', ',', ']'


I searched on Google but nothing, I checked with couple of my buddies, nothing..though one of them suggested I paste that JSON string on http://jsonlint.com/ apparently it's poorly written JSON and composer wont run it due to missing  { }.

If you ended up cloning Git repo, good for you, but if you're still trying to figure it out here's working string.
{
    "require": {
      "google/apiclient": "1.0.*@beta"
    }
}

Wednesday, 9 December 2015

2 Minute Tutorial - Remove Duplicate Lines with Notepad ++

1. You should notepad ++ installed with TextFx plugin. To download textFx open notepad++ go to Plugins tag > Plugins > Plugins Manager. When there type Press T on keyboard and look for textFx and install it.

2. Now you've textFx installed select textFx tab, click on 'Sort Output only UNIQUE (at column) lines'.

3. Now select all your data(Contro A), and go back to textFx, then click on 'Sort lines case sensitive (at column)', it's the first option.

You're done!

Monday, 7 December 2015

Who else want a free profitable Niche?

'Someone please help me find a niche' is one of the many frequently posted questions on forums. People want to make thread or sell products that're popular on forums and the easiest way to find out what's popular on fourm is to check out their tags page, tags page checks what's most popular on forum and creates that tag bigger than others, so you pick that topic and start your Niche. Note that this can be misleading sometimes, it's based on tags that user manually adds to their threads.

Examples:
www.codernation.net/tags
http://www.codingforums.com/tags/
www.thebot.net/tags
https://a2s.in/tags/
http://www.warriorforum.com/tags/

Friday, 4 December 2015

Get tons of twitter followers without paying a dime!

We all know how useful social plateform are for marketing these days, but just plateform isn't enough, you'll need a following so whenever you talk about something world will see it. That's what this tutorial's about, cutting corners and getting a huge following!

Proof(..in 5 minutes):
[​IMG]
That's basically equivlent to 18 twitter followers if you use 6 points to get 1 follower.

Prerequisites 1.0
- Firefox
- Download iMarcos
- Download script
- Twitter account
- Youlikehits account
- Twitter Profile details all filled
- A computer that's not in use when script's running.

Prerequisites 1.1
- Go to where iMarco's been installed and create a folder named liker, and put the liker.js file you downloaded. In my case the iMarco folder was in C:\Users\webdevtown\Documents\iMacros

Idea:
We're going to use website called 'youlikehits' where you earn points to follow others, and use those points to get yourself followers, the more points you offer to others, the faster you'll be followed.

Method
- Open firefox and click on 'iOpus iMacros' on the top right side near bookmarks.
[​IMG]

- An interface will open on the right hand side, click on 'Manage' tab, then 'Settings' then select 'liker' folder path.
[​IMG]


Now go back to youlikehits and on the left hand side click on 'Twitter Followers'.
[​IMG]

When clicked on 'Twitter followers' you'll see this:
[​IMG]

Now click on iMarcos menu make sure you've 'liker.js' selected, if favorites did not update ever after you changing the path go back to 'Manage' tab and click 'Refresh Macro List'.
[​IMG]

And finally being on 'Twitter followers' page, click the play on iMarco, when you click the play button, script will automatically start following users, so sit back and enjoy fruit or our hard labour! ; )

Bonus tip
To get followers faster, go to 'Twitter Follower Setting' page and set the 'Points' to highest. I've at 6 right now, which's not the highest but in the middle.
[​IMG]

Please follow the tutorial and let me know if you've any questions ; )

Sunday, 29 November 2015

Introduction to PHP programing for complete beginners

Hello these everyone! in this this little tutorial I'll be giving you all an introduction to PHP programming.

Prerequisites:
- None

What tools you will need:
- Computer
- Web browser
- Text editor

What you'll be learning:
- What's PHP and why you want to learn it
- What's a server
- What's database server and how it works with PHP
- Why's HTML necessary for PHP programmers

1. What's PHP?
- PHP's a interpreted(means it's run without the need to compile) high-level(basically high mean easy, low mean hard. psst! gurus don't bother arguing!).

Here's a little a little pyramid from webomedia on high/low level languages
[​IMG]

Basically a low level language is something very close to what your machine understands, and high level is where most of the work's already done, you don't really need to understand what's going on and is very different than what machine understand. Another good example of high level is python.

Why do I learn PHP?
PHP is one of the languages you can use to interact with server. You can build application that work on the backend processing information that came from client(you). Don't forget PHP still is used in millions of servers! don't let people tell you PHP's getting old.

What's a server?

Server's a computer with some software installed that can interact with client when requests are made. When you write a website name is address box and press enter, a request to server is sent, server then decides what to do with that requests. Should it be denied? should user location be redirected, should it pass info to PHP module? A commonly used server is Apache!

What's a database server?
Database server is just another server installed on a computer, which interects with apache. For example, if you open google.com apache will run index.php file, from there index.php file will take over. It can either process whatever it needes itself or it can use SQL extention to interect with database, fetch info off there and return it to client or do whatever it needs to. Here's a little screenshot form daniweb.
[​IMG]

What does PHP programmer need to know HTML?
HTML is a markup language which helps end user transmit data to server. A good example is forms. Whenever you press login button, your data is sent to PHP server through POST(it's just type of request, another basic request is GET, when you type www.google.com in addrss bad, get request is made). Though you don't need to be wizard basic HMTL is really needed.

Tricky part for beginners!

Your computer is also called client, it's in front of you. But the server you're making requests to is not, it's on cloud. Cloud basically means it's located somewhere. But it's still a computer. No magic here. Now thing about PHP is as I said it's a backend language, it runs in the server. NOT ON YOUR COMPUTER! PHP processes everything on the server.

I don't have server, how do I run PHP do I need to invest money?

No you do not, you can use local server, means you turn your computer into a server and run PHP! WAMP is a server you can use for windows. You basically installed it and open localhost to run whatever PHP you have.

Okay now go to C drive(could be different) > Wamp > www and create a file named index.php. Remember whenever you load the page index.php will automatically load. It's just default server(apache) setting. Alright with index.php created open your browser(localhost), type hello world in index file and save it. Reload you browser and you should see hello world message?

Guess what's happening right now? Basically for server to know you're running PHP you're required to have PHP code inside <?PHP ?> tags, whatever you do not type inside <?PHP ?> tags will run by your browser not server! lets try again <?PHP echo 'Hello world' ?>. Here's another tricky part. Whatever's inside PHP tag runs on server, by the way whenenver you are writing piece of text, it has to be inside quotation, 'text', it's also called string and echo means you want to print it to screen. So we run PHP code, now when it comes to echo, it will return that hello world piece of string to browser and browser it show it.

Alright now understand PHP were can I learn more about it?
PHP.net

If you're still reading, let get down some basic programming stuff.

What's a variables?
Variable's a an empty box, where you store stuff. For example, $x = 10; means you're storing 10 inside x, so if you go ahead and type echo $x; you'll see 10. What about echo $x + $x; ?? you'll see 20!

What's a string?
String's a piece of text and has to be inside quotation marks or you'll see error. What if you wanna store someone's name inside variables? $name = 'jon'. That's about you do.

What's an array?
An array is just like a variables but you an store multiple values inside it. For example, $x = []; Remember that braces, put multiple values inside it. $x = [10, 20, 'jon'], see you can put number aswell as string? you can also put in different data type, like boolean, object. Boolean's just true of false by the way. Also so what if we wanna show that array data on screen? Well lemme tell you this, each value in the array is represented by a number 0 , 1, 3, 4 etc.. so 1'st value is represented by 0, send, 2nd by 1 and so on.. so to show 1st value we do echo $[0];

Whats loop?
Wanna write something 1000 times on screen? well you could very well do echo 'someting', echo 'something' 1000 times... but if you use loop you could make it repeat 1000 times. Here's syntax for basic loop.

What's if confition?
If conditions are used to check if something is equal to something or if something's smaller than something or if something has a value and whatnot.

What're functions?
Suppose you wanna create a machine and whenenver you put water in it boils it! function's pretty much something that does same task over and over agan whenever you run it. We could have a function that when given 10, print 10 times table. It's used to organize code. One commonly used function is PHP is empty(); it checks if variables you're providing in is empty or not. Basic syntax or function is funcName(paramater).

Basic loop in PHP
[​IMG]

Basic funciton is PHP
function hi(){
echo "hi";
}

continued..

Saturday, 14 November 2015

Paid web based proxy visitor!

Basic proxy visitor writte in PHP, allows you to fake useragent and referal.


Referals test:













Useragent and IP test:

Usage is pretty simple. Open proxy file and put proxy with port. One in each line. Open useragent file
and put useragent in double quotes, one in a line and do same with referal, no quotation is needed for referals, just one in a line









Then open index.php and update website variable with your website











At the bottom of page you will see what what proxy, referal and useragent is being used:




And finally upload the files to server! make sure you've curl enabled!
 
Price: $2 BTC only 1HbakPHgjY9sBAHudouVh31SixjhVyVdSt
Free now: http://bit.ly/1N6tDYy

Friday, 13 November 2015

Basics of automation with Javascript

I personally advice against botting. Tutorial for educational purpose only!

I'm show ya guys how to do three basic stuff.
1. Fill a form
2. Accept terms
2. Click submit button

Lets take this paidoffers website as an example http://www.paidoffers.co.uk/


See that signup button? lets click it using javascript, but before that make sure you've inspect element on! Right click anywhere, inspect element! for chrome you ask? figure it out yourself... please?

Alright next step:
We gonna select documenet then select that button, but to select the button we need its ID! go over the button, inspect element and see if you can see its ID.


See easy stuff! now lets select that,
document.getElementById("signup_button").click();

Oh shit! it actually clicked the button! thats right! Now we're here at the buttom and we need to fill that, hard? no way!



Now against same thing.. we need to get the IDs so we can fill it! .value method represents the value insite it.


document.getElementById("fullname").value="jones michael";
document.getElementById("email").value="jonesmichael@gmail.com";
document.getElementById("newPassword").value="123456789";
document.getElementById("newPasswordRepeat").value="123456789";


Alright that's getting too repetitive! lets move on. We need to check that checkbox too don't we? right to check the box we'll need to change the check property. To change checked property we target the element like usual, the target it's property .checked and set it to true? pretty damn simple huh?

document.getElementById("tos").checked = true;


Lastly we find the signup button ID and hit it!
document.getElementById("signup_button_b").click();

Alright guys! we're done make sure to share this tutorial if you liked it!

Block unwanted users from your website with apache

It doesn't take very long before some users start becoming a problem for the website itself.. to get rid of these type of users you can ban them by IP - ofcourse they can hide behind proxy, but here's an ways to block users from your website, for this you need access to .htaccess file. Most host give you the access, if you don't see no file, create one! .htaccess is a configuration file for apache! don't confuse it with php.ini file which's for PHP.

Type this in .htaccess file and restart your server(if it's localhost) if it's up in cloud just refresh the page for test!

deny from all IP.AD.D.RE.SS
 
And you're done! MAGIC!? To ban multiple IP's you can repeat the statement.

Wanna see it in action? Here:
[​IMG]

What about trying it on localhost? Save .htaccess file with this:
Deny all from 127.0.0.1

Detect Proxy with one line of code!

There's an eays to to detect proxy by making HTTP request to sites that have open API.

For exam this site http://check.getipintel.net/check.php?ip=IP_address takes IP address as a get ip parameter's value and returnd the likelyhood of it being proxy.

For example, I'm using a proxy on purpose to see what it returns.
http://check.getipintel.net/check.php?ip=166.62.97.241

If it returns 1, it's definitely a proxy, if it returns 0, it's a regular address and if it returns something in middle, for example, 0.08 there's chances it's a proxy too! and what about 0.5? right! we really cant tell in that case.

Good part about it is you can check user for proxy in your applications and take a decision whether to allow him or not.

You can read more about it on their offical website
http://getipintel.net/

Update. Thanks to Stewart for adding good reason why you'd want to use it.
1 - Protect your site from automated XSS / SQL Injection / Brute Force / Crawlers that steal your content -- Well that's just a load of crock since they don't use proxies. Also hackers tend to go via infected computers and not proxies

2 - Serve traffic / content to real users, not bots, which reduces server load (bot detection) -- Again bots run from their own servers not via proxies

3 - Stop bots from scraping your content or bots spamming your website -- See the previous two responses

4 - Prevent trolls / people that are trying to bypass a ban -- True but then it doesn't stop dynamic IP address allocation nor just going to shops and using the countless free WiFi spots available

5 - Greatly reduce fraud on e-commerce sites (anti-fraud) -- Again not really

Collect & Validate User Emails for marketing

A simple lightweight script that allows you to collect user emails by simply locking any content that user may be after. Simply post a preview of content on the front page and link it to locked page and watch valid email addresses roll in!

It's pretty simple to use:
1. Persuade user:
[​IMG]

2. Collect the mail
[​IMG]

Make sure email's valid
[​IMG]

User clicks the email(verifying email's valid) and gains access to premium page:
[​IMG]

You can also set email info in locked.php file:
[​IMG]

In index.php file you can set page info, it's best to spend some time here to persuade user:
[​IMG]

In key_checker.php file you can set the dowload link or you can display an help page with more info as desired:
[​IMG]


Price: $3 BTC 1HbakPHgjY9sBAHudouVh31SixjhVyVdSt
Free now: http://bit.ly/1IzPHfu
little script I wrote to collect user emails. It's pesuading user and collectig their emails.
Requiremets are PHP installed server.

It's pretty simple to use:
1. Persuade user:

2. Collect the mail

Make sure email's valid

User clicks the email(verifying email's valid) and gains access to premium page:

You can also set email info in locked.php file:

In index.php file you can set page info, it's best to spend some time here to persuade user:

In key_checker.php file you can set the dowload link or you can display an help page with more info as desired:

Demo:

Price: $3 BTC 1HbakPHgjY9sBAHudouVh31SixjhVyVdSt
You get any help you may need to set it up.

Saturday, 7 November 2015

Basic Linear Search Algorithm for web scraping and many other stuff

Basic Automation Algorithm

There's plenty of techniques used in bots automation, they use different tricks and technique but the most common one is called Linear search. It's also quite useful in web scraping.

Imaging you've a page and you intend to search for certain word. Your first step would be to either convert it to array or some organized format so it can be manipulatedThere's plenty of techniques used in bots automation, they use different tricks and technique but the most common one is called Linear search. It's also quite useful in web scraping.

Imaging you've a page and you intend to search for certain word. Your first step would be to either convert it to array or some organized format so it can be manipulated
There's plenty of techniques used in bots automation, they use different tricks and technique but the most common one is called Linear search. It's also quite useful in web scraping.

Imaging you've a page and you intend to search for certain word. Your first step would be to either convert it to array or some organized format so it can be manipulated.
Basic Automation Algorithm

There's plenty of techniques used in bots automation, they use different tricks and technique but the most common one is called Linear search. It's also quite useful in web scraping.

Imaging you've a page and you intend to search for certain word. Your first step would be to either convert it to array or some organized format so it can be manipulated.
Basic Automation Algorithm

There's plenty of techniques used in bots automation, they use different tricks and technique but the most common one is called Linear search. It's also quite useful in web scraping.

Imaging you've a page and you intend to search for certain word. Your first step would be to either convert it to array or some organized format so it can be manipulated
 
 
 
 
Imaging you've a page and you intend to search for certain word. Your first step would be to either convert it to array or some organized format so it can be manipulated. There's plenty of techniques used in bots automation, they use different tricks and technique but the most common one is called Linear search. It's also quite useful in web scraping.

//Basic function declaration.
//Accepts two arguements, $array that we'll search in, and $target_word we wanna search for.
function find_word($array, $target_word) {
   
    // Here we being our basic for loop. We start 1 to 0, until i reaches arrays length, then we increment i
    for(var $i = 0; $i < $array.length; ++$i){
       
        // While looping it checks where $array[$i] <-- $i here represents a number that started from 0. And the whole expression
        // represents first array value. It it loops again, i will have value of 1 $array[1] will respresent 2nd value of array.
        // Then it checks if $array[$i] is equal the word we're looking for, if it finds the word, it will return the index or array position
        // where it was found
        if ($array[$i] == $target_word) {
            return $i;
        }
       
    }
   
    // If loop fails to find the word, it'll return -1, means it couldn't find the word.
    return -1;
}

find_word(["jon", "tom", "brown", 1, 0], "borwn");

Tuesday, 3 November 2015

How not to get your website hacked

The two most common type of attacks are:
  • SQL injection
  • XSS

SQL Injection(Senario):
  • Hacker can get access to premium section of the website
  • Can drop Database
  • Can echo all the data on screen
  • Can obviously steal confidential data and misue it
Picture from IBM

Prevention
Use PDO extention when making queries.
The PHP Data Objects (PDO) extension defines a lightweight, consistent interface for accessing databases in PHP. Each database driver that implements the PDO interface can expose database-specific features as regular extension functions. Note that you cannot perform any database functions using the PDO extension by itself; you must use a database-specific PDO driver to access a database server.

PDO provides a data-access abstraction layer, which means that, regardless of which database you're using, you use the same functions to issue queries and fetch data. PDO does not provide a database abstraction; it doesn't rewrite SQL or emulate missing features. You should use a full-blown abstraction layer if you need that facility.


XSS(Senario):
  • Hack can steal other uses' cookies
  • Can change website look for all other uses
  • Can direct user to similar looking website
  • Can do pretty much anything that you would do with Javascript 
 Picture from moz.net

Prevention
Escape everything that you get from user, and escape everything that you display to user. This suspicious code will fail to directly execute on the browser. 

Tip: Always Encrypt your data. There's chances you may get hacked even all the preperation. You never want to give hacker access to pain data format.

Monday, 26 October 2015

PHP snippet | Format POST Array

I wrote this little functions to dumb your POST array data into a nice little table. Post associate array can be a little confusing for someone who is just starting out, if ya wanna check your submitted data in formatted table call the function dump_data();

Before:


After:



https://github.com/phpdevsami/Show-post-data-in-a-clean-table

Saturday, 24 October 2015

PHP Script | Store all $_SERVER variable data into database and retrieve


This script will stores all the data that resides in $_SERVER variable into one field in databse which can be retrived as a regular array


How to use:
To use this object instantiate the Server class and pass the required parameters. Required parameters are: ($database_object, $table_name, $field_name). This object offers two method, one to save data to databse, another to retrived saved data.

Requred variables: 
  • $id variable takes the column you are selecting.  
  • $datbase_object takes the databse object that is from database connection.
  • $table_name takes the name of the table that you want to select data from.  
  • $field_name if the name of the field in table where the server information will be or is stored 

Methods:
  • save_data() method will return true or false if data fails to insert into server, like $_Server->save_data();
  • get_data() method will return the exact array that was saved in database, from where you can either loop through it or get each value using its key like, $Server->get_data()['HTTP_HOST'] This method requires and arguement $id 

Storage:
storing server variable in database


 
Retrieval:
php array unserialized






https://github.com/phpdevsami/Store-SERVER-array-into-database
https://dl.dropboxusercontent.com/u/28490184/webdevtown/store%20server%20into%20db.rar