RSS iconTwitter iconFacebook icon

The Trek BBS title image

The Trek BBS statistics

Threads: 143,163
Posts: 5,597,467
Members: 25,396
Currently online: 640
Newest member: mxadam

TrekToday headlines

Retro Review: When It Rains…
By: Michelle on Feb 27

Nimoy Dead At Eighty-Three
By: T'Bonz on Feb 27

Breaking news: Leonard Nimoy – ‘Mr Spock’ – dies aged 83
By: AntonyF on Feb 27

Hurley Passes
By: T'Bonz on Feb 26

USS Excelsior Model Coming Soon
By: T'Bonz on Feb 25

Hemsworth To Host SNL
By: T'Bonz on Feb 25

Quinto To Guest Star On HBO Comedy
By: T'Bonz on Feb 25

Wheaton To Voice Firefly Game
By: T'Bonz on Feb 24

Nimoy Health Scare
By: T'Bonz on Feb 24

Star Trek #42 Preview
By: T'Bonz on Feb 23


Welcome! The Trek BBS is the number one place to chat about Star Trek with like-minded fans. Please login to see our full range of forums as well as the ability to send and receive private messages, track your favourite topics and of course join in the discussions.

If you are a new visitor, join us for free. If you are an existing member please login below. Note: for members who joined under our old messageboard system, please login with your display name not your login name.


Go Back   The Trek BBS > Entertainment & Interests > Web Sites/Design

Web Sites/Design Talk about your websites here!

Reply
 
Thread Tools
Old December 5 2008, 12:26 AM   #1
Koinek
Vice Admiral
 
Koinek's Avatar
 
Location: Chicago, IL
Need some help with a php script

Disclaimer - I do not know how to code in PHP or any other language. I'm just an intuitive computer user who can tinker with existing code and make it work for me.

So, I'm working with an existing script in php that I found online. I originally used it to display a random image from a group that I uploaded online. Now, I'm trying to integrate javascript rollover code, into the php. I've succeeded except that it has invalidated the java's ability to preload the rollover image.

Take a look at the following code and tell me if there is a line I can add to have it preload the rollover image:
Code:
<?php

/*

  Author: Dan Benjamin - http://hivelogic.com/

  Copyright (c) 2004 Automatic, Ltd. All Rights Reserved.

  THIS SOFTWARE IS PROVIDED "AS IS", WITHOUT ANY WARRANTY OR CONDITION OF 
  ANY KIND, EXPRESS, IMPLIED OR STATUTORY, INCLUDING WITHOUT LIMITATION ANY 
  IMPLIED WARRANTIES OF ACCURACY, MERCHANTABILITY, FITNESS FOR A PARTICULAR 
  PURPOSE OR NONINFRINGEMENT.  

  IN NO EVENT SHALL DAN BENJAMIN, A LIST APART, OR AUTOMATIC, LTD. BE LIABLE
  FOR ANY DIRECT, INDIRECT, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES OR
  LOST PROFITS ARISING OUT OF OR IN CONNECTION WITH THE SOFTWARE (HOWEVER
  ARISING, INCLUDING NEGLIGENCE), EVEN IF DAN BENJAMIN, A LIST APART, OR
  AUTOMATIC, LTD. IS AWARE OF THE POSSIBILITY OF SUCH DAMAGES.

*/



  # file containg your image descriptions

  $IMG_culCONFIG_FILE = 'culimages2.ini';



  # You shouldn't need to change anything below this point

  function showculImage( $ini=null ) {
    global $IMG_culCONFIG_FILE;
    # if no custom ini file has been specified, use the default
    $ini_file = $ini ? $ini : $IMG_culCONFIG_FILE;
    # read the config file into an array or die trying
    $images = @parse_ini_file($ini_file,true);
    if (! $images) {
      die('Unable to read ini file.');
    }
    # pick a random image from the parsed config file
    $img = array_rand($images);
    # get the selected image's css id if one exists
    $id = $images[$img]['id'] ?
      sprintf( ' id="%s" ', $images[$img]['id'] ) :
      '';
    # get the selected image's css class if one exists
    $class = $images[$img]['class'] ?
      sprintf( ' class="%s" ', $images[$img]['class'] ) :
      '';
    # get selected image's dimensions
    $size = @getimagesize( $images[$img]['src'] );
    # if an url was specified, output the opening A HREF tag
    if ( $images[$img]['url'] ) {
      printf(
        '<a href="%s" target="_blank" onmouseover="MM_swapImage(%s)" onmouseout="MM_swapImgRestore()">',
        $images[$img]['url'],
        $images[$img]['rol']
      );
    }
    # output the IMG tag
    printf(
      '<img src="%s" alt="%s" name="culimg" %s border="0" id="culimg" />',
      $images[$img]['src'],
      $images[$img]['alt'],
      $size[3]
    );
    # if an url was specified, output the closing A HREF tag
    if ( $images[$img]['url'] ) {
      echo('</a>');
    }
  }


?>
And a sample piece from the .ini file that lists the images for the php files' use:
Code:
[Cul1]
src   = mywebpage.com/cul01.jpg
rol   = 'culimg','','mywebpage.comcul/20.jpg',1
alt   = Qi Shu Fang Peking Opera
url   = http://www.qishufang.com
As you can see there is some very ugly java splicing involved (done by me) but it works.

I'm hoping there is a way I can add a "lod = mywebpage.comcul/20.jpg" into the .ini and have the php pull that to preload the image. But like I said before, I can't code in php.
__________________
Originally Posted by Emh: "The Dutch don't count."
Originally Posted by Ominous Squirrel: "Actually, we do: een, twee, drie, etc"
Koinek is offline   Reply With Quote
Old December 5 2008, 01:06 AM   #2
ThunderAeroI
Rear Admiral
 
ThunderAeroI's Avatar
 
Location: Perpetually being chased by airplanes
Re: Need some help with a php script

does the lod=xxxx go into the <a href statement? I cant remember...

This assumes it goes in the <img> tag and does NOT test to see if there actually is a lod set in the ini

Code:
   printf(
      '<img src="%s" alt="%s" name="culimg" %s border="0" id="culimg" lod="%s" />',
      $images[$img]['src'],
      $images[$img]['alt'],
      $size[3],
      $images[$img]['lod']
    );
__________________
No Where to be found, but everywhere you are - I'll be there looking for ways to save your life.
ThunderAeroI is offline   Reply With Quote
Old December 5 2008, 03:52 PM   #3
Koinek
Vice Admiral
 
Koinek's Avatar
 
Location: Chicago, IL
Re: Need some help with a php script

Errr I didn't know "lod" was a tag or a piece of code. That was just a line/variable name I gave to the place where I could specify the file to be pre-loaded.

I'm just looking to specify the rollover image in the .ini and place something in the php where by it can be pre-loaded.
__________________
Originally Posted by Emh: "The Dutch don't count."
Originally Posted by Ominous Squirrel: "Actually, we do: een, twee, drie, etc"
Koinek is offline   Reply With Quote
Old December 5 2008, 07:01 PM   #4
ThunderAeroI
Rear Admiral
 
ThunderAeroI's Avatar
 
Location: Perpetually being chased by airplanes
Re: Need some help with a php script

Lod would be replaced in the code by whatever call you are using to do the preloading.

It might look like the below, but i cant say because your not showing us the preloading script you said was working.

<img src="%s" alt="%s" name="culimg" %s border="0" id="culimg"
ONMOUSEOVER=loadimage("%s");
/>
__________________
No Where to be found, but everywhere you are - I'll be there looking for ways to save your life.
ThunderAeroI is offline   Reply With Quote
Old December 15 2008, 08:01 PM   #5
smithaa02
Commodore
 
smithaa02's Avatar
 
Re: Need some help with a php script

You shouldn't need php for a preloader...

Use dreamweavers javascript preloader...

<body onload="MM_preloadImages('images/index_r06_c01_f2.gif','images/searchbutton_f2.gif','images/whatnew_r15_c1_f2.gif',etc...">

+

function MM_preloadImages() { //v3.0
var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}

smithaa02 is offline   Reply With Quote
Reply

Bookmarks

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump



All times are GMT +1. The time now is 05:49 PM.

Powered by vBulletin® Version 3.8.6
Copyright ©2000 - 2015, Jelsoft Enterprises Ltd.
FireFox 2+ or Internet Explorer 7+ highly recommended.