Welcome to Geeklog, Anonymous Thursday, March 28 2024 @ 10:05 am EDT

Geeklog Forums

Plug-ins fallign apart


Status: offline

profetas

Forum User
Newbie
Registered: 05/05/04
Posts: 5
Hi I am facing a strage problem.

yesterday I updated my apache from 1.3.xx to 2.
I also installed php and perl.

but when I load my gl the title (link) of the plug-ins in the admin menu diappeared.
its is only (N/A) I tested the plug-ins they are working. that means that mysql, php is fine.

is there any kind of dependence when installing a plug-in to the apache conf files?
or anything that could cause that?

Thanks for the help
 Quote

Status: offline

profetas

Forum User
Newbie
Registered: 05/05/04
Posts: 5
that is what I get

Content Syndication (1)
Plugins (8)
(N/A)
(N/A)
(N/A)
(N/A)
(N/A)
DB Backups (N/A)
GL Version Test (1.3)

(N/A) i nstead of the plug-ins
but when I stop the new apache and load the old one it is gonna work fine
]
 Quote

Status: offline

exdeath

Forum User
Junior
Registered: 02/13/04
Posts: 23
I have the same problem under php5 and apache 2.
I hacked the libcommon and manually copy/pasted code from the default GL admin panel links and edited the code to work with the plugins i have installed.
It would be good if the GL team gave this bug a look.
 Quote

Profetas

Anonymous
I want to understand why this happens.

why it works for one apache and it don't work for the other apache?
 Quote

profetas

Anonymous
I think the proble might be here
for( $i = 1; $i {
$plg = current( $plugin_options );

$adminmenu->set_var( 'option_url', $plg->adminurl );
$adminmenu->set_var( 'option_label', $plg->adminlabel );

if( empty( $plg->numsubmissions ))
{
$adminmenu->set_var( 'option_count', '0' );
}
else
{
$adminmenu->set_var( 'option_count', $plg->numsubmissions );
}

$retval .= $adminmenu->parse( 'item',( $thisUrl == $plg->adminurl ) ? 'current' : 'option', true );

next( $plugin_options );
}
 Quote

Status: offline

exdeath

Forum User
Junior
Registered: 02/13/04
Posts: 23
Besides that (i just remebered) the problem is not only for the admin menu, but for user menu and the /admin/moderation.php menu.
 Quote

Profetas

Anonymous
I am almost there

I found that function PLG_getAdminOptions() is only returnin the last row.

man this is the first time I play with PHP.

if you print the option on the function PLG_getAdminOptions() it will work ok but when you print it on the other side it will only have the last option


 Quote

Profetas

Anonymous
I have fixed it. if you want the code I will post here

 Quote

Status: offline

exdeath

Forum User
Junior
Registered: 02/13/04
Posts: 23
You got it working?
Post it please and sign the changes you've made. Maybe i can adapt it to the user menu and moderation php if you still haven't done it.
 Quote

Profetas

Anonymous
In the file lib-plugins.php you find the function
function PLG_getAdminOptions() and replace for this thisi will deal with the admin menu

Text Formatted Code
//--------------------------FIXED---------------------------///

function PLG_getAdminOptions()
{
    global $_TABLES;
 


    $result = DB_query("SELECT pi_name FROM {$_TABLES['plugins']} WHERE pi_enabled = 1");
    $nrows = DB_numRows($result);
    $plugin = new Plugin();
    $counter = 0;
    for ($i = 1; $i <= $nrows; $i++) {
        $A = DB_fetchArray($result);
        $function = 'plugin_getadminoption_' . $A['pi_name'];
        if (function_exists($function)) {
            list($plugin->adminlabel, $plugin->adminurl, $plugin->numsubmissions) = $function();
           
    $options_plg [$i][1]= $plugin->adminlabel;
    $options_plg [$i][2]= $plugin->adminurl;
    $options_plg [$i][3]= $plugin->numsubmissions;

                if (!empty ($plugin->adminlabel) && !empty ($plugin->adminurl)) {
                $counter++;
                $plgresults[$counter] = $plugin;
            }
         }

    }
    return $options_plg;
}

//--------------------------FIXED---------------------------///

 





then you find function PLG_getUserOptions() at the same file
and replcae for lig-plugins.php

Text Formatted Code


//--------------------------FIXED---------------------------///

function PLG_getUserOptions()
{
   
 global $_TABLES;

    $plgresults = array ();

    $result = DB_query("SELECT pi_name FROM {$_TABLES['plugins']} WHERE pi_enabled = 1");
    $nrows = DB_numRows($result);
 
    $plugin = new Plugin();
    $y=1;
    for ($i = 1; $i <= $nrows; $i++)
     {
        $A = DB_fetchArray($result);
        $function = 'plugin_getuseroption_' . $A['pi_name'];
     
       if (function_exists($function))
       {
        list($plugin->adminlabel, $plugin->adminurl, $plugin->numsubmissions) = $function();
        }
      if (!empty($plugin->adminlabel) && !empty($plugin->adminurl))
       {
         $options_plg[$y][1]= $plugin->adminlabel;
         $options_plg[$y][2]= $plugin->adminurl;
         $options_plg[$y][3]= $plugin->numsubmissions;
         $y++;

       }
         
       }
     
    return $options_plg;
}
//--------------------------FIXED---------------------------///

 




NOW you go to lib-common.php and find the
function COM_userMenu and replace by the following
I have only changes one part but I move things around so I will give you the entire function

Text Formatted Code

function COM_userMenu( $help='', $title='' )
{
    global $_TABLES, $_USER, $_CONF, $LANG01, $HTTP_SERVER_VARS;

    $retval = '';

    if( $_USER['uid'] > 1 )
    {
        $usermenu = new Template( $_CONF['path_layout'] );
        $usermenu->set_file( array( 'option' => 'useroption.thtml',
                                    'current' => 'useroption_off.thtml' ));
        $usermenu->set_var( 'site_url', $_CONF['site_url'] );
        $usermenu->set_var( 'layout_url', $_CONF['layout_url'] );
        $usermenu->set_var( 'block_name', str_replace( '_', '-', 'user_block' ));

        if( empty( $title ))
        {
            $title = DB_getItem( $_TABLES['blocks'], 'title', "name='user_block'" );
        }

        // what's our current URL?
        $thisUrl = $HTTP_SERVER_VARS['SCRIPT_URI'];
        if( empty( $thisUrl ))
        {
            $thisUrl = $HTTP_SERVER_VARS['DOCUMENT_URI'];
        }
        if( !empty( $thisUrl ) && !empty( $HTTP_SERVER_VARS['QUERY_STRING'] ))
        {
            $thisUrl .= '?' . $HTTP_SERVER_VARS['QUERY_STRING'];
        }
        if( empty( $thisUrl ))
        {
            $requestUri = $HTTP_SERVER_VARS['REQUEST_URI'];
            if( empty( $HTTP_SERVER_VARS['REQUEST_URI'] ))
            {
                $requestUri = $HTTP_SERVER_VARS['SCRIPT_NAME'];
                if( !empty( $HTTP_SERVER_VARS['QUERY_STRING'] ))
                {
                    $requestUri .= '?' . $HTTP_SERVER_VARS['QUERY_STRING'];    
                }
            }

            $firstslash = strpos( $_CONF['site_url'], '/' );
            if( $firstslash === false )
            {
                // special case - assume it's okay
                $thisUrl = $_CONF['site_url'] . $requestUri;
            }
            else if( $firstslash + 1 == strrpos( $_CONF['site_url'], '/' ))
            {
                // site is in the document root
                $thisUrl = $_CONF['site_url'] . $requestUri;
            }
            else
            {
                // extract server name first
                $pos = strpos( $_CONF['site_url'], '/', $firstslash + 2 );
                $thisUrl = substr( $_CONF['site_url'], 0, $pos ) . $requestUri;
            }
        }

        $retval .= COM_startBlock( $title, $help,
                           COM_getBlockTemplate( 'user_block', 'header' ));

        if( $_CONF['personalcalendars'] == 1 )
        {
            $url = $_CONF['site_url'] . '/calendar.php?mode=personal';
            $usermenu->set_var( 'option_label', $LANG01[66] );
            $usermenu->set_var( 'option_count', '' );
            $usermenu->set_var( 'option_url', $url );
            if( $thisUrl == $url )
            {
                $retval .= $usermenu->parse( 'item', 'current' );
            }
            else
            {
                $retval .= $usermenu->parse( 'item', 'option' );
            }
        }

        // This function will show the user options for all installed plugins
        // (if any)
//--------------------------FIXED---------------------------///

        $plugin_options = PLG_getUserOptions();
        $nrows = count( $plugin_options );

 
        for( $i = 1; $i <= $nrows; $i++ )
        {
 
            $plg_lbl =  $plugin_options[$i][1] ;
            $plg_url =  $plugin_options[$i][2] ;
            $plg_sub =  $plugin_options[$i][3] ;
               
 
           
 
            if( !empty( $plg_sub ))
            {
                $usermenu->set_var( 'option_count', '(' . $plg_sub . ')' );
            }
            else
            {
                $usermenu->set_var( 'option_count', '' );
            }

            $usermenu->set_var( 'option_url', $plg_url );
            $usermenu->set_var( 'option_label', $plg_lbl );
            if( $thisUrl == $plg_url )
            {
                $retval .= $usermenu->parse( 'item', 'current' );
            }
            else
            {
                $retval .= $usermenu->parse( 'item', 'option' );
            }
            next( $plugin_options );
       }
//--------------------------FIXED---------------------------///


 



The same for the admin menu this function is right after the users'
find the COM_adminMenu and replace


Text Formatted Code

function COM_adminMenu( $help = '', $title = '' )
{
    global $_TABLES, $_USER, $_CONF, $LANG01, $HTTP_SERVER_VARS;

    $retval = '';

    if( empty( $_USER['username'] ))
    {
        return $retval;
    }


    if( SEC_isModerator() OR SEC_hasrights( 'story.edit,block.edit,topic.edit,link.edit,event.edit,poll.edit,user.edit,plugin.edit,user.mail', 'OR' ) OR ( $nrows > 0 ))
    {
        // what's our current URL?
        $thisUrl = $HTTP_SERVER_VARS['SCRIPT_URI'];
        if( empty( $thisUrl ))
        {
            $thisUrl = $HTTP_SERVER_VARS['DOCUMENT_URI'];
        }
        if( !empty( $thisUrl ) && !empty( $HTTP_SERVER_VARS['QUERY_STRING'] ))
        {
            $thisUrl .= '?' . $HTTP_SERVER_VARS['QUERY_STRING'];
        }
        if( empty( $thisUrl ))
        {
            $requestUri = $HTTP_SERVER_VARS['REQUEST_URI'];
            if( empty( $HTTP_SERVER_VARS['REQUEST_URI'] ))
            {
                $requestUri = $HTTP_SERVER_VARS['SCRIPT_NAME'];
                if( !empty( $HTTP_SERVER_VARS['QUERY_STRING'] ))
                {
                    $requestUri .= '?' . $HTTP_SERVER_VARS['QUERY_STRING'];    
                }
            }

            $firstslash = strpos( $_CONF['site_url'], '/' );
            if( $firstslash === false )
            {
                // special case - assume it's okay
                $thisUrl = $_CONF['site_url'] . $requestUri;
            }
            else if( $firstslash + 1 == strrpos( $_CONF['site_url'], '/' ))
            {
                // site is in the document root
                $thisUrl = $_CONF['site_url'] . $requestUri;
            }
            else
            {
                // extract server name first
                $pos = strpos( $_CONF['site_url'], '/', $firstslash + 2 );
                $thisUrl = substr( $_CONF['site_url'], 0, $pos ) . $requestUri;
            }
        }

        $adminmenu = new Template( $_CONF['path_layout'] );
        $adminmenu->set_file( array( 'option' => 'adminoption.thtml',
                                     'current' => 'adminoption_off.thtml' ));
        $adminmenu->set_var( 'site_url', $_CONF['site_url'] );
        $adminmenu->set_var( 'layout_url', $_CONF['layout_url'] );
        $adminmenu->set_var( 'block_name', str_replace( '_', '-', 'admin_block' ));

        if( empty( $title ))
        {
            $title = DB_getItem( $_TABLES['blocks'], 'title',"name = 'admin_block'" );
        }

        $retval .= COM_startBlock( $title, $help, COM_getBlockTemplate( 'admin_block', 'header' ));

        $topicsql = '';
       if( SEC_isModerator() || SEC_hasrights( 'story.edit' ))
        {
            $tresult = DB_query( "SELECT tid FROM {$_TABLES['topics']}". COM_getPermSQL() );
            $trows = DB_numRows( $tresult );
            if( $trows > 0 )
            {
                $tids = array();
                for( $i = 0; $i < $trows; $i++ )
                {
                   $T = DB_fetchArray( $tresult );
                   $tids[] = $T['tid'];
                }
                if( sizeof( $tids ) > 0 )
                {
                    $topicsql = " (tid IN ('" . implode( "','", $tids ) . "'))";
                }
            }
        }

        if( SEC_isModerator()  || (( $_CONF['usersubmission'] == 1 ) && SEC_hasRights( 'user.edit,user.delete' )))
        {
            $num = 0;

            if( SEC_hasrights( 'story.edit' ))
            {
                if( empty( $topicsql ))
                {
                    $num += DB_count( $_TABLES['storysubmission'] );
                }
                else
                {
                    $sresult = DB_query( "SELECT COUNT(*) AS count FROM {$_TABLES['storysubmission']} WHERE" . $topicsql );
                    $S = DB_fetchArray( $sresult );
                    $num += $S['count'];
                }

                if( $_CONF['listdraftstories'] == 1 )
                {
                    $sql = "SELECT COUNT(*) AS count FROM {$_TABLES['stories']} WHERE (draft_flag = 1)";
                    if( !empty( $topicsql ))
                    {
                        $sql .= ' AND' . $topicsql;
                    }
                    $result = DB_query( $sql . COM_getPermSQL( 'AND', 0, 3 ));
                    $A = DB_fetchArray( $result );
                    $num += $A['count'];
                }
            }

            if( SEC_hasrights( 'event.edit' ))
            {
                $num += DB_count ($_TABLES['eventsubmission'] );
            }

            if( SEC_hasrights( 'link.edit' ))
            {
                $num += DB_count( $_TABLES['linksubmission'] );
            }

            if( $_CONF['usersubmission'] == 1 )
            {
                if( SEC_hasrights( 'user.edit' ) && SEC_hasrights( 'user.delete' ))
                {
                    $emptypwd = md5( '' );
                    $num += DB_count( $_TABLES['users'], 'passwd', $emptypwd );
                }
            }

            // now handle submissions for plugins
  $num = $num + PLG_getSubmissionCount();

            $url = $_CONF['site_admin_url'] . '/moderation.php';
            $adminmenu->set_var( 'option_url', $url );
            $adminmenu->set_var( 'option_label', $LANG01[10] );
            $adminmenu->set_var( 'option_count', $num );

            $retval .= $adminmenu->parse( 'item',
                    ( $thisUrl == $url ) ? 'current' : 'option' );
        }

        if( SEC_hasrights( 'story.edit' ))
        {
            $url = $_CONF['site_admin_url'] . '/story.php';
            $adminmenu->set_var( 'option_url', $url );
            $adminmenu->set_var( 'option_label', $LANG01[11] );
            if( empty( $topicsql ))
            {
                $numstories = DB_count( $_TABLES['stories'] );
            }
            else
            {
                $nresult = DB_query( "SELECT COUNT(*) AS count from {$_TABLES['stories']} WHERE" . $topicsql );
                $N = DB_fetchArray( $nresult );
                $numstories = $N['count'];
            }
            $adminmenu->set_var( 'option_count', $numstories );
            $retval .= $adminmenu->parse( 'item',
                    ( $thisUrl == $url ) ? 'current' : 'option' );
        }

        if( SEC_hasrights( 'block.edit' ))
        {
            $url = $_CONF['site_admin_url'] . '/block.php';
            $adminmenu->set_var( 'option_url', $url );
            $adminmenu->set_var( 'option_label', $LANG01[12] );
            $adminmenu->set_var( 'option_count', DB_count( $_TABLES['blocks'] ));

            $retval .= $adminmenu->parse( 'item',
                    ( $thisUrl == $url ) ? 'current' : 'option' );
 }

        if( SEC_hasrights( 'topic.edit' ))
        {
            $url = $_CONF['site_admin_url'] . '/topic.php';
            $adminmenu->set_var( 'option_url', $url );
            $adminmenu->set_var( 'option_label', $LANG01[13] );
            $adminmenu->set_var( 'option_count', DB_count( $_TABLES['topics'] ));

            $retval .= $adminmenu->parse( 'item',
                    ( $thisUrl == $url ) ? 'current' : 'option' );
        }

        if( SEC_hasrights( 'link.edit' ))
        {
            $url = $_CONF['site_admin_url'] . '/link.php';
            $adminmenu->set_var( 'option_url', $url );
            $adminmenu->set_var( 'option_label', $LANG01[14] );
            $adminmenu->set_var( 'option_count', DB_count( $_TABLES['links'] ));

            $retval .= $adminmenu->parse( 'item',
                    ( $thisUrl == $url ) ? 'current' : 'option' );
        }

        if( SEC_hasrights( 'event.edit' ))
        {
            $url = $_CONF['site_admin_url'] . '/event.php';
            $adminmenu->set_var( 'option_url', $url );
            $adminmenu->set_var( 'option_label', $LANG01[15] );
            $adminmenu->set_var( 'option_count', DB_count( $_TABLES['events'] ));

            $retval .= $adminmenu->parse( 'item',
                    ( $thisUrl == $url ) ? 'current' : 'option' );
        }

        if( SEC_hasrights( 'poll.edit' ))
        {
            $url = $_CONF['site_admin_url'] . '/poll.php';
            $adminmenu->set_var( 'option_url', $url );
            $adminmenu->set_var( 'option_label', $LANG01[16] );
            $adminmenu->set_var( 'option_count', DB_count( $_TABLES['pollquestions'] ));

            $retval .= $adminmenu->parse( 'item',
                    ( $thisUrl == $url ) ? 'current' : 'option' );
        }

        if( SEC_hasrights( 'user.edit' ))
        {
            $url = $_CONF['site_admin_url'] . '/user.php';
            $adminmenu->set_var( 'option_url', $url );
            $adminmenu->set_var( 'option_label', $LANG01[17] );
            $adminmenu->set_var( 'option_count', ( DB_count( $_TABLES['users'] ) -1 ));

            $retval .= $adminmenu->parse( 'item',
                    ( $thisUrl == $url ) ? 'current' : 'option' );
        }

        if( SEC_hasrights( 'group.edit' ))
        {
            $url = $_CONF['site_admin_url'] . '/group.php';
            $adminmenu->set_var( 'option_url', $url );
            $adminmenu->set_var( 'option_label', $LANG01[96] );
            $adminmenu->set_var( 'option_count', DB_count( $_TABLES['groups'] ));

            $retval .= $adminmenu->parse( 'item',
                    ( $thisUrl == $url ) ? 'current' : 'option' );
        }

        if( SEC_hasrights( 'user.mail' ))
        {
            $url = $_CONF['site_admin_url'] . '/mail.php';
            $adminmenu->set_var( 'option_url', $url );
            $adminmenu->set_var( 'option_label', $LANG01[105] );
            $adminmenu->set_var( 'option_count', 'N/A' );

            $retval .= $adminmenu->parse( 'item',
                    ( $thisUrl == $url ) ? 'current' : 'option' );
        }

        if(( $_CONF['backend'] == 1 ) && SEC_inGroup( 'Root' ))
        {
            $url = $_CONF['site_admin_url'] . '/syndication.php';
            $adminmenu->set_var( 'option_url', $url );
            $adminmenu->set_var( 'option_label', $LANG01[38] );
            $count = DB_count( $_TABLES['syndication'] );
            $adminmenu->set_var( 'option_count', $count );

            $retval .= $adminmenu->parse( 'item',
                    ( $thisUrl == $url ) ? 'current' : 'option' );
        }

        if( SEC_hasrights( 'plugin.edit' ))
        {
            $url = $_CONF['site_admin_url'] . '/plugins.php';
            $adminmenu->set_var( 'option_url', $url );
            $adminmenu->set_var( 'option_label', $LANG01[77] );
            $adminmenu->set_var( 'option_count', DB_count( $_TABLES['plugins'] ));

            $retval .= $adminmenu->parse( 'item',
                    ( $thisUrl == $url ) ? 'current' : 'option' );
        }
///--------------------------FIXED---------------------------///

  $plugin_options = PLG_getAdminOptions();
    $nrows = count( $plugin_options );


        // This will show the admin options for all installed plugins (if any)
        //--------------------------------------------------------------------//
        for( $i = 1; $i <= $nrows; $i++ )
        {

           
            $plg_lbl =  $plugin_options[$i][1] ;
            $plg_url =  $plugin_options[$i][2] ;
            $plg_sub =  $plugin_options[$i][3] ;


          if (SEC_inGroup( 'Root' ))
              {
                $url = $_CONF['site_admin_url'] .'item' .$plugin->adminurl;
                $adminmenu->set_var( 'option_url', $plg_url );
                $adminmenu->set_var( 'option_label', $plg_lbl );
                $adminmenu->set_var( 'option_count', $plg_sub );
                $retval .= $adminmenu->parse( 'item',( $thisUrl == $url ) ? 'current' : 'option' );
                next( $plugin_options );
              }

}
//--------------------------FIXED---------------------------///

           if( $_CONF['allow_mysqldump'] == 1 AND SEC_inGroup( 'Root' ))
              {
                $url = $_CONF['site_admin_url'] . '/database.php';
                $adminmenu->set_var( 'option_url', $url );
                $adminmenu->set_var( 'option_label', $LANG01[103] );
                $adminmenu->set_var( 'option_count', 'N/A' );
                $retval .= $adminmenu->parse( 'item',( $thisUrl == $url ) ? 'current' : 'option' );
              }

        if( SEC_inGroup( 'Root' ))
        {
            $adminmenu->set_var( 'option_url',
               'http://www.geeklog.net/versionchecker.php?version=' . VERSION );
            $adminmenu->set_var( 'option_label', $LANG01[107] );
            $adminmenu->set_var( 'option_count', VERSION );

            $retval .= $adminmenu->parse( 'item', 'option' );
        }

        $retval .= COM_endBlock( COM_getBlockTemplate( 'admin_block', 'footer' ));
    }

    return $retval;
}


 




Man I have no experience with PHP, this was my first time ever, I found thet the functions on the lib-plugins wasn't returning correctlly so I create a multi dimensional array and insteade of returning a pointer it returns a array.

I will also place these file under my server if you want to download them or l. let me now if it worked.

Profetas
 Quote

Status: offline

exdeath

Forum User
Junior
Registered: 02/13/04
Posts: 23
Thanks a lot, your code sure beats hacking libcommon each time i install a plugin!!
I'm currently on exams so i'll test it on wednsday and give you some feedback.
 Quote

Profetas

Anonymous
Is much easier just to replace the files and change the pach of your config.php
here are the files

http://www.hackersdobrasil.com.br/downloads/Tutorials/Assembly/lib-common.php
http://www.hackersdobrasil.com.br/downloads/Tutorials/Assembly/lib-plugins.php

I have also made some more changes the function befor woulf print the last option twice in some cases. so I added some more code
 Quote

Status: offline

exdeath

Forum User
Junior
Registered: 02/13/04
Posts: 23
Parse error: parse error, unexpected $ in /pathtopublick_html/lib-common.php on line 5322
When just replacing your changes on lib-common COM_adminMenu.
When i replaced the entire function it worked.

/admin/moderation.php continues to mess up.
 Quote

profetas

Anonymous
try to replace the files. and don't forget to change the path for you config.php ans lib-common.php will have the path for the config file.
maybe thta is the error.

 Quote

All times are EDT. The time is now 10:05 am.

  • Normal Topic
  • Sticky Topic
  • Locked Topic
  • New Post
  • Sticky Topic W/ New Post
  • Locked Topic W/ New Post
  •  View Anonymous Posts
  •  Able to post
  •  Filtered HTML Allowed
  •  Censored Content