A PHP Error was encountered

Severity: 8192

Message: Function create_function() is deprecated

Filename: geshi/geshi.php

Line Number: 4698

Backtrace:

File: /home/httpd/vhosts/scratchbook.ch/geopaste.scratchbook.ch/application/libraries/geshi/geshi.php
Line: 4698
Function: _error_handler

File: /home/httpd/vhosts/scratchbook.ch/geopaste.scratchbook.ch/application/libraries/geshi/geshi.php
Line: 4621
Function: _optimize_regexp_list_tokens_to_string

File: /home/httpd/vhosts/scratchbook.ch/geopaste.scratchbook.ch/application/libraries/geshi/geshi.php
Line: 1655
Function: optimize_regexp_list

File: /home/httpd/vhosts/scratchbook.ch/geopaste.scratchbook.ch/application/libraries/geshi/geshi.php
Line: 2029
Function: optimize_keyword_group

File: /home/httpd/vhosts/scratchbook.ch/geopaste.scratchbook.ch/application/libraries/geshi/geshi.php
Line: 2168
Function: build_parse_cache

File: /home/httpd/vhosts/scratchbook.ch/geopaste.scratchbook.ch/application/libraries/Process.php
Line: 45
Function: parse_code

File: /home/httpd/vhosts/scratchbook.ch/geopaste.scratchbook.ch/application/models/Pastes.php
Line: 517
Function: syntax

File: /home/httpd/vhosts/scratchbook.ch/geopaste.scratchbook.ch/application/controllers/Main.php
Line: 693
Function: getPaste

File: /home/httpd/vhosts/scratchbook.ch/geopaste.scratchbook.ch/index.php
Line: 315
Function: require_once

Untitled - Stikked
From Scanty Duck, 5 Years ago, written in Java.
Embed
  1. package com.savvas.content.analyzer.util;
  2.  
  3. import java.io.File;
  4. import java.io.IOException;
  5. import java.nio.file.Files;
  6. import java.nio.file.Path;
  7. import java.nio.file.Paths;
  8. import java.util.ArrayList;
  9. import java.util.Collection;
  10. import java.util.List;
  11. import java.util.stream.Stream;
  12.  
  13. import org.apache.commons.io.FileUtils;
  14. import org.apache.commons.io.LineIterator;
  15. import org.json.JSONTokener;
  16. import org.slf4j.Logger;
  17. import org.slf4j.LoggerFactory;
  18.  
  19. public class FileUtil {
  20.  
  21.     private static final Logger LOGGER = LoggerFactory.getLogger(FileUtil.class);
  22.  
  23.     /** The Constant ERROR_LOG_MSG_1. */
  24.     private static final String ERROR_LOG_MSG_1 = "Exception: {}";
  25.  
  26.     private FileUtil() {}
  27.  
  28.     public static void readFile(String filePath) throws IOException {
  29.         File file = new File(filePath);
  30.         LineIterator it = FileUtils.lineIterator(file, "UTF-8");
  31.         try {
  32.             while (it.hasNext()) {
  33.                 String line = it.nextLine();
  34.                 LOGGER.debug(line);
  35.             }
  36.         } finally {
  37.             LineIterator.closeQuietly(it);
  38.         }
  39.     }
  40.  
  41.     public static List<String> getDirFileList(String dirPath) {
  42.         List<String> pageXhtmls = new ArrayList<>();
  43.         try (Stream<Path> files = Files.list(Paths.get(dirPath)) ) {
  44.             files.forEach(path -> pageXhtmls.add(path.toString()));
  45.         } catch (IOException e) {
  46.             LOGGER.error(ERROR_LOG_MSG_1, e);
  47.         }
  48.         return pageXhtmls;
  49.     }
  50.  
  51.     public static List<String> getRecursiveDirFileList(String dirPath) {
  52.         List<String> pageXhtmls = new ArrayList<>();
  53.         String[] pattern = {"xhtml", "html"};
  54.         Collection<File> files = FileUtils.listFiles(new File(dirPath), pattern, true);
  55.         files.forEach(path -> pageXhtmls.add(path.toString()));
  56.         return pageXhtmls;
  57.     }
  58.  
  59.     public static Object readFileAsObject(String filename) {
  60.         String content = new String(readFileAsBytes(filename));
  61.         return new JSONTokener(content).nextValue();
  62.     }
  63.    
  64.     public static List<String> readFileAsLines(String filePath) {
  65.         List<String> lines = new ArrayList<>();
  66.         try {
  67.             File f = new File(filePath);
  68.             return FileUtils.readLines(f, "UTF-8");
  69.         } catch (IOException e) {
  70.             e.printStackTrace();
  71.         }
  72.         return lines;
  73.     }
  74.  
  75.     public static String readFileAsString(String filename) {
  76.         return new String(readFileAsBytes(filename));
  77.     }
  78.  
  79.     public static byte[] readFileAsBytes(String filename) {
  80.         byte[] temp = new byte[0];
  81.         try {
  82.             temp = Files.readAllBytes(Paths.get(filename));
  83.         } catch (IOException e) {
  84.             LOGGER.error(ERROR_LOG_MSG_1, e);
  85.         }
  86.         return temp;
  87.     }
  88.  
  89.     public static void createDirectories(String filename) {
  90.         try {
  91.             Path path = Paths.get(filename);
  92.             Files.createDirectories(path.getParent());
  93.         } catch (IOException e) {
  94.             LOGGER.error(ERROR_LOG_MSG_1, e);
  95.         }
  96.     }
  97.  
  98.     public static boolean deleteFile(String filePath) {
  99.         File fileToDelete = FileUtils.getFile(filePath);
  100.         return FileUtils.deleteQuietly(fileToDelete);
  101.     }
  102.  
  103. }
  104.