You are not logged in.

Dear visitor, welcome to krpano.com Forum. If this is your first visit here, please read the Help. It explains in detail how this page works. To use all features of this page, you should consider registering. Please use the registration form, to register here or read more information about the registration process. If you are already registered, please login here.

Yomas

Intermediate

  • "Yomas" started this thread

Posts: 190

Location: Anglet, France

  • Send private message

1

Wednesday, September 14th 2011, 11:28am

JS/PHP/HTML issue for loading multiple tour on the same html page

Hi all ^^
I'm finishing my web app and have another request to ask cause of my limited experience in php...
I want to have an only html page who could launch different tours depending on wich a href we have clicked ;-)
Not clear ?? ^^

The code part to explain better.

The calling code :

Source code

1
2
<a href="my_tour_page.html" >My first tour</a>
<a href="my_tour_page.html" >My second tour</a>


And then in my_tour_page.html :

Source code

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
 <script src="js/tour.js"></script>
	<div  style="width:100%; height:400px; z-index:100; background-color:none;" data-role="none" id="pano" > 
		<noscript> 
				<b>Attention:</b> <br/> 
				<br/> 
				Javascript is not activated. <br/> 
				<br/> 
				Please activate it to see the virtual tour <br/> 
		</noscript> 
	<script>
		 var viewer = createPanoViewer();
		  
		  if ( viewer.isHTML5possible() )
		  {
			viewer.useHTML5("always");
		  
			viewer.addVariable("xml", "tour.xml");
		
			viewer.embed("pano");
		  }
		  else
		  {
			// show error message:
			// browser is not HTML5/CSS 3D transforms capable.
		  }	
	</script>

	</div>


What I'd like is that my href links to an unique html page, but launches different tour ^^
Do you think that'll be possible with php stuf using variables on the href ?
Like :

Source code

1
<a href="my_tour_page.php?tour1"

And in the my_tour_page.php

Source code

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
<script>
		 var viewer = createPanoViewer();
		  
		  if ( viewer.isHTML5possible() )
		  {
			viewer.useHTML5("always");
		  
			viewer.addVariable("xml", "<?php $my_new_path... ?> /tour.xml");
		
			viewer.embed("pano");
		  }
		  else
		  {
			// show error message:
			// browser is not HTML5/CSS 3D transforms capable.
		  }	
	</script>


The goal is to change the path of the tour.xml using variables in the <a href...

All ideas are welcomed ^^
Thank you in advance !
Best regards.
My website: www.eboovisite.com, See me also on www.Viewat.com, Facebook and Twitter

Posts: 1,850

Occupation: Virtual Tours - Photography - Krpano developer

  • Send private message

2

Wednesday, September 14th 2011, 5:18pm

Google get variables.
That's it!
KRPano Developer: Portfolio ::Gigapixel Tagging Solutions - Porfolio 2 :: Facebook :: Twitter :: reddit.com/r/VirtualTour

Yomas

Intermediate

  • "Yomas" started this thread

Posts: 190

Location: Anglet, France

  • Send private message

3

Wednesday, September 14th 2011, 5:23pm

Thanks I am studying php already ^^
I know that Google is our friend ;-)
Just want to have some tips cause I don't know where to start and very newbie to php *whistling*
Moreover I think that this issue will be very helpfull for the Krpano community *thumbsup*
Looking for solutions, if I get it work by myself I'll post it ^^
Regards.
My website: www.eboovisite.com, See me also on www.Viewat.com, Facebook and Twitter

Posts: 1,850

Occupation: Virtual Tours - Photography - Krpano developer

  • Send private message

4

Wednesday, September 14th 2011, 6:27pm

This is a piece of what you should learn after using get variables...

<a href="my_tour_page.php?tour=tour1"

viewer.addVariable("xml", "<?php print $_GET["tour"]; ?> /tour.xml");
KRPano Developer: Portfolio ::Gigapixel Tagging Solutions - Porfolio 2 :: Facebook :: Twitter :: reddit.com/r/VirtualTour

Yomas

Intermediate

  • "Yomas" started this thread

Posts: 190

Location: Anglet, France

  • Send private message

5

Thursday, September 15th 2011, 10:27am

Hi sachagriffin ^
Thanks for the tip !
I got it to work partially but have problem with plugins and script path now...
Getting crazy !
Here's what I've done in the different pages :

In the all demo page :

Source code

1
2
<a href="tour.php?path=visites/myfirsttour/ ">My First Tour</a>
<a href="tour.php?path=visites/mysecondtour/">My Second Tour</a>


And in the tour.php :

Source code

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
       <?php 
		$mypath = $_GET['path'];
	?>
	<div style="width:100%; height:400px; z-index:100; background-color:none;" data-role="none" id="pano"> 
		<noscript> 
				<b>Attention:</b> <br/> 
				<br/> 
				Javascript is not activated. <br/> 
				<br/> 
				Please activate it to see the virtual tour <br/> 
		</noscript> 

    <script type="text/javascript"> 
		 var viewer = createPanoViewer();
		  
		  if ( viewer.isHTML5possible() )
		  {
			viewer.useHTML5("always");
		  
			viewer.addVariable("xml", "<?php echo $mypath; ?>tour.xml");
		
			viewer.embed("pano");
		  }
		  else
		  {
			// show error message:
			// browser is not HTML5/CSS 3D transforms capable.
		  }	
	</script>


It works perfectly but now obviously have path errors *cursing*
All my tours are in a specific folder like this :
visites/myfirsttour/(here all the panos and xml files)
visites/mysecondtour/(here all the panos and xml files)

In the xml I'm calling image plugins like this :

Source code

1
2
3
4
5
6
7
8
9
10
11
12
13
<plugin name="show_menu"
    align="centerbottom"
    crop="420|610|216|100"
    handcursor="true"
    keep="true"
    onclick="show_menu();"
    scale="0.5"
    altscale="1"
    url="images/image_set_iphone.png"
    x="0"
    y="10"
    zorder="10"
/>


The image_set_iphone.png gives me an error...
I tried :

Source code

1
2
3
 %HTMLPATH%/visites/myfirsttour/images/image_set_iphone.png
or either
visites/myfirsttour/images/image_set_iphone.png

But doesn't work *cry*
Really this path issue always makes me crazy !
At this purpose I already got this kind of problem wich I was talking in this post...
The path doesn't make problem when using flash, cause I solved it by compiling the xml files.
But for HTML5 it's very annoying...

I'm searching but no hope of succes...
If you have a magic disney issue with mickey mouse dancing on the xlm paths that interest me ^^
Best regards.
My website: www.eboovisite.com, See me also on www.Viewat.com, Facebook and Twitter

Yomas

Intermediate

  • "Yomas" started this thread

Posts: 190

Location: Anglet, France

  • Send private message

6

Thursday, September 15th 2011, 10:50am

Okay found a first part issue... *tongue*
I've went back to this documentation page and used the %CURRENTXML% variable to set my path dynamicly ^^
But now have another path problem for the scripts *confused*
Argghhh !!!
Not getting out of this ^^
With the previous structure, I have mysecondtour using gyro.js and combobox.js.
My tour.php is calling the tour.js, and the xml file the combobox.js and gyro.js...
Whatever I try always gives me an path error to gyro and combobox...
Getting furthur with that but what a waste of time !
Thanks again.
My website: www.eboovisite.com, See me also on www.Viewat.com, Facebook and Twitter

Posts: 1,850

Occupation: Virtual Tours - Photography - Krpano developer

  • Send private message

7

Thursday, September 15th 2011, 3:45pm

It's ok just take it slow, I'm sure you'll figure it out and use the placeholders appropriately.
You haven't shown your directory structure.. so maybe you need something like.

%CURRENTXML%/../../images/image_set_iphone.png

and as always, keep in mind, that someone can type in whatever they want for a get variable and make your code start working with it.
So if you use them incorrectly, someone can take down your website in a few minutes.
KRPano Developer: Portfolio ::Gigapixel Tagging Solutions - Porfolio 2 :: Facebook :: Twitter :: reddit.com/r/VirtualTour

Yomas

Intermediate

  • "Yomas" started this thread

Posts: 190

Location: Anglet, France

  • Send private message

8

Thursday, September 15th 2011, 4:46pm

Ok Thanks a lot for support ^^
I actually found a solution by getting the tour.php file in the visites directory as follow:
/visite contains :
-tour.php
-pano folder (pano1 folder/panos two folder...)
-js folder with all my js centralized
- plugin folder with all plugins centralized

With this directory structure I bypass the paths problems...
I'm really new to php, and doesn't understand your warning :

Quoted

and as always, keep in mind, that someone can type in whatever they want for a get variable and make your code start working with it.
So if you use them incorrectly, someone can take down your website in a few minutes.


What do you mean here ?
If it's about getting my code it doesn't matter I'm open sourced for those, and in fact it's impossible to really protect the images and work so...
And therefor if you mean that by passing variables into url people can change the titles or tour.xml path themselves,
what danger is in there ? I only act on the paths and titles for this stuff ^^
Thanks again for your help !!
Cheers.
My website: www.eboovisite.com, See me also on www.Viewat.com, Facebook and Twitter

Yomas

Intermediate

  • "Yomas" started this thread

Posts: 190

Location: Anglet, France

  • Send private message

9

Thursday, September 15th 2011, 6:03pm

Here is the source of what I've done.

In the main page calling the tours :

Source code

1
2
3
4
<a href="mytours/tour.php?tour.xml" >My First Tour</a>
<a href="mytours/tour.php?tour1.xml" >My Second Tour</a>
<a href="mytours/tour.php?tour2.xml" >My Third Tour</a>
...


In the page tour.php:

Source code

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
<?php 
	if (isset($_GET['path']))
	$mypath = $_GET['path'];
	else $mypath = "#";
	
	if (isset($_GET['title']))
	$mytitle = $_GET['title'];
	else $mytitle = "Nos R&eacute;alisations";
?>

<!-- Loading the tour with -->
		
<h1><?php echo $mytitle; ?></h1>

    <script type="text/javascript"> 
		 var viewer = createPanoViewer();
		  
		  if ( viewer.isHTML5possible() )
		  {
			viewer.useHTML5("always");
		  
			viewer.addVariable("xml", "<?php echo $mypath; ?>");
		
			viewer.embed("pano");
		  }
		  else
		  {
			// show error message:
			// browser is not HTML5/CSS 3D transforms capable.
		  }	
	</script>


Hoping it could help some people who want to do this kind of thing ^^
Cheers.
My website: www.eboovisite.com, See me also on www.Viewat.com, Facebook and Twitter

Posts: 1,850

Occupation: Virtual Tours - Photography - Krpano developer

  • Send private message

10

Thursday, September 15th 2011, 7:29pm

Well back when I was learning php I used a get variable to include a file in my php.
Someone set the get variable to include an email script uploaded to an anonymous filesharing site, which they could then use to make my webserver send out a bazillion emails.
After that I was more aware of how someone could change inputs to do nefarious things.

Ok Thanks a lot for support ^^

What do you mean here ?
If it's about getting my code it doesn't matter I'm open sourced for those, and in fact it's impossible to really protect the images and work so...
And therefor if you mean that by passing variables into url people can change the titles or tour.xml path themselves,
what danger is in there ? I only act on the paths and titles for this stuff ^^
Thanks again for your help !!
Cheers.
KRPano Developer: Portfolio ::Gigapixel Tagging Solutions - Porfolio 2 :: Facebook :: Twitter :: reddit.com/r/VirtualTour

Yomas

Intermediate

  • "Yomas" started this thread

Posts: 190

Location: Anglet, France

  • Send private message

11

Thursday, September 22nd 2011, 3:14pm

Hi again ^^
Ok I understood the risks of passing things by url.
I looked around in that security purpose but the only issue I found for the moment is URL rewritting by htaccess...
But that seems very hard stuff ^^
I know that in my use some malicious people could change my tour xml or titles directly from my server...
Can you give me another way hint for securing that ?
Thanks again and let you know my progress.
Best regards.
My website: www.eboovisite.com, See me also on www.Viewat.com, Facebook and Twitter