[ Index ]
 

Code source de b2evolution 2.1.0-beta

Accédez au Source d'autres logiciels libres

Classes | Fonctions | Variables | Constantes | Tables

title

Body

[fermer]

/blogs/cron/ -> mms.php (source)

   1  <?php
   2  /**

   3   * MMS Server - injecting mms messages from a mobile phone into a blog

   4   *

   5   * b2evolution - {@link http://b2evolution.net/}

   6   *

   7   * This file built upon code from original Peffisaur -

   8   * Stefan Hellkvist - {@link http://hellkvist.org}

   9   *

  10   * Released under GNU GPL License - http://b2evolution.net/about/license.html

  11   *

  12   * @todo dh> Make a plugin out of it

  13   * @todo This makes no sense in /cron/! (it belongs into /htsrv!) fp> true

  14   *

  15   * @copyright (c)2004 by Hans Reinders - {@link http://hansreinders.com}

  16   *

  17   * @package htsrv

  18   *

  19   * @version $Id: mms.php,v 1.11 2007/05/28 01:33:22 fplanque Exp $

  20   */
  21  
  22  /**

  23   * Initalize:

  24   */
  25  require_once dirname(__FILE__).'/../conf/_config.php';
  26  
  27  // Dity conf switch here because this will be pluginized anyway and using the same App Settings switch as email blloggin was a problem.

  28  $mms_AutoBR = 1;
  29  
  30  
  31  if( ! isset($HTTP_RAW_POST_DATA) )
  32  {
  33          $HTTP_RAW_POST_DATA = implode("\r\n", file('php://input'));
  34  }
  35  
  36  
  37  require_once $inc_path.'_main.inc.php';
  38  
  39  param( 'login', 'string', '', true );
  40  param( 'pass', 'string', '', true );
  41  // TODO: dh> $default_category was lost somewhere.. should get handled by transforming it into a plugin.

  42  param( 'cat', 'integer', $default_category, true );
  43  
  44  if( !user_pass_ok( $login, $pass, false ) || $_SERVER['CONTENT_TYPE'] != "application/vnd.wap.mms-message" || strlen( $HTTP_RAW_POST_DATA ) == 0 ) exit;
  45  
  46  $UserCache = & get_Cache( 'UserCache' );
  47  $current_User = & $UserCache->get_by_login( $login );
  48  $post_category = $cat;
  49  $blog = get_catblog($post_category);
  50  
  51  // Check permission:

  52  $current_User->check_perm( 'blog_post!published', 'edit', true, $blog );
  53  
  54  $BlogCache = & get_Cache('BlogCache');
  55  $Blog = & $BlogCache->get_by_ID($blog);
  56  
  57  
  58  define( "BCC",             0x01 );
  59  define( "CC",             0x02 );
  60  define( "CONTENT_LOCATION",     0x03 );
  61  define( "CONTENT_TYPE",     0x04 );
  62  define( "DATE",         0x05 );
  63  define( "DELIVERY_REPORT",     0x06 );
  64  define( "DELIVERY_TIME",     0x07 );
  65  define( "EXPIRY",         0x08 );
  66  define( "FROM",         0x09 );
  67  define( "MESSAGE_CLASS",    0x0A );
  68  define( "MESSAGE_ID",         0x0B );
  69  define( "MESSAGE_TYPE",     0x0C );
  70  define( "MMS_VERSION",         0x0D );
  71  define( "MESSAGE_SIZE",     0x0E );
  72  define( "PRIORITY",         0x0F );
  73  define( "READ_REPLY",         0x10 );
  74  define( "REPORT_ALLOWED",     0x11 );
  75  define( "RESPONSE_STATUS",     0x12 );
  76  define( "RESPONSE_TEXT",     0x13 );
  77  define( "SENDER_VISIBILITY",     0x14 );
  78  define( "STATUS",         0x15 );
  79  define( "SUBJECT",         0x16 );
  80  define( "TO",             0x17 );
  81  define( "TRANSACTION_ID",     0x18 );
  82  define( "IMAGE_GIF",         0x1D );
  83  define( "IMAGE_JPEG",         0x1E );
  84  define( "IMAGE_PNG",         0x20 );
  85  define( "IMAGE_WBMP",         0x21 );
  86  define( "TEXT_PLAIN",         0x03 );
  87  define( "MULTIPART_MIXED",     0x23 );
  88  define( "MULTIPART_RELATED",      0x33 );
  89  
  90  $content_types = array( "*/*", "text/*", "text/html", "text/plain",

  91                "text/x-hdml", "text/x-ttml", "text/x-vCalendar",

  92              "text/x-vCard", "text/vnd.wap.wml",

  93              "text/vnd.wap.wmlscript", "text/vnd.wap.wta-event",

  94              "multipart/*", "multipart/mixed",

  95              "multipart/form-data", "multipart/byterantes",

  96              "multipart/alternative", "application/*",

  97              "application/java-vm",

  98              "application/x-www-form-urlencoded",

  99              "application/x-hdmlc", "application/vnd.wap.wmlc",

 100              "application/vnd.wap.wmlscriptc",

 101              "application/vnd.wap.wta-eventc",

 102              "application/vnd.wap.uaprof",

 103              "application/vnd.wap.wtls-ca-certificate",

 104              "application/vnd.wap.wtls-user-certificate",

 105              "application/x-x509-ca-cert",

 106              "application/x-x509-user-cert",

 107              "image/*", "image/gif", "image/jpeg", "image/tiff",

 108              "image/png", "image/vnd.wap.wbmp",

 109              "application/vnd.wap.multipart.*",

 110              "application/vnd.wap.multipart.mixed",

 111              "application/vnd.wap.multipart.form-data",

 112              "application/vnd.wap.multipart.byteranges",

 113              "application/vnd.wap.multipart.alternative",

 114              "application/xml", "text/xml",

 115              "application/vnd.wap.wbxml",

 116              "application/x-x968-cross-cert",

 117              "application/x-x968-ca-cert",

 118              "application/x-x968-user-cert",

 119              "text/vnd.wap.si",

 120              "application/vnd.wap.sic",

 121              "text/vnd.wap.sl",

 122              "application/vnd.wap.slc",

 123              "text/vnd.wap.co",

 124              "application/vnd.wap.coc",

 125              "application/vnd.wap.multipart.related",

 126              "application/vnd.wap.sia",

 127              "text/vnd.wap.connectivity-xml",

 128              "application/vnd.wap.connectivity-wbxml",

 129              "application/pkcs7-mime",

 130              "application/vnd.wap.hashed-certificate",

 131              "application/vnd.wap.signed-certificate",

 132              "application/vnd.wap.cert-response",

 133              "application/xhtml+xml",

 134              "application/wml+xml",

 135              "text/css",

 136              "application/vnd.wap.mms-message",

 137              "application/vnd.wap.rollover-certificate",

 138              "application/vnd.wap.locc+wbxml",

 139              "application/vnd.wap.loc+xml",

 140              "application/vnd.syncml.dm+wbxml",

 141              "application/vnd.syncml.dm+xml",

 142              "application/vnd.syncml.notification",

 143              "application/vnd.wap.xhtml+xml",

 144              "application/vnd.wv.csp.cir",

 145              "application/vnd.oma.dd+xml",

 146              "application/vnd.oma.drm.message",

 147              "application/vnd.oma.drm.content",

 148              "application/vnd.oma.drm.rights+xml",

 149              "application/vnd.oma.drm.rights+wbxml" );

 150  

 151  $typeToExtension = array( IMAGE_GIF =>        ".gif",

 152                IMAGE_JPEG =>         ".jpg",

 153                IMAGE_PNG =>          ".png",

 154                IMAGE_WBMP =>         ".wbmp",

 155                TEXT_PLAIN =>        ".txt",

 156                "application/smil" => ".smil",

 157                "audio/amr" =>       ".amr",

 158                "x-music/x-midi" =>    ".mid",

 159                "audio/midi" =>    ".mid",

 160                "audio/x-wav" =>      ".wav",

 161                "video/mpeg" =>    ".mpg",

 162                "video/avi" =>    ".avi",

 163                "video/mpeg4" =>    ".mp4",

 164                "application/zip" =>    ".zip",

 165                "text/x-imelody" =>     ".imy" );

 166  

 167  function calcSize( $md )

 168  {

 169      $size = 0;

 170      $parts = $md->parts;

 171      for ( $i = 0; $i < sizeof( $parts ); $i++ )

 172      {

 173          $p = $parts[$i];

 174          $size = $size+$p->dataLen;

 175      }

 176      return $size;

 177  }

 178  

 179  function contentTypeToString( $contentType )

 180  {

 181      global $content_types;

 182      if ( is_string( $contentType ) ) return $contentType;

 183      return $content_types[$contentType];

 184  }

 185  

 186  function extractText( $md )

 187  {

 188      $parts = $md->parts;

 189      for ( $i = 0; $i < sizeof( $parts ); $i++ )

 190      {

 191          $p=$parts[$i];

 192          if ( $p->contentType==TEXT_PLAIN )

 193          {

 194              $text = toString( $p->data );

 195              $text = textDecode( $text );

 196              $text = strip_tags( $text );

 197              return $text;

 198          }

 199      }

 200      return "";

 201  }

 202  

 203  

 204  function getExtension( $contentType )

 205  {

 206      global $typeToExtension;

 207      if ( array_key_exists( $contentType, $typeToExtension ) ) return $typeToExtension[$contentType];

 208      return ".bin";

 209  }

 210  

 211  

 212  

 213  function textDecode( $text )

 214  {

 215      if ( ord( $text{0} ) == 0xff && ord( $text{1} ) == 0xfe )

 216      {

 217          for ( $i = 2; $i < strlen( $text ); $i += 2 ) $res .= $text{$i};

 218          return $res;

 219          }

 220      return $text;

 221  }

 222  

 223  

 224  function toString( $data )

 225  {

 226      for ( $i = 0; $i < sizeof( $data ); $i++ ) $res .= chr( $data[$i] );

 227      return $res;

 228  }

 229  

 230  function writeBackSendConf( $md ) {

 231      $reply[0] = 0x8c; // X-Mms-Message-Type

 232      $reply[1] = 0x81; // = m-send-conf

 233      $reply[2] = 0x98; // X-Mms-Transaction-ID

 234      for ( $i = 3; $i < strlen( $md->transactionId )+3; $i++ ) $reply[$i] = ord( $md->transactionId{$i-3} );

 235      $reply[$i++]=0; // Terminate string

 236      $reply[$i++]=0x8D; // X-Mms-Version

 237      $reply[$i++]=0x90; // = 1.0

 238      $reply[$i++]=0x92; // X-Mms-Response-Status

 239      $reply[$i++]=128;  // = OK

 240      header("Content-Type: application/vnd.wap.mms-message");

 241      for ( $j = 0; $j < $i; $j++ ) print( chr( $reply[$j] ) );

 242  }

 243  

 244  /**

 245   * @package htsrv

 246   */
 247  class MMSDecoder {
 248      var $data;
 249      var $curp;
 250      var $messageType;
 251      var $transactionId;
 252      var $mmsVersion;
 253      var $date;
 254      var $from;
 255      var $to;
 256      var $cc;
 257      var $bcc;
 258      var $subject;
 259      var $messageClass;
 260      var $priority;
 261      var $senderVisibility;
 262      var $deliveryReport;
 263      var $readReply;
 264      var $contentType;
 265      var $bodyStartsAt;
 266      var $expiryDate;
 267      var $expiryDeltaSeconds;
 268      var $status;
 269      var $nparts;
 270      var $parts;
 271  
 272  	function isSeparator( $ch )
 273      {
 274          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;
 275      }
 276  
 277  	function MMSDecoder( $data )
 278      {
 279          $datalen = strlen( $data );
 280          for ( $i = 0; $i < $datalen; $i++ ) $this->data[$i] = ord( $data{$i} );
 281          $this->curp = 0;
 282      }
 283  
 284  	function parse()
 285      {
 286          while ( MMSDecoder::parseHeader() );
 287          $this->bodyStartsAt = $this->curp;
 288          if ( $this->contentType == MULTIPART_MIXED || $this->contentType == MULTIPART_RELATED ) MMSDecoder::parseBody();
 289      }
 290  
 291  	function parseApplicationHeader()
 292      {
 293          $res = MMSDecoder::parseToken( $token );
 294          if ($res) $res = MMSDecoder::parseTextString( $appspec );
 295          return $res;
 296      }
 297  
 298  	function parseBcc()
 299      {
 300          MMSDecoder::parseEncodedString( $this->bcc );
 301      }
 302  
 303  	function parseBody()
 304      {
 305          MMSDecoder::parseUintvar( $this->nparts );
 306          for ($i=0; $i < $this->nparts; $i++ ) MMSDecoder::parsePart($i);
 307      }
 308  
 309  	function parseCc() {
 310          MMSDecoder::parseEncodedString( $this->cc );
 311      }
 312  
 313  	function parseConstrainedEncoding( &$encoding )
 314      {
 315          $res = MMSDecoder::parseShortInteger( $encoding );
 316          if (!$res) $res = MMSDecoder::parseExtensionMedia( $encoding );
 317          return $res;
 318      }
 319  
 320  	function parseConstrainedMedia( &$contentType )
 321      {
 322          return MMSDecoder::parseConstrainedEncoding( $contentType );
 323      }
 324  
 325  	function parseContentGeneralForm( &$encoding )
 326      {
 327          $res = MMSDecoder::parseValueLength( $length );
 328          $tmp = $this->curp;
 329          if ( !$res ) return 0;
 330          $res = MMSDecoder::parseMediaType( $encoding );
 331          $this->curp = $tmp+$length;
 332          return $res;
 333      }
 334  
 335  	function parseContentType( &$contentType )
 336      {
 337          $typeFound = MMSDecoder::parseConstrainedMedia( $contentType );
 338          if ( !$typeFound )
 339          {
 340              MMSDecoder::parseContentGeneralForm( $contentType );
 341              $typeFound = 1;
 342          }
 343          return $typeFound;
 344      }
 345  
 346  	function parseDate( &$date )
 347      {
 348          MMSDecoder::parseLongInteger( $date );
 349      }
 350  
 351  	function parseDeliveryReport()
 352      {
 353          $this->deliveryReport = $this->data[$this->curp++];
 354      }
 355  
 356  	function parseDeltaSeconds( &$deltaSecs )
 357      {
 358          MMSDecoder::parseDate( $deltaSecs );
 359      }
 360  
 361  	function parseEncodedString(&$encstring)
 362      {
 363          $isencoded = MMSDecoder::parseValueLength( $length );
 364          if ( $isencoded ) $this->curp++;
 365          MMSDecoder::parseTextString( $encstring );
 366      }
 367  
 368  	function parseExpiry()
 369      {
 370          MMSDecoder::parseValueLength( $length );
 371          switch ( $this->data[$this->curp] )
 372          {
 373              case 128:
 374                  $this->curp++;
 375                  MMSDecoder::parseDate( $this->expiryDate );
 376                  break;
 377              case 129:
 378                  $this->curp++;
 379                  MMSDecoder::parseDeltaSeconds( $this->expiryDeltaSeconds );
 380                  break;
 381              default:
 382          }
 383      }
 384  
 385  	function parseExtensionMedia( &$encoding )
 386      {
 387          $ch = $this->data[$this->curp];
 388          if ( $ch<32 || $ch == 127 ) return 0;
 389          $res = MMSDecoder::parseTextString( $encoding );
 390          return $res;
 391      }
 392  
 393  	function parseFrom()
 394      {
 395          MMSDecoder::parseValueLength( $length );
 396          if ( $this->data[$this->curp] == 128 )
 397          {
 398              $this->curp++;
 399              MMSDecoder::parseEncodedString( $this->from );
 400          }
 401          else
 402          {
 403              $this->from = "Anonymous";
 404              $this->curp++;
 405          }
 406      }
 407  
 408  	function parseHeader()
 409      {
 410          $res = MMSDecoder::parseMMSHeader();
 411          if (!$res) $res = MMSDecoder::parseApplicationHeader();
 412          return $res;
 413      }
 414  
 415  	function parseInteger( &$integer )
 416      {
 417          $res = MMSDecoder::parseShortInteger( $integer );
 418          if (!$res) $res = MMSDecoder::parseLongInteger( $integer );
 419          return $res;
 420      }
 421  
 422  	function parseLongInteger( &$longInt )
 423      {
 424          if ( !MMSDecoder::parseShortLength( $length ) ) return 0;
 425          return MMSDecoder::parseMultiOctetInteger( $longInt,$length );
 426      }
 427  
 428  	function parseMediaType( &$encoding )
 429      {
 430          $res = MMSDecoder::parseWellKnownMedia( $encoding );
 431          if (!$res) $res    = MMSDecoder::parseExtensionMedia( $encoding );
 432          return $res;
 433      }
 434  
 435  	function parseMessageClass()
 436      {
 437          if ($this->data[$this->curp]<128 || $this->data[$this->curp]>131) die( "parseMessageClass not fully implemented" );
 438          $this->messageClass = $this->data[$this->curp++];
 439      }
 440  
 441  	function parseMessageType()
 442      {
 443          if (!($this->data[$this->curp] & 0x80)) return 0;
 444          $this->messageType = $this->data[$this->curp];
 445          $this->curp++;
 446          return 1;
 447      }
 448  
 449  	function parseMMSHeader()
 450      {
 451          if ( !MMSDecoder::parseShortInteger( $mmsFieldName ) ) return 0;
 452          switch ($mmsFieldName)
 453          {
 454              case BCC:
 455                  MMSDecoder::parseBcc();
 456                  break;
 457              case CC:
 458                  MMSDecoder::parseCc();
 459                  break;
 460              case CONTENT_LOCATION:
 461                  MMSDecoder::parseContentLocation();
 462                  break;
 463              case CONTENT_TYPE:
 464                  MMSDecoder::parseContentType( $this->contentType );
 465                  break;
 466              case DATE:
 467                  MMSDecoder::parseDate( $this->date );
 468                  break;
 469              case DELIVERY_REPORT:
 470                  MMSDecoder::parseDeliveryReport();
 471                  break;
 472              case DELIVERY_TIME:
 473                  MMSDecoder::parseDeliveryTime();
 474                  break;
 475              case EXPIRY:
 476                  MMSDecoder::parseExpiry();
 477                  break;
 478              case FROM:
 479                  MMSDecoder::parseFrom();
 480                  break;
 481              case MESSAGE_CLASS:
 482                  MMSDecoder::parseMessageClass();
 483                  break;
 484              case MESSAGE_ID:
 485                  MMSDecoder::parseMessageId();
 486                  break;
 487              case MESSAGE_TYPE:
 488                  MMSDecoder::parseMessageType();
 489                  break;
 490              case MMS_VERSION:
 491                  MMSDecoder::parseMmsVersion();
 492                  break;
 493              case MESSAGE_SIZE:
 494                  MMSDecoder::parseMessageSize();
 495                  break;
 496              case PRIORITY:
 497                  MMSDecoder::parsePriority();
 498                  break;
 499              case READ_REPLY:
 500                  MMSDecoder::parseReadReply();
 501                  break;
 502              case REPORT_ALLOWED:
 503                  MMSDecoder::parseReportAllowed();
 504                  break;
 505              case RESPONSE_STATUS:
 506                  MMSDecoder::parseResponseStatus();
 507                  break;
 508              case SENDER_VISIBILITY:
 509                  MMSDecoder::parseSenderVisibility();
 510                  break;
 511              case STATUS:
 512                  MMSDecoder::parseStatus();
 513                  break;
 514              case SUBJECT:
 515                  MMSDecoder::parseSubject();
 516                  break;
 517              case TO:
 518                  MMSDecoder::parseTo();
 519                  break;
 520              case TRANSACTION_ID:
 521                  MMSDecoder::parseTransactionId();
 522                  break;
 523              default:
 524                  break;
 525          }
 526          return 1;
 527      }
 528  
 529  	function parseMmsVersion()
 530      {
 531          MMSDecoder::parseShortInteger( $this->mmsVersion );
 532      }
 533  
 534  	function parseMultiOctetInteger( &$moint, $noctets )
 535      {
 536          $moint=0;
 537          for ( $i = 0; $i < $noctets; $i++ )
 538          {
 539              $moint = $moint << 8;
 540              $moint |= $this->data[$this->curp];
 541              $this->curp++;
 542          }
 543          return 1;
 544      }
 545  
 546  	function parsePart( $i )
 547      {
 548          $part = new Part;
 549          MMSDecoder::parseUintvar( $headersLen );
 550          MMSDecoder::parseUintvar( $dataLen );
 551          $part->dataLen = $dataLen;
 552          $tmp = $this->curp;
 553          MMSDecoder::parseContentType( $part->contentType );
 554          $this->curp = $tmp+$headersLen;
 555          for ( $j = 0; $j < $dataLen; $j++ )
 556          {
 557              $part->data[$j] = $this->data[$this->curp];
 558              $this->curp++;
 559          }
 560          $this->parts[$i]=$part;
 561      }
 562  
 563  	function parsePriority()
 564      {
 565          $this->priority = $this->data[$this->curp++];
 566      }
 567  
 568  	function parseReadReply()
 569      {
 570          $this->readReply = $this->data[$this->curp++];
 571      }
 572  
 573  	function parseSenderVisibility()
 574      {
 575          $this->senderVisibility = $this->data[$this->curp++];
 576      }
 577  
 578  	function parseShortInteger(&$shortInt)
 579      {
 580          if ( !( $this->data[$this->curp] & 0x80 ) ) return 0;
 581          $shortInt = $this->data[$this->curp] & 0x7f;
 582          $this->curp++;
 583          return 1;
 584      }
 585  
 586  	function parseShortLength( &$shortLength )
 587      {
 588          $shortLength = $this->data[$this->curp];
 589          if ($shortLength>30) return 0;
 590          $this->curp++;
 591          return 1;
 592      }
 593  
 594  	function parseStatus()
 595      {
 596          $this->status = $this->data[$this->curp++];
 597      }
 598  
 599  	function parseSubject()
 600      {
 601          MMSDecoder::parseEncodedString( $this->subject );
 602      }
 603  
 604  	function parseTextString( &$textString )
 605      {
 606          if ( $this->data[$this->curp] == 127 ) $this->curp++;
 607          while ( $this->data[$this->curp] )
 608          {
 609              $textString .= chr( $this->data[$this->curp] );
 610              $this->curp++;
 611          }
 612          $this->curp++;
 613          return 1;
 614      }
 615  
 616  	function parseTo() {
 617          MMSDecoder::parseEncodedString( $this->to );
 618      }
 619  
 620  	function parseToken(&$token) {
 621          if ( $this->data[$this->curp] <= 31 || MMSDecoder::isSeparator( $this->data[$this->curp] ) ) return 0;
 622          while ( $this->data[$this->curp] > 31 && !MMSDecoder::isSeparator($this->data[$this->curp] ) )
 623          {
 624              $token .= chr( $this->data[$this->curp] );
 625              $this->curp++;
 626          }
 627          return 1;
 628      }
 629  
 630  	function parseTransactionId()
 631      {
 632          MMSDecoder::parseTextString( $this->transactionId );
 633      }
 634  
 635  	function parseUintvar( &$uintvar ) {
 636          $uintvar = 0;
 637          while ( $this->data[$this->curp] & 0x80 )
 638          {
 639              $uintvar=$uintvar << 7;
 640              $uintvar |= $this->data[$this->curp] & 0x7f;
 641              $this->curp++;
 642          }
 643          $uintvar = $uintvar << 7;
 644          $uintvar |= $this->data[$this->curp] & 0x7f;
 645          $this->curp++;
 646      }
 647  
 648  	function parseValueLength( &$length ) {
 649          $lengthFound=MMSDecoder::parseShortLength( $length );
 650          if ( !$lengthFound ) {
 651              if ( $this->data[$this->curp] == 31)
 652              {
 653                  $this->curp++;
 654                  MMSDecoder::parseUintvar( $length );
 655                  return 1;
 656              }
 657          }
 658          return $lengthFound;
 659      }
 660  
 661  	function parseWellKnownMedia( &$encoding ) {
 662          return MMSDecoder::parseInteger( $encoding );
 663      }
 664  
 665  }
 666  
 667  /**

 668   * @package htsrv

 669   */
 670  class Part
 671  {
 672  
 673      var $contentType;
 674      var $dataLen;
 675      var $data;
 676  
 677  	function writeToFile( $fileName )
 678      {
 679          $fp = fopen( $fileName, "wb" );
 680          for ( $i = 0; $i < $this->dataLen; $i++ ) fwrite( $fp, chr( $this->data[$i] ), 1 );
 681          fclose($fp);
 682      }
 683  
 684  }
 685  
 686  
 687  $md = new MMSDecoder( $HTTP_RAW_POST_DATA );
 688  $md->parse();
 689  
 690  // $from_ip = $Hit->IP;

 691  // $recipient = $md->to;

 692  
 693  $post_title = $md->subject;
 694  $text = extractText( $md );
 695  
 696  if ( strlen( $post_title ) == 0 )
 697  {
 698      if ( strlen( $text ) > 0) $post_title = substr( $text, 0, 12 ) . "...";
 699      else $post_title = date( 'H:i', $localtimenow );
 700  }
 701  
 702  $parts = $md->parts;
 703  $content = $text . '<br />';
 704  
 705  for ( $i = 0; $i < sizeof( $parts ); $i++ )
 706  {
 707      $part = $parts[$i];
 708      $ext = getExtension( $part->contentType );
 709      $size = $part->dataLen;
 710      $type = contentTypeToString( $part->contentType );
 711      if ( $ext != '.smil' )
 712      {
 713          // NOTE: you may want to change/hardcode this:

 714          $fileupload_path = $Blog->get_media_dir();
 715  
 716          if( ! $fileupload_path )
 717          {
 718              debug_die('Could not get Blog media directory!');
 719          }
 720  
 721          $filename = 'mms' . mktime() . $ext;
 722          $filepath = $fileupload_path.$filename;
 723          $part->writeToFile ( $filepath );
 724  
 725          $content .= '<img src="'.$Blog->get_media_url().$filename.'"';
 726          if( $img_dimensions = getimagesize( $filepath ) )
 727          { // add 'width="xx" height="xx"'
 728              $content .= ' '.$img_dimensions[3];
 729          }
 730          $content .= ' alt="" /><br />';
 731      }
 732  }
 733  // $sizeofparts = calcSize( $md ) / 1024;

 734  
 735  $post_title = format_to_post( trim( $post_title ), 0, 0 );
 736  $content = format_to_post( trim( $content ), $mms_AutoBR, 0 );
 737  
 738  $post_date = date('Y-m-d H:i:s', $localtimenow);
 739  
 740  $edited_Item = & new Item();
 741  $post_ID = $edited_Item->insert( $current_User->ID, $post_title, $content, $post_date, $post_category, array(), 'published', $current_User->locale );
 742  
 743  writeBackSendConf( $md );
 744  
 745  // Execute or schedule notifications & pings:

 746  $edited_Item->handle_post_processing();
 747  
 748  exit;
 749  
 750  /*

 751   * $Log: mms.php,v $

 752   * Revision 1.11  2007/05/28 01:33:22  fplanque

 753   * permissions/fixes

 754   *

 755   * Revision 1.10  2007/05/21 19:40:15  blueyed

 756   * Fixed usage of $HTTP_RAW_POST_DATA global by using php://input stream, if $HTTP_RAW_POST_DATA is not set.

 757   *

 758   * Revision 1.9  2006/12/12 02:53:56  fplanque

 759   * Activated new item/comments controllers + new editing navigation

 760   * Some things are unfinished yet. Other things may need more testing.

 761   *

 762   * Revision 1.8  2006/12/07 00:55:51  fplanque

 763   * reorganized some settings

 764   *

 765   * Revision 1.7  2006/12/04 00:10:43  fplanque

 766   * doc

 767   *

 768   * Revision 1.6  2006/12/03 18:22:58  blueyed

 769   * Nuked deprecated fileupload globals

 770   *

 771   * Revision 1.5  2006/08/21 16:07:43  fplanque

 772   * refactoring

 773   *

 774   * Revision 1.4  2006/08/21 00:03:12  fplanque

 775   * obsoleted some dirty old thing

 776   *

 777   * Revision 1.3  2006/08/19 07:56:29  fplanque

 778   * Moved a lot of stuff out of the automatic instanciation in _main.inc

 779   *

 780   * Revision 1.2  2006/08/19 02:15:06  fplanque

 781   * Half kille dthe pingbacks

 782   * Still supported in DB in case someone wants to write a plugin.

 783   *

 784   * Revision 1.1  2006/02/23 21:11:45  fplanque

 785   * File reorganization to MVC (Model View Controller) architecture.

 786   * See index.hml files in folders.

 787   * (Sorry for all the remaining bugs induced by the reorg... :/)

 788   *

 789   * Revision 1.9  2005/12/01 19:25:27  blueyed

 790   * Use $Hit object for remote address

 791   *

 792   * Revision 1.8  2005/10/05 20:26:12  fplanque

 793   * cleanup

 794   *

 795   */
 796  ?>


Généré le : Thu Nov 29 23:58:50 2007 par Balluche grâce à PHPXref 0.7
  Clicky Web Analytics