passage à un modèle unifié pour la création de page, sans bug d'auth.
authorx2000habouzit <x2000habouzit>
Thu, 19 Feb 2004 13:22:04 +0000 (13:22 +0000)
committerx2000habouzit <x2000habouzit>
Thu, 19 Feb 2004 13:22:04 +0000 (13:22 +0000)
new_popup_page n'a plus vraiment raison d'être (à part pour x.php, on traitera son cas plus tard...)
remplacée par new_nonhtml_page pour les pages type rss.php et cie.

j'ai aussi modifié la conf apache, plus besoin de hack pour faire marcher le site !

htdocs/mescontacts_ldif.php
htdocs/rss.php
htdocs/vcard.php
include/auto.prepend.inc.php
include/nonhtml.inc.php [deleted file]
include/xorg.common.inc.php
include/xorg.page.inc.php
include/xorg.session.inc.php
templates/rss.tpl

index f7e2ee0..91d4763 100644 (file)
@@ -1,5 +1,6 @@
 <?php
-require("nonhtml.inc.php");
+require("auto.prepend.inc.php");
+new_nonhtml_page('mescontacts_ldif.tpl', AUTH_COOKIE);
 
 function ensure_adr(&$table) {
     $trim = Array();
@@ -61,5 +62,5 @@ header("Pragma: ");
 header("Cache-Control: ");
 header("Content-type: text/x-ldif\n");
 
-$page->display('mescontacts_ldif.tpl');
+$page->display();
 ?>
index 101707a..5ecded1 100644 (file)
@@ -1,5 +1,6 @@
 <?php
-require("nonhtml.inc.php");
+require("auto.prepend.inc.php");
+new_nonhtml_page('rss.tpl', AUTH_PUBLIC);
 
 $requete="SELECT e.id,e.titre,e.texte FROM evenements AS e WHERE FIND_IN_SET(flags, 'valide') AND peremption >= NOW()";
 
@@ -9,8 +10,8 @@ if (isset($_REQUEST["promo"])) {
 }
 
 $requete.=" ORDER BY (e.promo_min != 0 AND e.promo_max != 0) DESC,  e.peremption";
-mysql_assign($page,$requete,'rss');
+$page->mysql_assign($requete,'rss');
 
 header("Content-Type: text/xml");
-$page->display('rss.tpl');
+$page->display();
 ?> 
index a5920fa..0058873 100644 (file)
@@ -1,5 +1,6 @@
 <?php
-require("nonhtml.inc.php");
+require("auto.prepend.inc.php");
+new_nonhtml_page('vcard.tpl', AUTH_COOKIE);
 
 function quoted_printable_encode($input, $line_max = 76) {
     $hex = array('0','1','2','3','4','5','6','7','8','9','A','B','C','D','E','F');
@@ -105,5 +106,5 @@ header("Cache-Control: ");
 header("Content-type: text/x-vcard\n");
 header("Content-Transfer-Encoding: Quoted-Printable\n");
 
-$page->display('vcard.tpl');
+$page->display();
 ?>
index 2a0cab5..17599bc 100644 (file)
@@ -1,6 +1,5 @@
 <?php
 require("config.xorg.inc.php") ;
-ini_set('include_path', ".:..:{$globals->root}/include/:{$globals->root}/configs/:$globals->libroot") ;
 setlocale(LC_TIME, "fr_FR");
 require("xorg.common.inc.php");
 
@@ -30,8 +29,8 @@ function new_skinned_page($tpl_name, $min_auth, $popup=false, $tpl_head="") {
     _new_page(SKINNED, $tpl_name, $tpl_head, $min_auth, $popup);
 }
 
-function new_popup_page($tpl_name, $min_auth, $popup=false, $tpl_head="") {
-    _new_page(SKINNED, $tpl_name, $tpl_head, $min_auth, $popup);
+function new_nonhtml_page($tpl_name, $min_auth) {
+    _new_page(NO_SKIN, $tpl_name, "", $min_auth, false);
 }
 
 function new_admin_page($tpl_name, $popup=false, $tpl_head="") {
diff --git a/include/nonhtml.inc.php b/include/nonhtml.inc.php
deleted file mode 100644 (file)
index ef8410c..0000000
+++ /dev/null
@@ -1,33 +0,0 @@
-<?php
-ini_set('include_path', ".:..:/home/x2000habouzit/dev/public/include:/home/x2000habouzit/dev/diogenes/lib/:/home/x2000habouzit/dev/smarty/");
-require("xorg.common.inc.php");
-require("Smarty.class.php");
-
-
-function mysql_assign(&$page,$sql_query,$var_name,$var_nb_name='') {
-    $sql = mysql_query($sql_query);
-    if(mysql_errno())
-        return(mysql_error($sql));
-
-    $array = Array();
-    while($array[] = mysql_fetch_assoc($sql));
-    array_pop($array);
-    mysql_free_result($sql);
-
-    $page->assign_by_ref($var_name,$array);
-    if(!empty($var_nb_name))
-        $page->assign($var_nb_name, count($array));
-    return 0;
-}
-
-$page = new Smarty();
-
-$page->template_dir = $globals->spoolroot . "/templates/";
-$page->compile_dir  = $globals->spoolroot . "/templates_c/";
-$page->plugins_dir[]= $globals->spoolroot . "/plugins/";
-$page->cache_dir    = $globals->spoolroot . "/cache/";
-    
-$page->config_overwrite=false;
-$page->compile_check=true;
-$page->caching=false;
-?>
index 2adc3cf..01a32aa 100644 (file)
@@ -10,11 +10,10 @@ define("PERMS_ADMIN", "admin");
 
 define('SKIN_COMPATIBLE','default.tpl');
 define('SKIN_COMPATIBLE_ID',1);
-define('SKIN_POPUP_COMPATIBLE','default.popup.tpl');
 define('SKIN_STOCHASKIN_ID','254');
 
 define('SKINNED', 0);
-define('POPUP', 1);
+define('NO_SKIN', 1);
 
 // import class definitions
 require("diogenes.database.inc.php");
index c1d4744..b661aae 100644 (file)
@@ -37,10 +37,10 @@ class XorgPage extends DiogenesCorePage {
     $this->cache_dir    = $globals->spoolroot."/cache/";
 
     $this->config_overwrite=false;
-    $this->compile_check=true;
-    $this->caching=true;
+    $this->compile_check = isset($site_dev);
+    $this->caching = ($type == SKINNED);
 
-    $this->_page_type = SKINNED;
+    $this->_page_type = $type;
     $this->_tpl = $tpl;
 
     $this->DiogenesCorePage();
@@ -66,8 +66,8 @@ class XorgPage extends DiogenesCorePage {
       $id = $this->make_id($append_to_id);
       if($site_dev) {
           $this->assign('validate', urlencode($baseurl.'/valid.html'));
-          if($this->_page_type == POPUP)
-              $result = $this->fetch('skin/'.$_SESSION['skin_popup'], $id);
+          if($this->_page_type == NO_SKIN)
+              $result = $this->fetch($this->_tpl, $id);
           else
               $result = $this->fetch('skin/'.$_SESSION['skin'], $id);
           $fd = fopen($this->cache_dir."valid.html","w");
@@ -75,8 +75,8 @@ class XorgPage extends DiogenesCorePage {
           fclose($fd);
           echo $result;
       } else {
-          if($this->_page_type == POPUP)
-              parent::display('skin/'.$_SESSION['skin_popup'], $id);
+          if($this->_page_type == NO_SKIN)
+              parent::display($this->_tpl, $id);
           else
               parent::display('skin/'.$_SESSION['skin'], $id);
       }
@@ -85,14 +85,14 @@ class XorgPage extends DiogenesCorePage {
 
   function xorg_is_cached($append_to_id="") {
       $id = $this->make_id($append_to_id);
-      if($this->_page_type == POPUP)
-          return parent::is_cached('skin/'.$_SESSION['skin_popup'], $id);
+      if($this->_page_type == NO_SKIN)
+          return parent::is_cached($this->_tpl, $id);
       else
           return parent::is_cached('skin/'.$_SESSION['skin'], $id);
   }
 
   function make_id($append_to_id="") {
-      $ret = $this->_tpl;
+      $ret = ($this->_page_type == NO_SKIN ? "noskin|" : "") . $this->_tpl;
       if($append_to_id)
           $ret.="|$append_to_id";
 
index 72fbf05..0126f66 100644 (file)
@@ -215,20 +215,19 @@ function start_connexion ($username, $uid, $identified) {
 
 function set_skin() {
   if(logged()) {
-    $result = mysql_query("SELECT skin,skin_tpl,skin_popup
+    $result = mysql_query("SELECT skin,skin_tpl
                            FROM auth_user_md5 AS a INNER JOIN skins AS s
                            ON a.skin=s.id WHERE user_id='{$_SESSION['uid']}' AND skin_tpl != ''");
-    if(list($_SESSION['skin_id'], $_SESSION['skin'], $_SESSION['skin_popup']) = mysql_fetch_row($result)) {
+    if(list($_SESSION['skin_id'], $_SESSION['skin']) = mysql_fetch_row($result)) {
       if ($_SESSION['skin_id'] == SKIN_STOCHASKIN_ID) {
-          $res = mysql_query("SELECT id,skin,skin_popup FROM skins
+          $res = mysql_query("SELECT id,skin FROM skins
                               WHERE !FIND_IN_SET('cachee',type) order by rand() limit 1");
-          list($_SESSION['skin_id'], $_SESSION['skin'], $_SESSION['skin_popup']) = mysql_fetch_row($res);
+          list($_SESSION['skin_id'], $_SESSION['skin']) = mysql_fetch_row($res);
           mysql_free_result($res);
       }
     } else {
       $_SESSION['skin'] = SKIN_COMPATIBLE;
       $_SESSION['skin_id'] = SKIN_COMPATIBLE_ID;
-      $_SESSION['skin_popup'] = SKIN_POPUP_COMPATIBLE;
     }
     mysql_free_result($result);
   }
@@ -238,7 +237,6 @@ function set_skin() {
   {
     $_SESSION['skin'] = SKIN_COMPATIBLE;
     $_SESSION['skin_id'] = SKIN_COMPATIBLE_ID;
-    $_SESSION['skin_popup'] = SKIN_POPUP_COMPATIBLE;
   }
 }
 
index a1afeec..a6e0578 100644 (file)
@@ -1,4 +1,4 @@
-{* $Id: rss.tpl,v 1.1 2004-02-04 19:47:47 x2000habouzit Exp $ *}
+{* $Id: rss.tpl,v 1.2 2004-02-19 13:22:05 x2000habouzit Exp $ *}
 <?xml version="1.0" encoding="ISO-8859-1"?>
 
 <!DOCTYPE rss PUBLIC "-//Netscape Communications//DTD RSS 0.91//EN"
@@ -14,7 +14,7 @@
 
 {foreach item=line from=$rss}
 <item>
-<title>{$line.titre|strip_tags}</title>
+<title>{$line.titre|strip_tags|escape:"html"}</title>
 <link>http://{$smarty.server.SERVER_NAME}/login.php#newsid{$line.id}</link>
 </item>
 {/foreach}