diff options
author | Phie <phie@phie.ovh> | 2020-05-06 23:46:02 +0300 |
---|---|---|
committer | Phie <phie@phie.ovh> | 2020-05-06 23:46:02 +0300 |
commit | a6969ce2d95e7f43f7ab8699a33a07ee8522baa0 (patch) | |
tree | dcd82a19c68a65680e2e60ace544b1e0408496c2 | |
parent | 797d145ce0fff50f7c8b7941e392806b162939c2 (diff) |
forgotten filev0.21.1stable-0.21.1
m--------- | templates/CarnetElectron | 0 | ||||
-rw-r--r-- | templates/importer.php | 44 |
2 files changed, 44 insertions, 0 deletions
diff --git a/templates/CarnetElectron b/templates/CarnetElectron -Subproject c85400af3d1f774ba2c02c1a84d5bf922c9e0e2 +Subproject 5f3dbc65aa1e8ac1f5eb57e6fed3de1b1d21407 diff --git a/templates/importer.php b/templates/importer.php new file mode 100644 index 0000000..bf04ae9 --- /dev/null +++ b/templates/importer.php @@ -0,0 +1,44 @@ +<?php +global $currentpath; +global $root; +global $appVersion; +$appVersion = $_['app_version']; +$currentpath = __DIR__."/CarnetElectron/"; +$root = \OCP\Util::linkToAbsolute("carnet","templates"); +$root = parse_url($root, PHP_URL_PATH); + +$file = file_get_contents($currentpath."importer/importer.html"); +$file = preg_replace_callback('/<link(.*?)href=\"(.*?\.css(?:\?.*?)?)"/s',function ($matches) { + global $currentpath; + global $appVersion; + global $root; + return "<link".$matches[1]."href=\"".$matches[2]."?v=".$appVersion."\""; +}, $file); +$file = str_replace("href=\"","href=\"".$root."/CarnetElectron/importer/",$file); + +$file = preg_replace_callback('/<script(.*?)src=\"(.*?\.js(?:\?.*?)?)"/s',function ($matches) { + global $currentpath; + global $fullscreen; + global $appVersion; + global $root; + + return "<script".$matches[1]."src=\"".$root."/CarnetElectron/importer/".$matches[2]."?v=".$appVersion."\""; +}, $file); +// token is needed to pass the csfr check +$file .= "<span style=\"display:none;\" id=\"token\">".$_['requesttoken']."</span>"; + + +$file .= "<script src=\"".$root."/CarnetElectron/compatibility/nextcloud/fullscreen.js?v=".$appVersion."\"></script>"; + +$file = str_replace("<!ROOTPATH>", $root."/CarnetElectron/", $file); +$root = substr(__DIR__, strlen($_SERVER['DOCUMENT_ROOT'])); +$urlGenerator = \OC::$server->getURLGenerator(); +$file = str_replace("<!ROOTURL>", $root."/CarnetElectron/", $file); +if (method_exists(\OC::$server, "getContentSecurityPolicyNonceManager")){ + $nonce = \OC::$server->getContentSecurityPolicyNonceManager()->getNonce(); + $file = str_replace("src=\"","defer nonce='".$nonce."' src=\"",$file); +} +$file = str_replace("<!APIURL>", parse_url($urlGenerator->linkToRouteAbsolute("carnet.page.index"), PHP_URL_PATH), $file); +echo $file; + +?>
\ No newline at end of file |