This question already has answers here:
Closed 10 years ago.
Possible Duplicate:
A simple hello world NPAPI plugin for Google Chrome?
How to open a file which includes in Chrome extension by C/C++?
originally i wanted to develop a chrome extension to open a file on the user's pc.
I wanted to use php fopen some SO users said that I have to use NPAPI instead and said that this is a duplicate question and deleted my question.
I just want to know why can't I use fopen? And if i really don't have other options, then how to open a file using firebreath?
When i go to this section of the docs i don't see the snippets.
i know that moderators gonna come to my question saying that this is a dupe and link to this question I'm one step ahead lol
I don't understand a thing from the accepted answer and i don't understand what file he edited.
the second answer give this link but i can't see the snippets! can you?
I'm on linux mint 12, 32 bit
let me change the question. Can i do this in java? Flashgot got some jar files in the source code :)
install flashgot using chrome, a file called flashgot-1.3.9-tb+sm+fx.xpi will be downloaded, change that to flashgot-1.3.9-tb+sm+fx.zip unzip it and go to the chrome folder
Can i do it in python? every linux distro has python by default
I just want to know why can't I use fopen?
Because JavaScript isn't C.
More generally, there's no way for arbitrary web pages to run arbitrary native code on your computer because otherwise clicking a link could take you to a page that would steal every file on your computer and then erase your hard drive.
If you use firebreath then you're in C++, so you can use fopen if you wish. Keep in mind that you would have the same privileges as the browser, which running as a user probably can't write places like Program Files, etc.
You can't use fopen in javascript. I don't know why a "building firebreath on linux" page would ever have snippets on how to open a file; since firebreath is just C++ I don't know why we'd need to add docs for opening a file at all.. it's just C++. Open a file like you would in any other C++ application.
The other question has all the information you need to figure out where your file is; they didn't include specifics on how to do the operation itself because you don't need those specifics; you can get them anywhere. Try googling "open a file in c++" and you'll get lots of hits.
Related
Problem: I'm creating a website right now, it's my first time dealing with PHP after learning the basics. My index.php file, when viewed on my localhost, is attempting to download the file and bring up the file explorer prompt. Does this on both Chrome and Edge.
Troubleshooting:
I removed the file association.
Tried on Edge browser.
Looked online for answers. All other YouTube videos & forums I found including StackOverflow had previous questions about this but the answers were either outdated by like 10+ years or just didn't for me.
What do I do? Any help is appreciated, and reminder I'm new to PHP so please no super veteran-sized solutions, thanks.
Edit 01: I was told to share my URL so here it is:http://127.0.0.1:5500/index.php
Edit 02 (Solution): I didn't realize that the Live Server plugin for VSC was only for static HTML pages and not PHP pages. WebPajooh helped me with setup how to achieve a similar result using XAMPP.
It was better to share your URL. I guess you are trying to access the PHP files by entering the file path, not the URL.
https://localhost/some_directory/some_file.php
If you are doing this, not entering the file path directly, check your web server configurations.
This question already has answers here:
Website screenshots
(18 answers)
Closed 6 years ago.
I need to take screenshots of few web pages and save them in a folder using php.
I want to do this using a php script, is there a way I can render those webpages and take screenshot of a particular area after the website is fully loadedd? - I'm using windows.
I tried using wkhtmltoimage but it takes low quality screenshots and also it takes the screenshot before the whole page is loaded, so some images of the webpage are not appearing in the screenshot, is there a way to do this using php?
Please help php specialists. Thank you
PHP runs on server side, so to be able to take screenshots you need something to render HTML (a browser-like script) and generate a image of it. This script will do that (wkhtmltoimage too):
HTML2PS:
http://freecode.com/projects/html2ps_php
But I still think the best solution will be using javascript. Of course, only the client will have access to the screenshots, and maybe you can upload the image to the server. A client browser is better than any kind of server script.
If that is the case, I would suggest using HTML2CANVAS:
HTML2CANVAS: http://html2canvas.hertzen.com/
The best server solution will be a linux distribution with a google chrome installation and a local script to take screenshots. That is the only way to get accurate screenshots of a web page that may contain javacript/HTML5/animations and other difficult to render stuff.
JavaScript / HTML5 / Canvas
It could be hard to code it only in PHP. In your case I think I would follow those instructions:
Using HTML5/Canvas/JavaScript to take screenshots
PHP
Or if you really want use only PHP, it should help you:
Website screenshots using PHP
So I am looking for a method of opening a browsers file dialog, and allowing users to either select a directory and have it populate the path, or select a file or set of (within the same directory). The isn't a Java Applet. Is there a means of this type of dialog? That can support IE 7 and up? Or am I stuck with a Java solution?
We currently have a Java Based solution that was written by someone years ago, which is starting to fail more and more due to new versions of Java coming out, due to OS's getting more tighter on security, and so on and so forth. So I am trying to find alternative solutions that will hopefully be a bit more easy to maintain, that don't require (preferably) java to do it.
I am ultimately just stuck with where to look to even begin to start finding any of the right methods to do this if its possible in the first place. Seems every search I do, just brings me in circles with answers that dont apply
EDIT
I should put emphasis, that the only goal of this dialog is so I can get a directory and or file path from the user on their local machine, without having the user key in the full path themselves.
As far as my knowledge go, it's only Java or possibly some AIR+Flash hybrid in this case, really. Reason for this being that you will need some technology to:
recognize your selection as file or directory
read all files and possibly sub-folders from the selected directory
queue them for upload and then be possibly able to recover their structure on the server-side
Therefore you at least need something that can natively work with file structure of the client, as well as optionally something that will re-create the same structure on your server.
EDIT: you may also want to check this: Upload a folder in ASP.NET of Flash or Silverlight
This question already has answers here:
Is there a PDF parser for PHP? [closed]
(7 answers)
Closed 8 years ago.
My question is that i want to open documents(pdf,doc,docx,txt) in browser page using php (without using google docs viewer) can any one help me?
Some of these are doable. Some, not so much. Let's tackle the low-hanging fruit first.
Text files
You can just wrap the content in <pre> tags after running it through htmlspecialchars.
PDF
There is no native way for PHP to turn a PDF document into HTML and images. Your best bet is probably ImageMagick, a common image manipulation program. You can basically call convert file.pdf file.png and it will convert the PDF file into a PNG image that you can then serve to the user. ImageMagick is installed on many Linux servers. If it's not available on your host's machine, please ask them to install it, most quality hosts shouldn't have a problem with this.
DOC & DOCX
We're getting a bit more tricky. Again, there's no way to do this in pure PHP. The Docvert extension looks like a possible choice, though it requires OpenOffice be installed as well. I was actually going to recommend plain vanilla OpenOffice/LibreOffice as well, because it can do the job directly from the command line. It's very unlikely that a shared host will want to install this. You'll probably need your own dedicated or virtual private server.
In the end, while these options can be made to work, the output quality is not guaranteeable. Overall, this is kind of a bad idea that you should not seriously consider implementing.
I am sure libraries and such exist that can do this. Google could probably help you there more than I can.
For txt files I would suggest breaking lines after a certain number of characters and putting them inside pre tags.
I know people will not be happy about this response, but if you are on a Linux environment and have pdf2html installed you could use shell_exec and call pdf2html.
Note: If you use shell_exec be wary of what you pass to it since it will be executed on the server outside of PHP.
I thought I'd just add that pdfs generally view well in a simple embed tag.
Or use an object so you can have fall backs if it cannot be displayed on the client.
A few months ago I saw a PHP script built to detect malware injections in files. Basically the script watched for any files on the server to change or for their contents to change, and then emailed an admin if the contents changed. I haven't been able to locate a script that does this but I need one.
Does anyone know of a program like this?
Thanks!
Use an Intrusion Detection System like OSSEC
It's not a PHP script, but you're probably looking for something like the famd package. Possibly used with http://php.net/manual/en/book.fam.php, however, at http://www.php.net/manual/en/fam.installation.php it states:
This extension is considered unmaintained and dead.
... so I don't know what the current alternatives are.