par hika - 2005-02-06 17:12:52
crée le 2005-02-06 17:12:52

wakka.class.php


<?php
/*
 *  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 Library 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.
 */
 
/* 
 * Version 0.5
 * Using custom _htmlspecialchars() instead of htmlspecialchars()
 * (From PHP >=5.4
 *
 * Version 0.4
 * WAKKA_IMAGE_PROTECT; // default not defined
 * If this variable is true, the displayimg() method
 * only shows the real if the http referer is on the same realm
 * otherwise, it shows an empty image or a replaced image with
 * WAKKA_URL_IMAGE_DEFAULT as the URL // default not defined
 *
 * Version 0.3
 * - Wakka is now implemented as an object
 * - Upload image form is not always printed
 * - Add a preview and reedit button
 * - Add a cancel button
 * - Can manage external users
 *   You must provide either a function that returns a userid
 *   or a function that returns a username
 *
 * Version 0.2
 * - Add a new revision table to have a modification history
 * - Here are the variables that can affect this script :
 *   $force_getvar = true;  // défaut unset => true
 *     This variable force the use of $wakka_page
 *     instead of $_GET[WAKKA_PAGE_NAME] to select the wakka page
 *     (cf WAKKA_PAGE_NAME in wakka.inc.php)
 *   $force_postvar = true;  // défaut unset => true
 *     This variable force the use of $wakka_page
 *     instead of $_POST[WAKKA_PAGE_NAME] to select the wakka page
 *   In *ALL* case, the $_POST has the priority   
 *
 *   $wakka_page = NULL; // default NULL
 *   $wakka_nl2br = true;
 *   $wakka_can_do_revision = false
 *   $wakka_can_edit = false
 *   $only_upload_form = false
 *   $show_header = false
 *   $show_footer = false
 */

define("REGEXP_WAKKA_PAGE", "[a-zA-Z0-9\-_]+");
define("REGEXP_WAKKA_IMG", "[a-zA-Z0-9\-_]+");
// This is a more restrictive URL regexp that only match http links
define("REGEXP_WAKKA_URL", "https{0,1}://[a-zA-Z0-9/\-\.\~\&\;\?:_\=]+");
define("REGEXP_WAKKA_INTERNAL_URL", "[a-zA-Z0-9/\-\.\~\&\;\?:_\=]+");
define("REGEXP_WAKKA_EMAIL", "[a-zA-Z0-9/\-\._\@]+");
define("REGEXP_WAKKA_CHAR", "[a-zA-Z0-9\ 'éèê@\-\._]");

Class Wakka {
  
  private $wakka_gvars; /* Must be an array */
  private $Conn_wakka;  /* Must be a Connect object */
  private $rewrite_rules;
  private $rewrite_rule_enable;
  
  public $wakka_page;
  public $nl2br;
  public $can_do_revision;
  public $can_edit;
  public $can_upload_img;
  public $only_upload_form;
  public $show_header;
  public $show_footer;

  function __construct() {
    $this->Wakka();
  }

  function Wakka() {
    $this->wakka_gvars = array();
    $this->wakka_page = NULL;
    $this->nl2br = true;
    $this->can_do_revision = false;
    $this->can_edit = false;
    $this->can_upload_img = false;
    $this->only_upload_form = false;
    $this->show_header = false;
    $this->show_footer = false;
    
    $this->force_getvar = true;
    $this->force_postvar = true;
    
    $this->rewrite_rule_enable = false;
  }

  function setConnect(&$Conn) {
    if ((is_object($Conn))
    && (get_class($Conn) == "Connect")) {
      $this->Conn_wakka = $Conn;
      return true;
    }
    return false;
  }
  
  function isConnected() {
    return (is_object($this->Conn_wakka))
        && (get_class($this->Conn_wakka) == "Connect");
  }
  
  function addRewriteRule($regexp, $rewrite) {
    if (!is_array($this->rewrite_rules))
      $this->rewrite_rules = array(array($regexp, $rewrite));
    else
      array_push($this->rewrite_rules, array($regexp, $rewrite));
  }
  
  function escape_string($valeur) {
    $new_val = str_replace("/", "/", $valeur);
    $new_val = str_replace("*", "*", $new_val);
    $new_val = str_replace("&", "\&", $new_val);
    $new_val = str_replace("[", "[", $new_val);
    $new_val = str_replace("]", "]", $new_val);
    $new_val = str_replace("(", "\(", $new_val);
    $new_val = str_replace(")", "\)", $new_val);
    return str_replace("/", "/", $valeur);
  }

/* -----------------------------------------------------------------------------
 * Callback functions for preg_replace_callback
 */ 
  function getservervars(&$tags, &$values) {
    if (isset($_SERVER)) {
      $tags = array();
      $values = array();
      foreach ($_SERVER as $name => $value) {
        array_push($tags, "/\\${".$name."}/");
        array_push($values, $value);
      }
      reset($_SERVER);
      return true;
    }
    return false;
  }

  function include_php_source($matches) {
    if (file_exists($matches[1])) {
      Include($matches[1]);
    }
  }

  function show_php_source($matches) {
    if (substr($matches[1], 0, 7) == "http://") {
      $source = highlight_file($matches[1], true);
    }
    else if (file_exists($matches[1])) {
      $source = highlight_file($matches[1], true);
    }
    if (isset($source)) {
      return "<div class=\"".WAKKA_DIV_PHPSOURCE_CSS_CLASS."\">".$source."</div>";
    }
  }

  function show_php_source_string($matches) {
    $source = html_entity_decode($matches[1]);
    $source = str_replace("<br />", "", $source);
    $source = highlight_string($source, true);
    return "<div class=\"".WAKKA_DIV_PHPSOURCE_CSS_CLASS."\">".$source."</div>";
  }

  function mailto_email_protect($matches) {
    switch (count($matches)) {
    case 2:
      $new_val = str_replace("@", " AT ", $matches[1]);
      $new_val = str_replace(".", " DOT ", $new_val);
      return "<a href=\"mailto:".$new_val."\">".$new_val."</a>";
      break;
    case 3:
      $new_val = str_replace("@", " AT ", $matches[1]);
      $new_val = str_replace(".", " DOT ", $new_val);
      return "<a href=\"mailto:".$new_val."\">".$matches[2]."</a>";    
      break;
    }
  }

  function tag_h_replace($matches) {
    if (count($matches) == 4) {
      $len1 = strlen($matches[1]);
      $len2 = strlen($matches[3]);
      
      if ($len1 == $len2 ) {
        return "<h".$len1.">".$matches[2]."</h".$len1.">";
      }
    }
  }

  function tag_ul_li_replace($matches) {
    $li = "";
    $elements = explode("\n", $matches[0]);
    for ($i = 0; $i < count($elements); $i++) {
      $line = str_replace("<br />", "", $elements[$i]);
      $line = str_replace("* ", "", $line);
      $line = trim($line);
      if ($line != "")
        $li .= "<li>".$line."</li>\n";
    }
    return "<ul>".$li."</ul>";
  }
  
  function process_internal_url($matches) {
    switch(count($matches)) {
    case 2:
      return "<a href=\"".$this->rewrite_url($matches[1])."\">".
             $matches[1]."</a>";
      break;
    case 3:
      return "<a href=\"".$this->rewrite_url($matches[1])."\">".
             $matches[2]."</a>";
      break;
    }
  }
  
  function process_external_url($matches) {
    switch(count($matches)) {
    case 2:
      return "<a target=\"_blank\" href=\"".$matches[1]."\">".
             $matches[1]."</a>";
      break;
    case 3:
      return "<a target=\"_blank\" href=\"".$matches[1]."\">".
             $matches[2]."</a>";
      break;
    }
  }
  
  function process_wakka_url($matches) {
    switch(count($matches)) {
    case 2:
      return "<a href=\"".$this->rewrite_url($_SERVER["SCRIPT_NAME"]."?".WAKKA_PAGE_NAME."=".$matches[1])."\">".
             $matches[1]."</a>";
      break;
    case 3:
      return "<a href=\"".$this->rewrite_url($_SERVER["SCRIPT_NAME"]."?".WAKKA_PAGE_NAME."=".$matches[1])."\">".
             $matches[2]."</a>";
      break;
    }
  }
  
  function process_wakka_url_img($matches) {
    $wakka_img_path = $this->getwakkaimgpath();
    switch(count($matches)) {
    case 2:
      return "<img src=\"".$this->rewrite_url($wakka_img_path."?".WAKKA_IMG_NAME."=".$matches[1])."\" ".
        "border=\"0\" alt=\"".$matches[1]."\" title=\"".$matches[1]."\" />";
      break;
    }
  }
  
  function process_wakka_url_img_href($matches) {
    $wakka_img_path = $this->getwakkaimgpath();
    switch(count($matches)) {
    case 3:
      return "<a target=\"_blank\" href=\"".$matches[2]."\">".
        "<img src=\"".$this->rewrite_url($wakka_img_path."?".WAKKA_IMG_NAME."=".$matches[1])."\" ".
        "border=\"0\" alt=\"".$matches[1]."\" title=\"".$matches[1]."\" /></a>";
      break;
    }
  }
/* -------------------------------------------------------------------------- */
  
/* -----------------------------------------------------------------------------
 * Functions that must be private
 */
  function getauthorname($wakka_page, $wakka_revision = NULL) {
  /* ---------------------------------------------------------------------------
   * Get the wakka page 's author name
   *
   * @param  string wakka page name
   * @param  int   (optional) wakka revision number
   * @return string author name or NULL
   * ------------------------------------------------------------------------ */
    if (!$this->isConnected())
      return NULL;
    
    if (!is_null($wakka_revision)) {
      $SQL = "SELECT wakka_author_id, wakka_author_name 
              FROM ".WAKKA_TXT_REVISION_TABLE."
              WHERE wakka_key = ".STRING_SQL($wakka_page)."
              AND wakka_revision = ".NUM_SQL($wakka_revision);
    }
    else {
      $SQL = "SELECT wakka_author_id, wakka_author_name 
              FROM ".WAKKA_TXT_TABLE."
              WHERE wakka_key = ".STRING_SQL($wakka_page);
    }
    $result = $this->Conn_wakka->QueryDB($SQL);
    if ($cur = $this->Conn_wakka->CursorDB($result)) {
      $this->Conn_wakka->FreeDB($result);
      
      $username = $this->getauthorname_byid($cur["wakka_author_id"]);
      if (!is_null($username))
        return $username;
      if (!is_null($cur["wakka_author_name"]))    
        return $cur["wakka_author_name"];
    }
    else
      $this->Conn_wakka->FreeDB($result);
    return WAKKA_DEFAULT_UNKNOWN_USER;
  }
  
  function getauthorname_byid($id) {
  /* ---------------------------------------------------------------------------
   * Get the wakka page 's author name by author_id
   *
   * @param  int   wakka_author_id
   * @return string author name or NULL
   * ------------------------------------------------------------------------ */
    if ((defined("WAKKA_FUNCTION_GETUSERNAMEBYID"))
    && (!is_null(WAKKA_FUNCTION_GETUSERNAMEBYID))
    && (is_string(WAKKA_FUNCTION_GETUSERNAMEBYID))
    && (WAKKA_FUNCTION_GETUSERNAMEBYID != "")
    && (function_exists(WAKKA_FUNCTION_GETUSERNAMEBYID))
    && (is_numeric($id))) {
      return call_user_func(WAKKA_FUNCTION_GETUSERNAMEBYID, $id);
    }
    return NULL;
  }
  
  function getinfowakka($wakka_page, $wakka_revision = NULL) {
  /* ---------------------------------------------------------------------------
   * Get the wakka page 's raw information
   *
   * @param  string wakka page name
   * @param  int   (optional) wakka revision number
   * @return array or NULL
   * ------------------------------------------------------------------------ */
    if (!$this->isConnected())
      return NULL;
    if (!is_null($wakka_revision)) {
      $SQL = "SELECT *
              FROM ".WAKKA_TXT_REVISION_TABLE."
              WHERE wakka_key = ".STRING_SQL($wakka_page)."
              AND wakka_revision = ".NUM_SQL($wakka_revision);
    }
    else {
      $SQL = "SELECT *
              FROM ".WAKKA_TXT_TABLE."
              WHERE wakka_key = ".STRING_SQL($wakka_page);
    }
    $result = $this->Conn_wakka->QueryDB($SQL);
    if ($cur = $this->Conn_wakka->CursorDB($result)) {
      $this->Conn_wakka->FreeDB($result);
      return $cur;
    }
    else
      $this->Conn_wakka->FreeDB($result);
    return NULL;
  }
  
  function getwakkaimgpath() {
    // We get the URL wakka_img_path
    $dirname = dirname($_SERVER["SCRIPT_NAME"]);
    $included_files = get_included_files();
    foreach ($included_files as $included_file) {
      $p = str_replace($_SERVER["DOCUMENT_ROOT"], "", $included_file);
      $p = str_replace($dirname."/", "", $p);  
      if (basename($p) == "wakka.class.php") {
        return str_replace("wakka.class.php", "wakka_img.php", $p);
        break;
      }
    }
  }
  
  function rewrite_url($url) {
    if (!$this->rewrite_rule_enable)
      return $url;
    
    if (is_array($this->rewrite_rules)) {
      foreach ($this->rewrite_rules as $rewrite_rule) {
        //echo $rewrite_rule[0].' to '.$rewrite_rule[1].'<br />';
        $url_rewrite = preg_replace('/'.$rewrite_rule[0].'/', $rewrite_rule[1], $url);
        //echo $url.' => '.$url_rewrite.'<br />';
        if ($url != $url_rewrite) {
          if ($url_rewrite[0] != '/')
            return '/'.$url_rewrite;
          return $url_rewrite;
        }
      }
    }
    return $url; 
  }
  
  function resize_image($file_src, &$bin_dst, &$size, $width = NULL, $height = NULL) {
  /* ---------------------------------------------------------------------------
   * Resize an image, by width, by height or both
   * and get the binary result
   *
   * @param  string
   * @param  ref       the binary result
   * @param  ref       the size of the binary result
   * @param  int (optional)
   * @param  int (optional)
   * @return boolean
   * ------------------------------------------------------------------------ */
    if (!file_exists($file_src))
      return false;
          
    if ($info = getimagesize($file_src)) {
      switch($info[2]) {
      case 1: // GIF
        if ((is_numeric($width)) || (is_numeric($height)))
          $img_src = imagecreatefromgif($file_src);
        break;
      case 2: // JPEG
        if ((is_numeric($width)) || (is_numeric($height)))
          $img_src = imagecreatefromjpeg($file_src);
        break;
      case 3: // PNG
        if ((is_numeric($width)) || (is_numeric($height)))
          $img_src = imagecreatefrompng($file_src);
        break;
      default:
        return false;
      }
      
      if ((!is_numeric($width)) && (!is_numeric($height))) {
      // Read the original file 
        $fd = fopen($file_src, "rb");
        $size = filesize($file_src);
        $bin_dst = fread($fd, $size);      
        fclose($fd);
        return true;
      }
      else if (isset($img_src)) {
        if ((is_numeric($width))
        && (!is_numeric($height))
        && ($info[0] > $width)) {
        // Resize by width only        
          $new_width = $width;
          $new_height = (int)($info[1] * $width / $info[0]);
        }
        else if ((!is_numeric($width))
        && (is_numeric($height))
        && ($info[1] > $height)) {
        // Resize by height only
          $new_width = (int)($info[0] * $height / $info[1]);
          $new_height = $height;
        }
        else if ((is_numeric($width))
        && (is_numeric($height))
        && ($info[0] > $width)
        && ($info[1] > $height)) {
        // Resize by width and height
          $new_width = $width;
          $new_height = $height;
        }
        
        if ((isset($new_height)) && (isset($new_width))) {
          $img_dst = imagecreatetruecolor($new_width, $new_height);
          if (imagecopyresampled($img_dst, $img_src, 0, 0, 0, 0, 
                                 $new_width, $new_height, $info[0], $info[1])) {
            imagedestroy($img_src);                                   
            ob_start();
            switch($info[2]) {
            case 1: // GIF
              imagegif($img_dst);
              break;
            case 2: // JPEG
              imagejpeg($img_dst);
              break;
            case 3: // PNG
              imagepng($img_dst);
              break;
            }
            $bin_dst = ob_get_contents();
            $size = ob_get_length();
            ob_end_clean();
            
            imagedestroy($img_dst);
            
            return true;
          }
          else
            imagedestroy($img_src);  
        }
        else
          imagedestroy($img_src);  
      }
    }
    
    return false;
  }
  
/* -------------------------------------------------------------------------- */

  function parse_rewritefile($rewrite_file) {
  /* ---------------------------------------------------------------------------
   * parse file that contains rewrite rules
   * !! URL rewrite variable must be on the same order than expression in brackets !!
   * For example : we must have something like :
   * /index.php?rub=$1&year=$2&month=$3&day=$4
   * and not
   * /index.php?rub=$4&year=$1&month=$2&day=$3
   *
   * @param  string  file path
   * @return boolean
   * ------------------------------------------------------------------------ */
    if (file_exists($rewrite_file)) {
      $fd = fopen($rewrite_file, "r");
      $content = fread($fd, filesize($rewrite_file));
      fclose($fd);
      $lines = explode("\n", $content);
      unset($content);
      foreach ($lines as $line) {
        if (($line != "")
        && ($line[0] != '#')) {
          $words = split("(\t|\ )+", $line);
          if ((count($words) >= 3)
          && ($words[0] == "RewriteRule")) {
          /* Rewrite pattern replacement */
            //echo $words[1]." <-> ".$words[2]."<br />";
          
            /* Parse URL to rewrite  */
            $url_from = $words[2];
            $url_from = str_replace('?', '\?', $url_from);
            $url_from = str_replace('/', '/', $url_from);
            $url_from = str_replace('&', '&amp;', $url_from);
            $tmp_url_from = "";
            $array_n = array();
            while(preg_match('/\$[1-9]/U', $url_from, $array)) {
              array_push($array_n, $array[0]);
              $url_from = preg_replace('/\$[1-9]/U', '(.+)', $url_from, 1);
            }
            
            /* Parse URL rewrited  */
            $url_to = $words[1];
            $url_to = str_replace('\', '', $url_to);
            $url_to = str_replace('^', '', $url_to);
            $url_to = str_replace('$', '', $url_to);
            $n = 1;
            while(preg_match('/\(.+\)/U', $url_to)) {
              $i = array_search('$'.$n, $array_n);
              $url_to = preg_replace('/\(.+\)/U', '\$'.($i+1), $url_to, 1);
              $n++;
            }
            
            //echo "result : ".$url_from." => ".$url_to."<br />";
            $this->addRewriteRule($url_from, $url_to);
          }
          else if ((count($words) == 2)
          && ($words[0] == "RewriteEngine")) {
            if (strtolower($words[1]) == "on") {
              $this->rewrite_rule_enable = true;  
            }
          }
        }
      }
      return true;
    }
    return false;
  }

  function diff($str_from, $str_to) {
  /* ---------------------------------------------------------------------------
   * diff between 2 strings
   *
   * @param  string
   * @param  string
   * @return string result after procession
   * ------------------------------------------------------------------------ */
   
    $array_from = explode("\n", $str_from);
    $array_to = explode("\n", $str_to);
    
    $count_from = count($array_from);
    $count_to = count($array_to);
    
    for($i = 0; $i < $count_from; $i++) {
      $array_from[$i] = preg_replace('/<br />$/', '', str_replace("\r", "", $array_from[$i]));
    }
    for($i = 0; $i < $count_to; $i++) {
      $array_to[$i] = preg_replace('/<br />$/', '', str_replace("\r", "", $array_to[$i]));
    }
    
    $i = 0;
    $j = 0;
    $k = 0;
    
    
    $nl = "<br />\n";
    
    $result = "";
    while (($i < $count_from)
    && ($j < $count_to)) {
      /* Line are equals */
            
      if ($array_from[$i] == $array_to[$j]) {
        $result .= $array_from[$i].$nl;
        $i++;
        $j++;
      }
      else {
      /* Line are different */
        if ($count_to - $j == $count_from - $i) {
          $result .= "<span class=\"".WAKKA_TEXT_ADD_CLASS."\">".$array_to[$j]."</span>".$nl;
          $result .= "<span class=\"".WAKKA_TEXT_DEL_CLASS."\">".$array_from[$i]."</span>".$nl;
          $j++;
          $i++;
        }
        else if ($count_to - $j > $count_from - $i) {
          $result .= "<span class=\"".WAKKA_TEXT_ADD_CLASS."\">".$array_to[$j]."</span>".$nl;
          $j++;
        }
        else {
          $result .= "<span class=\"".WAKKA_TEXT_DEL_CLASS."\">".$array_from[$i]."</span>".$nl;
          $i++;
        }
      }
      
      $k++;
    }
    
    while($i < $count_from) {
      $result .= "<span class=\"".WAKKA_TEXT_DEL_CLASS."\">".
                $array_from[$i]."</span>".$nl;
      $i++;
    }
    while($j < $count_to) {
      $result .= "<span class=\"".WAKKA_TEXT_ADD_CLASS."\">".
                $array_to[$j]."</span>".$nl;
      $j++;
    }
    
    return $result;
  }

  function getallwakka() {
  /* ---------------------------------------------------------------------------
   * get all wakka page name
   *
   * @return array
   * ------------------------------------------------------------------------ */
    if (!$this->isConnected())
      return false;
    $SQL = "SELECT wakka_key FROM ".WAKKA_TXT_TABLE;
    $result = $this->Conn_wakka->QueryDB($SQL);
    
    $array_key = array();
    while ($cur = $this->Conn_wakka->CursorDB($result)) {
      array_push($array_keys, $cur[0]);
    }
    return $array_keys;
  }

  function safetxt($valeur) {
  /* ---------------------------------------------------------------------------
   * Evaluate content
   *
   * @param  string initial value
   * @return string result after processing
   * ------------------------------------------------------------------------ */
    $new_val = _htmlspecialchars($valeur);
    // Insure that content does not affect html code
    
    //$new_val = str_replace("&amp;", "&", $new_val);
    //$new_val = preg_replace("/&lt;a\ href=&quot;(.*)&quot;\ target=&quot;(.*)&quot;&gt;(.*)&lt;/a&gt;/", "<a href=\"\\1\" target=\"\\2\">\\3</a>", $new_val);
    //$new_val = preg_replace("/&lt;a\ href=&quot;(.*)&quot;&gt;(.*)&lt;/a&gt;/", "<a href=\"\\1\">\\2</a>", $new_val);  
    //$new_val = preg_replace("/&lt;span class=&quot;(.*)&quot;&gt;(.*)&lt;/span&gt;/sU", "<span class=\"\\1\">\\2</span>", $new_val);
    //$new_val = preg_replace("/&lt;h([1-4])&gt;(.*)&lt;/h([1-4])&gt;/sU", "<h\\1>\\2</h\\3>", $new_val);
    //$new_val = preg_replace("/&lt;u&gt;(.*)&lt;/u&gt;/", "<u>\\1</u>", $new_val);
    //$new_val = preg_replace("/&lt;li&gt;(.*)&lt;/li&gt;/", "<li>\\1</li>", $new_val);
    //$new_val = preg_replace("/&lt;u class=&quot;(.*)&quot;&gt;(.*)&lt;/u&gt;/", "<u class=\"\\1\">\\2</u>", $new_val);
    //$new_val = preg_replace("/&lt;li class=&quot;(.*)&quot;&gt;(.*)&lt;/li&gt;/", "<li class=\"\\1\">\\2</li>", $new_val);
    //$new_val = preg_replace("/&lt;p&gt;(.*)&lt;/p&gt;/", "<p>\\1</p>", $new_val);
    //$new_val = preg_replace("/&lt;i&gt;(.*)&lt;/i&gt;/", "<i>\\1</i>", $new_val);
    //$new_val = preg_replace("/&lt;b&gt;(.*)&lt;/b&gt;/", "<b>\\1</b>", $new_val);
    
    if ($this->nl2br)
      return nl2br($new_val);
    return $new_val;
  }

  function process($value, $wakka_page = "") {
  /* ---------------------------------------------------------------------------
   * Evaluate content
   *
   * @param  string initial value
   * @param  string wakka page
   * @return string result after processing
   * ------------------------------------------------------------------------ */
    if (!$this->isConnected())
      return $value;
    
    $wakka_echo = $value;
    
    /* We manage the server variables */
    if ($this->getservervars($server_vars_index, $server_vars_value)) {
      $wakka_echo = preg_replace($server_vars_index, $server_vars_value, $wakka_echo);
    }
        
    /* !! IMPORTANT !!
      The following replacements must be from the more restrictive expression to the less
     */
     
    /* We manage expression like 
     * Something
     * Something else
     
     to be replaced by 
     <ul>
     <li>Something</li>
     <li>Something else</li>
     </ul>
     */
    $wakka_echo = preg_replace_callback("/(\ {2,}* .+\n){2,}/", array("Wakka", "tag_ul_li_replace"), $wakka_echo);
                
    /* We manage php source eval */
    $wakka_echo = preg_replace_callback("/[[INCLUDE SRC=(".REGEXP_WAKKA_INTERNAL_URL.")]]/", array("Wakka", "include_php_source"), $wakka_echo);
    
    /* We manage php source show from file */
    $wakka_echo = preg_replace_callback("/[[CODE SRC=(".REGEXP_WAKKA_INTERNAL_URL.")]]/", array("Wakka", "show_php_source"), $wakka_echo);

    /* We manage php source show from string */
    $wakka_echo = preg_replace_callback("/[[CODE STRING=(.+)]]/sU", array("Wakka", "show_php_source_string"), $wakka_echo);

    /* We manage internal image URL links */
    $wakka_echo = preg_replace_callback("/[[IMG NAME=(".REGEXP_WAKKA_IMG.") URL=(".REGEXP_WAKKA_URL.")]]/", array("Wakka", "process_wakka_url_img_href"), $wakka_echo);
    
    /* We manage internal image without URLlinks  */
    $wakka_echo = preg_replace_callback("/[[IMG NAME=(".REGEXP_WAKKA_IMG.")]]/", array("Wakka", "process_wakka_url_img"), $wakka_echo);
    
    /* We manage external image URL links */
    $wakka_echo = preg_replace("/[[IMG SRC=(".REGEXP_WAKKA_URL.") URL=(".REGEXP_WAKKA_URL.")]]/", "<a target=\"_blank\" href=\"\\2\"><img src=\"\\1\" border=\"0\" alt=\"\\1\" title=\"\\1\" /></a>", $wakka_echo);
    
    /* We manage external image without URL links */
    $wakka_echo = preg_replace("/[[IMG SRC=(".REGEXP_WAKKA_URL.")]]/", "<img src=\"\\1\" border=\"0\" alt=\"\\1\" title=\"\\1\" />", $wakka_echo);
 
    /* We manage forced wakka links */
    $wakka_echo = preg_replace_callback("/[[(".REGEXP_WAKKA_PAGE.")]]/", array("Wakka", "process_wakka_url"), $wakka_echo);
    
    /* We manage forced wakka links with another label */
    $wakka_echo = preg_replace_callback("/[[(".REGEXP_WAKKA_PAGE.")\ LABEL=(".REGEXP_WAKKA_CHAR."+)]]/", array("Wakka", "process_wakka_url"), $wakka_echo);
    $wakka_echo = preg_replace_callback("/[[(".REGEXP_WAKKA_PAGE.")\ (.+)]]/", array("Wakka", "process_wakka_url"), $wakka_echo);
    
    /* We manage normal external links */
    $wakka_echo = preg_replace_callback("/[(".REGEXP_WAKKA_URL.")]/",  array("Wakka", "process_external_url"), $wakka_echo);
    
    /* We manage normal external links with another label */
    $wakka_echo = preg_replace_callback("/[(".REGEXP_WAKKA_URL.")\ (".REGEXP_WAKKA_CHAR."+)]/",  array("Wakka", "process_external_url"), $wakka_echo);
    
    /* We manage normal internal links */
    $wakka_echo = preg_replace_callback("/[[HREF=(".REGEXP_WAKKA_INTERNAL_URL.")]]/", array("Wakka", "process_internal_url"), $wakka_echo);
    
    /* We manage normal internal links with another label */
    $wakka_echo = preg_replace_callback("/[[HREF=(".REGEXP_WAKKA_INTERNAL_URL.")\ (".REGEXP_WAKKA_CHAR."+)]]/", array("Wakka", "process_internal_url"), $wakka_echo);
    
    /* We manage mailto */
    $wakka_echo = preg_replace_callback("/[[MAILTO=(".REGEXP_WAKKA_EMAIL.")]]/", array("Wakka", "mailto_email_protect"), $wakka_echo);
    
    /* We manage mailto with another label */
    $wakka_echo = preg_replace_callback("/[[MAILTO=(".REGEXP_WAKKA_EMAIL.")\ (".REGEXP_WAKKA_CHAR."+)]]/", array("Wakka", "mailto_email_protect"), $wakka_echo);
        
    /* We manage expression like "=== Something ===" to be replaced by <h3>Something</h3> */
    $wakka_echo = preg_replace_callback("/^(\=+)\ (.+)\ (\=+)/m", array("Wakka", "tag_h_replace"), $wakka_echo);
    
    /* We manage expression like "* Something *" to be replaced by <b>Something</b> */
    $wakka_echo = preg_replace("/**\ (.+)\ **/m", "<b>\\1</b>", $wakka_echo);
    
    /* We manage expression like "Something" to be replaced by <i>Something</i> */
    $wakka_echo = preg_replace("////\ (.+)\ ////m", "<i>\\1</i>", $wakka_echo);
    
    /* We manage expression like "Something" to be replaced by <i>Something</i> */
    $wakka_echo = preg_replace("/''\ (.+)\ ''/m", "<i>\\1</i>", $wakka_echo);
    
    /* We manage expression like "Something" to be replaced by <u>Something</u> */
    $wakka_echo = preg_replace("/_\ (.+)\ _/m", "<u>\\1</u>", $wakka_echo);
    
    /* We manage expression like "
Something
" to be replaced by <center>Something</center> */
$wakka_echo = preg_replace("/::\ (.+)\ ::/m", "<center>\\1</center>", $wakka_echo); /* At the end, escape characters will be printed normally */ /* escape char are * , _ , / , :, [ , ] */ $wakka_echo = preg_replace("/\\\(*|_|/|:|[|]|{|}|')/mU", "\\1", $wakka_echo); /* Links to other wakka page */ if ($wakka_page != "") { $SQL = "SELECT wakka_key FROM ".WAKKA_TXT_TABLE." WHERE wakka_key != '".addslashes($wakka_page)."' AND wakka_key != '' AND wakka_key IS NOT NULL"; } else { $SQL = "SELECT wakka_key FROM ".WAKKA_TXT_TABLE." WHERE wakka_key != '' AND wakka_key IS NOT NULL"; } $result_keys = $this->Conn_wakka->QueryDB($SQL); /* We manage the other wakka page links */ while($cur_keys = $this->Conn_wakka->CursorDB($result_keys)) { $wakka_echo = preg_replace("/ ".$this->escape_string($cur_keys[0])."(,|.|\ )/", " <a href=\"".$this->rewrite_url($_SERVER["SCRIPT_NAME"]."?".WAKKA_PAGE_NAME."=".urlencode($cur_keys[0]))."\">".$cur_keys[0]."</a>\\1", $wakka_echo); } $this->Conn_wakka->FreeDB($result_keys); return $wakka_echo; } function processall($valeur, $wakka_page = "") { /* --------------------------------------------------------------------------- * Evaluate content * * @param string initial value * @param string wakka page * @return string result after processing * ------------------------------------------------------------------------ */ $new_val = $valeur; $new_val = $this->safetxt($new_val); $new_val = $this->process($new_val, $wakka_page); return $new_val; } /* ----------------------------------------------------------------------------- * This is for template use */ function assign($varname, $value) { /* --------------------------------------------------------------------------- * Assign new variable * * @param string name * @param mixed value * ------------------------------------------------------------------------ */ $this->wakka_gvars[$varname] = $value; } function getvars(&$tags, &$values) { /* --------------------------------------------------------------------------- * This is the main engine for Wakka * * Normal variables have format : {$varname} * Special variables have format : * {$wakka.server.NAME} for $_SERVER * {$wakka.post.NAME} for $_POST * {$wakka.get.NAME} for $_GET * {$wakka.session.NAME} for $_SESSION * {$wakka.page.NAME} for predefined variables * @param array reference * @param array reference * @return boolean * ------------------------------------------------------------------------ */ if (is_array($this->wakka_gvars)) { $tags = array(); $values = array(); foreach ($this->wakka_gvars as $name => $value) { array_push($tags, "/{\\$".$name."}/"); array_push($values, $value); } /* We get $_SERVER variables */ if (isset($_SERVER)) { foreach ($_SERVER as $name => $value) { array_push($tags, "/{\\\$wakka\.server\.".$name."}/"); array_push($values, $value); } reset($_SERVER); } /* We get $_GET variables */ if (isset($_GET)) { foreach ($_GET as $name => $value) { array_push($tags, "/{\\\$wakka\.get\.".$name."}/"); array_push($values, $value); } reset($_GET); } /* We get $_POST variables */ if (isset($_POST)) { foreach ($_POST as $name => $value) { array_push($tags, "/{\\\$wakka\.post\.".$name."}/"); array_push($values, $value); } reset($_POST); } /* We get $_SESSION variables */ if (isset($_SESSION)) { foreach ($_SESSION as $name => $value) { array_push($tags, "/{\\\$wakka\.session\.".$name."}/"); array_push($values, $value); } reset($_SESSION); } /* We get special variables */ if ($this->isConnected()) { $wakka_page = $this->getwakkapage(); if (!is_null($wakka_page)) { /* If we are on a page * get the infos */ $cur = $this->getinfowakka($wakka_page); if (!is_null($cur)) { array_push($tags, "/{\\\$wakka\.page\.key}/"); array_push($values, $cur["wakka_key"]); array_push($tags, "/{\\\$wakka\.page\.date_creat}/"); array_push($values, strdatetime($cur["wakka_date_creat"])); array_push($tags, "/{\\\$wakka\.page\.date_modif}/"); array_push($values, strdatetime($cur["wakka_date_modif"])); array_push($tags, "/{\\\$wakka\.page\.text}/"); array_push($values, $cur["wakka_txt"]); array_push($tags, "/{\\\$wakka\.page\.author_id}/"); array_push($values, $cur["wakka_author_id"]); array_push($tags, "/{\\\$wakka\.page\.author_name}/"); array_push($values, $cur["wakka_author_name"]); $username = $this->getauthorname_byid($cur["wakka_author_id"]); if (!is_null($username)) { array_push($tags, "/{\\\$wakka\.page\.author_name_by_id}/"); array_push($values, $username); } else { array_push($tags, "/{\\\$wakka\.page\.author_name_by_id}/"); array_push($values, WAKKA_DEFAULT_UNKNOWN_USER); } } $wakka_tag = $this->getwakkatag(); if (!is_null($wakka_tag)) { /* If we are on a tagged page * get the infos */ $SQL = "SELECT * FROM ".WAKKA_TXT_REVISION_TABLE." WHERE wakka_key = ".STRING_SQL($wakka_page)." AND wakka_tag = ".STRING_SQL($wakka_tag); $result = $this->Conn_wakka->QueryDB($SQL); if (($result) && ($cur = $this->Conn_wakka->CursorDB($result))) { array_push($tags, "/{\\\$wakka\.tag\.tag}/"); array_push($values, $wakka_tag); array_push($tags, "/{\\\$wakka\.tag\.author_id}/"); array_push($values, $cur["wakka_author_id"]); array_push($tags, "/{\\\$wakka\.tag\.author_name}/"); array_push($values, $cur["wakka_author_name"]); array_push($tags, "/{\\\$wakka\.tag\.date_revision}/"); array_push($values, strdatetime($cur["wakka_date_revision"])); $username = $this->getauthorname_byid($cur["wakka_author_id"]); if (!is_null($username)) { array_push($tags, "/{\\\$wakka\.tag\.author_name_by_id}/"); array_push($values, $username); } else { array_push($tags, "/{\\\$wakka\.tag\.author_name_by_id}/"); array_push($values, WAKKA_DEFAULT_UNKNOWN_USER); } } $this->Conn_wakka->FreeDB($result); } if ($this->getwakkatagrevision($wakka_revision_from, $wakka_revision_to)) { /* If we are on a diff revision * get the infos */ $from_infos = $this->getinfowakka($wakka_page, $wakka_revision_from); $to_infos = $this->getinfowakka($wakka_page, $wakka_revision_to); if ((!is_null($from_infos)) && (!is_null($to_infos))) { /* FROM info */ array_push($tags, "/{\\\$wakka\.tag_from\.tag}/"); array_push($values, $from_infos["wakka_tag"]); array_push($tags, "/{\\\$wakka\.tag_from\.author_id}/"); array_push($values, $from_infos["wakka_author_id"]); array_push($tags, "/{\\\$wakka\.tag_from\.author_name}/"); array_push($values, $from_infos["wakka_author_name"]); array_push($tags, "/{\\\$wakka\.tag_from\.date_revision}/"); array_push($values, strdatetime($from_infos["wakka_date_revision"])); $username = $this->getauthorname_byid($from_infos["wakka_author_id"]); if (!is_null($username)) { array_push($tags, "/{\\\$wakka\.tag_from\.author_name_by_id}/"); array_push($values, $username); } /* TO info */ array_push($tags, "/{\\\$wakka\.tag_to\.tag}/"); array_push($values, $to_infos["wakka_tag"]); array_push($tags, "/{\\\$wakka\.tag_to\.author_id}/"); array_push($values, $to_infos["wakka_author_id"]); array_push($tags, "/{\\\$wakka\.tag_to\.author_name}/"); array_push($values, $to_infos["wakka_author_name"]); array_push($tags, "/{\\\$wakka\.tag_to\.date_revision}/"); array_push($values, strdatetime($to_infos["wakka_date_revision"])); $username = $this->getauthorname_byid($to_infos["wakka_author_id"]); if (!is_null($username)) { array_push($tags, "/{\\\$wakka\.tag_to\.author_name_by_id}/"); array_push($values, $username); } } } } } return true; } return false; } function parsetpl($tpl_file) { /* --------------------------------------------------------------------------- * Parse a template file and return the result after evaluating * * @param string template file path * @return string template 's result content * ------------------------------------------------------------------------ */ if (!file_exists($tpl_file)) return; /* Read all template file */ $fd = fopen($tpl_file, "r"); $content = fread($fd, filesize($tpl_file)); fclose($fd); if ($this->getvars($tags, $values)) { $content = preg_replace($tags, $values, $content); } return $content; } function getwakkapage() { /* --------------------------------------------------------------------------- * Get wakka page name from various origin * $_GET, $_POST and class member wakka_page * * @return string wakka page name * ------------------------------------------------------------------------ */ if ((is_string($this->wakka_page)) && ($this->wakka_page != "")) { /* We must determine if we force using $_GET[WAKKA_PAGE_NAME] */ if ($this->force_getvar) { /* Force to use variable $_GET */ if ((isset($_GET[WAKKA_PAGE_NAME])) && ($_GET[WAKKA_PAGE_NAME]) != "") return $_GET[WAKKA_PAGE_NAME]; } return $this->wakka_page; } else { /* We have to use $_GET[WAKKA_PAGE_NAME] or $_POST[WAKKA_PAGE_NAME] */ if ((isset($_GET[WAKKA_PAGE_NAME])) && ($_GET[WAKKA_PAGE_NAME]) != "") return $_GET[WAKKA_PAGE_NAME]; } /* In all case $_POST[WAKKA_PAGE_NAME] has the priority */ if ($this->force_postvar) { if ((isset($_POST[WAKKA_PAGE_NAME])) && ($_POST[WAKKA_PAGE_NAME] != "")) return $_POST[WAKKA_PAGE_NAME]; } return NULL; } function getwakkatag() { /* --------------------------------------------------------------------------- * Get wakka tag name from various origin * $_GET, $_POST * * @return string wakka page name * ------------------------------------------------------------------------ */ /* We have to use $_GET[WAKKA_TAG_NAME] or $_POST[WAKKA_TAG_NAME] */ if ($this->force_getvar) { if ((isset($_GET[WAKKA_TAG_NAME])) && ($_GET[WAKKA_TAG_NAME]) != "") return $_GET[WAKKA_TAG_NAME]; } /* In all case $_POST[WAKKA_TAG_NAME] has the priority */ if ($this->force_postvar) { if ((isset($_POST[WAKKA_TAG_NAME])) && ($_POST[WAKKA_TAG_NAME] != "")) return $_POST[WAKKA_TAG_NAME]; } return NULL; } function getwakkatagrevision(&$wakka_revision_from, &$wakka_revision_to) { if ((isset($_POST["wakka_diff_revision"])) && (isset($_POST["wakka_key"])) && (isset($_POST["wakka_revision_from"])) && (isset($_POST["wakka_revision_to"]))) { $wakka_revision_from = $_POST["wakka_revision_from"]; $wakka_revision_to = $_POST["wakka_revision_to"]; return true; } return false; } function displayimg($img_name) { /* --------------------------------------------------------------------------- * Get an image from database and display it * * @param string wakka image name * @return boolean * ------------------------------------------------------------------------ */ if (!$this->isConnected()) return false; $show_image = true; if ((defined('WAKKA_IMAGE_PROTECT')) && (WAKKA_IMAGE_PROTECT)) { if (!isset($_SERVER["HTTP_REFERER"])) { // Image must be loaded in an html page $show_image = false; } else { // Empty referer is accepted if ($_SERVER["HTTP_REFERER"] !== "") { $info = parse_url($_SERVER["HTTP_REFERER"]); if (!isset($info["host"])) { // Cannot find the host part. // That means the URL is erroneous $show_image = false; } else { $show_image = ($info["host"] === $_SERVER["SERVER_NAME"]); } } } } if (!$show_image) { // Image must not be shown if (defined('WAKKA_IMAGE_PATH_DEFAULT')) { if ((file_exists(WAKKA_IMAGE_PATH_DEFAULT)) && (is_file(WAKKA_IMAGE_PATH_DEFAULT))) { $info = @getimagesize(WAKKA_IMAGE_PATH_DEFAULT); if ($info !== false) { // This is an image switch($info[2]) { case 1: // GIF Header("Content-Type: image/gif"); break; case 2: // JPEG Header("Content-Type: image/jpeg"); break; case 3: // PNG Header("Content-Type: image/png"); break; default: // Not supported return false; } Header("Content-Length: " . filesize(WAKKA_IMAGE_PATH_DEFAULT)); Header("Content-Disposition: filename=\"" . basename(WAKKA_IMAGE_PATH_DEFAULT) . "\""); Header("Content-Description: Powered by BSDMon"); $fd = fopen(WAKKA_IMAGE_PATH_DEFAULT, "rb"); if ($fd !== false) { while(!feof($fd)) { echo fread($fd, 32 * 1024); // 32k buffer size } fclose($fd); } } } } return false; } $SQL = "SELECT * FROM ".WAKKA_IMG_TABLE." WHERE wakka_key = ".STRING_SQL($img_name); $result_wakka = $this->Conn_wakka->QueryDB($SQL); if ($cur_wakka = $this->Conn_wakka->CursorDB($result_wakka)) { Header("Content-Type: ".$cur_wakka["wakka_type"]); Header("Content-Length: ".$cur_wakka["wakka_size"]); Header("Content-Disposition: filename=\"".$cur_wakka["wakka_name"])."\""; Header("Content-Description: Powered by BSDMon"); SHOW_BINARY($cur_wakka["wakka_data"]); } $this->Conn_wakka->FreeDB($result_wakka); return true; } function display($wakka_page = NULL) { /* --------------------------------------------------------------------------- * This is the main engine for Wakka * * @param string forced wakka page * @return boolean * ------------------------------------------------------------------------ */ if (!$this->isConnected()) return false; $wakka_edit = false; $wakka_upload_img = false; $on_preview = false; $on_edit = false; $on_tag = false; $on_diff = false; if ((is_null($wakka_page)) && (!$this->only_upload_form)) { /* if Wakka page is not set * we get this from $_GET, $_POST, or $wakka_page class member */ $wakka_page = $this->getwakkapage(); if (is_null($wakka_page)) return false; $wakka_tag = $this->getwakkatag(); if (!is_null($wakka_tag)) $on_tag = true; } /* BEGIN SUBMIT ACTION ------------------------------ */ /* Validate a page */ if ((isset($_POST[WAKKA_PAGE_NAME])) && (preg_match("/".REGEXP_WAKKA_PAGE."/", $_POST[WAKKA_PAGE_NAME])) && (isset($_POST["wakka_key"])) && (isset($_POST["wakka_txt"])) && ($_POST["wakka_key"] == $wakka_page)) { $additional_cols = ", wakka_author_id, wakka_author_name"; $additional_values = ", NULL, NULL"; $additional_cols_values = ", wakka_author_id = NULL, wakka_author_name = NULL"; $additional_revision_cols = ", wakka_revision_author_id, wakka_revision_author_name"; $additional_revision_values = ", NULL, NULL"; $additional_revision_cols_values = ", wakka_revision_author_id = NULL, ". "wakka_revision_author_name = NULL"; $userid = NULL; $username = NULL; if ((defined("WAKKA_FUNCTION_GETUSERID")) && (!is_null(WAKKA_FUNCTION_GETUSERID)) && (is_string(WAKKA_FUNCTION_GETUSERID)) && (WAKKA_FUNCTION_GETUSERID != "") && (function_exists(WAKKA_FUNCTION_GETUSERID))) { $userid = call_user_func(WAKKA_FUNCTION_GETUSERID); if (is_numeric($userid)) { $additional_cols = ", wakka_author_id, wakka_author_name"; $additional_values = ", ".$userid.", NULL"; $additional_cols_values = ", wakka_author_id = ".$userid.", ". "wakka_author_name = NULL"; $additional_revision_cols = ", wakka_revision_author_id, wakka_revision_author_name"; $additional_revision_values = ", ".$userid.", NULL"; $additional_revision_cols_values = ", wakka_revision_author_id = ".$userid.", ". "wakka_revision_author_name = NULL"; } } else if ((defined("WAKKA_FUNCTION_GETUSERNAME")) && (!is_null(WAKKA_FUNCTION_GETUSERNAME)) && (is_string(WAKKA_FUNCTION_GETUSERNAME)) && (WAKKA_FUNCTION_GETUSERNAME != "") && (function_exists(WAKKA_FUNCTION_GETUSERNAME))) { $username = call_user_func(WAKKA_FUNCTION_GETUSERNAME); if (is_string($username)) { $additional_cols = ", wakka_author_id, wakka_author_name"; $additional_values = ", NULL, ".STRING_SQL($username); $additional_cols_values = ", wakka_author_id = NULL, ". "wakka_author_name = ".STRING_SQL($username); $additional_revision_cols = ", wakka_revision_author_id, wakka_revision_author_name"; $additional_revision_values = ", NULL, ".STRING_SQL($username); $additional_revision_cols_values = ", wakka_revision_author_id = NULL, ". "wakka_revision_author_name = ".STRING_SQL($username); } } if (isset($_POST["wakka_ok"])) { $value_public = "0"; if ((isset($_POST["wakka_public"])) && ($_POST["wakka_public"] == "1")) $value_public = "1"; $SQL = "SELECT wakka_public FROM ".WAKKA_TXT_TABLE." WHERE wakka_key = ".STRING_SQL($_POST["wakka_key"]); $result_wakka = $this->Conn_wakka->QueryDB($SQL); if (($cur_wakka = $this->Conn_wakka->CursorDB($result_wakka)) && (($this->can_edit) || ($cur_wakka["wakka_public"]))) { $SQL = "UPDATE ".WAKKA_TXT_TABLE." SET wakka_txt = ".STRING_SQL(html_entity_decode($_POST["wakka_txt"])).", wakka_date_modif = ".SYSDATE().", wakka_public = ".$value_public. $additional_cols_values." WHERE wakka_key = ".STRING_SQL($_POST["wakka_key"]); $this->Conn_wakka->QueryDB($SQL); $msg = WAKKA_OK_UPDATE_PAGE; } else if ($this->can_edit) { $SQL = "INSERT INTO ".WAKKA_TXT_TABLE." (wakka_key, wakka_txt, wakka_public, wakka_date_creat, wakka_date_modif". $additional_cols.") ". "VALUES (".STRING_SQL($_POST["wakka_key"]).", ".STRING_SQL(html_entity_decode($_POST["wakka_txt"])).", ". $value_public.", ". SYSDATE().", ".SYSDATE().$additional_values.")"; $this->Conn_wakka->QueryDB($SQL); $msg = WAKKA_OK_INSERT_PAGE; } $this->Conn_wakka->FreeDB($result_wakka); } /* Validate revision */ if ((isset($_POST["wakka_revision_ok"])) && (isset($_POST["wakka_key"])) && (isset($_POST["wakka_tag_name"])) && ($_POST["wakka_tag_name"] != "") && ($this->can_do_revision)) { $info = $this->getinfowakka($_POST["wakka_key"]); if (!is_null($info)) { $SQL = "SELECT wakka_revision_author_id, wakka_revision_author_name FROM ".WAKKA_TXT_REVISION_TABLE." WHERE wakka_key = ".STRING_SQL($_POST["wakka_key"])." AND wakka_tag = ".STRING_SQL($_POST["wakka_tag_name"]); $result_wakka = $this->Conn_wakka->QueryDB($SQL); if ($cur_wakka = $this->Conn_wakka->CursorDB($result_wakka)) { if (((!is_null($cur_wakka["wakka_revision_author_id"])) && (!is_null($userid)) && ($userid == $cur_wakka["wakka_revision_author_id"])) || ((!is_null($cur_wakka["wakka_revision_author_name"])) && (!is_null($username)) && ($username == $cur_wakka["wakka_revision_author_name"]))) { $SQL = "UPDATE ".WAKKA_TXT_REVISION_TABLE." SET wakka_txt = ".STRING_SQL($info["wakka_txt"]).", wakka_date_revision = ".SYSDATE().$additional_revision_cols_values.", wakka_author_id = ".NUM_SQL($info["wakka_author_id"]).", wakka_author_name = ".STRING_SQL($info["wakka_author_name"])." WHERE wakka_key = ".STRING_SQL($_POST["wakka_key"])." AND wakka_tag = ".STRING_SQL($_POST["wakka_tag_name"]); $this->Conn_wakka->QueryDB($SQL); $msg = WAKKA_OK_UPDATE_REVISION; } } else { $wakka_revision = $this->Conn_wakka->LastIndexDB("wakka_revision", WAKKA_TXT_REVISION_TABLE, "WHERE wakka_key = ".STRING_SQL($_POST["wakka_key"])) + 1; $SQL = "INSERT INTO ".WAKKA_TXT_REVISION_TABLE." (wakka_key, wakka_revision, wakka_txt, wakka_date_revision, wakka_tag". $additional_revision_cols.", wakka_author_id, wakka_author_name) VALUES (".STRING_SQL($_POST["wakka_key"]).", ".$wakka_revision.", ".STRING_SQL($info["wakka_txt"]).", ".SYSDATE().", ".STRING_SQL($_POST["wakka_tag_name"]).$additional_revision_values.", ".NUM_SQL($info["wakka_author_id"]).", ".STRING_SQL($info["wakka_author_name"]).")"; $this->Conn_wakka->QueryDB($SQL); $msg = WAKKA_OK_INSERT_REVISION; } /* We stay on edit mode */ $wakka_edit = true; } } } /* Delete revision */ if ((isset($_POST["wakka_suppr_revision"])) && (isset($_POST["wakka_key"])) && (isset($_POST["wakka_revision"])) && ($this->can_do_revision) && ($_POST["wakka_key"] == $wakka_page)) { $info = $SQL = "DELETE FROM ".WAKKA_TXT_REVISION_TABLE." WHERE wakka_key = ".STRING_SQL($_POST["wakka_key"])." AND wakka_revision = ".$_POST["wakka_revision"]; $this->Conn_wakka->QueryDB($SQL); $msg = WAKKA_OK_DELETE_REVISION; /* We stay on edit mode */ $wakka_edit = true; } /* Restore revision */ if ((isset($_POST["wakka_restore_revision"])) && (isset($_POST["wakka_key"])) && (isset($_POST["wakka_revision"])) && ($this->can_do_revision) && ($_POST["wakka_key"] == $wakka_page)) { $info = $this->getinfowakka($_POST["wakka_key"], $_POST["wakka_revision"]); if (!is_null($info)) { $SQL = "UPDATE ".WAKKA_TXT_TABLE." SET wakka_txt = ".STRING_SQL($info["wakka_txt"]).", wakka_author_id = ".NUM_SQL($info["wakka_author_id"]).", wakka_author_name = ".NUM_SQL($info["wakka_author_name"]).", wakka_date_modif = ".SAFE_DATE_SQL(strdatetime($info["wakka_date_revision"]))." WHERE wakka_key = ".STRING_SQL($_POST["wakka_key"]); $this->Conn_wakka->QueryDB($SQL); $msg = WAKKA_OK_RESTORE_REVISION; /* We stay on edit mode */ $wakka_edit = true; } } /* Diff revision */ if ((isset($_POST["wakka_diff_revision"])) && (isset($_POST["wakka_key"])) && (isset($_POST["wakka_revision_from"])) && (isset($_POST["wakka_revision_to"])) && ($_POST["wakka_key"] == $wakka_page)) { $txt_from = NULL; $txt_to = NULL; $SQL = "SELECT wakka_txt FROM ".WAKKA_TXT_REVISION_TABLE." WHERE wakka_key = ".STRING_SQL($_POST["wakka_key"])." AND wakka_revision = ".NUM_SQL($_POST["wakka_revision_from"]); $result = $this->Conn_wakka->QueryDB($SQL); if ($cur = $this->Conn_wakka->CursorDB($result)) { $txt_from = $cur[0]; } $this->Conn_wakka->FreeDB($result); $SQL = "SELECT wakka_txt FROM ".WAKKA_TXT_REVISION_TABLE." WHERE wakka_key = ".STRING_SQL($_POST["wakka_key"])." AND wakka_revision = ".NUM_SQL($_POST["wakka_revision_to"]); $result = $this->Conn_wakka->QueryDB($SQL); if ($cur = $this->Conn_wakka->CursorDB($result)) { $txt_to = $cur[0]; } $this->Conn_wakka->FreeDB($result); if ((!is_null($txt_from)) && (!is_null($txt_to))) { if (isset($_POST["wakka_diff_raw_txt"])) $wakka_txt_diff = $this->diff( $this->safetxt($txt_from), $this->safetxt($txt_to) ); else //$wakka_txt_diff = $this->processall($this->diff($txt_from, $txt_to), $_POST["wakka_key"]); $wakka_txt_diff = $this->diff( $this->processall($txt_from, $_POST["wakka_key"]), $this->processall($txt_to, $_POST["wakka_key"]) ); $on_diff = true; } } /* Delete page */ if ((isset($_POST["wakka_suppr_ok"])) && (isset($_POST["wakka_key"])) && ($this->can_edit) && ($_POST["wakka_key"] == $wakka_page)) { $SQL = "DELETE FROM ".WAKKA_TXT_REVISION_TABLE." WHERE wakka_key = ".STRING_SQL($_POST["wakka_key"]); $this->Conn_wakka->QueryDB($SQL); $SQL = "DELETE FROM ".WAKKA_TXT_TABLE." WHERE wakka_key = ".STRING_SQL($_POST["wakka_key"]); $this->Conn_wakka->QueryDB($SQL); $msg = WAKKA_OK_DELETE_PAGE; } /* Insert a new image */ if ((isset($_POST["wakka_img_name"])) && (preg_match("/".REGEXP_WAKKA_PAGE."/", $_POST["wakka_img_name"])) && (isset($_FILES["wakka_img"])) && (($this->only_upload_form) || ($wakka_upload_img))) { if ($_FILES["wakka_img"]["size"] > WAKKA_MAX_FILESIZE) { /* Image trop volumineuse */ $msg_error = WAKKA_ERROR_FILESIZE_EXCEEDED." (".$_FILES["wakka_img"]["size"]." > ".WAKKA_MAX_FILESIZE.")<br />"; } else { switch($_FILES["wakka_img"]["type"]) { case "image/jpeg": case "image/gif": case "image/png": if (((isset($_POST["wakka_img_width"])) && (is_numeric($_POST["wakka_img_width"]))) || ((isset($_POST["wakka_img_height"])) && (is_numeric($_POST["wakka_img_height"])))) { $width_image = NULL; $height_image = NULL; if ((isset($_POST["wakka_img_width"])) && (is_numeric($_POST["wakka_img_width"]))) $width_image = $_POST["wakka_img_width"]; if ((isset($_POST["wakka_img_height"])) && (is_numeric($_POST["wakka_img_height"]))) $height_image = $_POST["wakka_img_height"]; if (!$this->resize_image($_FILES["wakka_img"]["tmp_name"], $bin_result, $bin_size, $width_image, $height_image)) { $msg_error = WAKKA_ERROR_IMG_RESIZE; unset($bin_result); unset($bin_size); } } else { $fd = fopen($_FILES["wakka_img"]["tmp_name"], "rb"); $bin_result = fread($fd, $_FILES["wakka_img"]["size"]); $bin_size = $_FILES["wakka_img"]["size"]; fclose($fd); } if ((isset($bin_result)) && (isset($bin_size))) { $SQL = "SELECT count(*) FROM ".WAKKA_IMG_TABLE." WHERE wakka_key = ".STRING_SQL($_POST["wakka_img_name"]); $result_wakka = $this->Conn_wakka->QueryDB($SQL); if (($cur_wakka = $this->Conn_wakka->CursorDB($result_wakka)) && ($cur_wakka[0] >= 1)) { if (WAKKA_OVERWRITE_UPLOAD_IMG) { $SQL = "UPDATE ".WAKKA_IMG_TABLE." SET wakka_type = ".STRING_SQL($_FILES["wakka_img"]["type"]).", wakka_size = ".$bin_size.", wakka_name = ".STRING_SQL($_FILES["wakka_img"]["name"]).", wakka_data = ".BINARY($bin_result).", wakka_date_modif = ".SYSDATE()." WHERE wakka_key = ".STRING_SQL($_POST["wakka_img_name"]); $this->Conn_wakka->QueryDB($SQL); $msg = WAKKA_OK_UPDATE_IMAGE; } else { $msg_error = WAKKA_ERROR_IMG_ALREADY_EXISTS; } } else { $SQL = "INSERT INTO ".WAKKA_IMG_TABLE." (wakka_key, wakka_type, wakka_size, wakka_name, wakka_data, wakka_date_creat, wakka_date_modif) VALUES (".STRING_SQL($_POST["wakka_img_name"])." , ".STRING_SQL($_FILES["wakka_img"]["type"])." , ".$bin_size." , ".STRING_SQL($_FILES["wakka_img"]["name"])." , ".BINARY($bin_result).", ".SYSDATE().", ".SYSDATE().")"; $this->Conn_wakka->QueryDB($SQL); $msg = WAKKA_OK_INSERT_IMAGE; } $this->Conn_wakka->FreeDB($result_wakka); } else { $msg_error = WAKKA_ERROR_IMAGE; } break; default: $msg_error = WAKKA_ERROR_UNKNOWN_IMAGE; break; } } } /* END SUBMIT ACTION -------------------------------- */ if ((isset($_GET[WAKKA_EDIT_NAME])) && (isset($wakka_page)) && ($_GET[WAKKA_EDIT_NAME] == $wakka_page)) { /* We must edit on the selected page * This will prevent open edit mode on all wakka page in the whole document */ $wakka_edit = true; } if ((isset($_POST[WAKKA_EDIT_NAME])) && (isset($wakka_page)) && (isset($_POST["wakka_reedit"])) && ($_POST[WAKKA_EDIT_NAME] == $wakka_page)) { /* We must edit on the selected page * This will prevent open edit mode on all wakka page in the whole document * * This case is reedit a preview */ $wakka_edit = true; } if (isset($_GET[WAKKA_UPLOAD_IMG_NAME])) $wakka_upload_img = true; /* Print msg error */ if (isset($msg_error)) { ?> <p class="<?php echo WAKKA_TEXT_ERROR_CSS_CLASS; ?>"> <?php echo $msg_error; ?> </p> <?php } /* Print msg */ if (isset($msg)) { ?> <p class="<?php echo WAKKA_TEXT_OK_CSS_CLASS; ?>"> <?php echo $msg; ?> </p> <?php } if ($this->only_upload_form) { /* We only show an upload form * This do not include <form> tag * so that you can include it on existing form */ ?> <div class="<?php echo WAKKA_TEXT_CSS_CLASS; ?>"> <h4><?php echo WAKKA_IMG_EDIT; ?></h4> <?php echo WAKKA_TEXT_IMG_EDIT; ?> <input class="<?php echo WAKKA_TEXTINPUT_CSS_CLASS; ?>" type="text" maxlength="100" size="30" name="wakka_img_name" /> <br /> <?php echo WAKKA_FILE_IMG_EDIT; ?> <input class="<?php echo WAKKA_TEXTINPUT_CSS_CLASS; ?>" type="file" size="30" name="wakka_img" /> <br /> <h4><?php echo WAKKA_TEXT_IMG_RESIZE; ?></h4> <?php echo WAKKA_TEXT_IMG_WIDTH_EDIT; ?> <input class="<?php echo WAKKA_TEXTINPUT_CSS_CLASS; ?>" type="text" maxlength="5" size="10" name="wakka_img_width" /> <br /> <?php echo WAKKA_TEXT_IMG_HEIGHT_EDIT; ?> <input class="<?php echo WAKKA_TEXTINPUT_CSS_CLASS; ?>" type="text" maxlength="5" size="10" name="wakka_img_height" /> <br /> <hr /> <input type="submit" value="<?php echo WAKKA_SUBMIT_OK_VALUE; ?>" class="<?php echo WAKKA_BUTTON_CSS_CLASS; ?>" name="wakka_ok" /> </div> <?php } else { /* Get the contents and print it */ if ((isset($wakka_page)) && ($wakka_page != "") && (preg_match("/".REGEXP_WAKKA_PAGE."/", $wakka_page))) { /* ----------------------------------------------------------------------------- * Begin get text */ $on_new_page = false; $wakka_public = false; if ($on_tag) { /* We get the text from existing wakka page * and a specified tag */ $SQL = "SELECT ".WAKKA_TXT_REVISION_TABLE.".wakka_txt, ". WAKKA_TXT_TABLE.".wakka_public FROM ".WAKKA_TXT_TABLE.", ".WAKKA_TXT_REVISION_TABLE." WHERE ".WAKKA_TXT_REVISION_TABLE.".wakka_key = ".STRING_SQL($wakka_page)." AND ".WAKKA_TXT_REVISION_TABLE.".wakka_tag = ".STRING_SQL($wakka_tag)." AND ".WAKKA_TXT_TABLE.".wakka_key = ".WAKKA_TXT_REVISION_TABLE.".wakka_key"; } else { /* We get the text from existing wakka page */ $SQL = "SELECT wakka_txt, wakka_public FROM ".WAKKA_TXT_TABLE." WHERE wakka_key = ".STRING_SQL($wakka_page); } $result_wakka = $this->Conn_wakka->QueryDB($SQL); if ($cur_wakka = $this->Conn_wakka->CursorDB($result_wakka)) { /* We have text to print */ $wakka_txt = $cur_wakka['wakka_txt']; $wakka_public = $cur_wakka['wakka_public']; } if ((isset($_POST["wakka_preview"])) && (isset($_POST["wakka_key"])) && (isset($_POST["wakka_txt"])) && ($_POST["wakka_key"] == $wakka_page)) { /* We are on a preview mode */ $wakka_txt = $_POST["wakka_txt"]; $on_preview = true; $wakka_edit = true; } else if ((isset($_POST["wakka_reedit"])) && (isset($_POST["wakka_key"])) && (isset($_POST["wakka_txt"])) && ($_POST["wakka_key"] == $wakka_page)) { /* We are on a reedit mode */ $wakka_txt = $_POST["wakka_txt"]; } else if (!isset($wakka_txt)) { /* We are on a new page */ $wakka_edit = true; $on_new_page = true; } if ($on_tag) { if ((defined("WAKKA_TEMPLATE_DIR")) && (defined("WAKKA_TEMPLATE_HEADER_REVISION")) && ($this->show_header) && (!$on_new_page)) { echo $this->parsetpl(WAKKA_TEMPLATE_DIR."/".WAKKA_TEMPLATE_HEADER_REVISION); } } else if ($on_diff) { if ((defined("WAKKA_TEMPLATE_DIR")) && (defined("WAKKA_TEMPLATE_HEADER_DIFF")) && ($this->show_header) && (!$on_new_page)) { echo $this->parsetpl(WAKKA_TEMPLATE_DIR."/".WAKKA_TEMPLATE_HEADER_DIFF); } } else if ((defined("WAKKA_TEMPLATE_DIR")) && (defined("WAKKA_TEMPLATE_HEADER")) && ($this->show_header) && (!$on_new_page)) { echo $this->parsetpl(WAKKA_TEMPLATE_DIR."/".WAKKA_TEMPLATE_HEADER); } if (isset($wakka_txt)) { /* text is set and we are not on diff */ if ((WAKKA_ALWAYS_PREVIEW_ON_EDIT) || ($on_preview) || (!$wakka_edit)) { /* We do not show the result if we are on edit * except on preview */ if ($on_preview) { /* On preview, we *MUST* notify it */ if ((defined("WAKKA_TEMPLATE_DIR")) && (defined("WAKKA_TEMPLATE_PREVIEW")) && ($this->show_header) && (!$on_new_page)) { echo $this->parsetpl(WAKKA_TEMPLATE_DIR."/".WAKKA_TEMPLATE_PREVIEW); } } if (($on_diff) && (isset($wakka_txt_diff))) { echo $wakka_txt_diff; } else { /* We format the content */ $wakka_echo = $this->processall($wakka_txt, $wakka_page); echo $wakka_echo; } } /* This will show the delete button */ $on_edit = true; if ((($this->can_edit) || ($wakka_public)) && (!$wakka_edit)) { ?> <br /><br /> <div class="LinkFormWakka"> <a href="<?php echo $this->rewrite_url($_SERVER["SCRIPT_NAME"]."?".WAKKA_EDIT_NAME."=".$wakka_page."&amp;".WAKKA_PAGE_NAME."=".$wakka_page); ?>"> <?php echo str_replace("%s", "[[".$wakka_page."]]", WAKKA_TEXT_EDIT); ?> </a> </div> <?php } } /* ---------------------------------------------------------------------------*/ if ((($this->can_edit) || ($wakka_public)) && ($wakka_edit)) { if ((isset($wakka_can_upload_img)) && ($wakka_can_upload_img) && ($wakka_upload_img)) { $form_enctype = " enctype=\"multipart/form-data\""; } else { $form_enctype = ""; } ?> <form action="<?php echo $_SERVER["SCRIPT_NAME"]; ?>" method="post"<?php echo $form_enctype; ?>> <div class="<?php echo WAKKA_TEXT_CSS_CLASS; ?>"> <?php if ((WAKKA_ALWAYS_EDIT_PREVIEW) || (!$on_preview)) { /* We show the textarea * if we are not on preview */ ?> <h4><?php echo str_replace("%s", "[[".$wakka_page."]]", WAKKA_TEXT_EDIT); ?></h4> <textarea class="<?php echo WAKKA_TEXTAREA_CSS_CLASS; ?>" name="wakka_txt" rows="<?php echo WAKKA_TEXTAREA_ROWS; ?>" cols="<?php echo WAKKA_TEXTAREA_COLS; ?>"><?php if (isset($wakka_txt)) echo _htmlspecialchars($wakka_txt); ?></textarea><br /> <?php echo WAKKA_TEXT_PUBLIC_EDIT; ?> <input type="checkbox" name="wakka_public" value="1" <?php echo ($wakka_public ? "checked=\"checked\"" : ""); ?> /> <?php } else if ($on_preview) { /* On preview, we *MUST* preserve the text * and create an input hidden to manage reedit */ ?> <input type="hidden" name="wakka_txt" value="<?php echo _htmlspecialchars($wakka_txt); ?>" /> <input type="hidden" name="wakka_public" value="<?php echo ($wakka_public ? "1" : "0"); ?>" /> <input type="hidden" name="<?php echo WAKKA_EDIT_NAME; ?>" value="<?php echo $wakka_page; ?>" /> <?php } ?> <input type="hidden" name="wakka_key" value="<?php echo $wakka_page; ?>" /> <input type="hidden" name="<?php echo WAKKA_PAGE_NAME; ?>" value="<?php echo $wakka_page; ?>" /> <br /> <hr /> <?php if ($on_preview) { ?> <input type="submit" value="<?php echo WAKKA_SUBMIT_OK_VALUE; ?>" class="<?php echo WAKKA_BUTTON_CSS_CLASS; ?>" name="wakka_ok" />&nbsp; <input type="submit" value="<?php echo WAKKA_SUBMIT_REEDIT_VALUE; ?>" class="<?php echo WAKKA_BUTTON_CSS_CLASS; ?>" name="wakka_reedit" />&nbsp; <input type="submit" value="<?php echo WAKKA_SUBMIT_CANCEL_VALUE; ?>" class="<?php echo WAKKA_BUTTON_CSS_CLASS; ?>" name="wakka_cancel" />&nbsp; <?php } else { /* We are not on preview here */ if (($this->can_upload_img) && ($wakka_upload_img)) { /* We show the input to upload image file */ ?> <h4><?php echo WAKKA_IMG_EDIT; ?></h4> <?php echo WAKKA_TEXT_IMG_EDIT; ?> <input class="<?php echo WAKKA_TEXTINPUT_CSS_CLASS; ?>" type="text" maxlength="100" size="30" name="wakka_img_name" /> <br /> <?php echo WAKKA_FILE_IMG_EDIT; ?> <input class="<?php echo WAKKA_TEXTINPUT_CSS_CLASS; ?>" type="file" size="30" name="wakka_img" /> <br /> <h4><?php echo WAKKA_TEXT_IMG_RESIZE; ?></h4> <?php echo WAKKA_TEXT_IMG_WIDTH_EDIT; ?> <input class="<?php echo WAKKA_TEXTINPUT_CSS_CLASS; ?>" type="text" maxlength="5" size="10" name="wakka_img_width" /> <br /> <?php echo WAKKA_TEXT_IMG_HEIGHT_EDIT; ?> <input class="<?php echo WAKKA_TEXTINPUT_CSS_CLASS; ?>" type="text" maxlength="5" size="10" name="wakka_img_height" /> <br /> <hr /> <?php } ?> <input type="submit" value="<?php echo WAKKA_SUBMIT_OK_VALUE; ?>" class="<?php echo WAKKA_BUTTON_CSS_CLASS; ?>" name="wakka_ok" />&nbsp; <input type="submit" value="<?php echo WAKKA_SUBMIT_PREVIEW_VALUE; ?>" class="<?php echo WAKKA_BUTTON_CSS_CLASS; ?>" name="wakka_preview" />&nbsp; <input type="submit" value="<?php echo WAKKA_SUBMIT_CANCEL_VALUE; ?>" class="<?php echo WAKKA_BUTTON_CSS_CLASS; ?>" name="wakka_cancel" />&nbsp; <?php /* Page exists in database */ if ($on_edit) { ?> <input type="submit" onclick="javascript:return confirm('<?php echo WAKKA_CONFIRM_TEXT; ?>');" value="<?php echo WAKKA_SUBMIT_DELETE_VALUE; ?>" class="<?php echo WAKKA_BUTTON_CSS_CLASS; ?>" name="wakka_suppr_ok" /> <?php } ?> <br /> <?php if (($this->can_do_revision) && ($on_edit)) { ?> <input type="submit" value="<?php echo WAKKA_SUBMIT_REVISION_VALUE; ?>" class="<?php echo WAKKA_BUTTON_CSS_CLASS; ?>" name="wakka_revision_ok" />&nbsp; avec pour &eacute;tiquette <input class="<?php echo WAKKA_TEXTINPUT_CSS_CLASS; ?>" type="text" size="15" maxlength="100" name="wakka_tag_name" /> <?php } ?> </div> </form> <?php if (($this->can_do_revision) && ($on_edit)) { $SQL = "SELECT wakka_revision, wakka_date_revision, wakka_tag FROM ".WAKKA_TXT_REVISION_TABLE." WHERE wakka_key = ".STRING_SQL($wakka_page)." ORDER BY wakka_date_revision DESC"; $result_revision = $this->Conn_wakka->QueryDB($SQL); if ($this->Conn_wakka->CountRowsDB($result_revision) > 0) { ?> <div> <h4><?php echo WAKKA_TEXT_TITLE_REVISION; ?></h4> <form action="<?php echo $_SERVER["SCRIPT_NAME"]; ?>" method="post"> <table border="0" cellspacing="0" cellpadding="3"> <tr> <th><?php echo WAKKA_TEXT_CHOICE; ?> </th> <th colspan="2"> <input type="submit" class="<?php echo WAKKA_BUTTON_CSS_CLASS; ?>" name="wakka_diff_revision" value="<?php echo WAKKA_SUBMIT_DIFF_REVISION_VALUE; ?>" /> </th> <th align="left"> <?php echo WAKKA_TEXT_PRINT_SIMPLE; ?><input type="checkbox" name="wakka_diff_raw_txt" checked="checked" /> </th> </tr> <?php $i = 0; while($cur_revision = $this->Conn_wakka->CursorDB($result_revision)) { ?> <tr> <td> <input type="radio" name="wakka_revision" value="<?php echo $cur_revision["wakka_revision"]; ?>" /> </td> <td> <input type="radio" name="wakka_revision_to" value="<?php echo $cur_revision["wakka_revision"]; ?>"<?php echo ($i == 0 ? " checked=\"checked\"" : "");?> /> </td> <td> <input type="radio" name="wakka_revision_from" value="<?php echo $cur_revision["wakka_revision"]; ?>"<?php echo ($i == 1 ? " checked=\"checked\"" : "");?> /> </td> <td> <?php echo "TAG : ". "<a href=\"".$this->rewrite_url($_SERVER["SCRIPT_NAME"]."?".WAKKA_TAG_NAME."=".$cur_revision["wakka_tag"]."&amp;".WAKKA_PAGE_NAME."=".$wakka_page)."\">". $cur_revision["wakka_tag"]."</a>, ". "DATE : ".strdatetime($cur_revision["wakka_date_revision"]).", ". "AUTHOR : ".$this->getauthorname($wakka_page, $cur_revision["wakka_revision"]); ?> </td> </tr> <?php $i++; } ?> </table> <input type="hidden" name="wakka_key" value="<?php echo $wakka_page; ?>" /> <input type="hidden" name="<?php echo WAKKA_PAGE_NAME; ?>" value="<?php echo $wakka_page; ?>" /> <input type="submit" onclick="javascript:return confirm('<?php echo WAKKA_CONFIRM_TEXT; ?>');" class="<?php echo WAKKA_BUTTON_CSS_CLASS; ?>" name="wakka_suppr_revision" value="<?php echo WAKKA_SUBMIT_DELETE_REVISION_VALUE; ?>" /> <input type="submit" class="<?php echo WAKKA_BUTTON_CSS_CLASS; ?>" name="wakka_restore_revision" value="<?php echo WAKKA_SUBMIT_RESTORE_REVISION_VALUE; ?>" /> </form> </div> <?php } $this->Conn_wakka->FreeDB($result_revision); } /* END revision section */ } /* END Not on preview */ } /* END Form edit */ if ($on_tag) { if ((defined("WAKKA_TEMPLATE_DIR")) && (defined("WAKKA_TEMPLATE_FOOTER_REVISION")) && ($this->show_footer) && (!$on_new_page)) { echo $this->parsetpl(WAKKA_TEMPLATE_DIR."/".WAKKA_TEMPLATE_FOOTER_REVISION); } } else if ($on_diff) { if ((defined("WAKKA_TEMPLATE_DIR")) && (defined("WAKKA_TEMPLATE_FOOTER_DIFF")) && ($this->show_footer) && (!$on_new_page)) { echo $this->parsetpl(WAKKA_TEMPLATE_DIR."/".WAKKA_TEMPLATE_FOOTER_DIFF); } } else if ((defined("WAKKA_TEMPLATE_DIR")) && (defined("WAKKA_TEMPLATE_FOOTER")) && ($this->show_footer) && (!$on_new_page)) { echo $this->parsetpl(WAKKA_TEMPLATE_DIR."/".WAKKA_TEMPLATE_FOOTER); } } /* END Wakka page */ } return true; } /* END display() /* -------------------------------------------------------------------------- */ } function wakkaprocessall($value, &$Conn_wakka, $nl2br = false, $wakka_page = "") { $wakka = new Wakka(); $wakka->setConnect($Conn_wakka); $wakka->nl2br = $nl2br; $wakka->parse_rewritefile("./.htaccess"); return $wakka->processall($value, $wakka_page); } function wakkarewriteurl($url, $rewrite_file = "./.htaccess") { $wakka = new Wakka(); $wakka->parse_rewritefile($rewrite_file); return $wakka->rewrite_url($url); } ?>

par hika - 2005-02-06 17:12:52
crée le 2005-02-06 17:12:52

FreeBSD Mall Smarty Template Engine Page générée le Samedi 26 Avril 2025 14:30:03 Powered by FreeBSD
POWERED BY FreeBSD, Apache, PHP, PostgreSQL, Code & design by Hika
BSD Daemon Copyright 1988 by Marshall Kirk McKusick. All Rights Reserved.