Ejemplo n.º 1
0
 function index()
 {
     $connection = $this->getServerConnection();
     $mapService = new \ManiaHost\Services\MapService($connection->getMapsDirectory());
     $usedSpace = $mapService->getSize('$uploaded/', array(), null, null, null, null, true);
     $analytics = new \ManiaHost\Services\AnalyticsService();
     $data = $analytics->getRental('day', '-6 days');
     $abscissa = array();
     $values = array();
     foreach ($data as $value) {
         $abscissa[] = $value[0];
         $values[] = $value[1];
     }
     $barChart = new \Google\ImageCharts\BarChart();
     $barChart->setSize(600, 200);
     $barChart->setTitle('Rental per day');
     $barChart->setAbscissaAxis($abscissa);
     $barChart->setData($values);
     $RentalUrl = $barChart->getUrl();
     $data = $analytics->getRevenuesAnalytics('day', '-6 days');
     $abscissa = array();
     $values = array();
     foreach ($data as $value) {
         $abscissa[] = $value[0];
         $values[] = $value[1];
     }
     $barChart = new \Google\ImageCharts\BarChart();
     $barChart->setSize(600, 200);
     $barChart->setTitle('Incomes per day');
     $barChart->setAbscissaAxis($abscissa);
     $barChart->setData($values);
     $IncomesUrl = $barChart->getUrl();
     $this->response->usedSpace = $usedSpace;
     $this->response->rentalUrl = $RentalUrl;
     $this->response->incomesUrl = $IncomesUrl;
 }
Ejemplo n.º 2
0
 function doUpload($file)
 {
     if (!preg_match('/(\\.map\\.gbx)$/ixu', $file)) {
         throw new \ManiaLib\Application\UserException('Please upload only maps');
     }
     try {
         $path = '$uploaded/' . $this->session->login . '/';
         $connection = $this->getServerConnection();
         $mapsPath = $connection->getMapsDirectory();
         $mapService = new \ManiaHost\Services\MapService($mapsPath);
         $maxSize = 20 * pow(2, 20) - $mapService->getSize($path, array(), null, null, null, null, true);
         $maxSize = $maxSize > pow(2, 20) ? pow(2, 20) : $maxSize;
         $data = file_get_contents('php://input', null, null, null, $maxSize);
         $connection->writeFileFromString($path . $file, $data);
         $datas = $mapService->getData($mapsPath . $path . $file);
         $map = new \ManiaHost\Services\Map();
         $map->filename = $file;
         $map->path = $path;
         foreach ($datas as $key => $value) {
             $map->{$key} = $value;
         }
         $mapService->register($map);
     } catch (\Exception $e) {
         \ManiaLib\Application\ErrorHandling::logException($e);
         $this->request->set('message', 'An error append during upload');
         $this->request->redirectArgList('../upload/', 'message');
     }
     $this->request->set('message', 'file successfully uploaded');
     $this->request->redirectArgList('../upload/', 'message');
 }