" . $dependent_patches . "";
?>
>
" /> |
|
|
|
|
|
|
0 && ($patch_row["remove_permission_files"]<> "" || $patch_row["backup_files"]<>"" || $patch_row["patch_files"]<> ""))
echo '
';
?>
|
addFeedback('CANCELLED');
header('Location: index.php');
exit;
}
require (TR_INCLUDE_PATH.'header.inc.php');
if (trim($_POST['who']) != '') $who = trim($_POST['who']);
elseif (trim($_REQUEST['who']) != '') $who = trim($_REQUEST['who']);
else $who = "public";
// check the connection to server update.atutor.ca
$connection_test_file = UPDATE_SERVER . '/index.php';
$connection = @file_get_contents($connection_test_file);
if (!$connection)
{
$infos = array('CANNOT_CONNECT_PATCH_SERVER', UPDATE_SERVER);
$msg->addInfo($infos);
$server_connected = false;
}
else
$server_connected = true;
// get patch list if successfully connect to patch server
if ($server_connected)
{
$patch_folder = UPDATE_SERVER . '/patch/' . str_replace('.', '_', VERSION) . '/';
$patch_list_xml = @file_get_contents($patch_folder . 'patch_list.xml');
if ($patch_list_xml)
{
$patchListParser = new PatchListParser();
$patchListParser->parse($patch_list_xml);
$patch_list_array = $patchListParser->getMyParsedArrayForVersion(VERSION);
}
}
// end of get patch list
$module_content_folder = TR_CONTENT_DIR . "updater/temp";
if (!is_dir($module_content_folder)) mkdir($module_content_folder);
if ($_POST['install_upload'] && $_POST['uploading'])
{
include_once(TR_INCLUDE_PATH . 'lib/pclzip.lib.php');
// clean up module content folder
FileUtility::clr_dir($module_content_folder);
// 1. unzip uploaded file to module's content directory
$archive = new PclZip($_FILES['patchfile']['tmp_name']);
if ($archive->extract(PCLZIP_OPT_PATH, $module_content_folder) == 0)
{
FileUtility::clr_dir($module_content_folder);
$msg->addError('CANNOT_UNZIP');
}
}
// Installation process
if ($_POST['install'] || $_POST['install_upload'] && !isset($_POST["not_ignore_version"]))
{
if (isset($_POST['id'])) $id=$_POST['id'];
else $id = $_REQUEST['id'];
if ($_POST['install'] && $id == "")
{
$msg->addError('CHOOSE_UNINSTALLED_PATCH');
}
else
{
if ($_POST['install'])
{
$patchURL = $patch_folder . $patch_list_array[$id][patch_folder] . "/";
}
else if ($_POST['install_upload'])
{
$patchURL = $module_content_folder . "/";
}
$patch_xml = @file_get_contents($patchURL . 'patch.xml');
if ($patch_xml === FALSE)
{
$msg->addError('PATCH_XML_NOT_FOUND');
}
else
{
require_once('classes/PatchParser.class.php');
require_once('classes/Patch.class.php');
$patchParser = new PatchParser();
$patchParser->parse($patch_xml);
$patch_array = $patchParser->getParsedArray();
if ($_POST["ignore_version"]) $patch_array["applied_version"] = VERSION;
if ($_POST["install_upload"])
{
$current_patch_list = array('system_patch_id' => $patch_array['system_patch_id'],
'applied_version' => $patch_array['applied_version'],
'patch_folder' => $patchURL,
'available_to' => 'private',
'author' => $patch_array['author'],
'sql' => $patch_array['sql'],
'description' => $patch_array['description'],
'dependent_patches' => $patch_array['dependent_patches']);
}
if ($_POST["install"])
{
$current_patch_list = $patch_list_array[$id];
$current_patch_list["sql"] = $patch_array["sql"];
}
if ($_POST["install_upload"] && is_patch_installed($patch_array["system_patch_id"]))
$msg->addError('UPDATE_ALREADY_INSTALLED');
else
{
$patch = new Patch($patch_array, $current_patch_list, $skipFilesModified, $patchURL);
if ($patch->applyPatch()) $patch_id = $patch->getPatchID();
}
}
}
}
// end of patch installation
// display permission and backup files message
if (isSet($_REQUEST['patch_id'])) $patch_id = $_REQUEST['patch_id'];
elseif ($_POST['patch_id']) $patch_id=$_POST['patch_id'];
if ($patch_id > 0)
{
// clicking on button "Done" at displaying remove permission info page
if ($_POST['done'])
{
$permission_files = array();
if (is_array($_SESSION['remove_permission']))
{
foreach ($_SESSION['remove_permission'] as $file)
{
if (is_writable($file)) $permission_files[] = $file;
}
}
if (count($permission_files) == 0)
{
$updateInfo = array("remove_permission_files"=>"", "status"=>"Installed");
$patchesDAO->UpdateByArray($patch_id, $updateInfo);
}
else
{
foreach($permission_files as $permission_file)
$remove_permission_files .= $permission_file. '|';
$updateInfo = array("remove_permission_files"=>preg_quote($remove_permission_files), "status"=>"Partly Installed");
$patchesDAO->UpdateByArray($patch_id, $updateInfo);
}
}
// display remove permission info
unset($_SESSION['remove_permission']);
$row = $patchesDAO->getByID($patch_id);
if ($row["remove_permission_files"]<> "")
{
$remove_permission_files = $_SESSION['remove_permission'] = get_array_by_delimiter($row["remove_permission_files"], "|");
if (count($_SESSION['remove_permission']) > 0)
{
if ($_POST['done']) $msg->printErrors('REMOVE_WRITE_PERMISSION');
else $msg->printInfos('PATCH_INSTALLED_AND_REMOVE_PERMISSION');
$feedbacks[] = _AT('remove_write_permission');
foreach($remove_permission_files as $remove_permission_file)
if ($remove_permission_file <> "") $feedbacks[count($feedbacks)-1] .= "" . $remove_permission_file . "
";
$notes = '';
}
print_errors($feedbacks, $notes);
}
// display backup file info after remove permission step
if ($row["remove_permission_files"] == "")
{
$msg->printFeedbacks('PATCH_INSTALLED_SUCCESSFULLY');
if ($row["backup_files"]<> "")
{
$backup_files = get_array_by_delimiter($row["backup_files"], "|");
if (count($backup_files) > 0)
{
$feedbacks[] = _AT('updater_show_backup_files');
foreach($backup_files as $backup_file)
if ($backup_file <> "") $feedbacks[count($feedbacks)-1] .= "" . $backup_file . "
";
}
}
if ($row["patch_files"]<> "")
{
$patch_files = get_array_by_delimiter($row["patch_files"], "|");
if (count($patch_files) > 0)
{
$feedbacks[] = _AT('updater_show_patch_files');
foreach($patch_files as $patch_file)
if ($patch_file <> "") $feedbacks[count($feedbacks)-1] .= "" . $patch_file . "
";
}
}
if (count($feedbacks)> 0)
print_feedback($feedbacks);
else
print_feedback(array());
}
}
$msg->printAll();
// display installed patches
$rows = $patchesDAO->getPatchByVersion(VERSION);
if (is_array($rows)) $num_of_patches_in_db = count($rows);
else $num_of_patches_in_db = 0;
$num_of_patches = $num_of_patches_in_db + count($patch_list_array);
$savant->assign('num_of_patches', $num_of_patches);
$savant->assign('patches_in_db', $rows);
$savant->assign('patch_list_array', $patch_list_array);
$savant->assign('patches_in_db', $rows);
$savant->assign('patches_in_db', $rows);
$savant->display('updater/index.tmpl.php');
?>