removed mods directory from the ATutor codebase
[atutor.git] / mods / patcher / index_admin.php
diff --git a/mods/patcher/index_admin.php b/mods/patcher/index_admin.php
deleted file mode 100644 (file)
index ff18d54..0000000
+++ /dev/null
@@ -1,424 +0,0 @@
-<?php\r
-define('AT_INCLUDE_PATH', '../../include/');\r
-require (AT_INCLUDE_PATH.'vitals.inc.php');\r
-admin_authenticate(AT_ADMIN_PRIV_PATCHER);\r
-require (AT_INCLUDE_PATH.'header.inc.php');\r
-\r
-require_once('include/common.inc.php');\r
-\r
-set_time_limit(0);\r
-\r
-/**\r
- * Generate html of each patch row at main patch page\r
- */\r
-function print_patch_row($patch_row, $row_id, $enable_radiotton)\r
-{\r
-       global $id, $patch_id;   // current selected patch\r
-       global $dependent_patches;\r
-\r
-       if ($dependent_patches =="")\r
-               $description = $patch_row["description"];\r
-       else\r
-               $description = $patch_row["description"] . _AT('patch_dependent_patch_not_installed') . "<span style='color: red'>" . $dependent_patches . "</span>";\r
-?>\r
-       <tr <?php if ($enable_radiotton) echo 'onmousedown="document.form[\'m'. $row_id.'\'].checked = true; rowselect(this);"'; ?> id="r_<?php echo $row_id; ?>">\r
-               <td><input type="radio" name="id" value="<?php echo $row_id; ?>" id="m<?php echo $row_id; ?>" <?php if (!$enable_radiotton) echo "disabled "; if (strcmp($row_id, $id) == 0 || strcmp($row_id, $patch_id) == 0) echo "checked "?> /></td>\r
-               <td><label for="m<?php echo $row_id; ?>"><?php echo $patch_row["atutor_patch_id"]; ?></label></td>\r
-               <td><?php echo $description; ?></td>\r
-               <td><?php if (!isset($patch_row['status'])) echo "Uninstalled"; else echo $patch_row["status"]; ?></td>\r
-               <td><?php echo $patch_row["available_to"]; ?></td>\r
-               <td>\r
-               <?php \r
-               if (preg_match('/Installed/', $patch_row["status"]) > 0 && ($patch_row["remove_permission_files"]<> "" || $patch_row["backup_files"]<>"" || $patch_row["patch_files"]<> ""))\r
-                       echo '\r
-                 <div class="row buttons">\r
-                               <input type="button" align="center" name="info" value="'._AT('view_message').'" onClick="location.href=\''. $_SERVER['PHP_SELF'] .'?patch_id='.$row_id.'\'" />\r
-                       </div>';\r
-               ?>\r
-               </td>\r
-       </tr>\r
-<?php\r
-}\r
-\r
-// split a string by given delimiter and return an array\r
-function get_array_by_delimiter($subject, $delimiter)\r
-{\r
-       return preg_split('/'.preg_quote($delimiter).'/', $subject, -1, PREG_SPLIT_NO_EMPTY);\r
-}\r
-\r
-$skipFilesModified = false;\r
-\r
-if ($_POST['yes'])  $skipFilesModified = true;\r
-\r
-require_once('classes/PatchListParser.class.php');\r
-\r
-if (trim($_POST['who']) != '') $who = trim($_POST['who']);\r
-elseif (trim($_REQUEST['who']) != '') $who = trim($_REQUEST['who']);\r
-else $who = "public";\r
-\r
-// check the connection to server update.atutor.ca\r
-$update_server = "update.atutor.ca"; \r
-\r
-$file = fsockopen ($update_server, 80, $errno, $errstr, 15);\r
-\r
-if (!$file) \r
-{\r
-       print '<span style="color: red"><b>Error: Cannot connect to patch server: '. $update_server . '</b></span>';\r
-       exit;\r
-}\r
-\r
-// get patch list\r
-$patch_folder = "http://" . $update_server . '/patch/' . str_replace('.', '_', VERSION) . '/';\r
-\r
-$patch_list_xml = @file_get_contents($patch_folder . 'patch_list.xml');\r
-\r
-if ($patch_list_xml === FALSE) \r
-{\r
-       echo _AT('none_found');\r
-}\r
-else\r
-{\r
-       $patchListParser =& new PatchListParser();\r
-       $patchListParser->parse($patch_list_xml);\r
-       $patch_list_array = $patchListParser->getMyParsedArrayForVersion(VERSION);\r
-}\r
-// end of get patch list\r
-\r
-$module_content_folder = AT_CONTENT_DIR . "patcher";\r
-               \r
-if ($_POST['install_upload'] && $_POST['uploading'])\r
-{\r
-       include_once(AT_INCLUDE_PATH . '/classes/pclzip.lib.php');\r
-       \r
-       // clean up module content folder\r
-       clear_dir($module_content_folder);\r
-       \r
-       // 1. unzip uploaded file to module's content directory\r
-       $archive = new PclZip($_FILES['patchfile']['tmp_name']);\r
-\r
-       if ($archive->extract(PCLZIP_OPT_PATH, $module_content_folder) == 0)\r
-       {\r
-    clear_dir($module_content_folder);\r
-    $msg->addError('CANNOT_UNZIP');\r
-  }\r
-}\r
-\r
-// Installation process\r
-if ($_POST['install'] || $_POST['install_upload'])\r
-{\r
-       \r
-       if (isset($_POST['id'])) $id=$_POST['id'];\r
-       else $id = $_REQUEST['id'];\r
-\r
-       if ($_POST['install'] && $id == "")\r
-       {\r
-               $msg->addError('CHOOSE_UNINSTALLED_PATCH');\r
-       }\r
-       else\r
-       {\r
-               if ($_POST['install'])\r
-               {\r
-                       $patchURL = $patch_folder . $patch_list_array[$id][patch_folder] . "/";\r
-               }\r
-               else if ($_POST['install_upload'])\r
-               {\r
-                       $patchURL = $module_content_folder . "/";\r
-               }\r
-                       \r
-               $patch_xml = @file_get_contents($patchURL . 'patch.xml');\r
-               \r
-               if ($patch_xml === FALSE) \r
-               {\r
-                       $msg->addError('PATCH_XML_NOT_FOUND');\r
-               }\r
-               else\r
-               {\r
-                       require_once('classes/PatchParser.class.php');\r
-                       require_once('classes/Patch.class.php');\r
-                       \r
-                       $patchParser =& new PatchParser();\r
-                       $patchParser->parse($patch_xml);\r
-                       \r
-                       $patch_array = $patchParser->getParsedArray();\r
-\r
-                       if ($_POST["install_upload"])\r
-                       {\r
-                               $current_patch_list = array('atutor_patch_id' => $patch_array['atutor_patch_id'],\r
-                                                                                                                                               'applied_version' => $patch_array['applied_version'],\r
-                                                                                                                                               'patch_folder' => $patchURL,\r
-                                                                                                                                               'available_to' => 'private',\r
-                                                                                                                                               'description' => $patch_array['description'],\r
-                                                                                                                                               'dependent_patches' => $patch_array['dependent_patches']);\r
-                       }\r
-\r
-                       if ($_POST["install"])\r
-                       {\r
-                               $current_patch_list = $patch_list_array[$id];\r
-                       }\r
-\r
-                       if ($_POST["install_upload"] && is_patch_installed($patch_array["atutor_patch_id"]))\r
-                               $msg->addError('PATCH_ALREADY_INSTALLED');\r
-                       else\r
-                       {\r
-                               $patch = & new Patch($patch_array, $current_patch_list, $skipFilesModified, $patchURL);\r
-                       \r
-                               if ($patch->applyPatch())  $patch_id = $patch->getPatchID();\r
-                       }\r
-               }\r
-       }\r
-}\r
-// end of patch installation\r
-\r
-// display permission and backup files message\r
-if (isSet($_REQUEST['patch_id']))  $patch_id = $_REQUEST['patch_id'];\r
-elseif ($_POST['patch_id']) $patch_id=$_POST['patch_id'];\r
-\r
-if ($patch_id > 0)\r
-{\r
-       // clicking on button "Done" at displaying remove permission info page\r
-       if ($_POST['done'])\r
-       {\r
-               $permission_files = array();\r
-               \r
-               if (is_array($_SESSION['remove_permission']))\r
-               {\r
-                       foreach ($_SESSION['remove_permission'] as $file)\r
-                       {\r
-                               if (is_writable($file))  $permission_files[] = $file;\r
-                       }\r
-               }\r
-               \r
-               if (count($permission_files) == 0)\r
-               {\r
-                       $updateInfo = array("remove_permission_files"=>"", "status"=>"Installed");\r
-               \r
-                       updatePatchesRecord($patch_id, $updateInfo);\r
-               }\r
-               else\r
-               {\r
-                       foreach($permission_files as $permission_file)\r
-                               $remove_permission_files .= $permission_file. '|';\r
-               \r
-                       $updateInfo = array("remove_permission_files"=>preg_quote($remove_permission_files), "status"=>"Partly Installed");\r
-                       \r
-                       updatePatchesRecord($patch_id, $updateInfo);\r
-               }\r
-       \r
-       }\r
-       \r
-       // display remove permission info\r
-       unset($_SESSION['remove_permission']);\r
-\r
-       $sql = "SELECT * FROM ".TABLE_PREFIX."patches \r
-                WHERE patches_id = " . $patch_id;\r
-\r
-       $result = mysql_query($sql, $db) or die(mysql_error());\r
-       $row = mysql_fetch_assoc($result);\r
-       \r
-       if ($row["remove_permission_files"]<> "")\r
-       {\r
-               $remove_permission_files = $_SESSION['remove_permission'] = get_array_by_delimiter($row["remove_permission_files"], "|");\r
-\r
-               if (count($_SESSION['remove_permission']) > 0)\r
-               {\r
-                       if ($_POST['done']) $msg->printErrors('REMOVE_WRITE_PERMISSION');\r
-                       else $msg->printInfos('PATCH_INSTALLED_AND_REMOVE_PERMISSION');\r
-                       \r
-                       $feedbacks[] = _AT('remove_write_permission');\r
-                       \r
-                       foreach($remove_permission_files as $remove_permission_file)\r
-                               if ($remove_permission_file <> "") $feedbacks[count($feedbacks)-1] .= "<strong>" . $remove_permission_file . "</strong><br>";\r
-\r
-                       $notes = '<form action="'. $_SERVER['PHP_SELF'].'?patch_id='.$patch_id.'" method="post" name="remove_permission">\r
-                 <div class="row buttons">\r
-                               <input type="hidden" name="patch_id" value="'.$patch_id.'" />\r
-                               <input type="submit" name="done" value="'._AT('done').'" accesskey="d" />\r
-                       </div>\r
-                       </form>';\r
-               }\r
-\r
-               print_errors($feedbacks, $notes);\r
-       }\r
-\r
-       // display backup file info after remove permission step\r
-       if ($row["remove_permission_files"] == "")\r
-       {\r
-               $msg->printFeedbacks('PATCH_INSTALLED_SUCCESSFULLY');\r
-               \r
-               if ($row["backup_files"]<> "")\r
-               {\r
-                       $backup_files = get_array_by_delimiter($row["backup_files"], "|");\r
-       \r
-                       if (count($backup_files) > 0)\r
-                       {\r
-                               $feedbacks[] = _AT('patcher_show_backup_files');\r
-                               \r
-                               foreach($backup_files as $backup_file)\r
-                                       if ($backup_file <> "") $feedbacks[count($feedbacks)-1] .= "<strong>" . $backup_file . "</strong><br>";\r
-                       }\r
-               }\r
-\r
-               if ($row["patch_files"]<> "")\r
-               {\r
-                       $patch_files = get_array_by_delimiter($row["patch_files"], "|");\r
-       \r
-                       if (count($patch_files) > 0)\r
-                       {\r
-                               $feedbacks[] = _AT('patcher_show_patch_files');\r
-                               \r
-                               foreach($patch_files as $patch_file)\r
-                                       if ($patch_file <> "") $feedbacks[count($feedbacks)-1] .= "<strong>" . $patch_file . "</strong><br>";\r
-                                       \r
-                       }\r
-               }\r
-               \r
-               if (count($feedbacks)> 0)\r
-                       print_feedback($feedbacks);\r
-               else\r
-                       print_feedback(array());\r
-       }\r
-}\r
-\r
-$msg->printErrors();\r
-\r
-?>\r
-\r
-<form action="<?php echo $_SERVER['PHP_SELF']; ?>" method="post" name="form">\r
-<div class="input-form">\r
-\r
-<?php \r
-?>\r
-<table class="data" summary="" style="width: 100%" rules="cols">\r
-<thead>\r
-       <tr>\r
-               <th scope="col">&nbsp;</th>\r
-               <th scope="col"><?php echo _AT('atutor_patch_id');?></th>\r
-               <th scope="col"><?php echo _AT('description');?></th>\r
-               <th scope="col"><?php echo _AT('status');?></th>\r
-               <th scope="col"><?php echo _AT('available_to');?></th>\r
-               <th scope="col"><?php echo _AT('view_message');?></th>\r
-       </tr>\r
-</thead>\r
-       \r
-<tbody>\r
-<?php \r
-// display installed patches\r
-$sql = "select * from ".TABLE_PREFIX."patches " .\r
-       "where applied_version = '" . VERSION . "' ".\r
-       "order by atutor_patch_id";\r
-\r
-$result = mysql_query($sql, $db);\r
-$num_of_patches = mysql_num_rows($result) + count($patch_list_array);\r
-\r
-if ($num_of_patches == 0)\r
-{\r
-       echo _AT('none_found');\r
-}\r
-else\r
-{\r
-       while ($row = mysql_fetch_assoc($result))\r
-       {\r
-                       print_patch_row($row, $row['patches_id'], false);\r
-       }\r
-       \r
-       $array_id = 0;\r
-       // display un-installed patches\r
-       foreach ($patch_list_array as $row_num => $new_patch)\r
-       {\r
-               if (!is_patch_installed($new_patch['atutor_patch_id']))\r
-               {\r
-                       $dependent_patches_installed = true;\r
-               \r
-                       // check if the dependent patches are installed\r
-                       if (is_array($new_patch["dependent_patches"]))\r
-                       {\r
-                               $dependent_patches = "";\r
-                               foreach ($new_patch["dependent_patches"] as $num => $dependent_patch)\r
-                               {\r
-                                       if (!is_patch_installed($dependent_patch))\r
-                                       {\r
-                                               $dependent_patches_installed = false;\r
-                                               $dependent_patches .= $dependent_patch. ", ";\r
-                                       }\r
-                               }\r
-                               \r
-                               // remove the last comma in the string\r
-                               if ($dependent_patches <> "") $dependent_patches = substr($dependent_patches, 0, -2);\r
-                       }\r
-\r
-                       // display patch row\r
-                       if ($dependent_patches_installed)\r
-                               print_patch_row($new_patch, $array_id++, true);\r
-                       else\r
-                       {\r
-                               print_patch_row($new_patch, $array_id++, false);\r
-                               $dependent_patches_installed = true;\r
-                       }\r
-               }\r
-               else\r
-                       $array_id++;\r
-       }\r
-\r
-?>\r
-</tbody>\r
-<tfoot>\r
-<tr>\r
-       <td colspan="7">\r
-               <input type="submit" name="install" value="<?php echo _AT('install'); ?>" />\r
-       </td>\r
-</tr>\r
-</tfoot>\r
-\r
-<?php \r
-}\r
-?>\r
-</table>\r
-\r
-</div>\r
-</form>\r
-\r
-<FORM NAME="frm_upload" ENCTYPE="multipart/form-data" METHOD=POST ACTION="<?php echo $_SERVER['PHP_SELF']; ?>" >\r
-       \r
-<div class="input-form">\r
-               <div class="row"><?php echo _AT("upload_patch"); ?></div>\r
-\r
-               <div class="row">\r
-                       <INPUT TYPE="hidden" name="MAX_FILE_SIZE" VALUE="52428800">\r
-                       <INPUT TYPE="file" NAME="patchfile"  SIZE=50>\r
-               </div>\r
-               \r
-               <div class="row buttons">\r
-                       <INPUT TYPE="submit" name="install_upload" value="Install" onClick="javascript: return validate_filename(); " class="submit" />\r
-                       <INPUT TYPE="hidden" name="uploading" value="1">\r
-               </div>\r
-</div>\r
-\r
-</form>\r
-\r
-<SCRIPT LANGUAGE="JavaScript">\r
-<!--\r
-\r
-String.prototype.trim = function() {\r
-       return this.replace(/^\s+|\s+$/g,"");\r
-}\r
-\r
-// This function validates if and only if a zip file is given\r
-function validate_filename() {\r
-  // check file type\r
-  var file = document.frm_upload.patchfile.value;\r
-  if (!file || file.trim()=='') {\r
-    alert('Please give a zip file!');\r
-    return false;\r
-  }\r
-  \r
-  if(file.slice(file.lastIndexOf(".")).toLowerCase() != '.zip') {\r
-    alert('Please upload ZIP file only!');\r
-    return false;\r
-  }\r
-}\r
-\r
-//  End -->\r
-//-->\r
-</script>\r
-\r
-<?php require (AT_INCLUDE_PATH.'footer.inc.php'); ?>\r