[pLog-svn] r7257 - in plugins/branches/lifetype-1.2/moblog: . class/moblog class/security install

jondaley at devel.lifetype.net jondaley at devel.lifetype.net
Wed Jan 12 12:45:54 EST 2022


Author: jondaley
Date: 2022-01-12 12:45:54 -0500 (Wed, 12 Jan 2022)
New Revision: 7257

Modified:
   plugins/branches/lifetype-1.2/moblog/class/moblog/moblogrequest.class.php
   plugins/branches/lifetype-1.2/moblog/class/security/moblogbatchfilter.class.php
   plugins/branches/lifetype-1.2/moblog/install/moblog.php
   plugins/branches/lifetype-1.2/moblog/pluginmoblog.class.php
Log:
updated with some more fields that might be useful

Modified: plugins/branches/lifetype-1.2/moblog/class/moblog/moblogrequest.class.php
===================================================================
--- plugins/branches/lifetype-1.2/moblog/class/moblog/moblogrequest.class.php	2022-01-12 17:42:22 UTC (rev 7256)
+++ plugins/branches/lifetype-1.2/moblog/class/moblog/moblogrequest.class.php	2022-01-12 17:45:54 UTC (rev 7257)
@@ -19,6 +19,7 @@
         var $_globalCategory;
         var $_articleCategories;
         var $_blogId;
+        var $_date;
         var $_blogName;
         var $_attachments;
         var $_inputEncoding;
@@ -42,6 +43,7 @@
             // by a default user and blog id cannot be used as 'gateways'
             isset( $request["blogId"] ) ? $this->_blogId = $request["blogId"] : $this->_blogId = "";
             isset( $request["user"] ) ? $this->_user = $request["user"] : $this->_user = "";
+            isset( $request["date"] ) ? $this->_date = $request["date"] : $this->_date = "";
             isset( $request["password"] ) ? $this->_pass = $request["password"] : $this->_pass = "";
 
             $this->_articlecategories = "";
@@ -76,9 +78,9 @@
             $this->parseBody( $structure->body );
             $this->_inputEncoding = strtoupper( $structure->ctype_parameters['charset'] );
             
-            MoblogLogger::log( "There are ".count($structure->parts)." MIME parts available to parse" );      
+            MoblogLogger::log( "There are ". at count($structure->parts)." MIME parts available to parse" );      
             
-            if(count($structure->parts) > 0) {
+            if(@count($structure->parts) > 0) {
                 $this->parseMimeParts( $structure->parts );                        
             }
             
@@ -103,61 +105,75 @@
          */ 
         function parseBody( $body )
         {
-            $body = strip_tags($body, "<a><b><i><u><s>");
-            //$body = strtr($body,"\xE2\x80\xA9","\n\n\n");
-            $body = str_replace("\xE2\x80\xA9","\n",$body);
-            
-                // find the inline topic/title
-            if (preg_match("/^topic:(.*)/mi", $body, $title)) {
+          $body = strip_tags($body, "<a><b><i><u><s>");
+          $body = str_replace("\xE2\x80\xA9","\n",$body);
+          
+              // find the inline topic/title
+          if (preg_match("/^topic:(.*)/mi", $body, $title)) {
                 //And put the title var in the proper place
-                $this->_topic = trim($title[1]);
-            }
-                // find user
-            if (preg_match("/^user:(.*)/mi", $body, $user)) {
-                $this->_user = trim($user[1]); 
-            }       
-                // find pass or password
-            if (preg_match("/^pass(?:word)?:(.*)/mi", $body, $password)) {
-                $this->_pass = trim($password[1]);
-            }
-                // find cat, cats, category, or categories
-            if (preg_match("/^cat(?:s|egor(?:y|ies)?)?:(.*)/mi", $body, $articlecategories)) {
-	        $this->_articlecategories = explode(",", preg_replace("/^0-9,/", "", trim($articlecategories[1])));
-            }
-                // find globalcat or globalcategory
-            if (preg_match("/^globalcat(?:egory)?:(.*)/mi", $body, $globalcategory)) {
-                $this->_globalcategory = preg_replace("/^0-9/", "", trim($globalcategory[1]));
-            }
-                // find blogid
-            if (preg_match("/^blogid:(.*)/mi", $body, $blog)) {
-                $this->_blogId = trim($blog[1]); 
-            }
-                // find blog(name)
-            if (preg_match("/^blog:(.*)/mi", $body, $blogname)) {
-                $this->_blogName = trim($blogname[1]); 
-            }
+            $this->_topic = trim($title[1]);
+          }
+              // find user
+          if (preg_match("/^user:(.*)/mi", $body, $user)) {
+            $this->_user = trim($user[1]); 
+          }       
+              // find date
+          if (preg_match("/^date:(.*)/mi", $body, $date)) {
+            $this->_date = trim($date[1]); 
+          }       
+              // find pass or password
+          if (preg_match("/^pass(?:word)?:(.*)/mi", $body, $password)) {
+            $this->_pass = trim($password[1]);
+          }
+              // find cat, cats, category, or categories
+          if (preg_match("/^cat(?:s|egor(?:y|ies)?)?:(.*)/mi", $body, $articlecategories)) {
+            $this->_articlecategories = explode(",", preg_replace("/^0-9,/", "", trim($articlecategories[1])));
+          }
+              // find globalcat or globalcategory
+          if (preg_match("/^globalcat(?:egory)?:(.*)/mi", $body, $globalcategory)) {
+            $this->_globalcategory = preg_replace("/^0-9/", "", trim($globalcategory[1]));
+          }
+              // find blogid
+          if (preg_match("/^blogid:(.*)/mi", $body, $blog)) {
+            $this->_blogId = trim($blog[1]); 
+          }
+              // find blog(name)
+          if (preg_match("/^blog:(.*)/mi", $body, $blogname)) {
+            $this->_blogName = trim($blogname[1]); 
+          }
 
-                // TODO: sanitize/validate the rest of the data too
+              // TODO: sanitize/validate the rest of the data too
             
-                //We strip out all the lines we already used, and use what's left as the body
+              //We strip out all the lines we already used, and use what's left as the body
+          if(!empty($title))
             $body = str_replace($title[0], "", $body);		
+          if(!empty($user))
             $body = str_replace($user[0], "", $body);
+          if(!empty($date))
+            $body = str_replace($date[0], "", $body);
+          if(!empty($password))
             $body = str_replace($password[0], "", $body);
+          if(!empty($blog))
             $body = str_replace($blog[0], "", $body );
+          if(!empty($blogname))
             $body = str_replace($blogname[0], "", $body );            
+          if(!empty($articlecategories))
             $body = str_replace($articlecategories[0], "", $body );            
+          if(!empty($globalcategory))
             $body = str_replace($globalcategory[0], "", $body );            
             
-            // strip off a standard .sig. Properly formed .sigs start with '-- ' on a new line.
-            list($body, $sig) = explode("\n-- ", $body);
+              // strip off a standard .sig. Properly formed .sigs start with '-- ' on a new line.
+          list($body, $sig) = explode("\n-- ", $body);
             
-            foreach( $this->_moblog_filter_out as $str ) {
-                $body = str_replace( $str, '', $body );
-            }
+          foreach( $this->_moblog_filter_out as $str ) {
+            $body = str_replace( $str, '', $body );
+          }
             
-            $body = trim($body);            
-            MoblogLogger::log( "parseBody ---> body = $body" );
-            $this->_body .= $body;
+          $body = trim($body);            
+              // replace \n with <br/>\n
+          $body = preg_replace("/\n/","<br/>\n",$body);
+          MoblogLogger::log( "parseBody ---> body = $body" );
+          $this->_body .= $body;
         }
         
         /**
@@ -300,6 +316,11 @@
             return $this->_articlecategories;
         }
         
+        function getDate()
+        {
+          return $this->_date;
+        }
+        
         function getGlobalCategory()
         {
             return $this->_globalcategory;

Modified: plugins/branches/lifetype-1.2/moblog/class/security/moblogbatchfilter.class.php
===================================================================
--- plugins/branches/lifetype-1.2/moblog/class/security/moblogbatchfilter.class.php	2022-01-12 17:42:22 UTC (rev 7256)
+++ plugins/branches/lifetype-1.2/moblog/class/security/moblogbatchfilter.class.php	2022-01-12 17:45:54 UTC (rev 7257)
@@ -25,7 +25,7 @@
         function filter()
         {
             $blogInfo = $this->_pipelineRequest->getBlogInfo();
-            $config =& Config::getConfig();
+            $config = Config::getConfig();
 
             // check if this moblog batch has been enabled or disabled by siteowner
             $pseudoBatch = $config->getValue('plugin_moblog_pseudobatch');
@@ -63,7 +63,7 @@
 			$password = $config->getValue('plugin_moblog_password');
 			
 		    // pop3 connection and log-in
-		    $pop3 =& new Net_POP3();
+		    $pop3 = new Net_POP3();
 		
 			if(PEAR::isError( $ret = $pop3->connect($mailServer , $port )) ) {
                	// if there is a match, we can quit and reject this request
@@ -98,10 +98,10 @@
 			    $config->setValue( "plugin_moblog_lastupdate", time() );
                 $config->save();
                 
-                $url = &new BaseRequestGenerator();
+                $url = new BaseRequestGenerator();
 
 			    for ($cnt = 0; $cnt < count($messages); $cnt++) {
-					$req = &new HTTP_Request($url->getBaseUrl(false)."/moblog.php");
+					$req = new HTTP_Request($url->getBaseUrl(false)."/moblog.php");
 					$req->setMethod(HTTP_REQUEST_METHOD_POST);
 					$req->addPostData('message', $messages[$cnt]);
 					$req->sendRequest();

Modified: plugins/branches/lifetype-1.2/moblog/install/moblog.php
===================================================================
--- plugins/branches/lifetype-1.2/moblog/install/moblog.php	2022-01-12 17:42:22 UTC (rev 7256)
+++ plugins/branches/lifetype-1.2/moblog/install/moblog.php	2022-01-12 17:45:54 UTC (rev 7257)
@@ -71,6 +71,7 @@
 MoblogLogger::log( "user = '".$request->getUser()."'");
     // uncomment the following if you want to see passwords... :)
     //MoblogLogger::log( "pass = '".$request->getPassword()."'");
+MoblogLogger::log( "date = ".$request->getDate());
 MoblogLogger::log( "blog id = ".$request->getBlogId());
 MoblogLogger::log( "blog name = ".$request->getBlogName());
 MoblogLogger::log( "topic = ".$request->getTopic());
@@ -285,7 +286,8 @@
                         POST_STATUS_PUBLISHED,
                         0
                         );
-$article->setDateObject( new Timestamp());
+$article->setDateObject(new Timestamp(Timestamp::parseDate($request->getDate())));
+
     // enable or disable comments by default depending on the current config
 $commentsEnabled = $blogSettings->getValue( "comments_enabled" );
 $article->setCommentsEnabled( $commentsEnabled );

Modified: plugins/branches/lifetype-1.2/moblog/pluginmoblog.class.php
===================================================================
--- plugins/branches/lifetype-1.2/moblog/pluginmoblog.class.php	2022-01-12 17:42:22 UTC (rev 7256)
+++ plugins/branches/lifetype-1.2/moblog/pluginmoblog.class.php	2022-01-12 17:45:54 UTC (rev 7257)
@@ -14,7 +14,7 @@
             $this->id = "moblog";
             $this->author = "The Lifetype Project";
             $this->locales = Array();
-			$this->version = "20111027";
+			$this->version = "20200604";
             $this->desc = "
 Send a message with the following format ('start' and 'end' messages not included!):<br/>
 <br/>
@@ -21,12 +21,17 @@
 --- start of moblog message format ---<br/>
 USER: your-lifetype-username<br/>
 PASS: your-lifetype-password<br/>
-BLOG: your-lifetype-blog-name or BLOGID: id-of-your-blog<br/>
+DATE: English parseable date format (for backdating or postdating posts)<br/>
+CATEGORY: comma separated list of categories<br/>
+GLOBALCATEGORY: global article category<br/>
+BLOG: your-lifetype-blog-name <b>or</b> BLOGID: id-of-your-blog<br/>
 TOPIC: your-subject (optional)<br/>
 --- end of moblog message format ---<br/>
 <br/>
 The subject of the mail will be used as the subject for the article as long as there is no TOPIC set.<br/>
-The message must be sent as plain text, and it can include as many attachment as needed.";
+The message must be sent as plain text, and it can include as many attachment as needed.<br/>
+Allowed HTML tags: <i>,<b>,<a>,<u>,<s><br/>
+Carriage returns will be converted to <br/> tags.";
 
             $this->init();
         }



More information about the pLog-svn mailing list