Textpattern CMS support forum
You are not logged in. Register | Login | Help
- Topics: Active | Unanswered
#1 2008-08-31 16:22:12
- Sono Juventino
- Member
- From: Skedsmo, Norway
- Registered: 2007-12-22
- Posts: 81
Trouble with plugin. Help appriciated
Hello
I have problems with a plugin coded by a friend of mine. The plugin work fine on his own server, but I just won’t work on my two own TXP instations. My problem is that the author currently is doing his military services, so he can’t sort out the problems before a couple of months.
I have compiled the plugin myself and installed it on two Txp-instalations. The first works admin-side, but gives me a php warning when activated, at index.php. The other instalation fails on the admin-side, so activating it leaves the admin panel blank.
What kind of information do I need to provide to get any help? I might give you access to both the authors TXP instalation and my own test version, but I really don’t know what you guys need. I’m able to understand some php myself, but I’ve not been able to track down what gives me these problems. Hope some of you can sort things out, because it’s really frustrating to see this plugin unactivated.
The plugin itself should really work, but maybe Php configuration is causing the errors? Would appriciate all help. :)
Thanks. Thomas.
Offline
Re: Trouble with plugin. Help appriciated
What kind of information do I need to provide to get any help?
The raw plugin code.
Offline
Re: Trouble with plugin. Help appriciated
For starters, a complete list of all the errors you get would be helpful.
Offline
#4 2008-08-31 17:06:37
- Sono Juventino
- Member
- From: Skedsmo, Norway
- Registered: 2007-12-22
- Posts: 81
Re: Trouble with plugin. Help appriciated
Raw plugin code: ( Remember <?php ?> before/after plugin code ofc.. ;) )
<?php $plugin['version'] = '0.1';
$plugin['author'] = 'Are Hjelt';
$plugin['uri'] = 'http://www.bareare.net/portfolio/';
$plugin['description'] = 'Integrate phpBB3';
$plugin['type'] = 1;
include_once('zem_tpl.php');
function kek_if($atts, $thing) {
global $kek, $kekBB;
$action = array_keys($atts);
$output = $kekBB->control($action[0]);
return parse(EvalElse($thing, $output));
}
function kek_phpbbintegrate() {
global $kek, $kekBB;
$kekBB = new kekBB();
$kekBB->integrate();
$kek->user = $kekBB->user();
$kek->comments = $kekBB->comments();
$kek->commentsInfo = $kekBB->commentsInfo();
$kek->path = $kekBB->path();
}
// Start profilebox functions
function kek_phpbbuser($atts) {
global $profile;
if (!empty($profile[$atts['info']])) {
return $profile[$atts['info']];
}
}
function kek_profilebox($atts) {
global $kek, $profile;
switch ($kek->user->data['username']) {
case 'Anonymous':
$output = '<form method="post" action="' . $kek->path . 'ucp.php?mode=login">' . parse_form('phpbblogin') . '</form>';
return $output;
break;
default:
$pmInfo = Array('Ingen nye meldinger', '1 ny melding');
if (isset($pmInfo[$kek->user->data['user_new_privmsg']])) {
$pms = $pmInfo[$kek->user->data['user_new_privmsg']];
}
else { // More than one new messages
$pms = $kek->user->data['user_new_privmsg'] . ' nye meldinger';
}
// print_r($kek->user);
$profile = Array('username' => $kek->user->data['username'],
'inboxlink' => $kek->path . 'ucp.php?i=pm&folder=inbox',
'messages' => $pms,
'postlink' => $kek->path . 'search.php?search_id=egosearch',
'logoutlink' => $kek->path . 'ucp.php?mode=logout&sid=' . $kek->user->data['session_id']);
return parse_form('profilebox');
break;
}
}
// End profilebox functions
// Start comment functions
function kek_comment($atts) {
global $comment;
if (!empty($comment[$atts['info']])) {
return $comment[$atts['info']];
}
}
function kek_comments_info($atts) {
global $kek, $kekBB;
$tid = $kekBB->getTid($GLOBALS['thisarticle']['kommentar lenke']);
$info = $kekBB->commentsInfo($GLOBALS['thisarticle']['thisid'], $tid);
return $info[$atts['type']];
}
function kek_comments($atts) {
global $kek, $comment;
if (empty($kek->comments)) {
return '';
}
$html = '';
foreach ($kek->comments as $post) {
$comment = Array('time' => $post['time'],
'text' => $post['text'],
'username' => $post['user']['username'],
'avatar' => $post['user']['avatar']);
$html .= parse_form('phpbb3_comments');
}
return $html;
}
// End comment functions
class kekBB {
function kekBB() {
// Get settings
$this->settings = Array('dbPrefix' => 'phpbb_',
'numCom' => '8',
'defaultAvatar' => 'http://bareare.net/work/juvenorge/files/defaultavatar.png',
'phpBBgroup' => 'Skribenter');
}
function user() {
global $user;
return $user;
}
function control($action) {
global $user, $db;
switch ($action) {
case 'user':
$sql = 'SELECT group_id FROM ' . $this->settings['dbPrefix'] . 'groups WHERE group_name="' . $this->settings['phpBBgroup'] . '"';
$result = $db->sql_query($sql);
$row = $db->sql_fetchrow($result);
$gid = $row['group_id'];
$sql = 'SELECT group_id FROM ' . $this->settings['dbPrefix'] . 'user_group WHERE group_id="' . $gid . '" AND user_id="' .
$user->data['user_id'] . '"';
$result = $db->sql_query($sql);
$row = $db->sql_fetchrow($result);
if (!empty($row['group_id'])) {
return True;
}
break;
case 'comments':
if (is_numeric($this->getTid($GLOBALS['thisarticle']['kommentar lenke']))) {
return True;
}
break;
}
return False; // default
}
function comments() {
$aid = $GLOBALS['thisarticle']['thisid'];
$tid = $this->getTid($GLOBALS['thisarticle']['kommentar lenke']);
if (empty($tid)) {
return False;
}
else {
return $this->getPosts($tid);
}
}
function commentsInfo($aid=False, $tid=False) {
global $db;
if (empty($aid)) {
$aid = $GLOBALS['thisarticle']['thisid'];
}
if (empty($tid)) {
$tid = $this->getTid($GLOBALS['thisarticle']['kommentar lenke']);
}
$info['link'] = $GLOBALS['thisarticle']['kommentar lenke'];
$sql = 'SELECT topic_replies FROM ' . $this->settings['dbPrefix'] . 'topics WHERE topic_id="' . $tid . '"';
$result = $db->sql_query($sql);
$row = $db->sql_fetchrow($result);
$num = $row['topic_replies'];
if ($num == 0) {
$info['num'] = 'Ingen kommentarer';
}
elseif ($num == 1) {
$info['num'] = '1 kommentar';
}
else {
$info['num'] = $num . ' kommentarer';
}
return $info;
}
function parseBBcode($str) {
$search = Array('/\[url\=(.*?)\](.*?)\[\/url\]/is');
$replace = Array('<a href="$1">$2</a>');
$str = preg_replace($search, $replace, $str);
preg_match_all('/\[quote/i', $str, $matches);
$num = count($matches[0]);
$search = Array('/\[quote\=(.*?)\](.*?)\[\/quote\]/is');
$replace = Array('<blockquote>$2</blockquote>');
for ($i=0;$i<$num;$i++) {
$str = preg_replace($search, $replace, $str);
}
return $str;
}
function getPosts($tid) {
global $db;
$months = Array('1' => 'jan',
'2' => 'feb',
'3' => 'mar',
'4' => 'apr',
'5' => 'mai',
'6' => 'jun',
'7' => 'jul',
'8' => 'aug',
'9' => 'sep',
'10' => 'okt',
'11' => 'nov',
'12' => 'des');
$sql = 'SELECT post_subject, post_text, bbcode_uid, bbcode_bitfield, poster_id, post_id, post_time FROM ' .
$this->settings['dbPrefix'] . 'posts WHERE topic_id="' . $tid . '" AND post_id!="' . $tid . '" ORDER BY post_time';
$result = $db->sql_query_limit($sql, $this->settings['numCom']);
$posts = Array();
$i = 0;
$allow_bbcode = 1;
$allow_smilies = 1;
$allow_urls = 1;
while ($row = $db->sql_fetchrow($result)) {
$flags = (($allow_bbcode) ? OPTION_FLAG_BBCODE : 0) + (($allow_smilies) ? OPTION_FLAG_SMILIES : 0) + (($allow_urls) ? OPTION_FLAG_LINKS : 0);
$posts[$i] = Array('subject' => $row['post_subject'],
'text' => generate_text_for_display($row['post_text'], $row['bbcode_uid'], $row['bbcode_bitfield'], 7));
$month = date('n', $row['post_time']);
$day = date('j', $row['post_time']);
$posts[$i]['time'] = $day . '. ' . $months[$month] . date(' y - H.i', $row['post_time']);
if ($row['poster_id'] == '1') { // Anonymous user
$sql = 'SELECT post_username FROM ' . $this->settings['dbPrefix'] . 'posts WHERE post_id="' . $row['post_id'] . '"';
$data = $db->sql_query($sql);
$row1 = $db->sql_fetchrow($data);
$posts[$i]['user'] = Array('username' => $row1['post_username'],
'avatar' => '<img class="avatar" src="' . $this->settings['defaultAvatar'] . '" ' .
'title="Standard avatar" alt="Avatar" />');
}
else {
$sql = 'SELECT username, user_avatar, user_avatar_type, user_avatar_width, user_avatar_height ' .
'FROM ' . $this->settings['dbPrefix'] . 'users WHERE user_id="' . $row['poster_id'] . '"';
$data = $db->sql_query($sql);
$row1 = $db->sql_fetchrow($data);
if ($row1['user_avatar'] == '') { // The user does not have an avatar, show default
$avatar = '<img class="avatar" src="' . $this->settings['defaultAvatar'] . '" title="Standard avatar" alt="Avatar" />';
}
else {
$avatar = $this->get_avatar($row1['user_avatar'], $row1['user_avatar_type'],
$row1['user_avatar_width'], $row1['user_avatar_height']);
}
$posts[$i]['user'] = Array('username' => '<a href="' . $this->path() .
'memberlist.php?mode=viewprofile&u=' . $row['poster_id'] . '">' . $row1['username'] . '</a>',
'avatar' => $avatar);
}
$i++;
}
return $posts;
}
function getTid($url) {
$tmp = explode('t=', $url);
$tid = $tmp[1];
if (is_numeric($tid)) {
return $tid;
}
else {
return False;
}
}
function get_avatar($avatar, $avatar_type, $avatar_width, $avatar_height, $alt = 'Avatar') {
global $user, $config, $phpbb_root_path, $phpEx;
if (empty($avatar) || !$avatar_type) {
return '';
}
$avatar_img = '';
switch ($avatar_type) {
case AVATAR_UPLOAD:
$avatar_img = $phpbb_root_path . "download/file.$phpEx?avatar=";
break;
case AVATAR_GALLERY:
$avatar_img = $phpbb_root_path . $config['avatar_gallery_path'] . '/';
break;
}
$avatar_img .= $avatar;
return '<img src="http://' . $GLOBALS['prefs']['siteurl'] . '/' . $avatar_img . '" class="avatar" ' .
'alt="' . ((!empty($user->lang[$alt])) ? $user->lang[$alt] : $alt) . '" />';
}
function integrate() {
global $phpbb_root_path, $phpEx, $user, $db, $config, $cache, $template;
define('IN_PHPBB', true);
$phpbb_root_path = './forum/';
$phpEx = substr(strrchr(__FILE__, '.'), 1);
include($phpbb_root_path . 'common.' . $phpEx);
$user->session_begin();
$user->setup();
$auth->acl($user->data);
}
function path() {
$sql = 'SELECT val FROM textpattern_txp_prefs WHERE name="kek_phpbb3_path"';
$result = safe_query($sql);
$a = mysql_num_rows($result);
if ($a == 0) { // First time setup
$path = './forum/';
$sql = 'INSERT INTO textpattern_txp_prefs (name, val) VALUES ("kek_phpbb3_path", "' . $path . '")';
safe_query($sql);
}
else {
$row = mysql_fetch_array($result);
$path = $row['val'];
}
return 'http://' . $GLOBALS['prefs']['siteurl'] . '/' . $path;
}
}
// Admin section
if (txpinterface == 'admin') {
$event = 'phpBB3';
add_privs($event, '1,2,6');
register_tab('admin', $event, 'phpBB3 Settings');
register_callback('kek_adminPage', $event);
}?>
Other info:
Authors site
Juvenorge.com error: hmzdeb ClassIntegrarteNULL
Fatal error: Call to a member function session_begin() on a non-object in /mounted-storage/home60a/sub001/sc15504-VBWD/thomasml/juvenorge/textpattern/lib/txplib_misc.php(574) : eval()’d code on line 324
I would perfer not to include usernames and passwords in this post. I’ve sent PMs to the ones that has responded.
(And thanks for the Textile help)
Last edited by Sono Juventino (2008-09-01 13:43:49)
Offline
Re: Trouble with plugin. Help appriciated
Sono Juventino wrote:
code not showing properly on the forum …
Just stick
bc.. code begins here
and when you’re ready to continue with normal text after the code block, signal a return to a paragraph with
p. and here's the remaining normal text beneath the code.
EDIT: removed duplicate code now that post above has been corrected. Just left the “how to” standing.
Last edited by jakob (2008-09-04 15:57:15)
TXP Builders – finely-crafted code, design and txp
Online
#6 2008-09-03 09:17:37
- Sono Juventino
- Member
- From: Skedsmo, Norway
- Registered: 2007-12-22
- Posts: 81
Re: Trouble with plugin. Help appriciated
Have any of you found the plugins problem? I have included raw plugin code, Error messages and other info you needed in the post above.
Hope we can solve this problem together. Thomas. :)
Offline
Re: Trouble with plugin. Help appriciated
One website doesn’t have the plugin installed. The other doesn’t allow login (invalid user/pass combination), although I did manage to login once and saw at least one warning at the bottom due to a malfunctioning plugin.
Offline
#8 2008-09-03 13:57:13
- Sono Juventino
- Member
- From: Skedsmo, Norway
- Registered: 2007-12-22
- Posts: 81
Re: Trouble with plugin. Help appriciated
Sorry about that, ruud. I tried to install the plugin on a third location. The server uses all recomended php settings etc.
All I get is this message:
Fatal error: Call to a member function getTid() on a non-object in /home/users/juvenorg/www/textpattern/lib/txplib_misc.php(574) : eval()’d code on line 81
You can take a look here: http://juvenorge.com.s9.subsys.net/
Last edited by Sono Juventino (2008-09-03 14:34:07)
Offline
#9 2008-09-03 14:31:11
- Sono Juventino
- Member
- From: Skedsmo, Norway
- Registered: 2007-12-22
- Posts: 81
Re: Trouble with plugin. Help appriciated
double post
Last edited by Sono Juventino (2008-09-03 14:31:50)
Offline
#10 2008-09-04 11:09:42
- Sono Juventino
- Member
- From: Skedsmo, Norway
- Registered: 2007-12-22
- Posts: 81
Re: Trouble with plugin. Help appriciated
The plugin code is written two times above. :)
Offline
Re: Trouble with plugin. Help appriciated
I’m guessing both errors are caused because the kek_phpbbintegrate function wasn’t called. Did you use the <txp:kek_phpbbintegrate /> tag in the page templates before using any of the other tags the plugin provides?
Offline
#12 2008-09-05 16:55:38
- Sono Juventino
- Member
- From: Skedsmo, Norway
- Registered: 2007-12-22
- Posts: 81
Re: Trouble with plugin. Help appriciated
<txp:kek_phpbbintegrate /> is in the body tag, before any tags related to the plugin. :(
Offline