Пример #1
0
 /**
  * Get the next step
  *
  * @return   step object
  */
 public function getStep($name = false, $json = true)
 {
     // Check if step is loaded
     if (empty($name)) {
         return false;
     }
     JLoader::import('helpers.redmigrator', JPATH_COMPONENT_ADMINISTRATOR);
     $params = redMigratorHelper::getParams();
     $limit = $params->chunk_limit;
     // Getting the total
     if (isset($this->source)) {
         $this->total = redMigratorHelper::getTotal($this);
     }
     // We must to fragment the steps
     if ($this->total > $limit) {
         if ($this->cache == 0 && $this->status == 0) {
             if (version_compare(PHP_VERSION, '5.3.0') >= 0) {
                 $this->cache = round(($this->total - 1) / $limit, 0, PHP_ROUND_HALF_DOWN);
             } else {
                 $this->cache = round(($this->total - 1) / $limit);
             }
             $this->start = 0;
             $this->stop = $limit - 1;
             $this->first = true;
             $this->debug = "{{{1}}}";
         } else {
             if ($this->cache == 1 && $this->status == 1) {
                 $this->start = $this->cid;
                 $this->cache = 0;
                 $this->stop = $this->total - 1;
                 $this->debug = "{{{2}}}";
                 $this->first = false;
             } else {
                 if ($this->cache > 0) {
                     $this->start = $this->cid;
                     $this->stop = $this->start - 1 + $limit;
                     $this->cache = $this->cache - 1;
                     $this->debug = "{{{3}}}";
                     $this->first = false;
                     if ($this->stop > $this->total) {
                         $this->stop = $this->total - 1;
                         $this->next = true;
                     } else {
                         $this->middle = true;
                     }
                 }
             }
         }
         // Status == 1
         $this->status = 1;
     } else {
         if ($this->total == 0) {
             $this->stop = -1;
             $this->next = 1;
             $this->first = true;
             if ($this->name == $this->laststep) {
                 $this->end = true;
             }
             $this->cache = 0;
             $this->status = 2;
             $this->debug = "{{{4}}}";
         } else {
             //$this->next = true;
             $this->start = 0;
             $this->first = 1;
             $this->cache = 0;
             $this->stop = $this->total - 1;
             $this->debug = "{{{5}}}";
         }
     }
     // Mark if is the end of the step
     if ($this->name == $this->laststep && $this->cache == 1) {
         $this->end = true;
     }
     // updating the status flag
     $this->_updateStep();
     return $this->getParameters();
 }
Пример #2
0
 function __construct(redMigratorStep $step = null)
 {
     // Set the current step
     $this->_step = $step;
     jimport('legacy.component.helper');
     jimport('cms.version.version');
     JLoader::import('helpers.redmigrator', JPATH_COMPONENT_ADMINISTRATOR);
     $this->params = redMigratorHelper::getParams();
     // Getting the J! version
     $version = new JVersion();
     $this->_version = $version->RELEASE;
     // Creating dabatase instance for this installation
     $this->_db = JFactory::getDBO();
     // Getting the driver
     JLoader::register('redMigratorDriver', JPATH_COMPONENT_ADMINISTRATOR . '/includes/redmigrator.driver.class.php');
     if ($this->_step instanceof redMigratorStep) {
         $this->_step->table = $this->getSourceTable();
         // Initialize the driver
         $this->_driver = redMigratorDriver::getInstance($step);
     }
     // Getting the total
     if (!empty($step->source)) {
         $this->_total = redMigratorHelper::getTotal($step);
     }
     // Set timelimit to 0
     if (!@ini_get('safe_mode')) {
         if (!empty($this->params->timelimit)) {
             set_time_limit(0);
         }
     }
     // Make sure we can see all errors.
     if (!empty($this->params->error_reporting)) {
         error_reporting(E_ALL);
         @ini_set('display_errors', 1);
     }
     // MySQL grants check
     $query = "SHOW GRANTS FOR CURRENT_USER";
     $this->_db->setQuery($query);
     $list = $this->_db->loadRowList();
     $grant = isset($list[1][0]) ? $list[1][0] : $list[0][0];
     $grant = empty($list[1][0]) ? $list[0][0] : $list[1][0];
     if (strpos($grant, 'DROP') == true || strpos($grant, 'ALL') == true) {
         $this->canDrop = true;
     }
 }