More code cleanup
This commit is contained in:
parent
456af09a04
commit
000cfd76cc
@ -4,7 +4,7 @@ $this->includeTemplate($GLOBALS['top_include']);
|
||||
|
||||
<ul>
|
||||
<li><?php echo T_('<strong>Store</strong> all your favourite links in one place, accessible from anywhere.'); ?></li>
|
||||
<li><?php echo T_('<strong>Share</strong> your bookmarks with everyone, with friends on your watchlist or just keep them private.') ;?></li>
|
||||
<li><?php echo T_('<strong>Share</strong> your bookmarks with everyone, with friends on your watchlist or just keep them private.'); ?></li>
|
||||
<li><?php echo T_('<strong>Tag</strong> your bookmarks with as many labels as you want, instead of wrestling with folders.'); ?></li>
|
||||
<li><?php echo sprintf('<strong><a href="'.createURL('register').'">'.T_('Register now').'</a> </strong>'.T_(' to start using %s!'), $GLOBALS['sitename']); ?></li>
|
||||
</ul>
|
||||
@ -16,9 +16,11 @@ $this->includeTemplate($GLOBALS['top_include']);
|
||||
|
||||
|
||||
|
||||
<?php if(!is_null($currentUser) && $currentUser->isAdmin()): ?>
|
||||
<li>SemanticScuttle v0.97.0</li>
|
||||
<?php endif ?>
|
||||
<?php
|
||||
if (!is_null($currentUser) && $currentUser->isAdmin()) {
|
||||
echo "<li>SemanticScuttle v0.97.0</li>";
|
||||
}
|
||||
?>
|
||||
</ul>
|
||||
|
||||
<h3><?php echo T_('Tips'); ?></h3>
|
||||
|
@ -1,35 +1,35 @@
|
||||
<?php
|
||||
|
||||
<?php
|
||||
|
||||
$this->includeTemplate($GLOBALS['top_include']);
|
||||
|
||||
echo '<h3>'.T_('Users management').'</h3>';
|
||||
|
||||
echo '<ol id="bookmarks">';
|
||||
|
||||
foreach($users as $user) {
|
||||
echo '<li class="xfolkentry">'."\n";
|
||||
|
||||
echo '<div class="link">';
|
||||
echo '<a href="'.createURL('profile', $user->getUsername()).'">'.$user->getUsername().'</a>';
|
||||
echo ' - <span title='. T_('Public/Shared/Private') .'>'. $user->getNbBookmarks('public') .' / '. $user->getNbBookmarks('shared') .' / '. $user->getNbBookmarks('private') .' '. T_('bookmark(s)') .'</span>';
|
||||
echo '</div>';
|
||||
echo '<ol id="bookmarks">';
|
||||
|
||||
if($user->getUsername() != $currentUser->getUsername()) {
|
||||
echo '<div class="meta">';
|
||||
echo '<a href="'.createURL('admin','delete/'.$user->getUsername()).'" onclick="return confirm(\''.T_('Are you sure?').'\');">'.T_('Delete').'</a>';
|
||||
echo '</div>';
|
||||
}
|
||||
|
||||
echo '</li>'."\n";
|
||||
foreach ($users as $user) {
|
||||
echo '<li class="xfolkentry">'."\n";
|
||||
|
||||
echo '<div class="link">';
|
||||
echo '<a href="'.createURL('profile', $user->getUsername()).'">'.$user->getUsername().'</a>';
|
||||
echo ' - <span title='. T_('Public/Shared/Private') .'>'. $user->getNbBookmarks('public') .' / '. $user->getNbBookmarks('shared') .' / '. $user->getNbBookmarks('private') .' '. T_('bookmark(s)') .'</span>';
|
||||
echo '</div>';
|
||||
|
||||
if ($user->getUsername() != $currentUser->getUsername()) {
|
||||
echo '<div class="meta">';
|
||||
echo '<a href="'.createURL('admin', 'delete/'.$user->getUsername()).'" onclick="return confirm(\''.T_('Are you sure?').'\');">'.T_('Delete').'</a>';
|
||||
echo '</div>';
|
||||
}
|
||||
|
||||
echo '</li>'."\n";
|
||||
}
|
||||
echo '</ol>';
|
||||
?>
|
||||
<h3><?php echo T_('Other actions')?></h3>
|
||||
<p>
|
||||
<a href="<?php echo createURL('admin','checkUrl/') ?>"> <?php echo T_('Check all URLs (May take some time)') ?></a>
|
||||
<a href="<?php echo createURL('admin', 'checkUrl/'); ?>"> <?php echo T_('Check all URLs (May take some time)'); ?></a>
|
||||
</p>
|
||||
<?php
|
||||
$this->includeTemplate('sidebar.tpl');
|
||||
$this->includeTemplate($GLOBALS['bottom_include']);
|
||||
|
||||
?>
|
||||
<?php
|
||||
$this->includeTemplate('sidebar.tpl');
|
||||
$this->includeTemplate($GLOBALS['bottom_include']);
|
||||
|
||||
?>
|
||||
|
@ -26,13 +26,13 @@ window.onload = function() {
|
||||
<tr>
|
||||
<td></td>
|
||||
<td>
|
||||
<?php
|
||||
if(strlen($description['cdDatetime'])>0) {
|
||||
echo T_('Last modification:').' '.$description['cdDatetime'].', ';
|
||||
$lastUser = $userservice->getUser($description['uId']);
|
||||
echo '<a href="'.createURL('profile', $lastUser['username']).'">'.$lastUser['username'].'</a>';
|
||||
}
|
||||
?>
|
||||
<?php
|
||||
if (strlen($description['cdDatetime'])>0) {
|
||||
echo T_('Last modification:').' '.$description['cdDatetime'].', ';
|
||||
$lastUser = $userservice->getUser($description['uId']);
|
||||
echo '<a href="'.createURL('profile', $lastUser['username']).'">'.$lastUser['username'].'</a>';
|
||||
}
|
||||
?>
|
||||
</td>
|
||||
<td></td>
|
||||
</tr>
|
||||
|
@ -32,12 +32,12 @@ $this->includeTemplate($GLOBALS['top_include']);
|
||||
include('search.menu.php');
|
||||
?>
|
||||
|
||||
<?php if($pageName == PAGE_INDEX && $GLOBALS['welcomeMessage']):?>
|
||||
<?php if ($pageName == PAGE_INDEX && $GLOBALS['welcomeMessage']):?>
|
||||
<p id="welcome"><?php echo $GLOBALS['welcomeMessage'];?></p>
|
||||
<?php endif?>
|
||||
|
||||
|
||||
<?php if($GLOBALS['enableAdminColors']!=false && isset($userid) && $userservice->isAdmin($userid) && $pageName != PAGE_WATCHLIST) : ?>
|
||||
<?php if ($GLOBALS['enableAdminColors']!=false && isset($userid) && $userservice->isAdmin($userid) && $pageName != PAGE_WATCHLIST) : ?>
|
||||
<div style="width:70%;text-align:center;">
|
||||
<img src="<?php echo ROOT ?>images/logo_24.gif" width="12px"/> <?php echo T_('Bookmarks on this page are managed by an admin user.'); ?><img src="<?php echo ROOT ?>images/logo_24.gif" width="12px"/>
|
||||
</div>
|
||||
@ -46,31 +46,31 @@ include('search.menu.php');
|
||||
|
||||
<?php
|
||||
// common tag description
|
||||
if(($currenttag!= '' && $GLOBALS['enableCommonTagDescription'])
|
||||
if (($currenttag!= '' && $GLOBALS['enableCommonTagDescription'])
|
||||
|| (isset($hash) && $GLOBALS['enableCommonBookmarkDescription'])):?>
|
||||
|
||||
|
||||
<p class="commondescription"><?php
|
||||
$cDescription = '';
|
||||
if($currenttag!= '' && $cdservice->getLastTagDescription($currenttag)) {
|
||||
$cDescription = $cdservice->getLastTagDescription($currenttag);
|
||||
echo nl2br(filter($cDescription['cdDescription']));
|
||||
} elseif(isset($hash) && $cdservice->getLastBookmarkDescription($hash)) {
|
||||
$cDescription = $cdservice->getLastBookmarkDescription($hash);
|
||||
echo nl2br(filter($cDescription['cdTitle'])). "<br/>";
|
||||
echo nl2br(filter($cDescription['cdDescription'])). "<br/>";
|
||||
if ($currenttag!= '' && $cdservice->getLastTagDescription($currenttag)) {
|
||||
$cDescription = $cdservice->getLastTagDescription($currenttag);
|
||||
echo nl2br(filter($cDescription['cdDescription']));
|
||||
} elseif (isset($hash) && $cdservice->getLastBookmarkDescription($hash)) {
|
||||
$cDescription = $cdservice->getLastBookmarkDescription($hash);
|
||||
echo nl2br(filter($cDescription['cdTitle'])). "<br/>";
|
||||
echo nl2br(filter($cDescription['cdDescription'])). "<br/>";
|
||||
}
|
||||
|
||||
//common tag description edit
|
||||
if($userservice->isLoggedOn()) {
|
||||
if($currenttag!= '' && ($GLOBALS['enableCommonTagDescriptionEditedByAll'] || $currentUser->isAdmin())) {
|
||||
echo ' <a href="'. createURL('tagcommondescriptionedit', $currenttag).'" title="'.T_('Edit the common description of this tag').'">';
|
||||
echo !is_array($cDescription) || strlen($cDescription['cdDescription'])==0?T_('Edit the common description of this tag'):'';
|
||||
echo ' <img src="'.ROOT.'images/b_edit.png" /></a>';
|
||||
} elseif(isset($hash)) {
|
||||
echo ' (<a href="'.createURL('bookmarkcommondescriptionedit', $hash).'" title="'.T_('Edit the common description of this bookmark').'">';
|
||||
echo T_('Edit the common description of this bookmark').'</a>)';
|
||||
}
|
||||
if ($userservice->isLoggedOn()) {
|
||||
if ($currenttag!= '' && ($GLOBALS['enableCommonTagDescriptionEditedByAll'] || $currentUser->isAdmin())) {
|
||||
echo ' <a href="'. createURL('tagcommondescriptionedit', $currenttag).'" title="'.T_('Edit the common description of this tag').'">';
|
||||
echo !is_array($cDescription) || strlen($cDescription['cdDescription'])==0?T_('Edit the common description of this tag'):'';
|
||||
echo ' <img src="'.ROOT.'images/b_edit.png" /></a>';
|
||||
} elseif (isset($hash)) {
|
||||
echo ' (<a href="'.createURL('bookmarkcommondescriptionedit', $hash).'" title="'.T_('Edit the common description of this bookmark').'">';
|
||||
echo T_('Edit the common description of this bookmark').'</a>)';
|
||||
}
|
||||
}
|
||||
?></p>
|
||||
<?php endif ?>
|
||||
@ -78,26 +78,26 @@ if($userservice->isLoggedOn()) {
|
||||
|
||||
<?php
|
||||
/* personal tag description */
|
||||
if($currenttag!= '' && $user!='') {
|
||||
$userObject = $userservice->getUserByUsername($user);
|
||||
if($tagservice->getDescription($currenttag, $userObject['uId'])) { ?>
|
||||
if ($currenttag!= '' && $user!='') {
|
||||
$userObject = $userservice->getUserByUsername($user);
|
||||
if ($tagservice->getDescription($currenttag, $userObject['uId'])) { ?>
|
||||
|
||||
<p class="commondescription"><?php
|
||||
$pDescription = $tagservice->getDescription($currenttag, $userObject['uId']);
|
||||
echo nl2br(filter($pDescription['tDescription']));
|
||||
|
||||
//personal tag description edit
|
||||
if($userservice->isLoggedOn()) {
|
||||
if($currenttag!= '') {
|
||||
echo ' <a href="'. createURL('tagedit', $currenttag).'" title="'.T_('Edit your personal description of this tag').'" >';
|
||||
echo strlen($pDescription['tDescription'])==0?T_('Edit your personal description of this tag'):'';
|
||||
echo ' <img src="'.ROOT.'images/b_edit.png" /></a>';
|
||||
}
|
||||
if ($userservice->isLoggedOn()) {
|
||||
if ($currenttag!= '') {
|
||||
echo ' <a href="'. createURL('tagedit', $currenttag).'" title="'.T_('Edit your personal description of this tag').'" >';
|
||||
echo strlen($pDescription['tDescription'])==0?T_('Edit your personal description of this tag'):'';
|
||||
echo ' <img src="'.ROOT.'images/b_edit.png" /></a>';
|
||||
}
|
||||
}
|
||||
?></p>
|
||||
|
||||
<?php
|
||||
}
|
||||
}
|
||||
}
|
||||
?>
|
||||
|
||||
@ -115,37 +115,37 @@ $dateSort = 'date_desc';
|
||||
$titleSort = 'title_asc';
|
||||
$votingSort = 'voting_desc';
|
||||
|
||||
switch(getSortOrder()) {
|
||||
switch (getSortOrder()) {
|
||||
case 'date_asc':
|
||||
$dateArrow = ' ↑';
|
||||
$dateSort = 'date_desc';
|
||||
break;
|
||||
$dateArrow = ' ↑';
|
||||
$dateSort = 'date_desc';
|
||||
break;
|
||||
|
||||
case 'title_asc':
|
||||
$titleArrow = ' ↑';
|
||||
$titleSort = 'title_desc';
|
||||
break;
|
||||
$titleArrow = ' ↑';
|
||||
$titleSort = 'title_desc';
|
||||
break;
|
||||
|
||||
case 'title_desc':
|
||||
$titleArrow = ' ↓';
|
||||
$titleSort = 'title_asc';
|
||||
break;
|
||||
$titleArrow = ' ↓';
|
||||
$titleSort = 'title_asc';
|
||||
break;
|
||||
|
||||
case 'voting_asc':
|
||||
$votingArrow = ' ↑';
|
||||
$votingSort = 'voting_desc';
|
||||
break;
|
||||
$votingArrow = ' ↑';
|
||||
$votingSort = 'voting_desc';
|
||||
break;
|
||||
|
||||
case 'voting_desc':
|
||||
$votingArrow = ' ↓';
|
||||
$votingSort = 'voting_asc';
|
||||
break;
|
||||
$votingArrow = ' ↓';
|
||||
$votingSort = 'voting_asc';
|
||||
break;
|
||||
|
||||
case 'date_desc':
|
||||
default:
|
||||
$dateArrow = ' ↓';
|
||||
$dateSort = 'date_asc';
|
||||
break;
|
||||
$dateArrow = ' ↓';
|
||||
$dateSort = 'date_asc';
|
||||
break;
|
||||
}
|
||||
?>
|
||||
<a href="?sort=<?php echo $dateSort ?>"><?php echo T_("Date").$dateArrow; ?></a>
|
||||
@ -159,73 +159,73 @@ default:
|
||||
|
||||
<?php
|
||||
if ($currenttag!= '') {
|
||||
if ($user!= '') {
|
||||
echo ' - ';
|
||||
echo '<a href="'. createURL('tags', $currenttag) .'">';
|
||||
echo T_('Bookmarks from other users for this tag').'</a>';
|
||||
//echo T_(' for these tags');
|
||||
} else if ($userservice->isLoggedOn()){
|
||||
echo ' - ';
|
||||
echo '<a href="'. createURL('bookmarks', $currentUser->getUsername().'/'.$currenttag) .'">';
|
||||
echo T_('Only your bookmarks for this tag').'</a>';
|
||||
//echo T_(' for these tags');
|
||||
}
|
||||
if ($user!= '') {
|
||||
echo ' - ';
|
||||
echo '<a href="'. createURL('tags', $currenttag) .'">';
|
||||
echo T_('Bookmarks from other users for this tag').'</a>';
|
||||
//echo T_(' for these tags');
|
||||
} else if ($userservice->isLoggedOn()){
|
||||
echo ' - ';
|
||||
echo '<a href="'. createURL('bookmarks', $currentUser->getUsername().'/'.$currenttag) .'">';
|
||||
echo T_('Only your bookmarks for this tag').'</a>';
|
||||
//echo T_(' for these tags');
|
||||
}
|
||||
}
|
||||
?></p>
|
||||
|
||||
<?php
|
||||
// PAGINATION
|
||||
// PAGINATION
|
||||
|
||||
// Ordering
|
||||
$sortOrder = '';
|
||||
if (GET_SORT != '') {
|
||||
$sortOrder = 'sort=' . getSortOrder();
|
||||
}
|
||||
// Ordering
|
||||
$sortOrder = '';
|
||||
if (GET_SORT != '') {
|
||||
$sortOrder = 'sort=' . getSortOrder();
|
||||
}
|
||||
|
||||
$sortAmp = (($sortOrder) ? '&'. $sortOrder : '');
|
||||
$sortQue = (($sortOrder) ? '?'. $sortOrder : '');
|
||||
$sortAmp = (($sortOrder) ? '&'. $sortOrder : '');
|
||||
$sortQue = (($sortOrder) ? '?'. $sortOrder : '');
|
||||
|
||||
// Previous
|
||||
$perpage = getPerPageCount($currentUser);
|
||||
if (!$page || $page < 2) {
|
||||
$page = 1;
|
||||
$start = 0;
|
||||
$bfirst = '<span class="disable">'. T_('First') .'</span>';
|
||||
$bprev = '<span class="disable">'. T_('Previous') .'</span>';
|
||||
} else {
|
||||
$prev = $page - 1;
|
||||
$prev = 'page='. $prev;
|
||||
$start = ($page - 1) * $perpage;
|
||||
$bfirst= '<a href="'. sprintf($nav_url, $user, $currenttag, '') . $sortQue .'">'. T_('First') .'</a>';
|
||||
$bprev = '<a href="'. sprintf($nav_url, $user, $currenttag, '?') . $prev . $sortAmp .'">'. T_('Previous') .'</a>';
|
||||
}
|
||||
// Previous
|
||||
$perpage = getPerPageCount($currentUser);
|
||||
if (!$page || $page < 2) {
|
||||
$page = 1;
|
||||
$start = 0;
|
||||
$bfirst = '<span class="disable">'. T_('First') .'</span>';
|
||||
$bprev = '<span class="disable">'. T_('Previous') .'</span>';
|
||||
} else {
|
||||
$prev = $page - 1;
|
||||
$prev = 'page='. $prev;
|
||||
$start = ($page - 1) * $perpage;
|
||||
$bfirst= '<a href="'. sprintf($nav_url, $user, $currenttag, '') . $sortQue .'">'. T_('First') .'</a>';
|
||||
$bprev = '<a href="'. sprintf($nav_url, $user, $currenttag, '?') . $prev . $sortAmp .'">'. T_('Previous') .'</a>';
|
||||
}
|
||||
|
||||
// Next
|
||||
$next = $page + 1;
|
||||
$totalpages = ceil($total / $perpage);
|
||||
if (count($bookmarks) < $perpage || $perpage * $page == $total) {
|
||||
$bnext = '<span class="disable">'. T_('Next') .'</span>';
|
||||
$blast = '<span class="disable">'. T_('Last') ."</span>\n";
|
||||
} else {
|
||||
$bnext = '<a href="'. sprintf($nav_url, $user, $currenttag, '?page=') . $next . $sortAmp .'">'. T_('Next') .'</a>';
|
||||
$blast = '<a href="'. sprintf($nav_url, $user, $currenttag, '?page=') . $totalpages . $sortAmp .'">'. T_('Last') ."</a>\n";
|
||||
}
|
||||
// Next
|
||||
$next = $page + 1;
|
||||
$totalpages = ceil($total / $perpage);
|
||||
if (count($bookmarks) < $perpage || $perpage * $page == $total) {
|
||||
$bnext = '<span class="disable">'. T_('Next') .'</span>';
|
||||
$blast = '<span class="disable">'. T_('Last') ."</span>\n";
|
||||
} else {
|
||||
$bnext = '<a href="'. sprintf($nav_url, $user, $currenttag, '?page=') . $next . $sortAmp .'">'. T_('Next') .'</a>';
|
||||
$blast = '<a href="'. sprintf($nav_url, $user, $currenttag, '?page=') . $totalpages . $sortAmp .'">'. T_('Last') ."</a>\n";
|
||||
}
|
||||
|
||||
// RSS
|
||||
$brss = '';
|
||||
$size = count($rsschannels);
|
||||
for ($i = 0; $i < $size; $i++) {
|
||||
$brss = '<a style="background:#FFFFFF" href="'. htmlspecialchars($rsschannels[$i][1]) . '"'
|
||||
// RSS
|
||||
$brss = '';
|
||||
$size = count($rsschannels);
|
||||
for ($i = 0; $i < $size; $i++) {
|
||||
$brss = '<a style="background:#FFFFFF" href="'. htmlspecialchars($rsschannels[$i][1]) . '"'
|
||||
. ' title="' . htmlspecialchars($rsschannels[$i][0]) . '">'
|
||||
. '<img src="' . ROOT . 'images/rss.gif" width="16" height="16" alt="' . htmlspecialchars($rsschannels[$i][0]) .'"/>'
|
||||
. '</a>';
|
||||
}
|
||||
}
|
||||
|
||||
$pagesBanner = '<p class="paging">'. $bfirst .'<span> / </span>'. $bprev .'<span> / </span>'. $bnext .'<span> / </span>'. $blast .'<span> / </span>'. sprintf(T_('Page %d of %d'), $page, $totalpages) ." ". $brss ." </p>\n";
|
||||
$pagesBanner = '<p class="paging">'. $bfirst .'<span> / </span>'. $bprev .'<span> / </span>'. $bnext .'<span> / </span>'. $blast .'<span> / </span>'. sprintf(T_('Page %d of %d'), $page, $totalpages) ." ". $brss ." </p>\n";
|
||||
|
||||
if (getPerPageCount($currentUser) > 10) {
|
||||
echo $pagesBanner; // display a page banner if too many bookmarks to manage
|
||||
}
|
||||
if (getPerPageCount($currentUser) > 10) {
|
||||
echo $pagesBanner; // display a page banner if too many bookmarks to manage
|
||||
}
|
||||
|
||||
|
||||
?>
|
||||
@ -253,87 +253,87 @@ if ($currenttag!= '') {
|
||||
$watchedNames = null;
|
||||
}
|
||||
|
||||
foreach ($bookmarks as $key => &$row) {
|
||||
switch ($row['bStatus']) {
|
||||
case 0:
|
||||
$access = '';
|
||||
break;
|
||||
case 1:
|
||||
$access = ' shared';
|
||||
break;
|
||||
case 2:
|
||||
$access = ' private';
|
||||
break;
|
||||
}
|
||||
foreach ($bookmarks as $key => &$row) {
|
||||
switch ($row['bStatus']) {
|
||||
case 0:
|
||||
$access = '';
|
||||
break;
|
||||
case 1:
|
||||
$access = ' shared';
|
||||
break;
|
||||
case 2:
|
||||
$access = ' private';
|
||||
break;
|
||||
}
|
||||
|
||||
$cats = '';
|
||||
$tagsForCopy = '';
|
||||
$tags = $row['tags'];
|
||||
foreach ($tags as $tkey => &$tag) {
|
||||
$tagcaturl = sprintf(
|
||||
$cat_url,
|
||||
filter($row['username'], 'url'),
|
||||
filter($tag, 'url')
|
||||
);
|
||||
$cats .= sprintf(
|
||||
'<a href="%s" rel="tag">%s</a>, ',
|
||||
$tagcaturl, filter($tag)
|
||||
);
|
||||
$tagsForCopy .= $tag . ',';
|
||||
}
|
||||
$cats = substr($cats, 0, -2);
|
||||
if ($cats != '') {
|
||||
$cats = T_('Tags:') . ' ' . $cats;
|
||||
}
|
||||
$cats = '';
|
||||
$tagsForCopy = '';
|
||||
$tags = $row['tags'];
|
||||
foreach ($tags as $tkey => &$tag) {
|
||||
$tagcaturl = sprintf(
|
||||
$cat_url,
|
||||
filter($row['username'], 'url'),
|
||||
filter($tag, 'url')
|
||||
);
|
||||
$cats .= sprintf(
|
||||
'<a href="%s" rel="tag">%s</a>, ',
|
||||
$tagcaturl, filter($tag)
|
||||
);
|
||||
$tagsForCopy .= $tag . ',';
|
||||
}
|
||||
$cats = substr($cats, 0, -2);
|
||||
if ($cats != '') {
|
||||
$cats = T_('Tags:') . ' ' . $cats;
|
||||
}
|
||||
|
||||
// Edit and delete links
|
||||
$edit = '';
|
||||
if ($bookmarkservice->editAllowed($row)) {
|
||||
$edit = ' - <a href="' . createURL('edit', $row['bId']) . '">'
|
||||
// Edit and delete links
|
||||
$edit = '';
|
||||
if ($bookmarkservice->editAllowed($row)) {
|
||||
$edit = ' - <a href="' . createURL('edit', $row['bId']) . '">'
|
||||
. T_('Edit')
|
||||
. '</a>'
|
||||
. '<script type="text/javascript">'
|
||||
. 'document.write(" - <a href=\"#\" onclick=\"deleteBookmark(this, '. $row['bId'] .'); return false;\">'
|
||||
. T_('Delete')
|
||||
.'<\/a>");</script>';
|
||||
}
|
||||
}
|
||||
|
||||
// Last update
|
||||
$update = ' <small title="'. T_('Last update') .'">('. date($GLOBALS['shortdate'], strtotime($row['bModified'])). ') </small>';
|
||||
// Last update
|
||||
$update = ' <small title="'. T_('Last update') .'">('. date($GLOBALS['shortdate'], strtotime($row['bModified'])). ') </small>';
|
||||
|
||||
// User attribution
|
||||
$copy = ' ' . T_('by') . ' ';
|
||||
if ($userservice->isLoggedOn()
|
||||
&& $currentUser->getUsername() == $row['username']
|
||||
// User attribution
|
||||
$copy = ' ' . T_('by') . ' ';
|
||||
if ($userservice->isLoggedOn()
|
||||
&& $currentUser->getUsername() == $row['username']
|
||||
) {
|
||||
$copy .= T_('you');
|
||||
} else {
|
||||
$copy .= '<a href="' . createURL('bookmarks', $row['username']) . '">'
|
||||
$copy .= T_('you');
|
||||
} else {
|
||||
$copy .= '<a href="' . createURL('bookmarks', $row['username']) . '">'
|
||||
. $row['username'] . '</a>';
|
||||
}
|
||||
}
|
||||
|
||||
// Udders!
|
||||
if (!isset($hash)) {
|
||||
$others = $otherCounts[$row['bAddress']];
|
||||
$ostart = '<a href="' . createURL('history', $row['bHash']) . '">';
|
||||
$oend = '</a>';
|
||||
switch ($others) {
|
||||
case 0:
|
||||
break;
|
||||
case 1:
|
||||
$copy .= sprintf(T_(' and %s1 other%s'), $ostart, $oend);
|
||||
break;
|
||||
default:
|
||||
$copy .= sprintf(T_(' and %2$s%1$s others%3$s'), $others, $ostart, $oend);
|
||||
}
|
||||
}
|
||||
// Udders!
|
||||
if (!isset($hash)) {
|
||||
$others = $otherCounts[$row['bAddress']];
|
||||
$ostart = '<a href="' . createURL('history', $row['bHash']) . '">';
|
||||
$oend = '</a>';
|
||||
switch ($others) {
|
||||
case 0:
|
||||
break;
|
||||
case 1:
|
||||
$copy .= sprintf(T_(' and %s1 other%s'), $ostart, $oend);
|
||||
break;
|
||||
default:
|
||||
$copy .= sprintf(T_(' and %2$s%1$s others%3$s'), $others, $ostart, $oend);
|
||||
}
|
||||
}
|
||||
|
||||
// Copy link
|
||||
if ($userservice->isLoggedOn()
|
||||
// Copy link
|
||||
if ($userservice->isLoggedOn()
|
||||
&& ($currentUser->getId() != $row['uId'])
|
||||
&& !$existence[$row['bAddress']]
|
||||
) {
|
||||
$copy .= ' - <a href="'
|
||||
$copy .= ' - <a href="'
|
||||
. createURL(
|
||||
'bookmarks',
|
||||
$currentUser->getUsername()
|
||||
@ -341,40 +341,40 @@ if ($currenttag!= '') {
|
||||
. '" title="'.T_('Copy this bookmark to YOUR bookmarks.').'">'
|
||||
. T_('Copy')
|
||||
. '</a>';
|
||||
}
|
||||
}
|
||||
|
||||
// Nofollow option
|
||||
$rel = '';
|
||||
if ($GLOBALS['nofollow']) {
|
||||
$rel = ' rel="nofollow"';
|
||||
}
|
||||
// Nofollow option
|
||||
$rel = '';
|
||||
if ($GLOBALS['nofollow']) {
|
||||
$rel = ' rel="nofollow"';
|
||||
}
|
||||
|
||||
$address = filter($row['bAddress']);
|
||||
$oaddress = $address;
|
||||
// Redirection option
|
||||
if ($GLOBALS['useredir']) {
|
||||
$address = $GLOBALS['url_redir'] . $address;
|
||||
}
|
||||
$address = filter($row['bAddress']);
|
||||
$oaddress = $address;
|
||||
// Redirection option
|
||||
if ($GLOBALS['useredir']) {
|
||||
$address = $GLOBALS['url_redir'] . $address;
|
||||
}
|
||||
|
||||
// Admin specific design
|
||||
if ($userservice->isAdmin($row['username']) && $GLOBALS['enableAdminColors']) {
|
||||
$adminBgClass = ' class="adminBackground"';
|
||||
$adminStar = ' <img src="'. ROOT .'images/logo_24.gif" width="12px" title="'. T_('This bookmark is certified by an admin user.') .'" />';
|
||||
} else {
|
||||
$adminBgClass = '';
|
||||
$adminStar = '';
|
||||
}
|
||||
// Admin specific design
|
||||
if ($userservice->isAdmin($row['username']) && $GLOBALS['enableAdminColors']) {
|
||||
$adminBgClass = ' class="adminBackground"';
|
||||
$adminStar = ' <img src="'. ROOT .'images/logo_24.gif" width="12px" title="'. T_('This bookmark is certified by an admin user.') .'" />';
|
||||
} else {
|
||||
$adminBgClass = '';
|
||||
$adminStar = '';
|
||||
}
|
||||
|
||||
// Private Note (just visible by the owner and his/her contacts)
|
||||
// Private Note (just visible by the owner and his/her contacts)
|
||||
if ($watchedNames !== null
|
||||
&& ($currentUser->getId() == $row['uId']
|
||||
|| in_array($row['username'], $watchedNames)
|
||||
)
|
||||
) {
|
||||
$privateNoteField = $row['bPrivateNote'];
|
||||
} else {
|
||||
$privateNoteField = '';
|
||||
}
|
||||
$privateNoteField = $row['bPrivateNote'];
|
||||
} else {
|
||||
$privateNoteField = '';
|
||||
}
|
||||
|
||||
if ($GLOBALS['enableVoting'] && $GLOBALS['hideBelowVoting'] !== null
|
||||
&& $row['bVoting'] < $GLOBALS['hideBelowVoting']
|
||||
@ -382,57 +382,57 @@ if ($currenttag!= '') {
|
||||
$access .= ' below-threshold';
|
||||
}
|
||||
|
||||
// Output
|
||||
echo ' <li class="xfolkentry'. $access .'">'."\n";
|
||||
// Output
|
||||
echo ' <li class="xfolkentry'. $access .'">'."\n";
|
||||
include 'bookmarks-thumbnail.inc.tpl.php';
|
||||
include 'bookmarks-vote.inc.tpl.php';
|
||||
|
||||
echo ' <div' . $adminBgClass . '>' . "\n";
|
||||
echo ' <div' . $adminBgClass . '>' . "\n";
|
||||
|
||||
echo ' <div class="link">'
|
||||
echo ' <div class="link">'
|
||||
. '<a href="'. $address .'"'. $rel .' class="taggedlink" target="_blank">'
|
||||
. filter($row['bTitle'])
|
||||
. '</a>' . $adminStar . "</div>\n";
|
||||
if ($row['bDescription'] == '') {
|
||||
$bkDescription = $GLOBALS['blankDescription'];
|
||||
} else {
|
||||
// Improve description display (anchors, links, ...)
|
||||
$bkDescription = preg_replace('|\[\/.*?\]|', '', filter($row['bDescription'])); // remove final anchor
|
||||
$bkDescription = preg_replace('|\[(.*?)\]|', ' <span class="anchorBookmark">$1</span> » ', $bkDescription); // highlight starting anchor
|
||||
$bkDescription = preg_replace('@((http|https|ftp)://.*?)( |\r|$)@', '<a href="$1" rel="nofollow">$1</a>$3', $bkDescription); // make url clickable
|
||||
if ($row['bDescription'] == '') {
|
||||
$bkDescription = $GLOBALS['blankDescription'];
|
||||
} else {
|
||||
// Improve description display (anchors, links, ...)
|
||||
$bkDescription = preg_replace('|\[\/.*?\]|', '', filter($row['bDescription'])); // remove final anchor
|
||||
$bkDescription = preg_replace('|\[(.*?)\]|', ' <span class="anchorBookmark">$1</span> » ', $bkDescription); // highlight starting anchor
|
||||
$bkDescription = preg_replace('@((http|https|ftp)://.*?)( |\r|$)@', '<a href="$1" rel="nofollow">$1</a>$3', $bkDescription); // make url clickable
|
||||
|
||||
}
|
||||
echo ' <div class="description">'. nl2br($bkDescription) ."</div>\n";
|
||||
}
|
||||
echo ' <div class="description">'. nl2br($bkDescription) ."</div>\n";
|
||||
echo ' <div class="address">' . shortenString($oaddress) . "</div>\n";
|
||||
|
||||
echo ' <div class="meta">'
|
||||
echo ' <div class="meta">'
|
||||
. $cats . "\n"
|
||||
. $copy . "\n"
|
||||
. $edit . "\n"
|
||||
. $update . "\n"
|
||||
. " </div>\n";
|
||||
echo $privateNoteField != ''
|
||||
echo $privateNoteField != ''
|
||||
? ' <div class="privateNote" title="'. T_('Private Note on this bookmark') .'">'.$privateNoteField."</div>\n"
|
||||
: '';
|
||||
echo ' ';
|
||||
include 'bookmarks-vote-horizontal.inc.tpl.php';
|
||||
echo " </div>\n";
|
||||
echo " </div>\n";
|
||||
|
||||
echo " </li>\n";
|
||||
}
|
||||
?>
|
||||
echo " </li>\n";
|
||||
}
|
||||
?>
|
||||
|
||||
</ol>
|
||||
|
||||
<?php
|
||||
if(getPerPageCount($currentUser)>7) {
|
||||
echo '<p class="backToTop"><a href="#header" title="'.T_('Come back to the top of this page.').'">'.T_('Top of the page').'</a></p>';
|
||||
}
|
||||
echo $pagesBanner; // display previous and next links pages + RSS link
|
||||
<?php
|
||||
if(getPerPageCount($currentUser)>7) {
|
||||
echo '<p class="backToTop"><a href="#header" title="'.T_('Come back to the top of this page.').'">'.T_('Top of the page').'</a></p>';
|
||||
}
|
||||
echo $pagesBanner; // display previous and next links pages + RSS link
|
||||
|
||||
|
||||
} else {
|
||||
echo '<p class="error">'.T_('No bookmarks available').'</p>';
|
||||
echo '<p class="error">'.T_('No bookmarks available').'</p>';
|
||||
}
|
||||
$this->includeTemplate('sidebar.tpl');
|
||||
$this->includeTemplate($GLOBALS['bottom_include']);
|
||||
|
@ -16,7 +16,7 @@
|
||||
*
|
||||
* @category Bookmarking
|
||||
* @package SemanticScuttle
|
||||
* @author Christian Weiske <cweiske@cweiske.de>
|
||||
* @author Christian Weiske <cweiske@cweiske.de>
|
||||
* @license GPL http://www.gnu.org/licenses/gpl.html
|
||||
* @link http://sourceforge.net/projects/semanticscuttle
|
||||
*/
|
||||
|
@ -121,7 +121,7 @@ class SemanticScuttle_Model_User
|
||||
public function getHomepage()
|
||||
{
|
||||
// Look for value only if not already set
|
||||
if(!isset($this->homepage)) {
|
||||
if (!isset($this->homepage)) {
|
||||
$us = SemanticScuttle_Service_Factory::get('User');
|
||||
$user = $us->getUser($this->id);
|
||||
$this->homepage = $user['homepage'];
|
||||
@ -137,7 +137,7 @@ class SemanticScuttle_Model_User
|
||||
public function getContent()
|
||||
{
|
||||
// Look for value only if not already set
|
||||
if(!isset($this->content)) {
|
||||
if (!isset($this->content)) {
|
||||
$us = SemanticScuttle_Service_Factory::get('User');
|
||||
$user = $us->getUser($this->id);
|
||||
$this->content = $user['uContent'];
|
||||
@ -154,7 +154,7 @@ class SemanticScuttle_Model_User
|
||||
public function getDatetime()
|
||||
{
|
||||
// Look for value only if not already set
|
||||
if(!isset($this->content)) {
|
||||
if (!isset($this->content)) {
|
||||
$us = SemanticScuttle_Service_Factory::get('User');
|
||||
$user = $us->getUser($this->id);
|
||||
$this->datetime = $user['uDatetime'];
|
||||
@ -170,7 +170,7 @@ class SemanticScuttle_Model_User
|
||||
public function isAdmin()
|
||||
{
|
||||
// Look for value only if not already set
|
||||
if(!isset($this->isAdmin)) {
|
||||
if (!isset($this->isAdmin)) {
|
||||
$us = SemanticScuttle_Service_Factory::get('User');
|
||||
$this->isAdmin = $us->isAdmin($this->username);
|
||||
}
|
||||
|
@ -33,8 +33,6 @@ class SemanticScuttle_Service
|
||||
*/
|
||||
protected $db;
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Returns the single service instance
|
||||
*
|
||||
@ -47,14 +45,14 @@ class SemanticScuttle_Service
|
||||
*
|
||||
* @return SemanticScuttle_Service
|
||||
*/
|
||||
public static function getInstance($db)
|
||||
public static function getInstance($db)
|
||||
{
|
||||
static $instance;
|
||||
if (!isset($instance)) {
|
||||
static $instance;
|
||||
if (!isset($instance)) {
|
||||
$instance = new self($db);
|
||||
}
|
||||
return $instance;
|
||||
}
|
||||
return $instance;
|
||||
}
|
||||
|
||||
}
|
||||
?>
|
||||
?>
|
||||
|
@ -86,7 +86,7 @@ class SemanticScuttle_Service_AuthUser extends SemanticScuttle_Service_User
|
||||
/**
|
||||
* Create new instance
|
||||
*
|
||||
* @var sql_db $db Database object
|
||||
* @param sql_db $db Database object
|
||||
*/
|
||||
protected function __construct($db)
|
||||
{
|
||||
@ -208,7 +208,7 @@ class SemanticScuttle_Service_AuthUser extends SemanticScuttle_Service_User
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
@ -229,4 +229,4 @@ class SemanticScuttle_Service_AuthUser extends SemanticScuttle_Service_User
|
||||
}
|
||||
|
||||
}
|
||||
?>
|
||||
?>
|
||||
|
@ -5,29 +5,29 @@
|
||||
*/
|
||||
|
||||
// Debug managament
|
||||
if(isset($GLOBALS['debugMode'])) {
|
||||
define('DEBUG_MODE', $GLOBALS['debugMode']);
|
||||
define('DEBUG_EXTRA', $GLOBALS['debugMode']); // Constant used exclusively into db/ directory
|
||||
if (isset($GLOBALS['debugMode'])) {
|
||||
define('DEBUG_MODE', $GLOBALS['debugMode']);
|
||||
define('DEBUG_EXTRA', $GLOBALS['debugMode']); // Constant used exclusively into db/ directory
|
||||
}
|
||||
|
||||
// Determine the base URL as ROOT
|
||||
if (!isset($GLOBALS['root'])) {
|
||||
$pieces = explode('/', $_SERVER['SCRIPT_NAME']);
|
||||
|
||||
$rootTmp = '/';
|
||||
foreach ($pieces as $piece) {
|
||||
//we eliminate possible sscuttle subfolders (like gsearch for example)
|
||||
if ($piece != '' && !strstr($piece, '.php') && $piece != 'gsearch') {
|
||||
$rootTmp .= $piece .'/';
|
||||
}
|
||||
}
|
||||
if (($rootTmp != '/') && (substr($rootTmp, -1, 1) != '/')) {
|
||||
$rootTmp .= '/';
|
||||
}
|
||||
$pieces = explode('/', $_SERVER['SCRIPT_NAME']);
|
||||
|
||||
$rootTmp = '/';
|
||||
foreach ($pieces as $piece) {
|
||||
//we eliminate possible sscuttle subfolders (like gsearch for example)
|
||||
if ($piece != '' && !strstr($piece, '.php') && $piece != 'gsearch') {
|
||||
$rootTmp .= $piece .'/';
|
||||
}
|
||||
}
|
||||
if (($rootTmp != '/') && (substr($rootTmp, -1, 1) != '/')) {
|
||||
$rootTmp .= '/';
|
||||
}
|
||||
|
||||
define('ROOT', 'http://'. $_SERVER['HTTP_HOST'] . $rootTmp);
|
||||
define('ROOT', 'http://'. $_SERVER['HTTP_HOST'] . $rootTmp);
|
||||
} else {
|
||||
define('ROOT', $GLOBALS['root']);
|
||||
define('ROOT', $GLOBALS['root']);
|
||||
}
|
||||
|
||||
// Error codes
|
||||
@ -49,14 +49,14 @@ define('INSTALLATION_ID', md5($GLOBALS['dbname'].$GLOBALS['tableprefix']));
|
||||
|
||||
// Correct bugs with PATH_INFO (maybe for Apache 1 or CGI) -- for 1&1 host...
|
||||
if (isset($_SERVER['PATH_INFO']) && isset($_SERVER['ORIG_PATH_INFO'])) {
|
||||
if(strlen($_SERVER["PATH_INFO"])<strlen($_SERVER["ORIG_PATH_INFO"])) {
|
||||
$_SERVER["PATH_INFO"] = $_SERVER["ORIG_PATH_INFO"];
|
||||
}
|
||||
if(strcasecmp($_SERVER["PATH_INFO"], $_SERVER["SCRIPT_NAME "]) == 0) {
|
||||
unset($_SERVER["PATH_INFO"]);
|
||||
}
|
||||
if(strpos($_SERVER["PATH_INFO"], '.php') !== false) {
|
||||
unset($_SERVER["PATH_INFO"]);
|
||||
}
|
||||
if (strlen($_SERVER["PATH_INFO"])<strlen($_SERVER["ORIG_PATH_INFO"])) {
|
||||
$_SERVER["PATH_INFO"] = $_SERVER["ORIG_PATH_INFO"];
|
||||
}
|
||||
if (strcasecmp($_SERVER["PATH_INFO"], $_SERVER["SCRIPT_NAME "]) == 0) {
|
||||
unset($_SERVER["PATH_INFO"]);
|
||||
}
|
||||
if (strpos($_SERVER["PATH_INFO"], '.php') !== false) {
|
||||
unset($_SERVER["PATH_INFO"]);
|
||||
}
|
||||
}
|
||||
?>
|
||||
|
@ -18,34 +18,36 @@
|
||||
// Converts tags:
|
||||
// - direction = out: convert spaces to underscores;
|
||||
// - direction = in: convert underscores to spaces.
|
||||
function convertTag($tag, $direction = 'out') {
|
||||
if ($direction == 'out') {
|
||||
$tag = str_replace(' ', '_', $tag);
|
||||
} else {
|
||||
$tag = str_replace('_', ' ', $tag);
|
||||
}
|
||||
return $tag;
|
||||
function convertTag($tag, $direction = 'out')
|
||||
{
|
||||
if ($direction == 'out') {
|
||||
$tag = str_replace(' ', '_', $tag);
|
||||
} else {
|
||||
$tag = str_replace('_', ' ', $tag);
|
||||
}
|
||||
return $tag;
|
||||
}
|
||||
|
||||
function filter($data, $type = NULL) {
|
||||
if (is_string($data)) {
|
||||
$data = trim($data);
|
||||
$data = stripslashes($data);
|
||||
switch ($type) {
|
||||
case 'url':
|
||||
$data = rawurlencode($data);
|
||||
break;
|
||||
default:
|
||||
$data = htmlspecialchars($data);
|
||||
break;
|
||||
}
|
||||
} else if (is_array($data)) {
|
||||
foreach(array_keys($data) as $key) {
|
||||
$row =& $data[$key];
|
||||
$row = filter($row, $type);
|
||||
}
|
||||
}
|
||||
return $data;
|
||||
function filter($data, $type = null)
|
||||
{
|
||||
if (is_string($data)) {
|
||||
$data = trim($data);
|
||||
$data = stripslashes($data);
|
||||
switch ($type) {
|
||||
case 'url':
|
||||
$data = rawurlencode($data);
|
||||
break;
|
||||
default:
|
||||
$data = htmlspecialchars($data);
|
||||
break;
|
||||
}
|
||||
} else if (is_array($data)) {
|
||||
foreach (array_keys($data) as $key) {
|
||||
$row =& $data[$key];
|
||||
$row = filter($row, $type);
|
||||
}
|
||||
}
|
||||
return $data;
|
||||
}
|
||||
|
||||
/**
|
||||
@ -60,63 +62,67 @@ function filter($data, $type = NULL) {
|
||||
*/
|
||||
function getPerPageCount($userObject = null)
|
||||
{
|
||||
global $defaultPerPage, $defaultPerPageForAdmins;
|
||||
global $defaultPerPage, $defaultPerPageForAdmins;
|
||||
|
||||
if (isset($defaultPerPageForAdmins)
|
||||
&& $userObject != null && $userObject->isAdmin()
|
||||
if (isset($defaultPerPageForAdmins)
|
||||
&& $userObject != null
|
||||
&& $userObject->isAdmin()
|
||||
) {
|
||||
return $defaultPerPageForAdmins;
|
||||
} else {
|
||||
return $defaultPerPage;
|
||||
}
|
||||
return $defaultPerPageForAdmins;
|
||||
} else {
|
||||
return $defaultPerPage;
|
||||
}
|
||||
}
|
||||
|
||||
function getSortOrder($override = NULL) {
|
||||
global $defaultOrderBy;
|
||||
function getSortOrder($override = null)
|
||||
{
|
||||
global $defaultOrderBy;
|
||||
|
||||
if (isset($_GET['sort'])) {
|
||||
return preg_replace('/[^a-z_]/', '', $_GET['sort']);
|
||||
} else if (isset($override)) {
|
||||
return $override;
|
||||
} else {
|
||||
return $defaultOrderBy;
|
||||
}
|
||||
if (isset($_GET['sort'])) {
|
||||
return preg_replace('/[^a-z_]/', '', $_GET['sort']);
|
||||
} elseif (isset($override)) {
|
||||
return $override;
|
||||
} else {
|
||||
return $defaultOrderBy;
|
||||
}
|
||||
}
|
||||
|
||||
function multi_array_search($needle, $haystack) {
|
||||
if (is_array($haystack)) {
|
||||
foreach(array_keys($haystack) as $key) {
|
||||
$value =& $haystack[$key];
|
||||
$result = multi_array_search($needle, $value);
|
||||
if (is_array($result)) {
|
||||
$return = $result;
|
||||
array_unshift($return, $key);
|
||||
return $return;
|
||||
} elseif ($result == true) {
|
||||
$return[] = $key;
|
||||
return $return;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
} else {
|
||||
if ($needle === $haystack) {
|
||||
return true;
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
function multi_array_search($needle, $haystack)
|
||||
{
|
||||
if (is_array($haystack)) {
|
||||
foreach (array_keys($haystack) as $key) {
|
||||
$value =& $haystack[$key];
|
||||
$result = multi_array_search($needle, $value);
|
||||
if (is_array($result)) {
|
||||
$return = $result;
|
||||
array_unshift($return, $key);
|
||||
return $return;
|
||||
} elseif ($result == true) {
|
||||
$return[] = $key;
|
||||
return $return;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
} else {
|
||||
if ($needle === $haystack) {
|
||||
return true;
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function createURL($page = '', $ending = '') {
|
||||
global $cleanurls;
|
||||
if (!$cleanurls && $page != '') {
|
||||
$page .= '.php';
|
||||
}
|
||||
if(strlen($ending)>0) {
|
||||
return ROOT . $page .'/'. $ending;
|
||||
} else {
|
||||
return ROOT . $page;
|
||||
}
|
||||
function createURL($page = '', $ending = '')
|
||||
{
|
||||
global $cleanurls;
|
||||
if (!$cleanurls && $page != '') {
|
||||
$page .= '.php';
|
||||
}
|
||||
if (strlen($ending)>0) {
|
||||
return ROOT . $page .'/'. $ending;
|
||||
} else {
|
||||
return ROOT . $page;
|
||||
}
|
||||
}
|
||||
/**
|
||||
* Creates a "vote for/against this bookmark" URL.
|
||||
@ -139,116 +145,129 @@ function createVoteURL($for, $bId)
|
||||
}
|
||||
|
||||
/* Shorten a string like a URL for example by cutting the middle of it */
|
||||
function shortenString($string, $maxSize=75) {
|
||||
$output = '';
|
||||
if(strlen($string) > $maxSize) {
|
||||
$output = substr($string, 0, $maxSize/2).'...'.substr($string, -$maxSize/2);
|
||||
} else {
|
||||
$output = $string;
|
||||
}
|
||||
return $output;
|
||||
function shortenString($string, $maxSize=75)
|
||||
{
|
||||
$output = '';
|
||||
if (strlen($string) > $maxSize) {
|
||||
$output = substr($string, 0, $maxSize/2).'...'.substr($string, -$maxSize/2);
|
||||
} else {
|
||||
$output = $string;
|
||||
}
|
||||
return $output;
|
||||
}
|
||||
|
||||
/* Check url format and check online if the url is a valid page (Not a 404 error for example) */
|
||||
function checkUrl($url, $checkOnline = true) {
|
||||
//check format
|
||||
if(!preg_match("#(ht|f)tp(s?)\://\S+\.\S+#i",$url)) {
|
||||
return false;
|
||||
}
|
||||
function checkUrl($url, $checkOnline = true)
|
||||
{
|
||||
//check format
|
||||
if (!preg_match("#(ht|f)tp(s?)\://\S+\.\S+#i", $url)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if($checkOnline) {
|
||||
//look if the page doesn't return a void or 40X or 50X HTTP code error
|
||||
$h = @get_headers($url);
|
||||
if(is_array($h) && strpos($h[0], '40') === false && strpos($h[0], '50') === false) {
|
||||
return true;
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
} else {
|
||||
return true;
|
||||
}
|
||||
if ($checkOnline) {
|
||||
//look if the page doesn't return a void or 40X or 50X HTTP code error
|
||||
$h = @get_headers($url);
|
||||
if (is_array($h) && strpos($h[0], '40') === false && strpos($h[0], '50') === false) {
|
||||
return true;
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
} else {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
/* Returns a concatenated String
|
||||
* including all the tags from the array $arrayTags (excepted of the $exceptedTag)
|
||||
* separated by the $separator.
|
||||
* */
|
||||
function aggregateTags($arrayTags, $separator = ' + ', $exceptedTag = '') {
|
||||
$output = '';
|
||||
function aggregateTags($arrayTags, $separator = ' + ', $exceptedTag = '')
|
||||
{
|
||||
$output = '';
|
||||
|
||||
for($i = 0; $i<count($arrayTags); $i++) {
|
||||
if($arrayTags[$i] != $exceptedTag) {
|
||||
$output.= $arrayTags[$i] . $separator;
|
||||
}
|
||||
}
|
||||
return substr($output, 0, strlen($output) - strlen($separator) );
|
||||
for ($i = 0; $i<count($arrayTags); $i++) {
|
||||
if ($arrayTags[$i] != $exceptedTag) {
|
||||
$output.= $arrayTags[$i] . $separator;
|
||||
}
|
||||
}
|
||||
return substr($output, 0, strlen($output) - strlen($separator));
|
||||
}
|
||||
|
||||
function message_die($msg_code, $msg_text = '', $msg_title = '', $err_line = '', $err_file = '', $sql = '', $db = NULL) {
|
||||
if(defined('HAS_DIED'))
|
||||
die(T_('message_die() was called multiple times.'));
|
||||
define('HAS_DIED', 1);
|
||||
function message_die($msg_code, $msg_text = '', $msg_title = '', $err_line = '', $err_file = '', $sql = '', $db = null)
|
||||
{
|
||||
if (defined('HAS_DIED')) {
|
||||
die(T_('message_die() was called multiple times.'));
|
||||
}
|
||||
define('HAS_DIED', 1);
|
||||
|
||||
$sql_store = $sql;
|
||||
$sql_store = $sql;
|
||||
|
||||
// Get SQL error if we are debugging. Do this as soon as possible to prevent
|
||||
// subsequent queries from overwriting the status of sql_error()
|
||||
if (DEBUG_MODE && ($msg_code == GENERAL_ERROR || $msg_code == CRITICAL_ERROR)) {
|
||||
$sql_error = is_null($db) ? '' : $db->sql_error();
|
||||
$debug_text = '';
|
||||
// Get SQL error if we are debugging. Do this as soon as possible to prevent
|
||||
// subsequent queries from overwriting the status of sql_error()
|
||||
if (DEBUG_MODE && ($msg_code == GENERAL_ERROR || $msg_code == CRITICAL_ERROR)) {
|
||||
$sql_error = is_null($db) ? '' : $db->sql_error();
|
||||
$debug_text = '';
|
||||
|
||||
if ($sql_error['message'] != '')
|
||||
$debug_text .= '<br /><br />'. T_('SQL Error') .' : '. $sql_error['code'] .' '. $sql_error['message'];
|
||||
if ($sql_error['message'] != '') {
|
||||
$debug_text .= '<br /><br />'. T_('SQL Error') .' : '. $sql_error['code'] .' '. $sql_error['message'];
|
||||
}
|
||||
|
||||
if ($sql_store != '')
|
||||
$debug_text .= '<br /><br />'. $sql_store;
|
||||
if ($sql_store != '') {
|
||||
$debug_text .= '<br /><br />'. $sql_store;
|
||||
}
|
||||
|
||||
if ($err_line != '' && $err_file != '')
|
||||
$debug_text .= '</br /><br />'. T_('Line') .' : '. $err_line .'<br />'. T_('File') .' :'. $err_file;
|
||||
if ($err_line != '' && $err_file != '') {
|
||||
$debug_text .= '</br /><br />'. T_('Line') .' : '. $err_line .'<br />'. T_('File') .' :'. $err_file;
|
||||
}
|
||||
|
||||
debug_print_backtrace();
|
||||
}
|
||||
debug_print_backtrace();
|
||||
}
|
||||
|
||||
switch($msg_code) {
|
||||
case GENERAL_MESSAGE:
|
||||
if ($msg_title == '')
|
||||
$msg_title = T_('Information');
|
||||
break;
|
||||
switch($msg_code) {
|
||||
case GENERAL_MESSAGE:
|
||||
if ($msg_title == '') {
|
||||
$msg_title = T_('Information');
|
||||
}
|
||||
break;
|
||||
|
||||
case CRITICAL_MESSAGE:
|
||||
if ($msg_title == '')
|
||||
$msg_title = T_('Critical Information');
|
||||
break;
|
||||
case CRITICAL_MESSAGE:
|
||||
if ($msg_title == '') {
|
||||
$msg_title = T_('Critical Information');
|
||||
}
|
||||
break;
|
||||
|
||||
case GENERAL_ERROR:
|
||||
if ($msg_text == '')
|
||||
$msg_text = T_('An error occured');
|
||||
case GENERAL_ERROR:
|
||||
if ($msg_text == '') {
|
||||
$msg_text = T_('An error occured');
|
||||
}
|
||||
if ($msg_title == '') {
|
||||
$msg_title = T_('General Error');
|
||||
}
|
||||
break;
|
||||
|
||||
if ($msg_title == '')
|
||||
$msg_title = T_('General Error');
|
||||
break;
|
||||
case CRITICAL_ERROR:
|
||||
// Critical errors mean we cannot rely on _ANY_ DB information being
|
||||
// available so we're going to dump out a simple echo'd statement
|
||||
|
||||
case CRITICAL_ERROR:
|
||||
// Critical errors mean we cannot rely on _ANY_ DB information being
|
||||
// available so we're going to dump out a simple echo'd statement
|
||||
if ($msg_text == '') {
|
||||
$msg_text = T_('An critical error occured');
|
||||
}
|
||||
if ($msg_title == '') {
|
||||
$msg_title = T_('Critical Error');
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
if ($msg_text == '')
|
||||
$msg_text = T_('An critical error occured');
|
||||
// Add on DEBUG_MODE info if we've enabled debug mode and this is an error. This
|
||||
// prevents debug info being output for general messages should DEBUG_MODE be
|
||||
// set TRUE by accident (preventing confusion for the end user!)
|
||||
if (DEBUG_MODE && ($msg_code == GENERAL_ERROR || $msg_code == CRITICAL_ERROR)) {
|
||||
if ($debug_text != '') {
|
||||
$msg_text = $msg_text . '<br /><br /><strong>'. T_('DEBUG MODE') .'</strong>'. $debug_text;
|
||||
}
|
||||
}
|
||||
|
||||
if ($msg_title == '')
|
||||
$msg_title = T_('Critical Error');
|
||||
break;
|
||||
}
|
||||
|
||||
// Add on DEBUG_MODE info if we've enabled debug mode and this is an error. This
|
||||
// prevents debug info being output for general messages should DEBUG_MODE be
|
||||
// set TRUE by accident (preventing confusion for the end user!)
|
||||
if (DEBUG_MODE && ($msg_code == GENERAL_ERROR || $msg_code == CRITICAL_ERROR)) {
|
||||
if ($debug_text != '')
|
||||
$msg_text = $msg_text . '<br /><br /><strong>'. T_('DEBUG MODE') .'</strong>'. $debug_text;
|
||||
}
|
||||
|
||||
echo "<html>\n<body>\n". $msg_title ."\n<br /><br />\n". $msg_text ."</body>\n</html>";
|
||||
exit;
|
||||
echo "<html>\n<body>\n". $msg_title ."\n<br /><br />\n". $msg_text ."</body>\n</html>";
|
||||
exit;
|
||||
}
|
||||
?>
|
||||
|
Loading…
Reference in New Issue
Block a user