summaryrefslogtreecommitdiffstats
path: root/avatar.php
diff options
context:
space:
mode:
Diffstat (limited to 'avatar.php')
-rw-r--r--avatar.php36
1 files changed, 36 insertions, 0 deletions
diff --git a/avatar.php b/avatar.php
new file mode 100644
index 00000000000..1134dc2e710
--- /dev/null
+++ b/avatar.php
@@ -0,0 +1,36 @@
+<?php
+
+require_once 'lib/base.php';
+
+$mode = \OC_Avatar::getMode();
+if ($mode === "none") {
+ exit();
+}
+
+if (isset($_GET['user'])) {
+ //SECURITY TODO does this fully eliminate directory traversals?
+ $user = stripslashes($_GET['user']);
+} else {
+ $user = false;
+}
+
+if (isset($_GET['size']) && ((int)$_GET['size'] > 0)) {
+ $size = (int)$_GET['size'];
+ if ($size > 2048) {
+ $size = 2048;
+ }
+} else {
+ $size = 64;
+}
+
+
+$image = \OC_Avatar::get($user, $size);
+
+if ($image instanceof \OC_Image) {
+ $image->show();
+} elseif (is_string($image)) { // Gravatar alike services
+ header("Location: ".$image);
+} else {
+ $image = \OC_Avatar::getDefaultAvatar($size);
+ $image->show();
+}