Source for file mms.php
Documentation is available at mms.php
* MMS Server - injecting mms messages from a mobile phone into a blog
* b2evolution - {@link http://b2evolution.net/}
* This file built upon code from original Peffisaur -
* Stefan Hellkvist - {@link http://hellkvist.org}
* Released under GNU GPL License - http://b2evolution.net/about/license.html
* @copyright (c)2004 by Hans Reinders - {@link http://hansreinders.com}
* @todo MOVE THIS FILE TO /htsrv
require_once( dirname(__FILE__
).
'/b2evocore/_main.php' );
param( 'login', 'string', '', true );
param( 'pass', 'string', '', true );
param( 'cat', 'integer', $default_category, true );
if( !user_pass_ok( $login, $pass, false ) ||
$_SERVER['CONTENT_TYPE'] !=
"application/vnd.wap.mms-message" ||
strlen( $HTTP_RAW_POST_DATA ) ==
0 ) exit;
$current_User->check_perm( 'blog_post_statuses', 'published', true, $blog );
define( "CONTENT_LOCATION", 0x03 );
define( "CONTENT_TYPE", 0x04 );
define( "DELIVERY_REPORT", 0x06 );
define( "DELIVERY_TIME", 0x07 );
define( "MESSAGE_CLASS", 0x0A );
define( "MESSAGE_TYPE", 0x0C );
define( "MMS_VERSION", 0x0D );
define( "MESSAGE_SIZE", 0x0E );
define( "REPORT_ALLOWED", 0x11 );
define( "RESPONSE_STATUS", 0x12 );
define( "RESPONSE_TEXT", 0x13 );
define( "SENDER_VISIBILITY", 0x14 );
define( "TRANSACTION_ID", 0x18 );
define( "MULTIPART_MIXED", 0x23 );
define( "MULTIPART_RELATED", 0x33 );
$content_types =
array( "*/*", "text/*", "text/html", "text/plain",
"text/x-hdml", "text/x-ttml", "text/x-vCalendar",
"text/x-vCard", "text/vnd.wap.wml",
"text/vnd.wap.wmlscript", "text/vnd.wap.wta-event",
"multipart/*", "multipart/mixed",
"multipart/form-data", "multipart/byterantes",
"multipart/alternative", "application/*",
"application/x-www-form-urlencoded",
"application/x-hdmlc", "application/vnd.wap.wmlc",
"application/vnd.wap.wmlscriptc",
"application/vnd.wap.wta-eventc",
"application/vnd.wap.uaprof",
"application/vnd.wap.wtls-ca-certificate",
"application/vnd.wap.wtls-user-certificate",
"application/x-x509-ca-cert",
"application/x-x509-user-cert",
"image/*", "image/gif", "image/jpeg", "image/tiff",
"image/png", "image/vnd.wap.wbmp",
"application/vnd.wap.multipart.*",
"application/vnd.wap.multipart.mixed",
"application/vnd.wap.multipart.form-data",
"application/vnd.wap.multipart.byteranges",
"application/vnd.wap.multipart.alternative",
"application/xml", "text/xml",
"application/vnd.wap.wbxml",
"application/x-x968-cross-cert",
"application/x-x968-ca-cert",
"application/x-x968-user-cert",
"application/vnd.wap.sic",
"application/vnd.wap.slc",
"application/vnd.wap.coc",
"application/vnd.wap.multipart.related",
"application/vnd.wap.sia",
"text/vnd.wap.connectivity-xml",
"application/vnd.wap.connectivity-wbxml",
"application/pkcs7-mime",
"application/vnd.wap.hashed-certificate",
"application/vnd.wap.signed-certificate",
"application/vnd.wap.cert-response",
"application/vnd.wap.mms-message",
"application/vnd.wap.rollover-certificate",
"application/vnd.wap.locc+wbxml",
"application/vnd.wap.loc+xml",
"application/vnd.syncml.dm+wbxml",
"application/vnd.syncml.dm+xml",
"application/vnd.syncml.notification",
"application/vnd.wap.xhtml+xml",
"application/vnd.wv.csp.cir",
"application/vnd.oma.dd+xml",
"application/vnd.oma.drm.message",
"application/vnd.oma.drm.content",
"application/vnd.oma.drm.rights+xml",
"application/vnd.oma.drm.rights+wbxml" );
$typeToExtension =
array( IMAGE_GIF =>
".gif",
"application/smil" =>
".smil",
"x-music/x-midi" =>
".mid",
"application/zip" =>
".zip",
"text/x-imelody" =>
".imy" );
for ( $i =
0; $i <
sizeof( $parts ); $i++
)
$size =
$size+
$p->dataLen;
if ( is_string( $contentType ) ) return $contentType;
return $content_types[$contentType];
for ( $i =
0; $i <
sizeof( $parts ); $i++
)
if ( array_key_exists( $contentType, $typeToExtension ) ) return $typeToExtension[$contentType];
if ( ord( $text{0} ) ==
0xff &&
ord( $text{1} ) ==
0xfe )
for ( $i =
2; $i <
strlen( $text ); $i +=
2 ) $res .=
$text{$i};
for ( $i =
0; $i <
sizeof( $data ); $i++
) $res .=
chr( $data[$i] );
$reply[0] =
0x8c; // X-Mms-Message-Type
$reply[1] =
0x81; // = m-send-conf
$reply[2] =
0x98; // X-Mms-Transaction-ID
for ( $i =
3; $i <
strlen( $md->transactionId )+
3; $i++
) $reply[$i] =
ord( $md->transactionId{$i-
3} );
$reply[$i++
]=
0; // Terminate string
$reply[$i++
]=
0x8D; // X-Mms-Version
$reply[$i++
]=
0x90; // = 1.0
$reply[$i++
]=
0x92; // X-Mms-Response-Status
$reply[$i++
]=
128; // = OK
header("Content-Type: application/vnd.wap.mms-message");
for ( $j =
0; $j <
$i; $j++
) print
( chr( $reply[$j] ) );
return $ch ==
40 ||
$ch ==
41 ||
$ch ==
60 ||
$ch ==
62 ||
$ch ==
64 ||
$ch ==
44 ||
$ch ==
58 ||
$ch ==
59 ||
$ch ==
92 ||
$ch ==
47 ||
$ch ==
123 ||
$ch ==
125 ||
$ch ==
91 ||
$ch ==
93 ||
$ch ==
63 ||
$ch ==
61 ||
$ch ==
32 ||
$ch ==
11;
for ( $i =
0; $i <
$datalen; $i++
) $this->data[$i] =
ord( $data{$i} );
$this->curp =
$tmp+
$length;
if ( $isencoded ) $this->curp++
;
if ( $ch<
32 ||
$ch ==
127 ) return 0;
$this->from =
"Anonymous";
if ($this->data[$this->curp]<
128 ||
$this->data[$this->curp]>
131) die( "parseMessageClass not fully implemented" );
if (!($this->data[$this->curp] & 0x80)) return 0;
for ( $i =
0; $i <
$noctets; $i++
)
$part->dataLen =
$dataLen;
$this->curp =
$tmp+
$headersLen;
for ( $j =
0; $j <
$dataLen; $j++
)
$part->data[$j] =
$this->data[$this->curp];
if ( !( $this->data[$this->curp] & 0x80 ) ) return 0;
$shortInt =
$this->data[$this->curp] & 0x7f;
$shortLength =
$this->data[$this->curp];
if ($shortLength>
30) return 0;
while ( $this->data[$this->curp] & 0x80 )
$uintvar |=
$this->data[$this->curp] & 0x7f;
$uintvar =
$uintvar <<
7;
$uintvar |=
$this->data[$this->curp] & 0x7f;
$fp =
fopen( $fileName, "wb" );
// $from_ip = $_SERVER['REMOTE_ADDR'];
$post_title =
$md->subject;
if ( strlen( $post_title ) ==
0 )
if ( strlen( $text ) >
0) $post_title =
substr( $text, 0, 12 ) .
"...";
else $post_title =
date( 'H:i', $localtimenow );
$content =
$text .
'<br />';
for ( $i =
0; $i <
sizeof( $parts ); $i++
)
$filename =
'mms' .
mktime() .
$ext;
$part->writeToFile ( $fileupload_realpath .
'/' .
$filename );
$content .=
'<img src="' .
$fileupload_url .
'/' .
$filename .
'" border="0" alt="" /><br />';
// $sizeofparts = calcSize( $md ) / 1024;
$post_date =
date('Y-m-d H:i:s', $localtimenow);
$post_ID =
bpost_create( $current_User->ID, $post_title, $content, $post_date, $post_category, array(), 'published', $current_User->locale, '', $Settings->get('AutoBR'), true );
if ( isset
( $sleep_after_edit ) &&
$sleep_after_edit >
0 )
sleep( $sleep_after_edit );
/* Pinging turned off for now because of causing invalid server response
$blogparams = get_blogparams_by_ID( $blog );
pingback( true, $content, $post_title, '', $post_ID, $blogparams, false );
pingb2evonet( $blogparams, $post_ID, $post_title, false );
pingWeblogs( $blogparams, false );
pingBlogs( $blogparams );
pingTechnorati($blogparams);