Pure JavaScript Append Text to File [closed] - javascript

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
Questions asking for code must demonstrate a minimal understanding of the problem being solved. Include attempted solutions, why they didn't work, and the expected results. See also: Stack Overflow question checklist
Closed 9 years ago.
Improve this question
Is it possible to append text to an existing textfile using only javaScript?

No. Browser JavaScript does not have access to the local file system for security reasons.

It does not have "arbitrary" access to the file system but it can in fact read/write local files from, eg, the browser cache directory. If you have full access to the client machine you could take advantage of this via a background script to synchronise temporary files to specific locations on the client. There are also techniques using local HTTP server daemons or modified browsers.
Of course if you wanted a "pure" JS solution the obvious question is how such a thing could be done without turning the browser into a premier malware installation system (well, assuming the browser isn't like IE that performs this task already).

As stated, not possible with pure JS. But it is possible if you use XMLHttprequest.
http://www.javascripter.net/faq/reading2.htm

Related

Hide JS Library [closed]

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
We don’t allow questions seeking recommendations for books, tools, software libraries, and more. You can edit the question so it can be answered with facts and citations.
Closed 1 year ago.
Improve this question
I'm creating a web based application and I got a JS library containing all my JS functions. If I try to open the library via browser I can see the source code. Is there a way to obfuscate it or deny the access to the file to users?
No, AFAIK there isn't, because the server cannot see whether the browser requests the JS file to execute it or to display its source code to the user. The only thing you can do is to minify your JS file; the browser will still execute it, but for the user it's hard to read it. But it's not hard for anyone to un-minify / tidy it.
EDIT: If you have access to the server, you can configure it to compress your JS file before sending it to the browser - The browser decompresses it for execution. I don't know though if the browser will decompress it too, when the file is viewed directly. If he would, it wouldn't make any sense to compress it (except for slightly faster load times).
You can minify and obfuscate but you cannot deny access to the file because the browser will load it along with your webpage.

How can my website store strings locally? [closed]

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
Questions asking for code must demonstrate a minimal understanding of the problem being solved. Include attempted solutions, why they didn't work, and the expected results. See also: Stack Overflow question checklist
Closed 9 years ago.
Improve this question
I have made a website where the user can create a design and then fill in a form. All the data is saved as strings. The website is not on a server so the only way to access it is locally, via the source files.
I was wondering; how can i save those strings locally, without a database. Basically; i hae string that need to be saved, even after the page is refreshed. Maybe the strings can be save to a text file or something.
Any ideas? Thanks for the help!
ps, written everything in html, css and javascript.
You can use localStorage, or a browser embedded database, like IndexedDB or WebSQL. These will store data inside your browser, so it wont be shared with anyone.
Maybe you can save it to a .ini file? This is easily done with PHP and the string will be stored locally. This thread can help you further

How can i pack javascript via php like javascriptobfuscator.com [closed]

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
Questions asking for code must demonstrate a minimal understanding of the problem being solved. Include attempted solutions, why they didn't work, and the expected results. See also: Stack Overflow question checklist
Closed 9 years ago.
Improve this question
if i put below javascript in javascriptobfuscator.com
Before
var a="Hello World!";
function MsgBox(msg){
alert(msg+"\n"+a);
}
MsgBox("OK");
it returns below packed javascript
After
var _0xd429=["\x48\x65\x6C\x6C\x6F\x20\x57\x6F\x72\x6C\x64\x21","\x0A","\x4F\x4B"];
var a=_0xd429[0];function MsgBox(_0xdb32x3){alert(_0xdb32x3+_0xd429[1]+a);};
MsgBox(_0xd429[2]);
how can i make same functionality in php.
Static asset minifying and file merges are accomplished automatically in many web frameworks (in Rails this concept is called the "asset pipeline"). You need to use a framework that has an asset minification/compilation scheme that suits you, otherwise either
use a build tool that watches your codebase and executes automatically if you change any files
write a build script and execute it yourself when creating a build
Assetic seems to be a PHP tool of choice that does all this for you.
https://github.com/kriswallsmith/assetic
Also, Asset Pipeline/Framework for PHP
I beg the question
Why do you want to secure your javascript?
Just making it unreadable to humans does not mean someone with aspbergers or with enough motivation to deobfuscate it cannot.
If you are protecting your script because you don't want people to recycle it, then minify (manually or automatically through frameworks and plugins).
If you have other security concerns then I think your time is better spent elsewhere
Sorry if this sounds harsh but I wasted a lot of time on this before realizing how futile and useless this endeavour turned out to be

Implementing protection for source images [closed]

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
This question does not appear to be about a specific programming problem, a software algorithm, or software tools primarily used by programmers. If you believe the question would be on-topic on another Stack Exchange site, you can leave a comment to explain where the question may be able to be answered.
Closed 8 years ago.
Improve this question
While browsing I came across this link
As you can see image is protected, if you browse cars-database.com you take source image and you will get the same message.
This is first time I see this and I wonder how this has been implemented? Does anybody know?
Screenshot of protected source image:
Here's a simple example on how to implement something similar in nginx:
location ~ \.(jpe?g|png|gif)$ {
valid_referers none blocked mysite.com *.mysite.com;
if ($invalid_referer) {
rewrite ^ http://mysite.com/lowres$request_uri permanent;
}
}
They likely simply have two versions of the image stored on the server, the "real" one and one with the extra message added via a Photoshop template or something. They then employ a check for the Referer header like:
if request for image and referer is not cars-database.com/*
then serve "watermarks/$requestedImage$"
This can be implemented trivially with an Apache mod_rewrite rule, any other web server's rule system or any server-side programming language like PHP, Python or whatnot.

Am I allowed to run a javascript runtime (like v8) on the iPhone? [closed]

Closed. This question is off-topic. It is not currently accepting answers.
Want to improve this question? Update the question so it's on-topic for Stack Overflow.
Closed 10 years ago.
Improve this question
According to this discussion, the iphone agreement says that it doesn't allow "loading of plugins or running interpreted code that has been downloaded".
Technically, I would like to download scripts from our server (embedded in a proprietary protocol).
Does this mean I wouldn't be allowed to run a runtime like v8 in an iphone app?
This is probably more of a legal question.
I think your interpretation is correct - You would not be allowed to download and execute JavaScript code in v8.
If there were some way to run the code in an interpreter already on the iPhone (i.e. the javascript engine in MobileSafari) then that would be permitted I think.
This is partially a technical question too. V8 as currently implemented won't run on the iPhone. No JIT-based VM will.
Well I embedded Lua into my application already and am programming most of the login in Lua and then downloading it to my iPhone for fast iteration, but this is only intended during development. Once I ship the scripts will be placed in the source and compiled into byte-code shipped along with the app just like any other resource.
I'd say this applies to V8 aswell.
I concur. My reading is also that DOWNLOADED scripts are not allowed. Pre-installed and user-written scripts are fine. But it is a fine distinction and IANAL etc etc.

Categories

Resources