Create Chat Room Automation

Folks,

I’d like to set up a mechanism using a shell script (or .php) to create chat rooms with specific options and restrictions, (e.g. disable ‘’, etc), and potentially have a fiat admin logged in. Typically any member can create a chat room, but I’d like to disallow this, and set up my own auto generated chat rooms, so that triggering events will cause their creation and configuration. Is there a way to do this?

Thanks

Based on the description of how to use Perl/CURL*1 to interact with OPF admin site, I created a PHP script to create a chat room, listed as follows. Notes about the PHP script, error information is output into /var/log/httpd/error_log. Native PHP libcurl did not work due to, ‘Your browser does not support Javascript’ call errors returned from the access.

HTH,

BEA

*1 http://www.igniterealtime.org/community/message/136879

<?php /* * open.php - Sets CURL command line args, with data sent via POST, * then uses PHP system() function to create chat rooms, * using listed options. */ $opf_uid = "admin"; $opf_pwd = "secret"; $curl_cookie_file = '/tmp/opf_cookie.' . rand() . '.dat'; if (isset($_POST["roomname"]) and isset($_POST["roomdesc"]) and isset($_POST["roomtopic"])) { if (isset($_POST["debug"])) { print "

" . $_POST["roomname"] . "

\n"; print "

" . $_POST["roomdesc"] . "

\n"; print "

" . $_POST["roomtopic"] . "

\n"; print "

". $curl_cookie_file . "

\n"; } $curl_req_1 = "/usr/bin/curl -D " . $curl_cookie_file . " " . "-d username=" . $opf_uid . " " . "-d password=" . $opf_pwd . " " . "-d login=true " . "-d url=\"" . urlencode('/muc-room-edit-form.jsp?create=true') ."\" " . "\"http://localhost:9090/login.jsp\" &> /dev/null"; $curl_req_2 = "/usr/bin/curl -b " . $curl_cookie_file . " " . "-d roomconfig_persistentroom=true " . "-d roomName=" . $_POST["roomname"] . " " . "-d roomconfig_roomname=" . $_POST["roomname"] . " " . "-d roomconfig_roomdesc=" . urlencode($_POST["roomdesc"]) . " " . "-d room_topic=" . urlencode($_POST["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=" . urlencode('Save Changes') . " " . "\"http://localhost:9090/muc-room-edit-form.jsp?save=true&create=true\" &> /dev/null"; if (isset($_POST["debug"])) { print "

". $curl_req_1 . "

\n"; print "

". $curl_req_2 . "

\n"; } /* You may want to add logic that checks the return value */ system($curl_req_1); system($curl_req_2); unlink($curl_cookie_file); } ?> room name:
room desc:
room topic:
debug