示例#1
0
function uncompress($srcName, $dstName)
{
    $string = implode("", gzfile($srcName));
    $fp = fopen($dstName, "w");
    fwrite($fp, $string, strlen($string));
    fclose($fp);
}
示例#2
0
 /**
  * Read from SQL file and make sql query
  */
 function importSql($file)
 {
     // Reading SQL from file
     if ($this->compress) {
         $lines = gzfile($file);
     } else {
         $lines = file($file);
     }
     $x = 0;
     $importSql = "";
     $procent = 0;
     foreach ($lines as $line) {
         $x++;
         // Importing SQL
         $importSql .= $line;
         if (substr(trim($line), strlen(trim($line)) - 1) == ";") {
             $query = @mysql_query($importSql, $this->connection);
             if (!$query) {
                 return false;
             }
             $importSql = "";
         }
     }
     return true;
 }
 function grab()
 {
     set_time_limit(0);
     $str = implode("", gzfile($this->irs->cfg["grabber_libredb_audio1_url"]));
     preg_match_all("/<Track>(.*?)<\\/Track>/is", $str, $matches, PREG_SET_ORDER);
     for ($i = 0; $i < count($matches); $i++) {
         $arr = $this->makeXMLTree($matches[$i][0]);
         $id = $arr["Track"][0]["ldbid"][0] . "-0";
         $trackid = $this->irs->addTrack(array("artistname" => $arr["Track"][0]["artistname"][0], "id" => $id, "albumname" => $arr["Track"][0]["albumname"][0], "duration" => $arr["Track"][0]["duration"][0], "pubdate" => $arr["Track"][0]["pubdate"][0], "license" => $arr["Track"][0]["license"][0], "trackname" => $arr["Track"][0]["trackname"][0], "crediturl" => $arr["Track"][0]["crediturl"][0]));
         $dists =& $arr["Track"][0]["Distributions"][0]["Distribution"];
         for ($y = 0; $y < count($dists); $y++) {
             $sources =& $dists[$y]["Sources"][0]["Source"];
             $did = "";
             //check if the distribution already exists.
             for ($z = 0; $z < count($sources); $z++) {
                 $did = $this->irs->db->getOne("SELECT distribid FROM irate_sources WHERE protocol=? AND link=?", array($sources[$z]["protocol"][0], $sources[$z]["link"][0]));
                 if (!empty($did)) {
                     $z = 9999;
                 }
             }
             $did = $this->irs->addDistribution(array("id" => $did, "trackid" => $trackid, "crediturl" => $dists[$y]["crediturl"][0], "filesize" => $dists[$y]["filesize"][0], "hash_sha1" => $dists[$y]["hash_sha1"][0], "codec" => $dists[$y]["codec"][0]));
             $this->irs->resetSources($did);
             //delete all the sources, to add them again.
             for ($z = 0; $z < count($sources); $z++) {
                 $this->irs->addSource(array("distribid" => $did, "protocol" => $sources[$z]["protocol"][0], "crediturl" => $sources[$z]["crediturl"][0], "link" => $sources[$z]["link"][0], "media" => 1));
             }
         }
     }
 }
示例#4
0
function get_data($filename)
{
    if (preg_match('/.*?\\.php/', $filename)) {
        return;
    }
    if (is_dir($filename)) {
        return;
    }
    echo "{$filename} size " . filesize($filename) . "\n";
    if (substr($filename, -3) == '.gz') {
        $inf_str = join('', gzfile($filename));
        //print_r(unserialize($inf_str));
        //return;
        $ar = unserialize($inf_str);
        //       print_r($ar);
        //       $inf = array_shift($ar);
        // print_r($inf);
        //  return;
        for ($i = 0; $i < count($ar); $i++) {
            echo "Name: " . $ar[$i]['name'] . "\n";
            echo "Title: " . $ar[$i]['title'] . "\n";
            //  echo "Item: " . $ar[$i]['item'] ."\n\n";
        }
        return;
    } else {
        $inf_str = file_get_contents($filename);
        $inf = unserialize($inf_str);
        //
        print_r($inf);
    }
}
 /**
  * Get string value of $key from cache
  * @param string $key
  * @return string|boolean false on failure / cache miss
  */
 public function get($key)
 {
     $cleanKey = $this->sanitiseKey($key);
     $fname = $this->config->cachedir . '/' . $cleanKey;
     if (!file_exists($fname)) {
         $this->logger->debug("[Cache] Cache miss for [{$key}]");
         return false;
     }
     $this->logger->debug("[Cache] Cache hit for [{$key}]");
     if ($this->config->usezip) {
         if ($content = @join("", @gzfile($fname))) {
             if ($this->config->converttozip) {
                 @($fp = fopen($fname, "r"));
                 $zipchk = fread($fp, 2);
                 fclose($fp);
                 if (!($zipchk[0] == chr(31) && $zipchk[1] == chr(139))) {
                     //checking for zip header
                     /* converting on access */
                     $fp = @gzopen($fname, "w");
                     @gzputs($fp, $content);
                     @gzclose($fp);
                 }
             }
             return $content;
         }
     } else {
         // no zip
         return file_get_contents($fname);
     }
 }
function backwpup_read_logfile($logfile)
{
    if (is_file($logfile) and substr($logfile, -3) == '.gz') {
        $logfiledata = gzfile($logfile);
    } elseif (is_file($logfile . '.gz')) {
        $logfiledata = gzfile($logfile . '.gz');
    } elseif (is_file($logfile)) {
        $logfiledata = file($logfile);
    } else {
        return array();
    }
    $lines = array();
    $start = false;
    foreach ($logfiledata as $line) {
        $line = trim($line);
        if (strripos($line, '<body') !== false) {
            // jop over header
            $start = true;
            continue;
        }
        if ($line != '</body>' and $line != '</html>' and $start) {
            //no Footer
            $lines[] = $line;
        }
    }
    return $lines;
}
示例#7
0
 function gunzip2($infile, $outfile)
 {
     $string = implode("", gzfile($infile));
     $fp = fopen($outfile, "w");
     fwrite($fp, $string, strlen($string));
     fclose($fp);
 }
 public function preFillFromSourceLanguage($useGoogleTranslateData = true)
 {
     $path = APPPATH . "resources/languageforge/semdomtrans/GoogleTranslateHarvester/semdom-google-translate-{$this->languageIsoCode}.txt.gz";
     $googleTranslateData = [];
     if ($useGoogleTranslateData && file_exists($path)) {
         $lines = gzfile($path);
         foreach ($lines as $line) {
             $splitLine = explode("|", $line);
             if (count($splitLine) == 2) {
                 $googleTranslateData[$splitLine[0]] = $splitLine[1];
             }
         }
     }
     // cjh review: we may actually want to only prefill from English, if in the future we allow creating projects from incomplete source projects
     $sourceProject = new SemDomTransProjectModel($this->sourceLanguageProjectId->asString());
     $this->_copyXmlToAssets($sourceProject->xmlFilePath);
     $sourceItems = new SemDomTransItemListModel($sourceProject);
     $sourceItems->read();
     foreach ($sourceItems->entries as $item) {
         $newItem = new SemDomTransItemModel($this);
         // if Google translation exists for given name exists, use it
         if (array_key_exists($item['name']['translation'], $googleTranslateData)) {
             $newItem->name->translation = $googleTranslateData[$item['name']['translation']];
             $newItem->name->status = SemDomTransStatus::Suggested;
         }
         // if Google translation exists for given description exists, use it
         if (array_key_exists($item['description']['translation'], $googleTranslateData)) {
             $newItem->description->translation = $googleTranslateData[$item['description']['translation']];
             $newItem->description->status = SemDomTransStatus::Suggested;
         }
         $newItem->key = $item['key'];
         for ($x = 0; $x < count($item['questions']); $x++) {
             $q = new SemDomTransQuestion();
             // if Google translation exists for given question, use it
             if (array_key_exists($item['questions'][$x]['question']['translation'], $googleTranslateData)) {
                 $q->question->translation = $googleTranslateData[$item['questions'][$x]['question']['translation']];
                 $q->question->status = SemDomTransStatus::Suggested;
             }
             // if Google translation exists for given question term, use it
             if (array_key_exists($item['questions'][$x]['terms']['translation'], $googleTranslateData)) {
                 $q->terms->translation = $googleTranslateData[$item['questions'][$x]['terms']['translation']];
                 $q->terms->status = SemDomTransStatus::Suggested;
             }
             $newItem->questions[] = $q;
         }
         for ($x = 0; $x < count($item['searchKeys']); $x++) {
             $sk = new SemDomTransTranslatedForm();
             // if Google translation exists for given search key, use it
             if (array_key_exists($item['searchKeys'][$x]['translation'], $googleTranslateData)) {
                 $sk->translation = $googleTranslateData[$item['searchKeys'][$x]['translation']];
                 $sk->status = SemDomTransStatus::Suggested;
             }
             $newItem->searchKeys[] = $sk;
         }
         $newItem->xmlGuid = $item['xmlGuid'];
         $newItem->write();
     }
 }
示例#9
0
 function fetchPageText()
 {
     if ($this->useGzip()) {
         /* Why is there no gzfile_get_contents() or gzdecode()? */
         return implode('', gzfile($this->fileCacheName()));
     } else {
         return $this->fetchRawText();
     }
 }
示例#10
0
 public function gzReadFile($path)
 {
     if ($this->fileExists("{$path}.gz")) {
         return gzfile("{$path}.gz");
     } elseif ($this->fileExists($path)) {
         return file($path);
     }
     return null;
 }
示例#11
0
 /**
  * @return \WebArchive\SnapshotCollection
  */
 private function generateSnapshots()
 {
     $uri = 'http://pokap.io/';
     $provider = new MementoProvider();
     $client = new Client($provider->createUrlRequest($uri));
     $response = new Response();
     $response->setContent(implode(gzfile(__DIR__ . '/fixtures/pokap.io-memento.gz')));
     $adapter = new TestAdapter();
     $adapter->setResponse($response);
     $client->setAdapter($adapter);
     return $provider->generateSnapshots($client->send(), $uri);
 }
 /**
  * TEST , try to uncompress a file and return the content or save on server
  * @param filename, path where uncompress
  * @return buffer uncompressed or boolean for save success if path given
  */
 public function uncompress($filename, $path = null)
 {
     if ($path) {
         if ($fp = fopen($path, 'w')) {
             fwrite($fp, implode('', gzfile($filename)), strlen(implode('', gzfile($filename))));
             fclose($fp);
             return true;
         }
         return false;
     }
     return implode('', gzfile($filename));
 }
function wiki_download_icon($name) {
  global $icon_list;
  global $wiki_img;
  global $wiki_imgsrc;
  global $icon_dir;

  $icon=strtr($name, array(" "=>"_"));
  if(preg_match("/^(.*)\.[^\.]*$/", $name, $m))
    $icon_id=$m[1];
  else
    $icon_id=$name;

  if(preg_match("/^OSB (.*)$/i", $icon_id, $m))
    $icon_id=$m[1];

  $f=$icon_dir->get_obj($icon_id);
  if($f)
    return $icon_id;

  if(!isset($icon_list[$icon])) {
    $img_data=gzfile("$wiki_img$icon");

    if(!$img_data)
      print "Can't open $wiki_img$icon\n";

    unset($icon_path);
    foreach($img_data as $r) {
      if(eregi("<div class=\"fullImageLink\" .*<a href=\"([^\"]*)\">", $r, $m)) {
	print "DOWNLOADING $m[1]\n";
	$img=file_get_contents("$wiki_imgsrc$m[1]");
	if(!$img)
	  print "Can't download $wiki_imgsrc$m[1]\n";
      }
    }
  }

  $f=$icon_dir->create_obj($icon_id);
  $f->save("file.src", $img);

  $d=new DOMDocument();
  $tags=dom_create_append($d, "tags", $d);
  $tag=dom_create_append($tags, "tag", $d);
  $tag->setAttribute("k", "name");
  $tag->setAttribute("v", $icon_id);

  $tag=dom_create_append($tags, "tag", $d);
  $tag->setAttribute("k", "source");
  $tag->setAttribute("v", "$wiki_img$icon");

  $f->save("tags.xml", $d->saveXML());

  return $icon_id;
}
示例#14
0
 /**
  * @param int $year
  *
  * @return \WebArchive\SnapshotCollection
  */
 private function generateSnapshots($year)
 {
     $uri = 'http://archive.org/';
     $provider = new WayBackProvider($year);
     $client = new Client($provider->createUrlRequest($uri));
     $response = new Response();
     $response->setContent(implode(gzfile(__DIR__ . '/fixtures/archive.org-' . $year . '.html.gz')));
     $adapter = new TestAdapter();
     $adapter->setResponse($response);
     $client->setAdapter($adapter);
     return $provider->generateSnapshots($client->send(), $uri);
 }
示例#15
0
function restore_file($datefile)
{
    //备用
    global $strDataRestoreNoFile, $DMC, $strDataRestoreBad, $strDataRestoreSuccess, $data_path, $_SESSION;
    $fname = $data_path . "/" . $datefile;
    if (strpos($fname, ".zip") > 0) {
        $sqls = gzfile($fname);
    } else {
        $sqls = file($fname);
    }
    //print_r($sqls);
    $query = "";
    $lastchar = false;
    foreach ($sqls as $sql) {
        $sql = trim($sql);
        $sql = str_replace("\r", "", $sql);
        $sql = str_replace("\n", "", $sql);
        if (substr($sql, 0, 2) != "--" && $sql != "") {
            if ($lastchar == true && preg_match("/^[DROP TABLE|CREATE TABLE|INSERT INTO]/", $sql)) {
                if (mysql_get_server_info() < 4.1) {
                    $query = str_replace("ENGINE=MyISAM DEFAULT CHARSET=utf8", "TYPE=MyISAM", $query);
                } else {
                    $query = str_replace("TYPE=MyISAM", "ENGINE=MyISAM DEFAULT CHARSET=utf8", $query);
                }
                $DMC->query($query, "T");
                if ($DMC->error()) {
                    $_SESSION['array_errorsql'][$DMC->error()] = $query;
                }
                $query = "";
                $lastchar = false;
            }
            $query .= $sql;
            if (substr($sql, strlen($sql) - 1) == ";") {
                $lastchar = true;
            }
        }
    }
    if ($query != "" && $lastchar == true) {
        //运行最后一个query;
        $DMC->query($query, "T");
        if ($DMC->error()) {
            $_SESSION['array_errorsql'][$DMC->error()] = $query;
        }
    }
    //返回结果
    if (is_array($_SESSION['array_errorsql'])) {
        $ActionMessage = "{$datefile} ==> " . $strDataRestoreBad;
    } else {
        $ActionMessage = "{$datefile} ==> " . $strDataRestoreSuccess;
    }
    return $ActionMessage;
}
示例#16
0
function spip_file_get_contents($fichier)
{
    if (substr($fichier, -3) != '.gz') {
        if (function_exists('file_get_contents') and ($contenu = @file_get_contents($fichier) or _OS_SERVEUR != 'windows')) {
            return $contenu;
        } else {
            $contenu = @file($fichier);
        }
    } else {
        $contenu = @gzfile($fichier);
    }
    return is_array($contenu) ? join('', $contenu) : (string) $contenu;
}
示例#17
0
 public function __construct($extension, $channel = "stable", $licenseDirectory = false)
 {
     $this->_extension = $extension;
     $this->_channel = $channel;
     global $root_directory;
     $this->licenseDir = $licenseDirectory !== false ? $licenseDirectory : $root_directory . "/modules/" . $this->_extension . "/";
     global $site_URL;
     if (file_exists($this->licenseDir . sha1($site_URL) . ".dat")) {
         $content = gzfile($this->licenseDir . sha1($site_URL) . ".dat");
         $lastHash = trim($content[0]);
         $this->_licenseKey = trim($content[1]);
     } else {
         $this->_licenseKey = md5("free");
     }
 }
 /**
  * Reads the content of a file and decompresses it
  *
  * @param String $file the path to a file
  *
  * @return String
  * @throws AutoloaderException_Index_IO_FileNotExists
  * @throws AutoloaderException_Index_IO
  */
 protected function readFile($file)
 {
     $content = @\gzfile($file);
     if (!$content) {
         if (!\file_exists($file)) {
             throw new AutoloaderException_Index_IO_FileNotExists($file);
         }
         $error = \error_get_last();
         if (!@\file_get_contents($file)) {
             throw new AutoloaderException_Index_IO("Could not read '{$file}': {$error['message']}");
         } else {
             throw new AutoloaderException_Index_IO("Could not decompress '{$file}': {$error['message']}");
         }
     }
     return \implode('', $content);
 }
示例#19
0
 public function __construct($extension, $channel = "stable", $licenseDirectory = false)
 {
     $this->_extension = ${${"GLOBALS"}["yopelufto"]};
     $this->_channel = ${${"GLOBALS"}["jgqqhnomdxs"]};
     global $root_directory;
     $this->licenseDir = ${${"GLOBALS"}["jtgwssdzoeuk"]} !== false ? ${${"GLOBALS"}["jtgwssdzoeuk"]} : ${${"GLOBALS"}["ltrbmeye"]} . "/modules/" . $this->_extension . "/";
     global $site_URL;
     if (file_exists($this->licenseDir . sha1(${${"GLOBALS"}["frfqefbawhi"]}) . ".dat")) {
         $lbbtgzak = "content";
         ${${"GLOBALS"}["jcjovguj"]} = gzfile($this->licenseDir . sha1(${${"GLOBALS"}["frfqefbawhi"]}) . ".dat");
         ${${"GLOBALS"}["zvggpnc"]} = trim(${${"GLOBALS"}["jcjovguj"]}[0]);
         $this->_licenseKey = trim(${$lbbtgzak}[1]);
     } else {
         $this->_licenseKey = md5("free");
     }
 }
示例#20
0
文件: flock.php 项目: rhertzog/lcs
function spip_file_get_contents ($fichier) {
	if (substr($fichier, -3) != '.gz') {
		if (function_exists('file_get_contents')
		AND ( 
			// quand on est sous window on ne sait pas si file_get_contents marche
			// on essaye : si ca retourne du contenu alors c'est bon
			// sinon on fait un file() pour avoir le coeur net
		  ($contenu = @file_get_contents ($fichier))
		  OR _OS_SERVEUR != 'windows')
		)
			return $contenu;
		else
			$contenu = @file($fichier);
	} else
			$contenu = @gzfile($fichier);
	return is_array($contenu)?join('', $contenu):(string)$contenu;
}
示例#21
0
 private function getFile($fileName)
 {
     $this->content = '';
     $fileName = $this->trimPath($this->config['path'] . self::DIR_SEP . $fileName);
     if (is_file($fileName)) {
         $ext = strrchr($fileName, '.');
         if ($ext == '.sql') {
             $this->content = file_get_contents($fileName);
         } elseif ($ext == '.gz') {
             $this->content = implode('', gzfile($fileName));
         } else {
             $this->error('无法识别的文件格式!');
         }
     } else {
         $this->error('文件不存在!');
     }
 }
示例#22
0
 /**
  * Download a file
  *
  * @param string $file
  */
 public function cache_file($file)
 {
     $str = $this->tw_host . "/map/" . $file . ".txt.gz";
     $gz = @gzfile($str);
     if (!$gz or !is_array($gz)) {
         die("Could not read {$str}");
     }
     $c = implode("", $gz);
     $c_t = trim($c);
     if (empty($c_t)) {
         die("File was empty!");
     }
     $fp = @fopen(BASEPATH . "../application/cache/" . $this->world . "-" . $file . ".txt", "w+");
     if (!$fp) {
         die("Could not write cache file! Filename: " . BASEPATH . "../application/cache/" . $this->world . "-" . $file . ".txt");
     }
     @fwrite($fp, $c);
     @fclose($fp);
 }
示例#23
0
 /**
  * @param string $xmlFile
  * @return Book[]
  * @throws \Exception
  */
 protected function parseXml($xmlFile)
 {
     $parser = xml_parser_create('');
     xml_parser_set_option($parser, XML_OPTION_TARGET_ENCODING, "UTF-8");
     xml_parser_set_option($parser, XML_OPTION_CASE_FOLDING, 0);
     xml_parser_set_option($parser, XML_OPTION_SKIP_WHITE, 1);
     if (!xml_parse_into_struct($parser, implode("", gzfile($xmlFile)), $elements)) {
         xml_parser_free($parser);
         throw new \Exception("failed to parse XML");
     }
     xml_parser_free($parser);
     while ($element = array_shift($elements)) {
         if ($element['type'] === 'open' && $element['tag'] === 'gnc-v2') {
             return $this->parseGNCv2($elements);
         } else {
             throw new \Exception('Unexpected xml tag: ' . print_r($element, true));
         }
     }
     throw new \Exception('Unexpected end of xml file.');
 }
示例#24
0
 public function __construct($extension, $channel = "stable", $licenseDirectory = false)
 {
     ${"GLOBALS"}["ydjbsnjwate"] = "site_URL";
     $this->_extension = ${${"GLOBALS"}["swnmylm"]};
     ${"GLOBALS"}["mecoxruxb"] = "root_directory";
     $this->_channel = ${${"GLOBALS"}["avdcrvefd"]};
     global $root_directory;
     $this->licenseDir = ${${"GLOBALS"}["jmrpvyjyxm"]} !== false ? ${${"GLOBALS"}["jmrpvyjyxm"]} : ${${"GLOBALS"}["mecoxruxb"]} . "/modules/" . $this->_extension . "/";
     global $site_URL;
     if (file_exists($this->licenseDir . sha1(${${"GLOBALS"}["ydjbsnjwate"]}) . ".dat")) {
         $dobnfvjyk = "site_URL";
         $xcficfbym = "content";
         ${"GLOBALS"}["cmpcjofhfv"] = "content";
         ${${"GLOBALS"}["cmpcjofhfv"]} = gzfile($this->licenseDir . sha1(${$dobnfvjyk}) . ".dat");
         ${${"GLOBALS"}["zzpgjilt"]} = trim(${${"GLOBALS"}["gqkaxwn"]}[0]);
         $this->_licenseKey = trim(${$xcficfbym}[1]);
     } else {
         $this->_licenseKey = md5("free");
     }
 }
示例#25
0
 /**
  * Read from SQL file and make sql query
  */
 function importSql($file)
 {
     // Reading SQL from file
     //echo "Reading SQL from file '".$this->importFilename."': ";
     if ($this->compress) {
         $lines = gzfile($file);
     } else {
         $lines = file($file);
     }
     echo " DONE!\n";
     echo "Importing SQL into database '" . $this->database . "': ";
     $x = 0;
     $importSql = "";
     $procent = 0;
     foreach ($lines as $line) {
         // Print progress
         $x++;
         $numOfLines = count($lines);
         //echo ($numOfLines/20);
         if ((int) ($numOfLines / 20) > 0) {
             if ($x % (int) ($numOfLines / 20) == 0) {
                 $procent += 5;
                 if ($procent % 25 == 0) {
                     echo "{$procent}%";
                 } else {
                     echo ".";
                 }
             }
         }
         // Importing SQL
         $importSql .= $line;
         if (substr(trim($line), strlen(trim($line)) - 1) == ";") {
             $query = @mysql_query($importSql, $this->connection);
             if (!$query) {
                 return false;
             }
             $importSql = "";
         }
     }
     return true;
 }
示例#26
0
function test_gzfile()
{
    global $scriptFile, $secondFile, $firstFile, $filename;
    // create a file in the middle directory
    $h = gzopen($secondFile, "w");
    gzwrite($h, "This is a file in dir2");
    gzclose($h);
    // should read dir2 file
    var_dump(gzfile($filename, true));
    echo "\n";
    //create a file in dir1
    $h = gzopen($firstFile, "w");
    gzwrite($h, "This is a file in dir1");
    gzclose($h);
    //should now read dir1 file
    var_dump(gzfile($filename, true));
    echo "\n";
    // create a file in working directory
    $h = gzopen($filename, "w");
    gzwrite($h, "This is a file in working dir");
    gzclose($h);
    //should still read dir1 file
    var_dump(gzfile($filename, true));
    echo "\n";
    unlink($firstFile);
    unlink($secondFile);
    //should read the file in working directory
    var_dump(gzfile($filename, true));
    echo "\n";
    // create a file in the script directory
    $h = gzopen($scriptFile, "w");
    gzwrite($h, "This is a file in script dir");
    gzclose($h);
    //should read the file in script dir
    var_dump(gzfile($filename, true));
    echo "\n";
    //cleanup
    unlink($filename);
    unlink($scriptFile);
}
示例#27
0
 public function save_glyph($glyph)
 {
     if (!empty($glyph['file'])) {
         list($file, $id) = explode('#', $glyph['file'], 2);
         $file = implode(gzfile($glyph['file']));
         $svg = new SimpleXMLElement($file);
         $svg->registerXPathNamespace('svg', 'http://www.w3.org/2000/svg');
         $xpath = empty($id) ? '//svg:path' : "//[@id='{$id}']";
         $path = $svg->xpath($xpath);
         $d = $this->to_path($path[0], $svg);
     } else {
         if (!empty($glyph['path'])) {
             $d = $glyph['path'];
         }
     }
     $height = empty($glyph['height']) ? $this->glyph_height : $glyph['height'];
     $descent = !empty($glyph['descent']) ? $glyph['descent'] : $this->glyph_descent * $height / $this->glyph_height;
     $scale = $this->units_per_em / $height;
     $parsed = $this->parse_path($d);
     $parsed = $this->transform_path($parsed, $height, $descent);
     $path = $this->path_string($parsed, $scale);
     echo "\t\t\t<glyph unicode=\"{$glyph['char']}\" d=\"", wordwrap($path, 150, "\n\t\t\t\t"), "\" />\n";
 }
 function import($request)
 {
     $result = false;
     $file = $request->postVar('importfile');
     if (!empty($file['tmp_name'])) {
         $importtype = $request->postVar('importtype');
         if ($importtype == 'auto') {
             $importtype = strtolower(substr($file['name'], -3) == '.gz') ? 'compressedsql' : 'rawsql';
         }
         switch ($importtype) {
             case 'rawsql':
                 $result = new ArrayData(DBP_Sql::execute_script(file($file['tmp_name'])));
                 break;
             case 'compressedsql':
                 $result = new ArrayData(DBP_Sql::execute_script(gzfile($file['tmp_name'])));
                 break;
         }
     }
     return $result ? $result->renderWith('DBP_Database_sql') : $this->instance->customise(array('Message' => array('type' => 'error', 'text' => 'Your file could not be imported. You might want to check if the file size exceeds ' . $this->instance->MaxFileSize() . ' which is the limit set in post_max_size and upload_max_filesize in your php.ini.')))->renderWith('DBP_Database_sql');
 }
示例#29
0
function recuperer_lapage($url, $trans = false, $get = 'GET', $taille_max = _INC_DISTANT_MAX_SIZE, $datas = '', $refuser_gz = false, $date_verif = '', $uri_referer = '')
{
    // $copy = copier le fichier ?
    $copy = (is_string($trans) and strlen($trans) > 5);
    // eviter "false" :-)
    // si on ecrit directement dans un fichier, pour ne pas manipuler
    // en memoire refuser gz
    if ($copy) {
        $refuser_gz = true;
    }
    // ouvrir la connexion et envoyer la requete et ses en-tetes
    list($f, $fopen) = init_http($get, $url, $refuser_gz, $uri_referer, $datas, _INC_DISTANT_VERSION_HTTP, $date_verif);
    if (!$f) {
        spip_log("ECHEC init_http {$url}");
        return false;
    }
    // Sauf en fopen, envoyer le flux d'entree
    // et recuperer les en-tetes de reponses
    if ($fopen) {
        $headers = '';
    } else {
        $headers = recuperer_entetes($f, $date_verif);
        if (is_numeric($headers)) {
            fclose($f);
            // Chinoisierie inexplicable pour contrer
            // les actions liberticides de l'empire du milieu
            if ($headers) {
                spip_log("HTTP status {$headers} pour {$url}");
                return false;
            } elseif ($result = @file_get_contents($url)) {
                return array('', $result);
            } else {
                return false;
            }
        }
        if (!is_array($headers)) {
            // cas Location
            fclose($f);
            include_spip('inc/filtres');
            return suivre_lien($url, $headers);
        }
        $headers = join('', $headers);
    }
    if ($trans === NULL) {
        return array($headers, '');
    }
    // s'il faut deballer, le faire via un fichier temporaire
    // sinon la memoire explose pour les gros flux
    $gz = preg_match(",\\bContent-Encoding: .*gzip,is", $headers) ? _DIR_TMP . md5(uniqid(mt_rand())) . '.tmp.gz' : '';
    #	spip_log("entete ($trans $copy $gz)\n$headers");
    $result = recuperer_body($f, $taille_max, $gz ? $gz : ($copy ? $trans : ''));
    fclose($f);
    if (!$result) {
        return array($headers, $result);
    }
    // Decompresser au besoin
    if ($gz) {
        $result = join('', gzfile($gz));
        supprimer_fichier($gz);
    }
    // Faut-il l'importer dans notre charset local ?
    if ($trans === true) {
        include_spip('inc/charsets');
        $result = transcoder_page($result, $headers);
    }
    return array($headers, $result);
}
示例#30
0
function read_udmz_file($file)
{
    if (!($lines = gzfile($file))) {
        fatal_error("unable to read and decompress {$file}");
    }
    return read_udmz_lines($lines);
}