コード例 #1
0
 /**
  * duplicates an article
  * @param string $newtitle the title for the new article
  */
 function copy($newtitle)
 {
     $newID = $newtitle;
     $id = parent::copy(array('titlelink' => $newID));
     if (!$id) {
         $newID = $newtitle . ':' . seoFriendly(date('Y-m-d_H-i-s'));
         $id = parent::copy(array('titlelink' => $newID));
     }
     if ($id) {
         $newobj = new ZenpageNews($newID);
         $newobj->setTitle($newtitle);
         $newobj->setTags($this->getTags());
         $newobj->save();
         $categories = array();
         foreach ($this->getCategories() as $cat) {
             $categories[] = $cat['cat_id'];
         }
         $result = query_full_array("SELECT * FROM " . prefix('news_categories') . " ORDER BY titlelink");
         foreach ($result as $cat) {
             if (in_array($cat['id'], $categories)) {
                 query("INSERT INTO " . prefix('news2cat') . " (cat_id, news_id) VALUES ('" . $cat['id'] . "', '" . $id . "')");
             }
         }
         return $newobj;
     }
     return false;
 }
コード例 #2
0
function makeArticle($class, $text)
{
    global $unique;
    $unique++;
    $i = strpos($text, '</a>');
    $j = strpos($text, '</h4>');
    $h4 = substr($text, $i + 4, $j - $i - 4);
    $text = substr($text, $j + 5);
    $text = str_replace('<hr />', '', $text);
    $text = str_replace('<hr/>', '', $text);
    $ts_news = new ZenpageNews(seoFriendly($class . '_' . trim(truncate_string(strip_tags($h4), 30, '')) . '_' . $unique), true);
    $ts_news->setShow(0);
    $ts_news->setDateTime(date('Y-m-d H:i:s'));
    $ts_news->setAuthor('TSGenerator');
    $ts_news->setTitle($h4);
    $ts_news->setContent($text);
    $ts_news->setCategories(array());
    $ts_news->setCategories(array('troubleshooting', 'troubleshooting-' . $class));
    $ts_news->save();
}
コード例 #3
0
ファイル: lib-auth.php プロジェクト: ariep/ZenPhoto20-DEV
 /**
  * Creates a "prime" album for the user. Album name is based on the userid
  */
 function createPrimealbum($new = true, $name = NULL)
 {
     //	create his album
     $t = 0;
     $ext = '';
     if (is_null($name)) {
         $filename = internalToFilesystem(str_replace(array('<', '>', ':', '"' . '/' . '\\', '|', '?', '*'), '_', seoFriendly($this->getUser())));
     } else {
         $filename = internalToFilesystem(str_replace(array('<', '>', ':', '"' . '/' . '\\', '|', '?', '*'), '_', $name));
     }
     while ($new && file_exists(ALBUM_FOLDER_SERVERPATH . $filename . $ext)) {
         $t++;
         $ext = '-' . $t;
     }
     $path = ALBUM_FOLDER_SERVERPATH . $filename . $ext;
     $albumname = filesystemToInternal($filename . $ext);
     if (@mkdir_recursive($path, FOLDER_MOD)) {
         $album = newAlbum($albumname);
         if ($title = $this->getName()) {
             $album->setTitle($title);
         }
         $album->save();
         $this->setAlbum($album);
         $this->setRights($this->getRights() | ALBUM_RIGHTS);
         if (getOption('user_album_edit_default')) {
             $subrights = MANAGED_OBJECT_RIGHTS_EDIT;
         } else {
             $subrights = 0;
         }
         if ($this->getRights() & UPLOAD_RIGHTS) {
             $subrights = $subrights | MANAGED_OBJECT_RIGHTS_UPLOAD;
         }
         $objects = $this->getObjects();
         $objects[] = array('data' => $albumname, 'name' => $albumname, 'type' => 'album', 'edit' => $subrights);
         $this->setObjects($objects);
     }
 }
コード例 #4
0
ファイル: menu_manager.php プロジェクト: ariep/ZenPhoto20-DEV
/**
 * Creates a menu set from the items passed. But only if the menu set does not already exist
 * @param array $menuitems items for the menuset
 * 		array elements:
 * 			'type'=>menuset type
 * 			'title'=>title for the menu item
 * 			'link'=>URL or other data for the item link
 * 			'show'=>set to 1:"visible" or 0:"hidden",
 * 			'nesting'=>nesting level of this item in the menu heirarchy
 *
 * @param string $menuset current menuset
 */
function createMenuIfNotExists($menuitems, $menuset = 'default')
{
    $count = db_count('menu', 'WHERE menuset=' . db_quote($menuset));
    if ($count == 0) {
        // there was not an existing menu set
        require_once dirname(__FILE__) . '/menu_manager/menu_manager-admin-functions.php';
        $success = 1;
        $orders = array();
        foreach ($menuitems as $key => $result) {
            if (array_key_exists('nesting', $result)) {
                $nesting = $result['nesting'];
            } else {
                $nesting = 0;
            }
            while ($nesting + 1 < count($orders)) {
                array_pop($orders);
            }
            while ($nesting + 1 > count($orders)) {
                array_push($orders, -1);
            }
            $result['id'] = 0;
            if (isset($result['include_li'])) {
                $includeli = $result['include_li'];
            } else {
                $includeli = 1;
            }
            $type = $result['type'];
            switch ($type) {
                case 'all_items':
                    $orders[$nesting]++;
                    query("INSERT INTO " . prefix('menu') . " (`title`,`link`,`type`,`show`,`menuset`,`sort_order`) " . "VALUES ('" . gettext('Home') . "', '" . WEBPATH . '/' . "','galleryindex','1'," . db_quote($menuset) . ',' . db_quote($orders), true);
                    $orders[$nesting] = addAlbumsToDatabase($menuset, $orders);
                    if (extensionEnabled('zenpage')) {
                        $orders[$nesting]++;
                        query("INSERT INTO " . prefix('menu') . " (title`,`link`,`type`,`show`,`menuset`,`sort_order`) " . "VALUES ('" . gettext('News index') . "', '" . getNewsIndexURL() . "','newsindex','1'," . db_quote($menuset) . ',' . db_quote(sprintf('%03u', $base + 1)), true);
                        $orders[$nesting] = addPagesToDatabase($menuset, $orders) + 1;
                        $orders[$nesting] = addCategoriesToDatabase($menuset, $orders);
                    }
                    $type = false;
                    break;
                case 'all_albums':
                    $orders[$nesting]++;
                    $orders[$nesting] = addAlbumsToDatabase($menuset, $orders);
                    $type = false;
                    break;
                case 'all_Pages':
                    $orders[$nesting]++;
                    $orders[$nesting] = addPagesToDatabase($menuset, $orders);
                    $type = false;
                    break;
                case 'all_categorys':
                    $orders[$nesting]++;
                    $orders[$nesting] = addCategoriesToDatabase($menuset, $orders);
                    $type = false;
                    break;
                case 'album':
                    $result['title'] = NULL;
                    if (empty($result['link'])) {
                        $success = -1;
                        debugLog(sprintf(gettext('createMenuIfNotExists item %s has an empty link.'), $key));
                    }
                    break;
                case 'galleryindex':
                    $result['link'] = NULL;
                    if (empty($result['title'])) {
                        $success = -1;
                        debugLog(sprintf(gettext('createMenuIfNotExists item %s has an empty title.'), $key));
                    }
                    break;
                case 'Page':
                    $result['title'] = NULL;
                    if (empty($result['link'])) {
                        $success = -1;
                        debugLog(sprintf(gettext('createMenuIfNotExists item %s has an empty link.'), $key));
                    }
                    break;
                case 'newsindex':
                    $result['link'] = NULL;
                    if (empty($result['title'])) {
                        $success = -1;
                        debugLog(sprintf(gettext('createMenuIfNotExists item %s has an empty title.'), $key));
                    }
                    break;
                case 'category':
                    $result['title'] = NULL;
                    if (empty($result['link'])) {
                        $success = -1;
                        debugLog(sprintf(gettext('createMenuIfNotExists item %s has an empty link.'), $key));
                    }
                    break;
                case 'custompage':
                    if (empty($result['title']) || empty($result['link'])) {
                        $success = -1;
                        debugLog(sprintf(gettext('createMenuIfNotExists item %s has an empty title or link.'), $key));
                    }
                    break;
                case 'customlink':
                    if (empty($result['title'])) {
                        $success = -1;
                        debugLog(sprintf(gettext('createMenuIfNotExists item %s has an empty title.'), $key));
                    } else {
                        if (empty($result['link'])) {
                            $result['link'] = seoFriendly(get_language_string($result['title']));
                        }
                    }
                    break;
                case 'menulabel':
                    if (empty($result['title'])) {
                        $success = -1;
                        debugLog(sprintf(gettext('createMenuIfNotExists item %s has an empty title.'), $key));
                    }
                    $result['link'] = sha1($result['title']);
                    break;
                case 'menufunction':
                    if (empty($result['title']) || empty($result['link'])) {
                        $success = -1;
                        debugLog(sprintf(gettext('createMenuIfNotExists item %s has an empty title or link.'), $key));
                    }
                    break;
                case 'html':
                    if (empty($result['title']) || empty($result['link'])) {
                        $success = -1;
                        debugLog(sprintf(gettext('createMenuIfNotExists item %s has an empty title or link.'), $key));
                    }
                    break;
                default:
                    $success = -1;
                    debugLog(sprintf(gettext('createMenuIfNotExists item %s has an invalid type.'), $key));
                    break;
            }
            if ($success > 0 && $type) {
                $orders[$nesting]++;
                $sort_order = '';
                for ($i = 0; $i < count($orders); $i++) {
                    $sort_order .= sprintf('%03u', $orders[$i]) . '-';
                }
                $sort_order = substr($sort_order, 0, -1);
                $sql = "INSERT INTO " . prefix('menu') . " (`title`,`link`,`type`,`show`,`menuset`,`sort_order`,`include_li`) " . "VALUES (" . db_quote($result['title']) . ", " . db_quote($result['link']) . "," . db_quote($result['type']) . "," . $result['show'] . "," . db_quote($menuset) . "," . db_quote($sort_order) . ",{$includeli})";
                if (!query($sql, false)) {
                    $success = -2;
                    debugLog(sprintf(gettext('createMenuIfNotExists item %1$s query (%2$s) failed: %3$s.'), $key, $sql, db_error()));
                }
            }
        }
    } else {
        $success = 0;
    }
    if ($success < 0) {
        zp_error(gettext('createMenuIfNotExists has posted processing errors to your debug log.'), E_USER_NOTICE);
    }
    return $success;
}
コード例 #5
0
ファイル: uploader.php プロジェクト: rb26/zenphoto
 private function handle_file_upload($uploaded_file, $name, $size, $type, $error)
 {
     global $folder, $targetPath, $_zp_current_admin_obj;
     $file = new stdClass();
     $name = $this->trim_file_name($name, $type);
     $seoname = seoFriendly($name);
     if (strrpos($seoname, '.') === 0) {
         $seoname = sha1($name) . $seoname;
     }
     // soe stripped out all the name.
     $targetFile = $targetPath . '/' . internalToFilesystem($seoname);
     if (file_exists($targetFile)) {
         $append = '_' . time();
         $seoname = stripSuffix($seoname) . $append . '.' . getSuffix($seoname);
         $targetFile = $targetPath . '/' . internalToFilesystem($seoname);
     }
     $file->name = $seoname;
     $file->size = intval($size);
     $file->type = $type;
     $error = $this->has_error($uploaded_file, $file, $error);
     if (!$error && $file->name) {
         $file_path = $this->options['upload_dir'] . $file->name;
         $append_file = !$this->options['discard_aborted_uploads'] && is_file($file_path) && $file->size > filesize($file_path);
         clearstatcache();
         if ($uploaded_file && is_uploaded_file($uploaded_file)) {
             // multipart/formdata uploads (POST method uploads)
             if ($append_file) {
                 file_put_contents($file_path, fopen($uploaded_file, 'r'), FILE_APPEND);
             } else {
                 move_uploaded_file($uploaded_file, $file_path);
                 if (Gallery::validImage($name) || Gallery::validImageAlt($name)) {
                     @chmod($targetFile, FILE_MOD);
                     $album = newAlbum($folder);
                     $image = newImage($album, $seoname);
                     $image->setOwner($_zp_current_admin_obj->getUser());
                     if ($name != $seoname && $image->getTitle() == substr($seoname, 0, strrpos($seoname, '.'))) {
                         $image->setTitle(stripSuffix($name, '.'));
                     }
                     $image->save();
                 } else {
                     if (is_zip($targetFile)) {
                         unzip($targetFile, $targetPath);
                         unlink($targetFile);
                     } else {
                         $file->error = $error = UPLOAD_ERR_EXTENSION;
                         // invalid file uploaded
                     }
                 }
             }
         } else {
             // Non-multipart uploads (PUT method support)
             file_put_contents($file_path, fopen('php://input', 'r'), $append_file ? FILE_APPEND : 0);
         }
         $file_size = filesize($file_path);
         if ($file_size === $file->size) {
             $file->url = $this->options['upload_url'] . rawurlencode($file->name);
             foreach ($this->options['image_versions'] as $version => $options) {
                 if ($this->create_scaled_image($file->name, $options)) {
                     $file->{$version . '_url'} = $options['upload_url'] . rawurlencode($file->name);
                 }
             }
         } else {
             if ($this->options['discard_aborted_uploads']) {
                 @chmod($file_path, 0777);
                 unlink($file_path);
                 $file->error = 'abort';
             }
         }
         $file->size = $file_size;
         $file->delete_url = $this->options['script_url'] . '?file=' . rawurlencode($file->name);
         $file->delete_type = 'DELETE';
     } else {
         $file->error = $error;
     }
     return $file;
 }
コード例 #6
0
/**
 * Gets the RSS file name from the feed url and clears out query items and special chars
 *
 * @return string
 */
function getRSSCacheFilename()
{
    $uri = explode('?', $_SERVER["REQUEST_URI"]);
    $filename = array();
    foreach (explode('&', $uri[1]) as $param) {
        $p = explode('=', $param);
        if (isset($p[1]) && !empty($p[1])) {
            $filename[] = $p[1];
        } else {
            $filename[] = $p[0];
        }
    }
    $filename = seoFriendly(implode('_', $filename));
    return $filename . ".xml";
    //old way
    $replace = array(WEBPATH . '/' => '', "albumname=" => "_", "albumsmode=" => "_", "title=" => "_", "folder=" => "_", "type=" => "-", "albumtitle=" => "_", "category=" => "_", "id=" => "_", "lang=" => "_", "&amp;" => "_", "&" => "_", "index.php" => "", "/" => "-", "?" => "");
    $filename = strtr($_SERVER["REQUEST_URI"], $replace);
    $filename = preg_replace("/__/", "_", $filename);
    $filename = seoFriendly($filename);
    return $filename . ".xml";
}
コード例 #7
0
ファイル: uploader.php プロジェクト: hatone/zenphoto-1.4.1.4
         exit;
     }
 }
 if ($new) {
     mkdir_recursive($targetPath, CHMOD_VALUE);
     $album = new Album($gallery, $folder);
     $album->setShow($_POST['http_publishalbum']);
     $album->setTitle(sanitize($_POST['http_albumtitle']));
     $album->setOwner($_zp_current_admin_obj->getUser());
     $album->save();
 }
 @chmod($targetPath, CHMOD_VALUE);
 $error = zp_apply_filter('check_upload_quota', UPLOAD_ERR_OK, $tempFile);
 if (!$error) {
     if (is_valid_image($name) || is_valid_other_type($name)) {
         $seoname = seoFriendly($name);
         if (strrpos($seoname, '.') === 0) {
             $seoname = sha1($name) . $seoname;
         }
         // soe stripped out all the name.
         $targetFile = $targetPath . '/' . internalToFilesystem($seoname);
         if (file_exists($targetFile)) {
             $append = '_' . time();
             $seoname = stripSuffix($seoname) . $append . '.' . getSuffix($seoname);
             $targetFile = $targetPath . '/' . internalToFilesystem($seoname);
         }
         if (move_uploaded_file($tempFile, $targetFile)) {
             @chmod($targetFile, 0666 & CHMOD_VALUE);
             $album = new Album($gallery, $folder);
             $image = newImage($album, $seoname);
             $image->setOwner($_zp_current_admin_obj->getUser());
コード例 #8
0
 /**
  * duplicates an article
  * @param string $newtitle the title for the new article
  */
 function copy($newtitle)
 {
     $newID = $newtitle;
     $id = parent::copy(array('titlelink' => $newID));
     if (!$id) {
         $newID = $newtitle . ':' . seoFriendly(date('Y-m-d_H-i-s'));
         $id = parent::copy(array('titlelink' => $newID));
     }
     if ($id) {
         $newobj = new ZenpagePage($newID);
         $newobj->setTitle($newtitle);
         $newobj->setSortOrder(NULL);
         $newobj->setTags($this->getTags());
         $newobj->save();
         return $newobj;
     }
     return false;
 }
コード例 #9
0
 /**
  * duplicates a category
  * @param string $newtitle the title for the new category
  */
 function copy($newtitle)
 {
     $newID = $newtitle;
     $id = parent::copy(array('titlelink' => $newID));
     if (!$id) {
         $newID = $newtitle . ':' . seoFriendly(date('Y-m-d_H-i-s'));
         $id = parent::copy(array('titlelink' => $newID));
     }
     if ($id) {
         $newobj = newCategory($newID);
         $newobj->setTitle($newtitle);
         $newobj->setSortOrder(NULL);
         $newobj->setDateTime(date('Y-m-d H:i:s'));
         $newobj->setShow(1);
         $newobj->save();
         return $newobj;
     }
     return false;
 }
コード例 #10
0
ファイル: lib-auth.php プロジェクト: hatone/zenphoto-1.4.1.4
 /**
  * Creates a "prime" album for the user. Album name is based on the userid
  */
 function createPrimealbum()
 {
     //	create his album
     $t = 0;
     $ext = '';
     $filename = str_replace(array('<', '>', ':', '"' . '/' . '\\', '|', '?', '*'), '_', seoFriendly($this->getUser()));
     while (file_exists(ALBUM_FOLDER_SERVERPATH . '/' . $filename . $ext)) {
         $t++;
         $ext = '-' . $t;
     }
     $path = ALBUM_FOLDER_SERVERPATH . '/' . $filename . $ext;
     if (@mkdir_recursive($path, CHMOD_VALUE)) {
         $album = new Album(new Gallery(), $filename . $ext);
         $album->save();
         $this->setAlbum($album);
         $objects = $this->getObjects();
         $objects[] = array('data' => $filename . $ext, 'name' => $filename . $ext, 'type' => 'album');
         $this->setObjects($objects);
     }
 }
コード例 #11
0
zp_apply_filter('admin_note', 'albums', 'dynamic');
echo "<h1>" . gettext("Create Dynamic Album") . "</h1>\n";
if (isset($_POST['savealbum'])) {
    // we fell through, some kind of error
    echo "<div class=\"errorbox space\">";
    echo "<h2>" . $msg . "</h2>";
    echo "</div>\n";
}
$albumlist = array();
genAlbumList($albumlist);
$fields = $search->fieldList;
$words = $search->codifySearchString();
if (isset($_GET['name'])) {
    $albumname = sanitize($_GET['name']);
} else {
    $albumname = seoFriendly(sanitize_path($words));
    $old = '';
    while ($old != $albumname) {
        $old = $albumname;
        $albumname = str_replace('--', '-', $albumname);
    }
}
$images = $search->getImages(0);
foreach ($images as $image) {
    $folder = $image['folder'];
    $filename = $image['filename'];
    $imagelist[] = '/' . $folder . '/' . $filename;
}
$subalbums = $search->getAlbums(0);
foreach ($subalbums as $folder) {
    getSubalbumImages($folder);
コード例 #12
0
/**
 * Unzips an image archive
 *
 * @param file $file the archive
 * @param string $dir where the images go
 */
function unzip($file, $dir)
{
    //check if zziplib is installed
    if (function_exists('zip_open')) {
        $zip = zip_open($file);
        if ($zip) {
            while ($zip_entry = zip_read($zip)) {
                // Skip non-images in the zip file.
                $fname = zip_entry_name($zip_entry);
                $seoname = internalToFilesystem(seoFriendly($fname));
                if (Gallery::validImage($seoname) || Gallery::validImageAlt($seoname)) {
                    if (zip_entry_open($zip, $zip_entry, "r")) {
                        $buf = zip_entry_read($zip_entry, zip_entry_filesize($zip_entry));
                        $path_file = str_replace("/", DIRECTORY_SEPARATOR, $dir . '/' . $seoname);
                        $fp = fopen($path_file, "w");
                        fwrite($fp, $buf);
                        fclose($fp);
                        clearstatcache();
                        zip_entry_close($zip_entry);
                        $albumname = substr($dir, strlen(ALBUM_FOLDER_SERVERPATH));
                        $album = newAlbum($albumname);
                        $image = newImage($album, $seoname);
                        if ($fname != $seoname) {
                            $image->setTitle($fname);
                            $image->save();
                        }
                    }
                }
            }
            zip_close($zip);
        }
    } else {
        require_once dirname(__FILE__) . '/lib-pclzip.php';
        $zip = new PclZip($file);
        if ($zip->extract(PCLZIP_OPT_PATH, $dir, PCLZIP_OPT_REMOVE_ALL_PATH) == 0) {
            return false;
        }
    }
    return true;
}
コード例 #13
0
ファイル: seo_cleanup.php プロジェクト: rb26/zenphoto
 function checkFolder($album, $album_cleaned)
 {
     global $count, $albumcount;
     $subalbums = $album->getAlbums(0);
     foreach ($subalbums as $subalbum) {
         $obj = newAlbum($subalbum);
         cleanAlbum($obj);
     }
     $folder = $album->name . '/';
     $files = $album->getImages(0);
     foreach ($files as $filename) {
         $seoname = seoFriendly($filename);
         if (stripSuffix($seoname) != stripSuffix($filename)) {
             $image = newImage($album, $filename);
             if ($e = $image->rename($seoname)) {
                 $error = getE($e, $filename, $seoname);
                 printf(gettext('<em>%1$s</em> rename to <em>%2$s</em> failed: %3$s'), $folder . $filename, $seoname, $error);
                 echo "<br />\n";
             } else {
                 $image->save();
                 clearstatcache();
                 echo '&nbsp;&nbsp;';
                 printf(gettext('<em>%1$s</em> renamed to <em>%2$s</em>'), $folder . $filename, $seoname);
                 echo "<br />\n";
                 $count++;
                 if (!$album_cleaned) {
                     Gallery::clearCache(SERVERCACHE . '/' . $album->name);
                     if (extensionEnabled('static_html_cache')) {
                         Gallery::clearCache(SERVERPATH . '/' . STATIC_CACHE_FOLDER);
                     }
                 }
             }
         }
     }
 }
コード例 #14
0
ファイル: seo_cleanup.php プロジェクト: rauldobrota/zenphoto
 function checkFolder($album)
 {
     global $count, $albumcount;
     $subalbums = $album->getAlbums(0);
     foreach ($subalbums as $subalbum) {
         $obj = newAlbum($subalbum);
         cleanAlbum($obj);
     }
     $folder = $album->name . '/';
     $files = $album->getImages(0);
     foreach ($files as $filename) {
         $seoname = seoFriendly($filename);
         if (stripSuffix($seoname) != stripSuffix($filename)) {
             $image = newImage($album, $filename);
             if ($e = $image->rename($seoname)) {
                 $error = getE($e, $filename, $seoname);
                 printf(gettext('<em>%1$s</em> rename to <em>%2$s</em> failed: %3$s'), $folder . $filename, $seoname, $error);
                 echo "<br />\n";
             } else {
                 $image->save();
                 clearstatcache();
                 echo '&nbsp;&nbsp;';
                 printf(gettext('<em>%1$s</em> renamed to <em>%2$s</em>'), $folder . $filename, $seoname);
                 echo "<br />\n";
                 $count++;
             }
         }
     }
 }
コード例 #15
0
 /**
  *
  * Creates the news article
  * @param object $obj
  */
 protected static function publishArticle($obj, $override = NULL)
 {
     global $_zp_CMS;
     $galleryitem_text = array();
     $locale = getOption('locale');
     switch ($type = $obj->table) {
         case 'albums':
             $album = $obj->name;
             $dbstring = getOption('galleryArticles_album_text');
             $localtext = get_language_string($dbstring);
             $galleryitem_text[$locale] = sprintf($localtext, $obj->getTitle($locale));
             foreach (generateLanguageList() as $key) {
                 $languagetext = get_language_string($dbstring, $key);
                 if ($localtext != $languagetext) {
                     $galleryitem_text[$key] = sprintf($languagetext, $obj->getTitle($key));
                 }
             }
             $ref = '"' . $album . '"';
             $title = $folder = $album;
             $img = $obj->getAlbumThumbImage();
             $class = 'galleryarticles-newalbum';
             break;
         case 'images':
             $album = $obj->album->name;
             $image = $obj->filename;
             $dbstring = unserialize(getOption('galleryArticles_image_text'));
             $localtext = get_language_string($dbstring);
             $galleryitem_text[$locale] = sprintf($localtext, $obj->getTitle($locale), $obj->album->getTitle($locale));
             foreach (generateLanguageList() as $key => $val) {
                 $languagetext = get_language_string($dbstring, $key);
                 if ($localtext != $languagetext) {
                     $galleryitem_text[$key] = sprintf($localtext, $obj->getTitle($key), $obj->album->getTitle($key));
                 }
             }
             $ref = '"' . $album . '" "' . $image . '"';
             $folder = $obj->imagefolder;
             $title = $folder . '-' . $image;
             $img = $obj;
             $class = 'galleryarticles-newimage';
             break;
         default:
             //not a gallery object
             return;
     }
     $article = newArticle(seoFriendly('galleryArticles-' . $title));
     $article->setTitle(serialize($galleryitem_text));
     $imglink = $img->getCustomImage(getOption('galleryArticles_size'), NULL, NULL, NULL, NULL, NULL, NULL, -1);
     $desc = '<p><a class="' . $class . '" href="' . $obj->getLink() . '"><img src="' . $imglink . '"></a></p><p>[GALLERYARTICLEDESC ' . $ref . ']</p>';
     $article->setContent($desc);
     $date = $obj->getPublishDate();
     if (!$date) {
         $date = date('Y-m-d H:i:s');
     }
     $article->setDateTime($date);
     $article->setLastchange(date('Y-m-d H:i:s'));
     $article->setAuthor('galleryArticles');
     $article->setLastchangeauthor('galleryArticles');
     $article->setShow(true);
     $article->save();
     if ($override) {
         $cat = $override;
     } else {
         $cat = getOption('galleryArticles_category');
         if (getOption('galleryArticles_albumCategory')) {
             $catlist = $_zp_CMS->getAllCategories();
             foreach ($catlist as $category) {
                 if ($category['titlelink'] == $folder) {
                     $cat = $category['titlelink'];
                     break;
                 }
             }
         }
     }
     $article->setCategories(array($cat));
 }
コード例 #16
0
function checkFolder($folder)
{
    global $albums, $gallery, $count, $albumcount;
    $files = scandir(ALBUM_FOLDER_SERVERPATH . '/' . $folder);
    $display = true;
    if (!empty($folder)) {
        $album = new Album($gallery, filesystemToInternal($folder));
    }
    foreach ($files as $file) {
        $file = str_replace('\\', '/', $file);
        $key = str_replace(SERVERPATH . '/', '', $folder . '/' . $file);
        if (is_dir(ALBUM_FOLDER_SERVERPATH . $folder . '/' . $file) && $file != '..' && $file != '.') {
            if (empty($folder)) {
                $albumname = $file;
            } else {
                $albumname = $folder . '/' . $file;
            }
            checkFolder($albumname);
        } else {
            if (is_valid_image($file) || is_valid_other_type($file)) {
                $filename = internalToFilesystem($file);
                $seoname = seoFriendly($filename);
                if ($seoname != $filename) {
                    $old = filesystemToInternal($file);
                    $image = newImage($album, $old);
                    if (!($e = $image->rename($seoname))) {
                        if ($display) {
                            echo '<p>' . filesystemToInternal($folder) . "</p>\n";
                            $display = false;
                        }
                        echo '&nbsp;&nbsp;';
                        printf(gettext('<em>%1$s</em> renamed to <em>%2$s</em>'), $old, $seoname);
                        echo "<br />\n";
                        $count++;
                        ?>
						<script type="text/javascript">
						<!--
							imagecount = <?php 
                        echo $count;
                        ?>
;
						//-->
						</script>
						<?php 
                    }
                }
            }
        }
    }
    if (!empty($folder)) {
        $albumname = internalToFilesystem($folder);
        $file = basename($albumname);
        $seoname = seoFriendly($file);
        if ($seoname != $file) {
            $newname = dirname($albumname);
            if (empty($newname) || $newname == '.') {
                $newname = $seoname;
            } else {
                $newname .= '/' . $seoname;
            }
            if (!$album->rename($newname)) {
                printf(gettext('<em>%1$s</em> renamed to <em>%2$s</em>'), $albumname, $newname);
                echo "<br />\n";
                $albumcount++;
                ?>
				<script type="text/javascript">
				<!--
					albumcount = <?php 
                echo $albumcount;
                ?>
;
				//-->
				</script>
				<?php 
            }
        }
    }
}
コード例 #17
0
ファイル: uploader.php プロジェクト: rb26/zenphoto
         $album->setTitle($title);
     }
     if ($new) {
         $album->setOwner($_zp_current_admin_obj->getUser());
     }
     $album->save();
 } else {
     $AlbumDirName = str_replace(SERVERPATH, '', $_zp_gallery->albumdir);
     zp_error(gettext("The album could not be created in the “albums” folder. This is usually a permissions problem. Try setting the permissions on the “albums” and “cache” folders to be world-writable using a shell:") . " <code>chmod 777 " . $AlbumDirName . '/' . CACHEFOLDER . '/' . "</code>, " . gettext("or use your FTP program to give everyone write permissions to those folders."));
 }
 foreach ($_FILES['files']['error'] as $key => $error) {
     $filecount++;
     if ($error == UPLOAD_ERR_OK) {
         $tmp_name = $_FILES['files']['tmp_name'][$key];
         $name = sanitize_path($_FILES['files']['name'][$key]);
         $soename = seoFriendly($name);
         $error = zp_apply_filter('check_upload_quota', UPLOAD_ERR_OK, $tmp_name);
         if (!$error) {
             if (Gallery::validImage($name) || Gallery::validImageAlt($name)) {
                 if (strrpos($soename, '.') === 0) {
                     $soename = md5($name) . $soename;
                 }
                 // soe stripped out all the name.
                 if (!$error) {
                     $uploadfile = $targetPath . '/' . internalToFilesystem($soename);
                     if (file_exists($uploadfile)) {
                         $append = '_' . time();
                         $soename = stripSuffix($soename) . $append . '.' . getSuffix($soename);
                         $uploadfile = $targetPath . '/' . internalToFilesystem($soename);
                     }
                     move_uploaded_file($tmp_name, $uploadfile);
コード例 #18
0
 /**
  *
  * Formats the message and calls sendTweet() on an object
  * @param object $obj
  */
 private static function publishArticle($obj, $override = NULL)
 {
     global $_zp_zenpage;
     $galleryitem_text = array();
     switch ($type = $obj->table) {
         case 'albums':
             if (getOption('multi_lingual')) {
                 $option_text = unserialize(getOption('galleryArticles_album_text'));
                 foreach ($option_text as $key => $val) {
                     $galleryitem_text[$key] = sprintf($option_text[$key], $obj->getTitle($key));
                 }
                 $text = serialize($galleryitem_text);
             } else {
                 $text = sprintf(get_language_string(getOption('galleryArticles_album_text')), $obj->getTitle());
             }
             $title = $folder = $obj->name;
             $img = $obj->getAlbumThumbImage();
             $class = 'galleryarticles-newalbum';
             break;
         case 'images':
             if (getOption('multi_lingual')) {
                 $option_text = unserialize(getOption('galleryArticles_image_text'));
                 foreach ($option_text as $key => $val) {
                     $galleryitem_text[$key] = sprintf($option_text[$key], $obj->getTitle($key), $obj->album->getTitle($key));
                 }
                 $text = serialize($galleryitem_text);
             } else {
                 $text = sprintf(get_language_string(getOption('galleryArticles_image_text')), $obj->getTitle(), $obj->album->getTitle());
             }
             $folder = $obj->imagefolder;
             $title = $folder . '-' . $obj->filename;
             $img = $obj;
             $class = 'galleryarticles-newimage';
             break;
     }
     $article = new ZenpageNews(seoFriendly('galleryArticles-' . $title));
     $article->setTitle($text);
     $imglink = $img->getCustomImage(getOption('galleryArticles_size'), NULL, NULL, NULL, NULL, NULL, NULL, -1);
     if (getOption('multi_lingual')) {
         $desc = '';
         foreach ($option_text as $key => $val) {
             $desc[$key] = '<p><a class="' . $class . '" href="' . $obj->getLink() . '"><img src="' . $imglink . '"></a></p><p>' . $obj->getDesc($key) . '</p>';
         }
         $desc = serialize($desc);
     } else {
         $desc = '<p><a class="' . $class . '" href="' . $obj->getLink() . '"><img src="' . $imglink . '"></a></p><p>' . $obj->getDesc() . '</p>';
     }
     $article->setContent($desc);
     $article->setShow(true);
     $date = $obj->getPublishDate();
     if (!$date) {
         $date = date('Y-m-d H:i:s');
     }
     $article->setDateTime($date);
     $article->setAuthor('galleryArticles');
     $article->save();
     if ($override) {
         $cat = $override;
     } else {
         $cat = getOption('galleryArticles_category');
         if (getOption('galleryArticles_albumCategory')) {
             $catlist = $_zp_zenpage->getAllCategories();
             foreach ($catlist as $category) {
                 if ($category['titlelink'] == $folder) {
                     $cat = $category['titlelink'];
                     break;
                 }
             }
         }
     }
     $article->setCategories(array($cat));
 }
コード例 #19
0
/**
 * Updates a category
 *
 */
function updateCategory(&$reports)
{
    $date = date('Y-m-d_H-i-s');
    $id = sanitize_numeric($_POST['id']);
    $permalink = getcheckboxState('permalink');
    $title = process_language_string_save("title", 2);
    $desc = process_language_string_save("desc", 0);
    $custom = process_language_string_save("custom_data", 1);
    $titlelink = $oldtitlelink = sanitize($_POST['titlelink-old'], 3);
    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 link to change
            $link = seoFriendly(get_language_string($title));
            if (!empty($link)) {
                $titlelink = $link;
            }
        }
    }
    $titleok = true;
    if ($titlelink != $oldtitlelink) {
        // title link change must be reflected in DB before any other updates
        $titleok = query('UPDATE ' . prefix('news_categories') . ' SET `titlelink`=' . db_quote($titlelink) . ' WHERE `id`=' . $id, false);
        if (!$titleok) {
            $titlelink = $oldtitlelink;
            // force old link so data gets saved
        }
    } else {
        $titlelink = $oldtitlelink;
    }
    //update category
    $show = getcheckboxState('show');
    $cat = new ZenpageCategory($titlelink);
    $notice = processPasswordSave($cat);
    $cat->setPermalink(getcheckboxState('permalink'));
    $cat->set('title', $title);
    $cat->setDesc($desc);
    $cat->setCustomData(zp_apply_filter('save_category_custom_data', $custom, $cat));
    $cat->setShow($show);
    if (getcheckboxState('resethitcounter')) {
        $cat->set('hitcounter', 0);
    }
    $msg = zp_apply_filter('update_category', '', $cat, $oldtitlelink);
    $cat->save();
    if ($titleok) {
        if (empty($titlelink) or empty($title)) {
            $reports[] = "<p class='errorbox fade-message'>" . gettext("You forgot to give your category a <strong>title or titlelink</strong>!") . "</p>";
        } else {
            if ($notice == 'user') {
                $reports[] = "<p class='errorbox fade-message'>" . gettext('You must supply a password for the Protected Category user') . '</p>';
            } else {
                if ($notice == 'pass') {
                    $reports[] = "<p class='errorbox fade-message'>" . gettext('Your passwords were empty or did not match') . '</p>';
                } else {
                    $reports[] = "<p class='messagebox fade-message'>" . gettext("Category updated!") . "</p>";
                }
            }
        }
    } else {
        $reports[] = "<p class='errorbox fade-message'>" . sprintf(gettext("A category with the title/titlelink <em>%s</em> already exists!"), html_encode($cat->getTitle())) . "</p>";
    }
    if ($msg) {
        $reports[] = $msg;
    }
    return $cat;
}
コード例 #20
0
/**
 * Updates or adds a category
 *
 * @param array $reports the results display
 * @param bool $newcategory true if a new article
 *
 */
function updateCategory(&$reports, $newcategory = false)
{
    $date = date('Y-m-d_H-i-s');
    $id = sanitize_numeric($_POST['id']);
    $permalink = getcheckboxState('permalink');
    $title = process_language_string_save("title", 2);
    $desc = process_language_string_save("desc", EDITOR_SANITIZE_LEVEL);
    $custom = process_language_string_save("custom_data", 1);
    if ($newcategory) {
        $titlelink = seoFriendly(get_language_string($title));
        if (empty($titlelink)) {
            $titlelink = seoFriendly($date);
        }
        $sql = 'SELECT `id` FROM ' . prefix('news_categories') . ' 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 category title') . '</p>';
        }
        $oldtitlelink = $titlelink;
    } else {
        $titlelink = $oldtitlelink = sanitize($_POST['titlelink-old'], 3);
        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 link to change
                $link = seoFriendly(get_language_string($title));
                if (!empty($link)) {
                    $titlelink = $link;
                }
            }
        }
    }
    $titleok = true;
    if ($titlelink != $oldtitlelink) {
        // title link change must be reflected in DB before any other updates
        $titleok = query('UPDATE ' . prefix('news_categories') . ' SET `titlelink`=' . db_quote($titlelink) . ' WHERE `id`=' . $id, false);
        if (!$titleok) {
            $titlelink = $oldtitlelink;
            // force old link so data gets saved
        } else {
            SearchEngine::clearSearchCache();
        }
    }
    //update category
    $show = getcheckboxState('show');
    $cat = new ZenpageCategory($titlelink, true);
    $notice = processCredentials($cat);
    $cat->setPermalink(getcheckboxState('permalink'));
    $cat->set('title', $title);
    $cat->setDesc($desc);
    $cat->setCustomData(zp_apply_filter('save_category_custom_data', $custom, $cat));
    $cat->setShow($show);
    if (getcheckboxState('resethitcounter')) {
        $cat->set('hitcounter', 0);
    }
    if (getcheckboxState('reset_rating')) {
        $cat->set('total_value', 0);
        $cat->set('total_votes', 0);
        $cat->set('used_ips', 0);
    }
    if ($newcategory) {
        $msg = zp_apply_filter('new_category', '', $cat);
        if (empty($title)) {
            $reports[] = "<p class='errorbox fade-message'>" . sprintf(gettext("Category <em>%s</em> added but you need to give it a <strong>title</strong> before publishing!"), $titlelink) . '</p>';
        } else {
            if ($notice == '?mismatch=user') {
                $reports[] = "<p class='errorbox fade-message'>" . gettext('You must supply a password for the Protected Category user') . '</p>';
            } else {
                if ($notice) {
                    $reports[] = "<p class='errorbox fade-message'>" . gettext('Your passwords were empty or did not match') . '</p>';
                } else {
                    $reports[] = "<p class='messagebox fade-message'>" . sprintf(gettext("Category <em>%s</em> added"), $titlelink) . '</p>';
                }
            }
        }
    } else {
        $msg = zp_apply_filter('update_category', '', $cat, $oldtitlelink);
        if ($titleok) {
            if (empty($titlelink) or empty($title)) {
                $reports[] = "<p class='errorbox fade-message'>" . gettext("You forgot to give your category a <strong>title or titlelink</strong>!") . "</p>";
            } else {
                if ($notice == '?mismatch=user') {
                    $reports[] = "<p class='errorbox fade-message'>" . gettext('You must supply a password for the Protected Category user') . '</p>';
                } else {
                    if ($notice) {
                        $reports[] = "<p class='errorbox fade-message'>" . gettext('Your passwords were empty or did not match') . '</p>';
                    } else {
                        $reports[] = "<p class='messagebox fade-message'>" . gettext("Category updated!") . "</p>";
                    }
                }
            }
        } else {
            $reports[] = "<p class='errorbox fade-message'>" . sprintf(gettext("A category with the title/titlelink <em>%s</em> already exists!"), html_encode($cat->getTitle())) . "</p>";
        }
    }
    $cat->save();
    if ($msg) {
        $reports[] = $msg;
    }
    return $cat;
}
コード例 #21
0
ファイル: admin-edit.php プロジェクト: ariep/ZenPhoto20-DEV
    }
}
if (isset($_GET['titlelink'])) {
    $result = $new(urldecode(sanitize($_GET['titlelink'])));
} else {
    if (isset($_GET['update'])) {
        XSRFdefender('update');
        $result = $update($reports);
        if (getCheckboxState('copy_delete_object')) {
            switch (sanitize($_POST['copy_delete_object'])) {
                case 'copy':
                    $as = trim(sanitize($_POST['copy_object_as']));
                    if (empty($as)) {
                        $as = sprintf(gettext('copy of %s'), $result->getTitle());
                    }
                    $as = seoFriendly($as);
                    $result->copy($as);
                    $result = $new($as);
                    $_GET['titlelink'] = $as;
                    break;
                case 'delete':
                    $reports[] = deleteZenpageObj($result, 'admin-' . $_GET['tab'] . '.php');
                    unset($_POST['subpage']);
                    break;
            }
        }
        if (isset($_POST['subpage']) && $_POST['subpage'] == 'object' && count($reports) <= 1) {
            header('Location: ' . $result->getLink());
            exitZP();
        }
    } else {
コード例 #22
0
ファイル: admin-dynamic-album.php プロジェクト: rb26/zenphoto
genAlbumList($albumlist);
$fields = $search->fieldList;
$albumname = $search->getSearchWords();
$words = $search->codifySearchString();
$images = $search->getImages(0);
foreach ($images as $image) {
    $folder = $image['folder'];
    $filename = $image['filename'];
    $imagelist[] = '/' . $folder . '/' . $filename;
}
$subalbums = $search->getAlbums(0);
foreach ($subalbums as $folder) {
    getSubalbumImages($folder);
}
$albumname = sanitize_path($albumname);
$albumname = seoFriendly($albumname);
$old = '';
while ($old != $albumname) {
    $old = $albumname;
    $albumname = str_replace('--', '-', $albumname);
}
?>
<form class="dirty-check" action="?savealbum" method="post" autocomplete="off">
	<?php 
XSRFToken('savealbum');
?>
	<input type="hidden" name="savealbum" value="yes" />
	<table>
		<tr>
			<td><?php 
echo gettext("Album name:");
コード例 #23
0
ファイル: class-feed.php プロジェクト: ariep/ZenPhoto20-DEV
 /**
  * Creates a file name from the options array
  *
  * @return string
  */
 protected function getCacheFilename()
 {
     $filename = array();
     foreach ($this->options as $key => $value) {
         if (empty($value)) {
             $filename[] = $key;
         } else {
             $filename[] = $value;
         }
     }
     $filename = seoFriendly(implode('_', $filename));
     return $filename . ".xml";
 }
コード例 #24
0
<?php

require '../../zp-core/admin-functions.php';
$string = sanitize($_GET['text_watermark_text'], 3);
if (!empty($string)) {
    if (isset($_GET['transient'])) {
        header("Content-type: image/png");
        $filename = NULL;
    } else {
        $filename = dirname(dirname(__FILE__)) . '/watermarks/' . seoFriendly($string) . '.png';
    }
    $len = strlen($string);
    $font = zp_imageLoadFont(sanitize($_GET['text_watermark_font'], 3));
    $fw = zp_imageFontWidth($font);
    $fh = zp_imageFontHeight($font);
    $image = zp_createImage($fw * $len, $fh);
    $color = sanitize($_GET['text_watermark_color'], 3);
    $cr = hexdec(substr($color, 1, 2));
    $cg = hexdec(substr($color, 3, 2));
    $cb = hexdec(substr($color, 5, 2));
    $back = zp_colorAllocate($image, 255 - $cr, 255 - $cg, 255 - $cb);
    zp_imagecolortransparent($image, $back);
    zp_imagefill($image, 0, 0, $back);
    $ink = zp_colorAllocate($image, $cr, $cg, $cb);
    $l = 0;
    for ($i = 0; $i < $len; $i++) {
        zp_writeString($image, $font, $l, 0, substr($string, $i, 1), $ink);
        $l = $l + $fw;
    }
    zp_imageOutput($image, 'png', $filename);
}