From b76f079747fde07b41b89b22c4d08fe835d04052 Mon Sep 17 00:00:00 2001 From: x2000habouzit Date: Sun, 23 Jul 2006 11:26:07 +0000 Subject: [PATCH] remove move cruft git-svn-id: svn+ssh://murphy/home/svn/platal/trunk@578 839d8a87-29fc-0310-9880-83ba4fa771e5 --- include/platal/page.inc.php => classes/Page.php | 72 ++++++++++++++++++- classes/Session.php | 22 ++++++ include/platal/session.inc.php | 47 ------------- include/platal/smarty.plugins.inc.php | 93 ------------------------- include/xnet/page.inc.php | 39 ++++++++++- include/xnet/session.inc.php | 2 +- include/xnet/smarty.plugins.inc.php | 59 ---------------- include/xorg.inc.php | 3 +- include/xorg/session.inc.php | 2 +- 9 files changed, 134 insertions(+), 205 deletions(-) rename include/platal/page.inc.php => classes/Page.php (79%) delete mode 100644 include/platal/session.inc.php delete mode 100644 include/platal/smarty.plugins.inc.php delete mode 100644 include/xnet/smarty.plugins.inc.php diff --git a/include/platal/page.inc.php b/classes/Page.php similarity index 79% rename from include/platal/page.inc.php rename to classes/Page.php index f81f994..4b6b302 100644 --- a/include/platal/page.inc.php +++ b/classes/Page.php @@ -20,7 +20,6 @@ ***************************************************************************/ require_once 'smarty/libs/Smarty.class.php'; -require_once 'platal/smarty.plugins.inc.php'; class PlatalPage extends Smarty { @@ -211,5 +210,76 @@ class PlatalPage extends Smarty // }}} } +// {{{ 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)) { + $transtbl = Array('<' => '<', '>' => '>', '"' => '"', '\'' => '''); + return preg_replace("/&(?![A-Za-z]{0,4}\w{2,3};|#[0-9]{2,4};)/", "&" , strtr($string, $transtbl)); + } 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 = array('script', 'pre', 'textarea'); + + foreach ($tags as $tag) { + preg_match_all("!<{$tag}[^>]+>.*?!is", $source, ${$tag}); + $source = preg_replace("!<{$tag}[^>]+>.*?!is", "&&&{$tag}&&&", $source); + } + + // remove all leading spaces, tabs and carriage returns NOT + // preceeded by a php close tag. + $source = preg_replace('/((?)\n)[\s]+/m', '\1', $source); + + foreach ($tags as $tag) { + $source = preg_replace("!&&&{$tag}&&&!e", 'array_shift(${$tag}[0])', $source); + } + + return $source; +} + +// }}} + // vim:set et sw=4 sts=4 sws=4 foldmethod=marker: ?> diff --git a/classes/Session.php b/classes/Session.php index 0a641a6..f87face 100644 --- a/classes/Session.php +++ b/classes/Session.php @@ -19,6 +19,9 @@ * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA * ***************************************************************************/ +require_once 'diogenes/diogenes.misc.inc.php'; +require_once 'diogenes/diogenes.core.logger.inc.php'; + class Session { function init() @@ -71,4 +74,23 @@ class Session class S extends Session { } +// {{{ 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."); + } +} + +// }}} + ?> diff --git a/include/platal/session.inc.php b/include/platal/session.inc.php deleted file mode 100644 index 6cd8dbf..0000000 --- a/include/platal/session.inc.php +++ /dev/null @@ -1,47 +0,0 @@ -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: -?> diff --git a/include/platal/smarty.plugins.inc.php b/include/platal/smarty.plugins.inc.php deleted file mode 100644 index e3109e9..0000000 --- a/include/platal/smarty.plugins.inc.php +++ /dev/null @@ -1,93 +0,0 @@ - < - * > --> > - * " --> " - * & not followed by some entity --> & - */ -function escape_html($string) -{ - if(is_string($string)) { - $transtbl = Array('<' => '<', '>' => '>', '"' => '"', '\'' => '''); - return preg_replace("/&(?![A-Za-z]{0,4}\w{2,3};|#[0-9]{2,4};)/", "&" , strtr($string, $transtbl)); - } 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 = array('script', 'pre', 'textarea'); - - foreach ($tags as $tag) { - preg_match_all("!<{$tag}[^>]+>.*?!is", $source, ${$tag}); - $source = preg_replace("!<{$tag}[^>]+>.*?!is", "&&&{$tag}&&&", $source); - } - - // remove all leading spaces, tabs and carriage returns NOT - // preceeded by a php close tag. - $source = preg_replace('/((?)\n)[\s]+/m', '\1', $source); - - foreach ($tags as $tag) { - $source = preg_replace("!&&&{$tag}&&&!e", 'array_shift(${$tag}[0])', $source); - } - - return $source; -} - -// }}} -// vim:set et sw=4 sts=4 sws=4 foldmethod=marker: -?> diff --git a/include/xnet/page.inc.php b/include/xnet/page.inc.php index 744711a..8d84f63 100644 --- a/include/xnet/page.inc.php +++ b/include/xnet/page.inc.php @@ -19,8 +19,7 @@ * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA * ***************************************************************************/ -require_once('platal/page.inc.php'); -require_once('xnet/smarty.plugins.inc.php'); +require_once dirname(__FILE__).'/../../classes/Page.php'; class XnetPage extends PlatalPage { @@ -113,5 +112,41 @@ class XnetPage extends PlatalPage // }}} } +// {{{ function list_all_my_groups + +function list_all_my_groups($params) +{ + if (!S::logged()) { + return; + } + $res = XDB::iterRow( + "SELECT a.nom, a.diminutif + FROM groupex.asso AS a + INNER JOIN groupex.membres AS m ON m.asso_id = a.id + WHERE m.uid={?}", S::v('uid')); + $html = '
Mes groupes :
'; + while (list($nom, $mini) = $res->next()) { + $html .= "• $nom"; + } + return $html; +} + +// }}} +// {{{ cat_pp + +function cat_pp($cat) +{ + $trans = array( + 'groupesx' => 'Groupes X' , + 'binets' => 'Binets' , + 'institutions' => 'Institutions' , + 'promotions' => 'Promotions' + ); + + return $trans[strtolower($cat)]; +} + +// }}} + // vim:set et sw=4 sts=4 sws=4 foldmethod=marker: ?> diff --git a/include/xnet/session.inc.php b/include/xnet/session.inc.php index 8e00856..a85780a 100644 --- a/include/xnet/session.inc.php +++ b/include/xnet/session.inc.php @@ -19,7 +19,7 @@ * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA * ***************************************************************************/ -require_once('platal/session.inc.php'); +require_once dirname(__FILE__).'/../../classes/Session.php'; class XnetSession { diff --git a/include/xnet/smarty.plugins.inc.php b/include/xnet/smarty.plugins.inc.php deleted file mode 100644 index b0352a7..0000000 --- a/include/xnet/smarty.plugins.inc.php +++ /dev/null @@ -1,59 +0,0 @@ -Mes groupes :'; - while (list($nom, $mini) = $res->next()) { - $html .= "• $nom"; - } - return $html; -} - -// }}} -// {{{ cat_pp - -function cat_pp($cat) -{ - $trans = array( - 'groupesx' => 'Groupes X' , - 'binets' => 'Binets' , - 'institutions' => 'Institutions' , - 'promotions' => 'Promotions' - ); - - return $trans[strtolower($cat)]; -} - -// }}} - -// vim:set et sw=4 sts=4 sws=4 foldmethod=marker: -?> diff --git a/include/xorg.inc.php b/include/xorg.inc.php index e655036..3d84c05 100644 --- a/include/xorg.inc.php +++ b/include/xorg.inc.php @@ -18,6 +18,7 @@ * Foundation, Inc., * * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA * ***************************************************************************/ + require_once('platal.inc.php'); require_once('xorg/globals.inc.php'); require_once('xorg/session.inc.php'); @@ -25,7 +26,7 @@ XorgGlobals::init(); XorgGlobals::setlocale(); XorgSession::init(); -require_once('platal/page.inc.php'); +require_once dirname(__FILE__).'/../classes/Page.php'; // {{{ class XorgPage diff --git a/include/xorg/session.inc.php b/include/xorg/session.inc.php index 841bbd1..a9e751e 100644 --- a/include/xorg/session.inc.php +++ b/include/xorg/session.inc.php @@ -19,7 +19,7 @@ * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA * ***************************************************************************/ -require_once 'platal/session.inc.php'; +require_once dirname(__FILE__).'/../../classes/Session.php'; // {{{ class XorgSession -- 2.1.4