1
metin
Link only for special group - code problem
  • 2005/6/30 16:04

  • metin

  • Just popping in

  • Posts: 64

  • Since: 2003/6/21


I have in PDdownloads module the VOTE button which i want to allow only for the special member group ( identity 4 ). This is the original link.

<a href='<{$xoops_url}>/modules/PDdownloads/ratefile.php?cid=<{$down.cid}>&lid=<{$down.id}>'><{$smarty.const._MD_PDD_RATETHISFILE}></a>


If i use this code in the singlefile.html template the
Voting page doesn´t open and it comes an error page. Also the button shows not the translated word only "{$smarty.const._MD_PDD_RATETHISFILE}>".

<{if $xoops_isuser}>
<{
php}>
global 
$xoopsUser;
$tamuye '4';
$name $xoopsUser->getVar('uname');
$groups $xoopsUser->getGroups();
if (
in_array($tamuye$groups)) {
echo 
'<a href='<{$xoops_url}>/modules/PDdownloads/ratefile.php?cid=<{$down.cid}>&lid=<{$down.id}>'><{$smarty.const._MD_PDD_RATETHISFILE}></a>';}                                      
<{/
php}>
<{/if}>


What i have to add at after echo ?

2
metin
Re: Link only for special group - code problem
  • 2005/6/30 17:17

  • metin

  • Just popping in

  • Posts: 64

  • Since: 2003/6/21


nobody there who could tell me how i have to write this echo line right ?

echo '<a href='<{$xoops_url}>/modules/PDdownloads/ratefile.php?cid=<{$down.cid}>&lid=<{$down.id}>'><{$smarty.const._MD_PDD_RATETHISFILE}></a>';}

3
Mithrandir
Re: Link only for special group - code problem

You have a } at the very end of the line, which shouldn't be there.
"When you can flatten entire cities at a whim, a tendency towards quiet reflection and seeing-things-from-the-other-fellow's-point-of-view is seldom necessary."

Cusix Software

4
metin
Re: Link only for special group - code problem
  • 2005/6/30 19:19

  • metin

  • Just popping in

  • Posts: 64

  • Since: 2003/6/21


now the singlefile page doesn´t work anymore.

Did try to add this code at ratefile template, cause than normal users can´t pushed the voting button but there is the same problem after i add the code in the template. The ratefile page don´t work.

this was the code for the ratingfile template

<{if $xoops_isuser}>
<{
php}>
global 
$xoopsUser;
$redaktion '4';
$name $xoopsUser->getVar('uname');
$groups $xoopsUser->getGroups();
if (
in_array($redaktion$groups)) 
{
echo 
'<form method="post" action="ratefile.php">n
        <input type="hidden" name="lid" value="<{$file.id}>" />n
        <input type="hidden" name="cid" value="<{$file.cid}>" />n
             <select name="rating"><option>--</option><option>10</option><option>9</option><option>8</option><option>7</option><option>6</option><option>5</option><option>4</option><option>3</option><option>2</option><option>1</option></select>n
        &nbsp;&nbsp;n
        <input type="submit" name="submit" value="<{$smarty.const._MD_PDD_RATEIT}>" alt="<{$smarty.const._MD_PDD_RATEIT}>" /> <input type="button" value="<{$smarty.const._CANCEL}>" alt="<{$smarty.const._CANCEL}>" onclick="location='
<{$xoops_url}>/modules/PDdownloads/singlefile.php?cid=<{$file.cid}>&lid=<{$file.id}>'" />n
      </form>n";
}
<{/php}>
<{/if}>

5
m0nty
Re: Link only for special group - code problem
  • 2005/6/30 19:28

  • m0nty

  • XOOPS is my life!

  • Posts: 3337

  • Since: 2003/10/24


i'm no coder, but could it possibly be the line end characters?

\n after each line???

6
metin
Re: Link only for special group - code problem
  • 2005/6/30 19:44

  • metin

  • Just popping in

  • Posts: 64

  • Since: 2003/6/21


monty i did try it without \n too but have the same blank page. All other blocks are visible.

It´s interesting that i had in the beginning not this problem. At first i did get an error page and not the ratefile page that had to be shown.

Now when i add the code in the singlefile template the singlefile content doesn´t shown and if i add the code in ratefile template this does not show the content, but the rest of the site.

i only want that only an special group can reach the ratingfile page or can vote there. It cannot be so difficult to get this, but i have no expirience with php too.

7
metin
Re: Link only for special group - code problem
  • 2005/6/30 20:09

  • metin

  • Just popping in

  • Posts: 64

  • Since: 2003/6/21


Where i could add the right code in the followin ratefile.php

anonymous & normal users cannot vote.

<?php 
/* $Id: ratefile.php,v 2.3 11 july 2004 Liquid Exp $
 * Module: PD-Downloads
 * Version: v1.0
 * Release Date: 04. März 2005
 * Author: Power-Dreams Team
 * Licence: GNU
 */
 
include 'header.php';

global 
$myts;

if (!empty(
$_POST['submit']))
{
    if (empty(
$xoopsUser))
    {
        
$ratinguser 0;
    } 
    else
    {
        
$ratinguser $xoopsUser -> getVar('uid');
    } 
    
// Make sure only 1 anonymous from an IP in a single day.
    
$anonwaitdays 1;
    
$ip getenv("REMOTE_ADDR");
    
$lid intval($_POST['lid']);
    
$cid intval($_POST['cid']);
    
$rating intval($_POST['rating']); 
    
// Check if Rating is Null
    
if ($rating == "--")
    {
        
redirect_header("ratefile.php?cid=" $cid "&lid=" $lid ""4_MD_PDD_NORATING);
        exit();
    } 
    
// Check if Download POSTER is voting (UNLESS Anonymous users allowed to post)
    
if ($ratinguser != 0)
    {
        
$result $xoopsDB -> query("SELECT submitter FROM " $xoopsDB -> prefix('PDdownloads_downloads') . " WHERE lid=$lid");
        while (list(
$ratinguserDB) = $xoopsDB -> fetchRow($result))
        {
            if (
$ratinguserDB == $ratinguser)
            {
                
redirect_header("index.php"4_MD_PDD_CANTVOTEOWN);
                exit();
            } 
        } 
        
// Check if REG user is trying to vote twice.
        
$result $xoopsDB -> query("SELECT ratinguser FROM " $xoopsDB -> prefix('PDdownloads_votedata') . " WHERE lid=$lid");
        while (list(
$ratinguserDB) = $xoopsDB -> fetchRow($result))
        {
            if (
$ratinguserDB == $ratinguser)
            {
                
redirect_header('index.php'4_MD_PDD_VOTEONCE);
                exit();
            } 
        } 
    } 
    else
    { 
        
// Check if ANONYMOUS user is trying to vote more than once per day.
        
$yesterday = (time() - (86400 $anonwaitdays));
        
$result $xoopsDB -> query("SELECT COUNT(*) FROM " $xoopsDB -> prefix('PDdownloads_votedata') . " WHERE lid=$lid AND ratinguser=0 AND ratinghostname = '$ip'  AND ratingtimestamp > $yesterday");
        list(
$anonvotecount) = $xoopsDB -> fetchRow($result);
        if (
$anonvotecount >= 1)
        {
            
redirect_header("index.php"4_MD_PDD_VOTEONCE);
            exit();
        } 
    } 
    
// All is well.  Add to Line Item Rate to DB.
    
$newid $xoopsDB -> genId($xoopsDB -> prefix('PDdownloads_votedata') . "_ratingid_seq");
    
$datetime time();
    
$sql sprintf("INSERT INTO %s (ratingid, lid, ratinguser, rating, ratinghostname, ratingtimestamp) VALUES (%u, %u, %u, %u, '%s', %u)"$xoopsDB -> prefix('PDdownloads_votedata'), $newid$lid$ratinguser$rating$ip$datetime);
    
$xoopsDB -> query($sql); 
    
// All is well.  Calculate Score & Add to Summary (for quick retrieval & sorting) to DB.
    
PDd_updaterating($lid);
    
$ratemessage _MD_PDD_VOTEAPPRE "<br />" sprintf(_MD_PDD_THANKYOU$xoopsConfig['sitename']);
    
redirect_header('index.php'4$ratemessage);
    exit();

else
{
    
$xoopsOption['template_main'] = 'PDdownloads_ratefile.html';
    include 
XOOPS_ROOT_PATH '/header.php';
    
$lid intval($_GET['lid']);
    
$cid intval($_GET['cid']);
    
$imageheader PDd_imageheader();

    
$result $xoopsDB -> query("SELECT title FROM " $xoopsDB -> prefix('PDdownloads_downloads') . " WHERE lid=$lid");
    list(
$title) = $xoopsDB -> fetchRow($result);
    
$xoopsTpl -> assign('file', array('id' => $lid'cid' => $cid'title' => $myts -> htmlSpecialChars($title), 'imageheader' => $imageheader));
    include 
XOOPS_ROOT_PATH '/footer.php';

include 
XOOPS_ROOT_PATH.'/footer.php';

?>

8
metin
Re: Link only for special group - code problem
  • 2005/6/30 22:05

  • metin

  • Just popping in

  • Posts: 64

  • Since: 2003/6/21


OK. I could solve the problem. Finito.

Login

Who's Online

199 user(s) are online (112 user(s) are browsing Support Forums)


Members: 0


Guests: 199


more...

Donat-O-Meter

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

Latest GitHub Commits