Beispiel #1
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);
 }
Beispiel #2
0
 public function userlistAction()
 {
     $registry = Zend_Registry::getInstance();
     $this->_helper->loadApiresource->user();
     $userInfo = $registry->get("userInfo");
     $tags = Ml_Model_Tags::getInstance();
     $taglist = $tags->getUserTags($userInfo['id']);
     $doc = new Ml_Model_Dom();
     $doc->formatOutput = true;
     $rootElement = $doc->createElement("who");
     $rootElement->appendChild($doc->newTextAttribute('id', $userInfo['id']));
     $doc->appendChild($rootElement);
     $tagsElement = $doc->createElement("tags");
     foreach ($taglist as $tag => $count) {
         $tagElement = $doc->createElement("tag");
         $tagElement->appendChild($doc->createTextNode($tag));
         $tagElement->appendChild($doc->newTextAttribute('count', $count));
         $tagsElement->appendChild($tagElement);
     }
     $rootElement->appendChild($tagsElement);
     $this->_helper->printResponse($doc);
 }
Beispiel #3
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();
     $favorites = Ml_Model_Favorites::getInstance();
     $comments = Ml_Model_Comments::getInstance();
     $tags = Ml_Model_Tags::getInstance();
     $numbers = new Ml_Model_Numbers();
     $this->_helper->loadApiresource->share();
     $shareInfo = $registry->get("shareInfo");
     $userInfo = $people->getById($shareInfo['byUid']);
     $tagsList = $tags->getShareTags($shareInfo['id']);
     $countFavs = $favorites->count($shareInfo['id']);
     $countComments = $comments->count($shareInfo['id']);
     //begin of response
     $doc = new Ml_Model_Dom();
     $doc->formatOutput = true;
     $rootElement = $doc->createElement("file");
     $doc->appendChild($rootElement);
     $rootElement->appendChild($doc->newTextAttribute('id', $shareInfo['id']));
     $rootElement->appendChild($doc->newTextAttribute('secret', $shareInfo['secret']));
     $rootElement->appendChild($doc->newTextAttribute('download_secret', $shareInfo['download_secret']));
     $ownerElement = $doc->createElement("owner");
     $ownerData = array("id" => $userInfo['id'], "username" => $userInfo['alias'], "realname" => $userInfo['name']);
     foreach ($ownerData as $field => $data) {
         $ownerElement->appendChild($doc->newTextAttribute($field, $data));
     }
     $rootElement->appendChild($ownerElement);
     $shareData = array("title" => $shareInfo['title'], "filename" => $shareInfo['filename'], "filetype" => $shareInfo['type'], "short" => $shareInfo['short'], "description" => $shareInfo['description_filtered'], "url" => "http://" . $config['webhost'] . $router->assemble(array("username" => $userInfo['alias'], "share_id" => $shareInfo['id']), "sharepage_1stpage"), "dataurl" => $config['services']['S3']['sharesBucketAddress'] . $userInfo['alias'] . "/" . $shareInfo['id'] . "-" . $shareInfo['download_secret'] . "/" . $shareInfo['filename'], "shorturl" => $config['URLshortening']['addr'] . $numbers->base58Encode($shareInfo['id']), "comments" => $countComments, "favorites" => $countFavs);
     foreach ($shareData as $field => $data) {
         $rootElement->appendChild($doc->newTextElement($field, $data));
     }
     $filesizeElement = $doc->createElement("filesize");
     $filesizeElement->appendChild($doc->newTextAttribute("bits", $shareInfo['fileSize']));
     $filesizeElement->appendChild($doc->newTextAttribute("kbytes", ceil($shareInfo['fileSize'] / (1024 * 8))));
     $rootElement->appendChild($filesizeElement);
     $checksumElement = $doc->createElement("checksum");
     $checksumElement->appendChild($doc->newTextAttribute("hash", "md5"));
     $checksumElement->appendChild($doc->newTextAttribute("value", $shareInfo['md5']));
     $rootElement->appendChild($checksumElement);
     $visibilityElement = $doc->createElement("visibility");
     $visibilityElement->appendChild($doc->newTextAttribute("ispublic", "1"));
     $rootElement->appendChild($visibilityElement);
     $datesData = array("posted" => $shareInfo['uploadedTime'], "lastupdate" => $shareInfo['lastChange']);
     $datesElement = $doc->createElement("dates");
     foreach ($datesData as $field => $data) {
         $datesElement->appendChild($doc->newTextAttribute($field, $data));
     }
     $rootElement->appendChild($datesElement);
     $tagsElement = $doc->createElement("tags");
     foreach ($tagsList as $tag) {
         $tagElement = $doc->createElement("tag");
         $tagElement->appendChild($doc->newTextAttribute("id", $tag['id']));
         $tagElement->appendChild($doc->newTextAttribute("raw", $tag['raw']));
         $tagElement->appendChild($doc->createTextNode($tag['clean']));
         $tagsElement->appendChild($tagElement);
     }
     $rootElement->appendChild($tagsElement);
     $this->_helper->printResponse($doc);
 }
Beispiel #4
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);
 }