wmguk Posted April 16, 2008 Share Posted April 16, 2008 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 More sharing options...
wmguk Posted April 16, 2008 Author Share Posted April 16, 2008 bump Link to comment https://forums.phpfreaks.com/topic/101328-odd-code-problems-wont-pass-get/#findComment-518301 Share on other sites More sharing options...
Cep Posted April 16, 2008 Share Posted April 16, 2008 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. Link to comment https://forums.phpfreaks.com/topic/101328-odd-code-problems-wont-pass-get/#findComment-518349 Share on other sites More sharing options...
conker87 Posted April 16, 2008 Share Posted April 16, 2008 Can you use variables stated outside of a function in a function? if not, use function returnimages($dir = $_GET['dir']) { Link to comment https://forums.phpfreaks.com/topic/101328-odd-code-problems-wont-pass-get/#findComment-518353 Share on other sites More sharing options...
wmguk Posted April 16, 2008 Author Share Posted April 16, 2008 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 Link to comment https://forums.phpfreaks.com/topic/101328-odd-code-problems-wont-pass-get/#findComment-518421 Share on other sites More sharing options...
conker87 Posted April 16, 2008 Share Posted April 16, 2008 Well, you're putting it in a javascript... Try: <?php include("getpics.php?dir=" . $dir); ?> Link to comment https://forums.phpfreaks.com/topic/101328-odd-code-problems-wont-pass-get/#findComment-518428 Share on other sites More sharing options...
soycharliente Posted April 16, 2008 Share Posted April 16, 2008 <script src="getpics.php?dir=<?php echo $dir; ?>" type="text/javascript"></script> Doesn't the src have to be a .js file? Are you giving it a .js file? Link to comment https://forums.phpfreaks.com/topic/101328-odd-code-problems-wont-pass-get/#findComment-518434 Share on other sites More sharing options...
wmguk Posted April 16, 2008 Author Share Posted April 16, 2008 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 Link to comment https://forums.phpfreaks.com/topic/101328-odd-code-problems-wont-pass-get/#findComment-518438 Share on other sites More sharing options...
wmguk Posted April 16, 2008 Author Share Posted April 16, 2008 <script src="getpics.php?dir=<?php echo $dir; ?>" type="text/javascript"></script> Doesn't the src have to be a .js file? Are you giving it a .js file? i did wonder this, but apparently not, you can have the src as anything? Link to comment https://forums.phpfreaks.com/topic/101328-odd-code-problems-wont-pass-get/#findComment-518439 Share on other sites More sharing options...
conker87 Posted April 16, 2008 Share Posted April 16, 2008 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. Link to comment https://forums.phpfreaks.com/topic/101328-odd-code-problems-wont-pass-get/#findComment-518450 Share on other sites More sharing options...
wmguk Posted April 16, 2008 Author Share Posted April 16, 2008 <?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? Link to comment https://forums.phpfreaks.com/topic/101328-odd-code-problems-wont-pass-get/#findComment-518458 Share on other sites More sharing options...
wmguk Posted April 16, 2008 Author Share Posted April 16, 2008 I dont think in the include you can say getpics.php?dir=$dir as the include fails, and the dir needs to be generated via this script Link to comment https://forums.phpfreaks.com/topic/101328-odd-code-problems-wont-pass-get/#findComment-518463 Share on other sites More sharing options...
wmguk Posted April 16, 2008 Author Share Posted April 16, 2008 bump bump Link to comment https://forums.phpfreaks.com/topic/101328-odd-code-problems-wont-pass-get/#findComment-518852 Share on other sites More sharing options...
Cep Posted April 17, 2008 Share Posted April 17, 2008 The include requires a parameter it should be, <?php returnimages($dir); ?> Where $dir is your original directory for the images. I believe that is what is he is saying. Link to comment https://forums.phpfreaks.com/topic/101328-odd-code-problems-wont-pass-get/#findComment-519262 Share on other sites More sharing options...
wmguk Posted April 17, 2008 Author Share Posted April 17, 2008 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 Link to comment https://forums.phpfreaks.com/topic/101328-odd-code-problems-wont-pass-get/#findComment-519275 Share on other sites More sharing options...
Cep Posted April 18, 2008 Share Posted April 18, 2008 You can't use the HTTP protocol call in opendir(), read this, http://uk3.php.net/manual/en/function.opendir.php Link to comment https://forums.phpfreaks.com/topic/101328-odd-code-problems-wont-pass-get/#findComment-520133 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.