Jump to content
xisto Community
Sign in to follow this  
Inhuman

I Could Use A Little Help Here [resolved]

Recommended Posts



/* This function is the one I've been using forever. It just goes and grabs
an alphabetical array of files in the specified directory. */

function getlist_alpha(&$afiles, $listdir) {
if (is_dir($listdir)) {
if ($thisdir = opendir($listdir)) {
while (($afile = readdir($thisdir)) !== false) {
if (!is_dir($afile) && preg_match("/.*\.(gif|jp(e)?g|png)/i", $afile)) {
$afiles[] = $afile;
}
}
closedir($thisdir);
return $afiles;
}
}
}

/* This function actually creates the strings to be put in the selection list. */

function printoptions($item1, $key, $listdir) {
if (strpos($item1, ".")) { $item1 = explode(".", $item1);
$item1 = $item1[0]; }
$ffile = "$listdir/$item1";
if ($item1 == $_GET['id']) echo "\n<option selected>"; else echo "\n<option>"; echo "$item1</option>";
}

/* This function sorts a collected array and then uses printoptions to make the list. */

function comiclist($listdir, $listid) {
echo "<center><form name=\"comiclist\">\n<select name=\"id\" id=\"id\">";
$alisting = getlist_alpha($listcomics, $listdir);
rsort($alisting);
array_walk($alisting, 'printoptions', $listdir);
echo "</select>\n<input type=\"submit\" value=\"Go\" action=\"selection.php\" method=\"get\">\n</form></center>";
}

comiclist($listdir, $listid);


?></p>
<div align="center">
<p><?php
$cdir = 'comics';
$getc = $_GET['id'];
$phpfile = $_SERVER['PHP_SELF'];

function check_zeros($num) {
$digits = 3;
$pad = strval(0);
$num = strval($num);

if (strlen($num) != $digits) {
$num = str_pad($num, $digits, $pad, STR_PAD_LEFT);
}
return $num;
}


function find_comic($idnum, $dir) {
if (is_dir($dir)) {
if ($cdir = opendir($dir)) {
if ($idnum != 'all') $idnum = check_zeros($idnum);
if ($idnum == 'all') $num = 0;
while (($file = readdir($cdir)) !== false) {
if ($file != '.' && $file != '..') {
if ($idnum != 'all') {
if (preg_match("/$idnum\.(gif|jp(e?)g|png)/i", $file)) {
$idnum = $file;
}
}
else if (preg_match("/.*\.(gif|jp(e?)g|png)/i", $file)) {
$num++;
}
}
}
}
closedir($cdir);
}
if ($idnum == 'all') return $num;
else return $idnum;
}



$max_comics = find_comic("all", $cdir);

if ($getc < 1 || $getc == NULL || $getc > $max_comics)
$getc = $max_comics;

if ($getc > 1)
$getp = $getc - 1;
else
$getp = NULL;

$getn = $getc + 1;
$cshow = find_comic($getc, $cdir);

echo "<img src=\"$cdir/$cshow\" border=\"0\" /><br>";

echo "<br><br>";

if ($getc > 2)
echo "<a href=\"$phpfile?id=1\"><img src=\"first.gif\" border=\"0\"></a>";

if ($getc > 1)
echo "<a href=\"$phpfile?id=$getp\"><img src=\"back.gif\" border=\"0\"></a>";

echo "<a href=\"MAKETHISYOURHOMEPAGEURL\"><img src=\"home.gif\" border=\"0\"></a>";

if ($getc < $max_comics)
echo "<a href=\"$phpfile?id=$getn\"><img src=\"next.gif\" border=\"0\"></a>";

if ($getc != $max_comics && $getc < $max_comics - 1)
echo "<a href=\"$phpfile?id=$max_comics\"><img src=\"newest.gif\" border=\"0\"></a>";
?> linenums:0'><?php$listdir = "comics"; // Customizeable$listid = $_GET['id']; // Leave this alone/* This function is the one I've been using forever. It just goes and grabs an alphabetical array of files in the specified directory. */function getlist_alpha(&$afiles, $listdir) { if (is_dir($listdir)) { if ($thisdir = opendir($listdir)) { while (($afile = readdir($thisdir)) !== false) { if (!is_dir($afile) && preg_match("/.*\.(gif|jp(e)?g|png)/i", $afile)) { $afiles[] = $afile; } } closedir($thisdir); return $afiles; } }}/* This function actually creates the strings to be put in the selection list. */function printoptions($item1, $key, $listdir) { if (strpos($item1, ".")) { $item1 = explode(".", $item1); $item1 = $item1[0]; } $ffile = "$listdir/$item1"; if ($item1 == $_GET['id']) echo "\n<option selected>"; else echo "\n<option>"; echo "$item1</option>";}/* This function sorts a collected array and then uses printoptions to make the list. */function comiclist($listdir, $listid) {echo "<center><form name=\"comiclist\">\n<select name=\"id\" id=\"id\">"; $alisting = getlist_alpha($listcomics, $listdir); rsort($alisting); array_walk($alisting, 'printoptions', $listdir);echo "</select>\n<input type=\"submit\" value=\"Go\" action=\"selection.php\" method=\"get\">\n</form></center>";}comiclist($listdir, $listid);?></p> <div align="center"> <p><?php$cdir = 'comics';$getc = $_GET['id']; $phpfile = $_SERVER['PHP_SELF']; function check_zeros($num) { $digits = 3; $pad = strval(0); $num = strval($num); if (strlen($num) != $digits) { $num = str_pad($num, $digits, $pad, STR_PAD_LEFT); } return $num;}function find_comic($idnum, $dir) { if (is_dir($dir)) { if ($cdir = opendir($dir)) { if ($idnum != 'all') $idnum = check_zeros($idnum); if ($idnum == 'all') $num = 0; while (($file = readdir($cdir)) !== false) { if ($file != '.' && $file != '..') { if ($idnum != 'all') { if (preg_match("/$idnum\.(gif|jp(e?)g|png)/i", $file)) { $idnum = $file; } } else if (preg_match("/.*\.(gif|jp(e?)g|png)/i", $file)) { $num++; } } } } closedir($cdir); } if ($idnum == 'all') return $num; else return $idnum;}$max_comics = find_comic("all", $cdir);if ($getc < 1 || $getc == NULL || $getc > $max_comics)$getc = $max_comics;if ($getc > 1)$getp = $getc - 1;else$getp = NULL;$getn = $getc + 1;$cshow = find_comic($getc, $cdir);echo "<img src=\"$cdir/$cshow\" border=\"0\" /><br>";echo "<br><br>";if ($getc > 2)echo "<a href=\"$phpfile?id=1\"><img src=\"first.gif\" border=\"0\"></a>";if ($getc > 1)echo "<a href=\"$phpfile?id=$getp\"><img src=\"back.gif\" border=\"0\"></a>";echo "<a href=\"MAKETHISYOURHOMEPAGEURL\"><img src=\"home.gif\" border=\"0\"></a>";if ($getc < $max_comics)echo "<a href=\"$phpfile?id=$getn\"><img src=\"next.gif\" border=\"0\"></a>";if ($getc != $max_comics && $getc < $max_comics - 1)echo "<a href=\"$phpfile?id=$max_comics\"><img src=\"newest.gif\" border=\"0\"></a>";?>
Ok, I got this code from here and it's not workin right.

Screen cap...and yes, I do plan on changing the look of the site. <_<

Ok, so what's going on with this bad larry?

Share this post


Link to post
Share on other sites

Where are you using this file? it looks like its just parsing it out. Are you testing it on a PHP enabled server? Make sure you save that file as a .php file because when I changed it to html to eheck I got the same output as your screenshot.

Edited by sonesay (see edit history)

Share this post


Link to post
Share on other sites

Well I'm trying to get this to work on my website...I installed Templates Express and I don't think it is...but then again, I'm new to php...and I have no idea how it works. <_<Change to php? I'll try that.Edit: Sonesay, I love you with mouth. It worked. Thanks a lot man. :(Mods, do whatever it is you do with threads that have expired their purpose.

Edited by Inhuman (see edit history)

Share this post


Link to post
Share on other sites

Topic is resolved.Please PM any moderator to continue this discussion. Until then, this topic is closed.

Share this post


Link to post
Share on other sites
Guest
This topic is now closed to further replies.
Sign in to follow this  

×
×
  • Create New...

Important Information

Terms of Use | Privacy Policy | Guidelines | 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.