Source for file wpDirAuth.php

Documentation is available at wpDirAuth.php

  1. <?php
  2. /**
  3.  * wpDirAuth: WordPress Directory Authentication (LDAP/LDAPS).
  4.  * 
  5.  * Works with most LDAP enabled directory services, such as OpenLDAP,
  6.  * Apache Directory, Microsoft Active Directory, Novell eDirectory,
  7.  * Sun Java System Directory Server, etc.
  8.  * 
  9.  * Please note that wpDirAuth will start in safe mode if it detects that
  10.  * another plugin is in conflict, by detecting if the wp_login and
  11.  * wp_setcookie functions have already been overwritten. It cannot,
  12.  * on the other hand, detect plugins that might want to overwrite these
  13.  * functions after wpDirAuth has been loaded.
  14.  * 
  15.  * Originally forked from a patched version of wpLDAP.
  16.  * 
  17.  * @package wpDirAuth
  18.  * @version 1.0
  19.  * @see http://tekartist.org/labs/wordpress/plugins/wpdirauth/
  20.  * @license GPL <http://www.gnu.org/licenses/gpl.html>
  21.  * 
  22.  * Copyrights are listed in chronological order, by contributions.
  23.  * 
  24.  * wpDirAuth: WordPress Directory Authentication
  25.  * Copyright (c) 2007 Stephane Daury - http://stephane.daury.org/
  26.  * 
  27.  * wpDirAuth and wpLDAP Patch Contributions
  28.  * Copyright (c) 2007 PKR Internet, LLC - http://www.pkrinternet.com/
  29.  *  
  30.  * wpDirAuth Patch Contributions
  31.  * Copyright (c) 2007 Todd Beverly
  32.  *  
  33.  * wpLDAP: WordPress LDAP Authentication
  34.  * Copyright (c) 2007 Ashay Suresh Manjure - http://ashay.org/
  35.  *  
  36.  * wpDirAuth is free software: you can redistribute it and/or modify it
  37.  * under the terms of the GNU General Public License as published by the
  38.  * Free Software Foundation.
  39.  * 
  40.  * wpDirAuth is distributed in the hope that it will be useful,
  41.  * but WITHOUT ANY WARRANTY; without even the implied warranty of
  42.  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  43.  * GNU General Public License for more details.
  44.  * 
  45.  * You should have received a copy of the GNU General Public License
  46.  * along with this program.  If not, see http://www.gnu.org/licenses/.
  47.  * 
  48.  * @todo Always stay on top of security and user input validation while
  49.  * staying backwards compatible enough until PHP4 support is dropped in
  50.  * WP (serious patches welcomed, please see code). Note that we do
  51.  * heavily rely on WP's admin ACL scheme, by necessity.
  52.  */
  53.  
  54. /*
  55. PLUGIN META INFO FOR WORDPRESS LISTINGS
  56. Plugin Name: wpDirAuth
  57. Plugin URI:  http://tekartist.org/labs/wordpress/plugins/wpdirauth/
  58. Description: WordPress Directory Authentication (LDAP/LDAPS).
  59.              Works with most LDAP enabled directory services, such as OpenLDAP,
  60.              Apache Directory, Microsoft Active Directory, Novell eDirectory,
  61.              Sun Java System Directory Server, etc.
  62.              Originally revived and upgraded from a patched version of wpLDAP.
  63. Version: 1.0
  64. Author: Stephane Daury [and whoever wants to help]
  65. Author URI: http://stephane.daury.org/
  66. */
  67.  
  68. /**
  69.  * wpDirAuth version.
  70.  */
  71. define('WPDIRAUTH_VERSION''1.0');
  72.  
  73. /**
  74.  * wpDirAuth signature.
  75.  */
  76. define('WPDIRAUTH_SIGNATURE''<a href="http://tekartist.org/labs/wordpress/plugins/wpdirauth/">wpDirAuth</a> '.WPDIRAUTH_VERSION);
  77.  
  78. /**
  79.  * Default LDAP field to search against when locating the user's profile.
  80.  */
  81. define('WPDIRAUTH_DEFAULT_FILTER''samAccountName');
  82.  
  83. /**
  84.  * Default login screen message.
  85.  */
  86. define('WPDIRAUTH_DEFAULT_LOGINSCREENMSG''%s members can login directly using their institutional password.');
  87.  
  88. /**
  89.  * Default password change message.
  90.  */
  91. define('WPDIRAUTH_DEFAULT_CHANGEPASSMSG''To change a %s password, please refer to the official institutional password policy.');
  92.  
  93. /**
  94.  * Allowed HTML (messages)
  95.  */
  96. define('WPDIRAUTH_ALLOWED_TAGS''<a><strong><em><p><ul><ol><li>');
  97.  
  98.  
  99. if (function_exists('wp_login'|| function_exists('wp_setcookie'|| !function_exists('ldap_connect')) {
  100. /**
  101.  * SAFE MODE
  102.  */
  103.     
  104.     /**
  105.      * SAFE MODE: wpDirAuth plugin configuration panel.
  106.      * Processes and outputs the wpDirAuth configuration form, with a conflict message.
  107.      * 
  108.      * @return void
  109.      */
  110.     function wpDirAuth_safeConflictMessage()
  111.     {
  112.         $wpDARef WPDIRAUTH_SIGNATURE;
  113.         
  114.         if (!function_exists('ldap_connect')) {
  115.             $message = <<<________EOS
  116.             <h3>Sorrybut your PHP install does not seem to have access to the LDAP features.</h3>
  117.             <p>
  118.                 <br />wpDirAuth is now running in safe mode.'
  119.             </p>
  120.             <p>
  121.                 Quote from the <a href="http://php.net/ldap#ldap.installation">PHP manual LDAP section</a>:
  122.                 <blockquote>
  123.                      LDAP support in PHP is not enabled by defaultYou will need to use the
  124.                      --with-ldap[=DIRconfiguration option when compiling PHP to enable LDAP
  125.                      supportDIR is the LDAP base install directoryTo enable SASL support,
  126.                      be sure --with-ldap-sasl[=DIRis usedand that sasl.h exists on the system.
  127.                 </blockquote>
  128.             </p>
  129. ________EOS;
  130.         }
  131.         else {
  132.             $message = <<<________EOS
  133.             <h3>Sorrybut another plugin seems to be conflicting with wpDirAuth.</h3>
  134.             <p>
  135.                 <br />wpDirAuth is now running in safe mode as to not impair the other plugin's operations.'
  136.             </p>
  137.             <p>
  138.                 The wp_login and wp_setcookie WordPress
  139.                 <a href="http://codex.wordpress.org/Pluggable_Functions">pluggable functions</a>
  140.                 have already been redefinedand wpDirAuth cannot provide directory authentication
  141.                 without having access to these functions.
  142.             </p>
  143.             <p>
  144.                 Please disable any WP plugins that deal with authentication in order to use wpDirAuth.
  145.                 Unfortunatelywe cannot provide you with more info as to which plugin is in conflict.
  146.             </p>
  147. ________EOS;
  148.         }
  149.         
  150.         echo <<<________EOS
  151.         <div class="wrap">
  152.             <h2>Directory Authentication OptionsPlugin Conflict</h2>
  153.             $message
  154.             <p>$wpDARef</p>
  155.         </div>        
  156. ________EOS;
  157.     }
  158.     
  159.  
  160.     /**
  161.      * SAFE MODE: Adds the `Directory Auth.` menu entry in the Wordpress Admin section.
  162.      * Also activates the wpDirAuth config panel, with a conflict message, as a callback function.
  163.      * 
  164.      * @uses wpDirAuth_safeConflictMessage
  165.      */
  166.     function wpDirAuth_safeAddMenu(
  167.     {
  168.         if (function_exists('add_options_page')) {
  169.             add_options_page(
  170.                 'Directory Authentication Options: Plugin Conflict',
  171.                 '!! Directory Auth. !!',
  172.                 9,
  173.                 basename(__FILE__),
  174.                 'wpDirAuth_safeConflictMessage'
  175.             );
  176.         }
  177.     }
  178.  
  179.  
  180.     /**
  181.      * SAFE MODE: Add custom WordPress actions.
  182.      * 
  183.      * @uses wpDirAuth_safeAddMenu
  184.      */
  185.     if (function_exists('add_action')) {
  186.         add_action('admin_menu''wpDirAuth_safeAddMenu');
  187.     }    
  188. }
  189. else {
  190. /**
  191.  * STANDARD MODE
  192.  */
  193.  
  194.     /**
  195.      * Cookie marker.
  196.      * Generates a random string to be used as salt for the password
  197.      * hash cookie checks in wp_setcookie and wp_login
  198.      *
  199.      * @return string 55 chars-long salty goodness (md5 + uniqid)
  200.      */
  201.     function wpDirAuth_makeCookieMarker()
  202.     {
  203.         $cookieMarker md5(
  204.              $_SERVER['SERVER_SIGNATURE']
  205.             .$_SERVER['HTTP_USER_AGENT']
  206.             .$_SERVER['REMOTE_ADDR']
  207.         ).uniqid(microtime(),true);
  208.         update_option("dirAuthCookieMarker",$cookieMarker);
  209.         return $cookieMarker;
  210.     }
  211.     
  212.     
  213.     /**
  214.      * LDAP bind test
  215.      * Tries two different documented method of php-based ldap binding.
  216.      * Note: passing params by reference, no need for copies (unlike in
  217.      * wpDirAuth_auth where it is desirable).
  218.      * 
  219.      * @param object &$connection LDAP connection
  220.      * @param string &$username LDAP username
  221.      * @param string &$password LDAP password
  222.      * @return boolean Binding status
  223.      *      */
  224.     function wpDirAuth_bindTest(&$connection&$username&$password)
  225.     {
  226.         if ( ($isBound @ldap_bind($connection$username$password)) === false {
  227.             // @see wpLDAP comment at http://ashay.org/?page_id=133#comment-558
  228.             $isBound @ldap_bind($connection,"uid=$username,$baseDn"$password);
  229.         }
  230.         return $isBound;
  231.     }
  232.  
  233.     
  234.     /**
  235.      * Custom LDAP authentication module.
  236.      * The returned keys are in the same format used by WP for
  237.      * the wp_insert_user and wp_update_user functions.
  238.      *
  239.      * @param string $username LDAP username
  240.      * @param string $password LDAP password
  241.      * @return boolean false OR array Directory email, last_name and first_name
  242.      * 
  243.      * @uses WPDIRAUTH_DEFAULT_FILTER
  244.      * @uses wpDirAuth_bindTest
  245.      */
  246.     function wpDirAuth_auth($username$password)
  247.     {
  248.         global $error$pwd;
  249.         
  250.         $errorTitle '<strong>'.__('Directory Login Error').'</strong>: ';
  251.         
  252.         $controllers      explode(','get_option('dirAuthControllers'));
  253.         $baseDn           get_option('dirAuthBaseDn');
  254.         $accountSuffix    get_option('dirAuthAccountSuffix');
  255.         $filter           get_option('dirAuthFilter');
  256.         $enableSsl        get_option('dirAuthEnableSsl');
  257.         
  258.         $returnKeys array('sn''givenname''mail');
  259.     
  260.         $isBound $isLoggedIn false;
  261.         
  262.         if (count($controllers1{
  263.             // shuffle the domain controllers for pseudo load balancing and fault tolerance.
  264.             shuffle($controllers);
  265.         }
  266.         elseif (count($controllers== 0{
  267.             $error $errorTitle
  268.                    . __(' wpDirAuth config error: no domain controllers specified.');
  269.             $pwd '';
  270.             return false;
  271.         }
  272.         
  273.         if ($accountSuffix$username .= $accountSuffix;
  274.     
  275.         $protocol ($enableSsl'ldaps' 'ldap';
  276.         
  277.         if (!$filter$filter WPDIRAUTH_DEFAULT_FILTER;
  278.         
  279.         $filterQuery "($filter=$username)";
  280.         
  281.         // Connection pool loop - Haha, PooL LooP 
  282.         foreach ($controllers as $dc{
  283.             /**
  284.              * The lack of conditional check at the ldap_connect() level below
  285.              * is because with php and openldap 2.x, the ldap_connect() will
  286.              * always return a resource as it does not actually connect but just
  287.              * initializes the connecting parameters. The actual connection happens
  288.              * with the following ldap_bind() which is itself wrapped in a
  289.              * conditional check.
  290.              * @see Notes at http://php.net/ldap_connect
  291.              */
  292.             $connection @ldap_connect($protocol.'://'.$dc);
  293.             /**
  294.              * Copes with W2K3/AD issue.
  295.              * @see http://bugs.php.net/bug.php?id=30670
  296.              */
  297.             if (@ldap_set_option($connectionLDAP_OPT_PROTOCOL_VERSION3)) {
  298.                 @ldap_set_option($connectionLDAP_OPT_REFERRALS0);
  299.             }
  300.             /**
  301.              * Attempt bind, both anonymously or with credentials (see cases)
  302.              */ 
  303.             if ( ($isBound wpDirAuth_bindTest($connection$username$password)) === true {
  304.                 /**
  305.                  * Use case 1: Servers that will not let you bind anonymously
  306.                  * altogether.
  307.                  * @see http://groups.google.com/group/wpdirauth-support/browse_thread/thread/8fd16c05266fc832
  308.                  * @see wpDirAuth_bindTest
  309.                  */
  310.                 $isLoggedIn true;
  311.                 break;
  312.             }
  313.             elseif ( ($isBound @ldap_bind($connection)) === true {
  314.                 /**
  315.                  * Use case 2: Servers that might require a full user DN to
  316.                  * actually login and therefore let you bind anonymously first .
  317.                  * Try ldap_search + ldap_get_dn before attempting a login.
  318.                  * @see http://wordpress.org/support/topic/129814?replies=34#post-603644
  319.                  */
  320.                 if ( ($results @ldap_search($connection$baseDn$filterQuery$returnKeys)) !== false {
  321.                     if ( ($userDn @ldap_get_dn($connectionldap_first_entry($connection$results))) !== false {
  322.                         $username $userDn;
  323.                     }
  324.                 }
  325.                 break;
  326.             }
  327.         }
  328.         
  329.         if (!$isBound{
  330.             $error $errorTitle
  331.                    . __(' No directory server available for authentication.');
  332.             $pwd '';
  333.             return false;
  334.         }
  335.         elseif ( ($isLoggedIn === false&& ( ($isBound wpDirAuth_bindTest($connection$username$password)) === false ) ) {
  336.             $error $errorTitle
  337.                    . __(' Could not authenticate user. Please check your credentials.')
  338.                    . " [$username]";
  339.             $pwd '';
  340.             return false;
  341.         }
  342.         else {
  343.             /**
  344.              * Search for profile, if still needed.
  345.              * @see Preceding loop: Use case 1 with anonymous ldap_search
  346.              *      failure or use case 2 and 3 in loop above)
  347.              */
  348.             if (!$results$results @ldap_search($connection$baseDn$filterQuery$returnKeys);
  349.             
  350.             if (!$results{
  351.                 $error $errorTitle
  352.                        . __('Directory authentication initially succeeded, but no
  353.                              valid profile was found (search procedure).')
  354.                        ." [$filter]";
  355.                 $pwd '';
  356.                 return false;
  357.             }
  358.             else{
  359.                 $userInfo @ldap_get_entries($connection$results);
  360.                 
  361.                 $count intval($userInfo['count']);
  362.                 if ($count 1{
  363.                     $error $errorTitle
  364.                            . __('Directory authentication initially succeeded, but no
  365.                                  valid profile was found ("get entries" procedure).')
  366.                            ." [$filter]";
  367.                     $pwd '';
  368.                     return false;
  369.                 }
  370.                 elseif ($count 1{
  371.                     $error $errorTitle
  372.                            . __('Directory authentication initially succeeded, but the
  373.                                  username you sent is not a unique profile identifier.')
  374.                            . " [$filter]";
  375.                     $pwd '';
  376.                     return false;
  377.                 }
  378.                 else {
  379.                     $email     = isset($userInfo[0]['mail'][0])
  380.                                ? $userInfo[0]['mail'][0'';
  381.                     
  382.                     $lastName  = isset($userInfo[0]['sn'][0])
  383.                                ? $userInfo[0]['sn'][0'';
  384.                     
  385.                     $firstName = isset($userInfo[0]['givenname'][0])
  386.                                ? $userInfo[0]['givenname'][0'';
  387.         
  388.                     return array(
  389.                         'email'      => $email,
  390.                         'last_name'  => $lastName,
  391.                         'first_name' => $firstName
  392.                     );
  393.                 }
  394.             }
  395.         }
  396.     }
  397.     
  398.     
  399.     /**
  400.      * Runs stripslashes, html_entity_decode, then strip_tags with
  401.      * allowed html if requested.
  402.      *  
  403.      * No input sashimi for us (hopefully).
  404.      *
  405.      * @param string $value Value to `sanitize`
  406.      * @param boolean $allowed Set to true for WPDIRAUTH_ALLOWED_TAGS
  407.      * @return string Cleaner value.
  408.      * 
  409.      * @uses WPDIRAUTH_ALLOWED_TAGS
  410.      */
  411.     function wpDirAuth_sanitize($value$allowed false)
  412.     {
  413.         $allowed ($allowedWPDIRAUTH_ALLOWED_TAGS '';
  414.         return strip_tags(html_entity_decode(stripslashes($value))$allowed);
  415.     }
  416.     
  417.     
  418.     /**
  419.      * wpDirAuth plugin configuration panel.
  420.      * Processes and outputs the wpDirAuth configuration form.
  421.      * 
  422.      * @return void
  423.      * 
  424.      * @uses WPDIRAUTH_DEFAULT_FILTER
  425.      * @uses WPDIRAUTH_DEFAULT_LOGINSCREENMSG
  426.      * @uses WPDIRAUTH_DEFAULT_CHANGEPASSMSG
  427.      * @uses WPDIRAUTH_ALLOWED_TAGS
  428.      * @uses wpDirAuth_makeCookieMarker
  429.      * @uses wpDirAuth_sanitize
  430.      */
  431.     function wpDirAuth_optionsPanel()
  432.     {
  433.         global $userdata;
  434.         
  435.         $wpDARef     WPDIRAUTH_SIGNATURE;
  436.         $allowedHTML htmlentities(WPDIRAUTH_ALLOWED_TAGS);
  437.         
  438.         $curUserIsDirUser get_usermeta($userdata->ID'wpDirAuthFlag');
  439.         
  440.         if ($curUserIsDirUser{
  441.             echo <<<____________EOS
  442.             <div class="wrap">
  443.                 <h2>Directory Authentication Options</h2>
  444.                 <p>
  445.                     Because any changes made to directory authentication
  446.                     options can adversly affect your session when logged in
  447.                     as a directory useryou must be logged in as a
  448.                     WordPress-only administrator user to update these settings.
  449.                 </p>
  450.                 <p>
  451.                     If such a user no longer exists in the databaseplease
  452.                     <a href="./users.php#add-new-user">create a new one</a>
  453.                     using the appropriate WordPress admin tool.
  454.                 </p>
  455.                 <p>$wpDARef</p>
  456.             </div>        
  457. ____________EOS;
  458.             return;
  459.         }
  460.         
  461.         if ($_POST{
  462.             // Booleans
  463.             $enable         intval($_POST['dirAuthEnable'])      == 0;
  464.             $enableSsl      intval($_POST['dirAuthEnableSsl'])   == 0;
  465.             $requireSsl     intval($_POST['dirAuthRequireSsl'])  == 0;
  466.             $TOS            intval($_POST['dirAuthTOS'])         == 0;
  467.  
  468.             // Strings, no HTML
  469.             $controllers    wpDirAuth_sanitize($_POST['dirAuthControllers']);
  470.             $baseDn         wpDirAuth_sanitize($_POST['dirAuthBaseDn']);
  471.             $accountSuffix  wpDirAuth_sanitize($_POST['dirAuthAccountSuffix']);
  472.             $filter         wpDirAuth_sanitize($_POST['dirAuthFilter']);
  473.             $institution    wpDirAuth_sanitize($_POST['dirAuthInstitution']);
  474.  
  475.             // Have to be allowed to contain some HTML
  476.             $loginScreenMsg wpDirAuth_sanitize($_POST['dirAuthLoginScreenMsg']true);
  477.             $changePassMsg  wpDirAuth_sanitize($_POST['dirAuthChangePassMsg']true);
  478.             
  479.             update_option('dirAuthEnable',         $enable);
  480.             update_option('dirAuthEnableSsl',      $enableSsl);
  481.             update_option('dirAuthRequireSsl',     $requireSsl);
  482.             update_option('dirAuthControllers',    $controllers);
  483.             update_option('dirAuthBaseDn',         $baseDn);
  484.             update_option('dirAuthAccountSuffix',  $accountSuffix);
  485.             update_option('dirAuthFilter',         $filter);
  486.             update_option('dirAuthInstitution',    $institution);
  487.             update_option('dirAuthLoginScreenMsg'$loginScreenMsg);
  488.             update_option('dirAuthChangePassMsg',  $changePassMsg);
  489.             update_option('dirAuthTOS',            $TOS);
  490.     
  491.             if (get_option('dirAuthEnable'&& !get_option('dirAuthCookieMarker')) {
  492.                 wpDirAuth_makeCookieMarker();
  493.             }
  494.             
  495.             echo '<div id="message" class="updated fade"><p>Your new settings were saved successfully.</p></div>';
  496.         }
  497.         else {        
  498.             // Booleans
  499.             $enable         intval(get_option('dirAuthEnable'))     == 0;
  500.             $enableSsl      intval(get_option('dirAuthEnableSsl'))  == 0;
  501.             $requireSsl     intval(get_option('dirAuthRequireSsl')) == 0;
  502.             $TOS            intval(get_option('dirAuthTOS'))        == 0;
  503.             
  504.             // Strings, no HTML
  505.             $controllers    wpDirAuth_sanitize(get_option('dirAuthControllers'));
  506.             $baseDn         wpDirAuth_sanitize(get_option('dirAuthBaseDn'));
  507.             $accountSuffix  wpDirAuth_sanitize(get_option('dirAuthAccountSuffix'));
  508.             $filter         wpDirAuth_sanitize(get_option('dirAuthFilter'));
  509.             $institution    wpDirAuth_sanitize(get_option('dirAuthInstitution'));
  510.             
  511.             // Have to be allowed to contain some HTML
  512.             $loginScreenMsg wpDirAuth_sanitize(get_option('dirAuthLoginScreenMsg')true);
  513.             $changePassMsg  wpDirAuth_sanitize(get_option('dirAuthChangePassMsg')true);
  514.         }
  515.  
  516.         $controllers    htmlspecialchars($controllers);
  517.         $baseDn         htmlspecialchars($baseDn);
  518.         $accountSuffix  htmlspecialchars($accountSuffix);
  519.         $filter         htmlspecialchars($filter);
  520.         $institution    htmlspecialchars($institution);
  521.         $loginScreenMsg htmlspecialchars($loginScreenMsg);
  522.         $changePassMsg  htmlspecialchars($changePassMsg);
  523.         
  524.         if ($enable{
  525.             $tEnable "checked";
  526.         }
  527.         else {
  528.             $fEnable "checked";
  529.         }
  530.         
  531.         $defaultFilter WPDIRAUTH_DEFAULT_FILTER;
  532.         if (!$filter{
  533.             $filter $defaultFilter;
  534.         }
  535.         
  536.         if (!$loginScreenMsg{
  537.             $loginScreenMsg sprintf(WPDIRAUTH_DEFAULT_LOGINSCREENMSG$institution);
  538.         }
  539.         
  540.         if (!$changePassMsg{
  541.             $changePassMsg sprintf(WPDIRAUTH_DEFAULT_CHANGEPASSMSG$institution);
  542.         }
  543.         
  544.         if ($enableSsl{
  545.             $tSsl "checked";
  546.         }
  547.         else {
  548.             $fSsl "checked";
  549.         }
  550.         
  551.         if ($requireSsl{
  552.             $tWpSsl "checked";
  553.         }
  554.         else {
  555.             $fWpSsl "checked";
  556.         }
  557.         
  558.         if ($TOS{
  559.             $tTOS "checked";
  560.         }
  561.         else {
  562.             $fTOS "checked";
  563.         }
  564.         
  565.         $wpDAV WPDIRAUTH_VERSION;
  566.         
  567.         echo <<<________EOS
  568.         <div class="wrap">
  569.             <h2>Directory Authentication Options</h2>
  570.             <form method="postid="dir_auth_options">
  571.                 <fieldset class="options">
  572.                     <p class="submit"><input type="submitname="dirAuthOptionsSavevalue="Update Options &raquo;" /></p>
  573.                     <fieldset class="options">
  574.                         <legend>WordPress Settings</legend>  
  575.                         <ul>
  576.                             <li>
  577.                                 <label for="dirAuthEnable"><strong>Enable Directory Authentication?</strong></label>
  578.                                 <br />
  579.                                 <input type="radioname="dirAuthEnablevalue="1" $tEnable /> Yes &nbsp;
  580.                                 <input type="radioname="dirAuthEnablevalue="0" $fEnable /> No
  581.                                 <br />
  582.                                 <strong>NOTE</strong>: Users created in WordPress are not affected by your directory authentication settings.
  583.                             </li>
  584.                             <li>
  585.                                 <label for="dirAuthRequireSsl"><strong>Require SSL Login?</strong></label>
  586.                                 <br />
  587.                                 <input type="radioname="dirAuthRequireSslvalue="1" $tWpSsl/> Yes &nbsp;
  588.                                 <input type="radioname="dirAuthRequireSslvalue="0" $fWpSsl/> No
  589.                                 <br />
  590.                                 <em>Force the WordPress login screen to require encryption (SSLhttps:// URL)?</em>
  591.                             </li>
  592.                         </ul>
  593.                     </fieldset>
  594.                     <fieldset class="options">
  595.                         <legend>Directory Settings</legend>
  596.                         <ul>
  597.                             <li>
  598.                                 <label for="dirAuthEnableSsl"><strong>Enable SSL Connectivity?</strong></label>
  599.                                 <br />
  600.                                 <input type="radioname="dirAuthEnableSslvalue="1" $tSsl/> Yes &nbsp;
  601.                                 <input type="radioname="dirAuthEnableSslvalue="0" $fSsl/> No
  602.                                 <br />
  603.                                 <em>Use encryption (SSLldaps:// URLwhen WordPress connects to the directory server(s)?</em>
  604.                             </li>
  605.                             <li>
  606.                                 <label for="dirAuthControllers"><strong>Directory Servers (Domain Controllers)</strong></label>
  607.                                 <br />
  608.                                 <input type="textname="dirAuthControllersvalue="$controllerssize="40"/><br />
  609.                                 <em>The DNS name or IP address of the directory server(s). Separate multiple entries by a comma (,).</em>
  610.                             </li>
  611.                             <li>
  612.                                 <label for="dirAuthBaseDn"><strong>Base DN</strong></label>
  613.                                 <br />
  614.                                 <input type="textname="dirAuthBaseDnvalue="$baseDnsize="40"/><br />
  615.                                 <em>The base DN for carrying out LDAP searches.</em>
  616.                             </li>
  617.                             <li>
  618.                                 <label for="dirAuthAccountSuffix"><strong>Account Suffix</strong></label>
  619.                                 <br />
  620.                                 <input type="textname="dirAuthAccountSuffixvalue="$accountSuffixsize="40" /><br />
  621.                                 <em>
  622.                                     Suffix needed to be appended to the usernamee.g. @domain.com<br />
  623.                                     <strong>NOTE:</strongChanging this value will cause your existing directory users to have new accounts created the next time they login.
  624.                                 </em>
  625.                             </li>
  626.                             <li>
  627.                                 <label for="dirAuthFilter"><strong>Account Filter</strong></label>
  628.                                 <br />
  629.                                 <input type="textname="dirAuthFiltervalue="$filtersize="40"/>
  630.                                 (Defaults to <em>$defaultFilter</em>) 
  631.                                 <br />
  632.                                 <em>What LDAP field should we search the username against to locate the user's profile after successful login?</em>
  633.                             </li>
  634.                         </ul>
  635.                     </fieldset>
  636.                     <fieldset class="options">
  637.                         <legend>Branding Settings</legend>
  638.                         <ul>
  639.                             <li>
  640.                                 <label for="dirAuthInstitution"><strong>Institution Name</strong></label>
  641.                                 <br />
  642.                                 <input type="textname="dirAuthInstitutionvalue="$institutionsize="40" />
  643.                                 <br />
  644.                                 <em>Name of your institution/companyDisplayed on the login screen.</em>
  645.                             </li>
  646.                             <li>
  647.                                 <label for="dirAuthLoginScreenMsg"><strong>Login Screen Message</strong></label>
  648.                                 <br />
  649.                                 <textarea name="dirAuthLoginScreenMsgcols="40" rows="3">$loginScreenMsg</textarea>
  650.                                 <br />
  651.                                 <em>
  652.                                     Displayed on the login screenunderneath the username/password fields.<br />
  653.                                     Some HTML allowed$allowedHTML
  654.                                 </em>
  655.                             </li>
  656.                             <li>
  657.                                 <label for="dirAuthChangePassMsg"><strong>Password Change Message</strong></label>
  658.                                 <br />
  659.                                 <textarea name="dirAuthChangePassMsgcols="40" rows="3">$changePassMsg</textarea>
  660.                                 <br />
  661.                                 <em>
  662.                                     Displayed wherever user passwords can be changedfor directory users only.<br />
  663.                                     Some HTML allowed$allowedHTML
  664.                                 </em>
  665.                             </li>
  666.                             <li>
  667.                                 <label for="dirAuthTOS"><strong>Terms of Services Agreement</strong></label>
  668.                                 <br />
  669.                                 <input type="radioname="dirAuthTOSvalue="1" $tTOS/> Yes &nbsp;
  670.                                 <input type="radioname="dirAuthTOSvalue="0" $fTOS/> No
  671.                                 <br />
  672.                                 <em>
  673.                                     Ask directory users to agree to terms of services that you link to in the message above?<br />
  674.                                     <strong>Note</strong>: Checkbox disappears once checkeddate of agreement is stored and users are no longer prompted.
  675.                                 </em>
  676.                             </li>
  677.                             </ul>
  678.                     </fieldset>
  679.                     <p class="submit"><input type="submitname="dirAuthOptionsSavevalue="Update Options &raquo;" /></p>
  680.                 </fieldset>
  681.             </form>
  682.             <p>Powered by $wpDARef.</p>
  683.         </div>
  684. ________EOS;
  685.     }
  686.     
  687.  
  688.     /**
  689.      * Adds the `Directory Auth.` menu entry in the Wordpress Admin section.
  690.      * Also activates the wpDirAuth config panel as a callback function.
  691.      * 
  692.      * @uses wpDirAuth_optionsPanel
  693.      */
  694.     function wpDirAuth_addMenu(
  695.     {
  696.         if (function_exists('add_options_page')) {
  697.             add_options_page(
  698.                 'Directory Authentication Options',
  699.                 'Directory Auth.',
  700.                 9,
  701.                 basename(__FILE__),
  702.                 'wpDirAuth_optionsPanel'
  703.             );
  704.         }
  705.     }
  706.     
  707.     
  708.     /**
  709.      * Extending WP's login_form.
  710.      * Enforces the admin defined SSL login preferences and adds a directory
  711.      * login related message to the standard WP login screen.
  712.      * 
  713.      * @uses WPDIRAUTH_DEFAULT_LOGINSCREENMSG
  714.      */
  715.     function wpDirAuth_loginFormExtra()
  716.     {
  717.         if (get_option('dirAuthEnable')) {
  718.             
  719.             if (isset($_SERVER['SCRIPT_URI']&& preg_match('|^http|',$_SERVER['SCRIPT_URI'])) {
  720.                 $selfURL $_SERVER['SCRIPT_URI'];
  721.             }
  722.             else {
  723.                 /**
  724.                  * $_SERVER['SCRIPT_URI'] seems to be unavilable in some PHP
  725.                  * installs, and $_SERVER['REQUEST_URI'] and $_SERVER['PHP_SELF']
  726.                  * have been known to sometimes have the same issue.
  727.                  * Thanks to Todd Beverly for helping out with this one. :)
  728.                  * @see http://wordpress.org/support/topic/129814?replies=27#post-605423
  729.                  */
  730.                 $selfURL sprintf(
  731.                     'http%s://%s%s',
  732.                     (isset($_SERVER['HTTPS']&& $_SERVER['HTTPS'== 'on' 's' ''),
  733.                     $_SERVER['HTTP_HOST'],
  734.                     (isset($_SERVER['REQUEST_URI'])
  735.                         ? $_SERVER['REQUEST_URI']
  736.                         : $_SERVER["SCRIPT_NAME"].'?'.$_SERVER['QUERY_STRING'])
  737.                 );
  738.             }
  739.             
  740.             if (get_option('dirAuthRequireSsl'&& (!preg_match('|^https|',$selfURL))) {
  741.                 $refreshJS   '<script type="text/javascript">'."\n".'top.location.href=\''.$location.'\';'."\n".'</script>" />';
  742.                 $refreshMeta '<meta http-equiv="refresh" content="0;url='.$location.'" />';
  743.                 $refreshMsg  'Please access the <a href="'.$location.'">encrypted version</a> of this page.';
  744.                 
  745.                 if (headers_sent()) {
  746.                         echo $refreshJS.$refreshMeta.'<p>'.$refreshMsg.'</p></form></div></html>';
  747.                 }
  748.                 else {
  749.                     @ob_end_clean();
  750.                     $location str_replace('http://','https://',$selfURL);
  751.                     if (!@header('Location:'.$location)) {
  752.                         echo '<html><head>'.$refreshJS.$refreshMeta.'</head>'
  753.                            . '<body>'.$refreshMsg.'</body></html>';
  754.                     }
  755.                 }
  756.                 
  757.                 exit;
  758.             }
  759.     
  760.             $dirAuthInstitution stripslashes(get_option('dirAuthInstitution'));
  761.             if (!$dirAuthInstitution$dirAuthInstitution __('Directory');
  762.             
  763.             $loginScreenMsg stripslashes(get_option('dirAuthLoginScreenMsg'));
  764.             if (!$loginScreenMsg$loginScreenMsg __(sprintf(
  765.                 WPDIRAUTH_DEFAULT_LOGINSCREENMSG,
  766.                 get_option('dirAuthInstitution')
  767.             ));
  768.             
  769.             echo '
  770.                 <style>.wpDirAuthMsg a, .wpDirAuthMsg a:visited {color: #ebcd4e;}</style>
  771.                 <p class="wpDirAuthMsg">'.$loginScreenMsg.'</p>
  772.             ';
  773.         }
  774.     }
  775.     
  776.     
  777.     /**
  778.      * Extending WP's show_password_fields.
  779.      * Displays the directory password change message in profile.php and user.php.
  780.      *
  781.      * @return boolean Return format as expected by WP's show_password_fields()
  782.      * 
  783.      * @uses WPDIRAUTH_DEFAULT_CHANGEPASSMSG
  784.      */
  785.     function wpDirAuth_hidePassFields()
  786.     {
  787.         global $profileuser$userdata;
  788.         
  789.         $editUserIsDirUser get_usermeta($profileuser->ID'wpDirAuthFlag');
  790.         
  791.         if (!$editUserIsDirUser{
  792.             return true;
  793.         }
  794.         else {
  795.             // Editing directory user profile, show password msg
  796.             $message stripslashes(get_option('dirAuthChangePassMsg'));
  797.             if (!$message{
  798.                 $message __(sprintf(
  799.                     WPDIRAUTH_DEFAULT_CHANGEPASSMSG,
  800.                     stripslashes(get_option('dirAuthInstitution'))
  801.                 ));
  802.             }
  803.             
  804.             if (get_option('dirAuthTOS')) {
  805.                 // TOS option is ON
  806.                 if (($TOSDate get_usermeta($profileuser->ID'wpDirAuthTOS')) === ''{
  807.                     if ($userdata->ID == $profileuser->ID{
  808.                         // Only show TOS acceptance checkbox to the owner of the profile.
  809.                         $message .= '</p><p class="desc">'
  810.                                  .  '<input type="checkbox" name="wpDirAuthTOS" value="1" style="width:15px; height:15px;" /> '
  811.                                  .  __('Accept terms of services.')
  812.                                  .  '</p><p class="desc">';
  813.                     }
  814.                     else {
  815.                         // Show generic message to other admins.
  816.                         $message .= '</p><p class="desc">'
  817.                                  .  __('User has not yet agreed to the terms of services.')
  818.                                  .  '</p><p class="desc">';
  819.                     }
  820.                 }
  821.                 else {
  822.                     // Show TOS acceptance date
  823.                     $message .= '</p><p class="desc">'
  824.                              .  __('Terms of services accepted on')
  825.                              .  ' '.$TOSDate
  826.                              .  '</p><p class="desc">';
  827.                 }
  828.             }
  829.             
  830.             echo '<fieldset><legend>'
  831.                . __('Directory Password Update')
  832.                . '</legend><p class="desc">'
  833.                . $message
  834.                . '</p></fieldset>';
  835.         
  836.             return false;
  837.         }
  838.     }
  839.     
  840.     
  841.     /**
  842.      * Extending WP's profile_update.
  843.      * Saves the TOS acceptance if sent.
  844.      *
  845.      * @param integer $userID Sent by WP profile_update action
  846.      * @return boolean Return format as expected by WP's profile_update()
  847.      */
  848.     function wpDirAuth_profileUpdate($userID){
  849.         if (intval($_POST['wpDirAuthTOS']=== 1{
  850.             update_usermeta($userID'wpDirAuthTOS'date('Y-m-d H:i:s'));
  851.         }
  852.         return true;
  853.     }
  854.  
  855.  
  856.     /**
  857.      * WP's wp_login overwrite.
  858.      * Processes the directory login and creates a new user on first access.
  859.      *
  860.      * @param string $username Login form username.
  861.      * @param string $password Login form password
  862.      * @param boolean $already_md5 Has the pswd been double-hashed already?
  863.      * @return boolean
  864.      * 
  865.      * @uses wpDirAuth_makeCookieMarker
  866.      * @uses wpDirAuth_auth
  867.      * 
  868.      * @see http://codex.wordpress.org/Pluggable_Functions
  869.      */
  870.     function wp_login($username$password$already_md5 false)
  871.     {
  872.         global $error$pwd;
  873.     
  874.         if (!$username{
  875.             $pwd '';
  876.             return false;
  877.         }
  878.     
  879.         if (!$password{
  880.             $error __('<strong>Login Error</strong>:
  881.                         The password field is empty.');
  882.             $pwd '';
  883.             return false;
  884.         }
  885.         
  886.         $enable       get_option('dirAuthEnable');
  887.         $cookieMarker get_option('dirAuthCookieMarker');
  888.         
  889.         if (!$cookieMarker{
  890.             $cookieMarker wpDirAuth_makeCookieMarker();
  891.         }
  892.         
  893.         /**
  894.          * Get the login object. We will use it for first user insertion or when the 
  895.          * directory auth option is not activated.
  896.          */
  897.         $login get_userdatabylogin($username);
  898.         $loginUserIsDirUser ($loginget_usermeta($login->ID'wpDirAuthFlag'0;
  899.         
  900.         if (!$enable && $loginUserIsDirUser{
  901.             /*
  902.              * Existing directory user, but directory access has now been disabled.
  903.              */
  904.             $error __('<strong>Directory Login Error</strong>:
  905.                         Sorry, but the site administrators have disabled
  906.                         directory access in this WordPress install.');
  907.             $pwd '';
  908.             return false;
  909.         }
  910.         elseif ($enable{
  911.             /**
  912.              * Directory auth == true
  913.              */
  914.             if ($already_md5{
  915.                 /**
  916.                  * If already_md5 is TRUE, then we're getting the user/password from the cookie.
  917.                  * As we don't want to store LDAP passwords in any form, we've already replaced
  918.                  * the password with the hashed username and dirAuthCookieMarker
  919.                  */
  920.                 if ($password == md5($username).md5($cookieMarker)) {
  921.                     return true;
  922.                 }
  923.             }
  924.     
  925.             if (!$login{
  926.                 /**
  927.                  * No existing account record found, try dir auth
  928.                  */
  929.                 $userData wpDirAuth_auth($username,$password);
  930.                 
  931.                 if ($userData !== false{
  932.                     /**
  933.                      * Passed directory signin, so create a new WP user
  934.                      */
  935.                     require_once(ABSPATH WPINC '/registration.php');
  936.                     
  937.                     $userLogin sanitize_user($username);
  938.                     $userEmail apply_filters('user_registration_email'$userData['email'])
  939.                     
  940.                     if (username_exists($userLogin)) {
  941.                         /*
  942.                          * Username exists.
  943.                          */
  944.                         $error __('<strong>Directory Login Error</strong>:
  945.                                     Could not create a new WP user account
  946.                                     because your directory username is already
  947.                                     registered on this site.')
  948.                                . " [$userLogin]";
  949.                         $pwd '';
  950.                         return false;
  951.                     }
  952.                     elseif (email_exists($userLogin)) {
  953.                         /*
  954.                          * Email exists.
  955.                          */
  956.                         $error __('<strong>Directory Login Error</strong>:
  957.                                     Could not create a new WP account because
  958.                                     the email retrieved from the directory is
  959.                                     already registered with this site.')
  960.                                . " [$userEmail]";
  961.                         $pwd '';
  962.                         return false;
  963.                     }
  964.                     elseif ($userID wp_create_user($userLogin$password$userEmail)) {
  965.                         $userData['ID'$userID;
  966.                         $tmpAr split('@',$userData['email']);
  967.                         $userData['nickname'=  str_replace('.','_',$tmpAr[0]);
  968.                         $userData['display_name'$userData['first_name'].' '.$userData['last_name'];
  969.                         unset($userData['email']);
  970.                         
  971.                         wp_update_user($userData);
  972.                         update_usermeta($userID'wpDirAuthFlag'1);
  973.                         
  974.                         return true;
  975.                     }
  976.                     else {
  977.                         /*
  978.                          * Unknown error.
  979.                          */
  980.                         $error __('<strong>Directory Login Error</strong>:
  981.                                     Could not create a new user account.
  982.                                     Unknown error.')
  983.                                . " [user$userLoginemail$userEmail]";
  984.                         $pwd '';
  985.                         return false;
  986.                     }
  987.                 }
  988.                 else {
  989.                     /*
  990.                      * Did not pass dir auth, and no login present in WP
  991.                      */
  992.                     if (!$error$error __('<strong>Login Error</strong>:
  993.                                               Could not authenticate user in
  994.                                               either WordPress or the directory.
  995.                                               Please check credentials.');
  996.                     $pwd '';
  997.                     return false;
  998.                 }
  999.             }
  1000.             else {
  1001.                 /*
  1002.                  * Dealing with an existing WP account
  1003.                  */
  1004.                 if (!$loginUserIsDirUser{
  1005.                     /*
  1006.                      * WP-only user
  1007.                      * If the password is already_md5, it has been double hashed.
  1008.                      * Otherwise, it is plain text.
  1009.                      */
  1010.                     if ( ($already_md5 && $login->user_login == $username && md5($login->user_pass== $password)
  1011.                          || ($login->user_login == $username && $login->user_pass == md5($password)) ) {
  1012.                         /*
  1013.                          * WP user, password okay.
  1014.                          */
  1015.                          return true;
  1016.                     
  1017.                     else {
  1018.                         /*
  1019.                          * WP user, wrong pass
  1020.                          */
  1021.                         $error __('<strong>WordPress Login Error</strong>:
  1022.                                     Incorrect password.');
  1023.                         $pwd '';
  1024.                         return false;
  1025.                     }
  1026.                 }
  1027.                 else {
  1028.                     /**
  1029.                      * Directory user, try ldap binding
  1030.                      */
  1031.                     $userData wpDirAuth_auth($username,$password);
  1032.                     
  1033.                     if ($userData !== false{
  1034.                         /*
  1035.                          * Directory user, password okay.
  1036.                          */
  1037.                         return true;
  1038.                     }
  1039.                     else {
  1040.                         /*
  1041.                          * Directory user, wrong pass
  1042.                          */
  1043.                         $error __('<strong>Directory Login Error</strong>:
  1044.                                     Incorrect password.');
  1045.                         $pwd '';
  1046.                         return false;
  1047.                     }
  1048.                 }
  1049.             }
  1050.         }
  1051.         else {
  1052.             /**
  1053.              * Directory auth == false
  1054.              */
  1055.             if (!$login{
  1056.                 /**
  1057.                  * No existing account record found
  1058.                  */
  1059.                 $error __('<strong>WordPress Login Error</strong>:
  1060.                             Could not authenticate user.
  1061.                             Please check your credentials.');
  1062.                 $pwd '';
  1063.                 return false;
  1064.             
  1065.             else {
  1066.                 /*
  1067.                  * Found an existing WP account.
  1068.                  * If the password is already_md5, it has been double hashed.
  1069.                  * Otherwise, it is plain text.
  1070.                  */
  1071.                 if ( ($already_md5 && $login->user_login == $username && md5($login->user_pass== $password)
  1072.                      || ($login->user_login == $username && $login->user_pass == md5($password)) ) {
  1073.                     /*
  1074.                      * WP user, password okay.
  1075.                      */
  1076.                     return true;
  1077.                 
  1078.                 else {
  1079.                     /*
  1080.                      * WP user, wrong pass
  1081.                      */
  1082.                     $error __('<strong>WordPress Login Error</strong>:
  1083.                                 Incorrect password).');
  1084.                     $pwd '';
  1085.                     return false;
  1086.                 }
  1087.             }
  1088.         }
  1089.     }
  1090.  
  1091.     
  1092.     /**
  1093.      * WordPress wp_setcookie overwrite.
  1094.      * Sets the WP session cookies.
  1095.      *
  1096.      * @param string $username Login form username.
  1097.      * @param string $password Login form password
  1098.      * @param boolean $already_md5 Has the pswd been double-hashed already?
  1099.      * @param string $home
  1100.      * @param string $siteurl
  1101.      * @param boolean $remember
  1102.      * @return void
  1103.      * 
  1104.      * @uses wpDirAuth_makeCookieMarker
  1105.      * 
  1106.      * @see http://codex.wordpress.org/Pluggable_Functions 
  1107.      */
  1108.     function wp_setcookie($username$password$already_md5 false$home ''$siteurl ''$remember false
  1109.     {
  1110.         global $wpdb;
  1111.  
  1112.         /**
  1113.          * Try to locate the user's record and define if it is an existing directory user
  1114.          */
  1115.         $login get_userdatabylogin($username);
  1116.         //$login = $wpdb->get_row('SELECT ID FROM $wpdb->users WHERE user_login = '$username'');
  1117.         $loginUserIsDirUser ($loginget_usermeta($login->ID'wpDirAuthFlag'0;
  1118.         
  1119.         /**
  1120.          * Get wpsDirAuth options
  1121.          */
  1122.         $enable       get_option('dirAuthEnable');
  1123.         $cookieMarker get_option('dirAuthCookieMarker');
  1124.         
  1125.         if (!$cookieMarker{
  1126.             $cookieMarker wpDirAuth_makeCookieMarker();
  1127.         }
  1128.         
  1129.         /**
  1130.          * Set the password hash cookie
  1131.          */
  1132.         if (($enable&& ($loginUserIsDirUser)) {
  1133.             $password md5($username).md5($cookieMarker);
  1134.         }
  1135.         else {
  1136.             if (!$already_md5{
  1137.                 $password md5md5($password) )// Double hash the password in the cookie.
  1138.             }
  1139.         }
  1140.     
  1141.         /**
  1142.          * Updated WP remember me option for directory users to only be
  1143.          * remembered for 1 hour so that institutional passwords are not
  1144.          * overly endangered when accessing the blog from a public terminal.
  1145.          */
  1146.         if $remember ){
  1147.             $duration ($loginUserIsDirUserstrtotime('1 hour'strtotime('6 months');
  1148.             $expire time($duration;
  1149.         }
  1150.         else {
  1151.             $expire 0;
  1152.         }
  1153.  
  1154.         /**
  1155.          * The rest of the logic is from the original WP wp_setcookie
  1156.          * function, from /wp-inlcudes/pluggable.php version 2.2.2
  1157.          */
  1158.         if empty($home) )
  1159.             $cookiepath COOKIEPATH;
  1160.         else
  1161.             $cookiepath preg_replace('|https?://[^/]+|i'''$home '/' );
  1162.     
  1163.         if empty($siteurl) ) {
  1164.             $sitecookiepath SITECOOKIEPATH;
  1165.             $cookiehash COOKIEHASH;
  1166.         else {
  1167.             $sitecookiepath preg_replace('|https?://[^/]+|i'''$siteurl '/' );
  1168.             $cookiehash md5($siteurl);
  1169.         }
  1170.     
  1171.         setcookie(USER_COOKIE$username$expire$cookiepathCOOKIE_DOMAIN);
  1172.         setcookie(PASS_COOKIE$password$expire$cookiepathCOOKIE_DOMAIN);
  1173.     
  1174.         if $cookiepath != $sitecookiepath {
  1175.             setcookie(USER_COOKIE$username$expire$sitecookiepathCOOKIE_DOMAIN);
  1176.             setcookie(PASS_COOKIE$password$expire$sitecookiepathCOOKIE_DOMAIN);
  1177.         }
  1178.  
  1179.     }
  1180.  
  1181.     
  1182.     /**
  1183.      * Add custom WordPress actions
  1184.      * 
  1185.      * @uses wpDirAuth_addMenu
  1186.      * @uses wpDirAuth_loginFormExtra
  1187.      */
  1188.     if (function_exists('add_action')) {
  1189.         add_action('admin_menu',     'wpDirAuth_addMenu');
  1190.         add_action('login_form',     'wpDirAuth_loginFormExtra');
  1191.         add_action('user_register',  'wpDirAuth_profileFormExtra');
  1192.         add_action('profile_update''wpDirAuth_profileUpdate');
  1193.     }
  1194.     
  1195.     
  1196.     /**
  1197.      * Add custom WordPress filters
  1198.      * 
  1199.      * @uses wpDirAuth_hidePassFields
  1200.      */
  1201.     if (function_exists('add_filter')) {
  1202.         add_filter('show_password_fields''wpDirAuth_hidePassFields');
  1203.     }
  1204. }
  1205.  
  1206. ?>

Documentation generated on Fri, 31 Aug 2007 21:41:27 -0400 by phpDocumentor 1.4.0a2