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.

Thursday, August 21, 2014

New Domain Extension

New Domains Availbe To Register
.academy
.actor
.agency
.archi
.associates
.bar
.bargains
.berlin
.best
.bid
.bike
.blackfriday
.blue
.boutique
.build
.builders
.buzz
.cab
.camera
.camp
.capital
.cards
.care
.careers
.cash
.catering
.center
.cheap
.christmas
.cleaning
.clinic
.clothing
.club
.codes
.coffee
.community
.company
.computer
.condos
.construction
.consulting
.contractors
.cool
.cruises
.dance
.dating
.democrat
.dental
.diamonds
.directory
.domains
.education
.email
.engineering
.enterprises
.equipment
.estate
.events
.exchange
.expert
.exposed
.fail
.farm
.financial
.fish
.flights
.florist
.foundation
.fund
.furniture
.futbol
.gallery
.gift
.glass
.graphics
.gripe
.guitars
.guru
.haus
.holdings
.holiday
.house
.immobilien
.industries
.ink
.institute
.international
.investments
.kaufen
.kim
.kitchen
.kiwi
.land
.lighting
.limited
.limo
.link
.maison
.management
.marketing
.media
.menu
.moda
.moe
.nagoya
.ninja
.partners
.parts
.photo
.photography
.photos
.pics
.pictures
.pink
.plumbing
.productions
.properties
.pub
.qpon
.recipes
.red
.reisen
.rentals
.repair
.report
.rest
.reviews
.rocks
.services
.sexy
.shiksha
.shoes
.singles
.social
.solar
.solutions
.supplies
.supply
.support
.surgery
.systems
.tattoo
.tax
.technology
.tienda
.tips
.today
.tokyo
.tools
.town
.toys
.trade
.training
.university
.uno
.vacations
.ventures
.viajes
.villas
.vision
.voting
.voyage
.watch
.webcam
.wien
.wiki
.works
.wtf
.在线
.移动
.中文网
.みんな
.xyz
.zone
Launching in this week
.bio
.cash
.fund
.furniture
.haus
.investments

.tax