Bug fixes: correct minor bugs appearing with 'notice' level in PHP

git-svn-id: https://semanticscuttle.svn.sourceforge.net/svnroot/semanticscuttle/trunk@122 b3834d28-1941-0410-a4f8-b48e95affb8f
This commit is contained in:
mensonge 2008-05-10 08:59:41 +00:00
parent e273c0d367
commit 2756e3f858
21 changed files with 73 additions and 30 deletions

View file

@ -13,7 +13,6 @@ function authenticate() {
} }
if(!$userservice->isLoggedOn()) { if(!$userservice->isLoggedOn()) {
/* Maybe we have caught authentication data in $_SERVER['REMOTE_USER'] /* Maybe we have caught authentication data in $_SERVER['REMOTE_USER']
( Inspired by http://www.yetanothercommunitysystem.com/article-321-regle-comment-utiliser-l-authentification-http-en-php-chez-ovh ) */ ( Inspired by http://www.yetanothercommunitysystem.com/article-321-regle-comment-utiliser-l-authentification-http-en-php-chez-ovh ) */
if((!isset($_SERVER['PHP_AUTH_USER']) || !isset($_SERVER['PHP_AUTH_PW'])) if((!isset($_SERVER['PHP_AUTH_USER']) || !isset($_SERVER['PHP_AUTH_PW']))

View file

@ -209,12 +209,12 @@ if ($templatename == 'editbookmark.tpl') {
$tplVars['start'] = $start; $tplVars['start'] = $start;
$tplVars['bookmarkCount'] = $start + 1; $tplVars['bookmarkCount'] = $start + 1;
$bookmarks =& $bookmarkservice->getBookmarks($start, $perpage, $userid, $cat, $terms, getSortOrder()); $bookmarks =& $bookmarkservice->getBookmarks($start, $perpage, $userid, $cat, null, getSortOrder());
$tplVars['total'] = $bookmarks['total']; $tplVars['total'] = $bookmarks['total'];
$tplVars['bookmarks'] =& $bookmarks['bookmarks']; $tplVars['bookmarks'] =& $bookmarks['bookmarks'];
$tplVars['cat_url'] = createURL('bookmarks', '%s/%s'); $tplVars['cat_url'] = createURL('bookmarks', '%s/%s');
$tplVars['nav_url'] = createURL('bookmarks', '%s/%s%s'); $tplVars['nav_url'] = createURL('bookmarks', '%s/%s%s');
if ($user == $currentUsername) { if ($userservice->isLoggedOn() && $user == $currentUsername) {
$title = T_('My Bookmarks') . filter($catTitle); $title = T_('My Bookmarks') . filter($catTitle);
} else { } else {
$title = filter($pagetitle); $title = filter($pagetitle);

View file

@ -3,6 +3,7 @@ ini_set('display_errors', '1');
ini_set('mysql.trace_mode', '0'); ini_set('mysql.trace_mode', '0');
error_reporting(E_ALL ^ E_NOTICE); error_reporting(E_ALL ^ E_NOTICE);
//error_reporting(E_ALL);
define('DEBUG', true); define('DEBUG', true);
session_start(); session_start();
@ -30,4 +31,5 @@ if (!isset($root)) {
} }
$root = 'http://'. $_SERVER['HTTP_HOST'] . $root; $root = 'http://'. $_SERVER['HTTP_HOST'] . $root;
} }
?> ?>

View file

@ -108,6 +108,7 @@ class FileReader {
// PHP 5.1.1 does not read more than 8192 bytes in one fread() // PHP 5.1.1 does not read more than 8192 bytes in one fread()
// the discussions at PHP Bugs suggest it's the intended behaviour // the discussions at PHP Bugs suggest it's the intended behaviour
$data = '';
while ($bytes > 0) { while ($bytes > 0) {
$chunk = fread($this->_fd, $bytes); $chunk = fread($this->_fd, $bytes);
$data .= $chunk; $data .= $chunk;

View file

@ -25,10 +25,12 @@ $templateservice =& ServiceFactory::getServiceInstance('TemplateService');
$tplVars = array(); $tplVars = array();
$keeppass = isset($_POST['keeppass'])&&($_POST['keeppass']=='yes')?true:false;
$login = false; $login = false;
if (isset($_POST['submitted']) && isset($_POST['username']) && isset($_POST['password'])) { if (isset($_POST['submitted']) && isset($_POST['username']) && isset($_POST['password'])) {
$posteduser = trim(utf8_strtolower($_POST['username'])); $posteduser = trim(utf8_strtolower($_POST['username']));
$login = $userservice->login($posteduser, $_POST['password'], ($_POST['keeppass'] == "yes")); $login = $userservice->login($posteduser, $_POST['password'], $keeppass);
if ($login) { if ($login) {
if ($_POST['query']) if ($_POST['query'])
header('Location: '. createURL('bookmarks', $posteduser .'?'. $_POST['query'])); header('Location: '. createURL('bookmarks', $posteduser .'?'. $_POST['query']));

View file

@ -24,7 +24,7 @@ $templateservice =& ServiceFactory::getServiceInstance('TemplateService');
$tplVars = array(); $tplVars = array();
// IF SUBMITTED // IF SUBMITTED
if ($_POST['submitted']) { if (isset($_POST['submitted'])) {
// NO USERNAME // NO USERNAME
if (!$_POST['username']) { if (!$_POST['username']) {

View file

@ -66,7 +66,7 @@ if (isset($user) && $user != '') {
$userid = NULL; $userid = NULL;
} }
$tags = $b2tservice->getPopularTags($userid, 150, $logged_on_userid); $tags = $b2tservice->getPopularTags($userid, 150);
$tplVars['tags'] =& $b2tservice->tagCloud($tags, 5, 90, 225, getSortOrder('alphabet_asc')); $tplVars['tags'] =& $b2tservice->tagCloud($tags, 5, 90, 225, getSortOrder('alphabet_asc'));
$tplVars['user'] = $user; $tplVars['user'] = $user;

View file

@ -25,7 +25,7 @@ $templateservice =& ServiceFactory::getServiceInstance('TemplateService');
$tplVars = array(); $tplVars = array();
if ($_POST['submitted']) { if (isset($_POST['submitted'])) {
$posteduser = trim(utf8_strtolower($_POST['username'])); $posteduser = trim(utf8_strtolower($_POST['username']));
// Check if form is incomplete // Check if form is incomplete

View file

@ -1,3 +1,10 @@
<?php
/* Manage input */
$select_watchlist = isset($select_watchlist)?$select_watchlist:'';
$select_all = isset($select_all)?$select_all:'';
?>
<form id="search" action="<?php echo createURL('search'); ?>" method="post"> <form id="search" action="<?php echo createURL('search'); ?>" method="post">
<table> <table>
<tr> <tr>
@ -16,12 +23,12 @@
<?php <?php
if (!in_array($range, array($currentUsername, 'all', 'watchlist'))) { if (!in_array($range, array($currentUsername, 'all', 'watchlist'))) {
?> ?>
<option value="<?php echo $user ?>"<?php echo $selectUser; ?>><?php echo T_("this user's bookmarks"); ?></option> <option value="<?php echo $user ?>"<?php //echo $selectUser; ?>><?php echo T_("this user's bookmarks"); ?></option>
<?php <?php
} }
if ($logged_on) { if ($logged_on) {
?> ?>
<option value="<?php echo $currentUsername; ?>"<?php echo $selectMy; ?>><?php echo T_('my bookmarks'); ?></option> <option value="<?php echo $currentUsername; ?>"<?php //echo $selectMy; ?>><?php echo T_('my bookmarks'); ?></option>
<option value="watchlist"<?php echo $select_watchlist; ?>><?php echo T_('my watchlist'); ?></option> <option value="watchlist"<?php echo $select_watchlist; ?>><?php echo T_('my watchlist'); ?></option>
<?php <?php
} }
@ -37,7 +44,7 @@
<?php <?php
} }
?> ?>
<td><input type="text" name="terms" size="30" value="<?php echo filter($terms); ?>" /></td> <td><input type="text" name="terms" size="30" value="<?php $terms=!isset($terms)?'':$terms; echo filter($terms); ?>" /></td>
<td><input type="submit" value="<?php echo T_('Search' /* Submit button */); ?>" /></td> <td><input type="submit" value="<?php echo T_('Search' /* Submit button */); ?>" /></td>
</tr> </tr>
</table> </table>

View file

@ -266,7 +266,8 @@ class Bookmark2TagService {
message_die(GENERAL_ERROR, 'Could not get related tags', '', __LINE__, __FILE__, $query, $this->db); message_die(GENERAL_ERROR, 'Could not get related tags', '', __LINE__, __FILE__, $query, $this->db);
return false; return false;
} }
return $this->db->sql_fetchrowset($dbresult); $output = $this->db->sql_fetchrowset($dbresult);
return $output;
} }
// Returns the most popular tags used for a particular bookmark hash // Returns the most popular tags used for a particular bookmark hash
@ -322,7 +323,8 @@ class Bookmark2TagService {
return false; return false;
} }
return $this->db->sql_fetchrowset($dbresult); $output = $this->db->sql_fetchrowset($dbresult);
return $output;
} }
function hasTag($bookmarkid, $tag) { function hasTag($bookmarkid, $tag) {
@ -366,7 +368,8 @@ class Bookmark2TagService {
function &tagCloud($tags = NULL, $steps = 5, $sizemin = 90, $sizemax = 225, $sortOrder = NULL) { function &tagCloud($tags = NULL, $steps = 5, $sizemin = 90, $sizemax = 225, $sortOrder = NULL) {
if (is_null($tags) || count($tags) < 1) { if (is_null($tags) || count($tags) < 1) {
return false; $output = false;
return $output;
} }
$min = $tags[count($tags) - 1]['bCount']; $min = $tags[count($tags) - 1]['bCount'];

View file

@ -280,6 +280,7 @@ class BookmarkService {
$query_3 .= ' AND ('. $query_3_1 .') AND B.bStatus IN (0, 1)'; $query_3 .= ' AND ('. $query_3_1 .') AND B.bStatus IN (0, 1)';
} }
$query_5 = '';
if($hash == null) { if($hash == null) {
$query_5.= ' GROUP BY B.bHash'; $query_5.= ' GROUP BY B.bHash';
} }
@ -389,7 +390,9 @@ class BookmarkService {
$row['tags'] = $b2tservice->getTagsForBookmark(intval($row['bId'])); $row['tags'] = $b2tservice->getTagsForBookmark(intval($row['bId']));
$bookmarks[] = $row; $bookmarks[] = $row;
} }
return array ('bookmarks' => $bookmarks, 'total' => $total);
$output = array ('bookmarks' => $bookmarks, 'total' => $total);
return $output;
} }
function deleteBookmark($bookmarkid) { function deleteBookmark($bookmarkid) {

View file

@ -62,7 +62,7 @@ class Tag2TagService {
$query.= " AND uId = '".$uId."'"; $query.= " AND uId = '".$uId."'";
} }
//die($query); //die($query);
if (! ($dbresult =& $this->db->sql_query_limit($query, $limit)) ){ if (! ($dbresult =& $this->db->sql_query($query)) ){
message_die(GENERAL_ERROR, 'Could not get related tags', '', __LINE__, __FILE__, $query, $this->db); message_die(GENERAL_ERROR, 'Could not get related tags', '', __LINE__, __FILE__, $query, $this->db);
return false; return false;
} }

View file

@ -127,7 +127,7 @@ class UserService {
if ($id = $this->getCurrentUserId()) if ($id = $this->getCurrentUserId())
$currentuser = $this->getUser($id); $currentuser = $this->getUser($id);
else else
return; return null;
} }
return $currentuser; return $currentuser;
} }

View file

@ -24,10 +24,12 @@ $tag2tagservice = & ServiceFactory :: getServiceInstance('Tag2TagService');
$templateservice = & ServiceFactory :: getServiceInstance('TemplateService'); $templateservice = & ServiceFactory :: getServiceInstance('TemplateService');
$userservice = & ServiceFactory :: getServiceInstance('UserService'); $userservice = & ServiceFactory :: getServiceInstance('UserService');
$logged_on_user = $userservice->getCurrentUser(); $logged_on_user = $userservice->getCurrentUser();
//permissions //permissions
if($logged_on_user == null) { if($logged_on_user == null) {
$tplVars['error'] = T_('Permission denied.'); $tplVars['error'] = T_('Permission denied.');
$templateservice->loadTemplate('error.500.tpl', $tplVars); $templateservice->loadTemplate('error.500.tpl', $tplVars);
exit(); exit();

View file

@ -43,17 +43,22 @@ if($logged_on_userid>0) {
<?php <?php
$userObject = $userservice->getUserByUsername($user);
/* Private tag description */ /* Private tag description */
if(isset($currenttag) && strlen($user)>0 && $tagservice->getDescription($currenttag, $userObject['uId'])):?> if(isset($currenttag) && isset($user)) {
$userObject = $userservice->getUserByUsername($user);
if($tagservice->getDescription($currenttag, $userObject['uId'])) { ?>
<p class="commondescription"> <p class="commondescription">
<?php <?php
$description = $tagservice->getDescription($currenttag, $userObject['uId']); $description = $tagservice->getDescription($currenttag, $userObject['uId']);
echo nl2br(filter($description['tDescription'])); echo nl2br(filter($description['tDescription']));
?> ?>
</p> </p>
<?php endif ?>
<?php
}
}
?>
<?php if (count($bookmarks) > 0) { ?> <?php if (count($bookmarks) > 0) { ?>
<script type="text/javascript"> <script type="text/javascript">

View file

@ -4,13 +4,20 @@ $userservice =& ServiceFactory::getServiceInstance('UserService');
require_once('sidebar.linkedtags.inc.php'); require_once('sidebar.linkedtags.inc.php');
/* Manage input */
$user = isset($user)?$user:'';
$userid = isset($userid)?$userid:0;
$currenttag = isset($currenttag)?$currenttag:'';
$summarizeLinkedTags = isset($summarizeLinkedTags)?$summarizeLinkedTags:false;
$logged_on_userid = $userservice->getCurrentUserId(); $logged_on_userid = $userservice->getCurrentUserId();
if ($logged_on_userid === false) { if ($logged_on_userid === false) {
$logged_on_userid = NULL; $logged_on_userid = NULL;
} }
$explodedTags = array(); $explodedTags = array();
if ($currenttag) { if (strlen($currenttag)>0) {
$explodedTags = explode('+', $currenttag); $explodedTags = explode('+', $currenttag);
} else { } else {
if($summarizeLinkedTags == true) { if($summarizeLinkedTags == true) {

View file

@ -4,6 +4,11 @@ $userservice =& ServiceFactory::getServiceInstance('UserService');
require_once('sidebar.linkedtags.inc.php'); require_once('sidebar.linkedtags.inc.php');
/* Manage input */
$userid = isset($userid)?$userid:0;
$user = isset($user)?$user:null;
$logged_on_userid = $userservice->getCurrentUserId(); $logged_on_userid = $userservice->getCurrentUserId();
if ($logged_on_userid === false) { if ($logged_on_userid === false) {
$logged_on_userid = NULL; $logged_on_userid = NULL;
@ -16,7 +21,7 @@ if(($logged_on_userid != null) && ($userid === $logged_on_userid)) {
$editingMode = false; $editingMode = false;
} }
if(strlen($user)==0) { if(!isset($user)) {
$cat_url = createURL('tags', '%2$s'); $cat_url = createURL('tags', '%2$s');
} }

View file

@ -2,6 +2,9 @@
$b2tservice =& ServiceFactory::getServiceInstance('Bookmark2TagService'); $b2tservice =& ServiceFactory::getServiceInstance('Bookmark2TagService');
$userservice =& ServiceFactory::getServiceInstance('UserService'); $userservice =& ServiceFactory::getServiceInstance('UserService');
/* Manage input */
$userid = isset($userid)?$userid:0;
$logged_on_userid = $userservice->getCurrentUserId(); $logged_on_userid = $userservice->getCurrentUserId();
if ($logged_on_userid === false) { if ($logged_on_userid === false) {
$logged_on_userid = NULL; $logged_on_userid = NULL;

View file

@ -19,6 +19,8 @@ function displayLinkedTags($tag, $linkType, $uId, $cat_url, $user, $editingMode
} else { } else {
$link = '> '; $link = '> ';
} }
} else {
$link = '';
} }
$output = ''; $output = '';
@ -69,7 +71,7 @@ function displayLinkedTags($tag, $linkType, $uId, $cat_url, $user, $editingMode
$displayLinkedTags = displayLinkedTags($linkedTag, $linkType, $uId, $cat_url, $user, $editingMode, $precedentTag, $level + 1, $stopList); $displayLinkedTags = displayLinkedTags($linkedTag, $linkType, $uId, $cat_url, $user, $editingMode, $precedentTag, $level + 1, $stopList);
$output.= $displayLinkedTags['output']; $output.= $displayLinkedTags['output'];
} }
if(is_array($displayLinkedTags['stopList'])) { if(isset($displayLinkedTags) && is_array($displayLinkedTags['stopList'])) {
$stopList = array_merge($stopList, $displayLinkedTags['stopList']); $stopList = array_merge($stopList, $displayLinkedTags['stopList']);
$stopList = array_unique($stopList); $stopList = array_unique($stopList);
} }

View file

@ -21,7 +21,7 @@ if ($userservice->isLoggedOn()) {
?> ?>
<ul id="navigation"> <ul id="navigation">
<li><a href="<?php echo createURL('populartags', $cUsername); ?>"><?php echo T_('Popular Tags'); ?></a></li> <li><a href="<?php echo createURL('populartags'); ?>"><?php echo T_('Popular Tags'); ?></a></li>
<li><a href="<?php echo createURL('about'); ?>"><?php echo T_('About'); ?></a></li> <li><a href="<?php echo createURL('about'); ?>"><?php echo T_('About'); ?></a></li>
<li class="access"><a href="<?php echo createURL('login'); ?>"><?php echo T_('Log In'); ?></a></li> <li class="access"><a href="<?php echo createURL('login'); ?>"><?php echo T_('Log In'); ?></a></li>
<li class="access"><a href="<?php echo createURL('register'); ?>"><?php echo T_('Register'); ?></a></li> <li class="access"><a href="<?php echo createURL('register'); ?>"><?php echo T_('Register'); ?></a></li>

View file

@ -7,11 +7,13 @@
<link rel="icon" type="image/png" href="<?php echo $GLOBALS['root']; ?>icon.png" /> <link rel="icon" type="image/png" href="<?php echo $GLOBALS['root']; ?>icon.png" />
<link rel="stylesheet" type="text/css" href="<?php echo $GLOBALS['root']; ?>scuttle.css" /> <link rel="stylesheet" type="text/css" href="<?php echo $GLOBALS['root']; ?>scuttle.css" />
<?php <?php
$size = count($rsschannels); if(isset($rsschannels)) {
for ($i = 0; $i < $size; $i++) { $size = count($rsschannels);
echo '<link rel="alternate" type="application/rss+xml" title="'. $rsschannels[$i][0] .'" href="'. $rsschannels[$i][1] .'" />'; for ($i = 0; $i < $size; $i++) {
echo '<link rel="alternate" type="application/rss+xml" title="'. $rsschannels[$i][0] .'" href="'. $rsschannels[$i][1] .'" />';
}
} }
if ($loadjs) { if (isset($loadjs)) {
echo '<script type="text/javascript" src="'. $GLOBALS['root'] .'jsScuttle.php"></script>'; echo '<script type="text/javascript" src="'. $GLOBALS['root'] .'jsScuttle.php"></script>';
} }
?> ?>