public function setUp() { $GLOBALS['enableVoting'] = true; //FIXME: create true new instance $this->vs = SemanticScuttle_Service_Factory::get('Vote'); $this->vs->deleteAll(); $this->bs = SemanticScuttle_Service_Factory::get('Bookmark'); }
protected function setUp() { $this->us = SemanticScuttle_Service_Factory::get('User'); $this->bs = SemanticScuttle_Service_Factory::get('Bookmark'); $this->bs->deleteAll(); $this->b2ts = SemanticScuttle_Service_Factory::get('Bookmark2Tag'); $this->b2ts->deleteAll(); $this->tts = SemanticScuttle_Service_Factory::get('Tag2Tag'); $this->tts->deleteAll(); $this->tsts = SemanticScuttle_Service_Factory::get('TagStat'); $this->tsts->deleteAll(); }
function startElement($parser, $name, $attrs) { global $depth, $status, $tplVars, $userservice; $bookmarkservice = SemanticScuttle_Service_Factory::get('Bookmark'); if ($name == 'POST') { $newstatus = $status; while (list($attrTitle, $attrVal) = each($attrs)) { switch ($attrTitle) { case 'HREF': $bAddress = $attrVal; break; case 'DESCRIPTION': $bTitle = $attrVal; break; case 'EXTENDED': $bDescription = $attrVal; break; case 'TIME': $bDatetime = $attrVal; break; case 'TAG': $tags = strtolower($attrVal); break; case 'PRIVATE': if ($attrVal == 'yes') { $newstatus = 2; } break; } } if ($bookmarkservice->bookmarkExists($bAddress, $userservice->getCurrentUserId())) { $tplVars['error'] = T_('You have already submitted this bookmark.'); } else { // Strangely, PHP can't work out full ISO 8601 dates, so we have to chop off the Z. $bDatetime = substr($bDatetime, 0, -1); // If bookmark claims to be from the future, set it to be now instead if (strtotime($bDatetime) > time()) { $bDatetime = gmdate('Y-m-d H:i:s'); } $res = $bookmarkservice->addBookmark($bAddress, $bTitle, $bDescription, '', $newstatus, $tags, null, $bDatetime, true, true); if ($res) { $tplVars['msg'] = T_('Bookmark imported.'); } else { $tplVars['error'] = T_('There was an error saving your bookmark. Please try again or contact the administrator.'); } } } if (!isset($depth[(int) $parser])) { $depth[(int) $parser] = 0; } $depth[(int) $parser]++; }
/** * Verify that we only get admin tags, not tags from * non-admin people */ public function testOnlyAdminTags() { $t2t = SemanticScuttle_Service_Factory::get('Tag2Tag'); $t2t->deleteAll(); $menu2Tag = reset($GLOBALS['menu2Tags']); //we have a subtag now $this->addBookmark($this->getAdminUser(), null, 0, $menu2Tag . '>adminsubtag'); //add another bookmark now, but for a normal user $this->addBookmark(null, null, 0, $menu2Tag . '>normalsubtag'); $res = $this->getRequest('?tag=' . $menu2Tag)->send(); $this->assertResponseJson200($res); $data = json_decode($res->getBody()); $this->assertInternalType('array', $data); //we should have only one subtag now, the admin one $this->assertEquals(1, count($data)); $this->assertEquals('adminsubtag', $data[0]->data->title); }
protected function setUp() { if ($GLOBALS['unittestUrl'] === null) { $this->assertTrue(false, 'Unittest URL not set in config'); } if ($this->urlPart === null) { $this->assertTrue(false, 'Set the urlPart variable'); } $this->url = $GLOBALS['unittestUrl'] . $this->urlPart; //clean up before test $configFile = $GLOBALS['datadir'] . '/config.testing-tmp.php'; if (file_exists($configFile)) { unlink($configFile); } $this->us = SemanticScuttle_Service_Factory::get('User'); $this->us->deleteAll(); $this->bs = SemanticScuttle_Service_Factory::get('Bookmark'); $this->bs->deleteAll(); $this->b2t = SemanticScuttle_Service_Factory::get('Bookmark2Tag'); $this->b2t->deleteAll(); }
/** * Retrieves the UID of an admin user. * If that user does not exist in the database, it is created. * * @return integer UID of admin user */ protected function getAdminUser() { if (count($GLOBALS['admin_users']) == 0) { $this->fail('No admin users configured'); } $adminUserName = reset($GLOBALS['admin_users']); $us = SemanticScuttle_Service_Factory::get('User'); $uid = $us->getIdFromUser($adminUserName); if ($uid === null) { //that user does not exist in the database; create it $uid = $us->addUser($adminUserName, rand(), 'unittest-admin-' . $adminUserName . '@example.org'); } return $uid; }
* @param integer $limit Number of tags to return. Defaults to 1000 * * Part of SemanticScuttle - your social bookmark manager. * * PHP version 5. * * @category Bookmarking * @package SemanticScuttle * @author Benjamin Huynh-Kim-Bang <*****@*****.**> * @author Christian Weiske <*****@*****.**> * @author Eric Dane <*****@*****.**> * @license GPL http://www.gnu.org/licenses/gpl.html * @link http://sourceforge.net/projects/semanticscuttle */ $httpContentType = 'application/json'; require_once '../www-header.php'; $limit = 30; $beginsWith = null; $currentUserId = $userservice->getCurrentUserId(); if (isset($_GET['limit']) && is_numeric($_GET['limit'])) { $limit = (int) $_GET['limit']; } if (isset($_GET['beginsWith']) && strlen(trim($_GET['beginsWith']))) { $beginsWith = trim($_GET['beginsWith']); } $listTags = SemanticScuttle_Service_Factory::get('Bookmark2Tag')->getAdminTags($limit, $currentUserId, null, $beginsWith); $tags = array(); foreach ($listTags as $t) { $tags[] = $t['tag']; } echo json_encode($tags);
/** * Loads self::$db if it is not loaded already. * Dies if the connection could not be established. * * @return void */ protected static function loadDb() { global $dbhost, $dbuser, $dbpass, $dbname, $dbport, $dbpersist, $dbtype, $dbneedssetnames; if (self::$db !== null) { return; } include_once 'SemanticScuttle/db/' . $dbtype . '.php'; $db = new sql_db(); $db->sql_connect($dbhost, $dbuser, $dbpass, $dbname, $dbport, $dbpersist); if (!$db->db_connect_id) { message_die(CRITICAL_ERROR, 'Could not connect to the database', self::$db); } $dbneedssetnames && $db->sql_query('SET NAMES UTF8'); self::$db = $db; }
<?php /* Export data with semantic format (SIOC: http://sioc-project.org/, FOAF, SKOS, Annotea Ontology) */ $httpContentType = 'text/xml'; require_once '../www-header.php'; /* Service creation: only useful services are created */ $userservice = SemanticScuttle_Service_Factory::get('User'); $bookmarkservice = SemanticScuttle_Service_Factory::get('Bookmark'); echo "<?xml version=\"1.0\" encoding=\"utf-8\"\n?>"; ?> <rdf:RDF xmlns="http://xmlns.com/foaf/0.1/" xmlns:foaf="http://xmlns.com/foaf/0.1/" xmlns:rss="http://purl.org/rss/1.0/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:dcterms="http://purl.org/dc/terms/" xmlns:rdfs="http://www.w3.org/2000/01/rdf-schema#" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:sioc="http://rdfs.org/sioc/ns#" xmlns:sioc_t="http://rdfs.org/sioc/types#" xmlns:bm="http://www.w3.org/2002/01/bookmark#" xmlns:skos="http://www.w3.org/2004/02/skos/core#"> <?php //site and community are described using FOAF and SIOC ontology ?> <sioc:Site rdf:about="<?php echo ROOT; ?> " > <rdf:label><?php
function renameTag($userid, $old, $new, $fromApi = false) { $bookmarkservice = SemanticScuttle_Service_Factory::get('Bookmark'); $tagservice = SemanticScuttle_Service_Factory::get('Tag'); if (is_null($userid) || is_null($old) || is_null($new)) { return false; } // Find bookmarks with old tag $bookmarksInfo =& $bookmarkservice->getBookmarks(0, NULL, $userid, $old); $bookmarks =& $bookmarksInfo['bookmarks']; // Delete old tag $this->deleteTag($userid, $old); // Attach new tags $new = $tagservice->normalize($new); foreach (array_keys($bookmarks) as $key) { $row =& $bookmarks[$key]; $this->attachTags($row['bId'], $new, $fromApi, NULL, false); } return true; }
* * SemanticScuttle - your social bookmark manager. * * PHP version 5. * * @category Bookmarking * @package SemanticScuttle * @subcategory Templates * @author Benjamin Huynh-Kim-Bang <*****@*****.**> * @author Christian Weiske <*****@*****.**> * @author Eric Dane <*****@*****.**> * @license GPL http://www.gnu.org/licenses/gpl.html * @link http://sourceforge.net/projects/semanticscuttle */ /* Service creation: only useful services are created */ $searchhistoryservice = SemanticScuttle_Service_Factory::get('SearchHistory'); $lastSearches = $searchhistoryservice->getAllSearches('all', NULL, 3, NULL, true, false); if ($lastSearches && count($lastSearches) > 0) { ?> <h2><?php echo T_('Last Searches'); ?> </h2> <div id="searches"> <table> <?php foreach ($lastSearches as $row) { echo ' <tr><td>'; echo '<a href="' . htmlspecialchars(createURL('search', $range . '/' . $row['shTerms'])) . '">'; echo htmlspecialchars($row['shTerms']);
function deleteAll() { $query = 'TRUNCATE TABLE `' . $this->getTableName() . '`'; $this->db->sql_query($query); $tsts = SemanticScuttle_Service_Factory::get('TagStat'); $tsts->deleteAll(); }
if ($GLOBALS['enableVoting']) { if (isset($_SESSION['lastUrl'])) { $GLOBALS['lastUrl'] = $_SESSION['lastUrl']; } //this here is hacky, but currently the only way to // differentiate between css/js php files and normal // http files if (!isset($GLOBALS['saveInLastUrl']) || $GLOBALS['saveInLastUrl']) { $_SESSION['lastUrl'] = $_SERVER['REQUEST_URI']; } } } // 5 // Create mandatory services and objects $userservice = SemanticScuttle_Service_Factory::get('User'); $currentUser = $userservice->getCurrentObjectUser(); $templateservice = SemanticScuttle_Service_Factory::get('Template'); $tplVars = array(); $tplVars['currentUser'] = $currentUser; $tplVars['userservice'] = $userservice; // 6 // Force UTF-8 behaviour for server (cannot be moved into top.inc.php which is not included into every file) if (!defined('UNIT_TEST_MODE') || defined('HTTP_UNIT_TEST_MODE')) { //API files define that, so we need a way to support both of them if (!isset($httpContentType)) { if (DEBUG_MODE) { //using that mime type makes all javascript nice in Chromium // it also serves as test base if the pages really validate $httpContentType = 'application/xhtml+xml'; } else { //until we are sure that all pages validate, we // keep the non-strict mode on for normal installations $httpContentType = 'text/html';
function displayLinkedTags($tag, $linkType, $uId, $cat_url, $user, $editingMode = false, $precedentTag = null, $level = 0, $stopList = array()) { if (in_array($tag, $stopList)) { return array('output' => '', 'stoplist' => $stopList); } $tag2tagservice = SemanticScuttle_Service_Factory::get('Tag2Tag'); $tagstatservice = SemanticScuttle_Service_Factory::get('TagStat'); // link '>' if ($level > 1) { if ($editingMode) { $link = '<small><a href="' . createURL('tag2tagedit', $precedentTag . '/' . $tag) . '" title="' . _('Edit link') . '">></a> </small>'; } else { $link = '> '; } } else { $link = ''; } $output = ''; $output .= '<tr>'; $output .= '<td></td>'; $output .= '<td>'; $output .= $level == 1 ? '<b>' : ''; $output .= str_repeat(' ', $level * 2) . $link . '<a href="' . sprintf($cat_url, filter($user, 'url'), filter($tag, 'url')) . '" rel="tag">' . filter($tag) . '</a>'; $output .= $level == 1 ? '</b>' : ''; //$output.= ' - '. $tagstatservice->getMaxDepth($tag, $linkType, $uId); $synonymTags = $tag2tagservice->getAllLinkedTags($tag, '=', $uId); $synonymTags = is_array($synonymTags) ? $synonymTags : array($synonymTags); sort($synonymTags); $synonymList = ''; foreach ($synonymTags as $synonymTag) { //$output.= ", ".$synonymTag; $synonymList .= $synonymTag . ' '; } if (count($synonymTags) > 0) { $output .= ', ' . $synonymTags[0]; } if (count($synonymTags) > 1) { $output .= '<span title="' . T_('Synonyms:') . ' ' . $synonymList . '">, etc</span>'; } /*if($editingMode) { $output.= ' ('; $output.= '<a href="'.createURL('tag2tagadd', $tag).'" title="'._('Add a subtag').'">+</a>'; if(1) { $output.= ' - '; $output.= '<a href="'.createURL('tag2tagdelete', $tag).'">-</a>'; } $output.= ')'; }*/ $output .= '</td>'; $output .= '</tr>'; $tags = array($tag); $tags = array_merge($tags, $synonymTags); foreach ($tags as $tag) { if (!in_array($tag, $stopList)) { $linkedTags = $tag2tagservice->getLinkedTags($tag, '>', $uId); $precedentTag = $tag; $stopList[] = $tag; foreach ($linkedTags as $linkedTag) { $displayLinkedTags = displayLinkedTags($linkedTag, $linkType, $uId, $cat_url, $user, $editingMode, $precedentTag, $level + 1, $stopList); $output .= $displayLinkedTags['output']; } if (isset($displayLinkedTags) && is_array($displayLinkedTags['stopList'])) { $stopList = array_merge($stopList, $displayLinkedTags['stopList']); $stopList = array_unique($stopList); } } } return array('output' => $output, 'stopList' => $stopList); }
protected function setUp() { $this->us = SemanticScuttle_Service_Factory::get('User'); $this->us->deleteAll(); }
$tplVars['error'] = T_('This username already exists, please make another choice.'); // Check if username is valid (length, authorized characters) } elseif (!$userservice->isValidUsername($posteduser)) { $tplVars['error'] = T_('This username is not valid (too short, too long, forbidden characters...), please make another choice.'); // Check if e-mail address is valid } elseif (!$userservice->isValidEmail(POST_MAIL)) { $tplVars['error'] = T_('E-mail address is not valid. Please try again.'); // Check if antispam answer is valid (doesn't take into account spaces and uppercase) } elseif (strcasecmp(str_replace(' ', '', POST_ANTISPAMANSWER), str_replace(' ', '', $GLOBALS['antispamAnswer'])) != 0) { $tplVars['error'] = T_('Antispam answer is not valid. Please try again.'); // Register details } else { $uId = $userservice->addUser($posteduser, POST_PASS, POST_MAIL); if ($uId !== false) { if (isset($_SERVER['SSL_CLIENT_VERIFY']) && $_SERVER['SSL_CLIENT_VERIFY'] == 'SUCCESS') { $ssl = SemanticScuttle_Service_Factory::get('User_SslClientCert'); $ssl->registerCurrentCertificate($uId); $ssl->updateProfileFromCurentCert($uId); } // Log in with new username $login = $userservice->login($posteduser, POST_PASS); if ($login) { header('Location: ' . createURL('bookmarks', $posteduser)); } $tplVars['msg'] = T_('You have successfully registered. Enjoy!'); } else { $tplVars['error'] = T_('Registration failed. Please try again.'); } } } $tplVars['antispamQuestion'] = $GLOBALS['antispamQuestion'];
/** * Return current user id based on session or cookie * * @return mixed Integer user id or boolean false when user * could not be found or is not logged on. */ public function getCurrentUserId() { if ($this->currentuserId !== null) { return $this->currentuserId; } if (isset($_SESSION[$this->getSessionKey()])) { $this->currentuserId = (int) $_SESSION[$this->getSessionKey()]; return $this->currentuserId; } if (isset($_COOKIE[$this->getCookieKey()])) { $cook = explode(':', $_COOKIE[$this->getCookieKey()]); //cookie looks like this: 'id:md5(username+password)' $query = 'SELECT * FROM ' . $this->getTableName() . ' WHERE MD5(CONCAT(' . $this->getFieldName('username') . ', ' . $this->getFieldName('password') . ')) = \'' . $this->db->sql_escape($cook[1]) . '\' AND ' . $this->getFieldName('primary') . ' = ' . $this->db->sql_escape($cook[0]); if (!($dbresult = $this->db->sql_query($query))) { message_die(GENERAL_ERROR, 'Could not get user', '', __LINE__, __FILE__, $query, $this->db); return false; } if ($row = $this->db->sql_fetchrow($dbresult)) { $this->setCurrentUserId((int) $row[$this->getFieldName('primary')], true); $this->db->sql_freeresult($dbresult); return $this->currentuserId; } } $ssls = SemanticScuttle_Service_Factory::get('User_SslClientCert'); if ($ssls->hasValidCert()) { $id = $ssls->getUserIdFromCert(); if ($id !== false) { $this->setCurrentUserId($id, true); return $this->currentuserId; } } return false; }
public function testGetDb() { $this->assertInstanceOf('sql_db', SemanticScuttle_Service_Factory::getDb()); }
/** * Test what countOther() returns when the user is logged in * and friends (people on the watchlist) have bookmarked * and shared the same address. * * @return void */ public function testCountOthersWatchlistComplex() { $uid = $this->addUser(); $address = 'http://example.org'; //log user in $this->us->setCurrentUserId($uid); //setup users $otherPublic1 = $this->addUser(); $otherPublic2 = $this->addUser(); $otherShared1 = $this->addUser(); $otherPrivate1 = $this->addUser(); $friendPublic1 = $this->addUser(); $friendShared1 = $this->addUser(); $friendShared2 = $this->addUser(); $friendPrivate1 = $this->addUser(); $friendSharing1 = $this->addUser(); //setup watchlists $us = SemanticScuttle_Service_Factory::get('User'); $this->us->setCurrentUserId($friendPublic1); $us->setWatchStatus($uid); $this->us->setCurrentUserId($friendShared1); $us->setWatchStatus($uid); $this->us->setCurrentUserId($friendShared2); $us->setWatchStatus($uid); $this->us->setCurrentUserId($friendPrivate1); $us->setWatchStatus($uid); //back to login of main user $this->us->setCurrentUserId($uid); $us->setWatchStatus($friendSharing1); //add bookmarks $this->addBookmark($uid, $address, 0); $this->addBookmark($otherPublic1, $address, 0); $this->addBookmark($otherPublic2, $address, 0); $this->addBookmark($otherShared1, $address, 1); $this->addBookmark($otherPrivate1, $address, 2); $this->addBookmark($friendPublic1, $address, 0); $this->addBookmark($friendShared1, $address, 1); $this->addBookmark($friendShared2, $address, 1); $this->addBookmark($friendPrivate1, $address, 2); //this user is on our watchlist, but we not on his $this->addBookmark($friendSharing1, $address, 1); //2 public //1 public (friend) //2 shared //-> 5 $this->assertEquals(5, $this->bs->countOthers($address)); }
* Creates an jsTree json array for the given tag * * @param string $tag Tag name * @param boolean $hasChildren If the tag has subtags (children) or not. * If unsure, set it to "true". * @param boolean $isOpen If the tag has children: Is the tree node open * or closed? * @param boolean $autoParent If the tag is an automatically generated parent tag * * @return array Array to be sent back to the browser as json */ function createTagArray($tag, $hasChildren = true, $isOpen = false, $autoParent = false) { if ($autoParent) { $title = '(' . $tag . ')'; } else { $title = $tag; } $ar = array('data' => array('title' => $title, 'attr' => array('href' => createUrl('tags', $tag))), 'attr' => array('rel' => $tag)); if ($hasChildren) { //jstree needs that to show the arrows $ar['state'] = $isOpen ? 'open' : 'closed'; } if ($autoParent) { //FIXME: use css class $ar['data']['attr']['style'] = 'color: #AAA'; } return $ar; } $tagData = assembleLinkedTagData($tags, 0, $loadParentTags, SemanticScuttle_Service_Factory::get('Tag2Tag')); echo json_encode($tagData);
<?php /** * Bookmark thumbnail image * Shows the website thumbnail for the bookmark. * * Expects a $row variable with bookmark data. */ $thumbnailer = SemanticScuttle_Service_Factory::get('Thumbnails')->getThumbnailer(); $imgUrl = $thumbnailer->getThumbnailUrl($address, 120, 90); if ($imgUrl !== false) { echo '<a href="' . htmlspecialchars($address) . '">' . '<img class="thumbnail" width="120" height="90" src="' . htmlspecialchars($imgUrl) . '" />' . '</a>'; }
* SemanticScuttle - your social bookmark manager. * * PHP version 5. * * @category Bookmarking * @package SemanticScuttle * @author Benjamin Huynh-Kim-Bang <*****@*****.**> * @author Christian Weiske <*****@*****.**> * @author Eric Dane <*****@*****.**> * @license GPL http://www.gnu.org/licenses/gpl.html * @link http://sourceforge.net/projects/semanticscuttle */ require_once 'www-header.php'; /* Service creation: only useful services are created */ $b2tservice = SemanticScuttle_Service_Factory::get('Bookmark2Tag'); $cdservice = SemanticScuttle_Service_Factory::get('CommonDescription'); /* Managing all possible inputs */ isset($_POST['confirm']) ? define('POST_CONFIRM', $_POST['confirm']) : define('POST_CONFIRM', ''); isset($_POST['cancel']) ? define('POST_CANCEL', $_POST['cancel']) : define('POST_CANCEL', ''); isset($_POST['description']) ? define('POST_DESCRIPTION', $_POST['description']) : define('POST_DESCRIPTION', ''); isset($_POST['referrer']) ? define('POST_REFERRER', $_POST['referrer']) : define('POST_REFERRER', ''); /* Managing current logged user */ $currentUser = $userservice->getCurrentObjectUser(); /* Managing path info */ list($url, $tag) = explode('/', $_SERVER['PATH_INFO']); //permissions if (!$userservice->isLoggedOn() || !$GLOBALS['enableCommonTagDescriptionEditedByAll'] && !$currentUser->isAdmin()) { $tplVars['error'] = T_('Permission denied.'); $templateservice->loadTemplate('error.500.tpl', $tplVars); exit; }
protected function _getSynonymValues($tag1, $uId, $tagExcepted = NULL) { $tagservice = SemanticScuttle_Service_Factory::get('Tag'); $tag1 = $tagservice->normalize($tag1); $tagExcepted = $tagservice->normalize($tagExcepted); if ($tag1 == '') { return false; } $query = "SELECT DISTINCT tag2 as 'tag'"; $query .= " FROM `" . $this->getTableName() . "`"; $query .= " WHERE relationType = '='"; $query .= " AND tag1 = '" . $this->db->sql_escape($tag1) . "'"; $query .= " AND uId = " . intval($uId); $query .= $tagExcepted != '' ? " AND tag2!='" . $this->db->sql_escape($tagExcepted) . "'" : ''; if (!($dbresult = $this->db->sql_query($query))) { message_die(GENERAL_ERROR, 'Could not get related tags', '', __LINE__, __FILE__, $query, $this->db); return false; } $rowset = $this->db->sql_fetchrowset($dbresult); $output = array(); foreach ($rowset as $row) { $output[] = $row['tag']; } $this->db->sql_freeresult($dbresult); return $output; }
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA ***************************************************************************/ ///////////////// // WARNING! // Comment the two lines of code below to make work the script. // You have to put // at the beginning of lines to comment them. // BEFORE upgrading, don't forget to make a BACKUP of your database. // AFTER upgrading, don't forget to UN-COMMENT the lines back. ///////////////// echo "Please edit the 'upgrade.php' file into SemanticScuttle/ to start upgrading"; exit; ///////////////// // This part below will be executed once you comment the two lines above ///////////////// require_once 'www-header.php'; $tagstatservice = SemanticScuttle_Service_Factory::get('TagStat'); ?> <h1>Upgrade</h1> <h2>From Scuttle 0.7.2 to SemanticScuttle 0.87</h2> <ul> <li>1/ Make a <b>backup</b> of your database</li> <li>2/ Create the missing tables <ul> <li>Open "tables.sql" (into your SemanticScuttle directory) with a text editor</li> <li>Copy to your database the last three tables : sc_tags2tags, sc_tagsstats, sc_commondescription</li> </ul> </li> <li>3/ Complete the upgrade by clicking on the following link : <a href="upgrade.php?action=upgrade">upgrade</a></li> </ul> <?php
<?php /* Service creation: only useful services are created */ $b2tservice = SemanticScuttle_Service_Factory::get('Bookmark2Tag'); if (!isset($user)) { $user = ''; } if (!isset($userid)) { $userid = NULL; } $logged_on_userid = $userservice->getCurrentUserId(); if ($logged_on_userid === false) { $logged_on_userid = NULL; } $popularTags =& $b2tservice->getPopularTags($userid, $popCount, $logged_on_userid); $popularTags =& $b2tservice->tagCloud($popularTags, 5, 90, 225, 'alphabet_asc'); if ($popularTags && count($popularTags) > 0) { ?> <h2><?php echo T_('Popular Tags'); ?> </h2> <div id="popular"> <p class="tags"> <?php $contents = ''; if (strlen($user) == 0) { $cat_url = createURL('tags', '%2$s'); } foreach ($popularTags as $row) {
function updateAllStat() { $tts = SemanticScuttle_Service_Factory::get('Tag2Tag'); $query = "SELECT tag1, uId FROM `" . $tts->getTableName() . "`"; $query .= " WHERE relationType = '>'"; //die($query); if (!($dbresult = $this->db->sql_query($query))) { message_die(GENERAL_ERROR, 'Could not update stats', '', __LINE__, __FILE__, $query, $this->db); return false; } $rowset = $this->db->sql_fetchrowset($dbresult); foreach ($rowset as $row) { $this->updateStat($row['tag1'], '>', $row['uId']); } $this->db->sql_freeresult($dbresult); }
(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 General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA ***************************************************************************/ require_once 'www-header.php'; /* Service creation: only useful services are created */ $b2tservice = SemanticScuttle_Service_Factory::get('Bookmark2Tag'); $tagservice = SemanticScuttle_Service_Factory::get('Tag'); $tag2tagservice = SemanticScuttle_Service_Factory::get('Tag2Tag'); /* Managing all possible inputs */ isset($_POST['confirm']) ? define('POST_CONFIRM', $_POST['confirm']) : define('POST_CONFIRM', ''); isset($_POST['cancel']) ? define('POST_CANCEL', $_POST['cancel']) : define('POST_CANCEL', ''); isset($_POST['old']) ? define('POST_OLD', $_POST['old']) : define('POST_OLD', ''); isset($_POST['new']) ? define('POST_NEW', $_POST['new']) : define('POST_NEW', ''); /* Managing current logged user */ $currentUser = $userservice->getCurrentObjectUser(); /* Managing path info */ list($url, $tag) = explode('/', $_SERVER['PATH_INFO']); //$tag = isset($_GET['query']) ? $_GET['query'] : NULL; $template = 'tagrename.tpl'; if (POST_CONFIRM) { if (trim(POST_OLD) != '') { $old = trim(POST_OLD); } else {
* Ajax script to retrieve new Private Key * * PHP version 5. * * @category Bookmarking * @package SemanticScuttle * @author Christian Weiske <*****@*****.**> * @author Mark Pemberton <*****@*****.**> * @license AGPL http://www.gnu.org/licenses/agpl.html * @link http://sourceforge.net/projects/semanticscuttle */ header("Last-Modified: " . gmdate("D, d M Y H:i:s") . " GMT"); header("Cache-Control: no-cache, must-revalidate"); $httpContentType = 'text/xml'; require_once 'www-header.php'; $us = SemanticScuttle_Service_Factory::get('User'); /* Managing all possible inputs */ isset($_GET['url']) ? define('GET_URL', $_GET['url']) : define('GET_URL', ''); echo '<?xml version="1.0" encoding="utf-8"?>'; ?> <response> <method> getNewPrivateKey </method> <result> <?php echo $us->getNewPrivateKey(); ?> </result> </response>
the Free Software Foundation; either version 2 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 General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA ***************************************************************************/ require_once 'www-header.php'; /* Service creation: only useful services are created */ $b2tservice = SemanticScuttle_Service_Factory::get('Bookmark2Tag'); $cacheservice = SemanticScuttle_Service_Factory::get('Cache'); list($url, $user) = explode('/', isset($_SERVER['PATH_INFO']) ? $_SERVER['PATH_INFO'] : '/'); if (!$user) { header('Location: ' . createURL('populartags')); exit; } if ($usecache) { // Generate hash for caching on $hashtext = $_SERVER['REQUEST_URI']; if ($userservice->isLoggedOn()) { $hashtext .= $userservice->getCurrentUserID(); } $hash = md5($hashtext); // Cache for an hour $cacheservice->Start($hash, 3600); }
<?php /** * SemanticScuttle from approximately 0.94 up to 0.98.2, system:unfiled * tags were not created when adding new bookmarks with the web interface. * * This script adds system:unfiled tags for all bookmarks that have no * tags. */ require_once dirname(__FILE__) . '/../src/SemanticScuttle/header-standalone.php'; //needed to load the database object $bt = SemanticScuttle_Service_Factory::get('Bookmark2Tag'); $db = SemanticScuttle_Service_Factory::getDb(); $query = <<<SQL SELECT b.bId FROM sc_bookmarks AS b LEFT JOIN sc_bookmarks2tags AS bt ON b.bId = bt.bId WHERE bt.bId IS NULL SQL; if (!($dbresult = $db->sql_query($query))) { die('Strange SQL error'); } while ($row = $db->sql_fetchrow($dbresult)) { $db->sql_query('INSERT INTO ' . $bt->getTableName() . ' ' . $db->sql_build_array('INSERT', array('bId' => $row['bId'], 'tag' => 'system:unfiled'))); } $db->sql_freeresult($dbresult);