Javascript API Credentials – Just a port

July 17th, 2014 No comments

There is not much to write than to attribute the logic up to a post on online code generator. Well since this was written in php and I needed the same in javascript, there was some cutting corners, and finally the script which is attached came up.

randomstring

 

The vars defined hold the two array of strings, and the function generates the key. Calling the function with genKey(16, access_salt) will generate a 16 char random string from the defined array access_salt.

Random String JS (16)
Categories: Code Snippets, Javascript Tags:

Script to redirect based on date or time or day of the week

May 20th, 2014 No comments

Recently made a mistake by accepting a project before the initial milestone was deposited. Though I completed the project, the client did not pay, instead commented SCAM and deleted the project. So I am posting this over here hoping that the beggar will pick from here. Or this will be of use to some one.

This is not much of a magic or php expertise. The configuration area requires a default configuration with the tag ( index ) ’0′ and then on the indexes have some meanings. A four digit will be treated as time. Eg ’1200′ will take as 12 noon and any time after that unless another time is configured. But if you put ’1170′ that will also be taken as 12 noon and continue. If put ‘Tuesday’ any day that falls on Tuesday will use that configuration. Again a blank configuration means not to show anything.
Read more…

Categories: Code Snippets, PHP Tags:

WooCommerce – APG SMS Notifications – Add Mvayoo

February 19th, 2014 1 comment

This sparked off after a mail by a colleague turned out with a very quick reply by the original authors. The nutshell was that “We’re sorry, but we can’t spent more free time with our plugins”. Well that is quite justifyable. But the donation requested was way too much for our considerations. And today morning I just sat down with an insight to look deeper into the original code by Art Project Group. Thanks to the Google Translator, and the wonderful code by the Art Project Group. Should not forget the contributions of one of my old colleague Niju NB, for creating the mVaayoo api as a php class. The whole integration took less than 15 minutes with all the available peripherals.
Read more…

Categories: Wordpress Plugins Tags:

Setting session timestamp limited to script scope in PHP

September 24th, 2013 No comments

Lets start with analyzing a use case. Well at Saturn we required to run a cron
job which was written in php, with a lot of use for date functions, every day
starting Jan 1 2001 to Dec 31 2012. I did not dig much into override_function
to change the behavior of the date function, instead a small class was written
to handle the ticks, but the loop was run using a history table in mysql.

Read more…

Categories: Code Snippets, PHP, Tips Tags:

RSA encryption in PHP decryption in .NET

September 12th, 2013 2 comments

If the subject is searched on the net, the basic issue that pops up would be “bad key” exception or decryption issue. If you have access to the original code with which the implementation is done, then you should be able to identify the mismatch. But for the time, quoting root.org for RSA padding , RSA requires the plaintext to be armored during encryption/signing and the result to be verified during decryption/verification. Unfortunately, this armoring is commonly called “padding”, which means some implementers think it functions like ordinary protocol padding. The interoperability principle (“be strict in what you send and lenient in what you accept”) is exactly opposite how public key crypto must be implemented. Padding cannot be ignored and if even one bit is out of place, the message is invalid. Failure to implement all the steps correctly could allow attackers to forge signatures, decrypt ciphertext, or even recover the private key. Read more…

Categories: PHP Tags:

Securing Web Applications – Best Practices

July 10th, 2013 No comments

Finding your web site hacked and defaced one fine moring would be a nightmare for any web application developer. For securing from the same there are some recommendations. Through out the past years, we have summarized our strategy on the expectation that this would help others to build applications that are difficult to penetrate. Mostly the content of the article would be refering to PHP scripting language, and most others should not be any different.

Read more…

Categories: Code Snippets Tags:

MsSQL Export to CSV

April 2nd, 2013 No comments

In the near past I got frustrated searching for a tool to export from MsSQL express to proper CSV. As always the frustration lead me to google, and found the post on stackoverflow and to digital point forums and a lot of other places. All these had some or the other issues with us. One being the MsSQL not hosted on our servers and we dont have access to the GUI tools, the second is that I am a bit towards the fag end when Microsoft Technologies are in the anvil. Finally there was no other way and what I did was to migrate our PHP MySQL wrapper to support MsSQL.

Read more…

Categories: PHP, Tips Tags: , ,

PHP MyProfiler as a WordPress Plugin

March 11th, 2013 No comments

The profiler and sampler has been bundled into a single download, but is now two wordpress plugins. Though this has issues that this will be plugged into the wordpress flow after init and that logging is done on shutdown hook, some of the database calls are never logged. Still that is not an issue as mostly slowness would be caused by database calls from the theme and plugins. Note that logging may make system more slow and this is for identifying the bottlenecks and should never be left on for long times. Features like Log requests from IP, Log requests from IP to specific URL, Enable/Disable, Log Frequency are in the wishlist. Currently when you enable, the profiler starts logging, and creates new file for every hour. This is stored into the UPLOAD_DIR/wp_php_my_profiler with <Year-month-date-hour>.log as filename, and posted into the $wpdb-posts table with post_status = private, and post_type = profiler_log, Once logging is done, and before going for analysis, better deactivate the Profiler. Log Analyzer creates a menu entry in the admin side, and shows the logs from the $wpdb->posts table with the above properties in a tabular form, with actions ‘Analyze’ and ‘Delete’. The plugin is provided for advanced users and debuggers to find issues and bottlenecks in their plugins or themes. Download the plugin PHP MyProfiler Wordpress Plugin (531)

Categories: PHP, Wordpress Plugins Tags:

Just activated bz2url with WP to Twitter

March 2nd, 2012 1 comment

We just activated our url compressor WP to Twitter. Trying to enable the WP to Twitter to work with the bz2 compressor. In fact this is a test post for the same. The WP to Twitter is simply superb, thankyou Doleson.
Read more…

Categories: Code Snippets Tags:

bz2url – a very simple url compressor for wordpress

February 24th, 2012 No comments

Its been over a year since we started bz2.in url compression for inhouse projects at Saturn and is being in use for Asianet India and this blog. Recently for a new project we absolutely needed an integrated url shortner, which finally gave shape to the initial version.
Read more…