Advertisement
Guest User

wpDirAuth.php.diff

a guest
Jun 3rd, 2014
229
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Diff 18.29 KB | None | 0 0
  1. --- wpDirAuth.php.orig  2014-06-03 10:11:25.000000000 +0100
  2. +++ wpDirAuth.php   2014-06-03 09:52:07.000000000 +0100
  3. @@ -137,7 +137,7 @@
  4.   */
  5.  //first we need to make sure we have access to the function
  6.  if(! function_exists('is_plugin_active_for_network')){
  7. -    require_once( ABSPATH . '/wp-admind/includes/plugin.php');
  8. +    require_once( ABSPATH . '/wp-admin/includes/plugin.php');
  9.  }
  10.  
  11.  /**
  12. @@ -258,7 +258,7 @@
  13.                  .$_SERVER['HTTP_USER_AGENT']
  14.                  .$_SERVER['REMOTE_ADDR']
  15.              ).uniqid(microtime(),true);
  16. -        update_site_option("dirAuthCookieMarker",$cookieMarker);
  17. +        wpDirAuth_update_site_option("dirAuthCookieMarker",$cookieMarker);
  18.          return $cookieMarker;
  19.      }
  20.  
  21. @@ -379,17 +379,17 @@
  22.  
  23.          $errorTitle = WPDIRAUTH_ERROR_TITLE;
  24.  
  25. -        $controllers      = explode(',', get_site_option('dirAuthControllers'));
  26. -        $baseDn           = get_site_option('dirAuthBaseDn');
  27. -        $preBindUser      = get_site_option('dirAuthPreBindUser');
  28. -        $preBindPassword  = get_site_option('dirAuthPreBindPassword');
  29. -        $accountSuffix    = get_site_option('dirAuthAccountSuffix');
  30. -        $filter           = get_site_option('dirAuthFilter');
  31. -        $enableSsl        = get_site_option('dirAuthEnableSsl');
  32. -        $boolUseGroups    = get_site_option('dirAuthUseGroups');
  33. +        $controllers      = explode(',', wpDirAuth_get_site_option('dirAuthControllers'));
  34. +        $baseDn           = wpDirAuth_get_site_option('dirAuthBaseDn');
  35. +        $preBindUser      = wpDirAuth_get_site_option('dirAuthPreBindUser');
  36. +        $preBindPassword  = wpDirAuth_get_site_option('dirAuthPreBindPassword');
  37. +        $accountSuffix    = wpDirAuth_get_site_option('dirAuthAccountSuffix');
  38. +        $filter           = wpDirAuth_get_site_option('dirAuthFilter');
  39. +        $enableSsl        = wpDirAuth_get_site_option('dirAuthEnableSsl');
  40. +        $boolUseGroups    = wpDirAuth_get_site_option('dirAuthUseGroups');
  41.  
  42.          if($boolUseGroups == 1){
  43. -            $strAuthGroups = get_site_option('dirAuthGroups');
  44. +            $strAuthGroups = wpDirAuth_get_site_option('dirAuthGroups');
  45.          }
  46.  
  47.          $returnKeys = unserialize(WPDIRAUTH_LDAP_RETURN_KEYS);
  48. @@ -633,32 +633,32 @@
  49.              $loginScreenMsg   = wpDirAuth_sanitize($_POST['dirAuthLoginScreenMsg'], true);
  50.              $changePassMsg    = wpDirAuth_sanitize($_POST['dirAuthChangePassMsg'], true);
  51.  
  52. -            update_site_option('dirAuthEnable',          $enable);
  53. -            update_site_option('dirAuthEnableSsl',       $enableSsl);
  54. -            update_site_option('dirAuthRequireSsl',      $requireSsl);
  55. -            update_site_option('dirAuthControllers',     $controllers);
  56. -            update_site_option('dirAuthBaseDn',          $baseDn);
  57. -            update_site_option('dirAuthPreBindUser',     $preBindUser);
  58. -            update_site_option('dirAuthAccountSuffix',   $accountSuffix);
  59. -            update_site_option('dirAuthFilter',          $filter);
  60. -            update_site_option('dirAuthInstitution',     $institution);
  61. -            update_site_option('dirAuthLoginScreenMsg',  $loginScreenMsg);
  62. -            update_site_option('dirAuthChangePassMsg',   $changePassMsg);
  63. -            update_site_option('dirAuthTOS',             $TOS);
  64. -            update_site_option('dirAuthUseGroups',       $boolUseGroups);
  65. -            update_site_option('dirAuthGroups',          $strAuthGroups);
  66. -            update_site_option('dirAuthMarketingSSOID',  $strMarketingSSOID);
  67. +            wpDirAuth_update_site_option('dirAuthEnable',          $enable);
  68. +            wpDirAuth_update_site_option('dirAuthEnableSsl',       $enableSsl);
  69. +            wpDirAuth_update_site_option('dirAuthRequireSsl',      $requireSsl);
  70. +            wpDirAuth_update_site_option('dirAuthControllers',     $controllers);
  71. +            wpDirAuth_update_site_option('dirAuthBaseDn',          $baseDn);
  72. +            wpDirAuth_update_site_option('dirAuthPreBindUser',     $preBindUser);
  73. +            wpDirAuth_update_site_option('dirAuthAccountSuffix',   $accountSuffix);
  74. +            wpDirAuth_update_site_option('dirAuthFilter',          $filter);
  75. +            wpDirAuth_update_site_option('dirAuthInstitution',     $institution);
  76. +            wpDirAuth_update_site_option('dirAuthLoginScreenMsg',  $loginScreenMsg);
  77. +            wpDirAuth_update_site_option('dirAuthChangePassMsg',   $changePassMsg);
  78. +            wpDirAuth_update_site_option('dirAuthTOS',             $TOS);
  79. +            wpDirAuth_update_site_option('dirAuthUseGroups',       $boolUseGroups);
  80. +            wpDirAuth_update_site_option('dirAuthGroups',          $strAuthGroups);
  81. +            wpDirAuth_update_site_option('dirAuthMarketingSSOID',  $strMarketingSSOID);
  82.  
  83.  
  84.              // Only store/override the value if a new one is being sent a bind user is set.
  85.              if ( $preBindUser && $preBindPassword && ($preBindPassCheck == $preBindPassword) )
  86. -                update_site_option('dirAuthPreBindPassword', $preBindPassword);
  87. +                wpDirAuth_update_site_option('dirAuthPreBindPassword', $preBindPassword);
  88.  
  89.              // Clear the stored password if the Bind DN is null
  90.              elseif ( ! $preBindUser)
  91. -                update_site_option('dirAuthPreBindPassword', '');
  92. +                wpDirAuth_update_site_option('dirAuthPreBindPassword', '');
  93.  
  94. -            if (get_site_option('dirAuthEnable') && !get_site_option('dirAuthCookieMarker'))
  95. +            if (wpDirAuth_get_site_option('dirAuthEnable') && !wpDirAuth_get_site_option('dirAuthCookieMarker'))
  96.                  wpDirAuth_makeCookieMarker();
  97.  
  98.              echo '<div id="message" class="updated fade"><p>Your new settings were saved successfully.</p></div>';
  99. @@ -668,27 +668,27 @@
  100.          }
  101.          else {
  102.              // Booleans
  103. -            $enable          = intval(get_site_option('dirAuthEnable'))     == 1 ? 1 : 0;
  104. -            $requireSsl      = intval(get_site_option('dirAuthRequireSsl')) == 1 ? 1 : 0;
  105. -            $TOS             = intval(get_site_option('dirAuthTOS'))        == 1 ? 1 : 0;
  106. -            $boolUseGroups   = intval(get_site_option('dirAuthUseGroups'))  == 1 ? 1 : 0;
  107. +            $enable          = intval(wpDirAuth_get_site_option('dirAuthEnable'))     == 1 ? 1 : 0;
  108. +            $requireSsl      = intval(wpDirAuth_get_site_option('dirAuthRequireSsl')) == 1 ? 1 : 0;
  109. +            $TOS             = intval(wpDirAuth_get_site_option('dirAuthTOS'))        == 1 ? 1 : 0;
  110. +            $boolUseGroups   = intval(wpDirAuth_get_site_option('dirAuthUseGroups'))  == 1 ? 1 : 0;
  111.  
  112.              //integers
  113. -            $enableSsl       = intval(get_site_option('dirAuthEnableSsl',0));
  114. +            $enableSsl       = intval(wpDirAuth_get_site_option('dirAuthEnableSsl',0));
  115.  
  116.              // Strings, no HTML
  117. -            $controllers        = wpDirAuth_sanitize(get_site_option('dirAuthControllers'));
  118. -            $baseDn             = wpDirAuth_sanitize(get_site_option('dirAuthBaseDn'));
  119. -            $preBindUser        = wpDirAuth_sanitize(get_site_option('dirAuthPreBindUser'));
  120. -            $accountSuffix      = wpDirAuth_sanitize(get_site_option('dirAuthAccountSuffix'));
  121. -            $filter             = wpDirAuth_sanitize(get_site_option('dirAuthFilter'));
  122. -            $institution        = wpDirAuth_sanitize(get_site_option('dirAuthInstitution'));
  123. -            $strAuthGroups      = wpDirAuth_sanitize((get_site_option('dirAuthGroups')));
  124. -            $strMarketingSSOID  = wpDirAuth_sanitize((get_site_option('dirAuthMarketingSSOID')));
  125. +            $controllers        = wpDirAuth_sanitize(wpDirAuth_get_site_option('dirAuthControllers'));
  126. +            $baseDn             = wpDirAuth_sanitize(wpDirAuth_get_site_option('dirAuthBaseDn'));
  127. +            $preBindUser        = wpDirAuth_sanitize(wpDirAuth_get_site_option('dirAuthPreBindUser'));
  128. +            $accountSuffix      = wpDirAuth_sanitize(wpDirAuth_get_site_option('dirAuthAccountSuffix'));
  129. +            $filter             = wpDirAuth_sanitize(wpDirAuth_get_site_option('dirAuthFilter'));
  130. +            $institution        = wpDirAuth_sanitize(wpDirAuth_get_site_option('dirAuthInstitution'));
  131. +            $strAuthGroups      = wpDirAuth_sanitize((wpDirAuth_get_site_option('dirAuthGroups')));
  132. +            $strMarketingSSOID  = wpDirAuth_sanitize((wpDirAuth_get_site_option('dirAuthMarketingSSOID')));
  133.  
  134.              // Have to be allowed to contain some HTML
  135. -            $loginScreenMsg  = wpDirAuth_sanitize(get_site_option('dirAuthLoginScreenMsg'), true);
  136. -            $changePassMsg   = wpDirAuth_sanitize(get_site_option('dirAuthChangePassMsg'), true);
  137. +            $loginScreenMsg  = wpDirAuth_sanitize(wpDirAuth_get_site_option('dirAuthLoginScreenMsg'), true);
  138. +            $changePassMsg   = wpDirAuth_sanitize(wpDirAuth_get_site_option('dirAuthChangePassMsg'), true);
  139.          }
  140.  
  141.          $controllers    = htmlspecialchars($controllers);
  142. @@ -955,7 +955,7 @@
  143.       */
  144.      function wpDirAuth_loginFormExtra()
  145.      {
  146. -        if (get_site_option('dirAuthEnable')) {
  147. +        if (wpDirAuth_get_site_option('dirAuthEnable')) {
  148.  
  149.              if (isset($_SERVER['SCRIPT_URI']) && preg_match('|^http|',$_SERVER['SCRIPT_URI'])) {
  150.                  $selfURL = $_SERVER['SCRIPT_URI'];
  151. @@ -981,7 +981,7 @@
  152.              //_log('contents of selfurl: '.$selfURL);
  153.  
  154.  
  155. -            if (get_site_option('dirAuthRequireSsl') && (!preg_match('|^https|',$selfURL))) {
  156. +            if (wpDirAuth_get_site_option('dirAuthRequireSsl') && (!preg_match('|^https|',$selfURL))) {
  157.                  $sslURL = str_replace('http://','https://',$selfURL);
  158.  
  159.                  $refreshJS   = '<script type="text/javascript">'."\n".'top.location.href=\''.$sslURL.'\';'."\n".'</script>" />';
  160. @@ -1002,13 +1002,13 @@
  161.                  exit;
  162.              }
  163.  
  164. -            $dirAuthInstitution = stripslashes(get_site_option('dirAuthInstitution'));
  165. +            $dirAuthInstitution = stripslashes(wpDirAuth_get_site_option('dirAuthInstitution'));
  166.              if (!$dirAuthInstitution) $dirAuthInstitution = __('Directory');
  167.  
  168. -            $loginScreenMsg = stripslashes(get_site_option('dirAuthLoginScreenMsg'));
  169. +            $loginScreenMsg = stripslashes(wpDirAuth_get_site_option('dirAuthLoginScreenMsg'));
  170.              if (!$loginScreenMsg) $loginScreenMsg = __(sprintf(
  171.                  WPDIRAUTH_DEFAULT_LOGINSCREENMSG,
  172. -                get_site_option('dirAuthInstitution')
  173. +                wpDirAuth_get_site_option('dirAuthInstitution')
  174.              ));
  175.  
  176.              echo '
  177. @@ -1038,15 +1038,15 @@
  178.          }
  179.          else {
  180.              // Editing directory user profile, show password msg
  181. -            $message = stripslashes(get_site_option('dirAuthChangePassMsg'));
  182. +            $message = stripslashes(wpDirAuth_get_site_option('dirAuthChangePassMsg'));
  183.              if (!$message) {
  184.                  $message = __(sprintf(
  185.                      WPDIRAUTH_DEFAULT_CHANGEPASSMSG,
  186. -                    stripslashes(get_site_option('dirAuthInstitution'))
  187. +                    stripslashes(wpDirAuth_get_site_option('dirAuthInstitution'))
  188.                  ));
  189.              }
  190.  
  191. -            if (get_site_option('dirAuthTOS')) {
  192. +            if (wpDirAuth_get_site_option('dirAuthTOS')) {
  193.                  // TOS option is ON
  194.                  if (($TOSDate = get_usermeta($profileuser->ID, 'wpDirAuthTOS')) === '') {
  195.                      if ($userdata->ID == $profileuser->ID) {
  196. @@ -1143,8 +1143,8 @@
  197.                          The password field is empty.'));
  198.          }
  199.  
  200. -        $enable       = get_site_option('dirAuthEnable');
  201. -        $cookieMarker = get_site_option('dirAuthCookieMarker');
  202. +        $enable       = wpDirAuth_get_site_option('dirAuthEnable');
  203. +        $cookieMarker = wpDirAuth_get_site_option('dirAuthCookieMarker');
  204.  
  205.          if (!$cookieMarker) {
  206.              $cookieMarker = wpDirAuth_makeCookieMarker();
  207. @@ -1367,8 +1367,8 @@
  208.          /**
  209.           * Get wpsDirAuth options
  210.           */
  211. -        $enable       = get_site_option('dirAuthEnable');
  212. -        $cookieMarker = get_site_option('dirAuthCookieMarker');
  213. +        $enable       = wpDirAuth_get_site_option('dirAuthEnable');
  214. +        $cookieMarker = wpDirAuth_get_site_option('dirAuthCookieMarker');
  215.  
  216.          if (!$cookieMarker) {
  217.              $cookieMarker = wpDirAuth_makeCookieMarker();
  218. @@ -1518,12 +1518,12 @@
  219.      function wpDirAuth_ConnectAndLookupUser($strSSOID){
  220.          $boolFound = false;
  221.  
  222. -        $strBaseDn           = get_site_option('dirAuthBaseDn');
  223. -        $strPreBindUser      = get_site_option('dirAuthPreBindUser','');
  224. -        $strPreBindPassword  = get_site_option('dirAuthPreBindPassword','');
  225. -        $strAccountSuffix    = get_site_option('dirAuthAccountSuffix');
  226. -        $strFilter           = get_site_option('dirAuthFilter');
  227. -        $intEnableSSL        = get_site_option('dirAuthEnableSsl');
  228. +        $strBaseDn           = wpDirAuth_get_site_option('dirAuthBaseDn');
  229. +        $strPreBindUser      = wpDirAuth_get_site_option('dirAuthPreBindUser','');
  230. +        $strPreBindPassword  = wpDirAuth_get_site_option('dirAuthPreBindPassword','');
  231. +        $strAccountSuffix    = wpDirAuth_get_site_option('dirAuthAccountSuffix');
  232. +        $strFilter           = wpDirAuth_get_site_option('dirAuthFilter');
  233. +        $intEnableSSL        = wpDirAuth_get_site_option('dirAuthEnableSsl');
  234.  
  235.          if ($strAccountSuffix) $strSSOID .= $strAccountSuffix;
  236.  
  237. @@ -1531,7 +1531,7 @@
  238.  
  239.          $strFilterQuery = "($strFilter=$strSSOID)";
  240.  
  241. -        $aryControllers = wpDirAuth_shuffleControllers(explode(',', get_site_option('dirAuthControllers')));
  242. +        $aryControllers = wpDirAuth_shuffleControllers(explode(',', wpDirAuth_get_site_option('dirAuthControllers')));
  243.  
  244.          if(is_wp_error($aryControllers)){
  245.              return $aryControllers; //there werent any controllers to connect to
  246. @@ -1688,7 +1688,7 @@
  247.       *
  248.       */
  249.      function wpDirAuth_add_user_contextual_help(){
  250. -        $strMarketingSSOID = get_site_option('dirAuthMarketingSSOID','Username');
  251. +        $strMarketingSSOID = wpDirAuth_get_site_option('dirAuthMarketingSSOID','Username');
  252.          add_contextual_help('users_page_'.basename(__FILE__,'.php'),
  253.              '<p>' . __('To add a directory authenticated user from your institution to your site, fill in the form on this screen. If you&#8217;re not sure which role to assign, you can use the link below to review the different roles and their capabilities. Here is a basic overview of roles:') . '</p>' .
  254.              '<ul>' .
  255. @@ -1727,7 +1727,7 @@
  256.          /**
  257.           * How do we refer to their SSOID?
  258.           */
  259. -        $strMarketingSSOID = get_site_option('dirAuthMarketingSSOID','Username');
  260. +        $strMarketingSSOID = wpDirAuth_get_site_option('dirAuthMarketingSSOID','Username');
  261.  
  262.          $strReferer = wpDirAuth_get_referer();
  263.  
  264. @@ -1801,7 +1801,7 @@
  265.  
  266.                      }
  267.  
  268. -                    $strWpDirAuthRole = (isset($_POST['role']) && in_array($_POST['role'],array_keys(get_editable_roles()))) ? $_POST['role'] : get_site_option('default_role');
  269. +                    $strWpDirAuthRole = (isset($_POST['role']) && in_array($_POST['role'],array_keys(get_editable_roles()))) ? $_POST['role'] : wpDirAuth_get_site_option('default_role');
  270.                      $intBlogID = (isset($_POST['id']) && is_numeric($_POST['id'])) ? intval($_POST['id']) : '';
  271.                      if(isset($_POST['noconfirmation']) && $_POST['noconfirmation'] == 1) $boolConfirmationEmail = false;
  272.  
  273. @@ -1835,7 +1835,7 @@
  274.                              }
  275.                          } else {
  276.                              $arySitesAddedTo[] = array(
  277. -                                'blogname'  =>get_site_option('blogname'),
  278. +                                'blogname'  =>wpDirAuth_get_site_option('blogname'),
  279.                                  'aoran'     =>wpDirAuth_determine_A_or_An($strWpDirAuthRole),
  280.                                  'role'      =>$strWpDirAuthRole,
  281.                                  'siteurl'   =>site_url()
  282. @@ -1963,7 +1963,7 @@
  283.                          <th scope="row"><label for="role"><?php _e('Role'); ?></label></th>
  284.                          <td><select name="role" id="role">
  285.                                  <?php
  286. -                                $strCurrentRole = empty($strWpDirAuthRole) ? get_site_option('default_role') : $strWpDirAuthRole;
  287. +                                $strCurrentRole = empty($strWpDirAuthRole) ? wpDirAuth_get_site_option('default_role') : $strWpDirAuthRole;
  288.                                  wp_dropdown_roles($strCurrentRole);
  289.                                  ?>
  290.                              </select>
  291. @@ -2112,6 +2112,41 @@
  292.  
  293.          return $strReferer;
  294.      }
  295. +
  296. +    /**
  297. +     * WordPress get_site_option overwrite using WPDIRAUTH_MULTISITE instead of is_multisite().
  298. +     * Retrieve site option value based on name of option.
  299. +     *
  300. +     * @param string $option Name of option to retrieve. Expected to not be SQL-escaped.
  301. +     * @param mixed $default Optional value to return if option doesn't exist. Default false.
  302. +     * @param bool $use_cache Whether to use cache. Multisite only. Default true.
  303. +     * @return mixed Value set for the option.
  304. +     */
  305. +    function wpDirAuth_get_site_option($option, $default = false, $use_cache = true){
  306. +        if(WPDIRAUTH_MULTISITE){
  307. +            return get_site_option($option, $default, $use_cache);
  308. +        } else {
  309. +            $default = apply_filters( 'default_site_option_' . $option, $default );
  310. +            $value = get_option($option, $default);
  311. +            return apply_filters( 'site_option_' . $option, $value );
  312. +        }
  313. +    }
  314. +
  315. +    /**
  316. +     * WordPress update_site_option overwrite using WPDIRAUTH_MULTISITE instead of is_multisite().
  317. +     * Update the value of a site option that was already added.
  318. +     *
  319. +     * @param string $option Name of option. Expected to not be SQL-escaped.
  320. +     * @param mixed $value Option value. Expected to not be SQL-escaped.
  321. +     * @return bool False if value was not updated and true if value was updated.
  322. +     */
  323. +    function wpDirAuth_update_site_option($option, $value){
  324. +        if(WPDIRAUTH_MULTISITE){
  325. +            return update_site_option($option, $value);
  326. +        } else {
  327. +            return update_option($option, $value);
  328. +        }
  329. +    }
  330.  }
  331.  
  332.  register_activation_hook(__FILE__, 'wpDirAuth_activation');
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement