コード例 #1
0
    /**
     * showOptionsPage
     * Displays the print option page.
     *
     * @return Void Does not return anything.
     */
    function showOptionsPage()
    {
        $statstype = $this->_getGETRequest('statstype', null);
        if ($statstype == null) {
            return false;
            exit;
        }
        $path = $this->_getGETRequest('path', '');
        SendStudio_Functions::LoadLanguageFile('stats');
        $stats_api = $this->GetApi('Splittest_Stats');
        $bg_color = 'white';
        $print_options = '<input type="hidden" name="statstype" value="' . htmlentities($statstype, ENT_QUOTES, SENDSTUDIO_CHARSET) . '" />';
        switch ($statstype) {
            case 'splittest':
                $splitStatIds = $this->_getGETRequest('statids', null);
                $jobIds = $this->_getGETRequest('jobids', null);
                $splitStatIds = SplitTest_API::FilterIntSet($splitStatIds);
                $jobIds = SplitTest_API::FilterIntSet($jobIds);
                $print_options .= '<input type="hidden" name="split_statids" value="' . implode(',', $splitStatIds) . '" />';
                $print_options .= '<input type="hidden" name="jobids" value="' . implode(',', $jobIds) . '" />';
                $options = array('snapshot' => GetLang('Addon_splittest_Menu_ViewStats'), 'open' => GetLang('Addon_splittest_open_summary'), 'click' => GetLang('Addon_splittest_linkclick_summary'), 'bounce' => GetLang('Addon_splittest_bounce_summary'), 'unsubscribe' => GetLang('Addon_splittest_unsubscribe_summary'));
                foreach ($options as $key => $val) {
                    $bg_color = $bg_color == 'white' ? '#EDECEC' : 'white';
                    $print_options .= '<div style="background-color: ' . $bg_color . '; padding: 5px; margin-bottom: 5px;">';
                    $print_options .= '<input id="print_' . $key . '" type="checkbox" name="options[]" value="' . $key . '" checked="checked" style="margin:0;"/>
						<label for="print_' . $key . '">' . $val . '</label>' . "\n";
                    $print_options .= '</div>' . "\n";
                }
                break;
        }
        $this->template_system->assign('path', $path);
        $this->template_system->Assign('title', GetLang('Addon_splittest_PrintSplitTestStatistics'));
        $this->template_system->Assign('print_options', $print_options);
        $this->template_system->ParseTemplate('print_stats_options');
    }
コード例 #2
0
ファイル: print_stats.php プロジェクト: hungnv0789/vhtm
 /**
  * printPage
  *
  * @return Void Doesn't return anything.
  */
 public function printPage()
 {
     $user = GetUser();
     $split_api = $this->GetApi('Splittest');
     // for permission checks
     $subaction = $this->_getGetRequest('subaction', 'print');
     $perpage = $this->_getGetRequest('PerPageDisplay', null);
     $jobids = $this->_getGETRequest('jobids', null);
     $listids = $this->_getGETRequest('split_statids', null);
     $jobids = explode(",", $jobids);
     $listids = explode(",", $listids);
     SendStudio_Functions::LoadLanguageFile('Stats');
     if (!SplitTest_API::OwnsJobs($user->Get('userid'), $jobids) && !$user->Admin()) {
         FlashMessage(GetLang('NoAccess'), SS_FLASH_MSG_ERROR, $this->base_url);
         return;
     }
     // Get some setup parameters for the API
     $sortdetails = array('sort' => 'splitname', 'direction' => 'asc');
     $page_number = 0;
     $perpage = 20;
     $displayAll = false;
     // just show a single splitest campaign send. If you want every campaign send for a split test set to true
     $dateFromat = self::getDateFormat();
     $statitics = array();
     $jobid = 0;
     for ($i = 0; $i < count($jobids); $i++) {
         $stats = array();
         $stats_api = new Splittest_Stats_API();
         $jobid = $jobids[$i];
         $splitid = $listids[$i];
         // get the array of stats data
         $stats = $stats_api->GetStats(array($splitid), $sortdetails, false, $page_number, $perpage, $displayAll, $jobid);
         foreach ($stats as $stats_id => $stats_details) {
             $stats[$stats_id]['splitname'] = htmlspecialchars($stats_details['splitname'], ENT_QUOTES, SENDSTUDIO_CHARSET);
             $stats[$stats_id]['campaign_names'] = htmlspecialchars($stats_details['campaign_names'], ENT_QUOTES, SENDSTUDIO_CHARSET);
             $stats[$stats_id]['list_names'] = htmlspecialchars($stats_details['list_names'], ENT_QUOTES, SENDSTUDIO_CHARSET);
         }
         // A Splittest can be sent multiple times hence we might have multiple campaign record sets here
         while (list($id, $data) = each($stats)) {
             $charts = $this->generateCharts($data['splitname'], $data['campaigns'], $subaction);
             foreach ($charts as $type => $data) {
                 $stats[$id][$type] = $data;
             }
         }
         $statistics[] = $stats;
     }
     $template = GetTemplateSystem(dirname(__FILE__) . '/templates');
     $template->Assign('DateFormat', $dateFromat);
     $template->Assign('statsData', $statistics);
     $template->Assign('subaction', $subaction);
     $options = $this->_getGETRequest('options', null);
     for ($i = 0; $i < count($options); $i++) {
         $template->Assign($options[$i], $options[$i]);
     }
     $template->ParseTemplate('Stats_Summary_Splittest');
 }
コード例 #3
0
 /**
  * Show_Send_Step_2
  * This handles the second step of the send process where
  *
  * 1) the first step is verified in php
  * - checks you are choosing a list or segment
  * - checks the list/segment id's are valid (ie they are proper id's and not non-numeric values)
  * - checks the list or segment has contacts in it
  *
  * If that checks out ok, the second step shows the form where you set:
  * - from details
  * - bounce details
  * - whether to send the campaigns as multipart (where possible)
  * - whether to embed images or not (where possible)
  * - choose the first/last name custom fields
  * - when to send the split test (if cron is enabled)
  *
  * @uses FlashMessage
  * @uses GetFlashMessages
  * @uses List_API::Load
  * @uses List_API::GetCustomFields
  * @uses Segment_API::Load
  * @uses GetUser
  * @uses User_API::HasAccess
  * @uses CheckCronEnabled
  */
 public function Show_Send_Step_2()
 {
     $send_details = IEM::sessionGet('SplitTestSend');
     /**
      * Check the user has been through step 1 successfully.
      */
     if (!$send_details || !isset($send_details['splitid']) || (int) $send_details['splitid'] <= 0) {
         FlashMessage(GetLang('Addon_splittest_Send_InvalidSplitTest'), SS_FLASH_MSG_ERROR, $this->admin_url);
         return;
     }
     $step1_url = $this->admin_url . '&Action=Send&id=' . $send_details['splitid'];
     $flash_messages = GetFlashMessages();
     /**
      * If we are not posting a form, maybe we're being redirected back to this step from step 3.
      * If we are, we'll have flash messages.
      *
      * If there are no post variables and we are not showing any messages, then go back to step 1.
      */
     if (empty($_POST) && empty($flash_messages)) {
         FlashMessage(GetLang('Addon_splittest_Send_ChooseListOrSegment'), SS_FLASH_MSG_ERROR, $step1_url);
         return;
     }
     /**
      * If we are posting a form, check we are posting a proper form (we should have lists or segments chosen)
      */
     if (!empty($_POST)) {
         /**
          * Work out which option the user chose
          */
         $sending_to = array();
         $send_type = '';
         switch ((int) $_POST['ShowFilteringOptions']) {
             case 1:
                 $send_type = 'list';
                 if (isset($_POST['lists'])) {
                     $sending_to = $_POST['lists'];
                 }
                 break;
             case 2:
                 $send_type = 'segment';
                 if (isset($_POST['segments'])) {
                     $sending_to = $_POST['segments'];
                 }
                 break;
             default:
                 FlashMessage(GetLang('Addon_splittest_Send_ChooseListOrSegment'), SS_FLASH_MSG_ERROR, $step1_url);
                 return;
                 break;
         }
         /**
          * Make sure the user actually chose some options.
          */
         if (empty($sending_to)) {
             FlashMessage(GetLang('Addon_splittest_Send_ChooseListOrSegment'), SS_FLASH_MSG_ERROR, $step1_url);
             return;
         }
         /**
          * Make sure the id's the user chose are valid
          * If any area invalid (not int's), the user is thrown back to the first step.
          */
         foreach ($sending_to as $id) {
             $id = (int) $id;
             if ($id <= 0) {
                 FlashMessage(GetLang('Addon_splittest_Send_ChooseListOrSegment'), SS_FLASH_MSG_ERROR, $step1_url);
                 return;
             }
         }
         /**
          * After everything has been validated, store the settings and display the next form.
          */
         $send_details['sendingto'] = array('sendtype' => $send_type, 'sendids' => $sending_to);
         IEM::sessionSet('SplitTestSend', $send_details);
     }
     $user = GetUser();
     /**
      * Re-set these variables.
      * They may be coming from the session if we are being redirected back to step 2 from another step.
      */
     $send_type = $send_details['sendingto']['sendtype'];
     $sending_to = $send_details['sendingto']['sendids'];
     /**
      * Get the first list or segment we're sending to.
      * We need this to set the defaults for the from name, email, reply-to email and bounce details.
      * It doesn't really matter what the id is, the user can override the options anyway through the form.
      */
     $id = $sending_to[0];
     $send_size = 0;
     /**
      * We always need the list api
      * so we can load the right details regardless of whether the user is sending to a segment or list.
      */
     require_once SENDSTUDIO_API_DIRECTORY . '/lists.php';
     $list_api = new Lists_API();
     switch ($send_type) {
         case 'list':
             $list_id = $id;
             $listids = $sending_to;
             $user_lists = $user->GetLists();
             foreach ($user_lists as $user_list_id => $user_list_details) {
                 if (!in_array($user_list_id, $sending_to)) {
                     continue;
                 }
                 $send_size += $user_list_details['subscribecount'];
             }
             // this is used at a later step to check duplicates etc.
             $send_details['sendingto']['Lists'] = $sending_to;
             break;
         case 'segment':
             require_once SENDSTUDIO_API_DIRECTORY . '/subscribers.php';
             $api = new Subscribers_API();
             $segment_info = $api->GetSubscribersFromSegment($sending_to, true);
             $send_size = $segment_info['count'];
             /**
              * Since a segment can go across lists,
              * we only need one list - so just get the first one we come across.
              * The user can change the details on the fly anyway.
              */
             $listids = $segment_info['lists'];
             $list_id = $listids[0];
             // this is used at a later step to check duplicates etc.
             $send_details['sendingto']['Lists'] = $listids;
             break;
     }
     if ($send_size <= 0) {
         $var = 'Addon_splittest_Send_NoContacts_';
         if (sizeof($sending_to) == 1) {
             $var .= 'One_';
         } else {
             $var .= 'Many_';
         }
         $var .= $send_type;
         FlashMessage(GetLang($var), SS_FLASH_MSG_ERROR, $step1_url);
         return;
     }
     $send_details['sendsize'] = $send_size;
     IEM::sessionSet('SplitTestSend', $send_details);
     /**
      * Get the flashmessage to draw the box.
      * then add to the existing messages (eg we're back here from step 3).
      */
     if ($send_size == 1) {
         FlashMessage(GetLang('Addon_splittest_Send_Step2_Size_One'), SS_FLASH_MSG_SUCCESS);
     } else {
         FlashMessage(sprintf(GetLang('Addon_splittest_Send_Step2_Size_Many'), $this->PrintNumber($send_size)), SS_FLASH_MSG_SUCCESS);
     }
     $flash_messages .= GetFlashMessages();
     $this->template_system->Assign('FlashMessages', $flash_messages, false);
     if (self::CheckCronEnabled()) {
         $this->template_system->Assign('CronEnabled', true);
         /**
          * Get the sendstudio functions file to create the date/time box.
          */
         require_once SENDSTUDIO_FUNCTION_DIRECTORY . '/sendstudio_functions.php';
         /**
          * also need to load the 'send' language file so it can put in the names/descriptions.
          */
         $ssf = new SendStudio_Functions();
         $ssf->LoadLanguageFile('send');
         $timebox = $ssf->CreateDateTimeBox(0, false, 'datetime', true);
         $this->template_system->Assign('ScheduleTimeBox', $timebox, false);
     }
     $this->template_system->Assign('ShowBounceInfo', $user->HasAccess('Lists', 'BounceSettings'));
     $this->template_system->Assign('DisplayEmbedImages', SENDSTUDIO_ALLOW_EMBEDIMAGES);
     $this->template_system->Assign('EmbedImagesByDefault', SENDSTUDIO_DEFAULT_EMBEDIMAGES);
     $list_api->Load($list_id);
     $details = array('fromname' => $list_api->Get('ownername'), 'fromemail' => $list_api->Get('owneremail'), 'replytoemail' => $list_api->Get('replytoemail'), 'bounceemail' => $list_api->Get('bounceemail'));
     $customfield_settings = array();
     $list_customfields = $list_api->GetCustomFields($listids);
     foreach ($list_customfields as $fieldid => $fielddetails) {
         if (strtolower($fielddetails['fieldtype']) != 'text') {
             continue;
         }
         $customfield_settings[$fieldid] = htmlspecialchars($fielddetails['name'], ENT_QUOTES, SENDSTUDIO_CHARSET);
     }
     $show_customfields = false;
     if (!empty($customfield_settings)) {
         $show_customfields = true;
     }
     $this->template_system->Assign('CustomFields', $customfield_settings);
     $this->template_system->Assign('ShowCustomFields', $show_customfields);
     foreach ($details as $name => $value) {
         $this->template_system->Assign($name, $value);
     }
     $this->template_system->Assign('AdminUrl', $this->admin_url, false);
     $this->template_system->ParseTemplate('send_step2');
 }
コード例 #4
0
	/**
	* ActionJob
	* This actually processes the autoresponder job and sends it out.
	* It makes sure the autoresponder queue is present (if not, returns false)
	* It makes sure the autoresponder exists and is active (if not, returns false)
	* It makes sure the autoresponder has some content (if not, returns false)
	* Once that is done, it removes any newly banned subscribers
	* Then removes any newly unsubscribe recipients
	* It makes sure the recipient is valid, is on the list and matches the criteria set by the autoresponder
	* Then it gets to work, constructing the email to get sent to the final recipient
	* Once all recipients for this queue have been looked at, it will "UnProcess" the queue to make everyone active again so next time the job runs, it can start all over again.
	* The only recipients that are treated this way are the ones who are before the autoresponder's "hours after subscription" timeframe.
	*
	* @param Int $queueid The queue to process.
	*
	* @see IsQueue
	* @see Autoresponders_API::Load
	* @see Autoresponders_API::Active
	* @see SendStudio_Functions::GetAttachments
	* @see Lists_API::Load
	* @see RemoveBannedEmails
	* @see RemoveUnsubscribedEmails
	* @see Email_API
	* @see FetchFromQueue
	* @see Subscribers_API::LoadSubscriberList
	* @see RemoveFromQueue
	* @see MarkAsProcessed
	* @see MatchCriteria
	*
	* @return Boolean Returns false if the queue can't be processed for any reason, otherwise it gets processed and returns true.
	*/
	function ActionJob($queueid=0, $jobid=0)
	{
		$queueid = (int)$queueid;
		if (!$this->IsQueue($queueid, 'autoresponder')) {
			if ($this->Debug) {
				error_log(time() . "\t" . __FILE__ . "\t" . __LINE__ . "\t" . "queueid (" . $queueid . ") is not valid" . "\n", 3, $this->LogFile);
				error_log(time() . "\t" . __FILE__ . "\t" . __LINE__ . "\t" . "Returning" . "\n", 3, $this->LogFile);
			}
			return false;
		}

		if ($this->Debug) {
			error_log(time() . "\t" . __FILE__ . "\t" . __LINE__ . "\t" . "found queueid (" . $queueid . ")" . "\n", 3, $this->LogFile);
		}

		$query = "SELECT autoresponderid FROM " . SENDSTUDIO_TABLEPREFIX . "autoresponders WHERE queueid='" . $queueid . "'";
		$result = $this->Db->Query($query);
		if (!$result) {
			if ($this->Debug) {
				error_log(time() . "\t" . __FILE__ . "\t" . __LINE__ . "\t" . "unable to find autoresponder for queue" . "\n", 3, $this->LogFile);
				error_log(time() . "\t" . __FILE__ . "\t" . __LINE__ . "\t" . "Returning" . "\n", 3, $this->LogFile);
			}
			return false;
		}

		if ($this->Debug) {
			error_log(time() . "\t" . __FILE__ . "\t" . __LINE__ . "\t" . "got autoresponder result" . "\n", 3, $this->LogFile);
		}

		$row = $this->Db->Fetch($result);
		if (empty($row)) {
			if ($this->Debug) {
				error_log(time() . "\t" . __FILE__ . "\t" . __LINE__ . "\t" . "unable to find autoresponder" . "\n", 3, $this->LogFile);
				error_log(time() . "\t" . __FILE__ . "\t" . __LINE__ . "\t" . "Returning" . "\n", 3, $this->LogFile);
			}
			return false;
		}

		if ($this->Debug) {
			error_log(time() . "\t" . __FILE__ . "\t" . __LINE__ . "\t" . "found autoresponder (" . $row['autoresponderid'] . ")" . "\n", 3, $this->LogFile);
		}

		$this->autoresponder_api->Load($row['autoresponderid']);
		if ($this->autoresponder_api->autoresponderid <= 0) {
			if ($this->Debug) {
				error_log(time() . "\t" . __FILE__ . "\t" . __LINE__ . "\t" . "unable to find autoresponder" . "\n", 3, $this->LogFile);
				error_log(time() . "\t" . __FILE__ . "\t" . __LINE__ . "\t" . "Returning" . "\n", 3, $this->LogFile);
			}
			return false;
		}

		if ($this->Debug) {
			error_log(time() . "\t" . __FILE__ . "\t" . __LINE__ . "\t" . "loaded autoresponder (" . $row['autoresponderid'] . ")" . "\n", 3, $this->LogFile);
		}

		// if the autoresponder isn't active, don't do anything.
		if (!$this->autoresponder_api->Active()) {
			if ($this->Debug) {
				error_log(time() . "\t" . __FILE__ . "\t" . __LINE__ . "\t" . "autoresponder not active" . "\n", 3, $this->LogFile);
				error_log(time() . "\t" . __FILE__ . "\t" . __LINE__ . "\t" . "Returning" . "\n", 3, $this->LogFile);
			}
			return false;
		}

		if ($this->Debug) {
			error_log(time() . "\t" . __FILE__ . "\t" . __LINE__ . "\t" . "autoresponder is active" . "\n", 3, $this->LogFile);
		}

		// if the autoresponder is empty, don't do anything.
		if (empty($this->autoresponder_api->textbody) && empty($this->autoresponder_api->htmlbody)) {
			if ($this->Debug) {
				error_log(time() . "\t" . __FILE__ . "\t" . __LINE__ . "\t" . "autoresponder bodies are empty" . "\n", 3, $this->LogFile);
				error_log(time() . "\t" . __FILE__ . "\t" . __LINE__ . "\t" . "Returning" . "\n", 3, $this->LogFile);
			}
			return false;
		}

		if ($this->Debug) {
			error_log(time() . "\t" . __FILE__ . "\t" . __LINE__ . "\t" . "autoresponder has text &/or html body" . "\n", 3, $this->LogFile);
		}

		$this->autoresponder['Attachments'] = SendStudio_Functions::GetAttachments('autoresponders', $this->autoresponder_api->Get('autoresponderid'), true);

		$this->listid = $this->autoresponder_api->Get('listid');

		$this->Lists_API->Load($this->listid);
		$listname = $this->Lists_API->Get('name');

		$search_criteria = $this->autoresponder_api->Get('searchcriteria');

		if ($this->Debug) {
			error_log(time() . "\t" . __FILE__ . "\t" . __LINE__ . "\t" . "search_criteria: " . array_contents($search_criteria) . "\n", 3, $this->LogFile);
		}

		if (SENDSTUDIO_DATABASE_TYPE == 'pgsql') {
			$this->Db->OptimizeTable(SENDSTUDIO_TABLEPREFIX . "queues");
		}

		// double check there are no duplicates in the autoresponder queue.
		$this->RemoveDuplicatesInQueue($queueid, 'autoresponder', $this->listid);

		// remove any that have been newly banned.
		$this->RemoveBannedEmails($this->listid, $queueid, 'autoresponder');

		// remove any that have unsubscribed.
		$this->RemoveUnsubscribedEmails($this->listid, $queueid, 'autoresponder');

		if (SENDSTUDIO_DATABASE_TYPE == 'pgsql') {
			$this->Db->OptimizeTable(SENDSTUDIO_TABLEPREFIX . "queues");
		}

		$this->Email_API->ForgetEmail();

		$this->Email_API->Set('statid', $this->statid);
		$this->Email_API->Set('listids', array($this->listid));

		$this->Email_API->SetSmtp(SENDSTUDIO_SMTP_SERVER, SENDSTUDIO_SMTP_USERNAME, @base64_decode(SENDSTUDIO_SMTP_PASSWORD), SENDSTUDIO_SMTP_PORT);

		if ($this->user->smtpserver) {
			$this->Email_API->SetSmtp($this->user->smtpserver, $this->user->smtpusername, $this->user->smtppassword, $this->user->smtpport);
		}

		if (is_null($this->userpause)) {
			$pause = $pausetime = 0;
			if ($this->user->perhour > 0) {
				$pause = $this->user->perhour;
			}

			// in case the system rate is less than the user rate, lower it.
			if (SENDSTUDIO_MAXHOURLYRATE > 0) {
				if ($pause == 0) {
					$pause = SENDSTUDIO_MAXHOURLYRATE;
				} else {
					$pause = min($pause, SENDSTUDIO_MAXHOURLYRATE);
				}
			}

			if ($pause > 0) {
				$pausetime = 3600 / $pause;
			}
			$this->userpause = $pausetime;
			if ($this->Debug) {
				error_log(time() . "\t" . __FILE__ . "\t" . __LINE__ . "\t" . "userpause is set to " . $this->userpause . "\n", 3, $this->LogFile);
			}
		}

		if ($this->autoresponder_api->Get('tracklinks')) {
			$this->Email_API->TrackLinks(true);
		}

		if ($this->autoresponder_api->Get('trackopens')) {
			$this->Email_API->TrackOpens(true);
		}

		if (SENDSTUDIO_FORCE_UNSUBLINK) {
			$this->Email_API->ForceLinkChecks(true);
		}

		$this->Email_API->Set('CharSet', $this->autoresponder_api->Get('charset'));

		if (!SENDSTUDIO_SAFE_MODE) {
			$this->Email_API->Set('imagedir', TEMP_DIRECTORY . '/autoresponder.' . $queueid);
		} else {
			$this->Email_API->Set('imagedir', TEMP_DIRECTORY . '/autoresponder');
		}

		// clear out the attachments just to be safe.
		$this->Email_API->ClearAttachments();

		if ($this->autoresponder['Attachments']) {
			$path = $this->autoresponder['Attachments']['path'];
			$files = $this->autoresponder['Attachments']['filelist'];
			foreach ($files as $p => $file) {
				$this->Email_API->AddAttachment($path . '/' . $file);
			}
		}

		$this->Email_API->Set('Subject', $this->autoresponder_api->Get('subject'));

		$this->Email_API->Set('FromName', $this->autoresponder_api->Get('sendfromname'));
		$this->Email_API->Set('FromAddress', $this->autoresponder_api->Get('sendfromemail'));
		$this->Email_API->Set('ReplyTo', $this->autoresponder_api->Get('replytoemail'));
		$this->Email_API->Set('BounceAddress', $this->autoresponder_api->Get('bounceemail'));

		$this->Email_API->Set('EmbedImages', $this->autoresponder_api->Get('embedimages'));

		$auto_format = $this->autoresponder_api->Get('format');

		$this->Email_API->Set('Multipart', false);

		if ($auto_format == 'b' || $auto_format == 't') {
			if ($this->autoresponder_api->GetBody('text')) {
				$this->Email_API->AddBody('text', $this->autoresponder_api->GetBody('text'));
				$this->Email_API->AppendBody('text', $this->user->Get('textfooter'));
				$this->Email_API->AppendBody('text', stripslashes(SENDSTUDIO_TEXTFOOTER));
			}
		}

		if ($auto_format == 'b' || $auto_format == 'h') {
			if ($this->autoresponder_api->GetBody('html')) {
				$this->Email_API->AddBody('html', $this->autoresponder_api->GetBody('html'));
				$this->Email_API->AppendBody('html', $this->user->Get('htmlfooter'));
				$this->Email_API->AppendBody('html', stripslashes(SENDSTUDIO_HTMLFOOTER));
			}
		}

		if ($auto_format == 'b' && $this->autoresponder_api->Get('multipart')) {
			if ($this->autoresponder_api->GetBody('text') && $this->autoresponder_api->GetBody('html')) {
				$sent_format = 'm';
				$this->Email_API->Set('Multipart', true);
			} else {
				$this->Email_API->Set('Multipart', false);
			}
		}

		$custom_fields_to_replace = $this->Email_API->GetCustomFields();

		$personalize_customfields = array();

		$firstname_field = $this->autoresponder_api->Get('to_firstname');
		if ($firstname_field) {
			$personalize_customfields[] = $firstname_field;
		}

		$lastname_field = $this->autoresponder_api->Get('to_lastname');
		if ($lastname_field) {
			$personalize_customfields[] = $lastname_field;
		}

		$personalize_customfields = array_unique($personalize_customfields);

		// Current available credit returns TRUE if credit is unlimited
		$credit_available = true;

		if (SENDSTUDIO_CREDIT_INCLUDE_AUTORESPONDERS) {
			$credit_available = API_USERS::creditAvailableTotal($this->autoresponder_api->Get('ownerid'));
		}

		$credit_used = 0;
		$emails_sent = 0;
		if ($this->Debug) {
			error_log(time() . "\t" . __FILE__ . "\t" . __LINE__ . "\t" . "checking queue for deleted recipients" . "\n", 3, $this->LogFile);
		}		
		$recipient_to_check = array();
		$query = "SELECT recipient FROM " . SENDSTUDIO_TABLEPREFIX . "queues WHERE queueid={$queueid}";
		$result = $this->Db->Query($query);
		if (!$result) {
			trigger_error(mysql_error());
			if ($this->Debug) {
				error_log(time() . "\t" . __FILE__ . "\t" . __LINE__ . "\t" . mysql_error() . "\n", 3, $this->LogFile);
			}
		}
		while ($row = $this->Db->Fetch($result)) {
			$recipient_to_check[] = $row['recipient'];
		}

		foreach($recipient_to_check as $val)
		{
			$query = "SELECT COUNT(subscriberid) FROM " . SENDSTUDIO_TABLEPREFIX . "list_subscribers WHERE subscriberid={$val}";
			$exist = $this->Db->FetchOne($query);
			if((int)$exist == 0){
				if ($this->Debug) {
					error_log(time() . "\t" . __FILE__ . "\t" . __LINE__ . "\t" . "subscriber id {$val} no longer exists" . "\n", 3, $this->LogFile);
				}
				$this->SaveAutoresponderSentStatus(false, $this->autoresponder_api->Get('autoresponderid'), $val, 'doesntexist');
				$this->MarkAsSent($queueid, $val);

			}
			
		}
		if ($this->Debug) {
			error_log(time() . "\t" . __FILE__ . "\t" . __LINE__ . "\t" . "fetching autoresponder recipients" . "\n", 3, $this->LogFile);
		}
		while ($recipients = $this->FetchFromQueue($queueid, 'autoresponder', 1, 500, $this->autoresponder_api->Get('hoursaftersubscription'))) {
			if (empty($recipients)) {
				if ($this->Debug) {
					error_log(time() . "\t" . __FILE__ . "\t" . __LINE__ . "\t" . "no more recipients" . "\n", 3, $this->LogFile);
				}

				break;
			}

			if ($this->Debug) {
				error_log(time() . "\t" . __FILE__ . "\t" . __LINE__ . "\t" . "found " . sizeof($recipients) . " recipients" . "\n", 3, $this->LogFile);
			}

			
            		$tempCustomField = $this->SetupDynamicContentFields($recipients, $this->listid, true);
            		$custom_fields_to_replace = array_unique(array_merge($tempCustomField, $custom_fields_to_replace));
			$all_customfields = $this->SetupCustomFields($this->listid, $custom_fields_to_replace, $recipients, $personalize_customfields);

			foreach ($recipients as $p => $recipientid) {
				$subscriberinfo = $this->Subscriber_API->LoadSubscriberList($recipientid, $this->listid, true, false, false);

				if ($this->Debug) {
					error_log(time() . "\t" . __FILE__ . "\t" . __LINE__ . "\t" . "recipientid: " . $recipientid . "; subscriberinfo: " . array_contents($subscriberinfo) . "\n", 3, $this->LogFile);
				}

				// if they don't match the search criteria, remember it for later and don't sent it.
				if (empty($subscriberinfo) || !isset($subscriberinfo['subscribedate'])) {
					if ($this->Debug) {
						error_log(time() . "\t" . __FILE__ . "\t" . __LINE__ . "\t" . "recipientid: " . $recipientid . "; subscriber info is empty or date is not set" . "\n", 3, $this->LogFile);
					}

					$this->SaveAutoresponderSentStatus(false, $this->autoresponder_api->Get('autoresponderid'), $recipientid, 'unsubscribed');


					$this->MarkAsSent($queueid, $recipientid);
					continue;
				}

				if ($this->Debug) {
					error_log(time() . "\t" . __FILE__ . "\t" . __LINE__ . "\t" . "recipientid: " . $recipientid . " has email address " . $subscriberinfo['emailaddress'] . "\n", 3, $this->LogFile);
				}

				// work out how long they have been subscribed for.
				$hours_subscribed = floor(($this->currenttime - $subscriberinfo['subscribedate']) / 3600);

				if ($this->Debug) {
					error_log(time() . "\t" . __FILE__ . "\t" . __LINE__ . "\t" . "recipientid: " . $recipientid . " subscribed for " . $hours_subscribed . "\n", 3, $this->LogFile);
				}

				// not long enough? Go to the next one.
				if ($hours_subscribed < $this->autoresponder_api->Get('hoursaftersubscription')) {
					if ($this->Debug) {
						error_log(time() . "\t" . __FILE__ . "\t" . __LINE__ . "\t" . "recipientid: " . $recipientid . "; not time to send the autoresponder yet (subscribed for " . $hours_subscribed . "; hours set to: " . $this->autoresponder_api->Get('hoursaftersubscription') . ")" . "\n", 3, $this->LogFile);
					}
					$this->MarkAsProcessed($queueid, 'autoresponder', $recipientid);
					continue;
				}

				if ($this->Debug) {
					error_log(time() . "\t" . __FILE__ . "\t" . __LINE__ . "\t" . "recipientid: " . $recipientid . " has been subscribed for long enough" . "\n", 3, $this->LogFile);
				}

				// if they don't match the search criteria, remember it for later and don't send it.
				if (!$this->MatchCriteria($search_criteria, $recipientid)) {
					$this->SaveAutoresponderSentStatus(false, $this->autoresponder_api->Get('autoresponderid'), $recipientid, 'search_criteria');
					if ($this->Debug) {
						error_log(time() . "\t" . __FILE__ . "\t" . __LINE__ . "\t" . "recipientid: " . $recipientid . "; dont meet search criteria (" . array_contents($search_criteria) . ")" . "\n", 3, $this->LogFile);
					}
					$this->MarkAsSent($queueid, $recipientid);
					continue;
				}

				if ($this->Debug) {
					error_log(time() . "\t" . __FILE__ . "\t" . __LINE__ . "\t" . "does meet search criteria" . "\n", 3, $this->LogFile);
				}

				// If user don't have enough credit, discard queue record
				if ($credit_available !== true && ($credit_available <= 0 || $credit_available <= $credit_used)) {
					if ($this->Debug) {
						error_log(time() . "\t" . __FILE__ . "\t" . __LINE__ . "\tUser (userid: {$this->autoresponder->ownerid}) does not have enough credit... Will remove subscriber (id: {$recipientid}) from queue table.\n", 3, $this->LogFile);
					}

					$this->SaveAutoresponderSentStatus(false, $this->autoresponder_api->Get('autoresponderid'), $recipientid, 'icredit');

					$this->MarkAsSent($queueid, $recipientid);
					continue;
				}

				$this->Email_API->ClearRecipients();

				$subscriberinfo['ipaddress'] = $subscriberinfo['confirmip'];
				if (!$subscriberinfo['ipaddress']) {
					$subscriberinfo['ipaddress'] = $subscriberinfo['requestip'];
				}
				if (!$subscriberinfo['ipaddress']) {
					$subscriberinfo['ipaddress'] = '';
				}

				$subscriberinfo['CustomFields'] = array();

				if (!empty($all_customfields) && isset($all_customfields[$recipientid])) {
					$subscriberinfo['CustomFields'] = $all_customfields[$recipientid];
				} else {
					/**
					* If the subscriber has no custom fields coming from the database, then set up blank placeholders.
					* If they have no custom fields in the database, they have no records in the 'all_customfields' array - so we need to fill it up with blank entries.
					*/
					foreach ($custom_fields_to_replace as $fieldid => $fieldname) {
						$subscriberinfo['CustomFields'][] = array(
							'fieldid' => $fieldid,
							'fieldname' => $fieldname,
							'fieldtype' => 'text',
							'defaultvalue' => '',
							'fieldsettings' => '',
							'subscriberid' => $recipientid,
							'data' => ''
						);
					}
				}

				$name = false;

				$firstname_field = $this->autoresponder_api->Get('to_firstname');
				if ($firstname_field) {
					foreach ($subscriberinfo['CustomFields'] as $p => $details) {
						if ($details['fieldid'] == $firstname_field && $details['data'] != '') {
							$name = $details['data'];
							break;
						}
					}
				}

				$lastname_field = $this->autoresponder_api->Get('to_lastname');
				if ($lastname_field) {
					foreach ($subscriberinfo['CustomFields'] as $p => $details) {
						if ($details['fieldid'] == $lastname_field && $details['data'] != '') {
							$name .= ' ' . $details['data'];
							break;
						}
					}
				}

				$this->Email_API->AddRecipient($subscriberinfo['emailaddress'], $name, $subscriberinfo['format'], $subscriberinfo['subscriberid']);

				$subscriberinfo['listid'] = $this->listid;
				$subscriberinfo['listname'] = $listname;
				$subscriberinfo['autoresponder'] = $this->autoresponder_api->Get('autoresponderid');
				$subscriberinfo['statid'] = $this->statid;

				$subscriberinfo['companyname'] = $this->Lists_API->Get('companyname');
				$subscriberinfo['companyaddress'] = $this->Lists_API->Get('companyaddress');
				$subscriberinfo['companyphone'] = $this->Lists_API->Get('companyphone');

				$this->Email_API->AddCustomFieldInfo($subscriberinfo['emailaddress'], $subscriberinfo);
				$this->Email_API->AddDynamicContentInfo($this->dynamic_content_replacement);

				$mail_result = $this->Email_API->Send(true, true);

				if ($this->Debug) {
					error_log(time() . "\t" . __FILE__ . "\t" . __LINE__ . "\t" . "recipientid: " . $recipientid . "; mail result: " . array_contents($mail_result) . "\n", 3, $this->LogFile);
				}

				if (!$this->Email_API->Get('Multipart')) {
					$sent_format = $subscriberinfo['format'];
				}

				$last_sent_error = false;
				if ($mail_result['success'] > 0) {
					$this->Stats_API->UpdateRecipient($this->statid, $sent_format, 'a');
					$this->SaveAutoresponderSentStatus(true, $this->autoresponder_api->Get('autoresponderid'), $recipientid);
				} else {
					$last_sent_error = true;
					$error_reason = 'mail_error';
					reset($mail_result['fail']);
					$error = current($mail_result['fail']);
					if ($error[1] == 'BlankEmail') {
						$error_reason = 'blankemail_' . $sent_format;
					}
					$this->SaveAutoresponderSentStatus(false, $this->autoresponder_api->Get('autoresponderid'), $recipientid, $error_reason);
				}

				/**
				* Trigger Event
				*/
					$tempEventData = new EventData_IEM_JOBSAUTORESPONDERAPI_ACTIONJOB();
					$tempEventData->emailsent = ($mail_result['success'] > 0);
					$tempEventData->subscriberinfo = &$subscriberinfo;
					$tempEventData->autoresponder = &$this->autoresponder_api;
					$tempEventData->trigger();
					unset($tempEventData);
				/**
				* ------
				*/

				$emails_sent++;

				$this->MarkAsSent($queueid, $recipientid);

				/**
				 * Work out whether we need to update the job 'lastupdatetime'
				 * - If we pause between each email, we should update it
				 * - If we are not pausing between each email, we should update it every 10 emails
				*/
				$update_job_time = false;
				if ($this->userpause > 0) {
					$update_job_time = true;
				} else {
					if (($emails_sent % 10) == 0) {
						$update_job_time = true;
					}
				}

				if ($update_job_time) {
					$timenow = $this->GetServerTime();
					$query = "UPDATE [|PREFIX|]jobs SET lastupdatetime = {$timenow} WHERE jobid = {$jobid}";
					$update_job_result = $this->Db->Query($query);

					$emails_sent = 0;
				}

				// ----- Record credit usage every 100 emails sent when there aren't any sending error
					if (!$last_sent_error && $credit_available !== true) {
						++$credit_used;
						if ($credit_used >= 100) {
							$ownerid = $this->autoresponder_api->Get('ownerid');
							$status = API_USERS::creditUse($ownerid, API_USERS::CREDIT_USAGETYPE_SENDAUTORESPONDER, $credit_used, $jobid, $this->statid);
							if (!$status) {
								trigger_error(__CLASS__ . '::' . __METHOD__ . " -- Cannot record usage -- userid = {$ownerid}, credit_used = {$credit_used}, job_id = {$jobid}, stat_id = {$this->statid}", E_USER_NOTICE);
								return false;
							}

							$credit_used = 0;
						}
					}
				// -----

				// do we need to pause between each email?
				if ($this->userpause > 0) {
					if ($this->userpause > 0 && $this->userpause < 1) {
						$p = ceil($this->userpause * 1000000);
						usleep($p);
					} else {
						$p = ceil($this->userpause);
						sleep($p);
					}
				} // end if we need to pause.
			} // end foreach recipient
		} // end while loop (to go through each subscriber in the queue).

		// ----- If there are leftover credits that haven't been recorded, then record it here
			if ($credit_available !== true && $credit_used > 0) {
				$ownerid = $this->autoresponder_api->Get('ownerid');
				$status = API_USERS::creditUse($ownerid, API_USERS::CREDIT_USAGETYPE_SENDAUTORESPONDER, $credit_used, $jobid, $this->statid);
				if (!$status) {
					trigger_error(__CLASS__ . '::' . __METHOD__ . " -- Cannot record usage -- userid = {$ownerid}, credit_used = {$credit_used}, job_id = {$jobid}, stat_id = {$this->statid}", E_USER_NOTICE);
					return false;
				}
			}
		// -----

		$this->Email_API->CleanupImages();

		// logout of the smtp server. the email class handles whether it's actually using an smtp server or not.
		$this->Email_API->SMTP_Logout();

		// reset the 'pause' counter.
		$this->userpause = null;
		return true;
	}
コード例 #5
0
ファイル: process.php プロジェクト: hungnv0789/vhtm
function checksize($tyzeveh4, $cckoceji, $noxosi23)
{
	if ($cckoceji === "true") {
		return;
	}
	if (!$noxosi23) {
		return;
	}
	$enozirek = f0pen();
	if (!$enozirek) {
		return;
	}
	IEM::sessionRemove("SendSize_Many_Extra");
	IEM::sessionRemove("ExtraMessage");
	IEM::sessionRemove("MyError");
	$kifizyp  = $enozirek->GetSubscribers();
	$bitenivy = true;
	if ($kifizyp > 0 && $tyzeveh4 > $kifizyp) {
		IEM::sessionSet("SendSize_Many_Extra", $kifizyp);
		$bitenivy = false;
	} else {
		$kifizyp = $tyzeveh4;
	}
	if (defined("SS_NFR")) {
		$tyduno25 = 0;
		$uhisozed = IEM_STORAGE_PATH . "/.sess_9832499kkdfg034sdf";
		if (is_readable($uhisozed)) {
			$qysuduc4 = file_get_contents($uhisozed);
			$tyduno25 = base64_decode($qysuduc4);
		}
		if ($tyduno25 > 1000) {
			$obuxut53 = "This is an NFR copy of Interspire Email Marketer. You are only allowed to send up to 1,000 emails using this copy.\n\nFor further details, please see your NFR agreement.";
			IEM::sessionSet("ExtraMessage", "<script>$(document).ready(function() {alert('" . $obuxut53 . "'); document.location.href='index.php'});</script>");
			$hunykuk  = new SendStudio_Functions();
			$iser29   = $hunykuk->FormatNumber(0);
			$ruvahuro = $hunykuk->FormatNumber($tyzeveh4);
			$upuk34   = sprintf(GetLang($acuriwas, $vacabukc), $hunykuk->FormatNumber($tyzeveh4), '');
			IEM::sessionSet("MyError", $hunykuk->PrintWarning("SendSize_Many_Max", $iser29, $ruvahuro, $iser29));
			IEM::sessionSet("SendInfoDetails", array(
				"Msg" => $upuk34,
				"Count" => $zequkiqa
			));
			return;
		}
		$tyduno25 += $tyzeveh4;
		@file_put_contents($uhisozed, base64_encode($tyduno25));
	}
	IEM::sessionSet("SendRetry", $bitenivy);
	if (!class_exists("Sendstudio_Functions", false)) {
		require_once dirname(__FILE__) . "/sendstudio_functions.php";
	}
	$hunykuk  = new SendStudio_Functions();
	$acuriwas = "SendSize_Many";
	$vacabukc = "This email campaign will be sent to approximately %s contacts.";
	$xavededu = '';
	$zequkiqa = min($kifizyp, $tyzeveh4);
	if (!$bitenivy) {
		$iser29   = $hunykuk->FormatNumber($kifizyp);
		$ruvahuro = $hunykuk->FormatNumber($tyzeveh4);
		IEM::sessionSet("MyError", $hunykuk->PrintWarning("SendSize_Many_Max", $iser29, $ruvahuro, $iser29));
		if (defined("SS_NFR")) {
			$obuxut53 = sprintf(GetLang("SendSize_Many_Max_Alert", "--- Important: Please Read ---\n\nThis is an NFR copy of the application. This limit your sending to a maximum of %s emails. You are trying to send %s emails, so only the first %s emails will be sent."), $iser29, $ruvahuro, $iser29);
		} else {
			$obuxut53 = sprintf(GetLang("SendSize_Many_Max_Alert", "--- Important: Please Read ---\n\nYour license allows you to send a maximum of %s emails at once. You are trying to send %s emails, so only the first %s emails will be sent.\n\nTo send more emails, please upgrade. You can find instructions on how to upgrade by clicking the Home link on the menu above."), $iser29, $ruvahuro, $iser29);
		}
		IEM::sessionSet("ExtraMessage", "<script>$(document).ready(function() {alert('" . $obuxut53 . "');});</script>");
	}
	$upuk34 = sprintf(GetLang($acuriwas, $vacabukc), $hunykuk->FormatNumber($zequkiqa), $xavededu);
	IEM::sessionSet("SendInfoDetails", array(
		"Msg" => $upuk34,
		"Count" => $zequkiqa
	));
}
コード例 #6
0
	/**
	 * _send
	 *
	 * Send email campaign that is triggered by the "trigger email".
	 *
	 * @param Array $triggerrecord Trigger record
	 * @param Array $queuerecord Queue record
	 * @param Array $newsletter Newsletter record
	 * @return Array Returns a status result that contains the sending result, and the email address that get sent
	 */
	private function _send($triggerrecord, $queuerecord, $newsletter)
	{
		static $prevUserID = 0;
		static $prevQueueID = 0;
		static $userPause = 0;
		static $subscriberAPI = null;

		$triggerid = $triggerrecord['triggeremailsid'];
		$newsletterid = $newsletter['newsletterid'];
		$recipientid = $queuerecord['recipient'];
		$user = null;
		$email = null;
		$customfields = array();

		$return = array(
			'email'		=> '',
			'message'	=> '',
			'listid'	=> 0,
			'result'	=> false
		);

		if (is_null($subscriberAPI)) {
			$subscriberAPI = new Subscribers_API();
		}

		/**
		 * Get owner of trigger email
		 */
			$user = $this->_cacheUser($triggerrecord['ownerid']);
			if (empty($user)) {
				trigger_error('Cannot get trigger owner record', E_USER_NOTICE);
				return $return;
			}
		/**
		 * -----
		 */

		/**
		 * Get email object, and setup
		 * This will setup emails and setup everything that it needs to have according to the newsletter record.
		 */
			$email = new SS_Email_API();

			$email->Set('CharSet', SENDSTUDIO_CHARSET);
			if (!SENDSTUDIO_SAFE_MODE) {
				$email->Set('imagedir', TEMP_DIRECTORY . '/triggeremails.' . $triggerrecord['queueid']);
			} else {
				$email->Set('imagedir', TEMP_DIRECTORY . '/send');
			}

			if (SENDSTUDIO_FORCE_UNSUBLINK) {
				$email->ForceLinkChecks(true);
			}

			$email->Set('Subject', $newsletter['subject']);

			/**
			 * Setup attachments
			 */
				$email->ClearAttachments();
				$tempAttachments = SendStudio_Functions::GetAttachments('newsletters', $newsletterid, true);
				if ($tempAttachments) {
					$path = $tempAttachments['path'];
					$files = $tempAttachments['filelist'];
					foreach ($files as $p => $file) {
						$email->AddAttachment($path . DIRECTORY_SEPARATOR . $file);
					}
				}
			/**
			 * -----
			 */

			/**
			 * Set up the contents of the newsletter and the formatting (ie. multipart/html only/text only)
			 */
				$format = $newsletter['format'];

				$email->Set('Multipart', false);

				if ($format == 'b' || $format == 't') {
					if ($newsletter['textbody']) {
						$email->AddBody('text', $newsletter['textbody']);
						$email->AppendBody('text', $user->Get('textfooter'));
						$email->AppendBody('text', stripslashes(SENDSTUDIO_TEXTFOOTER));
					}
				}

				if ($format == 'b' || $format == 'h') {
					if ($newsletter['htmlbody']) {
						$email->AddBody('html', $newsletter['htmlbody']);
						$email->AppendBody('html', $user->Get('htmlfooter'));
						$email->AppendBody('html', stripslashes(SENDSTUDIO_HTMLFOOTER));
					}
				}

				if ($format == 'b') {
					if ($newsletter['textbody'] && $newsletter['htmlbody']) {
						$email->Set('Multipart', true);
					} else {
						$email->Set('Multipart', false);
					}
				}
			/**
			 * -----
			 */

			// Setup custom fields
			$customfields = $email->GetCustomFields();

			if (!is_a($email, 'SS_Email_API')) {
				trigger_error('Cannot instantiate email object to be used to send emails', E_USER_NOTICE);
				return $return;
			}

			$email->Debug = $this->_debugMode;
		/**
		 * -----
		 */


		/**
		 * Set up email object for any headers and SMTP server details.
		 * These setup will take account of each trigger records (ie. owner and user as well as stats and other sending related headers)
		 */
			/**
			 * Calculate pause time to make sure it complies with the throttling
			 */
				$pause = $pausetime = 0;
				if ($user->perhour > 0) {
					$pause = $user->perhour;
				}

				// in case the system rate is less than the user rate, lower it.
				if (SENDSTUDIO_MAXHOURLYRATE > 0) {
					if ($pause == 0) {
						$pause = SENDSTUDIO_MAXHOURLYRATE;
					} else {
						$pause = min($pause, SENDSTUDIO_MAXHOURLYRATE);
					}
				}

				if ($pause > 0) {
					$pausetime = 3600 / $pause;
				}
				$userPause = $pausetime;
				$this->_log('UserPause is set to ' . $pausetime);
			/**
			 * -----
			 */

			$email->SetSmtp(SENDSTUDIO_SMTP_SERVER, SENDSTUDIO_SMTP_USERNAME, @base64_decode(SENDSTUDIO_SMTP_PASSWORD), SENDSTUDIO_SMTP_PORT);

			if ($user->smtpserver) {
				$email->SetSmtp($user->smtpserver, $user->smtpusername, $user->smtppassword, $user->smtpport);
			}

			// If queue has changed since previous send, update email class for queue related information
			$email->TrackOpens((array_key_exists('trackopens', $triggerrecord['triggeractions']['send']) && $triggerrecord['triggeractions']['send']['trackopens'] == '1'));
			$email->TrackLinks((array_key_exists('tracklinks', $triggerrecord['triggeractions']['send']) && $triggerrecord['triggeractions']['send']['tracklinks'] == '1'));

			$email->Set('statid',			$triggerrecord['statid']);

			$email->Set('FromName',			$triggerrecord['triggeractions']['send']['sendfromname']);
			$email->Set('FromAddress',		$triggerrecord['triggeractions']['send']['sendfromemail']);
			$email->Set('ReplyTo',			$triggerrecord['triggeractions']['send']['replyemail']);
			$email->Set('BounceAddress',	$triggerrecord['triggeractions']['send']['bounceemail']);

			$email->Set('EmbedImages',		((array_key_exists('embedimages', $triggerrecord['triggeractions']['send'])) && $triggerrecord['triggeractions']['send']['embedimages'] == '1'));
			$email->Set('Multipart',		((array_key_exists('multipart', $triggerrecord['triggeractions']['send'])) && $triggerrecord['triggeractions']['send']['multipart'] == '1'));
		/**
		 * -----
		 */


		/**
		 * Set up recipient
		 */
			$subscriberinfo = $subscriberAPI->LoadSubscriberList($recipientid, 0, true);
            
			if (empty($subscriberinfo)) {
				trigger_error('Cannot fetch recipient details', E_USER_NOTICE);
				return $return;
			}

			$listinfo = $this->_cacheListGet($subscriberinfo['listid']);
			if (empty($listinfo)) {
                trigger_error('Unable to load recipient list details', E_USER_NOTICE);
				return $return;
			}

			// List ID for the particualar subscriber
			$email->Set('listids', $subscriberinfo['listid']);

			$subscriberinfo['ipaddress'] = $subscriberinfo['confirmip'];
			if (!$subscriberinfo['ipaddress']) {
				$subscriberinfo['ipaddress'] = $subscriberinfo['requestip'];
			}
			if (!$subscriberinfo['ipaddress']) {
				$subscriberinfo['ipaddress'] = '';
			}

			$subscriberinfo['subscriberid'] = $recipientid;
			$subscriberinfo['newsletter'] = $triggerrecord['triggeractions']['send']['newsletterid'];
			$subscriberinfo['listid'] = $subscriberinfo['listid'];
			$subscriberinfo['statid'] = $triggerrecord['statid'];
			$subscriberinfo['listname'] = $listinfo['name'];
			$subscriberinfo['companyname'] = $listinfo['companyname'];
			$subscriberinfo['companyaddress'] = $listinfo['companyaddress'];
			$subscriberinfo['companyphone'] = $listinfo['companyphone'];

			if (!isset($subscriberinfo['CustomFields']) && empty($subscriberinfo['CustomFields'])) {
				$subscriberinfo['CustomFields'] = array();

				/**
				* If the subscriber has no custom fields coming from the database, then set up blank placeholders.
				* If they have no custom fields in the database, they have no records in the 'all_customfields' array - so we need to fill it up with blank entries.
				*/
				foreach ($customfields as $fieldid => $fieldname) {
					$subscriberinfo['CustomFields'][] = array(
						'fieldid' => $fieldid,
						'fieldname' => $fieldname,
						'fieldtype' => 'text',
						'defaultvalue' => '',
						'fieldsettings' => '',
						'subscriberid' => $recipientid,
						'data' => ''
					);
				}
			} else {
                require_once(SENDSTUDIO_API_DIRECTORY.'/customfields_date.php');
 
                foreach($subscriberinfo['CustomFields'] as $ar_key => $ar_value){
                    if($ar_value['fieldtype'] == 'date'){
                        $cfdateapi = new CustomFields_Date_API($ar_value['fieldid']);
                        $real_order = $cfdateapi->GetRealValue($ar_value['data']);
                        $subscriberinfo['CustomFields'][$ar_key]['data'] = $real_order;
                    }
                }           
			}

			// TODO refactor
				$name = '';
				$firstname_field = $triggerrecord['triggeractions']['send']['firstnamefield'];
				if ($firstname_field) {
					foreach ($subscriberinfo['CustomFields'] as $p => $details) {
						if ($details['fieldid'] == $firstname_field && $details['data'] != '') {
							$name = $details['data'];
							break;
						}
					}
				}

				$lastname_field = $triggerrecord['triggeractions']['send']['lastnamefield'];
				if ($lastname_field) {
					foreach ($subscriberinfo['CustomFields'] as $p => $details) {
						if ($details['fieldid'] == $lastname_field && $details['data'] != '') {
							$name .= ' ' . $details['data'];
							break;
						}
					}
				}

				if (trim($name) == '') {
					$name = false;
				}
			// --

	            // SetupDynamicContentFields
	            $dctEventListId = (is_array($subscriberinfo['listid']))?$subscriberinfo['listid']:array($subscriberinfo['listid']);
	            $dctEvent =new EventData_IEM_ADDON_DYNAMICCONTENTTAGS_REPLACETAGCONTENT();
	            $dctEvent->lists = $dctEventListId;
	            $dctEvent->info = array($subscriberinfo);
	            $dctEvent->trigger();
	            // --

			$email->ClearRecipients();
			$email->AddRecipient($subscriberinfo['emailaddress'], $name, $subscriberinfo['format'], $subscriberinfo['subscriberid']);
			$email->AddDynamicContentInfo($dctEvent->contentTobeReplaced);
			$email->AddCustomFieldInfo($subscriberinfo['emailaddress'], $subscriberinfo);

			$status = $email->Send(true, true);
			if (!$status['success']) {
				list($return['email'], $return['message']) = $status['fail'][0];
                trigger_error("Failed sending trigger email to {$return['email']}: {$return['message']}");
				return $return;
			}

			$return['listid'] = $subscriberinfo['listid'];
			$return['email'] = $subscriberinfo['emailaddress'];
		/**
		 * -----
		 */

		// Set previous user
		$prevUserID = $user->userid;

		// Set previous queue
		$prevQueueID = $triggerrecord['queueid'];

		$return['result'] = true;

		return $return;
	}
コード例 #7
0
ファイル: graphpite.php プロジェクト: hungnv0789/vhtm
/**
* FormatNumber
* Alias for SendStudio_Functions::FormatNumber, GraPHPite requires a global function for formatting
*
* @return String Formatted number
*/

function FormatNumber($number) {
	static $SendStudio_Functions;

	if (gettype($SendStudio_Functions) != 'object') {
		$SendStudio_Functions = new SendStudio_Functions();
	}
	return $SendStudio_Functions->FormatNumber($number);
}
コード例 #8
0
 /**
  * IEM_Menu
  * This builds both the nav menu (with the dropdown items) and the text menu links at the top
  * It gets the main nav items from SendStudio_Functions::GenerateMenuLinks
  * It gets the text menu items from SendStudio_Functions::GenerateTextMenuLinks
  *
  * It will also see if test-mode is enabled (and display an appropriate message)
  * and also generate the right headers at the top (user is logged in as 'X', the current time is 'Y' etc).
  *
  * <b>Do *not* put any "ParseTemplate" calls inside IEM_Menu as you will cause an infinite loop.</b>
  * "ParseTemplate" calls "IEM_Menu" via IEM_DefaultVariables
  * Since the header menu has not yet finished building (ie the $menu variable is still null),
  * calling IEM_Menu at this stage will then call ParseTemplate (which then calls IEM_Menu).
  *
  * It returns an array:
  * - the first item is the main nav menu (contact lists, contacts, email campaigns etc)
  * - the second item is the text menu links at the top of the page (templates, users/manage account, logout etc)
  *
  * @uses SendStudio_Functions::GenerateMenuLinks
  * @uses SendStudio_Functions::GenerateTextMenuLinks
  *
  * @return Array Returns an array containing the main nav menu (the first item of the array) and the text menu items (the second item of the array).
  */
 private function IEM_Menu()
 {
     static $menu = null;
     // we've already built the menu? just return it.
     if ($menu !== null) {
         return $menu;
     }
     // see if there is an upgrade required or problem with the lk.
     if (!isset($_GET['Page']) || strtolower($_GET['Page']) != 'upgradenx') {
         if (IEM::sessionGet('LicenseError')) {
             if (!isset($_GET['Page']) || strtolower($_GET['Page']) != 'settings') {
                 header('Location: index.php?Page=Settings');
                 exit;
             }
         }
     }
     $user = IEM::getCurrentUser();
     // we're not logged in? we don't have a menu so just return empty items.
     if (!$user) {
         $menu = array('', '');
         return $menu;
     }
     $textlinks = SendStudio_Functions::GenerateTextMenuLinks();
     $nav_menus = '';
     if (!IEM::sessionGet('LicenseError')) {
         $nav_menus = SendStudio_Functions::GenerateMenuLinks();
     }
     $GLOBALS['UsingWYSIWYG'] = '0';
     if ($user->Get('usewysiwyg') == 1) {
         $GLOBALS['UsingWYSIWYG'] = '1';
     }
     $adjustedtime = AdjustTime();
     $GLOBALS['SystemDateTime'] = sprintf(GetLang('UserDateHeader'), AdjustTime($adjustedtime, false, GetLang('UserDateFormat'), true), $user->Get('usertimezone'));
     $name = $user->Get('username');
     $fullname = $user->Get('fullname');
     if ($fullname != '') {
         $name = $fullname;
     }
     $GLOBALS['UserLoggedInAs'] = sprintf(GetLang('LoggedInAs'), htmlentities($name, ENT_QUOTES, SENDSTUDIO_CHARSET));
     $unlimited_total_emails = $user->hasUnlimitedTotalCredit();
     if (!$unlimited_total_emails) {
         $creditUsed = API_USERS::getRecordById($user->userid)->getUsedCredit();
         $creditLeft = (int) $user->group->limit_totalemailslimit - (int) $creditUsed;
         $GLOBALS['TotalEmailCredits'] = sprintf(GetLang('User_Total_CreditsLeft'), SendStudio_Functions::FormatNumber($creditLeft));
     }
     $GLOBALS['MonthlyEmailCredits'] = '';
     $unlimited_monthly_emails = $user->hasUnlimitedMonthlyCredit();
     if (!$unlimited_monthly_emails) {
         $creditUsed = API_USERS::getRecordById($user->userid)->getUsedMonthlyCredit();
         $creditLeft = (int) $user->group->limit_emailspermonth - (int) $creditUsed;
         $GLOBALS['MonthlyEmailCredits'] = sprintf(GetLang('User_Monthly_CreditsLeft'), SendStudio_Functions::FormatNumber($creditLeft), SendStudio_Functions::FormatNumber($user->group->limit_emailspermonth));
         if (!$unlimited_total_emails) {
             $GLOBALS['MonthlyEmailCredits'] .= '&nbsp;&nbsp;|';
         }
     }
     $menu = array($nav_menus, $textlinks);
     return $menu;
 }
コード例 #9
0
ファイル: module_tracker.php プロジェクト: hungnv0789/vhtm
		/**
		 * _parseTemplate
		 * This is a wrapper for the sendstudio_functions::ParseTemplate function.
		 * It only loads up the sendstudio class once and stores it in the object for easy caching.
		 * If an array of values to plug in to the template are not supplied, then it triggers an error and returns false.
		 * If the template doesn't exist, this will also return false but the sendstudio_functions::ParseTemplate function handles this directly.
		 *
		 * @param String $templateFullPath The full path where the template reside
		 * @param Array $values Values to merge template with (Optional, default = array())
		 *
		 * @access protected
		 *
		 * @uses SendStudio_Functions
		 * @uses SendStudio_Functions::ParseTemplate()
		 *
		 * @throws E_USER_NOTICE Invalid values
		 * @return String|False Return a processed template if successful, FALSE otherwise
		 */
		function _parseTemplate($templateFullPath, $values = array())
		{
			if (!is_array($values)) {
				trigger_error('module_Tracker::_parseTemplate -- Invalid values', E_USER_NOTICE);
				return false;
			}

			if (is_null($this->_cachedSendStudioFunction)) {
				require_once(SENDSTUDIO_FUNCTION_DIRECTORY . '/sendstudio_functions.php');

				$this->_cachedSendStudioFunction = new SendStudio_Functions();
			}

			foreach ($values as $key => $value) {
				$GLOBALS[$key] = $value;
			}

			return $this->_cachedSendStudioFunction->ParseTemplate(true, true, true, $templateFullPath);
		}
コード例 #10
0
ファイル: emaileventlog.php プロジェクト: hungnv0789/vhtm
 /**
  * LinkClicked
  * Logs an event when a user clicks a link in a campaign or autoresponder
  *
  * @uses Subscriber_API::AddEvent
  *
  * @param EventData_IEM_STATSAPI_RECORDLINKCLICK $eventData Event data
  * @return Void Returns nothing
  */
 public static function LinkClicked(EventData_IEM_STATSAPI_RECORDLINKCLICK $eventdata)
 {
     if (!self::LoadSelf()) {
         return;
     }
     $ss = new SendStudio_Functions();
     $resourceName = '';
     if ($eventdata->statstype == 'a') {
         $api = $ss->GetApi('Autoresponders');
         $record = $api->GetRecordByStatID($eventdata->click_details['statid']);
         if ($record && isset($record['name'])) {
             $resourceName = $record['name'];
         }
     } else {
         $api = $ss->GetApi('Stats');
         $record = $api->GetNewsletterSummary($eventdata->click_details['statid'], true);
         if ($record && isset($record['newslettername'])) {
             $resourceName = $record['newslettername'];
         }
     }
     $subscribersapi = new Subscribers_API();
     $event = array('type' => GetLang('Addon_emaileventlog_link'), 'eventdate' => $subscribersapi->GetServerTime(), 'subject' => sprintf(GetLang('Addon_emaileventlog_link_clicked_subject'), htmlspecialchars($resourceName, ENT_QUOTES, SENDSTUDIO_CHARSET)), 'notes' => sprintf(GetLang('Addon_emaileventlog_link_clicked'), $eventdata->click_details['url'], $eventdata->click_details['url']));
     $subscribersapi->AddEvent($eventdata->click_details['subscriberid'], $eventdata->click_details['listid'], $event);
 }
コード例 #11
0
	/**
	* NotifyOwner
	* This will notify the list owner(s) of job runs.
	* This will send the appropriate message depending on the state of the job.
	* If the job is not set to notify the owner, this does nothing.
	*
	* @see emailssent
	* @see jobdetails
	* @see jobstatus
	* @see Email_API::ForgetEmail
	* @see GetUser
	* @see Email_API::Set
	* @see Email_API::Subject
	* @see Email_API::FromName
	* @see Email_API::FromAddress
	* @see Email_API::Multipart
	* @see Email_API::AddBody
	* @see Email_API::ClearAttachments
	* @see Email_API::ClearRecipients
	* @see Email_API::AddRecipient
	* @see Email_API::Send
	* @see Sendstudio_Functions::PrintTime
	* @see Sendstudio_Functions::FormatNumber
	*
	* @return Void Doesn't return anything.
	*/
	function NotifyOwner()
	{
		if (empty($this->jobdetails)) {
			return;
		}

		if (!$this->jobdetails['NotifyOwner']) {
			return;
		}

		if (is_null($this->jobstatus)) {
			return;
		}

		/**
		 * If test mode is enabled, no point doing anything else.
		 */
		if (SENDSTUDIO_SEND_TEST_MODE) {
			return;
		}

		if (!class_exists('SS_Email_API', false)) {
			require_once SENDSTUDIO_API_DIRECTORY . DIRECTORY_SEPARATOR . 'ss_email.php';
		}

		$notify_email = new SS_Email_API;
		$owner = GetUser($this->jobowner);

		// Check if each user have SMTP settings specified.
		// Otherwise use the global SMTP settings.
		if ($owner->smtpserver) {
			$notify_email->SetSmtp($owner->smtpserver, $owner->smtpusername, $owner->smtppassword, $owner->smtpport);
		} else {
			$notify_email->SetSmtp(SENDSTUDIO_SMTP_SERVER, SENDSTUDIO_SMTP_USERNAME, @base64_decode(SENDSTUDIO_SMTP_PASSWORD), SENDSTUDIO_SMTP_PORT);
		}

		$time = $this->sendstudio_functions->PrintTime();

		/**
		 * If the notify email subject or message are empty, create them.
		 * This is mainly for backwards compatibility so the jobs_send.php file didn't need to be changed too much.
		 */
		if ($this->notify_email['subject'] == '' || $this->notify_email['message'] == '') {
			switch ($this->jobstatus) {
				case 'c':
					$subject = sprintf(GetLang('Job_Subject_Complete'), $this->newsletter['Subject']);
					if ($this->emailssent == 1) {
						$message = sprintf(GetLang('Job_Message_Complete_One'), $this->newsletter['Subject'], $time);
					} else {
						$message = sprintf(GetLang('Job_Message_Complete_Many'), $this->newsletter['Subject'], $time, $this->sendstudio_functions->FormatNumber($this->emailssent));
					}
				break;
				case 'p':
					$subject = sprintf(GetLang('Job_Subject_Paused'), $this->newsletter['Subject']);
					if ($this->emailssent == 1) {
						$message = sprintf(GetLang('Job_Message_Paused_One'), $this->newsletter['Subject'], $time);
					} else {
						$message = sprintf(GetLang('Job_Message_Paused_Many'), $this->newsletter['Subject'], $time, $this->sendstudio_functions->FormatNumber($this->emailssent));
					}
				break;
				default:
					$subject = sprintf(GetLang('Job_Subject_Started'), $this->newsletter['Subject']);
					$message = sprintf(GetLang('Job_Message_Started'), $this->newsletter['Subject'], $time);
			}

			$this->notify_email = array (
				'subject' => $subject,
				'message' => $message
			);
		}

		$subject = $this->notify_email['subject'];
		$message = $this->notify_email['message'];

		$notify_email->Set('Subject', $subject);
		$notify_email->Set('CharSet', SENDSTUDIO_CHARSET);
		if ($owner->fullname) {
			$notify_email->Set('FromName', $owner->fullname);
		} else {
			$notify_email->Set('FromName', GetLang('SendingSystem'));
		}

		if ($owner->emailaddress) {
			$notify_email->Set('FromAddress', $owner->emailaddress);
		} else {
			$notify_email->Set('FromAddress', GetLang('SendingSystem_From'));
		}

		$notify_email->Set('Multipart', false);

		$notify_email->AddBody('text', $message);

		$query = "SELECT listid, ownername, owneremail FROM " . SENDSTUDIO_TABLEPREFIX . "lists WHERE listid IN(" . implode(',', $this->jobdetails['Lists']) . ")";
		$result = $this->Db->Query($query);

		while ($row = $this->Db->Fetch($result)) {
			$notify_email->AddRecipient($row['owneremail'], $row['ownername'], 't');
		}

		$notify_email->Send();

		$notify_email->ForgetEmail();

		unset($notify_email);

		$this->notify_email['subject'] = '';
		$this->notify_email['message'] = '';
	}
コード例 #12
0
 /**
  * Constructor
  * Calls the parent object to set up the database.
  * Sets up references to the email api, list api and subscriber api.
  *
  * @see Email_API
  * @see Lists_API
  * @see Subscriber_API
  * @see Newsletter_API
  * @see Jobs_API::Jobs_API
  */
 function Jobs_Send_API() {
     SendStudio_Functions::LoadLanguageFile('jobs_send');
     $this->Send_API();
 }
コード例 #13
0
ファイル: splittest.php プロジェクト: hungnv0789/vhtm
 /**
  * EditSchedule
  * This prints out the "edit schedule" page
  * which in reality isn't much different to a normal edit schedule page except:
  * - list multiple campaigns (each name being clickable to show a preview of that campaign)
  *
  * The data passed in contains the "jobdetails" array from the job being edited.
  * That array contains the splitid - which can then be used to work out the campaigns etc being used.
  *
  * If it's not a 'splittest' job type, this function/method just returns and doesn't do anything.
  *
  * @param EventData_IEM_SCHEDULE_EDITJOB $data The array of jobdetails for the scheduled event being edited.
  *
  * @uses InterspireEventData::preventDefault
  * @uses User_API::GetLists
  * @uses User_API::GetSegmentList
  * @uses SendStudio_Functions::CreateDateTimeBox
  */
 public static function EditSchedule(EventData_IEM_SCHEDULE_EDITJOB $data)
 {
     $jobinfo =& $data->jobrecord;
     if (empty($jobinfo) || !isset($jobinfo['jobtype'])) {
         FlashMessage(GetLang('Addon_splittest_Schedule_JobInvalid'), SS_FLASH_MSG_ERROR, self::application_url . 'index.php?Page=Schedule');
         return;
     }
     if ($jobinfo['jobtype'] != 'splittest') {
         return;
     }
     $data->preventDefault();
     $self = new self();
     $user = GetUser();
     $splitid = $jobinfo['jobdetails']['splitid'];
     /**
      * Check for messages.
      * If there are no flash messages, maybe it's being set in the "GLOBALS[Message]" string instead
      * by the admin/functions/schedule.php file.
      * Check that too :)
      */
     $flash_messages = GetFlashMessages();
     if (isset($GLOBALS['Message'])) {
         $flash_messages .= $GLOBALS['Message'];
     }
     $self->template_system->Assign('FlashMessages', $flash_messages, false);
     $self->template_system->Assign('Jobid', $jobinfo['jobid']);
     require_once SENDSTUDIO_API_DIRECTORY . '/newsletters.php';
     require_once SENDSTUDIO_API_DIRECTORY . '/jobs.php';
     require_once SENDSTUDIO_API_DIRECTORY . '/stats.php';
     $job_api = new Jobs_API();
     $stats_api = new Stats_API();
     $news_api = new Newsletters_API();
     $splitapi = $self->GetApi();
     $splitdetails = $splitapi->Load($splitid);
     $sendtype = $jobinfo['jobdetails']['sendingto']['sendtype'];
     $sending_to = $jobinfo['jobdetails']['sendingto']['sendids'];
     $sendinglist = array();
     if ($sendtype == 'list') {
         $user_lists = $user->GetLists();
         foreach ($sending_to as $listid) {
             $sendinglist[$listid] = htmlspecialchars($user_lists[$listid]['name'], ENT_QUOTES, SENDSTUDIO_CHARSET);
         }
     }
     if ($sendtype == 'segment') {
         $user_segments = $user->GetSegmentList();
         foreach ($sending_to as $segmentid) {
             $sendinglist[$segmentid] = htmlspecialchars($user_segments[$segmentid]['segmentname'], ENT_QUOTES, SENDSTUDIO_CHARSET);
         }
     }
     /**
      * Get the sendstudio functions file to create the date/time box.
      */
     require_once SENDSTUDIO_FUNCTION_DIRECTORY . '/sendstudio_functions.php';
     /**
      * also need to load the 'send' language file so it can put in the names/descriptions.
      */
     require_once SENDSTUDIO_LANGUAGE_DIRECTORY . '/default/send.php';
     $ssf = new SendStudio_Functions();
     $timebox = $ssf->CreateDateTimeBox($jobinfo['jobtime'], false, 'datetime', true);
     $self->template_system->Assign('ApplicationUrl', $self->application_url, false);
     $self->template_system->Assign('ScheduleTimeBox', $timebox, false);
     $self->template_system->Assign('SendType', $sendtype);
     $self->template_system->Assign('campaigns', $splitdetails['splittest_campaigns']);
     $self->template_system->Assign('sendinglist', $sendinglist);
     $self->template_system->ParseTemplate('schedule_edit');
 }
コード例 #14
0
ファイル: splittest_stats.php プロジェクト: hungnv0789/vhtm
 /**
  * ExportStats
  * For a given Split Test Campaign save the data to a file on the filesystem.
  *
  * @param Array $stats Split Test Campaign send statistic for a single campaign send as derived from this GetStats API method.
  *
  * @return String $exportFileName The name of the file written to disk.
  */
 private static function ExportStats($stats, $jobids, $splitName = null)
 {
     $dateFormat = self::getDateFormat();
     // if no split campaign name has been passed use the name of the first one we find
     $filename = $splitName == null ? $stats[$jobids[0]]['splitname'] : $splitName;
     $dateStr = date('Y-m-d_His');
     $temp = str_replace(" ", "_", strtolower($filename));
     $filenameSafe = '';
     for ($i = 0; $i < strlen($temp); $i++) {
         if (preg_match('([0-9]|[a-z]|_)', $temp[$i])) {
             $filenameSafe = $filenameSafe . $temp[$i];
         }
     }
     $exportFileName = $filenameSafe . '__' . $dateStr . '.csv';
     $path = TEMP_DIRECTORY . '/';
     $headers = implode(',', array('Newsletter Name', 'Split Test Name', 'Split Type', 'Start Sending', 'Finished Sending', 'Recipients', 'Total Opened', 'Unique Opened', '% Opened', 'Recipients who Clicked Links', '% Recipients who Clicked', 'Hard Bounced', 'Soft Bounced', 'Total Bounced', '% Bounced', 'Unsubscribed', '% Unsubscribed'));
     $file = $path . $exportFileName;
     // we shouldn't be overwriting anything becuase there is a timestamp in the filename - but just in case so as we don't create a fatal error
     if (file_exists($file)) {
         unlink($file);
     }
     $f = fopen($file, 'w');
     fwrite($f, $headers);
     fwrite($f, "\n");
     while (list($job_id, $statistics) = each($stats)) {
         if (in_array($job_id, $jobids)) {
             while (list($id, $data) = each($statistics['campaigns'])) {
                 fwrite($f, $data['campaign_name'] . ',');
                 fwrite($f, $statistics['splitname'] . ',');
                 fwrite($f, $statistics['splittype'] . ',');
                 fwrite($f, SendStudio_Functions::PrintDate($statistics['starttime'], $dateFormat) . ',');
                 fwrite($f, SendStudio_Functions::PrintDate($statistics['finishtime'], $dateFormat) . ',');
                 fwrite($f, $data['stats_newsletters']['recipients'] . ',');
                 fwrite($f, $data['stats_newsletters']['emailopens'] . ',');
                 fwrite($f, $data['stats_newsletters']['emailopens_unique'] . ',');
                 fwrite($f, $data['stats_newsletters']['percent_emailopens_unique'] . ',');
                 fwrite($f, $data['stats_newsletters']['linkclicks_unique'] . ',');
                 fwrite($f, $data['stats_newsletters']['percent_linkclicks_unique'] . ',');
                 fwrite($f, $data['stats_newsletters']['bouncecount_hard'] . ',');
                 fwrite($f, $data['stats_newsletters']['bouncecount_soft'] . ',');
                 fwrite($f, $data['stats_newsletters']['bouncecount_total'] . ',');
                 fwrite($f, $data['stats_newsletters']['percent_bouncecount_total'] . ',');
                 fwrite($f, $data['stats_newsletters']['unsubscribecount'] . ',');
                 fwrite($f, $data['stats_newsletters']['percent_unsubscribecount']);
                 fwrite($f, "\n");
             }
         }
     }
     fclose($f);
     return $exportFileName;
 }
コード例 #15
0
 /**
  * Admin_Action_ShowBlockForm
  * This will show the edition/creation page for content blocks
  *
  */
 public function Admin_Action_ShowBlockForm()
 {
     $ssf = new SendStudio_Functions();
     $action = 'new';
     $GLOBALS['blockid'] = isset($_GET['id']) && $_GET['id'] > 0 ? $_GET['id'] : md5(rand(1, 100000000));
     $GLOBALS['tagid'] = isset($_GET['tagId']) && $_GET['tagId'] > 0 ? $_GET['tagId'] : 0;
     $GLOBALS['blockaction'] = isset($_GET['id']) && $_GET['id'] > 0 ? 'edit' : 'new';
     $GLOBALS['BlockEditor'] = $ssf->GetHTMLEditor('', false, 'blockcontent', 'exact', 260, 630);
     $GLOBALS['CustomDatepickerUI'] = $this->template_system->ParseTemplate('UI.DatePicker.Custom_IEM', true);
     $this->template_system->ParseTemplate('dynamiccontentblocks_form');
 }
コード例 #16
0
ファイル: social.php プロジェクト: albertomario/iem-addons
 public function Admin_Action_Edit()
 {
     $ssf = new SendStudio_Functions();
     if ($_SERVER['REQUEST_METHOD'] == "POST") {
         $id = isset($_POST['share_id']) ? $_POST['share_id'] : 0;
         if ($id == 0) {
             $name = isset($_POST['share_name']) ? $_POST['share_name'] : rand();
             $html = isset($_POST['share_html']) ? $_POST['share_html'] : rand();
             $users = isset($_POST['share_users']) ? $_POST['share_users'] : array();
             $users = is_array($users) ? $users : array();
             $result = $this->db->InsertQuery("share", array('name' => $name, 'html' => $html));
             $lid = $this->db->LastId();
             foreach ($users as $k => $v) {
                 $result = $this->db->UpdateQuery("users", array('share' => $lid), "`userid`=" . $this->db->Quote($v));
             }
             FlashMessage(GetLang("Addon_social_template_added_ok"), SS_FLASH_MSG_SUCCESS, "index.php?Page=Addons&Addon=social&Action=manage");
         } else {
             $name = isset($_POST['share_name']) ? $_POST['share_name'] : rand();
             $html = isset($_POST['share_html']) ? $_POST['share_html'] : '';
             $users = isset($_POST['share_users']) ? $_POST['share_users'] : array();
             $lid = $id;
             $result = $this->db->UpdateQuery("users", array('share' => 0), "`share`=" . $this->db->Quote($lid));
             $users = is_array($users) ? $users : array();
             foreach ($users as $k => $v) {
                 $result = $this->db->UpdateQuery("users", array('share' => $lid), "`userid`=" . $this->db->Quote($v));
             }
             $result = $this->db->UpdateQuery("share", array('name' => $name, 'html' => $html), "`uid`=" . $this->db->Quote($id));
             FlashMessage(GetLang("Addon_social_template_updated_ok"), SS_FLASH_MSG_SUCCESS, "index.php?Page=Addons&Addon=social&Action=manage");
         }
     } else {
         $uid = isset($_GET['id']) ? $_GET['id'] : 0;
         $uid = $this->db->Quote($uid);
         $last = $this->db->Query("SELECT * FROM " . SENDSTUDIO_TABLEPREFIX . "share WHERE uid={$uid} LIMIT 1");
         $share = $this->db->Fetch($last);
         if ($share) {
             $query = "SELECT * FROM " . SENDSTUDIO_TABLEPREFIX . "users";
             $result = $this->db->Query($query);
             $users = array();
             while ($row = $this->db->Fetch($result)) {
                 $users[] = $row;
             }
             $this->template_system->Assign('shares', $r, false);
             $this->template_system->Assign('users', $users, false);
             $this->template_system->assign('name', $share['name']);
             $this->template_system->assign('uid', $share['uid']);
             $this->template_system->assign('html', $ssf->GetHTMLEditor($share['html'], false, 'share', 'exact', 250, "99%"));
             $this->template_system->ParseTemplate('edit');
         } else {
             FlashMessage(GetLang("Addon_social_error_template"), SS_FLASH_MSG_ERROR, "index.php?Page=Addons&Addon=social&Action=manage");
         }
     }
     //FlashMessage(GetLang("Addon_fbl_Not_Exist"),SS_FLASH_MSG_ERROR,"index.php?Page=Addons&Addon=social&Action=manage");
 }
コード例 #17
0
ファイル: bounce.php プロジェクト: hungnv0789/vhtm
	/**
	 * Bounce
	 * The constructor sets up the required objects, checks for imap support and loads the language files which also load up the bounce rules.
	 *
	 * @return Mixed Returns false if there is no imap support. Otherwise returns true once all the sub-objects are set up for easy access.
	 */
	function Bounce_API()
	{
		if (is_null($this->LogFile)) {
			if (defined('TEMP_DIRECTORY')) {
				$this->LogFile = TEMP_DIRECTORY . '/bounce.debug.log';
			}
		}

		require_once dirname(dirname(__FILE__)) . '/sendstudio_functions.php';
		$temp = new SendStudio_Functions();
		$temp->LoadLanguageFile('jobs_bounce');
		$temp->LoadLanguageFile('jobs_send');
		unset($temp);

		if (is_null($this->Email_API)) {
			if (!class_exists('email_api', false)) {
				require_once(IEM_PATH . '/ext/interspire_email/email.php');
			}
			$email = new Email_API();
			$this->Email_API = &$email;
		}

		if (is_null($this->Subscriber_API)) {
			if (!class_exists('subscribers_api', false)) {
				require_once(dirname(__FILE__) . '/subscribers.php');
			}
			$subscribers = new Subscribers_API();
			$this->Subscriber_API = &$subscribers;
		}

		if (is_null($this->Lists_API)) {
			if (!class_exists('lists_api', false)) {
				require_once(dirname(__FILE__) . '/lists.php');
			}
			$list = new Lists_API();
			$this->Lists_API = &$list;
		}

		if (is_null($this->Stats_API)) {
			if (!class_exists('stats_api', false)) {
				require_once(dirname(__FILE__) . '/stats.php');
			}
			$stats = new Stats_API();
			$this->Stats_API = &$stats;
		}

		$this->GetDb();
		return true;
	}