getDataPath() 공개 정적인 메소드

Determine the Elgg data directory with trailing slash, save it to config, and return it
public static getDataPath ( ) : string
리턴 string
예제 #1
0
 /**
  * {@inheritdoc}
  */
 public function getDataPath()
 {
     if (!isset($this->config->dataroot)) {
         \Elgg\Application::getDataPath();
     }
     return $this->config->dataroot;
 }
예제 #2
0
    header("HTTP/1.1 304 Not Modified");
    exit;
}
$size = "medium";
if (!empty($_GET['size'])) {
    $size = strtolower($_GET['size']);
    if (!in_array($size, array('large', 'medium', 'small', 'tiny', 'master', 'topbar'))) {
        $size = "medium";
    }
}
$initialRoot = dirname(dirname(__DIR__));
$backupRoot = dirname(dirname(dirname($initialRoot)));
if (!(include_once "{$initialRoot}/vendor/autoload.php")) {
    require_once "{$backupRoot}/vendor/autoload.php";
}
$data_root = \Elgg\Application::getDataPath();
$locator = new \Elgg\EntityDirLocator($guid);
$user_path = $data_root . $locator->getPath();
$filename = $user_path . "profile/{$guid}{$size}.jpg";
$filesize = @filesize($filename);
if ($filesize) {
    header("Content-type: image/jpeg");
    header('Expires: ' . gmdate('D, d M Y H:i:s \\G\\M\\T', strtotime("+6 months")), true);
    header("Pragma: public");
    header("Cache-Control: public");
    header("Content-Length: {$filesize}");
    header("ETag: \"{$etag}\"");
    readfile($filename);
    exit;
}
// something went wrong so load engine and try to forward to default icon
예제 #3
0
/**
 * Loads configuration related to Elgg as an application
 *
 * This runs on the engine boot and loads from the datalists database table.
 * 
 * @see _elgg_engine_boot()
 * 
 * @access private
 */
function _elgg_load_application_config()
{
    _elgg_services()->timer->begin([__FUNCTION__]);
    global $CONFIG;
    $install_root = Directory\Local::root();
    $defaults = array('path' => $install_root->getPath("/"), 'plugins_path' => $install_root->getPath("mod") . "/", 'language' => 'en', 'pluginspath' => $install_root->getPath("mod") . "/");
    foreach ($defaults as $name => $value) {
        if (empty($CONFIG->{$name})) {
            $CONFIG->{$name} = $value;
        }
    }
    $GLOBALS['_ELGG']->view_path = \Elgg\Application::elggDir()->getPath("/views/");
    // set cookie values for session and remember me
    _elgg_configure_cookies($CONFIG);
    if (!is_memcache_available()) {
        _elgg_services()->datalist->loadAll();
    }
    // make sure dataroot gets set
    \Elgg\Application::getDataPath();
    if (!$GLOBALS['_ELGG']->simplecache_enabled_in_settings) {
        $simplecache_enabled = datalist_get('simplecache_enabled');
        $CONFIG->simplecache_enabled = $simplecache_enabled === false ? 1 : $simplecache_enabled;
    }
    $system_cache_enabled = datalist_get('system_cache_enabled');
    $CONFIG->system_cache_enabled = $system_cache_enabled === false ? 1 : $system_cache_enabled;
    // needs to be set before system, init for links in html head
    $CONFIG->lastcache = (int) datalist_get("simplecache_lastupdate");
    $GLOBALS['_ELGG']->i18n_loaded_from_cache = false;
    // this must be synced with the enum for the entities table
    $CONFIG->entity_types = array('group', 'object', 'site', 'user');
    _elgg_services()->timer->end([__FUNCTION__]);
}
예제 #4
0
list($guid, $type, $filename) = explode('/', trim($_GET['__uri'], '/'));
$guid = (int) $guid;
if (!$guid) {
    $response = new Response('', Response::HTTP_NOT_FOUND);
    $response->send();
}
$last_cache = empty($_GET['lastcache']) ? 0 : (int) $_GET['lastcache'];
// icontime
// If is the same ETag, content didn't changed.
$etag = $last_cache . $guid;
if (isset($_SERVER['HTTP_IF_NONE_MATCH']) && trim($_SERVER['HTTP_IF_NONE_MATCH']) == "\"{$etag}\"") {
    $response = new Response('', Response::HTTP_NOT_MODIFIED);
    $response->send();
}
// @todo: validate hmac
$hmac = $_GET['hmac'];
$data_root = Application::getDataPath();
$locator = new EntityDirLocator($guid);
$full_path = "{$data_root}{$locator->getPath()}media/{$type}/{$filename}";
if (!file_exists($full_path)) {
    header("HTTP/1.1 404 Not Found");
    exit;
}
$contents = file_get_contents($full_path);
$response = new Response($contents);
$d = $response->headers->makeDisposition(ResponseHeaderBag::DISPOSITION_INLINE, basename($full_path));
$response->headers->set('Content-Disposition', $d);
$response->headers->set('Content-Type', 'image/jpeg');
$response->headers->set('Expires', gmdate('D, d M Y H:i:s \\G\\M\\T', strtotime("+6 months")));
$response->headers->set('ETag', $etag);
$response->send();