Changeset 46072

Show
Ignore:
Timestamp:
05/15/08 18:38:04 (2 months ago)
Author:
damianm666
Message:

--

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • wp-submission/trunk/WP_Submission.php

    r26130 r46072  
    66Author: DCoda Ltd 
    77Author URI: http://www.dcoda.co.uk 
    8 Version: 2.0.0 
     8Version: 2.1.0 
    99*/ 
    10 require_once('DCodaBase.php'); 
    11 class DCodaSubmission extends DCodaBaseV1  
    12 
     10require_once(dirname(__FILE__).'/library/classes/base.php'); 
     11class DCodaSubmission extends dc_base_2_2_0  { 
    1312      function init() 
    1413      { 
    15             $this->Name="Submission"; 
    16       } 
    17       function initDashBoard() 
    18       { 
    19             $this->AddOptionsPage('Options','Submision'); 
    20       } 
    21       function OptionsPage() 
    22       { 
    23             $content="<textarea name='".$this->inputPrefix('Option')."Keywords' style='width:100%;height:100px;'>".$this->Options['Option']['Keywords']."</textarea>"; 
    24             $desciption='Comma separated list of keywords that will cause a submission to be rejected'; 
    25             $this->OptionsPageLine('Keywords :',$content,$desciption); 
    26             $this->OptionsPageSubmit(); 
    27              
    28       } 
    29       function filter($content) 
    30       { 
    31             global $userdata; 
    32             $matches=$this->matchCommentTag('Submission',$content); 
    33             foreach($matches as $match) 
    34             { 
    35                   if(is_feed()) 
    36                   { 
    37                         $newContent="<p class = 'thanks'>Please visit the site to see the submission form</p>";                
    38                   } else { 
    39                         $formContent=array(); 
    40                         if (!isset($userdata)) { 
    41                               $formContent[] = $this->input('Your Name','name','text',array($this,'checkMandatory')); 
    42                               $formContent[] = $this->input('Your Email','email','text',array($this,'checkMandatory')); 
    43                         } else { 
    44                               $formContent[] = $this->input($userdata->display_name,'name','hidden',array($this,'checkMandatory')); 
    45                               $formContent[] = $this->input($userdata->user_email,'email','hidden',array($this,'checkMandatory'));                           
    46                         } 
    47                         $formContent[] = $this->input('Link Url','link_url','text'); 
    48                         $formContent[] = $this->input('Link Caption','link_caption','text'); 
    49                         $formContent[] = $this->input('Description','description','textarea',array($this,'checkKeywords')); 
    50                         $formContent[] = $this->captcha(); 
    51                         $formContent[] = $this->input($match['attribute']['post'],'post','hidden'); 
    52                         $form = $this->form($formContent); 
    53                         if($this->isPosted() && !$form['error']) 
    54                         { 
    55                               $content=$this->saveSubmission(); 
    56                         } else { 
    57                               $newContent=$form[code]; 
    58                               $content=str_replace($match['match'],$newContent,$content); 
    59                         } 
    60                   } 
    61                    
    62             } 
    63             return $content; 
    64       } 
    65       function saveSubmission() 
    66       { 
    67             $_POST['ID']=$this->postExists($_POST[$this->CName.'_post']); 
    68             $_POST['ID']=$_POST['ID']->ID; 
    69             $_POST['post_content']=""; 
    70             $_POST['post_title']=$_POST[$this->CName.'_post']; 
    71             $_POST['post_status'] = 'draft'; 
    72             if ($_POST['ID']) 
    73             { 
    74                   $p=get_post($_POST['ID']); 
    75                   $_POST['post_content']=$p->post_content; 
    76             }            
    77             $_POST['post_content'].="test"; 
    78             $_POST['post_content']=addslashes($_POST['post_content']); 
    79             $NewContent="<li class='submission'>\n"; 
    80             $NewContent.="<span class='url'><a href='".$_POST[$this->CName.'_link_url']."'>".$_POST[$this->CName.'_link_caption']."</a></span><br/>\n"; 
    81             $NewContent.="<span class='content'>".$_POST[$this->CName.'_description']."</span>\n"; 
    82             $NewContent.="<span class='author'> - Submitted by ".$_POST[$this->CName.'_name']."</span>\n"; 
    83             $NewContent.="</li>\n"; 
    84             $NewContent.="<!--postnote-->\n"; 
    85             $NewContent.="<div style='background-color:#FFFFCC;border:solid 1px black'>\n"; 
    86             $NewContent.="<p>Submitter Email:<a href='mailto:".$_POST[$this->CName.'_email']."'>".$_POST[$this->CName.'_name']."</a></p>\n"; 
    87             $NewContent.="<p>Submitter IP:".$_SERVER["REMOTE_ADDR"]."</p>\n"; 
    88             $NewContent.="</div>\n"; 
    89             $NewContent.="<!--/postnote-->\n"; 
    90             $NewContent.="</ul>\n"; 
    91             $NewContent=addslashes($NewContent); 
    92             $pattern='|<\s*\/?script(.*)>|Ui'; 
    93             $do=preg_match_all($pattern,$NewContent,$matches,PREG_SET_ORDER); 
    94             foreach($matches as $match) 
    95             { 
    96                   $NewContent=str_replace($match[0],"",$NewContent); 
    97             } 
    98             $pattern='|<(.*) on(.*)\s?=(.*)>|Ui'; 
    99             $do=preg_match_all($pattern,$NewContent,$matches,PREG_SET_ORDER); 
    100             foreach($matches as $match) 
    101             { 
    102                   $NewContent=str_replace("on".$match[2],"no".$match[2],$NewContent); 
    103             } 
    104             $_POST['post_content'].=$NewContent; 
    105             //$_POST['post_content']=addslashes($_POST['post_content']); 
    106             $post=wp_insert_post($_POST); 
    107             $return  = ''; 
    108             $return .= stripslashes($NewContent); 
    109             $return .="<p class = 'thanks'>Thank you for your submission.</p>"; 
    110              
    111             $email=get_option('admin_email'); 
    112             $ename=get_option('blogname'); 
    113                    
    114             $address="$ename<$email>"; 
    115  
    116             $MailMsg="The following submission has been entered to <a href='".get_permalink($postID)."'>".$_POST['post_title']."</a> by <a href='mailto:".$_POST[$this->CName.'_email']."'>".$_POST[$this->CName.'_name']."</a>"; 
    117             $MailMsg.="<ul>$NewContent</ul>"; 
    118             $MailMsg="<html><body>$MailMsg</body></html>"; 
    119             $headers = "MIME-Version: 1.0\n"; 
    120             $headers .= "From: ".$_POST[$this->CName.'_name']." <".$_POST[$this->CName.'_email'].">\n"; 
    121             $headers .= "Content-Type: text/html; charset=\"" . get_settings('blog_charset') . "\"\n"; 
    122             //mail($email,"New Submission to ".$_POST['post_title'],$MailMsg,$headers); 
    123  
    124             $MailMsg="You have made the following submission:"; 
    125             $MailMsg.="<ul>$NewContent</ul>"; 
    126             $MailMsg.="<strong>Thank you</strong>"; 
    127             $MailMsg="<html><body>$MailMsg</body></html>"; 
    128             $headers = "MIME-Version: 1.0\n"; 
    129             $headers .= "From: ".$address."\n"; 
    130             $headers .= "Content-Type: text/html; charset=\"" . get_settings('blog_charset') . "\"\n"; 
    131             //mail($_POST[$this->CName.'_email'],"Thank you for your submission",$MailMsg,$headers); 
    132  
    133              
    134             return $return; 
     14            $this->setPath(__FILE__); 
     15            $this->loadClass('submission'); 
    13516      } 
    13617} 
    137 new DCodaSubmission
     18new DCodaSubmission()
    13819 
    13920?>