Jump to content

odd code problems? wont pass $GET


wmguk

Recommended Posts

hi guys,

 

I have my main page

 

<?php
$login = $_GET['login'];	
$dir ="http://www.domains.co.uk/clients/$login/";
include "connection.php"; 
echo $dir ;
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Untitled Document</title>
<link href="../../styles.css" rel="stylesheet" type="text/css" />
<style type="text/css">
<!--
body {
background-color: #ffffff;
}
-->
</style></head>
<body>
<script src="getpics.php?dir=<?php echo $dir; ?>" type="text/javascript"></script>
<script type="text/javascript">

var dimension="1x20" //Specify dimension of gallery (number of images shown), such as 4x2, 3x1 etc
var imagepath="<?php echo $dir ;?>" //Absolute path to image directory. Include trailing slash (/)
var href_target="order" //Enter target attribute of links, if applicable

//Toggle popup link setting: popupsetting[0 or 1, "pop up window attributes" (if 1)]
var popupsetting=[0, ""]

//Toggle image description: descriptionprefix[0 or 1, "Text to show" (if 1)]
var descriptionprefix=[0, " "]

//Sort images by date? ("asc", "desc", or "")
//"desc" for example causes the newest images to show up first in the gallery
//"" disables this feature, so images are sorted by file name (default)
var gsortorder=""

//By default, each image hyperlinks to itself.
//However, if you wish them to link to larger versions of themselves
//Specify the directory in which the larger images are located
//The file names of these large images should mirror those of the original
//Enter a blank string ("") to disable this option

/////No need to edit beyond here///////////////////

function sortbydate(a, b){ //Sort images function
if (gsortorder=="asc") //sort by file date: older to newer
return new Date(a[1])-new Date(b[1])
else if (gsortorder=="desc") //sort by file date: newer to older
return new Date(b[1])-new Date(a[1])
}

if (gsortorder=="asc" || gsortorder=="desc")
galleryarray.sort(sortbydate)

else
galleryarray.sort();

var totalslots=dimension.split("x")[0]*dimension.split("x")[1]

function buildimage(i){
var imagecompletepath='dis.php?login=<?php echo $login; ?>&image=<?php echo $dir ; ?>'+galleryarray[i][0]+''
var tempcontainer='<table align="center"><tr><td>'
tempcontainer+='<a href="'+imagecompletepath+'" target="'+href_target+'" onClick="return popuplinkfunc(this)">'
tempcontainer+='<img src="'+imagepath+galleryarray[i][0]+'" title="'+galleryarray[i][0]+'"/>'
tempcontainer+='</a></td></tr><tr><td class="image">'+galleryarray [i][0]+'</td></tr><tr><td><hr /></td></tr></table>'
return tempcontainer
}

function jumptopage(p){
var startpoint=(p-1)*totalslots
var y=1;
for (i=0; i<totalslots; i++){
document.getElementById("slide"+i).innerHTML=(typeof galleryarray[startpoint+i]!="undefined")? buildimage(startpoint+i) : ""
}
while(document.getElementById("navlink"+y)!=null){
document.getElementById("navlink"+y).className=""
y++
}
document.getElementById("navlink"+p).className="current"
}

var curimage=0
for (y=0; y<dimension.split("x")[1]; y++){
for (x=0; x<dimension.split("x")[0]; x++){
if (curimage<galleryarray.length)
document.write('<div id="slide'+curimage+'" class="slideshow">'+buildimage(curimage)+'</div>')
curimage++
}
document.write('')
}

function popuplinkfunc(imgsrc){
if (popupsetting[0]==1){
var popwin=open(imgsrc.href, "popwin", popupsetting[1])
popwin.focus()
return false

}
else
return true
}
</script>
<!--Below HTML code refers to the navigational links for the gallery-->
<div id="navlinks"><script type="text/javascript">
for (i=1; i<Math.ceil(galleryarray.length/totalslots)+1; i++)
document.write('<span class="main"><a id="navlink'+i+'" href="javascript:jumptopage('+i+')\">['+i+']</a></span> ')
document.getElementById("navlink1").className="current"
</script></div>
</body>
</html>

 

I echo $dir and that displays correctly, however for some reason I doesnt seem to send on to getpics.php

 

this is getpics.php

<?php
$dir = $_GET['dir'];
Header("content-type: application/x-javascript");
function returnimages() { 
   $dirname="$dir"; 
   $pattern="\.(jpg|jpeg|png|gif|bmp)$"; 
   $files = array();
   $curimage=0;
   if($handle = opendir($dirname)) {
       while(false !== ($file = readdir($handle))){
               if(eregi($pattern, $file)){
	 $filedate=date ("M d, Y H:i:s", filemtime($file));
                 echo 'galleryarray[' . $curimage .']=["' . $file . '", "'.$filedate.'"];' . "\n";
                 $curimage++;
               }
       }

       closedir($handle);
   }
   return($files);
}

echo "var galleryarray=new Array();" . "\n";
returnimages();
?> 

 

Any ideas what I've missed?

Link to comment
https://forums.phpfreaks.com/topic/101328-odd-code-problems-wont-pass-get/
Share on other sites

Well where in your script are you telling it to go to getpics.php? As far as I see you have no redirector, include or even a form to post from.

 

<body>
<script src="getpics.php?dir=<?php echo $dir; ?>" type="text/javascript"></script>

 

hi, this is the first line within the body, so thats where it pics out the getpics script :)

 

it just doesnt seem to be working :(

I just viewed the source and it shows in the first page

 

<script type="text/javascript" src="getpics.php?dir=http://www.domainname.co.uk/clients/cartern/">
so this is correct, so it must be sending the right info to the link, however I dont seem to be able to check if getpics.php is getting the dir, i tried echo $dir however that failed, is there anyway i can get that script to echo $dir?

 

- ahh ok, just did your suggestion conker, and i now get this error produced:

 

Warning: include() [function.include]: Failed opening 'getpics.php?dir=http://www.domainname.co.uk/clients/cartern/' for inclusion (include_path='.:') in /var/www/vhosts/domainname.co.uk/subdomains/demo/httpdocs/admin/gallery/thumb.php on line 21

 

however I have checked and there are nearly 200 images in that folder, (http://www.domainname.co.uk/clients/cartern/) so that is correct and getpics.php is defo there, in the same folder as the main script page :(

Hmm, OK, Lets try this another way:

getpics.php

<?php
function returnimages($dir) { 
   $dir = $_GET['dir'];
   $dirname="$dir"; 
   $pattern="\.(jpg|jpeg|png|gif|bmp)$"; 
   $files = array();
   $curimage=0;
   if($handle = opendir($dirname)) {
       while(false !== ($file = readdir($handle))){
               if(eregi($pattern, $file)){

$filedate=date ("M d, Y H:i:s", filemtime($file));
                 echo 'galleryarray[' . $curimage .']=["' . $file . '", "'.$filedate.'"];' . "\n";
                 $curimage++;
               }
       }

       closedir($handle);
   }
   return($files);
}
?>

Then, on your page that you want this to be in. Add a:

<?php include("getpics.php"); ?>

At the top. And use:

<?php returnimages(); ?>

In your code somewhere, but make sure to add a ?dir= at the top of this page.

<?php returnimages(); ?>

In your code somewhere, but make sure to add a ?dir= at the top of this page.

 

sorry, I recreated the getpics.php page, and changed the include, but where does that returnimages() go? and what do u mean add a ?dir=?

 

does the returnimages() go where i want to display the images? and $dir is already assigned at the top of the main page?

hmmmm, ok that makes sense,

 

now i get this error :

 

Warning: opendir(http://www.domain.co.uk/clients/cartern/) [function.opendir]: failed to open dir: not implemented in /var/www/vhosts/domain.co.uk/subdomains/demo/httpdocs/admin/gallery/getpics.php on line 7

 

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.