Saturday, November 30, 2013

Creating Wildcard Sub Domain Using Apache VirtualHost for php

You can't make dynamic subdomains with .htacces
You will need to configure the apache virtual host to accept requests for multiple domains
<VirtualHost *:80>
    ServerName www.example.com
    ServerAlias example.com *.example.com
    DocumentRoot /www/domain
</VirtualHost>
Adding the wildcard subdomain *.example.com, your PHP application will receive
all requests for any
domain below example.com, ie garbage.example.combusted.example.com,
llama.example.com, etc.
At this point, your application will have to determine the validity of the subdomain and
display the appropriate error for unknown subs.
From there, parse the domain for mike.


2down voteaccepted
Wildcard sub-domains are definitely possible using Apache virtual hosts.
I had basically the same requirements and managed to get it working with Apache's mod_vhost_alias.somodule. Try this in your http-vhosts.conf file:
DocumentRoot "/home/admin1/public_html/userweb/" 
<Directory "/home/admin1/public_html/userweb/"> 
    Options None 
    AllowOverride None 
    Order allow,deny 
    Allow from all 
</Directory>

<VirtualHost *:80>
    DocumentRoot /home/admin1/public_html/
    ServerName www.example.com
</VirtualHost>

<VirtualHost *:80> 
    VirtualDocumentRoot /home/admin1/public_html/userweb/%1.example.com/ 
</VirtualHost>

<VirtualHost *:80>
    DocumentRoot /home/admin1/public_html/
    ServerName example.com
</VirtualHost>
Note that I haven't tested this, but it's pretty close to the solution that worked for me.

Friday, November 29, 2013

how to include view within view in zendframe work?[Solved]

Here is the example : hope help you guys :)
<?php echo $this->render('login/index.phtml'); ?>

how to send value to view page in zendframe work?[Solved]

Simple its using zend framework assign reference function to view page


within controller  function pass value to view page
you can two way to pass value to view page
one is : $this->request=150
Or
$value=150;
$this->view->assign('request',$value);
--------------------------------------------------------------
Get variable value within  view page
like
echo $this->request;

Thursday, November 28, 2013

how to configure NETBean IDE for PHP

Hello Guys tricky for debugging PHP.ini . easy to debug and help it sure.
  1. First download the NetBean IDE HERE  then install in your system
  2. then some change configure  in PHP.INI file
  3. Find and  remove  the line zend_extension = "XAMPP_HOME\php\ext\php_xdebug.dll".
  4. Find and  remove ; the line xdebug.remote_host=localhost. Change the value of the setting from localhost to 127.0.0.1.
  5. Find and  remove ; the line xdebug.remote_enable = 0. Change 0 to 1.
  6. Find and  remove ; the line xdebug.remote_handler = "dbgp".
  7. Find and remove ; the line xdebug.remote_port = 9000.
  8. Find and remove ; the line xdebug.show_local_vars = 1 
  9. Save php.ini.
  10. Run the XAMPP Control Panel Application and restart the Apache server.

Wednesday, November 27, 2013

how do i set checkbox value in zend framework form [Solved]

Hello guy you can set your form checkbox default value in zend framework
$checkbox=new Zend_Form_Element_Checkbox('remember');
 $checkbox->setChecked(true)->setuncheckedValue(0);

simple zend framework login authentication controller action [Solved]


Login controller action function you can determine the authentication of Login user

public function loginAction()
 {
     
  $this->view->title = "User Login";
$this->view->headTitle($this->view->title, 'PREPEND');
$form = new Form_Login();
$form->submit->setLabel('Login');
$this->view->form = $form;
if ($this->getRequest()->isPost())
{
$formData = $this->getRequest()->getPost();
                                $formData['id']=1;
                             
$db = $this->_getParam('mysite');
if ($form->isValid($formData))
{

$username =$form->getValue('username');
$password =$form->getValue('password');
$adapter = new Zend_Auth_Adapter_DbTable(
$db,
'jos_users',
'username',
'email'
);


$adapter->setIdentity($username);
$adapter->setCredential($password);
$auth   = Zend_Auth::getInstance();
$result = $auth->authenticate($adapter);


if ($result->isValid())
     {
  $data = $adapter->getResultRowObject(null,'username');
                                           $auth->getStorage()->write($data);
$this->_helper->FlashMessenger('Successful Login');
$this->view->messages = $this->_helper->flashMessenger->getMessages();

$this->_redirect('/successlogin');
return;
}
     else
    {
            $this->_helper->FlashMessenger('invalide user and password');
       $this->view->messages = $this->_helper->flashMessenger->getMessages();
$form->populate($formData);
}


}
else
{
$form->populate($formData);
}
}
}

how do i set form hidden value in zend framework controller[Solved]

Hello guys it easy to find the tricky
Set values to form hidden properties by zend framework controller

$formData = $this->getRequest()->getPost();
// print_r($formData) all element value get and set your value which field you want
 $formData['hiddenid']=1;//hidden field
$form->populate($formData);


Hope help you:)

how to remove dt dl zend frame work form

hello guys you can remove here dl,dt tag in zend form
// for hidden element
$id = new Zend_Form_Element_Hidden('id');
                $id ->removeDecorator('label')
         ->removeDecorator('HtmlTag');

zendframework configure and run in localhost xampp [Solved]

 Download zendframe library  work extract and paste into D:\xampp\php\

1st->  enviernment valriable set -> name: Path : .;D:\xampp\php\ZendFramework\bin;D:\xampp\php\ZendFramework\library\;D:\xampp\php\ZendFramework\bin\zf.bat
2nd-> System Path D:\xampp\php\
3rd->Copy zend folder from D:\xampp\php\ZendFramework\library into paste D:\xampp\php\PEAR
Php.ini
4th -> include_path = ".;D:\xampp\htdocs\ZendFramework\library;D:\xampp\php\PEAR"
5th->Restart your apache server


6th -> then create project on command-> D:\xampp\htdocs->zf create project ProjectName


hope may its help you :

Tuesday, November 26, 2013

insert , update ,delete example using zend framework simple

Hello Guys we giving you simple add,edit ,delete example using zend framework you can learn step by step
first configure your database connection for zend application
------------------------------------------------------------------------
D:\xampp\htdocs\mysite\application\configs\application.ini
-------------------------------------------------------------------------
[production]
phpSettings.display_startup_errors = 0
phpSettings.display_errors = 0
includePaths.library = APPLICATION_PATH "/../library"
bootstrap.path = APPLICATION_PATH "/Bootstrap.php"
bootstrap.class = "Bootstrap"
appnamespace = "Application"

resources.frontController.controllerDirectory = APPLICATION_PATH "/controllers"
resources.frontController.params.displayExceptions = 1
resources.db.adapter = "PDO_MYSQL"
resources.db.params.host = "localhost"
resources.db.params.username = "root"
resources.db.params.password = ""
resources.db.params.dbname = "zend"
resources.layout.layoutpath = APPLICATION_PATH "/layouts"
phpSettings.date.timezone = "UTC"
[staging : production]
[testing : production]
phpSettings.display_startup_errors = 1
phpSettings.display_errors = 1

[development : production]
phpSettings.display_startup_errors = 1
phpSettings.display_errors = 1
resources.frontController.params.displayExceptions = 1

---------------------------------------create user table ---------------------------------------------------------
CREATE TABLE IF NOT EXISTS `jos_users` (
  `id` int(11) NOT NULL AUTO_INCREMENT,
  `name` varchar(255) NOT NULL DEFAULT '',
  `username` varchar(150) DEFAULT '',
  `email` varchar(100) NOT NULL DEFAULT '',
  `password` varchar(100) NOT NULL DEFAULT '',
  `usertype` varchar(25) NOT NULL DEFAULT '',
  `block` tinyint(4) NOT NULL DEFAULT '0',
  `sendEmail` tinyint(4) DEFAULT '0',
  `gid` tinyint(3) unsigned NOT NULL DEFAULT '1',
  `registerDate` datetime NOT NULL DEFAULT '0000-00-00 00:00:00',
  `lastvisitDate` datetime NOT NULL DEFAULT '0000-00-00 00:00:00',
  `activation` varchar(100) NOT NULL DEFAULT '',
  `params` text NOT NULL,
  PRIMARY KEY (`id`),
  KEY `usertype` (`usertype`),
  KEY `idx_name` (`name`),
  KEY `gid_block` (`gid`,`block`),
  KEY `username` (`username`),
  KEY `email` (`email`)
) ENGINE=MyISAM AUTO_INCREMENT=122 DEFAULT CHARSET=utf8;
--------------------------------------------------------------------------------------------------------
Stp->1 create a form class user.php location : D:\xampp\htdocs\zend\application\forms\user.php
-------------------------------------paste below code-----------------------------------------------------------
<?php
class Form_User extends Zend_Form
{
public function __construct($options = null)
{
parent::__construct($options);
$this->setName('album');
$id = new Zend_Form_Element_Hidden('id');
$name = new Zend_Form_Element_Text('name');
$name->setLabel('Name')
->setRequired(true)->addFilter('StripTags')->addFilter('StringTrim')->addValidator('NotEmpty');
$username = new Zend_Form_Element_Text('username');
$username->setLabel('Username')->setRequired(true)->addFilter('StripTags')->addFilter('StringTrim')->addValidator('NotEmpty');
$email = new Zend_Form_Element_Text('email');
$email->setLabel('Email')->setRequired(true)->addFilter('StripTags')->addFilter('StringTrim')->addValidator('NotEmpty')->addValidator('EmailAddress',  TRUE  );
$submit = new Zend_Form_Element_Submit('submit');
$submit->setAttrib('id', 'submitbutton');
$this->addElements(array($id, $name,$username, $email, $submit));
}
}
-----------------------------------------------------------------------------------------------------------------
Stp->2 create a controller class user.php location : D:\xampp\htdocs\mysite\application\controllers\BbcController.php
-----------------------------------------------------------------------------------------------------------------
<?php
class BbcController extends Zend_Controller_Action
{

    public function init()
    {
        /* Initialize action controller here */
    }

    function indexAction()
{

$this->view->title = "Bbc by bikash";
$this->view->headTitle($this->view->title, 'PREPEND');
$user = new Model_DbTable_Bbc();

$this->view->bbc = $user->fetchAll();

}
function insertAction()
{
       $this->view->title = "insert new user";
$this->view->headTitle($this->view->title, 'PREPEND');
$form = new Form_User();
$form->submit->setLabel('Insert');
$this->view->form = $form;


if ($this->getRequest()->isPost())
{
$formData = $this->getRequest()->getPost();
if ($form->isValid($formData))
{
$name = $form->getValue('name');
$username=$form->getValue('username');

$email = $form->getValue('email');
$albums = new Model_DbTable_Bbc();
$albums->insertuser($name, $username,$email);
$this->_redirect('/bbc');
}
else
{
$form->populate($formData);
}
}
}
    function updateAction(){
   $this->view->title = "Upadate user";
$this->view->headTitle($this->view->title, 'PREPEND');
        $form = new Form_User();
$form->submit->setLabel('update');
$this->view->form = $form;
if ($this->getRequest()->isPost())
{
$formData = $this->getRequest()->getPost();
if ($form->isValid($formData))
{
$id = (int)$form->getValue('id');
$name = $form->getValue('name');
$username=$form->getValue('username');
$email = $form->getValue('email');
$albums = new Model_DbTable_Bbc();
$albums->updateuser($id, $name,$username, $email);
$this->_redirect('/bbc');
}
else
{
$form->populate($formData);
}
}
else
{
$id = $this->_getParam('id', 0);
if ($id > 0)
{
$albums = new Model_DbTable_Bbc();
$form->populate($albums->getAlbum($id));
}
}

    }

public function deleteAction()
{
$this->view->title = "Delete album";
$this->view->headTitle($this->view->title, 'PREPEND');
if ($this->getRequest()->isPost())
{
$del = $this->getRequest()->getPost('del');
if ($del == 'Yes')
{
$id = $this->getRequest()->getPost('id');
$albums = new Model_DbTable_Bbc();
$albums->deleteUser($id);
}
$this->_redirect('/bbc');
}
else
{
$id = $this->_getParam('id', 0);
$albums = new Model_DbTable_Bbc();
$this->view->album = $albums->getAlbum($id);
}
}


}
------------------------------------------create view-----------------------------------------------------
Stp->1 create views location : D:\xampp\htdocs\mysite\application\views\scripts\bbc\index.phtml,insert.phtml,update.phtml,delete.phtml
--------------------------------------index.phtml -----------------------------------------------------

<p><a href="<?php echo $this->url(array('controller'=>'bbc',
'action'=>'insert'));?>">Add new album</a></p>
<table>
<tr>
<th>Name</th>
<th>Username</th>
<th>Email address</th>
<th>&nbsp;</th>
</tr>
<?php foreach($this->bbc as $album) : ?>
<tr>
<td><?php echo $this->escape($album->name);?></td>
<td><?php echo $this->escape($album->username);?></td>
<td><?php echo $this->escape($album->email);?></td>
<td>
<a href="<?php echo $this->url(array('controller'=>'bbc',
'action'=>'update', 'id'=>$album->id));?>">Edit</a>
<a href="<?php echo $this->url(array('controller'=>'bbc',
'action'=>'delete', 'id'=>$album->id));?>">Delete</a>
</td>
</tr>
<?php endforeach; ?>
</table>
--------------------------------------insert.phtml -----------------------------------------------------
<?php echo $this->form ;?>
--------------------------------------update.phtml -----------------------------------------------------
<?php echo $this->form ;?>
--------------------------------------delete.phtml -----------------------------------------------------
<p>Are you sure that you want to delete
'<?php echo $this->escape($this->album['name']); ?>' by
'<?php echo $this->escape($this->album['email']); ?>'?
</p>
<form action="<?php echo $this->url(array('action'=>'delete')); ?>" method="post">
<div>
<input type="hidden" name="id" value="<?php echo $this->album['id']; ?>" />
<input type="submit" name="del" value="Yes" />
<input type="submit" name="del" value="No" />
</div>

-------------------------hope it may help you--:)--:)-------------------------------------------:)

Monday, November 25, 2013

how to prevent An error occurred and An error occurred in zendframeword?[Solved]

do set In your /application/configs/application.ini
set
resources.frontController.params.displayExceptions = 1
For the environment you are in. If you don't know which one you are in, put it temporarily under[production].

zend frameword occored error like

An error occurred

An error occurred

Friday, November 22, 2013

how to call helper class function in magento ?[SOLVE]

simple create a class file under like D:\xampp\htdocs\FE2U\app\code\local\Rename\User\Helper/Getdata.php
---------------------------------------------------------------------------------------------

class Rename_Rename_Helper_Getdata extends Mage_Core_Helper_Abstract
{

    public function getUserName()
    {
        if (!Mage::getSingleton('customer/session')->isLoggedIn()) {
            return '';
        }
        $customer = Mage::getSingleton('customer/session')->getCustomer();
        return trim($customer->getName());
    }
   
}
----------------------------------call in Controller page -----------------------------------------------

Mage::helper('User/Getdata')->getUserName();
Default helper class is Data and this defaults to Yourmodule/Helper/Data.php
Mage::helper('User')->getUserName();

Thursday, November 21, 2013

how to integrate paypal IPN using php example

Receiving Your First Notification

To process a sample IPN message, build a listener and host it on your web server. Once the listener is up and running, test it by using the PayPal Sandbox to send a simulated IPN message to the listener.
The steps below include PHP snippets that show how to code a simple IPN listener.
  1. Upon receipt of a notification from PayPal, send an empty HTTP 200 response.
    <?php
    
       // Send an empty HTTP 200 OK response to acknowledge receipt of the notification 
       header('HTTP/1.1 200 OK'); 
      
  2. Extract variables from the notification for later processing.
    Note that how you process a particular notification depends on its type. For example, if a notification applies to a completed payment, you could extract these variables from the message:
      // Assign payment notification values to local variables
      $item_name        = $_POST['item_name'];
      $item_number      = $_POST['item_number'];
      $payment_status   = $_POST['payment_status'];
      $payment_amount   = $_POST['mc_gross'];
      $payment_currency = $_POST['mc_currency'];
      $txn_id           = $_POST['txn_id'];
      $receiver_email   = $_POST['receiver_email'];
      $payer_email      = $_POST['payer_email'];
      
  3. Use the notification to build the acknowledgement message required by the IPN authentication protocol.
      // Build the required acknowledgement message out of the notification just received
      $req = 'cmd=_notify-validate';               // Add 'cmd=_notify-validate' to beginning of the acknowledgement
    
      foreach ($_POST as $key => $value) {         // Loop through the notification NV pairs
        $value = urlencode(stripslashes($value));  // Encode these values
        $req  .= "&$key=$value";                   // Add the NV pairs to the acknowledgement
      }
  4. Post the acknowledgement back to PayPal, so PayPal can determine whether the original notification was tampered with.
      // Set up the acknowledgement request headers
      $header  = "POST /cgi-bin/webscr HTTP/1.1\r\n";                    // HTTP POST request
      $header .= "Content-Type: application/x-www-form-urlencoded\r\n";
      $header .= "Content-Length: " . strlen($req) . "\r\n\r\n";
    
      // Open a socket for the acknowledgement request
      $fp = fsockopen('ssl://www.sandbox.paypal.com', 443, $errno, $errstr, 30);
    
      // Send the HTTP POST request back to PayPal for validation
      fputs($fp, $header . $req);
  5. Parse PayPal's response to your acknowledgement to determine whether the original notification was OK - if so, process it.
      while (!feof($fp)) {                     // While not EOF
        $res = fgets($fp, 1024);               // Get the acknowledgement response
        if (strcmp ($res, "VERIFIED") == 0) {  // Response contains VERIFIED - process notification
    
          // Send an email announcing the IPN message is VERIFIED
          $mail_From    = "IPN@example.com";
          $mail_To      = "Your-eMail-Address";
          $mail_Subject = "VERIFIED IPN";
          $mail_Body    = $req;
          mail($mail_To, $mail_Subject, $mail_Body, $mail_From);
    
          // Authentication protocol is complete - OK to process notification contents
    
          // Possible processing steps for a payment include the following:
    
          // Check that the payment_status is Completed
          // Check that txn_id has not been previously processed
          // Check that receiver_email is your Primary PayPal email
          // Check that payment_amount/payment_currency are correct
          // Process payment
    
        } 
        else if (strcmp ($res, "INVALID") == 0) { Response contains INVALID - reject notification
    
          // Authentication protocol is complete - begin error handling
    
          // Send an email announcing the IPN message is INVALID
          $mail_From    = "IPN@example.com";
          $mail_To      = "Your-eMail-Address";
          $mail_Subject = "INVALID IPN";
          $mail_Body    = $req;
    
          mail($mail_To, $mail_Subject, $mail_Body, $mail_From);
        }
      }
  6. Close the file and end the PHP script.

      fclose($fp);  // Close the file

Tuesday, November 19, 2013

how to create zip file to multiple pdf, image, and other documents using php

Step-1> simple create a zipcreation.php and paste below those code and run some change are destination url and your multiple file location have to change
----------------------------------------zipcreation.php---------------------------------------------------
<?php
//Author : Bikash ranjan nayak
/* creates a compressed zip file */
function Create_YourFilestoZip($files = array(),$destination = '',$overwrite = false) {
//if the zip file already exists and overwrite is false, return false
if(file_exists($destination) && !$overwrite) { return false; }
//vars
$valid_files = array();
//if files were passed in...
if(is_array($files)) {
//cycle through each file
foreach($files as $file) {
//make sure the file exists
if(file_exists($file)) {
$valid_files[] = $file;
}
}
}
//if we have good files...
if(count($valid_files)) {
//class ZipArchive is php built libary class
$zipobj = new ZipArchive();
if($zipobj->open($destination,$overwrite ? ZIPARCHIVE::OVERWRITE : ZIPARCHIVE::CREATE) !== true) {
return false;
}
//add the files
foreach($valid_files as $file) {
$zipobj->addFile($file,$file);
}
//debug
//echo 'The zip archive contains ',$zip->numFiles,' files with a status of ',$zip->status;

//close the zip -- done!
$zipobj->close();

//check to make sure the file exists
return file_exists($destination);
}
else
{
return false;
}
}

$list_of_files_for_zip = array(
'D:\xampp\htdocs\test/bikash-ranjan-nayak.pdf',
'D:\xampp\htdocs\test/bikash-ranjan-nayak.gif'


);
//if true, good; if false, zip creation failed
if(Create_YourFilestoZip($list_of_files_for_zip,'D:\xampp\htdocs\test\createpdf/bikash-ranjan-nayak.zip'))
{
    echo "zip file has been created success fully";
 }else
 {
    echo "zip file creation fail";
 }
-------------------------------------------------------------------------------------------------

Virtuemart 10 awesome free templates must be your choice free download

Hello guy do not struggling for eCommerce template in VirtueMart 2.5 Joomla 2.5  to you can find here


download here Virtuemart one-page checkout for Joomla 2.5 latest version


have a nice achieved here.........go to ......your E-commerce application :)

Monday, November 18, 2013

how to delete all cookies of my website in php?[SOLVE]

First you get the all cookies value using $_SERVER['HTTP_COOKIE'] then delete according your time you want
<?php 
if (isset($_SERVER['HTTP_COOKIE'])) {
    $cookies = explode(';', $_SERVER['HTTP_COOKIE']);
    foreach($cookies as $cookie) {
        $parts = explode('=', $cookie);
        $name = trim($parts[0]);
        setcookie($name, '', time()-1000);
        setcookie($name, '', time()-1000, '/');
    }
}
?>

Friday, November 15, 2013

simple google chart api easily in integrate to application and example solve

Step1->include google apic
<script type="text/javascript" src="https://www.google.com/jsapi"></script>

 <script type="text/javascript">
  
    google.load("visualization", "1", {packages:["corechart"]});
    google.setOnLoadCallback(drawChart2);
    function drawChart2() {
      var data = new google.visualization.DataTable();
      data.addColumn('string', 'Date');
      data.addColumn('number', 'Sales Amount');
      data.addColumn('number', 'Quantity Sold');
      //["Sale date", sale amount,sale quantity]
      data.addRows([["2013-06-05", 14.95, 1],["2013-06-07", 29.9, 2],["2013-06-11", 14.95, 1],["2013-06-13", 30, 3],["2013-06-17", 19.9, 2],["2013-06-18", 14.95, 1],["2013-06-19", 0.2, 2],["2013-06-20", 88.85, 9],["2013-06-21", 117.1, 16],["2013-06-22", 71.8, 7],["2013-06-24", 164.45, 11],["2013-06-25", 492.95, 42],["2013-06-26", 271.85, 30],["2013-06-27", 95.95, 13],["2013-06-28", 52.9, 5],["2013-06-29", 14.95, 1]]);

      var chart = new google.visualization.AreaChart(document.getElementById('chart_div_2'));
      chart.draw(data, {width: 650, height: 240, title: 'Sale Amount and Quantity Sold by Date', colors:['#3366CC','#9AA2B4','#FFE1C9'],
                        hAxis: {title: 'Date', titleTextStyle: {color: 'black'}}
                       });
    }
    </script>
       <div id="chart_div_2"></div>
     <script type="text/javascript">   
      // Load the Visualization API and the piechart package.
      google.load('visualization', '1.0', {'packages':['corechart']});
     
      // Set a callback to run when the Google Visualization API is loaded.
      google.setOnLoadCallback(drawChart);
     
      // Callback that creates and populates a data table,
      // instantiates the pie chart, passes in the data and
      // draws it.
      function drawChart() {

      // Create the data table.
      var data = new google.visualization.DataTable();
      data.addColumn('string', 'Products');
      data.addColumn('number', 'Numbers');
      data.addRows([
        ["&quot;The Map&quot; Webinar Series", 3],["The “One Minute Manifestor” Audio Technique ", 1],["&quot;Life On Planet Earth: A User's Manual&quot; (E-Book)", 125],["The Map: To Our Responsive Universe, Where Dreams Really Do Come True!", 3],["&quot;Conscious Creation&quot; Inspiration Cards", 10],["Live a Life You Love Vneck TShirt", 48],      ]);

      // Set chart options
      var options = {'title':'Product Sale Quantity Stats',
                     'width':450,
                     'height':300};

      // Instantiate and draw our chart, passing in some options.
      var chart = new google.visualization.PieChart(document.getElementById('chart_div_1'));
      chart.draw(data, options);
    }
    </script>
       <div id="chart_div_1"></div>