/**
  * download a bunch of files in gz mode.
  */
 public function downloadBulk($bulkList, $jsList = null)
 {
     //language
     global $_CALEM_conf;
     $lang = isset($_REQUEST['lang']) ? $_REQUEST['lang'] : null;
     $ext = false;
     if ($lang) {
         $ext = '_' . $lang;
     }
     //download mode
     $mode = isset($_REQUEST['loadmode']) ? $_REQUEST['loadmode'] : $_CALEM_conf['client_js_load_mode'];
     $zip = false;
     $zipIt = count($bulkList) > 1;
     //zipping more than 1 files using min.
     if ($mode == "gzip") {
         if ($encoding = CalemGzip::canGzip()) {
             $zip = true;
         }
         if ($zipIt) {
             //More than 1 files so must use min regardless.
             $mode_ext = $_CALEM_conf['client_js_custom_ext']['min'];
         } else {
             if ($zip) {
                 //single file case - could use a zip file.
                 $mode_ext = $_CALEM_conf['client_js_custom_ext']['gzip'];
             } else {
                 //zip not available.
                 $mode_ext = $_CALEM_conf['client_js_custom_ext']['min'];
                 //use min instead.
             }
         }
     } else {
         //This is no gzip case.
         $mode_ext = $_CALEM_conf['client_js_custom_ext'][$mode];
     }
     //Now let's process file list here.
     $js = '';
     foreach ($bulkList as $fileItem) {
         $fileName = $fileItem['addLang'] && $ext ? $fileItem['id'] . $ext : $fileItem['id'];
         $fileName .= $fileItem['ext'] . $mode_ext;
         if (is_file($fileName)) {
             $data = file_get_contents($fileName);
             $js .= $data;
             if ($this->logger->isDebugEnabled()) {
                 $this->logger->debug("adding file for download: " . $fileName);
             }
         }
     }
     //Add in text list if any
     if (isset($jsList)) {
         foreach ($jsList as $jsDef) {
             $js .= $jsDef;
             if ($this->logger->isDebugEnabled()) {
                 $this->logger->debug("adding jsDef for download: " . $jsDef);
             }
         }
     }
     //Needs to pipe through gz if it's zipped format.
     if ($zip && $zipIt) {
         $js = gzencode($js, $_CALEM_conf['server_gzip_rate']);
     }
     if ($this->logger->isDebugEnabled()) {
         $this->logger->debug("Downloading JS by query: zip=" . $zip . ", mode=" . $mode_ext . ", fileCount=" . count($bulkList));
     }
     //Disable browser side cache
     header('Cache-Control: no-cache');
     //Output data
     CalemGzip::gzStart();
     print $js;
     CalemGzip::gzEndFlush($zip, $encoding);
 }
Example #2
0
 *
 * Software distributed under the License is distributed on an "AS IS" basis,
 * WITHOUT WARRANTY OF ANY KIND, either express or implied.  See the License
 * for the specific language governing rights and limitations under the
 * License.
 *
 * The Original Code is: CalemEAM Open Source
 *
 * The Initial Developer of the Original Code is CalemEAM Inc.
 * Portions created by CalemEAM are Copyright (C) 2007 CalemEAM Inc.;
 * All Rights Reserved.
 * Contributor(s): 
 */
//Checking basic initialization
if (!defined('_CALEM_DIR_')) {
    die("Access denied at " . __FILE__);
}
require_once _CALEM_DIR_ . 'server/include/core/CalemFactory.php';
require_once _CALEM_DIR_ . 'server/include/util/CalemGzip.php';
//Provide data or settings in this case
$fid = $_REQUEST['fid'];
$dbo = CalemFactory::getDbo('doc_upload');
try {
    $row = $dbo->fetchById($fid);
    $path = $_CALEM_conf['upload_conf']['dir_map'][$row['access_id']];
    $fp = _CALEM_DIR_ . $path . $row['file_upload'];
    CalemGzip::downloadFile($fp, $_CALEM_conf['upload_conf']['gzip']);
} catch (CalemDboDataNotFoundException $dnf) {
    print 'Upload data not found in the database';
    return;
}
Example #3
0
$sufix = '';
if ($lang) {
    $sufix = "_" . $lang;
}
$msgdir = _CALEM_DIR_ . 'client/lang/';
if (!isset($_CALEM_conf['client_lang_list']['CalemMsg' . $sufix . '.js'])) {
    $logger->error("Invalid language: " . $lang . ", to use default language.");
    $sufix = '';
}
$mapping = $_CALEM_conf['client_lang_list']['CalemMsg' . $sufix . ".js"];
if ($logger->isDebugEnabled()) {
    $logger->debug("fetch messages: lang={$lang}; fileset=" . var_export($mapping, true));
}
$data = "//Messages for Calem unpacked. " . CALEM_LFCR;
foreach ($mapping as $class => $files) {
    $data .= "//Message definition for " . $class . CALEM_LFCR;
    $data .= 'function ' . $class . '() {}' . CALEM_LFCR . CALEM_LFCR;
    foreach ($files as $file) {
        $fullname = _CALEM_DIR_ . 'client/lang/' . $file . '.properties';
        $data .= MessageToJs::fileToJs($class, $fullname);
    }
}
//Done parsing messages, now decide the output mode
//Disable browser side cache
if (!headers_sent()) {
    header('Cache-Control: no-cache');
}
CalemGzip::gzStart();
print $data;
CalemGzip::gzEndFlush(false);
Example #4
0
 public function get_data($reload = false)
 {
     $data = $this->getChartData($reload);
     CalemGzip::gzContents($data, $this->conf['gzip'], $this->logger);
 }
Example #5
0
 /**
  * Send a response back to client
  * @param String Response text
  */
 private function sendResponse($status, $response, $zipIt)
 {
     //Check for gzip per each service
     global $_CALEM_conf;
     $zip = false;
     if ($zipIt && $_CALEM_conf['calem_soap_allow_gzip'] && ($encoding = CalemGzip::canGzip())) {
         $zip = true;
     }
     //Output data
     CalemGzip::gzStart();
     print $response;
     CalemGzip::gzSoapCompressEndFlush($status, $zip, $encoding, $this->logger);
 }