php-display other sites page in my host without iframe - php

How to display other sites content in our site and server without using iframe?
In fact, I'm going download a page (same domain) and display in my server via php like browsers.
Note: file_get_contents works well, but "CORS policy: No 'Access-Control-Allow-Origin' header is present on the requested resource" so all stylesheets and some images are not loaded.
Is there a way to do it?

I think in PHP you can't do this, because some website header block access for you. I would do this in js/jquery like this:
Ajax/jQuery - Load webpage content into a div on page load?

Related

How to access iframe in PHP Scriptable Web Browser

I am using PHP Scriptable Web Browser for downloading some data from
one web site and that website contains so many links https://www.xxxx.com/CWRWeb/ReportNav.do?rid=CHARGEBACK using this link i want to download the data this page contains one iframe when is access this page using my script i am able to get the that page contain but not able to get iframe content from that page
can any one guide me.
Thank you.

Include ASP.NET Header and Footer on PHP Website

I'm building a Wordpress blog for someone with an ASP.NET website, their hosting provider won't install PHP on their server so we're having to use an external Linux server.
My question is, is there a good way to include their ASP.NET header and footer into the Wordpress blog despite it being hosted externally on Linux server.
Thanks.
Assuming the header and footer are ASP controls of some form, and assuming those controls are likely to includes things like links and images with relative urls, the easiest solution would be to create a simple ASP page with the header and footer controls, and in the middle an iframe pointing to the server hosting the blog.
The other option would be to create two "hidden" ASP pages that contain the header and footer controls. Then your wordpress code could use something like file_get_contents to get the contents of those pages, and the PHP DOM API to parse out the parts you need and rewrite any relative urls.

do you have access to contents of iframe loading external website?

If I have an iframe loading a website from a different server, like bing.com, can I manipulate or retrieve the code from that iframe?
If not, I can do a curl request and create the iframe from that and then manipulate it, right?
In javascript you can't access the contents of an iframe if that site resides on a different domain than the one you are loading the iframe from. You can proxy the page load by having a PHP scrip that "curls" the request. There is a lot more involved than that though to cleanly proxy another site.

cookies causing "unsecure content" warnings on google chrome?

If i visit the home page on my site (which uses code igniter) my homepage is using http,
Code igniter sets a cookie containing all the session info.
If I then click login, which is using https I get unsecure content warnings, and the only thing I can think of it being is the cookies as If I restart the browser then go straight to https://mysite.com/login then I get no unsecure content warnings.
How can I fix this (Note that the homepage cannot be https).
This error comes from content being served over http to a page that's supposed to be https. For example, an <img>, <link>, or <script>.
The thing with Codeigniter is that it's very likely you're using base_url() or site_url() for full absolute URLs to the embedded content, probably using http.
Here are some things you can do:
Use relative URL's, i.e. <img src="/path/to/images.jpg">
Don't specify a protocol. Example: //example.com/path/to/image.jpg More on this technique here: http://paulirish.com/2010/the-protocol-relative-url/
In the __construct() of the controller that you need to use https (or in the method that needs it), load a different config file that redefines your base url to use https. Note that it will be too late for any scripts/libraries that use the base url for html output before this config file is loaded.
If you load the page in IE, you should get a very nagging error message that will give you a list of all the content that was delivered insecurely to help you troubleshoot (other browsers should have this feature as well, but in IE it's especially prominent).
EDIT: Saw your note that there is nothing on the page being requested via http, only https, and the note about what happens when no cookies are present. My mistake, I just woke up - I should have read the question more thoroughly :p
You are loading unsecure content (usually images/iframes) on your secure (https) login page.
What this means is that you are referencing a link to a page that is not secure (is not https). This will cause the error, and prompt users whether or not to load such content. It's a problem with the links to external content, not your cookies.
Edit: To (temporarily) fix the issue, find any links/references to external content and disable it for the time being, then visit your page and the prompt/error should go away.
To fix the issue, you'll have to download the content or use a file on your site to securely download the content for that page to use.

Using http based IFRAME in https URL

I have php application in https mode. And the parent(https) contains an iframe. The iframe src will be a http file. The parent and the iframe are in the same domain. But i am not able to access the iframe source using http.
Is there any way in to fix this issue using php or javascript?
Thanks in advance.
Since you tagged this javascript, I assume you mean to access the iframe source using javascript.
Because of the same origin policy in your browser, pages can communicate across different windows or iframes only when their protocols (http vs. https), port, and domain are the same.
Since your protocols are different (http vs. https) you cannot use javascript in your page to access the document in the iframe.
Here is more info about same origin policy:
https://developer.mozilla.org/En/Same_origin_policy_for_JavaScript

Categories