JavaScript Hidden iFrame comet - javascript

I need to implement comet, preferably with the hidden "forever iFrame" technique using PHP to instantly update a file on the server and get data from that file (and then JavaScript would use that data to manipulate the webpage). I have been searching for a detailed example for how to do something like this. Much of what I have found I do not understand or I think is not applicable. I am not fluent in PHP, yet.
If anyone knows or knows how to find a detailed example of this or could make one, I would be much obliged.

I'm sure this is close to what you want:
http://code.jenseng.com/jenChat/
The guy even mocks the technique as preposterously outdated, but it's exactly what you need. Be warned, as I seem to remember, there's a little bug in the actual code which stops it from working out the box, like some erroneous filehandle.
Get back to me here if you can't spot it. I can assure you the code works perfectly once the error is spotted. I think it's in chat.php, I'm checking.

Related

Is this safe to use to hide code from view code / inspect?

Kindly looking to hide code from view code / inspect element is this safe to use ? I saw this anser here How to hide form code from view code/inspect element browser?
eval(function(p,a,c,k,e,d){e=function(c){return
c.toString(36)};if(!''.replace(/^/,String)){while(c--)
{d[c.toString(a)]=k[c]||c.toString(a)}k=[function(e){return
d[e]}];e=function(){return'\\w+'};c=1};while(c--)
{if(k[c]){p=p.replace(new RegExp('\\b'+e(c)+'\\b','g'),
k[c])}}return p}('(3(){(3 a(){8{(3 b(2)
{7((\'\'+(2/2)).6!==1||2%5===0){(3(){}).9(\'4\')()}
c{4}b(++2)})(0)}d(e){g(a,f)}})()})();',17,17,'
||i|function|debugger|20|length|if|try|constructor
|||else|catch||5000|setTimeout'.split('|'),0,{}))
In an answer about as useful as the question,
"No".
Most of us can't read the code because it is packed/obfuscated, and won't invest the time to try to read it.
If you're asking if it will prevent the user from opening the Developer Tools, then I don't know, because that would require me trying to run the code, which I'm not going to do, since I can't read the code and it could be malicious.
If you're asking if it will prevent someone from obtaining the rest of the code on your website, then no, it will not. A determined user could use curl or one of several other tools to retrieve the raw HTML or Javascript.
If you're asking if the code pasted above is secure because it is packed, then no, it is not. A determined user could quite easily analyze the code by hand and, once analyzed, write something to reverse engineer the packed code (that's assuming it uses an unknown packer -- if it uses a well-known packer, then someone has probably already written something to reverse it).
Is there a way to prevent the theft of a website's code?
One can never fully block a determined user from analyzing your code, only make things more annoying from them.
Simply using a minifier/uglifier on Javascript is usually enough to make the code mostly worthless to try to steal, since the cost of trying to analyze, rewrite it and further develop it is usually comparable to the cost of writing the same code from scratch.

Async loading of some generated Javascript

I work for a small company that isn't flexible in making changes on using a heavy themed webpage on Wordpress for their own reasons. They are also using a load of plugins, and it takes more than 10 seconds to load. So, I thought I should give it a try and check the generated homepage source code, after I ran the analysis that tells me that js is just a disaster.
The theme they had chosen was Unero, because it works with woocommerce I suppose. The website is a small e-shop along with a blog, nothing too fancy really, we use yoast SEO too, but that might be irrelevant.
I realized that there is a load of js scripts running here and there.
I read that you can set everything run with async set true.
A also read that this can cause things to break between scripts, due to undefined variables and other problems I suppose. Please note that I am kinda new to js technologies and I might not know what I really should be asking, or searching for. I do my best to explain what I need to happen though.
Is there a way you can override ( or overload, what is the term
here?)some js on footer, after being defined on their positon
(in HEAD and in BODY),setting it to async mode, by using a snippet
on footer? Will this actually work?
I do not want to involve any plugin general solutions, because I am
afraid they will break stuff as mentioned above. Correct me if I am
wrong and please suggest me something. Except if the solution IS to make a custom plugin, where I will have full control I guess.
I am open on ANY suggestions, as long as it won't break the site.
I am asking here and not on Wordpress Developement or any other Stack Exchange forum, because I am looking for a solution done by hand, along with an explaination why it will work. I am a code by hand guy really, and I am not afraid to dive deeper on something, if things are gonna be done right.
Is there a way you can override ( or overload, what is the term
here?)some js on footer, after being defined on their positon (in HEAD
and in BODY),setting it to async mode, by using a snippet on footer?
Will this actually work?
Answer: Yes, its possible but that could also happen with sync code. If plugin A is doing something like $('title').text('Title from A') and then the next plugin does $('title').text('Title from B')then its gonna get overridden, doesn't matter if its sync or async.
I do not want to involve any plugin general solutions, because I am
afraid they will break stuff as mentioned above. Correct me if I am
wrong and please suggest me something.
Answer: I am not sure what you want to do. What is your goal with this site? Do you want to untangle the mess of the plugins? That can be difficult since you have little control over the plugins and their mechanismm.
I am open on ANY suggestions, as long as it won't break the site.
Answer: One way would be to disable them one by one to see cause and effect and try to clean out that way. Another solution would to switch to more simple solution like Shopify and the third to creaate a custom solution that you have more control over.
Its quite an open question, so its kinda of hard to give a concrete answer or solution to your problem.

Display Comic Book files on a webpage?

I'm thinking about creating a webpage and I'm trying to brainstorm some ways to display them in the page.
If i wanted to get dirty and create everything myself, i think i could do it with html5, CSS3, and javascript/jquery. Just do some kind of page buttons with an image tag and maybe get into some more detailed stuff as it comes up (i dont know how i would do zooming and multiple pages).
But wahat i really want to know is if there is already some way to do this? I've looked around for a bit and cant seem to find any sort of plugin that would read a cbz file or display an set of images with the 'e-reader' type of tools in mind. Just wondering if anyone knows of anything?
Thanks
I used to use an online reader for a long time so I started an experiment to build one myself a while back: netcomix
It's open source so you can see if you find anything appealing in what I did. I figured I'd do all the real UI work client side with HTML, CSS, and JavaScript and the server was strictly responsible for acting as a service (for example, to supply a list of comics or a list of all the pages in a particular issue) and serving up the individual JPG/PNG/GIF files. That compartmentalized things nicely and I was very pleased with how jQuery BBQ gave me a history that I could back through even though I stayed on one page the whole time.
Now if I were to do the same experiment again, I'd use Backbone.js to give some structure to the client side and obviously it needs a lot of love because the server side really does nothing at the moment. Early versions were strictly hard coded although I started putting in some simple SQL stuff in there in the latest version. It's nothing more than an experiment though and should be treated as such. It's there for ideas and little else. If you find it interesting and want some more ideas contact me and I'll be happy to let you know all my wacky ideas for such a program.
I know this is an old question. But web technologies have gotten better in the last few years. There are several comic book readers that can work in the browser using pure HTML and JavaScript. I wrote one called: http://comic-book-reader.com .
If you want to see a very simple example of how to read CBR and CBZ files in the browser. You should check out http://workhorsy.github.io/uncompress.js/examples/simple/index.html which uses the JavaScript library https://github.com/workhorsy/uncompress.js

JavaScript/jQuery google style website preview

I remember following a like off of here a little while ago for something called shark.js or sharpe.js (but I might be wrong on the name). I've tried googling it, looking through here, my browser history and I have had no luck. It wasn't wkhtmltopdf, I know that much. Does anybody know what it might be called or what I am talking about? Have you got a link to it please?
Stack overflow Question: jQuery Webpage Preview
From the second answer:
http://craigsworks.com/projects/qtip/demos/content/thumbnail
That should be what your looking for, don't know if it's the exact same thing, but same functionality.
Not sure how this can be done in client side javascript in real-time. However, I bet Google uses a server-side process to capture a screenshot and then uses javascript to request an image to display to the client.

Help with screen scraping/parsing

I have been attempting to scrape and eventually parse some data(specifically availabilities and price) from hostels.com, for example http://www.hostels.com/hosteldetails.php/HostelNumber.11890. The problem is, once you select the number of nights and select "book now" nothing is passed through the URL string(its all done through Ajax, I belive) I cant go directly to a specific date or time frame.
I have attempted browser emulators such as Selenium, IRobotSoft and FakeApp and although I did get Selenium and Fake to do much of the work capturing the full source, it was ugly and still tedious when having to scrape(and parse with other software) multiple pages a day.
I have also tried HTML DOM Parser, PHP Scriptable Web Browser, HTMLUnit, cScrape.php, Crowbar. Either they couldn't handle the Ajax or I had no luck getting even them to run.
Ideally I would like something that can run from a server, with as few dependencies as possible, but at this point I would just like to get it running.
Now after spending many hours trying to get this working. I still feel I'm not sure where to begin. Can someone just point me in the right direction?. Should I go back and spend more time with HTMLUnit? what would be the best practice for a site like this?
Thanks
I'm really into Node.js atm (server-side javascript, in case you're not familiar), so that's what I'm recommending. What's awesome about using it to scrape sites is you can use jQuery or whatever your favorite JS framework is to do all the work of parsing for the info you want! See the following resources to get started:
http://blog.dtrejo.com/scraping-made-easy-with-jquery-and-selectorga
https://github.com/tmpvar/jsdom
https://github.com/chriso/node.io/wiki/Scraping
https://github.com/joshfire/node-crawler
The page you are referring to does not seem to be using AJAX. Instead what you are referring to as AJAX is a POST request (as opposed to stuff passed in the url, which is a GET request). I suggest you read up on difference between them. Try to understand what going on, it is more important than relying on some third-party tool which might turn out to be very inflexible.
Install Firebug and watch which variables are sent in the POST request.
Now do the same thing in your favourite programming language. Parse the response HTML for the POST request for the necessary information.
Also, +1 for the effort of trying so many different solutions and not giving up.
I've found Celerity (http://celerity.rubyforge.org), a JRuby library that uses HTMLUnit under the hood, to be a very robust solution for "data acquisition via the Web".
Celerity being Ruby, I found, was much faster to develop with in comparison to full blown Java (HTMLUnit). Also, due to Celerity's "wrapping" of HTMLUnit -- I was able to drop down to HTMLUnit as I needed to do some heavier lifting.
I've had success with sites that are rich in DHTML, as well as utilize Ajax; and while I made have used some sleep() calls to wait on the Ajax responses -- everything worked as expected.
Give it a try!

Categories

Resources