Download from URL (PATH) - iPhone - html

I got a little Question.
I'm working on an App, and for that I have to download an HTML File with the including CSS and Images.
And Yeah, there's an API for that (ASIHTTPRequest), but I wan't to publish my App to the App Store and I don't want to use 3rd party API's.
And Parsing the HTML code is a bit hard :(
And It would also work for me, if I could download the whole path of a URL.
For example:
I have this URL: http://example.org/smthg/.
At this path I have:
-index.html
-logo.png
-style.css
And I want to download all this files AUTOMATICALLY, and not every single file.
But I don't think, that you can find out which files are on the server, right? (without BruteForce).
I hope you know what I mean :)

You can use a UIWebView to download the content at the location and hold on to the WebView. You could also use NSURLConnection to download content at a URL if you want to save it unformatted and you have the URL's to the resources.

There's nothing wrong with using 3rd party frameworks, as long as they're good quality frameworks and you use them right. ; ) Apple just gives you the starting blocks to make an app, after all, and using open-source code can really speed up your project.
With that said, ASIHTTPRequest is a bit outdated and not well maintained. Instead, I'd recommend AFNetworking, which supports asynchronous downloads, background downloads, and blocks. See https://github.com/AFNetworking/AFNetworking .
Regarding your specific issue on downloading certain files, however, you might try creating a plist(s) on the server (if its yours that is, or else, bundled within the app perhaps) that would list all of the needed files and their download locations.
However, the issue you're liking going to quickly face- even if your app has all needed files downloaded, it still has to understand what to do with them. If its just HTML content, styles, etc, perhaps you can display it in a UIWebView ? However, be sure that your app is adding some useful functionality besides just being a web browser... (unless, of course, you're making an enhanced web browser... ;)
Good luck!

Related

How to convert Javascript, CSS, and HTML content into a interactive-pdf or .h5p page

I have a webapp that let users place dots on sitemap and link them to images.
The web app uses Javascript, CSS, and HTML.
phase1
While the user is subscribed he uses a rich set of functionalities to:
add dots on the sitemap and link them to images
edit the dots: move, delete, link momultiple images etc ..
etc..
This is done via the website that hosts the webapp.
phase2
When the user ends the subscription, he gets a .zip file with the information that he created (sitemap, images, links between the sitemap and the images, etc..).
The user can then connect to the website that hosts the webapp, without signing in and get a subset of the functionalities (e.g. he can only click on the dots and see the linked images, but he can no longer edit the dots or add images).
I want to change phase2.
Instead of interacting with the webapp on the website, I want to "freeze" the webapp into a interactive-pdf, or h5p page that can be played independently without the webapp.
There are multiple reasons that motivate to do this:
the webapp is complex, so engaging with the webapp is prone to more errors.
If the small subset functionality of the final data, which boils down to showing the image when clicking on the hyperlink, can be done via h5p browsing, then the risks for runtime errors are greatly reduced.
the interactive-pdf or .h5p file can be browsed by variety of tools potentially even when being offline.
the end product can be re-designed to appear more simple.
My questions:
is it possible to programatically convert the Javascript, CSS, and HTML content into a interactive-pdf or .h5p page?
Every end-product will be different (e.g. by the number of dots, and their location in the sitemap) so having to manually create the .h5p page every time is not practical.
are there mobile apps (e.g. on Apple Store, or Google Play) that can read .h5p content locally, e.g. when the device is offline?
Thanks
EDIT:
Oliver Tacke, thank you for replying.
Up to few days ago, looking for a solution to my problem, I did not hear about h5p at all.
When looking into h5p, I see that
many comments rlated to h5p that is a bit old - from ~5/6 years ago.
h5p is frequently talked in context of education (e.g. Moodle)
when I filed the question I could not even find a tag for 'h5p'
I could not find forums for h5p in mainstream channels like Discourse or Slack
So I want to know if I'm in the right direction at all.
Is h5p a new thing that just takes time to pick up, or is it something that started a while ago and dwindlled down,
or maybe I'm wrong and it is currently more active than I think (I'm aware of h5p.org and I do see activity there).
Basically, I want to create interactive content that can work
ideally offline, or
online but with a mainstream browser/tool/website (i.e. without needing my special website)
In the design industry, I know there are interactive catalogues.
But I don't know if the user can download them and somehow (e.g. with an epub reader) read them.
Thanks
I don't know anything about creating PDFs programmatically, so I can only offer a partial answer for the H5P related part. Given the broad scope of your question, this may be acceptable as a comment.
H5P content follows a specification that is documented at https://h5p.org/documentation/developers/h5p-specification.
You would basically have to implement an H5P content type library (file) from the files that you are given by the service. I assume that the JavaScript and CSS files are always the same, then those could be reused directly (but potentially not legally). You would also have to add some more JavaScript that takes parameters and generates the HTML output that you get from the service. You would then have to model semantics.json to suit the parameters, and then you essentially have an H5P content type. You don't have to use the then available form based editor (which probably wouldn't make sense), but you could create the content.json file programmatically and put it into the H5P content file archive. To create that file programmatically, you'd have to create a converter that identities the parameters in the HTML file generated by that service and transform them into the H5P semantics/content format. Not sure if it made more sense to rather create an editor widget for H5P, so you wouldn't have to depend on the other service at all.
There are currently no known mobile apps that allow you to load and run H5P content. They are on the roadmap of the H5P core team, but I wouldn't expect them to work on those any time soon. There's the moodle app for the moodle LMS that allows to use H5P content offline, but it needs to be fetched from a moodle instance. There's Lumi that allows to run H5P content locally on Windows, MacOS and Linux, but not on Android or iOS. However, Lumi also allows to create single standalone HTML files from H5P content containing all the content and logic ready to play, so that would allow offline use on Android and iOS.

How to get a torrent file link that can be downloaded?

I am creating a movie website for a project. In the website I'm going to add movies download links that can be downloaded via torrents. I have seen in some websites that they use torcache.net to provide download links. And my quesion is how to create a magnet link, or how to get a torrent file link that can embed in a html file from websites like torcache.net...
Have you considered just copy and pasting the magnet link from a regular torrent indexing site?
What is going to differentiate your website from a plain old torrent indexer like thepiratebay?
Making a link in html is simply a matter of:
text
Could you please be more specific in your question.
I think the gentleman is asking how, using magnet links, to download the data via torrent network in the application and serve is to the user.
There is a javascript library called WebTorrent that uses WebRTC protocol to transmit data in the browser to other browsers. You can use magnet links or .torrent files.
In the browser, WebTorrent uses WebRTC (data channels) for
peer-to-peer transport. It can be used without browser plugins,
extensions, or installations. It's Just JavaScript™. Note: WebTorrent
does not support UDP/TCP peers in browser.
You can see a demo of it where a video clip is streamed in via torrent and after it buffers up a bit, starts playing a short movie. You can also see a visual of the nodes connecting and disconnecting, which is quite cool - https://webtorrent.io
Bonus:
If I want to share large files (> 10Mb) with multiple people I use file.pizza implementation.

How to prevent viewing website code

I have a website that has a lot of data and that is sensitive to the website so I made a code that prevents right clicks but if you are using Safari it is easy to see the data I need to hide the info also so safari cant view it ether.
Client side, you cannot secure your code from view. Firebug will still show the code. You should have sensitive data on the Server.
You can't.
If the data is sufficiently sensitive that people shouldn't be able to view it, don't put it on a web site.
I m not sure if there is a completely safe solution.
if its images, use flash to load them dynamically.
yet people who knows swf-bin specs can decompile your swf files and find out the real image path.
if its data & text.
as much I can do is to
1: use pure js to render all views.
use XMLHttpRequest/ActiveXObject to load data and import these ajax js code # runtime.
compress your js/css code before deploy
here is one of my mockups
2: on the server side
check the request header to drop command line request.
exchange cookie/session key for each time.
BUT, this will make google-bots don't know how to inspect your site.
so DON'T do that on your landing page.

Convert webarchive to html

I managed to collect the behavior of a complex web site into a webarchive. Thereafter I would like to turn that webarchive into an html set of nested directory. Yet, when I did it both with Waf and with a commercial software bought on the the Apple store, what I get is just the nested directory with the html page at the bottom and no images, nor css nor working links.
If you are interested the webarchive document is at:
http://www.miafoto.it/it/GiroMilano.webarchive
while the weak product of the extraction is at:
http://www.miafoto.it/it/Giromilano/Pagine/default.aspx
and the empty directories above.
In addition to the different look, the webarchive displays the same behavior as the official web site - when a listbox vales is selected and then the button pushed - while the extracted version produces a page with no contents by loading itself rather than the official page.
As you may see the webarchive is over 1MB while the extraction just little over 1 KB.
What is wrong with it and how may I perform such an apparently trivial business with usable results?
Thanks,
textutil -convert html example.webarchive
Be careful — html with files is created in the same folder as webarchive!
Also, I had to open .html with text editor and replace "file:///image.tiff" links (replace "file:///" with "") so they point to relative path.
Also, not all browsers display .tiff images.
Who knew we have Stack Overflow wiki?
I find that this WebArchiveExtractor.app works on my Mac (Mojave OS) –
https://robrohan.github.io/WebArchiveExtractor/
I managed the issue by finding all parameters being submitted in the page and submitting them too in my script, ignoring the webarchive.
To save HTML pages on mac, I use chrome. Download and install it and save your page as HTML. Safari will save the web pages with webarchiveformat and for me, it's very hard to deal with it.

How to prevent downloading images and video files from my website?

How to prevent downloading images and video files from my website? Is it possible?
What would be the best way to do this?
No, it's not possible.
If you can see it, you can get it.
Don't post them to your site.
Otherwise it is not possible.
As the browser needs to transfer the content to display it (text, images, videos), the data is already on the client's computer when the website is displayed. The previous answers give little advice on how to make it harder for non-experienced users to grab the content. Here are some directions:
General
Overlay the respecitive contents with a transparent <DIV> or a
transparent image (as described in some answers to this question)
Open the website in a frameset, so saving may miss the frame content.
Open the website via window.open() to hide the menu bar.
Disable right-clicks via JavaScript (not recommended due to all the side-effects on usability)
Load the page's HTML code from another file (which may check for a specific referer or which may be ROT13) via JavaScript, so it's harder to access the source code.
Tell the browser that all content is display:none for the printer (something like #media print { body, div, p { display: none } })
Use JavaScript to hide the content before a client makes a screenshot (see Stop User from using “Print Scrn”)
Try to disable or overwrite the clipboard (see this post)
Images
Do not use the <img> tag for images but set the image as background for a <DIV>
Wrap images into SVGs or Flash movies to make them very hard to access in a usable format.
Disable caching for images (via <meta> tag or by setting the appropriate header on server delivery), so they are not stored in the browser cache (immeaditely accessible on the client's computer).
Cut an image into parts, so it takes some extra work to reconstruct the whole image
Add onmousedown events to images, e.g., display a copyright alert.
Deliver the image via server script (e.g., PHP) and check the referer.
Videos
Stream videos to prevent simple downloading via URL.
Wrap videos into a Flash movie.
Use some nasty format that supports DRM.
Texts
Make text unselectable (see How to make HTML Text unselectable)
Additionally to overlaying, wrap the text into JavaScript (e.g., after ROT13 or loaded dynamically from a second file), so the text is not directly available in the source code.
Convert texts to images (this may decrease display quality), SVGs or Flash
Again, I repeat that none of this will stop an experienced user from grabbing the content (e.g. by making a screenshot and - optionally - run OCR on it). Sometimes it's as easy as using the browser's developer tools or using the website without JavaScript. Yet, it will give inexperiences users a hard time, so they may look for some easier source to grab from.
Also keep in mind that the above techniques will affect search engines when reading the page's content (if you're interested in blocking them, start with a robots.txt).
Thank you for any other ideas to complement the above list!
Images must be downloaded in order to be viewed by the client. Videos are a similar case, in many scenarios. You can setup proxy scripts to serve the files out, but that doesn't really solve the issue of preventing the user from getting their own copy. For a more thorough discussion of this topic, see the question How can I prevent/make it hard to download my flash video?
If you are using PHP, the best way is to control it the .htaccess, you need to put your files, images and videos under consideration in a separate folder/directory, and create a new .htaccess file in this directory with the below:
RewriteEngine On
RewriteCond %{REQUEST_URI} \.(mp4|mp3|avi)$ [NC]
RewriteCond %{HTTP_REFERER} !^http://sample.com/.*$ [NC]
RewriteRule ^.* - [F,L]
The first line %{REQUEST_URI} will prevent getting the file through the web browser or through curl.
The second line %{HTTP_REFERER} will prevent accessing the image/video using HTML tags <img> or <video> from any website except the exception ! you provide instead of http://sample.com/ which usually should be your website itself.
You can also have a look at my question and the accepted answer here for more tricks on the browser side.
I'd like to add a more philosophical comment. The whole intent of the internet, particularly the World Wide Web, is to share data. If you don't want people to download a picture/video/document, don't put it on the web. It's really that simple. Too many people think they can impose their own rules on an existing design. Those who want to post content on the web, and control its distribution, are looking to have their cake and eat it too.
In short, no. If someone can view an image or video in their browser then they have, by definition, downloaded it. That's how the web works - it is client server based. Whatever you can view in your browser (client) has been transfered to your computer from the remote website (server).
In standard HTML, I don't know of anyway.
You didn't really say, but I'm guessing you are having problems with people deep linking into your content. If that's the case, and you are open to server side code, I believe this might work:
Create a page that accepts a numeric
id, maps it to a server file path,
opens that file, writes the binary
directly to the response stream.
On the page request, generate a
bunch of random ids, and map them to
the actual media urls, and store that
mapping object server side somewhere
(in session?) with a limited life.
Render your pages with your media
links pointing to the new media page
with the appropriate id as a query
string argument.
Clear the mapping object and generate
all new links on every postback.
This :
won't stop people from downloading
from within your page
definitely isn't as lightweight as standard
HTML
and has it's own set of issues.
But it's a general outline of a workable process which might help you prevent users from deep linking.
As many have said, you can't stop someone from downloading content. You just can't.
But you can make it harder.
You can overlay images with a transparent div, which will prevent people from right clicking on them (or, setting the background of a div to the image will have the same effect).
If you're worried about cross-linking (ie, other people linking to your images, you can check the HTTP referrer and redirect requests which come from a domain which isn't yours to "something else".
you can reduce the possibility but not eliminate it...
It also doesn't hurt to watermark your images with Photoshop or even in Lightroom 3 now. Make sure the watermark is clear and in a conspicuous place on your image. That way if it's downloaded, at least you get the advertising!
This is how I do it in case anyone in the future is wondering.
I put this in the .htaccess file on the root server:
RewriteEngine on
RewriteCond %{HTTP_REFERER} !^http://(www\.)?domain.com/ [NC]
RewriteCond %{HTTP_REFERER} !^http://(www\.)?domain.com.*$ [NC]
RewriteRule \.(mp4|avi)$ - [F]
This stops them from say going to domain.com/videos/myVid.mp4 and then saving it from there.
No it's not. You may block right-clicks and simillar stuff but if someone wants to download it, he will do so, trust me ;)
As soon as they view your page that includes the picture or video, the item is downloaded into the temporary folder of their browser. So if you don't want it downloaded, don't post it.
You can mark folders or files so that they don't have read access (any of the main web servers support this). This allows you to store them on the server without any level of access to the outside world. You may want to do this if you have a service that generates images for someone else to download later, or if you use your web account for FTP access, but don't want anyone to view the files. (i.e. upload a .bak file to the server for someone else to FTP down again).
However, as others have said, getting into copyright areas where people can view the image or video but not save them locally is not fully possibly, although there are tools to discourage illegal usage.
Put your image or video in flash format. Works great.
This is an old post, but for video you might want to consider using MPEG-DASH to obfuscate your files. Plus, it will provide a better streaming experience for your users without the need for a separate streaming server. More info in this post:
How to disable video/audio downloading in web pages?
I believe THEOplayer already provides this sort of solution as a paid service, but I'm not so sure about it.
Granted that any image the user can see will be able to be saved on the computer and there is nothing you can do about it. Now if you want to block access to other images that the user is not supposed to see, I am actually doing it that way:
Every link is to the "src" in your image tag is in fact a request
send to a controller on the server,
the server checks the access
rights of that specific user, and returns the image if the user is
supposed to have access to it,
all images are stored in a directory
that is not directly accessible from the browser.
Benefit:
The user will not have access to anything that you don't intent him/her to have access to
Drawback:
Those requests are slow.. especially is there are lots of images on the same page. I haven't found a good way to accelerate that in fact..
You can set the image to be background image and have a transparent foreground image.
I think the best way is:
STREAM THE VIDEO IN SEPARATED ENCRYPTED PARTS.
There are video hosting services such as vzaar that have this functionality.
As far as I know, that will make it really hard to download directly. At least for 95% of the people.
But of course, if the video plays on the screen people can just use a screen recorder and some simple software to record sound from the audio output (but he/she will have to play the ENTIRE thing to save it, totally inconvenient).
You can't stop image/video theft but you can make harder for normal users but you can't make it harder for the programmers like us (I mean thieves that know little web programming).
There are some tricks you can try:
1.) Using flash as YouTube and many others sites like http://www.funnenjoy.com does.
2.) Div overlaping or background pic setting (but users with little sense can easily save all resources by opening inspect element or other developer option).
3.) You can disable right click and specific keys like CTRL + S and others possibles with JavaScript but main drawback is that if user disable JavaScript our all tricks fail down.
4.) Save image in none online directories (if you have full access to web server) and read that files with server side languages like PHP every time when image / video is required and change image id time to time or create script that can automatically change ID after every access.
5.) Use .htaccess in apache to prevent linking of your images by others sites. you can use this site to automatically generate .htacess http://www.htaccesstools.com/hotlink-protection/
Insert a transparent gif 1px x 1px just inside the <body> tag:
<body><img src="route-to-images/blim.gif" class="blimover">
Then style it with this:
.blimover {
width: 100% !important;
height: 100% !important;
z-index: 1000 !important;
position: absolute !important;
top: 0 !important;
left: 0 !important;
}
This will remove any click functionality from a page, but it sure stops people stealing any content!
You can apply the same to a <div>, <section>, <article> etc, just name accordingly and prevent your copy and/or images being ripped.
Nothing stops a screengrab though ... ...
If you want only authorised users to get the content, both the client and the server need to use encryption.
For video and audio, a good solution is Azure Media Services, which has content protection and encryption. You embed the Azure media player in your browser and it streams the video from Azure.
For documents and email, you can look at Azure Rights Management, which uses a special client. It doesn't currently work in ordinary web browsers, unfortunately, except for one-off, single-use codes.
I'm not sure exactly how secure all this is, however. As others have pointed out, from a security point of view, once those downloaded bytes are in the "attacker's" RAM, they're as good as gone. No solution is 100% secure in this case (please correct me if I'm wrong). As with most security, the goal is to make it harder, so the 99% don't bother.
I think the best way is to prevent right clicking on your webpage, because that is the most convenient way a normal user try to download the content, and you can consider it as remark if u able to do this only as you are never gonna be able to stop a computer geek or hacker people from downloading it, because once the content is on the internet, it means it is in the public domain already...
Put the content on google drive and make it download protect. This way people can only see your documents, pictures but cannot download it.
DRM solutions are available today. It makes the video viewable but not downloadable.
What is DRM?
Digital Rights Management (DRM) solutions are software programs created to help people protect and control their valuable digital content, whether it's documents, videos, images, or audio files.
Check out this. Hope it's helpful.