Not signed in (Sign In)

Vanilla 1.1.10 is a product of Lussumo. More Information: Documentation, Community Support.

    • CommentAuthorthebluebus
    • CommentTimeJun 9th 2008 edited
     
    hi,

    what i'd really like to do, is set my site to load a random image page from any album when you visit the main domain. i.e.

    http://www.xxx.com - would re-direct to something like:

    http://www.xxx.com/index.php?level=picture&id=1172

    then next time you visit http://www.scenemeup.com it loads a new random image page i.e.

    http://www.xxx.com/index.php?level=picture&id=2632

    I'm thinking this is fairly easy to do, but i'm not quite sure where to start. Could it be done with htaccess? or maybe with a small redirection script on the main index page?
    • CommentAuthorthebluebus
    • CommentTimeJun 9th 2008 edited
     
    i've butchered a random image script a bit

    http://www.xxx.com/rand.php

    now displays a link which changes every page load. How do i incorporate a redirect script with it?
    •  
      CommentAuthorsidtheduck
    • CommentTimeJun 9th 2008 edited
     
    For redirection, just add the following code:<?php header("location:$your_link_variable"); ?>or:<?php header("location:".$your_link_variable); ?>(has to be before any other output though, so before your link output or any errors).

    That should work for you.
  1.  
    thanks for the reply sid. I'm clearly a bit out of my php depth though.....

    i've got:

    <?php header("location:$siteurl"; ?>/index.php?level=picture&id=<? echo "$id"; ?>

    but i'm getting

    Parse error: syntax error, unexpected ';' in /scenemeup.com/rand3.php on line 27
    • CommentAuthorthebluebus
    • CommentTimeJun 9th 2008 edited
     
    oops i just missed off a ')'
    however now i'm getting another error. If i put it right at the top of the document i get this

    www.xxx.com/rand3.php (it seems to like the $siteurl bit but not the $id part....

    and if i put it anywhere else i get an error about cannot modify headers, already sent etc
    •  
      CommentAuthorsidtheduck
    • CommentTimeJun 9th 2008
     
    Try this:<?php header("location:".$siteurl."/index.php?level=picture&id=".$id); ?>
    • CommentAuthorthebluebus
    • CommentTimeJun 9th 2008 edited
     
    thats doing the same thing

    www.xxx.com/rand4.php

    just doesnt seem to want to add the id to the end
    • CommentAuthorthebluebus
    • CommentTimeJun 9th 2008 edited
     
    my mistake....moved where it was in the code and

    www.xxx.com/rand5.php

    thanks again sid :)
    •  
      CommentAuthorsidtheduck
    • CommentTimeJun 9th 2008
     
    Great!
    • CommentAuthorthebluebus
    • CommentTimeJun 9th 2008 edited
     
    sorry sid, one more thing,

    its now working great, http://www.xxx.com takes you to a random image page. And clicking the logo top left gives you another random.
    The code above is stored in a file called rand.php so i added this to the .htaccess

    DirectoryIndex rand.php

    so its the default page loaded instead of index.php However, its now stopped my search working. Searches now just return a random image. This is obviously to do with the .htaccess redirect, but can i change this somewhere? search settings in plog-functions maybe?
    •  
      CommentAuthorsidtheduck
    • CommentTimeJun 9th 2008 edited
     
    Try this. Open 'plog-load_config.php' and find the following code: $config["use_mod_rewrite"] = 0;
    } else {
    $config["baseurl"] = "http://".$_SERVER["HTTP_HOST"]. substr($_SERVER["PHP_SELF"],0,strrpos($_SERVER["PHP_SELF"],"/")) . "/";
    }
    edit it to read: $config["use_mod_rewrite"] = 0;
    } else {
    if ($config["use_mod_rewrite"] == 1) {
    $config["baseurl"] = "http://".$_SERVER["HTTP_HOST"]. substr($_SERVER["PHP_SELF"],0,strrpos($_SERVER["PHP_SELF"],"/")) . "/";
    }
    }


    I think that should work for you.
  2.  
    once again, sidtheduck to the rescue! thanks a lot :)