Portable bookmarks - storing URI instead of full HTTP_REFERER

Do something cool with CMS? Show us ...
This board is for 'Answers', and the discussion of answers... Not for questions.
Post Reply
honcho

Portable bookmarks - storing URI instead of full HTTP_REFERER

Post by honcho »

I noticed that when a user in the admin panel makes a bookmark, it stores the fully qualified URL, not the URI.  This makes the bookmark less portable, because it won't work if the domain is changed or the site is ported to a different domain for development or production.

I implemented the following remedy in my code, sharing it here in case you find it useful.  I'd also welcome CMSMS's development group to look at this and decide if this or a similar remedy should be added to a subsequent release of CMSMS.

In admin/makebookmark.php I changed the following:

$origlink = $_SERVER['HTTP_REFERER'];

(changed to)

// Store URI as bookmark, not full URL, for bookmark portability
$bkParts = explode( $_SERVER['HTTP_HOST'], $_SERVER['HTTP_REFERER'] );
$origlink = ( (sizeof( $bkParts) > 1 ) ? $bkParts[1] : $_SERVER['HTTP_REFERER'] );
//$origlink = $_SERVER['HTTP_REFERER'];


This change was done in CMS Made Simple 1.5.2 "Caguas"
User avatar
Dr.CSS
Moderator
Moderator
Posts: 12711
Joined: Thu Mar 09, 2006 5:32 am

Re: Portable bookmarks - storing URI instead of full HTTP_REFERER

Post by Dr.CSS »

Post Reply

Return to “Tips and Tricks”