11
ghia
Re: How do I add a simple webpage to a xoops themed site?
  • 2009/11/7 8:35

  • ghia

  • Community Support Member

  • Posts: 4953

  • Since: 2008/7/3 1


Use a custom block, a blank module (eg ghost), a News category, a content module, ...
They all have permissions, that can be set to be viewed only by the targetted user group.

12
blackrx
Re: How do I add a simple webpage to a xoops themed site?
  • 2009/11/7 9:06

  • blackrx

  • Quite a regular

  • Posts: 227

  • Since: 2008/2/5 1


there is reason i want to use this.

i want it to be in my root

mysite.com/mypage.php

oh i made some search and i found this

$xoopsUser or redirect_header('index.php'3_NOPERM);


anonymous user will be redirect to index.php when they try to acces the page

but what about
Quote:

what if i want to restrict view of this page by user ID or by group ?


I don't want anonymous visitor or any other registered user to visit this page

how do i do this ?


what should i modify in the code

13
ghia
Re: How do I add a simple webpage to a xoops themed site?
  • 2009/11/7 9:20

  • ghia

  • Community Support Member

  • Posts: 4953

  • Since: 2008/7/3 1


if (is_object($xoopsUser)) {
  
$groups $xoopsUser->getGroups();
} else {
  
$groups XOOPS_GROUP_ANONYMOUS;
}

Then check if the required group is present.
if(is_object($xoopsUser)) {
  
$uid $xoopsUser->getVar('uid');
}
else

  
$uid 0;
}
Then check $uid is the required one.

14
demian
Re: How do I add a simple webpage to a xoops themed site?
  • 2009/11/7 13:11

  • demian

  • Quite a regular

  • Posts: 225

  • Since: 2008/4/29


if anyone is interested here is how to add custom site name, page title,keywords and description to the original code



https://xoops.org/modules/newbb/viewto ... id=271870#forumpost271870


<?php
if (file_exists("mainfile.php")) {
include(
"mainfile.php");
} elseif (
file_exists("../mainfile.php")) {
include(
"../mainfile.php");
} else {
include(
"../../mainfile.php");
}
include(
XOOPS_ROOT_PATH."/header.php");
$xoopsTpl->assign'xoops_showrblock'1); // 1 = With right block - 0 = Without right block
$xoopsTpl->assign'xoops_showlblock'0); // 1 = With left block - 0 = Without left block
?>

HTML CONTENT GOES HERE

<?php

if(isset($xoTheme) && is_object($xoTheme)) {
$xoTheme->addMeta'meta''keywords'"keyword, keyword, keyword, keyword");
$xoTheme->addMeta'meta''description'"This is the page description");
$xoopsTpl->assign('xoops_sitename','This is the page title');

}
include(
XOOPS_ROOT_PATH."/footer.php");
?>




15
blackrx
Re: How do I add a simple webpage to a xoops themed site?
  • 2009/11/7 13:29

  • blackrx

  • Quite a regular

  • Posts: 227

  • Since: 2008/2/5 1


Quote:

ghia wrote:
if (is_object($xoopsUser)) {
  
$groups $xoopsUser->getGroups();
} else {
  
$groups XOOPS_GROUP_ANONYMOUS;
}

Then check if the required group is present.
if(is_object($xoopsUser)) {
  
$uid $xoopsUser->getVar('uid');
}
else

  
$uid 0;
}
Then check $uid is the required one.


i dont quite understand this...im quite newbie..thanks anyway Ghia


but i think i found a possible solution from this topic

will try if this works




16
blackrx
Re: How do I add a simple webpage to a xoops themed site?
  • 2009/11/7 13:43

  • blackrx

  • Quite a regular

  • Posts: 227

  • Since: 2008/2/5 1


<{if $xoops_isadmin}>
echo 
"test - admin see this";
<{/if}>

<{if !
$xoops_isuser}>
echo 
"user see this";
<{/if}>


<{if 
$xoops_isadmin}> <!--condition if the real webmaster login-->
echo 
"what to do";
<{elseif 
$group_id == 4}> 
//<!--condition if the other webmaster login ("4" is the id of the group created before)-->
echo "something to do if first condition is false and this condition is true";
<{/if}>
?>


i test some of this code but

it seems smarty tags is not working in my page

keep getting
Parse error: syntax error, unexpected '<'

17
ghia
Re: How do I add a simple webpage to a xoops themed site?
  • 2009/11/7 14:13

  • ghia

  • Community Support Member

  • Posts: 4953

  • Since: 2008/7/3 1


Do not mix Smarty code <{.... inside your PHP file. Smarty code is for templates, which need to be loaded by the PHP code first. No need to do that, this will make it only more complex.

If you use Demian's example, you have to place your HTML code by replacing 'HTML CONTENT GOES HERE '.

Before the first PHP ending tag ?> , you must do the validation for the access with PHP code.
With the code snippets I gave you, you can find out about the user his id or the groups he belongs to.
With these you have to do a check for failing (to meet the criteria) eg:
if (!$userisok) {
    
redirect_header(XOOPS_URL.'/index.php'3_NOPERM);
    exit();
}
This will prevent the user from seeing the page with a not permitted warning and bring him back to the home page.

18
script_fu
Re: How do I add a simple webpage to a xoops themed site?

This is interesting... Ghia will this code work in the root folder of Xoops?

Meaning

root/test.php?

So can I wrap a page with this code we have been using for years. Then add your code to where to get this working in the root folder not root/modules/test/test.php

Quote:

Northern wrote:
name it whatever you want, but end it in .php

<?php
if (file_exists("mainfile.php")) {
    include(
"mainfile.php");
}
elseif(
file_exists("../mainfile.php")) {
    include(
"../mainfile.php");
}
else {
    include(
"../../mainfile.php");
}
include(
XOOPS_ROOT_PATH "/header.php");
$xoopsTpl->assign('xoops_showrblock'0); // 1 display right blocks
$xoopsTpl->assign('xoops_showlblock'0); // 1 display right blocks
?>
///////
Your code in html 
///////
<?php
include(XOOPS_ROOT_PATH "/footer.php");
?>


or

in full php


<?php
if (file_exists("mainfile.php")) {
    include(
"mainfile.php");
}
elseif(
file_exists("../mainfile.php")) {
    include(
"../mainfile.php");
}
else {
    include(
"../../mainfile.php");
}
include(
XOOPS_ROOT_PATH "/header.php");
$xoopsTpl->assign('xoops_showrblock'0); // 1 display right blocks
$xoopsTpl->assign('xoops_showlblock'0); // 1 display right blocks

echo "Your code";

include(
XOOPS_ROOT_PATH "/footer.php");
?>


Marc


I didn't know user's could be controlled with stand alone pages.

Thanks for your time...

19
ghia
Re: How do I add a simple webpage to a xoops themed site?
  • 2009/11/7 19:27

  • ghia

  • Community Support Member

  • Posts: 4953

  • Since: 2008/7/3 1


Quote:
Ghia will this code work in the root folder of Xoops?
It seems to be designed to work in the root and up to two levels up.
Quote:
I didn't know user's could be controlled with stand alone pages.
With the right programming, you can do everything!

20
blackrx
Re: How do I add a simple webpage to a xoops themed site?
  • 2009/11/8 0:36

  • blackrx

  • Quite a regular

  • Posts: 227

  • Since: 2008/2/5 1


Quote:

ghia wrote:
if (is_object($xoopsUser)) {
  
$groups $xoopsUser->getGroups();
} else {
  
$groups XOOPS_GROUP_ANONYMOUS;
}

Then check if the required group is present.
if(is_object($xoopsUser)) {
  
$uid $xoopsUser->getVar('uid');
}
else

  
$uid 0;
}
Then check $uid is the required one.



Ghia can you show me example ?

so if i want so only user id=1 and 34 can access this page..what should i modify and put the user ID ?

if (!$userisok) {
    
redirect_header(XOOPS_URL.'/index.php'3_NOPERM);
    exit();
}


there is some possible solution here..
ban user from certain page

https://xoops.org/modules/newbb/viewto ... id=316663#forumpost316663

it will ban users defined in a table
.but this will be difficult...cause i want to ban all users except2 users

user id 1 and 34

how do i modify the code ?

Login

Who's Online

46 user(s) are online (33 user(s) are browsing Support Forums)


Members: 0


Guests: 46


more...

Donat-O-Meter

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

Latest GitHub Commits