/** * Process * Executes functions for the page that was requested * * @return Void Returns nothing */ function Process() { $user = GetUser(); $action = $this->_getGETRequest('Action', ''); $statstype = $this->_getGETRequest('statstype', null); $subaction = $this->_getGETRequest('subaction', ''); if (isset($_GET['PerPageDisplay'])) { $perpage = $this->SetPerPage($_GET['PerPageDisplay']); } else { $perpage = $this->GetPerPage(); } $statsapi = $this->GetApi('Stats'); switch ($action) { case 'get_linkstats': $linksjson = array(); $token_id = IEM::requestGetGET('token', false); $request_link = IEM::requestGetGET('link', false); if (!$token_id || !$request_link) { die(); } $token_data = IEM::sessionGet($token_id); $statid = $token_data['statid']; $calendar_restrictions = $token_data['calendar_restrictions']; $chosen_link = (is_numeric($request_link) ? $request_link : 'a'); // Total Clicks $linkclicks = $statsapi->GetClicks($statid, 0, 0, $chosen_link, $calendar_restrictions, true); $linkclicks = intval($linkclicks); $linksjson['linkclicks'] = $linkclicks; // Average Clicks $averageclicks = 0; $open_count = $statsapi->GetOpens($statid, 0, 0, true, $calendar_restrictions, true); $open_count = intval($open_count); if ($open_count != 0) { $averageclicks = $linkclicks / $open_count; } $linksjson['averageclicks'] = $this->FormatNumber($averageclicks, 3); // Click-through rate if (isset($token_data['summary']['emails_sent'])) { $sent_to = $token_data['summary']['emails_sent']; } else { $summary = $statsapi->GetNewsletterSummary($statid, true, 0); if (!isset($summary['htmlrecipients'])) { $sent_to = $request_link == 'a' ? $statsapi->GetRecipients($statid, 'autoresponder', 0, 1, $calendar_restrictions, true) : 0; } else { $sent_to = $summary['htmlrecipients'] + $summary['textrecipients'] + $summary['multipartrecipients']; } } $clicks = $statsapi->GetUniqueClickRecipients($statid,$calendar_restrictions,$chosen_link); if ($sent_to == 0) { $linksjson['clickthrough'] = '0%'; } else { $linksjson['clickthrough'] = $this->FormatNumber($clicks / $sent_to * 100,2) . '%'; } // Unique Clicks $uniqueclicks = $clicks; $linksjson['uniqueclicks'] = $uniqueclicks; echo "var linksjson = " . GetJSON($linksjson) . ";"; break; case 'print': if ($statstype != 'a' && $statstype != 'n' && $statstype != 'l' && $statstype != 't') { exit; } switch ($statstype) { case 'a': $this->area = 'autoresponder'; break; case 'n': $this->area = 'newsletter'; break; case 'l': $this->area = 'list'; break; case 't': $this->area = 'triggeremails'; break; } switch ($subaction) { case 'step2': require_once(dirname(__FILE__) . "/amcharts/amcharts.php"); $options_details = array(); if (isset($_GET['options_details']) && is_array($_GET['options_details'])) { $options_details = $_GET['options_details']; } if (isset($_GET['autoresponderid'])) { $autoresponderid = (int)$_GET['autoresponderid']; } if (!isset($_GET['Preview'])) { $GLOBALS['Body_Onload'] = 'window.focus();window.print();'; } else { $GLOBALS['Body_Onload'] = ''; } header("Content-type: text/html; charset=" . SENDSTUDIO_DEFAULTCHARSET); $this->ParseTemplate('Stats_Print_Header'); $calendar_restrictions = ''; $statids = $statsapi->CheckIntVars($_GET['stats']); foreach ($statids as $index=>$statid) { if ($statstype == 'a') { // For autoresponders, $_GET['stats'] contains the autoresponderid $autoresponderid = $statid; $summary = $statsapi->GetAutoresponderSummary($autoresponderid, true, 0); $statid = $summary['statid']; } if ($statstype == 'n') { $summary = $statsapi->GetNewsletterSummary($statid, true, 0); } if ($statstype == 'l') { $summary = $statsapi->GetListSummary($statid); $listid = $statid; $statid = $summary['statids']; IEM::sessionSet('ListStatistics', $statid); } if ($statstype == 't') { $triggeremailsid = $this->_getGETRequest('triggermailsid', 0); if (isset($triggeremailsid[$index])) { $summary = $statsapi->GetTriggerEmailsStatsRecord($triggeremailsid[$index]); } else { $summary = array(); } } $access = true; if (in_array($statstype, array('a', 'n'))) { $access = $this->CanAccessStats($statid, $statstype); } elseif ($statstype == 't') { // Admin access? $access = $user->Admin(); // If this is NOT an admin, check whether or not he owns the trigger if (!$access && $this->IsOwner($summary['owneruserid'])) { $access = true; } } else { $access = $this->CanAccessList($listid); } if (!$access) { $this->DenyAccess(); return; } foreach ($_GET['options'] as $option) { switch ($option) { case 'snapshot': switch ($statstype) { case 'l': $data = $statsapi->GetSubscriberGraphData($statsapi->stats_type, array('unconfirms' => array(),'confirms' => array(),'subscribes' => array(),'unsubscribes' => array(),'bounces' => array(),'forwards' => array()), $listid); IEM::sessionSet('SubscriberGraphData', $data); $areas = array('unconfirms', 'confirms', 'unsubscribes', 'bounces', 'forwards'); $totals = array('unconfirms' => 0, 'confirms' => 0, 'unsubscribes' => 0, 'forwards' => 0, 'bounces' => 0); $now = getdate(); $today = $now['0']; $date = $today; $time_display = ''; for ($i = 1; $i <= 12; $i++) { $found_stats = false; foreach ($areas as $k => $area) { $GLOBALS[$area] = 0; foreach ($data[$area] as $p => $details) { if ($details['mth'] != $i) { continue; } $GLOBALS['Name'] = GetLang($this->Months[$i]) . ' ' . $details['yr']; $GLOBALS[$area] = $this->FormatNumber($details['count']); $totals[$area] += $details['count']; $found_stats = true; } } if (!$found_stats) { continue; } $time_display .= $this->ParseTemplate('Stats_List_Step3_Row', true, false); } foreach ($areas as $k => $area) { $GLOBALS['Total_' . $area] = $this->FormatNumber($totals[$area]); //$GLOBALS['Total_domain_' . $area] = $this->FormatNumber($domain_totals[$area]); } $data_url = SENDSTUDIO_APPLICATION_URL . '/admin/functions/stats_chart.php?Area=list&list='.$listid .'&graph=subscribersummary&' . IEM::SESSION_NAME . '=' . IEM::sessionID(); $this->InsertChartImage('SummaryChart', $data_url, array('graph_title' => GetLang("List_Summary_Graph_subscribersummary"))); $this->ParseTemplate('Stats_Summary_List'); break; // case l case 'n': $GLOBALS['NewsletterID'] = $summary['newsletterid']; $sent_when = $GLOBALS['StartSending'] = $this->PrintTime($summary['starttime'], true); if ($summary['finishtime'] > 0) { $GLOBALS['FinishSending'] = $this->PrintTime($summary['finishtime'], true); $GLOBALS['SendingTime'] = $this->TimeDifference($summary['finishtime'] - $summary['starttime']); } else { $GLOBALS['FinishSending'] = GetLang('NotFinishedSending'); $GLOBALS['SendingTime'] = GetLang('NotFinishedSending'); } $sent_to = $summary['htmlrecipients'] + $summary['textrecipients'] + $summary['multipartrecipients']; $sent_size = $summary['sendsize']; $GLOBALS['SentToDetails'] = sprintf(GetLang('NewsletterStatistics_Snapshot_SendSize'), $this->FormatNumber($sent_to), $this->FormatNumber($sent_size)); $GLOBALS['NewsletterSubject'] = $summary['newslettersubject']; $GLOBALS['UserEmail'] = htmlspecialchars($summary['emailaddress'], ENT_QUOTES, SENDSTUDIO_CHARSET); $sent_by = $summary['username']; if ($summary['fullname']) { $sent_by = $summary['fullname']; } $GLOBALS['SentBy'] = htmlspecialchars($sent_by, ENT_QUOTES, SENDSTUDIO_CHARSET); if (sizeof($summary['lists']) > 1) { $GLOBALS['SentToLists'] = GetLang('SentToLists'); $GLOBALS['MailingLists'] = ''; $break_up = 4; $c = 1; foreach ($summary['lists'] as $listid => $listname) { if ($c % $break_up == 0) { $GLOBALS['MailingLists'] .= '<br/>'; $c = 0; } $GLOBALS['MailingLists'] .= htmlspecialchars($listname, ENT_QUOTES, SENDSTUDIO_CHARSET) . ','; $c++; } if (($c - 1) % $break_up != 0) { $GLOBALS['MailingLists'] = substr($GLOBALS['MailingLists'], 0, -1); } } else { $GLOBALS['SentToLists'] = GetLang('SentToList'); $listname = current($summary['lists']); $GLOBALS['MailingLists'] = htmlspecialchars($listname, ENT_QUOTES, SENDSTUDIO_CHARSET); } $GLOBALS['UniqueOpens'] = sprintf(GetLang('EmailOpens_Unique'), $this->FormatNumber($summary['emailopens_unique'])); $GLOBALS['TotalOpens'] = sprintf(GetLang('EmailOpens_Total'), $this->FormatNumber($summary['emailopens'])); if ($sent_to != 0) { $GLOBALS['OpenRate'] = $this->FormatNumber($summary['emailopens_unique'] / $sent_to * 100,2) . "%" ; } else { $GLOBALS['OpenRate'] = '0%'; } $clicks = $statsapi->GetUniqueClickRecipients($statid,'','a'); if ($sent_to == 0) { $GLOBALS['ClickThroughRate'] = "0%"; } else { $GLOBALS['ClickThroughRate'] = $this->FormatNumber((int)$clicks / (int)$sent_to * 100,2) . '%'; } $total_bounces = $summary['bouncecount_unknown'] + $summary['bouncecount_hard'] + $summary['bouncecount_soft']; $GLOBALS['TotalBounces'] = $this->FormatNumber($total_bounces); $unopened = $sent_size - $summary['emailopens_unique'] - $total_bounces; $data_url = SENDSTUDIO_APPLICATION_URL . '/admin/stats_chart.php?Opens='.$summary['emailopens_unique'].'&Unopened='.$unopened.'&Bounced='.$total_bounces.'&' . IEM::SESSION_NAME . '=' . IEM::sessionID(); // Newsletter Summary Chart $this->InsertChartImage('SummaryChart',$data_url,array('graph_title' => GetLang("NewsletterSummaryChart"))); // finally put it all together. $this->ParseTemplate('Stats_Summary_Newsletter'); break; // case 'n' case 'a': $this->LoadLanguageFile('Autoresponders'); $GLOBALS['AutoresponderID'] = $autoresponderid; $GLOBALS['SummaryIntro'] = sprintf(GetLang('AutoresponderStatistics_Snapshot_Summary'), htmlspecialchars($summary['autorespondername'], ENT_QUOTES, SENDSTUDIO_CHARSET)); $GLOBALS['AutoresponderSubject'] = htmlspecialchars($summary['autorespondersubject'], ENT_QUOTES, SENDSTUDIO_CHARSET); $GLOBALS['UserEmail'] = $summary['emailaddress']; $created_by = $summary['username']; if ($summary['fullname']) { $created_by = $summary['fullname']; } $GLOBALS['CreatedBy'] = $created_by; $GLOBALS['MailingList'] = htmlspecialchars($summary['listname'], ENT_QUOTES, SENDSTUDIO_CHARSET); if ($summary['hoursaftersubscription'] < 1) { $GLOBALS['SentWhen'] = GetLang('Immediately'); } else { if ($summary['hoursaftersubscription'] == 1) { $GLOBALS['SentWhen'] = GetLang('HoursAfter_One'); } else { $GLOBALS['SentWhen'] = sprintf(GetLang('HoursAfter_Many'), $summary['hoursaftersubscription']); } } $total_sent = $summary['htmlrecipients'] + $summary['textrecipients'] + $summary['multipartrecipients']; $GLOBALS['SentToDetails'] = $this->FormatNumber($total_sent); $GLOBALS['UniqueOpens'] = sprintf(GetLang('EmailOpens_Unique'), $this->FormatNumber($summary['emailopens_unique'])); $GLOBALS['TotalOpens'] = sprintf(GetLang('EmailOpens_Total'), $this->FormatNumber($summary['emailopens'])); $total_bounces = $summary['bouncecount_unknown'] + $summary['bouncecount_hard'] + $summary['bouncecount_soft']; $GLOBALS['TotalBounces'] = $this->FormatNumber($total_bounces); $unopened = $total_sent - $summary['emailopens_unique'] - $total_bounces; if ($unopened < 0) { $unopened = 0; } $data_url = SENDSTUDIO_APPLICATION_URL . '/admin/stats_chart.php?Opens='.$summary['emailopens_unique'].'&Unopened='.$unopened.'&Bounced='.$total_bounces.'&Area=autoresponder&' . IEM::SESSION_NAME . '=' . IEM::sessionID(); $this->InsertChartImage('SummaryChart',$data_url); $this->ParseTemplate('Stats_Summary_Autoresponder'); break; // case 'a' case 't': $this->LoadLanguageFile('TriggerEmails'); $summary['processed_totalbounced'] = intval($summary['bouncecount_soft']) + intval($summary['bouncecount_hard']) + intval($summary['bouncecount_unknown']); $info = array(); $info['total_open'] = sprintf(GetLang('EmailOpens_Total'), $this->FormatNumber($summary['emailopens'])); $info['unique_open'] = sprintf(GetLang('EmailOpens_Unique'), $this->FormatNumber($summary['emailopens_unique'])); $info['total_bounce'] = $this->FormatNumber($summary['processed_totalbounced']); $template = GetTemplateSystem(); $template->assign('record', $summary); $template->assign('info', $info); $template->ParseTemplate('Stats_Summary_TriggerEmails'); break; // case 't' } // switch ($statstype) break; //snapshot case 'perdomain': $domain_data = $statsapi->GetSubscriberDomainGraphData(array('unconfirms' => array(),'confirms' => array(),'subscribes' => array(),'unsubscribes' => array(),'bounces' => array(),'forwards' => array()), $listid); $domain_totals = array('unconfirms' => 0, 'confirms' => 0, 'unsubscribes' => 0, 'forwards' => 0, 'bounces' => 0); $areas = array('unconfirms', 'confirms', 'unsubscribes', 'bounces', 'forwards'); $domain_lines = array(); foreach ($areas as $k => $area) { foreach ($domain_data[$area] as $p => $details) { if (isset($details['domainname'])) { $domain = $details['domainname']; if (!isset($domain_lines[$domain])) { $domain_lines[$domain] = array('unconfirms' => 0, 'confirms' => 0, 'unsubscribes' => 0, 'forwards' => 0, 'bounces' => 0); } $domain_lines[$domain][$area] = $details['count']; } } } $graph_details = array(); $domain_display = ''; if (!empty($domain_lines)) { foreach ($domain_lines as $domain_name => $domain_info) { $GLOBALS['Name'] = htmlspecialchars($domain_name, ENT_QUOTES, SENDSTUDIO_CHARSET); foreach ($domain_info as $area => $count) { $GLOBALS[$area] = $this->FormatNumber($count); $domain_totals[$area] += $count; if ($area == 'confirms') { if (!isset($graph_details[$domain_name])) { $graph_details[$domain_name] = 0; } $graph_details[$domain_name] += $count; continue; } } $domain_display .= $this->ParseTemplate('Stats_List_Step3_Row', true, false); } } else { $GLOBALS['Name'] = ''; foreach ($areas as $k => $area) { $GLOBALS[$area] = 0; } $domain_display .= $this->ParseTemplate('Stats_List_Step3_Row', true, false); } IEM::sessionSet('SubscriberDomains', $graph_details); $this->DisplayChart('DomainChart', 'subscriberdomains', '0','pie',array( 'hide_labels_percent' => 2, 'group_percent' => 2, 'x_position' => '', 'radius' => 85, 'graph_title' => GetLang("ListStatistics_Snapshot_PerDomain") )); $this->ParseTemplate('Stats_Summary_Perdomain'); if (in_array($option,$options_details)) { foreach ($areas as $k => $area) { $GLOBALS['Total_domain_' . $area] = $this->FormatNumber($domain_totals[$area]); } $GLOBALS['DisplayDomainList'] = $domain_display; $this->ParseTemplate('Stats_List_Step3_Domains_Table'); } break; // case perdomain case 'open': if ($statstype == 'l') { $total_emails = $summary['emails_sent']; } else { $total_emails = $summary['htmlrecipients'] + $summary['textrecipients'] + $summary['multipartrecipients']; } $GLOBALS['TotalEmails'] = $this->FormatNumber($total_emails); $GLOBALS['TotalOpens'] = $this->FormatNumber($summary['emailopens']); $GLOBALS['TotalUniqueOpens'] = $this->FormatNumber($summary['emailopens_unique']); $most_opens = $statsapi->GetMostOpens($statid, $calendar_restrictions); $now = getdate(); if (isset($most_opens['mth'])) { $GLOBALS['MostOpens'] = $this->Months[$most_opens['mth']] . ' ' . $most_opens['yr']; } if (isset($most_opens['hr'])) { $GLOBALS['MostOpens'] = $this->PrintDate(mktime($most_opens['hr'], 1, 1, 1, 1, $now['year']), GetLang('Daily_Time_Display')); } if (isset($most_opens['dow'])) { $pos = array_search($most_opens['dow'], array_keys($this->days_of_week)); // we need to add 1 hour here otherwise we get the wrong day from strtotime. $GLOBALS['MostOpens'] = $this->PrintDate(strtotime("last " . $this->days_of_week[$pos] . " +1 hour"), GetLang('Date_Display_Display')); } if (isset($most_opens['dom'])) { $month = $now['mon']; // if the day-of-month is after "today", it's going to be for "last month" so adjust the month accordingly. if ($most_opens['dom'] > $now['mday']) { $month = $now['mon'] - 1; } $GLOBALS['MostOpens'] = $this->PrintDate(mktime(0, 0, 1, $month, $most_opens['dom'], $now['year']), GetLang('Date_Display_Display')); } $avg_opens = 0; if ($total_emails > 0) { $avg_opens = $summary['emailopens'] / $total_emails; } $GLOBALS['AverageOpens'] = $this->FormatNumber($avg_opens, 1); if ($total_emails != 0) { $GLOBALS['OpenRate'] = $this->FormatNumber($summary['emailopens_unique'] / $total_emails * 100,2) . "%" ; } else { $GLOBALS['OpenRate'] = '0%'; } if ($summary['emailopens'] > 0) { $this->DisplayChart('OpenChart', $this->area, $statid,'column',array('graph_title' => GetLang("OpensChart"))); } $this->ParseTemplate('Stats_Summary_Newsletter_Opens'); if (in_array($option,$options_details)) { $token = "stats" . md5(uniqid('_')); IEM::sessionSet($token,array( 'statid' => $statid, 'unique_only' => false, 'calendar_restrictions' => $calendar_restrictions, 'summary' => $summary )); echo '<div id="'.$option . '_details"></div>'; echo '<script> $.ajax({ type: "get", url: "remote_stats.php", data: "type=newsletter_opens&pagination=false&token='.$token.'&sort=down", success: function (html) { $("#'.$option.'_details").html(html); } }); </script>'; } break; // opens case 'click': if (isset($summary['starttime'])) { $sent_when = $this->PrintTime($summary['starttime'], true); } $GLOBALS['StatID'] = (int)$statid; $GLOBALS['LinkAction'] = 'Newsletter'; if (!isset($chosen_link) || !is_numeric($chosen_link)) { $chosen_link = 'a'; } $summary['linkclicks'] = $statsapi->GetClicks($statid, 0, 0, $chosen_link, $calendar_restrictions, true); // build up the summary table. $GLOBALS['TotalClicks'] = $this->FormatNumber($summary['linkclicks']); $unique_clicks_count = $statsapi->GetUniqueClicks($statid, $chosen_link, $calendar_restrictions); $GLOBALS['TotalUniqueClicks'] = $this->FormatNumber($unique_clicks_count); $most_popular_link = $statsapi->GetMostPopularLink($statid, $chosen_link, $calendar_restrictions); $GLOBALS['MostPopularLink'] = htmlspecialchars($most_popular_link, ENT_QUOTES, SENDSTUDIO_CHARSET); $GLOBALS['MostPopularLink_Short'] = $most_popular_link; $averageclicks = 0; if (isset($summary['emailopens']) && (int)$summary['emailopens'] > 0) { $open_count = (int)$summary['emailopens']; $averageclicks = $summary['linkclicks'] / $open_count; } $GLOBALS['AverageClicks'] = $this->FormatNumber($averageclicks, 1); if ($summary['linkclicks'] > 0) { $this->DisplayChart('LinksChart', $this->area, $statid,'column',array('graph_title' => GetLang("LinksClickedChart"))); } $this->ParseTemplate('Stats_Summary_Newsletter_Links'); $token = "stats" . md5(uniqid('_')); IEM::sessionSet($token,array( 'statid' => $statid, 'chosen_link' => 'a', 'calendar_restrictions' => $calendar_restrictions, 'summary' => $summary )); if (in_array($option,$options_details)) { echo '<div id="'.$option . '_details"></div>'; echo '<script> $.ajax({ type: "get", url: "remote_stats.php", data: "type=newsletter_links&pagination=false&token='.$token.'&sort=down", success: function (html) { $("#'.$option.'_details").html(html); } }); </script>'; } echo " <script> $.get('remote_stats.php?Action=get_linkstats&link=a&token={$token}','',function (data) { eval(data); $('#clickthrough').html(linksjson.clickthrough); }); </script>"; break; // click case 'bounce': $chosen_bounce_type = 'a'; $total_bounces = $statsapi->GetBounces($statid, 0, 10, $chosen_bounce_type, $calendar_restrictions, true); $bounce_types_count = $statsapi->GetBounceCounts($statid, $calendar_restrictions); $GLOBALS['TotalBounceCount'] = $this->FormatNumber($bounce_types_count['total']); $GLOBALS['TotalSoftBounceCount'] = $this->FormatNumber($bounce_types_count['soft']); $GLOBALS['TotalHardBounceCount'] = $this->FormatNumber($bounce_types_count['hard']); if ($bounce_types_count['total'] > 0) { $this->DisplayChart('BounceChart', $this->area, $statid,'column'); } $this->ParseTemplate('stats_summary_newsletter_bounces'); if (in_array($option,$options_details)) { $token = "stats" . md5(uniqid('_')); IEM::sessionSet($token,array( 'statid' => $statid, 'chosen_bounce_type' => false, 'calendar_restrictions' => $calendar_restrictions, 'summary' => $summary )); echo '<div id="'.$option . '_details"></div>'; echo '<script> $.ajax({ type: "get", url: "remote_stats.php", data: "type=newsletter_bounces&pagination=false&token='.$token.'&sort=down", success: function (html) { $("#'.$option.'_details").html(html); } }); </script>'; } break; // bounce case 'unsubscribe': if ($summary['unsubscribecount'] > 0) { $unsubscribes = $statsapi->GetUnsubscribes($statid, 0, 10, $calendar_restrictions); } $GLOBALS['TotalUnsubscribes'] = $this->FormatNumber($summary['unsubscribecount']); $most_unsubscribes = $statsapi->GetMostUnsubscribes($statid, $calendar_restrictions); $now = getdate(); if (isset($most_unsubscribes['mth'])) { $GLOBALS['MostUnsubscribes'] = $this->Months[$most_unsubscribes['mth']] . ' ' . $most_unsubscribes['yr']; } if (isset($most_unsubscribes['hr'])) { $GLOBALS['MostUnsubscribes'] = $this->PrintDate(mktime($most_unsubscribes['hr'], 1, 1, 1, 1, $now['year']), GetLang('Daily_Time_Display')); } if (isset($most_unsubscribes['dow'])) { $pos = array_search($most_unsubscribes['dow'], array_keys($this->days_of_week)); // we need to add 1 hour here otherwise we get the wrong day from strtotime. $GLOBALS['MostUnsubscribes'] = $this->PrintDate(strtotime("last " . $this->days_of_week[$pos] . " +1 hour"), GetLang('Date_Display_Display')); } if (isset($most_unsubscribes['dom'])) { $month = $now['mon']; // if the day-of-month is after "today", it's going to be for "last month" so adjust the month accordingly. if ($most_unsubscribes['dom'] > $now['mday']) { $month = $now['mon'] - 1; } $GLOBALS['MostUnsubscribes'] = $this->PrintDate(mktime(0, 0, 1, $month, $most_unsubscribes['dom'], $now['year']), GetLang('Date_Display_Display')); } if ($summary['unsubscribecount'] > 0) { $this->DisplayChart('UnsubscribeChart', $this->area, $statid, 'column',array('graph_title' => GetLang("UnsubscribesChart"))); } $this->ParseTemplate('stats_summary_newsletter_unsubscribes'); if (in_array($option,$options_details)) { $token = "stats" . md5(uniqid('_')); if ($statstype == 't') { IEM::sessionSet($token,array( 'statid' => $statid, 'calendar_restrictions' => array('unsubscribes' => $calendar_restrictions), 'summary' => $summary )); } else { IEM::sessionSet($token,array( 'statid' => $statid, 'calendar_restrictions' => $calendar_restrictions, 'summary' => $summary )); } $url_data_statstype = 'newsletter_unsubscribes'; if ($statstype == 't') { $url_data_statstype = 'triggeremails_unsubscribes'; } echo '<div id="'.$option . '_details"></div>'; echo '<script> $.ajax({ type: "get", url: "remote_stats.php", data: "type=' . $url_data_statstype . '&pagination=false&token='.$token.'&sort=down", success: function (html) { $("#'.$option.'_details").html(html); } }); </script>'; } break; //unsubscribe case 'forward': if ($summary['emailforwards'] > 0) { $forwards = $statsapi->GetForwards($statid, 0, 0, $calendar_restrictions); } if ($calendar_restrictions != '') { $summary['emailforwards'] = $statsapi->GetForwards($statid, $start, $perpage, $calendar_restrictions, true); } $GLOBALS['TotalForwards'] = $this->FormatNumber($summary['emailforwards']); $new_signups = $statsapi->GetForwards($statid, 0, 0, $calendar_restrictions, true, true); $GLOBALS['TotalForwardSignups'] = $this->FormatNumber($new_signups); if ($summary['emailforwards'] > 0) { $this->DisplayChart('ForwardsChart', $this->area, $statid,'column',array('graph_title' => GetLang("ForwardsChart"))); } $this->ParseTemplate('Stats_Summary_Newsletter_Forwards'); if (in_array($option,$options_details)) { $token = "stats" . md5(uniqid('_')); if ($statstype == 't') { IEM::sessionSet($token,array( 'statid' => $statid, 'calendar_restrictions' => array('forwards' => $calendar_restrictions), 'summary' => $summary )); } else { IEM::sessionSet($token,array( 'statid' => $statid, 'calendar_restrictions' => $calendar_restrictions, 'summary' => $summary )); } $url_data_statstype = 'forwards'; if ($statstype == 't') { $url_data_statstype = 'triggeremails_forwards'; } echo '<div id="'.$option . '_details"></div>'; echo '<script> $.ajax({ type: "get", url: "remote_stats.php", data: "type=' . $url_data_statstype . '&pagination=false&token='.$token.'&sort=down", success: function (html) { $("#'.$option.'_details").html(html); } }); </script>'; } break; //forward default: } // switch $option } // foreach $options } // foreach $stats $this->ParseTemplate('Stats_Print_Footer'); break; // step2 default: // step1 $print_options = ''; $bg_color = 'white'; if ($_GET['statstype']) { $print_options .= '<input type="hidden" name="statstype" value="' . htmlentities($statstype, ENT_QUOTES, SENDSTUDIO_CHARSET) . '" />'; } switch ($statstype) { default: $itemids = $statsapi->CheckIntVars($_GET['stats']); if (isset($_GET['stats'])) { foreach ($_GET['stats'] as $val) { $print_options .= '<input type="hidden" name="stats[]" value="' . $val . '" />'; } } if (isset($_GET['autoresponderid'])) { foreach ($_GET['autoresponderid'] as $val) { $print_options .= '<input type="hidden" name="autoresponderid[]" value="' . $val . '" />'; } } if (isset($_GET['triggerid'])) { $triggeremailid = $_GET['triggerid']; if (!is_array($triggeremailid)) { $triggeremailid = array($triggeremailid); } foreach ($triggeremailid as $id) { $print_options .= '<input type="hidden" name="triggermailsid[]" value="' . intval($id) . '" />'; } } if ($statstype == 'l') { $a = array ( 'snapshot' => GetLang('ListStatistics_Snapshot'), 'perdomain' => GetLang('ListStatistics_Snapshot_PerDomain'), 'open' => GetLang('Opens_Summary'), 'click' => GetLang('LinkClicks_Summary'), 'bounce' => GetLang('Bounce_Summary'), 'unsubscribe' => GetLang('Unsubscribe_Summary'), 'forward' => GetLang('Forwards_Summary') ); } else { $a = array ( 'snapshot' => GetLang('NewsletterStatistics_Snapshot'), 'open' => GetLang('Opens_Summary'), 'click' => GetLang('LinkClicks_Summary'), 'bounce' => GetLang('Bounce_Summary'), 'unsubscribe' => GetLang('Unsubscribe_Summary'), 'forward' => GetLang('Forwards_Summary') ); } foreach ($a as $key => $val) { $bg_color = ($bg_color == 'white') ? '#EDECEC' : 'white'; $print_options .= '<div style="background: ' . $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><br />' . "\n"; if ($key != 'snapshot') { $count = 0; $function = 'Get' . ucfirst($key) . 's'; $real_statids = array(); if ($statstype == 'l') { // For lists, $itemids is actually the listids, so we have to get the statids for the lists foreach ($itemids as $listid) { if (!$this->CanAccessList($listid)) { $this->DenyAccess(); return; } $summary = $statsapi->GetListSummary($listid); $real_statids = array_merge($real_statids, $summary['statids']); } } if ($statstype == 'a') { // For autoresponders, $itemids is actually the autoresponderids, so we have to get the statids for the autoresponders foreach ($itemids as $arid) { $summary = $statsapi->GetAutoresponderSummary($arid, true, 0); if (!$this->CanAccessStats($summary['statid'], 'a')) { $this->DenyAccess(); return; } $real_statids[] = $summary['statid']; } } switch ($key) { case 'perdomain': $count = $statsapi->GetSubscriberDomainCount($itemids[0]); break; case 'bounce': case 'open': $count = $statsapi->$function( ($real_statids === array() ? $itemids : $real_statids), 0, 0, false, '', true); break; case 'click': $count = $statsapi->$function(($real_statids === array() ? $itemids : $real_statids), 0, 0, 'a', '', true); break; default: $count = $statsapi->$function(($real_statids === array() ? $itemids : $real_statids), 0, 0, '', true); } $print_options .= '<span style="width: 20px;"><img src="images/blank.gif" width="20" height="1" /></span>'; $print_options .= '<input id="print_details_'.$key.'" type="checkbox" name="options_details[]" value="'.$key.'" style="margin:0;"'; if ($count == 0) { $print_options .= ' disabled="disabled"'; } $print_options .= ' /> <label for="print_details_' . $key . '">' . sprintf(GetLang('Stats_Print_IncludeDetailsOf'),$count,GetLang("Stats_Print_$key")) . '</label><br />' . "\n"; } $print_options .= '</div>'; } break; } $GLOBALS['PrintOptions'] = $print_options; $this->ParseTemplate('stats_print_step1'); break; } // switch subaction break; //print default: $token_data = IEM::sessionGet($_GET['token']); $statid = $token_data['statid']; $calendar_restrictions = $token_data['calendar_restrictions']; $GLOBALS['TableToken'] = $_GET['token']; $GLOBALS['Token'] = $_GET['token']; if (isset($_GET['pagination']) && ($_GET['pagination'] == 'false')) { $perpage = 'all'; } $DisplayPage = (isset($_GET['DisplayPage'])) ? (int)$_GET['DisplayPage'] : 1; $GLOBALS['CurrentPage'] = (int)$DisplayPage; $start = 0; if ($perpage != 'all') { $start = ($DisplayPage - 1) * $perpage; } $summary = &$token_data['summary']; if (isset($_GET['sort'])) { switch ($_GET['sort']) { case 'up': case 'down': $GLOBALS['SortDirection'] = $_GET['sort']; break; default: $GLOBALS['SortDirection'] = 'up'; } $this->sort = ($GLOBALS['SortDirection'] == 'up' ? 'ASC' : 'DESC'); } else { $this->sort = 'ASC'; $GLOBALS['SortDirection'] = 'up'; } if (in_array($_GET['type'], array_keys($this->columns))) { $GLOBALS['TableType'] = $_GET['type']; $this->type = $_GET['type']; if (isset($_GET['column']) && in_array($_GET['column'], array_keys($this->columns[$this->type]))) { $GLOBALS['SortColumn'] = $_GET['column']; $this->column = $this->columns[$this->type][$_GET['column']]; } else { $q = array_keys($this->columns[$this->type]); $GLOBALS['SortColumn'] = $q[0]; $this->column = $this->columns[$this->type][$q[0]]; } } else { echo "Invalid parameters"; exit; } // Tables: header("Content-type: text/html; charset=" . SENDSTUDIO_DEFAULTCHARSET); switch ($this->type) { case 'newsletter_opens': $opens = array(); $opencount = $statsapi->GetOpens($token_data['statid'], 0, 0, $token_data['unique_only'], $token_data['calendar_restrictions'], true); // make sure unique opens are > 0 - if they aren't, something isn't tracking right anyway so no point trying anything else. if ($summary['emailopens_unique'] > 0) { if (isset($token_data['listid'])) { $opens = $statsapi->GetOpens($statid, $start, $perpage, $token_data['unique_only'], $token_data['calendar_restrictions'],false,$this->column,$this->sort,$token_data['listid']); } else { $opens = $statsapi->GetOpens($statid, $start, $perpage, $token_data['unique_only'], $token_data['calendar_restrictions'],false,$this->column,$this->sort); } } $GLOBALS['CurrentPage'] = (int)$DisplayPage; $this->_SetupPaging($opencount, $DisplayPage, $perpage, '', 'newsletter_opens', $_GET['token']); $paging = $this->ParseTemplate('Stats_Remote_Paging', true, false); $GLOBALS['Paging'] = $paging; $open_list = ''; foreach ($opens as $k => $opendetails) { $GLOBALS['EmailAddress'] = htmlspecialchars($opendetails['emailaddress'], ENT_QUOTES, SENDSTUDIO_CHARSET); $GLOBALS['DateOpened'] = $this->PrintTime($opendetails['opentime'], true); $GLOBALS['OpenedEmailAsType'] = GetLang('OpenedEmailAs_Unknown'); switch (strtolower($opendetails['opentype'])) { case 'h': $GLOBALS['OpenedEmailAsType'] = GetLang('OpenedEmailAs_HTML'); break; case 't': $GLOBALS['OpenedEmailAsType'] = GetLang('OpenedEmailAs_Text'); break; } $open_list .= $this->ParseTemplate('Stats_Step3_Opens_Row', true, false); } $GLOBALS['Stats_Step3_Opens_List'] = $open_list; if (isset($_GET['pagination']) && $_GET['pagination'] == 'false') { $GLOBALS['PagingBottom'] = $GLOBALS['Paging'] = ''; } echo $this->ParseTemplate('Stats_Step3_Opens_Table', true, false); break; //newsletter_opens case 'newsletter_links': $chosen_link = $token_data['chosen_link']; if (isset($_GET['link']) && is_numeric($_GET['link'])) { $chosen_link = (int)$_GET['link']; } else { $chosen_link = 'a'; } $links = array(); if ($summary['linkclicks'] > 0) { $links = $statsapi->GetClicks($statid, $start, $perpage, $chosen_link, $calendar_restrictions,false,$this->column,$this->sort); } $all_links = $statsapi->GetUniqueLinks($statid); if (empty($all_links)) { $GLOBALS['DisplayStatsLinkList'] = 'none'; } else { $GLOBALS['DisplayStatsLinkList'] = 'block'; $all_links_list = ''; foreach ($all_links as $p => $linkinfo) { $selected = ''; if ($linkinfo['linkid'] == $chosen_link) { $selected = ' SELECTED'; } $all_links_list .= '<option value="' . $linkinfo['linkid'] . '"' . $selected . '>' . str_replace(array("'", '"'), "", $linkinfo['url']) . '</option>'; } $GLOBALS['StatsLinkList'] = $all_links_list; $GLOBALS['CurrentPage'] = (int)$GLOBALS['CurrentPage']; $GLOBALS['StatsLinkDropDown'] = $this->ParseTemplate('Stats_Step3_Links_List', true, false); } $GLOBALS['CurrentPage'] = (int)$DisplayPage; $total_links = $statsapi->GetClicks($statid, $start, $perpage, $chosen_link, $calendar_restrictions,true); $this->_SetupPaging($total_links, $DisplayPage, $perpage,'','newsletter_links',$_GET['token']); $paging = $this->ParseTemplate('Stats_Remote_Paging', true, false); $GLOBALS['Paging'] = $paging; $click_list = ''; foreach ($links as $k => $clickdetails) { $GLOBALS['EmailAddress'] = htmlspecialchars($clickdetails['emailaddress'], ENT_QUOTES, SENDSTUDIO_CHARSET); $GLOBALS['DateClicked'] = $this->PrintTime($clickdetails['clicktime'], true); $GLOBALS['FullURL'] = $url = str_replace(array('"', "'"), "", $clickdetails['url']); $GLOBALS['LinkClicked'] = $this->TruncateInMiddle($url); $click_list .= $this->ParseTemplate('Stats_Step3_Links_Row', true, false); } $GLOBALS['Stats_Step3_Links_List'] = $click_list; if (isset($_GET['pagination']) && $_GET['pagination'] == 'false') { $GLOBALS['PagingBottom'] = $GLOBALS['Paging'] = ''; $GLOBALS['StatsLinkDropDown'] = ''; } echo $this->ParseTemplate('Stats_Step3_Links_Table'); break; // newsletter_links case 'newsletter_bounces': $chosen_bounce_type = $token_data['chosen_bounce_type']; if (isset($_GET['bouncetype']) && in_array($_GET['bouncetype'],array('any','soft','hard'))) { $chosen_bounce_type = $_GET['bouncetype']; } else { $chosen_bounce_type = 'any'; } $bouncetypelist = ''; $all_bounce_types = array('any', 'hard', 'soft'); if (!in_array($chosen_bounce_type, $all_bounce_types)) { $chosen_bounce_type = 'any'; } foreach ($all_bounce_types as $p => $bounce_type) { $selected = ''; if ($bounce_type == $chosen_bounce_type) { $selected = ' SELECTED'; } $bouncetypelist .= '<option value="' . $bounce_type . '"' . $selected . '>' . GetLang('Bounce_Type_' . $bounce_type) . '</option>'; } $GLOBALS['StatsBounceList'] = $bouncetypelist; $bounces = array(); $total_bounces = $statsapi->GetBounces($statid, $start, $perpage, $chosen_bounce_type, $calendar_restrictions, true); if ($total_bounces > 0) { $bounces = $statsapi->GetBounces($statid, $start, $perpage, $chosen_bounce_type, $calendar_restrictions,false,$this->column,$this->sort); } $this->_SetupPaging($total_bounces, $DisplayPage, $perpage,'','newsletter_bounces',$_GET['token']); $paging = $this->ParseTemplate('Stats_Remote_Paging', true, false); $GLOBALS['Paging'] = $paging; $bounce_list = ''; foreach ($bounces as $k => $bouncedetails) { $GLOBALS['EmailAddress'] = htmlspecialchars($bouncedetails['emailaddress'], ENT_QUOTES, SENDSTUDIO_CHARSET); $GLOBALS['BounceDate'] = $this->PrintTime($bouncedetails['bouncetime'], true); $GLOBALS['BounceType'] = GetLang('Bounce_Type_' . $bouncedetails['bouncetype']); $GLOBALS['BounceRule'] = GetLang('Bounce_Rule_' . $bouncedetails['bouncerule']); $bounce_list .= $this->ParseTemplate('Stats_Step3_Bounces_Row', true, false); } $GLOBALS['Stats_Step3_Bounces_List'] = $bounce_list; if (isset($_GET['pagination']) && $_GET['pagination'] == 'false') { $GLOBALS['PagingBottom'] = $GLOBALS['Paging'] = ''; $GLOBALS['StatsBounceList'] = ''; } echo $this->ParseTemplate('Stats_Step3_Bounces_Table'); break; // newsletter_bounces case 'newsletter_unsubscribes': $unsubscribes = array(); $listid = 0; $token_request = IEM::requestGetGET('token', ''); $token = IEM::sessionGet($token_request); if ($token !== false && isset($token['listid'])) { $listid = $token['listid']; } if ($summary['unsubscribecount'] > 0) { $unsubscribes = $statsapi->GetUnsubscribes($statid, $start, $perpage, $calendar_restrictions,false,$this->column,$this->sort, $listid); } if (empty($unsubscribes)) { if ($summary['unsubscribecount'] > 0) { $GLOBALS['Error'] = GetLang('NewsletterHasNoUnsubscribes_CalendarProblem'); } else { $GLOBALS['Error'] = GetLang('NewsletterHasNoUnsubscribes'); } $GLOBALS['Message'] = $this->ParseTemplate('ErrorMsg', true, false); return $this->ParseTemplate('Stats_Step3_Unsubscribes_Empty', true, false); } $total_unsubscribes = $statsapi->GetUnsubscribes($statid, $start, $perpage, $calendar_restrictions,true, '', '', $listid); $this->_SetupPaging($total_unsubscribes, $DisplayPage, $perpage,'','newsletter_unsubscribes',$_GET['token']); $paging = $this->ParseTemplate('Stats_Remote_Paging', true, false); $GLOBALS['Paging'] = $paging; $unsub_list = ''; foreach ($unsubscribes as $k => $unsubdetails) { $GLOBALS['EmailAddress'] = htmlspecialchars($unsubdetails['emailaddress'], ENT_QUOTES, SENDSTUDIO_CHARSET); $GLOBALS['UnsubscribeTime'] = $this->PrintTime($unsubdetails['unsubscribetime'], true); $unsub_list .= $this->ParseTemplate('Stats_Step3_Unsubscribes_Row', true, false); } $GLOBALS['Stats_Step3_Unsubscribes_List'] = $unsub_list; if (isset($_GET['pagination']) && $_GET['pagination'] == 'false') { $GLOBALS['PagingBottom'] = $GLOBALS['Paging'] = ''; } echo $this->ParseTemplate('Stats_Step3_Unsubscribes_Table'); break; // newsletter_unsubscribes case 'forwards': $forwards = array(); if ($summary['emailforwards'] > 0) { $forwards = $statsapi->GetForwards($statid, $start, $perpage, $calendar_restrictions,false,false,$this->column,$this->sort); } $total_forwards = $statsapi->GetForwards($statid, $start, $perpage, $calendar_restrictions,true); $this->_SetupPaging($total_forwards, $DisplayPage, $perpage,'','forwards',$_GET['token']); $paging = $this->ParseTemplate('Stats_Remote_Paging', true, false); $GLOBALS['Paging'] = $paging; $forward_list = ''; foreach ($forwards as $k => $forwarddetails) { $GLOBALS['ForwardedTo'] = htmlspecialchars($forwarddetails['forwardedto'], ENT_QUOTES, SENDSTUDIO_CHARSET); $GLOBALS['ForwardedBy'] = htmlspecialchars($forwarddetails['forwardedby'], ENT_QUOTES, SENDSTUDIO_CHARSET); $GLOBALS['ForwardTime'] = $this->PrintTime($forwarddetails['forwardtime'], true); if ($forwarddetails['subscribed'] > 0) { $hassubscribed = GetLang('Yes'); } else { $hassubscribed = GetLang('No'); } $GLOBALS['HasSubscribed'] = $hassubscribed; $forward_list .= $this->ParseTemplate('Stats_Step3_Forwards_Row', true, false); } $GLOBALS['Stats_Step3_Forwards_List'] = $forward_list; if (isset($_GET['pagination']) && $_GET['pagination'] == 'false') { $GLOBALS['PagingBottom'] = $GLOBALS['Paging'] = ''; } echo $this->ParseTemplate('Stats_Step3_Forwards_Table'); break; // forwards case 'triggeremails_opens': $opens = array(); $opencount = $statsapi->GetOpens($statid, 0, 0, $token_data['unique_open_only'], $token_data['calendar_restrictions']['opens'], true); if ($opencount > 0) { if (isset($token_data['listid'])) { $opens = $statsapi->GetOpens($statid, $start, $perpage, $token_data['unique_open_only'], $token_data['calendar_restrictions']['opens'], false, $this->column, $this->sort, $token_data['listid']); } else { $opens = $statsapi->GetOpens($statid, $start, $perpage, $token_data['unique_open_only'], $token_data['calendar_restrictions']['opens'], false, $this->column, $this->sort); } } $GLOBALS['CurrentPage'] = (int)$DisplayPage; $this->_SetupPaging($opencount, $DisplayPage, $perpage, '', 'triggeremails_opens', $_GET['token']); $paging = $this->ParseTemplate('Stats_Remote_Paging', true, false); $GLOBALS['Paging'] = $paging; $open_list = ''; foreach ($opens as $k => $opendetails) { $GLOBALS['EmailAddress'] = htmlspecialchars($opendetails['emailaddress'], ENT_QUOTES, SENDSTUDIO_CHARSET); $GLOBALS['DateOpened'] = $this->PrintTime($opendetails['opentime'], true); $GLOBALS['OpenedEmailAsType'] = GetLang('OpenedEmailAs_Unknown'); switch (strtolower($opendetails['opentype'])) { case 'h': $GLOBALS['OpenedEmailAsType'] = GetLang('OpenedEmailAs_HTML'); break; case 't': $GLOBALS['OpenedEmailAsType'] = GetLang('OpenedEmailAs_Text'); break; } $open_list .= $this->ParseTemplate('Stats_Step3_Opens_Row', true, false); } $GLOBALS['Stats_Step3_Opens_List'] = $open_list; if (isset($_GET['pagination']) && $_GET['pagination'] == 'false') { $GLOBALS['PagingBottom'] = $GLOBALS['Paging'] = ''; } echo $this->ParseTemplate('Stats_Step3_Opens_Table', true, false); break; //triggeremails_opens case 'triggeremails_links': $chosen_link = isset($token_data['chosen_link'])? $token_data['chosen_link'] : 'a'; if (isset($_GET['link']) && is_numeric($_GET['link'])) { $chosen_link = (int)$_GET['link']; } else { $chosen_link = 'a'; } $links = array(); if ($summary['linkclicks'] > 0) { $links = $statsapi->GetClicks($statid, $start, $perpage, $chosen_link, $token_data['calendar_restrictions']['clicks'], false, $this->column, $this->sort); } $all_links = $statsapi->GetUniqueLinks($statid); if (empty($all_links)) { $GLOBALS['DisplayStatsLinkList'] = 'none'; } else { $GLOBALS['DisplayStatsLinkList'] = 'block'; $all_links_list = ''; foreach ($all_links as $p => $linkinfo) { $selected = ''; if ($linkinfo['linkid'] == $chosen_link) { $selected = ' SELECTED'; } $all_links_list .= '<option value="' . $linkinfo['linkid'] . '"' . $selected . '>' . str_replace(array("'", '"'), "", $linkinfo['url']) . '</option>'; } $GLOBALS['StatsLinkList'] = $all_links_list; $GLOBALS['CurrentPage'] = (int)$GLOBALS['CurrentPage']; $GLOBALS['StatsLinkDropDown'] = $this->ParseTemplate('Stats_Step3_Links_List', true, false); } $GLOBALS['CurrentPage'] = (int)$DisplayPage; $total_links = $statsapi->GetClicks($statid, $start, $perpage, $chosen_link, $token_data['calendar_restrictions']['clicks'], true); $this->_SetupPaging($total_links, $DisplayPage, $perpage, '', 'triggeremails_links', $_GET['token']); $paging = $this->ParseTemplate('Stats_Remote_Paging', true, false); $GLOBALS['Paging'] = $paging; $click_list = ''; foreach ($links as $k => $clickdetails) { $GLOBALS['EmailAddress'] = htmlspecialchars($clickdetails['emailaddress'], ENT_QUOTES, SENDSTUDIO_CHARSET); $GLOBALS['DateClicked'] = $this->PrintTime($clickdetails['clicktime'], true); $GLOBALS['FullURL'] = $url = str_replace(array('"', "'"), "", $clickdetails['url']); $GLOBALS['LinkClicked'] = $this->TruncateInMiddle($url); $click_list .= $this->ParseTemplate('Stats_Step3_Links_Row', true, false); } $GLOBALS['Stats_Step3_Links_List'] = $click_list; if (isset($_GET['pagination']) && $_GET['pagination'] == 'false') { $GLOBALS['PagingBottom'] = $GLOBALS['Paging'] = ''; $GLOBALS['StatsLinkDropDown'] = ''; } echo $this->ParseTemplate('Stats_Step3_Links_Table'); break; // triggeremails_links case 'triggeremails_bounces': $chosen_bounce_type = isset($token_data['chosen_bounce_type'])? $token_data['chosen_bounce_type'] : 'any'; if (isset($_GET['bouncetype']) && in_array($_GET['bouncetype'], array('any', 'soft', 'hard'))) { $chosen_bounce_type = $_GET['bouncetype']; } else { $chosen_bounce_type = 'any'; } $bouncetypelist = ''; $all_bounce_types = array('any', 'hard', 'soft'); if (!in_array($chosen_bounce_type, $all_bounce_types)) { $chosen_bounce_type = 'any'; } foreach ($all_bounce_types as $p => $bounce_type) { $selected = ''; if ($bounce_type == $chosen_bounce_type) { $selected = ' SELECTED'; } $bouncetypelist .= '<option value="' . $bounce_type . '"' . $selected . '>' . GetLang('Bounce_Type_' . $bounce_type) . '</option>'; } $GLOBALS['StatsBounceList'] = $bouncetypelist; $bounces = array(); $total_bounces = $statsapi->GetBounces($statid, $start, $perpage, $chosen_bounce_type, $token_data['calendar_restrictions']['bounces'], true); if ($total_bounces > 0) { $bounces = $statsapi->GetBounces($statid, $start, $perpage, $chosen_bounce_type, $token_data['calendar_restrictions']['bounces'], false, $this->column,$this->sort); } $this->_SetupPaging($total_bounces, $DisplayPage, $perpage, '', 'triggeremails_bounces', $_GET['token']); $paging = $this->ParseTemplate('Stats_Remote_Paging', true, false); $GLOBALS['Paging'] = $paging; $bounce_list = ''; foreach ($bounces as $k => $bouncedetails) { $GLOBALS['EmailAddress'] = htmlspecialchars($bouncedetails['emailaddress'], ENT_QUOTES, SENDSTUDIO_CHARSET); $GLOBALS['BounceDate'] = $this->PrintTime($bouncedetails['bouncetime'], true); $GLOBALS['BounceType'] = GetLang('Bounce_Type_' . $bouncedetails['bouncetype']); $GLOBALS['BounceRule'] = GetLang('Bounce_Rule_' . $bouncedetails['bouncerule']); $bounce_list .= $this->ParseTemplate('Stats_Step3_Bounces_Row', true, false); } $GLOBALS['Stats_Step3_Bounces_List'] = $bounce_list; if (isset($_GET['pagination']) && $_GET['pagination'] == 'false') { $GLOBALS['PagingBottom'] = $GLOBALS['Paging'] = ''; $GLOBALS['StatsBounceList'] = ''; } echo $this->ParseTemplate('Stats_Step3_Bounces_Table'); break; // triggeremails_bounces case 'triggeremails_unsubscribes': $unsubscribes = array();; $statid = $token_data['statid']; if ($summary['unsubscribecount'] > 0) { $unsubscribes = $statsapi->GetUnsubscribes($statid, $start, $perpage, $token_data['calendar_restrictions']['unsubscribes'], false, $this->column, $this->sort); } if (empty($unsubscribes)) { if ($summary['unsubscribecount'] > 0) { $GLOBALS['Error'] = GetLang('NewsletterHasNoUnsubscribes_CalendarProblem'); } else { $GLOBALS['Error'] = GetLang('NewsletterHasNoUnsubscribes'); } $GLOBALS['Message'] = $this->ParseTemplate('ErrorMsg', true, false); return $this->ParseTemplate('Stats_Step3_Unsubscribes_Empty', true, false); } $total_unsubscribes = $statsapi->GetUnsubscribes($statid, $start, $perpage, $token_data['calendar_restrictions']['unsubscribes'], true, '', ''); $this->_SetupPaging($total_unsubscribes, $DisplayPage, $perpage, '', 'triggeremails_unsubscribes', $_GET['token']); $paging = $this->ParseTemplate('Stats_Remote_Paging', true, false); $GLOBALS['Paging'] = $paging; $unsub_list = ''; foreach ($unsubscribes as $k => $unsubdetails) { $GLOBALS['EmailAddress'] = htmlspecialchars($unsubdetails['emailaddress'], ENT_QUOTES, SENDSTUDIO_CHARSET); $GLOBALS['UnsubscribeTime'] = $this->PrintTime($unsubdetails['unsubscribetime'], true); $unsub_list .= $this->ParseTemplate('Stats_Step3_Unsubscribes_Row', true, false); } $GLOBALS['Stats_Step3_Unsubscribes_List'] = $unsub_list; if (isset($_GET['pagination']) && $_GET['pagination'] == 'false') { $GLOBALS['PagingBottom'] = $GLOBALS['Paging'] = ''; } echo $this->ParseTemplate('Stats_Step3_Unsubscribes_Table'); break; // triggeremails_unsubscribes case 'triggeremails_forwards': $forwards = array(); $statid = $token_data['statid']; if ($summary['emailforwards'] > 0) { $forwards = $statsapi->GetForwards($statid, $start, $perpage, $token_data['calendar_restrictions']['forwards'], false, false, $this->column, $this->sort); } $total_forwards = $statsapi->GetForwards($statid, $start, $perpage, $token_data['calendar_restrictions']['forwards'], true); $this->_SetupPaging($total_forwards, $DisplayPage, $perpage, '', 'triggeremails_forwards', $_GET['token']); $paging = $this->ParseTemplate('Paging', true, false); $GLOBALS['Paging'] = $paging; $forward_list = ''; foreach ($forwards as $k => $forwarddetails) { $GLOBALS['ForwardedTo'] = htmlspecialchars($forwarddetails['forwardedto'], ENT_QUOTES, SENDSTUDIO_CHARSET); $GLOBALS['ForwardedBy'] = htmlspecialchars($forwarddetails['forwardedby'], ENT_QUOTES, SENDSTUDIO_CHARSET); $GLOBALS['ForwardTime'] = $this->PrintTime($forwarddetails['forwardtime'], true); if ($forwarddetails['subscribed'] > 0) { $hassubscribed = GetLang('Yes'); } else { $hassubscribed = GetLang('No'); } $GLOBALS['HasSubscribed'] = $hassubscribed; $forward_list .= $this->ParseTemplate('Stats_Step3_Forwards_Row', true, false); } $GLOBALS['Stats_Step3_Forwards_List'] = $forward_list; if (isset($_GET['pagination']) && $_GET['pagination'] == 'false') { $GLOBALS['PagingBottom'] = $GLOBALS['Paging'] = ''; } echo $this->ParseTemplate('Stats_Step3_Forwards_Table'); break; // triggeremails_forwards default: break; } // switch type break; //export } // switch selectaction }
/** * Admin_Action_DeleteBlock * This will delete content block * */ public function Admin_Action_DeleteBlock() { $blockId = $this->_getPOSTRequest('blockid', 0); if ($blockId) { $blockIds = implode("','", $blockId); $query = "DELETE FROM [|PREFIX|]dynamic_content_block WHERE blockid in ('{$blockIds}')"; if ($result = $this->db->Query($query)) { // Error message FlashMessage(GetLang('Addon_dynamiccontenttags_DeleteBlock_Success'), SS_FLASH_MSG_SUCCESS); echo GetJSON(array('message' => GetFlashMessages(), 'result' => '1')); return; } } FlashMessage(GetLang('Addon_dynamiccontenttags_DeleteBlock_Failure'), SS_FLASH_MSG_ERROR); echo GetJSON(array('message' => GetFlashMessages(), 'result' => '0')); return; }
/** * Process * Lets a user manage their own account - to a certain extent. * The API itself manages saving and updating, this just works out displaying of forms etc. * * @see PrintHeader * @see ParseTemplate * @see IEM::getDatabase() * @see GetUser * @see User_API::Set * @see GetLang * @see PrintEditForm * @see PrintFooter * * @return Void Doesn't return anything, hands the processing off to the appropriate subarea and lets it do the work. */ function Process() { $action = (isset($_GET['Action'])) ? strtolower($_GET['Action']) : ''; if (!in_array($action, $this->PopupWindows)) { $this->PrintHeader(); } $user = IEM::getCurrentUser(); $db = IEM::getDatabase(); switch ($action) { case 'save': if (!$user->EditOwnSettings()) { $this->DenyAccess(); } $smtptype = 0; if ($user->HasAccess('User', 'SMTP')) { $smtptype = (isset($_POST['smtptype'])) ? $_POST['smtptype'] : 0; } // Make sure smtptype is eiter 0 or 1 if ($smtptype != 1) { $smtptype = 0; } // ----- Activity type $activity = IEM::requestGetPOST('eventactivitytype', '', 'trim'); if (!empty($activity)) { $activity_array = explode("\n", $activity); for ($i = 0, $j = count($activity_array); $i < $j; ++$i) { $activity_array[$i] = trim($activity_array[$i]); } } else { $activity_array = array(); } $user->Set('eventactivitytype', $activity_array); // ----- /** * This was added, because User's API uses different names than of the HTML form names. * HTML form names should stay the same to keep it consistant throught the application * * This will actually map HTML forms => User's API fields */ $areaMapping = array( 'fullname' => 'fullname', 'emailaddress' => 'emailaddress', 'usertimezone' => 'usertimezone', 'textfooter' => 'textfooter', 'htmlfooter' => 'htmlfooter', 'infotips' => 'infotips', 'usewysiwyg' => 'usewysiwyg', 'enableactivitylog' => 'enableactivitylog', 'usexhtml' => 'usexhtml', 'googlecalendarusername' => 'googlecalendarusername', 'googlecalendarpassword' => 'googlecalendarpassword' ); if ($user->HasAccess('User', 'SMTP')) { $areaMapping['smtp_server'] = 'smtpserver'; $areaMapping['smtp_u'] = 'smtpusername'; $areaMapping['smtp_p'] = 'smtppassword'; $areaMapping['smtp_port'] = 'smtpport'; } foreach ($areaMapping as $p => $area) { $val = (isset($_POST[$p])) ? $_POST[$p] : ''; $user->Set($area, $val); } /** * ----- */ if ($user->HasAccess('User', 'SMTP')) { if ($smtptype == 0) { $user->Set('smtpserver', ''); $user->Set('smtpusername', ''); $user->Set('smtppassword', ''); $user->Set('smtpport', 0); } } $error = false; $template = false; if (!$error) { if ($_POST['ss_p'] != '') { if ($_POST['ss_p_confirm'] != '' && $_POST['ss_p_confirm'] == $_POST['ss_p']) { $user->Set('password', $_POST['ss_p']); } else { $error = GetLang('PasswordsDontMatch'); } } } if (!$error) { $result = $user->Save(); if ($result) { $GLOBALS['Message'] = $this->PrintSuccess('UserUpdated') . '<br/>'; } else { $GLOBALS['Error'] = GetLang('UserNotUpdated'); $GLOBALS['Message'] = $this->ParseTemplate('ErrorMsg', true, false); } } else { $GLOBALS['Error'] = $error; $GLOBALS['Message'] = $this->ParseTemplate('ErrorMsg', true, false); } $userid = $user->Get('userid'); $this->PrintEditForm($userid); break; case 'sendpreviewdisplay': $this->PrintHeader(true); $this->SendTestPreviewDisplay('index.php?Page=ManageAccount&Action=SendPreview', 'self.parent.getSMTPPreviewParameters()'); $this->PrintFooter(true); break; case 'sendpreview': $this->SendTestPreview(); break; case 'testgooglecalendar': $status = array( 'status' => false, 'message' => '' ); try { $details = array( 'username' => $_REQUEST['gcusername'], 'password' => $_REQUEST['gcpassword'] ); $this->GoogleCalendarAdd($details, true); $status['status'] = true; $status['message'] = GetLang('GooglecalendarTestSuccess'); } catch (Exception $e) { $status['message'] = GetLang('GooglecalendarTestFailure'); } print GetJSON($status); break; default: $userid = $user->userid; $this->PrintEditForm($userid); break; } if (!in_array($action, $this->PopupWindows)) { $this->PrintFooter(); } }
triggeractions_removefromlist_label_generic: '<?php echo addslashes(GetLang('TriggerEmails_Form_Field_TriggerAction_RemoveList')); ?>', triggeractions_removefromlist_label_datecustomfield: '<?php echo addslashes(GetLang('TriggerEmails_Form_Field_TriggerAction_RemoveList_f')); ?>', triggeractions_removefromlist_label_staticdate_one: '<?php echo addslashes(GetLang('TriggerEmails_Form_Field_TriggerAction_RemoveList_s_One')); ?>', triggeractions_removefromlist_label_staticdate_many: '<?php echo addslashes(GetLang('TriggerEmails_Form_Field_TriggerAction_RemoveList_s_Many')); ?>', triggeractions_removefromlist_label_linkclicked: '<?php echo addslashes(GetLang('TriggerEmails_Form_Field_TriggerAction_RemoveList_l')); ?>', triggeractions_removefromlist_label_newsletteropen: '<?php echo addslashes(GetLang('TriggerEmails_Form_Field_TriggerAction_RemoveList_n')); ?>'}, _optionsDatePickerStaticDate: { yearRange:'-100:+100', dateFormat: 'yy-mm-dd', altField: 'div.TriggerType_s_options input[type=text]', altFormat: 'DD, d M yy'}, _cacheList: <?php echo GetJSON($tpl->Get('availableLists')); ?>, _cacheListCustomfields: <?php echo GetJSON($tpl->Get('availableCustomFields')); ?>, _cacheNewsletterLinks: <?php echo GetJSON($tpl->Get('availableLinks')); ?>, _currentlySelectedLinkID_Newsletter: [], eventDOMReady: function(event) { $('ul#tabnav a').click(Application.Page.TriggerEmailsForm.eventChangeTab); $(document.frmTriggerForm).submit(Application.Page.TriggerEmailsForm.eventSubmitForm); $('.cancelButton', document.frmTriggerForm).click(Application.Page.TriggerEmailsForm.eventClickCancel); $("input[name='record[triggertype]']", document.frmTriggerForm).click(Application.Page.TriggerEmailsForm.eventChangeTriggerType); $(document.frmTriggerForm['record[data][listid]']).change(Application.Page.TriggerEmailsForm.eventChangeList); $(document.frmTriggerForm['record[data][linkid_newsletterid]']).change(Application.Page.TriggerEmailsForm.eventChangeTriggerLinkNewsletter); $(document.frmTriggerForm['record[data][newsletterid]']).change(Application.Page.TriggerEmailsForm.eventChangeTriggerNewsletterOpen); $(document.frmTriggerForm['toprocess[when]']).change(Application.Page.TriggerEmailsForm.eventChangeTimeWhen); $(document.frmTriggerForm['record[triggeractions][send][enabled]']).click(Application.Page.TriggerEmailsForm.eventClickSendTriggerActions);
/** * ManageSubscribers_Step3 * Prints out the subscribers for the list chosen and criteria selected in steps 1 & 2. This handles sorting, paging and searching. If you are coming in for the first time, it remembers your search criteria in the session. If you change number per page, sorting criteria, it fetches the search criteria from the session again before continuing. * * @see ManageSubscribers_Step2 * @see GetApi * @see GetPerPage * @see GetCurrentPage * @see GetSortDetails * @see Subscribers_API::FetchSubscribers * @see SetupPaging * @see Lists_API::Load * * @return Void Doesn't return anything. Prints out the results and that's it. */ function ManageSubscribers_Step3($change=false) { $subscriber_api = $this->GetApi('Subscribers'); $user = IEM::getCurrentUser(); $search_info = IEM::sessionGet('Search_Subscribers'); $this->SetupGoogleCalendar(); $user_lists = $user->GetLists(); if (!isset($GLOBALS['Message'])) { $GLOBALS['Message'] = ''; } // if we are posting a form, we are most likely resetting the search criteria. // we are also resetting the search criteria once we detect "Lists" variable in the GET Request $resetsearch = ((isset($_POST) && !empty($_POST)) || isset($_GET['Lists']) || isset($_GET['Segment'])) ? true : false; // except if we're changing paging! if (isset($_GET['SubAction'])) { $subaction = strtolower($_GET['SubAction']); if ($subaction == 'processpaging' || $subaction == 'change') { $resetsearch = false; } } if (!$search_info || $resetsearch) { $this->SetCurrentPage(1); // forget current page $search_details = array(); if (isset($_POST['emailaddress']) && $_POST['emailaddress'] != '') { $search_details['Email'] = trim($_POST['emailaddress']); } if (isset($_POST['format']) && $_POST['format'] != '-1') { $search_details['Format'] = $_POST['format']; } if (isset($_POST['confirmed']) && $_POST['confirmed'] != '-1') { $search_details['Confirmed'] = $_POST['confirmed']; } if (isset($_POST['status']) && $_POST['status'] != '-1') { $search_details['Status'] = $_POST['status']; } if (isset($_POST['datesearch']) && isset($_POST['datesearch']['filter'])) { $search_details['DateSearch'] = $_POST['datesearch']; $search_details['DateSearch']['StartDate'] = AdjustTime(array(0, 0, 1, $_POST['datesearch']['mm_start'], $_POST['datesearch']['dd_start'], $_POST['datesearch']['yy_start'])); $search_details['DateSearch']['EndDate'] = AdjustTime(array(0, 0, 1, $_POST['datesearch']['mm_end'], $_POST['datesearch']['dd_end'], $_POST['datesearch']['yy_end'])); } $customfields = array(); if (isset($_POST['CustomFields']) && !empty($_POST['CustomFields'])) { $customfields = $_POST['CustomFields']; } $search_details['CustomFields'] = $customfields; if (isset($_GET['Lists']) || isset($_GET['List'])) { $search_details['List'] = isset($_GET['Lists'])? $_GET['Lists'] : $_GET['List']; } else { $search_details['List'] = 'any'; } // Get segment, and make sure user have access permission to it if ($user->HasAccess('Segments')) { $search_details['Segment'] = null; if (isset($_GET['Segment'])) { $tempSegmentList = array_keys($user->GetSegmentList()); $tempSegment = $_GET['Segment']; // Make sure that selected segment is allowed for user if (!is_array($tempSegment)) { if (!in_array($tempSegment, $tempSegmentList)) { $tempSegment = null; } } else { $tempSegment = array_intersect($tempSegment, $tempSegmentList); } if (!is_null($tempSegment)) { $search_details['Segment'] = $tempSegment; } } } if (is_array($search_details['List'])) { // Make sure that "any" is not selected when you are selecting multiple list if (count($search_details['List']) > 1) { if (($index = array_search('any', $search_details['List'])) !== false) { unset($search_details['List'][$index]); } } // If the array only contain 1 id, make take it out of the array if (count($search_details['List']) == 1) { $search_details['List'] = array_pop($search_details['List']); } } // Get allowable list if (!$user->ListAdmin()) { $search_details['AvailableLists'] = array_keys($user_lists); } if (is_array($search_details['List'])) { // Make sure IDs are numerics if (is_array($search_details['List'])) { $listIDs = array(); foreach ($search_details['List'] as $id) { array_push($listIDs, intval($id)); } $search_details['List'] = $listIDs; } } // Make sure that user can only select newsletter from his/her allowable list if (isset($search_details['AvailableLists']) && (is_numeric($search_details['List']) || is_array($search_details['List']))) { if (is_array($search_details['List'])) { $search_details['List'] = array_intersect($search_details['List'], $search_details['AvailableLists']); } else { $temp = in_array($search_details['List'], $search_details['AvailableLists']); if (!$temp) { $search_details['List'] = null; } } if (empty($search_details['List'])) { $search_details['List'] = $search_details['AvailableLists']; } // Make sure to unset available list, otherwise Subscribers API will think // we are looking to query all list unset($search_details['AvailableLists']); } if (isset($_POST['clickedlink']) && isset($_POST['linkid'])) { $search_details['LinkType'] = 'clicked'; if (isset($_POST['linktype']) && $_POST['linktype'] == 'not_clicked') { $search_details['LinkType'] = 'not_clicked'; } $search_details['Link'] = $_POST['linkid']; } if (isset($_POST['openednewsletter']) && isset($_POST['newsletterid'])) { $search_details['OpenType'] = 'opened'; if (isset($_POST['opentype']) && $_POST['opentype'] == 'not_opened') { $search_details['OpenType'] = 'not_opened'; } $search_details['Newsletter'] = $_POST['newsletterid']; } if (isset($_POST['Search_Options'])) { $search_details['Search_Options'] = $_POST['Search_Options']; } // Flag to differentiate where the search details are coming from $GLOBALS['Search'] = ''; if (!empty($_POST) || !empty($search_details['Email'])) { $search_details['Source'] = 'search'; $GLOBALS['Search'] = isset($search_details['Email'])? $search_details['Email'] : ''; } else { if (!empty($search_details['Segment'])) { $search_details['Source'] = 'segment'; } else { $search_details['Source'] = 'list'; } } IEM::sessionSet('Search_Subscribers', $search_details); } $search_info = IEM::sessionGet('Search_Subscribers'); // Process segmenting information if (!empty($search_info['Segment'])) { $segmentAPI = $this->GetApi('Segment'); if (is_array($search_info['Segment'])) { $search_info['List'] = $segmentAPI->GetMailingListUsed($search_info['Segment']); } else { $segmentAPI->Load($search_info['Segment']); $search_info['List'] = $segmentAPI->GetMailingListUsed(); } $subscriber_header_template = 'Subscribers_Manage_AnyList'; $subscriber_row_template = 'Subscribers_Manage_AnyList_Row'; $GLOBALS['Segment'] = is_array($search_info['Segment'])? implode('&Segment[]=', $search_info['Segment']) : $search_info['Segment']; } $GLOBALS['List'] = is_array($search_info['List'])? implode('&Lists[]=', $search_info['List']) : $search_info['List']; // Load visible fields for each list if (isset($_POST['VisibleFields'])) { IEM::sessionSet('visiblefields', $_POST['VisibleFields']); $visiblefields_set = $_POST['VisibleFields']; } elseif (IEM::sessionGet('visiblefields')) { $visiblefields_set = IEM::sessionGet('visiblefields'); } else { list(,$visiblefields_set) = $this->GetVisibleFields($search_info['List']); } $perpage = $this->GetPerPage(); $pageid = $this->GetCurrentPage(); $sortinfo = $this->GetSortDetails(); // Check if we are sorting by a custom field if (is_numeric($sortinfo['SortBy'])) { if (in_array($sortinfo['SortBy'], $visiblefields_set)) { $sortinfo['CustomFields'] = array($sortinfo['SortBy']); $sortinfo['SortBy'] = 'sd.data'; } else { $sortinfo['SortBy'] = 'emailaddress'; } } if (!empty($search_info['Segment'])) { $tempEmail = null; if (!empty($search_details['Email'])) { $tempEmail = $search_details['Email']; } $subscriber_list = $subscriber_api->FetchSubscribersFromSegment($pageid, $perpage, $search_info['Segment'], $sortinfo, $tempEmail); } else { $subscriber_list = $subscriber_api->FetchSubscribers($pageid, $perpage, $search_info, $sortinfo); } $subscriber_edited = (isset($_GET['Edit'])) ? true : false; $totalsubscribers = $subscriber_list['count']; unset($subscriber_list['count']); if ($subscriber_edited) { $GLOBALS['Message'] .= $this->PrintSuccess('SubscriberEditSuccess'); } $GLOBALS['TotalSubscriberCount'] = $this->FormatNumber($totalsubscribers); $tempMessageStringSubfix = ''; switch ($search_info['Source']) { case 'list': if ($search_info['List'] == 'any') { $tempMessageStringSubfix = 'AllList_'; } elseif (is_array($search_info['List'])) { $tempMessageStringSubfix = 'ManyList_'; } else { $tempMessageStringSubfix = 'OneList_'; } break; case 'segment': $tempMessageStringSubfix = 'Segment_'; break; } $DisplayPage = $pageid; $GLOBALS['PAGE'] = 'Subscribers&Action=Manage&SubAction=Step3'; // set up paging before we add the Lists[]= part, as we never want paging links to reset a search $this->SetupPaging($totalsubscribers, $DisplayPage, $perpage); $GLOBALS['FormAction'] = 'SubAction=ProcessPaging'; $paging = $this->ParseTemplate('Paging', true, false); if (!empty($search_info['Segment'])) { $GLOBALS['PAGE'] .= '&Segment[]=' . $GLOBALS['Segment']; } else { $GLOBALS['PAGE'] .= '&Lists[]=' . $GLOBALS['List']; } $subscriberdetails = ''; // If no visible fields are selected, make emailaddress visible if (count($visiblefields_set) == 0) { array_unshift($visiblefields_set,'emailaddress'); } // Make "View" PopUp menu $GLOBALS['SubscriberViewPickerMenu'] = $this->MakeViewPopupMenu($search_info, $user); $loaded_customfields = array(); $customfields = array(); $visiblefields = array(); $visiblefields_lists = array(); $subscriber_header_template = 'Subscribers_Manage_AnyList'; $subscriber_row_template = 'Subscribers_Manage_AnyList_Row'; if (!$user->HasAccess('Subscribers', 'Add')) { $GLOBALS['AddButtonDisplay'] = 'none'; } if (!empty($search_info['Segment'])) { $segmentAPI = $this->GetApi('Segment'); $tempSegmentID = $search_info['Segment']; $usedLists = array(); if (!is_array($tempSegmentID)) { $tempSegmentID = array($tempSegmentID); } foreach ($tempSegmentID as $id) { $segmentAPI->Load($id); $tempList = $segmentAPI->GetMailingListUsed(); $usedLists = array_merge($usedLists, $tempList); } $search_info['List'] = $usedLists; /** * Segments contain lists (as they can go across multiple lists) */ $listids = $search_info['List']; if ($search_info['Source'] == 'search' || is_array($search_info['Segment'])) { $title = GetLang('SubscribersManageSearchResult'); } else { $title = sprintf(GetLang('SubscribersManageSegment'), htmlspecialchars($segmentAPI->segmentname, ENT_QUOTES, SENDSTUDIO_CHARSET)); } $GLOBALS['AddButtonURL'] = 'index.php?Page=Subscribers&Action=Add'; } else { /** * Only viewing one list here. */ if (is_numeric($search_info['List'])) { $listids = array($search_info['List']); $subscriber_header_template = 'Subscribers_Manage'; $subscriber_row_template = 'Subscribers_Manage_Row'; $GLOBALS['ColumnCount'] = 3; if ($search_info['Source'] == 'search') { $title = GetLang('SubscribersManageSearchResult'); } else { $listname = $user_lists[$search_info['List']]['name']; $title = sprintf(GetLang('SubscribersManageSingleList'), htmlspecialchars($listname, ENT_QUOTES, SENDSTUDIO_CHARSET)); } $GLOBALS['AddButtonURL'] = 'index.php?Page=Subscribers&Action=Add&SubAction=Step2&list=' . $search_info['List']; } else { /** * If we're viewing more than one list, use those id's. */ if (is_array($search_info['List'])) { $listids = $search_info['List']; $title = GetLang('SubscribersManageMultipleList'); } else { /** * The default is all of the users lists. */ $listids = array_keys($user_lists); $title = GetLang('SubscribersManageAnyList'); } /** * Override the title if we're coming from a search result. */ if ($search_info['Source'] == 'search') { $title = GetLang('SubscribersManageSearchResult'); } $GLOBALS['AddButtonURL'] = 'index.php?Page=Subscribers&Action=Add'; $GLOBALS['ColumnCount'] = 4; } } $GLOBALS['SubscribersManage'] = $title; // Log this to "User Activity Log" except when is deleting. if (!(isset($_GET['SubAction']) && strtolower($_GET['SubAction']) != "delete")) { IEM::logUserActivity($_SERVER['REQUEST_URI'], 'images/lists_view.gif', $title); } if ($totalsubscribers < 1) { IEM::sessionRemove('Search_Subscribers'); if ($subscriber_edited) { $GLOBALS['Message'] .= $this->PrintSuccess('SubscriberEditSuccess'); } else { $GLOBALS['Message'] .= $this->PrintSuccess('NoSubscribersMatch', true); } $this->ParseTemplate('Subscribers_Manage_Empty'); return; } if ($totalsubscribers == 1) { $GLOBALS['Message'] .= $this->PrintSuccess('Subscribers_' . $tempMessageStringSubfix . 'FoundOne'); } else { $GLOBALS['Message'] .= $this->PrintSuccess('Subscribers_' . $tempMessageStringSubfix . 'FoundMany', $GLOBALS['TotalSubscriberCount']); } $CustomFieldsApi = $this->GetApi('CustomFields'); $customfields_for_all_lists = $CustomFieldsApi->GetCustomFieldsForLists($listids, $visiblefields_set); $listNames = array(); foreach ($listids as $listid) { array_push($listNames, $user_lists[$listid]['name']); foreach ($this->BuiltinFields as $key => $name) { if (in_array($key,$visiblefields_set) && !in_array($key,$visiblefields)) { if (!isset($visiblefields_lists[$key])) { $visiblefields_lists[$key] = array(); } $visiblefields_lists[$key][] = (int)$listid; $visiblefields[] = $key; } } foreach ($customfields_for_all_lists as $key => $details) { if (in_array($details['fieldid'],$visiblefields_set)) { if (!isset($visiblefields_lists[$details['fieldid']])) { $visiblefields_lists[$details['fieldid']] = array(); } $visiblefields_lists[$details['fieldid']][] = (int)$listid; if (!in_array($details['fieldid'],$visiblefields)) { $visiblefields[] = $details['fieldid']; } } } } $customfield_data = array(); $GLOBALS['Columns'] = ''; foreach ($visiblefields as $name) { if (!in_array($name,$visiblefields_set)) { continue; } if (is_numeric($name)) { $customfieldinfo = array(); foreach ($customfields_for_all_lists as $pos => $details) { if ($details['fieldid'] === $name) { $customfieldinfo = $details; break; } } /** * Check we got some data here. * We may have just changed the lists we are viewing and the custom field isn't associated with this new list */ if (!empty($customfieldinfo)) { $GLOBALS['FieldName'] = htmlspecialchars($customfieldinfo['name'], ENT_QUOTES, SENDSTUDIO_CHARSET); $subfield = $CustomFieldsApi->LoadSubField($customfieldinfo); $loaded_customfields[$name] = $subfield; $customfield_data[] = array ( 'fieldid' => $name, 'fieldtype' => $subfield->fieldtype, 'defaultvalue' => $subfield->GetDefaultValue(), 'name' => $subfield->GetFieldName(), ); } } elseif (in_array($name,array_keys($this->BuiltinFields))) { $GLOBALS['FieldName'] = GetLang($this->BuiltinFields[$name]); } if ($name == 'emailaddress') { $GLOBALS['Width'] = 'width="17%"'; } else { $GLOBALS['Width'] = ''; } $GLOBALS['SortName'] = htmlspecialchars($name, ENT_QUOTES, SENDSTUDIO_CHARSET); $GLOBALS['Columns'] .= $this->ParseTemplate('Subscribers_Manage_Column_Sortable',true,false); } if (isset($GLOBALS['Segment'])) { $GLOBALS['URLQueryString'] = '&Segment[]=' . $GLOBALS['Segment']; } else { $GLOBALS['URLQueryString'] = '&Lists[]=' . $GLOBALS['List']; } $actions = $user->GetEventActivityType(); $GLOBALS['Actions'] = ''; foreach ($actions as $action) { $GLOBALS['Actions'] .= '<option value="' . htmlspecialchars($action,ENT_QUOTES, SENDSTUDIO_CHARSET) . '">'. htmlspecialchars($action,ENT_QUOTES, SENDSTUDIO_CHARSET) . "</option>"; } $GLOBALS['EventTypesJSON'] = GetJSON($actions); $GLOBALS['EventAddForm'] = $this->ParseTemplate('Subscriber_Event_Add',true,false); $GLOBALS['EventJavascript'] = $this->ParseTemplate('Subscribers_Events_Javascript',true,false); $GLOBALS['DatePickerJavascript'] = $this->ParseTemplate('ui.datepicker.custom_iem',true,false); $template = $this->ParseTemplate($subscriber_header_template, true, false); $GLOBALS['List'] = $search_info['List']; $subscriber_customfields = array(); $customfield_ids = $visiblefields; $customfield_ids = $subscriber_api->CheckIntVars($customfield_ids); if (!empty($customfield_ids)) { $subids = array(); foreach ($subscriber_list['subscriberlist'] as $info) { $subids[] = $info['subscriberid']; } $subscriber_customfields = $subscriber_api->GetAllSubscriberCustomFields($listids, array(), $subids, $customfield_ids); unset($subids); } if (!isset($GLOBALS['ColumnCount'])) { $GLOBALS['ColumnCount'] = 0; } $GLOBALS['ColumnCount'] += count($visiblefields); foreach ($subscriber_list['subscriberlist'] as $pos => $subscriberinfo) { $GLOBALS['Columns'] = ''; $GLOBALS['FieldValue'] = ''; $subscriberfields = array(); foreach ($visiblefields as $fieldname) { switch ($fieldname) { case 'emailaddress': $GLOBALS['FieldValue'] = htmlspecialchars($subscriberinfo[$fieldname], ENT_QUOTES, SENDSTUDIO_CHARSET); break; case 'subscribedate': $GLOBALS['FieldValue'] = $this->PrintDate($subscriberinfo['subscribedate']); break; case 'format': $GLOBALS['FieldValue'] = ($subscriberinfo['format'] == 't') ? GetLang('Format_Text') : GetLang('Format_HTML'); break; case 'confirmed': $GLOBALS['FieldValue'] = ($subscriberinfo['confirmed'] == '1') ? GetLang('Confirmed') : GetLang('Unconfirmed'); break; case 'status': $status = GetLang('Active'); if ($subscriberinfo['unsubscribed'] > 0) { $status = GetLang('Unsubscribed'); } if ($subscriberinfo['bounced'] > 0) { $status = GetLang('Bounced'); } $GLOBALS['FieldValue'] = $status; break; default: $GLOBALS['FieldValue'] = ' '; if (is_numeric($fieldname)) { $subfield = $loaded_customfields[$fieldname]; $subid = $subscriberinfo['subscriberid']; /** * If there is no custom field for this subscriber, go to the next field. * This could happen if you view all lists but a field is only associated with one particular list */ if (!isset($subscriber_customfields[$subid])) { continue; } foreach ($subscriber_customfields[$subid] as $cf_p => $cf_details) { if ($cf_details['fieldid'] != $fieldname) { continue; } $GLOBALS['FieldValue'] = htmlspecialchars($subfield->GetRealValue($cf_details['data'],','), ENT_QUOTES, SENDSTUDIO_CHARSET); } } } $GLOBALS['Columns'] .= $this->ParseTemplate('Subscribers_Manage_Row_Column',true,false); } // if we are searching "any" list then we need to adjust the link. if (isset($subscriberinfo['listid'])) { $GLOBALS['List'] = $subscriberinfo['listid']; } if (isset($subscriberinfo['listname'])) { $GLOBALS['MailingListName'] = htmlspecialchars($subscriberinfo['listname'], ENT_QUOTES, SENDSTUDIO_CHARSET); } $GLOBALS['subscriberid'] = $subscriberinfo['subscriberid']; $GLOBALS['SubscriberID'] = $subscriberinfo['subscriberid']; $GLOBALS['EditSubscriberID'] = $subscriberinfo['subscriberid']; if (array_key_exists('Segment', $search_info) && $search_info['Segment'] != 0) { $GLOBALS['SegmentID'] = $search_info['Segment']; $GLOBALS['ExtraParameter'] = '&SegmentID=' . $search_info['Segment']; } else { $GLOBALS['SegmentID'] = 0; $GLOBALS['ExtraParameter'] = ''; } $GLOBALS['SubscriberAction'] = $this->ParseTemplate('Subscribers_Manage_ViewLink', true, false); if ($user->HasAccess('Subscribers', 'Eventsave')) { $GLOBALS['SubscriberAction'] .= $this->ParseTemplate('Subscribers_Manage_EventAddLink', true, false); } if ($user->HasAccess('Subscribers', 'Edit')) { $GLOBALS['SubscriberAction'] .= $this->ParseTemplate('Subscribers_Manage_EditLink', true, false); } if ($user->HasAccess('Subscribers', 'Delete')) { $GLOBALS['DeleteSubscriberID'] = $subscriberinfo['subscriberid']; $GLOBALS['SubscriberAction'] .= $this->ParseTemplate('Subscribers_Manage_DeleteLink', true, false); } $events = $subscriber_api->CountEvents($subscriberinfo['subscriberid']); $GLOBALS['EventButton'] = ''; if ($events) { $GLOBALS['EventButton'] = $this->ParseTemplate('Subscribers_Manage_Row_Eventbutton',true,false); } $subscriberdetails .= $this->ParseTemplate($subscriber_row_template, true, false); } $template = str_replace('%%TPL_' . $subscriber_row_template . '%%', $subscriberdetails, $template); $template = str_replace('%%TPL_Paging%%', $paging, $template); $template = str_replace('%%TPL_Paging_Bottom%%', $GLOBALS['PagingBottom'], $template); echo $template; }
/** * _Valid * Checks to see if the given file name is a valid language file to * include. * * @param String $filename The file name to test */ private function _Valid($filename) { if (strpos($filename, '..') !== false) { return false; } return (is_file($this->base_path . '/' . $filename)); } } header('Content-type: application/json'); $factory = new TokenFactory(); if ($factory->LookIn($_POST['files'])) { $tokens = $factory->GetTokens($_POST['tokens']); $response = array( 'status' => 'OK', 'tokens' => GetJSON($tokens) ); echo GetJSON($response); } else { echo GetJSON(array('status' => 'Failed')); }
/** * EditSubscriber * Prints the 'edit subscriber' form and all appropriate options including custom fields. * * @param Int $listid The list the subscriber is on. This is checked to make sure the user has 'edit' access to the list before anything else. * @param Int $subscriberid The subscriberid to edit. * @param Int $segmentid The segment the subscriber is on. * @param String $msgtype The heading to show when editing a subscriber. This can be either error or success. Used with $msg to display something. * @param String $msg The message to display in the heading. If this is not present, no message is displayed. * * @see GetApi * @see Subscribers_API::GetCustomFieldSettings * @see Lists_API::GetCustomFields * @see Lists_API::Load * @see Lists_API::GetListFormat * * @return Void Doesn't return anything. Prints out the edit form and that's it. */ function EditSubscriber($listid = 0, $subscriberid = 0, $segmentid = 0, $msgtype = 'Error', $msg = false) { $user = GetUser(); $access = $user->HasAccess('Subscribers', 'Edit'); if (!$access) { $this->DenyAccess(); return; } $this->SetupGoogleCalendar(); $search_info = IEM::sessionGet('Search_Subscribers'); $GLOBALS['list'] = $listid; if ($msg && $msgtype) { switch (strtolower($msgtype)) { case 'success': $GLOBALS['Success'] = $msg; $GLOBALS['Message'] = $this->ParseTemplate('SuccessMsg', true, false); break; default: $GLOBALS['Error'] = $msg; $GLOBALS['Message'] = $this->ParseTemplate('ErrorMsg', true, false); } } $SubscriberApi = $this->GetApi('Subscribers'); /** * Get Subscriber record from the database */ $adminAccess = false; // If this user is an admin/list admin/list admintype == a then give permission if ($user->Admin() || $user->ListAdminType() == 'a' || $user->ListAdmin()) { $adminAccess = true; } // Get subscribers from list if ($segmentid == 0) { if (!$adminAccess && !$SubscriberApi->CheckPermission($user->userid, $subscriberid)) { $this->DenyAccess(); return; } $subscriberinfo = $SubscriberApi->LoadSubscriberList($subscriberid, $listid); // Get subscribers from segment } else { if (!$adminAccess) { $segmentapi = $this->GetApi('Segment', true); $segmentapi->Load($segmentid); if ($segmentapi->ownerid != $user->userid && !$user->HasAccess('Segments', 'View', $segmentid)) { $this->DenyAccess(); return; } } $subscriberinfo = $SubscriberApi->LoadSubscriberSegment($subscriberid, $segmentid); $GLOBALS['SegmentID'] = $segmentid; } /** * ----- */ // hmm, the subscriber doesn't exist or can't be loaded? show an error. if (empty($subscriberinfo)) { $GLOBALS['ErrorMessage'] = GetLang('SubscriberDoesntExist_Edit'); $this->DenyAccess(); return; } $list_api = $this->GetApi('Lists'); $list_api->Load($listid); // Log this to "User Activity Log" if (IEM::requestGetGET('Action', '', 'strtolower') != 'save') { IEM::logUserActivity($_SERVER['REQUEST_URI'], 'images/contacts_view.gif', $subscriberinfo['emailaddress']); } $GLOBALS['emailaddress'] = $subscriberinfo['emailaddress']; $GLOBALS['subscriberid'] = $subscriberid; if ($subscriberinfo['requestdate'] == 0) { $GLOBALS['requestdate'] = GetLang('Unknown'); } else { $GLOBALS['requestdate'] = $this->PrintTime($subscriberinfo['requestdate']); } $GLOBALS['requestip'] = ($subscriberinfo['requestip'] == '') ? GetLang('Unknown') : $subscriberinfo['requestip']; if ($subscriberinfo['confirmdate'] == 0) { $GLOBALS['confirmdate'] = GetLang('Unknown'); } else { $GLOBALS['confirmdate'] = $this->PrintTime($subscriberinfo['confirmdate']); } $GLOBALS['confirmip'] = ($subscriberinfo['confirmip'] == '') ? GetLang('Unknown') : $subscriberinfo['confirmip']; $confirmed = ''; foreach (array('1' => 'Confirmed', '0' => 'Unconfirmed') as $confirmoption => $option) { $selected = ($confirmoption == $subscriberinfo['confirmed']) ? ' SELECTED' : ''; $confirmed .= '<option value="' . $confirmoption . '"' . $selected . '>' . GetLang($option) . '</option>'; } $GLOBALS['ConfirmedList'] = $confirmed; $GLOBALS['ShowUnsubscribeInfo'] = 'none'; $subscriber_status = 'a'; if ($subscriberinfo['unsubscribed'] > 0) { $subscriber_status = 'u'; $GLOBALS['unsubscribetime'] = $this->PrintTime($subscriberinfo['unsubscribed']); $GLOBALS['unsubscribeip'] = ($subscriberinfo['unsubscribeip'] == '') ? GetLang('Unknown') : $subscriberinfo['unsubscribeip']; $GLOBALS['ShowUnsubscribeInfo'] = ''; } if ($subscriberinfo['bounced'] > 0) { $subscriber_status = 'b'; } $status = ''; foreach (array('a' => 'Active', 'u' => 'Unsubscribed', 'b' => 'Bounced') as $statusoption => $option) { $selected = ($statusoption == $subscriber_status) ? ' SELECTED' : ''; $status .= '<option value="' . $statusoption . '"' . $selected . '>' . GetLang($option) . '</option>'; } $GLOBALS['StatusList'] = $status; $listformat = $list_api->GetListFormat(); switch ($listformat) { case 't': $format = '<option value="t" SELECTED>' . GetLang('Format_Text') . '</option>'; break; case 'h': $format = '<option value="h" SELECTED>' . GetLang('Format_HTML') . '</option>'; break; case 'b': $selected = ''; if ($subscriberinfo['format'] == 'h') { $selected = ' SELECTED'; } $format = '<option value="h"' . $selected . '>' . GetLang('Format_HTML') . '</option>'; $selected = ''; if ($subscriberinfo['format'] == 't') { $selected = ' SELECTED'; } $format .= '<option value="t"' . $selected . '>' . GetLang('Format_Text') . '</option>'; break; } $GLOBALS['FormatList'] = $format; $customfields = $list_api->GetCustomFields($listid); $extra_javascript = ''; $customfield_display = array(); $customfieldinfo = ''; if (!empty($customfields)) { $customfieldinfo .= $this->ParseTemplate('Subscribers_Edit_Step2_CustomFields', true, false); foreach ($customfields as $pos => $customfield_info) { $GLOBALS['FieldID'] = $customfield_info['fieldid']; if ($customfield_info['required']) { $GLOBALS['Required'] = $this->ParseTemplate('Required', true, false); } else { $GLOBALS['Required'] = $this->ParseTemplate('Not_Required', true, false); } $subscriber_settings = $SubscriberApi->GetCustomFieldSettings($customfield_info['fieldid']); $customfields_api = $this->GetApi('CustomFields'); $customfields_api->fieldid = $customfield_info['fieldid']; $customfields_api->fieldtype = $customfield_info['fieldtype']; $subfield = $customfields_api->LoadSubField(); $subscriber_settings_old = $subscriber_settings; $subscriber_settings = $realValue = $subfield->GetRealValue($subscriber_settings); switch ($customfield_info['fieldtype']) { case 'date': $optionlist = ''; $date_info = array(); if ($subscriber_settings) { $date_parts = explode('/', $subscriber_settings); $date_part_check = $date_parts[0] + $date_parts[1] + $date_parts[2]; if($date_part_check != 0){ for ($i = 0; $i <= 2; $i++) { if(strtolower($subfield->Settings['Key'][$i]) == 'month'){ $date_info['mm'] = $date_parts[$i]; } if(strtolower($subfield->Settings['Key'][$i]) == 'day'){ $date_info['dd'] = $date_parts[$i]; } if(strtolower($subfield->Settings['Key'][$i]) == 'year'){ $date_info['yy'] = $date_parts[$i]; } } } } $extra_javascript .= ' field_'.$customfield_info['fieldid'].'_check = CheckDate("CustomFields['.$customfield_info['fieldid'].']"); if (!field_'.$customfield_info['fieldid'].'_check) { alert("' . sprintf(GetLang('EnterValidDate'), htmlspecialchars($customfield_info['name'], ENT_QUOTES, SENDSTUDIO_CHARSET)) . '"); return false; } '; $template_name = 'Subscribers_View_CustomField_Date'; $fieldsettings = unserialize($customfield_info['fieldsettings']); $GLOBALS['GoogleCalendarButton'] = ''; $GLOBALS['DateJSON'] ='{}'; if (strlen($subscriber_settings)) { $date = explode('/', $subscriber_settings); $datejson = array_combine(array_slice($fieldsettings['Key'], 0, 3), $date); $GLOBALS['DateJSON'] = GetJSON($datejson); $GLOBALS['GoogleCalendarParameters'] = ",true"; } if (strlen($user->googlecalendarusername) && strlen($user->googlecalendarpassword)) { $GLOBALS['GoogleCalendarButton'] = $this->ParseTemplate('google_calendar_button', true); } else { $GLOBALS['GoogleCalendarButton'] = $this->ParseTemplate('google_calendar_button_disabled', true); } $this->Display_CustomField($customfield_info, $date_info); break; case 'radiobutton': $fieldsettings = (is_array($customfield_info['fieldsettings'])) ? $customfield_info['fieldsettings'] : unserialize($customfield_info['fieldsettings']); $default_value = ($subscriber_settings) ? $subscriber_settings : ''; $optionlist = ''; $c = 1; foreach ($fieldsettings['Key'] as $pos => $key) { $selected = ''; if ($key == $default_value) { $selected = ' CHECKED'; } $label_id = htmlspecialchars('CustomFields_' . $customfield_info['fieldid'] . '_'.$key, ENT_QUOTES, SENDSTUDIO_CHARSET); $optionlist .= '<label for="'.$label_id.'"><input type="radio" id="'.$label_id.'" name="CustomFields[' . $customfield_info['fieldid'] . ']" value="' . htmlspecialchars($key, ENT_QUOTES, SENDSTUDIO_CHARSET) . '"' . $selected . '>' . htmlspecialchars($fieldsettings['Value'][$pos], ENT_QUOTES, SENDSTUDIO_CHARSET) . '</label>'; if ($c % 4 == 0) { $optionlist .= '<br/>'; } $c++; } if ($customfield_info['required']) { $extra_javascript .= ' field_'.$customfield_info['fieldid'].'_check = CheckRadio("CustomFields_'.$customfield_info['fieldid'].'"); if (!field_'.$customfield_info['fieldid'].'_check) { alert("' . sprintf(GetLang('ChooseValueForCustomField'), htmlspecialchars($customfield_info['name'], ENT_QUOTES, SENDSTUDIO_CHARSET)) . '"); return false; } '; } break; case 'dropdown': $fieldsettings = (is_array($customfield_info['fieldsettings'])) ? $customfield_info['fieldsettings'] : unserialize($customfield_info['fieldsettings']); $optionlist = ''; $default_value = ($subscriber_settings_old) ? $subscriber_settings_old : ''; $optionlist .= '<option value="">' . $customfield_info['defaultvalue'] . '</option>'; foreach ($fieldsettings['Key'] as $pos => $key) { $selected = ''; if ($key == $default_value) { $selected = ' SELECTED'; } $optionlist .= '<option value="' . htmlspecialchars($key, ENT_QUOTES, SENDSTUDIO_CHARSET) . '"' . $selected . '>' . htmlspecialchars($fieldsettings['Value'][$pos], ENT_QUOTES, SENDSTUDIO_CHARSET) . '</option>'; } if ($customfield_info['required']) { $extra_javascript .= ' fld = document.getElementById("CustomFields['.$customfield_info['fieldid'].']"); selIndex = fld.selectedIndex; if (selIndex < 1) { alert("'.sprintf(GetLang('ChooseOptionForCustomField'), htmlspecialchars($customfield_info['name'], ENT_QUOTES, SENDSTUDIO_CHARSET)) . '"); fld.focus(); return false; } '; } break; case 'checkbox': $fieldsettings = (is_array($customfield_info['fieldsettings'])) ? $customfield_info['fieldsettings'] : unserialize($customfield_info['fieldsettings']); $default_values = (unserialize($subscriber_settings_old)) ? unserialize($subscriber_settings_old) : array(); $optionlist = ''; $c = 1; foreach ($fieldsettings['Key'] as $pos => $key) { $selected = ''; if (in_array($key, $default_values)) { $selected = ' CHECKED'; } $label = htmlspecialchars('CustomFields[' . $customfield_info['fieldid'] . '][' . $key . ']', ENT_QUOTES, SENDSTUDIO_CHARSET); $optionlist .= '<label for="' . $label . '"><input type="checkbox" name="CustomFields[' . $customfield_info['fieldid'] . '][' . $pos . ']" id="' . $label . '" value="' . htmlspecialchars($key, ENT_QUOTES, SENDSTUDIO_CHARSET) . '"' . $selected . '>' . htmlspecialchars($fieldsettings['Value'][$pos], ENT_QUOTES, SENDSTUDIO_CHARSET) . '</label>'; if ($c % 4 == 0) { $optionlist .= '<br/>'; } $c++; } if ($customfield_info['required']) { $extra_javascript .= ' CheckboxCheck = CheckMultiple("CustomFields[' . $customfield_info['fieldid'] . ']", f); if (!CheckboxCheck) { alert("' . sprintf(GetLang('ChooseValueForCustomField'), htmlspecialchars($customfield_info['name'], ENT_QUOTES, SENDSTUDIO_CHARSET)) . '"); return false; } '; } break; default: if ($customfield_info['required']) { $extra_javascript .= ' if (document.getElementById("CustomFields['.$customfield_info['fieldid'].']").value == "") { alert("' . sprintf(GetLang('EnterValueForCustomField'), htmlspecialchars($customfield_info['name'], ENT_QUOTES, SENDSTUDIO_CHARSET)) . '"); document.getElementById("CustomFields['.$customfield_info['fieldid'].']").focus(); return false; } '; } $optionlist = ''; $subscriber_settings = $subscriber_settings; } $GLOBALS['OptionList'] = $optionlist; $GLOBALS['DefaultValue'] = ''; if ( $realValue || $realValue == 0){ $GLOBALS['DefaultValue'] = htmlspecialchars($realValue, ENT_QUOTES, SENDSTUDIO_CHARSET); }elseif( $customfield_info['required'] ){ $GLOBALS['DefaultValue'] = htmlspecialchars($subscriber_settings_old, ENT_QUOTES, SENDSTUDIO_CHARSET); } $GLOBALS['FieldName'] = htmlspecialchars($customfield_info['name'], ENT_QUOTES, SENDSTUDIO_CHARSET); $GLOBALS['CustomFieldID'] = $customfield_info['fieldid']; $customfield_display[] = $this->ParseTemplate('CustomField_Edit_' . $customfield_info['fieldtype'], true, false); } $column1 = $column2 = array(); if (count($customfield_display) > 9) { $customfieldinfo_template = 'Subscribers_customfieldinfo_twocolumns'; $split = ceil(count($customfield_display) / 2); for ($i = 0; $i < $split; $i++) { $column1[] = $customfield_display[$i]; if (isset($customfield_display[$i + $split])) { $column2[] = $customfield_display[$i + $split]; } else { $column2[] = '<td> </td><td> </td>'; } } $GLOBALS['CustomFieldInfo_1'] = '<tr>' . implode('</tr><tr>',$column1) . '</tr>'; $GLOBALS['CustomFieldInfo_2'] = '<tr>' . implode('</tr><tr>',$column2) . '</tr>'; } else { $customfieldinfo_template = 'Subscribers_customfieldinfo_onecolumn'; $GLOBALS['CustomFieldInfo_1'] = ''; foreach ($customfield_display as $field) { $GLOBALS['CustomFieldInfo_1'] .= '<tr>' . $field . '</tr>'; } } $GLOBALS['CustomFieldInfo'] = $customfieldinfo . $this->ParseTemplate($customfieldinfo_template,true); $GLOBALS['ExtraJavascript'] = $extra_javascript; } $GLOBALS['listid'] = $listid; $GLOBALS['CustomDatepickerUI'] = $this->ParseTemplate('UI.DatePicker.Custom_IEM', true); $actions = $user->GetEventActivityType(); $GLOBALS['Actions'] = ''; foreach ($actions as $action) { $GLOBALS['Actions'] .= '<option value="' . htmlspecialchars($action,ENT_QUOTES, SENDSTUDIO_CHARSET) . '">'. htmlspecialchars($action,ENT_QUOTES, SENDSTUDIO_CHARSET) . "</option>"; } $GLOBALS['SubscriberEvents_Intro'] = GetLang('SubscriberEvents_Intro'); if ($user->HasAccess('Subscribers','EventSave')) { $GLOBALS['SubscriberEvents_Intro'] .= GetLang('SubscriberEvents_Intro_AddEvent'); } if (IEM::sessionGet('gcal_allday')) { $GLOBALS['GoogleCalendarAllDay'] = 'true'; } else { $GLOBALS['GoogleCalendarAllDay'] = 'false'; } if (strlen($user->googlecalendarusername) && strlen($user->googlecalendarpassword)) { $GLOBALS['GoogleCalendarEnabled'] = 'true'; } else { $GLOBALS['GoogleCalendarEnabled'] = 'false'; } $GLOBALS['EventTypesJSON'] = GetJSON($actions); $GLOBALS['EventAddForm'] = $this->ParseTemplate('Subscriber_Event_Add',true,false); $this->ParseTemplate('Subscribers_Edit_Step2'); }
/** * Process * Prints out the custom fields list. * * @see PrintHeader * @see GetApi * @see GetUser * @see User_API::GetLists * @see Lists_API::GetCustomFields * @see Forms_API::GetUserForms * * @return Void Prints out the list, doesn't return anything. */ function Process() { //$this->PrintHeader(true); $listapi = $this->GetApi('Lists'); $formapi = $this->GetApi('Forms'); $GLOBALS['ContentArea'] = $_GET['ContentArea']; $GLOBALS['EditorName'] = 'myDeveditControl'; if (isset($_GET['EditorName'])) { $GLOBALS['EditorName'] = $_GET['EditorName']; } $template = $this->ParseTemplate('ShowCustomFields_List_Start', true, false); $user = GetUser(); $lists = $user->GetLists(); $customfieldlist = ''; $GLOBALS['AreaName'] = GetLang('ShowCustomFields_BasicAreas'); $customfieldlist .= $this->ParseTemplate('ShowCustomFields_List_List_Start', true, false); $GLOBALS['CustomFieldRequired'] = ''; $cf_bucket = array(); // store CF details for JS insertion foreach (array('ListName', 'UnsubscribeLink', 'EmailAddress', 'ConfirmLink', 'SubscribeDate', 'TodaysDate') as $p => $area) { $GLOBALS['CustomFieldName'] = GetLang('CustomFields_' . $area); $GLOBALS['LinkName'] = strtolower($area); $GLOBALS['CustomFieldID'] = "field_" . $GLOBALS['LinkName']; $customfieldlist .= $this->ParseTemplate('ShowCustomFields_List_CustomFields', true, false); $cf_bucket[$GLOBALS['CustomFieldID']] = $GLOBALS['LinkName']; } if (check('ListLinks')) { foreach (array('WebVersion', 'MailingListArchive') as $p => $area) { $GLOBALS['CustomFieldName'] = GetLang('CustomFields_' . $area); $GLOBALS['LinkName'] = strtolower($area); $GLOBALS['CustomFieldID'] = "field_" . $GLOBALS['LinkName']; $customfieldlist .= $this->ParseTemplate('ShowCustomFields_List_CustomFields', true, false); $cf_bucket[$GLOBALS['CustomFieldID']] = $GLOBALS['LinkName']; } } foreach (array('CompanyName', 'CompanyAddress', 'CompanyPhone') as $p => $area) { $GLOBALS['CustomFieldName'] = GetLang('CustomFields_' . $area); $GLOBALS['LinkName'] = strtolower($area); $GLOBALS['CustomFieldID'] = "field_" . $GLOBALS['LinkName']; $customfieldlist .= $this->ParseTemplate('ShowCustomFields_List_CustomFields', true, false); $cf_bucket[$GLOBALS['CustomFieldID']] = $GLOBALS['LinkName']; } if (SENDSTUDIO_IPTRACKING) { $GLOBALS['CustomFieldName'] = GetLang('CustomFields_IPAddress'); $GLOBALS['LinkName'] = 'ipaddress'; $GLOBALS['CustomFieldID'] = "field_" . $GLOBALS['LinkName']; $customfieldlist .= $this->ParseTemplate('ShowCustomFields_List_CustomFields', true, false); $cf_bucket[$GLOBALS['CustomFieldID']] = $GLOBALS['LinkName']; } $customfieldlist .= $this->ParseTemplate('ShowCustomFields_List_List_End', true, false); $session_list = false; $session_autoresponder = IEM::sessionGet('Autoresponders'); $pagename = (isset($_GET['PageName'])) ? strtolower($_GET['PageName']) : false; if ($session_autoresponder && $pagename == 'autoresponders') { $session_list = $session_autoresponder['list']; } foreach ($lists as $listid => $listdetails) { if ($session_list && $session_list != $listid) { continue; } $customfields = $listapi->GetCustomFields($listid); if (empty($customfields)) { continue; // if there are no custom fields for this list, try the next one. } $GLOBALS['AreaName'] = $this->TruncateInMiddle(sprintf(GetLang('ShowCustomFields_AreaName'), $listdetails['name']), 80); $customfieldlist .= $this->ParseTemplate('ShowCustomFields_List_List_Start', true, false); foreach ($customfields as $pos => $details) { $GLOBALS['CustomFieldName'] = htmlspecialchars($details['name']); $GLOBALS['LinkName'] = addslashes($details['name']); $GLOBALS['CustomFieldID'] = "field_" . $details['fieldid']; $GLOBALS['CustomFieldRequired'] = ''; if ($details['required']) { $GLOBALS['CustomFieldRequired'] = GetLang('CustomFieldRequired_Popup'); } $customfieldlist .= $this->ParseTemplate('ShowCustomFields_List_CustomFields', true, false); $cf_bucket[$GLOBALS['CustomFieldID']] = $details['name']; } $customfieldlist .= $this->ParseTemplate('ShowCustomFields_List_List_End', true, false); } $form_userid = $user->userid; if ($user->Admin()) { $form_userid = 0; } $modify_forms = $formapi->GetUserForms($form_userid, 'modify'); if (!empty($modify_forms)) { $GLOBALS['AreaName'] = GetLang('ShowCustomFields_ModifyForms'); $customfieldlist .= $this->ParseTemplate('ShowCustomFields_List_List_Start', true, false); foreach ($modify_forms as $p => $formdetails) { $GLOBALS['CustomFieldName'] = htmlspecialchars($formdetails['name']); $GLOBALS['LinkName'] = 'modifydetails_' . $formdetails['formid']; $GLOBALS['CustomFieldID'] = "field_" . $GLOBALS['LinkName']; $customfieldlist .= $this->ParseTemplate('ShowCustomFields_List_CustomFields', true, false); $cf_bucket[$GLOBALS['CustomFieldID']] = $GLOBALS['LinkName']; } $customfieldlist .= $this->ParseTemplate('ShowCustomFields_List_List_End', true, false); } $sendfriend_forms = $formapi->GetUserForms($form_userid, 'friend'); if (!empty($sendfriend_forms)) { $GLOBALS['AreaName'] = GetLang('ShowCustomFields_SendToFriendForms'); $customfieldlist .= $this->ParseTemplate('ShowCustomFields_List_List_Start', true, false); foreach ($sendfriend_forms as $p => $formdetails) { $GLOBALS['CustomFieldName'] = htmlspecialchars($formdetails['name']); $GLOBALS['LinkName'] = 'sendfriend_' . $formdetails['formid']; $GLOBALS['CustomFieldID'] = "field_" . $GLOBALS['LinkName']; $customfieldlist .= $this->ParseTemplate('ShowCustomFields_List_CustomFields', true, false); $cf_bucket[$GLOBALS['CustomFieldID']] = $GLOBALS['LinkName']; } $customfieldlist .= $this->ParseTemplate('ShowCustomFields_List_List_End', true, false); } $GLOBALS['CustomFieldJSON'] = GetJSON($cf_bucket) . ';'; $customfieldlist .= $this->ParseTemplate('ShowCustomFields_List_End', true, false); $template = str_replace('%%TPL_ShowCustomFields_List_Details%%', $customfieldlist, $template); echo $template; //$this->PrintFooter(true); }
/** * EventList * Prints a list of events in HTML * * @param Integer $subscriberid The subscriberid to list events for * * @see Subscriber_API::GetEvents * @see GetJSON * * @return Void Prints out the step, doesn't return anything. */ function EventList($subscriberid) { $user = GetUser(); $sortdetails = array( 'SortBy' => 'eventdate', 'Direction' => 'desc' ); $events = $this->api->GetEvents($subscriberid,0,'all',false,$sortdetails); $events_list = ''; $GLOBALS['SubscriberID'] = $subscriberid; foreach ($events as $event) { $event['date'] = $this->PrintDate($event['eventdate'],'d/n/Y'); $event['time'] = $this->PrintDate($event['eventdate'],'g:i A'); $GLOBALS['eventid'] = $event['eventid']; $GLOBALS['Subject'] = htmlspecialchars($event['eventsubject'],ENT_QUOTES, SENDSTUDIO_CHARSET); $GLOBALS['Type'] = htmlspecialchars($event['eventtype'],ENT_QUOTES, SENDSTUDIO_CHARSET); $GLOBALS['Date'] = $this->PrintTime($event['eventdate']); $GLOBALS['Notes'] = nl2br(htmlspecialchars($event['eventnotes'])); $GLOBALS['EventJSON'] = GetJSON($event); $GLOBALS['EventLinkDisplay'] = 'none'; $GLOBALS['EventDeleteLink'] = ''; $GLOBALS['EventEditLink'] = ''; $GLOBALS['EventOr'] = ''; if ($user->HasAccess('Subscribers','Eventdelete')) { $GLOBALS['EventDeleteLink'] = $this->ParseTemplate('subscribers_manage_eventdeletelink',true,false); $GLOBALS['EventLinkDisplay'] = 'inline'; } if ($user->HasAccess('Subscribers','Eventupdate')) { $GLOBALS['EventEditLink'] = $this->ParseTemplate('subscribers_manage_eventeditlink',true,false); $GLOBALS['EventLinkDisplay'] = 'inline'; } if ($GLOBALS['EventDeleteLink'] != '' && $GLOBALS['EventEditLink'] != '') { $GLOBALS['EventOr'] = strtolower(GetLang('OR')); } $this->ParseTemplate('Subscriber_Event'); } }
/** * _ajax * Handle ALL AJAX requests for Trigger Emails functionalities. * * The function act as a "controller" that re-direct all ajax requests to the appropriate functions. * It will return a text that can be converted to JSON javascript notation. * * @param Array $parameters Any parameters that need to be parsed to this function (OPTIONAL) * @return String Returns response string that can be outputted to the browser */ private function _ajax($parameters = array()) { $requestType = IEM::requestGetPOST('ajaxType', '', 'trim'); if (empty($requestType)) { return "{status:false, data:'Ajax Type cannot be empty'}"; } if (!is_callable(array($this, '_ajax_' . $requestType))) { return "{status:false, data:'Invalid Ajax Type'}"; } $callableName = "_ajax_{$requestType}"; list($status, $data) = $this->$callableName($parameters); return GetJSON(array('status' => $status, 'data' => $data)); }
/** * GetJSON * Get JSON representation of specified data. * This is just an interface to choose between using PHP's own json_encode if available (ie. using PHP5 or above) * or appropriate (json_encode does not encode charactersets other than UTF-8), otherwise * it will emulate what json_encode does. * * @param Mixed $data Data to be encoded to JSON format * * @return String Returns JSON formatted representation of the data */ function GetJSON($data) { if (strtolower(SENDSTUDIO_CHARSET) == 'utf-8' && function_exists('json_encode')) { return json_encode($data); } else { if (is_null($data)) { return 'null'; } elseif ($data === true) { return 'true'; } elseif ($data === false) { return 'false'; } elseif (is_float($data)) { return str_replace(",", ".", strval($data)); } elseif (is_numeric($data)) { return intval($data); } elseif (is_scalar($data)) { return '"' . addcslashes(strval($data), "\\\n\r\t\/\x0B\x0C\"\'") . '"'; } else { $tempIsArray = true; for ($i = 0, $j = count($data), reset($data); $i < $j; $i++, next($data)) { if (key($data) !== $i) { $tempIsArray = false; break; } } $output = array(); if ($tempIsArray) { foreach ($data as $value) { array_push($output, GetJSON($value)); } return '[' . implode(',',$output) . ']'; } else { foreach ($data as $key => $value) { array_push($output, GetJSON($key) . ':' . GetJSON($value)); } return '{' . implode(',',$output) . '}'; } } } }
/** * _succeed * Return a JSON-formatted success status message. * * @return Void Doesn't return anything. */ private function _succeed() { echo GetJSON(array('status'=>'OK')) . "\n"; }
function GetUserInput() { if (!empty($_POST["submit"])) { $street = $_POST["street"]; $city = $_POST["city"]; $state = $_POST["state"]; $degree = $_POST["degree"]; echo "<script type='text/javascript'>\n SaveUserInput('" . $street . "','" . $city . "','" . $state . "','" . $degree . "');\n </script>"; if (!empty($street) && !empty($city) && !empty($state) && !empty($degree)) { $GeoCodeFile = simplexml_load_file("http://maps.google.com/maps/api/geocode/xml?address=" . $street . "," . $city . "," . $state); $Location = GetLocation($GeoCodeFile); $CallAPI = "https://api.forecast.io/forecast/7d75118b73458c705f9b911f7d637507/" . $Location[0] . "," . $Location[1] . "?units=" . $degree . "&exclude=flags"; echo $CallAPI; GetJSON($CallAPI, $degree); } } }
/** * Process * Works out what's going on. * The API does the loading, saving, updating - this page just displays the right form(s), checks password validation and so on. * After that, it'll print a success/failure message depending on what happened. * It also checks to make sure that you're an admin before letting you add or delete. * It also checks you're not going to delete your own account. * If you're not an admin user, it won't let you edit anyone elses account and it won't let you delete your own account either. * * @see PrintHeader * @see ParseTemplate * @see IEM::getDatabase() * @see GetUser * @see GetLang * @see User_API::Set * @see PrintEditForm * @see CheckUserSystem * @see PrintManageUsers * @see User_API::Find * @see User_API::Admin * @see PrintFooter * * @return Void Doesn't return anything, passes control over to the relevant function and prints that functions return message. */ function Process() { $action = (isset($_GET['Action'])) ? strtolower($_GET['Action']) : ''; if (!in_array($action, $this->PopupWindows)) { $this->PrintHeader(); } $thisuser = IEM::getCurrentUser(); $checkaction = $action; if ($action == 'generatetoken') { $checkaction = 'manage'; } if (!$thisuser->HasAccess('users', $checkaction)) { $this->DenyAccess(); } if ($action == 'processpaging') { $this->SetPerPage($_GET['PerPageDisplay']); $action = ''; } switch ($action) { case 'generatetoken': $check_fields = array('username', 'fullname', 'emailaddress'); foreach ($check_fields as $field) { if (!isset($_POST[$field])) { exit; } $$field = $_POST[$field]; } $user = GetUser(); echo htmlspecialchars(sha1($username . $fullname . $emailaddress . GetRealIp(true) . time() . microtime()), ENT_QUOTES, SENDSTUDIO_CHARSET); exit; break; case 'save': $userid = (isset($_GET['UserID'])) ? $_GET['UserID'] : 0; if (empty($_POST)) { $GLOBALS['Error'] = GetLang('UserNotUpdated'); $GLOBALS['Message'] = $this->ParseTemplate('ErrorMsg', true, false); $this->PrintEditForm($userid); break; } $user = GetUser($userid); $username = false; if (isset($_POST['username'])) { $username = $_POST['username']; } $userfound = $user->Find($username); $error = false; $template = false; $duplicate_username = false; if ($userfound && $userfound != $userid) { $duplicate_username = true; $error = GetLang('UserAlreadyExists'); } $warnings = array(); $GLOBALS['Message'] = ''; if (!$duplicate_username) { $to_check = array(); foreach (array('status' => 'isLastActiveUser', 'admintype' => 'isLastSystemAdmin') as $area => $desc) { if (!isset($_POST[$area])) { $to_check[] = $desc; } if (isset($_POST[$area]) && $_POST[$area] == '0') { $to_check[] = $desc; } } if ($user->isAdmin()) { $to_check[] = 'isLastSystemAdmin'; } $error = $this->CheckUserSystem($userid, $to_check); if (!$error) { $smtptype = (isset($_POST['smtptype'])) ? $_POST['smtptype'] : 0; // Make sure smtptype is eiter 0 or 1 if ($smtptype != 1) { $smtptype = 0; } /** * This was added, because User's API uses different names than of the HTML form names. * HTML form names should stay the same to keep it consistant throught the application * * This will actually map HTML forms => User's API fields */ $areaMapping = array( 'trialuser' => 'trialuser', 'groupid' => 'groupid', 'username' => 'username', 'fullname' => 'fullname', 'emailaddress' => 'emailaddress', 'status' => 'status', 'admintype' => 'admintype', 'listadmintype' => 'listadmintype', 'segmentadmintype' => 'segmentadmintype', 'templateadmintype' => 'templateadmintype', 'editownsettings' => 'editownsettings', 'usertimezone' => 'usertimezone', 'textfooter' => 'textfooter', 'htmlfooter' => 'htmlfooter', 'infotips' => 'infotips', 'smtp_server' => 'smtpserver', 'smtp_u' => 'smtpusername', 'smtp_p' => 'smtppassword', 'smtp_port' => 'smtpport', 'usewysiwyg' => 'usewysiwyg', 'usexhtml' => 'usexhtml', 'enableactivitylog' => 'enableactivitylog', 'xmlapi' => 'xmlapi', 'xmltoken' => 'xmltoken', 'googlecalendarusername' => 'googlecalendarusername', 'googlecalendarpassword' => 'googlecalendarpassword', 'user_language' => 'user_language', 'adminnotify_email' => 'adminnotify_email', 'adminnotify_send_flag' => 'adminnotify_send_flag', 'adminnotify_send_threshold' => 'adminnotify_send_threshold', 'adminnotify_send_emailtext' => 'adminnotify_send_emailtext', 'adminnotify_import_flag' => 'adminnotify_import_flag', 'adminnotify_import_threshold' => 'adminnotify_import_threshold', 'adminnotify_import_emailtext' => 'adminnotify_import_emailtext' ); $group = API_USERGROUPS::getRecordById($_POST['groupid']); $totalEmails = (int) $group['limit_totalemailslimit']; $unlimitedEmails = $totalEmails == 0; // set fields foreach ($areaMapping as $p => $area) { $val = (isset($_POST[$p])) ? $_POST[$p] : ''; if (in_array($area, array('status', 'editownsettings'))) { if ($userid == $thisuser->userid) { $val = $thisuser->$area; } } $user->Set($area, $val); } // activity type $activity = IEM::requestGetPOST('eventactivitytype', '', 'trim'); if (!empty($activity)) { $activity_array = explode("\n", $activity); for ($i = 0, $j = count($activity_array); $i < $j; ++$i) { $activity_array[$i] = trim($activity_array[$i]); } } else { $activity_array = array(); } $user->Set('eventactivitytype', $activity_array); // the 'limit' things being on actually means unlimited. so check if the value is NOT set. foreach (array('permonth', 'perhour', 'maxlists') as $p => $area) { $limit_check = 'limit' . $area; $val = 0; if (!isset($_POST[$limit_check])) { $val = (isset($_POST[$area])) ? $_POST[$area] : 0; } $user->Set($area, $val); } if (SENDSTUDIO_MAXHOURLYRATE > 0) { if ($user->Get('perhour') == 0 || ($user->Get('perhour') > SENDSTUDIO_MAXHOURLYRATE)) { $user_hourly = $this->FormatNumber($user->Get('perhour')); if ($user->Get('perhour') == 0) { $user_hourly = GetLang('UserPerHour_Unlimited'); } $warnings[] = sprintf(GetLang('UserPerHourOverMaxHourlyRate'), $this->FormatNumber(SENDSTUDIO_MAXHOURLYRATE), $user_hourly); } } if ($smtptype == 0) { $user->Set('smtpserver', ''); $user->Set('smtpusername', ''); $user->Set('smtppassword', ''); $user->Set('smtpport', 25); } if ($_POST['ss_p'] != '') { if ($_POST['ss_p_confirm'] != '' && $_POST['ss_p_confirm'] == $_POST['ss_p']) { $user->Set('password', $_POST['ss_p']); } else { $error = GetLang('PasswordsDontMatch'); } } } if (!$error) { $user->RevokeAccess(); $temp = array(); if (!empty($_POST['permissions'])) { foreach ($_POST['permissions'] as $area => $p) { foreach ($p as $subarea => $k) { $temp[$subarea] = $user->GrantAccess($area, $subarea); } } } } } if (!$error) { $result = $user->Save(); if ($result) { FlashMessage(GetLang('UserUpdated'), SS_FLASH_MSG_SUCCESS, IEM::urlFor('Users')); } else { $GLOBALS['Message'] = GetFlashMessages(); $GLOBALS['Error'] = GetLang('UserNotUpdated'); $GLOBALS['Message'] .= $this->ParseTemplate('ErrorMsg', true, false); } } else { $GLOBALS['Error'] = $error; $GLOBALS['Message'] = $this->ParseTemplate('ErrorMsg', true, false); } if (!empty($warnings)) { $GLOBALS['Warning'] = implode('<br/>', $warnings); $GLOBALS['Message'] .= $this->ParseTemplate('WarningMsg', true, false); } $this->PrintEditForm($userid); break; case 'add': $temp = get_available_user_count(); if ($temp['normal'] == 0 && $temp['trial'] == 0) { $this->PrintManageUsers(); break; } $this->PrintEditForm(0); break; case 'delete': $users = IEM::requestGetPOST('users', array(), 'intval'); $deleteData = (IEM::requestGetPOST('deleteData', 0, 'intval') == 1); $this->DeleteUsers($users, $deleteData); break; case 'create': $user = New User_API(); $warnings = array(); $fields = array( 'trialuser', 'username', 'fullname', 'emailaddress', 'status', 'admintype', 'editownsettings', 'listadmintype', 'segmentadmintype', 'usertimezone', 'textfooter', 'htmlfooter', 'templateadmintype', 'infotips', 'smtpserver', 'smtpusername', 'smtpport', 'usewysiwyg', 'enableactivitylog', 'xmlapi', 'xmltoken', 'googlecalendarusername','googlecalendarpassword', 'adminnotify_email','adminnotify_send_flag','adminnotify_send_threshold', 'adminnotify_send_emailtext','adminnotify_import_flag','adminnotify_import_threshold', 'adminnotify_import_emailtext' ); if (!$user->Find($_POST['username'])) { foreach ($fields as $p => $area) { $val = (isset($_POST[$area])) ? $_POST[$area] : ''; $user->Set($area, $val); } // activity type $activity = IEM::requestGetPOST('eventactivitytype', '', 'trim'); if (!empty($activity)) { $activity_array = explode("\n", $activity); for ($i = 0, $j = count($activity_array); $i < $j; ++$i) { $activity_array[$i] = trim($activity_array[$i]); } } else { $activity_array = array(); } $user->Set('eventactivitytype', $activity_array); // the 'limit' things being on actually means unlimited. so check if the value is NOT set. foreach (array('permonth', 'perhour', 'maxlists') as $p => $area) { $limit_check = 'limit' . $area; $val = 0; if (!isset($_POST[$limit_check])) { $val = (isset($_POST[$area])) ? $_POST[$area] : 0; } $user->Set($area, $val); } if (SENDSTUDIO_MAXHOURLYRATE > 0) { if ($user->Get('perhour') == 0 || ($user->Get('perhour') > SENDSTUDIO_MAXHOURLYRATE)) { $user_hourly = $this->FormatNumber($user->Get('perhour')); if ($user->Get('perhour') == 0) { $user_hourly = GetLang('UserPerHour_Unlimited'); } $warnings[] = sprintf(GetLang('UserPerHourOverMaxHourlyRate'), $this->FormatNumber(SENDSTUDIO_MAXHOURLYRATE), $user_hourly); } } // this has a different post value otherwise firefox tries to pre-fill it. $smtp_password = ''; if (isset($_POST['smtp_p'])) { $smtp_password = $_POST['smtp_p']; } $user->Set('smtppassword', $smtp_password); $error = false; if ($_POST['ss_p'] != '') { if ($_POST['ss_p_confirm'] != '' && $_POST['ss_p_confirm'] == $_POST['ss_p']) { $user->Set('password', $_POST['ss_p']); } else { $error = GetLang('PasswordsDontMatch'); } } if (!$error) { if (!empty($_POST['permissions'])) { foreach ($_POST['permissions'] as $area => $p) { foreach ($p as $subarea => $k) { $user->GrantAccess($area, $subarea); } } } if (!empty($_POST['lists'])) { $user->GrantListAccess($_POST['lists']); } if (!empty($_POST['templates'])) { $user->GrantTemplateAccess($_POST['templates']); } if (!empty($_POST['segments'])) { $user->GrantSegmentAccess($_POST['segments']); } $GLOBALS['Message'] = ''; if (!empty($warnings)) { $GLOBALS['Warning'] = implode('<br/>', $warnings); $GLOBALS['Message'] .= $this->ParseTemplate('WarningMsg', true, false); } $user->Set('gettingstarted', 0); $user->Set('groupid', (int) IEM_Request::getParam('groupid')); $result = $user->Create(); if ($result == '-1') { FlashMessage(GetLang('UserNotCreated_License'), SS_FLASH_MSG_ERROR, IEM::urlFor('Users')); break; } else { if ($result) { FlashMessage(GetLang('UserCreated'), SS_FLASH_MSG_SUCCESS, IEM::urlFor('Users')); break; } else { FlashMessage(GetLang('UserNotCreated'), SS_FLASH_MSG_ERROR, IEM::urlFor('Users')); } } } else { $GLOBALS['Error'] = $error; } } else { $GLOBALS['Error'] = GetLang('UserAlreadyExists'); } $GLOBALS['Message'] = $this->ParseTemplate('ErrorMsg', true, false); $details = array(); foreach (array('FullName', 'EmailAddress', 'Status', 'AdminType', 'ListAdminType', 'SegmentAdminType', 'TemplateAdminType', 'InfoTips', 'forcedoubleoptin', 'forcespamcheck', 'smtpserver', 'smtpusername', 'smtpport') as $p => $area) { $lower = strtolower($area); $val = (isset($_POST[$lower])) ? $_POST[$lower] : ''; $details[$area] = $val; } $this->PrintEditForm(0, $details); break; case 'edit': $userid = IEM::requestGetGET('UserID', 0, 'intval'); if ($userid == 0) { $this->DenyAccess(); } $this->PrintEditForm($userid); break; case 'sendpreviewdisplay': $this->PrintHeader(true); $this->SendTestPreviewDisplay('index.php?Page=Users&Action=SendPreview', 'self.parent.getSMTPPreviewParameters()'); $this->PrintFooter(true); break; case 'testgooglecalendar': $status = array( 'status' => false, 'message' => '' ); try { $details = array( 'username' => $_REQUEST['gcusername'], 'password' => $_REQUEST['gcpassword'] ); $this->GoogleCalendarAdd($details, true); $status['status'] = true; $status['message'] = GetLang('GooglecalendarTestSuccess'); } catch (Exception $e) { $status['message'] = GetLang('GooglecalendarTestFailure'); } print GetJSON($status); break; case 'sendpreview': $this->SendTestPreview(); break; default: $this->PrintManageUsers(); break; } if (!in_array($action, $this->PopupWindows)) { $this->PrintFooter(); } }
GetJSON(); } else { /* if ( $browser ) { print "<p>"; print "$auctionsFile is ". floor($timeDiff / 60) ." minutes old.<br>"; print "Auction House last updated: $lastModifiedEpochPretty<br>"; print "Not updating...<br>"; print "</p>"; } else { print "$auctionsFile is ". floor($timeDiff / 60) ." minutes old.\n"; print "Auction House last updated: $lastModifiedEpochPretty\n"; print "Not updating...\n"; } */ GetJSON(); } @($auctionsJSON = file_get_contents($auctionsFile)); $auctions = json_decode($auctionsJSON, true); unset($auctionsJSON); // if ( $browser ) { // print "<table>"; // } foreach ($chars as $char) { $char = trim($char); if ($browser) { print "<table border=\"1\" width=\"300px\">"; print "<tr><td bgcolor=\"black\" align=\"center\"><font color=\"white\"><b>{$char}</b></font></td></tr>"; } else { print "\n{$char}\n\n"; }
/** * ViewSubscriber * Prints the 'view subscriber' page and all appropriate options including custom fields. * * @param Int $listid The list the subscriber is on. This is checked to make sure the user has 'manage' access to the list before anything else. * @param Int $subscriberid The subscriberid to view. * @param Int $segmentid The ID of the segment that the subscriber is going to be fetched from * @param String $msgtype The heading to show when viewing a subscriber. This can be either error or success. Used with $msg to display something. * @param String $msg The message to display in the heading. If this is not present, no message is displayed. * * @see GetApi * @see Subscribers_API::GetCustomFieldSettings * @see Lists_API::GetCustomFields * @see Lists_API::Load * @see Lists_API::GetListFormat * * @return Void Doesn't return anything. Prints out the view form and that's it. */ function ViewSubscriber($listid = 0, $subscriberid = 0, $segmentid = 0, $msgtype = 'Error', $msg = false) { $user = GetUser(); $access = $user->HasAccess('Subscribers', 'Manage'); if (!$access) { $this->DenyAccess(); return; } $this->SetupGoogleCalendar(); $search_info = IEM::sessionGet('Search_Subscribers'); $GLOBALS['list'] = $listid; if ($msg && $msgtype) { switch (strtolower($msgtype)) { case 'success': $GLOBALS['Success'] = $msg; $GLOBALS['Message'] = $this->ParseTemplate('SuccessMsg', true, false); break; default: $GLOBALS['Error'] = $msg; $GLOBALS['Message'] = $this->ParseTemplate('ErrorMsg', true, false); } } $SubscriberApi = $this->GetApi('Subscribers'); $subscriberinfo = false; /** * Get Subscriber record from the database */ $adminAccess = false; // If this user is an admin/list admin/list admintype == a then give permission if ($user->Admin() || $user->ListAdminType() == 'a' || $user->ListAdmin()) { $adminAccess = true; } // Get subscribers from list if ($segmentid == 0) { if (!$adminAccess && !$SubscriberApi->CheckPermission($user->userid, $subscriberid)) { $this->DenyAccess(); return; } $subscriberinfo = $SubscriberApi->LoadSubscriberList($subscriberid, $listid); // Get subscribers from segment } else { if (!$adminAccess) { $segmentapi = $this->GetApi('Segment', true); $segmentapi->Load($segmentid); if ($segmentapi->ownerid != $user->userid && !$user->HasAccess('Segments', 'View', $segmentid)) { $this->DenyAccess(); return; } } $subscriberinfo = $SubscriberApi->LoadSubscriberSegment($subscriberid, $segmentid); } /** * ----- */ // hmm, the subscriber doesn't exist or can't be loaded? show an error. if (empty($subscriberinfo)) { $GLOBALS['ErrorMessage'] = GetLang('SubscriberDoesntExist_View'); $this->DenyAccess(); return; } // Log this to "User Activity Log" $logURL = SENDSTUDIO_APPLICATION_URL . '/admin/index.php?Page=Subscribers&Action=Edit&List=' . $_GET['List'] . '&id=' . $_GET['id']; IEM::logUserActivity($logURL, 'images/contacts_view.gif', $subscriberinfo['emailaddress']); $list_api = $this->GetApi('Lists'); $list_api->Load($listid); $GLOBALS['emailaddress'] = $subscriberinfo['emailaddress']; $GLOBALS['subscriberid'] = $subscriberid; if ($subscriberinfo['requestdate'] == 0) { $GLOBALS['requestdate'] = GetLang('Unknown'); } else { $GLOBALS['requestdate'] = $this->PrintTime($subscriberinfo['requestdate']); } $GLOBALS['requestip'] = ($subscriberinfo['requestip'] == '') ? GetLang('Unknown') : $subscriberinfo['requestip']; if ($subscriberinfo['confirmdate'] == 0) { $GLOBALS['confirmdate'] = GetLang('Unknown'); } else { $GLOBALS['confirmdate'] = $this->PrintTime($subscriberinfo['confirmdate']); } $GLOBALS['confirmip'] = ($subscriberinfo['confirmip'] == '') ? GetLang('Unknown') : $subscriberinfo['confirmip']; if ($subscriberinfo['confirmed'] == 1) { $confirmed = 'Confirmed'; } elseif ($subscriberinfo['confirmed'] == 0) { $confirmed = 'Unconfirmed'; } $GLOBALS['ConfirmedList'] = GetLang($confirmed); $GLOBALS['ShowUnsubscribeInfo'] = 'none'; $subscriber_status = 'a'; if ($subscriberinfo['unsubscribed'] > 0) { $subscriber_status = 'u'; $GLOBALS['unsubscribetime'] = $this->PrintTime($subscriberinfo['unsubscribed']); $GLOBALS['unsubscribeip'] = ($subscriberinfo['unsubscribeip'] == '') ? GetLang('Unknown') : $subscriberinfo['unsubscribeip']; $GLOBALS['ShowUnsubscribeInfo'] = ''; } if ($subscriberinfo['bounced'] > 0) { $subscriber_status = 'b'; } switch ($subscriber_status) { case 'a': $status = 'Active'; break; case 'u': $status = 'Unsubscribed'; break; case 'b': $status = 'Bounced'; break; default: } // this is used both by the 'edit' and 'delete' buttons. $GLOBALS['subscriberid'] = $subscriberid; if ($segmentid != 0) { $GLOBALS['SegmentID'] = $segmentid; $GLOBALS['ExtraParameter'] = '&SegmentID=' . $segmentid; } else { $GLOBALS['SegmentID'] = 0; $GLOBALS['ExtraParameter'] = ''; } $GLOBALS['EditButton'] = ''; if ($user->HasAccess('Subscribers', 'Edit')) { $GLOBALS['EditButton'] = $this->ParseTemplate('Subscribers_View_Button_Edit', true, false); } $GLOBALS['DeleteButton'] = ''; if ($user->HasAccess('Subscribers', 'Delete')) { $GLOBALS['DeleteButton'] = $this->ParseTemplate('Subscribers_View_Button_Delete', true, false); } $GLOBALS['StatusList'] = GetLang($status); $listformat = $list_api->GetListFormat(); if ($subscriberinfo['format'] == 'h') { $format = GetLang('Format_HTML'); } elseif ($subscriberinfo['format'] == 't') { $format = GetLang('Format_Text'); } $GLOBALS['FormatList'] = $format; $customfields = $list_api->GetCustomFields($listid); $customfield_display = array(); $customfieldinfo = ''; if (!empty($customfields)) { $customfields_api = $this->GetApi('CustomFields'); $customfieldinfo .= $this->ParseTemplate('Subscribers_Edit_Step2_CustomFields', true, false); foreach ($customfields as $pos => $customfield_info) { $GLOBALS['FieldID'] = $customfield_info['fieldid']; if ($customfield_info['required']) { $GLOBALS['Required'] = $this->ParseTemplate('Required', true, false); } else { $GLOBALS['Required'] = $this->ParseTemplate('Not_Required', true, false); } $subscriber_settings = $SubscriberApi->GetCustomFieldSettings($customfield_info['fieldid']); $customfields_api->fieldid = $customfield_info['fieldid']; $customfields_api->fieldtype = $customfield_info['fieldtype']; $subfield = $customfields_api->LoadSubField(); $GLOBALS['FieldName'] = htmlspecialchars($customfield_info['name'], ENT_QUOTES, SENDSTUDIO_CHARSET); $GLOBALS['FieldValue'] = htmlspecialchars($subfield->GetRealValue($subscriber_settings), ENT_QUOTES, SENDSTUDIO_CHARSET); switch ($customfield_info['fieldtype']) { case 'textarea': $template_name = 'Subscribers_View_CustomField_TextArea'; break; case 'date': $fieldsettings = unserialize($customfield_info['fieldsettings']); $GLOBALS['DateJSON'] = ''; $GLOBALS['GoogleCalendarButton'] = ''; if (strlen($GLOBALS['FieldValue'])) { $date = explode('/',$GLOBALS['FieldValue']); $datejson = array_combine(array_slice($fieldsettings['Key'],0,3),$date); $GLOBALS['DateJSON'] = GetJSON($datejson); if (strlen($user->googlecalendarusername) && strlen($user->googlecalendarpassword)) { $GLOBALS['GoogleCalendarButton'] = $this->ParseTemplate('google_calendar_button',true); } else { $GLOBALS['GoogleCalendarButton'] = $this->ParseTemplate('google_calendar_button_disabled',true); } } $template_name = 'Subscribers_View_CustomField_Date'; break; default: $template_name = 'Subscribers_View_CustomField'; } $customfield_display[] = $this->ParseTemplate($template_name, true, false); unset($subfield); } $column1 = $column2 = array(); if (count($customfield_display) > 9) { $customfieldinfo_template = 'Subscribers_customfieldinfo_twocolumns'; $split = ceil(count($customfield_display) / 2); for ($i = 0; $i < $split; $i++) { $column1[] = $customfield_display[$i]; if (isset($customfield_display[$i + $split])) { $column2[] = $customfield_display[$i + $split]; } else { $column2[] = '<td> </td><td> </td>'; } } $GLOBALS['CustomFieldInfo_1'] = '<tr>' . implode('</tr><tr>',$column1) . '</tr>'; $GLOBALS['CustomFieldInfo_2'] = '<tr>' . implode('</tr><tr>',$column2) . '</tr>'; } else { $customfieldinfo_template = 'Subscribers_customfieldinfo_onecolumn'; $GLOBALS['CustomFieldInfo_1'] = ''; foreach ($customfield_display as $field) { $GLOBALS['CustomFieldInfo_1'] .= '<tr>' . $field . '</tr>'; } } $GLOBALS['CustomFieldInfo'] = $customfieldinfo . $this->ParseTemplate($customfieldinfo_template,true); } $GLOBALS['listid'] = $listid; $actions = $user->GetEventActivityType(); $GLOBALS['Actions'] = ''; foreach ($actions as $action) { $GLOBALS['Actions'] .= '<option value="' . htmlspecialchars($action,ENT_QUOTES, SENDSTUDIO_CHARSET) . '">'. htmlspecialchars($action,ENT_QUOTES, SENDSTUDIO_CHARSET) . "</option>"; } $GLOBALS['EventTypesJSON'] = GetJSON($actions); $GLOBALS['EventAddForm'] = $this->ParseTemplate('Subscriber_Event_Add',true,false); $GLOBALS['DatePickerJavascript'] = $this->ParseTemplate('ui.datepicker.custom_iem',true,false); if (IEM::sessionGet('gcal_allday')) { $GLOBALS['GoogleCalendarAllDay'] = 'true'; } else { $GLOBALS['GoogleCalendarAllDay'] = 'false'; } $GLOBALS['SubscriberEvents_Intro'] = GetLang('SubscriberEvents_Intro'); if ($user->HasAccess('Subscribers','EventSave')) { $GLOBALS['SubscriberEvents_Intro'] .= GetLang('SubscriberEvents_Intro_AddEvent'); } $this->ParseTemplate('Subscribers_View_Step2'); }
/** * _getEditor * Returns an HTML string of the editor * @param User_API $userAPI Current user API * @param Segment_API $segmentAPI Segment to be displayed * @param Array $variables An associative array of the variables to be put in the editor * @return String Returns an HTML string * * @uses GetJSON() * @uses SendStudio_Functions::ParseTemplate() * @uses Segment::_getCustomFieldUsedByList() * @uses Segment::_getRuleNamesUsed() * @uses Segment::_getAvailableLinks() * @uses Segment::_getAvailableCampaigns() * @uses User_API::GetLists() */ function _getEditor($userAPI, $segmentAPI = null, $variables = array()) { $existingValues = array(); $listIDs = array(); /** * Set initial values if segment API is passed along */ if (!is_null($segmentAPI)) { $tempSearchInfo = $segmentAPI->searchinfo; $listIDs = $tempSearchInfo['Lists']; $variables['SegmentID'] = $segmentAPI->segmentid; $variables['SegmentName'] = htmlspecialchars($segmentAPI->segmentname, ENT_QUOTES, SENDSTUDIO_CHARSET); /** * Get rule and convert them to appropriate format accepted by the template */ $tempRules = array( 'ruleCache' => $this->_getCustomFieldUsedByList($listIDs), 'rules' => $segmentAPI->searchinfo['Rules'] ); // Get default values for each of the custom fields (if required) $tempRuleArray = $this->_getRuleNamesUsed($tempRules['rules']); if (in_array('link', $tempRuleArray)) { $tempRules['ruleCache']['values']['link'] = $this->_getAvailableLinks($userAPI, $listIDs); } if (in_array('campaign', $tempRuleArray)) { $tempRules['ruleCache']['values']['campaign'] = $this->_getAvailableCampaigns($userAPI); } $variables['InitialValues'] = addslashes(GetJSON($tempRules)); /** * ----- */ unset($variables['SegmentAPI']); } else { $variables['InitialValues'] = '{}'; } /** * ----- */ /** * Get mailing list from database and process list for display */ $tempList = $userAPI->GetLists(); $tempSelectList = ''; foreach ($tempList as $tempEach) { $tempSubscriberCount = intval($tempEach['subscribecount']); $GLOBALS['ListID'] = intval($tempEach['listid']); $GLOBALS['ListName'] = htmlspecialchars($tempEach['name'], ENT_QUOTES, SENDSTUDIO_CHARSET); $GLOBALS['OtherProperties'] = in_array($GLOBALS['ListID'], $listIDs)? ' selected="selected"' : ''; if ($tempSubscriberCount == 1) { $GLOBALS['ListSubscriberCount'] = GetLang('Subscriber_Count_One'); } else { $GLOBALS['ListSubscriberCount'] = sprintf(GetLang('Subscriber_Count_Many'), $this->FormatNumber($tempSubscriberCount)); } $tempSelectList .= $this->ParseTemplate('Segment_Form_ListRow', true); unset($GLOBALS['OtherProperties']); unset($GLOBALS['ListSubscriberCount']); unset($GLOBALS['ListName']); unset($GLOBALS['ListID']); } $variables['SelectListHTML'] = $tempSelectList; // If list is less than 10, use the following formula: list size * 25px for the height $tempCount = count($tempList); if ($tempCount <= 10) { if ($tempCount < 3) { $tempCount = 3; } $variables['SelectListStyle'] = 'height: ' . ($tempCount * 25) . 'px;'; } /** * ----- */ /** * Match type (is not used by the internal API anymore, but is still used * by the UI, so emulate this... It will be replaced by "grouping" in later version?? */ $variables['MatchType_AND'] = ' checked="checked"'; $variables['MatchType_OR'] = ''; If (!is_null($segmentAPI) && $segmentAPI->searchinfo['Rules'][0]['connector'] == 'or') { $variables['MatchType_AND'] = ''; $variables['MatchType_OR'] = ' checked="checked"'; } /** * */ //Get Common UI.DatePicker.Custom_IEM JavaScript $variables['CustomDatepickerUI'] = $this->ParseTemplate('UI.DatePicker.Custom_IEM', true); /** * Setup GLOBAL variable */ foreach ($variables as $key => $value) { if (array_key_exists($key, $GLOBALS)) { $existingValues[$key] = $GLOBALS[$key]; } $GLOBALS[$key] = $value; } /** * ----- */ $output = $this->ParseTemplate('Segment_Form', true); /** * Restore GLOBAL variable to it's original state */ foreach (array_keys($variables) as $key) { if (array_key_exists($key, $existingValues)) { $GLOBALS[$key] = $existingValues[$key]; } else { unset($GLOBALS[$key]); } } /** * ----- */ return $output; }