[pLog-svn] r1990 - plugins/trunk/moblog/class/moblog

oscar at devel.plogworld.net oscar at devel.plogworld.net
Wed May 11 18:54:40 GMT 2005


Author: oscar
Date: 2005-05-11 18:54:39 +0000 (Wed, 11 May 2005)
New Revision: 1990

Modified:
   plugins/trunk/moblog/class/moblog/moblogconstants.properties.php
   plugins/trunk/moblog/class/moblog/moblogrequest.class.php
Log:
now application/smil files are ignored by default (so that we don't get annoying links to pres.smil or default.smil in our posts when the message is sent via an MMS terminal like Mark's or mine)


Modified: plugins/trunk/moblog/class/moblog/moblogconstants.properties.php
===================================================================
--- plugins/trunk/moblog/class/moblog/moblogconstants.properties.php	2005-05-11 18:48:49 UTC (rev 1989)
+++ plugins/trunk/moblog/class/moblog/moblogconstants.properties.php	2005-05-11 18:54:39 UTC (rev 1990)
@@ -1,6 +1,16 @@
 <?php
 
+    //
+    // all different modes in which images can be embedded in posts
+    //
     define( 'MOBLOG_EMBED_SMALL_PREVIEW', 1 );
     define( 'MOBLOG_EMBED_MEDIUM_PREVIEW', 2 );
     define( 'MOBLOG_EMBED_FULL_SIZE', 3 );
+    
+    //
+    // whether to ignore SMIL files attached to messages... These are usually attached
+    // by mobile phones in MMS messages, as they specify how the message should be
+    // played
+    //
+    define( 'MOBLOG_IGNORE_SMIL_ATTACHMENTS', true );
 ?>
\ No newline at end of file

Modified: plugins/trunk/moblog/class/moblog/moblogrequest.class.php
===================================================================
--- plugins/trunk/moblog/class/moblog/moblogrequest.class.php	2005-05-11 18:48:49 UTC (rev 1989)
+++ plugins/trunk/moblog/class/moblog/moblogrequest.class.php	2005-05-11 18:54:39 UTC (rev 1990)
@@ -154,41 +154,43 @@
                 }
                 else {
                     // whatever comes as a part, we will take it and treat it as if it was 
-                    // a normal resource
+                    // a normal resource as long as it's not an application/smil thingie...
                     
-                    // GalleryResources::addResource only deals with uploaded files, so we'll
-                    // have to pretend that this is one of them!
-                    $config =& Config::getConfig();
-                    $tmpFolder = $config->getValue( "temp_folder" );
-                    $tmpFolderName = $tmpFolder."/".md5(microtime());
-                    File::createDir( $tmpFolderName );
-                    MoblogLogger::log( "Creating temp folder = $tmpFolderName" );
-                    $fileName = stripslashes($part->ctype_parameters["name"]);
-		            if( $fileName == "" )
-		              $fileName = stripslashes($part->d_parameters["filename"]);
-		              
-                    $fileName = str_replace( "\"", "", $fileName );
-                    $fileName = str_replace( "'", "", $fileName );
-                    $f = new File( $tmpFolderName."/".$fileName );
-                    $f->open( "ab+" );
-                    MoblogLogger::log( "fileName = ".$tmpFolderName."/".$fileName );                    
-                    MoblogLogger::log( "Saving attachment as = ".$tmpFolderName."/".$fileName );
-                    //MoblogLogger::log( "base64 encoded data = ".$part->body );
-                    if( !$f->write( $part->body )) {
-                        MoblogLogger::log( "There was an error writing the temporary file" );
-                        die();
+                    if( strtolower($part->ctype_secondary) != 'smil' && MOBLOG_IGNORE_SMIL_ATTACHMENTS ) {
+                        // GalleryResources::addResource only deals with uploaded files, so we'll
+                        // have to pretend that this is one of them!
+                        $config =& Config::getConfig();
+                        $tmpFolder = $config->getValue( "temp_folder" );
+                        $tmpFolderName = $tmpFolder."/".md5(microtime());
+                        File::createDir( $tmpFolderName );
+                        MoblogLogger::log( "Creating temp folder = $tmpFolderName" );
+                        $fileName = stripslashes($part->ctype_parameters["name"]);
+                        if( $fileName == "" )
+                          $fileName = stripslashes($part->d_parameters["filename"]);
+                          
+                        $fileName = str_replace( "\"", "", $fileName );
+                        $fileName = str_replace( "'", "", $fileName );
+                        $f = new File( $tmpFolderName."/".$fileName );
+                        $f->open( "ab+" );
+                        MoblogLogger::log( "fileName = ".$tmpFolderName."/".$fileName );                    
+                        MoblogLogger::log( "Saving attachment as = ".$tmpFolderName."/".$fileName );
+                        //MoblogLogger::log( "base64 encoded data = ".$part->body );
+                        if( !$f->write( $part->body )) {
+                            MoblogLogger::log( "There was an error writing the temporary file" );
+                            die();
+                        }
+                        MoblogLogger::log( "File saved ok!" );
+                        MoblogLogger::log("FILENAME = $fileName");
+                        $uploadInfo = Array( "name" => $fileName,
+                                             "type" => $part->ctype_primary."/".$part->ctype_secondary,
+                                             "tmp_name" => $tmpName,
+                                             "size" => $f->getSize(),
+                                             "error" => 0 );
+                        
+                        $upload = new FileUpload( $uploadInfo );
+                        $upload->setFolder( $tmpFolderName );
+                        array_push( $this->_attachments, $upload );
                     }
-                    MoblogLogger::log( "File saved ok!" );
-                    MoblogLogger::log("FILENAME = $fileName");
-                    $uploadInfo = Array( "name" => $fileName,
-                                         "type" => $part->ctype_primary."/".$part->ctype_secondary,
-                                         "tmp_name" => $tmpName,
-                                         "size" => $f->getSize(),
-                                         "error" => 0 );
-                    
-                    $upload = new FileUpload( $uploadInfo );
-                    $upload->setFolder( $tmpFolderName );
-                    array_push( $this->_attachments, $upload );
                 }
             }
         }




More information about the pLog-svn mailing list