/** * 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; }
function handleOption($option, $currentValue) { if ($option == "zenpage_homepage") { $unpublishedpages = query_full_array("SELECT titlelink FROM " . prefix('pages') . " WHERE `show` != 1 ORDER by `sort_order`"); if (empty($unpublishedpages)) { echo gettext("No unpublished pages available"); // clear option if no unpublished pages are available or have been published meanwhile // so that the normal gallery index appears and no page is accidentally set if set to unpublished again. setOption("zenpage_homepage", "none", true); } else { echo '<input type="hidden" name="' . CUSTOM_OPTION_PREFIX . 'selector-zenpage_homepage" value="0" />' . "\n"; echo '<select id="' . $option . '" name="zenpage_homepage">' . "\n"; if ($currentValue === "none") { $selected = " selected = 'selected'"; } else { $selected = ""; } echo "<option{$selected}>" . gettext("none") . "</option>"; foreach ($unpublishedpages as $page) { if ($currentValue === $page["titlelink"]) { $selected = " selected = 'selected'"; } else { $selected = ""; } echo "<option{$selected}>" . $page["titlelink"] . "</option>"; } echo "</select>\n"; } } }
function getOptionsSupported() { $unpublishedpages = query_full_array("SELECT title,titlelink FROM " . prefix('pages') . " WHERE `show` != 1 ORDER by `sort_order`"); $list = array(); foreach ($unpublishedpages as $page) { $list[get_language_string($page['title'])] = $page['titlelink']; } return array(gettext('Allow search') => array('key' => 'Allow_search', 'type' => OPTION_TYPE_CHECKBOX, 'desc' => gettext('Check to enable search form.')), gettext('News on index page') => array('key' => 'zenpage_zp_index_news', 'type' => OPTION_TYPE_CHECKBOX, 'desc' => gettext("Enable this if you want to show the news section’s first page on the <code>index.php</code> page.")), gettext('Homepage') => array('key' => 'zenpage_homepage', 'type' => OPTION_TYPE_SELECTOR, 'selections' => $list, 'null_selection' => gettext('none'), 'desc' => gettext("Choose here any <em>un-published Zenpage page</em> (listed by <em>titlelink</em>) to act as your site’s homepage instead the normal gallery index.") . "<p class='notebox'>" . gettext("<strong>Note:</strong> This of course overrides the <em>News on index page</em> option and your theme must be setup for this feature! Visit the theming tutorial for details.") . "</p>"), gettext('Use standard contact page') => array('key' => 'zenpage_contactpage', 'type' => OPTION_TYPE_CHECKBOX, 'desc' => gettext('Disable this if you do not want to use the separate contact page with the contact form. You can also use the codeblock of a page for this. See the contact_form plugin documentation for more info.')), gettext('Use custom menu') => array('key' => 'zenpage_custommenu', 'type' => OPTION_TYPE_CHECKBOX, 'desc' => gettext('Check this if you want to use the <em>menu_manager</em> plugin if enabled to build a custom menu instead of the separate standard ones. A standard menu named "zenpage" is created and used automatically.'))); }
static function getLatestImages($limit = 3) { if (!isset($limit) || !is_numeric($limit)) { $limit = 3; } $t_images = prefix("images"); $t_albums = prefix("albums"); $query = "SELECT i.filename, i.title, a.folder FROM {$t_images} i " . "LEFT JOIN {$t_albums} a ON i.albumid=a.id " . "ORDER BY i.id DESC LIMIT {$limit}"; $result = query_full_array($query); return self::createImages($result); }
function handleOption($option, $currentValue) { switch ($option) { case 'garland_menu': $menusets = array(); echo '<select id="garland_menuset" name="garland_menu"'; if (function_exists('printCustomMenu') && getThemeOption('custom_index_page', NULL, 'garland') === 'gallery') { $result = query_full_array("SELECT DISTINCT menuset FROM " . prefix('menu') . " ORDER BY menuset"); foreach ($result as $set) { $menusets[$set['menuset']] = $set['menuset']; } } else { echo ' disabled="disabled"'; } echo ">\n"; echo '<option value="" style="background-color:LightGray">' . gettext('*standard menu') . '</option>'; generateListFromArray(array($currentValue), $menusets, false, false); echo "</select>\n"; break; } }
/** * Retuns a list of album statistic accordingly to $option * * @param int $number the number of albums to get * @param string $option "popular" for the most popular albums, * "latest" for the latest uploaded, "mostrated" for the most voted, * "toprated" for the best voted * "latestupdated" for the latest updated * @param string $albumfolder The name of an album to get only the statistc for its subalbums * @return string */ function getAlbumStatistic($number = 5, $option, $albumfolder = '') { global $_zp_gallery; if (!isset($_zp_gallery)) { // needed for gallery stats as $_zp_gallery is not set... $_zp_gallery = new Gallery(); } $albumlist = array(); if ($albumfolder) { $obj = new Album($_zp_gallery, $albumfolder); $albumlist[] = $obj->getID(); } else { $obj = $_zp_gallery; } getImageAlbumAlbumList($obj, $albumlist); $albumWhere = ''; if (!empty($albumlist)) { $albumWhere = ' WHERE (`id`=' . implode(' OR `id`=', $albumlist) . ')'; } switch ($option) { case "popular": $sortorder = "hitcounter"; break; case "latest": $sortorder = "id"; break; case "mostrated": $sortorder = "total_votes"; break; case "toprated": $sortorder = "(total_value/total_votes)"; break; case "latestupdated": $sortorder = 'updateddate'; break; } $albums = query_full_array("SELECT id, title, folder, thumb FROM " . prefix('albums') . $albumWhere . " ORDER BY " . $sortorder . " DESC LIMIT " . $number); return $albums; }
static function getRandomImages($limit = 3, $albums = NULL) { if ($limit == 0) { $limit = 1; } $t_images = prefix("images"); $t_albums = prefix("albums"); $idQuery = "select img.id from {$t_images} img"; $where = ""; if (!is_null($albums) && count($albums) > 0) { $all = ''; for ($u = 0; $u < count($albums); $u++) { if ($u > 0) { $all .= ", "; } $all .= "'" . $albums[$u] . "'"; } $where = " LEFT JOIN {$t_albums} album ON img.albumid=album.id " . "WHERE album.folder IN ({$all}) ORDER BY img.id"; } $idQuery .= $where; $result = query_full_array($idQuery); $rowCount = count($result); $u = 0; $ids = ""; while ($u < $limit) { $id = rand(0, $rowCount - 1); if ($u > 0) { $ids .= ", "; } $ids .= $result[$id]['id']; $u++; } $query = "SELECT i.filename, i.title, a.folder FROM {$t_images} i " . "LEFT JOIN {$t_albums} a ON i.albumid=a.id WHERE i.id IN ({$ids})"; $result = query_full_array($query); return self::createImages($result); }
$action = $_POST['tag_action']; unset($_POST['tag_action']); if (isset($_POST['tag_list_tags_'])) { $tags = sanitize($_POST['tag_list_tags_']); } else { $tags = array(); } switch ($action) { case 'delete': if (count($tags) > 0) { $sql = "SELECT `id` FROM " . prefix('tags') . " WHERE "; foreach ($tags as $tag) { $sql .= "`name`=" . db_quote($tag) . " OR "; } $sql = substr($sql, 0, strlen($sql) - 4); $dbtags = query_full_array($sql); if (is_array($dbtags) && count($dbtags) > 0) { $sqltags = "DELETE FROM " . prefix('tags') . " WHERE "; $sqlobjects = "DELETE FROM " . prefix('obj_to_tag') . " WHERE "; foreach ($dbtags as $tag) { $sqltags .= "`id`='" . $tag['id'] . "' OR "; $sqlobjects .= "`tagid`='" . $tag['id'] . "' OR "; } $sqltags = substr($sqltags, 0, strlen($sqltags) - 4); query($sqltags); $sqlobjects = substr($sqlobjects, 0, strlen($sqlobjects) - 4); query($sqlobjects); } } $action = gettext('Checked tags deleted'); break;
function handleOption($option, $currentValue) { if ($option == 'zpfocus_showrandom') { echo '<select style="width:200px; " id="' . $option . '" name="' . $option . '"' . ">\n"; echo '<option value="single"'; if ($currentValue == "single") { echo ' selected="selected">Single Random</option>\\n'; } else { echo '>single</option>\\n'; } echo '<option value="rotator"'; if ($currentValue == "rotator") { echo ' selected="selected">rotator</option>\\n'; } else { echo '>rotator</option>\\n'; } echo '<option value="none"'; if ($currentValue == "none") { echo ' selected="selected">None</option>\\n'; } else { echo '>none</option>\\n'; } echo "</select>\n"; } if ($option == 'zpfocus_rotatoreffect') { echo '<select style="width:200px; " id="' . $option . '" name="' . $option . '"' . ">\n"; echo '<option value="fade"'; if ($currentValue == "fade") { echo ' selected="selected">Fade</option>\\n'; } else { echo '>Fade</option>\\n'; } echo '<option value="shuffle"'; if ($currentValue == "shuffle") { echo ' selected="selected">Shuffle</option>\\n'; } else { echo '>Shuffle</option>\\n'; } echo '<option value="scrollUp"'; if ($currentValue == "scrollUp") { echo ' selected="selected">Scroll Up</option>\\n'; } else { echo '>Scroll Up</option>\\n'; } echo '<option value="scrollDown"'; if ($currentValue == "scrollDown") { echo ' selected="selected">Scroll Down</option>\\n'; } else { echo '>Scroll Down</option>\\n'; } echo '<option value="scrollRight"'; if ($currentValue == "scrollRight") { echo ' selected="selected">Scroll Right</option>\\n'; } else { echo '>Scroll Right</option>\\n'; } echo '<option value="scrollLeft"'; if ($currentValue == "scrollLeft") { echo ' selected="selected">Scroll Left</option>\\n'; } else { echo '>Scroll Left</option>\\n'; } echo '<option value="scrollHorz"'; if ($currentValue == "scrollHorz") { echo ' selected="selected">Scroll Horizontal</option>\\n'; } else { echo '>Scroll Horizontal</option>\\n'; } echo '<option value="scrollVert"'; if ($currentValue == "scrollVert") { echo ' selected="selected">Scroll Vertical</option>\\n'; } else { echo '>Scroll Vertical</option>\\n'; } echo '<option value="blindX"'; if ($currentValue == "blindX") { echo ' selected="selected">Blind X</option>\\n'; } else { echo '>Blind X</option>\\n'; } echo '<option value="blindY"'; if ($currentValue == "blindY") { echo ' selected="selected">Blind Y</option>\\n'; } else { echo '>Blind Y</option>\\n'; } echo '<option value="cover"'; if ($currentValue == "cover") { echo ' selected="selected">Cover</option>\\n'; } else { echo '>Cover</option>\\n'; } echo '<option value="curtainX"'; if ($currentValue == "curtainX") { echo ' selected="selected">Curtain X</option>\\n'; } else { echo '>Curtain X</option>\\n'; } echo '<option value="curtainY"'; if ($currentValue == "curtainY") { echo ' selected="selected">Curtain Y</option>\\n'; } else { echo '>Curtain Y</option>\\n'; } echo '<option value="fadeZoom"'; if ($currentValue == "fadeZoom") { echo ' selected="selected">Fade Zoom</option>\\n'; } else { echo '>Fade Zoom</option>\\n'; } echo '<option value="growX"'; if ($currentValue == "growX") { echo ' selected="selected">Grow X</option>\\n'; } else { echo '>Grow X</option>\\n'; } echo '<option value="growY"'; if ($currentValue == "growY") { echo ' selected="selected">Grow Y</option>\\n'; } else { echo '>Grow Y</option>\\n'; } echo '<option value="slideX"'; if ($currentValue == "slideX") { echo ' selected="selected">Slide X</option>\\n'; } else { echo '>Slide X</option>\\n'; } echo '<option value="slideY"'; if ($currentValue == "slideY") { echo ' selected="selected">Slide Y</option>\\n'; } else { echo '>Slide Y</option>\\n'; } echo '<option value="toss"'; if ($currentValue == "toss") { echo ' selected="selected">Toss</option>\\n'; } else { echo '>Toss</option>\\n'; } echo '<option value="turnUp"'; if ($currentValue == "turnUp") { echo ' selected="selected">Turn Up</option>\\n'; } else { echo '>Turn Up</option>\\n'; } echo '<option value="turnDown"'; if ($currentValue == "turnDown") { echo ' selected="selected">Turn Down</option>\\n'; } else { echo '>Turn Down</option>\\n'; } echo '<option value="turnRight"'; if ($currentValue == "turnRight") { echo ' selected="selected">Turn Right</option>\\n'; } else { echo '>Turn Right</option>\\n'; } echo '<option value="turnLeft"'; if ($currentValue == "turnLeft") { echo ' selected="selected">Turn Left</option>\\n'; } else { echo '>Turn Left</option>\\n'; } echo '<option value="uncover"'; if ($currentValue == "uncover") { echo ' selected="selected">Uncover</option>\\n'; } else { echo '>Uncover</option>\\n'; } echo '<option value="wipe"'; if ($currentValue == "wipe") { echo ' selected="selected">Wipe</option>\\n'; } else { echo '>Wipe</option>\\n'; } echo '<option value="zoom"'; if ($currentValue == "zoom") { echo ' selected="selected">Zoom</option>\\n'; } else { echo '>Zoom</option>\\n'; } echo "</select>\n"; } if ($option == 'zpfocus_cbstyle') { echo '<select style="width:200px; " id="' . $option . '" name="' . $option . '"' . ">\n"; echo '<option value="example1"'; if ($currentValue == "example1") { echo ' selected="selected">style1</option>\\n'; } else { echo '>style1</option>\\n'; } echo '<option value="example2"'; if ($currentValue == "example2") { echo ' selected="selected">style2</option>\\n'; } else { echo '>style2</option>\\n'; } echo '<option value="example3"'; if ($currentValue == "example3") { echo ' selected="selected">style3</option>\\n'; } else { echo '>style3</option>\\n'; } echo '<option value="example4"'; if ($currentValue == "example4") { echo ' selected="selected">style4</option>\\n'; } else { echo '>style4</option>\\n'; } echo '<option value="example5"'; if ($currentValue == "example5") { echo ' selected="selected">style5</option>\\n'; } else { echo '>style5</option>\\n'; } echo "</select>\n"; } if ($option == 'zpfocus_cbtransition') { echo '<select style="width:200px; " id="' . $option . '" name="' . $option . '"' . ">\n"; echo '<option value="fade"'; if ($currentValue == "fade") { echo ' selected="selected">Fade</option>\\n'; } else { echo '>Fade</option>\\n'; } echo '<option value="elastic"'; if ($currentValue == "elastic") { echo ' selected="selected">Elastic</option>\\n'; } else { echo '>Elastic</option>\\n'; } echo '<option value="none"'; if ($currentValue == "none") { echo ' selected="selected">None</option>\\n'; } else { echo '>None</option>\\n'; } echo "</select>\n"; } if ($option == 'zpfocus_final_link') { echo '<select style="width:200px; " id="' . $option . '" name="' . $option . '"' . ">\n"; echo '<option value="colorbox"'; if ($currentValue == "colorbox") { echo ' selected="selected">colorbox</option>\\n'; } else { echo '>colorbox</option>\\n'; } echo '<option value="nolink"'; if ($currentValue == "nolink") { echo ' selected="selected">nolink</option>\\n'; } else { echo '>nolink</option>\\n'; } echo '<option value="standard"'; if ($currentValue == "standard") { echo ' selected="selected">standard</option>\\n'; } else { echo '>standard</option>\\n'; } echo '<option value="standard-new"'; if ($currentValue == "standard-new") { echo ' selected="selected">standard-new</option>\\n'; } else { echo '>standard-new</option>\\n'; } echo "</select>\n"; } if ($option == 'zpfocus_menutype') { echo '<select style="width:100px; " id="' . $option . '" name="' . $option . '"' . ">\n"; echo '<option value="dropdown"'; if ($currentValue == "dropdown") { echo ' selected="selected">DropDown</option>\\n'; } else { echo '>DropDown</option>\\n'; } echo '<option value="jump"'; if ($currentValue == 'jump') { echo ' selected="selected">Jump</option>\\n'; } else { echo '>Jump</option>\\n'; } echo "</select>\n"; } if ($option == 'zpfocus_spotlight') { echo '<select style="width:100px; " id="' . $option . '" name="' . $option . '"' . ">\n"; echo '<option value="none"'; if ($currentValue == "none") { echo ' selected="selected">None</option>\\n'; } else { echo '>None</option>\\n'; } echo '<option value="manual"'; if ($currentValue == 'manual') { echo ' selected="selected">Manual</option>\\n'; } else { echo '>Manual</option>\\n'; } echo '<option value="latest"'; if ($currentValue == 'latest') { echo ' selected="selected">Latest News</option>\\n'; } else { echo '>Latest News</option>\\n'; } echo "</select>\n"; } if ($option == "zpfocus_homepage") { $unpublishedpages = query_full_array("SELECT titlelink FROM " . prefix('pages') . " WHERE `show` != 1 ORDER by `sort_order`"); if (empty($unpublishedpages)) { echo gettext("No unpublished pages available"); // clear option if no unpublished pages are available or have been published meanwhile // so that the normal gallery index appears and no page is accidentally set if set to unpublished again. setOption("zpfocus_homepage", "none"); } else { echo '<input type="hidden" name="' . CUSTOM_OPTION_PREFIX . 'selector-zpfocus_homepage" value="0" />' . "\n"; echo '<select id="' . $option . '" name="zpfocus_homepage">' . "\n"; if ($currentValue === "none") { $selected = " selected = 'selected'"; } else { $selected = ""; } echo "<option{$selected}>" . gettext("none") . "</option>"; foreach ($unpublishedpages as $page) { if ($currentValue === $page["titlelink"]) { $selected = " selected = 'selected'"; } else { $selected = ""; } echo "<option{$selected}>" . $page["titlelink"] . "</option>"; } echo "</select>\n"; } } }
/** * Searches the table for tags * Returns an array of database records. * * @param string $searchstring * @param string $tbl set to 'albums' or 'images' * @param string $sorttype what to sort on * @param string $sortdirection what direction * @return array */ function searchFieldsAndTags($searchstring, $tbl, $sorttype, $sortdirection) { $allIDs = null; $idlist = array(); $exact = EXACT_TAG_MATCH; // create an array of [tag, objectid] pairs for tags $tag_objects = array(); $fields = $this->fieldList; if (count($fields) == 0) { // then use the default ones $fields = $this->allowedSearchFields(); } foreach ($fields as $key => $field) { if (strtolower($field) == 'tags') { unset($fields[$key]); $tagsql = 'SELECT t.`name`, o.`objectid` FROM ' . prefix('tags') . ' AS t, ' . prefix('obj_to_tag') . ' AS o WHERE t.`id`=o.`tagid` AND o.`type`="' . $tbl . '" AND ('; foreach ($searchstring as $singlesearchstring) { switch ($singlesearchstring) { case '&': case '!': case '|': case '(': case ')': break; default: $targetfound = true; if ($exact) { $tagsql .= '`name` = ' . db_quote($singlesearchstring) . ' OR '; } else { $tagsql .= '`name` LIKE ' . db_quote('%' . $singlesearchstring . '%') . ' OR '; } } } $tagsql = substr($tagsql, 0, strlen($tagsql) - 4) . ') ORDER BY t.`id`'; $objects = query_full_array($tagsql, false); if (is_array($objects)) { $tag_objects = $objects; } break; } } // create an array of [name, objectid] pairs for the search fields. $field_objects = array(); if (count($fields) > 0) { $columns = array(); $dbfields = db_list_fields($tbl); if (is_array($dbfields)) { foreach ($dbfields as $row) { $columns[] = strtolower($row['Field']); } } foreach ($searchstring as $singlesearchstring) { switch ($singlesearchstring) { case '&': case '!': case '|': case '(': case ')': break; default: $targetfound = true; query('SET @serachtarget=' . db_quote($singlesearchstring)); $fieldsql = ''; foreach ($fields as $fieldname) { if ($tbl == 'albums' && $fieldname == 'filename') { $fieldname = 'folder'; } else { $fieldname = strtolower($fieldname); } if ($fieldname && in_array($fieldname, $columns)) { $fieldsql .= ' `' . $fieldname . '` LIKE ' . db_quote('%' . $singlesearchstring . '%') . ' OR '; } } if (!empty($fieldsql)) { $fieldsql = substr($fieldsql, 0, strlen($fieldsql) - 4) . ') ORDER BY `id`'; $sql = 'SELECT @serachtarget AS name, `id` AS `objectid` FROM ' . prefix($tbl) . ' WHERE (' . $fieldsql; $objects = query_full_array($sql, false); if (is_array($objects)) { $field_objects = array_merge($field_objects, $objects); } } } } } $objects = array_merge($tag_objects, $field_objects); if (count($objects) != 0) { $tagid = ''; $taglist = array(); foreach ($objects as $object) { $tagid = strtolower($object['name']); if (!isset($taglist[$tagid]) || !is_array($taglist[$tagid])) { $taglist[$tagid] = array(); } $taglist[$tagid][] = $object['objectid']; } $op = ''; $idstack = array(); $opstack = array(); while (count($searchstring) > 0) { $singlesearchstring = array_shift($searchstring); switch ($singlesearchstring) { case '&': case '!': case '|': $op = $op . $singlesearchstring; break; case '(': array_push($idstack, $idlist); array_push($opstack, $op); $idlist = array(); $op = ''; break; case ')': $objectid = $idlist; $idlist = array_pop($idstack); $op = array_pop($opstack); switch ($op) { case '&': if (is_array($objectid)) { $idlist = array_intersect($idlist, $objectid); } else { $idlist = array(); } break; case '!': break; // Paren followed by NOT is nonsensical? // Paren followed by NOT is nonsensical? case '&!': if (is_array($objectid)) { $idlist = array_diff($idlist, $objectid); } break; case '': case '|': if (is_array($objectid)) { $idlist = array_merge($idlist, $objectid); } break; } $op = ''; break; default: $lookfor = strtolower($singlesearchstring); $objectid = NULL; foreach ($taglist as $key => $objlist) { if ($exact && $lookfor == $key || !$exact && preg_match('%' . $lookfor . '%', $key)) { if (is_array($objectid)) { $objectid = array_merge($objectid, $objlist); } else { $objectid = $objlist; } } } switch ($op) { case '&': if (is_array($objectid)) { $idlist = array_intersect($idlist, $objectid); } else { $idlist = array(); } break; case '!': if (is_null($allIDs)) { $allIDs = array(); $result = query_full_array("SELECT `id` FROM " . prefix($tbl)); if (is_array($result)) { foreach ($result as $row) { $allIDs[] = $row['id']; } } } if (is_array($objectid)) { $idlist = array_merge($idlist, array_diff($allIDs, $objectid)); } break; case '&!': if (is_array($objectid)) { $idlist = array_diff($idlist, $objectid); } break; case '': case '|': if (is_array($objectid)) { $idlist = array_merge($idlist, $objectid); } break; } $idlist = array_unique($idlist); $op = ''; break; } $idlist = array_unique($idlist); } } if (count($idlist) == 0) { return NULL; } $sql = 'SELECT DISTINCT `id`,`show`,`title`,'; switch ($tbl) { case 'pages': case 'news': $sql .= '`titlelink` '; break; case 'albums': $sql .= "`desc`,`folder` "; break; default: $sql .= "`desc`,`albumid`,`filename`,`location`,`city`,`state`,`country` "; break; } if (zp_loggedin()) { $show = ''; } else { $show = "`show` = 1 AND "; } switch ($tbl) { case 'news': if (is_array($this->category_list)) { $news_list = $this->subsetNewsCategories(); $idlist = array_intersect($news_list, $idlist); if (count($idlist) == 0) { return NULL; } } if (empty($sorttype)) { $key = '`date` DESC'; } else { $key = trim('`' . $sorttype . '` ' . $sortdirection); } if ($show) { $show .= '`date`<=' . db_quote(date('Y-m-d H:i:s')) . ' AND '; } break; case 'pages': if ($show) { $show .= '`date`<=' . db_quote(date('Y-m-d H:i:s')) . ' AND '; } $key = '`sort_order`'; break; case 'albums': if (is_null($sorttype)) { if (empty($this->dynalbumname)) { $key = lookupSortKey($this->gallery->getSortType(), 'sort_order', 'folder'); if ($this->gallery->getSortDirection()) { $key .= " DESC"; } } else { $gallery = new Gallery(); $album = new Album($gallery, $this->dynalbumname); $key = $album->getAlbumSortKey(); if ($key != '`sort_order`' && $key != 'RAND()') { if ($album->getSortDirection('album')) { $key .= " DESC"; } } } } else { $sorttype = lookupSortKey($sorttype, 'sort_order', 'folder'); $key = trim($sorttype . ' ' . $sortdirection); } break; default: if (is_null($sorttype)) { if (empty($this->dynalbumname)) { $key = lookupSortKey(IMAGE_SORT_TYPE, 'filename', 'filename'); if (IMAGE_SORT_DIRECTION) { $key .= " DESC"; } } else { $gallery = new Gallery(); $album = new Album($gallery, $this->dynalbumname); $key = $album->getImageSortKey(); if ($key != '`sort_order`') { if ($album->getSortDirection('image')) { $key .= " DESC"; } } } } else { $sorttype = lookupSortKey($sorttype, 'filename', 'filename'); $key = trim($sorttype . ' ' . $sortdirection); } break; } $sql .= "FROM " . prefix($tbl) . " WHERE " . $show; $sql .= '(' . $this->compressedIDList($idlist) . ')'; $sql .= " ORDER BY " . $key; $result = query_full_array($sql); return $result; }
setupLog(sprintf(gettext("Previous Release was %s"), $prevRel), true); } require dirname(__FILE__) . '/setup-option-defaults.php'; if ($debug == 'base64') { // update zenpage codeblocks--remove the base64 encoding $sql = 'SELECT `id`, `codeblock` FROM ' . prefix('news') . ' WHERE `codeblock` NOT REGEXP "^a:[0-9]+:{"'; $result = query_full_array($sql, false); if (is_array($result)) { foreach ($result as $row) { $codeblock = base64_decode($row['codeblock']); $sql = 'UPDATE ' . prefix('news') . ' SET `codeblock`=' . db_quote($codeblock) . ' WHERE `id`=' . $row['id']; query($sql); } } $sql = 'SELECT `id`, `codeblock` FROM ' . prefix('pages') . ' WHERE `codeblock` NOT REGEXP "^a:[0-9]+:{"'; $result = query_full_array($sql, false); if (is_array($result)) { foreach ($result as $row) { $codeblock = base64_decode($row['codeblock']); $sql = 'UPDATE ' . prefix('pages') . ' SET `codeblock`=' . db_quote($codeblock) . ' WHERE `id`=' . $row['id']; query($sql); } } } if ($debug == 'albumids') { // fixes 1.2 move/copy albums with wrong ids $albums = $_zp_gallery->getAlbums(); foreach ($albums as $album) { checkAlbumParentid($album, NULL, 'setuplog'); } }
$result = query_full_array($sql); if (is_array($result)) { foreach ($result as $row) { $filename = $row['creator']; if (!file_exists(SERVERPATH . '/' . $filename)) { $sql = 'DELETE FROM ' . prefix('options') . ' WHERE `creator`=' . db_quote($filename); query($sql); if (strpos($filename, PLUGIN_FOLDER) !== false || strpos($filename, USER_PLUGIN_FOLDER) !== false) { purgeOption('zp_plugin_' . stripSuffix(basename($filename))); } } } } // missing themes $sql = 'SELECT DISTINCT `theme` FROM ' . prefix('options') . ' WHERE `theme` IS NOT NULL'; $result = query_full_array($sql); if (is_array($result)) { foreach ($result as $row) { $filename = THEMEFOLDER . '/' . $row['theme']; if ($filename && !file_exists(SERVERPATH . '/' . $filename)) { $sql = 'DELETE FROM ' . prefix('options') . ' WHERE `theme`=' . db_quote($row['theme']); query($sql); } } } setOptionDefault('search_cache_duration', 30); setOptionDefault('search_within', 1); setOption('last_update_check', 30); $autoRotate = getOption('auto_rotate'); if (!is_null($autoRotate)) { if (!$autoRotate) {
/** * Deletes a page (and also if existing its subpages) from the database * */ function remove() { if ($success = parent::remove()) { $sortorder = $this->getSortOrder(); if ($this->id) { $success = $success && query("DELETE FROM " . prefix('obj_to_tag') . "WHERE `type`='pages' AND `objectid`=" . $this->id); $success = $success && query("DELETE FROM " . prefix('comments') . " WHERE ownerid = " . $this->getID() . ' AND type="pages"'); // delete any comments // remove subpages $mychild = strlen($sortorder) + 4; $result = query_full_array('SELECT * FROM ' . prefix('pages') . " WHERE `sort_order` like '" . $sortorder . "-%'"); if (is_array($result)) { foreach ($result as $row) { if (strlen($row['sort_order']) == $mychild) { $subpage = new ZenpagePage($row['titlelink']); $success = $success && $subpage->remove(); } } } } } return $success; }
/** * Gets latest comments for news articles and pages * * @param int $number how many comments you want. * @param string $type "all" for all latest comments for all news articles and all pages * "news" for the lastest comments of one specific news article * "page" for the lastest comments of one specific page * @param int $itemID the ID of the element to get the comments for if $type != "all" */ function getLatestZenpageComments($number, $type = "all", $itemID = "") { $itemID = sanitize_numeric($itemID); $number = sanitize_numeric($number); $checkauth = zp_loggedin(); if ($type == 'all' || $type == 'news') { $newspasswordcheck = ""; if (zp_loggedin(MANAGE_ALL_NEWS_RIGHTS)) { $newsshow = ''; } else { $newsshow = 'news.show=1 AND'; $newscheck = query_full_array("SELECT * FROM " . prefix('news') . " ORDER BY date"); foreach ($newscheck as $articlecheck) { $obj = new ZenpageNews($articlecheck['titlelink']); if ($obj->inProtectedCategory()) { if ($checkauth && $obj->isMyItem(LIST_RIGHTS)) { $newsshow = ''; } else { $excludenews = " AND id != " . $articlecheck['id']; $newspasswordcheck = $newspasswordcheck . $excludenews; } } } } } if ($type == 'all' || $type == 'page') { $pagepasswordcheck = ""; if (zp_loggedin(MANAGE_ALL_PAGES_RIGHTS)) { $pagesshow = ''; } else { $pagesshow = 'pages.show=1 AND'; $pagescheck = query_full_array("SELECT * FROM " . prefix('pages') . " ORDER BY date"); foreach ($pagescheck as $pagecheck) { $obj = new ZenpagePage($pagecheck['titlelink']); if ($obj->isProtected()) { if ($checkauth && $obj->isMyItem(LIST_RIGHTS)) { $pagesshow = ''; } else { $excludepages = " AND pages.id != " . $pagecheck['id']; $pagepasswordcheck = $pagepasswordcheck . $excludepages; } } } } } switch ($type) { case "news": $whereNews = " WHERE {$newsshow} news.id = " . $itemID . " AND c.ownerid = news.id AND c.type = 'news' AND c.private = 0 AND c.inmoderation = 0" . $newspasswordcheck; break; case "page": $wherePages = " WHERE {$pagesshow} pages.id = " . $itemID . " AND c.ownerid = pages.id AND c.type = 'pages' AND c.private = 0 AND c.inmoderation = 0" . $pagepasswordcheck; break; case "all": $whereNews = " WHERE {$newsshow} c.ownerid = news.id AND c.type = 'news' AND c.private = 0 AND c.inmoderation = 0" . $newspasswordcheck; $wherePages = " WHERE {$pagesshow} c.ownerid = pages.id AND c.type = 'pages' AND c.private = 0 AND c.inmoderation = 0" . $pagepasswordcheck; break; } $comments_news = array(); $comments_pages = array(); if ($type == "all" or $type == "news") { $comments_news = query_full_array("SELECT c.id, c.name, c.type, c.website," . " c.date, c.anon, c.comment, news.title, news.titlelink FROM " . prefix('comments') . " AS c, " . prefix('news') . " AS news " . $whereNews . " ORDER BY c.id DESC LIMIT {$number}"); } if ($type == "all" or $type == "page") { $comments_pages = query_full_array($sql = "SELECT c.id, c.name, c.type, c.website," . " c.date, c.anon, c.comment, pages.title, pages.titlelink FROM " . prefix('comments') . " AS c, " . prefix('pages') . " AS pages " . $wherePages . " ORDER BY c.id DESC LIMIT {$number}"); } $comments = array(); foreach ($comments_news as $comment) { $comments[$comment['id']] = $comment; } foreach ($comments_pages as $comment) { $comments[$comment['id']] = $comment; } krsort($comments); return array_slice($comments, 0, $number); }
/** * Adds Zenpage news categories to the menu set * @param string $menuset chosen menu set */ function addCategoriesToDatabase($menuset, $base = NULL) { if (is_null($base)) { $categorybase = db_count('menu', 'WHERE menuset=' . db_quote($menuset)); $sortbase = ''; } else { $categorybase = array_pop($base); $sortbase = ''; for ($i = 0; $i < count($base); $i++) { $sortbase .= sprintf('%03u', $base[$i]) . '-'; } } $result = $categorybase; $parents = array('NULL'); $result = query_full_array("SELECT * FROM " . prefix('news_categories') . " ORDER BY sort_order"); foreach ($result as $key => $item) { $sorts = explode('-', $item['sort_order']); $level = count($sorts); $sorts[0] = sprintf('%03u', $result = $sorts[0] + $categorybase); $order = $sortbase . implode('-', $sorts); $link = $item['titlelink']; $parent = $parents[$level - 1]; $sql = "INSERT INTO " . prefix('menu') . " (`title`, `link`, `type`, `show`,`menuset`,`sort_order`,`parentid`) " . 'VALUES (' . db_quote($item['title']) . ',' . db_quote($link) . ',"zenpagecategory", 1,' . db_quote($menuset) . ',' . db_quote($order) . ',' . $parent . ')'; if (query($sql, false)) { $id = db_insert_id(); } else { $rslt = query_single_row('SELECT `id` FROM' . prefix('menu') . ' WHERE `type`="zenpagecategory" AND `link`="' . $link . '"'); $id = $rslt['id']; } $parents[$level] = $id; } return $result; }
/** * Prints a table with a bar graph of the values. * * @param string $sortorder "popular", "mostrated","toprated","mostcommented" or - only if $type = "albums"! - "mostimages" * @param string_type $type "albums", "images", "pages", "news", "tags" * @param int $limit Number of entries to show */ function printBarGraph($sortorder = "mostimages", $type = "albums", $from_number = 0, $to_number = 10) { global $gallery, $webpath; $limit = $from_number . "," . $to_number; $bargraphmaxsize = 400; switch ($type) { case "albums": $typename = gettext("Albums"); $dbquery = "SELECT * FROM " . prefix('albums'); break; case "images": $typename = gettext("Images"); $dbquery = "SELECT * FROM " . prefix('images'); break; case "pages": $typename = gettext("Pages"); $dbquery = "SELECT * FROM " . prefix('pages'); break; case "news": $typename = gettext("News Articles"); $dbquery = "SELECT * FROM " . prefix('news'); break; case "newscategories": $typename = gettext("News Categories"); $dbquery = "SELECT * FROM " . prefix('news_categories'); break; case "tags": $typename = gettext("Tags"); break; case "rss": $typename = gettext("rss"); break; } switch ($sortorder) { case "mostused": switch ($type) { case "tags": $itemssorted = query_full_array("SELECT tagobj.tagid, count(*) as tagcount, tags.* FROM " . prefix('obj_to_tag') . " AS tagobj, " . prefix('tags') . " AS tags WHERE tags.id=tagobj.tagid GROUP BY tags.id ORDER BY tagcount DESC LIMIT " . $limit); if (empty($itemssorted)) { $maxvalue = 0; } else { $maxvalue = $itemssorted[0]['tagcount']; } break; case "newscategories": $itemssorted = query_full_array("SELECT news2cat.cat_id, count(*) as catcount, cats.* FROM " . prefix('news2cat') . " AS news2cat, " . prefix('news_categories') . " AS cats WHERE cats.id=news2cat.cat_id GROUP BY news2cat.cat_id ORDER BY catcount DESC LIMIT " . $limit); if (empty($itemssorted)) { $maxvalue = 0; } else { $maxvalue = $itemssorted[0]['catcount']; } break; } $headline = $typename . " - " . gettext("most used"); break; case "popular": switch ($type) { case 'rss': $itemssorted = query_full_array("SELECT `type`,`aux`, `data` FROM " . prefix('plugin_storage') . " WHERE `type` = 'rsshitcounter' ORDER BY CONVERT(data,UNSIGNED) DESC LIMIT " . $limit); if (empty($itemssorted)) { $maxvalue = 0; } else { $maxvalue = $itemssorted[0]['data']; } break; default: $itemssorted = query_full_array($dbquery . " ORDER BY hitcounter DESC LIMIT " . $limit); if (empty($itemssorted)) { $maxvalue = 0; } else { $maxvalue = $itemssorted[0]['hitcounter']; } break; } $headline = $typename . " - " . gettext("most viewed"); break; case "mostrated": $itemssorted = query_full_array($dbquery . " ORDER BY total_votes DESC LIMIT " . $limit); if (empty($itemssorted)) { $maxvalue = 0; } else { $maxvalue = $itemssorted[0]['total_votes']; } $headline = $typename . " - " . gettext("most rated"); break; case "toprated": $itemssorted = query_full_array($dbquery . " ORDER BY (total_value/total_votes) DESC LIMIT {$limit}"); if (empty($itemssorted)) { $maxvalue = 0; } else { if ($itemssorted[0]['total_votes'] != 0) { $maxvalue = $itemssorted[0]['total_value'] / $itemssorted[0]['total_votes']; } else { $maxvalue = 0; } } $headline = $typename . " - " . gettext("top rated"); break; case "mostcommented": switch ($type) { case "albums": $itemssorted = query_full_array("SELECT comments.ownerid, count(*) as commentcount, albums.* FROM " . prefix('comments') . " AS comments, " . prefix('albums') . " AS albums WHERE albums.id=comments.ownerid AND type = 'albums' GROUP BY comments.ownerid ORDER BY commentcount DESC LIMIT " . $limit); break; case "images": $itemssorted = query_full_array("SELECT comments.ownerid, count(*) as commentcount, images.* FROM " . prefix('comments') . " AS comments, " . prefix('images') . " AS images WHERE images.id=comments.ownerid AND type = 'images' GROUP BY comments.ownerid ORDER BY commentcount DESC LIMIT " . $limit); break; case "pages": $itemssorted = query_full_array("SELECT comments.ownerid, count(*) as commentcount, pages.* FROM " . prefix('comments') . " AS comments, " . prefix('pages') . " AS pages WHERE pages.id=comments.ownerid AND type = 'page' GROUP BY comments.ownerid ORDER BY commentcount DESC LIMIT " . $limit); break; case "news": $itemssorted = query_full_array("SELECT comments.ownerid, count(*) as commentcount, news.* FROM " . prefix('comments') . " AS comments, " . prefix('news') . " AS news WHERE news.id=comments.ownerid AND type = 'news' GROUP BY comments.ownerid ORDER BY commentcount DESC LIMIT " . $limit); break; } if (empty($itemssorted)) { $maxvalue = 0; } else { $maxvalue = $itemssorted[0]['commentcount']; } $headline = $typename . " - " . gettext("most commented"); break; case "mostimages": $itemssorted = query_full_array("SELECT images.albumid, count(*) as imagenumber, albums.* FROM " . prefix('images') . " AS images, " . prefix('albums') . " AS albums WHERE albums.id=images.albumid GROUP BY images.albumid ORDER BY imagenumber DESC LIMIT " . $limit); if (empty($itemssorted)) { $maxvalue = 0; } else { $maxvalue = $itemssorted[0]['imagenumber']; } $headline = $typename . " - " . gettext("most images"); break; case "latest": switch ($type) { case "albums": $allalbums = query_full_array($dbquery . " ORDER BY id DESC LIMIT " . $limit); $albums = array(); foreach ($allalbums as $album) { $albumobj = new Album($gallery, $album['folder']); $albumentry = array("id" => $albumobj->get('id'), "title" => $albumobj->getTitle(), "folder" => $albumobj->name, "imagenumber" => $albumobj->getNumImages(), "show" => $albumobj->get("show")); array_unshift($albums, $albumentry); } $maxvalue = 1; $itemssorted = sortMultiArray($albums, 'id', true, true); // The items are originally sorted by id; $headline = $typename . " - " . gettext("latest"); break; case "images": $itemssorted = query_full_array($dbquery . " ORDER BY id DESC LIMIT " . $limit); $barsize = 0; $maxvalue = 1; $headline = $typename . " - " . gettext("latest"); break; } break; case "latestupdated": $albums = getAlbumStatistic($to_number, 'latestupdated', ''); $maxvalue = 1; if (!empty($albums)) { foreach ($albums as $key => $album) { $albumobj = new Album($gallery, $album['folder']); $albums[$key]['imagenumber'] = $albumobj->getNumImages(); } } $itemssorted = $albums; $headline = $typename . " - " . gettext("latest updated"); break; } if ($maxvalue == 0 || empty($itemssorted)) { $maxvalue = 1; $no_hitcount_enabled_msg = ''; if ($sortorder == 'popular' && $type != 'rss' && !getOption('zp_plugin_hitcounter')) { $no_hitcount_enabled_msg = gettext("(The hitcounter plugin is not enabled.)"); } $no_statistic_message = "<tr><td><em>" . gettext("No statistic available.") . $no_hitcount_enabled_msg . "</em></td><td></td><td></td><td></td></tr>"; } else { $no_statistic_message = ""; if ($sortorder == 'popular' && $type != 'rss' && !getOption('zp_plugin_hitcounter')) { $no_statistic_message = "<tr><td colspan='4'><em>" . gettext("Note: The hitcounter plugin is not enabled, therefore any existing values will not get updated.") . "</em></td><td></td><td></td><td></td></tr>"; } } if ($from_number <= 1) { $count = 1; } else { $count = $from_number; } $countlines = 0; echo "<table class='bordered'>"; echo "<tr><th colspan='4'><strong>" . $headline . "</strong>"; if (isset($_GET['stats'])) { echo "<a href='gallery_statistics.php'> | " . gettext("Back to the top 10 lists") . "</a>"; } else { if (empty($no_statistic_message)) { echo "<a href='gallery_statistics.php?stats=" . $sortorder . "&type=" . $type . "'> | " . gettext("View more") . "</a>"; } echo "<a href='#top'> | " . gettext("top") . "</a>"; } echo "</th></tr>"; echo $no_statistic_message; foreach ($itemssorted as $item) { if (array_key_exists("filename", $item)) { $name = $item['filename']; } else { if (array_key_exists("folder", $item)) { $name = $item['folder']; } else { if ($type === "pages" or $type === "news") { $name = $item['titlelink']; } else { if ($type === "newscategories") { $name = $item['title']; } else { if ($type === "tags") { $name = ""; } } } } } switch ($sortorder) { case "popular": switch ($type) { case 'rss': $barsize = round($item['data'] / $maxvalue * $bargraphmaxsize); $value = $item['data']; break; default: $barsize = round($item['hitcounter'] / $maxvalue * $bargraphmaxsize); $value = $item['hitcounter']; break; } break; case "mostrated": if ($item['total_votes'] != 0) { $barsize = round($item['total_votes'] / $maxvalue * $bargraphmaxsize); } else { $barsize = 0; } $value = $item['total_votes']; break; case "toprated": if ($item['total_votes'] != 0) { $barsize = round($item['total_value'] / $item['total_votes'] / $maxvalue * $bargraphmaxsize); $value = round($item['total_value'] / $item['total_votes']); } else { $barsize = 0; $value = 0; } break; case "mostcommented": if ($maxvalue != 0) { $barsize = round($item['commentcount'] / $maxvalue * $bargraphmaxsize); } else { $barsize = 0; } $value = $item['commentcount']; break; case "mostimages": $barsize = round($item['imagenumber'] / $maxvalue * $bargraphmaxsize); $value = $item['imagenumber']; break; case "latest": switch ($type) { case "albums": $barsize = 0; //round($item['imagenumber'] / $maxvalue * $bargraphmaxsize); $value = sprintf(gettext("%s images"), $item['imagenumber']); break; case "images": $barsize = 0; $value = ""; break; } break; case "latestupdated": $barsize = 0; //round($item['imagenumber'] / $maxvalue * $bargraphmaxsize); $value = sprintf(gettext("%s images"), $item['imagenumber']); break; case "mostused": switch ($type) { case "tags": if ($maxvalue != 0) { $barsize = round($item['tagcount'] / $maxvalue * $bargraphmaxsize); } else { $barsize = 0; } $value = $item['tagcount']; break; case "newscategories": if ($maxvalue != 0) { $barsize = round($item['catcount'] / $maxvalue * $bargraphmaxsize); } else { $barsize = 0; } $value = $item['catcount']; break; } break; } // counter to have a gray background of every second line if ($countlines === 1) { $style = " style='background-color: #f4f4f4'"; // a little ugly but the already attached class for the table is so easiest overriden... $countlines = 0; } else { $style = ""; $countlines++; } switch ($type) { case "albums": $editurl = $webpath . "/admin-edit.php?page=edit&album=" . $name; $viewurl = WEBPATH . "/index.php?album=" . $name; $title = get_language_string($item['title']); break; case "images": $getalbumfolder = query_single_row("SELECT title, folder, `show` from " . prefix("albums") . " WHERE id = " . $item['albumid']); if ($sortorder === "latest") { $value = "<span"; if ($getalbumfolder['show'] != "1") { $value = $value . " class='unpublished_item'"; } $value = $value . ">" . get_language_string($getalbumfolder['title']) . "</span> (" . $getalbumfolder['folder'] . ")"; } $editurl = $webpath . "/admin-edit.php?page=edit&album=" . $getalbumfolder['folder'] . "&image=" . $item['filename'] . "&tab=imageinfo#IT"; $viewurl = WEBPATH . "/index.php?album=" . $getalbumfolder['folder'] . "&image=" . $name; $title = get_language_string($item['title']); break; case "pages": $editurl = $webpath . '/' . PLUGIN_FOLDER . "/zenpage/admin-edit.php?page&titlelink=" . $name; $viewurl = WEBPATH . "/index.php?p=pages&title=" . $name; $title = get_language_string($item['title']); break; case "news": $editurl = $webpath . '/' . PLUGIN_FOLDER . "/zenpage/admin-edit.php?news&titlelink=" . $name; $viewurl = WEBPATH . "/index.php?p=news&title=" . $name; $title = get_language_string($item['title']); break; case "newscategories": $editurl = $webpath . '/' . PLUGIN_FOLDER . "/zenpage/admin-categories.php?edit&id=" . $item['id']; $viewurl = WEBPATH . "/index.php?p=news&category=" . $name; $title = get_language_string($item['titlelink']); break; case "tags": $editurl = $webpath . "/admin-tags.php"; $viewurl = WEBPATH . "/index.php?p=search&searchfields=tags&words=" . $item['name']; $title = get_language_string($item['name']); break; case "rss": $editurl = ''; $viewurl = WEBPATH . "/index.php?" . html_encode(strrchr($item['aux'], 'rss')); $title = html_encode(strrchr($item['aux'], 'rss')); break; } if (isset($item['show'])) { if ($item['show'] != "1") { $show = " class='unpublished_item'"; } else { $show = ""; } } else { $show = ""; } if ($value != 0 or $sortorder === "latest") { if (empty($name)) { $name = ""; } else { $name = "(" . $name . ")"; } ?> <tr class="statistic_wrapper"> <td class="statistic_counter" <?php echo $style; ?> > <?php echo $count; ?> </td> <td class="statistic_title" <?php echo $style; ?> > <strong<?php echo $show; ?> ><?php echo $title; ?> </strong> <?php echo $name; ?> </td> <td class="statistic_graphwrap" <?php echo $style; ?> > <div class="statistic_bargraph" style="width: <?php echo $barsize; ?> px"></div> <div class="statistic_value"><?php echo $value; ?> </div> </td> <td class="statistic_link" <?php echo $style; ?> > <?php switch ($type) { case 'rss': echo "<a href='" . $viewurl . "' title='" . $name . "'>" . gettext("View") . "</a></td>"; break; default: echo "<a href='" . $editurl . "' title='" . $name . "'>" . gettext("Edit") . "</a> | <a href='" . $viewurl . "' title='" . $name . "'>" . gettext("View") . "</a></td>"; break; } echo "</tr>"; $count++; if ($count === $limit) { break; } } } // foreach end echo "</table>"; }
function handleOption($option, $currentValue) { if ($option == 'css_style') { echo '<select style="width: 200px;" id="' . $option . '" name="' . $option . '"' . ">\n"; echo '<option value="dark"'; if ($currentValue == 'dark') { echo ' selected="selected">Dark</option>\\n'; } else { echo '>Dark</option>\\n'; } echo '<option value="light"'; if ($currentValue == 'light') { echo ' selected="selected">Light</option>\\n'; } else { echo '>Light</option>\\n'; } echo "</select>\n"; } if ($option == 'color_style') { echo '<select style="width: 200px;" id="' . $option . '" name="' . $option . '"' . ">\n"; echo '<option value="default"'; if ($currentValue == 'default') { echo ' selected="selected">Default</option>\\n'; } else { echo '>Default</option>\\n'; } echo '<option value="custom"'; if ($currentValue == 'custom') { echo ' selected="selected">Custom</option>\\n'; } else { echo '>Custom</option>\\n'; } echo "</select>\n"; } if ($option == 'zenpage_homepage') { $unpublishedpages = query_full_array("SELECT titlelink, title FROM " . prefix('pages') . " WHERE `show` != 1 ORDER by `sort_order`"); if (empty($unpublishedpages)) { echo gettext("No unpublished pages available"); // clear option if no unpublished pages are available or have been published meanwhile // so that the normal gallery index appears and no page is accidentally set if set to unpublished again. setThemeOption('zenpage_homepage', 'none', NULL, 'zpArdoise'); } else { echo '<input type="hidden" name="' . CUSTOM_OPTION_PREFIX . 'selector-zenpage_homepage" value=0 />' . "\n"; echo '<select id="' . $option . '" name="' . $option . '">' . "\n"; echo '<option value="none"'; if ($currentValue == 'none') { echo ' selected="selected">' . gettext("none") . '</option>\\n'; } else { echo '>' . gettext("none") . '</option>\\n'; } foreach ($unpublishedpages as $page) { if ($currentValue == $page["titlelink"]) { $selected = ' selected="selected"'; } else { $selected = ''; } echo '<option value="' . $page["titlelink"] . '"' . $selected . '>' . get_language_string($page["title"]) . '</option>'; } echo "</select>\n"; } } if ($option == 'image_statistic') { echo '<select style="width: 200px;" id="' . $option . '" name="' . $option . '"' . ">\n"; echo '<option value="none"'; if ($currentValue == 'none') { echo ' selected="selected">None</option>\\n'; } else { echo '>None</option>\\n'; } echo '<option value="random"'; if ($currentValue == 'random') { echo ' selected="selected">Random</option>\\n'; } else { echo '>Random</option>\\n'; } echo '<option value="popular"'; if ($currentValue == 'popular') { echo ' selected="selected">Popular</option>\\n'; } else { echo '>Popular</option>\\n'; } echo '<option value="latest"'; if ($currentValue == 'latest') { echo ' selected="selected">Latest</option>\\n'; } else { echo '>Latest</option>\\n'; } echo '<option value="latest-date"'; if ($currentValue == 'latest-date') { echo ' selected="selected">Latest-date</option>\\n'; } else { echo '>Latest-date</option>\\n'; } echo '<option value="latest-mtime"'; if ($currentValue == 'latest-mtime') { echo ' selected="selected">Latest-mtime</option>\\n'; } else { echo '>Latest-mtime</option>\\n'; } echo '<option value="mostrated"'; if ($currentValue == 'mostrated') { echo ' selected="selected">Most Rated</option>\\n'; } else { echo '>Most Rated</option>\\n'; } echo '<option value="toprated"'; if ($currentValue == 'toprated') { echo ' selected="selected">Top Rated</option>\\n'; } else { echo '>Top Rated</option>\\n'; } echo "</select>\n"; } }
/** * Updates a news article and returns the object of that article * * @return object */ function updateArticle(&$reports) { $date = date('Y-m-d_H-i-s'); $title = process_language_string_save("title", 2); $author = sanitize($_POST['author']); $content = process_language_string_save("content", 0); // TinyMCE already clears unallowed code $extracontent = process_language_string_save("extracontent", 0); // TinyMCE already clears unallowed code $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'); $codeblock1 = sanitize($_POST['codeblock1'], 0); $codeblock2 = sanitize($_POST['codeblock2'], 0); $codeblock3 = sanitize($_POST['codeblock3'], 0); $codeblock = serialize(array("1" => $codeblock1, "2" => $codeblock2, "3" => $codeblock3)); $locked = getcheckboxState('locked'); $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 title link to change. $link = seoFriendly(get_language_string($title)); if (!empty($link)) { $titlelink = $link; } } } $id = sanitize($_POST['id']); $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 } } // 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); $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); } 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); $msg = zp_apply_filter('update_article', '', $article, $oldtitlelink); $article->save(); 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>'; } } if ($msg) { $reports[] = $msg; } return $article; }
function db_show($what, $aux = '') { global $_zp_conf_vars; switch ($what) { case 'tables': $sql = "SHOW TABLES FROM `" . $_zp_conf_vars['mysql_database'] . "` LIKE '" . $_zp_conf_vars['mysql_prefix'] . "%'"; return query($sql, false); case 'columns': $sql = 'SHOW FULL COLUMNS FROM `' . $_zp_conf_vars['mysql_prefix'] . $aux . '`'; return query($sql, true); case 'variables': $sql = "SHOW VARIABLES LIKE '{$aux}'"; return query_full_array($sql); } }
static function getListItemsFromDB() { $downloaditems = query_full_array("SELECT id, `aux`, `data` FROM " . prefix('plugin_storage') . " WHERE `type` = 'downloadList'"); return $downloaditems; }
/** * Checks if a tag is assigned at all and if it can be viewed by the current visitor and returns the corrected count * Helper function used optionally within getAllTagsCount() and getAllTagsUnique() * * @global obj $_zp_zenpage * @param array $tag Array representing a tag containing at least its name and id * @return int */ function getTagCountByAccess($tag) { global $_zp_zenpage, $_zp_object_to_tags; if (array_key_exists('count', $tag) && $tag['count'] == 0) { return $tag['count']; } $hidealbums = getNotViewableAlbums(); $hideimages = getNotViewableImages(); $hidenews = array(); $hidepages = array(); if (extensionEnabled('Zenpage')) { $hidenews = $_zp_zenpage->getNotViewableNews(); $hidepages = $_zp_zenpage->getNotViewablePages(); } //skip checks if there are no unviewable items at all if (empty($hidealbums) && empty($hideimages) && empty($hidenews) && empty($hidepages)) { if (array_key_exists('count', $tag)) { return $tag['count']; } return 0; } if (is_null($_zp_object_to_tags)) { $sql = "SELECT tagid, type, objectid FROM " . prefix('obj_to_tag') . " ORDER BY tagid"; $_zp_object_to_tags = query_full_array($sql); } $count = ''; if ($_zp_object_to_tags) { foreach ($_zp_object_to_tags as $tagcheck) { if ($tagcheck['tagid'] == $tag['id']) { switch ($tagcheck['type']) { case 'albums': if (!in_array($tagcheck['objectid'], $hidealbums)) { $count++; } break; case 'images': if (!in_array($tagcheck['objectid'], $hideimages)) { $count++; } break; case 'news': if (extensionEnabled('Zenpage') && ZP_NEWS_ENABLED) { if (!in_array($tagcheck['objectid'], $hidenews)) { $count++; } } break; case 'pages': if (extensionEnabled('Zenpage') && ZP_PAGES_ENABLED) { if (!in_array($tagcheck['objectid'], $hidepages)) { $count++; } } break; } } } } if (empty($count)) { $count = 0; } return $count; }
<?php define('OFFSET_PATH', 4); require_once dirname(dirname(dirname(__FILE__))) . '/admin-globals.php'; require_once dirname(dirname(dirname(__FILE__))) . '/template-functions.php'; if (getOption('zp_plugin_zenpage')) { require_once dirname(dirname(dirname(__FILE__))) . '/' . PLUGIN_FOLDER . '/zenpage/zenpage-admin-functions.php'; } require_once dirname(dirname(dirname(__FILE__))) . '/' . PLUGIN_FOLDER . '/menu_manager/menu_manager-admin-functions.php'; admin_securityChecks(NULL, currentRelativeURL(__FILE__)); $page = 'edit'; $menuset = checkChosenMenuset(''); if (empty($menuset)) { // setup default menuset $result = query_full_array("SELECT DISTINCT menuset FROM " . prefix('menu')); if (is_array($result)) { // default to the first one $set = array_shift($result); $menuset = $set['menuset']; } else { $menuset = 'default'; } $_GET['menuset'] = $menuset; } $reports = array(); if (isset($_POST['update'])) { XSRFdefender('update_menu'); processMenuBulkActions($reports); updateItemsSortorder($reports); } if (isset($_GET['delete'])) {
/** * returns the non-empty value of $field from the album or one of its parents * * @param string $folder the album name * @param string $field the desired field name * @param int $id will be set to the album `id` of the album which has the non-empty field * @return string */ function getAlbumInherited($folder, $field, &$id) { $folders = explode('/', filesystemToInternal($folder)); $album = array_shift($folders); $like = ' LIKE ' . db_quote(db_LIKE_escape($album)); while (count($folders) > 0) { $album .= '/' . array_shift($folders); $like .= ' OR `folder` LIKE ' . db_quote(db_LIKE_escape($album)); } $sql = 'SELECT `id`, `' . $field . '` FROM ' . prefix('albums') . ' WHERE `folder`' . $like; $result = query_full_array($sql); if (!is_array($result)) { return ''; } while (count($result) > 0) { $try = array_pop($result); if (!empty($try[$field])) { $id = $try['id']; return $try[$field]; } } return ''; }
function handleOption($option, $currentValue) { global $themecolors; switch ($option) { case 'Theme_colors': echo '<select id="EF_themeselect_colors" name="' . $option . '"' . ">\n"; generateListFromArray(array($currentValue), $themecolors, false, false); echo "</select>\n"; break; case 'effervescence_menu': $menusets = array($currentValue => $currentValue); echo '<select id="EF_menuset" name="effervescence_menu"'; if (function_exists('printCustomMenu')) { $result = query_full_array("SELECT DISTINCT menuset FROM " . prefix('menu') . " ORDER BY menuset"); foreach ($result as $set) { $menusets[$set['menuset']] = $set['menuset']; } } else { echo ' disabled="disabled"'; } echo ">\n"; echo '<option value="" style="background-color:LightGray">' . gettext('*standard menu') . '</option>'; generateListFromArray(array($currentValue), $menusets, false, false); echo "</select>\n"; break; case 'Graphic_logo': ?> <select id="EF_themeselect_logo" name="Graphic_logo"> <option value="" style="background-color:LightGray"><?php echo gettext('*no logo selected'); ?> </option>'; <option value="*"<?php if ($currentValue == '*') { echo ' selected="selected"'; } ?> ><?php echo gettext('Effervescence'); ?> </option>'; <?php generateListFromFiles($currentValue, SERVERPATH . '/' . UPLOAD_FOLDER . '/images', '.png'); ?> </select> <?php break; } }
/** * Saves the layout page assignment via filter on the backend for images and albums * * @param object $obj Object of the item to assign the layout * @return string */ function saveZenphotoLayoutSelection($obj, $prefix) { $cssIDappend = ''; $selectedlayout = ''; $titlelink = ''; $table = $obj->table; $type = 'multiple_layouts_' . $table; if (isset($_POST[$prefix . $type])) { $selectedlayout = sanitize($_POST[$prefix . $type]); $exists = query_single_row("SELECT * FROM " . prefix('plugin_storage') . ' WHERE `aux` = ' . $obj->getID() . ' AND `type` = "' . $type . '"'); if ($selectedlayout) { // not default if ($exists) { $query = query('UPDATE ' . prefix('plugin_storage') . ' SET `aux`=' . $obj->getID() . ', `data`=' . db_quote($selectedlayout) . ' WHERE `id`=' . $exists['id']); } else { $query = query('INSERT INTO ' . prefix('plugin_storage') . ' (type,aux,data) VALUES ("' . $type . '", ' . $obj->getID() . ', ' . db_quote($selectedlayout) . ')'); } } else { if ($exists) { // got to get rid of the record $query = query('DELETE FROM ' . prefix('plugin_storage') . ' WHERE `id`=' . $exists['id']); } else { $query = true; // no harm, no foul } } if ($table == 'albums') { // deal with the default images selection, clear image selections if (isset($_POST['layout_selector_resetimagelayouts'])) { $result = query_full_array('SELECT `id` FROM ' . prefix('images') . ' WHERE `albumid`=' . $obj->getID()); if ($result) { $imagelist = ''; foreach ($result as $row) { $imagelist .= '`aux`=' . $row['id'] . ' OR '; } $query = query($sql = 'DELETE FROM ' . prefix('plugin_storage') . ' WHERE `type`="multiple_layouts_images" AND (' . substr($imagelist, 0, -4) . ')', false); } } $exists = query_single_row("SELECT * FROM " . prefix('plugin_storage') . ' WHERE `aux` = ' . $obj->getID() . ' AND `type` = "multiple_layouts_albums_images"'); $selectedlayout = isset($_POST[$prefix . 'multiple_layouts_albums_images']) ? sanitize($_POST[$prefix . 'multiple_layouts_albums_images']) : NULL; if ($selectedlayout) { // not default if ($exists) { $query = query('UPDATE ' . prefix('plugin_storage') . ' SET `aux`=' . $obj->getID() . ', `data`=' . db_quote($selectedlayout) . ' WHERE `id`=' . $exists['id']); } else { $query = query('INSERT INTO ' . prefix('plugin_storage') . ' (type,aux,data) VALUES ("multiple_layouts_albums_images", ' . $obj->getID() . ', ' . db_quote($selectedlayout) . ')'); } } else { if ($exists) { // got to get rid of the record $query = query('DELETE FROM ' . prefix('plugin_storage') . ' WHERE `id`=' . $exists['id']); } else { $query = true; // no harm, no foul } } } } return $obj; }
function db_show($what, $aux = '') { global $_zp_DB_details; switch ($what) { case 'tables': $sql = "SHOW TABLES FROM `" . $_zp_DB_details['mysql_database'] . "` LIKE '" . db_LIKE_escape($_zp_DB_details['mysql_prefix']) . "%'"; return query($sql, false); case 'columns': $sql = 'SHOW FULL COLUMNS FROM `' . $_zp_DB_details['mysql_prefix'] . $aux . '`'; return query($sql, true); case 'variables': $sql = "SHOW VARIABLES LIKE '{$aux}'"; return query_full_array($sql); case 'index': $sql = "SHOW INDEX FROM `" . $_zp_DB_details['mysql_database'] . '`.' . $aux; return query_full_array($sql); } }
/** * Returns an array of comments for this album * * @param bool $moderated if false, ignores comments marked for moderation * @param bool $private if false ignores private comments * @param bool $desc set to true for descending order * @return array */ function getComments($moderated = false, $private = false, $desc = false) { $sql = "SELECT *, (date + 0) AS date FROM " . prefix("comments") . " WHERE `type`='" . $this->table . "' AND `ownerid`='" . $this->getID() . "'"; if (!$moderated) { $sql .= " AND `inmoderation`=0"; } if (!$private) { $sql .= " AND `private`=0"; } $sql .= " ORDER BY id"; if ($desc) { $sql .= ' DESC'; } $comments = query_full_array($sql); $this->comments = $comments; return $this->comments; }
} } break; default: // all of the image types $imagedata = query_full_array("SELECT `title`, `filename`, `albumid` FROM " . prefix('images') . " WHERE `id`=" . $comment['ownerid']); if ($imagedata) { $imgdata = $imagedata[0]; $image = $imgdata['filename']; if ($imgdata['title'] == "") { $title = $image; } else { $title = get_language_string($imgdata['title']); } $title = '/ ' . $title; $albmdata = query_full_array("SELECT `folder`, `title` FROM " . prefix('albums') . " WHERE `id`=" . $imgdata['albumid']); if ($albmdata) { $albumdata = $albmdata[0]; $album = $albumdata['folder']; $albumtitle = get_language_string($albumdata['title']); $link = "<a href=\"" . rewrite_path("/{$album}/{$image}", "/index.php?album=" . urlencode($album) . "&image=" . urlencode($image)) . "\">" . $albumtitle . $title . "</a>"; if (empty($albumtitle)) { $albumtitle = $album; } } } break; } $comment = truncate_string($comment['comment'], 123); echo "<li><div class=\"commentmeta\">" . sprintf(gettext('<em>%1$s</em> commented on %2$s:'), $author, $link) . "</div><div class=\"commentbody\">{$comment}</div></li>"; }
/** * Retrieves a list of all unique years & months * @param bool $yearsonly If set to true only the years' count is returned (Default false) * @param string $order 'desc' (default) or 'asc' for descending or ascending * @return array */ function getAllArticleDates($yearsonly = false, $order = 'desc') { $alldates = array(); $cleandates = array(); $sql = "SELECT date FROM " . prefix('news'); if (!zp_loggedin(MANAGE_ALL_NEWS_RIGHTS)) { $sql .= " WHERE `show` = 1"; } $result = query_full_array($sql); foreach ($result as $row) { $alldates[] = $row['date']; } foreach ($alldates as $adate) { if (!empty($adate)) { if ($yearsonly) { $cleandates[] = substr($adate, 0, 4); } else { $cleandates[] = substr($adate, 0, 7) . "-01"; } } } $datecount = array_count_values($cleandates); switch ($order) { case 'desc': default: krsort($datecount); break; case 'asc': ksort($datecount); break; } return $datecount; }
/** * Gets all categories * * @return array */ function getAllCategories() { deprecated_function_notify(gettext('Use the Zenpage class method instead.')); global $_zp_zenpage_all_categories; if (is_null($_zp_zenpage_all_categories) or isset($_GET['delete']) or isset($_GET['update']) or isset($_GET['save'])) { $_zp_zenpage_all_categories = query_full_array("SELECT * FROM " . prefix('news_categories') . " ORDER by sort_order", false, 'title'); } return $_zp_zenpage_all_categories; }