Advanced search  

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]

Pages: [1]   Go Down

Author Topic: [Closed]: Jigsaw Puzzle  (Read 9949 times)

0 Members and 1 Guest are viewing this topic.

gebe

  • Coppermine newbie
  • Offline Offline
  • Posts: 9
[Closed]: Jigsaw Puzzle
« on: September 09, 2009, 09:56:11 pm »

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)
« Last Edit: September 10, 2009, 11:01:16 am by Joachim Müller »
Logged

Joachim Müller

  • Dev Team member
  • Coppermine addict
  • ****
  • Offline Offline
  • Gender: Male
  • Posts: 47843
  • aka "GauGau"
    • gaugau.de
Re: Jigsaw Puzzle
« Reply #1 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.
Logged

gebe

  • Coppermine newbie
  • Offline Offline
  • Posts: 9
Re: [Closed]: Jigsaw Puzzle
« Reply #2 on: September 10, 2009, 05:59:18 pm »

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?

Logged

gebe

  • Coppermine newbie
  • Offline Offline
  • Posts: 9
Re: Jigsaw Puzzle
« Reply #3 on: September 11, 2009, 08:01:12 pm »

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!
Logged

Joachim Müller

  • Dev Team member
  • Coppermine addict
  • ****
  • Offline Offline
  • Gender: Male
  • Posts: 47843
  • aka "GauGau"
    • gaugau.de
Re: [Closed]: Jigsaw Puzzle
« Reply #4 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.
« Last Edit: September 14, 2009, 04:01:15 pm by Joachim Müller »
Logged

gebe

  • Coppermine newbie
  • Offline Offline
  • Posts: 9
Re: [Closed]: Jigsaw Puzzle
« Reply #5 on: September 14, 2009, 05:00:38 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!
Logged

Joachim Müller

  • Dev Team member
  • Coppermine addict
  • ****
  • Offline Offline
  • Gender: Male
  • Posts: 47843
  • aka "GauGau"
    • gaugau.de
Re: [Closed]: Jigsaw Puzzle
« Reply #6 on: September 16, 2009, 12:36:08 pm »

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
Code: [Select]
$template_img_navbar =and
Code: [Select]
function 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
Code: [Select]
?>of the file themes/yourtheme/theme.php
Then find
Code: [Select]
                <td align="center" valign="middle" class="navmenu" width="100%">
                        {PIC_POS}
                </td>
and add after it into a new line
Code: [Select]
<td align="center" valign="middle" class="navmenu" width="100%">
                        <a href="{PUZZLE_TGT}">Puzzle</a>
                </td>
Next, find
Code: [Select]
        '{LOCATION}' => $location,and add after it (into a line of it's own)
Code: [Select]
'{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:
Code: [Select]
// 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:
Code: [Select]
<?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.
Logged

gebe

  • Coppermine newbie
  • Offline Offline
  • Posts: 9
Re: [Closed]: Jigsaw Puzzle
« Reply #7 on: September 16, 2009, 06:48:29 pm »

This is great!! ;)

Works well.

Thank you for everything! Really thx!
Logged
Pages: [1]   Go Up
 

Page created in 0.025 seconds with 20 queries.