Exemplo n.º 1
0
 /**
  *  Sends a message from the current member to the member given as argument
  */
 function sendMessage()
 {
     global $CONF, $member;
     $error = $this->validateMessage();
     if ($error != '') {
         return array('message' => $error);
     }
     if (!$member->isLoggedIn()) {
         $fromMail = postVar('frommail');
         $fromName = _MMAIL_FROMANON;
     } else {
         $fromMail = $member->getEmail();
         $fromName = $member->getDisplayName();
     }
     $tomem = new MEMBER();
     $tomem->readFromId(postVar('memberid'));
     $message = _MMAIL_MSG . ' ' . $fromName . "\n" . '(' . _MMAIL_FROMNUC . ' ' . $CONF['IndexURL'] . ") \n\n" . _MMAIL_MAIL . " \n\n" . postVar('message');
     $message .= getMailFooter();
     $title = _MMAIL_TITLE . ' ' . $fromName;
     mb_language('ja');
     mb_internal_encoding(_CHARSET);
     @mb_send_mail($tomem->getEmail(), $title, $message, "From: " . $fromMail);
     if (postVar('url')) {
         redirect(postVar('url'));
     } else {
         $CONF['MemberURL'] = $CONF['IndexURL'];
         if ($CONF['URLMode'] == 'pathinfo') {
             $url = createLink('member', array('memberid' => $tomem->getID(), 'name' => $tomem->getDisplayName()));
         } else {
             $url = $CONF['IndexURL'] . createMemberLink($tomem->getID());
         }
         redirect($url);
     }
     exit;
 }
Exemplo n.º 2
0
function _getUserInfo($username, $password)
{
    // 1. login
    $mem = new MEMBER();
    if (!$mem->login($username, $password)) {
        return _error(1, "Could not log in");
    }
    // 3. return the info
    // Structure returned has nickname, userid, url, email, lastname, firstname
    $newstruct = new xmlrpcval(array("nickname" => new xmlrpcval($mem->getDisplayName(), "string"), "userid" => new xmlrpcval($mem->getID(), "string"), "url" => new xmlrpcval($mem->getURL(), "string"), "email" => new xmlrpcval($mem->getEmail(), "string"), "lastname" => new xmlrpcval("", "string"), "firstname" => new xmlrpcval($mem->getRealName(), "string")), 'struct');
    return new xmlrpcresp($newstruct);
}
Exemplo n.º 3
0
function _newMediaObject($blogid, $username, $password, $info)
{
    global $CONF, $DIR_MEDIA, $DIR_LIBS;
    // - login
    $mem = new MEMBER();
    if (!$mem->login($username, $password)) {
        return _error(1, 'Could not log in');
    }
    // - check if team member
    if (!BLOG::existsID($blogid)) {
        return _error(2, "No such blog ({$blogid})");
    }
    if (!$mem->teamRights($blogid)) {
        return _error(3, 'Not a team member');
    }
    $b = new BLOG($blogid);
    // - decode data
    $data = $info['bits'];
    // decoding was done transparantly by xmlrpclib
    // - check filesize
    if (strlen($data) > $CONF['MaxUploadSize']) {
        return _error(9, 'filesize is too big');
    }
    // - check if filetype is allowed (check filename)
    $filename = $info['name'];
    $ok = 0;
    $allowedtypes = explode(',', $CONF['AllowedTypes']);
    foreach ($allowedtypes as $type) {
        //if (eregi("\." .$type. "$",$filename)) $ok = 1;
        if (preg_match("#\\." . $type . "\$#i", $filename)) {
            $ok = 1;
        }
    }
    if (!$ok) {
        _error(8, 'Filetype is not allowed');
    }
    // - add file to media library
    //include_once($DIR_LIBS . 'MEDIA.php');	// media classes
    include_libs('MEDIA.php', true, false);
    // always use private media library of member
    $collection = $mem->getID();
    // prefix filename with current date (YYYY-MM-DD-)
    // this to avoid nameclashes
    if ($CONF['MediaPrefix']) {
        $filename = strftime("%Y%m%d-", time()) . $filename;
    }
    $res = MEDIA::addMediaObjectRaw($collection, $filename, $data);
    if ($res) {
        return _error(10, $res);
    }
    // - return URL
    $urlstruct = new xmlrpcval(array("url" => new xmlrpcval($CONF['MediaURL'] . $collection . '/' . $filename, 'string')), 'struct');
    return new xmlrpcresp($urlstruct);
}