Openfire PHP help

Hello,

I am trying to make a site where users can create events and post pictures and for each event i would like to also have a chat going on. So what would be the best way to communicate with openfire to create a new room from within the create event php file.

I can hink of two ways:

  1. Just edit the db to make the room

or

  1. connect to the openfire server using admin credentials

set room options

create the room

The db way seems easier but i dont know if it is the best way or if it will cause problems later on.

I dont know how i would do the second option. Any links to tutorial or code samples would be appreciated.

Also if there is another way to do this please let me know (such as javvascript or something)

Thanks

I’m not a developer, but after reading these forums for some years it seems that editing database directly is not a good option (especially with the embedded database) as Openfire is using caches a lot and then writes them into db after some time interval. So editing db can mess things up after Openfire flushes its changes into db. It can overwrite your changes. Second option doesn’t sound good to me from a security standpoint. Giving some script Openfire’s admin rights seems dangerous. I can’t give you any samples, all i know it’s that you should probably create some serviceprovider to hook into Openfire’s APIs, probably you will need a plugin on the Openfire side (java one). Not much help i kow, but still.

I found this thread http://community.igniterealtime.org/message/178014#178014 and tried to use the scripts however exception is thown.

Exception:

java.lang.NullPointerException
     at org.jivesoftware.openfire.muc.MultiUserChatManager.getMultiUserChatService(MultiUserChatManager.java:316)
     at org.jivesoftware.openfire.admin.muc_002droom_002dedit_002dform_jsp._jspService(muc_002droom_002dedit_002dform_jsp.java:178)
     at org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:97)
     at javax.servlet.http.HttpServlet.service(HttpServlet.java:820)
     at org.mortbay.jetty.servlet.ServletHolder.handle(ServletHolder.java:487)
     at org.mortbay.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1093)
     at com.opensymphony.module.sitemesh.filter.PageFilter.parsePage(PageFilter.java:118)
     at com.opensymphony.module.sitemesh.filter.PageFilter.doFilter(PageFilter.java:52)
     at org.mortbay.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1084)
     at org.jivesoftware.util.LocaleFilter.doFilter(LocaleFilter.java:66)
     at org.mortbay.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1084)
     at org.jivesoftware.util.SetCharacterEncodingFilter.doFilter(SetCharacterEncodingFilter.java:42)
     at org.mortbay.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1084)
     at org.jivesoftware.admin.PluginFilter.doFilter(PluginFilter.java:70)
     at org.mortbay.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1084)
     at org.jivesoftware.admin.AuthCheckFilter.doFilter(AuthCheckFilter.java:146)
     at org.mortbay.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1084)
     at org.mortbay.jetty.servlet.ServletHandler.handle(ServletHandler.java:360)
     at org.mortbay.jetty.security.SecurityHandler.handle(SecurityHandler.java:216)
     at org.mortbay.jetty.servlet.SessionHandler.handle(SessionHandler.java:181)
     at org.mortbay.jetty.handler.ContextHandler.handle(ContextHandler.java:726)
     at org.mortbay.jetty.webapp.WebAppContext.handle(WebAppContext.java:405)
     at org.mortbay.jetty.handler.ContextHandlerCollection.handle(ContextHandlerCollection.java:206)
     at org.mortbay.jetty.handler.HandlerCollection.handle(HandlerCollection.java:114)
     at org.mortbay.jetty.handler.HandlerWrapper.handle(HandlerWrapper.java:152)
     at org.mortbay.jetty.Server.handle(Server.java:324)
     at org.mortbay.jetty.HttpConnection.handleRequest(HttpConnection.java:505)
     at org.mortbay.jetty.HttpConnection$RequestHandler.content(HttpConnection.java:843)
     at org.mortbay.jetty.HttpParser.parseNext(HttpParser.java:648)
     at org.mortbay.jetty.HttpParser.parseAvailable(HttpParser.java:211)
     at org.mortbay.jetty.HttpConnection.handle(HttpConnection.java:380)
     at org.mortbay.io.nio.SelectChannelEndPoint.run(SelectChannelEndPoint.java:395)
     at org.mortbay.thread.QueuedThreadPool$PoolThread.run(QueuedThreadPool.java:488)

When you use ‘debug’ flag, what is the output?

What is the output of the apache logs?

What is the output of the page in the browser?

Debug Output

roomName

roomDesc

roomTopic

opf_cookie.1609797921.dat

/usr/bin/curl -D opf_cookie.1609797921.dat -d username=admin -d password=myPass -d login=true -d url="%2Fmuc-room-edit-form.jsp%3Fcreate%3Dtrue" “http://ec2-174-129-59-57.compute-1.amazonaws.com:9090/login.jsp” &> /dev/null

/usr/bin/curl -b opf_cookie.1609797921.dat -d roomconfig_persistentroom=true -d roomName=roomName -d roomconfig_roomname=roomName -d roomconfig_roomdesc=roomDesc -d room_topic=roomTopic -d roomconfig_maxusers=30 -d roomconfig_presencebroadcast=true -d roomconfig_presencebroadcast2=true -d roomconfig_presencebroadcast3=true -d roomconfig_roomsecret=’’ -d roomconfig_roomsecret2=’’ -d roomconfig_whois=anyone -d roomconfig_publicroom=true -d roomconfig_allowinvites=true -d roomconfig_enablelogging=true -d roomconfig_reservednick=true -d Submit=Save+Changes “http://ec2-174-129-59-57.compute-1.amazonaws.com:9090/muc-room-edit-form.jsp?sav e=true&create=true” &> /dev/null

Browser Output

Openfire

Openfire 3.6.4
Logged in as admin - Logout

  • Server

  • Users/Groups

  • Sessions

  • Group Chat

  • Plugins

                          [<img border="0" height="1" src="http://ec2-174-129-59-57.compute-1.amazonaws.com/images/blank.gif" width="150">](http://ec2-174-129-59-57.compute-1.amazonaws.com/images/blank.gif)
    

Exception:

java.lang.NullPointerException
     at org.jivesoftware.openfire.muc.MultiUserChatManager.getMultiUserChatService(MultiUserChatManager.java:316)
     at org.jivesoftware.openfire.admin.muc_002droom_002dedit_002dform_jsp._jspService(muc_002droom_002dedit_002dform_jsp.java:178)
     at org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:97)
     at javax.servlet.http.HttpServlet.service(HttpServlet.java:820)
     at org.mortbay.jetty.servlet.ServletHolder.handle(ServletHolder.java:487)
     at org.mortbay.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1093)
     at com.opensymphony.module.sitemesh.filter.PageFilter.parsePage(PageFilter.java:118)
     at com.opensymphony.module.sitemesh.filter.PageFilter.doFilter(PageFilter.java:52)
     at org.mortbay.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1084)
     at org.jivesoftware.util.LocaleFilter.doFilter(LocaleFilter.java:66)
     at org.mortbay.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1084)
     at org.jivesoftware.util.SetCharacterEncodingFilter.doFilter(SetCharacterEncodingFilter.java:42)
     at org.mortbay.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1084)
     at org.jivesoftware.admin.PluginFilter.doFilter(PluginFilter.java:70)
     at org.mortbay.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1084)
     at org.jivesoftware.admin.AuthCheckFilter.doFilter(AuthCheckFilter.java:146)
     at org.mortbay.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1084)
     at org.mortbay.jetty.servlet.ServletHandler.handle(ServletHandler.java:360)
     at org.mortbay.jetty.security.SecurityHandler.handle(SecurityHandler.java:216)
     at org.mortbay.jetty.servlet.SessionHandler.handle(SessionHandler.java:181)
     at org.mortbay.jetty.handler.ContextHandler.handle(ContextHandler.java:726)
     at org.mortbay.jetty.webapp.WebAppContext.handle(WebAppContext.java:405)
     at org.mortbay.jetty.handler.ContextHandlerCollection.handle(ContextHandlerCollection.java:206)
     at org.mortbay.jetty.handler.HandlerCollection.handle(HandlerCollection.java:114)
     at org.mortbay.jetty.handler.HandlerWrapper.handle(HandlerWrapper.java:152)
     at org.mortbay.jetty.Server.handle(Server.java:324)
     at org.mortbay.jetty.HttpConnection.handleRequest(HttpConnection.java:505)
     at org.mortbay.jetty.HttpConnection$RequestHandler.content(HttpConnection.java:843)
     at org.mortbay.jetty.HttpParser.parseNext(HttpParser.java:648)
     at org.mortbay.jetty.HttpParser.parseAvailable(HttpParser.java:211)
     at org.mortbay.jetty.HttpConnection.handle(HttpConnection.java:380)
     at org.mortbay.io.nio.SelectChannelEndPoint.run(SelectChannelEndPoint.java:395)
     at org.mortbay.thread.QueuedThreadPool$PoolThread.run(QueuedThreadPool.java:488)

Server | Users/Groups | Sessions | Group Chat | Plugins
Built by Jive Software and the IgniteRealtime.org community

Apache Log Output

/usr/bin/curl: /opt/bitnami/common/lib/libcurl.so.4: no version information available (required by /usr/bin/curl)

% Total % Received % Xferd Average Speed Time Time Time Current

Dload Upload Total Spent Left Speed

0 90 0 0 0 90 0 782 --:–:-- --:–:-- --:–:-- 782 0 90 0 0 0 90 0 762 --:–:-- --:–:-- --:–:-- 0

/usr/bin/curl: /opt/bitnami/common/lib/libcurl.so.4: no version information available (required by /usr/bin/curl)

% Total % Received % Xferd Average Speed Time Time Time Current

Dload Upload Total Spent Left Speed

115 460 0 0 0 460 0 356k --:–:-- --:–:-- --:–:-- 356k100 8859 101 8399 0 460 1305k 73190 --:–:-- --:–:-- --:–:-- 1550k

[Thu Feb 24 23:22:27 2011] [error] [client 174.138.198.209] File does not exist: /opt/bitnami/apache2/htdocs/style, referer: http://ec2-174-129-59-57.compute-1.amazonaws.com/test/open.php

[Thu Feb 24 23:22:27 2011] [error] [client 174.138.198.209] File does not exist: /opt/bitnami/apache2/htdocs/js, referer: http://ec2-174-129-59-57.compute-1.amazonaws.com/test/open.php

[Thu Feb 24 23:22:27 2011] [error] [client 174.138.198.209] File does not exist: /opt/bitnami/apache2/htdocs/images, referer: http://ec2-174-129-59-57.compute-1.amazonaws.com/test/open.php

[Thu Feb 24 23:22:27 2011] [error] [client 174.138.198.209] File does not exist: /opt/bitnami/apache2/htdocs/js, referer: http://ec2-174-129-59-57.compute-1.amazonaws.com/test/open.php

[Thu Feb 24 23:22:27 2011] [error] [client 174.138.198.209] File does not exist: /opt/bitnami/apache2/htdocs/js, referer: http://ec2-174-129-59-57.compute-1.amazonaws.com/test/open.php

[Thu Feb 24 23:22:27 2011] [error] [client 174.138.198.209] File does not exist: /opt/bitnami/apache2/htdocs/js, referer: http://ec2-174-129-59-57.compute-1.amazonaws.com/test/open.php

[Thu Feb 24 23:22:27 2011] [error] [client 174.138.198.209] File does not exist: /opt/bitnami/apache2/htdocs/images, referer: http://ec2-174-129-59-57.compute-1.amazonaws.com/test/open.php

[Thu Feb 24 23:22:27 2011] [error] [client 174.138.198.209] File does not exist: /opt/bitnami/apache2/htdocs/images, referer: http://ec2-174-129-59-57.compute-1.amazonaws.com/test/open.php

Any ideas if i do not input room name and desc, then i see the createroom page but when values are entered i get a null pointer?

Try removing the ‘&> /dev/null’ part from the curl statements, and trim down the php script to only attempt login, then post back the results.

Hello,

I get the exact same exception after successfully logged in with this PHP script using CURL.

Any idea what is wrong ?