Exemplo n.º 1
0
 function handleOptionSave($themename, $themealbum)
 {
     if (zp_loggedin(CODEBLOCK_RIGHTS)) {
         processCodeblockSave(0, $this);
     }
     return false;
 }
Exemplo n.º 2
0
     $_zp_gallery->setSortType($st);
     if ($st == 'manual' || $st == 'random') {
         $_zp_gallery->setSortDirection(false);
     } else {
         $_zp_gallery->setSortDirection(isset($_POST['gallery_sortdirection']));
     }
     foreach ($_POST as $item => $value) {
         if (strpos($item, 'gallery-page_') === 0) {
             $item = sanitize(substr(postIndexDecode($item), 13));
             $_zp_gallery->setUnprotectedPage($item, (int) isset($_POST['gallery_page_unprotected_' . $item]));
         }
     }
     $_zp_gallery->setSecurity(sanitize($_POST['gallery_security'], 3));
     $notify = processCredentials($_zp_gallery);
     if (zp_loggedin(CODEBLOCK_RIGHTS)) {
         $_zp_gallery->setCodeblock(processCodeblockSave(0));
     }
     $_zp_gallery->save();
     $returntab = "&tab=gallery";
 }
 /*		 * * Search options ** */
 if (isset($_POST['savesearchoptions'])) {
     $fail = '';
     $search = new SearchEngine();
     $searchfields = array();
     foreach ($_POST as $key => $value) {
         if (strpos($key, 'SEARCH_') !== false) {
             $searchfields[] = substr(sanitize(postIndexDecode($key)), 7);
         }
     }
     setOption('search_fields', implode(',', $searchfields));
Exemplo n.º 3
0
 static function codeblocks($obj, $instance, $field, $type)
 {
     if ($type == 'save') {
         if (zp_loggedin(CODEBLOCK_RIGHTS)) {
             processCodeblockSave((int) $instance, $obj);
             $obj->save();
         }
         return NULL;
     } else {
         ob_start();
         printCodeblockEdit($obj, (int) $instance);
         $item = ob_get_contents();
         ob_end_clean();
         return $item;
     }
 }
/**
 * Updates or adds a news article and returns the object of that article
 *
 * @param array $reports display
 * @param bool $newarticle true if a new article
 *
 * @return object
 */
function updateArticle(&$reports, $newarticle = false)
{
    $date = date('Y-m-d_H-i-s');
    $title = process_language_string_save("title", 2);
    $author = sanitize($_POST['author']);
    $content = zpFunctions::updateImageProcessorLink(process_language_string_save("content", EDITOR_SANITIZE_LEVEL));
    $extracontent = zpFunctions::updateImageProcessorLink(process_language_string_save("extracontent", EDITOR_SANITIZE_LEVEL));
    $custom = process_language_string_save("custom_data", 1);
    $show = getcheckboxState('show');
    $date = sanitize($_POST['date']);
    $expiredate = getExpiryDatePost();
    $permalink = getcheckboxState('permalink');
    $lastchange = sanitize($_POST['lastchange']);
    $lastchangeauthor = sanitize($_POST['lastchangeauthor']);
    $commentson = getcheckboxState('commentson');
    if (zp_loggedin(CODEBLOCK_RIGHTS)) {
        $codeblock = processCodeblockSave(0);
    }
    $locked = getcheckboxState('locked');
    if ($newarticle) {
        $titlelink = seoFriendly(get_language_string($title));
        if (empty($titlelink)) {
            $titlelink = seoFriendly($date);
        }
        $sql = 'SELECT `id` FROM ' . prefix('news') . ' WHERE `titlelink`=' . db_quote($titlelink);
        $rslt = query_single_row($sql, false);
        if ($rslt) {
            //already exists
            $time = explode(' ', microtime());
            $titlelink = $titlelink . '_' . ($time[1] + $time[0]);
            $reports[] = "<p class='warningbox fade-message'>" . gettext('Duplicate article title') . '</p>';
        }
        $oldtitlelink = $titlelink;
        $id = 0;
    } else {
        $titlelink = $oldtitlelink = sanitize($_POST['titlelink-old'], 3);
        $id = sanitize($_POST['id']);
    }
    if (getcheckboxState('edittitlelink')) {
        $titlelink = sanitize($_POST['titlelink'], 3);
        if (empty($titlelink)) {
            $titlelink = seoFriendly(get_language_string($title));
            if (empty($titlelink)) {
                $titlelink = seoFriendly($date);
            }
        }
    } else {
        if (!$permalink) {
            //	allow the title link to change.
            $link = seoFriendly(get_language_string($title));
            if (!empty($link)) {
                $titlelink = $link;
            }
        }
    }
    $rslt = true;
    if ($titlelink != $oldtitlelink) {
        // title link change must be reflected in DB before any other updates
        $rslt = query('UPDATE ' . prefix('news') . ' SET `titlelink`=' . db_quote($titlelink) . ' WHERE `id`=' . $id, false);
        if (!$rslt) {
            $titlelink = $oldtitlelink;
            // force old link so data gets saved
        } else {
            SearchEngine::clearSearchCache();
        }
    }
    // update article
    $article = new ZenpageNews($titlelink, true);
    $article->setTitle($title);
    $article->setContent($content);
    $article->setExtracontent($extracontent);
    $article->setCustomData(zp_apply_filter('save_article_custom_data', $custom, $article));
    $article->setShow($show);
    $article->setDateTime($date);
    $article->setCommentsAllowed($commentson);
    if (zp_loggedin(CODEBLOCK_RIGHTS)) {
        $article->setCodeblock($codeblock);
    }
    $article->setAuthor($author);
    $article->setLastchange($lastchange);
    $article->setLastchangeauthor($lastchangeauthor);
    $article->setPermalink($permalink);
    $article->setLocked($locked);
    $article->setExpiredate($expiredate);
    $article->setSticky(sanitize_numeric($_POST['sticky']));
    if (getcheckboxState('resethitcounter')) {
        $article->set('hitcounter', 0);
    }
    if (getcheckboxState('reset_rating')) {
        $article->set('total_value', 0);
        $article->set('total_votes', 0);
        $article->set('used_ips', 0);
    }
    $article->setTruncation(getcheckboxState('truncation'));
    processTags($article);
    $categories = array();
    $result2 = query_full_array("SELECT * FROM " . prefix('news_categories') . " ORDER BY titlelink");
    foreach ($result2 as $cat) {
        if (isset($_POST["cat" . $cat['id']])) {
            $categories[] = $cat['titlelink'];
        }
    }
    $article->setCategories($categories);
    if ($newarticle) {
        $msg = zp_apply_filter('new_article', '', $article);
        if (empty($title)) {
            $reports[] = "<p class='errorbox fade-message'>" . sprintf(gettext("Article <em>%s</em> added but you need to give it a <strong>title</strong> before publishing!"), get_language_string($titlelink)) . '</p>';
        } else {
            $reports[] = "<p class='messagebox fade-message'>" . sprintf(gettext("Article <em>%s</em> added"), $titlelink) . '</p>';
        }
    } else {
        $msg = zp_apply_filter('update_article', '', $article, $oldtitlelink);
        if (!$rslt) {
            $reports[] = "<p class='errorbox fade-message'>" . sprintf(gettext("An article with the title/titlelink <em>%s</em> already exists!"), $titlelink) . '</p>';
        } else {
            if (empty($title)) {
                $reports[] = "<p class='errorbox fade-message'>" . sprintf(gettext("Article <em>%s</em> updated but you need to give it a <strong>title</strong> before publishing!"), get_language_string($titlelink)) . '</p>';
            } else {
                $reports[] = "<p class='messagebox fade-message'>" . sprintf(gettext("Article <em>%s</em> updated"), $titlelink) . '</p>';
            }
        }
    }
    $article->save();
    if ($msg) {
        $reports[] = $msg;
    }
    return $article;
}
Exemplo n.º 5
0
/**
 * Process the image edit form posted
 * @param obj $image Image object
 * @param type $index Index of the image if within the images list or 0 if single image edit
 * @param boolean $massedit Whether editing single image (false) or multiple images at once (true). Note: to determine whether to process additional fields in single image edit mode.
 */
function processImageEdit($image, $index, $massedit = true)
{
    $notify = '';
    if (isset($_POST[$index . '-MoveCopyRename'])) {
        $movecopyrename_action = sanitize($_POST[$index . '-MoveCopyRename'], 3);
    } else {
        $movecopyrename_action = '';
    }
    if ($movecopyrename_action == 'delete') {
        $image->remove();
    } else {
        if ($thumbnail = sanitize($_POST['album_thumb-' . $index])) {
            //selected as an album thumb
            $talbum = newAlbum($thumbnail);
            if ($image->imagefolder == $thumbnail) {
                $talbum->setThumb($image->filename);
            } else {
                $talbum->setThumb('/' . $image->imagefolder . '/' . $image->filename);
            }
            $talbum->save();
        }
        if (isset($_POST[$index . '-reset_rating'])) {
            $image->set('total_value', 0);
            $image->set('total_votes', 0);
            $image->set('used_ips', 0);
        }
        $image->setPublishDate(sanitize($_POST['publishdate-' . $index]));
        $image->setExpireDate(sanitize($_POST['expirationdate-' . $index]));
        $image->setTitle(process_language_string_save("{$index}-title", 2));
        $image->setDesc(process_language_string_save("{$index}-desc", EDITOR_SANITIZE_LEVEL));
        if (isset($_POST[$index . '-oldrotation']) && isset($_POST[$index . '-rotation'])) {
            $oldrotation = (int) $_POST[$index . '-oldrotation'];
            $rotation = (int) $_POST[$index . '-rotation'];
            if ($rotation != $oldrotation) {
                $image->set('EXIFOrientation', $rotation);
                $image->updateDimensions();
                $album = $image->getAlbum();
                Gallery::clearCache(SERVERCACHE . '/' . $album->name);
            }
        }
        if (!$massedit) {
            $image->setLocation(process_language_string_save("{$index}-location", 3));
            $image->setCity(process_language_string_save("{$index}-city", 3));
            $image->setState(process_language_string_save("{$index}-state", 3));
            $image->setCountry(process_language_string_save("{$index}-country", 3));
            $image->setCredit(process_language_string_save("{$index}-credit", 1));
            $image->setCopyright(process_language_string_save("{$index}-copyright", 1));
            $tagsprefix = 'tags_' . $index . '-';
            $tags = array();
            $l = strlen($tagsprefix);
            foreach ($_POST as $key => $value) {
                $key = postIndexDecode($key);
                if (substr($key, 0, $l) == $tagsprefix) {
                    if ($value) {
                        $tags[] = sanitize(substr($key, $l));
                    }
                }
            }
            $tags = array_unique($tags);
            $image->setTags($tags);
            if (zp_loggedin(CODEBLOCK_RIGHTS)) {
                $image->setCodeblock(processCodeblockSave($index));
            }
            $custom = process_language_string_save("{$index}-custom_data", 1);
            $image->setCustomData(zp_apply_filter('save_image_custom_data', $custom, $index));
        }
        $image->setDateTime(sanitize($_POST["{$index}-date"]));
        $image->setShow(isset($_POST["{$index}-Visible"]));
        $image->setCommentsAllowed(isset($_POST["{$index}-allowcomments"]));
        if (isset($_POST["reset_hitcounter{$index}"])) {
            $image->set('hitcounter', 0);
        }
        $wmt = sanitize($_POST["{$index}-image_watermark"], 3);
        $image->setWatermark($wmt);
        $wmuse = 0;
        if (isset($_POST['wm_image-' . $index])) {
            $wmuse = $wmuse | WATERMARK_IMAGE;
        }
        if (isset($_POST['wm_thumb-' . $index])) {
            $wmuse = $wmuse | WATERMARK_THUMB;
        }
        if (isset($_POST['wm_full-' . $index])) {
            $wmuse = $wmuse | WATERMARK_FULL;
        }
        $image->setWMUse($wmuse);
        if (isset($_POST[$index . '-owner'])) {
            $image->setOwner(sanitize($_POST[$index . '-owner']));
        }
        $image->set('filesize', filesize($image->localpath));
        zp_apply_filter('save_image_utilities_data', $image, $index);
        $image->save();
        // Process move/copy/rename
        $folder = $image->getAlbumName();
        if ($movecopyrename_action == 'move') {
            $dest = sanitize_path($_POST[$index . '-albumselect']);
            if ($dest && $dest != $folder) {
                if ($e = $image->move($dest)) {
                    $notify = "&mcrerr=" . $e;
                }
            } else {
                // Cannot move image to same album.
                $notify = "&mcrerr=2";
            }
        } else {
            if ($movecopyrename_action == 'copy') {
                $dest = sanitize_path($_POST[$index . '-albumselect']);
                if ($dest && $dest != $folder) {
                    if ($e = $image->copy($dest)) {
                        $notify = "&mcrerr=" . $e;
                    }
                } else {
                    // Cannot copy image to existing album.
                    // Or, copy with rename?
                    $notify = "&mcrerr=2";
                }
            } else {
                if ($movecopyrename_action == 'rename') {
                    $renameto = sanitize_path($_POST[$index . '-renameto']);
                    if ($e = $image->rename($renameto)) {
                        $notify = "&mcrerr=" . $e;
                    }
                }
            }
        }
    }
    return $notify;
}
Exemplo n.º 6
0
     if ($st == 'manual' || $st == 'random') {
         $_zp_gallery->setSortDirection(false);
     } else {
         $_zp_gallery->setSortDirection(isset($_POST['gallery_sortdirection']));
     }
     foreach ($_POST as $item => $value) {
         if (strpos($item, 'gallery-page_') === 0) {
             $encoded = substr($item, 13);
             $item = sanitize(postIndexDecode($encoded));
             $_zp_gallery->setUnprotectedPage($item, (int) isset($_POST['gallery_page_unprotected_' . $encoded]));
         }
     }
     $_zp_gallery->setSecurity(sanitize($_POST['gallery_security'], 3));
     $notify = processCredentials($_zp_gallery);
     if (zp_loggedin(CODEBLOCK_RIGHTS)) {
         processCodeblockSave(0, $_zp_gallery);
     }
     $_zp_gallery->save();
     $returntab = "&tab=gallery";
 }
 /*		 * * Search options ** */
 if (isset($_POST['savesearchoptions'])) {
     $fail = '';
     $search = new SearchEngine();
     if (isset($_POST['SEARCH_list'])) {
         $searchfields = sanitize($_POST['SEARCH_list']);
     } else {
         $searchfields = array();
     }
     natcasesort($searchfields);
     setOption('search_fields', implode(',', $searchfields));