Hi i am trying to include a webpage link from another website into my website.
how can i do this?
i tried
<?php web_include ('http://website.com/website.html') ; ?>
but all the commands are not loading after this statement. I want to include another webpage into my homepage directly. my homepage is completely designed in php, but the other one is html or php.
i also tried <?php include("http://www.othersite.com/filename.html"); ?> but this html is not at all loading.
Possible Solution:
ok this is what i am using
<iframe name="FRAMENAME" src="http://website.com/dropdown.html" width="1000" style="z-index:10000" height="40" frameborder="0" scrolling="no" allowautotransparency=true></iframe>
I am just including a dropdown menu for my index page. The CMS of the my site is restricting me from viewing the dorpdown in IE. When i view the dropdown.html page, i can see the dropdown, so I am trying to use iframe. Now using the iframe i can see the dropdown in IE as well, but the dropdown is not showing on the top. It is showing behind the other images on the site. How do i get it on top of the other images. z-index is not working for this.
This code requires allow_url_include=On in your php.ini, which is disabled by default because it's REMOTE CODE EXECUTION, one of the worst you can have in PHP. This is called the Remote File Include (RFI) vulnerability. If there is PHP code on this site it will be executed on your server.
Extremely insecure:
<?php include("http://www.othersite.com/filename.html"); ?>
What you probably want is:
<?php print file_get_contents("http://www.othersite.com/filename.html"); ?>
However, this is technically an XSS vulnerability. So, if you trust the website there isn't a problem. But you probably want to run Html Purifer before printing it out.
Just a basic recommendation, but it sounds like you're trying to debug complex functionality within a complex environment, which will only make it harder.
Debugging is easier if you break it down into component steps. In this case, I recommend:
Display the iframe on a blank html page.
Make sure everything works in that simple case.
Display on the more complex page.
If it's still not working, comment out the javascript on the complex page to determine if that is causing the adverse interaction with the iframe page's javascript.
Going through the debuggging stepwise like that should simplify the process.
Related
I have been searching for hours and probably because of my limited java knowledge, I'm a little but stuck..
I'm developing a website and I want to make things as easy to change as possible. I want the users to load the home page, and then by clicking on different buttons, the html "main content" of the page will change accordingly.
My reasoning for this is that I want to keep everything really clean and simple, so that if i want to update the Index page's format, I will only have to update one page..
Im assuming i need java for this..
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Prodigy Doo Design</title>
<link href="template/style.css" rel="stylesheet" type="text/css" />
</head>
<body>
<?php include('template/header.php'); ?>
<div class="pad50px900wide"><!--Padding after headder--></div>
<?php include('template/nav.php'); ?>
<!--*****************************
********* BODY CONTENT***********
******************************-->
<div class="bodyContent"><?php include('text.html'); ?></div>
<!--*****************************
******END OF BODY CONTENT********
******************************-->
<?php include('template/footer.php'); ?>
</body>
The part that is very heavily indicated as the "BODY CONTENT" is the part i want to change.. i was thinking i could somehow say:
if home button click -> include 'home.html'
if about button click -> include 'about.html'
...
...
I just dont know how to put this into code..
you can view what i'v got so far here http://pddtest.webuda.com/ (if you didnt know, when you display the source code for the site in most browsers, it will load reference files as if they were all together in the first place, so it might be easier to understand what im trying to do)
Sorry if I'm a little vague, any help would be really apreciated, iv been crawling the interwebs for ages and i know this is probably fairly simple
I think what you're trying to achieve is a base template, where only the main content changes. Which means editing the base template (or page if you want to call it), edits all the other pages.
For this all you need is some basic PHP, where you send the file name in a GET variable with the response.
About
And wherever your includes are, you just add this variable to the php extension:
<?php include ($file.".php"); ?>
And of course don't forget to check if the variable is in the request.
This is a very basic way, and may not be safe but it's a good application of basic php.
Hope this will help.
You've already got PHP includes happening so that means you're cutting down on the amount up updating needing done to your pages and changing something in your header , footer etc will change it all throughout your site.
It would be better to simply have seperate pages i.e. index.php, about.php (your pages would have to be .php rather than .html as you are using php within the pages for your includes) and link to those pages just using regular links.
This method would also be better for SEO.
If you really wanted to do it the way you're originally talking about you could use the jQuery load() method.
More info here:
http://api.jquery.com/load/
I think you need to read up on the basics of what javascript, HTML and PHP are; this way you should be able to get this on your own and be a better developer.
Javascript is client-side scripting. What that means is that your javascript code is interpreted by the user's browser. This can cause issues when certain browsers interpret your javascript differently.
PHP is server-side scripting. It will behave the same no matter what browser your users are browsing from. As long as the same data is passed in, the functions will behave in a consistent manner. It sends HTML (or other data, but that's a bit more advanced) to the client.
HTML is markup. All it does is tell the browser how to display the data you've returned from the server.
Combine these three and you get a better idea of how they interact with each other. If something on your page can be "dynamic" in the background, but static (unchanging) once the user is viewing it, use PHP. If something relies on user input to change dynamically without the page refreshing, you're going to need to implement some sort of javascript.
There are multiple ways of achieving this,here are 3 simple ways without reloading index.html:
Using iFrames:
make index.html contain all your buttons and an iFrame called PageContent On click of every button call a JS function which simply
changes the src attribute of PageContent to the relevant html.
Using Client -Side JS:
make index.html contain all your buttons.ALso include the content of all the related pages into hidden DIVs. On click of each button hide all the other "option DIVS" and show only the relevant DIV.
Using AJAX:
make index.html contain all your buttons and an DIV called PageContent On click of every button call a JS function which simply
hits the server, gets the content for the page which is linked to the
button and renders it into the DIV using innerHTML.
I want to add google analytics to our website and have read some conflicting info about where to put the script tag.
Google says to put it before the closing </ head> tag: http://code.google.com/apis/analytics/docs/tracking/asyncTracking.html
The way our site is designed, this would mean making an edit to every page. It's not that big of a deal if I need to do this, however, our site also uses header and footer include files.
These header & footer files have html code in them and fall just inside the <body> and </body> tags once the page is loaded.
It would be so much easier to just add the script to the header or the footer file. I'd just paste it in there once and it would be serving up the code on every page.
My question is: Can I do this? Can I move the script snippet inside footer include file even though it's not before the </head> tag as google suggests?
Am I asking for problems if i do it this way?
Thanks!!
You can.
The only difference is that if you put in the "footer" (i.e. just before the </body> tag), the browser will first load the DOM (i.e. everything up to the script tag) and then start to load the script. If you put it in the header, it will try to load the script either before it loads the rest of the DOM or while it is loading it (depending on the browser).
You might feel a difference only if you have a huge page with a lot of elements, but the only difference really would be that the script would be loaded later, so if someone aborts a load of the page, the script might not get executed.
Thus, Google recommends to place it in the <head> and if you can, you should, however you also can put it somewhere else if that makes life easier.
I would recommend saving the analytics code in a file and including it in your footer or header - Example: . I've recently run into some issues with Firefox and IE regarding the page load and analytics. It loads the page to the point where the analytics code is present and then the page hangs indefinitely. I can refresh the page and it loads fine, but for some reason it's happening and there's very little info out there regarding solutions. So, in my case I've included the code in the Footer or of the page at the bottom. This way, in regards to your site visitors, they'll likely not even notice because the rest of your page will load and once they click on a link it shouldn't hang again.
I'd say you can - but easier than that. Just place it in the footer and check if the Live-tracking finds visitors if it does you have the answer.
It's possible and is in fact the way many plugins do it (especially most WordPress plugins I've seen). In fact, putting all your JS at the end of the html (just before < /body>) is recommended if those are not required during the load of the page.
I have seen people put it pretty much anywhere on the page. You can put script tags anywhere on the page; many prefer to keep them in the <head> tag, while others put them at the bottom to avoid using document.ready. The point is that putting scripts there still works. Therefore, I see no problem in putting it at the bottom of the page.
Yes, I believe that it would work - it's not recommended though.
f you have a header and footer file, why not just append your Analytics code to it? Unless every page has unique footer/header page, of course. Then I'd recommend you to take a look at MVC.
Observations have already been made here regarding the scripts placement which can be taken on a site by site basis. We run Google Analytics using Google Tag Manager and use the header code placement in the footer and have no problems with that. Google is currently rolling out Core Web Vitals which places website performance as a must have, and so optimising code delivery is really important. Just wanted to add this here as it was pertinant.
I have an iframe on my site that shows the full contents of an external site. I want to get rid of the iframe but keep the same functionality. I was thinking of using a div with overflow=auto. Problem is, when I attempt to include an external site using php, such as include 'http://www.site.com'; or echo file_get_contents("http://www.site.com");, the site shows up but it takes over formatting, the site's name appears in the titlebar, etc. How might I replace the iframe functionality?
How might I replace the iframe functionality?
This is not easily possible. You run into the problems you just described and to solve those is a real hard job. I don't know of an existing component that does this.
Instead stick to the iframe. What's so bad about it?
If you are getting rid of the iframe because of its default ugly border then you can just make the iframe look seamless using the 'seamless' attribute of iframe
http://www.w3schools.com/html5/att_iframe_seamless.asp
I am building an AJAX deep-linked site.
I want PHP to load all the HTML code of the page if the user is trying to access the site with a Javascript non-supported browser or if it is a search crawler. Basically PHP will return the whole page.
On the contrary, when the user is trying to access the site with Javascript supported browser, I want PHP to return only the template code, and let Javascript (AJAX) take care of the rest. Basically PHP will only load design elements and let Javascript populate them with content.
I looked into PHP's get_browser() function, however it seems it is not such a reliable tool. What is the industry's practice see if the browser supports Javascript or it is a search crawler using PHP?
Background:
Why I want the site to have this behavior.
Since I want the home page to load just by loading the address: example.com, which does not send any query to PHP, PHP returns the HTML code of the home page. This however causes issues when the user tries to load the following page: example.com#foo. So, for this example, PHP will return the home page and once the home page is loaded, Javascript (AJAX) will change the content around so that it shows proper content for #foo. This will make the user to see the home page, therefore load time will be slower and user-experience will not be so nice. However if my PHP script can figure out that if the use with Javascript supported browser is trying to load the page, it will only return the template of the web site, which has no content) and the javascript will populate that template with content whatever is supposed to be displayed for #foo. On the other hand, if the Javascript non-separated browser or a crawler will try to access the page example.com#foo, home page will be returned.
I am using SWFaddress (http://www.asual.com/swfaddress/) library for the deep-linking.
Edit
Thank you guys. I did not think of using <noscript></noscript> before.
Here is what I decided to do. PHP by default will load pages such as example.com or example.com#foo (which is essentially the same as example.com from PHP's point of view since fragments by definition are not sent to the server) blank (just visual template) with <noscript> tag inside for the content of the home page. This way users with javascript will not see the home page and AJAX will populate the content of the page according to the #foo fragment. On the other hand, search crawlers and users without javascript will see a home page.
Thank you again. I think this is pretty simple and elegant solution. If you have any further suggestions, please post a comment or another answer.
You can't do this using PHP. What you can do though is use a noscript tag to redirect to another php page if they don't have javascript:
<noscript>
<meta http-equiv="refresh" content="0; URL=nojavascript.php">
</noscript>
It's not possible to accomplish this in the way you're trying to do it.
It's rare that someone has JS turned off and doesn't know it.
PHP doesn't get passed anything after #, only javascript can do anything with that. So even if PHP could determine if the browser has javascript turned on then it still couldn't read # anyways.
You could include a link inside some <NOSCRIPT> tags that point the user to something like example.com#foo?javascript=disabled.
Unfortunately, browsers do not report whether JS is enabled or not, so there's no way to know from a simple HTTP GET whether or not you should send JS reliant pages.
You should just build an AJAX query that sets a session variable for javascript enabled.
Run this AJAX query before any other information on the site is loaded and then do a simple redirect to the actual site.
You could do something like this pseudo code:
Index.php:
ajax(check_js.php);
redirect(main_page.php);
check_js.php
$_SESSION['js_enable'] = true;
main_page.php
if($_SESSION['js_enable'] == true) {
//execute page
} else {
header("Location: no_js_error.php");
}
Instead of the server trying to sniff our the user's settings, how about using unobtrusive javascript in the first place? This way, the page will degrade gracefully (to the desired state) if JS is not available.
I am beginning to develop a website as a personal project, to discover a little bit web technologies. My question is more about "how to make the things clean" than a technical question.
Here is the thing:
Let's say that an index.php page will include an other menu.php, which will permit to navigate the website.
My index.php look like this, basically:
include("header");
include("menu");
include("DEPENDING ON WHICH LINK AS BEEN CLICKED FROM THE MENU");
include("bottom");
To avoid the POST method, and have a lot of stuff on my URL, I would like to do it an other way, but I do not know what is the best one.
I thought about declaring a variable like $page, when a link is clicked, I can do something like "if $page == home", then I include the home.php page... etc...
I do not know if my question is clear... I know that it will appear as a very easy and beginner question but I don't even know where to look...
Do you know if I can find any "open source website" so I can study the code and see the best practices about it?
P.S.: Sorry for my english which is probably not perfect at all, I am working on it.
You can have a menu like
Home
About
Then on your PHP code
include $_GET["view"] . ".php";
Note that I am not validating, so any parameter passed on the url would be able to include any file.
The $_GET returns the values passed to the page through the URL.
The $_POST returns values posted.
The $_REQUEST returns both $_GET and $_POST values.
A good place to study many languages is W3Schools, you could check there sometime.
Make a page which will be common redirect page.
Every post will come to that page and based on the page parameter it will redirect.
So action of every page is same, but based on page paramter redirect to which ever page you want
You can switch case and
use header to redirect
i think you want to avoid GET method and avoid lot stuff in url
For learning
I thinks this is the simple website for learner.
http://www.w3schools.com/php/default.asp
http://www.plus2net.com/php_tutorial/site_map.php
http://www.tizag.com/phpT/
actually most of all these websites are same.
i hope you know the basic website PHP.net
Then,,.. no one is low level ..every low level will be in a top level one day.. just like you am also trying :)
Don't do what you are trying to do. The whole point of having pages is to handle things with different files. That is, you will have some commonality between files (handled by auto prepend and include path, potentially) such as your header and footer. Each file should include this on its own and print it out directly.
That is, you should not handle everything on one page and then conditionally include a file. Just send users to a different page.
Finally, I recommend not splitting up the header/footer files at all. Instead create a decorator that wraps the main content and displays it all at once. Something like:
$page = <<<HTML
<html><head><title></title></head>
<body>
<div id="top nav"></div>
{CONTENT}
</body>
</html>
HTML;
Then you go through and build your page content. Then you add it to CONTENT in the decorator and print it. PHPTAL is a great way to have this handled externally.
Hi you should please ask one question at a time:
I think this basic tutorial will give you a good idea on how and what to use the include(); func.
http://www.w3schools.com/php/php_includes.asp
I started with:
http://www.solitude.dk/filethingie/
Very simple .php file administrator.
You should definetly check out sourceforge, giant colletion of open source projects just filter by php (search for literally anything).
Just wanted to mention that you can download the full code of more complex pages (that are based on php) like
wordpress (blogging platform) - very easy to install and configure
identi.ca (twitter open source alternave)
You can now download reddit´s source code - quite easy to.
Maybe you wont be able to modify them immeditelly but theyll help you to get the picture