Changeset 11450 for trunk/wp-admin/includes/misc.php
- Timestamp:
- 05/24/2009 11:47:49 PM (15 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/wp-admin/includes/misc.php
r11350 r11450 139 139 * Updates the IIS web.config file with the current rules if it is writable. 140 140 * If the permalinks do not require rewrite rules then the rules are deleted from the web.config file. 141 * 141 * 142 142 * @since 2.8.0 143 * 143 * 144 144 * @return bool True if web.config was updated successfully 145 145 */ 146 146 function iis7_save_url_rewrite_rules(){ 147 147 global $wp_rewrite; 148 148 149 149 $home_path = get_home_path(); 150 150 $web_config_file = $home_path . 'web.config'; 151 151 152 // Using win_is_writable() instead of is_writable() because of a bug in Windows PHP 152 // Using win_is_writable() instead of is_writable() because of a bug in Windows PHP 153 153 if ( ( ! file_exists($web_config_file) && win_is_writable($home_path) && $wp_rewrite->using_mod_rewrite_permalinks() ) || win_is_writable($web_config_file) ) { 154 154 if ( iis7_supports_permalinks() ) { … … 402 402 /** 403 403 * Check if IIS 7 supports pretty permalinks 404 * 404 * 405 405 * @since 2.8.0 406 * 406 * 407 407 * @return bool 408 408 */ … … 410 410 global $is_iis7; 411 411 412 $supports_permalinks = false; 412 $supports_permalinks = false; 413 413 if ( $is_iis7 ) { 414 414 /* First we check if the DOMDocument class exists. If it does not exist, … … 419 419 * Next we check if the URL Rewrite Module 1.1 is loaded and enabled for the web site. When 420 420 * URL Rewrite 1.1 is loaded it always sets a server variable called 'IIS_UrlRewriteModule'. 421 * Lastly we make sure that PHP is running via FastCGI. This is important because if it runs 421 * Lastly we make sure that PHP is running via FastCGI. This is important because if it runs 422 422 * via ISAPI then pretty permalinks will not work. 423 423 */ 424 424 $supports_permalinks = class_exists('DOMDocument') && isset($_SERVER['IIS_UrlRewriteModule']) && ( php_sapi_name() == 'cgi-fcgi' ); 425 425 } 426 426 427 427 return apply_filters('iis7_supports_permalinks', $supports_permalinks); 428 428 } … … 430 430 /** 431 431 * Check if rewrite rule for WordPress already exists in the IIS 7 configuration file 432 * 432 * 433 433 * @since 2.8.0 434 * 434 * 435 435 * @return bool 436 436 * @param string $filename The file path to the configuration file 437 437 */ 438 function iis7_rewrite_rule_exists($filename) { 438 function iis7_rewrite_rule_exists($filename) { 439 439 if ( ! file_exists($filename) ) 440 return false; 440 return false; 441 441 if ( ! class_exists('DOMDocument') ) 442 442 return false; 443 443 444 444 $doc = new DOMDocument(); 445 445 if ( $doc->load($filename) === false ) … … 450 450 return false; 451 451 else 452 return true; 452 return true; 453 453 } 454 454 … … 456 456 * Delete WordPress rewrite rule from web.config file if it exists there 457 457 * 458 * @since 2.8.0 458 * @since 2.8.0 459 459 * 460 460 * @param string $filename Name of the configuration file 461 461 * @return bool 462 462 */ 463 function iis7_delete_rewrite_rule($filename) { 463 function iis7_delete_rewrite_rule($filename) { 464 464 // If configuration file does not exist then rules also do not exist so there is nothing to delete 465 465 if ( ! file_exists($filename) ) 466 466 return true; 467 467 468 468 if ( ! class_exists('DOMDocument') ) 469 469 return false; 470 470 471 471 $doc = new DOMDocument(); 472 472 $doc->preserveWhiteSpace = false; … … 488 488 /** 489 489 * Add WordPress rewrite rule to the IIS 7 configuration file. 490 * 490 * 491 491 * @since 2.8.0 492 * 492 * 493 493 * @param string $filename The file path to the configuration file 494 494 * @param string $rewrite_rule The XML fragment with URL Rewrite rule 495 495 * @return bool 496 496 */ 497 function iis7_add_rewrite_rule($filename, $rewrite_rule) { 497 function iis7_add_rewrite_rule($filename, $rewrite_rule) { 498 498 if ( ! class_exists('DOMDocument') ) 499 499 return false; 500 500 501 501 // If configuration file does not exist then we create one. 502 502 if ( ! file_exists($filename) ) { … … 505 505 fclose($fp); 506 506 } 507 507 508 508 $doc = new DOMDocument(); 509 509 $doc->preserveWhiteSpace = false; … … 511 511 if ( $doc->load($filename) === false ) 512 512 return false; 513 513 514 514 $xpath = new DOMXPath($doc); 515 515 … … 525 525 } else { 526 526 $rules_node = $doc->createElement('rules'); 527 527 528 528 $xmlnodes = $xpath->query('/configuration/system.webServer/rewrite'); 529 529 if ( $xmlnodes->length > 0 ) { … … 541 541 $system_webServer_node = $doc->createElement('system.webServer'); 542 542 $system_webServer_node->appendChild($rewrite_node); 543 543 544 544 $xmlnodes = $xpath->query('/configuration'); 545 545 if ( $xmlnodes->length > 0 ) { … … 554 554 } 555 555 } 556 556 557 557 $rule_fragment = $doc->createDocumentFragment(); 558 558 $rule_fragment->appendXML($rewrite_rule); 559 559 $rules_node->appendChild($rule_fragment); 560 560 561 $doc->formatOutput = true; 561 $doc->formatOutput = true; 562 562 saveDomDocument($doc, $filename); 563 563 564 return true; 564 return true; 565 565 } 566 566 567 567 /** 568 568 * Saves the XML document into a file 569 * 569 * 570 570 * @since 2.8.0 571 571 *
Note: See TracChangeset
for help on using the changeset viewer.