public function testGetPath()
 {
     $size = Elgg_EntityDirLocator::BUCKET_SIZE;
     foreach ($this->guids as $guid) {
         $test = new Elgg_EntityDirLocator($guid);
         // we start at 1 since there are no guids of 0
         if ($guid < 5000) {
             $path = "1/{$guid}/";
         } elseif ($guid < 10000) {
             $path = "5000/{$guid}/";
         } elseif ($guid < 15000) {
             $path = "10000/{$guid}/";
         } elseif ($guid < 20000) {
             $path = "15000/{$guid}/";
         }
         $this->assertSame($path, $test->getPath());
     }
 }
Esempio n. 2
0
     $result = mysql_query($q, $mysql_dblink);
     if ($result) {
         $row = mysql_fetch_object($result);
         while ($row) {
             if ($row->name == 'dataroot') {
                 $data_root = $row->value;
             } elseif ($row->name == 'path') {
                 $elgg_path = $row->value;
             }
             $row = mysql_fetch_object($result);
         }
     }
     @mysql_close($mysql_dblink);
     if (isset($data_root) && isset($elgg_path)) {
         require_once $engine_dir . "classes/Elgg/EntityDirLocator.php";
         $locator = new Elgg_EntityDirLocator($guid);
         $user_path = $data_root . $locator->getPath();
         $filename = $user_path . "profile/{$guid}{$size}.jpg";
         $size = @filesize($filename);
         if ($size) {
             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: {$size}");
             header("ETag: \"{$etag}\"");
             readfile($filename);
             exit;
         }
     }
 }
Esempio n. 3
0
/**
 * Clears tree html cache
 *
 * @param ElggEntity $entity the root entity to flush the cache for
 *
 * @return void
 */
function pages_tools_flush_tree_html_cache(ElggEntity $entity)
{
    if (!$entity instanceof ElggEntity) {
        return;
    }
    $locator = new Elgg_EntityDirLocator($entity->getGUID());
    $cache_dir = elgg_get_data_path() . $locator->getPath() . 'tree_cache/';
    $dh = opendir($cache_dir);
    if (empty($dh)) {
        return;
    }
    while (($filename = readdir($dh)) !== false) {
        // make sure we have a file
        if (!is_file($cache_dir . $filename)) {
            continue;
        }
        unlink($cache_dir . $filename);
    }
}
Esempio n. 4
0
 /**
  * Construct a file path matrix for an entity.
  *
  * @param int $guid The guid of the entity to store the data under.
  *
  * @return str The path where the entity's data will be stored relative to the data dir.
  * @deprecated 1.9 Use Elgg_EntityDirLocator()
  */
 protected function makeFileMatrix($guid)
 {
     elgg_deprecated_notice('ElggDiskFilestore::makeFileMatrix() is deprecated by Elgg_EntityDirLocator', 1.9);
     $entity = get_entity($guid);
     if (!$entity instanceof ElggEntity) {
         return false;
     }
     $dir = new Elgg_EntityDirLocator($guid);
     return $dir->getPath();
 }
Esempio n. 5
0
            if ($result) {
                $row = mysql_fetch_object($result);
                while ($row) {
                    if ($row->name == "dataroot") {
                        $data_root = $row->value;
                    }
                    $row = mysql_fetch_object($result);
                }
            }
            @mysql_close($mysql_dblink);
        }
    }
}
if (isset($data_root)) {
    require_once $engine_dir . "classes/Elgg/EntityDirLocator.php";
    $locator = new Elgg_EntityDirLocator($guid);
    $entity_path = $data_root . $locator->getPath();
    $filename = $entity_path . "groups/{$group_guid}{$size}.jpg";
    $filecontents = @file_get_contents($filename);
    // try fallback size
    if (!$filecontents && $size !== "medium") {
        $filename = $entity_path . "groups/{$group_guid}medium.jpg";
        $filecontents = @file_get_contents($filename);
    }
    if ($filecontents) {
        $filesize = strlen($filecontents);
        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}");