From 9016a71e106fcf3288b8edafbf678a920c047f0d Mon Sep 17 00:00:00 2001 From: "Pierre Habouzit (MadCoder" Date: Fri, 3 Dec 2004 11:22:03 +0000 Subject: [PATCH] make webredirect (aka carva) be a module * WebRedirect : - now standalone ! git-archimport-id: opensource@polytechnique.org--2005/platal--mainline--0.9--patch-24 --- bin/devel/modules_status | 2 +- htdocs/{carva_redirect.php => webredirect.php} | 8 ++--- include/conf.d/webredirect.globals.inc.php | 34 ++++++++++++++++++++++ include/xorg.inc.php | 4 +-- install.d/STATE | 2 +- install.d/web-redirect/files | 5 ---- install.d/webredirect/README | 26 +++++++++++++++++ install.d/webredirect/files | 6 ++++ install.d/webredirect/install.sql | 3 ++ install.d/webredirect/uninstall.sql | 3 ++ bin/carva/redirect.php => scripts/webredirect.php | 2 +- .../error.php => scripts/webredirect_error.php | 0 .../{30.redirect.tpl => 80.webredirect.tpl} | 2 +- templates/{carva_redirect.tpl => webredirect.tpl} | 12 +++++--- upgrade/0.9.3/30_auth_user_md5.sql | 19 ++++++++++++ 15 files changed, 109 insertions(+), 19 deletions(-) rename htdocs/{carva_redirect.php => webredirect.php} (90%) create mode 100644 include/conf.d/webredirect.globals.inc.php delete mode 100644 install.d/web-redirect/files create mode 100644 install.d/webredirect/README create mode 100644 install.d/webredirect/files create mode 100644 install.d/webredirect/install.sql create mode 100644 install.d/webredirect/uninstall.sql rename bin/carva/redirect.php => scripts/webredirect.php (92%) rename bin/carva/error.php => scripts/webredirect_error.php (100%) rename templates/preferences.tpl.d/{30.redirect.tpl => 80.webredirect.tpl} (95%) rename templates/{carva_redirect.tpl => webredirect.tpl} (85%) diff --git a/bin/devel/modules_status b/bin/devel/modules_status index 118a173..185e0b8 100755 --- a/bin/devel/modules_status +++ b/bin/devel/modules_status @@ -2,7 +2,7 @@ chdir ${1:-.} -dirs=(bin configs htdocs hooks include plugins templates) +dirs=(bin configs htdocs hooks include plugins scripts templates) opts=(-type f -not -path '*CVS*' -not -name '.cvsignore' -not -path '*.arch*') diff -u <(cat install.d/**/files|sort) <(find $dirs $opts|sort) \ diff --git a/htdocs/carva_redirect.php b/htdocs/webredirect.php similarity index 90% rename from htdocs/carva_redirect.php rename to htdocs/webredirect.php index fe52340..3698f41 100644 --- a/htdocs/carva_redirect.php +++ b/htdocs/webredirect.php @@ -20,11 +20,11 @@ ***************************************************************************/ require_once("xorg.inc.php"); -new_skinned_page('carva_redirect.tpl', AUTH_MDP); +new_skinned_page('webredirect.tpl', AUTH_MDP); if (isset($_REQUEST['submit']) and ($_REQUEST['submit'] == "Valider" or $_REQUEST['submit'] == "Modifier") and isset($_REQUEST['url'])) { // on change la redirection (attention à http://) - $globals->db->query("update auth_user_md5 set redirecturl = '{$_REQUEST['url']}'" + $globals->db->query("update auth_user_quick set redirecturl = '{$_REQUEST['url']}'" ." where user_id = '{$_SESSION['uid']}'"); if (mysql_errno($conn) == 0) { $_SESSION['log']->log("carva_add","http://".$_REQUEST['url']); @@ -35,7 +35,7 @@ if (isset($_REQUEST['submit']) and ($_REQUEST['submit'] == "Valider" or $_REQUES } } elseif (isset($_REQUEST['submit']) and $_REQUEST['submit'] == "Supprimer") { // on supprime la redirection - $globals->db->query("update auth_user_md5 set redirecturl = '' where user_id = {$_SESSION['uid']}"); + $globals->db->query("update auth_user_quick set redirecturl = '' where user_id = {$_SESSION['uid']}"); if (mysql_errno($conn) == 0) { $_SESSION['log']->log("carva_del",$_REQUEST['url']); $_POST['url'] = ''; @@ -46,7 +46,7 @@ if (isset($_REQUEST['submit']) and ($_REQUEST['submit'] == "Valider" or $_REQUES } -$result = $globals->db->query("select redirecturl from auth_user_md5 where user_id={$_SESSION['uid']}"); +$result = $globals->db->query("select redirecturl from auth_user_quick where user_id={$_SESSION['uid']}"); list($carva) = mysql_fetch_row($result); mysql_free_result($result); $page->assign('carva', $carva); diff --git a/include/conf.d/webredirect.globals.inc.php b/include/conf.d/webredirect.globals.inc.php new file mode 100644 index 0000000..ec4a9b2 --- /dev/null +++ b/include/conf.d/webredirect.globals.inc.php @@ -0,0 +1,34 @@ +webredirect = new WebRedirConfig; + +// vim:set et sw=4 sts=4 sws=4 foldmethod=marker: +?> diff --git a/include/xorg.inc.php b/include/xorg.inc.php index c809fb6..eb3e7b2 100644 --- a/include/xorg.inc.php +++ b/include/xorg.inc.php @@ -54,7 +54,7 @@ $globals = new XorgGlobals; function _new_page($type, $tpl_name, $tpl_head, $min_auth, $admin=false) { - global $page; + global $page,$globals; require_once("xorg.page.inc.php"); if (!empty($admin)) { $page = new XorgAdmin($tpl_name, $type); @@ -88,7 +88,7 @@ function new_skinned_page($tpl_name, $min_auth, $tpl_head="") function new_simple_page($tpl_name, $min_auth, $tpl_head="") { - global $page; + global $page,$globals; _new_page(SKINNED, $tpl_name, $tpl_head, $min_auth); $page->assign('simple', true); } diff --git a/install.d/STATE b/install.d/STATE index 906d247..e87c17e 100644 --- a/install.d/STATE +++ b/install.d/STATE @@ -5,6 +5,7 @@ skins. only one minor bug +webredirect STILL NEED SOME WORK -------------------- @@ -36,5 +37,4 @@ profile register search stats -web-redirect xorg-stuff diff --git a/install.d/web-redirect/files b/install.d/web-redirect/files deleted file mode 100644 index 9df2303..0000000 --- a/install.d/web-redirect/files +++ /dev/null @@ -1,5 +0,0 @@ -htdocs/carva_redirect.php -bin/carva/error.php -bin/carva/redirect.php -templates/carva_redirect.tpl -templates/preferences.tpl.d/30.redirect.tpl diff --git a/install.d/webredirect/README b/install.d/webredirect/README new file mode 100644 index 0000000..8f0520f --- /dev/null +++ b/install.d/webredirect/README @@ -0,0 +1,26 @@ + + Notes for the webredirect module for plat/al + + +CONFIG OPTIONS +-------------- + + All settings of the module are shown here with their default and meaning + + [WebRedirect] + + domain = '' ; the domain used for web redirections. + + +BUGS +---- + + http://trackers.polytechnique.org/index.php?cat=13 + + +DEPENDS +------- + + platal + + diff --git a/install.d/webredirect/files b/install.d/webredirect/files new file mode 100644 index 0000000..e33d654 --- /dev/null +++ b/install.d/webredirect/files @@ -0,0 +1,6 @@ +htdocs/webredirect.php +include/conf.d/webredirect.globals.inc.php +scripts/webredirect_error.php +scripts/webredirect.php +templates/webredirect.tpl +templates/preferences.tpl.d/80.webredirect.tpl diff --git a/install.d/webredirect/install.sql b/install.d/webredirect/install.sql new file mode 100644 index 0000000..1830e20 --- /dev/null +++ b/install.d/webredirect/install.sql @@ -0,0 +1,3 @@ + +alter table auth_user_quick add column redirecturl varchar(255) not null; + diff --git a/install.d/webredirect/uninstall.sql b/install.d/webredirect/uninstall.sql new file mode 100644 index 0000000..e96060c --- /dev/null +++ b/install.d/webredirect/uninstall.sql @@ -0,0 +1,3 @@ + +alter table auth_user_quick drop column webredirect; + diff --git a/bin/carva/redirect.php b/scripts/webredirect.php similarity index 92% rename from bin/carva/redirect.php rename to scripts/webredirect.php index ea02e06..72cd26f 100644 --- a/bin/carva/redirect.php +++ b/scripts/webredirect.php @@ -27,7 +27,7 @@ require("../../include/xorg.inc.php"); // REQUEST_URI = /prenom.nom(/path/fichier.hmtl)? list($username, $path) = preg_split('/\//', $_SERVER["REQUEST_URI"], 2, PREG_SPLIT_NO_EMPTY); -$result = mysql_query("SELECT redirecturl FROM auth_user_md5 AS a INNER JOIN aliases AS al ON (al.id = a.user_id AND (al.type='a_vie' OR al.type='alias' OR al.type='epouse')) where al.alias= '$username'"); +$result = mysql_query("SELECT redirecturl FROM auth_user_quick AS a INNER JOIN aliases AS al ON (al.id = a.user_id AND (al.type='a_vie' OR al.type='alias' OR al.type='epouse')) where al.alias= '$username'"); if ($result and list($url) = mysql_fetch_row($result) and $url != '') { // on envoie un redirect (PHP met automatiquement le code de retour 302 if (!empty($path)) { diff --git a/bin/carva/error.php b/scripts/webredirect_error.php similarity index 100% rename from bin/carva/error.php rename to scripts/webredirect_error.php diff --git a/templates/preferences.tpl.d/30.redirect.tpl b/templates/preferences.tpl.d/80.webredirect.tpl similarity index 95% rename from templates/preferences.tpl.d/30.redirect.tpl rename to templates/preferences.tpl.d/80.webredirect.tpl index 4479135..899c379 100644 --- a/templates/preferences.tpl.d/30.redirect.tpl +++ b/templates/preferences.tpl.d/80.webredirect.tpl @@ -18,7 +18,7 @@ * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA * ***************************************************************************} -

Ma redirection de page WEB

+

Ma redirection de page WEB

Tu peux configurer tes redirections WEB http://www.carva.org/{dyn s=$smarty.session.bestalias} diff --git a/templates/carva_redirect.tpl b/templates/webredirect.tpl similarity index 85% rename from templates/carva_redirect.tpl rename to templates/webredirect.tpl index 6c32ab3..3dee9cf 100644 --- a/templates/carva_redirect.tpl +++ b/templates/webredirect.tpl @@ -31,8 +31,8 @@ Dans la lignée du service de redirection d'emails de Polytechnique.org, il est possible de faire pointer {dynamic} - les adresses http://www.carva.org/{$smarty.session.bestalias} - et http://www.carva.org/{$smarty.session.forlife} + les adresses http://{#globals.webredirect.domain#}/{$smarty.session.bestalias} + et http://{#globals.webredirect.domain#}/{$smarty.session.forlife} {/dynamic} vers la page WEB de ton choix. Pour de plus amples détails, consulte cette page @@ -52,8 +52,12 @@

{dynamic} {if $carva} - Actuellement, les adresses http://www.carva.org/{$smarty.session.bestalias} et http://www.carva.org/{$smarty.session.forlife} - sont redirigées sur http://{$carva} + Actuellement, les adresses + + http://{#globals.webredirect.domain#}/{$smarty.session.bestalias} + et + http://{#globals.webredirect.domain#}/{$smarty.session.forlife} + sont redirigées sur http://{$carva} {else} La redirection n'est pas utilisée ... {/if} diff --git a/upgrade/0.9.3/30_auth_user_md5.sql b/upgrade/0.9.3/30_auth_user_md5.sql index 3de96e9..5b67dc7 100644 --- a/upgrade/0.9.3/30_auth_user_md5.sql +++ b/upgrade/0.9.3/30_auth_user_md5.sql @@ -1,8 +1,15 @@ +-- +-- PERMS +-- alter table auth_user_md5 change column perms perms enum('user','admin','non-inscrit','pending','disabled'); update auth_user_md5 set perms='pending' where perms='non-inscrit'; alter table auth_user_md5 change column perms perms enum('user','admin','pending','disabled'); alter table auth_user_md5 change column comment comment varchar(64) not null; +-- +-- be naissance live as a date +-- + alter table auth_user_md5 add column foo int; update auth_user_md5 set foo=naissance ; alter table auth_user_md5 change column naissance naissance date not null; @@ -14,3 +21,15 @@ update en_cours set foo=naissance ; alter table en_cours change column naissance naissance date not null; update en_cours set naissance = concat(foo % 10000, '-', (foo / 10000) % 100, '-', foo / 1000000); alter table en_cours drop column foo; + +-- +-- webredirect +-- + +alter table auth_user_quick add column redirecturl varchar(255) not null; +replace into auth_user_quick (user_id,banana_last,skin,watch_flags,watch_last,redirecturl) + select q.user_id,q.banana_last,q.skin,q.watch_flags,q.watch_last,u.redirecturl + from auth_user_md5 as u + inner join auth_user_quick as q USING(user_id) + where u.redirecturl!=''; +alter table auth_user_md5 drop column redirecturl; -- 2.1.4