static function updateOpenID($openid_url, $authorID) { global $serendipity; if (!is_array(serendipity_db_query("SELECT username FROM {$serendipity['dbPrefix']}openid_authors LIMIT 1", true, 'both', false, false, false, true))) { serendipity_db_schema_import("CREATE TABLE {$serendipity['dbPrefix']}openid_authors (\r\n openid_url varchar(255) default null,\r\n hash varchar(32) default null,\r\n authorid int(11) default '0'\r\n );"); } $hash = md5($openid_url); if (serendipity_common_openid::getOpenID($authorID, true)) { $retVal = serendipity_db_update('openid_authors', array('authorid' => $authorID), array('openid_url' => $openid_url, 'hash' => $hash)); } else { $retVal = serendipity_db_insert('openid_authors', array('openid_url' => $openid_url, 'hash' => $hash, 'authorid' => $authorID)); } return $retVal === true ? true : false; }
function print_sidebar() { global $serendipity; if ($_SESSION['serendipityAuthedUser'] == true) { if (!empty($serendipity['GET']['openidflag']) && $serendipity['GET']['openidflag'] == 3) { if ($checkRet = serendipity_common_openid::authenticate_openid($_GET, $this->get_consumertest_path(), true)) { if (serendipity_common_openid::updateOpenID($checkRet['openID'], $serendipity['authorid'])) { echo '<strong>' . (function_exists('serendipity_specialchars') ? serendipity_specialchars(PLUGIN_OPENID_UPDATE_SUCCESS) : htmlspecialchars(PLUGIN_OPENID_UPDATE_SUCCESS, ENT_COMPAT, LANG_CHARSET)) . '</strong><br /><br />'; } else { echo '<strong>' . (function_exists('serendipity_specialchars') ? serendipity_specialchars(PLUGIN_OPENID_UPDATE_FAIL) : htmlspecialchars(PLUGIN_OPENID_UPDATE_FAIL, ENT_COMPAT, LANG_CHARSET)) . '</strong><br /><br />'; } } else { echo '<strong>' . (function_exists('serendipity_specialchars') ? serendipity_specialchars(PLUGIN_OPENID_INVALID_RESPONSE) : htmlspecialchars(PLUGIN_OPENID_INVALID_RESPONSE, ENT_COMPAT, LANG_CHARSET)) . '</strong><br /><br />'; } // Job done. unset($serendipity['GET']['openidflag']); } elseif (!empty($serendipity['POST']['openidflag']) && $serendipity['POST']['openidflag'] == 3) { echo '<strong>' . (function_exists('serendipity_specialchars') ? serendipity_specialchars(PLUGIN_OPENID_INVALID_RESPONSE) : htmlspecialchars(PLUGIN_OPENID_INVALID_RESPONSE, ENT_COMPAT, LANG_CHARSET)) . '</strong><br /><br />'; } } $imgopenid = $serendipity['baseURL'] . 'index.php?/plugin/openid.png'; $imggoogle = $serendipity['baseURL'] . 'index.php?/plugin/oids_google.png'; $imgyahoo = $serendipity['baseURL'] . 'index.php?/plugin/oids_yahoo.png'; $imgaol = $serendipity['baseURL'] . 'index.php?/plugin/oids_aol.png'; echo '<div>'; echo '<strong>' . (function_exists('serendipity_specialchars') ? serendipity_specialchars(PLUGIN_EVENT_OPENID_SELECT) : htmlspecialchars(PLUGIN_EVENT_OPENID_SELECT, ENT_COMPAT, LANG_CHARSET)) . '</strong><br /><br />'; // To allow ENTER in the input line we have to create two forms: echo '<form action="?" method="post">'; echo '<input type="hidden" name="serendipity[adminModule]" value="event_display" />'; echo '<input type="hidden" name="serendipity[adminAction]" value="profiles" />'; echo '<input type="hidden" name="serendipity[openidflag]" value="3" />'; echo '<img src="' . $imgopenid . '" alt="OpenID URL"> <input type="text" size="50" name="serendipity[openid_url]" value="' . serendipity_common_openid::getOpenID($serendipity['authorid']) . '" />'; echo ' <input type="submit" name="submit" value="' . EDIT . '" placeholder="' . PLUGIN_OPENID_LOGIN_INPUT . '"/>'; echo '</form>'; echo '<form action="?" method="post">'; echo '<input type="hidden" name="serendipity[adminModule]" value="event_display" />'; echo '<input type="hidden" name="serendipity[adminAction]" value="profiles" />'; echo '<input type="hidden" name="serendipity[openidflag]" value="3" />'; echo '<input name="openIDLoginGoogle" type="image" src="' . $imggoogle . '" alt="' . PLUGIN_OPENID_SET_GOOGLE_OID . '" title="' . PLUGIN_OPENID_SET_GOOGLE_OID . '"/> '; echo '<input name="openIDLoginYahoo" type="image" src="' . $imgyahoo . '" alt="' . PLUGIN_OPENID_SET_YAHOO_OID . '" title="' . PLUGIN_OPENID_SET_YAHOO_OID . '"/> '; echo '<input name="openIDLoginAol" type="image" src="' . $imgaol . '" alt="' . PLUGIN_OPENID_SET_AOL_OID . '" title="' . PLUGIN_OPENID_SET_AOL_OID . '"/> '; echo '</form>'; echo '</div><br /><hr />'; }