Jump to content

calvin182

Members
  • Posts

    190
  • Joined

  • Last visited

Everything posted by calvin182

  1. calvin182

    Random

    have u tried creating a .php page and putting it in there as a test?
  2. Is there a way to have flash on a page while meeting XTHML 1.0 Transitional standards and maintaining browser compatability with FireFox and IE? It seems like one or the other. I've got compatability at the moment but I really would like that XHTML 1.0 Transitional to be working error free. Here's what I got: <object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=7,0,19,0" width="780" height="450" title="flashtitle"> <param name="movie" value="http://www.domain.com/flash.swf"> <param name="quality" value="high"> <embed src="http://www.domain.com/flash.swf" quality="high" pluginspage="http://www.macromedia.com/go/getflashplayer" type="application/x-shockwave-flash" width="780" height="450"></embed></object> any ideas how to achieve both? I think firefox likes embed but XHTML doesnt
  3. with the filemtime() function... I'm trying to figure out how to use it to sort (both olderst and newest) but I'm not sure how to accomplish this when the existing array can't store this information alongside the images so I think I would have to create a second array, or is there a shorter way around this?also the filetype filter is nice :)edit: could this be done with compact() ?
  4. calvin182

    Random

    just put the whole entire thing into your html document.
  5. calvin182

    Random

    that generates the html code for it, it's just you have to copy and paste this section over and over again each time incrementing the little number and changing the image source. images[1] = "<img src='http://w3schools.invisionzone.com/style_images/w3sbanner.gif'>"; just paste the entire script whereever in your html you want the random image to show up
  6. Jonas if you havent already found a resolution you can use my php code. I wont remove it no worries Just be sure that you have all of the random images in one folder with no other non-image filetypes in it. <html><head><title></title><?php$dir = "/home/DOMAIN/public_html/RANDOMIMAGESFOLDER";$domain = "http://www.DOMAIN.com";$folder = "RANDOMIMAGESFOLDER";$imgs = array();// opens image directoryif (is_dir($dir)) {if ($dh = opendir($dir)) {while (($file = readdir($dh)) !== false) {if(!is_dir($file)) {$imgs[] = $file; }}closedir($dh);}}$rand = array_rand($imgs, 1);$rand_image = $imgs[$rand];echo "<style type=\"text/css\"> body { background: url(\"".$domain."/".$folder."/".$rand_image."\"); } </style>";?></head><body></body></html> edit: heh... i guess i only read the first page, oh well.
  7. calvin182

    Random

    its probably javascript, which I don't know. but I'm thinking you don't have php enabled on your server if it didn't work.edit: yeah I went back and tested this method and it works. try in the javascript forum or find a new host that supports php as php is a server side language and it must be installed on the server for any php scripts to work.
  8. calvin182

    Random

    well it sounds like you dont have one, so i'll help you out..htaccess file is pretty much a text file made in notepad, but instead of being named htaccess.txt its just .htaccess. so all you have to so is make a text file, paste that code above (AddType application/x-httpd-php .php .html) in it, and save it as .htaccess and upload it to your public_html folder. or if you have cpanel you can make a txt file in there and just save it as .htaccess.
  9. calvin182

    Random

    the page has to be saved as .php for any php script to work in it unless you change your .htaccess file to set your .php pages have the .html extention.if you want to try that, in your .htaccess file add this: AddType application/x-httpd-php .php .html i think that should do it
  10. calvin182

    Random

    I've been working on a gallery here for a while now so I'll give you the script I have set up on my site. Assuming you have php on your server (because on your site I see that all of your pages are .html), make sure you have a dedicated folder for your images you want to randomly display so only images are in it (no .html or anything else).The only things you need to edit are the top 3 lines (the stuff in UPPERCASE). Then copy the code and paste it in your html where you want it to be. If you want it to take from multiple folders, show thumbnails that have links to the larger images, or have any problems, let me know <?php$dir = "/home/DOMAIN/public_html/RANDOMIMAGESFOLDER";$domain = "http://www.mikemanx.com";$folder = "RANDOMIMAGESFOLDER";$imgs = array();// opens image directoryif (is_dir($dir)) {if ($dh = opendir($dir)) {while (($file = readdir($dh)) !== false) {if(!is_dir($file)) {$imgs[] = $file; }}closedir($dh);}}$rand = array_rand($imgs, 1);$rand_image = $imgs[$rand];echo "<img src=\"$domain/$folder/$rand_image\" border='0' alt='$rand_image' title='$rand_image'/>";?>
  11. i took out the session stuff bc I dont understand it but I was looking around http://www.php.net and http://www.w3chools.com and I couldn't find anything about file modified so I can add that as a sorting option.Also is there any way to filter out the filetypes from the array so if the user has a non image in the folder the script wont try to make an image for it?
  12. how do I use ++ and -- with this? if (($key = array_search($img, $imgs)) !== false){ echo "$key"; } I would like to set up $next and $prev variables but $next = $key++ and $prev = $key-- does not seem to work.
  13. on mouseover the border changes to a deep red, comfirming that it's not the image, and I looked in the source code and the border="0" attribute is not there.I use IPB as well so if you want I can write directions on where to go in the IPB ACP to fix it.
  14. Adding: <?php $imgs = array();// opens image directoryif (is_dir($dir)) {if ($dh = opendir($dir)) {while (($file = readdir($dh)) !== false) {if(!is_dir($file)) {$imgs[] = $file; }}closedir($dh);}}// sorts images in reverse orderif ($sorting=="reverse") {rsort($imgs);}else {sort($imgs);};if ($imgkey = array_search($img, $imgs) !== false) {echo "$img $imgkey";};?> to my show.php returns a 1 for every image. Isn't 1 supposed to be the key? I'm faily certain every image is key 1. Am I doing something wrong?and I've noticed that when you change the output formating from 16images in 4images per row it says 88images total, but if I were to display 5images with 5images per row(so 1row) then the total images now says 90, any idea why it's doing that?
  15. I'm a firefox user so I dunno if the error is visable in IE but the "Quote" button has no border attribute in the template HTML. just go into the IPB admin panel and edit your templat HTML and add border="0" to the img tag of the p_mq_add.gif image.
  16. does anybody have an idea on how to make back and next buttons to scroll though the images on the show page?i think this would involve these functions: in_array, next, and prev. so i think i would take the $img and use that with in_array and then use next and prev. but i think i would have to get the array again.i have created a backend control panel to control almost every aspect of this gallery so i cannot change the structure of the script for the back/next buttons
  17. maybe it can go to a diff php file (that contains no HTML) and opens the results in a new window and uses header to redirect back to the page you came from.im not sur eif it can be done, but its an idea.
  18. to fill anybody else in we found a few other issues and PM'd back and forth and came up with this as the result, I hope somebody can use this:INDEX.PHP: <html><head><title>Oneity PHP Gallery</title></head><body><?php// ------------------------------------------------------------------------------------------------------// Title: ONEITY PHP GALLERY// Version: 1.0// File Name: index.php// >>Required Files: show.php (included)// Author: Calvin Murphy, and members of w3schools.com forums// Last Updated: February 23rd, 2006 (3:41AM)// Website: [url="http://www.oneity-eight.roxr.com"]http://www.oneity-eight.roxr.com[/url]// Email: calvin182@gmail.com// ------------------------------------------------------------------------------------------------------// ------------------------------------------------------------------------------------------------------// Set up: ONEITY PHP GALLERY was created by Calvin Murphy with much help from the forum // members of [url="http://www.w3schools.com"]http://www.w3schools.com[/url]. This gallery was designed for digital camera users who // don't rename their images and want to display the most recent images first. Remember this is the first// version so theres no GD support amoung other things. For this script to function properly, the user // must set up a gallery folder, and within that folder there must be a folder for thumbnails (I recomend// calling it "thumbnails") and the full size images (I recomend calling it "imgs" or "images"). Both images// and thumbnails must have the same filename (including extension), the only difference is size and// location. For the thumbnails I recomend keeping the width of the images no more than 100pixels, but// there is no requirement. Place both files in the same directory. These files should not// be used used with include() or require() functions, but rather you should copy and paste your site// template around this block of php. For advanced users, filenames may be renamed.// ------------------------------------------------------------------------------------------------------//USER CONFIGURABLE ELEMENTS (these must be set correctly)// ------------------------------------------------------------------------------------------------------// set your domain and gallery directory. (ex: "http://www.domain.com" -no trailing slash)$domain = "http://www.domain.com/gallery";// set your thumbnails directory (if it is "http://www.domain.com/thumbnails", it'd just be "thumbnails")$thumbnails = "thumbnails";// thumbnails directory (as a relative address)$dir = '/home/YOURDOMAIN/public_html/gallery/thumbnails';// ------------------------------------------------------------------------------------------------------// ------------------------------------------------------------------------------------------------------// ADVANCED USERS// this file (defaultly named index.php)$index = "index";// show file (defaultly named show.php)$show = "show";// ------------------------------------------------------------------------------------------------------// ------------------------------------------------------------------------------------------------------// NO USER CONFIGUREABLE ELEMENTS (unless you know what you're doing!)// ------------------------------------------------------------------------------------------------------// ------------------------------------------------------------------------------------------------------$imgs = array();// opens image directoryif (is_dir($dir)) {if ($dh = opendir($dir)) {while (($file = readdir($dh)) !== false) {if(!is_dir($file)) {$imgs[] = $file; }}closedir($dh);}}// sorts images in reverse orderrsort($imgs);// fill the array so the table looks goodwhile((count($imgs) % 4) != 0){$imgs[] = " ";}// calculations$total = count($imgs);$pages = ceil($total/16);// set a default value$p = 1;// set a value if one was sentif(isset($_GET['p']))$p = intval($_GET['p']);// find upper limit for the pageif($p * 16 <= $total){$upperlimit = $p * 16;}else {$upperlimit = $total;}// set the start value of the index$start = ($p - 1) * 16;// tell user how far in the gallery they are$start1= $start + 1;echo "<p>displaying images $start1 to $upperlimit out of $total</p>\n";// builds image$j = $start;echo "<table>\n";while($j < $upperlimit){echo "<tr>\n";for($r = 0; $r < 4; $r++){echo "<td align='center' valign='middle'>\n";if($imgs[$j] != " ")echo "<a href='$domain/$show.php?img=".$imgs[$j]."&p=$p'><img src='$domain/$thumbnails/".$imgs[$j++]."' alt='Click here to view larger image' border='0'/></a>";elseecho $imgs[$j++]."\n";echo "</td>\n";}echo "</tr>\n";}echo "</table>\n";echo "<p>";for ($j = 1; $j <= $pages; $j++) {if ($p!=$j) {// ALMOST DONE! - creates page linkingecho "<a href=\"$domain/$index.php?p=$j\"> $j</a>\n";}else {echo " $j";}}echo "</p>";//FINISHED WOOT?></body></html> SHOW.PHP: <html><head><title>Oneity PHP Gallery</title></head><body><?php// ------------------------------------------------------------------------------------------------------// Title: ONEITY PHP GALLERY// Version: 1.0// File Name: show.php// >>Required Files: index.php (included)// Author: Calvin Murphy, and members of w3schools.com forums// Last Updated: February 23rd, 2006 (3:44AM)// Website: [url="http://www.oneity-eight.roxr.com"]http://www.oneity-eight.roxr.com[/url]// Email: calvin182@gmail.com// ------------------------------------------------------------------------------------------------------// ------------------------------------------------------------------------------------------------------// Set up: ONEITY PHP GALLERY was created by Calvin Murphy with much help from the forum // members of [url="http://www.w3schools.com"]http://www.w3schools.com[/url]. This gallery was designed for digital camera users who // don't rename their images and want to display the most recent images first. Remember this is the first// version so theres no GD support amoung other things. For this script to function properly, the user // must set up a gallery folder, and within that folder there must be a folder for thumbnails (I recomend// calling it "thumbnails") and the full size images (I recomend calling it "imgs" or "images"). Both images// and thumbnails must have the same filename (including extension), the only difference is size and// location. For the thumbnails I recomend keeping the width of the images no more than 100pixels, but// there is no requirement. Place both files in the same directory. These files should not// be used used with include() or require() functions, but rather you should copy and paste your site// template around this block of php. For advanced users, filenames may be renamed.// ------------------------------------------------------------------------------------------------------//USER CONFIGURABLE ELEMENTS (these must be set correctly)// ------------------------------------------------------------------------------------------------------// set your domain and gallery directory. (ex: "http://www.domain.com" -no trailing slash)$domain = "http://www.domain.com/gallery";// set your thumbnails directory (if it is "http://www.domain.com/thumbnails", it'd just be "thumbnails")$thumbnails = "thumbnails";// set the full size image directory$img = "img";// thumbnails directory (as a relative address)$dir = '/home/YOURDOMAIN/public_html/gallery/thumbnails';// ------------------------------------------------------------------------------------------------------// ------------------------------------------------------------------------------------------------------// ADVANCED USERS// index file (defaultly named index.php)$index = "index";// this file (defaultly named show.php)$show = "show";// ------------------------------------------------------------------------------------------------------// ------------------------------------------------------------------------------------------------------// NO USER CONFIGUREABLE ELEMENTS (unless you know what you're doing!)// ------------------------------------------------------------------------------------------------------// ------------------------------------------------------------------------------------------------------// set a default value$p = 1;$img="none";// set a value if one was sentif(isset($_GET['p']))$p = intval($_GET['p']);if(isset($_GET['img'])){$img = $_GET['image']} else {header("Location: $domain/$index.php"); exit(0);};<a href="$domain/$index.php?p=<?php echo $p;?>"><Back to gallery</a><br /><img src="$domain/$img/<?php echo "$img";?>" alt="img" hspace="0" vspace="0" border="0" />?></body></html>
  19. okay here's a bit of a question... i want to put a link around the image that includes an img variable and a p variable. i tired: echo "<a href=\'http://www.domain.com/gallery/nwb/show.php?img=".$imgs[$j++]."&p=$p' border='0'><img src='http://www.domain.com/gallery/nwb/thumbnails/".$imgs[$j++]."' alt='Click here to view larger image' /></a>\n"; but that reduces the images produced and fails to disable the border and the link is messed up so then i tried: $imgsrc=$imgs[$j++]; echo "<a href=\'http://www.domain.com/gallery/nwb/show.php?img=$imgsrc&p=$p' border='0'><img src='http://www.domain.com/gallery/nwb/thumbnails/$imgsrc"' alt='Click here to view larger image' /></a>\n"; and that produced errors... any ideas?
  20. oh that totally is awesome!!! Thank you SOOOO much! I think I can take it from here but if I need any help I'll make a post. Can I credit you for your help on my site? Just a first name and site url or email or just your name or whatever will do.You've gone way out of your way and I am very greatfull!EDIT: alright, but if you change your mind post here or PM me and I'll get on it, is it okay if I share this script on my site or something? no charing obliviously but i think it could be helpfull to some other people.
  21. im not sure what to do with that snippet... i know i gotta output $img_file as the image, and i'm actually going to output the image inside a table itself so i can add a frame around it, but i don't see how to output this. do i put the <td> stuff inside that space where &npsb; is and put <table> tags around the whole snippet? help please:)edit: do either of you have a first name and website I can credit for your help?
  22. okay... i've some how figured out how to cut out my range of images, the last thing I need to do is populate the images into a 4x4 table.code is as follows: <?php// set a default value$p = 1;// set a value if one was sentif(isset($_GET['p']))$p = $_GET['p'];$dir = '/home/domain/public_html/gallery/nwb/thumbnails';$imgs = array();if (is_dir($dir)) { if ($dh = opendir($dir)) { while (($file = readdir($dh)) !== false) { if(($file != '.') && ($file != '..')) { $imgs[] = $file; } }; closedir($dh); }};rsort($imgs);$total = count($imgs);$pages = ceil($total/16);$prerangemin1 = $p * 16;$prerangemin = $prerangemin1 - 17;if ($prerangemin < 0) {$rangemin="0";} else {$rangemin=$prerangemin;};$output = array_slice($imgs, $rangemin, 16);foreach($output as $img_file) { echo "<img src='http://www.domain.com/gallery/nwb/thumbnails/$img_file' alt='Click here to view larger image' />";};for ($j = 1; $j <= $pages; $j++) {if ($p!=$j) {echo "<a href=\"http://www.domain.com/gallery/nwb/index.php?p=$j\"> $j</a>";} else {echo " $j";};};?>
  23. first off i want to thank everybody who has been helping me on this one, you guys have really gone out of your way to help me out, and im glad there are people out there kind enough to help php noobs like me :)in regards to "So, are you sure you don't want to use an already made script."... yea i'm sure, i really dislike premade galleies because they are so generic, plus i don't learn anything. this approach, though difficult, is the best in my perspective because it caters to my exact needs and helps me understand how my site is going to work."I'm betting that the google search that sbrownii suggested would include a script that has a "class" that would allow sorting by date like you are after." php.net had a user contributed thing like that but the problem with that is i batch created all my images as thumbnails (and the main images) in irfanview so they all have the same date. they're all from my digi cam so by name will work.now, im following most of your code hacknsack, but the last line i don't get, what do you mean by create my own equation for the start? like... i think the next step is to tell the rest of the script to define a range of images to show depending on the value of $p, is that what you mean? but im not sure how to display a range from the array, ive been searching php.net but so far i havent found anything.i added an if statement to the for statement that creates the page links at the bottom so if the user is on page 1, then the link for page 1 in not active. heres where i am at: <?php$dir = '/home/******/public_html/gallery/nwb/thumbnails';$imgs = array();if (is_dir($dir)) { if ($dh = opendir($dir)) { while (($file = readdir($dh)) !== false) { if(($file != '.') && ($file != '..')) { $imgs[] = $file; } }; closedir($dh); }};rsort($imgs);// you can use print_r() for debug// echo "<pre>";// print_r($imgs);// echo "</pre>";foreach($imgs as $img_file) { echo "<img src='http://www.domain.com/gallery/nwb/thumbnails/$img_file' alt='Click here to view larger image' />";};// set a default value$p = 1;// set a value if one was sentif(isset($_GET['p']))$p = $_GET['p'];// subtract one because the array index starts at 0$upperlimit = intval($p) * 16 - 1;// you will need to create the equation to get your start for each page// $start = ...$total = count($imgs);$pages = ceil($total/16);for ($j = 1; $j <= $pages; $j++) {if ($p!=$j) {echo "<a href=\"http://www.domain.com/gallery/nwb/index.php?p=$j\"> $j</a>";} else {echo " $j";};};?> this is looking good, all thats left is to cut out a range of images to display :)EDIT: would array_slice() be used to return the range of 16 images after it is defined for the appropriate page?
  24. sweet, to recap, the script loads all images in the folder, puts them into an array, sorts the in reverse order, and displays them as images. here's what i've got at the moment: <?php$dir = '/home/******/public_html/gallery/nwb/thumbnails';$imgs = array();if (is_dir($dir)) { if ($dh = opendir($dir)) { while (($file = readdir($dh)) !== false) { if(($file != '.') && ($file != '..')) { $imgs[] = $file; } } closedir($dh); }}rsort($imgs);// you can use print_r() for debug// echo "<pre>";// print_r($imgs);// echo "</pre>";foreach($imgs as $img_file){ echo "<img src='http://www.domain.com/gallery/nwb/thumbnails/$img_file' alt='Click here to view larger image' />";}?> i havent set the anchor tags yet but i know how to do that stuff. now is there a way to load only a range of 16 to a page?
×
×
  • Create New...