Exemplo n.º 1
0
 /**
  * printPage
  *
  * @return Void Doesn't return anything.
  */
 public function printPage()
 {
     $user = GetUser();
     $split_api = $this->GetApi('Splittest');
     // for permission checks
     $subaction = $this->_getGetRequest('subaction', 'print');
     $perpage = $this->_getGetRequest('PerPageDisplay', null);
     $jobids = $this->_getGETRequest('jobids', null);
     $listids = $this->_getGETRequest('split_statids', null);
     $jobids = explode(",", $jobids);
     $listids = explode(",", $listids);
     SendStudio_Functions::LoadLanguageFile('Stats');
     if (!SplitTest_API::OwnsJobs($user->Get('userid'), $jobids) && !$user->Admin()) {
         FlashMessage(GetLang('NoAccess'), SS_FLASH_MSG_ERROR, $this->base_url);
         return;
     }
     // Get some setup parameters for the API
     $sortdetails = array('sort' => 'splitname', 'direction' => 'asc');
     $page_number = 0;
     $perpage = 20;
     $displayAll = false;
     // just show a single splitest campaign send. If you want every campaign send for a split test set to true
     $dateFromat = self::getDateFormat();
     $statitics = array();
     $jobid = 0;
     for ($i = 0; $i < count($jobids); $i++) {
         $stats = array();
         $stats_api = new Splittest_Stats_API();
         $jobid = $jobids[$i];
         $splitid = $listids[$i];
         // get the array of stats data
         $stats = $stats_api->GetStats(array($splitid), $sortdetails, false, $page_number, $perpage, $displayAll, $jobid);
         foreach ($stats as $stats_id => $stats_details) {
             $stats[$stats_id]['splitname'] = htmlspecialchars($stats_details['splitname'], ENT_QUOTES, SENDSTUDIO_CHARSET);
             $stats[$stats_id]['campaign_names'] = htmlspecialchars($stats_details['campaign_names'], ENT_QUOTES, SENDSTUDIO_CHARSET);
             $stats[$stats_id]['list_names'] = htmlspecialchars($stats_details['list_names'], ENT_QUOTES, SENDSTUDIO_CHARSET);
         }
         // A Splittest can be sent multiple times hence we might have multiple campaign record sets here
         while (list($id, $data) = each($stats)) {
             $charts = $this->generateCharts($data['splitname'], $data['campaigns'], $subaction);
             foreach ($charts as $type => $data) {
                 $stats[$id][$type] = $data;
             }
         }
         $statistics[] = $stats;
     }
     $template = GetTemplateSystem(dirname(__FILE__) . '/templates');
     $template->Assign('DateFormat', $dateFromat);
     $template->Assign('statsData', $statistics);
     $template->Assign('subaction', $subaction);
     $options = $this->_getGETRequest('options', null);
     for ($i = 0; $i < count($options); $i++) {
         $template->Assign($options[$i], $options[$i]);
     }
     $template->ParseTemplate('Stats_Summary_Splittest');
 }
Exemplo n.º 2
0
/**
 * Created by PhpStorm.
 * User: sp
 * Date: 26/11/15
 * Time: 3:59 PM
 */
function GetMthodFileView($Data)
{
    include '../common/controller/user_get.php';
    include '../common/controller/file_get.php';
    $UserDetail = GetUser($Data);
    $Response = GetFile($UserDetail[0]['Username']);
    if ($Response["STATUS CODE"] == 903) {
        return "NoData";
    }
    return $Response['Payloads'];
}
Exemplo n.º 3
0
/**
 * Created by PhpStorm.
 * User: sp
 * Date: 24/11/15
 * Time: 4:37 AM
 */
function HandleFileRequest($Request)
{
    include '../common/config/ErrorCodes.php';
    include '../common/helpers/ValidateRequest.php';
    include '../common/controller/user_get.php';
    include '../common/controller/add_file.php';
    include '../common/controller/file_get.php';
    include '../common/controller/add_fav.php';
    include '../common/controller/Rename.php';
    if (validate_file_request($Request) == "True") {
        $UserDetail = GetUser($Request["payloads"]);
        if (isset($UserDetail[0]['Username'])) {
            $RequestData['Username'] = $UserDetail[0]['Username'];
            $RequestData['Time'] = time();
            switch ($Request["type"]) {
                case "PUT":
                    $RequestData['File'] = $Request['payloads']['File'];
                    $RequestData['Filename'] = $Request['payloads']['File'];
                    $RequestData['Type'] = $Request['payloads']['Type'];
                    $Res = AddFile($RequestData);
                    $Response = ReturnResponse($Res);
                    break;
                case "GET":
                    $Response = GetFile($RequestData['Username']);
                    break;
                case "FAV":
                    $RequestData['File'] = $Request['payloads']['File'];
                    $RequestData['Fav'] = $Request['payloads']['Fav'];
                    $Res = AddFav($RequestData);
                    $Response = ReturnResponse($Res);
                    break;
                case "RENAME":
                    $RequestData['File'] = $Request['payloads']['File'];
                    $RequestData['Filename'] = $Request['payloads']['Filename'];
                    $Res = RenameFile($RequestData);
                    $Response = ReturnResponse($Res);
                    break;
                default:
                    $Response = ReturnResponse(TYPE_NOT_SPECIFIED);
            }
            return $Response;
        } else {
            $Response = ReturnResponse(PAYLOAD_MISSING);
            $Response['info'] = "Could Not Get User";
            return $Response;
        }
    } else {
        $Response = ReturnResponse(PAYLOAD_MISSING);
        $Response['info'] = "Data verification failed";
        return $Request;
    }
}
Exemplo n.º 4
0
function CreateTopic($username, $topicname, $content, $sectionid, $topictype)
{
    $row = ExeSQLFirstRow("SELECT * FROM Topics WHERE Topicname='" . $topicname . "'");
    $okay = true;
    if ($row[0] == "") {
        ExeSQL("INSERT INTO Topics VALUES(NULL, " . $sectionid . ", -1, '" . $topicname . "', '" . $username . "', '" . $topictype . "', 0, now())") or exit;
        $row = ExeSQLFirstRow("SELECT * FROM Topics WHERE Topicname='" . $topicname . "'");
        ExeSQL("INSERT INTO Posts VALUES(NULL, " . $row[0] . ", '" . $username . "', now(), '" . $content . "')");
        $row = ExeSQLFirstRow("SELECT * FROM Posts WHERE TOPICID=" . $row[0]);
        ExeSQL("UPDATE ForumSection SET LASTPOSTID=" . $row[0] . ", Topiccount=Topiccount+1 WHERE INDEXID=" . $sectionid);
        $user = GetUser($username);
        $user->AddExp(Points::$createtopic);
        $user->CommitUpdate();
    } else {
        $okay = false;
    }
    return $okay;
}
Exemplo n.º 5
0
 /**
  * Process
  * Logs you out and redirects you back to the login page.
  * If you are automatically logged in,
  * this will also remove the cookie (sets the time back a year)
  * so you're not automatically logged in anymore.
  *
  * @see Login::Process
  * @see GetSession
  * @see Session::Set
  *
  * @return void
  */
 function Process()
 {
     $session =& GetSession();
     $sessionuser = $session->Get('UserDetails');
     $userid = $sessionuser->userid;
     $user =& GetUser($userid);
     $user->settings = $sessionuser->settings;
     $user->SaveSettings();
     unset($user);
     $session->Set('UserDetails', '');
     if (isset($_COOKIE['TrackPointLogin'])) {
         $oneyear = time() - 3600 * 265 * 24;
         setcookie('TrackPointLogin', '', $oneyear, '/');
     }
     $_SESSION = array();
     session_destroy();
     header('Location: ' . $_SERVER['PHP_SELF'] . '?Page=Login&Action=Logout');
 }
Exemplo n.º 6
0
	/**
	 * __construct
	 * Sets the base path where to look for language token files.
	 *
	 * @return Void Does not return anything.
	 */
	public function __construct()
	{
		$lang_folder = IEM_PATH . '/language';
		$user_lang_folder = 'default';

		// ----- Get user language preference
			$user = GetUser();
			$temp = $user->user_language;

			if (!empty($temp) && is_dir("{$lang_folder}/{$user_lang_folder}")) {
				$user_lang_folder = $temp;
			}

			unset($temp);
			unset($user);
		// -----

		$this->base_path = "{$lang_folder}/{$user_lang_folder}";
	}
Exemplo n.º 7
0
 /**
  * GetTextMenuItems
  * This checks the addon is installed & enabled before displaying in the 'tools' menu at the top of the page.
  *
  * @param EventData_IEM_SENDSTUDIOFUNCTIONS_GENERATETEXTMENULINKS $data The existing text menu items. This addon puts itself into the tools menu.
  *
  * @uses Load
  * @uses enabled
  *
  * @see SendStudio_Functions::GenerateTextMenuLinks
  *
  * @return Void The menu is passed in by reference, so it's manipulated directly.
  *
  * @uses EventData_IEM_SENDSTUDIOFUNCTIONS_GENERATETEXTMENULINKS
  */
 public static function GetTextMenuItems(EventData_IEM_SENDSTUDIOFUNCTIONS_GENERATETEXTMENULINKS $data)
 {
     $user = GetUser();
     if (!$user->Admin()) {
         return;
     }
     try {
         $me = new self();
         $me->Load();
     } catch (Exception $e) {
         return;
     }
     if (!$me->enabled) {
         return;
     }
     if (!isset($data->data['tools'])) {
         $data->data['tools'] = array();
     }
     $data->data['tools'][] = array('text' => GetLang('Addon_dbcheck_Menu_Text'), 'link' => $me->admin_url, 'description' => GetLang('Addon_dbcheck_Menu_Description'));
     unset($me);
 }
Exemplo n.º 8
0
 /**
  * GetTextMenuItems
  * This checks the addon is installed & enabled before displaying in the 'tools' menu at the top of the page.
  *
  * @param EventData_IEM_SENDSTUDIOFUNCTIONS_GENERATETEXTMENULINKS $data The existing text menu items. This addon puts itself into the tools menu.
  *
  * @uses Load
  * @uses enabled
  *
  * @see SendStudio_Functions::GenerateTextMenuLinks
  *
  * @return Void The menu is passed in by reference, so it's manipulated directly.
  *
  * @uses EventData_IEM_SENDSTUDIOFUNCTIONS_GENERATETEXTMENULINKS
  */
 static function GetTextMenuItems(EventData_IEM_SENDSTUDIOFUNCTIONS_GENERATETEXTMENULINKS $data)
 {
     $user = GetUser();
     if (!$user->Admin()) {
         return;
     }
     try {
         $me = new self();
         $me->Load();
     } catch (Exception $e) {
         return;
     }
     if (!$me->enabled) {
         return;
     }
     if (!isset($data->data['tools'])) {
         $data->data['tools'] = array();
     }
     $data->data['tools'][] = array('text' => GetLang('Addon_updatecheck_Menu_Text'), 'link' => "#\" onclick=\"tb_show('" . LNG_Addon_updatecheck_Check . "', 'index.php?Page=Addons&Addon=updatecheck&Ajax=true&keepThis=true&TB_iframe=true&height=80&width=300', '');", 'description' => GetLang('Addon_updatecheck_Menu_Description'));
     unset($me);
 }
Exemplo n.º 9
0
/**
 * Created by PhpStorm.
 * User: sp
 * Date: 24/11/15
 * Time: 4:37 AM
 */
function HandleUserRequest($Request)
{
    include '../common/controller/user_add.php';
    include '../common/controller/user_get.php';
    include '../common/config/ErrorCodes.php';
    include '../common/helpers/ValidateRequest.php';
    if (validate_userview_request($Request) == "True") {
        $Type = $Request["type"];
        $RequestData = $Request["payloads"];
        switch ($Type) {
            case "PUT":
                $Response["STATUS CODE"] = AddUser($RequestData);
                if ($Response["STATUS CODE"] == ERROR_DUP_NAME) {
                    $Response["SUCCESS"] = "False";
                } else {
                    $Response["Payloads"] = "User Added Successfully";
                }
                $Response["SUCCESS"] = "True";
                return $Response;
            case "GET":
                $Response["Payloads"] = GetUser($RequestData);
                if ($Response["Payloads"] == ERROR_DATA_NOT_FOUND) {
                    $Response["STATUS CODE"] = ERROR_DATA_NOT_FOUND;
                    $Response["SUCCESS"] = "False";
                    $Response['Payloads'] = "Authentication Error";
                } else {
                    $Response["SUCCESS"] = "True";
                    $Response["STATUS CODE"] = 200;
                }
                return $Response;
            default:
                return TYPE_NOT_SPECIFIED;
        }
    } else {
        $Response["SUCCESS"] = "False";
        $Response["STATUS CODE"] = PAYLOAD_MISSING;
        $Response["Payloads"] = "Payloads Missing";
        return $Response;
    }
}
Exemplo n.º 10
0
	/**
	* 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>&nbsp;</td><td>&nbsp;</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');
	}
Exemplo n.º 11
0
    $stmt->bindValue(':medium', $addMovie['medium'], SQLITE3_TEXT);
    $stmt->bindValue(':condition', $addMovie['condition'], SQLITE3_TEXT);
    $stmt->bindValue(':userId', $addMovie['userId'], SQLITE3_INTEGER);
    $r = $stmt->execute();
    $response['AddMovie'] = $r === FALSE ? false : $db->lastInsertRowID();
}
if (isset($payloadDecoded['Search'])) {
    $searchString = $payloadDecoded['Search'];
    $searchString = '%' . $searchString . '%';
    $stmt = $db->prepare('SELECT * FROM movies WHERE info LIKE :searchString');
    $stmt->bindValue(':searchString', $searchString, SQLITE3_TEXT);
    $r = $stmt->execute();
    $movies = array();
    while ($row = $r->fetchArray(SQLITE3_ASSOC)) {
        $row['info'] = json_decode($row['info'], true);
        $row['user'] = GetUser($row['user_id']);
        $movies[] = $row;
    }
    $response['Search'] = count($movies) > 0 ? $movies : false;
}
function GetUser($id)
{
    global $db;
    $stmt = $db->prepare('SELECT * FROM users WHERE id=:id');
    $stmt->bindValue(':id', $id, SQLITE3_INTEGER);
    $r = $stmt->execute();
    return $r->fetchArray(SQLITE3_ASSOC);
}
//-----------------------------------------------
// RESPONSE AND EXIT
//-----------------------------------------------
Exemplo n.º 12
0
 function PrintStep2($error = false)
 {
     if (!$error) {
         $session =& GetSession();
         $backupfile = $session->Get('BackupFilename');
         $link = str_replace(TRACKPOINT_BASE_DIRECTORY, TRACKPOINT_APPLICATION_URL, TEMP_DIRECTORY . '/' . $backupfile);
         $msg = 'Your database has been backed up successfully. You can download it from here: <a href="' . $link . '" target="_blank">' . $link . '</a>';
         $this->PrintUpgradeHeader('2', $msg);
         $this->StartUpgrade();
     } else {
         $user =& GetUser();
         $msg = 'Problem updating your database:<br/>' . urldecode($error) . '<br/>';
         $msg .= 'Please post a support ticket through http://www.interspire.com/clientarea and include the error message above.<br/>';
         $this->PrintUpgradeHeader('2', $msg);
     }
     $this->PrintUpgradeFooter();
 }
 /**
  * getTagsSize
  * This will return number of dynamic content tags
  *
  * @return int Return size of loaded dynamic content tags
  */
 public function getTagsSize()
 {
     $user = GetUser();
     $query = "SELECT COUNT(dct.tagid) AS tagsize FROM [|PREFIX|]dynamic_content_tags dct ";
     if (!$user->isAdmin()) {
         $query .= " WHERE dct.ownerid = '{$user->Get('userid')}' ";
     }
     $result = $this->db->Query($query);
     if ($row = $this->db->Fetch($result)) {
         return $row['tagsize'];
     }
     return 0;
 }
Exemplo n.º 14
0
    /**
     * Show_Send_Step_4
     * Step 4 handles two pieces of functionality:
     * - if cron support is enabled, it "approves" the job for sending and then redirects the user to the main splittest page
     *
     * If cron is not enabled, it processes and sends the emails out in popup mode.
     * It looks at the queues table for people to send to, and sends one email per window refresh.
     * It prints out a report of what's going on:
     * - how many have been sent
     * - how many left
     * - approx how long it has taken so far
     * - approx how long to go
     * - optional extra - pause after displaying that info and sending the email (based on user restrictions)
     *
     * @uses Jobs_API
     * @uses Jobs_API::ApproveJob
     * @uses Jobs_API::QueueSize
     * @uses CheckCronEnabled
     * @uses Splittest_Send_API::StartJob
     */
    public function Show_Send_Step_4()
    {
        $send_details = IEM::sessionGet('SplitTestSendDetails');
        if (!$send_details || !isset($send_details['splitid']) || (int) $send_details['splitid'] <= 0) {
            FlashMessage(GetLang('Addon_splittest_Send_InvalidSplitTest'), SS_FLASH_MSG_ERROR, $this->admin_url);
            return;
        }
        $jobid = $send_details['Job'];
        require_once SENDSTUDIO_API_DIRECTORY . '/jobs.php';
        $jobApi = new Jobs_API();
        if (isset($_GET['Start']) || self::CheckCronEnabled()) {
            /**
             * Remove the "cleanup" variables so we don't kill the send off when we either
             * - successfully schedule a send
             * - or start a send going.
             */
            IEM::sessionRemove('SplitTestSend_Cleanup');
            $user = GetUser();
            $jobApi->ApproveJob($jobid, $user->Get('userid'), $user->Get('userid'));
        }
        /**
         * If we get here and cron is enabled, we're finishing off a scheduled send setup.
         * Show a message and return the user to the manage screen.
         */
        if (self::CheckCronEnabled()) {
            FlashMessage(GetLang('Addon_splittest_Send_JobScheduled'), SS_FLASH_MSG_SUCCESS, $this->admin_url);
            return;
        }
        $this->template_system->Assign('AdminUrl', $this->admin_url, false);
        $send_api = $this->GetApi('Splittest_Send');
        if (isset($_GET['Start'])) {
            $send_api->StartJob($jobid, $send_details['splitid']);
        }
        $sendqueue = $jobApi->GetJobQueue($jobid);
        $job = $jobApi->LoadJob($jobid);
        $send_api->Set('statids', $send_details['Stats']);
        $send_api->Set('jobdetails', $job['jobdetails']);
        $send_api->Set('jobowner', $job['ownerid']);
        $queuesize = $jobApi->QueueSize($sendqueue, 'splittest');
        $send_details['SendQueue'] = $sendqueue;
        $timenow = $send_api->GetServerTime();
        $timediff = $timenow - $send_details['SendStartTime'];
        $time_so_far = $this->TimeDifference($timediff);
        $num_left_to_send = $send_details['SendSize'] - $queuesize;
        if ($num_left_to_send > 0) {
            $timeunits = $timediff / $num_left_to_send;
            $timediff = $timeunits * $queuesize;
        } else {
            $timediff = 0;
        }
        $timewaiting = $this->TimeDifference($timediff);
        $this->template_system->Assign('SendTimeSoFar', sprintf(GetLang('Addon_splittest_Send_Step4_TimeSoFar'), $time_so_far));
        $this->template_system->Assign('SendTimeLeft', sprintf(GetLang('Addon_splittest_Send_Step4_TimeLeft'), $timewaiting));
        if ($num_left_to_send == 1) {
            $this->template_system->Assign('Send_NumberAlreadySent', GetLang('Addon_splittest_Send_Step4_NumberSent_One'));
        } else {
            $this->template_system->Assign('Send_NumberAlreadySent', sprintf(GetLang('Addon_splittest_Send_Step4_NumberSent_Many'), $this->PrintNumber($num_left_to_send)));
        }
        if ($queuesize <= 0) {
            require_once SENDSTUDIO_API_DIRECTORY . '/ss_email.php';
            $email = new SS_Email_API();
            if (SENDSTUDIO_SAFE_MODE) {
                $email->Set('imagedir', TEMP_DIRECTORY . '/send');
            } else {
                $email->Set('imagedir', TEMP_DIRECTORY . '/send.' . $jobid . '.' . $sendqueue);
            }
            $email->CleanupImages();
            $send_details['SendEndTime'] = $send_api->GetServerTime();
            IEM::sessionSet('SplitTestSendDetails', $send_details);
            $this->template_system->Assign('Send_NumberLeft', GetLang('Addon_splittest_Send_Step4_SendFinished'));
            $this->template_system->ParseTemplate('send_step4');
            ?>
				<script>
					window.opener.focus();
					window.opener.document.location = '<?php 
            echo $this->admin_url . '&Action=Send&Step=5';
            ?>
';
					window.close();
				</script>
			<?php 
            return;
        }
        if ($queuesize == 1) {
            $this->template_system->Assign('Send_NumberLeft', GetLang('Addon_splittest_Send_Step4_NumberLeft_One'));
        } else {
            $this->template_system->Assign('Send_NumberLeft', sprintf(GetLang('Addon_splittest_Send_Step4_NumberLeft_Many'), $this->PrintNumber($queuesize)));
        }
        $send_api->SetupJob($jobid, $sendqueue);
        $send_api->SetupNewsletter();
        $recipients = $send_api->FetchFromQueue($sendqueue, 'splittest', 1, 1);
        $send_api->SetupDynamicContentFields($recipients);
        $send_api->SetupCustomFields($recipients);
        $sent_ok = false;
        foreach ($recipients as $p => $recipientid) {
            $send_results = $send_api->SendToRecipient($recipientid, $sendqueue);
            // save the info in the session, then see if we need to pause between each email.
            if ($send_results['success'] > 0) {
                $sent_ok = true;
                $send_details['EmailResults']['success']++;
            } else {
                $send_details['EmailResults']['failure']++;
            }
            $send_details['EmailResults']['total']++;
            IEM::sessionSet('SplitTestSendDetails', $send_details);
        }
        session_write_close();
        $this->template_system->ParseTemplate('send_step4');
        // we should only need to pause if we successfully sent.
        if ($sent_ok) {
            $send_api->Pause();
        }
    }
Exemplo n.º 15
0
 /**
  * userTimestamp
  * When provided with a GMT Unix timestamp, it will return a timestamp
  * adjusted for the user's timezone, taking into account the server's
  * timezone offset.
  *
  * @see fixTimestamp
  *
  * @param Int|String $gmt_ts A valid GMT timestamp.
  *
  * @return Int A timestamp that has been adjusted with the current user's timezone offset.
  */
 private static function userTimestamp($gmt_ts)
 {
     if (!$gmt_ts) {
         return 0;
     }
     $user = GetUser();
     // User timezone offset (seconds).
     $user_offset = $user->Get('usertimezone');
     // "GMT-11:30"
     $user_offset = substr($user_offset, 3);
     // "-11:30"
     $user_offset = str_replace(':3', '.5', $user_offset);
     // "-11.50"
     $user_offset = str_replace(':', '.', $user_offset);
     $user_offset = floatval($user_offset);
     // -11.5
     $user_offset = $user_offset * 60 * 60;
     // to seconds
     $server_offset = date('Z');
     return intval($gmt_ts) + ($user_offset - $server_offset);
 }
Exemplo n.º 16
0
if ($autoresponder) {
	$subscriberinfo['autoresponder'] = $autoresponder;
}


$listAPI = $sendstudio_functions->GetApi('Lists');
$company = $listAPI->getCompanyDetails($list);
$subscriberinfo = array_merge($subscriberinfo, $company);

$emailapi->AddCustomFieldInfo($friendsemail, $subscriberinfo);
$emailapi->SetSmtp(SENDSTUDIO_SMTP_SERVER, SENDSTUDIO_SMTP_USERNAME, @base64_decode(SENDSTUDIO_SMTP_PASSWORD), SENDSTUDIO_SMTP_PORT);

/**
* See if the user has an smtp server set.
*/
$user = GetUser($formapi->ownerid);
if ($user->smtpserver) {
	$emailapi->SetSmtp($user->smtpserver, $user->smtpusername, $user->smtppassword, $user->smtpport);
}

$emailapi->TrackLinks(false);
$emailapi->ForceLinkChecks(false);
$emailapi->TrackOpens(false);

$emailapi->DisableUnsubscribe(true);

$emailapi->Set('CharSet', SENDSTUDIO_CHARSET);
$mail_result = $emailapi->Send(true);

/**
* Record the forward for statistical purposes.
	/**
	* ProcessJob
	* Processes an autoresponder queue
	* Checks a queue for duplicates, makes sure the queue is present and has recipients in it and then calls ActionJob to handle the rest
	*
	* @param Int $queueid Autoresponder queue to process. This is passed to ActionJob
	*
	* @see GetUser
	* @see RemoveDuplicatesInQueue
	* @see QueueSize
	* @see ActionJob
	* @see UnprocessQueue
	*
	* @return True Always returns true
	*/
	function ProcessJob($queueid=0)
	{
		$queueid = (int)$queueid;

		$this->user = GetUser($this->jobowner);
		IEM::userLogin($this->jobowner, false);

		$queuesize = $this->QueueSize($queueid, 'autoresponder');

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

		$jobid_query = "SELECT jobid FROM " . SENDSTUDIO_TABLEPREFIX . "jobs WHERE queueid='" . $queueid . "'";
		$jobid_result = $this->Db->Query($jobid_query);
		$jobid = $this->Db->FetchOne($jobid_result, 'jobid');

		if (!$jobid) {
			if ($this->Debug) {
				error_log(time() . "\t" . __FILE__ . "\t" . __LINE__ . "\t" . "no jobid (result " . gettype($jobid_result) . "; " . $jobid_result . ")" . "\n", 3, $this->LogFile);
				error_log(time() . "\t" . __FILE__ . "\t" . __LINE__ . "\t" . "Returning" . "\n", 3, $this->LogFile);
			}
			IEM::userLogout();
			return true;
		}

		$timenow = $this->GetServerTime();
		$query = "UPDATE " . SENDSTUDIO_TABLEPREFIX . "jobs SET lastupdatetime=" . $timenow . " WHERE jobid='" . $jobid . "'";
		$update_job_result = $this->Db->Query($query);

		if ($queuesize <= 0) {
			if ($this->Debug) {
				error_log(time() . "\t" . __FILE__ . "\t" . __LINE__ . "\t" . "Deleting job " . $jobid . " and then returning" . "\n", 3, $this->LogFile);
			}
			$this->Db->Query("DELETE FROM " . SENDSTUDIO_TABLEPREFIX . "jobs WHERE jobid='" . $jobid . "'");
			IEM::userLogout();
			return true;
		}

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

		$finished = $this->ActionJob($queueid, $jobid);

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

		// we need to turn 'processed' emails back to normal so we can check them next time.
		$this->UnprocessQueue($queueid);

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

		$this->Db->Query('DELETE FROM ' . SENDSTUDIO_TABLEPREFIX . 'jobs_lists WHERE jobid=' . intval($jobid));
		$this->Db->Query("DELETE FROM " . SENDSTUDIO_TABLEPREFIX . "jobs WHERE jobid=" . intval($jobid));

		IEM::userLogout();
		return true;
	}
Exemplo n.º 18
0
	/**
	 * EditList
	 * Loads the list and displays it for editing.
	 *
	 * @see GetApi
	 * @see List_API::Load
	 * @see List_API::GetAllFormats
	 *
	 * @param Array $param Any parameters that needed to be passed into this function
	 *
	 * @return String The form for the list to be edited.
	 */
	private function EditList($param)
	{
		$listid = (isset($_GET['id'])) ? (int)$_GET['id'] : 0;
		if ($listid <= 0) {
			$GLOBALS['ErrorMessage'] = GetLang('ListDoesntExist');
			$this->DenyAccess();
			return;
		}

		$list = $this->GetApi();
		if (!$list->Load($listid)) {
			$GLOBALS['ErrorMessage'] = GetLang('ListDoesntExist');
			$this->DenyAccess();
			return;
		}

		$user = GetUser();
		if (!$user->HasAccess('Lists', 'Edit')) {
			$this->DenyAccess();
			return;
		}

		$GLOBALS['Action'] = 'Update&id=' . $listid;
		$GLOBALS['CancelButton'] = GetLang('EditListCancelButton');
		$GLOBALS['Heading'] = GetLang('EditMailingList');
		$GLOBALS['Intro'] = GetLang('EditMailingListIntro');
		$GLOBALS['ListDetails'] = GetLang('EditMailingListHeading');

		$GLOBALS['Name'] = htmlspecialchars($list->name, ENT_QUOTES, SENDSTUDIO_CHARSET);
		$GLOBALS['OwnerName'] = htmlspecialchars($list->ownername, ENT_QUOTES, SENDSTUDIO_CHARSET);
		$GLOBALS['OwnerEmail'] = htmlspecialchars($list->owneremail, ENT_QUOTES, SENDSTUDIO_CHARSET);
		$GLOBALS['ReplyToEmail'] = htmlspecialchars($list->replytoemail, ENT_QUOTES, SENDSTUDIO_CHARSET);

		$GLOBALS['CompanyName'] = htmlspecialchars($list->companyname, ENT_QUOTES, SENDSTUDIO_CHARSET);
		$GLOBALS['CompanyAddress'] = htmlspecialchars($list->companyaddress, ENT_QUOTES, SENDSTUDIO_CHARSET);
		$GLOBALS['CompanyPhone'] = htmlspecialchars($list->companyphone, ENT_QUOTES, SENDSTUDIO_CHARSET);

		$GLOBALS['NotifyOwner'] = ($list->notifyowner) ? ' CHECKED' : '';

		if ($user->HasAccess('Lists', 'BounceSettings')) {
			$GLOBALS['ShowBounceInfo'] = '';

			$GLOBALS['BounceEmail'] = htmlspecialchars($list->bounceemail, ENT_QUOTES, SENDSTUDIO_CHARSET);
			$GLOBALS['Bounce_Server'] = htmlspecialchars($list->bounceserver, ENT_QUOTES, SENDSTUDIO_CHARSET);
			$GLOBALS['Bounce_Username'] = htmlspecialchars($list->bounceusername, ENT_QUOTES, SENDSTUDIO_CHARSET);
			$GLOBALS['Bounce_Password'] = htmlspecialchars($list->bouncepassword, ENT_QUOTES, SENDSTUDIO_CHARSET);

			$GLOBALS['DisplayExtraMailSettings'] = 'none';
			if ($list->extramailsettings) {
				$GLOBALS['DisplayExtraMailSettings'] = '';
				$GLOBALS['Bounce_ExtraOption'] = ' ';
				$GLOBALS['Bounce_ExtraSettings'] = htmlspecialchars($list->extramailsettings, ENT_QUOTES, SENDSTUDIO_CHARSET);
			}

			$GLOBALS['Imap_Selected'] = $GLOBALS['Pop3_Selected'] = '';
			if ($list->imapaccount) {
				$GLOBALS['Imap_Selected'] = ' SELECTED ';
			} else {
				$GLOBALS['Pop3_Selected'] = ' SELECTED ';
			}

			$GLOBALS['ProcessBounceChecked'] = ($list->processbounce == 1)? ' CHECKED' : '';
			$GLOBALS['Bounce_AgreeDeleteAll'] = ($list->agreedeleteall == 1)? ' CHECKED' : '';
		} else {
			$GLOBALS['ShowBounceInfo'] = 'none';
			$GLOBALS['DisplayExtraMailSettings'] = 'none';

			$GLOBALS['BounceEmail'] = '*****@*****.**';
		}


		$customfields_api = $this->GetApi('CustomFields');
		$user_customfields = $customfields_api->GetCustomFields($list->Get('ownerid'), array(), false, 0, 0);
		$list_customfields = $list->GetCustomFields($listid);

		$temp = array_diff(array_keys($list_customfields), array_keys($user_customfields));
		foreach ($temp as $each) {
			if (!array_key_exists($each, $user_customfields)) {
				$user_customfields[$each] = $list_customfields[$each];
			}
		}

		$availablefields = '';
		foreach ($user_customfields as $row => $fielddetails) {
			$availablefields .= '<option value="' . $fielddetails['fieldid'] . '"';
			$selected = false;
			if (in_array($fielddetails['fieldid'], $list->customfields)) {
				$selected = true;
			}
			if ($selected) {
				$availablefields .= ' SELECTED';
			}
			$availablefields .= '>' . htmlspecialchars($fielddetails['name'], ENT_QUOTES, SENDSTUDIO_CHARSET) . '</option>';
		}

		$GLOBALS['AvailableFields'] = $availablefields;

		$visiblefields = '';
		$buildinfields = $this->BuiltinFields;
		$allfields = 0;

		$fields = explode(',',$list->visiblefields);

		foreach ($buildinfields as $key => $name) {
			++$allfields;
			$visiblefields .= '<option value="' . $key . '"';

			if (in_array($key,$fields)) {
				$visiblefields .= ' selected="selected"';
			}

			$visiblefields .= '>' . htmlspecialchars(GetLang($name),ENT_QUOTES, SENDSTUDIO_CHARSET) . '</option>';
		}

		foreach ($list_customfields as $key => $details) {
			++$allfields;
			$visiblefields .= '<option value="' . $details['fieldid'] . '"';

			if (in_array($details['fieldid'],$fields)) {
				$visiblefields .= ' selected="selected"';
			}

			$visiblefields .= '>' . htmlspecialchars($details['name'],ENT_QUOTES, SENDSTUDIO_CHARSET) . '</option>';
		}

		$GLOBALS['VisibleFields'] = $visiblefields;

		$this->SetVisibleFieldsHeight($allfields);

		return $this->ParseTemplate('Lists_Form', true);
	}
Exemplo n.º 19
0
	/**
	 * CanAccessAutoresponder
	 * Returns true if the current user is allowed access to the autoresponder.
	 *
	 * @param Int $id The ID of the autoresponder.
	 *
	 * @return Boolean True if the current user is allowed to access the autoresponder, otherwise false.
	 */
	function CanAccessAutoresponder($id)
	{
		$user = GetUser();
		if (!$user->HasAccess('statistics', 'autoresponder')) {
			return false;
		}
		$api = $this->GetApi('Autoresponders');
		if (!$api->Load($id)) {
			return false;
		}
		$list_id = $api->listid;
		return $this->CanAccessList($list_id);
	}
Exemplo n.º 20
0
/**
* AdjustTime
* Adjusts the time based on the users timezone and the server timezone.
*
* @see GetUser
* @see User_API::UserTimeZone
* @see SENDSTUDIO_SERVERTIMEZONE
* @see ConvertDate
*
* @return Int The adjusted timestamp.
*/
function AdjustTime($time = 0, $convert_to_gmt = true, $date_format = '', $from_servertime = false)
{
    $user = GetUser();
    if (!is_object($user)) {
        return false;
    }
    if (!isset($GLOBALS['DateConverter'])) {
        $GLOBALS['DateConverter'] = new ConvertDate(SENDSTUDIO_SERVERTIMEZONE, $user->Get('usertimezone'));
    }
    if ($convert_to_gmt) {
        if ((int) $time < 0) {
            $time = 0;
        }
        if ($time == 0) {
            $timenow = getdate();
            $hr = $timenow['hours'];
            $min = $timenow['minutes'];
            $sec = $timenow['seconds'];
            $mon = $timenow['mon'];
            $day = $timenow['mday'];
            $yr = $timenow['year'];
            return $GLOBALS['DateConverter']->ConvertToGMTFromServer($hr, $min, $sec, $mon, $day, $yr);
        }
        $hr = $time[0];
        $min = $time[1];
        $sec = $time[2];
        $mon = $time[3];
        $day = $time[4];
        $yr = $time[5];
        if ($from_servertime) {
            return $GLOBALS['DateConverter']->ConvertToGMTFromServer($hr, $min, $sec, $mon, $day, $yr);
        }
        return $GLOBALS['DateConverter']->ConvertToGMT($hr, $min, $sec, $mon, $day, $yr);
    }
    return $GLOBALS['DateConverter']->ConvertFromGMT($time, $date_format);
}
Exemplo n.º 21
0
 /**
  * Admin_Action_Default
  * Displays the list of surveys, with pagination, and all the CRUD options.
  *
  * @return Void Returns nothing
  */
 public function Admin_Action_Default()
 {
     $this->Admin_Action_PreConfig();
     $me = self::LoadSelf();
     $surveyid = 0;
     if (isset($_REQUEST['id'])) {
         $surveyid = (int) $_REQUEST['id'];
     }
     $api = self::getApi();
     $user = GetUser();
     $me->template_system->Assign('Add_Button', $me->template_system->ParseTemplate('add_survey_button', true), false);
     $me->template_system->Assign('Delete_Button', $me->template_system->ParseTemplate('delete_survey_button', true), false);
     $me->template_system->Assign('FlashMessages', GetFlashMessages(), false);
     $numsurveys = $api->GetSurveys($user->userid, 0, 0, array(), array(), true);
     if ($numsurveys == 0) {
         $me->template_system->ParseTemplate('manage_surveys_empty');
         return;
     }
     $sort_details = array('SortBy' => 'name', 'Direction' => 'asc');
     if (isset($_GET['SortBy']) && in_array(strtolower(IEM::requestGetGET('SortBy')), Addons_survey_api::$validSorts)) {
         $sort_details['SortBy'] = strtolower(IEM::requestGetGET('SortBy'));
     }
     if (in_array(strtolower(IEM::requestGetGET('Direction')), array('up', 'down'))) {
         $direction = strtolower(IEM::requestGetGET('Direction'));
         if ($direction == 'up') {
             $sort_details['Direction'] = 'asc';
         } else {
             $sort_details['Direction'] = 'desc';
         }
     }
     $perpage = $me->GetPerPage();
     if (empty($perpage)) {
         $perpage = (int) IEM::requestGetGET('PerPageDisplay');
     }
     $me->SetPerPage($perpage);
     $page = (int) IEM::requestGetGET('DisplayPage');
     if ($page < 1) {
         $page = 1;
     }
     $paging = $me->SetupPaging($me->admin_url, $numsurveys);
     $me->template_system->Assign('Paging', $paging, false);
     $search_info = array();
     $surveys = $api->GetSurveys($user->userid, $page, $perpage, $search_info, $sort_details, false);
     $survey_rows = '';
     foreach ($surveys as $survey) {
         $me->template_system->Assign('name', $survey['name']);
         $me->template_system->Assign('surveyid', $survey['id']);
         $me->template_system->Assign('created', AdjustTime($survey['created'], false, GetLang('DateFormat'), true));
         if (isset($survey['updated'])) {
             $me->template_system->Assign('updated', AdjustTime($survey['updated'], false, GetLang('DateFormat'), true));
         } else {
             $me->template_system->Assign('updated', GetLang('Addon_Surveys_Default_NeverUpdated'), false);
         }
         // Number of response to be zero first..
         // now lets geat each number of response..
         $me->template_system->Assign('numresponses', $survey['responseCount']);
         if (empty($survey['responseCount'])) {
             $view_results = GetLang('Addon_Surveys_Default_Table_ViewResults');
             $export_responses = GetLang('Addon_Surveys_Default_Table_ExportResponses');
         } else {
             $view_results = '<a href="' . $me->admin_url . '&Action=result&surveyId=' . $survey['id'] . '">' . GetLang('Addon_Surveys_Default_Table_ViewResults') . '</a>';
             $export_responses = '<a href="' . $me->admin_url . '&Action=Export&ajax=1&surveyId=' . $survey['id'] . '">' . GetLang('Addon_Surveys_Default_Table_ExportResponses') . '</a>';
         }
         $me->template_system->Assign('view_results', $view_results, false);
         $me->template_system->Assign('export_responses', $export_responses, false);
         $editlink = '<a href="' . $me->admin_url . '&Action=Edit&formId=' . $survey['id'] . '">' . GetLang('Edit') . '</a>';
         $me->template_system->Assign('edit_link', $editlink, false);
         $deletelink = '<a class=\'deleteButton\' href="' . $me->admin_url . '&Action=Delete&id=' . $survey['id'] . '">' . GetLang('Delete') . '</a>';
         $me->template_system->Assign('delete_link', $deletelink, false);
         $previewlink = '<a target="_blank" href="' . SENDSTUDIO_APPLICATION_URL . '/surveys.php?id=' . $survey['id'] . '">' . GetLang('Preview') . '</a>';
         $me->template_system->Assign('preview_link', $previewlink, false);
         $survey_rows .= $me->template_system->ParseTemplate('manage_surveys_row', true);
     }
     $me->template_system->Assign('Items', $survey_rows, false);
     $me->template_system->ParseTemplate('manage_surveys');
 }
Exemplo n.º 22
0
/**
 * Created by PhpStorm.
 * User: sp
 * Date: 24/11/15
 * Time: 4:37 AM
 */
function HandleFileRequest($Request)
{
    include '../common/config/ErrorCodes.php';
    include '../common/helpers/ValidateRequest.php';
    include '../common/controller/user_get.php';
    include '../common/controller/add_file.php';
    include '../common/controller/file_get.php';
    include '../common/controller/add_fav.php';
    include '../common/controller/Rename.php';
    if (validate_file_request($Request) == "True") {
        $Type = $Request["type"];
        $Data = $Request["payloads"];
        $Username = GetUser($Data);
        if (isset($Username[0]['Username'])) {
            $username = $Username[0]['Username'];
            $RequestData['Username'] = $username;
            $RequestData['File'] = $Data['File'];
            $RequestData['Filename'] = $Data['File'];
            $RequestData['Type'] = $Data['Type'];
            $RequestData['Time'] = time();
            switch ($Type) {
                case "PUT":
                    $Response["STATUS CODE"] = AddFile($RequestData);
                    if ($Response["STATUS CODE"] == ERROR_DUP_NAME) {
                        $Response["SUCCESS"] = "False";
                        $Response["Message"] = "Something Went Wrong";
                    } else {
                        $Response["SUCCESS"] = "True";
                        $Response["Message"] = "File Added Successfully";
                    }
                    return $Response;
                case "GET":
                    $Response["Payloads"] = GetFile($RequestData['Username']);
                    if ($Response["Payloads"] == ERROR_DATA_NOT_FOUND) {
                        $Response["STATUS CODE"] = ERROR_DATA_NOT_FOUND;
                        $Response["SUCCESS"] = "False";
                        $Response['Payloads'] = "No Files To Display";
                    } else {
                        $Response["SUCCESS"] = "True";
                        $Response["STATUS CODE"] = 200;
                    }
                    return $Response;
                case "FAV":
                    $RequestData['Fav'] = $Data['Fav'];
                    $Response["Payloads"] = AddFav($RequestData);
                    if ($Response["Payloads"] == ERROR_DATA_NOT_FOUND) {
                        $Response["STATUS CODE"] = ERROR_DATA_NOT_FOUND;
                        $Response["SUCCESS"] = "False";
                        $Response['Payloads'] = "Authentication Error";
                    } else {
                        $Response["SUCCESS"] = "True";
                        $Response["STATUS CODE"] = 200;
                    }
                    return $Response;
                case "RENAME":
                    $Response["Payloads"] = RenameFile($RequestData);
                    if ($Response["Payloads"] == ERROR_DATA_NOT_FOUND) {
                        $Response["STATUS CODE"] = ERROR_DATA_NOT_FOUND;
                        $Response["SUCCESS"] = "False";
                        $Response['Payloads'] = "Authentication Error";
                    } else {
                        $Response["SUCCESS"] = "True";
                        $Response["STATUS CODE"] = 200;
                    }
                    return $Response;
                default:
                    return TYPE_NOT_SPECIFIED;
            }
        } else {
            $Response["SUCCESS"] = "False";
            $Response["STATUS CODE"] = PAYLOAD_MISSING;
            $Response["Payloads"] = "Payload Does Not Exists";
        }
    } else {
        $Response["SUCCESS"] = "False";
        $Response["STATUS CODE"] = PAYLOAD_MISSING;
        $Response["Payloads"] = "Invalid Json";
        return $Response;
    }
}
	/**
	* ImportSubscribers_Step2
	* Prints out step 2 of importing subscribers where you choose the type you're importing from, the "enclosed by", "separator" fields etc.
	*
	* @param Mixed $msg If there is a message passed in, it will print that message and then print out the form.
	*
	* @see GetApi
	* @see Lists_API::Load
	* @see Lists_API::GetListFormat
	* @see _getImportFileOptions
	*
	* @return Void Prints out the form, doesn't return anything.
	*/
	function ImportSubscribers_Step2($msg=false)
	{

		$GLOBALS['fieldenclosed'] = $this->DefaultFieldEnclosed;
		$GLOBALS['fieldseparator'] = $this->DefaultFieldSeparator;

		if ($msg) {
			$GLOBALS['Error'] = $msg;
			$GLOBALS['Message'] = $this->ParseTemplate('ErrorMsg', true, false);

			if (isset($_POST['FieldEnclosed'])) {
				$GLOBALS['fieldenclosed'] = $_POST['FieldEnclosed'];
			}

			if (isset($_POST['FieldSeparator'])) {
				$GLOBALS['fieldseparator'] = $_POST['FieldSeparator'];
			}
		}

		$importinfo = IEM::sessionGet('ImportInfo');

		$importtypes = '';
		foreach ($this->_ImportTypes as $pos => $importtype) {
			$importtypes .= '<option value="' . $importtype . '">' . GetLang('Import_From_' . $importtype) . '</option>';
		}
		$GLOBALS['ImportTypes'] = $importtypes;

		$listApi = $this->GetApi('Lists');
		$listApi->Load($importinfo['List']);
		$listformat = $listApi->GetListFormat();

		$importinfo['ListFormat'] = $listformat;
		IEM::sessionSet('ImportInfo', $importinfo);

		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':
				$format = '<option value="h" SELECTED>' . GetLang('Format_HTML') . '</option>';
				$format .= '<option value="t">' . GetLang('Format_Text') . '</option>';
			break;
		}
		$GLOBALS['ListFormats'] = $format;

		// if we're not running a recent version of php, don't show the "enclosed by" field at all.
		// will save some confusion!
		$phpversion = phpversion();
		$version_check = version_compare($phpversion, '4.3.0');
		$GLOBALS['ShowFieldEnclosed'] = '';
		if ($version_check < 0) {
			$GLOBALS['ShowFieldEnclosed'] = 'none';
		}

		$GLOBALS['ShowAutoresponderImport'] = 'none';

		$user = GetUser();

		if ($user->HasAccess('Autoresponders')) {
			$GLOBALS['ShowAutoresponderImport'] = '';
		}

		// Get file list (ie scan directory) for uploaded import file
		$GLOBALS['fieldServerFiles'] = $this->_getImportFileOptions(SENDSTUDIO_IMPORT_DIRECTORY);
		$this->ParseTemplate('Subscribers_Import_Step2');
	}
Exemplo n.º 24
0
	/**
	* RemoveCustomFields
	* Takes an array of customfield id's to remove from the database. It checks whether you are the owner of the custom field or if you are an admin user. If you are neither, you can't delete the field.
	*
	* @param Array $fields An array of fields the user wants to remove.
	*
	* @see GetUser
	* @see User_API::HasAccess
	* @see DenyAccess
	* @see GetAPI
	* @see CustomFields_API::Load
	* @see CustomFields_API::Delete
	* @see ManageCustomFields
	*
	* @return Void Doesn't return anything. Prints out the appropriate message based on what happened.
	*/
	function RemoveCustomFields($fields=array())
	{
		$user = GetUser();
		if (!$user->HasAccess('CustomFields', 'Delete')) {
			$this->DenyAccess();
			return;
		}

		if (!is_array($fields)) {
			$fields = array($fields);
		}

		$fields_api = $this->GetApi();

		$removed = 0; $notremoved = 0;
		$not_removed_errors = array();
		foreach ($fields as $pos => $fieldid) {
			$loaded = $fields_api->Load($fieldid);
			if (!$loaded) {
				continue;
			}
			if (!$user->Admin() && $user->Get('userid') != $fields_api->Get('ownerid')) {
				$not_removed_errors[$fieldid] = sprintf(GetLang('CannotDeleteCustomField_NoAccess'), $fields_api->Settings['FieldName']);
				$notremoved++;
				continue;
			}
			$status = $fields_api->Delete($fieldid);
			if ($status) {
				$removed++;
			} else {
				$notremoved++;
			}
		}

		$msg = '';

		if ($notremoved > 0) {
			if (empty($not_removed_errors)) {
				if ($notremoved == 1) {
					$GLOBALS['Error'] = GetLang('CustomFieldDeleteFail_One');
				} else {
					$GLOBALS['Error'] = sprintf(GetLang('CustomFieldDeleteFail_Many'), $this->FormatNumber($notremoved));
				}
				$msg .= $this->ParseTemplate('ErrorMsg', true, false);
			} else {
				foreach ($not_removed_errors as $fieldid => $message) {
					$GLOBALS['Error'] = $message;
					$msg .= $this->ParseTemplate('ErrorMsg', true, false);
				}
			}
		}

		if ($removed > 0) {
			if ($removed == 1) {
				$msg .= $this->PrintSuccess('CustomFieldDeleteSuccess_One');
			} else {
				$msg .= $this->PrintSuccess('CustomFieldDeleteSuccess_Many', $this->FormatNumber($removed));
			}
		}
		$GLOBALS['Message'] = $msg;

	  $this->ManageCustomFields();
	}
Exemplo n.º 25
0
	/**
	* DeleteUsers
	* Deletes a list of users from the database via the api. Each user is checked to make sure you're not going to accidentally delete your own account and that you're not going to delete the 'last' something (whether it's the last active user, admin user or other).
	* If you aren't an admin user, you can't do anything at all.
	*
	* @param integer[] $users An array of userid's to delete
	* @param boolean $deleteData Whether or not to delete data owned by user along
	*
	* @see GetUser
	* @see User_API::UserAdmin
	* @see DenyAccess
	* @see CheckUserSystem
	* @see PrintManageUsers
	*
	* @return Void Doesn't return anything. Works out the relevant message about who was/wasn't deleted and prints that out. Returns control to PrintManageUsers.
	*/
	function DeleteUsers($users = array(), $deleteData = false)
	{
		$thisuser = GetUser();
		if (!$thisuser->UserAdmin()) {
			$this->DenyAccess();
			return;
		}

		if (!is_array($users)) {
			$users = array($users);
		}

		$not_deleted_list = array();
		$not_deleted = $deleted = 0;
		foreach ($users as $p => $userid) {
			if ($userid == $thisuser->Get('userid')) {
				$not_deleted++;
				$not_deleted_list[$userid] = array('username' => $thisuser->Get('username'), 'reason' => GetLang('User_CantDeleteOwn'));
				continue;
			}

			$error = $this->CheckUserSystem($userid);
			if (!$error) {
				$result = API_USERS::deleteRecordByID($userid, $deleteData);

				if ($result) {
					$deleted++;
				} else {
					$not_deleted++;
					$user = GetUser($userid);
					if ($user instanceof User_API) {
						$not_deleted_list[$userid] = array('username' => $user->Get('username'), 'reason' => '');
					} else {
						$not_deleted_list[$userid] = array('username' => $userid, 'reason' => '');
					}
				}
			} else {
				$not_deleted++;
				$user = GetUser($userid);
				if ($user instanceof User_API) {
					$not_deleted_list[$userid] = array('username' => $user->Get('username'), 'reason' => $error);
				} else {
					$not_deleted_list[$userid] = array('username' => $userid, 'reason' => $error);
				}
			}
		}


		if ($not_deleted > 0) {
			foreach ($not_deleted_list as $uid => $details) {
				FlashMessage(sprintf(GetLang('UserDeleteFail'), htmlspecialchars($details['username'], ENT_QUOTES, SENDSTUDIO_CHARSET), htmlspecialchars($details['reason'], ENT_QUOTES, SENDSTUDIO_CHARSET)), SS_FLASH_MSG_ERROR);
			}
		}

		if ($deleted > 0) {
			if ($deleted == 1) {
				FlashMessage(GetLang('UserDeleteSuccess_One'), SS_FLASH_MSG_SUCCESS, IEM::urlFor('Users'));
			} else {
				FlashMessage(sprintf(GetLang('UserDeleteSuccess_Many'), $this->FormatNumber($deleted)), SS_FLASH_MSG_SUCCESS, IEM::urlFor('Users'));
			}
		}

		IEM::redirectTo('Users');
	}
	/**
	* AddSubscriber_Step2
	* Prints out the 'add subscriber' form. Prints out custom fields to add, sets default options and so on.
	*
	* @param Int $listid Listid to add the subscriber to.
	* @param Boolean $clear_post Whether to clear post information or not before pre-filling the form. This is used when the user chooses "Save & Add".
	*
	* @see GetApi
	* @see Lists_API::Load
	* @see Lists_API::GetCustomFields
	* @see Lists_API::GetListFormat
	*
	* @return Void Prints out the form and doesn't return anything.
	*/
	function AddSubscriber_Step2($listid=0, $clear_post=false)
	{
		$user = GetUser();
		$access = $user->HasAccess('Subscribers', 'Manage');
		if (!$access) {
			$this->DenyAccess();
			return;
		}

		$lists = $user->GetLists();
		$num_lists = sizeof(array_keys($lists));

		if ($num_lists > 1) {
			$GLOBALS['SaveExitButton'] = $this->ParseTemplate('Subscribers_Add_Save_Exit_Button', true, false);
		}

		if (isset($_POST['emailaddress']) && !$clear_post) {
			$GLOBALS['emailaddress'] = htmlspecialchars($_POST['emailaddress']);
			$formatoption_chosen = $_POST['format'];
			$confirmoption_chosen = $_POST['confirmed'];
		} else {
			$GLOBALS['emailaddress'] = '';
			$formatoption_chosen = 'h';
			$confirmoption_chosen = '1';
		}

		$GLOBALS['list'] = $listid;

		$confirmed = '';
		foreach (array('1' => 'Confirmed', '0' => 'Unconfirmed') as $confirmoption => $option) {
			$selected = ($confirmoption == $confirmoption_chosen) ? ' SELECTED' : '';
			$confirmed .= '<option value="' . $confirmoption . '"' . $selected . '>' . GetLang($option) . '</option>';
		}

		$GLOBALS['ConfirmedList'] = $confirmed;

		$list_api = $this->GetApi('Lists');
		$list_api->Load($listid);

		$GLOBALS['Heading'] = sprintf(GetLang('Subscribers_Add_Step2'), htmlspecialchars($list_api->Get('name'), ENT_QUOTES, SENDSTUDIO_CHARSET));
		$customfields = $list_api->GetCustomFields($listid);

		$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':
				$format = '<option value="h"' . (($formatoption_chosen == 'h') ? ' SELECTED' : '' ) . '>' . GetLang('Format_HTML') . '</option>';
				$format .= '<option value="t"' . (($formatoption_chosen == 't') ? ' SELECTED' : '' ) . '>' . GetLang('Format_Text') . '</option>';
			break;
		}

		$GLOBALS['FormatList'] = $format;

		$extra_javascript = '';
		$customfield_display = array();
		$customfieldinfo = '';

		if (!empty($customfields)) {
			$customfieldinfo = $this->ParseTemplate('Subscribers_Add_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);
				}

				$defaultvalue = $customfield_info['defaultvalue'];

				if (!$clear_post) {
					if (isset($_POST['CustomFields'][$customfield_info['fieldid']])) {
						$defaultvalue = $_POST['CustomFields'][$customfield_info['fieldid']];
					}
				}

				switch ($customfield_info['fieldtype']) {
					case 'date':
						$optionlist = '';
						$this->Display_CustomField($customfield_info,$defaultvalue);
					break;

					case 'radiobutton':
						$fieldsettings = (is_array($customfield_info['fieldsettings'])) ? $customfield_info['fieldsettings'] : unserialize($customfield_info['fieldsettings']);

						$optionlist = '';
						$c = 1;
						foreach ($fieldsettings['Key'] as $pos => $key) {
							$selected = '';
							if (!$clear_post && isset($_POST['CustomFields'][$customfield_info['fieldid']])) {
								$chosen_values = array($_POST['CustomFields'][$customfield_info['fieldid']]);
								if (in_array($key, $chosen_values)) {
									$selected = ' CHECKED';
								}
							} else {
								if ($key == $customfield_info['defaultvalue']) {
									$selected = ' CHECKED';
								}
							}

							$label_id = htmlspecialchars('CustomFields_' . $customfield_info['fieldid'].'_'.$c, 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'), $customfield_info['name']) . '");
									return false;
								}
							';
						}

					break;

					case 'dropdown':
						$fieldsettings = (is_array($customfield_info['fieldsettings'])) ? $customfield_info['fieldsettings'] : unserialize($customfield_info['fieldsettings']);
						$optionlist = '';

						$optionlist .= '<option value="">' . $customfield_info['defaultvalue'] . '</option>';

						foreach ($fieldsettings['Key'] as $pos => $key) {
							$selected = '';
							if ($key == $defaultvalue) {
								$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'), $customfield_info['name']) . '");
									fld.focus();
									return false;
								}
							';
						}

					break;

					case 'checkbox':
						$fieldsettings = (is_array($customfield_info['fieldsettings'])) ? $customfield_info['fieldsettings'] : unserialize($customfield_info['fieldsettings']);

						$chosen_values = array();
						if (isset($_POST['CustomFields'][$customfield_info['fieldid']]) && !$clear_post) {
							$chosen_values = $_POST['CustomFields'][$customfield_info['fieldid']];
						}

						$optionlist = '';
						$c = 1;
						foreach ($fieldsettings['Key'] as $pos => $key) {
							$checked = '';

							if (in_array($key, $chosen_values)) {
								$checked = ' 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) . '"' . $checked . '>' . 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:
						$optionlist = '';

						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;
								}
							';
						}

				}
				$GLOBALS['OptionList'] = $optionlist;
				if (!is_array($defaultvalue)) {
					$GLOBALS['DefaultValue'] = htmlspecialchars($defaultvalue, 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>&nbsp;</td><td>&nbsp;</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['CustomDatepickerUI'] = $this->ParseTemplate('UI.DatePicker.Custom_IEM', true);
		$this->ParseTemplate('Subscribers_Add_Step2');
	}
	/**
	 * CanAccessList
	 * Checks whether the current user can access a particular contact list.
	 *
	 * @param Int $list_id The ID of the contact list.
	 *
	 * @return Boolean True if the user can access the list, otherwise false.
	 */
	function CanAccessList($list_id)
	{
		$user = GetUser();

		if ($user->Admin()) {
			return true;
		}

		$allowed_lists = $user->GetLists();
		if (is_array($allowed_lists)) {
			$allowed_lists = array_keys($allowed_lists);
			if (in_array($list_id, $allowed_lists)) {
				return true;
			}
		}

		return false;
	}
Exemplo n.º 28
0
 /**
  * CheckUserSystem
  * Checks that the user you're editing or deleting isn't the last 'X' in the system.
  *
  * @param userid Userid to check. Must pass in a userid to check.
  * @param to_check Area(s) to check.
  *
  * @see GetUser
  * @see User_API::LastAdminUser
  * @see User_API::LastActiveUser
  * @see User_API::LastUser
  *
  * @return mixed Returns false if there is no error, otherwise returns the appropriate error message depending on what you're checking.
  */
 function CheckUserSystem($userid = 0, $to_check = array('LastActiveUser', 'LastUser', 'LastAdminUser'))
 {
     $return_error = false;
     $user_system =& GetUser($userid);
     if (in_array('LastAdminUser', $to_check)) {
         if (!$return_error && $user_system->LastAdminUser()) {
             $return_error = GetLang('LastAdminUser');
         }
     }
     if (in_array('LastActiveUser', $to_check)) {
         if ($user_system->LastActiveUser()) {
             $return_error = GetLang('LastActiveUser');
         }
     }
     if (in_array('LastUser', $to_check)) {
         if (!$return_error && $user_system->LastUser()) {
             $return_error = GetLang('LastUser');
         }
     }
     return $return_error;
 }
Exemplo n.º 29
0
    /**
     * DisplayEditNewsletter
     * Prints out the editor for stage 2 of editing a newsletter (the wysiwyg area or textarea depending on the format chosen in stage 1). If you have selected a template in the previous step, the content from that template will be displayed here.
     *
     * @param Int $newsletterid Newsletter to load up. If there is one, it will pre-load that content. If there is no newsletterid, it displays a blank area to create your content.
     *
     * @see CreateNewsletter
     * @see EditNewsletter
     * @see GetApi
     * @see Newsletter_API::Load
     * @see Newsletter_API::GetBody
     * @see GetAttachments
     * @see FetchEditor
     *
     * @return Void Prints out the form, doesn't return anything.
     */
    function DisplayEditNewsletter($newsletterid=0) {
        $newsletter = $this->GetApi();
        $newslettercontents = array('text' => '', 'html' => '');

        $user = GetUser();

        $GLOBALS['FromPreviewEmail'] = $user->Get('emailaddress');

        $GLOBALS['DisplayAttachmentsHeading'] = 'none';

        $tpl = GetTemplateSystem();


        if ($newsletterid > 0) {
            $GLOBALS['SaveAction'] = 'Edit&SubAction=Save&id=' . $newsletterid;
            $GLOBALS['Heading'] = GetLang('EditNewsletter');
            $GLOBALS['Intro'] = GetLang('EditNewsletterIntro_Step2');
            $GLOBALS['Action'] = 'Edit&SubAction=Complete&id=' . $newsletterid;
            $GLOBALS['CancelButton'] = GetLang('EditNewsletterCancelButton');

            $newsletter->Load($newsletterid);
            $GLOBALS['IsActive'] = ($newsletter->Active()) ? ' CHECKED' : '';
            $GLOBALS['Archive'] = ($newsletter->Archive()) ? ' CHECKED' : '';
            $newslettercontents['text'] = $newsletter->GetBody('text');
            $newslettercontents['html'] = $newsletter->GetBody('html');

            $GLOBALS['Subject'] = htmlspecialchars($newsletter->subject, ENT_QUOTES, SENDSTUDIO_CHARSET);
        } else {
            $GLOBALS['SaveAction'] = 'Create&SubAction=Save&id=' . $newsletterid;
            $GLOBALS['Heading'] = GetLang('CreateNewsletter');
            $GLOBALS['Intro'] = GetLang('CreateNewsletterIntro_Step2');
            $GLOBALS['Action'] = 'Create&SubAction=Complete';
            $GLOBALS['CancelButton'] = GetLang('CreateNewsletterCancelButton');

            $GLOBALS['IsActive'] = ' CHECKED';
            $GLOBALS['Archive'] = ' CHECKED';
        }

        if (!SENDSTUDIO_ALLOW_ATTACHMENTS) {
            $tpl->Assign('ShowAttach', false);
            $GLOBALS['DisplayAttachments'] = 'none';
            $user = IEM::getCurrentUser();
            if ($user) {
                if ($user->isAdmin()) {
                    $GLOBALS['AttachmentsMsg'] = GetLang('NoAttachment_Admin');
                } else {
                    $GLOBALS['AttachmentsMsg'] = GetLang('NoAttachment_User');
                }
            }
        } else {
            $tpl->Assign('ShowAttach', true);
            $attachmentsarea = strtolower(get_class($this));
            $attachments_list = $this->GetAttachments($attachmentsarea, $newsletterid);
            $GLOBALS['AttachmentsList'] = $attachments_list;
        }

        $GLOBALS['PreviewID'] = $newsletterid;
        // we don't really need to get/set the stuff here.. we could use references.
        // if we do though, it segfaults! so we get and then set the contents.
        $session_newsletter = IEM::sessionGet('Newsletters');
        $session_newsletter['id'] = (int) $newsletterid;

        if (isset($session_newsletter['TemplateID'])) {
            $templateApi = $this->GetApi('Templates');
            if (is_numeric($session_newsletter['TemplateID'])) {
                $templateApi->Load($session_newsletter['TemplateID']);
                $newslettercontents['text'] = $templateApi->textbody;
                $newslettercontents['html'] = $templateApi->htmlbody;
            } else {
                $newslettercontents['html'] = $templateApi->ReadServerTemplate($session_newsletter['TemplateID']);
            }
            unset($session_newsletter['TemplateID']);
        }

        $session_newsletter['contents'] = $newslettercontents;
        IEM::sessionSet('Newsletters', $session_newsletter);
        $editor = $this->FetchEditor();
        $GLOBALS['Editor'] = $editor;

        $user = GetUser();
        if ($user->group->forcespamcheck) {
            $GLOBALS['ForceSpamCheck'] = 1;
        }

        $tpl->ParseTemplate('Newsletter_Form_Step2');
    }
Exemplo n.º 30
0
	/**
	* Copy
	* Copy segment details
	*
	* @param Int $segmentID Segment ID to copy.
	*
	* @return Array Returns an array of status (whether the copy worked or not) and a message to go with it. If the copy worked, then the message is the new ID.
	*/
	function Copy($segmentID)
	{
		$segmentID = intval($segmentID);
		if ($segmentID <= 0) {
			return array(false, 'No ID');
		}

		if (!$this->Load($segmentID)) {
			return array(false, 'Unable to load segment to be copied.');
		}

		$currentuser = GetUser();

		$this->segmentname = GetLang('CopyPrefix') . $this->segmentname;
		$this->ownerid = $currentuser->userid;
		$this->createdate = AdjustTime();

		$status = $this->Create();
		if (!$status) {
			return array(false, 'Unable to create new segment');
		}

		return array(true, $this->segmentid);
	}