From 673ccbbb7e795069fd3a068e0e6c84b57150766a Mon Sep 17 00:00:00 2001 From: Simone Pigazzini Date: Thu, 1 Sep 2016 09:43:29 +0200 Subject: [PATCH 01/15] Adds jsroot interface when .root link is clicked --- .gitmodules | 3 +++ index.php | 33 +++++++++++++++++++++++---------- jsroot | 1 + 3 files changed, 27 insertions(+), 10 deletions(-) create mode 100644 .gitmodules create mode 160000 jsroot diff --git a/.gitmodules b/.gitmodules new file mode 100644 index 0000000..76bb828 --- /dev/null +++ b/.gitmodules @@ -0,0 +1,3 @@ +[submodule "jsroot"] + path = jsroot + url = git@github.com:linev/jsroot.git diff --git a/index.php b/index.php index f7965f3..e257273 100644 --- a/index.php +++ b/index.php @@ -179,16 +179,29 @@ function matchall($match,$name) { return true; } // print ""; print ""; // print ""; - foreach ($other_exts as $ex) { - $other_filename = $path_parts['filename'].$ex; - if (file_exists($other_filename)) { - if ($ex != '.txt') { - array_push($others, "[" . $ex . "]"); - array_push($displayed, $other_filename); - } else { + foreach ($other_exts as $ex) { + $other_filename = $path_parts['filename'].$ex; + if (file_exists($other_filename)) { + switch ($ex) { + case '.txt': $text = file_get_contents($other_filename); - array_push($others, "[" . $ex . "]". $text .""); - + array_push($others, "[" . $ex . "]". $text .""); + break; + case '.root': + $pruned_uri = $_SERVER['REQUEST_URI']; + if( $_SERVER['QUERY_STRING'] ) { + $pos = strpos($_SERVER['REQUEST_URI'], $_SERVER['QUERY_STRING']); + $pruned_uri = substr($_SERVER['REQUEST_URI'],0,$pos-1); + } + $folder = str_replace($_SERVER['DOCUMENT_ROOT'],"", + str_replace("index.php","",$pruned_uri) + ); + array_push($others, "[" . $ex . "]"); + array_push($displayed, $other_filename); + break; + default : + array_push($others, "[" . $ex . "]"); + array_push($displayed, $other_filename); } } } @@ -202,7 +215,7 @@ function matchall($match,$name) { return true; }

Other files

From 23be03c5d19d53a783b102c74ada913ce18774aa Mon Sep 17 00:00:00 2001 From: Simone Pigazzi Date: Thu, 19 Nov 2020 17:59:03 +0100 Subject: [PATCH 07/15] Update to Apache 2.4 + removing hardcoded jsroot path --- index.php | 28 +++++++--------------------- 1 file changed, 7 insertions(+), 21 deletions(-) diff --git a/index.php b/index.php index 3b7f75e..21cef6a 100644 --- a/index.php +++ b/index.php @@ -7,18 +7,12 @@ function isRegex($str0) { } function matchall($match,$name) { return true; } +$jsroot_instance = "/jsroot/index.htm"; $pruned_uri = $_SERVER['REQUEST_URI']; -if( $_SERVER['QUERY_STRING'] ) { - $pos = strpos($_SERVER['REQUEST_URI'], $_SERVER['QUERY_STRING']); - $pruned_uri = substr($_SERVER['REQUEST_URI'],0,$pos-1); -} -$folder = str_replace($_SERVER['DOCUMENT_ROOT'],"", - str_replace("index.php","",$pruned_uri) - ); -$script_path = str_replace($_SERVER['DOCUMENT_ROOT'],"",dirname($_SERVER["SCRIPT_FILENAME"])); -$target_folder = str_replace($script_path,getcwd(),$folder); -$script_path = str_replace("//","/","/".$script_path); -chdir( $target_folder ) +$folder = str_replace($_SERVER['DOCUMENT_ROOT'], "", str_replace("index.php","",$pruned_uri)); +$target_folder = substr_replace($pruned_uri, $_SERVER['CONTEXT_DOCUMENT_ROOT'], 0, strlen($_SERVER['CONTEXT_PREFIX'])); +$script_path = substr_replace(dirname($_SERVER["SCRIPT_FILENAME"]), $_SERVER['CONTEXT_PREFIX'], 0, strlen($_SERVER['CONTEXT_DOCUMENT_ROOT'])); +chdir( $target_folder ) ?> " /> @@ -188,15 +182,7 @@ function matchall($match,$name) { return true; } array_push($others, "[" . $ex . "]". $text .""); break; case '.root': - $pruned_uri = $_SERVER['REQUEST_URI']; - if( $_SERVER['QUERY_STRING'] ) { - $pos = strpos($_SERVER['REQUEST_URI'], $_SERVER['QUERY_STRING']); - $pruned_uri = substr($_SERVER['REQUEST_URI'],0,$pos-1); - } - $folder = str_replace($_SERVER['DOCUMENT_ROOT'],"", - str_replace("index.php","",$pruned_uri) - ); - array_push($others, "[" . $ex . "]"); + array_push($others, "[" . $ex . "]"); array_push($displayed, $other_filename); break; default : @@ -230,7 +216,7 @@ function matchall($match,$name) { return true; } else { if( fnmatch("*.root", $filename) ) { - print "

  • $filename
  • "; + print "
  • $filename
  • "; } else { print "
  • $filename
  • "; From a3c3604038612b8bb9a67937b62221706394b88f Mon Sep 17 00:00:00 2001 From: Simone Pigazzi Date: Thu, 19 Nov 2020 18:04:41 +0100 Subject: [PATCH 08/15] Update jsroot --- jsroot | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/jsroot b/jsroot index 4cf8fee..9606f26 160000 --- a/jsroot +++ b/jsroot @@ -1 +1 @@ -Subproject commit 4cf8feebd5338c7754ac8c971ae47725519404d8 +Subproject commit 9606f26b3aebfdc69b2af76d842c5331b8dcc970 From 42f4b08708127a8058608290728249ac97b59dbf Mon Sep 17 00:00:00 2001 From: Simone Pigazzi Date: Thu, 19 Nov 2020 18:10:21 +0100 Subject: [PATCH 09/15] Update htaccess and readme --- README.md | 4 +-- example/htaccess | 71 +++++++++++++++++++++++++++++++++++------------- 2 files changed, 54 insertions(+), 21 deletions(-) diff --git a/README.md b/README.md index 02788e6..d672e0b 100644 --- a/README.md +++ b/README.md @@ -17,14 +17,14 @@ It is tailored to people working in High Energy Physics that use ROOT (http://ro 1. Clone this repository (and its submodule jsroot) - git clone --recursive https://github.com/musella/php-plots.git . + git clone --recursive https://github.com/simonepigazzini/php-plots.git 1. Copy the example/htaccess file into .htaccess and edit its content to suit your needs. cp -p example/htaccess .htaccess $EDITOR .htacces -1. Copy res/ jsroot/ and index.php into your web page top directory. +1. Copy res/ jsroot/ and index.php into your web page top directory. cp -r res/ /path/to/www/ cp -r jsroot/ /path/to/www/ diff --git a/example/htaccess b/example/htaccess index e39b9d0..30d5f52 100644 --- a/example/htaccess +++ b/example/htaccess @@ -1,23 +1,56 @@ -## CERN Signle sign-on -## Uncomment if you want to restrict the access to your files +# *** This htaccess file has been modified automatically on November 16, 2020 *** +# Due to the end-of-life of SLC6 and Apache 2.2, web sites get migrated to a new infrastructure running +# CC7 and Apache 2.4. There are incompatible differences in web site configuration between these two versions. +# Because this htaccess file contained such incompatibilities, it has been modified in a way that works on both +# old and new infrastructures during the transition period (October-November 2020). +# See https://cern.service-now.com/service-portal/?id=outage&n=OTG0059516 # -# ShibRequireAll On -# ShibRequireSession On -# ShibExportAssertion On -# SSLRequireSSL -# AuthType Shibboleth -# -# SSLVerifyClient optional -# SSLVerifyDepth 5 -# SSLOptions +StrictRequire -# -# # Authorized group -# Require adfs-group "cms-private" - -## END CERN SSO +# *** If you need to modify this file during the transition period, make sure to apply your changes to both sections +# below. The site owner received an email with instructions to validate the web site configuration in the new +# infrastructure. *** + += 2.3> +# This section contains the Apache configuration directives used in the new webeos infrastructure running +# Apache 2.4 on CC7 + +Options +Indexes + +AuthType openid-connect +Require claim cern_roles:view-site-root + +## Tell Apache this is the web index +## +DirectoryIndex index.php index.html index.htm /spigazzi/index.php + + + + + +# This section contains the Apache configuration directives used in the legacy webeos infrastructure running +# Apache 2.2 on SLC6 +# It can be removed after December 2020 when https://cern.service-now.com/service-portal/?id=outage&n=OTG0059516 is complete. + +Options +Indexes + + + +ShibRequireAll On + +ShibRequireSession On + +ShibExportAssertion On + +SSLRequireSSL # The modules only work using HTTPS + +AuthType Shibboleth + + + +Require adfs-group "cms-physics" ## Tell Apache this is the web index ## -# Put below the path to your index.php (starting from the server root) -# eg /musella/higgs/index.php -DirectoryIndex index.php index.html index.htm ///index.php +DirectoryIndex index.php index.html index.htm /spigazzi/index.php + + + From f90d09b5423334e7f5259a399e70fe529558b5b8 Mon Sep 17 00:00:00 2001 From: Simone Pigazzi Date: Fri, 4 Dec 2020 09:38:23 +0100 Subject: [PATCH 10/15] Fix html queries using strtok --- index.php | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/index.php b/index.php index 21cef6a..f8f3a71 100644 --- a/index.php +++ b/index.php @@ -8,7 +8,7 @@ function isRegex($str0) { function matchall($match,$name) { return true; } $jsroot_instance = "/jsroot/index.htm"; -$pruned_uri = $_SERVER['REQUEST_URI']; +$pruned_uri = strtok($_SERVER['REQUEST_URI'], '?'); $folder = str_replace($_SERVER['DOCUMENT_ROOT'], "", str_replace("index.php","",$pruned_uri)); $target_folder = substr_replace($pruned_uri, $_SERVER['CONTEXT_DOCUMENT_ROOT'], 0, strlen($_SERVER['CONTEXT_PREFIX'])); $script_path = substr_replace(dirname($_SERVER["SCRIPT_FILENAME"]), $_SERVER['CONTEXT_PREFIX'], 0, strlen($_SERVER['CONTEXT_DOCUMENT_ROOT'])); @@ -88,9 +88,8 @@ function matchall($match,$name) { return true; } ?>

    Plots

    -

    Filter: - +

    Filter: +

    From 13f5d39aea58a58202bb129d62b33019588bd613 Mon Sep 17 00:00:00 2001 From: Simone Pigazzi Date: Wed, 23 Jun 2021 15:09:42 +0200 Subject: [PATCH 11/15] display link to html version of each plot (compatibility with plotly) --- index.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/index.php b/index.php index f8f3a71..28ce8cf 100644 --- a/index.php +++ b/index.php @@ -113,7 +113,7 @@ function matchall($match,$name) { return true; } if ($_GET['noplots']) { print "Plots will not be displayed.\n"; } else { - $other_exts = array('.pdf', '.cxx', '.eps', '.ps', '.root', '.txt', ".C"); + $other_exts = array('.pdf', '.cxx', '.eps', '.ps', '.root', '.txt', ".C", '.html'); $main_exts = array('.png','.gif','.jpg','.jpeg'); $folders = array('*'); if( intval($_GET['depth'])>1 ) { From a9403d15d08f7d3ffcc3d0fa5750138b5d740a3c Mon Sep 17 00:00:00 2001 From: Simone Pigazzi Date: Wed, 23 Jun 2021 15:13:38 +0200 Subject: [PATCH 12/15] update jsroot --- jsroot | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/jsroot b/jsroot index 9606f26..cde67e9 160000 --- a/jsroot +++ b/jsroot @@ -1 +1 @@ -Subproject commit 9606f26b3aebfdc69b2af76d842c5331b8dcc970 +Subproject commit cde67e98f870a194697c057b158e55e0f9dc9441 From 16708109fbaa43491f67a10df7a749e9175cce7b Mon Sep 17 00:00:00 2001 From: Simone Pigazzi Date: Wed, 23 Jun 2021 15:18:16 +0200 Subject: [PATCH 13/15] Readme update (jsroot and plotly) --- README.md | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index d672e0b..7e91a74 100644 --- a/README.md +++ b/README.md @@ -47,6 +47,7 @@ It is tailored to people working in High Energy Physics that use ROOT (http://ro 1. Overlay content of .txt version on mouse hover. -# Example +1. Display root files using [JSROOT](https://root.cern.ch/js/) + +1. Display html interactive plots generated with [plotly](https://plotly.com/) -https://musella.web.cern.ch/musella/php-plots From 80f07061764280a20977c9a347110cf60b0a3acd Mon Sep 17 00:00:00 2001 From: Simone Pigazzini Date: Fri, 27 Oct 2023 15:30:24 +0200 Subject: [PATCH 14/15] PHP > 7 --- index.php | 81 +++++++++++++++++++++++++++++++++++++++++++++++-------- 1 file changed, 70 insertions(+), 11 deletions(-) diff --git a/index.php b/index.php index 28ce8cf..b3bad5e 100644 --- a/index.php +++ b/index.php @@ -1,4 +1,4 @@ - + ",$closetag="") +{ + $ret = ""; + if ( $opentag != "" ) $ret .= $opentag; + $encurl = $url; + $ret .= "[$name]"; + if ( $closetag != "" ) $ret .= $closetag; + return $ret; +} + +function resource($url,$name) +{ + return bookmark($url, $name, "_blank", "", ""); +} + + +/** + * Reads a list of links from a file and renders them. + * + * The expected file format is + * url && linkname + */ +function get_bookmarks($filename,$target="_blank",$rowlen=12,$opentable="",$closetable="
    ",$openrow="",$closerow="",$opencell="",$closecell="") +{ + $file = file_get_contents($filename); + $bookmarks=split("\n",$file); + + $ret = $opentable; + $n = 1; + foreach( $bookmarks as $bm ) { + if( $bm == "" ) { continue; } + list($url,$name) = split("[ ]*&&[ ]*",$bm); + if( ! empty($url) ) { + if( $rowlen > 0 && $n % $rowlen == 1 ) { $ret .= $openrow; } + $ret .= bookmark( $url, $name, $target, $opencell, $closecell ); + if( $rowlen > 0 && $n % $rowlen == 0 ) { $ret .= $closerow; } + $n++; + } + } + if( $rowlen > 0 && $n % $rowlen != 1 ) { $ret .= $closerow; } + $ret .= $closetable; + return $ret; +} + $jsroot_instance = "/jsroot/index.htm"; $pruned_uri = strtok($_SERVER['REQUEST_URI'], '?'); $folder = str_replace($_SERVER['DOCUMENT_ROOT'], "", str_replace("index.php","",$pruned_uri)); $target_folder = substr_replace($pruned_uri, $_SERVER['CONTEXT_DOCUMENT_ROOT'], 0, strlen($_SERVER['CONTEXT_PREFIX'])); $script_path = substr_replace(dirname($_SERVER["SCRIPT_FILENAME"]), $_SERVER['CONTEXT_PREFIX'], 0, strlen($_SERVER['CONTEXT_DOCUMENT_ROOT'])); chdir( $target_folder ) + ?> " /> @@ -55,15 +103,9 @@ function matchall($match,$name) { return true; } [parent] "; ?> 0; if ($has_subs) { print "
    \n"; @@ -74,6 +116,7 @@ function matchall($match,$name) { return true; } print " (hide plots in subfolders)\n"; } print "\n"; + rsort($folders); foreach ($folders as $filename) { print " [$filename]"; } @@ -85,6 +128,22 @@ function matchall($match,$name) { return true; } print "
    \n"; readfile($readme); print "
    "; } } + +$bookm=""; +foreach (array("bookmarks.txt") as $bm) { + if (file_exists($bm)) { + if( $bookm == "" ) { + $bookm .= '

    Bookmarks

    '; + } + $bookm .= get_bookmarks($bm,"",10,"","","","
    ","",""); + } +} +if( $bookm != "" ) { + print "
    \n"; + print $bookm; + print "
    "; +} + ?>

    Plots

    @@ -153,7 +212,7 @@ function matchall($match,$name) { return true; } if( $skip ) { continue; } array_push($displayed, $filename); $others = array(); - $max=46; + $max=25; $asym=2; $len=strlen($filename); if ($len >= $max) { From b83ff92b29eaa0b55881ad3a8cba00408e32da9b Mon Sep 17 00:00:00 2001 From: Simone Pigazzini Date: Wed, 15 May 2024 15:18:24 +0200 Subject: [PATCH 15/15] fixed matching function and other files section --- index.php | 94 +++++++++++++++++++++++++++++-------------------------- 1 file changed, 49 insertions(+), 45 deletions(-) diff --git a/index.php b/index.php index b3bad5e..1be82bf 100644 --- a/index.php +++ b/index.php @@ -1,11 +1,26 @@

    1 ) { + if( isset($_GET['depth']) && intval($_GET['depth'])>1 ) { $wildc="*"; for( $de=2; $de<=intval($_GET['depth']); $de++ ){ $wildc = $wildc."/*"; @@ -190,8 +199,7 @@ function get_bookmarks($filename,$target="_blank",$rowlen=12,$opentable=" } sort($filenames); foreach ($filenames as $filename) { - if( ! $matchf($match,$filename) ) { continue; } - /// if (isset($_GET['match']) && !fnmatch('*'.$_GET['match'].'*', $filename)) continue; + if( ! matchall($match, $filename) ) { continue; } $path_parts = pathinfo($filename); if (PHP_VERSION_ID < 50200) { $path_parts['filename'] = str_replace('.'.$path_parts['extension'],"",$path_parts['basename']); @@ -255,38 +263,34 @@ function get_bookmarks($filename,$target="_blank",$rowlen=12,$opentable="
    } } ?> - +

    Other files

      -[DIR] $filename"; - } - else - { - if( fnmatch("*.root", $filename) ) { - print "
    • $filename
    • "; - } - else { +[DIR] $filename"; + } else { + if (fnmatch("*.root", $filename)) { + print "
    • $filename
    • "; + } else { print "
    • $filename
    • "; - } - } - } - } - ?> + } + } + } +} +?>
    +

    -Like this page? Get it here.
    +Like this page? Get it here.
    Credits: Giovanni Petrucciani.