Changeset 165
- Timestamp:
- 05/09/08 12:10:45 (8 months ago)
- Files:
-
- trunk/wp-infocard/wp/admin.pw.php (modified) (12 diffs)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
trunk/wp-infocard/wp/admin.pw.php
r164 r165 1 1 <?php 2 // This file is part of Pamela Project. 3 // 4 // Copyright (C) 2007 by various authors (see CONTRIBUTORS file) 5 // This file is free software, distributed under the new BSD License (see LICENSE file). 6 // 7 // admin.pw.php 8 // 2 9 //defined( '_VALID_IC' ) or die( 'Direct Access to this location is not allowed.'); 3 10 include_once( dirname(__FILE__) . '/../pw-config.php'); 4 11 include_once( dirname(__FILE__) . '/../pwlib/admin.pwlib.php'); 12 include_once( dirname(__FILE__) . '/processing.pw.php'); 13 include_once( dirname(__FILE__) . '/utils.pw.php'); 5 14 //require_once( ABSPATH . WPINC . '/registration-functions.php'); 6 15 /* … … 15 24 - createIdentityTable(); 16 25 - createOptionTable(); 17 18 26 19 27 */ … … 22 30 { 23 31 24 // Function: pw_infocard 25 // Description: Constructor -- Set things up. 26 // Input: none 27 // Output: none 28 // Side effect: initializes some parameters 29 function pw_infocard() 30 { 31 global $table_prefix; 32 33 // We use a bunch of tables to store data 34 $this->table_audit = $table_prefix . "infocard_audit"; 35 $this->table_identity = $table_prefix . "infocard_identities"; 36 37 // We also use some tables from Wordpress default set 38 $this->table_options = $table_prefix . "options"; 39 $this->table_users = $table_prefix . "users"; 40 $this->table_usermeta = $table_prefix . "usermeta"; 32 // Function: pw_infocard 33 // Description: Constructor -- Set things up. 34 // Input: none 35 // Output: none 36 // Side effect: initializes some parameters 37 function pw_infocard() 38 { 39 global $table_prefix; 40 // We use a bunch of tables to store data 41 $this->table_audit = $table_prefix . "infocard_audit"; 42 $this->table_identity = $table_prefix . "infocard_identities"; 43 44 // We also use some tables from Wordpress default set 45 $this->table_options = $table_prefix . "options"; 46 $this->table_users = $table_prefix . "users"; 47 $this->table_usermeta = $table_prefix . "usermeta"; 41 48 42 49 // Options Table 43 50 // For WP we will use the builtin options table. 44 51 45 //$this->table_options = $table_prefix . "infocard_options"; 46 $this->table_options = $table_prefix . "options"; 47 } // end pw_infocard 48 49 // Function: createAuditTable 50 // Description: Create audit table 51 // Input: none 52 // Output: boolean to detect if table was created 53 // Side effect: executes SQL code to create DB tables needed by the plugin 54 function _createAuditTable() { 55 global $wpdb; 56 57 $myTableAuditQuery = 58 "CREATE TABLE `$this->table_audit` ( 59 `modulusHash` varchar(128) NOT NULL default '', 60 `ppid` varchar(128) NOT NULL default '', 61 `accountid` bigint(20) unsigned, 62 `email` varchar(128) NOT NULL default '', 63 `time` datetime NOT NULL default '0000-00-00 00:00:00', 64 `IP` varchar(16) NOT NULL default '', 65 `status` varchar(128) NOT NULL default '' 66 ) ENGINE = MYISAM"; 67 68 // Check if table is already there 69 foreach ($wpdb->get_col("SHOW TABLES", 0) as $table ) { 70 if ($table == $this->table_audit) { 71 return false; 72 } 73 } 74 75 // Ok, let's proceed 76 if ( $wpdb->query( $myTableAuditQuery ) === false ) { 77 return false; 78 } 79 80 // Just to be sure, we check that tables were actually created 81 foreach ( $wpdb->get_col("SHOW TABLES", 0) as $table ) { 82 if ( $table == $this->table_audit ) { 83 return true; 84 } 85 } 86 return false; 87 } 88 // end createAuditTable 89 90 // Function: createIdentityTable 91 // Description: Create identity table 92 // Input: none 93 // Output: boolean to detect if table was created 94 // Side effect: executes SQL code to create DB tables needed by the plugin 95 function _createIdentityTable() { 96 global $wpdb; 97 98 $myTableIdentityQuery = 99 "CREATE TABLE `$this->table_identity` ( 100 `modulusHash` varchar(128) NOT NULL default '', 101 `ppid` varchar(128) NOT NULL default '', 102 `accountid` bigint(20) unsigned 103 ) ENGINE = MYISAM"; 104 105 // Check if table is already there 106 foreach ($wpdb->get_col("SHOW TABLES", 0) as $table ) { 107 if ($table == $this->table_identity) { 108 return false; 109 } 110 } 111 112 // Ok, let's proceed 113 if ( $wpdb->query( $myTableIdentityQuery ) === false ) { 114 return false; 115 } 116 117 // Just to be sure, we check that tables were actually created 118 foreach ( $wpdb->get_col("SHOW TABLES", 0) as $table ) { 119 if ( $table == $this->table_identity ) { 120 return true; 121 } 122 } 123 return false; 124 } 125 // end createIdentityTable 126 127 // Function: createOptionTable 128 // Description: Create option table (in the case of wp not needed) 129 // Input: none 130 // Output: boolean to detect if table was created 131 // Side effect: executes SQL code to create DB tables needed by the plugin 132 function _createOptionTable() { 133 global $wpdb; 52 //$this->table_options = $table_prefix . "infocard_options"; 53 } // end pw_infocard 54 55 // Function: createAuditTable 56 // Description: Create audit table 57 // Input: none 58 // Output: boolean to detect if table was created 59 // Side effect: executes SQL code to create DB tables needed by the plugin 60 function _createAuditTable() 61 { 62 global $wpdb; 63 64 $myTableAuditQuery = 65 "CREATE TABLE IF NOT EXISTS `$this->table_audit` ( 66 `cardhash` text default '', 67 `accountid` bigint(20) unsigned, 68 `email` varchar(128) NOT NULL default '', 69 `time` datetime NOT NULL default '0000-00-00 00:00:00', 70 `IP` varchar(16) NOT NULL default '', 71 `status` varchar(128) NOT NULL default '' 72 ) ENGINE = MYISAM"; 73 74 // Check if table is already there 75 foreach ($wpdb->get_col("SHOW TABLES", 0) as $table ) 76 { 77 if ($table == $this->table_audit) 78 { 79 return false; 80 } 81 } 82 83 // Ok, let's proceed 84 if ( $wpdb->query( $myTableAuditQuery ) === false ) 85 { 86 return false; 87 } 88 89 // Just to be sure, we check that tables were actually created 90 foreach ( $wpdb->get_col("SHOW TABLES", 0) as $table ) 91 { 92 if ( $table == $this->table_audit ) 93 { 94 return true; 95 } 96 } 97 return false; 98 } 99 // end createAuditTable 100 101 // Function: createIdentityTable 102 // Description: Create identity table 103 // Input: none 104 // Output: boolean to detect if table was created 105 // Side effect: executes SQL code to create DB tables needed by the plugin 106 function _createIdentityTable() 107 { 108 global $wpdb; 109 110 /* -- old format 111 $myTableIdentityQuery = 112 "CREATE TABLE `$this->table_identity` ( 113 `cardhash` text default '', 114 `accountid` bigint(20) unsigned, 115 `cardhandle` varchar(128) NOT NULL default '', 116 `startdate` varchar(128) NOT NULL default '', 117 `lastused` varchar(128) NOT NULL default '' 118 ) ENGINE = MYISAM"; 119 */ 120 $myTableIdentityQuery = 121 "CREATE TABLE `$this->table_identity` ( 122 `cardhash` text default '', 123 `accountid` bigint(20) unsigned, 124 `cardhandle` varchar(128) NOT NULL default '', 125 `startdate` varchar(128) NOT NULL default '', 126 `lastused` varchar(128) NOT NULL default '' 127 ) ENGINE = MYISAM"; 128 129 // Check if table is already there 130 foreach ($wpdb->get_col("SHOW TABLES", 0) as $table ) 131 { 132 if ($table == $this->table_identity) 133 { 134 return false; 135 } 136 } 137 138 // Ok, let's proceed 139 if ( $wpdb->query( $myTableIdentityQuery ) === false ) 140 { 141 return false; 142 } 143 144 // Just to be sure, we check that tables were actually created 145 foreach ( $wpdb->get_col("SHOW TABLES", 0) as $table ) 146 { 147 if ( $table == $this->table_identity ) 148 { 149 return true; 150 } 151 } 152 return false; 153 } 154 // end createIdentityTable 155 156 // Function: createOptionTable 157 // Description: Create option table (in the case of wp not needed) 158 // Input: none 159 // Output: boolean to detect if table was created 160 // Side effect: executes SQL code to create DB tables needed by the plugin 161 function _createOptionTable() 162 { 163 global $wpdb; 134 164 135 165 // Might decide later to have all plugins use a standard options 136 166 // table - but for right now, why re-invent the wheel. 137 167 138 // check to see if the wp_options table exists 139 foreach ( $wpdb->get_col("SHOW TABLES", 0) as $table ) { 140 if ( $table == $this->table_identity ) { 141 return true; 142 } 143 } 144 return false; 145 } 146 // end createOptionTable 147 148 // Function: setup 149 // Description: Creates Tables, sets up options. 150 // Input: none 151 // Output: none 152 // Side effect: creates tables 153 function setup() { 154 global $wpdb; 155 156 $isAuditTableCreated = $this->_createAuditTable(); 157 $isIdentityTableCreated = $this->_createIdentityTable(); 158 $isOptionTableCreated = $this->_createOptionTable(); 159 168 // check to see if the wp_options table exists 169 foreach ( $wpdb->get_col("SHOW TABLES", 0) as $table ) 170 { 171 if ( $table == $this->table_options ) 172 { 173 return true; 174 } 175 } 176 return false; 177 } 178 // end createOptionTable 179 180 // Function: setup 181 // Description: Creates Tables, sets up options. 182 // Input: none 183 // Output: none 184 // Side effect: creates tables 185 function setup() 186 { 187 global $wpdb; 188 pw_admin::createInfocardAuditTable(); 189 pw_admin::createInfocardIdentityTable(); 190 191 $isAuditTableCreated = $this->_createAuditTable(); 192 $isIdentityTableCreated = $this->_createIdentityTable(); 193 $isOptionTableCreated = $this->_createOptionTable(); 160 194 161 195 $salt = pw_admin::createClickbackSalt(); … … 167 201 $this->createOption('pw_securesiteurl', $https_url); 168 202 203 $this->createOption('pw_db_version', PW_DB_VERSION); 169 204 $this->createOption('pw_debug_on', 0); 170 205 $this->createOption('pw_enable_pass', 0); 171 172 173 174 } // end function setup 175 176 // Function: createOption 177 // Description: if the option exists & is non-empty, it is kept 178 // the same otherwise it is updated to $option_value 179 // Input: option name, option value 180 // Output:none 181 // Side effect: updates attributes in wp_options 206 $this->createOption('pw_selector_trigger', 'html'); 207 $this->createOption('pw_custom_data', 0); 208 $this->createOption('pw_time_validation', 1); 209 $this->createOption('pw_trust_managed_cards', 'validate'); 210 $this->createOption('pw_trust_personal_cards', 'validate'); 211 $this->createOption('pw_trusted_idp_list', ''); 212 213 } // end function setup 214 215 // Function: createOption 216 // Description: if the option exists & is non-empty, it is kept 217 // the same otherwise it is updated to $option_value 218 // Input: option name, option value 219 // Output: none 220 // Side effect: updates attributes in wp_options 182 221 function createOption($option_name, $option_value ) 183 222 { 184 185 223 $options = get_option($option_name); 186 187 if ( !$options ) 188 $options = $option_value; 189 190 update_option($option_name, $options); 191 224 if ( !$options ) 225 $options = $option_value; 226 227 update_option($option_name, $options); 192 228 } // end function createOptionValue 193 229 … … 204 240 { 205 241 global $current_user; 206 if (strpos($_SERVER[SCRIPT_URI], "https")) 207 { 208 $css = PW_PLUGINURL . "/custom/infocard-frontpage.css"; 209 } 210 else 211 { 212 $css = PW_SECUREPLUGINURL . "/custom/infocard-frontpage.css"; 213 } 242 $css = get_option('siteurl') . "/custom/infocard-frontpage.css"; 214 243 215 244 $chunk = ""; 216 245 if( !$current_user->ID ) 217 246 { 218 $chunk = '<link rel="stylesheet" href="'.$css.'" type="text/css" />'; 247 //$chunk = '<link rel="stylesheet" href="'.$css.'" type="text/css" />'; 248 $chunk = ''; 219 249 // note I set the CSS styles inline because otherwise 220 250 // the user has to link infocard.css - not worth it 221 251 // for this one icon 222 $chunk .='< /li><li><a id="pw_frontpage_link" href="'252 $chunk .='<li><a id="pw_frontpage_link" href="' 223 253 . PW_SECUREPLUGINURL .'/' . PW_PLUGIN 224 254 . '/login/infocard-login.php" alt="' 225 255 . __('Information Card Login') 226 . '" ><img id="pw_frontpage_icon" src="'256 . '" style="border-bottom:none;"><img id="pw_frontpage_icon" src="' 227 257 . PW_IMGURL . '/' .PW_FP_ICON 228 . '" /></a></li>';258 . '" style="border:none; border-bottom: none; background: none;"/></a></div></li>'; 229 259 } 230 return $link . $chunk;260 return $link . $chunk; 231 261 } //end function pw_frontpage_link 232 262 … … 236 266 // display_cryptographp(); 237 267 ?> 238 <hr />239 <a href="<?php echo PW_SECUREPLUGINURL . '/' . PW_PLUGIN; ?>/login/infocard-login.php" alt="<?php _e('Infocard Login'); ?>" style="text-decoration: none; color: #000">240 <?php _e('Login or Register using an Information Card'); ?>268 <hr /> 269 <a href="<?php echo PW_SECUREPLUGINURL . '/' . PW_PLUGIN; ?>/login/infocard-login.php" alt="<?php pw_utils::screenPrint('Infocard Login'); ?>" style="text-decoration: none; color: #000"> 270 <?php pw_utils::screenPrint('Login or Register using an Information Card'); ?> 241 271 <br/> 242 <img src="<?php echo PW_IMGURL; ?>/infocard_60x42.png" style="padding:10px; border: 0;" />243 </a>272 <img src="<?php echo PW_IMGURL; ?>/infocard_60x42.png" style="padding:10px; border:0" /> 273 </a> 244 274 <a alt="<?php echo __('What is this?'); ?>" style="text-decoration: none; color: #000" href="http://pamelaproject.com/"> 245 275 <?php echo __('(what is this?)'); ?> 246 </a> 247 <?php 248 } //end function pw_loginform_link 276 </a> 277 <?php 278 } //end function pw_loginform_link 279 280 281 function pw_registerform_link() 282 { 283 // if ( PW_USECAPTCHAS ) 284 // display_cryptographp(); 285 ?> 286 <hr /> 287 <a href="<?php echo PW_SECUREPLUGINURL . '/' . PW_PLUGIN; ?>/login/infocard-login.php" alt="<?php pw_utils::screenPrint('Infocard Login'); ?>" style="border-bottom: none; color: #FFF"> 288 <?php pw_utils::screenPrint('Register using an Information Card'); ?> 289 <br/> 290 <img src="<?php echo PW_IMGURL; ?>/infocard_60x42.png" style="padding:10px" /> 291 </a> 292 <a alt="<?php echo __('What is this?'); ?>" style="border-bottom: none; color: #fff" href="http://pamelaproject.com/"> 293 <?php echo __('(what is this?)'); ?> 294 </a> 295 <?php 296 } //end function pw_registerform_link 249 297 250 298 function pw_printUserCardStatus() … … 253 301 global $current_user; 254 302 255 $ppid = pw_userdata::getUserPPID( $current_user->ID ); 256 257 if ( $ppid ) 303 $cardcount = pw_processing::getUserCardCount( $current_user->ID ); 304 $handle = pw_processing::getCardHandle( $current_user->ID ); 305 306 if ( $cardcount > 0 ) 258 307 { 259 308 ?> 260 309 <p> 261 <img src="<?php echo PW_IMGURL; ?>/ic-logo/ic-logo-blue-icon.png"/> <?php pw_utils::screenPrint('Information Card ID: '); ?> 310 <img src="<?php echo PW_IMGURL; ?>/infocard_60x42.png"/> 311 <?php 312 pw_utils::screenPrint('An Information Card is associated with this account'); 313 //pw_utils::screenPrint('Information Card ID: ' . $handle); 314 ?> 262 315 </p> 263 316 … … 269 322 . "<label for='Information Card Info' style='display: inline'><img src=\"" 270 323 . PW_IMGURL 271 . '/i c-logo/ic-logo-disabled.png"'324 . '/infocard_60x42_disabled.png"' 272 325 . " style='vertical-align: middle'/> "; 273 pw_utils::screenPrint('No Information Card in use.');326 pw_utils::screenPrint('No Information Card associated with this account.'); 274 327 echo "</label></p>"; 275 328 } … … 279 332 class pw_admin extends pwlib_admin 280 333 { 281 // Function: getOption282 // Description: Retrieves things set in wp_options283 // Input: attribute name284 // Output: attribute value285 // Side effect: none334 // Function: getOption 335 // Description: Retrieves things set in wp_options 336 // Input: attribute name 337 // Output: attribute value 338 // Side effect: none 286 339 function getOption($attr_name) 287 340 { 288 return get_settings($attr_name); 289 341 return get_option($attr_name); 290 342 } //end function getOption 291 343 292 // Function: createNewAccount 293 // Description: creates a new db record 294 // Input: account details 295 // Output: returns the user Id on success, FALSE on failure 296 // Side effect: none 297 function createNewAccount( $user_login, $user_pass, $user_email, $user_url, $user_firstname, $user_lastname ) 298 { 299 require_once( ABSPATH . WPINC . '/registration-functions.php'); 300 301 InfocardUtils::printDebug("<br/>Action: createNewAccount<br>"); 302 $user_nicename = "$user_firstname $user_lastname"; 303 InfocardUtils::printDebug("<br/>Nice Name: $user_nicename<br>"); 304 $display_name = $user_nicename; 305 $userdata = compact('user_login', 'user_pass', 'user_email', 'user_nicename', 'user_url', 'display_name', 'user_firstname', 'user_lastname'); 306 $user_ID = wp_insert_user($userdata); 307 308 if ($user_ID) 309 { 310 InfocardUtils::printDebug(" Inserted record # $user_ID<br>"); 311 return $user_ID; 312 } else { 313 InfocardUtils::printDebug(" Error - new user not created<br/>"); 314 return FALSE; 315 } 316 317 } // end function createNewAccount 318 344 function createOption( $option_name, $option_value ) 345 { 346 // this is duplicated in the case of the wordpress plugin. 347 $options = get_option($option_name); 348 if ( !$options ) 349 $options = $option_value; 350 351 update_option($option_name, $options); 352 } 353 354 function removeOption( $option_name ) 355 { 356 delete_option( $option_name ); 357 358 } 359 319 360 function pwAdminScreen() 320 361 { 321 362 // get initial option values 322 $ic_opener = $new_opener = pw_admin::getOption('pw_infocard_opener'); 323 $ic_key = $new_key = pw_admin::getOption('pw_infocard_key'); 324 $secureurl = $new_secureurl = pw_admin::getOption('pw_securesiteurl'); 325 $ic_secret = pw_admin::getOption('secret'); 326 $ic_debug = $new_debug = pw_admin::getOption('pw_debug_on'); 327 $ic_pass = $new_pass = pw_admin::getOption('pw_enable_pass'); 328 363 $opts = pw_admin::updateAdminOptions(); 329 364 // write submitted changes if this page reload shows a submit 330 if ( $_POST["infocard_admin_submit"] ) 331 { 332 $new_opener = $_POST['pw_infocard_opener']; 333 $new_key = $_POST['pw_infocard_key']; 334 $new_secureurl = $_POST['pw_securesiteurl']; 335 $new_debug = $_POST['pw_debug_on']; 336 $new_pass = $_POST['pw_enable_pass']; 337 } 338 339 if ( $ic_opener != $new_opener ){ 340 update_option('pw_infocard_opener', $new_opener); 341 } 342 343 if ( $ic_key != $new_key ){ 344 update_option('pw_infocard_key', $new_key); 345 } 346 347 if ( $secureurl != $new_secureurl ){ 348 update_option('pw_securesiteurl', $new_secureurl ); 349 } 350 351 if ( $ic_debug != $new_debug ){ 352 update_option('pw_debug_on', $new_debug ); 353 } 354 355 if ( $ic_pass != $new_pass ){ 356 update_option('pw_enable_pass', $new_pass ); 357 } 358 359 pw_admin::printSystemCheck($new_secureurl); 360 ?> 361 <form action="" method="post"> 365 if (pw_utils::databaseUpToDate()) 366 { 367 echo "<p>Plugin Version: ". PW_VERSION . " " . PW_VERSION_DATE 368 . " (" . $opts['pw_db_version'] . ")</p>"; 369 } 370 else 371 { 372 ?> 373 <form action="" method="post"> 374 <?php 375 echo "<div id='message' class='updated'>" . pw_admin::fixDatabase() . "</div>"; 376 ?> 377 <input type="submit" name="infocard_admin_upgrade" id="infocard_admin_upgrade" value="Continue" /> 378 </form> 379 <?php 380 return; 381 } 382 383 pw_admin::printSystemCheck($opts['pw_securesiteurl']); 384 ?> 385 <form action="" method="post"> 362 386 <table border="0"><tr><th valign="bottom" colspan="2" align="left"> 363 387 <tr><td> </td><td/></tr> … … 366 390 <tr><td valign="top"> 367 391 <label for="securesiteurl" title="Secure Site URL"> 368 <?php _e('Secure Site URL', 'wp-infocard'); ?>392 <?php pw_utils::screenPrint('Secure Site URL'); ?> 369 393 </label> 370 394 </td><td> 371 <input type="text" name="pw_securesiteurl" id="pw_securesiteurl" size="50" value="<?php print $ new_secureurl; ?>" />395 <input type="text" name="pw_securesiteurl" id="pw_securesiteurl" size="50" value="<?php print $opts['pw_securesiteurl']; ?>" /> 372 396 </td></tr> 373 397 374 398 <tr><td valign="top"> 375 399 <label for="pw_infocard_key" title="SSL Private Key"> 376 <?php _e('SSL Private Key', 'wp-infocard'); ?>400 <?php pw_utils::screenPrint('SSL Private Key'); ?> 377 401 </label> 378 402 </td><td> 379 <textarea cols="60" rows="4" name="pw_infocard_key" id="pw_infocard_key"><?php print $ new_key; ?></textarea>403 <textarea cols="60" rows="4" name="pw_infocard_key" id="pw_infocard_key"><?php print $opts['pw_infocard_key']; ?></textarea> 380 404 </td></tr> 381 405 <tr><td> 382 406 <label for="pw_infocard_opener" title="SSL Passphrase"> 383 <?php _e('SSL Passphrase', 'wp-infocard'); ?>407 <?php pw_utils::screenPrint('SSL Passphrase'); ?> 384 408 </label> 385 409 </td><td> 386 <input type="text" name="pw_infocard_opener" id="pw_infocard_opener" size="50" value="<?php print $new_opener; ?>" /> 410 <input type="text" name="pw_infocard_opener" id="pw_infocard_opener" size="50" value="<?php print $opts['pw_infocard_opener']; ?>" /> 411 <?php /* 387 412 </td></tr> 388 413 <tr><td colspan="2"> 389 <input name="pw_enable_pass" type="checkbox" id="pw_enable_pass" value="1" <?php checked('1', ($new_pass)); ?> /> 390 <?php _e('Use Username/Password in addition to Information Cards', 'wp-infocard'); ?> 391 </td></tr> 414 <input name="pw_enable_pass" type="checkbox" id="pw_enable_pass" value="1" <?php checked('1', ($opts['pw_enable_pass'])); ?> /> 415 <?php pw_utils::screenPrint('Use Username/Password in addition to Information Cards'); ?> 416 </td></tr> 417 */ ?> 392 418 <tr><td> </td><td/></tr> 393 <tr><td> 394 <?php 395 if (!$ic_secret) { 396 _e('There is no 32-bit secret generated for this blog - the secret is needed for security purposes. Do not use this plugin until a secret has been generated & placed into the database', 'wp-infocard'); 397 } 398 ?> 419 <tr><th colspan="2" align="left">To Enable Information Card User Login</td></tr> 420 <tr><td colspan="2"><?php pw_utils::screenPrint('The following changes will result in a login form with the option "Use an Information Card". Please make a copy of the wp-login.php file before you begin, so that you can revert to that original file in case of difficulties.'); ?></td></tr> <tr><td colspan="2" id="code"> 421 <?php 422 pw_admin::printInstallData(); 423 ?> 399 424 </td></tr> 400 <tr><th colspan="2" align="left">To Enable Information Card User Login</td></tr> 401 <tr><td colspan="2"><?php _e('The following changes will result in a login form with the option "Use an Information Card". Please make a copy of the wp-login.php file before you begin, so that you can revert to that original file in case of difficulties.'); ?></td></tr> 402 <tr><td colspan="2" id="code"> 403 <?php 404 pw_admin::printInstallData(); 405 ?> 406 </td></tr> 407 <tr><td> </td><td/></tr> 408 <tr><th colspan="2" align="left">Advanced TroubleShooting</td></tr> 409 <tr><td> </td><td/></tr> 410 <tr><td colspan="2"> 411 <input name="pw_debug_on" type="checkbox" id="pw_debug_on" value="1" <?php checked('1', ($new_debug)); ?> /> 412 <?php _e('Debug Mode', 'wp-infocard'); ?> 413 </td></tr> 414 <tr><td> </td><td/></tr> 415 <tr><td colspan="2"><?php _e('This test requires that changes be made to the Apache configuration files. You only need to run this test if everything is green above, but things are still broken.'); ?></td></tr> 416 <tr><td> 417 <?php _e('Advanced Certificate Check', 'wp-infocard'); ?> 418 </td><td valign="bottom"> 419 <?php //pw_admin::advancedCertTest(IC_IMGURL); ?> 420 <br/> <a href="help/help.php?topic=advancedcerttest"><?php _e('More Information', 'wp-infocard');?></a> 421 </td></tr> 422 425 <tr><td> </td><td/></tr> 426 <tr><th colspan="2" align="left"> 427 <?php pw_utils::ScreenPrint('Advanced Settings'); ?> 428 </td></tr> 429 <tr><td colspan="2"> 430 <?php pw_utils::screenPrint('Don\'t mess with these unless you understand and accept the consequences. Security breaches or errors could occur if you change these settings under the wrong circumstances.'); ?> 431 </td></tr> 432 <tr><td colspan="2"> </td></tr> 433 <tr><td> 434 <?php pw_utils::screenPrint('Debug Mode'); ?> 435 </td><td> 436 <input name="pw_debug_on" type="radio" id="pw_debug_on" value="1" <?php echo ($opts['pw_debug_on'])?"checked":""; ?> /> 437 <?php pw_utils::screenPrint('On'); ?> 438 439 <input name="pw_debug_on" type="radio" id="pw_debug_on" value="0" <?php echo ($opts['pw_debug_on'])?"":"checked"; ?> /> 440 <?php pw_utils::screenPrint('Off'); ?> 441 </td></tr> 442 <tr><td> 443 <?php pw_utils::screenPrint('Time Validation'); ?> 444 </td><td> 445 <input name="pw_time_validation" type="radio" id="pw_time_validation" value="1" <?php echo ($opts['pw_time_validation'])?"checked":""; ?> /> 446 <?php pw_utils::screenPrint('On'); ?> 447 <input name="pw_time_validation" type="radio" id="pw_time_validation" value="0" <?php echo ($opts['pw_time_validation'])?"":"checked"; ?> /> 448 <?php pw_utils::screenPrint('Off'); ?> 449 <tr><td> 450 <?php pw_utils::screenPrint('Use Custom Data'); ?> 451 </td><td> 452 <input name="pw_custom_data" type="radio" id="pw_custom_data" value="1" <?php echo ($opts['pw_custom_data'])?"checked":""; ?> /> 453 <?php pw_utils::screenPrint('On'); ?> 454 <input name="pw_custom_data" type="radio" id="pw_custom_data" value="0" <?php echo ($opts['pw_custom_data'])?"":"checked"; ?> /> 455 <?php pw_utils::screenPrint('Off'); ?> 456 </td></tr> 457 <tr><td> 458 <?php pw_utils::screenPrint('Selector Trigger'); ?> 459 </td><td> 460 <input name="pw_selector_trigger" type="radio" id="pw_selector_trigger" value="html" <?php echo ($opts['pw_selector_trigger'] === 'html')?"checked":""; ?> /> 461 <?php pw_utils::screenPrint('HTML'); ?> 462 <input name="pw_selector_trigger" type="radio" id="pw_selector_trigger" value="xhtml" <?php echo ($opts['pw_selector_trigger'] === 'xhtml')?"checked":""; ?> /> 463 <?php pw_utils::screenPrint('XHTML'); ?> 464 </td></tr> 465 <?php 466 print pw_admin::getPWAdminCardOptions( $opts ); 467 ?> 423 468 </table> 424 <input type="submit" name="infocard_admin_submit" id="infocard_admin_submit" value="<?php _e('Save', 'wp-infocard');?>" />469 <input type="submit" name="infocard_admin_submit" id="infocard_admin_submit" value="<?php pw_utils::screenPrint('Save');?>" /> 425 470 </p> 426 471 </form> … … 430 475 function printInstallData() 431 476 { 432 return; // no need for extra steps anymore477 return; // no need for extra steps for WordPress, yay! 433 478 } // end function printInstallData 434 479 435 480 function pw_sidebar_cardlogin( $link ) 436 481 { 437 if( strstr('redirect_to', $link )) return $link; 438 return str_replace( 'action=logout', 'action=logout' . ini_get('arg_separator.output') . 'redirect_to=' . urlencode($_SERVER["REQUEST_URI"]), $link ); 439 } 482 if (strstr('redirect_to', $link )) 483 return $link; 484 return str_replace( 'action=logout', 'action=logout' . ini_get('arg_separator.output') . 'redirect_to=' . urlencode($_SERVER["REQUEST_URI"]), $link ); 485 } 440 486 441 487 function setupCaptcha() … … 444 490 return; 445 491 } 492 493 // Function: setOption 494 // Description: updates an option in the infocard_options table 495 // Input: option_name: the name of the option 496 // option_val: the new value 497 // Output: the value set 498 // Side Effects: writes to the database 499 function setOption( $option_name, $option_val ) 500 { 501 update_option($option_name, $option_val); 502 return $option_val; 503 } 504 505 function createInfocardAuditTable() 506 { 507 global $wpdb; 508 $audittable = PW_TABLE_PREFIX . "infocard_audit"; 509 510 $myTableAuditQuery = 511 "CREATE TABLE IF NOT EXISTS `" . $audittable . "` ( 512 `cardhash` text default '', 513 `accountid` bigint(20) unsigned, 514 `email` varchar(128) NOT NULL default '', 515 `time` datetime NOT NULL default '0000-00-00 00:00:00', 516 `IP` varchar(16) NOT NULL default '', 517 `status` varchar(128) NOT NULL default '' 518 ) ENGINE = MYISAM"; 519 520 // Check if table is already there 521 foreach ($wpdb->get_col("SHOW TABLES", 0) as $table ) 522 { 523 if ($table == $audittable) 524 { 525 return false; 526 } 527 } 528 529 // Ok, let's proceed 530 if ( $wpdb->query( $myTableAuditQuery ) === false ) 531 { 532 return false; 533 } 534 535 // Just to be sure, we check that tables were actually created 536 foreach ( $wpdb->get_col("SHOW TABLES", 0) as $table ) 537 { 538 if ( $table == $audittable ) 539 { 540 return true; 541 } 542 } 543 return false; 544 } //end function createInfocardAuditTable 545 546 funct
