function SB_Validator() { $this->um =& SB_UserManager::staticInstance(); $this->tree =& SB_Tree::staticInstance(); $this->db =& SB_Database::staticInstance(); $this->fc =& SB_FaviconCache::staticInstance(); if (!$this->um->setupDone || !$this->um->isLogged()) { echo 'Access denied!'; die; } }
function createLink($xmlTag) { $xmlTag['attributes']['url'] = $xmlTag['attributes']['href']; foreach ($xmlTag['children'] as $index => $value) { if ($value['tag'] == 'title') { $xmlTag['attributes']['name'] = $value['value']; } if ($value['tag'] == 'desc') { $xmlTag['attributes']['comment'] = $value['value']; } if ($value['tag'] == 'info') { foreach ($value['children'] as $index2 => $value2) { if ($value2['tag'] == 'metadata') { if (isset($value2['attributes']['owner']) == "Mozilla") { if (isset($value2['attributes']['WebPanel'])) { $xmlTag['attributes']['is_sidebar'] = $value2['attributes']['WebPanel']; } if (isset($value2['attributes']['FeedURL'])) { $xmlTag['attributes']['url'] = $value2['attributes']['FeedURL']; $xmlTag['attributes']['is_feed'] = 1; } if (isset($value2['attributes']['IconURI'])) { $xmlTag['attributes']['favicon'] = $value2['attributes']['IconURI']; } else { if (isset($value2['attributes']['Icon'])) { if (preg_match("/^data:image\\/(.*?);base64,(.*)\$/", $value2['attributes']['Icon'], $reg)) { $fc =& SB_FaviconCache::staticInstance(); $xmlTag['attributes']['favicon'] = $fc->saveFaviconBase64($reg[2]); } } } // Icon management missing } } } } } $xmlTag['attributes']['changed'] = SB_safeVal($xmlTag['attributes'], 'modified'); return new SB_Tree_Link($xmlTag['attributes']); }
<?php /****************************************************************************** * SiteBar 3 - The Bookmark Server for Personal and Team Use. * * Copyright (C) 2004-2008 Ondrej Brablc <http://brablc.com/mailto?o> * * Copyright (C) 2004 Gunnar Wrobel <*****@*****.**> * * * * This program is free software: you can redistribute it and/or modify * * it under the terms of the GNU Affero General Public License as published * * by the Free Software Foundation, either version 3 of the License, or * * (at your option) any later version. * * * * This program is distributed in the hope that it will be useful, * * but WITHOUT ANY WARRANTY; without even the implied warranty of * * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * * GNU Affero General Public License for more details. * * * * You should have received a copy of the GNU Affero General Public License * * along with this program. If not, see <http://www.gnu.org/licenses/>. * ******************************************************************************/ require_once './inc/faviconcache.inc.php'; $fc =& SB_FaviconCache::staticInstance(); $favicon_md5 = key($_GET); $lid = $_GET[$favicon_md5]; if ('.' . $lid != '.' . intval($lid)) { // We may have encoded favicon URL there $lid = base64_decode($lid); } $fc->faviconReturn($favicon_md5, $lid, isset($_GET['refresh']));
function getInformation($info = null) { if (!$this->retrieveHTTPHeaders()) { $this->isDead = true; return false; } // We wanted just validation if (!$info) { return true; } foreach ($info as $value) { $this->errorCode[$value] = PP_ERR; $this->info[$value] = null; } // Get the page head so that we can get more information $this->retrieveHEADTag(); if (!$this->hasErrors(E_ERROR)) { foreach ($info as $value) { $this->errorCode[$value] = 0; $execute = 'parseHEADTagFor' . $value; if (method_exists($this, $execute)) { $this->{$execute}(); } } } // Verify icon on FAVURL if (in_array('FAVURL', $info)) { // Not found in HEAD, try default location if (!isset($this->info['FAVURL'])) { $defLoc = $this->base . '/favicon.ico'; if ($this->expertMode) { $this->warn('Favicon not found! Trying default favicon location %s.', array($defLoc)); } $this->info['FAVURL'] = $defLoc; } if (!$this->setUrlInformation($this->info['FAVURL'])) { return false; } if (!$this->connect()) { unset($this->info['FAVURL']); $this->errorCode['FAVURL'] = PP_ERR; if ($this->expertMode) { $this->warn('Favicon not found!'); } } else { $ico = ''; $this->errorCode['FAVICON'] = $this->retrieveFAVICON($ico); if ($this->errorCode['FAVICON'] <= PP_OK) { $this->info['FAVICON'] = $ico; $this->errorCode['FAVURL'] = $this->errorCode['FAVICON']; require_once './inc/faviconcache.inc.php'; require_once './inc/usermanager.inc.php'; $fc =& SB_FaviconCache::staticInstance(); if ($this->um->getParam('config', 'use_favicon_cache') && !$fc->isFaviconCached($this->info['FAVURL'])) { // We have so save it $fc->saveFavicon($this->info['FAVURL'], $this->info['FAVICON']); } } else { unset($this->info['FAVURL']); $this->errorCode['FAVURL'] = PP_ERR; } } } return true; }
function commandProperties() { if (SB_reqVal('private')) { $link = $this->tree->getLink(SB_reqValInt('lid_acl')); if (!$link) { return; } if (!$this->tree->inMyTree($link->id_parent)) { $this->um->accessDenied(); return; } } $limit = $this->um->getParam('config', 'comment_limit'); if ($limit && $limit < strlen(SB_reqVal('comment'))) { $this->error('The description length exceeds maximum length of %s bytes!', array($limit)); return; } $favicon = SB_reqVal('favicon'); if ($this->um->getParam('config', 'use_favicon_cache')) { require_once './inc/faviconcache.inc.php'; $fc =& SB_FaviconCache::staticInstance(); if (preg_match("/^data:image\\/(.*?);base64,(.*)\$/", $favicon, $reg)) { $favicon = $fc->saveFaviconBase64($reg[2]); } else { // Delete old URL favicon from cache on update to allow new version $fc->purge(SB_reqValInt('lid_acl')); } } $update = array('name' => SB_reqVal('name'), 'url' => SB_reqVal('url'), 'favicon' => $favicon, 'target' => SB_reqVal('link_target'), 'private' => SB_reqVal('private') ? 1 : 0, 'is_feed' => SB_reqVal('is_feed') ? 1 : 0, 'comment' => SB_reqVal('comment'), 'validate' => SB_reqVal('novalidate') ? 0 : 1); if (SB_reqVal('is_dead') && !SB_reqVal('is_dead_check')) { $update['is_dead'] = 0; } $this->tree->updateLink(SB_reqValInt('lid_acl', true), $update); }
function buildShowAllIcons() { $fields = array(); $carpet = ''; require_once './inc/faviconcache.inc.php'; $fc =& SB_FaviconCache::staticInstance(); $cacheItems = $fc->faviconGetAll(); foreach ($cacheItems as $item) { $favicon = 'favicon.php?' . $item['ckey']; $carpet .= '<img class="favicon" height=16 width=16 alt="" src="' . $favicon . '">' . "\n"; } $fields['-raw1-'] = $carpet; return $fields; }
function loadNetscape(&$parent) { while (($line = array_shift($this->lines)) !== null) { if (preg_match('/<meta\\s+http-equiv=["\']Content-Type["\']\\s+' . 'content=["\'].*?\\bcharset=(.*?)["\']\\s*>/i', $line, $reg)) { if (strcasecmp($reg[1], $this->charSet)) { if ($this->useEngine && $this->getEngine() != SB_CHARSET_IGNORE) { $this->setCharSet($reg[1]); $this->warn('Character set overriden from document to %s!', array($reg[1])); } else { $this->warn('There is no conversion engine available to convert from %s character set!', array($reg[1])); } } } $line = $this->toUTF8($line); // Open node if (preg_match('/<DT.*><H3([^>]*)>([^<]*)<\\/H3>/i', $line, $reg)) { $rec = array(); $params = $reg[1]; $rec['name'] = $reg[2]; if (strlen($rec['name']) == 0) { $rec['name'] = '?'; } $this->_loadNetscapeComment($rec); $node = new SB_Tree_Node($rec); // Yes recursive! $this->loadNetscape($node); $parent->addNode($node); $this->importedFolders++; continue; } // Add link to current node if (preg_match('/<DT.*><A HREF="([^"]+)"([^>]*)>([^<]*)<\\/A>/i', $line, $reg)) { $rec = array(); $rec['url'] = $reg[1]; $params = $reg[2]; $rec['name'] = $reg[3]; if (strlen($rec['name']) == 0) { $rec['name'] = $rec['url']; } // Take live feeds URL if exists instead of site url if (preg_match('/FEEDURL="([^"]+)"/i', $params, $reg)) { $rec['url'] = $reg[1]; } if (preg_match('/ICON="([^"]+)"/i', $params, $reg)) { $rawdata = $reg[1]; if (preg_match("/^data:image\\/(.*?);base64,(.*)\$/", $rawdata, $reg2)) { $fc =& SB_FaviconCache::staticInstance(); $rec['favicon'] = $fc->saveFaviconBase64($reg2[2]); } else { if (substr($rawdata, 0, 7) == "http://") { $rec['favicon'] = $rawdata; } } } $this->_loadNetscapeComment($rec); $parent->addLink(new SB_Tree_Link($rec)); $this->importedLinks++; continue; } // Close node - break recursion if (stristr($line, "</DL>")) { return true; } } return true; }
function convertBinaryIcons() { echo "Convert binary icons ...\r"; $rset = $this->db->select('*', 'sitebar_link', "favicon LIKE 'data:image%'"); $fc =& SB_FaviconCache::staticInstance(); $converted = 0; while ($rec = $this->db->fetchRecord($rset)) { if (preg_match("/^data:image\\/(.*?);base64,(.*)\$/", $rec['favicon'], $reg)) { $update = array('favicon' => $fc->saveFaviconBase64($reg[2])); $this->tree->updateLink($rec['lid'], $update); $converted++; } } echo 'Converted ' . $converted . " favicons.\r"; }