Heyas. I have an flash app that I'm working on that can be embedded on other websites (like YouTube videos), but we want to know what website the user is viewing the site on. Is there any way to tell what site the app is embedded on that the user is viewing on?
The original app is written in flash/actionscript and php running on the server, if that helps. Thanks.
You can simply retrieve the HTTP referrer header via php, store it somewhere and than serve your flash content...
<?php
// served from http://yoursite.net/your_flash.php
//read the referer header
$referer_url = (isset($_SERVER['HTTP_REFERER']))? $_SERVER['HTTP_REFERER'] : "";
//store it somewhere...
//read the swf file
$swf=file_get_contents('flash_app.swf');
//spit the flash content out with the proper header
header('Content-type: application/x-shockwave-flash');
echo $swf;
?>
Embed code, to be pasted by third party websites in their HTML:
<object width="550" height="400">
<embed src="http://yoursite.net/your_flash.php" width="550" height="400">
</embed>
</object>
Related
I want to embed pdf files in my html ( either using the embed tag or the iframe tag ).
I've tried the following two. All work well on firefox but not on chrome, chromium and android browsers.
<embed type="application/pdf" src="myfile.pdf"></embed>
<iframe class="embed-responsive-item" src="myfile.pdf" allowfullscreen></iframe>
I've also tried reading the pdf file with php and then using an iframe to display it like this
header("Content-type: application/pdf");
header("Content-Disposition: inline; filename=".$_GET['pdf']);
#readfile($CONFIG['PDF']."/".$_GET['pdf']);
Again, this doesn't work on chrome / chromium and mobile browsers. It only works on desktop firefox.
I'm not sure if this is important information but I've also Set the X-Frame-Options "ALLOW-FROM mydomain.com"
Here you will find an example of what the issue is.
Is there any other way that I can embed a pdf file on a web page?
The Chrome browser on Android no longer supports PDF embeds. You can get this by using the Google Drive PDF viewer:
<embed src="https://drive.google.com/viewerng/
viewer?embedded=true&url=http://example.com/the.pdf" width="500" height="375">
You can also use Google PDF viewer for this purpose. You need to upload your PDF somewhere before and just use its URL:
<iframe src="http://docs.google.com/gview? url=http://example.com/mypdf.pdf&embedded=true" style="width:718px; height:700px;" frameborder="0"></iframe>
I understand that an iframe is rendered by the browser engine
is there a way to render the full HTML on the server side and serve it to the front end?
I tried the PHP's file_get_contents() function and the srcdoc attribute for the iframe
This simply downloads the content of the page and makes it unusable
<?= file_get_contents('http://dns_blocked_by_isp.com'); ?>
And this renders a non-working iframe
<iframe srcdoc="<?= file_get_contents('http://dns_blocked_by_isp.com'); ?>"
frameborder=0 width=510 height=400 scrolling=no
allowfullscreen=allowfullscreen>
</iframe>
So am basically looking for an alternative of runat="server" in ASP.NET but for PHP if possible
Motivation:
My ISP blocked the DNS address where I get my iframe source from, but my server runs on a different region which means it can download the content just fine and the urls in the iframe has -cdn.com suffix which in turn is not blocked by the ISP
Thank you
To get around browser support issues, you'd probably be better off setting up a PHP proxy page (i.e. a script on your server that just fetches the remote page and serves the source directly as a page from your server), but I suspect that the issue you're running into is just that the " characters being returned from the remote page are breaking the srcdoc attribute. Let's say that the remote file looks like:
<p class="worldclass">Hello World</p>
Then your example would result in:
<iframe srcdoc="<p class="worldclass">Hello World</p>"
So the the value of srcdoc is just <p class=
You just need to escape the code appropriately:
<iframe srcdoc="<?= htmlspecialchars(file_get_contents('http://dns_blocked_by_isp.com')); ?>"
frameborder=0 width=510 height=400 scrolling=no
allowfullscreen=allowfullscreen>
</iframe>
I have pdf link file coming from cloud server and i put it into iframe to show it but when i open the page, it direct to download this pdf file and didn't show the file itself, also i used embed and object and it doesn't appear anything.
<iframe src='{$finalurl}' width='1000' height='1000' align='center'></iframe>
Are you required to use an i-frame?
And do you just want to show it, or download it to your 'own' server and show it? That's a big difference.
If you just want to show it (and keep it where it is):
<embed src="http://cloudservice/yourpdf.pdf" width="1000" height="1000" type='application/pdf'>
Good luck
Currently I am using the standard way to embed an pdf to the browser, however, the built-in pdf viewer for my target browser is not working as expected. I would like to force (Chrome, Firefox and IE8 (if possible, but IE9+ is also ok)) to use the adobe reader. The problem is , I can only change this option manually. Is there any way to change the option in HTML/ JS/ PHP ? Thanks.
<OBJECT data="YourFile.pdf" TYPE="application/x-pdf" TITLE="SamplePdf"
WIDTH=200 HEIGHT=100>
shree
</object>
I try to find the solution and someone suggested header, not working unfortunately e.g.
Content-Type: application/pdf
Content-Disposition: inline; filename.pdf
You can use Google PDF viewer to embed pdf files on to your website. Use this link https://docs.google.com/viewer
Example:
<iframe src="https://docs.google.com/viewer?url={HTTP PATH OF THE PDF FILE}&embedded=true" width="600" height="780" style="border: none;"></iframe>
https://docs.google.com/viewer?url=http://research.google.com/archive/bigtable-osdi06.pdf
Check out PDFObject which is a Javascript library to embed PDFs in HTML files. It handles browser compatibility pretty well and will most likely work on IE8.
In your HTML, you could set up a div to display the PDFs:
<div id="pdfRenderer"></div>
Then, you can have Javascript code to embed a PDF in that div:
var pdf = new PDFObject({
url: "https://sample.pdf",
id: "pdfRendered",
pdfOpenParams: {
view: "FitH"
}
}).embed("pdfRenderer");
Cheers
Trick Chrome and Firefox (and maybe other browsers) into displaying the PDFs using the Adobe Reader plugin (for full PDF Open Parameters support among other benefits) by using one of the following 'Adobe PDF in XML Format' types in your embed code:
application/vnd.adobe.pdfxml
application/vnd.adobe.x-mars
This works fine as of my answer today and I'm hopeful it will continue to work fine. I'm using it currently with standard PDF files as a workaround for embedding PDF files in the browser that need to use the Adobe PDF plugin rather than the browser's built-in PDF rendering. Even though my PDF files are standard (non-XML) files, they appear to load just fine with this new application type parameter.
<OBJECT data="YourFile.pdf" TYPE="application/vnd.adobe.pdfxml" TITLE="SamplePdf"
WIDTH=200 HEIGHT=100>
shree
</object>
I have a PHP script that generates dynamic images using GD. The image may be accessed remotely via, for example, http://mysite.com/scripts/phpimages.php
Any remote website such as example.com could able to render this image in its client side HTML img tag. For example:
<!-- http://example.com/about.html -->
<img src="http://mysite.com/scripts/phpimages.php" />
What I need that my script able to know the URL of the image requested page i.e http://example.com/about.html
Use this
echo $_SERVER['HTTP_REFERER'];
To prevent errors,
if(isset($_SERVER['HTTP_REFERER'])) {
echo $_SERVER['HTTP_REFERER'];
}