--- /dev/null
+[submodule "core"]
+ path = core
+ url = ./
================================================================================
+VERSION 0.9.18 XX XX XXXX
+
+Bug/Wish:
+
+ * Search:
+ - #691: Adds search on postcode and thus on "arrondissements" -JAC
+ - #791: Adds the possibility to do an exact search -JAC
+ - #822: Adds the possibility to search on diplomas -JAC
+
+================================================================================
VERSION 0.9.17 19 07 2008
New:
all: build
-build: core banana wiki medals jquery
+build: core conf banana wiki medals jquery
q:
@echo -e "Code statistics\n"
## core
##
-core: spool/templates_c spool/mails_c include/globals.inc.php configs/platal.cron htdocs/.htaccess spool/conf spool/tmp
+core:
+ [ -d core ] || ( git submodule init && git submodule update )
+ make -C core all
+
+##
+## conf
+##
+
+conf: spool/templates_c spool/mails_c classes/platalglobals.php configs/platal.cron htdocs/.htaccess spool/conf spool/tmp
spool/templates_c spool/mails_c spool/uploads spool/conf spool/tmp:
mkdir -p $@
jquery: htdocs/javascript/jquery.js htdocs/javascript/jquery.autocomplete.js $(JQUERY_PLUGINS_PATHES)
-htdocs/javascript/jquery.js: DOWNLOAD_SRC = http://jquery.com/src/jquery-latest.pack.js
+htdocs/javascript/jquery.js: DOWNLOAD_SRC = http://jquery.com/src/jquery-latest.min.js
htdocs/javascript/jquery.js:
@$(download)
################################################################################
-.PHONY: build dist clean wiki build-wiki banana htdocs/images/banana htdocs/css/banana.css include/banana/banana.inc.php http*
+.PHONY: build dist clean core wiki build-wiki banana htdocs/images/banana htdocs/css/banana.css include/banana/banana.inc.php http*
* 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA *
***************************************************************************/
-ini_set('include_path',dirname(__FILE__).'/../include:' . dirname(__FILE__).'/../classes:/usr/share/php');
-
+ini_set('include_path', dirname(__FILE__) . '/../core/include:'
+ . dirname(__FILE__) . '/../include:'
+ . dirname(__FILE__) . '/../core/classes:'
+ . dirname(__FILE__) . '/../classes:'
+ . '/usr/share/php');
require_once('xorg.inc.php');
-require_once('xorg.misc.inc.php');
-require_once 'xdb.php';
+new Xorg('core');
// vim:set et sw=4 sts=4 sws=4 foldmethod=marker enc=utf-8:
?>
* 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA *
***************************************************************************/
-require_once(dirname(__FILE__) . '/../classes/csvimporter.php');
+require_once(dirname(__FILE__) . '/../core/classes/csvimporter.php');
// {{{ function showHelp()
$keys = 'id';
processArgs();
-require_once(dirname(__FILE__) . '/../classes/xdb.php');
+require_once(dirname(__FILE__) . '/../core/classes/xdb.php');
$source = file_get_contents($sourceName);
$insert_relation = null;
ini_set('include_path', '.:../include:/usr/share/php');
require_once('connect.db.inc.php');
-require_once('xorg.inc.php');
require_once('emails.inc.php');
$opts = getopt('o:');
ini_set('include_path', '.:../include:/usr/share/php');
require_once('connect.db.inc.php');
-require_once('xorg.inc.php');
require_once('emails.inc.php');
require_once('../classes/plmailer.php');
#!/usr/bin/php5 -q
<?php
-require_once("xorg.inc.php");
+
+require_once(dirname(__FILE__) . '/connect.db.inc.php');
require_once('validations.inc.php');
global $globals;
#!/usr/bin/env python
#***************************************************************************
-#* Copyright (C) 2004 polytechnique.org *
+#* Copyright (C) 2004-2008 polytechnique.org *
#* http://opensource.polytechnique.org/ *
#* *
#* This program is free software; you can redistribute it and/or modify *
VHOST_SEP = get_config('Lists', 'vhost_sep', '_')
ON_CREATE_CMD = get_config('Lists', 'on_create', '')
+SRV_HOST = get_config('Lists', 'rpchost', 'localhost')
+SRV_PORT = int(get_config('Lists', 'rpcport', '4949'))
+
################################################################################
#
# CLASSES
argument a UserDesc taken from the database, containing name, email and perms
"""
+ def _get_function(self, method):
+ try:
+ # check to see if a matching function has been registered
+ return self.server.funcs[method]
+ except:
+ raise Exception('method "%s" is not supported' % method)
+
+
def _dispatch(self, method, params):
- # TODO: subclass in SimpleXMLRPCDispatcher and not here.
new_params = list(params)
- new_params.insert(0, self.data[2])
- new_params.insert(0, self.data[1])
- new_params.insert(0, self.data[0])
- return self.server._dispatch(method, new_params)
+ return list_call_dispatcher(self._get_function(method), self.data[0], self.data[1], self.data[2], *params)
def do_POST(self):
try:
elif os.path.isdir(filename):
shutil.rmtree(filename)
+##
+# Call dispatcher
+##
+
+def has_annotation(method, name):
+ """ Check if the method contains the given annoation.
+ """
+ return method.__doc__ and method.__doc__.find("@%s" % name) > -1
+
+def list_call_dispatcher(method, userdesc, perms, vhost, *arg):
+ """Dispatch the call to the right handler.
+ This function checks the options of the called method the set the environment of the call.
+ The dispatcher uses method annotation (special tokens in the documentation of the method) to
+ guess the requested environment:
+ @mlist: the handler requires a mlist object instead of the vhost/listname couple
+ @lock: the handler requires the mlist to be locked (@mlist MUST be specified)
+ @edit: the handler edit the mlist (@mlist MUST be specified)
+ @admin: the handler requires admin rights on the list (@mlist MUST be specified)
+ @root: the handler requires site admin rights
+ """
+ try:
+ if has_annotation(method, "root") and perms != "admin":
+ return 0
+ if has_annotation(method, "mlist"):
+ listname = arg[0]
+ arg = arg[1:]
+ mlist = MailList.MailList(vhost + VHOST_SEP + listname.lower(), lock=0)
+ if has_annotation(method, "admin") and not is_admin_on(userdesc, perms, mlist):
+ return 0
+ if has_annotation(method, "edit") or has_annotation(method, "lock"):
+ return list_call_locked(method, userdesc, perms, mlist, has_annotation(method, "edit"), *arg)
+ else:
+ return method(userdesc, perms, mlist, *arg)
+ else:
+ return method(userdesc, perms, vhost, *arg)
+ except Exception, e:
+ raise e
+ return 0
+
+def list_call_locked(method, userdesc, perms, mlist, edit, *arg):
+ """Call the given method after locking the mlist.
+ """
+ try:
+ mlist.Lock()
+ ret = method(userdesc, perms, mlist, *arg)
+ if edit:
+ mlist.Save()
+ mlist.Unlock()
+ return ret
+ except:
+ mlist.Unlock()
+ return 0
+ # TODO: use finally when switching to python 2.5
+
#-------------------------------------------------------------------------------
# helpers on lists
#
+def is_subscription_pending(userdesc, perms, mlist, edit):
+ for id in mlist.GetSubscriptionIds():
+ if userdesc.address == mlist.GetRecord(id)[1]:
+ return True
+ return False
+
def get_list_info(userdesc, perms, mlist, front_page=0):
members = mlist.getRegularMemberKeys()
is_member = userdesc.address in members
if mlist.advertised or is_member or is_owner or (not front_page and perms == 'admin'):
is_pending = False
if not is_member and (mlist.subscribe_policy > 1):
- try:
- mlist.Lock()
- for id in mlist.GetSubscriptionIds():
- if userdesc.address == mlist.GetRecord(id)[1]:
- is_pending = 1
- break
- mlist.Unlock()
- except:
- mlist.Unlock()
+ is_pending = list_call_locked(userdesc, perms, mlist, is_subscription_pending, False)
+ if is_pending is 0:
return 0
host = mlist.internal_name().split(VHOST_SEP)[0].lower()
return (details, members)
return 0
-def get_options(userdesc, perms, vhost, listname, opts):
- try:
- mlist = MailList.MailList(vhost+VHOST_SEP+listname.lower(), lock=0)
- except:
- return 0
- try:
- if not is_admin_on(userdesc, perms, mlist):
- return 0
- options = { }
- for (k, v) in mlist.__dict__.iteritems():
- if k in opts:
- if type(v) is str:
- options[k] = quote(v)
- else: options[k] = v
- details = get_list_info(userdesc, perms, mlist)[0]
- return (details, options)
- except:
- return 0
-
-def set_options(userdesc, perms, vhost, listname, opts, vals):
- try:
- mlist = MailList.MailList(vhost+VHOST_SEP+listname.lower(), lock=0)
- except:
- return 0
- try:
- if not is_admin_on(userdesc, perms, mlist):
- return 0
- mlist.Lock()
- for (k, v) in vals.iteritems():
- if k not in opts:
- continue
- if k == 'default_member_moderation':
- for member in mlist.getMembers():
- mlist.setMemberOption(member, mm_cfg.Moderate, int(v))
- t = type(mlist.__dict__[k])
- if t is bool: mlist.__dict__[k] = bool(v)
- elif t is int: mlist.__dict__[k] = int(v)
- elif t is str: mlist.__dict__[k] = Utils.uncanonstr(v, 'fr')
- else: mlist.__dict__[k] = v
- mlist.Save()
- mlist.Unlock()
- return 1
- except:
- mlist.Unlock()
- return 0
+def get_options(userdesc, perms, mlist, opts):
+ """ Get the options of a list.
+ @mlist
+ @admin
+ """
+ options = { }
+ for (k, v) in mlist.__dict__.iteritems():
+ if k in opts:
+ if type(v) is str:
+ options[k] = quote(v)
+ else: options[k] = v
+ details = get_list_info(userdesc, perms, mlist)[0]
+ return (details, options)
+
+def set_options(userdesc, perms, mlist, vals):
+ """ Set the options of a list.
+ @mlist
+ @edit
+ @admin
+ """
+ for (k, v) in vals.iteritems():
+ if k not in opts:
+ continue
+ if k == 'default_member_moderation':
+ for member in mlist.getMembers():
+ mlist.setMemberOption(member, mm_cfg.Moderate, int(v))
+ t = type(mlist.__dict__[k])
+ if t is bool: mlist.__dict__[k] = bool(v)
+ elif t is int: mlist.__dict__[k] = int(v)
+ elif t is str: mlist.__dict__[k] = Utils.uncanonstr(v, 'fr')
+ else: mlist.__dict__[k] = v
+ return 1
#-------------------------------------------------------------------------------
# users procedures for [ index.php ]
#
def get_lists(userdesc, perms, vhost, email=None):
+ """ List available lists for the given vhost
+ """
if email is None:
udesc = userdesc
else:
continue
return result
-def subscribe(userdesc, perms, vhost, listname):
- try:
- mlist = MailList.MailList(vhost+VHOST_SEP+listname.lower(), lock=0)
- except:
- return 0
- try:
- mlist.Lock()
- if ( mlist.subscribe_policy in (0, 1) ) or userdesc.address in mlist.owner:
- mlist.ApprovedAddMember(userdesc)
- result = 2
- else:
- result = 1
- try:
- mlist.AddMember(userdesc)
- except Errors.MMNeedApproval:
- pass
- mlist.Save()
- except:
- result = 0
- mlist.Unlock()
+def subscribe(userdesc, perms, mlist):
+ """ Subscribe to a list.
+ @mlist
+ @edit
+ """
+ if ( mlist.subscribe_policy in (0, 1) ) or userdesc.address in mlist.owner:
+ mlist.ApprovedAddMember(userdesc)
+ result = 2
+ else:
+ result = 1
+ try:
+ mlist.AddMember(userdesc)
+ except Errors.MMNeedApproval:
+ pass
return result
-def unsubscribe(userdesc, perms, vhost, listname):
- try:
- mlist = MailList.MailList(vhost+VHOST_SEP+listname.lower(), lock=0)
- except:
- return 0
- try:
- mlist.Lock()
- mlist.ApprovedDeleteMember(userdesc.address)
- mlist.Save()
- mlist.Unlock()
- return 1
- except:
- mlist.Unlock()
- return 0
+def unsubscribe(userdesc, perms, mlist):
+ """ Unsubscribe from a list
+ @mlist
+ @edit
+ """
+ mlist.ApprovedDeleteMember(userdesc.address)
+ return 1
#-------------------------------------------------------------------------------
# users procedures for [ index.php ]
except:
return ''
-def get_members(userdesc, perms, vhost, listname):
- try:
- mlist = MailList.MailList(vhost+VHOST_SEP+listname.lower(), lock=0)
- except:
- return 0
- try:
- details, members = get_list_info(userdesc, perms, mlist)
- members.sort()
- members = map(lambda member: (get_name(member), member), members)
- return (details, members, mlist.owner)
- except:
- return 0
+def get_members(userdesc, perms, mlist):
+ """ List the members of a list.
+ @mlist
+ """
+ details, members = get_list_info(userdesc, perms, mlist)
+ members.sort()
+ members = map(lambda member: (get_name(member), member), members)
+ return (details, members, mlist.owner)
+
#-------------------------------------------------------------------------------
# users procedures for [ trombi.php ]
#
-def get_members_limit(userdesc, perms, vhost, listname, page, nb_per_page):
- try:
- members = get_members(userdesc, perms, vhost, listname.lower())[1]
- except:
- return 0
+def get_members_limit(userdesc, perms, mlist, page, nb_per_page):
+ """ Get a range of members of the list.
+ @mlist
+ """
+ members = get_members(userdesc, perms, mlist)[1]
i = int(page) * int(nb_per_page)
return (len(members), members[i:i+int(nb_per_page)])
-def get_owners(userdesc, perms, vhost, listname):
- try:
- details, members, owners = get_members(userdesc, perms, vhost, listname.lower())
- except:
- return 0
+def get_owners(userdesc, perms, mlist):
+ """ Get the owners of the list.
+ @mlist
+ """
+ details, members, owners = get_members(userdesc, perms, mlist)
return (details, owners)
+
#-------------------------------------------------------------------------------
# owners procedures [ admin.php ]
#
-def replace_email(userdesc, perms, vhost, listname, from_email, to_email):
- try:
- mlist = MailList.MailList(vhost+VHOST_SEP+listname.lower(), lock=0)
- except:
- return 0
- try:
- if not is_admin_on(userdesc, perms, mlist):
- return 0
-
- mlist.Lock()
- mlist.ApprovedChangeMemberAddress(from_email.lower(), to_email.lower(), 0)
- mlist.Save()
- mlist.Unlock()
- return 1
- except:
- return 0
-
-def mass_subscribe(userdesc, perms, vhost, listname, users):
- try:
- mlist = MailList.MailList(vhost+VHOST_SEP+listname.lower(), lock=0)
- except:
- return 0
- try:
- if not is_admin_on(userdesc, perms, mlist):
- return 0
+def replace_email(userdesc, perms, mlist, from_email, to_email):
+ """ Replace the address of a member by another one.
+ @mlist
+ @edit
+ @admin
+ """
+ mlist.ApprovedChangeMemberAddress(from_email.lower(), to_email.lower(), 0)
+ return 1
- members = mlist.getRegularMemberKeys()
- added = []
- mlist.Lock()
- for user in users:
- email, name = to_forlife(user)
- if ( email is None ) or ( email in members ):
- continue
- userd = UserDesc(email, name, None, 0)
- mlist.ApprovedAddMember(userd)
- added.append( (quote(userd.fullname), userd.address) )
- mlist.Save()
- except:
- pass
- mlist.Unlock()
+def mass_subscribe(userdesc, perms, mlist, users):
+ """ Add a list of users to the list.
+ @mlist
+ @edit
+ @admin
+ """
+ members = mlist.getRegularMemberKeys()
+ added = []
+ mlist.Lock()
+ for user in users:
+ email, name = to_forlife(user)
+ if ( email is None ) or ( email in members ):
+ continue
+ userd = UserDesc(email, name, None, 0)
+ mlist.ApprovedAddMember(userd)
+ added.append( (quote(userd.fullname), userd.address) )
return added
-def mass_unsubscribe(userdesc, perms, vhost, listname, users):
- try:
- mlist = MailList.MailList(vhost+VHOST_SEP+listname.lower(), lock=0)
- except:
- return 0
- try:
- if not is_admin_on(userdesc, perms, mlist):
- return 0
-
- mlist.Lock()
- map(lambda user: mlist.ApprovedDeleteMember(user), users)
- mlist.Save()
- except:
- pass
- mlist.Unlock()
+def mass_unsubscribe(userdesc, perms, mlist, users):
+ """ Remove a list of users from the list.
+ @mlist
+ @edit
+ @admin
+ """
+ map(lambda user: mlist.ApprovedDeleteMember(user), users)
return users
-def add_owner(userdesc, perms, vhost, listname, user):
- try:
- mlist = MailList.MailList(vhost+VHOST_SEP+listname.lower(), lock=0)
- except:
+def add_owner(userdesc, perms, mlist, user):
+ """ Add a owner to the list.
+ @mlist
+ @edit
+ @admin
+ """
+ email = to_forlife(user)[0]
+ if email is None:
return 0
- try:
- if not is_admin_on(userdesc, perms, mlist):
- return 0
- email = to_forlife(user)[0]
- if email is None:
- return 0
- if email not in mlist.owner:
- mlist.Lock()
- mlist.owner.append(email)
- mlist.Save()
- except:
- pass
- mlist.Unlock()
+ if email not in mlist.owner:
+ mlist.owner.append(email)
return True
-def del_owner(userdesc, perms, vhost, listname, user):
- try:
- mlist = MailList.MailList(vhost+VHOST_SEP+listname.lower(), lock=0)
- except:
+def del_owner(userdesc, perms, mlist, user):
+ """ Remove a owner of the list.
+ @mlist
+ @edit
+ @admin
+ """
+ if len(mlist.owner) < 2:
return 0
- try:
- if not is_admin_on(userdesc, perms, mlist):
- return 0
- if len(mlist.owner) < 2:
- return 0
- mlist.Lock()
- mlist.owner.remove(user)
- mlist.Save()
- except:
- pass
- mlist.Unlock()
+ mlist.owner.remove(user)
return True
#-------------------------------------------------------------------------------
# owners procedures [ admin.php ]
#
-def get_pending_ops(userdesc, perms, vhost, listname):
- try:
- mlist = MailList.MailList(vhost+VHOST_SEP+listname.lower(), lock=0)
- except:
- return 0
- try:
- if not is_admin_on(userdesc, perms, mlist):
- return 0
-
- mlist.Lock()
-
- subs = []
- seen = []
- dosave = False
- for id in mlist.GetSubscriptionIds():
- time, addr, fullname, passwd, digest, lang = mlist.GetRecord(id)
- if addr in seen:
- mlist.HandleRequest(id, mm_cfg.DISCARD)
- dosave = True
- continue
- seen.append(addr)
- try:
- login = re.match("^[^.]*\.[^.]*\.\d\d\d\d$", addr.split('@')[0]).group()
- subs.append({'id': id, 'name': quote(fullname), 'addr': addr, 'login': login })
- except:
- subs.append({'id': id, 'name': quote(fullname), 'addr': addr })
-
- helds = []
- for id in mlist.GetHeldMessageIds():
- ptime, sender, subject, reason, filename, msgdata = mlist.GetRecord(id)
- fpath = os.path.join(mm_cfg.DATA_DIR, filename)
- try:
- size = os.path.getsize(fpath)
- except OSError, e:
- if e.errno <> errno.ENOENT: raise
- continue
- try:
- msg = readMessage(fpath)
- fromX = msg.has_key("X-Org-Mail")
- except:
- pass
- helds.append({
- 'id' : id,
- 'sender': quote(sender, True),
- 'size' : size,
- 'subj' : quote(subject, True),
- 'stamp' : ptime,
- 'fromx' : fromX
- })
- if dosave: mlist.Save()
- mlist.Unlock()
- except:
- mlist.Unlock()
- return 0
- return (subs, helds)
-
-def handle_request(userdesc, perms, vhost, listname, id, value, comment):
- try:
- mlist = MailList.MailList(vhost+VHOST_SEP+listname.lower(), lock=0)
- except:
- return 0
- try:
- if not is_admin_on(userdesc, perms, mlist):
- return 0
- mlist.Lock()
- mlist.HandleRequest(int(id), int(value), comment)
- mlist.Save()
- mlist.Unlock()
- return 1
- except:
- mlist.Unlock()
- return 0
-
-def get_pending_sub(userdesc, perms, vhost, listname, id):
- try:
- mlist = MailList.MailList(vhost+VHOST_SEP+listname.lower(), lock=0)
- except:
- return 0
- try:
- if not is_admin_on(userdesc, perms, mlist):
- return 0
-
- mlist.Lock()
- sub = 0
- id = int(id)
- if id in mlist.GetSubscriptionIds():
- time, addr, fullname, passwd, digest, lang = mlist.GetRecord(id)
- try:
- login = re.match("^[^.]*\.[^.]*\.\d\d\d\d$", addr.split('@')[0]).group()
- sub = {'id': id, 'name': quote(fullname), 'addr': addr, 'login': login }
- except:
- sub = {'id': id, 'name': quote(fullname), 'addr': addr }
- mlist.Unlock()
- except:
- mlist.Unlock()
- return 0
- return sub
+def get_pending_ops(userdesc, perms, mlist):
+ """ Get the list of operation waiting for an action from the owners.
+ @mlist
+ @lock
+ @admin
+ """
+ subs = []
+ seen = []
+ dosave = False
+ for id in mlist.GetSubscriptionIds():
+ time, addr, fullname, passwd, digest, lang = mlist.GetRecord(id)
+ if addr in seen:
+ mlist.HandleRequest(id, mm_cfg.DISCARD)
+ dosave = True
+ continue
+ seen.append(addr)
+ try:
+ login = re.match("^[^.]*\.[^.]*\.\d\d\d\d$", addr.split('@')[0]).group()
+ subs.append({'id': id, 'name': quote(fullname), 'addr': addr, 'login': login })
+ except:
+ subs.append({'id': id, 'name': quote(fullname), 'addr': addr })
-def get_pending_mail(userdesc, perms, vhost, listname, id, raw=0):
- try:
- mlist = MailList.MailList(vhost+VHOST_SEP+listname.lower(), lock=0)
- except:
- return 0
- try:
- if not is_admin_on(userdesc, perms, mlist):
- return 0
- mlist.Lock()
- ptime, sender, subject, reason, filename, msgdata = mlist.GetRecord(int(id))
+ helds = []
+ for id in mlist.GetHeldMessageIds():
+ ptime, sender, subject, reason, filename, msgdata = mlist.GetRecord(id)
fpath = os.path.join(mm_cfg.DATA_DIR, filename)
- size = os.path.getsize(fpath)
- msg = readMessage(fpath)
- mlist.Unlock()
-
- if raw:
- return quote(str(msg))
- results_plain = []
- results_html = []
- for part in typed_subpart_iterator(msg, 'text', 'plain'):
- c = part.get_payload()
- if c is not None: results_plain.append (c)
- results_plain = map(lambda x: quote(x), results_plain)
- for part in typed_subpart_iterator(msg, 'text', 'html'):
- c = part.get_payload()
- if c is not None: results_html.append (c)
- results_html = map(lambda x: quote(x), results_html)
- return {'id' : id,
+ try:
+ size = os.path.getsize(fpath)
+ except OSError, e:
+ if e.errno <> errno.ENOENT: raise
+ continue
+ try:
+ msg = readMessage(fpath)
+ fromX = msg.has_key("X-Org-Mail")
+ except:
+ pass
+ helds.append({
+ 'id' : id,
'sender': quote(sender, True),
'size' : size,
'subj' : quote(subject, True),
'stamp' : ptime,
- 'parts_plain' : results_plain,
- 'parts_html': results_html }
- except:
- mlist.Unlock()
- return 0
+ 'fromx' : fromX
+ })
+ if dosave:
+ mlist.Save()
+ return (subs, helds)
+
+def handle_request(userdesc, perms, mlist, id, value, comment):
+ """ Handle a moderation request.
+ @mlist
+ @edit
+ @admin
+ """
+ mlist.HandleRequest(int(id), int(value), comment)
+ return 1
+
+def get_pending_sub(userdesc, perms, mlist, id):
+ """ Get informations about a given subscription moderation.
+ @mlist
+ @lock
+ @admin
+ """
+ sub = 0
+ id = int(id)
+ if id in mlist.GetSubscriptionIds():
+ time, addr, fullname, passwd, digest, lang = mlist.GetRecord(id)
+ try:
+ login = re.match("^[^.]*\.[^.]*\.\d\d\d\d$", addr.split('@')[0]).group()
+ sub = {'id': id, 'name': quote(fullname), 'addr': addr, 'login': login }
+ except:
+ sub = {'id': id, 'name': quote(fullname), 'addr': addr }
+ return sub
+
+def get_pending_mail(userdesc, perms, mlist, id, raw=0):
+ """ Get informations about a given mail moderation.
+ @mlist
+ @lock
+ @admin
+ """
+ ptime, sender, subject, reason, filename, msgdata = mlist.GetRecord(int(id))
+ fpath = os.path.join(mm_cfg.DATA_DIR, filename)
+ size = os.path.getsize(fpath)
+ msg = readMessage(fpath)
+
+ if raw:
+ return quote(str(msg))
+ results_plain = []
+ results_html = []
+ for part in typed_subpart_iterator(msg, 'text', 'plain'):
+ c = part.get_payload()
+ if c is not None: results_plain.append (c)
+ results_plain = map(lambda x: quote(x), results_plain)
+ for part in typed_subpart_iterator(msg, 'text', 'html'):
+ c = part.get_payload()
+ if c is not None: results_html.append (c)
+ results_html = map(lambda x: quote(x), results_html)
+ return {'id' : id,
+ 'sender': quote(sender, True),
+ 'size' : size,
+ 'subj' : quote(subject, True),
+ 'stamp' : ptime,
+ 'parts_plain' : results_plain,
+ 'parts_html': results_html }
#-------------------------------------------------------------------------------
# owner options [ options.php ]
'subject_prefix', 'goodbye_msg', 'send_goodbye_msg', 'subscribe_policy', \
'welcome_msg']
-def get_owner_options(userdesc, perms, vhost, listname):
- return get_options(userdesc, perms, vhost, listname.lower(), owner_opts)
+def get_owner_options(userdesc, perms, mlist):
+ """ Get the owner options of a list.
+ @mlist
+ @admin
+ """
+ return get_options(userdesc, perms, mlist, owner_opts)
-def set_owner_options(userdesc, perms, vhost, listname, values):
- return set_options(userdesc, perms, vhost, listname.lower(), owner_opts, values)
+def set_owner_options(userdesc, perms, mlist, values):
+ """ Set the owner options of a list.
+ @mlist
+ @edit
+ @admin
+ """
+ return set_options(userdesc, perms, mlist, owner_opts, values)
-def add_to_wl(userdesc, perms, vhost, listname, addr):
- try:
- mlist = MailList.MailList(vhost+VHOST_SEP+listname.lower(), lock=0)
- except:
- return 0
- try:
- if not is_admin_on(userdesc, perms, mlist):
- return 0
- mlist.Lock()
- mlist.accept_these_nonmembers.append(addr)
- mlist.Save()
- mlist.Unlock()
- return 1
- except:
- mlist.Unlock()
- return 0
+def add_to_wl(userdesc, perms, mlist, addr):
+ """ Add addr to the whitelist
+ @mlist
+ @edit
+ @admin
+ """
+ mlist.accept_these_nonmembers.append(addr)
+ return 1
-def del_from_wl(userdesc, perms, vhost, listname, addr):
- try:
- mlist = MailList.MailList(vhost+VHOST_SEP+listname.lower(), lock=0)
- except:
- return 0
- try:
- if not is_admin_on(userdesc, perms, mlist):
- return 0
- mlist.Lock()
- mlist.accept_these_nonmembers.remove(addr)
- mlist.Save()
- mlist.Unlock()
- return 1
- except:
- mlist.Unlock()
- return 0
+def del_from_wl(userdesc, perms, mlist, addr):
+ """ Remove an address from the whitelist
+ @mlist
+ @edit
+ @admin
+ """
+ mlist.accept_these_nonmembers.remove(addr)
+ return 1
-def get_bogo_level(userdesc, perms, vhost, listname):
- """ Compute bogo level from the filtering rules set up on the list. """
- try:
- mlist = MailList.MailList(vhost+VHOST_SEP+listname.lower(), lock=0)
- except:
+def get_bogo_level(userdesc, perms, mlist):
+ """ Compute bogo level from the filtering rules set up on the list.
+ @mlist
+ @admin
+ """
+ if len(mlist.header_filter_rules) == 0:
return 0
- try:
- if not is_admin_on(userdesc, perms, mlist):
- return 0
- if len(mlist.header_filter_rules) == 0:
- return 0
- unsurelevel = 0
- filterlevel = 0
- filterbase = 0
+ unsurelevel = 0
+ filterlevel = 0
+ filterbase = 0
- # The first rule filters Unsure mails
- if mlist.header_filter_rules[0][0] == 'X-Spam-Flag: Unsure, tests=bogofilter':
- unsurelevel = 1
- filterbase = 1
+ # The first rule filters Unsure mails
+ if mlist.header_filter_rules[0][0] == 'X-Spam-Flag: Unsure, tests=bogofilter':
+ unsurelevel = 1
+ filterbase = 1
- # Check the other rules:
- # - we have 2 rules: this is level 2 (drop > 0.999999, moderate Yes)
- # - we have only one rule with HOLD directive : this is level 1 (moderate spams)
- # - we have only one rule with DISCARD directive : this is level 3 (drop spams)
- try:
- action = mlist.header_filter_rules[filterbase + 1][1]
- filterlevel = 2
- except:
- action = mlist.header_filter_rules[filterbase][1]
- if action == mm_cfg.HOLD:
- filterlevel = 1
- elif action == mm_cfg.DISCARD:
- filterlevel = 3
- return (filterlevel << 1) + unsurelevel
+ # Check the other rules:
+ # - we have 2 rules: this is level 2 (drop > 0.999999, moderate Yes)
+ # - we have only one rule with HOLD directive : this is level 1 (moderate spams)
+ # - we have only one rule with DISCARD directive : this is level 3 (drop spams)
+ try:
+ action = mlist.header_filter_rules[filterbase + 1][1]
+ filterlevel = 2
except:
- return 0
+ action = mlist.header_filter_rules[filterbase][1]
+ if action == mm_cfg.HOLD:
+ filterlevel = 1
+ elif action == mm_cfg.DISCARD:
+ filterlevel = 3
+ return (filterlevel << 1) + unsurelevel
def set_bogo_level(userdesc, perms, vhost, listname, level):
- """ set filter to the specified level. """
- try:
- mlist = MailList.MailList(vhost+VHOST_SEP+listname.lower(), lock=0)
- except:
- return 0
- try:
- if not is_admin_on(userdesc, perms, mlist):
- return 0
- hfr = []
-
- # The level is a combination of a spam filtering level and unsure filtering level
- # - the unsure filtering level is only 1 bit (1 = HOLD unsures, 0 = Accept unsures)
- # - the spam filtering level is a number growing with filtering strength
- # (0 = no filtering, 1 = moderate spam, 2 = drop 0.999999 and moderate others, 3 = drop spams)
- bogolevel = int(level)
- filterlevel = bogolevel >> 1
- unsurelevel = bogolevel & 1
-
- # Set up unusre filtering
- if unsurelevel == 1:
- hfr.append(('X-Spam-Flag: Unsure, tests=bogofilter', mm_cfg.HOLD, False))
-
- # Set up spam filtering
- if filterlevel is 1:
- hfr.append(('X-Spam-Flag: Yes, tests=bogofilter', mm_cfg.HOLD, False))
- elif filterlevel is 2:
- hfr.append(('X-Spam-Flag: Yes, tests=bogofilter, spamicity=(0\.999999|1\.000000)', mm_cfg.DISCARD, False))
- hfr.append(('X-Spam-Flag: Yes, tests=bogofilter', mm_cfg.HOLD, False))
- elif filterlevel is 3:
- hfr.append(('X-Spam-Flag: Yes, tests=bogofilter', mm_cfg.DISCARD, False))
-
- # save configuration
- if mlist.header_filter_rules != hfr:
- mlist.Lock()
- mlist.header_filter_rules = hfr
- mlist.Save()
- mlist.Unlock()
- return 1
- except:
- mlist.Unlock()
- return 0
+ """ Set filter to the specified level.
+ @mlist
+ @edit
+ @admin
+ """
+ hfr = []
+
+ # The level is a combination of a spam filtering level and unsure filtering level
+ # - the unsure filtering level is only 1 bit (1 = HOLD unsures, 0 = Accept unsures)
+ # - the spam filtering level is a number growing with filtering strength
+ # (0 = no filtering, 1 = moderate spam, 2 = drop 0.999999 and moderate others, 3 = drop spams)
+ bogolevel = int(level)
+ filterlevel = bogolevel >> 1
+ unsurelevel = bogolevel & 1
+
+ # Set up unusre filtering
+ if unsurelevel == 1:
+ hfr.append(('X-Spam-Flag: Unsure, tests=bogofilter', mm_cfg.HOLD, False))
+
+ # Set up spam filtering
+ if filterlevel is 1:
+ hfr.append(('X-Spam-Flag: Yes, tests=bogofilter', mm_cfg.HOLD, False))
+ elif filterlevel is 2:
+ hfr.append(('X-Spam-Flag: Yes, tests=bogofilter, spamicity=(0\.999999|1\.000000)', mm_cfg.DISCARD, False))
+ hfr.append(('X-Spam-Flag: Yes, tests=bogofilter', mm_cfg.HOLD, False))
+ elif filterlevel is 3:
+ hfr.append(('X-Spam-Flag: Yes, tests=bogofilter', mm_cfg.DISCARD, False))
+
+ # save configuration
+ if mlist.header_filter_rules != hfr:
+ mlist.header_filter_rules = hfr
+ return 1
#-------------------------------------------------------------------------------
# admin procedures [ soptions.php ]
admin_opts = [ 'advertised', 'archive', \
'max_message_size', 'msg_footer', 'msg_header']
-def get_admin_options(userdesc, perms, vhost, listname):
- if perms != 'admin':
- return 0
- return get_options(userdesc, perms, vhost, listname.lower(), admin_opts)
+def get_admin_options(userdesc, perms, mlist):
+ """ Get administrator options.
+ @mlist
+ @root
+ """
+ return get_options(userdesc, perms, mlist, admin_opts)
-def set_admin_options(userdesc, perms, vhost, listname, values):
- if perms != 'admin':
- return 0
- return set_options(userdesc, perms, vhost, listname.lower(), admin_opts, values)
+def set_admin_options(userdesc, perms, mlist, values):
+ """ Set administrator options.
+ @mlist
+ @edit
+ @root
+ """
+ return set_options(userdesc, perms, mlist, admin_opts, values)
#-------------------------------------------------------------------------------
# admin procedures [ check.php ]
'unsubscribe_policy' : 0,
}
+def check_options_runner(userdesc, perms, mlist, listname, correct):
+ options = { }
+ for (k, v) in check_opts.iteritems():
+ if mlist.__dict__[k] != v:
+ options[k] = v, mlist.__dict__[k]
+ if correct: mlist.__dict__[k] = v
+ if mlist.real_name.lower() != listname:
+ options['real_name'] = listname, mlist.real_name
+ if correct: mlist.real_name = listname
+ details = get_list_info(userdesc, perms, mlist)[0]
+ return (details, options)
+
+
def check_options(userdesc, perms, vhost, listname, correct=False):
+ """ Check the list.
+ @root
+ """
listname = listname.lower()
- try:
- mlist = MailList.MailList(vhost+VHOST_SEP+listname, lock=0)
- except:
- return 0
- try:
- if perms != 'admin': return 0
- if correct:
- mlist.Lock()
- options = { }
- for (k, v) in check_opts.iteritems():
- if mlist.__dict__[k] != v:
- options[k] = v, mlist.__dict__[k]
- if correct: mlist.__dict__[k] = v
- if mlist.real_name.lower() != listname:
- options['real_name'] = listname, mlist.real_name
- if correct: mlist.real_name = listname
- if correct:
- mlist.Save()
- mlist.Unlock()
- details = get_list_info(userdesc, perms, mlist)[0]
- return (details, options)
- except:
- if correct: mlist.Unlock()
- return 0
+ mlist = MailList.MailList(vhost + VHOST_SEP + listname, lock=0)
+ if correct:
+ return list_call_locked(check_options_runner, userdesc, perms, mlist, True, listname, True)
+ else:
+ return check_options_runner(userdesc, perms, mlist, listname, False)
#-------------------------------------------------------------------------------
# super-admin procedures
#
def get_all_lists(userdesc, perms, vhost):
+ """ Get all the list for the given vhost
+ """
prefix = vhost.lower()+VHOST_SEP
names = Utils.list_names()
names.sort()
return result
def create_list(userdesc, perms, vhost, listname, desc, advertise, modlevel, inslevel, owners, members):
- if perms != 'admin':
- return 0
- name = vhost.lower()+VHOST_SEP+listname.lower();
+ """ Create a new list.
+ @root
+ """
+ name = vhost.lower() + VHOST_SEP + listname.lower();
if Utils.list_exists(name):
return 0
mlist.header_filter_rules = []
mlist.header_filter_rules.append(('X-Spam-Flag: Unsure, tests=bogofilter', mm_cfg.HOLD, False))
mlist.header_filter_rules.append(('X-Spam-Flag: Yes, tests=bogofilter', mm_cfg.HOLD, False))
-
mlist.Save()
-
mlist.Unlock()
if ON_CREATE_CMD != '':
try: os.system(ON_CREATE_CMD + ' ' + name)
except: pass
- check_options(userdesc, perms, vhost, listname.lower(), True)
- mass_subscribe(userdesc, perms, vhost, listname.lower(), members)
+ check_options(userdesc, perms, mlist, True)
+ mass_subscribe(userdesc, perms, mlist, members)
# avoid the "-1 mail to moderate" bug
mlist = MailList.MailList(name)
mlist._UpdateRecords()
mlist.Save()
- mlist.Unlock()
- except:
- try:
- mlist.Unlock()
- except:
- pass
- return 0
- return 1
-def delete_list(userdesc, perms, vhost, listname, del_archives=0):
- lname = vhost+VHOST_SEP+listname.lower()
- try:
- mlist = MailList.MailList(lname, lock=0)
- except:
- return 0
- try:
- if not is_admin_on(userdesc, perms, mlist):
- return 0
- # remove the list
- REMOVABLES = [ os.path.join('lists', lname), ]
- # remove stalled locks
- for filename in os.listdir(mm_cfg.LOCK_DIR):
- fn_lname = filename.split('.')[0]
- if fn_lname == lname:
- REMOVABLES.append(os.path.join(mm_cfg.LOCK_DIR, filename))
- # remove archives ?
- if del_archives:
- REMOVABLES.extend([
- os.path.join('archives', 'private', lname),
- os.path.join('archives', 'private', lname+'.mbox'),
- os.path.join('archives', 'public', lname),
- os.path.join('archives', 'public', lname+'.mbox')
- ])
- map(lambda dir: remove_it(lname, os.path.join(mm_cfg.VAR_PREFIX, dir)), REMOVABLES)
return 1
- except:
- return 0
+ finally:
+ mlist.Unlock()
+ return 0
+
+def delete_list(userdesc, perms, mlist, del_archives=0):
+ """ Delete the list.
+ @mlist
+ @admin
+ """
+ lname = mlist.internal_name()
+ # remove the list
+ REMOVABLES = [ os.path.join('lists', lname), ]
+ # remove stalled locks
+ for filename in os.listdir(mm_cfg.LOCK_DIR):
+ fn_lname = filename.split('.')[0]
+ if fn_lname == lname:
+ REMOVABLES.append(os.path.join(mm_cfg.LOCK_DIR, filename))
+ # remove archives ?
+ if del_archives:
+ REMOVABLES.extend([
+ os.path.join('archives', 'private', lname),
+ os.path.join('archives', 'private', lname+'.mbox'),
+ os.path.join('archives', 'public', lname),
+ os.path.join('archives', 'public', lname+'.mbox')
+ ])
+ map(lambda dir: remove_it(lname, os.path.join(mm_cfg.VAR_PREFIX, dir)), REMOVABLES)
+ return 1
def kill(userdesc, perms, vhost, alias, del_from_promo):
+ """ Remove a user from all the lists.
+ """
exclude = []
if not del_from_promo:
- exclude.append(PLATAL_DOMAIN+VHOST_SEP+'promo'+alias[-4:])
+ exclude.append(PLATAL_DOMAIN + VHOST_SEP + 'promo' + alias[-4:])
for list in Utils.list_names():
- if list in exclude: continue
+ if list in exclude:
+ continue
try:
mlist = MailList.MailList(list, lock=0)
except:
#-------------------------------------------------------------------------------
# server
#
-server = FastXMLRPCServer(("localhost", 4949), BasicAuthXMLRPCRequestHandler)
+server = FastXMLRPCServer((SRV_HOST, SRV_PORT), BasicAuthXMLRPCRequestHandler)
# index.php
server.register_function(get_lists)
XDB::execute('DELETE FROM search_name');
$res = XDB::iterRow('SELECT auth_user_md5.user_id, nom, prenom, nom_usage, profile_nick
FROM auth_user_md5
- LEFT JOIN auth_user_quick USING(user_id)');
+ LEFT JOIN auth_user_quick USING(user_id)');
$i = 0;
$muls = array(1, 1, 1, 0.2);
$pub = array(true, true, true, false);
--- /dev/null
+/platalglobals.php
+++ /dev/null
-<?php
-/*
- * Copyright (C) 2003-2004 Polytechnique.org
- * http://opensource.polytechnique.org/
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
- */
-
-
-class CoreLogger
-{
- /** user id */
- public $uid;
- /** id of the session */
- private $session;
- /** list of available actions */
- private $actions;
-
- public $ip;
- public $host;
- public $proxy_ip;
- public $proxy_host;
-
- /** The constructor, creates a new entry in the sessions table
- *
- * @param $uid the id of the logged user
- * @param $suid the id of the administrator who has just su'd to the user
- * @return VOID
- */
- public function __construct($uid, $suid = 0)
- {
- // write the session entry
- $this->uid = $uid;
- $this->session = $this->writeSession($uid, $suid);
-
- // retrieve available actions
- $res = XDB::iterRow("SELECT id, text FROM logger.actions");
-
- while (list($action_id, $action_text) = $res->next()) {
- $this->actions[$action_text] = $action_id;
- }
- }
-
- /** Creates a new session entry in database and return its ID.
- *
- * @param $uid the id of the logged user
- * @param $suid the id of the administrator who has just su'd to the user
- * @return session the session id
- */
- private function writeSession($uid, $suid = 0)
- {
- $ip = $_SERVER['REMOTE_ADDR'];
- $host = strtolower(gethostbyaddr($_SERVER['REMOTE_ADDR']));
- $browser = (isset($_SERVER['HTTP_USER_AGENT']) ? $_SERVER['HTTP_USER_AGENT'] : '');
-
- @list($forward_ip,) = explode(',', $_SERVER['HTTP_X_FORWARDED_FOR']);
- $forward_host = $forward_ip;
- if ($forward_host) {
- $forward_host = strtolower(gethostbyaddr($forward_host));
- }
- $proxy = '';
- if ($forward_ip || @$_SERVER['HTTP_VIA']) {
- $proxy = 'proxy';
- }
-
- XDB::execute("INSERT INTO logger.sessions
- SET uid={?}, host={?}, ip={?}, forward_ip={?}, forward_host={?}, browser={?}, suid={?}, flags={?}",
- $uid, $host, ip_to_uint($ip), ip_to_uint($forward_ip), $forward_host, $browser, $suid, $proxy);
- if ($forward_ip) {
- $this->proxy_ip = $ip;
- $this->proxy_host = $host;
- $this->ip = $forward_ip;
- $this->host = $forward_host;
- } else {
- $this->ip = $ip;
- $this->host = $host;
- }
-
- return XDB::insertId();
- }
-
-
- /** Logs an action and its related data.
- *
- * @param $action le type d'action
- * @param $data les données (id de liste, etc.)
- * @return VOID
- */
- public function log($action, $data = null)
- {
- if (isset($this->actions[$action])) {
- XDB::execute("INSERT INTO logger.events
- SET session={?}, action={?}, data={?}",
- $this->session, $this->actions[$action], $data);
- } else {
- trigger_error("CoreLogger: unknown action, $action", E_USER_WARNING);
- }
- }
-}
-
-// vim:set et sw=4 sts=4 sws=4 foldmethod=marker enc=utf-8:
-?>
+++ /dev/null
-<?php
-/***************************************************************************
- * Copyright (C) 2003-2008 Polytechnique.org *
- * http://opensource.polytechnique.org/ *
- * *
- * This program is free software; you can redistribute it and/or modify *
- * it under the terms of the GNU General Public License as published by *
- * the Free Software Foundation; either version 2 of the License, or *
- * (at your option) any later version. *
- * *
- * This program is distributed in the hope that it will be useful, *
- * but WITHOUT ANY WARRANTY; without even the implied warranty of *
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
- * GNU General Public License for more details. *
- * *
- * You should have received a copy of the GNU General Public License *
- * along with this program; if not, write to the Free Software *
- * Foundation, Inc., *
- * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA *
- ***************************************************************************/
-
-define('CSV_INSERT', 'insert'); // INSERT IGNORE
-define('CSV_REPLACE', 'replace'); // REPLACE
-define('CSV_UPDATE', 'update'); // INSERT and UPDATE on error
-define('CSV_UPDATEONLY', 'updateonly'); // UPDATE
-
-class CSVImporter
-{
- private $table;
- private $key;
- private $do_sql;
-
- private $index;
- private $data = array();
-
- private $user_functions = array();
- private $field_desc = array();
- private $field_value = array();
-
- public function __construct($table, $key = 'id', $do_sql = true)
- {
- $this->table = $table;
- $this->key = explode(',', $key);
- $this->do_sql = $do_sql;
- }
-
- private function processLine(array $array)
- {
- if (is_null($this->index)) {
- $this->index = array_map('strtolower', $array);
- return true;
- }
-
- if (count($array) != count($this->index)) {
- return false;
- }
- $assoc = array();
- $i = 0;
- foreach ($this->index as $key) {
- $assoc[$key] = $array[$i];
- $i++;
- }
- $this->data[] = $assoc;
- return true;
- }
-
- private function getValue($line, $key, $action)
- {
- if (@array_key_exists($action, $line)) {
- $value = $line[$action];
- } elseif (is_callable($action, false)) {
- $value = call_user_func($action, $line, $key);
- } else {
- $value = $action;
- }
- if (is_null($value) || $value == 'NULL') {
- $value = 'NULL';
- }
- return $value;
- }
-
- private function makeAssoc($line, $relation)
- {
- $ops = array();
- foreach ($relation as $key=>$ref) {
- $ops[$key] = $this->getValue($line, $key, $ref);
- }
- return $ops;
- }
-
- private function makeRequestArgs($line, $relation)
- {
- $ops = array();
- foreach ($relation as $key=>$ref) {
- $value = $this->getValue($line, $key, $ref);
- if (!is_null($value) && $value != 'NULL') {
- $value = "'" . addslashes($value) . "'";
- }
- $ops[$key] = "$key = $value";
- }
- return $ops;
- }
-
- private function makeRelation()
- {
- $relation = array();
- foreach ($this->index as $title) {
- $relation[$title] = $title;
- }
- return $relation;
- }
-
- private function execute($query)
- {
- if (!$this->do_sql) {
- echo "$query;\n";
- return false;
- }
- return XDB::execute($query);
- }
-
- private function getFieldList()
- {
- $res = XDB::query("SHOW COLUMNS FROM {$this->table}");
- if ($res->numRows()) {
- return $res->fetchColumn();
- }
- return null;
- }
-
- public function setCSV($csv, $index = null, $separator = ';')
- {
- require_once dirname(__FILE__) . '/varstream.php';
- VarStream::init();
- global $csv_source;
- $this->index = null;
-
- $csv_source = $csv;
- $res = fopen('var://csv_source', 'r');
-
- while (!feof($res)) {
- $this->processLine(fgetcsv($res, 0, $separator));
- }
- }
-
- public function run($action = CSV_UPDATE, $insert_relation = null, $update_relation = null)
- {
- if (is_null($insert_relation)) {
- $insert_relation = $this->makeRelation();
- }
- if (is_null($update_relation)) {
- $update_relation = $insert_relation;
- }
- foreach ($this->data as $line) {
- $set = join(', ', $this->makeRequestArgs($line, $insert_relation));
- switch ($action) {
- case CSV_INSERT:
- $this->execute("INSERT IGNORE INTO {$this->table} SET $set");
- break;
- case CSV_REPLACE:
- $this->execute("REPLACE INTO {$this->table} SET $set");
- break;
- case CSV_UPDATE: case CSV_UPDATEONLY:
- if ($action == CSV_UPDATEONLY || !$this->execute("INSERT INTO {$this->table} SET $set")) {
- $ops = $this->makeRequestArgs($line, $update_relation);
- $set = join(', ', $ops);
- $where = array();
- foreach ($this->key as $key) {
- $where[] = $ops[$key];
- }
- $where = join(' AND ', $where);
- $this->execute("UPDATE {$this->table} SET $set WHERE $where");
- }
- break;
- }
- }
- }
-
- static public function dynamicCond($line, $key)
- {
- static $fields, $conds, $values, $thens, $elses;
-
- if (!isset($fields)) {
- $fields = $_SESSION['csv_cond_field'];
- $conds = $_SESSION['csv_cond'];
- $values = $_SESSION['csv_cond_value'];
- $thens = $_SESSION['csv_cond_then'];
- $elses = $_SESSION['csv_cond_else'];
- }
- $field = $line[$fields[$key]];
- $cond = $conds[$key];
- $value = $values[$key];
- if (is_numeric($field) && is_numeric($value)) {
- $field = floatval($field);
- $value = floatval($value);
- }
- switch ($cond) {
- case 'defined': $ok = (!empty($field)); break;
- case 'equals': $ok = ($field == $value); break;
- case 'contains': $ok = (strpos($field, $value) !== false); break;
- case 'contained': $ok = (strpos($value, $field) !== false); break;
- case 'greater': $ok = ($field > $value); break;
- case 'greater_or_equal': $ok ($field >= $value); break;
- case 'lower': $ok = ($field < $value); break;
- case 'lower_or_equal': $ok = ($field <= $value); break;
- default: $ok = false;
- }
- if ($ok) {
- return $thens[$key];
- } else {
- return $elses[$key];
- }
- }
-
- public function registerFunction($name, $desc, $callback)
- {
- if (is_callable($callback, false, $ref)) {
- $this->user_functions['func_' . $name] = array('desc' => $desc, 'callback' => $callback);
- return true;
- }
- return false;
- }
-
- public function describe($name, $desc)
- {
- $this->field_desc[$name] = $desc;
- }
-
- public function forceValue($name, $value)
- {
- $this->field_value[$name] = $value;
- }
-
- private function cleanSession($fields)
- {
- foreach ($fields as $field) {
- unset($_SESSION[$field]);
- }
- }
-
- /** Handle insertion form
- * @param $page PlatalPage to process
- * @param $url URI of the page
- * @param $field Editable fields
- */
- public function apply(&$page, $url, $fields = null)
- {
- $sesfields = array('csv_value', 'csv_user_value', 'csv_cond_field',
- 'csv_update', 'csv_action', 'csv_cond_field',
- 'csv_cond', 'csv_cond_value', 'csv_cond_then',
- 'csv_cond_else', 'csv', 'csv_separator', 'csv_url');
- if ($url != @$_SESSION['csv_url']) {
- $this->cleanSession($sesfields);
- $_SESSION['csv_url'] = $url;
- }
-
- if (is_null($fields) || empty($fields)) {
- $fields = $this->getFieldList();
- }
- if (is_null($fields)) {
- return false;
- }
- foreach ($this->field_value as $key=>$value) {
- $search = array_search($key, $fields);
- unset($fields[$search]);
- }
-
- $current = Env::v('csv_page');
- if (empty($current)) {
- $current = 'source';
- }
- $next = Env::v('csv_next_page');
- if (empty($next)) {
- $next = $current;
- }
- $csv = @$_SESSION['csv'];
- if ($current == 'source' && Env::has('csv_valid')) {
- $csv = Env::v('csv_source');
- $_SESSION['csv'] = $csv;
- $next = 'values';
- }
- if ($csv) {
- if (Env::has('csv_separator')) {
- $sep = Env::v('csv_separator');
- if (empty($sep)) {
- $sep = ';';
- }
- $_SESSION['csv_separator'] = $sep;
- }
- $this->setCSV($csv, null, $_SESSION['csv_separator']);
- }
- if ($current == 'values' && Env::has('csv_valid')) {
- $next = 'valid';
- }
- if (empty($csv)) {
- $next = 'source';
- }
- if (Env::has('csv_action')) {
- $_SESSION['csv_action'] = Env::v('csv_action');
- }
- if ($next == 'valid') {
- if ($current != 'valid') {
- $cpyfields = array('csv_value', 'csv_user_value', 'csv_cond_field',
- 'csv_update', 'csv_action', 'csv_cond_field',
- 'csv_cond', 'csv_cond_value', 'csv_cond_then',
- 'csv_cond_else');
- foreach ($cpyfields as $field) {
- $_SESSION[$field] = Env::v($field);
- }
- }
- $insert = $_SESSION['csv_value'];
- $values = $_SESSION['csv_user_value'];
- $update = $_SESSION['csv_update'];
- foreach ($insert as $key=>$value) {
- if (empty($value)) {
- $insert[$key] = null;
- } elseif ($value == 'user_value') {
- $insert[$key] = $values[$key];
- } elseif ($value == 'cond_value') {
- $insert[$key] = array($this, 'dynamicCond');
- } elseif (array_key_exists($value, $this->user_functions)) {
- $insert[$key] = $this->user_functions[$value]['callback'];
- }
- if (isset($update[$key])) {
- $update[$key] = $insert[$key];
- }
- }
- foreach ($this->field_value as $key=>$value) {
- $insert[$key] = $value;
- $fields[] = $key;
- }
- if ($current == 'valid' && Env::has('csv_valid')) {
- S::assert_xsrf_token();
- $this->run($_SESSION['csv_action'], $insert, $update);
- $page->assign('csv_done', true);
- $this->cleanSession($sesfields);
- } else {
- $preview = array();
- foreach ($this->data as $line) {
- $preview[] = $this->makeAssoc($line, $insert);
- }
- $page->assign('csv_preview', $preview);
- }
- }
- $page->assign('csv_index', $this->index);
- $page->assign('csv_functions', $this->user_functions);
- $page->assign('csv_field_desc', $this->field_desc);
- $page->assign('csv_page', $next);
- $page->assign('csv_path', $url);
- $page->assign('csv_fields', $fields);
- }
-}
-
-// vim:set et sw=4 sts=4 sws=4 foldmethod=marker enc=utf-8:
-?>
+++ /dev/null
-<?php
-/***************************************************************************
- * Copyright (C) 2003-2008 Polytechnique.org *
- * http://opensource.polytechnique.org/ *
- * *
- * This program is free software; you can redistribute it and/or modify *
- * it under the terms of the GNU General Public License as published by *
- * the Free Software Foundation; either version 2 of the License, or *
- * (at your option) any later version. *
- * *
- * This program is distributed in the hope that it will be useful, *
- * but WITHOUT ANY WARRANTY; without even the implied warranty of *
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
- * GNU General Public License for more details. *
- * *
- * You should have received a copy of the GNU General Public License *
- * along with this program; if not, write to the Free Software *
- * Foundation, Inc., *
- * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA *
- ***************************************************************************/
-
-class Env
-{
- public static function _get($key, $default)
- {
- return isset($_REQUEST[$key]) ? $_REQUEST[$key] : $default;
- }
-
- public static function has($key)
- {
- return isset($_REQUEST[$key]);
- }
-
- public static function kill($key)
- {
- unset($_REQUEST[$key]);
- }
-
- public static function v($key, $default = null)
- {
- return Env::_get($key, $default);
- }
-
- public static function s($key, $default = '')
- {
- return (string)Env::_get($key, $default);
- }
-
- public static function b($key, $default = false)
- {
- return (bool)Env::_get($key, $default);
- }
-
- public static function i($key, $default = 0)
- {
- $i = Env::_get($key, $default);
- return is_numeric($i) ? intval($i) : $default;
- }
-
- public static function l(array $keys)
- {
- return array_map(array('Env', 'v'), $keys);
- }
-}
-
-class Post
-{
- public static function _get($key, $default)
- {
- return isset($_POST[$key]) ? $_POST[$key] : $default;
- }
-
- public static function has($key)
- {
- return isset($_POST[$key]);
- }
-
- public static function kill($key)
- {
- unset($_POST[$key]);
- }
-
- public static function v($key, $default = null)
- {
- return Post::_get($key, $default);
- }
-
- public static function b($key, $default = false)
- {
- return (bool)Post::_get($key, $default);
- }
-
- public static function s($key, $default = '')
- {
- return (string)Post::_get($key, $default);
- }
-
- public static function i($key, $default = 0)
- {
- $i = Post::_get($key, $default);
- return is_numeric($i) ? intval($i) : $default;
- }
-
- public static function l(array $keys)
- {
- return array_map(array('Post', 'v'), $keys);
- }
-}
-
-class Get
-{
- public static function _get($key, $default)
- {
- return isset($_GET[$key]) ? $_GET[$key] : $default;
- }
-
- public static function has($key)
- {
- return isset($_GET[$key]);
- }
-
- public static function kill($key)
- {
- unset($_GET[$key]);
- }
-
- public static function v($key, $default = null)
- {
- return Get::_get($key, $default);
- }
-
- public static function b($key, $default = false)
- {
- return (bool)Get::_get($key, $default);
- }
-
- public static function s($key, $default = '')
- {
- return (string)Get::_get($key, $default);
- }
-
- public static function i($key, $default = 0)
- {
- $i = Get::_get($key, $default);
- return is_numeric($i) ? intval($i) : $default;
- }
-
- public static function l(array $keys)
- {
- return array_map(array('Get', 'v'), $keys);
- }
-}
-
-class Cookie
-{
- public static function _get($key, $default)
- {
- return isset($_COOKIE[$key]) ? $_COOKIE[$key] : $default;
- }
-
- public static function has($key)
- {
- return isset($_COOKIE[$key]);
- }
-
- public static function kill($key)
- {
- unset($_COOKIE[$key]);
- }
-
- public static function v($key, $default = null)
- {
- return Cookie::_get($key, $default);
- }
-
- public static function s($key, $default = '')
- {
- return (string)Cookie::_get($key, $default);
- }
-
- public static function b($key, $default = false)
- {
- return (bool)Cookie::_get($key, $default);
- }
-
- public static function i($key, $default = 0)
- {
- $i = Cookie::_get($key, $default);
- return is_numeric($i) ? intval($i) : $default;
- }
-
- public static function l(array $keys)
- {
- return array_map(array('Cookie', 'v'), $keys);
- }
-}
-
-function fix_gpc_magic(&$item, $key) {
- if (is_array($item)) {
- array_walk($item, 'fix_gpc_magic');
- } else {
- $item = stripslashes($item);
- }
-}
-
-if (ini_get('magic_quotes_gpc') && empty($DONT_FIX_GPC)) {
- array_walk($_GET, 'fix_gpc_magic');
- array_walk($_POST, 'fix_gpc_magic');
- array_walk($_COOKIE, 'fix_gpc_magic');
- array_walk($_REQUEST, 'fix_gpc_magic');
-}
-
-// vim:set et sw=4 sts=4 sws=4 foldmethod=marker enc=utf-8:
-?>
+++ /dev/null
-<?php
-/*
- * Copyright (C) 2003-2004 Polytechnique.org
- * http://opensource.polytechnique.org/
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
- */
-
-
-/** class for describing flags
- */
-class Flagset
-{
- /** string that holds the flagset */
- private $value;
-
- /** the boundary between flags */
- private $sep = ",";
-
-
- /** set flag
- * @param $flags services FROM coupures
- * @return VOID
- */
- public function __construct($flags = "")
- {
- $this->value = $flags;
- }
-
-
- /** add flag
- * @param $flag XXX
- * @return VOID
- */
- public function addFlag($flag)
- {
- if (!$flag) return;
- if (!$this->hasflag($flag)) {
- if ($this->value)
- $this->value .= $this->sep;
- $this->value .= $flag;
- }
- }
-
-
- /** test si flag ou pas
- * @param $flag XXX
- * @return 1 || 0
- */
- public function hasFlag($flag)
- {
- $tok = strtok($this->value,$this->sep);
- while ($tok) {
- if ($tok==$flag) return 1;
- $tok = strtok($this->sep);
- }
- return 0;
- }
-
- /** test flag combination
- */
- public function hasFlagCombination($flag)
- {
- $perms = explode(',', $flag);
- foreach ($perms as $perm)
- {
- $ok = true;
- $rights = explode(':', $perm);
- foreach ($rights as $right) {
- if (($right{0} == '!' && $this->hasFlag(substr($right, 1))) || !$this->hasFlag($right)) {
- $ok = false;
- }
- }
- if ($ok) {
- return true;
- }
- }
- return false;
- }
-
- /** remove flag
- * @param $flag XXX
- * @return VOID
- */
- public function rmFlag($flag)
- {
- if (!$flag) return;
- $newvalue = "";
- $tok = strtok($this->value,$this->sep);
- while ($tok) {
- if ($tok!=$flag) {
- if ($newvalue)
- $newvalue .= $this->sep;
- $newvalue .= $tok;
- }
- $tok = strtok($this->sep);
- }
- $this->value=$newvalue;
- }
-
- /** return the flagset
- */
- public function flags()
- {
- return $this->value;
- }
-}
-
-// vim:set et sw=4 sts=4 sws=4 foldmethod=marker enc=utf-8:
-?>
+++ /dev/null
-<?php
-
-class MiniWiki
-{
-
- private static $patternsWiki = array();
- private static $replacementHTML = array();
- private static $replacementText = array();
-
- private static $title_index = -1;
- private static $info = array();
-
- public static function Markup($pattern, $replacement, $replacementTxt, $info = null)
- {
- $id = count(MiniWiki::$patternsWiki);
- MiniWiki::$patternsWiki[$id] = $pattern;
- MiniWiki::$replacementHTML[$id] = $replacement;
- MiniWiki::$replacementText[$id] = $replacementTxt;
- if ($info) {
- MiniWiki::$info[$id] = $info;
- }
- return $id;
- }
-
- public static function init()
- {
- if (isset(MiniWiki::$patternsWiki[0])) {
- return;
- }
- MiniWiki::Markup("/(\r\n|\r([^\n]))/", "\n$2", "\n$2");
-
- // retours à la ligne avec \\
- MiniWiki::Markup("/\\\\(?".">(\\\\*))\n/e", "str_repeat('<br />\n',mb_strlen('$1'))", "str_repeat('\n',mb_strlen('$1'))", "ligne1\\\\\nligne2");
-
- // * unordered list
- MiniWiki::Markup("/(^|\n)\*(([^\n]*(\n|$))(\*[^\n]*(\n|$))*)/se",
- "'</p><ul><li>'.str_replace(\"\\n*\",'</li><li>','$2').'</li></ul><p>'",
- "'$1 -' . str_replace(\"\\n*\", \"\\n -\", '$2')",
- "* element1\n* element2\n* element3");
- // # unordered list
- MiniWiki::Markup("/(^|\n)#(([^\n]*(\n|$))(#[^\n]*(\n|$))*)/se", "'<ol><li>'.str_replace(\"\\n#\",'</li><li>','$2').'</li></ol>'", "'$0'", "# element1\n# element2\n# element3");
-
- // bold, italic and others
- // ''' bold '''
- MiniWiki::Markup("/'''(.*?)'''/",'<strong>$1</strong>','*$1*', "'''gras'''");
- // '' italic ''
- MiniWiki::Markup("/''(.*?)''/",'<em>$1</em>','/$1/', "''italique''");
- // '+ big +'
- MiniWiki::Markup("/'\\+(.*?)\\+'/",'<big>$1</big>','*$1*', "'+grand+'");
- // '- small -'
- MiniWiki::Markup("/'\\-(.*?)\\-'/",'<small>$1</small>','$1', "'-petit-'");
- // '^superscript^'
- MiniWiki::Markup("/'\\^(.*?)\\^'/",'<sup>$1</sup>','$1', "'^exposant^'");
- // '_subscript_'
- MiniWiki::Markup("/'_(.*?)_'/",'<sub>$1</sub>','$1', "'_indice_'");
- // {+ underline +}
- MiniWiki::Markup("/\\{\\+(.*?)\\+\\}/",'<ins>$1</ins>','_$1_', "{+insertion+}");
- // {- strikeout -}
- MiniWiki::Markup("/\\{-(.*?)-\\}/",'<del>$1</del>','-$1-', "{-suppression-}");
- // {color| colored text |}
- MiniWiki::Markup("/%([a-z]+|\#[0-9a-f]{3,6})%(.*?)%%/i", "<span style='color: $1;'>$2</span>", "$2",
- "%red% texte en rouge %%\\\\\n%#ff0% texte en jaune %%\\\\\n%#0000ff% texte en bleu %%");
- // [+ big +] [++ bigger ++] [+++ even bigger +++] ...
- MiniWiki::Markup("/\\[(([-+])+)(.*?)\\1\\]/e","'<span style=\'font-size:'.(round(pow(6/5,$2mb_strlen('$1'))*100,0)).'%\'>$3</span>'", "'$3'", "[+ grand +]\n\n[++ plus grand ++]\n\n[+++ encore plus grand +++]");
-
- // ----- <hr/>
- MiniWiki::Markup("/(\n|^)--(--+| \n)/s", '$1<hr/>', '$1-- '."\n", "----\n");
- // titles
- MiniWiki::$title_index = MiniWiki::Markup('/(\n|^)(!+)([^\n]*)/se',
- "'$1<h'.mb_strlen('$2').'>$3</h'.mb_strlen('$2').'>'",
- "'$1$3'", "!titre1\n\n!!titre2\n\n!!!titre3");
-
- // links
- MiniWiki::Markup('/((?:https?|ftp):\/\/(?:[\.\,\;\!\:]*[\w@~%$£µ&i#\-+=_\/\?])*)/ui',
- '<a href="\\0">\\0</a>', '<\\0>');
- MiniWiki::Markup('/(\s|^|\[\[)www\.((?:[\.\,\;\!\:]*[\w@~%$£µ&i#\-+=_\/\?])*)/iu',
- '\\1<a href="http://www.\\2">www.\\2</a>', '\\1<http://www.\\2>');
- MiniWiki::Markup('/(?:mailto:)?([a-z0-9.\-+_]+@([\-.+_]?[a-z0-9])+)/i', '<a href="mailto:\\0">\\0</a>', '<\\0>');
- MiniWiki::Markup('/\[\[\s*<(?:a href=")?([^">]*?)(?:">.*?<\/a)?>\s*\|([^\]]+)\]\]/i',
- '<a href="\\1">\\2</a>', '\\2 <\\1>',
- "[[http://www.example.com|Mon site web]]\n\nhttp://www.example.com\n\ntest@example.com");
-
- // paragraphs and empty lines
- MiniWiki::Markup("/\n\n/", '</p><p>', "\n\n", "paragraphe1\n\nparagraphe2");
- MiniWiki::Markup("/\n/", ' ', "\n");
- MiniWiki::Markup("/^.*<\/p>.*<p>.*$/s", "<p>$0</p>", "$0");
-
- // french typo rules, unbreakable spaces
- MiniWiki::Markup("/ +([!?:;])/", " $1", "$0");
- }
-
- public static function WikiToHTML($wiki, $title = false)
- {
- if (!$title) {
- $oldrule12 = MiniWiki::$replacementHTML[MiniWiki::$title_index];
- MiniWiki::$replacementHTML[MiniWiki::$title_index] = "'$0'";
- }
- $html = preg_replace(MiniWiki::$patternsWiki,
- MiniWiki::$replacementHTML,
- htmlentities(trim($wiki), ENT_COMPAT, 'UTF-8'));
- if (!$title) {
- MiniWiki::$replacementHTML[MiniWiki::$title_index] = $oldrule12;
- }
- return $html;
- }
-
- private static function justify($text, $n)
- {
- $arr = explode("\n", wordwrap($text, $n));
- $arr = array_map('trim', $arr);
- $res = '';
- foreach ($arr as $key => $line) {
- $nxl = isset($arr[$key+1]) ? trim($arr[$key+1]) : '';
- $nxl_split = preg_split('! +!u', $nxl);
- $nxw_len = count($nxl_split) ? mb_strlen($nxl_split[0]) : 0;
- $line = trim($line);
-
- if (mb_strlen($line)+1+$nxw_len < $n) {
- $res .= "$line\n";
- continue;
- }
-
- if (preg_match('![.:;]$!u',$line)) {
- $res .= "$line\n";
- continue;
- }
-
- $tmp = preg_split('! +!u', trim($line));
- $words = count($tmp);
- if ($words <= 1) {
- $res .= "$line\n";
- continue;
- }
-
- $len = array_sum(array_map('mb_strlen', $tmp));
- $empty = $n - $len;
- $sw = floatval($empty) / floatval($words-1);
-
- $cur = 0;
- $l = '';
- foreach ($tmp as $word) {
- $l .= $word;
- $cur += $sw + strlen($word); // Use strlen here instead of mb_strlen because it is used by str_pad
- // which is not multibyte compatible
- $l = str_pad($l, intval($cur + 0.5));
- }
- $res .= trim($l)."\n";
- }
- return trim($res);
- }
-
-
- public static function WikiToText($wiki, $just=false, $indent=0, $width=68, $title=false)
- {
- if (!$title) {
- $oldrule12 = MiniWiki::$replacementHTML[MiniWiki::$title_index];
- MiniWiki::$replacementHTML[MiniWiki::$title_index] = "'$0'";
- }
- //$text = trim($wiki);
- //foreach (MiniWiki::$patternsWiki as $key=>$pattern) {
- // echo $key . " - " . $pattern . "\n";
- // $text = preg_replace($pattern, MiniWiki::$replacementText[$key], $text);
- //}
- $text = preg_replace(MiniWiki::$patternsWiki, MiniWiki::$replacementText, trim($wiki));
- if (!$title) {
- MiniWiki::$replacementHTML[MiniWiki::$title_index] = $oldrule12;
- }
- $text = $just ? MiniWiki::justify($text, $width - $indent) : wordwrap($text, $width - $indent);
- if($indent) {
- $ind = str_pad('',$indent);
- $text = $ind.str_replace("\n","\n$ind",$text);
- }
- return $text;
- }
-
- static public function help($with_title = false)
- {
- if (!$with_title) {
- $info12 = MiniWiki::$info[MiniWiki::$title_index];
- unset(MiniWiki::$info[MiniWiki::$title_index]);
- }
-
- $res = array();
- foreach (MiniWiki::$info as $value) {
- $res[$value] = MiniWiki::wikiToHtml($value, true);
- }
-
- if (!$with_title) {
- MiniWiki::$info[MiniWiki::$title_index] = $info12;
- }
- return $res;
- }
-}
-
-MiniWiki::init();
-
-// vim:set et sw=4 sts=4 sws=4 foldmethod=marker enc=utf-8:
-?>
+++ /dev/null
-<?php
-/***************************************************************************
- * Copyright (C) 2003-2008 Polytechnique.org *
- * http://opensource.polytechnique.org/ *
- * *
- * This program is free software; you can redistribute it and/or modify *
- * it under the terms of the GNU General Public License as published by *
- * the Free Software Foundation; either version 2 of the License, or *
- * (at your option) any later version. *
- * *
- * This program is distributed in the hope that it will be useful, *
- * but WITHOUT ANY WARRANTY; without even the implied warranty of *
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
- * GNU General Public License for more details. *
- * *
- * You should have received a copy of the GNU General Public License *
- * along with this program; if not, write to the Free Software *
- * Foundation, Inc., *
- * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA *
- ***************************************************************************/
-
-define('PL_DO_AUTH', 300);
-define('PL_FORBIDDEN', 403);
-define('PL_NOT_FOUND', 404);
-
-class Platal
-{
- private $__mods;
- private $__hooks;
-
- protected $https;
-
- public $ns;
- public $path;
- public $argv;
-
- public function __construct()
- {
- $modules = func_get_args();
- if (is_array($modules[0])) {
- $modules = $modules[0];
- }
- $this->path = trim(Get::_get('n', null), '/');
-
- $this->__mods = array();
- $this->__hooks = array();
-
- array_unshift($modules, 'core');
- foreach ($modules as $module) {
- $module = strtolower($module);
- $this->__mods[$module] = $m = PLModule::factory($module);
- $this->__hooks += $m->handlers();
- }
-
- global $globals;
- if ($globals->mode == '') {
- pl_redirect('index.html');
- }
- }
-
- public function pl_self($n = null)
- {
- if (is_null($n))
- return $this->path;
-
- if ($n >= 0)
- return join('/', array_slice($this->argv, 0, $n + 1));
-
- if ($n <= -count($this->argv))
- return $this->argv[0];
-
- return join('/', array_slice($this->argv, 0, $n));
- }
-
- protected function find_hook()
- {
- $p = $this->path;
-
- while ($p) {
- if (array_key_exists($p, $this->__hooks))
- break;
-
- $p = substr($p, 0, strrpos($p, '/'));
- }
-
- if (empty($this->__hooks[$p])) {
- return null;
- }
-
- $hook = $this->__hooks[$p];
-
- if (!is_callable($hook['hook'])) {
- return null;
- }
-
- $this->https = ($hook['type'] & NO_HTTPS) ? false : true;
- $this->argv = explode('/', substr($this->path, strlen($p)));
- $this->argv[0] = $p;
-
- return $hook;
- }
-
- protected function find_nearest_key($key, array &$array)
- {
- $keys = array_keys($array);
- if (in_array($key, $keys)) {
- return $key;
- }
-
- if (($pos = strpos($key, '.php')) !== false) {
- $key = substr($key, 0, $pos);
- }
-
- $has_end = in_array("#final#", $keys);
- if (strlen($key) > 24 && $has_end) {
- return "#final#";
- }
-
- foreach ($keys as $k) {
- if ($k == "#final#") {
- continue;
- }
- $lev = levenshtein($key, $k);
-
- if ((!isset($val) || $lev < $val)
- && ($lev <= strlen($k)/2 || strpos($k, $key) !== false || strpos($key, $k) !== false)) {
- $val = $lev;
- $best = $k;
- }
- }
- if (!isset($best) && $has_end) {
- return "#final#";
- } else if (isset($best)) {
- return $best;
- }
- return null;
- }
-
- public function near_hook()
- {
- $hooks = array();
- $leafs = array();
- foreach ($this->__hooks as $hook=>$handler) {
- if (!$this->check_perms($handler['perms'])) {
- continue;
- }
- $parts = split('/', $hook);
- $place =& $hooks;
- foreach ($parts as $part) {
- if (!isset($place[$part])) {
- $place[$part] = array();
- }
- $place =& $place[$part];
- }
- $leaf = $parts[count($parts)-1];
- if (!isset($leafs[$leaf])) {
- $leafs[$leaf] = $hook;
- } else if (is_array($leafs[$leaf])) {
- $leafs[$leaf][] = $hook;
- } else {
- $leafs[$leaf] = array($hook, $leafs[$leaf]);
- }
- $place["#final#"] = array();
- }
-
- // search for the nearest full path
- $p = split('/', $this->path);
- $place =& $hooks;
- $link = '';
- foreach ($p as $k) {
- if (!isset($ended)) {
- $key = $this->find_nearest_key($k, $place);
- } else {
- $key = $k;
- }
- if ($key == "#final#") {
- if (!array_key_exists($link, $this->__hooks)) {
- $link = '';
- break;
- }
- $key = $k;
- $ended = true;
- }
- if (!is_null($key)) {
- if (!empty($link)) {
- $link .= '/';
- }
- $link .= $key;
- $place =& $place[$key];
- } else {
- $link = '';
- break;
- }
- }
- if ($link == $this->path) {
- $link = '';
- }
- if ($link && levenshtein($link, $this->path) < strlen($link)/3) {
- return $link;
- }
-
- // search for missing namespace (the given name is a leaf)
- $leaf = array_shift($p);
- $args = count($p) ? '/' . implode('/', $p) : '';
- if (isset($leafs[$leaf]) && !is_array($leafs[$leaf]) && $leafs[$leaf] != $this->path) {
- return $leafs[$leaf] . $args;
- }
- unset($val);
- $best = null;
- foreach ($leafs as $k=>&$path) {
- if (is_array($path)) {
- continue;
- }
- $lev = levenshtein($leaf, $k);
-
- if ((!isset($val) || $lev < $val)
- && ($lev <= strlen($k)/2 || strpos($k, $leaf) !== false || strpos($leaf, $k) !== false)) {
- $val = $lev;
- $best = $path;
- }
- }
- return $best == null ? ( $link ? $link : null ) : $best . $args;
- }
-
- protected function check_perms($perms)
- {
- if (!$perms) { // No perms, no check
- return true;
- }
- $s_perms = S::v('perms');
- return $s_perms->hasFlagCombination($perms);
- }
-
- private function call_hook(PlatalPage &$page)
- {
- $hook = $this->find_hook();
- if (empty($hook)) {
- return PL_NOT_FOUND;
- }
- global $globals;
- if ($this->https && !$_SERVER['HTTPS'] && $globals->core->secure_domain) {
- http_redirect('https://' . $globals->core->secure_domain . $_SERVER['REQUEST_URI']);
- }
-
- $args = $this->argv;
- $args[0] =& $page;
-
- if ($hook['auth'] > S::v('auth', AUTH_PUBLIC)) {
- if ($hook['type'] & DO_AUTH) {
- if (!call_user_func(array($globals->session, 'doAuth'))) {
- $this->force_login($page);
- }
- } else {
- return PL_FORBIDDEN;
- }
- }
- if ($hook['auth'] != AUTH_PUBLIC && !$this->check_perms($hook['perms'])) {
- return PL_FORBIDDEN;
- }
-
- $val = call_user_func_array($hook['hook'], $args);
- if ($val == PL_DO_AUTH) {
- // The handler need a better auth with the current args
- if (!call_user_func(array($globals->session, 'doAuth'))) {
- $this->force_login($page);
- }
- $val = call_user_func_array($hook['hook'], $args);
- }
- return $val;
- }
-
- public function force_login(PlatalPage &$page)
- {
- header($_SERVER['SERVER_PROTOCOL'] . ' 403 Forbidden');
- if (S::logged()) {
- $page->changeTpl('core/password_prompt_logged.tpl');
- $page->addJsLink('do_challenge_response_logged.js');
- } else {
- $page->changeTpl('core/password_prompt.tpl');
- $page->addJsLink('do_challenge_response.js');
- }
- $page->assign('platal', $this);
- $page->run();
- }
-
- public function run()
- {
- global $page;
-
- new_skinned_page('platal/index.tpl');
-
- if (empty($this->path)) {
- $this->path = 'index';
- }
-
- $page->assign('platal', $this);
- switch ($this->call_hook($page)) {
- case PL_FORBIDDEN:
- $this->__mods['core']->handler_403($page);
- break;
-
- case PL_NOT_FOUND:
- $this->__mods['core']->handler_404($page);
- break;
- }
-
- $page->assign('platal', $this);
- $page->run();
- }
-
- public function on_subscribe($forlife, $uid, $promo, $pass)
- {
- $args = func_get_args();
- foreach ($this->__mods as $mod) {
- if (!is_callable($mod, 'on_subscribe'))
- continue;
- call_user_func_array(array($mod, 'on_subscribe'), $args);
- }
- }
-}
-
-// vim:set et sw=4 sts=4 sws=4 foldmethod=marker enc=utf-8:
-?>
--- /dev/null
+<?php
+/***************************************************************************
+ * Copyright (C) 2003-2008 Polytechnique.org *
+ * http://opensource.polytechnique.org/ *
+ * *
+ * This program is free software; you can redistribute it and/or modify *
+ * it under the terms of the GNU General Public License as published by *
+ * the Free Software Foundation; either version 2 of the License, or *
+ * (at your option) any later version. *
+ * *
+ * This program is distributed in the hope that it will be useful, *
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of *
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
+ * GNU General Public License for more details. *
+ * *
+ * You should have received a copy of the GNU General Public License *
+ * along with this program; if not, write to the Free Software *
+ * Foundation, Inc., *
+ * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA *
+ ***************************************************************************/
+
+class PlatalGlobals extends PlGlobals
+{
+ /** The x.org version */
+ public $version = '@VERSION@';
+
+ /** db params */
+ public $dbdb = 'x4dat';
+ public $dbhost = 'localhost';
+ public $dbuser = 'x4dat';
+ public $dbpwd = 'x4dat';
+ public $dbcharset = 'utf8';
+
+ /** default skin */
+ public $skin;
+ public $register_skin;
+
+ public function __construct()
+ {
+ parent::__construct(array('platal.ini', 'platal.conf'));
+ }
+
+ public function init()
+ {
+ $this->bootstrap(array('NbIns'), array($this, 'updateNbIns'));
+ $this->bootstrap(array('NbValid'), array($this, 'updateNbValid'));
+ }
+
+ public function asso($key=null)
+ {
+ static $aid = null;
+
+ if (is_null($aid)) {
+ $gp = Get::v('n');
+ if ($p = strpos($gp, '/')) {
+ $gp = substr($gp, 0, $p);
+ }
+
+ if ($gp) {
+ $res = XDB::query('SELECT a.*, d.nom AS domnom,
+ FIND_IN_SET(\'wiki_desc\', a.flags) AS wiki_desc,
+ FIND_IN_SET(\'notif_unsub\', a.flags) AS notif_unsub
+ FROM groupex.asso AS a
+ LEFT JOIN groupex.dom AS d ON d.id = a.dom
+ WHERE diminutif = {?}', $gp);
+ if (!($aid = $res->fetchOneAssoc())) {
+ $aid = array();
+ }
+ } else {
+ $aid = array();
+ }
+ }
+ if (empty($key)) {
+ return $aid;
+ } elseif ( isset($aid[$key]) ) {
+ return $aid[$key];
+ } else {
+ return null;
+ }
+ }
+
+
+ public function updateNbIns()
+ {
+ $res = XDB::query("SELECT COUNT(*)
+ FROM auth_user_md5
+ WHERE perms IN ('admin','user') AND deces=0");
+ $cnt = $res->fetchOneCell();
+ $this->changeDynamicConfig(array('NbIns' => $cnt));
+ }
+
+ public function updateNbValid()
+ {
+ $res = XDB::query("SELECT COUNT(*)
+ FROM requests");
+ $this->changeDynamicConfig(array('NbValid' => $res->fetchOneCell()));
+ }
+}
+
+
+/******************************************************************************
+ * Dynamic configuration update/edition stuff
+ *****************************************************************************/
+
+// vim:set et sw=4 sts=4 sws=4 foldmethod=marker enc=utf-8:
+?>
+++ /dev/null
-<?php
-/***************************************************************************
- * Copyright (C) 2003-2008 Polytechnique.org *
- * http://opensource.polytechnique.org/ *
- * *
- * This program is free software; you can redistribute it and/or modify *
- * it under the terms of the GNU General Public License as published by *
- * the Free Software Foundation; either version 2 of the License, or *
- * (at your option) any later version. *
- * *
- * This program is distributed in the hope that it will be useful, *
- * but WITHOUT ANY WARRANTY; without even the implied warranty of *
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
- * GNU General Public License for more details. *
- * *
- * You should have received a copy of the GNU General Public License *
- * along with this program; if not, write to the Free Software *
- * Foundation, Inc., *
- * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA *
- ***************************************************************************/
-
-require_once 'smarty/libs/Smarty.class.php';
-
-abstract class PlatalPage extends Smarty
-{
- private $_page_type;
- private $_tpl;
- private $_errors;
- private $_failure;
- private $_jsonVars;
-
- // {{{ function PlatalPage()
-
- public function __construct($tpl, $type = SKINNED)
- {
- parent::Smarty();
-
- global $globals;
-
- $this->caching = false;
- $this->config_overwrite = false;
- $this->use_sub_dirs = false;
- $this->template_dir = $globals->spoolroot."/templates/";
- $this->compile_dir = $globals->spoolroot."/spool/templates_c/";
- array_unshift($this->plugins_dir, $globals->spoolroot."/plugins/");
- $this->config_dir = $globals->spoolroot."/configs/";
-
- $this->compile_check = !empty($globals->debug);
-
- $this->changeTpl($tpl, $type);
- $this->_errors = array('errors' => array());
- $this->_jsonVars = array();
- $this->_failure = false;
-
- if ($globals->mode != 'rw') {
- $this->trigError("En raison d'une maintenance, une partie des fonctionnalités du site sont"
- . " actuellement désactivée, en particuliers aucune donnée ne sera sauvegardée");
- }
- $this->register_prefilter('at_to_globals');
- $this->addJsLink('xorg.js');
- $this->addJsLink('jquery.js');
- }
-
- // }}}
- // {{{ function changeTpl()
-
- public function changeTpl($tpl, $type = SKINNED)
- {
- $this->_tpl = $tpl;
- $this->_page_type = $type;
- $this->assign('xorg_tpl', $tpl);
- }
-
- // }}}
- // {{{ function raw()
-
- public function raw()
- {
- global $globals;
- $this->assign('globals', $globals);
- return $this->fetch($this->_tpl);
- }
-
- // }}}
- // {{{ function _run()
-
- protected function _run($skin)
- {
- global $globals, $TIME_BEGIN;
-
- session_write_close();
-
- $this->register_prefilter('trimwhitespace');
- $this->register_prefilter('form_force_encodings');
- $this->register_prefilter('wiki_include');
- $this->register_prefilter('if_has_perms');
- $this->assign('xorg_triggers', $this->_errors);
- $this->assign('xorg_errors', $this->nb_errs());
- $this->assign('xorg_failure', $this->_failure);
- $this->assign('globals', $globals);
-
- if (Env::has('json') && count($this->_jsonVars)) {
- return $this->jsonDisplay();
- }
-
- if (Env::v('display') == 'light') {
- $this->_page_type = SIMPLE;
- } elseif (Env::v('display') == 'raw') {
- $this->_page_type = NO_SKIN;
- } elseif (Env::v('display') == 'full') {
- $this->_page_typ = SKINNED;
- }
-
- switch ($this->_page_type) {
- case NO_SKIN:
- if (!($globals->debug & DEBUG_SMARTY)) {
- error_reporting(0);
- }
- $this->display($this->_tpl);
- exit;
-
- case SIMPLE:
- $this->assign('simple', true);
-
- case SKINNED:
- $this->register_modifier('escape_html', 'escape_html');
- $this->default_modifiers = Array('@escape_html');
- }
- if (S::i('auth') <= AUTH_PUBLIC) {
- $this->register_outputfilter('hide_emails');
- }
- $this->addJsLink('wiki.js');
- header("Accept-Charset: utf-8");
- if (Env::v('forceXml')) {
- header("Content-Type: text/xml; charset=utf-8");
- }
-
- if (!$globals->debug) {
- error_reporting(0);
- $this->display($skin);
- exit;
- }
-
- $this->assign('validate', true);
- if (!($globals->debug & DEBUG_SMARTY)) {
- error_reporting(0);
- }
- $START_SMARTY = microtime(true);
- $result = $this->fetch($skin);
- $ttime = sprintf('Temps total: %.02fs (Smarty %.02fs) - Mémoire totale : %dKo<br />',
- microtime(true) - $TIME_BEGIN, microtime(true) - $START_SMARTY,
- memory_get_peak_usage(true) / 1024);
- if ($globals->debug & DEBUG_BT) {
- PlBacktrace::clean();
- $this->assign_by_ref('backtraces', PlBacktrace::$bt);
- $result = str_replace('@@BACKTRACE@@', $this->fetch('skin/common.backtrace.tpl'), $result);
- } else {
- $result = str_replace('@@BACKTRACE@@', '', $result);
- }
-
- $replc = "<span class='erreur'>VALIDATION HTML INACTIVE</span><br />";
- if ($globals->debug & DEBUG_VALID) {
- $fd = fopen($this->compile_dir."/valid.html","w");
- fwrite($fd, $result);
- fclose($fd);
-
- exec($globals->spoolroot."/bin/devel/xhtml.validate.pl ".$this->compile_dir."/valid.html", $val);
- foreach ($val as $h) {
- if (preg_match("/^X-W3C-Validator-Errors: (\d+)$/", $h, $m)) {
- $replc = '<span style="color: #080;">HTML OK</span><br />';
- if ($m[1]) {
- $replc = "<span class='erreur'><a href='http://validator.w3.org/check?uri={$globals->baseurl}"
- ."/valid.html&ss=1#result'>{$m[1]} ERREUR(S) !!!</a></span><br />";
- }
- break;
- }
- }
- }
-
- echo str_replace("@HOOK@", $ttime.$replc, $result);
- exit;
- }
-
- abstract public function run();
-
- // }}}
- // {{{ function nb_errs()
-
- public function nb_errs()
- {
- return count($this->_errors['errors']);
- }
-
- // }}}
- // {{{ function trig()
-
- private function trig($msg, $type = 'errors')
- {
- if (!isset($this->_errors[$type])) {
- $this->_errors[$type] = array();
- }
- $this->_errors[$type][] = $msg;
- }
-
- public function trigError($msg)
- {
- $this->trig($msg, 'errors');
- }
-
- public function trigWarning($msg)
- {
- $this->trig($msg, 'warnings');
- }
-
- public function trigSuccess($msg)
- {
- $this->trig($msg, 'success');
- }
-
- // }}}
- // {{{ function kill()
-
- public function kill($msg)
- {
- global $platal;
-
- $this->assign('platal', $platal);
- $this->trigError($msg);
- $this->_failure = true;
- $this->run();
- }
-
- // }}}
- // {{{ function addJsLink
-
- public function addJsLink($path)
- {
- $this->append('xorg_js', $path);
- }
-
- // }}}
- // {{{ function addCssLink
-
- public function addCssLink($path)
- {
- $this->append('xorg_css', $path);
- }
-
- // }}}
- // {{{ function addCssInline
-
- public function addCssInline($css)
- {
- if (!empty($css)) {
- $this->append('xorg_inline_css', $css);
- }
- }
-
- // }}}
- // {{{ function setRssLink
-
- public function setRssLink($title, $path)
- {
- $this->assign('xorg_rss', array('title' => $title, 'href' => $path));
- }
-
- // }}}
- // {{{ function jsonDisplay
- protected function jsonDisplay()
- {
- header("Content-type: text/javascript; charset=utf-8");
- array_walk_recursive($this->_jsonVars, "escape_xorgDB");
- $jsonbegin = Env::v('jsonBegin');
- $jsonend = Env::v('jsonEnd');
- if (Env::has('jsonVar')) {
- $jsonbegin = Env::v('jsonVar').' = ';
- $jsonend = ';';
- } elseif (Env::has('jsonFunc')) {
- $jsonbegin = Env::v('jsonFunc').'(';
- $jsonend = ');';
- }
- echo $jsonbegin, json_encode($this->_jsonVars), $jsonend;
- exit;
- }
- // }}}
- // {{{ function jsonAssign
- public function jsonAssign($var, $value)
- {
- $this->_jsonVars[$var] = $value;
- }
-
- // }}}
-}
-
-function escape_xorgDB(&$item, $key)
-{
- if (is_a($item, 'XOrgDBIterator')) {
- $expanded = array();
- while ($a = $item->next()) {
- $expanded[] = $a;
- }
- $item = $expanded;
- }
-}
-
-// {{{ function escape_html ()
-
-/**
- * default smarty plugin, used to auto-escape dangerous html.
- *
- * < --> <
- * > --> >
- * " --> "
- * & not followed by some entity --> &
- */
-function escape_html($string)
-{
- if (is_string($string)) {
- return htmlspecialchars($string, ENT_QUOTES, 'UTF-8');
- } else {
- return $string;
- }
-}
-
-// }}}
-// {{{ function at_to_globals()
-
-/**
- * helper
- */
-
-function _to_globals($s) {
- global $globals;
- $t = explode('.',$s);
- if (count($t) == 1) {
- return var_export($globals->$t[0],true);
- } else {
- return var_export($globals->$t[0]->$t[1],true);
- }
-}
-
-/**
- * compilation plugin used to import $globals confing through #globals.foo.bar# directives
- */
-
-function at_to_globals($tpl_source, &$smarty)
-{
- return preg_replace('/#globals\.([a-zA-Z0-9_.]+?)#/e', '_to_globals(\'\\1\')', $tpl_source);
-}
-
-// }}}
-// {{{ function trimwhitespace
-
-function trimwhitespace($source, &$smarty)
-{
- $tags = '(script|pre|textarea)';
- preg_match_all("!<$tags.*?>.*?</(\\1)>!ius", $source, $tagsmatches);
- $source = preg_replace("!<$tags.*?>.*?</(\\1)>!ius", "&&&tags&&&", $source);
-
- // remove all leading spaces, tabs and carriage returns NOT
- // preceeded by a php close tag.
- $source = preg_replace('/((?<!\?>)\n)[\s]+/m', '\1', $source);
- $source = preg_replace("!&&&tags&&&!e", 'array_shift($tagsmatches[0])', $source);
-
- return $source;
-}
-
-// }}}
-// {{{ function wiki_include
-
-function wiki_include($source, &$smarty)
-{
- return preg_replace('/\{include( [^}]*)? wiki=([^} ]+)(.*?)\}/ui',
- '{include\1 file="../spool/wiki.d/cache_\2.tpl"\3 included=1}',
- $source);
-}
-
-// }}}
-//{{{ function hasPerm
-
-function if_has_perms($source, &$smarty)
-{
- $source = preg_replace('/\{if([^}]*) (\!?)hasPerms\(([^)]+)\)([^}]*)\}/',
- '{if\1 \2$smarty.session.perms->hasFlagCombination(\3)\4}',
- $source);
- return preg_replace('/\{if([^}]*) (\!?)hasPerm\(([^)]+)\)([^}]*)\}/',
- '{if\1 \2($smarty.session.perms && $smarty.session.perms->hasFlag(\3))\4}',
- $source);
-}
-
-// }}}
-// {{{
-
-function form_force_encodings($source, &$smarty)
-{
- return preg_replace('/<form[^\w]/',
- '\0 accept-charset="utf-8" ',
- $source);
-}
-
-// }}}
-// {{{ function hide_emails
-
-function _hide_email($source)
-{
- $source = str_replace("\n", '', $source);
- return '<script type="text/javascript">//<![CDATA[' . "\n" .
- 'Nix.decode("' . addslashes(str_rot13($source)) . '");' . "\n" .
- '//]]></script>';
-}
-
-function hide_emails($source, &$smarty)
-{
- if (!strpos($source, '@')) {
- return $source;
- }
-
- //prevent email replacement in <script> and <textarea>
- $tags = '(script|textarea|select)';
- preg_match_all("!<$tags.*?>.*?</(\\1)>!ius", $source, $tagsmatches);
- $source = preg_replace("!<$tags.*?>.*?</(\\1)>!ius", "&&&tags&&&", $source);
-
- //catch all emails in <a href="mailto:...">
- preg_match_all("!<a[^>]+href=[\"'][^\"']*[-a-z0-9+_.]+@[-a-z0-9_.]+[^\"']*[\"'].*?>.*?</a>!ius", $source, $ahref);
- $source = preg_replace("!<a[^>]+href=[\"'][^\"']*[-a-z0-9+_.]+@[-a-z0-9_.]+[^\"']*[\"'].*?>.*?</a>!ius", '&&&ahref&&&', $source);
-
- //prevant replacement in tag attributes
- preg_match_all("!<[^>]+[-a-z0-9_+.]+@[-a-z0-9_.]+.+?>!ius", $source, $misc);
- $source = preg_replace("!<[^>]+[-a-z0-9_+.]+@[-a-z0-9_.]+.+?>!ius", '&&&misc&&&', $source);
-
- //catch !
- $source = preg_replace('!([-a-z0-9_+.]+@[-a-z0-9_.]+)!iue', '_hide_email("\1")', $source);
- $source = preg_replace('!&&&ahref&&&!e', '_hide_email(array_shift($ahref[0]))', $source);
-
- // restore data
- $source = preg_replace('!&&&misc&&&!e', 'array_shift($misc[0])', $source);
- $source = preg_replace("!&&&tags&&&!e", 'array_shift($tagsmatches[0])', $source);
-
- return $source;
-}
-
-// }}}
-
-// vim:set et sw=4 sts=4 sws=4 foldmethod=marker enc=utf-8:
-?>
+++ /dev/null
-<?php
-/***************************************************************************
- * Copyright (C) 2003-2008 Polytechnique.org *
- * http://opensource.polytechnique.org/ *
- * *
- * This program is free software; you can redistribute it and/or modify *
- * it under the terms of the GNU General Public License as published by *
- * the Free Software Foundation; either version 2 of the License, or *
- * (at your option) any later version. *
- * *
- * This program is distributed in the hope that it will be useful, *
- * but WITHOUT ANY WARRANTY; without even the implied warranty of *
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
- * GNU General Public License for more details. *
- * *
- * You should have received a copy of the GNU General Public License *
- * along with this program; if not, write to the Free Software *
- * Foundation, Inc., *
- * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA *
- ***************************************************************************/
-
-/** Ligth debugging tool to generate execution backtrace
- */
-class PlBacktrace
-{
- static public $bt = array();
-
- public $traces = array();
- public $totaltime = 0.0;
- public $error = false;
-
- function __construct($name, array $init = array(), $sizef = 'rows', $timef = 'exectime', $errorf = 'error')
- {
- PlBacktrace::$bt[$name] = $this;
- foreach ($init as &$entry) {
- $this->add($entry, $sizef, $timef, $errorf);
- }
- }
-
- private function fixCharset($action)
- {
- if (!is_string($action)) {
- return $action;
- } else {
- return is_utf8($action) ? $action : utf8_encode($action);
- }
- }
-
- private function add(array &$entry, $sizef = 'rows', $timef = 'exectime', $errorf = 'error')
- {
- $trace = array();
- $trace['action'] = $this->fixCharset($entry['action']);
- unset($entry['action']);
- $trace['exectime'] = @$entry[$timef];
- $this->totaltime += $trace['exectime'];
- unset($entry[$timef]);
- $trace['rows'] = @$entry[$sizef];
- unset($entry[$sizef]);
- $trace['error'] = $this->fixCharset(@$entry[$errorf]);
- unset($entry[$errorf]);
- if ($trace['error']) {
- $this->error = true;
- }
- $trace['data'] = array($this->fixCharset($entry));
- $this->traces[] =& $trace;
- }
-
- public function newEvent($action, $rows = 0, $error = null, array $userdata = array())
- {
- $trace = array('action' => $this->fixCharset($action), 'time' => 0);
- $this->traces[] =& $trace;
- $this->update($rows, $error, $userdata);
- }
-
- public function start($action)
- {
- $this->traces[] = array('action' => $this->fixCharset($action), 'starttime' => microtime(true));;
- }
-
- public function stop($rows = 0, $error = null, array $userdata = array())
- {
- $time = microtime(true);
- if (!$this->traces) {
- return;
- }
- $trace =& $this->traces[count($this->traces) - 1];
- $trace['exectime'] = $time - $trace['starttime'];
- unset($trace['starttime']);
- $this->totaltime += $trace['exectime'];
- $this->update($rows, $error, $userdata);
- }
-
- public function update($rows = 0, $error = null, array $userdata = array())
- {
- $trace =& $this->traces[count($this->traces) - 1];
- $trace['rows'] = $rows;
- $trace['error'] = $this->fixCharset($error);
- array_walk_recursive($userdata, array($this, 'fixCharset'));
- $trace['data'] = $userdata;
- if ($trace['error']) {
- $this->error = true;
- }
- }
-
- public static function clean()
- {
- foreach (PlBacktrace::$bt as $name=>&$entry) {
- if (!$entry->traces) {
- unset(PlBacktrace::$bt[$name]);
- }
- }
- }
-}
-
-// vim:set et sw=4 sts=4 sws=4 foldmethod=marker enc=utf-8:
-?>
+++ /dev/null
-<?php
-/***************************************************************************
- * Copyright (C) 2003-2008 Polytechnique.org *
- * http://opensource.polytechnique.org/ *
- * *
- * This program is free software; you can redistribute it and/or modify *
- * it under the terms of the GNU General Public License as published by *
- * the Free Software Foundation; either version 2 of the License, or *
- * (at your option) any later version. *
- * *
- * This program is distributed in the hope that it will be useful, *
- * but WITHOUT ANY WARRANTY; without even the implied warranty of *
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
- * GNU General Public License for more details. *
- * *
- * You should have received a copy of the GNU General Public License *
- * along with this program; if not, write to the Free Software *
- * Foundation, Inc., *
- * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA *
- ***************************************************************************/
-
-interface PlIterator
-{
- public function next();
- public function total();
- public function first();
- public function last();
-}
-
-// vim:set et sw=4 sts=4 sws=4 foldmethod=marker enc=utf-8:
-?>
+++ /dev/null
-<?php
-/***************************************************************************
- * Copyright (C) 2003-2008 Polytechnique.org *
- * http://opensource.polytechnique.org/ *
- * *
- * This program is free software; you can redistribute it and/or modify *
- * it under the terms of the GNU General Public License as published by *
- * the Free Software Foundation; either version 2 of the License, or *
- * (at your option) any later version. *
- * *
- * This program is distributed in the hope that it will be useful, *
- * but WITHOUT ANY WARRANTY; without even the implied warranty of *
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
- * GNU General Public License for more details. *
- * *
- * You should have received a copy of the GNU General Public License *
- * along with this program; if not, write to the Free Software *
- * Foundation, Inc., *
- * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA *
- ***************************************************************************/
-
-require_once('smarty/libs/Smarty.class.php');
-
-/** Classe de mail avec corps en templates.
- */
-class PlMail extends Smarty
-{
- private $tpl;
- private $mailer = null;
-
- function __construct($tpl)
- {
- global $globals;
- $this->tpl = $tpl;
- $this->caching = false;
- $this->compile_check = true;
-
- $this->template_dir = $globals->spoolroot . "/templates/";
- $this->compile_dir = $globals->spoolroot . "/spool/mails_c/";
- $this->config_dir = $globals->spoolroot . "/configs/";
- array_unshift($this->plugins_dir, $globals->spoolroot."/plugins/");
-
- $this->register_outputfilter(Array($this, 'mail_format'));
- $this->register_function('from', Array($this, 'setFrom'));
- $this->register_function('to', Array($this, 'addTo'));
- $this->register_function('cc', Array($this, 'addCc'));
- $this->register_function('bcc', Array($this, 'addBcc'));
- $this->register_function('subject', Array($this, 'setSubject'));
- $this->register_function('add_header', Array($this, 'addHeader'));
- $this->assign_by_ref('globals', $globals);
- }
-
- public static function &get(&$mailer, $tpl)
- {
- static $plmail;
- if (!isset($plmail) || $plmail->tpl != $tpl) {
- $plmail = new PlMail($tpl);
- }
- $plmail->mailer =& $mailer;
- return $plmail;
- }
-
- public function run($version)
- {
- $this->assign('mail_part', $version);
- $text = $this->fetch($this->tpl);
- if ($version == 'text') {
- return wordwrap($text, 78);
- }
- return $text;
- }
-
- /** used to remove the empty lines due to {from ...}, {to ...} ... functions */
- static public function mail_format($output, &$smarty)
- {
- return "\n".trim($output)."\n";
- }
-
- static protected function format_addr(&$params)
- {
- if (isset($params['full'])) {
- return $params['full'];
- } elseif (empty($params['text'])) {
- return $params['addr'];
- } else {
- return $params['text'].' <'.$params['addr'].'>';
- }
- }
-
- /** template function : from.
- * {from full=...} for an already formatted address
- * {from addr=... [text=...]} else
- */
- public function setFrom($params, &$smarty)
- {
- $smarty->mailer->setFrom(PlMail::format_addr($params));
- }
-
- /** template function : to.
- * {to full=...} for an already formatted address
- * {to addr=... [text=...]} else
- */
- public function addTo($params, &$smarty)
- {
- $smarty->mailer->addTo(PlMail::format_addr($params));
- }
-
- /** template function : cc.
- * {cc full=...} for an already formatted address
- * {cc addr=... [text=...]} else
- */
- public function addCc($params, &$smarty)
- {
- $smarty->mailer->addCc(PlMail::format_addr($params));
- }
-
- /** template function : bcc.
- * {bcc full=...} for an already formatted address
- * {bcc addr=... [text=...]} else
- */
- public function addBcc($params, &$smarty)
- {
- $smarty->mailer->addBcc(PlMail::format_addr($params));
- }
-
- /** template function : subject.
- * {subject text=...}
- */
- public function setSubject($params, &$smarty)
- {
- $smarty->mailer->setSubject($params['text']);
- }
-
- /** template function : add_header.
- * {add_header name=... value=...}
- */
- public function addHeader($params, &$smarty)
- {
- $smarty->mailer->addHeader($params['name'], $params['value']);
- }
-}
-
-require_once('Mail.php');
-require_once('Mail/mime.php');
-
-/** Class for sending inline or multipart-emails.
- * Based on Diogenes' HermesMailer
- */
-class PlMailer extends Mail_Mime {
-
- private $mail;
- private $page = null;
- private $charset;
- private $wiki = null;
-
- function __construct($tpl = null, $charset = "UTF-8")
- {
- $this->charset = $charset;
- $this->Mail_Mime("\n");
- $this->mail = Mail::factory('sendmail', Array('sendmail_args' => '-oi'));
- if (!is_null($tpl)) {
- $this->page =& PlMail::get($this, $tpl);
- }
- }
-
- /**
- * converts all : Foo Bar Baz <quux@foobar.org> into "Foo Bar Baz" <quux@foobar.org> which is RFC compliant
- */
- private function correct_emails($email)
- {
- return preg_replace('!(^|, *)([^<"]+?) *(<[^>]*>)!u', '\1"\2" \3', $email);
- }
-
- public function addTo($email)
- {
- $email = $this->correct_emails($email);
- if (isset($this->_headers['To'])) {
- $this->_headers['To'] .= ", $email";
- } else {
- $this->_headers['To'] = $email;
- }
- }
-
- public function addCc($email)
- {
- return parent::addCc($this->correct_emails($email));
- }
-
- public function addBcc($email)
- {
- return parent::addBcc($this->correct_emails($email));
- }
-
- public function setFrom($email)
- {
- return parent::setFrom($this->correct_emails($email));
- }
-
- public function addHeader($hdr,$val)
- {
- switch($hdr) {
- case 'From':
- $this->setFrom($val);
- break;
-
- case 'To':
- unset($this->_headers[$hdr]);
- $this->addTo($val);
- break;
-
- case 'Cc':
- unset($this->_headers[$hdr]);
- $this->addCc($val);
- break;
-
- case 'Bcc':
- unset($this->_headers[$hdr]);
- $this->addBcc($val);
- break;
-
- default:
- $this->headers(Array($hdr=>$val));
- }
- }
-
- public function addUploadAttachment(PlUpload &$upload, $name)
- {
- $encoding = $upload->isType('text') ? 'quoted-printable' : 'base64';
- $this->addAttachment($upload->getContents(), $upload->contentType(), $name, false, $encoding);
- }
-
- public function assign($var, $value)
- {
- if (!is_null($this->page)) {
- $this->page->assign($var, $value);
- }
- }
-
- public function assign_by_ref($var, &$value)
- {
- if (!is_null($this->page)) {
- $this->page->assign_by_ref($var, $value);
- }
- }
-
- public function register_modifier($var, $callback)
- {
- if (!is_null($this->page)) {
- $this->page->register_modifier($var, $callback);
- }
- }
-
- public function register_function($var, $callback)
- {
- if (!is_null($this->page)) {
- $this->page->register_function($var, $callback);
- }
- }
-
- public function setWikiBody($wiki)
- {
- $this->wiki = $wiki;
- }
-
- private function processPage($with_html = true)
- {
- if (!is_null($this->page)) {
- global $globals;
- if (!($globals->debug & DEBUG_SMARTY)) {
- $level = error_reporting(0);
- }
- $this->page->run('head'); // process page headers
- $this->wiki = trim($this->page->run('wiki')); // get wiki
- if (!$this->wiki) {
- $this->setTxtBody($this->page->run('text'));
- if ($with_html) {
- $html = trim($this->page->run('html'));
- if (!empty($html)) {
- $this->setHtmlBody($html);
- }
- }
- }
- if (!($globals->debug & DEBUG_SMARTY)) {
- error_reporting($level);
- }
- }
- if ($this->wiki) {
- $this->setTxtBody(MiniWiki::WikiToText($this->wiki, false, 0, 78));
- if ($with_html) {
- $this->setHtmlBody('<html><body>' . MiniWiki::WikiToHtml($this->wiki, true) . '</body></html>');
- }
- }
- }
-
- public function send($with_html = true)
- {
- $this->processPage($with_html);
- if (S::v('forlife')) {
- global $globals;
- $this->addHeader('X-Org-Mail', S::v('forlife') . '@' . $globals->mail->domain);
- }
- $addrs = Array();
- foreach(Array('To', 'Cc', 'Bcc') as $hdr) {
- if(isset($this->_headers[$hdr])) {
- require_once 'Mail/RFC822.php';
- $parsed = @Mail_RFC822::parseAddressList($this->_headers[$hdr]);
- if (is_array($parsed)) {
- $addrs = array_merge($addrs, $parsed);
- }
- }
- }
- if(empty($addrs)) {
- return false;
- }
-
- $dests = Array();
- foreach($addrs as $a) {
- $dests[] = "{$a->mailbox}@{$a->host}";
- }
-
- // very important to do it in THIS order very precisely.
- $body = $this->get(array('text_charset' => $this->charset,
- 'text_encoding' => '8bit',
- 'html_charset' => $this->charset,
- 'head_charset' => $this->charset));
- $hdrs = $this->headers();
- if (empty($hdrs['From'])) {
- trigger_error('Empty "From", mail not sent', E_USER_WARNING);
- return false;
- }
- return $this->mail->send($dests, $hdrs, $body);
- }
-}
-
-// vim:set et sw=4 sts=4 sws=4 foldmethod=marker enc=utf-8:
-?>
+++ /dev/null
-<?php
-/***************************************************************************
- * Copyright (C) 2003-2008 Polytechnique.org *
- * http://opensource.polytechnique.org/ *
- * *
- * This program is free software; you can redistribute it and/or modify *
- * it under the terms of the GNU General Public License as published by *
- * the Free Software Foundation; either version 2 of the License, or *
- * (at your option) any later version. *
- * *
- * This program is distributed in the hope that it will be useful, *
- * but WITHOUT ANY WARRANTY; without even the implied warranty of *
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
- * GNU General Public License for more details. *
- * *
- * You should have received a copy of the GNU General Public License *
- * along with this program; if not, write to the Free Software *
- * Foundation, Inc., *
- * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA *
- ***************************************************************************/
-
-abstract class PLModule
-{
- abstract function handlers();
-
- /** Register a hook
- * @param fun name of the handler (the exact name will be handler_$fun)
- * @param auth authentification level of needed to run this handler
- * @param perms permission required to run this handler
- * @param type additionnal flags
- *
- * Perms syntax is the following:
- * perms = rights(,rights)*
- * rights = right(:right)*
- * right is an atomic right permission (like 'admin', 'user', 'groupadmin', 'groupmember'...)
- *
- * If type is set to NO_AUTH, the system will return 403 instead of asking auth data
- * this is useful for Ajax handler
- * If type is not set to NO_SKIN, the system will consider redirecting the user to https
- */
- public function make_hook($fun, $auth, $perms = 'user', $type = DO_AUTH)
- {
- return array('hook' => array($this, 'handler_'.$fun),
- 'auth' => $auth,
- 'perms' => $perms,
- 'type' => $type);
- }
-
- /* static functions */
-
- public static function factory($modname)
- {
- $mod_path = dirname(__FILE__) . '/../modules/' . $modname . '.php';
- $class = ucfirst($modname) . 'Module';
-
- require_once $mod_path;
- return new $class();
- }
-}
-
-// vim:set et sw=4 sts=4 sws=4 foldmethod=marker enc=utf-8:
-?>
+++ /dev/null
-<?php
-/***************************************************************************
- * Copyright (C) 2003-2008 Polytechnique.org *
- * http://opensource.polytechnique.org/ *
- * *
- * This program is free software; you can redistribute it and/or modify *
- * it under the terms of the GNU General Public License as published by *
- * the Free Software Foundation; either version 2 of the License, or *
- * (at your option) any later version. *
- * *
- * This program is distributed in the hope that it will be useful, *
- * but WITHOUT ANY WARRANTY; without even the implied warranty of *
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
- * GNU General Public License for more details. *
- * *
- * You should have received a copy of the GNU General Public License *
- * along with this program; if not, write to the Free Software *
- * Foundation, Inc., *
- * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA *
- ***************************************************************************/
-
-/** UserSet is a light-weight Model/View tool for displaying a set of items
- */
-class PlSet
-{
- private $from = null;
- private $groupby = null;
- private $joins = null;
- private $where = null;
-
- private $count = null;
-
- private $mods = array();
- private $modParams = array();
- private $mod = null;
- private $default = null;
-
- public function __construct($from, $joins = '', $where = '', $groupby = '')
- {
- $this->from = $from;
- $this->joins = $joins;
- $this->where = $where;
- $this->groupby = $groupby;
- }
-
- public function addMod($name, $description, $default = false, array $params = array())
- {
- $name = strtolower($name);
- $this->mods[$name] = $description;
- $this->modParams[$name] = $params;
- if ($default) {
- $this->default = $name;
- }
- }
-
- public function rmMod($name)
- {
- $name = strtolower($name);
- unset($this->mods[$name]);
- }
-
- private function &query($fields, $from, $joins, $where, $groupby, $order, $limit)
- {
- if (trim($order)) {
- $order = "ORDER BY $order";
- }
- if (trim($where)) {
- $where = "WHERE $where";
- }
- if (trim($groupby)) {
- $groupby = "GROUP BY $groupby";
- }
- $query = "SELECT SQL_CALC_FOUND_ROWS
- $fields
- FROM $from
- $joins
- $where
- $groupby
- $order
- $limit";
-// echo $query;
-// print_r($this);
- $it = XDB::query($query);
- $it = $it->fetchAllAssoc();
- $count = XDB::query('SELECT FOUND_ROWS()');
- $this->count = intval($count->fetchOneCell());
- return $it;
- }
-
- public function args()
- {
- $get = $_GET;
- unset($get['n']);
- return $get;
- }
-
- protected function encodeArgs(array $args, $encode = false)
- {
- $qs = '?';
- $sep = '&';
- foreach ($args as $k=>$v) {
- if (!$encode) {
- $k = urlencode($k);
- $v = urlencode($v);
- }
- $qs .= "$k=$v$sep";
- }
- return $encode ? urlencode($qs) : $qs;
- }
-
- public function &get($fields, $joins, $where, $groupby, $order, $limitcount = null, $limitfrom = null)
- {
- if (!is_null($limitcount)) {
- if (!is_null($limitfrom)) {
- $limitcount = "$limitfrom,$limitcount";
- }
- $limitcount = "LIMIT $limitcount";
- }
- $joins = $this->joins . ' ' . $joins;
- if (trim($this->where)) {
- if (trim($where)) {
- $where .= ' AND ';
- }
- $where .= $this->where;
- }
- if (!$groupby) {
- $groupby = $this->groupby;
- }
- return $this->query($fields, $this->from, $joins, $where, $groupby, $order, $limitcount);
- }
-
- public function count()
- {
- return $this->count;
- }
-
- private function &buildView($view, $data)
- {
- $view = strtolower($view);
- if (!$view || !class_exists($view . 'View') || !isset($this->mods[$view])) {
- reset($this->mods);
- $view = $this->default ? $this->default : key($this->mods);
- }
- $this->mod = $view;
- $class = $view . 'View';
- if (!class_exists($class)) {
- $view = null;
- } else {
- $view = new $class($this, $data, $this->modParams[$this->mod]);
- if (!$view instanceof PlView) {
- $view = null;
- }
- }
- return $view;
- }
-
- public function apply($baseurl, PlatalPage &$page, $view = null, $data = null)
- {
- $view =& $this->buildView($view, $data);
- if (is_null($view)) {
- return false;
- }
- $args = $view->args();
- if (!isset($args['rechercher'])) {
- $args['rechercher'] = 'Chercher';
- }
- $page->changeTpl('core/plset.tpl');
- $page->assign('plset_base', $baseurl);
- $page->assign('plset_mods', $this->mods);
- $page->assign('plset_mod', $this->mod);
- $page->assign('plset_search', $this->encodeArgs($args));
- $page->assign('plset_search_enc', $this->encodeArgs($args, true));
- foreach ($this->modParams[$this->mod] as $param=>$value) {
- $page->assign($this->mod . '_' . $param, $value);
- }
- $page->assign('plset_content', $view->apply($page));
- $page->assign('plset_count', $this->count);
- return true;
- }
-}
-
-interface PlView
-{
- public function __construct(PlSet &$set, $data, array $params);
- public function apply(PlatalPage &$page);
- public function args();
-}
-
-abstract class MultipageView implements PlView
-{
- protected $set;
-
- public $pages = 1;
- public $page = 1;
- public $offset = 0;
-
- protected $entriesPerPage = 20;
- protected $params = array();
-
- protected $sortkeys = array();
- protected $defaultkey = null;
-
- protected $bound_field = null;
-
- public function __construct(PlSet &$set, $data, array $params)
- {
- $this->set =& $set;
- $this->page = Env::i('page', 1);
- $this->offset = $this->entriesPerPage * ($this->page - 1);
- $this->params = $params;
- }
-
- public function joins()
- {
- return null;
- }
-
- public function where()
- {
- return null;
- }
-
- public function groupBy()
- {
- return null;
- }
-
- public function bounds()
- {
- return null;
- }
-
- protected function addSortKey($name, array $keys, $desc, $default = false)
- {
- $this->sortkeys[$name] = array('keys' => $keys, 'desc' => $desc);
- if (!$this->defaultkey || $default) {
- $this->defaultkey = $name;
- }
- }
-
- public function order()
- {
- $order = Env::v('order', $this->defaultkey);
- $invert = ($order{0} == '-');
- if ($invert) {
- $order = substr($order, 1);
- }
- $list = array();
- foreach ($this->sortkeys[$order]['keys'] as $item) {
- $desc = ($item{0} == '-');
- if ($desc) {
- $item = substr($item, 1);
- }
- if ($desc xor $invert) {
- $item .= ' DESC';
- }
- $list[] = $item;
- }
- return implode(', ', $list);
- }
-
- abstract public function templateName();
-
- public function apply(PlatalPage &$page)
- {
- $res = $this->set->get($this->fields(),
- $this->joins(),
- $this->where(),
- $this->groupBy(),
- $this->order(),
- $this->entriesPerPage,
- $this->offset);
- $show_bounds = $this->bounds();
- $end = end($res);
- if ($show_bounds) {
- if ($show_bounds == 1) {
- $first = $res[0][$this->bound_field];
- $last = $end[$this->bound_field];
- } elseif ($show_bounds == -1) {
- $first = $end[$this->bound_field];
- $last = $res[0][$this->bound_field];
- }
- $page->assign('first', $first);
- $page->assign('last', $last);
- }
-
- $page->assign('show_bounds', $show_bounds);
- $page->assign('order', Env::v('order', $this->defaultkey));
- $page->assign('orders', $this->sortkeys);
- $page->assign_by_ref('plview', $this);
- $page->assign_by_ref('set', $res);
- $count = $this->set->count();
- $this->pages = intval(ceil($count / $this->entriesPerPage));
- return 'include/plview.multipage.tpl';
- }
-
- public function args()
- {
- $list = $this->set->args();
- unset($list['page']);
- unset($list['order']);
- return $list;
- }
-}
-
-// vim:set et sw=4 sts=4 sws=4 foldmethod=marker enc=utf-8:
-?>
+++ /dev/null
-<?php
-/***************************************************************************
- * Copyright (C) 2003-2008 Polytechnique.org *
- * http://opensource.polytechnique.org/ *
- * *
- * This program is free software; you can redistribute it and/or modify *
- * it under the terms of the GNU General Public License as published by *
- * the Free Software Foundation; either version 2 of the License, or *
- * (at your option) any later version. *
- * *
- * This program is distributed in the hope that it will be useful, *
- * but WITHOUT ANY WARRANTY; without even the implied warranty of *
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
- * GNU General Public License for more details. *
- * *
- * You should have received a copy of the GNU General Public License *
- * along with this program; if not, write to the Free Software *
- * Foundation, Inc., *
- * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA *
- ***************************************************************************/
-
-class PLTableEditor
-{
- // the plat/al name of the page
- public $pl;
- // the table name
- public $table;
- // joint tables to delete when deleting an entry
- public $jtables = array();
- // sorting field
- public $sort = array();
- // the id field
- public $idfield;
- // possibility to edit the field
- public $idfield_editable;
- // vars
- public $vars;
- // number of displayed fields
- public $nbfields;
- // a where clause to restrict table
- public $whereclause;
- // the field for sorting entries
- public $sortfield;
- public $sortdesc = false;
- // action to do to delete row:
- // null => delete effectively, false => no deletion, SQL
- public $delete_action;
- public $delete_message;
- // Should "Save" button return to the list view
- public $auto_return = true;
-
- /* table editor for platal
- * $plname : the PLname of the page, ex: admin/payments
- * $table : the table to edit, ex: profile_medals
- * $idfield : the field of the table which is the id, ex: id
- * $editid : is the id editable or not (if not, it is considered as an int)
- */
- public function __construct($plname, $table, $idfield, $editid=false)
- {
- $this->pl = $plname;
- $this->table = $table;
- $this->idfield = $idfield;
- $this->sortfield = $idfield;
- $this->idfield_editable = $editid;
- $this->whereclause = '1';
- $r = XDB::iterator("SHOW FULL COLUMNS FROM $table");
- $this->vars = array();
- while ($a = $r->next()) {
- // desc will be the title of the column
- $a['desc'] = $a['Field'];
- $a['display'] = true;
-
- if (substr($a['Type'],0,8) == 'varchar(') {
- // limit editing box size
- $a['Size'] = $a['Maxlength'] = substr($a['Type'], 8, strlen($a['Type']) - 9);
- if ($a['Size'] > 40) $a['Size'] = 40;
- // if too big, put a textarea
- $a['Type'] = ($a['Maxlength']<200)?'varchar':'varchar200';
- }
- elseif ($a['Type'] == 'text' || $a['Type'] == 'mediumtext')
- $a['Type'] = 'textarea';
- elseif (substr($a['Type'],0,4) == 'set(') {
- // get the list of options
- $a['List'] = explode('§',str_replace("','","§",substr($a['Type'], 5, strlen($a['Type']) - 7)));
- if (count($a['List']) == 1) {
- $a['Type'] = 'checkbox';
- $a['Value'] = $a['List'][0];
- } else {
- $a['Type'] = 'set';
- }
- }
- elseif (substr($a['Type'],0,5) == 'enum(') {
- // get the list of options
- $a['List'] = explode('§',str_replace("','","§",substr($a['Type'], 6, strlen($a['Type']) - 8)));
- $a['Type'] = 'enum';
- }
- elseif (substr($a['Type'],0,10) == 'timestamp(' || $a['Type'] == 'datetime') {
- $a['Type'] = 'timestamp';
- }
- elseif ($a['Comment'] == 'ip_address') {
- $a['Type']='ip_address';
- }
-
- $this->vars[$a['Field']] = $a;
- }
- $this->vars[$idfield]['desc'] = 'id';
- }
-
- // called before creating a new entry
- private function prepare_new()
- {
- $entry = array();
- foreach ($this->vars as $field => $descr) {
- $entry[$field] = $descr['Default'];
- }
- return $this->prepare_edit($entry);
- }
-
- // called before editing $entry
- private function prepare_edit(&$entry)
- {
- foreach ($this->vars as $field => $descr) {
- if ($descr['Type'] == 'set') {
- // get the list of options selected
- $selected = explode(',', $entry[$field]);
- $entry[$field] = array();
- foreach ($selected as $option)
- $entry[$field][$option] = 1;
- }
- if ($descr['Type'] == 'timestamp') {
- // set readable timestamp
- $date =& $entry[$field];
- $date = preg_replace('/([0-9]{4})([0-9]{2})([0-9]{2})([0-9]{2})([0-9]{2})([0-9]{2})/', '\3/\2/\1 \4:\5:\6', $date);
- }
- if ($descr['Type'] == 'date') {
- $date =& $entry[$field];
- $date = preg_replace('/([0-9]{4})-?([0-9]{2})-?([0-9]{2})/', '\3/\2/\1', $date);
- }
- if ($descr['Type'] == 'ip_address') {
- $ip = & $entry[$field];
- $ip = long2ip($ip);
- }
- }
- return $entry;
- }
-
- // set whether the save button show redirect to list view or edit view
- public function list_on_edit($var)
- {
- $this->auto_return = $var;
- }
-
- // change display of a field
- public function describe($name, $desc, $display)
- {
- $this->vars[$name]['desc'] = $desc;
- $this->vars[$name]['display'] = $display;
- }
-
- // add a join table, when deleting a row corresponding entries will be deleted in these tables
- public function add_join_table($name,$joinid,$joindel,$joinextra="")
- {
- if ($joindel)
- $this->jtables[$name] = array("joinid" => $joinid,"joinextra" => $joinextra?(" AND ".$joinextra):"");
- }
-
- // add a sort key
- public function add_sort_field($key, $desc = false, $default = false)
- {
- if ($default) {
- $this->sortfield = $key . ($desc ? ' DESC' : '');
- } else {
- $this->sort[] = $key . ($desc ? ' DESC' : '');
- }
- }
-
- // add a where clause to limit table listing
- public function set_where_clause($whereclause="1")
- {
- $this->whereclause = $whereclause;
- }
-
- // set an action when trying to delete row
- public function on_delete($action = NULL, $message = NULL)
- {
- $this->delete_action = $action;
- $this->delete_message = $message;
- }
-
- // call when done
- public function apply(PlatalPage &$page, $action, $id = false)
- {
- $page->changeTpl('core/table-editor.tpl');
- $list = true;
- if ($action == 'delete') {
- S::assert_xsrf_token();
-
- if (!isset($this->delete_action)) {
- foreach ($this->jtables as $table => $j)
- XDB::execute("DELETE FROM {$table} WHERE {$j['joinid']} = {?}{$j['joinextra']}", $id);
- XDB::execute("DELETE FROM {$this->table} WHERE {$this->idfield} = {?}",$id);
- $page->trigSuccess("L'entrée ".$id." a été supprimée.");
- } else if ($this->delete_action) {
- XDB::execute($this->delete_action, $id);
- if (isset($this->delete_message)) {
- $page->trigSuccess($this->delete_message);
- } else {
- $page->trigSuccess("L'entrée ".$id." a été supprimée.");
- }
- } else {
- $page->trigError("Impossible de supprimer l'entrée.");
- }
- }
- if ($action == 'edit') {
- $r = XDB::query("SELECT * FROM {$this->table} WHERE {$this->idfield} = {?} AND {$this->whereclause}",$id);
- $entry = $r->fetchOneAssoc();
- $page->assign('entry', $this->prepare_edit($entry));
- $page->assign('id', $id);
- $list = false;
- }
- if ($action == 'massadd') {
- $importer = new CSVImporter($this->table, $this->idfield_editable ? $this->idfield : null);
- $fields = array();
- foreach ($this->vars as $field=>$descr) {
- if ($this->idfield_editable || $field != $this->idfield) {
- $fields[] = $field;
- $importer->describe($field, @$descr['desc']);
- }
- }
- $page->assign('massadd', true);
- $importer->apply($page, $this->pl . '/massadd', $fields);
- $list = false;
- }
- if ($action == 'new') {
- if (!$this->idfield_editable) {
- $r = XDB::query("SELECT MAX({$this->idfield})+1 FROM {$this->table}");
- $page->assign('id', $r->fetchOneCell());
- $page->assign('entry', $this->prepare_new());
- }
- $list = false;
- }
- if ($action == 'update') {
- S::assert_xsrf_token();
-
- $values = "";
- $cancel = false;
- foreach ($this->vars as $field => $descr) {
- if ($values) $values .= ',';
- if (($field == $this->idfield) && !$this->idfield_editable)
- $val = "'".addslashes($id)."'";
- elseif ($descr['Type'] == 'set') {
- $val = "";
- if (Post::has($field)) foreach (Post::v($field) as $option) {
- if ($val) $val .= ',';
- $val .= $option;
- }
- $val = "'".addslashes($val)."'";
- } elseif ($descr['Type'] == 'checkbox') {
- $val = Post::has($field)?"'".addslashes($descr['Value'])."'":"''";
- } elseif (Post::has($field)) {
- $val = Post::v($field);
- if ($descr['Type'] == 'timestamp') {
- $val = preg_replace('/([0-9]{1,2})\/([0-9]{1,2})\/([0-9]{4}) ([0-9]{1,2}):([0-9]{1,2}):([0-9]{1,2})/', '\3\2\1\4\5\6', $val);
- }
- elseif ($descr['Type'] == 'date') {
- $val = preg_replace('/([0-9]{1,2})\/([0-9]{1,2})\/([0-9]{4})/', '\3-\2-\1', $val);
- }
- elseif ($descr['Type'] == 'ip_address') {
- $val = ip2long($val);
- }
- $val = "'".addslashes($val)."'";
- } else {
- $cancel = true;
- $page->trigError("Il manque le champ ".$field);
- }
- $values .= $val;
- }
- if (!$cancel) {
- if ($this->idfield_editable && ($id != Post::v($this->idfield)) && $action != 'new')
- XDB::execute("UPDATE {$this->table} SET {$this->idfield} = {?} WHERE {$this->idfield} = {?} AND {$this->whereclause}", Post::v($this->idfield), $id);
- XDB::execute("REPLACE INTO {$this->table} VALUES ($values)");
- if ($id !== false)
- $page->trigSuccess("L'entrée ".$id." a été mise à jour.");
- else {
- $page->trigSuccess("Une nouvelle entrée a été créée.");
- $id = XDB::insertId();
- }
- } else
- $page->trigError("Impossible de mettre à jour.");
- if (!$this->auto_return) {
- return $this->apply($page, 'edit', $id);
- }
- }
- if ($action == 'sort') {
- $this->sortfield = $id;
- }
- if ($action == 'sortdesc') {
- $this->sortfield = $id.' DESC';
- }
- if ($list) {
- // user can sort by field by clicking the title of the column
- if (isset($this->sortfield)) {
- // add this sort order after the others (chosen by dev)
- $this->add_sort_field($this->sortfield);
- if (substr($this->sortfield,-5) == ' DESC') {
- $this->sortfield = substr($this->sortfield,0,-5);
- $this->sortdesc = true;
- }
- }
- if (count($this->sort) > 0) {
- $sort = 'ORDER BY ' . join($this->sort, ',');
- }
- $it = XDB::iterator("SELECT * FROM {$this->table} WHERE {$this->whereclause} $sort");
- $this->nbfields = 0;
- foreach ($this->vars as $field => $descr)
- if ($descr['display']) $this->nbfields++;
- $page->assign('list', $it);
- }
- $page->assign('t', $this);
- }
-}
-
-// vim:set et sw=4 sts=4 sws=4 foldmethod=marker enc=utf-8:
-?>
+++ /dev/null
-<?php
-/***************************************************************************
- * Copyright (C) 2003-2008 Polytechnique.org *
- * http://opensource.polytechnique.org/ *
- * *
- * This program is free software; you can redistribute it and/or modify *
- * it under the terms of the GNU General Public License as published by *
- * the Free Software Foundation; either version 2 of the License, or *
- * (at your option) any later version. *
- * *
- * This program is distributed in the hope that it will be useful, *
- * but WITHOUT ANY WARRANTY; without even the implied warranty of *
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
- * GNU General Public License for more details. *
- * *
- * You should have received a copy of the GNU General Public License *
- * along with this program; if not, write to the Free Software *
- * Foundation, Inc., *
- * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA *
- ***************************************************************************/
-
-/** Class to store per user and per category files
- */
-class PlUpload
-{
- private $forlife;
- private $category;
- private $file_id;
-
- private $filename;
- private $type;
-
- static public $lastError;
-
- /** For images
- */
- private $x;
- private $y;
-
- public function __construct($forlife, $category, $filename = null)
- {
- $this->file_id = $filename;
- $this->category = $category;
- $this->forlife = $forlife;
- $this->filename = $this->makeFilename($this->file_id);
- $this->checkContentType();
- }
-
- private function makeFilename($file_id)
- {
- global $globals;
- $filename = $globals->spoolroot . '/spool/tmp/';
- if (!file_exists($filename)) {
- if (!mkdir($filename)) {
- trigger_error('can\'t create upload directory: ' . $filename, E_USER_ERROR);
- }
- }
- $filename .= $this->forlife . '--' . $this->category;
- if ($file_id) {
- $filename .= '--' . $file_id;
- }
- return $filename;
- }
-
- private function checkContentType()
- {
- if ($this->exists()) {
- $this->type = trim(mime_content_type($this->filename));
- if ($this->type == 'text/plain') { // Workaround a bug of php 5.2.0+etch10 (mime_content_type fallback is 'text/plain')
- $this->type = preg_replace('/;.*/', '', trim(shell_exec('file -bi ' . escapeshellarg($this->filename))));
- }
- }
- }
-
- public function upload(array &$file)
- {
- if (@$file['error']) {
- PlUpload::$lastError = 'Erreur de téléchargement de ' . $file['name'] . ' : ';
- switch ($file['error']) {
- case UPLOAD_ERR_INI_SIZE: case UPLOAD_ERR_FORM_SIZE:
- PlUpload::$lastError .= 'le fichier est trop gros (limite : ' . ini_get('upload_max_filesize') . ')';
- break;
- case UPLOAD_ERR_PARTIAL: case UPLOAD_ERR_NO_FILE:
- PlUpload::$lastError .= 'le fichier n\'a pas été transmis intégralement';
- break;
- default:
- PlUpload::$lastError .= 'erreur interne';
- break;
- }
- return false;
- }
- if (!is_uploaded_file($file['tmp_name'])) {
- return false;
- } else if (!move_uploaded_file($file['tmp_name'], $this->filename)) {
- return false;
- }
- $this->checkContentType();
- return true;
- }
-
- public function copyFrom($filename)
- {
- if (!copy($filename, $this->filename)) {
- return false;
- }
- $this->checkContentType();
- return true;
- }
-
- public function download($url)
- {
- if (!$url || @parse_url($url) === false) {
- trigger_error('malformed URL given', E_USER_NOTICE);
- return false;
- }
- $data = file_get_contents($url);
- if (!$data) {
- return false;
- }
- if (!file_put_contents($this->filename, $data)) {
- return false;
- }
- $this->checkContentType();
- return true;
- }
-
- static public function &get(array &$file, $forlife, $category, $uniq = false)
- {
- $upload = new PlUpload($forlife, $category, $uniq ? null : $file['name']);
- if (!$upload->upload($file)) {
- $upload = null;
- }
- return $upload;
- }
-
- public function rm()
- {
- @unlink($this->filename);
- @clearstatcache();
- }
-
- public function rename($fn)
- {
- if (!$this->file_id) {
- return false;
- }
- $filename = $this->makeFilename($fn);
- if (rename($this->filename)) {
- $this->filename = $filename;
- $this->file_id = $fn;
- clearstatcache();
- return true;
- }
- return false;
- }
-
- public function exists()
- {
- return file_exists($this->filename);
- }
-
- static public function listRawFiles($forlife = '*', $category = '*', $uniq = false, $basename = false)
- {
- global $globals;
- $filename = $globals->spoolroot . '/spool/tmp/';
- $filename .= $forlife . '--' . $category;
- if (!$uniq) {
- $filename .= '--*';
- }
- $files = glob($filename);
- if ($basename) {
- $files = array_map('basename', $files);
- }
- return $files;
- }
-
- static public function listFilenames($forlife = '*', $category = '*')
- {
- $files = PlUpload::listRawFiles($forlife, $category, false, true);
- foreach ($files as &$name) {
- list($forlife, $cat, $fn) = explode('--', $name, 3);
- $name = $fn;
- }
- return $files;
- }
-
- static public function &listFiles($forlife = '*', $category = '*', $uniq = false)
- {
- $res = array();
- $files = PlUpload::listRawFiles($forlife, $category, $uniq, true);
- foreach ($files as $name) {
- list($forlife, $cat, $fn) = explode('--', $name, 3);
- $res[$fn] = new PlUpload($forlife, $cat, $fn);
- }
- return $res;
- }
-
- static public function clear($user = '*', $category = '*', $uniq = false)
- {
- $files = PlUpload::listRawFiles($user, $category, $uniq, false);
- array_map('unlink', $files);
- }
-
- public function contentType()
- {
- return $this->type;
- }
-
- public function isType($type, $subtype = null)
- {
- list($mytype, $mysubtype) = explode('/', $this->type);
- if ($mytype != $type || ($subtype && $mysubtype != $subtype)) {
- return false;
- }
- return true;
- }
-
- public function imageInfo()
- {
- static $map;
- if (!isset($map)) {
- $tmpmap = array (IMG_GIF => 'gif', IMG_JPG => 'jpeg', IMG_PNG => 'png', IMG_WBMP => 'bmp', IMG_XPM => 'xpm');
- $map = array();
- $supported = imagetypes();
- foreach ($tmpmap as $type=>$mime) {
- if ($supported & $type) {
- $map[$type] = $mime;
- }
- }
- }
- $array = getimagesize($this->filename);
- $array[2] = @$map[$array[2]];
- if (!$array[2]) {
- list($image, $type) = explode('/', $array['mime']);
- $array[2] = $type;
- }
- if (!$array[2]) {
- trigger_error('unknown image type', E_USER_NOTICE);
- return null;
- }
- return $array;
- }
-
- public function resizeImage($max_x = -1, $max_y = -1, $min_x = 0, $min_y = 0, $maxsize = -1)
- {
- if (!$this->exists() || strpos($this->type, 'image/') !== 0) {
- trigger_error('not an image', E_USER_NOTICE);
- return false;
- }
- $image_infos = $this->imageInfo();
- if (!$image_infos) {
- trigger_error('invalid image', E_USER_NOTICE);
- return false;
- }
- list($this->x, $this->y, $mimetype) = $image_infos;
- if ($max_x == -1) {
- $max_x = $this->x;
- }
- if ($max_y == -1) {
- $max_y = $this->y;
- }
- if ($maxsize == -1) {
- $maxsize = filesize($this->filename);
- }
- if (filesize($this->filename) > $maxsize || $this->x > $max_x || $this->y > $max_y
- || $this->x < $min_x || $this->y < $min_y) {
- $img = imagecreatefromstring(file_get_contents($this->filename));
- if (!$img) {
- trigger_error('too large image, can\'t be resized', E_USER_NOTICE);
- return false;
- }
-
- $nx = $this->x;
- $ny = $this->y;
- if ($nx > $max_x) {
- $ny = intval($ny*$max_x/$nx);
- $nx = $max_x;
- }
- if ($ny > $max_y) {
- $nx = intval($nx*$max_y/$ny);
- $ny = $max_y;
- }
- if ($nx < $min_x) {
- $ny = intval($ny*$min_x/$nx);
- $nx = $min_x;
- }
- if ($ny < $min_y) {
- $nx = intval($nx * $min_y/$ny);
- $ny = $min_y;
- }
-
- $comp = 90;
- do {
- $img2 = imagecreatetruecolor($nx, $ny);
- imagecopyresampled($img2, $img, 0, 0, 0, 0, $nx, $ny, $this->x, $this->y);
- imagejpeg($img2, $this->filename, $comp);
- $comp --;
- clearstatcache();
- } while (filesize($this->filename) > $maxsize && $comp > 0);
- $this->type = 'image/jpeg';
- $this->x = $nx;
- $this->y = $ny;
- }
- return true;
- }
-
- public function getContents()
- {
- if ($this->exists()) {
- return file_get_contents($this->filename);
- }
- return null;
- }
-}
-// vim:set et sw=4 sts=4 sws=4 foldmethod=marker enc=utf-8:
-?>
+++ /dev/null
-<?php
-/***************************************************************************
- * Copyright (C) 2003-2008 Polytechnique.org *
- * http://opensource.polytechnique.org/ *
- * *
- * This program is free software; you can redistribute it and/or modify *
- * it under the terms of the GNU General Public License as published by *
- * the Free Software Foundation; either version 2 of the License, or *
- * (at your option) any later version. *
- * *
- * This program is distributed in the hope that it will be useful, *
- * but WITHOUT ANY WARRANTY; without even the implied warranty of *
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
- * GNU General Public License for more details. *
- * *
- * You should have received a copy of the GNU General Public License *
- * along with this program; if not, write to the Free Software *
- * Foundation, Inc., *
- * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA *
- **************************************************************************/
-
-/** A Wizard Page is a page of a wizard. It is a self-contained step which
- * handles both the creation and initialisation of the step (by using the
- * Wizard global state, if needed) and the processing of the action the
- * user made on it.
- */
-interface PlWizardPage
-{
- /** Build a new instance of the class
- * associated with the given wizard master.
- */
- public function __construct(PlWizard &$wiz);
-
- /** Return the name of the templace describing the page.
- */
- public function template();
-
- /** Prepare the page by assigning to it any useful value.
- */
- public function prepare(PlatalPage &$page, $id);
-
- /** Process information resulting of the application of the page.
- * This function must return a clue indicating the next page to show.
- * This clue can be either a page id, a page number or a navigation
- * id (PlWizard::FIRST_PAGE, PlWizard::NEXT_PAGE, PlWizard::CURRENT_PAGE
- * PlWizard::PREVIOUS_PAGE, PlWizard::LAST_PAGE).
- */
- public function process();
-}
-
-/** A PlWizard is a set of pages through which the user can navigate,
- * his action on a page determining which the next one will be.
- *
- * A Wizard can either a stateless wizard (which is only a set of
- * independent pages through which the user can easily navigate) or
- * stateful (a suite of steps where each step gives clue for the next
- * one).
- */
-class PlWizard
-{
- const FIRST_PAGE = 'bt_first';
- const NEXT_PAGE = 'bt_next';
- const CURRENT_PAGE = 'bt_current';
- const PREVIOUS_PAGE = 'bt_previous';
- const LAST_PAGE = 'bt_last';
-
- protected $name;
- protected $layout;
- protected $stateless;
- protected $ajax;
-
- protected $pages;
- protected $titles;
- protected $lookup;
- protected $inv_lookup;
-
- public function __construct($name, $layout, $stateless = false, $ajax = true)
- {
- $this->name = 'wiz_' . $name;
- $this->layout = $layout;
- $this->stateless = $stateless;
- $this->pages = array();
- $this->lookup = array();
- $this->titles = array();
- $this->ajax = $ajax;
- if (!isset($_SESSION[$this->name])) {
- $_SESSION[$this->name] = array();
- $_SESSION[$this->name . '_page'] = null;
- $_SESSION[$this->name . '_stack'] = array();
- }
- }
-
- public function addPage($class, $title, $id = null)
- {
- if ($id == null) {
- $id = count($this->pages);
- }
- $this->lookup[$id] = count($this->pages);
- $this->inv_lookup[] = $id;
- $this->pages[] = $class;
- $this->titles[] = $title;
- }
-
- public function set($varname, $value)
- {
- $_SESSION[$this->name][$varname] = $value;
- }
-
- public function get($varname, $default = null)
- {
- return isset($_SESSION[$this->name][$varname]) ?
- $_SESSION[$this->name][$varname] : $default;
- }
-
- public function v($varname, $default = "")
- {
- return $this->get($varname, $default);
- }
-
- public function i($varname, $default = 0)
- {
- return (int)$this->get($varname, $default);
- }
-
- public function clear($varname = null)
- {
- if (is_null($varname)) {
- $_SESSION[$this->name] = array();
- } else {
- unset($_SESSION[$this->name][$varname]);
- }
- $_SESSION[$this->name . '_page'] = null;
- }
-
- private function getPage($id)
- {
- $page = $this->pages[$id];
- return new $page($this);
- }
-
- public function apply(PlatalPage &$smarty, $baseurl, $pgid = null, $mode = 'normal')
- {
- if ($this->stateless && (isset($this->lookup[$pgid]) || isset($this->pages[$pgid]))) {
- $curpage = is_numeric($pgid) ? $pgid : $this->lookup[$pgid];
- } else if ($this->stateless && is_null($pgid)) {
- $curpage = 0;
- } else {
- $curpage = $_SESSION[$this->name . '_page'];
- }
- $oldpage = $curpage;
-
- // Process the previous page
- if (Post::has('valid_page')) {
- S::assert_xsrf_token();
-
- $page = $this->getPage(Post::i('valid_page'));
- $curpage = Post::i('valid_page');
- $next = $page->process();
- $last = $curpage;
- switch ($next) {
- case PlWizard::FIRST_PAGE:
- $curpage = 0;
- break;
- case PlWizard::PREVIOUS_PAGE:
- if (!$this->stateless && count($_SESSION[$this->name . '_stack'])) {
- $curpage = array_pop($_SESSION[$this->name . '_stack']);
- } elseif ($curpage && $this->stateless) {
- $curpage--;
- } else {
- $curpage = 0;
- }
- break;
- case PlWizard::NEXT_PAGE:
- if ($curpage < count($this->pages) - 1) {
- $curpage++;
- }
- break;
- case PlWizard::LAST_PAGE:
- $curpage = count($this->pages) - 1;
- break;
- case PlWizard::CURRENT_PAGE: break; // don't change the page
- default:
- $curpage = is_numeric($next) ? $next : $this->lookup[$next];
- break;
- }
- if (!$this->stateless) {
- array_push($_SESSION[$this->name . '_stack'], $last);
- }
- }
- if (is_null($curpage)) {
- $curpage = 0;
- }
-
- // Prepare the page
- $_SESSION[$this->name . '_page'] = $curpage;
- if ($curpage != $oldpage) {
- pl_redirect($baseurl . '/' . $this->inv_lookup[$curpage]);
- } else if (!isset($page)) {
- $page = $this->getPage($curpage);
- }
- if ($mode == 'ajax') {
- header('Content-Type: text/html; charset=utf-8');
- $smarty->changeTpl($page->template(), NO_SKIN);
- } else {
- $smarty->changeTpl($this->layout);
- }
- $smarty->assign('pages', $this->titles);
- $smarty->assign('current', $curpage);
- $smarty->assign('lookup', $this->inv_lookup);
- $smarty->assign('stateless', $this->stateless);
- $smarty->assign('wiz_baseurl', $baseurl);
- $smarty->assign('wiz_ajax', $this->ajax);
- $smarty->assign('tab_width', (int)(99 / count($this->pages)));
- $smarty->assign('wiz_page', $page->template());
- $smarty->assign('xorg_no_errors', true);
- $page->prepare($smarty, isset($this->inv_lookup[$curpage]) ? $this->inv_lookup[$curpage] : $curpage);
- }
-}
-
-// vim:set et sw=4 sts=4 sws=4 foldmethod=marker enc=utf-8:
-?>
+++ /dev/null
-<?php
-/***************************************************************************
- * Copyright (C) 2003-2008 Polytechnique.org *
- * http://opensource.polytechnique.org/ *
- * *
- * This program is free software; you can redistribute it and/or modify *
- * it under the terms of the GNU General Public License as published by *
- * the Free Software Foundation; either version 2 of the License, or *
- * (at your option) any later version. *
- * *
- * This program is distributed in the hope that it will be useful, *
- * but WITHOUT ANY WARRANTY; without even the implied warranty of *
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
- * GNU General Public License for more details. *
- * *
- * You should have received a copy of the GNU General Public License *
- * along with this program; if not, write to the Free Software *
- * Foundation, Inc., *
- * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA *
- ***************************************************************************/
-
-class S extends Session {
-}
-
-// vim:set et sw=4 sts=4 sws=4 foldmethod=marker enc=utf-8:
-?>
+++ /dev/null
-<?php
-/***************************************************************************
- * Copyright (C) 2003-2008 Polytechnique.org *
- * http://opensource.polytechnique.org/ *
- * *
- * This program is free software; you can redistribute it and/or modify *
- * it under the terms of the GNU General Public License as published by *
- * the Free Software Foundation; either version 2 of the License, or *
- * (at your option) any later version. *
- * *
- * This program is distributed in the hope that it will be useful, *
- * but WITHOUT ANY WARRANTY; without even the implied warranty of *
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
- * GNU General Public License for more details. *
- * *
- * You should have received a copy of the GNU General Public License *
- * along with this program; if not, write to the Free Software *
- * Foundation, Inc., *
- * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA *
- ***************************************************************************/
-
-class Session
-{
- public static function init()
- {
- @session_start();
- if (empty($_SESSION['challenge'])) {
- $_SESSION['challenge'] = sha1(uniqid(rand(), true));
- }
- if (empty($_SESSION['xsrf_token'])) {
- require_once 'xorg.misc.inc.php';
- $_SESSION['xsrf_token'] = rand_url_id();
- }
- if (!isset($_SESSION['perms']) || !($_SESSION['perms'] instanceof FlagSet)) {
- $_SESSION['perms'] = new FlagSet();
- }
- }
-
- public static function destroy()
- {
- @session_destroy();
- unset($_SESSION);
- }
-
- public static function has($key)
- {
- return isset($_SESSION[$key]);
- }
-
- public static function kill($key)
- {
- unset($_SESSION[$key]);
- }
-
- public static function v($key, $default = null)
- {
- return isset($_SESSION[$key]) ? $_SESSION[$key] : $default;
- }
-
- public static function s($key, $default = '')
- {
- return (string)Session::v($key, $default);
- }
-
- public static function i($key, $default = 0)
- {
- $i = Session::v($key, $default);
- return is_numeric($i) ? intval($i) : $default;
- }
-
- public static function l(array $keys)
- {
- return array_map(array('Session', 'v'), $keys);
- }
-
- public static function has_perms()
- {
- return Session::logged() && Session::v('perms')->hasFlag(PERMS_ADMIN);
- }
-
- public static function logged()
- {
- return Session::v('auth', AUTH_PUBLIC) >= AUTH_COOKIE;
- }
-
- public static function identified()
- {
- return Session::v('auth', AUTH_PUBLIC) >= AUTH_MDP;
- }
-
- // Anti-XSRF protections.
- public static function has_xsrf_token()
- {
- return Session::has('xsrf_token') && Session::v('xsrf_token') == Env::v('token');
- }
-
- public static function assert_xsrf_token()
- {
- if (!Session::has_xsrf_token()) {
- global $page;
- if ($page instanceof PlatalPage) {
- $page->kill("L'opération n'a pas pu aboutir, merci de réessayer.");
- }
- }
- }
-
- public static function rssActivated()
- {
- return Session::has('core_rss_hash') && Session::v('core_rss_hash');
- }
-}
-
-// {{{ function check_perms()
-
-/** verifie si un utilisateur a les droits pour voir une page
- ** si ce n'est pas le cas, on affiche une erreur
- * @return void
- */
-function check_perms()
-{
- global $page;
- if (!S::has_perms()) {
- if ($_SESSION['log']) {
- $_SESSION['log']->log("noperms",$_SERVER['PHP_SELF']);
- }
- $page->kill("Tu n'as pas les permissions nécessaires pour accéder à cette page.");
- }
-}
-
-// }}}
-
-// vim:set et sw=4 sts=4 sws=4 foldmethod=marker enc=utf-8:
-?>
+++ /dev/null
-<?php
-/***************************************************************************
- * Copyright (C) 2003-2008 Polytechnique.org *
- * http://opensource.polytechnique.org/ *
- * *
- * This program is free software; you can redistribute it and/or modify *
- * it under the terms of the GNU General Public License as published by *
- * the Free Software Foundation; either version 2 of the License, or *
- * (at your option) any later version. *
- * *
- * This program is distributed in the hope that it will be useful, *
- * but WITHOUT ANY WARRANTY; without even the implied warranty of *
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
- * GNU General Public License for more details. *
- * *
- * You should have received a copy of the GNU General Public License *
- * along with this program; if not, write to the Free Software *
- * Foundation, Inc., *
- * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA *
- ***************************************************************************/
-
-class VarStream
-{
- // Stream handler to read from global variables
- private $varname;
- private $position;
-
- public function stream_open($path, $mode, $options, &$opened_path)
- {
- $url = parse_url($path);
- $this->varname = $url['host'];
- $this->position = 0;
- if (!isset($GLOBALS[$this->varname]))
- {
- trigger_error('Global variable '.$this->varname.' does not exist', E_USER_WARNING);
- return false;
- }
- return true;
- }
-
- public function stream_close()
- {
- }
-
- public function stream_read($count)
- {
- $ret = substr($GLOBALS[$this->varname], $this->position, $count);
- $this->position += strlen($ret);
- return $ret;
- }
-
- public function stream_write($data)
- {
- $len = strlen($data);
- if ($len > $this->position + strlen($GLOBALS[$this->varname])) {
- str_pad($GLOBALS[$this->varname], $len);
- }
-
- $GLOBALS[$this->varname] = substr_replace($GLOBALS[$this->varname], $data, $this->position, $len);
- $this->position += $len;
- }
-
- public function stream_eof()
- {
- return $this->position >= strlen($GLOBALS[$this->varname]);
- }
-
- public function stream_tell()
- {
- return $this->position;
- }
-
- public function stream_seek($offs, $whence)
- {
- switch ($whence) {
- case SEEK_SET:
- $final = $offs;
- break;
-
- case SEEK_CUR:
- $final += $offs;
- break;
-
- case SEEK_END:
- $final = strlen($GLOBALS[$this->varname]) + $offs;
- break;
- }
-
- if ($final < 0) {
- return -1;
- }
- $this->position = $final;
- return 0;
- }
-
- public function stream_flush()
- {
- }
-
- static public function init()
- {
- stream_wrapper_register('var','VarStream');
- }
-}
-
-// vim:set et sw=4 sts=4 sws=4 foldmethod=marker enc=utf-8:
-?>
+++ /dev/null
-<?php
-/***************************************************************************
- * Copyright (C) 2003-2008 Polytechnique.org *
- * http://opensource.polytechnique.org/ *
- * *
- * This program is free software; you can redistribute it and/or modify *
- * it under the terms of the GNU General Public License as published by *
- * the Free Software Foundation; either version 2 of the License, or *
- * (at your option) any later version. *
- * *
- * This program is distributed in the hope that it will be useful, *
- * but WITHOUT ANY WARRANTY; without even the implied warranty of *
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
- * GNU General Public License for more details. *
- * *
- * You should have received a copy of the GNU General Public License *
- * along with this program; if not, write to the Free Software *
- * Foundation, Inc., *
- * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA *
- **************************************************************************/
-
-class XDB
-{
- private static $mysqli = null;
-
- public static function connect()
- {
- global $globals;
- XDB::$mysqli = new mysqli($globals->dbhost, $globals->dbuser, $globals->dbpwd, $globals->dbdb);
- if ($globals->debug & DEBUG_BT) {
- $bt = new PlBacktrace('MySQL');
- if (mysqli_connect_errno()) {
- $bt->newEvent("MySQLI connection", 0, mysqli_connect_error());
- return false;
- }
- }
- XDB::$mysqli->autocommit(true);
- XDB::$mysqli->set_charset($globals->dbcharset);
- return true;
- }
-
- public static function _prepare($args)
- {
- $query = array_map(Array('XDB', 'escape'), $args);
- $query[0] = str_replace('{?}', '%s', str_replace('%', '%%', $args[0]));
- return call_user_func_array('sprintf', $query);
- }
-
- public static function _reformatQuery($query)
- {
- $query = preg_split("/\n\\s*/", trim($query));
- $length = 0;
- foreach ($query as $key=>$line) {
- $local = -2;
- if (preg_match('/^([A-Z]+(?:\s+(?:JOIN|BY|FROM|INTO))?)\s+(.*)/u', $line, $matches)
- && $matches[1] != 'AND' && $matches[1] != 'OR')
- {
- $local = strlen($matches[1]);
- $line = $matches[1] . ' ' . $matches[2];
- $length = max($length, $local);
- }
- $query[$key] = array($line, $local);
- }
- $res = '';
- foreach ($query as $array) {
- list($line, $local) = $array;
- $local = max(0, $length - $local);
- $res .= str_repeat(' ', $local) . $line . "\n";
- $length += 2 * (substr_count($line, '(') - substr_count($line, ')'));
- }
- return $res;
- }
-
- public static function _query($query)
- {
- global $globals;
-
- if (!XDB::$mysqli && !XDB::connect()) {
- return false;
- }
-
- if ($globals->debug & DEBUG_BT) {
- $explain = array();
- if (strpos($query, 'FOUND_ROWS()') === false) {
- $res = XDB::$mysqli->query("EXPLAIN $query");
- if ($res) {
- while ($row = $res->fetch_assoc()) {
- $explain[] = $row;
- }
- $res->free();
- }
- }
- PlBacktrace::$bt['MySQL']->start(XDB::_reformatQuery($query));
- }
-
- $res = XDB::$mysqli->query($query);
-
- if ($globals->debug & DEBUG_BT) {
- PlBacktrace::$bt['MySQL']->stop(@$res->num_rows ? $res->num_rows : XDB::$mysqli->affected_rows,
- XDB::$mysqli->error,
- $explain);
- }
- return $res;
- }
-
- public static function query()
- {
- return new XOrgDBResult(XDB::_prepare(func_get_args()));
- }
-
- public static function execute()
- {
- global $globals;
- $args = func_get_args();
- if ($globals->mode != 'rw' && !strpos($args[0], 'logger')) {
- return;
- }
- return XDB::_query(XDB::_prepare($args));
- }
-
- public static function iterator()
- {
- return new XOrgDBIterator(XDB::_prepare(func_get_args()));
- }
-
- public static function iterRow()
- {
- return new XOrgDBIterator(XDB::_prepare(func_get_args()), MYSQL_NUM);
- }
-
- public static function insertId()
- {
- return XDB::$mysqli->insert_id;
- }
-
- public static function errno()
- {
- return XDB::$mysqli->errno;
- }
-
- public static function error()
- {
- return XDB::$mysqli->error;
- }
-
- public static function affectedRows()
- {
- return XDB::$mysqli->affected_rows;
- }
-
- public static function escape($var)
- {
- switch (gettype($var)) {
- case 'boolean':
- return $var ? 1 : 0;
-
- case 'integer':
- case 'double':
- case 'float':
- return $var;
-
- case 'string':
- return "'".addslashes($var)."'";
-
- case 'NULL':
- return 'NULL';
-
- case 'object':
- if ($var instanceof FlagSet) {
- return "'" . addslashes($var->flags()) . "'";
- }
- case 'array':
- return "'".addslashes(serialize($var))."'";
-
- default:
- die(var_export($var, true).' is not a valid for a database entry');
- }
- }
-}
-
-class XOrgDBResult
-{
-
- private $_res;
-
- public function __construct($query)
- {
- $this->_res = XDB::_query($query);
- }
-
- public function free()
- {
- if ($this->_res) {
- $this->_res->free();
- }
- unset($this);
- }
-
- protected function _fetchRow()
- {
- return $this->_res ? $this->_res->fetch_row() : null;
- }
-
- protected function _fetchAssoc()
- {
- return $this->_res ? $this->_res->fetch_assoc() : null;
- }
-
- public function fetchAllRow()
- {
- $result = Array();
- if (!$this->_res) {
- return $result;
- }
- while ($result[] = $this->_res->fetch_row());
- array_pop($result);
- $this->free();
- return $result;
- }
-
- public function fetchAllAssoc()
- {
- $result = Array();
- if (!$this->_res) {
- return $result;
- }
- while ($result[] = $this->_res->fetch_assoc());
- array_pop($result);
- $this->free();
- return $result;
- }
-
- public function fetchOneAssoc()
- {
- $tmp = $this->_fetchAssoc();
- $this->free();
- return $tmp;
- }
-
- public function fetchOneRow()
- {
- $tmp = $this->_fetchRow();
- $this->free();
- return $tmp;
- }
-
- public function fetchOneCell()
- {
- $tmp = $this->_fetchRow();
- $this->free();
- return $tmp[0];
- }
-
- public function fetchColumn($key = 0)
- {
- $res = Array();
- if (is_numeric($key)) {
- while($tmp = $this->_fetchRow()) {
- $res[] = $tmp[$key];
- }
- } else {
- while($tmp = $this->_fetchAssoc()) {
- $res[] = $tmp[$key];
- }
- }
- $this->free();
- return $res;
- }
-
- public function fetchOneField()
- {
- return $this->_res ? $this->_res->fetch_field() : null;
- }
-
- public function fetchFields()
- {
- $res = array();
- while ($res[] = $this->fetchOneField());
- return $res;
- }
-
- public function numRows()
- {
- return $this->_res ? $this->_res->num_rows : 0;
- }
-
- public function fieldCount()
- {
- return $this->_res ? $this->_res->field_count : 0;
- }
-}
-
-require_once dirname(__FILE__) . '/pliterator.php';
-
-class XOrgDBIterator extends XOrgDBResult implements PlIterator
-{
- private $_result;
- private $_pos;
- private $_total;
- private $_fpos;
- private $_fields;
- private $_mode = MYSQL_ASSOC;
-
- public function __construct($query, $mode = MYSQL_ASSOC)
- {
- parent::__construct($query);
- $this->_pos = 0;
- $this->_total = $this->numRows();
- $this->_fpost = 0;
- $this->_fields = $this->fieldCount();
- $this->_mode = $mode;
- }
-
- public function next()
- {
- $this->_pos ++;
- if ($this->_pos > $this->_total) {
- $this->free();
- unset($this);
- return null;
- }
- return $this->_mode != MYSQL_ASSOC ? $this->_fetchRow() : $this->_fetchAssoc();
- }
-
- public function first()
- {
- return $this->_pos == 1;
- }
-
- public function last()
- {
- return $this->_pos == $this->_total;
- }
-
- public function total()
- {
- return $this->_total;
- }
-
- public function nextField()
- {
- $this->_fpos++;
- if ($this->_fpos > $this->_fields) {
- return null;
- }
- return $this->fetchOneField();
- }
-
- public function firstField()
- {
- return $this->_fpos == 1;
- }
-
- public function lastField()
- {
- return $this->_fpos == $this->_fields;
- }
-
- public function totalFields()
- {
- return $this->_fields;
- }
-}
-
-// vim:set et sw=4 sts=4 sws=4 foldmethod=marker enc=utf-8:
-?>
+++ /dev/null
-<?php
-/***************************************************************************
- * Copyright (C) 2003-2008 Polytechnique.org *
- * http://opensource.polytechnique.org/ *
- * *
- * This program is free software; you can redistribute it and/or modify *
- * it under the terms of the GNU General Public License as published by *
- * the Free Software Foundation; either version 2 of the License, or *
- * (at your option) any later version. *
- * *
- * This program is distributed in the hope that it will be useful, *
- * but WITHOUT ANY WARRANTY; without even the implied warranty of *
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
- * GNU General Public License for more details. *
- * *
- * You should have received a copy of the GNU General Public License *
- * along with this program; if not, write to the Free Software *
- * Foundation, Inc., *
- * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA *
- ***************************************************************************/
-
-/* taken from : http://fr2.php.net/xml-rpc
- * Author mboeren@php.net
- *
- * Usage:
- * $client = new xmlrpc_client("http://localhost:7080");
- * print $client->echo('x')."\n";
- * print $client->add(1, 3)."\n";
- */
-
-class XmlrpcClient
-{
- private $url;
- private $urlparts;
- public $bt = null;
-
- public function __construct($url)
- {
- $this->url = $url;
- $this->urlparts = parse_url($this->url);
-
- if (empty($this->urlparts['port'])) {
- $this->urlparts['port'] = 80;
- }
-
- if (empty($this->urlparts['path'])) {
- $this->urlparts['path'] = '/';
- }
- }
-
- private function http_post($request)
- {
- $host = $path = $port = $user = $pass = null;
- extract($this->urlparts);
-
- if ($scheme == 'https') {
- $host = 'ssl://'.$host;
- }
-
- $query_fd = fsockopen($host, $port, $errno, $errstr, 10);
- if (!$query_fd)
- return null;
-
- $auth = '';
- if ($user) {
- $auth = 'Authorization: Basic ' . base64_encode("$user:$pass") . "\r\n";
- }
-
- $content_len = strlen($request);
- $http_request =
- "POST $path HTTP/1.0\r\n" .
- $auth .
- "Content-Type: text/xml\r\n" .
- "Content-Length: $content_len\r\n" .
- "Connection: Close\r\n" .
- "Host: $host:$port\r\n" .
- "\r\n" .
- $request;
-
- fputs($query_fd, $http_request, strlen($http_request));
-
- $buf = '';
- while (!feof($query_fd)) {
- $buf .= fread($query_fd, 8192);
- }
-
- fclose($query_fd);
- return $buf;
- }
-
- private function find_and_decode_xml($buf)
- {
- $pos = strpos($buf, '<?xml');
- if ($pos !== false) {
- return xmlrpc_decode(substr($buf, $pos));
- }
- trigger_error("Cannot parse XML\n".$buf);
- }
-
- public function __call($method, $args)
- {
- $query = xmlrpc_encode_request($method, $args);
- if ($this->bt) {
- $this->bt->start($method . "\n" . var_export($args, true));
- }
- $answer = $this->http_post($query, $this->urlparts);
- if ($this->bt) {
- $this->bt->stop();
- }
- $result = $this->find_and_decode_xml($answer);
- if ($this->bt) {
- if (is_array($result) && isset($result['faultCode'])) {
- $this->bt->update(0, $result['faultString']);
- } else {
- $this->bt->update(count($result));
- }
- }
-
- if (is_array($result) && isset($result['faultCode'])) {
- trigger_error("Error in xmlrpc call $function\n".
- " code : {$result['faultCode']}\n".
- " message: {$result['faultString']}\n");
- return null;
- }
- return $result;
- }
-}
-
-// vim:set et sw=4 sts=4 sws=4 enc=utf-8:
-?>
return $ans;
}
- public function force_login(&$page)
+ public function force_login(PlPage &$page)
{
http_redirect(S::v('loginX'));
}
* 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA *
***************************************************************************/
-class XnetPage extends PlatalPage
+class XnetPage extends PlPage
{
public $nomenu = false;
// {{{ function XnetPage()
- public function __construct($tpl, $type=SKINNED)
+ public function __construct()
{
- parent::__construct($tpl, $type);
+ parent::__construct();
$this->register_function('list_all_my_groups', 'list_all_my_groups');
$this->register_modifier('cat_pp', 'cat_pp');
$this->assign('it_is_xnet', true);
- if (!S::logged() && Get::has('auth')) {
- XnetSession::doAuthX();
+ global $globals;
+ $this->assign('is_logged', S::logged());
+ if ($globals->asso('id')) {
+ $this->assign('asso', $globals->asso());
+ $this->setType($globals->asso('cat'));
+ $this->assign('is_admin', may_update());
+ $this->assign('is_member', is_member());
}
+ $this->addJsLink('xorg.js');
}
// }}}
}
// }}}
- // {{{ function changeTpl()
-
- public function changeTpl($tpl, $type = SKINNED)
- {
- global $globals;
- parent::changeTpl($tpl, $type);
- $this->assign('is_logged', S::logged());
- if ($globals->asso('id')) {
- $this->assign('asso', $globals->asso());
- $this->setType($globals->asso('cat'));
- $this->assign('is_admin', may_update());
- $this->assign('is_member', is_member());
- }
- }
-
- // }}}
// {{{ function setType
public function setType($type)
$menu = array();
$sub = array();
- $sub['liste des groupes'] = 'plan';
+ $sub['tous les groupes'] = 'plan';
$sub['documentation'] = 'Xnet';
$sub['signaler un bug'] = array('href' => 'send_bug/'.$_SERVER['REQUEST_URI'], 'class' => 'popup_840x600');
$menu["no_title"] = $sub;
* 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA *
***************************************************************************/
-class XnetSession
+class XnetSession extends XorgSession
{
- // {{{ function init
-
- public static function init()
+ public function __construct()
{
- global $globals;
+ parent::__construct();
+ }
- S::init();
+ public function startAvailableAuth()
+ {
+ if (!S::logged() && Get::has('auth')) {
+ if (!$this->start(AUTH_MDP)) {
+ return false;
+ }
+ }
+ global $globals;
if (!S::logged()) {
- // prevent connexion to be linked to deconnexion
+ // prevent connection to be linked to disconnection
if (($i = strpos($_SERVER['REQUEST_URI'], 'exit')) !== false)
$returl = "http://{$_SERVER['SERVER_NAME']}".substr($_SERVER['REQUEST_URI'], 0, $i);
else
$url .= "&challenge=" . S::v('challenge');
$url .= "&pass=" . md5(S::v('challenge') . $globals->xnet->secret);
$url .= "&url=".urlencode($returl);
- $_SESSION['loginX'] = $url;
+ S::set('loginX', $url);
}
if (S::logged() && $globals->asso()) {
if ($globals->asso('cat') == 'Promotions') {
$perms->addFlag('groupannu');
}
- $_SESSION['perms'] = $perms;
+ S::set('perms', $perms);
}
+ return true;
}
- // }}}
- // {{{ public static function destroy()
-
- public static function destroy() {
- S::destroy();
- XnetSession::init();
- }
-
- // }}}
- // {{{ public static function doAuth()
-
- /** Try to do an authentication.
- *
- * @param page the calling page (by reference)
- */
- public static function doAuth()
+ protected function doAuth($level)
{
- if (S::identified()) { // ok, c'est bon, on n'a rien à faire
- return true;
- }
-
- if (Get::has('auth')) {
- return XnetSession::doAuthX();
+ if (S::identified()) { // ok, c'est bon, on n'a rien à faire
+ return S::i('uid');
}
-
- return false;
- }
-
- // }}}
- // {{{ doAuthCookie
-
- public static function doAuthCookie() {
- return XnetSession::doAuth();
+ if (!Get::has('auth')) {
+ return null;
+ }
+ global $globals;
+ if (md5('1' . S::v('challenge') . $globals->xnet->secret . Get::i('uid') . '1') != Get::v('auth')) {
+ return null;
+ }
+ Get::kill('auth');
+ S::set('auth', AUTH_MDP);
+ return Get::i('uid');
}
- // }}}
- // {{{ doAuthX
-
- public static function doAuthX()
+ protected function startSessionAs($user, $level)
{
- global $globals, $page;
+ global $globals;
- if (md5('1'.S::v('challenge').$globals->xnet->secret.Get::i('uid').'1') != Get::v('auth')) {
- Get::kill('auth');
- if (!$page) {
- require_once 'xnet.inc.php';
- new_skinned_page('platal/index.tpl');
- }
- $page->kill("Erreur d'authentification avec polytechnique.org !");
+ if ($level == -1) {
+ S::set('auth', AUTH_MDP);
}
-
- $res = XDB::query("
- SELECT u.user_id AS uid, prenom, nom, perms, promo, password, FIND_IN_SET('femme', u.flags) AS femme,
- a.alias AS forlife, a2.alias AS bestalias, q.core_mail_fmt AS mail_fmt, q.core_rss_hash
- FROM auth_user_md5 AS u
- INNER JOIN auth_user_quick AS q USING(user_id)
- INNER JOIN aliases AS a ON (u.user_id = a.id AND a.type='a_vie')
- INNER JOIN aliases AS a2 ON (u.user_id = a2.id AND FIND_IN_SET('bestalias',a2.flags))
- WHERE u.user_id = {?} AND u.perms IN('admin','user')
- LIMIT 1", Get::i('uid'));
- $_SESSION = array_merge($_SESSION, $res->fetchOneAssoc());
- $_SESSION['auth'] = AUTH_MDP;
- require_once 'xorg/session.inc.php';
- $_SESSION['perms'] =& XorgSession::make_perms(S::v('perms'));
+ $res = XDB::query('SELECT u.user_id AS uid, prenom, nom, perms, promo, password, FIND_IN_SET(\'femme\', u.flags) AS femme,
+ a.alias AS forlife, a2.alias AS bestalias, q.core_mail_fmt AS mail_fmt, q.core_rss_hash
+ FROM auth_user_md5 AS u
+ INNER JOIN auth_user_quick AS q USING(user_id)
+ INNER JOIN aliases AS a ON (u.user_id = a.id AND a.type = \'a_vie\')
+ INNER JOIN aliases AS a2 ON (u.user_id = a2.id AND FIND_IN_SET(\'bestalias\', a2.flags))
+ WHERE u.user_id = {?} AND u.perms IN(\'admin\', \'user\')
+ LIMIT 1', $user);
+ $sess = $res->fetchOneAssoc();
+ $perms = $sess['perms'];
+ unset($sess['perms']);
+ $_SESSION = array_merge($_SESSION, $sess);
+ $this->makePerms($perms);
S::kill('challenge');
S::kill('loginX');
S::kill('may_update');
S::kill('is_member');
- Get::kill('auth');
Get::kill('uid');
- $path = Get::v('n');
- Get::kill('n');
Get::kill('PHPSESSID');
$args = array();
foreach($_GET as $key => $val) {
- $args[] = urlencode($key).'='.urlencode($val);
+ $args[] = urlencode($key). '=' .urlencode($val);
}
-
- http_redirect($globals->baseurl . '/' . $path, join('&', $args));
+ return true;
}
- // }}}
- // {{{ doSelfSuid
-
- public static function doSelfSuid()
+ public function doSelfSuid()
{
- if (!S::has('suid')) {
- $_SESSION['suid'] = $_SESSION;
+ if (!$this->startSUID(S::i('uid'))) {
+ return false;
}
- require_once 'xorg/session.inc.php';
- $_SESSION['perms'] =& XorgSession::make_perms('user');
+ $this->makePerms('user');
+ return true;
}
- // }}}
- // {{{ killSuid
-
- public static function killSuid()
+ public function stopSUID()
{
- if (!S::has('suid')) {
- return;
- }
$suid = S::v('suid');
+ if (!parent::stopSUID()) {
+ return false;
+ }
S::kill('suid');
S::kill('may_update');
S::kill('is_member');
- $_SESSION['perms'] = $suid['perms'];
+ S::set('perms', $suid['perms']);
+ return true;
}
-
- // }}}
}
-// }}}
// {{{ function may_update
/** Return administration rights for the current asso
* 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA *
***************************************************************************/
-class MMList extends XmlrpcClient
+class Xorg extends Platal
{
- public function __construct($uid, $pass, $fqdn = null)
+ public function force_login(PlPage &$page)
{
- global $globals;
-
- $dom = is_null($fqdn) ? $globals->mail->domain : $fqdn;
- $url = "http://$uid:$pass@{$globals->lists->rpchost}:{$globals->lists->rpcport}/$dom";
- parent::__construct($url);
- if ($globals->debug & DEBUG_BT) {
- $this->bt = new PlBacktrace('MMList');
+ header($_SERVER['SERVER_PROTOCOL'] . ' 403 Forbidden');
+ if (S::logged()) {
+ $page->changeTpl('core/password_prompt_logged.tpl');
+ $page->addJsLink('do_challenge_response_logged.js');
+ } else {
+ $page->changeTpl('core/password_prompt.tpl');
+ $page->addJsLink('do_challenge_response.js');
}
+ $page->assign_by_ref('platal', $this);
+ $page->run();
}
}
* 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA *
***************************************************************************/
-function smarty_function_xsrf_token_field($params, &$smarty) {
- if (S::has('xsrf_token')) {
- return '<div style="display: none"><input type="hidden" name="token" value="' . S::v('xsrf_token') . '" /></div>';
+class XorgPage extends PlPage
+{
+ public function __construct()
+ {
+ parent::__construct();
+
+ // Set the default page
+ $this->changeTpl('platal/index.tpl');
+ $this->addJsLink('xorg.js');
+ }
+
+ public function run()
+ {
+ global $globals, $platal;
+ if (isset($platal) && $platal->path == 'register') {
+ $skin = $globals->register_skin . ".tpl";
+ } else {
+ $skin = S::v('skin', $globals->skin . ".tpl");
+ }
+ $this->_run('skin/' . $skin);
}
- return '';
}
// vim:set et sw=4 sts=4 sws=4 foldmethod=marker enc=utf-8:
--- /dev/null
+<?php
+/***************************************************************************
+ * Copyright (C) 2003-2008 Polytechnique.org *
+ * http://opensource.polytechnique.org/ *
+ * *
+ * This program is free software; you can redistribute it and/or modify *
+ * it under the terms of the GNU General Public License as published by *
+ * the Free Software Foundation; either version 2 of the License, or *
+ * (at your option) any later version. *
+ * *
+ * This program is distributed in the hope that it will be useful, *
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of *
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
+ * GNU General Public License for more details. *
+ * *
+ * You should have received a copy of the GNU General Public License *
+ * along with this program; if not, write to the Free Software *
+ * Foundation, Inc., *
+ * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA *
+ ***************************************************************************/
+
+class XorgSession extends PlSession
+{
+ public function __construct()
+ {
+ parent::__construct();
+ }
+
+ public function startAvailableAuth()
+ {
+ if (!S::logged()) {
+ $cookie = $this->tryCookie();
+ if ($cookie == 0) {
+ return $this->start(AUTH_COOKIE);
+ } else if ($cookie == 1 || $cookie == -2) {
+ return false;
+ }
+ }
+ if ((check_ip('dangerous') && S::has('uid')) || check_account()) {
+ $_SESSION['log']->log("view_page", $_SERVER['REQUEST_URI']);
+ }
+ return true;
+ }
+
+ /** Check the cookie and set the associated user_id in the auth_by_cookie session variable.
+ */
+ private function tryCookie()
+ {
+ S::kill('auth_by_cookie');
+ if (Cookie::v('ORGaccess') == '' || !Cookie::has('ORGuid')) {
+ return -1;
+ }
+
+ $res = XDB::query('SELECT user_id, password
+ FROM auth_user_md5
+ WHERE user_id = {?} AND perms IN(\'admin\', \'user\')',
+ Cookie::i('ORGuid'));
+ if ($res->numRows() != 0) {
+ list($uid, $password) = $res->fetchOneRow();
+ require_once 'secure_hash.inc.php';
+ $expected_value = hash_encrypt($password);
+ if ($expected_value == Cookie::v('ORGaccess')) {
+ S::set('auth_by_cookie', $uid);
+ return 0;
+ } else {
+ return 1;
+ }
+ }
+ return -2;
+ }
+
+ private function checkPassword($uname, $login, $response, $login_type)
+ {
+ $res = XDB::query('SELECT u.user_id, u.password
+ FROM auth_user_md5 AS u
+ INNER JOIN aliases AS a ON (a.id = u.user_id AND type != \'homonyme\')
+ WHERE a.' . $login_type . ' = {?} AND u.perms IN(\'admin\', \'user\')',
+ $login);
+ if (list($uid, $password) = $res->fetchOneRow()) {
+ require_once 'secure_hash.inc.php';
+ $expected_response = hash_encrypt("$uname:$password:" . S::v('challenge'));
+ if ($response != $expected_response) {
+ $new_password = hash_xor(Env::v('xorpass'), $password);
+ $expected_response = hash_encrypt("$uname:$new_password:" . S::v('challenge'));
+ if ($response == $expected_response) {
+ XDB::execute('UPDATE auth_user_md5
+ SET password = {?}
+ WHERE user_id = {?}',
+ $new_password, $uid);
+ }
+ }
+ if ($response != $expected_response) {
+ S::logger($uid)->log('auth_fail', 'bad password');
+ return null;
+ }
+ return $uid;
+ }
+ return null;
+ }
+
+
+ /** Check auth.
+ */
+ protected function doAuth($level)
+ {
+ global $globals;
+
+ /* Cookie authentication
+ */
+ if ($level == AUTH_COOKIE && !S::has('auth_by_cookie')) {
+ $this->tryCookie();
+ }
+ if ($level == AUTH_COOKIE && S::has('auth_by_cookie')) {
+ if (!S::logged()) {
+ S::set('auth', AUTH_COOKIE);
+ }
+ return S::i('auth_by_cookie');
+ }
+
+
+ /* We want to do auth... we must have infos from a form.
+ */
+ if (!Post::has('username') || !Post::has('response') || !S::has('challenge')) {
+ return null;
+ }
+
+ /** We come from an authentication form.
+ */
+ if (S::has('suid')) {
+ $suid = S::v('suid');
+ $login = $uname = $suid['forlife'];
+ $redirect = false;
+ } else {
+ $uname = Env::v('username');
+
+ if (Env::v('domain') == "alias") {
+ $res = XDB::query('SELECT redirect
+ FROM virtual
+ INNER JOIN virtual_redirect USING(vid)
+ WHERE alias LIKE {?}',
+ $uname . '@' . $globals->mail->alias_dom);
+ $redirect = $res->fetchOneCell();
+ if ($redirect) {
+ $login = substr($redirect, 0, strpos($redirect, '@'));
+ } else {
+ $login = '';
+ }
+ } else {
+ $login = $uname;
+ $redirect = false;
+ }
+ }
+
+ $uid = $this->checkPassword($uname, $login, Post::v('response'), (!$redirect && preg_match('/^\d*$/', $uname)) ? 'id' : 'alias');
+ if (!is_null($uid)) {
+ S::set('auth', AUTH_MDP);
+ if (Post::has('domain')) {
+ if (($domain = Post::v('domain', 'login')) == 'alias') {
+ setcookie('ORGdomain', "alias", (time() + 25920000), '/', '', 0);
+ } else {
+ setcookie('ORGdomain', '', (time() - 3600), '/', '', 0);
+ }
+ // pour que la modification soit effective dans le reste de la page
+ $_COOKIE['ORGdomain'] = $domain;
+ }
+ S::kill('challenge');
+ S::logger($uid)->log('auth_ok');
+ }
+ return $uid;
+ }
+
+ protected function startSessionAs($uid, $level)
+ {
+ if ((!is_null(S::v('user')) && S::i('user') != $uid) || (S::has('uid') && S::i('uid') != $uid)) {
+ return false;
+ } else if (S::has('uid')) {
+ return true;
+ }
+ if ($level == -1) {
+ S::set('auth', AUTH_COOKIE);
+ }
+ unset($_SESSION['log']);
+
+ // Retrieves main user properties.
+ $res = XDB::query('SELECT u.user_id AS uid, prenom, prenom_ini, nom, nom_ini, nom_usage, perms, promo, promo_sortie,
+ matricule, password, FIND_IN_SET(\'femme\', u.flags) AS femme,
+ a.alias AS forlife, a2.alias AS bestalias,
+ q.core_mail_fmt AS mail_fmt, UNIX_TIMESTAMP(q.banana_last) AS banana_last, q.watch_last, q.core_rss_hash,
+ FIND_IN_SET(\'watch\', u.flags) AS watch_account, q.last_version, g.g_account_name IS NOT NULL AS googleapps
+ FROM auth_user_md5 AS u
+ INNER JOIN auth_user_quick AS q USING(user_id)
+ INNER JOIN aliases AS a ON (u.user_id = a.id AND a.type = \'a_vie\')
+ INNER JOIN aliases AS a2 ON (u.user_id = a2.id AND FIND_IN_SET(\'bestalias\', a2.flags))
+ LEFT JOIN gapps_accounts AS g ON (u.user_id = g.l_userid AND g.g_status = \'active\')
+ WHERE u.user_id = {?} AND u.perms IN(\'admin\', \'user\')', $uid);
+ $sess = $res->fetchOneAssoc();
+ $perms = $sess['perms'];
+ unset($sess['perms']);
+
+ // Retrieves account usage information (last login, last host).
+ $res = XDB::query('SELECT UNIX_TIMESTAMP(s.start) AS lastlogin, s.host
+ FROM logger.sessions AS s
+ WHERE s.uid = {?} AND s.suid = 0
+ ORDER BY s.start DESC
+ LIMIT 1', $uid);
+ if ($res->numRows()) {
+ $sess = array_merge($sess, $res->fetchOneAssoc());
+ }
+
+ // Loads the data into the real session.
+ $_SESSION = array_merge($_SESSION, $sess);
+
+ // Starts the session's logger, and sets up the permanent cookie.
+ if (S::has('suid')) {
+ $suid = S::v('suid');
+ $logger = S::logger($uid);
+ $logger->log("suid_start", S::v('forlife') . " by " . $suid['uid']);
+ } else {
+ $logger = S::logger($uid);
+ setcookie('ORGuid', $uid, (time() + 25920000), '/', '', 0);
+
+ if (S::i('auth_by_cookie') == $uid || Post::v('remember', 'false') == 'true') {
+ $cookie = hash_encrypt($sess['password']);
+ setcookie('ORGaccess', $cookie, (time() + 25920000), '/', '', 0);
+ if ($logger && S::i('auth_by_cookie') != $uid) {
+ $logger->log("cookie_on");
+ }
+ } else {
+ setcookie('ORGaccess', '', time() - 3600, '/', '', 0);
+ if ($logger) {
+ $logger->log("cookie_off");
+ }
+ }
+ }
+
+ // Finalizes the session setup.
+ $this->makePerms($perms);
+ $this->securityChecks();
+ $this->setSkin();
+ $this->updateNbNotifs();
+ check_redirect();
+
+ // We should not have to use this private data anymore
+ S::kill('auth_by_cookie');
+ return true;
+ }
+
+ private function securityChecks()
+ {
+ $mail_subject = array();
+ if (check_account()) {
+ $mail_subject[] = 'Connexion d\'un utilisateur surveillé';
+ }
+ if (check_ip('unsafe')) {
+ $mail_subject[] = 'Une IP surveillee a tente de se connecter';
+ if (check_ip('ban')) {
+ send_warning_mail(implode(' - ', $mail_subject));
+ $this->destroy();
+ Platal::page()->kill('Une erreur est survenue lors de la procédure d\'authentification. '
+ . 'Merci de contacter au plus vite '
+ . '<a href="mailto:support@polytechnique.org">support@polytechnique.org</a>');
+ return false;
+ }
+ }
+ if (count($mail_subject)) {
+ send_warning_mail(implode(' - ', $mail_subject));
+ }
+ }
+
+ public function tokenAuth($login, $token)
+ {
+ // FIXME: we broke the session here because some RSS feeds (mainly wiki feeds) require
+ // a valid nome and checks the permissions. When the PlUser object will be ready, we'll
+ // be able to return a simple 'PlUser' object here without trying to alterate the
+ // session.
+ $res = XDB::query('SELECT u.user_id AS uid, u.perms, u.nom, u.nom_usage, u.prenom, u.promo, FIND_IN_SET(\'femme\', u.flags) AS sexe
+ FROM aliases AS a
+ INNER JOIN auth_user_md5 AS u ON (a.id = u.user_id AND u.perms IN ("admin", "user"))
+ INNER JOIN auth_user_quick AS q ON (a.id = q.user_id AND q.core_rss_hash = {?})
+ WHERE a.alias = {?} AND a.type != "homonyme"', $token, $login);
+ if ($res->numRows() == 1) {
+ $sess = $res->fetchOneAssoc();
+ if (!S::has('uid')) {
+ $_SESSION = $sess;
+ $this->makePerms($sess['perms']);
+ return S::i('uid');
+ } else if (S::i('uid') == $sess['uid']) {
+ return S::i('uid');
+ } else {
+ Platal::page()->kill('Invalid state. To be fixed when hruid is ready');
+ }
+ }
+ return null;
+ }
+
+ public function makePerms($perm)
+ {
+ $flags = new PlFlagSet();
+ if ($perm == 'disabled' || $perm == 'ext') {
+ S::set('perms', $flags);
+ return;
+ }
+ $flags->addFlag(PERMS_USER);
+ if ($perm == 'admin') {
+ $flags->addFlag(PERMS_ADMIN);
+ }
+ S::set('perms', $flags);
+ }
+
+ public function setSkin()
+ {
+ global $globals;
+ if (S::logged() && (!S::has('skin') || S::has('suid'))) {
+ $uid = S::v('uid');
+ $res = XDB::query("SELECT skin_tpl
+ FROM auth_user_quick AS a
+ INNER JOIN skins AS s ON a.skin = s.id
+ WHERE user_id = {?} AND skin_tpl != ''", $uid);
+ S::set('skin', $res->fetchOneCell());
+ }
+ }
+
+ public function loggedLevel()
+ {
+ return AUTH_COOKIE;
+ }
+
+ public function sureLevel()
+ {
+ return AUTH_MDP;
+ }
+
+
+ public function updateNbNotifs()
+ {
+ require_once 'notifs.inc.php';
+ $n = select_notifs(false, S::i('uid'), S::v('watch_last'), false);
+ S::set('notifs', $n->numRows());
+ }
+}
+
+// vim:set et sw=4 sts=4 sws=4 foldmethod=marker enc=utf-8:
+?>
[Lists]
rpchost = "localhost"
-rpcport = 4949
+rpcport = "4949"
spool = "/var/lib/mailman/archives/private"
vhost_sep = "_"
--- /dev/null
+Subproject commit 5177a1b50e47e7d62a66aba9565580af3abf15dd
div.contact div.identity {
float: left;
- width: 89%;
+ width: 85%;
}
div.contact div.nom {
div.contact div.bits {
text-align: right;
float: right;
- width: 10%;
+ width: 14%;
}
div.contact div.long {
}
} else if (ajax.xml_client.status == 403) {
window.location.reload();
+ } else if (ajax.xml_client.status >= 500) {
+ alert("Une erreur s'est produite lors du traitement de la requête");
}
}
};
* 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA *
***************************************************************************/
-require_once dirname(__FILE__).'/../include/xorg.inc.php';
+require_once 'xorg.inc.php';
preg_match('!^/(moderate|admin|members|archives)/(.*)_([^_]*)(/.*)?$!', $_SERVER['REQUEST_URI'], $matches);
* 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA *
***************************************************************************/
-require_once dirname(__FILE__).'/../include/xorg.inc.php';
+require_once 'xorg.inc.php';
+
+new Platal('core');
global $globals;
list($username, $path) = preg_split('/\//', $_SERVER["REQUEST_URI"], 2, PREG_SPLIT_NO_EMPTY);
<hr>
<address>Apache Server at www.carva.org Port 80</address>
</body>
+</html>
+<?php
// vim:set et sw=4 sts=4 sws=4 foldmethod=marker enc=utf-8:
?>
***************************************************************************/
$GLOBALS['IS_XNET_SITE'] = true;
-global $platal, $globals, $page;
require_once dirname(__FILE__).'/../include/xnet.inc.php';
+$platal = new Xnet('xnet', 'xnetgrp', 'xnetlists', 'xnetevents', 'geoloc', 'payment', 'bandeau');
if (!($path = Env::v('n')) || substr($path, 0, 4) != 'Xnet') {
- $platal = new Xnet('xnet', 'xnetgrp', 'xnetlists', 'xnetevents', 'geoloc', 'payment', 'bandeau');
$platal->run();
-
exit;
}
/*** WIKI CODE ***/
-include 'wiki/engine.php';
+include pl_core_include('wiki.engine.inc.php');
// vim:set et sw=4 sts=4 sws=4 foldmethod=marker enc=utf-8:
?>
***************************************************************************/
require_once dirname(__FILE__).'/../include/xorg.inc.php';
-global $globals, $platal, $page;
-if (!($path = Env::v('n')) || ($path{0} < 'A' || $path{0} > 'Z')) {
+$platal = new Xorg('auth', 'carnet', 'email', 'events', 'forums',
+ 'geoloc', 'lists', 'marketing', 'payment', 'platal',
+ 'profile', 'register', 'search', 'stats', 'admin',
+ 'newsletter', 'axletter', 'bandeau', 'survey',
+ 'gadgets', 'googleapps');
- $platal = new Platal('auth', 'carnet', 'email', 'events', 'forums',
- 'geoloc', 'lists', 'marketing', 'payment', 'platal',
- 'profile', 'register', 'search', 'stats', 'admin',
- 'newsletter', 'axletter', 'bandeau', 'survey',
- 'gadgets', 'googleapps');
+if (!($path = Env::v('n')) || ($path{0} < 'A' || $path{0} > 'Z')) {
$platal->run();
-
exit;
}
/*** WIKI CODE ***/
-include 'wiki/engine.php';
+include pl_core_include('wiki.engine.inc.php');
// vim:set et sw=4 sts=4 sws=4 foldmethod=marker enc=utf-8:
?>
+++ /dev/null
-/globals.inc.php
* 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA *
***************************************************************************/
-global $page;
-
function applis_options($current=0) {
$html = '<option value="-1"></option>';
$res = XDB::iterator("select * from applis_def order by text");
$params['selected'] = 0;
return applis_options($params['selected']);
}
-$page->register_function('applis_options','_applis_options_smarty');
+Platal::page()->register_function('applis_options','_applis_options_smarty');
/** affiche un Array javascript contenant les types de chaque appli
}
return $html;
}
-$page->register_function('applis_type','applis_type');
+Platal::page()->register_function('applis_type','applis_type');
/** affiche tous les types possibles d'applis
*/
$arr_appli = $res->fetchOneAssoc();
return str_replace(")","",str_replace("set(","",$arr_appli["Type"]));
}
-$page->register_function('applis_type_all','applis_type_all');
+Platal::page()->register_function('applis_type_all','applis_type_all');
/** formatte une ecole d'appli pour l'affichage
*/
extract($params);
return applis_fmt($type, $text, $url);
}
-$page->register_function('applis_fmt','_applis_fmt');
+Platal::page()->register_function('applis_fmt','_applis_fmt');
// vim:set et sw=4 sts=4 sws=4 foldmethod=marker enc=utf-8:
?>
protected function action_updateProfile()
{
- global $page, $globals;
+ global $globals;
+ $page = Platal::page();
$colors = glob(dirname(__FILE__) . '/../../htdocs/images/banana/m2*.gif');
foreach ($colors as $key=>$path) {
function hook_makeJs($src)
{
- global $page;
- $page->addJsLink("$src.js");
+ Platal::page()->addJsLink("$src.js");
return ' ';
}
protected function prepare()
{
$tpl = parent::prepare();
- global $wiz, $page;
- $wiz = new PlWizard('Banana', 'core/plwizard.tpl', true, false);
+ global $wiz;
+ $wiz = new PlWizard('Banana', PlPage::getCoreTpl('plwizard.tpl'), true, false);
foreach ($this->pages as $name=>&$mpage) {
$wiz->addPage($this->handler, $mpage['text'], $name);
}
- $wiz->apply($page, $this->base, $this->page);
+ $wiz->apply(Platal::page(), $this->base, $this->page);
return $tpl;
}
}
return 'banana/index.tpl';
}
- public function prepare(PlatalPage &$page, $id)
+ public function prepare(PlPage &$page, $id)
{
}
public function trig($msg)
{
- global $page;
- if ($page) {
- $page->trigError($msg);
- }
+ Platal::page()->trigError($msg);
return true;
}
}
* 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA *
***************************************************************************/
-require_once 'platal.inc.php';
-
-function smarty_modifier_miniwiki($string, $format = 'no_title', $type = 'html')
+function __autoload($cls)
{
- if ($type == 'html') {
- return MiniWiki::wikiToHTML($string, $format == 'title');
- } else {
- return MiniWiki::wikiToText($string, false, 0, 80, $format == 'title');
+ if (!pl_autoload($cls)) {
+ $cls = strtolower($cls);
+ if (substr($cls, -3, 3) == 'req') {
+ @include 'validations.inc.php';
+ return;
+ } else if (substr($cls, 0, 6) == 'banana') {
+ require_once 'banana/banana.inc.php';
+ Banana::load(substr($cls, 6));
+ return;
+ }
+ @include "$cls.inc.php";
}
}
* 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA *
***************************************************************************/
-require_once("xorg.misc.inc.php");
-
define("SUCCESS", 1);
define("ERROR_INACTIVE_REDIRECTION", 2);
define("ERROR_INVALID_EMAIL", 3);
return $ident . '@' . $dom;
}
+// function isvalid_email_redirection() {{{1
+/** vérifie si une adresse email convient comme adresse de redirection
+ * @param $email l'adresse email a verifier
+ * @return BOOL
+ */
+function isvalid_email_redirection($email)
+{
+ return isvalid_email($email) &&
+ !preg_match("/@(polytechnique\.(org|edu)|melix\.(org|net)|m4x\.org)$/", $email);
+}
+
// class Bogo {{{1
// The Bogo class represents a spam filtering level in plat/al architecture.
class Bogo
SET panne_level = IF(flags = 'panne', panne_level - 1, panne_level),
flags = 'active'
WHERE uid={?} AND email={?}", $this->uid, $this->email);
- $_SESSION['log']->log("email_on", $this->email.($this->uid!=S::v('uid') ? "(admin on {$this->uid})" : ""));
+ S::logger()->log("email_on", $this->email.($this->uid!=S::v('uid') ? "(admin on {$this->uid})" : ""));
$this->active = true;
$this->broken = false;
}
if ($this->active) {
XDB::execute("UPDATE emails SET flags =''
WHERE uid={?} AND email={?}", $this->uid, $this->email);
- $_SESSION['log']->log("email_off",$this->email.($this->uid != S::v('uid') ? "(admin on {$this->uid})" : "") );
+ S::logger()->log("email_off",$this->email.($this->uid != S::v('uid') ? "(admin on {$this->uid})" : "") );
$this->active = false;
}
}
$res = XDB::query("SELECT mail_storage
FROM auth_user_md5
WHERE user_id = {?}", $this->uid);
- return new FlagSet($res->fetchOneCell());
+ return new PlFlagSet($res->fetchOneCell());
}
// Updates the list of active storages.
return ERROR_INACTIVE_REDIRECTION;
}
XDB::execute('DELETE FROM emails WHERE uid={?} AND email={?}', $this->uid, $email);
- $_SESSION['log']->log('email_del',$email.($this->uid!=S::v('uid') ? " (admin on {$this->uid})" : ""));
+ S::logger()->log('email_del',$email.($this->uid!=S::v('uid') ? " (admin on {$this->uid})" : ""));
foreach ($this->emails as $i => $mail) {
if ($email == $mail->email) {
unset($this->emails[$i]);
}
XDB::execute('REPLACE INTO emails (uid,email,flags) VALUES({?},{?},"active")', $this->uid, $email);
if ($logger = S::v('log', null)) { // may be absent --> step4.php
- $logger->log('email_add',$email.($this->uid!=S::v('uid') ? " (admin on {$this->uid})" : ""));
+ S::logger()->log('email_add',$email.($this->uid!=S::v('uid') ? " (admin on {$this->uid})" : ""));
}
foreach ($this->emails as $mail) {
if ($mail->email == $email_stripped) {
+++ /dev/null
-<?php
-/***************************************************************************
- * Copyright (C) 2003-2008 Polytechnique.org *
- * http://opensource.polytechnique.org/ *
- * *
- * This program is free software; you can redistribute it and/or modify *
- * it under the terms of the GNU General Public License as published by *
- * the Free Software Foundation; either version 2 of the License, or *
- * (at your option) any later version. *
- * *
- * This program is distributed in the hope that it will be useful, *
- * but WITHOUT ANY WARRANTY; without even the implied warranty of *
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
- * GNU General Public License for more details. *
- * *
- * You should have received a copy of the GNU General Public License *
- * along with this program; if not, write to the Free Software *
- * Foundation, Inc., *
- * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA *
- ***************************************************************************/
-
-class PlatalGlobals
-{
- public $session;
-
- /** The x.org version */
- public $version = '@VERSION@';
- public $debug = 0;
- public $mode = 'rw'; // 'rw' => read/write,
- // 'r' => read/only
- // '' => site down
-
- /** db params */
- public $dbdb = 'x4dat';
- public $dbhost = 'localhost';
- public $dbuser = 'x4dat';
- public $dbpwd = 'x4dat';
- public $dbcharset = 'utf8';
-
- /** default skin */
- public $skin;
- public $register_skin;
-
- /** paths */
- public $baseurl;
- public $baseurl_http;
- public $spoolroot;
-
- public $locale;
- public $timezone;
-
- public function __construct($sess)
- {
- $this->session = $sess;
- $this->spoolroot = dirname(dirname(__FILE__));
-
- $this->read_config();
- if (isset($_SERVER) && isset($_SERVER['SERVER_NAME'])) {
- $base = empty($_SERVER['HTTPS']) ? 'http://' : 'https://';
- $this->baseurl = @trim($base .$_SERVER['SERVER_NAME'].dirname($_SERVER['PHP_SELF']), '/');
- $this->baseurl_http = @trim('http://'.$_SERVER['SERVER_NAME'].dirname($_SERVER['PHP_SELF']), '/');
- }
-
- $this->setlocale();
- }
-
- private function read_ini_file($filename)
- {
- $array = parse_ini_file($filename, true);
- if (!is_array($array)) {
- return;
- }
- foreach ($array as $cat => $conf) {
- $c = strtolower($cat);
- foreach ($conf as $k => $v) {
- if ($c == 'core' && property_exists($this, $k)) {
- $this->$k=$v;
- } else {
- if (!isset($this->$c)) {
- $this->$c = new stdClass;
- }
- $this->$c->$k = $v;
- }
- }
- }
- }
-
- private function read_config()
- {
- $this->read_ini_file($this->spoolroot.'/configs/platal.ini');
- $this->read_ini_file($this->spoolroot.'/configs/platal.conf');
- if (file_exists($this->spoolroot.'/spool/conf/platal.dynamic.conf')) {
- $this->read_ini_file($this->spoolroot.'/spool/conf/platal.dynamic.conf');
- }
- }
-
- /** Writes an ini file separated in categories
- * @param filename the name of the file to write (overwrite existing)
- * @param categories an array of categories (array of keys and values)
- */
- private static function write_ini_file($filename, &$categories)
- {
- // [category]
- // key = value
- $f = fopen($filename, 'w');
- foreach ($categories as $cat => $conf) {
- fwrite($f, '; {{{ '.$cat."\n\n");
- fwrite($f, '['.$cat.']'."\n\n");
- foreach ($conf as $k => $v) {
- fwrite($f, $k.' = "'.str_replace('"','\\"',$v).'"'."\n");
- }
- fwrite($f, "\n".'; }}}'."\n");
- }
- fwrite($f, '; vim:set syntax=dosini foldmethod=marker:'."\n");
- fclose($f);
- }
-
- /** Change dynamic config file
- * @param conf array of keys and values to add or replace
- * @param category name of category to change
- *
- * Opens the dynamic conf file and set values from conf in specified
- * category. Updates config vars too.
- */
- public function change_dynamic_config($conf, $category = 'Core')
- {
- $dynamicfile = $this->spoolroot.'/spool/conf/platal.dynamic.conf';
- if (file_exists($dynamicfile)) {
- $array = parse_ini_file($dynamicfile, true);
- } else {
- $array = null;
- }
- if (!is_array($array)) {
- // dynamic conf is empty
- $array = array($category => $conf);
- } else {
- // looks for a category that looks the same (case insensitive)
- $same = false;
- foreach ($array as $m => &$c) {
- if (strtolower($m) == strtolower($category)) {
- $same = $m;
- break;
- }
- }
- if (!$same) {
- // this category doesn't exist yet
- $array[$category] = $conf;
- } else {
- // this category already exists
- $conflower = array();
- foreach ($conf as $k => $v) {
- $conflower[strtolower($k)] = $v;
- }
- // $conflower is now same as $conf but with lower case keys
- // replaces values of keys that already exists
- foreach ($array[$same] as $k => $v) {
- if (isset($conflower[strtolower($k)])) {
- $array[$same][$k] = $conflower[strtolower($k)];
- unset($conflower[strtolower($k)]);
- }
- }
- // add new keys
- foreach ($conf as $k => $v) {
- if (isset($conflower[strtolower($k)])) {
- $array[$same][$k] = $v;
- }
- }
- }
- }
- // writes the file over
- PlatalGlobals::write_ini_file($dynamicfile, $array);
- // rereads the new config to correctly set vars
- $this->read_ini_file($dynamicfile);
- }
-
- public function bootstrap($conf, $callback, $category = 'Core')
- {
- $bootstrap = false;
- $category = strtolower($category);
- foreach ($conf as $key) {
- if (!isset($this->$category->$key)) {
- $bootstrap = true;
- break;
- }
- }
- if ($bootstrap) {
- call_user_func($callback);
- }
- }
-
- private function setlocale()
- {
- setlocale(LC_MESSAGES, $this->locale);
- setlocale(LC_TIME, $this->locale);
- setlocale(LC_CTYPE, $this->locale);
- date_default_timezone_set($this->timezone);
- mb_internal_encoding("UTF-8");
- }
-
- public function asso($key=null)
- {
- static $aid = null;
-
- if (is_null($aid)) {
- $gp = Get::v('n');
- if ($p = strpos($gp, '/')) {
- $gp = substr($gp, 0, $p);
- }
-
- if ($gp) {
- $res = XDB::query('SELECT a.*, d.nom AS domnom,
- FIND_IN_SET(\'wiki_desc\', a.flags) AS wiki_desc,
- FIND_IN_SET(\'notif_unsub\', a.flags) AS notif_unsub
- FROM groupex.asso AS a
- LEFT JOIN groupex.dom AS d ON d.id = a.dom
- WHERE diminutif = {?}', $gp);
- if (!($aid = $res->fetchOneAssoc())) {
- $aid = array();
- }
- } else {
- $aid = array();
- }
- }
- if (empty($key)) {
- return $aid;
- } elseif ( isset($aid[$key]) ) {
- return $aid[$key];
- } else {
- return null;
- }
- }
-}
-
-// vim:set et sw=4 sts=4 sws=4 foldmethod=marker enc=utf-8:
-?>
private function getUser($uid, $email)
{
- require_once("xorg.misc.inc.php");
$res = XDB::query("SELECT FIND_IN_SET('femme', flags) AS sexe, nom, prenom, promo
FROM auth_user_md5
WHERE user_id = {?}", $uid);
return $this->signature;
}
- protected function prepareText(PlatalPage &$page, array $user)
+ protected function prepareText(PlPage &$page, array $user)
{
$page->assign('intro', $this->getIntro());
$page->assign('u', $user);
public function getText(array $user)
{
- $page = new XorgPage('marketing/marketing.mail.tpl', NO_SKIN);
+ $page = new XorgPage();
+ $page->changeTpl('marketing/marketing.mail.tpl', NO_SKIN);
$this->prepareText($page, $user);
return $page->raw();
}
* 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA *
***************************************************************************/
-require_once("xorg.misc.inc.php");
-
// {{{ class MassMailer
abstract class MassMailer
WHERE ni_id={?}', $uid);
XDB::execute('DELETE FROM watch_nonins WHERE ni_id={?}', $uid);
}
- require_once 'xorg.misc.inc.php';
- update_NbNotifs();
+ Platal::session()->updateNbNotifs();
}
// }}}
+++ /dev/null
-<?php
-/***************************************************************************
- * Copyright (C) 2003-2008 Polytechnique.org *
- * http://opensource.polytechnique.org/ *
- * *
- * This program is free software; you can redistribute it and/or modify *
- * it under the terms of the GNU General Public License as published by *
- * the Free Software Foundation; either version 2 of the License, or *
- * (at your option) any later version. *
- * *
- * This program is distributed in the hope that it will be useful, *
- * but WITHOUT ANY WARRANTY; without even the implied warranty of *
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
- * GNU General Public License for more details. *
- * *
- * You should have received a copy of the GNU General Public License *
- * along with this program; if not, write to the Free Software *
- * Foundation, Inc., *
- * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA *
- ***************************************************************************/
-
-$TIME_BEGIN = microtime(true);
-
-define('AUTH_PUBLIC', 0);
-define('AUTH_COOKIE', 1);
-define('AUTH_MDP', 2);
-
-define('PERMS_EXT', 'ext');
-define('PERMS_USER', 'user');
-define('PERMS_ADMIN', 'admin');
-
-define('SKINNED', 0);
-define('SIMPLE', 1);
-define('NO_SKIN', 2);
-
-define('NO_AUTH', 0);
-define('DO_AUTH', 1);
-define('NO_HTTPS', 2);
-
-define('DEBUG_BT', 1);
-define('DEBUG_VALID', 2);
-define('DEBUG_SMARTY', 4);
-
-function __autoload($cls)
-{
- $cls = strtolower($cls);
- $path = dirname(dirname(__FILE__));
- if (!@include "$path/classes/$cls.php") {
- if (substr($cls, -3, 3) == 'req') {
- @include 'validations.inc.php';
- return;
- } else if (substr($cls, 0, 6) == 'banana') {
- require_once 'banana/banana.inc.php';
- Banana::load(substr($cls, 6));
- return;
- }
- @include "$cls.inc.php";
- }
-}
-__autoload('Env');
-
-function pl_error_handler($errno, $errstr, $errfile, $errline)
-{
- static $errortype;
- if (!error_reporting())
- return;
-
- if (!isset($errortype)) {
- $errortype = array (
- E_ERROR => "Error",
- E_WARNING => "Warning",
- E_PARSE => "Parsing Error",
- E_NOTICE => "Notice",
- E_CORE_ERROR => "Core Error",
- E_CORE_WARNING => "Core Warning",
- E_COMPILE_ERROR => "Compile Error",
- E_COMPILE_WARNING => "Compile Warning",
- E_USER_ERROR => "User Error",
- E_USER_WARNING => "User Warning",
- E_USER_NOTICE => "User Notice",
- E_STRICT => "Runtime Notice",
- E_RECOVERABLE_ERROR => "Recoverable Error"
- );
- }
-
- global $globals;
- if (isset($globals) && !$globals->debug) {
- if ($errno == E_NOTICE || $errno == E_USER_NOTICE || $errno == E_STRICT) {
- return;
- }
- }
-
- $type = isset($errortype[$errno]) ? $errortype[$errno] : $errno;
- $errstr = utf8_encode(htmlentities($errstr));
- $GLOBALS['pl_errors'][] =
- "<div class='phperror'>".
- "<strong>{$type}</strong> <em>$errstr</em><br />".
- "<tt>$errfile : $errline</tt>".
- "</div>";
-}
-
-function pl_clear_errors()
-{
- unset($GLOBALS['pl_errors']);
-}
-
-function pl_dump_env()
-{
- echo "<div class='phperror'><pre>";
- echo "\nSESSION: "; var_export($_SESSION);
- echo "\nPOST: "; var_export($_POST);
- echo "\nGET: "; var_export($_GET);
- echo "\nCOOKIE: "; var_export($_COOKIE);
- echo "</pre></div>";
-}
-
-function pl_print_errors()
-{
- if (!empty($GLOBALS['pl_errors'])) {
- print join("\n", $GLOBALS['pl_errors']);
- }
-}
-
-set_error_handler('pl_error_handler', E_ALL | E_STRICT);
-register_shutdown_function('pl_print_errors');
-// register_shutdown_function('pl_dump_env');
-
-/** Check if the string is utf8
- */
-function is_utf8($s)
-{
- return @iconv('utf-8', 'utf-8', $s) == $s;
-}
-
-/** vérifie si une adresse email est bien formatée * ATTENTION, cette fonction ne doit pas être appelée sur une chaîne ayant subit un addslashes (car elle accepte le "'" qui it alors un "\'"
- * @param $email l'adresse email a verifier
- * @return BOOL */
-function isvalid_email($email)
-{
- // la rfc2822 authorise les caractères "a-z", "0-9", "!", "#", "$", "%", "&", "'", "*", "+", "-", "/", "=", "?", "^", `", "{", "|", "}", "~" aussi bien dans la partie locale que dans le domaine.
- // Pour la partie locale, on réduit cet ensemble car il n'est pas utilisé.
- // Pour le domaine, le système DNS limite à [a-z0-9.-], on y ajoute le "_" car il est parfois utilisé.
- return preg_match("/^[a-z0-9_.'+-]+@[a-z0-9._-]+\.[a-z]{2,6}$/i", $email);
-}
-
-function pl_url($path, $query = null, $fragment = null)
-{
- global $platal;
-
- $base = $platal->ns . $path . ($query ? '?'.$query : '');
- return $fragment ? $base.'#'.$fragment : $base;
-}
-
-function pl_self($n = null) {
- global $platal;
- return $platal->pl_self($n);
-}
-
-function http_redirect($fullurl)
-{
- if (count($_SESSION)) {
- session_write_close();
- }
- header('Location: '.$fullurl);
- exit;
-}
-
-function pl_redirect($path, $query = null, $fragment = null)
-{
- global $globals;
- http_redirect($globals->baseurl . '/' . pl_url($path, $query, $fragment));
-}
-
-function pl_entities($text, $mode = ENT_COMPAT)
-{
- return htmlentities($text, $mode, 'UTF-8');
-}
-
-function pl_entity_decode($text, $mode = ENT_COMPAT)
-{
- return html_entity_decode($text, $mode, 'UTF-8');
-}
-
-// vim:set et sw=4 sts=4 sws=4 foldmethod=marker enc=utf-8:
-?>
* 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA *
***************************************************************************/
-function _rss_encode_date($d) {
- if (preg_match('/^\d{14}$/', $d)) {
- $t = mktime(substr($d,8,2), substr($d,10,2), substr($d,12,2), substr($d,4,2), substr($d,6,2), substr($d,0,4));
- } else {
- $t = strtotime($d);
- }
- return date('r', $t);
-}
-
function init_rss($template, $alias, $hash, $require_uid = true)
{
- global $page;
+ $page =& Platal::page();
$page->changeTpl($template, NO_SKIN);
- $page->register_modifier('rss_date', '_rss_encode_date');
-
- $res = XDB::query(
- 'SELECT a.id
- FROM aliases AS a
- INNER JOIN auth_user_md5 AS u ON (a.id = u.user_id AND u.perms IN ("admin", "user"))
- INNER JOIN auth_user_quick AS q ON (a.id = q.user_id AND q.core_rss_hash = {?})
- WHERE a.alias = {?} AND a.type != "homonyme"', $hash, $alias);
- $uid = $res->fetchOneCell();
-
+ $uid = Platal::session()->tokenAuth($alias, $hash);
if (empty($uid)) {
if ($require_uid) {
exit;
--- /dev/null
+<?php
+/***************************************************************************
+ * Copyright (C) 2003-2008 Polytechnique.org *
+ * http://opensource.polytechnique.org/ *
+ * *
+ * This program is free software; you can redistribute it and/or modify *
+ * it under the terms of the GNU General Public License as published by *
+ * the Free Software Foundation; either version 2 of the License, or *
+ * (at your option) any later version. *
+ * *
+ * This program is distributed in the hope that it will be useful, *
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of *
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
+ * GNU General Public License for more details. *
+ * *
+ * You should have received a copy of the GNU General Public License *
+ * along with this program; if not, write to the Free Software *
+ * Foundation, Inc., *
+ * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA *
+ ***************************************************************************/
+
+/******************************************************************************
+ * Security functions
+ *****************************************************************************/
+
+function check_ip($level)
+{
+ if (empty($_SERVER['REMOTE_ADDR'])) {
+ return false;
+ }
+ if (empty($_SESSION['check_ip'])) {
+ $ips = array();
+ if (!empty($_SERVER['HTTP_X_FORWARDED_FOR'])) {
+ $ips = explode(',', $_SERVER['HTTP_X_FORWARDED_FOR']);
+ }
+ $ips[] = $_SERVER['REMOTE_ADDR'];
+ foreach ($ips as &$ip) {
+ $ip = '(ip & mask) = (' . ip_to_uint($ip) . '& mask)';
+ }
+ $res = XDB::query('SELECT state, description
+ FROM ip_watch
+ WHERE ' . implode(' OR ', $ips) . '
+ ORDER BY state DESC');
+ if ($res->numRows()) {
+ $state = $res->fetchOneAssoc();
+ $_SESSION['check_ip'] = $state['state'];
+ $_SESSION['check_ip_desc'] = $state['description'];
+ } else {
+ $_SESSION['check_ip'] = 'safe';
+ }
+ }
+ $test = array();
+ switch ($level) {
+ case 'unsafe': $test[] = 'unsafe';
+ case 'dangerous': $test[] = 'dangerous';
+ case 'ban': $test[] = 'ban'; break;
+ default: return false;
+ }
+ return in_array($_SESSION['check_ip'], $test);
+}
+
+function check_email($email, $message)
+{
+ $res = XDB::query("SELECT state, description
+ FROM emails_watch
+ WHERE state != 'safe' AND email = {?}", $email);
+ if ($res->numRows()) {
+ send_warning_mail($message);
+ return true;
+ }
+ return false;
+}
+
+function check_account()
+{
+ return S::v('watch_account');
+}
+
+function check_redirect($red = null)
+{
+ require_once 'emails.inc.php';
+ if (is_null($red)) {
+ $red = new Redirect(S::v('uid'));
+ }
+ if ($red->get_uid() == S::v('uid')) {
+ $_SESSION['no_redirect'] = !$red->other_active('');
+ $_SESSION['mx_failures'] = $red->get_broken_mx();
+ }
+}
+
+function send_warning_mail($title)
+{
+ global $globals;
+ $mailer = new PlMailer();
+ $mailer->setFrom("webmaster@" . $globals->mail->domain);
+ $mailer->addTo($globals->core->admin_email);
+ $mailer->setSubject("[Plat/al Security Alert] $title");
+ $mailer->setTxtBody("Identifiants de session :\n" . var_export($_SESSION, true) . "\n\n"
+ ."Identifiants de connexion :\n" . var_export($_SERVER, true));
+ $mailer->send();
+}
+
+function kill_sessions()
+{
+ assert(S::has_perms());
+ shell_exec('sudo -u root ' . dirname(dirname(__FILE__)) . '/bin/kill_sessions.sh');
+}
+
+// vim:set et sw=4 sts=4 sws=4 foldmethod=marker enc=utf-8:
+?>
* 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA *
***************************************************************************/
-
-require_once("xorg.inc.php");
-
require_once('user.func.inc.php');
function is_ax_key_missing() {
// Defaut callback to call when a login is not found
function _default_user_callback($login)
{
- global $page;
- $page->trigError("Il n'y a pas d'utilisateur avec l'identifiant : $login");
+ Platal::page()->trigError("Il n'y a pas d'utilisateur avec l'identifiant : $login");
return;
}
function get_user_login($data, $get_forlife = false, $callback = '_default_user_callback')
{
- global $globals, $page;
+ global $globals;
if (is_numeric($data)) {
$res = XDB::query("SELECT alias FROM aliases WHERE type='a_vie' AND id={?}", $data);
default:
if (S::has_perms()) {
$aliases = $res->fetchColumn();
- $page->trigError("Il y a $i utilisateurs avec cette adresse email : ".join(', ', $aliases));
+ Platal::page()->trigError("Il y a $i utilisateurs avec cette adresse mail : ".join(', ', $aliases));
} else {
$res->free();
}
gp.pays AS countrytxt,a.region, a.regiontxt,
FIND_IN_SET('active', a.statut) AS active, a.adrid,
FIND_IN_SET('res-secondaire', a.statut) AS secondaire,
+ FIND_IN_SET('courrier', a.statut) AS courier,
a.pub, gp.display
FROM adresses AS a
LEFT JOIN geoloc_pays AS gp ON (gp.a2=a.country)
* 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA *
***************************************************************************/
-require_once('xorg.misc.inc.php');
require_once('user.func.inc.php');
global $globals;
public function __construct($quick = false, $no_search = false, $join = '', $where = '')
{
- require_once dirname(__FILE__).'/../modules/search/search.inc.php';
-
+ Platal::load('search', 'search.inc.php');
if ($no_search) {
return;
}
private function getQuick($join, $where)
{
- require_once dirname(__FILE__).'/../modules/search/search.inc.php';
+ Platal::load('search', 'search.inc.php');
global $globals;
if (!S::logged()) {
Env::kill('with_soundex');
u.perms != 'pending' AS wasinscrit,
u.deces != 0 AS dcd, u.deces, u.matricule_ax,
FIND_IN_SET('femme', u.flags) AS sexe,
- e.entreprise, es.label AS secteur, ef.fonction_fr AS fonction,
+ e.entreprise, e.web AS job_web, es.label AS secteur, ef.fonction_fr AS fonction,
IF(n.nat='',n.pays,n.nat) AS nat, n.a2 AS iso3166,
ad0.text AS app0text, ad0.url AS app0url, ai0.type AS app0type,
ad1.text AS app1text, ad1.url AS app1url, ai1.type AS app1type,
return 'include/plview.trombi.tpl';
}
- public function apply(PlatalPage &$page)
+ public function apply(PlPage &$page)
{
if (!empty($GLOBALS['IS_XNET_SITE'])) {
global $globals;
return $args;
}
- public function apply(PlatalPage &$page)
+ public function apply(PlPage &$page)
{
require_once 'geoloc.inc.php';
require_once '../modules/search/search.inc.php';
: "");
}
- public function apply(PlatalPage &$page)
+ public function apply(PlPage &$page)
{
$page->assign_by_ref('set',
$this->set->get($this->fields(), $this->joins(), null, null, null, 5, 0));
define('SIZE_MAX', 32768);
-require_once dirname(__FILE__) . '/../classes/xdb.php';
+global $globals;
+require_once $globals->spoolroot . '/core/classes/xdb.php';
/**
* Iterator class, that lists objects through the database
$this->uid, $this->type, $this, $this->stamp);
global $globals;
- update_NbValid();
+ $globals->updateNbValid();
return true;
}
*/
public function clean()
{
+ global $globals;
+
if ($this->unique) {
$success = XDB::execute('DELETE FROM requests WHERE user_id={?} AND type={?}',
$this->uid, $this->type);
$success = XDB::execute('DELETE FROM requests WHERE user_id={?} AND type={?} AND stamp={?}',
$this->uid, $this->type, $this->stamp);
}
- update_NbValid();
+ $globals->updateNbValid();
return $success;
}
protected function trigError($msg)
{
- global $page;
- $page->trigError($msg);
+ Platal::page()->trigError($msg);
}
protected function trigWarning($msg)
{
- global $page;
- $page->trigWarning($msg);
+ Platal::page()->trigWarning($msg);
}
protected function trigSuccess($msg)
{
- global $page;
- $page->trigSuccess($msg);
+ Platal::page()->trigSuccess($msg);
}
// }}}
protected function _mail_subj()
{
- return "[Polytechnique.org/LISTES] Demande de la liste {$this->liste}";
+ return "[Polytechnique.org/LISTES] Demande de la liste {$this->liste}@{$this->domain}";
}
// }}}
protected function _mail_body($isok)
{
if ($isok) {
- return " La liste de diffusion {$this->liste} que tu avais demandée vient d'être créée.";
+ return " La liste de diffusion {$this->liste}@{$this->domain} que tu avais demandée vient d'être créée.";
} else {
- return " La demande que tu avais faite pour la liste de diffusion {$this->liste} a été refusée.";
+ return " La demande que tu avais faite pour la liste de diffusion {$this->liste}@{$this->domain} a été refusée.";
}
}
parent::__construct($_uid, true, 'usage');
$this->nom_usage = $_usage;
$this->reason = $_reason;
- require_once 'xorg.misc.inc.php';
$this->alias = make_username($this->prenom, $this->nom_usage);
if (!$this->nom_usage) $this->alias = "";
* 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA *
***************************************************************************/
-require_once('xorg.misc.inc.php');
require_once('user.func.inc.php');
-class VCardIterator implements PlIterator
+class VCard extends PlVCard
{
private $user_list = array();
private $count = 0;
private $freetext = null;
private $photos = true;
- public function __construct($photos, $freetext)
+ public function __construct($photos = true, $freetext = null)
{
+ PlVCard::$folding = false;
$this->freetext = $freetext;
$this->photos = $photos;
}
- public function add_user($user)
+ public function addUser($user)
{
$forlife = get_user_forlife($user, '_silent_user_callback');
if ($forlife) {
}
}
- public function first()
- {
- return count($this->user_list) == $this->count - 1;
- }
-
- public function last()
- {
- return count($this->user_list) == 0;
+ public function addUsers(array $users) {
+ foreach ($users as $user) {
+ $this->addUser($user);
+ }
}
- public function total()
+ protected function fetch()
{
- return $this->count;
+ return PlIteratorUtils::fromArray($this->user_list);
}
- public function next()
+ protected function buildEntry($entry)
{
- if (!$this->user_list) {
- return null;
- }
global $globals;
- $login = array_shift($this->user_list);
+ $login = $entry['value'];
$user = get_user_details($login);
- if (strlen(trim($user['freetext']))) {
- $user['freetext'] = pl_entity_decode($user['freetext']);
+ if (empty($user['nom_usage'])) {
+ $entry = new PlVCardEntry($user['prenom'], $user['nom'], null, null, @$user['nickname']);
+ } else {
+ $entry = new PlVCardEntry($user['prenom'], array($user['nom'], $user['nom_usage']), null, null, @$user['nickname']);
}
+
+ // Free text
+ $freetext = '(' . $user['promo'] . ')';
if ($this->freetext) {
- if (strlen(trim($user['freetext']))) {
- $user['freetext'] = $this->freetext . "\n" . $user['freetext'];
- } else {
- $user['freetext'] = $this->freetext;
+ $freetext .= "\n" . $this->freetext;
+ }
+ if (strlen(trim($user['freetext']))) {
+ $freetext .= "\n" . MiniWiki::WikiToText($user['freetext']);
+ }
+ $entry->set('NOTE', $freetext);
+
+ // Mobile
+ if (!empty($user['mobile'])) {
+ $entry->addTel(null, $user['mobile'], false, true, true, false, true, true);
+ }
+
+ // Emails
+ $entry->addMail(null, $user['bestalias'] . '@' . $globals->mail->domain, true);
+ $entry->addMail(null, $user['bestalias'] . '@' . $globals->mail->domain2);
+ if ($user['bestalias'] != $user['forlife']) {
+ $entry->addMail(null, $user['forlife'] . '@' . $globals->mail->domain);
+ $entry->addMail(null, $user['forlife'] . '@' . $globals->mail->domain2);
+ }
+
+ // Homes
+ foreach ($user['adr'] as $adr) {
+ $street = array($adr['adr1']);
+ if (!empty($adr['adr2'])) {
+ $street[] = $adr['adr2'];
+ }
+ if (!empty($adr['adr3'])) {
+ $street[] = $adr['adr3'];
+ }
+ $group = $entry->addHome($street, null, null, $adr['postcode'], $adr['city'], $adr['region'], @$adr['country'],
+ $adr['active'], $adr['courier'], $adr['courier']);
+ if (!empty($adr['tels'])) {
+ foreach ($adr['tels'] as $tel) {
+ $fax = $tel['tel_type'] == 'Fax';
+ $entry->addTel($group, $tel['tel'], $fax, !$fax, !$fax, false, false, !$fax && $adr['active'] && empty($user['mobile']));
+ }
+ }
+ }
+
+ // Pro
+ foreach ($user['adr_pro'] as $pro) {
+ $street = array($adr['adr1']);
+ if (!empty($pro['adr2'])) {
+ $street[] = $pro['adr2'];
+ }
+ if (!empty($pro['adr3'])) {
+ $street[] = $pro['adr3'];
+ }
+ $group = $entry->addWork($pro['entreprise'], null, $pro['poste'], $pro['fonction'],
+ $street, null, null, $pro['postcode'], $pro['city'], $pro['region'], @$pro['country']);
+ if (!empty($pro['tel'])) {
+ $entry->addTel($group, $pro['tel']);
+ }
+ if (!empty($pro['fax'])) {
+ $entry->addTel($group, $pro['fax'], true);
+ }
+ if (!empty($pro['email'])) {
+ $entry->addMail($group, $pro['email']);
}
}
- // alias virtual
+ // Melix
$res = XDB::query(
"SELECT alias
FROM virtual
$user['user_id'],
$user['forlife'].'@'.$globals->mail->domain,
$user['forlife'].'@'.$globals->mail->domain2);
+ if ($res->numRows()) {
+ $entry->addMail(null, $res->fetchOneCell());
+ }
+
+ // Custom fields
+ if (count($user['gpxs_name'])) {
+ $entry->set('X-GROUPS', join(', ', $user['gpxs_name']));
+ }
+ if (count($user['binets'])) {
+ $entry->set('X-BINETS', join(', ', $user['binets']));
+ }
+ if (!empty($user['section'])) {
+ $entry->set('X-SECTION', $user['section']);
+ }
- $user['virtualalias'] = $res->fetchOneCell();
- $user['gpxs_vcardjoin'] = join(', ', array_map(array('VCard', 'text_encode'), $user['gpxs_name']));
- $user['binets_vcardjoin'] = join(', ', array_map(array('VCard', 'text_encode'), $user['binets']));
- // get photo
+ // Photo
if ($this->photos) {
$res = XDB::query(
"SELECT attach, attachmime
INNER JOIN aliases AS a ON (a.id = p.uid AND a.type = 'a_vie')
WHERE a.alias = {?}", $login);
if ($res->numRows()) {
- $user['photo'] = $res->fetchOneAssoc();
- }
- }
- return $user;
- }
-}
-
-class VCard
-{
- static private $windows = false;
- private $iterator = null;
-
- public function __construct($users, $photos = true, $freetext = null)
- {
- $this->iterator = new VCardIterator($photos, $freetext);
- VCard::$windows = (strpos($_SERVER['HTTP_USER_AGENT'], 'Windows') !== false);
- if (is_array($users)) {
- foreach ($users as $user) {
- $this->iterator->add_user($user);
+ list($data, $type) = $res->fetchOneRow();
+ $entry->setPhoto($data, strtoupper($type));
}
- } else {
- $this->iterator->add_user($users);
- }
- }
-
- public static function escape($text)
- {
- if (VCard::$windows) {
- return str_replace(';', '\\\\;', $text);
- } else {
- return str_replace(array(';', ','), array('\\\\;', '\\\\,'), $text);
- }
- }
-
- public static function format_adr($params, &$smarty)
- {
- // $adr1, $adr2, $adr3, $postcode, $city, $region, $country
- extract($params['adr']);
- $adr = trim($adr1);
- $adr = trim("$adr\n$adr2");
- $adr = trim("$adr\n$adr3");
- return VCard::text_encode(';;'
- . (VCard::$windows ? VCard::escape($adr) : $adr) . ';'
- . (VCard::$windows ? VCard::escape($city) : $city) . ';'
- . (VCard::$windows ? VCard::escape($region) : $region) . ';'
- . (VCard::$windows ? VCard::escape($postcode) : $postcode) . ';'
- . (VCard::$windows ? VCard::escape($country) : $country), false);
- }
-
- public static function text_encode($text, $escape = true)
- {
- if (is_array($text)) {
- return implode(',', array_map(array('VCard', 'text_encode'), $text));
- }
- if ($escape) {
- $text = VCard::escape($text);
}
- if (VCard::$windows) {
- $text = utf8_decode($text);
- }
- return str_replace(array("\r\n", "\n", "\r"), '\n', $text);
+ return $entry;
}
-
- public function do_page(&$page)
- {
- $page->changeTpl('core/vcard.tpl', NO_SKIN);
- $page->register_modifier('vcard_enc', array($this, 'text_encode'));
- $page->register_function('format_adr', array($this, 'format_adr'));
- $page->assign_by_ref('users', $this->iterator);
-
- header("Pragma: ");
- header("Cache-Control: ");
- header("Content-type: text/x-vcard; charset=UTF-8");
- }
}
// vim:set et sw=4 sts=4 sws=4 foldmethod=marker enc=utf-8:
+++ /dev/null
-<?php
-/***************************************************************************
- * Copyright (C) 2003-2008 Polytechnique.org *
- * http://opensource.polytechnique.org/ *
- * *
- * This program is free software; you can redistribute it and/or modify *
- * it under the terms of the GNU General Public License as published by *
- * the Free Software Foundation; either version 2 of the License, or *
- * (at your option) any later version. *
- * *
- * This program is distributed in the hope that it will be useful, *
- * but WITHOUT ANY WARRANTY; without even the implied warranty of *
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
- * GNU General Public License for more details. *
- * *
- * You should have received a copy of the GNU General Public License *
- * along with this program; if not, write to the Free Software *
- * Foundation, Inc., *
- * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA *
- ***************************************************************************/
-
-function wiki_pagename()
-{
- if (!Get::v('n')) {
- return null;
- }
-
- $words = explode('/', trim(Get::v('n'), '/'));
- if (count($words) == 2) {
- return join('.', $words);
- }
-
- array_unshift($words, $words[0]);
- $b = array_pop($words);
- $a = array_pop($words);
-
- pl_redirect($a.'/'.$b);
-}
-
-function wiki_filename($s)
-{
- if (@iconv('utf-8', 'utf-8', $s) == $s) {
- return $s;
- }
- return utf8_encode($s);
-}
-
-function wiki_work_dir()
-{
- global $globals;
- return $globals->spoolroot.'/spool/wiki.d';
-}
-
-function wiki_clear_all_cache()
-{
- system('rm -f '.wiki_work_dir().'/cache_*');
-}
-
-function wiki_perms_options() {
- return array('public' => 'Public', 'logged' => 'Connecté',
- 'mdp' => 'Authentifié', 'admin' => 'Admin');
-}
-
-function wiki_get_perms($n)
-{
- $file = wiki_work_dir().'/'.wiki_filename(str_replace('/', '.', $n));
- $lines = explode("\n", @file_get_contents($file));
- foreach ($lines as $line) {
- @list($k, $v) = explode('=', $line, 2);
- if ($k == 'platal_perms') {
- return explode(':', $v);
- }
- }
- return array('logged', 'admin');
-}
-
-function wiki_putfile($f, $s)
-{
- $fp = fopen($f, 'w');
- fputs($fp, $s);
- fclose($fp);
-}
-
-function wiki_set_perms($n, $pr, $pw)
-{
- $file = wiki_work_dir().'/'.wiki_filename(str_replace('/', '.', $n));
- if (!file_exists($file)) {
- return false;
- }
-
- $p = $pr . ':' . $pw;
-
- $lines = explode("\n", file_get_contents($file));
- foreach ($lines as $i => $line) {
- list($k, $v) = explode('=', $line, 2);
- if ($k == 'platal_perms') {
- $lines[$i] = 'platal_perms='.$p;
- wiki_putfile($file, join("\n", $lines));
- return true;
- }
- }
-
- array_splice($lines, 1, 0, array('platal_perms='.$p));
- wiki_putfile($file, join("\n", $lines));
- return true;
-}
-
-function wiki_may_have_perms($perm) {
- switch ($perm) {
- case 'public': return true;
- case 'logged': return S::logged();
- case 'mdp': return S::logged();
- default: return S::has_perms();
- }
-}
-
-function wiki_apply_feed_perms($perm)
-{
- if ($perm == 'public') {
- return;
- }
-
- require_once 'rss.inc.php';
- $uid = init_rss(null, Env::v('user'), Env::v('hash'));
- $res = XDB::query('SELECT user_id AS uid, IF (nom_usage <> \'\', nom_usage, nom) AS nom, prenom, perms
- FROM auth_user_md5
- WHERE user_id = {?}', $uid);
- if (!$res->numRows()) {
- exit;
- }
- $table = $res->fetchOneAssoc();
- $_SESSION = array_merge($_SESSION, $table, array('forlife' => Env::v('user')));
- require_once 'xorg/session.inc.php';
- $_SESSION['perms'] =& XorgSession::make_perms($_SESSION['perms']);
- if ($perm == 'logged' || $_SESSION['perms']->hasFlag('admin')) {
- return;
- }
- exit;
-}
-
-function wiki_apply_perms($perm) {
- global $page, $platal, $globals;
-
- switch ($perm) {
- case 'public':
- return;
-
- case 'logged':
- if (!call_user_func(array($globals->session, 'doAuthCookie'))) {
- $platal = empty($GLOBALS['IS_XNET_SITE']) ? new Platal() : new Xnet();
- $platal->force_login($page);
- }
- return;
-
- default:
- if (!call_user_func(array($globals->session, 'doAuth'))) {
- $platal = empty($GLOBALS['IS_XNET_SITE']) ? new Platal() : new Xnet();
- $platal->force_login($page);
- }
- if ($perm == 'admin') {
- check_perms();
- }
- return;
- }
-}
-
-function wiki_require_page($pagename)
-{
- global $globals;
- $pagename_slashes = str_replace('.','/',$pagename);
- $pagename_dots = str_replace('/','.',$pagename);
- if (is_file(wiki_work_dir().'/cache_'.$pagename_dots.'.tpl')) {
- return;
- }
- system('wget --no-check-certificate '. escapeshellarg($globals->baseurl.'/'.$pagename_slashes) . ' -O /dev/null');
-}
-
-function wiki_delete_page($pagename)
-{
- $pagename_dots = str_replace('/','.',$pagename);
- if (!strpos($pagename_dots, '.')) {
- return false;
- }
- $file = wiki_work_dir().'/'.wiki_filename($pagename_dots);
- $cachefile = wiki_work_dir().'/cache_'.$pagename_dots.'.tpl';
- if (is_file($cachefile)) {
- unlink($cachefile);
- }
- if (!is_file($file)) {
- return false;
- }
- unlink($file);
- return true;
-}
-
-function wiki_links_in_line($line, $groupname)
-{
- $links = array();
- if (preg_match_all('@\[\[([^~][^\]\|\?#]*)((\?|#)[^\]\|]+)?(\\|[^\]]+)?\]\]@', $line, $matches, PREG_OFFSET_CAPTURE)) {
- foreach ($matches[1] as $j => $link) if (!preg_match('@http://@', $link[0])) {
- $mylink = str_replace('/','.',trim($link[0]));
- $sup = trim(substr($matches[2][$j][0],1));
- $alt = trim(substr($matches[4][$j][0],1));
- $newlink = str_replace(' ','',ucwords($mylink));
- if (strpos($newlink,'.') === false) {
- $newlink = $groupname.'.'.$newlink;
- }
- if (!$alt && $mylink != $newlink) {
- $alt = trim($link[0]);
- }
- $links[] = array(
- 'pos' => $matches[0][$j][1],
- 'size' => strlen($matches[0][$j][0]),
- 'href' => $newlink,
- 'sup' => $sup,
- 'alt' => $alt,
- 'group' => substr($mylink, 0, strpos($mylink, '.')));
- }
- }
- return $links;
-}
-
-function wiki_rename_page($pagename, $newname, $changeLinks = true)
-{
- $pagename_dots = str_replace('/','.',$pagename);
- $newname_dots = str_replace('/','.',$newname);
- if (!strpos($pagename_dots, '.') || !strpos($newname_dots, '.')) {
- return false;
- }
- $groupname = substr($pagename_dots, 0, strpos($pagename_dots,'.'));
- $newgroupname = substr($newname_dots, 0, strpos($pagename_dots,'.'));
-
- $file = wiki_work_dir().'/'.wiki_filename($pagename_dots);
- $newfile = wiki_work_dir().'/'.wiki_filename($newname_dots);
- if (!is_file($file)) {
- // old page doesn't exist
- return false;
- }
- if (!rename($file, $newfile)) {
- // impossible to renama page
- return false;
- }
-
- if (!$changeLinks) {
- return true;
- }
-
- $changedLinks = 0;
- // change name inside this folder and ingroup links if changing group
- $lines = explode("\n", file_get_contents($newfile));
- $changed = false;
- foreach ($lines as $i => $line) {
- list($k, $v) = explode('=', $line, 2);
- if ($k == 'name' && $v == $pagename_dots) {
- $lines[$i] = 'name='.$newname_dots;
- $changed = true;
- } else if ($groupname != $newgroupname) {
- $links = wiki_links_in_line($line, $groupname);
- $newline = ''; $last = 0;
- foreach ($links as $link) if ($link['group'] == $groupname) {
- $newline .= substr($line, $last, $link['pos']);
- $newline .= '[['.$link['href'].$link['sup'].($link['alt']?(' |'.$link['alt']):'').']]';
- $last = $link['pos']+$link['size'];
- $changedLinks++;
- }
- if ($last != 0) {
- $newline .= substr($line, $last);
- $lines[$i] = $newline;
- $changed = true;
- }
- }
- }
- wiki_putfile($newfile, join("\n", $lines));
-
- // change wiki links in all wiki pages
- $endname = substr($pagename_dots, strpos($pagename_dots,'.')+1);
- $pages = array();
- exec("grep ".$endname." ".wiki_work_dir()."/* -sc", $pages);
- foreach($pages as $line) {
- if (preg_match('%/([^/:]+):([0-9]+)$%', $line, $vals) && $vals[2] > 0) {
- $inpage = $vals[1];
- $lines = explode("\n", file_get_contents(wiki_work_dir().'/'.$inpage));
- $changed = false;
- // find all wiki links in page and change if linked to this page
- foreach ($lines as $i => $line) {
- $links = wiki_links_in_line($line, substr($inpage, 0, strpos($inpage, '.')));
- $newline = ''; $last = 0;
- foreach ($links as $link) {
- if ($link['href'] == $pagename_dots) {
- $newline .= substr($line, $last, $link['pos']);
- $newline .= '[['.$newname_dots.$link['sup'].($link['alt']?(' |'.$link['alt']):'').']]';
- $last = $link['pos']+$link['size'];
- $changedLinks++;
- }
- }
- if ($last != 0) {
- $newline .= substr($line, $last);
- $lines[$i] = $newline;
- $changed = true;
- }
- }
- if ($changed)
- {
- wiki_putfile(wiki_work_dir().'/'.$inpage, join("\n", $lines));
- }
- }
- }
- if ($changedLinks > 0) {
- return $changedLinks;
- }
- return true;
-}
-
-function wiki_rename_folder($pagename, $newname, $changeLinks = true)
-{
-}
-
-// vim:set et sw=4 sts=4 sws=4 foldmethod=marker enc=utf-8:
-?>
+++ /dev/null
-<?php
-/***************************************************************************
- * Copyright (C) 2003-2008 Polytechnique.org *
- * http://opensource.polytechnique.org/ *
- * *
- * This program is free software; you can redistribute it and/or modify *
- * it under the terms of the GNU General Public License as published by *
- * the Free Software Foundation; either version 2 of the License, or *
- * (at your option) any later version. *
- * *
- * This program is distributed in the hope that it will be useful, *
- * but WITHOUT ANY WARRANTY; without even the implied warranty of *
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
- * GNU General Public License for more details. *
- * *
- * You should have received a copy of the GNU General Public License *
- * along with this program; if not, write to the Free Software *
- * Foundation, Inc., *
- * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA *
- ***************************************************************************/
-
-require_once 'wiki.inc.php';
-
-$n = wiki_pagename();
-if (!$n) {
- pl_redirect('');
-}
-
-new_skinned_page('core/wiki.tpl');
-$perms = wiki_get_perms($n);
-$feed = false;
-
-// Check user perms
-switch (Env::v('action')) {
- case 'rss': case 'atom': case 'sdf': case 'dc':
- wiki_apply_feed_perms($perms[0]);
- $feed = true;
- case '': case 'search':
- break;
-
- case 'edit':
- wiki_apply_perms($perms[1]);
- break;
-
- default:
- wiki_apply_perms('admin');
- break;
-}
-
-if ($p = Post::v('setrperms')) {
- wiki_apply_perms('admin');
- if (wiki_set_perms($n, $p, $perms[1])) {
- $perms = wiki_get_perms($n);
- $page->trigSuccess('Permissions mises à jour');
- }
-}
-
-if ($p = Post::v('setwperms')) {
- wiki_apply_perms('admin');
- if (wiki_set_perms($n, $perms[0], $p)) {
- $perms = wiki_get_perms($n);
- $page->trigSuccess('Permissions mises à jour');
- }
-}
-
-// Generate cache even if we don't have access rights
-$wiki_cache = wiki_work_dir().'/cache_'.wiki_filename($n).'.tpl';
-$cache_exists = file_exists($wiki_cache);
-if (Env::v('action') || !$cache_exists) {
- if ($cache_exists && !$feed) {
- unlink($wiki_cache);
- $files = glob($globals->spoolroot . '/spool/templates_c/*cache_' . wiki_filename($n) . '.tpl*');
- foreach ($files as $file) {
- unlink($file);
- }
- }
-
- // we leave pmwiki do whatever it wants and store everything
- ob_start();
- require_once($globals->spoolroot.'/wiki/pmwiki.php');
-
- $wikiAll = ob_get_clean();
- pl_clear_errors();
-
- // the pmwiki skin we are using (almost empty) has these keywords:
- $i = strpos($wikiAll, "<!--/HeaderText-->");
- $j = strpos($wikiAll, "<!--/PageLeftFmt-->", $i);
-}
-
-$wiki_exists = file_exists(wiki_work_dir() . '/' . wiki_filename($n));
-
-if ($feed) {
- $wikiAll = str_replace('dc:contributor', 'author', $wikiAll);
- $wikiAll = preg_replace('!<author>.*?\..*?\.(\d{4})\|(.*?)</author>!u', '<author>$2 (X$1)</author>', $wikiAll);
- $wikiAll = str_replace('<link>./', '<link>' . $globals->baseurl . '/' . $platal->ns, $wikiAll);
- echo $wikiAll;
- pl_clear_errors();
- exit;
-} elseif (Env::v('action')) {
- $page->assign('xorg_extra_header', substr($wikiAll, 0, $i));
- $wikiAll = substr($wikiAll, $j);
-} else {
- if (!$cache_exists && $wiki_exists) {
- $wikiAll = substr($wikiAll, $j);
- wiki_putfile($wiki_cache, $wikiAll);
- } elseif ($cache_exists) {
- $wikiAll = file_get_contents($wiki_cache);
- } elseif (S::has_perms()) {
- $wikiAll = "<p>La page de wiki $n n'existe pas. "
- . "Il te suffit de <a href='" . str_replace('.', '/', $n) . "?action=edit'>l'éditer</a></p>";
- } else {
- $page->changeTpl('core/404.tpl');
- }
-}
-
-// Check user perms
-wiki_apply_perms($perms[0]);
-
-$page->assign('perms', $perms);
-$page->assign('perms_opts', wiki_perms_options());
-
-$page->assign('canedit', wiki_may_have_perms($perms[1]));
-$page->assign('has_perms', wiki_may_have_perms('admin'));
-
-$page->assign('wikipage', str_replace('.', '/', $n));
-if (!$feed && $perms[1] == 'admin' && !Env::v('action') && $wiki_exists) {
- $page->assign('pmwiki_cache', $wiki_cache);
-} else {
- $page->assign('pmwiki', $wikiAll);
- $page->assign('text', true);
-}
-$page->addCssLink('wiki.css');
-$page->addJsLink('wiki.js');
-if (!Env::v('action')) {
- $url = '/' . str_replace('.', '/', $n) . '?action=rss';
- if (S::logged()) {
- $url .= '&user=' . S::v('forlife') . '&hash=' . S::v('core_rss_hash');
- }
- $page->setRssLink($n, $url);
-}
-
-$page->run();
-
-// vim:set et sw=4 sts=4 sws=4 foldmethod=marker enc=utf-8:
-?>
* 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA *
***************************************************************************/
-require_once('platal.inc.php');
-require_once('globals.inc.php');
-require_once('xnet/session.inc.php');
-$globals = new PlatalGlobals('XnetSession');
-XnetSession::init();
+define('PL_GLOBALS_CLASS', 'PlatalGlobals');
+define('PL_SESSION_CLASS', 'XnetSession');
+define('PL_PAGE_CLASS', 'XnetPage');
-function new_skinned_page($tpl_name)
-{
- global $page;
- require_once("xnet/page.inc.php");
- if (!$page instanceof XnetPage) {
- $page = new XnetPage($tpl_name);
- } else {
- $page->changeTpl($tpl_name);
- }
-}
+require_once dirname(dirname(__FILE__)) . '/core/include/platal.inc.php';
+require_once 'common.inc.php';
// vim:set et sw=4 sts=4 sws=4 foldmethod=marker enc=utf-8:
?>
* 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA *
***************************************************************************/
-require_once('platal.inc.php');
-require_once('globals.inc.php');
-require_once('xorg/session.inc.php');
-$globals = new PlatalGlobals('XorgSession');
-$globals->bootstrap(array('NbIns'), 'update_NbIns');
-$globals->bootstrap(array('NbValid'), 'update_NbValid');
+define('PL_GLOBALS_CLASS', 'PlatalGlobals');
+define('PL_SESSION_CLASS', 'XorgSession');
+define('PL_PAGE_CLASS', 'XorgPage');
-// {{{ class XorgPage
-
-class XorgPage extends PlatalPage
-{
- public function __construct($tpl, $type = SKINNED)
- {
- parent::__construct($tpl, $type);
- }
-
- public function run()
- {
- global $globals, $platal;
- $this->assign('globals', $globals);
- if (isset($platal) && $platal->path == 'register') {
- $skin = $globals->register_skin . ".tpl";
- } else {
- $skin = S::v('skin', $globals->skin . ".tpl");
- }
- $this->_run('skin/' . $skin);
- }
-}
-
-// {{{ function new_skinned_page()
-
-function new_skinned_page($tpl_name)
-{
- global $page;
- if (!$page instanceof XorgPage) {
- $page = new XorgPage($tpl_name);
- } else {
- $page->changeTpl($tpl_name);
- }
-}
-
-XorgSession::init();
+require_once dirname(dirname(__FILE__)) . '/core/include/platal.inc.php';
+require_once 'security.inc.php';
+require_once 'common.inc.php';
// vim:set et sw=4 sts=4 sws=4 foldmethod=marker enc=utf-8:
?>
+++ /dev/null
-<?php
-/***************************************************************************
- * Copyright (C) 2003-2008 Polytechnique.org *
- * http://opensource.polytechnique.org/ *
- * *
- * This program is free software; you can redistribute it and/or modify *
- * it under the terms of the GNU General Public License as published by *
- * the Free Software Foundation; either version 2 of the License, or *
- * (at your option) any later version. *
- * *
- * This program is distributed in the hope that it will be useful, *
- * but WITHOUT ANY WARRANTY; without even the implied warranty of *
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
- * GNU General Public License for more details. *
- * *
- * You should have received a copy of the GNU General Public License *
- * along with this program; if not, write to the Free Software *
- * Foundation, Inc., *
- * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA *
- ***************************************************************************/
-
-function quoted_printable_encode($input, $line_max = 76)
-{
- $lines = preg_split("/(?:\r\n|\r|\n)/", $input);
- $eol = "\n";
- $linebreak = "=0D=0A=\n ";
- $escape = "=";
- $output = "";
-
- foreach ($lines as $j => $line) {
- $linlen = strlen($line);
- $newline = "";
- for($i = 0; $i < $linlen; $i++) {
- $c = $line{$i};
- $dec = ord($c);
- if ( ($dec == 32) && ($i == ($linlen - 1)) ) {
- // convert space at eol only
- $c = "=20";
- } elseif ( ($dec == 61) || ($dec < 32 ) || ($dec > 126) ) {
- // always encode "\t", which is *not* required
- $c = $escape.strtoupper(sprintf("%02x",$dec));
- }
- if ( (strlen($newline) + strlen($c)) >= $line_max ) { // CRLF is not counted
- $output .= $newline.$escape.$eol;
- $newline = " ";
- }
- $newline .= $c;
- } // end of for
- $output .= $newline;
- if ($j<count($lines)-1) $output .= $linebreak;
- }
- return trim($output);
-}
-
-/** vérifie si une adresse email convient comme adresse de redirection
- * @param $email l'adresse email a verifier
- * @return BOOL
- */
-function isvalid_email_redirection($email)
-{
- return isvalid_email($email) &&
- !preg_match("/@(polytechnique\.(org|edu)|melix\.(org|net)|m4x\.org)$/", $email);
-}
-
-/** genere une chaine aleatoire de 22 caracteres ou moins
- * @param $len longueur souhaitée, 22 par défaut
- * @return la chaine aleatoire qui contient les caractères [A-Za-z0-9+/]
- */
-function rand_token($len = 22)
-{
- $len = max(2, $len);
- $len = min(50, $len);
- $fp = fopen('/dev/urandom', 'r');
- // $len * 2 is certainly an overkill,
- // but HEY, reading 40 bytes from /dev/urandom is not that slow !
- $token = fread($fp, $len * 2);
- fclose($fp);
- $token = base64_encode($token);
- $token = preg_replace("![Il10O+/]!", "", $token);
- $token = substr($token,0,$len);
- return $token;
-}
-
-/** genere une chaine aleatoire convenable pour une url
- * @param $len longueur souhaitée, 22 par défaut
- * @return la chaine aleatoire
- */
-function rand_url_id($len = 22)
-{
- return rand_token($len);
-}
-
-
-/** genere une chaine aleatoire convenable pour un mot de passe
- * @return la chaine aleatoire
- */
-function rand_pass()
-{
- return rand_token(8);
-}
-
-/** Remove accent from a string and replace them by the nearest letter
- */
-global $lc_convert, $uc_convert;
-$lc_convert = array('é' => 'e', 'è' => 'e', 'ë' => 'e', 'ê' => 'e',
- 'á' => 'a', 'à' => 'a', 'ä' => 'a', 'â' => 'a', 'å' => 'a', 'ã' => 'a',
- 'ï' => 'i', 'î' => 'i', 'ì' => 'i', 'í' => 'i',
- 'ô' => 'o', 'ö' => 'o', 'ò' => 'o', 'ó' => 'o', 'õ' => 'o', 'ø' => 'o',
- 'ú' => 'u', 'ù' => 'u', 'û' => 'u', 'ü' => 'u',
- 'ç' => 'c', 'ñ' => 'n');
-$uc_convert = array('É' => 'E', 'È' => 'E', 'Ë' => 'E', 'Ê' => 'E',
- 'Á' => 'A', 'À' => 'A', 'Ä' => 'A', 'Â' => 'A', 'Å' => 'A', 'Ã' => 'A',
- 'Ï' => 'I', 'Î' => 'I', 'Ì' => 'I', 'Í' => 'I',
- 'Ô' => 'O', 'Ö' => 'O', 'Ò' => 'O', 'Ó' => 'O', 'Õ' => 'O', 'Ø' => 'O',
- 'Ú' => 'U', 'Ù' => 'U', 'Û' => 'U', 'Ü' => 'U',
- 'Ç' => 'C', 'Ñ' => 'N');
-
-function replace_accent($string)
-{
- global $lc_convert, $uc_convert;
- $string = strtr($string, $lc_convert);
- return strtr($string, $uc_convert);
-}
-
-/** creates a username from a first and last name
- *
- * @param $prenom the firstname
- * @param $nom the last name
- *
- * return STRING the corresponding username
- */
-function make_username($prenom,$nom)
-{
- /* on traite le prenom */
- $prenomUS=replace_accent(trim($prenom));
- $prenomUS=stripslashes($prenomUS);
-
- /* on traite le nom */
- $nomUS=replace_accent(trim($nom));
- $nomUS=stripslashes($nomUS);
-
- // calcul du login
- $username = strtolower($prenomUS.".".$nomUS);
- $username = str_replace(" ","-",$username);
- $username = str_replace("'","",$username);
- return $username;
-}
-
-/* Un soundex en français posté par Frédéric Bouchery
- Voici une adaptation en PHP de la fonction soundex2 francisée de Frédéric BROUARD (http://sqlpro.developpez.com/Soundex/).
- C'est une bonne démonstration de la force des expressions régulières compatible Perl.
-trouvé sur http://expreg.com/voirsource.php?id=40&type=Chaines%20de%20caract%E8res */
-function soundex_fr($sIn)
-{
- static $convVIn, $convVOut, $convGuIn, $convGuOut, $accents;
- if (!isset($convGuIn)) {
- global $uc_convert, $lc_convert;
- $convGuIn = array( 'GUI', 'GUE', 'GA', 'GO', 'GU', 'SCI', 'SCE', 'SC', 'CA', 'CO',
- 'CU', 'QU', 'Q', 'CC', 'CK', 'G', 'ST', 'PH');
- $convGuOut = array( 'KI', 'KE', 'KA', 'KO', 'K', 'SI', 'SE', 'SK', 'KA', 'KO',
- 'KU', 'K', 'K', 'K', 'K', 'J', 'T', 'F');
- $convVIn = array( '/E?(AU)/', '/([EA])?[UI]([NM])([^EAIOUY]|$)/', '/[AE]O?[NM]([^AEIOUY]|$)/',
- '/[EA][IY]([NM]?[^NM]|$)/', '/(^|[^OEUIA])(OEU|OE|EU)([^OEUIA]|$)/', '/OI/',
- '/(ILLE?|I)/', '/O(U|W)/', '/O[NM]($|[^EAOUIY])/', '/(SC|S|C)H/',
- '/([^AEIOUY1])[^AEIOUYLKTPNR]([UAO])([^AEIOUY])/', '/([^AEIOUY]|^)([AUO])[^AEIOUYLKTP]([^AEIOUY1])/', '/^KN/',
- '/^PF/', '/C([^AEIOUY]|$)/',
- '/C/', '/Z$/', '/(?<!^)Z+/', '/ER$/', '/H/', '/W/');
- $convVOut = array( 'O', '1\3', 'A\1',
- 'E\1', '\1E\3', 'O',
- 'Y', 'U', 'O\1', '9',
- '\1\2\3', '\1\2\3', 'N',
- 'F', 'K\1',
- 'S', 'SE', 'S', 'E', '', 'V');
- $accents = $uc_convert + $lc_convert;
- $accents['Ç'] = 'S';
- $accents['¿'] = 'E';
- }
- // Si il n'y a pas de mot, on sort immédiatement
- if ( $sIn === '' ) return ' ';
- // On supprime les accents
- $sIn = strtr( $sIn, $accents);
- // On met tout en minuscule
- $sIn = strtoupper( $sIn );
- // On supprime tout ce qui n'est pas une lettre
- $sIn = preg_replace( '`[^A-Z]`', '', $sIn );
- // Si la chaîne ne fait qu'un seul caractère, on sort avec.
- if ( strlen( $sIn ) === 1 ) return $sIn . ' ';
- // on remplace les consonnances primaires
- $sIn = str_replace( $convGuIn, $convGuOut, $sIn );
- // on supprime les lettres répétitives
- $sIn = preg_replace( '`(.)\1`', '$1', $sIn );
- // on réinterprète les voyelles
- $sIn = preg_replace( $convVIn, $convVOut, $sIn);
- // on supprime les terminaisons T, D, S, X (et le L qui précède si existe)
- $sIn = preg_replace( '`L?[TDX]S?$`', '', $sIn );
- // on supprime les E, A et Y qui ne sont pas en première position
- $sIn = preg_replace( '`(?!^)Y([^AEOU]|$)`', '\1', $sIn);
- $sIn = preg_replace( '`(?!^)[EA]`', '', $sIn);
- return substr( $sIn . ' ', 0, 4);
-}
-
-/** met les majuscules au debut de chaque atome du prénom
- * @param $prenom le prénom à formater
- * return STRING le prénom avec les majuscules
- */
-function make_firstname_case($prenom)
-{
- $prenom = strtolower($prenom);
- $pieces = explode('-',$prenom);
-
- foreach ($pieces as $piece) {
- $subpieces = explode("'",$piece);
- $usubpieces="";
- foreach ($subpieces as $subpiece)
- $usubpieces[] = ucwords($subpiece);
- $upieces[] = implode("'",$usubpieces);
- }
- return implode('-',$upieces);
-}
-
-
-function make_forlife($prenom, $nom, $promo)
-{
- $prenomUS = replace_accent(trim($prenom));
- $nomUS = replace_accent(trim($nom));
-
- $forlife = strtolower($prenomUS.".".$nomUS.".".$promo);
- $forlife = str_replace(" ","-",$forlife);
- $forlife = str_replace("'","",$forlife);
- return $forlife;
-}
-
-/** Convert ip to uint (to store it in a database)
- */
-function ip_to_uint($ip)
-{
- $part = explode('.', $ip);
- if (count($part) != 4) {
- return null;
- }
- $v = 0;
- $fact = 0x1000000;
- for ($i = 0 ; $i < 4 ; ++$i) {
- $v += $fact * $part[$i];
- $fact >>= 8;
- }
- return $v;
-}
-
-/** Convert uint to ip (to build a human understandable ip)
- */
-function uint_to_ip($uint)
-{
- return long2ip($uint);
-}
-
-
-/******************************************************************************
- * Security functions
- *****************************************************************************/
-
-function check_ip($level)
-{
- if (empty($_SERVER['REMOTE_ADDR'])) {
- return false;
- }
- if (empty($_SESSION['check_ip'])) {
- $ips = array();
- if (!empty($_SERVER['HTTP_X_FORWARDED_FOR'])) {
- $ips = explode(',', $_SERVER['HTTP_X_FORWARDED_FOR']);
- }
- $ips[] = $_SERVER['REMOTE_ADDR'];
- foreach ($ips as &$ip) {
- $ip = '(ip & mask) = (' . ip_to_uint($ip) . '& mask)';
- }
- $res = XDB::query('SELECT state, description
- FROM ip_watch
- WHERE ' . implode(' OR ', $ips) . '
- ORDER BY state DESC');
- if ($res->numRows()) {
- $state = $res->fetchOneAssoc();
- $_SESSION['check_ip'] = $state['state'];
- $_SESSION['check_ip_desc'] = $state['description'];
- } else {
- $_SESSION['check_ip'] = 'safe';
- }
- }
- $test = array();
- switch ($level) {
- case 'unsafe': $test[] = 'unsafe';
- case 'dangerous': $test[] = 'dangerous';
- case 'ban': $test[] = 'ban'; break;
- default: return false;
- }
- return in_array($_SESSION['check_ip'], $test);
-}
-
-function check_email($email, $message)
-{
- $res = XDB::query("SELECT state, description
- FROM emails_watch
- WHERE state != 'safe' AND email = {?}", $email);
- if ($res->numRows()) {
- send_warning_mail($message);
- return true;
- }
- return false;
-}
-
-function check_account()
-{
- return S::v('watch_account');
-}
-
-function check_redirect($red = null)
-{
- require_once 'emails.inc.php';
- if (is_null($red)) {
- $red = new Redirect(S::v('uid'));
- }
- if ($red->get_uid() == S::v('uid')) {
- $_SESSION['no_redirect'] = !$red->other_active('');
- $_SESSION['mx_failures'] = $red->get_broken_mx();
- }
-}
-
-function send_warning_mail($title)
-{
- global $globals;
- $mailer = new PlMailer();
- $mailer->setFrom("webmaster@" . $globals->mail->domain);
- $mailer->addTo($globals->core->admin_email);
- $mailer->setSubject("[Plat/al Security Alert] $title");
- $mailer->setTxtBody("Identifiants de session :\n" . var_export($_SESSION, true) . "\n\n"
- ."Identifiants de connexion :\n" . var_export($_SERVER, true));
- $mailer->send();
-}
-
-function kill_sessions()
-{
- assert(S::has_perms());
- shell_exec('sudo -u root ' . dirname(dirname(__FILE__)) . '/bin/kill_sessions.sh');
-}
-
-
-/******************************************************************************
- * Dynamic configuration update/edition stuff
- *****************************************************************************/
-
-function update_NbIns()
-{
- global $globals;
- $res = XDB::query("SELECT COUNT(*)
- FROM auth_user_md5
- WHERE perms IN ('admin','user') AND deces=0");
- $cnt = $res->fetchOneCell();
- $globals->change_dynamic_config(array('NbIns' => $cnt));
-}
-
-function update_NbValid()
-{
- global $globals;
- $res = XDB::query("SELECT COUNT(*)
- FROM requests");
- $globals->change_dynamic_config(array('NbValid' => $res->fetchOneCell()));
-}
-
-function update_NbNotifs()
-{
- require_once 'notifs.inc.php';
- $n = select_notifs(false, S::i('uid'), S::v('watch_last'), false);
- $_SESSION['notifs'] = $n->numRows();
-}
-
-// vim:set et sw=4 sts=4 sws=4 foldmethod=marker enc=utf-8:
-?>
+++ /dev/null
-<?php
-/***************************************************************************
- * Copyright (C) 2003-2008 Polytechnique.org *
- * http://opensource.polytechnique.org/ *
- * *
- * This program is free software; you can redistribute it and/or modify *
- * it under the terms of the GNU General Public License as published by *
- * the Free Software Foundation; either version 2 of the License, or *
- * (at your option) any later version. *
- * *
- * This program is distributed in the hope that it will be useful, *
- * but WITHOUT ANY WARRANTY; without even the implied warranty of *
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
- * GNU General Public License for more details. *
- * *
- * You should have received a copy of the GNU General Public License *
- * along with this program; if not, write to the Free Software *
- * Foundation, Inc., *
- * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA *
- ***************************************************************************/
-
-require_once 'xorg.misc.inc.php';
-
-class XorgSession
-{
- // {{{ public static function init
-
- public static function init()
- {
- S::init();
- if (!S::has('uid')) {
- try_cookie();
- }
- if ((check_ip('dangerous') && S::has('uid')) || check_account()) {
- $_SESSION['log']->log("view_page", $_SERVER['REQUEST_URI']);
- }
- }
-
- // }}}
- // {{{ public static function destroy()
-
- public static function destroy()
- {
- S::destroy();
- XorgSession::init();
- }
-
- // }}}
- // {{{ public static function doAuth()
-
- public static function doAuth($new_name = false)
- {
- global $globals;
- if (S::identified()) { // ok, c'est bon, on n'a rien à faire
- return true;
- }
-
- if (!Env::has('username') || !Env::has('response')
- || !S::has('challenge'))
- {
- return false;
- }
-
- // si on vient de recevoir une identification par passwordpromptscreen.tpl
- // ou passwordpromptscreenlogged.tpl
- if (S::has('suid')) {
- $suid = S::v('suid');
- $login = $uname = $suid['forlife'];
- $redirect = false;
- } else {
- $uname = Env::v('username');
-
- if (Env::v('domain') == "alias") {
- $res = XDB::query(
- "SELECT redirect
- FROM virtual
- INNER JOIN virtual_redirect USING(vid)
- WHERE alias LIKE {?}", $uname."@".$globals->mail->alias_dom);
- $redirect = $res->fetchOneCell();
- if ($redirect) {
- $login = substr($redirect, 0, strpos($redirect, '@'));
- } else {
- $login = "";
- }
- } else {
- $login = $uname;
- $redirect = false;
- }
- }
-
- $field = (!$redirect && preg_match('/^\d*$/', $uname)) ? 'id' : 'alias';
- $res = XDB::query(
- "SELECT u.user_id, u.password
- FROM auth_user_md5 AS u
- INNER JOIN aliases AS a ON ( a.id=u.user_id AND type!='homonyme' )
- WHERE a.$field = {?} AND u.perms IN('admin','user')", $login);
-
- $logger = S::v('log');
- if (list($uid, $password) = $res->fetchOneRow()) {
- require_once('secure_hash.inc.php');
- $expected_response = hash_encrypt("$uname:$password:".S::v('challenge'));
- // le password de la base est peut-être encore encodé en md5
- if (Env::v('response') != $expected_response) {
- $new_password = hash_xor(Env::v('xorpass'), $password);
- $expected_response = hash_encrypt("$uname:$new_password:".S::v('challenge'));
- if (Env::v('response') == $expected_response) {
- XDB::execute("UPDATE auth_user_md5 SET password = {?} WHERE user_id = {?}",
- $new_password, $uid);
- }
- }
- if (Env::v('response') == $expected_response) {
- if (Env::has('domain')) {
- if (($domain = Env::v('domain', 'login')) == 'alias') {
- setcookie('ORGdomain', "alias", (time()+25920000), '/', '', 0);
- } else {
- setcookie('ORGdomain', '', (time()-3600), '/', '', 0);
- }
- // pour que la modification soit effective dans le reste de la page
- $_COOKIE['ORGdomain'] = $domain;
- }
-
- S::kill('challenge');
- if ($logger) {
- $logger->log('auth_ok');
- }
- if (!start_connexion($uid, true)) {
- return false;
- }
- if (Env::v('remember', 'false') == 'true') {
- $cookie = hash_encrypt(S::v('password'));
- setcookie('ORGaccess',$cookie,(time()+25920000),'/','',0);
- if ($logger) {
- $logger->log("cookie_on");
- }
- } else {
- setcookie('ORGaccess', '', time() - 3600, '/', '', 0);
-
- if ($logger) {
- $logger->log("cookie_off");
- }
- }
- return true;
- } elseif ($logger) {
- $logger->log('auth_fail','bad password');
- }
- } elseif ($logger) {
- $logger->log('auth_fail','bad login');
- }
-
- return false;
- }
-
- // }}}
- // {{{ public static function doAuthCookie()
-
- /** Try to do a cookie-based authentication.
- *
- * @param page the calling page (by reference)
- */
- public static function doAuthCookie()
-
- {
- if (S::logged()) {
- return true;
- }
-
- if (Env::has('username') and Env::has('response')) {
- return XorgSession::doAuth();
- }
-
- if ($r = try_cookie()) {
- return XorgSession::doAuth(($r > 0));
- }
-
- return false;
- }
-
- // }}}
- // {{{ public static function make_perms()
-
- public static function &make_perms($perm)
- {
- $flags = new FlagSet();
- if ($perm == 'disabled' || $perm == 'ext') {
- return $flags;
- }
- $flags->addFlag(PERMS_USER);
- if ($perm == 'admin') {
- $flags->addFlag(PERMS_ADMIN);
- }
- return $flags;
- }
-
- // }}}
-}
-
-// {{{ function try_cookie()
-
-/** réalise la récupération de $_SESSION pour qqn avec cookie
- * @return int 0 if all OK, -1 if no cookie, 1 if cookie with bad hash,
- * -2 should not happen
- */
-function try_cookie()
-{
- if (Cookie::v('ORGaccess') == '' or !Cookie::has('ORGuid')) {
- return -1;
- }
-
- $res = @XDB::query(
- "SELECT user_id,password FROM auth_user_md5
- WHERE user_id = {?} AND perms IN('admin','user')",
- Cookie::i('ORGuid'));
-
- if ($res->numRows() != 0) {
- list($uid, $password) = $res->fetchOneRow();
- require_once('secure_hash.inc.php');
- $expected_value = hash_encrypt($password);
- if ($expected_value == Cookie::v('ORGaccess')) {
- if (!start_connexion($uid, false)) {
- return -3;
- }
- return 0;
- } else {
- return 1;
- }
- }
-
- return -2;
-}
-
-// }}}
-// {{{ function start_connexion()
-
-/** place les variables de session dépendants de auth_user_md5
- * et met à jour les dates de dernière connexion si nécessaire
- * @return void
- * @see controlpermanent.inc.php controlauthentication.inc.php
- */
-function start_connexion ($uid, $identified)
-{
- $res = XDB::query("
- SELECT u.user_id AS uid, prenom, prenom_ini, nom, nom_ini, nom_usage, perms, promo, promo_sortie,
- matricule, password, FIND_IN_SET('femme', u.flags) AS femme,
- a.alias AS forlife, a2.alias AS bestalias,
- q.core_mail_fmt AS mail_fmt, UNIX_TIMESTAMP(q.banana_last) AS banana_last, q.watch_last, q.core_rss_hash,
- FIND_IN_SET('watch', u.flags) AS watch_account, q.last_version, g.g_account_name IS NOT NULL AS googleapps
- FROM auth_user_md5 AS u
- INNER JOIN auth_user_quick AS q USING(user_id)
- INNER JOIN aliases AS a ON (u.user_id = a.id AND a.type='a_vie')
- INNER JOIN aliases AS a2 ON (u.user_id = a2.id AND FIND_IN_SET('bestalias',a2.flags))
- LEFT JOIN gapps_accounts AS g ON (u.user_id = g.l_userid AND g.g_status = 'active')
- WHERE u.user_id = {?} AND u.perms IN('admin','user')", $uid);
- $sess = $res->fetchOneAssoc();
- $res = XDB::query("SELECT UNIX_TIMESTAMP(s.start) AS lastlogin, s.host
- FROM logger.sessions AS s
- WHERE s.uid = {?} AND s.suid = 0
- ORDER BY s.start DESC
- LIMIT 1", $uid);
- if ($res->numRows()) {
- $sess = array_merge($sess, $res->fetchOneAssoc());
- }
- $suid = S::v('suid');
-
- if ($suid) {
- $logger = new CoreLogger($uid, $suid['uid']);
- $logger->log("suid_start", S::v('forlife')." by {$suid['uid']}");
- $sess['suid'] = $suid;
- } else {
- $logger = S::v('log', new CoreLogger($uid));
- $logger->log("connexion", Env::v('n'));
- setcookie('ORGuid', $uid, (time()+25920000), '/', '', 0);
- }
-
- $_SESSION = array_merge($_SESSION, $sess);
- $_SESSION['log'] = $logger;
- $_SESSION['auth'] = ($identified ? AUTH_MDP : AUTH_COOKIE);
- $_SESSION['perms'] =& XorgSession::make_perms($_SESSION['perms']);
- $mail_subject = null;
- if (check_account()) {
- $mail_subject = "Connexion d'un utilisateur surveillé";
- }
- if (check_ip('unsafe')) {
- if ($mail_subject) {
- $mail_subject .= ' - ';
- }
- $mail_subject .= "Une IP surveillee a tente de se connecter";
- if (check_ip('ban')) {
- send_warning_mail($mail_subject);
- $_SESSION = array();
- $_SESSION['perms'] = new FlagSet();
- global $page;
- $newpage = false;
- if (!$page) {
- require_once 'xorg.inc.php';
- new_skinned_page('platal/index.tpl');
- $newpage = true;
- }
- $page->trigError("Une erreur est survenue lors de la procédure d'authentification. "
- ."Merci de contacter au plus vite "
- ."<a href='mailto:support@polytechnique.org'>support@polytechnique.org</a>");
- if ($newpage) {
- $page->run();
- }
- return false;
- }
- }
- if ($mail_subject) {
- send_warning_mail($mail_subject);
- }
- set_skin();
- update_NbNotifs();
- check_redirect();
- return true;
-}
-
-// }}}
-
-function set_skin()
-{
- global $globals;
- if (S::logged() && (!S::has('skin') || S::has('suid'))) {
- $uid = S::v('uid');
- $res = XDB::query("SELECT skin_tpl
- FROM auth_user_quick AS a
- INNER JOIN skins AS s ON a.skin = s.id
- WHERE user_id = {?} AND skin_tpl != ''", $uid);
- if ($_SESSION['skin'] = $res->fetchOneCell()) {
- return;
- }
- }
-}
-
-// vim:set et sw=4 sts=4 sws=4 foldmethod=marker enc=utf-8:
-?>
function handler_default(&$page)
{
$page->changeTpl('admin/index.tpl');
- $page->assign('xorg_title','Polytechnique.org - Administration');
+ $page->setTitle('Administration');
}
function handler_postfix_delayed(&$page)
{
$page->changeTpl('admin/postfix_delayed.tpl');
- $page->assign('xorg_title','Polytechnique.org - Administration - Postfix : Retardés');
+ $page->setTitle('Administration - Postfix : Retardés');
if (Env::has('del')) {
$crc = Env::v('crc');
function handler_postfix_regexpsbounces(&$page, $new = null) {
$page->changeTpl('admin/emails_bounces_re.tpl');
- $page->assign('xorg_title','Polytechnique.org - Administration - Postfix : Regexps Bounces');
+ $page->setTitle('Administration - Postfix : Regexps Bounces');
$page->assign('new', $new);
if (Post::has('submit')) {
$page->changeTpl('admin/logger-view.tpl');
- $page->assign('xorg_title','Polytechnique.org - Administration - Logs des sessions');
+ $page->setTitle('Administration - Logs des sessions');
}
function handler_user(&$page, $login = false)
{
global $globals;
$page->changeTpl('admin/utilisateurs.tpl');
- $page->assign('xorg_title','Polytechnique.org - Administration - Edit/Su/Log');
+ $page->setTitle('Administration - Edit/Su/Log');
require_once("emails.inc.php");
require_once("user.func.inc.php");
}
if(Env::has('suid_button') && $login) {
- $_SESSION['log']->log("suid_start", "login by ".S::v('forlife'));
- $_SESSION['suid'] = $_SESSION;
- $r = XDB::query("SELECT id FROM aliases WHERE alias={?}", $login);
+ S::logger()->log("suid_start", "login by ".S::v('forlife'));
+ $r = XDB::query("SELECT id
+ FROM aliases
+ WHERE alias={?}", $login);
if($uid = $r->fetchOneCell()) {
- start_connexion($uid, true);
- pl_redirect("");
+ if (!Platal::session()->startSUID($uid)) {
+ $page->trigError('Impossible d\'effectuer un SUID sur ' . $uid);
+ } else {
+ $page->kill("coucou");
+ pl_redirect("");
+ }
}
}
$mailer->send();
// update number of subscribers (perms or deceased may have changed)
- update_NbIns();
+ $globals->updateNbIns();
$page->trigSuccess("updaté correctement.");
}
if (Env::v('nomusageN') != $mr['nom_usage']) {
- require_once "xorg.misc.inc.php";
set_new_usage($mr['user_id'], Env::v('nomusageN'), make_username(Env::v('prenomN'), Env::v('nomusageN')));
}
if (Env::v('decesN') != $mr['deces']) {
case "u_kill":
user_clear_all_subs($mr['user_id']);
// update number of subscribers (perms or deceased may have changed)
- update_NbIns();
+ $globals->updateNbIns();
$page->trigSuccess("'{$mr['user_id']}' a été désinscrit !");
$mailer = new PlMailer("admin/useredit.mail.tpl");
$mailer->assign("admin", S::v('forlife'));
function handler_homonyms(&$page, $op = 'list', $target = null) {
$page->changeTpl('admin/homonymes.tpl');
- $page->assign('xorg_title','Polytechnique.org - Administration - Homonymes');
+ $page->setTitle('Administration - Homonymes');
require_once("homonymes.inc.php");
if ($target) {
function handler_ax_xorg(&$page) {
$page->changeTpl('admin/ax-xorg.tpl');
- $page->assign('xorg_title','Polytechnique.org - Administration - AX/X.org');
+ $page->setTitle('Administration - AX/X.org');
// liste des différences
$res = XDB::query(
function handler_deaths(&$page, $promo = 0, $validate = false) {
$page->changeTpl('admin/deces_promo.tpl');
- $page->assign('xorg_title','Polytechnique.org - Administration - Deces');
+ $page->setTitle('Administration - Deces');
if (!$promo)
$promo = Env::i('promo');
function handler_dead_but_active(&$page) {
$page->changeTpl('admin/dead_but_active.tpl');
- $page->assign('xorg_title','Polytechnique.org - Administration - Décédés');
+ $page->setTitle('Administration - Décédés');
$res = XDB::iterator(
"SELECT u.promo, u.nom, u.prenom, u.deces, u.matricule_ax, a.alias, DATE(MAX(s.start)) AS last
function handler_synchro_ax(&$page, $user = null, $action = null) {
$page->changeTpl('admin/synchro_ax.tpl');
- $page->assign('xorg_title','Polytechnique.org - Administration - Synchro AX');
+ $page->setTitle('Administration - Synchro AX');
require_once('synchro_ax.inc.php');
function handler_validate(&$page, $action = 'list', $id = null)
{
$page->changeTpl('admin/valider.tpl');
- $page->assign('xorg_title','Polytechnique.org - Administration - Valider une demande');
+ $page->setTitle('Administration - Valider une demande');
$page->addCssLink('nl.css');
$page->addJsLink('ajax.js');
require_once("validations.inc.php");
// Update the count of item to validate here... useful in development configuration
// where several copies of the site use the same DB, but not the same "dynamic configuration"
- update_NbValid();
+ global $globals;
+ $globals->updateNbValid();
$page->assign('vit', new ValidateIterator());
}
function handler_validate_answers(&$page, $action = 'list', $id = null) {
- $page->assign('xorg_title','Polytechnique.org - Administration - Réponses automatiques de validation');
+ $page->setTitle('Administration - Réponses automatiques de validation');
$page->assign('title', 'Gestion des réponses automatiques');
$table_editor = new PLTableEditor('admin/validate/answers','requests_answers','id');
$table_editor->describe('category','catégorie',true);
$table_editor->apply($page, $action, $id);
}
function handler_skins(&$page, $action = 'list', $id = null) {
- $page->assign('xorg_title','Polytechnique.org - Administration - Skins');
+ $page->setTitle('Administration - Skins');
$page->assign('title', 'Gestion des skins');
$table_editor = new PLTableEditor('admin/skins','skins','id');
$table_editor->describe('name','nom',true);
}
function handler_postfix_blacklist(&$page, $action = 'list', $id = null) {
- $page->assign('xorg_title','Polytechnique.org - Administration - Postfix : Blacklist');
+ $page->setTitle('Administration - Postfix : Blacklist');
$page->assign('title', 'Blacklist de postfix');
$table_editor = new PLTableEditor('admin/postfix/blacklist','postfix_blacklist','email', true);
$table_editor->describe('reject_text','Texte de rejet',true);
$table_editor->apply($page, $action, $id);
}
function handler_postfix_whitelist(&$page, $action = 'list', $id = null) {
- $page->assign('xorg_title','Polytechnique.org - Administration - Postfix : Whitelist');
+ $page->setTitle('Administration - Postfix : Whitelist');
$page->assign('title', 'Whitelist de postfix');
$table_editor = new PLTableEditor('admin/postfix/whitelist','postfix_whitelist','email', true);
$table_editor->describe('email','email',true);
$table_editor->apply($page, $action, $id);
}
function handler_mx_broken(&$page, $action = 'list', $id = null) {
- $page->assign('xorg_title', 'Polytechnique.org - Administration - MX Défaillants');
+ $page->setTitle('Administration - MX Défaillants');
$page->assign('title', 'MX Défaillant');
$table_editor = new PLTableEditor('admin/mx/broken', 'mx_watch', 'host', true);
$table_editor->describe('host', 'Masque', true);
$table_editor->apply($page, $action, $id);
}
function handler_logger_actions(&$page, $action = 'list', $id = null) {
- $page->assign('xorg_title','Polytechnique.org - Administration - Actions');
+ $page->setTitle('Administration - Actions');
$page->assign('title', 'Gestion des actions de logger');
$table_editor = new PLTableEditor('admin/logger/actions','logger.actions','id');
$table_editor->describe('text','intitulé',true);
$table_editor->apply($page, $action, $id);
}
function handler_downtime(&$page, $action = 'list', $id = null) {
- $page->assign('xorg_title','Polytechnique.org - Administration - Coupures');
+ $page->setTitle('Administration - Coupures');
$page->assign('title', 'Gestion des coupures');
$table_editor = new PLTableEditor('admin/downtime','coupures','id');
$table_editor->describe('debut','date',true);
$table_editor->apply($page, $action, $id);
}
- function handler_wiki(&$page, $action='list', $wikipage='', $wikipage2='')
+ function handler_wiki(&$page, $action = 'list', $wikipage = null, $wikipage2 = null)
{
- require_once 'wiki.inc.php';
-
if (S::v('core_rss_hash')) {
$page->setRssLink('Changement Récents',
'/Site/AllRecentChanges?action=rss&user=' . S::v('forlife') . '&hash=' . S::v('core_rss_hash'));
S::assert_xsrf_token();
$perms_read = Post::v('read');
- $perms_edot = Post::v('edit');
+ $perms_edit = Post::v('edit');
if ($perms_read || $perms_edit) {
- foreach ($_POST as $wiki_page => $val) if ($val == 'on') {
- $wiki_page = str_replace('_', '/', $wiki_page);
- if (!$perms_read || !$perms_edit)
- list($perms0, $perms1) = wiki_get_perms($wiki_page);
- if ($perms_read)
- $perms0 = $perms_read;
- if ($perms_edit)
- $perms1 = $perms_edit;
- wiki_set_perms($wiki_page, $perms0, $perms1);
+ foreach ($_POST as $wiki_page => $val) {
+ if ($val == 'on') {
+ $wp = new PlWikiPage(str_replace(array('_', '/'), '.', $wiki_page));
+ if ($wp->setPerms($perms_read ? $perms_read : $wp->readPerms(),
+ $perms_edit ? $perms_edit : $wp->writePerms())) {
+ $page->trigSuccess("Permission de la page $wiki_page mises à jour");
+ } else {
+ $page->trigError("Impossible de mettre les permissions de la page $wiki_page à jour");
+ }
+ }
}
}
- }
-
- if ($action == 'delete' && $wikipage != '') {
- S::assert_xsrf_token();
-
- if (wiki_delete_page($wikipage)) {
- $page->trigSuccess("La page ".$wikipage." a été supprimée.");
- } else {
- $page->trigError("Impossible de supprimer la page ".$wikipage.".");
- }
- }
-
- if ($action == 'rename' && $wikipage != '' && $wikipage2 != '' && $wikipage != $wikipage2) {
+ } else if ($action != 'list' && !empty($wikipage)) {
+ $wp = new PlWikiPage($wikipage);
S::assert_xsrf_token();
- if ($changedLinks = wiki_rename_page($wikipage, $wikipage2)) {
- $s = 'La page <em>'.$wikipage.'</em> a été déplacée en <em>'.$wikipage2.'</em>.';
- if (is_numeric($changedLinks)) {
- $s .= $changedLinks.' lien'.(($changedLinks>1)?'s ont été modifiés.':' a été modifié.');
+ if ($action == 'delete') {
+ if ($wp->delete()) {
+ $page->trigSuccess("La page ".$wikipage." a été supprimée.");
+ } else {
+ $page->trigError("Impossible de supprimer la page ".$wikipage.".");
+ }
+ } else if ($action == 'rename' && !empty($wikipage2) && $wikipage != $wikipage2) {
+ if ($changedLinks = $wp->rename($wikipage2)) {
+ $s = 'La page <em>'.$wikipage.'</em> a été déplacée en <em>'.$wikipage2.'</em>.';
+ if (is_numeric($changedLinks)) {
+ $s .= $changedLinks.' lien'.(($changedLinks>1)?'s ont été modifiés.':' a été modifié.');
+ }
+ $page->trigSuccess($s);
+ } else {
+ $page->trigError("Impossible de déplacer la page ".$wikipage);
}
- $page->trigSuccess($s);
- } else {
- $page->trigError("Impossible de déplacer la page ".$wikipage);
}
}
- $perms = wiki_perms_options();
+ $perms = PlWikiPage::permOptions();
// list wiki pages and their perms
- $wiki_pages = array();
- $dir = wiki_work_dir();
- if (is_dir($dir)) {
- if ($dh = opendir($dir)) {
- while (($file = readdir($dh)) !== false) if (substr($file,0,1) >= 'A' && substr($file,0,1) <= 'Z') {
- list($read,$edit) = wiki_get_perms($file);
- $wiki_pages[$file] = array('read' => $perms[$read], 'edit' => $perms[$edit]);
- if (is_file($dir . '/cache_' . wiki_filename($file) . '.tpl')) {
- $wiki_pages[$file]['cached'] = true;
- }
- }
- closedir($dh);
- }
- }
+ $wiki_pages = PlWikiPage::listPages();
ksort($wiki_pages);
$wiki_tree = array();
foreach ($wiki_pages as $file => $desc) {
function handler_groupex(&$page, $charset = 'utf8')
{
- require_once dirname(__FILE__).'/auth/auth.inc.php';
+ $this->load('auth.inc.php');
$page->assign('referer', true);
$gpex_pass = $_GET["pass"];
$uid = S::i('uid');
if (!isset($_SESSION['suid'])) {
$logger = (isset($_SESSION['log']) && $_SESSION['log']->uid == $uid)
- ? $_SESSION['log'] : new CoreLogger($uid);
+ ? $_SESSION['log'] : new PlLogger($uid);
global $platal;
- $logger->log('connexion_auth_ext', $platal->path);
+ S::logger()->log('connexion_auth_ext', $platal->path);
}
/* on parcourt les entrees de groupes_auth */
function handler_admin_authgroupesx(&$page, $action = 'list', $id = null)
{
- $page->assign('xorg_title','Polytechnique.org - Administration - Auth groupes X');
+ $page->setTitle('Administration - Auth groupes X');
$page->assign('title', 'Gestion de l\'authentification centralisée');
$table_editor = new PLTableEditor('admin/auth-groupes-x','groupesx_auth','id');
$table_editor->describe('name','nom',true);
return $this->handler_index($page, 'out');
}
}
- require_once dirname(__FILE__) . '/axletter/axletter.inc.php';
+ $this->load('axletter.inc.php');
$page->changeTpl('axletter/unsubscribe.tpl');
$page->assign('success', AXLetter::unsubscribe($hash, true));
}
function handler_index(&$page, $action = null)
{
- require_once dirname(__FILE__) . '/axletter/axletter.inc.php';
+ $this->load('axletter.inc.php');
$page->changeTpl('axletter/index.tpl');
- $page->assign('xorg_title','Polytechnique.org - Envois de l\'AX');
+ $page->setTitle('Envois de l\'AX');
switch ($action) {
case 'in': AXLetter::subscribe(); break;
function handler_submit(&$page, $action = null)
{
- require_once dirname(__FILE__) . '/axletter/axletter.inc.php';
+ $this->load('axletter.inc.php');
if (!AXLetter::hasPerms()) {
return PL_FORBIDDEN;
}
switch (@Post::v('valid')) {
case 'Aperçu':
- require_once dirname(__FILE__) . '/axletter/axletter.inc.php';
+ $this->load('axletter.inc.php');
$al = new AXLetter(array($id, $short_name, $subject, $title, $body, $signature,
$promo_min, $promo_max, $echeance, 0, 'new'));
$al->toHtml($page, S::v('prenom'), S::v('nom'), S::v('femme'));
function handler_cancel(&$page, $force = null)
{
- require_once dirname(__FILE__) . '/axletter/axletter.inc.php';
+ $this->load('axletter.inc.php');
if (!AXLetter::hasPerms() || !S::has_xsrf_token()) {
return PL_FORBIDDEN;
}
function handler_valid(&$page, $force = null)
{
- require_once dirname(__FILE__) . '/axletter/axletter.inc.php';
+ $this->load('axletter.inc.php');
if (!AXLetter::hasPerms() || !S::has_xsrf_token()) {
return PL_FORBIDDEN;
}
function handler_show(&$page, $nid = 'last')
{
- require_once dirname(__FILE__) . '/axletter/axletter.inc.php';
+ $this->load('axletter.inc.php');
$page->changeTpl('axletter/show.tpl');
$nl = new AXLetter($nid);
function handler_admin(&$page, $action = null, $uid = null)
{
- require_once dirname(__FILE__) . '/axletter/axletter.inc.php';
+ $this->load('axletter.inc.php');
if (Post::has('action')) {
$action = Post::v('action');
$uid = Post::v('uid');
);
}
- function on_subscribe($forlife, $uid, $promo, $password)
- {
- require_once 'notifs.inc.php';
- register_watch_op($uid, WATCH_INSCR);
- inscription_notifs_base($uid);
- }
-
function _add_rss_link(&$page)
{
if (!S::has('core_rss_hash')) {
function handler_index(&$page)
{
$page->changeTpl('carnet/index.tpl');
- $page->assign('xorg_title','Polytechnique.org - Mon carnet');
+ $page->setTitle('Mon carnet');
$this->_add_rss_link($page);
}
$page->changeTpl('carnet/panel.tpl');
if (Get::has('read')) {
- $_SESSION['watch_last'] = Get::v('read');
- update_NbNotifs();
+ S::set('watch_last', Get::v('read'));
+ Platal::session()->updateNbNotifs();
pl_redirect('carnet/panel');
}
}
function searchErrorHandler($explain) {
- global $page;
+ $page =& Platal::page();
$page->trigError($explain);
$this->handler_contacts($page);
}
function handler_contacts(&$page, $action = null, $subaction = null, $ssaction = null)
{
- $page->assign('xorg_title','Polytechnique.org - Mes contacts');
+ $page->setTitle('Mes contacts');
$this->_add_rss_link($page);
$uid = S::v('uid');
require_once 'userset.inc.php';
$base = 'carnet/contacts/search';
- require_once(dirname(__FILE__) . '/search/classes.inc.php');
+ Platal::load('search', 'classes.inc.php');
ThrowError::$throwHook = array($this, 'searchErrorHandler');
$view = new SearchSet(true, false, "INNER JOIN contacts AS c2 ON (u.user_id = c2.contact)", "c2.uid = $uid");
} else {
function handler_pdf(&$page, $arg0 = null, $arg1 = null)
{
- require_once dirname(__FILE__).'/carnet/contacts.pdf.inc.php';
+ $this->load('contacts.pdf.inc.php');
require_once 'user.func.inc.php';
- session_write_close();
+ Platal::session()->close();
$sql = "SELECT a.alias
FROM aliases AS a
function handler_rss(&$page, $user = null, $hash = null)
{
- require_once 'rss.inc.php';
- require_once 'notifs.inc.php';
-
- $uid = init_rss('carnet/rss.tpl', $user, $hash);
- $notifs = new Notifs($uid, false);
- $page->assign('notifs', $notifs);
+ $this->load('feed.inc.php');
+ $feed = new CarnetFeed();
+ return $feed->run($page, $user, $hash);
}
function handler_ical(&$page, $alias = null, $hash = null)
if (!$uid) {
$uid = S::i('uid');
} else if ($uid != S::i('uid')) {
- require_once 'xorg.misc.inc.php';
send_warning_email("Récupération d\'un autre utilisateur ($uid)");
}
} else if (!$uid) {
$res = XDB::query('SELECT contact
FROM contacts
WHERE uid = {?}', S::v('uid'));
- $vcard = new VCard($res->fetchColumn(), $photos == 'photos');
- $vcard->do_page(&$page);
+ $vcard = new VCard($photos == 'photos');
+ $vcard->addUsers($res->fetchColumn());
+ $vcard->show();
}
}
--- /dev/null
+<?php
+/***************************************************************************
+ * Copyright (C) 2003-2008 Polytechnique.org *
+ * http://opensource.polytechnique.org/ *
+ * *
+ * This program is free software; you can redistribute it and/or modify *
+ * it under the terms of the GNU General Public License as published by *
+ * the Free Software Foundation; either version 2 of the License, or *
+ * (at your option) any later version. *
+ * *
+ * This program is distributed in the hope that it will be useful, *
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of *
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
+ * GNU General Public License for more details. *
+ * *
+ * You should have received a copy of the GNU General Public License *
+ * along with this program; if not, write to the Free Software *
+ * Foundation, Inc., *
+ * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA *
+ ***************************************************************************/
+
+require_once 'notifs.inc.php';
+
+class CarnetFeedIterator implements PlIterator
+{
+ private $notifs;
+ private $it;
+
+ public function __construct(Notifs& $notifs)
+ {
+ $this->notifs =& $notifs;
+ $this->it = PlIteratorUtils::fromArray($notifs->_data, 3);
+ }
+
+ public function next()
+ {
+ $data = $this->it->next();
+ if (is_null($data)) {
+ return null;
+ }
+ $cid = $data['keys'][0];
+ $x = $data['value'];
+
+ global $globals;
+ @require_once 'Date.php';
+ @$date = new Date($x['date']);
+ @$date = $date->format('%e %B %Y');
+ $author = $x['prenom'] . ' ' . $x['nom'] . ' (X' . $x['promo'] . ')';
+ return array_merge($x,
+ array('author' => $author,
+ 'publication' => $x['known'],
+ 'id' => 'carnet' . $x['known'] . $cid . $x['bestalias'],
+ 'link' => $globals->baseurl . '/profile/private/'
+ . $x['bestalias'],
+ 'title' => '[' . $this->notifs->_cats[$cid]['short'] . '] '
+ . $author . ' - le ' . $date));
+ }
+
+ public function total()
+ {
+ return $this->it->total();
+ }
+
+ public function first()
+ {
+ return $this->it->first();
+ }
+
+ public function last()
+ {
+ return $this->it->last();
+ }
+}
+
+class CarnetFeed extends PlFeed
+{
+ public function __construct()
+ {
+ global $globals;
+ parent::__construct($globals->core->sitename . ' :: Carnet',
+ $globals->baseurl . '/carnet/panel',
+ 'Ton carnet polytechnicien',
+ $globals->baseurl . '/images/logo.png',
+ 'carnet/rss.tpl');
+ }
+
+ protected function fetch($user)
+ {
+ return new CarnetFeedIterator(new Notifs($user, false));
+ }
+}
+
+// vim:set et sw=4 sts=4 sws=4 foldmethod=marker enc=utf-8:
+?>
+++ /dev/null
-<?php
-/***************************************************************************
- * Copyright (C) 2003-2008 Polytechnique.org *
- * http://opensource.polytechnique.org/ *
- * *
- * This program is free software; you can redistribute it and/or modify *
- * it under the terms of the GNU General Public License as published by *
- * the Free Software Foundation; either version 2 of the License, or *
- * (at your option) any later version. *
- * *
- * This program is distributed in the hope that it will be useful, *
- * but WITHOUT ANY WARRANTY; without even the implied warranty of *
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
- * GNU General Public License for more details. *
- * *
- * You should have received a copy of the GNU General Public License *
- * along with this program; if not, write to the Free Software *
- * Foundation, Inc., *
- * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA *
- ***************************************************************************/
-
-class CoreModule extends PLModule
-{
- function handlers()
- {
- return array(
- '403' => $this->make_hook('403', AUTH_PUBLIC),
- '404' => $this->make_hook('404', AUTH_PUBLIC),
- 'login' => $this->make_hook('login', AUTH_COOKIE),
- 'send_bug' => $this->make_hook('bug', AUTH_COOKIE),
- 'purge_cache' => $this->make_hook('purge_cache', AUTH_COOKIE, 'admin'),
- 'kill_sessions' => $this->make_hook('kill_sessions', AUTH_COOKIE, 'admin'),
- 'get_rights' => $this->make_hook('get_rights', AUTH_MDP, 'admin'),
-
- 'wiki_help' => $this->make_hook('wiki_help', AUTH_PUBLIC),
- 'wiki_preview' => $this->make_hook('wiki_preview', AUTH_COOKIE, 'user', NO_AUTH),
-
- 'valid.html' => $this->make_hook('valid', AUTH_PUBLIC),
- 'favicon.ico' => $this->make_hook('favicon', AUTH_PUBLIC),
- 'robots.txt' => $this->make_hook('robotstxt', AUTH_PUBLIC, 'user', NO_HTTPS),
- );
- }
-
- function handler_valid(&$page)
- {
- readfile($page->compile_dir.'/valid.html');
- exit;
- }
-
- function handler_403(&$page)
- {
- global $globals;
- header($_SERVER['SERVER_PROTOCOL'] . ' 403 Forbidden');
- $page->changeTpl('core/403.tpl');
- }
-
- function handler_404(&$page)
- {
- global $globals, $platal;
- header($_SERVER['SERVER_PROTOCOL'] . ' 404 Not Found');
- $page->changeTpl('core/404.tpl');
- $page->assign('near', $platal->near_hook());
- }
-
- function handler_login(&$page)
- {
- $allkeys = func_get_args();
- unset($allkeys[0]);
- $url = join('/',$allkeys);
- pl_redirect($url);
- }
-
- function handler_favicon(&$page)
- {
- $data = file_get_contents(dirname(__FILE__).'/../htdocs/images/favicon.ico');
- header('Content-Type: image/x-icon');
- echo $data;
- exit;
- }
-
- function handler_robotstxt(&$page)
- {
- global $globals;
- if (!$globals->core->restricted_platal) {
- return PL_NOT_FOUND;
- }
-
- header('Content-Type: text/plain');
- echo "User-agent: *\n";
- echo "Disallow: /\n";
- exit;
- }
-
- function handler_purge_cache(&$page)
- {
- require_once 'wiki.inc.php';
- S::assert_xsrf_token();
-
- $page->clear_compiled_tpl();
- wiki_clear_all_cache();
-
- http_redirect(empty($_SERVER['HTTP_REFERER']) ? './' : $_SERVER['HTTP_REFERER']);
- }
-
- function handler_kill_sessions(&$page)
- {
- kill_sessions();
- }
-
- function handler_get_rights(&$page, $level)
- {
- if (S::has('suid')) {
- $page->kill('Déjà en SUID');
- }
-
- if (isset($_SESSION['log'])) {
- $_SESSION['log']->log("suid_start", "login by ".S::v('forlife'));
- }
- $_SESSION['suid'] = $_SESSION;
- $_SESSION['perms'] =& XorgSession::make_perms($level);
-
- pl_redirect('/');
- }
-
- function handler_bug(&$page)
- {
- global $globals;
-
- if (empty($_SERVER['HTTP_REFERER'])) {
- // We don't have a valid referer, we need to use the url
- list($currentPage, $location) = explode('//', $_SERVER['REQUEST_URI'], 2);
-
- $location = 'http'.(empty($_SERVER['HTTPS']) ? '' : 's').'://'.$_SERVER['SERVER_NAME'].'/'.$location;
- } else {
- $location = $_SERVER['HTTP_REFERER'];
- }
-
- $page->changeTpl('core/bug.tpl', SIMPLE);
- $page->assign('location', $location);
- $page->addJsLink('close_on_esc.js');
-
- if (Env::has('send') && trim(Env::v('detailed_desc'))) {
- S::assert_xsrf_token();
-
- $body = wordwrap(Env::v('detailed_desc'), 78) . "\n\n"
- . "----------------------------\n"
- . "Page : " . Env::v('page') . "\n\n"
- . "Utilisateur : " . S::v('forlife') . "\n"
- . "Navigateur : " . $_SERVER['HTTP_USER_AGENT'] . "\n"
- . "Skin : " . S::v('skin') . "\n";
- $page->assign('bug_sent',1);
- $mymail = new PlMailer();
- $mymail->setFrom('"'.S::v('prenom').' '.S::v('nom').'" <'.S::v('bestalias').'@' . $globals->mail->domain . '>');
- $mymail->addTo('support+platal@' . $globals->mail->domain);
- $mymail->addCc('"'.S::v('prenom').' '.S::v('nom').'" <'.S::v('bestalias').'@' . $globals->mail->domain . '>');
- $mymail->setSubject('Plat/al '.Env::v('task_type').' : '.Env::v('item_summary'));
- $mymail->setTxtBody($body);
- $mymail->send();
- } elseif (Env::has('send')) {
- $page->trigError("Merci de remplir une explication du problème rencontré");
- }
- }
-
- function handler_wiki_help(&$page, $action = 'title')
- {
- $page->changeTpl('core/wiki.help.tpl', SIMPLE);
- $page->assign('wiki_help', MiniWiki::help($action == 'title'));
- }
-
- /// Shared handler for wiki syntax result preview
- function handler_wiki_preview(&$page, $action = 'title')
- {
- header('Content-Type: text/html; charset=utf-8');
- $text = Get::v('text');
- echo MiniWiki::wikiToHtml($text, $action == 'title');
- exit;
- }
-}
-
-// vim:set et sw=4 sts=4 sws=4 foldmethod=marker enc=utf-8:
-?>
require_once 'emails.inc.php';
$page->changeTpl('emails/index.tpl');
- $page->assign('xorg_title','Polytechnique.org - Mes emails');
+ $page->setTitle('Mes emails');
$uid = S::v('uid');
global $globals;
$page->changeTpl('emails/alias.tpl');
- $page->assign('xorg_title','Polytechnique.org - Alias melix.net');
+ $page->setTitle('Alias melix.net');
$uid = S::v('uid');
$forlife = S::v('forlife');
function handler_antispam(&$page, $statut_filtre = null)
{
require_once 'emails.inc.php';
- require_once('wiki.inc.php');
- wiki_require_page('Xorg.Antispam');
+ $wp = new PlWikiPage('Xorg.Antispam');
+ $wp->buildCache();
$page->changeTpl('emails/antispam.tpl');
function handler_submit(&$page)
{
- require_once('wiki.inc.php');
- wiki_require_page('Xorg.Mails');
+ $wp = new PlWikiPage('Xorg.Mails');
+ $wp->buildCache();
$page->changeTpl('emails/submit_spam.tpl');
if (Post::has('send_email')) {
$page->changeTpl('emails/send.tpl');
$page->addJsLink('ajax.js');
- $page->assign('xorg_title','Polytechnique.org - Envoyer un email');
+ $page->setTitle('Envoyer un email');
// action si on recoit un formulaire
if (Post::has('save')) {
function handler_broken(&$page, $warn = null, $email = null)
{
require_once 'emails.inc.php';
- require_once('wiki.inc.php');
- wiki_require_page('Xorg.PatteCassée');
+ $wp = new PlWikiPage('Xorg.PatteCassée');
+ $wp->buildCache();
global $globals;
return $res->fetchOneAssoc();
}
- private function upload_image(PlatalPage &$page, PlUpload &$upload)
+ private function upload_image(PlPage &$page, PlUpload &$upload)
{
if (@!$_FILES['image']['tmp_name'] && !Env::v('image_url')) {
return true;
// cache les evenements lus et raffiche les evenements a relire
if ($action == 'read' && $eid) {
- XDB::execute('DELETE evenements_vus.*
+ XDB::execute('DELETE ev.*
FROM evenements_vus AS ev
INNER JOIN evenements AS e ON e.id = ev.evt_id
WHERE peremption < NOW()');
function handler_rss(&$page, $user = null, $hash = null)
{
- require_once 'rss.inc.php';
-
- $uid = init_rss('events/rss.tpl', $user, $hash);
-
- $rss = XDB::iterator(
- 'SELECT e.id, e.titre, e.texte, e.creation_date, e.post_id, p.attachmime IS NOT NULL AS photo,
- IF(u2.nom_usage = "", u2.nom, u2.nom_usage) AS nom, u2.prenom, u2.promo,
- FIND_IN_SET(\'wiki\', e.flags) AS wiki
- FROM auth_user_md5 AS u
- INNER JOIN evenements AS e ON ( (e.promo_min = 0 || e.promo_min <= u.promo)
- AND (e.promo_max = 0 || e.promo_max >= u.promo) )
- LEFT JOIN evenements_photo AS p ON (p.eid = e.id)
- INNER JOIN auth_user_md5 AS u2 ON (u2.user_id = e.user_id)
- WHERE u.user_id = {?} AND FIND_IN_SET("valide", e.flags)
- AND peremption >= NOW()', $uid);
- $page->assign('rss', $rss);
+ $this->load('feed.inc.php');
+ $feed = new EventFeed();
+ return $feed->run($page, $user, $hash);
}
function handler_preview(&$page)
$page->changeTpl('events/submit.tpl');
$page->addJsLink('ajax.js');
- require_once('wiki.inc.php');
- wiki_require_page('Xorg.Annonce');
+ $wp = new PlWikiPage('Xorg.Annonce');
+ $wp->buildCache();
$titre = Post::v('titre');
$texte = Post::v('texte');
function handler_admin_tips(&$page, $action = 'list', $id = null)
{
- $page->assign('xorg_title', 'Polytechnique.org - Administration - Astuces');
+ $page->setTitle('Administration - Astuces');
$page->assign('title', 'Gestion des Astuces');
$table_editor = new PLTableEditor('admin/tips', 'tips', 'id');
$table_editor->describe('peremption', 'date de péremption', true);
{
$page->changeTpl('events/admin.tpl');
$page->addJsLink('ajax.js');
- $page->assign('xorg_title','Polytechnique.org - Administration - Evenements');
+ $page->setTitle('Administration - Evenements');
$page->register_modifier('hde', 'html_entity_decode');
$arch = $action == 'archives';
$action = 'edit';
} else {
$res = XDB::query('SELECT flags FROM evenements WHERE id = {?}', $eid);
- $flags = new FlagSet($res->fetchOneCell());
+ $flags = new PlFlagSet($res->fetchOneCell());
$flags->addFlag('wiki');
if (Post::v('important')) {
$flags->addFlag('important');
* 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA *
***************************************************************************/
-class PlProfiler
+class EventFeed extends PlFeed
{
- static public function start($name, $info = "action")
+ public function __construct()
{
global $globals;
- if (!($globals->debug & DEBUG_BT)) {
- return false;
- }
- if (!isset(PlBacktrace::$bt[$name])) {
- new PlBacktrace($name);
- }
- PlBacktrace::$bt[$name]->start($info);
- return true;
+ parent::__construct($globals->core->sitename . ' :: News',
+ $globals->baseurl,
+ 'Informations et Activités polytechniciennes',
+ $globals->baseurl . '/images/logo.png',
+ 'events/rss.tpl');
}
- static public function step($name, $info = "action")
- {
- PlProfiler::stop($name);
- PlProfiler::start($name, $info);
- }
-
- static public function stop($name)
+ protected function fetch($user)
{
global $globals;
- if (!($globals->debug & DEBUG_BT)) {
- return false;
- }
- PlBacktrace::$bt[$name]->stop();
- return true;
+ return XDB::iterator(
+ 'SELECT e.id, e.titre AS title, e.texte, e.creation_date AS publication, e.post_id, p.attachmime IS NOT NULL AS photo,
+ CONCAT(u2.prenom, " ", IF(u2.nom_usage = "", u2.nom, u2.nom_usage), " (X", u2.promo, ")") AS author,
+ FIND_IN_SET(\'wiki\', e.flags) AS wiki,
+ CONCAT({?}, "/events#newsid", e.id) AS link
+ FROM auth_user_md5 AS u
+ INNER JOIN evenements AS e ON ( (e.promo_min = 0 || e.promo_min <= u.promo)
+ AND (e.promo_max = 0 || e.promo_max >= u.promo) )
+ LEFT JOIN evenements_photo AS p ON (p.eid = e.id)
+ INNER JOIN auth_user_md5 AS u2 ON (u2.user_id = e.user_id)
+ WHERE u.user_id = {?} AND FIND_IN_SET("valide", e.flags)
+ AND peremption >= NOW()', $globals->baseurl, $user);
}
}
function handlers()
{
return array(
- 'banana' => $this->make_hook('banana', AUTH_COOKIE),
- 'banana/rss' => $this->make_hook('rss', AUTH_PUBLIC, 'user', NO_HTTPS),
+ 'banana' => $this->make_hook('banana', AUTH_COOKIE),
+ 'banana/rss' => $this->make_hook('rss', AUTH_PUBLIC, 'user', NO_HTTPS),
'admin/forums' => $this->make_hook('forums_bans', AUTH_MDP, 'admin'),
);
}
- function on_subscribe($forlife, $uid, $promo, $password)
- {
- $cible = array('xorg.general', 'xorg.pa.divers', 'xorg.pa.logements');
- $p_for = "xorg.promo.x$promo";
-
- // récupération de l'id du forum promo
- $res = XDB::query("SELECT fid FROM forums.list WHERE nom={?}", $p_for);
- if ($res->numRows()) {
- $cible[] = $p_for;
- } else { // pas de forum promo, il faut le créer
- $res = XDB::query("SELECT SUM(perms IN ('admin','user') AND deces=0),COUNT(*)
- FROM auth_user_md5 WHERE promo={?}", $promo);
- list($effau, $effid) = $res->fetchOneRow();
- if (5*$effau>$effid) { // + de 20% d'inscrits
- $mymail = new PlMailer('admin/forums-promo.mail.tpl');
- $mymail->assign('promo', $promo);
- $mymail->send();
- }
- }
-
- while (list ($key, $val) = each ($cible)) {
- XDB::execute("INSERT INTO forums.abos (fid,uid)
- SELECT fid,{?} FROM forums.list WHERE nom={?}", $uid, $val);
- }
- }
-
function handler_banana(&$page, $group = null, $action = null, $artid = null)
{
$page->changeTpl('banana/index.tpl');
- $page->assign('xorg_title','Polytechnique.org - Forums & PA');
+ $page->setTitle('Forums & PA');
$get = Array();
if (Post::has('updateall')) {
function handler_forums_bans(&$page, $action = 'list', $id = null)
{
- $page->assign('xorg_title','Polytechnique.org - Administration - Bannissements des forums');
+ $page->setTitle('Administration - Bannissements des forums');
$page->assign('title', 'Gestion des mises au ban');
$table_editor = new PLTableEditor('admin/forums','forums.innd','id_innd');
$table_editor->add_sort_field('priority', true, true);
static function run_banana(&$page, $params = null)
{
$page->changeTpl('banana/index.tpl');
- $page->assign('xorg_title','Polytechnique.org - Forums & PA');
+ $page->setTitle('Forums & PA');
require_once 'banana/forum.inc.php';
run_banana($page, 'ForumsBanana', $params);
// iGoogle gadgets helpers.
function init_igoogle_xml($template)
{
- global $page;
- $page->changeTpl($template, NO_SKIN);
+ Platal::page()->changeTpl($template, NO_SKIN);
header('Content-Type: application/xml; charset=utf-8');
}
function init_igoogle_html($template, $auth = AUTH_PUBLIC)
{
- global $page;
+ $page =& Platal::page();
$page->changeTpl('gadgets/ig-skin.tpl', NO_SKIN);
$page->register_modifier('escape_html', 'escape_html');
$page->default_modifiers = Array('@escape_html');
function handler_admin(&$page, $action = false) {
$page->changeTpl('geoloc/admin.tpl');
require_once("geoloc.inc.php");
- $page->assign('xorg_title','Polytechnique.org - Administration - Geolocalisation');
+ $page->setTitle('Administration - Geolocalisation');
$nb_synchro = 0;
$noCoordinates = $countNoCoordinates->fetchOneCell();
if (isset($refresh) && $missing) {
- $page->assign("xorg_extra_header", "<meta http-equiv='Refresh' content='3'/>");
+ $page->assign("pl_extra_header", "<meta http-equiv='Refresh' content='3'/>");
}
$page->assign("nb_cities_not_on_map", $missing);
$page->assign("no_smallest", $noSmallest);
require_once("googleapps.inc.php");
$page->changeTpl('googleapps/index.tpl');
$page->addJsLink('motdepasse.js');
- $page->assign('xorg_title', 'Polytechnique.org - Compte Google Apps');
+ $page->setTitle('Compte Google Apps');
$account = new GoogleAppsAccount(S::v('uid'), S::v('forlife'));
function handler_admin(&$page, $action = null) {
require_once("googleapps.inc.php");
$page->changeTpl('googleapps/admin.tpl');
- $page->assign('xorg_title', 'Polytechnique.org - Administration Google Apps');
+ $page->setTitle('Administration Google Apps');
$page->assign('googleapps_admin', GoogleAppsAccount::is_administrator(S::v('uid')));
if ($action == 'ack') {
function handler_admin_job(&$page, $job = null) {
require_once("googleapps.inc.php");
$page->changeTpl('googleapps/admin.job.tpl');
- $page->assign('xorg_title', 'Polytechnique.org - Administration Google Apps');
+ $page->setTitle('Administration Google Apps');
$page->assign('googleapps_admin', GoogleAppsAccount::is_administrator(S::v('uid')));
if ($job) {
require_once("emails.inc.php");
require_once("googleapps.inc.php");
$page->changeTpl('googleapps/admin.user.tpl');
- $page->assign('xorg_title', 'Polytechnique.org - Administration Google Apps');
+ $page->setTitle('Administration Google Apps');
$page->assign('googleapps_admin', GoogleAppsAccount::is_administrator(S::v('uid')));
if (!$user && Post::has('login')) {
);
}
- function on_subscribe($forlife, $uid, $promo, $password)
- {
- $this->prepare_client(null);
- $this->client->subscribe("promo$promo");
- }
-
function prepare_client(&$page)
{
global $globals;
- require_once dirname(__FILE__).'/lists/lists.inc.php';
+ $this->load('lists.inc.php');
$this->client = new MMList(S::v('uid'), S::v('password'));
return $globals->mail->domain;
$page->changeTpl('lists/index.tpl');
$page->addJsLink('ajax.js');
- $page->assign('xorg_title','Polytechnique.org - Listes de diffusion');
+ $page->setTitle('Listes de diffusion');
if (Get::has('del')) {
function handler_admin_all(&$page) {
$page->changeTpl('lists/admin_all.tpl');
- $page->assign('xorg_title','Polytechnique.org - Administration - Mailing lists');
+ $page->setTitle('Administration - Mailing lists');
$client = new MMList(S::v('uid'), S::v('password'));
$listes = $client->get_all_lists();
{
$page->changeTpl('marketing/index.tpl');
- $page->assign('xorg_title','Polytechnique.org - Marketing');
+ $page->setTitle('Marketing');
// Quelques statistiques
$page->assign('user', $user);
$email = null;
+ require_once 'emails.inc.php';
if (Post::has('mail')) {
- require_once 'emails.inc.php';
$email = valide_email(Post::v('mail'));
}
if (Post::has('valide') && isvalid_email_redirection($email)) {
if (Post::has('valide')) {
S::assert_xsrf_token();
-
- require_once('xorg.misc.inc.php');
$email = trim(Post::v('mail'));
+ require_once 'emails.inc.php';
if (!isvalid_email_redirection($email)) {
$page->trigError("Email invalide !");
} else {
require_once 'newsletter.inc.php';
$page->changeTpl('newsletter/index.tpl');
- $page->assign('xorg_title','Polytechnique.org - Lettres mensuelles');
+ $page->setTitle('Lettres mensuelles');
switch ($action) {
case 'out': Newsletter::unsubscribe(); break;
$page->changeTpl('newsletter/submit.tpl');
require_once 'newsletter.inc.php';
- require_once 'wiki.inc.php';
- wiki_require_page('Xorg.LettreMensuelle');
+ $wp = new PlWikiPage('Xorg.LettreMensuelle');
+ $wp->buildCache();
if (Post::has('see') || (Post::has('valid') && (!trim(Post::v('title')) || !trim(Post::v('body'))))) {
if (!Post::has('see')) {
function handler_admin_nl(&$page, $new = false) {
$page->changeTpl('newsletter/admin.tpl');
- $page->assign('xorg_title','Polytechnique.org - Administration - Newsletter : liste');
+ $page->setTitle('Administration - Newsletter : liste');
require_once("newsletter.inc.php");
if($new) {
function handler_admin_nl_edit(&$page, $nid = 'last', $aid = null, $action = 'edit') {
$page->changeTpl('newsletter/edit.tpl');
$page->addCssLink('nl.css');
- $page->assign('xorg_title','Polytechnique.org - Administration - Newsletter : Edition');
+ $page->setTitle('Administration - Newsletter : Edition');
require_once("newsletter.inc.php");
$nl = new NewsLetter($nid);
}
function handler_admin_nl_cat(&$page, $action = 'list', $id = null) {
- $page->assign('xorg_title','Polytechnique.org - Administration - Newsletter : Catégories');
+ $page->setTitle('Administration - Newsletter : Catégories');
$page->assign('title', 'Gestion des catégories de la newsletter');
$table_editor = new PLTableEditor('admin/newsletter/categories','newsletter_cat','cid');
$table_editor->describe('titre','intitulé',true);
/* sort en affichant une erreur */
function paypal_erreur($text, $send=true)
{
- global $page, $erreur, $globals;
+ global $erreur, $globals;
if ($erreur) return;
$erreur = $text;
if (!$send) return;
$mymail->setTxtBody("\n\n".var_export($_REQUEST,true));
$mymail->send();
- $page->trigError($text);
+ Platal::page()->trigError($text);
}
/* http://fr.wikipedia.org/wiki/Formule_de_Luhn */
global $globals;
require_once 'profil.func.inc.php' ;
- require_once dirname(__FILE__).'/payment/money.inc.php' ;
+ $this->load('money.inc.php');
if (!empty($GLOBALS['IS_XNET_SITE'])) {
if (!$globals->asso('id')) {
}
}
$page->changeTpl('payment/index.tpl');
- $page->assign('xorg_title','Polytechnique.org - Télépaiements');
+ $page->setTitle('Télépaiements');
// initialisation
$op = Env::v('op', 'select');
}
function handler_admin(&$page, $action = 'list', $id = null) {
- $page->assign('xorg_title','Polytechnique.org - Administration - Paiements');
+ $page->setTitle('Administration - Paiements');
$page->assign('title', 'Gestion des télépaiements');
$table_editor = new PLTableEditor('admin/payments','paiement.paiements','id');
$table_editor->add_join_table('paiement.transactions','ref',true);
$this->montant_min = (float)$this->montant_min;
$this->montant_max = (float)$this->montant_max;
- $this->flags = new Flagset($flags);
+ $this->flags = new PlFlagSet($flags);
}
// }}}
$name = $req->fetchOneCell();
// on constuit la reference de la transaction
- require_once 'xorg.misc.inc.php';
$prefix = ($pay->flags->hasflag('unique')) ? str_pad("",15,"0") : rand_url_id();
$fullref = substr("$prefix-xorg-{$pay->id}",-15);
$this->infos['client'] = array_map('replace_accent', array_merge($info_client, $res->fetchOneAssoc()));
// on constuit la reference de la transaction
- require_once 'xorg.misc.inc.php';
$prefix = ($pay->flags->hasflag('unique')) ? str_pad("",15,"0") : rand_url_id();
$fullref = substr("$prefix-xorg-{$pay->id}",-15);
function handler_prefs(&$page)
{
$page->changeTpl('platal/preferences.tpl');
- $page->assign('xorg_title','Polytechnique.org - Mes préférences');
+ $page->setTitle('Mes préférences');
if (Post::has('mail_fmt')) {
$fmt = Post::v('mail_fmt');
{
$page->changeTpl('platal/webredirect.tpl');
- $page->assign('xorg_title','Polytechnique.org - Redirection de page WEB');
+ $page->setTitle('Redirection de page WEB');
$log =& S::v('log');
$url = Env::v('url');
XDB::execute('UPDATE auth_user_quick
SET redirecturl = {?} WHERE user_id = {?}',
$url, S::v('uid'));
- $log->log('carva_add', 'http://'.Env::v('url'));
+ S::logger()->log('carva_add', 'http://'.Env::v('url'));
$page->trigSuccess("Redirection activée vers <a href='http://$url'>$url</a>");
} elseif (Env::v('submit') == "Supprimer") {
XDB::execute("UPDATE auth_user_quick
SET redirecturl = ''
WHERE user_id = {?}",
S::v('uid'));
- $log->log("carva_del", $url);
+ S::logger()->log("carva_del", $url);
Post::kill('url');
$page->trigSuccess('Redirection supprimée');
}
}
$log =& S::v('log');
- $log->log('passwd', '');
+ S::logger()->log('passwd', '');
if (Cookie::v('ORGaccess')) {
setcookie('ORGaccess', hash_encrypt($password), (time()+25920000), '/', '' ,0);
$page->changeTpl('platal/motdepasse.tpl');
$page->addJsLink('motdepasse.js');
- $page->assign('xorg_title','Polytechnique.org - Mon mot de passe');
+ $page->setTitle('Mon mot de passe');
}
function handler_smtppass(&$page)
{
$page->changeTpl('platal/acces_smtp.tpl');
- $page->assign('xorg_title','Polytechnique.org - Acces SMTP/NNTP');
+ $page->setTitle('Acces SMTP/NNTP');
- require_once 'wiki.inc.php';
- wiki_require_page('Xorg.SMTPSécurisé');
- wiki_require_page('Xorg.NNTPSécurisé');
+ $wp = new PlWikiPage('Xorg.SMTPSécurisé');
+ $wp->buildCache();
+ $wp = new PlWikiPage('Xorg.NNTPSécurisé');
+ $wp->buildCache();
$uid = S::v('uid');
$pass = Env::v('smtppass1');
XDB::execute('UPDATE auth_user_md5 SET smtppass = {?}
WHERE user_id = {?}', $pass, $uid);
$page->trigSuccess('Mot de passe enregistré');
- $log->log("passwd_ssl");
+ S::logger()->log("passwd_ssl");
} elseif (Env::v('op') == "Supprimer") {
XDB::execute('UPDATE auth_user_md5 SET smtppass = ""
WHERE user_id = {?}', $uid);
$page->trigSuccess('Compte SMTP et NNTP supprimé');
- $log->log("passwd_del");
+ S::logger()->log("passwd_del");
}
$res = XDB::query("SELECT IF(smtppass != '', 'actif', '')
$mymail->send();
// on cree un objet logger et on log l'evenement
- $logger = $_SESSION['log'] = new CoreLogger($uid);
- $logger->log('recovery', $mails);
+ $logger = $_SESSION['log'] = new PlLogger($uid);
+ S::logger()->log('recovery', $mails);
} else {
$page->trigError('Les informations que tu as rentrées ne permettent pas de récupérer ton mot de passe.<br />'.
'Si tu as un homonyme, utilise prenom.nom.promo comme login');
}
}
- $logger = new CoreLogger($uid);
- $logger->log("passwd","");
+ $logger = new PlLogger($uid);
+ S::logger()->log("passwd","");
$page->changeTpl('platal/tmpPWD.success.tpl');
} else {
$page->changeTpl('platal/motdepasse.tpl');
global $globals;
$page->changeTpl('platal/skins.tpl');
- $page->assign('xorg_title','Polytechnique.org - Skins');
+ $page->setTitle('Skins');
if (Env::has('newskin')) { // formulaire soumis, traitons les données envoyées
XDB::execute('UPDATE auth_user_quick
SET skin={?} WHERE user_id={?}',
Env::i('newskin'), S::v('uid'));
S::kill('skin');
- set_skin();
+ Platal::session()->setSkin();
}
$res = XDB::query('SELECT id FROM skins WHERE skin_tpl={?}', S::v('skin'));
$a4l = S::v('forlife');
$suid = S::v('suid');
$log = S::v('log');
- $log->log("suid_stop", S::v('forlife') . " by " . $suid['forlife']);
- $_SESSION = $suid;
- S::kill('suid');
+ S::logger()->log("suid_stop", S::v('forlife') . " by " . $suid['forlife']);
+ Platal::session()->stopSUID();
pl_redirect('admin/user/' . $a4l);
}
setcookie('ORGaccess', '', time() - 3600, '/', '', 0);
Cookie::kill('ORGaccess');
if (isset($_SESSION['log']))
- $_SESSION['log']->log("cookie_off");
+ S::logger()->log("cookie_off");
}
if ($level == 'forgetuid' || $level == 'forgetall') {
if (isset($_SESSION['log'])) {
$ref = isset($_SERVER['HTTP_REFERER']) ? $_SERVER['HTTP_REFERER'] : '';
- $_SESSION['log']->log('deconnexion',$ref);
+ S::logger()->log('deconnexion',$ref);
}
-
- XorgSession::destroy();
+ Platal::session()->destroy();
if (Get::has('redirect')) {
http_redirect(rawurldecode(Get::v('redirect')));
function handler_review(&$page, $action = null, $mode = null)
{
- require_once 'wiki.inc.php';
- require_once dirname(__FILE__) . '/platal/review.inc.php';
- $dir = wiki_work_dir();
+ $this->load('review.inc.php');
$dom = 'Review';
if (@$GLOBALS['IS_XNET_SITE']) {
$dom .= 'Xnet';
}
- if (!is_dir($dir)) {
- $page->kill("Impossible de trouver le wiki");
- }
- if (!file_exists($dir . '/' . $dom . '.Admin')) {
- $page->kill("Impossible de trouver la page d'administration");
- }
- $conf = preg_grep('/^text=/', explode("\n", file_get_contents($dir . '/' . $dom . '.Admin')));
- $conf = preg_split('/(text\=|\%0a)/', array_shift($conf), -1, PREG_SPLIT_NO_EMPTY);
- $wiz = new PlWizard('Tour d\'horizon', 'core/plwizard.tpl', true);
+ $wp = new PlWikiPage($dom . '.Admin');
+ $conf = explode('%0a', $wp->getField('text'));
+ $wiz = new PlWizard('Tour d\'horizon', PlPage::getCoreTpl('plwizard.tpl'), true);
foreach ($conf as $line) {
$list = preg_split('/\s*[*|]\s*/', $line, -1, PREG_SPLIT_NO_EMPTY);
$wiz->addPage('ReviewPage', $list[0], $list[1]);
public function template() { return 'platal/review.tpl'; }
public function process() { }
- public function prepare(PlatalPage &$page, $id)
+ public function prepare(PlPage &$page, $id)
{
- require_once 'wiki.inc.php';
- $dom = (@$GLOBALS['IS_XNET_SITE'] ? 'ReviewXnet' : 'Review') . '.' . ucfirst($id);
- wiki_require_page($dom);
- $page->assign('cacheExists', wiki_work_dir() . '/cache_' . $dom . '.tpl');
- $page->assign('article', $dom);
+ $wp = new PlWikiPage((@$GLOBALS['IS_XNET_SITE'] ? 'ReviewXnet' : 'Review') . '.' . ucfirst($id));
+ $wp->buildCache();
+ $page->assign('cacheExists', $wp->cacheFilename());
+ $page->assign('article', $wp->name);
}
}
function handler_photo_change(&$page)
{
+ global $globals;
$page->changeTpl('profile/trombino.tpl');
require_once('validations.inc.php');
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(*)
}
if (S::logged()) {
- $_SESSION['log']->log('view_profile', $login);
+ S::logger()->log('view_profile', $login);
}
$title = $user['prenom'] . ' ' . ( empty($user['nom_usage']) ? $user['nom'] : $user['nom_usage'] );
- $page->assign('xorg_title', $title);
+ $page->setTitle($title);
// photo
$page->addJsLink('grades.js');
$page->addJsLink('profile.js');
$page->addJsLink('jquery.autocomplete.js');
- $wiz = new PlWizard('Profil', 'core/plwizard.tpl', true, true);
- require_once dirname(__FILE__) . '/profile/page.inc.php';
+ $wiz = new PlWizard('Profil', PlPage::getCoreTpl('plwizard.tpl'), true, true);
+ $this->load('page.inc.php');
$wiz->addPage('ProfileGeneral', 'Général', 'general');
$wiz->addPage('ProfileAddresses', 'Adresses personnelles', 'adresses');
$wiz->addPage('ProfileGroups', 'Groupes X - Binets', 'poly');
. " la procédure de récupération de mot de passe si un jour tu le perdais");
}
- $page->assign('xorg_title', 'Polytechnique.org - Mon Profil');
+ $page->setTitle('Mon Profil');
}
function handler_applis_js(&$page)
$page->changeTpl('profile/orange.tpl');
require_once 'validations.inc.php';
- require_once 'xorg.misc.inc.php';
$res = XDB::query(
"SELECT u.promo, u.promo_sortie
function handler_ref_search(&$page, $action = null, $subaction = null)
{
- require_once 'wiki.inc.php';
- wiki_require_page('Docs.Emploi');
- $page->assign('xorg_title', 'Polytechnique.org - Conseil Pro');
+ $wp = new PlWikiPage('Docs.Emploi');
+ $wp->buildCache();
+
+ $page->setTitle('Conseil Pro');
//recuperation des noms de secteurs
$res = XDB::iterRow("SELECT id, label FROM emploi_secteur");
$page->changeTpl('profile/nomusage.tpl');
require_once 'validations.inc.php';
- require_once 'xorg.misc.inc.php';
$res = XDB::query(
"SELECT u.nom, u.nom_usage, u.flags, e.alias
WHERE user_id={?}", S::v('uid'));
list($nom, $usage_old, $flags, $alias_old) = $res->fetchOneRow();
- $flags = new flagset($flags);
+ $flags = new PlFlagSet($flags);
$page->assign('usage_old', $usage_old);
$page->assign('alias_old', $alias_old);
function handler_xnet(&$page)
{
$page->changeTpl('profile/groupesx.tpl');
- $page->assign('xorg_title', 'Polytechnique.org - Promo, Groupes X, Binets');
+ $page->setTitle('Promo, Groupes X, Binets');
$req = XDB::query('
SELECT m.asso_id, a.nom, diminutif, a.logo IS NOT NULL AS has_logo,
$x = substr($x, 0, strlen($x) - 4);
}
- $vcard = new VCard($x);
- $vcard->do_page($page);
+ $vcard = new VCard();
+ $vcard->addUser($x);
+ $vcard->show();
}
function handler_admin_trombino(&$page, $uid = null, $action = null) {
$page->changeTpl('profile/admin_trombino.tpl');
- $page->assign('xorg_title','Polytechnique.org - Administration - Trombino');
+ $page->setTitle('Administration - Trombino');
$page->assign('uid', $uid);
$q = XDB::query(
$page->assign('forlife', $forlife);
}
function handler_admin_binets(&$page, $action = 'list', $id = null) {
- $page->assign('xorg_title','Polytechnique.org - Administration - Binets');
+ $page->setTitle('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);
$table_editor->apply($page, $action, $id);
}
function handler_admin_formations(&$page, $action = 'list', $id = null) {
- $page->assign('xorg_title','Polytechnique.org - Administration - Formations');
+ $page->setTitle('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);
$table_editor->apply($page, $action, $id);
}
function handler_admin_sections(&$page, $action = 'list', $id = null) {
- $page->assign('xorg_title','Polytechnique.org - Administration - Sections');
+ $page->setTitle('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('xorg_title', 'Polytechnique.org - Administration - Sous-secteurs');
+ $page->setTitle('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('xorg_title', 'Polytechnique.org - Administration - Fonctions');
+ $page->setTitle('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);
$table_editor->apply($page, $action, $id);
}
function handler_admin_secteurs(&$page, $action = 'list', $id = null) {
- $page->assign('xorg_title', 'Polytechnique.org - Administration - Secteurs');
+ $page->setTitle('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('xorg_title','Polytechnique.org - Administration - Distinctions');
+ $page->setTitle('Administration - Distinctions');
$page->assign('title', 'Gestion des Distinctions');
$table_editor = new PLTableEditor('admin/medals','profile_medals','id');
$table_editor->describe('text', 'intitulé', true);
private function saveAddress($adrid, array &$address)
{
- $flags = new FlagSet();
+ $flags = new PlFlagSet();
if ($address['secondaire']) {
$flags->addFlag('res-secondaire');
}
}
}
- public function _prepare(PlatalPage &$page, $id)
+ public function _prepare(PlPage &$page, $id)
{
$res = XDB::iterator("SELECT *, FIND_IN_SET('validation', flags) AS validate
FROM profile_medals
|| $this->matchWord($ini, $new, $newLen)
|| ($field == 'nom' && $new == 'DE ' . $old);
if (!$success) {
- global $page;
- $page->trigError("Le $field que tu as choisi ($value) est trop loin de ton $field initial ($init)"
- . (($init == $current)? "" : " et de ton prénom précédent ($current)"));
+ Platal::page()->trigError("Le $field que tu as choisi ($value) est trop loin de ton $field initial ($init)"
+ . (($init == $current)? "" : " et de ton prénom précédent ($current)"));
}
return $success ? $value : $current;
}
}
}
- public function _prepare(PlatalPage &$page, $id)
+ public function _prepare(PlPage &$page, $id)
{
require_once "applis.func.inc.php";
}
$this->watched['section'] = $this->watched['binets'] = true;
}
- public function _prepare(PlatalPage &$page, $id)
+ public function _prepare(PlPage &$page, $id)
{
$page->assign('mygroups', XDB::iterator("SELECT a.nom, a.site, a.diminutif, a.unsub_url, a.pub, m.perms
FROM groupex.asso AS a
}
}
- public function _prepare(PlatalPage &$page, $id)
+ public function _prepare(PlPage &$page, $id)
{
$page->assign('secteurs', XDB::iterator("SELECT id, label
FROM emploi_secteur"));
} else if (!is_array($value)) {
$value = array();
} else if (count($value) > 10) {
- global $page;
- $page->trigError("Le nombre de secteurs d'expertise est limité à 10");
+ Platal::page()->trigError("Le nombre de secteurs d'expertise est limité à 10");
$success = false;
}
ksort($value);
} else if (!is_array($value)) {
$value = array();
} else if (count($value) > 10) {
- global $page;
- $page->trigError("Le nombre de secteurs d'expertise est limité à 10");
+ Platal::page()->trigError("Le nombre de secteurs d'expertise est limité à 10");
$success = false;
}
ksort($value);
}
}
- public function _prepare(PlatalPage &$page, $id)
+ public function _prepare(PlPage &$page, $id)
{
$page->assign('secteurs_sel', XDB::iterator("SELECT id, label
FROM emploi_secteur"));
$value = trim($value);
$success = empty($value) || preg_match("{^(https?|ftp)://[a-zA-Z0-9._%#+/?=&~-]+$}i", $value);
if (!$success) {
- global $page;
- $page->trigError('URL Incorrecte : une url doit commencer par http:// ou https:// ou ftp://'
- . ' et ne pas contenir de caractères interdits');
+ Platal::page()->trigError('URL Incorrecte : une url doit commencer par http:// ou https:// ou ftp://'
+ . ' et ne pas contenir de caractères interdits');
}
return $value;
}
return isset($page->values[$field]) ? $page->values[$field] : S::v($field);
}
$value = trim($value);
- require_once 'xorg.misc.inc.php';
$success = empty($value) || isvalid_email($value);
if (!$success) {
- global $page;
- $page->trigError('Adresse Email invalide');
+ Platal::page()->trigError('Adresse Email invalide');
}
return $value;
}
}
$success = !preg_match('/[<>{}@&#~\/:;?,!§*_`\[\]|%$^=]/', $value, $matches);
if (!$success) {
- global $page;
- $page->trigError('Le numéro de téléphone contient un caractère interdit : ' . pl_entities($matches[0][0]));
+ Platal::page()->trigError('Le numéro de téléphone contient un caractère interdit : ' . pl_entities($matches[0][0]));
}
return $value;
}
} else {
$success = preg_match('@(\d{2})/(\d{2})/(\d{4})@', $value, $matches);
if (!$success) {
- global $page;
- $page->trigError("Les dates doivent être au format jj/mm/aaaa");
+ Platal::page()->trigError("Les dates doivent être au format jj/mm/aaaa");
} else {
$day = (int)$matches[1];
$month = (int)$matches[2];
$year = (int)$matches[3];
$success = ($day > 0 && $day <= 31) && ($month > 0 && $month <= 12) && ($year > 1900 && $year <= 2020);
if (!$success) {
- global $page;
- $page->trigError("La date n'a pas une valeur valide");
+ Platal::page()->trigError("La date n'a pas une valeur valide");
}
}
}
}
global $platal;
$log =& $_SESSION['log'];
- $log->log('profil', $platal->pl_self(1));
+ S::logger()->log('profil', $platal->pl_self(1));
}
protected function checkChanges()
return 'profile/base.tpl';
}
- protected function _prepare(PlatalPage &$page, $id)
+ protected function _prepare(PlPage &$page, $id)
{
}
- public function prepare(PlatalPage &$page, $id)
+ public function prepare(PlPage &$page, $id)
{
if (count($this->values) == 0) {
$this->fetchData();
}
return Post::has('next_page') ? PlWizard::NEXT_PAGE : PlWizard::CURRENT_PAGE;
}
- global $page;
- $page->trigError("Certains champs n'ont pas pu être validés, merci de corriger les informations "
- . "de ton profil et de revalider ta demande");
+ Platal::page()->trigError("Certains champs n'ont pas pu être validés, merci de corriger les informations "
+ . "de ton profil et de revalider ta demande");
return PlWizard::CURRENT_PAGE;
}
}
$this->settings['langues'] = new ProfileSkill('langues', 'lid', 'langue_fr');
}
- public function _prepare(PlatalPage &$page, $id)
+ public function _prepare(PlPage &$page, $id)
{
$page->assign('comp_list', XDB::iterator("SELECT id, text_fr, FIND_IN_SET('titre',flags) AS title
FROM competences_def"));
switch ($sub_state['step']) {
case 0:
- require_once('wiki.inc.php');
- wiki_require_page('Reference.Charte');
+ $wp = new PlWikiPage('Reference.Charte');
+ $wp->buildCache();
if (Post::has('step1')) {
$sub_state['step'] = 1;
if (isset($sub_state['hash'])) {
$sub_state['step'] = 3;
- require_once(dirname(__FILE__) . '/register/register.inc.php');
+ $this->load('register.inc.php');
create_aliases($sub_state);
}
}
case 2:
if (count($_POST)) {
- require_once(dirname(__FILE__) . '/register/register.inc.php');
+ $this->load('register.inc.php');
$sub_state['prenom'] = Post::v('prenom');
$sub_state['nom'] = Post::v('nom');
$sub_state['mat'] = Post::v('mat');
case 3:
if (count($_POST)) {
- require_once(dirname(__FILE__) . '/register/register.inc.php');
+ $this->load('register.inc.php');
+ require_once 'emails.inc.php';
if (!isvalid_email(Post::v('email'))) {
$err[] = "Le champ 'E-mail' n'est pas valide.";
} elseif (!isvalid_email_redirection(Post::v('email'))) {
$redirect->add_email($email);
// on cree un objet logger et on log l'inscription
- $logger = new CoreLogger($uid);
- $logger->log('inscription', $email);
-
+ S::logger($uid)->log('inscription', $email);
XDB::execute('UPDATE register_pending SET hash="INSCRIT" WHERE uid={?}', $uid);
- global $platal;
- $platal->on_subscribe($forlife, $uid, $promo, $password);
$mymail = new PlMailer('register/inscription.reussie.tpl');
$mymail->assign('forlife', $forlife);
$mymail->assign('prenom', $prenom);
$mymail->send();
+ // Enable search on the user
require_once('user.func.inc.php');
user_reindex($uid);
+ // Add notification for people looking for this registration
+ require_once 'notifs.inc.php';
+ register_watch_op($uid, WATCH_INSCR);
+ inscription_notifs_base($uid);
+
+ // Default registration on forums
+ $p_for = 'xorg.promo.x' . $promo;
+ $cible = array('xorg.general', 'xorg.pa.divers', 'xorg.pa.logements', $p_for);
+ foreach ($cible as $val) {
+ XDB::execute("INSERT INTO forums.abos (fid,uid)
+ SELECT fid, {?} FROM forums.list WHERE nom={?}", $uid, $val);
+ if (XDB::affectedRows() == 0 && $val == $p_for) {
+ $res = XDB::query("SELECT SUM(perms IN ('admin','user') AND deces = 0), COUNT(*)
+ FROM auth_user_md5
+ WHERE promo = {?}", $promo);
+ list($effau, $effid) = $res->fetchOneRow();
+ if (5 * $effau > $effid) { // +
+ $mymail = new PlMailer('admin/forums-promo.mail.tpl');
+ $mymail->assign('promo', $promo);
+ $mymail->send();
+ }
+ }
+ }
+
// update number of subscribers (perms has changed)
- update_NbIns();
+ $globals->updateNbIns();
if (!start_connexion($uid, false)) {
return PL_FORBIDDEN;
INNER JOIN aliases AS sa ON ( sa.id = m.sender
AND FIND_IN_SET('bestalias', sa.flags) )
WHERE m.uid = {?}
- GROUP BY m.sender", $uid);
+ GROUP BY m.sender
+ ORDER BY dateDernier DESC", $uid);
XDB::execute("UPDATE register_mstats SET success=NOW() WHERE uid={?}", $uid);
$market = array();
$msg .= "Les marketings suivants avaient été effectués :\n"
. implode("\n", $market);
} else {
- $msg .= "$prenom $nom n'a jamais reçu de mail de marketing.";
+ $msg .= "$prenom $nom n'a jamais reçu d\'email de marketing.";
}
$mymail->setTxtBody($msg);
$mymail->send();
}
$log = S::v('log');
- $log->log('passwd', '');
+ S::logger()->log('passwd', '');
if (Cookie::v('ORGaccess')) {
require_once('secure_hash.inc.php');
NewsLetter::subscribe();
}
if (Post::v('add_to_ax')) {
- require_once dirname(__FILE__) . '/axletter/axletter.inc.php';
+ Platal::load('axletter', 'axletter.inc.php');
AXLetter::subscribe();
}
if (Post::v('add_to_promo')) {
* 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA *
***************************************************************************/
-require_once 'xorg.misc.inc.php';
-
// {{{ function user_cmp
function user_cmp($prenom, $nom, $_prenom, $_nom)
global $globals;
extract ($sub);
- require_once "xorg.misc.inc.php";
$mailorg = make_username($prenom, $nom);
$mailorg2 = $mailorg.sprintf(".%02u", ($promo%100));
$forlife = make_forlife($prenom, $nom, $promo);
exit;
}
- function on_subscribe($forlife, $uid, $promo, $pass)
- {
- require_once 'user.func.inc.php';
- user_reindex($uid);
- }
-
-
function form_prepare()
{
- global $page;
-
- $page->assign('formulaire',1);
+ Platal::page()->assign('formulaire',1);
}
function get_diplomas($school = null)
$types = explode('(',$row[1]);
$types = str_replace("'","",substr($types[1],0,-1));
}
- global $page;
- $page->assign('choix_diplomas', explode(',',$types));
+ Platal::page()->assign('choix_diplomas', explode(',',$types));
}
function handler_quick(&$page, $action = null, $subaction = null)
if (Env::has('quick') || $action == 'geoloc') {
$quick = trim(Env::v('quick'));
if (S::logged() && !Env::has('page')) {
- $_SESSION['log']->log('search', 'quick=' . $quick);
+ S::logger()->log('search', 'quick=' . $quick);
}
$list = 'profile|prf|fiche|fic|referent|ref|mentor';
if (S::has_perms()) {
$page->addJsLink('ajax.js');
}
- require_once dirname(__FILE__) . '/search/search.inc.php';
+ $this->load('search.inc.php');
$page->changeTpl('search/index.tpl');
- $page->assign('xorg_title','Polytechnique.org - Annuaire');
+ $page->setTitle('Annuaire');
}
function handler_advanced(&$page, $action = null, $subaction = null)
{
global $globals;
require_once 'geoloc.inc.php';
- require_once dirname(__FILE__) . '/search/search.inc.php';
+ $this->load('search.inc.php');
$page->assign('advanced',1);
$page->addJsLink('jquery.autocomplete.js');
'city' => array('table' => 'geoloc_city', 'text' => 'name', 'exact' => false)
);
if (!Env::has('page')) {
- $_SESSION['log']->log('search', 'adv=' . var_export($_GET, true));
+ S::logger()->log('search', 'adv=' . var_export($_GET, true));
}
foreach ($textFields as $field=>&$query) {
if (!Env::v($field) && Env::v($field . 'Txt')) {
* 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA *
***************************************************************************/
-require_once("xorg.misc.inc.php");
-
// {{{ Global variables used for the search Queries
@$globals->search->result_fields = '
*/
private static function defaultHandler($explain)
{
- global $page, $globals;
+ global $globals;
+ $page =& Platal::page();
$page->changeTpl('search/index.tpl');
- $page->assign('xorg_title','Polytechnique.org - Annuaire');
+ $page->setTitle('Polytechnique.org - Annuaire');
$page->assign('baseurl', $globals->baseurl);
$page->trigError($explain);
$page->run();
$s = preg_replace('!\d+!', ' ', $s);
$this->strings = preg_split("![^a-zA-Z%]+!",$s, -1, PREG_SPLIT_NO_EMPTY);
if (count($this->strings) > 5) {
- global $page;
- $page->trigWarning("Tu as indiqué trop d'éléments dans ta recherche, seuls les 5 premiers seront pris en compte");
+ Platal::page()->trigWarning("Tu as indiqué trop d'éléments dans ta recherche, seuls les 5 premiers seront pris en compte");
$this->strings = array_slice($this->strings, 0, 5);
}
if (Env::i('with_soundex') && strlen($s) > 1) {
$t = soundex_fr($s);
$where[] = "sn$i.soundex = '$t'";
+ } elseif (Env::i('exact')) {
+ $where[] = "sn$i.token = '$s'";
} else {
$t = str_replace('*', '%', $s).'%';
$t = str_replace('%%', '%', $t);
function compare()
{
$val = addslashes($this->value);
+ if (Env::i('exact')) return "='$val'";
return $this->exact ? "='$val'" : " LIKE '%$val%'";
}
* @param field nom de champ de la bdd concerné par la clause */
function get_single_where_statement($field)
{
- $regexp = strtr(addslashes($this->value), '-*', '_%');
+ $val = addslashes($this->value);
+ if (Env::i('exact')) return "$field = '$val'";
+ $regexp = strtr($val, '-*', '_%');
return "$field LIKE '$regexp%'";
}
function get_single_where_statement($field)
{
- $regexp = strtr(addslashes($this->value), '-*', '_%');
+ $val = addslashes($this->value);
+ if (Env::i('exact')) return "$field = '$val'";
+ $regexp = strtr($val, '-*', '_%');
return "$field LIKE '$regexp%' OR $field LIKE '% $regexp%' OR $field LIKE '%-$regexp%'";
}
}
if (!Env::i('cityid')) {
- $townField = new RefSField('city',array('ac.city'),'adresses','ac',getadr_join('ac'),false);
+ $townField = new RefSField('city',array('ac.city', 'ac.postcode'),'adresses','ac',getadr_join('ac'),false);
} else {
- $townField = new RefSField('cityid',array('av.cityid'),'adresses','av',getadr_join('av'));
+ $townField = new RefSField('cityid',array('av.cityid', 'av.postcode'),'adresses','av',getadr_join('av'));
}
$countryField = new RefSField('country',array('ap.country'),'adresses','ap',getadr_join('ap'));
$regionField = new RefSField('region',array('ar.region'),'adresses','ar',getadr_join('ar'));
// {{{ function handler_index() : lists all available surveys
function handler_index(&$page, $action = null)
{
- require_once dirname(__FILE__).'/survey/survey.inc.php';
+ $this->load('survey.inc.php');
$page->changeTpl('survey/index.tpl');
$page->assign('survey_current', Survey::retrieveList('c'));
$page->assign('survey_old', Survey::retrieveList('o'));
if ($id == -1) {
return $this->show_error($page, "Un identifiant de sondage doit être précisé.", 'survey');
}
- require_once dirname(__FILE__).'/survey/survey.inc.php';
+ $this->load('survey.inc.php');
$survey = Survey::retrieveSurvey($id); // retrieves the survey object structure
if ($survey == null || !$survey->isValid()) {
return $this->show_error($page, "Sondage ".$id." introuvable.", 'survey');
if ($id == -1) {
return $this->show_error($page, "Un identifiant de sondage doit être précisé.", 'survey');
}
- require_once dirname(__FILE__).'/survey/survey.inc.php';
+ $this->load('survey.inc.php');
$survey = Survey::retrieveSurvey($id); // retrieves the survey object structure
if ($survey == null || !$survey->isValid()) {
return $this->show_error($page, "Sondage ".$id." introuvable.", 'survey');
// {{{ function handler_admin() : index of admin mode
function handler_admin(&$page, $id = -1)
{
- require_once dirname(__FILE__).'/survey/survey.inc.php';
+ $this->load('survey.inc.php');
$this->clear_session();
if ($id == -1) {
$page->changeTpl('survey/admin.tpl');
if ($id == -1 || ($id == 'req' && $req == -1)) {
return $this->show_error($page, "Un identifiant de sondage doit être précisé.", 'survey/admin');
}
- require_once dirname(__FILE__).'/survey/survey.inc.php';
+ $this->load('survey.inc.php');
$this->clear_session(); // cleans session (in case there would have been a problem before)
if ($id == 'req') {
$survey = Survey::retrieveSurveyReq($req);
return $this->show_error($page, "Un identifiant de sondage doit être précisé.", 'survey/admin');
}
$id = intval($id);
- require_once dirname(__FILE__).'/survey/survey.inc.php';
+ $this->load('survey.inc.php');
$surveyInfo = Survey::retrieveSurveyInfo($id); // retrieves information about the survey (does not retrieve and unserialize the object structure)
if ($surveyInfo == null) {
return $this->show_error($page, "Sondage ".$id." introuvable.", 'survey/admin');
return $this->show_error($page, "Un identifiant de sondage doit être précisé.", 'survey/admin');
}
$id = intval($id);
- require_once dirname(__FILE__).'/survey/survey.inc.php';
+ $this->load('survey.inc.php');
$surveyInfo = Survey::retrieveSurveyInfo($id); // retrieves information about the survey (does not retrieve and unserialize the object structure)
if ($surveyInfo == null) {
return $this->show_error($page, "Sondage ".$id." introuvable.", 'survey/admin');
// {{{ function handler_edit() : edits a survey (in normal mode unless called by handler_adminEdit() )
function handler_edit(&$page, $action = 'show', $qid = 'root')
{
- require_once dirname(__FILE__).'/survey/survey.inc.php';
+ $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
// {{{ function handler_ajax() : some ajax in editing a new question (for now, there may be a little more later)
function handler_ajax(&$page, $type)
{
- require_once dirname(__FILE__).'/survey/survey.inc.php';
+ $this->load('survey.inc.php');
header('Content-Type: text/html; charset="UTF-8"');
if (Survey::isType($type)) { // when type has been chosen, the form is updated to fit exactly the type of question chosen
$page->changeTpl('survey/edit_new.tpl', NO_SKIN);
// {{{ function check_surveyPerms() : checks the particular surveys access permissions
function check_surveyPerms(&$page, $survey)
{
- require_once dirname(__FILE__).'/survey/survey.inc.php';
+ $this->load('survey.inc.php');
if (!$survey->isMode(Survey::MODE_ALL)) { // if the survey is reserved to alumni
global $globals;
if (!call_user_func(array($globals->session, 'doAuth'))) { // checks authentification
function handler_exit(&$page)
{
- XnetSession::killSuid();
- XnetSession::destroy();
+ Platal::session()->stopSUID();
+ Platal::session()->destroy();
$page->changeTpl('xnet/deconnexion.tpl');
}
XDB::execute("DELETE FROM requests
WHERE type = 'paiements' AND data LIKE {?}",
PayReq::same_event($eid, $globals->asso('id')));
- update_NbValid();
+ $globals->updateNbValid();
}
if ($action == 'archive') {
function handler_sub(&$page, $eid = null)
{
- require_once dirname(__FILE__).'/xnetevents/xnetevents.inc.php';
+ $this->load('xnetevents.inc.php');
$page->changeTpl('xnetevents/subscribe.tpl');
$evt = get_event_detail($eid);
function handler_csv(&$page, $eid = null, $item_id = null)
{
- require_once dirname(__FILE__).'/xnetevents/xnetevents.inc.php';
+ $this->load('xnetevents.inc.php');
if (!is_numeric($item_id)) {
$item_id = null;
{
global $globals;
- require_once dirname(__FILE__).'/xnetevents/xnetevents.inc.php';
+ $this->load('xnetevents.inc.php');
$evt = get_event_detail($eid);
if (!$evt) {
return PL_FORBIDDEN;
if (Post::v('intitule')) {
S::assert_xsrf_token();
- require_once dirname(__FILE__).'/xnetevents/xnetevents.inc.php';
+ $this->load('xnetevents.inc.php');
$short_name = event_change_shortname($page, $eid,
$infos['short_name'],
Env::v('short_name', ''));
{
global $globals;
- require_once dirname(__FILE__).'/xnetevents/xnetevents.inc.php';
+ $this->load('xnetevents.inc.php');
$evt = get_event_detail($eid, $item_id);
if (!$evt) {
function subscribe_lists_event($participate, $uid, $evt)
{
require_once('user.func.inc.php');
- global $globals,$page;
+ global $globals;
+ $page =& Platal::page();
$participant_list = $evt['participant_list'];
$absent_list = $evt['absent_list'];
$res = XDB::query("SELECT email
FROM groupex.membres
WHERE uid = {?} AND asso_id = {?}",
- S::v('uid'), $globals->asso('id'));
+ $uid, $globals->asso('id'));
$email = $res->fetchOneCell();
}
$lastid = XDB::insertId();
XDB::execute(
- "INSERT INTO virtual_redirect (
+ "INSERT IGNORE INTO virtual_redirect (
SELECT {?} AS vid, IF(u.nom IS NULL, m.email, CONCAT(a.alias, {?})) AS redirect
FROM groupex.evenements_participants AS ep
LEFT JOIN groupex.membres AS m ON (ep.uid = m.uid)
if (S::logged()) {
if (Env::has('read')) {
- XDB::query('DELETE r.*
+ XDB::query('DELETE groupex.r.*
FROM groupex.announces_read AS r
INNER JOIN groupex.announces AS a ON a.id = r.announce_id
WHERE peremption < CURRENT_DATE()');
if (Post::has('submit')) {
S::assert_xsrf_token();
- $flags = new FlagSet('wiki_desc');
+ $flags = new PlFlagSet('wiki_desc');
if (Post::has('notif_unsub') && Post::i('notif_unsub') == 1) {
$flags->addFlag('notif_unsub');
}
+ $site = trim(Post::v('site'));
+ if ($site && ($site != "http://")) {
+ $scheme = parse_url($site, PHP_URL_SCHEME);
+ if (!$scheme) {
+ $site = "http://" . $site;
+ }
+ } else {
+ $site = "";
+ }
if (S::has_perms()) {
if (Post::v('mail_domain') && (strstr(Post::v('mail_domain'), '.') === false)) {
$page->trigError("le domaine doit être un FQDN (aucune modif effectuée) !!!");
WHERE id={?}",
Post::v('nom'), Post::v('diminutif'),
Post::v('cat'), Post::i('dom'),
- Post::v('descr'), Post::v('site'),
+ Post::v('descr'), $site,
Post::v('mail'), Post::v('resp'),
Post::v('forum'), Post::v('mail_domain'),
Post::has('ax'), Post::v('pub'),
forum={?}, ax={?}, pub= {?}, sub_url={?},
unsub_url={?},flags={?}
WHERE id={?}",
- Post::v('descr'), Post::v('site'),
+ Post::v('descr'), $site,
Post::v('mail'), Post::v('resp'),
Post::v('forum'), Post::has('ax'),
Post::v('pub'),
$mls = array_keys(Env::v('ml', array()));
$mbr = array_keys(Env::v('membres', array()));
- require_once dirname(__FILE__) . '/xnetgrp/mail.inc.php';
+ $this->load('mail.inc.php');
set_time_limit(120);
$tos = get_all_redirects($mbr, $mls, $mmlist);
$upload = PlUpload::get($_FILES['uploaded'], S::v('forlife'), 'xnet.emails', true);
$res = XDB::query('SELECT uid
FROM groupex.membres
WHERE asso_id = {?}', $globals->asso('id'));
- $vcard = new VCard($res->fetchColumn(), $photos == 'photos', 'Membre du groupe ' . $globals->asso('nom'));
- $vcard->do_page($page);
+ $vcard = new VCard($photos == 'photos', 'Membre du groupe ' . $globals->asso('nom'));
+ $vcard->addUsers($res->fetchColumn());
+ $vcard->show();
}
function handler_csv(&$page, $filename = null)
if (Env::has('right') && (may_update() || S::has('suid'))) {
switch (Env::v('right')) {
case 'admin':
- XnetSession::killSuid();
+ Platal::session()->stopSUID();
break;
case 'anim':
- XnetSession::doSelfSuid();
+ Platal::session()->doSelfSuid();
may_update(true);
is_member(true);
break;
case 'member':
- XnetSession::doSelfSuid();
+ Platal::session()->doSelfSuid();
may_update(false, true);
is_member(true);
break;
case 'logged':
- XnetSession::doSelfSuid();
+ Platal::session()->doSelfSuid();
may_update(false, true);
is_member(false, true);
break;
}
}
+// var_dump($_SESSION);
http_redirect($_SERVER['HTTP_REFERER']);
}
{
global $globals;
- require_once dirname(__FILE__) . '/xnetgrp/mail.inc.php';
+ $this->load('mail.inc.php');
$page->changeTpl('xnetgrp/annuaire-admin.tpl');
$mmlist = new MMList(S::v('uid'), S::v('password'),
$globals->asso('mail_domain'));
$page->trigError($email." n'est pas un alias polytechnique.org valide.");
}
} else {
- require_once 'xorg.misc.inc.php';
if (isvalid_email($email)) {
if (Env::v('x') && Env::has('userid') && Env::i('userid')) {
$uid = Env::i('userid');
function unsubscribe(&$user)
{
- global $globals, $page;
+ global $globals;
XDB::execute(
"DELETE FROM groupex.membres WHERE uid={?} AND asso_id={?}",
$user['uid'], $globals->asso('id'));
$mmlist->unsubscribe($liste['list']);
}
} elseif ($liste['sub']) {
- $page->trigWarning("{$user['prenom']} {$user['nom']} a une"
- ." demande d'inscription en cours sur la"
- ." liste {$liste['list']}@ !");
+ Platal::page()->trigWarning("{$user['prenom']} {$user['nom']} a une"
+ ." demande d'inscription en cours sur la"
+ ." liste {$liste['list']}@ !");
$warning = true;
}
}
}
}
- private function changeLogin(PlatalPage &$page, array &$user, MMList &$mmlist, $login)
+ private function changeLogin(PlPage &$page, array &$user, MMList &$mmlist, $login)
{
require_once 'user.func.inc.php';
// Search the uid of the user...
function handler_rss(&$page, $user = null, $hash = null)
{
global $globals;
- require_once('rss.inc.php');
- $uid = init_rss('xnetgrp/announce-rss.tpl', $user, $hash, false);
-
- if ($uid) {
- $rss = XDB::iterator("SELECT a.id, a.titre, a.texte, a.contacts, a.create_date,
- IF(u2.nom_usage != '', u2.nom_usage, u2.nom) AS nom, u2.prenom, u2.promo,
- FIND_IN_SET('photo', a.flags) AS photo
- FROM auth_user_md5 AS u
- INNER JOIN groupex.announces AS a ON ( (a.promo_min = 0 OR a.promo_min <= u.promo)
- AND (a.promo_max = 0 OR a.promo_max <= u.promo))
- INNER JOIN auth_user_md5 AS u2 ON (u2.user_id = a.user_id)
- WHERE u.user_id = {?} AND peremption >= NOW() AND a.asso_id = {?}",
- $uid, $globals->asso('id'));
- } else {
- $rss = XDB::iterator("SELECT a.id, a.titre, a.texte, a.create_date,
- IF(u.nom_usage != '', u.nom_usage, u.nom) AS nom, u.prenom, u.promo
- FROM groupex.announces AS a
- INNER JOIN auth_user_md5 AS u USING(user_id)
- WHERE FIND_IN_SET('public', a.flags) AND peremption >= NOW() AND a.asso_id = {?}",
- $globals->asso('id'));
- }
$page->assign('asso', $globals->asso());
- $page->assign('rss', $rss);
+
+ $this->load('feed.inc.php');
+ $feed = new XnetGrpEventFeed();
+ return $feed->run($page, $user, $hash, false);
}
- private function upload_image(PlatalPage &$page, PlUpload &$upload)
+ private function upload_image(PlPage &$page, PlUpload &$upload)
{
if (@!$_FILES['image']['tmp_name'] && !Env::v('image_url')) {
return true;
if (Post::v('valid') == 'Enregistrer') {
$promo_min = ($art['public'] ? 0 : $art['promo_min']);
$promo_max = ($art['public'] ? 0 : $art['promo_max']);
- $flags = new FlagSet();
+ $flags = new PlFlagSet();
if ($art['public']) {
$flags->addFlag('public');
}
--- /dev/null
+<?php
+/***************************************************************************
+ * Copyright (C) 2003-2008 Polytechnique.org *
+ * http://opensource.polytechnique.org/ *
+ * *
+ * This program is free software; you can redistribute it and/or modify *
+ * it under the terms of the GNU General Public License as published by *
+ * the Free Software Foundation; either version 2 of the License, or *
+ * (at your option) any later version. *
+ * *
+ * This program is distributed in the hope that it will be useful, *
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of *
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
+ * GNU General Public License for more details. *
+ * *
+ * You should have received a copy of the GNU General Public License *
+ * along with this program; if not, write to the Free Software *
+ * Foundation, Inc., *
+ * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA *
+ ***************************************************************************/
+
+class XnetGrpEventFeed extends PlFeed
+{
+ public function __construct()
+ {
+ global $globals;
+ $name = $globals->asso('nom');
+ $url = $globals->baseurl . '/' . $globals->asso('diminutif');
+ parent::__construct('Polytechnique.net :: ' . $name . ' :: News',
+ $url,
+ 'L\'actualité du groupe ' . $name,
+ $url . '/logo',
+ 'xnetgrp/announce-rss.tpl');
+ }
+
+ protected function fetch($user)
+ {
+ global $globals;
+ if (!is_null($user)) {
+ return XDB::iterator("SELECT a.id, a.titre AS title, a.texte, a.contacts,
+ a.create_date AS publication,
+ CONCAT(u2.prenom, ' ', IF(u2.nom_usage != '', u2.nom_usage, u2.nom), ' (X', u2.promo, ')') AS author,
+ FIND_IN_SET('photo', a.flags) AS photo,
+ CONCAT({?}, '/#art', a.id) AS link
+ FROM auth_user_md5 AS u
+ INNER JOIN groupex.announces AS a ON ( (a.promo_min = 0 OR a.promo_min <= u.promo)
+ AND (a.promo_max = 0 OR a.promo_max <= u.promo))
+ INNER JOIN auth_user_md5 AS u2 ON (u2.user_id = a.user_id)
+ WHERE u.user_id = {?} AND peremption >= NOW() AND a.asso_id = {?}",
+ $this->link, $user, $globals->asso('id'));
+ } else {
+ return XDB::iterator("SELECT a.id, a.titre AS title, a.texte, a.create_date AS publication,
+ CONCAT(u.prenom, ' ', IF(u.nom_usage != '', u.nom_usage, u.nom), ' (X', u.promo, ')') AS author,
+ CONCAT({?}, '/#art', a.id) AS link,
+ NULL AS photo, NULL AS contacts
+ FROM groupex.announces AS a
+ INNER JOIN auth_user_md5 AS u USING(user_id)
+ WHERE FIND_IN_SET('public', a.flags) AND peremption >= NOW() AND a.asso_id = {?}",
+ $this->link, $globals->asso('id'));
+ }
+ }
+}
+
+// vim:set et sw=4 sts=4 sws=4 foldmethod=marker enc=utf-8:
+
+?>
* 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA *
***************************************************************************/
-require_once dirname(__FILE__).'/lists.php';
+Platal::load('lists');
class XnetListsModule extends ListsModule
{
function prepare_client(&$page)
{
global $globals;
-
- require_once dirname(__FILE__).'/lists/lists.inc.php';
+ Platal::load('lists', 'lists.inc.php');
$this->client = new MMList(S::v('uid'), S::v('password'),
$globals->asso('mail_domain'));
+++ /dev/null
-<?php
-/***************************************************************************
- * Copyright (C) 2003-2008 Polytechnique.org *
- * http://opensource.polytechnique.org/ *
- * *
- * This program is free software; you can redistribute it and/or modify *
- * it under the terms of the GNU General Public License as published by *
- * the Free Software Foundation; either version 2 of the License, or *
- * (at your option) any later version. *
- * *
- * This program is distributed in the hope that it will be useful, *
- * but WITHOUT ANY WARRANTY; without even the implied warranty of *
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
- * GNU General Public License for more details. *
- * *
- * You should have received a copy of the GNU General Public License *
- * along with this program; if not, write to the Free Software *
- * Foundation, Inc., *
- * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA *
- ***************************************************************************/
-
-global $tidy_config;
-$tidy_config = array(
- 'drop-empty-paras' => true,
- 'drop-font-tags' => true,
- 'drop-proprietary-attributes' => true,
- 'hide-comments' => true,
- 'logical-emphasis' => true,
- 'output-xhtml' => true,
- 'replace-color' => true,
- 'show-body-only' => true,
- 'clean' => false,
- 'join-styles' => false,
- 'join-classes' => false,
- 'alt-text' => '[ inserted by TIDY ]',
- 'wrap' => '120');
-
-/*
- * Smarty plugin
- * -------------------------------------------------------------
- * File: block.min_perms.php
- * Type: block
- * Name: min_perms
- * Purpose:
- * -------------------------------------------------------------
- */
-function smarty_block_tidy($params, $content, &$smarty)
-{
- global $tidy_config;
- return tidy_repair_string($content, $tidy_config, 'utf8');
-}
-
-// vim:set et sw=4 sts=4 sws=4 foldmethod=marker enc=utf-8:
-?>
+++ /dev/null
-<?php
-/***************************************************************************
- * Copyright (C) 2003-2008 Polytechnique.org *
- * http://opensource.polytechnique.org/ *
- * *
- * This program is free software; you can redistribute it and/or modify *
- * it under the terms of the GNU General Public License as published by *
- * the Free Software Foundation; either version 2 of the License, or *
- * (at your option) any later version. *
- * *
- * This program is distributed in the hope that it will be useful, *
- * but WITHOUT ANY WARRANTY; without even the implied warranty of *
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
- * GNU General Public License for more details. *
- * *
- * You should have received a copy of the GNU General Public License *
- * along with this program; if not, write to the Free Software *
- * Foundation, Inc., *
- * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA *
- ***************************************************************************/
-require_once 'platal.inc.php';
-
-function smarty_compiler_checkpasswd($tag_attrs, &$compiler)
-{
- extract($compiler->_parse_attrs($tag_attrs));
- if (!isset($width)) {
- $width = '230px';
- }
- if (!isset($prompt)) {
- $prompt = "'nouveau'";
- }
- if (!isset($submit)) {
- $submit = "'submitn'";
- }
-
- return '?><script type="text/javascript" src="javascript/jquery.js" ></script>
- <script type="text/javascript" src="javascript/jquery.color.js" ></script>
- <script type="text/javascript">//<![CDATA[
- var passwordprompt_name = '. $prompt . ';
- var passwordprompt_submit = ' . $submit . ';
- $(":input[@name=' . $prompt . ']").keyup(function(event) { checkPassword(event.target); });
- $(document).ready(function() {
- checkPassword($(":input[@name=' . $prompt . ']").get(0));
- });
- //]]></script>
- <div>
- <div style="border: 1px solid white; width: ' . $width . '; height: 7px; background-color: #444; margin-top: 4px; float: left">
- <div id="passwords_measure" style="height: 100%; background-color: red; width: 0px"></div>
- </div>
- <a href="Xorg/MDP?display=light" style="display: block; float: left; margin-left: 4px;" class="popup_600x800">
- <img src="images/icons/information.gif" alt="Aide" title="Comment construire un mot de passe fort..." />
- </a>
- </div><?php';
-}
-
-/* vim: set expandtab enc=utf-8: */
-
-?>
* Foundation, Inc., *
* 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA *
***************************************************************************/
-require_once 'platal.inc.php';
function smarty_compiler_icon($tag_attrs, &$compiler)
{
+++ /dev/null
-<?php
-/***************************************************************************
- * Copyright (C) 2003-2008 Polytechnique.org *
- * http://opensource.polytechnique.org/ *
- * *
- * This program is free software; you can redistribute it and/or modify *
- * it under the terms of the GNU General Public License as published by *
- * the Free Software Foundation; either version 2 of the License, or *
- * (at your option) any later version. *
- * *
- * This program is distributed in the hope that it will be useful, *
- * but WITHOUT ANY WARRANTY; without even the implied warranty of *
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
- * GNU General Public License for more details. *
- * *
- * You should have received a copy of the GNU General Public License *
- * along with this program; if not, write to the Free Software *
- * Foundation, Inc., *
- * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA *
- ***************************************************************************/
-
-function iterate_end($tag_attrs, &$compiler) {
- return 'endwhile;';
-}
-
-function smarty_compiler_iterate($tag_attrs, &$compiler)
-{
- static $reg = false;
- if (!$reg) {
- $reg = true;
- $compiler->register_compiler_function("/iterate", 'iterate_end');
- }
-
- $_params = $compiler->_parse_attrs($tag_attrs);
-
- if (!isset($_params['from'])) {
- $compiler->_syntax_error("iterate: missing 'from' parameter", E_USER_ERROR, __FILE__, __LINE__);
- return;
- }
-
- if (empty($_params['item'])) {
- $compiler->_syntax_error("iterate: missing 'item' attribute", E_USER_ERROR, __FILE__, __LINE__);
- return;
- }
-
- $_from = $compiler->_dequote($_params['from']);
- $_item = $compiler->_dequote($_params['item']);
-
- return "\$_iterate_$_item = $_from;\n"
- . "while ((\$this->_tpl_vars['$_item'] = \$_iterate_{$_item}->next()) !== null):";
-}
-
-/* vim: set expandtab enc=utf-8: */
-
-?>
+++ /dev/null
-<?php
-/***************************************************************************
- * Copyright (C) 2003-2008 Polytechnique.org *
- * http://opensource.polytechnique.org/ *
- * *
- * This program is free software; you can redistribute it and/or modify *
- * it under the terms of the GNU General Public License as published by *
- * the Free Software Foundation; either version 2 of the License, or *
- * (at your option) any later version. *
- * *
- * This program is distributed in the hope that it will be useful, *
- * but WITHOUT ANY WARRANTY; without even the implied warranty of *
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
- * GNU General Public License for more details. *
- * *
- * You should have received a copy of the GNU General Public License *
- * along with this program; if not, write to the Free Software *
- * Foundation, Inc., *
- * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA *
- ***************************************************************************/
-require_once 'platal.inc.php';
-
-function smarty_compiler_javascript($tag_attrs, &$compiler)
-{
- extract($compiler->_parse_attrs($tag_attrs));
-
- if (!isset($name)) {
- return null;
- }
- $name = pl_entities(trim($name, '\'"'), ENT_QUOTES);
- $name = "javascript/$name.js";
- if ($full) {
- global $globals;
- $name = $globals->baseurl . '/' . $name;
- }
-
- return "?><script type='text/javascript' src='$name'></script><?php";
-}
-
-/* vim: set expandtab enc=utf-8: */
-
-?>
* Foundation, Inc., *
* 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA *
***************************************************************************/
-require_once 'platal.inc.php';
function smarty_function_make_forlife($params, &$smarty)
{
+++ /dev/null
-<?php
-/***************************************************************************
- * Copyright (C) 2003-2008 Polytechnique.org *
- * http://opensource.polytechnique.org/ *
- * *
- * This program is free software; you can redistribute it and/or modify *
- * it under the terms of the GNU General Public License as published by *
- * the Free Software Foundation; either version 2 of the License, or *
- * (at your option) any later version. *
- * *
- * This program is distributed in the hope that it will be useful, *
- * but WITHOUT ANY WARRANTY; without even the implied warranty of *
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
- * GNU General Public License for more details. *
- * *
- * You should have received a copy of the GNU General Public License *
- * along with this program; if not, write to the Free Software *
- * Foundation, Inc., *
- * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA *
- ***************************************************************************/
-
-require_once 'platal.inc.php';
-
-function select_options($table,$valeur,$champ="text",$pad=false,
- $where="",$join="",$group="")
-{
- $fields = 't.id,' . $champ;
- $order = $champ;
- if ($group) {
- $fields .= ',' . $group;
- $order = $group . ',' . $order;
- }
- $sql = "SELECT $fields FROM $table AS t $join $where ORDER BY $order";
- $res = XDB::iterRow($sql);
- $sel = ' selected="selected"';
-
- // on ajoute une entree vide si $pad est vrai
- $html = "";
- if ($pad) {
- $html.= '<option value="0"'.($valeur==0?$sel:"")."></option>\n";
- }
- $optgrp = null;
- while (list($my_id,$my_text,$my_grp) = $res->next()) {
- if ($my_grp != $optgrp) {
- if (!is_null($optgrp)) {
- $html .= '</optgroup>';
- }
- $html .= '<optgroup label="' . pl_entities($my_grp, ENT_QUOTES) . '">';
- $optgrp = $my_grp;
- }
- $html .= sprintf("<option value=\"%s\" %s>%s</option>\n",
- $my_id, $valeur==$my_id ? $sel : "", pl_entities($my_text));
- }
- if (!is_null($optgrp)) {
- $html .= '</optgroup>';
- }
- return $html;
-}
-
-function smarty_function_select_db_table($params, &$smarty) {
- if(empty($params['table']))
- return;
- if(empty($params['champ']))
- $params['champ'] = 'text';
- if(empty($params['pad']) || !($params['pad']))
- $pad = false;
- else
- $pad = true;
- if(empty($params['where']))
- $params['where'] = '';
- return select_options($params['table'], $params['valeur'], $params['champ'], $pad,
- $params['where'], $params['join'], $params['group']);
-}
-
-// vim:set et sw=4 sts=4 sws=4 foldmethod=marker enc=utf-8:
-?>
function select_nat($valeur,$pad=false) {
- $sql = "SELECT a2 AS id,IF(nat='',pays,nat) AS text FROM geoloc_pays ORDER BY text";
+ $sql = "SELECT a2 AS id,IF(nat='',pays,nat) AS text FROM geoloc_pays WHERE nat IS NOT NULL ORDER BY text";
$res = XDB::iterRow($sql);
$sel = ' selected="selected"';
+++ /dev/null
-<?php
-/***************************************************************************
- * Copyright (C) 2003-2008 Polytechnique.org *
- * http://opensource.polytechnique.org/ *
- * *
- * This program is free software; you can redistribute it and/or modify *
- * it under the terms of the GNU General Public License as published by *
- * the Free Software Foundation; either version 2 of the License, or *
- * (at your option) any later version. *
- * *
- * This program is distributed in the hope that it will be useful, *
- * but WITHOUT ANY WARRANTY; without even the implied warranty of *
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
- * GNU General Public License for more details. *
- * *
- * You should have received a copy of the GNU General Public License *
- * along with this program; if not, write to the Free Software *
- * Foundation, Inc., *
- * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA *
- ***************************************************************************/
-require_once 'platal.inc.php';
-
-function smarty_function_valid_date($params, &$smarty)
-{
- extract($params);
-
- if (!isset($name)) {
- $name = 'valid_date';
- }
- $text = "<select name=\"$name\">";
- if (!isset($from)) {
- $from = 1;
- }
- if (!isset($to)) {
- $to = 30;
- }
- $value = strtr($value, array('-' => ''));
- $time = time() + 3600 * 24 * $from;
- $mth = '';
- for ($i = $from ; $i <= $to ; $i++) {
- $p_stamp = date('Ymd', $time);
- $date = date('d / m / Y', $time);
- $select = ($p_stamp == $value) ? 'selected="selected"' : '';
- $month = pl_entities(strftime('%B', $time), ENT_QUOTES);
- if ($mth != $month) {
- if ($i != $from) {
- $text .= '</optgroup>';
- }
- $text .= "<optgroup label=\"$month\">";
- $mth = $month;
- }
- $time += 3600 * 24;
- $text .= "<option value=\"$p_stamp\" $select>$date</option>";
- }
- return $text . "</optgroup></select>";
-}
-
-/* vim: set expandtab enc=utf-8: */
-?>
+++ /dev/null
-<?php
-/***************************************************************************
- * Copyright (C) 2003-2008 Polytechnique.org *
- * http://opensource.polytechnique.org/ *
- * *
- * This program is free software; you can redistribute it and/or modify *
- * it under the terms of the GNU General Public License as published by *
- * the Free Software Foundation; either version 2 of the License, or *
- * (at your option) any later version. *
- * *
- * This program is distributed in the hope that it will be useful, *
- * but WITHOUT ANY WARRANTY; without even the implied warranty of *
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
- * GNU General Public License for more details. *
- * *
- * You should have received a copy of the GNU General Public License *
- * along with this program; if not, write to the Free Software *
- * Foundation, Inc., *
- * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA *
- ***************************************************************************/
-
-function smarty_function_xsrf_token($params, &$smarty) {
- return S::v('xsrf_token', '');
-}
-
-// vim:set et sw=4 sts=4 sws=4 foldmethod=marker enc=utf-8:
-?>
+++ /dev/null
-<?php
-/***************************************************************************
- * Copyright (C) 2003-2008 Polytechnique.org *
- * http://opensource.polytechnique.org/ *
- * *
- * This program is free software; you can redistribute it and/or modify *
- * it under the terms of the GNU General Public License as published by *
- * the Free Software Foundation; either version 2 of the License, or *
- * (at your option) any later version. *
- * *
- * This program is distributed in the hope that it will be useful, *
- * but WITHOUT ANY WARRANTY; without even the implied warranty of *
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
- * GNU General Public License for more details. *
- * *
- * You should have received a copy of the GNU General Public License *
- * along with this program; if not, write to the Free Software *
- * Foundation, Inc., *
- * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA *
- ***************************************************************************/
-
-function smarty_modifier_date_format($string, $format = '%x', $default_date=null)
-{
- $d = empty($string) ? $default_date : $string;
- if (empty($format) || preg_match('/^[ 0\-]*$/', $d)) return;
- $f = str_replace('%X', '%T', str_replace('%x', '%e %B %Y', $format));
-
- if (preg_match('/^\d{14}$/', $d)) {
- $t = mktime(substr($d,8,2), substr($d,10,2), substr($d,12,2), substr($d,4,2), substr($d,6,2), substr($d,0,4));
- } elseif (preg_match('/^\d{8}$/', $d)) {
- $t = mktime(0, 0, 0, substr($d,4,2), substr($d,6,2), substr($d,0,4));
- } elseif (is_numeric($d)) {
- $t = intval($d);
- } else {
- $t = strtotime($d);
- }
-
- if ( $t != -1 ) {
- return strftime($f , $t);
- } else {
- require_once('Date.php');
- $date = new Date($d);
- return $date->format($f);
- }
-}
-
-// vim:set et sw=4 sts=4 sws=4 foldmethod=marker enc=utf-8:
-?>
+++ /dev/null
-<?php
-/***************************************************************************
- * Copyright (C) 2003-2008 Polytechnique.org *
- * http://opensource.polytechnique.org/ *
- * *
- * This program is free software; you can redistribute it and/or modify *
- * it under the terms of the GNU General Public License as published by *
- * the Free Software Foundation; either version 2 of the License, or *
- * (at your option) any later version. *
- * *
- * This program is distributed in the hope that it will be useful, *
- * but WITHOUT ANY WARRANTY; without even the implied warranty of *
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
- * GNU General Public License for more details. *
- * *
- * You should have received a copy of the GNU General Public License *
- * along with this program; if not, write to the Free Software *
- * Foundation, Inc., *
- * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA *
- ***************************************************************************/
-
-require_once 'platal.inc.php';
-
-function smarty_modifier_htmlentities($string, $format = ENT_COMPAT)
-{
- return pl_entities($string, $format);
-}
-
-// vim:set et sw=4 sts=4 sws=4 foldmethod=marker enc=utf-8:
-?>
+++ /dev/null
-<?php
-/***************************************************************************
- * Copyright (C) 2003-2008 Polytechnique.org *
- * http://opensource.polytechnique.org/ *
- * *
- * This program is free software; you can redistribute it and/or modify *
- * it under the terms of the GNU General Public License as published by *
- * the Free Software Foundation; either version 2 of the License, or *
- * (at your option) any later version. *
- * *
- * This program is distributed in the hope that it will be useful, *
- * but WITHOUT ANY WARRANTY; without even the implied warranty of *
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
- * GNU General Public License for more details. *
- * *
- * You should have received a copy of the GNU General Public License *
- * along with this program; if not, write to the Free Software *
- * Foundation, Inc., *
- * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA *
- ***************************************************************************/
-
-function smarty_modifier_number_format($string, $decimal = 0)
-{
- return number_format($string, $decimal, ',', '.');
-}
-
-// vim:set et sw=4 sts=4 sws=4 foldmethod=marker enc=utf-8:
-?>
+++ /dev/null
-<?php
-/***************************************************************************
- * Copyright (C) 2003-2008 Polytechnique.org *
- * http://opensource.polytechnique.org/ *
- * *
- * This program is free software; you can redistribute it and/or modify *
- * it under the terms of the GNU General Public License as published by *
- * the Free Software Foundation; either version 2 of the License, or *
- * (at your option) any later version. *
- * *
- * This program is distributed in the hope that it will be useful, *
- * but WITHOUT ANY WARRANTY; without even the implied warranty of *
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
- * GNU General Public License for more details. *
- * *
- * You should have received a copy of the GNU General Public License *
- * along with this program; if not, write to the Free Software *
- * Foundation, Inc., *
- * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA *
- ***************************************************************************/
-
-function smarty_modifier_uint_to_ip($string)
-{
- return uint_to_ip($string);
-}
-
-// vim:set et sw=4 sts=4 sws=4 foldmethod=marker enc=utf-8:
-?>
</form>
{if $promo}
-{include file="include/csv-importer.tpl"}
+{include core=csv-importer.tpl}
{/if}
{* vim:set et sw=2 sts=2 sws=2 enc=utf-8: *}
<h1>Ajout d'utilisateurs</h1>
-{include file="include/csv-importer.tpl"}
+{include core=csv-importer.tpl}
{* vim:set et sw=2 sts=2 sws=2 enc=utf-8: *}
<tr class="pair">
<td class="titre" colspan="2">
<input type="checkbox" {if $xface}checked="checked"{/if} name="bananaxface" id="xface" />
- <label for="xface">Afficher mon X-Face plutôt que ma photo si il est disponible</label>
+ <label for="xface">Afficher mon X-Face plutôt que ma photo s'il est disponible</label>
</td>
</tr>
</table>
Rechercher dans tes contacts :
</p>
-{include file="core/plset.tpl"}
+{include core=plset.tpl}
{/if}
{foreach from=$u.data key=cid item=d}
-!{if $d|@count eq 1}{if $d[0].sexe}{$cats[$cid].mail_sg_xette}{else}{$cats[$cid].mail_sg}{/if}{else}{$cats[$cid].mail}{/if}:
+!{if $d|@count eq 1}{if $d[0].sexe}{$cats[$cid].mail_sg_xette}{else}{$cats[$cid].mail_sg}{/if}{else}{$cats[$cid].mail}{/if} :
{foreach from=$d item=x}
* (X{$x.promo}), le {$x.date|date_format:"%d %B %Y"}, [[https://www.polytechnique.org/profile/private/{$x.bestalias}|{$x.prenom} {$x.nom}]]
--
L'Équipe de Polytechnique.org
-'''''Note:''''' Tu reçois cet email car tu as activé la notification automatique par email des événements que tu surveilles.\\
+'''''Note :''''' Tu reçois cet email car tu as activé la notification automatique par email des événements que tu surveilles.\\
Tu peux changer cette option sur la [[https://www.polytechnique.org/carnet/notifs|page de configuration des notifications]].
{/if}
<fieldset>
<legend>Email</legend>
<input type='checkbox' name='mail' onclick="this.form.submit();" {if $watch->watch_mail}checked="checked"{/if} />
- Recevoir un email hebdomadaire des événements que je n'ai pas déjà vus sur le site<br />
+ Recevoir un email hebdomadaire des événements que je n'ai pas déjà vus sur le site.<br />
<input type='hidden' name='flags_mail' value='valider' />
</fieldset>
</form>
{$promo[row].prenom} {$promo[row].nom}
{/if}
</td>
- <td style="width:25%" {if $promo[row].data}rowspan="2"{/if}>
+ <td style="width:25%">
{$promo[row].date|date_format}
</td>
{if $promo[row].data}
- </tr><tr><td>{$promo[row].data|smarty:nodefaults}</td>
+ </tr><tr><td colspan="2">{$promo[row].data|smarty:nodefaults}</td>
{/if}
</tr>
{/section}
{* *}
{**************************************************************************}
-<?xml version="1.0"?>
-<rss version="2.0">
- <channel>
- <title>Polytechnique.org :: Carnet</title>
- <language>fr</language>
- <link>{#globals.baseurl#}/carnet/panel</link>
- <description>Ton carnet polytechnicien...</description>
- <image>
- <title>Polytechnique.org</title>
- <url>{#globals.baseurl#}/images/logo.png</url>
- <link>{#globals.baseurl#}/</link>
- </image>
- {foreach from=$notifs->_data item=c key=cid}
- {foreach from=$c item=promo}
- {foreach from=$promo item=x}
- <item>
- <title>
- [{$notifs->_cats[$cid].short}] {$x.prenom} {$x.nom} ({$x.promo}) - le {$x.date|date_format}
- </title>
- <link>{#globals.baseurl#}/profile/private/{$x.bestalias}</link>
- <guid isPermaLink="false">carnet{$x.known}{$cid}{$x.bestalias}</guid>
- <description><![CDATA[
- {if $x.data}{$x.prenom} {$x.nom} a mis à jours les données suivantes :<br />{$x.data}<br />{/if}
- {if !$x.contact and !$x.dcd}
- <a href="{#globals.baseurl#}/carnet/contacts?action=ajouter&user={$x.bestalias}&token={$rss_hash}">
- {icon name=add title="Ajouter" full=true} Ajouter à mes contacts
- </a><br />
- {/if}
- {if !$x.dcd}
- <a href="{#globals.baseurl#}/vcard/{$x.bestalias}.vcf">
- {icon name=vcard title="Carte de visite" full=true} Télécharger la carte de visite électronique
- </a>
- {/if}
- ]]></description>
- <author>{$x.prenom} {$x.nom} (X{$x.promo})</author>
- <pubDate>{$x.known|rss_date}</pubDate>
- </item>
- {/foreach}
- {/foreach}
- {/foreach}
- </channel>
-</rss>
+{if $article->data}{$article->prenom} {$article->nom} a mis à jours les données suivantes :<br />{$article->data}<br />{/if}
+{if !$article->contact and !$article->dcd}
+<a href="{#globals.baseurl#}/carnet/contacts?action=ajouter&user={$article->bestalias}&token={$rss_hash}">
+ {icon name=add title="Ajouter" full=true} Ajouter à mes contacts
+</a><br />
+{/if}
+{if !$article->dcd}
+<a href="{#globals.baseurl#}/vcard/{$article->bestalias}.vcf">
+ {icon name=vcard title="Carte de visite" full=true} Télécharger la carte de visite électronique
+</a>
+{/if}
{* vim:set et sw=2 sts=2 sws=2 enc=utf-8: *}
+++ /dev/null
-{**************************************************************************}
-{* *}
-{* Copyright (C) 2003-2008 Polytechnique.org *}
-{* http://opensource.polytechnique.org/ *}
-{* *}
-{* This program is free software; you can redistribute it and/or modify *}
-{* it under the terms of the GNU General Public License as published by *}
-{* the Free Software Foundation; either version 2 of the License, or *}
-{* (at your option) any later version. *}
-{* *}
-{* This program is distributed in the hope that it will be useful, *}
-{* but WITHOUT ANY WARRANTY; without even the implied warranty of *}
-{* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *}
-{* GNU General Public License for more details. *}
-{* *}
-{* You should have received a copy of the GNU General Public License *}
-{* along with this program; if not, write to the Free Software *}
-{* Foundation, Inc., *}
-{* 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA *}
-{* *}
-{**************************************************************************}
-
-<h1 class="erreur">Tu n'as pas les permissions nécessaires pour accéder à cette page.</h1>
-
-{* vim:set et sw=2 sts=2 sws=2 enc=utf-8: *}
+++ /dev/null
-{**************************************************************************}
-{* *}
-{* Copyright (C) 2003-2008 Polytechnique.org *}
-{* http://opensource.polytechnique.org/ *}
-{* *}
-{* This program is free software; you can redistribute it and/or modify *}
-{* it under the terms of the GNU General Public License as published by *}
-{* the Free Software Foundation; either version 2 of the License, or *}
-{* (at your option) any later version. *}
-{* *}
-{* This program is distributed in the hope that it will be useful, *}
-{* but WITHOUT ANY WARRANTY; without even the implied warranty of *}
-{* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *}
-{* GNU General Public License for more details. *}
-{* *}
-{* You should have received a copy of the GNU General Public License *}
-{* along with this program; if not, write to the Free Software *}
-{* Foundation, Inc., *}
-{* 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA *}
-{* *}
-{**************************************************************************}
-
-<h1 class="erreur">Cette page n'existe pas !!!</h1>
-
-{if $near}
-<p>L'adresse suivante semble correspondre à ta demande :<br />
-{icon name="lightbulb" title="Cherchais-tu ?"} <a href="{$globals->baseurl}/{$near}">{$globals->baseurl}/{$near}</a>
-</p>
-{/if}
-{* vim:set et sw=2 sts=2 sws=2 enc=utf-8: *}
+++ /dev/null
-{**************************************************************************}\r
-{* *}\r
-{* Copyright (C) 2003-2008 Polytechnique.org *}\r
-{* http://opensource.polytechnique.org/ *}\r
-{* *}\r
-{* This program is free software; you can redistribute it and/or modify *}\r
-{* it under the terms of the GNU General Public License as published by *}\r
-{* the Free Software Foundation; either version 2 of the License, or *}\r
-{* (at your option) any later version. *}\r
-{* *}\r
-{* This program is distributed in the hope that it will be useful, *}\r
-{* but WITHOUT ANY WARRANTY; without even the implied warranty of *}\r
-{* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *}\r
-{* GNU General Public License for more details. *}\r
-{* *}\r
-{* You should have received a copy of the GNU General Public License *}\r
-{* along with this program; if not, write to the Free Software *}\r
-{* Foundation, Inc., *}\r
-{* 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA *}\r
-{* *}\r
-{**************************************************************************}\r
-\r
-<script type="text/javascript">//<![CDATA[\r
-{literal}\r
-var edited=false;\r
-\r
-function cleanContent()\r
-{\r
- if (edited == false) {\r
- var field = document.getElementById('flyspray_detail');\r
- field.value = '';\r
- field.style.color = "black";\r
- field.style.textAlign = "left";\r
- }\r
-}\r
-\r
-function fillContent()\r
-{\r
- var field = document.getElementById('flyspray_detail');\r
- if (field.value == '' || (field.value.toUpperCase() == field.value && field.value.toLowerCase() == field.value)) {\r
- field.value = "** Explique ici le problème ou l'amélioration proposée **";\r
- field.style.color = "gray";\r
- field.style.textAlign = "center";\r
- edited = false;\r
- } else {\r
- edited = true;\r
- }\r
-}\r
-{/literal}\r
-//]]></script>\r
-\r
-<div style="width:800px;height:600px">\r
-{if $bug_sent}\r
-<p class="erreur">\r
- Ton message a bien été envoyé au support de Polytechnique.org, tu devrais en\r
- recevoir une copie d'ici quelques minutes. Nous allons le traiter et y répondre\r
- dans les plus brefs délais.\r
-</p>\r
-\r
-<div class="center"><input type="submit" onclick="window.close()" name="close" value="Fermer" /></div>\r
-{else}\r
-<form action="send_bug" method="post" onsubmit="cleanContent()">\r
- {xsrf_token_field}\r
- <h1>Signaler un bug ou demander une amélioration</h1>\r
- <div style="margin-left:10%;margin-right:10%">\r
- <select name="task_type">\r
- <option value="bug">Erreur</option>\r
- <option value="wish">Souhait</option>\r
- <option value="help">Aide/Dépannage</option>\r
- </select>\r
- Sujet : <input type="text" name="item_summary" id="flyspray_title" value="sur la page { $location }" size="50" maxlength="100"/>\r
- <textarea name="detailed_desc" id="flyspray_detail" cols="70" rows="10" style="width:100%;margin-top:10px;margin-bottom:10px;height:400px;display:block;" onFocus="cleanContent()" onBlur="fillContent()"></textarea>\r
- <input type="hidden" name="page" value="{$smarty.server.HTTP_REFERER|default:$smarty.request.page}" />\r
- <div class="center">\r
- <input type="button" value="Abandonner" onclick="window.close()"/>\r
- <input type="submit" name="send" value="Envoyer"/>\r
- </div>\r
- </div>\r
-</form>\r
-<script type="text/javascript">\r
- fillContent();\r
-</script>\r
-</div>\r
-{/if}\r
-\r
-{* vim:set et sws=2 sts=2 sw=2 enc=utf-8: *}\r
<!-- Set up the form with the challenge value and an empty reply value //-->
<form action="{$smarty.server.REQUEST_URI}" method="post" id="loginsub">
<div>
+ {xsrf_token_field}
<input type="hidden" name="challenge" value="{$smarty.session.challenge}" />
<input type="hidden" name="response" value="" />
<input type="hidden" name="xorpass" value="" />
</td>
<td>
<input type="password" name="password" size="10" maxlength="10" />
- <a href="recovery">Perdu ?</a>
+ <a href="recovery">Perdu ?</a>
</td>
<td class="right" rowspan="2" style="vertical-align: middle">
<input type="submit" name="submitbtn" value="Envoyer" />
+++ /dev/null
-{**************************************************************************}
-{* *}
-{* Copyright (C) 2003-2008 Polytechnique.org *}
-{* http://opensource.polytechnique.org/ *}
-{* *}
-{* This program is free software; you can redistribute it and/or modify *}
-{* it under the terms of the GNU General Public License as published by *}
-{* the Free Software Foundation; either version 2 of the License, or *}
-{* (at your option) any later version. *}
-{* *}
-{* This program is distributed in the hope that it will be useful, *}
-{* but WITHOUT ANY WARRANTY; without even the implied warranty of *}
-{* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *}
-{* GNU General Public License for more details. *}
-{* *}
-{* You should have received a copy of the GNU General Public License *}
-{* along with this program; if not, write to the Free Software *}
-{* Foundation, Inc., *}
-{* 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA *}
-{* *}
-{**************************************************************************}
-
-<div id="pl_set_top" style="clear: both">
-<h1 style="display: block; float: left">
- {$plset_mods[$plset_mod]}
- {if $plset_mods|@count > 1}[
- {assign var=has_prev value=false}
- {foreach from=$plset_mods key=mod item=desc name=mods}
- {if $mod neq $plset_mod}
- {if $has_prev}| {/if}
- <a href="{$platal->ns}{$plset_base}/{$mod}{$plset_search}#pl_set_top">{$desc}</a>
- {assign var=has_prev value=true}
- {/if}
- {/foreach}
- ]
- {/if}
-</h1>
-<h1 style="display: block; float: right">
- {if !$plset_count}
- Aucune entrée
- {elseif $plset_count eq 1}
- 1 entrée
- {else}
- {$plset_count} entrées
- {/if}
-</h1>
-</div>
-
-<div id="plset_content" style="clear: both">
-{include file=$plset_content}
-</div>
-
-{* vim:set et sw=2 sts=2 sws=2 enc=utf-8: *}
+++ /dev/null
-{**************************************************************************}
-{* *}
-{* Copyright (C) 2003-2008 Polytechnique.org *}
-{* http://opensource.polytechnique.org/ *}
-{* *}
-{* This program is free software; you can redistribute it and/or modify *}
-{* it under the terms of the GNU General Public License as published by *}
-{* the Free Software Foundation; either version 2 of the License, or *}
-{* (at your option) any later version. *}
-{* *}
-{* This program is distributed in the hope that it will be useful, *}
-{* but WITHOUT ANY WARRANTY; without even the implied warranty of *}
-{* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *}
-{* GNU General Public License for more details. *}
-{* *}
-{* You should have received a copy of the GNU General Public License *}
-{* along with this program; if not, write to the Free Software *}
-{* Foundation, Inc., *}
-{* 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA *}
-{* *}
-{**************************************************************************}
-
-<script type="text/javascript">//<![CDATA[
- {if ($stateless || $id gt $current) && $wiz_ajax}
- {literal}
- function changePage(obj, id)
- {
- var myUrl = obj.href;
- $.ajax({ url: myUrl + "/ajax",
- global: false,
- dataTye: 'html',
- error: function(request, error) {
- document.location = myUrl;
- },
- success: function(data) {
- if (is_IE) {
- $(".wiz_tab").removeClass("active");
- $("#wiz_tab_" + id).addClass("active");
- $(".wiz_content").html(data);
- if (typeof wizPage_onLoad == 'function') {
- wizPage_onLoad(id);
- }
- auto_links();
- } else {
- $(".wiz_content").fadeOut('normal',
- function() {
- $(".wiz_tab").removeClass("active");
- $("#wiz_tab_" + id).addClass("active");
- $(".wiz_content").html(data).fadeIn('normal');
- if (typeof wizPage_onLoad == 'function') {
- wizPage_onLoad(id);
- }
- auto_links();
- });
- }
- }
- });
- return false;
- }
- {/literal}
- {else}
- {literal}
- function changePage(obj)
- {
- return true;
- }
- {/literal}
- {/if}
-//]]></script>
-
-<div class="wizard" style="clear: both">
- <div class="wiz_header">
- {foreach from=$pages item=title key=id}
- {if $stateless || $id gt $current}
- {assign var=tag value="a"}
- {else}
- {assign var=tag value="div"}
- {/if}
- <{$tag} class="wiz_tab {if $id eq $current}active{/if} {if !$stateless && $current gt $id}grayed{/if}"
- style="display: block; float: left; width: {$tab_width}%; vertical-align: middle"
- id="wiz_tab_{$lookup[$id]}"
- {if $tag eq "a"}
- href="{$wiz_baseurl}/{$lookup[$id]}"
- onclick="return changePage(this, '{$lookup[$id]}')"
- {/if}
- >
- <span style="vertical-align: middle">{$title}</span>
- </{$tag}>
- {/foreach}
- <div style="clear: both"></div>
- </div>
- <div class="wiz_content" style="clear: both">
- {include file="skin/common.triggers.tpl"}
- {include file=$wiz_page}
- </div>
-</div>
-
-<script type="text/javascript">
-{literal}
-if (typeof wizPage_onLoad == 'function') {
- wizPage_onLoad({/literal}'{$lookup[$current]}'{literal});
-}
-{/literal}
-</script>
-
-{* vim:set et sw=2 sts=2 sws=2 enc=utf-8: *}
+++ /dev/null
-{**************************************************************************}
-{* *}
-{* Copyright (C) 2003-2008 Polytechnique.org *}
-{* http://opensource.polytechnique.org/ *}
-{* *}
-{* This program is free software; you can redistribute it and/or modify *}
-{* it under the terms of the GNU General Public License as published by *}
-{* the Free Software Foundation; either version 2 of the License, or *}
-{* (at your option) any later version. *}
-{* *}
-{* This program is distributed in the hope that it will be useful, *}
-{* but WITHOUT ANY WARRANTY; without even the implied warranty of *}
-{* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *}
-{* GNU General Public License for more details. *}
-{* *}
-{* You should have received a copy of the GNU General Public License *}
-{* along with this program; if not, write to the Free Software *}
-{* Foundation, Inc., *}
-{* 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA *}
-{* *}
-{**************************************************************************}
-
-
-<h1>{$title}</h1>
-
-{if $list}
-<script type="text/javascript">
- {literal}
- function redirect(a) {
- document.location = a;
- }
- {/literal}
-</script>
-<table class="bicol">
-<tr>
- {foreach from=$t->vars item=myval key=myvar}{if $myval.display}
- <th style="cursor:pointer" onclick="redirect('{$t->pl}/sort{if $t->sortfield eq $myvar && !$t->sortdesc}desc{/if}/{$myvar}')">{$myval.desc}{if $t->sortfield eq $myvar}{if $t->sortdesc}{icon name="bullet_arrow_down"}{else}{icon name="bullet_arrow_up"}{/if}{/if}</th>
- {/if}{/foreach}
- {if !$hideactions}
- <th>action</th>
- {/if}
-</tr>
-{if !$readonly}
-<tr class="impair">
- <td colspan="{$t->nbfields}">
- <strong>
- Nouvelles entrées : <a href="{$t->pl}/new">Manuellement</a> • <a href="{$t->pl}/massadd">Depuis un CSV</a>
- </strong>
- </td>
- <td class="right">
- <a href="{$t->pl}/new">{icon name=add title='nouvelle entrée'}</a>
- </td>
-</tr>
-{/if}
-{iterate from=$list item=myrow}
-<tr class="{cycle values="pair,impair"}">
-{foreach from=$t->vars item=myval}{if $myval.display}
- <td>
- {assign var="myfield" value=$myval.Field}
- {if $myfield eq $t->idfield}
- {assign var="idval" value=$myrow.$myfield}
- {/if}
- {if $myval.Type eq 'timestamp'}
- <span class="smaller">{$myrow.$myfield|date_format:"%x %X"}</span>
- {elseif $myval.Type eq 'checkbox'}
- <input type="checkbox" disabled="disabled"{if $myrow.$myfield} checked="checked"{/if}/>
- {elseif $myval.Type eq 'ip_address'}
- {$myrow.$myfield|uint_to_ip}
- {else}
- {$myrow.$myfield}
- {/if}
- </td>
-{/if}{/foreach}
- {if !$hideactions}
- <td class="action">
- {if !$readonly}
- <a href="{$t->pl}/edit/{$idval}">{icon name=page_edit title='éditer'}</a>
- <a href="{$t->pl}/delete/{$idval}?token={xsrf_token}">{icon name=delete title='supprimer'}</a>
- {/if}
- </td>
- {/if}
-</tr>
-{/iterate}
-</table>
-
-{if ($p_prev > -1) || ($p_next > -1)}
-<p class="pagenavigation">
-{if $p_prev > -1}<a href="{$platal->path}?start={$p_prev}">{$msg_previous_page}</a> {/if}
-{if $p_next > -1}<a href="{$platal->path}?start={$p_next}">{$msg_next_page}</a>{/if}
-</p>
-{/if}
-
-{elseif $massadd}
-{include file="include/csv-importer.tpl"}
-
-<p>
-<a href="{$t->pl}">back</a>
-</p>
-
-{else}
-
-<form method="post" action="{$t->pl}/update/{$id}">
- {xsrf_token_field}
- <table class="bicol">
- <tr class="impair">
- <th colspan="2">
- {if $id}
- modification de l'entrée
- {else}
- nouvelle entrée
- {/if}
- </th>
- </tr>
- {foreach from=$t->vars item=myval}{assign var="myfield" value=$myval.Field}{if ($myfield neq $t->idfield) or ($t->idfield_editable)}
- <tr class="{cycle values="pair,impair"}">
- <td>
- <strong>{$myval.desc}</strong>
- </td>
- <td>
- {if $myval.Type eq 'set'}
- <select name="{$myfield}[]" multiple="multiple">
- {foreach from=$myval.List item=option}
- <option value="{$option}" {if $entry.$myfield.$option}selected="selected"{/if}>{$option}</option>
- {/foreach}
- </select>
- {elseif $myval.Type eq 'enum'}
- <select name="{$myfield}">
- {foreach from=$myval.List item=option}
- <option value="{$option}" {if $entry.$myfield eq $option}selected="selected"{/if}>{$option}</option>
- {/foreach}
- </select>
- {elseif ($myval.Type eq 'textarea') or ($myval.Type eq 'varchar200')}
- <textarea name="{$myfield}" rows="{if $myval.Type eq 'varchar200'}3{else}10{/if}" cols="70">{$entry.$myfield}</textarea>
- {elseif ($myval.Type eq 'checkbox')}
- <input type="checkbox" name="{$myfield}" value="{$myval.Value}"{if $entry.$myfield} checked="checked"{/if}/>
- {else}
- <input type="text" name="{$myfield}" value="{$entry.$myfield}" {if $myval.Size}size="{$myval.Size}" maxlength="{$myval.Maxlength}"{/if}/>
- {if $myval.Type eq 'timestamp'}<em>jj/mm/aaaa hh:mm:ss</em>{/if}
- {if $myval.Type eq 'date'}<em>jj/mm/aaaa</em>{/if}
- {if $myval.Type eq 'time'}<em>hh:mm:ss</em>{/if}
- {/if}
- </td>
- </tr>
- {/if}{/foreach}
- </table>
-
- <p class="center">
- <input type="submit" value="enregistrer" />
- </p>
-
-</form>
-
-<p>
-<a href="{$t->pl}">back</a>
-</p>
-
-{/if}
-
-
-{* vim:set et sw=2 sts=2 sws=2 enc=utf-8: *}
+++ /dev/null
-{**************************************************************************}
-{* *}
-{* Copyright (C) 2003-2008 Polytechnique.org *}
-{* http://opensource.polytechnique.org/ *}
-{* *}
-{* This program is free software; you can redistribute it and/or modify *}
-{* it under the terms of the GNU General Public License as published by *}
-{* the Free Software Foundation; either version 2 of the License, or *}
-{* (at your option) any later version. *}
-{* *}
-{* This program is distributed in the hope that it will be useful, *}
-{* but WITHOUT ANY WARRANTY; without even the implied warranty of *}
-{* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *}
-{* GNU General Public License for more details. *}
-{* *}
-{* You should have received a copy of the GNU General Public License *}
-{* along with this program; if not, write to the Free Software *}
-{* Foundation, Inc., *}
-{* 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA *}
-{* *}
-{**************************************************************************}
-{iterate from=$users item=vcard}
-BEGIN:VCARD
-VERSION:3.0
-{if $vcard.nom_usage}
-FN:{$vcard.prenom|vcard_enc} {$vcard.nom_usage|vcard_enc} ({$vcard.nom|vcard_enc})
-{else}
-FN:{$vcard.prenom|vcard_enc} {$vcard.nom|vcard_enc}
-{/if}
-N:{$vcard.nom|vcard_enc};{$vcard.prenom|vcard_enc};{$vcard.nom_usage|vcard_enc};;
-{if $vcard.nickname}
-NICKNAME:{$vcard.nickname|vcard_enc}
-{/if}
-EMAIL;TYPE=internet,pref:{$vcard.bestalias}@{#globals.mail.domain#}
-EMAIL;TYPE=internet:{$vcard.bestalias}@{#globals.mail.domain2#}
-{if $vcard.bestalias neq $vcard.forlife}
-EMAIL;TYPE=internet:{$vcard.forlife}@{#globals.mail.domain#}
-EMAIL;TYPE=internet:{$vcard.forlife}@{#globals.mail.domain2#}
-{/if}
-{if $vcard.virtualalias}
-EMAIL;TYPE=internet:{$vcard.virtualalias}
-{/if}
-{if $vcard.mobile}
-TEL;TYPE=cell:{$vcard.mobile|vcard_enc}
-{/if}
-{if $vcard.adr_pro}
-{if $vcard.adr_pro[0].entreprise}
-ORG:{$vcard.adr_pro[0].entreprise|vcard_enc}
-{/if}
-{if $vcard.adr_pro[0].poste}
-TITLE:{$vcard.adr_pro[0].poste|vcard_enc}
-{/if}
-{if $vcard.adr_pro[0].fonction}
-ROLE:{$vcard.adr_pro[0].fonction|vcard_enc}
-{/if}
-{if $vcard.adr_pro[0].tel}
-TEL;TYPE=work:{$vcard.adr_pro[0].tel|vcard_enc}
-{/if}
-{if $vcard.adr_pro[0].fax}
-FAX;TYPE=work:{$vcard.adr_pro[0].fax|vcard_enc}
-{/if}
-ADR;TYPE=work:{format_adr adr=$vcard.adr_pro[0]}
-{/if}
-{foreach item=adr from=$vcard.adr}
-ADR;TYPE=home{if $adr.courier},postal{/if}:{format_adr adr=$adr}
-{foreach item=tel from=$adr.tels}
-{if $tel.tel}
-{if $tel.tel_type neq 'Fax'}TEL{else}FAX{/if};TYPE=home:{$tel.tel}
-{/if}
-{/foreach}
-{/foreach}
-{if $vcard.web}
-URL:{$vcard.web}
-{/if}
-{if strlen(trim($vcard.freetext)) == 0}
-NOTE:(X{$vcard.promo})
-{else}
-NOTE:(X{$vcard.promo})\n{$vcard.freetext|miniwiki:'no_title':'text'|vcard_enc}
-{/if}
-{if $vcard.section}
-X-SECTION:{$vcard.section}
-{/if}
-{if $vcard.binets_vcardjoin}
-X-BINETS:{$vcard.binets_vcardjoin}
-{/if}
-{if $vcard.gpxs_vcardjoin}
-X-GROUPS:{$vcard.gpxs_vcardjoin}
-{/if}
-{if $vcard.photo}
-PHOTO;ENCODING=b;TYPE={$vcard.photo.attachmime}:{$vcard.photo.attach|base64_encode|vcard_enc}
-{/if}
-SORT-STRING:{$vcard.nom|vcard_enc}
-REV:{$vcard.date|date_format:"%Y%m%dT000000Z"}
-END:VCARD{"\n"}
-{/iterate}
-{* vim:set et sw=2 sts=2 sws=2 enc=utf-8: *}
+++ /dev/null
-{**************************************************************************}
-{* *}
-{* Copyright (C) 2003-2008 Polytechnique.org *}
-{* http://opensource.polytechnique.org/ *}
-{* *}
-{* This program is free software; you can redistribute it and/or modify *}
-{* it under the terms of the GNU General Public License as published by *}
-{* the Free Software Foundation; either version 2 of the License, or *}
-{* (at your option) any later version. *}
-{* *}
-{* This program is distributed in the hope that it will be useful, *}
-{* but WITHOUT ANY WARRANTY; without even the implied warranty of *}
-{* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *}
-{* GNU General Public License for more details. *}
-{* *}
-{* You should have received a copy of the GNU General Public License *}
-{* along with this program; if not, write to the Free Software *}
-{* Foundation, Inc., *}
-{* 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA *}
-{* *}
-{**************************************************************************}
-
-<h1>Syntaxe wiki</h1>
-
-<table class="bicol">
- <tr><th>Syntaxe</th><th>Apparence</th></tr>
- {foreach from=$wiki_help key=syntax item=html}
- <tr class="{cycle values="pair,impair"}">
- <td>{$syntax|nl2br}</td>
- <td>{$html|smarty:nodefaults}</td>
- </tr>
- {/foreach}
-</table>
-
-{* vim:set et sws=2 sts=2 sw=2 enc=utf-8: *}
+++ /dev/null
-{**************************************************************************}
-{* *}
-{* Copyright (C) 2003-2008 Polytechnique.org *}
-{* http://opensource.polytechnique.org/ *}
-{* *}
-{* This program is free software; you can redistribute it and/or modify *}
-{* it under the terms of the GNU General Public License as published by *}
-{* the Free Software Foundation; either version 2 of the License, or *}
-{* (at your option) any later version. *}
-{* *}
-{* This program is distributed in the hope that it will be useful, *}
-{* but WITHOUT ANY WARRANTY; without even the implied warranty of *}
-{* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *}
-{* GNU General Public License for more details. *}
-{* *}
-{* You should have received a copy of the GNU General Public License *}
-{* along with this program; if not, write to the Free Software *}
-{* Foundation, Inc., *}
-{* 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA *}
-{* *}
-{**************************************************************************}
-
-{if $canedit || $has_perms}
-<table class='wiki' cellspacing='0' cellpadding='0'>
- <tr>
- <td>
- <a href='{$wikipage}'>Voir la page</a>
- </td>
- {if $canedit}
- <td>
- <a href='{$wikipage}?action=edit'>Éditer la page</a>
- </td>
- {/if}
- {if $has_perms}
- <td>
- <a href='{$wikipage}?action=diff'>Historique</a>
- </td>
- <td>
- <a href='{$wikipage}?action=upload'>Upload</a>
- </td>
- </tr>
- <tr>
- <td>
- <select onchange="dynpostkv('{$wikipage}', 'setrperms', this.value)">
- {html_options options=$perms_opts selected=$perms[0]}
- </select>
- </td>
- <td>
- <select onchange="dynpostkv('{$wikipage}', 'setwperms', this.value)">
- {html_options options=$perms_opts selected=$perms[1]}
- </select>
- </td>
- <td colspan='2' style='text-align: left'><-- Droits associés</td>
- {/if}
- </tr>
-</table>
-{/if}
-
-{if $text}
-{$pmwiki|smarty:nodefaults}
-{else}
-{include file=$pmwiki_cache}
-{/if}
-{* vim:set et sw=2 sts=2 sws=2 enc=utf-8: *}
{/if}
{if $retour == $smarty.const.ERROR_INVALID_EMAIL}
<p class="erreur">
- Erreur: l'email n'est pas valide.
+ Erreur : l'email n'est pas valide.
</p>
{/if}
{if $retour == $smarty.const.ERROR_LOOP_EMAIL}
<p class="erreur">
- Erreur: {$smarty.session.forlife}@{#globals.mail.domain#} ne doit pas être renvoyé
+ Erreur : {$smarty.session.forlife}@{#globals.mail.domain#} ne doit pas être renvoyé
vers lui-même, ni vers son équivalent en {#globals.mail.domain2#} ni vers polytechnique.edu.
</p>
{/if}
<h1>Aperçu de l'astuce</h1>
{include file="include/tips.tpl" full=true tips=$entry nochange=true}
-{include file="core/table-editor.tpl"}
+{include core=table-editor.tpl}
{* vim:set et sw=2 sts=2 sws=2 enc=utf-8: *}
{* 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA *}
{* *}
{**************************************************************************}
-
-<?xml version="1.0"?>
-<rss version="2.0">
- <channel>
- <title>{#globals.core.sitename#} :: News</title>
- <language>fr</language>
- <link>{#globals.baseurl#}/</link>
- <description>L'actualite polytechnicienne...</description>
- <image>
- <title>{#globals.core.sitename#}</title>
- <url>{#globals.baseurl#}/images/logo.png</url>
- <link>{#globals.baseurl#}/</link>
- </image>
- {iterate item=line from=$rss}
- <item>
- <title>{$line.titre|strip_tags|htmlentities}</title>
- <guid isPermaLink="false">{$line.id}</guid>
- <link>{#globals.baseurl#}/events#newsid{$line.id}</link>
- <description><![CDATA[
- {if $line.photo}
- <div style="float: left; padding-right: 0.5em">
- <img src="{#globals.baseurl#}/events/photo/{$line.id}" alt="{$line.title}" />
- </div>
- {/if}
- <div>{if $line.wiki}{$line.texte|miniwiki}{else}{$line.texte}{/if}</div>
- {if $line.post_id neq -1}
- <div style="clear: both">
- <br />
- <a href="{#globals.baseurl#}/banana/{#globals.banana.event_reply#|default:#globals.banana.event_forum#}/read/{$line.post_id}">
- {icon name=comments full=true} Suivre la discussion
- </a>
- </div>
- {/if}
- ]]></description>
- <author>{$line.prenom} {$line.nom} (X{$line.promo})</author>
- <pubDate>{$line.creation_date|rss_date}</pubDate>
- </item>
- {/iterate}
- </channel>
-</rss>
+{if $article->photo}
+<div style="float: left; padding-right: 0.5em">
+ <img src="{#globals.baseurl#}/events/photo/{$article->id}" alt="{$article->title|htmlentities}" />
+</div>
+{/if}
+<div>{if $article->wiki}{$article->texte|miniwiki}{else}{$article->texte}{/if}</div>
+{if $article->post_id neq -1}
+<div style="clear: both">
+ <br />
+ <a href="{#globals.baseurl#}/banana/{#globals.banana.event_reply#|default:#globals.banana.event_forum#}/read/{$article->post_id}">
+ {icon name=comments full=true} Suivre la discussion
+ </a>
+</div>
+{/if}
{* vim:set et sw=2 sts=2 sws=2 enc=utf-8: *}
Les différentes règles sont appliquées par ordre de priorité décroissante.
</p>
-{include file="core/table-editor.tpl"}
+{include core=table-editor.tpl}
{literal}
<script type="text/javascript">
<table cellspacing="0" cellpadding="0">
{if $c.countrytxt || $c.city}
<tr>
- <td class="lt">Géographie:</td>
+ <td class="lt">Géographie :</td>
<td class="rt">{$c.city}{if $c.city && $c.countrytxt}, {/if}{$c.countrytxt}</td>
</tr>
{/if}
{if $c.mobile && !$c.dcd}
<tr>
- <td class="lt">Mobile:</td>
+ <td class="lt">Mobile :</td>
<td class="rt">{$c.mobile}</td>
</tr>
{/if}
{if $account->g_suspension}
<tr class="pair">
<td>
- Ton compte est actuellement suspendu pour la raison suivante: <em>{$account->g_suspension}</em>.
+ Ton compte est actuellement suspendu pour la raison suivante : <em>{$account->g_suspension}</em>.
</td>
</tr>
{/if}
Attention, cette opération changera ton mot de passe Google Apps.
</li>
<li>
- Changer le mot de passe de ton compte Google Apps:<br /><br />
+ Changer le mot de passe de ton compte Google Apps :<br /><br />
<form action="googleapps/password#password" method="post" id="changepass">
<table class="tinybicol">
<tr>
+++ /dev/null
-{**************************************************************************}
-{* *}
-{* Copyright (C) 2003-2008 Polytechnique.org *}
-{* http://opensource.polytechnique.org/ *}
-{* *}
-{* This program is free software; you can redistribute it and/or modify *}
-{* it under the terms of the GNU General Public License as published by *}
-{* the Free Software Foundation; either version 2 of the License, or *}
-{* (at your option) any later version. *}
-{* *}
-{* This program is distributed in the hope that it will be useful, *}
-{* but WITHOUT ANY WARRANTY; without even the implied warranty of *}
-{* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *}
-{* GNU General Public License for more details. *}
-{* *}
-{* You should have received a copy of the GNU General Public License *}
-{* along with this program; if not, write to the Free Software *}
-{* Foundation, Inc., *}
-{* 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA *}
-{* *}
-{**************************************************************************}
-
-{if $form_title}
-<h1>{$form_title}</h1>
-{/if}
-
-<script type="text/javascript">//<![CDATA[
-{literal}
- function showValue(key, box)
- {
- var span_value = document.getElementById('csv_user_value_span[' + key + ']');
- var span_cond = document.getElementById('csv_cond_value_span[' + key + ']');
- var i = box.selectedIndex;
- if (box.options[i].value == "user_value") {
- span_value.style.display = "";
- span_cond.style.display = "none";
- } else if(box.options[i].value == "cond_value") {
- span_value.style.display = "none";
- span_cond.style.display = "";
- } else {
- span_value.style.display = "none";
- span_conf.style.display = "none";
- }
- }
- function showCond(key, box)
- {
- var line = document.getElementById('csv_cond_value[' + key + ']');
- var i = box.selectedIndex;
- if (box.options[i].value == "defined") {
- line.style.display = "none";
- } else {
- line.style.display = "";
- }
- }
- function gotoPage(page)
- {
- document.getElementById('csv_next_page').value = page;
- document.getElementById('csv_form').submit();
- return false;
- }
-{/literal}
-//]]></script>
-<form action="{$csv_path}" method="post" id="csv_form">
- {xsrf_token_field}
- <div class="center" style="padding-bottom: 1em">
- Import d'un CSV :
- {if $csv_page eq 'source'}
- <span class="erreur">Choisir la source</span>
- {else}
- <a href="{$csv_path}" onclick="return gotoPage('source');">Choisir la source</a>
- {/if}
- »
- {if $csv_page eq 'values'}
- <span class="erreur">Définir les valeurs</span>
- {elseif $smarty.session.csv}
- <a href="{$csv_path}" onclick="return gotoPage('values');">Définir les valeurs</a>
- {else}
- Définir les valeurs
- {/if}
- »
- {if $csv_page eq 'valid'}
- <span class="erreur">Vérifier et valider</span>
- {elseif $csv_action}
- <a href="{$csv_path}" onclick="return gotoPage('valid');">Vérifier et valider</a>
- {else}
- Vérifier et valider
- {/if}
- </div>
- {if $csv_page eq 'source'}
- <div>
- <textarea name="csv_source" rows="20" cols="80">{$smarty.session.csv|default:$smarty.session.csv_source}</textarea><br />
- Entrez les données sous la forme suivante (avec
- <input type="text" name="csv_separator" value="{$smarty.session.csv_separator|default:";"}" maxlength="1" size="1" />
- comme séparateur) :<br/>
- <pre class="center">TITRE1{$smarty.session.csv_separator|default:";"}TITRE2{$smarty.session.csv_separator|default:";"}...
-val1_1{$smarty.session.csv_separator|default:";"}val1_2{$smarty.session.csv_separator|default:";"}...
-val2_1{$smarty.session.csv_separator|default:";"}val2_2{$smarty.session.csv_separator|default:";"}...
-val3_1{$smarty.session.csv_separator|default:";"}val3_2{$smarty.session.csv_separator|default:";"}...</pre>
- </div>
- {elseif $csv_page eq 'values'}
- <div class="center">
- Action à effectuer si l'entrée existe :
- <select name="csv_action" onchange="this.form.submit()">
- <option value="insert" {if $smarty.session.csv_action eq 'insert'}selected="selected"{/if}>
- ne rien faire
- </option>
- <option value="replace" {if $smarty.session.csv_action eq 'replace'}selected="selected"{/if}>
- remplacer par la nouvelle entrée
- </option>
- {if $csv_key}
- <option value="update" {if $smarty.session.csv_action eq 'update'}selected="selected"{/if}>
- mettre à jour les champs sélectionnés
- </option>
- {/if}
- </select>
- </div>
- <table class="bicol">
- <tr>
- <th>Champ</th>
- <th colspan="2">Valeur</th>
- {if $smarty.session.csv_action eq 'update'}
- <th>MàJ</th>
- {/if}
- </tr>
- {foreach from=$csv_fields item=f}
- <tr class="{cycle values="pair,impair"}">
- <td>{$csv_field_desc[$f]|default:$f}</td>
- <td>
- <select name="csv_value[{$f}]" onchange="showValue('{$f}', this);">
- <option value="" {if !$smarty.session.csv_value[$f]}selected="selected"{/if}>
- Vide
- </option>
- <option value="user_value" {if $smarty.session.csv_value[$f] eq "user_value"}selected="selected"{/if}>
- Entrer la valeur
- </option>
- <option value="cond_value" {if $smarty.session.csv_value[$f] eq "cond_value"}selected="selected"{/if}>
- Valeur conditionnelle
- </option>
- <optgroup label="Colonnes du CSV">
- {foreach from=$csv_index item=col}
- <option value="{$col}" {if $smarty.session.csv_value[$f] eq $col}selected="selected"{/if}>{$col}</option>
- {/foreach}
- </optgroup>
- {if $csv_functions|count}
- <optgroup label="Fonctions">
- {foreach from=$csv_functions key=func item=desc}
- <option value="{$func}" {if $smarty.session.csv_value[$f] eq $func}selected="selected"{/if}>{$desc.desc}</option>
- {/foreach}
- </optgroup>
- {/if}
- </select>
- </td>
- <td>
- <span id="csv_user_value_span[{$f}]" {if $smarty.session.csv_value[$f] neq "user_value"}style="display: none"{/if}>
- <input type="text" name="csv_user_value[{$f}]" value="{$smarty.session.csv_user_value[$f]}" />
- </span>
- <span id="csv_cond_value_span[{$f}]" {if $smarty.session.csv_value[$f] neq "cond_value"}style="display: none"{/if}>
- Si
- <select name="csv_cond_field[{$f}]">
- {foreach from=$csv_index item=col}
- <option value="{$col}" {if $smarty.session.csv_cond_field_value[$f] eq $col}selected="selected"{/if}>
- {$col}
- </option>
- {/foreach}
- </select>
- <select name="csv_cond[{$f}]" onchange="showCond('{$f}', this)">
- <option value="defined" {if $smarty.session.csv_cond[$f] eq "defined"}selected="selected"{/if}>
- défini
- </option>
- <option value="equals" {if $smarty.session.csv_cond[$f] eq "equals"}selected="selected"{/if}>
- est égale à
- </option>
- <option value="contains" {if $smarty.session.csv_cond[$f] eq "contains"}selected="selected"{/if}>
- contient
- </option>
- <option value="contained" {if $smarty.session.csv_cond[$f] eq "contained"}selected="selected"{/if}>
- est contenu dans
- </option>
- <option value="greater" {if $smarty.session.csv_cond[$f] eq "greater"}selected="selected"{/if}>
- supérieur à
- </option>
- <option value="greater_or_equal" {if $smarty.session.csv_cond[$f] eq "greater_or_equal"}selected="selected"{/if}>
- supérieur ou égal à
- </option>
- <option value="lower" {if $smarty.session.csv_cond[$f] eq "lower"}selected="selected"{/if}>
- inférieur à
- </option>
- <option value="lower_or_equal" {if $smarty.session.csv_cond[$f] eq "lower_or_equal"}selected="selected"{/if}>
- inférieur ou égal à
- </option>
- </select>
- <span id="csv_cond_value[{$f}]" {if $smarty.session.csv_cond[$f] eq "defined" || !$smarty.session.csv_cond[$f]}style="display: none"{/if}>
- <input type="text" name="csv_cond_value[{$f}]" value="{$smarty.session.csv_cond_value[$f]}" />
- </span>
- <br />Alors <input type="text" name="csv_cond_then[{$f}]" value="{$smarty.session.csv_cond_then[$f]}" />
- <br />Sinon <input type="text" name="csv_cond_else[{$f}]" value="{$smarty.session.csv_cond_else[$f]}" />
- </span>
- </td>
- {if $smarty.session.csv_action eq 'update'}
- <td class="center">
- <input type="checkbox" name="csv_update[{$f}]" {if $smarty.session.csv_update[$f]}checked="checked"{/if} />
- </td>
- {/if}
- </tr>
- {/foreach}
- </table>
- {elseif $csv_page eq 'valid'}
- {if !$csv_done}
- <table class="bicol">
- <tr>
- {foreach from=$csv_fields item=f}
- <th>{$csv_field_desc[$f]|default:$f}</th>
- {/foreach}
- </tr>
- {foreach from=$csv_preview item=assoc}
- <tr class="{cycle values="pair,impair"}">
- {foreach from=$csv_fields item=f}
- <td>{$assoc[$f]}</td>
- {/foreach}
- <tr>
- {/foreach}
- </table>
- {else}
- Les données ont été ajoutées.
- {/if}
- {/if}
-
- {if !$csv_done}
- <div class="center">
- <input type="hidden" name="csv_page" value="{$csv_page}" />
- <input type="hidden" id="csv_next_page" name="csv_next_page" value="{$csv_page}" />
- {if $csv_page eq 'source'}
- <input type="submit" name="csv_valid" value="Changer le CSV" />
- {elseif $csv_page eq 'values'}
- <input type="submit" name="csv_valid" value="Aperçu" />
- {elseif $csv_page eq 'valid'}
- <input type="submit" name="csv_valid" value="Valider" />
- {/if}
- </div>
- {/if}
-</form>
-
-{* vim:set et sws=2 sts=2 sw=2 enc=utf-8: *}
<table>
{if $address.entreprise || $address.web}
<tr>
- <td><em>Ent/Org: </em></td>
+ <td><em>Ent/Org : </em></td>
<td><strong>{$address.entreprise}{if $address.web} [<a href='{$address.web}'>site</a>]{/if}</strong></td>
</tr>
{/if}
{if $address.secteur}
<tr>
- <td><em>Secteur: </em></td>
+ <td><em>Secteur : </em></td>
<td><strong>{$address.secteur}{if $address.ss_secteur} ({$address.ss_secteur}){/if}</strong></td>
</tr>
{/if}
{if $address.fonction}
<tr>
- <td><em>Fonction: </em></td>
+ <td><em>Fonction : </em></td>
<td><strong>{$address.fonction}</strong></td>
</tr>
{/if}
{if $address.poste}
<tr>
- <td><em>Poste: </em></td>
+ <td><em>Poste : </em></td>
<td><strong>{$address.poste}</strong></td>
</tr>
{/if}
{if $withtext}
<a href="Xorg/FAQ?display=light#flags" class="popup_800x240">Quelle couleur ?</a>
{/if}
-<input type="radio" name="{$name}" value="public" {if $val eq 'public'}checked="checked"{/if}
+<label><input type="radio" name="{$name}" value="public" {if $val eq 'public'}checked="checked"{/if}
{if $disabled}disabled="disabled"{/if}/>
{icon name="flag_green" title="site public"}
-{if $withtext}<span class="texte">site public</span>{/if}
-<input type="radio" name="{$name}" value="ax" {if $val eq 'ax'}checked="checked"{/if}
+{if $withtext}<span class="texte">site public</span>{/if}</label>
+<label><input type="radio" name="{$name}" value="ax" {if $val eq 'ax'}checked="checked"{/if}
{if $disabled}disabled="disabled"{/if}/>
{icon name="flag_orange" title="transmis à l'AX"}
-{if $withtext}<span class="texte">transmis à l'AX</span>{/if}
-<input type="radio" name="{$name}" value="private" {if $val eq 'private' || (!$val && !$disabled)}checked="checked"{/if}
+{if $withtext}<span class="texte">transmis à l'AX</span>{/if}</label>
+<label><input type="radio" name="{$name}" value="private" {if $val eq 'private' || (!$val && !$disabled)}checked="checked"{/if}
{if $disabled}disabled="disabled"{/if}/>
{icon name="flag_red" title="privé"}
-{if $withtext}<span class="texte">privé</span>{/if}
+{if $withtext}<span class="texte">privé</span>{/if}</label>
{* vim:set et sw=2 sts=2 sws=2 enc=utf-8: *}
{if !$c.dcd}
<a href="vcard/{$c.forlife}.vcf">{*
*}{icon name=vcard title="Afficher la carte de visite"}</a>
+ <a href="mailto:{$c.forlife}@{#globals.mail.domain#}">{*
+ *}{icon name=email title="Envoyer un email"}</a>
{if $show_action eq ajouter}
<a href="carnet/contacts?action={$show_action}&user={$c.forlife}&token={xsrf_token}">{*
*}{icon name=add title="Ajouter à mes contacts"}</a>
<tr>
<td class="lt">Profession :</td>
<td class="rt">
- {$c.entreprise} {if $c.secteur}({$c.secteur}){/if}
- {if $c.fonction}<br />{$c.fonction}{/if}
+ {if $c.job_web}<a href="{$c.job_web}">{$c.entreprise}</a>{else}{$c.entreprise}{/if}
+ {if $c.secteur}({$c.secteur}){/if} {if $c.fonction}<br />{$c.fonction}{/if}
</td>
</tr>
{/if}
+++ /dev/null
-{**************************************************************************}
-{* *}
-{* Copyright (C) 2003-2008 Polytechnique.org *}
-{* http://opensource.polytechnique.org/ *}
-{* *}
-{* This program is free software; you can redistribute it and/or modify *}
-{* it under the terms of the GNU General Public License as published by *}
-{* the Free Software Foundation; either version 2 of the License, or *}
-{* (at your option) any later version. *}
-{* *}
-{* This program is distributed in the hope that it will be useful, *}
-{* but WITHOUT ANY WARRANTY; without even the implied warranty of *}
-{* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *}
-{* GNU General Public License for more details. *}
-{* *}
-{* You should have received a copy of the GNU General Public License *}
-{* along with this program; if not, write to the Free Software *}
-{* Foundation, Inc., *}
-{* 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA *}
-{* *}
-{**************************************************************************}
-
-{capture name=pages}
-{if $plview->pages > 1}
- {if $show_bounds}<div style="float: right"><small><strong>[{$first} - {$last}] </strong></small></div>{/if}
-<div class="center pages" style="float: left">
- {if $plview->page neq 1}
- <a href="{$platal->pl_self()}{$plset_search}order={$order}&page=1#pl_set_top">{icon name=resultset_first title="Première page"}</a>{*
- *}<a href="{$platal->pl_self()}{$plset_search}order={$order}&page={$plview->page-1}#pl_set_top">{icon name=resultset_previous title="Page précédente"}</a>
- {else}
- {icon name=null title=""}{icon name=null title=""}
- {/if}
- {section name=page loop=$plview->pages+1 start=1}
- {if $smarty.section.page.index eq $plview->page}
- <span style="color: red">{$plview->page}</span>
- {else}
- <a href="{$platal->pl_self()}{$plset_search}order={$order}&page={$smarty.section.page.index}#pl_set_top">{$smarty.section.page.index}</a>
- {/if}
- {/section}
- {if $plview->page neq $plview->pages}
- <a href="{$platal->pl_self()}{$plset_search}order={$order}&page={$plview->page+1}#pl_set_top">{icon name=resultset_next title="Page suivante"}</a>{*
- *}<a href="{$platal->pl_self()}{$plset_search}order={$order}&page={$plview->pages}#pl_set_top">{icon name=resultset_last title="Dernière page"}</a>
- {else}
- {icon name=null title=""}{icon name=null title=""}
- {/if}
-</div>
-{/if}
-{/capture}
-
-{capture name=order}
-{if $plset_count > 1}
-<div style="clear: both">
- Trier par :
- {foreach from=$orders key=name item=sort}
- [
- {if $name eq $order}
- <img src='images/dn.png' alt='tri ascendant' />
- <a href="{$platal->pl_self()}{$plset_search}order=-{$name}#pl_set_top">{$sort.desc}</a>
- {elseif $order eq "-$name"}
- <img src='images/up.png' alt='tri ascendant' />
- <a href="{$platal->pl_self()}{$plset_search}order={$name}#pl_set_top">{$sort.desc}</a>
- {else}
- <a href="{$platal->pl_self()}{$plset_search}order={$name}#pl_set_top">{$sort.desc}</a>
- {/if}
- ]
- {/foreach}
-</div>
-{/if}
-{/capture}
-
-
-{$smarty.capture.order|smarty:nodefaults}
-
-{$smarty.capture.pages|smarty:nodefaults}
-
-<div id="multipage_content" style="padding: 0.5em 0; clear: both">
- {include file=$plview->templateName()}
-</div>
-
-{$smarty.capture.pages|smarty:nodefaults}<br />
-
-{$smarty.capture.order|smarty:nodefaults}
-
-{* vim:set et sw=2 sts=2 sws=2 enc=utf-8: *}
</tr>
</table>
-{include file="core/plset.tpl"}
+{include core=plset.tpl}
<h1>
modérateurs de la liste
{if $options|@count}
<table class='bicol' cellpadding='2' cellspacing='0'>
<tr><th colspan='3'>Options incorrectes pour {$details.addr}</th></tr>
- <tr><th>champs</th><th>devrait être:</th><th>est ...</th></tr>
+ <tr><th>champs</th><th>devrait être :</th><th>est ...</th></tr>
{foreach from=$options key=k item=o}
<tr>
<td class='titre'>{$k}</td>
<td>{$del_user.name}</td>
</tr>
<tr>
- <td>raison:
+ <td>raison :
<textarea cols='50' rows='10' name='reason'></textarea>
</td>
</tr>
{/iterate}
<tr>
<td></td>
- <td colspan='5' class='smaller'>(*): email perso</td>
+ <td colspan='5' class='smaller'>(*) : email perso</td>
</tr>
<tr>
<td>
<th colspan="2">Edition de l'email de relance</th>
</tr>
<tr class="pair">
- <td align="right"><strong>From:</strong></td>
+ <td align="right"><strong>From :</strong></td>
<td>
{if $rel_from_staff neq $rel_from_user}
<select name="from">
</td>
</tr>
<tr class="pair">
- <td align="right"><strong>To:</strong></td>
+ <td align="right"><strong>To :</strong></td>
<td>
<input type="text" value="{$rel_to}" name="to" size="40" maxlength="100" />
<input type="submit" name="valider" value="Envoyer" />
</td>
</tr>
<tr class="pair">
- <td align="right"><strong>Objet:</strong></td>
+ <td align="right"><strong>Objet :</strong></td>
<td><input type="text" name="title" value="{$rel_title}" size="50" maxlength="100" /></td>
</tr>
<tr class="pair">
- <td align="right"><strong>Message:</strong></td>
+ <td align="right"><strong>Message :</strong></td>
<td>
<textarea name="message" rows="40" cols="60">{$rel_text}</textarea>
</td>
<a href="marketing/promo/{$promo-1}" title="-1"><img src="images/icons/resultset_previous.gif" alt="[<]" /></a>
- Promo:<input type="text" name="promo" value="{$promo}" size="4" maxlength="4" /><input type="submit" value="GO" />
+ Promo :<input type="text" name="promo" value="{$promo}" size="4" maxlength="4" /><input type="submit" value="GO" />
<a href="marketing/promo/{$promo+1}" title="+1"><img src="images/icons/resultset_next.gif" alt="[>]" /></a>
<td>{if $it.last_known_email}{mailto address=$it.last_known_email}{/if}</td>
<td class="center">
{if $it.dern_rel && $it.dern_rel != '0000-00-00'}
- Relance le: {$it.dern_rel}
+ Relance le : {$it.dern_rel}
{elseif $it.email}
En cours : {$it.email}
{else}
<h1>Télépaiements</h1>
-{if $smarty.request.op eq "submit" and !$xorg_errors}
+{if $smarty.request.op eq "submit" and !$pl_errors}
<table class="bicol">
<tr>
Tu peux le désactiver en allant dans Préférences et en cliquant sur "désactiver les fils RSS".
</p>
<p>
-Attention: désactiver, puis réactiver le fil RSS en change l'adresse.
+Attention : désactiver, puis réactiver le fil RSS en change l'adresse.
</p>
<p>[<a href="{$goback}">retour à la page dont tu venais</a>]</p>
{/if}
</p>
<p>
Pour une sécurité optimale, ton mot de passe circule de manière chiffrée (https) et est
- stocké chiffrée irréversiblement sur nos serveurs.
+ stocké chiffré irréversiblement sur nos serveurs.
</p>
<br />
<form action="{$smarty.server.REQUEST_URI}" method="post" id="changepass">
{* *}
{**************************************************************************}
-{include file="core/table-editor.tpl"}
+{include core=table-editor.tpl}
<h1>Administration Polytechnique.org</h1>
<tr>
<td>
<div class="flags">
- <input type="checkbox" name="medals_pub"{if $medals_pub eq 'public'} checked="checked"{/if} />
- {icon name="flag_green" title="site public"}
+ <label><input type="checkbox" name="medals_pub"{if $medals_pub eq 'public'} checked="checked"{/if} />
+ {icon name="flag_green" title="site public"}</label>
<span class="texte">
bien que publiques (JO, ...), tu peux choisir de ne pas associer ces informations à ta fiche publique
</span>
{/if}
<table class="bicol" style="margin-bottom: 1em"
- summary="Profil: Trombinoscope">
+ summary="Profil : Trombinoscope">
<tr>
<th colspan="2">
<div class="flags" style="float: left">
- <input type="checkbox" name="photo_pub" {if $photo_pub eq 'public'}checked="checked" {/if}/>
- {icon name="flag_green" title="site public"}
+ <label><input type="checkbox" name="photo_pub" {if $photo_pub eq 'public'}checked="checked" {/if}/>
+ {icon name="flag_green" title="site public"}</label>
</div>
Trombinoscope
</th>
</table>
<table class="bicol" style="margin-bottom: 1em"
- summary="Profil: Divers">
+ summary="Profil : Divers">
<tr>
<th colspan="2">
Divers
<tr>
<td>
<span class="flags">
- <input type="checkbox" name="web_pub" {if $web_pub eq 'public'}checked="checked"{/if} />
- {icon name="flag_green" title="site public"}
+ <label><input type="checkbox" name="web_pub" {if $web_pub eq 'public'}checked="checked"{/if} />
+ {icon name="flag_green" title="site public"}</label>
</span>
<span class="titre">Page web Perso</span>
</td>
<td>
<div>
<span class="flags">
- <input type="checkbox" name="freetext_pub" {if $freetext_pub eq 'public'}checked="checked"{/if} />
- {icon name="flag_green" title="site public"}
+ <label><input type="checkbox" name="freetext_pub" {if $freetext_pub eq 'public'}checked="checked"{/if} />
+ {icon name="flag_green" title="site public"}</label>
</span>
<span class="titre">Complément libre</span><br />
<span class="comm">Commentaire ? ICQ ? etc...</span>
{* *}
{**************************************************************************}
-<table class="bicol" style="margin-bottom: 1em" summary="Profil: Informations Polytechniciennes">
+<table class="bicol" style="margin-bottom: 1em" summary="Profil : Informations Polytechniciennes">
<tr>
<th colspan="2">
<div class="flags" style="float: left">
<li>ou bien, plus âgés, qui souhaitent réorienter leur carrière.</li>
</ul>
-<table class="bicol" style="margin-bottom: 1em" summary="Profil: Mentoring">
+<table class="bicol" style="margin-bottom: 1em" summary="Profil : Mentoring">
<tr>
<th>
<div class="flags" style="float: left">
</tr>
</table>
-<table class="bicol" style="margin-bottom: 1em" summary="Profil: Mentoring">
+<table class="bicol" style="margin-bottom: 1em" summary="Profil : Mentoring">
<tr>
<th>
<div class="flags" style="float: left">
</tr>
</table>
-<table class="bicol" summary="Profil: Mentoring">
+<table class="bicol" summary="Profil : Mentoring">
<tr>
<th>
<div class="flags" style="float: left">
{if $plset_count}
-{include file="core/plset.tpl"}
+{include core=plset.tpl}
{else}
{include wiki=Docs.Emploi}
{/if}
<tr class="pair">
<td></td>
<td>
- 6 chiffres terminant par le numéro d'entrée (ex:
+ 6 chiffres terminant par le numéro d'entrée (ex :
{if $promo < 2000}
{math equation="promo % 100" promo=$promo}0532)<br />
{else}
return '...';
}
- return name + '<em> - ' + row[1] + ' camarades<\/em>';
+ camarades = (row[1] > 1) ? "camarades" : "camarade";
+
+ return name + '<em> - ' + row[1] + ' ' + camarades + '<\/em>';
};
}
$("[@name='diploma']").parent().load(baseurl + 'list/diploma/', { school:schoolId }, function() {
if ($("select[@name='diploma']").children("option").size() > 1) {
$("select[@name='diploma']").attr('value', '{/literal}{$smarty.request.diploma}{literal}');
-
- $("tr#diploma_ln").show();
} else {
$("select[@name='diploma']").attr('value', '');
-
- $("tr#diploma_ln").hide();
}
});
} else {
$(".autocomplete[@name='schoolTxt']").removeClass('hidden_valid');
$("select[@name='diploma']").attr('value', '');
-
- $("tr#diploma_ln").hide();
}
}
<th colspan="2">Géographie</th>
</tr>
<tr>
- <td>Ville</td>
+ <td>Ville ou code postal</td>
<td><input type="text" class="autocomplete" name="city" size="32" value="{$smarty.request.city}" /></td>
</tr>
<tr>
<a href="school" class="autocompleteToSelect">{icon name="table" title="Toutes les formations"}</a>
</td>
</tr>
- <tr id="diploma_ln">
+ <tr>
<td>Diplôme</td>
<td>
- <input name="diploma" type="hidden" size="32" value="{$smarty.request.diploma}"/>
+ <input name="diploma" size="32" value="{$smarty.request.diploma}"/>
</td>
</tr>
<tr>
<label for="order">Mettre les fiches modifiées récemment en premier.</label>
</td>
</tr>
+ <tr>
+ <td colspan="2">
+ <input type='checkbox' name='exact' id="exact" {if $smarty.request.exact}checked='checked'{/if} value='1'/>
+ <label for="exact">Faire une recherche exacte.</label>
+ </td>
+ </tr>
{/if}
<tr><td colspan="2"></td></tr>
<tr>
{**************************************************************************}
-{if $formulaire eq 0 and !$xorg_errors}
+{if $formulaire eq 0 and !$pl_errors}
{if !$simple}
{if !$advanced}
{include file=search/quick.form.tpl show_js=1}
{include file=search/adv.links.tpl do_title=1 with_soundex=$with_soundex}
{/if}
{/if}
-
- {include file='core/plset.tpl'}
+
+ {include core=plset.tpl}
{if $search_pages_nb > 1}
<p>
+++ /dev/null
-{**************************************************************************}
-{* *}
-{* Copyright (C) 2003-2008 Polytechnique.org *}
-{* http://opensource.polytechnique.org/ *}
-{* *}
-{* This program is free software; you can redistribute it and/or modify *}
-{* it under the terms of the GNU General Public License as published by *}
-{* the Free Software Foundation; either version 2 of the License, or *}
-{* (at your option) any later version. *}
-{* *}
-{* This program is distributed in the hope that it will be useful, *}
-{* but WITHOUT ANY WARRANTY; without even the implied warranty of *}
-{* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *}
-{* GNU General Public License for more details. *}
-{* *}
-{* You should have received a copy of the GNU General Public License *}
-{* along with this program; if not, write to the Free Software *}
-{* Foundation, Inc., *}
-{* 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA *}
-{* *}
-{**************************************************************************}
-
-{foreach from=$backtraces key=bt_name item=trace}
-<div class="backtrace">
- <h1>
- {if $trace->error}<span style="color: #f00">{/if}
- Exécution de {$bt_name} : {$trace->traces|@count} actions en {$trace->totaltime|string_format:"%.3f"}s (hover-me pour la trace)
- {if $trace->error}</span>{/if}
- </h1>
- <div class="hide">
-{foreach item=query from=$trace->traces}
-{if $query.data}
-{assign var=cols value=$query.data[0]|@count}
-{else}
-{assign var=cols value=1}
-{/if}
-<table class="bicol" style="width: 75%; font-size: smaller; margin-left:2px; margin-top: 3px;">
- <tr class="impair">
- <td colspan="{$cols}">
- <strong>ACTION:</strong>
- <pre style="padding: 0; margin: 0;">{$query.action}</pre>
- <br/>
- </td>
- </tr>
- {if $query.error}
- <tr>
- <td colspan="{$cols}">
- <strong style="color: #f00">ERROR:</strong><br />
- {$query.error|nl2br}
- </td>
- </tr>
- {else}
- <tr>
- <td colspan="{$cols}">
- <strong>INFO:</strong><br />
- {$query.rows} ligne{if $query.rows > 1}s{/if} en {$query.exectime|string_format:"%.3f"}s
- </td>
- </tr>
- {/if}
-{if $query.data}
- <tr>
- {foreach key=key item=item from=$query.data[0]}
- <th style="font-size: smaller">{$key}</th>
- {/foreach}
- </tr>
- {foreach item=data_row from=$query.data}
- <tr class="impair">
- {foreach item=item from=$data_row}
- <td class="center" style="font-size: smaller">{$item}</td>
- {/foreach}
- </tr>
- {/foreach}
-{/if}
-</table>
-{/foreach}
-</div>
-</div>
-{/foreach}
-
-{* vim:set et sw=2 sts=2 sws=2 enc=utf-8: *}
<br />
{/if}
-{if !$xorg_no_errors || $xorg_failure}
-{include file="skin/common.triggers.tpl"}
+{if !$pl_no_errors || $pl_failure}
+{include core=triggers.tpl}
{/if}
-{if !$xorg_failure && $xorg_tpl}{include file=$xorg_tpl}{/if}
+{if !$pl_failure && $pl_tpl}{include file=$pl_tpl}{/if}
{* vim:set et sw=2 sts=2 sws=2 enc=utf-8: *}
{if $validate}
<div id="dev">
@HOOK@
- Validation:
+ Validation :
<a href="http://jigsaw.w3.org/css-validator/validator?uri={#globals.baseurl#}/valid.html">CSS</a>
|
références :
<link rel="bookmark" href="http://www.polytechnique.fr/eleves/" title="| Site d'élèves" />
<link rel="stylesheet" type="text/css" href="css/base.css" media="all"/>
- {foreach from=$xorg_css item=css}
+ {foreach from=$pl_css item=css}
<link rel="stylesheet" type="text/css" href="css/{$css}" media="all"/>
{/foreach}
- {foreach from=$xorg_inline_css item=css}
+ {foreach from=$pl_inline_css item=css}
<style type="text/css">
{$css|smarty:nodefaults}
</style>
<script type="text/javascript">
var platal_baseurl = "{$globals->baseurl}/";
</script>
- {foreach from=$xorg_js item=js}
+ {foreach from=$pl_js item=js}
<script type="text/javascript" src="javascript/{$js}"></script>
{/foreach}
{javascript name=overlib}
{javascript name=sha1}
{javascript name=secure_hash}
- {if $xorg_rss}
- <link rel="alternate" type="application/rss+xml" title="{$xorg_rss.title}" href="{$xorg_rss.href}" />
+ {if $pl_rss}
+ <link rel="alternate" type="application/rss+xml" title="{$pl_rss.title}" href="{$pl_rss.href}" />
{/if}
- {if $xorg_extra_header}
- {$xorg_extra_header|smarty:nodefaults}
+ {if $pl_extra_header}
+ {$pl_extra_header|smarty:nodefaults}
{/if}
- <title>{$xorg_title|default:"Polytechnique.org : le site des élèves et anciens élèves de l'École polytechnique"}</title>
+ <title>{$pl_title|default:"Polytechnique.org : le site des élèves et anciens élèves de l'École polytechnique"}</title>
{* vim:set et sw=2 sts=2 sws=2 enc=utf-8: *}
+++ /dev/null
-{**************************************************************************}
-{* *}
-{* Copyright (C) 2003-2008 Polytechnique.org *}
-{* http://opensource.polytechnique.org/ *}
-{* *}
-{* This program is free software; you can redistribute it and/or modify *}
-{* it under the terms of the GNU General Public License as published by *}
-{* the Free Software Foundation; either version 2 of the License, or *}
-{* (at your option) any later version. *}
-{* *}
-{* This program is distributed in the hope that it will be useful, *}
-{* but WITHOUT ANY WARRANTY; without even the implied warranty of *}
-{* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *}
-{* GNU General Public License for more details. *}
-{* *}
-{* You should have received a copy of the GNU General Public License *}
-{* along with this program; if not, write to the Free Software *}
-{* Foundation, Inc., *}
-{* 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA *}
-{* *}
-{**************************************************************************}
-
-{foreach from=$xorg_triggers key=type item=triggers}
-{if $triggers|@count}
-<div class="{$type}">
- <ul>
- {foreach from=$triggers item=err}
- <li>{$err|smarty:nodefaults}</li>
- {/foreach}
- </ul>
-</div>
-{/if}
-{/foreach}
-
-{* vim:set et sw=2 sts=2 sws=2 enc=utf-8: *}
{elseif $survey_message neq ""}
{$survey_message}
{else}
-Une erreur inconnue est survenue dans l'édition de ce sondage. N'hésite pas à <a href='send_bug/{ $smarty.server.REQUEST_URI }'>signaler ce bug</a> si il persiste.
+Une erreur inconnue est survenue dans l'édition de ce sondage. N'hésite pas à <a href='send_bug/{ $smarty.server.REQUEST_URI }'>signaler ce bug</a> s'il persiste.
{/if}
<br/>
<a href="{$survey_link}">Retour</a>
<table id="content" cellpadding="2" cellspacing="0">
<tr>
<td style="vertical-align: middle;">
- <img src="images/parfait.jpg" width="459" height="200" alt="Logo des groupes" />
+ <a href="plan"><img src="images/parfait.jpg" width="459" height="200" alt="Logo des groupes" /></a>
</td>
<td>
<link rel="bookmark" href="http://www.polytechnique.org/" title="| Polytechnique.org" />
<link rel="bookmark" href="http://www.polytechnique.fr/eleves/" title="| Site d'élèves" />
- {foreach from=$xorg_css item=css}
+ {foreach from=$pl_css item=css}
<link rel="stylesheet" type="text/css" href="css/{$css}" />
{/foreach}
- {foreach from=$xorg_inline_css item=css}
+ {foreach from=$pl_inline_css item=css}
<style type="text/css">
{$css|smarty:nodefaults}
</style>
if (window.top != window)
document.write('<link rel="stylesheet" type="text/css" href="css/onlycontent.css" media="all"/>');
</script>
- {foreach from=$xorg_js item=js}
+ {foreach from=$pl_js item=js}
<script type="text/javascript" src="javascript/{$js}"></script>
{/foreach}
{javascript name=overlib}
- {if $xorg_rss}
- <link rel="alternate" type="application/rss+xml" title="{$xorg_rss.title}" href="{$xorg_rss.href}" />
+ {if $pl_rss}
+ <link rel="alternate" type="application/rss+xml" title="{$pl_rss.title}" href="{$pl_rss.href}" />
{/if}
- {if $xorg_extra_header}
- {$xorg_extra_header|smarty:nodefaults}
+ {if $pl_extra_header}
+ {$pl_extra_header|smarty:nodefaults}
{/if}
<title>Les associations polytechniciennes</title>
--
{$smarty.session.prenom} {$smarty.session.nom}{/if}</textarea><br />
- Page internet de l'événement : <input size="40" name="site" value="{$paiement_site|default:$asso.site|default:$platal->ns}" /><br />
+ Page internet de l'événement : <input size="40" name="site" value="{$paiement_site|default:$asso.site|default:$globals->baseurl|cat:'/'|cat:$platal->ns}" /><br />
Le nouveau paiement sera activé automatiquement après validation par le trésorier de Polytechnique.org,
ce qui sera fait sous peu.
<script type="text/javascript">//<![CDATA[
{* 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA *}
{* *}
{**************************************************************************}
-
-<?xml version="1.0"?>
-<rss version="2.0">
- <channel>
- <title>Polytechnique.net :: {$asso.nom|htmlentities} :: News</title>
- <language>fr</language>
- <link>{#globals.baseurl#}/{$asso.diminutif}/</link>
- <description>L'actualite polytechnicienne...</description>
- <image>
- <title>{#globals.core.sitename#}</title>
- <url>{#globals.baseurl#}/images/logo.png</url>
- <link>{#globals.baseurl#}/{$asso.diminutif}/</link>
- </image>
- {iterate item=line from=$rss}
- <item>
- <title>{$line.titre|strip_tags|htmlentities}</title>
- <guid isPermaLink="false">{$line.id}</guid>
- <link>{#globals.baseurl#}/{$asso.diminutif}/#art{$line.id}</link>
- <description><![CDATA[
- {if $line.photo}
- <div style="float: left; padding-right: 0.5em">
- <img src="{#globals.baseurl#}/{$asso.diminutif}/announce/photo/{$line.id}" alt="{$line.titre|strip_tags}" />
- </div>
- {/if}
- <div>{$line.texte|miniwiki}{if $line.contacts}<br/><br/><strong>Contacts :</strong><br/>{$line.contacts|miniwiki}{/if}</div>]]></description>
- <author>{$line.prenom} {$line.nom} (X{$line.promo})</author>
- <pubDate>{$line.create_date|rss_date}</pubDate>
- </item>
- {/iterate}
- </channel>
-</rss>
+{if $article->photo}
+<div style="float: left; padding-right: 0.5em">
+ <img src="{#globals.baseurl#}/{$asso.diminutif}/announce/photo/{$article->id}" alt="{$article->titre|strip_tags}" />
+</div>
+{/if}
+<div>{$article->texte|miniwiki}{if $article->contacts}<br/><br/><strong>Contacts :</strong><br/>{$article->contacts|miniwiki}{/if}</div>
{* vim:set et sw=2 sts=2 sws=2 enc=utf-8: *}
</ul>
{if $plset_base}
-{include file="core/plset.tpl"}
+{include core=plset.tpl}
{else}
<p class="center">
{if $broken}
<p class="smaller">
- {icon name=error} : Un camarade signalé par ce symbole n'a plus d'adresse de redirection et ne peut donc
+ {icon name=error} Un camarade signalé par ce symbole n'a plus d'adresse de redirection et ne peut donc
plus être contacté via son adresse polytechnique.org. Si tu connais sa nouvelle adresse, tu peux nous la communiquer en
cliquant sur le symbole.
</p>
{if $asso.site}
<tr>
<td class="titre">
- Site Web:
+ Site Web :
</td>
<td><a href="{$asso.site}">{$asso.site}</a></td>
</tr>
{if $asso.resp || $asso.mail}
<tr>
<td class="titre">
- Contact:
+ Contact :
</td>
<td>
{if $asso.mail}
{if $asso.forum}
<tr>
<td class="titre">
- Forum:
+ Forum :
</td>
<td>
<a href="{$platal->ns}forum">par le web</a>
Site web :
</td>
<td>
- <input type="text" size="40" value="{$asso.site}" name="site" />
+ <input type="text" size="40" value="{$asso.site|default:"http://"}" name="site" />
</td>
</tr>
<tr>
<td colspan="2">
<input type="checkbox" id="x" name="x" onchange="xStateChange(this);" />
- <label for="x">Coche cette case si il s'agit d'un X non inscrit à Polytechnique.org.</label>
+ <label for="x">Coche cette case s'il s'agit d'un X non inscrit à Polytechnique.org.</label>
</td>
</tr>
<tr id="xnom" style="display: none">
<td colspan="2">
<span id="make_X_cb">
<input type="checkbox" name="is_x" id="is_x" onclick="showXInput(this);" onchange="showXInput(this);" />
- <label for="is_x">coche cette case si il s'agit d'un X</label>
+ <label for="is_x">coche cette case s'il s'agit d'un X</label>
</span>
<span id="make_X_login" style="display: none">
<span class="titre">Identifiant (prenom.nom.promo) :</span>
--- /dev/null
+ALTER TABLE applis_ins MODIFY type enum('Corps','Ingénieur','MBA','ME','MS','PhD','Diplôme','DEA','MiF','MPA', 'MIA');
+
+ALTER TABLE applis_def MODIFY type set('Corps','Ingénieur','MBA','ME','MS','PhD','Diplôme','DEA','MiF','MPA', 'MIA')
+
+# vim:set syntax=mysql:
+
--- /dev/null
+alter table geoloc_pays change column nat nat varchar(100);
+update geoloc_pays
+ set nat = NULL
+ where a2 = 'MQ' or a2 = 'RE' or a2 = 'GP' or a2 = 'YT' or a2 = 'TF' or a2 = 'PF' or a2 = 'NC' or a2 = 'GF'
+ or a2 = 'UM';
+update auth_user_md5 set nationalite = 'FR' where nationalite = 'MQ' or nationalite = 'RE' or nationalite = 'GP' or nationalite = 'YT' or nationalite = 'TF' or nationalite = 'PF' or nationalite = 'NC' or nationalite = 'GF';
+
+# vim:set syntax=mysql: