Thursday, June 19, 2014

Monday, June 9, 2014

How to upload files on another FTP in PHP

First of all make the connection with ftp host and then login to ftp with username and password.
then If you are logged in the put the files on the ftp with ftp_put function.

$connection = ftp_connect(FTP_HOST );
$login = ftp_login( $connection, FTP_USERNAME, FTP_PASSWORD);
if ($connection AND $login ) {

ftp_put($connection, "REMOTE_FTP", "LOCAL_FILE_PATH", FTP_BINARY);
ftp_close($connection);
}

Need any help contact me.

Thursday, October 10, 2013

Solved - mouseover not working on dynamically generated ul li

$(".CLASS_NAME").on("mouseover", "li", function() {
   alert('now the mouseover will work');
});
 
NOTE : replace CLASS_NAME with your selector. 
 
Read the DOCS! http://api.jquery.com/on/ 

Friday, September 13, 2013

How to replace multiple occurence in a string in javascript

Here is the code :
str = str.replace(/abc/g, '');
 
or you can use this one :
var find = 'abcxyz';
var re = new RegExp(find, 'g');
str = str.replace(re, ''); 

or

function replaceAll(find, replace, str) {
  return str.replace(new RegExp(find, 'g'), replace);
}
 
call the function :  
replaceAll(find, replace, str);

Monday, June 10, 2013

How to Set Permission on Custom module in magento? Solved

I have got the solution, I think It will help you.
Here it is:
Lets say my module name is fabric

Change your /app/code/local/<Namespace>/<Module>/etc/config.xml

        <acl>
            <resources>
                <all>
                    <title>Allow Everything</title>
                </all>
                <admin>
                    <children>
                        <Store_Fabric>
                            <title>Swatches</title>
                            <sort_order>10</sort_order>
                        </Store_Fabric>
                    </children>
                </admin>
            </resources>
        </acl>


To :
        <acl>
            <resources>
                <all>
                    <title>Allow Everything</title>
                </all>
                <admin>
                    <children>
                       <fabric translate="title" module="fabric">
                            <title>Swatches</title>
                            <sort_order>10</sort_order>
                            <children>
                                <items module="fabric">
                                   <title>Manage Swatches</title>
                                    <sort_order>0</sort_order>
                                       <action>fabric/adminhtml_fabric</action>
                                </items>
                            </children>
                        </fabric>
                    </children>
                </admin>
            </resources>
        </acl>


Thanks
Vipin Choudhary

Thursday, January 10, 2013

Wordpress Blank Page on Logout - Solved

Check your themes's function.php and remove the blank spaces. Specially from the end of the file.

Friday, December 7, 2012

HOw to removed HTML tags codes, javascript sections and white space from the string or document solution

<?php // $document should contain an HTML document. // This will remove HTML tags, javascript sections // and white space. It will also convert some // common HTML entities to their text equivalent.
$search = array ("'<script[^>]*?>.*?</script>'si",  // Strip out javascript                  "'<[/!]*?[^<>]*?>'si",          // Strip out HTML tags                  "'([rn])[s]+'",                // Strip out white space                  "'&(quot|#34);'i",                // Replace HTML entities                  "'&(amp|#38);'i",                  "'&(lt|#60);'i",                  "'&(gt|#62);'i",                  "'&(nbsp|#160);'i",                  "'&(iexcl|#161);'i",                  "'&(cent|#162);'i",                  "'&(pound|#163);'i",                  "'&(copy|#169);'i",                  "'&#(d+);'e");                    // evaluate as php $replace = array ("",                  "",                  "\1",                  "\"",                  "&",                  "<",                  ">",                  " ",                  chr(161),                  chr(162),                  chr(163),                  chr(169),                  "chr(\1)"); $text = preg_replace($search, $replace, $document); ?>
Source:http://forums.digitalpoint.com/showthread.php?t=57667

Wednesday, December 5, 2012

How to get Logged in User Data in Magento

Here is the information for magento logged in users data.
Just paste this code to your magento template files or php files too.

echo Mage::helper('customer')->getCustomer()->getId();
print_r(Mage::helper('customer')->getCustomer()->getData());
echo Mage::getSingleton('customer/session')->getCustomer()->getId();

Sunday, August 12, 2012

How can to implement Captcha with the refresh feature ( button )?

<?php
  session_start(); // start a session
  $image = imagecreate(50, 20); //create blank image (width, height)
  $bgcolor = imagecolorallocate($image, 0, 0, 0); //add background color with RGB.
  $textcolor = imagecolorallocate($image, 255, 255, 255); //add text/code color with RGB.
    $characters_on_image = 4;
    $possible_letters = '23456789bcdfghjkmnpqrstvwxyz';
    $i = 0;
    $code = '';
    while ($i < $characters_on_image) {
    $code .= substr($possible_letters, mt_rand(0, strlen($possible_letters)-1), 1);
    $i++;
    }

  $_SESSION['captcha_code'] = ($code); //add the code to session
  imagestring($image, 10, 8, 3, $code, $textcolor); //create image with all the settings above.
  header ("Content-type: image/png"); // define image type
  imagepng($image); //display image as PNG
?>
Save this code in the file image.php

HTML File:
<table> <tr>
              <td valign="top">
<input type="text" name="txt_captcha_code" id="txt_captcha_code" value="" style="width:120px;" />
<img src="./cimage.php" id="captcha">
              <a href="JavaScript: new_captcha();">
                <img border="0" alt="" src="refresh.png" align="bottom">
              </a>
              </td> </tr></table>
JavaScript Code :
<script type="text/javascript">
function new_captcha()
{
var c_currentTime = new Date();
var c_miliseconds = c_currentTime.getTime();

document.getElementById('captcha').src = 'image.php?x='+ c_miliseconds;
}
</script>

Friday, August 3, 2012

Fixed - Magento Admin showing 404 error whem transfering to another server

When I tranered the Magento site from my  server to client server ( Hostgator )  then I got the 404 Error when accessing the admin panel. 

Run the below SQL Query and the problem will be fixed.


Solution:

- Open PhpMyAdmin
- Go to your database
- Click SQL
- Run the following SQL Query:
SET FOREIGN_KEY_CHECKS=0;
UPDATE `core_store` SET store_id = 0 WHERE code='admin';
UPDATE `core_store_group` SET group_id = 0 WHERE name='Default';
UPDATE `core_website` SET website_id = 0 WHERE code='admin';
UPDATE `customer_group` SET customer_group_id = 0 WHERE customer_group_code='NOT LOGGED IN';
SET FOREIGN_KEY_CHECKS=1;
That’s all. Your error is solved now.

Monday, February 14, 2011

Continuie button is missing in Oscommerce

Add the below code BEFORE "if (isset($navigation->path[$back])) {" in the shopping_cart.php
// BOF FWR Mod category based continue button
        $count = count($products);
        if( isset($products[$count-1]['id']) ) {
          $continueButtonId = tep_get_product_path(str_replace(strstr($products[$count-1]['id'], '{'), '', $products[$count-1]['id']));
        }
        if( isset($continueButtonId) ) {
?>
                                <td align="center" class="main"><?php echo '<a href="' . tep_href_link(FILENAME_DEFAULT, 'cPath=' . $continueButtonId) . '">' . tep_image_button('button_continue_shopping.gif', IMAGE_BUTTON_CONTINUE_SHOPPING) . '</a>'; ?></td>
<?php
    //if (isset($navigation->path[$back])) {
        } else

Thursday, February 10, 2011

How do you disable warnings in PHP?

display_errors = Off
...in your php.ini file. i highly recommend that you don't do this on your development environment as this will nearly impossible to debug your code.

You can also use:
error_reporting(0);  at the top of your script.