public function index()
 {
     $filenamezip = APP_ROOT_PATH . "public/mobile_goods_down_region_conf.zip";
     if (!file_exists($filenamezip)) {
         $sql = "select id,pid,name,'' as postcode,'' as py from " . DB_PREFIX . "delivery_region";
         $list = $GLOBALS['db']->getAll($sql);
         $root = array();
         $root['return'] = 1;
         $region_list = "";
         foreach ($list as $item) {
             $sql = "insert into region_conf(id,pid,name,postcode,py) values('{$item['id']}','{$item['pid']}','{$item['name']}','{$item['postcode']}','{$item['py']}');";
             if ($region_list == "") {
                 $region_list = $sql;
             } else {
                 $region_list = $region_list . "\n" . $sql;
             }
         }
         $ziper = new zipfile();
         $ziper->addFile($region_list, "region_conf.txt");
         $ziper->output($filenamezip);
     }
     $root = array();
     $root['return'] = 1;
     if (file_exists($filenamezip)) {
         $root['file_exists'] = 1;
     } else {
         $root['file_exists'] = 0;
     }
     $sql = "select count(*) as num from " . DB_PREFIX . "delivery_region";
     $root['region_num'] = $GLOBALS['db']->getOne($sql);
     //配置地区数量
     $root['file_url'] = get_domain() . APP_ROOT . "/../public/mobile_goods_down_region_conf.zip";
     $root['file_size'] = abs(filesize($filenamezip));
     output($root);
 }
Exemple #2
0
        }
    }
    if ($_POST['output'] == '0') {
        // write the sql file
        $file_name = 'data/' . $_GET['db'] . '-' . date("D-m-y_h-i-s") . ".sql";
        $fp = fopen($file_name, "w");
        fwrite_stream($fp, $_final_data);
        fclose($fp);
    }
    if ($_POST['output'] == '1') {
        $_SESSION['file_sql'] = 'data/' . $_GET['db'] . '-' . date("D-m-y_h-i-s") . ".sql";
        $fp = fopen($_SESSION['file_sql'], "w");
        fwrite_stream($fp, $_final_data);
        $ziper = new zipfile();
        $ziper->addFiles($_SESSION['file_sql']);
        $ziper->output($_SESSION['file_sql'] . '.zip');
        unlink($_SESSION['file_sql']);
        fclose($fp);
    }
} else {
    if (isset($_GET['db'])) {
        if ($db_name) {
            $lt = $db->query("SHOW TABLE STATUS;");
            while ($lst = $lt->fetch_array()) {
                $list[] = $lst[0];
            }
        }
    } else {
        $lt = $db->query("SHOW DATABASES;");
        while ($lst = $lt->fetch_array()) {
            $list[] = $lst[0];
Exemple #3
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 #4
0
function saveOds($obj, $file)
{
    $charset = ini_get('default_charset');
    ini_set('default_charset', 'UTF-8');
    $tmp = get_tmp_dir();
    $uid = uniqid();
    mkdir($tmp . '/' . $uid);
    file_put_contents($tmp . '/' . $uid . '/content.xml', $obj->array2ods());
    file_put_contents($tmp . '/' . $uid . '/mimetype', 'application/vnd.oasis.opendocument.spreadsheet');
    file_put_contents($tmp . '/' . $uid . '/meta.xml', $obj->getMeta('pt-BR'));
    file_put_contents($tmp . '/' . $uid . '/styles.xml', $obj->getStyle());
    file_put_contents($tmp . '/' . $uid . '/settings.xml', $obj->getSettings());
    mkdir($tmp . '/' . $uid . '/META-INF/');
    mkdir($tmp . '/' . $uid . '/Configurations2/');
    mkdir($tmp . '/' . $uid . '/Configurations2/acceleator/');
    mkdir($tmp . '/' . $uid . '/Configurations2/images/');
    mkdir($tmp . '/' . $uid . '/Configurations2/popupmenu/');
    mkdir($tmp . '/' . $uid . '/Configurations2/statusbar/');
    mkdir($tmp . '/' . $uid . '/Configurations2/floater/');
    mkdir($tmp . '/' . $uid . '/Configurations2/menubar/');
    mkdir($tmp . '/' . $uid . '/Configurations2/progressbar/');
    mkdir($tmp . '/' . $uid . '/Configurations2/toolbar/');
    file_put_contents($tmp . '/' . $uid . '/META-INF/manifest.xml', $obj->getManifest());
    $ziper = new zipfile();
    $ziper->addFiles($tmp . '/' . $uid, array('META-INF', 'Configurations2', 'content.xml', 'meta.xml', 'mimetype', 'settings.xml', 'styles.xml'));
    $ziper->output($file);
    remove_directory($tmp . '/' . $uid);
    ini_set('default_charset', $charset);
}
Exemple #5
0
    // 进行缩放
    imagepng($thumb, UPLOAD_DIR . $files['1x'][$key]);
    // 输出缩略图
    imagedestroy($thumb);
    imagedestroy($photo);
}
// 所有文件缩放完毕,开始进行打包
require_once 'zip.lib.php';
$archive = new zipfile();
foreach ($files['1x'] as $name) {
    $archive->addFile(file_get_contents(UPLOAD_DIR . $name), $name);
    @unlink(UPLOAD_DIR . $name);
}
foreach ($files['2x'] as $name) {
    $archive->addFile(file_get_contents(UPLOAD_DIR . $name), $name);
    @unlink(UPLOAD_DIR . $name);
}
$archive->output(UPLOAD_DIR . 'archive.zip');
header('Content-Type: application/zip');
header('Content-disposition: attachment; filename="archive.zip"');
@readfile(UPLOAD_DIR . 'archive.zip');
// 产生相应 Header 并读取文件内容
foreach ($files['1x'] as $name) {
    @unlink(UPLOAD_DIR . $name);
}
foreach ($files['2x'] as $name) {
    @unlink(UPLOAD_DIR . $name);
}
@unlink(UPLOAD_DIR . 'archive.zip');
@rmdir(UPLOAD_DIR);
// 删除对应文件
Exemple #6
0
    public function getKML($url, $download = false, $file = "")
    {
        // Create KMZ archieve
        if ($file == "") {
            $file = $this->dirtmp . "/tme" . $this->nomeTemp . ".kmz";
        }
        $this->nomeArquivo = $file;
        if (!file_exists($file)) {
            include dirname(__FILE__) . "/../kmlmapserver/classes/zip.class.php";
            $zip = new zipfile();
            // Add balloon logo to archieve (300 x 30 px)
            $zip->addFile($this->logoline, 'files/balloonlogo.png');
            // KML header
            $kml = "<?xml version='1.0' encoding='UTF-8'?>" . PHP_EOL . "<kml xmlns='http://www.opengis.net/kml/2.2' xmlns:atom='http://www.w3.org/2005/Atom'>" . PHP_EOL . "  <Document>" . PHP_EOL . "    <atom:author>" . PHP_EOL . "      <atom:name>Thematic Mapping Engine</atom:name>" . PHP_EOL . "    </atom:author>" . PHP_EOL . "    <atom:link href='http://thematicmapping.org' rel='related' />" . PHP_EOL . "    <name>{$this->mapTitle}</name>" . PHP_EOL . "    <open>1</open>" . PHP_EOL . "    <Snippet maxLines='1'>{$this->mapSource}</Snippet>" . PHP_EOL . "    <description><![CDATA[ {$this->mapDescription} <p>{$this->mapSource}</p>{$this->engine} ]]></description>" . PHP_EOL;
            // Add style for indicator balloon
            $kmlStyles = "    <Style id='balloonStyle'>" . PHP_EOL . "      <BalloonStyle>" . PHP_EOL . "        <text><![CDATA[" . PHP_EOL . "          <a href='http://thematicmapping.org'><img src='http://thematicmapping.org/engine/files/balloonlogo.png'></a>" . PHP_EOL . "          <p><b><font size='+2'>\$[name]</font></b></p>" . PHP_EOL . "          <p>\$[description]</p>" . PHP_EOL . "        ]]></text>" . PHP_EOL . "      </BalloonStyle>" . PHP_EOL . "    </Style>" . PHP_EOL . "    <styleUrl>#balloonStyle</styleUrl>" . PHP_EOL;
            if ($this->colourType == 'scale') {
                // Need to run before getColourValue / getColourLegend / makeClasses
                self::makeColourScale();
                if ($this->classification != 'unclassed') {
                    self::makeClasses($this->classification, $this->numClasses);
                }
                // Add colour legend to KMZ archieve
                if ($this->showLegend) {
                    $imgLegenda = self::getColourLegend();
                    $zip->addFile($imgLegenda, 'files/legend.png');
                }
                $kmlSingleColour = '';
                // Colours needs to be defined for each feature
                //$kmlColour = self::rgb2bgr($this->noDataColour); // Not in use, only so the variable has a value
            } else {
                $kmlSingleColour = '<color>' . self::rgb2bgr($this->colour) . '</color>';
                //$kmlColour = self::rgb2bgr($this->colour);
            }
            // Add style for value placemarks
            if ($this->showLabel) {
                $kmlStyles .= "    <Style id='labelPlacemark'>" . PHP_EOL . "      <IconStyle>" . PHP_EOL . "        <scale>0.0</scale>" . PHP_EOL . "      </IconStyle>" . PHP_EOL . "      <LabelStyle>" . PHP_EOL . "        <scale>1</scale>" . PHP_EOL . "      </LabelStyle>" . PHP_EOL . "    </Style>" . PHP_EOL;
            }
            // Define shared styles and legend
            $kmlStyles .= "    <Style id='sharedStyle'>" . PHP_EOL;
            switch ($this->mapType) {
                case "choropleth":
                case "prism":
                    $kmlStyles .= "      <PolyStyle>" . PHP_EOL . "        <fill>1</fill>" . PHP_EOL . "        <outline>1</outline>" . PHP_EOL . "        {$kmlSingleColour}" . PHP_EOL . "      </PolyStyle>" . PHP_EOL . "      <LineStyle>" . PHP_EOL . "        <color>cc000000</color>" . PHP_EOL . "      </LineStyle>" . PHP_EOL;
                    break;
                case "bar":
                    if ($this->outlinecolor == "") {
                        $outline = 0;
                    } else {
                        $outline = 1;
                    }
                    $kmlStyles .= "      <PolyStyle>" . PHP_EOL . "        <fill>1</fill>" . PHP_EOL . "        <outline>" . $outline . "</outline>" . PHP_EOL . "        {$kmlSingleColour}" . PHP_EOL . "      </PolyStyle>" . PHP_EOL;
                    if ($this->outlinecolor != "") {
                        $kmlStyles .= "<LineStyle>" . PHP_EOL . "        <color>" . $this->outlinecolor . "</color>" . PHP_EOL . "      </LineStyle>" . PHP_EOL;
                    }
                    break;
                    // Proportional symbol
                // Proportional symbol
                case "symbol":
                    switch ($this->symbolType) {
                        case 'image':
                            $zip->addFile("files/{$this->symbolShape}.png", 'files/symbol.png');
                            $kmlStyles .= "      <IconStyle>" . PHP_EOL . "        {$kmlSingleColour}" . PHP_EOL . "        <Icon>" . PHP_EOL . "          <href>" . $url . "/symbol.png</href>" . PHP_EOL . "        </Icon>" . PHP_EOL . "      </IconStyle>" . PHP_EOL;
                            break;
                        case 'polygon':
                            if ($this->symbolShape == 'square') {
                                $this->symbolVertices = 4;
                            }
                            $kmlStyles .= "      <PolyStyle>" . PHP_EOL . "        {$kmlSingleColour}" . PHP_EOL . "        <fill>1</fill>" . PHP_EOL . "        <outline>1</outline>" . PHP_EOL . "      </PolyStyle>" . PHP_EOL . "      <LineStyle>" . PHP_EOL . "        <color>cc000000</color>" . PHP_EOL . "      </LineStyle>" . PHP_EOL;
                            break;
                        case 'collada':
                            if ($this->colourType == 'scale') {
                                // Limit number of collada objects (one for each colour)
                                if ($this->classification == 'unclassed') {
                                    self::makeClasses('equal', 12);
                                }
                                foreach ($this->classColours as $class => $classColour) {
                                    $colladaColour = self::rgb2collada($classColour);
                                    // Read collada model
                                    $filename = "files/{$this->symbolShape}.dae";
                                    $handle = fopen($filename, "r");
                                    $collada = fread($handle, filesize($filename));
                                    fclose($handle);
                                    // Search and replace colour
                                    $pos = strpos($collada, '<effect id="material0-effect" name="material0-effect">');
                                    $pos = strpos($collada, "<diffuse>", $pos);
                                    $pos = strpos($collada, "<color>", $pos);
                                    $collada = substr_replace($collada, $colladaColour, $pos + 7, 28);
                                    // Add collada object to kmz archieve
                                    $zip->addFromString("files/object{$class}.dae", $collada);
                                }
                            } else {
                                $colladaColour = self::rgb2collada($this->colour);
                                // Read collada model
                                $filename = "files/{$this->symbolShape}.dae";
                                $handle = fopen($filename, "r");
                                $collada = fread($handle, filesize($filename));
                                fclose($handle);
                                // Search and replace colour
                                $pos = strpos($collada, '<effect id="material0-effect" name="material0-effect">');
                                $pos = strpos($collada, "<diffuse>", $pos);
                                $pos = strpos($collada, "<color>", $pos);
                                $collada = substr_replace($collada, $colladaColour, $pos + 7, 28);
                                // Add collada object to kmz archieve
                                $zip->addFromString("files/object.dae", $collada);
                            }
                            $kmlstyle = '';
                            // Not possible to define style for collada objects
                    }
                    // switch symbol
            }
            // switch type
            $kmlStyles .= "      <BalloonStyle>" . PHP_EOL . "        <text><![CDATA[" . PHP_EOL . "          <a href='http://thematicmapping.org'><img src='http://thematicmapping.org/engine/files/balloonlogo.png'></a>" . PHP_EOL . "          <p><b><font size='+2'>\$[name]</font></b></p>" . PHP_EOL . "          <p>{$this->mapTitle}: \$[Snippet]</p>" . PHP_EOL . "          <p>{$this->mapDescription}</p>" . PHP_EOL . "          <p>{$this->mapSource}</p>" . PHP_EOL . "          <p>{$this->engine}</p>" . PHP_EOL . "        ]]></text>" . PHP_EOL . "      </BalloonStyle>" . PHP_EOL . "    </Style>" . PHP_EOL;
            // End of shared style
            $kmlFolder = "    <Folder>" . PHP_EOL . "      <name>Colunas</name>" . PHP_EOL . "      <open>1</open>" . PHP_EOL;
            if ($this->timeType == 'series') {
                $kmlFolder .= "      <Style>" . PHP_EOL . "        <ListStyle>" . PHP_EOL . "          <listItemType>radioFolder</listItemType>" . PHP_EOL . "        </ListStyle>" . PHP_EOL . "      </Style>" . PHP_EOL;
            }
            // Loop thorough all years
            foreach ($this->yearArray as $key => $year) {
                $kmlFeatures = '';
                if ($this->timeType == 'slider' or $year == $this->year) {
                    $visibility = 1;
                } else {
                    $visibility = 0;
                }
                $kmlFolder .= "      <Folder>" . PHP_EOL . "        <name>{$year}</name>" . PHP_EOL . "        <visibility>{$visibility}</visibility>" . PHP_EOL;
                if ($this->showLabel) {
                    $kmlLabels = "        <Folder>" . PHP_EOL . "          <name>Show/hide labels</name>" . PHP_EOL . "          <visibility>{$visibility}</visibility>" . PHP_EOL . "          <Style>" . PHP_EOL . "            <ListStyle>" . PHP_EOL . "              <listItemType>checkHideChildren</listItemType>" . PHP_EOL . "            </ListStyle>" . PHP_EOL . "          </Style>" . PHP_EOL;
                }
                // Add timespan if time animation
                if ($this->timeType == 'slider') {
                    $end = '';
                    // Check if there is more years
                    if (array_key_exists($key + 1, $this->yearArray)) {
                        $end = '<end>' . intval($this->yearArray[$key + 1] - 1) . '-12-31</end>';
                    }
                    $kmlFolder .= "        <TimeSpan>" . PHP_EOL . "          <begin>{$year}-01-01</begin>{$end}" . PHP_EOL . "        </TimeSpan>" . PHP_EOL;
                }
                // Loop thorough all features (values without features will not be shown)
                foreach ($this->dataStore['features'] as $featureID => $feature) {
                    $name = $feature['name'];
                    //if (!mb_detect_encoding($name,"UTF-8",true))
                    //{$name = mb_convert_encoding($name,"UTF-8","ISO-8859-1");}
                    $name = "<![CDATA[ " . $name . " ]]>";
                    $value = '';
                    // use null?
                    $valueText = 'no data';
                    $valueLabel = '';
                    $kmlFeature = '';
                    $altitude = 0;
                    $symbolSize = 0;
                    $colladaCount = 0;
                    //$kmlColour = self::rgb2bgr($this->noDataColour);
                    $kmlColour = '';
                    $longitude = $feature['lon'];
                    $latitude = $feature['lat'];
                    // Check if value exists for this feature
                    if (isset($this->indicator['values'][$year][$featureID])) {
                        // Extract value from dataStore
                        $value = $this->indicator['values'][$year][$featureID];
                        $valueText = $valueLabel = number_format($value, 2, ',', '.');
                        // Colour scale
                        if ($this->colourType == 'scale') {
                            if ($this->classification != 'unclassed') {
                                $class = self::getClass($value);
                                $kmlColour = self::rgb2bgr($this->classColours[$class]);
                            } else {
                                $kmlColour = self::getColourValue($value, 'kml');
                            }
                        }
                        // Single colour
                        //else {
                        //    $kmlColour = self::rgb2bgr($this->colour);
                        //}
                    } else {
                        $kmlColour = self::rgb2bgr($this->noDataColour);
                    }
                    if ($this->outlinecolor == "") {
                        $outline = 0;
                    } else {
                        $outline = 1;
                    }
                    switch ($this->mapType) {
                        case "choropleth":
                            $kmlFeature = "          <Style>" . PHP_EOL . "            <PolyStyle>" . PHP_EOL . "              <color>{$kmlColour}</color>" . PHP_EOL . "            </PolyStyle>" . PHP_EOL . "          </Style>" . PHP_EOL;
                            $kmlFeature .= self::wkt2kml($feature['wkt'], 0);
                            break;
                        case "prism":
                            $altitude = intval($value * ($this->maxHeight / $this->maxValue));
                            if ($this->colourType == 'scale') {
                                $kmlFeature = "          <Style>" . PHP_EOL . "            <PolyStyle>" . PHP_EOL . "              <color>{$kmlColour}</color>" . PHP_EOL . "            </PolyStyle>" . PHP_EOL . "          </Style>" . PHP_EOL;
                            }
                            $kmlFeature .= self::wkt2kml($feature['wkt'], $altitude) . PHP_EOL;
                            break;
                        case "bar":
                            if ($value != null) {
                                $altitude = intval($value * ($this->maxHeight / $this->maxValue));
                                if ($this->colourType == 'scale') {
                                    $kmlFeature = "          <Style>" . PHP_EOL . "            <PolyStyle>" . PHP_EOL . "              <color>{$kmlColour}</color>" . PHP_EOL . "              <outline>" . $outline . "</outline>" . PHP_EOL . "            </PolyStyle>" . PHP_EOL;
                                    if ($this->outlinecolor != "") {
                                        $kmlFeature .= "<LineStyle>" . PHP_EOL . "        <color>" . $this->outlinecolor . "</color>" . PHP_EOL . "      </LineStyle>" . PHP_EOL;
                                    }
                                    $kmlFeature .= "          </Style>" . PHP_EOL;
                                }
                                $kmlFeature .= self::kmlSymbolCalculator($longitude, $latitude, $this->barSize, $this->numvertices, $altitude);
                            }
                            break;
                        case "symbol":
                            if ($value != null) {
                                switch ($this->symbolType) {
                                    case 'im$z = new ZipArchive();
									$z->open("test.zip", ZIPARCHIVE::CREATE);
									folderToZip("storeThisFolder", $z);
									$z->close();age':
                                        //$symbolSize = round(self::getSymbolSize($value, $this->symbolShape),2);
                                        $symbolSize = round($this->symbolMaxSize * sqrt($value / $this->maxValue), 2);
                                        $kmlFeature = "          <Style>" . PHP_EOL . "            <IconStyle>" . PHP_EOL . "              <scale>{$symbolSize}</scale>" . PHP_EOL . "              <color>{$kmlColour}</color>" . PHP_EOL . "            </IconStyle>" . PHP_EOL . "          </Style>" . PHP_EOL;
                                        $kmlFeature .= "          <LookAt>" . PHP_EOL . "            <longitude>{$longitude}</longitude>" . PHP_EOL . "            <latitude>{$latitude}</latitude>" . PHP_EOL . "            <altitude>0</altitude>" . PHP_EOL . "            <range>3200000</range>" . PHP_EOL . "            <altitudeMode>clampToGround</altitudeMode>" . PHP_EOL . "          </LookAt>" . PHP_EOL . "          <Point>" . PHP_EOL . "            <coordinates>{$longitude},{$latitude},0</coordinates>" . PHP_EOL . "          </Point>" . PHP_EOL;
                                        break;
                                    case 'polygon':
                                        //$symbolSize = intval(self::getSymbolSize($value, $this->symbolShape));
                                        $symbolSize = intval($this->symbolMaxSize * sqrt($value / $this->maxValue) * 70000);
                                        if ($this->colourType == 'scale') {
                                            $kmlFeature = "          <Style>" . PHP_EOL . "            <PolyStyle>" . PHP_EOL . "              <color>{$kmlColour}</color>" . PHP_EOL . "            </PolyStyle>" . PHP_EOL . "          </Style>" . PHP_EOL;
                                        }
                                        $kmlFeature .= self::kmlSymbolCalculator($longitude, $latitude, $symbolSize, $this->symbolVertices, 0);
                                        break;
                                    case 'collada':
                                        //$symbolSize = intval(self::getSymbolSize($value, $this->symbolShape));
                                        $symbolSize = intval($this->symbolMaxSize * pow($value / $this->maxValue, 1 / 3) * 20000);
                                        $class = '';
                                        // Single colour
                                        if ($this->colourType == 'scale') {
                                            $class = self::getClass($value);
                                        }
                                        $altitude = $symbolSize;
                                        // Used for label placement
                                        $kmlFeature = "          <Model>" . PHP_EOL . "            <altitudeMode>absolute</altitudeMode>" . PHP_EOL . "            <Location>" . PHP_EOL . "              <longitude>{$longitude}</longitude>" . PHP_EOL . "              <latitude>{$latitude}</latitude>" . PHP_EOL . "              <altitude>0</altitude>" . PHP_EOL . "            </Location>" . PHP_EOL . "            <Scale>" . PHP_EOL . "              <x>{$symbolSize}</x>" . PHP_EOL . "              <y>{$symbolSize}</y>" . PHP_EOL . "              <z>{$symbolSize}</z>" . PHP_EOL . "            </Scale>" . PHP_EOL . "            <Link>" . PHP_EOL . "              <href>files/object{$class}.dae</href>" . PHP_EOL . "            </Link>" . PHP_EOL . "          </Model>" . PHP_EOL;
                                }
                                // switch
                            }
                            // if
                    }
                    // switch
                    $kmlFeatures .= "        <Placemark>" . PHP_EOL . "          <name>{$name}</name>" . PHP_EOL . "          <visibility>{$visibility}</visibility>" . PHP_EOL . "          <Snippet>{$valueText} ({$year})</Snippet>" . PHP_EOL . "          <styleUrl>#sharedStyle</styleUrl>" . PHP_EOL . $kmlFeature . "        </Placemark>" . PHP_EOL;
                    if ($this->showLabel) {
                        $label = '';
                        if ($this->showNames) {
                            $label = $name;
                        }
                        if ($this->showValues) {
                            $label .= ' ' . $valueLabel;
                        }
                        $kmlLabels .= "          <Placemark>" . PHP_EOL . "            <name>{$label}</name>" . PHP_EOL . "            <visibility>{$visibility}</visibility>" . PHP_EOL . "            <styleUrl>#labelPlacemark</styleUrl>" . PHP_EOL . "            <Point>" . PHP_EOL . "              <altitudeMode>absolute</altitudeMode>" . PHP_EOL . "              <coordinates>{$longitude}, {$latitude}, {$altitude}</coordinates>" . PHP_EOL . "            </Point>" . PHP_EOL . "          </Placemark>" . PHP_EOL;
                    }
                }
                // foreach features
                if ($this->showLabel) {
                    $kmlLabels .= "        </Folder>";
                    $kmlFolder .= $kmlLabels;
                }
                $kmlFolder .= $kmlFeatures;
                $kmlFolder .= "      </Folder>" . PHP_EOL;
            }
            // foreach years
            // Close Years folder
            $kmlFolder .= "    </Folder>" . PHP_EOL;
            // Create logo with title and source and add to archieve
            if ($this->showTitle) {
                $imgBrand = self::mapTitleImage();
                $zip->addFile($imgBrand, 'files/brand.png');
            } else {
                $zip->addFile($this->logo, 'files/brand.png');
            }
            // Add title
            $kml .= "    <ScreenOverlay>" . PHP_EOL . "      <name>Titulo</name>" . PHP_EOL . "      <Icon>" . PHP_EOL . "        <href>" . $url . "/" . basename($imgBrand) . "</href>" . PHP_EOL . "      </Icon>" . PHP_EOL . "      <overlayXY x='0.01' y='0.99' xunits='fraction' yunits='fraction'/>" . PHP_EOL . "      <screenXY x='0.01' y='0.99' xunits='fraction' yunits='fraction'/>" . PHP_EOL . "      <size x='-1' y='-1' xunits='pixels' yunits='pixels'/>" . PHP_EOL . "    </ScreenOverlay>" . PHP_EOL;
            // Add legend
            if ($this->showLegend && $this->colourType == 'scale') {
                $kml .= "    <ScreenOverlay>" . PHP_EOL . "      <name>Legenda</name>" . PHP_EOL . "      <Icon>" . PHP_EOL . "        <href>" . $url . "/" . basename($imgLegenda) . "</href>" . PHP_EOL . "      </Icon>" . PHP_EOL . "      <overlayXY x='0.01' y='0.14' xunits='fraction' yunits='fraction'/>" . PHP_EOL . "      <screenXY x='0.01' y='0.14' xunits='fraction' yunits='fraction'/>" . PHP_EOL . "      <size x='-1' y='-1' xunits='pixels' yunits='pixels'/>" . PHP_EOL . "    </ScreenOverlay>" . PHP_EOL;
            }
            $kml .= $kmlStyles . $kmlFolder;
            $kml .= "  </Document>" . PHP_EOL . "</kml>" . PHP_EOL;
            // Add kml to archieve
            //$zip->addFromString("doc.kml", $kml);
            $zip->addFile($kml, 'doc.kml');
            //edmar
            $zip->output($file);
            //edmar
        }
        if ($download) {
            ob_end_clean();
            //header('Content-Type: application/vnd.google-earth.kml+xml');
            header('Content-Disposition: attachment; filename=' . basename($file));
            print $file;
            exit;
        } else {
            return $url . basename($file);
        }
    }
Exemple #7
0
        break;
    case "EXCLUIATRIBUTOSMEDIDAVARIAVEL":
        $m = new Metaestat();
        $resultado = $m->excluiAtributosMedidaVariavel($id_medida_variavel, $codigo_tipo_regiao, $_GET["identificador_regiao"], $id);
        retornaJSON($resultado);
        exit;
        break;
    case "REGIAO2SHP":
        $m = new Metaestat();
        $shp = $m->regiao2shp($codigo_tipo_regiao);
        include dirname(__FILE__) . "/../../pacotes/kmlmapserver/classes/zip.class.php";
        $handle = fopen($shp . ".shp", "r");
        $contentsshp = fread($handle, filesize($shp . ".shp"));
        fclose($handle);
        $handle = fopen($shp . ".shp", "r");
        $contentsdbf = fread($handle, filesize($shp . ".dbf"));
        fclose($handle);
        $handle = fopen($shp . ".shp", "r");
        $contentsshx = fread($handle, filesize($shp . ".shx"));
        fclose($handle);
        $ziper = new zipfile();
        $ziper->addFile($contentsshp, basename($shp) . '.shp');
        $ziper->addFile($contentsshx, basename($shp) . '.shx');
        $ziper->addFile($contentsdbf, basename($shp) . '.dbf');
        $arq = $shp . ".zip";
        $ziper->output($arq);
        $dirtmp = basename(dirname($arq));
        $d = "/ms_tmp/" . basename($arq);
        echo "<html><script> window.location.assign('{$d}'); </script></html>";
        break;
}
 * so that in the event of an upgrade failure the system can be
 * restored from the backup. 
 *
 * @author     Conor Mac Aoidh <*****@*****.**>
 * @license    http://furasta.org/licence.txt The BSD License
 * @version    1.0
 * @package    admin_settings
 */
if (!defined('AJAX_LOADED') || !defined('AJAX_VERIFIED')) {
    exit;
}
$zip = new zipfile();
$files = scandir(HOME);
function zip_files($files, $dir = '')
{
    global $zip;
    foreach ($files as $file) {
        if ($file == '.' || $file == '..' || $file == 'update.zip' || $file == 'backup') {
            continue;
        }
        if (is_dir(HOME . $dir . $file)) {
            $zip->addDir($dir . $file);
            zip_files(scandir(HOME . $dir . $file), $dir . $file . '/');
        } else {
            $zip->addFile(file_get_contents(HOME . '/' . $dir . $file), $dir . $file);
        }
    }
}
zip_files($files);
$zip->output(USERS_DIR . 'backup/file-backup.zip');
die('ok');
Exemple #9
0
<?php

include "zip.php";
$ziper = new zipfile();
$ziper->addFiles(array("sathish", "251220081742.jpg", "261220081767.jpg"));
//array of files
$ziper->output("zipFile.zip");
Exemple #10
0
function EMAILFILE1($NODE)
{
    /*
    This function is the second phase of the EMAIL File process, this is the
    checking phase and mail process, previously to use this function the SMTP
    variable in PHP.INI must be set acordingly to your ISPs smtp mail server, an
    smtp server something like "smtp.your_ip_server.com"
    (you_ip_server could be anything).
    */
    $CURRENT_FILE = BUILD_PATH($NODE);
    $REAL_FILE = str_replace(DIRECTORY_SEPARATOR . DIRECTORY_SEPARATOR, DIRECTORY_SEPARATOR, DIRNAME($_SESSION['Server_Path'])) . DIRECTORY_SEPARATOR . $CURRENT_FILE;
    // the real full filename of the directory
    PAGEMAIL_HEADER("FILE MANAGER - DIRTREEVIEW", "EMAIL FUNCTION", "BLUE", "WHITE");
    ?>
   <Table WIDTH=100% BORDER=0 CELLPADDING=8 CELLSPACING=0 class=td>
        <Tr>
            <Td VALIGN=top ALIGN=left>
                <Center>
                <Font FACE=tahoma>
                <H3>FileName:
    <?php 
    echo $CURRENT_FILE . "</h3>";
    ?>
            </Td>
        </Tr>
        <Tr>
            <Td>
            <Form NAME="emailfile1" METHOD="post" ENCTYPE="multipart/form-data" ACTION="<?php 
    echo $_SERVER['PHP_SELF'];
    ?>
">
               <Table ALIGN=center BORDER=0 class=td>
                    <Tr>
    <?php 
    $ERROR_FUNCTION = false;
    if (empty($_POST['attached'])) {
        echo "<td><CENTER><h3>No file to send</h3></td>";
        $ERROR_FUNCTION = true;
    } else {
        CLEARSTATCACHE();
        if (!IS_FILE($_POST['attached'])) {
            echo "<td><CENTER><h3>The File has been erased or moved</h3></td>";
            $ERROR_FUNCTION = true;
        } else {
            if (!IS_VALID_EMAIL($_POST['target_email'])) {
                echo "<td><CENTER><h3>The data fields has errors</h3></td>";
                $ERROR_FUNCTION = true;
            } else {
                $prioridad = "3";
                $headers = "From: ";
                $headers .= $_POST['your_name'];
                $headers .= " <";
                $headers .= $_POST['your_email'];
                $headers .= ">\n";
                $headers .= "Reply-To: ";
                $headers .= $_POST['your_name'];
                $headers .= " <";
                $headers .= $_POST['your_email'];
                $headers .= ">\n";
                $headers .= "MIME-Version: 1.0\n";
                $headers .= "Content-Type: multipart/mixed; boundary=\"MIME_BOUNDRY\"\n";
                $headers .= "X-Sender: DIRTREEVIEW 1.0 <";
                $headers .= $_POST['your_email'];
                $headers .= ">\n";
                $headers .= "X-Mailer: DIRTREEVIEW 1.0\n";
                $headers .= "X-Priority: ";
                $headers .= $prioridad;
                $headers .= "\n";
                $headers .= "Return-Path: <";
                $headers .= $_POST['target_email'];
                $headers .= ">\n";
                $headers .= "This is a multi-part message in MIME format.\n";
                $FILE_TO_EMAIL = $_POST['attached'];
                if ($_POST['ACTIONEMAIL'] == "compress") {
                    CLEARSTATCACHE();
                    if (IS_FILE($REAL_FILE)) {
                        $ZIP_FILE = DIRNAME($REAL_FILE) . DIRECTORY_SEPARATOR . SUBSTR(BASENAME($REAL_FILE), 0, STRRPOS(BASENAME($REAL_FILE), ".")) . ".zip";
                        if ($ZIP_FILE != $REAL_FILE) {
                            if (IS_FILE($ZIP_FILE)) {
                                UNLINK($ZIP_FILE);
                            }
                            $FILE_TO_ZIP[1] = $REAL_FILE;
                            //include_once("dirtreezip1.inc.php");
                            $ziper = new zipfile();
                            $ziper->addFiles($FILE_TO_ZIP);
                            $ziper->output($ZIP_FILE);
                            if (IS_FILE($ZIP_FILE)) {
                                $FILE_TO_EMAIL = $ZIP_FILE;
                            }
                        }
                    }
                }
                $fp = fopen($FILE_TO_EMAIL, "r");
                $str = fread($fp, filesize($FILE_TO_EMAIL));
                $str = chunk_split(base64_encode($str));
                $fp = fclose($fp);
                $blankline = " \r\n";
                $tmp_message = "Hi " . $_POST['target_name'];
                $tmp_message .= $blankline;
                $tmp_message .= $blankline;
                $tmp_message .= "I'am " . $_POST['your_name'] . " and I send you this message and the attached file";
                $tmp_message .= $blankline;
                $tmp_message .= $blankline;
                $tmp_message .= "Message";
                $tmp_message .= $blankline;
                $tmp_message .= $blankline;
                $tmp_message .= "=======";
                $tmp_message .= $blankline;
                $tmp_message .= $blankline;
                $tmp_message .= $_POST['email_message'];
                $message = "--MIME_BOUNDRY\n";
                $message .= "Content-Type: text/plain; charset=\"iso-8859-1\"\n";
                $message .= "Content-Transfer-Encoding: quoted-printable\n";
                $message .= "\n";
                $message .= $tmp_message;
                $message .= "\n";
                $message .= "--MIME_BOUNDRY\n";
                $message .= "Content-Type: application/octet-stream; name=";
                $message .= basename($FILE_TO_EMAIL);
                $message .= "\n";
                $message .= "Content-disposition: attachment\n";
                $message .= "Content-Transfer-Encoding: base64\n";
                $message .= "\n";
                $message .= $str;
                $message .= "\n";
                $message .= "\n";
                $message .= "--MIME_BOUNDRY--\n";
                if (!mail($_POST['target_email'], $_POST['matter'], $message, $headers)) {
                    echo "<td><CENTER><h3>ERROR : email has not been sent, please try it again</h3></td>";
                    $ERROR_FUNCTION = true;
                } else {
                    echo "<td><CENTER><h3>The file " . $FILE_TO_EMAIL . " has been sent succesfully</h3></td>";
                }
                if ($_POST['ACTIONEMAIL'] == "compress") {
                    if ($ZIP_FILE != $REAL_FILE) {
                        if (IS_FILE($ZIP_FILE)) {
                            UNLINK($ZIP_FILE);
                        }
                    }
                    unset($_POST['ACTIONEMAIL']);
                }
            }
        }
    }
    ?>
                    </Tr>
                    <Input TYPE="hidden" NAME="FILE_EXTENSION" VALUE="<?php 
    echo $_SESSION['File_Extension'];
    ?>
">
                    <Input TYPE="hidden" NAME="NODE" VALUE="<?php 
    echo $NODE;
    ?>
">
    <?php 
    if ($ERROR_FUNCTION) {
        ?>
                    <Input TYPE="hidden" NAME="ACTION" VALUE="">
                    <Tr>
                        <Td><Center><Input TYPE="Submit" NAME="emailfileform3a" VALUE="    Cancel   "></Td>
    <?php 
    } else {
        ?>
                    <Input TYPE="hidden" NAME="ACTION" VALUE="">
                    <Tr>
                        <Td><Center><Input TYPE="Submit" NAME="emailfileform3b" VALUE="    Accept   "></Td>
    <?php 
    }
    ?>
                    </Tr>
                </Table>
            </Form>
            </Td>
        </Tr>
   </Table>
   <?php 
    PAGE_FOOTER("BLUE", "WHITE");
    exit;
}