A while back I asked how to open a file in actionscript to supply information for my flash banner.
It works nicely when I just open the flash file on my computer, but when I upload it to my website it does not show the data from the remote text file...
I know that the file reading bit of the program is correct, as it reads local files on the same web server just fine. So I assume it has something to do with either PHP or the FlashPlayer.
Thanks for any help you can give me!
===
How stupid of me to forget to mention that the file being loaded is from a remote server.
Thus the path to it is an actual URL. As I said this works fine on the computer regardless of whether the file is local or a remote file.
But on the PHP webserver it only wants to read the local files, it doesn't Read the Remote ones...
===Update
I've tried the crossdomain.xml solution, but it seems not to be working.
The banner is located on the actual webserver (http://forum.mydomainhere.com/)
while the text file is located at:
http://files.mydomainhere.com/ - this is a DNS reference to my file server.
The xml file i created looks like:
<?xml version="1.0"?>
<!DOCTYPE cross-domain-policy SYSTEM "http://www.macromedia.com/xml/dtds/cross-domain-policy.dtd">
<cross-domain-policy>
<allow-access-from domain="www.forum.mydomainhere.com/" />
</cross-domain-policy>
As it said I put it on the http://files.mydomainhere.com/ server.
==
EDIT
I changed the www. simply to a * which made it work. That's when I removed the www. bit and it still works like a charm. my quess is my forum doesn't work at www. but just a http://
Thanks for all the help people :)
You're probably having a path issue, meaning Flash can't find the specified file. Flash loads external files starting from its containing page location, eg: the PHP page that contains it, not where the SWF is located.
Further, path may be handled differently on the web server than on the local file system. If you are using relative paths, try adding "./" onto the path, or removing "./" if it is already there.
If you are using absolute paths, make sure the path is in the same domain as the SWF. If the browser is at http://www.mysite.com but Flash is loading the file from http://mysite.com (no www) it is actually in a different security domain, and outside of your sandbox. Make sure they are the same.
If you post some more details, we'll be better able to identify your problem.
I hope that helps,
Edit
Based on comment below, you need a cross domain file on the other server. Lots of info on the web about those, start here for a good guide: http://kb2.adobe.com/cps/142/tn_14213.html
SWF's have different security rules based on where you are running them, when you are debugging through one of the IDE's the security settings are very relaxed.
Related
I've got a legacy PHP project to fix a thing or two. I've downloaded it via FileZilla and served it on my local machine with a local copy of the database. The project is exactly the same with the live one, yet the live one can open the url/contact.html but on my machine it says no such file is found. All other pages go for url/categories/ or url/products/ so I've tried altering the url but no use.
All the other pages within the site are simple: one .php controller one .php model and one .tpl smarty template view. Requiring no .html at all. But this one is somehow different. The .htaccess file is exactly the same as the live version. I've tried adding a rewrite rule to direct every .html to .php but didn't work. I'm lost and out of options, please help? It doesn't even have to be an answer,"Try looking into that" would work too.
I'm working via XAMPP on windows, and I've configured the https:// to http:// on my project but that's all. Even hidden files are checked and confirmed.
have checked that contact.html is a static file (like a real existing html file?)
is there some kind of "routing" within the PHP of the project? If there is route urls might be really anyware.. in the mysql database, redis, a json file and whatnot.. have seen them all.
try to debug where and how it works on the "production" server by using some logging to a file edit the file through filezilla and log to a 'mylog.log' file until you find out what is going on.. or if the site is not used all the time by clients - you can just try to echo stuff to figure out how this exact /contact.html works
I'm loading a html file hosted on the OS X built in Apache server, within that file I am linking to another html file in the same directory as follows:
<a href="2ndFile.html"><button type="submit">Local file</button>
This works. However (for reasons too lengthy to go into) I am experimenting using the file: scheme instead, however I cannot get anything to work. Here is how I am re-writing the above line using file:
<a href="file://192.168.1.57/~User/2ndFile.html"><button type="submit">Local file</button>
(192.168.1.57 is my current IP address)
Changing it to the following does also not work:
<a href="file://Name-Of-MacBookPro/~User/2ndFile.html"><button type="submit">Local file</button>
But the file cannot be found, how should it be specified using the file: scheme?
The file: URL scheme refers to a file on the client machine. There is no hostname in the file: scheme; you just provide the path of the file. So, the file on your local machine would be file:///~User/2ndFile.html. Notice the three slashes; the hostname part of the URL is empty, so the slash at the beginning of the path immediately follows the double slash at the beginning of the URL. You will also need to expand the user's path; ~ does no expand in a file: URL. So you would need file:///home/User/2ndFile.html (on most Unixes), file:///Users/User/2ndFile.html (on Mac OS X), or file:///C:/Users/User/2ndFile.html (on Windows).
Many browsers, for security reasons, do not allow linking from a file that is loaded from a server to a local file. So, you may not be able to do this from a page loaded via HTTP; you may only be able to link to file: URLs from other local pages.
the "file://" url protocol can only be used to locate files in the file system of the local machine. since this html code is interpreted by a browser, the "local machine" is the machine that is running the browser.
if you are getting file not found errors, i suspect it is because the file is not found. however, it could also be a security limitation of the browser. some browsers will not let you reference a filesystem file from a non-filesystem html page. you could try using the file path from the command line on the machine running the browser to confirm that this is a browser limitation and not a legitimate missing file.
The 'file' protocol is not a network protocol. Therefore file://192.168.1.57/~User/2ndFile.html simply does not make much sense.
Question is how you load the first file. Is that really done using a web server? Does not really sound like. If it is, then why not use the same protocol, most likely http? You cannot expect to simply switch the protocol and use two different protocols the same way...
I suspect the first file is not really loaded using an apache http server at all, but simply by opening the file? href="2ndFile.html" simply works because it uses a "relative url". This makes the browser use the same protocol and path as where he got the first (current) file from.
I had similar issue before and in my case the file was in another machine
so i have mapped network drive z to the folder location where my file is
then i created a context in tomcat
so in my web project i could access the HTML file via context
For apache look up SymLink or you can solve via the OS with Symbolic Links or on linux set up a library link/etc
My answer is one method specifically to windows 10.
So my method involves mapping a network drive to U:/ (e.g. I use G:/ for Google Drive)
open cmd and type hostname (example result: LAPTOP-G666P000, you could use your ip instead, but using a static hostname for identifying yourself makes more sense if your network stops)
Press Windows_key + E > right click 'This PC' > press N
(It's Map Network drive, NOT add a network location)
If you are right clicking the shortcut on the desktop you need to press N then enter
Fill out U: or G: or Z: or whatever you want
Example Address: \\LAPTOP-G666P000\c$\Users\username\
Then you can use <a href="file:///u:/2ndFile.html"><button type="submit">Local file</button> like in your question
related: You can also use this method for FTPs, and setup multiple drives for different relative paths on that same network.
related2: I have used http://localhost/c$ etc before on some WAMP/apache servers too before, you can use .htaccess for control/security but I recommend to not do so on a live/production machine -- or any other symlink documentroot example you can google
I have been using "Delphi PHP XE2". The file structure has worked fine for over a year on the development machine and the production.
The folders are organised as follows.
src/app_login.php
src/add
src/css
src/js
src/fnc
src/db
src/images
etc.
I am just trying out PHPSTORM. The include files work fine. When I run it in Firefox it can find all images, JavaScript files, etc. But it can not find the CSS files as it is looking for them in
css
rather than
src/css
I haven't changed anything.
Why is the browser now looking at absolute path rather than relative?
How did PHPStorm manage to tell it that?
And how do I coerce it to treat them as relative paths?
I see that in the browser it runs it as:
http://localhost:63342/SRC/app_login.php
instead of
http://localhost:63342/app_login.php
I guess this the problem. How do I coerce it to move down one directory level?
I am trying to set up IIS, I think this might be best for later on. Here are the screen shots:
I configured the hosts file so that when I type wys.com in the browser it tries to run it and shows a blank page. If I type in 192.168.1.0 it just shows a blank page. View Source shows nothing. I was expecting it to run the index.html at d:\wys\src. Why is the browser not running it?
You are using PhpStorm's own simple built-in web server which uses URLs like http://localhost:63342/ProjectName/app_login.php. You cannot make http://localhost:63342/app_login.php using such server as it will not be able to tell what files to serve.
Either use your own Apache/IIS/whatever web server .. or the best you can get with built-in server would be http://ProjectName:63342/app_login.php(IDE needs to know what site/files to serve somehow). For that:
Edit your hosts file (or local DNS server, if preferred and have one) and point ProjectName to your computer's IP (e.g. 127.0.0.1).
Create Deployment entry of correct type (In Place should do), configure it (provide desired URL etc -- http://ProjectName:63342/) and mark it as Default for this project -- now IDE will use URL from there when generating "open in browser" URLs.
I am developing a website on php, I have installed wamp on my personal computer and my website files are in the www folder of wamp.
now considering www as my root folder i have a template folder in the root folder and header.inc.html file in the template folder. when I try to include this header.inc.html file in any other php file using an absolute path include('/template/header.inc.html'); it gives me error "Failed to open stream: No such file or directory", but when I create a simple html link using the same absolute path it works perfectly and opens the file. below is my test code
<?php
echo 'headerfile';
include('/template/header.inc.html');
?>
if I give the full path for example C:/wamp/www/template/header.inc.html to the include function it works fine.
I am confused that this problem is occurring on my wamp server only and it would work perfectly on any webhost server, or maybe the same problem will exist on a webhost
I would appreciate any help that would clarify my confusion, Thanks.
Absolute paths on the server start from the server's hard disk (C:\).
Absolute paths on the client start from the root of the website (http://example.com/).
You can make use of __DIR__ to make some file on disk relative to the php-file on disk itself:
include(__DIR__.'/template/header.inc.html');
This should solve your issue.
The difference is not that easy to explain because both types of paths - even related - are two pair of shoes. I suggest you start with a very basic HTML website tutorial that explains how to link on your website and where files are located and how that is related to the webserver configuration.
HTML pages live in the client's browser that know nothing about your server's folder structure, and they're relative to the domain name eg. http://example.com/.
PHP programs run on the server side and they deal with the server folders. You shouldn't hardcode full paths in your php programs, because it will cause problems whenever you'll move them between the development server and the live host (just to name an example). Therefore in php files you should either use relative paths to your file, or use the __DIR__ magic constant that gets substituted with the directory where the php file is.
1.) First approach: include('template/header.inc.html');
2.) Second approach: include(__DIR__ .'/template/header.inc.html');
In your case (working on a development machine) both the client and the server is the same box, that might be confusing you.
This may be a really stupid question...I started worrying last night that there might be someway to view PHP files on a server via a browser or someother means on a client machine.
My worry is, I have an include file that contains the database username and password. If there were a way to put the address of this file in to a browser or some other system and see the code itself then it would be an issue for obvious reasons.
Is this a legitimate concern?
If so how do people go about preventing this?
Not if your server is configured right. I think discussion on how that is done belongs on serverfault.
To add on to the other answers:
If you use a file extension like .inc there's indeed a higher risk. Can you open the file directly in your browser?
The most important advice is missing:
Only the files that should be accessed by a browser, should be in a publicly accessible location. All the other code (and configuration) should be in a completely separate directory.
For example
root
- webroot
- includes
- config
Only 'webroot' is exposed by your webserver (apache). Webroot can for example contain a single index.php, along with all your assets (javascript, css, images).
Any code index.php needs to load comes from 'includes' and all the configuration from 'config'. There's no way a user could ever directly access anything from those 2 directories, provided this is done correctly.
This depends on the file extension you have given the include file.
If the extension is one that is known and executed by the web server, it will be protected. If you browse to the file, the server will try to execute the code rather than just returning it as plain text.
If the extension is not known by the web server it will serve it as plain data, so anyone (who can guess the file name) can browse to the file and see the source code.
A Directory Traversal Vulnerability can used to obtain files off of the remote mahine. Alternatively you can use MySQL based sql injection to read files using load_file(). You can also test your system with w3af's urlfuzzer which will look for "backup files", such as index.php.zip. Also make sure that all files have .php extensions, a .inc can be viewed from the public. I would also disable Apache directory listing.
Normally there should be no way to view the PHP files remotely... it would be absolutely pointless. This completely depends on what web server you are using and how it's setup though.
Having looked around I can see that it is possible to protect a directory via the .htaccess by adding these lines:
Order allow,deny
Deny from all
This apparently protects the directory so that only local non web-access is possible.
This allows me to keep my includes in a subdirectory of the main site directory which is good for organisation and it can be used on the projects where I do not have access to folders outside the web root.
Does anyone else use this method?
Just for good measure I've put the directory permissions to execute only.
And the include extension is PHP as suggested by others.