Tuesday, March 22, 2011

Chor Police in Cyberspace

So lets begin a journey to explore the hugely unexplored avenues of a fancy world called the cyber space. Tell me how you would feel if you wake up and log into your Facebook account just to know if everybody else in this world has woken up or not, the same you have been doing religiously for months now. But today a bolt from the blue awaits you. You can’t access your account, some weird irritating error ‘Invalid user-name or password’ makes life difficult for you! I’m sure it would be frustrating not to be able to tell the world that you have woken up. But wait! The trouble may have just begun. What if some Tom, Dick or Harry, who hold some medieval era grudges against you has HACKED into your account and now has access to everything that you called ‘personal’? What if he tweaks your relationship status to ‘it’s complicated’? That would really piss off your girl. Wouldn’t it? What if he messages your Dad, ‘I wanna become a NAZI!!’? Well, I would suggest you find yourself some part-time job coz you’ll be short on pocket money for a few months now!

Hacking is just the tip of the iceberg. Cyber crimes go really deep and dark. From banking fraud to credit card information theft. From cyber terrorism to IPR violations. And yes, worm attacks and ahh… well… yeah… pornography! You would surely not like yourself pictured with Anna Nicole Smith with an advertising strip running below ‘Meet the new Bed Stars!’
Cyber crimes can be categorized as-
The computer as a target- using a computer to attack other computers.
Example- Hacking, Virus/Worm Attacks, DOS Attack etc.

The computer as a weapon- using a computer to commit real world crimes.
Example- Cyber Terrorism, IPR Violations, Credit Card Frauds, EFT Frauds, pornography etc.

To counter these Toms, Dicks  and Harrys; a league of good men have formulated some rules dictating the terms and conditions for human interaction with the cyber space, these rules have come to be called as ‘Cyber Laws’. Cyber law is a term used to describe the legal issues related to the use of communications technology, particularly cyber space i.e. The Internet!
Cyber laws are a desperate attempt to bring some order to the jungle raj of cyber space. And trust me; bringing order to chaos has never been that easy. It is a less distinct field of law in a way that property or contract are as it is an amalgamation of many legal fields, including intellectual property, privacy, freedom of expression and jurisdiction. In a gist, it’s an attempt to integrate the challenges presented by human activity on the internet with the legacy system of the laws.
So now you have a little idea about what you should and what you must not do on net, as it has been the thumb rule of nature, for every evil there is some good. In this way, for every crime there will be a law, it’s your responsibility to remain on the safe side of it.
Have I ignited any flame of excitement in you about the Cyber Laws? Would you like to know whats and hows of the Cyber Laws? Then stay hooked to this space, I’ll be back with more 

Advance PHP guide of |PHP Date | PHP Include | PHP File |

Before, I start And you start reading after my End, Let me tell you before you come to this post, You must know Basic of PHP Which includes, Knowing of Variables, Loops, arrays, Forms, GET & POST. If Yes, Than Chhers Let read this further to know more About PHP.


Index



  1. PHP Date
  2. PHP Include
  3. PHP File


1). PHP Date


Format
PHP Code:
date(format,timestamp

"format" is parameter and it is Required.It Specifies the format of the timestamp.
"timestamp" is parameter and it is optional. Specifies a timestamp. Default is the current date and time

Time PHP Code "PHP Date()" - Format the Date
Click to View Example (Click to View)
PHP Date() - Adding a Timestamp



Format
PHP Code:
mktime(hour,minute,second,month,day,year,is_dst

Example
Click to View (Click to View)
Icon_prost You have Learn Date Function, Now Lets move on to

PHP include() & require() function


Let us first now feature of this function, this is time saving feature in short what it does, it calls up some file to execute by just writing the page name, and we don't have to write same code what we have written earlier. For E.g, If we need header in our all page than we can make one header file and will call that page by just writing header tag on every page, rather than typing again and again the header page content, Thats it, If you understood well and goo, if not dont reply here for this function Icon_textemoticon09

PHP include function

Examples will make you clear no more Clarification:-
PHP require() Function

Now Let it make it shorter, just write "require" in place of "include" and you are done with require functio too.

Now, You must be thinking why two function for 1 purpose. Nah Nah, Not 1 feature,

Difference in "include()" & "require()" function is, :-

"include()" function executes the bottom line of statement if there is any error line above to it.
But "require()" function stops and does not proceed further, if there is any error in above lines of code/statement.

Rest they both are same.Now Lets move on to

PHP File


How to open a File

Format
PHP Code:
<html>
<
body>

<?
php
$file
=fopen("welcome.txt","r");?>
</body>
</html> 

$file = variable and
fopen is function
with "welcome.txt" file name to open and
"r" to format of open, whether readable or writable or executable or two of any of them or all of them.

List of format of open, are

1). "r" = read only and this starts @ the beginning of file.
2). "r+" = read and write, starts @ beginning of file.
3). "w" = write only, Opens the file and clears it, if the filename doesnot exist than it will create it.
4). "w+" = write/read starts, Opens the file and clears it, if the filename doesnot exist than it will create it.
5). "a" = Append.Opens and writes to the end of the file or creates a new file if it doesn't exist.
6). "a+" = Read/Append. Preserves file content by writing to the end of the file.
7). "x" = Write only. Creates a new file. Returns FALSE and an error if file already exists.
8). "x+" = Read/Write. Creates a new file. Returns FALSE and an error if file already exists.

Example Closing a file

PHP Code:
<?php
$file 
fopen("test.txt","r");
//some code to be executed
fclose($file);?>

Check End-of-file

PHP Code:
if (feof($file)) echo "End of file"

Reading a File Line by Line

PHP Code:
<?php
$file 
fopen("welcome.txt""r") or exit("Unable to open file!");//Output a line of the file until the end is reachedwhile(!feof($file))
  {
  echo 
fgets($file). "<br />";
  }
fclose($file);?>

while is loop here and (!feof($file)) means run the loop until you reach the end of line. [if not feof than echo, if feof than stop]

Reading a File Character by Character

PHP Code:
<?php
$file
=fopen("welcome.txt","r") or exit("Unable to open file!");
while (!
feof($file))
  {
  echo 
fgetc($file);
  }
fclose($file);?>

This is for those who will copy my this thread

PHP Database ODBC or PHP Application Programming Interface | PHP API

ODBC is an Application Programming Interface (API) that allows you to connect to a data source (e.g. an MS Access database).


Create an ODBC Connection


With an ODBC connection, you can connect to any database, on any computer in your network, as long as an ODBC connection is available.

Here is how to create an ODBC connection to a MS Access Database:

1. Open the Administrative Tools icon in your Control Panel.
2. Double-click on the Data Sources (ODBC) icon inside.
3. Choose the System DSN tab.
4. Click on Add in the System DSN tab.
5. Select the Microsoft Access Driver. Click Finish.
6. In the next screen, click Select to locate the database.
7. Give the database a Data Source Name (DSN).
8. Click OK.

Connecting to an ODBC


The odbc_connect() function is used to connect to an ODBC data source. The function takes four parameters: the data source name, username, password, and an optional cursor type.The odbc_exec() function is used to execute an SQL statement.

Example :-

PHP Code:
$conodbc_connect("WorldofHacker" ,"""");$sql_query="SELECT * from USERNAME";$resultodbc_exec($con$sql); 


How to fetch Records ?


Now as we have run the query & executed above, Now its time to fetch the query.
We have a simple command to fetch the query, it is
PHP Code:
odbc_fetch_rows($result

Retrieving Fields from a Record


The odbc_result() function is used to read fields from a record. This function takes two parameters: the ODBC result identifier and a field number or name.

Example
PHP Code:
$computername=odbc_result($result,1); 

The code line below returns the value of a field called "Username" :-
PHP Code:
$computername=odbc_result($result,"Username"); 

How to close ODBC Connection


The odbc_close() function is used to close an ODBC connection.
PHP Code:
odbc_close($con); 

Well, All the above were Basics Lets Complete with 1 good Example :-

PHP Code:
<html>
<
body>

<?
php
$con
=odbc_connect("worldofhacker""" ,"");
if (!
$con)
{
exit (
"connection failer: " .$con);
}
$sql_querySelect from username;$query=odbc_exec($sql_query,$con);
if(!
$query)
{
exit (
"Error in SQL");
}

echo 
"<table><tr>";
echo 
"<th>Username</th>";
echo 
"<th>Contact name</th></tr>";
while (
odbc_fetch_rows($query,$con)
{
$computername=odbc_result($query,$con);$contactname=odbc_resule($query,$con);
echo 
"<tr><td>$conputername"</td>;
echo 
"<td>$contactname</td></tr>";
}
odbc_close($con);
echo 
"</table>";?></body>
</html> 


Now you are done with all Basic Knowledge of PHP Application Programming Interface AKA "API".