Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
?
Solved

Trying to find out what the value of a variable is...

Posted on 2007-10-03
5
Medium Priority
?
267 Views
Last Modified: 2008-03-10
Hi!
Im attempting to find out what the value of $int_pic is in the following code.
Any help greatly appreciated.

<script type="text/javascript">
var galleryarray = new Array();

<?php
$images = glob('panorama/*.jpg');
$indx = 0;
$init_pic = $images[array_rand($images)];
foreach( $images AS $pic)
{
      echo "galleryarray[$indx]='$pic';
";
            $indx++;
}
?>
</script>

=======================================================

Just to let you know, the path where this script is located is:

c:\wamp\www\mediawiki

with the panorama folder being in

c:\wamp\www\mediawiki\panorama

There are image files in the above folder.

Thank you.
0
Comment
Question by:Simon336697
  • 3
  • 2
5 Comments
 
LVL 24

Accepted Solution

by:
glcummins earned 2000 total points
ID: 20006638
$init_pic contains one random filename from your directory 'panorama.'
0
 
LVL 1

Author Comment

by:Simon336697
ID: 20006966
Hi glcummins!
Thanks so much for your help on this.
Ive been working on this very problem for days now.

gl, is $init_pic the FULL PATH to the image filename, or JUST the filename?

The reason I ask is that, and I so much hope you can help me....

On initial load of my page, the image is displayed properly.....with a path pointing to:

http://fire/mediawiki/skins/gumax/panorama/vervet_monkey.jpg

But on subsequent polling, the returned image name has a value of:

http://fire/mediawiki/index.php/panorama/qnljis_weimaraner.jpg

which the page cant find to load the image

If I hard code the path to the image, it works.

Here is the code that Im having problems with :>)

==================================================================

<script type="text/javascript">
function opacity(id, opacStart, opacEnd, millisec) {
      //speed for each frame
      var speed = Math.round(millisec / 100);
      var timer = 0;

      //determine the direction for the blending, if start and end are the same nothing happens
      if(opacStart > opacEnd) {
            for(i = opacStart; i >= opacEnd; i--) {
                  setTimeout("changeOpac(" + i + ",'" + id + "')",(timer * speed));
                  timer++;
            }
      } else if(opacStart < opacEnd) {
            for(i = opacStart; i <= opacEnd; i++)
                  {
                  setTimeout("changeOpac(" + i + ",'" + id + "')",(timer * speed));
                  timer++;
            }
      }
}

//change the opacity for different browsers
function changeOpac(opacity, id) {
      var object = document.getElementById(id).style;
      object.opacity = (opacity / 100);
      object.MozOpacity = (opacity / 100);
      object.KhtmlOpacity = (opacity / 100);
      object.filter = "alpha(opacity=" + opacity + ")";
}

function shiftOpacity(id, millisec) {
      //if an element is invisible, make it visible, else make it ivisible
      if(document.getElementById(id).style.opacity == 0) {
            opacity(id, 0, 100, millisec);
      } else {
            opacity(id, 100, 0, millisec);
      }
}

function blendimage(divid, imageid, imagefile, millisec) {
      var speed = Math.round(millisec / 100);
      var timer = 0;
      
      //set the current image as background
      document.getElementById(divid).style.backgroundImage = "url(" + document.getElementById(imageid).src + ")";
      
      //make image transparent
      changeOpac(0, imageid);
      
      //make new image
      document.getElementById(imageid).src = imagefile;

      //fade in image
      for(i = 0; i <= 100; i++) {
            setTimeout("changeOpac(" + i + ",'" + imageid + "')",(timer * speed));
            timer++;
      }
}

function currentOpac(id, opacEnd, millisec) {
      //standard opacity is 100
      var currentOpac = 100;
      
      //if the element has an opacity set, get it
      if(document.getElementById(id).style.opacity < 100) {
            currentOpac = document.getElementById(id).style.opacity * 100;
      }

      //call for the function that changes the opacity
      opacity(id, currentOpac, opacEnd, millisec)
}


</script>


<script type="text/javascript">
var galleryarray = new Array();

<?php
$images = glob('panorama/*.jpg');
$indx = 0;
$init_pic = $images[array_rand($images)];
foreach( $images AS $pic)
{
      echo "galleryarray[$indx]='$pic';
";
            $indx++;
}
?>

var tm1=2,tm2=15,tm3=1;
function step1()
{
   setTimeout("step2()",tm1*1000);
}
function step2()
{
   shiftOpacity('blendimage', tm3*1000);
   setTimeout("step3()",(tm2+tm3)*1000);
}
function step3()
{
  var rand=Math.floor(Math.random()*galleryarray.length);
   shiftOpacity('blendimage', tm3*1000);
   setTimeout("step2()",(tm1+tm3)*1000);
setTimeout("document.getElementById('blendimage').src = '"+galleryarray[rand]+"'", tm3*1000);
}
window.onload=step1;
</script>

<div id="gumax-site-logo">
    <?php $sitelogo = $this->data['stylepath'] . '/' . $this->data['stylename'] . '/' . $init_pic; ?>    
<img src="<?php echo $sitelogo ?>" style="width: 928px; height: 147px; border: 1 none; filter: alpha(opacity=20); -moz-opacity: 20; opacity: 0;" id="blendimage""/>          
</div>
</div>

===============================================================
My php file (GuMax.php) is located in:
/var/www/html/mediawiki/skins/GuMax.php

My images folder called panorama is:
/var/www/html/mediawiki/panorama

In my code, I have the panorama folder pointing to:
$images = glob('panorama/*.jpg');
which is in:
/var/www/html/mediawiki/panorama

Now the problem........
When the page loads, it loads the firs image fine, but its getting it from:
http://fire/mediawiki/skins/gumax/panorama/namibie_desert.jpg
which is
/var/www/html/mediawiki/skins/gumax/panorama
which is NOT what I have in my code.
On subsequent images, it is trying to find:
http://fire/mediawiki/index.php/panorama/vervet_monkey.jpg
which is:
/var/www/html/mediawiki/panorama
Again not correct, and this time, the page displays a red cross.
The quandry I have is that the php code where it randomly finds an image IS actually doing this.
It is just having a problem with displaying the correct path on the page on load, so that the image doesnt display and the path is incorrect.

what I have to do somehow is get the path pointing to:

http://fire/mediawiki/skins/panorama PLUS image_name_variable, so the path it will load is:

http://fire/mediawiki/skins/panorama/imagevariable.jpg

Something in my code is not correct in outputting or echoing the wrong path in the following section:

    <?php $sitelogo = $this->data['stylepath'] . '/' . $this->data['stylename'] . '/' . $init_pic; ?>    
<img src="<?php echo $sitelogo ?>" style="width: 928px; height: 147px; border: 1 none; filter: alpha(opacity=20); -moz-opacity: 20; opacity: 0;" id="blendimage""/>          
</div>

Take 2........

On first load

http://fire/mediakwiki/skins/panorama/death_valley_flowers_panorama.jpg

After around 15 seconds, I get:
http://fire/mediawiki/index.php/skins/panorama/death_valley_flowers_panorama.jpg

0
 
LVL 24

Expert Comment

by:glcummins
ID: 20007010
glob() returns only the filename, not the full path.
0
 
LVL 1

Author Comment

by:Simon336697
ID: 20007101
gl!
Ive honed in on what the problem is and hope you can help...you are my last resort.....

Im trying to return at a set interval, different images from the panorama folder, and to load them into the div gumax-site-logo

If I just echo out the $init_pic variable into the div as below....
<div id="gumax-site-logo">    
<img src="<?php echo $init_pic ?>" style="width: 928px; height: 147px; border: 1 none; filter: alpha(opacity=20); -moz-opacity: 20; opacity: 0;" id="blendimage""/>          
</div>

The path to the image is:
http://fire/mediawiki/index.php/skins/panorama/morocco.jpg
This would load successfully if it were not for the 'index.php' part in the filename above.
If somehow we can strip out the index.php in the above when echoing out the $init_pic variable, you have solved the hardest problem I have ever had to face.

So, the $init_pic is still required because it is returning random image names, but its returning the full path including the path which is stuffing things up....the index.php.



http://fire/mediawiki/index.php/skins/panorama/mr_rhino_1.jpg
0
 
LVL 1

Author Comment

by:Simon336697
ID: 20012127
Thx for your help :>)
0

Featured Post

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

A while back, I ran into a situation where I was trying to use the calculated columns feature in SharePoint 2013 to do some simple math using values in two lists. Between certain data types not being accessible, and also with trying to make a one to…
This holiday season, we’re giving away the gift of knowledge—tech knowledge, that is. Keep reading to see what hacks, tips, and trends we have wrapped and waiting for you under the tree.
The viewer will learn how to create and use a small PHP class to apply a watermark to an image. This video shows the viewer the setup for the PHP watermark as well as important coding language. Continue to Part 2 to learn the core code used in creat…
The viewer will learn the basics of jQuery including how to code hide show and toggles. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery…
Suggested Courses

580 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question