NAME Drupal::Credentials - Access credentials (user, pass etc.) from Drupal's sites directory (settings.php) VERSION Version 0.02 SYNOPSIS Access info from Drupal's $db_uri contained in settings.php use Drupal::Credentials; #new Drupal::Credentials::Symlinks='follow';#default is dontfollow my $credentials = Drupal::Credentials->new($site_dir); foreach my $site_id ($credentials->list) { my $dbstring=$credentials->get_dbstring($site_id); my $proto=$credentials->get_scheme($site_id); my $passw=$credentials->get_pass($site_id); my $db=$credentials->get_database($site_id); my $host=$credentials->get_host($site_id); my $user=$credentials->get_user($site_id); #new: my $dir=$credentials->get_install_dir ($site_id); } my $sites_dir=$credentials->get_sites_dir; METHODS my $credentials = Drupal::Credentials->new($site_dir); $site_dir is the full path to the drupal/sites directory. Returns the Drupal::Credentials object on success and nothing on failure. $credentials->_parse_sites_dir Reads the directory specified as sites_dir during new, and looks for subdirectories which a setting.php file in them. Settings.php file is searched for $db_url from which the credentials are extracted. TODO: Currently, always returns 1. Should be able to fail my $host=$credentials->get_host($site_id); Return host from credentials. my $pw=$credentials->get_pass($site_id); Return pass from credentials for site with $site_id. my $proto=$credentials->get_scheme($site_id); Return scheme from credentials for site with $site_id. my $un=$credentials->get_user($site_id); Return user from credentials for site with $site_id. my $db=$credentials->get_database($site_id); Return database from credentials for site with $site_id. my $dbstring=$credentials->get_dbstring($site_id); Return string from settings.php's $db_uri for site with $site_id. This one will not be unescaped, if it uses hex encoding (e.g. %2a for :). I suspect that this method is not of real use except for debugging. my $credentials->list; Return site ids in an array. A site id is the name of the directory in sites directory, e.g. exampledomain.com (In code site id is sometimes referred to as site name.) my $sites_dir=$credentials->get_install_dir; Return path for the installation (in Drupal's site directory). At the moment, it can be relative or absolute path. Todo: Do i need an absolute path? my $sites_dir=$credentials->get_sites_dir; Return Drupal's path for site as specified during new. SEE ALSO http://php.net/manual/en/function.parse-url.php Drupal's settings.php AUTHOR Maurice Mengel, "<mauricemengel at gmail.com>" BUGS Please report any bugs or feature requests to "bug-drupal-credentials at rt.cpan.org", or through the web interface at <http://rt.cpan.org/NoAuth/ReportBug.html?Queue=Drupal-Credentials>. I will be notified, and then you'll automatically be notified of progress on your bug as I make changes. SUPPORT You can find documentation for this module with the perldoc command. perldoc Drupal::Credentials You can also look for information at: * RT: CPAN's request tracker <http://rt.cpan.org/NoAuth/Bugs.html?Dist=Drupal-Credentials> * AnnoCPAN: Annotated CPAN documentation <http://annocpan.org/dist/Drupal-Credentials> * CPAN Ratings <http://cpanratings.perl.org/d/Drupal-Credentials> * Search CPAN <http://search.cpan.org/dist/Drupal-Credentials/> INSTALLATION To install this module, run the following commands: perl Makefile.PL make make test make install LICENSE AND COPYRIGHT Copyright 2010 Maurice Mengel. This program is free software; you can redistribute it and/or modify it under the terms of either: the GNU General Public License as published by the Free Software Foundation; or the Artistic License. See http://dev.perl.org/licenses/ for more information.
mokko/Drupal-Credentials
Access credentials (user, pass etc.) from Drupal's sites directory (settings.php)
PHP