function buildProperties() { $fields = array(); $link = null; if ($this->command != 'Add Bookmark') { $link = $this->tree->getLink(SB_reqValInt('lid_acl')); if (!$link) { return null; } } else { $link = new SB_Tree_Link(array()); } $fields['-hidden1-'] = array('name' => 'lid_acl', 'value' => $link->id); $fields['URL'] = array('name' => 'url'); if ($this->command != 'Delete Bookmark') { /* Show the 'Retrieve Info' button only in case it has not been yet * performed */ $fields['Get Bookmark Information'] = array('type' => 'addbutton'); $fields['-hidden4-'] = array('name' => 'origin', 'value' => $this->command); } $fields['Bookmark Name'] = array('name' => 'name', 'maxlength' => 255); $size = strlen($link->comment); $MAXSIZETOEDIT = 4096; if ($size <= $MAXSIZETOEDIT) { $fields['Description'] = array('name' => 'comment', 'type' => 'textarea'); } else { $fields['-raw1-'] = SB_T("Description too long for inplace editing, please use export feature!"); } if ($this->um->getParam('user', 'use_favicons')) { $fields['Favicon'] = array('name' => 'favicon', 'maxsize' => 32000); $fields['-raw2-'] = ''; } if (strlen(SB_reqVal('url'))) { $link->url = SB_reqVal('url'); } if ($this->getInfo && strlen(SB_reqVal('url'))) { $link->name = SB_reqVal('name'); $link->comment = SB_reqVal('comment'); $link->favicon = SB_reqVal('favicon'); /* Try to get the title and favicon */ require_once './inc/pageparser.inc.php'; $page = new SB_PageParser($link->url); if ($page->getInformation(array('CHARSET', 'TITLE', 'FAVURL', 'DESC', 'KEYWORDS'))) { $cp = 'iso-8859-1'; if ($page->errorCode['CHARSET'] < PP_ERR) { $cp = $page->info['CHARSET']; } require_once './inc/converter.inc.php'; $c = new SB_Converter($this->um->getParam('config', 'use_conv_engine'), $cp); if (!$link->name && isset($page->info['TITLE'])) { $link->name = $c->utf8RawUrlDecode($page->info['TITLE']); } if (!$link->comment && isset($page->info['DESC'])) { $link->comment = $c->utf8RawUrlDecode($page->info['DESC']); } if ($this->um->getParam('user', 'use_favicons')) { if (!$link->favicon && isset($page->info['FAVURL'])) { $link->favicon = $page->info['FAVURL']; /* Show the retrieved favicon. */ if ($this->command == 'Add Bookmark') { /* Show the retrieved favicon. */ $wrong = SB_Skin::imgsrc('link_wrong_favicon'); $fields['-raw2-'] = "<div><img class='favicon' alt='' src='" . $link->favicon . "' onerror='this.src=\"{$wrong}\"'></div>"; } else { $fields['-raw2-'] = $this->_buildFavicon(SB_reqValInt('lid_acl'), $link->favicon); } } } } } $fields['URL']['value'] = $link->url; $fields['Bookmark Name']['value'] = $link->name; $fields['Description']['value'] = $link->comment; if ($this->um->getParam('user', 'use_favicons')) { if ($this->command != 'Add Bookmark') { $favicon = $link->favicon; if (substr($link->favicon, 0, 7) == 'binary:') { require_once './inc/faviconcache.inc.php'; $fc =& SB_FaviconCache::staticInstance(); $favicon = 'data:image/x-icon;base64,' . base64_encode($fc->faviconGet($link->favicon, null)); } if ($link->favicon) { $fields['-raw2-'] = $this->_buildFavicon($link->id, $link->favicon); } } $fields['Favicon']['value'] = $link->favicon; } $size = strlen($link->comment); $MAXSIZETOEDIT = 4096; if ($size <= $MAXSIZETOEDIT) { $fields['Description'] = array('name' => 'comment', 'type' => 'textarea', 'value' => $link->comment); } else { $fields['-raw1-'] = SB_T("Description too long for inplace editing, please use export feature!"); } $fields['Feed Bookmark'] = array('name' => 'is_feed', 'type' => 'checkbox', 'title' => SB_P('command::tooltip_is_feed')); if ($link->is_feed) { $fields['Feed Bookmark']['checked'] = null; } if ($this->command == 'Add Bookmark' || $this->tree->inMyTree($link->id_parent)) { $fields['Private'] = array('name' => 'private', 'type' => 'checkbox', 'title' => SB_P('command::tooltip_private')); if ($link->private) { $fields['Private']['checked'] = null; } } if ($link->is_dead) { $fields['Dead Bookmark'] = array('name' => 'is_dead_check', 'type' => 'checkbox', 'checked' => null, 'title' => SB_P('command::tooltip_is_dead_check')); $fields['-hidden2-'] = array('name' => 'is_dead', 'type' => 'hidden', 'value' => 1); } if ($this->um->getParam('config', 'use_outbound_connection')) { $fields['Exclude From Validation'] = array('name' => 'novalidate', 'type' => 'checkbox', 'title' => SB_P('command::tooltip_novalidate')); if (!$link->validate) { $fields['Exclude From Validation']['checked'] = null; } } $fields['Target'] = array('name' => 'link_target', 'value' => $link->target); if ($this->command != 'Delete Bookmark') { if ($this->um->getParam('config', 'comment_impex') && strlen($link->comment) > 0 || strlen($link->comment) >= $MAXSIZETOEDIT) { $fields['Export Description'] = array('name' => 'command', 'type' => 'addbutton'); } if ($this->um->getParam('config', 'comment_impex')) { $fields['Import Description'] = array('name' => 'command', 'type' => 'addbutton'); } } if ($this->command == 'Properties') { $fields['Delete Bookmark'] = array('type' => 'addbutton'); } return $fields; }
function validate($lid, $getFavicon) { if (!$this->um->isAuthorized('Validation', false, null, null, $lid)) { echo 'Access denied!'; die; } $link = $this->tree->getLink($lid); $deadCount = $link->is_dead + 1; // Mark as dead $set = array('tested' => array('now' => ''), 'is_dead' => $deadCount < 127 ? $deadCount : 0); $this->tree->updateLink($link->id, $set, false); $page = new SB_PageParser($link->url); $page->getInformation($getFavicon ? array('FAVURL') : null); // Unmark early if not dead if (!intval($page->isDead)) { $set['is_dead'] = 0; $this->tree->updateLink($link->id, $set, false); } $location = SB_Skin::imgsrc('link'); if ($page->isDead) { $location = SB_Skin::imgsrc('link_wrong_favicon'); } else { $set = array(); if (isset($page->info['FAVURL'])) { $favicon = $page->info['FAVURL']; $set['favicon'] = $favicon; if ($this->um->getParam('config', 'use_favicon_cache')) { $location = 'favicon.php?' . md5($favicon) . '=' . $link->id; } else { $location = $favicon; } } else { if ($getFavicon) { $set['favicon'] = ''; } } if (isset($set['favicon'])) { $this->tree->updateLink($link->id, $set, false); } } header('Location: ' . $location); exit; }