Added password change to plesk
This commit is contained in:
36
application/classes/lnapp/pwgen.php
Normal file
36
application/classes/lnapp/pwgen.php
Normal file
@@ -0,0 +1,36 @@
|
||||
<?php defined('SYSPATH') or die('No direct access allowed.');
|
||||
|
||||
/**
|
||||
* This class is for providing password from a password genarator
|
||||
*
|
||||
* @package lnApp
|
||||
* @subpackage PWGen
|
||||
* @category Helpers
|
||||
* @author Deon George
|
||||
* @copyright (c) 2010 Deon George
|
||||
* @license http://dev.leenooks.net/license.html
|
||||
*/
|
||||
abstract class lnApp_PWgen {
|
||||
public static function get($pwonly=TRUE) {
|
||||
if (! Kohana::Config('pwgen.host') OR ! Kohana::Config('pwgen.port'))
|
||||
throw new Kohana_Exception('No configuration for host or port (:host/:port)',array(':host'=>Kohana::Config('pwgen.host'),':port'=>Kohana::Config('pwgen.port')));
|
||||
|
||||
$ps = socket_create(AF_INET,SOCK_STREAM,0);
|
||||
if (! socket_connect($ps,Kohana::Config('pwgen.host'),Kohana::Config('pwgen.port')))
|
||||
throw new Kohana_Exception('Unable to connect to password server');
|
||||
|
||||
// echo "Reading response:\n\n";
|
||||
$pw = '';
|
||||
while ($out = socket_read($ps,64))
|
||||
$pw .= rtrim($out);
|
||||
|
||||
// echo "Closing socket...";
|
||||
socket_close ($ps);
|
||||
|
||||
list($passwd,$passwdSay) = explode(' ',$pw);
|
||||
// print " Password [$passwd] ($passwdSay) [$pw] ".md5($passwd)."<BR>";
|
||||
|
||||
return $pwonly ? $passwd : array('pw'=>$passwd,'say'=>$passwdSay);
|
||||
}
|
||||
}
|
||||
?>
|
4
application/classes/pwgen.php
Normal file
4
application/classes/pwgen.php
Normal file
@@ -0,0 +1,4 @@
|
||||
<?php defined('SYSPATH') or die('No direct access allowed.');
|
||||
|
||||
class PWGen extends lnApp_PWGen {}
|
||||
?>
|
Reference in New Issue
Block a user