Added secure functions to libs directories of php and ruby cartridges

Copied secure generation files from the drupal/wordpress and rails templates. These can be used in any php and ruby applications.