Example #1
0
/**
 * Generic comment adding routine. Called by album objects or image objects
 * to add comments.
 *
 * Returns a code for the success of the comment add:
 *    0: Bad entry
 *    1: Marked for moderation
 *    2: Successfully posted
 *
 * @param string $name Comment author name
 * @param string $email Comment author email
 * @param string $website Comment author website
 * @param string $comment body of the comment
 * @param string $code Captcha code entered
 * @param string $code_ok Captcha md5 expected
 * @param string $type 'albums' if it is an album or 'images' if it is an image comment
 * @param object $receiver the object (image or album) to which to post the comment
 * @param string $ip the IP address of the comment poster
 * @param bool $private set to true if the comment is for the admin only
 * @param bool $anon set to true if the poster wishes to remain anonymous
 * @return int
 */
function postComment($name, $email, $website, $comment, $code, $code_ok, $receiver, $ip, $private, $anon)
{
    global $_zp_captcha;
    $result = commentObjectClass($receiver);
    list($type, $class) = $result;
    $receiver->getComments();
    $name = trim($name);
    $email = trim($email);
    $website = trim($website);
    $admins = getAdministrators();
    $admin = array_shift($admins);
    $key = $admin['pass'];
    // Let the comment have trailing line breaks and space? Nah...
    // Also (in)validate HTML here, and in $name.
    $comment = trim($comment);
    if (getOption('comment_email_required') && (empty($email) || !is_valid_email_zp($email))) {
        return -2;
    }
    if (getOption('comment_name_required') && empty($name)) {
        return -3;
    }
    if (getOption('comment_web_required') && (empty($website) || !isValidURL($website))) {
        return -4;
    }
    if (getOption('Use_Captcha')) {
        if (!$_zp_captcha->checkCaptcha($code, $code_ok)) {
            return -5;
        }
    }
    if (empty($comment)) {
        return -6;
    }
    if (!empty($website) && substr($website, 0, 7) != "http://") {
        $website = "http://" . $website;
    }
    $goodMessage = 2;
    $gallery = new gallery();
    if (!(false === ($requirePath = getPlugin('spamfilters/' . UTF8ToFileSystem(getOption('spam_filter')) . ".php", false)))) {
        require_once $requirePath;
        $spamfilter = new SpamFilter();
        $goodMessage = $spamfilter->filterMessage($name, $email, $website, $comment, isImageClass($receiver) ? $receiver->getFullImage() : NULL, $ip);
    }
    if ($goodMessage) {
        if ($goodMessage == 1) {
            $moderate = 1;
        } else {
            $moderate = 0;
        }
        if ($private) {
            $private = 1;
        } else {
            $private = 0;
        }
        if ($anon) {
            $anon = 1;
        } else {
            $anon = 0;
        }
        $receiverid = $receiver->id;
        // Update the database entry with the new comment
        query("INSERT INTO " . prefix("comments") . " (`ownerid`, `name`, `email`, `website`, `comment`, `inmoderation`, `date`, `type`, `ip`, `private`, `anon`) VALUES " . ' ("' . $receiverid . '", "' . mysql_real_escape_string($name) . '", "' . mysql_real_escape_string($email) . '", "' . mysql_real_escape_string($website) . '", "' . mysql_real_escape_string($comment) . '", "' . $moderate . '", NOW()' . ', "' . $type . '", "' . $ip . '", "' . $private . '", "' . $anon . '")');
        if ($moderate) {
            $action = "placed in moderation";
        } else {
            //  add to comments array and notify the admin user
            $newcomment = array();
            $newcomment['name'] = $name;
            $newcomment['email'] = $email;
            $newcomment['website'] = $website;
            $newcomment['comment'] = $comment;
            $newcomment['date'] = time();
            $receiver->comments[] = $newcomment;
            $action = "posted";
        }
        // switch added for zenpage support
        $class = get_class($receiver);
        switch ($class) {
            case "Albums":
                $on = $receiver->name;
                $url = "album=" . urlencode($receiver->name);
                $ur_album = getUrAlbum($receiver);
                break;
            case "ZenpageNews":
                $on = $receiver->getTitlelink();
                $url = "p=" . ZENPAGE_NEWS . "&title=" . urlencode($receiver->getTitlelink());
                break;
            case "ZenpagePage":
                $on = $receiver->getTitlelink();
                $url = "p=" . ZENPAGE_PAGES . "&title=" . urlencode($receiver->getTitlelink());
                break;
            default:
                // all image types
                $on = $receiver->getAlbumName() . " about " . $receiver->getTitle();
                $url = "album=" . urlencode($receiver->album->name) . "&image=" . urlencode($receiver->filename);
                $album = $receiver->getAlbum();
                $ur_album = getUrAlbum($album);
                break;
        }
        if (getOption('email_new_comments')) {
            $last_comment = fetchComments(1);
            $last_comment = $last_comment[0]['id'];
            $message = gettext("A comment has been {$action} in your album") . " {$on}\n" . "\n" . "Author: " . $name . "\n" . "Email: " . $email . "\n" . "Website: " . $website . "\n" . "Comment:\n" . $comment . "\n" . "\n" . "You can view all comments about this image here:\n" . "http://" . $_SERVER['SERVER_NAME'] . WEBPATH . "/index.php?{$url}\n" . "\n" . "You can edit the comment here:\n" . "http://" . $_SERVER['SERVER_NAME'] . WEBPATH . "/" . ZENFOLDER . "/admin-comments.php?page=editcomment&id={$last_comment}\n";
            $emails = array();
            $admin_users = getAdministrators();
            foreach ($admin_users as $admin) {
                // mail anyone else with full rights
                if ($admin['rights'] & ADMIN_RIGHTS && $admin['rights'] & COMMENT_RIGHTS && !empty($admin['email'])) {
                    $emails[] = $admin['email'];
                    unset($admin_users[$admin['id']]);
                }
            }
            // take out for zenpage comments since there are no album admins
            if ($type === "images" or $type === "albums") {
                $id = $ur_album->getAlbumID();
                $sql = "SELECT `adminid` FROM " . prefix('admintoalbum') . " WHERE `albumid`={$id}";
                $result = query_full_array($sql);
                foreach ($result as $anadmin) {
                    $admin = $admin_users[$anadmin['adminid']];
                    if (!empty($admin['email'])) {
                        $emails[] = $admin['email'];
                    }
                }
            }
            zp_mail("[" . get_language_string(getOption('gallery_title'), getOption('locale')) . "] Comment posted on {$on}", $message, "", $emails);
        }
    }
    return $goodMessage;
}
/**
 * Creates the cache folder version of the image, including watermarking
 *
 * @param string $newfilename the name of the file when it is in the cache
 * @param string $imgfile the image name
 * @param array $args the cropping arguments
 * @param bool $allow_watermark set to true if image may be watermarked
 * @param bool $force_cache set to true to force the image into the cache folders
 * @param string $theme the current theme
 */
function cacheImage($newfilename, $imgfile, $args, $allow_watermark = false, $force_cache = false, $theme)
{
    @(list($size, $width, $height, $cw, $ch, $cx, $cy, $quality, $thumb, $crop, $thumbstandin, $thumbWM, $adminrequest) = $args);
    // Set the config variables for convenience.
    $image_use_side = getOption('image_use_side');
    $upscale = getOption('image_allow_upscale');
    $allowscale = true;
    $sharpenthumbs = getOption('thumb_sharpen');
    $sharpenimages = getOption('image_sharpen');
    $newfile = SERVERCACHE . $newfilename;
    if (DEBUG_IMAGE) {
        debugLog("cacheImage(\$imgfile=" . basename($imgfile) . ", \$newfilename={$newfilename}, \$allow_watermark={$allow_watermark}, \$force_cache={$force_cache}, \$theme={$theme}) \$size={$size}, \$width={$width}, \$height={$height}, \$cw={$cw}, \$ch={$ch}, \$cx={$cx}, \$cy={$cy}, \$quality={$quality}, \$thumb={$thumb}, \$crop={$crop} \$image_use_side={$image_use_side}; \$upscale={$upscale};");
    }
    // Check for GD
    if (!function_exists('imagecreatetruecolor')) {
        imageError(gettext('The GD Library is not installed or not available.'), 'err-nogd.gif');
    }
    // Check for the source image.
    if (!file_exists($imgfile) || !is_readable($imgfile)) {
        imageError(gettext('Image not found or is unreadable.'), 'err-imagenotfound.gif');
    }
    $rotate = false;
    if (function_exists('imagerotate') && getOption('auto_rotate')) {
        $rotate = getImageRotation($imgfile);
    }
    if ($im = get_image($imgfile)) {
        if ($rotate) {
            $newim_rot = imagerotate($im, $rotate, 0);
            imagedestroy($im);
            $im = $newim_rot;
        }
        $w = imagesx($im);
        $h = imagesy($im);
        // Give the sizing dimension to $dim
        $ratio_in = '';
        $ratio_out = '';
        $crop = $crop || $cw != 0 || $ch != 0;
        if (!empty($size)) {
            $dim = $size;
            $width = $height = false;
            if ($crop) {
                $dim = $size;
                if (!$ch) {
                    $ch = $size;
                }
                if (!$cw) {
                    $cw = $size;
                }
            }
        } else {
            if (!empty($width) && !empty($height)) {
                $ratio_in = $h / $w;
                $ratio_out = $height / $width;
                if ($ratio_in > $ratio_out) {
                    // image is taller than desired, $height is the determining factor
                    $thumb = true;
                    $dim = $width;
                    if (!$ch) {
                        $ch = $height;
                    }
                } else {
                    // image is wider than desired, $width is the determining factor
                    $dim = $height;
                    if (!$cw) {
                        $cw = $width;
                    }
                }
            } else {
                if (!empty($width)) {
                    $dim = $width;
                    $size = $height = false;
                } else {
                    if (!empty($height)) {
                        $dim = $height;
                        $size = $width = false;
                    } else {
                        // There's a problem up there somewhere...
                        imageError(gettext("Unknown error! Please report to the developers at <a href=\"http://www.zenphoto.org/\">www.zenphoto.org</a>"), 'err-imagegeneral.gif');
                    }
                }
            }
        }
        $sizes = propSizes($size, $width, $height, $w, $h, $thumb, $image_use_side, $dim);
        list($neww, $newh) = $sizes;
        if (DEBUG_IMAGE) {
            debugLog("cacheImage:" . basename($imgfile) . ": \$size={$size}, \$width={$width}, \$height={$height}, \$w={$w}; \$h={$h}; \$cw={$cw}, \$ch={$ch}, \$cx={$cx}, \$cy={$cy}, \$quality={$quality}, \$thumb={$thumb}, \$crop={$crop}, \$newh={$newh}, \$neww={$neww}, \$dim={$dim}, \$ratio_in={$ratio_in}, \$ratio_out={$ratio_out} \$upscale={$upscale} \$rotate={$rotate} \$force_cache={$force_cache}");
        }
        if (!$upscale && $newh >= $h && $neww >= $w) {
            // image is the same size or smaller than the request
            if (!getOption('watermark_image') && !($crop || $thumb || $rotate || $force_cache)) {
                // no processing needed
                if (DEBUG_IMAGE) {
                    debugLog("Serve " . basename($imgfile) . " from original image.");
                }
                if (getOption('album_folder_class') != 'external') {
                    // local album system, return the image directly
                    $image = substr(strrchr($imgfile, '/'), 1);
                    $album = substr($imgfile, strlen(getAlbumFolder()));
                    $album = substr($album, 0, strlen($album) - strlen($image) - 1);
                    header("Location: " . getAlbumFolder(FULLWEBPATH) . pathurlencode($album) . "/" . rawurlencode($image));
                    exit;
                } else {
                    // the web server does not have access to the image, have to supply it
                    $suffix = strtolower(substr(strrchr($filename, "."), 1));
                    $fp = fopen($imgfile, 'rb');
                    // send the right headers
                    header("Content-Type: image/{$suffix}");
                    header("Content-Length: " . filesize($imgfile));
                    // dump the picture and stop the script
                    fpassthru($fp);
                    fclose($fp);
                    exit;
                }
            }
            $neww = $w;
            $newh = $h;
            $allowscale = false;
            if ($crop) {
                if ($width > $neww) {
                    $width = $neww;
                }
                if ($height > $newh) {
                    $height = $newh;
                }
            }
            if (DEBUG_IMAGE) {
                debugLog("cacheImage:no upscale " . basename($imgfile) . ":  \$newh={$newh}, \$neww={$neww}");
            }
        }
        // Crop the image if requested.
        if ($crop) {
            if ($cw > $ch) {
                $ir = $ch / $cw;
            } else {
                $ir = $cw / $ch;
            }
            if ($size) {
                $ts = $size;
                $neww = $size;
                $newh = $ir * $size;
            } else {
                $neww = $width;
                $newh = $height;
                if ($neww > $newh) {
                    $ts = $neww;
                    if ($newh === false) {
                        $newh = $ir * $neww;
                    }
                } else {
                    $ts = $newh;
                    if ($neww === false) {
                        $neww = $ir * $newh;
                    }
                }
            }
            $cr = min($w, $h) / $ts;
            if (!$cx) {
                if (!$cw) {
                    $cw = $w;
                } else {
                    $cw = round($cw * $cr);
                }
                $cx = round(($w - $cw) / 2);
            } else {
                // custom crop
                if (!$cw || $cw > $w) {
                    $cw = $w;
                }
            }
            if (!$cy) {
                if (!$ch) {
                    $ch = $h;
                } else {
                    $ch = round($ch * $cr);
                }
                $cy = round(($h - $ch) / 2);
            } else {
                // custom crop
                if (!$ch || $ch > $h) {
                    $ch = $h;
                }
            }
            if ($cw + $cx > $w) {
                $cx = $w - $cw;
            }
            if ($cx < 0) {
                $cw = $cw + $cx;
                $cx = 0;
            }
            if ($ch + $cy > $h) {
                $cy = $h - $ch;
            }
            if ($cy < 0) {
                $ch = $ch + $cy;
                $cy = 0;
            }
            if (DEBUG_IMAGE) {
                debugLog("cacheImage:crop " . basename($imgfile) . ":\$size={$size}, \$width={$width}, \$height={$height}, \$cw={$cw}, \$ch={$ch}, \$cx={$cx}, \$cy={$cy}, \$quality={$quality}, \$thumb={$thumb}, \$crop={$crop}, \$rotate={$rotate}");
            }
            $newim = imagecreatetruecolor($neww, $newh);
            imagecopyresampled($newim, $im, 0, 0, $cx, $cy, $neww, $newh, $cw, $ch);
        } else {
            if ($allowscale) {
                $sizes = propSizes($size, $width, $height, $w, $h, $thumb, $image_use_side, $dim);
                list($neww, $newh) = $sizes;
            }
            if (DEBUG_IMAGE) {
                debugLog("cacheImage:no crop " . basename($imgfile) . ":\$size={$size}, \$width={$width}, \$height={$height}, \$dim={$dim}, \$neww={$neww}; \$newh={$newh}; \$quality={$quality}, \$thumb={$thumb}, \$crop={$crop}, \$rotate={$rotate}; \$allowscale={$allowscale};");
            }
            $newim = imagecreatetruecolor($neww, $newh);
            imagecopyresampled($newim, $im, 0, 0, 0, 0, $neww, $newh, $w, $h);
        }
        if ($thumb && $sharpenthumbs || !$thumb && $sharpenimages) {
            unsharp_mask($newim, getOption('sharpen_amount'), getOption('sharpen_radius'), getOption('sharpen_threshold'));
        }
        $watermark_image = false;
        if ($thumbWM) {
            if ($thumb || !$allow_watermark) {
                $watermark_image = SERVERPATH . '/' . ZENFOLDER . '/watermarks/' . UTF8ToFileSystem($thumbWM) . '.png';
                if (!file_exists($watermark_image)) {
                    $watermark_image = SERVERPATH . '/' . ZENFOLDER . '/images/imageDefault.png';
                }
            }
        } else {
            if ($allow_watermark) {
                $watermark_image = getOption('fullimage_watermark');
                if ($watermark_image) {
                    $watermark_image = SERVERPATH . '/' . ZENFOLDER . '/watermarks/' . UTF8ToFileSystem($watermark_image) . '.png';
                    if (!file_exists($watermark_image)) {
                        $watermark_image = SERVERPATH . '/' . ZENFOLDER . '/images/imageDefault.png';
                    }
                }
            }
        }
        if ($watermark_image) {
            $offset_h = getOption('watermark_h_offset') / 100;
            $offset_w = getOption('watermark_w_offset') / 100;
            $watermark = imagecreatefrompng($watermark_image);
            $watermark_width = imagesx($watermark);
            $watermark_height = imagesy($watermark);
            $imw = imagesx($newim);
            $imh = imagesy($newim);
            $percent = getOption('watermark_scale') / 100;
            $r = sqrt($imw * $imh * $percent / ($watermark_width * $watermark_height));
            if (!getOption('watermark_allow_upscale')) {
                $r = min(1, $r);
            }
            $nw = round($watermark_width * $r);
            $nh = round($watermark_height * $r);
            if ($nw != $watermark_width || $nh != $watermark_height) {
                $watermark = imageResizeAlpha($watermark, $nw, $nh);
            }
            // Position Overlay in Bottom Right
            $dest_x = max(0, floor(($imw - $nw) * $offset_w));
            $dest_y = max(0, floor(($imh - $nh) * $offset_h));
            if (DEBUG_IMAGE) {
                debugLog("Watermark:" . basename($imgfile) . ": \$offset_h={$offset_h}, \$offset_w={$offset_w}, \$watermark_height={$watermark_height}, \$watermark_width={$watermark_width}, \$imw={$imw}, \$imh={$imh}, \$percent={$percent}, \$r={$r}, \$nw={$nw}, \$nh={$nh}, \$dest_x={$dest_x}, \$dest_y={$dest_y}");
            }
            imagecopy($newim, $watermark, $dest_x, $dest_y, 0, 0, $nw, $nh);
            imagedestroy($watermark);
        }
        // Create the cached file (with lots of compatibility)...
        mkdir_recursive(dirname($newfile));
        if (imagejpeg($newim, $newfile, $quality)) {
            if (DEBUG_IMAGE) {
                debugLog('Finished:' . basename($imgfile));
            }
        } else {
            if (DEBUG_IMAGE) {
                debugLog('cacheImage: failed to create ' . $newfile);
            }
        }
        @chmod($newfile, 0666 & CHMOD_VALUE);
        imagedestroy($newim);
        imagedestroy($im);
    }
}
Example #3
0
    case 'wbmp':
        $newim = imagecreatefromwbmp($image_path);
        break;
    case 'jpeg':
        $newim = imagecreatefromjpeg($image_path);
        break;
    case 'gif':
        $newim = imagecreatefromgif($image_path);
        break;
}
if (getOption('protect_full_image') == 'Download') {
    header('Content-Disposition: attachment; filename="' . $_zp_current_image->filename . '"');
    // enable this to make the image a download
}
if (getOption('watermark_image')) {
    $watermark_path = SERVERPATH . "/" . ZENFOLDER . "/" . UTF8ToFileSystem(getOption('watermark_image'));
    $offset_h = getOption('watermark_h_offset') / 100;
    $offset_w = getOption('watermark_w_offset') / 100;
    $watermark = imagecreatefrompng($watermark_path);
    $watermark_width = imagesx($watermark);
    $watermark_height = imagesy($watermark);
    $imw = imagesx($newim);
    $imh = imagesy($newim);
    $percent = getOption('watermark_scale') / 100;
    $r = sqrt($imw * $imh * $percent / ($watermark_width * $watermark_height));
    if (!getOption('watermark_allow_upscale')) {
        $r = min(1, $r);
    }
    $nw = round($watermark_width * $r);
    $nh = round($watermark_height * $r);
    if ($nw != $watermark_width || $nh != $watermark_height) {
/**
 * Finds the name of the themeColor option selected on the admin options tab
 * Returns a path and name of the theme css file. Returns the value passed for defaultcolor if the
 * theme css option file does not exist.
 *
 * @param string &$zenCSS path to the css file
 * @param string &$themeColor name of the css file
 * @param string $defaultColor name of the default css file
 * @return string
 * @since 1.1
 */
function getTheme(&$zenCSS, &$themeColor, $defaultColor)
{
    global $_zp_themeroot;
    $themeColor = getOption('Theme_colors');
    $zenCSS = $_zp_themeroot . '/styles/' . $themeColor . '.css';
    $unzenCSS = str_replace(WEBPATH, '', $zenCSS);
    if (!file_exists(SERVERPATH . UTF8ToFileSystem($unzenCSS))) {
        $zenCSS = $_zp_themeroot . "/styles/" . $defaultColor . ".css";
        return $themeColor == '';
    } else {
        return true;
    }
}
/**
 * processes the post from the above
 *@param int param1 the index of the entry in mass edit or 0 if single album
 *@param object param2 the album object
 *@return string error flag if passwords don't match
 *@since 1.1.3
 */
function processAlbumEdit($index, $album)
{
    if ($index == 0) {
        $prefix = '';
    } else {
        $prefix = "{$index}-";
    }
    $tagsprefix = 'tags_' . $prefix;
    $notify = '';
    $album->setTitle(process_language_string_save($prefix . 'albumtitle', 2));
    $album->setDesc(process_language_string_save($prefix . 'albumdesc', 1));
    $tags = array();
    for ($i = 0; $i < 4; $i++) {
        if (isset($_POST[$tagsprefix . 'new_tag_value_' . $i])) {
            $tag = trim(strip($_POST[$tagsprefix . 'new_tag_value_' . $i]));
            unset($_POST[$tagsprefix . 'new_tag_value_' . $i]);
            if (!empty($tag)) {
                $tags[] = $tag;
            }
        }
    }
    $l = strlen($tagsprefix);
    foreach ($_POST as $key => $value) {
        $key = postIndexDecode($key);
        if (substr($key, 0, $l) == $tagsprefix) {
            if ($value) {
                $tags[] = substr($key, $l);
            }
        }
    }
    $tags = array_unique($tags);
    $album->setTags($tags);
    $album->setDateTime(strip($_POST[$prefix . "albumdate"]));
    $album->setPlace(process_language_string_save($prefix . 'albumplace', 3));
    if (isset($_POST[$prefix . 'thumb'])) {
        $album->setAlbumThumb(strip($_POST[$prefix . 'thumb']));
    }
    $album->setShow(isset($_POST[$prefix . 'Published']));
    $album->setCommentsAllowed(isset($_POST[$prefix . 'allowcomments']));
    $sorttype = strtolower(sanitize($_POST[$prefix . 'sortby'], 3));
    if ($sorttype == 'custom') {
        $sorttype = strtolower(sanitize($_POST[$prefix . 'customimagesort'], 3));
    }
    $album->setSortType($sorttype);
    if ($sorttype == 'manual') {
        $album->setSortDirection('image', 0);
    } else {
        if (empty($sorttype)) {
            $direction = 0;
        } else {
            $direction = isset($_POST[$prefix . 'image_sortdirection']);
        }
        $album->setSortDirection('image', $direction);
    }
    $sorttype = strtolower(sanitize($_POST[$prefix . 'subalbumsortby'], 3));
    if ($sorttype == 'custom') {
        $sorttype = strtolower(sanitize($_POST[$prefix . 'customalbumsort'], 3));
    }
    $album->setSubalbumSortType($sorttype);
    if ($sorttype == 'manual') {
        $album->setSortDirection('album', 0);
    } else {
        $album->setSortDirection('album', isset($_POST[$prefix . 'album_sortdirection']));
    }
    if (isset($_POST[$prefix . 'reset_hitcounter'])) {
        $album->set('hitcounter', 0);
    }
    if (isset($_POST[$prefix . 'reset_rating'])) {
        $album->set('total_value', 0);
        $album->set('total_votes', 0);
        $album->set('used_ips', 0);
    }
    $olduser = $album->getUser();
    $newuser = $_POST[$prefix . 'albumuser'];
    $pwd = trim($_POST[$prefix . 'albumpass']);
    $fail = '';
    if ($olduser != $newuser) {
        if ($pwd != $_POST[$prefix . 'albumpass_2']) {
            $pwd2 = trim($_POST[$prefix . 'albumpass_2']);
            $_POST[$prefix . 'albumpass'] = $pwd;
            // invalidate password, user changed without password beign set
            if (!empty($newuser) && empty($pwd) && empty($pwd2)) {
                $fail = '&mismatch=user';
            }
        }
    }
    if ($_POST[$prefix . 'albumpass'] == $_POST[$prefix . 'albumpass_2']) {
        $album->setUser($newuser);
        if (empty($pwd)) {
            if (empty($_POST[$prefix . 'albumpass'])) {
                $album->setPassword(NULL);
                // clear the gallery password
            }
        } else {
            $album->setPassword($pwd);
        }
    } else {
        if (empty($fail)) {
            $notify = '&mismatch=album';
        } else {
            $notify = $fail;
        }
    }
    $oldtheme = $album->getAlbumTheme();
    if (isset($_POST[$prefix . 'album_theme'])) {
        $newtheme = strip($_POST[$prefix . 'album_theme']);
        if ($oldtheme != $newtheme) {
            $album->setAlbumTheme($newtheme);
        }
    }
    $album->setPasswordHint(process_language_string_save($prefix . 'albumpass_hint', 3));
    $album->setCustomData(process_language_string_save($prefix . 'album_custom_data', 1));
    $album->save();
    // Move/Copy/Rename the album after saving.
    $movecopyrename_action = '';
    if (isset($_POST['a-' . $prefix . 'MoveCopyRename'])) {
        $movecopyrename_action = sanitize($_POST['a-' . $prefix . 'MoveCopyRename'], 3);
    }
    if ($movecopyrename_action == 'move') {
        $dest = UTF8ToFileSystem(sanitize_path($_POST['a' . $prefix . '-albumselect'], 3));
        // Append the album name.
        $dest = ($dest ? $dest . '/' : '') . (strpos($album->name, '/') === FALSE ? $album->name : basename($album->name));
        if ($dest && $dest != $album->name) {
            if ($returnalbum = $album->moveAlbum($dest)) {
                // A slight hack to redirect to the new album after moving.
                $_GET['album'] = $returnalbum;
            } else {
                $notify .= "&mcrerr=1";
            }
        } else {
            // Cannot move album to same album.
        }
    } else {
        if ($movecopyrename_action == 'copy') {
            $dest = UTF8ToFileSystem(sanitize_path($_POST['a' . $prefix . '-albumselect'], 3));
            // Append the album name.
            $dest = ($dest ? $dest . '/' : '') . (strpos($album->name, '/') === FALSE ? $album->name : basename($album->name));
            if ($dest && $dest != $album->name) {
                if (!$album->copyAlbum($dest)) {
                    $notify .= "&mcrerr=1";
                }
            } else {
                // Cannot copy album to existing album.
                // Or, copy with rename?
            }
        } else {
            if ($movecopyrename_action == 'rename') {
                $renameto = UTF8ToFileSystem(sanitize_path($_POST['a' . $prefix . '-renameto'], 3));
                $renameto = str_replace(array('/', '\\'), '', $renameto);
                if (dirname($album->name) != '.') {
                    $renameto = dirname($album->name) . '/' . $renameto;
                }
                if ($renameto != $album->name) {
                    if ($returnalbum = $album->renameAlbum($renameto)) {
                        // A slight hack to redirect to the new album after moving.
                        $_GET['album'] = $returnalbum;
                    } else {
                        $notify .= "&mcrerr=1";
                    }
                }
            }
        }
    }
    return $notify;
}
Example #6
0
 */
// force UTF-8 Ø
define('OFFSET_PATH', 1);
require_once dirname(__FILE__) . '/functions-basic.php';
require_once dirname(__FILE__) . '/functions-image.php';
$debug = isset($_GET['debug']);
// Check for minimum parameters.
if (!isset($_GET['a']) || !isset($_GET['i'])) {
    header("HTTP/1.0 404 Not Found");
    imageError(gettext("Too few arguments! Image not found."), 'err-imagenotfound.gif');
}
// Fix special characters in the album and image names if mod_rewrite is on:
// URL looks like: "/album1/subalbum/image/picture.jpg"
list($ralbum, $rimage) = rewrite_get_album_image('a', 'i');
$ralbum = UTF8ToFileSystem($ralbum);
$rimage = UTF8ToFileSystem($rimage);
$album = str_replace('..', '', sanitize_path($ralbum));
$image = str_replace(array('/', "\\"), '', sanitize_path($rimage));
$theme = themeSetup($album);
// loads the theme based image options.
$adminrequest = isset($_GET['admin']);
// Disallow abusive size requests.
if (isset($_GET['s']) && abs($_GET['s']) < MAX_SIZE || isset($_GET['w']) && abs($_GET['w']) < MAX_SIZE || isset($_GET['h']) && abs($_GET['h']) < MAX_SIZE) {
    // Extract the image parameters from the input variables
    // This validates the input as well.
    $args = array();
    if (isset($_GET['s'])) {
        //0
        $args[] = $_GET['s'];
    } else {
        $args[] = NULL;