19     $handle = @opendir($dir);
 
   20     while ($file = @readdir($handle)) {
 
   21         if (in_array($file, array(
'.', 
'..'))) {
 
   24         if (is_dir($dir . $file)) {
 
   25             $total_size = 
get_dir_size($dir . $file . 
"/", $total_size);
 
   27             $total_size += filesize($dir . $file);
 
   54     if ($file->getError() !== 0) {
 
   58     return file_get_contents($file->getPathname());
 
   76 $square = 
false, $upscale = 
false) {
 
   87     if ($file->getError() !== 0) {
 
   92         $maxheight, $square, 0, 0, 0, 0, $upscale);
 
  120     if ($imgsizearray == 
false) {
 
  124     $width = $imgsizearray[0];
 
  125     $height = $imgsizearray[1];
 
  127     $accepted_formats = array(
 
  128         'image/jpeg' => 
'jpeg',
 
  129         'image/pjpeg' => 
'jpeg',
 
  130         'image/png' => 
'png',
 
  131         'image/x-png' => 
'png',
 
  136     $load_function = 
"imagecreatefrom" . $accepted_formats[$imgsizearray[
'mime']];
 
  137     if (!is_callable($load_function)) {
 
  143         'maxwidth' => $maxwidth,
 
  144         'maxheight' => $maxheight,
 
  146         'upscale' => $upscale,
 
  158     $original_image = call_user_func($load_function, 
$input_name);
 
  159     if (!$original_image) {
 
  164     $new_image = imagecreatetruecolor(
$params[
'newwidth'], 
$params[
'newheight']);
 
  170     imagefilledrectangle(
 
  172         imagecolorallocate($new_image, 255, 255, 255)
 
  175     $rtn_code = imagecopyresampled( $new_image,
 
  191     imagejpeg($new_image, 
null, 90);
 
  192     $jpeg = ob_get_clean();
 
  194     imagedestroy($new_image);
 
  195     imagedestroy($original_image);
 
  245         $selection_width = 
$x2 - 
$x1;
 
  246         $selection_height = 
$y2 - 
$y1;
 
  249         $selection_width = $width;
 
  250         $selection_height = $height;
 
  258         if ($crop == 
true && $selection_width != $selection_height) {
 
  263         $new_width = $new_height = min($maxwidth, $maxheight);
 
  266         $selection_width = $selection_height = min($selection_width, $selection_height);
 
  276             $widthoffset = floor(($width - $selection_width) / 2);
 
  277             $heightoffset = floor(($height - $selection_height) / 2);
 
  281         $new_width = $maxwidth;
 
  282         $new_height = $maxheight;
 
  285         if (($selection_height / (
float)$new_height) > ($selection_width / (
float)$new_width)) {
 
  286             $new_width = floor($new_height * $selection_width / (
float)$selection_height);
 
  288             $new_height = floor($new_width * $selection_height / (
float)$selection_width);
 
  301     if (!$upscale && ($selection_height < $new_height || $selection_width < $new_width)) {
 
  304             $new_height = $selection_height;
 
  305             $new_width = $selection_width;
 
  307             if ($selection_height < $new_height && $selection_width < $new_width) {
 
  308                 $new_height = $selection_height;
 
  309                 $new_width = $selection_width;
 
  315         'newwidth' => $new_width,
 
  316         'newheight' => $new_height,
 
  317         'selectionwidth' => $selection_width,
 
  318         'selectionheight' => $selection_height,
 
  319         'xoffset' => $widthoffset,
 
  320         'yoffset' => $heightoffset,
 
  335     if (!$file || !$file->canEdit()) {
 
  339     $thumbnail = $file->thumbnail;
 
  340     $smallthumb = $file->smallthumb;
 
  341     $largethumb = $file->largethumb;
 
  343         $delfile = new \ElggFile();
 
  344         $delfile->owner_guid = $file->owner_guid;
 
  345         $delfile->setFilename($thumbnail);
 
  349         $delfile = new \ElggFile();
 
  350         $delfile->owner_guid = $file->owner_guid;
 
  351         $delfile->setFilename($smallthumb);
 
  355         $delfile = new \ElggFile();
 
  356         $delfile->owner_guid = $file->owner_guid;
 
  357         $delfile->setFilename($largethumb);
 
  361     return $file->delete();
 
  373     if (!$handle = opendir($directory)) {
 
  378     while (($file = readdir($handle)) !== 
false) {
 
  379         if (in_array($file, array(
'.', 
'..'))) {
 
  383         $path = 
"$directory/$file";
 
  397     return rmdir($directory);
 
  416     $dir = new \Elgg\EntityDirLocator(
$entity->guid);
 
  418     if (file_exists($file_path)) {
 
  462     $params = array(
'mime_type' => $mime_type);
 
  477     if (isset(
$CONFIG->dataroot)) {
 
  506     $info = pathinfo($original_filename);
 
  509     $office_formats = array(
'docx', 
'xlsx', 
'pptx');
 
  510     if ($mime_type == 
"application/zip" && in_array($info[
'extension'], $office_formats)) {
 
  511         switch ($info[
'extension']) {
 
  513                 $mime_type = 
"application/vnd.openxmlformats-officedocument.wordprocessingml.document";
 
  516                 $mime_type = 
"application/vnd.openxmlformats-officedocument.spreadsheetml.sheet";
 
  519                 $mime_type = 
"application/vnd.openxmlformats-officedocument.presentationml.presentation";
 
  525     if ($mime_type == 
"application/vnd.ms-office" && $info[
'extension'] == 
"ppt") {
 
  526         $mime_type = 
"application/vnd.ms-powerpoint";
 
  547     switch ($mime_type) {
 
  548         case "application/msword":
 
  549         case "application/vnd.openxmlformats-officedocument.wordprocessingml.document":
 
  550         case "application/pdf":
 
  553         case "application/ogg":
 
  557     if (preg_match(
'~^(audio|image|video)/~', $mime_type, 
$m)) {
 
  560     if (0 === strpos($mime_type, 
'text/') || 
false !== strpos($mime_type, 
'opendocument')) {
 
  580     $value[] = 
"{$CONFIG->path}engine/tests/ElggCoreFilestoreTest.php";
 
  585     $events->registerHandler(
'init', 
'system', 
'_elgg_filestore_init', 100);
 
if(! $owner||!($owner instanceof ElggUser)||! $owner->canEdit()) $x1
 
elgg_get_config($name, $site_guid=0)
Get an Elgg configuration value.
 
$guid
Removes an admin notice.
 
elgg_extract($key, $array, $default=null, $strict=true)
Checks for $array[$key] and returns its value if it exists, else returns $default.
 
elgg_register_plugin_hook_handler($hook, $type, $callback, $priority=500)
 
elgg_trigger_plugin_hook($hook, $type, $params=null, $returnvalue=null)
 
get_entity($guid)
Loads and returns an entity object from a guid.
 
_elgg_filestore_detect_mimetype($hook, $type, $mime_type, $params)
Fix MIME type detection for Microsoft zipped formats.
 
elgg_get_file_simple_type($mime_type)
Returns the category of a file from its MIME type.
 
_elgg_filestore_test($hook, $type, $value)
Unit tests for files.
 
_elgg_clear_entity_files($entity)
Removes all entity files.
 
get_resized_image_from_uploaded_file($input_name, $maxwidth, $maxheight, $square=false, $upscale=false)
Gets the jpeg contents of the resized version of an uploaded image (Returns false if the uploaded fil...
 
get_default_filestore()
Return the default filestore.
 
set_default_filestore(\ElggFilestore $filestore)
Set the default filestore for the system.
 
get_image_resize_parameters($width, $height, $options)
Calculate the parameters for resizing an image.
 
_elgg_filestore_init()
Initialize the file library.
 
get_dir_size($dir, $total_size=0)
Get the size of the specified directory.
 
delete_directory($directory)
Delete a directory and all its contents.
 
_elgg_filestore_parse_simpletype($hook, $type, $simple_type, $params)
Parse a file category of file from a MIME type.
 
get_resized_image_from_existing_file($input_name, $maxwidth, $maxheight, $square=false, $x1=0, $y1=0, $x2=0, $y2=0, $upscale=false)
Gets the jpeg contents of the resized version of an already uploaded image (Returns false if the file...
 
$DEFAULT_FILE_STORE
Variable holding the default datastore.
 
get_uploaded_file($input_name)
Get the contents of an uploaded file.
 
file_delete($guid)
Delete an \ElggFile file.