Welcome to Geeklog, Anonymous Thursday, December 26 2024 @ 11:10 am EST

Geeklog Forums

Shorter URLs for Userpages


Status: Banned

gtgillis

Forum User
Full Member
Registered: 11/05/03
Posts: 121
I am playing with an idea to give select users there own page that they can update as they please although I would have ultimate control. I would like any comments on the concept and possible problems.

The idea is that a user has a nice short url on my site to get to their page. In the example on my site www.sillig.com I have a user named sparky. To get to sparkys page go to www.sillig.com/sparky . I have added some code to 404.php which will look in a new table and if it matches www.sillig.com/sparky it does a COM_refresh and loads a static page also stored in the table. I suppose I could just store the id of the static page and grab the info from the static page table. Anyway, I am thinking of copying the static page creation code and modifying it so that the user can only edit their own page. I also want to add the ability of other users to leave comments.

In my test I got the test code to work fine running firefox but it craps out in IE.

All comments appreciated.
 Quote

Status: offline

jhackwith

Forum User
Chatty
Registered: 07/24/04
Posts: 63
Location:Lewiston, Idaho
Quote by: gtgillis

I am playing with an idea to give select users there own page that they can update as they please although I would have ultimate control. I would like any comments on the concept and possible problems.

The idea is that a user has a nice short url on my site to get to their page. In the example on my site www.sillig.com I have a user named sparky. To get to sparkys page go to <a href="http://www.sillig.com/sparky">www.sillig.com/sparky</a> . I have added some code to 404.php which will look in a new table and if it matches www.sillig.com/sparky it does a COM_refresh and loads a static page also stored in the table....

In my test I got the test code to work fine running firefox but it craps out in IE.



That sounds exactly like an issue I'm having, and I think there's a problem in COM_refresh. I have a custom 404.html (with Mark over at glFusion.org's help) that is working fine in Firefox but fails in Internet Explorer. I have Apache set to process PHP in .html pages so Internet Explorer will even bother processing the script as a 404 page, but the redirect (which uses COM_refresh) also fails.

The idea in my script is to process every six digit number URL and redirect to another script with the six digit number as a variable, but process every other invalid URL normally as a 404 error.

Try the following URLs in Firefox and then in Internet Explorer to see what is going on:

A six digit number:
http://www.re-tp.com/111541

An invalid URL:
http://www.re-tp.com/asdf

Here's the code:
Text Formatted Code


<?php

/* Reminder: always indent with 4 spaces (no tabs). */
// +---------------------------------------------------------------------------+
// | Geeklog 1.5                                                               |
// +---------------------------------------------------------------------------+
// | 404.php, 404.html                                                         |
// |                                                                           |
// | Special MLS redirect 404 page                                             |
// +---------------------------------------------------------------------------+
//
// $Id: 404.php,v 1.10 2005/06/23 08:06:09 dhaun Exp $

require_once ('lib-common.php');

//$parm = preg_replace('/[^a-z0-9\-_]/', '', $_SERVER['REQUEST_URI']);
$parm = COM_applyFilter($_SERVER['REQUEST_URI']);
$pLen = strlen($parm)-1;
$parm = substr($parm,1,$pLen);
$pLength = strlen($parm);

if (is_numeric($parm) && $pLength == 6 ){
//    echo COM_refresh($_CONF['site_url'] . '/scriptname.php?id=' . $parm);
    echo COM_refresh('http://www.lewistonclarkstonidx.com/listing.php?mls=' . $parm . "&site_id=1485");
    exit;
}

if (isset ($_SERVER['SCRIPT_URI'])) {
    $url = strip_tags ($_SERVER['SCRIPT_URI']);
} else {
    $pos = strpos ($_SERVER['REQUEST_URI'], '?');
    if ($pos === false) {
        $request = $_SERVER['REQUEST_URI'];
    } else {
        $request = substr ($_SERVER['REQUEST_URI'], 0, $pos);
    }
    $url = 'http://' . $_SERVER['HTTP_HOST'] . strip_tags ($request);
}
$display = COM_siteHeader ('menu', $LANG_404[1]);
$display .= COM_startBlock ($LANG_404[1]);
$display .= sprintf ($LANG_404[2], $url);
$display .= $LANG_404[3];
$display .= COM_endBlock ();
$display .= COM_siteFooter ();

echo $display

?>
 


Anybody know why COM_refresh doesn't seem to work in Internet Explorer, or what else could be going on?

Jason Hackwith
"Beauty... is the shadow of God on the universe." ~ Gabriela Mistral -- Desolacíon
 Quote

Status: offline

jhackwith

Forum User
Chatty
Registered: 07/24/04
Posts: 63
Location:Lewiston, Idaho
Got it! The problem was in COM_refresh. It would get to that point of the script and then fail in IE.

Got it to work using J23's COM_refresh code in this thread:

Text Formatted Code

  function COM_refresh( $url )
{
    header ("Location: " . str_replace ( '&', '&', $url) );
    return "<html><head><meta http-equiv=\"refresh\" content=\"0; URL=$url\"></head></html>n";
}
 

"Beauty... is the shadow of God on the universe." ~ Gabriela Mistral -- Desolacíon
 Quote

All times are EST. The time is now 11:10 am.

  • Normal Topic
  • Sticky Topic
  • Locked Topic
  • New Post
  • Sticky Topic W/ New Post
  • Locked Topic W/ New Post
  •  View Anonymous Posts
  •  Able to post
  •  Filtered HTML Allowed
  •  Censored Content