X-Git-Url: http://git.polytechnique.org/?a=blobdiff_plain;f=modules%2Fprofile.php;h=123ccb75e499bea99ba063954c4b00d6497fe48f;hb=d4775fe2dea4db5e6ca3db4a6034bb03a8b711cc;hp=b6cd6956b7f92f6004b2e1ab3034b6b90e365e95;hpb=f70f2bcdc077c220e40ecebaf569e097f6028743;p=platal.git diff --git a/modules/profile.php b/modules/profile.php index b6cd695..123ccb7 100644 --- a/modules/profile.php +++ b/modules/profile.php @@ -125,6 +125,7 @@ class ProfileModule extends PLModule function handler_photo_change(&$page) { + global $globals; $page->changeTpl('profile/trombino.tpl'); require_once('validations.inc.php'); @@ -133,6 +134,8 @@ class ProfileModule extends PLModule .'/'.S::v('forlife').'.jpg'; if (Env::has('upload')) { + S::assert_xsrf_token(); + $upload = new PlUpload(S::v('forlife'), 'photo'); if (!$upload->upload($_FILES['userfile']) && !$upload->download(Env::v('photo'))) { $page->trigError('Une erreur est survenue lors du téléchargement du fichier'); @@ -143,6 +146,8 @@ class ProfileModule extends PLModule } } } elseif (Env::has('trombi')) { + S::assert_xsrf_token(); + $upload = new PlUpload(S::v('forlife'), 'photo'); if ($upload->copyFrom($trombi_x)) { $myphoto = new PhotoReq(S::v('uid'), $upload); @@ -152,18 +157,22 @@ class ProfileModule extends PLModule } } } elseif (Env::v('suppr')) { + S::assert_xsrf_token(); + XDB::execute('DELETE FROM photo WHERE uid = {?}', S::v('uid')); XDB::execute('DELETE FROM requests WHERE user_id = {?} AND type="photo"', S::v('uid')); - update_NbValid(); + $globals->updateNbValid(); } elseif (Env::v('cancel')) { + S::assert_xsrf_token(); + $sql = XDB::query('DELETE FROM requests WHERE user_id={?} AND type="photo"', S::v('uid')); - update_NbValid(); + $globals->updateNbValid(); } $sql = XDB::query('SELECT COUNT(*) @@ -221,7 +230,7 @@ class ProfileModule extends PLModule } $title = $user['prenom'] . ' ' . ( empty($user['nom_usage']) ? $user['nom'] : $user['nom_usage'] ); - $page->assign('pl_title', $title); + $page->setTitle($title); // photo @@ -328,7 +337,7 @@ class ProfileModule extends PLModule . " la procédure de récupération de mot de passe si un jour tu le perdais"); } - $page->assign('pl_title', 'Polytechnique.org - Mon Profil'); + $page->setTitle('Polytechnique.org - Mon Profil'); } function handler_applis_js(&$page) @@ -459,6 +468,8 @@ class ProfileModule extends PLModule if (!Env::has('promo_sortie')) { return; + } else { + S::assert_xsrf_token(); } $promo_sortie = Env::i('promo_sortie'); @@ -557,9 +568,10 @@ class ProfileModule extends PLModule function handler_ref_search(&$page, $action = null, $subaction = null) { - require_once 'wiki.inc.php'; - wiki_require_page('Docs.Emploi'); - $page->assign('pl_title', 'Polytechnique.org - Conseil Pro'); + $wp = new PlWikiPage('Docs.Emploi'); + $wp->buildCache(); + + $page->setTitle('Polytechnique.org - Conseil Pro'); //recuperation des noms de secteurs $res = XDB::iterRow("SELECT id, label FROM emploi_secteur"); @@ -661,6 +673,8 @@ class ProfileModule extends PLModule $page->assign('usage_req', $nom_usage); if (Env::has('submit') && ($nom_usage != $usage_old)) { + S::assert_xsrf_token(); + // on vient de recevoir une requete, differente de l'ancien nom d'usage if ($nom_usage == $nom) { $page->assign('same', true); @@ -680,7 +694,7 @@ class ProfileModule extends PLModule function handler_xnet(&$page) { $page->changeTpl('profile/groupesx.tpl'); - $page->assign('pl_title', 'Polytechnique.org - Promo, Groupes X, Binets'); + $page->setTitle('Polytechnique.org - Promo, Groupes X, Binets'); $req = XDB::query(' SELECT m.asso_id, a.nom, diminutif, a.logo IS NOT NULL AS has_logo, @@ -710,7 +724,7 @@ class ProfileModule extends PLModule function handler_admin_trombino(&$page, $uid = null, $action = null) { $page->changeTpl('profile/admin_trombino.tpl'); - $page->assign('pl_title','Polytechnique.org - Administration - Trombino'); + $page->setTitle('Polytechnique.org - Administration - Trombino'); $page->assign('uid', $uid); $q = XDB::query( @@ -721,7 +735,6 @@ class ProfileModule extends PLModule list($forlife, $promo) = $q->fetchOneRow(); switch ($action) { - case "original": header("Content-type: image/jpeg"); readfile("/home/web/trombino/photos".$promo."/".$forlife.".jpg"); @@ -729,6 +742,8 @@ class ProfileModule extends PLModule break; case "new": + S::assert_xsrf_token(); + $data = file_get_contents($_FILES['userfile']['tmp_name']); list($x, $y) = getimagesize($_FILES['userfile']['tmp_name']); $mimetype = substr($_FILES['userfile']['type'], 6); @@ -739,6 +754,8 @@ class ProfileModule extends PLModule break; case "delete": + S::assert_xsrf_token(); + XDB::execute('DELETE FROM photo WHERE uid = {?}', $uid); break; } @@ -746,7 +763,7 @@ class ProfileModule extends PLModule $page->assign('forlife', $forlife); } function handler_admin_binets(&$page, $action = 'list', $id = null) { - $page->assign('pl_title','Polytechnique.org - Administration - Binets'); + $page->setTitle('Polytechnique.org - Administration - Binets'); $page->assign('title', 'Gestion des binets'); $table_editor = new PLTableEditor('admin/binets', 'binets_def', 'id'); $table_editor->add_join_table('binets_ins','binet_id',true); @@ -754,7 +771,7 @@ class ProfileModule extends PLModule $table_editor->apply($page, $action, $id); } function handler_admin_formations(&$page, $action = 'list', $id = null) { - $page->assign('pl_title','Polytechnique.org - Administration - Formations'); + $page->setTitle('Polytechnique.org - Administration - Formations'); $page->assign('title', 'Gestion des formations'); $table_editor = new PLTableEditor('admin/formations','applis_def','id'); $table_editor->add_join_table('applis_ins','aid',true); @@ -763,21 +780,21 @@ class ProfileModule extends PLModule $table_editor->apply($page, $action, $id); } function handler_admin_sections(&$page, $action = 'list', $id = null) { - $page->assign('pl_title','Polytechnique.org - Administration - Sections'); + $page->setTitle('Polytechnique.org - Administration - Sections'); $page->assign('title', 'Gestion des sections'); $table_editor = new PLTableEditor('admin/sections','sections','id'); $table_editor->describe('text','intitulé',true); $table_editor->apply($page, $action, $id); } function handler_admin_ss_secteurs(&$page, $action = 'list', $id = null) { - $page->assign('pl_title', 'Polytechnique.org - Administration - Sous-secteurs'); + $page->setTitle('Polytechnique.org - Administration - Sous-secteurs'); $page->assign('title', 'Gestion des sous-secteurs'); $table_editor = new PLTableEditor('admin/ss_secteurs', 'emploi_ss_secteur', 'id', true); $table_editor->describe('label', 'intitulé', true); $table_editor->apply($page, $action, $id); } function handler_admin_fonctions(&$page, $action = 'list', $id = null) { - $page->assign('pl_title', 'Polytechnique.org - Administration - Fonctions'); + $page->setTitle('Polytechnique.org - Administration - Fonctions'); $page->assign('title', 'Gestion des fonctions'); $table_editor = new PLTableEditor('admin/fonctions', 'fonctions_def', 'id', true); $table_editor->describe('fonction_fr', 'intitulé', true); @@ -786,14 +803,14 @@ class ProfileModule extends PLModule $table_editor->apply($page, $action, $id); } function handler_admin_secteurs(&$page, $action = 'list', $id = null) { - $page->assign('pl_title', 'Polytechnique.org - Administration - Secteurs'); + $page->setTitle('Polytechnique.org - Administration - Secteurs'); $page->assign('title', 'Gestion des secteurs'); $table_editor = new PLTableEditor('admin/secteurs', 'emploi_secteur', 'id', true); $table_editor->describe('label', 'intitulé', true); $table_editor->apply($page, $action, $id); } function handler_admin_medals(&$page, $action = 'list', $id = null) { - $page->assign('pl_title','Polytechnique.org - Administration - Distinctions'); + $page->setTitle('Polytechnique.org - Administration - Distinctions'); $page->assign('title', 'Gestion des Distinctions'); $table_editor = new PLTableEditor('admin/medals','profile_medals','id'); $table_editor->describe('text', 'intitulé', true);