Example #1
0
/**
 * $returns coordinate informations for an image
 * @param $image		image object
 */
function getGeoCoord($image)
{
    global $_zp_current_image;
    if (isImageClass($image)) {
        $_zp_current_image = $image;
        $lat = $_zp_current_image->get('GPSLatitude');
        $long = $_zp_current_image->get('GPSLongitude');
        if (!empty($lat) && !empty($long)) {
            $lat_f = inputConvert($lat);
            $long_f = inputConvert($long);
            $thumb = '<a href="javascript:image(\'' . $_zp_current_image->albumname . '\',\'' . $_zp_current_image->filename . '\');"><img src="' . getCustomImageURL(150, NULL, NULL, NULL, NULL, NULL, NULL, true) . '" /></a>';
            return array('lat' => $lat_f, 'long' => $long_f, 'title' => $_zp_current_image->getTitle(), 'desc' => $_zp_current_image->getDesc(), 'thumb' => $thumb);
        }
    } else {
        return false;
    }
}
Example #2
0
 /**
  * Checks if the item is either expired or in scheduled publishing
  * A class method wrapper of the functions.php function of the same name
  * @return boolean
  */
 function checkPublishDates()
 {
     $row = array();
     if (isAlbumClass($this) || isImageClass($this)) {
         $row = array('show' => $this->getShow(), 'expiredate' => $this->getExpireDate(), 'publishdate' => $this->getPublishDate());
     } else {
         if ($this->table == 'news' || $this->table == 'pages') {
             $row = array('show' => $this->getShow(), 'expiredate' => $this->getExpireDate(), 'publishdate' => $this->getDateTime());
         }
     }
     $check = checkPublishDates($row);
     if ($check == 1 || $check == 2) {
         return false;
     } else {
         return true;
     }
 }
Example #3
0
/**
 * Helper function for getRelatedItems() only.
 * Returns an array with array for each item with name, album (images only), type and weight (search weight value)
 * Excludes the current item itself.
 *
 * @param array $result array with search results
 * @param string $type "albums", "images", "news", "pages"
 */
function createRelatedItemsResultArray($result, $type)
{
    global $_zp_gallery, $_zp_current_album, $_zp_current_image, $_zp_current_zenpage_page, $_zp_current_zenpage_news, $_zp_gallery_page;
    switch ($_zp_gallery_page) {
        case 'album.php':
            $current = $_zp_current_album;
            break;
        case 'image.php':
            $current = $_zp_current_image;
            break;
        case 'news.php':
            $current = $_zp_current_zenpage_news;
            break;
        case 'pages.php':
            $current = $_zp_current_zenpage_page;
            break;
    }
    $results = array();
    foreach ($result as $item) {
        switch ($type) {
            case 'albums':
                if (!isAlbumClass($current) || $current->name != $item) {
                    array_push($results, array('name' => $item, 'album' => '', 'type' => $type, 'weight' => '13'));
                    // doesn't have weight so we just add one for sorting later
                }
                break;
            case 'images':
                if (!isImageClass($current) || $current->filename != $item['filename']) {
                    array_push($results, array('name' => $item['filename'], 'album' => $item['folder'], 'type' => $type, 'weight' => $item['weight']));
                }
                break;
            case 'news':
                if (get_class($current) != 'ZenpageNews' || $current->getTitlelink() != $item['titlelink']) {
                    if (!isset($item['weight'])) {
                        $item['weight'] = 13;
                    }
                    //	there are circumstances where weights are not generated.
                    array_push($results, array('name' => $item['titlelink'], 'album' => '', 'type' => $type, 'weight' => $item['weight']));
                }
                break;
            case 'pages':
                if (get_class($current) != 'ZenpagePage' || $current->getTitlelink() != $item) {
                    array_push($results, array('name' => $item, 'album' => '', 'type' => $type, 'weight' => '13'));
                    // doesn't have weight so we just add one for sorting later
                }
                break;
        }
    }
    return $results;
}
Example #4
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;
}
Example #5
0
/**
 * $returns coordinate informations for an image
 * @param $image		image object
 */
function getGeoCoord($image)
{
    global $_zp_current_image;
    $result = false;
    if (isImageClass($image)) {
        $_zp_current_image = $image;
        $exif = $_zp_current_image->getMetaData();
        if (!empty($exif['EXIFGPSLatitude']) && !empty($exif['EXIFGPSLongitude'])) {
            $lat_c = explode('.', str_replace(',', '.', $exif['EXIFGPSLatitude']) . '.0');
            $lat_f = round((double) abs($lat_c[0]) + $lat_c[1] / pow(10, strlen($lat_c[1])), 12);
            if (strtoupper(@$exif['EXIFGPSLatitudeRef'][0]) == 'S') {
                $lat_f = -$lat_f;
            }
            $long_c = explode('.', str_replace(',', '.', $exif['EXIFGPSLongitude']) . '.0');
            $long_f = round((double) abs($long_c[0]) + $long_c[1] / pow(10, strlen($long_c[1])), 12);
            if (strtoupper(@$exif['EXIFGPSLongitudeRef'][0]) == 'W') {
                $long_f = -$long_f;
            }
            $thumb = '<a href="javascript:image(\'' . $_zp_current_image->albumname . '\',\'' . $_zp_current_image->filename . '\');"><img src="' . getCustomImageURL(150) . '" /></a>';
            $result = array('lat' => $lat_f, 'long' => $long_f, 'title' => $_zp_current_image->getTitle(), 'desc' => $_zp_current_image->getDesc(), 'thumb' => $thumb);
        }
    }
    return $result;
}