TP-Docs
HTML5 Icon HTML5 Icon HTML5 Icon
TP on Social Media

Recent

Welcome to TinyPortal. Please login or sign up.

May 13, 2024, 04:09:07 AM

Login with username, password and session length
Members
  • Total Members: 3,885
  • Latest: Growner
Stats
  • Total Posts: 195,188
  • Total Topics: 21,220
  • Online today: 62
  • Online ever: 3,540 (September 03, 2022, 01:38:54 AM)
Users Online
  • Users: 0
  • Guests: 74
  • Total: 74

Latest Comic

Started by onicat, August 04, 2008, 01:18:38 AM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

IchBin

Did you look at the link I provided? One of the links on that page http://feed2js.org/index.php?s=build will do exactly what you want I think.

onicat

Tried it.  The HTML block mode didn't like having a <script> in it for some reason.  All it displayed was code.  I think I can do it using SimplePie and an iframe, though.

IchBin

Then don't use an HTML block, use a script block type.

Ianedres

#13
Try this and see if it will work on your server. It does require 'allow_url_fopen' to be set to on in your server's php.ini configuration file. (More info on that)... I think this would work better than trying to build the RSS feed on your one site, and then try to extract the graphic on the other.

This should start at the current date and try to open a file with the naming scheme of 'yyyy-mm-dd' (which is the format the graphic used in original example). Failing that, it will subtract one day at a time, going down through the months. It will limit the search to the previous year...

* Remove the opening and closing php tags if you are copying directly to a php block or article...

I went back and added the option to set the image size, as well as whether it can be linked to the original graphic by clicking on the displayed image (for making a thumbnail).

<?php

// akcommunity.com | Latest Comic Retrieval
// August 06, 2008 | Tim Antley | www.BayouMX.com

// Two variables ($comic_path & $comic_ext) should be set to go
// Other variables can be set by reading comments

// Your php server must have 'allow_url_fopen' on in php.ini config file.
// See http://www.php.net/manual/en/filesystem.configuration.php#ini.allow-url-fopen for more info on that.

$date getdate();
$year $date['year'];
$month sprintf("%02s"$date['mon']);
$day sprintf("%02s"$date['mday']);

$max_height '743'// set image maximum height
$max_width '800'// set image maximum width

$use_link true// 'true' or 'false' - makes displayed image link to original image (for thumbnailing)
$target '_blank'// link target - '_blank', '_self', etc.

// build the link with padded zeros
function make_link($year$month$day)
{
$comic_path 'akcommunity.com/Comic/comics/'// path to your server and directory with trailing slash /
$comic_ext 'jpg'// image type extension (jpg/gif/tif/bmp)

$link $comic_path sprintf("%04s"$year) . '-' sprintf("%02s"$month) . '-' sprintf("%02s"$day) . '.' $comic_ext;

return $link;
}

// start recursive search by day, then month, and year
for($year $year$year >= ($year 1); $year $year 1)
{
for($month $month$month 0$month $month 1)
{
for($day $day$day 0$day $day 1)
{
$link  make_link($year$month$day);

if(@fopen('http://' $link"r")) // suppress errors
{
if($use_link) echo '<a href="http://' $link '" target="' $target '">';

echo '<img src="http://' $link '" height="' $max_height '" width="' $max_width '" />';

if($use_link) echo '</a>';
return; // image was found - end of script
}
}
$day '31'// reset to day #31 for recursive search
}
$month '12'// reset to month #12 for recursive search

}

// nothing for output if no file was located
?>

JPDeni

#14
Unnecessary post.

onicat

#15
That...is exactly what I'm looking for, Tim!  You, sir, are a gentleman and a scholar.  m(~.~)m  Setting allow_url_fopen wasn't an issue (already taken care of, in fact, for some other software I have installed).  The script works great in a PHP block (I get an image, and it's the correct one), but I'm running into a few odd issues:

First, when used exactly as presented (minus the open/close tags), it makes my right-hand TP column and all other blocks below it disappear.  How do I troubleshoot that?

Second, the link option links directly to the image itself.  That works as you intended, but I would prefer to link it to the comic archive site (http://akcommunity.com/Comic/), that way users can browse the archive if they wish to do so.  I noticed, however, I can't just change the code on the line that sets the $link variable because it would break the image output altogether.  I suppose I could just hard code that url into the line that actually outputs the href statement, though, right?

Third: This one kind of breaks things.  The $max_width and $max_height variables just tell the img statement what to scale things to, which will stretch things out of proportion when the comic sizes differ between postings.  Is there a way to make that dynamically scale?

I really appreciate the help, Tim.  Where do you want your credit?  :laugh:

Ianedres

For your questions:

1) My script simply outputs the <img> tag (and href, if set) to the screen; it does nothing to the other TP-blocks, tables, or anything else. If you are using this in a php article (I know you said a 'php block'), you may need to turn on/off the visual options as such. Other than maybe a CSS issue with margins or padding around the IMG image tag, it should not affect the display that I'm aware of.

2) To change the link to a static destination, just replace:if($use_link) echo '<a href="http://' . $link . '" target="' . $target . '">';
with this:if($use_link) echo '<a href="http://akcommunity.com" target="' . $target . '">';

3) To remove the height/width constraints, change:echo '<img src="http://' . $link . '" height="' . $max_height . '" width="' . $max_width . '" />';
with this:echo '<img src="http://' . $link . '" />';

As far as credit goes, don't worry about it. If you happen to have a links section or a simple way to point to my SMF/TP website (www.BayouMX.com), that would be cool.

Just remember to name the images using the yyyy-mm-dd scheme, and I think it will serve you well.

onicat

Have a look at http://akcommunity.com to see what I'm talking about regarding the disappearing blocks.  There are supposed to be a column down the right side and other content blocks below the comic.  Using your code in a TinyPortal PHP box causes those to disappear.  That's what I'm trying to solve now.  Otherwise it works beautifully.

Ianedres

My big error!  :o

Replace 'die();' with 'return;'...

Will modify my original code...