Zend - The PHP Company




Miscellaneous

Add Code


Interface to poppassd  

Type: class
Added by: jcostom
Entered: 03/03/2000
Last modified: 05/12/2000
Rating: ***** (6 votes)
Views: 6550
This class provides an interface to poppassd, a commonly used daemon to enable password changes via the network, particularly using the Eudora mail client. Take care to ensure the safety of your password data in transit! I recommend using this script only over SSL.


<?
/*

Copyright (c) 2000, Jason Costomiris
All rights reserved.

Don't be scared, it's just a BSD-ish license.

Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions
are met:

1. Redistributions of source code must retain the above copyright notice,
   this list of conditions and the following disclaimer.
2. Redistributions in binary form must reproduce the above copyright notice,
   this list of conditions and the following disclaimer in the
   documentation and/or other materials provided with the distribution.
3. All advertising materials mentioning features or use of this software
   must display the following acknowledgement:
   This product includes software developed by Jason Costomiris.
4. The name of the author may not be used to endorse or promote products
   derived from this software without specific prior written permission.

THIS SOFTWARE IS PROVIDED BY THE AUTHOR COPYRIGHT HOLDERS AND CONTRIBUTORS
``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 
ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

*/

    
Class poppass {

        function 
err_handle($err) {
            
$this->error $err;
            
printf("Error: %sn<BR>n"$this->error);
            exit;
        }

        function 
setuser($user){
            
$this->user $user;
        }

        function 
setserver($server){
            
$this->server $server;
        }

        function 
oldpass($oldpass){
            
$this->oldpass $oldpass;
        }

        function 
newpass($newpass1$newpass2) {
            if (
$newpass1 == $newpass2) {
                
$this->newpass $newpass1;
            } else {
                
$this->err_handle("New password not confirmed.");
            }
        }

        function 
logit($line){
            
/* Log transactions */
            
$date date('d M Y H:i:s');
            
openlog("[php-poppass]"LOG_PIDLOG_LOCAL7);
            
syslog(LOG_INFO"$line");
            
closelog();
        }

        function 
getline($filepointer) {
            
/* Make sure status is always 200, else error out. */
            
$output fgets($filepointer128);
            
$v substr($output03);
            if (
$v != 200){
                
$this->err_handle("Error: $output");
            }
        }

        function 
connect() {
            
$fp fsockopen($this->server106, &$errno , &$errstr30);
            if(!
$fp) {
                
$this->err_handle("Cannot connect to $this->server");
            } else {
                
$this->getline($fp);
                
$this->fp $fp;
            }
        }

        function 
login() {
            
fputs($this->fp"user $this->usern");
            
$this->getline($this->fp);
        }

        function 
sendoldpass() {
            
fputs($this->fp"pass $this->oldpassn");
            
$this->getline($this->fp);
        }

        function 
sendnewpass() {
            
fputs($this->fp"newpass $this->newpassn");
            
$this->getline($this->fp);
        }

        function 
close() {
            
fputs($this->fp"quitn");
            
fclose($this->fp);
        }
        
    }
?>



Usage Example


<?
    
require("poppass.php");
    
$pop = new poppass;
    
$pop->setuser("username");
    
$pop->setserver("server.yourcompany.com");
    
$pop->oldpass("oldpasswd");
    
$pop->newpass("newpasswd""newpasswd");
    
$pop->connect();
    
$pop->login();
    
$pop->sendoldpass();
    
$pop->sendnewpass();
    
$pop->close();
?>


Rate This Script





Search



This Category All Categories