Skip to main content

Posts

Showing posts with the label PHP

Node.js vs PHP response time metrics

I recently did a small Hello World Time Metric Test to see response time on Node.js and PHP and plotted the graph to see the performance difference between the two. PHP was hosted on a LAMP stack while node.js was downloaded via apt-get install. Instructions can be found on http://nodejs.org . The node.js script was simple hello world script: var http = require('http'); http.createServer(function (req, res) {   res.writeHead(200, {'Content-Type': 'text/plain'});   res.end('Hello World\n'); }).listen(1337, "127.0.0.1"); console.log('Server running at http://127.0.0.1:1337/'); While the PHP script used was: echo "Hello World"; ?> The tester script was: $j=0; while($j<100) { $time1=microtime(true); $i=0; while($i<10000) {     file_get_contents("http://localhost/hello.php"); $i++; } $time2=microtime(true); print($time2-$time1); print(' '); $j++; } Any gu...

Joomla Module JTweetSearch.

I recently created a Joomla Module to search Twitter for a particular configurable query and display all the results of the matching query but without tweets having any link on them. The module is available on the link http://biplav.saraf.googlepages.com/mod_jtweetsearch.zip Its easy to install. And uses Jquery to give a nice fade and sliding effect. The demo of this module can be seen on http://www.vtunews.in . with the module on the right named VTU Tweets. This is just the version 1.0 of the module. Incase you find any bugs please report. Feature enhancement request can also be reported on the comment section of this blog. so happy tweeting or i can be reached on twitter @biplavs

XSS vulnerability

Cross-site scripting (XSS) is a type of computer security vulnerability typically found in web applications which enable malicious attackers to inject client-side script into web pages viewed by other users. An exploited cross-site scripting vulnerability can be used by attackers to bypass access controls such as the same origin policy. One common way to solve is: Ensure that parameters and user input are sanitized by doing the following: # Remove # Remove > input and replace with > # Remove ' input and replace with ' # Remove " input and replace with " # Remove ) input and replace with ) # Remove ( input and replace with (

How to send JSON object using JQUERY to PHP?

After struggling for hours and googling more, finally i succeeded in commincating over Json object. I will share the code: JS side: var datastring=JSON.stringify(obj); $.post('getmessage.php',{data:datastring},function(res){ alert("HIIII"+res); },"text"); }); php side: $data=json_decode(stripslashes($_REQUEST['data']),true); echo $data['page']; ?>