public function send() { pl_cached_dynamic_content_headers($this->mimeType()); echo $this->data; exit; }
function handler_photo($page, $eid = null, $valid = null) { if ($eid && $eid != 'valid') { $res = XDB::query("SELECT * FROM announce_photos WHERE eid = {?}", $eid); if ($res->numRows()) { $photo = $res->fetchOneAssoc(); pl_cached_dynamic_content_headers("image/" . $photo['attachmime']); echo $photo['attach']; exit; } } elseif ($eid == 'valid') { $valid = Validate::get_request_by_id($valid); if ($valid && $valid->img) { pl_cached_dynamic_content_headers("image/" . $valid->imgtype); echo $valid->img; exit; } } else { $upload = new PlUpload(S::user()->login(), 'event'); if ($upload->exists() && $upload->isType('image')) { pl_cached_dynamic_content_headers($upload->contentType()); echo $upload->getContents(); exit; } } global $globals; pl_cached_dynamic_content_headers("image/png"); echo file_get_contents($globals->spoolroot . '/htdocs/images/logo.png'); exit; }
function handler_xnetlogo($page, $id) { if (is_null($id)) { return PL_NOT_FOUND; } $res = XDB::query('SELECT logo, logo_mime FROM groups WHERE id = {?}', $id); list($logo, $logo_mime) = $res->fetchOneRow(); if (!empty($logo)) { pl_cached_dynamic_content_headers($logo_mime); echo $logo; } else { pl_cached_dynamic_content_headers("image/jpeg"); readfile(dirname(__FILE__) . '/../htdocs/images/dflt_carre.jpg'); } exit; }
function handler_photo_announce($page, $eid = null) { if ($eid) { $res = XDB::query('SELECT * FROM group_announces_photo WHERE eid = {?}', $eid); if ($res->numRows()) { $photo = $res->fetchOneAssoc(); pl_cached_dynamic_content_headers("image/" . $photo['attachmime']); echo $photo['attach']; exit; } } else { $upload = new PlUpload(S::user()->login(), 'xnetannounce'); if ($upload->exists() && $upload->isType('image')) { pl_cached_dynamic_content_headers($upload->contentType()); echo $upload->getContents(); exit; } } global $globals; pl_cached_dynamic_content_headers("image/png"); echo file_get_contents($globals->spoolroot . '/htdocs/images/logo.png'); exit; }
function handler_graph($page, $promo = null) { if (in_array($promo, array(Profile::DEGREE_X, Profile::DEGREE_M, Profile::DEGREE_D))) { $cycle = Profile::$cycles[$promo] . 's'; $res = XDB::iterRow("SELECT pe.promo_year, SUM(a.state = 'active') / COUNT(*) * 100\n FROM accounts AS a\n INNER JOIN account_profiles AS ap ON (ap.uid = a.uid AND FIND_IN_SET('owner', ap.perms))\n INNER JOIN profiles AS p ON (p.pid = ap.pid)\n INNER JOIN profile_education AS pe ON (pe.pid = ap.pid AND FIND_IN_SET('primary', pe.flags))\n INNER JOIN profile_education_degree_enum AS ped ON (pe.degreeid = ped.id)\n WHERE p.deathdate IS NULL AND ped.degree = {?}\n GROUP BY pe.promo_year", $promo); list($promo, $count) = $res->next(); $first = $promo; $registered = $promo . ' ' . $count . "\n"; while ($next = $res->next()) { list($promo, $count) = $next; $registered .= $promo . ' ' . $count . "\n"; } $last = $promo + 2; // Generate drawing thanks to Gnuplot. $gnuplot = <<<EOF2 gnuplot <<EOF set term png small color set size 640/480 set timefmt "%d/%m/%y" set xr [{$first}:{$last}] set yr [0:100] set title "Proportion de {$cycle} inscrits par promotion, en %." set key left top plot "-" using 1:2 title 'inscrits' with boxes; {$registered} EOF EOF2; } else { $day_length = 24 * 3600; $days = 365; $res = XDB::query("SELECT MIN(TO_DAYS(a.registration_date) - TO_DAYS(NOW()))\n FROM accounts AS a\n INNER JOIN account_profiles AS ap ON (ap.uid = a.uid AND FIND_IN_SET('owner', ap.perms))\n INNER JOIN profile_display AS pd ON (ap.pid = pd.pid)\n WHERE pd.promo = {?} AND a.state = 'active'", $promo); $days = -$res->fetchOneCell(); // Retrieve the registration count per days during the given date range. $res = XDB::iterRow("SELECT IF(a.registration_date > DATE_SUB(NOW(), INTERVAL {?} DAY),\n TO_DAYS(a.registration_date) - TO_DAYS(NOW()),\n - {?}) AS day,\n COUNT(a.uid) AS nb\n FROM accounts AS a\n INNER JOIN account_profiles AS ap ON (ap.uid = a.uid AND FIND_IN_SET('owner', ap.perms))\n INNER JOIN profile_display AS pd ON (ap.pid = pd.pid)\n WHERE pd.promo = {?} AND a.state = 'active'\n GROUP BY day", (int) $days, 1 + (int) $days, $promo); // The first line contains the registration count before starting date (D - $days). list(, $init_nb) = $res->next(); $total = $init_nb; $registered = ''; list($num_day, $nb) = $res->next(); for ($i = -$days; $i <= 0; ++$i) { if ($num_day < $i) { if (!(list($num_day, $nb) = $res->next())) { $num_day = 0; $nb = 0; } } if ($num_day == $i) { $total += $nb; } $registered .= date('d/m/y', $i * $day_length + time()) . ' ' . $total . "\n"; } // Generate drawing thanks to Gnuplot. $delt = ($total - $init_nb) / 10; $delt += $delt < 1; $ymin = round($init_nb - $delt, 0); $ymax = round($total + $delt, 0); $gnuplot = <<<EOF2 gnuplot <<EOF set term png small color set size 640/480 set xdata time set timefmt "%d/%m/%y" set format x "%m/%y" set yr [{$ymin}:{$ymax}] set title "Nombre d'inscrits de la promotion {$promo}." plot "-" using 1:2 title 'inscrits' with lines; {$registered}e EOF EOF2; } pl_cached_dynamic_content_headers("image/png"); passthru($gnuplot); exit; }