Example #1
0
function xmlrpc_smtp2pne($message)
{
    // パラメータを取得
    $param = $message->getParam(0);
    if (!XML_RPC_Value::isValue($param)) {
        return $param;
    }
    $params = XML_RPC_decode($param);
    // 入力チェック とりあえず空かどうかのみ
    if (empty($params['prefix']) and empty($params['domain'])) {
        return xmlrpc_get_response_faultDefault('incorrect_params');
    }
    if (empty($params['to'])) {
        return xmlrpc_get_response_faultDefault('incorrect_params');
    }
    if (empty($params['from'])) {
        return xmlrpc_get_response_faultDefault('incorrect_params');
    }
    // デコーダオブジェクトを作成
    $options['from_encoding'] = 'UTF-8';
    $options['to_encoding'] = 'UTF-8';
    $options['img_tmp_dir'] = OPENPNE_VAR_DIR . '/tmp';
    $options['img_max_filesize'] = IMAGE_MAX_FILESIZE * 1024;
    $options['trim_doublebyte_space'] = OPENPNE_TRIM_DOUBLEBYTE_SPACE;
    $decoder =& new OpenPNE_KtaiMail_RPC($options);
    $decoder->assign($params);
    // メール受信処理オブジェクトを起動
    $mail_sns =& new mail_sns($decoder);
    if (!$mail_sns->main()) {
        //エラーの場合はfaultCodeを返す
        return xmlrpc_get_fault_response(56, 'Can\'t Receive Mail');
    }
    return xmlrpc_get_response(0);
}
Example #2
0
/**
 * 認証API
 */
function xmlrpc_000_auth($message)
{
    $param = $message->getParam(0);
    if (!XML_RPC_Value::isValue($param)) {
        return false;
    }
    $params = XML_RPC_decode($param);
    if (empty($params['sid'])) {
        return false;
    }
    if (empty($params['mid'])) {
        return false;
    }
    if (empty($params['dt'])) {
        return false;
    }
    $c_member_id = $params['mid'];
    $datetime = $params['dt'];
    if (!db_member_c_member4c_member_id_LIGHT($c_member_id)) {
        return xmlrpc_get_fault_response(56);
    }
    if (!($member_token = db_api_get_member_token($c_member_id))) {
        return xmlrpc_get_fault_response(52);
    }
    $session_id = api_get_sid($c_member_id, $member_token, $datetime);
    if ($params['sid'] != $session_id) {
        return xmlrpc_get_fault_response(52);
    }
    return xmlrpc_get_response($c_member_id);
}
Example #3
0
/**
 * Aux functions
 *
 * @access  public
 * @param   object  $p
 * @param   string  $i
 * @return  mixed   
 */
function getScalarValue($p, $i)
{
    $r = $p->getParam($i);
    if (!XML_RPC_Value::isValue($r)) {
        return false;
        //return new XML_RPC_Response(0, $GLOBALS['XML_RPC_erruser']+3, 'fubar user param');
    }
    return $r->scalarval();
}
function xmlrpc_di_000_get_diary($message)
{
    $dummy = array();
    $re_false = array('result' => 1, 'list' => $dummy);
    $param = $message->getParam(0);
    if (!XML_RPC_Value::isValue($param)) {
        return xmlrpc_get_response($re_false);
    }
    $params = XML_RPC_decode($param);
    if (empty($params['mid_to'])) {
        //対象メンバID必須
        return xmlrpc_get_response($re_false);
    }
    if (empty($params['count'])) {
        //取得数必須
        return xmlrpc_get_response($re_false);
    }
    if (!is_numeric($params['mid_to'])) {
        //対象メンバIDは整数値
        return xmlrpc_get_response($re_false);
    }
    if (!empty($params['mid_from'])) {
        //アクセスメンバIDは(存在する場合は)整数値
        if (!is_numeric($params['mid_from'])) {
            return xmlrpc_get_response($re_false);
        }
    }
    if (!is_numeric($params['count'])) {
        //取得数は整数値
        return xmlrpc_get_response($re_false);
    }
    if ($params['count'] < 0) {
        //取得数は正
        return xmlrpc_get_response($re_false);
    }
    $member_id_to = $params['mid_to'];
    $member_id_from = $params['mid_from'];
    $count = $params['count'];
    if ($count > 100) {
        //取得最大数は100
        $count = 100;
    }
    if (!($arr = OP::op_diary_get_c_diary($member_id_to, $member_id_from, $count))) {
        return xmlrpc_get_response($re_false);
    } else {
        foreach ($arr as $key => $value) {
            $diary[$key]['id'] = $arr[$key]['c_diary_id'];
            $diary[$key]['subject'] = $arr[$key]['subject'];
            $diary[$key]['body'] = $arr[$key]['body'];
            $diary[$key]['datetime'] = date('Y/m/d H:i:s', strtotime($arr[$key]['r_datetime']));
        }
        $re_true = array('result' => 0, 'list' => $diary);
        return xmlrpc_get_response($re_true);
    }
}
/**
 * @copyright 2005-2008 OpenPNE Project
 * @license   http://www.php.net/license/3_01.txt PHP License 3.01
 */
function xmlrpc_002_get_member_point($message)
{
    $param = $message->getParam(0);
    if (!XML_RPC_Value::isValue($param)) {
        return false;
    }
    $params = XML_RPC_decode($param);
    if (empty($params['c_member_id'])) {
        return false;
    }
    $point = get_point($params['c_member_id']);
    return xmlrpc_get_response($point);
}
 public function getDefinition($params)
 {
     // get word
     $param = $params->getParam(0);
     if (!XML_RPC_Value::isValue($param)) {
         log_debug($param);
     }
     $word = $param->scalarval();
     // get the definition by the word.
     $message = $this->objMxitDictionary->getDefinition($word);
     $val = $message['definition'];
     // return the value as an XML-RPC value and response.
     $val2send = new XML_RPC_Value($val, 'string');
     return new XML_RPC_Response($val2send);
 }
function xmlrpc_as_001_set_ashiato($message)
{
    $dummy = array();
    $re_false = array('result' => 1);
    $re_true = array('result' => 0);
    $param = $message->getParam(0);
    if (!XML_RPC_Value::isValue($param)) {
        return xmlrpc_get_response($re_false);
    }
    $params = XML_RPC_decode($param);
    //「あしあと」を付けたメンバID必須
    if (empty($params['mid_from'])) {
        return xmlrpc_get_response($re_false);
    }
    //「あしあと」を付けられたメンバID必須
    if (empty($params['mid_to'])) {
        return xmlrpc_get_response($re_false);
    }
    $mid_from = $params['mid_from'];
    $mid_to = $params['mid_to'];
    //登録済みのメンバか
    if (!OP::op_member_is_active_c_member_id($mid_from)) {
        return xmlrpc_get_response($re_false);
    }
    //登録済みのメンバか
    if (!OP::op_member_is_active_c_member_id($mid_to)) {
        return xmlrpc_get_response($re_false);
    }
    //あしあとを付けたメンバIDと付けられたメンバIDは同一か
    if ($mid_from == $mid_to) {
        return xmlrpc_get_response($re_true);
    }
    //一定時間内の連続アクセスか?
    if (!OP::op_ashiato_check_access_minute($mid_to, $mid_from)) {
        return xmlrpc_get_response($re_true);
    }
    //忍び足状態か?
    if (USE_SHINOBIASHI) {
        if (OP::op_member_is_shinobiashi($mid_from)) {
            return xmlrpc_get_response($re_true);
        }
    }
    if (!OP::op_ashiato_insert_c_ashiato($mid_to, $mid_from)) {
        return xmlrpc_get_response($re_false);
    }
    //正常終了
    return xmlrpc_get_response($re_true);
}
function xmlrpc_as_000_get_ashiato($message)
{
    $dummy = array();
    $re_false = array('result' => 1, 'list' => $dummy);
    $param = $message->getParam(0);
    if (!XML_RPC_Value::isValue($param)) {
        return xmlrpc_get_response($re_false);
    }
    $params = XML_RPC_decode($param);
    //対象メンバID必須
    if (empty($params['mid'])) {
        return xmlrpc_get_response($re_false);
    }
    //取得数必須
    if (empty($params['count'])) {
        return xmlrpc_get_response($re_false);
    }
    //取得数は数値
    if (!is_numeric($params['count'])) {
        return xmlrpc_get_response($re_false);
    }
    $member_id = $params['mid'];
    $count = intval($params['count']);
    $profile = $params['profile'];
    //取得数は正
    if ($count <= 0) {
        return xmlrpc_get_response($re_false);
    }
    //登録済みのメンバか
    if (!OP::op_member_is_active_c_member_id($member_id)) {
        return xmlrpc_get_response($re_false);
    }
    //あしあとのあるメンバか
    if (!OP::op_is_ahiato_member($member_id)) {
        return xmlrpc_get_response($re_false);
    }
    //取得最大数は100
    if ($count > 100) {
        $count = 100;
    }
    $list = OP::op_ashiato_list_c_member_profile($member_id, $count, $profile);
    if (empty($list)) {
        return xmlrpc_get_respose($re_false);
    }
    return xmlrpc_get_response(array('result' => 0, 'list' => $list));
}
 public function grabXMLDoc($params)
 {
     $param = $params->getParam(0);
     if (!XML_RPC_Value::isValue($param)) {
         log_debug($param);
     }
     $doc = $param->scalarval();
     if (!file_exists($this->objConfig->getContentBasePath() . 'apitmp/')) {
         @mkdir($this->objConfig->getContentBasePath() . 'apitmp/');
         @chmod($this->objConfig->getContentBasePath() . 'apitmp/', 0777);
     }
     $localfile = $this->objConfig->getContentBasePath() . 'apitmp/annote' . rand(1, 999);
     $ret = file_put_contents($doc, $localfile);
     $val = new XML_RPC_Value($ret, 'boolean');
     return new XML_RPC_Response($val);
     // Ooops, couldn't open the file so return an error message.
     return new XML_RPC_Response(0, $XML_RPC_erruser + 1, $this->objLanguage->languageText("mod_packages_fileerr", "packages"));
 }
/**
 * @copyright 2005-2008 OpenPNE Project
 * @license   http://www.php.net/license/3_01.txt PHP License 3.01
 */
function xmlrpc_001_get_c_member($message)
{
    $param = $message->getParam(0);
    if (!XML_RPC_Value::isValue($param)) {
        return false;
    }
    $params = XML_RPC_decode($param);
    if (empty($params['target_c_member_id'])) {
        return false;
    }
    if (empty($params['my_c_member_id'])) {
        return false;
    }
    $t_id = intval($params['target_c_member_id']);
    $m_id = intval($params['my_c_member_id']);
    // my_c_member_id が不正
    if (!db_member_c_member4c_member_id_LIGHT($m_id)) {
        return xmlrpc_get_fault_response(56);
    }
    if ($t_id == $m_id) {
        // 自分
        $public_flag = 'private';
    } elseif (db_friend_is_friend($t_id, $m_id)) {
        $public_flag = 'friend';
    } else {
        $public_flag = 'public';
    }
    // target_c_member_id が不正
    if (!($c_member = db_member_c_member4c_member_id($t_id, false, true, $public_flag))) {
        return xmlrpc_get_fault_response(56);
    }
    // アクセスブロック判定
    if (db_member_is_access_block($m_id, $t_id)) {
        $result = array('c_member_id' => $t_id, 'nickname' => $c_member['nickname'], 'image_url' => xmlrpc_get_image_url());
    } else {
        $result = array('c_member_id' => $t_id, 'nickname' => $c_member['nickname'], 'image_url' => xmlrpc_get_image_url($c_member['image_filename']), 'image_url_1' => xmlrpc_get_image_url($c_member['image_filename_1'], false), 'image_url_2' => xmlrpc_get_image_url($c_member['image_filename_2'], false), 'image_url_3' => xmlrpc_get_image_url($c_member['image_filename_3'], false), 'birth_year' => intval($c_member['birth_year']), 'birth_month' => intval($c_member['birth_month']), 'birth_day' => intval($c_member['birth_day']), 'access_date' => xmlrpc_get_date($c_member['access_date']), 'r_date' => xmlrpc_get_date($c_member['r_date']), 'profile' => array());
        foreach ($c_member['profile'] as $key => $profile) {
            $result['profile'][$key] = $profile['value'];
        }
    }
    return xmlrpc_get_response($result);
}
Example #11
0
/**
 * @copyright 2005-2008 OpenPNE Project
 * @license   http://www.php.net/license/3_01.txt PHP License 3.01
 */
function xmlrpc_901_o_search($message)
{
    $param = $message->getParam(0);
    if (!XML_RPC_Value::isValue($param)) {
        return false;
    }
    $params = XML_RPC_decode($param);
    if (!array_key_exists('searchword', $params)) {
        return false;
    }
    if (empty($params['type'])) {
        return false;
    }
    $searchword = $params['searchword'];
    if (empty($searchword)) {
        $searchword = '';
    }
    $type = $params['type'];
    $number = 0;
    switch ($type) {
        case 'DIARY':
            $diary = p_h_diary_list_all_search_c_diary4c_diary($searchword, 0, 1);
            $number += (int) $diary[3];
            break;
        case 'COMMUNITY':
            $commu = db_commu_search_c_commu4c_commu_category($searchword, 0, 0, 1);
            $number += (int) $commu[3];
            break;
        case 'ALL':
        default:
            $diary = p_h_diary_list_all_search_c_diary4c_diary($searchword, 0, 1);
            $number += (int) $diary[3];
            $commu = db_commu_search_c_commu4c_commu_category($searchword, 0, 0, 1);
            $number += (int) $commu[3];
            break;
    }
    $result = array('number' => intval($number), 'sns_name' => SNS_NAME);
    return xmlrpc_get_response($result);
}
Example #12
0
/**
 * @copyright 2005-2008 OpenPNE Project
 * @license   http://www.php.net/license/3_01.txt PHP License 3.01
 */
function xmlrpc_101_add_point($message)
{
    $param = $message->getParam(0);
    if (!XML_RPC_Value::isValue($param)) {
        return false;
    }
    $params = XML_RPC_decode($param);
    if (empty($params['c_member_id'])) {
        return false;
    }
    if (!isset($params['point'])) {
        return false;
    }
    $c_member_id = intval($params['c_member_id']);
    $point = intval($params['point']);
    if (!db_member_c_member4c_member_id_LIGHT($c_member_id)) {
        return xmlrpc_get_fault_response(56);
    }
    $c_point_log_id = db_point_insert_log($c_member_id, $point, $params['memo']);
    db_point_insert_tags($c_point_log_id, $params['tags']);
    $point = db_point_add_point($c_member_id, $point);
    return xmlrpc_get_response($point);
}
function xmlrpc_di_001_set_comment($message)
{
    $re_true = array('result' => 0);
    $re_false = array('result' => 1);
    $param = $message->getParam(0);
    if (!XML_RPC_Value::isValue($param)) {
        return xmlrpc_get_response($re_false);
    }
    $params = XML_RPC_decode($param);
    if (empty($params['mid'])) {
        //コメント書込メンバID必須
        return xmlrpc_get_response($re_false);
    }
    if (empty($params['did'])) {
        //コメント書込日記ID必須
        return xmlrpc_get_response($re_false);
    }
    if (is_null($params['body']) || $params['body'] === '') {
        //コメント本文必須(0または'0'を除く)
        return xmlrpc_get_response($re_false);
    }
    if (!is_numeric($params['mid'])) {
        //コメント書込メンバIDは整数値
        return xmlrpc_get_response($re_false);
    }
    if (!is_numeric($params['did'])) {
        //コメント書込日記IDは整数値
        return xmlrpc_get_response($re_false);
    }
    if (mb_strwidth($params['body']) > 65535) {
        //コメント本文は65535bytesまで
        return xmlrpc_get_response($re_false);
    }
    $member_id = $params['mid'];
    $diary_id = $params['did'];
    $diary_body = rawurldecode($params['body']);
    $d_member_id = OP::op_diary_get_c_member_id4c_diary_id($diary_id);
    //日記IDから日記作成メンバIDを取得
    if (!OP::op_member_is_active_c_member_id($d_member_id)) {
        //アクティブメンバーか?
        return xmlrpc_get_response($re_false);
    }
    if ($member_id != $d_member_id) {
        //日記作成メンバ本人か?
        if (OP::op_member_is_access_block($member_id, $d_member_id)) {
            //アクセスブロックされているか?
            return xmlrpc_get_response($re_false);
        }
        $pubflg = OP::op_diary_get_c_member_id4public_flg($diary_id);
        //日記IDから公開範囲を取得
        if ($pubflg != "public") {
            //公開範囲がpublic以外か?
            if ($pubflg != "friend") {
                //公開範囲がfriendか?
                return xmlrpc_get_response($re_false);
            }
            if (!OP::op_friend_is_friend($d_member_id, $member_id)) {
                //フレンド登録済以外か?
                return xmlrpc_get_response($re_false);
            }
        }
    }
    if (!OP::op_diary_insert_c_diary_comment($member_id, $diary_id, $diary_body)) {
        //コメント書込
        return xmlrpc_get_response($re_false);
    }
    if (!OP::op_diary_c_diary_is_no_checked($diary_id)) {
        //未読フラグ書込
        return xmlrpc_get_response($re_false);
    }
    if ($member_id != $d_member_id) {
        //日記作成メンバ本人か?
        OP::op_point_add_point($member_id, OP::op_action_get_point4c_action_id(3));
        OP::op_point_add_point($d_member_id, OP::op_action_get_point4c_action_id(2));
    }
    return xmlrpc_get_response($re_true);
}
 /**
  * Metaweblog get post
  * 
  * Get a post by its ID
  * 
  * @param  object $params Parameters
  * @return object Return 
  * @access public
  */
 public function metaWeblogGetPost($params)
 {
     //log_debug("getting single post..... - metaweblog");
     $param = $params->getParam(0);
     if (!XML_RPC_Value::isValue($param)) {
         log_debug($param);
     }
     $postid = $param->scalarval();
     $param = $params->getParam(1);
     if (!XML_RPC_Value::isValue($param)) {
         log_debug($param);
     }
     $username = $param->scalarval();
     $param = $params->getParam(2);
     if (!XML_RPC_Value::isValue($param)) {
         log_debug($param);
     }
     $pass = $param->scalarval();
     //go get the post
     $post = $this->objDbBlog->getPostById($postid);
     $post = $post[0];
     //log_debug($post);
     $postStruct = new XML_RPC_Value(array("description" => new XML_RPC_Value($post['post_content'], "string"), "userid" => new XML_RPC_Value($post['userid'], "string"), "postid" => new XML_RPC_Value($post['id'], "string"), "dateCreated" => new XML_RPC_Value($post['post_date'], "string")), "struct");
     return new XML_RPC_Response($postStruct);
 }
 public function convert3GPtoFLV($params)
 {
     $param = $params->getParam(0);
     if (!XML_RPC_Value::isValue($param)) {
         log_debug($param);
     }
     $appkey = $param->scalarval();
     $param = $params->getParam(1);
     if (!XML_RPC_Value::isValue($param)) {
         log_debug($param);
     }
     $file = $param->scalarval();
     $file = base64_decode($file);
     // check the api key for validity
     if ($this->checkApiKey($appkey) != TRUE) {
         return new XML_RPC_Response("Incorrect API Key!");
     }
     if (!file_exists($this->objConfig->getContentBasePath() . 'apitmp/')) {
         @mkdir($this->objConfig->getContentBasePath() . 'apitmp/');
         @chmod($this->objConfig->getContentBasePath() . 'apitmp/', 0777);
     }
     $localfile = $this->objConfig->getContentBasePath() . 'apitmp/' . rand(1, 999);
     $orig = $localfile . '.3gp';
     $conv = $localfile;
     file_put_contents($orig, $file);
     $newfile = $this->objMedia->convert3gp2flv($orig, $conv);
     $filetosend = file_get_contents($newfile);
     $filetosend = base64_encode($filetosend);
     $val = new XML_RPC_Value($filetosend, 'string');
     unlink($orig);
     unlink($newfile);
     return new XML_RPC_Response($val);
     // Ooops, couldn't open the file so return an error message.
     return new XML_RPC_Response(0, $XML_RPC_erruser + 1, $this->objLanguage->languageText("mod_packages_fileerr", "packages"));
 }
Example #16
0
function xmlrpc_au_000_auth($message)
{
    $re_false = array('result' => 1);
    $param = $message->getParam(0);
    if (!XML_RPC_Value::isValue($param)) {
        return xmlrpc_get_response($re_false);
    }
    $params = XML_RPC_decode($param);
    if (empty($params['mail'])) {
        //メールアドレス必須
        return xmlrpc_get_response($re_false);
    }
    if (empty($params['passwd'])) {
        //パスワード必須
        return xmlrpc_get_response($re_false);
    }
    if (is_null($params['sidflg']) || $params['sidflg'] === '') {
        //セッション作成フラグ必須
        return xmlrpc_get_response($re_false);
    }
    if (!is_numeric($params['sidflg'])) {
        //セッション作成フラグは数値
        return xmlrpc_get_response($re_false);
    }
    if (intval($params['sidflg']) != 0 && intval($params['sidflg']) != 1) {
        //セッション作成フラグは0 or 1
        return xmlrpc_get_response($re_false);
    }
    $user_mail = htmlentities($params['mail']);
    $user_passwd = htmlentities($params['passwd']);
    $sid = htmlspecialchars($params['sid']);
    $sidflg = intval($params['sidflg']);
    $is_ktai = is_ktai_mail_address($user_mail);
    //携帯か?
    if ($is_ktai) {
        //携帯からのアクセス
        $c_member_id = OP::op_member_k_auth_login($user_mail, $user_passwd);
    } else {
        //PCからのアクセス
        $c_member_id = OP::op_member_auth_login($user_mail, $user_passwd);
    }
    if (!$c_member_id) {
        //メンバIDが取得できたか?
        return xmlrpc_get_response($re_false);
    }
    if (OP::op_member_is_login_rejected($c_member_id)) {
        //ログイン拒否されているか?
        return xmlrpc_get_response($re_false);
    }
    if (!OP::op_member_is_active_c_member_id($c_member_id)) {
        //アクティブメンバーか?
        return xmlrpc_get_response($re_false);
    }
    if (!$sidflg) {
        //セッションIDを作成するか
        $req = array('c_member_id' => $c_member_id, 'address' => $user_mail, 'password' => $user_passwd, 'sid' => $sid, 'is_ktai' => $is_ktai);
        if (!($session_id = OP::op_k_login($req))) {
            return xmlrpc_get_response($re_false);
        }
        $re_true = array('result' => 0, 'sid' => $session_id, 'mid' => intval($c_member_id));
    } else {
        //セッションIDを作成しない
        $re_true = array('result' => 0, 'mid' => intval($c_member_id));
    }
    return xmlrpc_get_response($re_true);
}
 /**
  * Method to insert  a mail
  * @params array $params  
  * @return int
  * @access public
  */
 public function sendMail($params)
 {
     try {
         $param = $params->getParam(0);
         if (!XML_RPC_Value::isValue($param)) {
             log_debug($param);
         }
         $emailId = $param->scalarval();
         $param = $params->getParam(1);
         if (!XML_RPC_Value::isValue($param)) {
             log_debug($param);
         }
         $senderId = $param->scalarval();
         $userId = $this->objUser->getUserId($senderId);
         $param = $params->getParam(2);
         if (!XML_RPC_Value::isValue($param)) {
             log_debug($param);
         }
         $recipientList = $param->scalarval();
         $param = $params->getParam(3);
         if (!XML_RPC_Value::isValue($param)) {
             log_debug($param);
         }
         $subject = $param->scalarval();
         $param = $params->getParam(4);
         if (!XML_RPC_Value::isValue($param)) {
             log_debug($param);
         }
         $message = $param->scalarval();
         $attachement = "";
         $this->objDbEmail->sendMail($recipientList, $subject, $message, $attachment, $userId, $emailId);
         $emailStruct = new XML_RPC_Value(array(new XML_RPC_Value($emailId, "string")), "array");
         return new XML_RPC_Response($emailStruct);
     } catch (customException $e) {
         echo customException::cleanUp();
         die($e);
     }
 }
Example #18
0
 /**
  * Record a Skype sound bite from the caller or callers (this can be used in concurrent calls). The recorsing is simply dumped to disc, then transported via this API to Chisimba 
  * and the podcast module. Again, because there is no better place for it at the moment.
  *
  * @param object $params - XML-RPC object containing paramaters from the API
  * @return object - XML-RPC object of th return response. In this case a string.
  */
 public function soundbite($params)
 {
     // Gran the file data as a base64_encoded string
     $param = $params->getParam(0);
     if (!XML_RPC_Value::isValue($param)) {
         log_debug($param);
     }
     $file = $param->scalarval();
     // Get the username of the person doing the upload. (This is hard coded for now in the Skype Python tool API)
     $param = $params->getParam(1);
     if (!XML_RPC_Value::isValue($param)) {
         log_debug($param);
     }
     $username = $param->scalarval();
     // base64 decode the file and write it down
     $file = base64_decode($file);
     // Grab the user id based on the username parameter.
     $userid = $this->objUser->getUserId($username);
     // Make sure the directory that we are using exists and all.
     if (!file_exists($this->objConfig->getContentBasePath() . 'users/' . $userid . "/")) {
         // else create the darn thing!
         @mkdir($this->objConfig->getContentBasePath() . 'users/' . $userid . "/");
         @chmod($this->objConfig->getContentBasePath() . 'users/' . $userid . "/", 0777);
     }
     // Make up a filename. This one is based on timestamp appended by _skypecall. It is a .wav for now, still trying to figurte out a better format for transporting.
     $filename = time() . "_skypecall.wav";
     // local file name.
     $localfile = $this->objConfig->getContentBasePath() . 'users/' . $userid . "/" . $filename;
     // smash the file data into the filename and forget about it.
     file_put_contents($localfile, $file);
     // A quick conversion
     $media = $this->getObject('media', 'utilities');
     // convert the .wav to a .mp3
     $mp3 = $media->convertWav2Mp3($localfile, $this->objConfig->getContentBasePath() . 'users/' . $userid . "/");
     // Now add to list of podcasts
     // get the file size
     $filesize = filesize($mp3);
     if (extension_loaded('fileinfo')) {
         // hopefully sane folks will have fileinfo installed.
         $finfo = finfo_open(FILEINFO_MIME);
         // MIME type
         $type = finfo_file($finfo, $filename);
     } else {
         // fall back to the old skewl method (deprecated btw)
         $type = mime_content_type($filename);
     }
     $mimetype = $type;
     //mime_content_type($mp3);
     // category? dunno.
     $category = '';
     // version 1 as we just created the file.
     $version = 1;
     // The file we are going to be working with
     $fmname = basename($localfile, ".wav");
     // end name
     $fmname = $fmname . ".mp3";
     // some path info
     $fmpath = 'users/' . $userid . '/' . $fmname;
     $path = $this->objConfig->getContentBasePath() . 'users/' . $userid . "/";
     // Dunno wtf this is sposed to be...
     $idcomment = NULL;
     // add the MP3 to the user's filemanager set
     $fileId = $this->objFiles->addFile($fmname, $fmpath, $filesize, $mimetype, $category, $version, $userid, $idcomment);
     // now take the generated FileID and insert the podcast to the podcast module.
     $pod = $this->getObject('dbpodcast', 'podcast');
     $ret = $pod->addPodcast($fileId, $userid, basename($filename, ".wav"));
     // return an XML-RPC string response as an object in case anyone is listening.
     $val = new XML_RPC_Value("File saved to {$localfile}", 'string');
     return new XML_RPC_Response($val);
     // Ooops, couldn't open the file so return an error message.
     return new XML_RPC_Response(0, $XML_RPC_erruser + 1, $this->objLanguage->languageText("mod_packages_fileerr", "packages"));
 }
 /**
  * Method to convert the document
  */
 public function convertDoc($params, $type)
 {
     $this->objModules = $this->getObject('modules', 'modulecatalogue');
     if ($type == 'swftools') {
         $moduleRegistered = $this->objModules->checkIfRegistered('swftools');
     } else {
         $moduleRegistered = $this->objModules->checkIfRegistered('documentconverter');
     }
     // If module is not registered, return 0, can't do anything
     if (!$moduleRegistered) {
         $noResponse = new XML_RPC_Value('0', 'string');
         return new XML_RPC_Response($noResponse);
     }
     // get password
     $param = $params->getParam(0);
     if (!XML_RPC_Value::isValue($param)) {
         log_debug($param);
     }
     $password = $param->scalarval();
     // get Required Password
     $requiredPassword = $this->objSysconfig->getValue('REMOTEPASSWORD', 'documentconverter');
     // Check if match
     if ($password != $requiredPassword) {
         $noResponse = new XML_RPC_Value('0', 'string');
         return new XML_RPC_Response($noResponse);
     }
     // get current filename
     $param = $params->getParam(1);
     if (!XML_RPC_Value::isValue($param)) {
         log_debug($param);
     }
     $filename = $param->scalarval();
     // get contents of file
     $param = $params->getParam(2);
     if (!XML_RPC_Value::isValue($param)) {
         log_debug($param);
     }
     $contents = $param->scalarval();
     // get filename of converted file
     $param = $params->getParam(3);
     if (!XML_RPC_Value::isValue($param)) {
         log_debug($param);
     }
     $this->convertFilename = $param->scalarval();
     // Create Temp Directory
     $dirName = md5($filename . $this->convertFilename . time());
     // Full Path to Temp Directory
     $dirToSave = $this->objConfig->getContentBasePath() . '/remoteconversion/' . $dirName;
     // Load Classes
     $objMkdir = $this->getObject('mkdir', 'files');
     $objCleanUrl = $this->getObject('cleanurl', 'filemanager');
     // Clean Paths
     $dirToSave = $objCleanUrl->cleanUpUrl($dirToSave);
     // Make Directory
     $objMkdir->mkdirs($dirToSave);
     // Store File Contents
     file_put_contents($dirToSave . '/' . $filename, base64_decode($contents));
     // Convert Files
     if ($type == 'swftools') {
         $objSWFTools = $this->getObject('pdf2flash', 'swftools');
         $objSWFTools->convert2SWF($dirToSave . '/' . $filename, $dirToSave . '/' . $this->convertFilename);
     } else {
         $objDocumentConverter = $this->getObject('convertdoc', 'documentconverter');
         $objDocumentConverter->convert($dirToSave . '/' . $filename, $dirToSave . '/' . $this->convertFilename);
     }
     // Delete Original File
     @unlink($dirToSave . '/' . $filename);
     $convertedFile = new XML_RPC_Value($this->returnFile($dirToSave), 'string');
     return new XML_RPC_Response($convertedFile);
 }
 /**
  * delete post
  * 
  * Deletes a post
  * 
  * @param  object $params Parameters 
  * @return object Return
  * @access public
  */
 public function bloggerDeletePost($params)
 {
     $param = $params->getParam(0);
     if (!XML_RPC_Value::isValue($param)) {
         log_debug($param);
     }
     $appkey = $param->scalarval();
     $param = $params->getParam(1);
     if (!XML_RPC_Value::isValue($param)) {
         log_debug($param);
     }
     $postid = $param->scalarval();
     $param = $params->getParam(2);
     if (!XML_RPC_Value::isValue($param)) {
         log_debug($param);
     }
     $username = $param->scalarval();
     $param = $params->getParam(3);
     if (!XML_RPC_Value::isValue($param)) {
         log_debug($param);
     }
     $pass = $param->scalarval();
     $this->objDbBlog->deletePost($postid);
     $val = new XML_RPC_Value(TRUE, 'boolean');
     return new XML_RPC_Response($val);
 }
 public function getPresentationSlidesFormattedAPI($params)
 {
     $param = $params->getParam(0);
     if (!XML_RPC_Value::isValue($param)) {
         log_debug($param);
     }
     $id = $param->scalarval();
     $data = $this->objDbSlides->getPresentationSlidesFormatted($id);
     return new XML_RPC_Response(new XML_RPC_Value($data, 'string'));
 }
 public function fileDrop($params)
 {
     $param = $params->getParam(0);
     if (!XML_RPC_Value::isValue($param)) {
         log_debug($param);
     }
     $username = $param->scalarval();
     $param = $params->getParam(1);
     if (!XML_RPC_Value::isValue($param)) {
         log_debug($param);
     }
     $password = $param->scalarval();
     $param = $params->getParam(2);
     if (!XML_RPC_Value::isValue($param)) {
         log_debug($param);
     }
     $file = $param->scalarval();
     $file = base64_decode($file);
     $userid = $this->objUser->getUserId($username);
     // Rackspace Files case
     if ($this->objModuleCat->checkIfRegistered('rackspacecloudfiles')) {
         $param = $params->getParam(3);
         if (!XML_RPC_Value::isValue($param)) {
             log_debug($param);
         }
         $filename = $param->scalarval();
         $filename = str_replace(" ", "_", $filename);
         $localfile = $this->objConfig->getContentBasePath() . 'users/' . $userid . "/" . $filename;
         file_put_contents($localfile, $file);
         $this->objCloudfiles->uploadFile($userid, $filename, $localfile);
         // read the metadata and insert some stuff to the db for indexing
         if ($this->objModuleCat->checkIfRegistered('imagevault')) {
             $this->objOps->insertImageData($userid, $localfile);
         }
         // $this->objOps->insertImageData($userid, $localfile);
         // clean up the file from local
         unlink($localfile);
         // send a response
         $val = new XML_RPC_Value("saved", 'string');
         return new XML_RPC_Response($val);
     } else {
         if (!file_exists($this->objConfig->getContentBasePath() . 'users/' . $userid . "/")) {
             @mkdir($this->objConfig->getContentBasePath() . 'users/' . $userid . "/");
             @chmod($this->objConfig->getContentBasePath() . 'users/' . $userid . "/", 0777);
         }
         $param = $params->getParam(3);
         if (!XML_RPC_Value::isValue($param)) {
             log_debug($param);
         }
         $filename = $param->scalarval();
         $objOverwriteIncrement = $this->getObject('overwriteincrement', 'filemanager');
         $filename = $objOverwriteIncrement->checkfile($filename, 'users/' . $userid);
         $localfile = $this->objConfig->getContentBasePath() . 'users/' . $userid . "/" . $filename;
         file_put_contents($localfile, $file);
         $fmname = basename($filename);
         $fmpath = 'users/' . $userid . '/' . $fmname;
         // Add to users fileset
         $fileId = $this->objFileIndexer->processIndexedFile($fmpath, $userid);
         $this->objOps->insertImageData($userid, $localfile);
         $val = new XML_RPC_Value("saved", 'string');
         return new XML_RPC_Response($val);
     }
 }
 public function acceptUserTagsData($params)
 {
     $param = $params->getParam(0);
     if (!XML_RPC_Value::isValue($param)) {
         log_debug($param);
     }
     // finally grok the actual message out of the xmlrpc message encoding
     $msg = $param->scalarval();
     $user = $params->getParam(1);
     if (!XML_RPC_Value::isValue($user)) {
         log_debug($user);
     }
     // finally grok the actual username out of the xmlrpc message encoding
     $user = $user->scalarval();
     $pass = $params->getParam(2);
     if (!XML_RPC_Value::isValue($pass)) {
         log_debug($pass);
     }
     // finally grok the actual username out of the xmlrpc message encoding
     $pass = $pass->scalarval();
     $auth = $this->objUser->authenticateUser($user, $pass);
     if ($auth != 1) {
         $ret = "Login failure!";
         $val = new XML_RPC_Value($ret, 'string');
         return new XML_RPC_Response($val);
     }
     // messages are base64_encoded
     $msg = base64_decode($msg);
     // msg is tab separated string of data
     $data = explode("\t", $msg);
     $userid = $this->objUser->getUserId($user);
     // map the data to the insert array
     $insarr = array('userid' => $userid, 'geonameid' => $data[0], 'tag' => $data[1]);
     // insert the row to the database
     if ($this->dataCapable == TRUE) {
         $this->objDbGeonames->insertUserTagsInfo($insarr);
         $ret = "Success";
         $val = new XML_RPC_Value($ret, 'string');
         return new XML_RPC_Response($val);
     } else {
         $ret = "This server is not yet capable of handling geo data. Please install the geonames module!";
         $val = new XML_RPC_Value($ret, 'string');
         return new XML_RPC_Response($val);
     }
 }
Example #24
0
 public function userDelete($params)
 {
     $objUAModel = $this->getObject('useradmin_model2', 'security');
     $objUser = $this->getObject('user', 'security');
     $param = $params->getParam(0);
     if (!XML_RPC_Value::isValue($param)) {
         log_debug($param);
     }
     $username = $param->scalarval();
     $username = explode("(", $username);
     $param = $params->getParam(1);
     if (!XML_RPC_Value::isValue($param)) {
         log_debug($param);
     }
     $adminuser = $param->scalarval();
     $param = $params->getParam(2);
     if (!XML_RPC_Value::isValue($param)) {
         log_debug($param);
     }
     $adminpass = $param->scalarval();
     $adminuserdetails = $objUser->lookupData($adminuser);
     $adUserId = $adminuserdetails['userid'];
     if (!isset($username) || empty($username)) {
         $val = new XML_RPC_Value("FALSE", "string");
     } elseif (!$objUser->authenticateUser($adminuser, $adminpass, FALSE)) {
         // fail
         $val = new XML_RPC_Value("FALSE", "string");
     } elseif (!$objUser->inAdminGroup($adUserId)) {
         // fail
         $val = new XML_RPC_Value("FALSE", "string");
     } else {
         $username = trim($username[0]);
         $userdetails = $objUser->lookupData($username);
         $id = $objUser->PKId($userdetails['userid']);
         $res = $objUAModel->apiUserDelete($id);
         if ($res) {
             $val = new XML_RPC_Value("TRUE", "string");
         } else {
             $val = new XML_RPC_Value("FALSE", "string");
         }
     }
     return new XML_RPC_Response($val);
 }
 public function isContextPlugin($params)
 {
     try {
         $param = $params->getParam(0);
         if (!XML_RPC_Value::isValue($param)) {
             log_debug($param);
         }
         $contextCode = $param->scalarval();
         $param = $params->getParam(1);
         if (!XML_RPC_Value::isValue($param)) {
             log_debug($param);
         }
         $moduleId = $param->scalarval();
         $objContextModules = $this->getObject('dbcontextmodules', 'context');
         $isPlugin = (int) $objContextModules->isContextPlugin($contextCode, $moduleId);
         $postStruct = new XML_RPC_Value($isPlugin, "int");
         return new XML_RPC_Response($postStruct);
     } catch (customException $e) {
         customException::cleanUp();
         exit;
     }
 }
Example #26
0
 /**
  * insert a reply to a post
  * 
  * insert reply information into database
  * 
  * @return object 
  * @access public
  */
 public function forumInsertPost($params)
 {
     try {
         $param = $params->getParam(0);
         if (!XML_RPC_Value::isValue($param)) {
             log_debug($param);
         }
         $post_title = $param->scalarval();
         $param = $params->getParam(1);
         if (!XML_RPC_Value::isValue($param)) {
             log_debug($param);
         }
         $post_text = $param->scalarval();
         $post_text = "<p>" . $post_text . "</p>";
         $param = $params->getParam(2);
         if (!XML_RPC_Value::isValue($param)) {
             log_debug($param);
         }
         $type_id = $param->scalarval();
         $param = $params->getParam(3);
         if (!XML_RPC_Value::isValue($param)) {
             log_debug($param);
         }
         $forum_id = $param->scalarval();
         $param = $params->getParam(4);
         if (!XML_RPC_Value::isValue($param)) {
             log_debug($param);
         }
         $username = $param->scalarval();
         $userId = $this->objUser->getUserId($username);
         $param = $params->getParam(5);
         if (!XML_RPC_Value::isValue($param)) {
             log_debug($param);
         }
         $topic_id = $param->scalarval();
         $param = $params->getParam(6);
         if (!XML_RPC_Value::isValue($param)) {
             log_debug($param);
         }
         $parentPostId = $param->scalarval();
         $parentPostDetails = $this->objPost->getRow('id', $parentPostId);
         $level = $parentPostDetails["level"] + 1;
         $post_id = $this->objPost->insertSingle($parentPostId, 0, $forum_id, $topic_id, $userId, $level);
         $this->objPostText->insertSingle($post_id, $post_title, $post_text, "em", $userId, "1");
         $this->objTopic->updateLastPost($topic_id, $post_id);
         $this->objForum->updateLastPost($forum_id, $post_id);
         // Attachment Handling
         //$this->handleAttachments($post_id, $_POST['temporaryId']);
         $postStruct = new XML_RPC_Value(array(new XML_RPC_Value($topic_id, "string"), new XML_RPC_Value($post_title, "string"), new XML_RPC_Value($forum_name, "string")), "array");
         //$postStruct[] = $struct;
         //$postArray = new XML_RPC_Value($postStruct,"array");
         return new XML_RPC_Response($postStruct);
     } catch (customException $e) {
         echo customException::cleanUp();
         die($e);
     }
 }
 public function addCollRecord($params)
 {
     $param = $params->getParam(0);
     if (!XML_RPC_Value::isValue($param)) {
         log_debug($param);
     }
     $coll = $param->scalarval();
     $collid = $this->objDbColl->getCollByName($coll);
     $param = $params->getParam(1);
     if (!XML_RPC_Value::isValue($param)) {
         log_debug($param);
     }
     $accno = $param->scalarval();
     $param = $params->getParam(2);
     if (!XML_RPC_Value::isValue($param)) {
         log_debug($param);
     }
     $title = $param->scalarval();
     $param = $params->getParam(3);
     if (!XML_RPC_Value::isValue($param)) {
         log_debug($param);
     }
     $description = $param->scalarval();
     $param = $params->getParam(4);
     if (!XML_RPC_Value::isValue($param)) {
         log_debug($param);
     }
     $comment = $param->scalarval();
     $param = $params->getParam(5);
     if (!XML_RPC_Value::isValue($param)) {
         log_debug($param);
     }
     $file = $param->scalarval();
     $file = base64_decode($file);
     $param = $params->getParam(6);
     if (!XML_RPC_Value::isValue($param)) {
         log_debug($param);
     }
     $fname = $param->scalarval();
     $param = $params->getParam(7);
     if (!XML_RPC_Value::isValue($param)) {
         log_debug($param);
     }
     $username = $param->scalarval();
     $userid = $this->objUser->getUserId($username);
     // log_debug($userid);
     if (!file_exists($this->objConfig->getContentBasePath() . 'users/' . $userid . "/")) {
         @mkdir($this->objConfig->getContentBasePath() . 'users/' . $userid . "/");
         @chmod($this->objConfig->getContentBasePath() . 'users/' . $userid . "/", 0777);
     }
     $objOverwriteIncrement = $this->getObject('overwriteincrement', 'filemanager');
     $fname = $objOverwriteIncrement->checkfile($fname, 'users/' . $userid);
     $localfile = $this->objConfig->getContentBasePath() . 'users/' . $userid . "/" . $fname;
     file_put_contents($localfile, $file);
     $fmname = basename($fname);
     $fmpath = 'users/' . $userid . '/' . $fmname;
     // Add to users fileset
     $fileId = $this->objFileIndexer->processIndexedFile($fmpath, $userid);
     // now add the record to the sahris collections database
     $insarr = array('userid' => $userid, 'accno' => $accno, 'collection' => $collid, 'title' => $title, 'description' => $description, 'media' => $fileId, 'comment' => $comment);
     $res = $this->objDbColl->insertRecord($insarr);
     $val = new XML_RPC_Value($res, 'string');
     return new XML_RPC_Response($val);
 }
 public function grabHiResShot($params)
 {
     $param = $params->getParam(0);
     if (!XML_RPC_Value::isValue($param)) {
         log_debug($param);
     }
     $url = $param->scalarval();
     chdir($this->objConfig->getContentBasePath() . 'apitmp/screenshots/output/');
     $result = md5($url);
     $filetosend = @file_get_contents($result . '.png');
     if (!$filetosend) {
         $val = new XML_RPC_Value('FALSE', 'string');
         return new XML_RPC_Response($val);
     } else {
         $filetosend = base64_encode($filetosend);
         $val = new XML_RPC_Value($filetosend, 'string');
         return new XML_RPC_Response($val);
         // Ooops, couldn't open the file so return an error message.
         return new XML_RPC_Response(0, $XML_RPC_erruser + 1, $this->objLanguage->languageText("mod_packages_fileerr", "packages"));
     }
 }
 /**
 * Lists all links for a given page. The returned array contains structs, with the following elements:
 * 
 * page (string) : The page name or URL the link is to.
 * type (string) : The link type. This is a string, with the following possible values:
      o &amp;amp;amp;amp;amp;amp;quot;external&amp;amp;amp;amp;amp;amp;quot; : The link is an external hyperlink
      o &amp;amp;amp;amp;amp;amp;quot;local&amp;amp;amp;amp;amp;amp;quot; : This is a local Wiki name for hyperlinking 
 * href (string) : The HREF the link points to. Useful for finding this link within the HTML of this page. 
 *
 * @param string $params
 * @return string
 */
 public function listLinks($params)
 {
     $param = $params->getParam(0);
     if (!XML_RPC_Value::isValue($param)) {
         log_debug($param);
     }
     $pagename = $param->scalarval();
     $param = $params->getParam(1);
     if (!XML_RPC_Value::isValue($param)) {
         log_debug($param);
     }
     $wikiid = $param->scalarval();
     $this->objDbWiki->wikiId = $wikiid;
     $data = $this->objDbWiki->getLinks();
     $val = new XML_RPC_Value($data, "array");
     // send it back as a struct encoded value
     return new XML_RPC_Response($val);
 }
 public function fileDrop($params)
 {
     $param = $params->getParam(0);
     if (!XML_RPC_Value::isValue($param)) {
         log_debug($param);
     }
     $username = $param->scalarval();
     $param = $params->getParam(1);
     if (!XML_RPC_Value::isValue($param)) {
         log_debug($param);
     }
     $password = $param->scalarval();
     $param = $params->getParam(2);
     if (!XML_RPC_Value::isValue($param)) {
         log_debug($param);
     }
     $file = $param->scalarval();
     $file = base64_decode($file);
     $userid = $this->objUser->getUserId($username);
     if (!file_exists($this->objConfig->getContentBasePath() . 'users/' . $userid . "/")) {
         @mkdir($this->objConfig->getContentBasePath() . 'users/' . $userid . "/");
         @chmod($this->objConfig->getContentBasePath() . 'users/' . $userid . "/", 0777);
     }
     $param = $params->getParam(3);
     if (!XML_RPC_Value::isValue($param)) {
         log_debug($param);
     }
     $filename = $param->scalarval();
     $objOverwriteIncrement = $this->getObject('overwriteincrement', 'filemanager');
     $filename = $objOverwriteIncrement->checkfile($filename, 'users/' . $userid);
     $localfile = $this->objConfig->getContentBasePath() . 'users/' . $userid . "/" . $filename;
     file_put_contents($localfile, $file);
     $fmname = basename($filename);
     $fmpath = 'users/' . $userid . '/' . $fmname;
     // Add to users fileset
     $fileId = $this->objFileIndexer->processIndexedFile($fmpath, $userid);
     $val = new XML_RPC_Value("File saved", 'string');
     return new XML_RPC_Response($val);
 }