function SB_Writer_search() { parent::__construct(); $this->switches['flat'] = 1; $this->tree->sortMode = 'hits'; $this->search = SB_safeVal($_COOKIE, 'SB3SEARCH'); if (SB_reqChk('q') != '') { $this->search = SB_reqVal('q'); } $this->type = $this->um->getParam('user', 'default_search'); // Check search pattern if (preg_match("/^(url|desc|name|all):(.*)\$/i", $this->search, $matches)) { $this->type = $matches[1]; // If we have pattern then use it if ($this->type == 'url' || $this->type == 'desc' || $this->type == 'name' || $this->type == 'all') { $this->search = $matches[2]; } } $url = $this->um->getParamB64('user', 'search_engine_url'); $url = str_replace('%SEARCH%', $this->search, $url); $url = str_replace('%BASEURL%', urlencode(SB_Page::absBaseUrlShort()), $url); $url = str_replace('%LOGO%', urlencode(SB_Page::absBaseUrl() . SB_Skin::imgsrc('logo')), $url); $this->engineURL = $url; // We would not get here if no engine is specified if ($this->um->getParam('user', 'hide_xslt') || SB_reqVal("web") == 1) { header('Location: ' . $this->engineURL); exit; } }
function drawLink(&$node, &$link) { $this->path = implode('/', $this->nodes); $url = $link->url; if (!($url[0] == 'j' && strpos($url, 'javascript:') !== false)) { $url = SB_Page::absBaseUrl() . 'go.php?id=' . $link->id . '&url=' . $link->url; } $this->write(array($this->path . '/' . $link->id, 'flags', $link->name, '', $this->quoteAtt($url))); }
function drawLink(&$node, &$link) { $this->path = implode('/', $this->nodes); $comment = preg_replace("/[\n\r]/m", ' ', $link->comment); if ($link->favicon && $this->um->getParam('user', 'use_favicons') && $this->um->getParam('config', 'use_favicon_cache')) { $link->favicon = SB_Page::absBaseUrl() . 'favicon.php?' . md5($link->favicon) . '=' . $link->id; } $this->write(array(str_repeat('.', $node->level), $link->name, $this->quoteAtt($link->url), $comment, $link->favicon)); }
function getLinkAttMap(&$bmkAtt, &$node, &$link) { // Append absolute URL to relative urls if (!preg_match('/^\\w+:/', $link->url)) { $link->url = SB_Page::absBaseUrl() . $link->url; } $bmkAtt['href'] = $this->quoteAtt($link->url); $bmkAtt['modified'] = $this->getDateISO8601($link->changed); $bmkAtt['visited'] = $this->getDateISO8601($link->visited); }
function getXSLPath($file) { /** * The path to URL should use & * IE - handles OK * Firefox - https://bugzilla.mozilla.org/show_bug.cgi?id=286132 * Safari - omits parameters after the first * * Workaround, use ; as parameter delimiter. */ return SB_Page::absBaseUrl() . 'xsl.php?file=' . $file . ';skin=' . str_replace(' ', '%20', SB_Skin::get()); }
function writeMenuItem($id, &$itemArray) { static $expertMode = null; if ($expertMode === null) { $expertMode = $this->um->getParam('user', 'expert_mode'); } $command = SB_safeVal($itemArray, 'name'); $link = SB_safeVal($itemArray, 'href'); $callback = SB_safeVal($itemArray, 'callback'); $acl = SB_safeVal($itemArray, 'acl'); $optional = SB_safeVal($itemArray, 'optional', false); $more = SB_safeVal($itemArray, 'more', false); $class = 'item'; if (!$command) { $class .= ' separator'; } else { if ($optional && !$expertMode) { $class .= ' optional'; } } $div = "\t" . '<div id="' . $id . '" class="' . $class . '"'; if ($command) { $div .= ' onmouseover="SB_itemOn(this);"' . ' onmouseout="SB_itemOff(this);"'; } if ($command && !$link) { $div .= ' x_acl="' . $acl . '"' . ' x_cmd="' . $command . '"'; } echo $div . '>'; if ($link) { static $target; if ($target == null) { $target = SB_Page::target(); } if (strstr($link, 'http') !== 0) { $link = SB_Page::absBaseUrl() . $link; } echo '<a class="menuLink" href="' . $link . '"' . $target . '>'; } else { echo '<a href="javascript:SB_itemDoAlt(\'' . $id . '\'' . ($callback ? ',\'' . $callback . '\'' : '') . ')">'; } echo SB_T($command); if ($command == 'Log Out') { echo ' (' . $this->um->username . ')'; } if ($link) { echo '</a>'; } echo "</div>\r"; }
function drawHead() { $this->drawXMLPI(); $this->drawTagOpen('rss', array('version' => '2.0', 'xmlns:rss' => 'http://purl.org/rss/2.0/')); $this->drawTagOpen('channel'); $this->drawTag('title', null, $this->quoteText($this->getTitle())); $desc = $this->settingsValue('feed_desc') . ' ' . SB_Page::absBaseUrl(); $this->drawTag('description', null, $this->quoteText($desc)); $this->drawTagOpen('image'); $this->drawTag('title', null, $this->quoteText($this->getTitle())); $this->drawTag('url', null, SB_Page::absBaseUrl() . SB_Skin::imgsrc('root_transparent')); $this->drawTag('link', null, $this->settingsValue('feed_link')); $this->drawTagClose('image'); $this->drawTag('link', null, $this->settingsValue('feed_link')); $this->drawTag('managingEditor', null, $this->quoteText($this->settingsValue('feed_managing_editor'))); $this->drawTag('webMaster', null, $this->quoteText($this->settingsValue('feed_webmaster'))); $this->drawTag('copyright', null, $this->quoteText($this->settingsValue('feed_copyright'))); $this->drawTag('language', null, str_replace('_', '-', $this->um->getParam('user', 'lang'))); $this->drawTag('generator', null, 'SiteBar ' . SB_CURRENT_RELEASE . ' (Bookmark Server; http://sitebar.org/)'); // Time to live in minutes $this->drawTag('ttl', null, '60'); }
function drawNodeOpen(&$node) { $filler = str_repeat("\t", $node->level); $added = $node->added ? strtotime($node->added) : mktime(); $feedname = $node->name; // If we have subfolders if ($node->nodeCount()) { echo $filler . '<DT><H3 ADD_DATE="' . $added . '">' . $node->name . "</H3>\r"; if ($node->comment) { echo $filler . '<DD>' . $node->comment . "\r"; } echo $filler . "<DL><p>\r"; $filler = str_repeat("\t", $node->level + 1); $feedname = '@' . SB_T('Content'); } // Do we have some content if ($node->linkCount()) { $url = SB_Page::absBaseUrl() . 'index.php?w=rss&sd=0&root=' . $node->id; if ($this->switches['hits']) { $url .= '&hits=1'; } echo $filler . '<DT><A HREF="' . SB_Page::absBaseUrl() . 'index.php"' . ' ADD_DATE="' . $added . '"' . ' FEEDURL="' . $url . '">' . $feedname . "</A>\r"; } }
function headerContent($inscript) { ?> <link rel="stylesheet" type="text/css" href="<?php echo SB_Skin::webPath(); ?> /sitebar.css?version=<?php echo STATIC_VERSION; ?> " media="all"> <script type="text/javascript" src="<?php echo SB_Page::absBaseUrl(); ?> js/sitebar.js?version=<?php echo STATIC_VERSION; ?> "></script> <script type="text/javascript"> SB_gSkinDir = '<?php echo SB_Skin::webPath(); ?> /'; <?php echo $inscript . "\n"; ?> </script> <?php }
function _buildExportUrl() { $url = SB_Page::absBaseUrl() . 'index.php'; $params = array(); if (!SB_reqChk('sd')) { $params[] = 'sd=0'; } if (!SB_reqChk('hits') && $this->um->getParam('config', 'use_hit_counter')) { $params[] = 'hits=0'; } // Add value foreach (array('w', 'sort', 'username', 'pass', 'max', 'len', 'cmd', 'exr', 'igp', 'flat', 'cp', 'mix') as $check) { if (SB_reqChk($check) && strlen(SB_reqVal($check))) { if ($check == 'w' && SB_reqVal($check) == 'sitebar') { continue; } if ($check == 'sort' && SB_reqVal($check) == 'custom') { continue; } if ($check == 'cp' && SB_reqVal($check) == 'utf-8') { continue; } $params[] = $check . '=' . SB_reqVal($check); } } if (SB_reqChk('nid_acl') && SB_reqValInt('nid_acl') > 0) { $params[] = 'root=' . SB_reqValInt('nid_acl'); } if (count($params)) { $url .= '?' . implode('&', $params); } return $url; }
/** * If the token is invalid, then all tokens for the given username will be invalidated. */ function validate($uid, $token, $redirect = false) { // Select the right token $rset = $this->db->select(null, 'sitebar_token', array('uid' => $uid, '^1' => 'AND', 'token' => $token, '^2' => 'AND expires>=' . time())); $tokenRec = $this->db->fetchRecord($rset); if ($tokenRec) { $user = $this->um->getUser($uid); switch ($tokenRec['type']) { case 'verify': // Delete all existing tokens for this user now $this->invalidateTokens($uid); $this->db->update('sitebar_user', array('verified' => 1), array('uid' => $user['uid'])); if ($this->um->getParam('config', 'users_must_verify_email')) { $paraName = 'usermanager::signup_info_verified'; $paraAtt = array($user['username'], SB_Page::absBaseUrl()); if ($this->um->getParam('config', 'users_must_be_approved') && !$user['approved']) { $paraName = 'usermanager::signup_approval_verified'; $paraAtt[] = $this->um->getApproveUserUrl($user['username']); $paraAtt[] = $this->um->getRejectUserUrl($user['username']); $paraAtt[] = $this->um->getPendingUsersUrl(); } $this->um->mailToAdmins('SiteBar: New SiteBar User Verified E-mail', $paraName, $paraAtt); } if ($redirect) { // No & - it does not go to HTML, it is HTTP redirect SB_redirect('command.php?command=Email+Verified&do=yes&uid=' . $uid); } break; case 'reset': if ($redirect) { // No & - it does not go to HTML, it is HTTP redirect SB_redirect('command.php?command=New+Password&uid=' . $uid . '&token=' . $token); } break; } return true; } if ($redirect) { // No & - it does not go to HTML, it is HTTP redirect SB_redirect('command.php?command=Invalid+Token&do=yes'); } return false; }
function privateMessage($params) { $gid = isset($params['gid']) && $params['gid'] ? $params['gid'] : null; $isModerator = $gid && $this->isModerator($gid); $isAdmin = $this->isAdmin(); $role = ($isModerator || $isAdmin) && isset($params['from_role']) ? $params['from_role'] : 'user'; $db =& SB_Database::staticInstance(); $insert = array('uid' => $this->uid, 'gid' => $gid, 'sent' => array('now' => null), 'role' => $role, 'format' => $isAdmin && $params['format'] ? $params['format'] : 'plain', 'to_label' => $params['to_label'], 'subject' => $params['subject'], 'message' => $params['message']); $db->insert('sitebar_message', $insert); $mid = $db->getLastId(); if ($isAdmin && $params['expires']) { $insert['expires'] = $params['expires']; } $counter = 0; $safe_mode = in_array(strtolower(ini_get('safe_mode')), array("1", "on", "yes", "true")); if (!$safe_mode) { // We need more time if our database is slow set_time_limit(intval(count($params['to_list']) / 20) + 10); } $insert = array('mid' => $mid); // Insert recipients foreach ($params['to_list'] as $uid => $user) { if ($uid == SB_ANONYM) { continue; } $userparams = $user['params']; $this->explodeParams($userparams, 'tmp'); if (($isModerator || $isAdmin) && isset($params['respect']) && !$this->getParam('tmp', 'allow_info_mails')) { continue; } SB_SetLanguage($this->getParam('tmp', 'lang')); $counter++; $insert['uid'] = $uid; $db->insert('sitebar_message_folder', $insert); if ($params['pm_notification'] && $user['verified'] && $this->getParam('config', 'use_mail_features') && $this->getParam('tmp', 'pm_notification')) { $subject = SB_T('SiteBar: Private Message Notification'); $msg = SB_P('command::pm_notification', array($params['subject'], SB_Page::absBaseUrl())); $this->sendMail(array('email' => $user['email']), $subject, $msg); } } SB_SetLanguage($this->getParam('user', 'lang')); $insert['folder'] = 'outbox'; // Insert senders if (($isModerator || $isAdmin) && $role != 'user') { $gid = $role == 'admins' ? SB_ADMIN_GROUP : $gid; foreach ($this->getMembers($gid) as $uid => $user) { $userparams = $user['params']; $this->explodeParams($userparams, 'tmp'); SB_SetLanguage($this->getParam('tmp', 'lang')); $counter++; $insert['uid'] = $uid; $db->insert('sitebar_message_folder', $insert); } } else { $insert['uid'] = $this->uid; $db->insert('sitebar_message_folder', $insert); } SB_SetLanguage($this->getParam('user', 'lang')); }
function putCommonHeaders($close = true) { static $agent = null; if ($agent === null) { $agent = 'SiteBar/' . str_replace(' ', '', SB_CURRENT_RELEASE) . ' (Bookmark Server; http://sitebar.org/)'; } $this->http->put('User-Agent: ' . $agent . "\r\n"); // We cannot use Keep-Alive if we do not want to complicate the communication a lot. // It is not guaranteed that the connection would be kept and we do usually only 3 // hits to one site. Keep-Alive could speed it up, but probably not very dramatically. // If someone wants to go this way, then he must count with other problems. He must // ensure that he flushes the stream, reads only what he should (some sites do not // sent Content-length!). $this->http->put('Connection: Close' . "\r\n"); $this->http->put('Referer: ' . SB_Page::absBaseUrl() . "\r\n"); if ($close) { $this->http->put("\r\n"); } }
function SearchEngine() { $um = SB_UserManager::staticInstance(); $name = $um->getParamB64('config', 'feed_root_name'); if (!strlen($name)) { $name = 'SiteBar'; } ?> # SiteBar plug-in <search name="<?php echo $name; ?> " description="<?php echo SB_T('Search in SiteBar Bookmarks'); ?> " method="GET" action="<?php echo SB_Page::absBaseUrl(); ?> search.php" searchForm="<?php echo SB_Page::absBaseUrl(); ?> index.php" > <input name="q" user> <input name="sourceid" value="sitebar-search"> </search> <?php exit; }
function _commandSendEmail($to, $subject, $group = null) { // Prefetch to have it in our language $okStr = SB_T('%s - ok.'); $errorStr = SB_T('%s - error!'); $message = stripslashes(SB_reqVal('message')); foreach ($to as $uid => $user) { $userparams = $user['params']; $this->um->explodeParams($userparams, 'tmp'); if (SB_reqVal('checkrcpt')) { if (SB_reqChk('respect') && !$this->um->getParam('tmp', 'allow_info_mails')) { continue; } if (SB_reqChk('verified') && !$user['verified']) { continue; } } SB_SetLanguage($this->um->getParam('tmp', 'lang')); $body = ''; if ($group) { $body = SB_P('command::contact_group', array($group, $message, SB_Page::absBaseUrl())); } else { $body = SB_P('command::contact', array($message, SB_Page::absBaseUrl())); } if (!$this->um->email || !$this->checkEmailCorrectness($this->um->email)) { continue; } $ret = $this->um->sendMail($user, SB_T($subject), $body, $this->um->name, $this->um->email); // No translation here if ($ret) { $this->warn('%s', sprintf($okStr, $user['completenamehtml'])); } else { $this->error('%s', sprintf($errorStr, $user['completenamehtml'])); } } SB_SetLanguage($this->um->getParam('user', 'lang')); }
* * * 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/>. * ******************************************************************************/ header('Content-Type: application/xml; charset=utf-8'); //text/xml is ambiguous for some clients and slower require_once './inc/localizer.inc.php'; require_once './inc/errorhandler.inc.php'; require_once './inc/page.inc.php'; require_once './inc/usermanager.inc.php'; $baseurl = str_replace('skins', '', SB_Page::absBaseUrl()); $um = SB_UserManager::staticInstance(); function niceUrl($writer) { global $baseurl; global $um; if ($um->getParam('config', 'use_nice_url')) { return "concat('{$baseurl}news/{$writer}/',substring(./@id,2),'/',\$root)"; } else { return "concat('{$baseurl}index.php?w={$writer}&flat=1&sort=',substring(./@id,2),'&root=',\$root)"; } } ?> <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"> <xsl:output method="html"
<![CDATA[ <?php $height = "400px"; if (isset($_GET['height'])) { if (preg_match('/^(\\d+)(.*)?$/', $_GET['height'], $reg)) { $height = $reg[1]; if ($reg[2] == '%') { $height .= '%'; } else { $height .= 'px'; } } } require_once './inc/errorhandler.inc.php'; require_once './inc/page.inc.php'; require_once './inc/usermanager.inc.php'; $um = SB_UserManager::staticInstance(); $url = SB_Page::absBaseUrl(); ?> <iframe style="border: none; width:100%;height:<?php echo $height; ?> " src="<?php echo $url; ?> ?target=_top" /> ]]> </Content> </Module>
</xsl:attribute> <xsl:attribute name="type">text/css</xsl:attribute> <xsl:attribute name="media">all</xsl:attribute> </xsl:element> <xsl:element name="script"> <xsl:attribute name="type">text/javascript</xsl:attribute> <xsl:attribute name="src"><?php echo SB_Page::absBaseUrl() . "skins/sitebar.js?version=" . STATIC_VERSION; ?> </xsl:attribute> </xsl:element> </head> <body class="siteBar siteBarBaseFont siteBarPageBackground"> <div style="display: none" id="sb_absBaseUrl"><?php echo SB_Page::absBaseUrl(); ?> </div> <div class="title cmnTitleColorInverse"> <xsl:value-of select="xbel/title" /> </div> <xsl:if test="/xbel/folder/@id != 'n'"> <xsl:call-template name="displayBack" /> </xsl:if> <xsl:for-each select="xbel/folder/*"> <xsl:choose> <xsl:when test="local-name(.)='folder'"> <xsl:call-template name="displayFolder" /> </xsl:when> <xsl:when test="local-name(.)='bookmark'"> <xsl:call-template name="displayBookmark" />
function drawHead() { $this->drawHeadPage(); if ($this->useToolTips) { ?> <div id="toolTip"></div> <?php } $this->writeMenu('node', $this->nodeMenu); $this->writeMenu('link', $this->linkMenu); // TODO $this->writeMenu('nodeDrag', $this->nodeDragMenu); // TODO $this->writeMenu('linkDrag', $this->linkDragMenu); $this->drawHeadLogo(); $this->drawToolBar(); $this->drawWarning(); if ($this->appError) { echo <<<_DOC <div id="warning"> {$this->appError} </div> _DOC; } if ($this->switches['user'] && strlen($this->switches['user'])) { $message = SB_T("Hide bookmarks from %s!", $this->switches['user']); echo ' <div id="info"><a href="' . SB_Page::absBaseUrl() . '?user="******"http://sitebar.org/version.php"); $lines = $page->getContent(); if (!$this->hasErrors()) { $this->um->db->setData('version', 'Version'); $this->um->db->setData('version', 'lastcheck', time()); $this->um->db->setData('version', 'failed_count'); foreach ($lines as $line) { if (preg_match("/^(.*)=(.*)\$/", $line, $reg)) { $this->um->db->setData('version', $reg[1], $reg[2]); } } } else { $errors =& $this->getErrors(); // Hide errors $errors = array(); echo '<div id="versionCheck">'; echo SB_T('Error during version check!'); echo '<br>'; echo SB_T('Will try in %d hours again.', 6); echo "</div>\r"; $this->um->db->setData('version', 'lastcheck', time() - $interval + 60 * 60 * 6); $this->um->db->setData('version', 'failed_count', intval($this->um->db->getData('version', 'failed_count')) + 1); } } if (!$this->um->db->getData('version', 'failed_count')) { $lastVersion = $this->um->db->getData('version', 'Version'); if ($lastVersion && version_compare(SB_CURRENT_RELEASE, $lastVersion, '<')) { $this->um->db->setData('version', 'newversion', $lastVersion); echo '<div id="versionCheck">'; $link = sprintf(' <a href="%s"' . SB_Page::target() . '>%s</a>', $this->um->db->getData('version', 'Download URL'), $lastVersion); echo SB_T('New version available') . ': ' . $link; echo '<br>'; echo SB_T('Severity') . ': ' . $this->um->db->getData('version', 'Severity'); echo "</div>\r"; } } } } }
function drawFoot() { $baseurl = SB_Page::absBaseUrl(); ?> </form> <div class="footer cmnTitleColorInverse"> <?php echo SB_T("Messages from SiteBar installation at"); ?> <a class="url" href="<?php echo $baseurl; ?> "><?php echo $baseurl; ?> </a> </div> </body> </html> <?php }
function drawChildren(&$node) { $count = $node->childrenCount(); foreach ($node->getChildren() as $child) { $count--; if ($child->type) { continue; } if ($child->type_flag == 'n') { if (!$this->drawNode($child, $count == 0)) { return false; } } else { $child->ignoreHits = false; $child->origURL = $child->url; if ($this->switches['hits']) { $child->ignoreHits = strlen($child->url) && ($child->url[0] == 'j' && strpos($child->url, 'javascript:') !== false || $child->url[0] == 'm' && strpos($child->url, 'mailto:') !== false); if ($child->id && !$child->ignoreHits && false) { if ($this->switches['shorten']) { $child->url = 'go.php?id=' . $child->id; } else { $child->url = SB_Page::absBaseUrl() . 'go.php?id=' . $child->id . '&url=' . urlencode($child->getUrl()); } } } if ($this->switches['len'] !== null) { $child->comment = substr($child->comment, 0, $this->switches['len']); } $child->name = $this->fromUTF8($child->name); $child->comment = $this->fromUTF8($child->comment); $this->drawLink($node, $child, $count == 0); $this->countLinks++; if ($this->switches['max'] !== null && $this->countLinks == $this->switches['max']) { return false; } } } return true; }