Changeset 164
- Timestamp:
- 05/09/08 09:51:55 (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
r144 r164 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.php8 //9 2 //defined( '_VALID_IC' ) or die( 'Direct Access to this location is not allowed.'); 10 3 include_once( dirname(__FILE__) . '/../pw-config.php'); 11 4 include_once( dirname(__FILE__) . '/../pwlib/admin.pwlib.php'); 12 include_once( dirname(__FILE__) . '/processing.pw.php');13 include_once( dirname(__FILE__) . '/utils.pw.php');14 5 //require_once( ABSPATH . WPINC . '/registration-functions.php'); 15 6 /* … … 24 15 - createIdentityTable(); 25 16 - createOptionTable(); 17 26 18 27 19 */ … … 30 22 { 31 23 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"; 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"; 48 41 49 42 // Options Table 50 43 // For WP we will use the builtin options table. 51 44 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; 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; 164 134 165 135 // Might decide later to have all plugins use a standard options 166 136 // table - but for right now, why re-invent the wheel. 167 137 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(); 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 194 160 195 161 $salt = pw_admin::createClickbackSalt(); … … 201 167 $this->createOption('pw_securesiteurl', $https_url); 202 168 203 $this->createOption('pw_db_version', PW_DB_VERSION);204 169 $this->createOption('pw_debug_on', 0); 205 170 $this->createOption('pw_enable_pass', 0); 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 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 221 182 function createOption($option_name, $option_value ) 222 183 { 184 223 185 $options = get_option($option_name); 224 if ( !$options ) 225 $options = $option_value; 226 227 update_option($option_name, $options); 186 187 if ( !$options ) 188 $options = $option_value; 189 190 update_option($option_name, $options); 191 228 192 } // end function createOptionValue 229 193 … … 240 204 { 241 205 global $current_user; 242 $css = get_option('siteurl') . "/custom/infocard-frontpage.css"; 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 } 243 214 244 215 $chunk = ""; 245 216 if( !$current_user->ID ) 246 217 { 247 //$chunk = '<link rel="stylesheet" href="'.$css.'" type="text/css" />'; 248 $chunk = ''; 218 $chunk = '<link rel="stylesheet" href="'.$css.'" type="text/css" />'; 249 219 // note I set the CSS styles inline because otherwise 250 220 // the user has to link infocard.css - not worth it 251 221 // for this one icon 252 $chunk .='< li><a id="pw_frontpage_link" href="'222 $chunk .='</li><li><a id="pw_frontpage_link" href="' 253 223 . PW_SECUREPLUGINURL .'/' . PW_PLUGIN 254 224 . '/login/infocard-login.php" alt="' 255 225 . __('Information Card Login') 256 . '" style="border-bottom:none;"><img id="pw_frontpage_icon" src="'226 . '"><img id="pw_frontpage_icon" src="' 257 227 . PW_IMGURL . '/' .PW_FP_ICON 258 . '" style="border:none; border-bottom: none; background: none;"/></a></div></li>';259 } 260 return $link . $chunk;228 . '"/></a></li>'; 229 } 230 return $link . $chunk; 261 231 } //end function pw_frontpage_link 262 232 … … 266 236 // display_cryptographp(); 267 237 ?> 268 <hr />269 <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">270 <?php pw_utils::screenPrint('Login or Register using an Information Card'); ?>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'); ?> 271 241 <br/> 272 <img src="<?php echo PW_IMGURL; ?>/infocard_60x42.png" style="padding:10px " />273 </a>274 <a alt="<?php echo __('What is this?'); ?>" style=" border-bottom: none; color: #fff" href="http://pamelaproject.com/">242 <img src="<?php echo PW_IMGURL; ?>/infocard_60x42.png" style="padding:10px; border: 0;" /> 243 </a> 244 <a alt="<?php echo __('What is this?'); ?>" style="text-decoration: none; color: #000" href="http://pamelaproject.com/"> 275 245 <?php echo __('(what is this?)'); ?> 276 </a> 246 </a> 277 247 <?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 248 } //end function pw_loginform_link 297 249 298 250 function pw_printUserCardStatus() … … 301 253 global $current_user; 302 254 303 $cardcount = pw_processing::getUserCardCount( $current_user->ID ); 304 $handle = pw_processing::getCardHandle( $current_user->ID ); 305 306 if ( $cardcount > 0 ) 255 $ppid = pw_userdata::getUserPPID( $current_user->ID ); 256 257 if ( $ppid ) 307 258 { 308 259 ?> 309 260 <p> 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 ?> 261 <img src="<?php echo PW_IMGURL; ?>/ic-logo/ic-logo-blue-icon.png"/> <?php pw_utils::screenPrint('Information Card ID: '); ?> 315 262 </p> 316 263 … … 322 269 . "<label for='Information Card Info' style='display: inline'><img src=\"" 323 270 . PW_IMGURL 324 . '/i nfocard_60x42_disabled.png"'271 . '/ic-logo/ic-logo-disabled.png"' 325 272 . " style='vertical-align: middle'/> "; 326 pw_utils::screenPrint('No Information Card associated with this account.');273 pw_utils::screenPrint('No Information Card in use.'); 327 274 echo "</label></p>"; 328 275 } … … 332 279 class pw_admin extends pwlib_admin 333 280 { 334 // Function: getOption335 // Description: Retrieves things set in wp_options336 // Input: attribute name337 // Output: attribute value338 // Side effect: none281 // Function: getOption 282 // Description: Retrieves things set in wp_options 283 // Input: attribute name 284 // Output: attribute value 285 // Side effect: none 339 286 function getOption($attr_name) 340 287 { 341 return get_option($attr_name); 288 return get_settings($attr_name); 289 342 290 } //end function getOption 343 291 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 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 360 319 function pwAdminScreen() 361 320 { 362 321 // get initial option values 363 $opts = pw_admin::updateAdminOptions(); 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 364 329 // write submitted changes if this page reload shows a submit 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"> 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"> 386 362 <table border="0"><tr><th valign="bottom" colspan="2" align="left"> 387 363 <tr><td> </td><td/></tr> … … 390 366 <tr><td valign="top"> 391 367 <label for="securesiteurl" title="Secure Site URL"> 392 <?php pw_utils::screenPrint('Secure Site URL'); ?>368 <?php _e('Secure Site URL', 'wp-infocard'); ?> 393 369 </label> 394 370 </td><td> 395 <input type="text" name="pw_securesiteurl" id="pw_securesiteurl" size="50" value="<?php print $ opts['pw_securesiteurl']; ?>" />371 <input type="text" name="pw_securesiteurl" id="pw_securesiteurl" size="50" value="<?php print $new_secureurl; ?>" /> 396 372 </td></tr> 397 373 398 374 <tr><td valign="top"> 399 375 <label for="pw_infocard_key" title="SSL Private Key"> 400 <?php pw_utils::screenPrint('SSL Private Key'); ?>376 <?php _e('SSL Private Key', 'wp-infocard'); ?> 401 377 </label> 402 378 </td><td> 403 <textarea cols="60" rows="4" name="pw_infocard_key" id="pw_infocard_key"><?php print $ opts['pw_infocard_key']; ?></textarea>379 <textarea cols="60" rows="4" name="pw_infocard_key" id="pw_infocard_key"><?php print $new_key; ?></textarea> 404 380 </td></tr> 405 381 <tr><td> 406 382 <label for="pw_infocard_opener" title="SSL Passphrase"> 407 <?php pw_utils::screenPrint('SSL Passphrase'); ?>383 <?php _e('SSL Passphrase', 'wp-infocard'); ?> 408 384 </label> 409 385 </td><td> 410 <input type="text" name="pw_infocard_opener" id="pw_infocard_opener" size="50" value="<?php print $opts['pw_infocard_opener']; ?>" /> 411 <?php /* 386 <input type="text" name="pw_infocard_opener" id="pw_infocard_opener" size="50" value="<?php print $new_opener; ?>" /> 412 387 </td></tr> 413 388 <tr><td colspan="2"> 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 */ ?> 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> 418 392 <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 ?> 399 </td></tr> 419 400 <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"> 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"> 421 403 <?php 422 404 pw_admin::printInstallData(); 423 ?> 424 </td></tr> 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 ?> 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 468 423 </table> 469 <input type="submit" name="infocard_admin_submit" id="infocard_admin_submit" value="<?php pw_utils::screenPrint('Save');?>" />424 <input type="submit" name="infocard_admin_submit" id="infocard_admin_submit" value="<?php _e('Save', 'wp-infocard');?>" /> 470 425 </p> 471 426 </form> … … 475 430 function printInstallData() 476 431 { 477 return; // no need for extra steps for WordPress, yay!432 return; // no need for extra steps anymore 478 433 } // end function printInstallData 479 434 480 435 function pw_sidebar_cardlogin( $link ) 481 436 { 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 } 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 } 486 440 487 441 function setupCaptcha() … … 490 444 return; 491 445 } 492 493 // Function: setOption494 // Description: updates an option in the infocard_options table495 // Input: option_name: the name of the option496 // option_val: the new value497 // Output: the value set498 // Side Effects: writes to the database499 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 there521 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 proceed530 if ( $wpdb->query( $myTableAuditQuery ) === false )531 {532 return false;533 }534 535 // Just to be sure, we check that tables were actually created536 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
