public function getUploadStatus($uid) { $numbers = new Ml_Model_Numbers(); $config = self::$_registry->get("config"); if (!$numbers->isNaturalDbId($uid)) { return false; } $this->_dbAdapter->query("set @aaaab:=0"); $since = date("Y-m-00 00:00:00"); $call = "select sum from (select * from(select @aaaab:=@aaaab+filesize as sum, id from upload_history where byUid = ? and timestamp >= ? order by timestamp ASC) as sizesum) as sum order by sum DESC LIMIT 1"; $query = $this->_dbAdapter->fetchOne($call, array($uid, $since)); if (!$query) { $query = 0; } $this->_dbAdapter->query("set @aaaab:=0"); $uploadStatus = array("bandwidth" => array("maxbytes" => floor($config['share']['monthlyLimit'] * 1024 * 1024), "usedbytes" => ceil($query), "remainingbytes" => floor($config['share']['monthlyLimit'] * 1024 * 1024 - $query)), "filesize" => array("maxbytes" => floor($config['share']['maxFileSize'] * 1024 * 1024))); return $uploadStatus; }
/** * Matches a user submitted path. Assigns and returns an array of variables * on a successful match. * * If a request object is registered, it uses its setModuleName(), * setControllerName(), and setActionName() accessors to set those values. * Always returns the values as an array. * * @param string $path Path used to match against this routing map * @return array An array of assigned values or a false on a mismatch */ public function match($path, $partial = false) { $numbers = new Ml_Model_Numbers(); if (HOST_MODULE == "api") { return array("controller" => "notstatic", "action" => "error", "module" => "api"); } else { if (HOST_MODULE == "default") { //@todo this is a workaround for another resource: the tag system //the Zend_Controller_Router_Route_Regex don't work with utf-8 //despite trying the hack http://framework.zend.com/issues/browse/ZF-6661 //it didn't work //clear this part of the code when everything is ok //and only let the static=>docs $path = explode("/", $path, 5); if (isset($path[2]) && $path[2] == "tags" && isset($path[3])) { //could be using regex... $username = $path[1]; if ($username) { $tag = urldecode($path[3]); if (!isset($path[4])) { $page = "1"; } else { if (mb_substr($path[4], 0, 4) == "page") { $tryPage = mb_substr($path[4], 4); if ($numbers->isNaturalDbId($tryPage)) { $page = $tryPage; } } } if (isset($page)) { return array("username" => $username, "tag" => $tag, "page" => $page, "controller" => "tagspages", "action" => "tagpage", "module" => "default"); } } } //end of workaround return array("controller" => "static", "action" => "docs", "module" => "default"); } } $this->_setRequestKeys(); $values = array(); $params = array(); if (!$partial) { $path = trim($path, self::URI_DELIMITER); } else { $matchedPath = $path; } if ($path != '') { $path = explode(self::URI_DELIMITER, $path); if ($this->_dispatcher && $this->_dispatcher->isValidModule($path[0])) { $values[$this->_moduleKey] = array_shift($path); $this->_moduleValid = true; } if (count($path) && !empty($path[0])) { $values[$this->_controllerKey] = array_shift($path); } if (count($path) && !empty($path[0])) { $values[$this->_actionKey] = array_shift($path); } if ($numSegs = count($path)) { for ($i = 0; $i < $numSegs; $i = $i + 2) { $key = urldecode($path[$i]); $val = isset($path[$i + 1]) ? urldecode($path[$i + 1]) : null; $params[$key] = isset($params[$key]) ? array_merge((array) $params[$key], array($val)) : $val; } } } if ($partial) { $this->setMatchedPath($matchedPath); } $this->_values = $values + $params; return $this->_values + $this->_defaults; }