Exemplo n.º 1
0
 public function pseudoshareSetUp()
 {
     $registry = Zend_Registry::getInstance();
     $request = $this->getRequest();
     if ($request->getUserParam('username') && !$registry->isRegistered("userInfo")) {
         //avoid calling the DB again for nothing
         if (isset($registry['signedUserInfo']) && $registry['signedUserInfo']['alias'] == $request->getUserParam('username')) {
             $userInfo = $registry['signedUserInfo'];
         } else {
             $people = Ml_Model_People::getInstance();
             $userInfo = $people->getByUsername($request->getUserParam('username'));
         }
         if (!$userInfo) {
             $registry->set("notfound", true);
             throw new Exception("User does not exists.");
         }
         $registry->set("userInfo", $userInfo);
         $registry->set("requestUserParams", $this->getRequest()->getUserParams());
         if ($this->getRequest()->getUserParam("share_id")) {
             $share = Ml_Model_Share::getInstance();
             $shareInfo = $share->getById($this->getRequest()->getUserParam("share_id"));
             if (!$shareInfo) {
                 $registry->set("notfound", true);
                 throw new Exception("Share does not exists.");
             } else {
                 if ($shareInfo['byUid'] != $userInfo['id']) {
                     $registry->set("notfound", true);
                     throw new Exception("Share owned by another user.");
                 }
             }
             $registry->set("shareInfo", $shareInfo);
         }
     }
 }
Exemplo n.º 2
0
 public function deleteAccount($userInfo, $userInfoSerializedHashed)
 {
     $registry = Zend_Registry::getInstance();
     $people = Ml_Model_People::getInstance();
     $share = Ml_Model_Share::getInstance();
     $removeFiles = Ml_Model_RemoveFiles::getInstance();
     $picture = Ml_Model_Picture::getInstance();
     if (!is_array($userInfo) || !isset($userInfo['alias'])) {
         throw new Exception("Invalid userInfo data.");
     }
     //flag set to true when authorized to do so, least security resource
     if (!$registry->isRegistered("canDeleteAccount")) {
         throw new Exception("Not authorized to delete account.");
     }
     if (sha1(serialize($userInfo)) != $userInfoSerializedHashed) {
         throw new Exception("userInfo and serialized data doesn't match.");
     }
     $this->_dbAdapter->beginTransaction();
     try {
         $picture->deleteFiles($userInfo);
         $removeFiles->addFilesGc($userInfo['id'], $userInfo['alias']);
         $this->_dbAdapter->query("INSERT INTO " . $this->_dbAdapter->quoteTableAs($this->_dbTable->getTableName()) . " SELECT id, alias, email, membershipdate, name, private_email, CURRENT_TIMESTAMP as delete_timestamp from people where " . $this->_dbAdapter->quoteInto("id = ?", $userInfo['id']));
         $people->delete($userInfo['id']);
         $this->_dbAdapter->commit();
     } catch (Exception $e) {
         $this->_dbAdapter->rollBack();
         throw $e;
     }
     return true;
 }
Exemplo n.º 3
0
 public function getUserPage($uid, $perPage, $page)
 {
     $share = Ml_Model_Share::getInstance();
     $select = $this->_dbTable->select();
     $select->setIntegrityCheck(false);
     $select->order("E.timestamp DESC");
     $select->from(array('E' => 'favorites'), array("id", "share", "byUid", "timestamp"));
     $select->joinInner("share", "`E`.`share` = `share`.`id`", array("title as share.title", "fileSize as share.fileSize", "short as share.short", "filename as share.filename"));
     $select->joinInner("people as D", "`E`.`byUid` = `D`.`id`", array("name as people.name", "alias as people.alias", "avatarInfo as people.avatarInfo"));
     $select->where("`E`.`uid` = ?", $uid);
     /*
             SELECT
     `E`.`id`,
     `E`.`share`,
     `E`.`byUid`,
     `E`.`timestamp`,
     `share`.`title` as `share.title`,
     `share`.`fileSize` as `share.fileSize`,
     `share`.`short` as `share.short`,
     `share`.`filename` as `share.filename`,
     `D`.`alias` as `people.alias`,
     `D`.`name` as `people.name`,
     `D`.`avatarInfo` as `people.avatarInfo`
     FROM `favorites` AS `E` INNER JOIN `people` as `D` ON `E`.`byUid` = `D`.`id` INNER JOIN `share` ON `E`.`share` = `share`.`id`
     WHERE `E`.`uid` = '33' ORDER BY `E`.`timestamp` DESC
     */
     $paginator = Zend_Paginator::factory($select);
     $paginator->setCurrentPageNumber($page);
     $paginator->setItemCountPerPage($perPage);
     return $paginator;
 }
Exemplo n.º 4
0
 public function statusAction()
 {
     $this->_helper->verifyIdentity();
     $registry = Zend_Registry::getInstance();
     $userInfo = $registry->get("authedUserInfo");
     $share = Ml_Model_Share::getInstance();
     $uploadStatus = $share->getUploadStatus($userInfo['id']);
     $doc = new Ml_Model_Dom();
     $doc->formatOutput = true;
     $rootElement = $doc->createElement("user");
     $doc->appendChild($rootElement);
     $rootElement->appendChild($doc->newTextAttribute('id', $userInfo['id']));
     $usernameElement = $doc->createElement("username");
     $usernameElement->appendChild($doc->createTextNode($userInfo['alias']));
     $rootElement->appendChild($usernameElement);
     $bandwidth = $uploadStatus['bandwidth'];
     $bandwidthInfo = array("maxbytes" => $bandwidth['maxbytes'], "maxkb" => floor($bandwidth['maxbytes'] / 8), "usedbytes" => $bandwidth['usedbytes'], "usedkb" => ceil($bandwidth['usedbytes'] / 8), "remainingbytes" => $bandwidth['remainingbytes'], "remainingkb" => floor($bandwidth['remainingbytes'] / 8));
     $bandwidthElement = $doc->createElement("bandwidth");
     foreach ($bandwidthInfo as $field => $data) {
         $bandwidthElement->appendChild($doc->newTextAttribute($field, $data));
     }
     $rootElement->appendChild($bandwidthElement);
     $filesizeElement = $doc->createElement("filesize");
     $filesizeElement->appendChild($doc->newTextAttribute('maxbytes', floor($uploadStatus['filesize']['maxbytes'])));
     $filesizeElement->appendChild($doc->newTextAttribute('maxkb', floor($uploadStatus['filesize']['maxbytes'] / 8)));
     $rootElement->appendChild($filesizeElement);
     $this->_helper->printResponse($doc);
 }
Exemplo n.º 5
0
 public function indexAction()
 {
     $auth = Zend_Auth::getInstance();
     $registry = Zend_Registry::getInstance();
     $router = Zend_Controller_Front::getInstance()->getRouter();
     $config = $registry->get("config");
     $request = $this->getRequest();
     $share = Ml_Model_Share::getInstance();
     if (!$auth->hasIdentity()) {
         $this->_redirect($router->assemble(array(), "login"), array("exit"));
     }
     if (!$config['upload']['available']) {
         $this->_forward("offline");
     }
     $signedUserInfo = $registry->get('signedUserInfo');
     $uploadStatus = $share->getUploadStatus($auth->getIdentity());
     $registry->set("uploadStatus", $uploadStatus);
     $form = $share->form();
     if ($request->isPost()) {
         ignore_user_abort(true);
     }
     if ($request->isPost() && $form->isValid($request->getPost())) {
         // Returns all known internal file information
         $files = $form->file->getFileInfo();
         $fileErrors = array();
         $fileInfo = array();
         $num = -1;
         foreach ($files as $file => $info) {
             $num++;
             if ($info['error'] != 0 || $info['tmp_name'] == '' || !is_uploaded_file($info['tmp_name'])) {
                 $fileErrors[] = $file;
                 continue;
             }
             $fileInfo[$num] = $info;
         }
         $uploaded = array();
         foreach ($fileInfo as $num => $file) {
             set_time_limit(100);
             $newFileId = $share->addFile($file, $signedUserInfo);
             if ($newFileId) {
                 $uploaded[] = $newFileId;
             }
         }
         $upNum = sizeof($uploaded);
         if ($upNum > 1) {
             //@todo batch editing. Load like /upload/batchedit/id1/id2/id3...
             $this->_redirect($router->assemble(array("username" => $signedUserInfo['alias']), "filestream_1stpage") . "?uploaded=true", array("exit"));
         } else {
             if ($upNum == 1) {
                 $this->_redirect($router->assemble(array("username" => $signedUserInfo['alias'], "share_id" => $uploaded[0]), "editsharepage"), array("exit"));
             }
         }
     }
     $this->view->uploadForm = $form;
     $this->view->uploadStatus = $uploadStatus;
 }
Exemplo n.º 6
0
 public function share()
 {
     $registry = Zend_Registry::getInstance();
     $request = $this->getRequest();
     $params = $request->getParams();
     $share = Ml_Model_Share::getInstance();
     if (!isset($params['file_id'])) {
         throw new Exception("File ID param not given.");
     }
     $shareInfo = $share->getById($params['file_id']);
     if (empty($shareInfo)) {
         $registry->set("notfound", true);
         throw new Exception("File not found.");
     }
     $registry->set("shareInfo", $shareInfo);
 }
Exemplo n.º 7
0
 public function filestreamAction()
 {
     $registry = Zend_Registry::getInstance();
     $config = $registry->get('config');
     $router = Zend_Controller_Front::getInstance()->getRouter();
     $request = $this->getRequest();
     $share = Ml_Model_Share::getInstance();
     $userInfo = $registry->get('userInfo');
     $page = $request->getUserParam("page");
     $paginator = $share->getPages($userInfo['id'], $config['share']['perPage'], $page);
     //Test if there is enough pages or not
     if (!$paginator->count() && $page != 1 && $page != 1 || $paginator->getCurrentPageNumber() != $page) {
         $this->_redirect($router->assemble(array("username" => $userInfo['alias']), "filestream_1stpage"), array("exit"));
     }
     $this->view->paginator = $paginator;
 }
Exemplo n.º 8
0
 public function userAction()
 {
     $registry = Zend_Registry::getInstance();
     $router = Zend_Controller_Front::getInstance()->getRouter();
     $favorites = Ml_Model_Favorites::getInstance();
     $share = Ml_Model_Share::getInstance();
     $people = Ml_Model_People::getInstance();
     $request = $this->getRequest();
     $userInfo = $registry->get('userInfo');
     $page = $request->getUserParam("page");
     $paginator = $favorites->getUserPage($userInfo['id'], 25, $page);
     //Test if there is enough pages or not
     if (!$paginator->count() && $page != 1 || $paginator->getCurrentPageNumber() != $page) {
         $this->_redirect($router->assemble(array("username" => $userInfo['alias']), "userfav_1stpage"), array("exit"));
     }
     $this->view->paginator = $paginator;
 }
Exemplo n.º 9
0
 public function deleteAction()
 {
     $auth = Zend_Auth::getInstance();
     $registry = Zend_Registry::getInstance();
     $router = Zend_Controller_Front::getInstance()->getRouter();
     $request = $this->getRequest();
     $share = Ml_Model_Share::getInstance();
     $signedUserInfo = $registry->get("signedUserInfo");
     $shareInfo = $registry->get("shareInfo");
     $form = $share->deleteForm();
     if ($request->isPost() && $form->isValid($request->getPost())) {
         $forget = $form->getValue("forget");
         if (!empty($forget)) {
             $this->_redirect($router->assemble(array("username" => $signedUserInfo['alias']), "filestream_1stpage"), array("exit"));
         }
         $share->deleteShare($shareInfo, $signedUserInfo);
         $this->_redirect($router->assemble(array("username" => $signedUserInfo['alias']), "filestream_1stpage") . "?share-erased=true", array("exit"));
     }
     $this->view->deleteForm = $form;
 }
Exemplo n.º 10
0
 public function shortLink()
 {
     $registry = Zend_Registry::getInstance();
     $config = $registry->get("config");
     $uri = $_SERVER['REQUEST_URI'];
     if ($uri == '/') {
         header("HTTP/1.1 301 Moved Permanently");
         header("Location: http://" . $config['webhost'] . "/");
         exit;
     }
     //clear the first and the last '/'
     if (mb_substr($uri, -1) == '/') {
         $uri = mb_substr($uri, 1, -1);
     } else {
         $uri = mb_substr($uri, 1);
     }
     $numbers = new Ml_Model_Numbers();
     $id = $numbers->base58Decode($uri);
     if ($id) {
         //Is it a valid share ID?
         $share = Ml_Model_Share::getInstance();
         $people = Ml_Model_People::getInstance();
         $shareInfo = $share->getById($id);
         if ($shareInfo) {
             $userInfo = $people->getById($shareInfo['byUid']);
             $link = "http://" . $config['webhost'] . "/" . urlencode($userInfo['alias']) . "/" . $shareInfo['id'];
             header("HTTP/1.1 301 Moved Permanently");
             header("Location: " . $link);
             exit;
             //nothing more to do
         }
     }
     //If nothing matches
     $link = "http://" . $config['webhost'] . "/not-found/" . urlencode(utf8_encode($uri));
     header("Location: " . $link);
     //the redirector stops the default bootstrap, always
     exit;
 }
Exemplo n.º 11
0
 public function deleteAction()
 {
     $registry = Zend_Registry::getInstance();
     $service = new Ml_Model_Service();
     $timecheck = new Ml_Model_Timecheck();
     $share = Ml_Model_Share::getInstance();
     $people = Ml_Model_People::getInstance();
     $service->putString("WARNING!\n========\n");
     $service->requestConfirmAction("Delete share");
     $timecheck->reset();
     $shareId = $service->getInput("Delete share of ID?");
     $timecheck->check(60);
     $timecheck->reset();
     $shareInfo = $share->getById($shareId);
     if (!is_array($shareInfo)) {
         die("Share not found.\n");
     }
     $service->putString(print_r($shareInfo, true));
     $userInfo = $people->getById($shareInfo['byUid']);
     $service->putString("By user alias: " . $userInfo['alias'] . "\n");
     $service->requestConfirmAction("Delete this share");
     $share->deleteShare($shareInfo, $userInfo);
     echo "Share deleted!\n";
 }
Exemplo n.º 12
0
 public function filepageAction()
 {
     $registry = Zend_Registry::getInstance();
     $auth = Zend_Auth::getInstance();
     $request = $this->getRequest();
     $config = $registry->get('config');
     $params = $request->getParams();
     $keys = array("deletetag" => array("tags" => "delete"), "addtags" => array("tags" => "add"), "favorite" => array("favorites" => "switch"), "unfavorite" => array("favorites" => "switch"), "tweet" => array("twitter" => "tweet"));
     $this->_helper->loadResource->pseudoshareSetUp();
     foreach ($keys as $key => $where) {
         if (array_key_exists($key, $params)) {
             return $this->_forward(current($where), key($where));
         }
     }
     $userInfo = $registry->get('userInfo');
     $shareInfo = $registry->get("shareInfo");
     if ($registry->isRegistered("signedUserInfo")) {
         $signedUserInfo = $registry->get("signedUserInfo");
     }
     $page = $request->getUserParam("page");
     $share = Ml_Model_Share::getInstance();
     $tags = Ml_Model_Tags::getInstance();
     $people = Ml_Model_People::getInstance();
     $comments = Ml_Model_Comments::getInstance();
     $twitter = Ml_Model_Twitter::getInstance();
     $ignore = Ml_Model_Ignore::getInstance();
     $paginator = $comments->getCommentsPages($shareInfo['id'], $config['share']['commentsPerPage'], $page);
     //Test if there is enough pages or not
     if (!$paginator->count() && $page != 1 || $paginator->getCurrentPageNumber() != $page) {
         $this->_redirect(Zend_Controller_Front::getInstance()->getRouter()->assemble(array("username" => $userInfo['alias'], "share_id" => $shareInfo['id']), "sharepage_1stpage"), array("exit"));
     }
     $tagsList = $tags->getShareTags($shareInfo['id']);
     if ($auth->hasIdentity()) {
         $ignore = Ml_Model_Ignore::getInstance();
         if ($auth->getIdentity() == $userInfo['id'] || !$ignore->status($userInfo['id'], $auth->getIdentity())) {
             $commentForm = $comments->addForm();
             //should The comment form processing should be in the CommentsController?
             if ($request->isPost() && $commentForm->isValid($request->getPost())) {
                 $newCommentMsg = $commentForm->getValue('commentMsg');
                 $previewFlag = $commentForm->getValue('getCommentPreview');
                 //check if it is a post or preview
                 if (!empty($previewFlag)) {
                     $this->view->commentPreview = $newCommentMsg;
                 } else {
                     $newComment = $comments->add($newCommentMsg, $auth->getIdentity(), $shareInfo);
                     if (!$newComment) {
                         $newComment = "#commentPreview";
                         $this->view->commentPreview = $newCommentMsg;
                     } else {
                         $request->setParam("comment_id", $newComment);
                         return $this->_forward("commentpermalink", "comments");
                     }
                 }
             }
             $this->view->commentForm = $commentForm;
             if ($twitter->getSignedUserTwitterAccount()) {
                 $this->view->twitterForm = $twitter->form();
             }
         }
     }
     $this->view->tagsList = $tagsList;
     $this->view->paginator = $paginator;
 }
Exemplo n.º 13
0
 public function setmetaAction()
 {
     $registry = Zend_Registry::getInstance();
     $request = $this->getRequest();
     $this->_helper->verifyIdentity();
     $this->_helper->loadApiresource->share();
     $share = Ml_Model_Share::getInstance();
     $form = $share->apiSetMetaForm();
     if ($request->isPost()) {
         //@todo should work with PUT also
         if ($form->isValid($request->getPost())) {
             $shareInfo = $registry->get("shareInfo");
             $authedUserInfo = $registry->get("authedUserInfo");
             $share->setMeta($authedUserInfo, $shareInfo, $form->getValues(), $form->getErrors());
         } else {
             throw new Exception("Invalid post.");
         }
     } else {
         throw new Exception("Not POST HTTP call.");
     }
 }
Exemplo n.º 14
0
 public function infoAction()
 {
     //@todo route: do it the right way!
     $router = new Zend_Controller_Router_Rewrite();
     $routeConfig = new Zend_Config_Ini(APPLICATION_PATH . '/configs/defaultRoutes.ini');
     $router->addConfig($routeConfig, 'routes');
     $registry = Zend_Registry::getInstance();
     $config = $registry->get("config");
     $request = $this->getRequest();
     $params = $request->getParams();
     $people = Ml_Model_People::getInstance();
     $profile = Ml_Model_Profile::getInstance();
     $share = Ml_Model_Share::getInstance();
     if (isset($params['username'])) {
         $userInfo = $people->getByUsername($params['username']);
     } else {
         if (isset($params['user_id'])) {
             $userInfo = $people->getById($params['user_id']);
         } else {
             if (isset($params['email'])) {
                 $userInfo = $people->getByEmail($params['email']);
                 if (!empty($userInfo) && $userInfo['private_email'] == true) {
                     $registry->set("notfound", true);
                     throw new Exception("User not found.");
                 }
             } else {
                 throw new Exception("No user params were given.");
             }
         }
     }
     if (empty($userInfo)) {
         $registry->set("notfound", true);
         throw new Exception("User not found.");
     }
     $profileInfo = $profile->getById($userInfo['id']);
     $doc = new Ml_Model_Dom();
     $doc->formatOutput = true;
     $rootElement = $doc->createElement("person");
     $doc->appendChild($rootElement);
     $rootElement->appendChild($doc->newTextAttribute('id', $userInfo['id']));
     $avatarInfo = unserialize($userInfo['avatarInfo']);
     if (isset($avatarInfo['secret'])) {
         $iconSecret = $avatarInfo['secret'];
     } else {
         $iconSecret = '';
     }
     $rootElement->appendChild($doc->newTextAttribute('iconsecret', $iconSecret));
     $userData = array("username" => $userInfo['alias'], "realname" => $userInfo['name']);
     if (!$userInfo['private_email']) {
         $userData["mbox_sha1sum"] = sha1("mailto:" . $userInfo['email']);
     }
     $userData["location"] = $profileInfo['location'];
     $userData["url"] = "http://" . $config['webhost'] . $router->assemble(array("username" => $userInfo['alias']), "filestream_1stpage");
     foreach ($userData as $field => $data) {
         $rootElement->appendChild($doc->newTextElement($field, $data));
     }
     $sharesCounter = $share->countOfUser($userInfo['id']);
     $sharesElement = $doc->createElement("files");
     $sharesCounterElement = $doc->createElement("count");
     $sharesCounterElement->appendChild($doc->createTextNode($sharesCounter));
     $sharesElement->appendChild($sharesCounterElement);
     $rootElement->appendChild($sharesElement);
     $this->_helper->printResponse($doc);
 }
Exemplo n.º 15
0
 public function userfeedAction()
 {
     $registry = Zend_Registry::getInstance();
     $config = $registry->get("config");
     $s3config = $config['services']['S3'];
     $request = $this->getRequest();
     $router = Zend_Controller_Front::getInstance()->getRouter();
     $userInfo = $registry->get("userInfo");
     $share = Ml_Model_Share::getInstance();
     $paginator = $share->getPages($userInfo['id'], 20, 1);
     $currentItems = $paginator->getCurrentItems()->toArray();
     $this->_helper->layout->disableLayout();
     $this->_helper->viewRenderer->setNoRender();
     $doc = new Ml_Model_Dom();
     $doc->formatOutput = true;
     $doc->encoding = "utf-8";
     $rootElement = $doc->createElement("rss");
     $rootElement->appendChild($doc->newTextAttribute("version", "2.0"));
     $rootElement->appendChild($doc->newTextAttribute("xmlns:atom", "http://www.w3.org/2005/Atom"));
     $doc->appendChild($rootElement);
     $channelElement = $doc->createElement("channel");
     $channelElement->appendChild($doc->newTextElement("description", "Recent uploads to " . $config['applicationname'] . "."));
     $rootElement->appendChild($channelElement);
     $userLink = "http://" . $config['webhost'] . $router->assemble(array("username" => $userInfo['alias']), "filestream_1stpage");
     /*Instead of...
        * $firstElement = current($currentItems);
       if(!is_array($firstElement)) $x = 1;
       else $x =2;
       should see the last changed or published of the items...
       */
     $userData = array("title" => "Shared files from " . $userInfo['name'], "link" => $userLink, "generator" => "http://" . $config['webhost'], "docs" => "http://blogs.law.harvard.edu/tech/rss", "ttl" => "180");
     if (empty($config['webroot'])) {
         $userData['generator'] .= '/';
     } else {
         $userData['generator'] .= "/" . $config['webroot'] . "/";
     }
     foreach ($userData as $field => $value) {
         $channelElement->appendChild($doc->newTextElement($field, $value));
     }
     $avatarInfo = unserialize($userInfo['avatarInfo']);
     if (isset($avatarInfo['secret'])) {
         $iconSecret = $avatarInfo['secret'];
     } else {
         $iconSecret = '';
     }
     if (!empty($iconSecret)) {
         $imageElement = $doc->createElement("image");
         $picUri = $s3config['headshotsBucketAddress'] . $userInfo['id'] . '-' . $iconSecret . '-s.jpg';
         $imageElement->appendChild($doc->newTextElement("url", $picUri));
         $imageElement->appendChild($doc->newTextElement("title", "Shares from " . $userInfo['name']));
         $imageElement->appendChild($doc->newTextElement("link", $userLink));
         $channelElement->appendChild($imageElement);
     }
     $atomLink = $doc->createElement("atom:link");
     $atomLink->appendChild($doc->newTextAttribute("href", "http://" . $config['webhost'] . $router->assemble(array("username" => $userInfo['alias']), "userfeed")));
     $atomLink->appendChild($doc->newTextAttribute("rel", "self"));
     $atomLink->appendChild($doc->newTextAttribute("type", "application/rss+xml"));
     $channelElement->appendChild($atomLink);
     foreach ($currentItems as $share) {
         $shareElement = $doc->createElement("item");
         if (empty($share['description_filtered'])) {
             $description = $this->view->escape($share['short']);
         } else {
             $description = $share['description_filtered'];
         }
         $link = "http://" . $config['webhost'] . $router->assemble(array("username" => $userInfo['alias'], "share_id" => $share['id']), "sharepage_1stpage");
         $shareDate = new Zend_Date($share['uploadedTime'], Zend_Date::ISO_8601);
         $shareData = array("title" => $share['title'], "link" => $link, "description" => $description, "pubDate" => $shareDate->get(Zend_Date::RSS));
         foreach ($shareData as $field => $data) {
             $shareElement->appendChild($doc->newTextElement($field, $data));
         }
         $shareElement->appendChild($doc->newTextElement("guid", $link));
         $enclosureElement = $doc->createElement("enclosure");
         $enclosureElement->appendChild($doc->newTextAttribute("url", $this->view->downloadLink($share, $userInfo)));
         $enclosureElement->appendChild($doc->newTextAttribute("length", $share['fileSize']));
         $enclosureElement->appendChild($doc->newTextAttribute("type", $share['type']));
         $shareElement->appendChild($enclosureElement);
         $channelElement->appendChild($shareElement);
     }
     $request = $this->getRequest();
     $response = new Zend_Controller_Response_Http();
     //I'm not serving as rss+xml for browsers because they get it wrong
     if (isset($_SERVER['HTTP_USER_AGENT']) && strstr($_SERVER['HTTP_USER_AGENT'], "Mozilla")) {
         $contenttype = 'text/xml';
     } else {
         $contenttype = 'application/rss+xml';
     }
     header('Content-Type: ' . $contenttype . '; charset=utf-8');
     echo $doc->saveXML();
     exit;
 }