/** * Sets the IIS rewrite rules * * @return bool Returns true on success and false on failure */ function gp_set_webconfig($path) { if (file_exists('web.config')) { return false; } // Try and create the web.config file. $webconfig_file = @fopen('web.config', 'w'); // error opening htaccess, inform user! if (false === $webconfig_file) { return false; } // Write the rules out to the web.config file fwrite($webconfig_file, gp_mod_rewrite_rules($path)); fclose($webconfig_file); return true; }
/** * Sets the rewrite rules * * @return bool Returns true on success and false on failure */ function gp_set_htaccess() { // The server doesn't support mod rewrite if (!apache_mod_loaded('mod_rewrite', true)) { return false; } if (file_exists('.htaccess') && !is_writeable('.htaccess')) { return false; } // check if the .htaccess is in place or try to write it $htaccess_file = @fopen('.htaccess', 'c+'); //error opening htaccess, inform user! if (false === $htaccess_file) { return false; } //'# BEGIN GlotPress' not found, write the access rules if (false === strpos(stream_get_contents($htaccess_file), '# BEGIN GlotPress')) { fwrite($htaccess_file, gp_mod_rewrite_rules()); } fclose($htaccess_file); return true; }
echo '<p>' . $success_message . '</p>'; } } ?> <?php // TODO: deny access to scripts folder if ($show_htaccess_instructions) { ?> <p> <?php _e('If your <code>.htaccess</code> file was writeable, we could do this automatically, but it isn’t so these are the mod_rewrite rules you should have in your <code>.htaccess</code> file.'); ?> <pre><?php echo esc_html(gp_mod_rewrite_rules()); ?> </pre> </p> <?php } // TODO: deny access to scripts folder if ($show_webconfig_instructions) { ?> <p> <?php _e('If your <code>web.config</code> didn’t exist, we could do this automatically, but it does so these are the IIS rewrite rules you should have in your <code>web.config</code> file.'); ?> <pre><?php echo esc_html(gp_iis_rewrite_rules());