TP-Docs
HTML5 Icon HTML5 Icon HTML5 Icon
TP on Social Media

Recent

Welcome to TinyPortal. Please login or sign up.

Members
  • Total Members: 3,970
  • Latest: bynw
Stats
  • Total Posts: 196,046
  • Total Topics: 21,335
  • Online today: 232
  • Online ever: 8,223 (February 19, 2025, 04:35:35 AM)
Users Online
  • Users: 0
  • Guests: 161
  • Total: 161

Database Error when posting in Sbox: HELP!

Started by magz, June 12, 2007, 11:41:11 PM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

magz

Error Message:
Duplicate entry '289' for key 1
File: /home/myUSERNAME/public_html/Sources/TPmodules.php
Line: 514


TPmodules.php:
<?php
/******************************************************************************
* TPmodules.php                                                                   *
******************************************************************************
* TP: Tiny Portal for SMF                                                  *
* Software Version:           SMF 0.9                                       *
* Software by:                Bloc (http://www.tinyportal.co.uk) *
* Copyright 2005 by:     Bloc (bloc@tinyportal.co.uk)         *
* Support, News, Updates at:  http://www.tinyportal.co.uk                   *
*******************************************************************************/

if (!defined('SMF'))
die('Hacking attempt...');


// TinyPortal module entrance
function TPmodules()
{
global $db_prefix, $settings, $modSettings, $context, $scripturl,$txt , $user_info , $sourcedir, $boardurl,$ID_MEMBER;


  $tp_prefix=$settings['tp_prefix'];

  loadlanguage('TPmodules');
  loadlanguage('TPortalAdmin');

// get subaction
$tpsub='';
if(isset($_GET['sa'])){
$context['TPortal']['subaction']=$_GET['sa'];
$tpsub=$_GET['sa'];
}
elseif(isset($_GET['sub'])){
$context['TPortal']['subaction']=$_GET['sub'];
$tpsub=$_GET['sub'];
}

// for help pages
if(isset($_GET['p']))
$context['TPortal']['helpsection'] = $_GET['p'];
else
$context['TPortal']['helpsection'] = 'introduction';

// a switch to make it clear what is "forum" and not
$context['TPortal']['not_forum']=true;


// are we on submitarticle page? include the wysiwyg editor then.
if($context['TPortal']['use_wysiwyg']=='2' || $context['TPortal']['use_wysiwyg']=='1')
$context['html_headers'] .= '
<script language="javascript" type="text/javascript" src="'
. $boardurl .'/FCKeditor/fckeditor.js"></script>';
elseif($context['TPortal']['use_wysiwyg']=='3')
$context['html_headers'] .=
'<script language="JavaScript" type="text/javascript" src="'. $boardurl. '/wysiwyg/whizzywig.js"></script>';

// FCKeditor
if($context['TPortal']['use_wysiwyg']=='2' || $context['TPortal']['use_wysiwyg']=='1')
$context['html_headers'] .= '
<script language="JavaScript" type="text/javascript">
function FullEditor(BodyName)
{
var FCKContent = new FCKeditor(BodyName) ;
FCKContent.BasePath = "FCKeditor/" ;
FCKContent.ToolbarSet = "Default"
FCKContent.Height = "400";
FCKContent.Width = "100%";
FCKContent.ReplaceTextarea() ;
}
function SmallerEditor(BodyName)
{
var FCKComment = new FCKeditor(BodyName) ;
FCKComment.BasePath = "FCKeditor/" ;
FCKComment.ToolbarSet = "Basic"
FCKComment.Height = "200";
FCKComment.Width = "100%";
FCKComment.ReplaceTextarea() ;
}
function syncTextarea(){};
</script>'
;

// Whizzywig
elseif($context['TPortal']['use_wysiwyg']=='3')
$context['html_headers'] .= '
<script language="JavaScript" type="text/javascript">
function FullEditor(BodyName)
{
buttonPath = "'
.$boardurl.'/wysiwyg/btn/";
cssFile="";
imageBrowse = "'
.$boardurl.'/wysiwyg/whizzypic.php?d=tp-images/Image";
linkBrowse = "";
makeWhizzyWig(BodyName, "all");
}
function SmallerEditor(BodyName)
{
buttonPath = "'
.$boardurl.'/wysiwyg/btn/";
cssFile="";
imageBrowse = "";
linkBrowse = "";
makeWhizzyWig(BodyName, "formatblock fontname fontsize newline bold italic underline | left center right |  undo redo  | color hilite rule | clean html");
}
</script>'
;

// download manager?
if(isset($_GET['dl'])){
$context['TPortal']['dlsub']=$_GET['dl'];
}
// link manager?
elseif(isset($_GET['link'])){
$context['TPortal']['linksub']=$_GET['link'];
}
// gallery?
elseif(isset($_GET['show'])){
$context['TPortal']['showsub']=$_GET['show'];
}
// team page?
elseif(isset($_GET['team'])){
$context['TPortal']['teamsub']=$_GET['team'];
}
// module manager?
elseif(isset($_GET['modules'])){
$context['TPortal']['modsub']=$_GET['modules'];
}

$idmember = $context['user']['id'];

// add the linktree
TPstrip_linktree();
if(isset($_GET['sub']))
TPadd_linktree($scripturl.'?action=tpmod;sub='.$_GET['sub'] , $_GET['sub']);

// include source files in case of modules
if(isset($context['TPortal']['dlsub'])){
  require_once( $sourcedir .'/TPdlmanager.php');
  TPdlmanager_init();
 }
elseif(isset($context['TPortal']['linksub'])){
  require_once( $sourcedir .'/TPlinkmanager.php');
  TPlinkmanager_init();
 }
elseif(isset($context['TPortal']['showsub'])){
  require_once( $sourcedir .'/TPgallery.php');
  TPgallery_init();
 }
elseif(isset($context['TPortal']['teamsub'])){
  require_once( $sourcedir .'/TPteampage.php');
  TPteampage_init();
 }
// save the upshrink value
elseif(isset($_GET['upshrink']) && isset($_GET['state']))
{
$blockid=$_GET['upshrink'];
$state=$_GET['state'];
// Guests just save it in the cookie.
if ($context['user']['is_guest']){
if(isset($_COOKIE['tp-upshrinks'])){
$shrinks=explode(",",$_COOKIE['tp-upshrinks']);
if($state==0 && !in_array($blockid,$shrinks))
$shrinks[]=$blockid;
elseif($state==1 && in_array($blockid,$shrinks)){
$spos=array_search($blockid,$shrinks);
if($spos>0)
unset($shrinks[$spos]);
}
setcookie ("tp-upshrinks", implode(",",$shrinks));
}
else{
if($state==0)
setcookie ("tp-upshrinks", $blockid);
}
}
else{
// Update the option.
$result = db_query("SELECT id FROM {$tp_prefix}data WHERE type=0 AND ID_MEMBER=$idmember AND item=$blockid", __FILE__, __LINE__);
if(mysql_num_rows($result)>0){
$itemid=mysql_fetch_row($result);
$id=$itemid[0];
mysql_free_result($result);
db_query("UPDATE {$tp_prefix}data SET value=$state WHERE id=$id", __FILE__, __LINE__);
}
else{
db_query("INSERT INTO {$tp_prefix}data (type,ID_MEMBER,value,item) VALUES(0, $idmember, $state, $blockid)", __FILE__, __LINE__);
}
}
// Don't output anything...
$tid=mktime();
redirectexit($settings['images_url'] . '/blank.gif?ti='.$tid);
}
// a comment is sent
elseif($tpsub=='comment' && isset($_POST['tp_article_type']) && $_POST['tp_article_type']=='article_comment' ){
// check the session
checkSession('post');

if ($user_info['is_guest'])
fatal_error('guest not allowed');
$commenter = $context['user']['id'];
$article = $_POST['tp_article_id'];
// check if the article indeed exists
$request = db_query("SELECT comments FROM {$tp_prefix}articles WHERE id=$article", __FILE__, __LINE__);
if(mysql_num_rows($request)>0){
$row=mysql_fetch_row($request);
$num_comments=$row[0]+1;
mysql_free_result($request);
$title = strip_tags($_POST['tp_article_comment_title']);
$comment = substr(strip_tags($_POST['tp_article_bodytext']),0,65536);

$comment = htmlspecialchars($comment, ENT_QUOTES);
require_once($sourcedir.'/Subs-Post.php');
preparsecode($comment);
$time=time();

// insert the comment
db_query("INSERT INTO {$tp_prefix}variables (value1,value2,value3,type,value4,value5)
VALUES('
$title','$comment','$ID_MEMBER','article_comment','$time',$article)", __FILE__, __LINE__);
// count and increase the number of comments
db_query("UPDATE {$tp_prefix}articles SET comments=$num_comments WHERE id=$article", __FILE__, __LINE__);
// go back to the article
redirectexit('page='.$article.'#tp-comment');
}
}
elseif($tpsub=='savesettings' ){
// check the session
checkSession('post');
if(isset($_POST['item']))
$item=$_POST['item'];
else
$item=0;

if(isset($_POST['memberid']))
$mem=$_POST['memberid'];
else
$mem=0;

if(!isset($mem) || (isset($mem) && !is_numeric($mem)))
fatalerror('Member doesn\'t exist.');

foreach($_POST as $what => $value){
if($what=='tpwysiwyg' && $item>0){
db_query("UPDATE {$tp_prefix}data SET value=$value WHERE id=$item", __FILE__, __LINE__);
}
elseif($what=='tpwysiwyg' && $item==0)
db_query("INSERT INTO {$tp_prefix}data (type,ID_MEMBER,value) VALUES(2, $mem, $value)", __FILE__, __LINE__);
}
// go back to profile page
redirectexit('action=profile;u='.$mem.';sa=tparticles;settings');
}
// edit or deleting a comment?
elseif((substr($tpsub,0,11)=='killcomment' || substr($tpsub,0,11)=='editcomment') && $context['user']['is_logged']){
// check that you indeed can edit or delete
$comment=substr($tpsub,11);
if(!is_numeric($comment))
fatal_error('Not allowed.');

$request = db_query("SELECT * FROM {$tp_prefix}variables WHERE id=$comment LIMIT 1", __FILE__, __LINE__);
if(mysql_num_rows($request)>0){
$row=mysql_fetch_assoc($request);
mysql_free_result($request);
if(allowedTo('tp_articles') || $row['value3'] == $ID_MEMBER){
// deleting the comment
if(substr($tpsub,0,11)=='killcomment'){
db_query("UPDATE {$tp_prefix}variables SET value5=-value5 WHERE id=$comment", __FILE__, __LINE__);
redirectexit('page='.$row['value5']);
}
elseif(substr($tpsub,0,11)=='editcomment'){
$context['TPortal']['comment_edit'] = array(
'id' => $row['id'],
'title' => $row['value1'],
'body' => $row['value2'],
);
$context['TPortal']['subaction']='editcomment';
loadtemplate('TPmodules');
}
}
fatal_error($txt['tp-notallowed']);
}
}
// rating is underway
elseif($tpsub=='rate_article' && isset($_POST['tp_article_rating_submit']) && $_POST['tp_article_type']=='article_rating'){
// check the session
checkSession('post');

$commenter = $context['user']['id'];
$article = $_POST['tp_article_id'];
// check if the article indeed exists
$request = db_query("SELECT rating,voters FROM {$tp_prefix}articles WHERE id=$article", __FILE__, __LINE__);
if(mysql_num_rows($request)>0){
$row=mysql_fetch_row($request);
mysql_free_result($request);

$voters=array(); $ratings=array();
$voters=explode(",",$row[1]);
$ratings=explode(",",$row[0]);
// check if we haven't rated anyway
if(!in_array($ID_MEMBER,$voters)){
if($row[0]!=''){
$new_voters=$row[1].','.$ID_MEMBER;
$new_ratings=$row[0].','.$_POST['tp_article_rating'];
}
else{
$new_voters=$ID_MEMBER;
$new_ratings=$_POST['tp_article_rating'];
}
// update ratings and raters
db_query("UPDATE {$tp_prefix}articles SET rating='$new_ratings' WHERE id=$article", __FILE__, __LINE__);
db_query("UPDATE {$tp_prefix}articles SET voters='$new_voters' WHERE id=$article", __FILE__, __LINE__);
}
// go back to the article
redirectexit('page='.$article);
}
}
elseif($tpsub=='help'){
$context['current_action']='help';
require_once( $sourcedir .'/TPhelp.php');
TPhelp_init();
}
// edit your own articles?
elseif(substr($tpsub,0,11)=='editarticle'){
$what=substr($tpsub,11);
if(!is_numeric($what))
fatal_error($txt['tp-notanarticle']);
  // get one article
$context['TPortal']['subaction']='editarticle';
  $context['TPortal']['editarticle']=array();
  $request = db_query("SELECT * FROM {$tp_prefix}articles WHERE id=$what LIMIT 1", __FILE__, __LINE__);
  if(mysql_num_rows($request)){
$row = mysql_fetch_assoc($request);
// check permission
if(!allowedTo('tp_articles') && $ID_MEMBER!=$row['authorID'])
fatal_error($txt['tp-articlenotallowed']);

$context['TPortal']['editarticle'] = array(
  'id' => $row['id'],
'date' => array(
'timestamp' => $row['date'],
'day' => date("j",$row['date']),
'month' => date("m",$row['date']),
'year' => date("Y",$row['date']),
'hour' => date("G",$row['date']),
'minute' => date("i",$row['date']),
),
'body' => $row['useintro']=='-1' ? stripslashes($row['body']) : normalizeNewline($row['body']),
'intro' => $row['intro'],
'useintro' => $row['useintro'],
'category' => $row['category'],
'frontpage' => $row['frontpage'],
'subject' => $row['subject'],
'authorID' => $row['authorID'],
'author' => $row['author'],
'frame' => !empty($row['frame']) ? $row['frame'] : 'theme',
'approved' => $row['approved'],
'off' => $row['off'],
'options' => $row['options'],
);
mysql_free_result($request);

}
else
fatal_error($txt['tp-notanarticlefound']);
loadlanguage('TPortalAdmin');
loadtemplate('TPmodules');
}
// edit a block?
elseif(substr($tpsub,0,9)=='editblock'){
$what=substr($tpsub,9);
if(!is_numeric($what))
fatal_error($txt['tp-notablock']);
  // get one block
$context['TPortal']['subaction']='editblock';
  $context['TPortal']['blockedit']=array();
  $request = db_query("SELECT * FROM {$tp_prefix}blocks WHERE id=$what LIMIT 1", __FILE__, __LINE__);
  if(mysql_num_rows($request)){
$row = mysql_fetch_assoc($request);

// check permission
if(allowedTo('tp_blocks') || get_perm($row['editgroups']))
$ok=true;
else
fatal_error($txt['tp-blocknotallowed']);

$context['TPortal']['editblock'] = array(
);
$context['TPortal']['blockedit']['id']=$row['id'];
$context['TPortal']['blockedit']['title']=$row['title'];
$context['TPortal']['blockedit']['body']=$row['body'];
$context['TPortal']['blockedit']['frame']=$row['frame'];
$context['TPortal']['blockedit']['type']=$row['type'];
$context['TPortal']['blockedit']['var1']=$row['var1'];
$context['TPortal']['blockedit']['var2']=$row['var2'];
$context['TPortal']['blockedit']['visible']=$row['visible'];
$context['TPortal']['blockedit']['editgroups']=$row['editgroups'];
mysql_free_result($request);

}
else
fatal_error($txt['tp-notablock']);

loadlanguage('TPortalAdmin');
loadtemplate('TPmodules');
}
// save a block?
elseif(substr($tpsub,0,9)=='saveblock'){
$whatID=substr($tpsub,9);
if(!is_numeric($whatID))
fatal_error($txt['tp-notablock']);
  $request = db_query("SELECT editgroups FROM {$tp_prefix}blocks WHERE id=$whatID LIMIT 1", __FILE__, __LINE__);
  if(mysql_num_rows($request)){
$row = mysql_fetch_assoc($request);

// check permission
if(allowedTo('tp_blocks') || get_perm($row['editgroups']))
$ok=true;
else
fatal_error($txt['tp-blocknotallowed']);

mysql_free_result($request);
// loop through the values and save them
foreach ($_POST as $what => $value) {
  if(substr($what,0,10)=='blocktitle'){
  // make sure special charachters can't be done
 $value=strip_tags($value);
  $value = preg_replace('~&#\d+$~', '', $value);
$val=substr($what,10);
  db_query("UPDATE {$tp_prefix}blocks SET title='$value' WHERE id=$val", __FILE__, __LINE__);
  }
  elseif(substr($what,0,9)=='blockbody'){
  $val=substr($what,9);
  db_query("UPDATE {$tp_prefix}blocks SET body='$value' WHERE id=$val", __FILE__, __LINE__);
  }
  elseif(substr($what,0,10)=='blockframe'){
$val=substr($what,10);
  db_query("UPDATE {$tp_prefix}blocks SET frame='$value' WHERE id=$val", __FILE__, __LINE__);
  }
 elseif(substr($what,0,12)=='blockvisible'){
$val=substr($what,12);
  db_query("UPDATE {$tp_prefix}blocks SET visible='$value' WHERE id=$val", __FILE__, __LINE__);
  }
 elseif(substr($what,0,9)=='blockvar1'){
$val=substr($what,9);
  db_query("UPDATE {$tp_prefix}blocks SET var1='$value' WHERE id=$val", __FILE__, __LINE__);
  }
 elseif(substr($what,0,9)=='blockvar2'){
$val=substr($what,9);
  db_query("UPDATE {$tp_prefix}blocks SET var2='$value' WHERE id=$val", __FILE__, __LINE__);
  }
}
redirectexit('action=tpmod;sa=editblock'.$whatID);
 }
 else
fatal_error($txt['tp-notablock']);
}
// save an article
elseif($tpsub=='savearticle'){
if(isset($_REQUEST['send'])){
foreach ($_POST as $what => $value) {
  if(substr($what,0,16)=='tp_article_title'){
$val=substr($what,16);
if(is_numeric($val) && $val>0)
db_query("UPDATE {$tp_prefix}articles SET subject='$value' WHERE id=$val", __FILE__, __LINE__);
  }
  elseif(substr($what,0,15)=='tp_article_body'){
  $val=substr($what,15);
if(is_numeric($val) && $val>0)
  db_query("UPDATE {$tp_prefix}articles SET body='$value' WHERE id=$val", __FILE__, __LINE__);
  }
  elseif(substr($what,0,19)=='tp_article_useintro'){
$val=substr($what,19);
if(is_numeric($val) && $val>0)
  db_query("UPDATE {$tp_prefix}articles SET useintro='$value' WHERE id=$val", __FILE__, __LINE__);
  }
  elseif(substr($what,0,16)=='tp_article_intro'){
  $val=substr($what,16);
  db_query("UPDATE {$tp_prefix}articles SET intro='$value' WHERE id=$val", __FILE__, __LINE__);
  }
  elseif($what=='tp_wysiwyg'){
$result = db_query("SELECT id FROM {$tp_prefix}data WHERE type=2 AND ID_MEMBER=$ID_MEMBER", __FILE__, __LINE__);
if(mysql_num_rows($result)>0){
$row=mysql_fetch_assoc($result);
$wysid=$row['id'];
mysql_free_result($result);
}
if(isset($wysid))
db_query("UPDATE {$tp_prefix}data SET value=$value WHERE id=$wysid", __FILE__, __LINE__);
else
db_query("INSERT INTO {$tp_prefix}data (type,ID_MEMBER,value,item) VALUES(2, $ID_MEMBER, $value, 0)", __FILE__, __LINE__);
  }
}
redirectexit('action=tpmod;sa=editarticle'.$val);
}
}
else{
// a shout
if(isset($_POST['tp-shout-url'])){
if(isset($_POST['tp-shout'])){

// Check the session id.
checkSession('post');

 $shout=strip_tags(substr($_POST['tp-shout'],0,300),'<b><u><i>');

  $shout_name=strip_tags($_POST['tp-shout-name']);
 $memID=-1;
  if($context['user']['is_logged']){

  $shout_name = '<a href="'.$scripturl.'?action=profile;u='.$context['user']['id'].'"';
$memID=$context['user']['id'];
if(!empty($context['TPortal']['usercolor']))
$shout_name .=' style="color: '. $context['TPortal']['usercolor'] . '"';

$shout_name .= '>'.$context['user']['name'].'</a>';
}
  $shout_time=time();
 // register the IP and userID, if any
$ip=$user_info['ip'];
if($shout!='')
db_query("INSERT INTO {$tp_prefix}shoutbox (value1,value2,value3,type,value4, value5) VALUES('$shout','$shout_time','$shout_name','shoutbox','$ip',$memID)", __FILE__, __LINE__);
}
  redirectexit($_POST['tp-shout-url']);
}
else
  loadtemplate('TPmodules');
 }
}

function
dl_recentitems($number='8', $sort='date',$type='array')
{
global $context, $scripturl, $settings, $txt, $db_prefix;

// collect all categories to search in

$mycats=array();
dl_getcats();
foreach($context['TPortal']['dl_allowed_cats'] as $ca)
$mycats[]=$ca['id'];

// empty?
if(sizeof($mycats)>0){

$tp_prefix=$settings['tp_prefix'];
$context['TPortal']['dlrecenttp'] = array();
// decide what to sort from
if($sort=='date')
$sortstring='ORDER BY dlm.created DESC';
elseif($sort=='views')
$sortstring='ORDER BY dlm.views DESC';
elseif($sort=='downloads')
$sortstring='ORDER BY dlm.downloads DESC';
else
$sortstring='ORDER BY dlm.created DESC';

$request = db_query("SELECT dlm.id, dlm.description, dlm.name, dlm.category, dlm.file, dlm.downloads, dlm.views, dlm.authorID, dlm.icon, dlm.created, dlm.screenshot, dlm.filesize,
dlcat.name AS catname, mem.realName
FROM (
{$tp_prefix}dlmanager AS dlm, {$db_prefix}members AS mem)
LEFT JOIN
{$tp_prefix}dlmanager AS dlcat ON dlcat.id=dlm.category
WHERE dlm.type = 'dlitem'
AND dlm.category IN ("
. implode(',' , $mycats) . ")
AND dlm.authorID=mem.ID_MEMBER
"
. $sortstring . " LIMIT $number ", __FILE__, __LINE__);

if(mysql_num_rows($request)>0)
{
while ($row = mysql_fetch_assoc($request))
{
$fs='';
if($context['TPortal']['dl_fileprefix']=='K')
$fs=ceil($row['filesize']/1000).' Kb';
elseif($context['TPortal']['dl_fileprefix']=='M')
$fs=(ceil($row['filesize']/1000)/1000).' Mb';
elseif($context['TPortal']['dl_fileprefix']=='G')
$fs=(ceil($row['filesize']/1000000)/1000).' Gb';

$context['TPortal']['dlrecenttp'][] = array(
'id' => $row['id'],
'body' => $row['description'],
'name' => $row['name'],
'category' => $row['category'],
'file' => $row['file'],
'href' => $scripturl.'?action=tpmod;dl=item'.$row['id'],
'downloads' => $row['downloads'],
'views' => $row['views'],
'author' => '<a href="'.$scripturl.'?action=profile;u='.$row['authorID'].'">'.$row['realName'].'</a>',
'icon' => $row['icon'],
'date' => timeformat($row['created']),
'screenshot' => !empty($row['screenshot']) ? $row['screenshot'] : '' ,
'catname' => $row['catname'],
'cathref' => $scripturl.'?action=tpmod;dl=cat'.$row['category'],
'filesize' => $fs,
);
}
mysql_free_result($request);
}
if($type=='array')
{
return $context['TPortal']['dlrecenttp'];
}
else{
echo '<table width="100%" cellpadding="2" cellspacing="0">';
foreach($context['TPortal']['dlrecenttp'] as $dl)
{
echo '<tr>
<td valign="top" class="smalltext"><a href="'
.$dl['href'].'">'.$dl['name'].'</a></td>
<td valign="top" class="smalltext" align="right">'
;
if($sort=='date')
echo $dl['downloads'];
elseif($sort=='views')
echo $dl['views'];
elseif($sort=='downloads')
echo $dl['downloads'];

echo ' </td></tr>';
}
echo '</table>';
}
}
}

function
dl_getcats()
{
global $context, $settings, $db_prefix, $txt;

if(isset($settings['tp_prefix']))
$tp_prefix=$settings['tp_prefix'];
else{
$tp_prefix = $db_prefix.'tp_';
$settings['tp_prefix'] = $tp_prefix;
}

$context['TPortal']['dl_allowed_cats'] = array();
$request = db_query("SELECT id, parent, name, access FROM {$tp_prefix}dlmanager WHERE type = 'dlcat'", __FILE__, __LINE__);
if(mysql_num_rows($request)>0){
while ($row = mysql_fetch_assoc($request))
{
$show = get_perm($row['access']);
if($show)
$context['TPortal']['dl_allowed_cats'][$row['id']] = array(
'id' => $row['id'],
'name' => $row['name'],
'parent' => $row['parent'],
);
}
mysql_free_result($request);
}

}

function
art_recentitems($max='5' , $type='date' ){

global $context, $settings, $db_prefix, $txt, $settings;

$tp_prefix=$settings['tp_prefix'];

$data=array();

if($type=='date')
$request = db_query("SELECT id, date, subject, views, rating, comments FROM {$tp_prefix}articles WHERE 1 ORDER BY date DESC LIMIT $max", __FILE__, __LINE__);
elseif($type=='views')
$request = db_query("SELECT id, date, subject, views, rating, comments FROM {$tp_prefix}articles WHERE 1 ORDER BY views DESC LIMIT $max", __FILE__, __LINE__);
elseif($type=='comments')
$request = db_query("SELECT id, date, subject, views, rating, comments FROM {$tp_prefix}articles WHERE 1 ORDER BY comments DESC LIMIT $max", __FILE__, __LINE__);

if(mysql_num_rows($request)>0){
while ($row = mysql_fetch_assoc($request))
{
$rat=explode(",",$row['rating']);
$rating_votes=count($rat);
if($row['rating']=='')
$rating_votes=0;

$total=0;
foreach($rat as $mm => $mval)
{
$total=$total+$mval;
}
if($rating_votes>0 && $total>0)
$rating_average=floor($total/$rating_votes);
else
$rating_average=0;

$data[] = array(
'id' => $row['id'],
'subject' => $row['subject'],
'views' => $row['views'],
'date' => timeformat($row['date']),
'rating' => $rating_average,
'rating_votes' => $rating_votes,
'comments' => $row['comments'],
);
}
mysql_free_result($request);
}
return $data;
}
// profile summary
function tp_profile_summary($memID)
{
global $txt, $user_profile, $db_prefix, $context, $db_prefix , $settings, $scripturl;

$context['page_title'] = $txt['tpsummary'];
$tp_prefix=$settings['tp_prefix'];
$max_art=0;
// get all articles written by member
$request = db_query("SELECT COUNT(*) FROM {$tp_prefix}articles
WHERE authorID=
$memID", __FILE__, __LINE__);
$result=mysql_fetch_row($request);
$max_art=$result[0];
mysql_free_result($request);

$max_upload=0;
if($context['TPortal']['show_download']){
// get all uploads
$request = db_query("SELECT COUNT(*) FROM {$tp_prefix}dlmanager
WHERE authorID=
$memID AND type='dlitem'", __FILE__, __LINE__);
$result=mysql_fetch_row($request);
$max_upload=$result[0];
mysql_free_result($request);
}
$max_shout=0;
// get all shouts
$request = db_query("SELECT COUNT(*) FROM {$tp_prefix}shoutbox
WHERE value5=
$memID AND type='shoutbox'", __FILE__, __LINE__);
$result=mysql_fetch_row($request);
$max_shout=$result[0];
mysql_free_result($request);

$context['TPortal']['tpsummary']=array(
'articles' => $max_art,
'uploads' => $max_upload,
'shouts' => $max_shout,
);

}
// articles and comments made by the member
function tp_profile_articles($memID)
{
global $txt, $user_profile, $db_prefix, $context, $db_prefix , $settings, $scripturl;

$context['page_title'] = $txt['articlesprofile'];
$tp_prefix=$settings['tp_prefix'];

if(isset($context['TPortal']['mystart']))
$start=$context['TPortal']['mystart'];
else
$start=0;

$context['TPortal']['memID']=$memID;

if($context['TPortal']['tpsort']!='')
$sorting= $context['TPortal']['tpsort'];
else
$sorting= 'date';

$max=0;
// get all articles written by member
$request = db_query("SELECT COUNT(*) FROM {$tp_prefix}articles
WHERE authorID=
$memID", __FILE__, __LINE__);
$result=mysql_fetch_row($request);
$max=$result[0];
mysql_free_result($request);

// get all not approved articles
$request = db_query("SELECT COUNT(*) FROM {$tp_prefix}articles
WHERE authorID=
$memID AND approved=0", __FILE__, __LINE__);
$result=mysql_fetch_row($request);
$max_approve=$result[0];
mysql_free_result($request);

// get all articles currently being off
$request = db_query("SELECT COUNT(*) FROM {$tp_prefix}articles
WHERE authorID=
$memID AND off=1", __FILE__, __LINE__);
$result=mysql_fetch_row($request);
$max_off=$result[0];
mysql_free_result($request);

$context['TPortal']['all_articles']=$max;
$context['TPortal']['approved_articles']=$max_approve;
$context['TPortal']['off_articles']=$max_off;

if(!in_array($sorting, array('date','subject','views','category','comments')))
$sorting='date';

$request = db_query("SELECT art.id, art.date, art.subject, art.approved, art.off, art.comments, art.views, art.rating, art.voters, art.authorID, art.category
FROM
{$tp_prefix}articles AS art
WHERE art.authorID=
$memID
ORDER BY art."
. $sorting . " DESC LIMIT $start,10", __FILE__, __LINE__);
if(mysql_num_rows($request)>0){
while($row=mysql_fetch_assoc($request)){

$rat=array();
$rating_votes=0;
$rat=explode(",",$row['rating']);
$rating_votes=count($rat);
if($row['rating']=='')
$rating_votes=0;

$total=0;
foreach($rat as $mm => $mval)
$total=$total+$mval;

if($rating_votes>0 && $total>0)
$rating_average=floor($total/$rating_votes);
else
$rating_average=0;

$context['TPortal']['profile_articles'][] = array(
'id' => $row['id'],
'subject' => $row['subject'],
'date' => timeformat($row['date']),
'timestamp' => tp_forum_time(true,$row['date']),
'href' => '' . $scripturl . '?page='.$row['id'],
'comments' => $row['comments'],
'views' => $row['views'],
'rating_votes' => $rating_votes,
'rating_average' => $rating_average,
'approved' => $row['approved'],
'off' => $row['off'],
'catID' => $row['category'],
'category' => '<a href="'.$scripturl.'?mycat='.$row['category'].'">' . (isset($context['TPortal']['catnames'][$row['category']]) ? $context['TPortal']['catnames'][$row['category']] : '') .'</a>',
'editlink' => allowedTo('tp_articles') ? $scripturl.'?action=tpadmin;sa=editarticle'.$row['id'] : $scripturl.'?action=tpmod;sa=editarticle'.$row['id'],
);
}
mysql_free_result($request);
}
// construct pageindexes
if($max>0)
$context['TPortal']['pageindex']=TPageIndex($scripturl.'?action=profile;sa=tparticles;u='.$memID.';tpsort='.$sorting, $start, $max, '10');
else
$context['TPortal']['pageindex']='';

// setup subaction
$context['TPortal']['profile_action'] = '';
if(isset($_GET['settings']))
$context['TPortal']['profile_action'] = 'settings';

// setup tabs
$context['TPortal']['tabs'] = array();
$context['TPortal']['tabs'][]=array(
'name' => $txt['articlesprofile'],
'link' => $scripturl.'?action=profile;u='.$memID.';sa=tparticles',
'chosen' => $context['TPortal']['profile_action']=='' ? true : false);
$context['TPortal']['tabs'][]=array(
'name' => $txt['tp-dlsettings'],
'link' => $scripturl.'?action=profile;u='.$memID.';sa=tparticles;settings',
'chosen' => $context['TPortal']['profile_action']=='settings' ? true : false);

// setup values for personal settings - for now only editor choice
// type = 1 -
// type = 2 - editor choice

$result = db_query("SELECT id, value FROM {$tp_prefix}data WHERE type=2 AND ID_MEMBER=$memID LIMIT 1", __FILE__, __LINE__);
if(mysql_num_rows($result)>0){
$row=mysql_fetch_assoc($result);
$context['TPortal']['selected_member_choice'] = $row['value'];
$context['TPortal']['selected_member_choice_id'] = $row['id'];
mysql_free_result($result);
}
else{
$context['TPortal']['selected_member_choice'] = $context['TPortal']['use_wysiwyg'];
$context['TPortal']['selected_member_choice_id'] = 0;
}
$context['TPortal']['selected_member'] = $memID;
loadlanguage('TPortalAdmin');
}

function
tp_profile_download($memID)
{
global $txt, $user_profile, $db_prefix, $context, $db_prefix , $settings, $scripturl;

$context['page_title'] = $txt['downloadprofile'] ;

// is dl manager on?
if($context['TPortal']['show_download']==0)
fatal_error($txt['tp-dlmanageroff']);

$tp_prefix=$settings['tp_prefix'];

if(isset($context['TPortal']['mystart']))
$start=$context['TPortal']['mystart'];
else
$start=0;

$context['TPortal']['memID']=$memID;

if($context['TPortal']['tpsort']!='')
$sorting= $context['TPortal']['tpsort'];
else
$sorting= 'date';

$max=0;
// get all uploads
$request = db_query("SELECT COUNT(*) FROM {$tp_prefix}dlmanager
WHERE authorID=
$memID AND type='dlitem'", __FILE__, __LINE__);
$result=mysql_fetch_row($request);
$max=$result[0];
mysql_free_result($request);

// get all not approved uploads
$request = db_query("SELECT COUNT(*) FROM {$tp_prefix}dlmanager
WHERE authorID=
$memID AND type='dlitem' AND category<0", __FILE__, __LINE__);
$result=mysql_fetch_row($request);
$max_approve=$result[0];
mysql_free_result($request);

$context['TPortal']['all_downloads']=$max;
$context['TPortal']['approved_downloads']=$max_approve;
$context['TPortal']['profile_uploads']=array();
if(!in_array($sorting, array('name','created','views','downloads','category')))
$sorting='created';

$request = db_query("SELECT id, name, category, downloads, views, created, filesize, rating, voters
FROM
{$tp_prefix}dlmanager
WHERE authorID=
$memID
AND type='dlitem'
ORDER BY "
. $sorting . " DESC LIMIT $start,10", __FILE__, __LINE__);
if(mysql_num_rows($request)>0){
while($row=mysql_fetch_assoc($request)){

$rat=array();
$rating_votes=0;
$rat=explode(",",$row['rating']);
$rating_votes=count($rat);
if($row['rating']=='')
$rating_votes=0;

$total=0;
foreach($rat as $mm => $mval)
$total=$total+$mval;

if($rating_votes>0 && $total>0)
$rating_average=floor($total/$rating_votes);
else
$rating_average=0;

$context['TPortal']['profile_uploads'][] = array(
'id' => $row['id'],
'name' => $row['name'],
'created' => timeformat($row['created']),
'category' => $row['category'],
'href' => $scripturl . '?action=tpmod;dl=item'.$row['id'],
'views' => $row['views'],
'rating_votes' => $rating_votes,
'rating_average' => $rating_average,
'approved' => $row['category']>0 ? '1' : '0',
'downloads' => $row['downloads'],
'catID' => abs($row['category']),
'category' => $row['category'],
'editlink' => allowedTo('tp_dlmanager') ? $scripturl.'?action=tpmod;dl=adminitem'.$row['id'] : '',
);
}
mysql_free_result($request);
}
// construct pageindexes
if($max>0)
$context['TPortal']['pageindex']=TPageIndex($scripturl.'?action=profile;sa=tpdownload;u='.$memID.';tpsort='.$sorting, $start, $max, '10');
else
$context['TPortal']['pageindex']='';
}

function
tp_profile_shoutbox($memID)
{
global $txt, $user_profile, $db_prefix, $context, $db_prefix , $settings, $scripturl;

$context['page_title'] = $txt['shoutboxprofile'] ;

$tp_prefix=$settings['tp_prefix'];

if(isset($context['TPortal']['mystart']))
$start=$context['TPortal']['mystart'];
else
$start=0;

$context['TPortal']['memID']=$memID;

$sorting= 'value2';

$max=0;
// get all shouts
$request = db_query("SELECT COUNT(*) FROM {$tp_prefix}shoutbox
WHERE value5=
$memID AND type='shoutbox'", __FILE__, __LINE__);
$result=mysql_fetch_row($request);
$max=$result[0];
mysql_free_result($request);

$context['TPortal']['all_shouts']=$max;
$context['TPortal']['profile_shouts']=array();

$request = db_query("SELECT *
FROM
{$tp_prefix}shoutbox
WHERE value5=
$memID
AND type='shoutbox'
ORDER BY "
. $sorting . " DESC LIMIT $start,10", __FILE__, __LINE__);
if(mysql_num_rows($request)>0){
while($row=mysql_fetch_assoc($request)){

$context['TPortal']['profile_shouts'][] = array(
'id' => $row['id'],
'shout' => doUBBC(censorText($row['value1'])),
'created' => timeformat($row['value2']),
'ip' => $row['value4'],
'editlink' => allowedTo('tp_blocks') ? $scripturl.'?action=tpadmin;sa=shoutbox;u='.$memID : '',
);
}
mysql_free_result($request);
}
// construct pageindexes
if($max>0)
$context['TPortal']['pageindex']=TPageIndex($scripturl.'?action=profile;sa=tpshoutbox;u='.$memID.';tpsort='.$sorting, $start, $max, '10', true);
else
$context['TPortal']['pageindex']='';
}
function
tp_profile_gallery($memID)
{
global $txt, $user_profile, $db_prefix, $context, $db_prefix;

$context['page_title'] = $txt['galleryprofile'] ;
}
function
tp_profile_links($memID)
{
global $txt, $user_profile, $db_prefix, $context, $db_prefix;

$context['page_title'] = $txt['linksprofile'] ;
}

?>



We cannot use the Shoutbox (I turned it off for the meantime)  :(
Forum

tick



IchBin

Theres no need to post the whole file code. You could save us time if you just posted a few lines including the line number. However, I don't thing your problem lies in the code. I think its in your database. Run a repair on the shoutbox table and see if that helps. If not, run the manual_tp_install.php file and see if that will fix it.

magz

I wasnt the one who installed the TP and I do not know how to run a repair on the shotbox or manual_tp_install.php file . I would appreciate if you'll post a link for tutorial...

G6Cad

Download the file manual_tp_install.php (Database Only) from the downloadsection
Upload the file manually through FTP and point your browser to the file.
www.yoursitehere.com/manual_tp_install.php and let it update the tables.

If that doesent work you need to have access to your database through Cpanel or PhPMyadmin

magz


This website is proudly hosted on Crocweb Cloud Website Hosting.