1
BeautyBrains
Top Posters Block not updating

When users post on the site the top posters block does not update; the count is incorrect. I have cleared the cache and templates_c folders, as well my browser's cache, cleared the sessions and updated the system module from the admin. Nothing worked. Below is the template text. How do I fix this?

Template - system_block_topusers.html


<{foreach item=user from=$block.users}>
" valign="middle">




<{/foreach}>
<{$user.rank}>
<{if $user.avatar != ""}>


<{/if}>
<{$user.name}>
<{$user.posts}>
A man without history is like a tree without roots. Marcus Garvey (1917) http://CaribbeanAncestry.com http://JamaicaGenealogy.com http://thephilosophizers.com Teach what you know and learn what you don't; stay open to all. 24/7

2
ghia
Re: Top Posters Block not updating
  • 2009/1/22 21:18

  • ghia

  • Community Support Member

  • Posts: 4953

  • Since: 2008/7/3 1


And for which module (and version) is this block?

3
BeautyBrains
Re: Top Posters Block not updating

I'm using XOOPS v2.2.6 that comes with my control panel. Top Posters is part of its 'System' module (xoops/modules/system/templates/blocks
A man without history is like a tree without roots. Marcus Garvey (1917) http://CaribbeanAncestry.com http://JamaicaGenealogy.com http://thephilosophizers.com Teach what you know and learn what you don't; stay open to all. 24/7

4
ghia
Re: Top Posters Block not updating
  • 2009/1/23 2:26

  • ghia

  • Community Support Member

  • Posts: 4953

  • Since: 2008/7/3 1


It works!

How did you verify it is not working?
Why you conclude the count is wrong?
What are your settings for the block?

5
BeautyBrains
Re: Top Posters Block not updating

When you click on some users name, their profile page does not show "posts" and so it is not being counted, and I know they have created posts.
A man without history is like a tree without roots. Marcus Garvey (1917) http://CaribbeanAncestry.com http://JamaicaGenealogy.com http://thephilosophizers.com Teach what you know and learn what you don't; stay open to all. 24/7

6
ghia
Re: Top Posters Block not updating
  • 2009/1/24 9:07

  • ghia

  • Community Support Member

  • Posts: 4953

  • Since: 2008/7/3 1


Some modules have a category preference setting to let the count count or not.
Postings from the user without login (as anonymous, but sometimes with their name) are also not counted.
Which module is not counted?

7
BeautyBrains
Re: Top Posters Block not updating

Not being counted that I can see - xgallery, AMS, XFguestbook, my album-p and links
A man without history is like a tree without roots. Marcus Garvey (1917) http://CaribbeanAncestry.com http://JamaicaGenealogy.com http://thephilosophizers.com Teach what you know and learn what you don't; stay open to all. 24/7

8
ghia
Re: Top Posters Block not updating
  • 2009/1/26 9:36

  • ghia

  • Community Support Member

  • Posts: 4953

  • Since: 2008/7/3 1


It is possible that these modules do not have code implemented to update the user count. Of AMS, I was surprised because it is a News clone and News do update the count. It seems this feature was added to news after the fork.
The code is located in submit.php (of News)
// Increment author's posts count (only if it's a new article)
        // First case, it's not an anonyous, the story is approved and it's a new story
        
if($uid && $approve && empty($storyid)) {
            
$tmpuser=new xoopsUser($uid);
            
$member_handler =& xoops_gethandler('member');
            
$member_handler->updateUserByField($tmpuser'posts'$tmpuser->getVar('posts') + 1);
        }

        
// Second case, it's not an anonymous, the story is NOT approved and it's NOT a new story (typical when someone is approving a submited story)
        
if(is_object($xoopsUser) && $approve && !empty($storyid)) {
            
$storytemp = new NewsStory$storyid );
            if(!
$storytemp->published() && $storytemp->uid()>0) {    // the article has been submited but not approved
                
$tmpuser=new xoopsUser($storytemp->uid());
                
$member_handler =& xoops_gethandler('member');
                
$member_handler->updateUserByField($tmpuser'posts'$tmpuser->getVar('posts') + 1);
            }
            unset(
$storytemp);
        }
As you can see above the posts count is updated for the user during the post of a new article, if he has approve rights or on his behalve when it is approved by the approver.
I assume you could implement it easy in AMS and with a little effort to the other modules.

9
BeautyBrains
Re: Top Posters Block not updating

I have the above code in news but not in AMS, mylinks or xfguestbook. I have no clue where to implement the code, please direct me as to where I should copy / paste the above code in their submit.php.

My AMS submit.php is as follows
// $Id: submit.php,v 1.13 2004/05/29 15:10:18 mithyt2 Exp $
// ------------------------------------------------------------------------ //
// XOOPS - PHP Content Management System //
// Copyright (c) 2000 XOOPS.org //
// <https://xoops.org/> //
// ------------------------------------------------------------------------ //
// This program is free software; you can redistribute it and/or modify //
// it under the terms of the GNU General Public License as published by //
// the Free Software Foundation; either version 2 of the License, or //
// (at your option) any later version. //
// //
// You may not change or alter any portion of this comment or credits //
// of supporting developers from this source code or any supporting //
// source code which is considered copyrighted (c) material of the //
// original comment or credit authors. //
// //
// This program is distributed in the hope that it will be useful, //
// but WITHOUT ANY WARRANTY; without even the implied warranty of //
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the //
// GNU General Public License for more details. //
// //
// You should have received a copy of the GNU General Public License //
// along with this program; if not, write to the Free Software //
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA //
// ------------------------------------------------------------------------ //

include_once '../../mainfile.php';
include_once XOOPS_ROOT_PATH.'/modules/'.$xoopsModule->getVar('dirname').'/class/class.newsstory.php';
include_once XOOPS_ROOT_PATH.'/modules/'.$xoopsModule->getVar('dirname').'/class/class.sfiles.php';
include_once XOOPS_ROOT_PATH.'/class/uploader.php';

$xoopsConfig['module_cache'][$xoopsModule->getVar('mid')] = 0;
include_once XOOPS_ROOT_PATH.'/header.php';
if (file_exists(XOOPS_ROOT_PATH.'/modules/'.$xoopsModule->getVar('dirname').'/language/'.$xoopsConfig['language'].'/admin.php')) {
include_once 'language/'.$xoopsConfig['language'].'/admin.php';
}
else {
include_once 'language/english/admin.php';
}

$module_id = $xoopsModule->getVar('mid');
$groups = $xoopsUser ? $xoopsUser->getGroups() : XOOPS_GROUP_ANONYMOUS;

$gperm_handler =& xoops_gethandler('groupperm');
$perm_itemid = isset($_POST['topic_id']) ? intval($_POST['topic_id']) : 0;

//If no access
if (!$gperm_handler->checkRight("ams_submit", $perm_itemid, $groups, $module_id)) {
redirect_header('index.php', 3, _NOPERM);
}

$op = 'form';
$myts =& MyTextSanitizer::getInstance();

//If approve privileges
$approveprivilege = 0;
if ($xoopsUser && $gperm_handler->checkRight("ams_approve", $perm_itemid, $groups, $module_id)) {
$approveprivilege = 1;
}

if (isset($_REQUEST['hometext'] ))
{
$hometext = $myts->stripSlashesGPC($_REQUEST['hometext']);
}

if (isset($_REQUEST['bodytext'] ))
{
$bodytext = $myts->stripSlashesGPC($_REQUEST['bodytext']);
}

if (isset($_REQUEST['storyid'] ))
{
$storyid = intval($_REQUEST['storyid']);
}

if ( isset($_REQUEST['preview'] ))
{
$op = 'preview';
}elseif ( isset($_REQUEST['post']))
{
$op = 'post';
}elseif ( (isset($_REQUEST['op']) ) && (isset($_REQUEST['storyid'])))
{
if ($approveprivilege && (($_REQUEST['op'] == 'edit') ))
{
$op = 'edit';
}
elseif ($approveprivilege && (($_REQUEST['op'] == 'delete') ))
{
$op = 'delete';
}elseif ($approveprivilege && (($_REQUEST['op'] == _AMS_NW_OVERRIDE) ))
{
$op = _AMS_NW_OVERRIDE;
}elseif ($approveprivilege && (($_REQUEST['op'] == _AMS_NW_FINDVERSION) ))
{
$op = _AMS_NW_FINDVERSION;
}elseif ($approveprivilege && (($_REQUEST['op'] == 'override_ok') ))
{
$op = 'override_ok';
}else
{
redirect_header("index.php", 0, _NOPERM);
exit();
}
if (isset($_REQUEST['storyid']))
{
$storyid = intval($_REQUEST['storyid']);
}
}

switch ($op) {
case "delete":

if ( !empty( $_POST['ok'] ) )
{
if ( empty( $_POST['storyid'] ) )
{
redirect_header( 'index.php?op=newarticle', 2, _AMS_AM_EMPTYNODELETE );
exit();
}
$storyid = intval($_POST['storyid']);
$story = new AmsStory( $storyid );
$story -> delete();
$sfiles = new sFiles();
$filesarr=Array();
$filesarr=$sfiles->getAllbyStory($storyid);
if(count($filesarr)>0)
{
foreach ($filesarr as $onefile)
{
$onefile->delete();
}
}
xoops_comment_delete( $xoopsModule -> getVar( 'mid' ), $storyid );
xoops_notification_deletebyitem( $xoopsModule -> getVar( 'mid' ), 'story', $storyid );
redirect_header( 'index.php?op=newarticle', 1, _AMS_AM_DBUPDATED );
exit();
}
else
{

//include_once '../../include/cp_header.php';
//xoops_cp_header();
echo "

" . _AMS_AM_CONFIG . "

";
xoops_confirm( array( 'op' => 'delete', 'storyid' => $_REQUEST['storyid'], 'ok' => 1 ), 'submit.php', _AMS_AM_RUSUREDEL );
}
break;

case 'edit':
if (!$approveprivilege) {
redirect_header('index.php', 0, _NOPERM);
break;
}
$storyid = $_REQUEST['storyid'];
$story = new AmsStory( $storyid );

echo $story->getPath(true)." > "._EDIT." ".$story->title();

echo"
";
echo "

" . _AMS_AM_EDITARTICLE . "

";

if ($story->published() > 0) {
$story->setApproved(1);
}
else {
$story->setApproved(0);
}
$edit = true;
$type = $story -> type();
$story->uname();
$author = $story->uname;
include "include/storyform.inc.php";
echo"
";
break;

case "preview":
$xt = new AmsTopic($xoopsDB->prefix("ams_topics"), $_POST['topic_id']);
//$hometext = $_POST['hometext'];
//$bodytext = $_POST['bodytext'];

if ( isset( $_POST['storyid'] ) ) {
$story = new AmsStory( $storyid );
$edit = true;
}
else {
$story = new AmsStory();
$story->setPublished(0);
$story->setExpired(0);
$edit = false;
}
$story->setTopicId($_POST['topic_id']);
$story->setTitle($_POST['title']);
$story->setHometext($hometext);
$story->setBodytext($bodytext);
$story->banner = isset($_POST['banner']) ? $_POST['banner'] : 0;
if ($approveprivilege) {
$story->setTopicdisplay($_POST['topicdisplay']);
$story->setTopicalign($_POST['topicalign']);
$story->audienceid = $_POST['audience'];
}
else {
$noname = isset($_POST['noname']) ? intval($_POST['noname']) : 0;
}
$notifypub = isset($_POST['notifypub']) ? intval($_POST['notifypub']) : 0;
$story->setNotifyPub($notifypub);

if ( isset( $_POST['nosmiley'] ) && ( $_POST['nosmiley'] == 0 || $_POST['nosmiley'] == 1 ) ) {
$story -> setNosmiley( $_POST['nosmiley'] );
}
else {
$story->setNosmiley(0);
}
if ($approveprivilege) {
$change = isset($_POST['change']) ? $_POST['change'] : 0;
$story->setChange($change);
$nohtml = isset($_POST['nohtml']) ? intval($_POST['nohtml']) : 0;
$story->setNohtml($nohtml);
if (!isset($_POST['approve'])) {
$story->setApproved(0);
}
else {
$story->setApproved($_POST['approve']);
}
} else {
$story->setNohtml = 1;
}
//Display breadcrumbs
if ($edit) {
echo $story->getPath(true)." > "._EDIT." ".$story->title();
}

//Display post preview
$p_title = $story->title("Preview");
$p_hometext = $story->hometext("Preview");
$p_hometext .= "
".$story->bodytext("Preview");
$topversion = ($story->revision == 0 && $story->revisionminor == 0) ? 1 : 0;
$topicalign = isset($story->topicalign) ? 'align="'.$story->topicalign().'"' : "";
$p_hometext = (($xt->topic_imgurl() != '') && $story->topicdisplay()) ? 'topicalign().' alt="" />'.$p_hometext : $p_hometext;

//Added in AMS 2.50 Final. replace deprecated themecenterposts function
if(file_exists(XOOPS_ROOT_PATH."/Frameworks/xoops22/class/xoopsformloader.php"))
{
if(!@include_once XOOPS_ROOT_PATH."/Frameworks/xoops22/class/xoopsformloader.php"){
include_once XOOPS_ROOT_PATH."/class/xoopsformloader.php";
}
}else
{
include_once XOOPS_ROOT_PATH."/class/xoopsformloader.php";
}
$pform = new XoopsThemeForm($p_title, "previewform", XOOPS_URL.'/modules/'.$xoopsModule->getVar('dirname').'/submit.php');
$pform->display();
print "$p_hometext";

$story->uname();
$author = $story->uname;

//Display post edit form
include 'include/storyform.inc.php';
break;

case "post":
//$hometext = $_POST['hometext'];
//$bodytext = $_POST['bodytext'];
$nohtml_db = 1;
if ( is_object($xoopsUser) ) {
$uid = $xoopsUser->getVar('uid');
if ( $approveprivilege ) {
$nohtml_db = empty($_POST['nohtml']) ? 0 : 1;
}
} else {
$uid = 0;
}
if ( empty( $_POST['storyid'] ) ) {
$story = new AmsStory();
$oldapprove = 0;
$story -> setUid( $uid );
}
else {

$story = new AmsStory( $_POST['storyid'] );
$oldapprove = $story->published() > 0 ? 1 : 0;

$change = isset($_POST['change']) ? $_POST['change'] : 0;
//If change = auto
if ($change == 4)
{

if ( ($hometext!= $story->hometext) ||
($bodytext!=$story->bodytext) ||
($_POST['newauthor'] && $approveprivilege))
{
$change=3;
}else
{
$change=0;
}

}
$story->setChange($change);
if ($_POST['newauthor'] && $approveprivilege) {
$story->setUid($uid);
}
}
$story->banner = isset($_POST['banner']) ? $_POST['banner'] : 0;
$story->setTitle($_POST['title']);

$story->setHometext($hometext);
if ($bodytext) {
$story->setBodytext($bodytext);
}
else {
$story->setBodytext(' ');
}
$story->setTopicId($_POST['topic_id']);
$story->setHostname(xoops_getenv('REMOTE_ADDR'));
$story->setNohtml($nohtml_db);
$nosmiley = isset($_POST['nosmiley']) ? intval($_POST['nosmiley']) : 0;
$notifypub = isset($_POST['notifypub']) ? intval($_POST['notifypub']) : 0;
$story->setNosmiley($nosmiley);
$story->setNotifyPub($notifypub);
$story->setType($_POST['type']);
// Set audience id to default
$story->audienceid = intval(1);
if ($approveprivilege) {
$approve = isset($_POST['approve']) ? $_POST['approve'] : 0;
if ( !empty( $_POST['autodate'] )) {
$pubdate = strtotime($_POST['publish_date']['date']) + $_POST['publish_date']['time'];
$offset = $xoopsUser -> timezone() - $xoopsConfig['server_TZ'];
$pubdate = $pubdate - ( $offset * 3600 );
if ($pubdate-time() > 0 && $pubdate-time() < 600) //fix bug article missing for 10 minute after republish
{
$pubdate=$pubdate-601; //set publish date backward 10 minute
}

$story -> setPublished( $pubdate );
}else
{
$story->setPublished(time());
}
if ( !empty( $_POST['autoexpdate'] )) {
$expiry_date = strtotime($_POST['expiry_date']['date']) + $_POST['expiry_date']['time'];
$offset = $xoopsUser -> timezone() - $xoopsConfig['server_TZ'];
$expiry_date = $expiry_date - ( $offset * 3600 );
$story -> setExpired( $expiry_date );
}else
{
$story->setExpired(0);
}

$story->setTopicdisplay($_POST['topicdisplay']);
$story->setTopicalign($_POST['topicalign']);
$story->setIhome($_POST['ihome']);

if(!$approve) {
$story->setPublished(0);
}

if($story->published() >= $story->expired())
{
$story->setExpired(0);
}

$story->audienceid = intval($_POST['audience']);
}
elseif ( $xoopsModuleConfig['autoapprove'] == 1 && !$approveprivilege) {
$approve = 1;
$story->setPublished(time());
$story->setExpired(0);
$story->setTopicalign('R');
}
else {
$story->setPublished(0);
$approve = 0;
$story -> setExpired( 0 );
}
$story->setApproved($approve);
$result = $story->store();

if ($result) {
// Notification
$notification_handler =& xoops_gethandler('notification');
$tags = array();
$tags['STORY_NAME'] = $story->title();
$tags['STORY_URL'] = XOOPS_URL . '/modules/' . $xoopsModule->getVar('dirname') . '/article.php?storyid=' . $story->storyid();
if ( $approve == 1 && $oldapprove == 0 && $story->published <= time()) {
$notification_handler->triggerEvent('global', 0, 'new_story', $tags);
} elseif ($approve != 1) {
$tags['WAITINGSTORIES_URL'] = XOOPS_URL . '/modules/' . $xoopsModule->getVar('dirname') . '/submit.php?op=edit&storyid='.$story->storyid();
$notification_handler->triggerEvent('global', 0, 'story_submit', $tags);

// If notify checkbox is set, add subscription for approve
if ($notifypub) {
include_once XOOPS_ROOT_PATH . '/include/notification_constants.php';
$notification_handler->subscribe('story', $story->storyid(), 'approve', XOOPS_NOTIFICATION_MODE_SENDONCETHENDELETE);
}
}

// Manage upload(s)
if(isset($_POST['delupload']) && count($_POST['delupload'])>0 )
{
foreach ($_POST['delupload'] as $onefile)
{
$sfiles = new sFiles($onefile);
$sfiles->delete();
}
}

if(isset($_POST['xoops_upload_file'])&& isset($_FILES[$_POST['xoops_upload_file'][0]]))
{
$fldname = $_FILES[$_POST['xoops_upload_file'][0]];
$fldname = (get_magic_quotes_gpc()) ? stripslashes($fldname['name']) : $fldname['name'];
if(trim($fldname!=''))
{
$sfiles = new sFiles();
$destname=$sfiles->createUploadName(XOOPS_UPLOAD_PATH,$fldname);
// Actually : Web pictures (png, gif, jpeg), zip, doc, xls, pdf, gtar, tar, txt, tiff, htm, xml, ico,swf flv, mp3, bmp, ra, mov, swc. swf not allow by xoops, not AMS
$permittedtypes=array('text/xml','text/html', 'text/plain','image/tiff', 'image/vnd.microsoft.icon', 'image/gif', 'image/jpeg', 'image/pjpeg', 'image/x-png', 'image/png' ,'application/x-zip-compressed','application/msword', 'application/vnd.ms-excel', 'application/pdf', 'application/x-gtar', 'application/x-gzip', 'application/x-tar','application/zip','application/x-shockwave-flash','video/x-flv','application/x-rar-compressed','image/bmp','audio/mpeg','audio/x-realaudio','video/quicktime');
$uploader = new XoopsMediaUploader( XOOPS_UPLOAD_PATH, $permittedtypes, $xoopsModuleConfig['maxuploadsize']);
$uploader->setTargetFileName($destname);
if ($uploader->fetchMedia($_POST['xoops_upload_file'][0]))
{
if ($uploader->upload())
{
$sfiles->setFileRealName($uploader->getMediaName());
$sfiles->setStoryid($story->storyid());
$sfiles->setMimetype($sfiles->giveMimetype(XOOPS_UPLOAD_PATH.'/'.$uploader->getMediaName()));
$sfiles->setDownloadname($destname);
if(!$sfiles->store())
{
//echo _AMS_AM_UPLOAD_DBERROR_SAVE;
echo $uploader->getErrors(); //Better error message
}
}
else
{
//echo _AMS_AM_UPLOAD_ERROR;
echo $uploader->getErrors(); //Better error message
}
} else {

if (!$_FILES[$fldname]['tmp_name'])
{

echo $uploader->getErrors();
echo "Or file size too big"; //Add additional comment since the original error message not so accurate. TODO : add this into language
}else
{
echo $uploader->getErrors();
}
}
}
}
}
else {
if ($story->versionConflict == true) {
include ('include/versionconflict.inc.php');
break;
}
else {
$message = $story->renderErrors();
}
}
if (!isset($message)) {
$message = _AMS_NW_THANKS;
}
redirect_header("index.php",2, $message);
break;

case _AMS_NW_OVERRIDE:
if (!$approveprivilege || !$xoopsUser) {
redirect_header('index.php', 3, _NOPERM);
}
$change = isset($_POST['change']) ? $_POST['change'] : 0;
$hiddens = array('bodytext' => $bodytext,
'hometext' => $hometext,
'storyid' => $storyid,
'change' => $change,
'op' => 'override_ok');
$story = new AmsStory($storyid);
$story->setChange($change);

$message = "";
$story->calculateVersion();
$message .= _AMS_NW_TRYINGTOSAVE." ".$story->version.".".$story->revision.".".$story->revisionminor."
";
$higher_versions = $story->getVersions(true);
if (count($higher_versions) > 0) {
$message .= sprintf(_AMS_NW_VERSIONSEXIST, count($higher_versions));
$message .= "
";
foreach ($higher_versions as $key => $version) {
$message .= $version['version'].".".$version['revision'].".".$version['revisionminor']."
";
}
}
$message .= _AMS_NW_AREYOUSUREOVERRIDE;
xoops_confirm($hiddens, 'submit.php', $message, _YES);
break;

case 'override_ok':
if (!$approveprivilege || !$xoopsUser) {
redirect_header('index.php', 3, _NOPERM);
}
$story = new AmsStory($_POST['storyid']);
$change = isset($_POST['change']) ? $_POST['change'] : 0;
$story->setChange($change);
$story->setUid($xoopsUser->getVar('uid'));
$story->setHometext($hometext);
$story->setBodytext($bodytext);
$story->calculateVersion();
if ($story->overrideVersion()) {
$message = sprintf(_AMS_NW_VERSIONUPDATED, $story->version.".".$story->revision.".".$story->revisionminor);
}
else {
$message = $story->renderErrors();
}
redirect_header('article.php?storyid='.$story->storyid, 3, $message);
break;


case _AMS_NW_FINDVERSION:
if (!$approveprivilege || !$xoopsUser) {
redirect_header('index.php', 3, _NOPERM);
exit();
}
$story = new AmsStory($_POST['storyid']);
$story->setUid($xoopsUser->getVar('uid'));
$story->setHometext($hometext);
$story->setBodytext($bodytext);

$change = isset($_POST['change']) ? $_POST['change'] : 0;
$story->setChange($change);
if ($story->calculateVersion(true)) {
if ($story->updateVersion()) {
$message = sprintf(_AMS_NW_VERSIONUPDATED, $story->version.".".$story->revision.".".$story->revisionminor);
//redirect_header('article.php?storyid='.$story->storyid(), 3, $message);
//exit();
}
else {
$message = $story->renderErrors();
}
}
else {
$message = $story->renderErrors();
}
redirect_header('article.php?storyid='.$story->storyid(), 3, $message);
break;

case 'form':
default:
$story = new AmsStory();
$story->setTitle('');
$story->setHometext('');
$noname = 0;
$story->setNohtml(0);
$story->setNosmiley(0);
$story->setNotifypub(1);
$story->setTopicId(0);
if ($approveprivilege) {
$story->setTopicdisplay(0);
$story->setTopicalign('R');
$story->setIhome(0);
$story->setBodytext('');
$story->setApproved(1);
$story->set = '';
$expired = 0;
$published = 0;
$audience = 0;
}
$banner = "";
$edit = false;
include 'include/storyform.inc.php';
break;
}
include XOOPS_ROOT_PATH.'/footer.php';
?>


My links submit.php is as follows
/**
* $Id: submit.php v 1.0.4 06 july 2004 Liquid Exp $
* Module: PD-Links
* Version: v1.0
* Release Date: 04. März 2005
* Author: Power-Dreams Team
* Licence: GNU
*/

include 'header.php';
include_once XOOPS_ROOT_PATH . '/class/xoopstree.php';
include_once XOOPS_ROOT_PATH . '/include/xoopscodes.php';
include XOOPS_ROOT_PATH . '/header.php';
include XOOPS_ROOT_PATH . '/class/xoopsformloader.php';

$myts = &MyTextSanitizer::getInstance(); // MyTextSanitizer object
$mytree = new XoopsTree($xoopsDB->prefix('PDlinks_cat'), "cid", "pid");

global $xoopsDB, $myts, $mytree, $xoopsModuleConfig, $xoopsUser;
if (is_object($xoopsUser))
{
$groups = $xoopsUser->getGroups();
if (!array_intersect($xoopsModuleConfig['submitarts'], $groups))
{
redirect_header("index.php", 1, _MD_PDD2_NOTALLOWESTOSUBMIT);
exit();
}
else { $suballow=1;}
}
else
{
if (isset($xoopsModuleConfig['anonpost']) && !$xoopsModuleConfig['anonpost'] == 1)
{
redirect_header("index.php", 1, _MD_PDD2_NOTALLOWESTOSUBMIT);
exit();
}
else { $suballow=1;}
}
if ($suballow==1){
if (isset($_POST['submit']) && !empty($_POST['submit']))
{
$notify = !empty($_POST['notify']) ? 1 : 0;

$lid = (!empty($_POST['lid'])) ? intval($_POST['lid']) : 0 ;
$cid = (!empty($_POST['cid'])) ? intval($_POST['cid']) : 0 ;

if (empty($_FILES['userfile']['name']) && $_POST["url"] && $_POST["url"] != "" && $_POST["url"] != "http://")
{
$url = ($_POST["url"] != "http://") ? $myts->addslashes($_POST["url"]) : '';
$title = $myts->addslashes(trim($_POST["title"]));
}
else
{
global $_FILES;
$url = $link['url'];
$title = $_FILES['userfile']['name'];
$title = rtrim(PDd_strrrchr($title, "."), ".");
$title = (isset($_POST["title_checkbox"]) && $_POST["title_checkbox"] == 1) ? $title : $myts->addslashes(trim($_POST["title"]));
}

$descriptionb = $myts -> addslashes(trim($_POST["descriptionb"]));
$submitter = !empty($xoopsUser) ? $xoopsUser->getVar('uid') : 0;
$forumid = (isset($_POST["forumid"]) && $_POST["forumid"] > 0) ? intval($_POST["forumid"]) : 0;
$offline = (isset($_POST['offline']) && $_POST['offline'] == 1) ? 1 : 0;
$date = time();
$publishdate = 0;
$notifypub = (isset($_POST['notifypub']) && $_POST['notifypub'] == 1) ? 1 : 0;

$ipaddress = $_SERVER['REMOTE_ADDR'];
if ($lid == 0)
{
if ($xoopsModuleConfig['autoapprove'] == 1)
{
$publishdate = time();
$status = 1;
}
$status = ($xoopsModuleConfig['autoapprove'] == 1) ? 1 : 0 ;
$query = "INSERT INTO " . $xoopsDB->prefix("PDlinks_links") . "
(lid, cid, title, url, submitter, status,
date, hits, rating, votes, comments, forumid, published, expired, offline, description, ipaddress, notifypub)";
$query .= " VALUES ('', $cid, '$title', '$url',
'$submitter', '$status', '$date', 0, 0, 0, 0, '$forumid', '$publishdate',
0, '$offline', '$descriptionb', '$ipaddress', '$notifypub')";
$result = $xoopsDB->queryF($query);
$error = _MD_PDD2_INFONOSAVEDB;
$error .= $query;
if (!$result)
{
trigger_error($error, E_USER_ERROR);
}
$newid = $xoopsDB->getInsertId();
$groups = array(1, 2);
PDd_save_Permissions($groups, $newid, 'PDlinkFilePerm');
/*
* Notify of new link (anywhere) and new link in category
*/
$notification_handler = &xoops_gethandler('notification');
$tags = array();
$tags['FILE_NAME'] = $title;
$tags['FILE_URL'] = XOOPS_URL . '/modules/PDlinks/singlefile.php?cid=' . $cid . '&lid=' . $newid;
$sql = "SELECT title FROM " . $xoopsDB->prefix('mylinks_cat') . " WHERE cid=" . $cid;
$result = $xoopsDB->query($sql);
$row = $xoopsDB->fetchArray($result);
$tags['CATEGORY_NAME'] = $row['title'];
$tags['CATEGORY_URL'] = XOOPS_URL . '/modules/PDlinks/viewcat.php?cid=' . $cid;
if ($xoopsModuleConfig['autoapprove'] == 1)
{
$notification_handler->triggerEvent('global', 0, 'new_file', $tags);
$notification_handler->triggerEvent('category', $cid, 'new_file', $tags);
redirect_header('index.php', 2, _MD_PDD2_ISAPPROVED . "");
}
else
{
$tags['WAITINGFILES_URL'] = XOOPS_URL . '/modules/PDlinks/admin/newlinks.php';
$notification_handler->triggerEvent('global', 0, 'file_submit', $tags);
$notification_handler->triggerEvent('category', $cid, 'file_submit', $tags);
if ($notify)
{
include_once XOOPS_ROOT_PATH . '/include/notification_constants.php';
$notification_handler->subscribe('file', $newid, 'approve', XOOPS_NOTIFICATION_MODE_SENDONCETHENDELETE);
}
redirect_header('index.php', 2, _MD_PDD2_THANKSFORINFO);
}
exit();
}
else
{
$updated = (isset($_POST['up_dated']) && $_POST['up_dated'] == 0) ? 0 : time();

if ($xoopsModuleConfig['autoapprove'] == 1)
{
$updated = time();
$xoopsDB->query("UPDATE " . $xoopsDB->prefix('PDlinks_links') . " SET cid = $cid, title = '$title',
url = '$url', updated = '$updated', offline = '$offline', description = '$descriptionb', ipaddress = '$ipaddress', notifypub = '$notifypub' WHERE lid = $lid");
$notification_handler = &xoops_gethandler('notification');
$tags = array();
$tags['FILE_NAME'] = $title;
$tags['FILE_URL'] = XOOPS_URL . '/modules/PDlinks/singlefile.php?cid=' . $cid . '&lid=' . $lid;
$sql = "SELECT title FROM " . $xoopsDB->prefix('PDlinks_cat') . " WHERE cid=" . $cid;
$result = $xoopsDB->query($sql);
$row = $xoopsDB->fetchArray($result);
$tags['CATEGORY_NAME'] = $row['title'];
$tags['CATEGORY_URL'] = XOOPS_URL . '/modules/PDlinks/viewcat.php?cid=' . $cid;
}
else
{
$modifysubmitter = $xoopsUser->uid();
$requestid = $modifysubmitter;
$requestdate = time();
$sql = "INSERT INTO " . $xoopsDB->prefix("PDlinks_mod") . "
(requestid, lid, cid, title, url, forumid, description, modifysubmitter, requestdate)";
$sql .= " VALUES ('', $lid, $cid, '$title', '$url', '$forumid', '$descriptionb',
'$modifysubmitter', '$requestdate')";
$result = $xoopsDB->query($sql);
$error = "" . _MD_PDD2_ERROR . ":

" . $sql;
if (!$result)
{
trigger_error($error, E_USER_ERROR);
}
$tags = array();
$tags['MODIFYREPORTS_URL'] = XOOPS_URL . '/modules/PDlinks/admin/index.php?op=listModReq';
$notification_handler = &xoops_gethandler('notification');
$notification_handler->triggerEvent('global', 0, 'file_modify', $tags);
}

if ($xoopsModuleConfig['autoapprove'] == 1)
{
$notification_handler->triggerEvent('global', 0, 'new_file', $tags);
$notification_handler->triggerEvent('category', $cid, 'new_file', $tags);
redirect_header("index.php", 2, _MD_PDD2_ISAPPROVED . "");
}
else
{
$tags['WAITINGFILES_URL'] = XOOPS_URL . '/modules/PDlinks/admin/index.php?op=listNewlinks';
$notification_handler->triggerEvent('global', 0, 'file_submit', $tags);
$notification_handler->triggerEvent('category', $cid, 'file_submit', $tags);
if ($notify)
{
include_once XOOPS_ROOT_PATH . '/include/notification_constants.php';
$notification_handler->subscribe('file', $newid, 'approve', XOOPS_NOTIFICATION_MODE_SENDONCETHENDELETE);
}
redirect_header('index.php', 2, _MD_PDD2_THANKSFORINFO);
exit();
}
}
}
else
{
global $_FILES, $xoopsModuleConfig, $xoopsConfig;

if ($xoopsModuleConfig['showdisclaimer'] && !isset($_GET['agree']))
{
echo "

" . PDd_imageheader() . "

\n

" . _MD_PDD2_DISCLAIMERAGREEMENT . "

\n

" . $myts->displayTarea($xoopsModuleConfig['disclaimer'], 0, 1, 1, 1, 1) . "

\n
\n
" . _MD_PDD2_DOYOUAGREE . "

\n
\n
 \n
\n
\n";
include XOOPS_ROOT_PATH . '/footer.php';
exit();
}

$lid = 0;
$cid = 0;
$title = '';
$url = 'http://';
$descriptionb = '';
$forumid = 0;
$status = 0;
$is_updated = 0;
$offline = 0;
$published = 0;
$expired = 0;
$updated = 0;
$versiontypes = '';

if (isset($_POST['lid']))
{
$lid = $_POST['lid'];
} elseif (isset($_GET['lid']))
{
$lid = $_GET['lid'];
}
else
{
$lid = 0;
}

echo "

" . PDd_imageheader() . "

\n
" . _MD_PDD2_SUB_SNEWMNAMEDESC . "
\n";
if ($lid)
{
$sql = "SELECT * FROM " . $xoopsDB->prefix('PDlinks_links') . " WHERE lid=" . $lid . "";
$link_array = $xoopsDB->fetchArray($xoopsDB->query($sql));

$lid = $myts->htmlSpecialChars($link_array['lid']);
$cid = $myts->htmlSpecialChars($link_array['cid']);
$title = $myts->htmlSpecialChars($link_array['title']);
$url = $myts->htmlSpecialChars($link_array['url']);
$descriptionb = $myts -> htmlSpecialChars($link_array['description']);
$published = $myts->htmlSpecialChars($link_array['published']);
$expired = $myts->htmlSpecialChars($link_array['expired']);
$updated = $myts->htmlSpecialChars($link_array['updated']);
$offline = $myts->htmlSpecialChars($link_array['offline']);
}
$sform = new XoopsThemeForm(_MD_PDD2_SUBMITCATHEAD, "storyform", xoops_getenv('PHP_SELF'));
$sform->setExtra('enctype="multipart/form-data"');

$sform->addElement(new XoopsFormText(_MD_PDD2_FILETITLE, 'title', 50, 255, $title), true);
$sform->addElement(new XoopsFormText(_MD_PDD2_DLURL, 'url', 50, 255, $url), false);
if ($xoopsModuleConfig['useruploads'])
{
$sform->addElement(new XoopsFormFile(_MD_PDD2_UPLOAD_FILEC, 'userfile', 0), false);
}

$mytree = new XoopsTree($xoopsDB->prefix('PDlinks_cat'), "cid", "pid");
ob_start();
$sform->addElement(new XoopsFormHidden('cid', 'pid'));
$mytree->makeMySelBox('title', 'title', $cid, 0);
$sform->addElement(new XoopsFormLabel(_MD_PDD2_CATEGORYC, ob_get_contents()));
ob_end_clean();

$sform -> addElement(new XoopsFormDhtmlTextArea(_MD_PDD2_DESCRIPTION, 'descriptionb', $descriptionb, 15, 60), true);

$option_tray = new XoopsFormElementTray(_MD_PDD2_OPTIONS, '
');
$notify_checkbox = new XoopsFormCheckBox('', 'notifypub');
$notify_checkbox->addOption(1, _MD_PDD2_NOTIFYAPPROVE);
$option_tray->addElement($notify_checkbox);
$sform->addElement($option_tray);
$button_tray = new XoopsFormElementTray('', '');

$button_tray->addElement(new XoopsFormButton('', 'submit', _SUBMIT, 'submit'));
$button_tray->addElement(new XoopsFormHidden('lid', $lid));
$sform->addElement($button_tray);
$sform->display();
include XOOPS_ROOT_PATH . '/footer.php';
}
}
?>


My xfguestbook does not have a submit.php, it has a xfcreate.php as follows
// $Id: xfcreate.php, v 0.1 2007/12/04 C. Asswipe php team
// ------------------------------------------------------------------------ //
// XF Guestbook //
// ------------------------------------------------------------------------- //
// This program is free software; you can redistribute it and/or modify //
// it under the terms of the GNU General Public License as published by //
// the Free Software Foundation; either version 2 of the License, or //
// (at your option) any later version. //
// //
// You may not change or alter any portion of this comment or credits //
// of supporting developers from this source code or any supporting //
// source code which is considered copyrighted (c) material of the //
// original comment or credit authors. //
// //
// This program is distributed in the hope that it will be useful, //
// but WITHOUT ANY WARRANTY; without even the implied warranty of //
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the //
// GNU General Public License for more details. //
// //
// You should have received a copy of the GNU General Public License //
// along with this program; if not, write to the Free Software //
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA //
// ------------------------------------------------------------------------ //

include("../../mainfile.php");
if ($xoopsModuleConfig['anonsign']!=1 && !is_object($xoopsUser)) {
redirect_header(XOOPS_URL."/user.php",2,_MD_XFGB_MUSTREGFIRST);
exit();
}

//include_once(XOOPS_ROOT_PATH."/modules/".$xoopsModule->dirname()."/class/msg.php");
include_once(XOOPS_ROOT_PATH."/modules/".$xoopsModule->dirname()."/include/functions.php");
include_once("include/config.inc.php");

$option = getOptions();
$msg_handler =& xoops_getmodulehandler('msg');

$confirm_code = isset($_POST['confirm_code']) ? $_POST['confirm_code'] : '';
$confirm_str = isset($_POST['confirm_str']) ? $_POST['confirm_str'] : '';
$user_id = isset($_POST['user_id']) ? intval($_POST['user_id']) : 0;
$title = (isset($_POST['title']) ? $_POST['title'] : '');
$message = (isset($_POST['message']) ? $_POST['message'] : '');
$gender = (isset($_POST['gender']) ? $_POST['gender'] : '');
$preview_name = (isset($_POST['preview_name']) ? $_POST['preview_name'] : '');
$email = (isset($_POST['email']) ? $_POST['email'] : '');
$name = (isset($_POST['name']) ? $_POST['name'] : '');
$url = (isset($_POST['url']) ? $_POST['url'] : '');
$country = (isset($_POST['country']) ? $_POST['country'] : '');

if (isset($_POST['preview'])) {
$op = 'preview';
} elseif (isset($_POST['post']) ) {
$op = 'post';
} else
$op = 'form';

$badip = in_array($_SERVER['REMOTE_ADDR'], xfgb_get_badips()) ? true : false ;

switch ($op) {
case "cancel":
$photos_dir = XOOPS_ROOT_PATH . "/modules/".$xoopsModule->dirname()."/images/msg" ;
$nb_removed_tmp = xfgb_clear_tmp_files( $photos_dir ) ;
redirect_header("index.php", 0);
break;

case "preview":
$ts =& MyTextSanitizer::getInstance();
include XOOPS_ROOT_PATH.'/header.php';
$xoopsOption['template_main'] = 'xfguestbook_signform.html';
$msgstop = '';

if ($option['opt_code']) {
include_once XOOPS_ROOT_PATH."/modules/".$xoopsModule->dirname()."/include/randomscript.php";
$wrong_code = xfgb_verify_code($confirm_str, $confirm_code);
if($wrong_code != ''){
$msgstop .= _MD_XFGB_CONFIRM_CODE_WRONG.$wrong_code.'
';
$confirm_code ='';
}
list($confirm_str, $confirm_image) = xfgb_create_image($confirm_code);
$xoopsTpl->assign('confirm_image', $confirm_image);
}
if ($option['opt_url'] == 2 && preg_match("/(http)|(www)/i",$message))
$msgstop .= _MD_XFGB_URL_DISABLED.'
';

if ($email != '' && !checkEmail($email) ) $msgstop .= _MD_XFGB_INVALIDMAIL.'
';
if ( !empty($_FILES['photo']['name'])) {
xfgb_upload();
}
$title = $ts->htmlSpecialChars( $ts->stripSlashesGPC($title) );
$message = $ts->htmlSpecialChars( $ts->stripSlashesGPC($message) );
if ( !empty($msgstop) ) {
$xoopsTpl->assign('preview', true);
$xoopsTpl->assign('msgstop',$msgstop);
include_once "include/form_sign.inc.php";
$signform->assign($xoopsTpl);
include XOOPS_ROOT_PATH."/footer.php";
exit();
}
$msgpost['title'] = $ts->previewTarea($title);
$msgpost['message'] = $ts->previewTarea($message);
$msgpost['poster'] = $name;
$msgpost['user_id'] = $user_id;
$msgpost['date'] = formatTimestamp(time(),"s");
$msgpost['photo'] = $preview_name;
if ($option['opt_url'] == 1)
$msgpost['message'] = str_replace('target="_blank"', 'target="_blank" rel="nofollow"',$msgpost['message']);
if ($gender)
$msgpost['gender'] = ' if ($email)
$msgpost['email'] = "\""._SENDEMAILTO."\"";
if ($url)
$msgpost['url'] = ''._VISITWEBSITE.'';
if ($country) {
$flag = XOOPS_ROOT_PATH."/modules/".$xoopsModule->dirname()."/images/flags/".$xoopsModuleConfig['flagdir']."/".$country.".gif";
$arr_country = xfgb_getCountry("country_code ='".$country."'");
$country_name = (count($arr_country) > 0) ? $arr_country[0]['country_name'] : '';
if (file_exists($flag)) {
$msgpost['country'] = "\"".$country_name."\"";
} else {
$msgpost['country'] = $country_name;
}
}

$xoopsTpl->assign('preview', true);
$xoopsTpl->assign('msgstop',$msgstop);
include "include/form_sign.inc.php";
$xoopsTpl->assign('msg', $msgpost);
$signform->assign($xoopsTpl);
include XOOPS_ROOT_PATH."/footer.php";
break;

case "post":
$msgstop = '';
if ($option['opt_code']) {
include_once XOOPS_ROOT_PATH."/modules/".$xoopsModule->dirname()."/include/randomscript.php";
$wrong_code = xfgb_verify_code($confirm_str, $confirm_code);
if($wrong_code != ''){
$msgstop .= _MD_XFGB_CONFIRM_CODE_WRONG.$wrong_code.'
';
$confirm_code ='';
}
include XOOPS_ROOT_PATH.'/header.php';
$xoopsOption['template_main'] = 'xfguestbook_signform.html';
list($confirm_str, $confirm_image) = xfgb_create_image($confirm_code);
$xoopsTpl->assign('confirm_image', $confirm_image);
}
if ($option['opt_url'] == 2 && preg_match("/(http)|(www)/i",$message))
$msgstop .= _MD_XFGB_URL_DISABLED.'
';

if ($email != '' && !checkEmail($email) ) $msgstop .= _MD_XFGB_INVALIDMAIL.'
';
if (!empty($_FILES['photo']['name'])) {
xfgb_upload();
}
if ( !empty($msgstop) ) {
include XOOPS_ROOT_PATH.'/header.php';
$xoopsOption['template_main'] = 'xfguestbook_signform.html';
$xoopsTpl->assign('preview', true);
$xoopsTpl->assign('msgstop',$msgstop);
include_once "include/form_sign.inc.php";
$signform->assign($xoopsTpl);
include XOOPS_ROOT_PATH."/footer.php";
exit();
}
$photos_dir = XOOPS_ROOT_PATH . "/modules/".$xoopsModule->dirname()."/images/msg" ;
if ($preview_name != '') {
$photo = str_replace('tmp_', 'msg_',$preview_name);
rename( "$photos_dir/$preview_name" , "$photos_dir/$photo" ) ;
}

$msgpost = $msg_handler->create();
($xoopsUser) ? $user_id = $xoopsUser->uid() : $user_id=0;
($xoopsUser) ? $username=$xoopsUser->uname() : $username=$name;
$msgpost->setVar('user_id', $user_id);
$msgpost->setVar('uname', $username);
$msgpost->setVar('title', $title);
$msgpost->setVar('message', $message);
$msgpost->setVar('note', '');
$msgpost->setVar('post_time', time());
$msgpost->setVar('email', $email);
$msgpost->setVar('url', $url);
$msgpost->setVar('poster_ip', $_SERVER['REMOTE_ADDR']);
$msgpost->setVar('country', $country);
$msgpost->setVar('flagdir', $xoopsModuleConfig['flagdir']);
$msgpost->setVar('gender', $gender);
if (!isset($photo)) $photo='';
$msgpost->setVar('photo', $photo);

if ($badip) {
$msgpost->setVar('moderate', 1);
} else {
$msgpost->setVar('moderate', $xoopsModuleConfig['moderate']);
}
$nb_removed_tmp = xfgb_clear_tmp_files( $photos_dir ) ;
$messagesent = _MD_XFGB_MESSAGESENT;

if ($msg_handler->insert($msgpost)) {
if($xoopsModuleConfig['moderate'] || $badip)
$messagesent.="
"._MD_XFGB_AFTERMODERATE;

// Send mail to webmaster
if($xoopsModuleConfig['sendmail2wm']==1) {
$subject = $xoopsConfig['sitename']." - "._MD_XFGB_NAMEMODULE;
$xoopsMailer =& getMailer();
$xoopsMailer->useMail();
$xoopsMailer->setToEmails($xoopsConfig['adminmail']);
$xoopsMailer->setFromEmail($xoopsConfig['adminmail']);
$xoopsMailer->setFromName($xoopsConfig['sitename']);
$xoopsMailer->setSubject($subject);
$xoopsMailer->setBody(_MD_XFGB_NEWMESSAGE." ".XOOPS_URL."/modules/".$xoopsModule->dirname()."/");
$xoopsMailer->send();
}
redirect_header("index.php",2,$messagesent);
} else {
$messagesent = $msgpost->getHtmlErrors();
redirect_header("index.php",2,$messagesent);
}
break;

case 'form':
default:
$xoopsOption['template_main'] = 'xfguestbook_signform.html';

include XOOPS_ROOT_PATH."/header.php";
$user_id = !empty($xoopsUser) ? $xoopsUser->getVar('uid', 'E') : 0;
$name = !empty($xoopsUser) ? $xoopsUser->getVar('uname', 'E') : '';
$email = !empty($xoopsUser) ? $xoopsUser->getVar('email', 'E') : "";
$url = !empty($xoopsUser) ? $xoopsUser->getVar('url', 'E') : '';
$country = $option['countrybydefault'];

if ($option['opt_code']) {
include_once XOOPS_ROOT_PATH."/modules/".$xoopsModule->dirname()."/include/randomscript.php";
list($confirm_str, $confirm_image) = xfgb_create_image();
$xoopsTpl->assign('confirm_image', $confirm_image);
}
if($xoopsModuleConfig['moderate'] || $badip)
$xoopsTpl->assign('moderate', _MD_XFGB_MODERATED);

include "include/form_sign.inc.php";
$signform->assign($xoopsTpl);
include XOOPS_ROOT_PATH."/footer.php";
break;
}
?>


thanks in advance
A man without history is like a tree without roots. Marcus Garvey (1917) http://CaribbeanAncestry.com http://JamaicaGenealogy.com http://thephilosophizers.com Teach what you know and learn what you don't; stay open to all. 24/7

10
BeautyBrains
Re: Top Posters Block not updating

I figured it out for AMS but not for the others.
Thanks
A man without history is like a tree without roots. Marcus Garvey (1917) http://CaribbeanAncestry.com http://JamaicaGenealogy.com http://thephilosophizers.com Teach what you know and learn what you don't; stay open to all. 24/7

Login

Who's Online

426 user(s) are online (308 user(s) are browsing Support Forums)


Members: 0


Guests: 426


more...

Donat-O-Meter

Stats
Goal: $100.00
Due Date: Nov 30
Gross Amount: $0.00
Net Balance: $0.00
Left to go: $100.00
Make donations with PayPal!

Latest GitHub Commits