예제 #1
0
function email_new_user_save($savemsg, $userobj, $what)
{
    global $_zp_authority;
    if ($what == 'new' && ($mail = $userobj->getEmail())) {
        $gallery = new Gallery();
        $ref = $_zp_authority->getResetTicket($adm = $userobj->getUser(), $userobj->getPass());
        $msg = "\n" . sprintf(gettext('You are receiving this e-mail because a user code (%1$s) has been created for you on the Zenphoto gallery %2$s.'), $adm, $gallery->getTitle()) . "\n" . sprintf(gettext('To set your Zenphoto User password visit: %s'), FULLWEBPATH . "/" . ZENFOLDER . "/admin-users.php?ticket={$ref}&user={$adm}") . "\n" . gettext("This ticket will automatically expire in 3 days.");
        $err_msg = zp_mail(gettext("The Zenphoto user created"), $msg, array($mail));
        if (!empty($err_msg)) {
            $savemsg .= $err_msg;
        }
    }
    return $savemsg;
}
예제 #2
0
/**
 * Filters a new comment post and sends email replies to previous posters
 * @param object $comment the comment
 * @param object $owner the element commented upon.
 */
function emailReply($comment, $owner)
{
    $gallery = new Gallery();
    if ($comment->getInModeration() || $comment->getPrivate()) {
        return $comment;
        // we are not going to e-mail unless the comment has passed.
    }
    $oldcomments = $owner->comments;
    $emails = array();
    foreach ($oldcomments as $oldcomment) {
        $name = $oldcomment['name'];
        $emails[$name] = $oldcomment['email'];
    }
    $emails = array_unique($emails);
    switch ($comment->getType()) {
        case "albums":
            $url = "album=" . urlencode($owner->name);
            $action = sprintf(gettext('A reply has been posted on album "%1$s".'), $owner->name);
            break;
        case "news":
            $url = "p=" . ZENPAGE_NEWS . "&title=" . urlencode($owner->getTitlelink());
            $action = sprintf(gettext('A reply has been posted on article "%1$s".'), $owner->getTitlelink());
            break;
        case "pages":
            $url = "p=" . ZENPAGE_PAGES . "&title=" . urlencode($owner->getTitlelink());
            $action = sprintf(gettext('A reply has been posted on page "%1$s".'), $owner->getTitlelink());
            break;
        default:
            // all image types
            $url = "album=" . urlencode($owner->album->name) . "&image=" . urlencode($owner->filename);
            $action = sprintf(gettext('A reply has been posted on "%1$s" the album "%2$s".'), $owner->getTitle(), $owner->getAlbumName());
    }
    if ($comment->getAnon()) {
        $email = $name = '<' . gettext("Anonymous") . '>';
    } else {
        $name = $comment->getname();
        $email = $comment->getEmail();
    }
    $message = $action . "\n\n" . sprintf(gettext('Author: %1$s' . "\n" . 'Email: %2$s' . "\n" . 'Website: %3$s' . "\n" . 'Comment:' . "\n\n" . '%4$s'), $name, $email, $comment->getWebsite(), $comment->getComment()) . "\n\n" . sprintf(gettext('You can view all comments about this item here:' . "\n" . '%1$s'), 'http://' . $_SERVER['SERVER_NAME'] . WEBPATH . '/index.php?' . $url) . "\n\n";
    $on = gettext('Reply posted');
    zp_mail("[" . $gallery->getTitle() . "] {$on}", $message, $emails);
    return $comment;
}
예제 #3
0
    $feeds = explode(';', $feeds);
    if (count($feeds) < 0) {
        exitZP();
    }
    // set the header type
    header("Content-type: text/xml");
    // set an arbitrary feed date
    $RSS_date = date("r", mktime(10, 0, 0, 9, 8, 2010));
    if (isset($_GET['lang'])) {
        $locale = sanitize($_GET['lang']);
    } else {
        $locale = getOption('locale');
    }
    $gallery = new Gallery();
    // Create new MergedRSS object with desired parameters
    $MergedRSS = new MergedRSS($feeds, getBare(get_language_string($gallery->getTitle(), $locale)), FULLWEBPATH, getBare(get_language_string($gallery->getDesc(), $locale)), $RSS_date);
    //Export the first 10 items to screen
    $mergedrss_feeditems = getOption('mergedrss_items');
    if (empty($mergedrss_feeditems)) {
        $mergedrss_feeditems = 10;
    }
    $MergedRSS->export(false, true, $mergedrss_feeditems);
    //getOption('RSS_items')
    exitZP();
}
class MergedRSSOptions
{
    function __construct()
    {
        if (OFFSET_PATH == 2) {
            setOptionDefault('mergedrss_items', 10);
예제 #4
0
                        case 'enable':
                            $userobj->setValid(1);
                            $userobj->save();
                            break;
                        case 'renew':
                            $newdate = getOption('user_expiry_interval') * 86400 + strtotime($userobj->getDateTime());
                            if ($newdate + getOption('user_expiry_interval') * 86400 < time()) {
                                $newdate = time() + getOption('user_expiry_interval') * 86400;
                            }
                            $userobj->setDateTime(date('Y-m-d H:i:s', $newdate));
                            $userobj->setValid(1);
                            $userobj->save();
                            break;
                        case 'revalidate':
                            $gallery = new Gallery();
                            $site = $gallery->getTitle();
                            $user_e = $userobj->getEmail();
                            $user = $userobj->getUser();
                            $key = bin2hex(serialize(array('user' => $user, 'email' => $user_e, 'date' => time())));
                            $link = FULLWEBPATH . '/index.php?user_expiry_reverify=' . $key;
                            $message = sprintf(gettext('Your %1$s credentials need to be renewed. Visit %2$s to renew your logon credentials.'), $site, $link);
                            $msg = zp_mail(sprintf(gettext('%s renewal required'), $site), $message, array($user => $user_e));
                            break;
                    }
                }
            }
        }
        header("Location: " . FULLWEBPATH . "/" . ZENFOLDER . '/' . PLUGIN_FOLDER . '/user-expiry/user-expiry-tab.php?page=users&tab=groups&applied=' . $msg);
        exit;
    }
}
예제 #5
0
/**
 * 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 string $theme the current theme
 * @param string $album the album containing the image
 */
function cacheImage($newfilename, $imgfile, $args, $allow_watermark = false, $theme, $album)
{
    @(list($size, $width, $height, $cw, $ch, $cx, $cy, $quality, $thumb, $crop, $thumbstandin, $passedWM, $adminrequest, $effects) = $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');
    $id = NULL;
    $watermark_use_image = getAlbumInherited($album, 'watermark', $id);
    if (empty($watermark_use_image)) {
        $watermark_use_image = IMAGE_WATERMARK;
    }
    if (!$effects) {
        if ($thumb && getOption('thumb_gray')) {
            $effects = 'gray';
        } else {
            if (getOption('image_gray')) {
                $effects = 'gray';
            }
        }
    }
    $newfile = SERVERCACHE . $newfilename;
    if (DEBUG_IMAGE) {
        debugLog("cacheImage(\$imgfile=" . basename($imgfile) . ", \$newfilename={$newfilename}, \$allow_watermark={$allow_watermark}, \$theme={$theme}) \$size={$size}, \$width={$width}, \$height={$height}, \$cw={$cw}, \$ch={$ch}, \$cx=" . (is_null($cx) ? 'NULL' : $cx) . ", \$cy=" . (is_null($cy) ? 'NULL' : $cy) . ", \$quality={$quality}, \$thumb={$thumb}, \$crop={$crop} \$image_use_side={$image_use_side}; \$upscale={$upscale};");
    }
    // Check for the source image.
    if (!file_exists($imgfile) || !is_readable($imgfile)) {
        imageError(gettext('Image not found or is unreadable.'), 'err-imagenotfound.png');
    }
    $rotate = false;
    if (zp_imageCanRotate() && getOption('auto_rotate')) {
        $rotate = getImageRotation($imgfile);
    }
    if ($im = zp_imageGet($imgfile)) {
        if ($rotate) {
            $im = zp_rotateImage($im, $rotate);
        }
        $w = zp_imageWidth($im);
        $h = zp_imageHeight($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.png');
                    }
                }
            }
        }
        $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} \$effects={$effects}");
        }
        if (!$upscale && $newh >= $h && $neww >= $w) {
            // image is the same size or smaller than the request
            $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={$crop}, \$thumb={$thumb}, \$rotate={$rotate}, watermark=" . $watermark_use_image);
            }
        }
        // Crop the image if requested.
        if ($crop) {
            if ($cw > $ch) {
                $ir = $ch / $cw;
            } else {
                $ir = $cw / $ch;
            }
            if ($size) {
                $neww = $size;
                $newh = $ir * $size;
            } else {
                $neww = $width;
                $newh = $height;
                if ($neww > $newh) {
                    if ($newh === false) {
                        $newh = $ir * $neww;
                    }
                } else {
                    if ($neww === false) {
                        $neww = $ir * $newh;
                    }
                }
            }
            if (is_null($cx) && is_null($cy)) {
                // scale crop to max of image
                // set crop scale factor
                $cf = 1;
                if ($cw) {
                    $cf = min($cf, $cw / $neww);
                }
                if ($ch) {
                    $cf = min($cf, $ch / $newh);
                }
                //	set the image area of the crop (use the most image possible, rule of thirds positioning)
                if (!$cw || $w / $cw * $ch > $h) {
                    $cw = round($h / $ch * $cw * $cf);
                    $ch = round($h * $cf);
                    $cx = round(($w - $cw) / 3);
                } else {
                    $ch = round($w / $cw * $ch * $cf);
                    $cw = round($w * $cf);
                    $cy = round(($h - $ch) / 3);
                }
            } else {
                // custom crop
                if (!$cw || $cw > $w) {
                    $cw = $w;
                }
                if (!$ch || $ch > $h) {
                    $ch = $h;
                }
            }
            // force the crop to be within the image
            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 = zp_createImage($neww, $newh);
            zp_resampleImage($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 = zp_createImage($neww, $newh);
            zp_resampleImage($newim, $im, 0, 0, 0, 0, $neww, $newh, $w, $h);
        }
        $imgEffects = explode(',', $effects);
        if (in_array('gray', $imgEffects)) {
            zp_imageGray($newim);
        }
        if ($thumb && $sharpenthumbs || !$thumb && $sharpenimages) {
            zp_imageUnsharpMask($newim, getOption('sharpen_amount'), getOption('sharpen_radius'), getOption('sharpen_threshold'));
        }
        $watermark_image = false;
        if ($passedWM) {
            if ($passedWM != NO_WATERMARK) {
                $watermark_image = getWatermarkPath($passedWM);
                if (!file_exists($watermark_image)) {
                    $watermark_image = SERVERPATH . '/' . ZENFOLDER . '/images/imageDefault.png';
                }
            }
        } else {
            if ($allow_watermark) {
                $watermark_image = $watermark_use_image;
                if ($watermark_image) {
                    if ($watermark_image != NO_WATERMARK) {
                        $watermark_image = getWatermarkPath($watermark_image);
                        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 = zp_imageGet($watermark_image);
            $watermark_width = zp_imageWidth($watermark);
            $watermark_height = zp_imageHeight($watermark);
            $imw = zp_imageWidth($newim);
            $imh = zp_imageHeight($newim);
            $nw = sqrt($imw * $imh * $percent * ($watermark_width / $watermark_height));
            $nh = $nw * ($watermark_height / $watermark_width);
            $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 = zp_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}");
            }
            zp_copyCanvas($newim, $watermark, $dest_x, $dest_y, 0, 0, $nw, $nh);
            zp_imageKill($watermark);
        }
        // Create the cached file (with lots of compatibility)...
        mkdir_recursive(dirname($newfile));
        if (zp_imageOutput($newim, getSuffix($newfile), $newfile, $quality)) {
            //	successful save of cached image
            if (getOption('ImbedIPTC') && getSuffix($newfilename) == 'jpg') {
                // the imbed function works only with JPEG images
                $iptc_data = zp_imageIPTC($imgfile);
                if (empty($iptc_data)) {
                    global $_zp_extra_filetypes;
                    //	because we are doing the require in a function!
                    if (!$_zp_extra_filetypes) {
                        $_zp_extra_filetypes = array();
                    }
                    require_once dirname(__FILE__) . '/functions.php';
                    //	it is ok to increase memory footprint now since the image processing is complete
                    $gallery = new Gallery();
                    $iptc = array('1#090' => chr(0x1b) . chr(0x25) . chr(0x47), '2#115' => $gallery->getTitle());
                    $imgfile = str_replace(ALBUM_FOLDER_SERVERPATH, '', $imgfile);
                    $imagename = basename($imgfile);
                    $albumname = dirname($imgfile);
                    $image = newImage(new Album(new Gallery(), $albumname), $imagename);
                    $copyright = $image->getCopyright();
                    if (empty($copyright)) {
                        $copyright = getOption('default_copyright');
                    }
                    if (!empty($copyright)) {
                        $iptc['2#116'] = $copyright;
                    }
                    $credit = $image->getCredit();
                    if (!empty($credit)) {
                        $iptc['2#110'] = $credit;
                    }
                    foreach ($iptc as $tag => $string) {
                        $tag_parts = explode('#', $tag);
                        $iptc_data .= iptc_make_tag($tag_parts[0], $tag_parts[1], $string);
                    }
                } else {
                    if (GRAPHICS_LIBRARY == 'Imagick' && IMAGICK_RETAIN_PROFILES) {
                        //	Imageick has preserved the metadata
                        $iptc_data = false;
                    }
                }
                if ($iptc_data) {
                    $content = iptcembed($iptc_data, $newfile);
                    $fw = fopen($newfile, 'w');
                    fwrite($fw, $content);
                    fclose($fw);
                    clearstatcache();
                }
            }
            if (DEBUG_IMAGE) {
                debugLog('Finished:' . basename($imgfile));
            }
        } else {
            if (DEBUG_IMAGE) {
                debugLog('cacheImage: failed to create ' . $newfile);
            }
        }
        @chmod($newfile, 0666 & CHMOD_VALUE);
        zp_imageKill($newim);
        zp_imageKill($im);
    }
}
예제 #6
0
    /**
     * Print the login form for ZP. This will take into account whether mod_rewrite is enabled or not.
     *
     * @param string $redirect URL to return to after login
     * @param bool $logo set to true to display the ADMIN zenphoto logo.
     * @param bool $showUser set to true to display the user input
     * @param bool $showCaptcha set to false to not display the forgot password captcha.
     * @param string $hint optional hint for the password
     *
     */
    function printLoginForm($redirect = null, $logo = true, $showUser = true, $showCaptcha = '*', $hint = '')
    {
        global $_zp_login_error, $_zp_captcha, $_zp_authority;
        if (is_null($redirect)) {
            $redirect = WEBPATH . '/' . ZENFOLDER . '/admin.php';
        }
        if (isset($_POST['user'])) {
            $requestor = sanitize($_POST['user'], 3);
        } else {
            $requestor = '';
        }
        if (empty($requestor)) {
            if (isset($_GET['ref'])) {
                $requestor = sanitize($_GET['ref'], 0);
            }
        }
        $alt_handlers = zp_apply_filter('alt_login_handler', array());
        $star = '';
        $mails = array();
        if (!empty($requestor)) {
            $admin = $_zp_authority->getAnAdmin(array('`user`=' => $requestor, '`valid`=' => 1));
            if (is_object($admin) && $admin->getEmail()) {
                $star = $showCaptcha;
            }
        }
        if (!$star) {
            $admins = $_zp_authority->getAdministrators();
            while (count($admins) > 0) {
                $user = array_shift($admins);
                if ($user['email']) {
                    $star = $showCaptcha;
                }
            }
        }
        ?>
		<div id="loginform">
		<?php 
        if ($logo) {
            echo "<p><img src=\"" . WEBPATH . '/' . ZENFOLDER . "/images/zen-logo.png\" title=\"ZenPhoto\" alt=\"ZenPhoto\" /></p>";
        }
        switch ($_zp_login_error) {
            case 1:
                ?>
				<div class="errorbox" id="message"><h2><?php 
                echo gettext("There was an error logging in.");
                ?>
</h2><?php 
                echo gettext("Check your username and password and try again.");
                ?>
</div>
				<?php 
                break;
            case 2:
                ?>
				<div class="messagebox fade-message">
				<h2><?php 
                echo gettext("A reset request has been sent.");
                ?>
</h2>
				</div>
				<?php 
                break;
            default:
                if (!empty($_zp_login_error)) {
                    ?>
					<div class="errorbox fade-message">
					<h2><?php 
                    echo $_zp_login_error;
                    ?>
</h2>
					</div>
					<?php 
                }
                break;
        }
        ?>
		<form name="login" action="#" method="post">
		<input type="hidden" name="login" value="1" />
		<input type="hidden" name="password" value="1" />
		<input type="hidden" name="redirect" value="<?php 
        echo html_encode($redirect);
        ?>
" />
		<fieldset id="logon_box">
			<?php 
        if (empty($alt_handlers)) {
            $ledgend = gettext('Login');
        } else {
            $gallery = new Gallery();
            ?>
				<script type="text/javascript">
					<!--
					var handlers = [];
					<?php 
            $list = '<select id="logon_choices" onchange="changeHandler(handlers[$(this).val()]);">' . '<option value="0">' . html_encode(get_language_string($gallery->getTitle())) . '</option>';
            $c = 0;
            foreach ($alt_handlers as $handler => $details) {
                $c++;
                $details['params'][] = 'redirect=' . $redirect;
                if (!empty($requestor)) {
                    $details['params'][] = 'requestor=' . $requestor;
                }
                echo "handlers[" . $c . "]=['" . $details['script'] . "','" . implode("','", $details['params']) . "'];";
                $list .= '<option value="' . $c . '">' . $handler . '</option>';
            }
            $list .= '</select>';
            $ledgend = sprintf(gettext('Logon using:%s'), $list);
            ?>
					function changeHandler(handler) {
						handler.push('user='******'#user').val());
						var script = handler.shift();
						launchScript(script,handler);
					}
					-->
				</script>
				<?php 
        }
        ?>
			<legend><?php 
        echo $ledgend;
        ?>
</legend>
			<table class="password">
				<?php 
        if ($showUser || GALLERY_SECURITY == 'private') {
            //	requires a "user" field
            ?>
					<tr>
						<td align="left">
						<h2><?php 
            echo gettext("User");
            ?>
&nbsp;</h2>
						</td>
						<td><input class="textfield" name="user" id="user" type="text" size="20"
							value="<?php 
            echo html_encode($requestor);
            ?>
" /></td>
					</tr>
					<?php 
        }
        ?>
				<tr>
					<td align="left">
					<h2><?php 
        echo gettext("Password") . $star;
        ?>
</h2>
					</td>
					<td><input class="textfield" name="pass" type="password" size="20" /></td>
				</tr>
			</table>
		</fieldset>
		<table class="password">
		<?php 
        if ($star == '*') {
            $captchaCode = $_zp_captcha->generateCaptcha($img);
            $html = "<input type=\"hidden\" name=\"code_h\" value=\"" . $captchaCode . "\"/><label><img src=\"" . $img . "\" alt=\"Code\" align=\"middle\"/></label>";
            ?>
			<tr>
				<td align="left"><?php 
            echo gettext("*Enter CAPTCHA in place of <em>Password</em> to request a password reset.");
            ?>
</td>
				<td><?php 
            echo $html;
            ?>
</td>
			</tr>
			<?php 
        }
        ?>
			<tr>
				<td colspan="2">
					<div class="buttons">
						<button type="submit" value="<?php 
        echo gettext("Log in");
        ?>
" ><img src="<?php 
        echo WEBPATH . '/' . ZENFOLDER;
        ?>
/images/pass.png" alt="" /><?php 
        echo gettext("Log in");
        ?>
</button>
						<button type="reset" value="<?php 
        echo gettext("Reset");
        ?>
" ><img src="<?php 
        echo WEBPATH . '/' . ZENFOLDER;
        ?>
/images/reset.png" alt="" /><?php 
        echo gettext("Reset");
        ?>
</button>
					</div>
				</td>
			</tr>
		</table>
		</form>
		<?php 
        if ($hint) {
            echo '<p>' . $hint . '</p>';
        }
        ?>
		</div>
	<?php 
    }
예제 #7
0
		return false;
	}
	// ]]> -->
</script>

<?php 
echo "\n</head>";
echo "\n<body>";
printLogoAndLinks();
echo "\n" . '<div id="main">';
printTabs();
echo "\n" . '<div id="content">';
$galleryTheme = $_zp_gallery->getCurrentTheme();
$themelist = array();
if (zp_loggedin(ADMIN_RIGHTS)) {
    $gallery_title = $_zp_gallery->getTitle();
    if ($gallery_title != gettext("Gallery")) {
        $gallery_title .= ' (' . gettext("Gallery") . ')';
    }
    $themelist[$gallery_title] = '';
}
$albums = $_zp_gallery->getAlbums(0);
foreach ($albums as $alb) {
    $album = newAlbum($alb);
    if ($album->isMyItem(THEMES_RIGHTS)) {
        $key = $album->getTitle();
        if ($key != $alb) {
            $key .= " ({$alb})";
        }
        $themelist[$key] = $alb;
    }
예제 #8
0
/**
 * Print the header for all admin pages. Starts at <DOCTYPE> but does not include the </head> tag,
 * in case there is a need to add something further.
 *
 * @param string $tab the album page
 * @param string $subtab the sub-tab if any
 */
function printAdminHeader($tab, $subtab = NULL)
{
    global $_zp_admin_tab, $_zp_admin_subtab, $gallery, $zenphoto_tabs, $_zp_RTL_css, $_zp_last_modified;
    if (!is_object($gallery)) {
        $gallery = new Gallery();
    }
    $_zp_admin_tab = $tab;
    if (isset($_GET['tab'])) {
        $_zp_admin_subtab = sanitize($_GET['tab'], 3);
    } else {
        $_zp_admin_subtab = $subtab;
    }
    $tabtext = $_zp_admin_tab;
    foreach ($zenphoto_tabs as $key => $tabrow) {
        if ($key == $_zp_admin_tab) {
            $tabtext = $tabrow['text'];
            break;
        }
        $tabrow = NULL;
    }
    if (empty($_zp_admin_subtab) && $tabrow && isset($tabrow['default'])) {
        $_zp_admin_subtab = $zenphoto_tabs[$_zp_admin_tab]['default'];
    }
    $subtabtext = '';
    if ($_zp_admin_subtab && $tabrow && array_key_exists('subtabs', $tabrow) && $tabrow['subtabs']) {
        foreach ($tabrow['subtabs'] as $key => $link) {
            $i = strpos($link, '&amp;tab=');
            if ($i !== false) {
                $text = substr($link, $i + 9);
                if ($text == $_zp_admin_subtab) {
                    $subtabtext = '-' . $key;
                    break;
                }
            }
        }
    }
    if (empty($subtabtext)) {
        if ($_zp_admin_subtab) {
            $subtabtext = '-' . $_zp_admin_subtab;
        }
    }
    header('Last-Modified: ' . $_zp_last_modified);
    header('Content-Type: text/html; charset=' . LOCAL_CHARSET);
    zp_apply_filter('admin_headers');
    ?>
	<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
	<html xmlns="http://www.w3.org/1999/xhtml">
	<head>
	<meta http-equiv="content-type" content="text/html; charset=<?php 
    echo LOCAL_CHARSET;
    ?>
" />
	<link rel="stylesheet" href="<?php 
    echo WEBPATH . '/' . ZENFOLDER;
    ?>
/admin.css" type="text/css" />
	<link rel="stylesheet" href="<?php 
    echo WEBPATH . '/' . ZENFOLDER;
    ?>
/js/toggleElements.css" type="text/css" />
	<link rel="stylesheet" href="<?php 
    echo WEBPATH . '/' . ZENFOLDER;
    ?>
/js/jqueryui/jquery_ui_zenphoto.css" type="text/css" />
	<?php 
    if ($_zp_RTL_css) {
        ?>
		<link rel="stylesheet" href="<?php 
        echo WEBPATH . '/' . ZENFOLDER;
        ?>
/admin-rtl.css" type="text/css" />
		<?php 
    }
    ?>
	<title><?php 
    echo sprintf(gettext('%1$s %2$s: %3$s%4$s'), html_encode($gallery->getTitle()), gettext('admin'), html_encode($tabtext), html_encode($subtabtext));
    ?>
</title>
	<script src="<?php 
    echo WEBPATH . '/' . ZENFOLDER;
    ?>
/js/jquery.js" type="text/javascript"></script>
	<script src="<?php 
    echo WEBPATH . '/' . ZENFOLDER;
    ?>
/js/jqueryui/jquery_ui_zenphoto.js" type="text/javascript"></script>
	<script src="<?php 
    echo WEBPATH . '/' . ZENFOLDER;
    ?>
/js/zenphoto.js" type="text/javascript" ></script>
	<script src="<?php 
    echo WEBPATH . '/' . ZENFOLDER;
    ?>
/js/admin.js" type="text/javascript" ></script>
	<script src="<?php 
    echo WEBPATH . '/' . ZENFOLDER;
    ?>
/js/jquery.tooltip.js" type="text/javascript"></script>
	<script src="<?php 
    echo WEBPATH . '/' . ZENFOLDER;
    ?>
/js/jquery.scrollTo.js" type="text/javascript"></script>
	<script language="javascript" type="text/javascript">
		// <!-- <![CDATA[
		$(document).ready(function(){
			$("a.colorbox").colorbox({ maxWidth:"98%", maxHeight:"98%"});
		});
		jQuery(function( $ ){
			$("#fade-message").fadeTo(5000, 1).fadeOut(1000);
			$(".fade-message").fadeTo(5000, 1).fadeOut(1000);
			$('.tooltip').tooltip({
				left: -80
			});
		})
		// ]]> -->
	</script>
	<?php 
    zp_apply_filter('admin_head', NULL);
}
예제 #9
0
		return false;
	}
	// ]]> -->
</script>

<?php 
echo "\n</head>";
echo "\n<body>";
printLogoAndLinks();
echo "\n" . '<div id="main">';
printTabs();
echo "\n" . '<div id="content">';
$galleryTheme = $gallery->getCurrentTheme();
$themelist = array();
if (zp_loggedin(ADMIN_RIGHTS)) {
    $gallery_title = $gallery->getTitle();
    if ($gallery_title != gettext("Gallery")) {
        $gallery_title .= ' (' . gettext("Gallery") . ')';
    }
    $themelist[$gallery_title] = '';
}
$albums = $gallery->getAlbums(0);
foreach ($albums as $alb) {
    $album = new Album($gallery, $alb);
    if ($album->isMyItem(THEMES_RIGHTS)) {
        $key = $album->getTitle();
        if ($key != $alb) {
            $key .= " ({$alb})";
        }
        $themelist[$key] = $alb;
    }
예제 #10
0
function user_expiry_checkexpires($loggedin, $userobj)
{
    $subscription = 86400 * getOption('user_expiry_interval');
    $expires = strtotime($userobj->getDateTime()) + $subscription;
    if ($expires < time()) {
        $userobj->setValid(2);
        $userobj->save();
        $loggedin = false;
    } else {
        if ($expires < time() + getOption('user_expiry_warn_interval') * 86400) {
            //	expired
            if (getOption('user_expiry_auto_renew')) {
                $newdate = getOption('user_expiry_interval') * 86400 + strtotime($userobj->getDateTime());
                if ($newdate + getOption('user_expiry_interval') * 86400 < time()) {
                    $newdate = time() + getOption('user_expiry_interval') * 86400;
                }
                $userobj->setDateTime(date('Y-m-d H:i:s', $newdate));
                $userobj->setValid(1);
                $credentials = $userobj->getCredentials();
                $key = array_search('exiry_notice', $credentials);
                if ($key !== false) {
                    unset($credentials[$key]);
                    $userobj->setCredentials($credentials);
                }
                $userobj->save();
            } else {
                if ($mail = $userobj->getEmail()) {
                    $credentials = $userobj->getCredentials();
                    if (!in_array('exiry_notice', $credentials)) {
                        $credentials[] = 'exiry_notice';
                        $userobj->setCredentials($credentials);
                        $userobj->save();
                        $gallery = new Gallery();
                        $message = sprintf(gettext('Your user id for the Zenphoto site %s will expire on %s.'), $gallery->getTitle(), date('Y-m-d', $expires));
                        $notify = zp_mail(get_language_string(gettext('User id expiration')), $message, array($userobj->getName() => $mail));
                    }
                }
            }
        } else {
            $credentials = $userobj->getCredentials();
            $key = array_search('exiry_notice', $credentials);
            if ($key !== false) {
                unset($credentials[$key]);
                $userobj->setCredentials($credentials);
                $userobj->save();
            }
        }
    }
    return $loggedin;
}
예제 #11
0
/**
 * Generic comment adding routine. Called by album objects or image objects
 * to add comments.
 *
 * Returns a comment object
 *
 * @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 hash 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
 * @param bit $check bitmask of which fields must be checked. If set overrides the options
 * @return object
 */
function postComment($name, $email, $website, $comment, $code, $code_ok, $receiver, $ip, $private, $anon, $check = false)
{
    global $_zp_captcha, $_zp_gallery, $_zp_authority, $_zp_comment_on_hold;
    if ($check === false) {
        $whattocheck = 0;
        if (getOption('comment_email_required') == 'required') {
            $whattocheck = $whattocheck | COMMENT_EMAIL_REQUIRED;
        }
        if (getOption('comment_name_required')) {
            $whattocheck = $whattocheck | COMMENT_NAME_REQUIRED;
        }
        if (getOption('comment_web_required') == 'required') {
            $whattocheck = $whattocheck | COMMENT_WEB_REQUIRED;
        }
        if (getOption('Use_Captcha')) {
            $whattocheck = $whattocheck | USE_CAPTCHA;
        }
        if (getOption('comment_body_requiired')) {
            $whattocheck = $whattocheck | COMMENT_BODY_REQUIRED;
        }
        if (getOption('email_new_comments')) {
            $whattocheck = $whattocheck | COMMENT_SEND_EMAIL;
        }
    } else {
        $whattocheck = $check;
    }
    $type = $receiver->table;
    $class = get_class($receiver);
    $receiver->getComments();
    $name = trim($name);
    $email = trim($email);
    $website = trim($website);
    if (!empty($website) && substr($website, 0, 7) != "http://") {
        $website = "http://" . $website;
    }
    // Let the comment have trailing line breaks and space? Nah...
    // Also (in)validate HTML here, and in $name.
    $comment = trim($comment);
    $receiverid = $receiver->id;
    $goodMessage = 2;
    if ($private) {
        $private = 1;
    } else {
        $private = 0;
    }
    if ($anon) {
        $anon = 1;
    } else {
        $anon = 0;
    }
    $commentobj = new Comment();
    $commentobj->transient = false;
    // otherwise we won't be able to save it....
    $commentobj->setOwnerID($receiverid);
    $commentobj->setName($name);
    $commentobj->setEmail($email);
    $commentobj->setWebsite($website);
    $commentobj->setComment($comment);
    $commentobj->setType($type);
    $commentobj->setIP($ip);
    $commentobj->setPrivate($private);
    $commentobj->setAnon($anon);
    $commentobj->setInModeration(0);
    if ($whattocheck & COMMENT_EMAIL_REQUIRED && (empty($email) || !is_valid_email_zp($email))) {
        $commentobj->setInModeration(-2);
        $commentobj->comment_error_text .= ' ' . gettext("You must supply an e-mail address.");
        $goodMessage = false;
    }
    if ($whattocheck & COMMENT_NAME_REQUIRED && empty($name)) {
        $commentobj->setInModeration(-3);
        $commentobj->comment_error_text .= ' ' . gettext("You must enter your name.");
        $goodMessage = false;
    }
    if ($whattocheck & COMMENT_WEB_REQUIRED && (empty($website) || !isValidURL($website))) {
        $commentobj->setInModeration(-4);
        $commentobj->comment_error_text .= ' ' . gettext("You must supply a WEB page URL.");
        $goodMessage = false;
    }
    if ($whattocheck & USE_CAPTCHA) {
        if (!$_zp_captcha->checkCaptcha($code, $code_ok)) {
            $commentobj->setInModeration(-5);
            $commentobj->comment_error_text .= ' ' . gettext("CAPTCHA verification failed.");
            $goodMessage = false;
        }
    }
    if ($whattocheck & COMMENT_BODY_REQUIRED && empty($comment)) {
        $commentobj->setInModeration(-6);
        $commentobj->comment_error_text .= ' ' . gettext("You must enter something in the comment text.");
        $goodMessage = false;
    }
    $moderate = 0;
    if ($goodMessage && !(false === ($requirePath = getPlugin('spamfilters/' . internalToFilesystem(getOption('spam_filter')) . ".php")))) {
        require_once $requirePath;
        $spamfilter = new SpamFilter();
        $goodMessage = $spamfilter->filterMessage($name, $email, $website, $comment, $receiver, $ip);
        switch ($goodMessage) {
            case 0:
                $commentobj->setInModeration(2);
                $commentobj->comment_error_text .= sprintf(gettext('Your comment was rejected by the <em>%s</em> SPAM filter.'), getOption('spam_filter'));
                $goodMessage = false;
                break;
            case 1:
                $_zp_comment_on_hold = sprintf(gettext('Your comment has been marked for moderation by the <em>%s</em> SPAM filter.'), getOption('spam_filter'));
                $commentobj->comment_error_text .= $_zp_comment_on_hold;
                $commentobj->setInModeration(1);
                $moderate = 1;
                break;
            case 2:
                $commentobj->setInModeration(0);
                break;
        }
    }
    $localerrors = $commentobj->getInModeration();
    zp_apply_filter('comment_post', $commentobj, $receiver);
    if ($check === false) {
        // ignore filter provided errors if caller is supplying the fields to check
        $localerrors = $commentobj->getInModeration();
    }
    if ($goodMessage && $localerrors >= 0) {
        // Update the database entry with the new comment
        $commentobj->save();
        //  add to comments array and notify the admin user
        if (!$moderate) {
            $receiver->comments[] = array('name' => $commentobj->getname(), 'email' => $commentobj->getEmail(), 'website' => $commentobj->getWebsite(), 'comment' => $commentobj->getComment(), 'date' => $commentobj->getDateTime(), 'custom_data' => $commentobj->getCustomData());
        }
        $class = strtolower(get_class($receiver));
        switch ($class) {
            case "album":
                $url = "album=" . pathurlencode($receiver->name);
                $ur_album = getUrAlbum($receiver);
                if ($moderate) {
                    $action = sprintf(gettext('A comment has been placed in moderation on your album "%1$s".'), $receiver->name);
                } else {
                    $action = sprintf(gettext('A comment has been posted on your album "%1$s".'), $receiver->name);
                }
                break;
            case "zenpagenews":
                $url = "p=news&title=" . urlencode($receiver->getTitlelink());
                if ($moderate) {
                    $action = sprintf(gettext('A comment has been placed in moderation on your article "%1$s".'), $receiver->getTitlelink());
                } else {
                    $action = sprintf(gettext('A comment has been posted on your article "%1$s".'), $receiver->getTitlelink());
                }
                break;
            case "zenpagepage":
                $url = "p=pages&title=" . urlencode($receiver->getTitlelink());
                if ($moderate) {
                    $action = sprintf(gettext('A comment has been placed in moderation on your page "%1$s".'), $receiver->getTitlelink());
                } else {
                    $action = sprintf(gettext('A comment has been posted on your page "%1$s".'), $receiver->getTitlelink());
                }
                break;
            default:
                // all image types
                $url = "album=" . pathurlencode($receiver->album->name) . "&image=" . urlencode($receiver->filename);
                $album = $receiver->getAlbum();
                $ur_album = getUrAlbum($album);
                if ($moderate) {
                    $action = sprintf(gettext('A comment has been placed in moderation on your image "%1$s" in the album "%2$s".'), $receiver->getTitle(), $receiver->getAlbumName());
                } else {
                    $action = sprintf(gettext('A comment has been posted on your image "%1$s" in the album "%2$s".'), $receiver->getTitle(), $receiver->getAlbumName());
                }
                break;
        }
        if ($whattocheck & COMMENT_SEND_EMAIL) {
            $message = $action . "\n\n" . sprintf(gettext('Author: %1$s' . "\n" . 'Email: %2$s' . "\n" . 'Website: %3$s' . "\n" . 'Comment:' . "\n\n" . '%4$s'), $commentobj->getname(), $commentobj->getEmail(), $commentobj->getWebsite(), $commentobj->getComment()) . "\n\n" . sprintf(gettext('You can view all comments about this item here:' . "\n" . '%1$s'), 'http://' . $_SERVER['SERVER_NAME'] . WEBPATH . '/index.php?' . $url) . "\n\n" . sprintf(gettext('You can edit the comment here:' . "\n" . '%1$s'), 'http://' . $_SERVER['SERVER_NAME'] . WEBPATH . '/' . ZENFOLDER . '/admin-comments.php?page=editcomment&id=' . $commentobj->id);
            $emails = array();
            $admin_users = $_zp_authority->getAdministrators();
            foreach ($admin_users as $admin) {
                // mail anyone with full rights
                if (!empty($admin['email']) && ($admin['rights'] & ADMIN_RIGHTS || ($admin['rights'] & (MANAGE_ALL_ALBUM_RIGHTS | COMMENT_RIGHTS)) == (MANAGE_ALL_ALBUM_RIGHTS | COMMENT_RIGHTS))) {
                    $emails[] = $admin['email'];
                    unset($admin_users[$admin['id']]);
                }
            }
            if ($type === "images" or $type === "albums") {
                // mail to album admins
                $id = $ur_album->getAlbumID();
                $sql = 'SELECT `adminid` FROM ' . prefix('admin_to_object') . ' WHERE `objectid`=' . $id . ' AND `type`="album"';
                $result = query_full_array($sql);
                foreach ($result as $anadmin) {
                    $id = $anadmin['adminid'];
                    if (array_key_exists($id, $admin_users)) {
                        $admin = $admin_users[$id];
                        if ($admin['rights'] & COMMENT_RIGHTS && !empty($admin['email'])) {
                            $emails[] = $admin['email'];
                        }
                    }
                }
            }
            $on = gettext('Comment posted');
            $gallery = new Gallery();
            $result = zp_mail("[" . $gallery->getTitle() . "] {$on}", $message, $emails);
            if ($result) {
                $commentobj->setInModeration(-12);
                $commentobj->comment_error_text = $result;
            }
        }
    }
    return $commentobj;
}
예제 #12
0
$option = getRSSNewsCatOptions("option");
$titleappendix = gettext(' (Latest news)');
if (isset($_GET['withimages'])) {
    $option = "withimages";
    $titleappendix = gettext(' (Latest news and images)');
}
$s = getOption('feed_imagesize');
// un-cropped image size
$items = getOption("zenpage_rss_items");
// # of Items displayed on the feed
$gallery = new Gallery();
?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom">
<channel>
<title><?php 
echo html_encode(get_language_string($gallery->getTitle(), $locale));
echo $cattitle;
echo $titleappendix;
?>
</title>
<link><?php 
echo $protocol . "://" . $host . WEBPATH;
?>
</link>
<atom:link href="<?php 
echo $protocol;
?>
://<?php 
echo html_encode($_SERVER["HTTP_HOST"]);
echo html_encode($_SERVER["REQUEST_URI"]);
?>