コード例 #1
0
ファイル: xmlrpc.php プロジェクト: BGCX067/f2cont-svn-to-git
function metaWeblog_newMediaObject($values)
{
    //2007-02-01 add support for uploading files
    global $settingInfo, $DMC, $DBPrefix, $defualtcategoryid;
    $userdetail = check_user_pw($values['username'], $values['password']);
    $struct = $values['struct'];
    $foldername = date("Ym");
    //writetofile ('text1.php', $struct['bits']); //debug only
    if ($struct['bits'] && $struct['name']) {
        $type = strtolower(substr($struct['name'], strrpos($struct['name'], ".") + 1));
        if (strpos(";" . $settingInfo['attachType'], $type) > 0 && strpos(";php|phtml|php3|jsp|exe|dll|asp|aspx|asa|cgi|fcgi|pl", $type) < 1) {
            $writefilecontent = base64_decode($struct['bits']);
            if (file_exists("attachments/{$foldername}/{$struct['name']}")) {
                @unlink("attachments/{$foldername}/{$struct['name']}");
            }
            $filenum = @fopen("attachments/{$foldername}/{$struct['name']}", "wb");
            if (!$filenum) {
                xml_error("Sorry, uploading file ({$struct['name']}) failed.");
            }
            flock($filenum, LOCK_EX);
            fwrite($filenum, $writefilecontent);
            fclose($filenum);
            $xml_content = make_xml_piece("struct", array('url' => "{$settingInfo['blogurl']}attachments/{$foldername}/{$struct['name']}"));
        } else {
            $xml_content = make_xml_piece("struct", array('url' => "{$settingInfo['blogurl']}index.php"));
        }
    } else {
        $xml_content = make_xml_piece("struct", array('url' => "{$settingInfo['blogurl']}index.php"));
    }
    $body_xml = xml_generate($xml_content);
    send_response($body_xml);
}
コード例 #2
0
ファイル: xmlrpc.php プロジェクト: BGCX067/f2cont-svn-to-git
function metaWeblog_newMediaObject($values)
{
    //2006-12-2 add support for uploading files
    global $config, $defualtcategoryid, $db_prefix, $mbcon, $nowtime;
    $userdetail = check_user($values['username'], $values['password']);
    $struct = $values['struct'];
    //writetofile ('text1.php', $struct['bits']); //debug only
    if ($struct['bits'] && $struct['name']) {
        $writefilecontent = base64_decode($struct['bits']);
        $ext = strtolower(strrchr($struct['name'], '.'));
        $ext = str_replace(".", '', $ext);
        $upload_filename = time() . '_' . rand(1000, 9999) . substr(md5($struct['name']), 0, 4) . '.' . $ext;
        if ($mbcon['uploadfolders'] == '1') {
            $targetfolder_ym = date("Ym") . '/';
            $targetfolder = "attachment/{$targetfolder_ym}";
            if (!is_dir($targetfolder)) {
                $mktargetfolder = @mkdir($targetfolder, 0777);
                if (!$mktargetfolder) {
                    xml_error("Sorry, uploading file ({$struct['name']}) failed because PHP was unable to create a new directory.");
                }
            }
        } else {
            $targetfolder_ym = '';
            $targetfolder = 'attachment';
        }
        $filenum = @fopen("{$targetfolder}/{$upload_filename}", "wb");
        if (!$filenum) {
            xml_error("Sorry, uploading file ({$struct['name']}) failed.");
        }
        flock($filenum, LOCK_EX);
        fwrite($filenum, $writefilecontent);
        fclose($filenum);
        //DB updating, new function in 2.1.0
        $blog = new boblog();
        $blog->query("INSERT INTO `{$db_prefix}upload` (fid,filepath,originalname,uploadtime,uploaduser) VALUES (null, \"attachment/{$targetfolder_ym}{$upload_filename}\", \"{$struct['name']}\", {$nowtime['timestamp']}, {$userdetail['userid']})");
        $currentid = db_insert_id();
        if ($mbcon['wmenable'] == '1') {
            //Add watermark
            $imgext_watermark = array('jpg', 'gif', 'png');
            if (in_array($ext, $imgext_watermark)) {
                create_watermark("attachment/{$targetfolder_ym}{$upload_filename}");
            }
        }
    }
    $xml_content = make_xml_piece("struct", array('url' => "{$config['blogurl']}/attachment.php?fid={$currentid}"));
    $body_xml = xml_generate($xml_content);
    send_response($body_xml);
}
コード例 #3
0
ファイル: xmlrpc.php プロジェクト: BGCX067/f2cont-svn-to-git
function metaWeblog_newMediaObject($values)
{
    //2007-02-01 add support for uploading files
    global $settingInfo, $DMC, $DBPrefix, $defualtcategoryid;
    $userdetail = check_user_pw($values['username'], $values['password']);
    $struct = $values['struct'];
    //writetofile ('text1.php', $struct['bits']); //debug only
    if ($struct['bits'] && $struct['name']) {
        $writefilecontent = base64_decode($struct['bits']);
        if (file_exists("attachments/{$struct['name']}")) {
            @unlink("attachments/{$struct['name']}");
        }
        $filenum = @fopen("attachments/{$struct['name']}", "wb");
        if (!$filenum) {
            xml_error("Sorry, uploading file ({$struct['name']}) failed.");
        }
        flock($filenum, LOCK_EX);
        fwrite($filenum, $writefilecontent);
        fclose($filenum);
    }
    $xml_content = make_xml_piece("struct", array('url' => "{$settingInfo['blogurl']}/attachments/{$struct['name']}"));
    $body_xml = xml_generate($xml_content);
    send_response($body_xml);
}