} else if (isset($_POST['submit_yes'])) {\r
\r
//clean up the db\r
- require(AT_INCLUDE_PATH.'../mods/_core/file_manager/filemanager.inc.php');\r
+ require_once(AT_INCLUDE_PATH.'../mods/_core/file_manager/filemanager.inc.php');\r
\r
if (($result = clr_dir(AT_CONTENT_DIR . 'logs/'))) {\r
$msg->addFeedback('ERROR_LOG_RESET');\r
+++ /dev/null
-<?php
-/****************************************************************/
-/* ATutor */
-/****************************************************************/
-/* Copyright (c) 2002-2008 by Greg Gay & Joel Kronenberg */
-/* Adaptive Technology Resource Centre / University of Toronto */
-/* http://atutor.ca */
-/* */
-/* This program is free software. You can redistribute it and/or*/
-/* modify it under the terms of the GNU General Public License */
-/* as published by the Free Software Foundation. */
-/****************************************************************/
-// $Id: zipfile.class.php 7208 2008-01-09 16:07:24Z greg $
-
-//loads the pclzip library.
-define('PCLZIP_TEMPORARY_DIR', AT_CONTENT_DIR.'export'.DIRECTORY_SEPARATOR);
-include(AT_INCLUDE_PATH.'/classes/pclzip.lib.php');
-include(AT_INCLUDE_PATH.'..//mods/_core/file_manager/filemanager.inc.php'); //copy/delete folder
-
-/**
-* Class for creating and accessing an archive zip file
-* @access public
-* @link http://www.pkware.com/products/enterprise/white_papers/appnote.html for the specs
-* @author Joel Kronenberg
-*/
-class zipfile {
-
-
- /**
- *
- */
- var $zipfile_dir;
-
- /**
- * boolean $is_closed - flag set to true if file is closed, false if still open
- * @access private
- */
- var $is_closed;
-
- /** File name */
- var $filename;
-
-
- /**
- * Constructor method. Initialises variables.
- * @access public
- * @author Joel Kronenberg
- */
- function zipfile() {
- //create the
- if (!is_dir(PCLZIP_TEMPORARY_DIR)){
- mkdir(PCLZIP_TEMPORARY_DIR);
- copy(PCLZIP_TEMPORARY_DIR.'../index.html', PCLZIP_TEMPORARY_DIR.'index.html');
- }
-
- //generate a random hash
- $this->filename = substr(md5(rand()), 0, 5);
-
- $this->zipfile_dir = PCLZIP_TEMPORARY_DIR.$this->filename.DIRECTORY_SEPARATOR;
- mkdir($this->zipfile_dir);
- $this->is_closed = false;
- }
-
-
- /**
- * Public interface for adding a dir and its contents recursively to zip file
- * @access public
- * @param string $dir the real system directory that contains the files to add to the zip
- * @param string $zip_prefix_dir the zip dir where the contents of $dir will be put in
- * @param string $pre_pend_dir used during the recursion to keep track of the path, default=''
- * @see $_base_path in include/vitals.inc.php
- * @see priv_add_dir() in include/classes/zipfile.class.php
- * @see add_file() in include/classes/zipfile.class.php
- * @author Joel Kronenberg
- */
- function add_dir($dir, $zip_prefix_dir, $pre_pend_dir='') {
- if (!($dh = @opendir($dir.$pre_pend_dir))) {
- echo 'cant open dir: '.$dir.$pre_pend_dir;
- exit;
- }
-debug($dir, 'add dir');
- //copy folder recursively
- copys($dir, $this->zipfile_dir.DIRECTORY_SEPARATOR.$zip_prefix_dir);
- }
-
- /**
- * Adding a dir to the archive
- * @access private
- * @param string $name directory name
- * @param string $timestamp time, default=''
- * @author Joel Kronenberg
- */
- function priv_add_dir($name, $timestamp = '') {
- //deprecated.
- }
-
- /**
- * Public interface to create a directory in the archive.
- * @access public
- * @param string $name directory name
- * @param string $timestamp time of creation, default=''
- * @see $_base_path in include/vitals.inc.php
- * @see priv_add_dir() in include/zipfile.class.php
- * @author Joel Kronenberg
- */
- function create_dir($name, $timestamp='') {
- $name = trim($name);
-
- if(is_dir(dirname($this->zipfile_dir.$name)) && $name != '.'){
- $this->create_dir(dirname($name));
- } elseif ($name == '' || $name ='.') {
- return;
- }
-
- //mkdir
-
-debug($this->zipfile_dir.$name, 'create dir');
- mkdir($this->zipfile_dir.$name);
- }
-
-
- /**
- * Adds a file to the archive.
- * @access public
- * @param string $file_data file contents
- * @param string $name name of file in archive (add path if your want)
- * @param string $timestamp time of creation, default=''
- * @see $_base_path in include/vitals.inc.php
- * @see priv_add_dir() in include/zipfile.class.php
- * @author Joel Kronenberg
- */
- function add_file($file_data, $name, $timestamp = '') {
- $name = str_replace("\\", "/", $name);
-
- //check if folder exists, if not, create it.
-debug($name);
- if (!is_dir(dirname($this->zipfile_dir.$name))){
- $this->create_dir(dirname($this->zipfile_dir.$name));
- }
-
- $fp = fopen($this->zipfile_dir.$name, 'w');
- fwrite($fp, $file_data);
- fclose($fp);
- }
-
- /**
- * Closes archive, sets $is_closed to true
- * @access public
- * @param none
- * @author Joel Kronenberg
- */
- function close() {
- //save file
-
- $archive = new PclZip($this->zipfile_dir.$this->filename.'.zip');
- $v_list = $archive->create($this->zipfile_dir,
- PCLZIP_OPT_REMOVE_PATH, $this->zipfile_dir);
-
- //error info
- if ($v_list == 0) {
- die ("Error: " . $archive->errorInfo(true));
- }
-
-// debug($v_list);
- $this->is_closed = true;
- }
-
- /**
- * Gets size of new archive
- * Only call this after calling close() - will return false if the zip wasn't close()d yet
- * @access public
- * @return int size of file in byte.
- * @author Joel Kronenberg
- */
- function get_size() {
- if (!$this->is_closed) {
- return false;
- }
-
- //file path
- $filepath = $this->zipfile_dir.$this->filename.'.zip';
- if (file_exists($filepath)){
- return filesize($filepath);
- }
-
- return false;
- }
-
-
- /**
- * Returns binary file
- * @access public
- * @see get_size() in include/classes/zipfile.class.php
- * @author Joel Kronenberg
- */
- function get_file() {
- if (!$this->is_closed) {
- $this->close();
- }
- return file_get_contents($this->zipfile_dir.$this->filename.'.zip');
- }
-
- /**
- * Writes the file to disk.
- * Similar to get_file(), but instead of returning the file, it saves it to disk.
- * @access public
- * @author Joel Kronenberg
- * @param $file The full path and file name of the destination file.
- */
- function write_file($file) {
- if (!$this->is_closed) {
- $this->close();
- }
- copy($this->zipfile_dir.$this->filename.'.zip', $file);
- }
-
-
- /**
- * Outputs the file - sends headers to browser to force download
- * Only call this after calling close() - will return false if the zip wasn't close()d yet
- * @access public
- * @see get_size() in include/classes/zipfile.class.php
- * @author Joel Kronenberg
- */
- function send_file($file_name) {
-return;
- if (!$this->is_closed) {
- $this->close();
- }
- $file_name = str_replace(array('"', '<', '>', '|', '?', '*', ':', '/', '\\'), '', $file_name);
-
- header("Content-type: application/octet-stream");
- header("Content-disposition: attachment; filename=$file_name.zip");
- readfile($this->zipfile_dir.$this->filename.'.zip');
- exit;
- }
-
- /**
- * Destructor - removes temporary folder and its content.
- */
- function __destruct(){
-// clr_dir($this->zipfile_dir);
- }
-}
-
-?>
\ No newline at end of file
<?php
-/****************************************************************/
-/* ATutor */
-/****************************************************************/
-/* Copyright (c) 2002-2008 by Greg Gay & Joel Kronenberg */
-/* Adaptive Technology Resource Centre / University of Toronto */
-/* http://atutor.ca */
-/* */
-/* This program is free software. You can redistribute it and/or*/
-/* modify it under the terms of the GNU General Public License */
-/* as published by the Free Software Foundation. */
-/****************************************************************/
+/***********************************************************************/
+/* ATutor */
+/***********************************************************************/
+/* Copyright (c) 2002-2009 */
+/* Adaptive Technology Resource Centre / Inclusive Design Institute */
+/* http://atutor.ca */
+/* */
+/* This program is free software. You can redistribute it and/or */
+/* modify it under the terms of the GNU General Public License */
+/* as published by the Free Software Foundation. */
+/***********************************************************************/
// $Id$
-//loads the pclzip library.
-define('PCLZIP_TEMPORARY_DIR', AT_CONTENT_DIR.'export'.DIRECTORY_SEPARATOR);
-include(AT_INCLUDE_PATH.'/classes/pclzip.lib.php');
-include(AT_INCLUDE_PATH.'..//mods/_core/file_manager/filemanager.inc.php'); //copy/delete folder
+define('PCLZIP_TEMPORARY_DIR', AT_CONTENT_DIR.'export'.DIRECTORY_SEPARATOR); //constant for the temp folder.
+include(AT_INCLUDE_PATH.'/classes/pclzip.lib.php'); //loads the pclzip library.
+include_once(AT_INCLUDE_PATH.'..//mods/_core/file_manager/filemanager.inc.php'); //copy/delete folder
/**
-* Class for creating and accessing an archive zip file
+* Class for creating and accessing an archive zip file. Originally written by Joel Kronenberg,
+* edited by Harris Wong to use the PCLZIP library (http://www.phpconcept.net)
+*
+* As of ATutor 2.0, this file will extend the pclzip library functions instead of using Joel's.
+* The function preconditions and postconditions will remain the same however.
+*
* @access public
-* @link http://www.pkware.com/products/enterprise/white_papers/appnote.html for the specs
+* @link http://www.pkware.com/documents/casestudies/APPNOTE.TXT for the specs
* @author Joel Kronenberg
*/
class zipfile {
-
/**
- *
+ * string $zipfile_dir - the actual system directory that stores the temporary files for archiving.
+ * @access private
*/
var $zipfile_dir;
*/
var $is_closed;
- /** File name */
+ /**
+ * string $filename - randomized filename of this zip instance. It also shares the same name
+ * as the folder under the export/ folder.
+ */
var $filename;
* @author Joel Kronenberg
*/
function zipfile() {
- //create the
+ //create the temp folder for export if it hasn't been created.
if (!is_dir(PCLZIP_TEMPORARY_DIR)){
mkdir(PCLZIP_TEMPORARY_DIR);
copy(PCLZIP_TEMPORARY_DIR.'../index.html', PCLZIP_TEMPORARY_DIR.'index.html');
//generate a random hash
$this->filename = substr(md5(rand()), 0, 5);
+ //create a temporary folder for this zip instance
$this->zipfile_dir = PCLZIP_TEMPORARY_DIR.$this->filename.DIRECTORY_SEPARATOR;
mkdir($this->zipfile_dir);
$this->is_closed = false;
echo 'cant open dir: '.$dir.$pre_pend_dir;
exit;
}
-debug($dir, 'add dir');
- //copy folder recursively
+ //copy folder recursively into the temp folder.
copys($dir, $this->zipfile_dir.DIRECTORY_SEPARATOR.$zip_prefix_dir);
}
* @author Joel Kronenberg
*/
function priv_add_dir($name, $timestamp = '') {
- //deprecated.
+ //deprecated as of ATutor 2.0
}
/**
*/
function create_dir($name, $timestamp='') {
$name = trim($name);
- //don't create folder if it is itself
+ //don't create a folder if it is itself
if ($name=='' || $name=='.'){
return;
}
$this->create_dir(dirname($name));
}
- //returned stack. continue from where it left off.
- //Now, the parent folder is created, so it should be able to create its folder.
+ //returned stack. continue from where it left off.
if (!is_dir($this->zipfile_dir.$name)){
+ //the parent folder should be created at this point, create itself
mkdir($this->zipfile_dir.$name);
}
}
$this->create_dir(dirname($name));
}
+ //write to file
$fp = fopen($this->zipfile_dir.$name, 'w');
fwrite($fp, $file_data);
fclose($fp);
* @author Joel Kronenberg
*/
function close() {
- //save file
-
+ //use pclzip to compress the file, and save it in the temp folder.
$archive = new PclZip($this->zipfile_dir.$this->filename.'.zip');
$v_list = $archive->create($this->zipfile_dir,
PCLZIP_OPT_REMOVE_PATH, $this->zipfile_dir);
if ($v_list == 0) {
die ("Error: " . $archive->errorInfo(true));
}
-
-// debug($v_list);
+
$this->is_closed = true;
}
/**
* Destructor - removes temporary folder and its content.
+ * Should self-destruct automatically for PHP 5.0+; otherwise developers should call this function
+ * to clean up.
+ * @access public
+ * @author Harris Wong
*/
function __destruct(){
clr_dir($this->zipfile_dir);
--- /dev/null
+<?php
+/****************************************************************/
+/* ATutor */
+/****************************************************************/
+/* Copyright (c) 2002-2008 by Greg Gay & Joel Kronenberg */
+/* Adaptive Technology Resource Centre / University of Toronto */
+/* http://atutor.ca */
+/* */
+/* This program is free software. You can redistribute it and/or*/
+/* modify it under the terms of the GNU General Public License */
+/* as published by the Free Software Foundation. */
+/****************************************************************/
+// $Id: zipfile.class.php 7208 2008-01-09 16:07:24Z greg $
+
+
+/**
+* Class for creating and accessing an archive zip file
+* @access public
+* @link http://www.pkware.com/products/enterprise/white_papers/appnote.html for the specs
+* @author Joel Kronenberg
+*/
+class zipfile {
+
+ /**
+ * string $files_data - stores file information like the header and description
+ * @access public
+ */
+ var $files_data;
+
+ /**
+ * string $central_directory_headers - headers necessary for including file in central record
+ * @access public
+ */
+ var $central_directory_headers;
+
+ /**
+ * int $num_entries - a counter for the number of entries in the archive
+ * @access public
+ */
+ var $num_entries = 0;
+
+ /**
+ * string $zip_file - complete contents of file
+ * @access public
+ */
+ var $zip_file;
+
+ /**
+ * boolean $is_closed - flag set to true if file is closed, false if still open
+ * @access private
+ */
+ var $is_closed;
+
+
+ /**
+ * Constructor method. Initialises variables.
+ * @access public
+ * @author Joel Kronenberg
+ */
+ function zipfile() {
+ $this->files_data = '';
+ $this->central_directory_headers = '';
+ $this->num_entries = 0;
+ $this->is_closed = false;
+ }
+
+ /**
+ * Public interface for adding a dir and its contents recursively to zip file
+ * @access public
+ * @param string $dir the real system directory that contains the files to add to the zip
+ * @param string $zip_prefix_dir the zip dir where the contents of $dir will be put in
+ * @param string $pre_pend_dir used during the recursion to keep track of the path, default=''
+ * @see $_base_path in include/vitals.inc.php
+ * @see priv_add_dir() in include/classes/zipfile.class.php
+ * @see add_file() in include/classes/zipfile.class.php
+ * @author Joel Kronenberg
+ */
+ function add_dir($dir, $zip_prefix_dir, $pre_pend_dir='') {
+ if (!($dh = @opendir($dir.$pre_pend_dir))) {
+ echo 'cant open dir: '.$dir.$pre_pend_dir;
+ exit;
+ }
+
+ while (($file = readdir($dh)) !== false) {
+ /* skip directories */
+ if ($file == '.' || $file == '..') {
+ continue;
+ }
+ /* skip potential harmful files/directories */
+ if ( (strpos($file, '..') !== false) || (strpos($file, '/') !== false)) {
+ continue;
+ }
+
+ $file_info = stat( $dir . $pre_pend_dir . $file );
+
+ if (is_dir( $dir . $pre_pend_dir . $file )) {
+ /* create this dir in the zip */
+ $this->priv_add_dir( $zip_prefix_dir . $pre_pend_dir . $file . '/',
+ $file_info['mtime'] );
+
+ /* continue recursion, going down this dir */
+ $this->add_dir( $dir,
+ $zip_prefix_dir,
+ $pre_pend_dir . $file . '/' );
+
+ } else {
+ /* add this file to the zip */
+ $this-> add_file( file_get_contents($dir . $pre_pend_dir . $file),
+ $zip_prefix_dir . $pre_pend_dir . $file,
+ $file_info['mtime'] );
+ }
+ }
+ closedir($dh);
+ }
+
+ /**
+ * Adding a dir to the archive
+ * @access private
+ * @param string $name directory name
+ * @param string $timestamp time, default=''
+ * @author Joel Kronenberg
+ */
+ function priv_add_dir($name, $timestamp = '') {
+ $name = str_replace("\\", "/", $name);
+ $old_offset = strlen($this->files_data);
+
+ $local_file_header = "\x50\x4b\x03\x04"; // local file header signature 4 bytes (0x04034b50)
+ $local_file_header .= "\x0a\x00"; // ver needed to extract // version needed to extract 2 bytes
+ $local_file_header .= "\x00\x00"; // gen purpose bit flag // general purpose bit flag 2 bytes
+ $local_file_header .= "\x00\x00"; // compression method // compression method 2 bytes
+ $local_file_header .= "\x00\x00\x00\x00"; // last mod time and date // last mod file time 2 bytes & last mod file date 2 bytes
+ $local_file_header .= pack("V",0); // crc32 // crc-32 4 bytes
+ $local_file_header .= pack("V",0); //compressed filesize // compressed size 4 bytes
+ $local_file_header .= pack("V",0); //uncompressed filesize // uncompressed size 4 bytes
+ $local_file_header .= pack("v", strlen($name) ); //length of pathname // file name length 2 bytes
+ $local_file_header .= pack("v", 0 ); //extra field length // extra field length 2 bytes
+ $local_file_header .= $name; // file name (variable size) & extra field (variable size)
+ // end of "local file header" segment
+
+ // no "file data" segment for path
+
+ // add this entry to array
+ $this->files_data .= $local_file_header;
+
+ // ext. file attributes mirrors MS-DOS directory attr byte, detailed
+ // at http://support.microsoft.com/support/kb/articles/Q125/0/19.asp
+
+ if ($timestamp) {
+ $v_date = getdate($timestamp);
+ } else {
+ $v_date = getdate();
+ }
+ $time = ($v_date['hours']<<11) + ($v_date['minutes']<<5) + $v_date['seconds']/2;
+ $date = (($v_date['year']-1980)<<9) + ($v_date['mon']<<5) + $v_date['mday'];
+
+ // now add to central record
+ $central_directory = "\x50\x4b\x01\x02"; // central file header signature 4 bytes (0x02014b50)
+ $central_directory .="\x14\x00"; // version made by // version made by 2 bytes
+ $central_directory .="\x14\x00"; // version needed to extract // version needed to extract 2 bytes
+ $central_directory .="\x00\x00"; // gen purpose bit flag // general purpose bit flag 2 bytes
+ $central_directory .="\x00\x00"; // compression method // compression method 2 bytes
+ $central_directory .= pack("v",$time); // time // last mod file time 2 bytes
+ $central_directory .= pack("v",$date); // date // last mod file date 2 bytes
+ $central_directory .= pack("V", 0); // crc32 // crc-32 4 bytes
+ $central_directory .= pack("V", 0); // compressed filesize // compressed size 4 bytes
+ $central_directory .= pack("V", 0); // uncompressed filesize // uncompressed size 4 bytes
+ $central_directory .= pack("v", strlen($name) ); //length of filename // file name length 2 bytes
+ $central_directory .= pack("v", 0); // extra field length // extra field length 2 bytes
+ $central_directory .= pack("v", 0); // file comment length // file comment length 2 bytes
+ $central_directory .= pack("v", 0); // disk number start // disk number start 2 bytes
+ $central_directory .= pack("v", 0); // internal file attributes // internal file attributes 2 bytes
+ $central_directory .= pack("V", 16+32); //external file attributes - 'directory' 'archive' bit set // external file attributes 4 bytes
+ $central_directory .= pack("V", $old_offset); //relative offset of local header // relative offset of local header 4 bytes
+ $central_directory .= $name; // file name (variable size)
+
+ $this->central_directory_headers .= $central_directory;
+
+ $this->num_entries++;
+ }
+
+ /**
+ * Public interface to create a directory in the archive.
+ * @access public
+ * @param string $name directory name
+ * @param string $timestamp time of creation, default=''
+ * @see $_base_path in include/vitals.inc.php
+ * @see priv_add_dir() in include/zipfile.class.php
+ * @author Joel Kronenberg
+ */
+ function create_dir($name, $timestamp='') {
+ $name = trim($name);
+
+ if (substr($name, -1) != '/') {
+ /* add the trailing slash */
+ $name .= '/';
+ }
+
+ $this->priv_add_dir($name, $timestamp = '');
+ }
+
+ /**
+ * Adds a file to the archive.
+ * @access public
+ * @param string $file_data file contents
+ * @param string $name name of file in archive (add path if your want)
+ * @param string $timestamp time of creation, default=''
+ * @see $_base_path in include/vitals.inc.php
+ * @see priv_add_dir() in include/zipfile.class.php
+ * @author Joel Kronenberg
+ */
+ function add_file($file_data, $name, $timestamp = '') {
+ $name = str_replace("\\", "/", $name);
+ $crc = crc32($file_data);
+ $uncompressed_size = strlen($file_data);
+ $file_data = substr(gzcompress($file_data, 9), 2, -4);
+ $compressed_size = strlen($file_data);
+ $old_offset = strlen($this->files_data);
+
+ /* local file header */
+ $local_file_header = "\x50\x4b\x03\x04"; // local file header signature 4 bytes (0x04034b50)
+ $local_file_header .= "\x14\x00"; // ver needed to extract // version needed to extract 2 bytes
+ $local_file_header .= "\x00\x00"; // gen purpose bit flag // general purpose bit flag 2 bytes
+ $local_file_header .= "\x08\x00"; // compression method // compression method 2 bytes
+ $local_file_header .= "\x00\x00\x00\x00"; // last mod time and date // last mod file time 2 bytes & last mod file date 2 bytes
+ $local_file_header .= pack("V",$crc); // crc32 // crc-32 4 bytes
+ $local_file_header .= pack("V",$compressed_size); //compressed filesize // compressed size 4 bytes
+ $local_file_header .= pack("V",$uncompressed_size); //uncompressed filesize // uncompressed size 4 bytes
+ $local_file_header .= pack("v", strlen($name) ); //length of filename // file name length 2 bytes
+ $local_file_header .= "\x00\x00"; //extra field length // extra field length 2 bytes
+ $local_file_header .= $name; // file name (variable size) & extra field (variable size)
+ /* end of local file header */
+
+ $this->files_data .= $local_file_header . $file_data; // . $data_descriptor;;
+
+ /* create the central directory */
+ $central_directory = '';
+ if ($timestamp) {
+ $v_date = getdate($timestamp);
+ } else {
+ $v_date = getdate();
+ }
+ $time = ($v_date['hours']<<11) + ($v_date['minutes']<<5) + $v_date['seconds']/2;
+ $date = (($v_date['year']-1980)<<9) + ($v_date['mon']<<5) + $v_date['mday'];
+
+ // now add to central directory record
+ $central_directory = "\x50\x4b\x01\x02"; // central file header signature 4 bytes (0x02014b50)
+ $central_directory .="\x14\x00"; // version made by // version made by 2 bytes
+ $central_directory .="\x14\x00"; // version needed to extract // version needed to extract 2 bytes
+ $central_directory .="\x00\x00"; // gen purpose bit flag // general purpose bit flag 2 bytes
+ $central_directory .="\x08\x00"; // compression method // compression method 2 bytes
+ $central_directory .= pack("v",$time); // time // last mod file time 2 bytes
+ $central_directory .= pack("v",$date); // date // last mod file date 2 bytes
+ $central_directory .= pack("V",$crc); // crc32 // crc-32 4 bytes
+ $central_directory .= pack("V",$compressed_size); //compressed filesize // compressed size 4 bytes
+ $central_directory .= pack("V",$uncompressed_size); //uncompressed filesize // uncompressed size 4 bytes
+ $central_directory .= pack("v", strlen($name) ); //length of filename // file name length 2 bytes
+ $central_directory .= "\x00\x00"; //extra field length // extra field length 2 bytes
+ $central_directory .= "\x00\x00"; //file comment length // file comment length 2 bytes
+ $central_directory .= "\x00\x00"; //disk number start // disk number start 2 bytes
+ $central_directory .= "\x00\x00"; //internal file attributes // internal file attributes 2 bytes
+ $central_directory .= pack("V", 32); //external file attributes - 'archive' bit set // external file attributes 4 bytes
+ $central_directory .= pack("V", $old_offset);
+
+ $central_directory .= $name; // file name (variable size)
+
+ $this->central_directory_headers .= $central_directory;
+
+ $this->num_entries++;
+ }
+
+ /**
+ * Closes archive, sets $is_closed to true
+ * @access public
+ * @param none
+ * @author Joel Kronenberg
+ */
+ function close() {
+ $this->files_data .= $this->central_directory_headers . "\x50\x4b\x05\x06\x00\x00\x00\x00" .
+ pack("v", $this->num_entries). // total # of entries "on this disk"
+ pack("v", $this->num_entries). // total # of entries overall
+ pack("V", strlen($this->central_directory_headers)). // size of central dir
+ pack("V", strlen($this->files_data)). // offset to start of central dir
+ "\x00\x00";
+
+ unset($this->central_directory_headers);
+ unset($this->num_entries);
+
+ $this->zip_file =& $this->files_data;
+ $this->is_closed = true;
+ }
+
+ /**
+ * Gets size of new archive
+ * Only call this after calling close() - will return false if the zip wasn't close()d yet
+ * @access public
+ * @return int size of file
+ * @author Joel Kronenberg
+ */
+ function get_size() {
+ if (!$this->is_closed) {
+ return false;
+ }
+ return strlen($this->zip_file);
+ }
+
+
+ /**
+ * Returns binary file
+ * @access public
+ * @see get_size() in include/classes/zipfile.class.php
+ * @author Joel Kronenberg
+ */
+ function get_file() {
+ if (!$this->is_closed) {
+ $this->close();
+ }
+ return $this->zip_file;
+ }
+
+ /**
+ * Writes the file to disk.
+ * Similar to get_file(), but instead of returning the file, it saves it to disk.
+ * @access public
+ * @author Joel Kronenberg
+ * @param $file The full path and file name of the destination file.
+ */
+ function write_file($file) {
+ if (!$this->is_closed) {
+ $this->close();
+ }
+ if (function_exists('file_put_contents')) {
+ file_put_contents($file, $this->zip_file);
+ } else {
+ $fp = fopen($file, 'wb+');
+ fwrite($fp, $this->zip_file);
+ fclose($fp);
+ }
+ }
+
+
+ /**
+ * Outputs the file - sends headers to browser to force download
+ * Only call this after calling close() - will return false if the zip wasn't close()d yet
+ * @access public
+ * @see get_size() in include/classes/zipfile.class.php
+ * @author Joel Kronenberg
+ */
+ function send_file($file_name) {
+ if (!$this->is_closed) {
+ $this->close();
+ }
+ $file_name = str_replace(array('"', '<', '>', '|', '?', '*', ':', '/', '\\'), '', $file_name);
+
+ header('Content-Type: application/x-zip');
+ header('Content-transfer-encoding: binary');
+ header('Content-Disposition: attachment; filename="'.htmlspecialchars($file_name).'.zip"');
+ header('Expires: 0');
+ header('Cache-Control: must-revalidate, post-check=0, pre-check=0');
+ header('Pragma: public');
+ header('Content-Length: '.$this->get_size());
+
+ echo $this->get_file();
+
+ exit;
+ }
+}
+
+?>
\ No newline at end of file
\r
} else { //disable, clear directory and delete theme from db\r
\r
- require(AT_INCLUDE_PATH.'../mods/_core/file_manager/filemanager.inc.php'); /* for clr_dir() */\r
+ require_once(AT_INCLUDE_PATH.'../mods/_core/file_manager/filemanager.inc.php'); /* for clr_dir() */\r
if ($status != 0) {\r
disable_theme($theme_dir);\r
$msg->deleteFeedback('THEME_DISABLED');\r
admin_authenticate(AT_ADMIN_PRIV_BACKUPS);
require(AT_INCLUDE_PATH.'../mods/_core/backups/classes/Backup.class.php');
-require(AT_INCLUDE_PATH.'../mods/_core/file_manager/filemanager.inc.php');
+require_once(AT_INCLUDE_PATH.'../mods/_core/file_manager/filemanager.inc.php');
if (isset($_POST['backup_id'])) {
$ids = explode('_', $_POST['backup_id']);
require(AT_INCLUDE_PATH.'vitals.inc.php');
admin_authenticate(AT_ADMIN_PRIV_BACKUPS);
-require(AT_INCLUDE_PATH.'../mods/_core/file_manager/filemanager.inc.php');
+require_once(AT_INCLUDE_PATH.'../mods/_core/file_manager/filemanager.inc.php');
require(AT_INCLUDE_PATH.'../mods/_core/backups/classes/Backup.class.php');
$page = 'backups';
authenticate(AT_PRIV_ADMIN);
require(AT_INCLUDE_PATH.'../mods/_core/backups/classes/Backup.class.php');
-require(AT_INCLUDE_PATH.'../mods/_core/file_manager/filemanager.inc.php');
+require_once(AT_INCLUDE_PATH.'../mods/_core/file_manager/filemanager.inc.php');
if (isset($_POST['restore'], $_POST['backup_id'])) {
header('Location: restore.php?backup_id=' . $_POST['backup_id']);
authenticate(AT_PRIV_ADMIN);
require(AT_INCLUDE_PATH.'../mods/_core/backups/classes/Backup.class.php');
-require(AT_INCLUDE_PATH.'../mods/_core/file_manager/filemanager.inc.php');
+require_once(AT_INCLUDE_PATH.'../mods/_core/file_manager/filemanager.inc.php');
$Backup = new Backup($db, $_SESSION['course_id']);
$get_related_glossary = true;
require(AT_INCLUDE_PATH.'vitals.inc.php');
require(AT_INCLUDE_PATH.'lib/tinymce.inc.php');
-require(AT_INCLUDE_PATH.'../mods/_core/file_manager/filemanager.inc.php');
+require_once(AT_INCLUDE_PATH.'../mods/_core/file_manager/filemanager.inc.php');
$cid = intval($_REQUEST['cid']);
if (is_array($word)) {
/* update $_POST['glossary_defs'] with any new/changed terms */
for($i=0; $i<$num_terms; $i++) {
- $word[$i] = $word[$i];
+ $word[$i] = htmlentities_utf8($word[$i]);
if (!isset($_POST['glossary_defs'][$word[$i]])) {
$_POST['glossary_defs'][$word[$i]] = $glossary[$word[$i]];
}
if (is_array($_POST['glossary_defs']) && ($current_tab != 2)) {
foreach($_POST['glossary_defs'] as $w => $d) {
+
/* this term still exists in the content */
if (!in_array($w, $word)) {
unset($_POST['glossary_defs'][$w]);
define('AT_INCLUDE_PATH', '../../../include/');
require(AT_INCLUDE_PATH.'vitals.inc.php');
-require(AT_INCLUDE_PATH.'../mods/_core/file_manager/filemanager.inc.php');
+require_once(AT_INCLUDE_PATH.'../mods/_core/file_manager/filemanager.inc.php');
global $db;
\r
define('AT_INCLUDE_PATH', '../../../include/');\r
require(AT_INCLUDE_PATH.'vitals.inc.php');\r
-require(AT_INCLUDE_PATH.'../mods/_core/file_manager/filemanager.inc.php');\r
+require_once(AT_INCLUDE_PATH.'../mods/_core/file_manager/filemanager.inc.php');\r
\r
\r
if (!authenticate(AT_PRIV_FILES,AT_PRIV_RETURN)) {\r
define('AT_INCLUDE_PATH', '../../../include/');
require(AT_INCLUDE_PATH.'vitals.inc.php');
-require(AT_INCLUDE_PATH.'../mods/_core/file_manager/filemanager.inc.php');
+require_once(AT_INCLUDE_PATH.'../mods/_core/file_manager/filemanager.inc.php');
if ((isset($_REQUEST['popup']) && $_REQUEST['popup']) &&
(!isset($_REQUEST['framed']) || !$_REQUEST['framed'])) {
define('AT_INCLUDE_PATH', '../../../include/');
require(AT_INCLUDE_PATH.'vitals.inc.php');
-require(AT_INCLUDE_PATH.'../mods/_core/file_manager/filemanager.inc.php');
+require_once(AT_INCLUDE_PATH.'../mods/_core/file_manager/filemanager.inc.php');
if (!authenticate(AT_PRIV_FILES,AT_PRIV_RETURN)) {
authenticate(AT_PRIV_CONTENT);
define('AT_INCLUDE_PATH', '../../../include/');
require(AT_INCLUDE_PATH.'vitals.inc.php');
-require(AT_INCLUDE_PATH.'../mods/_core/file_manager/filemanager.inc.php');
+require_once(AT_INCLUDE_PATH.'../mods/_core/file_manager/filemanager.inc.php');
if (!authenticate(AT_PRIV_FILES,AT_PRIV_RETURN)) {
authenticate(AT_PRIV_CONTENT);
define('AT_INCLUDE_PATH', '../../../include/');
require(AT_INCLUDE_PATH.'vitals.inc.php');
-require(AT_INCLUDE_PATH.'../mods/_core/file_manager/filemanager.inc.php');
+require_once(AT_INCLUDE_PATH.'../mods/_core/file_manager/filemanager.inc.php');
if (!authenticate(AT_PRIV_FILES,AT_PRIV_RETURN)) {
authenticate(AT_PRIV_CONTENT);
define('AT_INCLUDE_PATH', '../../../include/');
require(AT_INCLUDE_PATH.'vitals.inc.php');
-require(AT_INCLUDE_PATH.'../mods/_core/file_manager/filemanager.inc.php');
+require_once(AT_INCLUDE_PATH.'../mods/_core/file_manager/filemanager.inc.php');
if (!authenticate(AT_PRIV_FILES,AT_PRIV_RETURN)) {
authenticate(AT_PRIV_CONTENT);
define('AT_INCLUDE_PATH', '../../../include/');
require(AT_INCLUDE_PATH.'vitals.inc.php');
require(AT_INCLUDE_PATH.'classes/pclzip.lib.php');
-require(AT_INCLUDE_PATH.'../mods/_core/file_manager/filemanager.inc.php');
+require_once(AT_INCLUDE_PATH.'../mods/_core/file_manager/filemanager.inc.php');
if (!authenticate(AT_PRIV_FILES,AT_PRIV_RETURN)) {
authenticate(AT_PRIV_CONTENT);
define('AT_INCLUDE_PATH', '../../../include/');
require(AT_INCLUDE_PATH.'vitals.inc.php');
-require(AT_INCLUDE_PATH.'../mods/_core/file_manager/filemanager.inc.php'); /* for clr_dir() and preImportCallBack and dirsize() */
+require_once(AT_INCLUDE_PATH.'../mods/_core/file_manager/filemanager.inc.php'); /* for clr_dir() and preImportCallBack and dirsize() */
require(AT_INCLUDE_PATH.'classes/pclzip.lib.php');
require(AT_INCLUDE_PATH.'../mods/_core/imsqti/lib/qti.inc.php');
require(AT_INCLUDE_PATH.'../mods/_core/imsqti/classes/QTIImport.class.php');
if (!$msg->containsErrors())
{
- require(AT_INCLUDE_PATH.'../mods/_core/file_manager/filemanager.inc.php');
+ require_once(AT_INCLUDE_PATH.'../mods/_core/file_manager/filemanager.inc.php');
if (!clr_dir(AT_MODULE_PATH . $this->_directoryName))
$msg->addError(array('MODULE_UNINSTALL', '<li>'.AT_MODULE_PATH . $this->_directoryName.' can not be removed. Please manually remove it.</li>'));
require(AT_INCLUDE_PATH.'vitals.inc.php');
admin_authenticate(AT_ADMIN_PRIV_ADMIN);
-require(AT_INCLUDE_PATH.'../mods/_core/file_manager/filemanager.inc.php');
+require_once(AT_INCLUDE_PATH.'../mods/_core/file_manager/filemanager.inc.php');
$dir_name = str_replace(array('.','..'), '', $_GET['mod_dir']);
require (AT_INCLUDE_PATH.'vitals.inc.php');
admin_authenticate(AT_ADMIN_PRIV_ADMIN);
require(AT_INCLUDE_PATH.'../mods/_core/modules/classes/ModuleListParser.class.php');
-require(AT_INCLUDE_PATH.'../mods/_core/file_manager/filemanager.inc.php');
+require_once(AT_INCLUDE_PATH.'../mods/_core/file_manager/filemanager.inc.php');
// delete all folders and files in $dir
function clear_dir($dir)
admin_authenticate(AT_ADMIN_PRIV_ADMIN);
require(AT_INCLUDE_PATH.'../mods/_core/modules/classes/ModuleParser.class.php');
-require(AT_INCLUDE_PATH.'../mods/_core/file_manager/filemanager.inc.php');
+require_once(AT_INCLUDE_PATH.'../mods/_core/file_manager/filemanager.inc.php');
// module content folder
$module_content_folder = AT_CONTENT_DIR . "module/";
header('Location: ../../courses/admin/courses.php');
exit;
} else if (isset($_POST['step']) && ($_POST['step'] == 2) && isset($_POST['submit_yes'])) {
- require(AT_INCLUDE_PATH.'../mods/_core/file_manager/filemanager.inc.php');
+ require_once(AT_INCLUDE_PATH.'../mods/_core/file_manager/filemanager.inc.php');
require(AT_INCLUDE_PATH.'../mods/_core/properties/lib/delete_course.inc.php');
delete_course($course, $entire_course = true, $rel_path = '../'); // delete the course
header('Location: '.AT_BASE_HREF.'mods/_core/properties/course_properties.php');
exit;
} else if (isset($_POST['step']) && ($_POST['step'] == 2) && isset($_POST['submit_yes'])) {
- require(AT_INCLUDE_PATH.'../mods/_core/file_manager/filemanager.inc.php');
+ require_once(AT_INCLUDE_PATH.'../mods/_core/file_manager/filemanager.inc.php');
require(AT_INCLUDE_PATH.'../mods/_core/properties/lib/delete_course.inc.php');
delete_course($_SESSION['course_id'], $entire_course = true); // delete the course
}
function add_update_course($_POST, $isadmin = FALSE) {
- require(AT_INCLUDE_PATH.'../mods/_core/file_manager/filemanager.inc.php');
+ require_once(AT_INCLUDE_PATH.'../mods/_core/file_manager/filemanager.inc.php');
global $addslashes;
global $db;
// 1. define relative path to `include` directory:\r
define('AT_INCLUDE_PATH', '../../../include/');\r
require (AT_INCLUDE_PATH . 'vitals.inc.php');\r
-require(AT_INCLUDE_PATH.'../mods/_core/file_manager/filemanager.inc.php');\r
+require_once(AT_INCLUDE_PATH.'../mods/_core/file_manager/filemanager.inc.php');\r
require (AT_INCLUDE_PATH . 'classes/pclzip.lib.php');\r
require (AT_INCLUDE_PATH . '../mods/_core/themes/classes/ThemeParser.class.php');\r
admin_authenticate(AT_ADMIN_PRIV_THEMES);\r
require (AT_INCLUDE_PATH.'vitals.inc.php');
admin_authenticate(AT_ADMIN_PRIV_ADMIN);
require(AT_INCLUDE_PATH.'../mods/_core/themes/classes/ThemeListParser.class.php');
-require(AT_INCLUDE_PATH.'../mods/_core/file_manager/filemanager.inc.php');
+require_once(AT_INCLUDE_PATH.'../mods/_core/file_manager/filemanager.inc.php');
// delete all folders and files in $dir
function clear_dir($dir)
\r
} else { //disable, clear directory and delete theme from db\r
\r
- require(AT_INCLUDE_PATH.'../mods/_core/file_manager/filemanager.inc.php'); /* for clr_dir() */\r
+ require_once(AT_INCLUDE_PATH.'../mods/_core/file_manager/filemanager.inc.php'); /* for clr_dir() */\r
if ($status != 0) {\r
disable_theme($theme_dir);\r
$msg->deleteFeedback('THEME_DISABLED');\r
require(AT_INCLUDE_PATH.'vitals.inc.php');
admin_authenticate(AT_ADMIN_PRIV_ADMIN);
-require(AT_INCLUDE_PATH.'../mods/_core/file_manager/filemanager.inc.php');
+require_once(AT_INCLUDE_PATH.'../mods/_core/file_manager/filemanager.inc.php');
require(AT_INCLUDE_PATH . '../mods/_core/themes/classes/ThemeParser.class.php');
// theme content folder
define('AT_INCLUDE_PATH', '../../../include/');
require(AT_INCLUDE_PATH.'vitals.inc.php');
-require(AT_INCLUDE_PATH.'../mods/_core/file_manager/filemanager.inc.php'); // for get_human_size()
+require_once(AT_INCLUDE_PATH.'../mods/_core/file_manager/filemanager.inc.php'); // for get_human_size()
require(AT_INCLUDE_PATH.'../mods/_standard/file_storage/file_storage.inc.php');
// check folders and files id
\r
define('AT_INCLUDE_PATH', '../../../include/');\r
require(AT_INCLUDE_PATH.'vitals.inc.php');\r
-require(AT_INCLUDE_PATH.'../mods/_core/file_manager/filemanager.inc.php'); // for get_human_size()\r
+require_once(AT_INCLUDE_PATH.'../mods/_core/file_manager/filemanager.inc.php'); // for get_human_size()\r
require(AT_INCLUDE_PATH.'../mods/_standard/file_storage/file_storage.inc.php');\r
\r
$owner_type = abs($_REQUEST['ot']);\r
* @author Cindy Qi Li\r
*/\r
function clear_dir($dir) {\r
- require(AT_INCLUDE_PATH.'../mods/_core/file_manager/filemanager.inc.php');\r
+ require_once(AT_INCLUDE_PATH.'../mods/_core/file_manager/filemanager.inc.php');\r
\r
if(!$opendir = @opendir($dir)) {\r
return false;\r
// $Id: import_test.php 9081 2010-01-13 20:26:03Z cindy $
define('AT_INCLUDE_PATH', '../../../include/');
require(AT_INCLUDE_PATH.'vitals.inc.php');
-require(AT_INCLUDE_PATH.'../mods/_core/file_manager/filemanager.inc.php'); /* for clr_dir() and preImportCallBack and dirsize() */
+require_once(AT_INCLUDE_PATH.'../mods/_core/file_manager/filemanager.inc.php'); /* for clr_dir() and preImportCallBack and dirsize() */
require(AT_INCLUDE_PATH.'../mods/_core/imsqti/lib/qti.inc.php');
require(AT_INCLUDE_PATH.'classes/pclzip.lib.php');
//require(AT_INCLUDE_PATH.'classes/QTI/QTIParser.class.php');
define('AT_INCLUDE_PATH', '../../../include/');
require(AT_INCLUDE_PATH.'vitals.inc.php');
-require(AT_INCLUDE_PATH.'../mods/_core/file_manager/filemanager.inc.php'); /* for clr_dir() and preImportCallBack and dirsize() */
+require_once(AT_INCLUDE_PATH.'../mods/_core/file_manager/filemanager.inc.php'); /* for clr_dir() and preImportCallBack and dirsize() */
require(AT_INCLUDE_PATH.'../mods/_core/imsqti/lib/qti.inc.php');
require(AT_INCLUDE_PATH.'classes/pclzip.lib.php');
//require(AT_INCLUDE_PATH.'classes/QTI/QTIParser.class.php');