Skip to content

Instantly share code, notes, and snippets.

Created August 13, 2011 06:08
Show Gist options
  • Save anonymous/1143529 to your computer and use it in GitHub Desktop.
Save anonymous/1143529 to your computer and use it in GitHub Desktop.
<?php
function checkName($fname)
{
if ($fname == "20031128ab.jpg")
return "20031128.jpg";
return $fname;
}
function checkPath($pathToImages, $fname)
{
if (substr($fname, -6) == "nt.jpg")
return "http://2kinds.com/images/" . $fname;
//echo substr($fname, -6), "<br />";
return $pathToImages . $fname;
}
if (file_exists("original_thumbs/" . $pagename[$pagenum]))
{
if ($pagenum < count($pagename)-1)
$imglink = "http://twokinds.keenspot.com/archive.php?p=" . $pagenum;
else
$imglink = "http://twokinds.keenspot.com/";
echo "<div class=\"thumb\">
<a href=\"$imglink\">
<img src=\"original_thumbs/$pagename[$pagenum]\" />
</a><br />
Site version (official)
</div>\n";
}
if ($ntname[$pagenum] != "" && file_exists("nt_thumbs/" . $ntname[$pagenum]))
{
if ($pagenum == 105)
$imglink = "http://twokinds.keenspot.com/archive.php?p=" . $pagenum;
else
$imglink = checkPath("http://twokindscomic.com/speechless/images/", $ntname[$pagenum]);
echo "<div class=\"thumb\">
<a href=\"$imglink\">
<img src=\"nt_thumbs/$ntname[$pagenum]\" />
</a><br />
Speechless version (official)
</div>\n";
}
if (file_exists("te_files/" . $pagename[$pagenum]))
{
if (!file_exists("te_thumbs/" . $pagename[$pagenum]))
{
require_once("includes/create_thumb.inc.php");
$controlmessage = create_thumb("te_files/", $pagename[$pagenum], "te_thumbs/", $pagename[$pagenum]);
//$controlmessage .= "<br />";
//echo $controlmessage;
}
echo "<div class=\"thumb\">
<a href=\"te_files/", $pagename[$pagenum], "\">
<img src=\"te_thumbs/", $pagename[$pagenum], "\" />
</a><br />
Text-erased version (unofficial)
</div>\n";
}
/* Check if there's a folder with the current file name in old_versions. Note that there's not files in it, but more folders, with one file in each. The folders can only be found by listing them, as it's the folder names that will be used for the picture subtitles.
*/
$oldfilesdir = "old_files/" . $pagename[$pagenum];
if (file_exists($oldfilesdir)) // Finds a folder, not a file
{
//echo "old_files/" . $pagename[$pagenum];//Old official version
// Search the folder for subfolders:
// Open the directory
$dir_h=opendir($oldfilesdir);
//echo '<br />oldfilesdir = ', $oldfilesdir, '<br />';
// read directory into pics array
while (($subdir = readdir($dir_h))!==false)
if ($subdir != "." && $subdir != "..")
{
//echo 'subdir = ', $subdir, '<br />';
// For each subfolder found, look for a file inside it.
$subdirpath = $oldfilesdir . '/' . $subdir;
//echo '$subdirpath = ', $subdirpath, '<br />';
$subdir_h=opendir($subdirpath);
while (($file = readdir($subdir_h))!==false)
if ($file != "." && $file != "..")
{
// echo 'thumb = ', $thumb, '<br />';
// Check for a corresponding thumbnail image
$thumbpath = "old_thumbs/" . $pagename[$pagenum] . '/' . $subdir . '/';
$thumb = $thumbpath . $file;
if (!file_exists($thumb))
{
// If file exists but not thumbnail, create a thumbnail image
require_once("includes/create_thumb.inc.php");
$subdirpath .= '/';
$tpath = "old_thumbs/" . $pagename[$pagenum];
echo 'tpath = ', $tpath, '<br />';
if (!file_exists($tpath))
if (mkdir($tpath, 0777))
echo "Success!<br />";
else
echo "Fail!<br />";
$tpath = "old_thumbs/" . $pagename[$pagenum] . "/X";
echo 'tpath = ', $tpath, '<br />';
if (!file_exists($tpath))
if (mkdir($tpath, 0777))
echo "Success!<br />";
else
echo "Fail!<br />";
$tpath = "old_thumbs/X";
echo 'tpath = ', $tpath, '<br />';
if (!file_exists($tpath))
if (mkdir($tpath, 0777))
echo "Success!<br />";
else
echo "Fail!<br />";
$tpath = "old_thumbs/X/X";
echo 'tpath = ', $tpath, '<br />';
if (!file_exists($tpath))
if (mkdir($tpath, 0777))
echo "Success!<br />";
else
echo "Fail!<br />";
$tpath = substr($thumbpath, 0, -1);
echo 'tpath = ', $tpath, '<br />';
if (!file_exists($tpath))
if (mkdir($tpath, 0777))
echo "Success!<br />";
else
echo "Fail!<br />";
$controlmessage = create_thumb($subdirpath, $file, $thumbpath, $file);
//echo $controlmessage;
}
// Output folder name as a subtitle, thumbnail as an image
echo "<div class=\"thumb\">
<a href=\"$subdirpath/$file\">
<img src=\"$thumb\" />
</a><br />
$subdir
</div>\n";/**/
}
closedir($subdir_h);
}
closedir($dir_h);
}
else
;//echo "Y";
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment