PM Wiki Integration With Icy Phoenix »  Show posts from    to     

Icy Phoenix


Old Customizations - PM Wiki Integration With Icy Phoenix



AndyGpy [ Sat 10 Oct, 2009 11:09 ]
Post subject: PM Wiki Integration With Icy Phoenix
Hi Guys

I am trying to incorporate pmWiki to my website and have it editable by the members of my site.

In pmwiki cookbook is many scripts to interface it into phpbb2, phpbb3 smf etc etc but not one for ICY.

What i have here is the PHPbb2 script , can someone please help modify it so that it may work for ICY if you know what i mean.

pmwiki resides at the same level as my forum folder ie in the root.

Code: [Hide] [Select]

<?php if (!defined('PmWiki')) exit();

##
## SMC: New alternative Wiki Auth
## SMC: Check if we are already authenticated via phpBB2 forum
## Version: 1.0
##

// Set the default phpBB2 cookie name. _data is appended to this name later in this script.
SDV($phpBB2cookie,'phpBB2_cookie_name');

// Override the default AuthFunction to phpAuth
$AuthFunction = 'PhpBB2Auth';

$m_phpBB2_auth = false;
$m_username = 'Anonymous'; // forum defaults to this also

$m_data_cookie = $phpBB2cookie . '_data'; // append _data to cookie name as this is the element we need
#print "Session Cookie: " . $m_data_cookie . "<br>";

if (isset($_COOKIE[$m_data_cookie]))
{
$sessiondata = isset($_COOKIE[$m_data_cookie]) ? unserialize(stripslashes($_COOKIE[$m_data_cookie])) : array();
if (strcasecmp((string)$sessiondata['username'],"Anonymous") <> 0) {
$m_phpBB2_auth = true;
$Author = (string)$sessiondata['username'];
#print "Session Data: " . (string)$sessiondata['username'] . "<br>";
}
}

function PhpBB2Auth($pagename, $level, $authprompt=true, $since=0) {
global $DefaultPasswords, $GroupAttributesFmt, $AllowPassword,
$AuthCascade, $FmtV, $AuthPromptFmt, $PageStartFmt, $PageEndFmt,
$AuthId, $AuthList, $NoHTMLCache, $m_phpBB2_auth;

## SMC: If we find an authenticated phpBB2 user continue with regular
## PmWiki auth check, if phpBB2 auth failed, stop check now
static $acache;
SDV($GroupAttributesFmt,'$Group/GroupAttributes');
SDV($AllowPassword,'nopass');
$page = ReadPage($pagename, $since);
if (!$page) { return false; }
if (!isset($acache))
SessionAuth($pagename, (@$_POST['authpw'])
? array('authpw' => array($_POST['authpw'] => 1))
: '');
if (@$AuthId) {
$AuthList["id:$AuthId"] = 1;
$AuthList["id:-$AuthId"] = -1;
$AuthList["id:*"] = 1;
}
$gn = FmtPageName($GroupAttributesFmt, $pagename);
if (!isset($acache[$gn])) {
$gp = ReadPage($gn, READPAGE_CURRENT);
foreach($DefaultPasswords as $k => $v) {
$x = array(2, array(), '');
$acache['@site'][$k] = IsAuthorized($v, 'site', $x);
$AuthList["@_site_$k"] = $acache['@site'][$k][0] ? 1 : 0;
$acache[$gn][$k] = IsAuthorized(@$gp["passwd$k"], 'group',
$acache['@site'][$k]);
}
}
foreach($DefaultPasswords as $k => $v)
list($page['=auth'][$k], $page['=passwd'][$k], $page['=pwsource'][$k]) =
IsAuthorized(@$page["passwd$k"], 'page', $acache[$gn][$k]);
foreach($AuthCascade as $k => $t) {
if ($page['=auth'][$k]+0 == 2) {
$page['=auth'][$k] = $page['=auth'][$t];
if ($page['=passwd'][$k] = $page['=passwd'][$t]) # assign
$page['=pwsource'][$k] = "cascade:$t";
}
}
if (@$page['=auth']['admin'])
foreach($page['=auth'] as $lv=>$a) @$page['=auth'][$lv] = 3;
if (@$page['=passwd']['read']) $NoHTMLCache |= 2;

# SMC: only allow page reads unless phpBB2 authenticated
if ($m_phpBB2_auth == true) {
if ($level=='ALWAYS' || @$page['=auth'][$level]) return $page;
}
if (strcasecmp ($level, "read") == 0) {
if ($level=='ALWAYS' || @$page['=auth'][$level]) return $page; # SMC: orig line
}

if (!$authprompt) return false;
$GLOBALS['AuthNeeded'] = (@$_POST['authpw'])
? $page['=pwsource'][$level] . ' ' . $level : '';
PCache($pagename, $page);

$postvars = '';
foreach($_POST as $k=>$v) {
if ($k == 'authpw' || $k == 'authid') continue;
$v = str_replace('$', '$',
htmlspecialchars(stripmagic($v), ENT_COMPAT));
$postvars .= "<input type='hidden' name='$k' value=\"$v\" />\n";
}
$FmtV['$PostVars'] = $postvars;
SDV($AuthPromptFmt,array(&$PageStartFmt,
"<p><b>$[Password required]</b></p>
<form name='authform' action='{$_SERVER['REQUEST_URI']}' method='post'>
$[Password]: <input tabindex='1' type='password' name='authpw'
value='' />
<input type='submit' value='OK' />\$PostVars</form>
<script language='javascript' type='text/javascript'><!--
document.authform.authpw.focus() //--></script>", &$PageEndFmt));
PrintFmt($pagename,$AuthPromptFmt);
exit;


I hope someone can help, its been pulling my hair out for weeks.

regards


Mighty Gorgon [ Sat 10 Oct, 2009 12:51 ]
Post subject: Re: ICY Security - Login System
If the script is installed in the same root of Icy Phoenix you should add in the common file something like this code:

Code: [Hide] [Select]
// CTracker_Ignore: File checked by human
define('MG_KILL_CTRACK', true);
define('IN_ICYPHOENIX', true);
if (!defined('IP_ROOT_PATH')) define('IP_ROOT_PATH', './');
if (!defined('PHP_EXT')) define('PHP_EXT', substr(strrchr(__FILE__, '.'), 1));
include(IP_ROOT_PATH . 'common.' . PHP_EXT);

// Start session management
$userdata = session_pagestart($user_ip);
init_userprefs($userdata);
// End session management


This will allow you to use Icy Phoenix auth system within your script.


AndyGpy [ Sat 10 Oct, 2009 14:44 ]
Post subject: Re: ICY Security - Login System
It is not in the same folder as ICY Forum.

The Script i have:-

Spoiler: [ Show ]



Is Giving me a hacking attempt message when tryng to access my wiki site, any ideas anyone ?

regards


Mighty Gorgon [ Sun 11 Oct, 2009 10:09 ]
Post subject: Re: ICY Security - Login System
Forget that for now...

I have created 2 files for you and edited pmwiki.php for PMWIKI 2.2.6.

Here is what you have to do:
  • Make a backup of your current pmwiki.php
  • Download and extract the files in the archive attached here
  • Edit ipwiki.php by adjusting the correct path to your pmwiki folder and upload that into your Icy Phoenix root folder
  • Edit index.php by adjusting the correct path to your Icy Phoenix root folder
    Code: [Hide] [Select]
    if (!defined('IP_ROOT_PATH')) define('IP_ROOT_PATH', '../ip/');

  • Upload both index.php and pmwiki.php to your PMWiki root folder
  • Enjoy your "icyphoenixsessionized" PMWiki!


Please note that I have just forced only logged in users to be able to surf PMWiki pages, if you need just to remove the EDIT link or allow just some special features, you need to refer to PMWiki docs on how to do that... you will then just need to add a proper switch to allow only registered, moderators or administrators to access special sections, and you will do that just by using the same code you would use in Icy Phoenix... something like this for example:

Code: [Hide] [Select]
if (!$userdata['session_logged_in'])
{
DO MY STUFF
}


Informpro [ Sun 11 Oct, 2009 10:55 ]
Post subject: Re: PM Wiki Integration With Icy Phoenix
Could be useful ... I think you could put in "customisation"


AndyGpy [ Sun 11 Oct, 2009 17:10 ]
Post subject: Re: PM Wiki Integration With Icy Phoenix
Thanks MG,

Problem i have found is that it allows me to view the wiki homepage but wont let me browse past that or edit any pages

if i log off and try to access id defaults me to my login page which is great.

just need to resolve the browsing away from the wiki homepage and editting.

Anyone ??

MG ??



UPDATE:---

I have removed the reference MG made in pmwiki.php

Code: [Hide] [Select]
if (!defined('IN_ICYPHOENIX'))
{
header('Location: index.php');
}


I have had to take the code from index.php and insert it into the pmwiki.php file. with the ending of the index file at the bottom if you know what i mean MG.

i have included the new pmwiki file attached.

For those that are interested

PMWIKI can be found HERE

install it in a directory on the same level as IP

Download the attached pmwiki.php file and replace the one that came with the installation.

Find

Code: [Hide] [Select]
if (!defined('IP_ROOT_PATH')) define('IP_ROOT_PATH', '../ip/');


and correct the '../ip/' to point to your ip directory.

Set your config file found in yourwikihome/docs/sample-config and then save it as yourwikihome/local/config

yourwikihome is the name of the folder you have put the package into.

Lastly take the ipwiki.php file and put it in your IP root folder and edit it

Then all that remains is to create your wiki !!

Have fun anyone and MG thanks a bunch on the help ( even if you did do most of the work )

regards



UPDATE 2 :-

Hit a snag

Whet i edit a page and save it i get the

CBACK CrackerTracker has detected a potential attack on this site with a worm or exploit script so the Security System stopped the script.

message hows can i fix this ?


spydie [ Sun 11 Oct, 2009 22:56 ]
Post subject: Re: PM Wiki Integration With Icy Phoenix
check in crTracker log. witch file it is blocking and insert following code in the beginning of it

Code: [Hide]
  1. // CTracker_Ignore: File checked by human  
  2. define('MG_KILL_CTRACK', true);  


AndyGpy [ Sun 11 Oct, 2009 23:53 ]
Post subject: Re: PM Wiki Integration With Icy Phoenix
// CTracker_Ignore: File checked by human
define('CTRACKER_DISABLED', true);

is already in the offending file :-

Log :--- 2009/10/11 - 21:42 /ScotWiki/pmwiki.php?n=Site.SideBar?action=edit http://www.scotbird.co.uk/ScotWiki/...Bar?action=edit


spydie [ Mon 12 Oct, 2009 01:05 ]
Post subject: Re: PM Wiki Integration With Icy Phoenix
AndyGpy wrote: [View Post]
// CTracker_Ignore: File checked by human
define('CTRACKER_DISABLED', true);

is already in the offending file :-

Log :--- 2009/10/11 - 21:42 /ScotWiki/pmwiki.php?n=Site.SideBar?action=edit http://www.scotbird.co.uk/ScotWiki/...Bar?action=edit


If i´m not wrong you´ve got to use the code i posted, replacing the one you´ve got. Cause i don´t think that the one you used, is accepted bu icy.

just give it a try. it wan´t hurt.

it should be

Code: [Hide] [Select]
define('MG_KILL_CTRACK', true);


AndyGpy [ Mon 12 Oct, 2009 07:11 ]
Post subject: Re: PM Wiki Integration With Icy Phoenix
I take my hat of to you Spydie, it looks like MG got his code wrong, now i am getting worried he is heading for a nervious breakdown !! LOL

UPDATE 3 -- Thanks to Spydie,


Find the Line in pmwiki.php:-

Code: [Hide] [Select]
define('CTRACKER_DISABLED', true);


and replace with

Code: [Hide] [Select]
define('MG_KILL_CTRACK', true);


I have updated the download file to reflect the changes in pmwiki.php


Mighty Gorgon [ Mon 12 Oct, 2009 09:55 ]
Post subject: Re: PM Wiki Integration With Icy Phoenix
AndyGpy wrote: [View Post]
I take my hat of to you Spydie, it looks like MG got his code wrong, now i am getting worried he is heading for a nervious breakdown !! LOL

You are right... I'm having a breakdown!

If you check my first code I have posted the right CONSTANT, but when I tested the package on my local testing environment I had to use the new CONSTANT for latest development version, and that has been changed from MG_KILL_CTRACK which means nothing to CTRACKER_DISABLED which is self explaining.

Sorry for the error, I will remove my files and if everything is working, please create a new topic with full instructions and files to make PM Wiki work correctly.

Thanks.


AndyGpy [ Mon 12 Oct, 2009 18:09 ]
Post subject: Re: PM Wiki Integration With Icy Phoenix
MG

As soon as i have fully finished testing i will post , i am in the process of exploring just now, hate to put a topic up and not have a bit of knowledge about it first.

regards




Powered by Icy Phoenix