[Closed]: Jigsaw Puzzle [Closed]: Jigsaw Puzzle
 

News:

cpg1.5.48 Security release - upgrade mandatory!
The Coppermine development team is releasing a security update for Coppermine in order to counter a recently discovered vulnerability. It is important that all users who run version cpg1.5.46 or older update to this latest version as soon as possible.
[more]

Main Menu

[Closed]: Jigsaw Puzzle

Started by gebe, September 09, 2009, 09:56:11 PM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

gebe

Hi!

I have question. I want a jigsaw puzzle generator to my coppermine gallery.

Some examples: http://www.animegalleries.net/category/37   or    http://www.puzzz.com/

I'm not the god of program making Undecided, i need a plugin like on these sites.

Can somebody help me?

Thx in advance!

(Sorry for my english)

Joachim Müller

The Coppermine-driven gallery you refer to is using a Java-driven jigsaw puzzle script that we're not familiar with that doesn't come from this site. All that they do in coppermine is add a link to the jigsaw puzzle by adding the file path to the fullsize pic to the URL of the jisaw puzzle pop-up page.

Example: http://www.animegalleries.net/img/12548 embedds the image http://media.animegalleries.net/albums/Fancy%20Lala/groups/fll_groups000.JPG
The URL of the correpsonding jigsaw puzzle is http://www.animegalleries.net/puzzle/puzzle.php?action=draw&img=1252572472-91-18-93-216.jpg&orig=../albums/Fancy%20Lala/groups/fll_groups000.JPG
You get the point, don't you?
Anyway, as I suggested: we're not aware of such a script. Search the web for such a puzzle script and if you have found one that will do the needed actions and can cope with the URL of an image passed as only GET parameter then return here and will teach you how to add the reference inside coppermine. In the meantime, I'll mark this thread as "closed". Reply to it to change the status.

gebe

Hi!

Thx very much. I have found the script what works on the animegalleries.

The link: http://homepage.ntlworld.com/dashfad/computing/jigsaw/

It's good for me.

What's the first step?


gebe

Quote from: Joachim Müller on September 10, 2009, 11:01:01 AM
The Coppermine-driven gallery you refer to is using a Java-driven jigsaw puzzle script that we're not familiar with that doesn't come from this site. All that they do in coppermine is add a link to the jigsaw puzzle by adding the file path to the fullsize pic to the URL of the jisaw puzzle pop-up page.

Example: http://www.animegalleries.net/img/12548 embedds the image http://media.animegalleries.net/albums/Fancy%20Lala/groups/fll_groups000.JPG
The URL of the correpsonding jigsaw puzzle is http://www.animegalleries.net/puzzle/puzzle.php?action=draw&img=1252572472-91-18-93-216.jpg&orig=../albums/Fancy%20Lala/groups/fll_groups000.JPG
You get the point, don't you?
Anyway, as I suggested: we're not aware of such a script. Search the web for such a puzzle script and if you have found one that will do the needed actions and can cope with the URL of an image passed as only GET parameter then return here and will teach you how to add the reference inside coppermine. In the meantime, I'll mark this thread as "closed". Reply to it to change the status.

If you have some idea pls mail me: gabizolipage@gmail.com

The script is in the previous post.

Bye!

Joachim Müller

#4
Posting your email address will please email harvesters and result in more spam in your mailbox, that's all. This is not a hotline, so you should allow some time for answers. As suggested in your other needless double-postings it's not a bright idea to upset supporters by nmot respecting board rules and common sense. Being new or lack of language skills is no excuse for not showing enough respect.

gebe

Quote from: Joachim Müller on September 14, 2009, 03:46:59 PM
Posting your email address will please email harvesters and result in more spam in your mailbox, that's all. This is not a hotline, so you should allow some time for answers. As suggested in your other needless double-postings it's not a bright idea to upset supporters by nmot respecting board rules and common sense. Being new or lack of language skills is no excuse for not showing enough respect.

I'm so sorry. Help me if you have any time. I'll be patient.

Bye!

Joachim Müller

OK, I had a look into this and first attempted to convert this into a plugin, but I figured out that the Java code used is pretty badly done. Therefor, I have come up with a hack that is not very cleverly done itself and therefor fits to the code of the jigsaw puzzle itself.

This is what you do:
1) download the attached mod zip-file and unzip the contents into a temporary folder, preserving the structure within the zip.
2)Upload the content of the tempory folder into the root of your coppermine-driven gallery
3) Edit your custom theme (themes/yourtheme/theme.php) with a plain text editor and find the sections $template_img_navbar =andfunction theme_html_img_nav_menu()and edit as suggested below. If your custom theme doesn't contain those sections, copy them first from themes/sample/theme.php and add them into a new line before ?>of the file themes/yourtheme/theme.php
Then find                <td align="center" valign="middle" class="navmenu" width="100%">
                        {PIC_POS}
                </td>
and add after it into a new line <td align="center" valign="middle" class="navmenu" width="100%">
                        <a href="{PUZZLE_TGT}">Puzzle</a>
                </td>

Next, find        '{LOCATION}' => $location,and add after it (into a line of it's own) '{PUZZLE_TGT}' => "puzzle.php?album=$album$cat_link&amp;pid=$pid&amp;pos=$pos",

As I suggested, the underlying Java code is quite badly written: it requires files to be moved around and can not cope with just the position of the files, so I had to come up with a basic garbage collection routine in puzzle.php (that file resides in the zip file).
You'll notice that there are some hard-coded language strings in that file that you might want to edit, and you might want to change the parameters of the applet call in puzzle.php. In my opinion this piece of code should not be used, and it might act up easily. Use at your own risk.



For clarity here's the edited code that needs to go into themes/yourtheme/theme.php:// HTML template for the image navigation bar
$template_img_navbar = <<<EOT

        <tr>
                <td align="center" valign="middle" class="navmenu" width="48">
                        <a href="{THUMB_TGT}" class="navmenu_pic" title="{THUMB_TITLE}"><img src="{LOCATION}images/thumbnails.gif" align="middle" border="0" alt="{THUMB_TITLE}" /></a>
                </td>
                <td align="center" valign="middle" class="navmenu" width="48">
                        <a href="javascript:;" class="navmenu_pic" onclick="blocking('picinfo','yes', 'block'); return false;" title="{PIC_INFO_TITLE}"><img src="{LOCATION}images/info.gif" border="0" align="middle" alt="{PIC_INFO_TITLE}" /></a>
                </td>
                <td align="center" valign="middle" class="navmenu" width="48">
                        <a href="{SLIDESHOW_TGT}" class="navmenu_pic" title="{SLIDESHOW_TITLE}"><img src="{LOCATION}images/slideshow.gif" border="0" align="middle" alt="{SLIDESHOW_TITLE}" /></a>
                </td>
                <td align="center" valign="middle" class="navmenu" width="100%">
                        {PIC_POS}
                </td>
<td align="center" valign="middle" class="navmenu" width="100%">
                        <a href="{PUZZLE_TGT}">Puzzle</a>
                </td>
<!-- BEGIN report_file_button -->
                <td align="center" valign="middle" class="navmenu" width="48">
                        <a href="{REPORT_TGT}" class="navmenu_pic" title="{REPORT_TITLE}"><img src="{LOCATION}images/report.gif" border="0" align="middle" alt="{REPORT_TITLE}" /></a>
                </td>
<!-- END report_file_button -->
<!-- BEGIN ecard_button -->
                <td align="center" valign="middle" class="navmenu" width="48">
                        <a href="{ECARD_TGT}" class="navmenu_pic" title="{ECARD_TITLE}"><img src="{LOCATION}images/ecard.gif"  border="0" align="middle" alt="{ECARD_TITLE}" /></a>
                </td>
<!-- END ecard_button -->
                <td align="center" valign="middle" class="navmenu" width="48">
                        <a href="{PREV_TGT}" class="navmenu_pic" title="{PREV_TITLE}"><img src="{LOCATION}images/prev.gif"  border="0" align="middle" alt="{PREV_TITLE}" /></a>
                </td>
                <td align="center" valign="middle" class="navmenu" width="48">
                        <a href="{NEXT_TGT}" class="navmenu_pic" title="{NEXT_TITLE}"><img src="{LOCATION}images/next.gif"  border="0" align="middle" alt="{NEXT_TITLE}" /></a>
                </td>
        </tr>

EOT;


function theme_html_img_nav_menu()
{
    global $CONFIG, $CURRENT_PIC_DATA, $meta_nav, $THEME_DIR ; //$PHP_SELF,
    global $album, $cat, $pos, $pic_count, $lang_img_nav_bar, $lang_text_dir, $template_img_navbar;

    $cat_link = is_numeric($album) ? '' : '&amp;cat=' . $cat;
    $uid_link = (isset($_GET['uid']) && is_numeric($_GET['uid'])) ? '&amp;uid=' . $_GET['uid'] : '';

    $human_pos = $pos + 1;
    $page = ceil(($pos + 1) / ($CONFIG['thumbrows'] * $CONFIG['thumbcols']));
    $pid = $CURRENT_PIC_DATA['pid'];
    $linebreak = "\r\n";

    $start = 0;
        $start_tgt = "{$_SERVER['PHP_SELF']}?album=$album$cat_link&amp;pos=$start";
        $start_title = $lang_img_nav_bar['go_album_start'];
        $meta_nav .= $linebreak . "<link rel=\"start\" href=\"$start_tgt\" title=\"$start_title\" />";
        $end = $pic_count - 1;
        $end_tgt = "{$_SERVER['PHP_SELF']}?album=$album$cat_link&amp;pos=$end";
        $end_title = $lang_img_nav_bar['go_album_end'];
        $meta_nav .= $linebreak . "<link rel=\"last\" href=\"$end_tgt\" title=\"$end_title\" />";

    if ($pos > 0) {
        $prev = $pos - 1;
        $prev_tgt = "{$_SERVER['PHP_SELF']}?album=$album$cat_link&amp;pos=$prev$uid_link";
        $prev_title = $lang_img_nav_bar['prev_title'];
        $meta_nav .= $linebreak . "<link rel=\"prev\" href=\"$prev_tgt\" title=\"$prev_title\" />";
    } else {
        $prev_tgt = "javascript:;";
        $prev_title = "";
    }

    if ($pos < ($pic_count -1)) {
        $next = $pos + 1;
        $next_tgt = "{$_SERVER['PHP_SELF']}?album=$album$cat_link&amp;pos=$next$uid_link";
        $next_title = $lang_img_nav_bar['next_title'];
        $meta_nav .= $linebreak . "<link rel=\"next\" href=\"$next_tgt\" title=\"$next_title\"/>";
    } else {
        $next_tgt = "javascript:;";
        $next_title = "";
    }

    if (USER_CAN_SEND_ECARDS) {
        $ecard_tgt = "ecard.php?album=$album$cat_link&amp;pid=$pid&amp;pos=$pos";
        $ecard_title = $lang_img_nav_bar['ecard_title'];
    } else {
        template_extract_block($template_img_navbar, 'ecard_button'); // added to remove button if cannot send ecard
    }

    //report to moderator buttons
    $report_tgt = '';
    if (($CONFIG['report_post']==1) && (USER_CAN_SEND_ECARDS)) {
        $report_tgt = "report_file.php?album=$album$cat_link&amp;pid=$pid&amp;pos=$pos";
    } else { // remove button if report toggle is off
        template_extract_block($template_img_navbar, 'report_file_button');

    }

    $thumb_tgt = "thumbnails.php?album=$album$cat_link&amp;page=$page$uid_link";
    $meta_nav .= $linebreak . "<link rel=\"up\" href=\"$thumb_tgt\" title=\"".$lang_img_nav_bar['thumb_title']."\"/>";

    $slideshow_tgt = "{$_SERVER['PHP_SELF']}?album=$album$cat_link$uid_link&amp;pid=$pid&amp;slideshow=".$CONFIG['slideshow_interval'];

    $pic_pos = sprintf($lang_img_nav_bar['pic_pos'], $human_pos, $pic_count);

    if (defined('THEME_HAS_NAVBAR_GRAPHICS')) {
            $location= $THEME_DIR;
        } else {
            $location= '';
        }

    $params = array('{THUMB_TGT}' => $thumb_tgt,
        '{THUMB_TITLE}' => $lang_img_nav_bar['thumb_title'],
        '{PIC_INFO_TITLE}' => $lang_img_nav_bar['pic_info_title'],
        '{SLIDESHOW_TGT}' => $slideshow_tgt,
        '{SLIDESHOW_TITLE}' => $lang_img_nav_bar['slideshow_title'],
        '{PIC_POS}' => $pic_pos,
        '{ECARD_TGT}' => $ecard_tgt,
        '{ECARD_TITLE}' => $ecard_title,
        '{PREV_TGT}' => $prev_tgt,
        '{PREV_TITLE}' => $prev_title,
        '{NEXT_TGT}' => $next_tgt,
        '{NEXT_TITLE}' => $next_title,
        '{PREV_IMAGE}' => ($lang_text_dir=='ltr') ? 'prev' : 'next',
        '{NEXT_IMAGE}' => ($lang_text_dir=='ltr') ? 'next' : 'prev',
        '{REPORT_TGT}' => $report_tgt,
        '{REPORT_TITLE}' => $lang_img_nav_bar['report_title'],
        '{LOCATION}' => $location,
'{PUZZLE_TGT}' => "puzzle.php?album=$album$cat_link&amp;pid=$pid&amp;pos=$pos",
        );
    return template_eval($template_img_navbar, $params);
}



Additionally, here's the code that I have come up with for puzzle.php:<?php
define
('IN_COPPERMINE'true);

require(
'include/init.inc.php');

$pid = (int)$_GET['pid'];
$pos = (int)$_GET['pos'];
$album = (int)$_GET['album'];
$solved = (int)$_GET['solved'];



// Get picture thumbnail url
$result cpg_db_query("SELECT * from {$CONFIG['TABLE_PICTURES']} WHERE pid='$pid'");
if (!
mysql_num_rows($result)) cpg_die(ERROR$lang_errors['non_exist_ap'], __FILE____LINE__);
$row mysql_fetch_array($result);
$normal_pic_url get_pic_url($row'normal');
if (
file_exists($normal_pic_url) != TRUE) {
$normal_pic_url get_pic_url($row'fullsize');
}

$pic_title $row['title'];
$pic_caption bb_decode($row['caption']);

if (!
is_image($row['filename'])) cpg_die(ERROR$lang_ecard_php['error_not_image'], __FILE____LINE__);

copy($normal_pic_url'pictures/'.$CONFIG['normal_pfx'].$row['filename']);
// Gargabe collection
$handle=opendir('pictures');
while (
false!==($file readdir($handle))) {
   if (
$file != "." && $file != "..") { 
   $Diff = (time() - filectime("$path/$file"))/60/60/24;
   if ($Diff 1unlink("$path/$file");
   }
}
closedir($handle);

$dimension $CONFIG['picture_width'] + 200;

pageheader('Puzzle');
echo <<< EOT
<h1>Puzzle</h1>
EOT;
if (
$solved != 1) {
echo <<< EOT
<applet code="jigsaw.class" width="100%" height="{$dimension}">
<param name="imagename" value="
{$CONFIG['normal_pfx']}{$row['filename']}">
<param name="picturelist" value="
{$CONFIG['normal_pfx']}{$row['filename']}">
<param name="npieceshor" value="6">
<param name="npiecesver" value="4">
<param name="percent" value="50">
<param name="picture" value="
{$CONFIG['normal_pfx']}{$row['filename']}">
<param name="faded" value="no">
<param name="popup" value="no">
<param name="rotations" value="no">
<param name="resize" value="no">
<param name="optionswindow" value="no">
<param name="newpage" value="puzzle.php?solved=1&amp;album=
$album&amp;pid=$pid&amp;pos=$pos">
</applet>
EOT;
} else {
echo <<< EOT
Congratulaions! You have solved the puzzle.<br />
EOT;
}
echo <<< EOT
<a href="displayimage.php?album=$album$cat_link&amp;pid=$pid&amp;pos=$pos">Return to intermediate image view</a>
EOT;
pagefooter();


?>


As this is not related to plugins I have moved this thread accordingly.

gebe

This is great!! ;)

Works well.

Thank you for everything! Really thx!