Example #1
0
if (!is_array(stat($configname))) {
    die("\nCouldn't find users config in {$configname}\n");
}
$vcardfh = fopen($vcardname, "r");
$vcard = fread($vcardfh, filesize($vcardname));
fclose($vcardfh);
$configfh = fopen($configname, "r");
$config = fread($configfh, filesize($configname));
fclose($configfh);
include "ctdlsession.php";
include "ctdlprotocol.php";
include "ctdlelements.php";
//define(CITADEL_DEBUG_HTML, FALSE);
establish_citadel_session();
create_new_user($user, $password);
ctdl_goto("My Citadel Config");
list($num_msgs, $response, $msgs) = ctdl_msgs("", "");
$Webcit_Preferences = array();
$Webcit_PrefMsgid = 0;
if ($num_msgs > 0) {
    foreach ($msgs as $msgnum) {
        print_r($msgnum);
        // Fetch the message from the server
        list($ok, $response, $fields) = ctdl_fetch_message($msgnum);
        // Bail out gracefully if the message isn't there.
        if (!$ok) {
            echo "Error: " . $response . "\n";
            return false;
        }
        if (isset($fields['part'])) {
            $parts = explode('|', $fields['part']);
Example #2
0
function establish_citadel_session()
{
    global $session, $clientsocket;
    if (strcmp('4.3.0', phpversion()) > 0) {
        die("This program requires PHP 4.3.0 or newer.");
    }
    session_start();
    if (isset($_SESSION["ctdlsession"])) {
        $session = $_SESSION["ctdlsession"];
    } else {
        $session = "CtdlSession." . time() . rand(1000, 9999);
        $_SESSION["ctdlsession"] = $session;
    }
    // See if there's a Citadel connection proxy open for this session.
    // The name of the socket is identical to the name of the
    // session, and it's found in the /tmp directory.
    $sockname = "/tmp/" . $session . ".socket";
    $errno = 0;
    $errstr = "";
    if (is_array(stat($sockname))) {
        $clientsocket = fsockopen(SOCKET_PREFIX . $sockname, 0, $errno, $errstr, 5);
    } else {
        $clientsocket = false;
    }
    //// TODO: if we get connection refused...
    echo "{$socketname} - {$errno} - {$errstr}";
    if (!$clientsocket) {
        // It ain't there, dude.  Open up the proxy. (C version)
        //$cmd = "./sessionproxy " . $sockname ;
        //exec($cmd);
        // It ain't there, dude.  Open up the proxy.  (PHP version)
        if (CITADEL_DEBUG_PROXY) {
            $stdout = '>>/tmp/sessionproxyout.txt ';
        } else {
            $stdout = '>/dev/null ';
        }
        $cmd = "./sessionproxy.php " . $sockname . " </dev/null " . $stdout . "2>&1 " . " 3>&1 4>&1 5>&1 6>&1 7>&1 8>&1 & ";
        exec($cmd);
        sleep(1);
        // Keep attempting connections 10 times per second up to 100 times
        $attempts = 0;
        while (!$clientsocket) {
            usleep(100);
            if (is_array(stat($sockname))) {
                $clientsocket = fsockopen(SOCKET_PREFIX . $sockname, 0, $errno, $errstr, 5);
            } else {
                $clientsocket = false;
            }
            $attempts += 1;
            if ($attempts > 100) {
                echo "ERROR: unable to start connection proxy. ";
                echo "Please contact your system administrator.<BR>\n";
                flush();
                exit(1);
            }
        }
        // At this point we have a good connection to Citadel.
        $identity = array("DevelNr" => '0', "ClientID" => '8', "VersionNumber" => '001', "ClientInfoString" => 'PHP web client|', "Remote Address" => $_SERVER['REMOTE_ADDR']);
        ctdl_iden($identity);
        // Identify client
        ctdl_MessageFormatsPrefered(array("text/html", "text/plain"));
        if (isset($_SESSION["username"])) {
            login_existing_user($_SESSION["username"], $_SESSION["password"]);
        }
        if (isset($_SESSION["room"])) {
            ctdl_goto($_SESSION["room"]);
        } else {
            ctdl_goto("_BASEROOM_");
        }
    }
    if (!isset($_SESSION["serv_humannode"])) {
        $server_info = ctdl_get_serv_info();
        // print_r($server_info);
        $keys = array_keys($server_info);
        foreach ($keys as $key) {
            $_SESSION[$key] = $server_info[$key];
        }
    }
    // If the user is trying to call up any page other than
    // login.php logout.php do_login.php,
    // and the session is not logged in, redirect to login.php
    //
    if (isset($_SESSION["logged_in"]) && $_SESSION["logged_in"] != 1) {
        $filename = basename(getenv('SCRIPT_NAME'));
        if (strcmp($filename, "login.php") && strcmp($filename, "logout.php") && strcmp($filename, "do_login.php")) {
            header("Location: login.php");
            exit(0);
        }
    }
}
Example #3
0
 function GetFolder($id)
 {
     debugLog("GetFolder {$id}");
     $ret = ctdl_goto($id);
     //	    debugLog(print_r($ret, true));
     $box = new SyncFolder();
     $box->serverid = $id;
     $box->parentid = $ret['floorid'];
     $box->displayname = $ret['roomname'];
     switch ($ret['defaultview']) {
         case VIEW_BBS:
             $box->type = SYNC_FOLDER_TYPE_OTHER;
             break;
         case VIEW_MAILBOX:
             $box->type = SYNC_FOLDER_TYPE_INBOX;
             break;
         case VIEW_ADDRESSBOOK:
             $box->type = SYNC_FOLDER_TYPE_OTHER;
             break;
         case VIEW_CALENDAR:
             $box->type = SYNC_FOLDER_TYPE_OTHER;
             break;
         case VIEW_TASKS:
             $box->type = SYNC_FOLDER_TYPE_OTHER;
             break;
         case VIEW_NOTES:
             $box->type = SYNC_FOLDER_TYPE_OTHER;
             break;
     }
     return $box;
     //        if($id == "root") {
     //            $inbox = new SyncFolder();
     //
     //            $inbox->serverid = $id;
     //            $inbox->parentid = "0"; // Root
     //            $inbox->displayname = "Inbox";
     //            $inbox->type = SYNC_FOLDER_TYPE_INBOX;
     //
     //            return $inbox;
     //        } else if($id = "sub") {
     //            $inbox = new SyncFolder();
     //            $inbox->serverid = $id;
     //            $inbox->parentid = "root";
     //            $inbox->displayname = "Sub";
     //            $inbox->type = SYNC_FOLDER_TYPE_OTHER;
     //
     //            return $inbox;
     //        } else {
     //            return false;
     //        }
 }
Example #4
0
<?php

include "ctdlheader.php";
bbs_page_header();
ctdl_goto($_REQUEST["towhere"]);
echo "You are now in: ", htmlspecialchars($_SESSION["room"]), "<BR>\n";
?>

<a href="readmsgs.php?mode=new&count=0">Read new messages</a><BR>
<a href="readmsgs.php?mode=all&count=0">Read all messages</a><BR>
<a href="welcome.php">Page One</a><BR>
<a href="page3.php">Page Three</a><BR>

<?php 
bbs_page_footer();
Example #5
0
function become_logged_in($server_parms)
{
    $_SESSION["logged_in"] = 1;
    $tokens = explode("|", $server_parms);
    $oneline["username"] = $tokens[0];
    $oneline["axlevel"] = $tokens[1];
    $oneline["calls"] = $tokens[2];
    $oneline["posts"] = $tokens[3];
    $oneline["userflags"] = $tokens[4];
    $oneline["usernum"] = $tokens[5];
    $oneline["lastcall"] = $tokens[6];
    ctdl_goto("_BASEROOM_");
}