本文整理汇总了PHP中Post::v方法的典型用法代码示例。如果您正苦于以下问题:PHP Post::v方法的具体用法?PHP Post::v怎么用?PHP Post::v使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Post
的用法示例。
在下文中一共展示了Post::v方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: handler_licenses_final
public function handler_licenses_final($page, $no_reason = false)
{
$softwares = License::getSoftwares();
$keys = array();
if (Post::has('disagree') || !$no_reason && !Post::has('resend') && (!Post::has('reason') || Post::v('reason') == "") || !Post::has('software') || !in_array(Post::v('software'), array_keys($softwares))) {
$this->handler_licenses($page);
} else {
$page->changeTpl('licenses/licenses_final.tpl');
$page->assign('title', "Demande de licence pour {$softwares[Post::v('software')]}");
$page->assign('software', Post::s('software'));
$page->assign('software_name', $softwares[Post::s('software')]);
if (($key = License::adminKey(Post::s('software'))) && License::hasRights(S::user())) {
$key->give(S::user());
$page->assign('direct', true);
} elseif (Post::has('resend')) {
$l = License::fetch(array('id' => Post::i('id')));
if ($l[0]->uid() == S::user()->id()) {
License::send($l);
} else {
die("La license n'appartient pas à l'utilisateur courant");
}
$page->assign('direct', true);
} else {
$lv = new LicensesValidate(Post::s('software'), Post::s('reason'));
$v = new Validate(array('writer' => S::user(), 'group' => Group::from('licenses'), 'item' => $lv, 'type' => 'licenses'));
$v->insert();
$page->assign('direct', false);
}
}
}
示例2: handler_banana
function handler_banana($page, $group = null, $action = null, $artid = null)
{
$page->changeTpl('banana/index.tpl');
$page->setTitle('Forums & PA');
$get = array();
if (Post::has('updateall')) {
$get['updateall'] = Post::v('updateall');
}
require_once 'banana/forum.inc.php';
get_banana_params($get, $group, $action, $artid);
run_banana($page, 'ForumsBanana', $get);
}
示例3: handle_editor
protected function handle_editor()
{
$data = Post::v('valid');
if (isset($data['text']) && $data['text'] != $this->toy_text && $data['text'] != $this->given_text) {
$this->toy_text = $data['text'];
$address = new Address(array('changed' => 1, 'text' => $this->toy_text));
$address->format();
$this->address = $address->toFormArray();
}
$this->modified = isset($data['modified']);
return true;
}
示例4: handler_coml_submit
function handler_coml_submit($page)
{
$page->changeTpl('comletter/submit.tpl');
$nl = $this->getNl();
if (!$nl) {
return PL_NOT_FOUND;
}
$wp = new PlWikiPage('Xorg.LettreCommunaute');
$wp->buildCache();
if (Post::has('see') || Post::has('valid') && (!trim(Post::v('title')) || !trim(Post::v('body')))) {
if (!Post::has('see')) {
$page->trigError("L'article doit avoir un titre et un contenu");
}
$art = new ComLArticle(Post::v('title'), Post::v('body'), Post::v('append'));
$page->assign('art', $art);
} elseif (Post::has('valid')) {
$art = new ComLReq(S::user(), Post::v('title'), Post::v('body'), Post::v('append'));
$art->submit();
$page->assign('submited', true);
}
$page->addCssLink($nl->cssFile());
}
示例5: HandleAction
public function HandleAction($action)
{
switch ($action) {
case 'suscribe':
S::assert_xsrf_token();
$subs = array_keys(Post::v('sub_ml'));
$res = XDB::iterRow("SELECT sub, domain\n FROM register_subs\n WHERE uid = {?} AND type = 'list'\n ORDER BY domain", S::i('uid'));
while (list($sub, $domain) = $res->next()) {
if (array_shift($subs) == "{$sub}@{$domain}") {
MailingList::subscribeTo($sub, $domain);
}
}
$this->UpdateOnYes();
pl_redirect('lists');
break;
case 'dismiss':
$this->UpdateOnDismiss();
break;
case 'no':
$this->UpdateOnNo();
break;
}
}
示例6: handler_deceased
function handler_deceased($page, $action = '')
{
if ($action == 'updateXorg') {
XDB::execute('UPDATE fusionax_deceased
SET deces_xorg = deces_ax
WHERE deces_xorg IS NULL');
}
if ($action == 'updateAX') {
XDB::execute('UPDATE fusionax_deceased
SET deces_ax = deces_xorg
WHERE deces_ax = "0000-00-00"');
}
if ($action == 'update') {
if (Post::has('pid') && Post::has('date')) {
XDB::execute('UPDATE fusionax_deceased
SET deces_ax = {?}, deces_xorg = {?}
WHERE pid = {?}', Post::v('date'), Post::v('date'), Post::i('pid'));
}
}
$page->changeTpl('fusionax/deceased.tpl');
// deceased
$deceasedErrorsSql = XDB::query('SELECT COUNT(*) FROM fusionax_deceased');
$page->assign('deceasedErrors', $deceasedErrorsSql->fetchOneCell());
$res = XDB::iterator('SELECT pid, ax_id, promo, private_name, deces_ax
FROM fusionax_deceased
WHERE deces_xorg IS NULL
LIMIT 10');
$page->assign('nbDeceasedMissingInXorg', $res->total());
$page->assign('deceasedMissingInXorg', $res);
$res = XDB::iterator('SELECT pid, ax_id, promo, private_name, deces_xorg
FROM fusionax_deceased
WHERE deces_ax = "0000-00-00"
LIMIT 10');
$page->assign('nbDeceasedMissingInAX', $res->total());
$page->assign('deceasedMissingInAX', $res);
$res = XDB::iterator('SELECT pid, ax_id, promo, private_name, deces_xorg, deces_ax
FROM fusionax_deceased
WHERE deces_xorg != "0000-00-00" AND deces_ax != "0000-00-00"');
$page->assign('nbDeceasedDifferent', $res->total());
$page->assign('deceasedDifferent', $res);
}
示例7: handler_edit
function handler_edit($page, $action = 'show', $qid = 'root')
{
$this->load('survey.inc.php');
$action = Post::v('survey_action', $action);
$qid = Post::v('survey_qid', $qid);
if (Post::has('survey_cancel')) {
// after cancelling changes, shows the survey
if (S::has('survey')) {
$action = 'show';
} else {
// unless no editing has been done at all (shows to the surveys index page)
return $this->handler_index($page);
}
}
$page->assign('survey_editmode', true);
if (S::has('survey_id')) {
// if 'survey_id' is in session, it means we are modifying a survey in admin mode
$page->assign('survey_updatemode', true);
}
if ($action == 'show' && !S::has('survey')) {
$action = 'new';
}
if ($action == 'question') {
// {{{ modifies an existing question
if (Post::has('survey_submit')) {
// if the form has been submitted, makes the modifications
$survey = unserialize(S::v('survey'));
$args = Post::v('survey_question');
if (!$survey->editQuestion($qid, $args)) {
// update the survey object structure
return $this->show_error($page, '', 'survey/edit');
}
$this->show_survey($page, $survey);
$this->store_session($survey);
} else {
// if a form has not been submitted, shows modification form
$survey = unserialize(S::v('survey'));
$current = $survey->toArray($qid);
// gets the current parameters of the question
if ($current == null) {
return $this->show_error($page, '', 'survey/edit');
}
$this->show_form($page, $action, $qid, $current['type'], $current);
}
// }}}
} elseif ($action == 'new') {
// {{{ create a new survey : actually store the root question
if (Post::has('survey_submit')) {
// if the form has been submitted, creates the survey
$this->clear_session();
$survey = new Survey(Post::v('survey_question'));
// creates the object structure
$this->show_survey($page, $survey);
$this->store_session($survey);
} else {
$this->clear_session();
$this->show_form($page, $action, 'root', 'newsurvey');
}
// }}}
} elseif ($action == 'add') {
// {{{ adds a new question
if (Post::has('survey_submit')) {
// if the form has been submitted, adds the question
$survey = unserialize(S::v('survey'));
if (!$survey->addQuestion($qid, $survey->factory(Post::v('survey_type'), Post::v('survey_question')))) {
return $this->show_error($page, '', 'survey/edit');
}
$this->show_survey($page, $survey);
$this->store_session($survey);
} else {
$this->show_form($page, $action, $qid);
}
// }}}
} elseif ($action == 'del') {
// {{{ deletes a question
if (Post::has('survey_submit')) {
// if a confirmation has been sent, deletes the question
$survey = unserialize(S::v('survey'));
if (!$survey->delQuestion(Post::v('survey_qid'))) {
// deletes the node in the survey object structure
return $this->show_error($page, '', 'survey/edit');
}
$this->show_survey($page, $survey);
$this->store_session($survey);
} else {
// if user has not confirmed, shows a confirmation form
$survey = unserialize(S::v('survey'));
$current = $survey->toArray($qid);
// needed to get the title of the question to delete (more user-friendly than an id)
if ($current == null) {
return $this->show_error($page, '', 'survey/edit');
}
$this->show_confirm($page, 'Êtes-vous certain de vouloir supprimer la question intitulé "' . $current['question'] . '" ? ' . 'Attention, cela supprimera en même temps toutes les questions qui dépendent de celle-ci.', 'edit', array('action' => 'del', 'qid' => $qid));
}
// }}}
} elseif ($action == 'show') {
// {{{ simply shows the survey in its current state
$this->show_survey($page, unserialize(S::v('survey')));
// }}}
} elseif ($action == 'valid') {
//.........这里部分代码省略.........
示例8: handler_add_secondary_edu
function handler_add_secondary_edu($page)
{
$page->changeTpl('admin/add_secondary_edu.tpl');
if (!(Post::has('verify') || Post::has('add'))) {
return;
} elseif (!Post::has('people')) {
$page->trigWarning("Aucune information n'a été fournie.");
return;
}
require_once 'name.func.inc.php';
$lines = explode("\n", Post::t('people'));
$separator = Post::t('separator');
$degree = Post::v('degree');
$promotion = Post::i('promotion');
$schoolsList = array_flip(DirEnum::getOptions(DirEnum::EDUSCHOOLS));
$degreesList = array_flip(DirEnum::getOptions(DirEnum::EDUDEGREES));
$edu_id = $schoolsList[Profile::EDU_X];
$degree_id = $degreesList[$degree];
$res = array('incomplete' => array(), 'empty' => array(), 'multiple' => array(), 'already' => array(), 'new' => array());
$old_pids = array();
$new_pids = array();
foreach ($lines as $line) {
$line = trim($line);
$line_array = explode($separator, $line);
array_walk($line_array, 'trim');
if (count($line_array) != 3) {
$page->trigError("La ligne « {$line} » est incomplète.");
$res['incomplete'][] = $line;
continue;
}
$cond = new PFC_And(new UFC_NameTokens(split_name_for_search($line_array[0]), array(), false, false, Profile::LASTNAME));
$cond->addChild(new UFC_NameTokens(split_name_for_search($line_array[1]), array(), false, false, Profile::FIRSTNAME));
$cond->addChild(new UFC_Promo('=', UserFilter::DISPLAY, $line_array[2]));
$uf = new UserFilter($cond);
$pid = $uf->getPIDs();
$count = count($pid);
if ($count == 0) {
$page->trigError("La ligne « {$line} » ne correspond à aucun profil existant.");
$res['empty'][] = $line;
continue;
} elseif ($count > 1) {
$page->trigError("La ligne « {$line} » correspond à plusieurs profils existant.");
$res['multiple'][] = $line;
continue;
} else {
$count = XDB::fetchOneCell('SELECT COUNT(*) AS count
FROM profile_education
WHERE pid = {?} AND eduid = {?} AND degreeid = {?}', $pid, $edu_id, $degree_id);
if ($count == 1) {
$res['already'][] = $line;
$old_pids[] = $pid[0];
} else {
$res['new'][] = $line;
$new_pids[] = $pid[0];
}
}
}
$display = array();
foreach ($res as $type => $res_type) {
if (count($res_type) > 0) {
$display = array_merge($display, array('--------------------' . $type . ':'), $res_type);
}
}
$page->assign('people', implode("\n", $display));
$page->assign('promotion', $promotion);
$page->assign('degree', $degree);
if (Post::has('add')) {
$entry_year = $promotion - Profile::educationDuration($degree);
if (Post::b('force_addition')) {
$pids = array_unique(array_merge($old_pids, $new_pids));
} else {
$pids = array_unique($new_pids);
// Updates years.
if (count($old_pids)) {
XDB::execute('UPDATE profile_education
SET entry_year = {?}, grad_year = {?}, promo_year = {?}
WHERE pid IN {?} AND eduid = {?} AND degreeid = {?}', $entry_year, $promotion, $promotion, $old_pids, $edu_id, $degree_id);
}
}
// Precomputes values common to all users.
$select = XDB::format('MAX(id) + 1, pid, {?}, {?}, {?}, {?}, {?}, \'secondary\'', $edu_id, $degree_id, $entry_year, $promotion, $promotion);
XDB::startTransaction();
foreach ($pids as $pid) {
XDB::execute('INSERT INTO profile_education (id, pid, eduid, degreeid, entry_year, grad_year, promo_year, flags)
SELECT ' . $select . '
FROM profile_education
WHERE pid = {?}
GROUP BY pid', $pid);
}
XDB::commit();
}
}
示例9: handler_admin_user
function handler_admin_user($page, $user = null)
{
require_once 'emails.inc.php';
require_once 'googleapps.inc.php';
$page->changeTpl('googleapps/admin.user.tpl');
$page->setTitle('Administration Google Apps');
$page->assign('googleapps_admin', GoogleAppsAccount::is_administrator(S::v('uid')));
if (!$user && Post::has('login')) {
$user = Post::v('login');
}
$user = User::get($user);
if ($user) {
$account = new GoogleAppsAccount($user);
// Apply requested actions.
if (Post::has('suspend') && $account->active() && !$account->pending_update_suspension) {
S::assert_xsrf_token();
$account->suspend();
$page->trigSuccess('Le compte est en cours de suspension.');
} else {
if (Post::has('unsuspend') && $account->suspended() && !$account->pending_update_suspension) {
S::assert_xsrf_token();
$account->do_unsuspend();
$page->trigSuccess('Le compte est en cours de réactivation.');
} else {
if (Post::has('forcesync') && $account->active() && $account->sync_password) {
$account->set_password($user->password());
$page->trigSuccess('Le mot de passe est en cours de synchronisation.');
} else {
if (Post::has('sync') && $account->active()) {
$account->set_password($user->password());
$account->set_password_sync(true);
} else {
if (Post::has('nosync') && $account->active()) {
$account->set_password_sync(false);
}
}
}
}
}
// Displays basic account information.
$page->assign('account', $account);
$page->assign('admin_account', GoogleAppsAccount::is_administrator($user->id()));
$page->assign('googleapps_storage', Email::is_active_storage($user, 'googleapps'));
$page->assign('user', $user->id());
// Retrieves user's pending requests.
$res = XDB::iterator("SELECT q_id, q_recipient_id, p_status, j_type, UNIX_TIMESTAMP(p_entry_date) AS p_entry_date\n FROM gapps_queue\n WHERE q_recipient_id = {?}\n ORDER BY p_entry_date DESC", $user->id());
$page->assign('requests', $res);
}
}
示例10: handler_batch
function handler_batch($page)
{
$page->changeTpl('carnet/batch.tpl');
$errors = false;
$incomplete = array();
if (Post::has('add')) {
S::assert_xsrf_token();
require_once 'userset.inc.php';
require_once 'emails.inc.php';
require_once 'marketing.inc.php';
$list = explode("\n", Post::v('list'));
$origin = Post::v('origin');
foreach ($list as $item) {
if ($item = trim($item)) {
$elements = preg_split("/\\s/", $item);
$email = array_pop($elements);
if (!isvalid_email($email)) {
$page->trigError('Email invalide : ' . $email);
$incomplete[] = $item;
$errors = true;
continue;
}
$user = User::getSilent($email);
if (is_null($user)) {
$details = implode(' ', $elements);
$promo = trim(array_pop($elements));
$cond = new PFC_And();
if (preg_match('/^[MDX]\\d{4}$/', $promo)) {
$cond->addChild(new UFC_Promo('=', UserFilter::DISPLAY, $promo));
} else {
$cond->addChild(new UFC_NameTokens($promo));
}
foreach ($elements as $element) {
$cond->addChild(new UFC_NameTokens($element));
}
$uf = new UserFilter($cond);
$count = $uf->getTotalCount();
if ($count == 0) {
$page->trigError('Les informations : « ' . $item . ' » ne correspondent à aucun camarade.');
$incomplete[] = $item;
$errors = true;
continue;
} elseif ($count > 1) {
$page->trigError('Les informations : « ' . $item . ' » sont ambigues et correspondent à plusieurs camarades.');
$incomplete[] = $item;
$errors = true;
continue;
} else {
$user = $uf->getUser();
}
}
if ($user->state == 'active') {
$this->addRegistered($page, $user->profile());
} else {
if (!User::isForeignEmailAddress($email)) {
$page->trigError('Email pas encore attribué : ' . $email);
$incomplete[] = $item;
$errors = true;
} else {
$this->addNonRegistered($page, $user);
if (!Marketing::get($user->id(), $email, true)) {
check_email($email, "Une adresse surveillée est proposée au marketing par " . S::user()->login());
$market = new Marketing($user->id(), $email, 'default', null, $origin, S::v('uid'), null);
$market->add();
}
}
}
}
}
}
$page->assign('errors', $errors);
$page->assign('incomplete', $incomplete);
}
示例11: handler_admin
function handler_admin($page, $eid = null, $item_id = null)
{
global $globals;
$this->load('xnetevents.inc.php');
$evt = get_event_detail($eid, $item_id);
if (!$evt) {
return PL_NOT_FOUND;
}
$page->changeTpl('xnetevents/admin.tpl');
if (!$evt['show_participants'] && !may_update()) {
return PL_FORBIDDEN;
}
if (may_update() && Post::v('adm')) {
S::assert_xsrf_token();
$member = User::getSilent(Post::v('mail'));
if (!$member) {
$page->trigError("Membre introuvable");
}
// change the price paid by a participant
if (Env::v('adm') == 'prix' && $member) {
$amount = strtr(Env::v('montant'), ',', '.');
XDB::execute("UPDATE group_event_participants\n SET paid = paid + {?}\n WHERE uid = {?} AND eid = {?} AND nb > 0\n ORDER BY item_id ASC\n LIMIT 1", $amount, $member->uid, $evt['eid']);
subscribe_lists_event($member->uid, $evt['short_name'], 1, $amount);
}
// change the number of personns coming with a participant
if (Env::v('adm') == 'nbs' && $member) {
$res = XDB::query("SELECT SUM(paid)\n FROM group_event_participants\n WHERE uid = {?} AND eid = {?}", $member->uid, $evt['eid']);
$paid = $res->fetchOneCell();
// Ensure we have an integer
if ($paid == null) {
$paid = 0;
}
$nbs = Post::v('nb', array());
$paid_inserted = false;
foreach ($nbs as $id => $nb) {
$nb = max(intval($nb), 0);
if (!$paid_inserted && $nb > 0) {
$item_paid = $paid;
$paid_inserted = true;
} else {
$item_paid = 0;
}
XDB::execute('INSERT INTO group_event_participants (eid, uid, item_id, nb, flags, paid)
VALUES ({?}, {?}, {?}, {?}, {?}, {?})
ON DUPLICATE KEY UPDATE nb = VALUES(nb), flags = VALUES(flags), paid = VALUES(paid)', $evt['eid'], $member->uid, $id, $nb, '', $item_paid);
}
$res = XDB::query('SELECT COUNT(uid) AS cnt, SUM(nb) AS nb
FROM group_event_participants
WHERE uid = {?} AND eid = {?}
GROUP BY uid', $member->uid, $evt['eid']);
$u = $res->fetchOneAssoc();
if ($paid == 0 && Post::v('cancel')) {
XDB::execute("DELETE FROM group_event_participants\n WHERE uid = {?} AND eid = {?}", $member->uid, $evt['eid']);
$u = 0;
subscribe_lists_event($member->uid, $evt['short_name'], -1, $paid);
} else {
$u = $u['cnt'] ? $u['nb'] : null;
subscribe_lists_event($member->uid, $evt['short_name'], $u > 0 ? 1 : 0, $paid);
}
}
$evt = get_event_detail($eid, $item_id);
}
$page->assign_by_ref('evt', $evt);
$page->assign('tout', is_null($item_id));
if (count($evt['moments'])) {
$page->assign('moments', $evt['moments']);
}
if ($evt['paiement_id']) {
$infos = User::getBulkUsersWithUIDs(XDB::fetchAllAssoc('SELECT t.uid, t.amount
FROM payment_transactions AS t
LEFT JOIN group_event_participants AS ep ON(ep.uid = t.uid AND ep.eid = {?})
WHERE t.status = "confirmed" AND t.ref = {?} AND ep.uid IS NULL', $evt['eid'], $evt['paiement_id']), 'uid', 'user');
$page->assign('oublis', count($infos));
$page->assign('oubliinscription', $infos);
}
$absents = User::getBulkUsersFromDB('SELECT p.uid
FROM group_event_participants AS p
LEFT JOIN group_event_participants AS p2 ON (p2.uid = p.uid
AND p2.eid = p.eid
AND p2.nb != 0)
WHERE p.eid = {?} AND p2.eid IS NULL
GROUP BY p.uid', $evt['eid']);
$ofs = Env::i('offset');
$part = get_event_participants($evt, $item_id, UserFilter::sortByName(), NB_PER_PAGE, $ofs * NB_PER_PAGE);
$nbp = ceil($evt['user_count'] / NB_PER_PAGE);
if ($nbp > 1) {
$links = array();
if ($ofs) {
$links['précédent'] = $ofs - 1;
}
for ($i = 1; $i <= $nbp; $i++) {
$links[(string) $i] = $i - 1;
}
if ($ofs < $nbp - 1) {
$links['suivant'] = $ofs + 1;
}
$page->assign('links', $links);
}
$page->assign('absents', $absents);
$page->assign('participants', $part);
//.........这里部分代码省略.........
示例12: startSessionAs
/** Start a session as user $user
*/
protected function startSessionAs($user, $level)
{
/* Session data and required data mismatch */
if (!is_null(S::v('user')) && S::v('user')->id() != $user->id() || S::has('uid') && S::i('uid') != $user->id()) {
return false;
} else {
if (S::has('uid')) {
return true;
}
}
/* If we want to do a SUID */
if ($level == AUTH_SUID) {
S::set('auth', AUTH_MDP);
}
S::set('user', $user);
S::set('uid', $user->id());
if (!isSmartphone()) {
S::set('skin', $user->skin());
}
if (!S::suid()) {
if (Post::v('remember', 'false') == 'on') {
$this->setAccessCookie(false);
}
S::logger()->saveLastSession();
} else {
S::logger()->log("suid_start", S::v('hruid') . ' by ' . S::suid('hruid'));
}
// Set session perms from User perms
S::set('perms', $user->perms());
/* Clean temp var 'cookie_uid' */
S::kill('cookie_uid');
return true;
}
示例13: handler_delete
function handler_delete($page, $liste = null)
{
global $globals;
if (is_null($liste)) {
return PL_NOT_FOUND;
}
$mlist = $this->prepare_list($liste);
if (!$this->is_group_admin($page)) {
$this->verify_list_owner($page, $mlist);
}
$page->changeTpl('lists/delete.tpl');
if (Post::v('valid') == 'OUI') {
S::assert_xsrf_token();
if ($mlist->delete(Post::b('del_archive'))) {
require_once 'emails.inc.php';
delete_list($mlist->mbox, $mlist->domain);
$page->assign('deleted', true);
$page->trigSuccess('La liste a été détruite !');
} else {
$page->kill('Une erreur est survenue lors de la suppression de la liste.<br />' . 'Contact les administrateurs du site pour régler le problème : ' . '<a href="mailto:support@polytechnique.org">support@polytechnique.org</a>.');
}
} elseif (list($details, $options) = $mlist->getOwnerOptions()) {
if (!$details['own']) {
$page->trigWarning('Tu n\'es pas administrateur de la liste, mais du site.');
}
$page->assign_by_ref('details', $details);
$page->assign_by_ref('options', $options);
$page->assign('bogo_level', $mlist->getBogoLevel());
} else {
$page->kill("La liste n'existe pas ou tu n'as pas le droit de l'administrer.");
}
}
示例14: handler_end
function handler_end($page, $hash = null)
{
global $globals;
$_SESSION['subState'] = array('step' => 5);
// Reject registration requests from unsafe IP addresses (and remove the
// registration information from the database, to prevent IP changes).
if (check_ip('unsafe')) {
send_warning_mail('Une IP surveillée a tenté de finaliser son inscription.');
XDB::execute("DELETE FROM register_pending\n WHERE hash = {?} AND hash != 'INSCRIT'", $hash);
return PL_FORBIDDEN;
}
// Retrieve the pre-registration information using the url-provided
// authentication token.
$res = XDB::query("SELECT r.uid, p.pid, r.forlife, r.bestalias, r.mailorg2,\n r.password, r.email, r.services, r.naissance,\n ppn.lastname_initial, ppn.firstname_initial, pe.promo_year,\n pd.promo, p.sex, p.birthdate_ref, a.type, a.email AS old_account_email\n FROM register_pending AS r\n INNER JOIN accounts AS a ON (r.uid = a.uid)\n INNER JOIN account_profiles AS ap ON (a.uid = ap.uid AND FIND_IN_SET('owner', ap.perms))\n INNER JOIN profiles AS p ON (p.pid = ap.pid)\n INNER JOIN profile_public_names AS ppn ON (ppn.pid = p.pid)\n INNER JOIN profile_display AS pd ON (p.pid = pd.pid)\n INNER JOIN profile_education AS pe ON (pe.pid = p.pid AND FIND_IN_SET('primary', pe.flags))\n WHERE hash = {?} AND hash != 'INSCRIT' AND a.state = 'pending'", $hash);
if (!$hash || $res->numRows() == 0) {
$page->kill("<p>Cette adresse n'existe pas, ou plus, sur le serveur.</p>\n <p>Causes probables :</p>\n <ol>\n <li>Vérifie que tu visites l'adresse du dernier\n email reçu s'il y en a eu plusieurs.</li>\n <li>Tu as peut-être mal copié l'adresse reçue par\n email, vérifie-la à la main.</li>\n <li>Tu as peut-être attendu trop longtemps pour\n confirmer. Les pré-inscriptions sont annulées\n tous les 30 jours.</li>\n <li>Tu es en fait déjà inscrit.</li>\n </ol>");
}
list($uid, $pid, $forlife, $bestalias, $emailXorg2, $password, $email, $services, $birthdate, $lastname, $firstname, $yearpromo, $promo, $sex, $birthdate_ref, $type, $old_account_email) = $res->fetchOneRow();
$isX = $type == 'x';
$mail_domain = User::$sub_mail_domains[$type] . $globals->mail->domain;
// Prepare the template for display.
$page->changeTpl('register/end.tpl');
$page->assign('forlife', $forlife);
$page->assign('firstname', $firstname);
// Check if the user did enter a valid password; if not (or if none is found),
// get her an information page.
if (Post::has('response')) {
$expected_response = sha1("{$forlife}:{$password}:" . S::v('challenge'));
if (Post::v('response') != $expected_response) {
$page->trigError("Mot de passe invalide.");
S::logger($uid)->log('auth_fail', 'bad password (register/end)');
return;
}
} else {
return;
}
//
// Create the user account.
//
XDB::startTransaction();
XDB::execute("UPDATE accounts\n SET password = {?}, state = 'active',\n registration_date = NOW(), email = NULL\n WHERE uid = {?}", $password, $uid);
XDB::execute("UPDATE profiles\n SET birthdate = {?}, last_change = NOW()\n WHERE pid = {?}", $birthdate, $pid);
XDB::execute('INSERT INTO email_source_account (email, uid, type, flags, domain)
SELECT {?}, {?}, \'forlife\', \'\', id
FROM email_virtual_domains
WHERE name = {?}', $forlife, $uid, $mail_domain);
XDB::execute('INSERT INTO email_source_account (email, uid, type, flags, domain)
SELECT {?}, {?}, \'alias\', \'bestalias\', id
FROM email_virtual_domains
WHERE name = {?}', $bestalias, $uid, $mail_domain);
if ($emailXorg2) {
XDB::execute('INSERT INTO email_source_account (email, uid, type, flags, domain)
SELECT {?}, {?}, \'alias\', \'\', id
FROM email_virtual_domains
WHERE name = {?}', $emailXorg2, $uid, $mail_domain);
}
XDB::commit();
// Try to start a session (so the user don't have to log in); we will use
// the password available in Post:: to authenticate the user.
Platal::session()->start(AUTH_PASSWD);
// Add the registration email address as first and only redirection.
require_once 'emails.inc.php';
$user = User::getSilentWithUID($uid);
$redirect = new Redirect($user);
$redirect->add_email($email);
fix_bestalias($user);
// If the user was registered to some aliases and MLs, we must change
// the subscription to her forlife email.
if ($old_account_email) {
$listClient = new MMList($user);
$listClient->change_user_email($old_account_email, $user->forlifeEmail());
update_alias_user($old_account_email, $user->forlifeEmail());
}
// Subscribe the user to the services she did request at registration time.
require_once 'newsletter.inc.php';
foreach (explode(',', $services) as $service) {
switch ($service) {
case 'ax_letter':
/* This option is deprecated by 'com_letters' */
NewsLetter::forGroup(NewsLetter::GROUP_AX)->subscribe($user);
break;
case 'com_letters':
NewsLetter::forGroup(NewsLetter::GROUP_AX)->subscribe($user);
NewsLetter::forGroup(NewsLetter::GROUP_EP)->subscribe($user);
NewsLetter::forGroup(NewsLetter::GROUP_FX)->subscribe($user);
break;
case 'nl':
NewsLetter::forGroup(NewsLetter::GROUP_XORG)->subscribe($user);
break;
case 'imap':
Email::activate_storage($user, 'imap', Bogo::IMAP_DEFAULT);
break;
case 'ml_promo':
if ($isX) {
$r = XDB::query('SELECT id FROM groups WHERE diminutif = {?}', $yearpromo);
if ($r->numRows()) {
$asso_id = $r->fetchOneCell();
XDB::execute('INSERT IGNORE INTO group_members (uid, asso_id)
VALUES ({?}, {?})', $uid, $asso_id);
try {
//.........这里部分代码省略.........
示例15: handler_admin
function handler_admin($page)
{
$page->changeTpl('xnet/admin.tpl');
if (Get::has('del')) {
$res = XDB::query('SELECT id, nom, mail_domain
FROM groups WHERE diminutif={?}', Get::v('del'));
list($id, $nom, $domain) = $res->fetchOneRow();
$page->assign('nom', $nom);
if ($id && Post::has('del')) {
S::assert_xsrf_token();
XDB::query('DELETE FROM group_members WHERE asso_id={?}', $id);
$page->trigSuccess('membres supprimés');
if ($domain) {
XDB::execute('DELETE v
FROM email_virtual AS v
INNER JOIN email_virtual_domains AS d ON (v.domain = d.id)
WHERE d.name = {?}', $domain);
XDB::execute('DELETE FROM email_virtual_domains
WHERE name = {?}', $domain);
$page->trigSuccess('suppression des alias mails');
$mmlist = new MMList(S::v('uid'), S::v('password'), $domain);
if ($listes = $mmlist->get_lists()) {
foreach ($listes as $l) {
$mmlist->delete_list($l['list'], true);
}
$page->trigSuccess('mail lists surpprimées');
}
}
XDB::query('DELETE FROM groups WHERE id={?}', $id);
$page->trigSuccess("Groupe {$nom} supprimé");
Get::kill('del');
}
if (!$id) {
Get::kill('del');
}
}
if (Post::has('diminutif') && Post::v('diminutif') != "") {
S::assert_xsrf_token();
$res = XDB::query('SELECT COUNT(*)
FROM groups
WHERE diminutif = {?}', Post::v('diminutif'));
if ($res->fetchOneCell() == 0) {
XDB::execute('INSERT INTO groups (id, diminutif)
VALUES (NULL, {?})', Post::v('diminutif'));
pl_redirect(Post::v('diminutif') . '/edit');
} else {
$page->trigError('Le diminutif demandé est déjà pris.');
}
}
$res = XDB::query('SELECT nom, diminutif
FROM groups
ORDER BY nom');
$page->assign('assos', $res->fetchAllAssoc());
}