Thursday, March 29, 2012

How to determine whether a computer is running a 32-bit version or 64-bit ?

How to find system is working with 32-bit or 64-bit

Find the below steps

Start RUN command line

Start-> Run -> winmsd.exe

Under "System Summary"/ System Type you can find the OS version 

X64 -> 64 Bit
X86 -> 32 Bit

Wednesday, March 28, 2012

Google map Integration?



How to integrate google map integrate into your site.

It's very simple

Find the below code just copy and paste into your application

<!--<div style="width: 600px">
    <iframe width="600" height="300" src="http://regiohelden.de/google-maps/map_en.php?width=600&amp;height=300&amp;hl=en&amp;q=ProWorks%20Contracting%20%2013704%20lrving%20Ave%20S%20%20Burnsville%2C%20MN%2055337+(ProWorks%20Contracting)&amp;ie=UTF8&amp;t=&amp;z=14&amp;iwloc=A&amp;output=embed" frameborder="0" scrolling="no" marginheight="0" marginwidth="0">
    <a href="http://www.regiohelden.de/google-maps/">Google Maps Script</a> von <a href="http://www.regiohelden.de/">RegioHelden</a></iframe><br />
    <span style="font-size: 9px;">
    <a href="http://www.regiohelden.de/google-maps/" style="font-size: 9px;">Google Maps Script</a> by <a href="http://www.regiohelden.de/" style="font-size: 9px;">RegioHelden</a>
    </span>
</div>-->

Saturday, March 24, 2012

Abstracts and Interfaces, what's the difference?

Abstract Class Interfaces

Classes defined as abstract may not be instantiated, and any class that contains at least one abstract method must also be abstract. Methods defined as abstract simply declare the method's signature - they cannot define the implementation. For interface all the methods by default are abstract methods only. So one cannot declare variables or concrete methods in interfaces

In Abstract class we can declare public, private, protected methods & properties In interface class we can declare only public

Abstract class contain abstract methods and common methods Interface class all the methods should be an abstract

A class can Inherit only one Abstract class and Multiple inheritance is not possible for Abstract class. A class can implement many interfaces and Multiple interface inheritance is possible.

Thursday, March 22, 2012

Uses of drupla CMS

The following list shows the most common uses for drupla CMS
  1. Social networking sites
  2. Music & Multimedia web sites
  3. Education
  4. Corporate websites
  5. News and Publishing
  6. Community Portal

To change the XAMPP server port number:


  1. Stop the XAMPP server, if it is running already.
  2. Open the file [XAMPP Installation Folder]/apache/conf/httpd.conf.
  3. Now search for the string Listen 80 (I’m assuming that your XAMPP was using the port 80. Otherwise, just search for the string “Listen”). This is the port number which XAMPP uses. Change this 80 to any other number which you prefer.
  4. Then search for the string “ServerName” and update the port number there also.
  5. Now save and re-start XAMPP server and you are done.

Remove Duplicate Rows from mysql table

How to delete duplicate rows from MySQL table 

It's very simple

In my case as per the requirement admin can import csv file and all the data we need to store in MySQL database

Before inserting data i need to check the data already existed or not ? :)

Find the below code

            $query="SELECT * FROM table";
            $result=mysql_query($query);
            echo mysql_error();
            while($row = mysql_fetch_array($result)){
                $query1="SELECT * FROM table WHERE order_number='".$result_data[0]."' ";
                $result1=mysql_query($query1);
                $count = mysql_num_rows($result1) - 1;
                mysql_query("DELETE FROM table WHERE order_number='".$result_data[0]."' ");
                //echo "deleted $row[1] ";
            }
After this code INSERT the records


Wednesday, March 21, 2012

PHP Security tips

Any web application security is most important throughout the development. There are very simple ways you can take to protect your application from hackers. This post will cover some of the basics of PHP security.

The below mentioned tips every developer should know

1. Filtering Input :-

Filtering all data from external sources is probably the most important security measure you can take. This can be as easy as running some simple built-in functions on your variables.

whenever user enter some data into the form never directly use anything in $_GET or $_POST.. Check each value to make sure it is something expected and assign it to a local variable for use

// input filter examples
 
// Make sure it is an integer
$int = intval($_POST['variable']);
 
// Make it safe to use in a URL
$string = urlencode($_POST['variable']);
 
PHP as of version 5.2 provides a set of filtering functions designed 
just for the purpose of filtering user data. 

filter_input Gets a specific external variable by name and optionally filters it

<?php
$search_html 
filter_input(INPUT_GET'search'FILTER_SANITIZE_SPECIAL_CHARS);$search_url filter_input(INPUT_GET'search'FILTER_SANITIZE_ENCODED);
echo 
"You have searched for $search_html.\n";
echo 
"<a href='?search=$search_url'>Search again.</a>";?>

Out Put

You have searched for Me &#38; son. <a href='?search=Me%20%26%20son'>Search again.</a>  

2.Register_Globals:-

PHP is when the default value for the PHP directive register_globals went from ON to OFF in PHP » 4.2.0.
This post will explain how one can write insecure code with this directive but keep in mind that the directive itself isn't insecure but rather it's the misuse of it.

<?php// define $authorized = true only if user is authenticatedif (authenticated_user()) {
    
$authorized true;
}
// Because we didn't first initialize $authorized as false, this might be
// defined through register_globals, like from GET auth.php?authorized=1
// So, anyone can be seen as authenticated!
if ($authorized) {
    include 
"/highly/sensitive/data.php";
}
?> 

Example use of sessions with register_globals on or off

<?php// We wouldn't know where $username came from but do know $_SESSION is
// for session data
if (isset($_SESSION['username'])) {

    echo 
"Hello <b>{$_SESSION['username']}</b>";

} else {

    echo 
"Hello <b>Guest</b><br />";
    echo 
"Would you like to login?";

}
?>
  

3. Error Reporting:-

The error_reporting() function sets the error_reporting directive at runtime. PHP has many levels of errors, using this function sets that level for the duration (runtime) of your script. If the optional level is not set, error_reporting() will just return the current error reporting level.

It's never a good idea to show the world your errors. It make you look bad, it also might give malicious users another clue to help them break your site. You should always have display_errors disabled in a production environment, but continue logging errors with log_errors for your own information.

                Production        Development
display_errors     0                  1
log_errors         1                  0
error_reporting    E_ALL             E_ALL    

4. Use POST for Dangerous Actions

There are two common methods used to send data to a PHP application, GET and POST. GET works by adding variables to the end of URL's (eg. http://www.example.com/process.php?action=delete&id=123). POST works by sending variables in the body of the request (normal users will not see them). It is important to carefully consider which method to use for a certain task.
You should generally stick to POST when you are performing a potentially dangerous action (like deleting something). The reason is that is is much easier to trick a user into accessing a URL with GET parameters than it is to trick them into sending a POST request. Take this example:
<img src="http://www.example.com/process.php?action=delete&id=123" />
If a user with an active session on your site visits another web page with the above image tag, the user's browser will quietly send a request to your site telling it to delete record 123.
Keep in mind that other precautions should also be taken to ensure requests are legitimate under a secure session. It is also easily possible to create a form that does the same as above using a POST request, so don't assume that method is "safe" either. See sections 2 and 4 of the PHP Security Guide for more information on form and session security.

5. Database Queries Filtering:-

Example #1 Simple mysql_real_escape_string() example
<?php// We didn't check $_POST['password'], it could be anything the user wanted! For example:$_POST['username'] = 'aidan';$_POST['password'] = "' OR ''='";
// Query database to check if there are any matching users$query "SELECT * FROM users WHERE user='{$_POST['username']}' AND password='{$_POST['password']}'";mysql_query($query);
// This means the query sent to MySQL would be:echo $query;?>

6.Output Filtering

It is also important to filter what comes out of your applications.
htmlspecialchars();//Convert special characters to HTML entities
htmlspecialchars();//Convert all applicable characters to HTML entities
strip_tags();// Strip HTML and PHP tags from a string

<?php
$new 
htmlspecialchars("<a href='test'>Test</a>"ENT_QUOTES);
echo 
$new// &lt;a href=&#039;test&#039;&gt;Test&lt;/a&gt;?>

htmlspecialchars();
<?php
$str 
"A 'quote' is <b>bold</b>";
// Outputs: A 'quote' is &lt;b&gt;bold&lt;/b&gt;echo htmlentities($str);

 strip_tags():
<?php
$text 
'<p>Test paragraph.</p><!-- Comment --> <a href="#fragment">Other text</a>';
echo 
strip_tags($text);
echo 
"\n";
// Allow <p> and <a>echo strip_tags($text'<p><a>');?> 

document.formname.submit is not a function Error in javascript

In my case i have 2 radio buttons

<input type="radio" name="test" value="1"  OnClick="javascript:document.formname.submit()"/>
<input type="radio" name="affiliates" value="2"   OnClick="javascript:document.affiliatesform.submit()" /> 

But in the same form as my my requirement i put one sumit button like

<input type="submit" name="submit" value="GO">
 
This means i have have a function trying to call the form's submit() method, but you also have a button which is called submit(). This causes a conflict in javascript, because the submit method is already bound to that button.

i just resolve this problem with change the name of the submit button

<input type="submit" name="print" value="GO">

login is very simple enjoy :)



Multiple Checkbox select / unselect using jQuery

Handling multiple checkbox with select and unselect

Find the below code you can get simple solution here

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<HTML>
<HEAD>
    <script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.3.2/jquery.min.js"></script>
    <TITLE>Multiple Checkbox Select/Deselect - DEMO</TITLE>
</HEAD>
<BODY>
    <H2>Multiple Checkbox Select/Deselect - DEMO</H2>
<table border="1">
<tr>
    <th><input type="checkbox" id="selectall"/></th>
    <th>First Name</th>
    <th>Last Name</th>
    <th>Address</th>
</tr>
<tr>
    <td align="center"><input type="checkbox" class="case" name="case" value="1"/></td>
    <td>rajesh</td>
    <td>kumar</td>
    <td>Hyderabad</td>
</tr>
<tr>
    <td align="center"><input type="checkbox" class="case" name="case" value="2"/></td>
    <td>rajesh1</td>
    <td>kumar1</td>
    <td>Hyderabad1</td>
</tr>

</table>

</BODY>
</HTML>

<body>
</body>
</html>

Include the below script in in your head tag

<SCRIPT language="javascript">
$(function(){
 
    // add multiple select / deselect functionality
    $("#selectall").click(function () {
          $('.case').attr('checked', this.checked);
    });
 
    // if all checkbox are selected, check the selectall checkbox
    // and viceversa
    $(".case").click(function(){
 
        if($(".case").length == $(".case:checked").length) {
            $("#selectall").attr("checked", "checked");
        } else {
            $("#selectall").removeAttr("checked");
        }
 
    });
});
</SCRIPT>



Monday, March 19, 2012

How to install Yii Framework & How to Create Your First App

Download the Yii framework source files from below link:-

http://www.yiiframework.com/download/

PHP xampp server

YiiRoot = C:\xampp\htdocs\yii\framework

WebRoot = C:\xampp\htdocs


Open your command prompt install the yii framework

C:\xampp\htdocs\yii\framework>yiic webapp C:\xampp\htdocs\yourfirstapp
C:\xampp\htdocs\mesmarty'? [Yes|No] give y

all the script will be excuted

Finally Your application has been created successfully under C:\xampp\htdocs\mesmarty. 






The table "{{users}}" for active record class "RegistrationForm" cannot be found in the database. Yii Frame in User Module

How to resolve this issue in real time?

very simple when ever we install the use module in Yii  it's giving table prefix like tblusers

solution:-
   path: yourapp/protected/config/main.php

 goto below line
           'db'=>array(
            'connectionString' => 'mysql:host=localhost;dbname=yourdb',
            'emulatePrepare' => true,
            'username' => 'yourusername',
            'password' => '',
            'charset' => 'utf8',
             'tablePrefix' => 'tbl_',
        ),

add tablePrefix end the array :)
 

Thursday, March 15, 2012

How to import CSV to MYSQL usong PHP script?

<?php
error_reporting(0);
//connect to the database
$connect = mysql_connect("localhost","root","");
mysql_select_db("btp",$connect); //select the table
    if ($_FILES[csv][size] > 0) {
        $row = 0;
         $file = $_FILES[csv][tmp_name];
        if (($handle = fopen($file, "r")) !== FALSE) {
               while (($data = fgetcsv($handle, 1000, ",")) !== FALSE) {
                if($row > 0){         
                    $num = count($data);
                          mysql_query("INSERT INTO contacts (contact_first, contact_last, contact_email) VALUES (
'".addslashes($data[0])."','".addslashes($data[1])."','".addslashes($data[2])."')");
                  }
            $row++;
        }
        //echo "<pre>";print_r($data);
        fclose($handle);
    }
        header('Location: import.php?success=1'); die;
}
?>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>Import a CSV File with PHP & MySQL</title>
</head>

<body>

<?php if (!empty($_GET[success])) { echo "<b>Your file has been imported.</b><br><br>"; } //generic success notice ?>

<form action="" method="post" enctype="multipart/form-data" name="form1" id="form1">
  Choose your file: <br />
  <input name="csv" type="file" id="csv" />
  <input type="submit" name="Submit" value="Submit" />
</form>

</body>
</html>

Wednesday, March 14, 2012

How to create Watermark image with test?

function watermarkImage ($SourceFile, $WaterMarkText, $DestinationFile) {
list($width, $height) = getimagesize($SourceFile);
$image_p = imagecreatetruecolor($width, $height);
$image = imagecreatefromjpeg($SourceFile);
imagecopyresampled($image_p, $image, 0, 0, 0, 0, $width, $height, $width, $height);
$black = imagecolorallocate($image_p, 0, 0, 0);
$font = 'arial.ttf';
$font_size = 10;
imagettftext($image_p, $font_size, 0, 10, 20, $black, $font, $WaterMarkText);
if ($DestinationFile<>'') {
imagejpeg ($image_p, $DestinationFile, 100);
} else {
header('Content-Type: image/jpeg');
imagejpeg($image_p, null, 100);
};
imagedestroy($image);
imagedestroy($image_p);
};

$SourceFile = 'images/Sunset.jpg';
$DestinationFile = 'Blue hills.jpg';
$WaterMarkText = 'Copyright phpJabbers.com';
watermarkImage ($SourceFile, $WaterMarkText, $DestinationFile);

How to install ZEND Framework in WAMP Server?

Zend Installation Steps.


1.Exatract the zend downloded files
2.set the enviroment variable php file PATH C:\wamp\bin\php\php5.3.5
(windows=> mycomputer/advanced settings/advanced/Enviroment Variables)
3.open cmd and run php for varification
4.run zf batch file
5.Create zend folder in cmd c:/wamp>www>zf create test

Enjoy with Zend framework :)

What is the difference between Joomla and Drupal?

Jomla and Drupal both are Big CMS applications in PHP. Drupal users and developers love drupal CMS and Joomla users and developers love Joomla CMS but there is a lot of difference coming to database part or front end architecture admin side interface many things are different i like both Drupal and Joomla

Please find below some differences


Joomla vs Drupal


1.Joomla supports one section/category creating an article, while you can assign Drupal contents to several Sections/Categories.

2.Drupal is more flexible when it comes to the development and integrating theme and layout of the website. Joomla! is known offers less compare to drupal.

3.Joomla is very easy for non-technical users but not in drupal case

4.Administration functionality with the Drupal is not good and quite difficult, while Joomla! its really easy and limited functionality small websites with limited functionality its really good.

5.In drupal every user can login with same interface but in joomla have some difference

6.The Drupal codes are more professional and secure and of a quality, while it lacks in the case of Joomla!.

7.SEO is very impotent for every website especially in CMS web applications in drupal very good for Search Engine Friendly URLS its free component and its very flexible while in Joomla development not that much flexible and its having component but that is for commercial

Terminology Joomla vs Drupal

1. Joomla "Template" is called "Theme" in Drupal.
2. Component = Module.
3. Module = Block.
4. Mambot/Plugin = Input filter.
5. Menu-Horizontal = Primary Links
6. Menu-Vertical = Navigation
7. Dynamic Content Item = Story
8. Static Content = Page
9. Back-end = there is no back-end in Drupal, but modules like Administration Menu that provide a similar interface.
10. SEF = Clean URLs (but some docs refer to SEF, too).
11. Section = Taxonomy Vocabulary/Term
12. Section Title = Taxonomy Term (master)
13. Category = Taxonomy Term (child)
14. Introtext = Teaser
15. Maintext = Body (see explanation below)
16. Pathway = Breadcrumb

Why we love Drupal 7

Drupal 7 release in January of this year, now the people are very passionate about drupal 7 all the projects are now developing in drupal7 There are significant differences between Drupal 6 and 7, so working with the new platform has been a bit of an adjustment for us. We want share some experience

Please find the below points for drupal7 cahnges:-

1. The administrator theme is greatly improved

In previous versions drupal6 the admin theme is quite different for non-technical persons. But in drupal7 the admin theme its very interesting and all layout will be designed using Jquery. The administrative interface now includes Ajax goodness, an overall admin toolbar, shortcuts and generally increased loading times.

2. Page Loading very fast compare to previous versions?

In the previous versions the the page loading is a big problem because of to many sql connection in the code there is no serving cache architecture. In drupal6 there is a Big improving, but Drupal 7 features significantly less SQL queries causing sites to load faster.

3. CCK is now part of Drupal7.

When working with Drupal 6, installing the Content Construction Kit (CCK) module was pretty much a requirement. CCK has been moved into core and rebranded as the Field API. Moving CCK into core gives developers the power to add fields to not only content types, but also to People, Taxonomy, etc.

4. Upload feature that is included in the Field Set

Uploading file into drupal6 its quite difficult but in In Drupal 7 what you can do right out of the box is much improved:

The Content API allows you to specify mime types you want to allow (JPG, GIF, PDF, DOC, etc.). It also lets you set upload limits and maximum dimensions when uploading images.
Files are now uploaded via an AJAX interface. After the file is uploaded it is immediately displayed in the form, where the user sees the file name and can delete the file right there. Further, as the file is uploaded the user sees a loading image so they can be confident that the file is getting loaded.

5. Custom Content Type creation
Drupal6 we are creating content types were really designed to be text fields with the Body field required for all custom content types you created. In Drupal 7, this requirement has been removed. This makes it less clunky to create non-text based custom content types for assets such as PDFs or images.

6. Working with jQuery plugins is much easier in Drupal 7.
Jquery is probably the most popular JavaScript library, and allows for the rapid development of client side site features. Drupal 7 has made it much easier in general to use jQuery in your themes, and also ships with a jQuery 1.4.4, which is much faster and more feature rich than jQuery 1.2.6, which was the default in Drupal6. For the front-end developers out there, this is a big improvement that will save lots of time.

7. Drupal7 compatible with multiple databases.
Using drupal7 we can easily connect with multiple databases. Drupal7 is depend on any specific database

8.Drupal 7 is much easier to update.

Keeping Drupal 6 current was a hassle, as to update a module you had to download it, unpack it, upload it again and then run the update. Drupal 7 features an Update manager that tells you when a module is out of date and allows you to update it right from the web interface. Much, much easier, and more like the experience in WordPress.

9.Blocks are much easier to configure.

In Drupal 6, to create a block you have to first create a block on the page you want it to appear, and then go to the slow-loading block overview page to set where on the page you want it to appear. In Drupal 7 this is all done in one step. While it sounds trivial, this can save a lot of time on more complicated sites.

Bar Code Generator

A bar code is an machine (scan)readable representation of data, which shows data about the object to which it attaches. Generally barcodes represented data by varying the lines width and height and spacings of parallel lines, and may be referred to as linear or one-dimensional (1D). Later they evolved into rectangles, dots, hexagons and other geometric patterns in two dimensions (2D). Although 2D systems use a variety of symbols, they are generally referred to as barcodes as well.

Using bar code originally scanned special optical scanner and smart phone devices

There are many types of barcodes like
1.barcode39
2.barcode128
3.barcode93
4.barcode11
5.barcode8 etc..

If you want to download the code Click Here

QR Code Generator

What is really amazing about QR Codes is that it is also a very impressive and powerful open source code – which means that you can have your own QR Code PHP that you can create and use. For people who deal very frequently with QR Codes, there will be absolutely no problems whatsoever in coming up with their own codes and using it but the issue of finding and creating a reader that can be used to decode the result would be a little bit of a problem. However, we have met some real talents who can come up with their own QR code using PHP programing. This would take an expert, so, beginners, you might want to stay out of this one.

Find QR Code library file


class qrcode
{
private $data;

//creating code with link mtadata
public function link($url){
if (preg_match('/^http:\/\//', $url) || preg_match('/^https:\/\//', $url))
{
$this->data = $url;
}
else
{
$this->data = "http://".$url;
}
}

//creating code with bookmark metadata
public function bookmark($title, $url){
$this->data = "MEBKM:TITLE:".$title.";URL:".$url.";;";
}

//creating text qr code
public function text($text){
$this->data = $text;
}

//creatng code with sms metadata
public function sms($phone, $text){
$this->data = "SMSTO:".$phone.":".$text;
}

//creating code with phone
public function phone_number($phone){
$this->data = "TEL:".$phone;
}

//creating code with mecard metadata
public function contact_info($name, $address, $phone, $email){
$this->data = "MECARD:N:".$name.";ADR:".$address.";TEL:".$phone.";EMAIL:".$email.";;";
}

//creating code wth email metadata
public function email($email, $subject, $message){
$this->data = "MATMSG:TO:".$email.";SUB:".$subject.";BODY:".$message.";;";
}

//creating code with geo location metadata
public function geo($lat, $lon, $height){
$this->data = "GEO:".$lat.",".$lon.",".$height;
}

//creating code with wifi configuration metadata
public function wifi($type, $ssid, $pass){
$this->data = "WIFI:T:".$type.";S:".$ssid.";P:".$pass.";;";
}

//creating code with i-appli activating meta data
public function iappli($adf, $cmd, $param){
$param_str = "";
foreach($param as $val)
{
$param_str .= "PARAM:".$val["name"].",".$val["value"].";";
}
$this->data = "LAPL:ADFURL:".$adf.";CMD:".$cmd.";".$param_str.";";
}

//creating code with gif or jpg image, or smf or MFi of ToruCa files as content
public function content($type, $size, $content){
$this->data = "CNTS:TYPE:".$type.";LNG:".$size.";BODY:".$content.";;";
}

//getting image
public function get_image($size = 150, $EC_level = 'L', $margin = '0'){
$ch = curl_init();
$this->data = urlencode($this->data);
curl_setopt($ch, CURLOPT_URL, 'http://chart.apis.google.com/chart');
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_POSTFIELDS, 'chs='.$size.'x'.$size.'&cht=qr&chld='.$EC_level.'|'.$margin.'&chl='.$this->data);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_HEADER, false);
curl_setopt($ch, CURLOPT_TIMEOUT, 30);

$response = curl_exec($ch);
curl_close($ch);
return $response;
}

//getting link for image
public function get_link($size = 150, $EC_level = 'L', $margin = '0'){
$this->data = urlencode($this->data);
return 'http://chart.apis.google.com/chart?chs='.$size.'x'.$size.'&cht=qr&chld='.$EC_level.'|'.$margin.'&chl='.$this->data;
}

//forcing image download
public function download_image($file){
header('Content-Disposition: attachment; filename=QRcode.png');
header('Content-Type: image/png');
echo $file;
}

//save image to server
public function save_image($file, $path = "./QRcode.png"){
file_put_contents($path, $file);
}
}
?>
example.php
include("qrcode.php");
$qr = new qrcode();
$qr->text("BTP295298");

?>

If you want to download Click Here :)