phpBMS

Changeset 730 for trunk/phpbms/modules

Show
Ignore:
Timestamp:
01/07/10 18:13:51 (2 years ago)
Author:
brieb
Message:
  • more sucrity tightening with roles.
Location:
trunk/phpbms/modules/mailchimp
Files:
7 modified

Legend:

Unmodified
Added
Removed
  • trunk/phpbms/modules/mailchimp/adminsettings.php

    r686 r730  
    11<?php 
     2/* 
     3 $Rev: 267 $ | $LastChangedBy: brieb $ 
     4 $LastChangedDate: 2007-08-14 13:08:27 -0600 (Tue, 14 Aug 2007) $ 
     5 +-------------------------------------------------------------------------+ 
     6 | Copyright (c) 2004 - 2010, Kreotek LLC                                  | 
     7 | All rights reserved.                                                    | 
     8 +-------------------------------------------------------------------------+ 
     9 |                                                                         | 
     10 | Redistribution and use in source and binary forms, with or without      | 
     11 | modification, are permitted provided that the following conditions are  | 
     12 | met:                                                                    | 
     13 |                                                                         | 
     14 | - Redistributions of source code must retain the above copyright        | 
     15 |   notice, this list of conditions and the following disclaimer.         | 
     16 |                                                                         | 
     17 | - Redistributions in binary form must reproduce the above copyright     | 
     18 |   notice, this list of conditions and the following disclaimer in the   | 
     19 |   documentation and/or other materials provided with the distribution.  | 
     20 |                                                                         | 
     21 | - Neither the name of Kreotek LLC nor the names of its contributore may | 
     22 |   be used to endorse or promote products derived from this software     | 
     23 |   without specific prior written permission.                            | 
     24 |                                                                         | 
     25 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS     | 
     26 | "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT       | 
     27 | LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A | 
     28 | PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT      | 
     29 | OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,   | 
     30 | SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT        | 
     31 | LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,   | 
     32 | DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY   | 
     33 | THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT     | 
     34 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE   | 
     35 | OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.    | 
     36 |                                                                         | 
     37 +-------------------------------------------------------------------------+ 
     38*/ 
    239class mailchimpUpdate{ 
    340 
    441    function updateSettings($variables){ 
    5                  
     42 
    643                if(!isset($variables["mailchimp_secure"])) 
    744                        $variables["mailchimp_secure"] = 0; 
    8          
     45 
    946                /** 
    1047                  *   Check for a valid api key. 
     
    1249                if($variables["apikey_changed"] == "1" && $variables["mailchimp_apikey"] != ""){ 
    1350            include_once("include/MCAPI.class.php"); 
    14              
     51 
    1552            $api = new MCAPI($variables["mailchimp_apikey"]); 
    1653            $api->ping(); 
     
    2057                                return $variables; 
    2158            }//end if 
    22              
     59 
    2360        }//end if 
    24                  
    25                  
     61 
     62 
    2663                /** 
    27                   *  Check for valid list id  
     64                  *  Check for valid list id 
    2865                  */ 
    2966                if($variables["apilist_changed"] == "1" && $variables["mailchimp_list_id"] != ""){ 
    3067                        include_once("include/MCAPI.class.php"); 
    31                          
     68 
    3269                        /** 
    3370                          *  Check to see if api is already defined (from a possible api key check) 
     
    4380                                }//end if 
    4481                        }//end if 
    45                          
     82 
    4683                        /** 
    4784                          *   Look up the lists 
     
    5390                                return $variables; 
    5491                        }else{ 
    55                                  
     92 
    5693                                /** 
    57                                   *  Check to see if list id is valid  
     94                                  *  Check to see if list id is valid 
    5895                                  */ 
    5996                                $validId = false; 
     
    63100                                                break; 
    64101                                        }//endif 
    65                                  
     102 
    66103                                if(!$validId){ 
    67104                                        unset($variables["mailchimp_list_id"]); 
     
    69106                                        return $variables; 
    70107                                }else{ 
    71                                          
    72                                         /** 
    73                                           *  Check to see if the list has a uuid.  
     108 
     109                                        /** 
     110                                          *  Check to see if the list has a uuid. 
    74111                                          */ 
    75112                                        $hasUuid = false; 
     
    82119                                                return $variables; 
    83120                                        }//end if 
    84                                                  
     121 
    85122                                        $req = array(); 
    86123                                        foreach($mergeVars as $mergeVar){ 
    87                                                  
     124 
    88125                                                switch($mergeVar["tag"]){ 
    89                                                          
     126 
    90127                                                        case "UUID": 
    91128                                                                $hasUuid = true; 
    92129                                                                break; 
    93                                                          
     130 
    94131                                                        case "COMPANY": 
    95132                                                                $hasCompany = true; 
    96133                                                                break; 
    97                                                          
     134 
    98135                                                        case "TYPE": 
    99136                                                                $hasType = true; 
    100137                                                                break; 
    101                                                          
     138 
    102139                                                }//end switch 
    103                                                  
     140 
    104141                                        }//end foreach 
    105                                          
    106                                         /** 
    107                                           *  If it doesn't have a uuid field, create it.  
     142 
     143                                        /** 
     144                                          *  If it doesn't have a uuid field, create it. 
    108145                                          */ 
    109146                                        if(!$hasUuid){ 
     
    119156                                                        return $variables; 
    120157                                                }//end if 
    121                                                  
    122                                         }//end if 
    123                                          
    124                                         /** 
    125                                           *  If it doesn't have a company field, create it.  
     158 
     159                                        }//end if 
     160 
     161                                        /** 
     162                                          *  If it doesn't have a company field, create it. 
    126163                                          */ 
    127164                                        if(!$hasCompany){ 
     
    137174                                                        return $variables; 
    138175                                                }//end if 
    139                                                  
    140                                         }//end if 
    141                                          
    142                                         /** 
    143                                           *  If it doesn't have a type field, create it.  
     176 
     177                                        }//end if 
     178 
     179                                        /** 
     180                                          *  If it doesn't have a type field, create it. 
    144181                                          */ 
    145182                                        if(!$hasType){ 
     
    155192                                                        return $variables; 
    156193                                                }//end if 
    157                                                  
    158                                         }//end if 
    159                                          
    160                                          
    161                                         /** 
    162                                           *  If the date list id has changed, the last sync date must be reset:  
     194 
     195                                        }//end if 
     196 
     197 
     198                                        /** 
     199                                          *  If the date list id has changed, the last sync date must be reset: 
    163200                                          */ 
    164201                                        $variables["mailchimp_last_sync_date"] = ""; 
    165                                          
     202 
    166203                                }//end if 
    167                                  
     204 
    168205                        }//end if 
    169                          
     206 
    170207                }//end if 
    171          
     208 
    172209        return $variables; 
    173          
     210 
    174211    }//end function 
    175      
    176      
     212 
     213 
    177214}//end class 
    178215 
     
    186223                        $theinput = new inputField("mailchimp_apikey",$therecord["mailchimp_apikey"],"mailchimp apikey", false, NULL, 48); 
    187224                        $fields[] = $theinput; 
    188                          
     225 
    189226                        $theinput = new inputCheckbox("mailchimp_secure", $therecord["mailchimp_secure"], "use ssl connection"); 
    190227                        $fields[] = $theinput; 
    191                          
     228 
    192229                        $theinput = new inputField("mailchimp_list_id", $therecord["mailchimp_list_id"], "list id"); 
    193230                        $fields[] = $theinput; 
    194                          
     231 
    195232                        $theinput = new inputField("mailchimp_last_sync_date", $therecord["mailchimp_last_sync_date"], "last sync date"); 
    196233                        $theinput->setAttribute("class", "uneditable"); 
     
    207244        <legend>Main</legend> 
    208245 
    209          
     246 
    210247        <input type="hidden" id="apikey_changed" name="apikey_changed" value="0" /> 
    211          
     248 
    212249        <p> 
    213250                <span class="notes"> 
     
    216253                </span> 
    217254        </p> 
    218          
     255 
    219256    <p> 
    220257                <?php echo $theform->showField("mailchimp_apikey");?> 
  • trunk/phpbms/modules/mailchimp/include/list_sync.php

    r684 r730  
    11<?php 
     2/* 
     3 $Rev: 267 $ | $LastChangedBy: brieb $ 
     4 $LastChangedDate: 2007-08-14 13:08:27 -0600 (Tue, 14 Aug 2007) $ 
     5 +-------------------------------------------------------------------------+ 
     6 | Copyright (c) 2004 - 2010, Kreotek LLC                                  | 
     7 | All rights reserved.                                                    | 
     8 +-------------------------------------------------------------------------+ 
     9 |                                                                         | 
     10 | Redistribution and use in source and binary forms, with or without      | 
     11 | modification, are permitted provided that the following conditions are  | 
     12 | met:                                                                    | 
     13 |                                                                         | 
     14 | - Redistributions of source code must retain the above copyright        | 
     15 |   notice, this list of conditions and the following disclaimer.         | 
     16 |                                                                         | 
     17 | - Redistributions in binary form must reproduce the above copyright     | 
     18 |   notice, this list of conditions and the following disclaimer in the   | 
     19 |   documentation and/or other materials provided with the distribution.  | 
     20 |                                                                         | 
     21 | - Neither the name of Kreotek LLC nor the names of its contributore may | 
     22 |   be used to endorse or promote products derived from this software     | 
     23 |   without specific prior written permission.                            | 
     24 |                                                                         | 
     25 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS     | 
     26 | "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT       | 
     27 | LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A | 
     28 | PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT      | 
     29 | OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,   | 
     30 | SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT        | 
     31 | LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,   | 
     32 | DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY   | 
     33 | THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT     | 
     34 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE   | 
     35 | OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.    | 
     36 |                                                                         | 
     37 +-------------------------------------------------------------------------+ 
     38*/ 
    239class listSync{ 
    3      
     40 
    441    /** 
    542      *  $lastSyncDate 
     
    1855      */ 
    1956    var $listId; 
    20      
     57 
    2158    /** 
    2259      *  $api 
     
    4178      */ 
    4279    var $stopScript = false; 
    43      
    44      
     80 
     81 
    4582    /** 
    4683      *  function listSync 
     
    5491      *  @param bool $secure Whether to send info over ssl 
    5592      */ 
    56      
     93 
    5794    function listSync($db, $apiKey, $listId, $lastSyncDate = NULL, $batchlimit = NULL, $secure = false){ 
    58          
     95 
    5996        $this->db = $db; 
    6097        $this->listId = $listId; 
    61          
     98 
    6299        /** 
    63100          *   Check for a valid datetime format? 
     
    65102        if($lastSyncDate) 
    66103            $this->lastSyncDate = $lastSyncDate; 
    67              
     104 
    68105        if((int)$batchlimit > 0) 
    69106           $this->batchlimit = (int)$batchlimit; 
    70          
     107 
    71108        $this->api = new MCAPI($apiKey, NULL, $secure); 
    72109        $this->api->ping(); 
     
    75112            return false; 
    76113        }//end if 
    77          
     114 
    78115        /** 
    79116          *   check to see if there is a uuid field 
     
    85122            return false; 
    86123        }//end if 
    87              
     124 
    88125        foreach($mergeVars as $mergeVar){ 
    89              
     126 
    90127            if($mergeVar["tag"] == "UUID"){ 
    91128                $hasUuid = true; 
    92129                break; 
    93130            }//end if 
    94              
     131 
    95132        }//end foreach 
    96          
     133 
    97134        if(!$hasUuid){ 
    98135            $this->_addError("The list does not have a merge variable with tag of 'UUID'.", NULL, true); 
    99136            return false; 
    100137        } 
    101          
     138 
    102139    }//end function 
    103      
     140 
    104141    /** 
    105142      *   function _addError 
    106143      * 
    107144      *   Add an error to the class' error array. 
    108       *    
     145      * 
    109146      *   @param string $message Text of error message 
    110147      *   @param int $errorCode Error number 
     
    112149      *   function needs to be stopped. 
    113150      */ 
    114      
     151 
    115152    function _addError($message, $errorCode = NULL, $fatal = false){ 
    116          
     153 
    117154        $tempArray["message"] = $message; 
    118155        $tempArray["code"] = $errorCode; 
    119          
     156 
    120157        if($fatal){ 
    121158            $this->stopScript = true; 
     
    124161            $tempArray["errorType"] = "warning"; 
    125162        }//end if 
    126          
     163 
    127164        $this->errors[] = $tempArray; 
    128          
     165 
    129166    }//end function 
    130      
    131      
     167 
     168 
    132169    /** 
    133170      *   function _reportResult 
     
    140177      *   code pairs. 
    141178      */ 
    142      
     179 
    143180    function _reportResult(){ 
    144          
     181 
    145182        $return = array(); 
    146          
     183 
    147184        if(count($this->errors)){ 
    148              
     185 
    149186            if($this->stopScript) 
    150187                $return["type"] = "error"; 
    151188            else 
    152189                $return["type"] = "warning"; 
    153              
     190 
    154191            $return["details"] = $this->errors; 
    155              
     192 
    156193        }else{ 
    157              
     194 
    158195            $return["type"] = "success"; 
    159196            $return["details"] = array(); 
    160              
    161         }//end if 
    162              
     197 
     198        }//end if 
     199 
    163200        return $return; 
    164          
     201 
    165202    }//end foreach 
    166      
    167      
     203 
     204 
    168205    /** 
    169206      *  function pullChanges 
     
    173210      *  address. 
    174211      */ 
    175      
     212 
    176213    function pullChanges(){ 
    177          
    178         /** 
    179           *  pull all the unsubscribed  
     214 
     215        /** 
     216          *  pull all the unsubscribed 
    180217          */ 
    181218        $unsubscribed = array(); 
    182219        $start = 0; 
    183220        do{ 
    184              
     221 
    185222            $members = $this->api->listMembers($this->listId, 'unsubscribed', $this->lastSyncDate, $start, $this->batchLimit); 
    186223            if($this->api->errorCode){ 
     
    188225                return false; 
    189226            }//end if 
    190              
     227 
    191228            foreach($members as $member){ 
    192                  
     229 
    193230                $info = $this->api->listMemberInfo($this->listId, $member["email"]); 
    194231                if($this->api->errorCode){ 
     
    196233                    return false; 
    197234                }//end if 
    198                      
     235 
    199236                $unsubscribed[] = $info["merges"]["UUID"]; 
    200                  
     237 
    201238            }//end foreach 
    202              
     239 
    203240            $start++; 
    204241        }while(count($members) == $this->batchLimit); 
    205          
    206         /** 
    207           *  pull all the cleaned  
     242 
     243        /** 
     244          *  pull all the cleaned 
    208245          */ 
    209246        $start = 0; 
    210247        do{ 
    211              
     248 
    212249            $members = $this->api->listMembers($this->listId, 'cleaned', $this->lastSyncDate, $start, $this->batchLimit); 
    213250            if($this->api->errorCode){ 
     
    215252                return false; 
    216253            }//end ifd 
    217              
     254 
    218255            foreach($members as $member){ 
    219                  
     256 
    220257                $info = $this->api->listMemberInfo($this->listId, $member["email"]); 
    221258                if($this->api->errorCode){ 
     
    224261                }//end if 
    225262                $unsubscribed[] = $info["merges"]["UUID"]; 
    226                  
     263 
    227264            }//end foreach 
    228              
     265 
    229266            $start++; 
    230267        }while(count($members) == $this->batchLimit); 
    231          
    232          
     268 
     269 
    233270        /** 
    234271          *  If there are records to unsubscribe, set their `canemail` to '0' 
    235272          */ 
    236273        if(count($unsubscribed)){ 
    237              
     274 
    238275            /** 
    239               *  construct the in statement  
     276              *  construct the in statement 
    240277              */ 
    241278            $inValues = ""; 
    242279            foreach($unsubscribed as $uuid) 
    243280                $inValues .= ",'".$uuid."'"; 
    244                  
     281 
    245282            $inValues = substr($inValues, 1); 
    246              
     283 
    247284            /** 
    248285              *  set the cleaned/unsubscribed to canemail = 0 
     
    256293                    `uuid` IN (".$inValues.") 
    257294            "; 
    258              
     295 
    259296            $queryresult = $this->db->query($querystatement); 
    260              
    261         }//end if 
    262          
     297 
     298        }//end if 
     299 
    263300    }//end function 
    264      
     301 
    265302    /** 
    266303      *   function unsubscribeInvalid 
    267       *    
     304      * 
    268305      *   Unsubscribe the emails that are related to 
    269306      *   client records those that don't have an email (or don't exist), 
    270307      *   or that can't be emailed anymore. 
    271308      */ 
    272      
     309 
    273310    function unsubscribeInvalid(){ 
    274          
     311 
    275312        /** 
    276313          *   Get rid of the temorary table. 
     
    281318        "; 
    282319        $this->db->query($dropTableStatement); 
    283          
    284         /** 
    285           *  Create a temporary table  
     320 
     321        /** 
     322          *  Create a temporary table 
    286323          */ 
    287324        $createTableStatement = " 
     
    291328                `email` varchar(128) default NULL 
    292329            ) ENGINE=INNODB"; 
    293          
     330 
    294331        $this->db->query($createTableStatement); 
    295          
    296         /** 
    297           *  pull all the subscribed  
     332 
     333        /** 
     334          *  pull all the subscribed 
    298335          */ 
    299336        $start = 0; 
    300         do{     
     337        do{ 
    301338            $valuesClause = ""; 
    302                          
     339 
    303340            $members = $this->api->listMembers($this->listId, 'subscribed', NULL, $start, $this->batchLimit); 
    304341 
     
    307344                return false; 
    308345            }//end if 
    309              
     346 
    310347            foreach($members as $member) 
    311348                $valuesClause .= ",('".$member["email"]."')"; 
    312              
     349 
    313350            $valuesClause = substr($valuesClause, 1); 
    314              
    315              
     351 
     352 
    316353            /** 
    317               *  Put the subscribed into a temporary table  
     354              *  Put the subscribed into a temporary table 
    318355              */ 
    319356            if($valuesClause){ 
     
    324361                        VALUES 
    325362                    ".$valuesClause; 
    326                  
     363 
    327364                $this->db->query($insertStatement); 
    328365            }//end if 
    329              
     366 
    330367            $start++; 
    331368        }while(count($members) == $this->batchLimit); 
    332369 
    333          
     370 
    334371        /** 
    335372          *  Get all the emails of client records that are subscribed 
     
    346383                `clients`.`email` IS NULL 
    347384        "; 
    348          
     385 
    349386        $selectresult = $this->db->query($selectStatement); 
    350          
     387 
    351388        /** 
    352389          *   Unsubscribe them from the mailchimp list 
     
    355392        while($therecord = $this->db->fetchArray($selectresult)) 
    356393            $unsubscribeList[] = $therecord["email"]; 
    357          
    358         /** 
    359           *  If there are records to unsubscribe (deleted), do so.  
     394 
     395        /** 
     396          *  If there are records to unsubscribe (deleted), do so. 
    360397          */ 
    361398        if(count($unsubscribeList)){ 
    362              
     399 
    363400            $return = $this->api->listBatchUnsubscribe($this->listId, $unsubscribeList, true, false); 
    364401            if ($this->api->errorCode){ 
     
    368405                foreach($return['errors'] as $val) 
    369406                    $this->_addError("Unsubscribing email ".$val["email"]." failed: ".$val["message"], $val["code"]); 
    370                      
    371         }//end if 
    372              
     407 
     408        }//end if 
     409 
    373410        /** 
    374411          *   Get rid of the temorary table. 
     
    379416        "; 
    380417        $this->db->query($dropTableStatement); 
    381          
     418 
    382419    }//end function 
    383      
    384      
     420 
     421 
    385422    /** 
    386423      *  function pushChanges 
     
    390427      */ 
    391428    function pushChanges(){ 
    392          
     429 
    393430        /** 
    394431          *   Get the changed records / fields 
     
    411448                `canemail` != '0' 
    412449        "; 
    413          
     450 
    414451        /** 
    415452          *  If there is a last sync *date*, limit the records by their modified 
     
    418455        if($this->lastSyncDate) 
    419456            $querystatement .= " AND `modifieddate` > '".$this->lastSyncDate."'"; 
    420              
    421          
     457 
     458 
    422459        $queryresult = $this->db->query($querystatement); 
    423          
     460 
    424461        /** 
    425462          *   Format the variables to be interpreted by Mailchimp. 
     
    427464        $batchVars = array(); 
    428465        while($therecord = $this->db->fetchArray($queryresult)){ 
    429              
     466 
    430467            $tempArray["EMAIL"] = $therecord["email"]; 
    431468            $tempArray["FNAME"] = $therecord["firstname"]; 
     
    434471            $tempArray["TYPE"] = $therecord["type"]; 
    435472            $tempArray["UUID"] = $therecord["uuid"]; 
    436              
     473 
    437474            $batchVars[] = $tempArray; 
    438475        }//end while 
    439          
    440         /** 
    441           *  Update / Insert the changes  
     476 
     477        /** 
     478          *  Update / Insert the changes 
    442479          */ 
    443480        if(count($batchVars)){ 
    444              
     481 
    445482            $return = $this->api->listBatchSubscribe($this->listId, $batchVars, false, true); 
    446483            if($this->api->errorCode){ 
     
    448485                return false; 
    449486            }else{ 
    450                  
     487 
    451488                $instatement = ""; 
    452                  
     489 
    453490                foreach($return['errors'] as $val){ 
    454                      
     491 
    455492                    $this->_addError("Subscribing or updating uuid '".$val["row"]["UUID"]."' failed: ".$val["message"], $val["code"]); 
    456                      
     493 
    457494                    $memberInfo = $this->api->listMemberInfo($this->listId, $val["row"]["EMAIL"]); 
    458                      
     495 
    459496                    if($memberInfo["status"] != "subcribed") 
    460497                        $instatement .= ", '".$val["row"]["UUID"]."'"; 
    461                      
     498 
    462499                }//end foreach 
    463                  
     500 
    464501                if($instatement){ 
    465                      
     502 
    466503                    $instatement = substr($instatement, 2); 
    467504                    $instatement = "(".$instatement.")"; 
    468                      
     505 
    469506                    $updatestatement = " 
    470507                        UPDATE 
     
    475512                        WHERE 
    476513                            `uuid` IN ".$instatement; 
    477                      
     514 
    478515                    $this->db->query($updatestatement); 
    479                      
     516 
    480517                }//end if 
    481                  
     518 
    482519            }//end if 
    483                      
    484         }//end if 
    485          
     520 
     521        }//end if 
     522 
    486523    }//end function 
    487      
    488      
     524 
     525 
    489526    /* 
    490527     * function resetSyncDate 
     
    492529     * Set the last sync date in the settings table to be NOW() 
    493530     */ 
    494      
     531 
    495532    function resetSyncDate() { 
    496          
     533 
    497534        $querystatement = " 
    498535            UPDATE 
     
    503540                `name` = 'mailchimp_last_sync_date' 
    504541        "; 
    505          
     542 
    506543        $queryresult = $this->db->query($querystatement); 
    507          
     544 
    508545    }//end if 
    509      
    510      
     546 
     547 
    511548    /** 
    512549      *  function process 
    513       *   
     550      * 
    514551      *  Perform the list sync 
    515552      */ 
    516553    function process(){ 
    517          
     554 
    518555        if(!$this->stopScript) 
    519556            $this->pullChanges(); 
     
    524561        if(!$this->stopScript) 
    525562            $this->resetSyncDate(); 
    526          
     563 
    527564        return $this->_reportResult(); 
    528          
     565 
    529566    }//end function 
    530      
     567 
    531568}//end class 
    532569?> 
  • trunk/phpbms/modules/mailchimp/install/tableoptions.sql

    r682 r730  
    1 INSERT INTO `tableoptions` (`tabledefid`, `name`, `option`, `needselect`, `othercommand`, `roleid`, `displayorder`) VALUES ('tbld:6d290174-8b73-e199-fe6c-bcf3d4b61083', 'massEmail', 'sync to MailChimp', '0', '1', '', '100'); 
     1INSERT INTO `tableoptions` (`tabledefid`, `name`, `option`, `needselect`, `othercommand`, `roleid`, `displayorder`) VALUES ('tbld:6d290174-8b73-e199-fe6c-bcf3d4b61083', 'massEmail', 'sync to MailChimp', '0', '1', 'Admin', '100'); 
  • trunk/phpbms/modules/mailchimp/manual_list_sync.php

    r717 r730  
    11<?php 
     2/* 
     3 $Rev: 267 $ | $LastChangedBy: brieb $ 
     4 $LastChangedDate: 2007-08-14 13:08:27 -0600 (Tue, 14 Aug 2007) $ 
     5 +-------------------------------------------------------------------------+ 
     6 | Copyright (c) 2004 - 2010, Kreotek LLC                                  | 
     7 | All rights reserved.                                                    | 
     8 +-------------------------------------------------------------------------+ 
     9 |                                                                         | 
     10 | Redistribution and use in source and binary forms, with or without      | 
     11 | modification, are permitted provided that the following conditions are  | 
     12 | met:                                                                    | 
     13 |                                                                         | 
     14 | - Redistributions of source code must retain the above copyright        | 
     15 |   notice, this list of conditions and the following disclaimer.         | 
     16 |                                                                         | 
     17 | - Redistributions in binary form must reproduce the above copyright     | 
     18 |   notice, this list of conditions and the following disclaimer in the   | 
     19 |   documentation and/or other materials provided with the distribution.  | 
     20 |                                                                         | 
     21 | - Neither the name of Kreotek LLC nor the names of its contributore may | 
     22 |   be used to endorse or promote products derived from this software     | 
     23 |   without specific prior written permission.                            | 
     24 |                                                                         | 
     25 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS     | 
     26 | "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT       | 
     27 | LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A | 
     28 | PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT      | 
     29 | OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,   | 
     30 | SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT        | 
     31 | LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,   | 
     32 | DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY   | 
     33 | THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT     | 
     34 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE   | 
     35 | OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.    | 
     36 |                                                                         | 
     37 +-------------------------------------------------------------------------+ 
     38*/ 
    239require_once("../../include/session.php"); 
     40 
     41$querystatement = " 
     42    SELECT 
     43        roleid 
     44    FROM 
     45        tableoptions 
     46    WHERE 
     47        name= 'massemail' 
     48        AND tabledefid = 'tbld:6d290174-8b73-e199-fe6c-bcf3d4b61083' 
     49        "; 
     50 
     51$queryresult = $this->db->query($querystatement); 
     52 
     53$therecord = $this->db->fetchArray($queryresult); 
     54 
     55if(!hasRights($therecord["roleid"])) 
     56    goURL(APP_PATH."noaccess.php"); 
    357 
    458$pageTitle = "MailChimp List Sync"; 
  • trunk/phpbms/modules/mailchimp/manual_list_sync_ajax.php

    r686 r730  
    11<?php 
    2 require("../../include/session.php"); 
    3 include("include/MCAPI.class.php");//for MCAPI CLASS (listSync class uses it) 
    4 include("include/list_sync.php");//for listSync class 
     2/* 
     3 $Rev: 267 $ | $LastChangedBy: brieb $ 
     4 $LastChangedDate: 2007-08-14 13:08:27 -0600 (Tue, 14 Aug 2007) $ 
     5 +-------------------------------------------------------------------------+ 
     6 | Copyright (c) 2004 - 2010, Kreotek LLC                                  | 
     7 | All rights reserved.                                                    | 
     8 +-------------------------------------------------------------------------+ 
     9 |                                                                         | 
     10 | Redistribution and use in source and binary forms, with or without      | 
     11 | modification, are permitted provided that the following conditions are  | 
     12 | met:                                                                    | 
     13 |                                                                         | 
     14 | - Redistributions of source code must retain the above copyright        | 
     15 |   notice, this list of conditions and the following disclaimer.         | 
     16 |                                                                         | 
     17 | - Redistributions in binary form must reproduce the above copyright     | 
     18 |   notice, this list of conditions and the following disclaimer in the   | 
     19 |   documentation and/or other materials provided with the distribution.  | 
     20 |                                                                         | 
     21 | - Neither the name of Kreotek LLC nor the names of its contributore may | 
     22 |   be used to endorse or promote products derived from this software     | 
     23 |   without specific prior written permission.                            | 
     24 |                                                                         | 
     25 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS     | 
     26 | "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT       | 
     27 | LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A | 
     28 | PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT      | 
     29 | OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,   | 
     30 | SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT        | 
     31 | LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,   | 
     32 | DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY   | 
     33 | THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT     | 
     34 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE   | 
     35 | OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.    | 
     36 |                                                                         | 
     37 +-------------------------------------------------------------------------+ 
     38*/ 
     39 
     40class manualSync{ 
     41 
     42    var $db; 
     43 
     44    function manualSync($db){ 
     45 
     46        $this->db = $db; 
     47        $this->db->errorFormat = "json"; 
     48 
     49    }//end function init 
    550 
    651 
    7 $listSync = new listSync( 
    8                          $db, 
    9                          MAILCHIMP_APIKEY, 
    10                          MAILCHIMP_LIST_ID, 
    11                          MAILCHIMP_LAST_SYNC_DATE, 
    12                          NULL, 
    13                          MAILCHIMP_SECURE 
    14                          ); 
     52    function checkSecurity(){ 
    1553 
    16 $response = $listSync->process(); 
     54        $querystatement = " 
     55            SELECT 
     56                roleid 
     57            FROM 
     58                tableoptions 
     59            WHERE 
     60                name= 'massemail' 
     61                AND tabledefid = 'tbld:6d290174-8b73-e199-fe6c-bcf3d4b61083' 
     62                "; 
    1763 
    18 if(!isset($response["type"])){ 
    19     $response = array(); 
    20     $response["type"] = "error"; 
    21     $response["details"] = array("message"=>"Fatal error: no valid response from script.", "code"=>NULL); 
    22 }//end if 
     64        $queryresult = $this->db->query($querystatement); 
    2365 
    24 $response = json_encode($response); 
    25 echo($response); 
    26 exit; 
     66        $therecord = $this->db->fetchArray($queryresult); 
     67 
     68        if(hasRights($therecord["roleid"])) 
     69           return true; 
     70        else 
     71            return false; 
     72 
     73    }//end function checkSecurity 
     74 
     75 
     76    function sync(){ 
     77 
     78        $listSync = new listSync( 
     79                                 $this->db, 
     80                                 MAILCHIMP_APIKEY, 
     81                                 MAILCHIMP_LIST_ID, 
     82                                 MAILCHIMP_LAST_SYNC_DATE, 
     83                                 NULL, 
     84                                 MAILCHIMP_SECURE 
     85                                 ); 
     86 
     87        $response = $listSync->process(); 
     88 
     89        if(!isset($response["type"])){ 
     90            $response = array(); 
     91            $response["type"] = "error"; 
     92            $response["details"] = array("message"=>"Fatal error: no valid response from script.", "code"=>NULL); 
     93        }//end if 
     94 
     95        $response = json_encode($response); 
     96        echo($response); 
     97 
     98    }//end function sync 
     99 
     100}//end class 
     101 
     102/** 
     103 * PROCESSING ================================================================== 
     104 */ 
     105if(!isset($noOutput)){ 
     106 
     107    require("../../include/session.php"); 
     108    include("include/MCAPI.class.php");//for MCAPI CLASS (listSync class uses it) 
     109    include("include/list_sync.php");//for listSync class 
     110 
     111    $sync = new manualSync($db); 
     112 
     113    if($sync->checkSecurity()) 
     114        $sync->sync(); 
     115    else{ 
     116 
     117        $response = array(); 
     118        $response["type"] = "error"; 
     119        $response["details"] = array("message"=>"No rights to run script", "code"=>NULL); 
     120        echo json_encode($response); 
     121 
     122    }//endif 
     123 
     124}//endif 
     125 
     126 
    27127?> 
  • trunk/phpbms/modules/mailchimp/report/basic_mc.php

    r677 r730  
    11<?php 
     2/* 
     3 $Rev: 267 $ | $LastChangedBy: brieb $ 
     4 $LastChangedDate: 2007-08-14 13:08:27 -0600 (Tue, 14 Aug 2007) $ 
     5 +-------------------------------------------------------------------------+ 
     6 | Copyright (c) 2004 - 2010, Kreotek LLC                                  | 
     7 | All rights reserved.                                                    | 
     8 +-------------------------------------------------------------------------+ 
     9 |                                                                         | 
     10 | Redistribution and use in source and binary forms, with or without      | 
     11 | modification, are permitted provided that the following conditions are  | 
     12 | met:                                                                    | 
     13 |                                                                         | 
     14 | - Redistributions of source code must retain the above copyright        | 
     15 |   notice, this list of conditions and the following disclaimer.         | 
     16 |                                                                         | 
     17 | - Redistributions in binary form must reproduce the above copyright     | 
     18 |   notice, this list of conditions and the following disclaimer in the   | 
     19 |   documentation and/or other materials provided with the distribution.  | 
     20 |                                                                         | 
     21 | - Neither the name of Kreotek LLC nor the names of its contributore may | 
     22 |   be used to endorse or promote products derived from this software     | 
     23 |   without specific prior written permission.                            | 
     24 |                                                                         | 
     25 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS     | 
     26 | "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT       | 
     27 | LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A | 
     28 | PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT      | 
     29 | OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,   | 
     30 | SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT        | 
     31 | LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,   | 
     32 | DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY   | 
     33 | THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT     | 
     34 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE   | 
     35 | OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.    | 
     36 |                                                                         | 
     37 +-------------------------------------------------------------------------+ 
     38*/ 
    239    $_POST["columns"] = array(5,4,3,2,1,0); 
    340    $_POST["columns"] = json_encode($_POST["columns"]); 
    441 
    5         require("client_mailchimp_export.php"); 
     42    require("client_mailchimp_export.php"); 
    643 
    744?> 
  • trunk/phpbms/modules/mailchimp/scheduler_list_sync.php

    r686 r730  
    11<?php 
     2/* 
     3 $Rev: 267 $ | $LastChangedBy: brieb $ 
     4 $LastChangedDate: 2007-08-14 13:08:27 -0600 (Tue, 14 Aug 2007) $ 
     5 +-------------------------------------------------------------------------+ 
     6 | Copyright (c) 2004 - 2010, Kreotek LLC                                  | 
     7 | All rights reserved.                                                    | 
     8 +-------------------------------------------------------------------------+ 
     9 |                                                                         | 
     10 | Redistribution and use in source and binary forms, with or without      | 
     11 | modification, are permitted provided that the following conditions are  | 
     12 | met:                                                                    | 
     13 |                                                                         | 
     14 | - Redistributions of source code must retain the above copyright        | 
     15 |   notice, this list of conditions and the following disclaimer.         | 
     16 |                                                                         | 
     17 | - Redistributions in binary form must reproduce the above copyright     | 
     18 |   notice, this list of conditions and the following disclaimer in the   | 
     19 |   documentation and/or other materials provided with the distribution.  | 
     20 |                                                                         | 
     21 | - Neither the name of Kreotek LLC nor the names of its contributore may | 
     22 |   be used to endorse or promote products derived from this software     | 
     23 |   without specific prior written permission.                            | 
     24 |                                                                         | 
     25 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS     | 
     26 | "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT       | 
     27 | LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A | 
     28 | PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT      | 
     29 | OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,   | 
     30 | SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT        | 
     31 | LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,   | 
     32 | DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY   | 
     33 | THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT     | 
     34 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE   | 
     35 | OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.    | 
     36 |                                                                         | 
     37 +-------------------------------------------------------------------------+ 
     38*/ 
     39 
    240//uncomment if need debug 
    341if(!class_exists("appError")) 
    4         include_once("../../include/session.php"); 
    5          
     42    include_once("../../include/session.php"); 
     43 
    644include("include/MCAPI.class.php");//for MCAPI CLASS (listSync class uses it) 
    745include("include/list_sync.php");//for listSync class 
    846 
     47$querystatement = " 
     48    SELECT 
     49        roleid 
     50    FROM 
     51        tableoptions 
     52    WHERE 
     53        name= 'massemail' 
     54        AND tabledefid = 'tbld:6d290174-8b73-e199-fe6c-bcf3d4b61083' 
     55        "; 
     56 
     57$queryresult = $this->db->query($querystatement); 
     58 
     59$therecord = $this->db->fetchArray($queryresult); 
     60 
     61if(!hasRights($therecord["roleid"])) 
     62    exit(false); 
    963 
    1064$listSync = new listSync( 
     
    2074 
    2175if(isset($response["type"])){ 
    22      
     76 
    2377    if($response["type"] != "success") 
    2478       foreach($response["details"] AS $errorArray){ 
    25              
     79 
    2680            $message = "MailChimp sync ".$response["type"].": ".$errorArray["message"]." (".$errorArray["code"].")"; 
    2781            $log = new phpbmsLog($message, "SCHEDULER", NULL, $db); 
    28              
     82 
    2983       }//end if 
    30      
     84 
    3185}//end if 
    3286?> 
phpBMS vulnerability assesment provided by Orvant Inc. Copyright © 2010 Kreotek, LLC. All Rights reserved.