<?php @include ('../../mainfile.php'); @include $GLOBALS['xoops']->path('/Frameworks/wideimage/WideImage.php'); $GLOBALS['xoopsLogger']->activated = false; $dir = XOOPS_VAR_PATH."/images/erotica/"; $watermarkdir = XOOPS_VAR_PATH."/images/watermarks/erotica/"; $image = array(); if (is_dir($dir)) { if ($dh = opendir($dir)) { while (($file = readdir($dh)) !== false) { if (strpos(strtolower($file),".jpg")>0||strpos(strtolower($file),".gif")>0||strpos(strtolower($file),".png")>0) { $image[] = $file; } } closedir($dh); } } $watermarks = array(); if (is_dir($watermarkdir)) { if ($dh = opendir($watermarkdir)) { while (($file = readdir($dh)) !== false) { if (strpos(strtolower($file),".jpg")>0||strpos(strtolower($file),".gif")>0||strpos(strtolower($file),".png")>0) { $watermarks[] = $file; } } closedir($dh); } } if (sizeof($image)>0) { srand((((float)('0' . substr(microtime(), strpos(microtime(), ' ') + 1, strlen(microtime()) - strpos(microtime(), ' ') + 1))) * mt_rand(30, 99999))); srand((((float)('0' . substr(microtime(), strpos(microtime(), ' ') + 1, strlen(microtime()) - strpos(microtime(), ' ') + 1))) * mt_rand(30, 99999))); if (sizeof($watermarks)>0) { $which = mt_rand(0,sizeof($image)-1); $water = mt_rand(0,sizeof($watermarks)-1); error_reporting(E_ALL); $img = WideImage::load($dir.$image[$which]); $watermark = WideImage::load($watermarkdir.$watermarks[$water]); $wwidth = $watermark->getWidth(); $wheight = $watermark->getHeight(); if (isset($_GET['resize'])) { $resizeimg = $img->resize(intval($_GET['resize']).'%'); $resizeimg->output("JPG"); } elseif (isset($_GET['width'])&&isset($_GET['height'])) { $width = $img->getWidth(); $height = $img->getHeight(); if ($width>$height) { $resizeimg = $img->resize(NULL,intval($_GET['height']),'inside', 'down')->crop("center", "middle", intval($_GET['width']), intval($_GET['height'])); $imgb = $resizeimg->merge($watermark, sprintf("right - %s", $wwidth*(1/5)), sprintf("bottom - %s", $wheight*(1/5)), 75); } else { if ($width>intval($_GET['width'])&&$height>intval($_GET['height'])) { $resizeimg = $img->resize(intval($_GET['width']),intval($_GET['height']),'inside', 'down'); $imgb = $resizeimg->merge($watermark, sprintf("left + %s", mt_rand(5,25)), sprintf("top + %s", mt_rand(9,35)), 75); } else { $resizeimg = $img->resize(intval($_GET['width']),intval($_GET['height']),'inside', 'up'); $imgb = $resizeimg->merge($watermark, sprintf("left + %s", mt_rand(5,25)), sprintf("top + %s", mt_rand(9,35)), 75); } } $imgb->output("JPG"); exit(0); } elseif (isset($_GET['width'])) { $width = $img->getWidth(); $height = $img->getHeight(); if ($width>$height) { $resizeimg = $img->resize(NULL,$height* (intval($_GET['width'])/$width),'inside', 'down')->crop("center", "middle", intval($_GET['width']), intval($_GET['height'])); $imgb = $resizeimg->merge($watermark, sprintf("right - %s", $wwidth*(1/5)), sprintf("bottom - %s", $wheight*(1/5)), 75); } else { if ($width>intval($_GET['width'])) { $resizeimg = $img->resize(intval($_GET['width']),NULL,'inside', 'down'); $imgb = $resizeimg->merge($watermark, sprintf("left - %s", mt_rand(5,25)), sprintf("top + %s", mt_rand(9,35)), 75); } else { $resizeimg = $img->resize(intval($_GET['width']),NULL,'inside', 'up'); $imgb = $resizeimg->merge($watermark, sprintf("left + %s", mt_rand(5,25)), sprintf("top + %s", mt_rand(9,35)), 75); } } $imgb->output("JPG"); exit(0); } elseif (isset($_GET['height'])) { $width = $img->getWidth(); $height = $img->getHeight(); if ($width>$height) { $resizeimg = $img->resize($width* (intval($_GET['height'])/$height),NULL,'inside', 'down')->crop("center", "middle", intval($_GET['width']), intval($_GET['height'])); $imgb = $resizeimg->merge($watermark, sprintf("right - %s", $wwidth*(1/5)), sprintf("bottom - %s", $wheight*(1/5)), 75); } else { if ($height>intval($_GET['height'])) { $resizeimg = $img->resize(NULL,intval($_GET['height']),'inside', 'down'); $imgb = $resizeimg->merge($watermark, sprintf("left + %s", mt_rand(5,25)), sprintf("top + %s", mt_rand(9,35)), 75); } else { $resizeimg = $img->resize(NULL,intval($_GET['height']),'inside', 'up'); $imgb = $resizeimg->merge($watermark, sprintf("left + %s", mt_rand(5,25)), sprintf("top + %s", mt_rand(9,35)), 75); } } $imgb->output("JPG"); exit(0); } $img->output("JPG"); } else { $which = mt_rand(0,sizeof($image)); $img = WideImage::load($dir.$image[$which]); if (isset($_GET['resize'])) { $resizeimg = $img->resize(intval($_GET['resize']).'%'); $resizeimg->output("JPG"); } elseif (isset($_GET['width'])&&isset($_GET['height'])) { $width = $img->getWidth(); $height = $img->getHeight(); if ($width>$height) { $resizeimg = $img->resize(NULL,intval($_GET['height']),'inside', 'down')->crop("center", "middle", intval($_GET['width']), intval($_GET['height'])); } else { if ($width>intval($_GET['width'])&&$height>intval($_GET['height'])) { $resizeimg = $img->resize(intval($_GET['width']),intval($_GET['height']),'inside', 'down'); } else { $resizeimg = $img->resize(intval($_GET['width']),intval($_GET['height']),'inside', 'up'); } } $resizeimg->output("JPG"); exit(0); } elseif (isset($_GET['width'])) { $width = $img->getWidth(); $height = $img->getHeight(); if ($width>$height) { $resizeimg = $img->resize(NULL,$height* (intval($_GET['width'])/$width),'inside', 'down')->crop("center", "middle", intval($_GET['width']), intval($_GET['height'])); } else { if ($width>intval($_GET['width'])) { $resizeimg = $img->resize(intval($_GET['width']),NULL,'inside', 'down'); } else { $resizeimg = $img->resize(intval($_GET['width']),NULL,'inside', 'up'); } } $resizeimg->output("JPG"); exit(0); } elseif (isset($_GET['height'])) { $width = $img->getWidth(); $height = $img->getHeight(); if ($width>$height) { $resizeimg = $img->resize($width* (intval($_GET['height'])/$height),NULL,'inside', 'down')->crop("center", "middle", intval($_GET['width']), intval($_GET['height'])); } else { if ($height>intval($_GET['height'])) { $resizeimg = $img->resize(NULL,intval($_GET['height']),'inside', 'down'); } else { $resizeimg = $img->resize(NULL,intval($_GET['height']),'inside', 'up'); } } $resizeimg->output("JPG"); exit(0); } $img->output("JPG"); } exit(0); } ?>