PHP include outside url - url

When trying to include a php file into another it either does nothing at all (no errors). If i require it will give a useless message
"Failed opening required 'http://example.org.com/xxx.php' (include_path='.:/usr/local/php5/lib/php')
<div id="menu"> <?php include("http://www.sitename.com/menu.php") ?> </div>
The file im trying to include is on the same site and host.
The page im including from is:
root/wiki/skin/index.php (mediawiki)
menu.php is located:
root/menu.php
since mediawiki treats the /wiki/ path as the root i cannot back out with ../../ etc.
What am i doing wrong here? Thanks

Sir, try this:
<div id="menu"> <?php include("../../menu.php") ?> </div>

To include URLs in your PHP project you must have enabled (true) this option:
allow_url_include
in your php.ini configuration. More information you can find here:
http://php.net/manual/en/filesystem.configuration.php#ini.allow-url-include

Related

NodeMCU enduser setup module html file that creates another file

I have created my own enduser_setup.html file nodemcu(for the enduser setup module: https://nodemcu.readthedocs.io/en/master/en/modules/enduser-setup/#enduser_setupstart).
I have added another field (beyond the ssid\password fileds):
<input id=result1 type=text autocorrect=off autocapitalize=none placeholder='Place ID' />
I want on submit to create a lua file (result1.lua) with the Get result of this field.
Tried with php:
<?php
$myfile = fopen("result1.lua", "w") or die("Unable to open file!");
$txt = $_GET["result1"];
fwrite($myfile, $txt);
fclose($myfile);
?>
Did not work :(
That is currently not possible with NodeMCU. However, there is a pending pull request that'll add this feature. It's likely going to be merged to the dev branch in the next days.

Dropwizard Assets not serving static content outside of root path

Here's my Dropwizard (0.8.5) app's basic project structure:
myapp/
src/main/groovy/
org/example/myapp/
MyApp.groovy
<lots of other packages/classes>
controllers/
site/
SiteController.groovy
dashboard/
DashboardController.groovy
org/example/myapp/views
site/
SiteView.groovy
dashboard/
DashboardView.groovy
src/main/resources/
assets/
images/
mylogo.png
org/example/myapp/views/
site/
header.ftl
index.ftl
dashboard/
dashboard.ftl
Where the gist of each of those classes is:
class MyApp extends Application<MyAppConfiguration> {
#Override
void initialize(Bootstrap<MyAppConfiguration> bootstrap) {
bootstrap.addBundle(new AssetsBundle('/assets/images', '/images', null, 'images'))
bootstrap.addBundle(new ViewBundle())
}
// etc...
}
#Path('/')
#Produces('text/html')
class SiteController {
#GET
SiteView homepage() {
new SiteView()
}
}
#Path('/app/dashboard')
#Produces('text/html')
class DashboardController {
#GET
DashboardView dashboard() {
new DashboardView()
}
}
header.ftl (dropwizard-views-freemarker)
=========================================
<!DOCTYPE html>
<html>
<head> <!-- lots of stuff omitted here for brevity --> </head>
<body>
<div class="well">
<img src="images/mylogo.png" />
<br/>This is the header!
</div>
index.ftl
=========
<#include "header.ftl">
<p>
Homepage!
</p>
</body>
</html>
dashboard.ftl
=============
<#include "../site/header.ftl">
<p>
Dashboard!
</p>
</body>
</html>
So you can see I'm using DW as an actual web app/UI, and that I'm utilizing both Dropwizard Views (Freemarker binding) as well as Dropwizard Assets.
When I run this, the app starts up just fine and I am able to visit both my homepage (served from / which maps to index.ftl) as well as my dashboard page (served from /app/dashboard which maps to dashboard.ftl).
The problem is that both pages use the header.ftl, which pulls in my assets/images/mylogo.png, but only my homepage actually renders the logo. On my dashboard page, I do see the "This is the header!" message, so I know the header is being resolved and included with my dashboard template. But, I get a failed-to-load-image "X" icon, and when I open my browser's dev tools I see that I'm getting HTTP 404s on the image.
So it seems that DW is unable to find my image asset from a view/URL not directly living under root (/).
On the Dropwizard Assets page (link provided above) there's a peculiar warning:
Either your application or your static assets can be served from the root path, but not both. The latter is useful when using Dropwizard to back a Javascript application. To enable it, move your application to a sub-URL.
I don't entirely understand what this means, but suspect it is the main culprit here. Either way, anyone see where I'm going awry, and what I can do (exact steps!) to fix this?
You need to add / before your URI:
<img src="/images/mylogo.png" />
this can be explained from the examples in RFC 3986 URI Generic Syntax, I pulled out the relevant examples.
5.4. Reference Resolution Examples
Within a representation with a well defined base URI of
http://a/b/c/d;p?q
a relative reference is transformed to its target URI as follows.
5.4.1. Normal Examples
"g" = "http://a/b/c/g"
"g/" = "http://a/b/c/g/"
"/g" = "http://a/g"
"../g" = "http://a/b/g"
"../../g" = "http://a/g"
Putting in the preceding / makes the URI begin from the domain name regardless of the referring URI, which allows you to do precisely what you want.
Load both pages up (the one that works, and the one that doesn't), and use Firebug or Chrome dev tools to inspect the logo element. What path is it trying to get to? I suspect on your index page it's going to http://some.thing/images/mylogo.png whereas on your dashboard it's trying to load http://some.thing/app/dashboard/images/mylogo.png
Try putting an additional / in front of the path in your template, and it should resolve from anywhere.
(Originally answered here: Dropwizard-user Google Group)

MediaWiki Scribunto extension's "Listen" module not generating expected HTML

I have a MediaWiki installation (1.23) with the Scribunto extension and Module:Listen. I try to invoke this module from an article like so:
{{Listen
|filename = Noise.ogg
|title = Noise
|description = Some noise
}}
This generates the little infobox, but the embedded sound player itself does not appear. I looked at the generated HTML, and the module is just making a second ordinary href to the file:
<div class="haudio">
<div style="padding:2px 0;">Noise</div>
<div style="padding-right:4px;">File:Noise.ogg</div>
<div class="description" style="padding:2px 0 0 0;">Some noise</div></div>
Rather than the second href to the file, I'd expect to see a or similar. Am I missing some template or Lua module?
You need to have TimedMediaHandler installed for the sound player to show up!

Paths with assemble and swig

i have a project running grunt with assemble and swig as the engine for templating. i need to know how to handle paths for my navigation, because i want to store some files in subfolders.
i just found this for assemble: http://assemble.io/helpers/helpers-path.html
but that doesn't work for me, it says "Warning: Unexpected string Use".
anyone knows a solution for that? do you need any further information?
Thanks for your help at first! I found a first solution myself today:
{{ _dirname(page) }} doesn't work either, because dirnameis related to the layout file where I created my navigation. It does work if I use page.dirname.
My code now looks like
<ul class="navigation-level-1">
<li class="item-level-1 {% if basename == "page" %}current{% endif %}">
<a href="{% if dirname != 'root' %}../{% endif %}page.html" class="text-level-1">
Guild
</a>
<ul class="navigation-level-2">
<li class="item-level-2">
subpage
</li>
</ul>
</li>
</ul>
But the Problem with this is, that I cannot get into subpages from other pages if i entered one subpage. I hope someone can understand what i mean :D
I try to visualize:
* Page A
** Subpage A
* Page B
** Subpage B
If I entered Subpage A and I want to visit Subpage B i can't do so because my solution just works if I am on the root, you know?
Any ideas? :)

Textmate with HTML(rails) Problem

I am editing a .html.erb file with HTML(rails) selected at the bottom. When I type if I get:
< ?php if (condition): ? >
< ?php endif ? >
Any ideas?
Cheers
Don't fully understand but when I type:
if and hit TAB, I get PHP instead:
<?php if (condition): ?>
<?php endif ?>
You could create your own ERB snippet for example on IF, TAB:
<% if ${1:value?} %>
${2}
<% end %>
Suggestion: Open your Bundle Editor and delete the PHP bundle in you don't need it. This way, I won't interfere with your ERB templates again.
You probably have an incorrect manual binding for .erb files. To see what manual bindings you have run
defaults read com.macromates.textmate OakLanguageFileBindings
If you want to get rid of all your manual bindings, quit TextMate and run
defaults delete com.macromates.textmate OakLanguageFileBindings
More info here http://blog.macromates.com/2007/file-type-detection-rspec-rails/

Resources