Exemplo n.º 1
0
 *  the Free Software Foundation; either version 2 of the License, or
 *  (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 *  GNU General Public License for more details.
 *
 *  You should have received a copy of the GNU General Public License
 *  along with this program; if not, write to the Free Software
 *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
 *
 * @author Evan Prodromou <*****@*****.**>
 * @addtogroup Extensions
 */
require_once 'commandLine.inc';
ini_set("include_path", "/usr/share/php:" . ini_get("include_path"));
require_once "{$IP}/extensions/OpenID/Consumer.php";
global $wgSharedDB, $wgDBprefix;
$tableName = "{$wgDBprefix}user_openid";
if (isset($wgSharedDB)) {
    $tableName = "`{$wgSharedDB}`.{$tableName}";
}
$dbr =& wfGetDB(DB_SLAVE);
$res = $dbr->select(array('user'), array('user_name'), array('user_options LIKE "%openid_url%"'), 'optionToTable', array('ORDER BY' => 'user_name'));
while ($res && ($row = $dbr->fetchObject($res))) {
    $user = User::newFromName($row->user_name);
    print $user->getName() . ": " . $user->getOption('openid_url') . "\n";
    OpenIDSetUserUrl($user, $user->getOption('openid_url'));
}
$dbr->freeResult($res);
Exemplo n.º 2
0
 function OpenIDConvertFinish()
 {
     global $wgUser, $wgOut;
     $consumer = OpenIDConsumer();
     $response = $consumer->complete($_GET);
     if (!isset($response)) {
         $wgOut->errorpage('openiderror', 'openiderrortext');
         return;
     }
     switch ($response->status) {
         case Auth_OpenID_CANCEL:
             // This means the authentication was cancelled.
             $wgOut->errorpage('openidcancel', 'openidcanceltext');
             break;
         case Auth_OpenID_FAILURE:
             $wgOut->errorpage('openidfailure', 'openidfailuretext');
             break;
         case Auth_OpenID_SUCCESS:
             // This means the authentication succeeded.
             $openid_url = $response->identity_url;
             if (!isset($openid_url)) {
                 $wgOut->errorpage('openiderror', 'openiderrortext');
                 return;
             }
             # We check again for dupes; this may be normalized or
             # reformatted by the server.
             $other = OpenIDGetUser($openid_url);
             if (isset($other)) {
                 if ($other->getId() == $wgUser->getID()) {
                     $wgOut->errorpage('openiderror', 'openidconvertyourstext');
                 } else {
                     $wgOut->errorpage('openiderror', 'openidconvertothertext');
                 }
                 return;
             }
             OpenIDSetUserUrl($wgUser, $openid_url);
             $wgOut->setPageTitle(wfMsg('openidconvertsuccess'));
             $wgOut->setRobotpolicy('noindex,nofollow');
             $wgOut->setArticleRelated(false);
             $wgOut->addWikiText(wfMsg('openidconvertsuccesstext', $openid_url));
             $wgOut->returnToMain();
     }
 }