39                         $this->db =& $a_db_handler;
 
   54                         $this->db = $mySetup->db;
 
   63                 $this->current_file = $updatefile;
 
   64                 $this->DB_UPDATE_FILE = $this->PATH.
"setup/sql/".$updatefile;
 
   69                 $this->LAST_UPDATE_FILE = $this->PATH.
"setup/sql/dbupdate_03.php";
 
   84                 if ((
int)$a_version > 2948)             
 
   86                         return "dbupdate_03.php";
 
   88                 else if ((
int)$a_version > 864)         
 
   90                         return "dbupdate_02.php";
 
   94                         return "dbupdate.php";
 
  113                 $this->db->disconnect();
 
  118                 if (!file_exists($this->DB_UPDATE_FILE))
 
  120                         $this->error = 
"no_db_update_file";
 
  121                         $this->filecontent = array();
 
  125                 $this->filecontent = @file($this->DB_UPDATE_FILE);
 
  131                 if (!file_exists($this->LAST_UPDATE_FILE))
 
  133                         $this->error = 
"no_last_update_file";
 
  134                         $this->lastfilecontent = array();
 
  138                 $this->lastfilecontent = @file($this->LAST_UPDATE_FILE);
 
  145                 include_once 
'./Services/Administration/classes/class.ilSetting.php';
 
  147                 $this->currentVersion = (integer) $set->get(
"db_version");
 
  153                 include_once 
'./Services/Administration/classes/class.ilSetting.php';
 
  155                 $set->set(
"db_version", $a_version);
 
  156                 $this->currentVersion = $a_version;
 
  168                 include_once 
'./Services/Administration/classes/class.ilSetting.php';
 
  170                 $set->set(
"db_update_running", $a_nr);
 
  171                 $this->db_update_running = $a_nr;
 
  181                 include_once 
'./Services/Administration/classes/class.ilSetting.php';
 
  183                 $this->db_update_running = (integer) $set->get(
"db_update_running");
 
  185                 return $this->db_update_running;
 
  193                 include_once 
'./Services/Administration/classes/class.ilSetting.php';
 
  195                 $set->set(
"db_update_running", 0);
 
  196                 $this->db_update_running = 0;
 
  202                 reset($this->lastfilecontent);
 
  204                 foreach ($this->lastfilecontent as 
$row)
 
  206                         if (ereg(
"^<#([0-9]+)>", $row, $regs))
 
  212                 $this->fileVersion = (integer) $version;
 
  232                 $sql = explode(
"\n",trim($str));
 
  233                 for ($i=0; $i<count($sql); $i++)
 
  235                         $sql[$i] = trim($sql[$i]);
 
  236                         if ($sql[$i] != 
"" && substr($sql[$i],0,1)!=
"#")
 
  239                                 if (substr($sql[$i],-1)==
";")
 
  242                                         $q .= 
" ".substr($sql[$i],0,-1);
 
  249                                                         $this->error = $r->getMessage();
 
  255                                                 $this->error = $check;
 
  268                         echo 
"incomplete_statement: ".$q.
"<br>";
 
  289                 include_once 
'./Services/Database/classes/class.ilMySQLAbstraction.php';
 
  292                 $GLOBALS[
'ilMySQLAbstraction'] = $ilMySQLAbstraction;
 
  297                 if ($a_break > $this->currentVersion &&
 
  298                         $a_break < $this->fileVersion)
 
  306                         for ($i=($c+1); $i<=$f; $i++)
 
  311                                         $this->DB_UPDATE_FILE = $this->PATH.
"setup/sql/".$this->
getFileForStep($i);
 
  320                                                 "msg" => 
"update_error: ".$this->error,
 
  323                                         $this->updateMsg = $msg;
 
  329                                                 "msg" => 
"update_applied",
 
  335                         $this->updateMsg = $msg;
 
  339                         $this->updateMsg = 
"no_changes";
 
  342                 if ($f < $this->fileVersion)
 
  357                 require_once 
"./setup/classes/class.ilModuleReader.php";
 
  358                 require_once 
"./setup/classes/class.ilServiceReader.php";
 
  359                 require_once 
"./setup/classes/class.ilCtrlStructureReader.php";
 
  361                 require_once 
"./Services/Component/classes/class.ilModule.php";
 
  362                 require_once 
"./Services/Component/classes/class.ilService.php";
 
  367                 foreach($modules as $module)
 
  370                                 $module[
"subdir"], 
"Modules");
 
  376                 foreach($services as $service)
 
  379                                 $service[
"subdir"], 
"Services");
 
  384                 $ilCtrlStructureReader->readStructure();
 
  400                 reset($this->filecontent);
 
  411                 while (!ereg(
"^<#".$nr.
">", $this->filecontent[$i]) && $i<count($this->filecontent))
 
  417                 if ($i == count($this->filecontent))
 
  419                         $this->error = 
"update_not_found";
 
  427                 while ($i<count($this->filecontent) && !ereg(
"^<#".($nr+1).
">", $this->filecontent[$i]))
 
  429                         $update[] = trim($this->filecontent[$i]);
 
  438                 foreach ($update as 
$row)
 
  440                         if (ereg(
"<\?php", $row))
 
  444                                         if ($this->
execQuery($this->db, implode(
"\n", $sql)) == 
false)
 
  446                                                 $this->error = $this->error;
 
  453                         elseif (ereg(
"\?>", $row))
 
  457                                         $code = implode(
"\n", $php);
 
  458                                         if (eval($code) === 
false)
 
  460                                                 $this->error = 
"Parse error: ".$code;
 
  482                 if ($mode == 
"sql" && count($sql) > 0)
 
  484                         if ($this->
execQuery($this->db, implode(
"\n", $sql)) == 
false)
 
  486                                 $this->error = 
"dump_error: ".$this->error;
 
  492                 if (!$hotfix && !$custom_update)
 
  500                 elseif($custom_update)
 
  505                 if (!$hotfix && !$custom_update)
 
  517                 if ($this->fileVersion > $this->currentVersion)
 
  533                                 "name" => $status[
"Table"],
 
  535                                 "status" => $status[
"Msg_text"]
 
  545                 $query = 
"ANALYZE TABLE ".$table;       
 
  554                 foreach (
$_POST[
"tables"] as $key => $value)
 
  556                         $query = 
"OPTIMIZE TABLE ".$key;        
 
  558                         $msg[] = 
"table $key: ok";
 
  574                 return $this->hotfix_current_version;
 
  583                 $this->hotfix_setting->set(
"db_hotfixes_".
 
  584                         $this->hotfix_version[0].
"_".$this->hotfix_version[1], $a_version);
 
  585                 $this->hotfix_current_version = $a_version;
 
  595                 return $this->hotfix_file_version;
 
  604                 reset($a_file_content);
 
  606                 foreach ($a_file_content as 
$row)
 
  608                         if (ereg(
"^<#([0-9]+)>", $row, $regs))
 
  614                 return (integer) $version;
 
  622                 if ($this->hotfix_info_read && !$a_force)
 
  626                 include_once 
'./Services/Administration/classes/class.ilSetting.php';
 
  628                 $this->hotfix_setting = 
new ilSetting(
"common", 
true);
 
  630                 $version_array = explode(
".", $ilias_version);
 
  631                 $this->hotfix_version[0] = $version_array[0];
 
  632                 $this->hotfix_version[1] = $version_array[1];
 
  633                 $hotfix_file = $this->PATH.
"setup/sql/".$this->hotfix_version[0].
"_".$this->hotfix_version[1].
"_hotfixes.php";
 
  634                 if (is_file($hotfix_file))
 
  636                         $this->hotfix_content = @file($hotfix_file);
 
  637                         $this->hotfix_current_version = (int) $this->hotfix_setting->get(
"db_hotfixes_".
 
  638                                 $this->hotfix_version[0].
"_".$this->hotfix_version[1]);
 
  641                 $this->hotfix_info_read = 
true;
 
  650                 if ($this->hotfix_file_version > $this->hotfix_current_version)
 
  664                 include_once 
'./Services/Database/classes/class.ilMySQLAbstraction.php';
 
  667                 $GLOBALS[
'ilMySQLAbstraction'] = $ilMySQLAbstraction;
 
  677                         for ($i=($c+1); $i<=$f; $i++)
 
  681                                 $this->filecontent = $this->hotfix_content;
 
  686                                                 "msg" => 
"update_error: ".$this->error,
 
  689                                         $this->updateMsg = $msg;
 
  695                                                 "msg" => 
"hotfix_applied",
 
  701                         $this->updateMsg = $msg;
 
  705                         $this->updateMsg = 
"no_changes";
 
  714                 return $this->custom_updates_current_version;
 
  720                 $this->custom_updates_setting->set(
'db_version_custom', $a_version);
 
  721                 $this->custom_updates_current_version = $a_version;
 
  728                 return $this->custom_updates_file_version;
 
  734                 reset($a_file_content);
 
  736                 foreach ($a_file_content as 
$row)
 
  738                         if (ereg(
"^<#([0-9]+)>", $row, $regs))
 
  744                 return (integer) $version;
 
  749                 if ($this->custom_updates_info_read && !$a_force)
 
  753                 include_once 
'./Services/Administration/classes/class.ilSetting.php';
 
  755                 $this->custom_updates_setting = 
new ilSetting();
 
  756                 $custom_updates_file = $this->PATH.
"setup/sql/dbupdate_custom.php";
 
  757                 if (is_file($custom_updates_file))
 
  759                         $this->custom_updates_content = @file($custom_updates_file);
 
  760                         $this->custom_updates_current_version = (int) $this->custom_updates_setting->get(
'db_version_custom', 0);
 
  763                 $this->custom_updates_info_read = 
true;
 
  772                 if ($this->custom_updates_file_version > $this->custom_updates_current_version)
 
  783                 include_once 
'./Services/Database/classes/class.ilMySQLAbstraction.php';
 
  786                 $GLOBALS[
'ilMySQLAbstraction'] = $ilMySQLAbstraction;
 
  796                         for ($i=($c+1); $i<=$f; $i++)
 
  800                                 $this->filecontent = $this->custom_updates_content;
 
  805                                                 "msg" => 
"update_error: ".$this->error,
 
  808                                         $this->updateMsg = $msg;
 
  814                                                 "msg" => 
"custom_update_applied",
 
  820                         $this->updateMsg = $msg;
 
  824                         $this->updateMsg = 
"no_changes";
 
  844                 if ($a_break > $this->currentVersion &&
 
  845                         $a_break < $this->fileVersion)
 
  853                         for ($i=($c+1); $i<=$f; $i++)
 
  858                                         $this->DB_UPDATE_FILE = $this->PATH.
"setup/sql/".$this->
getFileForStep($i);
 
  886                         for ($i=($c+1); $i<=$f; $i++)
 
  888                                 $this->filecontent = $this->hotfix_content;
 
  908                 reset($this->filecontent);
 
  914                 while (!ereg(
"^<#".$nr.
">", $this->filecontent[$i]) && $i<count($this->filecontent))
 
  920                 if ($i == count($this->filecontent))
 
  929                 while ($i<count($this->filecontent) && !ereg(
"^<#".($nr+1).
">", $this->filecontent[$i]))
 
  931                         $str.= $this->filecontent[$i];
 
  935                 return "<pre><b><#".$nr.
"></b>\n".htmlentities($str).
"</pre>";