From 4c6aac503d8c7d305f26d381ebaec5d8813389a1 Mon Sep 17 00:00:00 2001
From: Laurent Laffont <llaffont@afi-sa.fr>
Date: Fri, 26 Oct 2018 10:03:21 +0200
Subject: [PATCH] remove dead code

---
 cosmogramme/php/fonctions/fonctions_base.php | 54 +--------------
 cosmogramme/php/fonctions/sql.php            | 29 +-------
 cosmogramme/php/fonctions/string.php         | 12 +---
 library/Class/Xml.php                        | 52 +++-----------
 library/fonctions/error.php                  | 33 +--------
 library/fonctions/file_system.php            | 73 --------------------
 library/fonctions/sql.php                    | 27 --------
 library/fonctions/string.php                 | 34 ---------
 8 files changed, 17 insertions(+), 297 deletions(-)
 delete mode 100644 library/fonctions/file_system.php

diff --git a/cosmogramme/php/fonctions/fonctions_base.php b/cosmogramme/php/fonctions/fonctions_base.php
index 3105d7ae374..b70ea8ed994 100644
--- a/cosmogramme/php/fonctions/fonctions_base.php
+++ b/cosmogramme/php/fonctions/fonctions_base.php
@@ -16,7 +16,7 @@
  *
  * You should have received a copy of the GNU AFFERO GENERAL PUBLIC LICENSE
  * along with BOKEH; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301  USA 
+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301  USA
  */
 //////////////////////////////////////////////////////////////////////////////
 //   FONCTIONS DE BASE
@@ -43,9 +43,9 @@ function lireConfig($fic)
 	}
 	return $cfg;
 }
-// ---------------------------------------------------	
+// ---------------------------------------------------
 // Clef se securite
-// ---------------------------------------------------	
+// ---------------------------------------------------
 function getClefSecurite()
 {
 	$clef="IMG".date("DxzxYxM")."VIG";
@@ -83,52 +83,4 @@ function rendBouton($libelle,$script,$arguments,$confirmation="")
 	return $url;
 }
 
-///////////////////////////////////////////////////////////////////////////////////////
-// DEBUG
-///////////////////////////////////////////////////////////////////////////////////////
-
-// Affiche le contenu d'un tableau
-function dump_array( $tableau)
-{
-	print( "<br><br><big><b>Tableau</b></big>");
-	print("<br><br><pre>");
-	print_r($tableau);
-	print("</pre><br><br>");
-}
-function dump_var($texte)
-{
-	print(htmlspecialchars($texte));
-}
-function dump_ascii($chaine)
-{
-	for($i=0;$i<strlen($chaine);$i++)
-	{
-		$car=strmid($chaine,$i,1);
-		print("CHAR=".$car."=".ord($car).BR);
-	}
-}
-function traceDebug($trace=false,$exit=false)
-{
-	// Script et fonction
-	$stack=debug_backtrace();
-	$lig=$stack[1];
-	print('<div class="trace_debug">');
-	if($niveau==100) dump_array($stack);
-	else
-	{
-		print("<b>Script : </b>". $lig["file"]);
-		print(" - <b>Ligne : </b>". $lig["line"]);
-		if($lig["class"]) print(" - <b>Classe : </b>". $lig["class"]);
-		print(" - <b>Fonction : </b>". $lig["function"].BR);
-		// Données
-		if($trace)
-		{
-			if(gettype($trace) == "array") dump_array($trace);
-			else print('<b>Message : </b>'.$trace.BR);
-		}
-	}
-	print('</div>');
-	flush();
-	if($exit == true) exit;
-}
 ?>
\ No newline at end of file
diff --git a/cosmogramme/php/fonctions/sql.php b/cosmogramme/php/fonctions/sql.php
index 1d8c0618bf5..479ca335dd3 100644
--- a/cosmogramme/php/fonctions/sql.php
+++ b/cosmogramme/php/fonctions/sql.php
@@ -16,7 +16,7 @@
  *
  * You should have received a copy of the GNU AFFERO GENERAL PUBLIC LICENSE
  * along with BOKEH; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301  USA 
+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301  USA
  */
 //////////////////////////////////////////////////////////////////////////////////////////
 // OPAC3 - Fonctions sql simplifi�es
@@ -58,23 +58,6 @@ function fetchAll($req,$num=false)
 	return $sql->fetchAll($req,$num);
 }
 
-// ---------------------------------------------------
-// Renvoie un where a partir d'un array de conditions
-// ---------------------------------------------------
-function getWhereSql($conditions)
-{
-	if(!$conditions) return "";
-	if(gettype($conditions)=="string") $conditions[0]=$conditions;
-	foreach($conditions as $condition)
-	{
-		if(!trim($condition)) continue;
-		if($where) $where.=" and ";
-		$where.=$condition;
-	}
-	if(!$where) return "";
-	$where=" where ".$where;
-	return $where;
-}
 
 // ---------------------------------------------------
 // Requete update
@@ -93,13 +76,3 @@ function sqlInsert($table,$data)
 	global $sql;
 	return $sql->insert($table,$data);
 }
-// ---------------------------------------------------
-// Renvoie une clause limt sql
-// ---------------------------------------------------
-function getLimitSql($nb_par_page,$page)
-{
-	if(!$page) $page=1;
-	$limit = ($page-1) * $nb_par_page;
-	$limit = " LIMIT ".$limit.",". $nb_par_page;
-	return $limit;
-}
\ No newline at end of file
diff --git a/cosmogramme/php/fonctions/string.php b/cosmogramme/php/fonctions/string.php
index d7df060caeb..15bd25cce9c 100644
--- a/cosmogramme/php/fonctions/string.php
+++ b/cosmogramme/php/fonctions/string.php
@@ -16,7 +16,7 @@
  *
  * You should have received a copy of the GNU AFFERO GENERAL PUBLIC LICENSE
  * along with BOKEH; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301  USA 
+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301  USA
  */
 //////////////////////////////////////////////////////////////////////////////////////
 //                  FONCTIONS CHAINES DE CARACTERES
@@ -51,15 +51,5 @@ function strScan( $chaine, $cherche, $posDeb=0)
 	return -1;
 }
 
-function strScanReverse( $chaine, $cherche, $pos )
-{
-	$len = strLen($cherche);
-	if( $pos == -1 ) $pos = strLen($chaine);
-	for( $i=$pos; $i>=0; $i-- )
-	{
-		if( substr( $chaine, $i, $len ) == $cherche ) return $i;
-	}
-	return -1;
-}
 
 ?>
\ No newline at end of file
diff --git a/library/Class/Xml.php b/library/Class/Xml.php
index 131a1f4b4de..75f50922049 100644
--- a/library/Class/Xml.php
+++ b/library/Class/Xml.php
@@ -40,9 +40,17 @@ class Class_Xml {
   }
 
 
+  public function lire_fichier( $fic) {
+    @$handle = fopen( $fic, "r") or erreur_admin( "Impossible d'ouvrir le fichier : " .$fic );
+    $data=fread ($handle, filesize ($fic));
+    fclose($handle);
+    return $data;
+  }
+
+
   public function open_fichier($fic) {
     include_once 'fonctions/file_system.php';
-    $data = lire_fichier($fic);
+    $data = $this->lire_fichier($fic);
     $parser = xml_parser_create("ISO-8859-1");
     xml_parse_into_struct($parser, $data, $this->valeurs, $this->index);
     xml_parser_free($parser);
@@ -108,22 +116,6 @@ class Class_Xml {
   }
 
 
-  public function dump_node($node)  {
-    if($this->valeurs[$node]["type"]=="complete"){dump_array($this->valeurs[$node]); return true;}
-    for($i=$node; $i< 32000; $i++)
-    {
-      if(!$this->valeurs[$i]) return false;
-      if($this->fin_node($node, $i) == true)
-      {
-        //dump_array($data);
-        return true;
-      }
-      //$data[]= $this->valeurs[$i];
-      dump_array($this->valeurs[$i]);flush();
-    }
-  }
-
-
   public function get_value($node) {
     return $this->valeurs[$node]["value"];
   }
@@ -135,32 +127,6 @@ class Class_Xml {
   }
 
 
-  public function dump_xml($format) {
-    if(strToUpper($format)=="XML") {
-      foreach($this->valeurs as $balise) {
-        $balise["tag"]=strToLower($balise["tag"]);
-        $data.=str_repeat("&nbsp;", 5 * $balise["level"]);
-        if($balise["type"] == "close" ) $data.="@D@/"; else $data.="@D@";
-        $data.= '<font color="#772B1A">'. $balise["tag"] .'</font>';
-        if($balise["attributes"]) {
-          foreach( $balise["attributes"] as $key => $value) $data.=' <font color="#ff0000">'.strToLower($key).'</font><font color="#0000ff">="</font><font color="#ff0000">'.$value.'</font><font color="#0000ff">"</font>';
-        }
-        if($balise["type"]=="complete" and $balise["value"]) $data.= "@F@<b>" .$balise["value"] ."</b>@D@/".'<font color="#772B1A">'.$balise["tag"] .'</font>';
-        $data.= "@F@";
-        $data.= BR;
-      }
-      $data = str_replace("@D@/", '<font color="#0000ff">&lt;/</font>', $data);
-      $data = str_replace("@D@", '<font color="#0000ff">&lt;</font>', $data);
-      $data = str_replace("@F@", '<font color="#0000ff">&gt;</font>', $data);
-      print($data);
-      return;
-    }
-
-    dump_array($this->index);
-    dump_array($this->valeurs);
-  }
-
-
   public function fin_node($node, $test) {
     if($this->valeurs[$node]["type"]=="complete")
       return true;
diff --git a/library/fonctions/error.php b/library/fonctions/error.php
index 99ad1a39cc5..908a07c57c0 100644
--- a/library/fonctions/error.php
+++ b/library/fonctions/error.php
@@ -16,36 +16,9 @@
  *
  * You should have received a copy of the GNU AFFERO GENERAL PUBLIC LICENSE
  * along with BOKEH; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301  USA 
+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301  USA
  */
-function logErrorMessage($message) 
-{ 
-    echo '<b>keskil pass</b><br />'.$message.'<br />'; 
-}
-
-function traceDebug($trace,$exit=false)
-{
-  // Script et fonction
-  $stack=debug_backtrace();
-  $lig=$stack[1];
-  print('<div style="margin-left:10px;margin-bottom:5px;margin-top:5px;border:1px solid;border-color:#E0E0E0;background-color:#CCFF99;padding:5px;text-align:left">');
-  if($niveau==100) dump_array($stack);
-  else
-  {
-    print("<b>Script : </b>". $lig["file"]);
-    print(" - <b>Ligne : </b>". $lig["line"]);
-    if($lig["class"]) print(" - <b>Classe : </b>". $lig["class"]);
-    print(" - <b>Fonction : </b>". $lig["function"].BR);
-    // Données
-    if($trace)
-    {
-      $type=gettype($trace);
-      if( $type == "array" or $type=="object") dump_array($trace);
-      else print('<b>Message : </b>'.$trace.BR);
-    }
-  }
-  print('</div>');
-  flush();
-  if($exit == true) exit;
+function logErrorMessage($message) {
+    echo '<b>Error</b><br />'.$message.'<br />';
 }
 ?>
\ No newline at end of file
diff --git a/library/fonctions/file_system.php b/library/fonctions/file_system.php
deleted file mode 100644
index 25ae3671907..00000000000
--- a/library/fonctions/file_system.php
+++ /dev/null
@@ -1,73 +0,0 @@
-<?php
-/**
- * Copyright (c) 2012, Agence Française Informatique (AFI). All rights reserved.
- *
- * BOKEH is free software; you can redistribute it and/or modify
- * it under the terms of the GNU AFFERO GENERAL PUBLIC LICENSE as published by
- * the Free Software Foundation.
- *
- * There are special exceptions to the terms and conditions of the AGPL as it
- * is applied to this software (see README file).
- *
- * BOKEH 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 AFFERO GENERAL PUBLIC LICENSE for more details.
- *
- * You should have received a copy of the GNU AFFERO GENERAL PUBLIC LICENSE
- * along with BOKEH; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301  USA 
- */
-/*
- * FONCTIONS DE TRAITEMENTS REPERTOIRES ET FICHIERS
- */
-
-// Lit le contenu entier d'un fichier
-function lire_fichier( $fic)
-{
-  @$handle = fopen( $fic, "r") or erreur_admin( "Impossible d'ouvrir le fichier : " .$fic );
-  $data=fread ($handle, filesize ($fic));
-  fclose($handle);
-  return $data;
-}
-
-// Lit un fichier en éliminant les lignes vides et les commentaires
-function lire_fichier_ressource( $fic )
-{
-  $lig = @file( $fic ) or erreur_admin( "Impossible d'ouvrir le fichier : " . $fic);
-  for( $i = 0; $i < count($lig); $i++)
-  {
-    $lig[$i] = trim($lig[$i]);
-    if( ! $lig[$i] or strLeft( $lig[$i],2 ) == "//") continue;
-    $data .= NL.$lig[$i];
-  }
-  return $data;
-}
-
-// Rend tous les fichiers de tous les dossiers et sous-dossiers d'une racine
-function parse_dossier( $root )
-{
-  if( file_exists($root) == false ) return false;
-  $liste = array();
-  @$dir = opendir( $root) or die("Impossible d'ouvrir le dossier : " .$root);
-  while (($file = readdir($dir)) !== false) 
-  {
-    if( subStr( $file, 0, 1 )!= ".") 
-    {
-      if(filetype($root. "/" .$file) == "dir")
-      {
-        $liste1 = parse_dossier( $root. "/" .$file);
-        $liste = array_merge( $liste, $liste1); 
-      }
-      else
-      {
-        $index = count($liste);
-        $liste[$index][0]= $root;
-        $liste[$index][1]= $file;
-      }
-    }
-  }
-  closedir( $dir);
-  return $liste;
-}
-?>
\ No newline at end of file
diff --git a/library/fonctions/sql.php b/library/fonctions/sql.php
index 8564a2a9c4b..0f36293ac89 100644
--- a/library/fonctions/sql.php
+++ b/library/fonctions/sql.php
@@ -46,27 +46,6 @@ function fetchAll($req, $num=false) {
 }
 
 
-function getWhereSql($conditions) {
-  if (!$conditions)
-    return '';
-
-  if ('string' == gettype($conditions))
-    $conditions = [$conditions];
-
-  $clauses = [];
-  foreach ($conditions as $condition) {
-    if (!$trimmed = trim($condition))
-      continue;
-    $clauses[] = $trimmed;
-  }
-
-  if (0 == count($clauses))
-    return '';
-
-  return ' where ' . implode(' and ', $clauses);
-}
-
-
 function sqlUpdate($req, $data, $force_quote=false) {
   return Zend_Registry::get('sql')->update($req, $data, $force_quote);
 }
@@ -77,10 +56,4 @@ function sqlInsert($table, $data, $force_quote=false) {
 }
 
 
-function getLimitSql($nb_par_page, $page) {
-  if(!$page) $page = 1;
-  $limit = ($page-1) * $nb_par_page;
-  return ' LIMIT ' . $limit . ',' . $nb_par_page;
-}
-
 ?>
\ No newline at end of file
diff --git a/library/fonctions/string.php b/library/fonctions/string.php
index 9f430f8a42c..123c87e2d7d 100644
--- a/library/fonctions/string.php
+++ b/library/fonctions/string.php
@@ -23,16 +23,6 @@
 //
 /////////////////////////////////////////////////////////////////////////////////////
 
-//----------------------------------------------------------------------------------
-// Debug dans un fichier log
-//----------------------------------------------------------------------------------
-function debug_log($chaine,$stop=false)
-{
-  $handle=fopen(USERFILESPATH."/debug.log","a");
-  fwrite($handle,$chaine.chr(13).chr(10));
-  fclose($handle);
-  if($stop==true) exit;
-}
 
 //----------------------------------------------------------------------------------
 // Rend une variable admin
@@ -61,16 +51,6 @@ function getVarListeCosmogramme($clef)
   return $liste;
 }
 
-//----------------------------------------------------------------------------------
-// Affichage d'un tableau pour debugging
-//----------------------------------------------------------------------------------
-function dump_array( $tableau)
-{
-  print( "<br><br><big><b>Tableau</b></big>");
-  print("<br><br><pre>");
-  print_r($tableau);
-  print("</pre><br><br>");
-}
 
 //----------------------------------------------------------------------------------
 // Formattage de date
@@ -152,20 +132,6 @@ function strScan( $chaine, $cherche, $posDeb = 0)
   return -1;
 }
 
-function strScanReverse( $chaine, $cherche, $pos ) {
-
-  $chaine = convertFromUtf8($chaine);
-  $cherche = convertFromUtf8($cherche);
-
-  $len = strLen($cherche);
-  if( $pos == -1 )
-    $pos = strLen($chaine);
-  for( $i=$pos; $i>=0; $i-- ) {
-    if( substr( $chaine, $i, $len ) == $cherche )
-      return $i;
-  }
-  return -1;
-}
 
 // Cherche une valeur dans un tableau et renvoie l'indice sinon -1
 function array_find( $tableau, $valeur )
-- 
GitLab