2 /************************************************************************/
\r
4 /************************************************************************/
\r
5 /* Copyright (c) 2002-2010 */
\r
6 /* Inclusive Design Institute */
\r
7 /* http://atutor.ca */
\r
9 /* This program is free software. You can redistribute it and/or */
\r
10 /* modify it under the terms of the GNU General Public License */
\r
11 /* as published by the Free Software Foundation. */
\r
12 /************************************************************************/
\r
14 function print_errors( $errors, $notes='' ) {
\r
16 <div class="input-form">
\r
17 <table border="0" class="errbox" cellpadding="3" cellspacing="2" width="100%" summary="" align="center">
\r
20 <h3 class="err"><img src="images/bad.gif" align="top" alt="" class="img" /> Warning</h3>
\r
23 foreach ($errors as $p) {
\r
24 echo '<li>'.$p.'</li>';
\r
32 <?php echo $notes; ?>
\r
40 function print_feedback( $feedback, $notes='' ) {
\r
42 <div class="input-form">
\r
43 <table border="0" class="fbkbox" cellpadding="3" cellspacing="2" width="100%" summary="" align="center">
\r
45 <td><h3 class="feedback2"><img src="images/feedback.gif" align="top" alt="" class="img" /> The patch has been installed successfully!</h3>
\r
48 foreach ($feedback as $p) {
\r
49 echo '<li>'.$p.'</li>';
\r
56 <?php echo $notes; ?>
\r
66 * update patches.remove_permission_files & patches.backup_files
\r
68 * @author Cindy Qi Li
\r
70 function updatePatchesRecord($patch_id, $updateInfo)
\r
74 $sql_prefix = "Update ". TABLE_PREFIX. "patches set ";
\r
76 foreach ($updateInfo as $key => $value)
\r
78 $sql_middle .= $key . "='" . $value . "', ";
\r
81 $sql = substr($sql_prefix . $sql_middle, 0, -2) . " where patches_id = " . $patch_id;
\r
83 $result = mysql_query($sql, $db) or die(mysql_error());
\r
89 * This function deletes $dir recrusively without deleting $dir itself.
\r
91 * @param string $charsets_array The name of the directory where all files and folders under needs to be deleted
\r
92 * @author Cindy Qi Li
\r
94 function clear_dir($dir) {
\r
95 require_once(AT_INCLUDE_PATH.'../mods/_core/file_manager/filemanager.inc.php');
\r
97 if(!$opendir = @opendir($dir)) {
\r
101 while(($readdir=readdir($opendir)) !== false) {
\r
102 if (($readdir !== '..') && ($readdir !== '.')) {
\r
103 $readdir = trim($readdir);
\r
105 clearstatcache(); /* especially needed for Windows machines: */
\r
107 if (is_file($dir.'/'.$readdir)) {
\r
108 if(!@unlink($dir.'/'.$readdir)) {
\r
111 } else if (is_dir($dir.'/'.$readdir)) {
\r
112 /* calls lib function to clear subdirectories recrusively */
\r
113 if(!clr_dir($dir.'/'.$readdir)) {
\r
120 @closedir($opendir);
\r
126 * Check if the patch has been installed
\r
128 function is_patch_installed($patch_id)
\r
132 // Only displays the patches that are not installed
\r
133 $sql = "select count(*) num_of_installed from ".TABLE_PREFIX."patches " .
\r
134 "where atutor_patch_id = '" . $patch_id ."'".
\r
135 " and applied_version = '".VERSION."'".
\r
136 " and status like '%Installed'";
\r
138 $result = mysql_query($sql, $db) or die(mysql_error());
\r
139 $row = mysql_fetch_assoc($result);
\r
141 if ($row["num_of_installed"] > 0) return true;
\r