| 49 | | |
|---|
| 50 | | function printBinary ($title, $binary) |
|---|
| 51 | | { |
|---|
| 52 | | // if debugging is on, this pretty-prints the contents of $binary |
|---|
| 53 | | // if debugging is off, printBinary simply returns. |
|---|
| 54 | | if (PW_DEBUG_ON) { |
|---|
| 55 | | |
|---|
| 56 | | pw_utils::printDebug( $title . " (length: " .strlen($binary) . " octents) <br/>"); |
|---|
| 57 | | $ascii = strtoupper(bin2hex($binary)); |
|---|
| 58 | | $ascii_length = strlen($ascii); |
|---|
| 59 | | |
|---|
| 60 | | $offset = 0; |
|---|
| 61 | | $linelen = 0; |
|---|
| 62 | | $binary_offset = 0; |
|---|
| 63 | | // initial value of printbuf is 8 zeros |
|---|
| 64 | | $printbuf .= sprintf(" <b>%08d</b> ", $binary_offset); |
|---|
| 65 | | |
|---|
| 66 | | while ($offset < $ascii_length){ |
|---|
| 67 | | $printbuf = $printbuf.substr($ascii, $offset, 8); |
|---|
| 68 | | $offset += 8; |
|---|
| 69 | | $linelen += 8; |
|---|
| 70 | | |
|---|
| 71 | | if ($linelen < 64){ |
|---|
| 72 | | if ($offset < $ascii_length) |
|---|
| 73 | | $printbuf = $printbuf.'-'; |
|---|
| 74 | | } |
|---|
| 75 | | else { |
|---|
| 76 | | // output needs to span multiple lines |
|---|
| 77 | | // so print off the current line & start a new one |
|---|
| 78 | | $printbuf = $printbuf."<br>"; |
|---|
| 79 | | pw_utils::printDebug( $printbuf ); |
|---|
| 80 | | $binary_offset += 32; |
|---|
| 81 | | $printbuf = sprintf(" <b>%08d</b> ", $binary_offset); |
|---|
| 82 | | $linelen = 0; |
|---|
| 83 | | } |
|---|
| 84 | | } |
|---|
| 85 | | |
|---|
| 86 | | if ($linelen > 0) |
|---|
| 87 | | pw_utils::printDebug( $printbuf . "<br/>"); |
|---|
| 88 | | } |
|---|
| 89 | | |
|---|
| 90 | | } // end of function print_binary |
|---|
| 91 | | |
|---|
| 92 | | // Function: writeToAudit |
|---|
| 93 | | // Description: writeToAudit puts information into the pw_infocard_audit table. |
|---|
| 94 | | // Input: IP address, Certificate Modulus, Email from token, Account ID if |
|---|
| 95 | | // available, any Error message |
|---|
| 96 | | // Output: none |
|---|
| 97 | | // Side Effects: alters DB table |
|---|
| 98 | | function writeToAudit( $ip, $modulus, $ppid, $email, $error, $acct) |
|---|
| 99 | | { |
|---|
| 100 | | global $wpdb; |
|---|
| 101 | | |
|---|
| 102 | | $today = date('Y-m-d H-i-s'); |
|---|
| 103 | | $query = "INSERT INTO `wp_infocard_audit` " |
|---|
| 104 | | . "(`modulusHash`, `ppid`, `accountid`, `email`,`time`,`IP`,`status`) " |
|---|
| 105 | | . "VALUES ('$modulus', '$ppid', '$acct', '$email','$today','$ip','$error')"; |
|---|
| 106 | | |
|---|
| 107 | | $update_result = $wpdb->query( $query ); |
|---|
| 108 | | if ( $update_result == FALSE ) |
|---|
| 109 | | { |
|---|
| 110 | | pw_utils::printDebug("Error ".mysql_errno($update_result)."with mysql_query update (".mysql_error($update_result).")<br/>"); |
|---|
| 111 | | } |
|---|
| 112 | | |
|---|
| 113 | | } // end function writeToAudit |
|---|
| | 150 | function infocardPostIncludes() |
|---|
| | 151 | { |
|---|
| | 152 | // no joomla includes needed |
|---|
| | 153 | } |
|---|
| | 154 | |
|---|
| | 155 | function getDefaultLang() |
|---|
| | 156 | { |
|---|
| | 157 | // hard-coded for now |
|---|
| | 158 | |
|---|
| | 159 | return 'en-us'; |
|---|
| | 160 | } |
|---|
| | 161 | |
|---|
| | 162 | function showClaimList($claimslist) |
|---|
| | 163 | { |
|---|
| | 164 | pw_utils::printDebug('<br/>Requested Claims:<br/>'); |
|---|
| | 165 | foreach ($claimslist as $claim) |
|---|
| | 166 | { |
|---|
| | 167 | pw_utils::printDebug( ' ' . $claim->displayname . (($claim->required)?' (required)':' (optional)') . '<br/>'); |
|---|
| | 168 | //pw_utils::printDebug($claim->displayname); |
|---|
| | 169 | } |
|---|
| | 170 | pw_utils::printDebug('<br/>'); |
|---|
| | 171 | } |
|---|
| | 172 | |
|---|
| | 173 | function showDataMap($datamap) |
|---|
| | 174 | { |
|---|
| | 175 | pw_utils::printDebug('<br/>Mapped Data:<br/>'); |
|---|
| | 176 | foreach ($datamap as $map) |
|---|
| | 177 | { |
|---|
| | 178 | pw_utils::printDebug($map->handle . " in " |
|---|
| | 179 | . $map->mappingtable . "." |
|---|
| | 180 | . $map->mappingattribute |
|---|
| | 181 | . (($map->description != '')?" (".$map->description.")":"") |
|---|
| | 182 | . "<br />"); |
|---|
| | 183 | } |
|---|
| | 184 | } // end function showDataMap |
|---|
| | 185 | |
|---|
| | 186 | function redirectToURL( $url ) |
|---|
| | 187 | { |
|---|
| | 188 | wp_redirect( $url ); |
|---|
| | 189 | } |
|---|
| | 190 | |
|---|
| | 191 | function getUserMessageURL( $mesg ) |
|---|
| | 192 | { |
|---|
| | 193 | return PW_PLUGINURL |
|---|
| | 194 | . "/site-messages/infocard-usermessage.php?mesg=".$mesg; |
|---|
| | 195 | } |
|---|