[geeklog-cvs] Auth_Enterprise AEUtility.class.php,1.1.1.1,1.2 ServerLog.txt,1.1.1.1,1.2 index.php,1.1.1.1,1.2 log.txt,1.1.1.1,1.2

tony at geeklog.net tony at geeklog.net
Tue Oct 28 19:52:42 EST 2003


Update of /usr/cvs/geeklog/Auth_Enterprise
In directory geeklog_prod:/tmp/cvs-serv1664

Modified Files:
	AEUtility.class.php ServerLog.txt index.php log.txt 
Log Message:
Authenticate method nearly complete using XML_RPC

Index: AEUtility.class.php
===================================================================
RCS file: /usr/cvs/geeklog/Auth_Enterprise/AEUtility.class.php,v
retrieving revision 1.1.1.1
retrieving revision 1.2
diff -C2 -d -r1.1.1.1 -r1.2
*** AEUtility.class.php	23 Oct 2003 14:17:34 -0000	1.1.1.1
--- AEUtility.class.php	29 Oct 2003 00:52:40 -0000	1.2
***************
*** 1,190 ****
  <?php
! 
! /**
! * Auth_Enterprise
! *
! * This source file is subject to version 2.02 of the PHP license,
! * that is bundled with this package in the file LICENSE, and is
! * available at through the world-wide-web at
! * http://www.php.net/license/2_02.txt.
! * If you did not receive a copy of the PHP license and are unable to
! * obtain it through the world-wide-web, please send a note to
! * license at php.net so we can mail you a copy immediately.
! *
! * @author Tony Bibbs <tony at geeklog.net>
! * @copyright 2003
! * @version $Id$
! *
! */
! 
! /**
! * PEAR object, need it mostly for PEAR_Error class
  */
  require_once 'PEAR.php';
! 
! /**
! * PEAR Log class for error and debug messages
! */
  require_once 'Log.php';
! 
! /**
! * This utility class can hold odd ball methods that don't quite fit in a class of their own
! * but need to used by quite a bit.
! *
! * This class uses PEAR::Log to log messages. 
! *
! * @author Tony Bibbs <tony at geeklog.net>
! * @package net.geeklog.auth_enterprise
! *
! */
! class AEUtility {
!     /**
!     * Logs a message to the log file
!     *
!     * @author Tony Bibbs <tony at geeklog.net>
!     * @access public
!     * @param string $message Message to log
!     * @param string $file File that is logging the message
!     * @param int $line Line number in $file that logged the message
!     * @param int $priority Priority of this log message.
!     *
!     */
!     function logMessage($message, $callingFile, $callingLine, $priority = PEAR_LOG_INFO, $identifier = '', $logToBrowser = false)
!     {
!         $logger = &Log::singleton('file', AE_LOGFILE, $identifier);
!         if ($priority > AE_LOGLEVEL) {
!             return;
!         }
!         if (is_a($message, 'PEAR_Error')) {
!             $userinfo = $message->getUserInfo();
!             $message = $message->getMessage();
!             if (!empty($userinfo)) {
!                 if (is_array($userinfo)) {
!                     $userinfo = implode(', ', $userinfo);
!                 }
!                 $message .= ': ' . $userinfo;
!             }
          }
- 
          $message = "\n\tFile:" . $callingFile . "\n\tLine:" . $callingLine . "\n\tMessage:  " . $message;
!         
!         // Make sure to log in the system's locale.
!         $locale = setlocale(LC_TIME, 0);
!         setlocale(LC_TIME, 'C');
!         
          $logger->log($message, $priority);
!         
!         if ($logToBrowser) {
!             print nl2br($message);
!         }
! 
!         // Restore original locale.
!         setlocale(LC_TIME, $locale);
! 
!         return true;
      }
!     
!     /**
!     * Logs an object to the log file
!     *
!     * @author Tony Bibbs <tony at geeklog.net>
!     * @access public
!     *
!     */
!     function logObject($someObj, $fileName, $lineNum)
!     {
!         ob_start();
!         print_r($someObj);
!         $strObj = ob_get_contents();
!         ob_end_clean();
!         
!         AEUtility::logMessage($strObj, $fileName, $lineNum);
!         return;
      }
!     
!     /**
!     * Actually handles PEAR errors and errors we trigger in our PHP code
!     *
!     * @author Tony Bibbs <tony at geeklog.net>
!     * @access public
!     * @param int $errno Error Number
!     * @param string $errmsg Error Message
!     * @param string $fileName File that error occurred in
!     * @param int $lineNum Line in $fileName that error occurred on
!     * @param array $vars All variables in memory when the error occurred
!     *
!     */
!     function handleError($errno, $errmsg, $fileName, $lineNum, $vars, $doVarDump)
!     {
!         // Only handle sane errors
          if (!in_array($errno, array(2,256,512,1024))) return;
!             
!         // define an assoc array of error string
!         // in reality the only entries we should
!         // consider are 2,8,256,512 and 1024
!         $errorType = array (
!                     1   =>  'Error',
!                     2   =>  'Warning',
!                     4   =>  'Parsing Error',
!                     8   =>  'Notice',
!                     16  =>  'Core Error',
!                     32  =>  'Core Warning',
!                     64  =>  'Compile Error',
!                     128 =>  'Compile Warning',
!                     256 =>  'User Error',
!                     512 =>  'User Warning',
!                     1024=>  'User Notice'
                      );
!         // set of errors for which a var trace will be saved
!         $userErrors = array(E_USER_ERROR, E_USER_NOTICE);
!         
!         $errText = "\n\t\tError Number: $errno\n\t\tError Type: {$errorType[$errno]}\n\t\tError Message: $errmsg\n\t";
!         if (($doVarDump) AND in_array($errno, $userErrors)) {
!             $errText .= "Variable Dump:\n\t";
!             ob_start();
!             for ($i = 1; $i <= count($vars); $i++) {
!                 print_r(current($vars));
!                 
!                 $errText .= "\t\t" . key($vars) . ' = ' . nl2br(ob_get_contents());
!                 ob_clean();
!                 next($vars);
!             }
!             ob_end_clean();
!         }
!         AEUtility::logMessage($errText, $fileName, $lineNum, $priority = PEAR_LOG_ERR, $identifier = '*ERROR*');
!     }
  }
! 
! /**
! * Error handler
! *
! * PHP's set_error_handler can't take a class method as an argument so this
! * does so in a round about way.  NOTE: if you want this method to dump all
! * variables in memory to the log file you nee to change $varDump to true
! *
! * @author Tony Bibbs <tony at geeklog.net>
! * @param int $errno Error number
! * @param string $errmsg Error message
! * @param string $filename File where error occured
! * @param string $linenum Line number in $filename wher error occured
! * @param array $vars All variables and their values in memory
! *
! */
! function AEErrorHandler($errno, $errmsg, $filename, $linenum, $vars)
! {
!     // Set this to true if you want all variables in memory dumped.
!     // NOTE: do NOT use this in production...it will fill the log quickly.
      $varDump = false;
!     
!     // Call the utility error handler
!     AEUtility::handleError($errno, $errmsg, $filename, $linenum, $vars, $varDump);
  }
! 
! // Force errors triggered in our code to use our error handler
! set_error_handler('AEErrorHandler');
! 
! // Force PEAR classes to call our error handler
  PEAR::setErrorHandling(PEAR_ERROR_CALLBACK, 'AEErrorHandler');
- 
- 
  ?>
--- 1,170 ----
  <?php
! /**
! * Auth_Enterprise
! *
! * This source file is subject to version 2.02 of the PHP license,
! * that is bundled with this package in the file LICENSE, and is
! * available at through the world-wide-web at
! * http://www.php.net/license/2_02.txt.
! * If you did not receive a copy of the PHP license and are unable to
! * obtain it through the world-wide-web, please send a note to
! * license at php.net so we can mail you a copy immediately.
! *
! * @author Tony Bibbs <tony at geeklog.net>
! * @copyright 2003
! * @version $Id$
! *
  */
+ /**
+ * PEAR object, need it mostly for PEAR_Error class
+ */
  require_once 'PEAR.php';
! /**
! * PEAR Log class for error and debug messages
! */
  require_once 'Log.php';
! /**
! * This utility class can hold odd ball methods that don't quite fit in a class of their own
! * but need to used by quite a bit.
! *
! * This class uses PEAR::Log to log messages. 
! *
! * @author Tony Bibbs <tony at geeklog.net>
! * @package net.geeklog.auth_enterprise
! *
! */
! class AEUtility {
!     /**
!     * Logs a message to the log file
!     *
!     * @author Tony Bibbs <tony at geeklog.net>
!     * @access public
!     * @param string $message Message to log
!     * @param string $file File that is logging the message
!     * @param int $line Line number in $file that logged the message
!     * @param int $priority Priority of this log message.
!     *
!     */
!     function logMessage($message, $callingFile, $callingLine, $priority = PEAR_LOG_INFO, $identifier = '', $logToBrowser = false)
!     {
!         $logger = &Log::singleton('file', AE_LOGFILE, $identifier);
!         if ($priority > AE_LOGLEVEL) {
!             return;
!         }
!         if (is_a($message, 'PEAR_Error')) {
!             $userinfo = $message->getUserInfo();
!             $message = $message->getMessage();
!             if (!empty($userinfo)) {
!                 if (is_array($userinfo)) {
!                     $userinfo = implode(', ', $userinfo);
!                 }
!                 $message .= ': ' . $userinfo;
!             }
          }
          $message = "\n\tFile:" . $callingFile . "\n\tLine:" . $callingLine . "\n\tMessage:  " . $message;
!         // Make sure to log in the system's locale.
!         $locale = setlocale(LC_TIME, 0);
!         setlocale(LC_TIME, 'C');
          $logger->log($message, $priority);
!         if ($logToBrowser) {
!             print nl2br($message);
!         }
!         
!         // Restore original locale.
!         setlocale(LC_TIME, $locale);
!         return true;
      }
!     /**
!     * Logs an object to the log file
!     *
!     * @author Tony Bibbs <tony at geeklog.net>
!     * @access public
!     *
!     */
!     function logObject($someObj, $fileName, $lineNum)
!     {
!         ob_start();
!         print_r($someObj);
!         $strObj = ob_get_contents();
!         ob_end_clean();
!         AEUtility::logMessage($strObj, $fileName, $lineNum);
!         return;
      }
!     /**
!     * Actually handles PEAR errors and errors we trigger in our PHP code
!     *
!     * @author Tony Bibbs <tony at geeklog.net>
!     * @access public
!     * @param int $errno Error Number
!     * @param string $errmsg Error Message
!     * @param string $fileName File that error occurred in
!     * @param int $lineNum Line in $fileName that error occurred on
!     * @param array $vars All variables in memory when the error occurred
!     *
!     */
!     function handleError($errno, $errmsg, $fileName, $lineNum, $vars, $doVarDump)
!     {
!         // Only handle sane errors
          if (!in_array($errno, array(2,256,512,1024))) return;
!         // define an assoc array of error string
!         // in reality the only entries we should
!         // consider are 2,8,256,512 and 1024
!         $errorType = array (
!                     1   =>  'Error',
!                     2   =>  'Warning',
!                     4   =>  'Parsing Error',
!                     8   =>  'Notice',
!                     16  =>  'Core Error',
!                     32  =>  'Core Warning',
!                     64  =>  'Compile Error',
!                     128 =>  'Compile Warning',
!                     256 =>  'User Error',
!                     512 =>  'User Warning',
!                     1024=>  'User Notice'
                      );
!         // set of errors for which a var trace will be saved
!         $userErrors = array(E_USER_ERROR, E_USER_NOTICE);
!         $errText = "\n\t\tError Number: $errno\n\t\tError Type: {$errorType[$errno]}\n\t\tError Message: $errmsg\n\t";
!         if (($doVarDump) AND in_array($errno, $userErrors)) {
!             $errText .= "Variable Dump:\n\t";
!             ob_start();
!             for ($i = 1; $i <= count($vars); $i++) {
!                 print_r(current($vars));
!                 $errText .= "\t\t" . key($vars) . ' = ' . nl2br(ob_get_contents());
!                 ob_clean();
!                 next($vars);
!             }
!             ob_end_clean();
!         }
!         AEUtility::logMessage($errText, $fileName, $lineNum, $priority = PEAR_LOG_ERR, $identifier = '*ERROR*');
!     }
  }
! /**
! * Error handler
! *
! * PHP's set_error_handler can't take a class method as an argument so this
! * does so in a round about way.  NOTE: if you want this method to dump all
! * variables in memory to the log file you nee to change $varDump to true
! *
! * @author Tony Bibbs <tony at geeklog.net>
! * @param int $errno Error number
! * @param string $errmsg Error message
! * @param string $filename File where error occured
! * @param string $linenum Line number in $filename wher error occured
! * @param array $vars All variables and their values in memory
! *
! */
! function AEErrorHandler($errno, $errmsg, $filename, $linenum, $vars)
! {
!     // Set this to true if you want all variables in memory dumped.
!     // NOTE: do NOT use this in production...it will fill the log quickly.
      $varDump = false;
!     // Call the utility error handler
!     AEUtility::handleError($errno, $errmsg, $filename, $linenum, $vars, $varDump);
  }
! // Force errors triggered in our code to use our error handler
! set_error_handler('AEErrorHandler');
! 
! // Force PEAR classes to call our error handler
  PEAR::setErrorHandling(PEAR_ERROR_CALLBACK, 'AEErrorHandler');
  ?>

Index: ServerLog.txt
===================================================================
RCS file: /usr/cvs/geeklog/Auth_Enterprise/ServerLog.txt,v
retrieving revision 1.1.1.1
retrieving revision 1.2
diff -C2 -d -r1.1.1.1 -r1.2
*** ServerLog.txt	23 Oct 2003 14:17:34 -0000	1.1.1.1
--- ServerLog.txt	29 Oct 2003 00:52:40 -0000	1.2
***************
*** 0 ****
--- 1,5346 ----
+ Oct 27 19:42:04  [info] 
+ 	File:c:\program files\apache group\apache\htdocs\projects\auth_enterprise\server\xmlrpc\index.php
+ 	Line:66
+ 	Message:  Instantiating server
+ Oct 27 19:42:04  [info] 
+ 	File:c:\program files\apache group\apache\htdocs\projects\auth_enterprise\server\xmlrpc\index.php
+ 	Line:50
+ 	Message:  Array
+ (
[...5317 lines suppressed...]
+     [_password] => foo
+     [_accountLocked] => 
+     [_failedAttempts] => 0
+     [_lastPWChange] => 1038344984
+     [_privileges] => 
+     [_groups] => Array
+         (
+             [0] => aegroup Object
+                 (
+                     [_groupId] => 1
+                     [_groupLogicalName] => TEST_GROUP
+                     [_groupDisplayName] => TEST GROUP ONLY FOR TESTING
+                     [_groupDesc] => This user can modify anything within the A&A application
+                     [_privileges] => 
+                 )
+ 
+         )
+ 
+ )
+ 

Index: index.php
===================================================================
RCS file: /usr/cvs/geeklog/Auth_Enterprise/index.php,v
retrieving revision 1.1.1.1
retrieving revision 1.2
diff -C2 -d -r1.1.1.1 -r1.2
*** index.php	23 Oct 2003 14:17:34 -0000	1.1.1.1
--- index.php	29 Oct 2003 00:52:40 -0000	1.2
***************
*** 1,38 ****
  <?php
! 
! define('AE_LOGFILE','C:/Program Files/Apache Group/Apache/htdocs/projects/Auth_Enterprise/log.txt');
! define('AE_LOGLEVEL',7);
! require_once 'Auth_Enterprise/AEUtility.class.php';
  require_once 'Auth_Enterprise/Client/AEClient.class.php';
! $userId = 'tony at tonybibbs.com';
! $password = 'foo';
! $appId = 'AE_TEST_APP_PEAR';
! $method = AE_XML_RPC;
! $server = 'localhost';
! $path = '/Auth_Enterprise/Server/XMLRPC/';
  $port = 80;
! 
! AEUtility::logMessage('Calling authenticate',__FILE__,__LINE__);
! $userObj = AEClient::authenticate($userId, $password, $appId, $method, $server, $path, $port);
  AEUtility::logMessage('Returned from authenticate',__FILE__,__LINE__);
- 
  print_r($userObj);
! 
! /*
! require_once 'XML/RPC.php';
! $f=new XML_RPC_Message('Auth_Enterprise.processRequest', array(new XML_RPC_Value($myVar, 'string')));
! $c=new XML_RPC_Client('/A_and_A/service/XMLRPC_index.php', 'localhost', 80);
! $r=$c->send($f);
! if ($r->faultCode()) {
!     print "Fault: \n";
!     print "Code: " . $r->faultCode() . 
!     " \nReason '" .$r->faultString()."'<BR>";
!     exit;
  }
! $v=$r->value();
! print $v->scalarval();
! print htmlentities($r->serialize());
  */
- 
- 
  ?>
--- 1,34 ----
  <?php
! define('AE_LOGFILE','C:/Program Files/Apache Group/Apache/htdocs/projects/Auth_Enterprise/log.txt');
! define('AE_LOGLEVEL',7);
! 
! require_once 'Auth_Enterprise/AEUtility.class.php';
  require_once 'Auth_Enterprise/Client/AEClient.class.php';
! $userId = 'tony at tonybibbs.com';
! $password = 'foo';
! $appId = 'AE_TEST_APP_PEAR';
! $method = AE_XML_RPC;
! //$method = AE_LOCALHOST;
! $server = 'localhost';
! $path = '/Auth_Enterprise/Server/XMLRPC/';
  $port = 80;
! AEUtility::logMessage('Calling authenticate',__FILE__,__LINE__);
! $userObj = AEClient::authenticate($userId, $password, $appId, $method, $server, $path, $port);
  AEUtility::logMessage('Returned from authenticate',__FILE__,__LINE__);
  print_r($userObj);
! /*
! require_once 'XML/RPC.php';
! $f=new XML_RPC_Message('Auth_Enterprise.processRequest', array(new XML_RPC_Value($myVar, 'string')));
! $c=new XML_RPC_Client('/A_and_A/service/XMLRPC_index.php', 'localhost', 80);
! $r=$c->send($f);
! if ($r->faultCode()) {
!     print "Fault: \n";
!     print "Code: " . $r->faultCode() . 
!     " \nReason '" .$r->faultString()."'<BR>";
!     exit;
  }
! $v=$r->value();
! print $v->scalarval();
! print htmlentities($r->serialize());
  */
  ?>

Index: log.txt
===================================================================
RCS file: /usr/cvs/geeklog/Auth_Enterprise/log.txt,v
retrieving revision 1.1.1.1
retrieving revision 1.2
diff -C2 -d -r1.1.1.1 -r1.2
*** log.txt	23 Oct 2003 14:17:34 -0000	1.1.1.1
--- log.txt	29 Oct 2003 00:52:40 -0000	1.2
***************
*** 0 ****
--- 1,2740 ----
+ Oct 25 14:57:11  [info] 
+ 	File:c:\program files\apache group\apache\htdocs\projects\auth_enterprise\index.php
+ 	Line:29
+ 	Message:  Calling authenticate
+ Oct 25 14:57:11  [info] 
+ 	File:c:\Program Files\Apache Group\Apache\htdocs\projects\Auth_Enterprise\Client\AEClient.class.php
+ 	Line:195
+ 	Message:  Inside client authentication method
+ Oct 25 14:57:11  [info] 
[...2711 lines suppressed...]
+                         )
+ 
+                     [mytype] => 1
+                 )
+ 
+             [3] => xml_rpc_value Object
+                 (
+                     [me] => Array
+                         (
+                             [string] => foo
+                         )
+ 
+                     [mytype] => 1
+                 )
+ 
+         )
+ 
+     [debug] => 0
+ )
+ 





More information about the geeklog-cvs mailing list