Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Change $userrequest source in redirect() #5

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 2 additions & 25 deletions wp-simple-301-redirects.php
Original file line number Diff line number Diff line change
Expand Up @@ -240,7 +240,7 @@ function save_redirects() {
*/
function redirect() {
// this is what the user asked for (strip out home portion, case insensitive)
$userrequest = str_ireplace(get_option('home'),'',$this->get_address());
$userrequest = $_SERVER['REQUEST_URI'];
$userrequest = rtrim($userrequest,'/');

$this->maybe_upgrade_db(); // upgrade the storage format if needed @todo: benchmark this, tune for speed
Expand Down Expand Up @@ -310,29 +310,6 @@ function ajax_delete() {
}
else { echo 'failure'; exit; } // something went wrong
}

/**
* getAddress function
* utility function to get the full address of the current request
* credit: http://www.phpro.org/examples/Get-Full-URL.html
* @access public
* @return void
*/
function get_address() {
// return the full address
return $this->get_protocol().'://'.$_SERVER['HTTP_HOST'].$_SERVER['REQUEST_URI'];
} // end function get_address

function get_protocol() {
// Set the base protocol to http
$protocol = 'http';
// check for https
if ( isset( $_SERVER["HTTPS"] ) && strtolower( $_SERVER["HTTPS"] ) == "on" ) {
$protocol .= "s";
}

return $protocol;
} // end function get_protocol

function maybe_upgrade_db() {
$latest_db_version = 2;
Expand Down Expand Up @@ -410,4 +387,4 @@ function str_ireplace($search,$replace,$subject){
$subject = str_replace($token,$replace,$subject);
return $subject;
}
}
}