Showing posts with label web program. Show all posts
Showing posts with label web program. Show all posts

Monday, June 29, 2015

How To Reset Wordpress Password

Hi guys, In this post i am going to show you how to reset your magento password if you forget it not to worry at all. All what you need to do is you need to login to your phpMyadmin panel.

select wp-user table over there


it will show up users in left hand side you need to edit it

now you need to put you desired password in user_pass by selecting md 5 in dropdown

Then click on go botton

Thats all done now try login with the new password.

Hope this post will help you.



How to Reset Zencart Password

Hi guys, in this post i am just going to show you how to reset zencart admin password if you loss it. by default zencart ask to change password after every three months in this case it my be difficult to remember the password. So you if forget your password of admin panel of zencart not to worry about it. you can reset it from you phpMyadmin panel it is quite very easy. you need to execute two sql command that is one to delete the current admin and second one is to insert admin new information.

to delete current admin user of your zencart store you need to execute

DELETE FROM admin WHERE admin_name = 'admin'; 

you need to change admin to the admin username of you zencart store. then you will have to insert fresh admin user information for this you will have to execute

INSERT INTO admin (admin_name, admin_email, admin_pass, admin_profile) 
VALUES ('admin', 'admin@yoursite.com', '351683ea4e19efe34874b501fdbf9792:9b', 1);

change admin email to you store admin email. now

User: admin
Password: admin

is set you can now try login to your admin panel it will ask you to change the password as after fresh installation.

hope this post will you help you.

Thursday, June 25, 2015

how to add custom additional tab for my magento description

Hi guys if you are looking for how to make your own custom tag in magento product description section like specification, benefits or ingredients you need to play with attributes. In my case I have made two tabs benefits or ingredients. The process of adding extra tabs I am describing here hope this will help you.
1.       You need to modify a file which is app/design/frontend/YOUR_THEME/default/layout/catalog.xml
Look for the code

<block type="catalog/product_view_description" name="product.description" as="description" template="catalog/product/view/description.phtml">
                    <action method="addToParentGroup"><group>detailed_info</group></action>
                    <action method="setTitle" translate="value"><value>HOW TO USE</value></action>
                </block>

Under this code you need to add a block in my case I have added two blocks

<block type="catalog/product_view_attributes" name="product.benefits" as="benefits" template="catalog/product/view/benefits.phtml">
                                                                    <action method="addToParentGroup"><group>detailed_info</group></action>
                                                                    <action method="setTitle" translate="value"><value>BENEFITS</value></action>
                                                                </block>


<block type="catalog/product_view_attributes" name="product.ingredients" as="ingredients" template="catalog/product/view/ingredients.phtml">
                                                                    <action method="addToParentGroup"><group>detailed_info</group></action>
                                                                    <action method="setTitle" translate="value"><value>INGREDIENTS</value></action>
                                                                </block>

After that you need to create phtml file for each block which will be saved under app/design/frontend/YOUR_TEMPLATE/default/template/catalog/product/view
I have made two files benefits.phtml and ingredients.phtml as described you I had added two blocks under these phtml file you need to write some codes. In benefits I have written

<?php $_helper = $this->helper('catalog/output'); ?>
<?php $_product = $this->getProduct(); ?>
<?php if ($_product->getbenefits()):?>
                <div class="short-benefits">
                    <h2><?php echo $this->__('benefits') ?></h2>
                    <div class="std"><?php echo $_helper->productAttribute($_product, nl2br($_product->getbenefits()), 'benefits') ?></div>
                </div>
            <?php endif;?>

And in ingredients I have written

<?php $_helper = $this->helper('catalog/output'); ?>
<?php $_product = $this->getProduct(); ?>
<?php if ($_product->getingredients()):?>
                <div class="short-ingredients">
                    <h2><?php echo $this->__('ingredients') ?></h2>
                    <div class="std"><?php echo $_helper->productAttribute($_product, nl2br($_product->getingredients()), 'ingredients') ?></div>
                </div>
            <?php endif;?>

Once these you have completed you need to login to you magento admin panel and go to
Catalog->attributes->manage attribute



Click on add new and assign the same name as defined in the block like in name=” product.benefits” then make the attribute with benefits name in Catalog Input Type for Store Owner select text area.
If you wish to allow html editor then in Enable WYSIWYG select yes



Now in the left hand side manage label / options
Put the name of the tab like benefits



Now you have made your attribute to assign it you need go to catalog->attributes-> manage attribute sets



Over these select default. Once you click on default you will see in right Unassigned Attributes with the attribute that you have made simpally you need to drag it to your group I had put it after short_description and click on save. Now you are done.

Go catalog manage product and you will see a box that will ask you to enter benefits once you put the content over there it will show up in your produt desctiption page or product view page of your mangento store.



final result

Monday, June 22, 2015

Display Reviews Starts on Product listing page Magento

hi guys if you want to display reviews rating stars on product listing page or anywhere else you will need up the following code.

<?php
$storeId = Mage::app()->getStore()->getId();
$summaryData = Mage::getModel('review/review_summary')->setStoreId($storeId)  ->load($_product->getId());
?>
<div class="ratings" style="text-align: center;">
        <div class="rating-box">
            <div class="rating" style="width:<?php echo $summaryData['rating_summary']; ?>%"></div>          
         </div>
</div>



Just you need to copy and paste above code to your program and you are done after placing this code you might need to delete cache of magento which is under var/cache.

if you need any other help or facing any issue please comment i will get back to you soon with you reply.


Wednesday, June 3, 2015

can not login to magento after installation

Hi guys if you can not login to magento admin panel after installation it's not an issue. All what you need to do is you will have to modify up a file of magento.



Go to:
app\code\core\Mage\Core\Model\Session\Abstract\Varien.php

and look for this code.

$cookieParams = array(
            'lifetime' => $cookie->getLifetime(),
            'path'     => $cookie->getPath(),
            'domain'   => $cookie->getConfigDomain(),
            'secure'   => $cookie->isSecure(),
            'httponly' => $cookie->getHttponly()
        );

        if (!$cookieParams['httponly']) {
            unset($cookieParams['httponly']);
            if (!$cookieParams['secure']) {
                unset($cookieParams['secure']);
                if (!$cookieParams['domain']) {
                    unset($cookieParams['domain']);
                }
            }
        }

you need to comment all of these codes. or you can replace this code with

/*$cookieParams = array(
            'lifetime' => $cookie->getLifetime(),
            'path'     => $cookie->getPath(),
            'domain'   => $cookie->getConfigDomain(),
            'secure'   => $cookie->isSecure(),
            'httponly' => $cookie->getHttponly()
        );

        if (!$cookieParams['httponly']) {
            unset($cookieParams['httponly']);
            if (!$cookieParams['secure']) {
                unset($cookieParams['secure']);
                if (!$cookieParams['domain']) {
                    unset($cookieParams['domain']);
                }
            }
        }*/

After this modification open your admin URL

http://domain.com/index.php/admin

and now try login with the username and password that you have setup on the installation time.

Note: This is tested on magento ver1.9.x

Friday, April 24, 2015

Magento dimensional magento free download

If you want to to set you custom dimensional shipping in magento according to height, width, length and weight you can use this extension.



To use this extension you should have little bit knowledge about php. You need to edit a file according to your condition

How to use


  1. extract magento-dimensional-shipping
  2. Go to app -> code -> local-> Foobar -> Shipping -> Model -> Carrier -> Customrate.php
  3. open Customrate.php in any editore like notepad dreamviewer or anything you use
  4. Go to line 17 and change values to you own condition
  5. upload all the folders in root directory
  6. login to magento admin


clear all cache and you are done!!!!!!!!

Hope this plugin will short it up.

Wednesday, February 4, 2015

WP-Galleriffic galleriffic WordPress extension plugins

Galleriffic is a jQuery plugin that provides a rich, post-back free experience optimized to handle high volumes of photos while conserving bandwidth. You can download the source file form http://www.twospy.com/galleriffic/


If you are developing a wordpress website you can use galleriffic gallery using this extension you can download it from here.

How to use galleriffic wordpress extension

1. First of all you need to download the css and js file form http://www.twospy.com/galleriffic/
2. Then you need to call it in you header file you can get this file under wp-contents->themes->your_theme->header.php
3. Then you need to extract and upload the plugins file to wp-contents->plugins
4. After uploading wordpress extension to your plugins folder you need to setup your gallery follow these steps






Shortcode for gallery [nggallery id=1 template="galleriffic"]



Tuesday, January 27, 2015

Paypal Error (35) error 14094410: SSLV3 zencart

If you are using zencart 1.5.1 and payment getway as paypal then you might get a error message Paypal Error (35) error 14094410: SSLV3. This is acctually because of update from paypal you can see the SSLV3 paypal update here. To overcome this problem i just have edited a file of Zencart. The file location is

includes->modules->payment->paypal->paypal_curl.php

The whole modefied code is here you simpally need to copy and pest it into paypal_curl.php and update it on to your web server.


 <?php  
 /**  
  * paypal_curl.php communications class for PayPal Express Checkout / Website Payments Pro / Payflow Pro payment methods  
  *  
  * @package paymentMethod  
  * @copyright Copyright 2003-2012 Zen Cart Development Team  
  * @license http://www.zen-cart.com/license/2_0.txt GNU Public License V2.0  
  * @version GIT: $Id: Author: DrByte Tue Aug 28 14:21:34 2012 -0400 Modified in v1.5.1 $  
  */  
 /**  
  * PayPal NVP (v61) and Payflow Pro (v4 HTTP API) implementation via cURL.  
  */  
 class paypal_curl extends base {  
  /**  
   * What level should we log at? Valid levels are:  
   *  1 - Log only severe errors.  
   *  2 - Date/time of operation, operation name, elapsed time, success or failure indication.  
   *  3 - Full text of requests and responses and other debugging messages.  
   *  
   * @access protected  
   *  
   * @var integer $_logLevel  
   */  
  var $_logLevel = 3;  
  /**  
   * If we're logging, what directory should we create log files in?  
   * Note that a log name coincides with a symlink, logging will  
   * *not* be done to avoid security problems. File names are  
   * <DateStamp>.PayflowPro.log.  
   *  
   * @access protected  
   *  
   * @var string $_logFile  
   */  
  var $_logDir = 'logs';  
  /**  
   * Debug or production?  
   */  
  var $_server = 'sandbox';  
  /**  
   * URL endpoints -- defaults here are for three-token NVP implementation  
   */  
  var $_endpoints = array('live'  => 'https://api-3t.paypal.com/nvp',  
              'sandbox' => 'https://api-3t.sandbox.paypal.com/nvp');  
  /**  
   * Options for cURL. Defaults to preferred (constant) options.  
   */  
  var $_curlOptions = array(CURLOPT_HEADER => 0,  
               CURLOPT_RETURNTRANSFER => TRUE,  
               CURLOPT_TIMEOUT => 60,  
               CURLOPT_FOLLOWLOCATION => FALSE,  
               CURLOPT_SSL_VERIFYPEER => FALSE,  
               CURLOPT_SSL_VERIFYHOST => 2,  
               //CURLOPT_SSLVERSION => 3,  
               CURLOPT_FORBID_REUSE => TRUE,  
               CURLOPT_FRESH_CONNECT => TRUE,  
               CURLOPT_POST => TRUE,  
               );  
  /**  
   * Parameters that are always required and that don't change  
   * request to request.  
   */  
  var $_partner;  
  var $_vendor;  
  var $_user;  
  var $_pwd;  
  var $_version;  
  var $_signature;  
  /**  
   * nvp or payflow?  
   */  
  var $_mode = 'nvp';  
  /**  
   * Sales or authorizations? For the U.K. this will always be 'S'  
   * (Sale) because of Switch and Solo cards which don't support  
   * authorizations. The other option is 'A' for Authorization.  
   * NOTE: 'A' is not supported for pre-signup-EC-boarding.  
   */  
  var $_trxtype = 'S';  
  /**  
   * Store the last-generated name/value list for debugging.  
   */  
  var $lastParamList = null;  
  /**  
   * Store the last-generated headers for debugging.  
   */  
  var $lastHeaders = null;  
  /**  
   * submission values  
   */  
  var $values = array();  
  /**  
   * Constructor. Sets up communication infrastructure.  
   */  
  function paypal_curl($params = array()) {  
   foreach ($params as $name => $value) {  
    $this->setParam($name, $value);  
   }  
  }  
  /**  
   * SetExpressCheckout  
   *  
   * Prepares to send customer to PayPal site so they can  
   * log in and choose their funding source and shipping address.  
   *  
   * The token returned to this function is passed to PayPal in  
   * order to link their PayPal selections to their cart actions.  
   */  
  function SetExpressCheckout($returnUrl, $cancelUrl, $options = array()) {  
   $values = $options;  
   if ($this->_mode == 'payflow') {  
    $values = array_merge($values, array('ACTION' => 'S', /* ACTION=S denotes SetExpressCheckout */  
                       'TENDER' => 'P',  
                       'TRXTYPE' => $this->_trxtype,  
                       'RETURNURL' => $returnUrl,  
                       'CANCELURL' => $cancelUrl));  
   } elseif ($this->_mode == 'nvp') {  
    if (!isset($values['PAYMENTACTION']) || ($this->checkHasApiCredentials() === FALSE)) $values['PAYMENTACTION'] = ($this->_trxtype == 'S' || ($this->checkHasApiCredentials() === FALSE) ? 'Sale' : 'Authorization');  
    $values['RETURNURL'] = urlencode($returnUrl);  
    $values['CANCELURL'] = urlencode($cancelUrl);  
   }  
   // convert country code key to proper key name for paypal 2.0 (needed when sending express checkout via payflow gateway, due to PayPal field naming inconsistency)  
   if ($this->_mode == 'payflow') {  
    if (!isset($values['SHIPTOCOUNTRY']) && isset($values['SHIPTOCOUNTRYCODE'])) {  
     $values['SHIPTOCOUNTRY'] = $values['SHIPTOCOUNTRYCODE'];  
     unset($values['SHIPTOCOUNTRYCODE']);  
    }  
    //if (isset($values['AMT'])) unset($values['AMT']);  
   }  
   // allow page-styling support -- see language file for definitions  
   if (defined('MODULE_PAYMENT_PAYPALWPP_PAGE_STYLE'))  $values['PAGESTYLE'] = MODULE_PAYMENT_PAYPALWPP_PAGE_STYLE;  
   if (defined('MODULE_PAYMENT_PAYPAL_LOGO_IMAGE')) $values['LOGOIMG'] = urlencode(MODULE_PAYMENT_LOGO_IMAGE);  
   if (defined('MODULE_PAYMENT_PAYPAL_CART_BORDER_COLOR')) $values['CARTBORDERCOLOR'] = MODULE_PAYMENT_PAYPAL_CART_BORDER_COLOR;  
   if (defined('MODULE_PAYMENT_PAYPALWPP_HEADER_IMAGE')) $values['HDRIMG'] = urlencode(MODULE_PAYMENT_PAYPALWPP_HEADER_IMAGE);  
   if (defined('MODULE_PAYMENT_PAYPALWPP_PAGECOLOR'))  $values['PAYFLOWCOLOR'] = MODULE_PAYMENT_PAYPALWPP_PAGECOLOR;  
   if (defined('MODULE_PAYMENT_PAYPALWPP_HEADER_BORDER_COLOR')) $values['HDRBORDERCOLOR'] = MODULE_PAYMENT_PAYPALWPP_HEADER_BORDER_COLOR;  
   if (defined('MODULE_PAYMENT_PAYPALWPP_HEADER_BACK_COLOR')) $values['HDRBACKCOLOR'] = MODULE_PAYMENT_PAYPALWPP_HEADER_BACK_COLOR;  
   if (PAYPAL_DEV_MODE == 'true') $this->log('SetExpressCheckout - breakpoint 1 - [' . print_r($values, true) .']');  
   $this->values = $values;  
   $this->notify('NOTIFY_PAYPAL_SETEXPRESSCHECKOUT');  
   return $this->_request($this->values, 'SetExpressCheckout');  
  }  
  /**  
   * GetExpressCheckoutDetails  
   *  
   * When customer returns from PayPal site, this retrieves their payment/shipping data for use in Zen Cart  
   */  
  function GetExpressCheckoutDetails($token, $optional = array()) {  
   $values = array_merge($optional, array('TOKEN' => $token));  
   if ($this->_mode == 'payflow') {  
    $values = array_merge($values, array('ACTION' => 'G', /* ACTION=G denotes GetExpressCheckoutDetails */  
                       'TENDER' => 'P',  
                       'TRXTYPE' => $this->_trxtype));  
   }  
   return $this->_request($values, 'GetExpressCheckoutDetails');  
  }  
  /**  
   * DoExpressCheckoutPayment  
   *  
   * Completes the sale using PayPal as payment choice  
   */  
  function DoExpressCheckoutPayment($token, $payerId, $options = array()) {  
   $values = array_merge($options, array('TOKEN'  => $token,  
                      'PAYERID' => $payerId));  
   if (PAYPAL_DEV_MODE == 'true') $this->log('DoExpressCheckout - breakpoint 1 - ['.$token . ' ' . $payerId . ' ' . "]\n\n[" . print_r($values, true) .']', $token);  
   if ($this->_mode == 'payflow') {  
    $values['ACTION'] = 'D'; /* ACTION=D denotes DoExpressCheckoutPayment via Payflow */  
    $values['TENDER'] = 'P';  
    $values['TRXTYPE'] = $this->_trxtype;  
    $values['NOTIFYURL'] = zen_href_link('ipn_main_handler.php', '', 'SSL',false,false,true);  
   } elseif ($this->_mode == 'nvp') {  
    if (!isset($values['PAYMENTACTION']) || $this->checkHasApiCredentials() === FALSE) $values['PAYMENTACTION'] = ($this->_trxtype == 'S' || ($this->checkHasApiCredentials() === FALSE) ? 'Sale' : 'Authorization');  
    $values['NOTIFYURL'] = urlencode(zen_href_link('ipn_main_handler.php', '', 'SSL',false,false,true));  
   }  
   $this->values = $values;  
   $this->notify('NOTIFY_PAYPAL_DOEXPRESSCHECKOUTPAYMENT');  
   if (PAYPAL_DEV_MODE == 'true') $this->log('DoExpressCheckout - breakpoint 2 '.print_r($this->values, true), $token);  
   return $this->_request($this->values, 'DoExpressCheckoutPayment');  
  }  
  /**  
   * DoDirectPayment  
   * Sends CC information to gateway for processing.  
   *  
   * Requires Website Payments Pro or Payflow Pro as merchant gateway.  
   *  
   * PAYMENTACTION = Authorization (auth/capt) or Sale (final)  
   */  
  function DoDirectPayment($cc, $cvv2 = '', $exp, $fname = null, $lname = null, $cc_type, $options = array(), $nvp = array() ) {  
   $values = $options;  
   $values['ACCT'] = $cc;  
   if ($cvv2 != '') $values['CVV2'] = $cvv2;  
   $values['FIRSTNAME'] = $fname;  
   $values['LASTNAME'] = $lname;  
   if (isset($values['NAME'])) unset ($values['NAME']);  
   if ($this->_mode == 'payflow') {  
    $values['EXPDATE'] = $exp;  
    $values['TENDER'] = 'C';  
    $values['TRXTYPE'] = $this->_trxtype;  
    $values['VERBOSITY'] = 'MEDIUM';  
    $values['NOTIFYURL'] = zen_href_link('ipn_main_handler.php', '', 'SSL',false,false,true);  
   } elseif ($this->_mode == 'nvp') {  
    $values = array_merge($values, $nvp);  
    if (isset($values['ECI'])) {  
     $values['ECI3DS'] = $values['ECI'];  
     unset($values['ECI']);  
    }  
    $values['CREDITCARDTYPE'] = ($cc_type == 'American Express') ? 'Amex' : $cc_type;  
    $values['NOTIFYURL'] = urlencode(zen_href_link('ipn_main_handler.php', '', 'SSL',false,false,true));  
    if (!isset($values['PAYMENTACTION'])) $values['PAYMENTACTION'] = ($this->_trxtype == 'S' ? 'Sale' : 'Authorization');  
    if (isset($values['COUNTRY'])) unset ($values['COUNTRY']);  
    if (isset($values['COMMENT1'])) unset ($values['COMMENT1']);  
    if (isset($values['COMMENT2'])) unset ($values['COMMENT2']);  
    if (isset($values['CUSTREF'])) unset ($values['CUSTREF']);  
   }  
   $this->values = $values;  
   $this->notify('NOTIFY_PAYPAL_DODIRECTPAYMENT');  
   ksort($this->values);  
   return $this->_request($this->values, 'DoDirectPayment');  
  }  
  /**  
   * RefundTransaction  
   *  
   * Used to refund all or part of a given transaction  
   */  
  function RefundTransaction($oID, $txnID, $amount = 'Full', $note = '', $curCode = 'USD') {  
   if ($this->_mode == 'payflow') {  
    $values['ORIGID'] = $txnID;  
    $values['TENDER'] = 'C';  
    $values['TRXTYPE'] = 'C';  
    $values['AMT'] = number_format((float)$amount, 2);  
    if ($note != '') $values['COMMENT2'] = $note;  
   } elseif ($this->_mode == 'nvp') {  
    $values['TRANSACTIONID'] = $txnID;  
    if ($amount != 'Full' && (float)$amount > 0) {  
     $values['REFUNDTYPE'] = 'Partial';  
     $values['CURRENCYCODE'] = $curCode;  
     $values['AMT'] = number_format((float)$amount, 2);  
    } else {  
     $values['REFUNDTYPE'] = 'Full';  
    }  
    if ($note != '') $values['NOTE'] = $note;  
   }  
   return $this->_request($values, 'RefundTransaction');  
  }  
  /**  
   * DoVoid  
   *  
   * Used to void a previously authorized transaction  
   */  
  function DoVoid($txnID, $note = '') {  
   if ($this->_mode == 'payflow') {  
    $values['ORIGID'] = $txnID;  
    $values['TENDER'] = 'C';  
    $values['TRXTYPE'] = 'V';  
    if ($note != '') $values['COMMENT2'] = $note;  
   } elseif ($this->_mode == 'nvp') {  
    $values['AUTHORIZATIONID'] = $txnID;  
    if ($note != '') $values['NOTE'] = $note;  
   }  
   return $this->_request($values, 'DoVoid');  
  }  
  /**  
   * DoAuthorization  
   *  
   * Used to authorize part of a previously placed order which was initiated as authType of Order  
   */  
  function DoAuthorization($txnID, $amount = 0, $currency = 'USD', $entity = 'Order') {  
   $values['TRANSACTIONID'] = $txnID;  
   $values['AMT'] = number_format($amount, 2, '.', ',');  
   $values['TRANSACTIONENTITY'] = $entity;  
   $values['CURRENCYCODE'] = $currency;  
   return $this->_request($values, 'DoAuthorization');  
  }  
  /**  
   * DoReauthorization  
   *  
   * Used to reauthorize a previously-authorized order which has expired  
   */  
  function DoReauthorization($txnID, $amount = 0, $currency = 'USD') {  
   $values['AUTHORIZATIONID'] = $txnID;  
   $values['AMT'] = number_format($amount, 2, '.', ',');  
   $values['CURRENCYCODE'] = $currency;  
   return $this->_request($values, 'DoReauthorization');  
  }  
  /**  
   * DoCapture  
   *  
   * Used to capture part or all of a previously placed order which was only authorized  
   */  
  function DoCapture($txnID, $amount = 0, $currency = 'USD', $captureType = 'Complete', $invNum = '', $note = '') {  
   if ($this->_mode == 'payflow') {  
    $values['ORIGID'] = $txnID;  
    $values['TENDER'] = 'C';  
    $values['TRXTYPE'] = 'D';  
    $values['VERBOSITY'] = 'MEDIUM';  
    if ($invNum != '') $values['INVNUM'] = $invNum;  
    if ($note != '') $values['COMMENT2'] = $note;  
   } elseif ($this->_mode == 'nvp') {  
    $values['AUTHORIZATIONID'] = $txnID;  
    $values['COMPLETETYPE'] = $captureType;  
    $values['AMT'] = number_format((float)$amount, 2);  
    $values['CURRENCYCODE'] = $currency;  
    if ($invNum != '') $values['INVNUM'] = $invNum;  
    if ($note != '') $values['NOTE'] = $note;  
   }  
   return $this->_request($values, 'DoCapture');  
  }  
  /**  
   * ManagePendingTransactionStatus  
   *  
   * Accept/Deny pending FMF transactions  
   */  
  function ManagePendingTransactionStatus($txnID, $action) {  
   if (!in_array($action, array('Accept', 'Deny'))) return FALSE;  
   $values['TRANSACTIONID'] = $txnID;  
   $values['ACTION'] = $action;  
   return $this->_request($values, 'ManagePendingTransactionStatus');  
  }  
  /**  
   * GetTransactionDetails  
   *  
   * Used to read data from PayPal for a given transaction  
   */  
  function GetTransactionDetails($txnID) {  
   if ($this->_mode == 'payflow') {  
    $values['ORIGID'] = $txnID;  
    $values['TENDER'] = 'C';  
    $values['TRXTYPE'] = 'I';  
    $values['VERBOSITY'] = 'MEDIUM';  
   } elseif ($this->_mode == 'nvp') {  
    $values['TRANSACTIONID'] = $txnID;  
   }  
   return $this->_request($values, 'GetTransactionDetails');  
  }  
  /**  
   * TransactionSearch  
   *  
   * Used to read data from PayPal for specified transaction criteria  
   */  
  function TransactionSearch($startdate, $txnID = '', $email = '', $options) {  
   if ($this->_mode == 'payflow') {  
    $values['CUSTREF'] = $txnID;  
    $values['TENDER'] = 'C';  
    $values['TRXTYPE'] = 'I';  
    $values['VERBOSITY'] = 'MEDIUM';  
   } elseif ($this->_mode == 'nvp') {  
    $values['STARTDATE'] = $startdate;  
    $values['TRANSACTIONID'] = $txnID;  
    $values['EMAIL'] = $email;  
    if (is_array($options)) $values = array_merge($values, $options);  
   }  
   return $this->_request($values, 'TransactionSearch');  
  }  
  /**  
   * Set a parameter as passed.  
   */  
  function setParam($name, $value) {  
   $name = '_' . $name;  
   $this->$name = $value;  
  }  
  /**  
   * Set CURL options.  
   */  
  function setCurlOption($name, $value) {  
   $this->_curlOptions[$name] = $value;  
  }  
  /**  
   * Send a request to endpoint.  
   */  
  function _request($values, $operation, $requestId = null) {  
   if ($this->_mode == 'NOTCONFIGURED') {  
    return array('RESULT' => 'PayPal credentials not set. Cannot proceed.');  
    die('NOTCONFIGURED');  
   }  
   if ($this->checkHasApiCredentials() === FALSE && (!in_array($operation, array('SetExpressCheckout','GetExpressCheckoutDetails', 'DoExpressCheckoutPayment')))) {  
    return array('RESULT' => 'Unauthorized: Unilateral');  
   }  
   if (PAYPAL_DEV_MODE == 'true') $this->log('_request - breakpoint 1 - ' . $operation . "\n" . print_r($values, true));  
   $start = $this->_getMicroseconds();  
   if ($this->_mode == 'nvp') {  
    $values['METHOD'] = $operation;  
   }  
   if ($this->_mode == 'payflow') {  
    $values['REQUEST_ID'] = time();  
   }  
   // convert currency code to proper key name for nvp  
   if ($this->_mode == 'nvp') {  
    if (!isset($values['CURRENCYCODE']) && isset($values['CURRENCY'])) {  
     $values['CURRENCYCODE'] = $values['CURRENCY'];  
     unset($values['CURRENCY']);  
    }  
   }  
   // request-id must be unique within 30 days  
   if ($requestId === null) {  
    $requestId = md5(uniqid(mt_rand()));  
   }  
   $headers[] = 'Content-Type: text/namevalue';  
   $headers[] = 'X-VPS-Timeout: 90';  
   $headers[] = "X-VPS-VIT-Client-Type: PHP/cURL";  
   if ($this->_mode == 'payflow') {  
    $headers[] = 'X-VPS-VIT-Integration-Product: PHP::Zen Cart(R) - PayPal/Payflow Pro';  
   } elseif ($this->_mode == 'nvp') {  
    $headers[] = 'X-VPS-VIT-Integration-Product: PHP::Zen Cart(R) - PayPal/NVP';  
   }  
   $headers[] = 'X-VPS-VIT-Integration-Version: 1.5.1';  
   $this->lastHeaders = $headers;  
   $ch = curl_init();  
   curl_setopt($ch, CURLOPT_URL, $this->_endpoints[$this->_server]);  
   curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);  
   curl_setopt($ch, CURLOPT_POSTFIELDS, $this->_buildNameValueList($values));  
   foreach ($this->_curlOptions as $name => $value) {  
    curl_setopt($ch, $name, $value);  
   }  
   $response = curl_exec($ch);  
   $commError = curl_error($ch);  
   $commErrNo = curl_errno($ch);  
   $commInfo = @curl_getinfo($ch);  
   curl_close($ch);  
   $rawdata = "CURL raw data:\n" . $response . "CURL RESULTS: (" . $commErrNo . ') ' . $commError . "\n" . print_r($commInfo, true) . "\nEOF";  
   $errors = ($commErrNo != 0 ? "\n(" . $commErrNo . ') ' . $commError : '');  
   $response .= '&CURL_ERRORS=' . ($commErrNo != 0 ? urlencode('(' . $commErrNo . ') ' . $commError) : '') ;  
   // do debug/logging  
   if ((!in_array($operation, array('GetTransactionDetails','TransactionSearch'))) || (in_array($operation, array('GetTransactionDetails','TransactionSearch')) && !strstr($response, '&ACK=Success')) ) $this->_logTransaction($operation, $this->_getElapsed($start), $response, $errors . ($commErrNo != 0 ? "\n" . print_r($commInfo, true) : ''));  
   if ($response) {  
    return $this->_parseNameValueList($response);  
   } else {  
    return false;  
   }  
  }  
  /**  
   * Take an array of name-value pairs and return a properly  
   * formatted list. Enforces the following rules:  
   *  
   *  - Names must be uppercase, all characters must match [A-Z].  
   *  - Values cannot contain quotes.  
   *  - If values contain & or =, the name has the length appended to  
   *   it in brackets (NAME[4] for a 4-character value.  
   *  
   * If any of the "cannot" conditions are violated the function  
   * returns false, and the caller must abort and not proceed with  
   * the transaction.  
   */  
  function _buildNameValueList($pairs) {  
   // Add the parameters that are always sent.  
   $commpairs = array();  
   // generic:  
   if ($this->_user != '')   $commpairs['USER'] = str_replace('+', '%2B', trim($this->_user));  
   if ($this->_pwd != '')    $commpairs['PWD'] = trim($this->_pwd);  
   // PRO2.0 options:  
   if ($this->_partner != '')  $commpairs['PARTNER'] = trim($this->_partner);  
   if ($this->_vendor != '')  $commpairs['VENDOR'] = trim($this->_vendor);  
   // NVP-specific options:  
   if ($this->_version != '')  $commpairs['VERSION'] = trim($this->_version);  
   if ($this->_signature != '') $commpairs['SIGNATURE'] = trim($this->_signature);  
   // Use sandbox credentials if defined and sandbox selected  
   if ($this->_server == 'sandbox'  
     && defined('MODULE_PAYMENT_PAYPALWPP_SANDBOX_APIUSERNAME') && MODULE_PAYMENT_PAYPALWPP_SANDBOX_APIUSERNAME != ''  
     && defined('MODULE_PAYMENT_PAYPALWPP_SANDBOX_APIPASSWORD') && MODULE_PAYMENT_PAYPALWPP_SANDBOX_APIPASSWORD != ''  
     && defined('MODULE_PAYMENT_PAYPALWPP_SANDBOX_APISIGNATURE') && MODULE_PAYMENT_PAYPALWPP_SANDBOX_APISIGNATURE != '') {  
    $commpairs['USER'] = str_replace('+', '%2B', trim(MODULE_PAYMENT_PAYPALWPP_SANDBOX_APIPASSWORD));  
    $commpairs['PWD'] = trim(MODULE_PAYMENT_PAYPALWPP_SANDBOX_APIPASSWORD);  
    $commpairs['SIGNATURE'] = trim(MODULE_PAYMENT_PAYPALWPP_SANDBOX_APISIGNATURE);  
   }  
   // Adjustments if Micropayments account profile details have been set  
   if (defined('MODULE_PAYMENT_PAYPALWPP_MICROPAY_THRESHOLD') && MODULE_PAYMENT_PAYPALWPP_MICROPAY_THRESHOLD != ''  
     && $pairs['AMT'] < strval(MODULE_PAYMENT_PAYPALWPP_MICROPAY_THRESHOLD)  
     && defined('MODULE_PAYMENT_PAYPALWPP_MICROPAY_APIUSERNAME') && MODULE_PAYMENT_PAYPALWPP_MICROPAY_APIUSERNAME != ''  
     && defined('MODULE_PAYMENT_PAYPALWPP_MICROPAY_APIPASSWORD') && MODULE_PAYMENT_PAYPALWPP_MICROPAY_APIPASSWORD != ''  
     && defined('MODULE_PAYMENT_PAYPALWPP_MICROPAY_APISIGNATURE') && MODULE_PAYMENT_PAYPALWPP_MICROPAY_APISIGNATURE != '') {  
    $commpairs['USER'] = str_replace('+', '%2B', trim(MODULE_PAYMENT_PAYPALWPP_MICROPAY_APIUSERNAME));  
    $commpairs['PWD'] = trim(MODULE_PAYMENT_PAYPALWPP_MICROPAY_APIPASSWORD);  
    $commpairs['SIGNATURE'] = trim(MODULE_PAYMENT_PAYPALWPP_MICROPAY_APISIGNATURE);  
   }  
   // Accelerated/Unilateral Boarding support:  
   if ($this->checkHasApiCredentials() == FALSE) {  
    $commpairs['SUBJECT'] = STORE_OWNER_EMAIL_ADDRESS;  
    $commpairs['USER'] = '';  
    $commpairs['PWD'] = '';  
    $commpairs['SIGNATURE'] = '';  
   }  
   $pairs = array_merge($pairs, $commpairs);  
   $string = array();  
   foreach ($pairs as $name => $value) {  
    if (preg_match('/[^A-Z_0-9]/', $name)) {  
     if (PAYPAL_DEV_MODE == 'true') $this->log('_buildNameValueList - datacheck - ABORTING - preg_match found invalid submission key: ' . $name . ' (' . $value . ')');  
     return false;  
    }  
    // remove quotation marks  
    $value = str_replace('"', '', $value);  
    // if the value contains a & or = symbol, handle it differently  
    if (($this->_mode == 'payflow') && (strpos($value, '&') !== false || strpos($value, '=') !== false)) {  
     $string[] = $name . '[' . strlen($value) . ']=' . $value;  
     if (PAYPAL_DEV_MODE == 'true') $this->log('_buildNameValueList - datacheck - adding braces and string count to: ' . $value . ' (' . $name . ')');  
    } else {  
     if ($this->_mode == 'nvp' && ((strstr($name, 'SHIPTO') || strstr($name, 'L_NAME')) && (strpos($value, '&') !== false || strpos($value, '=') !== false))) $value = urlencode($value);  
     $string[] = $name . '=' . $value;  
    }  
   }  
   $this->lastParamList = implode('&', $string);  
   return $this->lastParamList;  
  }  
  /**  
   * Take a name/value response string and parse it into an  
   * associative array. Doesn't handle length tags in the response  
   * as they should not be present.  
   */  
  function _parseNameValueList($string) {  
   $string = str_replace('&amp;', '|', $string);  
   $pairs = explode('&', str_replace(array("\r\n","\n"), '', $string));  
   //$this->log('['.$string . "]\n\n[" . print_r($pairs, true) .']');  
   $values = array();  
   foreach ($pairs as $pair) {  
    list($name, $value) = explode('=', $pair, 2);  
    $values[$name] = str_replace('|', '&amp;', $value);  
   }  
   return $values;  
  }  
  /**  
   * Log the current transaction depending on the current log level.  
   *  
   * @access protected  
   *  
   * @param string $operation The operation called.  
   * @param integer $elapsed  Microseconds taken.  
   * @param object $response  The response.  
   */  
  function _logTransaction($operation, $elapsed, $response, $errors) {  
   $values = $this->_parseNameValueList($response);  
   $token = isset($values['TOKEN']) ? $values['TOKEN'] : '';  
   $token = preg_replace('/[^0-9.A-Z\-]/', '', urldecode($token));  
   $success = false;  
   if ($response) {  
    if ((isset($values['RESULT']) && $values['RESULT'] == 0) || (isset($values['ACK']) && (strstr($values['ACK'],'Success') || strstr($values['ACK'],'SuccessWithWarning')) && !strstr($values['ACK'],'Failure'))) {  
     $success = true;  
    }  
   }  
   $message =  date('Y-m-d h:i:s') . "\n-------------------\n";  
   $message .= '(' . $this->_server . ' transaction) --> ' . $this->_endpoints[$this->_server] . "\n";  
   $message .= 'Request Headers: ' . "\n" . $this->_sanitizeLog($this->lastHeaders) . "\n\n";  
   $message .= 'Request Parameters: {' . $operation . '} ' . "\n" . urldecode($this->_sanitizeLog($this->_parseNameValueList($this->lastParamList))) . "\n\n";  
   $message .= 'Response: ' . "\n" . urldecode($this->_sanitizeLog($values)) . $errors;  
   if ($this->_logLevel > 0 || $success == FALSE) {  
    $this->log($message, $token);  
    // extra debug email: //  
    if (MODULE_PAYMENT_PAYPALWPP_DEBUGGING == 'Log and Email') {  
     zen_mail(STORE_NAME, STORE_OWNER_EMAIL_ADDRESS, 'PayPal Debug log - ' . $operation, $message, STORE_OWNER, STORE_OWNER_EMAIL_ADDRESS, array('EMAIL_MESSAGE_HTML'=>nl2br($message)), 'debug');  
    }  
    $this->log($operation . ', Elapsed: ' . $elapsed . 'ms -- ' . (isset($values['ACK']) ? $values['ACK'] : ($success ? 'Succeeded' : 'Failed')) . $errors, $token);  
    if (!$response) {  
     $this->log('No response from server' . $errors, $token);  
    } else {  
     if ((isset($values['RESULT']) && $values['RESULT'] != 0) || strstr($values['ACK'],'Failure')) {  
      $this->log($response . $errors, $token);  
     }  
    }  
   }  
  }  
  /**  
   * Strip sensitive information (passwords, credit card numbers, cvv2 codes) from requests/responses.  
   *  
   * @access protected  
   *  
   * @param mixed $log The log to sanitize.  
   * @return string The sanitized (and string-ified, if necessary) log.  
   */  
  function _sanitizeLog($log, $allsensitive = false) {  
   if (is_array($log)) {  
    foreach (array_keys($log) as $key) {  
     switch (strtolower($key)) {  
      case 'pwd':  
      case 'cvv2':  
       $log[$key] = str_repeat('*', strlen($log[$key]));  
       break;  
      case 'signature':  
      case 'acct':  
       $log[$key] = str_repeat('*', strlen(substr($log[$key], 0, -4))) . substr($log[$key], -4);  
       break;  
      case 'solutiontype':  
       unset($log[$key]);  
       break;  
     }  
     if ($allsensitive && in_array($key, array('BUTTONSOURCE', 'VERSION', 'SIGNATURE', 'USER', 'VENDOR', 'PARTNER', 'PWD', 'VERBOSITY'))) unset($log[$key]);  
    }  
    return print_r($log, true);  
   } else {  
    return $log;  
   }  
  }  
  function log($message, $token = '') {  
   static $tokenHash;  
   if ($tokenHash == '') $tokenHash = '_' . zen_create_random_value(4);  
   if ($token == '') $token = $_SESSION['paypal_ec_token'];  
   if ($token == '') $token = time();  
   $token .= $tokenHash;  
   $file = $this->_logDir . '/' . 'Paypal_CURL_' . $token . '.log';  
   if ($fp = @fopen($file, 'a')) {  
    fwrite($fp, $message . "\n\n");  
    fclose($fp);  
   }  
  }  
  /**  
   * Check whether API credentials are supplied, or if is blank  
   *  
   * @return boolean  
   */  
  function checkHasApiCredentials()  
  {  
   return ($this->_mode == 'nvp' && ($this->_user == '' || $this->_pwd == '')) ? FALSE : TRUE;  
  }  
  /**  
   * Return the current time including microseconds.  
   *  
   * @access protected  
   *  
   * @return integer Current time with microseconds.  
   */  
  function _getMicroseconds() {  
   list($ms, $s) = explode(' ', microtime());  
   return floor($ms * 1000) + 1000 * $s;  
  }  
  /**  
   * Return the difference between now and $start in microseconds.  
   *  
   * @access protected  
   *  
   * @param integer $start Start time including microseconds.  
   *  
   * @return integer Number of microseconds elapsed since $start  
   */  
  function _getElapsed($start) {  
   return $this->_getMicroseconds() - $start;  
  }  
 }  
 /**  
  * Convert HTML comments to readable text  
  * @param string $string  
  * @return string  
  */  
 function zen_uncomment($string) {  
  return str_replace(array('<!-- ', ' -->'), array('[', ']'), $string);  
 }  

Sunday, December 21, 2014

[Solved] How To Import Export Product in Magento?

Well i had scenario that i have upload all the product and categories on my local host Magento store now what i had to is to make the website live and i had configured it live but the challenge came to me is i have to upload all the product in a day. There was around 3,000 products on my store which looks very difficult for me. so i have started researching and googling over it. After a long research i got a solution. and the solution here it is.

Step1:
 Go to your phpMyAdmin select your database on which your store is running on localhost. There you have to select all the tables starting with catelog_

After selecting tables you need to export all these table scroll bottom and you will get a dropdown saying with selected click on it and select export.

Step2:
After selecting export you will be redirected to another page where you will get two radio buttons
Quick - display only the minimal options
Custom - display all possible options
you have to select 2nd one custom. and in table list all the tables that you had checked previously will be selected.
befor exporting all the products you need to check all these following option are enabled.


Now click on go button at the very bottom of page and your product with categories are exported. 

Step3
simply import this SQL file. for product images you need to upload all those image in 
media/products
and you are done. Hope this artical will help you.



Tuesday, November 4, 2014

Difference Between DataReader, DataSet, DataAdapter and DataTable in C#

DataReader

DataReader is used to read the data from database and it is a read and forward only connection oriented architecture during fetch the data from database. DataReader will fetch the data very fast when compared with dataset. Generally we will use ExecuteReader object to bind data to datareader.

To bind DataReader data to GridView we need to write the code like as shown below:


Protected void BindGridview()
{
using (SqlConnection conn = new SqlConnection("Data Source=abc;Integrated Security=true;Initial Catalog=Test"))
{
con.Open();
SqlCommand cmd = new SqlCommand("Select UserName, First Name,LastName,Location FROM Users", conn);
SqlDataReader sdr = cmd.ExecuteReader();
gvUserInfo.DataSource = sdr;
gvUserInfo.DataBind();
conn.Close();
}
}
Holds the connection open until you are finished (don't forget to close it!).
Can typically only be iterated over once
Is not as useful for updating back to the database.

DataSet

DataSet is a disconnected orient architecture that means there is no need of active connections during work with datasets and it is a collection of DataTables and relations between tables. It is used to hold multiple tables with data. You can select data form tables, create views based on table and ask child rows over relations. Also DataSet provides you with rich features like saving data as XML and loading XML data.

protected void BindGridview()
{
    SqlConnection conn = new SqlConnection("Data Source=abc;Integrated Security=true;Initial Catalog=Test");
    conn.Open();
    SqlCommand cmd = new SqlCommand("Select UserName, First Name,LastName,Location FROM Users", conn);
    SqlDataAdapter sda = new SqlDataAdapter(cmd);
    DataSet ds = new DataSet();
    da.Fill(ds);
    gvUserInfo.DataSource = ds;
    gvUserInfo.DataBind();
}
DataAdapter

DataAdapter will acts as a Bridge between DataSet and database. This dataadapter object is used to read the data from database and bind that data to dataset. Dataadapter is a disconnected oriented architecture. Check below sample code to see how to use DataAdapter in code:

protected void BindGridview()
{
    SqlConnection con = new SqlConnection("Data Source=abc;Integrated Security=true;Initial Catalog=Test");
    conn.Open();
    SqlCommand cmd = new SqlCommand("Select UserName, First Name,LastName,Location FROM Users", conn);
    SqlDataAdapter sda = new SqlDataAdapter(cmd);
    DataSet ds = new DataSet();
    da.Fill(ds);
    gvUserInfo.DataSource = ds;
    gvUserInfo.DataBind();
}
Lets you close the connection as soon it's done loading data, and may even close it for you automatically
All of the results are available in memory
You can iterate over it as many times as you need, or even look up a specific record by index
Has some built-in faculties for updating back to the database.

DataTable 

DataTable represents a single table in the database. It has rows and columns. There is no much difference between dataset and datatable, dataset is simply the collection of datatables.

protected void BindGridview()
{
     SqlConnection con = new SqlConnection("Data Source=abc;Integrated Security=true;Initial Catalog=Test");
     conn.Open();
     SqlCommand cmd = new SqlCommand("Select UserName, First Name,LastName,Location FROM Users", conn);
     SqlDataAdapter sda = new SqlDataAdapter(cmd);
     DataTable dt = new DataTable();
     da.Fill(dt);
     gridview1.DataSource = dt;
     gvidview1.DataBind();
}
  

Important Command Ado.Net

With the release of the .NET Framework, Microsoft introduced a new data access model, called ADO.NET.The five major objects in ADO.NET are:

Obects Description
Connection The Connection object is responsible for establishing and maintaining the connection to the data source.
Command The Command object stores the query that is to be sent to the data source, and any applicable parameters.
DataReader The DataReader object provides fast, forward-only,readonly object. It is connection oriented.
DataSet           The DataSet object is the collection of objects.It contains DataTable,DataRow,DataRelation, etc.It provides a storage mechanism for disconnected data. It is as an in-memory repository to store data that has been retrieved.
DataAdapter The DataAdapter object works as a bridge between the DataSet and the data source. The DataAdapter is responsible for retrieving the data from the Command object and populating the DataSet with the data returned.It uses the Fill method to populate the DataSet.



If you are working with Microsoft SQL server then you must include the following namespace:

System.Data
System.Data.SqlClient
Connection Objects

The main use of connection object is to provide connection to a data source. A connection object does not fetch or update data, it does not execute queries, and it does not contain the results of queries.It is a place where you can provide the connection string.

Creating Connection:
SqlConnection conObject = new SqlConnection
("Data Source=ServerName; Initial Catalog=DatabaseName; Integrated Security=True");

Important Properties of Connection Object.

NAME Description
ConnectionString Gets or sets the string used to open the connection.
Database Read only. Gets the name of the current database after a connection is opened .
DataSource Read only. Gets the name of the database server to which it is connected.
State Read only. Gets the state of the connection.
Command Objects

Command object is used to execute SQL statements and stored procedures against a database. Command objects contain the necessary information to execute SQL statements, stored procedures, functions, and so on.

Important Properties of Command Object.

NAME DESCRIPTION
CommandText Set this to any valid SQL statement or the name of any valid stored procedure. The CommandType value determines the manner of execution.
CommandType Set to either SQL statement or StoredProcedure
Connection Set this to the connection object.
Parameters The command’s parameters collection. When running parameterized queries or stored procedures, you must add parameterobjects to this collection.
Transaction The SqlTransaction within which the SqlCommand executes.

Important Methods of Command Object.

NAME DESCRIPTION
ExecuteNonQuery This method is used,If you are using insert,update,delete SQL statement.Its return type is Integer.This indicates the no of effected records.
ExecuteReader This method is used,If you are using Select SQL statement.Its return type is DataReader.
ExecuteScalar If you need to return a single value from a database query, you can use the ExecuteScalar method. This method always returns the value of the first column from the first row of a resultset.Its return type is Object.
ExecuteXMLReader Returns XML formatted data. Returns a System.Xml.XmlReader object.
DataReader Object

The DataReader Object provides a connection oriented data access to the Data Sources. DataReader Object is fast, forward-only, read-only retrieval of query results from the Data Sources It is not used to update the data.When we started to read from a DataReader it should always be open and positioned prior to the first record. The Read() method in the DataReader is used to read the rows from DataReader and it always moves forward to a new valid row, if any row exist .

Important Properties of DataReader Object.

NAME DESCRIPTION
Connection Gets the Connection associated with the DataReader.
FieldCount Gets the number of columns in the current row.
HasRows Gets a value that indicates whether the DataReader contains one or more rows.
IsClosed Retrieves a Boolean value that indicates whether the specified DataReader instance has been closed or not.
RecordsAffected Gets the number of rows affected, inserted, or deleted by execution of the Transact-SQL statement.
Important Methods of DataReader Object.

NAME DESCRIPTION
Close Closes the DataReader object.
NextResult Advances the data reader to the next result, when reading the results of batch Transact-SQL statements.
Read Advances the DataReader to the next record.
GetValue Gets the value of the specified column
The DataReader cannot be created directly from code, they can created only by calling the ExecuteReader method of a Command Object.

Example:

string connString = "some valid conn string";
SqlConnection connection = new SqlConnection(connString);
connection.Open();
SqlCommand cmd = new SqlCommand();
cmd.Connection = connection;
cmd.CommandType = CommandType.Text;
cmd.CommandText = "SELECT empID, empName FROM Employees";
SqlDataReader reader= cmd.ExecuteReader();
GridView1.DataSource = reader;
GridView1.DataBind ();
connection.Close();

Working with ADO.NET disconnected classes

The DataTable object represents tabular data as rows, columns, and constraints. You generally get a DataTable object by connecting to the database and returning table data but we can also create it by using DataTable class.

Example:

DataTable dt = new DataTable();
DataColumn dc = new DataColumn();
dc.ColumnName = "ProductID";
dc.DataType = typeof(int);
dt.Columns.Add(dc);
DataColumn dc2 = new DataColumn();
dc2.ColumnName = "ProductName";
dc2.DataType = typeof(string);
dt.Columns.Add(dc2);
dt.Rows.Add(new object[] { "1","CareerRide" });
GridView1.DataSource = dt;
GridView1.DataBind ();

Working with DataSet Object

Dataset is a disconnected, in-memory representation of data. It can contain multiple data table from different database.

Example:

string connString = "some valid conn string";
SqlConnection connection = new SqlConnection(connString);
using (SqlCommand cmd = new SqlCommand("Select * from Products", connection))
{
            SqlDataAdapter da = new SqlDataAdapter(cmd);
            DataSet ds = new DataSet();
            da.Fill(ds);
            GridView1.DataSource = ds;
            GridView1.DataBind();
}

Monday, October 13, 2014

[Solved] How To Increase File Upload size in OpenCart

This article will help you to increase file upload size in OpenCart. If you are a OpenCart beginner and you are facing a problem while updating products on your OpenCart store and you are getting error message about file size go through this article and you are done.

Go to admin > controller > common > filemanager.php

Default filemanager.php


<?php
class ControllerCommonFileManager extends Controller {
 private $error = array();

  public function index() {
  $this->language->load('common/filemanager');

   $this->data['title'] = $this->language->get('heading_title');

   if (isset($this->request->server['HTTPS']) && (($this->request->server['HTTPS'] == 'on') || ($this->request->server['HTTPS'] == '1'))) {
   $this->data['base'] = HTTPS_SERVER;
  } else {
   $this->data['base'] = HTTP_SERVER;
  }

   $this->data['entry_folder'] = $this->language->get('entry_folder');
  $this->data['entry_move'] = $this->language->get('entry_move');
  $this->data['entry_copy'] = $this->language->get('entry_copy');
  $this->data['entry_rename'] = $this->language->get('entry_rename');

   $this->data['button_folder'] = $this->language->get('button_folder');
  $this->data['button_delete'] = $this->language->get('button_delete');
  $this->data['button_move'] = $this->language->get('button_move');
  $this->data['button_copy'] = $this->language->get('button_copy');
  $this->data['button_rename'] = $this->language->get('button_rename');
  $this->data['button_upload'] = $this->language->get('button_upload');
  $this->data['button_refresh'] = $this->language->get('button_refresh');
  $this->data['button_submit'] = $this->language->get('button_submit');

   $this->data['error_select'] = $this->language->get('error_select');
  $this->data['error_directory'] = $this->language->get('error_directory');

   $this->data['token'] = $this->session->data['token'];

   $this->data['directory'] = HTTP_CATALOG . 'image/data/';

   $this->load->model('tool/image');

   $this->data['no_image'] = $this->model_tool_image->resize('no_image.jpg', 100, 100);

   if (isset($this->request->get['field'])) {
   $this->data['field'] = $this->request->get['field'];
  } else {
   $this->data['field'] = '';
  }

   if (isset($this->request->get['CKEditorFuncNum'])) {
   $this->data['fckeditor'] = $this->request->get['CKEditorFuncNum'];
  } else {
   $this->data['fckeditor'] = false;
  }

   $this->template = 'common/filemanager.tpl';

   $this->response->setOutput($this->render());
 } 

  public function image() {
  $this->load->model('tool/image');

   if (isset($this->request->get['image'])) {
   $this->response->setOutput($this->model_tool_image->resize(html_entity_decode($this->request->get['image'], ENT_QUOTES, 'UTF-8'), 100, 100));
  }
 }

  public function directory() { 
  $json = array();

   if (isset($this->request->post['directory'])) {
   $directories = glob(rtrim(DIR_IMAGE . 'data/' . str_replace('../', '', $this->request->post['directory']), '/') . '/*', GLOB_ONLYDIR);

    if ($directories) {
    $i = 0;

     foreach ($directories as $directory) {
     $json[$i]['data'] = basename($directory);
     $json[$i]['attributes']['directory'] = utf8_substr($directory, strlen(DIR_IMAGE . 'data/'));

      $children = glob(rtrim($directory, '/') . '/*', GLOB_ONLYDIR);

      if ($children)  {
      $json[$i]['children'] = ' ';
     }

      $i++;
    }
   }  
  }

   $this->response->setOutput(json_encode($json));  
 }

  public function files() {
  $json = array();

   if (!empty($this->request->post['directory'])) {
   $directory = DIR_IMAGE . 'data/' . str_replace('../', '', $this->request->post['directory']);
  } else {
   $directory = DIR_IMAGE . 'data/';
  }

   $allowed = array(
   '.jpg',
   '.jpeg',
   '.png',
   '.gif'
  );

   $files = glob(rtrim($directory, '/') . '/*');

   if ($files) {
   foreach ($files as $file) {
    if (is_file($file)) {
     $ext = strrchr($file, '.');
    } else {
     $ext = '';
    } 

     if (in_array(strtolower($ext), $allowed)) {
     $size = filesize($file);

      $i = 0;

      $suffix = array(
      'B',
      'KB',
      'MB',
      'GB',
      'TB',
      'PB',
      'EB',
      'ZB',
      'YB'
     );

      while (($size / 1024) > 1) {
      $size = $size / 1024;
      $i++;
     }

      $json[] = array(
      'filename' => basename($file),
      'file'     => utf8_substr($file, utf8_strlen(DIR_IMAGE . 'data/')),
      'size'     => round(utf8_substr($size, 0, utf8_strpos($size, '.') + 4), 2) . $suffix[$i]
     );
    }
   }
  }

   $this->response->setOutput(json_encode($json)); 
 } 

  public function create() {
  $this->language->load('common/filemanager');

   $json = array();

   if (isset($this->request->post['directory'])) {
   if (isset($this->request->post['name']) || $this->request->post['name']) {
    $directory = rtrim(DIR_IMAGE . 'data/' . str_replace('../', '', $this->request->post['directory']), '/');       

     if (!is_dir($directory)) {
     $json['error'] = $this->language->get('error_directory');
    }

     if (file_exists($directory . '/' . str_replace('../', '', $this->request->post['name']))) {
     $json['error'] = $this->language->get('error_exists');
    }
   } else {
    $json['error'] = $this->language->get('error_name');
   }
  } else {
   $json['error'] = $this->language->get('error_directory');
  }

   if (!$this->user->hasPermission('modify', 'common/filemanager')) {
   $json['error'] = $this->language->get('error_permission');
  }

   if (!isset($json['error'])) { 
   mkdir($directory . '/' . str_replace('../', '', $this->request->post['name']), 0777);

    $json['success'] = $this->language->get('text_create');
  } 

   $this->response->setOutput(json_encode($json));
 }

  public function delete() {
  $this->language->load('common/filemanager');

   $json = array();

   if (isset($this->request->post['path'])) {
   $path = rtrim(DIR_IMAGE . 'data/' . str_replace('../', '', html_entity_decode($this->request->post['path'], ENT_QUOTES, 'UTF-8')), '/');

    if (!file_exists($path)) {
    $json['error'] = $this->language->get('error_select');
   }

    if ($path == rtrim(DIR_IMAGE . 'data/', '/')) {
    $json['error'] = $this->language->get('error_delete');
   }
  } else {
   $json['error'] = $this->language->get('error_select');
  }

   if (!$this->user->hasPermission('modify', 'common/filemanager')) {
   $json['error'] = $this->language->get('error_permission');
  }

   if (!isset($json['error'])) {
   if (is_file($path)) {
    unlink($path);
   } elseif (is_dir($path)) {
    $files = array();

     $path = array($path . '*');

     while(count($path) != 0) {
     $next = array_shift($path);

      foreach(glob($next) as $file) {
      if (is_dir($file)) {
       $path[] = $file . '/*';
      }

       $files[] = $file;
     }
    }

     rsort($files);

     foreach ($files as $file) {
     if (is_file($file)) {
      unlink($file);
     } elseif(is_dir($file)) {
      rmdir($file); 
     }
    }    
   }

    $json['success'] = $this->language->get('text_delete');
  }    

   $this->response->setOutput(json_encode($json));
 }

  public function move() {
  $this->language->load('common/filemanager');

   $json = array();

   if (isset($this->request->post['from']) && isset($this->request->post['to'])) {
   $from = rtrim(DIR_IMAGE . 'data/' . str_replace('../', '', html_entity_decode($this->request->post['from'], ENT_QUOTES, 'UTF-8')), '/');

    if (!file_exists($from)) {
    $json['error'] = $this->language->get('error_missing');
   }

    if ($from == DIR_IMAGE . 'data') {
    $json['error'] = $this->language->get('error_default');
   }

    $to = rtrim(DIR_IMAGE . 'data/' . str_replace('../', '', html_entity_decode($this->request->post['to'], ENT_QUOTES, 'UTF-8')), '/');

    if (!file_exists($to)) {
    $json['error'] = $this->language->get('error_move');
   } 

    if (file_exists($to . '/' . basename($from))) {
    $json['error'] = $this->language->get('error_exists');
   }
  } else {
   $json['error'] = $this->language->get('error_directory');
  }

   if (!$this->user->hasPermission('modify', 'common/filemanager')) {
   $json['error'] = $this->language->get('error_permission');
  }

   if (!isset($json['error'])) {
   rename($from, $to . '/' . basename($from));

    $json['success'] = $this->language->get('text_move');
  }

   $this->response->setOutput(json_encode($json));
 } 

  public function copy() {
  $this->language->load('common/filemanager');

   $json = array();

   if (isset($this->request->post['path']) && isset($this->request->post['name'])) {
   if ((utf8_strlen($this->request->post['name']) < 3) || (utf8_strlen($this->request->post['name']) > 255)) {
    $json['error'] = $this->language->get('error_filename');
   }

    $old_name = rtrim(DIR_IMAGE . 'data/' . str_replace('../', '', html_entity_decode($this->request->post['path'], ENT_QUOTES, 'UTF-8')), '/');

    if (!file_exists($old_name) || $old_name == DIR_IMAGE . 'data') {
    $json['error'] = $this->language->get('error_copy');
   }

    if (is_file($old_name)) {
    $ext = strrchr($old_name, '.');
   } else {
    $ext = '';
   }  

    $new_name = dirname($old_name) . '/' . str_replace('../', '', html_entity_decode($this->request->post['name'], ENT_QUOTES, 'UTF-8') . $ext);

    if (file_exists($new_name)) {
    $json['error'] = $this->language->get('error_exists');
   }   
  } else {
   $json['error'] = $this->language->get('error_select');
  }

   if (!$this->user->hasPermission('modify', 'common/filemanager')) {
   $json['error'] = $this->language->get('error_permission');
  }

   if (!isset($json['error'])) {
   if (is_file($old_name)) {
    copy($old_name, $new_name);
   } else {
    $this->recursiveCopy($old_name, $new_name);
   }

    $json['success'] = $this->language->get('text_copy');
  }

   $this->response->setOutput(json_encode($json)); 
 }

  function recursiveCopy($source, $destination) {
  $directory = opendir($source);

   @mkdir($destination);

   while (false !== ($file = readdir($directory))) {
   if (($file != '.') && ($file != '..')) {
    if (is_dir($source . '/' . $file)) {
     $this->recursiveCopy($source . '/' . $file, $destination . '/' . $file);
    } else {
     copy($source . '/' . $file, $destination . '/' . $file);
    }
   }
  }

   closedir($directory);
 }

  public function folders() {
  $this->response->setOutput($this->recursiveFolders(DIR_IMAGE . 'data/')); 
 }

  protected function recursiveFolders($directory) {
  $output = '';

   $output .= '<option value="' . utf8_substr($directory, strlen(DIR_IMAGE . 'data/')) . '">' . utf8_substr($directory, strlen(DIR_IMAGE . 'data/')) . '</option>';

   $directories = glob(rtrim(str_replace('../', '', $directory), '/') . '/*', GLOB_ONLYDIR);

   foreach ($directories  as $directory) {
   $output .= $this->recursiveFolders($directory);
  }

   return $output;
 }

  public function rename() {
  $this->language->load('common/filemanager');

   $json = array();

   if (isset($this->request->post['path']) && isset($this->request->post['name'])) {
   if ((utf8_strlen($this->request->post['name']) < 3) || (utf8_strlen($this->request->post['name']) > 255)) {
    $json['error'] = $this->language->get('error_filename');
   }

    $old_name = rtrim(DIR_IMAGE . 'data/' . str_replace('../', '', html_entity_decode($this->request->post['path'], ENT_QUOTES, 'UTF-8')), '/');

    if (!file_exists($old_name) || $old_name == DIR_IMAGE . 'data') {
    $json['error'] = $this->language->get('error_rename');
   }

    if (is_file($old_name)) {
    $ext = strrchr($old_name, '.');
   } else {
    $ext = '';
   }  

    $new_name = dirname($old_name) . '/' . str_replace('../', '', html_entity_decode($this->request->post['name'], ENT_QUOTES, 'UTF-8') . $ext);

    if (file_exists($new_name)) {
    $json['error'] = $this->language->get('error_exists');
   }   
  }

   if (!$this->user->hasPermission('modify', 'common/filemanager')) {
   $json['error'] = $this->language->get('error_permission');
  }

   if (!isset($json['error'])) {
   rename($old_name, $new_name);

    $json['success'] = $this->language->get('text_rename');
  }

   $this->response->setOutput(json_encode($json));
 }

  public function upload() {
  $this->language->load('common/filemanager');

   $json = array();

   if (isset($this->request->post['directory'])) {
   if (isset($this->request->files['image']) && $this->request->files['image']['tmp_name']) {
    $filename = basename(html_entity_decode($this->request->files['image']['name'], ENT_QUOTES, 'UTF-8'));

     if ((strlen($filename) < 3) || (strlen($filename) > 255)) {
     $json['error'] = $this->language->get('error_filename');
    }

     $directory = rtrim(DIR_IMAGE . 'data/' . str_replace('../', '', $this->request->post['directory']), '/');

     if (!is_dir($directory)) {
     $json['error'] = $this->language->get('error_directory');
    }

     if ($this->request->files['image']['size'] > 300000) {
     $json['error'] = $this->language->get('error_file_size');
    }

     $allowed = array(
     'image/jpeg',
     'image/pjpeg',
     'image/png',
     'image/x-png',
     'image/gif',
     'application/x-shockwave-flash'
    );

     if (!in_array($this->request->files['image']['type'], $allowed)) {
     $json['error'] = $this->language->get('error_file_type');
    }

     $allowed = array(
     '.jpg',
     '.jpeg',
     '.gif',
     '.png',
     '.flv'
    );

     if (!in_array(strtolower(strrchr($filename, '.')), $allowed)) {
     $json['error'] = $this->language->get('error_file_type');
    }

     if ($this->request->files['image']['error'] != UPLOAD_ERR_OK) {
     $json['error'] = 'error_upload_' . $this->request->files['image']['error'];
    }   
   } else {
    $json['error'] = $this->language->get('error_file');
   }
  } else {
   $json['error'] = $this->language->get('error_directory');
  }

   if (!$this->user->hasPermission('modify', 'common/filemanager')) {
   $json['error'] = $this->language->get('error_permission');
  }

   if (!isset($json['error'])) { 
   if (@move_uploaded_file($this->request->files['image']['tmp_name'], $directory . '/' . $filename)) {  
    $json['success'] = $this->language->get('text_uploaded');
   } else {
    $json['error'] = $this->language->get('error_uploaded');
   }
  }

   $this->response->setOutput(json_encode($json));
 }
}

?>

Modified filemanager.php

<?php
class ControllerCommonFileManager extends Controller {
 private $error = array();

 public function index() {
  $this->language->load('common/filemanager');

  $this->data['title'] = $this->language->get('heading_title');

  if (isset($this->request->server['HTTPS']) && (($this->request->server['HTTPS'] == 'on') || ($this->request->server['HTTPS'] == '1'))) {
   $this->data['base'] = HTTPS_SERVER;
  } else {
   $this->data['base'] = HTTP_SERVER;
  }

  $this->data['entry_folder'] = $this->language->get('entry_folder');
  $this->data['entry_move'] = $this->language->get('entry_move');
  $this->data['entry_copy'] = $this->language->get('entry_copy');
  $this->data['entry_rename'] = $this->language->get('entry_rename');

  $this->data['button_folder'] = $this->language->get('button_folder');
  $this->data['button_delete'] = $this->language->get('button_delete');
  $this->data['button_move'] = $this->language->get('button_move');
  $this->data['button_copy'] = $this->language->get('button_copy');
  $this->data['button_rename'] = $this->language->get('button_rename');
  $this->data['button_upload'] = $this->language->get('button_upload');
  $this->data['button_refresh'] = $this->language->get('button_refresh');
  $this->data['button_submit'] = $this->language->get('button_submit');

  $this->data['error_select'] = $this->language->get('error_select');
  $this->data['error_directory'] = $this->language->get('error_directory');

  $this->data['token'] = $this->session->data['token'];

  $this->data['directory'] = HTTP_CATALOG . 'image/data/';

  $this->load->model('tool/image');

  $this->data['no_image'] = $this->model_tool_image->resize('no_image.jpg', 100, 100);

  if (isset($this->request->get['field'])) {
   $this->data['field'] = $this->request->get['field'];
  } else {
   $this->data['field'] = '';
  }

  if (isset($this->request->get['CKEditorFuncNum'])) {
   $this->data['fckeditor'] = $this->request->get['CKEditorFuncNum'];
  } else {
   $this->data['fckeditor'] = false;
  }

  $this->template = 'common/filemanager.tpl';

  $this->response->setOutput($this->render());
 } 

 public function image() {
  $this->load->model('tool/image');

  if (isset($this->request->get['image'])) {
   $this->response->setOutput($this->model_tool_image->resize(html_entity_decode($this->request->get['image'], ENT_QUOTES, 'UTF-8'), 100, 100));
  }
 }

 public function directory() { 
  $json = array();

  if (isset($this->request->post['directory'])) {
   $directories = glob(rtrim(DIR_IMAGE . 'data/' . str_replace('../', '', $this->request->post['directory']), '/') . '/*', GLOB_ONLYDIR);

   if ($directories) {
    $i = 0;

    foreach ($directories as $directory) {
     $json[$i]['data'] = basename($directory);
     $json[$i]['attributes']['directory'] = utf8_substr($directory, strlen(DIR_IMAGE . 'data/'));

     $children = glob(rtrim($directory, '/') . '/*', GLOB_ONLYDIR);

     if ($children)  {
      $json[$i]['children'] = ' ';
     }

     $i++;
    }
   }  
  }

  $this->response->setOutput(json_encode($json));  
 }

 public function files() {
  $json = array();

  if (!empty($this->request->post['directory'])) {
   $directory = DIR_IMAGE . 'data/' . str_replace('../', '', $this->request->post['directory']);
  } else {
   $directory = DIR_IMAGE . 'data/';
  }

  $allowed = array(
   '.jpg',
   '.jpeg',
   '.png',
   '.gif'
  );

  $files = glob(rtrim($directory, '/') . '/*');

  if ($files) {
   foreach ($files as $file) {
    if (is_file($file)) {
     $ext = strrchr($file, '.');
    } else {
     $ext = '';
    } 

    if (in_array(strtolower($ext), $allowed)) {
     $size = filesize($file);

     $i = 0;

     $suffix = array(
      'B',
      'KB',
      'MB',
      'GB',
      'TB',
      'PB',
      'EB',
      'ZB',
      'YB'
     );

     while (($size / 1024) > 1) {
      $size = $size / 1024;
      $i++;
     }

     $json[] = array(
      'filename' => basename($file),
      'file'     => utf8_substr($file, utf8_strlen(DIR_IMAGE . 'data/')),
      'size'     => round(utf8_substr($size, 0, utf8_strpos($size, '.') + 4), 2) . $suffix[$i]
     );
    }
   }
  }

  $this->response->setOutput(json_encode($json)); 
 } 

 public function create() {
  $this->language->load('common/filemanager');

  $json = array();

  if (isset($this->request->post['directory'])) {
   if (isset($this->request->post['name']) || $this->request->post['name']) {
    $directory = rtrim(DIR_IMAGE . 'data/' . str_replace('../', '', $this->request->post['directory']), '/');       

    if (!is_dir($directory)) {
     $json['error'] = $this->language->get('error_directory');
    }

    if (file_exists($directory . '/' . str_replace('../', '', $this->request->post['name']))) {
     $json['error'] = $this->language->get('error_exists');
    }
   } else {
    $json['error'] = $this->language->get('error_name');
   }
  } else {
   $json['error'] = $this->language->get('error_directory');
  }

  if (!$this->user->hasPermission('modify', 'common/filemanager')) {
   $json['error'] = $this->language->get('error_permission');
  }

  if (!isset($json['error'])) { 
   mkdir($directory . '/' . str_replace('../', '', $this->request->post['name']), 0777);

   $json['success'] = $this->language->get('text_create');
  } 

  $this->response->setOutput(json_encode($json));
 }

 public function delete() {
  $this->language->load('common/filemanager');

  $json = array();

  if (isset($this->request->post['path'])) {
   $path = rtrim(DIR_IMAGE . 'data/' . str_replace('../', '', html_entity_decode($this->request->post['path'], ENT_QUOTES, 'UTF-8')), '/');

   if (!file_exists($path)) {
    $json['error'] = $this->language->get('error_select');
   }

   if ($path == rtrim(DIR_IMAGE . 'data/', '/')) {
    $json['error'] = $this->language->get('error_delete');
   }
  } else {
   $json['error'] = $this->language->get('error_select');
  }

  if (!$this->user->hasPermission('modify', 'common/filemanager')) {
   $json['error'] = $this->language->get('error_permission');
  }

  if (!isset($json['error'])) {
   if (is_file($path)) {
    unlink($path);
   } elseif (is_dir($path)) {
    $files = array();

    $path = array($path . '*');

    while(count($path) != 0) {
     $next = array_shift($path);

     foreach(glob($next) as $file) {
      if (is_dir($file)) {
       $path[] = $file . '/*';
      }

      $files[] = $file;
     }
    }

    rsort($files);

    foreach ($files as $file) {
     if (is_file($file)) {
      unlink($file);
     } elseif(is_dir($file)) {
      rmdir($file); 
     }
    }    
   }

   $json['success'] = $this->language->get('text_delete');
  }    

  $this->response->setOutput(json_encode($json));
 }

 public function move() {
  $this->language->load('common/filemanager');

  $json = array();

  if (isset($this->request->post['from']) && isset($this->request->post['to'])) {
   $from = rtrim(DIR_IMAGE . 'data/' . str_replace('../', '', html_entity_decode($this->request->post['from'], ENT_QUOTES, 'UTF-8')), '/');

   if (!file_exists($from)) {
    $json['error'] = $this->language->get('error_missing');
   }

   if ($from == DIR_IMAGE . 'data') {
    $json['error'] = $this->language->get('error_default');
   }

   $to = rtrim(DIR_IMAGE . 'data/' . str_replace('../', '', html_entity_decode($this->request->post['to'], ENT_QUOTES, 'UTF-8')), '/');

   if (!file_exists($to)) {
    $json['error'] = $this->language->get('error_move');
   } 

   if (file_exists($to . '/' . basename($from))) {
    $json['error'] = $this->language->get('error_exists');
   }
  } else {
   $json['error'] = $this->language->get('error_directory');
  }

  if (!$this->user->hasPermission('modify', 'common/filemanager')) {
   $json['error'] = $this->language->get('error_permission');
  }

  if (!isset($json['error'])) {
   rename($from, $to . '/' . basename($from));

   $json['success'] = $this->language->get('text_move');
  }

  $this->response->setOutput(json_encode($json));
 } 

 public function copy() {
  $this->language->load('common/filemanager');

  $json = array();

  if (isset($this->request->post['path']) && isset($this->request->post['name'])) {
   if ((utf8_strlen($this->request->post['name']) < 3) || (utf8_strlen($this->request->post['name']) > 255)) {
    $json['error'] = $this->language->get('error_filename');
   }

   $old_name = rtrim(DIR_IMAGE . 'data/' . str_replace('../', '', html_entity_decode($this->request->post['path'], ENT_QUOTES, 'UTF-8')), '/');

   if (!file_exists($old_name) || $old_name == DIR_IMAGE . 'data') {
    $json['error'] = $this->language->get('error_copy');
   }

   if (is_file($old_name)) {
    $ext = strrchr($old_name, '.');
   } else {
    $ext = '';
   }  

   $new_name = dirname($old_name) . '/' . str_replace('../', '', html_entity_decode($this->request->post['name'], ENT_QUOTES, 'UTF-8') . $ext);

   if (file_exists($new_name)) {
    $json['error'] = $this->language->get('error_exists');
   }   
  } else {
   $json['error'] = $this->language->get('error_select');
  }

  if (!$this->user->hasPermission('modify', 'common/filemanager')) {
   $json['error'] = $this->language->get('error_permission');
  }

  if (!isset($json['error'])) {
   if (is_file($old_name)) {
    copy($old_name, $new_name);
   } else {
    $this->recursiveCopy($old_name, $new_name);
   }

   $json['success'] = $this->language->get('text_copy');
  }

  $this->response->setOutput(json_encode($json)); 
 }

 function recursiveCopy($source, $destination) {
  $directory = opendir($source);

  @mkdir($destination);

  while (false !== ($file = readdir($directory))) {
   if (($file != '.') && ($file != '..')) {
    if (is_dir($source . '/' . $file)) {
     $this->recursiveCopy($source . '/' . $file, $destination . '/' . $file);
    } else {
     copy($source . '/' . $file, $destination . '/' . $file);
    }
   }
  }

  closedir($directory);
 }

 public function folders() {
  $this->response->setOutput($this->recursiveFolders(DIR_IMAGE . 'data/')); 
 }

 protected function recursiveFolders($directory) {
  $output = '';

  $output .= '<option value="' . utf8_substr($directory, strlen(DIR_IMAGE . 'data/')) . '">' . utf8_substr($directory, strlen(DIR_IMAGE . 'data/')) . '</option>';

  $directories = glob(rtrim(str_replace('../', '', $directory), '/') . '/*', GLOB_ONLYDIR);

  foreach ($directories  as $directory) {
   $output .= $this->recursiveFolders($directory);
  }

  return $output;
 }

 public function rename() {
  $this->language->load('common/filemanager');

  $json = array();

  if (isset($this->request->post['path']) && isset($this->request->post['name'])) {
   if ((utf8_strlen($this->request->post['name']) < 3) || (utf8_strlen($this->request->post['name']) > 255)) {
    $json['error'] = $this->language->get('error_filename');
   }

   $old_name = rtrim(DIR_IMAGE . 'data/' . str_replace('../', '', html_entity_decode($this->request->post['path'], ENT_QUOTES, 'UTF-8')), '/');

   if (!file_exists($old_name) || $old_name == DIR_IMAGE . 'data') {
    $json['error'] = $this->language->get('error_rename');
   }

   if (is_file($old_name)) {
    $ext = strrchr($old_name, '.');
   } else {
    $ext = '';
   }  

   $new_name = dirname($old_name) . '/' . str_replace('../', '', html_entity_decode($this->request->post['name'], ENT_QUOTES, 'UTF-8') . $ext);

   if (file_exists($new_name)) {
    $json['error'] = $this->language->get('error_exists');
   }   
  }

  if (!$this->user->hasPermission('modify', 'common/filemanager')) {
   $json['error'] = $this->language->get('error_permission');
  }

  if (!isset($json['error'])) {
   rename($old_name, $new_name);

   $json['success'] = $this->language->get('text_rename');
  }

  $this->response->setOutput(json_encode($json));
 }

 public function upload() {
  $this->language->load('common/filemanager');

  $json = array();

  if (isset($this->request->post['directory'])) {
   if (isset($this->request->files['image']) && $this->request->files['image']['tmp_name']) {
    $filename = basename(html_entity_decode($this->request->files['image']['name'], ENT_QUOTES, 'UTF-8'));

    if ((strlen($filename) < 3) || (strlen($filename) > 255)) {
     $json['error'] = $this->language->get('error_filename');
    }

    $directory = rtrim(DIR_IMAGE . 'data/' . str_replace('../', '', $this->request->post['directory']), '/');

    if (!is_dir($directory)) {
     $json['error'] = $this->language->get('error_directory');
    }

    if ($this->request->files['image']['size'] > 3000000000) {
     $json['error'] = $this->language->get('error_file_size');
    }

    $allowed = array(
     'image/jpeg',
     'image/pjpeg',
     'image/png',
     'image/x-png',
     'image/gif',
     'application/x-shockwave-flash'
    );

    if (!in_array($this->request->files['image']['type'], $allowed)) {
     $json['error'] = $this->language->get('error_file_type');
    }

    $allowed = array(
     '.jpg',
     '.jpeg',
     '.gif',
     '.png',
     '.flv'
    );

    if (!in_array(strtolower(strrchr($filename, '.')), $allowed)) {
     $json['error'] = $this->language->get('error_file_type');
    }

    if ($this->request->files['image']['error'] != UPLOAD_ERR_OK) {
     $json['error'] = 'error_upload_' . $this->request->files['image']['error'];
    }   
   } else {
    $json['error'] = $this->language->get('error_file');
   }
  } else {
   $json['error'] = $this->language->get('error_directory');
  }

  if (!$this->user->hasPermission('modify', 'common/filemanager')) {
   $json['error'] = $this->language->get('error_permission');
  }

  if (!isset($json['error'])) { 
   if (@move_uploaded_file($this->request->files['image']['tmp_name'], $directory . '/' . $filename)) {  
    $json['success'] = $this->language->get('text_uploaded');
   } else {
    $json['error'] = $this->language->get('error_uploaded');
   }
  }

  $this->response->setOutput(json_encode($json));
 }
}

?>

Or you can go to line 436 where you will get this code

if ($this->request->files['image']['size'] > 300000) {
     $json['error'] = $this->language->get('error_file_size');

    }

change 300000 to your need what you required.