function kfmFile() { if (func_num_args() == 1) { $this->id = (int) func_get_arg(0); parent::__construct(); $filedata = db_fetch_row("SELECT id,name,directory FROM " . KFM_DB_PREFIX . "files WHERE id=" . $this->id); if ($filedata === false) { return false; } // does not exist in database $this->name = $filedata['name']; $this->parent = $filedata['directory']; $dir = kfmDirectory::getInstance($this->parent); $this->dir = $dir; $this->directory = $dir->path(); $this->path = $this->directory . '/' . $filedata['name']; if (!$this->exists()) { $this->delete(); return false; } $this->writable = $this->isWritable(); $this->ctime = filemtime($this->path) + $GLOBALS['kfm_server_hours_offset'] * 3600; $this->modified = strftime($GLOBALS['kfm']->setting('date_format') . ' ' . $GLOBALS['kfm']->setting('time_format'), filemtime($this->path)); require_once $_SERVER['DOCUMENT_ROOT'] . '/ww.incs/Core_getMimeType.php'; $mimetype = Core_getMimeType($this->path); $pos = strpos($mimetype, ';'); $this->mimetype = $pos === false ? $mimetype : substr($mimetype, 0, $pos); $this->type = trim(substr(strstr($this->mimetype, '/'), 1)); } }
if (isset($_SERVER['HTTP_USER_AGENT']) && strstr($_SERVER['HTTP_USER_AGENT'], 'MSIE')) { $name = preg_replace('/\\./', '%2e', $name, substr_count($name, '.') - 1); } set_time_limit(0); header('Cache-Control: max-age = 2592000'); header('Expires-Active: On'); header('Expires: Fri, 1 Jan 2500 01:01:01 GMT'); header('Pragma:'); $filesize = filesize($path); header('Content-Length: ' . (string) filesize($path)); if (isset($_GET['forcedownload'])) { header('Content-Type: force/download'); header('Content-Disposition: attachment; filename="' . $name . '"'); } else { require_once $_SERVER['DOCUMENT_ROOT'] . '/ww.incs/Core_getMimeType.php'; header('Content-Type: ' . Core_getMimeType($extension)); } header('Content-Transfer-Encoding: binary'); // } if (!file_exists($path)) { exit; } if ($file = fopen($path, 'rb')) { // send file while (!feof($file) && connection_status() == 0) { print fread($file, 1024 * 8); flush(); } fclose($file); } if (file_exists('api/log_retrieved_file.php')) {
} function CSS_colourCode($code) { if ($code[0] == '#') { $code = substr($code, 1, strlen($code) - 1); } if (strlen($code) == 3) { $chars = str_split($code); foreach ($chars as $k => $v) { $chars[$k] = $v . $v; } $code = join('', $chars); } return $code; } $mimetype = Core_getMimeType(preg_replace('/.*\\./', '', $file)); if ($mimetype == 'text/css') { $parsed = USERBASE . '/ww.cache/css_' . str_replace('/', '|', $file); if (!file_exists($parsed) || filectime($parsed) < filectime($file)) { $f = file_get_contents($file); // { cool stuff preg_match_all('/\\.([a-z\\-]*)\\(([^\\)]*)\\);/', $f, $matches); for ($i = 0; $i < count($matches[0]); ++$i) { switch ($matches[1][$i]) { case 'linear-gradient': // { $bits = preg_split('/, */', $matches[2][$i]); $colours = array(); foreach ($bits as $k => $v) { if (strpos($v, '#') === false) { continue;