am using this script for my folder image gallery i want a little change in it, it use to read filenames like animal.jpg i want to change it reads only image name not its extension like only ANIMAL it reads file name when i change this line to $imagetext = "Slide"; $imagetext = "$filename"; can any one recode it for me that it will read only image name without its extention <?php // USER SET CUSTOM VARIABLES $pagetitle = "OPG Image Gallery"; $logo = "OPG Image Gallery"; $website = "www.photos.com"; $email = "info@photos.com"; $deadline = "January 1st, 2006"; // If left blank between the quotation marks, the deadline message will not display on the page $deadline_message = "The deadline for print orders to be completed and returned is<br /> "; $imagetext = "Slide"; // To display the file name, leave this blank between the quotation marks $linkname ="Order Form"; // If left blank between the quotation marks, the link will not display on the page $link ="orderform.pdf"; $disable = 1; // Set to 0 to deactivate the Right Click Disable feature $message = " For Ordering Prints please contact us at $email"; // USER SET FILE TYPES ACCEPTED $xt = array("jpeg", "jpe", "jpg"); // USER SET PAGE COLORS AND DIMENSIONS $cols = 4; $rows = 3; $background_color = "#000000"; $txt_color = "#666666"; $link_color = "white"; $tn_cell_width = "110px"; $tn_cell_height = "110px"; $tn_cell_padding = "10px"; $tn_cell_background_color = "#000000"; $tn_cell_border = "solid 2px #666666"; $crnt_tn_cell_background_color = "#333333"; $img_cell_width = "650px"; $img_cell_height = "1px"; $img_cell_padding = "10px"; $img_cell_background_color = "#000000"; $img_cell_border = "solid 0px #000000"; $display_background_color = "#000000"; $display_border = "solid 0px #000000"; $thumbnail_border = "solid 0px white"; $image_border = "solid 2px white"; /* --------------------------------------------------------------------------------- GET GLOBAL VARIABLES AND ARRAY OF IMAGES --------------------------------------------------------------------------------- */ if(!$_GET['crnt']){$_GET['crnt']=0;} $crnt=$_GET['crnt']; if(!$_GET['type']){$_GET['type']=0;} $type=$_GET['type']; if(!$_GET['type']){$folder="./tn/";}else{$folder="./";} if (!$cols){$cols=1;} if (!$rows){$rows=1;} $dir = opendir($folder); while(false !== ($file = readdir($dir))){ for ($i = 0; $i < count($xt); $i++){ if (eregi("\.". $xt[$i] ."$", $file)){ $files[] = $file; } } } closedir($dir); sort($files); $total=count($files); $total_cells = $cols*$rows; $maxpage = ceil($total/$total_cells); $crntpage = floor(($crnt+$total_cells)/$total_cells); $baseslide = ($crntpage*$total_cells)-$total_cells; /* ----------------------------------------------------- MAIN HTML PAGE FOR DISPLAY NO NEED TO CHANGE ANYTHING BELOW UNLESS YOU ARE FAMILIAR WITH PHP CODING ----------------------------------------------------- */ ?> <!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"> <!-- ****************************************************************** --> <!-- This OnePagePhpGallery script has been --> <!-- written by Robert Watcher --> <!-- www.robertwatcher.com --> <!-- --> <!-- It is copyright protected 2006 R.Watcher --> <!-- and falls under the same copyright terms and --> <!-- protection as all original content. --> <!-- --> <!-- You are free to use and distribute this script, --> <!-- change and customize it to your requirements. --> <!-- --> <!-- I only ask that you respect my copyright and --> <!-- keep this Author comment intact. --> <!-- ****************************************************************** --> <head> <meta http-equiv="content-type" content="text/html; charset=iso-8859-1" /> <title><?php echo $pagetitle ?></title> <? if($disable){ ?> <META HTTP-EQUIV="imagetoolbar" CONTENT="no"> <script language="JavaScript"> <!-- var message="<? echo $message ?>"; function clickIE4(){ if (event.button==2){ alert(message); return false; } } function clickNS4(e){ if (document.layers||document.getElementById&&!document.all){ if (e.which==2||e.which==3){ alert(message); return false; } } } if (document.layers){ document.captureEvents(Event.MOUSEDOWN); document.onmousedown=clickNS4; } else if (document.all&&!document.getElementById){ document.onmousedown=clickIE4; } document.oncontextmenu=new Function("alert(message);return false") //--> </script> <? } ?> <script type="text/javascript"> <!-- function WindowFocus() { window.focus(); } document.onkeydown = function(e){ e = (typeof e == "undefined") ? event : e; b = (typeof e.which == "number") ? e.which : e.keyCode; if (b == 39) {location.href = document.getElementById("next").href} else if (b == 37) {location.href = document.getElementById("prev").href} } //--> </script> <STYLE TYPE="text/css"> <!-- body {margin:0px; background:<?php echo $background_color ?> } img.big {border: <?php echo $image_border ?>} img.small {border: <?php echo $thumbnail_border ?>} .display {background:<?php echo $display_background_color ?>; border: <?php echo $display_border ?>} .tn_cell {background:<?php echo $tn_cell_background_color ?>; width:<?php echo $tn_cell_width ?>; height:<?php echo $tn_cell_height ?>; padding:<?php echo $tn_cell_padding ?>; border: <?php echo $tn_cell_border ?>} .crnt_tn_cell {background:<?php echo $crnt_tn_cell_background_color ?>; width:<?php echo $tn_cell_width ?>; height:<?php echo $tn_cell_height ?>; padding:<?php echo $tn_cell_padding ?>; border: <?php echo $tn_cell_border ?>} .img_cell {background:<?php echo $img_cell_background_color ?>; width:<?php echo $img_cell_width ?>; height:<?php echo $img_cell_height ?>; padding:<?php echo $img_cell_padding ?>; border: <?php echo $img_cell_border ?>} .txt { color: <?php echo $txt_color ?>; font: bold 12px Verdana, Arial, sans-serif } .linktxt {color: <?php echo $txt_color ?>; text-decoration: none; font: bold 14px Arial, sans-serif; padding:8px } .unlinktxt { color: <?php echo $background_color ?>; text-decoration: none; font: normal 12px Arial, sans-serif } a:link { color: <?php echo $link_color ?>; text-decoration: none; font: normal 12px Arial, sans-serif } a:active { color: <?php echo $link_color ?>; text-decoration: none; font: normal 12px Arial, sans-serif } a:visited { color: <?php echo $link_color ?>; text-decoration: none; font: normal 12px Arial, sans-serif } a:hover { color: <?php echo $txt_color ?>; text-decoration: underline; font: normal 12px Arial, sans-serif } .notice { padding:3px; background:black; color: white; font: normal 12px Arial, sans-serif } --> </STYLE> </head> <body onload='WindowFocus()'> <table width=100% height=1 cellpadding=20 cellspacing=0 border=0> <tr><td> <table align='center' cellpadding='0' cellspacing='2' border='0' class="display"> <?php /* --------------------------------------------------------------------------------- PAGE AND SLIDE COUNTER --------------------------------------------------------------------------------- */ if (!$type){ echo "<tr><td colspan=$cols align='center' class='linktxt'>Page - "; for ($lp=1; $lp<=$maxpage; $lp++){ if ($crntpage==$lp){ echo " $lp "; }else{ $tmp = ($lp-1)*$total_cells; echo " <a href='index.php?crnt=$tmp&type=$type'>$lp</a> "; } } echo "</td></tr>"; if ($crntpage>1){ $tmp = ($crntpage-2)*$total_cells; echo "<a href='index.php?crnt=$tmp&type=$type' id='prev'></a>"; } if ($crntpage<$maxpage){ $tmp = ($crntpage)*$total_cells; echo "<a href='index.php?crnt=$tmp&type=$type' id='next'></a>"; } }else{ ?> <tr><td colspan=<? echo $cols ?> align='center' class='linktxt'> <table width='1' height='1'> <tr><td NOWRAP> <? if ($crnt>0){ $tmp=0; echo "<a href='index.php?crnt=$tmp&type=1'> << </a>"; }else{ echo "<div class='unlinktxt'> << </div>"; } ?> </td> <td NOWRAP> <? if ($crnt>0){ $tmp=$crnt-1; echo "<a href='index.php?crnt=$tmp&type=1' id='prev'> < PREV </a>"; }else{ echo "<div class='unlinktxt'> < PREV </div>"; } ?> </td> <td NOWRAP> <? $tmp=$crnt; echo "<a href='index.php?crnt=$tmp&type=0'> INDEX </a>"; ?> </td> <td NOWRAP> <? if ($crnt<$total-1){ $tmp=$crnt+1; echo "<a href='index.php?crnt=$tmp&type=1' id='next'> NEXT > </a>"; }else{ echo "<div class='unlinktxt'> NEXT > </div>"; } ?> </td> <td NOWRAP> <? if ($crnt<$total-1){ $tmp=$total-1; echo "<a href='index.php?crnt=$tmp&type=1'> >> </a>"; }else{ echo "<div class='unlinktxt'> >> </div>"; } ?> </td></tr> </table> </td></tr> <? } /* --------------------------------------------------------------------------------- DISPLAY IMAGE TABLE --------------------------------------------------------------------------------- */ if ($deadline){ echo "<tr><td colspan=$cols align='center' class='notice'> $deadline_message<span class='txt'>$deadline</span><br /><br /> </td></tr>"; } if (!$type){ $tmp=$baseslide; for ($row=0; $row<$rows; $row++){ echo "<tr>"; for ($col=0; $col<$cols; $col++){ if ($tmp<$total){ $img=$folder.$files[$tmp]; $size = GetImageSize($img); $slide=$tmp+1; if($imagetext){ $imgtxt = $imagetext." ".$slide; }else{ $imgtxt = $files[$tmp]; } echo "<td align='center' class='tn_cell'><a href='index.php?crnt=$tmp&type=1'><img src='$img' {$size[3]} border='0' class='small' /><br />$imgtxt</a></td>"; $tmp++; }else{ echo "<td align='center' class='tn_cell'> </td>"; } } echo "</tr>"; } }else{ $tmp = $crnt; $img=$folder.$files[$tmp]; $size = GetImageSize($img); $slide=$tmp+1; if($imagetext){ $imgtxt = $imagetext." ".$slide; }else{ $imgtxt = $files[$tmp]; } echo "<tr>"; echo "<td align='center' class='img_cell'><a href='index.php?crnt=$tmp'><img src='$img' {$size[3]} border='0' class='big' /><br /><br />$imgtxt</a></td>"; echo "</tr>"; } /* --------------------------------------------------------------------------------- IFORMATION PANEL --------------------------------------------------------------------------------- */ ?> <tr><td colspan="<?php echo $cols ?>" class='linktxt'> <table width=100% height=100% cellpadding=0 cellspacing=0 border=0> <tr> <?php if($linkname){ ?> <td align="right" NOWRAP> <?php echo " <a href='$link' target='_blank'>$linkname</a>" ?> </td> <?php } ?> <td align="center" class="txt" NOWRAP> <?php if($logo){ echo "$logo<br />"; } ?> <?php if($website){ echo "<br /> Website - <a href='http://$website'>$website</a>"; } ?> <?php if($email){ echo " Email - <a href='mailto:$email'>$email</a> "; } ?> </td> </tr> </table> </td></tr> </table> </td></tr> </table> </body> </html>
correction $imagetext = substr(strrchr(substr($img, 0, strrpos($img, '.')),'/'), 1); $imgtxt = $imagetext; I took the liberty of putting your script on the server, this one works
thanks for your reply its helpful to me now one thing more the link of my image is shown as hostname/index.php?crnt=imagename i want to open full length imags on a new php page and below the image on that page it writes the name of image by getting the name of file is this $get[] method will work better for it ? simple i want to fetch the CRNT= value on a new page that is linked with image name to open image in full length view and show the link as hostname/imageviewer.php?crnt=imagename i dont want to get crnt= value in address bar becoz it is coming fine i want to fetch it in html codes by GET method or any else
Put this in your code before ANYTHING is output to the browser: session_start(); foreach ($_GET as $key => $value) { $_SESSION[$key] = $value; } Code (markup): Then you can get the vars on that next page by putting session_start(); again and using $_SESSION like you would $_GET.
i'd use an apache mod_rewrite rule if you can use that on the server (requires apache with .htaccess) attach $img to the query as index.php?crnt=$tmp&imagetitle=$img&type=1 have the server store the request and rewrite the url as /imageviewer.php?imagetitle then you can use one single file I aint familiar enough with mod_rewrite, you'd have to ask a cms programmer or apache admin about the specific rule the option of a separate viewerpage can be done like pos1tron says, but i'd also consider a gallery script with lightbox http://www.smashingmagazine.com/200...ns-for-image-galleries-slideshows-lightboxes/
i think i wrote some thing confusing, actually i want to need the same method like asp used in request.querystring to get the value of a variable on next page i want same method in php for my above mentioned script
You'd have to recode half the script and try pos1tron's idea although I'd use the $_SESSION[] array : store $crnt and $type in the session array and pass the stripped name as &image=$img. session_start(); $folder="./tn/"; //test to see if there are session-vars : if(!isset($_SESSION['type'])) { //type is not set, new session //test to see i an image parameter was passed, //if so, the request wasn't generated by this page //as there is no session if(!isset($_GET['image'])) { //no get-var image, //so it's a clean call on imageviewer.php $type=0; $_SESSION['type']=$type; //...if type is not set, crnt is not set : $crnt=0; $_SESSION['crnt']=$crnt; } else { //no session //but there is an image-var, //someone wants a picture page //set type to 1, next page is full image view, //and try and find the picture-id by the 'image' parameter $type=1; $_SESSION['type']=$type; // make file array $dir = opendir($folder); while(false !== ($file = readdir($dir))){ for ($i = 0; $i < count($xt); $i++){ if (eregi("\.". $xt[$i] ."$", $file)){ $files[] = $file; } } } closedir($dir); sort($files); // compare the stripped filenames, pick the winner for($i=0;$i<count($files);$i++) { $cmptext = substr(strrchr(substr($files[$i], 0, strrpos($files[$i], '.')),'/'), 1); if($cmptext=$_GET['image']) { //we have a match break; } } if($i=count($files)) { //no matching file... displays last file... } //set $crnt and $_SESSION['crnt'] to matching file id $crnt=$i; $_SESSION['crnt']=$crnt; //add a javascript relocation bit //and the page will open with the proper $crnt and $type=1 //stored in the session echo "<script>\n"; echo "<!--\n"; echo 'location.replace("imageviewer.php?image=".$_GET['image']);'; echo"\n"; echo "-->\n"; echo "</script>\n"; echo "..."; } } PHP: you'd still have to reprogram the links in the script, but this would solve the url problem without a mod_rewrite. I sincerely hope some programmer has an easier one-liner to solve this ?
jusst am really very thank ful to you u helps me alot my english is not good so am feeling difficulty to express my real mean what i want let i try again to define actually this picture gallery script i want to use as my video gallery it will dipslay thumbnails of images which i have made from youtube videos and i have made a href link with thumbnails and thumbnails name as imageviewer.php?crnt=$imgtext now this is my youtube player code <object width="600" height="500"><param name="movie" value="http://www.youtube.com/v/GET CRNT VALUE HERE&autoplay=1"> </param><param name="wmode" value="transparent"></param> <embed src="http://www.youtube.com/v/GET CRNT VALUE HERE&autoplay=1" type="application/x-shockwave-flash" wmode="transparent" width="600" height="500"> </embed> </object where i write GET CRNT VALUE which is actually $imgtext means image name at that place i want to get and write the crnt value $imgtext name because i have saved my images with not their real name but the id supplied by youtube so when in the player after /v/ this crnt $imgtext value will be writed when user click to watch that video then player will work and run the video hope u will understnad now what i want thanks again bro
hey babupathan, sorry 'bout the delay I had a look at it this afternoon and reprogrammed the source to make a normal model (data, functions, form/layout), that makes it a lot easier to maintain and edit. It still works the same, reads the /tn/ directory and grabs the filenames, displays the thumbnails in a grid, per thumbnail you can click and get a running video, and the name displayed in the bar is the filename then you can return back to the grid. I am gonna work on the layout and controls tomorrow, if you can send me a zip (juustout dot hetnet dot nl) with some thumbnails or a list with the filenames, so i can test it with some actual videos then before the end of the week you can put on a server
hi juust i have test the flash player code with this syntx <?php echo $_GET["id"]; ?>and geting my required values on flash player codes but their is another problem when i use this php syntx on redtube flash player codes then it is geting the required value but the problem is that if i run my page on mozila firefox its runig fine and play video but when i run it on IE then it is not playing video u can check this demo at www.desivideos.co.cc/t2/ its test script directory where am testing it
shite i had a small xss attack on my site so i was busy for a moment about that IE-thing, internet explorer often does url-encoding (where all spaces in a url are replaced with an escapecode (%20 i think ?) and if your Url-filename has white spaces then the string passed is different from the name of the file you try and access. (beautifull%20girl%20....) try using an underscore _ in the filename, that might work.