throw new SqlErrorException("Unable to create session"); } # else } # if SpotTiming::stop('auth'); /* * And check if the security groups need updating */ if (!$currentSession['security']->securityValid()) { throw new SecurityNotUpgradedException(); } # if # User session has been loaded, let's translate the categories if ($currentSession['user']['prefs']['user_language'] != 'en_US') { SpotTranslation::initialize($currentSession['user']['prefs']['user_language']); } # if SpotCategories::startTranslation(); /* * Let the form handler know what userid we are using so * we can make the CSRF cookie be user-bounded */ $req->setUserId($currentSession['user']['userid']); /* * Only now it is safe to check wether the user is actually alowed * to authenticate with an API key */ if ($req->doesExist('apikey')) { /* * To use the Spotweb API we need the actual permission
echo $x->getMessage() . PHP_EOL; die; } # InvalidOwnSettingsSetting require_once "lib/SpotTiming.php"; require_once "lib/exceptions/ParseSpotXmlException.php"; require_once "lib/exceptions/NntpException.php"; /* * disable timing, all queries which are ran by retrieve this would make it use * large amounts of memory */ SpotTiming::disable(); # Initialize commandline arguments SpotCommandline::initialize(array('force', 'debug', 'retro'), array('force' => false, 'debug' => false, 'retro' => false)); # Initialize translation to english SpotTranslation::initialize('en_US'); # in safe mode, max execution time cannot be set, warn the user if (ini_get('safe_mode')) { echo "WARNING: PHP safemode is enabled, maximum execution cannot be reset! Turn off safemode if this causes problems" . PHP_EOL . PHP_EOL; } # if try { $db = new SpotDb($settings['db']); $db->connect(); } catch (DatabaseConnectionException $x) { die("Unable to connect to database: " . $x->getMessage() . PHP_EOL); } # catch # Creer het settings object $settings = SpotSettings::singleton($db, $settings); # Controleer dat we niet een schema upgrade verwachten
function createStatistics($graph, $limit, $lastUpdate, $language) { SpotTranslation::initialize($language); $spotStatistics = new SpotStatistics($this->_db); include_once "images/pchart/pData.class.php"; include_once "images/pchart/pDraw.class.php"; include_once "images/pchart/pImage.class.php"; $width = 800; $height = 500; $titleHeight = 20; $dataSet = array(); $graphs = $this->getValidStatisticsGraphs(); $limits = $this->getValidStatisticsLimits(); switch ($graph) { case 'spotsperhour': $prepData = $this->prepareData($spotStatistics->getSpotCountPerHour($limit, $lastUpdate)); $legend = array('0', '1', '2', '3', '4', '5', '6', '7', '8', '9', '10', '11', '12', '13', '14', '15', '16', '17', '18', '19', '20', '21', '22', '23'); for ($x = 0; $x <= 23; $x++) { $dataSet[] = @$prepData[$x]; } $graphicType = "bar"; break; case 'spotsperweekday': $prepData = $this->prepareData($spotStatistics->getSpotCountPerWeekday($limit, $lastUpdate)); $legend = array(_("Monday"), _("Tuesday"), _("Wednesday"), _("Thursday"), _("Friday"), _("Saturday"), _("Sunday")); $dataSet = array(@$prepData[1], @$prepData[2], @$prepData[3], @$prepData[4], @$prepData[5], @$prepData[6], @$prepData[0]); $graphicType = "bar"; break; case 'spotspermonth': $prepData = $this->prepareData($spotStatistics->getSpotCountPerMonth($limit, $lastUpdate)); $legend = array(_("January"), _("February"), _("March"), _("April"), _("May"), _("June"), _("July"), _("August"), _("September"), _("October"), _("November"), _("December")); for ($x = 1; $x <= 12; $x++) { $dataSet[] = @$prepData[$x]; } $graphicType = "bar"; break; case 'spotspercategory': $prepData = $this->prepareData($spotStatistics->getSpotCountPerCategory($limit, $lastUpdate)); $legend = array(_(SpotCategories::HeadCat2Desc(0)), _(SpotCategories::HeadCat2Desc(1)), _(SpotCategories::HeadCat2Desc(2)), _(SpotCategories::HeadCat2Desc(3))); for ($x = 0; $x <= 3; $x++) { $dataSet[] = @$prepData[$x]; } $graphicType = "3Dpie"; break; } # switch array_walk($dataSet, create_function('& $item, $key', 'if ($item === NULL) $item = 0;')); $title = $graphs[$graph]; if (!empty($limit)) { $title .= " (" . $limits[$limit] . ")"; } # if $imgData = new pData(); if ($graphicType == "bar") { $imgData->addPoints($dataSet, "data"); $imgData->addPoints($legend, "legend"); $imgData->setAbscissa("legend"); $imgData->setPalette("data", array("R" => 0, "G" => 108, "B" => 171, "Alpha" => 100)); $img = new pImage($width, $height, $imgData); $img->drawGradientArea(0, $titleHeight, $width, $height, DIRECTION_VERTICAL, array("StartR" => 200, "StartG" => 200, "StartB" => 200, "EndR" => 18, "EndG" => 52, "EndB" => 86, "Alpha" => 100)); $img->drawGradientArea(0, 0, $width, $titleHeight, DIRECTION_VERTICAL, array("StartR" => 18, "StartG" => 52, "StartB" => 86, "EndR" => 50, "EndG" => 50, "EndB" => 50, "Alpha" => 100)); $img->setFontProperties(array("FontName" => "images/ttf/liberation-sans/LiberationSans-Bold.ttf", "FontSize" => 10)); $img->drawText($width / 2, 13, $title, array("Align" => TEXT_ALIGN_MIDDLEMIDDLE, "R" => 255, "G" => 255, "B" => 255)); $img->setFontProperties(array("R" => 255, "G" => 255, "B" => 255, "FontName" => "images/ttf/liberation-sans/LiberationSans-Regular.ttf", "FontSize" => 9)); $img->setGraphArea(60, $titleHeight + 20, $width - 50, $height - 30); $img->drawScale(array("GridR" => 200, "GridG" => 200, "GridB" => 200, "Mode" => SCALE_MODE_START0)); $img->drawBarChart(array("Gradient" => TRUE, "GradientMode" => GRADIENT_EFFECT_CAN, "DisplayPos" => LABEL_POS_INSIDE, "DisplayValues" => TRUE, "Surrounding" => 10)); } elseif ($graphicType == "3Dpie") { include_once "images/pchart/pPie.class.php"; $imgData->addPoints($dataSet, "data"); $imgData->addPoints($legend, "legend"); $imgData->setAbscissa("legend"); $img = new pImage($width, $height, $imgData, TRUE); $PieChart = new pPie($img, $imgData); $img->drawGradientArea(0, $titleHeight, $width, $height, DIRECTION_VERTICAL, array("StartR" => 200, "StartG" => 200, "StartB" => 200, "EndR" => 18, "EndG" => 52, "EndB" => 86, "Alpha" => 100)); $img->drawGradientArea(0, 0, $width, $titleHeight, DIRECTION_VERTICAL, array("StartR" => 18, "StartG" => 52, "StartB" => 86, "EndR" => 50, "EndG" => 50, "EndB" => 50, "Alpha" => 100)); $img->setFontProperties(array("FontName" => "images/ttf/liberation-sans/LiberationSans-Bold.ttf", "FontSize" => 10)); $img->drawText($width / 2, 13, $title, array("Align" => TEXT_ALIGN_MIDDLEMIDDLE, "R" => 255, "G" => 255, "B" => 255)); $PieChart->setSliceColor(0, array("R" => 0, "G" => 108, "B" => 171)); $PieChart->setSliceColor(1, array("R" => 205, "G" => 159, "B" => 0)); $PieChart->setSliceColor(2, array("R" => 0, "G" => 171, "B" => 0)); $PieChart->setSliceColor(3, array("R" => 171, "G" => 28, "B" => 0)); $img->setFontProperties(array("FontName" => "images/ttf/liberation-sans/LiberationSans-Regular.ttf", "FontSize" => 9)); $PieChart->draw3DPie($width / 2, $height / 2 + $titleHeight, array("Radius" => $width / 2 - 100, "SecondPass" => TRUE, "DrawLabels" => TRUE, "WriteValues" => TRUE, "Precision" => 2, "ValueR" => 0, "ValueG" => 0, "ValueB" => 0, "ValueAlpha" => 100, "SkewFactor" => 0.6, "LabelR" => 255, "LabelG" => 255, "LabelB" => 255, "LabelAlpha" => 100)); } # if if (isset($img)) { ob_start(); $img->render(NULL); $imageString = ob_get_clean(); $data = $this->getImageInfoFromString($imageString); return array('metadata' => $data['metadata'], 'content' => $imageString); } # img }