Thursday, August 6, 2009

PHP Hit Counter using text only

Steps to make a Hit Counter

1. Create a counter text file of the name hitcounter.txt and save it to the same directory you will put your hit counter in.


2. Open your php editor. Save the document as counter.php. Set your opening statement for PHP script.

<?php
?>

3. Set the variable for the file named hitcounter.txt and place this between your PHP tags. remember to place the filename in quotes. place the semicolon on the end of the line to end the command.

<?php
$count_my_page = ("hitcounter.txt");
?>

4. Set the number of visits to the current value of the contents of the hitcounter.txt file:

<?php
$count_my_page = ("hitcounter.txt");
$hits = file($count_my_page);
?>

5. When the script is accessed as the page loads, it not only reads the current number of hits on the page in the hitcounter.txt, it must increase the value by 1 for the current hit to be recorded. Add 1 to your value of $hits and call it $hits.

<?php
$count_my_page = ("hitcounter.txt");
$hits = file($count_my_page);
$hits[0] ++;
?>

6.Open the file that is keeping count so we can write to it

<?php
$count_my_page = ("hitcounter.txt");
$hits = file($count_my_page);
$hits[0] ++;
$fp = fopen($count_my_page , "w");
?>

7. Replace the value in the file with the new $hits number after it was incremented.

<?php
$count_my_page = ("hitcounter.txt");
$hits = file($count_my_page);
$hits[0] ++;
$fp = fopen($count_my_page , "w");
fputs($fp , "$hits[0]");
?>

8. You must close the file next.

<?php
$count_my_page = ("hitcounter.txt");
$hits = file($count_my_page);
$hits[0] ++;
$fp = fopen($count_my_page , "w");
fputs($fp , "$hits[0]");
fclose($fp);
?>

9. Set the code to display your hit number.

<?php
$count_my_page = ("hitcounter.txt");
$hits = file($count_my_page);
$hits[0] ++;
$fp = fopen($count_my_page , "w");
fputs($fp , "$hits[0]");
fclose($fp);
echo $hits[0];
?>

10. Save your php file in same directory as the text file.

11. To use this script you just have to add a php statement that calls that php file. Use the following include:

<?php
include ("counter.php");
?>

PHP Array Functions

array() : Creates an array
array_change_key_case() : Returns an array with all keys in lowercase or uppercase
array_chunk() : Splits an array into chunks of arrays
array_combine() : Creates an array by using one array for keys and another for its values
array_count_values() : Returns an array with the number of occurrences for each value
array_diff() : Compares array values, and returns the differences
array_diff_assoc() : Compares array keys and values, and returns the differences
array_diff_key() : Compares array keys, and returns the differences
array_diff_uassoc() :Compares array keys and values, with an additional user-made function check, and returns the differences
array_diff_ukey() : Compares array keys, with an additional user-made function check, and returns the differences
array_fill() : Fills an array with values
array_filter() : Filters elements of an array using a user-made function
array_flip() : Exchanges all keys with their associated values in an array
array_intersect() : Compares array values, and returns the matches
array_intersect_assoc() : Compares array keys and values, and returns the matches
array_intersect_key() : Compares array keys, and returns the matches
array_intersect_uassoc() : Compares array keys and values, with an additional user-made function check, and returns the matches
array_intersect_ukey() : Compares array keys, with an additional user-made function check, and returns the matches
array_key_exists() : Checks if the specified key exists in the array
array_keys() : Returns all the keys of an array
array_map() : Sends each value of an array to a user-made function, which returns new values
array_merge() : Merges one or more arrays into one array
array_merge_recursive() : Merges one or more arrays into one array
array_multisort() : Sorts multiple or multi-dimensional arrays
array_pad() : Inserts a specified number of items, with a specified value, to an array
array_pop() : Deletes the last element of an array
array_product() : Calculates the product of the values in an array
array_push() : Inserts one or more elements to the end of an array
array_rand() : Returns one or more random keys from an array
array_reduce() : Returns an array as a string, using a user-defined function
array_reverse() : Returns an array in the reverse order
array_search() : Searches an array for a given value and returns the key
array_shift() : Removes the first element from an array, and returns the value of the removed element
array_slice() : Returns selected parts of an array
array_splice() : Removes and replaces specified elements of an array
array_sum() : Returns the sum of the values in an array
array_udiff() : Compares array values in a user-made function and returns an array
array_udiff_assoc() : Compares array keys, and compares array values in a user-made function, and returns an array
array_udiff_uassoc() : Compares array keys and array values in user-made functions, and returns an array
array_uintersect() : Compares array values in a user-made function and returns an array
array_uintersect_assoc() : Compares array keys, and compares array values in a user-made function, and returns an array
array_uintersect_uassoc() : Compares array keys and array values in user-made functions, and returns an array
array_unique() : Removes duplicate values from an array
array_unshift() : Adds one or more elements to the beginning of an array
array_values() : Returns all the values of an array
array_walk() : Applies a user function to every member of an array
array_walk_recursive() : Applies a user function recursively to every member of an array
arsort() : Sorts an array in reverse order and maintain index association
asort() : Sorts an array and maintain index association
compact() : Create array containing variables and their values
count() : Counts elements in an array, or properties in an object
current() : Returns the current element in an array
each() : Returns the current key and value pair from an array
end() : Sets the internal pointer of an array to its last element
extract() : Imports variables into the current symbol table from an array
in_array() : Checks if a specified value exists in an array
key() : Fetches a key from an array
krsort() : Sorts an array by key in reverse order
ksort() : Sorts an array by key
list() : Assigns variables as if they were an array
natcasesort() : Sorts an array using a case insensitive "natural order" algorithm
natsort() : Sorts an array using a "natural order" algorithm
next() : Advance the internal array pointer of an array
pos() : Alias of current()
prev() : Rewinds the internal array pointer
range() : Creates an array containing a range of elements
reset() : Sets the internal pointer of an array to its first element
rsort() : Sorts an array in reverse order
shuffle() : Shuffles an array
sizeof() : Alias of count()
sort() : Sorts an array
uasort() : Sorts an array with a user-defined function and maintain index association
uksort() : Sorts an array by keys using a user-defined function
usort() : Sorts an array by values using a user-defined function

read more..

Tuesday, August 4, 2009

PHP Introduction

HP stands for Hypertext Preprocessor and is used as a scripting language that is embedded in HTML and runs on the web server. The PHP code is run on the server when the page is requested
Anyone who knows HTML and the C or C++ language can easily program PHP. PHP uses much of the same syntax of C, but is much easier to use and provides access to variables and their values as submitted using HTML forms without the need to parse information. Also PHP is designed to work easily with most SQL servers including the open source SQL server, MySQL.

PHP code is placed in the body of HTML code. It may be placed in HTML code as follows:

The above example will output the quoted text on the HTML page where the PHP code is embedded.

Many webservers support PHP out of the box although depending on the version, they may not support the latest version of PHP (Currently 4). If using PHP on the web, it is wise to run the latest version since it has some security enhancements. If you're just using PHP to learn on a local network using the latest PHP version is not as imperative. For example the Apache webserver that comes with Redhat Linux version 6.1 supports PHP3. Depending on how the webserver is setup, it may be required to name the HTML files that contain PHP code with an extension like ".php4".

Documentation

This manual is a brief synopsis of information as an aid to learning PHP. It provides basic PHP information, then provide examples of some useful PHP functionality including sessions, cookie use, sending mail and using it with SQL. It is not intended completely cover all aspects of PHP. Also, it is assumed that the reader is familiar with HTML and languages similar in type to C or Perl. Much PHP syntax is similar to the C programming language. To supplement this document, the reader should refer to the documents page in the weblinks PHP section for available online and downloadable documentation about PHP.

This document and the documentation at the PHP.org Document Section should be all a reader needs to learn PHP. Specifically the large downloadable PHP Manual which is in both PDF and HTML format is an excellent reference manual outlining the many PHP functions by category.


PHP Syntax

PHP statements end with a semicolon.

PHP supports comments the same as C and C++ using the methods shown below:




PHP Variables

  • PHP variable type is determined by the way in which it is used (context).
  • Variable names begin with a dollar sign, $, followed by a letter, then more letters or numbers.
Supported variables include integers, floating point numbers, strings, arrays, and objects.

Predefined Variables

There are additional predefined PHP variables defined in a file called "php.ini". Variables defined in HTML forms are available to the PHP file that the form is submitted to using the HTML form "action" attribute. Also if the PHP document has been called using a HTML form, a variable named $submit is available and may be tested to see if it exists. If it exists, an if statement may be used to display one set of HTML rather then the HTML that would be displayed if it does not exist. The phpinfo() function may be used to get a list of predefined variables.

Typecasting

Typecasting is performed with the type written in parenthesis as follows:

$i = (int) $myrealvalue;

Supported typecasts include (int), (array), (object), (string), (real), (double), and (float).

PHP Array Variables

PHP Array variables may be defined in the following manner:

$tree = array("trunk", "branches", "leaves");

In this case the value:

tree[0]

evaluates to the string "trunk". The statement:

$tree[3]="nuts";

sets a fourth array value to "nuts". In this way, the array, tree, may be dynamically expanded.

An array can be created and expanded in the following manner.

$car[ ]="body";

$car[ ]="engine";

$car[ ]="transmission";

$car[ ]="tires";

String Concatenation

Strings can be added to each other or additional values may be added to a string using the append, "." operator as follows:

echo "The value of my variable is: " . $myvariable;

Operators

The math and logical operators are the same as the C programming language. Variables may be pre-incremented or post incremented or decremented with commands like "++$a;" which does a pre increment.

Monday, August 3, 2009

What is the Top Trojan Removal Program?

If you are confused about what the top Trojan removal program is and do not even know where to start to ensure that you are not wasting your money, the information to follow should help you to head in the right direction.

One key issue that always arises is whether or not Trojan viruses are the problem to start with. If your computer performance has declined, you are experiencing computer crashes and freezes, or if your PC has been acting in a strange way, you may have a virus on your system. Some of the follow symptoms are associated with Trojan viruses and could require the help of a Trojan removal program to eliminate: 

1. Websites you did not request are appearing.
2. You are getting strange error messages and pop-up ads.
3. Your web browser is very slow.
4. Windows loads slowly.
5. Strange software appears when you start up your PC.
6. Your modem light is spastically blinking even when you are not online.
7. The mouse is leaving a trail on your screen.
8. Your favourites list has added some sites that you never placed there.
9. Brand new toolbars are appearing in your web browser.
10. Your homepage is hijacked and you end up on sites not requested.
11. Your function buttons are reversed on your mouse.

read more

Sunday, August 2, 2009

Data Recovery Software for Memory Cards

Data Doctor Recovery TM is pioneer in developing windows data recovery software which offers economical and faster way of do it yourself recovery process. They are leading developers of professional and user interactive data recovery software and have maintained outstanding records in the field of data recovery. Following are some of the remarkable features.  
Easy to use: Data Recovery Software for Memory Cards contains simple and well guided help manual. The Inbuilt instruction manual offers step by step assistance to the user and enables him to easily understand software functionality without having advance computer skill. 

read more..