Exemple #1
0
 function zipFiles($zipname, $files)
 {
     $zipfile = new zipfile();
     //	        $zipfile->add_dir("files/");
     for ($f = 0; $f < count($files); $f++) {
         $filename = $files[$f][0];
         $filedata = $files[$f][1];
         $zipfile->add_file($filedata, $filename);
     }
     File::throwFile($zipname, $zipfile->file());
 }
Exemple #2
0
        $file_extension = $regs[2];
        $file['file_name'] = $file_name . ($size ? "_" . $size : "") . "." . $file_extension;
        $file['file_path'] = is_local_file($image_row['image_media_file']) ? dirname($image_row['image_media_file']) . "/" . $file['file_name'] : MEDIA_PATH . "/" . $image_row['cat_id'] . "/" . $file['file_name'];
    }
    if ($user_info['user_level'] != ADMIN) {
        $sql = "UPDATE " . IMAGES_TABLE . "\n            SET image_downloads = image_downloads + 1\n            WHERE image_id = {$image_id}";
        $site_db->query($sql);
    }
    if (!empty($file['file_path'])) {
        @set_time_limit(120);
        if ($remote_url) {
            redirect($file['file_path']);
        }
        if ($action == "zip" && !preg_match("/\\.zip\$/i", $file['file_name']) && function_exists("gzcompress") && function_exists("crc32")) {
            include ROOT_PATH . "includes/zip.php";
            $zipfile = new zipfile();
            $zipfile->add_file(file_get_contents($file['file_path']), $file['file_name']);
            $zipfile->send(get_file_name($file['file_name']) . ".zip");
        } else {
            send_file($file['file_name'], $file['file_path']);
        }
        exit;
    } else {
        echo $lang['download_error'] . "\n<!-- EMPTY FILE PATH //-->";
        exit;
    }
} else {
    echo $lang['download_error'] . "\n<!-- NO ACTION SPECIFIED //-->";
    exit;
}
exit;
Exemple #3
0
 function create($description)
 {
     global $addslashes, $moduleFactory;
     if ($this->getNumAvailable() >= AT_COURSE_BACKUPS) {
         return FALSE;
     }
     $timestamp = time();
     $zipfile = new zipfile();
     $package_identifier = VERSION . "\n\n\n" . 'Do not change the first line of this file it contains the ATutor version this backup was created with.';
     $zipfile->add_file($package_identifier, 'atutor_backup_version', $timestamp);
     // backup course properties. ONLY BANNER FOR NOW.
     require_once AT_INCLUDE_PATH . 'classes/CSVExport.class.php';
     $CSVExport = new CSVExport();
     $now = time();
     $sql = 'SELECT banner 
           FROM ' . TABLE_PREFIX . 'courses 
          WHERE course_id=' . $this->course_id;
     $properties = $CSVExport->export($sql, $course_id);
     $zipfile->add_file($properties, 'properties.csv', $now);
     // backup modules
     $modules = $moduleFactory->getModules(AT_MODULE_STATUS_ENABLED | AT_MODULE_STATUS_DISABLED);
     $keys = array_keys($modules);
     foreach ($keys as $module_name) {
         $module =& $modules[$module_name];
         $module->backup($this->course_id, $zipfile);
     }
     $zipfile->close();
     $system_file_name = md5($timestamp);
     if (!is_dir(AT_BACKUP_DIR)) {
         @mkdir(AT_BACKUP_DIR);
     }
     if (!is_dir(AT_BACKUP_DIR . $this->course_id)) {
         @mkdir(AT_BACKUP_DIR . $this->course_id);
     }
     $zipfile->write_file(AT_BACKUP_DIR . $this->course_id . DIRECTORY_SEPARATOR . $system_file_name . '.zip');
     $row['description'] = $addslashes($description);
     $row['contents'] = addslashes(serialize($table_counters));
     $row['system_file_name'] = $system_file_name;
     $row['file_size'] = $zipfile->get_size();
     $row['file_name'] = $this->generateFileName();
     $this->add($row);
     return TRUE;
 }
 function process($file)
 {
     @xtc_set_time_limit(0);
     require DIR_FS_CATALOG . DIR_WS_CLASSES . 'xtcPrice.php';
     $xtPrice = new xtcPrice($_POST['currencies'], $_POST['status']);
     $schema = 'artikelid;hersteller;herstellernummer;bezeichnung;kategorie;beschreibung_kurz;beschreibung_lang;bild_klein;deeplink;preis_val;product_ean;' . 'lagerstand;lieferzeit;vkat;vkat_ausland1a;vkde;vkde_ausland1;freeamount' . "\n";
     # added new fields by geizhals
     $export_query = xtc_db_query("SELECT\n                                           p.products_id,\n                                           pd.products_name,\n                                           pd.products_description,pd.products_short_description,\n                                           p.products_model,p.products_ean,\n                                           p.products_image,\n                                           p.products_price,\n                                           p.products_status,\n                                           p.products_date_available,\n                                           p.products_shippingtime,\n                                           p.products_discount_allowed,\n                                           pd.products_meta_keywords,\n                                           p.products_tax_class_id,\n                                           p.products_date_added,\n                                           m.manufacturers_name,\n                                           p.products_quantity,\n                                           p.products_weight\n                                    FROM\n                                           " . TABLE_PRODUCTS . " p LEFT JOIN\n                                           " . TABLE_MANUFACTURERS . " m\n                                        ON p.manufacturers_id = m.manufacturers_id LEFT JOIN\n                                           " . TABLE_PRODUCTS_DESCRIPTION . " pd\n                                        ON p.products_id = pd.products_id AND\n                                           pd.language_id = '" . $_SESSION['languages_id'] . "' LEFT JOIN\n                                           " . TABLE_SPECIALS . " s\n                                        ON p.products_id = s.products_id\n                                     WHERE p.products_status = 1\n                                     ORDER BY\n                                           p.products_date_added DESC,\n                                           pd.products_name");
     # added p.products_quantity, p.products_weight to select by geizhals
     while ($products = xtc_db_fetch_array($export_query)) {
         $products_price = $xtPrice->xtcGetPrice($products['products_id'], $format = false, 1, $products['products_tax_class_id'], '');
         // get product categorie
         $categorie_query = xtc_db_query("SELECT\n                                              categories_id\n                                         FROM " . TABLE_PRODUCTS_TO_CATEGORIES . "\n                                        WHERE products_id='" . $products['products_id'] . "'");
         while ($categorie_data = xtc_db_fetch_array($categorie_query)) {
             $categories = $categorie_data['categories_id'];
         }
         ################## added by geizhals
         $shipping_query = xtc_db_query("SELECT\n                                             shipping_status_name\n                                        FROM " . TABLE_SHIPPING_STATUS . "\n                                       WHERE shipping_status_id=" . $products['products_shippingtime'] . " AND language_id=" . $_SESSION['languages_id']);
         $shipping_data = xtc_db_fetch_array($shipping_query);
         $shipping[] = $shipping_data['shipping_status_name'];
         $vkat_query = xtc_db_query("select configuration_value as vkat from configuration where configuration_key='MODULE_SHIPPING_AP_COST_8'");
         $vkat_data = xtc_db_fetch_array($vkat_query);
         $vkat[] = $vkat_data['vkat'];
         $vkat_ausland_query = xtc_db_query("select configuration_value as vkat from configuration where configuration_key='MODULE_SHIPPING_AP_COST_1'");
         $vkat_ausland_data = xtc_db_fetch_array($vkat_ausland_query);
         $vkat_ausland[] = $vkat_ausland_data['vkat'];
         $vkde_query = xtc_db_query("select configuration_value as vkde from configuration where configuration_key='MODULE_SHIPPING_DP_COST_6'");
         $vkde_data = xtc_db_fetch_array($vkde_query);
         $vkde[] = $vkde_data['vkde'];
         $vkde_ausland_query = xtc_db_query("select configuration_value as vkde from configuration where configuration_key='MODULE_SHIPPING_DP_COST_1'");
         $vkde_ausland_data = xtc_db_fetch_array($vkde_ausland_query);
         $vkde_ausland[] = $vkde_ausland_data['vkde'];
         $free_query = xtc_db_query("select configuration_value as freeamount from configuration where configuration_key='MODULE_SHIPPING_FREEAMOUNT_AMOUNT'");
         $free_data = xtc_db_fetch_array($free_query);
         $free[] = $free_data['freeamount'];
         ################## end added by geizhals
         // remove trash
         $products_description = strip_tags($products['products_description']);
         $products_description = str_replace("<br>", " ", $products_description);
         $products_description = str_replace("<br />", " ", $products_description);
         $products_description = str_replace(";", ", ", $products_description);
         $products_description = str_replace("'", ", ", $products_description);
         $products_description = str_replace("\n", " ", $products_description);
         $products_description = str_replace("\r", " ", $products_description);
         $products_description = str_replace("\t", " ", $products_description);
         $products_description = str_replace("\v", " ", $products_description);
         $products_description = str_replace("&quot,", " \"", $products_description);
         $products_description = str_replace("&qout,", " \"", $products_description);
         $products_description = str_replace(chr(13), " ", $products_description);
         $products_short_description = strip_tags($products['products_short_description']);
         $products_short_description = str_replace("<br>", " ", $products_short_description);
         $products_short_description = str_replace("<br />", " ", $products_short_description);
         $products_short_description = str_replace(";", ", ", $products_short_description);
         $products_short_description = str_replace("'", ", ", $products_short_description);
         $products_short_description = str_replace("\n", " ", $products_short_description);
         $products_short_description = str_replace("\r", " ", $products_short_description);
         $products_short_description = str_replace("\t", " ", $products_short_description);
         $products_short_description = str_replace("\v", " ", $products_short_description);
         $products_short_description = str_replace("&quot,", " \"", $products_short_description);
         $products_short_description = str_replace("&qout,", " \"", $products_short_description);
         $products_short_description = str_replace(chr(13), " ", $products_short_description);
         $products_short_description = substr($products_short_description, 0, 255);
         $products_description = substr($products_description, 0, 65536);
         $cat = $this->buildCAT($categories);
         if ($products['products_image'] != '') {
             $image = HTTP_CATALOG_SERVER . DIR_WS_CATALOG_THUMBNAIL_IMAGES . $products['products_image'];
         } else {
             $image = '';
         }
         //create content
         $schema .= $products['products_id'] . ";" . $products['manufacturers_name'] . ";" . $products['products_model'] . ";" . $products['products_name'] . ";" . substr($cat, 0, strlen($cat) - 2) . ";" . $products_short_description . ";" . $products_description . ";" . $image . ";" . HTTP_CATALOG_SERVER . DIR_WS_CATALOG . 'product_info.php?' . $_POST['campaign'] . xtc_product_link($products['products_id'], $products['products_name']) . ";" . number_format($products_price, 2, '.', '') . ";" . $products['products_ean'] . ";" . $products['products_quantity'] . ";" . xtc_get_shipping_status_name($products['products_shippingtime']) . ";" . $this->getShipCost($vkat[0], $products['products_weight']) . ";" . $this->getShipCost($vkat_ausland[0], $products['products_weight']) . ";" . $this->getShipCost($vkde[0], $products['products_weight']) . ";" . $this->getShipCost($vkde_ausland[0], $products['products_weight']) . ";" . $free[0] . "\n";
     }
     // create File
     $fp = fopen(DIR_FS_DOCUMENT_ROOT . 'export/' . $file, "w+");
     fputs($fp, $schema);
     fclose($fp);
     ################## added by geizhals
     // zip file
     $zipfile = new zipfile();
     $filedata = implode("", file(DIR_FS_DOCUMENT_ROOT . 'export/' . $file));
     $zipfile->add_file($filedata, $file);
     header("Content-type: application/octet-stream");
     header("Content-disposition: attachment; filename=zipfile.zip");
     $fp = fopen(DIR_FS_DOCUMENT_ROOT . 'export/' . $file . '.zip', "w+");
     fputs($fp, $zipfile->file());
     fclose($fp);
     ################## end added by geizhals
     switch ($_POST['export']) {
         case 'yes':
             // send File to Browser
             $extension = substr($file, -3);
             $fp = fopen(DIR_FS_DOCUMENT_ROOT . 'export/' . $file, "rb");
             $buffer = fread($fp, filesize(DIR_FS_DOCUMENT_ROOT . 'export/' . $file));
             fclose($fp);
             header('Content-type: application/x-octet-stream');
             header('Content-disposition: attachment; filename=' . $file);
             echo $buffer;
             exit;
             break;
     }
 }
         $str_applilcation = str_replace("[script_refund_policy]", $script_refund_policy, $str_applilcation);
         $str_applilcation = str_replace("[package_description]", $package_description, $str_applilcation);
     }
     $str_applilcation = str_replace("[company_bank]", $company_bank, $str_applilcation);
     $str_applilcation = str_replace("[beneficiary_name]", $beneficiary_name, $str_applilcation);
     $str_applilcation = str_replace("[name_on_account]", $name_on_account, $str_applilcation);
     $str_applilcation = str_replace("[bank_address]", $bank_address, $str_applilcation);
     $str_applilcation = str_replace("[bank_country]", $bank_country, $str_applilcation);
     $str_applilcation = str_replace("[bank_phone]", $bank_phone, $str_applilcation);
     $str_applilcation = str_replace("[bank_sort_code]", $bank_sort_code, $str_applilcation);
     $str_applilcation = str_replace("[bank_account_number]", $bank_account_number, $str_applilcation);
     $str_applilcation = str_replace("[bank_swift_code]", $bank_swift_code, $str_applilcation);
     $zipfile->add_dir($dir_company_name . "/");
     //$zipfile -> add_dir($dir_company_name."/Application/");
     $filedata = $str_applilcation;
     $zipfile->add_file($filedata, $dir_company_name . "/" . $str_company_name . ".html");
 }
 //print("comp. file size= ".$zipfile -> get_file_size()."<br>");
 //	print($str_company_name."<br>");
 if ($is_doc != "") {
     $myLicenceFileArray = array();
     $myArticlesFileArray = array();
     $myHistoryFileArray = array();
     $myProfessionalReferenceFileArray = array();
     //$str_qry = "select file_type, file_name from cs_uploaded_documents where user_id = $company_id and status = 'A'";
     $str_qry = "select file_type, file_name from cs_uploaded_documents where status='A' AND user_id = {$company_id}";
     if (!($show_sql = mysql_query($str_qry, $cnn_cs))) {
         print mysql_errno() . ": " . mysql_error() . "<BR>";
         print "Cannot execute query";
         print $str_qry;
         exit;
Exemple #6
0
$imsmanifest_xml .= str_replace(array('{ORGANIZATIONS}', '{GLOSSARY}', '{RESOURCES}', '{TEST_ITEMS}', '{COURSE_TITLE}'), array($organizations_str, $glossary_manifest_xml, $resources, $test_xml_items, $ims_course_title), $ims_template_xml['final']);
/* generate the vcard for the instructor/author */
$sql = "SELECT first_name, last_name, email, website, login, phone FROM %smembers WHERE member_id=%d";
$row_member = queryDB($sql, array(TABLE_PREFIX, $instructor_id), TRUE);
$vcard = new vCard();
if (count($row_member) > 0) {
    $vcard->setName($row_member['last_name'], $row_member['first_name'], $row_member['login']);
    $vcard->setEmail($row['email']);
    $vcard->setNote('Originated from an ATutor at ' . AT_BASE_HREF . '. See ATutor.ca for additional information.');
    $vcard->setURL($row['website']);
    $imsmanifest_xml = str_replace('{VCARD}', $vcard->getVCard(), $imsmanifest_xml);
} else {
    $imsmanifest_xml = str_replace('{VCARD}', '', $imsmanifest_xml);
}
/* save the imsmanifest.xml file */
$zipfile->add_file($imsmanifest_xml, 'imsmanifest.xml');
if ($glossary_xml) {
    $zipfile->create_dir('resources/GlossaryItem/');
    $zipfile->add_file($glossary_xml, 'resources/GlossaryItem/glossary.xml');
}
$zipfile->close();
// this is optional, since send_file() closes it anyway
$ims_course_title = str_replace(array(' ', ':'), '_', $ims_course_title);
/**
 * A problem here with the preg_replace below.
 * Originally was designed to remove all werid symbols to avoid file corruptions.
 * In UTF-8, all non-english chars are considered to be 'werid symbols'
 * We can still replace it as is, or add fileid to the filename to avoid these problems
 * Well then again people won't be able to tell what this file is about
 * If we are going to take out the preg_replace, some OS might not be able to understand
 * these characters and will have problems importing.
Exemple #7
0
$imsmanifest_xml .= str_replace(array('{ORGANIZATIONS}', '{RESOURCES}', '{COURSE_TITLE}'), array($organizations_str, $resources, $ims_course_title), $ims_template_xml['final']);
/* generate the vcard for the instructor/author */
$sql = "SELECT first_name, last_name, email, website, login, phone FROM %smembers WHERE member_id=%d";
$row_members = queryDB($sql, array(TABLE_PREFIX, $instructor_id), TRUE);
$vcard = new vCard();
if (count($row_members) > 0) {
    $vcard->setName($row_members['last_name'], $row_members['first_name'], $row_members['login']);
    $vcard->setEmail($row_members['email']);
    $vcard->setNote('Originated from an ATutor at ' . AT_BASE_HREF . '. See ATutor.ca for additional information.');
    $vcard->setURL($row_members['website']);
    $imsmanifest_xml = str_replace('{VCARD}', $vcard->getVCard(), $imsmanifest_xml);
} else {
    $imsmanifest_xml = str_replace('{VCARD}', '', $imsmanifest_xml);
}
/* save the imsmanifest.xml file */
$zipfile->add_file($frame, 'index.html');
$zipfile->add_file($toc_html, 'toc.html');
$zipfile->add_file($imsmanifest_xml, 'imsmanifest.xml');
$zipfile->add_file($html_mainheader, 'header.html');
$zipfile->add_file($footer, 'footer.html');
if ($glossary_xml) {
    $zipfile->add_file($glossary_xml, 'glossary.xml');
    $zipfile->add_file($glossary_html, 'glossary.html');
}
$zipfile->add_file(file_get_contents(AT_INCLUDE_PATH . '../mods/_core/imscp/include/adlcp_rootv1p2.xsd'), 'adlcp_rootv1p2.xsd');
$zipfile->add_file(file_get_contents(AT_INCLUDE_PATH . '../mods/_core/imscp/include/ims_xml.xsd'), 'ims_xml.xsd');
$zipfile->add_file(file_get_contents(AT_INCLUDE_PATH . '../mods/_core/imscp/include/imscp_rootv1p1p2.xsd'), 'imscp_rootv1p1p2.xsd');
$zipfile->add_file(file_get_contents(AT_INCLUDE_PATH . '../mods/_core/imscp/include/imsmd_rootv1p2p1.xsd'), 'imsmd_rootv1p2p1.xsd');
$zipfile->add_file(file_get_contents(AT_INCLUDE_PATH . '../mods/_core/imscp/include/ims.css'), 'ims.css');
$zipfile->add_file(file_get_contents('../../../images/logo.gif'), 'logo.gif');
$zipfile->close();
 function process_backup($user)
 {
     include_once "class_zip.php";
     if ($_REQUEST['choice'] == 'yes') {
         //CREATE A UNIX TIMESTAMP
         $stamp = time();
         $date1 = gmdate("m-d-y", $stamp);
         $date = gmdate("Y-m-d H:i:s", $stamp);
         $title = "bu_" . $date . "_" . $user->user_name . ".zip";
         //CREATE THE BACKUP OF OUR DATABASE
         $filename = "../" . $this->config->file_dir . "/tmp_{$date1}.sql";
         passthru("mysqldump --opt -h" . $this->config->db_host . " -u" . $this->config->db_user . " -p" . $this->config->db_pass . " " . $this->config->db_name . " >{$filename}");
         //
         $zipfile = new zipfile();
         //READ THE CURRENT DIRECTORY WE ARE IN
         $dir_list = $this->read_dir("../");
         for ($i = 0; $i < count($dir_list); $i++) {
             if ($dir_list[$i]['type'] == "dir") {
                 //echo $dir_list[$i]['name']."<br/>";
                 $zipfile->add_dir($dir_list[$i]['name']);
             } else {
                 if ($dir_list[$i]['type'] == "file") {
                     //echo $dir_list[$i]['name']."<br/>";
                     $zipfile->add_file(file_get_contents($dir_list[$i]['loc'], false), $dir_list[$i]['name']);
                 }
             }
         }
         //REMOVE OUR TEMP SQL FILE
         unlink($filename);
         //CREATE THE SYSTEM NAME
         $sql = "SELECT id FROM " . $this->config->db_prefix . "_files ORDER BY id DESC";
         $results = $this->db->DB_Q_C($sql);
         $total_files = mysql_fetch_array($results);
         $total_files[0]++;
         $sys_name = "file_" . $total_files[0] . ".zip";
         //CREATE THE ZIP FILE
         $fileName = "../" . $this->config->file_dir . "/backup/{$sys_name}";
         $fd = fopen($fileName, "w");
         $out = fwrite($fd, $zipfile->file());
         fclose($fd);
         //
         $sql = "INSERT INTO `" . $this->config->db_prefix . "_files` VALUES ('', '{$title}', '{$sys_name}', '../" . $this->config->file_dir . "/backup/', 'zip', 'A backup of your site.')";
         $results = $this->db->DB_Q_C($sql);
         $lastid = mysql_insert_id();
         //LOG THE ACTION
         $sql = "INSERT INTO " . $this->config->db_prefix . "_object(create_date, create_who) \r\r\n          \t\t\t   VALUES('{$date}', '{$user->user_id}')";
         $results = $this->db->DB_Q_C($sql);
         $lastobjectid = mysql_insert_id();
         $sql = "INSERT INTO " . $this->config->db_prefix . "_logs(object_id, user_id, module_id, sub_module_id, record_id, action)\r\r\n                  VALUES({$lastobjectid}, '" . $user->user_id . "', '" . $this->id . "', 1, {$lastid}, 1)";
         $results = $this->db->DB_Q_C($sql);
         //
         $ret_code = array(1, $lastid);
     } else {
         $ret_code = array(-1, 0);
     }
     return $ret_code;
 }
 function export($filename = '')
 {
     $search = array('"', "'", "", "\n", "\r", "");
     //\x08\\x09, not required
     $replace = array('\\"', "\\'", '\\0', '\\n', '\\r', '\\Z');
     // use a function to generate the ini file
     // use a diff fn to generate the sql dump
     // use the zipfile class to package the ini file and the sql dump
     $sql_dump = "INSERT INTO `languages` VALUES ('{$this->code}', '{$this->characterSet}', '{$this->direction}', '{$this->regularExpression}', '{$this->nativeName}', '{$this->englishName}', {$this->status});\r\n\r\n";
     $sql_dump .= "INSERT INTO `language_text` VALUES ";
     $sql = "SELECT * FROM %slanguage_text WHERE language_code='%s' ORDER BY variable, term";
     $rows_text = queryDB($sql, array(TABLE_PREFIX, $this->code));
     if (count($rows_text) > 0) {
         foreach ($rows_text as $row) {
             $row['text'] = str_replace($search, $replace, $row['text']);
             $row['context'] = str_replace($search, $replace, $row['context']);
             $sql_dump .= "('{$this->code}', '{$row['variable']}', '{$row['term']}', '{$row['text']}', '{$row['revised_date']}', '{$row['context']}'),\r\n";
         }
     } else {
         $this->msg->addError('LANG_EMPTY');
     }
     $sql_dump = substr($sql_dump, 0, -3) . ";";
     $readme = 'This is an ATutor language pack. Use the administrator Language section to import this language pack or manually import the contents of the SQL file into your [table_prefix]language_text table, where `table_prefix` should be replaced with your correct ATutor table prefix as defined in ./include/config.inc.php . Additional Language Packs can be found on http://atutor.ca .';
     require AT_INCLUDE_PATH . 'classes/zipfile.class.php';
     $zipfile = new zipfile();
     $zipfile->add_file($sql_dump, 'language_text.sql');
     $zipfile->add_file($readme, 'readme.txt');
     $zipfile->add_file($this->getXML(), 'language.xml');
     if ($filename) {
         $fp = fopen($filename, 'wb+');
         fwrite($fp, $zipfile->get_file(), $zipfile->get_size());
     } else {
         $version = str_replace('.', '_', VERSION);
         $zipfile->send_file('atutor_' . $version . '_' . $this->code);
     }
 }
Exemple #10
0
        return $data . $ctrldir . $this->eof_ctrl_dir . pack("v", sizeof($this->ctrl_dir)) . pack("v", sizeof($this->ctrl_dir)) . pack("V", strlen($ctrldir)) . pack("V", strlen($data)) . "";
        // .zip file comment length
    }
}
?>
 

Example Usage of the Class

<?php 
$zipfile = new zipfile();
// add the subdirectory ... important!
$zipfile->add_dir("test/");
// add the binary data stored in the string 'filedata'
//$filename = "c:\\apache\\apache\\htdocs\\projects\\companysetup\\admin\\5_SREEnew.doc";
$filename = "c:\\apache\\apache\\htdocs\\projects\\companysetup\\admin\\passports.jpg";
$handle = fopen($filename, "rb");
$contents = fread($handle, filesize($filename));
fclose($handle);
$filedata = $contents;
$zipfile->add_file($filedata, "test/passports.jpg");
// the next three lines force an immediate download of the zip file:
//header("Content-type: application/octet-stream");
//header("Content-disposition: attachment; filename=test.zip");
//echo $zipfile -> file();
// OR instead of doing that, you can write out the file to the loca disk like this:
$filename = "output.zip";
$fd = fopen($filename, "wb");
$out = fwrite($fd, $zipfile->file());
fclose($fd);
// then offer it to the user to download:
<?php

define('AT_INCLUDE_PATH', '../../../include/');
require AT_INCLUDE_PATH . 'vitals.inc.php';
//require (AT_INCLUDE_PATH.'header.inc.php');
$forum_id = $_GET['fid'];
$forum_title = $_GET['title'];
require 'forum_post.php';
require AT_INCLUDE_PATH . 'classes/zipfile.class.php';
$zipfile = new zipfile();
$zipfile->add_file(file_get_contents(AT_CONTENT_DIR . '/exported_forum.html'), 'exported_forum.html');
foreach ($filearr as $val) {
    $zipfile->add_file(file_get_contents(AT_CONTENT_DIR . '/' . $val), $val);
    unlink(AT_CONTENT_DIR . '/' . $val);
}
$zipfile->add_file(file_get_contents(AT_CONTENT_DIR . '/styles.css'), 'styles.css');
unlink(AT_CONTENT_DIR . '/styles.css');
// replaces spaces with underscores
if (strpos($forum_title, chr(32)) != false) {
    $forum_title = str_replace(chr(32), chr(95), $forum_title);
}
$zipfile->send_file($forum_title);
exit;
?>

<?php 
//require (AT_INCLUDE_PATH.'footer.inc.php');
Exemple #12
0
//$sql = "SELECT first_name, last_name, email, website, login, phone FROM ".TABLE_PREFIX."members WHERE member_id=$instructor_id";
//$result = mysql_query($sql, $db);
$usersDAO = new UsersDAO();
$row = $usersDAO->getUserByID($instructor_id);
$vcard = new vCard();
if (isset($row)) {
    $vcard->setName($row['last_name'], $row['first_name'], $row['login']);
    $vcard->setEmail($row['email']);
    $vcard->setNote('Originated from an AContent at ' . TR_BASE_HREF . '. See ATutor.ca for additional information.');
    $vcard->setURL($row['website']);
    $imsmanifest_xml = str_replace('{VCARD}', $vcard->getVCard(), $imsmanifest_xml);
} else {
    $imsmanifest_xml = str_replace('{VCARD}', '', $imsmanifest_xml);
}
/* save the imsmanifest.xml file */
$zipfile->add_file($frame, 'index.html');
$zipfile->add_file($toc_html, 'toc.html');
$zipfile->add_file($imsmanifest_xml, 'imsmanifest.xml');
$zipfile->add_file($html_mainheader, 'header.html');
// Modified by Cindy Qi Li on Jun 3, 2010
// AContent does not support glossary
/*
if ($glossary_xml) {
	$zipfile->add_file($glossary_xml,  'glossary.xml');
	$zipfile->add_file($glossary_html, 'glossary.html');
}
*/
// END OF Modified by Cindy Qi Li on Jun 3, 2010
$zipfile->add_file(file_get_contents(TR_INCLUDE_PATH . '../home/ims/include/adlcp_rootv1p2.xsd'), 'adlcp_rootv1p2.xsd');
$zipfile->add_file(file_get_contents(TR_INCLUDE_PATH . '../home/ims/include/ims_xml.xsd'), 'ims_xml.xsd');
$zipfile->add_file(file_get_contents(TR_INCLUDE_PATH . '../home/ims/include/imscp_rootv1p1p2.xsd'), 'imscp_rootv1p1p2.xsd');
            //print("comp. file size= ".$zipfile -> get_file_size()."<br>");
        }
        if (count($myProfessionalReferenceFileArray) > 0) {
            for ($i_loop = 0; $i_loop < count($myProfessionalReferenceFileArray); $i_loop++) {
                $filedata = func_read_file("../gateway/" . $_SESSION['gw_folder'] . "UserDocuments/Professional_Reference/" . $myProfessionalReferenceFileArray[$i_loop]);
                $compressed_file_size = func_get_compressed_file_size($filedata);
                if ($zipfile->get_file_size() + $compressed_file_size >= $i_max_file_size_MB) {
                    $arr_result = func_send_documents($zipfile, $str_company_name, $other_email, $str_failure_companies, $i_max_file_size_MB, $error_msg);
                    $zipfile = new zipfile();
                    $zipfile->add_dir($dir_company_name . "/Professional_Reference/");
                } else {
                    if ($i_loop == 0) {
                        $zipfile->add_dir($dir_company_name . "/Professional_Reference/");
                    }
                }
                $zipfile->add_file($filedata, $dir_company_name . "/Professional_Reference/" . $myProfessionalReferenceFileArray[$i_loop]);
            }
            //print("comp. file size= ".$zipfile -> get_file_size()."<br>");
        }
    }
    if ($zipfile->get_file_size() > 0) {
        $arr_result = func_send_documents($zipfile, $str_company_name, $other_email, $str_failure_companies, $i_max_file_size_MB, $error_msg);
    }
}
function getDirList($dirName, $i_company)
{
    $d = dir($dirName);
    $filename = "";
    while ($entry = $d->read()) {
        //echo strpos($entry,$i_company);
        if ($entry != "." && $entry != "..") {
 function export($filename = '')
 {
     //		$search  = array('"', "'", "\x00", "\x0a", "\x0d", "\x1a"); //\x08\\x09, not required
     //		$replace = array('\"', "\'", '\0', '\n', '\r', '\Z');
     // use a function to generate the ini file
     // use a diff fn to generate the sql dump
     // use the zipfile class to package the ini file and the sql dump
     global $addslashes;
     $sql_dump = "INSERT INTO `languages` VALUES ('{$this->code}', '{$this->characterSet}', '{$this->regularExpression}', '{$this->nativeName}', '{$this->englishName}', {$this->status});\r\n\r\n";
     $sql_dump .= "INSERT INTO `language_text` VALUES ";
     $languageTextDAO = new LanguageTextDAO();
     $rows = $languageTextDAO->getAllByLang($this->code);
     if (is_array($rows)) {
         foreach ($rows as $row) {
             //				$row['text']    = str_replace($search, $replace, $row['text']);
             //				$row['context'] = str_replace($search, $replace, $row['context']);
             $row['text'] = $addslashes($row['text']);
             $row['context'] = $addslashes($row['context']);
             $sql_dump .= "('{$this->code}', '{$row['variable']}', '{$row['term']}', '{$row['text']}', '{$row['revised_date']}', '{$row['context']}'),\r\n";
         }
     } else {
         $this->msg->addError('LANG_EMPTY');
         return;
     }
     $sql_dump = substr($sql_dump, 0, -3) . ";";
     $readme = 'This is an AChecker language pack. Use the administrator Language section to import this language pack or manually import the contents of the SQL file into your [table_prefix]language_text table, where `table_prefix` should be replaced with your correct AChecker table prefix as defined in ./include/config.inc.php .';
     require AC_INCLUDE_PATH . 'classes/zipfile.class.php';
     $zipfile = new zipfile();
     $zipfile->add_file($sql_dump, 'language_text.sql');
     $zipfile->add_file($readme, 'readme.txt');
     $zipfile->add_file($this->getXML(), 'language.xml');
     if ($filename) {
         $fp = fopen($filename, 'wb+');
         fwrite($fp, $zipfile->get_file(), $zipfile->get_size());
     } else {
         $version = str_replace('.', '_', VERSION);
         $zipfile->send_file('achecker_' . $version . '_' . $this->code);
     }
 }
Exemple #15
0
        $pdfcontent = $exportobj->MakePdf($xmlArr, $TagArr, $repeat, '', '', $csv, '', '', $enc);
        $pdfcontent = "<h1 align='center'>Invoice Details</h1></br>" . $pdfcontent;
        // Prints($csvcontent);exit;
        break;
}
//exit();
//$html = $exportobj->GenerateFormat($fieldArr,$dataArr,$CallFunctionArr);
$xml .= $htmlcontent;
$xml .= '</Dataroot>' . "\n";
// pr($csvcontent); exit;
// print($exportobj->output_xml($xml));exit;
ini_set('zlib.output_compression', 'Off');
$html = $exportobj->GenerateXml($xml);
// pr($html); exit;
$timeval = date('Y-m-d_H_i_s');
$zip->add_file($html, 'export_' . $timeval . '.xml');
$zip->add_file($csvcontent, 'export_' . $timeval . '.csv');
define('_MPDF_PATH', SITE_CO_PATH . 'MPDF44/');
//include(DIR_LIB . '/fpdf/mpdf.php');
include SITE_CO_PATH . "MPDF44/mpdf.php";
$mpdf = new mPDF();
//$mpdf=new mPDF('utf-8-s');
$mpdf->AddPage();
$mpdf->WriteHTML($pdfcontent);
$pdffile = $mpdf->Output('export_' . $timeval . '.pdf', 'S');
$zip->add_file($pdffile, 'export_' . $timeval . '.pdf');
//$filepath = $zip->file();
// $mime = 'application/download';
$mime = 'application/zip';
header('Content-type: ' . $mime);
header('Content-Disposition: attachment; filename=export.zip');
/** 
 * Export test 
 * @param    int        test id
 * @param    string    the test title
 * @param    ref        [OPTIONAL] zip object reference
 * @param    array    [OPTIONAL] list of already added files.
 */
function test_qti_export($tid, $test_title = '', $zipfile = null)
{
    require_once AT_INCLUDE_PATH . 'classes/zipfile.class.php';
    // for zipfile
    require_once AT_INCLUDE_PATH . 'classes/XML/XML_HTMLSax/XML_HTMLSax.php';
    // for XML_HTMLSax
    require_once AT_INCLUDE_PATH . 'lib/html_resource_parser.inc.php';
    // for get_html_resources()
    global $savant, $db, $system_courses, $languageManager, $test_zipped_files, $test_files, $use_cc;
    global $course_id;
    $course_id = $_SESSION['course_id'];
    $course_title = $_SESSION['course_title'];
    $course_language = $system_courses[$_SESSION['course_id']]['primary_language'];
    if ($course_language == '') {
        // when oauth export into Transformable
        $sql = "SELECT course_id, title, primary_language FROM " . TABLE_PREFIX . "courses\n                 WHERE course_id = (SELECT course_id FROM " . TABLE_PREFIX . "tests\n                                     WHERE test_id=" . $tid . ")";
        $result = mysql_query($sql, $db);
        $course_row = mysql_fetch_assoc($result);
        $course_language = $course_row['primary_language'];
        $course_id = $course_row['course_id'];
        $course_title = $course_row['title'];
    }
    $courseLanguage =& $languageManager->getLanguage($course_language);
    $course_language_charset = $courseLanguage->getCharacterSet();
    $imported_files;
    $zipflag = false;
    if ($zipfile == null) {
        $zipflag = true;
    }
    if ($test_zipped_files == null) {
        $test_zipped_files = array();
    }
    if ($zipflag) {
        $zipfile = new zipfile();
        $zipfile->create_dir('resources/');
        // for all the dependency files
    }
    $resources = array();
    $dependencies = array();
    //    don't want to sort it, i want the same order out.
    //    asort($question_ids);
    //TODO: Merge the following 2 sqls together.
    //Randomized or not, export all the questions that are associated with it.
    $sql = "SELECT TQ.question_id, TQA.weight FROM " . TABLE_PREFIX . "tests_questions TQ INNER JOIN " . TABLE_PREFIX . "tests_questions_assoc TQA USING (question_id) WHERE TQ.course_id={$course_id} AND TQA.test_id={$tid} ORDER BY TQA.ordering, TQA.question_id";
    $result = mysql_query($sql, $db);
    $question_ids = array();
    while (($question_row = mysql_fetch_assoc($result)) != false) {
        $question_ids[] = $question_row['question_id'];
    }
    //No questions in the test
    if (sizeof($question_ids) == 0) {
        return;
    }
    $question_ids_delim = implode(',', $question_ids);
    //$sql = "SELECT * FROM ".TABLE_PREFIX."tests_questions WHERE course_id=$_SESSION[course_id] AND question_id IN($question_ids_delim)";
    $sql = "SELECT TQ.*, TQA.weight, TQA.test_id FROM " . TABLE_PREFIX . "tests_questions TQ INNER JOIN " . TABLE_PREFIX . "tests_questions_assoc TQA USING (question_id) WHERE TQA.test_id={$tid} AND TQ.question_id IN({$question_ids_delim}) ORDER BY TQA.ordering, TQA.question_id";
    $result = mysql_query($sql, $db);
    while ($row = mysql_fetch_assoc($result)) {
        $obj = TestQuestions::getQuestion($row['type']);
        $local_xml = '';
        $local_xml = $obj->exportQTI($row, $course_language_charset, '1.2.1');
        $local_dependencies = array();
        $text_blob = implode(' ', $row);
        $local_dependencies = get_html_resources($text_blob, $course_id);
        $dependencies = array_merge($dependencies, $local_dependencies);
        $xml = $xml . "\n\n" . $local_xml;
    }
    //files that are found inside the test; used by print_organization(), to add all test files into QTI/ folder.
    $test_files = $dependencies;
    $resources[] = array('href' => 'tests_' . $tid . '.xml', 'dependencies' => array_keys($dependencies));
    $xml = trim($xml);
    //get test title
    $sql = "SELECT title, num_takes FROM " . TABLE_PREFIX . "tests WHERE test_id = {$tid}";
    $result = mysql_query($sql, $db);
    $row = mysql_fetch_array($result);
    //TODO: wrap around xml now
    $savant->assign('xml_content', $xml);
    $savant->assign('title', htmlspecialchars($row['title'], ENT_QUOTES, 'UTF-8'));
    $savant->assign('num_takes', $row['num_takes']);
    $savant->assign('use_cc', $use_cc);
    $xml = $savant->fetch('test_questions/wrapper.tmpl.php');
    $xml_filename = 'tests_' . $tid . '.xml';
    if (!$use_cc) {
        $zipfile->add_file($xml, $xml_filename);
    } else {
        $zipfile->add_file($xml, 'QTI/' . $xml_filename);
    }
    // add any dependency files:
    if (!$use_cc) {
        foreach ($dependencies as $resource => $resource_server_path) {
            //add this file in if it's not already in the zip package
            if (!in_array($resource_server_path, $test_zipped_files)) {
                $zipfile->add_file(@file_get_contents($resource_server_path), 'resources/' . $resource, filemtime($resource_server_path));
                $test_zipped_files[] = $resource_server_path;
            }
        }
    }
    if ($zipflag) {
        // construct the manifest xml
        $savant->assign('resources', $resources);
        $savant->assign('dependencies', array_keys($dependencies));
        $savant->assign('encoding', $course_language_charset);
        $savant->assign('title', $test_title);
        $savant->assign('xml_filename', $xml_filename);
        $manifest_xml = $savant->fetch('test_questions/manifest_qti_1p2.tmpl.php');
        $zipfile->add_file($manifest_xml, 'imsmanifest.xml');
        $zipfile->close();
        $filename = str_replace(array(' ', ':'), '_', $course_title . '-' . $test_title . '-' . date('Ymd'));
        $zipfile->send_file($filename);
        exit;
    }
    $return_array[$xml_filename] = array_keys($dependencies);
    return $return_array;
    //done
}
Exemple #17
0
$result = InstanciasController::Respaldar_Instancias($ids);
//Respaldar_Instancias recibe como params un array
if (strlen($result) > 0) {
    die("<html><head><meta HTTP-EQUIV='REFRESH' content='3; url=instancias.bd.php'><title>Error al descargar, perimisos</title></head><body><h1><center>" . $result . "</center></h1></body></html>");
}
$f = new zipfile();
for ($i = 0; $i < sizeof($ids); $i++) {
    //$f->add_file(file_get_contents($files[$i]), $file_id[$i] . ".sql");
    $final_path = str_replace("server", "static_content/db_backups", POS_PATH_TO_SERVER_ROOT);
    $dbs_instance = trim(shell_exec("ls -lat -m1 " . $final_path . "| grep " . $ids[$i] . ".sql"));
    Logger::log("Respaldos encontrados: " . $dbs_instance);
    /*dbs_instance almacena una cadena con un listado donde se encuentran archivos que tengan la teminacion
    	con el id de la instancia y .sql, ademas de que la lista viene ordenada de mas reciente a antiguo
    	la lista seria como lo siguiente:
    	1353617611_pos_instance_82.sql 1353608687_pos_instance_82.sql 1353608206_pos_instance_82.sql 1353608191_pos_instance_82.sql
    	en found se coloca un array y en cada posicion el nombre de cada respaldo
    	*/
    $found = preg_split("/[\\s,]+/", $dbs_instance, -1, PREG_SPLIT_NO_EMPTY);
    //Logger::log("No archivos: ".count($found));
    if (count($found) < 1) {
        Logger::log("Error al restaurar la instancias " . $ids[$i] . ", no hay un respaldo existente");
        continue;
    }
    $contenido = file_get_contents($final_path . "/" . $found[0]);
    $f->add_file($contenido, $found[0]);
}
$folder_name = sizeof($ids) > 1 ? "instances_backup_" . date("d-m-Y H:i:s") : "instance_" . $ids[0] . "_backup_" . date("d-m-Y H:i:s");
Logger::log(":::::::ENVIANDO ARCHIVO A DESCARGAR");
header("Content-type: application/octet-stream");
header("Content-disposition: attachment; filename={$folder_name}.zip");
echo $f->file();
Exemple #18
0
    require_once 'inc/zip.class.php';
    $zipfile = new zipfile();
    $timestamp = date('Y-m-d-Hi');
    ini_set("memory_limit", "600M");
    // paths and files to backup
    $paths = array($relative . 'data', $relative . 'theme');
    //no trailing slash
    $files = array($relative . '.htaccess', $relative . 'index.php', $relative . 'gsconfig.php');
    $zipfile->add_dir('getsimple');
    // cycle thru each path and file and add to zip file
    foreach ($paths as $path) {
        $dir_handle = @opendir($path) or die("Unable to open {$path}");
        ListDir($dir_handle, $path);
    }
    foreach ($files as $fl) {
        $filedata = file_get_contents($fl);
        $zipfile->add_file($filedata, substr_replace($fl, 'getsimple', 0, 2));
    }
    // $listing is the list of all files and folders that were added to the backup
    //echo $listing;
    // create the final zip file
    $file = $relative . 'backups/zip/' . $timestamp . '_archive.zip';
    $fh = fopen($file, 'w') or die('Could not open file for writing!');
    fwrite($fh, $zipfile->file()) or die('Could not write to file');
    fclose($fh);
    // redirect back to archive page with a success
    header('Location: archive.php?done');
} else {
    die('You do not have permission to execute this page');
}
exit;
 /**
  * Create zip file which contains patch.xml and the files to be added, overwritten, altered; and force to download
  * @access  private
  * @return  true   if successful
  *          false  if errors
  * @author  Cindy Qi Li
  */
 function createZIP()
 {
     require_once AT_INCLUDE_PATH . '/classes/zipfile.class.php';
     $zipfile = new zipfile();
     $zipfile->add_file(file_get_contents($this->patch_xml_file), 'patch.xml');
     if (is_array($this->patch_info_array["files"])) {
         foreach ($this->patch_info_array["files"] as $file_info) {
             if ($file_info["upload_tmp_name"] != '') {
                 $file_name = preg_replace('/.php$/', '.new', $file_info['file_name']);
                 $zipfile->add_file(file_get_contents($file_info['upload_tmp_name']), $file_name);
             }
         }
     }
     $zipfile->send_file($this->patch_info_array["atutor_patch_id"]);
 }
Exemple #20
0
 public function packZip()
 {
     $id = $this->input['infolist'];
     $name = $this->input['staffName'];
     $frontTif = $this->input['frontTif'];
     $backTif = $this->input['backTif'];
     $whitebackTif = $this->input['whitebackTif'];
     //$id = 1;
     //$name = array(1=>'沈伟');
     //$frontTif = array(1=>'http://img.dev.hogesoft.com:233/material/staff/img/2013/03/11946c76f7a8b2b82d10bf2919c62b23.tif');
     //$backTif = array(1=>'http://img.dev.hogesoft.com:233/material/staff/img/2013/03/5df1463ba59a493a3417bcd53c7c4f8f.tif');
     //$dfile =  tempnam('/tmp', 'tmp');//产生一个临时文件,用于缓存下载文件
     $temp = date('Ymd_His', TIMENOW) . '_' . rand(1, 100) . '.tmp';
     $dir = CUR_CONF_PATH . $this->settings['staff_zip']['path'];
     if (!is_dir($dir)) {
         hg_mkdir($dir);
     }
     $dfile = $dir . $temp;
     $zip = new zipfile();
     $filename = 'image.zip';
     //下载的默认文件名
     $image = array();
     if ($id && !empty($name) && !empty($frontTif) && !empty($backTif)) {
         if (is_array($id)) {
             foreach ($id as $key => $val) {
                 $name[$val] = iconv('UTF-8', 'GB2312//IGNORE', $name[$val]);
                 $image[] = array('image_src' => $frontTif[$val], 'image_name' => $name[$val] . '_F_' . $val . '.tif');
                 $image[] = array('image_src' => $backTif[$val], 'image_name' => $name[$val] . '_B_' . $val . '.tif');
                 $image[] = array('image_src' => $whitebackTif[$val], 'image_name' => $name[$val] . '_WB_' . $val . '.tif');
             }
         }
     }
     if (!empty($image)) {
         foreach ($image as $v) {
             $zip->add_file(file_get_contents($v['image_src']), $v['image_name']);
         }
         $zip->output($dfile);
         $data = array('zipname' => $filename, 'zipfilename' => $this->settings['staff_zip']['protocol'] . $this->settings['staff_zip']['host'] . '/' . $this->settings['staff_zip']['dir'] . $this->settings['staff_zip']['path'] . '/' . $temp);
     }
     $this->addItem($data);
     $this->output();
     /*
     $image = array(
         array('image_src' => 'pic1.jpg', 'image_name' => '图片1.jpg'),
         array('image_src' => 'pic2.jpg', 'image_name' => 'pic/图片2.jpg'),
     );
     foreach($image as $v){
         $zip->add_file(file_get_contents($v['image_src']),  $v['image_name']);
         // 添加打包的图片,第一个参数是图片内容,第二个参数是压缩包里面的显示的名称, 可包含路径
         // 或是想打包整个目录 用 $zip->add_path($image_path);
     }
     */
 }
Exemple #21
0
function export_theme($theme_dir)
{
    require AT_INCLUDE_PATH . 'classes/zipfile.class.php';
    /* for zipfile */
    require AT_INCLUDE_PATH . 'classes/XML/XML_HTMLSax/XML_HTMLSax.php';
    /* for XML_HTMLSax */
    require 'theme_template.inc.php';
    /* for theme XML templates */
    global $db;
    //identify current theme and then searches db for relavent info
    $sql = "SELECT * FROM " . TABLE_PREFIX . "themes WHERE dir_name = '{$theme_dir}'";
    $result = mysql_query($sql, $db);
    $row = mysql_fetch_assoc($result);
    $dir = $row['dir_name'] . '/';
    $title = $row['title'];
    $version = $row['version'];
    $type = $row['type'];
    $last_updated = $row['last_updated'];
    $extra_info = $row['extra_info'];
    //generate 'theme_info.xml' file based on info
    $info_xml = str_replace(array('{TITLE}', '{VERSION}', '{TYPE}', '{LAST_UPDATED}', '{EXTRA_INFO}'), array($title, $version, $type, $last_updated, $extra_info), $theme_template_xml);
    //zip together all the contents of the folder along with the XML file
    $zipfile = new zipfile();
    $zipfile->create_dir($dir);
    //update installation folder
    $dir1 = get_main_theme_dir(intval($row["customized"])) . $dir;
    $zipfile->add_file($info_xml, $dir . 'theme_info.xml');
    /* zip other required files */
    $zipfile->add_dir($dir1, $dir);
    /*close & send*/
    $zipfile->close();
    //Name the Zip file and sends to user for download
    $zipfile->send_file(str_replace(array(' ', ':'), '_', $title));
}
     }
     // Open a read pointer to run through each log date directory getting all the profiles
     while (($file = readdir($dir)) !== false) {
         if ($file == '.' || $file == '..' || is_dir($file)) {
             continue;
         }
         // any files mathcing the $elem key correspond to this profile
         if (strpos($file, $elem) !== false) {
             $store_some[$dir_ . '/' . $val . '/' . $file] = $file;
         }
     }
     closedir($dir);
     // clean it up
     // The dir pointer is closed lets add to the zip
     foreach ($store_some as $val_ => $e) {
         $zipfile->add_file(file_get_contents($val_), $e);
     }
 }
 $zipfile->close();
 if ($file_handle = fopen($dir_ . '/bundle.log', "w")) {
     if (!fwrite($file_handle, $zipfile->get_file())) {
     }
 } else {
 }
 fclose($file_handle);
 $mail->From = $_config['contact_email'];
 $mail->addAddress($_POST['email_add']);
 $mail->Subject = _AT('log_file_bundle');
 $mail->Body = _AT('see_attached');
 $mail->AddAttachment($dir_ . '/bundle.log');
 // clean up the file at the redirection point
Exemple #23
0
     while ($row = mysql_fetch_assoc($result)) {
         $msg = _AT('from') . ': ' . $my_display_name . "\r\n";
         $msg .= _AT('to') . ': ' . get_display_name($row['from_member_id']) . "\r\n";
         $msg .= _AT('subject') . ': ' . $row['subject'] . "\r\n";
         $msg .= _AT('date') . ': ' . $row['date_sent'] . "\r\n";
         $msg .= _AT('body') . ': ' . $row['body'] . "\r\n";
         $msg .= "\r\n=============================================\r\n\r\n";
         $sent_messages .= $msg;
     }
 }
 if ($inbox_messages && $sent_messages) {
     // add the two to a zip file
     require AT_INCLUDE_PATH . 'classes/zipfile.class.php';
     // for zipfile
     $zipfile = new zipfile();
     $zipfile->add_file($inbox_messages, _AT('inbox') . '.txt');
     $zipfile->add_file($sent_messages, _AT('sent_messages') . '.txt');
     $zipfile->close();
     $zipfile->send_file(_AT('inbox') . '-' . date('Ymd'));
     exit;
 } else {
     if ($inbox_messages) {
         header('Content-Type: text/plain');
         header('Content-Disposition: attachment; filename="' . _AT('inbox') . '-' . date('Ymd') . '.txt"');
         header('Expires: 0');
         header('Cache-Control: must-revalidate, post-check=0, pre-check=0');
         header('Pragma: public');
         header('Content-Length: ' . strlen($inbox_messages));
         echo $inbox_messages;
         exit;
     } else {
Exemple #24
0
         exit;
     }
 } else {
     // zip multiple files and folders
     require AT_INCLUDE_PATH . 'classes/zipfile.class.php';
     $zipfile = new zipfile();
     $zip_file_name = fs_get_workspace($owner_type, $owner_id);
     // want the name of the workspace
     $zip_file_name = str_replace(" ", "_", $zip_file_name);
     if (is_array($_GET['files'])) {
         foreach ($_GET['files'] as $file_id) {
             $file_path = fs_get_file_path($file_id) . $file_id;
             $sql = "SELECT file_name, UNIX_TIMESTAMP(date) AS date FROM " . TABLE_PREFIX . "files WHERE file_id={$file_id} AND owner_type={$owner_type} AND owner_id={$owner_id}";
             $result = mysql_query($sql, $db);
             if (($row = mysql_fetch_assoc($result)) && file_exists($file_path)) {
                 $zipfile->add_file(file_get_contents($file_path), $row['file_name'], $row['date']);
             }
         }
     }
     if (is_array($_GET['folders'])) {
         foreach ($_GET['folders'] as $folder_id) {
             fs_download_folder($folder_id, $zipfile, $owner_type, $owner_id);
             $row['title'] = str_replace(" ", "_", $row['title']);
             $zipfile->create_dir($row['title']);
         }
         if (count($_GET['folders']) == 1) {
             // zip just one folder, use that folder's title as the zip file name
             $row = fs_get_folder_by_id($_GET['folders'][0], $owner_type, $owner_id);
             if ($row) {
                 $zip_file_name = $row['title'];
                 $zip_file_name = str_replace(" ", "_", $zip_file_name);
Exemple #25
0
$usersDAO = new UsersDAO();
$row = $usersDAO->getUserByID($instructor_id);
//$sql = "SELECT first_name, last_name, email, website, login, phone FROM ".TABLE_PREFIX."members WHERE member_id=$instructor_id";
//$result = mysql_query($sql, $db);
$vcard = new vCard();
if (isset($row)) {
    $vcard->setName($row['last_name'], $row['first_name'], $row['login']);
    $vcard->setEmail($row['email']);
    $vcard->setNote('Originated from an AContent at ' . TR_BASE_HREF . '. See ATutor.ca for additional information.');
    $vcard->setURL($row['website']);
    $imsmanifest_xml = str_replace('{VCARD}', $vcard->getVCard(), $imsmanifest_xml);
} else {
    $imsmanifest_xml = str_replace('{VCARD}', '', $imsmanifest_xml);
}
/* save the imsmanifest.xml file */
$zipfile->add_file($imsmanifest_xml, 'imsmanifest.xml');
/* Commented by Cindy Qi Li on Jan 12, 2010
// AContent does not have glossary and forums (discussion tools)
if ($glossary_xml) {
	$zipfile->create_dir('resources/GlossaryItem/');
	$zipfile->add_file($glossary_xml,  'resources/GlossaryItem/glossary.xml');
}
*/
$zipfile->close();
// this is optional, since send_file() closes it anyway
$ims_course_title = str_replace(array(' ', ':'), '_', $ims_course_title);
/**
 * A problem here with the preg_replace below.
 * Originally was designed to remove all werid symbols to avoid file corruptions.
 * In UTF-8, all non-english chars are considered to be 'werid symbols'
 * We can still replace it as is, or add fileid to the filename to avoid these problems
     $str_applilcation = str_replace("[reserve]", $reserve, $str_applilcation);
     $str_applilcation = str_replace("[company_status]", $company_status, $str_applilcation);
     $str_applilcation = str_replace("[merchant_type]", $merchant_type, $str_applilcation);
     $str_applilcation = str_replace("[volumenumber]", $volumenumber, $str_applilcation);
     $str_applilcation = str_replace("[avgticket]", $avgticket, $str_applilcation);
     $str_applilcation = str_replace("[company_bank]", $company_bank, $str_applilcation);
     $str_applilcation = str_replace("[bank_address]", $bank_address, $str_applilcation);
     $str_applilcation = str_replace("[bank_country]", $bank_country, $str_applilcation);
     $str_applilcation = str_replace("[bank_phone]", $bank_phone, $str_applilcation);
     $str_applilcation = str_replace("[bank_sort_code]", $bank_sort_code, $str_applilcation);
     $str_applilcation = str_replace("[bank_account_number]", $bank_account_number, $str_applilcation);
     $str_applilcation = str_replace("[bank_swift_code]", $bank_swift_code, $str_applilcation);
     $zipfile->add_dir($dir_company_name . "/");
     $zipfile->add_dir($dir_company_name . "/Application/");
     $filedata = $str_applilcation;
     $zipfile->add_file($filedata, $dir_company_name . "/Application/application_" . $company_id . ".html");
 }
 //print("comp. file size= ".$zipfile -> get_file_size()."<br>");
 //	print($str_company_name."<br>");
 if ($is_doc != "") {
     $myLicenceFileArray = array();
     $myArticlesFileArray = array();
     $myHistoryFileArray = array();
     $myProfessionalReferenceFileArray = array();
     $str_qry = "select file_type, file_name from cs_uploaded_documents where user_id = {$company_id} and status = 'A'";
     if (!($show_sql = mysql_query($str_qry, $cnn_cs))) {
         print mysql_errno() . ": " . mysql_error() . "<BR>";
         print "Cannot execute query";
         print $str_qry;
         exit;
     }