$title = empty($_POST['title']) ? addslashes($node) : "{$title4save} {$filecount}"; if (is_readable($file_path) && in_array(strtolower($ext), $array_allowed_exts)) { $lid = $xoopsDB->genId($table_photos . "_lid_seq"); if (in_array(strtolower($ext), $gnavi_normal_exts)) { list($w, $h) = getimagesize($file_path); } else { list($w, $h) = array(0, 0); } $sql = "INSERT INTO {$table_photos} SET lid='{$lid}', cid='{$cid}', title='{$title}', ext='{$ext}', res_x='{$w}', res_y='{$h}', submitter='{$submitter}', status=1, date='{$date}'"; $xoopsDB->query($sql) or die("DB error: INSERT photos table."); if ($lid == 0) { $lid = $xoopsDB->getInsertId(); } print " <a href='../index.php?lid={$lid}' target='_blank'>{$file_path}</a>\n"; copy($file_path, "{$photos_dir}/{$lid}.{$ext}"); gnavi_create_thumb("{$photos_dir}/{$lid}.{$ext}", $lid, $ext); $xoopsDB->query("INSERT INTO {$table_text} SET lid='{$lid}', description='{$desc4save}'"); echo _MD_A_GNAVI_MB_FINISHED . "<br />\n"; $filecount++; } } closedir($dir_h); if ($filecount <= 1) { echo "<p>{$dir4edit} : " . _MD_A_GNAV_MES_BATCHNONE . "</p>"; } else { printf("<p>" . _MD_A_GNAV_MES_BATCHDONE . "</p>", $filecount - 1); } $result_str = ob_get_contents(); ob_end_clean(); } // Make form objects
function gnavi_exeResize($lid, $fileNo, $ext, $w, $h, $makethumbs) { global $photos_dir, $gnavi_normal_exts, $thumbs_dir, $gnavi_makethumb, $table_photos, $xoopsDB; global $gnavi_width, $gnavi_height; global $resize, $forceredo; $file = $fileNo ? $lid . "_" . $fileNo : $lid; $res_x = "res_x" . ($fileNo ? $fileNo : ''); $res_y = "res_y" . ($fileNo ? $fileNo : ''); if (!$ext) { printf(_MD_A_GNAVI_FMT_CHECKING, "{$file}"); echo _MD_A_GNAVI_MB_SKIPPED . "<br />\n"; return; } printf(_MD_A_GNAVI_FMT_CHECKING, "{$file}.{$ext}"); if (!is_readable("{$photos_dir}/{$file}.{$ext}")) { echo _MD_A_GNAVI_MB_PHOTONOTEXISTS . " "; echo _MD_A_GNAVI_MB_SKIPPED . "<br />\n"; return; } // Check if the file is normal image if (!in_array(strtolower($ext), $gnavi_normal_exts)) { echo _MD_A_GNAVI_MB_SKIPPED . "<br />\n"; return; } // Size of main photo list($true_w, $true_h) = getimagesize("{$photos_dir}/{$file}.{$ext}"); echo "{$true_w}x{$true_h} .. "; // Check and resize the main photo if necessary if ($resize && ($true_w > $gnavi_width || $true_h > $gnavi_height)) { $tmp_path = "{$photos_dir}/gnavi_tmp_photo"; @unlink($tmp_path); rename("{$photos_dir}/{$file}.{$ext}", $tmp_path); gnavi_modify_photo($tmp_path, "{$photos_dir}/{$file}.{$ext}"); @unlink($tmp_path); echo _MD_A_GNAVI_MB_PHOTORESIZED . " "; list($true_w, $true_h) = getimagesize("{$photos_dir}/{$file}.{$ext}"); } else { echo _MD_A_GNAVI_MB_SKIPPED . " "; } // Check and repair record of the photo if necessary if ($true_w != $w || $true_h != $h) { $xoopsDB->query("UPDATE {$table_photos} SET {$res_x}={$true_w}, {$res_y}={$true_h} WHERE lid={$lid}") or die("DB error: UPDATE photo table."); echo "-> {$true_w}x{$true_h} " . _MD_A_GNAVI_MB_SIZEREPAIRED . " "; } if ($makethumbs) { // Create Thumbs if (is_readable("{$thumbs_dir}/{$file}.{$ext}")) { list($thumb_w, $thumb_h) = getimagesize("{$thumbs_dir}/{$file}.{$ext}"); echo "{$thumb_w}x{$thumb_h} ... "; if ($forceredo) { $retcode = gnavi_create_thumb("{$photos_dir}/{$file}.{$ext}", $file, $ext); } else { $retcode = 3; } } else { if ($gnavi_makethumb) { $retcode = gnavi_create_thumb("{$photos_dir}/{$file}.{$ext}", $file, $ext); } else { $retcode = 3; } } switch ($retcode) { case 0: echo _MD_A_GNAVI_MB_FAILEDREADING; break; case 1: echo _MD_A_GNAVI_MB_CREATEDTHUMBS; break; case 2: echo _MD_A_GNAVI_MB_BIGTHUMBS; break; case 3: echo _MD_A_GNAVI_MB_SKIPPED; break; } } echo "<br />\n"; return; }
if ($ext1) { gnavi_modify_photo("{$photos_dir}/{$tmp_name1}", $photos_dir . "/" . $lid . "_1." . $ext1); if (in_array(strtolower($ext1), $gnavi_normal_exts)) { if (!gnavi_create_thumb($photos_dir . "/" . $lid . "_1." . $ext1, $lid . "_1", $ext1)) { $xoopsDB->query("DELETE FROM {$table_photos} WHERE lid={$lid}"); redirect_header('index.php?page=submit' . ($lid ? '&lid=' . $lid : ''), 2, _MD_GNAV_MSG_FILEREADERROR); exit; } } } else { $ext1 = $p_ext1; } if ($ext2) { gnavi_modify_photo("{$photos_dir}/{$tmp_name2}", $photos_dir . "/" . $lid . "_2." . $ext2); if (in_array(strtolower($ext2), $gnavi_normal_exts)) { if (!gnavi_create_thumb($photos_dir . "/" . $lid . "_2." . $ext2, $lid . "_2", $ext2)) { $xoopsDB->query("DELETE FROM {$table_photos} WHERE lid={$lid}"); redirect_header('index.php?page=submit' . ($lid ? '&lid=' . $lid : ''), 2, _MD_GNAV_MSG_FILEREADERROR); exit; } } } else { $ext2 = $p_ext2; } //get size $resx = 0; $resx1 = 0; $resx2 = 0; $resy = 0; $resy1 = 0; $resy2 = 0;